Skip to content

Commit

Permalink
feat: add attestorChainID to xrpl attestor requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Oct 24, 2024
1 parent 98b2804 commit a8c2ca8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,3 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Local Netlify folder
.netlify
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
17 changes: 13 additions & 4 deletions src/functions/attestor/attestor-request.functions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { equals, filter, isEmpty, isNotNil, join, map, prop } from 'ramda';

import {
AttestorChainID,
FundingTXAttestorInfo,
WithdrawDepositTXAttestorInfo,
} from '../../models/attestor.models.js';
Expand All @@ -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<void> {
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<void> {
const requestBody = JSON.stringify({ tx_hash: txHash });
export async function submitXRPLCheckToCash(
coordinatorURL: string,
txHash: string,
attestorChainID: AttestorChainID
): Promise<void> {
const requestBody = JSON.stringify({ tx_hash: txHash, chain: attestorChainID });
return sendRequest(`${coordinatorURL}/app/cash-xrpl-check`, requestBody);
}

Expand Down
11 changes: 10 additions & 1 deletion src/models/attestor.models.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 7 additions & 2 deletions src/network-handlers/xrp-gem-wallet-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -127,9 +128,13 @@ export class GemXRPHandler {
}
}

public async sendCheckTXHash(coordinatorURL: string, checkTXHash: string): Promise<void> {
public async sendCheckTXHash(
coordinatorURL: string,
checkTXHash: string,
attestorChainID: AttestorChainID
): Promise<void> {
try {
await submitXRPLCheckToCash(coordinatorURL, checkTXHash);
await submitXRPLCheckToCash(coordinatorURL, checkTXHash, attestorChainID);
} catch (error) {
throw new Error(`Error sending Check TX Hash to Attestors: ${error}`);
}
Expand Down
9 changes: 7 additions & 2 deletions src/network-handlers/xrp-ledger-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -137,9 +138,13 @@ export class LedgerXRPHandler {
}
}

public async sendCheckTXHash(coordinatorURL: string, checkTXHash: string): Promise<void> {
public async sendCheckTXHash(
coordinatorURL: string,
checkTXHash: string,
attestorChainID: AttestorChainID
): Promise<void> {
try {
await submitXRPLCheckToCash(coordinatorURL, checkTXHash);
await submitXRPLCheckToCash(coordinatorURL, checkTXHash, attestorChainID);
} catch (error) {
throw new Error(`Error sending Check TX Hash to Attestors: ${error}`);
}
Expand Down

0 comments on commit a8c2ca8

Please sign in to comment.