evernode-js-client 0.5.14 → 0.5.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +67 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -15065,6 +15065,45 @@ class XrplAccount {
15065
15065
  return this.#submitAndVerifyTransaction(tx, options);
15066
15066
  }
15067
15067
 
15068
+ /**
15069
+ * Set the signer list to the account. Setting signerQuorum = 0 in options, will remove the signerlist from the account.
15070
+ * @param {*} signerList (optional) An array of signers. Ex: [ {account:"ras24cvffvfbvfbbt5or4332", weight: 1}, {}, ...]
15071
+ * @param {*} options Ex: {signerQuorum: 1, sequence: 6543233}
15072
+ * @returns a promise
15073
+ */
15074
+ setSignerList(signerList = [], options = {}) {
15075
+ if (options.signerQuorum < 0)
15076
+ throw ("Everpocket: quorum can't be less than zero.");
15077
+
15078
+ if (options.signerQuorum > 0 && signerList.length >= 0) {
15079
+ let totalWeight = 0;
15080
+ for (const signer of signerList) {
15081
+ if (!(signer.account && signer.account.length > 0 && signer.weight && signer.weight > 0))
15082
+ throw ("Everpocket: Signer list is invalid");
15083
+ totalWeight += signerList.weight;
15084
+ }
15085
+ if (totalWeight < options.signerQuorum)
15086
+ throw ("Everpocket: Total weight is less than the quorum");
15087
+ }
15088
+
15089
+ const signerListTx =
15090
+ {
15091
+ Flags: 0,
15092
+ TransactionType: "SignerListSet",
15093
+ Account: this.address,
15094
+ SignerQuorum: options.signerQuorum,
15095
+ SignerEntries: [
15096
+ ...signerList.map(signer => ({
15097
+ SignerEntry: {
15098
+ Account: signer.account,
15099
+ SignerWeight: signer.weight
15100
+ }
15101
+ }))
15102
+ ]
15103
+ };
15104
+ return this.#submitAndVerifyTransaction(signerListTx, options);
15105
+ }
15106
+
15068
15107
  makePayment(toAddr, amount, currency, issuer = null, memos = null, options = {}) {
15069
15108
 
15070
15109
  const amountObj = makeAmountObject(amount, currency, issuer);
@@ -15376,6 +15415,16 @@ class XrplAccount {
15376
15415
 
15377
15416
  });
15378
15417
  }
15418
+
15419
+ /**
15420
+ * Sign the given transaction and returns the signed blob and its hash.
15421
+ * @param {object} tx Transaction object.
15422
+ * @param {boolean} isMultiSign Whether the transaction is for multisigning. Defaults to false.
15423
+ * @returns {hash: string, tx_blob: string}
15424
+ */
15425
+ sign(tx, isMultiSign = false) {
15426
+ return this.wallet.sign(tx, isMultiSign);
15427
+ }
15379
15428
  }
15380
15429
 
15381
15430
  function makeAmountObject(amount, currency, issuer) {
@@ -15697,6 +15746,24 @@ class XrplApi {
15697
15746
  async #subscribeToStream(streamName) {
15698
15747
  await this.#client.request({ command: 'subscribe', streams: [streamName] });
15699
15748
  }
15749
+
15750
+ async submitMultisigned(tx) {
15751
+ return await this.#client.request({command: 'submit_multisigned', tx_json: tx});
15752
+ }
15753
+
15754
+ /**
15755
+ * Join the given the array of signed transactions into one multi-signed transaction.
15756
+ * For more details: https://js.xrpl.org/functions/multisign.html
15757
+ *
15758
+ * @param {(string | Transaction)[]} transactions An array of signed Transactions (in object or blob form) to combine into a single signed Transaction.
15759
+ * @returns A single signed Transaction string which has all Signers from transactions within it.
15760
+ */
15761
+ multiSign(transactions) {
15762
+ if(transactions.length > 0){
15763
+ return xrpl.multisign(transactions);
15764
+ } else
15765
+ throw("Transaction list is empty for multi-signing.");
15766
+ }
15700
15767
  }
15701
15768
 
15702
15769
  module.exports = {
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  ],
7
7
  "homepage": "https://github.com/HotPocketDev/evernode-js-client",
8
8
  "license": "MIT",
9
- "version": "0.5.14",
9
+ "version": "0.5.16",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",