Skip to content

Commit

Permalink
my stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
emccorson committed Oct 31, 2023
1 parent d0dd325 commit 9741f1b
Show file tree
Hide file tree
Showing 20 changed files with 743 additions and 127 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use flake
CC=emcc
36 changes: 18 additions & 18 deletions .github/workflows/deploy-wallet-at-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ jobs:
REACT_APP_NAMADA_CHAIN_ID: "internal-devnet-6be.86067e06a5"
REACT_APP_NAMADA_URL: "https://proxy.heliax.click/internal-devnet-6be.86067e06a5"

- name: Deploy to Netlify
if: false
uses: nwtgck/[email protected]
with:
publish-dir: "./apps/namada-interface/build"
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Merged PR ${{ github.event.number }} to main"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN_WALLET_PREVIEW }}
NETLIFY_SITE_ID: 2380782e-9b20-477a-bc27-b4e9d05e16f3

- name: Slack Notification
run: |
curl --header "Content-Type: application/json" \
--request POST \
--data '{"message":"https://wallet-preview-heliax-dev.netlify.app"}' \
${{ secrets.SLACK_WEBHOOK_WALLET_RELEASE }}
#- name: Deploy to Netlify
# if: false
# uses: nwtgck/[email protected]
# with:
# publish-dir: "./apps/namada-interface/build"
# production-branch: main
# github-token: ${{ secrets.GITHUB_TOKEN }}
# deploy-message: "Merged PR ${{ github.event.number }} to main"
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN_WALLET_PREVIEW }}
# NETLIFY_SITE_ID: 2380782e-9b20-477a-bc27-b4e9d05e16f3

#- name: Slack Notification
# run: |
# curl --header "Content-Type: application/json" \
# --request POST \
# --data '{"message":"https://wallet-preview-heliax-dev.netlify.app"}' \
# ${{ secrets.SLACK_WEBHOOK_WALLET_RELEASE }}

rust-unit-test-js-cache:
runs-on: ubuntu-latest
Expand Down
53 changes: 21 additions & 32 deletions .github/workflows/deploy-wallet-at-pr.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
name: Deploy wallet preview to netlify at PR and pushes to it
on:
pull_request:
paths:
- "apps/namada-interface/**"
- "apps/extension/**"
- "packages/integrations/**"
- "packages/rpc/**"
- "packages/shared/**"
- "packages/tx/**"
- "packages/utils/**"
- "packages/wallet/**"
- "packages/wasm/**"
- ".github/workflows/**"
push:

env:
CI: false
Expand Down Expand Up @@ -143,26 +132,26 @@ jobs:
REACT_APP_NAMADA_ALIAS: "Namada Devnet"
REACT_APP_NAMADA_CHAIN_ID: "internal-devnet-6be.86067e06a5"
REACT_APP_NAMADA_URL: "https://proxy.heliax.click/internal-devnet-6be.86067e06a5"
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: "./apps/namada-interface/build"
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "deploy ${{ github.event.number }} at creating a PR"
alias: pull-request-${{ github.event.number }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN_WALLET_PREVIEW }}
NETLIFY_SITE_ID: 1f548c68-c620-4522-97e0-0d85c08366fb
# namada.me
# NETLIFY_SITE_ID: 2380782e-9b20-477a-bc27-b4e9d05e16f3

- name: Slack Notification
run: |
curl --header "Content-Type: application/json" \
--request POST \
--data '{"message":"New deployment for a PR\nhttps://pull-request-${{ github.event.number }}--wallet-development-heliax-dev.netlify.app\n \nthe PR\nhttps://github.com/anoma/namada-interface/pull/${{ github.event.number }}"}' \
${{ secrets.SLACK_WEBHOOK_WALLET_PR }}
#- name: Deploy to Netlify
# uses: nwtgck/[email protected]
# with:
# publish-dir: "./apps/namada-interface/build"
# production-branch: main
# github-token: ${{ secrets.GITHUB_TOKEN }}
# deploy-message: "deploy ${{ github.event.number }} at creating a PR"
# alias: pull-request-${{ github.event.number }}
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN_WALLET_PREVIEW }}
# NETLIFY_SITE_ID: 1f548c68-c620-4522-97e0-0d85c08366fb
# # namada.me
# # NETLIFY_SITE_ID: 2380782e-9b20-477a-bc27-b4e9d05e16f3

#- name: Slack Notification
# run: |
# curl --header "Content-Type: application/json" \
# --request POST \
# --data '{"message":"New deployment for a PR\nhttps://pull-request-${{ github.event.number }}--wallet-development-heliax-dev.netlify.app\n \nthe PR\nhttps://github.com/anoma/namada-interface/pull/${{ github.event.number }}"}' \
# ${{ secrets.SLACK_WEBHOOK_WALLET_PR }}
E2E-tests:
needs: build
timeout-minutes: 60
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ target/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

masp-params/*.params
.direnv/
trees/
4 changes: 4 additions & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
build
*.lock
trees
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,21 @@ export const SeedPhraseImport: React.FC<Props> = ({ onConfirm, requester }) => {
const [mnemonicLength, setMnemonicLength] = useState(SHORT_PHRASE_COUNT);
const mnemonicsRange = Array.from(Array(mnemonicLength).keys());
const [mnemonics, setMnemonics] = useState<string[]>(
mnemonicsRange.map(() => "")
//mnemonicsRange.map(() => "")
[
"column",
"banana",
"aunt",
"acquire",
"dolphin",
"fruit",
"fever",
"rent",
"dawn",
"divert",
"book",
"amateur",
]
);
const isSubmitButtonDisabled = mnemonics.some((mnemonic) => !mnemonic);

Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/background/keyring/keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export class KeyRing {
return { path, info: accountInfo, balances };
};

while (index < 999999999 && emptyBalanceCount < 20) {
while (index < 999999999 && emptyBalanceCount < 1) {
const { path, info, balances } = await get(index++);
const hasBalance = balances.some(([, value]) => {
return !new BigNumber(value).isZero();
Expand Down
29 changes: 29 additions & 0 deletions apps/namada-interface/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Specify the following if you wish to override the defaults defined in @anoma/chains:

# NAMADA
REACT_APP_NAMADA_ALIAS=Namada Testnet
REACT_APP_NAMADA_CHAIN_ID=dev-test.42324e8e5d09b566a0700
REACT_APP_NAMADA_URL=http://127.0.0.1:27657
REACT_APP_NAMADA_BECH32_PREFIX=atest
REACT_APP_NAMADA_FAUCET_ADDRESS=atest1v4ehgw368pprgvjygv652w2yg3znvd69xucnvde3xaz5ysenx5myx3f389z5yv3nxg65xv3kx0fkez
REACT_APP_NAMADA_FAUCET_LIMIT=1000

# COSMOS
REACT_APP_COSMOS_ALIAS=Cosmos Testnet
REACT_APP_COSMOS_CHAIN_ID=cosmoshub-4
REACT_APP_COSMOS_URL=https://rpc.sentry-01.theta-testnet.polypore.xyz

# OSMOSIS
REACT_APP_OSMOSIS_ALIAS=Osmosis Testnet
REACT_APP_OSMOSIS_CHAIN_ID=osmosis-testnet.123412341234
REACT_APP_OSMOSIS_URL=http://127.0.0.1:54321

# ETH
REACT_APP_ETH_ALIAS=Eth Testnet
REACT_APP_ETH_CHAIN_ID="0x7A69"
REACT_APP_ETH_URL=http://127.0.0.1:12345

# ETH smart contracts
CONTRACT_ADDR_ETH_BRIDGE="0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"

MASP_PARAMS_PATH=http://127.0.0.1:8080
2 changes: 1 addition & 1 deletion apps/namada-interface/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/.pnp
.pnp.js
/build
.env
#.env
# Ignore parts of the lib/anoma artifact
# Everything else will be tracked in repo to speed up CI builds
/lib/anoma/.gitignore
Expand Down
2 changes: 1 addition & 1 deletion e2e/genesis.toml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ max_signatures_per_transaction = 15
max_validator_slots = 128
# Pipeline length (in epochs). Any change in the validator set made in
# epoch 'n' will become active in epoch 'n + pipeline_len'.
pipeline_len = 0
pipeline_len = 2
# Unbonding length (in epochs). Validators may have their stake slashed
# for a fault in epoch 'n' up through epoch 'n + unbonding_len'.
unbonding_len = 0
Expand Down
4 changes: 4 additions & 0 deletions e2e/namada.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAMADA_BIN_DIR="$HOME/src/namada/target/debug"
NAMADA_BASE_DIR=".namada/basedir"

$NAMADA_BIN_DIR/namada --base-dir $NAMADA_BASE_DIR "$@"
82 changes: 16 additions & 66 deletions e2e/setup-namada.sh
Original file line number Diff line number Diff line change
@@ -1,66 +1,20 @@
#!/bin/bash -x
#!/usr/bin/env bash

VERSION="v0.23.0"
CURRENT_VERSION=""
NAMADA_DIR=".namada"
NAMADA_DIR="$HOME/src/namada"
NAMADA_BIN_DIR="${NAMADA_DIR}/target/debug"
NAMADA_BASE_DIR=".namada/basedir"
OS="Linux"

(cd $NAMADA_DIR && nix develop -c make build)

if [[ $OSTYPE == "darwin"* ]]; then
OS="Darwin"
fi

# Read current version
CURRENT_VERSION_PATH="${NAMADA_DIR}/.version"
if test -f "$CURRENT_VERSION_PATH"; then
while read -r line;
do
CURRENT_VERSION=$line

done < "$CURRENT_VERSION_PATH"
fi

if [ "$CURRENT_VERSION" != "$VERSION" ]; then
# Download Namada binaries
FILENAME="namada-${VERSION}-${OS}-x86_64.tar.gz"
curl --location --remote-header-name --remote-name https://github.com/anoma/namada/releases/download/${VERSION}/${FILENAME}
mkdir $NAMADA_DIR
tar -xzf ${FILENAME} --directory $NAMADA_DIR --strip-components 1
rm -rf ${FILENAME}

# Download wasm checksums
curl --location --remote-header-name --remote-name https://raw.githubusercontent.com/anoma/namada/${VERSION}/wasm/checksums.json
mv checksums.json "${NAMADA_DIR}/checksums.json"

# Download masp params
curl --location --remote-header-name --remote-name https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-output.params
curl --location --remote-header-name --remote-name https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-convert.params
curl --location --remote-header-name --remote-name https://github.com/anoma/masp-mpc/releases/download/namada-trusted-setup/masp-spend.params
mv masp-*.params "${NAMADA_DIR}"

# Download wasms
CHECKSUMS="${NAMADA_DIR}/checksums.json"
WASM=""
S3="https://namada-wasm-master.s3.eu-west-1.amazonaws.com"

rm -rf "${NAMADA_DIR}/wasm"
mkdir "${NAMADA_DIR}/wasm"

while read -r line;
do
WASM=$(echo "$line" | sed -E "s/\".+\":[[:space:]]\"//g" | sed -E "s/\".*//g");
curl "${S3}/${WASM}" --output "${NAMADA_DIR}/wasm/${WASM}"

done < "$CHECKSUMS"

# Save version
echo "${VERSION}" > "${NAMADA_DIR}/.version"
fi

# Clear the basedir
rm -rf $NAMADA_BASE_DIR

"${NAMADA_DIR}/namadac" --base-dir $NAMADA_BASE_DIR utils init-network \
"${NAMADA_BIN_DIR}/namadac" --base-dir $NAMADA_BASE_DIR utils init-network \
--chain-prefix dev-test \
--wasm-checksums-path "${NAMADA_DIR}/checksums.json" \
--genesis-path genesis.toml \
Expand All @@ -71,7 +25,7 @@ CONFIG="${NAMADA_BASE_DIR}/global-config.toml"
CHAIN_ID=""

# Read CHAIN_ID from global-config.toml
while read -r line;
while read -r line;
do
CHAIN_ID=$(echo "$line" | sed "s/default_chain_id = \"//g" | sed "s/\"//");

Expand All @@ -81,18 +35,14 @@ done < "$CONFIG"
cp -f ${NAMADA_DIR}/wasm/*.wasm ${NAMADA_BASE_DIR}/${CHAIN_ID}/setup/validator-0/.namada/${CHAIN_ID}/wasm/
cp -f ${NAMADA_DIR}/wasm/*.wasm ${NAMADA_BASE_DIR}/${CHAIN_ID}/wasm/

echo "Replacing CHAIN_ID: $CHAIN_ID"
# Override envs - so we do not have to rebuild extension and app
if [[ $OS == "Darwin" ]]; then
LC_ALL=C find ../apps/extension/build/chrome -type f -name "*.js" -exec sed -i "" -E "s/dev-test\..{21}/$CHAIN_ID/g" {} +
LC_ALL=C find ../apps/namada-interface/build -type f -name "*.js" -exec sed -i "" -E "s/dev-test\..{21}/$CHAIN_ID/g" {} +
else
find ../apps/extension/build/chrome -type f -name "*.js" -exec sed -i -E "s/dev-test\..{21}/$CHAIN_ID/g" {} +
find ../apps/namada-interface/build -type f -name "*.js" -exec sed -i -E "s/dev-test\..{21}/$CHAIN_ID/g" {} +
fi

echo "Fixing CORS"
find .namada/basedir -type f -name "config.toml" -exec sed -i -E "s/cors_allowed_origins[[:space:]]=[[:space:]]\[\]/cors_allowed_origins = [\"*\"]/g" {} +
find $NAMADA_BASE_DIR -type f -name "config.toml" -exec sed -i -E "s/cors_allowed_origins[[:space:]]=[[:space:]]\[\]/cors_allowed_origins = [\"*\"]/g" {} +

#echo "Moving MASP params"
#cp -t $NAMADA_BIN_DIR ../masp-params/*.params

echo "Writing chain ID to .env"
sed -i -E "s/(REACT_APP_NAMADA_CHAIN_ID=).*/\1$CHAIN_ID/" ../apps/namada-interface/.env

echo "Moving MASP params"
cp .namada/masp-*.params ../apps/namada-interface/build/assets
echo "Copying wallet"
cp ${NAMADA_BASE_DIR}/${CHAIN_ID}/setup/other/wallet.toml ${NAMADA_BASE_DIR}/${CHAIN_ID}
2 changes: 1 addition & 1 deletion e2e/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const getExtensionId = async (browser: puppeteer.Browser): Promise<string> => {
};

export const openInterface = async (page: puppeteer.Page): Promise<void> => {
await page.goto("http://localhost:8080", {
await page.goto("http://localhost:3000", {
waitUntil: ["domcontentloaded"],
});
};
Expand Down
17 changes: 12 additions & 5 deletions e2e/start-namada.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#!/bin/bash -x
#!/usr/bin/env bash

NAMADA_DIR=".namada"
NAMADA_BASE_DIR=".namada/basedir"
CURRENT_DIR=$(pwd)

NAMADA_DIR="$HOME/src/namada"
NAMADA_BASE_DIR="$CURRENT_DIR/.namada/basedir"

CONFIG="${NAMADA_BASE_DIR}/global-config.toml"
CHAIN_ID=""

# Read CHAIN_ID from global-config.toml
while read -r line;
while read -r line;
do
CHAIN_ID=$(echo "$line" | sed "s/default_chain_id = \"//g" | sed "s/\"//");

done < "$CONFIG"

# Start the chain
NAMADA_LOG=debug "${NAMADA_DIR}/namadan" --chain-id ${CHAIN_ID} --base-dir ${NAMADA_BASE_DIR}/${CHAIN_ID}/setup/validator-0/.namada ledger
(
cd $NAMADA_DIR
NAMADA_LOG=debug ENV_VAR_MASP_PARAMS_DIR=$CURRENT_DIR/../masp-params \
nix develop -c ./target/debug/namadan --chain-id ${CHAIN_ID} --base-dir ${NAMADA_BASE_DIR}/${CHAIN_ID}/setup/validator-0/.namada ledger
)
Loading

0 comments on commit 9741f1b

Please sign in to comment.