From a8c2ca8d76fa85a1a46d813eb645c7190714ec79 Mon Sep 17 00:00:00 2001 From: Polybius93 Date: Wed, 23 Oct 2024 13:58:45 +0200 Subject: [PATCH] feat: add attestorChainID to xrpl attestor requests --- .gitignore | 3 --- package.json | 2 +- .../attestor/attestor-request.functions.ts | 17 +++++++++++++---- src/models/attestor.models.ts | 11 ++++++++++- src/network-handlers/xrp-gem-wallet-handler.ts | 9 +++++++-- src/network-handlers/xrp-ledger-handler.ts | 9 +++++++-- 6 files changed, 38 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index a138e33..2b3f55c 100644 --- a/.gitignore +++ b/.gitignore @@ -132,6 +132,3 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* - -# Local Netlify folder -.netlify diff --git a/package.json b/package.json index 59d2b0b..5f4f986 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "dlc-btc-lib", - "version": "2.4.7", + "version": "2.4.8", "description": "This library provides a comprehensive set of interfaces and functions for minting dlcBTC tokens on supported blockchains.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/functions/attestor/attestor-request.functions.ts b/src/functions/attestor/attestor-request.functions.ts index e3c07c3..f4026e0 100644 --- a/src/functions/attestor/attestor-request.functions.ts +++ b/src/functions/attestor/attestor-request.functions.ts @@ -1,6 +1,7 @@ import { equals, filter, isEmpty, isNotNil, join, map, prop } from 'ramda'; import { + AttestorChainID, FundingTXAttestorInfo, WithdrawDepositTXAttestorInfo, } from '../../models/attestor.models.js'; @@ -9,14 +10,22 @@ import { sendGetRequest, sendRequest } from '../request/request.functions.js'; export async function submitSetupXRPLVaultRequest( coordinatorURL: string, - userXRPLAddress: string + userXRPLAddress: string, + attestorChainID: AttestorChainID ): Promise { - const requestBody = JSON.stringify({ user_xrpl_address: userXRPLAddress }); + const requestBody = JSON.stringify({ + user_xrpl_address: userXRPLAddress, + chain: attestorChainID, + }); return sendRequest(`${coordinatorURL}/app/setup-xrpl-vault`, requestBody); } -export async function submitXRPLCheckToCash(coordinatorURL: string, txHash: string): Promise { - const requestBody = JSON.stringify({ tx_hash: txHash }); +export async function submitXRPLCheckToCash( + coordinatorURL: string, + txHash: string, + attestorChainID: AttestorChainID +): Promise { + const requestBody = JSON.stringify({ tx_hash: txHash, chain: attestorChainID }); return sendRequest(`${coordinatorURL}/app/cash-xrpl-check`, requestBody); } diff --git a/src/models/attestor.models.ts b/src/models/attestor.models.ts index bd1fe88..4a5e247 100644 --- a/src/models/attestor.models.ts +++ b/src/models/attestor.models.ts @@ -1,11 +1,20 @@ export type AttestorChainID = + | 'evm-mainnet' + | 'evm-sepolia' | 'evm-arbitrum' | 'evm-arbsepolia' + | 'evm-base' + | 'evm-basesepolia' + | 'evm-optimism' + | 'evm-opsepolia' + | 'evm-polygon' + | 'evm-polygonsepolia' | 'evm-localhost' | 'evm-hardhat-arb' | 'evm-hardhat-eth' | 'ripple-xrpl-mainnet' - | 'ripple-xrpl-testnet'; + | 'ripple-xrpl-testnet' + | 'ripple-xrpl-devnet'; export interface FundingTXAttestorInfo { vaultUUID: string; diff --git a/src/network-handlers/xrp-gem-wallet-handler.ts b/src/network-handlers/xrp-gem-wallet-handler.ts index a7337c0..3f5ff56 100644 --- a/src/network-handlers/xrp-gem-wallet-handler.ts +++ b/src/network-handlers/xrp-gem-wallet-handler.ts @@ -11,6 +11,7 @@ import { getLockedBTCBalance, setTrustLine, } from '../functions/ripple/ripple.functions.js'; +import { AttestorChainID } from '../models/attestor.models.js'; export class GemXRPHandler { private xrpClient: Client; @@ -127,9 +128,13 @@ export class GemXRPHandler { } } - public async sendCheckTXHash(coordinatorURL: string, checkTXHash: string): Promise { + public async sendCheckTXHash( + coordinatorURL: string, + checkTXHash: string, + attestorChainID: AttestorChainID + ): Promise { try { - await submitXRPLCheckToCash(coordinatorURL, checkTXHash); + await submitXRPLCheckToCash(coordinatorURL, checkTXHash, attestorChainID); } catch (error) { throw new Error(`Error sending Check TX Hash to Attestors: ${error}`); } diff --git a/src/network-handlers/xrp-ledger-handler.ts b/src/network-handlers/xrp-ledger-handler.ts index 1d05c7a..17deb1b 100644 --- a/src/network-handlers/xrp-ledger-handler.ts +++ b/src/network-handlers/xrp-ledger-handler.ts @@ -11,6 +11,7 @@ import { getLockedBTCBalance, setTrustLine, } from '../functions/ripple/ripple.functions.js'; +import { AttestorChainID } from '../models/attestor.models.js'; export class LedgerXRPHandler { private ledgerApp: Xrp.default; @@ -137,9 +138,13 @@ export class LedgerXRPHandler { } } - public async sendCheckTXHash(coordinatorURL: string, checkTXHash: string): Promise { + public async sendCheckTXHash( + coordinatorURL: string, + checkTXHash: string, + attestorChainID: AttestorChainID + ): Promise { try { - await submitXRPLCheckToCash(coordinatorURL, checkTXHash); + await submitXRPLCheckToCash(coordinatorURL, checkTXHash, attestorChainID); } catch (error) { throw new Error(`Error sending Check TX Hash to Attestors: ${error}`); }