@wormhole-foundation/connect-sdk
Advanced tools
Comparing version 0.1.7-beta.3 to 0.1.7-beta.4
@@ -6,3 +6,2 @@ "use strict"; | ||
const common_1 = require("../common"); | ||
const tasks_1 = require("../tasks"); | ||
const types_1 = require("../types"); | ||
@@ -172,3 +171,3 @@ const wormholeTransfer_1 = require("../wormholeTransfer"); | ||
const txid = this.txids[this.txids.length - 1]; | ||
const msgId = await TokenTransfer.getTransferMessage(this.wh, txid); | ||
const msgId = await TokenTransfer.getTransferMessage(this.wh, txid, timeout); | ||
this.vaas = [{ id: msgId }]; | ||
@@ -221,17 +220,6 @@ } | ||
const { chain, txid } = tx; | ||
const originChain = wh.getChain(chain); | ||
const task = async () => { | ||
const msgs = await originChain.parseTransaction(txid); | ||
// possible the node we hit does not have this data yet | ||
// return null to signal retry | ||
if (msgs.length === 0) | ||
return null; | ||
return msgs; | ||
}; | ||
const parsed = await (0, tasks_1.retry)(task, originChain.config.blockTime, timeout, "WormholeCore:ParseMessageFromTransaction"); | ||
if (!parsed) | ||
throw new Error(`No WormholeMessageId found for ${txid}`); | ||
if (parsed.length != 1) | ||
throw new Error(`Expected a single VAA, got ${parsed.length}`); | ||
return parsed[0]; | ||
const msgs = await wh.parseMessageFromTx(chain, txid, timeout); | ||
if (msgs.length === 0) | ||
throw new Error(`No messages found in transaction ${txid}`); | ||
return msgs[0]; | ||
} | ||
@@ -238,0 +226,0 @@ static async getTransferVaa(wh, whm, timeout) { |
@@ -149,4 +149,4 @@ import { PlatformName, ChainName, Network } from "@wormhole-foundation/sdk-base"; | ||
*/ | ||
parseMessageFromTx(chain: ChainName, txid: TxHash): Promise<WormholeMessageId[]>; | ||
parseMessageFromTx(chain: ChainName, txid: TxHash, timeout?: number): Promise<WormholeMessageId[]>; | ||
} | ||
//# sourceMappingURL=wormhole.d.ts.map |
@@ -287,4 +287,18 @@ "use strict"; | ||
*/ | ||
async parseMessageFromTx(chain, txid) { | ||
return await this.getChain(chain).parseTransaction(txid); | ||
async parseMessageFromTx(chain, txid, timeout) { | ||
const originChain = this.getChain(chain); | ||
const task = async () => { | ||
const msgs = await originChain.parseTransaction(txid); | ||
// possible the node we hit does not have this data yet | ||
// return null to signal retry | ||
if (msgs.length === 0) | ||
return null; | ||
return msgs; | ||
}; | ||
const parsed = await (0, tasks_1.retry)(task, originChain.config.blockTime, timeout, "WormholeCore:ParseMessageFromTransaction"); | ||
if (!parsed) | ||
throw new Error(`No WormholeMessageId found for ${txid}`); | ||
if (parsed.length != 1) | ||
throw new Error(`Expected a single VAA, got ${parsed.length}`); | ||
return parsed; | ||
} | ||
@@ -291,0 +305,0 @@ } |
import { TokenBridge, isTransactionIdentifier, isWormholeMessageId, toNative, } from "@wormhole-foundation/sdk-definitions"; | ||
import { signSendWait } from "../common"; | ||
import { retry } from "../tasks"; | ||
import { isTokenTransferDetails } from "../types"; | ||
@@ -168,3 +167,3 @@ import { TransferState, } from "../wormholeTransfer"; | ||
const txid = this.txids[this.txids.length - 1]; | ||
const msgId = await TokenTransfer.getTransferMessage(this.wh, txid); | ||
const msgId = await TokenTransfer.getTransferMessage(this.wh, txid, timeout); | ||
this.vaas = [{ id: msgId }]; | ||
@@ -217,17 +216,6 @@ } | ||
const { chain, txid } = tx; | ||
const originChain = wh.getChain(chain); | ||
const task = async () => { | ||
const msgs = await originChain.parseTransaction(txid); | ||
// possible the node we hit does not have this data yet | ||
// return null to signal retry | ||
if (msgs.length === 0) | ||
return null; | ||
return msgs; | ||
}; | ||
const parsed = await retry(task, originChain.config.blockTime, timeout, "WormholeCore:ParseMessageFromTransaction"); | ||
if (!parsed) | ||
throw new Error(`No WormholeMessageId found for ${txid}`); | ||
if (parsed.length != 1) | ||
throw new Error(`Expected a single VAA, got ${parsed.length}`); | ||
return parsed[0]; | ||
const msgs = await wh.parseMessageFromTx(chain, txid, timeout); | ||
if (msgs.length === 0) | ||
throw new Error(`No messages found in transaction ${txid}`); | ||
return msgs[0]; | ||
} | ||
@@ -234,0 +222,0 @@ static async getTransferVaa(wh, whm, timeout) { |
@@ -149,4 +149,4 @@ import { PlatformName, ChainName, Network } from "@wormhole-foundation/sdk-base"; | ||
*/ | ||
parseMessageFromTx(chain: ChainName, txid: TxHash): Promise<WormholeMessageId[]>; | ||
parseMessageFromTx(chain: ChainName, txid: TxHash, timeout?: number): Promise<WormholeMessageId[]>; | ||
} | ||
//# sourceMappingURL=wormhole.d.ts.map |
@@ -284,6 +284,20 @@ import { isCircleSupported, isCircleChain, isChain, normalizeAmount, } from "@wormhole-foundation/sdk-base"; | ||
*/ | ||
async parseMessageFromTx(chain, txid) { | ||
return await this.getChain(chain).parseTransaction(txid); | ||
async parseMessageFromTx(chain, txid, timeout) { | ||
const originChain = this.getChain(chain); | ||
const task = async () => { | ||
const msgs = await originChain.parseTransaction(txid); | ||
// possible the node we hit does not have this data yet | ||
// return null to signal retry | ||
if (msgs.length === 0) | ||
return null; | ||
return msgs; | ||
}; | ||
const parsed = await retry(task, originChain.config.blockTime, timeout, "WormholeCore:ParseMessageFromTransaction"); | ||
if (!parsed) | ||
throw new Error(`No WormholeMessageId found for ${txid}`); | ||
if (parsed.length != 1) | ||
throw new Error(`Expected a single VAA, got ${parsed.length}`); | ||
return parsed; | ||
} | ||
} | ||
//# sourceMappingURL=wormhole.js.map |
{ | ||
"name": "@wormhole-foundation/connect-sdk", | ||
"version": "0.1.7-beta.3", | ||
"version": "0.1.7-beta.4", | ||
"repository": { | ||
@@ -61,5 +61,5 @@ "type": "git", | ||
"axios": "^1.4.0", | ||
"@wormhole-foundation/sdk-base": "0.1.7-beta.1", | ||
"@wormhole-foundation/sdk-definitions": "0.1.7-beta.1" | ||
"@wormhole-foundation/sdk-base": "0.1.7-beta.2", | ||
"@wormhole-foundation/sdk-definitions": "0.1.7-beta.2" | ||
} | ||
} |
@@ -13,3 +13,2 @@ import { | ||
import { signSendWait } from "../common"; | ||
import { retry } from "../tasks"; | ||
import { TokenTransferDetails, isTokenTransferDetails } from "../types"; | ||
@@ -281,3 +280,3 @@ import { Wormhole } from "../wormhole"; | ||
const txid = this.txids[this.txids.length - 1] | ||
const msgId = await TokenTransfer.getTransferMessage(this.wh, txid) | ||
const msgId = await TokenTransfer.getTransferMessage(this.wh, txid, timeout) | ||
this.vaas = [{ id: msgId }] | ||
@@ -349,24 +348,6 @@ } | ||
): Promise<WormholeMessageId> { | ||
const { chain, txid } = tx; | ||
const originChain = wh.getChain(chain); | ||
const task = async () => { | ||
const msgs = await originChain.parseTransaction(txid) | ||
// possible the node we hit does not have this data yet | ||
// return null to signal retry | ||
if (msgs.length === 0) return null | ||
return msgs | ||
} | ||
const parsed = await retry<WormholeMessageId[]>( | ||
task, | ||
originChain.config.blockTime, | ||
timeout, | ||
"WormholeCore:ParseMessageFromTransaction", | ||
); | ||
if (!parsed) throw new Error(`No WormholeMessageId found for ${txid}`); | ||
if (parsed.length != 1) | ||
throw new Error(`Expected a single VAA, got ${parsed.length}`); | ||
return parsed[0]; | ||
const { chain, txid } = tx | ||
const msgs = await wh.parseMessageFromTx(chain, txid, timeout) | ||
if (msgs.length === 0) throw new Error(`No messages found in transaction ${txid}`) | ||
return msgs[0]; | ||
} | ||
@@ -373,0 +354,0 @@ |
@@ -433,5 +433,27 @@ import { | ||
txid: TxHash, | ||
timeout?: number, | ||
): Promise<WormholeMessageId[]> { | ||
return await this.getChain(chain).parseTransaction(txid); | ||
const originChain = this.getChain(chain); | ||
const task = async () => { | ||
const msgs = await originChain.parseTransaction(txid) | ||
// possible the node we hit does not have this data yet | ||
// return null to signal retry | ||
if (msgs.length === 0) return null | ||
return msgs | ||
} | ||
const parsed = await retry<WormholeMessageId[]>( | ||
task, | ||
originChain.config.blockTime, | ||
timeout, | ||
"WormholeCore:ParseMessageFromTransaction", | ||
); | ||
if (!parsed) throw new Error(`No WormholeMessageId found for ${txid}`); | ||
if (parsed.length != 1) | ||
throw new Error(`Expected a single VAA, got ${parsed.length}`); | ||
return parsed; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
386920
5943
+ Added@wormhole-foundation/sdk-base@0.1.7-beta.2(transitive)
+ Added@wormhole-foundation/sdk-definitions@0.1.7-beta.2(transitive)
- Removed@wormhole-foundation/sdk-base@0.1.7-beta.1(transitive)
- Removed@wormhole-foundation/sdk-definitions@0.1.7-beta.1(transitive)