Skip to content

Commit f106797

Browse files
kcsongorMaxwell DulinMaxwell DulinemrebogaEmre Bogazliyanlioglu
authored
ntt: sui implementation (#613)
* sui: implement NTT * sui: add docs on auth system * sui: fix transceiver message serialisation * sui: handle additional payload in native token transfers * sui: fix wormhole transceiver auth type name this needs to be Auth * sui: add wormhole transceiver init logic * sui: allow updating peers (and updating inbound rate limit) * sui: remove frontrun protection in payload handling payloads are supposed to be handled by modifying the ntt source code, instead of having the recipient handle it. because of this, we don't need to implemnent any additional protections in the default ntt instance * sui: untrim amounts in outbound rate limiting * Add demo of accountant changes * Edit implementation to include only a single SetPeer * Add parsing tests to files * Add more comments * Remove 'option' from the WH message ticket * sui: fine grained access control in contract_auth.move * sui: tie transceiver to a particular manager * sui: store admin cap in state for off-chain discoverability * sui: add get_next_sequence * sui: switch to testnet branch of wormhole (temporary) * sui: rename test auth module duplicate module names across different packages triggers a compiler bug * sui: store admin cap id in state for off-chain discoverability * sui: store transceiver state object id for off-chain discoverability * sui: separate entrypoint for completing burning and locking setup * sui: store upgrade cap id for off chain discoverability * sui: manager identifies itself by its state object * sui: add get_transceiver_type to transceiver * sui: cli + sdk sui: store state object id in transceiver registry sui: store admin cap id in wormhole transceiver cli: deployment works sdk: add ability to set threshold sdk/sui: some clean up sdk/sui: better typing for sui contract data cli: sui upgradeability wip cli: create local env for sui commands instead of relying on global environment cli: register correct address sui cli: use sui manager package id in registration the deployment json stores the state id, but we need to register the package id sui: add get_transceiver_type to transceiver [sdk] * sui/sdk: dynamic coin metadata (does it work? haven't tried yet) * wip cli separate entrypoint * small cli fixes * cli: await askForConfirmation * cli: update sui dependency revision * cli/install: don't link package by name * Adding executor SDK for Sui NTT (#27) * Implement redeem and add unit tests Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Add Executor SDK Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Verify executor SDK and trim down excessive tests Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Revert previous redeem implementation Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Update tests Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Combine tests Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Fix gas limits for Sui executor route Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Enable EVM Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Copy sui/ts to Dockerfile.cli build Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> --------- Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Add Mainnet addresses and use isSameType for coin type comparison on Sui Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * omit cli-checking from 'build' script we do this for the practical reason that the cli is not included in the ci docker image * chore: Address previous feedback from PR#27 Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * chore: Remove unnecessary chain/platform check Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * fix: TS error for unused import Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * chore: Add temp values for inboud limits to unblock local testing Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * chore: Use SUI_CLOCK_OBJECT_ID instead Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * feat: Adding impl for rate limiting functions (#28) Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * sui: add pausing functionality * sdk: sui pausing * sui: threshold invariants * feat: Adding implementation for redeem and transfer status functions (#29) * feat: Adding implementation for transfer status functions Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Add redeem implementation Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Fix tests Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> --------- Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Add completeInboundQueuedTransfer implementation and fix function signatures to match NTT interface Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Add Sui to Publish workflow Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Fix Attestation creation and add more checks Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Use seconds instead of millis for rate limit timestamp Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Add ntt::release call to redeem flow (#30) * Add ntt::release call to redeem flow Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Fix tests Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> --------- Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Fix coin split Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Refactor Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Fix transfer function manual outbound transfers Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * sui: take/return treasury cap * Move shared functionality to utils and constants (#32) * Move shared functionality to utils and constants Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Fix unit tests Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> --------- Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Add implementation for setOwner (#31) * Implement setOwner Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Remove extensive variable checks Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> --------- Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * sui: pause create_transceiver_message * Address PR feedback Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> * Revert wormhole-foundation/sdk* version bumps Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> --------- Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz> Co-authored-by: Maxwell Dulin <strikeout@maxwells-mbp.lan> Co-authored-by: Maxwell Dulin <strikeout@mac.lan> Co-authored-by: Emre Bogazliyanlioglu <emreboga@users.noreply.github.com> Co-authored-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz>
1 parent 94a4f6b commit f106797

68 files changed

Lines changed: 10559 additions & 68 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version to publish'
7+
description: "Version to publish"
88
required: true
9-
type: 'string'
9+
type: "string"
1010

1111
jobs:
1212
publish-ts-sdk:
@@ -36,8 +36,9 @@ jobs:
3636
--workspace sdk/definitions \
3737
--workspace evm/ts \
3838
--workspace solana \
39+
--workspace sui \
3940
--workspace sdk/route
4041
env:
4142
VERSION: ${{ inputs.version }}
4243
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
43-
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
44+
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
cache/
33
out/
44
target/
5+
build/
6+
tsconfig.tsbuildinfo
57

68
# Ignores development broadcast logs
79
!/broadcast
@@ -25,3 +27,6 @@ node_modules
2527

2628
# Tilt
2729
.wormhole
30+
31+
# Claude code
32+
.claude/settings.local.json

Dockerfile.cli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ COPY solana/package.json solana/package.json
4848
COPY solana/ts solana/ts
4949
COPY evm/ts evm/ts
5050
COPY solana/tsconfig.*.json solana/
51+
COPY sui/ts sui/ts
5152
COPY cli/package.json cli/package.json
5253
COPY cli/package-lock.json cli/package-lock.json
5354
COPY cli/src cli/src

bun.lock

Lines changed: 31 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/install.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ function install_cli {
157157
cd cli
158158

159159
bun link
160-
161-
bun link @wormhole-foundation/ntt-cli
162160
}
163161

164162
main "$@"

cli/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"ntt": "src/index.ts"
1818
},
1919
"dependencies": {
20+
"@mysten/sui": "1.37.2",
21+
"@wormhole-foundation/sdk-sui-ntt": "^0.5.0",
2022
"chalk": "^5.3.0",
2123
"yargs": "^17.7.2"
2224
}

cli/src/getSigner.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import solana from "@wormhole-foundation/sdk/platforms/solana";
22
import * as myEvmSigner from "./evmsigner.js";
3+
import * as mySuiSigner from "./suisigner.js";
34
import { ChainContext, Wormhole, chainToPlatform, type Chain, type ChainAddress, type Network, type Signer } from "@wormhole-foundation/sdk";
45
import { Keypair } from "@solana/web3.js";
56
import fs from "fs";
@@ -55,12 +56,14 @@ export async function getSigner<N extends Network, C extends Chain>(
5556
// Read the private key from the file if filePath is provided
5657
const keyPair = Keypair.fromSecretKey(new Uint8Array(JSON.parse(fs.readFileSync(filePath, 'utf8'))));
5758
privateKey = encoding.b58.encode(keyPair.secretKey);
59+
source = filePath;
5860
} else {
5961
const privateKeySource = source ?? process.env.SOLANA_PRIVATE_KEY;
6062
if (privateKeySource === undefined) {
6163
throw new Error("Private key not provided and SOLANA_PRIVATE_KEY env var not set");
6264
}
6365
privateKey = privateKeySource;
66+
source = privateKeySource;
6467
}
6568
source = privateKey;
6669
signer = await solana.getSigner(
@@ -94,6 +97,26 @@ export async function getSigner<N extends Network, C extends Chain>(
9497
throw new Error("Unsupported signer type");
9598
}
9699
break;
100+
case "Sui":
101+
switch (type) {
102+
case "privateKey":
103+
const privateKey = source ?? process.env.SUI_PRIVATE_KEY;
104+
if (!privateKey) {
105+
throw new Error("SUI_PRIVATE_KEY env var not set");
106+
}
107+
source = privateKey;
108+
signer = await mySuiSigner.getSuiSigner(
109+
await chain.getRpc(),
110+
privateKey,
111+
{ debug: false }
112+
);
113+
break;
114+
case "ledger":
115+
throw new Error("Ledger not yet supported on Sui");
116+
default:
117+
throw new Error("Unsupported signer type");
118+
}
119+
break;
97120
default:
98121
throw new Error("Unrecognized platform: " + platform);
99122
}

0 commit comments

Comments
 (0)