Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solana: support tokens with transfer hooks #1

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/solana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions sdk/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,15 @@ async function deploySolana(ctx: Ctx): Promise<Ctx> {
await signSendWait(ctx.context, initTxs, signer);
console.log("Initialized ntt at", manager.program.programId.toString());

// NOTE: this is a hack. The next instruction will fail if we don't wait
// here, because the address lookup table is not yet available, despite
// the transaction having been confirmed.
// Looks like a bug, but I haven't investigated further. In practice, this
// won't be an issue, becase the address lookup table will have been
// created well before anyone is trying to use it, but we might want to be
// mindful in the deploy script too.
await new Promise((resolve) => setTimeout(resolve, 400));

const registrTxs = manager.registerTransceiver({
payer: keypair,
owner: keypair,
Expand Down
2 changes: 1 addition & 1 deletion sdk/solana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./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": {
Expand Down
16 changes: 0 additions & 16 deletions sdk/solana/scripts/readVersion.ts

This file was deleted.

15 changes: 15 additions & 0 deletions sdk/solana/src/anchor-idl/2_0_0.ts
Original file line number Diff line number Diff line change
@@ -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;
}
110 changes: 110 additions & 0 deletions sdk/solana/src/anchor-idl/2_0_0/dummy_transfer_hook.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
]
}
Loading
Loading