Skip to content

Commit 43f4ac6

Browse files
committed
Typescript SDK changes and bug fixes needed for Connect
- Added a WormholeTransferStandardRelayer payload type needed to parse the VAA for an automatic transfer between EVM chains - EVM: getIsExecuted should check if the transfer is inbound queued to determine if the transfer is completed - Solana: getIsExecuted should check if the inboxItem is released - Solana: getIsApproved should not swallow exception - Solana: getInboundQueuedTransfer should return null if the transfer is not queued - Bumped SDK dependencies needed for Connect
1 parent 9f9dd3f commit 43f4ac6

File tree

16 files changed

+400
-324
lines changed

16 files changed

+400
-324
lines changed

evm/ts/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@
4444
"test": "jest --config ./jest.config.ts"
4545
},
4646
"dependencies": {
47-
"@wormhole-foundation/sdk-base": "^0.7",
48-
"@wormhole-foundation/sdk-definitions": "^0.7",
47+
"@wormhole-foundation/sdk-base": "0.8.0-beta.0",
48+
"@wormhole-foundation/sdk-definitions": "0.8.0-beta.0",
4949
"@wormhole-foundation/sdk-definitions-ntt": "0.1.0-beta.0",
50-
"@wormhole-foundation/sdk-evm": "^0.7",
51-
"@wormhole-foundation/sdk-evm-core": "^0.7",
50+
"@wormhole-foundation/sdk-evm": "0.8.0-beta.0",
51+
"@wormhole-foundation/sdk-evm-core": "0.8.0-beta.0",
5252
"ethers": "^6.5.1"
5353
},
5454
"peerDependencies": {
5555
"@wormhole-foundation/sdk-definitions-ntt": "0.1.0-beta.0",
56-
"@wormhole-foundation/sdk-base": "^0.7",
57-
"@wormhole-foundation/sdk-definitions": "^0.7",
58-
"@wormhole-foundation/sdk-evm": "^0.7",
59-
"@wormhole-foundation/sdk-evm-core": "^0.7"
56+
"@wormhole-foundation/sdk-base": "0.8.0-beta.0",
57+
"@wormhole-foundation/sdk-definitions": "0.8.0-beta.0",
58+
"@wormhole-foundation/sdk-evm": "0.8.0-beta.0",
59+
"@wormhole-foundation/sdk-evm-core": "0.8.0-beta.0"
6060
},
6161
"devDependencies": {
6262
"@typechain/ethers-v6": "^0.5.1",
@@ -76,4 +76,4 @@
7676
}
7777
}
7878
}
79-
}
79+
}

evm/ts/src/ntt.ts

+26-12
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {
99
ChainAddress,
1010
ChainsConfig,
1111
Contracts,
12-
TokenAddress,
13-
VAA,
1412
serialize,
1513
universalAddress,
1614
} from "@wormhole-foundation/sdk-definitions";
@@ -143,19 +141,30 @@ export class EvmNtt<N extends Network, C extends EvmChains>
143141
return enabled.filter((x) => x).length > 0;
144142
}
145143

146-
getIsExecuted(attestation: Ntt.Attestation): Promise<boolean> {
147-
const { emitterChain: chain, payload } =
148-
attestation as VAA<"Ntt:WormholeTransfer">;
149-
return this.manager.isMessageExecuted(
150-
Ntt.messageDigest(chain, payload["nttManagerPayload"])
144+
async getIsExecuted(attestation: Ntt.Attestation): Promise<boolean> {
145+
const payload =
146+
attestation.payloadName === "WormholeTransfer"
147+
? attestation.payload
148+
: attestation.payload.payload;
149+
const isExecuted = await this.manager.isMessageExecuted(
150+
Ntt.messageDigest(attestation.emitterChain, payload["nttManagerPayload"])
151151
);
152+
if (!isExecuted) return false;
153+
// Also check that the transfer is not queued for it to be considered complete
154+
const queued = await this.getInboundQueuedTransfer(
155+
attestation.emitterChain,
156+
payload["nttManagerPayload"]
157+
);
158+
return queued === null;
152159
}
153160

154161
getIsApproved(attestation: Ntt.Attestation): Promise<boolean> {
155-
const { emitterChain: chain, payload } =
156-
attestation as VAA<"Ntt:WormholeTransfer">;
162+
const payload =
163+
attestation.payloadName === "WormholeTransfer"
164+
? attestation.payload
165+
: attestation.payload.payload;
157166
return this.manager.isMessageApproved(
158-
Ntt.messageDigest(chain, payload["nttManagerPayload"])
167+
Ntt.messageDigest(attestation.emitterChain, payload["nttManagerPayload"])
159168
);
160169
}
161170

@@ -311,7 +320,13 @@ export class EvmNtt<N extends Network, C extends EvmChains>
311320

312321
for (const idx in this.xcvrs) {
313322
const xcvr = this.xcvrs[idx]!;
314-
yield* xcvr.receive(attestations[idx]);
323+
const attestation = attestations[idx];
324+
if (attestation?.payloadName !== "WormholeTransfer") {
325+
// TODO: support standard relayer attestations
326+
// which must be submitted to the delivery provider
327+
throw new Error("Invalid attestation type for redeem");
328+
}
329+
yield* xcvr.receive(attestation);
315330
}
316331
}
317332

@@ -349,7 +364,6 @@ export class EvmNtt<N extends Network, C extends EvmChains>
349364
async *completeInboundQueuedTransfer(
350365
fromChain: Chain,
351366
transceiverMessage: Ntt.Message,
352-
token: TokenAddress<C>,
353367
payer?: AccountAddress<C>
354368
) {
355369
const tx = await this.manager.completeInboundQueuedTransfer(

0 commit comments

Comments
 (0)