From df4cf648edbf6f5c894e0c6d399484726339a816 Mon Sep 17 00:00:00 2001 From: imsk17 Date: Mon, 16 Dec 2024 13:21:20 +0530 Subject: [PATCH 01/12] feat(config::testnet): import terra --- src/config.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/config.ts b/src/config.ts index b61e8c1..fbc6572 100644 --- a/src/config.ts +++ b/src/config.ts @@ -163,6 +163,20 @@ export const bridgeTestChains = [ decimals: 18, blockChunks: 1000, }, + { + chain: "TERRA", + chainType: "cosmwasm", + blockChunks: 1000, + chainId: "pisco-1", + contractAddress: + "terra1sryye399v0wrq5aap0s9jlqn9s6wm34gmd27pnlmceghd9qsgyqsugalra", + decimals: 6, + intialFund: "1000000", + lastBlock: 14343708, + nativeCoinSymbol: "LUNA", + rpcURL: "https://rpc.testcosmos.directory/terra2testnet", + walletPrefix: "terra", + }, ] as const satisfies TChain[]; export const storageTestnetConfig: IEvmChainConfig = { From 8c81f1a8a122a15f15a303edb3a9a41f64e26765 Mon Sep 17 00:00:00 2001 From: D Date: Mon, 16 Dec 2024 15:18:24 +0500 Subject: [PATCH 02/12] chore(secret): new testnet contract --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index a95c560..2811f47 100644 --- a/src/config.ts +++ b/src/config.ts @@ -62,7 +62,7 @@ export const bridgeTestChains = [ blockChunks: 1000, chainType: "scrt", chainId: "secret-4", - contractAddress: "secret1zyd2j3wqkeagcuzhklewfa6u26epn672cuktnm", + contractAddress: "secret1g2hwd0ah57a5elkkne544495qnfldvz02ckyg5", decimals: 6, intialFund: "10000000", lastBlock: 16833475, From 0337357fa0ffb6cd3b7ee8641f3c67eab82df71a Mon Sep 17 00:00:00 2001 From: imsk17 Date: Mon, 16 Dec 2024 16:23:00 +0530 Subject: [PATCH 03/12] feat(config::testnet): bump tezos contract --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 479900c..b518028 100644 --- a/src/config.ts +++ b/src/config.ts @@ -73,7 +73,7 @@ export const bridgeTestChains = [ blockChunks: 1000, chain: "TEZOS", chainType: "tezos", - contractAddress: "KT1Fh6VH8BxA9xgJCn8hGZRxoo2vY3hrbqeV", + contractAddress: "KT1CFXpeB7RPAvzgGAVBkKZ5fXsAB61h72rs", decimals: 9, intialFund: "100000000", lastBlock: 7259145, From 1d17e5733bba87754a6eaf1ddaf6e3e2166f675f Mon Sep 17 00:00:00 2001 From: imsk17 Date: Mon, 16 Dec 2024 16:44:35 +0530 Subject: [PATCH 04/12] feat(config::testnet): bump hedera contract --- src/config.ts | 2 +- validator.db-journal | 0 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 validator.db-journal diff --git a/src/config.ts b/src/config.ts index b518028..6afa03a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -40,7 +40,7 @@ export const bridgeTestChains = [ rpcURL: "https://testnet.hashio.io/api", nativeCoinSymbol: "HBAR", intialFund: "50000000000000000", - contractAddress: "0xf33e51DccC7727F1ac62782de7811712420841a0", + contractAddress: "0x0C687Dc235f8e461441d69Dc6aD123EAe7401744", chainType: "evm", lastBlock: 6959861, decimals: 18, diff --git a/validator.db-journal b/validator.db-journal new file mode 100644 index 0000000..e69de29 From 34649b5213cb0a421fb72cfb9570c3fb9c1a27fd Mon Sep 17 00:00:00 2001 From: D Date: Mon, 16 Dec 2024 16:44:37 +0500 Subject: [PATCH 05/12] chore(secret): contract --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 6afa03a..7d13163 100644 --- a/src/config.ts +++ b/src/config.ts @@ -62,7 +62,7 @@ export const bridgeTestChains = [ blockChunks: 1000, chainType: "scrt", chainId: "secret-4", - contractAddress: "secret1g2hwd0ah57a5elkkne544495qnfldvz02ckyg5", + contractAddress: "secret1ym9jslryg6r8nlch2036py92gd50vejznwhuvx", decimals: 6, intialFund: "10000000", lastBlock: 16833475, From 1f99f4db5a6b23e143b5d9416e0e3ab03d093812 Mon Sep 17 00:00:00 2001 From: D Date: Mon, 16 Dec 2024 17:02:46 +0500 Subject: [PATCH 06/12] chore(hedera): new contract --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 7d13163..2bdc14f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -256,7 +256,7 @@ export const prodBridgeConfig: IBridgeConfig = { rpcURL: process.env.HEDERA_RPC || "https://mainnet.hashio.io/api", nativeCoinSymbol: "HBAR", intialFund: "50000000000000000000", - contractAddress: "0x00000000000000000000000000000000006bc585", + contractAddress: "0x0000000000000000000000000000000000786484", chainType: "hedera", lastBlock: 68924608, royaltyInfoProxyAddress: "0x97fec8ed7203ea3ce58e2a4f44056fd954a35be4", From 5cc3e5553a1428865a3b11e893bbde6546ac1735 Mon Sep 17 00:00:00 2001 From: Muhammad Usman Date: Mon, 16 Dec 2024 17:44:06 +0500 Subject: [PATCH 07/12] fix(secret): convert token id before getting nft data --- src/handler/lock-listener/lock-listener.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/handler/lock-listener/lock-listener.ts b/src/handler/lock-listener/lock-listener.ts index 6f4f616..5718c5e 100644 --- a/src/handler/lock-listener/lock-listener.ts +++ b/src/handler/lock-listener/lock-listener.ts @@ -14,7 +14,12 @@ import type { THandler, TNftTransferDetailsObject, } from "../types"; -import { fetchHttpOrIpfs, retry, useMutexAndRelease } from "../utils"; +import { + convertNumbToHexToString, + fetchHttpOrIpfs, + retry, + useMutexAndRelease, +} from "../utils"; import { unreachable } from "../utils/unreachable"; import { processEventsFailSafe } from "./process-fail-safe"; @@ -65,7 +70,9 @@ export async function listenEvents( } const nftDetails = await sourceChain.nftData( - ev.tokenId, + ev.sourceChain === "SECRET" && ev.destinationChain === "SECRET" + ? convertNumbToHexToString(ev.tokenId) + : ev.tokenId, ev.sourceNftContractAddress, log, ); From 3fd528f8755e4d4c50808519cb9de18db978687b Mon Sep 17 00:00:00 2001 From: Muhammad Usman Date: Mon, 16 Dec 2024 18:17:38 +0500 Subject: [PATCH 08/12] fix(secret): send converted id for storing signatures --- src/handler/lock-listener/lock-listener.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/handler/lock-listener/lock-listener.ts b/src/handler/lock-listener/lock-listener.ts index 5718c5e..278f5c2 100644 --- a/src/handler/lock-listener/lock-listener.ts +++ b/src/handler/lock-listener/lock-listener.ts @@ -16,6 +16,7 @@ import type { } from "../types"; import { convertNumbToHexToString, + convertStringToHexToNumb, fetchHttpOrIpfs, retry, useMutexAndRelease, @@ -69,9 +70,18 @@ export async function listenEvents( return; } + let convertedTokenId = ev.tokenId; + if (ev.sourceChain === "SECRET") { + if (chain.chainIdent === "SECRET") { + convertedTokenId = convertStringToHexToNumb(ev.tokenId); + } else if (ev.destinationChain === "SECRET") { + convertedTokenId = convertNumbToHexToString(ev.tokenId); + } + } + const nftDetails = await sourceChain.nftData( ev.sourceChain === "SECRET" && ev.destinationChain === "SECRET" - ? convertNumbToHexToString(ev.tokenId) + ? convertedTokenId : ev.tokenId, ev.sourceNftContractAddress, log, @@ -138,7 +148,7 @@ export async function listenEvents( sourceNftContractAddress: ev.sourceNftContractAddress, symbol: nftDetails.symbol, tokenAmount: ev.tokenAmount, - tokenId: ev.tokenId, + tokenId: convertedTokenId, transactionHash: ev.transactionHash, lockTxChain: chain.chainIdent, imgUri: imgUri?.substring(imgUri?.indexOf("https://")) || "", @@ -207,7 +217,9 @@ export async function listenEvents( return await useMutexAndRelease(fetchStorage, async (storage) => { const feeData = await storageProvider.getFeeData(); log.info( - `Using nonce: ${nonce}, txHash: ${inft.transactionHash} ${new Date().getSeconds()} ${+new Date()}`, + `Using nonce: ${nonce}, txHash: ${ + inft.transactionHash + } ${new Date().getSeconds()} ${+new Date()}`, ); const response = await ( await storage.approveLockNft( @@ -224,7 +236,9 @@ export async function listenEvents( ).wait(); used(); log.info( - `Used nonce: ${nonce}, txHash: ${inft.transactionHash} ${new Date().getSeconds()} ${+new Date()}`, + `Used nonce: ${nonce}, txHash: ${ + inft.transactionHash + } ${new Date().getSeconds()} ${+new Date()}`, ); await setTimeout(5 * 1000); return response; From 8477179605da5387911d4b48b7d571826df31039 Mon Sep 17 00:00:00 2001 From: Muhammad Usman Date: Mon, 16 Dec 2024 18:43:45 +0500 Subject: [PATCH 09/12] fix(secret): revert token id change --- src/handler/lock-listener/lock-listener.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/handler/lock-listener/lock-listener.ts b/src/handler/lock-listener/lock-listener.ts index 278f5c2..e9851a2 100644 --- a/src/handler/lock-listener/lock-listener.ts +++ b/src/handler/lock-listener/lock-listener.ts @@ -16,7 +16,6 @@ import type { } from "../types"; import { convertNumbToHexToString, - convertStringToHexToNumb, fetchHttpOrIpfs, retry, useMutexAndRelease, @@ -70,18 +69,9 @@ export async function listenEvents( return; } - let convertedTokenId = ev.tokenId; - if (ev.sourceChain === "SECRET") { - if (chain.chainIdent === "SECRET") { - convertedTokenId = convertStringToHexToNumb(ev.tokenId); - } else if (ev.destinationChain === "SECRET") { - convertedTokenId = convertNumbToHexToString(ev.tokenId); - } - } - const nftDetails = await sourceChain.nftData( ev.sourceChain === "SECRET" && ev.destinationChain === "SECRET" - ? convertedTokenId + ? convertNumbToHexToString(ev.tokenId) : ev.tokenId, ev.sourceNftContractAddress, log, @@ -148,7 +138,7 @@ export async function listenEvents( sourceNftContractAddress: ev.sourceNftContractAddress, symbol: nftDetails.symbol, tokenAmount: ev.tokenAmount, - tokenId: convertedTokenId, + tokenId: ev.tokenId, transactionHash: ev.transactionHash, lockTxChain: chain.chainIdent, imgUri: imgUri?.substring(imgUri?.indexOf("https://")) || "", From af7fd594f0fdfd176522c60f86ef01fca2c86b22 Mon Sep 17 00:00:00 2001 From: Muhammad Usman Date: Mon, 16 Dec 2024 19:00:25 +0500 Subject: [PATCH 10/12] fix(secret): convert token id when only source chain is secret --- src/handler/lock-listener/lock-listener.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/lock-listener/lock-listener.ts b/src/handler/lock-listener/lock-listener.ts index e9851a2..569de02 100644 --- a/src/handler/lock-listener/lock-listener.ts +++ b/src/handler/lock-listener/lock-listener.ts @@ -70,7 +70,7 @@ export async function listenEvents( } const nftDetails = await sourceChain.nftData( - ev.sourceChain === "SECRET" && ev.destinationChain === "SECRET" + ev.sourceChain === "SECRET" ? convertNumbToHexToString(ev.tokenId) : ev.tokenId, ev.sourceNftContractAddress, From 8ffb267247a8108d2a3e0c4f5ece72175784fbfa Mon Sep 17 00:00:00 2001 From: Muhammad Usman Date: Mon, 16 Dec 2024 19:09:33 +0500 Subject: [PATCH 11/12] fix(secret): sign metadata from lock event --- src/handler/lock-listener/lock-listener.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/lock-listener/lock-listener.ts b/src/handler/lock-listener/lock-listener.ts index 569de02..ddb19e8 100644 --- a/src/handler/lock-listener/lock-listener.ts +++ b/src/handler/lock-listener/lock-listener.ts @@ -97,7 +97,7 @@ export async function listenEvents( // ? ev.metaDataUri // : nftDetails.metadata || ev.metaDataUri; - if (ev.sourceChain === "CASPER") { + if (ev.sourceChain === "CASPER" || data.sourceChain === "SECRET") { metadataUri = ev.metaDataUri; } else { metadataUri = nftDetails.metadata || ev.metaDataUri; From e89fde630f1798ca86c1ac3b0481efbb848bab9e Mon Sep 17 00:00:00 2001 From: Muhammad Usman Date: Mon, 16 Dec 2024 19:14:29 +0500 Subject: [PATCH 12/12] fix(secret): fix event data --- src/handler/lock-listener/lock-listener.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/lock-listener/lock-listener.ts b/src/handler/lock-listener/lock-listener.ts index ddb19e8..a842ba8 100644 --- a/src/handler/lock-listener/lock-listener.ts +++ b/src/handler/lock-listener/lock-listener.ts @@ -97,7 +97,7 @@ export async function listenEvents( // ? ev.metaDataUri // : nftDetails.metadata || ev.metaDataUri; - if (ev.sourceChain === "CASPER" || data.sourceChain === "SECRET") { + if (ev.sourceChain === "CASPER" || ev.sourceChain === "SECRET") { metadataUri = ev.metaDataUri; } else { metadataUri = nftDetails.metadata || ev.metaDataUri;