Skip to content

Commit

Permalink
feat: add minSigners argument to ripplehandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Oct 16, 2024
1 parent ec5a5c9 commit 0ba53c9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
28 changes: 20 additions & 8 deletions src/network-handlers/ripple-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,27 @@ export class RippleHandler {
private client: xrpl.Client;
private wallet: xrpl.Wallet;
private issuerAddress: string;

private constructor(seedPhrase: string, issuerAddress: string, websocketURL: string) {
private minSigners: number;

private constructor(
seedPhrase: string,
issuerAddress: string,
websocketURL: string,
minSigners: number
) {
this.client = new xrpl.Client(websocketURL);
this.wallet = xrpl.Wallet.fromSeed(seedPhrase);
this.issuerAddress = issuerAddress;
this.minSigners = minSigners;
}

static fromSeed(seedPhrase: string, issuerAddress: string, websocketURL: string): RippleHandler {
return new RippleHandler(seedPhrase, issuerAddress, websocketURL);
static fromSeed(
seedPhrase: string,
issuerAddress: string,
websocketURL: string,
minSigners: number
): RippleHandler {
return new RippleHandler(seedPhrase, issuerAddress, websocketURL, minSigners);
}

async submit(signatures: string[]): Promise<string> {
Expand Down Expand Up @@ -370,7 +382,7 @@ export class RippleHandler {
Account: this.issuerAddress,
NFTokenID: nftTokenId,
};
const preparedBurnTx = await this.client.autofill(burnTransactionJson, 3); // this hardcoded number should match the number of active signers
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
Expand Down Expand Up @@ -401,7 +413,7 @@ export class RippleHandler {
URI: newURI,
NFTokenTaxon: 0,
};
const preparedMintTx = await this.client.autofill(mintTransactionJson, 3);
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
Expand Down Expand Up @@ -545,7 +557,7 @@ export class RippleHandler {

const updatedCashCheckTransactionJSON: CheckCash = await this.client.autofill(
cashCheckTransactionJSON,
3 // hardcoded? not good? just fee related?
this.minSigners
);

// set the LastLedgerSequence to equal LastLedgerSequence plus 5 and then rounded up to the nearest 10
Expand Down Expand Up @@ -598,7 +610,7 @@ export class RippleHandler {

const updatedSendTokenTransactionJSON: Payment = await this.client.autofill(
sendTokenTransactionJSON,
3
this.minSigners
);

// set the LastLedgerSequence to equal LastLedgerSequence plus 5 and then rounded up to the nearest 10
Expand Down
2 changes: 1 addition & 1 deletion src/network-handlers/xrp-ledger-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Xrp from '@ledgerhq/hw-app-xrp';
import * as Xrp from '@ledgerhq/hw-app-xrp';
import { encode } from 'ripple-binary-codec';
import { CheckCreate, Client, Transaction, TrustSet } from 'xrpl';

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/request-functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Request Functions', () => {
);

await expect(sendRequest(TEST_REGTEST_ATTESTOR_APIS[0], 'requestBody')).rejects.toThrow(
new Error(`Response ${TEST_REGTEST_ATTESTOR_APIS[0]} was not OK: Bad Request`)
new Error(`Request to ${TEST_REGTEST_ATTESTOR_APIS[0]} failed: Bad Request - `)
);
});

Expand Down

0 comments on commit 0ba53c9

Please sign in to comment.