Compare commits

...

16 Commits

Author SHA1 Message Date
Denis Angell
09533116ce add checkId ledger hash 2023-04-23 15:08:36 -04:00
dependabot[bot]
b86f736cab build(deps-dev): bump expect from 29.4.3 to 29.5.0 (#2248) 2023-04-21 21:35:26 +00:00
dependabot[bot]
7a89f8c63e build(deps): bump buffer from 5.6.0 to 6.0.3 (#2249) 2023-04-21 21:11:28 +00:00
Caleb Kniffen
4ffc51ad54 docs: detail how to reference on a cdn (#2271) 2023-04-12 18:57:48 -05:00
Mayukha Vadari
d2224e9cfb remove: remove old sidechain design features (#2060)
* remove federator_info RPC

* remove util

* update history

* fix merge issues
2023-04-11 15:03:13 -04:00
Florian
70745f4c94 Update the applications.md file (#2269) 2023-04-10 11:37:19 -05:00
Jackson Mills
c5433c6ac0 Update docker to use xrpllabs image (#2223)
Added additional documentation and config.
2023-04-06 11:11:46 -07:00
Mayukha Vadari
be2aa32542 fix: don't run ripple-binary-codec tests on install (#2260)
fix rbc scripts
2023-04-06 13:03:23 -04:00
dependabot[bot]
18e777b093 build(deps-dev): bump jest-mock from 29.4.2 to 29.4.3 (#2233) 2023-04-03 14:25:07 +00:00
Caleb Kniffen
62a39c69ce chore: bump codeql-analysis (#2246) 2023-03-27 18:32:54 -04:00
dependabot[bot]
dfd2fc1ba1 build(deps-dev): bump webpack from 5.75.0 to 5.76.0 (#2241)
Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to 5.76.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.75.0...v5.76.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-24 16:42:34 -04:00
dependabot[bot]
41563d1529 build(deps-dev): bump expect from 29.4.2 to 29.4.3 (#2230) 2023-03-23 14:13:53 +00:00
Elliot Lee
d57233fc49 CONTRIBUTING: update release checklist (#2238)
---------

Co-authored-by: Jackson Mills <jmills@ripple.com>
2023-03-22 17:07:19 -07:00
tequ
bbbdf06e91 add destination_account field to PathOption(path_find method) (#2160)
* add destination_account field to PathOption(path_find method)

* fix field name

* Fix grammar in comment

* Fix sentence with missing end

* Add HISTORY.md

---------

Co-authored-by: Jackson Mills <jmills@ripple.com>
2023-03-22 17:42:46 -04:00
Jackson Mills
0c6ea2afe2 feat: modifiable definitions.json values at runtime via encode/decode parameter (#2127) 2023-03-16 10:35:50 -07:00
Alexey Novikov
97ff2aa104 Issue 2212. Improve NFToken.URI handling for empty and undefined values (#2218)
* Handle undefined and null values in transactions better.
2023-03-09 13:34:28 -08:00
47 changed files with 1443 additions and 701 deletions

151
.ci-config/rippled.cfg Normal file
View File

@@ -0,0 +1,151 @@
[server]
port_rpc_admin_local
port_ws_public
port_ws_admin_local
# port_peer
# port_ws_admin_local
# ssl_key = /etc/ssl/private/server.key
# ssl_cert = /etc/ssl/certs/server.crt
# IPs must be 0.0.0.0 instead of 127.0.0.1 to be accessed outside the docker container
[port_rpc_admin_local]
port = 5005
ip = 0.0.0.0
admin = 0.0.0.0
protocol = http
[port_ws_public]
port = 80
ip = 0.0.0.0
protocol = ws
# [port_peer]
# port = 51235
# ip = 0.0.0.0
# protocol = peer
[port_ws_admin_local]
port = 6006
ip = 0.0.0.0
admin = 0.0.0.0
protocol = ws
[node_size]
small
# tiny
# small
# medium
# large
# huge
[node_db]
type=NuDB
path=/var/lib/rippled/db/nudb
advisory_delete=0
# How many ledgers do we want to keep (history)?
# Integer value that defines the number of ledgers
# between online deletion events
online_delete=256
[ledger_history]
# How many ledgers do we want to keep (history)?
# Integer value (ledger count)
# or (if you have lots of TB SSD storage): 'full'
256
[database_path]
/var/lib/rippled/db
[debug_logfile]
/var/log/rippled/debug.log
[sntp_servers]
time.windows.com
time.apple.com
time.nist.gov
pool.ntp.org
[ips]
r.ripple.com 51235
[validators_file]
validators.txt
[rpc_startup]
{ "command": "log_level", "severity": "info" }
# severity (order: lots of information .. only errors)
# debug
# info
# warn
# error
# fatal
[ssl_verify]
1
# The [features] stanza does not currently work for standalone mode: https://github.com/XRPLF/xrpl-dev-portal/issues/1762#issuecomment-1441252450
# In order to enable an amendment which by default would vote "No", you must include its amendment id and name here.
# To get the list of amendments on a network:
# 1. Run this ledger_entry command against the network to get a list of enabled amendment ids. (Command is in the websocket link as an easy way to run it)
# https://xrpl.org/websocket-api-tool.html?server=wss%3A%2F%2Fs1.ripple.com%2F&req=%7B%22command%22%3A%22ledger_entry%22%2C%22index%22%3A%227DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4%22%2C%22ledger_index%22%3A%22validated%22%7D
# 2. Strip away the quotes and commas
# 3. Add the amendment name to the same line as each amendment id (You can look them up via hash on https://xrpl.org/known-amendments.html)
# Ex. 4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373 Multisign
# The amendment name can be any string (including just a number)
#
# Note: The version of rippled you use this config with must have an implementation for the amendments you attempt to enable or it will crash.
[amendments]
# Devnet amendments as of March 28th, 2023
B4E4F5D2D6FB84DF7399960A732309C9FD530EAE5941838160042833625A6076 NegativeUNL
DF8B4536989BDACE3F934F29423848B9F1D76D09BE6A1FCFE7E7F06AA26ABEAD fixRemoveNFTokenAutoTrustLine
3C43D9A973AA4443EF3FC38E42DD306160FBFFDAB901CD8BAA15D09F2597EB87 NonFungibleTokensV1
98DECF327BF79997AEC178323AD51A830E457BFC6D454DAF3E46E5EC42DC619F CheckCashMakesTrustLine
B6B3EEDC0267AB50491FDC450A398AF30DBCD977CECED8BEF2499CAB5DAC19E2 fixRmSmallIncreasedQOffers
452F5906C46D46F407883344BFDD90E672B672C5E9943DB4891E3A34FEEEB9DB fixSTAmountCanonicalize
AF8DF7465C338AE64B1E937D6C8DA138C0D63AD5134A68792BBBE1F63356C422 FlowSortStrands
955DF3FA5891195A9DAEFA1DDC6BB244B545DDE1BAA84CBB25D5F12A8DA68A0C TicketBatch
B4D44CC3111ADD964E846FC57760C8B50FFCD5A82C86A72756F6B058DDDF96AD fix1201
89308AF3B8B10B7192C4E613E1D2E4D9BA64B2EE2D5232402AE82A6A7220D953 fixQualityUpperBound
3012E8230864E95A58C60FD61430D7E1B4D3353195F2981DC12B0C7C0950FFAC FlowCross
DC9CA96AEA1DCF83E527D1AFC916EFAF5D27388ECA4060A88817C1238CAEE0BF EnforceInvariants
B9E739B8296B4A1BB29BE990B17D66E21B62A300A909F25AC55C22D6C72E1F9D fix1523
1F4AFA8FA1BC8827AD4C0F682C03A8B671DCDF6B5C4DE36D44243A684103EF88 HardenedValidations
3CBC5C4E630A1B82380295CDA84B32B49DD066602E74E39B85EF64137FA65194 DepositPreauth
586480873651E106F1D6339B0C4A8945BA705A777F3F4524626FF1FC07EFE41D MultiSignReserve
58BE9B5968C4DA7C59BA900961828B113E5490699B21877DEF9A31E9D0FE5D5F fix1623
42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE FeeEscalation
08DE7D96082187F6E6578530258C77FAABABE4C20474BDB82F04B021F1A68647 PayChan
67A34F2CF55BFC0F93AACD5B281413176FEE195269FA6D95219A2DF738671172 fix1513
00C1FC4A53E60AB02C864641002B3172F38677E29C26C5406685179B37E1EDAC RequireFullyCanonicalSig
CA7C02118BA27599528543DFE77BA6838D1B0F43B447D4D7F53523CE6A0E9AC2 fix1543
532651B4FD58DF8922A49BA101AB3E996E5BFBF95A913B3E392504863E63B164 TickSize
25BA44241B3BD880770BFA4DA21C7180576831855368CBEC6A3154FDE4A7676E fix1781
8F81B066ED20DAECA20DF57187767685EEF3980B228E0667A650BAF24426D3B4 fixCheckThreading
5D08145F0A4983F23AFFFF514E83FAD355C5ABFBB6CAB76FB5BC8519FF5F33BE fix1515
1562511F573A19AE9BD103B5D6B9E01B3B46805AEC5D3C4805C902B514399146 CryptoConditions
1D3463A5891F9E589C5AE839FFAC4A917CE96197098A1EF22304E1BC5B98A454 fix1528
621A0B264970359869E3C0363A899909AAB7A887C8B73519E4ECF952D33258A8 fixPayChanRecipientOwnerDir
CC5ABAE4F3EC92E94A59B1908C2BE82D2228B6485C00AFF8F22DF930D89C194E SortedDirectories
FBD513F1B893AC765B78F250E6FFA6A11B573209D1842ADC787C850696741288 fix1578
7117E2EC2DBF119CA55181D69819F1999ECEE1A0225A7FD2B9ED47940968479C fix1571
4F46DF03559967AC60F2EB272FEFE3928A7594A45FF774B87A7E540DB0F8F068 fixAmendmentMajorityCalc
2CD5286D8D687E98B41102BDD797198E81EA41DF7BD104E6561FEB104EFF2561 fixTakerDryOfferRemoval
C4483A1896170C66C098DEA5B0E024309C60DC960DE5F01CD7AF986AA3D9AD37 fixMasterKeyAsRegularKey
740352F2412A9909880C23A559FCECEDA3BE2126FED62FC7660D628A06927F11 Flow
07D43DCE529B15A10827E5E04943B496762F9A88E3268269D69C44BE49E21104 Escrow
6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC TrustSetAuth
30CD365592B8EE40489BA01AE2F7555CAC9C983145871DC82A42A31CF5BAE7D9 DeletableAccounts
F64E1EABBE79D55B3BB82020516CEC2C582A98A6BFE20FBE9BB6A0D233418064 DepositAuth
E2E6F2866106419B88C50045ACE96368558C345566AC8F2BDF5A5B5587F0E6FA fix1368
6C92211186613F9647A89DFFBAB8F94C99D4C7E956D495270789128569177DA1 fix1512
42EEA5E28A97824821D4EF97081FE36A54E9593C6E4F20CBAE098C69D2E072DC fix1373
4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373 MultiSign
157D2D480E006395B76F948E3E07A45A05FE10230D88A7993C71F97AE4B1F2D1 Checks

View File

@@ -39,7 +39,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -50,7 +50,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -64,4 +64,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

View File

@@ -100,15 +100,13 @@ jobs:
matrix:
node-version: [14.x, 16.x, 18.x]
services:
rippled:
image: natenichols/rippled-standalone:latest
ports:
- 6006:6006
options: --health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s
steps:
- uses: actions/checkout@v3
- name: Run docker in background
run: |
docker run --detach --rm --name rippled-service -p 6006:6006 --volume "${{ github.workspace }}/.ci-config/":"/config/" --health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env "ENV_ARGS=-a --start" --env GITHUB_ACTIONS=true --env CI=true xrpllabsofficial/xrpld:latest
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
@@ -138,10 +136,13 @@ jobs:
run: npm ci
- run: npm run build
- run: npm run test:integration
env:
HOST: localhost
PORT: ${{ job.services.rippled.ports['6006'] }}
- name: Run integration test
run: npm run test:integration
- name: Stop docker container
if: always()
run: docker stop rippled-service
browser:
runs-on: ubuntu-latest
@@ -151,20 +152,18 @@ jobs:
matrix:
node-version: [14.x] # This just needs to be compatible w/ puppeteer
services:
rippled:
image: natenichols/rippled-standalone:latest
ports:
- 6006:6006
options: --health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Run docker in background
run: |
docker run --detach --rm --name rippled-service -p 6006:6006 --volume "${{ github.workspace }}/.ci-config/":"/config/" --health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env "ENV_ARGS=-a --start" --env GITHUB_ACTIONS=true --env CI=true xrpllabsofficial/xrpld:latest
- name: Setup npm version 7
run: |
npm i -g npm@7 --registry=https://registry.npmjs.org
@@ -189,4 +188,10 @@ jobs:
run: npm ci
- run: npm run build
- run: npm run test:browser
- name: Run integration test
run: npm run test:browser
- name: Stop docker container
if: always()
run: docker stop rippled-service

2
.gitignore vendored
View File

@@ -39,8 +39,6 @@ db/*.db
db/*.db-*
# Ignore customized configs
rippled.cfg
validators.txt
test/config.js
# Ignore coverage files

View File

@@ -74,6 +74,10 @@ Warning: Use at your own risk.
## Wallets and wallet tools
- **[GemWallet](https://gemwallet.app/)**
Users can use the GemWallet (non-custodial) web extension to interact with the XRPL from their browser. The documentation is available at [https://gemwallet.app/](https://gemwallet.app/docs/user-guide/introduction).
- **[XUMM](https://xumm.app/)**
Users can use the xumm application to track their accounts, balances and transactions. The true power of xumm is the platform available for developers.
@@ -109,7 +113,7 @@ Warning: Use at your own risk.
- **[XRP Account Mnemonic Recovery](https://github.com/WietseWind/xrp-mnemonic-recovery)** (uses `ripple-keypairs`)
Recover a 24 word mnemonic if one word is wrong or one word is missing.
- **[Trustline](https://trustline.co)**
A decentralized stablecoin wallet that runs on the XRP Ledger.

View File

@@ -47,7 +47,7 @@ npm run lint
## Running Tests
For integration and browser tests, we use a `rippled` node in standalone mode to test xrpl.js code against. To set this up, you can either run `rippled` locally, or set up the Docker container `natenichols/rippled-standalone:latest` for this purpose. The latter will require you to [install Docker](https://docs.docker.com/get-docker/).
For integration and browser tests, we use a `rippled` node in standalone mode to test xrpl.js code against. To set this up, you can either configure and run `rippled` locally, or set up the Docker container `xrpllabsofficial/xrpld:latest` by [following these instructions](#integration-tests). The latter will require you to [install Docker](https://docs.docker.com/get-docker/).
### Unit Tests
@@ -59,14 +59,25 @@ npm test
### Integration Tests
From the top-level xrpl.js folder (one level above `packages`), run the following commands:
```bash
npm install
# sets up the rippled standalone Docker container - you can skip this step if you already have it set up
docker run -p 6006:6006 -it natenichols/rippled-standalone:latest
docker run -p 6006:6006 --interactive -t --volume $PWD/.ci-config:/config/ xrpllabsofficial/xrpld:latest -a --start
npm run build
npm run test:integration
```
Breaking down the command:
* `docker run -p 6006:6006` starts a Docker container with an open port for admin WebSocket requests.
* `--interactive` allows you to interact with the container.
* `-t` starts a terminal in the container for you to send commands to.
* `--volume $PWD/.ci-config:/config/` identifies the `rippled.cfg` and `validators.txt` to import. It must be an absolute path, so we use `$PWD` instead of `./`.
* `xrpllabsofficial/xrpld:latest` is an image that is regularly updated with the latest `rippled` releases and can be found here: https://github.com/WietseWind/docker-rippled
* `-a` starts `rippled` in standalone mode
* `--start` signals to start `rippled` with the specified amendments in `rippled.cfg` enabled immediately instead of voting for 2 weeks on them.
### Browser Tests
There are two ways to run browser tests.
@@ -75,10 +86,12 @@ One is in the browser - run `npm run build:browserTests` and open `test/localInt
The other is in the command line (this is what we use for CI) -
This should be run from the `xrpl.js` top level folder (one above the `packages` folder).
```bash
npm run build
# sets up the rippled standalone Docker container - you can skip this step if you already have it set up
docker run -p 6006:6006 -it natenichols/rippled-standalone:latest
docker run -p 6006:6006 -it -v $PWD/.ci-config:/config/ xrpllabsofficial/xrpld:latest -a --start
npm run test:browser
```
@@ -169,48 +182,86 @@ npm install abbrev -w ripple-keypairs
npm uninstall abbrev -w xrpl
```
## Release process
## Release process + checklist
### Release
## PR process
1. Ensure that all tests passed on the last CI that ran on `main`.
- [ ] Your changes should be on a branch.
- [ ] Your changes should have unit tests.
- [ ] Lint the code with `npm lint`
- [ ] Build your code with `npm build`
- [ ] Run the unit tests with `npm test`
- [ ] Get a full code review.
- [ ] Merge your branch into `main` and push to github.
- [ ] Ensure that all tests passed on the last CI that ran on `main`.
NOW WE ARE READY TO PUBLISH! No new code changes happen manually now.
## Release
2. Checkout `main` (or your beta branch) and `git pull`.
3. Create a new branch (`git checkout -b <BRANCH_NAME>`) to capture updates that take place during this process.
4. Update `HISTORY.md` to reflect release changes.
5. Run `npm run docgen` if the docs were modified in this release to update them (skip this step for a beta).
6. Run `npm run build` to triple check the build still works
7. Run `npx lerna version --no-git-tag-version` - This creates a draft PR and bumps the versions of the packages.
* For each changed package, pick what the new version should be. Lerna will bump the versions, commit version bumps to `main`, and create a new git tag for each published package.
* If publishing a beta, make sure that the versions are all of the form `a.b.c-beta.d`, where `a`, `b`, and `c` are identical to the last normal release except for one, which has been incremented by 1.
8. Run `npm i` to update the package-lock with the updated versions
9. Create a new PR from this branch into `main` and merge it (you can directly merge into the beta branch for a beta).
10. Checkout `main` and `git pull` (you can skip this step for a beta since you already have the latest version of the beta branch).
11. Run `npx lerna publish from-package --yes` - This will actually publish the packages.
* NOTE: if you're releasing a beta, run `npx lerna publish from-package --dist-tag beta --yes` instead.
* If it asks for it, enter your [npmjs.com](https://npmjs.com) OTP (one-time password) to complete publication.
12. Create a new branch (`git checkout -b <BRANCH_NAME>`)to capture the updated packages from the release. Merge those changes into `main`. (You can skip this step on a beta release).
1. Checkout `main` (or your beta branch) and `git pull`.
1. Create a new branch (`git checkout -b <BRANCH_NAME>`) to capture updates that take place during this process.
1. Update `HISTORY.md` to reflect release changes.
NOW YOU HAVE PUBLISHED! But you're not done; we have to notify people!
- [ ] Update the version number and release date, and ensure it lists the changes since the previous release.
13. Pull the most recent changes to main locally.
14. Run `git tag <tagname> -m <tagname>`, where `<tagname>` is the new package and version (e.g. `xrpl@2.1.1`), for each version released.
15. Run `git push --follow-tags`, to push the tags to Github.
16. On Github, click the "releases" link on the right-hand side of the page.
17. Click "Draft a new release"
18. Click "Choose a tag", and choose a tag that you just created.
19. Edit the name of the release to match the tag (IE \<package\>@\<version\>) and edit the description as you see fit.
20. Repeat steps 17-19 for each release.
21. Send an email to [xrpl-announce](https://groups.google.com/g/xrpl-announce).
1. Run `npm run docgen` if the docs were modified in this release to update them (skip this step for a beta).
1. Run `npm run build` to triple check the build still works
1. Run `npx lerna version --no-git-tag-version` - This creates a draft PR and bumps the versions of the packages.
- For each changed package, pick what the new version should be. Lerna will bump the versions, commit version bumps to `main`, and create a new git tag for each published package.
- If publishing a beta, make sure that the versions are all of the form `a.b.c-beta.d`, where `a`, `b`, and `c` are identical to the last normal release except for one, which has been incremented by 1.
1. Run `npm i` to update the package-lock with the updated versions.
1. Create a new PR from this branch into `main` and merge it (you can directly merge into the beta branch for a beta).
1. Checkout `main` and `git pull` (you can skip this step for a beta since you already have the latest version of the beta branch).
1. Actually publish the packages with one of the following:
- Stable release: Run `npx lerna publish from-package --yes`
- Beta release: Run `npx lerna publish from-package --dist-tag beta --yes`
Notice this allows developers to install the package with `npm add xrpl@beta`
1. If requested, enter your [npmjs.com](https://npmjs.com) OTP (one-time password) to complete publication.
1. If not a beta release: Create a new branch (`git checkout -b <BRANCH_NAME>`) to capture the updated packages from the release. Merge those changes into `main`.
NOW YOU HAVE PUBLISHED! But you're not done; we have to notify people!
1. Pull the most recent changes to `main` locally.
1. Run `git tag <tagname> -m <tagname>`, where `<tagname>` is the new package and version (e.g. `xrpl@2.1.1`), for each version released.
1. Run `git push --follow-tags`, to push the tags to Github.
1. On GitHub, click the "Releases" link on the right-hand side of the page.
1. Repeat for each release:
1. Click "Draft a new release"
1. Click "Choose a tag", and choose a tag that you just created.
1. Edit the name of the release to match the tag (IE \<package\>@\<version\>) and edit the description as you see fit.
1. Lastly, send an email to [xrpl-announce](https://groups.google.com/g/xrpl-announce).
# ripple-lib 1.x releases
- [ ] Publish the release to npm.
- [ ] If you are publishing a 1.x release to the `xrpl` package, use:
npm publish --tag ripple-lib
This prevents the release from taking the `latest` tag.
For ripple-lib:
- Have one of the ripple-lib package maintainers push to `ripple-lib` (npm package name). You can contact [@intelliot](https://github.com/intelliot) to request the npm publish.
- For ripple-lib releases, cross-publish the package to `xrpl` with `--tag ripple-lib`
- [Here's why](https://blog.greenkeeper.io/one-simple-trick-for-javascript-package-maintainers-to-avoid-breaking-their-user-s-software-and-to-6edf06dc5617).
- https://www.npmjs.com/package/ripple-lib
- https://www.npmjs.com/package/xrpl
## Mailing Lists
We have a low-traffic mailing list for announcements of new `xrpl.js` releases. (About 1 email every couple of weeks)
+ [Subscribe to xrpl-announce](https://groups.google.com/g/xrpl-announce)
- [Subscribe to xrpl-announce](https://groups.google.com/g/xrpl-announce)
If you're using the XRP Ledger in production, you should run a [rippled server](https://github.com/ripple/rippled) and subscribe to the ripple-server mailing list as well.
+ [Subscribe to ripple-server](https://groups.google.com/g/ripple-server)
- [Subscribe to ripple-server](https://groups.google.com/g/ripple-server)

View File

@@ -74,6 +74,7 @@ It goes through:
If you're using xrpl.js with React or Deno, you'll need to do a couple extra steps to set it up:
- [Using xrpl.js with a CDN](./UNIQUE_SETUPS.md#using-xrpljs-from-a-cdn)
- [Using xrpl.js with `create-react-app`](./UNIQUE_SETUPS.md#using-xrpljs-with-create-react-app)
- [Using xrpl.js with `React Native`](./UNIQUE_SETUPS.md#using-xrpljs-with-react-native)
- [Using xrpl.js with `Vite React`](./UNIQUE_SETUPS.md#using-xrpljs-with-vite-react)

View File

@@ -2,6 +2,15 @@
For when you need to do more than just install `xrpl.js` for it to work (especially for React projects in the browser).
### Using xrpl.js from a CDN
You can avoid setting up your build system to handle `xrpl.js` by using a cdn version that is prebuilt for the browser.
- unpkg `<script src="https://unpkg.com/xrpl@2.3.0/build/xrpl-latest-min.js"></script>`
- jsdelivr `<script src="https://cdn.jsdelivr.net/npm/xrpl@2.3.0/build/xrpl-latest-min.js"></script>`
Ensure that the full path is provided so the browser can find the sourcemaps.
### Using xrpl.js with `create-react-app`
To use `xrpl.js` with React, you need to install shims for core NodeJS modules. Starting with version 5, Webpack stopped including shims by default, so you must modify your Webpack configuration to add the shims you need. Either you can eject your config and modify it, or you can use a library such as `react-app-rewired`. The example below uses `react-app-rewired`.

275
package-lock.json generated
View File

@@ -1074,12 +1074,12 @@
}
},
"node_modules/@jest/expect-utils": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.2.tgz",
"integrity": "sha512-Dd3ilDJpBnqa0GiPN7QrudVs0cczMMHtehSo2CSTjm3zdHx0RcpmhFNVEltuEFeqfLIyWKFI224FsMSQ/nsJQA==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.5.0.tgz",
"integrity": "sha512-fmKzsidoXQT2KwnrwE0SQq3uj8Z763vzR8LnLBwC2qYWEFpjX8daRsk6rHUM1QvNlEW/UJXNXm59ztmJJWs2Mg==",
"dev": true,
"dependencies": {
"jest-get-type": "^29.4.2"
"jest-get-type": "^29.4.3"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -1161,9 +1161,9 @@
}
},
"node_modules/@jest/schemas": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.2.tgz",
"integrity": "sha512-ZrGzGfh31NtdVH8tn0mgJw4khQuNHiKqdzJAFbCaERbyCP9tHlxWuL/mnMu8P7e/+k4puWjI1NOzi/sFsjce/g==",
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.3.tgz",
"integrity": "sha512-VLYKXQmtmuEz6IxJsrZwzG9NvtkQsWNnWMsKxqWNu3+CnfzJQhp0WDDKWLVV9hLKr0l3SLLFRqcYHjhtyuDVxg==",
"dev": true,
"dependencies": {
"@sinclair/typebox": "^0.25.16"
@@ -1243,12 +1243,12 @@
}
},
"node_modules/@jest/types": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.2.tgz",
"integrity": "sha512-CKlngyGP0fwlgC1BRUtPZSiWLBhyS9dKwKmyGxk8Z6M82LBEGB2aLQSg+U1MyLsU+M7UjnlLllBM2BLWKVm/Uw==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-29.5.0.tgz",
"integrity": "sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog==",
"dev": true,
"dependencies": {
"@jest/schemas": "^29.4.2",
"@jest/schemas": "^29.4.3",
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-reports": "^3.0.0",
"@types/node": "*",
@@ -2684,9 +2684,9 @@
"dev": true
},
"node_modules/@sinclair/typebox": {
"version": "0.25.21",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.21.tgz",
"integrity": "sha512-gFukHN4t8K4+wVC+ECqeqwzBDeFeTzBXroBTqE6vcWrQGbEUpHO7LYdG0f4xnvYq4VOEwITSlHlp0JBAIFMS/g==",
"version": "0.25.24",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz",
"integrity": "sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ==",
"dev": true
},
"node_modules/@sinonjs/commons": {
@@ -4502,7 +4502,6 @@
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"dev": true,
"funding": [
{
"type": "github",
@@ -5871,9 +5870,9 @@
}
},
"node_modules/diff-sequences": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.2.tgz",
"integrity": "sha512-R6P0Y6PrsH3n4hUXxL3nns0rbRk6Q33js3ygJBeEpbzLzgcNuJ61+u0RXasFpTKISw99TxUzFnumSnRLsjhLaw==",
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz",
"integrity": "sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==",
"dev": true,
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -7121,16 +7120,16 @@
}
},
"node_modules/expect": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/expect/-/expect-29.4.2.tgz",
"integrity": "sha512-+JHYg9O3hd3RlICG90OPVjRkPBoiUH7PxvDVMnRiaq1g6JUgZStX514erMl0v2Dc5SkfVbm7ztqbd6qHHPn+mQ==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/expect/-/expect-29.5.0.tgz",
"integrity": "sha512-yM7xqUrCO2JdpFo4XpM82t+PJBFybdqoQuJLDGeDX2ij8NZzqRHyu3Hp188/JX7SWqud+7t4MUdvcgGBICMHZg==",
"dev": true,
"dependencies": {
"@jest/expect-utils": "^29.4.2",
"jest-get-type": "^29.4.2",
"jest-matcher-utils": "^29.4.2",
"jest-message-util": "^29.4.2",
"jest-util": "^29.4.2"
"@jest/expect-utils": "^29.5.0",
"jest-get-type": "^29.4.3",
"jest-matcher-utils": "^29.5.0",
"jest-message-util": "^29.5.0",
"jest-util": "^29.5.0"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -9650,15 +9649,15 @@
}
},
"node_modules/jest-diff": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.2.tgz",
"integrity": "sha512-EK8DSajVtnjx9sa1BkjZq3mqChm2Cd8rIzdXkQMA8e0wuXq53ypz6s5o5V8HRZkoEt2ywJ3eeNWFKWeYr8HK4g==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.5.0.tgz",
"integrity": "sha512-LtxijLLZBduXnHSniy0WMdaHjmQnt3g5sa16W4p0HqukYTTsyTW3GD1q41TyGl5YFXj/5B2U6dlh5FM1LIMgxw==",
"dev": true,
"dependencies": {
"chalk": "^4.0.0",
"diff-sequences": "^29.4.2",
"jest-get-type": "^29.4.2",
"pretty-format": "^29.4.2"
"diff-sequences": "^29.4.3",
"jest-get-type": "^29.4.3",
"pretty-format": "^29.5.0"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -9710,9 +9709,9 @@
}
},
"node_modules/jest-get-type": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.2.tgz",
"integrity": "sha512-vERN30V5i2N6lqlFu4ljdTqQAgrkTFMC9xaIIfOPYBw04pufjXRty5RuXBiB1d72tGbURa/UgoiHB90ruOSivg==",
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.3.tgz",
"integrity": "sha512-J5Xez4nRRMjk8emnTpWrlkyb9pfRQQanDrvWHhsR1+VUfbwxi30eVcZFlcdGInRibU4G5LwHXpI7IRHU0CY+gg==",
"dev": true,
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -9757,33 +9756,33 @@
}
},
"node_modules/jest-matcher-utils": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.2.tgz",
"integrity": "sha512-EZaAQy2je6Uqkrm6frnxBIdaWtSYFoR8SVb2sNLAtldswlR/29JAgx+hy67llT3+hXBaLB0zAm5UfeqerioZyg==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.5.0.tgz",
"integrity": "sha512-lecRtgm/rjIK0CQ7LPQwzCs2VwW6WAahA55YBuI+xqmhm7LAaxokSB8C97yJeYyT+HvQkH741StzpU41wohhWw==",
"dev": true,
"dependencies": {
"chalk": "^4.0.0",
"jest-diff": "^29.4.2",
"jest-get-type": "^29.4.2",
"pretty-format": "^29.4.2"
"jest-diff": "^29.5.0",
"jest-get-type": "^29.4.3",
"pretty-format": "^29.5.0"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/jest-message-util": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.2.tgz",
"integrity": "sha512-SElcuN4s6PNKpOEtTInjOAA8QvItu0iugkXqhYyguRvQoXapg5gN+9RQxLAkakChZA7Y26j6yUCsFWN+hlKD6g==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.5.0.tgz",
"integrity": "sha512-Kijeg9Dag6CKtIDA7O21zNTACqD5MD/8HfIV8pdD94vFyFuer52SigdC3IQMhab3vACxXMiFk+yMHNdbqtyTGA==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.12.13",
"@jest/types": "^29.4.2",
"@jest/types": "^29.5.0",
"@types/stack-utils": "^2.0.0",
"chalk": "^4.0.0",
"graceful-fs": "^4.2.9",
"micromatch": "^4.0.4",
"pretty-format": "^29.4.2",
"pretty-format": "^29.5.0",
"slash": "^3.0.0",
"stack-utils": "^2.0.3"
},
@@ -9792,14 +9791,14 @@
}
},
"node_modules/jest-mock": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.4.2.tgz",
"integrity": "sha512-x1FSd4Gvx2yIahdaIKoBjwji6XpboDunSJ95RpntGrYulI1ByuYQCKN/P7hvk09JB74IonU3IPLdkutEWYt++g==",
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.4.3.tgz",
"integrity": "sha512-LjFgMg+xed9BdkPMyIJh+r3KeHt1klXPJYBULXVVAkbTaaKjPX1o1uVCAZADMEp/kOxGTwy/Ot8XbvgItOrHEg==",
"dev": true,
"dependencies": {
"@jest/types": "^29.4.2",
"@jest/types": "^29.4.3",
"@types/node": "*",
"jest-util": "^29.4.2"
"jest-util": "^29.4.3"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -9976,12 +9975,12 @@
}
},
"node_modules/jest-util": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.2.tgz",
"integrity": "sha512-wKnm6XpJgzMUSRFB7YF48CuwdzuDIHenVuoIb1PLuJ6F+uErZsuDkU+EiExkChf6473XcawBrSfDSnXl+/YG4g==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.5.0.tgz",
"integrity": "sha512-RYMgG/MTadOr5t8KdhejfvUU82MxsCu5MF6KuDUHl+NuwzUt+Sm6jJWxTJVrDR1j5M/gJVCPKQEpWXY+yIQ6lQ==",
"dev": true,
"dependencies": {
"@jest/types": "^29.4.2",
"@jest/types": "^29.5.0",
"@types/node": "*",
"chalk": "^4.0.0",
"ci-info": "^3.2.0",
@@ -11975,7 +11974,7 @@
"dependencies": {
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"buffer": "^6.0.2",
"console-browserify": "^1.2.0",
"constants-browserify": "^1.0.0",
"crypto-browserify": "^3.12.0",
@@ -12022,7 +12021,7 @@
"dev": true,
"dependencies": {
"abort-controller": "^3.0.0",
"buffer": "^6.0.3",
"buffer": "^6.0.2",
"events": "^3.3.0",
"process": "^0.11.10"
},
@@ -13474,12 +13473,12 @@
}
},
"node_modules/pretty-format": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.2.tgz",
"integrity": "sha512-qKlHR8yFVCbcEWba0H0TOC8dnLlO4vPlyEjRPw31FZ2Rupy9nLa8ZLbYny8gWEl8CkEhJqAE6IzdNELTBVcBEg==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.5.0.tgz",
"integrity": "sha512-V2mGkI31qdttvTFX7Mt4efOqHXqJWMu4/r66Xh3Z3BwZaPfPJgp6/gbwoujRpPUtfEF6AUUWx3Jim3GCw5g/Qw==",
"dev": true,
"dependencies": {
"@jest/schemas": "^29.4.2",
"@jest/schemas": "^29.4.3",
"ansi-styles": "^5.0.0",
"react-is": "^18.0.0"
},
@@ -16529,9 +16528,9 @@
}
},
"node_modules/webpack": {
"version": "5.75.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz",
"integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==",
"version": "5.76.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.0.tgz",
"integrity": "sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA==",
"dev": true,
"dependencies": {
"@types/eslint-scope": "^3.7.3",
@@ -17140,7 +17139,7 @@
"dependencies": {
"assert": "^2.0.0",
"big-integer": "^1.6.48",
"buffer": "5.6.0",
"buffer": "6.0.3",
"create-hash": "^1.2.0",
"decimal.js": "^10.2.0",
"ripple-address-codec": "^4.2.5"
@@ -17149,14 +17148,6 @@
"node": ">= 10"
}
},
"packages/ripple-binary-codec/node_modules/buffer": {
"version": "5.6.0",
"license": "MIT",
"dependencies": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
},
"packages/ripple-keypairs": {
"version": "1.1.5",
"license": "ISC",
@@ -17971,12 +17962,12 @@
}
},
"@jest/expect-utils": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.2.tgz",
"integrity": "sha512-Dd3ilDJpBnqa0GiPN7QrudVs0cczMMHtehSo2CSTjm3zdHx0RcpmhFNVEltuEFeqfLIyWKFI224FsMSQ/nsJQA==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.5.0.tgz",
"integrity": "sha512-fmKzsidoXQT2KwnrwE0SQq3uj8Z763vzR8LnLBwC2qYWEFpjX8daRsk6rHUM1QvNlEW/UJXNXm59ztmJJWs2Mg==",
"dev": true,
"requires": {
"jest-get-type": "^29.4.2"
"jest-get-type": "^29.4.3"
}
},
"@jest/fake-timers": {
@@ -18038,9 +18029,9 @@
}
},
"@jest/schemas": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.2.tgz",
"integrity": "sha512-ZrGzGfh31NtdVH8tn0mgJw4khQuNHiKqdzJAFbCaERbyCP9tHlxWuL/mnMu8P7e/+k4puWjI1NOzi/sFsjce/g==",
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.3.tgz",
"integrity": "sha512-VLYKXQmtmuEz6IxJsrZwzG9NvtkQsWNnWMsKxqWNu3+CnfzJQhp0WDDKWLVV9hLKr0l3SLLFRqcYHjhtyuDVxg==",
"dev": true,
"requires": {
"@sinclair/typebox": "^0.25.16"
@@ -18105,12 +18096,12 @@
}
},
"@jest/types": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.2.tgz",
"integrity": "sha512-CKlngyGP0fwlgC1BRUtPZSiWLBhyS9dKwKmyGxk8Z6M82LBEGB2aLQSg+U1MyLsU+M7UjnlLllBM2BLWKVm/Uw==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-29.5.0.tgz",
"integrity": "sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog==",
"dev": true,
"requires": {
"@jest/schemas": "^29.4.2",
"@jest/schemas": "^29.4.3",
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-reports": "^3.0.0",
"@types/node": "*",
@@ -19315,9 +19306,9 @@
"dev": true
},
"@sinclair/typebox": {
"version": "0.25.21",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.21.tgz",
"integrity": "sha512-gFukHN4t8K4+wVC+ECqeqwzBDeFeTzBXroBTqE6vcWrQGbEUpHO7LYdG0f4xnvYq4VOEwITSlHlp0JBAIFMS/g==",
"version": "0.25.24",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz",
"integrity": "sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ==",
"dev": true
},
"@sinonjs/commons": {
@@ -20809,7 +20800,6 @@
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"dev": true,
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
@@ -21902,9 +21892,9 @@
"dev": true
},
"diff-sequences": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.2.tgz",
"integrity": "sha512-R6P0Y6PrsH3n4hUXxL3nns0rbRk6Q33js3ygJBeEpbzLzgcNuJ61+u0RXasFpTKISw99TxUzFnumSnRLsjhLaw==",
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz",
"integrity": "sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==",
"dev": true
},
"diffie-hellman": {
@@ -22859,16 +22849,16 @@
"dev": true
},
"expect": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/expect/-/expect-29.4.2.tgz",
"integrity": "sha512-+JHYg9O3hd3RlICG90OPVjRkPBoiUH7PxvDVMnRiaq1g6JUgZStX514erMl0v2Dc5SkfVbm7ztqbd6qHHPn+mQ==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/expect/-/expect-29.5.0.tgz",
"integrity": "sha512-yM7xqUrCO2JdpFo4XpM82t+PJBFybdqoQuJLDGeDX2ij8NZzqRHyu3Hp188/JX7SWqud+7t4MUdvcgGBICMHZg==",
"dev": true,
"requires": {
"@jest/expect-utils": "^29.4.2",
"jest-get-type": "^29.4.2",
"jest-matcher-utils": "^29.4.2",
"jest-message-util": "^29.4.2",
"jest-util": "^29.4.2"
"@jest/expect-utils": "^29.5.0",
"jest-get-type": "^29.4.3",
"jest-matcher-utils": "^29.5.0",
"jest-message-util": "^29.5.0",
"jest-util": "^29.5.0"
}
},
"extend": {
@@ -24757,15 +24747,15 @@
}
},
"jest-diff": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.2.tgz",
"integrity": "sha512-EK8DSajVtnjx9sa1BkjZq3mqChm2Cd8rIzdXkQMA8e0wuXq53ypz6s5o5V8HRZkoEt2ywJ3eeNWFKWeYr8HK4g==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.5.0.tgz",
"integrity": "sha512-LtxijLLZBduXnHSniy0WMdaHjmQnt3g5sa16W4p0HqukYTTsyTW3GD1q41TyGl5YFXj/5B2U6dlh5FM1LIMgxw==",
"dev": true,
"requires": {
"chalk": "^4.0.0",
"diff-sequences": "^29.4.2",
"jest-get-type": "^29.4.2",
"pretty-format": "^29.4.2"
"diff-sequences": "^29.4.3",
"jest-get-type": "^29.4.3",
"pretty-format": "^29.5.0"
}
},
"jest-docblock": {
@@ -24805,9 +24795,9 @@
}
},
"jest-get-type": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.2.tgz",
"integrity": "sha512-vERN30V5i2N6lqlFu4ljdTqQAgrkTFMC9xaIIfOPYBw04pufjXRty5RuXBiB1d72tGbURa/UgoiHB90ruOSivg==",
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.3.tgz",
"integrity": "sha512-J5Xez4nRRMjk8emnTpWrlkyb9pfRQQanDrvWHhsR1+VUfbwxi30eVcZFlcdGInRibU4G5LwHXpI7IRHU0CY+gg==",
"dev": true
},
"jest-haste-map": {
@@ -24841,43 +24831,43 @@
}
},
"jest-matcher-utils": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.2.tgz",
"integrity": "sha512-EZaAQy2je6Uqkrm6frnxBIdaWtSYFoR8SVb2sNLAtldswlR/29JAgx+hy67llT3+hXBaLB0zAm5UfeqerioZyg==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.5.0.tgz",
"integrity": "sha512-lecRtgm/rjIK0CQ7LPQwzCs2VwW6WAahA55YBuI+xqmhm7LAaxokSB8C97yJeYyT+HvQkH741StzpU41wohhWw==",
"dev": true,
"requires": {
"chalk": "^4.0.0",
"jest-diff": "^29.4.2",
"jest-get-type": "^29.4.2",
"pretty-format": "^29.4.2"
"jest-diff": "^29.5.0",
"jest-get-type": "^29.4.3",
"pretty-format": "^29.5.0"
}
},
"jest-message-util": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.2.tgz",
"integrity": "sha512-SElcuN4s6PNKpOEtTInjOAA8QvItu0iugkXqhYyguRvQoXapg5gN+9RQxLAkakChZA7Y26j6yUCsFWN+hlKD6g==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.5.0.tgz",
"integrity": "sha512-Kijeg9Dag6CKtIDA7O21zNTACqD5MD/8HfIV8pdD94vFyFuer52SigdC3IQMhab3vACxXMiFk+yMHNdbqtyTGA==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.12.13",
"@jest/types": "^29.4.2",
"@jest/types": "^29.5.0",
"@types/stack-utils": "^2.0.0",
"chalk": "^4.0.0",
"graceful-fs": "^4.2.9",
"micromatch": "^4.0.4",
"pretty-format": "^29.4.2",
"pretty-format": "^29.5.0",
"slash": "^3.0.0",
"stack-utils": "^2.0.3"
}
},
"jest-mock": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.4.2.tgz",
"integrity": "sha512-x1FSd4Gvx2yIahdaIKoBjwji6XpboDunSJ95RpntGrYulI1ByuYQCKN/P7hvk09JB74IonU3IPLdkutEWYt++g==",
"version": "29.4.3",
"resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.4.3.tgz",
"integrity": "sha512-LjFgMg+xed9BdkPMyIJh+r3KeHt1klXPJYBULXVVAkbTaaKjPX1o1uVCAZADMEp/kOxGTwy/Ot8XbvgItOrHEg==",
"dev": true,
"requires": {
"@jest/types": "^29.4.2",
"@jest/types": "^29.4.3",
"@types/node": "*",
"jest-util": "^29.4.2"
"jest-util": "^29.4.3"
}
},
"jest-pnp-resolver": {
@@ -25025,12 +25015,12 @@
}
},
"jest-util": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.2.tgz",
"integrity": "sha512-wKnm6XpJgzMUSRFB7YF48CuwdzuDIHenVuoIb1PLuJ6F+uErZsuDkU+EiExkChf6473XcawBrSfDSnXl+/YG4g==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.5.0.tgz",
"integrity": "sha512-RYMgG/MTadOr5t8KdhejfvUU82MxsCu5MF6KuDUHl+NuwzUt+Sm6jJWxTJVrDR1j5M/gJVCPKQEpWXY+yIQ6lQ==",
"dev": true,
"requires": {
"@jest/types": "^29.4.2",
"@jest/types": "^29.5.0",
"@types/node": "*",
"chalk": "^4.0.0",
"ci-info": "^3.2.0",
@@ -26695,7 +26685,7 @@
"requires": {
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"buffer": "^6.0.2",
"console-browserify": "^1.2.0",
"constants-browserify": "^1.0.0",
"crypto-browserify": "^3.12.0",
@@ -26733,7 +26723,7 @@
"dev": true,
"requires": {
"abort-controller": "^3.0.0",
"buffer": "^6.0.3",
"buffer": "^6.0.2",
"events": "^3.3.0",
"process": "^0.11.10"
}
@@ -27856,12 +27846,12 @@
}
},
"pretty-format": {
"version": "29.4.2",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.2.tgz",
"integrity": "sha512-qKlHR8yFVCbcEWba0H0TOC8dnLlO4vPlyEjRPw31FZ2Rupy9nLa8ZLbYny8gWEl8CkEhJqAE6IzdNELTBVcBEg==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.5.0.tgz",
"integrity": "sha512-V2mGkI31qdttvTFX7Mt4efOqHXqJWMu4/r66Xh3Z3BwZaPfPJgp6/gbwoujRpPUtfEF6AUUWx3Jim3GCw5g/Qw==",
"dev": true,
"requires": {
"@jest/schemas": "^29.4.2",
"@jest/schemas": "^29.4.3",
"ansi-styles": "^5.0.0",
"react-is": "^18.0.0"
},
@@ -28669,19 +28659,10 @@
"requires": {
"assert": "^2.0.0",
"big-integer": "^1.6.48",
"buffer": "5.6.0",
"buffer": "6.0.3",
"create-hash": "^1.2.0",
"decimal.js": "^10.2.0",
"ripple-address-codec": "^4.2.5"
},
"dependencies": {
"buffer": {
"version": "5.6.0",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
}
}
},
"ripple-keypairs": {
@@ -30224,9 +30205,9 @@
"dev": true
},
"webpack": {
"version": "5.75.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz",
"integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==",
"version": "5.76.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.0.tgz",
"integrity": "sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA==",
"dev": true,
"requires": {
"@types/eslint-scope": "^3.7.3",

View File

@@ -1,6 +1,8 @@
# ripple-binary-codec Release History
## Unreleased
### Added
- Allow custom type definitions to be used for encoding/decoding transactions at runtime (e.g. for sidechains/new amendments)
## 1.5.0 (2023-03-08)
### Changed

View File

@@ -14,7 +14,7 @@
"dependencies": {
"assert": "^2.0.0",
"big-integer": "^1.6.48",
"buffer": "5.6.0",
"buffer": "6.0.3",
"create-hash": "^1.2.0",
"decimal.js": "^10.2.0",
"ripple-address-codec": "^4.2.5"
@@ -22,8 +22,8 @@
"scripts": {
"build": "tsc -b && copyfiles ./src/enums/definitions.json ./dist/enums/",
"clean": "rm -rf ./dist && rm -rf tsconfig.tsbuildinfo",
"prepare": "npm run build && npm test",
"test": "jest --verbose false --silent=false ./test/*.test.js",
"prepublishOnly": "npm test",
"test": "npm run build && jest --verbose false --silent=false ./test/*.test.js",
"lint": "eslint . --ext .ts --ext .test.js"
},
"repository": {

View File

@@ -6,7 +6,11 @@ import { AccountID } from './types/account-id'
import { HashPrefix } from './hash-prefixes'
import { BinarySerializer, BytesList } from './serdes/binary-serializer'
import { sha512Half, transactionID } from './hashes'
import { FieldInstance } from './enums'
import {
type XrplDefinitionsBase,
DEFAULT_DEFINITIONS,
type FieldInstance,
} from './enums'
import { STObject } from './types/st-object'
import { JsonObject } from './types/serialized-type'
import { Buffer } from 'buffer/'
@@ -16,26 +20,41 @@ import bigInt = require('big-integer')
* Construct a BinaryParser
*
* @param bytes hex-string to construct BinaryParser from
* @param definitions rippled definitions used to parse the values of transaction types and such.
* Can be customized for sidechains and amendments.
* @returns A BinaryParser
*/
const makeParser = (bytes: string): BinaryParser => new BinaryParser(bytes)
const makeParser = (
bytes: string,
definitions?: XrplDefinitionsBase,
): BinaryParser => new BinaryParser(bytes, definitions)
/**
* Parse BinaryParser into JSON
*
* @param parser BinaryParser object
* @param definitions rippled definitions used to parse the values of transaction types and such.
* Can be customized for sidechains and amendments.
* @returns JSON for the bytes in the BinaryParser
*/
const readJSON = (parser: BinaryParser): JsonObject =>
(parser.readType(coreTypes.STObject) as STObject).toJSON()
const readJSON = (
parser: BinaryParser,
definitions: XrplDefinitionsBase = DEFAULT_DEFINITIONS,
): JsonObject =>
(parser.readType(coreTypes.STObject) as STObject).toJSON(definitions)
/**
* Parse a hex-string into its JSON interpretation
*
* @param bytes hex-string to parse into JSON
* @param definitions rippled definitions used to parse the values of transaction types and such.
* Can be customized for sidechains and amendments.
* @returns JSON
*/
const binaryToJSON = (bytes: string): JsonObject => readJSON(makeParser(bytes))
const binaryToJSON = (
bytes: string,
definitions?: XrplDefinitionsBase,
): JsonObject => readJSON(makeParser(bytes, definitions), definitions)
/**
* Interface for passing parameters to SerializeObject
@@ -46,17 +65,18 @@ interface OptionObject {
prefix?: Buffer
suffix?: Buffer
signingFieldsOnly?: boolean
definitions?: XrplDefinitionsBase
}
/**
* Function to serialize JSON object representing a transaction
*
* @param object JSON object to serialize
* @param opts options for serializing, including optional prefix, suffix, and signingFieldOnly
* @param opts options for serializing, including optional prefix, suffix, signingFieldOnly, and definitions
* @returns A Buffer containing the serialized object
*/
function serializeObject(object: JsonObject, opts: OptionObject = {}): Buffer {
const { prefix, suffix, signingFieldsOnly = false } = opts
const { prefix, suffix, signingFieldsOnly = false, definitions } = opts
const bytesList = new BytesList()
if (prefix) {
@@ -66,8 +86,9 @@ function serializeObject(object: JsonObject, opts: OptionObject = {}): Buffer {
const filter = signingFieldsOnly
? (f: FieldInstance): boolean => f.isSigningField
: undefined
coreTypes.STObject.from(object, filter).toBytesSink(bytesList)
;(coreTypes.STObject as typeof STObject)
.from(object, filter, definitions)
.toBytesSink(bytesList)
if (suffix) {
bytesList.put(suffix)
@@ -81,13 +102,19 @@ function serializeObject(object: JsonObject, opts: OptionObject = {}): Buffer {
*
* @param transaction Transaction to serialize
* @param prefix Prefix bytes to put before the serialized object
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
* @returns A Buffer with the serialized object
*/
function signingData(
transaction: JsonObject,
prefix: Buffer = HashPrefix.transactionSig,
opts: { definitions?: XrplDefinitionsBase } = {},
): Buffer {
return serializeObject(transaction, { prefix, signingFieldsOnly: true })
return serializeObject(transaction, {
prefix,
signingFieldsOnly: true,
definitions: opts.definitions,
})
}
/**
@@ -102,6 +129,7 @@ interface ClaimObject extends JsonObject {
* Serialize a signingClaim
*
* @param claim A claim object to serialize
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
* @returns the serialized object with appropriate prefix
*/
function signingClaimData(claim: ClaimObject): Buffer {
@@ -123,11 +151,15 @@ function signingClaimData(claim: ClaimObject): Buffer {
*
* @param transaction transaction to serialize
* @param signingAccount Account to sign the transaction with
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
* @returns serialized transaction with appropriate prefix and suffix
*/
function multiSigningData(
transaction: JsonObject,
signingAccount: string | AccountID,
opts: { definitions: XrplDefinitionsBase } = {
definitions: DEFAULT_DEFINITIONS,
},
): Buffer {
const prefix = HashPrefix.transactionMultiSig
const suffix = coreTypes.AccountID.from(signingAccount).toBytes()
@@ -135,6 +167,7 @@ function multiSigningData(
prefix,
suffix,
signingFieldsOnly: true,
definitions: opts.definitions,
})
}

View File

@@ -1,4 +1,5 @@
import {
DEFAULT_DEFINITIONS,
Field,
TransactionType,
LedgerEntryType,
@@ -17,6 +18,7 @@ export {
hashes,
binary,
ledgerHashes,
DEFAULT_DEFINITIONS,
Field,
TransactionType,
LedgerEntryType,

View File

@@ -1,12 +1,16 @@
# Definitions
This file is used to serialize/deserialize transactions and ledger objects for the XRPL. It's broken into 5 sections laid out below.
At the bottom of this README you can find instructions and examples for how to define your own types in a definitions file in order to work on a custom sidechain or develop new amendments.
## Types
These are the [types](https://xrpl.org/serialization.html#type-list) associated with a given Serialization Field. Each type has an arbitrary [type_code](https://xrpl.org/serialization.html#type-codes), with lower codes sorting first.
## Ledger Entry Types
Each ledger's state tree contain [ledger objects](https://xrpl.org/ledger-object-types.html), which represent all settings, balances, and relationships in the shared ledger.
Each ledger's state tree contain [ledger objects](https://xrpl.org/ledger-object-types.html), which represent all settings, balances, and relationships in the shared ledger.
## Fields
@@ -53,8 +57,88 @@ See:
- https://github.com/ripple/rippled/blob/develop/src/ripple/protocol/TER.h
- https://xrpl.org/transaction-results.html
TODO: Write a script to read rippled's source file and generate the necessary mapping.
To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
## Transaction Types
See https://github.com/ripple/rippled/blob/develop/src/ripple/protocol/TxFormats.h
# Defining Your Own Definitions
If you're building your own sidechain or writing an amendment for the XRPL, you may need to create new XRPL definitions.
To do that there are a couple things you need to do:
1. Generate your own `definitions.json` file from rippled source code using [this tool](https://github.com/RichardAH/xrpl-codec-gen) (The default `definitions.json` for mainnet can be found [here](https://github.com/XRPLF/xrpl.js/blob/main/packages/ripple-binary-codec/src/enums/definitions.json))
2. Create new SerializedType classes for any new Types (So that encode/decode behavior is defined). The SerializedType classes correspond to "ST..." classes in Rippled. Note: This is very rarely required.
- For examples of how to implement that you can look at objects in the [`types` folder](../types/), such as `Amount`, `UInt8`, or `STArray`.
3. Import your `definitions.json` file to construct your own `XrplDefinitions` object.
4. Pass the `XrplDefinitions` object whenever you `encode` or `decode` a transaction.
5. If you added any new transaction types, you should create an `interface` for the transaction that extends `BaseTransaction` from the `xrpl` repo to use it with the functions on `Client` (See the below example of adding a new transaction type)
## Example of adding a new Transaction type
```
// newDefinitionsJson is where you can import your custom defined definitions.json file
const newDefinitionsJson = require('./new-transaction-type-definitions.json')
const { XrplDefinitions, Client } = require('xrpl')
const newDefs = new XrplDefinitions(newDefinitionsJson)
// Change to point at the server you care about
const serverAddress = 'wss://s.devnet.rippletest.net:51233'
const client = new Client(serverAddress)
const wallet1 = await client.fundWallet()
// Extending BaseTransaction allows typescript to recognize this as a transaction type
interface NewTx extends BaseTransaction {
Amount: Amount
}
const tx: NewTx = {
// The TransactionType here needs to match what you added in your newDefinitionsJson file
TransactionType: 'NewTx',
Account: wallet1.address,
Amount: '100',
}
// By passing in your newDefs, your new transaction should be serializable.
// Rippled will still throw an error though if it's not a supported transaction type.
const result = await client.submitAndWait(tx, {
wallet: wallet1,
definitions: newDefs,
})
```
## Example of adding a new serializable Type
```
const { XrplDefinitions } = require('../dist/coretypes')
// newDefinitionsJson is where you can import your custom defined definitions.json file
const newDefinitionsJson = require('./fixtures/new-definitions.json')
// For any new Types you create, you'll need to make a class with the same name which extends a SerializedType object
// In order to define how to serialize/deserialize that field. Here we simply make our NewType act like a UInt32.
const { UInt32 } = require('../dist/types/uint-32')
class NewType extends UInt32 {
// Should be the same as UInt32
}
const extendedCoreTypes = { NewType }
const newDefs = new XrplDefinitions(newDefinitionsJson, extendedCoreTypes)
// From this point on, we should be able to serialize / deserialize Transactions with fields that have 'NewType' as their Type.
const encoded = encode(my_tx, newDefs)
const decoded = decode(encoded, newDefs)
```
## Other examples
You can find other examples of how to modify `definitions.json` in `definition.test.js` which contains tests for this feature, and uses various example modified `definition` files. You can find the tests and the corresponding example `definition` files in [this folder of test cases](https://github.com/XRPLF/xrpl.js/tree/main/packages/ripple-binary-codec/test)

View File

@@ -0,0 +1,75 @@
import { BytesList, BinaryParser } from '../binary'
import { Buffer } from 'buffer/'
/*
* @brief: Bytes, name, and ordinal representing one type, ledger_type, transaction type, or result
*/
export class Bytes {
readonly bytes: Buffer
constructor(
readonly name: string,
readonly ordinal: number,
readonly ordinalWidth: number,
) {
this.bytes = Buffer.alloc(ordinalWidth)
for (let i = 0; i < ordinalWidth; i++) {
this.bytes[ordinalWidth - i - 1] = (ordinal >>> (i * 8)) & 0xff
}
}
toJSON(): string {
return this.name
}
toBytesSink(sink: BytesList): void {
sink.put(this.bytes)
}
toBytes(): Uint8Array {
return this.bytes
}
}
/*
* @brief: Collection of Bytes objects, mapping bidirectionally
*/
export class BytesLookup {
constructor(types: Record<string, number>, readonly ordinalWidth: number) {
Object.entries(types).forEach(([k, v]) => {
this.add(k, v)
})
}
/**
* Add a new name value pair to the BytesLookup.
*
* @param name - A human readable name for the field.
* @param value - The numeric value for the field.
* @throws if the name or value already exist in the lookup because it's unclear how to decode.
*/
add(name: string, value: number): void {
if (this[name]) {
throw new SyntaxError(
`Attempted to add a value with a duplicate name "${name}". This is not allowed because it is unclear how to decode.`,
)
}
if (this[value.toString()]) {
throw new SyntaxError(
`Attempted to add a duplicate value under a different name (Given name: "${name}" and previous name: "${
this[value.toString()]
}. This is not allowed because it is unclear how to decode.\nGiven value: ${value.toString()}`,
)
}
this[name] = new Bytes(name, value, this.ordinalWidth)
this[value.toString()] = this[name]
}
from(value: Bytes | string): Bytes {
return value instanceof Bytes ? value : (this[value] as Bytes)
}
fromParser(parser: BinaryParser): Bytes {
return this.from(parser.readUIntN(this.ordinalWidth).toString())
}
}

View File

@@ -0,0 +1,4 @@
export const TYPE_WIDTH = 2
export const LEDGER_ENTRY_WIDTH = 2
export const TRANSACTION_TYPE_WIDTH = 2
export const TRANSACTION_RESULT_WIDTH = 1

View File

@@ -0,0 +1,85 @@
import { Bytes } from './bytes'
import { SerializedType } from '../types/serialized-type'
import { TYPE_WIDTH } from './constants'
import { Buffer } from 'buffer/'
/**
* Encoding information for a rippled field, often used in transactions.
* See the enums [README.md](https://github.com/XRPLF/xrpl.js/tree/main/packages/ripple-binary-codec/src/enums) for more details on what each means.
*/
export interface FieldInfo {
nth: number
isVLEncoded: boolean
isSerialized: boolean
isSigningField: boolean
type: string
}
export interface FieldInstance {
readonly nth: number
readonly isVariableLengthEncoded: boolean
readonly isSerialized: boolean
readonly isSigningField: boolean
readonly type: Bytes
readonly ordinal: number
readonly name: string
readonly header: Buffer
readonly associatedType: typeof SerializedType
}
/*
* @brief: Serialize a field based on type_code and Field.nth
*/
function fieldHeader(type: number, nth: number): Buffer {
const header: Array<number> = []
if (type < 16) {
if (nth < 16) {
header.push((type << 4) | nth)
} else {
header.push(type << 4, nth)
}
} else if (nth < 16) {
header.push(nth, type)
} else {
header.push(0, type, nth)
}
return Buffer.from(header)
}
function buildField(
[name, info]: [string, FieldInfo],
typeOrdinal: number,
): FieldInstance {
const field = fieldHeader(typeOrdinal, info.nth)
return {
name: name,
nth: info.nth,
isVariableLengthEncoded: info.isVLEncoded,
isSerialized: info.isSerialized,
isSigningField: info.isSigningField,
ordinal: (typeOrdinal << 16) | info.nth,
type: new Bytes(info.type, typeOrdinal, TYPE_WIDTH),
header: field,
associatedType: SerializedType, // For later assignment in ./types/index.js or Definitions.updateAll(...)
}
}
/*
* @brief: The collection of all fields as defined in definitions.json
*/
export class FieldLookup {
constructor(
fields: Array<[string, FieldInfo]>,
types: Record<string, number>,
) {
fields.forEach(([name, field_info]) => {
const typeOrdinal = types[field_info.type]
this[name] = buildField([name, field_info], typeOrdinal)
this[this[name].ordinal.toString()] = this[name]
})
}
fromString(value: string): FieldInstance {
return this[value] as FieldInstance
}
}

View File

@@ -1,164 +1,34 @@
import * as enums from './definitions.json'
import { SerializedType } from '../types/serialized-type'
import { Buffer } from 'buffer/'
import { BytesList } from '../binary'
import {
XrplDefinitionsBase,
FieldInstance,
Bytes,
} from './xrpl-definitions-base'
/**
* By default, coreTypes from the `types` folder is where known type definitions are initialized to avoid import cycles.
*/
const DEFAULT_DEFINITIONS = new XrplDefinitionsBase(enums, {})
const Type = DEFAULT_DEFINITIONS.type
const LedgerEntryType = DEFAULT_DEFINITIONS.ledgerEntryType
const TransactionType = DEFAULT_DEFINITIONS.transactionType
const TransactionResult = DEFAULT_DEFINITIONS.transactionResult
const Field = DEFAULT_DEFINITIONS.field
/*
* @brief: All valid transaction types
*/
export const TRANSACTION_TYPES = Object.entries(enums.TRANSACTION_TYPES)
.filter(([_key, value]) => value >= 0)
.map(([key, _value]) => key)
const TYPE_WIDTH = 2
const LEDGER_ENTRY_WIDTH = 2
const TRANSACTION_TYPE_WIDTH = 2
const TRANSACTION_RESULT_WIDTH = 1
/*
* @brief: Serialize a field based on type_code and Field.nth
*/
function fieldHeader(type: number, nth: number): Buffer {
const header: Array<number> = []
if (type < 16) {
if (nth < 16) {
header.push((type << 4) | nth)
} else {
header.push(type << 4, nth)
}
} else if (nth < 16) {
header.push(nth, type)
} else {
header.push(0, type, nth)
}
return Buffer.from(header)
}
/*
* @brief: Bytes, name, and ordinal representing one type, ledger_type, transaction type, or result
*/
export class Bytes {
readonly bytes: Buffer
constructor(
readonly name: string,
readonly ordinal: number,
readonly ordinalWidth: number,
) {
this.bytes = Buffer.alloc(ordinalWidth)
for (let i = 0; i < ordinalWidth; i++) {
this.bytes[ordinalWidth - i - 1] = (ordinal >>> (i * 8)) & 0xff
}
}
toJSON(): string {
return this.name
}
toBytesSink(sink: BytesList): void {
sink.put(this.bytes)
}
toBytes(): Uint8Array {
return this.bytes
}
}
/*
* @brief: Collection of Bytes objects, mapping bidirectionally
*/
class BytesLookup {
constructor(types: Record<string, number>, readonly ordinalWidth: number) {
Object.entries(types).forEach(([k, v]) => {
this[k] = new Bytes(k, v, ordinalWidth)
this[v.toString()] = this[k]
})
}
from(value: Bytes | string): Bytes {
return value instanceof Bytes ? value : (this[value] as Bytes)
}
fromParser(parser): Bytes {
return this.from(parser.readUIntN(this.ordinalWidth).toString())
}
}
/*
* type FieldInfo is the type of the objects containing information about each field in definitions.json
*/
interface FieldInfo {
nth: number
isVLEncoded: boolean
isSerialized: boolean
isSigningField: boolean
type: string
}
interface FieldInstance {
readonly nth: number
readonly isVariableLengthEncoded: boolean
readonly isSerialized: boolean
readonly isSigningField: boolean
readonly type: Bytes
readonly ordinal: number
readonly name: string
readonly header: Buffer
readonly associatedType: typeof SerializedType
}
function buildField([name, info]: [string, FieldInfo]): FieldInstance {
const typeOrdinal = enums.TYPES[info.type]
const field = fieldHeader(typeOrdinal, info.nth)
return {
name: name,
nth: info.nth,
isVariableLengthEncoded: info.isVLEncoded,
isSerialized: info.isSerialized,
isSigningField: info.isSigningField,
ordinal: (typeOrdinal << 16) | info.nth,
type: new Bytes(info.type, typeOrdinal, TYPE_WIDTH),
header: field,
associatedType: SerializedType, // For later assignment in ./types/index.js
}
}
/*
* @brief: The collection of all fields as defined in definitions.json
*/
class FieldLookup {
constructor(fields: Array<[string, FieldInfo]>) {
fields.forEach(([k, v]) => {
this[k] = buildField([k, v])
this[this[k].ordinal.toString()] = this[k]
})
}
fromString(value: string): FieldInstance {
return this[value] as FieldInstance
}
}
const Type = new BytesLookup(enums.TYPES, TYPE_WIDTH)
const LedgerEntryType = new BytesLookup(
enums.LEDGER_ENTRY_TYPES,
LEDGER_ENTRY_WIDTH,
)
const TransactionType = new BytesLookup(
enums.TRANSACTION_TYPES,
TRANSACTION_TYPE_WIDTH,
)
const TransactionResult = new BytesLookup(
enums.TRANSACTION_RESULTS,
TRANSACTION_RESULT_WIDTH,
)
const Field = new FieldLookup(enums.FIELDS as Array<[string, FieldInfo]>)
const TRANSACTION_TYPES = DEFAULT_DEFINITIONS.transactionNames
export {
Bytes,
XrplDefinitionsBase,
DEFAULT_DEFINITIONS,
Field,
FieldInstance,
Type,
LedgerEntryType,
TransactionResult,
TransactionType,
TRANSACTION_TYPES,
}

View File

@@ -0,0 +1,111 @@
import { SerializedType } from '../types/serialized-type'
import { Bytes, BytesLookup } from './bytes'
import { FieldInfo, FieldLookup, FieldInstance } from './field'
import {
TYPE_WIDTH,
LEDGER_ENTRY_WIDTH,
TRANSACTION_TYPE_WIDTH,
TRANSACTION_RESULT_WIDTH,
} from './constants'
interface DefinitionsData {
TYPES: Record<string, number>
LEDGER_ENTRY_TYPES: Record<string, number>
FIELDS: (string | FieldInfo)[][]
TRANSACTION_RESULTS: Record<string, number>
TRANSACTION_TYPES: Record<string, number>
}
/**
* Stores the various types and fields for rippled to be used to encode/decode information later on.
* XrplDefinitions should be instantiated instead of this class.
*/
class XrplDefinitionsBase {
// A collection of fields that can be included in transactions
field: FieldLookup
// A collection of ids corresponding to types of ledger objects
ledgerEntryType: BytesLookup
// A collection of type flags used to determine how to serialize a field's data
type: BytesLookup
// Errors and result codes for transactions
transactionResult: BytesLookup
// Defined transactions that can be submitted to the ledger
transactionType: BytesLookup
// Valid transaction names
transactionNames: string[]
// Maps serializable types to their TypeScript class implementation
dataTypes: Record<string, typeof SerializedType>
/**
* Present rippled types in a typed and updatable format.
* For an example of the input format see `definitions.json`
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
*
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
*
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
* @param types - A list of type objects with the same name as the fields defined.
* You can use the coreTypes object if you are not adding new types.
*/
constructor(
enums: DefinitionsData,
types: Record<string, typeof SerializedType>,
) {
this.type = new BytesLookup(enums.TYPES, TYPE_WIDTH)
this.ledgerEntryType = new BytesLookup(
enums.LEDGER_ENTRY_TYPES,
LEDGER_ENTRY_WIDTH,
)
this.transactionType = new BytesLookup(
enums.TRANSACTION_TYPES,
TRANSACTION_TYPE_WIDTH,
)
this.transactionResult = new BytesLookup(
enums.TRANSACTION_RESULTS,
TRANSACTION_RESULT_WIDTH,
)
this.field = new FieldLookup(
enums.FIELDS as Array<[string, FieldInfo]>,
enums.TYPES,
)
this.transactionNames = Object.entries(enums.TRANSACTION_TYPES)
.filter(([_key, value]) => value >= 0)
.map(([key, _value]) => key)
this.dataTypes = {} // Filled in via associateTypes
this.associateTypes(types)
}
/**
* Associates each Field to a corresponding class that TypeScript can recognize.
*
* @param types a list of type objects with the same name as the fields defined.
* Defaults to xrpl.js's core type definitions.
*/
public associateTypes(types: Record<string, typeof SerializedType>): void {
// Overwrite any existing type definitions with the given types
this.dataTypes = Object.assign({}, this.dataTypes, types)
Object.values(this.field).forEach((field) => {
field.associatedType = this.dataTypes[field.type.name]
})
this.field['TransactionType'].associatedType = this.transactionType
this.field['TransactionResult'].associatedType = this.transactionResult
this.field['LedgerEntryType'].associatedType = this.ledgerEntryType
}
public getAssociatedTypes(): Record<string, typeof SerializedType> {
return this.dataTypes
}
}
export {
DefinitionsData,
XrplDefinitionsBase,
FieldLookup,
FieldInfo,
FieldInstance,
Bytes,
BytesLookup,
}

View File

@@ -0,0 +1,32 @@
import {
type DefinitionsData,
XrplDefinitionsBase,
} from './xrpl-definitions-base'
import { coreTypes } from '../types'
import { SerializedType } from '../types/serialized-type'
/**
* Stores the various types and fields for rippled to be used to encode/decode information later on.
* Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
* ledger data.
*/
export class XrplDefinitions extends XrplDefinitionsBase {
/**
* Present rippled types in a typed and updatable format.
* For an example of the input format see `definitions.json`
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
*
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
*
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
* @param additionalTypes - A list of SerializedType objects with the same name as the fields defined.
* These types will be included in addition to the coreTypes used on mainnet.
*/
constructor(
enums: DefinitionsData,
additionalTypes?: Record<string, typeof SerializedType>,
) {
const types = Object.assign({}, coreTypes, additionalTypes)
super(enums, types)
}
}

View File

@@ -1,9 +1,15 @@
import * as assert from 'assert'
import { quality, binary } from './coretypes'
import { quality, binary, HashPrefix } from './coretypes'
import { decodeLedgerData } from './ledger-hashes'
import { ClaimObject } from './binary'
import { JsonObject } from './types/serialized-type'
import { TRANSACTION_TYPES } from './enums'
import {
XrplDefinitionsBase,
TRANSACTION_TYPES,
DEFAULT_DEFINITIONS,
} from './enums'
import { XrplDefinitions } from './enums/xrpl-definitions'
import { coreTypes } from './types'
const {
signingData,
@@ -17,22 +23,25 @@ const {
* Decode a transaction
*
* @param binary hex-string of the encoded transaction
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
* @returns the JSON representation of the transaction
*/
function decode(binary: string): JsonObject {
function decode(binary: string, definitions?: XrplDefinitionsBase): JsonObject {
assert.ok(typeof binary === 'string', 'binary must be a hex string')
return binaryToJSON(binary)
return binaryToJSON(binary, definitions)
}
/**
* Encode a transaction
*
* @param json The JSON representation of a transaction
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
*
* @returns A hex-string of the encoded transaction
*/
function encode(json: object): string {
function encode(json: object, definitions?: XrplDefinitionsBase): string {
assert.ok(typeof json === 'object')
return serializeObject(json as JsonObject)
return serializeObject(json as JsonObject, { definitions })
.toString('hex')
.toUpperCase()
}
@@ -42,11 +51,17 @@ function encode(json: object): string {
*
* @param json JSON object representing the transaction
* @param signer string representing the account to sign the transaction with
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
* @returns a hex string of the encoded transaction
*/
function encodeForSigning(json: object): string {
function encodeForSigning(
json: object,
definitions?: XrplDefinitionsBase,
): string {
assert.ok(typeof json === 'object')
return signingData(json as JsonObject)
return signingData(json as JsonObject, HashPrefix.transactionSig, {
definitions,
})
.toString('hex')
.toUpperCase()
}
@@ -56,6 +71,7 @@ function encodeForSigning(json: object): string {
*
* @param json JSON object representing the transaction
* @param signer string representing the account to sign the transaction with
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
* @returns a hex string of the encoded transaction
*/
function encodeForSigningClaim(json: object): string {
@@ -70,12 +86,18 @@ function encodeForSigningClaim(json: object): string {
*
* @param json JSON object representing the transaction
* @param signer string representing the account to sign the transaction with
* @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
* @returns a hex string of the encoded transaction
*/
function encodeForMultisigning(json: object, signer: string): string {
function encodeForMultisigning(
json: object,
signer: string,
definitions?: XrplDefinitionsBase,
): string {
assert.ok(typeof json === 'object')
assert.equal(json['SigningPubKey'], '')
return multiSigningData(json as JsonObject, signer)
const definitionsOpt = definitions ? { definitions } : undefined
return multiSigningData(json as JsonObject, signer, definitionsOpt)
.toString('hex')
.toUpperCase()
}
@@ -112,4 +134,8 @@ export {
decodeQuality,
decodeLedgerData,
TRANSACTION_TYPES,
XrplDefinitions,
XrplDefinitionsBase,
DEFAULT_DEFINITIONS,
coreTypes,
}

View File

@@ -11,6 +11,7 @@ import { UInt8 } from './types/uint-8'
import { BinaryParser } from './serdes/binary-parser'
import { JsonObject } from './types/serialized-type'
import bigInt = require('big-integer')
import { XrplDefinitionsBase } from './enums'
/**
* Computes the hash of a list of objects
@@ -160,11 +161,16 @@ function ledgerHash(header: ledgerObject): Hash256 {
* Decodes a serialized ledger header
*
* @param binary A serialized ledger header
* @param definitions Type definitions to parse the ledger objects.
* Used if there are non-default ledger objects to decode.
* @returns A JSON object describing a ledger header
*/
function decodeLedgerData(binary: string): object {
function decodeLedgerData(
binary: string,
definitions?: XrplDefinitionsBase,
): object {
assert.ok(typeof binary === 'string', 'binary must be a hex string')
const parser = new BinaryParser(binary)
const parser = new BinaryParser(binary, definitions)
return {
ledger_index: parser.readUInt32(),
total_coins: parser.readType(UInt64).valueOf().toString(),

View File

@@ -1,6 +1,10 @@
import * as assert from 'assert'
import { Field, FieldInstance } from '../enums'
import { SerializedType } from '../types/serialized-type'
import {
XrplDefinitionsBase,
DEFAULT_DEFINITIONS,
FieldInstance,
} from '../enums'
import { type SerializedType } from '../types/serialized-type'
import { Buffer } from 'buffer/'
/**
@@ -8,14 +12,21 @@ import { Buffer } from 'buffer/'
*/
class BinaryParser {
private bytes: Buffer
definitions: XrplDefinitionsBase
/**
* Initialize bytes to a hex string
*
* @param hexBytes a hex string
* @param definitions Rippled definitions used to parse the values of transaction types and such.
* Can be customized for sidechains and amendments.
*/
constructor(hexBytes: string) {
constructor(
hexBytes: string,
definitions: XrplDefinitionsBase = DEFAULT_DEFINITIONS,
) {
this.bytes = Buffer.from(hexBytes, 'hex')
this.definitions = definitions
}
/**
@@ -146,7 +157,7 @@ class BinaryParser {
* @return The field represented by the bytes at the head of the BinaryParser
*/
readField(): FieldInstance {
return Field.fromString(this.readFieldOrdinal().toString())
return this.definitions.field.fromString(this.readFieldOrdinal().toString())
}
/**

View File

@@ -1,6 +1,6 @@
import * as assert from 'assert'
import { FieldInstance } from '../enums'
import { SerializedType } from '../types/serialized-type'
import { type SerializedType } from '../types/serialized-type'
import { Buffer } from 'buffer/'
/**

View File

@@ -130,7 +130,7 @@ class ShaMapInner extends ShaMapNode {
*/
hash(): Hash256 {
if (this.empty()) {
return coreTypes.Hash256.ZERO_256
return (coreTypes.Hash256 as typeof Hash256).ZERO_256
}
const hash = Sha512Half.put(this.hashPrefix())
this.toBytesSink(hash)
@@ -145,7 +145,9 @@ class ShaMapInner extends ShaMapNode {
toBytesSink(list: BytesList): void {
for (let i = 0; i < this.branches.length; i++) {
const branch = this.branches[i]
const hash = branch ? branch.hash() : coreTypes.Hash256.ZERO_256
const hash = branch
? branch.hash()
: (coreTypes.Hash256 as typeof Hash256).ZERO_256
hash.toBytesSink(list)
}
}

View File

@@ -1,9 +1,3 @@
import {
Field,
TransactionResult,
TransactionType,
LedgerEntryType,
} from '../enums'
import { AccountID } from './account-id'
import { Amount } from './amount'
import { Blob } from './blob'
@@ -19,8 +13,10 @@ import { UInt32 } from './uint-32'
import { UInt64 } from './uint-64'
import { UInt8 } from './uint-8'
import { Vector256 } from './vector-256'
import { type SerializedType } from './serialized-type'
import { DEFAULT_DEFINITIONS } from '../enums'
const coreTypes = {
const coreTypes: Record<string, typeof SerializedType> = {
AccountID,
Amount,
Blob,
@@ -38,12 +34,26 @@ const coreTypes = {
Vector256,
}
Object.values(Field).forEach((field) => {
field.associatedType = coreTypes[field.type.name]
})
// Ensures that the DEFAULT_DEFINITIONS object connects these types to fields for serializing/deserializing
// This is done here instead of in enums/index.ts to avoid a circular dependency
// because some of the above types depend on BinarySerializer which depends on enums/index.ts.
DEFAULT_DEFINITIONS.associateTypes(coreTypes)
Field['TransactionType'].associatedType = TransactionType
Field['TransactionResult'].associatedType = TransactionResult
Field['LedgerEntryType'].associatedType = LedgerEntryType
export { coreTypes }
export {
coreTypes,
AccountID,
Amount,
Blob,
Currency,
Hash128,
Hash160,
Hash256,
PathSet,
STArray,
STObject,
UInt8,
UInt16,
UInt32,
UInt64,
Vector256,
}

View File

@@ -1,4 +1,9 @@
import { Field, FieldInstance, Bytes } from '../enums'
import {
DEFAULT_DEFINITIONS,
FieldInstance,
Bytes,
XrplDefinitionsBase,
} from '../enums'
import { SerializedType, JsonObject } from './serialized-type'
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
import { BinaryParser } from '../serdes/binary-parser'
@@ -83,11 +88,13 @@ class STObject extends SerializedType {
*
* @param value An object to include
* @param filter optional, denote which field to include in serialized object
* @param definitions optional, types and values to use to encode/decode a transaction
* @returns a STObject object
*/
static from<T extends STObject | JsonObject>(
value: T,
filter?: (...any) => boolean,
definitions: XrplDefinitionsBase = DEFAULT_DEFINITIONS,
): STObject {
if (value instanceof STObject) {
return value
@@ -108,7 +115,7 @@ class STObject extends SerializedType {
}, {})
let sorted = Object.keys(xAddressDecoded)
.map((f: string): FieldInstance => Field[f] as FieldInstance)
.map((f: string): FieldInstance => definitions.field[f] as FieldInstance)
.filter(
(f: FieldInstance): boolean =>
f !== undefined &&
@@ -155,11 +162,12 @@ class STObject extends SerializedType {
/**
* Get the JSON interpretation of this.bytes
*
* @param definitions rippled definitions used to parse the values of transaction types and such.
* Can be customized for sidechains and amendments.
* @returns a JSON object
*/
toJSON(): JsonObject {
const objectParser = new BinaryParser(this.toString())
toJSON(definitions?: XrplDefinitionsBase): JsonObject {
const objectParser = new BinaryParser(this.toString(), definitions)
const accumulator = {}
while (!objectParser.end()) {

View File

@@ -0,0 +1,100 @@
const { encode, decode, XrplDefinitions } = require('../src')
const normalDefinitionsJson = require('../src/enums/definitions.json')
const { UInt32 } = require('../dist/types/uint-32')
const txJson = {
Account: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
Amount: '1000',
Destination: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
Fee: '10',
Flags: 0,
Sequence: 1,
TransactionType: 'Payment',
}
describe('encode and decode using new types as a parameter', function () {
test('can encode and decode a new TransactionType', function () {
const tx = { ...txJson, TransactionType: 'NewTestTransaction' }
// Before updating the types, this should not be encodable
expect(() => encode(tx)).toThrow()
// Normally this would be generated directly from rippled with something like `server_definitions`.
// Added here to make it easier to see what is actually changing in the definitions.json file.
const definitions = JSON.parse(JSON.stringify(normalDefinitionsJson))
definitions.TRANSACTION_TYPES['NewTestTransaction'] = 30
const newDefs = new XrplDefinitions(definitions)
const encoded = encode(tx, newDefs)
expect(() => decode(encoded)).toThrow()
const decoded = decode(encoded, newDefs)
expect(decoded).toStrictEqual(tx)
})
test('can encode and decode a new Field', function () {
const tx = { ...txJson, NewFieldDefinition: 10 }
// Before updating the types, undefined fields will be ignored on encode
expect(decode(encode(tx))).not.toStrictEqual(tx)
// Normally this would be generated directly from rippled with something like `server_definitions`.
// Added here to make it easier to see what is actually changing in the definitions.json file.
const definitions = JSON.parse(JSON.stringify(normalDefinitionsJson))
definitions.FIELDS.push([
'NewFieldDefinition',
{
nth: 100,
isVLEncoded: false,
isSerialized: true,
isSigningField: true,
type: 'UInt32',
},
])
const newDefs = new XrplDefinitions(definitions)
const encoded = encode(tx, newDefs)
expect(() => decode(encoded)).toThrow()
const decoded = decode(encoded, newDefs)
expect(decoded).toStrictEqual(tx)
})
test('can encode and decode a new Type', function () {
const tx = {
...txJson,
TestField: 10, // Should work the same as a UInt32
}
// Normally this would be generated directly from rippled with something like `server_definitions`.
// Added here to make it easier to see what is actually changing in the definitions.json file.
const definitions = JSON.parse(JSON.stringify(normalDefinitionsJson))
definitions.TYPES.NewType = 24
definitions.FIELDS.push([
'TestField',
{
nth: 100,
isVLEncoded: true,
isSerialized: true,
isSigningField: true,
type: 'NewType',
},
])
// Test that before updating the types this tx fails to decode correctly. Note that undefined fields are ignored on encode.
expect(decode(encode(tx))).not.toStrictEqual(tx)
class NewType extends UInt32 {
// Should be the same as UInt32
}
const extendedCoreTypes = { NewType }
const newDefs = new XrplDefinitions(definitions, extendedCoreTypes)
const encoded = encode(tx, newDefs)
expect(() => decode(encoded)).toThrow()
const decoded = decode(encoded, newDefs)
expect(decoded).toStrictEqual(tx)
})
})

View File

@@ -4,6 +4,9 @@ const {
encodeForSigningClaim,
encodeForMultisigning,
} = require('../src')
const { XrplDefinitions } = require('../src/enums/xrpl-definitions')
const normalDefinitions = require('../src/enums/definitions.json')
const tx_json = {
Account: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
@@ -67,6 +70,53 @@ describe('Signing data', function () {
)
})
test('can create single signing blobs with modified type', function () {
const customPaymentDefinitions = JSON.parse(
JSON.stringify(normalDefinitions),
)
customPaymentDefinitions.TRANSACTION_TYPES.Payment = 31
const newDefs = new XrplDefinitions(customPaymentDefinitions)
const actual = encodeForSigning(tx_json, newDefs)
expect(actual).toBe(
[
'53545800', // signingPrefix
// TransactionType
'12',
'001F',
// Flags
'22',
'80000000',
// Sequence
'24',
'00000001',
// Amount
'61',
// native amount
'40000000000003E8',
// Fee
'68',
// native amount
'400000000000000A',
// SigningPubKey
'73',
// VLLength
'21',
'ED5F5AC8B98974A3CA843326D9B88CEBD0560177B973EE0B149F782CFAA06DC66A',
// Account
'81',
// VLLength
'14',
'5B812C9D57731E27A2DA8B1830195F88EF32A3B6',
// Destination
'83',
// VLLength
'14',
'B5F762798A53D543A014CAF8B297CFF8F2F937E8',
].join(''),
)
})
test('can fail gracefully for invalid TransactionType', function () {
const invalidTransactionType = {
...tx_json,
@@ -78,7 +128,7 @@ describe('Signing data', function () {
test('can create multi signing blobs', function () {
const signingAccount = 'rJZdUusLDtY9NEsGea7ijqhVrXv98rYBYN'
const signingJson = Object.assign({}, tx_json, { SigningPubKey: '' })
const signingJson = { ...tx_json, SigningPubKey: '' }
const actual = encodeForMultisigning(signingJson, signingAccount)
expect(actual).toBe(
[
@@ -120,6 +170,58 @@ describe('Signing data', function () {
].join(''),
)
})
test('can create multi signing blobs with custom definitions', function () {
const customPaymentDefinitions = JSON.parse(
JSON.stringify(normalDefinitions),
)
customPaymentDefinitions.TRANSACTION_TYPES.Payment = 31
const newDefs = new XrplDefinitions(customPaymentDefinitions)
const signingAccount = 'rJZdUusLDtY9NEsGea7ijqhVrXv98rYBYN'
const signingJson = { ...tx_json, SigningPubKey: '' }
const actual = encodeForMultisigning(signingJson, signingAccount, newDefs)
expect(actual).toBe(
[
'534D5400', // signingPrefix
// TransactionType
'12',
'001F',
// Flags
'22',
'80000000',
// Sequence
'24',
'00000001',
// Amount
'61',
// native amount
'40000000000003E8',
// Fee
'68',
// native amount
'400000000000000A',
// SigningPubKey
'73',
// VLLength
'00',
// '',
// Account
'81',
// VLLength
'14',
'5B812C9D57731E27A2DA8B1830195F88EF32A3B6',
// Destination
'83',
// VLLength
'14',
'B5F762798A53D543A014CAF8B297CFF8F2F937E8',
// signingAccount suffix
'C0A5ABEF242802EFED4B041E8F2D4A8CC86AE3D1',
].join(''),
)
})
test('can create claim blob', function () {
const channel =
'43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1'

View File

@@ -3,6 +3,16 @@
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
### Added
* Null and undefined values in transactions are now treated as though the field was not passed in.
### Fixed
* Fixed `ServerState.transitions` typing, it is now a string instead of a number. (Only used in return from `server_state` request)
* Added `destination_amount` to `PathOption` which is returned as part of a `path_find` request
### Removed
* RPCs and utils related to the old sidechain design
## 2.7.0 (2023-03-08)
### Fixed

View File

@@ -3,6 +3,7 @@ import BigNumber from 'bignumber.js'
import { fromSeed } from 'bip32'
import { mnemonicToSeedSync, validateMnemonic } from 'bip39'
import isEqual from 'lodash/isEqual'
import omitBy from 'lodash/omitBy'
import {
classicAddressToXAddress,
isValidXAddress,
@@ -26,7 +27,7 @@ import {
import ECDSA from '../ECDSA'
import { ValidationError, XrplError } from '../errors'
import { IssuedCurrencyAmount } from '../models/common'
import { Transaction } from '../models/transactions'
import { Transaction, validate } from '../models/transactions'
import { isIssuedCurrency } from '../models/transactions/common'
import { isHex } from '../models/utils'
import { ensureClassicAddress } from '../sugar/utils'
@@ -323,7 +324,12 @@ class Wallet {
multisignAddress = this.classicAddress
}
const tx = { ...transaction }
// clean null & undefined valued tx properties
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- ensure Transaction flows through
const tx = omitBy(
{ ...transaction },
(value) => value == null,
) as unknown as Transaction
if (tx.TxnSignature || tx.Signers) {
throw new ValidationError(
@@ -333,6 +339,12 @@ class Wallet {
removeTrailingZeros(tx)
/*
* This will throw a more clear error for JS users if the supplied transaction has incorrect formatting
*/
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- validate does not accept Transaction type
validate(tx as unknown as Record<string, unknown>)
const txToSignAndEncode = { ...tx }
txToSignAndEncode.SigningPubKey = multisignAddress ? '' : this.publicKey
@@ -460,9 +472,6 @@ class Wallet {
})
if (txCopy.TransactionType === 'NFTokenMint' && txCopy.URI) {
if (!isHex(txCopy.URI)) {
throw new ValidationError('URI must be a hex value')
}
txCopy.URI = txCopy.URI.toUpperCase()
}

View File

@@ -1,78 +0,0 @@
import { BaseRequest, BaseResponse } from './baseMethod'
/**
* The `federator_info` command asks the federator for information
* about the door account and other bridge-related information. This
* method only exists on sidechain federators. Expects a response in
* the form of a {@link FederatorInfoResponse}.
*
* @category Requests
*/
export interface FederatorInfoRequest extends BaseRequest {
command: 'federator_info'
}
/**
* Response expected from a {@link FederatorInfoRequest}.
*
* @category Responses
*/
export interface FederatorInfoResponse extends BaseResponse {
result: {
info: {
mainchain: {
door_status: {
initialized: boolean
status: 'open' | 'opening' | 'closed' | 'closing'
}
last_transaction_sent_seq: number
listener_info: {
state: 'syncing' | 'normal'
}
pending_transactions: Array<{
amount: string
destination_account: string
signatures: Array<{
public_key: string
seq: number
}>
}>
sequence: number
tickets: {
initialized: boolean
tickets: Array<{
status: 'taken' | 'available'
ticket_seq: number
}>
}
}
public_key: string
sidechain: {
door_status: {
initialized: boolean
status: 'open' | 'opening' | 'closed' | 'closing'
}
last_transaction_sent_seq: number
listener_info: {
state: 'syncing' | 'normal'
}
pending_transactions: Array<{
amount: string
destination_account: string
signatures: Array<{
public_key: string
seq: number
}>
}>
sequence: number
tickets: {
initialized: boolean
tickets: Array<{
status: 'taken' | 'available'
ticket_seq: number
}>
}
}
}
}
}

View File

@@ -23,7 +23,6 @@ import {
DepositAuthorizedRequest,
DepositAuthorizedResponse,
} from './depositAuthorized'
import { FederatorInfoRequest, FederatorInfoResponse } from './federatorInfo'
import { FeeRequest, FeeResponse } from './fee'
import {
GatewayBalancesRequest,
@@ -121,8 +120,6 @@ type Request =
// NFT methods
| NFTBuyOffersRequest
| NFTSellOffersRequest
// sidechain methods
| FederatorInfoRequest
/**
* @category Responses
@@ -171,8 +168,6 @@ type Response =
// NFT methods
| NFTBuyOffersResponse
| NFTSellOffersResponse
// sidechain methods
| FederatorInfoResponse
export {
Request,
@@ -268,7 +263,4 @@ export {
NFTBuyOffersResponse,
NFTSellOffersRequest,
NFTSellOffersResponse,
// sidechain methods
FederatorInfoRequest,
FederatorInfoResponse,
}

View File

@@ -63,6 +63,11 @@ interface PathOption {
* Destination to receive the desired amount.
*/
source_amount: Amount
/**
* Destination Amount that the destination would receive along this path.
* If the `send_max` field is set, this field will be set.
*/
destination_amount?: Amount
}
/**
@@ -80,7 +85,7 @@ export interface PathFindResponse extends BaseResponse {
alternatives: PathOption[]
/** Unique address of the account that would receive a transaction. */
destination_account: string
/** Currency amount that the destination would receive in a transaction. */
/** Currency amount provided in the WebSocket request. */
destination_amount: Amount
/** Unique address that would send a transaction. */
source_account: string

View File

@@ -22,7 +22,7 @@ export type ServerState =
export interface StateAccounting {
duration_us: string
transitions: number
transitions: string
}
export interface JobType {

View File

@@ -86,8 +86,11 @@ export interface NFTokenMint extends BaseTransaction {
*
* This field must be hex-encoded. You can use `convertStringToHex` to
* convert this field to the proper encoding.
*
* This field must not be an empty string. Omit it from the transaction or
* set to `undefined` value if you do not use it.
*/
URI?: string
URI?: string | null
Flags?: number | NFTokenMintFlagsInterface
}
@@ -106,6 +109,10 @@ export function validateNFTokenMint(tx: Record<string, unknown>): void {
)
}
if (typeof tx.URI === 'string' && tx.URI === '') {
throw new ValidationError('NFTokenMint: URI must not be empty string')
}
if (typeof tx.URI === 'string' && !isHex(tx.URI)) {
throw new ValidationError('NFTokenMint: URI must be in hex format')
}

View File

@@ -1,10 +1,6 @@
/* eslint-disable complexity -- verifies 19 tx types hence a lot of checks needed */
/* eslint-disable max-lines-per-function -- need to work with a lot of Tx verifications */
import isEqual from 'lodash/isEqual'
import omitBy from 'lodash/omitBy'
import { encode, decode } from 'ripple-binary-codec'
import { ValidationError } from '../../errors'
import { setTransactionFlagsToNumber } from '../utils/flags'
@@ -209,13 +205,4 @@ export function validate(transaction: Record<string, unknown>): void {
`Invalid field TransactionType: ${tx.TransactionType}`,
)
}
if (
!isEqual(
decode(encode(tx)),
omitBy(tx, (value) => value == null),
)
) {
throw new ValidationError(`Invalid Transaction: ${tx.TransactionType}`)
}
}

View File

@@ -1,40 +0,0 @@
import { XrplError } from '../errors'
import { Payment } from '../models'
import { Memo } from '../models/common'
import { convertStringToHex } from './stringConversion'
/**
* Creates a cross-chain payment transaction.
*
* @param payment - The initial payment transaction. If the transaction is
* signed, then it will need to be re-signed. There must be no more than 2
* memos, since one memo is used for the sidechain destination account. The
* destination must be the sidechain's door account.
* @param destAccount - the destination account on the sidechain.
* @returns A cross-chain payment transaction, where the mainchain door account
* is the `Destination` and the destination account on the sidechain is encoded
* in the memos.
* @throws XrplError - if there are more than 2 memos.
* @category Utilities
*/
export default function createCrossChainPayment(
payment: Payment,
destAccount: string,
): Payment {
const destAccountHex = convertStringToHex(destAccount)
const destAccountMemo: Memo = { Memo: { MemoData: destAccountHex } }
const memos = payment.Memos ?? []
if (memos.length > 2) {
throw new XrplError(
'Cannot have more than 2 memos in a cross-chain transaction.',
)
}
const newMemos = [destAccountMemo, ...memos]
const newPayment = { ...payment, Memos: newMemos }
delete newPayment.TxnSignature
return newPayment
}

View File

@@ -184,4 +184,22 @@ export function hashPaymentChannel(
)
}
/**
* Compute the Hash of an Check LedgerEntry.
*
* @param address - Address of the Check.
* @param sequence - Sequence of the CreateCheck tx.
* @returns The hash of the Check LedgerEntry.
* @category Utilities
*/
export function hashCheckId(address: string, sequence: number): string {
const hexPrefix = ledgerSpaces.check
.charCodeAt(0)
.toString(HEX)
.padStart(2, '0')
const hexSequence = sequence.toString(HEX).padStart(8, '0')
const prefix = `00${hexPrefix}`
return sha512Half(prefix + addressToHex(address) + hexSequence)
}
export { hashLedgerHeader, hashSignedTx, hashLedger, hashStateTree, hashTxTree }

View File

@@ -22,7 +22,6 @@ import { Response } from '../models/methods'
import { PaymentChannelClaim } from '../models/transactions/paymentChannelClaim'
import { Transaction } from '../models/transactions/transaction'
import createCrossChainPayment from './createCrossChainPayment'
import { deriveKeypair, deriveAddress, deriveXAddress } from './derive'
import getBalanceChanges from './getBalanceChanges'
import getNFTokenID from './getNFTokenID'
@@ -220,6 +219,5 @@ export {
encodeForSigning,
encodeForSigningClaim,
getNFTokenID,
createCrossChainPayment,
parseNFTokenID,
}

View File

@@ -1,5 +1,7 @@
To run integration tests:
1. Run rippled-standalone node, either in a docker container (preferred) or by installing rippled.
* With docker, run `docker run -p 6006:6006 -it natenichols/rippled-standalone:latest`
* Or [download and build rippled](https://xrpl.org/install-rippled.html) and run `./rippled -a`
1. Run rippled in standalone node, either in a docker container (preferred) or by installing rippled.
* Go to the top-level of the `xrpl.js` repo, just above the `packages` folder.
* With docker, run `docker run -p 6006:6006 --interactive -t --volume $PWD/.ci-config:/config/ xrpllabsofficial/xrpld:latest -a --start`
* Or [download and build rippled](https://xrpl.org/install-rippled.html) and run `./rippled -a --start`
* If you'd like to use the latest rippled amendments, you should modify your `rippled.cfg` file to enable amendments in the `[amendments]` section. You can view `.ci-config/rippled.cfg` in the top level folder as an example of this.
2. Run `npm test:integration` or `npm test:browser`

View File

@@ -61,11 +61,11 @@ describe('server_info (rippled)', function () {
server_state: 'full',
server_state_duration_us: '8752395105',
state_accounting: {
connected: { duration_us: '0', transitions: 0 },
disconnected: { duration_us: '41860', transitions: 1 },
full: { duration_us: '20723121268', transitions: 1 },
syncing: { duration_us: '0', transitions: 0 },
tracking: { duration_us: '0', transitions: 0 },
connected: { duration_us: '0', transitions: '0' },
disconnected: { duration_us: '41860', transitions: '1' },
full: { duration_us: '20723121268', transitions: '1' },
syncing: { duration_us: '0', transitions: '0' },
tracking: { duration_us: '0', transitions: '0' },
},
time: '2021-Sep-23 22:56:55.320858 UTC',
uptime: 8752,
@@ -108,6 +108,9 @@ describe('server_info (rippled)', function () {
'pubkey_node',
'server_state_duration_us',
'validated_ledger',
'build_version',
'node_size',
'initial_sync_duration_us',
]
assert.deepEqual(
omit(response.result.info, removeKeys),
@@ -129,7 +132,7 @@ describe('server_info (rippled)', function () {
)
assert.equal(
typeof response.result.info.state_accounting[key].transitions,
'number',
'string',
)
})

View File

@@ -68,11 +68,11 @@ describe('server_state', function () {
server_state: 'full',
server_state_duration_us: '8752487389',
state_accounting: {
connected: { duration_us: '0', transitions: 0 },
disconnected: { duration_us: '41860', transitions: 1 },
full: { duration_us: '20723121268', transitions: 1 },
syncing: { duration_us: '0', transitions: 0 },
tracking: { duration_us: '0', transitions: 0 },
connected: { duration_us: '0', transitions: '0' },
disconnected: { duration_us: '41860', transitions: '1' },
full: { duration_us: '20723121268', transitions: '1' },
syncing: { duration_us: '0', transitions: '0' },
tracking: { duration_us: '0', transitions: '0' },
},
time: '2021-Sep-23 22:56:55.413151 UTC',
uptime: 8752,
@@ -112,6 +112,9 @@ describe('server_state', function () {
'server_state_duration_us',
'validated_ledger',
'io_latency_ms',
'build_version',
'node_size',
'initial_sync_duration_us',
]
assert.deepEqual(
omit(response.result.state, removeKeys),
@@ -133,7 +136,7 @@ describe('server_state', function () {
)
assert.equal(
typeof response.result.state.state_accounting[key].transitions,
'number',
'string',
)
})

View File

@@ -68,6 +68,26 @@ describe('NFTokenMint', function () {
)
})
it(`throws w/ URI being an empty string`, function () {
const invalid = {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
NFTokenTaxon: 0,
Issuer: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
TransferFee: 1,
URI: '',
} as any
assert.throws(
() => validate(invalid),
ValidationError,
'NFTokenMint: URI must not be empty string',
)
})
it(`throws w/ URI not in hex format`, function () {
const invalid = {
TransactionType: 'NFTokenMint',

View File

@@ -1,124 +0,0 @@
import { assert } from 'chai'
import { createCrossChainPayment, convertStringToHex, Payment } from '../../src'
describe('createCrossChainPayment', function () {
it('successful xchain payment creation', function () {
const payment: Payment = {
TransactionType: 'Payment',
Account: 'rRandom',
Destination: 'rRandom2',
Amount: '3489303',
}
const sidechainAccount = 'rSidechain'
const expectedPayment = {
...payment,
Memos: [
{
Memo: {
MemoData: convertStringToHex(sidechainAccount),
},
},
],
}
const resultPayment = createCrossChainPayment(payment, sidechainAccount)
assert.deepEqual(resultPayment, expectedPayment)
// ensure that the original object wasn't modified
assert.notDeepEqual(resultPayment, payment)
})
it('successful xchain payment creation with memo', function () {
const memo = {
Memo: {
MemoData: 'deadbeef',
},
}
const payment: Payment = {
TransactionType: 'Payment',
Account: 'rRandom',
Destination: 'rRandom2',
Amount: '3489303',
Memos: [memo],
}
const sidechainAccount = 'rSidechain'
const expectedPayment = {
...payment,
Memos: [
{
Memo: {
MemoData: convertStringToHex(sidechainAccount),
},
},
memo,
],
}
const resultPayment = createCrossChainPayment(payment, sidechainAccount)
assert.deepEqual(resultPayment, expectedPayment)
// ensure that the original object wasn't modified
assert.notDeepEqual(resultPayment, payment)
})
it('removes TxnSignature', function () {
const payment: Payment = {
TransactionType: 'Payment',
Account: 'rRandom',
Destination: 'rRandom2',
Amount: '3489303',
TxnSignature: 'asodfiuaosdfuaosd',
}
const sidechainAccount = 'rSidechain'
const expectedPayment = {
...payment,
Memos: [
{
Memo: {
MemoData: convertStringToHex(sidechainAccount),
},
},
],
}
delete expectedPayment.TxnSignature
const resultPayment = createCrossChainPayment(payment, sidechainAccount)
assert.deepEqual(resultPayment, expectedPayment)
// ensure that the original object wasn't modified
assert.notDeepEqual(resultPayment, payment)
})
it('fails with 3 memos', function () {
const payment: Payment = {
TransactionType: 'Payment',
Account: 'rRandom',
Destination: 'rRandom2',
Amount: '3489303',
Memos: [
{
Memo: {
MemoData: '2934723843ace',
},
},
{
Memo: {
MemoData: '2934723843ace',
},
},
{
Memo: {
MemoData: '2934723843ace',
},
},
],
}
assert.throws(() => {
createCrossChainPayment(payment, 'rSidechain')
}, /Cannot have more than 2 memos/u)
})
})

View File

@@ -864,6 +864,171 @@ describe('Wallet', function () {
assert.deepEqual(result, expectedResult)
})
it('sign throws when NFTokenMint.URI is empty string', async function () {
const tx: NFTokenMint = {
TransactionType: 'NFTokenMint',
Account: wallet.address,
TransferFee: 314,
NFTokenTaxon: 0,
Flags: 8,
Fee: '10',
URI: '',
Memos: [
{
Memo: {
MemoType:
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
],
}
assert.throws(() => {
wallet.sign(tx)
}, /URI must not be empty string/u)
})
it('sign removes undefined NFTokenMint.URI property from transaction blob', async function () {
const tx: NFTokenMint = {
TransactionType: 'NFTokenMint',
Account: wallet.address,
TransferFee: 314,
NFTokenTaxon: 0,
Flags: 8,
Fee: '10',
URI: undefined,
Memos: [
{
Memo: {
MemoType:
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
],
}
const result = wallet.sign(tx)
const decodedTx = decode(result.tx_blob) as unknown as NFTokenMint
assert.notExists(decodedTx.URI)
})
it('sign removes nulled NFTokenMint.URI property from transaction blob', async function () {
const tx: NFTokenMint = {
TransactionType: 'NFTokenMint',
Account: wallet.address,
TransferFee: 314,
NFTokenTaxon: 0,
Flags: 8,
Fee: '10',
URI: null,
Memos: [
{
Memo: {
MemoType:
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
],
}
const result = wallet.sign(tx)
const decodedTx = decode(result.tx_blob) as unknown as NFTokenMint
assert.notExists(decodedTx.URI)
})
it('sign allows undefined value for NFTokenMint.URI', async function () {
// transaction with explicit URI: undefined
const tx_1: NFTokenMint = {
TransactionType: 'NFTokenMint',
Account: wallet.address,
TransferFee: 314,
NFTokenTaxon: 0,
Flags: 8,
Fee: '10',
URI: undefined,
Memos: [
{
Memo: {
MemoType:
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
],
}
const result_1 = wallet.sign(tx_1)
// transaction with no URI
const tx_2: NFTokenMint = {
TransactionType: 'NFTokenMint',
Account: wallet.address,
TransferFee: 314,
NFTokenTaxon: 0,
Flags: 8,
Fee: '10',
Memos: [
{
Memo: {
MemoType:
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
],
}
const result_2 = wallet.sign(tx_2)
assert.deepEqual(result_1, result_2)
})
it('sign allows nulled value for NFTokenMint.URI', async function () {
// transaction with explicit URI: null
const tx_1: NFTokenMint = {
TransactionType: 'NFTokenMint',
Account: wallet.address,
TransferFee: 314,
NFTokenTaxon: 0,
Flags: 8,
Fee: '10',
URI: null,
Memos: [
{
Memo: {
MemoType:
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
],
}
const result_1 = wallet.sign(tx_1)
// transaction with no URI
const tx_2: NFTokenMint = {
TransactionType: 'NFTokenMint',
Account: wallet.address,
TransferFee: 314,
NFTokenTaxon: 0,
Flags: 8,
Fee: '10',
Memos: [
{
Memo: {
MemoType:
'687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963',
MemoData: '72656e74',
},
},
],
}
const result_2 = wallet.sign(tx_2)
assert.deepEqual(result_1, result_2)
})
it('sign allows lowercase hex value for NFTokenMint.URI', async function () {
const tx: NFTokenMint = {
TransactionType: 'NFTokenMint',
@@ -915,7 +1080,7 @@ describe('Wallet', function () {
assert.throws(() => {
wallet.sign(tx)
}, /URI must be a hex value/u)
}, /URI must be in hex format/u)
})
})

View File

@@ -139,7 +139,9 @@ describe('Signer', function () {
it('multisign runs successfully with tx_blobs', function () {
const transactions = [multisignTxToCombine1, multisignTxToCombine2]
const encodedTransactions: string[] = transactions.map(encode)
const encodedTransactions: string[] = transactions.map((transaction) =>
encode(transaction),
)
assert.deepEqual(multisign(encodedTransactions), expectedMultisign)
})