Skip to content

Commit 37675dc

Browse files
committed
Added getIsTransferInboundQueued method
1 parent e181ba7 commit 37675dc

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

evm/ts/src/ntt.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,22 @@ export class EvmNtt<N extends Network, C extends EvmChains>
151151
);
152152
if (!isExecuted) return false;
153153
// 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"]
154+
return !(await this.getIsTransferInboundQueued(attestation));
155+
}
156+
157+
async getIsTransferInboundQueued(
158+
attestation: Ntt.Attestation
159+
): Promise<boolean> {
160+
const payload =
161+
attestation.payloadName === "WormholeTransfer"
162+
? attestation.payload
163+
: attestation.payload.payload;
164+
return (
165+
(await this.getInboundQueuedTransfer(
166+
attestation.emitterChain,
167+
payload["nttManagerPayload"]
168+
)) !== null
157169
);
158-
return queued === null;
159170
}
160171

161172
getIsApproved(attestation: Ntt.Attestation): Promise<boolean> {

sdk/definitions/src/ntt.ts

+6
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ export interface Ntt<N extends Network, C extends Chain> {
241241
*/
242242
getIsExecuted(attestation: Ntt.Attestation): Promise<boolean>;
243243

244+
/**
245+
* getIsTransferInboundQueued returns whether the transfer is inbound queued
246+
* @param attestation the attestation to check
247+
*/
248+
getIsTransferInboundQueued(attestation: Ntt.Attestation): Promise<boolean>;
249+
244250
/**
245251
* getInboundQueuedTransfer returns the details of an inbound queued transfer
246252
* @param transceiverMessage the transceiver message

sdk/route/src/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ export namespace NttRoute {
175175
capacity: bigint
176176
): boolean {
177177
const threshold = (capacity * 95n) / 100n;
178-
console.log(amount, threshold, amount > threshold);
179178
return amount > threshold;
180179
}
181180
}

solana/ts/sdk/ntt.ts

+19
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,25 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
567567
return !!inboxItem.releaseStatus.released;
568568
}
569569

570+
async getIsTransferInboundQueued(
571+
attestation: Ntt.Attestation
572+
): Promise<boolean> {
573+
if (attestation.payloadName !== "WormholeTransfer") return false;
574+
const payload = attestation.payload["nttManagerPayload"];
575+
let inboxItem;
576+
try {
577+
inboxItem = await this.program.account.inboxItem.fetch(
578+
this.pdas.inboxItemAccount(attestation.emitterChain, payload)
579+
);
580+
} catch (e: any) {
581+
if (e.message?.includes("Account does not exist")) {
582+
return false;
583+
}
584+
throw e;
585+
}
586+
return !!inboxItem.releaseStatus.releaseAfter;
587+
}
588+
570589
async getIsApproved(attestation: Ntt.Attestation): Promise<boolean> {
571590
const digest = (attestation as WormholeNttTransceiver.VAA).hash;
572591
const vaaAddress = utils.derivePostedVaaKey(

0 commit comments

Comments
 (0)