From eae0b51d37a19121fea4b66652d3d911af96ad40 Mon Sep 17 00:00:00 2001 From: Paul Noel <35237584+panoel@users.noreply.github.com> Date: Tue, 16 Aug 2022 15:14:48 +0000 Subject: [PATCH] Algorand mainnet deploy (#1434) * algorand mainnet deploy * Changes to sdk/js * Update sdk changlog Co-authored-by: Bruce Riley --- node/cmd/guardiand/node.go | 36 ++++++++++++++--------------- node/pkg/common/mainnet_consts.go | 1 + node/pkg/governor/mainnet_chains.go | 1 + sdk/js/CHANGELOG.md | 9 ++++++++ sdk/js/package.json | 2 +- sdk/js/src/algorand/Algorand.ts | 26 +++++++++++++++++++++ sdk/js/src/utils/consts.ts | 4 ++-- 7 files changed, 57 insertions(+), 22 deletions(-) diff --git a/node/cmd/guardiand/node.go b/node/cmd/guardiand/node.go index c9505134b..7fe6ae0df 100644 --- a/node/cmd/guardiand/node.go +++ b/node/cmd/guardiand/node.go @@ -641,23 +641,23 @@ func runNode(cmd *cobra.Command, args []string) { logger.Fatal("Please specify --terra2Contract") } - if *testnetMode { - if *algorandIndexerRPC == "" { - logger.Fatal("Please specify --algorandIndexerRPC") - } - if *algorandIndexerToken == "" { - logger.Fatal("Please specify --algorandIndexerToken") - } - if *algorandAlgodRPC == "" { - logger.Fatal("Please specify --algorandAlgodRPC") - } - if *algorandAlgodToken == "" { - logger.Fatal("Please specify --algorandAlgodToken") - } - if *algorandAppID == 0 { - logger.Fatal("Please specify --algorandAppID") - } + if *algorandIndexerRPC == "" { + logger.Fatal("Please specify --algorandIndexerRPC") + } + if *algorandIndexerToken == "" { + logger.Fatal("Please specify --algorandIndexerToken") + } + if *algorandAlgodRPC == "" { + logger.Fatal("Please specify --algorandAlgodRPC") + } + if *algorandAlgodToken == "" { + logger.Fatal("Please specify --algorandAlgodToken") + } + if *algorandAppID == 0 { + logger.Fatal("Please specify --algorandAppID") + } + if *testnetMode { if *pythnetContract == "" { logger.Fatal("Please specify --pythnetContract") } @@ -816,9 +816,7 @@ func runNode(cmd *cobra.Command, args []string) { chainObsvReqC[vaa.ChainIDPolygon] = make(chan *gossipv1.ObservationRequest) chainObsvReqC[vaa.ChainIDAvalanche] = make(chan *gossipv1.ObservationRequest) chainObsvReqC[vaa.ChainIDOasis] = make(chan *gossipv1.ObservationRequest) - if *testnetMode || *unsafeDevMode { - chainObsvReqC[vaa.ChainIDAlgorand] = make(chan *gossipv1.ObservationRequest) - } + chainObsvReqC[vaa.ChainIDAlgorand] = make(chan *gossipv1.ObservationRequest) if *nearRPC != "" { chainObsvReqC[vaa.ChainIDNear] = make(chan *gossipv1.ObservationRequest) } diff --git a/node/pkg/common/mainnet_consts.go b/node/pkg/common/mainnet_consts.go index c18f0d192..0b0fc1aaf 100644 --- a/node/pkg/common/mainnet_consts.go +++ b/node/pkg/common/mainnet_consts.go @@ -106,6 +106,7 @@ var knownTokenbridgeEmitters = map[vaa.ChainID]string{ vaa.ChainIDPolygon: "0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde", vaa.ChainIDAvalanche: "0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052", vaa.ChainIDOasis: "0000000000000000000000005848c791e09901b40a9ef749f2a6735b418d7564", + vaa.ChainIDAlgorand: "25e716e0618d9f38b603a97cc42db659069c0f5185230e5e61679fa876191ec4", vaa.ChainIDAurora: "00000000000000000000000051b5123a7b0F9b2bA265f9c4C8de7D78D52f510F", vaa.ChainIDFantom: "0000000000000000000000007C9Fc5741288cDFdD83CeB07f3ea7e22618D79D2", vaa.ChainIDKarura: "000000000000000000000000ae9d7fe007b3327AA64A32824Aaac52C42a6E624", diff --git a/node/pkg/governor/mainnet_chains.go b/node/pkg/governor/mainnet_chains.go index 8f665c2b5..1c11f5812 100644 --- a/node/pkg/governor/mainnet_chains.go +++ b/node/pkg/governor/mainnet_chains.go @@ -12,6 +12,7 @@ func chainList() []chainConfigEntry { return []chainConfigEntry{ chainConfigEntry{emitterChainID: vaa.ChainIDTerra, dailyLimit: 500000}, chainConfigEntry{emitterChainID: vaa.ChainIDOasis, dailyLimit: 500000}, + chainConfigEntry{emitterChainID: vaa.ChainIDAlgorand, dailyLimit: 500000}, chainConfigEntry{emitterChainID: vaa.ChainIDAurora, dailyLimit: 500000}, chainConfigEntry{emitterChainID: vaa.ChainIDFantom, dailyLimit: 500000}, chainConfigEntry{emitterChainID: vaa.ChainIDKarura, dailyLimit: 500000}, diff --git a/sdk/js/CHANGELOG.md b/sdk/js/CHANGELOG.md index 661c17ba3..dfd327ab1 100644 --- a/sdk/js/CHANGELOG.md +++ b/sdk/js/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.6.2 + +### Added + +Algorand mainnet support + +Updated consts.ts file +Exported signSendAndConfirmAlgorand() + ## 0.6.1 ### Added diff --git a/sdk/js/package.json b/sdk/js/package.json index e2e907d09..9b4793103 100644 --- a/sdk/js/package.json +++ b/sdk/js/package.json @@ -1,6 +1,6 @@ { "name": "@certusone/wormhole-sdk", - "version": "0.6.1", + "version": "0.6.2", "description": "SDK for interacting with Wormhole", "homepage": "https://wormholenetwork.com", "main": "./lib/cjs/index.js", diff --git a/sdk/js/src/algorand/Algorand.ts b/sdk/js/src/algorand/Algorand.ts index 26ad79251..a1a604ebb 100644 --- a/sdk/js/src/algorand/Algorand.ts +++ b/sdk/js/src/algorand/Algorand.ts @@ -1,7 +1,9 @@ // Algorand.ts import algosdk, { + Account, Algodv2, + assignGroupID, bigIntToBytes, decodeAddress, encodeAddress, @@ -14,6 +16,7 @@ import algosdk, { OnApplicationComplete, signLogicSigTransaction, Transaction, + waitForConfirmation, } from "algosdk"; import abi from "algosdk"; @@ -963,3 +966,26 @@ export function hexToNativeAssetBigIntAlgorand(s: string): bigint { export function hexToNativeAssetStringAlgorand(s: string): string { return BigNumber.from(hexToUint8Array(s)).toString(); } + +export async function signSendAndConfirmAlgorand( + algodClient: Algodv2, + txs: TransactionSignerPair[], + wallet: Account +) { + assignGroupID(txs.map((tx) => tx.tx)); + const signedTxns: Uint8Array[] = []; + for (const tx of txs) { + if (tx.signer) { + signedTxns.push(await tx.signer.signTxn(tx.tx)); + } else { + signedTxns.push(tx.tx.signTxn(wallet.sk)); + } + } + await algodClient.sendRawTransaction(signedTxns).do(); + const result = await waitForConfirmation( + algodClient, + txs[txs.length - 1].tx.txID(), + 4 + ); + return result; +} diff --git a/sdk/js/src/utils/consts.ts b/sdk/js/src/utils/consts.ts index 1de2874a5..647a845e7 100644 --- a/sdk/js/src/utils/consts.ts +++ b/sdk/js/src/utils/consts.ts @@ -117,8 +117,8 @@ const MAINNET = { nft_bridge: "0x04952D522Ff217f40B5Ef3cbF659EcA7b952a6c1", }, algorand: { - core: undefined, - token_bridge: undefined, + core: "836919128", + token_bridge: "836919282", nft_bridge: undefined, }, aurora: {