mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-05 05:15:48 +00:00
Compare commits
105 Commits
ripple-key
...
iouescrow-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edfdd42584 | ||
|
|
157a9d9409 | ||
|
|
6c6dade636 | ||
|
|
369c9fe7a4 | ||
|
|
31e52fbc3b | ||
|
|
038bbac34f | ||
|
|
0c4765d2e0 | ||
|
|
bc70d3b6c1 | ||
|
|
2d6ab38d33 | ||
|
|
00d4840501 | ||
|
|
8e90ecd350 | ||
|
|
b80521152d | ||
|
|
4693c91ec4 | ||
|
|
d890b81924 | ||
|
|
81f09ba043 | ||
|
|
46dd51b196 | ||
|
|
4d9a5cf4a0 | ||
|
|
e69d3913b8 | ||
|
|
34a01cf093 | ||
|
|
d29bdbb5de | ||
|
|
dd841c9441 | ||
|
|
8c83a12933 | ||
|
|
df0d32713a | ||
|
|
2c15d2c205 | ||
|
|
ffe93d0462 | ||
|
|
0787166f6a | ||
|
|
45008596a4 | ||
|
|
f5645126f9 | ||
|
|
f9957c5a3c | ||
|
|
7057b60d10 | ||
|
|
38a313b77c | ||
|
|
c52160c1c6 | ||
|
|
a3aa1f8613 | ||
|
|
6c03eec61b | ||
|
|
218ca41df3 | ||
|
|
c3bb4d9b72 | ||
|
|
65a8de6f47 | ||
|
|
3b19974634 | ||
|
|
b7283c5841 | ||
|
|
b41d671c10 | ||
|
|
61afad39c6 | ||
|
|
82d0d12d81 | ||
|
|
6ca13bc8dc | ||
|
|
33b02ee70a | ||
|
|
2cb81b21ef | ||
|
|
fbd485ff33 | ||
|
|
3dbe28ce98 | ||
|
|
764f8d7b5e | ||
|
|
d8930c5fb8 | ||
|
|
c8d24d65f5 | ||
|
|
e712d8fd8c | ||
|
|
8fbcb20129 | ||
|
|
a679128f02 | ||
|
|
9f15deed15 | ||
|
|
9b540c89f0 | ||
|
|
5541632b7f | ||
|
|
070413c9e8 | ||
|
|
c0c1507037 | ||
|
|
6b20053f7e | ||
|
|
81eb9668a0 | ||
|
|
c056ca0cd9 | ||
|
|
0ac00086df | ||
|
|
315a25b6f4 | ||
|
|
86ab93a299 | ||
|
|
f570ac6f8c | ||
|
|
0347e357eb | ||
|
|
3268a29843 | ||
|
|
96e97506f8 | ||
|
|
c1de808680 | ||
|
|
0196ccb097 | ||
|
|
bc50c6eb66 | ||
|
|
9673a85ca6 | ||
|
|
d41954f007 | ||
|
|
c26235f424 | ||
|
|
aa3443a347 | ||
|
|
2dc665e125 | ||
|
|
2065e6f040 | ||
|
|
9fb741f6f5 | ||
|
|
ecffb1375a | ||
|
|
5f97366947 | ||
|
|
43bf4b9e14 | ||
|
|
9de54dcea9 | ||
|
|
b6ee50f726 | ||
|
|
50335554ab | ||
|
|
ad4c952fbf | ||
|
|
df80702c6c | ||
|
|
58657f373c | ||
|
|
c4dd6fba84 | ||
|
|
dab0667b2f | ||
|
|
2c658fe145 | ||
|
|
c29319aad8 | ||
|
|
00796001a3 | ||
|
|
c371a38e87 | ||
|
|
492de32388 | ||
|
|
ac88bf3079 | ||
|
|
48214a90ca | ||
|
|
6508d048bf | ||
|
|
901a0e62e2 | ||
|
|
277725858d | ||
|
|
caddad737c | ||
|
|
29282298d6 | ||
|
|
9d58400373 | ||
|
|
0286b81745 | ||
|
|
3a93f60aab | ||
|
|
77199025f1 |
4
.github/workflows/nodejs.yml
vendored
4
.github/workflows/nodejs.yml
vendored
@@ -102,7 +102,7 @@ jobs:
|
||||
|
||||
services:
|
||||
rippled:
|
||||
image: natenichols/rippled-standalone:latest
|
||||
image: gcr.io/metaxrplorer/dangell7-iouescrow-standalone:1
|
||||
ports:
|
||||
- 6006:6006
|
||||
options: --health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s
|
||||
@@ -153,7 +153,7 @@ jobs:
|
||||
|
||||
services:
|
||||
rippled:
|
||||
image: natenichols/rippled-standalone:latest
|
||||
image: gcr.io/metaxrplorer/dangell7-iouescrow-standalone:1
|
||||
ports:
|
||||
- 6006:6006
|
||||
options: --health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s
|
||||
|
||||
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"editor.tabSize": 2,
|
||||
"cSpell.words": [
|
||||
"Multisigned",
|
||||
"Setf",
|
||||
"hostid",
|
||||
"Multisigned",
|
||||
"preauthorization",
|
||||
"secp256k1"
|
||||
"secp256k1",
|
||||
"Setf",
|
||||
"xchain"
|
||||
],
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
|
||||
118
create_validate.py
Normal file
118
create_validate.py
Normal file
@@ -0,0 +1,118 @@
|
||||
"""
|
||||
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())
|
||||
7
package-lock.json
generated
7
package-lock.json
generated
@@ -17129,7 +17129,8 @@
|
||||
}
|
||||
},
|
||||
"packages/ripple-binary-codec": {
|
||||
"version": "1.4.2",
|
||||
"version": "1.5.0-beta.0",
|
||||
"integrity": "sha512-XMRCbFXyG+dGp3x7tMs9IwA+FVWPPaGjdHYW2+g4Q/WQJqFp5MRED+jjOBOUafmrW4TUsOn1PEEdbB4ozWbDBw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"assert": "^2.0.0",
|
||||
@@ -17175,7 +17176,7 @@
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"ripple-address-codec": "^4.2.4",
|
||||
"ripple-binary-codec": "^1.4.2",
|
||||
"ripple-binary-codec": "^1.5.0-beta.0",
|
||||
"ripple-keypairs": "^1.1.4",
|
||||
"ws": "^8.2.2"
|
||||
},
|
||||
@@ -30596,7 +30597,7 @@
|
||||
"node-polyfill-webpack-plugin": "^2.0.1",
|
||||
"react": "^18.2.0",
|
||||
"ripple-address-codec": "^4.2.4",
|
||||
"ripple-binary-codec": "^1.4.2",
|
||||
"ripple-binary-codec": "^1.5.0-beta.0",
|
||||
"ripple-keypairs": "^1.1.4",
|
||||
"typedoc": "^0.23.24",
|
||||
"ws": "^8.2.2"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ripple-binary-codec",
|
||||
"version": "1.4.2",
|
||||
"version": "1.5.0-beta.0",
|
||||
"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 run build && npm test",
|
||||
"test": "jest --verbose false --silent=false ./test/*.test.js",
|
||||
"prepare": "npm test",
|
||||
"test": "npm run build && jest --verbose false --silent=false ./test/*.test.js",
|
||||
"lint": "eslint . --ext .ts --ext .test.js"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
@@ -11,6 +11,7 @@ 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
|
||||
@@ -95,7 +96,7 @@ function signingData(
|
||||
*/
|
||||
interface ClaimObject extends JsonObject {
|
||||
channel: string
|
||||
amount: string | number
|
||||
amount: AmountObject
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,16 +106,19 @@ 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)
|
||||
bytesList.put(amount)
|
||||
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)
|
||||
}
|
||||
return bytesList.toBytes()
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
"UInt192": 21,
|
||||
"UInt384": 22,
|
||||
"UInt512": 23,
|
||||
"Issue": 24,
|
||||
"XChainBridge": 25,
|
||||
"Transaction": 10001,
|
||||
"LedgerEntry": 10002,
|
||||
"Validation": 10003,
|
||||
@@ -34,8 +36,11 @@
|
||||
"Ticket": 84,
|
||||
"SignerList": 83,
|
||||
"Offer": 111,
|
||||
"Bridge": 105,
|
||||
"LedgerHashes": 104,
|
||||
"Amendments": 102,
|
||||
"XChainClaimID": 113,
|
||||
"XChainCreateAccountClaimID": 116,
|
||||
"FeeSettings": 115,
|
||||
"Escrow": 117,
|
||||
"PayChannel": 120,
|
||||
@@ -231,6 +236,16 @@
|
||||
"type": "UInt8"
|
||||
}
|
||||
],
|
||||
[
|
||||
"WasLockingChainSend",
|
||||
{
|
||||
"nth": 19,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "UInt8"
|
||||
}
|
||||
],
|
||||
[
|
||||
"LedgerEntryType",
|
||||
{
|
||||
@@ -761,6 +776,16 @@
|
||||
"type": "UInt32"
|
||||
}
|
||||
],
|
||||
[
|
||||
"LockCount",
|
||||
{
|
||||
"nth": 49,
|
||||
"isVLEncoded": false,
|
||||
"isSerialized": true,
|
||||
"isSigningField": true,
|
||||
"type": "UInt32"
|
||||
}
|
||||
],
|
||||
[
|
||||
"IndexNext",
|
||||
{
|
||||
@@ -931,6 +956,36 @@
|
||||
"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",
|
||||
{
|
||||
@@ -1421,6 +1476,36 @@
|
||||
"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",
|
||||
{
|
||||
@@ -1761,6 +1846,66 @@
|
||||
"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",
|
||||
{
|
||||
@@ -1811,6 +1956,36 @@
|
||||
"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",
|
||||
{
|
||||
@@ -2021,6 +2196,46 @@
|
||||
"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",
|
||||
{
|
||||
@@ -2160,6 +2375,46 @@
|
||||
"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": {
|
||||
@@ -2215,6 +2470,15 @@
|
||||
"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,
|
||||
@@ -2298,7 +2562,33 @@
|
||||
"tecCANT_ACCEPT_OWN_NFTOKEN_OFFER": 158,
|
||||
"tecINSUFFICIENT_FUNDS": 159,
|
||||
"tecOBJECT_NOT_FOUND": 160,
|
||||
"tecINSUFFICIENT_PAYMENT": 161
|
||||
"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
|
||||
},
|
||||
"TRANSACTION_TYPES": {
|
||||
"Invalid": -1,
|
||||
@@ -2330,6 +2620,14 @@
|
||||
"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
|
||||
|
||||
@@ -11,6 +11,7 @@ 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'
|
||||
@@ -19,6 +20,7 @@ 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,
|
||||
@@ -28,6 +30,7 @@ const coreTypes = {
|
||||
Hash128,
|
||||
Hash160,
|
||||
Hash256,
|
||||
Issue,
|
||||
PathSet,
|
||||
STArray,
|
||||
STObject,
|
||||
@@ -36,6 +39,7 @@ const coreTypes = {
|
||||
UInt32,
|
||||
UInt64,
|
||||
Vector256,
|
||||
XChainBridge,
|
||||
}
|
||||
|
||||
Object.values(Field).forEach((field) => {
|
||||
|
||||
96
packages/ripple-binary-codec/src/types/issue.ts
Normal file
96
packages/ripple-binary-codec/src/types/issue.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
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 }
|
||||
128
packages/ripple-binary-codec/src/types/xchain-bridge.ts
Normal file
128
packages/ripple-binary-codec/src/types/xchain-bridge.ts
Normal file
@@ -0,0 +1,128 @@
|
||||
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 }
|
||||
@@ -4435,20 +4435,207 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"transactions": [{
|
||||
"binary": "1200002200000000240000003E6140000002540BE40068400000000000000A7321034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E74473045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F17962646398114550FC62003E785DC231A1058A05E56E3F09CF4E68314D4CC8AB5B21D86A82C3E9E8D0ECF2404B77FECBA",
|
||||
"json": {
|
||||
"Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
|
||||
"Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj",
|
||||
"TransactionType": "Payment",
|
||||
"TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639",
|
||||
"SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E",
|
||||
"Amount": "10000000000",
|
||||
"Fee": "10",
|
||||
"Flags": 0,
|
||||
"Sequence": 62
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
"ledgerData": [{
|
||||
"binary": "01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00",
|
||||
"json": {
|
||||
@@ -4463,4 +4650,4 @@
|
||||
"transaction_hash": "DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ describe('Signing data', function () {
|
||||
].join(''),
|
||||
)
|
||||
})
|
||||
test('can create claim blob', function () {
|
||||
test('can create native claim blob', function () {
|
||||
const channel =
|
||||
'43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1'
|
||||
const amount = '1000'
|
||||
@@ -137,4 +137,27 @@ 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(''),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -26,6 +26,7 @@ Wallet.fromMmnemonic()
|
||||
|
||||
### Added
|
||||
* Optional custom amount field to `fundWallet`.
|
||||
* Support for the cross-chain bridge feature.
|
||||
|
||||
### Changed
|
||||
* Add support for Transaction objects in `verifyTransaction`
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"ripple-address-codec": "^4.2.4",
|
||||
"ripple-binary-codec": "^1.4.2",
|
||||
"ripple-binary-codec": "^1.5.0-beta.0",
|
||||
"ripple-keypairs": "^1.1.4",
|
||||
"ws": "^8.2.2"
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@ interface XRP {
|
||||
currency: 'XRP'
|
||||
}
|
||||
|
||||
interface IssuedCurrency {
|
||||
export interface IssuedCurrency {
|
||||
currency: string
|
||||
issuer: string
|
||||
}
|
||||
@@ -117,3 +117,10 @@ export interface NFTOffer {
|
||||
destination?: string
|
||||
expiration?: number
|
||||
}
|
||||
|
||||
export interface XChainBridge {
|
||||
LockingChainDoor: string
|
||||
LockingChainIssue: Currency
|
||||
IssuingChainDoor: string
|
||||
IssuingChainIssue: Currency
|
||||
}
|
||||
|
||||
41
packages/xrpl/src/models/ledger/Bridge.ts
Normal file
41
packages/xrpl/src/models/ledger/Bridge.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Amount } from '../common'
|
||||
|
||||
import BaseLedgerEntry from './BaseLedgerEntry'
|
||||
|
||||
/**
|
||||
* The Escrow object type represents a held payment of XRP waiting to be
|
||||
* The Escrow object type represents a held payment waiting to be
|
||||
* executed or canceled.
|
||||
*
|
||||
* @category Ledger Entries
|
||||
@@ -10,17 +12,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 XRP, and gets it back if the held payment is
|
||||
* account that provided the amounts, and gets it back if the held payment is
|
||||
* canceled.
|
||||
*/
|
||||
Account: string
|
||||
/**
|
||||
* The destination address where the XRP is paid if the held payment is
|
||||
* The destination address where the amounts are paid if the held payment is
|
||||
* successful.
|
||||
*/
|
||||
Destination: string
|
||||
/** The amount of XRP, in drops, to be delivered by the held payment. */
|
||||
Amount: string
|
||||
/** The amount to be delivered by the held payment. */
|
||||
Amount: Amount
|
||||
/**
|
||||
* A PREIMAGE-SHA-256 crypto-condition, as hexadecimal. If present, the
|
||||
* EscrowFinish transaction must contain a fulfillment that satisfies this
|
||||
@@ -71,4 +73,9 @@ 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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Amount } from '../common'
|
||||
|
||||
import BaseLedgerEntry from './BaseLedgerEntry'
|
||||
|
||||
/**
|
||||
* The PayChannel object type represents a payment channel. Payment channels
|
||||
* 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
|
||||
* enable small, rapid off-ledger payments that can be later reconciled
|
||||
* with the consensus ledger. A payment channel holds a balance that can
|
||||
* only be paid out to a specific destination address until the channel is
|
||||
* closed.
|
||||
*
|
||||
@@ -18,37 +20,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 XRP from the
|
||||
* channel is open, this address is the only one that can receive amounts from the
|
||||
* channel. This comes from the Destination field of the transaction that
|
||||
* created the channel.
|
||||
*/
|
||||
Destination: string
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
Amount: string
|
||||
Amount: Amount
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
Balance: string
|
||||
Balance: Amount
|
||||
/**
|
||||
* 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 XRP from this channel to the destination
|
||||
* source address can also send amounts 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 XRP in it. Smaller values mean that the destination
|
||||
* it still has any amount 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
|
||||
@@ -104,4 +106,10 @@ 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
|
||||
}
|
||||
|
||||
40
packages/xrpl/src/models/ledger/XChainOwnedClaimID.ts
Normal file
40
packages/xrpl/src/models/ledger/XChainOwnedClaimID.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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
|
||||
}
|
||||
@@ -3,6 +3,7 @@ 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'
|
||||
@@ -17,12 +18,15 @@ 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,
|
||||
@@ -40,4 +44,6 @@ export {
|
||||
SignerList,
|
||||
SignerListFlags,
|
||||
Ticket,
|
||||
XChainOwnedClaimID,
|
||||
XChainOwnedCreateAccountClaimID,
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { LedgerIndex } from '../common'
|
||||
import { Amount, LedgerIndex } from '../common'
|
||||
|
||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||
|
||||
interface Channel {
|
||||
account: string
|
||||
amount: string
|
||||
amount: Amount
|
||||
balance: string
|
||||
channel_id: string
|
||||
destination_account: string
|
||||
@@ -15,6 +15,7 @@ interface Channel {
|
||||
cancel_after?: number
|
||||
source_tab?: number
|
||||
destination_tag?: number
|
||||
transfer_rate?: number
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LedgerIndex } from '../common'
|
||||
import { Amount, LedgerIndex } from '../common'
|
||||
|
||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||
|
||||
@@ -64,6 +64,14 @@ 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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
RippleState,
|
||||
SignerList,
|
||||
Ticket,
|
||||
XChainOwnedClaimID,
|
||||
XChainOwnedCreateAccountClaimID,
|
||||
} from '../ledger'
|
||||
|
||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||
@@ -22,6 +24,8 @@ 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
|
||||
@@ -78,6 +82,8 @@ type AccountObject =
|
||||
| SignerList
|
||||
| RippleState
|
||||
| Ticket
|
||||
| XChainOwnedClaimID
|
||||
| XChainOwnedCreateAccountClaimID
|
||||
|
||||
/**
|
||||
* Response expected from an {@link AccountObjectsRequest}.
|
||||
|
||||
@@ -9,7 +9,7 @@ import { BaseRequest, BaseResponse } from './baseMethod'
|
||||
*/
|
||||
export interface ChannelVerifyRequest extends BaseRequest {
|
||||
command: 'channel_verify'
|
||||
/** The amount of XRP, in drops, the provided signature authorizes. */
|
||||
/** The amount the provided signature authorizes. */
|
||||
amount: string
|
||||
/**
|
||||
* The Channel ID of the channel that provides the XRP. This is a
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LedgerIndex } from '../common'
|
||||
import { Currency, LedgerIndex } from '../common'
|
||||
import { LedgerEntry } from '../ledger'
|
||||
|
||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||
@@ -137,6 +137,28 @@ 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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
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')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
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',
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
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',
|
||||
)
|
||||
}
|
||||
}
|
||||
80
packages/xrpl/src/models/transactions/XChainClaim.ts
Normal file
80
packages/xrpl/src/models/transactions/XChainClaim.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
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')
|
||||
}
|
||||
}
|
||||
71
packages/xrpl/src/models/transactions/XChainCommit.ts
Normal file
71
packages/xrpl/src/models/transactions/XChainCommit.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
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')
|
||||
}
|
||||
}
|
||||
62
packages/xrpl/src/models/transactions/XChainCreateBridge.ts
Normal file
62
packages/xrpl/src/models/transactions/XChainCreateBridge.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
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',
|
||||
)
|
||||
}
|
||||
}
|
||||
65
packages/xrpl/src/models/transactions/XChainCreateClaimID.ts
Normal file
65
packages/xrpl/src/models/transactions/XChainCreateClaimID.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
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',
|
||||
)
|
||||
}
|
||||
}
|
||||
67
packages/xrpl/src/models/transactions/XChainModifyBridge.ts
Normal file
67
packages/xrpl/src/models/transactions/XChainModifyBridge.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
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',
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,14 @@
|
||||
import { TRANSACTION_TYPES } from 'ripple-binary-codec'
|
||||
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount, IssuedCurrencyAmount, Memo, Signer } from '../common'
|
||||
import {
|
||||
Amount,
|
||||
IssuedCurrency,
|
||||
IssuedCurrencyAmount,
|
||||
Memo,
|
||||
Signer,
|
||||
XChainBridge,
|
||||
} from '../common'
|
||||
import { onlyHasFields } from '../utils'
|
||||
|
||||
const MEMO_SIZE = 3
|
||||
@@ -50,17 +57,37 @@ 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 malformed.
|
||||
* @returns Whether the IssuedCurrencyAmount is properly formed.
|
||||
*/
|
||||
export function isIssuedCurrency(
|
||||
input: unknown,
|
||||
@@ -78,12 +105,29 @@ 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 malformed.
|
||||
* @returns Whether the Amount is properly formed.
|
||||
*/
|
||||
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 {}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ValidationError } from '../../errors'
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
* Return escrowed XRP to the sender.
|
||||
* Return escrowed amount to the sender.
|
||||
*
|
||||
* @category Transaction Models
|
||||
*/
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
/* eslint-disable complexity -- Necessary for validateEscrowCreate */
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount } from '../common'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
* Sequester XRP until the escrow process either finishes or is canceled.
|
||||
* Sequester amount until the escrow process either finishes or is canceled.
|
||||
*
|
||||
* @category Transaction Models
|
||||
*/
|
||||
export interface EscrowCreate extends BaseTransaction {
|
||||
TransactionType: 'EscrowCreate'
|
||||
/**
|
||||
* 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 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: string
|
||||
/** Address to receive escrowed XRP. */
|
||||
Amount: Amount
|
||||
/** Address to receive escrowed amount. */
|
||||
Destination: string
|
||||
/**
|
||||
* The time, in seconds since the Ripple Epoch, when this escrow expires.
|
||||
@@ -25,7 +26,7 @@ export interface EscrowCreate extends BaseTransaction {
|
||||
*/
|
||||
CancelAfter?: number
|
||||
/**
|
||||
* The time, in seconds since the Ripple Epoch, when the escrowed XRP can be
|
||||
* The time, in seconds since the Ripple Epoch, when the escrowed amount can be
|
||||
* released to the recipient. This value is immutable; the funds cannot move.
|
||||
* until this time is reached.
|
||||
*/
|
||||
@@ -55,8 +56,8 @@ export function validateEscrowCreate(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('EscrowCreate: missing field Amount')
|
||||
}
|
||||
|
||||
if (typeof tx.Amount !== 'string') {
|
||||
throw new ValidationError('EscrowCreate: Amount must be a string')
|
||||
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
|
||||
throw new ValidationError('EscrowCreate: Amount must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.Destination === undefined) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ValidationError } from '../../errors'
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
* Deliver XRP from a held payment to the recipient.
|
||||
* Deliver amount from a held payment to the recipient.
|
||||
*
|
||||
* @category Transaction Models
|
||||
*/
|
||||
|
||||
@@ -45,3 +45,15 @@ 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'
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/* eslint-disable complexity -- Necessary for validatePaymentChannelClaim */
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount } from '../common'
|
||||
|
||||
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
|
||||
import {
|
||||
BaseTransaction,
|
||||
GlobalFlags,
|
||||
validateBaseTransaction,
|
||||
isAmount,
|
||||
} from './common'
|
||||
|
||||
/**
|
||||
* Enum representing values for PaymentChannelClaim transaction flags.
|
||||
@@ -18,15 +24,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 XRP allocated to it after processing the current claim, or if
|
||||
* has no more funds 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 XRP, this schedules the channel to close after
|
||||
* the channel still holds an amount, 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 XRP, any XRP that remains after processing the claim is returned to
|
||||
* the source address.
|
||||
* holds an amount, any amount that remains after processing the claim is
|
||||
* returned to the source address.
|
||||
*/
|
||||
tfClose = 0x00020000,
|
||||
}
|
||||
@@ -78,21 +84,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 XRP allocated to it after processing the current claim, or if
|
||||
* has no more funds 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 XRP, this schedules the channel to close after
|
||||
* the channel still holds an amount, 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 XRP, any XRP that remains after processing the claim is returned to
|
||||
* the source address.
|
||||
* holds an amount, any amount that remains after processing the claim is
|
||||
* returned to the source address.
|
||||
*/
|
||||
tfClose?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Claim XRP from a payment channel, adjust the payment channel's expiration,
|
||||
* Claim amount from a payment channel, adjust the payment channel's expiration,
|
||||
* or both.
|
||||
*
|
||||
* @category Transaction Models
|
||||
@@ -103,18 +109,18 @@ export interface PaymentChannelClaim extends BaseTransaction {
|
||||
/** The unique ID of the channel as a 64-character hexadecimal string. */
|
||||
Channel: string
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
Balance?: string
|
||||
Balance?: Amount
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
Amount?: string
|
||||
Amount?: Amount
|
||||
/**
|
||||
* 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
|
||||
@@ -147,12 +153,12 @@ export function validatePaymentChannelClaim(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('PaymentChannelClaim: Channel must be a string')
|
||||
}
|
||||
|
||||
if (tx.Balance !== undefined && typeof tx.Balance !== 'string') {
|
||||
throw new ValidationError('PaymentChannelClaim: Balance must be a string')
|
||||
if (tx.Balance !== undefined && !isAmount(tx.Balance)) {
|
||||
throw new ValidationError('PaymentChannelClaim: Balance must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.Amount !== undefined && typeof tx.Amount !== 'string') {
|
||||
throw new ValidationError('PaymentChannelClaim: Amount must be a string')
|
||||
if (tx.Amount !== undefined && !isAmount(tx.Amount)) {
|
||||
throw new ValidationError('PaymentChannelClaim: Amount must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.Signature !== undefined && typeof tx.Signature !== 'string') {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/* eslint-disable complexity -- Necessary for validatePaymentChannelCreate */
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount } from '../common'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
|
||||
|
||||
/**
|
||||
* Create a unidirectional channel and fund it with XRP. The address sending
|
||||
* Create a unidirectional channel and fund it. The address sending
|
||||
* this transaction becomes the "source address" of the payment channel.
|
||||
*
|
||||
* @category Transaction Models
|
||||
@@ -12,20 +13,20 @@ import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
export interface PaymentChannelCreate extends BaseTransaction {
|
||||
TransactionType: 'PaymentChannelCreate'
|
||||
/**
|
||||
* 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 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: string
|
||||
Amount: Amount
|
||||
/**
|
||||
* Address to receive XRP claims against this channel. This is also known as
|
||||
* Address to receive 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 XRP.
|
||||
* it has unclaimed amount.
|
||||
*/
|
||||
SettleDelay: number
|
||||
/**
|
||||
@@ -65,8 +66,8 @@ export function validatePaymentChannelCreate(
|
||||
throw new ValidationError('PaymentChannelCreate: missing Amount')
|
||||
}
|
||||
|
||||
if (typeof tx.Amount !== 'string') {
|
||||
throw new ValidationError('PaymentChannelCreate: Amount must be a string')
|
||||
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
|
||||
throw new ValidationError('PaymentChannelCreate: Amount must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.Destination === undefined) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { ValidationError } from '../../errors'
|
||||
import { Amount } from '../common'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
|
||||
|
||||
/**
|
||||
* Add additional XRP to an open payment channel, and optionally update the
|
||||
* Add additional amount 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.
|
||||
*
|
||||
@@ -17,16 +18,15 @@ export interface PaymentChannelFund extends BaseTransaction {
|
||||
*/
|
||||
Channel: string
|
||||
/**
|
||||
* Amount of XRP in drops to add to the channel. Must be a positive amount
|
||||
* of XRP.
|
||||
* Amount to add to the channel. Must be a positive amount
|
||||
*/
|
||||
Amount: string
|
||||
Amount: Amount
|
||||
/**
|
||||
* 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 XRP is returned to
|
||||
* channel without taking its normal action. Any unspent amount 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') {
|
||||
throw new ValidationError('PaymentChannelFund: Amount must be a string')
|
||||
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
|
||||
throw new ValidationError('PaymentChannelFund: Amount must be an Amount')
|
||||
}
|
||||
|
||||
if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
|
||||
|
||||
@@ -51,6 +51,32 @@ 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
|
||||
@@ -80,6 +106,14 @@ export type Transaction =
|
||||
| SignerListSet
|
||||
| TicketCreate
|
||||
| TrustSet
|
||||
| XChainAddAccountCreateAttestation
|
||||
| XChainAddClaimAttestation
|
||||
| XChainClaim
|
||||
| XChainCommit
|
||||
| XChainCreateBridge
|
||||
| XChainCreateClaimID
|
||||
| XChainAccountCreateCommit
|
||||
| XChainModifyBridge
|
||||
|
||||
/**
|
||||
* @category Transaction Models
|
||||
@@ -204,6 +238,38 @@ 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}`,
|
||||
|
||||
@@ -6,22 +6,14 @@ import {
|
||||
AccountRootFlagsInterface,
|
||||
AccountRootFlags,
|
||||
} from '../ledger/AccountRoot'
|
||||
import {
|
||||
AccountSetFlagsInterface,
|
||||
AccountSetTfFlags,
|
||||
} from '../transactions/accountSet'
|
||||
import { AccountSetTfFlags } from '../transactions/accountSet'
|
||||
import { GlobalFlags } from '../transactions/common'
|
||||
import {
|
||||
OfferCreateFlagsInterface,
|
||||
OfferCreateFlags,
|
||||
} from '../transactions/offerCreate'
|
||||
import { PaymentFlagsInterface, PaymentFlags } from '../transactions/payment'
|
||||
import {
|
||||
PaymentChannelClaimFlagsInterface,
|
||||
PaymentChannelClaimFlags,
|
||||
} from '../transactions/paymentChannelClaim'
|
||||
import { OfferCreateFlags } from '../transactions/offerCreate'
|
||||
import { PaymentFlags } from '../transactions/payment'
|
||||
import { PaymentChannelClaimFlags } from '../transactions/paymentChannelClaim'
|
||||
import type { Transaction } from '../transactions/transaction'
|
||||
import { TrustSetFlagsInterface, TrustSetFlags } from '../transactions/trustSet'
|
||||
import { TrustSetFlags } from '../transactions/trustSet'
|
||||
import { XChainModifyBridgeFlags } from '../transactions/XChainModifyBridge'
|
||||
|
||||
import { isFlagEnabled } from '.'
|
||||
|
||||
@@ -61,55 +53,30 @@ export function setTransactionFlagsToNumber(tx: Transaction): void {
|
||||
|
||||
switch (tx.TransactionType) {
|
||||
case 'AccountSet':
|
||||
tx.Flags = convertAccountSetFlagsToNumber(tx.Flags)
|
||||
tx.Flags = convertFlagsToNumber(tx.Flags, AccountSetTfFlags)
|
||||
return
|
||||
case 'OfferCreate':
|
||||
tx.Flags = convertOfferCreateFlagsToNumber(tx.Flags)
|
||||
tx.Flags = convertFlagsToNumber(tx.Flags, OfferCreateFlags)
|
||||
return
|
||||
case 'PaymentChannelClaim':
|
||||
tx.Flags = convertPaymentChannelClaimFlagsToNumber(tx.Flags)
|
||||
tx.Flags = convertFlagsToNumber(tx.Flags, PaymentChannelClaimFlags)
|
||||
return
|
||||
case 'Payment':
|
||||
tx.Flags = convertPaymentTransactionFlagsToNumber(tx.Flags)
|
||||
tx.Flags = convertFlagsToNumber(tx.Flags, PaymentFlags)
|
||||
return
|
||||
case 'TrustSet':
|
||||
tx.Flags = convertTrustSetFlagsToNumber(tx.Flags)
|
||||
tx.Flags = convertFlagsToNumber(tx.Flags, TrustSetFlags)
|
||||
return
|
||||
case 'XChainModifyBridge':
|
||||
tx.Flags = convertFlagsToNumber(tx.Flags, XChainModifyBridgeFlags)
|
||||
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 reduceFlags(flags: GlobalFlags, flagEnum: any): number {
|
||||
function convertFlagsToNumber(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) {
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('server_state', function () {
|
||||
id: 0,
|
||||
result: {
|
||||
state: {
|
||||
build_version: '1.7.3',
|
||||
build_version: '1.10.0-rc1',
|
||||
complete_ledgers: '2563-2932',
|
||||
io_latency_ms: 1,
|
||||
jq_trans_overflow: '0',
|
||||
@@ -103,6 +103,8 @@ describe('server_state', function () {
|
||||
)
|
||||
|
||||
const removeKeys = [
|
||||
'initial_sync_duration_us',
|
||||
'node_size',
|
||||
'complete_ledgers',
|
||||
'load',
|
||||
'state_accounting',
|
||||
@@ -133,7 +135,7 @@ describe('server_state', function () {
|
||||
)
|
||||
assert.equal(
|
||||
typeof response.result.state.state_accounting[key].transitions,
|
||||
'number',
|
||||
'string',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ describe('subscribe', function () {
|
||||
// Explicitly checking that there are only known fields in the return
|
||||
const expectedResult = {
|
||||
fee_base: ledgerResponse.fee_base,
|
||||
fee_ref: ledgerResponse.fee_ref,
|
||||
fee_ref: 0,
|
||||
ledger_hash: ledgerResponse.ledger_hash,
|
||||
ledger_index: ledgerResponse.ledger_index,
|
||||
ledger_time: ledgerResponse.ledger_time,
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { Client, Wallet } from '../../src'
|
||||
import { AccountSet, TrustSet, Payment } from '../../src/models/transactions'
|
||||
|
||||
import serverUrl from './serverUrl'
|
||||
import { fundAccount } from './utils'
|
||||
import { fundAccount, ledgerAccept } from './utils'
|
||||
|
||||
export interface XrplIntegrationTestContext {
|
||||
client: Client
|
||||
wallet: Wallet
|
||||
destination: Wallet
|
||||
gateway: Wallet
|
||||
}
|
||||
|
||||
export async function teardownClient(
|
||||
@@ -29,18 +32,137 @@ async function connectWithRetry(client: Client, tries = 0): Promise<void> {
|
||||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line max-params -- need comments
|
||||
async function initToken(
|
||||
client: Client,
|
||||
wallet: Wallet,
|
||||
destination: Wallet,
|
||||
gateway: Wallet,
|
||||
): Promise<void> {
|
||||
const atx: AccountSet = {
|
||||
TransactionType: 'AccountSet',
|
||||
Account: gateway.classicAddress,
|
||||
SetFlag: 8,
|
||||
}
|
||||
const atxr = await client.submit(atx, {
|
||||
wallet: gateway,
|
||||
})
|
||||
if (atxr.result.engine_result !== 'tesSUCCESS') {
|
||||
// eslint-disable-next-line no-console -- happens only when something goes wrong
|
||||
console.log(atxr)
|
||||
}
|
||||
await ledgerAccept(client)
|
||||
|
||||
const wtl: TrustSet = {
|
||||
TransactionType: 'TrustSet',
|
||||
Account: wallet.classicAddress,
|
||||
LimitAmount: {
|
||||
currency: 'USD',
|
||||
issuer: gateway.classicAddress,
|
||||
value: '100000',
|
||||
},
|
||||
}
|
||||
|
||||
const wtlr = await client.submit(wtl, {
|
||||
wallet,
|
||||
})
|
||||
if (wtlr.result.engine_result !== 'tesSUCCESS') {
|
||||
// eslint-disable-next-line no-console -- happens only when something goes wrong
|
||||
console.log(wtlr)
|
||||
}
|
||||
await ledgerAccept(client)
|
||||
|
||||
const dtl: TrustSet = {
|
||||
TransactionType: 'TrustSet',
|
||||
Account: destination.classicAddress,
|
||||
LimitAmount: {
|
||||
currency: 'USD',
|
||||
issuer: gateway.classicAddress,
|
||||
value: '100000',
|
||||
},
|
||||
}
|
||||
|
||||
const dtlr = await client.submit(dtl, {
|
||||
wallet: destination,
|
||||
})
|
||||
if (wtlr.result.engine_result !== 'tesSUCCESS') {
|
||||
// eslint-disable-next-line no-console -- happens only when something goes wrong
|
||||
console.log(dtlr)
|
||||
}
|
||||
await ledgerAccept(client)
|
||||
|
||||
const wp: Payment = {
|
||||
TransactionType: 'Payment',
|
||||
Account: gateway.classicAddress,
|
||||
Destination: wallet.classicAddress,
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: gateway.classicAddress,
|
||||
value: '10000',
|
||||
},
|
||||
}
|
||||
|
||||
const wpr = await client.submit(wp, {
|
||||
wallet: gateway,
|
||||
})
|
||||
if (wpr.result.engine_result !== 'tesSUCCESS') {
|
||||
// eslint-disable-next-line no-console -- happens only when something goes wrong
|
||||
console.log(wpr)
|
||||
}
|
||||
await ledgerAccept(client)
|
||||
|
||||
const dp: Payment = {
|
||||
TransactionType: 'Payment',
|
||||
Account: gateway.classicAddress,
|
||||
Destination: destination.classicAddress,
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: gateway.classicAddress,
|
||||
value: '10000',
|
||||
},
|
||||
}
|
||||
|
||||
const dpr = await client.submit(dp, {
|
||||
wallet: gateway,
|
||||
})
|
||||
if (dpr.result.engine_result !== 'tesSUCCESS') {
|
||||
// eslint-disable-next-line no-console -- happens only when something goes wrong
|
||||
console.log(dpr)
|
||||
}
|
||||
await ledgerAccept(client)
|
||||
}
|
||||
|
||||
export async function setupClient(
|
||||
server = serverUrl,
|
||||
token?: boolean | false,
|
||||
): Promise<XrplIntegrationTestContext> {
|
||||
const context: XrplIntegrationTestContext = {
|
||||
client: new Client(server, { timeout: 200000 }),
|
||||
wallet: Wallet.generate(),
|
||||
destination: Wallet.generate(),
|
||||
gateway: Wallet.generate(),
|
||||
}
|
||||
return connectWithRetry(context.client).then(async () => {
|
||||
await fundAccount(context.client, context.wallet, {
|
||||
count: 20,
|
||||
delayMs: 1000,
|
||||
})
|
||||
if (token) {
|
||||
await fundAccount(context.client, context.destination, {
|
||||
count: 20,
|
||||
delayMs: 1000,
|
||||
})
|
||||
await fundAccount(context.client, context.gateway, {
|
||||
count: 20,
|
||||
delayMs: 1000,
|
||||
})
|
||||
await initToken(
|
||||
context.client,
|
||||
context.wallet,
|
||||
context.destination,
|
||||
context.gateway,
|
||||
)
|
||||
}
|
||||
return context
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,13 +7,7 @@ import {
|
||||
teardownClient,
|
||||
type XrplIntegrationTestContext,
|
||||
} from '../setup'
|
||||
import {
|
||||
// calculateWaitTimeForTransaction,
|
||||
generateFundedWallet,
|
||||
// getXRPBalance,
|
||||
testTransaction,
|
||||
submitTransaction,
|
||||
} from '../utils'
|
||||
import { testTransaction, submitTransaction } from '../utils'
|
||||
|
||||
// TODO: Fix these tests
|
||||
// NOTE: Because ledger accept is called among multiple tests, the actual ledger close time is not
|
||||
@@ -30,16 +24,13 @@ describe('EscrowCancel', function () {
|
||||
let testContext: XrplIntegrationTestContext
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient(serverUrl)
|
||||
testContext = await setupClient(serverUrl, true)
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
|
||||
it(
|
||||
'base',
|
||||
'test xrp',
|
||||
async () => {
|
||||
// Funding the wallet can take some time, so we do it first BEFORE getting the ledger close_time.
|
||||
const wallet1 = await generateFundedWallet(testContext.client)
|
||||
|
||||
// get the most recent close_time from the standalone container for cancel & finish after.
|
||||
const CLOSE_TIME: number = (
|
||||
await testContext.client.request({
|
||||
@@ -54,7 +45,7 @@ describe('EscrowCancel', function () {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'EscrowCreate',
|
||||
Amount: '10000',
|
||||
Destination: wallet1.classicAddress,
|
||||
Destination: testContext.destination.classicAddress,
|
||||
CancelAfter: CLOSE_TIME + 3,
|
||||
FinishAfter: CLOSE_TIME + 2,
|
||||
}
|
||||
@@ -74,12 +65,101 @@ describe('EscrowCancel', function () {
|
||||
})
|
||||
).result.account_objects
|
||||
|
||||
assert.equal(accountObjects.length, 1)
|
||||
assert.equal(accountObjects.length, 2)
|
||||
|
||||
const sequence = (
|
||||
await testContext.client.request({
|
||||
command: 'tx',
|
||||
transaction: accountObjects[0].PreviousTxnID,
|
||||
transaction: accountObjects[1].PreviousTxnID,
|
||||
})
|
||||
).result.Sequence
|
||||
|
||||
if (!sequence) {
|
||||
throw new Error('sequence did not exist')
|
||||
}
|
||||
|
||||
const cancelTx: EscrowCancel = {
|
||||
TransactionType: 'EscrowCancel',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
Owner: testContext.wallet.classicAddress,
|
||||
OfferSequence: sequence,
|
||||
}
|
||||
|
||||
// We set the CancelAfter timer to be 3 seconds after the last ledger close_time. We need to wait this long
|
||||
// before we can cancel the escrow.
|
||||
// const cancelAfterTimerPromise = new Promise((resolve) => {
|
||||
// setTimeout(resolve, waitTimeInMs)
|
||||
// })
|
||||
|
||||
// Make sure we wait long enough before canceling the escrow.
|
||||
// await cancelAfterTimerPromise
|
||||
|
||||
// await testTransaction(testContext.client, cancelTx, testContext.wallet, {
|
||||
// count: 20,
|
||||
// delayMs: 2000,
|
||||
// })
|
||||
|
||||
await submitTransaction({
|
||||
client: testContext.client,
|
||||
transaction: cancelTx,
|
||||
wallet: testContext.wallet,
|
||||
})
|
||||
|
||||
// Make sure the Destination wallet did not receive any XRP.
|
||||
// assert.equal(
|
||||
// await getXRPBalance(testContext.client, wallet1),
|
||||
// initialBalanceWallet1,
|
||||
// )
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
it(
|
||||
'test token',
|
||||
async () => {
|
||||
// get the most recent close_time from the standalone container for cancel & finish after.
|
||||
const CLOSE_TIME: number = (
|
||||
await testContext.client.request({
|
||||
command: 'ledger',
|
||||
ledger_index: 'validated',
|
||||
})
|
||||
).result.ledger.close_time
|
||||
|
||||
// const waitTimeInMs = calculateWaitTimeForTransaction(CLOSE_TIME)
|
||||
|
||||
const createTx: EscrowCreate = {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'EscrowCreate',
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: testContext.gateway.classicAddress,
|
||||
value: '100',
|
||||
},
|
||||
Destination: testContext.destination.classicAddress,
|
||||
CancelAfter: CLOSE_TIME + 3,
|
||||
FinishAfter: CLOSE_TIME + 2,
|
||||
}
|
||||
|
||||
await testTransaction(testContext.client, createTx, testContext.wallet)
|
||||
|
||||
// const initialBalanceWallet1 = await getXRPBalance(
|
||||
// testContext.client,
|
||||
// wallet1,
|
||||
// )
|
||||
|
||||
// check that the object was actually created
|
||||
const accountObjects = (
|
||||
await testContext.client.request({
|
||||
command: 'account_objects',
|
||||
account: testContext.wallet.classicAddress,
|
||||
})
|
||||
).result.account_objects
|
||||
|
||||
assert.equal(accountObjects.length, 2)
|
||||
|
||||
const sequence = (
|
||||
await testContext.client.request({
|
||||
command: 'tx',
|
||||
transaction: accountObjects[1].PreviousTxnID,
|
||||
})
|
||||
).result.Sequence
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
teardownClient,
|
||||
type XrplIntegrationTestContext,
|
||||
} from '../setup'
|
||||
import { generateFundedWallet, testTransaction } from '../utils'
|
||||
import { testTransaction } from '../utils'
|
||||
|
||||
// how long before each test case times out
|
||||
const TIMEOUT = 20000
|
||||
@@ -16,15 +16,13 @@ describe('EscrowCreate', function () {
|
||||
let testContext: XrplIntegrationTestContext
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient(serverUrl)
|
||||
testContext = await setupClient(serverUrl, true)
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
|
||||
it(
|
||||
'base',
|
||||
'test xrp',
|
||||
async () => {
|
||||
const wallet2 = await generateFundedWallet(testContext.client)
|
||||
|
||||
// get the most recent close_time from the standalone container for finish after.
|
||||
const CLOSE_TIME: number = (
|
||||
await testContext.client.request({
|
||||
@@ -37,7 +35,7 @@ describe('EscrowCreate', function () {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'EscrowCreate',
|
||||
Amount: '10000',
|
||||
Destination: wallet2.classicAddress,
|
||||
Destination: testContext.destination.classicAddress,
|
||||
FinishAfter: CLOSE_TIME + 2,
|
||||
}
|
||||
|
||||
@@ -51,7 +49,46 @@ describe('EscrowCreate', function () {
|
||||
account: testContext.wallet.classicAddress,
|
||||
})
|
||||
).result.account_objects.length,
|
||||
1,
|
||||
2,
|
||||
)
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
|
||||
it(
|
||||
'test token',
|
||||
async () => {
|
||||
// get the most recent close_time from the standalone container for finish after.
|
||||
const CLOSE_TIME: number = (
|
||||
await testContext.client.request({
|
||||
command: 'ledger',
|
||||
ledger_index: 'validated',
|
||||
})
|
||||
).result.ledger.close_time
|
||||
|
||||
const tx: EscrowCreate = {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'EscrowCreate',
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: testContext.gateway.classicAddress,
|
||||
value: '100',
|
||||
},
|
||||
Destination: testContext.destination.classicAddress,
|
||||
FinishAfter: CLOSE_TIME + 2,
|
||||
}
|
||||
|
||||
await testTransaction(testContext.client, tx, testContext.wallet)
|
||||
|
||||
// check that the object was actually created
|
||||
assert.equal(
|
||||
(
|
||||
await testContext.client.request({
|
||||
command: 'account_objects',
|
||||
account: testContext.wallet.classicAddress,
|
||||
})
|
||||
).result.account_objects.length,
|
||||
2,
|
||||
)
|
||||
},
|
||||
TIMEOUT,
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
} from '../setup'
|
||||
import {
|
||||
calculateWaitTimeForTransaction,
|
||||
generateFundedWallet,
|
||||
getXRPBalance,
|
||||
testTransaction,
|
||||
} from '../utils'
|
||||
@@ -21,15 +20,13 @@ describe('EscrowFinish', function () {
|
||||
let testContext: XrplIntegrationTestContext
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient(serverUrl)
|
||||
testContext = await setupClient(serverUrl, true)
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
|
||||
it(
|
||||
'base',
|
||||
'test xrp',
|
||||
async () => {
|
||||
const wallet1 = await generateFundedWallet(testContext.client)
|
||||
|
||||
// get the most recent close_time from the standalone container for cancel & finish after.
|
||||
const CLOSE_TIME: number = (
|
||||
await testContext.client.request({
|
||||
@@ -40,13 +37,11 @@ describe('EscrowFinish', function () {
|
||||
|
||||
const waitTimeInMs = calculateWaitTimeForTransaction(CLOSE_TIME)
|
||||
|
||||
const AMOUNT = 10000
|
||||
|
||||
const createTx: EscrowCreate = {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'EscrowCreate',
|
||||
Amount: AMOUNT.toString(),
|
||||
Destination: wallet1.classicAddress,
|
||||
Amount: '10000',
|
||||
Destination: testContext.destination.classicAddress,
|
||||
FinishAfter: CLOSE_TIME + 2,
|
||||
}
|
||||
|
||||
@@ -56,7 +51,10 @@ describe('EscrowFinish', function () {
|
||||
|
||||
await testTransaction(testContext.client, createTx, testContext.wallet)
|
||||
|
||||
const initialBalance = await getXRPBalance(testContext.client, wallet1)
|
||||
const initialBalance = await getXRPBalance(
|
||||
testContext.client,
|
||||
testContext.destination,
|
||||
)
|
||||
|
||||
// check that the object was actually created
|
||||
const accountObjects = (
|
||||
@@ -66,12 +64,12 @@ describe('EscrowFinish', function () {
|
||||
})
|
||||
).result.account_objects
|
||||
|
||||
assert.equal(accountObjects.length, 1)
|
||||
assert.equal(accountObjects.length, 2)
|
||||
|
||||
const sequence = (
|
||||
await testContext.client.request({
|
||||
command: 'tx',
|
||||
transaction: accountObjects[0].PreviousTxnID,
|
||||
transaction: accountObjects[1].PreviousTxnID,
|
||||
})
|
||||
).result.Sequence
|
||||
|
||||
@@ -86,9 +84,81 @@ describe('EscrowFinish', function () {
|
||||
|
||||
await testTransaction(testContext.client, finishTx, testContext.wallet)
|
||||
|
||||
const expectedBalance = String(Number(initialBalance) + Number(AMOUNT))
|
||||
const expectedBalance = String(Number(initialBalance) + Number('10000'))
|
||||
assert.equal(
|
||||
await getXRPBalance(testContext.client, wallet1),
|
||||
await getXRPBalance(testContext.client, testContext.destination),
|
||||
expectedBalance,
|
||||
)
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
it(
|
||||
'test token',
|
||||
async () => {
|
||||
// get the most recent close_time from the standalone container for cancel & finish after.
|
||||
const CLOSE_TIME: number = (
|
||||
await testContext.client.request({
|
||||
command: 'ledger',
|
||||
ledger_index: 'validated',
|
||||
})
|
||||
).result.ledger.close_time
|
||||
|
||||
const waitTimeInMs = calculateWaitTimeForTransaction(CLOSE_TIME)
|
||||
|
||||
const createTx: EscrowCreate = {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'EscrowCreate',
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: testContext.gateway.classicAddress,
|
||||
value: '100',
|
||||
},
|
||||
Destination: testContext.destination.classicAddress,
|
||||
FinishAfter: CLOSE_TIME + 2,
|
||||
}
|
||||
|
||||
const finishAfterPromise = new Promise((resolve) => {
|
||||
setTimeout(resolve, waitTimeInMs)
|
||||
})
|
||||
|
||||
await testTransaction(testContext.client, createTx, testContext.wallet)
|
||||
|
||||
const initialBalance = await getXRPBalance(
|
||||
testContext.client,
|
||||
testContext.destination,
|
||||
)
|
||||
|
||||
// check that the object was actually created
|
||||
const accountObjects = (
|
||||
await testContext.client.request({
|
||||
command: 'account_objects',
|
||||
account: testContext.wallet.classicAddress,
|
||||
})
|
||||
).result.account_objects
|
||||
|
||||
assert.equal(accountObjects.length, 2)
|
||||
|
||||
const sequence = (
|
||||
await testContext.client.request({
|
||||
command: 'tx',
|
||||
transaction: accountObjects[1].PreviousTxnID,
|
||||
})
|
||||
).result.Sequence
|
||||
|
||||
const finishTx: EscrowFinish = {
|
||||
TransactionType: 'EscrowFinish',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
Owner: testContext.wallet.classicAddress,
|
||||
OfferSequence: sequence!,
|
||||
}
|
||||
|
||||
await finishAfterPromise
|
||||
|
||||
await testTransaction(testContext.client, finishTx, testContext.wallet)
|
||||
|
||||
const expectedBalance = String(Number(initialBalance))
|
||||
assert.equal(
|
||||
await getXRPBalance(testContext.client, testContext.destination),
|
||||
expectedBalance,
|
||||
)
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
teardownClient,
|
||||
type XrplIntegrationTestContext,
|
||||
} from '../setup'
|
||||
import { generateFundedWallet, testTransaction } from '../utils'
|
||||
import { testTransaction } from '../utils'
|
||||
|
||||
// how long before each test case times out
|
||||
const TIMEOUT = 20000
|
||||
@@ -15,19 +15,18 @@ describe('PaymentChannelClaim', function () {
|
||||
let testContext: XrplIntegrationTestContext
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient(serverUrl)
|
||||
testContext = await setupClient(serverUrl, true)
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
|
||||
it(
|
||||
'base',
|
||||
'test xrp',
|
||||
async () => {
|
||||
const wallet2 = await generateFundedWallet(testContext.client)
|
||||
const paymentChannelCreate: PaymentChannelCreate = {
|
||||
TransactionType: 'PaymentChannelCreate',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
Amount: '100',
|
||||
Destination: wallet2.classicAddress,
|
||||
Destination: testContext.destination.classicAddress,
|
||||
SettleDelay: 86400,
|
||||
PublicKey: testContext.wallet.publicKey,
|
||||
}
|
||||
@@ -48,7 +47,7 @@ describe('PaymentChannelClaim', function () {
|
||||
TransactionType: 'PaymentChannelClaim',
|
||||
Channel: hashPaymentChannel(
|
||||
testContext.wallet.classicAddress,
|
||||
wallet2.classicAddress,
|
||||
testContext.destination.classicAddress,
|
||||
paymentChannelResponse.result.tx_json.Sequence ?? 0,
|
||||
),
|
||||
Amount: '100',
|
||||
@@ -62,4 +61,48 @@ describe('PaymentChannelClaim', function () {
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
it(
|
||||
'test token',
|
||||
async () => {
|
||||
const paymentChannelCreate: PaymentChannelCreate = {
|
||||
TransactionType: 'PaymentChannelCreate',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: testContext.gateway.classicAddress,
|
||||
value: '100',
|
||||
},
|
||||
Destination: testContext.destination.classicAddress,
|
||||
SettleDelay: 86400,
|
||||
PublicKey: testContext.wallet.publicKey,
|
||||
}
|
||||
|
||||
const paymentChannelResponse = await testContext.client.submit(
|
||||
paymentChannelCreate,
|
||||
{ wallet: testContext.wallet },
|
||||
)
|
||||
|
||||
const paymentChannelClaim: PaymentChannelClaim = {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'PaymentChannelClaim',
|
||||
Channel: hashPaymentChannel(
|
||||
testContext.wallet.classicAddress,
|
||||
testContext.destination.classicAddress,
|
||||
paymentChannelResponse.result.tx_json.Sequence ?? 0,
|
||||
),
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: testContext.gateway.classicAddress,
|
||||
value: '100',
|
||||
},
|
||||
}
|
||||
|
||||
await testTransaction(
|
||||
testContext.client,
|
||||
paymentChannelClaim,
|
||||
testContext.wallet,
|
||||
)
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,32 +1,78 @@
|
||||
import { PaymentChannelCreate } from '../../../src'
|
||||
import { PaymentChannelCreate, hashes, PaymentChannelClaim } from '../../../src'
|
||||
import serverUrl from '../serverUrl'
|
||||
import {
|
||||
setupClient,
|
||||
teardownClient,
|
||||
type XrplIntegrationTestContext,
|
||||
} from '../setup'
|
||||
import { generateFundedWallet, testTransaction } from '../utils'
|
||||
import { testTransaction } from '../utils'
|
||||
|
||||
// how long before each test case times out
|
||||
const TIMEOUT = 20000
|
||||
const { hashPaymentChannel } = hashes
|
||||
|
||||
describe('PaymentChannelCreate', function () {
|
||||
describe('PaymentChannelClaim', function () {
|
||||
let testContext: XrplIntegrationTestContext
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient(serverUrl)
|
||||
testContext = await setupClient(serverUrl, true)
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
|
||||
it(
|
||||
'base',
|
||||
'test xrp',
|
||||
async () => {
|
||||
const wallet2 = await generateFundedWallet(testContext.client)
|
||||
const paymentChannelCreate: PaymentChannelCreate = {
|
||||
TransactionType: 'PaymentChannelCreate',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
Amount: '100',
|
||||
Destination: wallet2.classicAddress,
|
||||
Destination: testContext.destination.classicAddress,
|
||||
SettleDelay: 86400,
|
||||
PublicKey: testContext.wallet.publicKey,
|
||||
}
|
||||
|
||||
const paymentChannelResponse = await testContext.client.submit(
|
||||
paymentChannelCreate,
|
||||
{ wallet: testContext.wallet },
|
||||
)
|
||||
|
||||
await testTransaction(
|
||||
testContext.client,
|
||||
paymentChannelCreate,
|
||||
testContext.wallet,
|
||||
)
|
||||
|
||||
const paymentChannelClaim: PaymentChannelClaim = {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'PaymentChannelClaim',
|
||||
Channel: hashPaymentChannel(
|
||||
testContext.wallet.classicAddress,
|
||||
testContext.destination.classicAddress,
|
||||
paymentChannelResponse.result.tx_json.Sequence ?? 0,
|
||||
),
|
||||
Amount: '100',
|
||||
}
|
||||
|
||||
await testTransaction(
|
||||
testContext.client,
|
||||
paymentChannelClaim,
|
||||
testContext.wallet,
|
||||
)
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
it(
|
||||
'test token',
|
||||
async () => {
|
||||
const paymentChannelCreate: PaymentChannelCreate = {
|
||||
TransactionType: 'PaymentChannelCreate',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: testContext.gateway.classicAddress,
|
||||
value: '100',
|
||||
},
|
||||
Destination: testContext.destination.classicAddress,
|
||||
SettleDelay: 86400,
|
||||
PublicKey: testContext.wallet.publicKey,
|
||||
}
|
||||
|
||||
@@ -5,29 +5,28 @@ import {
|
||||
teardownClient,
|
||||
type XrplIntegrationTestContext,
|
||||
} from '../setup'
|
||||
import { generateFundedWallet, testTransaction } from '../utils'
|
||||
import { testTransaction } from '../utils'
|
||||
|
||||
// how long before each test case times out
|
||||
const TIMEOUT = 20000
|
||||
const { hashPaymentChannel } = hashes
|
||||
|
||||
describe('PaymentChannelFund', function () {
|
||||
describe('PaymentChannelClaim', function () {
|
||||
let testContext: XrplIntegrationTestContext
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient(serverUrl)
|
||||
testContext = await setupClient(serverUrl, true)
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
|
||||
it(
|
||||
'base',
|
||||
'test xrp',
|
||||
async () => {
|
||||
const wallet2 = await generateFundedWallet(testContext.client)
|
||||
const paymentChannelCreate: PaymentChannelCreate = {
|
||||
TransactionType: 'PaymentChannelCreate',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
Amount: '100',
|
||||
Destination: wallet2.classicAddress,
|
||||
Destination: testContext.destination.classicAddress,
|
||||
SettleDelay: 86400,
|
||||
PublicKey: testContext.wallet.publicKey,
|
||||
}
|
||||
@@ -36,6 +35,7 @@ describe('PaymentChannelFund', function () {
|
||||
paymentChannelCreate,
|
||||
{ wallet: testContext.wallet },
|
||||
)
|
||||
|
||||
await testTransaction(
|
||||
testContext.client,
|
||||
paymentChannelCreate,
|
||||
@@ -47,7 +47,7 @@ describe('PaymentChannelFund', function () {
|
||||
TransactionType: 'PaymentChannelFund',
|
||||
Channel: hashPaymentChannel(
|
||||
testContext.wallet.classicAddress,
|
||||
wallet2.classicAddress,
|
||||
testContext.destination.classicAddress,
|
||||
paymentChannelResponse.result.tx_json.Sequence ?? 0,
|
||||
),
|
||||
Amount: '100',
|
||||
@@ -61,4 +61,48 @@ describe('PaymentChannelFund', function () {
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
it(
|
||||
'test token',
|
||||
async () => {
|
||||
const paymentChannelCreate: PaymentChannelCreate = {
|
||||
TransactionType: 'PaymentChannelCreate',
|
||||
Account: testContext.wallet.classicAddress,
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: testContext.gateway.classicAddress,
|
||||
value: '100',
|
||||
},
|
||||
Destination: testContext.destination.classicAddress,
|
||||
SettleDelay: 86400,
|
||||
PublicKey: testContext.wallet.publicKey,
|
||||
}
|
||||
|
||||
const paymentChannelResponse = await testContext.client.submit(
|
||||
paymentChannelCreate,
|
||||
{ wallet: testContext.wallet },
|
||||
)
|
||||
|
||||
const paymentChannelFund: PaymentChannelFund = {
|
||||
Account: testContext.wallet.classicAddress,
|
||||
TransactionType: 'PaymentChannelFund',
|
||||
Channel: hashPaymentChannel(
|
||||
testContext.wallet.classicAddress,
|
||||
testContext.destination.classicAddress,
|
||||
paymentChannelResponse.result.tx_json.Sequence ?? 0,
|
||||
),
|
||||
Amount: {
|
||||
currency: 'USD',
|
||||
issuer: testContext.gateway.classicAddress,
|
||||
value: '100',
|
||||
},
|
||||
}
|
||||
|
||||
await testTransaction(
|
||||
testContext.client,
|
||||
paymentChannelFund,
|
||||
testContext.wallet,
|
||||
)
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -82,12 +82,12 @@ describe('EscrowCreate', function () {
|
||||
assert.throws(
|
||||
() => validateEscrowCreate(escrow),
|
||||
ValidationError,
|
||||
'EscrowCreate: Amount must be a string',
|
||||
'EscrowCreate: Amount must be an Amount',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(escrow),
|
||||
ValidationError,
|
||||
'EscrowCreate: Amount must be a string',
|
||||
'EscrowCreate: Amount must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -77,12 +77,12 @@ describe('PaymentChannelClaim', function () {
|
||||
assert.throws(
|
||||
() => validatePaymentChannelClaim(channel),
|
||||
ValidationError,
|
||||
'PaymentChannelClaim: Balance must be a string',
|
||||
'PaymentChannelClaim: Balance must be an Amount',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(channel),
|
||||
ValidationError,
|
||||
'PaymentChannelClaim: Balance must be a string',
|
||||
'PaymentChannelClaim: Balance must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
@@ -92,12 +92,12 @@ describe('PaymentChannelClaim', function () {
|
||||
assert.throws(
|
||||
() => validatePaymentChannelClaim(channel),
|
||||
ValidationError,
|
||||
'PaymentChannelClaim: Amount must be a string',
|
||||
'PaymentChannelClaim: Amount must be an Amount',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(channel),
|
||||
ValidationError,
|
||||
'PaymentChannelClaim: Amount must be a string',
|
||||
'PaymentChannelClaim: Amount must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -106,12 +106,12 @@ describe('PaymentChannelCreate', function () {
|
||||
assert.throws(
|
||||
() => validatePaymentChannelCreate(channel),
|
||||
ValidationError,
|
||||
'PaymentChannelCreate: Amount must be a string',
|
||||
'PaymentChannelCreate: Amount must be an Amount',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(channel),
|
||||
ValidationError,
|
||||
'PaymentChannelCreate: Amount must be a string',
|
||||
'PaymentChannelCreate: Amount must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -70,12 +70,12 @@ describe('PaymentChannelFund', function () {
|
||||
assert.throws(
|
||||
() => validatePaymentChannelFund(channel),
|
||||
ValidationError,
|
||||
'PaymentChannelFund: Amount must be a string',
|
||||
'PaymentChannelFund: Amount must be an Amount',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(channel),
|
||||
ValidationError,
|
||||
'PaymentChannelFund: Amount must be a string',
|
||||
'PaymentChannelFund: Amount must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user