Compare commits

..

12 Commits

Author SHA1 Message Date
Denis Angell
a5deee1274 update tests and fixtures 2023-02-22 17:47:42 -05:00
Denis Angell
294c1cb083 add network id to autofill 2023-02-22 17:47:42 -05:00
Denis Angell
69c705874f update base tx 2023-02-22 17:47:42 -05:00
Denis Angell
e36912c60a update server info 2023-02-22 17:47:42 -05:00
Denis Angell
3d06185867 Merge branch 'main' into network-id 2023-02-22 17:44:21 -05:00
Jackson Mills
5d34746f12 Add a helper to get the NFTokenID after minting (#2205) 2023-02-21 14:42:52 -08:00
Jackson Mills
3d0bec7e89 Add support for disallowIncoming flags (#2221)
* Add support for disallowIncoming flags

* Fix broken tests

* Update packages/xrpl/src/models/ledger/AccountRoot.ts

* Update packages/xrpl/src/models/ledger/AccountRoot.ts

* Update HISTORY.md
2023-02-21 10:22:47 -08:00
Denis Angell
b241779f10 add network id to base transaction 2023-02-16 23:01:23 -05:00
Denis Angell
c809bd87e4 update definitions 2023-02-16 23:01:08 -05:00
dependabot[bot]
fde954640f build(deps-dev): bump prettier from 2.8.3 to 2.8.4 (#2210) 2023-02-16 22:08:03 +00:00
Mayukha Vadari
b2dcce75b0 docs: update release instructions with beta details (#2213)
* Update release instructions with beta details

* add tag details

* add version info
2023-02-16 16:07:46 -05:00
dependabot[bot]
e6c7c88209 build(deps-dev): bump webpack-cli from 4.9.2 to 5.0.1 (#2165)
Bumps [webpack-cli](https://github.com/webpack/webpack-cli) from 4.9.2 to 5.0.1.
- [Release notes](https://github.com/webpack/webpack-cli/releases)
- [Changelog](https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.9.2...webpack-cli@5.0.1)

---
updated-dependencies:
- dependency-name: webpack-cli
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-15 16:12:33 -08:00
89 changed files with 1596 additions and 2201 deletions

View File

@@ -1,12 +1,11 @@
{
"editor.tabSize": 2,
"cSpell.words": [
"hostid",
"Multisigned",
"preauthorization",
"secp256k1",
"Setf",
"xchain"
"hostid",
"preauthorization",
"secp256k1"
],
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",

View File

@@ -177,32 +177,33 @@ npm uninstall abbrev -w xrpl
NOW WE ARE READY TO PUBLISH! No new code changes happen manually now.
2. Checkout `main` and `git pull`.
3. Create a new branch to capture updates that take place during this process. `git checkout -b <BRANCH_NAME>`
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.
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 release tags for the new version.
8. 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.
9. Run `npm i` to update the package-lock with the updated versions
10. Create a new PR from this branch into `main` and merge it.
11. Checkout `main` and `git pull`
12. Run `npx lerna publish from-package --yes` - This will actually publish the packages.
13. If it asks for it, enter your [npmjs.com](https://npmjs.com) OTP (one-time password) to complete publication.
14. Create a new branch to capture the updated packages from the release (`git checkout -b <BRANCH_NAME>`)
15. Make a PR to merge those changes into `main`
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).
NOW YOU HAVE PUBLISHED! But you're not done; we have to notify people!
16. Pull the most recent changes to main locally.
17. Run `git tag <tagname> -m <tagname>`, where `<tagname>` is the new package and version (e.g. `xrpl@2.1.1`), for each version released.
18. Run `git push --follow-tags`, to push the tags to Github.
19. On Github, click the "releases" link on the right-hand side of the page.
20. Click "Draft a new release"
21. Click "Choose a tag", and choose a tag that you just created.
22. Edit the name of the release to match the tag (IE \<package\>@\<version\>) and edit the description as you see fit.
23. Repeat steps 19-21 for each release.
24. Send an email to [xrpl-announce](https://groups.google.com/g/xrpl-announce).
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).
## Mailing Lists

View File

@@ -1,118 +0,0 @@
"""
Helper script to write `validate` methods for transactions.
"""
import sys
NORMAL_TYPES = ["number", "string"]
NUMBERS = ["0", "1"]
def main():
model_name = sys.argv[1]
filename = f"./packages/xrpl/src/models/transactions/{model_name}.ts"
model, tx_name = get_model(filename)
return process_model(model, tx_name)
# Extract just the model from the file
def get_model(filename):
model = ""
started = False
ended = False
with open(filename) as f:
for line in f:
if ended:
continue
if not started and not line.startswith("export"):
continue
if not started and "Flags" in line:
continue
if not started:
started = True
model += line
if line == '}\n':
ended = True
lines = model.split("\n")
name_line = lines[0].split(" ")
tx_name = name_line[2]
return model, tx_name
# Process the model and build the `validate` method
def get_if_line_param_part(param: str, param_type: str):
if param_type in NORMAL_TYPES:
return f"typeof tx.{param} !== \"{param_type}\""
elif param_type in NUMBERS:
return f"tx.{param} !== {param_type}"
else:
return f"!is{param_type}(tx.{param})"
def process_model(model, tx_name):
output = ""
for line in model.split("\n"):
if line == "":
continue
if line.startswith("export"):
continue
if line == "}":
continue
line = line.strip()
if line.startswith("TransactionType"):
continue
if line.startswith("Flags"):
continue
split = line.split(" ")
param = split[0].strip("?:")
param_types = split[1:]
optional = split[0].endswith("?:")
if optional:
if_line = f" if(tx.{param} !== undefined && "
else:
output += f" if (tx.{param} == null) {{\n"
output += f" throw new ValidationError('{tx_name}: missing field {param}')\n"
output += " }\n\n"
if_line = " if("
if len(param_types) == 1:
param_type = param_types[0]
if_line += get_if_line_param_part(param, param_type)
else:
i = 0
if_outputs = []
while i < len(param_types):
param_type = param_types[i]
if_outputs.append(get_if_line_param_part(param, param_type))
i += 2
if_line += "(" + " && ".join(if_outputs) + ")"
if_line += ") {\n"
output += if_line
output += f" throw new ValidationError('{tx_name}: invalid field {param}')\n"
output += " }\n\n"
output = output[:-1]
output += "}\n"
output = f"""/**
* Verify the form and type of a {tx_name} at runtime.
*
* @param tx - A {tx_name} Transaction.
* @throws When the {tx_name} is malformed.
*/
export function validate{tx_name}(tx: Record<string, unknown>): void {{
validateBaseTransaction(tx)
""" + output
return output
if __name__ == "__main__":
print(main())

172
package-lock.json generated
View File

@@ -65,7 +65,7 @@
"url": "^0.11.0",
"webpack": "^5.6.0",
"webpack-bundle-analyzer": "^4.1.0",
"webpack-cli": "^4.2.0"
"webpack-cli": "^5.0.1"
},
"engines": {
"node": ">=12.0.0",
@@ -3339,34 +3339,42 @@
}
},
"node_modules/@webpack-cli/configtest": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz",
"integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.0.1.tgz",
"integrity": "sha512-njsdJXJSiS2iNbQVS0eT8A/KPnmyH4pv1APj2K0d1wrZcBLw+yppxOy4CGqa0OxDJkzfL/XELDhD8rocnIwB5A==",
"dev": true,
"engines": {
"node": ">=14.15.0"
},
"peerDependencies": {
"webpack": "4.x.x || 5.x.x",
"webpack-cli": "4.x.x"
"webpack": "5.x.x",
"webpack-cli": "5.x.x"
}
},
"node_modules/@webpack-cli/info": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-1.5.0.tgz",
"integrity": "sha512-e8tSXZpw2hPl2uMJY6fsMswaok5FdlGNRTktvFk2sD8RjH0hE2+XistawJx1vmKteh4NmGmNUrp+Tb2w+udPcQ==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.1.tgz",
"integrity": "sha512-fE1UEWTwsAxRhrJNikE7v4EotYflkEhBL7EbajfkPlf6E37/2QshOy/D48Mw8G5XMFlQtS6YV42vtbG9zBpIQA==",
"dev": true,
"dependencies": {
"envinfo": "^7.7.3"
"engines": {
"node": ">=14.15.0"
},
"peerDependencies": {
"webpack-cli": "4.x.x"
"webpack": "5.x.x",
"webpack-cli": "5.x.x"
}
},
"node_modules/@webpack-cli/serve": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz",
"integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.1.tgz",
"integrity": "sha512-0G7tNyS+yW8TdgHwZKlDWYXFA6OJQnoLCQvYKkQP0Q2X205PSQ6RNUj0M+1OB/9gRQaUZ/ccYfaxd0nhaWKfjw==",
"dev": true,
"engines": {
"node": ">=14.15.0"
},
"peerDependencies": {
"webpack-cli": "4.x.x"
"webpack": "5.x.x",
"webpack-cli": "5.x.x"
},
"peerDependenciesMeta": {
"webpack-dev-server": {
@@ -8780,12 +8788,12 @@
}
},
"node_modules/interpret": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz",
"integrity": "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz",
"integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==",
"dev": true,
"engines": {
"node": ">= 0.10"
"node": ">=10.13.0"
}
},
"node_modules/ip": {
@@ -13439,9 +13447,9 @@
}
},
"node_modules/prettier": {
"version": "2.8.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz",
"integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==",
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz",
"integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
@@ -14220,15 +14228,15 @@
}
},
"node_modules/rechoir": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz",
"integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==",
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz",
"integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==",
"dev": true,
"dependencies": {
"resolve": "^1.9.0"
"resolve": "^1.20.0"
},
"engines": {
"node": ">= 0.10"
"node": ">= 10.13.0"
}
},
"node_modules/redent": {
@@ -16621,44 +16629,42 @@
}
},
"node_modules/webpack-cli": {
"version": "4.10.0",
"resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.10.0.tgz",
"integrity": "sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==",
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.0.1.tgz",
"integrity": "sha512-S3KVAyfwUqr0Mo/ur3NzIp6jnerNpo7GUO6so51mxLi1spqsA17YcMXy0WOIJtBSnj748lthxC6XLbNKh/ZC+A==",
"dev": true,
"dependencies": {
"@discoveryjs/json-ext": "^0.5.0",
"@webpack-cli/configtest": "^1.2.0",
"@webpack-cli/info": "^1.5.0",
"@webpack-cli/serve": "^1.7.0",
"@webpack-cli/configtest": "^2.0.1",
"@webpack-cli/info": "^2.0.1",
"@webpack-cli/serve": "^2.0.1",
"colorette": "^2.0.14",
"commander": "^7.0.0",
"commander": "^9.4.1",
"cross-spawn": "^7.0.3",
"envinfo": "^7.7.3",
"fastest-levenshtein": "^1.0.12",
"import-local": "^3.0.2",
"interpret": "^2.2.0",
"rechoir": "^0.7.0",
"interpret": "^3.1.1",
"rechoir": "^0.8.0",
"webpack-merge": "^5.7.3"
},
"bin": {
"webpack-cli": "bin/cli.js"
},
"engines": {
"node": ">=10.13.0"
"node": ">=14.15.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"peerDependencies": {
"webpack": "4.x.x || 5.x.x"
"webpack": "5.x.x"
},
"peerDependenciesMeta": {
"@webpack-cli/generators": {
"optional": true
},
"@webpack-cli/migrate": {
"optional": true
},
"webpack-bundle-analyzer": {
"optional": true
},
@@ -16668,12 +16674,12 @@
}
},
"node_modules/webpack-cli/node_modules/commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"dev": true,
"engines": {
"node": ">= 10"
"node": "^12.20.0 || >=14"
}
},
"node_modules/webpack-merge": {
@@ -17129,8 +17135,7 @@
}
},
"packages/ripple-binary-codec": {
"version": "1.5.0-beta.0",
"integrity": "sha512-XMRCbFXyG+dGp3x7tMs9IwA+FVWPPaGjdHYW2+g4Q/WQJqFp5MRED+jjOBOUafmrW4TUsOn1PEEdbB4ozWbDBw==",
"version": "1.4.2",
"license": "ISC",
"dependencies": {
"assert": "^2.0.0",
@@ -17176,7 +17181,7 @@
"https-proxy-agent": "^5.0.0",
"lodash": "^4.17.4",
"ripple-address-codec": "^4.2.4",
"ripple-binary-codec": "^1.5.0-beta.0",
"ripple-binary-codec": "^1.4.2",
"ripple-keypairs": "^1.1.4",
"ws": "^8.2.2"
},
@@ -19873,25 +19878,23 @@
}
},
"@webpack-cli/configtest": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz",
"integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.0.1.tgz",
"integrity": "sha512-njsdJXJSiS2iNbQVS0eT8A/KPnmyH4pv1APj2K0d1wrZcBLw+yppxOy4CGqa0OxDJkzfL/XELDhD8rocnIwB5A==",
"dev": true,
"requires": {}
},
"@webpack-cli/info": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-1.5.0.tgz",
"integrity": "sha512-e8tSXZpw2hPl2uMJY6fsMswaok5FdlGNRTktvFk2sD8RjH0hE2+XistawJx1vmKteh4NmGmNUrp+Tb2w+udPcQ==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.1.tgz",
"integrity": "sha512-fE1UEWTwsAxRhrJNikE7v4EotYflkEhBL7EbajfkPlf6E37/2QshOy/D48Mw8G5XMFlQtS6YV42vtbG9zBpIQA==",
"dev": true,
"requires": {
"envinfo": "^7.7.3"
}
"requires": {}
},
"@webpack-cli/serve": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz",
"integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.1.tgz",
"integrity": "sha512-0G7tNyS+yW8TdgHwZKlDWYXFA6OJQnoLCQvYKkQP0Q2X205PSQ6RNUj0M+1OB/9gRQaUZ/ccYfaxd0nhaWKfjw==",
"dev": true,
"requires": {}
},
@@ -24134,9 +24137,9 @@
}
},
"interpret": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz",
"integrity": "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz",
"integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==",
"dev": true
},
"ip": {
@@ -27838,9 +27841,9 @@
"dev": true
},
"prettier": {
"version": "2.8.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz",
"integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==",
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz",
"integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==",
"dev": true
},
"prettier-linter-helpers": {
@@ -28457,12 +28460,12 @@
}
},
"rechoir": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz",
"integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==",
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz",
"integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==",
"dev": true,
"requires": {
"resolve": "^1.9.0"
"resolve": "^1.20.0"
}
},
"redent": {
@@ -30285,29 +30288,30 @@
}
},
"webpack-cli": {
"version": "4.10.0",
"resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.10.0.tgz",
"integrity": "sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==",
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.0.1.tgz",
"integrity": "sha512-S3KVAyfwUqr0Mo/ur3NzIp6jnerNpo7GUO6so51mxLi1spqsA17YcMXy0WOIJtBSnj748lthxC6XLbNKh/ZC+A==",
"dev": true,
"requires": {
"@discoveryjs/json-ext": "^0.5.0",
"@webpack-cli/configtest": "^1.2.0",
"@webpack-cli/info": "^1.5.0",
"@webpack-cli/serve": "^1.7.0",
"@webpack-cli/configtest": "^2.0.1",
"@webpack-cli/info": "^2.0.1",
"@webpack-cli/serve": "^2.0.1",
"colorette": "^2.0.14",
"commander": "^7.0.0",
"commander": "^9.4.1",
"cross-spawn": "^7.0.3",
"envinfo": "^7.7.3",
"fastest-levenshtein": "^1.0.12",
"import-local": "^3.0.2",
"interpret": "^2.2.0",
"rechoir": "^0.7.0",
"interpret": "^3.1.1",
"rechoir": "^0.8.0",
"webpack-merge": "^5.7.3"
},
"dependencies": {
"commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"dev": true
}
}
@@ -30597,7 +30601,7 @@
"node-polyfill-webpack-plugin": "^2.0.1",
"react": "^18.2.0",
"ripple-address-codec": "^4.2.4",
"ripple-binary-codec": "^1.5.0-beta.0",
"ripple-binary-codec": "^1.4.2",
"ripple-keypairs": "^1.1.4",
"typedoc": "^0.23.24",
"ws": "^8.2.2"

View File

@@ -69,7 +69,7 @@
"url": "^0.11.0",
"webpack": "^5.6.0",
"webpack-bundle-analyzer": "^4.1.0",
"webpack-cli": "^4.2.0"
"webpack-cli": "^5.0.1"
},
"workspaces": [
"./packages/*"

View File

@@ -1,6 +1,6 @@
{
"name": "ripple-binary-codec",
"version": "1.5.0-beta.0",
"version": "1.4.2",
"description": "XRP Ledger binary codec",
"files": [
"dist/*",
@@ -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 test",
"test": "npm run build && jest --verbose false --silent=false ./test/*.test.js",
"prepare": "npm run build && npm test",
"test": "jest --verbose false --silent=false ./test/*.test.js",
"lint": "eslint . --ext .ts --ext .test.js"
},
"repository": {

View File

@@ -11,7 +11,6 @@ import { STObject } from './types/st-object'
import { JsonObject } from './types/serialized-type'
import { Buffer } from 'buffer/'
import bigInt = require('big-integer')
import { AmountObject } from './types/amount'
/**
* Construct a BinaryParser
@@ -96,7 +95,7 @@ function signingData(
*/
interface ClaimObject extends JsonObject {
channel: string
amount: AmountObject
amount: string | number
}
/**
@@ -106,19 +105,16 @@ interface ClaimObject extends JsonObject {
* @returns the serialized object with appropriate prefix
*/
function signingClaimData(claim: ClaimObject): Buffer {
const num = bigInt(String(claim.amount))
const prefix = HashPrefix.paymentChannelClaim
const channel = coreTypes.Hash256.from(claim.channel).toBytes()
const amount = coreTypes.UInt64.from(num).toBytes()
const bytesList = new BytesList()
bytesList.put(prefix)
bytesList.put(channel)
if (typeof claim.amount === 'string') {
const num = bigInt(String(claim.amount))
const amount = coreTypes.UInt64.from(num).toBytes()
bytesList.put(amount)
} else {
const amount = coreTypes.Amount.from(claim.amount).toBytes()
bytesList.put(amount)
}
bytesList.put(amount)
return bytesList.toBytes()
}

View File

@@ -21,8 +21,6 @@
"UInt192": 21,
"UInt384": 22,
"UInt512": 23,
"Issue": 24,
"XChainBridge": 25,
"Transaction": 10001,
"LedgerEntry": 10002,
"Validation": 10003,
@@ -36,11 +34,8 @@
"Ticket": 84,
"SignerList": 83,
"Offer": 111,
"Bridge": 105,
"LedgerHashes": 104,
"Amendments": 102,
"XChainClaimID": 113,
"XChainCreateAccountClaimID": 116,
"FeeSettings": 115,
"Escrow": 117,
"PayChannel": 120,
@@ -236,16 +231,6 @@
"type": "UInt8"
}
],
[
"WasLockingChainSend",
{
"nth": 19,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt8"
}
],
[
"LedgerEntryType",
{
@@ -336,6 +321,16 @@
"type": "UInt16"
}
],
[
"NetworkID",
{
"nth": 1,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt32"
}
],
[
"Flags",
{
@@ -776,16 +771,6 @@
"type": "UInt32"
}
],
[
"LockCount",
{
"nth": 49,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt32"
}
],
[
"IndexNext",
{
@@ -956,36 +941,6 @@
"type": "UInt64"
}
],
[
"XChainClaimID",
{
"nth": 20,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"XChainAccountCreateCount",
{
"nth": 21,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"XChainAccountClaimCount",
{
"nth": 22,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"EmailHash",
{
@@ -1476,36 +1431,6 @@
"type": "Amount"
}
],
[
"SignatureReward",
{
"nth": 29,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"MinAccountCreateAmount",
{
"nth": 30,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"LockedBalance",
{
"nth": 31,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"PublicKey",
{
@@ -1846,66 +1771,6 @@
"type": "AccountID"
}
],
[
"OtherChainSource",
{
"nth": 18,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "AccountID"
}
],
[
"OtherChainDestination",
{
"nth": 19,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "AccountID"
}
],
[
"AttestationSignerAccount",
{
"nth": 20,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "AccountID"
}
],
[
"AttestationRewardAccount",
{
"nth": 21,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "AccountID"
}
],
[
"LockingChainDoor",
{
"nth": 22,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "AccountID"
}
],
[
"IssuingChainDoor",
{
"nth": 23,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "AccountID"
}
],
[
"Indexes",
{
@@ -1956,36 +1821,6 @@
"type": "PathSet"
}
],
[
"LockingChainIssue",
{
"nth": 1,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Issue"
}
],
[
"IssuingChainIssue",
{
"nth": 2,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Issue"
}
],
[
"XChainBridge",
{
"nth": 1,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "XChainBridge"
}
],
[
"TransactionMetaData",
{
@@ -2196,46 +2031,6 @@
"type": "STObject"
}
],
[
"XChainClaimProofSig",
{
"nth": 32,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"XChainCreateAccountProofSig",
{
"nth": 33,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"XChainClaimAttestationBatchElement",
{
"nth": 34,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"XChainCreateAccountAttestationBatchElement",
{
"nth": 35,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STObject"
}
],
[
"Signers",
{
@@ -2375,46 +2170,6 @@
"isSigningField": true,
"type": "STArray"
}
],
[
"XChainClaimAttestationBatch",
{
"nth": 21,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
],
[
"XChainCreateAccountAttestationBatch",
{
"nth": 22,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
],
[
"XChainClaimAttestations",
{
"nth": 23,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
],
[
"XChainCreateAccountAttestations",
{
"nth": 24,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "STArray"
}
]
],
"TRANSACTION_RESULTS": {
@@ -2431,6 +2186,9 @@
"telCAN_NOT_QUEUE_BLOCKED": -389,
"telCAN_NOT_QUEUE_FEE": -388,
"telCAN_NOT_QUEUE_FULL": -387,
"telWRONG_NETWORK": -386,
"telREQUIRES_NETWORK_ID": -385,
"telNETWORK_ID_MAKES_TX_NON_CANONICAL": -384,
"temMALFORMED": -299,
"temBAD_AMOUNT": -298,
@@ -2470,15 +2228,6 @@
"temUNKNOWN": -264,
"temSEQ_AND_TICKET": -263,
"temBAD_NFTOKEN_TRANSFER_FEE": -262,
"temBAD_AMM_OPTIONS": -261,
"temBAD_AMM_TOKENS": -260,
"temEQUAL_DOOR_ACCOUNTS": -259,
"temBAD_XCHAIN_PROOF": -258,
"temSIDECHAIN_BAD_ISSUES": -257,
"temSIDECHAIN_NONDOOR_OWNER": -256,
"temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -255,
"temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -254,
"temXCHAIN_TOO_MANY_ATTESTATIONS": -253,
"tefFAILURE": -199,
"tefALREADY": -198,
@@ -2562,33 +2311,7 @@
"tecCANT_ACCEPT_OWN_NFTOKEN_OFFER": 158,
"tecINSUFFICIENT_FUNDS": 159,
"tecOBJECT_NOT_FOUND": 160,
"tecINSUFFICIENT_PAYMENT": 161,
"tecUNFUNDED_AMM": 162,
"tecAMM_BALANCE": 163,
"tecAMM_FAILED_DEPOSIT": 164,
"tecAMM_FAILED_WITHDRAW": 165,
"tecAMM_INVALID_TOKENS": 166,
"tecAMM_EXISTS": 167,
"tecAMM_FAILED_BID": 168,
"tecAMM_DIRECT_PAYMENT": 169,
"tecAMM_FAILED_VOTE": 170,
"tecBAD_XCHAIN_TRANSFER_ISSUE": 171,
"tecXCHAIN_NO_CLAIM_ID": 172,
"tecXCHAIN_BAD_CLAIM_ID": 173,
"tecXCHAIN_CLAIM_NO_QUORUM": 174,
"tecXCHAIN_PROOF_UNKNOWN_KEY": 175,
"tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 176,
"tecXCHAIN_WRONG_CHAIN": 177,
"tecXCHAIN_REWARD_MISMATCH": 178,
"tecXCHAIN_NO_SIGNERS_LIST": 179,
"tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 180,
"tecXCHAIN_INSUFF_CREATE_AMOUNT": 181,
"tecXCHAIN_ACCOUNT_CREATE_PAST": 182,
"tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 183,
"tecXCHAIN_PAYMENT_FAILED": 184,
"tecXCHAIN_SELF_COMMIT": 185,
"tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 186,
"tecPRECISION_LOSS": 187
"tecINSUFFICIENT_PAYMENT": 161
},
"TRANSACTION_TYPES": {
"Invalid": -1,
@@ -2620,14 +2343,6 @@
"NFTokenCreateOffer": 27,
"NFTokenCancelOffer": 28,
"NFTokenAcceptOffer": 29,
"XChainCreateBridge": 40,
"XChainCreateClaimID": 41,
"XChainCommit": 42,
"XChainClaim": 43,
"XChainAccountCreateCommit": 44,
"XChainAddClaimAttestation": 45,
"XChainAddAccountCreateAttestation": 46,
"XChainModifyBridge": 47,
"EnableAmendment": 100,
"SetFee": 101,
"UNLModify": 102

View File

@@ -11,7 +11,6 @@ import { Currency } from './currency'
import { Hash128 } from './hash-128'
import { Hash160 } from './hash-160'
import { Hash256 } from './hash-256'
import { Issue } from './issue'
import { PathSet } from './path-set'
import { STArray } from './st-array'
import { STObject } from './st-object'
@@ -20,7 +19,6 @@ import { UInt32 } from './uint-32'
import { UInt64 } from './uint-64'
import { UInt8 } from './uint-8'
import { Vector256 } from './vector-256'
import { XChainBridge } from './xchain-bridge'
const coreTypes = {
AccountID,
@@ -30,7 +28,6 @@ const coreTypes = {
Hash128,
Hash160,
Hash256,
Issue,
PathSet,
STArray,
STObject,
@@ -39,7 +36,6 @@ const coreTypes = {
UInt32,
UInt64,
Vector256,
XChainBridge,
}
Object.values(Field).forEach((field) => {

View File

@@ -1,96 +0,0 @@
import { BinaryParser } from '../serdes/binary-parser'
import { AccountID } from './account-id'
import { Currency } from './currency'
import { JsonObject, SerializedType } from './serialized-type'
import { Buffer } from 'buffer/'
/**
* Interface for JSON objects that represent amounts
*/
interface IssueObject extends JsonObject {
currency: string
issuer?: string
}
/**
* Type guard for AmountObject
*/
function isIssueObject(arg): arg is IssueObject {
const keys = Object.keys(arg).sort()
if (keys.length === 1) {
return keys[0] === 'currency'
}
return keys.length === 2 && keys[0] === 'currency' && keys[1] === 'issuer'
}
/**
* Class for serializing/Deserializing Amounts
*/
class Issue extends SerializedType {
static readonly ZERO_ISSUED_CURRENCY: Issue = new Issue(Buffer.alloc(20))
constructor(bytes: Buffer) {
super(bytes ?? Issue.ZERO_ISSUED_CURRENCY.bytes)
}
/**
* Construct an amount from an IOU or string amount
*
* @param value An Amount, object representing an IOU, or a string
* representing an integer amount
* @returns An Amount object
*/
static from<T extends Issue | IssueObject>(value: T): Issue {
if (value instanceof Issue) {
return value
}
if (isIssueObject(value)) {
const currency = Currency.from(value.currency).toBytes()
if (value.issuer == null) {
return new Issue(currency)
}
const issuer = AccountID.from(value.issuer).toBytes()
return new Issue(Buffer.concat([currency, issuer]))
}
throw new Error('Invalid type to construct an Amount')
}
/**
* Read an amount from a BinaryParser
*
* @param parser BinaryParser to read the Amount from
* @returns An Amount object
*/
static fromParser(parser: BinaryParser): Issue {
const currency = parser.read(20)
if (new Currency(currency).toJSON() === 'XRP') {
return new Issue(currency)
}
const currencyAndIssuer = [currency, parser.read(20)]
return new Issue(Buffer.concat(currencyAndIssuer))
}
/**
* Get the JSON representation of this Amount
*
* @returns the JSON interpretation of this.bytes
*/
toJSON(): IssueObject {
const parser = new BinaryParser(this.toString())
const currency = Currency.fromParser(parser) as Currency
if (currency.toJSON() === 'XRP') {
return { currency: currency.toJSON() }
}
const issuer = AccountID.fromParser(parser) as AccountID
return {
currency: currency.toJSON(),
issuer: issuer.toJSON(),
}
}
}
export { Issue, IssueObject }

View File

@@ -1,128 +0,0 @@
import { BinaryParser } from '../serdes/binary-parser'
import { AccountID } from './account-id'
import { JsonObject, SerializedType } from './serialized-type'
import { Buffer } from 'buffer/'
import { Issue, IssueObject } from './issue'
/**
* Interface for JSON objects that represent cross-chain bridges
*/
interface XChainBridgeObject extends JsonObject {
LockingChainDoor: string
LockingChainIssue: IssueObject | string
IssuingChainDoor: string
IssuingChainIssue: IssueObject | string
}
/**
* Type guard for XChainBridgeObject
*/
function isXChainBridgeObject(arg): arg is XChainBridgeObject {
const keys = Object.keys(arg).sort()
return (
keys.length === 4 &&
keys[0] === 'IssuingChainDoor' &&
keys[1] === 'IssuingChainIssue' &&
keys[2] === 'LockingChainDoor' &&
keys[3] === 'LockingChainIssue'
)
}
/**
* Class for serializing/deserializing XChainBridges
*/
class XChainBridge extends SerializedType {
static readonly ZERO_XCHAIN_BRIDGE: XChainBridge = new XChainBridge(
Buffer.concat([
Buffer.from([0x14]),
Buffer.alloc(40),
Buffer.from([0x14]),
Buffer.alloc(40),
]),
)
static readonly TYPE_ORDER: { name: string; type: typeof SerializedType }[] =
[
{ name: 'LockingChainDoor', type: AccountID },
{ name: 'LockingChainIssue', type: Issue },
{ name: 'IssuingChainDoor', type: AccountID },
{ name: 'IssuingChainIssue', type: Issue },
]
constructor(bytes: Buffer) {
super(bytes ?? XChainBridge.ZERO_XCHAIN_BRIDGE.bytes)
}
/**
* Construct a cross-chain bridge from a JSON
*
* @param value XChainBridge or JSON to parse into a XChainBridge
* @returns A XChainBridge object
*/
static from<T extends XChainBridge | XChainBridgeObject>(
value: T,
): XChainBridge {
if (value instanceof XChainBridge) {
return value
}
if (isXChainBridgeObject(value)) {
const bytes: Array<Buffer> = []
this.TYPE_ORDER.forEach((item) => {
const { name, type } = item
if (type === AccountID) {
bytes.push(Buffer.from([0x14]))
}
const object = type.from(value[name])
bytes.push(object.toBytes())
})
return new XChainBridge(Buffer.concat(bytes))
}
throw new Error('Invalid type to construct a XChainBridge')
}
/**
* Read a XChainBridge from a BinaryParser
*
* @param parser BinaryParser to read the XChainBridge from
* @returns A XChainBridge object
*/
static fromParser(parser: BinaryParser): XChainBridge {
const bytes: Array<Buffer> = []
this.TYPE_ORDER.forEach((item) => {
const { type } = item
if (type === AccountID) {
parser.skip(1)
bytes.push(Buffer.from([0x14]))
}
const object = type.fromParser(parser)
bytes.push(object.toBytes())
})
return new XChainBridge(Buffer.concat(bytes))
}
/**
* Get the JSON representation of this XChainBridge
*
* @returns the JSON interpretation of this.bytes
*/
toJSON(): XChainBridgeObject {
const parser = new BinaryParser(this.toString())
const json = {}
XChainBridge.TYPE_ORDER.forEach((item) => {
const { name, type } = item
if (type === AccountID) {
parser.skip(1)
}
const object = type.fromParser(parser).toJSON()
json[name] = object
})
return json as XChainBridgeObject
}
}
export { XChainBridge, XChainBridgeObject }

View File

@@ -4435,207 +4435,20 @@
}
}
],
"transactions": [
{
"binary": "1200002200000000240000003E6140000002540BE40068400000000000000A7321034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E74473045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F17962646398114550FC62003E785DC231A1058A05E56E3F09CF4E68314D4CC8AB5B21D86A82C3E9E8D0ECF2404B77FECBA",
"json": {
"Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj",
"TransactionType": "Payment",
"TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639",
"SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E",
"Amount": "10000000000",
"Fee": "10",
"Flags": 0,
"Sequence": 62
}
},
{
"binary": "1200282200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000",
"json": {
"Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"XChainBridge": {
"LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL",
"LockingChainIssue": {"currency": "XRP"},
"IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"IssuingChainIssue": {"currency": "XRP"}
},
"Fee": "10",
"Flags": 0,
"MinAccountCreateAmount": "10000",
"Sequence": 1,
"SignatureReward": "1000",
"SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
"TransactionType": "XChainCreateBridge",
"TxnSignature": "30440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A27091"
}
},
{
"binary": "12002F2200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000",
"json": {
"Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"XChainBridge": {
"LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL",
"LockingChainIssue": {"currency": "XRP"},
"IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"IssuingChainIssue": {"currency": "XRP"}
},
"Fee": "10",
"Flags": 0,
"MinAccountCreateAmount": "10000",
"Sequence": 1,
"SignatureReward": "1000",
"SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
"TransactionType": "XChainModifyBridge",
"TxnSignature": "3045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E5"
}
},
{
"binary": "1200292280000000240000000168400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000",
"json": {
"Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"XChainBridge": {
"LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL",
"LockingChainIssue": {"currency": "XRP"},
"IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"IssuingChainIssue": {"currency": "XRP"}
},
"Fee": "10",
"Flags": 2147483648,
"OtherChainSource": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL",
"Sequence": 1,
"SignatureReward": "10000",
"SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
"TransactionType": "XChainCreateClaimID",
"TxnSignature": "30440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD"
}
},
{
"binary": "12002A228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074453043021F177323F0D93612C82A4393A99B23905A7E675753FD80C52997AFAB13F5F9D002203BFFAF457E90BDA65AABE8F8762BD96162FAD98A0C030CCD69B06EE9B12BBFFE8114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000",
"json": {
"Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"Amount": "10000",
"XChainBridge": {
"LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL",
"LockingChainIssue": {"currency": "XRP"},
"IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"IssuingChainIssue": {"currency": "XRP"}
},
"Fee": "10",
"Flags": 2147483648,
"Sequence": 1,
"SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
"TransactionType": "XChainCommit",
"TxnSignature": "3043021F177323F0D93612C82A4393A99B23905A7E675753FD80C52997AFAB13F5F9D002203BFFAF457E90BDA65AABE8F8762BD96162FAD98A0C030CCD69B06EE9B12BBFFE",
"XChainClaimID": "0000000000000001"
}
},
{
"binary": "12002B228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220445F7469FDA401787D9EE8A9B6E24DFF81E94F4C09FD311D2C0A58FCC02C684A022029E2EF34A5EA35F50D5BB57AC6320AD3AE12C13C8D1379B255A486D72CED142E8114B5F762798A53D543A014CAF8B297CFF8F2F937E88314550FC62003E785DC231A1058A05E56E3F09CF4E6011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000",
"json": {
"Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"Amount": "10000",
"XChainBridge": {
"LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL",
"LockingChainIssue": {"currency": "XRP"},
"IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"IssuingChainIssue": {"currency": "XRP"}
},
"Destination": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"Fee": "10",
"Flags": 2147483648,
"Sequence": 1,
"SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
"TransactionType": "XChainClaim",
"TxnSignature": "30440220445F7469FDA401787D9EE8A9B6E24DFF81E94F4C09FD311D2C0A58FCC02C684A022029E2EF34A5EA35F50D5BB57AC6320AD3AE12C13C8D1379B255A486D72CED142E",
"XChainClaimID": "0000000000000001"
}
},
{
"binary": "12002C228000000024000000016140000000000F424068400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000",
"json": {
"Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"XChainBridge": {
"LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL",
"LockingChainIssue": {"currency": "XRP"},
"IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"IssuingChainIssue": {"currency": "XRP"}
},
"Amount": "1000000",
"Fee": "10",
"Flags": 2147483648,
"Destination": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL",
"Sequence": 1,
"SignatureReward": "10000",
"SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
"TransactionType": "XChainAccountCreateCommit",
"TxnSignature": "304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF18"
}
},
{
"binary": "12002E2400000005201B0000000D30150000000000000006614000000000989680684000000000000014601D40000000000000647121ED1F4A024ACFEBDB6C7AA88DEDE3364E060487EA31B14CC9E0D610D152B31AADC27321EDF54108BA2E0A0D3DC2AE3897F8BE0EFE776AE8D0F9FB0D0B9D64233084A8DDD1744003E74AEF1F585F156786429D2FC87A89E5C6B5A56D68BFC9A6A329F3AC67CBF2B6958283C663A4522278CA162C69B23CF75149AF022B410EA0508C16F42058007640EEFCFA3DC2AB4AB7C4D2EBBC168CB621A11B82BABD86534DFC8EFA72439A49662D744073CD848E7A587A95B35162CDF9A69BB237E72C9537A987F5B8C394F30D81145E7A3E3D7200A794FA801C66CE3775B6416EE4128314C15F113E49BCC4B9FFF43CD0366C23ACD82F75638012143FD9ED9A79DEA67CB5D585111FEF0A29203FA0408014145E7A3E3D7200A794FA801C66CE3775B6416EE4128015145E7A3E3D7200A794FA801C66CE3775B6416EE4120010130101191486F0B1126CE1205E59FDFDD2661A9FB7505CA70F000000000000000000000000000000000000000014B5F762798A53D543A014CAF8B297CFF8F2F937E80000000000000000000000000000000000000000",
"json": {
"Account": "r9cYxdjQsoXAEz3qQJc961SNLaXRkWXCvT",
"Amount": "10000000",
"AttestationRewardAccount": "r9cYxdjQsoXAEz3qQJc961SNLaXRkWXCvT",
"AttestationSignerAccount": "r9cYxdjQsoXAEz3qQJc961SNLaXRkWXCvT",
"Destination": "rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi",
"Fee": "20",
"LastLedgerSequence": 13,
"OtherChainSource": "raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym",
"PublicKey": "ED1F4A024ACFEBDB6C7AA88DEDE3364E060487EA31B14CC9E0D610D152B31AADC2",
"Sequence": 5,
"Signature": "EEFCFA3DC2AB4AB7C4D2EBBC168CB621A11B82BABD86534DFC8EFA72439A49662D744073CD848E7A587A95B35162CDF9A69BB237E72C9537A987F5B8C394F30D",
"SignatureReward": "100",
"SigningPubKey": "EDF54108BA2E0A0D3DC2AE3897F8BE0EFE776AE8D0F9FB0D0B9D64233084A8DDD1",
"TransactionType": "XChainAddAccountCreateAttestation",
"TxnSignature": "03E74AEF1F585F156786429D2FC87A89E5C6B5A56D68BFC9A6A329F3AC67CBF2B6958283C663A4522278CA162C69B23CF75149AF022B410EA0508C16F4205800",
"WasLockingChainSend": 1,
"XChainAccountCreateCount": "0000000000000006",
"XChainBridge": {
"IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"IssuingChainIssue": {
"currency": "XRP"
},
"LockingChainDoor": "rDJVtEuDKr4rj1B3qtW7R5TVWdXV2DY7Qg",
"LockingChainIssue": {
"currency": "XRP"
}
}
}
},
{
"binary": "12002D2400000009201B00000013301400000000000000016140000000009896806840000000000000147121ED7541DEC700470F54276C90C333A13CDBB5D341FD43C60CEA12170F6D6D4E11367321ED0406B134786FE0751717226657F7BF8AFE96442C05D28ACEC66FB64852BA604C7440D0423649E48A44F181262CF5FC08A68E7FA5CD9E55843E4F09014B76E602574741E8553383A4B43CABD194BB96713647FC0B885BE248E4FFA068FA3E6994CF0476407C175050B08000AD35EEB2D87E16CD3F95A0AEEBF2A049474275153D9D4DD44528FE99AA50E71660A15B0B768E1B90E609BBD5DC7AFAFD45D9705D72D40EA10C81141F30A4D728AB98B0950EC3B9815E6C8D43A7D5598314C15F113E49BCC4B9FFF43CD0366C23ACD82F75638012143FD9ED9A79DEA67CB5D585111FEF0A29203FA0408014141F30A4D728AB98B0950EC3B9815E6C8D43A7D5598015141F30A4D728AB98B0950EC3B9815E6C8D43A7D5590010130101191486F0B1126CE1205E59FDFDD2661A9FB7505CA70F000000000000000000000000000000000000000014B5F762798A53D543A014CAF8B297CFF8F2F937E80000000000000000000000000000000000000000",
"json": {
"Account": "rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3",
"Amount": "10000000",
"AttestationRewardAccount": "rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3",
"AttestationSignerAccount": "rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3",
"Destination": "rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi",
"Fee": "20",
"LastLedgerSequence": 19,
"OtherChainSource": "raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym",
"PublicKey": "ED7541DEC700470F54276C90C333A13CDBB5D341FD43C60CEA12170F6D6D4E1136",
"Sequence": 9,
"Signature": "7C175050B08000AD35EEB2D87E16CD3F95A0AEEBF2A049474275153D9D4DD44528FE99AA50E71660A15B0B768E1B90E609BBD5DC7AFAFD45D9705D72D40EA10C",
"SigningPubKey": "ED0406B134786FE0751717226657F7BF8AFE96442C05D28ACEC66FB64852BA604C",
"TransactionType": "XChainAddClaimAttestation",
"TxnSignature": "D0423649E48A44F181262CF5FC08A68E7FA5CD9E55843E4F09014B76E602574741E8553383A4B43CABD194BB96713647FC0B885BE248E4FFA068FA3E6994CF04",
"WasLockingChainSend": 1,
"XChainBridge": {
"IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"IssuingChainIssue": {
"currency": "XRP"
},
"LockingChainDoor": "rDJVtEuDKr4rj1B3qtW7R5TVWdXV2DY7Qg",
"LockingChainIssue": {
"currency": "XRP"
}
},
"XChainClaimID": "0000000000000001"
}
"transactions": [{
"binary": "1200002200000000240000003E6140000002540BE40068400000000000000A7321034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E74473045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F17962646398114550FC62003E785DC231A1058A05E56E3F09CF4E68314D4CC8AB5B21D86A82C3E9E8D0ECF2404B77FECBA",
"json": {
"Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
"Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj",
"TransactionType": "Payment",
"TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639",
"SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E",
"Amount": "10000000000",
"Fee": "10",
"Flags": 0,
"Sequence": 62
}
],
}],
"ledgerData": [{
"binary": "01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00",
"json": {
@@ -4650,4 +4463,4 @@
"transaction_hash": "DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87"
}
}]
}
}

View File

@@ -120,7 +120,7 @@ describe('Signing data', function () {
].join(''),
)
})
test('can create native claim blob', function () {
test('can create claim blob', function () {
const channel =
'43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1'
const amount = '1000'
@@ -137,27 +137,4 @@ describe('Signing data', function () {
].join(''),
)
})
test('can create ic claim blob', function () {
const channel =
'43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1'
const amount = {
issuer: 'rJZdUusLDtY9NEsGea7ijqhVrXv98rYBYN',
currency: 'USD',
value: '10',
}
const json = { channel, amount }
const actual = encodeForSigningClaim(json)
expect(actual).toBe(
[
// hash prefix
'434C4D00',
// channel ID
'43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1',
// amount as a uint64
'D4C38D7EA4C680000000000000000000000000005553440000000000C0A5ABEF',
// amount as a uint64
'242802EFED4B041E8F2D4A8CC86AE3D1',
].join(''),
)
})
})

View File

@@ -1,5 +1,5 @@
import assert from 'assert'
import fixtures from './fixtures/api.json'
import * as fixtures from './fixtures/api.json'
import * as api from '../src'
const decodeSeed = api.decodeSeed

View File

@@ -10,6 +10,7 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
* Improved typescript typing
### Added
- `getNFTokenID` lets you get the NFTokenID after minting an NFT
### Changed
@@ -26,7 +27,7 @@ Wallet.fromMmnemonic()
### Added
* Optional custom amount field to `fundWallet`.
* Support for the cross-chain bridge feature.
* Support for `disallowIncoming` account set flags (e.g. `asfDisallowIncomingTrustline`)
### Changed
* Add support for Transaction objects in `verifyTransaction`

View File

@@ -28,7 +28,7 @@
"https-proxy-agent": "^5.0.0",
"lodash": "^4.17.4",
"ripple-address-codec": "^4.2.4",
"ripple-binary-codec": "^1.5.0-beta.0",
"ripple-binary-codec": "^1.4.2",
"ripple-keypairs": "^1.1.4",
"ws": "^8.2.2"
},

View File

@@ -1,5 +1,4 @@
/* eslint-disable max-lines -- Connection is a large file w/ lots of imports/exports */
import { EventEmitter } from 'events'
import { Agent } from 'http'

View File

@@ -4,7 +4,7 @@ interface XRP {
currency: 'XRP'
}
export interface IssuedCurrency {
interface IssuedCurrency {
currency: string
issuer: string
}
@@ -117,10 +117,3 @@ export interface NFTOffer {
destination?: string
expiration?: number
}
export interface XChainBridge {
LockingChainDoor: string
LockingChainIssue: Currency
IssuingChainDoor: string
IssuingChainIssue: Currency
}

View File

@@ -116,6 +116,22 @@ export interface AccountRootFlagsInterface {
* (It has DepositAuth enabled.)
*/
lsfDepositAuth?: boolean
/**
* Disallow incoming NFTOffers from other accounts.
*/
lsfDisallowIncomingNFTOffer?: boolean
/**
* Disallow incoming Checks from other accounts.
*/
lsfDisallowIncomingCheck?: boolean
/**
* Disallow incoming PayChannels from other accounts.
*/
lsfDisallowIncomingPayChan?: boolean
/**
* Disallow incoming Trustlines from other accounts.
*/
lsfDisallowIncomingTrustline?: boolean
}
export enum AccountRootFlags {
@@ -156,4 +172,20 @@ export enum AccountRootFlags {
* (It has DepositAuth enabled.)
*/
lsfDepositAuth = 0x01000000,
/**
* Disallow incoming NFTOffers from other accounts.
*/
lsfDisallowIncomingNFTOffer = 0x04000000,
/**
* Disallow incoming Checks from other accounts.
*/
lsfDisallowIncomingCheck = 0x08000000,
/**
* Disallow incoming PayChannels from other accounts.
*/
lsfDisallowIncomingPayChan = 0x10000000,
/**
* Disallow incoming Trustlines from other accounts.
*/
lsfDisallowIncomingTrustline = 0x20000000,
}

View File

@@ -1,41 +0,0 @@
import { Amount, XChainBridge } from '../common'
import BaseLedgerEntry from './BaseLedgerEntry'
export default interface Bridge extends BaseLedgerEntry {
LedgerEntryType: 'Bridge'
Account: string
SignatureReward: Amount
MinAccountCreateAmount?: string
XChainBridge: XChainBridge
XChainClaimID: string
XChainAccountCreateCount: number
XChainAccountClaimCount: Amount
/**
* A bit-map of boolean flags. No flags are defined for Bridges, so this value
* is always 0.
*/
Flags: 0
/**
* A hint indicating which page of the sender's owner directory links to this
* object, in case the directory consists of multiple pages.
*/
OwnerNode: string
/**
* The identifying hash of the transaction that most recently modified this
* object.
*/
PreviousTxnID: string
/**
* The index of the ledger that contains the transaction that most recently
* modified this object.
*/
PreviousTxnLgrSeq: number
}

View File

@@ -1,9 +1,7 @@
import { Amount } from '../common'
import BaseLedgerEntry from './BaseLedgerEntry'
/**
* The Escrow object type represents a held payment waiting to be
* The Escrow object type represents a held payment of XRP waiting to be
* executed or canceled.
*
* @category Ledger Entries
@@ -12,17 +10,17 @@ export default interface Escrow extends BaseLedgerEntry {
LedgerEntryType: 'Escrow'
/**
* The address of the owner (sender) of this held payment. This is the
* account that provided the amounts, and gets it back if the held payment is
* account that provided the XRP, and gets it back if the held payment is
* canceled.
*/
Account: string
/**
* The destination address where the amounts are paid if the held payment is
* The destination address where the XRP is paid if the held payment is
* successful.
*/
Destination: string
/** The amount to be delivered by the held payment. */
Amount: Amount
/** The amount of XRP, in drops, to be delivered by the held payment. */
Amount: string
/**
* A PREIMAGE-SHA-256 crypto-condition, as hexadecimal. If present, the
* EscrowFinish transaction must contain a fulfillment that satisfies this
@@ -73,9 +71,4 @@ export default interface Escrow extends BaseLedgerEntry {
* modified this object.
*/
PreviousTxnLgrSeq: number
/**
* The fee to charge when users finish an escrow, initially set on the
* creation of an escrow contract, and updated on subsequent finish transactions
*/
TransferRate?: number
}

View File

@@ -1,11 +1,9 @@
import { Amount } from '../common'
import BaseLedgerEntry from './BaseLedgerEntry'
/**
* The PayChannel object type represents a payment channel. Payment channels
* enable small, rapid off-ledger payments that can be later reconciled
* with the consensus ledger. A payment channel holds a balance that can
* enable small, rapid off-ledger payments of XRP that can be later reconciled
* with the consensus ledger. A payment channel holds a balance of XRP that can
* only be paid out to a specific destination address until the channel is
* closed.
*
@@ -20,37 +18,37 @@ export default interface PayChannel extends BaseLedgerEntry {
Account: string
/**
* The destination address for this payment channel. While the payment
* channel is open, this address is the only one that can receive amounts from the
* channel is open, this address is the only one that can receive XRP from the
* channel. This comes from the Destination field of the transaction that
* created the channel.
*/
Destination: string
/**
* Total amount that has been allocated to this channel. This includes amounts
* that have been paid to the destination address. This is initially set by the
* transaction that created the channel and can be increased if the source
* address sends a PaymentChannelFund transaction.
* Total XRP, in drops, that has been allocated to this channel. This
* includes XRP that has been paid to the destination address. This is
* initially set by the transaction that created the channel and can be
* increased if the source address sends a PaymentChannelFund transaction.
*/
Amount: Amount
Amount: string
/**
* Total amount already paid out by the channel. The difference between this value
* and the Amount field is how much can still be paid to the destination address
* with PaymentChannelClaim transactions. If the channel closes, the remaining
* difference is returned to the source address.
* Total XRP, in drops, already paid out by the channel. The difference
* between this value and the Amount field is how much XRP can still be paid
* to the destination address with PaymentChannelClaim transactions. If the
* channel closes, the remaining difference is returned to the source address.
*/
Balance: Amount
Balance: string
/**
* Public key, in hexadecimal, of the key pair that can be used to sign
* claims against this channel. This can be any valid secp256k1 or Ed25519
* public key. This is set by the transaction that created the channel and
* must match the public key used in claims against the channel. The channel
* source address can also send amounts from this channel to the destination
* source address can also send XRP from this channel to the destination
* without signed claims.
*/
PublicKey: string
/**
* Number of seconds the source address must wait to close the channel if
* it still has any amount in it. Smaller values mean that the destination
* it still has any XRP in it. Smaller values mean that the destination
* address has less time to redeem any outstanding claims after the source
* address requests to close the channel. Can be any value that fits in a
* 32-bit unsigned integer (0 to 2^32-1). This is set by the transaction that
@@ -106,10 +104,4 @@ export default interface PayChannel extends BaseLedgerEntry {
* this object, in case the directory consists of multiple pages.
*/
DestinationNode?: string
/**
* The fee to charge when users make claims on a payment channel, initially
* set on the creation of a payment channel and updated on subsequent funding
* or claim transactions.
*/
TransferRate?: number
}

View File

@@ -1,40 +0,0 @@
import { XChainBridge } from '../common'
import BaseLedgerEntry from './BaseLedgerEntry'
export default interface XChainOwnedClaimID extends BaseLedgerEntry {
LedgerEntryType: 'XChainOwnedClaimID'
Account: string
XChainBridge: XChainBridge
XChainClaimID: string
OtherChainSource: string
// TODO: type this better
XChainClaimAttestations: object[]
SignatureReward: string
/**
* A bit-map of boolean flags. No flags are defined for XChainOwnedClaimIDs,
* so this value is always 0.
*/
Flags: 0
/**
* A hint indicating which page of the sender's owner directory links to this
* object, in case the directory consists of multiple pages.
*/
OwnerNode: string
/**
* The identifying hash of the transaction that most recently modified this
* object.
*/
PreviousTxnID: string
/**
* The index of the ledger that contains the transaction that most recently
* modified this object.
*/
PreviousTxnLgrSeq: number
}

View File

@@ -1,37 +0,0 @@
import { XChainBridge } from '../common'
import BaseLedgerEntry from './BaseLedgerEntry'
export default interface XChainOwnedCreateAccountClaimID
extends BaseLedgerEntry {
LedgerEntryType: 'XChainOwnedCreateAccountClaimID'
Account: string
XChainBridge: XChainBridge
XChainAccountCreateCount: number
// TODO: type this better
XChainCreateAccountAttestations: object[]
/**
* A bit-map of boolean flags. No flags are defined for,
* XChainOwnedCreateAccountClaimIDs, so this value is always 0.
*/
Flags: 0
/**
* A hint indicating which page of the sender's owner directory links to this
* object, in case the directory consists of multiple pages.
*/
OwnerNode: string
/**
* The identifying hash of the transaction that most recently modified this
* object.
*/
PreviousTxnID: string
/**
* The index of the ledger that contains the transaction that most recently
* modified this object.
*/
PreviousTxnLgrSeq: number
}

View File

@@ -3,7 +3,6 @@ import AccountRoot, {
AccountRootFlagsInterface,
} from './AccountRoot'
import Amendments from './Amendments'
import Bridge from './Bridge'
import Check from './Check'
import DepositPreauth from './DepositPreauth'
import DirectoryNode from './DirectoryNode'
@@ -18,15 +17,12 @@ import PayChannel from './PayChannel'
import RippleState, { RippleStateFlags } from './RippleState'
import SignerList, { SignerListFlags } from './SignerList'
import Ticket from './Ticket'
import XChainOwnedClaimID from './XChainOwnedClaimID'
import XChainOwnedCreateAccountClaimID from './XChainOwnedCreateAccountClaimID'
export {
AccountRoot,
AccountRootFlags,
AccountRootFlagsInterface,
Amendments,
Bridge,
Check,
DepositPreauth,
DirectoryNode,
@@ -44,6 +40,4 @@ export {
SignerList,
SignerListFlags,
Ticket,
XChainOwnedClaimID,
XChainOwnedCreateAccountClaimID,
}

View File

@@ -1,10 +1,10 @@
import { Amount, LedgerIndex } from '../common'
import { LedgerIndex } from '../common'
import { BaseRequest, BaseResponse } from './baseMethod'
interface Channel {
account: string
amount: Amount
amount: string
balance: string
channel_id: string
destination_account: string
@@ -15,7 +15,6 @@ interface Channel {
cancel_after?: number
source_tab?: number
destination_tag?: number
transfer_rate?: number
}
/**

View File

@@ -1,4 +1,4 @@
import { Amount, LedgerIndex } from '../common'
import { LedgerIndex } from '../common'
import { BaseRequest, BaseResponse } from './baseMethod'
@@ -64,14 +64,6 @@ export interface Trustline {
* false.
*/
freeze_peer?: boolean
/**
* The total amount of FT, in drops/Amount locked in payment channels or escrow.
*/
locked_balance?: Amount
/**
* The total number of lock balances on a RippleState ledger object.
*/
lock_count?: number
}
/**

View File

@@ -29,7 +29,7 @@ export interface AccountNFTsRequest extends BaseRequest {
*
* @category Responses
*/
interface AccountNFToken {
export interface AccountNFToken {
Flags: number
Issuer: string
NFTokenID: string

View File

@@ -8,8 +8,6 @@ import {
RippleState,
SignerList,
Ticket,
XChainOwnedClaimID,
XChainOwnedCreateAccountClaimID,
} from '../ledger'
import { BaseRequest, BaseResponse } from './baseMethod'
@@ -24,8 +22,6 @@ type AccountObjectType =
| 'signer_list'
| 'state'
| 'ticket'
| 'xchain_create_account_claim_id'
| 'xchain_claim_id'
/**
* The account_objects command returns the raw ledger format for all objects
@@ -82,8 +78,6 @@ type AccountObject =
| SignerList
| RippleState
| Ticket
| XChainOwnedClaimID
| XChainOwnedCreateAccountClaimID
/**
* Response expected from an {@link AccountObjectsRequest}.

View File

@@ -9,7 +9,7 @@ import { BaseRequest, BaseResponse } from './baseMethod'
*/
export interface ChannelVerifyRequest extends BaseRequest {
command: 'channel_verify'
/** The amount the provided signature authorizes. */
/** The amount of XRP, in drops, the provided signature authorizes. */
amount: string
/**
* The Channel ID of the channel that provides the XRP. This is a

View File

@@ -1,4 +1,4 @@
import { Currency, LedgerIndex } from '../common'
import { LedgerIndex } from '../common'
import { LedgerEntry } from '../ledger'
import { BaseRequest, BaseResponse } from './baseMethod'
@@ -137,28 +137,6 @@ export interface LedgerEntryRequest extends BaseRequest {
ticket_sequence: number
}
| string
bridge_account?: string
xchain_claim_id?:
| {
locking_chain_door: string
locking_chain_issue: Currency
issuing_chain_door: string
issuing_chain_issue: Currency
xchain_claim_id: string | number
}
| string
xchain_create_account_claim_id?:
| {
locking_chain_door: string
locking_chain_issue: Currency
issuing_chain_door: string
issuing_chain_issue: Currency
xchain_create_account_claim_id: string | number
}
| string
}
/**

View File

@@ -136,6 +136,10 @@ export interface ServerInfoResponse extends BaseResponse {
* overall network's load factor.
*/
load_factor?: number
/**
* The network id of the server.
*/
network_id?: number
/**
* Current multiplier to the transaction cost based on
* load to this server.

View File

@@ -1,85 +0,0 @@
import { ValidationError } from '../../errors'
import { Amount, XChainBridge } from '../common'
import {
BaseTransaction,
isAmount,
isXChainBridge,
validateBaseTransaction,
} from './common'
/**
*
* @category Transaction Models
*/
export interface XChainAccountCreateCommit extends BaseTransaction {
TransactionType: 'XChainAccountCreateCommit'
XChainBridge: XChainBridge
SignatureReward: number | string
Destination: string
Amount: Amount
}
/**
* Verify the form and type of a XChainAccountCreateCommit at runtime.
*
* @param tx - A XChainAccountCreateCommit Transaction.
* @throws When the XChainAccountCreateCommit is malformed.
*/
// eslint-disable-next-line max-lines-per-function -- okay for this function, there's a lot of things to check
export function validateXChainAccountCreateCommit(
tx: Record<string, unknown>,
): void {
validateBaseTransaction(tx)
if (tx.XChainBridge == null) {
throw new ValidationError(
'XChainAccountCreateCommit: missing field XChainBridge',
)
}
if (!isXChainBridge(tx.XChainBridge)) {
throw new ValidationError(
'XChainAccountCreateCommit: invalid field XChainBridge',
)
}
if (tx.SignatureReward == null) {
throw new ValidationError(
'XChainAccountCreateCommit: missing field SignatureReward',
)
}
if (
typeof tx.SignatureReward !== 'number' &&
typeof tx.SignatureReward !== 'string'
) {
throw new ValidationError(
'XChainAccountCreateCommit: invalid field SignatureReward',
)
}
if (tx.Destination == null) {
throw new ValidationError(
'XChainAccountCreateCommit: missing field Destination',
)
}
if (typeof tx.Destination !== 'string') {
throw new ValidationError(
'XChainAccountCreateCommit: invalid field Destination',
)
}
if (tx.Amount == null) {
throw new ValidationError('XChainAccountCreateCommit: missing field Amount')
}
if (!isAmount(tx.Amount)) {
throw new ValidationError('XChainAccountCreateCommit: invalid field Amount')
}
}

View File

@@ -1,184 +0,0 @@
import { ValidationError } from '../../errors'
import { Amount, XChainBridge } from '../common'
import {
BaseTransaction,
isAmount,
isXChainBridge,
validateBaseTransaction,
} from './common'
/**
*
* @category Transaction Models
*/
export interface XChainAddAccountCreateAttestation extends BaseTransaction {
TransactionType: 'XChainAddAccountCreateAttestation'
Amount: Amount
AttestationRewardAccount: string
AttestationSignerAccount: string
Destination: string
OtherChainSource: string
PublicKey: string
Signature: string
SignatureReward: Amount
WasLockingChainSend: 0 | 1
XChainAccountCreateCount: string
XChainBridge: XChainBridge
}
/**
* Verify the form and type of a XChainAddAccountCreateAttestation at runtime.
*
* @param tx - A XChainAddAccountCreateAttestation Transaction.
* @throws When the XChainAddAccountCreateAttestation is malformed.
*/
// eslint-disable-next-line max-lines-per-function, max-statements, complexity -- okay for this function, lots of things to check
export function validateXChainAddAccountCreateAttestation(
tx: Record<string, unknown>,
): void {
validateBaseTransaction(tx)
if (tx.Amount == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field Amount',
)
}
if (!isAmount(tx.Amount)) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field Amount',
)
}
if (tx.AttestationRewardAccount == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field AttestationRewardAccount',
)
}
if (typeof tx.AttestationRewardAccount !== 'string') {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field AttestationRewardAccount',
)
}
if (tx.AttestationSignerAccount == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field AttestationSignerAccount',
)
}
if (typeof tx.AttestationSignerAccount !== 'string') {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field AttestationSignerAccount',
)
}
if (tx.Destination == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field Destination',
)
}
if (typeof tx.Destination !== 'string') {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field Destination',
)
}
if (tx.OtherChainSource == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field OtherChainSource',
)
}
if (typeof tx.OtherChainSource !== 'string') {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field OtherChainSource',
)
}
if (tx.PublicKey == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field PublicKey',
)
}
if (typeof tx.PublicKey !== 'string') {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field PublicKey',
)
}
if (tx.Signature == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field Signature',
)
}
if (typeof tx.Signature !== 'string') {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field Signature',
)
}
if (tx.SignatureReward == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field SignatureReward',
)
}
if (!isAmount(tx.SignatureReward)) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field SignatureReward',
)
}
if (tx.WasLockingChainSend == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field WasLockingChainSend',
)
}
if (tx.WasLockingChainSend !== 0 && tx.WasLockingChainSend !== 1) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field WasLockingChainSend',
)
}
if (tx.XChainAccountCreateCount == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field XChainAccountCreateCount',
)
}
if (typeof tx.XChainAccountCreateCount !== 'string') {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field XChainAccountCreateCount',
)
}
if (tx.XChainBridge == null) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: missing field XChainBridge',
)
}
if (!isXChainBridge(tx.XChainBridge)) {
throw new ValidationError(
'XChainAddAccountCreateAttestation: invalid field XChainBridge',
)
}
}

View File

@@ -1,160 +0,0 @@
import { ValidationError } from '../../errors'
import { Amount, XChainBridge } from '../common'
import {
BaseTransaction,
isAmount,
isXChainBridge,
validateBaseTransaction,
} from './common'
/**
*
* @category Transaction Models
*/
export interface XChainAddClaimAttestation extends BaseTransaction {
TransactionType: 'XChainAddClaimAttestation'
Amount: Amount
AttestationRewardAccount: string
AttestationSignerAccount: string
Destination?: string
OtherChainSource: string
PublicKey: string
Signature: string
WasLockingChainSend: 0 | 1
XChainBridge: XChainBridge
XChainClaimID: string
}
/**
* Verify the form and type of a XChainAddClaimAttestation at runtime.
*
* @param tx - A XChainAddClaimAttestation Transaction.
* @throws When the XChainAddClaimAttestation is malformed.
*/
// eslint-disable-next-line max-lines-per-function, max-statements, complexity -- okay for this function, lots of things to check
export function validateXChainAddClaimAttestation(
tx: Record<string, unknown>,
): void {
validateBaseTransaction(tx)
if (tx.Amount == null) {
throw new ValidationError('XChainAddClaimAttestation: missing field Amount')
}
if (!isAmount(tx.Amount)) {
throw new ValidationError('XChainAddClaimAttestation: invalid field Amount')
}
if (tx.AttestationRewardAccount == null) {
throw new ValidationError(
'XChainAddClaimAttestation: missing field AttestationRewardAccount',
)
}
if (typeof tx.AttestationRewardAccount !== 'string') {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field AttestationRewardAccount',
)
}
if (tx.AttestationSignerAccount == null) {
throw new ValidationError(
'XChainAddClaimAttestation: missing field AttestationSignerAccount',
)
}
if (typeof tx.AttestationSignerAccount !== 'string') {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field AttestationSignerAccount',
)
}
if (tx.Destination !== undefined && typeof tx.Destination !== 'string') {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field Destination',
)
}
if (tx.OtherChainSource == null) {
throw new ValidationError(
'XChainAddClaimAttestation: missing field OtherChainSource',
)
}
if (typeof tx.OtherChainSource !== 'string') {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field OtherChainSource',
)
}
if (tx.PublicKey == null) {
throw new ValidationError(
'XChainAddClaimAttestation: missing field PublicKey',
)
}
if (typeof tx.PublicKey !== 'string') {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field PublicKey',
)
}
if (tx.Signature == null) {
throw new ValidationError(
'XChainAddClaimAttestation: missing field Signature',
)
}
if (typeof tx.Signature !== 'string') {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field Signature',
)
}
if (tx.WasLockingChainSend == null) {
throw new ValidationError(
'XChainAddClaimAttestation: missing field WasLockingChainSend',
)
}
if (tx.WasLockingChainSend !== 0 && tx.WasLockingChainSend !== 1) {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field WasLockingChainSend',
)
}
if (tx.XChainBridge == null) {
throw new ValidationError(
'XChainAddClaimAttestation: missing field XChainBridge',
)
}
if (!isXChainBridge(tx.XChainBridge)) {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field XChainBridge',
)
}
if (tx.XChainClaimID == null) {
throw new ValidationError(
'XChainAddClaimAttestation: missing field XChainClaimID',
)
}
if (typeof tx.XChainClaimID !== 'string') {
throw new ValidationError(
'XChainAddClaimAttestation: invalid field XChainClaimID',
)
}
}

View File

@@ -1,80 +0,0 @@
import { ValidationError } from '../../errors'
import { Amount, XChainBridge } from '../common'
import {
BaseTransaction,
isAmount,
isXChainBridge,
validateBaseTransaction,
} from './common'
/**
*
* @category Transaction Models
*/
export interface XChainClaim extends BaseTransaction {
TransactionType: 'XChainClaim'
XChainBridge: XChainBridge
XChainClaimID: number | string
Destination: string
DestinationTag?: number
Amount: Amount
}
/**
* Verify the form and type of a XChainClaim at runtime.
*
* @param tx - A XChainClaim Transaction.
* @throws When the XChainClaim is malformed.
*/
// eslint-disable-next-line complexity -- okay for this function, lots of things to check
export function validateXChainClaim(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)
if (tx.XChainBridge == null) {
throw new ValidationError('XChainClaim: missing field XChainBridge')
}
if (!isXChainBridge(tx.XChainBridge)) {
throw new ValidationError('XChainClaim: invalid field XChainBridge')
}
if (tx.XChainClaimID == null) {
throw new ValidationError('XChainClaim: missing field XChainClaimID')
}
if (
typeof tx.XChainClaimID !== 'number' &&
typeof tx.XChainClaimID !== 'string'
) {
throw new ValidationError('XChainClaim: invalid field XChainClaimID')
}
if (tx.Destination == null) {
throw new ValidationError('XChainClaim: missing field Destination')
}
if (typeof tx.Destination !== 'string') {
throw new ValidationError('XChainClaim: invalid field Destination')
}
if (
tx.DestinationTag !== undefined &&
typeof tx.DestinationTag !== 'number'
) {
throw new ValidationError('XChainClaim: invalid field DestinationTag')
}
if (tx.Amount == null) {
throw new ValidationError('XChainClaim: missing field Amount')
}
if (!isAmount(tx.Amount)) {
throw new ValidationError('XChainClaim: invalid field Amount')
}
}

View File

@@ -1,71 +0,0 @@
import { ValidationError } from '../../errors'
import { Amount, XChainBridge } from '../common'
import {
BaseTransaction,
isAmount,
isXChainBridge,
validateBaseTransaction,
} from './common'
/**
*
* @category Transaction Models
*/
export interface XChainCommit extends BaseTransaction {
TransactionType: 'XChainCommit'
XChainBridge: XChainBridge
XChainClaimID: number | string
OtherChainDestination?: string
Amount: Amount
}
/**
* Verify the form and type of a XChainCommit at runtime.
*
* @param tx - A XChainCommit Transaction.
* @throws When the XChainCommit is malformed.
*/
export function validateXChainCommit(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)
if (tx.XChainBridge == null) {
throw new ValidationError('XChainCommit: missing field XChainBridge')
}
if (!isXChainBridge(tx.XChainBridge)) {
throw new ValidationError('XChainCommit: invalid field XChainBridge')
}
if (tx.XChainClaimID == null) {
throw new ValidationError('XChainCommit: missing field XChainClaimID')
}
if (
typeof tx.XChainClaimID !== 'number' &&
typeof tx.XChainClaimID !== 'string'
) {
throw new ValidationError('XChainCommit: invalid field XChainClaimID')
}
if (
tx.OtherChainDestination !== undefined &&
typeof tx.OtherChainDestination !== 'string'
) {
throw new ValidationError(
'XChainCommit: invalid field OtherChainDestination',
)
}
if (tx.Amount == null) {
throw new ValidationError('XChainCommit: missing field Amount')
}
if (!isAmount(tx.Amount)) {
throw new ValidationError('XChainCommit: invalid field Amount')
}
}

View File

@@ -1,62 +0,0 @@
import { ValidationError } from '../../errors'
import { Amount, XChainBridge } from '../common'
import {
BaseTransaction,
isAmount,
isXChainBridge,
validateBaseTransaction,
} from './common'
/**
*
* @category Transaction Models
*/
export interface XChainCreateBridge extends BaseTransaction {
TransactionType: 'XChainCreateBridge'
XChainBridge: XChainBridge
SignatureReward: Amount
MinAccountCreateAmount?: Amount
}
/**
* Verify the form and type of a XChainCreateBridge at runtime.
*
* @param tx - A XChainCreateBridge Transaction.
* @throws When the XChainCreateBridge is malformed.
*/
export function validateXChainCreateBridge(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)
if (tx.XChainBridge == null) {
throw new ValidationError('XChainCreateBridge: missing field XChainBridge')
}
if (!isXChainBridge(tx.XChainBridge)) {
throw new ValidationError('XChainCreateBridge: invalid field XChainBridge')
}
if (tx.SignatureReward == null) {
throw new ValidationError(
'XChainCreateBridge: missing field SignatureReward',
)
}
if (!isAmount(tx.SignatureReward)) {
throw new ValidationError(
'XChainCreateBridge: invalid field SignatureReward',
)
}
if (
tx.MinAccountCreateAmount !== undefined &&
!isAmount(tx.MinAccountCreateAmount)
) {
throw new ValidationError(
'XChainCreateBridge: invalid field MinAccountCreateAmount',
)
}
}

View File

@@ -1,65 +0,0 @@
import { ValidationError } from '../../errors'
import { Amount, XChainBridge } from '../common'
import {
BaseTransaction,
isAmount,
isXChainBridge,
validateBaseTransaction,
} from './common'
/**
*
* @category Transaction Models
*/
export interface XChainCreateClaimID extends BaseTransaction {
TransactionType: 'XChainCreateClaimID'
XChainBridge: XChainBridge
SignatureReward: Amount
OtherChainSource: string
}
/**
* Verify the form and type of a XChainCreateClaimID at runtime.
*
* @param tx - A XChainCreateClaimID Transaction.
* @throws When the XChainCreateClaimID is malformed.
*/
export function validateXChainCreateClaimID(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)
if (tx.XChainBridge == null) {
throw new ValidationError('XChainCreateClaimID: missing field XChainBridge')
}
if (!isXChainBridge(tx.XChainBridge)) {
throw new ValidationError('XChainCreateClaimID: invalid field XChainBridge')
}
if (tx.SignatureReward == null) {
throw new ValidationError(
'XChainCreateClaimID: missing field SignatureReward',
)
}
if (!isAmount(tx.SignatureReward)) {
throw new ValidationError(
'XChainCreateClaimID: invalid field SignatureReward',
)
}
if (tx.OtherChainSource == null) {
throw new ValidationError(
'XChainCreateClaimID: missing field OtherChainSource',
)
}
if (typeof tx.OtherChainSource !== 'string') {
throw new ValidationError(
'XChainCreateClaimID: invalid field OtherChainSource',
)
}
}

View File

@@ -1,67 +0,0 @@
import { ValidationError } from '../../errors'
import { Amount, XChainBridge } from '../common'
import {
BaseTransaction,
GlobalFlags,
isAmount,
isXChainBridge,
validateBaseTransaction,
} from './common'
export enum XChainModifyBridgeFlags {
tfClearAccountCreateAmount = 0x00010000,
}
export interface XChainModifyBridgeFlagsInterface extends GlobalFlags {
tfClearAccountCreateAmount?: boolean
}
/**
*
* @category Transaction Models
*/
export interface XChainModifyBridge extends BaseTransaction {
TransactionType: 'XChainModifyBridge'
XChainBridge: XChainBridge
SignatureReward?: Amount
MinAccountCreateAmount?: Amount
Flags?: number | XChainModifyBridgeFlagsInterface
}
/**
* Verify the form and type of a XChainModifyBridge at runtime.
*
* @param tx - A XChainModifyBridge Transaction.
* @throws When the XChainModifyBridge is malformed.
*/
export function validateXChainModifyBridge(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)
if (tx.XChainBridge == null) {
throw new ValidationError('XChainModifyBridge: missing field XChainBridge')
}
if (!isXChainBridge(tx.XChainBridge)) {
throw new ValidationError('XChainModifyBridge: invalid field XChainBridge')
}
if (tx.SignatureReward !== undefined && !isAmount(tx.SignatureReward)) {
throw new ValidationError(
'XChainModifyBridge: invalid field SignatureReward',
)
}
if (
tx.MinAccountCreateAmount !== undefined &&
!isAmount(tx.MinAccountCreateAmount)
) {
throw new ValidationError(
'XChainModifyBridge: invalid field MinAccountCreateAmount',
)
}
}

View File

@@ -44,6 +44,15 @@ export enum AccountSetAsfFlags {
* Allow another account to mint and burn tokens on behalf of this account.
*/
asfAuthorizedNFTokenMinter = 10,
/** asf 11 is reserved for Hooks amendment */
/** Disallow other accounts from creating incoming NFTOffers */
asfDisallowIncomingNFTOffer = 12,
/** Disallow other accounts from creating incoming Checks */
asfDisallowIncomingCheck = 13,
/** Disallow other accounts from creating incoming PayChannels */
asfDisallowIncomingPayChan = 14,
/** Disallow other accounts from creating incoming Trustlines */
asfDisallowIncomingTrustline = 15,
}
/**

View File

@@ -4,14 +4,7 @@
import { TRANSACTION_TYPES } from 'ripple-binary-codec'
import { ValidationError } from '../../errors'
import {
Amount,
IssuedCurrency,
IssuedCurrencyAmount,
Memo,
Signer,
XChainBridge,
} from '../common'
import { Amount, IssuedCurrencyAmount, Memo, Signer } from '../common'
import { onlyHasFields } from '../utils'
const MEMO_SIZE = 3
@@ -57,37 +50,17 @@ function isSigner(obj: unknown): boolean {
)
}
const XRP_CURRENCY_SIZE = 1
const ISSUE_SIZE = 2
const ISSUED_CURRENCY_SIZE = 3
const XCHAIN_BRIDGE_SIZE = 4
function isRecord(value: unknown): value is Record<string, unknown> {
return value !== null && typeof value === 'object'
}
/**
* Verify the form and type of an IssuedCurrency at runtime.
*
* @param input - The input to check the form and type of.
* @returns Whether the IssuedCurrency is properly formed.
*/
export function isIssue(input: unknown): input is IssuedCurrency {
return (
isRecord(input) &&
((Object.keys(input).length === ISSUE_SIZE &&
typeof input.issuer === 'string' &&
typeof input.currency === 'string') ||
(Object.keys(input).length === XRP_CURRENCY_SIZE &&
input.currency === 'XRP'))
)
}
/**
* Verify the form and type of an IssuedCurrencyAmount at runtime.
*
* @param input - The input to check the form and type of.
* @returns Whether the IssuedCurrencyAmount is properly formed.
* @returns Whether the IssuedCurrencyAmount is malformed.
*/
export function isIssuedCurrency(
input: unknown,
@@ -105,29 +78,12 @@ export function isIssuedCurrency(
* Verify the form and type of an Amount at runtime.
*
* @param amount - The object to check the form and type of.
* @returns Whether the Amount is properly formed.
* @returns Whether the Amount is malformed.
*/
export function isAmount(amount: unknown): amount is Amount {
return typeof amount === 'string' || isIssuedCurrency(amount)
}
/**
* Verify the form and type of an XChainBridge at runtime.
*
* @param input - The input to check the form and type of.
* @returns Whether the XChainBridge is properly formed.
*/
export function isXChainBridge(input: unknown): input is XChainBridge {
return (
isRecord(input) &&
Object.keys(input).length === XCHAIN_BRIDGE_SIZE &&
typeof input.LockingChainDoor === 'string' &&
isIssue(input.LockingChainIssue) &&
typeof input.IssuingChainDoor === 'string' &&
isIssue(input.IssuingChainIssue)
)
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface -- no global flags right now, so this is fine
export interface GlobalFlags {}
@@ -203,6 +159,10 @@ export interface BaseTransaction {
* account it says it is from.
*/
TxnSignature?: string
/**
* The network id of the transaction.
*/
NetworkID?: number
}
/**
@@ -296,6 +256,9 @@ export function validateBaseTransaction(common: Record<string, unknown>): void {
) {
throw new ValidationError('BaseTransaction: invalid TxnSignature')
}
if (common.NetworkID !== undefined && typeof common.NetworkID !== 'number') {
throw new ValidationError('BaseTransaction: invalid NetworkID')
}
}
/**

View File

@@ -3,7 +3,7 @@ import { ValidationError } from '../../errors'
import { BaseTransaction, validateBaseTransaction } from './common'
/**
* Return escrowed amount to the sender.
* Return escrowed XRP to the sender.
*
* @category Transaction Models
*/

View File

@@ -1,23 +1,22 @@
/* eslint-disable complexity -- Necessary for validateEscrowCreate */
import { ValidationError } from '../../errors'
import { Amount } from '../common'
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
import { BaseTransaction, validateBaseTransaction } from './common'
/**
* Sequester amount until the escrow process either finishes or is canceled.
* Sequester XRP until the escrow process either finishes or is canceled.
*
* @category Transaction Models
*/
export interface EscrowCreate extends BaseTransaction {
TransactionType: 'EscrowCreate'
/**
* Amount to deduct from the sender's balance and escrow. Once escrowed, the
* amount can either go to the Destination address (after the FinishAfter time)
* or returned to the sender (after the CancelAfter time).
* Amount of XRP, in drops, to deduct from the sender's balance and escrow.
* Once escrowed, the XRP can either go to the Destination address (after the.
* FinishAfter time) or returned to the sender (after the CancelAfter time).
*/
Amount: Amount
/** Address to receive escrowed amount. */
Amount: string
/** Address to receive escrowed XRP. */
Destination: string
/**
* The time, in seconds since the Ripple Epoch, when this escrow expires.
@@ -26,7 +25,7 @@ export interface EscrowCreate extends BaseTransaction {
*/
CancelAfter?: number
/**
* The time, in seconds since the Ripple Epoch, when the escrowed amount can be
* The time, in seconds since the Ripple Epoch, when the escrowed XRP can be
* released to the recipient. This value is immutable; the funds cannot move.
* until this time is reached.
*/
@@ -56,8 +55,8 @@ export function validateEscrowCreate(tx: Record<string, unknown>): void {
throw new ValidationError('EscrowCreate: missing field Amount')
}
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
throw new ValidationError('EscrowCreate: Amount must be an Amount')
if (typeof tx.Amount !== 'string') {
throw new ValidationError('EscrowCreate: Amount must be a string')
}
if (tx.Destination === undefined) {

View File

@@ -3,7 +3,7 @@ import { ValidationError } from '../../errors'
import { BaseTransaction, validateBaseTransaction } from './common'
/**
* Deliver amount from a held payment to the recipient.
* Deliver XRP from a held payment to the recipient.
*
* @category Transaction Models
*/

View File

@@ -45,15 +45,3 @@ export { SetRegularKey } from './setRegularKey'
export { SignerListSet } from './signerListSet'
export { TicketCreate } from './ticketCreate'
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
export { XChainAddAccountCreateAttestation } from './XChainAddAccountCreateAttestation'
export { XChainAddClaimAttestation } from './XChainAddClaimAttestation'
export { XChainClaim } from './XChainClaim'
export { XChainCommit } from './XChainCommit'
export { XChainCreateBridge } from './XChainCreateBridge'
export { XChainCreateClaimID } from './XChainCreateClaimID'
export { XChainAccountCreateCommit } from './XChainAccountCreateCommit'
export {
XChainModifyBridge,
XChainModifyBridgeFlags,
XChainModifyBridgeFlagsInterface,
} from './XChainModifyBridge'

View File

@@ -1,6 +1,6 @@
import { Amount } from '../common'
interface CreatedNode {
export interface CreatedNode {
CreatedNode: {
LedgerEntryType: string
LedgerIndex: string
@@ -8,7 +8,7 @@ interface CreatedNode {
}
}
interface ModifiedNode {
export interface ModifiedNode {
ModifiedNode: {
LedgerEntryType: string
LedgerIndex: string
@@ -19,7 +19,7 @@ interface ModifiedNode {
}
}
interface DeletedNode {
export interface DeletedNode {
DeletedNode: {
LedgerEntryType: string
LedgerIndex: string
@@ -29,6 +29,36 @@ interface DeletedNode {
export type Node = CreatedNode | ModifiedNode | DeletedNode
/**
* A typeguard to check if a node is a CreatedNode.
*
* @param node - A node from metadata.
* @returns whether the given node is a CreatedNode.
*/
export function isCreatedNode(node: Node): node is CreatedNode {
return Object.prototype.hasOwnProperty.call(node, `CreatedNode`)
}
/**
* A typeguard to check if a node is a ModifiedNode.
*
* @param node - A node from metadata.
* @returns whether the given node is a ModifiedNode.
*/
export function isModifiedNode(node: Node): node is ModifiedNode {
return Object.prototype.hasOwnProperty.call(node, `ModifiedNode`)
}
/**
* A typeguard to check if a node is a DeletedNode.
*
* @param node - A node from metadata.
* @returns whether the given node is a DeletedNode.
*/
export function isDeletedNode(node: Node): node is DeletedNode {
return Object.prototype.hasOwnProperty.call(node, `DeletedNode`)
}
export interface TransactionMetadata {
AffectedNodes: Node[]
DeliveredAmount?: Amount

View File

@@ -1,13 +1,7 @@
/* eslint-disable complexity -- Necessary for validatePaymentChannelClaim */
import { ValidationError } from '../../errors'
import { Amount } from '../common'
import {
BaseTransaction,
GlobalFlags,
validateBaseTransaction,
isAmount,
} from './common'
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
/**
* Enum representing values for PaymentChannelClaim transaction flags.
@@ -24,15 +18,15 @@ export enum PaymentChannelClaimFlags {
/**
* Request to close the channel. Only the channel source and destination
* addresses can use this flag. This flag closes the channel immediately if it
* has no more funds allocated to it after processing the current claim, or if
* has no more XRP allocated to it after processing the current claim, or if
* the destination address uses it. If the source address uses this flag when
* the channel still holds an amount, this schedules the channel to close after
* the channel still holds XRP, this schedules the channel to close after
* SettleDelay seconds have passed. (Specifically, this sets the Expiration of
* the channel to the close time of the previous ledger plus the channel's
* SettleDelay time, unless the channel already has an earlier Expiration
* time.) If the destination address uses this flag when the channel still
* holds an amount, any amount that remains after processing the claim is
* returned to the source address.
* holds XRP, any XRP that remains after processing the claim is returned to
* the source address.
*/
tfClose = 0x00020000,
}
@@ -84,21 +78,21 @@ export interface PaymentChannelClaimFlagsInterface extends GlobalFlags {
/**
* Request to close the channel. Only the channel source and destination
* addresses can use this flag. This flag closes the channel immediately if it
* has no more funds allocated to it after processing the current claim, or if
* has no more XRP allocated to it after processing the current claim, or if
* the destination address uses it. If the source address uses this flag when
* the channel still holds an amount, this schedules the channel to close after
* the channel still holds XRP, this schedules the channel to close after
* SettleDelay seconds have passed. (Specifically, this sets the Expiration of
* the channel to the close time of the previous ledger plus the channel's
* SettleDelay time, unless the channel already has an earlier Expiration
* time.) If the destination address uses this flag when the channel still
* holds an amount, any amount that remains after processing the claim is
* returned to the source address.
* holds XRP, any XRP that remains after processing the claim is returned to
* the source address.
*/
tfClose?: boolean
}
/**
* Claim amount from a payment channel, adjust the payment channel's expiration,
* Claim XRP from a payment channel, adjust the payment channel's expiration,
* or both.
*
* @category Transaction Models
@@ -109,18 +103,18 @@ export interface PaymentChannelClaim extends BaseTransaction {
/** The unique ID of the channel as a 64-character hexadecimal string. */
Channel: string
/**
* Total amount delivered by this channel after processing this claim. Required
* to deliver amount. Must be more than the total amount delivered by the channel
* so far, but not greater than the Amount of the signed claim. Must be provided
* except when closing the channel.
* Total amount of XRP, in drops, delivered by this channel after processing
* this claim. Required to deliver XRP. Must be more than the total amount
* delivered by the channel so far, but not greater than the Amount of the
* signed claim. Must be provided except when closing the channel.
*/
Balance?: Amount
Balance?: string
/**
* The amount authorized by the Signature. This must match the amount in the
* signed message. This is the cumulative amount that can be dispensed by the
* channel, including amounts previously redeemed. Required unless closing the channel.
* The amount of XRP, in drops, authorized by the Signature. This must match
* the amount in the signed message. This is the cumulative amount of XRP that
* can be dispensed by the channel, including XRP previously redeemed.
*/
Amount?: Amount
Amount?: string
/**
* The signature of this claim, as hexadecimal. The signed message contains
* the channel ID and the amount of the claim. Required unless the sender of
@@ -153,12 +147,12 @@ export function validatePaymentChannelClaim(tx: Record<string, unknown>): void {
throw new ValidationError('PaymentChannelClaim: Channel must be a string')
}
if (tx.Balance !== undefined && !isAmount(tx.Balance)) {
throw new ValidationError('PaymentChannelClaim: Balance must be an Amount')
if (tx.Balance !== undefined && typeof tx.Balance !== 'string') {
throw new ValidationError('PaymentChannelClaim: Balance must be a string')
}
if (tx.Amount !== undefined && !isAmount(tx.Amount)) {
throw new ValidationError('PaymentChannelClaim: Amount must be an Amount')
if (tx.Amount !== undefined && typeof tx.Amount !== 'string') {
throw new ValidationError('PaymentChannelClaim: Amount must be a string')
}
if (tx.Signature !== undefined && typeof tx.Signature !== 'string') {

View File

@@ -1,11 +1,10 @@
/* eslint-disable complexity -- Necessary for validatePaymentChannelCreate */
import { ValidationError } from '../../errors'
import { Amount } from '../common'
import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
import { BaseTransaction, validateBaseTransaction } from './common'
/**
* Create a unidirectional channel and fund it. The address sending
* Create a unidirectional channel and fund it with XRP. The address sending
* this transaction becomes the "source address" of the payment channel.
*
* @category Transaction Models
@@ -13,20 +12,20 @@ import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
export interface PaymentChannelCreate extends BaseTransaction {
TransactionType: 'PaymentChannelCreate'
/**
* Amount to deduct from the sender's balance and set aside in this channel.
* While the channel is open, the amount can only go to the Destination
* address. When the channel closes, any unclaimed amount is returned to
* the source address's balance.
* Amount of XRP, in drops, to deduct from the sender's balance and set aside
* in this channel. While the channel is open, the XRP can only go to the
* Destination address. When the channel closes, any unclaimed XRP is returned
* to the source address's balance.
*/
Amount: Amount
Amount: string
/**
* Address to receive claims against this channel. This is also known as
* Address to receive XRP claims against this channel. This is also known as
* the "destination address" for the channel.
*/
Destination: string
/**
* Amount of time the source address must wait before closing the channel if
* it has unclaimed amount.
* it has unclaimed XRP.
*/
SettleDelay: number
/**
@@ -66,8 +65,8 @@ export function validatePaymentChannelCreate(
throw new ValidationError('PaymentChannelCreate: missing Amount')
}
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
throw new ValidationError('PaymentChannelCreate: Amount must be an Amount')
if (typeof tx.Amount !== 'string') {
throw new ValidationError('PaymentChannelCreate: Amount must be a string')
}
if (tx.Destination === undefined) {

View File

@@ -1,10 +1,9 @@
import { ValidationError } from '../../errors'
import { Amount } from '../common'
import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
import { BaseTransaction, validateBaseTransaction } from './common'
/**
* Add additional amount to an open payment channel, and optionally update the
* Add additional XRP to an open payment channel, and optionally update the
* expiration time of the channel. Only the source address of the channel can
* use this transaction.
*
@@ -18,15 +17,16 @@ export interface PaymentChannelFund extends BaseTransaction {
*/
Channel: string
/**
* Amount to add to the channel. Must be a positive amount
* Amount of XRP in drops to add to the channel. Must be a positive amount
* of XRP.
*/
Amount: Amount
Amount: string
/**
* New Expiration time to set for the channel in seconds since the Ripple
* Epoch. This must be later than either the current time plus the SettleDelay
* of the channel, or the existing Expiration of the channel. After the
* Expiration time, any transaction that would access the channel closes the
* channel without taking its normal action. Any unspent amount is returned to
* channel without taking its normal action. Any unspent XRP is returned to
* the source address when the channel closes. (Expiration is separate from
* the channel's immutable CancelAfter time.) For more information, see the
* PayChannel ledger object type.
@@ -55,8 +55,8 @@ export function validatePaymentChannelFund(tx: Record<string, unknown>): void {
throw new ValidationError('PaymentChannelFund: missing Amount')
}
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
throw new ValidationError('PaymentChannelFund: Amount must be an Amount')
if (typeof tx.Amount !== 'string') {
throw new ValidationError('PaymentChannelFund: Amount must be a string')
}
if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {

View File

@@ -51,32 +51,6 @@ import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
import { SignerListSet, validateSignerListSet } from './signerListSet'
import { TicketCreate, validateTicketCreate } from './ticketCreate'
import { TrustSet, validateTrustSet } from './trustSet'
import {
XChainAccountCreateCommit,
validateXChainAccountCreateCommit,
} from './XChainAccountCreateCommit'
import {
XChainAddAccountCreateAttestation,
validateXChainAddAccountCreateAttestation,
} from './XChainAddAccountCreateAttestation'
import {
XChainAddClaimAttestation,
validateXChainAddClaimAttestation,
} from './XChainAddClaimAttestation'
import { XChainClaim, validateXChainClaim } from './XChainClaim'
import { XChainCommit, validateXChainCommit } from './XChainCommit'
import {
XChainCreateBridge,
validateXChainCreateBridge,
} from './XChainCreateBridge'
import {
XChainCreateClaimID,
validateXChainCreateClaimID,
} from './XChainCreateClaimID'
import {
XChainModifyBridge,
validateXChainModifyBridge,
} from './XChainModifyBridge'
/**
* @category Transaction Models
@@ -106,14 +80,6 @@ export type Transaction =
| SignerListSet
| TicketCreate
| TrustSet
| XChainAddAccountCreateAttestation
| XChainAddClaimAttestation
| XChainClaim
| XChainCommit
| XChainCreateBridge
| XChainCreateClaimID
| XChainAccountCreateCommit
| XChainModifyBridge
/**
* @category Transaction Models
@@ -238,38 +204,6 @@ export function validate(transaction: Record<string, unknown>): void {
validateTrustSet(tx)
break
case 'XChainAddAccountCreateAttestation':
validateXChainAddAccountCreateAttestation(tx)
break
case 'XChainAddClaimAttestation':
validateXChainAddClaimAttestation(tx)
break
case 'XChainClaim':
validateXChainClaim(tx)
break
case 'XChainCommit':
validateXChainCommit(tx)
break
case 'XChainCreateBridge':
validateXChainCreateBridge(tx)
break
case 'XChainCreateClaimID':
validateXChainCreateClaimID(tx)
break
case 'XChainAccountCreateCommit':
validateXChainAccountCreateCommit(tx)
break
case 'XChainModifyBridge':
validateXChainModifyBridge(tx)
break
default:
throw new ValidationError(
`Invalid field TransactionType: ${tx.TransactionType}`,

View File

@@ -6,14 +6,22 @@ import {
AccountRootFlagsInterface,
AccountRootFlags,
} from '../ledger/AccountRoot'
import { AccountSetTfFlags } from '../transactions/accountSet'
import {
AccountSetFlagsInterface,
AccountSetTfFlags,
} from '../transactions/accountSet'
import { GlobalFlags } from '../transactions/common'
import { OfferCreateFlags } from '../transactions/offerCreate'
import { PaymentFlags } from '../transactions/payment'
import { PaymentChannelClaimFlags } from '../transactions/paymentChannelClaim'
import {
OfferCreateFlagsInterface,
OfferCreateFlags,
} from '../transactions/offerCreate'
import { PaymentFlagsInterface, PaymentFlags } from '../transactions/payment'
import {
PaymentChannelClaimFlagsInterface,
PaymentChannelClaimFlags,
} from '../transactions/paymentChannelClaim'
import type { Transaction } from '../transactions/transaction'
import { TrustSetFlags } from '../transactions/trustSet'
import { XChainModifyBridgeFlags } from '../transactions/XChainModifyBridge'
import { TrustSetFlagsInterface, TrustSetFlags } from '../transactions/trustSet'
import { isFlagEnabled } from '.'
@@ -53,30 +61,55 @@ export function setTransactionFlagsToNumber(tx: Transaction): void {
switch (tx.TransactionType) {
case 'AccountSet':
tx.Flags = convertFlagsToNumber(tx.Flags, AccountSetTfFlags)
tx.Flags = convertAccountSetFlagsToNumber(tx.Flags)
return
case 'OfferCreate':
tx.Flags = convertFlagsToNumber(tx.Flags, OfferCreateFlags)
tx.Flags = convertOfferCreateFlagsToNumber(tx.Flags)
return
case 'PaymentChannelClaim':
tx.Flags = convertFlagsToNumber(tx.Flags, PaymentChannelClaimFlags)
tx.Flags = convertPaymentChannelClaimFlagsToNumber(tx.Flags)
return
case 'Payment':
tx.Flags = convertFlagsToNumber(tx.Flags, PaymentFlags)
tx.Flags = convertPaymentTransactionFlagsToNumber(tx.Flags)
return
case 'TrustSet':
tx.Flags = convertFlagsToNumber(tx.Flags, TrustSetFlags)
return
case 'XChainModifyBridge':
tx.Flags = convertFlagsToNumber(tx.Flags, XChainModifyBridgeFlags)
tx.Flags = convertTrustSetFlagsToNumber(tx.Flags)
return
default:
tx.Flags = 0
}
}
function convertAccountSetFlagsToNumber(
flags: AccountSetFlagsInterface,
): number {
return reduceFlags(flags, AccountSetTfFlags)
}
function convertOfferCreateFlagsToNumber(
flags: OfferCreateFlagsInterface,
): number {
return reduceFlags(flags, OfferCreateFlags)
}
function convertPaymentChannelClaimFlagsToNumber(
flags: PaymentChannelClaimFlagsInterface,
): number {
return reduceFlags(flags, PaymentChannelClaimFlags)
}
function convertPaymentTransactionFlagsToNumber(
flags: PaymentFlagsInterface,
): number {
return reduceFlags(flags, PaymentFlags)
}
function convertTrustSetFlagsToNumber(flags: TrustSetFlagsInterface): number {
return reduceFlags(flags, TrustSetFlags)
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- added ValidationError check for flagEnum
function convertFlagsToNumber(flags: GlobalFlags, flagEnum: any): number {
function reduceFlags(flags: GlobalFlags, flagEnum: any): number {
return Object.keys(flags).reduce((resultFlags, flag) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- safe member access
if (flagEnum[flag] == null) {

View File

@@ -9,6 +9,7 @@ import { setTransactionFlagsToNumber } from '../models/utils/flags'
import { xrpToDrops } from '../utils'
import getFeeXrp from './getFeeXrp'
import getNetworkID from './getNetworkID'
// Expire unconfirmed transactions after 20 ledger versions, approximately 1 minute, by default
const LEDGER_OFFSET = 20
@@ -39,8 +40,10 @@ async function autofill<T extends Transaction>(
setValidAddresses(tx)
setTransactionFlagsToNumber(tx)
const promises: Array<Promise<void>> = []
if (tx.NetworkID == null) {
promises.push(setNetworkID(this, tx))
}
if (tx.Sequence == null) {
promises.push(setNextValidSequenceNumber(this, tx))
}
@@ -200,6 +203,12 @@ function scaleValue(value, multiplier): string {
return new BigNumber(value).times(multiplier).toString()
}
async function setNetworkID(client: Client, tx: Transaction): Promise<void> {
const id = await getNetworkID(client)
// eslint-disable-next-line no-param-reassign -- param reassign is safe
tx.NetworkID = id
}
async function setLatestValidatedLedgerSequence(
client: Client,
tx: Transaction,

View File

@@ -0,0 +1,22 @@
import type { Client } from '..'
import { XrplError } from '../errors'
/**
* Returns the network ID of the rippled server.
*
* @param this - The Client used to connect to the ledger.
* @param client
* @returns The network id.
*/
export default async function getNetworkID(client: Client): Promise<number> {
const response = await client.request({
command: 'server_info',
})
const networkID = response.result.info.network_id
if (networkID == null) {
throw new XrplError(
'getNetworkID: Could not get network_id from server_info',
)
}
return networkID
}

View File

@@ -0,0 +1,85 @@
import flatMap from 'lodash/flatMap'
import {
CreatedNode,
isCreatedNode,
isModifiedNode,
ModifiedNode,
TransactionMetadata,
} from '../models/transactions/metadata'
interface NFToken {
NFToken: {
NFTokenID: string
URI: string
}
}
/**
* Gets the NFTokenID for an NFT recently minted with NFTokenMint.
*
* @param meta - Metadata from the response to submitting an NFTokenMint transaction.
* @returns The NFTokenID for the minted NFT.
* @throws if meta is not TransactionMetadata.
*/
export default function getNFTokenID(
meta: TransactionMetadata,
): string | undefined {
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provides a nicer error for js users */
if (meta.AffectedNodes === undefined) {
throw new TypeError(`Unable to parse the parameter given to getNFTokenID.
'meta' must be the metadata from an NFTokenMint transaction. Received ${JSON.stringify(
meta,
)} instead.`)
}
/*
* When a mint results in splitting an existing page,
* it results in a created page and a modified node. Sometimes,
* the created node needs to be linked to a third page, resulting
* in modifying that third page's PreviousPageMin or NextPageMin
* field changing, but no NFTs within that page changing. In this
* case, there will be no previous NFTs and we need to skip.
* However, there will always be NFTs listed in the final fields,
* as rippled outputs all fields in final fields even if they were
* not changed. Thus why we add the additional condition to check
* if the PreviousFields contains NFTokens
*/
const affectedNodes = meta.AffectedNodes.filter((node) => {
if (isCreatedNode(node)) {
return node.CreatedNode.LedgerEntryType === 'NFTokenPage'
}
if (isModifiedNode(node)) {
return (
node.ModifiedNode.LedgerEntryType === 'NFTokenPage' &&
Boolean(node.ModifiedNode.PreviousFields?.NFTokens)
)
}
return false
})
/* eslint-disable @typescript-eslint/consistent-type-assertions -- Necessary for parsing metadata */
const previousTokenIDSet = new Set(
flatMap(affectedNodes, (node) => {
const nftokens = isModifiedNode(node)
? (node.ModifiedNode.PreviousFields?.NFTokens as NFToken[])
: []
return nftokens.map((token) => token.NFToken.NFTokenID)
}).filter((id) => Boolean(id)),
)
/* eslint-disable @typescript-eslint/no-unnecessary-condition -- Cleaner to read */
const finalTokenIDs = flatMap(affectedNodes, (node) =>
(
(((node as ModifiedNode).ModifiedNode?.FinalFields?.NFTokens ??
(node as CreatedNode).CreatedNode?.NewFields?.NFTokens) as NFToken[]) ??
[]
).map((token) => token.NFToken.NFTokenID),
).filter((nftokenID) => Boolean(nftokenID))
/* eslint-enable @typescript-eslint/consistent-type-assertions -- Necessary for parsing metadata */
/* eslint-enable @typescript-eslint/no-unnecessary-condition -- Cleaner to read */
const nftokenID = finalTokenIDs.find((id) => !previousTokenIDSet.has(id))
return nftokenID
}

View File

@@ -25,6 +25,7 @@ import { Transaction } from '../models/transactions/transaction'
import createCrossChainPayment from './createCrossChainPayment'
import { deriveKeypair, deriveAddress, deriveXAddress } from './derive'
import getBalanceChanges from './getBalanceChanges'
import getNFTokenID from './getNFTokenID'
import {
hashSignedTx,
hashTx,
@@ -218,6 +219,7 @@ export {
encodeForMultiSigning,
encodeForSigning,
encodeForSigningClaim,
getNFTokenID,
createCrossChainPayment,
parseNFTokenID,
}

View File

@@ -18,6 +18,7 @@ import { assertRejects } from '../testUtils'
const Fee = '10'
const Sequence = 1432
const LastLedgerSequence = 2908734
const NetworkID = 21338
describe('client.autofill', function () {
let testContext: XrplTestContext
@@ -35,12 +36,14 @@ describe('client.autofill', function () {
Fee,
Sequence,
LastLedgerSequence,
NetworkID,
}
const txResult = await testContext.client.autofill(tx)
assert.strictEqual(txResult.Fee, Fee)
assert.strictEqual(txResult.Sequence, Sequence)
assert.strictEqual(txResult.LastLedgerSequence, LastLedgerSequence)
assert.strictEqual(txResult.NetworkID, NetworkID)
})
it('converts Account & Destination X-address to their classic address', async function () {
@@ -58,6 +61,10 @@ describe('client.autofill', function () {
'server_info',
rippled.server_info.normal,
)
testContext.mockRippled!.addResponse(
'server_info',
rippled.server_info.normal,
)
testContext.mockRippled!.addResponse('ledger', rippled.ledger.normal)
const txResult = await testContext.client.autofill(tx)
@@ -76,6 +83,7 @@ describe('client.autofill', function () {
Authorize: 'rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo',
Fee,
LastLedgerSequence,
NetworkID,
}
testContext.mockRippled!.addResponse('account_info', {
status: 'success',
@@ -101,6 +109,10 @@ describe('client.autofill', function () {
'server_info',
rippled.server_info.normal,
)
testContext.mockRippled!.addResponse(
'server_info',
rippled.server_info.normal,
)
testContext.mockRippled!.addResponse(
'account_objects',
rippled.account_objects.normal,
@@ -113,6 +125,7 @@ describe('client.autofill', function () {
Fee,
Sequence,
LastLedgerSequence,
NetworkID,
}
await assertRejects(testContext.client.autofill(tx), XrplError)
@@ -126,6 +139,7 @@ describe('client.autofill', function () {
Authorize: 'rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo',
Sequence,
LastLedgerSequence,
NetworkID,
}
testContext.mockRippled!.addResponse(
'server_info',
@@ -155,6 +169,10 @@ describe('client.autofill', function () {
'server_info',
rippled.server_info.normal,
)
testContext.mockRippled!.addResponse(
'server_info',
rippled.server_info.normal,
)
const txResult = await testContext.client.autofill(tx)
assert.strictEqual(txResult.Fee, '399')
@@ -171,6 +189,10 @@ describe('client.autofill', function () {
rippled.account_info.normal,
)
testContext.mockRippled!.addResponse('ledger', rippled.ledger.normal)
testContext.mockRippled!.addResponse(
'server_info',
rippled.server_info.normal,
)
testContext.mockRippled!.addResponse('server_state', {
status: 'success',
type: 'response',
@@ -214,6 +236,10 @@ describe('client.autofill', function () {
'server_info',
rippled.server_info.normal,
)
testContext.mockRippled!.addResponse(
'server_info',
rippled.server_info.normal,
)
const txResult = await testContext.client.autofill(tx, 4)
assert.strictEqual(txResult.Fee, '459')
@@ -227,6 +253,7 @@ describe('client.autofill', function () {
Authorize: 'rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo',
Fee,
Sequence,
NetworkID,
}
testContext.mockRippled!.addResponse('ledger', {
status: 'success',
@@ -272,9 +299,37 @@ describe('client.autofill', function () {
},
},
})
testContext.mockRippled!.addResponse(
'server_info',
rippled.server_info.normal,
)
const txResult = await testContext.client.autofill(tx)
assert.strictEqual(txResult.Fee, '12')
assert.strictEqual(txResult.Sequence, 23)
assert.strictEqual(txResult.LastLedgerSequence, 9038234)
assert.strictEqual(txResult.NetworkID, 21338)
})
it("should autofill NetworkID when it's missing", async function () {
const tx: Transaction = {
TransactionType: 'DepositPreauth',
Account: 'rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf',
Authorize: 'rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo',
Fee,
LastLedgerSequence,
Sequence,
}
testContext.mockRippled!.addResponse('server_info', {
status: 'success',
type: 'response',
result: {
info: {
network_id: 21338,
},
},
})
const txResult = await testContext.client.autofill(tx)
assert.strictEqual(txResult.NetworkID, 21338)
})
})

View File

@@ -34,6 +34,7 @@ describe('client.submit', function () {
Sequence: 1,
Fee: '12',
LastLedgerSequence: 12312,
NetworkID: 21338,
}
it('should submit an unsigned transaction', async function () {
@@ -83,6 +84,7 @@ describe('client.submit', function () {
LastLedgerSequence: 12312,
Amount: '20000000',
Fee: '12',
NetworkID: 21338,
SigningPubKey:
'030E58CDD076E798C84755590AAF6237CA8FAE821070A59F648B517A30DC6F589D',
TxnSignature:

View File

@@ -0,0 +1,480 @@
{
"tx": {
"Account": "rXMART8usFd5kABXCayoP6ZfB35b4v43t",
"Fee": "12",
"Flags": 8,
"Issuer": "rMhoejpvS8mWfiffy4Zj8H2KbVs1oZCVsP",
"LastLedgerSequence": 77781480,
"Memos": [
{
"Memo": {
"MemoData": "68747470733A2F2F786D6172742E6172742F766965772D6E66742F38646261376436386533383665363865653636393030373461633965653438323A31363735373034353330383336",
"MemoType": "784D6172742D4E46542D6D696E74"
}
}
],
"NFTokenTaxon": 5545,
"Sequence": 72168792,
"SigningPubKey": "ED8BB649713ED492AE35B4B5CA745CCA55ADF8EF4CEDB2CC8BA4E28557E993AD2F",
"TransactionType": "NFTokenMint",
"TransferFee": 5000,
"TxnSignature": "8E4B05FE811BA0DCFE9B4E54B0550D2B934336C09449C2FC14E8F6CFE20069115D18C5930E744220E84C06C145F93F5C291C4CC96D19425C941E2603652B8C02",
"URI": "697066733A2F2F626166796265696161736F7073366D6D783772616732743464687833616B3374747432683462647274657279786C373662366C78646E6A7962336D2F6D657461646174612E6A736F6E",
"date": 1676330052000,
"warnings": [
{
"id": 1004,
"message": "This is a reporting server. The default behavior of a reporting server is to only return validated data. If you are looking for not yet validated data, include \"ledger_index : current\" in your request, which will cause this server to forward the request to a p2p node. If the forward is successful the response will include \"forwarded\" : \"true\""
}
]
},
"meta": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Flags": 0,
"NFTokens": [
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB1AD9556900000225",
"URI": "697066733A2F2F62616679626569626732726B6B6768616B6B727433696D61656F6D6D65377164747169687A756F713272327875637872776478676565356A7272652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB1EF9501C0000021A",
"URI": "697066733A2F2F62616679626569626A74736F7270637879366465797A666B3233676D6863786E67356C7536746277786E786269627667776575357172356B7A34752F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB1FFCAED5000000E1",
"URI": "697066733A2F2F6261667962656962736432653571337674686375777034746868336F6B633673746F676C696D6873746C70347663336564333632796375346978342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB21D71D900000009E",
"URI": "697066733A2F2F6261667962656964736B686B746C646233686F6F637A786A7577766932377835696C637677776278696C33366371366736746362667478653573612F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB22ADCA8600000194",
"URI": "697066733A2F2F6261667962656964786336343471776B35626172357036756561376C747A786F3737786B647665616666633435337A66777565646737336B7966752F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB24F382CE000001CC",
"URI": "697066733A2F2F62616679626569626A363563346E77737A3773756C773364756D6E776B6F616D6E786770716270656E726D6567356F76657067763233356C687A342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB25F7188700000093",
"URI": "697066733A2F2F626166796265696371767069796C6271616D6371336C636175727A706A696465367468346233376C68346A7766786C65646C63686533756F6179342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB28A8254800000146",
"URI": "697066733A2F2F626166796265696571627072637873686370647865677268686B6C786570666535376970696E6571687137656C706F68326B356E32753571706C792F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB2F794C20000001EE",
"URI": "697066733A2F2F626166796265696832656D6A7A616A687337747A6B616C68646B756D363737357678326F76616C33726F6D696368336A3434326A6F3468366166342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB31BF046800000226",
"URI": "697066733A2F2F6261667962656965696E7A787774776B7672666E646E626A7061636D61776E6C7A7564616A726473616777703474676B6F643363756477697337692F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB38BCCC930000009F",
"URI": "697066733A2F2F62616679626569636E6678796D66676D70346A6E7365716678617A7633326E65796D697333357769637333336333616B616D72707773323233716D2F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB3B6DE94400000152",
"URI": "697066733A2F2F626166796265696435726C676577667762736676683368346C7434756B763267766A7634656B61736778327A766A6D67377166773775737A7576342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB3BD97DC1000001CD",
"URI": "697066733A2F2F62616679626569656A6B677A706C6766616775737564646174326A3335657163756A3762337376356D6C3568613569786676327535747A337170652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB3F2283CE000000CC",
"URI": "697066733A2F2F62616679626569667670746C366B69666C746E3661766F6179663473347A3364796466796B6A666466646A626A76746575696A706B626A336733752F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB3F8E144B00000147",
"URI": "697066733A2F2F62616679626569636675336272636F6C6962767171727736703464617772636A6B75737877637436366C6F736C797576636D766C66766D643478692F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB41D3AFB30000017F",
"URI": "697066733A2F2F6261667962656967796166656E357877766F346973706E777A3275376E696664687477366C686A376A6E37333334643732366A36656178367377342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB45F3AAA600000174",
"URI": "697066733A2F2F626166796265696774766B3336696F766C68777562326F6B6934747069726670647070337437747171777A6F36746D33706575373478636C3474712F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB465F3F23000001EF",
"URI": "697066733A2F2F62616679626569646B37796D37736775747A7A766E70736669796B6A7379733565646568637936707370756C74337137646B696F7A737A376271652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB47CE1E6500000131",
"URI": "697066733A2F2F6261667962656968627A683362786C76716578327163747665616B71656271357066366468637569773779796D6C696E6A346F74327636736937612F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB48A4F76B00000227",
"URI": "697066733A2F2F626166796265696179766F6C686F3462777A736D6A69363633337174696975776B71753664726272746877667277626236346B62776174346E76342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB49A84D20000000EE",
"URI": "697066733A2F2F62616679626569633269337535366163646A6764643573733434753674743767656B35796A6D637933766E71676F3265633734686D6D6D676D74612F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB4B82B0EF000000AB",
"URI": "697066733A2F2F626166796265696462756637356D67616A6F63336969363465667675786D64356F7236746C3236356E7865623675616A34656232356F35657066652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB4DC848D7000000E3",
"URI": "697066733A2F2F626166796265696169746C677662756774636B37786C6C6934717378683434663467687A6171376B6F6662666135657A6D796A336C7461766877612F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5079949800000196",
"URI": "697066733A2F2F62616679626569666F616B736468666A63716575783676766577377078326E34786F6773656E7133377A6176656233696973666E6D64347A6666342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5253D84700000153",
"URI": "697066733A2F2F62616679626569633735366A6F6263786961346776643477717634696E6E766F6C6C75767068676171666161656168353676626C713471343434792F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB52BF2CC0000001CE",
"URI": "697066733A2F2F626166796265696268626E6F356664353272717663656A6769656C336B6E796C77727A366A747233767A77336B75656F363674697033716B36356D2F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB542E0F0200000110",
"URI": "697066733A2F2F62616679626569666F73776A6B33666775726F6F6F767864326E7372336B676164706768633732366A683672776579776432656E736E74686777792F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5499938F0000018B",
"URI": "697066733A2F2F6261667962656961663473797979367A6C6E76716F3664646A326779727A786C6F7779636F6C74746A6777676F33637270373333336E7A676767652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5C6E313C000000FA",
"URI": "697066733A2F2F626166796265696669793734673662767575646A6E757A6661676F6368656E6C6936666E3633616C6C6C717562617A756C7362736F636C636B66342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5D44EE22000001F0",
"URI": "697066733A2F2F62616679626569636171686F6D7A6F36677334656761376D68647A6D6E6F67657274687337776C78777677746B33696B64646E6D7A647273637A6D2F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5F8AA66A00000228",
"URI": "697066733A2F2F626166796265696161736F7073366D6D783772616732743464687833616B3374747432683462647274657279786C373662366C78646E6A7962336D2F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB61651529000001E5",
"URI": "697066733A2F2F62616679626569637432737174363732766563677232367862776E797A373365657565777A37616D32736869767578376E756232367837326D62342F6D657461646174612E6A736F6E"
}
}
],
"NextPageMin": "05BDF50FBDEF54276A1C889252E71B4347C3A0BDE73120BB868538B400000182",
"PreviousPageMin": "05BDF50FBDEF54276A1C889252E71B4347C3A0BDE73120BB175153BE0000007C"
},
"LedgerEntryType": "NFTokenPage",
"LedgerIndex": "05BDF50FBDEF54276A1C889252E71B4347C3A0BDE73120BB626863EE000000AC",
"PreviousFields": {
"NFTokens": [
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB1AD9556900000225",
"URI": "697066733A2F2F62616679626569626732726B6B6768616B6B727433696D61656F6D6D65377164747169687A756F713272327875637872776478676565356A7272652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB1EF9501C0000021A",
"URI": "697066733A2F2F62616679626569626A74736F7270637879366465797A666B3233676D6863786E67356C7536746277786E786269627667776575357172356B7A34752F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB1FFCAED5000000E1",
"URI": "697066733A2F2F6261667962656962736432653571337674686375777034746868336F6B633673746F676C696D6873746C70347663336564333632796375346978342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB21D71D900000009E",
"URI": "697066733A2F2F6261667962656964736B686B746C646233686F6F637A786A7577766932377835696C637677776278696C33366371366736746362667478653573612F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB22ADCA8600000194",
"URI": "697066733A2F2F6261667962656964786336343471776B35626172357036756561376C747A786F3737786B647665616666633435337A66777565646737336B7966752F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB24F382CE000001CC",
"URI": "697066733A2F2F62616679626569626A363563346E77737A3773756C773364756D6E776B6F616D6E786770716270656E726D6567356F76657067763233356C687A342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB25F7188700000093",
"URI": "697066733A2F2F626166796265696371767069796C6271616D6371336C636175727A706A696465367468346233376C68346A7766786C65646C63686533756F6179342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB28A8254800000146",
"URI": "697066733A2F2F626166796265696571627072637873686370647865677268686B6C786570666535376970696E6571687137656C706F68326B356E32753571706C792F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB2F794C20000001EE",
"URI": "697066733A2F2F626166796265696832656D6A7A616A687337747A6B616C68646B756D363737357678326F76616C33726F6D696368336A3434326A6F3468366166342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB31BF046800000226",
"URI": "697066733A2F2F6261667962656965696E7A787774776B7672666E646E626A7061636D61776E6C7A7564616A726473616777703474676B6F643363756477697337692F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB38BCCC930000009F",
"URI": "697066733A2F2F62616679626569636E6678796D66676D70346A6E7365716678617A7633326E65796D697333357769637333336333616B616D72707773323233716D2F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB3B6DE94400000152",
"URI": "697066733A2F2F626166796265696435726C676577667762736676683368346C7434756B763267766A7634656B61736778327A766A6D67377166773775737A7576342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB3BD97DC1000001CD",
"URI": "697066733A2F2F62616679626569656A6B677A706C6766616775737564646174326A3335657163756A3762337376356D6C3568613569786676327535747A337170652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB3F2283CE000000CC",
"URI": "697066733A2F2F62616679626569667670746C366B69666C746E3661766F6179663473347A3364796466796B6A666466646A626A76746575696A706B626A336733752F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB3F8E144B00000147",
"URI": "697066733A2F2F62616679626569636675336272636F6C6962767171727736703464617772636A6B75737877637436366C6F736C797576636D766C66766D643478692F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB41D3AFB30000017F",
"URI": "697066733A2F2F6261667962656967796166656E357877766F346973706E777A3275376E696664687477366C686A376A6E37333334643732366A36656178367377342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB45F3AAA600000174",
"URI": "697066733A2F2F626166796265696774766B3336696F766C68777562326F6B6934747069726670647070337437747171777A6F36746D33706575373478636C3474712F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB465F3F23000001EF",
"URI": "697066733A2F2F62616679626569646B37796D37736775747A7A766E70736669796B6A7379733565646568637936707370756C74337137646B696F7A737A376271652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB47CE1E6500000131",
"URI": "697066733A2F2F6261667962656968627A683362786C76716578327163747665616B71656271357066366468637569773779796D6C696E6A346F74327636736937612F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB48A4F76B00000227",
"URI": "697066733A2F2F626166796265696179766F6C686F3462777A736D6A69363633337174696975776B71753664726272746877667277626236346B62776174346E76342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB49A84D20000000EE",
"URI": "697066733A2F2F62616679626569633269337535366163646A6764643573733434753674743767656B35796A6D637933766E71676F3265633734686D6D6D676D74612F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB4B82B0EF000000AB",
"URI": "697066733A2F2F626166796265696462756637356D67616A6F63336969363465667675786D64356F7236746C3236356E7865623675616A34656232356F35657066652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB4DC848D7000000E3",
"URI": "697066733A2F2F626166796265696169746C677662756774636B37786C6C6934717378683434663467687A6171376B6F6662666135657A6D796A336C7461766877612F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5079949800000196",
"URI": "697066733A2F2F62616679626569666F616B736468666A63716575783676766577377078326E34786F6773656E7133377A6176656233696973666E6D64347A6666342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5253D84700000153",
"URI": "697066733A2F2F62616679626569633735366A6F6263786961346776643477717634696E6E766F6C6C75767068676171666161656168353676626C713471343434792F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB52BF2CC0000001CE",
"URI": "697066733A2F2F626166796265696268626E6F356664353272717663656A6769656C336B6E796C77727A366A747233767A77336B75656F363674697033716B36356D2F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB542E0F0200000110",
"URI": "697066733A2F2F62616679626569666F73776A6B33666775726F6F6F767864326E7372336B676164706768633732366A683672776579776432656E736E74686777792F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5499938F0000018B",
"URI": "697066733A2F2F6261667962656961663473797979367A6C6E76716F3664646A326779727A786C6F7779636F6C74746A6777676F33637270373333336E7A676767652F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5C6E313C000000FA",
"URI": "697066733A2F2F626166796265696669793734673662767575646A6E757A6661676F6368656E6C6936666E3633616C6C6C717562617A756C7362736F636C636B66342F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5D44EE22000001F0",
"URI": "697066733A2F2F62616679626569636171686F6D7A6F36677334656761376D68647A6D6E6F67657274687337776C78777677746B33696B64646E6D7A647273637A6D2F6D657461646174612E6A736F6E"
}
},
{
"NFToken": {
"NFTokenID": "00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB61651529000001E5",
"URI": "697066733A2F2F62616679626569637432737174363732766563677232367862776E797A373365657565777A37616D32736869767578376E756232367837326D62342F6D657461646174612E6A736F6E"
}
}
]
},
"PreviousTxnID": "C6DDE35463575822835391EAC1E6E03CC7545EFE0144D8D410FB5EA6A9746CE0",
"PreviousTxnLgrSeq": 77781454
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rXMART8usFd5kABXCayoP6ZfB35b4v43t",
"Balance": "16344096437",
"Domain": "786D6172742E617274",
"EmailHash": "D48190C85BE485DEA4CF4A56A8E93772",
"Flags": 0,
"OwnerCount": 4816,
"Sequence": 72168793
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "141E89D379C6949CA34BCB244DCBB7A6B2889781B157119CCC05ED19DFB676B0",
"PreviousFields": {
"Balance": "16344096449",
"Sequence": 72168792
},
"PreviousTxnID": "E17B8C46E87FD5FADA045AD19A572661F01DEC6CFB7A24536211EF8999A99C47",
"PreviousTxnLgrSeq": 77781459
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rMhoejpvS8mWfiffy4Zj8H2KbVs1oZCVsP",
"Balance": "1471369312",
"BurnedNFTokens": 1,
"Domain": "706978656C736F66756B69796F2E636F6D",
"Flags": 8388608,
"MintedNFTokens": 553,
"NFTokenMinter": "rXMART8usFd5kABXCayoP6ZfB35b4v43t",
"OwnerCount": 19,
"Sequence": 77578378
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "9DA74F431B2F406947558A12C01D4A080CAA5AC3FFA221C444E32A89B56C519A",
"PreviousFields": {
"MintedNFTokens": 552
},
"PreviousTxnID": "C6DDE35463575822835391EAC1E6E03CC7545EFE0144D8D410FB5EA6A9746CE0",
"PreviousTxnLgrSeq": 77781454
}
}
],
"TransactionIndex": 42,
"TransactionResult": "tesSUCCESS"
},
"hash": "1C57BFD847DBBAB78211229AA9AC8965B8EF705390ABAD8C2E79C98520EE9B10",
"ledger_index": 77781462,
"date": 1676330052000
}

View File

@@ -0,0 +1,348 @@
{
"tx": {
"Account": "rJMBXARKGNGTP5428VdksLLEbPYP5dxn9d",
"Fee": "5500",
"Flags": 8,
"LastLedgerSequence": 77804703,
"Memos": [
{
"Memo": {
"MemoData": "43726561746564206F6E206E66742E6F6E7872702E636F6D"
}
}
],
"NFTokenTaxon": 23935453,
"Sequence": 72918661,
"SigningPubKey": "021E4C21B87E989C95EBBB228738A3E73F169E6F9CA73CE4FDA5B5827AF34987DF",
"TransactionType": "NFTokenMint",
"TransferFee": 4700,
"TxnSignature": "3045022100E18E831549F5E5E59AFF7D13DB6AF41CAD3E1F0BB447FC48D7007E08A03E82D7022039D279BDDEA2C5BFCD24CB67FF875D1D6058AB7CFC3CD6030A29DF6EC375FE26",
"URI": "697066733A2F2F516D594B71784A347779696E38466A6F516A55797363704E7167627568537373646631726F675334353144315161",
"date": 1676421542000,
"warnings": [
{
"id": 1004,
"message": "This is a reporting server. The default behavior of a reporting server is to only return validated data. If you are looking for not yet validated data, include \"ledger_index : current\" in your request, which will cause this server to forward the request to a p2p node. If the forward is successful the response will include \"forwarded\" : \"true\""
}
]
},
"meta": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Flags": 0,
"NFTokens": [
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF32DC40200000218",
"URI": "697066733A2F2F516D564D527647464D68635637416D5153375A31535A3753667645546F4A4E4E4C6F68694E67356F647251557242"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF424182F00000303",
"URI": "697066733A2F2F516D6167744843744D394D5259343777744B7841744138576E3942726652577A484D48444E74344735344E6D6D45"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF58F04F000000192",
"URI": "697066733A2F2F516D644562464C6A5261794D425532383243685731545979526A4E6F6D6A397375645A32323275427379434C4675"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF593075100000245",
"URI": "697066733A2F2F516D65384A37335478556A6A4551583651686434317A75536B4A316B4637644A574543424B46534771504B525536"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF5FEABEA000002C0",
"URI": "697066733A2F2F516D515175517266675666376D336A54716E6A726A63554B4A5A3439696374536235654D65783979566F6363326B"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF64A555000000346",
"URI": "697066733A2F2F516D596445464A39577A4D615375543438423272317A777034717A78506442384155436866584874765141675A71"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF6B5F9ED000003C1",
"URI": "697066733A2F2F516D584668746251444D3239443539336A48504C4869554A4B586A776A776D56746F744346616172677A6374694C"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF6D2C66C00000016",
"URI": "697066733A2F2F516D6466386D4467535778415A59663133575A746A627464736A6B5A636A355A6564676F4C44576468384B32684B"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF74DCF190000020D",
"URI": "697066733A2F2F516D55614877636E6E6B62354357653858336D6E704D7575517A695777774B6545436F42326E6E724B57364D486A"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF7D1B0370000014F",
"URI": "697066733A2F2F516D62755332414276576D4B57366D5437736F715346384C766952314C75767263794258574E57675755486F6864"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF844E322000002F8",
"URI": "697066733A2F2F516D6234756343754859677635394A5350325A5039767045764E6D7A515071504C323277563874636D33774D4144"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF86F7BFF00000187",
"URI": "697066733A2F2F516D614A6B337464574C46513166593436734A707842566446697567326455343478686B516373543336384E4848"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF8AF97BF00000373",
"URI": "697066733A2F2F516D54474B6975326A386D683454784A57596F586E3474346A644A4A48467A36764675726B4D554C345571397071"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFA6A50670000033B",
"URI": "697066733A2F2F516D54597A6A3262506F616B36593943734272526B735277426D3745574A44686F4577556661324B7A5534757733"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFA766254000003EE",
"URI": "697066733A2F2F516D594B71784A347779696E38466A6F516A55797363704E7167627568537373646631726F675334353144315161"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFAD5C4E0000003B6",
"URI": "697066733A2F2F516D53774855547A4E585153356E64484E633565566B6359794A73656E5458736F6E6F6779475A54486142554B73"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFC4F7ECA0000017C",
"URI": "697066733A2F2F516D656B4E7435595A6F4B6E78764667345745504E694C5042524D324E4B33594837454E43386162535946454A66"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFCCF92B200000368",
"URI": "697066733A2F2F516D614E555A3470484B73714439366279526E623746356D6B477279634A576E696B615A566D6239396D396E3745"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFD3B07CF000003E3",
"URI": "697066733A2F2F516D55426F325242596F70526A656F4A7134686570366A57663258716E7A344B46366866537754636463564B5052"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFE1EB6E1000002B5",
"URI": "697066733A2F2F516D563348623434313776687352637963726470537A757262514E5755394E345443733548345038697A5335686D"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFE8A5B7A00000330",
"URI": "697066733A2F2F516D656144416F6D4C596664344D6F586832674B754E3656776B794C36585377426B725155654870445944506A33"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFEF5CFF7000003AB",
"URI": "697066733A2F2F516D51783143755371523771653670786F6E6935575938796D5245334E75637A6B50364A7665356434505A573358"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFF48850300000043",
"URI": "697066733A2F2F516D5034674D485761396B777174327858733372383772585A6641674B437459626D73746D61754C795448526E75"
}
}
],
"PreviousPageMin": "BE4B401B2F62ED35CC67362165AA813CCA06316FCA06316FF2F2C36100000021"
},
"LedgerEntryType": "NFTokenPage",
"LedgerIndex": "BE4B401B2F62ED35CC67362165AA813CCA06316FFFFFFFFFFFFFFFFFFFFFFFFF",
"PreviousFields": {
"NFTokens": [
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF32DC40200000218",
"URI": "697066733A2F2F516D564D527647464D68635637416D5153375A31535A3753667645546F4A4E4E4C6F68694E67356F647251557242"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF424182F00000303",
"URI": "697066733A2F2F516D6167744843744D394D5259343777744B7841744138576E3942726652577A484D48444E74344735344E6D6D45"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF58F04F000000192",
"URI": "697066733A2F2F516D644562464C6A5261794D425532383243685731545979526A4E6F6D6A397375645A32323275427379434C4675"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF593075100000245",
"URI": "697066733A2F2F516D65384A37335478556A6A4551583651686434317A75536B4A316B4637644A574543424B46534771504B525536"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF5FEABEA000002C0",
"URI": "697066733A2F2F516D515175517266675666376D336A54716E6A726A63554B4A5A3439696374536235654D65783979566F6363326B"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF64A555000000346",
"URI": "697066733A2F2F516D596445464A39577A4D615375543438423272317A777034717A78506442384155436866584874765141675A71"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF6B5F9ED000003C1",
"URI": "697066733A2F2F516D584668746251444D3239443539336A48504C4869554A4B586A776A776D56746F744346616172677A6374694C"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF6D2C66C00000016",
"URI": "697066733A2F2F516D6466386D4467535778415A59663133575A746A627464736A6B5A636A355A6564676F4C44576468384B32684B"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF74DCF190000020D",
"URI": "697066733A2F2F516D55614877636E6E6B62354357653858336D6E704D7575517A695777774B6545436F42326E6E724B57364D486A"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF7D1B0370000014F",
"URI": "697066733A2F2F516D62755332414276576D4B57366D5437736F715346384C766952314C75767263794258574E57675755486F6864"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF844E322000002F8",
"URI": "697066733A2F2F516D6234756343754859677635394A5350325A5039767045764E6D7A515071504C323277563874636D33774D4144"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF86F7BFF00000187",
"URI": "697066733A2F2F516D614A6B337464574C46513166593436734A707842566446697567326455343478686B516373543336384E4848"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FF8AF97BF00000373",
"URI": "697066733A2F2F516D54474B6975326A386D683454784A57596F586E3474346A644A4A48467A36764675726B4D554C345571397071"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFA6A50670000033B",
"URI": "697066733A2F2F516D54597A6A3262506F616B36593943734272526B735277426D3745574A44686F4577556661324B7A5534757733"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFAD5C4E0000003B6",
"URI": "697066733A2F2F516D53774855547A4E585153356E64484E633565566B6359794A73656E5458736F6E6F6779475A54486142554B73"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFC4F7ECA0000017C",
"URI": "697066733A2F2F516D656B4E7435595A6F4B6E78764667345745504E694C5042524D324E4B33594837454E43386162535946454A66"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFCCF92B200000368",
"URI": "697066733A2F2F516D614E555A3470484B73714439366279526E623746356D6B477279634A576E696B615A566D6239396D396E3745"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFD3B07CF000003E3",
"URI": "697066733A2F2F516D55426F325242596F70526A656F4A7134686570366A57663258716E7A344B46366866537754636463564B5052"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFE1EB6E1000002B5",
"URI": "697066733A2F2F516D563348623434313776687352637963726470537A757262514E5755394E345443733548345038697A5335686D"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFE8A5B7A00000330",
"URI": "697066733A2F2F516D656144416F6D4C596664344D6F586832674B754E3656776B794C36585377426B725155654870445944506A33"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFEF5CFF7000003AB",
"URI": "697066733A2F2F516D51783143755371523771653670786F6E6935575938796D5245334E75637A6B50364A7665356434505A573358"
}
},
{
"NFToken": {
"NFTokenID": "0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFF48850300000043",
"URI": "697066733A2F2F516D5034674D485761396B777174327858733372383772585A6641674B437459626D73746D61754C795448526E75"
}
}
]
},
"PreviousTxnID": "12E8B027A922BDDD80E89005D1E813AA52E6BFC02C72AC490E002A3F3D2448A4",
"PreviousTxnLgrSeq": 77803196
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rJMBXARKGNGTP5428VdksLLEbPYP5dxn9d",
"Balance": "509694877",
"BurnedNFTokens": 206,
"Flags": 0,
"MintedNFTokens": 1007,
"OwnerCount": 38,
"Sequence": 72918662
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "E3EDB522680D817CCE9CBC714D33EC5F567478D2DB551617A41856456D532AB2",
"PreviousFields": {
"Balance": "509700377",
"MintedNFTokens": 1006,
"Sequence": 72918661
},
"PreviousTxnID": "8E476510367BF294618730C443D2A22D9857B37C407DB7D7C6A5D4D477359033",
"PreviousTxnLgrSeq": 77804606
}
}
],
"TransactionIndex": 16,
"TransactionResult": "tesSUCCESS"
},
"hash": "77130966274E7DB385AC262A944AC20178611EE694EE0CA75A32C8760791521F",
"ledger_index": 77804695,
"date": 1676421542000
}

View File

@@ -12,6 +12,7 @@
"converge_time_s": 2.007,
"proposers": 4
},
"network_id": 21338,
"load_factor": 1,
"peers": 53,
"pubkey_node": "n94wWvFUmaKGYrKUGgpv1DyYgDeXRGdACkNQaSe7zJiy5Znio7UC",

View File

@@ -0,0 +1,68 @@
import { assert } from 'chai'
import _ from 'lodash'
import { Client } from 'xrpl'
import {
convertStringToHex,
getNFTokenID,
NFTokenMint,
TransactionMetadata,
} from '../../../src'
// how long before each test case times out
const TIMEOUT = 20000
describe('NFTokenMint', function () {
// TODO: Once we update our integration tests to handle NFTs, replace this client with XrplIntegrationTestContext
it(
'get NFTokenID',
async function () {
const client = new Client('wss://s.altnet.rippletest.net:51233/')
await client.connect()
const { wallet, balance: _balance } = await client.fundWallet()
const tx: NFTokenMint = {
TransactionType: 'NFTokenMint',
Account: wallet.address,
URI: convertStringToHex('https://www.google.com'),
NFTokenTaxon: 0,
}
try {
const response = await client.submitAndWait(tx, {
wallet,
})
assert.equal(response.type, 'response')
assert.equal(
(response.result.meta as TransactionMetadata).TransactionResult,
'tesSUCCESS',
)
const accountNFTs = await client.request({
command: 'account_nfts',
account: wallet.address,
})
const nftokenID =
getNFTokenID(response.result.meta as TransactionMetadata) ??
'undefined'
const accountHasNFT = accountNFTs.result.account_nfts.some(
(value) => value.NFTokenID === nftokenID,
)
assert.isTrue(
accountHasNFT,
`Expected to find an NFT with NFTokenID ${nftokenID} in account ${
wallet.address
} but did not find it.
\n\nHere's what was returned from 'account_nfts' for ${
wallet.address
}: ${JSON.stringify(accountNFTs)}`,
)
} finally {
await client.disconnect()
}
},
TIMEOUT,
)
})

View File

@@ -19,6 +19,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -32,6 +33,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -44,6 +46,7 @@ describe('NFTokenAcceptOffer', function () {
TransactionType: 'NFTokenAcceptOffer',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -62,6 +65,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
NFTokenBrokerFee: '1',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -80,6 +84,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
NFTokenBrokerFee: '1',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -98,6 +103,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -113,6 +119,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenBrokerFee: '1',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -128,6 +135,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
NFTokenBrokerFee: '0',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -147,6 +155,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
NFTokenBrokerFee: '-1',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -166,6 +175,7 @@ describe('NFTokenAcceptOffer', function () {
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
NFTokenBrokerFee: 1,
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any

View File

@@ -17,6 +17,7 @@ describe('NFTokenBurn', function () {
NFTokenID: TOKEN_ID,
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any
@@ -29,6 +30,7 @@ describe('NFTokenBurn', function () {
TransactionType: 'NFTokenBurn',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: 2147483648,
} as any

View File

@@ -14,6 +14,7 @@ describe('NFTokenCancelOffer', function () {
it(`verifies valid NFTokenCancelOffer`, function () {
const validNFTokenCancelOffer = {
TransactionType: 'NFTokenCancelOffer',
NetworkID: 21338,
NFTokenOffers: [BUY_OFFER],
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
@@ -28,6 +29,7 @@ describe('NFTokenCancelOffer', function () {
const invalid = {
TransactionType: 'NFTokenCancelOffer',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
NetworkID: 21338,
Fee: '5000000',
Sequence: 2470665,
Flags: 2147483648,
@@ -44,6 +46,7 @@ describe('NFTokenCancelOffer', function () {
const invalid = {
TransactionType: 'NFTokenCancelOffer',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
NetworkID: 21338,
NFTokenOffers: [],
Fee: '5000000',
Sequence: 2470665,

View File

@@ -14,6 +14,7 @@ describe('NFTokenCreateOffer', function () {
it(`verifies valid NFTokenCreateOffer buyside`, function () {
const validNFTokenCreateOffer = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
NFTokenID: NFTOKEN_ID,
Amount: '1',
Owner: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
@@ -30,6 +31,7 @@ describe('NFTokenCreateOffer', function () {
it(`verifies valid NFTokenCreateOffer sellside`, function () {
const validNFTokenCreateOffer = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
NFTokenID: NFTOKEN_ID,
Amount: '1',
Flags: NFTokenCreateOfferFlags.tfSellNFToken,
@@ -46,6 +48,7 @@ describe('NFTokenCreateOffer', function () {
it(`verifies w/ 0 Amount NFTokenCreateOffer sellside`, function () {
const validNFTokenCreateOffer = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
NFTokenID: NFTOKEN_ID,
Amount: '0',
Flags: NFTokenCreateOfferFlags.tfSellNFToken,
@@ -62,6 +65,7 @@ describe('NFTokenCreateOffer', function () {
it(`throws w/ Account === Owner`, function () {
const invalid = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
NFTokenID: NFTOKEN_ID,
Amount: '1',
Expiration: 1000,
@@ -81,6 +85,7 @@ describe('NFTokenCreateOffer', function () {
it(`throws w/ Account === Destination`, function () {
const invalid = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
NFTokenID: NFTOKEN_ID,
Amount: '1',
Flags: NFTokenCreateOfferFlags.tfSellNFToken,
@@ -101,6 +106,7 @@ describe('NFTokenCreateOffer', function () {
it(`throws w/out NFTokenID`, function () {
const invalid = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
Amount: '1',
Owner: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXe',
Expiration: 1000,
@@ -120,6 +126,7 @@ describe('NFTokenCreateOffer', function () {
it(`throws w/ invalid Amount`, function () {
const invalid = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
NFTokenID: NFTOKEN_ID,
Amount: 1,
Owner: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXe',
@@ -140,6 +147,7 @@ describe('NFTokenCreateOffer', function () {
it(`throws w/ missing Amount`, function () {
const invalid = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
Owner: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXe',
Expiration: 1000,
NFTokenID: NFTOKEN_ID,
@@ -159,6 +167,7 @@ describe('NFTokenCreateOffer', function () {
it(`throws w/ Owner for sell offer`, function () {
const invalid = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
Expiration: 1000,
Owner: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
@@ -179,6 +188,7 @@ describe('NFTokenCreateOffer', function () {
it(`throws w/out Owner for buy offer`, function () {
const invalid = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
Expiration: 1000,
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Amount: '1',
@@ -197,6 +207,7 @@ describe('NFTokenCreateOffer', function () {
it(`throws w/ 0 Amount for buy offer`, function () {
const invalid = {
TransactionType: 'NFTokenCreateOffer',
NetworkID: 21338,
Expiration: 1000,
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Owner: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',

View File

@@ -18,6 +18,7 @@ describe('NFTokenMint', function () {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
NFTokenTaxon: 0,
@@ -34,6 +35,7 @@ describe('NFTokenMint', function () {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
Issuer: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
@@ -53,6 +55,7 @@ describe('NFTokenMint', function () {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
Issuer: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
@@ -73,6 +76,7 @@ describe('NFTokenMint', function () {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
NetworkID: 21338,
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
NFTokenTaxon: 0,

View File

@@ -13,6 +13,7 @@ describe('AccountDelete', function () {
const validAccountDelete = {
TransactionType: 'AccountDelete',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
NetworkID: 21338,
Destination: 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe',
DestinationTag: 13,
Fee: '5000000',
@@ -27,6 +28,7 @@ describe('AccountDelete', function () {
const invalidDestination = {
TransactionType: 'AccountDelete',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
NetworkID: 21338,
Fee: '5000000',
Sequence: 2470665,
Flags: 2147483648,
@@ -49,6 +51,7 @@ describe('AccountDelete', function () {
const invalidDestination = {
TransactionType: 'AccountDelete',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
NetworkID: 21338,
Destination: 65478965,
Fee: '5000000',
Sequence: 2470665,
@@ -71,6 +74,7 @@ describe('AccountDelete', function () {
const invalidDestinationTag = {
TransactionType: 'AccountDelete',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
NetworkID: 21338,
Destination: 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe',
DestinationTag: 'gvftyujnbv',
Fee: '5000000',

View File

@@ -15,6 +15,7 @@ describe('AccountSet', function () {
account = {
TransactionType: 'AccountSet',
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
NetworkID: 21338,
Fee: '12',
Sequence: 5,
Domain: '6578616D706C652E636F6D',
@@ -30,7 +31,7 @@ describe('AccountSet', function () {
})
it(`throws w/ invalid SetFlag (out of range)`, function () {
account.SetFlag = 12
account.SetFlag = 20
assert.throws(
() => validateAccountSet(account),
@@ -60,7 +61,7 @@ describe('AccountSet', function () {
})
it(`throws w/ invalid ClearFlag`, function () {
account.ClearFlag = 12
account.ClearFlag = 20
assert.throws(
() => validateAccountSet(account),

View File

@@ -13,6 +13,7 @@ describe('BaseTransaction', function () {
const txJson = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
Fee: '12',
Sequence: 100,
AccountTxnID: 'DEADBEEF',
@@ -63,6 +64,7 @@ describe('BaseTransaction', function () {
const txJson = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
}
assert.doesNotThrow(() => validateBaseTransaction(txJson))
@@ -72,6 +74,7 @@ describe('BaseTransaction', function () {
const invalidFee = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
Fee: 1000,
} as any
@@ -86,6 +89,7 @@ describe('BaseTransaction', function () {
const invalidSeq = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
Sequence: '145',
} as any
@@ -100,6 +104,7 @@ describe('BaseTransaction', function () {
const invalidID = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
AccountTxnID: ['WRONG'],
} as any
@@ -114,6 +119,7 @@ describe('BaseTransaction', function () {
const invalidLastLedgerSequence = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
LastLedgerSequence: '1000',
} as any
@@ -128,6 +134,7 @@ describe('BaseTransaction', function () {
const invalidSourceTag = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
SourceTag: ['ARRAY'],
} as any
@@ -142,6 +149,7 @@ describe('BaseTransaction', function () {
const invalidSigningPubKey = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
SigningPubKey: 1000,
} as any
@@ -156,6 +164,7 @@ describe('BaseTransaction', function () {
const invalidTicketSequence = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
TicketSequence: '1000',
} as any
@@ -170,6 +179,7 @@ describe('BaseTransaction', function () {
const invalidTxnSignature = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
TxnSignature: 1000,
} as any
@@ -180,10 +190,25 @@ describe('BaseTransaction', function () {
)
})
it(`Handles invalid NetworkID`, function () {
const invalidTxnSignature = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: '21338',
} as any
assert.throws(
() => validateBaseTransaction(invalidTxnSignature),
ValidationError,
'BaseTransaction: invalid NetworkID',
)
})
it(`Handles invalid Signers`, function () {
const invalidSigners = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
Signers: [],
} as any
@@ -196,6 +221,7 @@ describe('BaseTransaction', function () {
const invalidSigners2 = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
Signers: [
{
Signer: {
@@ -216,6 +242,7 @@ describe('BaseTransaction', function () {
const invalidMemo = {
Account: 'r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe',
TransactionType: 'Payment',
NetworkID: 21338,
Memos: [
{
Memo: {

View File

@@ -13,6 +13,7 @@ describe('CheckCancel', function () {
const validCheckCancel = {
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
TransactionType: 'CheckCancel',
NetworkID: 21338,
CheckID:
'49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0',
} as any

View File

@@ -13,6 +13,7 @@ describe('CheckCash', function () {
const validCheckCash = {
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
NetworkID: 21338,
Amount: '100000000',
CheckID:
'838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334',
@@ -27,6 +28,7 @@ describe('CheckCash', function () {
const invalidCheckID = {
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
NetworkID: 21338,
Amount: '100000000',
CheckID: 83876645678567890,
} as any
@@ -47,6 +49,7 @@ describe('CheckCash', function () {
const invalidAmount = {
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
NetworkID: 21338,
Amount: 100000000,
CheckID:
'838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334',
@@ -68,6 +71,7 @@ describe('CheckCash', function () {
const invalidDeliverMin = {
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
NetworkID: 21338,
Amount: '100000000',
DeliverMin: 852156963,
CheckID:
@@ -90,6 +94,7 @@ describe('CheckCash', function () {
const invalidDeliverMin = {
Account: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
TransactionType: 'CheckCash',
NetworkID: 21338,
DeliverMin: 852156963,
CheckID:
'838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334',

View File

@@ -20,6 +20,7 @@ describe('CheckCreate', function () {
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: 1,
Fee: '12',
NetworkID: 21338,
} as any
assert.doesNotThrow(() => validateCheckCreate(validCheck))
@@ -37,6 +38,7 @@ describe('CheckCreate', function () {
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: 1,
Fee: '12',
NetworkID: 21338,
} as any
assert.throws(
@@ -62,6 +64,7 @@ describe('CheckCreate', function () {
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: 1,
Fee: '12',
NetworkID: 21338,
} as any
assert.throws(
@@ -80,6 +83,7 @@ describe('CheckCreate', function () {
const invalidDestinationTag = {
TransactionType: 'CheckCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
NetworkID: 21338,
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
SendMax: '100000000',
Expiration: 570113521,
@@ -112,6 +116,7 @@ describe('CheckCreate', function () {
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
DestinationTag: 1,
Fee: '12',
NetworkID: 21338,
} as any
assert.throws(
@@ -136,6 +141,7 @@ describe('CheckCreate', function () {
InvoiceID: 789656963258531,
DestinationTag: 1,
Fee: '12',
NetworkID: 21338,
} as any
assert.throws(

View File

@@ -15,6 +15,7 @@ describe('DepositPreauth', function () {
depositPreauth = {
TransactionType: 'DepositPreauth',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
NetworkID: 21338,
} as any
})

View File

@@ -17,6 +17,7 @@ describe('EscrowCancel', function () {
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
Owner: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
OfferSequence: 7,
NetworkID: 21338,
}
})

View File

@@ -15,6 +15,7 @@ describe('EscrowCreate', function () {
escrow = {
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
TransactionType: 'EscrowCreate',
NetworkID: 21338,
Amount: '10000',
Destination: 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW',
CancelAfter: 533257958,
@@ -82,12 +83,12 @@ describe('EscrowCreate', function () {
assert.throws(
() => validateEscrowCreate(escrow),
ValidationError,
'EscrowCreate: Amount must be an Amount',
'EscrowCreate: Amount must be a string',
)
assert.throws(
() => validate(escrow),
ValidationError,
'EscrowCreate: Amount must be an Amount',
'EscrowCreate: Amount must be a string',
)
})

View File

@@ -15,6 +15,7 @@ describe('EscrowFinish', function () {
escrow = {
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
TransactionType: 'EscrowFinish',
NetworkID: 21338,
Owner: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
OfferSequence: 7,
Condition:

View File

@@ -15,6 +15,7 @@ describe('OfferCancel', function () {
offer = {
Account: 'rnKiczmiQkZFiDES8THYyLA2pQohC5C6EF',
Fee: '10',
NetworkID: 21338,
LastLedgerSequence: 65477334,
OfferSequence: 60797528,
Sequence: 60797535,

View File

@@ -13,6 +13,7 @@ describe('OfferCreate', function () {
const offer = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
NetworkID: 21338,
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
@@ -37,6 +38,7 @@ describe('OfferCreate', function () {
const offer2 = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
NetworkID: 21338,
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
@@ -59,6 +61,7 @@ describe('OfferCreate', function () {
const offer3 = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
NetworkID: 21338,
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
@@ -87,6 +90,7 @@ describe('OfferCreate', function () {
const offer = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
NetworkID: 21338,
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
@@ -120,6 +124,7 @@ describe('OfferCreate', function () {
const offer = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
NetworkID: 21338,
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
@@ -153,6 +158,7 @@ describe('OfferCreate', function () {
const offer = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
NetworkID: 21338,
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
@@ -182,6 +188,7 @@ describe('OfferCreate', function () {
const offer = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
NetworkID: 21338,
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,

View File

@@ -19,6 +19,7 @@ describe('Payment', function () {
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
DestinationTag: 1,
Fee: '12',
NetworkID: 21338,
Flags: 2147483648,
LastLedgerSequence: 65953073,
Sequence: 65923914,

View File

@@ -15,6 +15,7 @@ describe('PaymentChannelClaim', function () {
channel = {
Account: 'rB5Ux4Lv2nRx6eeoAAsZmtctnBQ2LiACnk',
TransactionType: 'PaymentChannelClaim',
NetworkID: 21338,
Channel:
'C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198',
Balance: '1000000',
@@ -77,12 +78,12 @@ describe('PaymentChannelClaim', function () {
assert.throws(
() => validatePaymentChannelClaim(channel),
ValidationError,
'PaymentChannelClaim: Balance must be an Amount',
'PaymentChannelClaim: Balance must be a string',
)
assert.throws(
() => validate(channel),
ValidationError,
'PaymentChannelClaim: Balance must be an Amount',
'PaymentChannelClaim: Balance must be a string',
)
})
@@ -92,12 +93,12 @@ describe('PaymentChannelClaim', function () {
assert.throws(
() => validatePaymentChannelClaim(channel),
ValidationError,
'PaymentChannelClaim: Amount must be an Amount',
'PaymentChannelClaim: Amount must be a string',
)
assert.throws(
() => validate(channel),
ValidationError,
'PaymentChannelClaim: Amount must be an Amount',
'PaymentChannelClaim: Amount must be a string',
)
})

View File

@@ -15,6 +15,7 @@ describe('PaymentChannelCreate', function () {
channel = {
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
TransactionType: 'PaymentChannelCreate',
NetworkID: 21338,
Amount: '10000',
Destination: 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW',
SettleDelay: 86400,
@@ -106,12 +107,12 @@ describe('PaymentChannelCreate', function () {
assert.throws(
() => validatePaymentChannelCreate(channel),
ValidationError,
'PaymentChannelCreate: Amount must be an Amount',
'PaymentChannelCreate: Amount must be a string',
)
assert.throws(
() => validate(channel),
ValidationError,
'PaymentChannelCreate: Amount must be an Amount',
'PaymentChannelCreate: Amount must be a string',
)
})

View File

@@ -15,6 +15,7 @@ describe('PaymentChannelFund', function () {
channel = {
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
TransactionType: 'PaymentChannelFund',
NetworkID: 21338,
Channel:
'C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198',
Amount: '200000',
@@ -70,12 +71,12 @@ describe('PaymentChannelFund', function () {
assert.throws(
() => validatePaymentChannelFund(channel),
ValidationError,
'PaymentChannelFund: Amount must be an Amount',
'PaymentChannelFund: Amount must be a string',
)
assert.throws(
() => validate(channel),
ValidationError,
'PaymentChannelFund: Amount must be an Amount',
'PaymentChannelFund: Amount must be a string',
)
})

View File

@@ -16,6 +16,7 @@ describe('SetRegularKey', function () {
TransactionType: 'SetRegularKey',
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
Fee: '12',
NetworkID: 21338,
Flags: 0,
RegularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD',
} as any

View File

@@ -17,6 +17,7 @@ describe('SignerListSet', function () {
TransactionType: 'SignerListSet',
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
Fee: '12',
NetworkID: 21338,
SignerQuorum: 3,
SignerEntries: [
{

View File

@@ -15,6 +15,7 @@ describe('TicketCreate', function () {
ticketCreate = {
TransactionType: 'TicketCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
NetworkID: 21338,
TicketCount: 150,
} as any
})

View File

@@ -15,6 +15,7 @@ describe('TrustSet', function () {
trustSet = {
TransactionType: 'TrustSet',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
NetworkID: 21338,
LimitAmount: {
currency: 'XRP',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',

View File

@@ -50,6 +50,7 @@ describe('Models Utils', function () {
const tx: OfferCreate = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
Fee: '10',
NetworkID: 21338,
TakerGets: {
currency: 'DSH',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
@@ -151,6 +152,7 @@ describe('Models Utils', function () {
assert.strictEqual(tx.Flags, 0)
})
// eslint-disable-next-line complexity -- Simpler to list them all out at once.
it('parseAccountRootFlags all enabled', function () {
const accountRootFlags =
AccountRootFlags.lsfDefaultRipple |
@@ -161,7 +163,11 @@ describe('Models Utils', function () {
AccountRootFlags.lsfNoFreeze |
AccountRootFlags.lsfPasswordSpent |
AccountRootFlags.lsfRequireAuth |
AccountRootFlags.lsfRequireDestTag
AccountRootFlags.lsfRequireDestTag |
AccountRootFlags.lsfDisallowIncomingNFTOffer |
AccountRootFlags.lsfDisallowIncomingCheck |
AccountRootFlags.lsfDisallowIncomingPayChan |
AccountRootFlags.lsfDisallowIncomingTrustline
const parsed = parseAccountRootFlags(accountRootFlags)
@@ -174,7 +180,11 @@ describe('Models Utils', function () {
parsed.lsfNoFreeze &&
parsed.lsfPasswordSpent &&
parsed.lsfRequireAuth &&
parsed.lsfRequireDestTag,
parsed.lsfRequireDestTag &&
parsed.lsfDisallowIncomingNFTOffer &&
parsed.lsfDisallowIncomingCheck &&
parsed.lsfDisallowIncomingPayChan &&
parsed.lsfDisallowIncomingTrustline,
)
})
@@ -190,6 +200,10 @@ describe('Models Utils', function () {
assert.isUndefined(parsed.lsfPasswordSpent)
assert.isUndefined(parsed.lsfRequireAuth)
assert.isUndefined(parsed.lsfRequireDestTag)
assert.isUndefined(parsed.lsfDisallowIncomingNFTOffer)
assert.isUndefined(parsed.lsfDisallowIncomingCheck)
assert.isUndefined(parsed.lsfDisallowIncomingPayChan)
assert.isUndefined(parsed.lsfDisallowIncomingTrustline)
})
})
})

View File

@@ -0,0 +1,28 @@
import { assert } from 'chai'
import { getNFTokenID } from '../../src'
import * as NFTokenResponse from '../fixtures/rippled/mintNFTMeta.json'
import * as NFTokenResponse2 from '../fixtures/rippled/mintNFTMeta2.json'
describe('parseNFTokenID', function () {
it('decode a valid NFTokenID', function () {
const result = getNFTokenID(NFTokenResponse.meta)
const expectedNFTokenID =
'00081388DC1AB4937C899037B2FDFC3CB20F6F64E73120BB5F8AA66A00000228'
assert.equal(result, expectedNFTokenID)
})
it('decode a different valid NFTokenID', function () {
const result = getNFTokenID(NFTokenResponse2.meta)
const expectedNFTokenID =
'0008125CBE4B401B2F62ED35CC67362165AA813CCA06316FFA766254000003EE'
assert.equal(result, expectedNFTokenID)
})
it('fails with nice error when given raw response instead of meta', function () {
assert.throws(() => {
// @ts-expect-error - Validating error for javascript users
const _ = getNFTokenID(NFTokenResponse)
}, /^Unable to parse the parameter given to getNFTokenID.*/u)
})
})