|
9 | 9 | ChainAddress,
|
10 | 10 | ChainsConfig,
|
11 | 11 | Contracts,
|
12 |
| - TokenAddress, |
13 |
| - VAA, |
14 | 12 | serialize,
|
15 | 13 | universalAddress,
|
16 | 14 | } from "@wormhole-foundation/sdk-definitions";
|
@@ -143,19 +141,30 @@ export class EvmNtt<N extends Network, C extends EvmChains>
|
143 | 141 | return enabled.filter((x) => x).length > 0;
|
144 | 142 | }
|
145 | 143 |
|
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"]) |
151 | 151 | );
|
| 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; |
152 | 159 | }
|
153 | 160 |
|
154 | 161 | 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; |
157 | 166 | return this.manager.isMessageApproved(
|
158 |
| - Ntt.messageDigest(chain, payload["nttManagerPayload"]) |
| 167 | + Ntt.messageDigest(attestation.emitterChain, payload["nttManagerPayload"]) |
159 | 168 | );
|
160 | 169 | }
|
161 | 170 |
|
@@ -311,7 +320,13 @@ export class EvmNtt<N extends Network, C extends EvmChains>
|
311 | 320 |
|
312 | 321 | for (const idx in this.xcvrs) {
|
313 | 322 | 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); |
315 | 330 | }
|
316 | 331 | }
|
317 | 332 |
|
@@ -349,7 +364,6 @@ export class EvmNtt<N extends Network, C extends EvmChains>
|
349 | 364 | async *completeInboundQueuedTransfer(
|
350 | 365 | fromChain: Chain,
|
351 | 366 | transceiverMessage: Ntt.Message,
|
352 |
| - token: TokenAddress<C>, |
353 | 367 | payer?: AccountAddress<C>
|
354 | 368 | ) {
|
355 | 369 | const tx = await this.manager.completeInboundQueuedTransfer(
|
|
0 commit comments