Skip to content

Commit

Permalink
feat: modify limit of get nfts
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Oct 17, 2024
1 parent b75773e commit cb9348c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 48 deletions.
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.0",
"version": "2.4.2",
"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
1 change: 1 addition & 0 deletions src/functions/ripple/ripple.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export async function getAllRippleVaults(
const getAccountNFTsRequest: AccountNFTsRequest = {
command: 'account_nfts',
account: issuerAddress,
limit: 400,
};

const {
Expand Down
103 changes: 56 additions & 47 deletions src/network-handlers/ripple-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ export class RippleHandler {
const getNFTsTransaction: AccountNFTsRequest = {
command: 'account_nfts',
account: this.issuerAddress,
limit: 400,
};

const nfts: xrpl.AccountNFTsResponse = await this.client.request(getNFTsTransaction);
Expand Down Expand Up @@ -372,62 +373,70 @@ export class RippleHandler {
}

async burnNFT(nftUUID: string, incrementBy: number = 0): Promise<string> {
if (!this.client.isConnected()) {
await this.client.connect();
}
console.log(`Getting sig for Burning Ripple Vault, vault: ${nftUUID}`);
const nftTokenId = await this.getNFTokenIdForVault(nftUUID);
const burnTransactionJson: SubmittableTransaction = {
TransactionType: 'NFTokenBurn',
Account: this.issuerAddress,
NFTokenID: nftTokenId,
};
const preparedBurnTx = await this.client.autofill(burnTransactionJson, this.minSigners); // this hardcoded number should match the number of active signers
try {
if (!this.client.isConnected()) {
await this.client.connect();
}
console.log(`Getting sig for Burning Ripple Vault, vault: ${nftUUID}`);
const nftTokenId = await this.getNFTokenIdForVault(nftUUID);
const burnTransactionJson: SubmittableTransaction = {
TransactionType: 'NFTokenBurn',
Account: this.issuerAddress,
NFTokenID: nftTokenId,
};
const preparedBurnTx = await this.client.autofill(burnTransactionJson, this.minSigners); // this hardcoded number should match the number of active signers

// set the LastLedgerSequence to equal LastLedgerSequence plus 5 and then rounded up to the nearest 10
// this is to ensure that the transaction is valid for a while, and that the different attestors all use a matching LLS value to have matching sigs
preparedBurnTx.LastLedgerSequence =
Math.ceil(preparedBurnTx.LastLedgerSequence! / 10000 + 1) * 10000; // Better way?!?
// set the LastLedgerSequence to equal LastLedgerSequence plus 5 and then rounded up to the nearest 10
// this is to ensure that the transaction is valid for a while, and that the different attestors all use a matching LLS value to have matching sigs
preparedBurnTx.LastLedgerSequence =
Math.ceil(preparedBurnTx.LastLedgerSequence! / 10000 + 1) * 10000; // Better way?!?

if (incrementBy > 0) {
preparedBurnTx.Sequence = preparedBurnTx.Sequence! + incrementBy;
}
if (incrementBy > 0) {
preparedBurnTx.Sequence = preparedBurnTx.Sequence! + incrementBy;
}

console.log('preparedBurnTx ', preparedBurnTx);
console.log('preparedBurnTx ', preparedBurnTx);

const sig = this.wallet.sign(preparedBurnTx, true);
// console.log('tx_one_sig: ', sig);
return sig.tx_blob;
const sig = this.wallet.sign(preparedBurnTx, true);
// console.log('tx_one_sig: ', sig);
return sig.tx_blob;
} catch (error) {
throw new RippleError(`Could not burn Vault: ${error}`);
}
}

async mintNFT(vault: RawVault, incrementBy: number = 0): Promise<string> {
if (!this.client.isConnected()) {
await this.client.connect();
}
console.log(`Getting sig for Minting Ripple Vault, vault: ${JSON.stringify(vault, null, 2)}`);
const newURI = encodeURI(vault);
console.log('newURI: ', newURI);
const mintTransactionJson: SubmittableTransaction = {
TransactionType: 'NFTokenMint',
Account: this.issuerAddress,
URI: newURI,
NFTokenTaxon: 0,
};
const preparedMintTx = await this.client.autofill(mintTransactionJson, this.minSigners);

// set the LastLedgerSequence to equal LastLedgerSequence plus 5 and then rounded up to the nearest 10
// this is to ensure that the transaction is valid for a while, and that the different attestors all use a matching LLS value to have matching sigs
preparedMintTx.LastLedgerSequence =
Math.ceil(preparedMintTx.LastLedgerSequence! / 10000 + 1) * 10000;
if (incrementBy > 0) {
preparedMintTx.Sequence = preparedMintTx.Sequence! + incrementBy;
}
try {
if (!this.client.isConnected()) {
await this.client.connect();
}
console.log(`Getting sig for Minting Ripple Vault, vault: ${JSON.stringify(vault, null, 2)}`);
const newURI = encodeURI(vault);
console.log('newURI: ', newURI);
const mintTransactionJson: SubmittableTransaction = {
TransactionType: 'NFTokenMint',
Account: this.issuerAddress,
URI: newURI,
NFTokenTaxon: 0,
};
const preparedMintTx = await this.client.autofill(mintTransactionJson, this.minSigners);

// set the LastLedgerSequence to equal LastLedgerSequence plus 5 and then rounded up to the nearest 10
// this is to ensure that the transaction is valid for a while, and that the different attestors all use a matching LLS value to have matching sigs
preparedMintTx.LastLedgerSequence =
Math.ceil(preparedMintTx.LastLedgerSequence! / 10000 + 1) * 10000;
if (incrementBy > 0) {
preparedMintTx.Sequence = preparedMintTx.Sequence! + incrementBy;
}

console.log('preparedMintTx ', preparedMintTx);
console.log('preparedMintTx ', preparedMintTx);

const sig = this.wallet.sign(preparedMintTx, true);
console.log('tx_one_sig: ', sig);
return sig.tx_blob;
const sig = this.wallet.sign(preparedMintTx, true);
console.log('tx_one_sig: ', sig);
return sig.tx_blob;
} catch (error) {
throw new RippleError(`Could not mint Vault: ${error}`);
}
}

async getSigUpdateVaultForSSP(uuid: string, updates: SSPVaultUpdate): Promise<string> {
Expand Down

0 comments on commit cb9348c

Please sign in to comment.