Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support xrpl #34

Merged
merged 31 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0a35add
Add initial support for Ripple, RippleHandler
sosaucily Sep 25, 2024
b12c077
remove some noisy debug statements;
sosaucily Sep 30, 2024
f00241c
feat: add check functions to ripplehandler
Polybius93 Sep 30, 2024
8eed719
chore: merge branch 'support-xrpl' into feat/support-xrpl-check
Polybius93 Sep 30, 2024
09fe59b
feat: modify ripple handler to handle token minting
Polybius93 Oct 2, 2024
30014a7
feat: modify customer wallet seed
Polybius93 Oct 5, 2024
46216c7
Merge pull request #32 from DLC-link/feat/support-xrpl-check
sosaucily Oct 5, 2024
e67a4a5
Support multisig for XRPL txs
sosaucily Oct 7, 2024
8b71cb6
feat: abstract xrpl functions, modifiy ripple handler
Polybius93 Oct 10, 2024
4d6d192
feat: modify ripple functions
Polybius93 Oct 14, 2024
6d7af06
remove NFT burning, only mint more
sosaucily Oct 14, 2024
9810560
sort by nft_serial when getting all vaults
sosaucily Oct 14, 2024
112d065
feat: add ledger-xrp-handler
Polybius93 Oct 15, 2024
a7ff441
chore: revert "sort by nft_serial when getting all vaults"
Polybius93 Oct 15, 2024
cfbd637
chore: revert "remove NFT burning, only mint more"
Polybius93 Oct 15, 2024
f73dc87
feat: add gem wallet xrp handler
Polybius93 Oct 15, 2024
ec5a5c9
feat: modify ripplehandler to have websockerurl argument in constructor
Polybius93 Oct 15, 2024
0ba53c9
feat: add minSigners argument to ripplehandler
Polybius93 Oct 16, 2024
b75773e
chore: bump version
Polybius93 Oct 16, 2024
5f0b1ba
feat: add timestamp to xrpl vaults
Polybius93 Oct 17, 2024
a643120
feat: modify currency symbol for xrpl
Polybius93 Oct 17, 2024
cb9348c
feat: modify limit of get nfts
Polybius93 Oct 17, 2024
181b7bf
chore: merge branch 'fix/nft-limit' into feat/support-xrpl
Polybius93 Oct 17, 2024
d072392
chore: merge branch 'feat/add-xrpl-date' into feat/support-xrpl
Polybius93 Oct 17, 2024
3c40342
chore: bump package version
Polybius93 Oct 17, 2024
9730076
feat: add cash check by tx id function (#33)
Polybius93 Oct 18, 2024
857107e
feat: add pagination to getAllRippleVaults
Polybius93 Oct 21, 2024
98b2804
feat: add fee arguments to setup vault
Polybius93 Oct 22, 2024
a8c2ca8
feat: add attestorChainID to xrpl attestor requests
Polybius93 Oct 23, 2024
3159e78
use a withXrplConnection context for functions that need a connection
sosaucily Oct 27, 2024
1866b3b
feat: remove lint-commit git hook, bump version
Polybius93 Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ jobs:
- name: Typecheck
run: yarn lint:typecheck

lint-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Commit Message
uses: wagoid/commitlint-github-action@v4

test-unit:
needs: build
runs-on: ubuntu-latest
Expand Down
37 changes: 21 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "dlc-btc-lib",
"version": "2.2.7",
"version": "2.4.9",
"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 All @@ -15,7 +15,8 @@
"./models": "./dist/models/index.js",
"./bitcoin-functions": "./dist/functions/bitcoin/index.js",
"./attestor-request-functions": "./dist/functions/attestor/index.js",
"./ethereum-functions": "./dist/functions/ethereum/index.js"
"./ethereum-functions": "./dist/functions/ethereum/index.js",
"./ripple-functions": "./dist/functions/ripple/index.js"
},
"scripts": {
"clean": "rm -rf dist && rm -rf node_modules",
Expand Down Expand Up @@ -58,20 +59,24 @@
"typescript-eslint": "^7.7.0"
},
"dependencies": {
"@ledgerhq/hw-app-btc": "^10.2.4",
"@noble/hashes": "^1.4.0",
"@scure/base": "^1.1.6",
"@scure/btc-signer": "^1.3.1",
"@types/ramda": "^0.30.1",
"bip32": "^4.0.0",
"bitcoinjs-lib": "^6.1.5",
"chalk": "^5.3.0",
"decimal.js": "^10.4.3",
"@gemwallet/api": "3.8.0",
"@ledgerhq/hw-app-btc": "10.4.1",
"@ledgerhq/hw-app-xrp": "6.29.4",
"@noble/hashes": "1.4.0",
"@scure/base": "1.1.8",
"@scure/btc-signer": "1.3.2",
"@types/ramda": "0.30.1",
"bip32": "4.0.0",
"bitcoinjs-lib": "6.1.6",
"chalk": "5.3.0",
"decimal.js": "10.4.3",
"ethers": "5.7.2",
"ledger-bitcoin": "^0.2.3",
"prompts": "^2.4.2",
"ramda": "^0.30.1",
"scure": "^1.6.0",
"tiny-secp256k1": "^2.2.3"
"ledger-bitcoin": "0.2.3",
"prompts": "2.4.2",
"ramda": "0.30.1",
"ripple-binary-codec": "2.1.0",
"scure": "1.6.0",
"tiny-secp256k1": "2.2.3",
"xrpl": "4.0.0"
}
}
4 changes: 4 additions & 0 deletions src/constants/ripple.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { convertStringToHex } from 'xrpl';

export const TRANSACTION_SUCCESS_CODE = 'tesSUCCESS';
export const XRPL_DLCBTC_CURRENCY_HEX = convertStringToHex('dlcBTC').padEnd(40, '0');
33 changes: 4 additions & 29 deletions src/dlc-handlers/software-wallet-dlc-handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Transaction, p2tr, p2wpkh } from '@scure/btc-signer';
import { P2Ret, P2TROut } from '@scure/btc-signer/payment';
import { Network } from 'bitcoinjs-lib';
import { bitcoin, regtest, testnet } from 'bitcoinjs-lib/src/networks.js';

import {
createTaprootMultisigPayment,
Expand Down Expand Up @@ -33,35 +32,11 @@ export class SoftwareWalletDLCHandler {
taprootDerivedPublicKey: string,
fundingPaymentType: 'wpkh' | 'tr',
bitcoinNetwork: Network,
bitcoinBlockchainAPI?: string,
bitcoinBlockchainFeeRecommendationAPI?: string
bitcoinBlockchainAPI: string,
bitcoinBlockchainFeeRecommendationAPI: string
) {
switch (bitcoinNetwork) {
case bitcoin:
this.bitcoinBlockchainAPI = 'https://mempool.space/api';
this.bitcoinBlockchainFeeRecommendationAPI =
'https://mempool.space/api/v1/fees/recommended';
break;
case testnet:
this.bitcoinBlockchainAPI = 'https://mempool.space/testnet/api';
this.bitcoinBlockchainFeeRecommendationAPI =
'https://mempool.space/testnet/api/v1/fees/recommended';
break;
case regtest:
if (
bitcoinBlockchainAPI === undefined ||
bitcoinBlockchainFeeRecommendationAPI === undefined
) {
throw new Error(
'Regtest requires a Bitcoin Blockchain API and a Bitcoin Blockchain Fee Recommendation API'
);
}
this.bitcoinBlockchainAPI = bitcoinBlockchainAPI;
this.bitcoinBlockchainFeeRecommendationAPI = bitcoinBlockchainFeeRecommendationAPI;
break;
default:
throw new Error('Invalid Bitcoin Network');
}
this.bitcoinBlockchainAPI = bitcoinBlockchainAPI;
this.bitcoinBlockchainFeeRecommendationAPI = bitcoinBlockchainFeeRecommendationAPI;
this.fundingPaymentType = fundingPaymentType;
this.bitcoinNetwork = bitcoinNetwork;
this.fundingDerivedPublicKey = fundingDerivedPublicKey;
Expand Down
28 changes: 27 additions & 1 deletion src/functions/attestor/attestor-request.functions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
import { equals, filter, isEmpty, isNotNil, join, map, prop } from 'ramda';

import {
AttestorChainID,
FundingTXAttestorInfo,
WithdrawDepositTXAttestorInfo,
} from '../../models/attestor.models.js';
import { AttestorError } from '../../models/errors.js';
import { sendRequest } from '../request/request.functions.js';
import { sendGetRequest, sendRequest } from '../request/request.functions.js';

export async function submitSetupXRPLVaultRequest(
coordinatorURL: string,
userXRPLAddress: string,
attestorChainID: AttestorChainID
): Promise<void> {
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,
attestorChainID: AttestorChainID
): Promise<void> {
const requestBody = JSON.stringify({ tx_hash: txHash, chain: attestorChainID });
return sendRequest(`${coordinatorURL}/app/cash-xrpl-check`, requestBody);
}

export async function getAttestorExtendedGroupPublicKey(coordinatorURL: string): Promise<string> {
return sendGetRequest(`${coordinatorURL}/tss/get-extended-group-publickey`);
}

export async function submitFundingPSBT(
attestorRootURLs: string[],
Expand Down
3 changes: 3 additions & 0 deletions src/functions/attestor/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export {
submitFundingPSBT,
submitWithdrawDepositPSBT,
getAttestorExtendedGroupPublicKey,
submitSetupXRPLVaultRequest,
submitXRPLCheckToCash,
} from '../attestor/attestor-request.functions.js';
4 changes: 3 additions & 1 deletion src/functions/bitcoin/bitcoin-request-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export async function fetchBitcoinTransaction(
const response = await fetch(bitcoinBlockchainAPITransactionEndpoint);

if (!response.ok)
throw new Error(`Bitcoin Network Transaction Response was not OK: ${response.statusText}`);
throw new Error(
`Bitcoin Network Transaction Response was not OK: ${response.statusText} - btc tx id: ${txID}`
);

return await response.json();
} catch (error) {
Expand Down
17 changes: 16 additions & 1 deletion src/functions/request/request.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ export async function sendRequest(url: string, body: string): Promise<void> {
});

if (!response.ok) {
throw new Error(`Response ${url} was not OK: ${response.statusText}`);
const errorMessage = await response.text();
throw new Error(`Request to ${url} failed: ${response.statusText} - ${errorMessage}`);
}
}

export async function sendGetRequest(url: string): Promise<string> {
const response = await fetch(url, {
method: 'GET',
headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' },
});

if (!response.ok) {
const errorMessage = await response.text();
throw new Error(`Request to ${url} failed: ${response.statusText} - ${errorMessage}`);
}

return response.text();
}
1 change: 1 addition & 0 deletions src/functions/ripple/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ripple.functions.js';
Loading
Loading