diff --git a/algorand/sandbox-algorand/images/algod/Dockerfile b/algorand/sandbox-algorand/images/algod/Dockerfile index e3d43a51cb..d65373a364 100644 --- a/algorand/sandbox-algorand/images/algod/Dockerfile +++ b/algorand/sandbox-algorand/images/algod/Dockerfile @@ -39,7 +39,7 @@ COPY . /tmp RUN /tmp/images/algod/install.sh \ -d "${BIN_DIR}" \ -u "https://github.com/algorand/go-algorand" \ - -b "v3.6.2-stable" \ + -b "v3.9.2-stable" \ -s "" # Configure network diff --git a/algorand/sandbox-algorand/images/indexer/Dockerfile b/algorand/sandbox-algorand/images/indexer/Dockerfile index 8bddd4e266..de9b3ab628 100644 --- a/algorand/sandbox-algorand/images/indexer/Dockerfile +++ b/algorand/sandbox-algorand/images/indexer/Dockerfile @@ -29,6 +29,7 @@ COPY images/indexer/start.sh /tmp/start.sh COPY images/indexer/install.sh /tmp/install.sh # Install indexer binaries. + RUN /tmp/install.sh CMD ["/tmp/start.sh"] diff --git a/algorand/sandbox-algorand/images/indexer/install.sh b/algorand/sandbox-algorand/images/indexer/install.sh index 6f06ff1480..9415b4a51d 100755 --- a/algorand/sandbox-algorand/images/indexer/install.sh +++ b/algorand/sandbox-algorand/images/indexer/install.sh @@ -6,6 +6,7 @@ # URL - Git repository URL. # BRANCH - Git branch to clone. # SHA - (optional) Specific commit hash to checkout. + set -e # Sometimes indexer is disabled, detect the missing build config. diff --git a/near/contracts/ft/src/lib.rs b/near/contracts/ft/src/lib.rs index 1444a7aced..0c3fcf13d4 100644 --- a/near/contracts/ft/src/lib.rs +++ b/near/contracts/ft/src/lib.rs @@ -154,12 +154,16 @@ impl FTContract { if payload.is_empty() { p = [p, vec![0; 24], (fee as u64).to_be_bytes().to_vec()].concat(); if p.len() != 133 { - env::panic_str(&format!("paylod1 formatting errro len = {}", p.len())); + env::panic_str(&format!("payload1 formatting error len = {}", p.len())); } } else { + if fee != 0 { + env::panic_str("Payload3 does not support fees"); + } + p = [p, hex::decode(&payload).unwrap()].concat(); if p.len() != (133 + (payload.len() / 2)) { - env::panic_str(&format!("paylod3 formatting errro len = {}", p.len())); + env::panic_str(&format!("payload3 formatting error len = {}", p.len())); } } diff --git a/near/contracts/token-bridge/src/lib.rs b/near/contracts/token-bridge/src/lib.rs index 4d3572674f..d5ca0f0956 100644 --- a/near/contracts/token-bridge/src/lib.rs +++ b/near/contracts/token-bridge/src/lib.rs @@ -403,6 +403,12 @@ impl TokenBridge { env::panic_str("nfee >= namount"); } + env::log_str(&format!( + "token-bridge/{}#{}: vaa_transfer {} {} {} {} {}", + file!(), + line!(), + amount.1, fee.1, namount, nfee, near_mult)); + env::log_str(&format!( "token-bridge/{}#{}: vaa_transfer calling ft_transfer against {} for {} from {} to {}", file!(), @@ -975,6 +981,10 @@ impl TokenBridge { env::panic_str("EmptyTransfer"); } + if !payload.is_empty() && nfee != 0 { + env::panic_str("Payload3 does not support fees"); + } + if nfee >= namount { env::panic_str("TransferFeeExceedsDeposit"); } @@ -1498,6 +1508,10 @@ impl TokenBridge { env::panic_str("EmptyTransfer"); } + if !tp.payload.is_empty() && nfee != 0 { + env::panic_str("Payload3 does not support fees"); + } + if namount > (u64::MAX as u128) || nfee > (u64::MAX as u128) { env::panic_str("transfer exceeds max bridged token amount"); } @@ -1529,12 +1543,12 @@ impl TokenBridge { if tp.payload.is_empty() { p = [p, vec![0; 24], (nfee as u64).to_be_bytes().to_vec()].concat(); if p.len() != 133 { - env::panic_str(&format!("paylod1 formatting errro len = {}", p.len())); + env::panic_str(&format!("payload1 formatting error len = {}", p.len())); } } else { p = [p, hex::decode(&tp.payload).unwrap()].concat(); if p.len() != (133 + (tp.payload.len() / 2)) { - env::panic_str(&format!("paylod3 formatting errro len = {}", p.len())); + env::panic_str(&format!("payload3 formatting error len = {}", p.len())); } } diff --git a/near/test/sdk.ts b/near/test/sdk.ts index ad659ec191..4c9974f30a 100644 --- a/near/test/sdk.ts +++ b/near/test/sdk.ts @@ -79,7 +79,10 @@ import { const wh = require("@certusone/wormhole-sdk"); -import { parseSequenceFromLogAlgorand, parseSequenceFromLogNear } from "@certusone/wormhole-sdk/lib/cjs/bridge"; +import { + parseSequenceFromLogAlgorand, + parseSequenceFromLogNear, +} from "@certusone/wormhole-sdk/lib/cjs/bridge"; import { getMessageFee, @@ -520,25 +523,21 @@ async function testNearSDK() { wrappedTransfer = signedVAA; } - console.log(await userAccount.viewFunction( - randoToken, - "ft_balance_of", - { + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { account_id: userAccount.accountId, - } - )); + }) + ); - console.log(await userAccount.viewFunction( - randoToken, - "ft_balance_of", - { + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { account_id: token_bridge, - } - )); + }) + ); let randoTransfer; { - console.log("transfer rando token from near to algorand"); + console.log("YYY transfer rando token from near to algorand"); let s = await transferTokenFromNear( userAccount, core_bridge, @@ -566,27 +565,27 @@ async function testNearSDK() { console.log(_parseVAAAlgorand(randoTransfer)); if (s[1] != getEmitterAddressNear(token_bridge)) { - console.log("Unexpected emitter address: " + s[1] + "!=" + getEmitterAddressNear(token_bridge)); - process.exit(1); + console.log( + "Unexpected emitter address: " + + s[1] + + "!=" + + getEmitterAddressNear(token_bridge) + ); + process.exit(1); } } - console.log(await userAccount.viewFunction( - randoToken, - "ft_balance_of", - { + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { account_id: userAccount.accountId, - } - )); + }) + ); - console.log(await userAccount.viewFunction( - randoToken, - "ft_balance_of", - { + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { account_id: token_bridge, - } - )); - + }) + ); let nearTransfer; { @@ -639,7 +638,7 @@ async function testNearSDK() { let randoAssetId; { - console.log("redeeming our near native asset on Algorand"); + console.log("YYY redeeming our near native asset on Algorand"); const tx = await redeemOnAlgorand( algoClient, algoToken, @@ -721,18 +720,17 @@ async function testNearSDK() { ).vaaBytes; } - console.log("transfering rando from Algo To Near... getting the vaa"); + console.log("YYY transfering rando from Algo To Near... getting the vaa"); let transferAlgoToNearRando; { - const AmountToTransfer: number = 100; - const Fee: number = 20; + const Fee: number = 0; const transferTxs = await transferFromAlgorand( algoClient, algoToken, algoCore, algoWallet.addr, randoAssetId, - BigInt(AmountToTransfer), + BigInt(20) * BigInt("1000000000") * BigInt("100000000"), myAddress, CHAIN_ID_NEAR, BigInt(Fee) @@ -793,12 +791,37 @@ async function testNearSDK() { ); console.log( - "redeeming Rando on Near: " + uint8ArrayToHex(transferAlgoToNearRando) + "YYY redeeming Rando on Near: " + uint8ArrayToHex(transferAlgoToNearRando) ); + + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { + account_id: userAccount.accountId, + }) + ); + + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { + account_id: token_bridge, + }) + ); + console.log( await redeemOnNear(user2Account, token_bridge, transferAlgoToNearRando) ); + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { + account_id: userAccount.accountId, + }) + ); + + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { + account_id: token_bridge, + }) + ); + console.log("redeeming NEAR on Near"); console.log( await redeemOnNear(user2Account, token_bridge, transferAlgoToNearNEAR) @@ -854,21 +877,20 @@ async function testNearSDK() { await redeemOnNear(user2Account, token_bridge, transferAlgoToNearP3) ); - console.log("transfering rando from Algo To Near... getting the vaa"); + console.log("YYY P3 transfering rando from Algo To Near... getting the vaa"); let transferAlgoToNearRandoP3; { - const AmountToTransfer: number = 100; - const Fee: number = 20; + const Fee: number = 0; const transferTxs = await transferFromAlgorand( algoClient, algoToken, algoCore, algoWallet.addr, randoAssetId, - BigInt(AmountToTransfer), + BigInt(1) * BigInt("1000000000") * BigInt("100000000"), userAccount2Address, CHAIN_ID_NEAR, - BigInt(Fee), + BigInt(Fee) * BigInt("100000000"), hexToUint8Array("ff") ); const transferResult = await signSendAndConfirmAlgorand( @@ -888,12 +910,24 @@ async function testNearSDK() { ).vaaBytes; } - console.log("redeeming P3 random on Near"); + console.log("YYY redeeming P3 random on Near"); console.log( await redeemOnNear(user2Account, token_bridge, transferAlgoToNearRandoP3) ); } + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { + account_id: userAccount.accountId, + }) + ); + + console.log( + await userAccount.viewFunction(randoToken, "ft_balance_of", { + account_id: token_bridge, + }) + ); + console.log("What next?"); }