Skip to content

Commit

Permalink
Readme and comments tidying (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
SilentRhetoric authored Jan 1, 2024
1 parent a6bc068 commit 25334d5
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 142 deletions.
229 changes: 108 additions & 121 deletions README.md

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions examples/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ETH_PRIVATE_KEY=
SOL_PRIVATE_KEY=
ALGORAND_MNEMONIC=
5 changes: 4 additions & 1 deletion examples/src/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 7 additions & 4 deletions examples/src/multiTokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -36,6 +36,9 @@ interface BridgingResult extends BridgingInputs {
result: TransferReceipt<TokenTransferProtocol>;
}

// 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
Expand Down Expand Up @@ -205,17 +208,17 @@ async function tokenTransfer<N extends Network>(
// 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;
Expand Down
16 changes: 9 additions & 7 deletions examples/src/tokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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]);

Expand Down Expand Up @@ -120,8 +123,7 @@ async function tokenTransfer<N extends Network>(
},
roundTrip?: boolean,
): Promise<TokenTransfer<N>> {
// 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,
Expand Down Expand Up @@ -150,17 +152,17 @@ async function tokenTransfer<N extends Network>(
// 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;
Expand Down
7 changes: 3 additions & 4 deletions platforms/algorand/protocols/tokenBridge/src/tokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export class AlgorandTokenBridge<N extends Network, C extends AlgorandChains>

txs.push({
tx: makeApplicationCallTxnFromObject({
accounts: [], // TODO:
accounts: [],
appArgs: [AlgorandTokenBridge.receiveAttest, serialize(vaa)],
appIndex: safeBigIntToNumber(this.tokenBridgeAppId),
foreignAssets: foreignAssets,
Expand All @@ -374,7 +374,7 @@ export class AlgorandTokenBridge<N extends Network, C extends AlgorandChains>
}),
});

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);
Expand Down Expand Up @@ -418,8 +418,7 @@ export class AlgorandTokenBridge<N extends Network, C extends AlgorandChains>
);
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;
Expand Down

0 comments on commit 25334d5

Please sign in to comment.