diff --git a/README.md b/README.md index 600b407f4..aea36117e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Connect SDK -The Connect SDK is a TypeScript SDK for interacting with the chains Wormhole supports and the [protocols](#protocols) built on top of Wormhole. +The Connect SDK is a TypeScript SDK for interacting with the chains Wormhole supports and the [protocols](#protocols) built on top of Wormhole. ## Installation @@ -15,48 +15,45 @@ As well as any other platforms you wish to use ```bash npm install @wormhole-foundation/connect-sdk-evm npm install @wormhole-foundation/connect-sdk-solana -npm install @wormhole-foundation/connect-sdk-cosmwasm +npm install @wormhole-foundation/connect-sdk-algorand ``` And any protocols you intend to use ```bash -npm install @wormhole-foundation/connect-sdk-evm-core npm install @wormhole-foundation/connect-sdk-evm-tokenbridge - -npm install @wormhole-foundation/connect-sdk-solana-core npm install @wormhole-foundation/connect-sdk-solana-tokenbridge +npm install @wormhole-foundation/connect-sdk-algorand-tokenbridge ``` ## Usage -A developer would use the core connect-sdk package in conjunction with 1 or more of the chain context packages. Most developers don't use every single chain and may only use a couple, this allows developers to import only the dependencies they actually need. +A developer would use the connect-sdk package in conjunction with one or more of the chain context packages. Most developers don't use every single chain and may only use a couple, which allows developers to import only the dependencies they actually need. Getting started is simple, just import and pass in the [Platform](#platforms) modules you wish to support as an argument to the Wormhole class. ```ts -import { Wormhole, Signer } from '@wormhole-foundation/connect-sdk'; -import { EvmContext } from '@wormhole-foundation/connect-sdk-evm'; -import { SolanaContext } from '@wormhole-foundation/connect-sdk-solana'; - -// include the protocols you wish to use -import "@wormhole-foundation/connect-sdk-evm-core" -import "@wormhole-foundation/connect-sdk-evm-tokenbridge" -import "@wormhole-foundation/connect-sdk-solana-core" -import "@wormhole-foundation/connect-sdk-solana-tokenbridge" +import { Wormhole, Signer } from "@wormhole-foundation/connect-sdk"; +import { EvmContext } from "@wormhole-foundation/connect-sdk-evm"; +import { SolanaContext } from "@wormhole-foundation/connect-sdk-solana"; +import { AlgorandContext } from "@wormhole-foundation/connect-sdk-algorand"; +// Include the protocols you wish to use +import "@wormhole-foundation/connect-sdk-evm-tokenbridge"; +import "@wormhole-foundation/connect-sdk-solana-tokenbridge"; +import "@wormhole-foundation/connect-sdk-algorand-tokenbridge"; const network = "Mainnet"; // Or "Testnet" -const wh = new Wormhole(network, [EvmContext, SolanaContext]); +const wh = new Wormhole(network, [EvmPlatform, SolanaPlatform, AlgorandPlatform]); -// Get a ChainContext object for a specific chain -// Useful to do things like get the rpc client, make Protocol clients, -// look up configuration parameters or even parse addresses -const srcChain = wh.getChain('Ethereum'); +// Get a ChainContext object for a specific chain +// Useful to do things like get the rpc client, make Protocol clients, +// look up configuration parameters or even parse addresses +const srcChain = wh.getChain("Ethereum"); -srcChain.parseAddress("0xdeadbeef...") // => NativeAddress<'Evm'> -await srcChain.getTokenBridge() // => TokenBridge<'Evm'> -srcChain.getRpcClient() // => RpcClient<'Evm'> +srcChain.parseAddress("0xdeadbeef..."); // => NativeAddress<'Evm'> +await srcChain.getTokenBridge(); // => TokenBridge<'Evm'> +srcChain.getRpcClient(); // => RpcClient<'Evm'> ``` ### Wormhole Transfer @@ -65,29 +62,27 @@ While using the [ChainContext](#chain-context) and [Protocol](#protocols) client The `WormholeTransfer` interface provides a convenient abstraction to encapsulate the steps involved in a cross-chain transfer. - ### Token Transfers -Performing a Token Transfer is trivial for any source and destination chains. +Performing a Token Transfer is trivial for any source and destination chains. -We can create a new `WormholeTransfer` object (`TokenTransfer`, `CircleTransfer`, `GatewayTransfer`, ...) and use it to transfer tokens between chains. The `WormholeTransfer` object is responsible for tracking the transfer through the process and providing updates on its status. +We can create a new `Wormhole` object and use it to to create `TokenTransfer`, `CircleTransfer`, `GatewayTransfer`, etc. objects to transfer tokens between chains. The transfer object is responsible for tracking the transfer through the process and providing updates on its status. ```ts +// We'll send the native gas token on source chain +const token = "native"; -// we'll send the native gas token on source chain -const token = 'native' - -// format it for base units -const amt = normalizeAmount(1, srcChain.config.nativeTokenDecimals) +// Format it for base units +const amount = normalizeAmount(1, BigInt(srcChain.config.nativeTokenDecimals)); // Create a TokenTransfer object, allowing us to shepard the transfer through the process and get updates on its status const manualXfer = wh.tokenTransfer( - token, // TokenId of the token to transfer or 'native' - amt, // amount in base units - senderAddress, // Sender address on source chain + token, // TokenId of the token to transfer or 'native' + amount, // Amount in base units + senderAddress, // Sender address on source chain recipientAddress, // Recipient address on destination chain - false, // No Automatic transfer -) + false, // No Automatic transfer +); // 1) Submit the transactions to the source chain, passing a signer to sign any txns const srcTxids = await manualXfer.initiateTransfer(src.signer); @@ -95,17 +90,16 @@ const srcTxids = await manualXfer.initiateTransfer(src.signer); // 2) Wait for the VAA to be signed and ready (not required for auto transfer) // Note: Depending on chain finality, this timeout may need to be increased. // See https://docs.wormhole.com/wormhole/reference/constants#consistency-levels for more info on specific chain finality. -const timeout = 60_000; +const timeout = 60_000; const attestIds = await manualXfer.fetchAttestation(timeout); -// 3) Redeem the VAA on the dest chain +// 3) Redeem the VAA on the destination chain const destTxids = await manualXfer.completeTransfer(dst.signer); ``` -Internally, this uses the [TokenBridge](#token-bridge) protocol client to transfer tokens. The `TokenBridge` protocol, like other Protocols, provides a consistent set of methods across all chains to generate a set of transactions for that specific chain. - -See the example [here](https://github.com/wormhole-foundation/connect-sdk/blob/develop/examples/src/tokenBridge.ts) +Internally, this uses the [TokenBridge](#token-bridge) protocol client to transfer tokens. The `TokenBridge` protocol, like other Protocols, provides a consistent set of methods across all chains to generate a set of transactions for that specific chain. +See the example [here](https://github.com/wormhole-foundation/connect-sdk/blob/develop/examples/src/tokenBridge.ts). ### Native USDC Transfers @@ -114,11 +108,11 @@ We can also transfer native USDC using [Circle's CCTP](https://www.circle.com/en ```ts // OR for an native USDC transfer const usdcXfer = wh.cctpTransfer( - 1_000_000n, // amount in base units (1 USDC) - senderAddress, // Sender address on source chain + 1_000_000n, // amount in base units (1 USDC) + senderAddress, // Sender address on source chain recipientAddress, // Recipient address on destination chain - false, // Automatic transfer -) + false, // Automatic transfer +); // 1) Submit the transactions to the source chain, passing a signer to sign any txns const srcTxids = await usdcXfer.initiateTransfer(src.signer); @@ -133,8 +127,7 @@ const attestIds = await usdcXfer.fetchAttestation(timeout); const destTxids = await usdcXfer.completeTransfer(dst.signer); ``` -See the [example here](https://github.com/wormhole-foundation/connect-sdk/blob/develop/examples/src/cctp.ts) - +See the [example here](https://github.com/wormhole-foundation/connect-sdk/blob/develop/examples/src/cctp.ts). ### Automatic Transfers @@ -143,26 +136,24 @@ Some transfers allow for automatic relaying to the destination, in that case onl ```ts // OR for an automatic transfer const automaticXfer = wh.tokenTransfer( - 'native', // send native gas on source chain - amt, // amount in base units - senderAddress, // Sender address on source chain + "native", // send native gas on source chain + amt, // amount in base units + senderAddress, // Sender address on source chain recipientAddress, // Recipient address on destination chain - true, // Automatic transfer -) + true, // Automatic transfer +); // 1) Submit the transactions to the source chain, passing a signer to sign any txns const srcTxids = await automaticXfer.initiateTransfer(src.signer); // 2) If automatic, we're done, just wait for the transfer to complete -if (automatic) return waitLog(automaticXfer) ; +if (automatic) return waitLog(automaticXfer); ``` ### Gateway Transfers Gateway transfers are transfers that are passed through the Wormhole Gateway to or from Cosmos chains. - -See example [here](https://github.com/wormhole-foundation/connect-sdk/blob/develop/examples/src/cosmos.ts) - +See the example [here](https://github.com/wormhole-foundation/connect-sdk/blob/develop/examples/src/cosmos.ts). ### Recovering Transfers @@ -175,24 +166,27 @@ A `TransactionId` may be used // and attestation types so it may wait depending on the chain finality // and when the transactions were issued. const timeout = 60_000; -const xfer = await TokenTransfer.from({ - chain: 'Ethereum', - txid: '0x1234...', -}, timeout); - -const dstTxIds = await xfer.completeTransfer(dst.signer) +const xfer = await TokenTransfer.from( + { + chain: "Ethereum", + txid: "0x1234...", + }, + timeout, +); + +const dstTxIds = await xfer.completeTransfer(dst.signer); ``` -Or a `WormholeMessageId` if a `VAA` is generated +Or a `WormholeMessageId` if a `VAA` is generated ```ts const xfer = await TokenTransfer.from({ - chain: 'Ethereum', - emitter: toNative('Ethereum', emitterAddress).toUniversalAddress(), - sequence: '0x1234...', + chain: "Ethereum", + emitter: toNative("Ethereum", emitterAddress).toUniversalAddress(), + sequence: "0x1234...", }); -const dstTxIds = await xfer.completeTransfer(dst.signer) +const dstTxIds = await xfer.completeTransfer(dst.signer); ``` ## Concepts @@ -201,103 +195,97 @@ Understanding several higher level concepts of the SDK will help in using it eff ### Platforms -Every chain is its own special snowflake but many of them share similar functionality. The `Platform` modules provide a consistent interface for interacting with the chains that share a platform. +Every chain is its own special snowflake but many of them share similar functionality. The `Platform` modules provide a consistent interface for interacting with the chains that share a platform. Each platform can be installed separately so that dependencies can stay as minimal as possible. - ### Chain Context -The `Wormhole` class provides a `getChain` method that returns a `ChainContext` object for a given chain. This object provides access to the chain specific methods and utilities. Much of the functionality in the `ChainContext` is provided by the `Platform` methods but the specific chain may have overriden methods. +The `Wormhole` class provides a `getChain` method that returns a `ChainContext` object for a given chain. This object provides access to the chain specific methods and utilities. Much of the functionality in the `ChainContext` is provided by the `Platform` methods but the specific chain may have overriden methods. -The ChainContext object is also responsible for holding a cached rpc client and protocol clients. +The ChainContext object is also responsible for holding a cached rpc client and protocol clients. ```ts // Get the chain context for the source and destination chains -// This is useful to grab direct clients for the protocols +// This is useful to grab direct clients for the protocols const srcChain = wh.getChain(senderAddress.chain); const dstChain = wh.getChain(receiverAddress.chain); - -srcChain.parseAddress("0xdeadbeef...") // => NativeAddress<'Evm'> -await srcChain.getTokenBridge() // => TokenBridge<'Evm'> -srcChain.getRpcClient() // => RpcClient<'Evm'> +srcChain.parseAddress("0xdeadbeef..."); // => NativeAddress<'Evm'> +await srcChain.getTokenBridge(); // => TokenBridge<'Evm'> +srcChain.getRpcClient(); // => RpcClient<'Evm'> ``` ### Protocols -While Wormhole itself is a Generic Message Passing protocol, a number of protocols have been built on top of it to provide specific functionality. +While Wormhole itself is a Generic Message Passing protocol, a number of protocols have been built on top of it to provide specific functionality. #### Token Bridge The most familiar protocol built on Wormhole is the Token Bridge. -Every chain has a `TokenBridge` protocol client that provides a consistent interface for interacting with the Token Bridge. This includes methods to generate the transactions required to transfer tokens, as well as methods to generate and redeem attestations. +Every chain has a `TokenBridge` protocol client that provides a consistent interface for interacting with the Token Bridge. This includes methods to generate the transactions required to transfer tokens, as well as methods to generate and redeem attestations. -Using the `WormholeTransfer` abstractions is the recommended way to interact with these `Protocols` but it is possible to use them directly +Using the `WormholeTransfer` abstractions is the recommended way to interact with these protocols but it is possible to use them directly ```ts -import {signSendWait} from '@wormhole-foundation/connect-sdk'; +import { signSendWait } from "@wormhole-foundation/connect-sdk"; -import "@wormhole-foundation/connect-sdk-evm-core" -import "@wormhole-foundation/connect-sdk-evm-tokenbridge" +import "@wormhole-foundation/connect-sdk-evm-tokenbridge"; // ... -const tb = await srcChain.getTokenBridge() // => TokenBridge<'Evm'> - -const token = '0xdeadbeef...'; -const txGenerator = tb.createAttestation(token) // => AsyncGenerator -const txids = await signSendWait(srcChain, txGenerator, src.signer) // => TxHash[] +const tb = await srcChain.getTokenBridge(); // => TokenBridge<'Evm'> +const token = "0xdeadbeef..."; +const txGenerator = tb.createAttestation(token); // => AsyncGenerator +const txids = await signSendWait(srcChain, txGenerator, src.signer); // => TxHash[] ``` -Supported protocols are defined in the [definitions module](https://github.com/wormhole-foundation/connect-sdk/tree/develop/core/definitions/src/protocols) +Supported protocols are defined in the [definitions module](https://github.com/wormhole-foundation/connect-sdk/tree/develop/core/definitions/src/protocols). ### Signers -In order to sign transactions, an object that fulfils the `Signer` interface is required. This is a simple interface that can be implemented by wrapping a web wallet or other signing mechanism. +In order to sign transactions, an object that fulfils the `Signer` interface is required. This is a simple interface that can be implemented by wrapping a web wallet or other signing mechanism. ```ts // A Signer is an interface that must be provided to certain methods // in the SDK to sign transactions. It can be either a SignOnlySigner -// or a SignAndSendSigner depending on circumstances. +// or a SignAndSendSigner depending on circumstances. // A Signer can be implemented by wrapping an existing offline wallet -// or a web wallet +// or a web wallet export type Signer = SignOnlySigner | SignAndSendSigner; // A SignOnlySender is for situations where the signer is not // connected to the network or does not wish to broadcast the -// transactions themselves +// transactions themselves export interface SignOnlySigner { - chain(): ChainName; - address(): string; - // Accept an array of unsigned transactions and return - // an array of signed and serialized transactions. - // The transactions may be inspected or altered before - // signing. - // Note: The serialization is chain specific, if in doubt, - // see the example implementations linked below - sign(tx: UnsignedTransaction[]): Promise; + chain(): ChainName; + address(): string; + // Accept an array of unsigned transactions and return + // an array of signed and serialized transactions. + // The transactions may be inspected or altered before + // signing. + // Note: The serialization is chain specific, if in doubt, + // see the example implementations linked below + sign(tx: UnsignedTransaction[]): Promise; } // A SignAndSendSigner is for situations where the signer is // connected to the network and wishes to broadcast the -// transactions themselves +// transactions themselves export interface SignAndSendSigner { - chain(): ChainName; - address(): string; - // Accept an array of unsigned transactions and return - // an array of transaction ids in the same order as the - // UnsignedTransactions array. - signAndSend(tx: UnsignedTransaction[]): Promise; + chain(): ChainName; + address(): string; + // Accept an array of unsigned transactions and return + // an array of transaction ids in the same order as the + // UnsignedTransactions array. + signAndSend(tx: UnsignedTransaction[]): Promise; } ``` - See the testing signers ([Evm](https://github.com/wormhole-foundation/connect-sdk/blob/develop/platforms/evm/src/testing/signer.ts), [Solana](https://github.com/wormhole-foundation/connect-sdk/blob/develop/platforms/solana/src/testing/signer.ts), ...) for an example of how to implement a signer for a specific chain or platform. - ```ts // Create a signer for the source and destination chains const sender: Signer = // ... @@ -309,31 +297,30 @@ const receiver: Signer = // ... Within the Wormhole context, addresses are [normalized](https://docs.wormhole.com/wormhole/blockchain-environments/evm#addresses) to 32 bytes and referred to in this SDK as a `UniversalAddresses`. -Each platform comes with an address type that understands the native address formats, unsuprisingly referred to a NativeAddress. This abstraction allows the SDK to work with addresses in a consistent way regardless of the underlying chain. +Each platform comes with an address type that understands the native address formats, unsuprisingly referred to a NativeAddress. This abstraction allows the SDK to work with addresses in a consistent way regardless of the underlying chain. ```ts // Convert a string address to its Native address -const ethAddr: NativeAddress<'Evm'> = toNative('Ethereum', '0xbeef...'); -const solAddr: NativeAddress<'Solana'> = toNative('Solana', 'Sol1111...') +const ethAddr: NativeAddress<"Evm"> = toNative("Ethereum", "0xbeef..."); +const solAddr: NativeAddress<"Solana"> = toNative("Solana", "Sol1111..."); +const algoAddr: NativeAddress<"Algorand"> = toNative("Solana", "TRYALGO..."); // Convert a Native address to its string address -ethAddr.toString() // => '0xbeef...' +ethAddr.toString(); // => '0xbeef...' // Convert a Native address to a UniversalAddress -ethAddr.toUniversalAddresS() +ethAddr.toUniversalAddresS(); -// A common type in the SDK is the `ChainAddress`. +// A common type in the SDK is the `ChainAddress`. // A helper exists to provide a ChainAddress for a signer, or [ChainName, string address] -const senderAddress: ChainAddress = nativeChainAddress(sender) -const receiverAddress: ChainAddress = nativeChainAddress(receiver) +const senderAddress: ChainAddress = nativeChainAddress(sender); +const receiverAddress: ChainAddress = nativeChainAddress(receiver); ``` - ## See also The tsdoc is available [here](https://wormhole-foundation.github.io/connect-sdk/) - ## WIP -:warning: This package is a Work in Progress so the interface may change and there are likely bugs. Please [report](https://github.com/wormhole-foundation/connect-sdk/issues) any issues you find. :warning: +:warning: This package is a Work in Progress so the interface may change and there are likely bugs. Please [report](https://github.com/wormhole-foundation/connect-sdk/issues) any issues you find. :warning: diff --git a/TODO.md b/TODO.md index 91caf9ac2..a9fa5d288 100644 --- a/TODO.md +++ b/TODO.md @@ -1,18 +1,17 @@ ## TODOS: -Chains: +Chains: - [ ] Add support for Aptos chains -- [ ] Add support for Algorand chains - [ ] Add support for Sui chains - [ ] Add support for Near chains Other: - [ ] Add support for NFTBridge protocols -- [ ] Simulate prior to sending -- [ ] Gas utilities (estimate from unsigned, get gas used from txid) +- [ ] Simulate prior to sending +- [ ] Gas utilities (estimate from unsigned, get gas used from txid) - [ ] Validation of inputs (amount > dust, etc..) - [ ] Better tracking of auto-redeem, use target contract? - [ ] Estimate tx finalization -- [ ] Event emission/subscription for status changes +- [ ] Event emission/subscription for status changes diff --git a/examples/.env.example b/examples/.env.example new file mode 100644 index 000000000..95d2f676c --- /dev/null +++ b/examples/.env.example @@ -0,0 +1,3 @@ +ETH_PRIVATE_KEY= +SOL_PRIVATE_KEY= +ALGORAND_MNEMONIC= \ No newline at end of file diff --git a/examples/src/helpers/helpers.ts b/examples/src/helpers/helpers.ts index ac6e9435d..133e5e9ba 100644 --- a/examples/src/helpers/helpers.ts +++ b/examples/src/helpers/helpers.ts @@ -20,7 +20,10 @@ import { getCosmwasmSigner } from "@wormhole-foundation/connect-sdk-cosmwasm/src import { getEvmSigner } from "@wormhole-foundation/connect-sdk-evm/src/testing"; import { getSolanaSigner } from "@wormhole-foundation/connect-sdk-solana/src/testing"; -// read in from `.env` +// Use .env.example as a template for your .env file and populate it with secrets +// for funded accounts on the relevant chain+network combos to run the example + +// Read in from `.env` require("dotenv").config(); function getEnv(key: string): string { diff --git a/examples/src/multiTokenBridge.ts b/examples/src/multiTokenBridge.ts index 7a2ff3340..f1dda618c 100644 --- a/examples/src/multiTokenBridge.ts +++ b/examples/src/multiTokenBridge.ts @@ -13,7 +13,7 @@ import { import { TransferStuff, getStuff, waitLog } from "./helpers"; import { inspect } from "util"; -// Import the platform specific packages +// Import the platform-specific packages import { EvmPlatform } from "@wormhole-foundation/connect-sdk-evm"; import { SolanaPlatform } from "@wormhole-foundation/connect-sdk-solana"; import { AlgorandPlatform } from "@wormhole-foundation/connect-sdk-algorand"; @@ -36,6 +36,9 @@ interface BridgingResult extends BridgingInputs { result: TransferReceipt; } +// Use .env.example as a template for your .env file and populate it with secrets +// for funded accounts on the relevant chain+network combos to run the example + (async function multipleBridges() { const scenarios: BridgingInputs[] = [ // Example input set showing all parameters with recoverTxId as optional @@ -205,17 +208,17 @@ async function tokenTransfer( // If automatic, we're done if (route.delivery?.automatic) return xfer; - // 2) wait for the VAA to be signed and ready (not required for auto transfer) + // 2) Wait for the VAA to be signed and ready (not required for auto transfer) console.log("Getting Attestation"); const attestIds = await xfer.fetchAttestation(60_000); console.log(`Got Attestation: `, attestIds); - // 3) redeem the VAA on the dest chain + // 3) Redeem the VAA on the dest chain console.log("Completing Transfer"); const destTxids = await xfer.completeTransfer(route.destination.signer); console.log(`Completed Transfer: `, destTxids); - // No need to send back, dip + // If no need to send back, dip if (!roundTrip) return xfer; const { destinationToken: token } = quote; diff --git a/examples/src/tokenBridge.ts b/examples/src/tokenBridge.ts index 19dcde964..22a798624 100644 --- a/examples/src/tokenBridge.ts +++ b/examples/src/tokenBridge.ts @@ -10,7 +10,7 @@ import { } from "@wormhole-foundation/connect-sdk"; import { TransferStuff, getStuff, waitLog } from "./helpers"; -// Import the platform specific packages +// Import the platform-specific packages import { EvmPlatform } from "@wormhole-foundation/connect-sdk-evm"; import { SolanaPlatform } from "@wormhole-foundation/connect-sdk-solana"; import { AlgorandPlatform } from "@wormhole-foundation/connect-sdk-algorand"; @@ -20,8 +20,11 @@ import "@wormhole-foundation/connect-sdk-evm-tokenbridge"; import "@wormhole-foundation/connect-sdk-solana-tokenbridge"; import "@wormhole-foundation/connect-sdk-algorand-tokenbridge"; +// Use .env.example as a template for your .env file and populate it with secrets +// for funded accounts on the relevant chain+network combos to run the example + (async function () { - // init Wormhole object, passing config for which network + // Init Wormhole object, passing config for which network // to use (e.g. Mainnet/Testnet) and what Platforms to support const wh = new Wormhole("Testnet", [EvmPlatform, SolanaPlatform, AlgorandPlatform]); @@ -120,8 +123,7 @@ async function tokenTransfer( }, roundTrip?: boolean, ): Promise> { - // Create a TokenTransfer object to track the state of - // the transfer over time + // Create a TokenTransfer object to track the state of the transfer over time const xfer = await wh.tokenTransfer( route.token, route.amount, @@ -150,17 +152,17 @@ async function tokenTransfer( // If automatic, we're done if (route.delivery?.automatic) return xfer; - // 2) wait for the VAA to be signed and ready (not required for auto transfer) + // 2) Wait for the VAA to be signed and ready (not required for auto transfer) console.log("Getting Attestation"); const attestIds = await xfer.fetchAttestation(60_000); console.log(`Got Attestation: `, attestIds); - // 3) redeem the VAA on the dest chain + // 3) Redeem the VAA on the dest chain console.log("Completing Transfer"); const destTxids = await xfer.completeTransfer(route.destination.signer); console.log(`Completed Transfer: `, destTxids); - // No need to send back, dip + // If no need to send back, dip if (!roundTrip) return xfer; const { destinationToken: token } = quote; diff --git a/platforms/algorand/protocols/tokenBridge/src/tokenBridge.ts b/platforms/algorand/protocols/tokenBridge/src/tokenBridge.ts index 1e9137fe7..2e35a7484 100644 --- a/platforms/algorand/protocols/tokenBridge/src/tokenBridge.ts +++ b/platforms/algorand/protocols/tokenBridge/src/tokenBridge.ts @@ -364,7 +364,7 @@ export class AlgorandTokenBridge txs.push({ tx: makeApplicationCallTxnFromObject({ - accounts: [], // TODO: + accounts: [], appArgs: [AlgorandTokenBridge.receiveAttest, serialize(vaa)], appIndex: safeBigIntToNumber(this.tokenBridgeAppId), foreignAssets: foreignAssets, @@ -374,7 +374,7 @@ export class AlgorandTokenBridge }), }); - txs[txs.length - 1].tx.fee = txs[txs.length - 1].tx.fee * 2; // QUESTIONBW: There are like 3 different ways of adjusting fees in various functions--this should be standardized + txs[txs.length - 1].tx.fee = txs[txs.length - 1].tx.fee * 2; for (const utxn of txs) { yield this.createUnsignedTx(utxn, "TokenBridge.submitAttestation", true); @@ -418,8 +418,7 @@ export class AlgorandTokenBridge ); txs.push(...emitterOptInTxs); - // Check that the auth address of the creator - // is the token bridge + // Check that the auth address of the creator is the token bridge let creator = ""; let creatorAcct: modelsv2.Account | undefined; let wormhole: boolean = false;