From 5fb81e38c9482cf7ab297db9a8c49eb847c5b187 Mon Sep 17 00:00:00 2001 From: Csongor Kiss Date: Mon, 29 Apr 2024 17:04:06 +0100 Subject: [PATCH] solana: bump version to 2.0.0 add script to sync/check crate versions --- .github/workflows/solana.yml | 8 + sdk/solana/package.json | 2 +- sdk/solana/scripts/readVersion.ts | 16 - sdk/solana/src/anchor-idl/2_0_0.ts | 15 + .../anchor-idl/2_0_0/dummy_transfer_hook.json | 110 + .../anchor-idl/2_0_0/dummy_transfer_hook.ts | 221 + .../2_0_0/example_native_token_transfers.json | 1932 ++++++++ .../2_0_0/example_native_token_transfers.ts | 4087 +++++++++++++++++ .../src/anchor-idl/2_0_0/ntt_quoter.json | 588 +++ sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.ts | 1177 +++++ .../anchor-idl/2_0_0/wormhole_governance.json | 76 + .../anchor-idl/2_0_0/wormhole_governance.ts | 153 + sdk/solana/src/anchor-idl/index.ts | 1 + sdk/solana/src/bindings.ts | 9 +- solana/Cargo.lock | 10 +- solana/Makefile | 1 + solana/idl/json/dummy_transfer_hook.json | 2 +- .../json/example_native_token_transfers.json | 2 +- solana/idl/json/ntt_quoter.json | 2 +- solana/idl/json/wormhole_governance.json | 2 +- solana/idl/ts/dummy_transfer_hook.ts | 4 +- .../idl/ts/example_native_token_transfers.ts | 4 +- solana/idl/ts/ntt_quoter.ts | 4 +- solana/idl/ts/wormhole_governance.ts | 4 +- solana/modules/ntt-messages/Cargo.toml | 2 +- .../programs/dummy-transfer-hook/Cargo.toml | 2 +- .../example-native-token-transfers/Cargo.toml | 2 +- .../example-native-token-transfers/src/lib.rs | 2 +- solana/programs/ntt-quoter/Cargo.toml | 2 +- .../programs/wormhole-governance/Cargo.toml | 2 +- solana/scripts/program-version | 26 + solana/scripts/sync-versions | 39 + 32 files changed, 8463 insertions(+), 44 deletions(-) delete mode 100644 sdk/solana/scripts/readVersion.ts create mode 100644 sdk/solana/src/anchor-idl/2_0_0.ts create mode 100644 sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.json create mode 100644 sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.ts create mode 100644 sdk/solana/src/anchor-idl/2_0_0/example_native_token_transfers.json create mode 100644 sdk/solana/src/anchor-idl/2_0_0/example_native_token_transfers.ts create mode 100644 sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.json create mode 100644 sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.ts create mode 100644 sdk/solana/src/anchor-idl/2_0_0/wormhole_governance.json create mode 100644 sdk/solana/src/anchor-idl/2_0_0/wormhole_governance.ts create mode 100755 solana/scripts/program-version create mode 100755 solana/scripts/sync-versions diff --git a/.github/workflows/solana.yml b/.github/workflows/solana.yml index 5cb598de0..0faa6174e 100644 --- a/.github/workflows/solana.yml +++ b/.github/workflows/solana.yml @@ -97,6 +97,14 @@ jobs: cargo build-sbf --features "mainnet" cargo test-sbf --features "mainnet" cargo test + check-version: + name: Check version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: ./scripts/sync-versions --check + shell: bash + anchor-test: name: Anchor Test runs-on: ubuntu-latest diff --git a/sdk/solana/package.json b/sdk/solana/package.json index 7cb9ce239..2a8e1a9d4 100644 --- a/sdk/solana/package.json +++ b/sdk/solana/package.json @@ -41,7 +41,7 @@ "test:ci": "jest --config ./jest.config.ts", "copy:idl": "cp ../../solana/target/idl/*.json ./src/anchor-idl/$IDL_VERSION/", "copy:types": "cp ../../solana/target/types/*.ts ./src/anchor-idl/$IDL_VERSION/", - "generate": "export IDL_VERSION=`tsx scripts/readVersion.ts` && mkdir -p ./src/anchor-idl/$IDL_VERSION && npm run copy:idl && npm run copy:types", + "generate": "export IDL_VERSION=`../../solana/scripts/program-version | sed s/\\\\\\./_/g` && mkdir -p ./src/anchor-idl/$IDL_VERSION && npm run copy:idl && npm run copy:types", "build:contracts": "cd ../../solana && make build" }, "devDependencies": { diff --git a/sdk/solana/scripts/readVersion.ts b/sdk/solana/scripts/readVersion.ts deleted file mode 100644 index 2f2a109a7..000000000 --- a/sdk/solana/scripts/readVersion.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as fs from "fs"; - -// From the persp of `sdk/solana` -const projectRoot = "../../"; -const versionFile = "solana/programs/example-native-token-transfers/src/lib.rs"; -const versionRegex = /pub const VERSION/; -(function () { - const contents = fs.readFileSync(projectRoot + versionFile, "utf8"); - for (const line of contents.split("\n")) { - if (line.match(versionRegex)) { - const version = line.split('"')[1]; - console.log(version?.replaceAll(".", "_")); - return; - } - } -})(); diff --git a/sdk/solana/src/anchor-idl/2_0_0.ts b/sdk/solana/src/anchor-idl/2_0_0.ts new file mode 100644 index 000000000..0eaf59c94 --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0.ts @@ -0,0 +1,15 @@ +import ntt from "./2_0_0/example_native_token_transfers.json"; +import quoter from "./2_0_0/ntt_quoter.json"; +import governance from "./2_0_0/wormhole_governance.json"; + +import type { ExampleNativeTokenTransfers } from "./2_0_0/example_native_token_transfers.js"; +import type { NttQuoter } from "./2_0_0/ntt_quoter.js"; +import type { WormholeGovernance } from "./2_0_0/wormhole_governance.js"; + +export namespace _2_0_0 { + export const idl = { ntt, quoter, governance }; + + export type RawExampleNativeTokenTransfers = ExampleNativeTokenTransfers; + export type RawNttQuoter = NttQuoter; + export type RawWormholeGovernance = WormholeGovernance; +} diff --git a/sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.json b/sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.json new file mode 100644 index 000000000..2f6864c36 --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.json @@ -0,0 +1,110 @@ +{ + "version": "2.0.0", + "name": "dummy_transfer_hook", + "instructions": [ + { + "name": "initializeExtraAccountMetaList", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "extraAccountMetaList", + "isMut": true, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "counter", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "transferHook", + "accounts": [ + { + "name": "sourceToken", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "destinationToken", + "isMut": false, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "extraAccountMetaList", + "isMut": false, + "isSigner": false + }, + { + "name": "dummyAccount", + "isMut": false, + "isSigner": false, + "docs": [ + "computes and the on-chain code correctly passes on the PDA." + ] + }, + { + "name": "counter", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "Counter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "count", + "type": "u64" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.ts b/sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.ts new file mode 100644 index 000000000..25e31bff3 --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.ts @@ -0,0 +1,221 @@ +export type DummyTransferHook = { + "version": "2.0.0", + "name": "dummy_transfer_hook", + "instructions": [ + { + "name": "initializeExtraAccountMetaList", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "extraAccountMetaList", + "isMut": true, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "counter", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "transferHook", + "accounts": [ + { + "name": "sourceToken", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "destinationToken", + "isMut": false, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "extraAccountMetaList", + "isMut": false, + "isSigner": false + }, + { + "name": "dummyAccount", + "isMut": false, + "isSigner": false, + "docs": [ + "computes and the on-chain code correctly passes on the PDA." + ] + }, + { + "name": "counter", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "counter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "count", + "type": "u64" + } + ] + } + } + ] +}; + +export const IDL: DummyTransferHook = { + "version": "2.0.0", + "name": "dummy_transfer_hook", + "instructions": [ + { + "name": "initializeExtraAccountMetaList", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "extraAccountMetaList", + "isMut": true, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "counter", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "transferHook", + "accounts": [ + { + "name": "sourceToken", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "destinationToken", + "isMut": false, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "extraAccountMetaList", + "isMut": false, + "isSigner": false + }, + { + "name": "dummyAccount", + "isMut": false, + "isSigner": false, + "docs": [ + "computes and the on-chain code correctly passes on the PDA." + ] + }, + { + "name": "counter", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "counter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "count", + "type": "u64" + } + ] + } + } + ] +}; diff --git a/sdk/solana/src/anchor-idl/2_0_0/example_native_token_transfers.json b/sdk/solana/src/anchor-idl/2_0_0/example_native_token_transfers.json new file mode 100644 index 000000000..82369389d --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0/example_native_token_transfers.json @@ -0,0 +1,1932 @@ +{ + "version": "2.0.0", + "name": "example_native_token_transfers", + "instructions": [ + { + "name": "initialize", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "deployer", + "isMut": false, + "isSigner": true + }, + { + "name": "programData", + "isMut": false, + "isSigner": false + }, + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "The custody account that holds tokens in locking mode and temporarily", + "holds tokens in burning mode.", + "function if the token account has already been created." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false, + "docs": [ + "associated token account for the given mint." + ] + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "InitializeArgs" + } + } + ] + }, + { + "name": "initializeLut", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "lutAddress", + "isMut": true, + "isSigner": false + }, + { + "name": "lut", + "isMut": true, + "isSigner": false + }, + { + "name": "lutProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "entries", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxRateLimit", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ] + } + ], + "args": [ + { + "name": "recentSlot", + "type": "u64" + } + ] + }, + { + "name": "version", + "accounts": [], + "args": [], + "returns": "string" + }, + { + "name": "transferBurn", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "from", + "isMut": true, + "isSigner": false, + "docs": [ + "account can spend these tokens." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": true + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "Tokens are always transferred to the custody account first regardless of", + "the mode.", + "For an explanation, see the note in [`transfer_burn`]." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "sessionAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "See [`crate::SESSION_AUTHORITY_SEED`] for an explanation of the flow." + ] + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "TransferArgs" + } + } + ] + }, + { + "name": "transferLock", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "from", + "isMut": true, + "isSigner": false, + "docs": [ + "account can spend these tokens." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": true + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "Tokens are always transferred to the custody account first regardless of", + "the mode.", + "For an explanation, see the note in [`transfer_burn`]." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "sessionAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "See [`crate::SESSION_AUTHORITY_SEED`] for an explanation of the flow." + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "TransferArgs" + } + } + ] + }, + { + "name": "redeem", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiverMessage", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false, + "docs": [ + "NOTE: This account is content-addressed (PDA seeded by the message hash).", + "This is because in a multi-transceiver configuration, the different", + "transceivers \"vote\" on messages (by delivering them). By making the inbox", + "items content-addressed, we can ensure that disagreeing votes don't", + "interfere with each other.", + "On the first call to [`redeem()`], [`InboxItem`] will be allocated and initialized with", + "default values.", + "On subsequent calls, we want to modify the `InboxItem` by \"voting\" on it. Therefore the", + "program should not fail which would occur when using the `init` constraint.", + "The [`InboxItem::init`] field is used to guard against malicious or accidental modification", + "InboxItem fields that should remain constant." + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RedeemArgs" + } + } + ] + }, + { + "name": "releaseInboundMint", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "recipient", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseInboundArgs" + } + } + ] + }, + { + "name": "releaseInboundUnlock", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "recipient", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseInboundArgs" + } + } + ] + }, + { + "name": "transferOwnership", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "newOwner", + "isMut": false, + "isSigner": false + }, + { + "name": "upgradeLock", + "isMut": false, + "isSigner": false + }, + { + "name": "programData", + "isMut": true, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "claimOwnership", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "upgradeLock", + "isMut": false, + "isSigner": false + }, + { + "name": "newOwner", + "isMut": false, + "isSigner": true + }, + { + "name": "programData", + "isMut": true, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setPaused", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "config", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "pause", + "type": "bool" + } + ] + }, + { + "name": "setPeer", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": true, + "isSigner": false + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetPeerArgs" + } + } + ] + }, + { + "name": "registerTransceiver", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredTransceiver", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setOutboundLimit", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetOutboundLimitArgs" + } + } + ] + }, + { + "name": "setInboundLimit", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetInboundLimitArgs" + } + } + ] + }, + { + "name": "setWormholePeer", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "peer", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetTransceiverPeerArgs" + } + } + ] + }, + { + "name": "receiveWormholeMessage", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "vaa", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiverMessage", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "releaseWormholeOutbound", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": false + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseOutboundArgs" + } + } + ] + }, + { + "name": "broadcastWormholeId", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": true + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [] + }, + { + "name": "broadcastWormholePeer", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": true + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "BroadcastPeerArgs" + } + } + ] + } + ], + "accounts": [ + { + "name": "Config", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "owner", + "docs": [ + "Owner of the program." + ], + "type": "publicKey" + }, + { + "name": "pendingOwner", + "docs": [ + "Pending next owner (before claiming ownership)." + ], + "type": { + "option": "publicKey" + } + }, + { + "name": "mint", + "docs": [ + "Mint address of the token managed by this program." + ], + "type": "publicKey" + }, + { + "name": "tokenProgram", + "docs": [ + "Address of the token program (token or token22). This could always be queried", + "from the [`mint`] account's owner, but storing it here avoids an indirection", + "on the client side." + ], + "type": "publicKey" + }, + { + "name": "mode", + "docs": [ + "The mode that this program is running in. This is used to determine", + "whether the program is burning tokens or locking tokens." + ], + "type": { + "defined": "Mode" + } + }, + { + "name": "chainId", + "docs": [ + "The chain id of the chain that this program is running on. We don't", + "hardcode this so that the program is deployable on any potential SVM", + "forks." + ], + "type": { + "defined": "ChainId" + } + }, + { + "name": "nextTransceiverId", + "docs": [ + "The next transceiver id to use when registering an transceiver." + ], + "type": "u8" + }, + { + "name": "threshold", + "docs": [ + "The number of transceivers that must attest to a transfer before it is", + "accepted." + ], + "type": "u8" + }, + { + "name": "enabledTransceivers", + "docs": [ + "Bitmap of enabled transceivers.", + "The maximum number of transceivers is equal to [`Bitmap::BITS`]." + ], + "type": { + "defined": "Bitmap" + } + }, + { + "name": "paused", + "docs": [ + "Pause the program. This is useful for upgrades and other maintenance." + ], + "type": "bool" + }, + { + "name": "custody", + "docs": [ + "The custody account that holds tokens in locking mode." + ], + "type": "publicKey" + } + ] + } + }, + { + "name": "LUT", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": "publicKey" + } + ] + } + }, + { + "name": "NttManagerPeer", + "docs": [ + "A peer on another chain. Stored in a PDA seeded by the chain id." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "tokenDecimals", + "type": "u8" + } + ] + } + }, + { + "name": "InboxItem", + "type": { + "kind": "struct", + "fields": [ + { + "name": "init", + "type": "bool" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipientAddress", + "type": "publicKey" + }, + { + "name": "votes", + "type": { + "defined": "Bitmap" + } + }, + { + "name": "releaseStatus", + "type": { + "defined": "ReleaseStatus" + } + } + ] + } + }, + { + "name": "InboxRateLimit", + "docs": [ + "Inbound rate limit per chain.", + "SECURITY: must check the PDA (since there are multiple PDAs, namely one for each chain.)" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "rateLimit", + "type": { + "defined": "RateLimitState" + } + } + ] + } + }, + { + "name": "OutboxItem", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": { + "defined": "TrimmedAmount" + } + }, + { + "name": "sender", + "type": "publicKey" + }, + { + "name": "recipientChain", + "type": { + "defined": "ChainId" + } + }, + { + "name": "recipientNttManager", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "recipientAddress", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "releaseTimestamp", + "type": "i64" + }, + { + "name": "released", + "type": { + "defined": "Bitmap" + } + } + ] + } + }, + { + "name": "OutboxRateLimit", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rateLimit", + "type": { + "defined": "RateLimitState" + } + } + ] + } + }, + { + "name": "RegisteredTransceiver", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "id", + "type": "u8" + }, + { + "name": "transceiverAddress", + "type": "publicKey" + } + ] + } + }, + { + "name": "TransceiverPeer", + "docs": [ + "A peer on another chain. Stored in a PDA seeded by the chain id." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "BridgeData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "guardianSetIndex", + "docs": [ + "The current guardian set index, used to decide which signature sets to accept." + ], + "type": "u32" + }, + { + "name": "lastLamports", + "docs": [ + "Lamports in the collection account" + ], + "type": "u64" + }, + { + "name": "config", + "docs": [ + "Bridge configuration, which is set once upon initialization." + ], + "type": { + "defined": "BridgeConfig" + } + } + ] + } + } + ], + "types": [ + { + "name": "Bitmap", + "type": { + "kind": "struct", + "fields": [ + { + "name": "map", + "type": "u128" + } + ] + } + }, + { + "name": "SetInboundLimitArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "type": "u64" + }, + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + } + ] + } + }, + { + "name": "SetOutboundLimitArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "type": "u64" + } + ] + } + }, + { + "name": "SetPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "limit", + "type": "u64" + }, + { + "name": "tokenDecimals", + "docs": [ + "The token decimals on the peer chain." + ], + "type": "u8" + } + ] + } + }, + { + "name": "InitializeArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + }, + { + "name": "limit", + "type": "u64" + }, + { + "name": "mode", + "type": { + "defined": "Mode" + } + } + ] + } + }, + { + "name": "RedeemArgs", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "ReleaseInboundArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "revertOnDelay", + "type": "bool" + } + ] + } + }, + { + "name": "TransferArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipientChain", + "type": { + "defined": "ChainId" + } + }, + { + "name": "recipientAddress", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "shouldQueue", + "type": "bool" + } + ] + } + }, + { + "name": "ReleaseStatus", + "docs": [ + "The status of an InboxItem. This determines whether the tokens are minted/unlocked to the recipient. As", + "such, this must be used as a state machine that moves forward in a linear manner. A state", + "should never \"move backward\" to a previous state (e.g. should never move from `Released` to", + "`ReleaseAfter`)." + ], + "type": { + "kind": "enum", + "variants": [ + { + "name": "NotApproved" + }, + { + "name": "ReleaseAfter", + "fields": [ + "i64" + ] + }, + { + "name": "Released" + } + ] + } + }, + { + "name": "RateLimitState", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "docs": [ + "The maximum capacity of the rate limiter." + ], + "type": "u64" + }, + { + "name": "capacityAtLastTx", + "docs": [ + "The capacity of the rate limiter at `last_tx_timestamp`.", + "The actual current capacity is calculated in `capacity_at`, by", + "accounting for the time that has passed since `last_tx_timestamp` and", + "the refill rate." + ], + "type": "u64" + }, + { + "name": "lastTxTimestamp", + "docs": [ + "The timestamp of the last transaction that counted towards the current", + "capacity. Transactions that exceeded the capacity do not count, they are", + "just delayed." + ], + "type": "i64" + } + ] + } + }, + { + "name": "SetTransceiverPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "BroadcastPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + } + ] + } + }, + { + "name": "ReleaseOutboundArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "revertOnDelay", + "type": "bool" + } + ] + } + }, + { + "name": "ChainId", + "type": { + "kind": "struct", + "fields": [ + { + "name": "id", + "type": "u16" + } + ] + } + }, + { + "name": "Mode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Locking" + }, + { + "name": "Burning" + } + ] + } + }, + { + "name": "TrimmedAmount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "decimals", + "type": "u8" + } + ] + } + }, + { + "name": "BridgeConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "guardianSetExpirationTime", + "docs": [ + "Period for how long a guardian set is valid after it has been replaced by a new one. This", + "guarantees that VAAs issued by that set can still be submitted for a certain period. In", + "this period we still trust the old guardian set." + ], + "type": "u32" + }, + { + "name": "fee", + "docs": [ + "Amount of lamports that needs to be paid to the protocol to post a message" + ], + "type": "u64" + } + ] + } + } + ], + "errors": [ + { + "code": 6000, + "name": "CantReleaseYet", + "msg": "CantReleaseYet" + }, + { + "code": 6001, + "name": "InvalidPendingOwner", + "msg": "InvalidPendingOwner" + }, + { + "code": 6002, + "name": "InvalidChainId", + "msg": "InvalidChainId" + }, + { + "code": 6003, + "name": "InvalidRecipientAddress", + "msg": "InvalidRecipientAddress" + }, + { + "code": 6004, + "name": "InvalidTransceiverPeer", + "msg": "InvalidTransceiverPeer" + }, + { + "code": 6005, + "name": "InvalidNttManagerPeer", + "msg": "InvalidNttManagerPeer" + }, + { + "code": 6006, + "name": "InvalidRecipientNttManager", + "msg": "InvalidRecipientNttManager" + }, + { + "code": 6007, + "name": "TransferAlreadyRedeemed", + "msg": "TransferAlreadyRedeemed" + }, + { + "code": 6008, + "name": "TransferCannotBeRedeemed", + "msg": "TransferCannotBeRedeemed" + }, + { + "code": 6009, + "name": "TransferNotApproved", + "msg": "TransferNotApproved" + }, + { + "code": 6010, + "name": "MessageAlreadySent", + "msg": "MessageAlreadySent" + }, + { + "code": 6011, + "name": "InvalidMode", + "msg": "InvalidMode" + }, + { + "code": 6012, + "name": "InvalidMintAuthority", + "msg": "InvalidMintAuthority" + }, + { + "code": 6013, + "name": "TransferExceedsRateLimit", + "msg": "TransferExceedsRateLimit" + }, + { + "code": 6014, + "name": "Paused", + "msg": "Paused" + }, + { + "code": 6015, + "name": "DisabledTransceiver", + "msg": "DisabledTransceiver" + }, + { + "code": 6016, + "name": "InvalidDeployer", + "msg": "InvalidDeployer" + }, + { + "code": 6017, + "name": "BadAmountAfterTransfer", + "msg": "BadAmountAfterTransfer" + }, + { + "code": 6018, + "name": "BadAmountAfterBurn", + "msg": "BadAmountAfterBurn" + }, + { + "code": 6019, + "name": "ZeroThreshold", + "msg": "ZeroThreshold" + }, + { + "code": 6020, + "name": "OverflowExponent", + "msg": "OverflowExponent" + }, + { + "code": 6021, + "name": "OverflowScaledAmount", + "msg": "OverflowScaledAmount" + }, + { + "code": 6022, + "name": "BitmapIndexOutOfBounds", + "msg": "BitmapIndexOutOfBounds" + } + ] +} diff --git a/sdk/solana/src/anchor-idl/2_0_0/example_native_token_transfers.ts b/sdk/solana/src/anchor-idl/2_0_0/example_native_token_transfers.ts new file mode 100644 index 000000000..4a7fceeeb --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0/example_native_token_transfers.ts @@ -0,0 +1,4087 @@ +export type ExampleNativeTokenTransfers = { + "version": "2.0.0", + "name": "example_native_token_transfers", + "instructions": [ + { + "name": "initialize", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "deployer", + "isMut": false, + "isSigner": true + }, + { + "name": "programData", + "isMut": false, + "isSigner": false + }, + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "The custody account that holds tokens in locking mode and temporarily", + "holds tokens in burning mode.", + "function if the token account has already been created." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false, + "docs": [ + "associated token account for the given mint." + ] + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "InitializeArgs" + } + } + ] + }, + { + "name": "initializeLut", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "lutAddress", + "isMut": true, + "isSigner": false + }, + { + "name": "lut", + "isMut": true, + "isSigner": false + }, + { + "name": "lutProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "entries", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxRateLimit", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ] + } + ], + "args": [ + { + "name": "recentSlot", + "type": "u64" + } + ] + }, + { + "name": "version", + "accounts": [], + "args": [], + "returns": "string" + }, + { + "name": "transferBurn", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "from", + "isMut": true, + "isSigner": false, + "docs": [ + "account can spend these tokens." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": true + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "Tokens are always transferred to the custody account first regardless of", + "the mode.", + "For an explanation, see the note in [`transfer_burn`]." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "sessionAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "See [`crate::SESSION_AUTHORITY_SEED`] for an explanation of the flow." + ] + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "TransferArgs" + } + } + ] + }, + { + "name": "transferLock", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "from", + "isMut": true, + "isSigner": false, + "docs": [ + "account can spend these tokens." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": true + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "Tokens are always transferred to the custody account first regardless of", + "the mode.", + "For an explanation, see the note in [`transfer_burn`]." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "sessionAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "See [`crate::SESSION_AUTHORITY_SEED`] for an explanation of the flow." + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "TransferArgs" + } + } + ] + }, + { + "name": "redeem", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiverMessage", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false, + "docs": [ + "NOTE: This account is content-addressed (PDA seeded by the message hash).", + "This is because in a multi-transceiver configuration, the different", + "transceivers \"vote\" on messages (by delivering them). By making the inbox", + "items content-addressed, we can ensure that disagreeing votes don't", + "interfere with each other.", + "On the first call to [`redeem()`], [`InboxItem`] will be allocated and initialized with", + "default values.", + "On subsequent calls, we want to modify the `InboxItem` by \"voting\" on it. Therefore the", + "program should not fail which would occur when using the `init` constraint.", + "The [`InboxItem::init`] field is used to guard against malicious or accidental modification", + "InboxItem fields that should remain constant." + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RedeemArgs" + } + } + ] + }, + { + "name": "releaseInboundMint", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "recipient", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseInboundArgs" + } + } + ] + }, + { + "name": "releaseInboundUnlock", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "recipient", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseInboundArgs" + } + } + ] + }, + { + "name": "transferOwnership", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "newOwner", + "isMut": false, + "isSigner": false + }, + { + "name": "upgradeLock", + "isMut": false, + "isSigner": false + }, + { + "name": "programData", + "isMut": true, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "claimOwnership", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "upgradeLock", + "isMut": false, + "isSigner": false + }, + { + "name": "newOwner", + "isMut": false, + "isSigner": true + }, + { + "name": "programData", + "isMut": true, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setPaused", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "config", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "pause", + "type": "bool" + } + ] + }, + { + "name": "setPeer", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": true, + "isSigner": false + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetPeerArgs" + } + } + ] + }, + { + "name": "registerTransceiver", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredTransceiver", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setOutboundLimit", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetOutboundLimitArgs" + } + } + ] + }, + { + "name": "setInboundLimit", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetInboundLimitArgs" + } + } + ] + }, + { + "name": "setWormholePeer", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "peer", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetTransceiverPeerArgs" + } + } + ] + }, + { + "name": "receiveWormholeMessage", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "vaa", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiverMessage", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "releaseWormholeOutbound", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": false + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseOutboundArgs" + } + } + ] + }, + { + "name": "broadcastWormholeId", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": true + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [] + }, + { + "name": "broadcastWormholePeer", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": true + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "BroadcastPeerArgs" + } + } + ] + } + ], + "accounts": [ + { + "name": "config", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "owner", + "docs": [ + "Owner of the program." + ], + "type": "publicKey" + }, + { + "name": "pendingOwner", + "docs": [ + "Pending next owner (before claiming ownership)." + ], + "type": { + "option": "publicKey" + } + }, + { + "name": "mint", + "docs": [ + "Mint address of the token managed by this program." + ], + "type": "publicKey" + }, + { + "name": "tokenProgram", + "docs": [ + "Address of the token program (token or token22). This could always be queried", + "from the [`mint`] account's owner, but storing it here avoids an indirection", + "on the client side." + ], + "type": "publicKey" + }, + { + "name": "mode", + "docs": [ + "The mode that this program is running in. This is used to determine", + "whether the program is burning tokens or locking tokens." + ], + "type": { + "defined": "Mode" + } + }, + { + "name": "chainId", + "docs": [ + "The chain id of the chain that this program is running on. We don't", + "hardcode this so that the program is deployable on any potential SVM", + "forks." + ], + "type": { + "defined": "ChainId" + } + }, + { + "name": "nextTransceiverId", + "docs": [ + "The next transceiver id to use when registering an transceiver." + ], + "type": "u8" + }, + { + "name": "threshold", + "docs": [ + "The number of transceivers that must attest to a transfer before it is", + "accepted." + ], + "type": "u8" + }, + { + "name": "enabledTransceivers", + "docs": [ + "Bitmap of enabled transceivers.", + "The maximum number of transceivers is equal to [`Bitmap::BITS`]." + ], + "type": { + "defined": "Bitmap" + } + }, + { + "name": "paused", + "docs": [ + "Pause the program. This is useful for upgrades and other maintenance." + ], + "type": "bool" + }, + { + "name": "custody", + "docs": [ + "The custody account that holds tokens in locking mode." + ], + "type": "publicKey" + } + ] + } + }, + { + "name": "lut", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": "publicKey" + } + ] + } + }, + { + "name": "validatedTransceiverMessage", + "generics": [ + "A" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "fromChain", + "type": { + "defined": "ChainId" + } + }, + { + "name": "message", + "type": { + "definedWithTypeArgs": { + "name": "TransceiverMessageData", + "args": [ + { + "type": { + "generic": "A" + } + } + ] + } + } + } + ] + } + }, + { + "name": "nttManagerPeer", + "docs": [ + "A peer on another chain. Stored in a PDA seeded by the chain id." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "tokenDecimals", + "type": "u8" + } + ] + } + }, + { + "name": "inboxItem", + "type": { + "kind": "struct", + "fields": [ + { + "name": "init", + "type": "bool" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipientAddress", + "type": "publicKey" + }, + { + "name": "votes", + "type": { + "defined": "Bitmap" + } + }, + { + "name": "releaseStatus", + "type": { + "defined": "ReleaseStatus" + } + } + ] + } + }, + { + "name": "inboxRateLimit", + "docs": [ + "Inbound rate limit per chain.", + "SECURITY: must check the PDA (since there are multiple PDAs, namely one for each chain.)" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "rateLimit", + "type": { + "defined": "RateLimitState" + } + } + ] + } + }, + { + "name": "outboxItem", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": { + "defined": "TrimmedAmount" + } + }, + { + "name": "sender", + "type": "publicKey" + }, + { + "name": "recipientChain", + "type": { + "defined": "ChainId" + } + }, + { + "name": "recipientNttManager", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "recipientAddress", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "releaseTimestamp", + "type": "i64" + }, + { + "name": "released", + "type": { + "defined": "Bitmap" + } + } + ] + } + }, + { + "name": "outboxRateLimit", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rateLimit", + "type": { + "defined": "RateLimitState" + } + } + ] + } + }, + { + "name": "registeredTransceiver", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "id", + "type": "u8" + }, + { + "name": "transceiverAddress", + "type": "publicKey" + } + ] + } + }, + { + "name": "transceiverPeer", + "docs": [ + "A peer on another chain. Stored in a PDA seeded by the chain id." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "bridgeData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "guardianSetIndex", + "docs": [ + "The current guardian set index, used to decide which signature sets to accept." + ], + "type": "u32" + }, + { + "name": "lastLamports", + "docs": [ + "Lamports in the collection account" + ], + "type": "u64" + }, + { + "name": "config", + "docs": [ + "Bridge configuration, which is set once upon initialization." + ], + "type": { + "defined": "BridgeConfig" + } + } + ] + } + } + ], + "types": [ + { + "name": "Bitmap", + "type": { + "kind": "struct", + "fields": [ + { + "name": "map", + "type": "u128" + } + ] + } + }, + { + "name": "SetInboundLimitArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "type": "u64" + }, + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + } + ] + } + }, + { + "name": "SetOutboundLimitArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "type": "u64" + } + ] + } + }, + { + "name": "SetPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "limit", + "type": "u64" + }, + { + "name": "tokenDecimals", + "docs": [ + "The token decimals on the peer chain." + ], + "type": "u8" + } + ] + } + }, + { + "name": "InitializeArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + }, + { + "name": "limit", + "type": "u64" + }, + { + "name": "mode", + "type": { + "defined": "Mode" + } + } + ] + } + }, + { + "name": "RedeemArgs", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "ReleaseInboundArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "revertOnDelay", + "type": "bool" + } + ] + } + }, + { + "name": "TransferArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipientChain", + "type": { + "defined": "ChainId" + } + }, + { + "name": "recipientAddress", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "shouldQueue", + "type": "bool" + } + ] + } + }, + { + "name": "ReleaseStatus", + "docs": [ + "The status of an InboxItem. This determines whether the tokens are minted/unlocked to the recipient. As", + "such, this must be used as a state machine that moves forward in a linear manner. A state", + "should never \"move backward\" to a previous state (e.g. should never move from `Released` to", + "`ReleaseAfter`)." + ], + "type": { + "kind": "enum", + "variants": [ + { + "name": "NotApproved" + }, + { + "name": "ReleaseAfter", + "fields": [ + "i64" + ] + }, + { + "name": "Released" + } + ] + } + }, + { + "name": "RateLimitState", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "docs": [ + "The maximum capacity of the rate limiter." + ], + "type": "u64" + }, + { + "name": "capacityAtLastTx", + "docs": [ + "The capacity of the rate limiter at `last_tx_timestamp`.", + "The actual current capacity is calculated in `capacity_at`, by", + "accounting for the time that has passed since `last_tx_timestamp` and", + "the refill rate." + ], + "type": "u64" + }, + { + "name": "lastTxTimestamp", + "docs": [ + "The timestamp of the last transaction that counted towards the current", + "capacity. Transactions that exceeded the capacity do not count, they are", + "just delayed." + ], + "type": "i64" + } + ] + } + }, + { + "name": "SetTransceiverPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "BroadcastPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + } + ] + } + }, + { + "name": "ReleaseOutboundArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "revertOnDelay", + "type": "bool" + } + ] + } + }, + { + "name": "ChainId", + "type": { + "kind": "struct", + "fields": [ + { + "name": "id", + "type": "u16" + } + ] + } + }, + { + "name": "Mode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Locking" + }, + { + "name": "Burning" + } + ] + } + }, + { + "name": "NttManagerMessage", + "generics": [ + "A" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "id", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "sender", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "payload", + "type": { + "generic": "A" + } + } + ] + } + }, + { + "name": "TransceiverMessageData", + "generics": [ + "A" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "sourceNttManager", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "recipientNttManager", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "nttManagerPayload", + "type": { + "definedWithTypeArgs": { + "name": "NttManagerMessage", + "args": [ + { + "type": { + "generic": "A" + } + } + ] + } + } + } + ] + } + }, + { + "name": "TrimmedAmount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "decimals", + "type": "u8" + } + ] + } + }, + { + "name": "BridgeConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "guardianSetExpirationTime", + "docs": [ + "Period for how long a guardian set is valid after it has been replaced by a new one. This", + "guarantees that VAAs issued by that set can still be submitted for a certain period. In", + "this period we still trust the old guardian set." + ], + "type": "u32" + }, + { + "name": "fee", + "docs": [ + "Amount of lamports that needs to be paid to the protocol to post a message" + ], + "type": "u64" + } + ] + } + } + ], + "errors": [ + { + "code": 6000, + "name": "CantReleaseYet", + "msg": "CantReleaseYet" + }, + { + "code": 6001, + "name": "InvalidPendingOwner", + "msg": "InvalidPendingOwner" + }, + { + "code": 6002, + "name": "InvalidChainId", + "msg": "InvalidChainId" + }, + { + "code": 6003, + "name": "InvalidRecipientAddress", + "msg": "InvalidRecipientAddress" + }, + { + "code": 6004, + "name": "InvalidTransceiverPeer", + "msg": "InvalidTransceiverPeer" + }, + { + "code": 6005, + "name": "InvalidNttManagerPeer", + "msg": "InvalidNttManagerPeer" + }, + { + "code": 6006, + "name": "InvalidRecipientNttManager", + "msg": "InvalidRecipientNttManager" + }, + { + "code": 6007, + "name": "TransferAlreadyRedeemed", + "msg": "TransferAlreadyRedeemed" + }, + { + "code": 6008, + "name": "TransferCannotBeRedeemed", + "msg": "TransferCannotBeRedeemed" + }, + { + "code": 6009, + "name": "TransferNotApproved", + "msg": "TransferNotApproved" + }, + { + "code": 6010, + "name": "MessageAlreadySent", + "msg": "MessageAlreadySent" + }, + { + "code": 6011, + "name": "InvalidMode", + "msg": "InvalidMode" + }, + { + "code": 6012, + "name": "InvalidMintAuthority", + "msg": "InvalidMintAuthority" + }, + { + "code": 6013, + "name": "TransferExceedsRateLimit", + "msg": "TransferExceedsRateLimit" + }, + { + "code": 6014, + "name": "Paused", + "msg": "Paused" + }, + { + "code": 6015, + "name": "DisabledTransceiver", + "msg": "DisabledTransceiver" + }, + { + "code": 6016, + "name": "InvalidDeployer", + "msg": "InvalidDeployer" + }, + { + "code": 6017, + "name": "BadAmountAfterTransfer", + "msg": "BadAmountAfterTransfer" + }, + { + "code": 6018, + "name": "BadAmountAfterBurn", + "msg": "BadAmountAfterBurn" + }, + { + "code": 6019, + "name": "ZeroThreshold", + "msg": "ZeroThreshold" + }, + { + "code": 6020, + "name": "OverflowExponent", + "msg": "OverflowExponent" + }, + { + "code": 6021, + "name": "OverflowScaledAmount", + "msg": "OverflowScaledAmount" + }, + { + "code": 6022, + "name": "BitmapIndexOutOfBounds", + "msg": "BitmapIndexOutOfBounds" + } + ] +}; + +export const IDL: ExampleNativeTokenTransfers = { + "version": "2.0.0", + "name": "example_native_token_transfers", + "instructions": [ + { + "name": "initialize", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "deployer", + "isMut": false, + "isSigner": true + }, + { + "name": "programData", + "isMut": false, + "isSigner": false + }, + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "The custody account that holds tokens in locking mode and temporarily", + "holds tokens in burning mode.", + "function if the token account has already been created." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false, + "docs": [ + "associated token account for the given mint." + ] + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "InitializeArgs" + } + } + ] + }, + { + "name": "initializeLut", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": false, + "isSigner": false + }, + { + "name": "lutAddress", + "isMut": true, + "isSigner": false + }, + { + "name": "lut", + "isMut": true, + "isSigner": false + }, + { + "name": "lutProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "entries", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxRateLimit", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ] + } + ], + "args": [ + { + "name": "recentSlot", + "type": "u64" + } + ] + }, + { + "name": "version", + "accounts": [], + "args": [], + "returns": "string" + }, + { + "name": "transferBurn", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "from", + "isMut": true, + "isSigner": false, + "docs": [ + "account can spend these tokens." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": true + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "Tokens are always transferred to the custody account first regardless of", + "the mode.", + "For an explanation, see the note in [`transfer_burn`]." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "sessionAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "See [`crate::SESSION_AUTHORITY_SEED`] for an explanation of the flow." + ] + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "TransferArgs" + } + } + ] + }, + { + "name": "transferLock", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "from", + "isMut": true, + "isSigner": false, + "docs": [ + "account can spend these tokens." + ] + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": true + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false, + "docs": [ + "Tokens are always transferred to the custody account first regardless of", + "the mode.", + "For an explanation, see the note in [`transfer_burn`]." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "sessionAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "See [`crate::SESSION_AUTHORITY_SEED`] for an explanation of the flow." + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "TransferArgs" + } + } + ] + }, + { + "name": "redeem", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiverMessage", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false, + "docs": [ + "NOTE: This account is content-addressed (PDA seeded by the message hash).", + "This is because in a multi-transceiver configuration, the different", + "transceivers \"vote\" on messages (by delivering them). By making the inbox", + "items content-addressed, we can ensure that disagreeing votes don't", + "interfere with each other.", + "On the first call to [`redeem()`], [`InboxItem`] will be allocated and initialized with", + "default values.", + "On subsequent calls, we want to modify the `InboxItem` by \"voting\" on it. Therefore the", + "program should not fail which would occur when using the `init` constraint.", + "The [`InboxItem::init`] field is used to guard against malicious or accidental modification", + "InboxItem fields that should remain constant." + ] + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "outboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RedeemArgs" + } + } + ] + }, + { + "name": "releaseInboundMint", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "recipient", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseInboundArgs" + } + } + ] + }, + { + "name": "releaseInboundUnlock", + "accounts": [ + { + "name": "common", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "inboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "recipient", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "custody", + "isMut": true, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseInboundArgs" + } + } + ] + }, + { + "name": "transferOwnership", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "newOwner", + "isMut": false, + "isSigner": false + }, + { + "name": "upgradeLock", + "isMut": false, + "isSigner": false + }, + { + "name": "programData", + "isMut": true, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "claimOwnership", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "upgradeLock", + "isMut": false, + "isSigner": false + }, + { + "name": "newOwner", + "isMut": false, + "isSigner": true + }, + { + "name": "programData", + "isMut": true, + "isSigner": false + }, + { + "name": "bpfLoaderUpgradeableProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setPaused", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "config", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "pause", + "type": "bool" + } + ] + }, + { + "name": "setPeer", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": true, + "isSigner": false + }, + { + "name": "inboxRateLimit", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetPeerArgs" + } + } + ] + }, + { + "name": "registerTransceiver", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredTransceiver", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setOutboundLimit", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetOutboundLimitArgs" + } + } + ] + }, + { + "name": "setInboundLimit", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "rateLimit", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetInboundLimitArgs" + } + } + ] + }, + { + "name": "setWormholePeer", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "peer", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SetTransceiverPeerArgs" + } + } + ] + }, + { + "name": "receiveWormholeMessage", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "vaa", + "isMut": false, + "isSigner": false + }, + { + "name": "transceiverMessage", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "releaseWormholeOutbound", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "accounts": [ + { + "name": "config", + "isMut": false, + "isSigner": false + } + ] + }, + { + "name": "outboxItem", + "isMut": true, + "isSigner": false + }, + { + "name": "transceiver", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": false + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "ReleaseOutboundArgs" + } + } + ] + }, + { + "name": "broadcastWormholeId", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": true + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [] + }, + { + "name": "broadcastWormholePeer", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "peer", + "isMut": false, + "isSigner": false + }, + { + "name": "wormholeMessage", + "isMut": true, + "isSigner": true + }, + { + "name": "emitter", + "isMut": false, + "isSigner": false + }, + { + "name": "wormhole", + "accounts": [ + { + "name": "bridge", + "isMut": true, + "isSigner": false + }, + { + "name": "feeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "sequence", + "isMut": true, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ] + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "BroadcastPeerArgs" + } + } + ] + } + ], + "accounts": [ + { + "name": "config", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "owner", + "docs": [ + "Owner of the program." + ], + "type": "publicKey" + }, + { + "name": "pendingOwner", + "docs": [ + "Pending next owner (before claiming ownership)." + ], + "type": { + "option": "publicKey" + } + }, + { + "name": "mint", + "docs": [ + "Mint address of the token managed by this program." + ], + "type": "publicKey" + }, + { + "name": "tokenProgram", + "docs": [ + "Address of the token program (token or token22). This could always be queried", + "from the [`mint`] account's owner, but storing it here avoids an indirection", + "on the client side." + ], + "type": "publicKey" + }, + { + "name": "mode", + "docs": [ + "The mode that this program is running in. This is used to determine", + "whether the program is burning tokens or locking tokens." + ], + "type": { + "defined": "Mode" + } + }, + { + "name": "chainId", + "docs": [ + "The chain id of the chain that this program is running on. We don't", + "hardcode this so that the program is deployable on any potential SVM", + "forks." + ], + "type": { + "defined": "ChainId" + } + }, + { + "name": "nextTransceiverId", + "docs": [ + "The next transceiver id to use when registering an transceiver." + ], + "type": "u8" + }, + { + "name": "threshold", + "docs": [ + "The number of transceivers that must attest to a transfer before it is", + "accepted." + ], + "type": "u8" + }, + { + "name": "enabledTransceivers", + "docs": [ + "Bitmap of enabled transceivers.", + "The maximum number of transceivers is equal to [`Bitmap::BITS`]." + ], + "type": { + "defined": "Bitmap" + } + }, + { + "name": "paused", + "docs": [ + "Pause the program. This is useful for upgrades and other maintenance." + ], + "type": "bool" + }, + { + "name": "custody", + "docs": [ + "The custody account that holds tokens in locking mode." + ], + "type": "publicKey" + } + ] + } + }, + { + "name": "lut", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": "publicKey" + } + ] + } + }, + { + "name": "validatedTransceiverMessage", + "generics": [ + "A" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "fromChain", + "type": { + "defined": "ChainId" + } + }, + { + "name": "message", + "type": { + "definedWithTypeArgs": { + "name": "TransceiverMessageData", + "args": [ + { + "type": { + "generic": "A" + } + } + ] + } + } + } + ] + } + }, + { + "name": "nttManagerPeer", + "docs": [ + "A peer on another chain. Stored in a PDA seeded by the chain id." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "tokenDecimals", + "type": "u8" + } + ] + } + }, + { + "name": "inboxItem", + "type": { + "kind": "struct", + "fields": [ + { + "name": "init", + "type": "bool" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipientAddress", + "type": "publicKey" + }, + { + "name": "votes", + "type": { + "defined": "Bitmap" + } + }, + { + "name": "releaseStatus", + "type": { + "defined": "ReleaseStatus" + } + } + ] + } + }, + { + "name": "inboxRateLimit", + "docs": [ + "Inbound rate limit per chain.", + "SECURITY: must check the PDA (since there are multiple PDAs, namely one for each chain.)" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "rateLimit", + "type": { + "defined": "RateLimitState" + } + } + ] + } + }, + { + "name": "outboxItem", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": { + "defined": "TrimmedAmount" + } + }, + { + "name": "sender", + "type": "publicKey" + }, + { + "name": "recipientChain", + "type": { + "defined": "ChainId" + } + }, + { + "name": "recipientNttManager", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "recipientAddress", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "releaseTimestamp", + "type": "i64" + }, + { + "name": "released", + "type": { + "defined": "Bitmap" + } + } + ] + } + }, + { + "name": "outboxRateLimit", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rateLimit", + "type": { + "defined": "RateLimitState" + } + } + ] + } + }, + { + "name": "registeredTransceiver", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "id", + "type": "u8" + }, + { + "name": "transceiverAddress", + "type": "publicKey" + } + ] + } + }, + { + "name": "transceiverPeer", + "docs": [ + "A peer on another chain. Stored in a PDA seeded by the chain id." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "bridgeData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "guardianSetIndex", + "docs": [ + "The current guardian set index, used to decide which signature sets to accept." + ], + "type": "u32" + }, + { + "name": "lastLamports", + "docs": [ + "Lamports in the collection account" + ], + "type": "u64" + }, + { + "name": "config", + "docs": [ + "Bridge configuration, which is set once upon initialization." + ], + "type": { + "defined": "BridgeConfig" + } + } + ] + } + } + ], + "types": [ + { + "name": "Bitmap", + "type": { + "kind": "struct", + "fields": [ + { + "name": "map", + "type": "u128" + } + ] + } + }, + { + "name": "SetInboundLimitArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "type": "u64" + }, + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + } + ] + } + }, + { + "name": "SetOutboundLimitArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "type": "u64" + } + ] + } + }, + { + "name": "SetPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "limit", + "type": "u64" + }, + { + "name": "tokenDecimals", + "docs": [ + "The token decimals on the peer chain." + ], + "type": "u8" + } + ] + } + }, + { + "name": "InitializeArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + }, + { + "name": "limit", + "type": "u64" + }, + { + "name": "mode", + "type": { + "defined": "Mode" + } + } + ] + } + }, + { + "name": "RedeemArgs", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "ReleaseInboundArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "revertOnDelay", + "type": "bool" + } + ] + } + }, + { + "name": "TransferArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipientChain", + "type": { + "defined": "ChainId" + } + }, + { + "name": "recipientAddress", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "shouldQueue", + "type": "bool" + } + ] + } + }, + { + "name": "ReleaseStatus", + "docs": [ + "The status of an InboxItem. This determines whether the tokens are minted/unlocked to the recipient. As", + "such, this must be used as a state machine that moves forward in a linear manner. A state", + "should never \"move backward\" to a previous state (e.g. should never move from `Released` to", + "`ReleaseAfter`)." + ], + "type": { + "kind": "enum", + "variants": [ + { + "name": "NotApproved" + }, + { + "name": "ReleaseAfter", + "fields": [ + "i64" + ] + }, + { + "name": "Released" + } + ] + } + }, + { + "name": "RateLimitState", + "type": { + "kind": "struct", + "fields": [ + { + "name": "limit", + "docs": [ + "The maximum capacity of the rate limiter." + ], + "type": "u64" + }, + { + "name": "capacityAtLastTx", + "docs": [ + "The capacity of the rate limiter at `last_tx_timestamp`.", + "The actual current capacity is calculated in `capacity_at`, by", + "accounting for the time that has passed since `last_tx_timestamp` and", + "the refill rate." + ], + "type": "u64" + }, + { + "name": "lastTxTimestamp", + "docs": [ + "The timestamp of the last transaction that counted towards the current", + "capacity. Transactions that exceeded the capacity do not count, they are", + "just delayed." + ], + "type": "i64" + } + ] + } + }, + { + "name": "SetTransceiverPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": { + "defined": "ChainId" + } + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "BroadcastPeerArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + } + ] + } + }, + { + "name": "ReleaseOutboundArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "revertOnDelay", + "type": "bool" + } + ] + } + }, + { + "name": "ChainId", + "type": { + "kind": "struct", + "fields": [ + { + "name": "id", + "type": "u16" + } + ] + } + }, + { + "name": "Mode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Locking" + }, + { + "name": "Burning" + } + ] + } + }, + { + "name": "NttManagerMessage", + "generics": [ + "A" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "id", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "sender", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "payload", + "type": { + "generic": "A" + } + } + ] + } + }, + { + "name": "TransceiverMessageData", + "generics": [ + "A" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "sourceNttManager", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "recipientNttManager", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "nttManagerPayload", + "type": { + "definedWithTypeArgs": { + "name": "NttManagerMessage", + "args": [ + { + "type": { + "generic": "A" + } + } + ] + } + } + } + ] + } + }, + { + "name": "TrimmedAmount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "decimals", + "type": "u8" + } + ] + } + }, + { + "name": "BridgeConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "guardianSetExpirationTime", + "docs": [ + "Period for how long a guardian set is valid after it has been replaced by a new one. This", + "guarantees that VAAs issued by that set can still be submitted for a certain period. In", + "this period we still trust the old guardian set." + ], + "type": "u32" + }, + { + "name": "fee", + "docs": [ + "Amount of lamports that needs to be paid to the protocol to post a message" + ], + "type": "u64" + } + ] + } + } + ], + "errors": [ + { + "code": 6000, + "name": "CantReleaseYet", + "msg": "CantReleaseYet" + }, + { + "code": 6001, + "name": "InvalidPendingOwner", + "msg": "InvalidPendingOwner" + }, + { + "code": 6002, + "name": "InvalidChainId", + "msg": "InvalidChainId" + }, + { + "code": 6003, + "name": "InvalidRecipientAddress", + "msg": "InvalidRecipientAddress" + }, + { + "code": 6004, + "name": "InvalidTransceiverPeer", + "msg": "InvalidTransceiverPeer" + }, + { + "code": 6005, + "name": "InvalidNttManagerPeer", + "msg": "InvalidNttManagerPeer" + }, + { + "code": 6006, + "name": "InvalidRecipientNttManager", + "msg": "InvalidRecipientNttManager" + }, + { + "code": 6007, + "name": "TransferAlreadyRedeemed", + "msg": "TransferAlreadyRedeemed" + }, + { + "code": 6008, + "name": "TransferCannotBeRedeemed", + "msg": "TransferCannotBeRedeemed" + }, + { + "code": 6009, + "name": "TransferNotApproved", + "msg": "TransferNotApproved" + }, + { + "code": 6010, + "name": "MessageAlreadySent", + "msg": "MessageAlreadySent" + }, + { + "code": 6011, + "name": "InvalidMode", + "msg": "InvalidMode" + }, + { + "code": 6012, + "name": "InvalidMintAuthority", + "msg": "InvalidMintAuthority" + }, + { + "code": 6013, + "name": "TransferExceedsRateLimit", + "msg": "TransferExceedsRateLimit" + }, + { + "code": 6014, + "name": "Paused", + "msg": "Paused" + }, + { + "code": 6015, + "name": "DisabledTransceiver", + "msg": "DisabledTransceiver" + }, + { + "code": 6016, + "name": "InvalidDeployer", + "msg": "InvalidDeployer" + }, + { + "code": 6017, + "name": "BadAmountAfterTransfer", + "msg": "BadAmountAfterTransfer" + }, + { + "code": 6018, + "name": "BadAmountAfterBurn", + "msg": "BadAmountAfterBurn" + }, + { + "code": 6019, + "name": "ZeroThreshold", + "msg": "ZeroThreshold" + }, + { + "code": 6020, + "name": "OverflowExponent", + "msg": "OverflowExponent" + }, + { + "code": 6021, + "name": "OverflowScaledAmount", + "msg": "OverflowScaledAmount" + }, + { + "code": 6022, + "name": "BitmapIndexOutOfBounds", + "msg": "BitmapIndexOutOfBounds" + } + ] +}; diff --git a/sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.json b/sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.json new file mode 100644 index 000000000..d6c6f2f7a --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.json @@ -0,0 +1,588 @@ +{ + "version": "2.0.0", + "name": "ntt_quoter", + "instructions": [ + { + "name": "requestRelay", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": false, + "isSigner": false, + "docs": [ + "and checking the release constraint into a single function" + ] + }, + { + "name": "relayRequest", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RequestRelayArgs" + } + } + ] + }, + { + "name": "closeRelay", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": true, + "isSigner": false + }, + { + "name": "relayRequest", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "initialize", + "accounts": [ + { + "name": "owner", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": false, + "isSigner": false + }, + { + "name": "programData", + "isMut": true, + "isSigner": false, + "docs": [ + "We use the program data to make sure this owner is the upgrade authority (the true owner,", + "who deployed this program)." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setAssistant", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "assistant", + "isMut": false, + "isSigner": false, + "isOptional": true + } + ], + "args": [] + }, + { + "name": "setFeeRecipient", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "registerChain", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RegisterChainArgs" + } + } + ] + }, + { + "name": "registerNtt", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RegisterNttArgs" + } + } + ] + }, + { + "name": "deregisterNtt", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "DeregisterNttArgs" + } + } + ] + }, + { + "name": "updateSolPrice", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateSolPriceArgs" + } + } + ] + }, + { + "name": "updateChainPrices", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateChainPricesArgs" + } + } + ] + }, + { + "name": "updateChainParams", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateChainParamsArgs" + } + } + ] + } + ], + "accounts": [ + { + "name": "Instance", + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "publicKey" + }, + { + "name": "assistant", + "type": "publicKey" + }, + { + "name": "feeRecipient", + "type": "publicKey" + }, + { + "name": "solPrice", + "type": "u64" + } + ] + } + }, + { + "name": "RegisteredChain", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "maxGasDropoff", + "type": "u64" + }, + { + "name": "basePrice", + "type": "u64" + }, + { + "name": "nativePrice", + "type": "u64" + }, + { + "name": "gasPrice", + "type": "u64" + } + ] + } + }, + { + "name": "RegisteredNtt", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "wormholeTransceiverIndex", + "type": "u8" + }, + { + "name": "gasCost", + "type": "u32" + } + ] + } + }, + { + "name": "RelayRequest", + "type": { + "kind": "struct", + "fields": [ + { + "name": "requestedGasDropoff", + "type": "u64" + } + ] + } + } + ], + "types": [ + { + "name": "RegisterChainArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + } + ] + } + }, + { + "name": "RegisterNttArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nttProgramId", + "type": "publicKey" + }, + { + "name": "wormholeTransceiverIndex", + "type": "u8" + }, + { + "name": "gasCost", + "type": "u32" + } + ] + } + }, + { + "name": "DeregisterNttArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nttProgramId", + "type": "publicKey" + } + ] + } + }, + { + "name": "RequestRelayArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "gasDropoff", + "type": "u64" + }, + { + "name": "maxFee", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateSolPriceArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "solPrice", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateChainPricesArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nativePrice", + "type": "u64" + }, + { + "name": "gasPrice", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateChainParamsArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxGasDropoff", + "type": "u64" + }, + { + "name": "basePrice", + "type": "u64" + } + ] + } + } + ], + "errors": [ + { + "code": 6001, + "name": "ExceedsUserMaxFee", + "msg": "Relay fees exceeds specified max" + }, + { + "code": 6002, + "name": "ExceedsMaxGasDropoff", + "msg": "Requested gas dropoff exceeds max allowed for chain" + }, + { + "code": 6003, + "name": "InvalidFeeRecipient", + "msg": "The specified fee recipient does not match the address in the instance accound" + }, + { + "code": 6004, + "name": "RelayingToChainDisabled", + "msg": "Relaying to the specified chain is disabled" + }, + { + "code": 6005, + "name": "OutboxItemNotReleased", + "msg": "Relaying to the specified chain is disabled" + }, + { + "code": 6006, + "name": "ScalingOverflow", + "msg": "Scaled value exceeds u64::MAX" + }, + { + "code": 6007, + "name": "DivByZero", + "msg": "Cannot divide by zero" + }, + { + "code": 6257, + "name": "FeeRecipientCannotBeDefault", + "msg": "The fee recipient cannot be the default address (0x0)" + }, + { + "code": 6258, + "name": "NotAuthorized", + "msg": "Must be owner or assistant" + }, + { + "code": 6259, + "name": "PriceCannotBeZero", + "msg": "The price cannot be zero" + } + ] +} \ No newline at end of file diff --git a/sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.ts b/sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.ts new file mode 100644 index 000000000..063f2ec30 --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0/ntt_quoter.ts @@ -0,0 +1,1177 @@ +export type NttQuoter = { + "version": "2.0.0", + "name": "ntt_quoter", + "instructions": [ + { + "name": "requestRelay", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": false, + "isSigner": false, + "docs": [ + "and checking the release constraint into a single function" + ] + }, + { + "name": "relayRequest", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RequestRelayArgs" + } + } + ] + }, + { + "name": "closeRelay", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": true, + "isSigner": false + }, + { + "name": "relayRequest", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "initialize", + "accounts": [ + { + "name": "owner", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": false, + "isSigner": false + }, + { + "name": "programData", + "isMut": true, + "isSigner": false, + "docs": [ + "We use the program data to make sure this owner is the upgrade authority (the true owner,", + "who deployed this program)." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setAssistant", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "assistant", + "isMut": false, + "isSigner": false, + "isOptional": true + } + ], + "args": [] + }, + { + "name": "setFeeRecipient", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "registerChain", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RegisterChainArgs" + } + } + ] + }, + { + "name": "registerNtt", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RegisterNttArgs" + } + } + ] + }, + { + "name": "deregisterNtt", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "DeregisterNttArgs" + } + } + ] + }, + { + "name": "updateSolPrice", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateSolPriceArgs" + } + } + ] + }, + { + "name": "updateChainPrices", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateChainPricesArgs" + } + } + ] + }, + { + "name": "updateChainParams", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateChainParamsArgs" + } + } + ] + } + ], + "accounts": [ + { + "name": "instance", + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "publicKey" + }, + { + "name": "assistant", + "type": "publicKey" + }, + { + "name": "feeRecipient", + "type": "publicKey" + }, + { + "name": "solPrice", + "type": "u64" + } + ] + } + }, + { + "name": "registeredChain", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "maxGasDropoff", + "type": "u64" + }, + { + "name": "basePrice", + "type": "u64" + }, + { + "name": "nativePrice", + "type": "u64" + }, + { + "name": "gasPrice", + "type": "u64" + } + ] + } + }, + { + "name": "registeredNtt", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "wormholeTransceiverIndex", + "type": "u8" + }, + { + "name": "gasCost", + "type": "u32" + } + ] + } + }, + { + "name": "relayRequest", + "type": { + "kind": "struct", + "fields": [ + { + "name": "requestedGasDropoff", + "type": "u64" + } + ] + } + } + ], + "types": [ + { + "name": "RegisterChainArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + } + ] + } + }, + { + "name": "RegisterNttArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nttProgramId", + "type": "publicKey" + }, + { + "name": "wormholeTransceiverIndex", + "type": "u8" + }, + { + "name": "gasCost", + "type": "u32" + } + ] + } + }, + { + "name": "DeregisterNttArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nttProgramId", + "type": "publicKey" + } + ] + } + }, + { + "name": "RequestRelayArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "gasDropoff", + "type": "u64" + }, + { + "name": "maxFee", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateSolPriceArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "solPrice", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateChainPricesArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nativePrice", + "type": "u64" + }, + { + "name": "gasPrice", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateChainParamsArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxGasDropoff", + "type": "u64" + }, + { + "name": "basePrice", + "type": "u64" + } + ] + } + } + ], + "errors": [ + { + "code": 6001, + "name": "ExceedsUserMaxFee", + "msg": "Relay fees exceeds specified max" + }, + { + "code": 6002, + "name": "ExceedsMaxGasDropoff", + "msg": "Requested gas dropoff exceeds max allowed for chain" + }, + { + "code": 6003, + "name": "InvalidFeeRecipient", + "msg": "The specified fee recipient does not match the address in the instance accound" + }, + { + "code": 6004, + "name": "RelayingToChainDisabled", + "msg": "Relaying to the specified chain is disabled" + }, + { + "code": 6005, + "name": "OutboxItemNotReleased", + "msg": "Relaying to the specified chain is disabled" + }, + { + "code": 6006, + "name": "ScalingOverflow", + "msg": "Scaled value exceeds u64::MAX" + }, + { + "code": 6007, + "name": "DivByZero", + "msg": "Cannot divide by zero" + }, + { + "code": 6257, + "name": "FeeRecipientCannotBeDefault", + "msg": "The fee recipient cannot be the default address (0x0)" + }, + { + "code": 6258, + "name": "NotAuthorized", + "msg": "Must be owner or assistant" + }, + { + "code": 6259, + "name": "PriceCannotBeZero", + "msg": "The price cannot be zero" + } + ] +}; + +export const IDL: NttQuoter = { + "version": "2.0.0", + "name": "ntt_quoter", + "instructions": [ + { + "name": "requestRelay", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": false, + "isSigner": false + }, + { + "name": "outboxItem", + "isMut": false, + "isSigner": false, + "docs": [ + "and checking the release constraint into a single function" + ] + }, + { + "name": "relayRequest", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RequestRelayArgs" + } + } + ] + }, + { + "name": "closeRelay", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": true, + "isSigner": false + }, + { + "name": "relayRequest", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "initialize", + "accounts": [ + { + "name": "owner", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": false, + "isSigner": false + }, + { + "name": "programData", + "isMut": true, + "isSigner": false, + "docs": [ + "We use the program data to make sure this owner is the upgrade authority (the true owner,", + "who deployed this program)." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "setAssistant", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "assistant", + "isMut": false, + "isSigner": false, + "isOptional": true + } + ], + "args": [] + }, + { + "name": "setFeeRecipient", + "accounts": [ + { + "name": "owner", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + }, + { + "name": "feeRecipient", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "registerChain", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RegisterChainArgs" + } + } + ] + }, + { + "name": "registerNtt", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RegisterNttArgs" + } + } + ] + }, + { + "name": "deregisterNtt", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredNtt", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "DeregisterNttArgs" + } + } + ] + }, + { + "name": "updateSolPrice", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateSolPriceArgs" + } + } + ] + }, + { + "name": "updateChainPrices", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateChainPricesArgs" + } + } + ] + }, + { + "name": "updateChainParams", + "accounts": [ + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "instance", + "isMut": false, + "isSigner": false + }, + { + "name": "registeredChain", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateChainParamsArgs" + } + } + ] + } + ], + "accounts": [ + { + "name": "instance", + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "publicKey" + }, + { + "name": "assistant", + "type": "publicKey" + }, + { + "name": "feeRecipient", + "type": "publicKey" + }, + { + "name": "solPrice", + "type": "u64" + } + ] + } + }, + { + "name": "registeredChain", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "maxGasDropoff", + "type": "u64" + }, + { + "name": "basePrice", + "type": "u64" + }, + { + "name": "nativePrice", + "type": "u64" + }, + { + "name": "gasPrice", + "type": "u64" + } + ] + } + }, + { + "name": "registeredNtt", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "wormholeTransceiverIndex", + "type": "u8" + }, + { + "name": "gasCost", + "type": "u32" + } + ] + } + }, + { + "name": "relayRequest", + "type": { + "kind": "struct", + "fields": [ + { + "name": "requestedGasDropoff", + "type": "u64" + } + ] + } + } + ], + "types": [ + { + "name": "RegisterChainArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chainId", + "type": "u16" + } + ] + } + }, + { + "name": "RegisterNttArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nttProgramId", + "type": "publicKey" + }, + { + "name": "wormholeTransceiverIndex", + "type": "u8" + }, + { + "name": "gasCost", + "type": "u32" + } + ] + } + }, + { + "name": "DeregisterNttArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nttProgramId", + "type": "publicKey" + } + ] + } + }, + { + "name": "RequestRelayArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "gasDropoff", + "type": "u64" + }, + { + "name": "maxFee", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateSolPriceArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "solPrice", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateChainPricesArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nativePrice", + "type": "u64" + }, + { + "name": "gasPrice", + "type": "u64" + } + ] + } + }, + { + "name": "UpdateChainParamsArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxGasDropoff", + "type": "u64" + }, + { + "name": "basePrice", + "type": "u64" + } + ] + } + } + ], + "errors": [ + { + "code": 6001, + "name": "ExceedsUserMaxFee", + "msg": "Relay fees exceeds specified max" + }, + { + "code": 6002, + "name": "ExceedsMaxGasDropoff", + "msg": "Requested gas dropoff exceeds max allowed for chain" + }, + { + "code": 6003, + "name": "InvalidFeeRecipient", + "msg": "The specified fee recipient does not match the address in the instance accound" + }, + { + "code": 6004, + "name": "RelayingToChainDisabled", + "msg": "Relaying to the specified chain is disabled" + }, + { + "code": 6005, + "name": "OutboxItemNotReleased", + "msg": "Relaying to the specified chain is disabled" + }, + { + "code": 6006, + "name": "ScalingOverflow", + "msg": "Scaled value exceeds u64::MAX" + }, + { + "code": 6007, + "name": "DivByZero", + "msg": "Cannot divide by zero" + }, + { + "code": 6257, + "name": "FeeRecipientCannotBeDefault", + "msg": "The fee recipient cannot be the default address (0x0)" + }, + { + "code": 6258, + "name": "NotAuthorized", + "msg": "Must be owner or assistant" + }, + { + "code": 6259, + "name": "PriceCannotBeZero", + "msg": "The price cannot be zero" + } + ] +}; diff --git a/sdk/solana/src/anchor-idl/2_0_0/wormhole_governance.json b/sdk/solana/src/anchor-idl/2_0_0/wormhole_governance.json new file mode 100644 index 000000000..1561e7350 --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0/wormhole_governance.json @@ -0,0 +1,76 @@ +{ + "version": "2.0.0", + "name": "wormhole_governance", + "instructions": [ + { + "name": "governance", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "governance", + "isMut": true, + "isSigner": false, + "docs": [ + "governed program." + ] + }, + { + "name": "vaa", + "isMut": false, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "replay", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + } + ], + "accounts": [ + { + "name": "ReplayProtection", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + } + ] + } + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidGovernanceChain", + "msg": "InvalidGovernanceChain" + }, + { + "code": 6001, + "name": "InvalidGovernanceEmitter", + "msg": "InvalidGovernanceEmitter" + }, + { + "code": 6002, + "name": "InvalidGovernanceProgram", + "msg": "InvalidGovernanceProgram" + } + ] +} \ No newline at end of file diff --git a/sdk/solana/src/anchor-idl/2_0_0/wormhole_governance.ts b/sdk/solana/src/anchor-idl/2_0_0/wormhole_governance.ts new file mode 100644 index 000000000..b988f040d --- /dev/null +++ b/sdk/solana/src/anchor-idl/2_0_0/wormhole_governance.ts @@ -0,0 +1,153 @@ +export type WormholeGovernance = { + "version": "2.0.0", + "name": "wormhole_governance", + "instructions": [ + { + "name": "governance", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "governance", + "isMut": true, + "isSigner": false, + "docs": [ + "governed program." + ] + }, + { + "name": "vaa", + "isMut": false, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "replay", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + } + ], + "accounts": [ + { + "name": "replayProtection", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + } + ] + } + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidGovernanceChain", + "msg": "InvalidGovernanceChain" + }, + { + "code": 6001, + "name": "InvalidGovernanceEmitter", + "msg": "InvalidGovernanceEmitter" + }, + { + "code": 6002, + "name": "InvalidGovernanceProgram", + "msg": "InvalidGovernanceProgram" + } + ] +}; + +export const IDL: WormholeGovernance = { + "version": "2.0.0", + "name": "wormhole_governance", + "instructions": [ + { + "name": "governance", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "governance", + "isMut": true, + "isSigner": false, + "docs": [ + "governed program." + ] + }, + { + "name": "vaa", + "isMut": false, + "isSigner": false + }, + { + "name": "program", + "isMut": false, + "isSigner": false + }, + { + "name": "replay", + "isMut": true, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + } + ], + "accounts": [ + { + "name": "replayProtection", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + } + ] + } + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidGovernanceChain", + "msg": "InvalidGovernanceChain" + }, + { + "code": 6001, + "name": "InvalidGovernanceEmitter", + "msg": "InvalidGovernanceEmitter" + }, + { + "code": 6002, + "name": "InvalidGovernanceProgram", + "msg": "InvalidGovernanceProgram" + } + ] +}; diff --git a/sdk/solana/src/anchor-idl/index.ts b/sdk/solana/src/anchor-idl/index.ts index 6be35f4b7..926c925ce 100644 --- a/sdk/solana/src/anchor-idl/index.ts +++ b/sdk/solana/src/anchor-idl/index.ts @@ -1,4 +1,5 @@ export * from "./1_0_0.js"; +export * from "./2_0_0.js"; // This is a workaround for the fact that the anchor idl doesn't support generics // yet. This type is used to remove the generics from the idl types. diff --git a/sdk/solana/src/bindings.ts b/sdk/solana/src/bindings.ts index 20a697550..66e33c1c6 100644 --- a/sdk/solana/src/bindings.ts +++ b/sdk/solana/src/bindings.ts @@ -1,17 +1,18 @@ import { IdlAccounts, Program } from "@coral-xyz/anchor"; -import { OmitGenerics, _1_0_0 } from "./anchor-idl/index.js"; +import { OmitGenerics, _1_0_0, _2_0_0 } from "./anchor-idl/index.js"; import { Connection } from "@solana/web3.js"; export const IdlVersions = { "1.0.0": _1_0_0, - default: _1_0_0, + "2.0.0": _2_0_0, + default: _2_0_0, } as const; export type IdlVersion = keyof typeof IdlVersions; export namespace NttBindings { export type NativeTokenTransfer = - OmitGenerics<_1_0_0.RawExampleNativeTokenTransfers>; - export type Quoter = OmitGenerics<_1_0_0.RawNttQuoter>; + OmitGenerics<_2_0_0.RawExampleNativeTokenTransfers>; + export type Quoter = OmitGenerics<_2_0_0.RawNttQuoter>; export type Config = IdlAccounts["config"]; export type InboxItem = diff --git a/solana/Cargo.lock b/solana/Cargo.lock index 541661c36..4424e6667 100644 --- a/solana/Cargo.lock +++ b/solana/Cargo.lock @@ -1394,7 +1394,7 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dummy-transfer-hook" -version = "0.1.0" +version = "2.0.0" dependencies = [ "anchor-lang", "anchor-spl", @@ -1553,7 +1553,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "example-native-token-transfers" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "anchor-spl", @@ -2476,7 +2476,7 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "ntt-messages" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "hex", @@ -2486,7 +2486,7 @@ dependencies = [ [[package]] name = "ntt-quoter" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "cfg-if", @@ -6392,7 +6392,7 @@ dependencies = [ [[package]] name = "wormhole-governance" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "hex", diff --git a/solana/Makefile b/solana/Makefile index 1fd77ae03..1389adfea 100644 --- a/solana/Makefile +++ b/solana/Makefile @@ -25,6 +25,7 @@ idl: target/idl/example_native_token_transfers.json @ mkdir -p $@/ts @ cp -r target/idl/* $@/json/ @ cp -r target/types/* $@/ts/ + @ cd ../sdk/solana && npm run generate node_modules: package-lock.json npm ci diff --git a/solana/idl/json/dummy_transfer_hook.json b/solana/idl/json/dummy_transfer_hook.json index 27f37cb16..2f6864c36 100644 --- a/solana/idl/json/dummy_transfer_hook.json +++ b/solana/idl/json/dummy_transfer_hook.json @@ -1,5 +1,5 @@ { - "version": "0.1.0", + "version": "2.0.0", "name": "dummy_transfer_hook", "instructions": [ { diff --git a/solana/idl/json/example_native_token_transfers.json b/solana/idl/json/example_native_token_transfers.json index 0feeff52c..82369389d 100644 --- a/solana/idl/json/example_native_token_transfers.json +++ b/solana/idl/json/example_native_token_transfers.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "2.0.0", "name": "example_native_token_transfers", "instructions": [ { diff --git a/solana/idl/json/ntt_quoter.json b/solana/idl/json/ntt_quoter.json index c756bd654..d6c6f2f7a 100644 --- a/solana/idl/json/ntt_quoter.json +++ b/solana/idl/json/ntt_quoter.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "2.0.0", "name": "ntt_quoter", "instructions": [ { diff --git a/solana/idl/json/wormhole_governance.json b/solana/idl/json/wormhole_governance.json index 895f58575..1561e7350 100644 --- a/solana/idl/json/wormhole_governance.json +++ b/solana/idl/json/wormhole_governance.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "2.0.0", "name": "wormhole_governance", "instructions": [ { diff --git a/solana/idl/ts/dummy_transfer_hook.ts b/solana/idl/ts/dummy_transfer_hook.ts index 4e068844b..25e31bff3 100644 --- a/solana/idl/ts/dummy_transfer_hook.ts +++ b/solana/idl/ts/dummy_transfer_hook.ts @@ -1,5 +1,5 @@ export type DummyTransferHook = { - "version": "0.1.0", + "version": "2.0.0", "name": "dummy_transfer_hook", "instructions": [ { @@ -110,7 +110,7 @@ export type DummyTransferHook = { }; export const IDL: DummyTransferHook = { - "version": "0.1.0", + "version": "2.0.0", "name": "dummy_transfer_hook", "instructions": [ { diff --git a/solana/idl/ts/example_native_token_transfers.ts b/solana/idl/ts/example_native_token_transfers.ts index a8ea1f346..4a7fceeeb 100644 --- a/solana/idl/ts/example_native_token_transfers.ts +++ b/solana/idl/ts/example_native_token_transfers.ts @@ -1,5 +1,5 @@ export type ExampleNativeTokenTransfers = { - "version": "1.0.0", + "version": "2.0.0", "name": "example_native_token_transfers", "instructions": [ { @@ -2043,7 +2043,7 @@ export type ExampleNativeTokenTransfers = { }; export const IDL: ExampleNativeTokenTransfers = { - "version": "1.0.0", + "version": "2.0.0", "name": "example_native_token_transfers", "instructions": [ { diff --git a/solana/idl/ts/ntt_quoter.ts b/solana/idl/ts/ntt_quoter.ts index 298ae9042..063f2ec30 100644 --- a/solana/idl/ts/ntt_quoter.ts +++ b/solana/idl/ts/ntt_quoter.ts @@ -1,5 +1,5 @@ export type NttQuoter = { - "version": "1.0.0", + "version": "2.0.0", "name": "ntt_quoter", "instructions": [ { @@ -588,7 +588,7 @@ export type NttQuoter = { }; export const IDL: NttQuoter = { - "version": "1.0.0", + "version": "2.0.0", "name": "ntt_quoter", "instructions": [ { diff --git a/solana/idl/ts/wormhole_governance.ts b/solana/idl/ts/wormhole_governance.ts index d3ccfd9bb..b988f040d 100644 --- a/solana/idl/ts/wormhole_governance.ts +++ b/solana/idl/ts/wormhole_governance.ts @@ -1,5 +1,5 @@ export type WormholeGovernance = { - "version": "1.0.0", + "version": "2.0.0", "name": "wormhole_governance", "instructions": [ { @@ -76,7 +76,7 @@ export type WormholeGovernance = { }; export const IDL: WormholeGovernance = { - "version": "1.0.0", + "version": "2.0.0", "name": "wormhole_governance", "instructions": [ { diff --git a/solana/modules/ntt-messages/Cargo.toml b/solana/modules/ntt-messages/Cargo.toml index cf6f5468c..b3443dd67 100644 --- a/solana/modules/ntt-messages/Cargo.toml +++ b/solana/modules/ntt-messages/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ntt-messages" -version = "1.0.0" +version = "2.0.0" edition = "2021" [features] diff --git a/solana/programs/dummy-transfer-hook/Cargo.toml b/solana/programs/dummy-transfer-hook/Cargo.toml index 6f78242db..9e408629d 100644 --- a/solana/programs/dummy-transfer-hook/Cargo.toml +++ b/solana/programs/dummy-transfer-hook/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dummy-transfer-hook" -version = "0.1.0" +version = "2.0.0" description = "Created with Anchor" edition = "2021" diff --git a/solana/programs/example-native-token-transfers/Cargo.toml b/solana/programs/example-native-token-transfers/Cargo.toml index 9a131c741..c248cb6c0 100644 --- a/solana/programs/example-native-token-transfers/Cargo.toml +++ b/solana/programs/example-native-token-transfers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "example-native-token-transfers" -version = "1.0.0" +version = "2.0.0" description = "Example implementation of native token transfer standard" edition = "2021" diff --git a/solana/programs/example-native-token-transfers/src/lib.rs b/solana/programs/example-native-token-transfers/src/lib.rs index 6521acf1e..693a890be 100644 --- a/solana/programs/example-native-token-transfers/src/lib.rs +++ b/solana/programs/example-native-token-transfers/src/lib.rs @@ -62,7 +62,7 @@ pub const TOKEN_AUTHORITY_SEED: &[u8] = b"token_authority"; /// user, atomically). pub const SESSION_AUTHORITY_SEED: &[u8] = b"session_authority"; -pub const VERSION: &str = "1.0.0"; +pub const VERSION: &str = "2.0.0"; #[program] pub mod example_native_token_transfers { diff --git a/solana/programs/ntt-quoter/Cargo.toml b/solana/programs/ntt-quoter/Cargo.toml index fcc3ba281..ee06ec7ae 100644 --- a/solana/programs/ntt-quoter/Cargo.toml +++ b/solana/programs/ntt-quoter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ntt-quoter" -version = "1.0.0" +version = "2.0.0" edition = "2021" [lib] diff --git a/solana/programs/wormhole-governance/Cargo.toml b/solana/programs/wormhole-governance/Cargo.toml index 93a1b664d..0d384e87e 100644 --- a/solana/programs/wormhole-governance/Cargo.toml +++ b/solana/programs/wormhole-governance/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wormhole-governance" -version = "1.0.0" +version = "2.0.0" description = "Governance for programs controlled by Wormhole Guardians" edition = "2021" diff --git a/solana/scripts/program-version b/solana/scripts/program-version new file mode 100755 index 000000000..08c3e93f4 --- /dev/null +++ b/solana/scripts/program-version @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# cd to the solana root (one level up from the script location) +cd "$(dirname "$0")"/.. + +version= + +# grab all lib.rs files that export a VERSION constant +# and ensure there is exactly one +for lib in $(find programs modules -name lib.rs); do + if grep -q "pub const VERSION" $lib; then + if [[ -n $version ]]; then + echo "Error: multiple versions found" >&2 + exit 1 + fi + version=$(grep "pub const VERSION" $lib | cut -d '"' -f 2) + echo "$version" + fi +done + +if [[ -z $version ]]; then + echo "Error: version not found" >&2 + exit 1 +fi diff --git a/solana/scripts/sync-versions b/solana/scripts/sync-versions new file mode 100755 index 000000000..ac14841a4 --- /dev/null +++ b/solana/scripts/sync-versions @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# cd to the solana root (one level up from the script location) +cd "$(dirname "$0")"/.. + +# check if --check is passed (in a way that doesn't complain about unbound variables) +check=false +if [[ "${1:-}" == "--check" ]]; then + check=true +fi + +version=$(./scripts/program-version) +failed=0 + +# update Cargo.toml versions in all Cargo.toml files in the `programs` and +# `modules` directories +for cargo in $(find programs modules -name Cargo.toml); do + if $check; then + if ! grep -q "version = \"$version\"" $cargo; then + echo "Error: $cargo is out of date" >&2 + failed=$((failed + 1)) + fi + else + # NOTE: we don't use sed -i because it's not portable + cp $cargo $cargo.bak + sed "s/^version = .*/version = \"$version\"/" $cargo.bak > $cargo + if ! diff $cargo $cargo.bak > /dev/null; then + echo "Updated $cargo" + fi + rm $cargo.bak + fi +done + +if [[ $failed -gt 0 ]]; then + echo "Run $0 to update versions" >&2 + exit 1 +fi