mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-04-29 15:37:50 +00:00
Compare commits
8 Commits
fix-mnemon
...
expanded-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4140cccaca | ||
|
|
082fe492e0 | ||
|
|
993d155cf3 | ||
|
|
1571e30653 | ||
|
|
3b68781a14 | ||
|
|
1fa277676c | ||
|
|
927172a65f | ||
|
|
663415b23f |
19
.github/workflows/nodejs.yml
vendored
19
.github/workflows/nodejs.yml
vendored
@@ -18,12 +18,11 @@ jobs:
|
||||
node-version: [14.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
- run: npm install -g npm@7
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
@@ -38,13 +37,11 @@ jobs:
|
||||
node-version: [12.x, 14.x, 16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: '**/package-lock.json'
|
||||
- run: npm install -g npm@7
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
@@ -66,13 +63,11 @@ jobs:
|
||||
--health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: '**/package-lock.json'
|
||||
- run: npm install -g npm@7
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
@@ -102,8 +97,6 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: '**/package-lock.json'
|
||||
- run: npm install -g npm@7
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
58
package-lock.json
generated
58
package-lock.json
generated
@@ -6998,8 +6998,7 @@
|
||||
},
|
||||
"node_modules/filter-obj": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz",
|
||||
"integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==",
|
||||
"integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs=",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
@@ -12617,9 +12616,8 @@
|
||||
}
|
||||
},
|
||||
"node_modules/parse-path": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/parse-path/-/parse-path-4.0.4.tgz",
|
||||
"integrity": "sha512-Z2lWUis7jlmXC1jeOG9giRO2+FsuyNipeQ43HAjqAZjwSe3SEf+q/84FGPHoso3kyntbxa4c4i77t3m6fGf8cw==",
|
||||
"version": "4.0.3",
|
||||
"integrity": "sha512-9Cepbp2asKnWTJ9x2kpw6Fe8y9JDbqwahGCTvklzd/cEq5C5JC59x2Xb0Kx+x0QZ8bvNquGO8/BWP0cwBHzSAA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"is-ssh": "^1.3.0",
|
||||
@@ -12629,14 +12627,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/parse-url": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/parse-url/-/parse-url-6.0.2.tgz",
|
||||
"integrity": "sha512-uCSjOvD3T+6B/sPWhR+QowAZcU/o4bjPrVBQBGFxcDF6J6FraCGIaDBsdoQawiaaAVdHvtqBe3w3vKlfBKySOQ==",
|
||||
"version": "6.0.0",
|
||||
"integrity": "sha512-cYyojeX7yIIwuJzledIHeLUBVJ6COVLeT4eF+2P6aKVzwvgKQPndCBv3+yQ7pcWjqToYwaligxzSYNNmGoMAvw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"is-ssh": "^1.3.0",
|
||||
"normalize-url": "^6.1.0",
|
||||
"parse-path": "^4.0.4",
|
||||
"parse-path": "^4.0.0",
|
||||
"protocols": "^1.4.0"
|
||||
}
|
||||
},
|
||||
@@ -13108,9 +13105,8 @@
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
|
||||
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
|
||||
"version": "6.10.1",
|
||||
"integrity": "sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"side-channel": "^1.0.4"
|
||||
@@ -13124,7 +13120,6 @@
|
||||
},
|
||||
"node_modules/query-string": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz",
|
||||
"integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
@@ -14595,7 +14590,6 @@
|
||||
},
|
||||
"node_modules/split-on-first": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz",
|
||||
"integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
@@ -14790,8 +14784,7 @@
|
||||
},
|
||||
"node_modules/strict-uri-encode": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
|
||||
"integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==",
|
||||
"integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
@@ -16711,7 +16704,7 @@
|
||||
}
|
||||
},
|
||||
"packages/ripple-binary-codec": {
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.1",
|
||||
"integrity": "sha512-XMRCbFXyG+dGp3x7tMs9IwA+FVWPPaGjdHYW2+g4Q/WQJqFp5MRED+jjOBOUafmrW4TUsOn1PEEdbB4ozWbDBw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -16750,7 +16743,7 @@
|
||||
}
|
||||
},
|
||||
"packages/xrpl": {
|
||||
"version": "2.3.1",
|
||||
"version": "2.3.0",
|
||||
"integrity": "sha512-NmrSYpXym7NzGABeXU1H8g4ZtCxRhr/3wu0lguxzcIYpcKPgWLYimg+s9NLLNbPWTZdxXu9SeSWu5zh4gyqAeA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -16760,7 +16753,7 @@
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"ripple-address-codec": "^4.2.4",
|
||||
"ripple-binary-codec": "^1.4.2",
|
||||
"ripple-binary-codec": "^1.4.1",
|
||||
"ripple-keypairs": "^1.1.4",
|
||||
"ws": "^8.2.2"
|
||||
},
|
||||
@@ -22221,8 +22214,7 @@
|
||||
},
|
||||
"filter-obj": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz",
|
||||
"integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==",
|
||||
"integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs=",
|
||||
"dev": true
|
||||
},
|
||||
"find-cache-dir": {
|
||||
@@ -26436,9 +26428,8 @@
|
||||
}
|
||||
},
|
||||
"parse-path": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/parse-path/-/parse-path-4.0.4.tgz",
|
||||
"integrity": "sha512-Z2lWUis7jlmXC1jeOG9giRO2+FsuyNipeQ43HAjqAZjwSe3SEf+q/84FGPHoso3kyntbxa4c4i77t3m6fGf8cw==",
|
||||
"version": "4.0.3",
|
||||
"integrity": "sha512-9Cepbp2asKnWTJ9x2kpw6Fe8y9JDbqwahGCTvklzd/cEq5C5JC59x2Xb0Kx+x0QZ8bvNquGO8/BWP0cwBHzSAA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-ssh": "^1.3.0",
|
||||
@@ -26448,14 +26439,13 @@
|
||||
}
|
||||
},
|
||||
"parse-url": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/parse-url/-/parse-url-6.0.2.tgz",
|
||||
"integrity": "sha512-uCSjOvD3T+6B/sPWhR+QowAZcU/o4bjPrVBQBGFxcDF6J6FraCGIaDBsdoQawiaaAVdHvtqBe3w3vKlfBKySOQ==",
|
||||
"version": "6.0.0",
|
||||
"integrity": "sha512-cYyojeX7yIIwuJzledIHeLUBVJ6COVLeT4eF+2P6aKVzwvgKQPndCBv3+yQ7pcWjqToYwaligxzSYNNmGoMAvw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-ssh": "^1.3.0",
|
||||
"normalize-url": "^6.1.0",
|
||||
"parse-path": "^4.0.4",
|
||||
"parse-path": "^4.0.0",
|
||||
"protocols": "^1.4.0"
|
||||
}
|
||||
},
|
||||
@@ -26809,9 +26799,8 @@
|
||||
"dev": true
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
|
||||
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
|
||||
"version": "6.10.1",
|
||||
"integrity": "sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"side-channel": "^1.0.4"
|
||||
@@ -26819,7 +26808,6 @@
|
||||
},
|
||||
"query-string": {
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz",
|
||||
"integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
@@ -27962,7 +27950,6 @@
|
||||
},
|
||||
"split-on-first": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz",
|
||||
"integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==",
|
||||
"dev": true
|
||||
},
|
||||
@@ -28118,8 +28105,7 @@
|
||||
},
|
||||
"strict-uri-encode": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
|
||||
"integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==",
|
||||
"integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=",
|
||||
"dev": true
|
||||
},
|
||||
"string_decoder": {
|
||||
@@ -29439,7 +29425,7 @@
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"ripple-address-codec": "^4.2.4",
|
||||
"ripple-binary-codec": "^1.4.2",
|
||||
"ripple-binary-codec": "^1.4.1",
|
||||
"ripple-keypairs": "^1.1.4",
|
||||
"ws": "^8.2.2",
|
||||
"xrpl-local": "file:src"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# ripple-binary-codec Release History
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 1.4.2 (2022-06-27)
|
||||
- Fixed standard currency codes with lowercase and allowed symbols not decoding into standard codes.
|
||||
|
||||
## 1.4.1 (2022-06-02)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ripple-binary-codec",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.1",
|
||||
"description": "XRP Ledger binary codec",
|
||||
"files": [
|
||||
"dist/*",
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xrpl-announce) for release announcements. We recommend that xrpl.js (ripple-lib) users stay up-to-date with the latest stable release.
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 2.3.1 (2022-06-27)
|
||||
### Fixed
|
||||
* Signing tx with standard currency codes with lowercase and allowed symbols causing an error on decode.
|
||||
|
||||
### Added
|
||||
* Add ExpandedSignerList amendment support
|
||||
* When connected to nft-devnet, Client.fundWallet now defaults to using the nft-devnet faucet instead of requiring specification.
|
||||
|
||||
## 2.3.0 (2022-06-02)
|
||||
|
||||
2
packages/xrpl/package-lock.json
generated
2
packages/xrpl/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xrpl",
|
||||
"version": "2.3.1",
|
||||
"version": "2.3.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xrpl",
|
||||
"version": "2.3.1",
|
||||
"version": "2.3.0",
|
||||
"license": "ISC",
|
||||
"description": "A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser",
|
||||
"files": [
|
||||
@@ -27,7 +27,7 @@
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"ripple-address-codec": "^4.2.4",
|
||||
"ripple-binary-codec": "^1.4.2",
|
||||
"ripple-binary-codec": "^1.4.1",
|
||||
"ripple-keypairs": "^1.1.4",
|
||||
"ws": "^8.2.2"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable max-lines -- There are lots of equivalent constructors which make sense to have here. */
|
||||
import BigNumber from 'bignumber.js'
|
||||
import { fromSeed } from 'bip32'
|
||||
import { mnemonicToSeedSync, validateMnemonic } from 'bip39'
|
||||
import { mnemonicToSeedSync } from 'bip39'
|
||||
import _ from 'lodash'
|
||||
import {
|
||||
classicAddressToXAddress,
|
||||
@@ -229,12 +229,6 @@ class Wallet {
|
||||
})
|
||||
}
|
||||
// Otherwise decode using bip39's mnemonic standard
|
||||
if (!validateMnemonic(mnemonic)) {
|
||||
throw new ValidationError(
|
||||
'Unable to parse the given mnemonic using bip39 encoding',
|
||||
)
|
||||
}
|
||||
|
||||
const seed = mnemonicToSeedSync(mnemonic)
|
||||
const masterNode = fromSeed(seed)
|
||||
const node = masterNode.derivePath(
|
||||
|
||||
@@ -136,13 +136,7 @@ function getSubKey(
|
||||
const ch = [0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
let word = ''
|
||||
for (word of sublist) {
|
||||
const idx = rfc1751WordList.indexOf(word.toUpperCase())
|
||||
if (idx === -1) {
|
||||
throw new TypeError(
|
||||
`Expected an RFC1751 word, but received '${word}'. ` +
|
||||
`For the full list of words in the RFC1751 encoding see https://datatracker.ietf.org/doc/html/rfc1751`,
|
||||
)
|
||||
}
|
||||
const idx = rfc1751WordList.indexOf(word)
|
||||
const shift = (8 - ((bits + 11) % 8)) % 8
|
||||
const y = idx << shift
|
||||
const cl = y >> 16
|
||||
@@ -177,14 +171,10 @@ function bufferToArray(buf: Buffer): number[] {
|
||||
* @returns A buffer containing the same data with reversed endianness
|
||||
*/
|
||||
function swap128(buf: Buffer): Buffer {
|
||||
// Interprets buffer as an array of (two, in this case) 64-bit numbers and swaps byte order in-place.
|
||||
const reversedBytes = buf.swap64()
|
||||
|
||||
// Swap the two 64-bit numbers since our buffer is 128 bits.
|
||||
return Buffer.concat(
|
||||
[reversedBytes.slice(8, 16), reversedBytes.slice(0, 8)],
|
||||
16,
|
||||
)
|
||||
const result = Buffer.alloc(16)
|
||||
result.writeBigUInt64LE(buf.readBigUInt64BE(0), 8)
|
||||
result.writeBigUInt64LE(buf.readBigUInt64BE(8), 0)
|
||||
return result
|
||||
}
|
||||
|
||||
export { rfc1751MnemonicToKey, keyToRFC1751Mnemonic }
|
||||
|
||||
@@ -61,10 +61,31 @@ interface PathStep {
|
||||
|
||||
export type Path = PathStep[]
|
||||
|
||||
/**
|
||||
* The object that describes the signer in SignerEntries.
|
||||
*/
|
||||
export interface SignerEntry {
|
||||
/**
|
||||
* The object that describes the signer in SignerEntries.
|
||||
*/
|
||||
SignerEntry: {
|
||||
/**
|
||||
* An XRP Ledger address whose signature contributes to the multi-signature.
|
||||
* It does not need to be a funded address in the ledger.
|
||||
*/
|
||||
Account: string
|
||||
/**
|
||||
* The weight of a signature from this signer.
|
||||
* A multi-signature is only valid if the sum weight of the signatures provided meets
|
||||
* or exceeds the signer list's SignerQuorum value.
|
||||
*/
|
||||
SignerWeight: number
|
||||
/**
|
||||
* An arbitrary 256-bit (32-byte) field that can be used to identify the signer, which
|
||||
* may be useful for smart contracts, or for identifying who controls a key in a large
|
||||
* organization.
|
||||
*/
|
||||
WalletLocator?: string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,13 +20,15 @@ export interface SignerListSet extends BaseTransaction {
|
||||
/**
|
||||
* Array of SignerEntry objects, indicating the addresses and weights of
|
||||
* signers in this list. This signer list must have at least 1 member and no
|
||||
* more than 8 members. No address may appear more than once in the list, nor
|
||||
* more than 32 members. No address may appear more than once in the list, nor
|
||||
* may the Account submitting the transaction appear in the list.
|
||||
*/
|
||||
SignerEntries: SignerEntry[]
|
||||
}
|
||||
|
||||
const MAX_SIGNERS = 8
|
||||
const MAX_SIGNERS = 32
|
||||
|
||||
const HEX_WALLET_LOCATOR_REGEX = /^[0-9A-Fa-f]{64}$/u
|
||||
|
||||
/**
|
||||
* Verify the form and type of an SignerListSet at runtime.
|
||||
@@ -61,7 +63,21 @@ export function validateSignerListSet(tx: Record<string, unknown>): void {
|
||||
|
||||
if (tx.SignerEntries.length > MAX_SIGNERS) {
|
||||
throw new ValidationError(
|
||||
'SignerListSet: maximum of 8 members allowed in SignerEntries',
|
||||
`SignerListSet: maximum of ${MAX_SIGNERS} members allowed in SignerEntries`,
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.SignerEntries.length > 0) {
|
||||
for (const entry of tx.SignerEntries) {
|
||||
const signerEntry = entry.SignerEntry
|
||||
if (
|
||||
signerEntry.WalletLocator !== undefined &&
|
||||
!HEX_WALLET_LOCATOR_REGEX.test(signerEntry.WalletLocator)
|
||||
) {
|
||||
throw new ValidationError(
|
||||
`SignerListSet: WalletLocator in SignerEntry must be a 256-bit (32-byte) hexadecimal value`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,127 @@ describe('SignerListSet', function () {
|
||||
'SignerListSet: invalid SignerEntries',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ maximum of 32 members allowed in SignerEntries`, function () {
|
||||
signerListSetTx.SignerEntries = []
|
||||
const accounts = [
|
||||
'rBFBipte4nAQCTsRxd2czwvSurhCpAf4X6',
|
||||
'r3ijUH32iiy9tYNj3rD7hKWYjy1BFUxngm',
|
||||
'rpwq8vi4Mn3L5kDJmb8Mg59CanPFPzMCnj',
|
||||
'rB72Gzqfejai46nkA4HaKYBHwAnn2yUoT4',
|
||||
'rGqsJSAW71pCfUwDD5m52bLw69RzFg6kMW',
|
||||
'rs8smPRA31Ym4mGxb1wzgwxtU5eVK82Gyk',
|
||||
'rLrugpGxzezUQLDh7Jv1tZpouuV4MQLbU9',
|
||||
'rUQ6zLXQdh1jJLGwMXp9P8rgi42kwuafzs',
|
||||
'rMjY8sPdfxsyRrnVKQcutxr4mTHNXy9dEF',
|
||||
'rUaxYLeFGm6SmMoa2WCqLKSyHwJyvaQmeG',
|
||||
'r9wUfeVtqMfqrcDTfCpNYbNZvs5q9M9Rpo',
|
||||
'rQncVNak5kvJGPUFa6fuKH7t8Usjs7Np1c',
|
||||
'rnwbSSnPbVbUzuBa4etkeYrfy5v7SyhtPu',
|
||||
'rDXh5D3t48MdBJyXByXq47k5P8Kuf1758B',
|
||||
'rh1D4jd2mAiqUPHfAZ2cY9Nbfa3kAkaQXP',
|
||||
'r9T129tXgtnyfGoLeS35c2HctaZAZSQoCH',
|
||||
'rUd2uKsyCWfJP7Ve36mKoJbNCA7RYThnYk',
|
||||
'r326x8PaAFtnaH7uoxaKrcDWuwpeHn4wDa',
|
||||
'rpN3mkXkYhfNadcXPrY4LniM1KpM3egyQM',
|
||||
'rsPKbR155hz1zrA4pSJp5Y2fxasZAatcHb',
|
||||
'rsyWFLaEKTpaoSJusjpcDvGexuHCwMnqss',
|
||||
'rUbc5RXfyF81oLDMgd3d7jpY9YMNMZG4XN',
|
||||
'rGpYHM88BZe1iVKFHm5xiWYYxR74oxJEXf',
|
||||
'rPsetWAtR1KxDtxzgHjRMD7Rc87rvXk5nD',
|
||||
'rwSeNhL6Hi34igr12mCr61jY42psfTkWTq',
|
||||
'r46Mygy98qjkDhVB6qs4sBnqaf7FPiA2vU',
|
||||
'r4s8GmeYN4CiwVate1nMUvwMQbundqf5cW',
|
||||
'rKAr4dQWDYG8cG2hSwJUVp4ry4WNaWiNgp',
|
||||
'rPWXRLp1vqeUHEH3WiSKuyo9GM9XhaENQU',
|
||||
'rPgmdBdRKGmndxNEYxUrrsYCZaS6go9RvW',
|
||||
'rPDJZ9irzgwKRKScfEmuJMvUgrqZAJNCbL',
|
||||
'rDuU2uSXMfEaoxN1qW8sj7aUNFLGEn3Hr2',
|
||||
'rsbjSjA4TCB9gtm7x7SrWbZHB6g4tt9CGU',
|
||||
]
|
||||
signerListSetTx.SignerQuorum = accounts.length
|
||||
for (const acc of accounts) {
|
||||
signerListSetTx.SignerEntries.push({
|
||||
SignerEntry: {
|
||||
Account: acc,
|
||||
SignerWeight: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const errorMessage =
|
||||
'SignerListSet: maximum of 32 members allowed in SignerEntries'
|
||||
assert.throws(
|
||||
() => validateSignerListSet(signerListSetTx),
|
||||
ValidationError,
|
||||
errorMessage,
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(signerListSetTx),
|
||||
ValidationError,
|
||||
errorMessage,
|
||||
)
|
||||
})
|
||||
|
||||
it(`verifies valid WalletLocator in SignerEntries`, function () {
|
||||
signerListSetTx.SignerQuorum = 3
|
||||
signerListSetTx.SignerEntries = [
|
||||
{
|
||||
SignerEntry: {
|
||||
Account: 'rBFBipte4nAQCTsRxd2czwvSurhCpAf4X6',
|
||||
SignerWeight: 1,
|
||||
WalletLocator:
|
||||
'CAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE',
|
||||
},
|
||||
},
|
||||
{
|
||||
SignerEntry: {
|
||||
Account: 'r3ijUH32iiy9tYNj3rD7hKWYjy1BFUxngm',
|
||||
SignerWeight: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
SignerEntry: {
|
||||
Account: 'rpwq8vi4Mn3L5kDJmb8Mg59CanPFPzMCnj',
|
||||
SignerWeight: 1,
|
||||
WalletLocator:
|
||||
'00000000000000000000000000000000000000000000000000000000DEADBEEF',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
assert.doesNotThrow(() => validateSignerListSet(signerListSetTx))
|
||||
assert.doesNotThrow(() => validate(signerListSetTx))
|
||||
})
|
||||
|
||||
it(`throws w/ invalid WalletLocator in SignerEntries`, function () {
|
||||
signerListSetTx.SignerQuorum = 2
|
||||
signerListSetTx.SignerEntries = [
|
||||
{
|
||||
SignerEntry: {
|
||||
Account: 'rBFBipte4nAQCTsRxd2czwvSurhCpAf4X6',
|
||||
SignerWeight: 1,
|
||||
WalletLocator: 'not_valid',
|
||||
},
|
||||
},
|
||||
{
|
||||
SignerEntry: {
|
||||
Account: 'r3ijUH32iiy9tYNj3rD7hKWYjy1BFUxngm',
|
||||
SignerWeight: 1,
|
||||
},
|
||||
},
|
||||
]
|
||||
const errorMessage =
|
||||
'SignerListSet: WalletLocator in SignerEntry must be a 256-bit (32-byte) hexadecimal value'
|
||||
assert.throws(
|
||||
() => validateSignerListSet(signerListSetTx),
|
||||
ValidationError,
|
||||
errorMessage,
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(signerListSetTx),
|
||||
ValidationError,
|
||||
errorMessage,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -143,41 +143,6 @@ describe('Wallet', function () {
|
||||
assert.equal(wallet.seed, expectedSeed)
|
||||
})
|
||||
|
||||
it('throws an error when using an RFC1751 mnemonic for bip39', function () {
|
||||
const algorithm = ECDSA.ed25519
|
||||
const mnemonic =
|
||||
'CAB BETH HANK BIRD MEND SIGN GILD ANY KERN HYDE CHAT STUB'
|
||||
assert.throws(() => {
|
||||
Wallet.fromMnemonic(mnemonic, {
|
||||
mnemonicEncoding: 'bip39',
|
||||
algorithm,
|
||||
})
|
||||
}, /^Unable to parse the given mnemonic using bip39 encoding$/u)
|
||||
})
|
||||
|
||||
it('throws an error when using an bip39 mnemonic for RFC1751', function () {
|
||||
const mnemonic =
|
||||
'draw attack antique swing base employ blur above palace lucky glide clap pen use illegal'
|
||||
assert.throws(() => {
|
||||
Wallet.fromMnemonic(mnemonic, {
|
||||
mnemonicEncoding: 'rfc1751',
|
||||
})
|
||||
}, /^Expected an RFC1751 word, but received 'attack'\. For the full list of words in the RFC1751 encoding see https:\/\/datatracker\.ietf\.org\/doc\/html\/rfc1/u)
|
||||
})
|
||||
|
||||
it('derives a wallet using rfc1751 mnemonic with lowercase words', function () {
|
||||
const algorithm = ECDSA.ed25519
|
||||
const mnemonic =
|
||||
'cab beth hank bird mend sign gild any kern hyde chat stub'
|
||||
const expectedSeed = 'sEdVaw4m9W3H3ou3VnyvDwvPAP5BEz1'
|
||||
const wallet = Wallet.fromMnemonic(mnemonic, {
|
||||
mnemonicEncoding: 'rfc1751',
|
||||
algorithm,
|
||||
})
|
||||
|
||||
assert.equal(wallet.seed, expectedSeed)
|
||||
})
|
||||
|
||||
it('derives a wallet using a Regular Key Pair', function () {
|
||||
const masterAddress = 'rUAi7pipxGpYfPNg3LtPcf2ApiS8aw9A93'
|
||||
const regularKeyPair = {
|
||||
@@ -246,11 +211,11 @@ describe('Wallet', function () {
|
||||
|
||||
describe('fromMnemonic', function () {
|
||||
const mnemonic =
|
||||
'assault rare scout seed design extend noble drink talk control guitar quote'
|
||||
'try milk link drift aware pass obtain again music stick pluck fold'
|
||||
const publicKey =
|
||||
'035953FCD81D001CF634EB44A87940F3F98ADF2483D09C914BAED0539BE50F385D'
|
||||
'0257B550BA2FDCCF0ADDA3DEB2A5411700F3ADFDCC7C68E1DCD1E2B63E6B0C63E6'
|
||||
const privateKey =
|
||||
'0013FC461CA5799F1357C8130AF703CBA7E9C28E072C6CA8F7DEF8601CDE98F394'
|
||||
'008F942B6E229C0E9CEE47E7A94253DABB6A9855F4BA2D8A741FA31851A1D423C3'
|
||||
|
||||
it('derives a wallet using default derivation path', function () {
|
||||
const wallet = Wallet.fromMnemonic(mnemonic)
|
||||
@@ -270,16 +235,15 @@ describe('Wallet', function () {
|
||||
it('derives a wallet using a Regular Key Pair', function () {
|
||||
const masterAddress = 'rUAi7pipxGpYfPNg3LtPcf2ApiS8aw9A93'
|
||||
const regularKeyPair = {
|
||||
mnemonic: 'I IRE BOND BOW TRIO LAID SEAT GOAL HEN IBIS IBIS DARE',
|
||||
mnemonic: 'KNEW BENT LYNN LED GAD BEN KENT SHAM HOBO RINK WALT ALLY',
|
||||
publicKey:
|
||||
'0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020',
|
||||
'02FBC77338A52D9733641437A77369ACB0D89D52642740A008509F7A3A7450C841',
|
||||
privateKey:
|
||||
'001ACAAEDECE405B2A958212629E16F2EB46B153EEE94CDD350FDEFF52795525B7',
|
||||
'007A10DF756751129060DD29C9BB6733ADB92507B7DD83BB0795CAA09FB815BE22',
|
||||
}
|
||||
|
||||
const wallet = Wallet.fromMnemonic(regularKeyPair.mnemonic, {
|
||||
masterAddress,
|
||||
mnemonicEncoding: 'rfc1751',
|
||||
})
|
||||
|
||||
assert.equal(wallet.publicKey, regularKeyPair.publicKey)
|
||||
@@ -289,7 +253,7 @@ describe('Wallet', function () {
|
||||
})
|
||||
|
||||
describe('fromEntropy', function () {
|
||||
let entropy: number[]
|
||||
let entropy
|
||||
const publicKey =
|
||||
'0390A196799EE412284A5D80BF78C3E84CBB80E1437A0AECD9ADF94D7FEAAFA284'
|
||||
const privateKey =
|
||||
|
||||
Reference in New Issue
Block a user