Skip to content

Commit

Permalink
Check is transfer completed by vaa sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed Nov 15, 2023
1 parent 86cb928 commit 58f2a50
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sdk/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alephium/wormhole-sdk",
"version": "0.2.0",
"version": "0.2.1",
"description": "SDK for interacting with Alephium Wormhole",
"homepage": "https://wormholenetwork.com",
"main": "./lib/cjs/index.js",
Expand Down
13 changes: 12 additions & 1 deletion sdk/js/src/token_bridge/getIsTransferCompleted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,22 @@ export async function getIsTransferCompletedAlph(
tokenBridgeForChainId: string,
groupIndex: number,
signedVAA: Uint8Array
) {
return getIsTransferCompletedBySequenceAlph(
tokenBridgeForChainId,
groupIndex,
extractSequenceFromVAA(signedVAA)
)
}

export async function getIsTransferCompletedBySequenceAlph(
tokenBridgeForChainId: string,
groupIndex: number,
sequence: bigint
) {
const tokenBridgeForChainAddress = addressFromContractId(tokenBridgeForChainId)
const contract = TokenBridgeForChain.at(tokenBridgeForChainAddress)
const contractState = await contract.fetchState()
const sequence = extractSequenceFromVAA(signedVAA)

if (sequence < contractState.fields.start) {
return isSequenceExecuted(tokenBridgeForChainId, sequence, groupIndex)
Expand Down

0 comments on commit 58f2a50

Please sign in to comment.