mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-09 15:25:49 +00:00
Compare commits
7 Commits
@transia/x
...
@transia/r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecfa0ea3f8 | ||
|
|
cbbeebffa9 | ||
|
|
05f75b7316 | ||
|
|
c04d1c8708 | ||
|
|
ac2f4bac8b | ||
|
|
61942003f6 | ||
|
|
6f077f8e51 |
4434
package-lock.json
generated
4434
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -13,10 +13,10 @@
|
|||||||
"update:confirm": "npx npm-check-updates --configFileName .ncurc.json -u"
|
"update:confirm": "npx npm-check-updates --configFileName .ncurc.json -u"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "file:packages/ripple-address-codec",
|
"ripple-address-codec": "file:packages/ripple-address-codec",
|
||||||
"@transia/ripple-binary-codec": "file:packages/ripple-binary-codec",
|
"ripple-binary-codec": "file:packages/ripple-binary-codec",
|
||||||
"@transia/ripple-keypairs": "file:packages/ripple-keypairs",
|
"ripple-keypairs": "file:packages/ripple-keypairs",
|
||||||
"@transia/xrpl": "file:packages/xrpl"
|
"xrpl": "file:packages/xrpl"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/brorand": "^1.0.30",
|
"@types/brorand": "^1.0.30",
|
||||||
|
|||||||
4
packages/ripple-address-codec/package-lock.json
generated
4
packages/ripple-address-codec/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ripple-address-codec",
|
"name": "ripple-address-codec",
|
||||||
"version": "4.2.8-alpha.0",
|
"version": "4.2.6-tbeta.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ripple-address-codec",
|
"name": "ripple-address-codec",
|
||||||
"version": "4.2.8-alpha.0",
|
"version": "4.2.6-tbeta.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"base-x": "^3.0.9",
|
"base-x": "^3.0.9",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-address-codec",
|
"name": "@transia/ripple-address-codec",
|
||||||
"version": "4.2.8-alpha.0",
|
"version": "4.2.6-tbeta.0",
|
||||||
"description": "encodes/decodes base58 encoded XRP Ledger identifiers",
|
"description": "encodes/decodes base58 encoded XRP Ledger identifiers",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@github.com/Transia-RnD/xrpl.js/tree/beta"
|
"url": "git@github.com:Transia-RnD/xrpl.js/tree/transia-beta"
|
||||||
},
|
},
|
||||||
"prepublish": "tsc -b",
|
"prepublish": "tsc -b",
|
||||||
"prepublishOnly": "tslint -b ./ && jest",
|
"prepublishOnly": "tslint -b ./ && jest",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-binary-codec",
|
"name": "@transia/ripple-binary-codec",
|
||||||
"version": "1.4.6-alpha.4",
|
"version": "1.4.4-tbeta.0",
|
||||||
"description": "XRP Ledger binary codec",
|
"description": "XRP Ledger binary codec",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
@@ -12,12 +12,12 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.8-alpha.0",
|
|
||||||
"assert": "^2.0.0",
|
"assert": "^2.0.0",
|
||||||
"big-integer": "^1.6.48",
|
"big-integer": "^1.6.48",
|
||||||
"buffer": "5.6.0",
|
"buffer": "5.6.0",
|
||||||
"create-hash": "^1.2.0",
|
"create-hash": "^1.2.0",
|
||||||
"decimal.js": "^10.2.0"
|
"decimal.js": "^10.2.0",
|
||||||
|
"ripple-address-codec": "^4.2.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -b && copyfiles ./src/enums/definitions.json ./dist/enums/",
|
"build": "tsc -b && copyfiles ./src/enums/definitions.json ./dist/enums/",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@github.com/Transia-RnD/xrpl.js/tree/beta"
|
"url": "git@github.com:Transia-RnD/xrpl.js/tree/transia-beta"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/XRPLF/xrpl.js/issues"
|
"url": "https://github.com/XRPLF/xrpl.js/issues"
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { STObject } from './types/st-object'
|
|||||||
import { JsonObject } from './types/serialized-type'
|
import { JsonObject } from './types/serialized-type'
|
||||||
import { Buffer } from 'buffer/'
|
import { Buffer } from 'buffer/'
|
||||||
import bigInt = require('big-integer')
|
import bigInt = require('big-integer')
|
||||||
import { AmountObject } from './types/amount'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a BinaryParser
|
* Construct a BinaryParser
|
||||||
@@ -123,7 +122,7 @@ function signingData(
|
|||||||
*/
|
*/
|
||||||
interface ClaimObject extends JsonObject {
|
interface ClaimObject extends JsonObject {
|
||||||
channel: string
|
channel: string
|
||||||
amount: AmountObject
|
amount: string | number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,19 +133,16 @@ interface ClaimObject extends JsonObject {
|
|||||||
* @returns the serialized object with appropriate prefix
|
* @returns the serialized object with appropriate prefix
|
||||||
*/
|
*/
|
||||||
function signingClaimData(claim: ClaimObject): Buffer {
|
function signingClaimData(claim: ClaimObject): Buffer {
|
||||||
|
const num = bigInt(String(claim.amount))
|
||||||
const prefix = HashPrefix.paymentChannelClaim
|
const prefix = HashPrefix.paymentChannelClaim
|
||||||
const channel = coreTypes.Hash256.from(claim.channel).toBytes()
|
const channel = coreTypes.Hash256.from(claim.channel).toBytes()
|
||||||
|
const amount = coreTypes.UInt64.from(num).toBytes()
|
||||||
|
|
||||||
const bytesList = new BytesList()
|
const bytesList = new BytesList()
|
||||||
|
|
||||||
bytesList.put(prefix)
|
bytesList.put(prefix)
|
||||||
bytesList.put(channel)
|
bytesList.put(channel)
|
||||||
if (typeof claim.amount === 'string') {
|
bytesList.put(amount)
|
||||||
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()
|
return bytesList.toBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
"LedgerHashes": 104,
|
"LedgerHashes": 104,
|
||||||
"Amendments": 102,
|
"Amendments": 102,
|
||||||
"FeeSettings": 115,
|
"FeeSettings": 115,
|
||||||
"ImportVlseq": 73,
|
|
||||||
"Escrow": 117,
|
"Escrow": 117,
|
||||||
"PayChannel": 120,
|
"PayChannel": 120,
|
||||||
"Check": 67,
|
"Check": 67,
|
||||||
@@ -46,7 +45,6 @@
|
|||||||
"NFTokenPage": 80,
|
"NFTokenPage": 80,
|
||||||
"NFTokenOffer": 55,
|
"NFTokenOffer": 55,
|
||||||
"URIToken": 85,
|
"URIToken": 85,
|
||||||
"UNLReport": 82,
|
|
||||||
"Any": -3,
|
"Any": -3,
|
||||||
"Child": -2,
|
"Child": -2,
|
||||||
"Nickname": 110,
|
"Nickname": 110,
|
||||||
@@ -781,67 +779,7 @@
|
|||||||
[
|
[
|
||||||
"LockCount",
|
"LockCount",
|
||||||
{
|
{
|
||||||
"nth": 49,
|
"nth": 47,
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"FirstNFTokenSequence",
|
|
||||||
{
|
|
||||||
"nth": 50,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"XahauActivationLgrSeq",
|
|
||||||
{
|
|
||||||
"nth": 96,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"ImportSequence",
|
|
||||||
{
|
|
||||||
"nth": 97,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"RewardTime",
|
|
||||||
{
|
|
||||||
"nth": 98,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"RewardLgrFirst",
|
|
||||||
{
|
|
||||||
"nth": 99,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt32"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"RewardLgrLast",
|
|
||||||
{
|
|
||||||
"nth": 100,
|
|
||||||
"isVLEncoded": false,
|
"isVLEncoded": false,
|
||||||
"isSerialized": true,
|
"isSerialized": true,
|
||||||
"isSigningField": true,
|
"isSigningField": true,
|
||||||
@@ -1008,36 +946,6 @@
|
|||||||
"type": "UInt64"
|
"type": "UInt64"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
|
||||||
"AccountIndex",
|
|
||||||
{
|
|
||||||
"nth": 98,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"AccountCount",
|
|
||||||
{
|
|
||||||
"nth": 99,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"RewardAccumulator",
|
|
||||||
{
|
|
||||||
"nth": 100,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "UInt64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"EmailHash",
|
"EmailHash",
|
||||||
{
|
{
|
||||||
@@ -1428,36 +1336,6 @@
|
|||||||
"type": "Hash256"
|
"type": "Hash256"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
|
||||||
"GovernanceFlags",
|
|
||||||
{
|
|
||||||
"nth": 99,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "Hash256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"GovernanceMarks",
|
|
||||||
{
|
|
||||||
"nth": 98,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "Hash256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"EmittedTxnID",
|
|
||||||
{
|
|
||||||
"nth": 97,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "Hash256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"Amount",
|
"Amount",
|
||||||
{
|
{
|
||||||
@@ -1618,36 +1496,6 @@
|
|||||||
"type": "Amount"
|
"type": "Amount"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
|
||||||
"BaseFeeDrops",
|
|
||||||
{
|
|
||||||
"nth": 22,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "Amount"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"ReserveBaseDrops",
|
|
||||||
{
|
|
||||||
"nth": 23,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "Amount"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"ReserveIncrementDrops",
|
|
||||||
{
|
|
||||||
"nth": 24,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "Amount"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"PublicKey",
|
"PublicKey",
|
||||||
{
|
{
|
||||||
@@ -2268,46 +2116,6 @@
|
|||||||
"type": "STObject"
|
"type": "STObject"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
|
||||||
"GenesisMint",
|
|
||||||
{
|
|
||||||
"nth": 96,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "STObject"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"ActiveValidator",
|
|
||||||
{
|
|
||||||
"nth": 95,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "STObject"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"ImportVLKey",
|
|
||||||
{
|
|
||||||
"nth": 94,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "STObject"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"HookEmission",
|
|
||||||
{
|
|
||||||
"nth": 93,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "STObject"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"Signers",
|
"Signers",
|
||||||
{
|
{
|
||||||
@@ -2447,46 +2255,6 @@
|
|||||||
"isSigningField": true,
|
"isSigningField": true,
|
||||||
"type": "STArray"
|
"type": "STArray"
|
||||||
}
|
}
|
||||||
],
|
|
||||||
[
|
|
||||||
"GenesisMints",
|
|
||||||
{
|
|
||||||
"nth": 96,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "STArray"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"ActiveValidators",
|
|
||||||
{
|
|
||||||
"nth": 95,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "STArray"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"ImportVLKeys",
|
|
||||||
{
|
|
||||||
"nth": 94,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "STArray"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"HookEmissions",
|
|
||||||
{
|
|
||||||
"nth": 93,
|
|
||||||
"isVLEncoded": false,
|
|
||||||
"isSerialized": true,
|
|
||||||
"isSigningField": true,
|
|
||||||
"type": "STArray"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"TRANSACTION_RESULTS": {
|
"TRANSACTION_RESULTS": {
|
||||||
@@ -2507,8 +2275,6 @@
|
|||||||
"telREQUIRES_NETWORK_ID": -385,
|
"telREQUIRES_NETWORK_ID": -385,
|
||||||
"telNETWORK_ID_MAKES_TX_NON_CANONICAL": -384,
|
"telNETWORK_ID_MAKES_TX_NON_CANONICAL": -384,
|
||||||
"telNON_LOCAL_EMITTED_TXN": -383,
|
"telNON_LOCAL_EMITTED_TXN": -383,
|
||||||
"telIMPORT_VL_KEY_NOT_RECOGNISED": -382,
|
|
||||||
"telCAN_NOT_QUEUE_IMPORT": -381,
|
|
||||||
|
|
||||||
"temMALFORMED": -299,
|
"temMALFORMED": -299,
|
||||||
"temBAD_AMOUNT": -298,
|
"temBAD_AMOUNT": -298,
|
||||||
@@ -2549,10 +2315,10 @@
|
|||||||
"temSEQ_AND_TICKET": -263,
|
"temSEQ_AND_TICKET": -263,
|
||||||
"temBAD_NFTOKEN_TRANSFER_FEE": -262,
|
"temBAD_NFTOKEN_TRANSFER_FEE": -262,
|
||||||
"temAMM_BAD_TOKENS": -261,
|
"temAMM_BAD_TOKENS": -261,
|
||||||
"temXCHAIN_EQUAL_DOOR_ACCOUNTS": -260,
|
"temEQUAL_DOOR_ACCOUNTS": -260,
|
||||||
"temXCHAIN_BAD_PROOF": -259,
|
"temBAD_XCHAIN_PROOF": -259,
|
||||||
"temXCHAIN_BRIDGE_BAD_ISSUES": -258,
|
"temSIDECHAIN_BAD_ISSUES": -258,
|
||||||
"temXCHAIN_BRIDGE_NONDOOR_OWNER": -257,
|
"temSIDECHAIN_NONDOOR_OWNER": -257,
|
||||||
"temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -256,
|
"temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -256,
|
||||||
"temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -255,
|
"temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -255,
|
||||||
"temXCHAIN_TOO_MANY_ATTESTATIONS": -254,
|
"temXCHAIN_TOO_MANY_ATTESTATIONS": -254,
|
||||||
@@ -2580,8 +2346,6 @@
|
|||||||
"tefTOO_BIG": -181,
|
"tefTOO_BIG": -181,
|
||||||
"tefNO_TICKET": -180,
|
"tefNO_TICKET": -180,
|
||||||
"tefNFTOKEN_IS_NOT_TRANSFERABLE": -179,
|
"tefNFTOKEN_IS_NOT_TRANSFERABLE": -179,
|
||||||
"tefPAST_IMPORT_SEQ": -178,
|
|
||||||
"tefPAST_IMPORT_VL_SEQ": -177,
|
|
||||||
|
|
||||||
"terRETRY": -99,
|
"terRETRY": -99,
|
||||||
"terFUNDS_SPENT": -98,
|
"terFUNDS_SPENT": -98,
|
||||||
@@ -2595,8 +2359,7 @@
|
|||||||
"terNO_RIPPLE": -90,
|
"terNO_RIPPLE": -90,
|
||||||
"terQUEUED": -89,
|
"terQUEUED": -89,
|
||||||
"terPRE_TICKET": -88,
|
"terPRE_TICKET": -88,
|
||||||
"terNO_AMM": -87,
|
"terNO_HOOK": -87,
|
||||||
"terNO_HOOK": -86,
|
|
||||||
|
|
||||||
"tesSUCCESS": 0,
|
"tesSUCCESS": 0,
|
||||||
|
|
||||||
@@ -2671,8 +2434,7 @@
|
|||||||
"tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 183,
|
"tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 183,
|
||||||
"tecXCHAIN_PAYMENT_FAILED": 184,
|
"tecXCHAIN_PAYMENT_FAILED": 184,
|
||||||
"tecXCHAIN_SELF_COMMIT": 185,
|
"tecXCHAIN_SELF_COMMIT": 185,
|
||||||
"tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 186,
|
"tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 186
|
||||||
"tecLAST_POSSIBLE_ENTRY": 255
|
|
||||||
},
|
},
|
||||||
"TRANSACTION_TYPES": {
|
"TRANSACTION_TYPES": {
|
||||||
"Invalid": -1,
|
"Invalid": -1,
|
||||||
@@ -2709,14 +2471,10 @@
|
|||||||
"URITokenBuy": 47,
|
"URITokenBuy": 47,
|
||||||
"URITokenCreateSellOffer": 48,
|
"URITokenCreateSellOffer": 48,
|
||||||
"URITokenCancelSellOffer": 49,
|
"URITokenCancelSellOffer": 49,
|
||||||
"GenesisMint": 96,
|
|
||||||
"Import": 97,
|
|
||||||
"ClaimReward": 98,
|
|
||||||
"Invoke": 99,
|
"Invoke": 99,
|
||||||
"EnableAmendment": 100,
|
"EnableAmendment": 100,
|
||||||
"SetFee": 101,
|
"SetFee": 101,
|
||||||
"UNLModify": 102,
|
"UNLModify": 102,
|
||||||
"EmitFailure": 103,
|
"EmitFailure": 103
|
||||||
"UNLReport": 104
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
encodeAccountID,
|
encodeAccountID,
|
||||||
isValidXAddress,
|
isValidXAddress,
|
||||||
xAddressToClassicAddress,
|
xAddressToClassicAddress,
|
||||||
} from '@transia/ripple-address-codec'
|
} from 'ripple-address-codec'
|
||||||
import { Hash160 } from './hash-160'
|
import { Hash160 } from './hash-160'
|
||||||
import { Buffer } from 'buffer/'
|
import { Buffer } from 'buffer/'
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { Currency } from './currency'
|
|||||||
import { Hash128 } from './hash-128'
|
import { Hash128 } from './hash-128'
|
||||||
import { Hash160 } from './hash-160'
|
import { Hash160 } from './hash-160'
|
||||||
import { Hash256 } from './hash-256'
|
import { Hash256 } from './hash-256'
|
||||||
|
import { Issue } from './issue'
|
||||||
import { PathSet } from './path-set'
|
import { PathSet } from './path-set'
|
||||||
import { STArray } from './st-array'
|
import { STArray } from './st-array'
|
||||||
import { STObject } from './st-object'
|
import { STObject } from './st-object'
|
||||||
@@ -24,6 +25,7 @@ const coreTypes: Record<string, typeof SerializedType> = {
|
|||||||
Hash128,
|
Hash128,
|
||||||
Hash160,
|
Hash160,
|
||||||
Hash256,
|
Hash256,
|
||||||
|
Issue,
|
||||||
PathSet,
|
PathSet,
|
||||||
STArray,
|
STArray,
|
||||||
STObject,
|
STObject,
|
||||||
|
|||||||
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 }
|
||||||
@@ -5,10 +5,7 @@ import {
|
|||||||
XrplDefinitionsBase,
|
XrplDefinitionsBase,
|
||||||
} from '../enums'
|
} from '../enums'
|
||||||
import { SerializedType, JsonObject } from './serialized-type'
|
import { SerializedType, JsonObject } from './serialized-type'
|
||||||
import {
|
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
||||||
xAddressToClassicAddress,
|
|
||||||
isValidXAddress,
|
|
||||||
} from '@transia/ripple-address-codec'
|
|
||||||
import { BinaryParser } from '../serdes/binary-parser'
|
import { BinaryParser } from '../serdes/binary-parser'
|
||||||
import { BinarySerializer, BytesList } from '../serdes/binary-serializer'
|
import { BinarySerializer, BytesList } from '../serdes/binary-serializer'
|
||||||
import { Buffer } from 'buffer/'
|
import { Buffer } from 'buffer/'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const { coreTypes } = require('../src/types')
|
const { coreTypes } = require('../src/types')
|
||||||
const Decimal = require('decimal.js')
|
const Decimal = require('decimal.js')
|
||||||
|
|
||||||
const { encodeAccountID } = require('@transia/ripple-address-codec')
|
const { encodeAccountID } = require('ripple-address-codec')
|
||||||
const { binary } = require('../src/coretypes')
|
const { binary } = require('../src/coretypes')
|
||||||
const { Amount, Hash160 } = coreTypes
|
const { Amount, Hash160 } = coreTypes
|
||||||
const { makeParser, readJSON } = binary
|
const { makeParser, readJSON } = binary
|
||||||
|
|||||||
@@ -105,11 +105,6 @@ let json_omitted = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NegativeUNL = require('./fixtures/negative-unl.json')
|
const NegativeUNL = require('./fixtures/negative-unl.json')
|
||||||
const UNLReport = {
|
|
||||||
tx: require('./fixtures/unl-report.json'),
|
|
||||||
binary: require('./fixtures/unl-report-binary.json'),
|
|
||||||
meta: require('./fixtures/unl-report-meta-binary.json'),
|
|
||||||
}
|
|
||||||
|
|
||||||
function bytesListTest() {
|
function bytesListTest() {
|
||||||
const list = new BytesList()
|
const list = new BytesList()
|
||||||
@@ -234,18 +229,6 @@ function NegativeUNLTest() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function UNLReportTest() {
|
|
||||||
test('can serialize UNLReport', () => {
|
|
||||||
expect(encode(UNLReport.tx)).toEqual(UNLReport.binary)
|
|
||||||
})
|
|
||||||
test('can serialize UNLReport metadata', () => {
|
|
||||||
expect(encode(UNLReport.tx.meta)).toEqual(UNLReport.meta)
|
|
||||||
})
|
|
||||||
test('can deserialize UNLReport metadata', () => {
|
|
||||||
expect(decode(UNLReport.meta)).toEqual(UNLReport.tx.meta)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function omitUndefinedTest() {
|
function omitUndefinedTest() {
|
||||||
test('omits fields with undefined value', () => {
|
test('omits fields with undefined value', () => {
|
||||||
let encodedOmitted = encode(json_omitted)
|
let encodedOmitted = encode(json_omitted)
|
||||||
@@ -303,5 +286,4 @@ describe('Binary Serialization', function () {
|
|||||||
describe('OmitUndefined', omitUndefinedTest)
|
describe('OmitUndefined', omitUndefinedTest)
|
||||||
describe('TicketTest', ticketTest)
|
describe('TicketTest', ticketTest)
|
||||||
describe('NFToken', nfTokenTest)
|
describe('NFToken', nfTokenTest)
|
||||||
describe('UNLReport', UNLReportTest)
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ describe('encode and decode using new types as a parameter', function () {
|
|||||||
definitions.FIELDS.push([
|
definitions.FIELDS.push([
|
||||||
'NewFieldDefinition',
|
'NewFieldDefinition',
|
||||||
{
|
{
|
||||||
nth: 101,
|
nth: 100,
|
||||||
isVLEncoded: false,
|
isVLEncoded: false,
|
||||||
isSerialized: true,
|
isSerialized: true,
|
||||||
isSigningField: true,
|
isSigningField: true,
|
||||||
|
|||||||
@@ -4448,6 +4448,213 @@
|
|||||||
"Flags": 0,
|
"Flags": 0,
|
||||||
"Sequence": 62
|
"Sequence": 62
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "12002315000A220000000024000000026140000000000027106840000000000000016BD5838D7EA4C680000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440913E39EC2BA0E5BC4C5DF1222B1AE9E76758F2B8FFEF1F056076147BB0ADC8117CD0296360DA08B3D48BE9EFC8693C03A253E0D9F166C19CA8D936F9E61A1100811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMCreate",
|
||||||
|
"TxnSignature": "913E39EC2BA0E5BC4C5DF1222B1AE9E76758F2B8FFEF1F056076147BB0ADC8117CD0296360DA08B3D48BE9EFC8693C03A253E0D9F166C19CA8D936F9E61A1100",
|
||||||
|
"Amount": "10000",
|
||||||
|
"Amount2": {
|
||||||
|
"currency": "ETH",
|
||||||
|
"issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9",
|
||||||
|
"value": "10000"
|
||||||
|
},
|
||||||
|
"TradingFee": 10,
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 0,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120024220001000024000000026840000000000000016014D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D074409EEE8CF88C668B955E7EEAB1B4A1B059EDF4F51B7F1546810F87E3E48B09237F015C651E37FB40A979E00EA21361D4E18D7A33DB7DD23070CEEAB2648AB3BB0D811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMDeposit",
|
||||||
|
"TxnSignature": "9EEE8CF88C668B955E7EEAB1B4A1B059EDF4F51B7F1546810F87E3E48B09237F015C651E37FB40A979E00EA21361D4E18D7A33DB7DD23070CEEAB2648AB3BB0D",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"LPTokenOut": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"},
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 65536,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120024220008000024000000026140000000000003E86840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440BD18A6E2B10B451F61CFADC32B59A0243702DC5DAAE556D51CB9C79981D40C78101FFA9DE6163CFBDF6E7578DF02F2AE3B8A5AB60697E0746D65064D91E8F90A811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMDeposit",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"Amount": "1000",
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 524288,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "BD18A6E2B10B451F61CFADC32B59A0243702DC5DAAE556D51CB9C79981D40C78101FFA9DE6163CFBDF6E7578DF02F2AE3B8A5AB60697E0746D65064D91E8F90A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120024220010000024000000026140000000000003E86840000000000000016BD511C37937E080000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440E0B1AE32A0F731BF0CEF0D019295BD7F35B22F11A5962F65FA99EE4D38993B14B53DB11C15E36D756E282812E9015D38A6F225940A157693F43F9B795C59950F811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMDeposit",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"Amount": "1000",
|
||||||
|
"Amount2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9", "value": "500"},
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 1048576,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "E0B1AE32A0F731BF0CEF0D019295BD7F35B22F11A5962F65FA99EE4D38993B14B53DB11C15E36D756E282812E9015D38A6F225940A157693F43F9B795C59950F"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120024220020000024000000026140000000000003E86840000000000000016014D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440452BC59F9EE12C224EC983EFDF580F20C4A50E897105FD1FB13520D9753CFB02BD210599181574DF6AD0DB6A42C1EA48D9E48FC3D11B9008E4C76FBB163D5B00811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMDeposit",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"Amount": "1000",
|
||||||
|
"LPTokenOut": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"},
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 2097152,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "452BC59F9EE12C224EC983EFDF580F20C4A50E897105FD1FB13520D9753CFB02BD210599181574DF6AD0DB6A42C1EA48D9E48FC3D11B9008E4C76FBB163D5B00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120024220040000024000000026140000000000003E8684000000000000001601640000000000000197321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440DD6685DC586FAA6AD2D50D785900122EB147D4AC09A55D7080267A9B38180F87CEC44B823359FC3F0AC0104D47B53FFC6B80415664C3C4582672420A0100F70C811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMDeposit",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"Amount": "1000",
|
||||||
|
"EPrice": "25",
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 4194304,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "DD6685DC586FAA6AD2D50D785900122EB147D4AC09A55D7080267A9B38180F87CEC44B823359FC3F0AC0104D47B53FFC6B80415664C3C4582672420A0100F70C"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120025220001000024000000026840000000000000016015D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744066944797E9F03808C9A00AAEFF786AD74FEB2E64B51A9601E89ABA820AAA15927C2E961A9CCA22C4B0D2A2B55E342BD6E297BD765B6F4D3FDCA578A3416BB505811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMWithdraw",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"LPTokenIn": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"},
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 65536,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "66944797E9F03808C9A00AAEFF786AD74FEB2E64B51A9601E89ABA820AAA15927C2E961A9CCA22C4B0D2A2B55E342BD6E297BD765B6F4D3FDCA578A3416BB505"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120025220008000024000000026140000000000003E86840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440E30397CE7E99B13D35FFB5C66725B17F4F103675E10293C7B1D63C1BE3FA81B884BD3FBD31B52F6B811F99C5FBB5102D170EC379C268DF80DABF04E7F2DD4F0C811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMWithdraw",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"Amount": "1000",
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 524288,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "E30397CE7E99B13D35FFB5C66725B17F4F103675E10293C7B1D63C1BE3FA81B884BD3FBD31B52F6B811F99C5FBB5102D170EC379C268DF80DABF04E7F2DD4F0C"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120025220010000024000000026140000000000003E86840000000000000016BD511C37937E080000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440C0818312B269A4EF16C1C7EBBB74EFD1852A288BB214A714B8BE3B5F4B2F9CFDFF4F66C931B8434244A8016035B9EC9493B7CF5E0ACF4570A88DF808D79E4300811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMWithdraw",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"Amount": "1000",
|
||||||
|
"Amount2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9", "value": "500"},
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 1048576,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "C0818312B269A4EF16C1C7EBBB74EFD1852A288BB214A714B8BE3B5F4B2F9CFDFF4F66C931B8434244A8016035B9EC9493B7CF5E0ACF4570A88DF808D79E4300"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120025220020000024000000026140000000000003E86840000000000000016015D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744073552B3DC7AE99DDF4E4FF0D60E6D0BE4688E3474D363603FA25DA6AD8BBA8F0E4E3EA82ADB2B57F5B9A6C379969E00095546DDA0E74FF3D0F0689351C2F8C06811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMWithdraw",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"Amount": "1000",
|
||||||
|
"LPTokenIn": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"},
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 2097152,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "73552B3DC7AE99DDF4E4FF0D60E6D0BE4688E3474D363603FA25DA6AD8BBA8F0E4E3EA82ADB2B57F5B9A6C379969E00095546DDA0E74FF3D0F0689351C2F8C06"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120025220040000024000000026140000000000003E8684000000000000001601640000000000000197321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744023BAFE5BFE58E7BF0B02B5875983D007C10796C8E62A190BF688EBE5D8A104DAD2DE7EDE995FE2E494883FD8140F38E22E3376A2F49C50EFCAA00C7499A4690E811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMWithdraw",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"Amount": "1000",
|
||||||
|
"EPrice": "25",
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 4194304,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "23BAFE5BFE58E7BF0B02B5875983D007C10796C8E62A190BF688EBE5D8A104DAD2DE7EDE995FE2E494883FD8140F38E22E3376A2F49C50EFCAA00C7499A4690E"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "120027220000000024000000026840000000000000016CD4C8E1BC9BF04000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0486DD4CC6F3B40B6C000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D074406B2A1548E6DC14681356C27CCBE7072CAB2AD8C72D0D7A045916FB0E0DBE6BF71A429CC519E9200172829D3EEF79100899D3A8710C1C3C1A2B664FD64086AD0A811462D4D845D20B4F09CFEA8BB4C01063D99FC9673EF01AE01C81149A91957F8F16BC57F3F200CD8C98375BF1791586E1F10318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMBid",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"AuthAccounts": [{"AuthAccount": {"Account": "rEaHTti4HZsMBpxTAF4ncWxkcdqDh1h6P7"}}],
|
||||||
|
"BidMax": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "35"},
|
||||||
|
"BidMin": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "25"},
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 0,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "6B2A1548E6DC14681356C27CCBE7072CAB2AD8C72D0D7A045916FB0E0DBE6BF71A429CC519E9200172829D3EEF79100899D3A8710C1C3C1A2B664FD64086AD0A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"binary": "1200261500EA220000000024000000026840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744072767CF9A0F5E9C9DA6BBB6E84905B0ECDF122D3E2D730843EFD377521E8E73664AD809D0A54E8C75CD1735ACB64E310BB49FDED10913FA150B8C006D4ACEC00811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C",
|
||||||
|
"json": {
|
||||||
|
"Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV",
|
||||||
|
"TransactionType": "AMMVote",
|
||||||
|
"Asset": {"currency": "XRP"},
|
||||||
|
"Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"},
|
||||||
|
"TradingFee": 234,
|
||||||
|
"Fee": "1",
|
||||||
|
"Flags": 0,
|
||||||
|
"Sequence": 2,
|
||||||
|
"SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0",
|
||||||
|
"TxnSignature": "72767CF9A0F5E9C9DA6BBB6E84905B0ECDF122D3E2D730843EFD377521E8E73664AD809D0A54E8C75CD1735ACB64E310BB49FDED10913FA150B8C006D4ACEC00"
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
"ledgerData": [{
|
"ledgerData": [{
|
||||||
"binary": "01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00",
|
"binary": "01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00",
|
||||||
@@ -4463,4 +4670,4 @@
|
|||||||
"transaction_hash": "DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87"
|
"transaction_hash": "DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87"
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"120068240000000026006D2E00684000000000000000730081140000000000000000000000000000000000000000E05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655E1"
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
"201C00000000F8E51100525661E32E7A24A238F1C619D5F9DDCC41A94B33B66C0163F7EFCC8A19C9FD6F28DCE6F05FE05F7121ED3ABC6740983BFB13FFD9728EBCC365A2877877D368FC28990819522300C92A698114A53F8465478D79DC0C764F0FB2B67AE92465FD5EE1E05F7121ED49F82B2FFD537F224A1E0A10DEEFC3C25CE3882979E6B327C9F18603D21F0A2281142BF2A77E25382EC1DEF521D81D24BC0FDD35BC9BE1E05F7121ED79EB0F6A9F01A039235E536D19F812B55ACF540C9E22CF62C271E0D42BFF51748114C45147960400DB6B763110CBCE8D641E9365F24EE1E05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655811408BCFB092DEE1BF0F2662AECE4DCC62C4AECCB8AE1E05F7121ED96F581FED430E8CBE1F08B37408857001D4118D49FBB594B0BE007C2DBFFD3678114A4EF485B50A7D91DF45450A680FAC31C53367B2DE1E05F7121EDCF31B8F683345E1C49B4A1D85BF2731E55E7D6781F3D4BF45EE7ADF2D2FB340281144D854497B48F1A41EF04E09DB656A11AAD01A703E1E05F7121EDDF197FC59A7FAA09EB1AD60A4638BA6201DD51497B5C08A1745115098E229E0E811446550CBD2B655081662AE3159B0488DE27EC0592E1F1E1E72200000000F05EE05E7121ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860811478339DD5880A994A5CB6E56CB7ED13FEEF201928E1F1F05FE05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655811408BCFB092DEE1BF0F2662AECE4DCC62C4AECCB8AE1F1E1E1F1031000"
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
{
|
|
||||||
"Account": "",
|
|
||||||
"ActiveValidator": {
|
|
||||||
"PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
|
|
||||||
},
|
|
||||||
"Fee": "0",
|
|
||||||
"LedgerSequence": 7155200,
|
|
||||||
"Sequence": 0,
|
|
||||||
"SigningPubKey": "",
|
|
||||||
"TransactionType": "UNLReport",
|
|
||||||
"hash": "0878863F758F74A5CBD35691CDAB625A3BCD35B21B440E20545C4757DDB0CA43",
|
|
||||||
"meta": {
|
|
||||||
"AffectedNodes": [
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"ActiveValidators": [
|
|
||||||
{
|
|
||||||
"ActiveValidator": {
|
|
||||||
"Account": "roUo3ygV92bdhfE1v9LGpPETXvJv2kQv5",
|
|
||||||
"PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"Flags": 0,
|
|
||||||
"ImportVLKeys": [
|
|
||||||
{
|
|
||||||
"ImportVLKey": {
|
|
||||||
"Account": "rBxZvQBY551DJ21g9AC1Qc9ASQowqcskbF",
|
|
||||||
"PublicKey": "ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "UNLReport",
|
|
||||||
"LedgerIndex": "61E32E7A24A238F1C619D5F9DDCC41A94B33B66C0163F7EFCC8A19C9FD6F28DC",
|
|
||||||
"PreviousFields": {
|
|
||||||
"ActiveValidators": [
|
|
||||||
{
|
|
||||||
"ActiveValidator": {
|
|
||||||
"Account": "rGhk2uLd8ShzX2Zrcgn8sQk1LWBG4jjEwf",
|
|
||||||
"PublicKey": "ED3ABC6740983BFB13FFD9728EBCC365A2877877D368FC28990819522300C92A69"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ActiveValidator": {
|
|
||||||
"Account": "rnr4kwS1VkJhvjVRuq2fbWZtEdN2HbpVVu",
|
|
||||||
"PublicKey": "ED49F82B2FFD537F224A1E0A10DEEFC3C25CE3882979E6B327C9F18603D21F0A22"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ActiveValidator": {
|
|
||||||
"Account": "rJupFrPPYgUNFBdoSqhMEJ22hiHKiZSHXQ",
|
|
||||||
"PublicKey": "ED79EB0F6A9F01A039235E536D19F812B55ACF540C9E22CF62C271E0D42BFF5174"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ActiveValidator": {
|
|
||||||
"Account": "roUo3ygV92bdhfE1v9LGpPETXvJv2kQv5",
|
|
||||||
"PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ActiveValidator": {
|
|
||||||
"Account": "rGsa7f4arJ8JE9ok9LCht6jCu5xBKUKVMq",
|
|
||||||
"PublicKey": "ED96F581FED430E8CBE1F08B37408857001D4118D49FBB594B0BE007C2DBFFD367"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ActiveValidator": {
|
|
||||||
"Account": "r3htgPchiR2r8kMGzPK3Wfv3WTrpaRKjtU",
|
|
||||||
"PublicKey": "EDCF31B8F683345E1C49B4A1D85BF2731E55E7D6781F3D4BF45EE7ADF2D2FB3402"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ActiveValidator": {
|
|
||||||
"Account": "rfQtB8m51sdbWgcmddRX2mMjMpSxzX1AGr",
|
|
||||||
"PublicKey": "EDDF197FC59A7FAA09EB1AD60A4638BA6201DD51497B5C08A1745115098E229E0E"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"TransactionIndex": 0,
|
|
||||||
"TransactionResult": "tesSUCCESS"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -170,7 +170,59 @@ describe('Signing data', function () {
|
|||||||
].join(''),
|
].join(''),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
test('can create native claim blob', function () {
|
|
||||||
|
test('can create multi signing blobs with custom definitions', function () {
|
||||||
|
const customPaymentDefinitions = JSON.parse(
|
||||||
|
JSON.stringify(normalDefinitions),
|
||||||
|
)
|
||||||
|
customPaymentDefinitions.TRANSACTION_TYPES.Payment = 31
|
||||||
|
|
||||||
|
const newDefs = new XrplDefinitions(customPaymentDefinitions)
|
||||||
|
const signingAccount = 'rJZdUusLDtY9NEsGea7ijqhVrXv98rYBYN'
|
||||||
|
const signingJson = { ...tx_json, SigningPubKey: '' }
|
||||||
|
const actual = encodeForMultisigning(signingJson, signingAccount, newDefs)
|
||||||
|
expect(actual).toBe(
|
||||||
|
[
|
||||||
|
'534D5400', // signingPrefix
|
||||||
|
// TransactionType
|
||||||
|
'12',
|
||||||
|
'001F',
|
||||||
|
// Flags
|
||||||
|
'22',
|
||||||
|
'80000000',
|
||||||
|
// Sequence
|
||||||
|
'24',
|
||||||
|
'00000001',
|
||||||
|
// Amount
|
||||||
|
'61',
|
||||||
|
// native amount
|
||||||
|
'40000000000003E8',
|
||||||
|
// Fee
|
||||||
|
'68',
|
||||||
|
// native amount
|
||||||
|
'400000000000000A',
|
||||||
|
// SigningPubKey
|
||||||
|
'73',
|
||||||
|
// VLLength
|
||||||
|
'00',
|
||||||
|
// '',
|
||||||
|
// Account
|
||||||
|
'81',
|
||||||
|
// VLLength
|
||||||
|
'14',
|
||||||
|
'5B812C9D57731E27A2DA8B1830195F88EF32A3B6',
|
||||||
|
// Destination
|
||||||
|
'83',
|
||||||
|
// VLLength
|
||||||
|
'14',
|
||||||
|
'B5F762798A53D543A014CAF8B297CFF8F2F937E8',
|
||||||
|
// signingAccount suffix
|
||||||
|
'C0A5ABEF242802EFED4B041E8F2D4A8CC86AE3D1',
|
||||||
|
].join(''),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('can create claim blob', function () {
|
||||||
const channel =
|
const channel =
|
||||||
'43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1'
|
'43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1'
|
||||||
const amount = '1000'
|
const amount = '1000'
|
||||||
@@ -187,27 +239,4 @@ describe('Signing data', function () {
|
|||||||
].join(''),
|
].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(''),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-keypairs",
|
"name": "@transia/ripple-keypairs",
|
||||||
"version": "1.1.8-alpha.0",
|
"version": "1.1.6-tbeta.0",
|
||||||
"description": "Cryptographic key pairs for the XRP Ledger",
|
"description": "Cryptographic key pairs for the XRP Ledger",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -b",
|
"build": "tsc -b",
|
||||||
@@ -17,15 +17,15 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.8-alpha.0",
|
|
||||||
"bn.js": "^5.1.1",
|
"bn.js": "^5.1.1",
|
||||||
"brorand": "^1.0.5",
|
"brorand": "^1.0.5",
|
||||||
"elliptic": "^6.5.4",
|
"elliptic": "^6.5.4",
|
||||||
"hash.js": "^1.0.3"
|
"hash.js": "^1.0.3",
|
||||||
|
"ripple-address-codec": "^4.2.5"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@github.com/Transia-RnD/xrpl.js/tree/beta"
|
"url": "git@github.com:Transia-RnD/xrpl.js/tree/transia-beta"
|
||||||
},
|
},
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"prettier": "@xrplf/prettier-config",
|
"prettier": "@xrplf/prettier-config",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import brorand = require('brorand')
|
|||||||
import * as hashjs from 'hash.js'
|
import * as hashjs from 'hash.js'
|
||||||
import * as elliptic from 'elliptic'
|
import * as elliptic from 'elliptic'
|
||||||
|
|
||||||
import * as addressCodec from '@transia/ripple-address-codec'
|
import * as addressCodec from 'ripple-address-codec'
|
||||||
import { derivePrivateKey, accountPublicFromPublicGenerator } from './secp256k1'
|
import { derivePrivateKey, accountPublicFromPublicGenerator } from './secp256k1'
|
||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import * as api from '@transia/ripple-address-codec'
|
import * as api from 'ripple-address-codec'
|
||||||
|
|
||||||
function toHex(bytes) {
|
function toHex(bytes) {
|
||||||
return Buffer.from(bytes).toString('hex').toUpperCase()
|
return Buffer.from(bytes).toString('hex').toUpperCase()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import * as api from '@transia/ripple-address-codec'
|
import * as api from 'ripple-address-codec'
|
||||||
|
|
||||||
function toHex(bytes: Buffer) {
|
function toHex(bytes: Buffer) {
|
||||||
return Buffer.from(bytes).toString('hex').toUpperCase()
|
return Buffer.from(bytes).toString('hex').toUpperCase()
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ Wallet.fromMmnemonic()
|
|||||||
* `Wallet.fromMnemonic` detects when an invalid encoding is provided, and throws an error
|
* `Wallet.fromMnemonic` detects when an invalid encoding is provided, and throws an error
|
||||||
* Made unexpected errors in `submitAndWait` more verbose to make them easier to debug.
|
* Made unexpected errors in `submitAndWait` more verbose to make them easier to debug.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
* Support for Automated Market Maker (AMM) transactions and requests as defined in XLS-30.
|
||||||
|
|
||||||
## 2.3.1 (2022-06-27)
|
## 2.3.1 (2022-06-27)
|
||||||
### Fixed
|
### Fixed
|
||||||
* Signing tx with standard currency codes with lowercase and allowed symbols causing an error on decode.
|
* Signing tx with standard currency codes with lowercase and allowed symbols causing an error on decode.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/xrpl",
|
"name": "@transia/xrpl",
|
||||||
"version": "2.7.3-alpha.16",
|
"version": "2.7.1-tbeta.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser",
|
"description": "A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -22,14 +22,14 @@
|
|||||||
"https-proxy-agent": false
|
"https-proxy-agent": false
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.8-alpha.0",
|
|
||||||
"@transia/ripple-binary-codec": "^1.4.6-alpha.4",
|
|
||||||
"@transia/ripple-keypairs": "^1.1.8-alpha.0",
|
|
||||||
"bignumber.js": "^9.0.0",
|
"bignumber.js": "^9.0.0",
|
||||||
"bip32": "^2.0.6",
|
"bip32": "^2.0.6",
|
||||||
"bip39": "^3.0.4",
|
"bip39": "^3.0.4",
|
||||||
"https-proxy-agent": "^5.0.0",
|
"https-proxy-agent": "^5.0.0",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
|
"ripple-address-codec": "^4.2.5",
|
||||||
|
"ripple-binary-codec": "^1.4.3",
|
||||||
|
"ripple-keypairs": "^1.1.5",
|
||||||
"ws": "^8.2.2"
|
"ws": "^8.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
"prettier": "@xrplf/prettier-config",
|
"prettier": "@xrplf/prettier-config",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@github.com/Transia-RnD/xrpl.js/tree/beta"
|
"url": "git@github.com:Transia-RnD/xrpl.js/tree/transia-beta"
|
||||||
},
|
},
|
||||||
"readmeFilename": "README.md",
|
"readmeFilename": "README.md",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { IncomingMessage } from 'http'
|
import { IncomingMessage } from 'http'
|
||||||
import { request as httpsRequest, RequestOptions } from 'https'
|
import { request as httpsRequest, RequestOptions } from 'https'
|
||||||
|
|
||||||
import { isValidClassicAddress } from '@transia/ripple-address-codec'
|
import { isValidClassicAddress } from 'ripple-address-codec'
|
||||||
|
|
||||||
import type { Client } from '../client'
|
import type { Client } from '../client'
|
||||||
import { RippledError, XRPLFaucetError } from '../errors'
|
import { RippledError, XRPLFaucetError } from '../errors'
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
/* eslint-disable max-lines -- There are lots of equivalent constructors which make sense to have here. */
|
/* eslint-disable max-lines -- There are lots of equivalent constructors which make sense to have here. */
|
||||||
|
import BigNumber from 'bignumber.js'
|
||||||
|
import { fromSeed } from 'bip32'
|
||||||
|
import { mnemonicToSeedSync, validateMnemonic } from 'bip39'
|
||||||
|
import isEqual from 'lodash/isEqual'
|
||||||
|
import omitBy from 'lodash/omitBy'
|
||||||
import {
|
import {
|
||||||
classicAddressToXAddress,
|
classicAddressToXAddress,
|
||||||
isValidXAddress,
|
isValidXAddress,
|
||||||
xAddressToClassicAddress,
|
xAddressToClassicAddress,
|
||||||
encodeSeed,
|
encodeSeed,
|
||||||
} from '@transia/ripple-address-codec'
|
} from 'ripple-address-codec'
|
||||||
import {
|
import {
|
||||||
decode,
|
decode,
|
||||||
encodeForSigning,
|
encodeForSigning,
|
||||||
encodeForMultisigning,
|
encodeForMultisigning,
|
||||||
encode,
|
encode,
|
||||||
} from '@transia/ripple-binary-codec'
|
} from 'ripple-binary-codec'
|
||||||
import {
|
import {
|
||||||
deriveAddress,
|
deriveAddress,
|
||||||
deriveKeypair,
|
deriveKeypair,
|
||||||
generateSeed,
|
generateSeed,
|
||||||
verify,
|
verify,
|
||||||
sign,
|
sign,
|
||||||
} from '@transia/ripple-keypairs'
|
} from 'ripple-keypairs'
|
||||||
import BigNumber from 'bignumber.js'
|
|
||||||
import { fromSeed } from 'bip32'
|
|
||||||
import { mnemonicToSeedSync, validateMnemonic } from 'bip39'
|
|
||||||
import isEqual from 'lodash/isEqual'
|
|
||||||
import omitBy from 'lodash/omitBy'
|
|
||||||
|
|
||||||
import ECDSA from '../ECDSA'
|
import ECDSA from '../ECDSA'
|
||||||
import { ValidationError, XrplError } from '../errors'
|
import { ValidationError, XrplError } from '../errors'
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { decodeAccountID } from '@transia/ripple-address-codec'
|
import { BigNumber } from 'bignumber.js'
|
||||||
|
import { flatMap } from 'lodash'
|
||||||
|
import { decodeAccountID } from 'ripple-address-codec'
|
||||||
import {
|
import {
|
||||||
decode,
|
decode,
|
||||||
encode,
|
encode,
|
||||||
encodeForSigning,
|
encodeForSigning,
|
||||||
encodeForSigningClaim,
|
encodeForSigningClaim,
|
||||||
} from '@transia/ripple-binary-codec'
|
} from 'ripple-binary-codec'
|
||||||
import { sign as signWithKeypair, verify } from '@transia/ripple-keypairs'
|
import { sign as signWithKeypair, verify } from 'ripple-keypairs'
|
||||||
import { BigNumber } from 'bignumber.js'
|
|
||||||
import { flatMap } from 'lodash'
|
|
||||||
|
|
||||||
import { ValidationError } from '../errors'
|
import { ValidationError } from '../errors'
|
||||||
import { Signer } from '../models/common'
|
import { Signer } from '../models/common'
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import {
|
|||||||
AccountOffersResponse,
|
AccountOffersResponse,
|
||||||
AccountTxRequest,
|
AccountTxRequest,
|
||||||
AccountTxResponse,
|
AccountTxResponse,
|
||||||
|
// AMM methods
|
||||||
|
AMMInfoRequest,
|
||||||
|
AMMInfoResponse,
|
||||||
GatewayBalancesRequest,
|
GatewayBalancesRequest,
|
||||||
GatewayBalancesResponse,
|
GatewayBalancesResponse,
|
||||||
NoRippleCheckRequest,
|
NoRippleCheckRequest,
|
||||||
@@ -308,6 +311,7 @@ class Client extends EventEmitter {
|
|||||||
): Promise<AccountObjectsResponse>
|
): Promise<AccountObjectsResponse>
|
||||||
public async request(r: AccountOffersRequest): Promise<AccountOffersResponse>
|
public async request(r: AccountOffersRequest): Promise<AccountOffersResponse>
|
||||||
public async request(r: AccountTxRequest): Promise<AccountTxResponse>
|
public async request(r: AccountTxRequest): Promise<AccountTxResponse>
|
||||||
|
public async request(r: AMMInfoRequest): Promise<AMMInfoResponse>
|
||||||
public async request(r: BookOffersRequest): Promise<BookOffersResponse>
|
public async request(r: BookOffersRequest): Promise<BookOffersResponse>
|
||||||
public async request(r: ChannelVerifyRequest): Promise<ChannelVerifyResponse>
|
public async request(r: ChannelVerifyRequest): Promise<ChannelVerifyResponse>
|
||||||
public async request(
|
public async request(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { decode } from '@transia/ripple-binary-codec'
|
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
|
import { decode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
AccountTxResponse,
|
AccountTxResponse,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ interface XRP {
|
|||||||
currency: 'XRP'
|
currency: 'XRP'
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IssuedCurrency {
|
export interface IssuedCurrency {
|
||||||
currency: string
|
currency: string
|
||||||
issuer: string
|
issuer: string
|
||||||
}
|
}
|
||||||
@@ -97,15 +97,14 @@ export interface Hook {
|
|||||||
* The object that describes the hook in Hooks.
|
* The object that describes the hook in Hooks.
|
||||||
*/
|
*/
|
||||||
Hook: {
|
Hook: {
|
||||||
HookHash?: string
|
|
||||||
/**
|
/**
|
||||||
* The code that is executed when the hook is triggered.
|
* The code that is executed when the hook is triggered.
|
||||||
*/
|
*/
|
||||||
CreateCode?: string
|
CreateCode: string
|
||||||
/**
|
/**
|
||||||
* The flags that are set on the hook.
|
* The flags that are set on the hook.
|
||||||
*/
|
*/
|
||||||
Flags?: number
|
Flags: number
|
||||||
/**
|
/**
|
||||||
* The transactions that triggers the hook. Represented as a 256Hash
|
* The transactions that triggers the hook. Represented as a 256Hash
|
||||||
*/
|
*/
|
||||||
@@ -195,13 +194,3 @@ export interface NFTOffer {
|
|||||||
destination?: string
|
destination?: string
|
||||||
expiration?: number
|
expiration?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This information is added to emitted Transactions.
|
|
||||||
*/
|
|
||||||
export interface EmitDetails {
|
|
||||||
EmitBurden: number
|
|
||||||
EmitGeneration: number
|
|
||||||
EmitHookHash: string
|
|
||||||
EmitParentTxnID: string
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -72,10 +72,6 @@ export default interface AccountRoot extends BaseLedgerEntry {
|
|||||||
* account to each other.
|
* account to each other.
|
||||||
*/
|
*/
|
||||||
TransferRate?: number
|
TransferRate?: number
|
||||||
ImportSequence?: string
|
|
||||||
GovernanceFlags?: string
|
|
||||||
GovernanceMarks?: string
|
|
||||||
AccountIndex?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { Amount } from '../common'
|
|
||||||
|
|
||||||
import BaseLedgerEntry from './BaseLedgerEntry'
|
import BaseLedgerEntry from './BaseLedgerEntry'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Escrow object type represents a held payment waiting to be
|
* The Escrow object type represents a held payment of XRP waiting to be
|
||||||
* executed or canceled.
|
* executed or canceled.
|
||||||
*
|
*
|
||||||
* @category Ledger Entries
|
* @category Ledger Entries
|
||||||
@@ -12,17 +10,17 @@ export default interface Escrow extends BaseLedgerEntry {
|
|||||||
LedgerEntryType: 'Escrow'
|
LedgerEntryType: 'Escrow'
|
||||||
/**
|
/**
|
||||||
* The address of the owner (sender) of this held payment. This is the
|
* The address of the owner (sender) of this held payment. This is the
|
||||||
* account that provided the amounts, and gets it back if the held payment is
|
* account that provided the XRP, and gets it back if the held payment is
|
||||||
* canceled.
|
* canceled.
|
||||||
*/
|
*/
|
||||||
Account: string
|
Account: string
|
||||||
/**
|
/**
|
||||||
* The destination address where the amounts are paid if the held payment is
|
* The destination address where the XRP is paid if the held payment is
|
||||||
* successful.
|
* successful.
|
||||||
*/
|
*/
|
||||||
Destination: string
|
Destination: string
|
||||||
/** The amount to be delivered by the held payment. */
|
/** The amount of XRP, in drops, to be delivered by the held payment. */
|
||||||
Amount: Amount
|
Amount: string
|
||||||
/**
|
/**
|
||||||
* A PREIMAGE-SHA-256 crypto-condition, as hexadecimal. If present, the
|
* A PREIMAGE-SHA-256 crypto-condition, as hexadecimal. If present, the
|
||||||
* EscrowFinish transaction must contain a fulfillment that satisfies this
|
* EscrowFinish transaction must contain a fulfillment that satisfies this
|
||||||
@@ -73,9 +71,4 @@ export default interface Escrow extends BaseLedgerEntry {
|
|||||||
* modified this object.
|
* modified this object.
|
||||||
*/
|
*/
|
||||||
PreviousTxnLgrSeq: number
|
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
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,4 @@ export default interface FeeSettings extends BaseLedgerEntry {
|
|||||||
* type.
|
* type.
|
||||||
*/
|
*/
|
||||||
Flags: number
|
Flags: number
|
||||||
XahauActivationLgrSeq?: number
|
|
||||||
AccountCount?: number
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
import BaseLedgerEntry from './BaseLedgerEntry'
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @category Ledger Entries
|
|
||||||
*/
|
|
||||||
export default interface ImportVLSequence extends BaseLedgerEntry {
|
|
||||||
LedgerEntryType: 'ImportVLSequence'
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
PublicKey: string
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
ImportSequence: string
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@ import FeeSettings from './FeeSettings'
|
|||||||
import Hook from './Hook'
|
import Hook from './Hook'
|
||||||
import HookDefinition from './HookDefinition'
|
import HookDefinition from './HookDefinition'
|
||||||
import HookState from './HookState'
|
import HookState from './HookState'
|
||||||
import ImportVLSequence from './ImportVLSequence'
|
|
||||||
import LedgerHashes from './LedgerHashes'
|
import LedgerHashes from './LedgerHashes'
|
||||||
import NegativeUNL from './NegativeUNL'
|
import NegativeUNL from './NegativeUNL'
|
||||||
import Offer from './Offer'
|
import Offer from './Offer'
|
||||||
@@ -17,8 +16,6 @@ import PayChannel from './PayChannel'
|
|||||||
import RippleState from './RippleState'
|
import RippleState from './RippleState'
|
||||||
import SignerList from './SignerList'
|
import SignerList from './SignerList'
|
||||||
import Ticket from './Ticket'
|
import Ticket from './Ticket'
|
||||||
import UNLReport from './UNLReport'
|
|
||||||
import URIToken from './URIToken'
|
|
||||||
|
|
||||||
type LedgerEntry =
|
type LedgerEntry =
|
||||||
| AccountRoot
|
| AccountRoot
|
||||||
@@ -32,7 +29,6 @@ type LedgerEntry =
|
|||||||
| Hook
|
| Hook
|
||||||
| HookDefinition
|
| HookDefinition
|
||||||
| HookState
|
| HookState
|
||||||
| ImportVLSequence
|
|
||||||
| LedgerHashes
|
| LedgerHashes
|
||||||
| NegativeUNL
|
| NegativeUNL
|
||||||
| Offer
|
| Offer
|
||||||
@@ -40,7 +36,5 @@ type LedgerEntry =
|
|||||||
| RippleState
|
| RippleState
|
||||||
| SignerList
|
| SignerList
|
||||||
| Ticket
|
| Ticket
|
||||||
| UNLReport
|
|
||||||
| URIToken
|
|
||||||
|
|
||||||
export default LedgerEntry
|
export default LedgerEntry
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { Amount } from '../common'
|
|
||||||
|
|
||||||
import BaseLedgerEntry from './BaseLedgerEntry'
|
import BaseLedgerEntry from './BaseLedgerEntry'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PayChannel object type represents a payment channel. Payment channels
|
* The PayChannel object type represents a payment channel. Payment channels
|
||||||
* enable small, rapid off-ledger payments that can be later reconciled
|
* enable small, rapid off-ledger payments of XRP that can be later reconciled
|
||||||
* with the consensus ledger. A payment channel holds a balance that can
|
* with the consensus ledger. A payment channel holds a balance of XRP that can
|
||||||
* only be paid out to a specific destination address until the channel is
|
* only be paid out to a specific destination address until the channel is
|
||||||
* closed.
|
* closed.
|
||||||
*
|
*
|
||||||
@@ -20,37 +18,37 @@ export default interface PayChannel extends BaseLedgerEntry {
|
|||||||
Account: string
|
Account: string
|
||||||
/**
|
/**
|
||||||
* The destination address for this payment channel. While the payment
|
* The destination address for this payment channel. While the payment
|
||||||
* channel is open, this address is the only one that can receive amounts from the
|
* channel is open, this address is the only one that can receive XRP from the
|
||||||
* channel. This comes from the Destination field of the transaction that
|
* channel. This comes from the Destination field of the transaction that
|
||||||
* created the channel.
|
* created the channel.
|
||||||
*/
|
*/
|
||||||
Destination: string
|
Destination: string
|
||||||
/**
|
/**
|
||||||
* Total amount that has been allocated to this channel. This includes amounts
|
* Total XRP, in drops, that has been allocated to this channel. This
|
||||||
* that have been paid to the destination address. This is initially set by the
|
* includes XRP that has been paid to the destination address. This is
|
||||||
* transaction that created the channel and can be increased if the source
|
* initially set by the transaction that created the channel and can be
|
||||||
* address sends a PaymentChannelFund transaction.
|
* increased if the source address sends a PaymentChannelFund transaction.
|
||||||
*/
|
*/
|
||||||
Amount: Amount
|
Amount: string
|
||||||
/**
|
/**
|
||||||
* Total amount already paid out by the channel. The difference between this value
|
* Total XRP, in drops, already paid out by the channel. The difference
|
||||||
* and the Amount field is how much can still be paid to the destination address
|
* between this value and the Amount field is how much XRP can still be paid
|
||||||
* with PaymentChannelClaim transactions. If the channel closes, the remaining
|
* to the destination address with PaymentChannelClaim transactions. If the
|
||||||
* difference is returned to the source address.
|
* channel closes, the remaining difference is returned to the source address.
|
||||||
*/
|
*/
|
||||||
Balance: Amount
|
Balance: string
|
||||||
/**
|
/**
|
||||||
* Public key, in hexadecimal, of the key pair that can be used to sign
|
* 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
|
* 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
|
* 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
|
* must match the public key used in claims against the channel. The channel
|
||||||
* source address can also send amounts from this channel to the destination
|
* source address can also send XRP from this channel to the destination
|
||||||
* without signed claims.
|
* without signed claims.
|
||||||
*/
|
*/
|
||||||
PublicKey: string
|
PublicKey: string
|
||||||
/**
|
/**
|
||||||
* Number of seconds the source address must wait to close the channel if
|
* Number of seconds the source address must wait to close the channel if
|
||||||
* it still has any amount in it. Smaller values mean that the destination
|
* it still has any XRP in it. Smaller values mean that the destination
|
||||||
* address has less time to redeem any outstanding claims after the source
|
* address 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
|
* 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
|
* 32-bit unsigned integer (0 to 2^32-1). This is set by the transaction that
|
||||||
@@ -106,10 +104,4 @@ export default interface PayChannel extends BaseLedgerEntry {
|
|||||||
* this object, in case the directory consists of multiple pages.
|
* this object, in case the directory consists of multiple pages.
|
||||||
*/
|
*/
|
||||||
DestinationNode?: string
|
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
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import BaseLedgerEntry from './BaseLedgerEntry'
|
|
||||||
|
|
||||||
interface ImportVLKey {
|
|
||||||
ImportVLKey: {
|
|
||||||
PublicKey: string
|
|
||||||
Account?: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
interface ActiveValidator {
|
|
||||||
ActiveValidator: {
|
|
||||||
PublicKey: string
|
|
||||||
Account?: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @category Ledger Entries
|
|
||||||
*/
|
|
||||||
export default interface UNLReport extends BaseLedgerEntry {
|
|
||||||
LedgerEntryType: 'UNLReport'
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
ImportVLKeys?: ImportVLKey[]
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
ActiveValidators?: ActiveValidator[]
|
|
||||||
/**
|
|
||||||
* 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,53 +0,0 @@
|
|||||||
import { Amount } from '../common'
|
|
||||||
|
|
||||||
import BaseLedgerEntry from './BaseLedgerEntry'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The URIToken object type contains the
|
|
||||||
*
|
|
||||||
* @category Ledger Entries
|
|
||||||
*/
|
|
||||||
export default interface URIToken extends BaseLedgerEntry {
|
|
||||||
LedgerEntryType: 'URIToken'
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
Owner: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
Issuer: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
URI: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
Digest: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
Amount: Amount
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
Destination: 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
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,6 @@ import FeeSettings from './FeeSettings'
|
|||||||
import Hook from './Hook'
|
import Hook from './Hook'
|
||||||
import HookDefinition from './HookDefinition'
|
import HookDefinition from './HookDefinition'
|
||||||
import HookState from './HookState'
|
import HookState from './HookState'
|
||||||
import ImportVLSequence from './ImportVLSequence'
|
|
||||||
import Ledger from './Ledger'
|
import Ledger from './Ledger'
|
||||||
import LedgerEntry from './LedgerEntry'
|
import LedgerEntry from './LedgerEntry'
|
||||||
import LedgerHashes from './LedgerHashes'
|
import LedgerHashes from './LedgerHashes'
|
||||||
@@ -22,8 +21,6 @@ import PayChannel from './PayChannel'
|
|||||||
import RippleState, { RippleStateFlags } from './RippleState'
|
import RippleState, { RippleStateFlags } from './RippleState'
|
||||||
import SignerList, { SignerListFlags } from './SignerList'
|
import SignerList, { SignerListFlags } from './SignerList'
|
||||||
import Ticket from './Ticket'
|
import Ticket from './Ticket'
|
||||||
import UNLReport from './UNLReport'
|
|
||||||
import URIToken from './URIToken'
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
AccountRoot,
|
AccountRoot,
|
||||||
@@ -39,7 +36,6 @@ export {
|
|||||||
Hook,
|
Hook,
|
||||||
HookDefinition,
|
HookDefinition,
|
||||||
HookState,
|
HookState,
|
||||||
ImportVLSequence,
|
|
||||||
Ledger,
|
Ledger,
|
||||||
LedgerEntry,
|
LedgerEntry,
|
||||||
LedgerHashes,
|
LedgerHashes,
|
||||||
@@ -52,6 +48,4 @@ export {
|
|||||||
SignerList,
|
SignerList,
|
||||||
SignerListFlags,
|
SignerListFlags,
|
||||||
Ticket,
|
Ticket,
|
||||||
UNLReport,
|
|
||||||
URIToken,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Amount, LedgerIndex } from '../common'
|
import { LedgerIndex } from '../common'
|
||||||
|
|
||||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||||
|
|
||||||
interface Channel {
|
interface Channel {
|
||||||
account: string
|
account: string
|
||||||
amount: Amount
|
amount: string
|
||||||
balance: string
|
balance: string
|
||||||
channel_id: string
|
channel_id: string
|
||||||
destination_account: string
|
destination_account: string
|
||||||
@@ -15,7 +15,6 @@ interface Channel {
|
|||||||
cancel_after?: number
|
cancel_after?: number
|
||||||
source_tab?: number
|
source_tab?: number
|
||||||
destination_tag?: number
|
destination_tag?: number
|
||||||
transfer_rate?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Amount, LedgerIndex } from '../common'
|
import { LedgerIndex } from '../common'
|
||||||
|
|
||||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||||
|
|
||||||
@@ -64,14 +64,6 @@ export interface Trustline {
|
|||||||
* false.
|
* false.
|
||||||
*/
|
*/
|
||||||
freeze_peer?: boolean
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,13 +3,11 @@ import {
|
|||||||
Check,
|
Check,
|
||||||
DepositPreauth,
|
DepositPreauth,
|
||||||
Escrow,
|
Escrow,
|
||||||
Hook,
|
|
||||||
Offer,
|
Offer,
|
||||||
PayChannel,
|
PayChannel,
|
||||||
RippleState,
|
RippleState,
|
||||||
SignerList,
|
SignerList,
|
||||||
Ticket,
|
Ticket,
|
||||||
URIToken,
|
|
||||||
} from '../ledger'
|
} from '../ledger'
|
||||||
|
|
||||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||||
@@ -18,14 +16,12 @@ type AccountObjectType =
|
|||||||
| 'check'
|
| 'check'
|
||||||
| 'deposit_preauth'
|
| 'deposit_preauth'
|
||||||
| 'escrow'
|
| 'escrow'
|
||||||
| 'hook'
|
|
||||||
| 'nft_offer'
|
| 'nft_offer'
|
||||||
| 'offer'
|
| 'offer'
|
||||||
| 'payment_channel'
|
| 'payment_channel'
|
||||||
| 'signer_list'
|
| 'signer_list'
|
||||||
| 'state'
|
| 'state'
|
||||||
| 'ticket'
|
| 'ticket'
|
||||||
| 'uritoken'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The account_objects command returns the raw ledger format for all objects
|
* The account_objects command returns the raw ledger format for all objects
|
||||||
@@ -77,13 +73,11 @@ type AccountObject =
|
|||||||
| Check
|
| Check
|
||||||
| DepositPreauth
|
| DepositPreauth
|
||||||
| Escrow
|
| Escrow
|
||||||
| Hook
|
|
||||||
| Offer
|
| Offer
|
||||||
| PayChannel
|
| PayChannel
|
||||||
| SignerList
|
| SignerList
|
||||||
| RippleState
|
| RippleState
|
||||||
| Ticket
|
| Ticket
|
||||||
| URIToken
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response expected from an {@link AccountObjectsRequest}.
|
* Response expected from an {@link AccountObjectsRequest}.
|
||||||
|
|||||||
147
packages/xrpl/src/models/methods/ammInfo.ts
Normal file
147
packages/xrpl/src/models/methods/ammInfo.ts
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
import { Amount, Currency, IssuedCurrencyAmount } from '../common'
|
||||||
|
|
||||||
|
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `amm_info` command retrieves information about an AMM instance.
|
||||||
|
* Returns an {@link AMMInfoResponse}.
|
||||||
|
*
|
||||||
|
* @category Requests
|
||||||
|
*/
|
||||||
|
export interface AMMInfoRequest extends BaseRequest {
|
||||||
|
command: 'amm_info'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies one of the pool assets (XRP or token) of the AMM instance.
|
||||||
|
* Both asset and asset2 must be defined to specify an AMM instance.
|
||||||
|
*/
|
||||||
|
asset: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the other pool asset of the AMM instance.
|
||||||
|
* Both asset and asset2 must be defined to specify an AMM instance.
|
||||||
|
*/
|
||||||
|
asset2: Currency
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AuthAccount {
|
||||||
|
account: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VoteEntry {
|
||||||
|
account: string
|
||||||
|
trading_fee: number
|
||||||
|
vote_weight: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response expected from an {@link AMMInfoRequest}.
|
||||||
|
*
|
||||||
|
* @category Responses
|
||||||
|
*/
|
||||||
|
export interface AMMInfoResponse extends BaseResponse {
|
||||||
|
result: {
|
||||||
|
amm: {
|
||||||
|
/**
|
||||||
|
* The account that tracks the balance of LPTokens between the AMM instance via Trustline.
|
||||||
|
*/
|
||||||
|
amm_account: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One of the pool assets (XRP or token) of the AMM instance.
|
||||||
|
*/
|
||||||
|
amount: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The other pool asset of the AMM instance.
|
||||||
|
*/
|
||||||
|
amount2: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Omitted for XRP) If true, the amount currency is currently frozen for asset.
|
||||||
|
*/
|
||||||
|
asset_frozen: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Omitted for XRP) If true, the amount currency is currently frozen for asset2.
|
||||||
|
*/
|
||||||
|
asset2_frozen: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Details of the current owner of the auction slot.
|
||||||
|
*/
|
||||||
|
auction_slot?: {
|
||||||
|
/**
|
||||||
|
* The current owner of this auction slot.
|
||||||
|
*/
|
||||||
|
account: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of at most 4 additional accounts that are authorized to trade at the discounted fee for this AMM instance.
|
||||||
|
*/
|
||||||
|
auth_accounts: AuthAccount[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The trading fee to be charged to the auction owner, in the same format as TradingFee.
|
||||||
|
* By default this is 0, meaning that the auction owner can trade at no fee instead of the standard fee for this AMM.
|
||||||
|
*/
|
||||||
|
discounted_fee: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time when this slot expires, in seconds since the Ripple Epoch.
|
||||||
|
*/
|
||||||
|
expiration: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount the auction owner paid to win this slot, in LPTokens.
|
||||||
|
*/
|
||||||
|
price: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total slot time of 24-hours is divided into 20 equal time intervals.
|
||||||
|
*/
|
||||||
|
time_interval: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The total outstanding balance of liquidity provider tokens from this AMM instance.
|
||||||
|
* The holders of these tokens can vote on the AMM's trading fee in proportion to their holdings,
|
||||||
|
* or redeem the tokens for a share of the AMM's assets which grows with the trading fees collected.
|
||||||
|
*/
|
||||||
|
lp_token: IssuedCurrencyAmount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the fee, in basis point, to be charged to the traders for the trades
|
||||||
|
* executed against the AMM instance. Trading fee is a percentage of the trading volume.
|
||||||
|
* Valid values for this field are between 0 and 1000 inclusive.
|
||||||
|
* A value of 1 is equivalent to 1/10 bps or 0.001%, allowing trading fee
|
||||||
|
* between 0% and 1%. This field is required.
|
||||||
|
*/
|
||||||
|
trading_fee: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps a track of up to eight active votes for the instance.
|
||||||
|
*/
|
||||||
|
vote_slots?: VoteEntry[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifying hash of the ledger that was used to generate this
|
||||||
|
* response.
|
||||||
|
*/
|
||||||
|
ledger_hash?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ledger index of the ledger version that was used to generate this
|
||||||
|
* response.
|
||||||
|
*/
|
||||||
|
ledger_index?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If included and set to true, the information in this response comes from
|
||||||
|
* a validated ledger version. Otherwise, the information is subject to
|
||||||
|
* change.
|
||||||
|
*/
|
||||||
|
validated?: boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ import { BaseRequest, BaseResponse } from './baseMethod'
|
|||||||
*/
|
*/
|
||||||
export interface ChannelVerifyRequest extends BaseRequest {
|
export interface ChannelVerifyRequest extends BaseRequest {
|
||||||
command: 'channel_verify'
|
command: 'channel_verify'
|
||||||
/** The amount the provided signature authorizes. */
|
/** The amount of XRP, in drops, the provided signature authorizes. */
|
||||||
amount: string
|
amount: string
|
||||||
/**
|
/**
|
||||||
* The Channel ID of the channel that provides the XRP. This is a
|
* The Channel ID of the channel that provides the XRP. This is a
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
AccountOffersResponse,
|
AccountOffersResponse,
|
||||||
} from './accountOffers'
|
} from './accountOffers'
|
||||||
import { AccountTxRequest, AccountTxResponse } from './accountTx'
|
import { AccountTxRequest, AccountTxResponse } from './accountTx'
|
||||||
|
import { AMMInfoRequest, AMMInfoResponse } from './ammInfo'
|
||||||
import { ErrorResponse } from './baseMethod'
|
import { ErrorResponse } from './baseMethod'
|
||||||
import { BookOffersRequest, BookOffer, BookOffersResponse } from './bookOffers'
|
import { BookOffersRequest, BookOffer, BookOffersResponse } from './bookOffers'
|
||||||
import { ChannelVerifyRequest, ChannelVerifyResponse } from './channelVerify'
|
import { ChannelVerifyRequest, ChannelVerifyResponse } from './channelVerify'
|
||||||
@@ -87,6 +88,7 @@ type Request =
|
|||||||
| AccountObjectsRequest
|
| AccountObjectsRequest
|
||||||
| AccountOffersRequest
|
| AccountOffersRequest
|
||||||
| AccountTxRequest
|
| AccountTxRequest
|
||||||
|
| AMMInfoRequest
|
||||||
| GatewayBalancesRequest
|
| GatewayBalancesRequest
|
||||||
| NoRippleCheckRequest
|
| NoRippleCheckRequest
|
||||||
// ledger methods
|
// ledger methods
|
||||||
@@ -137,6 +139,7 @@ type Response =
|
|||||||
| AccountObjectsResponse
|
| AccountObjectsResponse
|
||||||
| AccountOffersResponse
|
| AccountOffersResponse
|
||||||
| AccountTxResponse
|
| AccountTxResponse
|
||||||
|
| AMMInfoResponse
|
||||||
| GatewayBalancesResponse
|
| GatewayBalancesResponse
|
||||||
| NoRippleCheckResponse
|
| NoRippleCheckResponse
|
||||||
// ledger methods
|
// ledger methods
|
||||||
@@ -195,6 +198,8 @@ export {
|
|||||||
AccountOffersResponse,
|
AccountOffersResponse,
|
||||||
AccountTxRequest,
|
AccountTxRequest,
|
||||||
AccountTxResponse,
|
AccountTxResponse,
|
||||||
|
AMMInfoRequest,
|
||||||
|
AMMInfoResponse,
|
||||||
GatewayBalancesRequest,
|
GatewayBalancesRequest,
|
||||||
GatewayBalancesResponse,
|
GatewayBalancesResponse,
|
||||||
NoRippleCheckRequest,
|
NoRippleCheckRequest,
|
||||||
|
|||||||
@@ -79,11 +79,6 @@ export interface LedgerEntryRequest extends BaseRequest {
|
|||||||
}
|
}
|
||||||
| string
|
| string
|
||||||
|
|
||||||
/**
|
|
||||||
* The object ID of a transaction emitted by the ledger entry.
|
|
||||||
*/
|
|
||||||
emitted_txn?: string
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Escrow object to retrieve. If a string, must be the object ID of the
|
* The Escrow object to retrieve. If a string, must be the object ID of the
|
||||||
* escrow, as hexadecimal. If an object, requires owner and seq sub-fields.
|
* escrow, as hexadecimal. If an object, requires owner and seq sub-fields.
|
||||||
@@ -97,47 +92,6 @@ export interface LedgerEntryRequest extends BaseRequest {
|
|||||||
}
|
}
|
||||||
| string
|
| string
|
||||||
|
|
||||||
/**
|
|
||||||
* The hash of the Hook object to retrieve.
|
|
||||||
*/
|
|
||||||
hook_definition?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Hook object to retrieve. If a string, must be the object ID of the Hook.
|
|
||||||
* If an object, requires `account` sub-field.
|
|
||||||
*/
|
|
||||||
hook?:
|
|
||||||
| {
|
|
||||||
/** The account of the Hook object. */
|
|
||||||
account: string
|
|
||||||
}
|
|
||||||
| string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Object specifying the HookState object to retrieve. Requires the sub-fields
|
|
||||||
* `account`, `key`, and `namespace_id` to uniquely specify the HookState entry
|
|
||||||
* to retrieve.
|
|
||||||
*/
|
|
||||||
hook_state?: {
|
|
||||||
/** The account of the Hook object. */
|
|
||||||
account: string
|
|
||||||
/** The key of the state. */
|
|
||||||
key: string
|
|
||||||
/** The namespace of the state. */
|
|
||||||
namespace_id: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Import VL Sequence object to retrieve. If a string, must be the object ID of the VLSequence.
|
|
||||||
* If an object, requires `public_key` sub-field.
|
|
||||||
*/
|
|
||||||
import_vlseq?:
|
|
||||||
| {
|
|
||||||
/** The public_key of the Import VL Sequence object. */
|
|
||||||
public_key: string
|
|
||||||
}
|
|
||||||
| string
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Offer object to retrieve. If a string, interpret as the unique object
|
* The Offer object to retrieve. If a string, interpret as the unique object
|
||||||
* ID to the Offer. If an object, requires the sub-fields `account` and `seq`
|
* ID to the Offer. If an object, requires the sub-fields `account` and `seq`
|
||||||
@@ -183,20 +137,40 @@ export interface LedgerEntryRequest extends BaseRequest {
|
|||||||
ticket_sequence: number
|
ticket_sequence: number
|
||||||
}
|
}
|
||||||
| string
|
| string
|
||||||
|
/**
|
||||||
|
* The object ID of a transaction emitted by the ledger entry.
|
||||||
|
*/
|
||||||
|
emitted_txn?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URIToken object to retrieve. If a string, must be the object ID of the
|
* The hash of the Hook object to retrieve.
|
||||||
* URIToken, as hexadecimal. If an object, the `issuer` and `uri`
|
|
||||||
* sub-fields are required to uniquely specify the URIToken entry.
|
|
||||||
*/
|
*/
|
||||||
uri_token?:
|
hook_definition?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Hook object to retrieve. If a string, must be the object ID of the Hook.
|
||||||
|
* If an object, requires `account` sub-field.
|
||||||
|
*/
|
||||||
|
hook?:
|
||||||
| {
|
| {
|
||||||
/** The issuer of the URIToken object. */
|
/** The account of the Hook object. */
|
||||||
issuer: string
|
account: string
|
||||||
/** The URIToken uri string (ascii). */
|
|
||||||
uri: string
|
|
||||||
}
|
}
|
||||||
| string
|
| string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object specifying the HookState object to retrieve. Requires the sub-fields
|
||||||
|
* `account`, `key`, and `namespace_id` to uniquely specify the HookState entry
|
||||||
|
* to retrieve.
|
||||||
|
*/
|
||||||
|
hook_state?: {
|
||||||
|
/** The account of the Hook object. */
|
||||||
|
account: string
|
||||||
|
/** The key of the state. */
|
||||||
|
key: string
|
||||||
|
/** The namespace of the state. */
|
||||||
|
namespace_id: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
106
packages/xrpl/src/models/transactions/AMMBid.ts
Normal file
106
packages/xrpl/src/models/transactions/AMMBid.ts
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/* eslint-disable complexity -- required for validateAMMBid */
|
||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
import { Amount, Currency } from '../common'
|
||||||
|
|
||||||
|
import {
|
||||||
|
BaseTransaction,
|
||||||
|
isAmount,
|
||||||
|
isCurrency,
|
||||||
|
validateBaseTransaction,
|
||||||
|
} from './common'
|
||||||
|
|
||||||
|
const MAX_AUTH_ACCOUNTS = 4
|
||||||
|
|
||||||
|
interface AuthAccount {
|
||||||
|
AuthAccount: {
|
||||||
|
Account: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMBid is used for submitting a vote for the trading fee of an AMM Instance.
|
||||||
|
*
|
||||||
|
* Any XRPL account that holds LPToken for an AMM instance may submit this
|
||||||
|
* transaction to vote for the trading fee for that instance.
|
||||||
|
*/
|
||||||
|
export interface AMMBid extends BaseTransaction {
|
||||||
|
TransactionType: 'AMMBid'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies one of the pool assets (XRP or token) of the AMM instance.
|
||||||
|
*/
|
||||||
|
Asset: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the other pool asset of the AMM instance.
|
||||||
|
*/
|
||||||
|
Asset2: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This field represents the minimum price that the bidder wants to pay for the slot.
|
||||||
|
* It is specified in units of LPToken. If specified let BidMin be X and let
|
||||||
|
* the slot-price computed by price scheduling algorithm be Y, then bidder always pays
|
||||||
|
* the max(X, Y).
|
||||||
|
*/
|
||||||
|
BidMin?: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This field represents the maximum price that the bidder wants to pay for the slot.
|
||||||
|
* It is specified in units of LPToken.
|
||||||
|
*/
|
||||||
|
BidMax?: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This field represents an array of XRPL account IDs that are authorized to trade
|
||||||
|
* at the discounted fee against the AMM instance.
|
||||||
|
* A maximum of four accounts can be provided.
|
||||||
|
*/
|
||||||
|
AuthAccounts?: AuthAccount[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an AMMBid at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An AMMBid Transaction.
|
||||||
|
* @throws When the AMMBid is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateAMMBid(tx: Record<string, unknown>): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.Asset == null) {
|
||||||
|
throw new ValidationError('AMMBid: missing field Asset')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCurrency(tx.Asset)) {
|
||||||
|
throw new ValidationError('AMMBid: Asset must be an Issue')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Asset2 == null) {
|
||||||
|
throw new ValidationError('AMMBid: missing field Asset2')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCurrency(tx.Asset2)) {
|
||||||
|
throw new ValidationError('AMMBid: Asset2 must be an Issue')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.BidMin != null && !isAmount(tx.BidMin)) {
|
||||||
|
throw new ValidationError('AMMBid: BidMin must be an Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.BidMax != null && !isAmount(tx.BidMax)) {
|
||||||
|
throw new ValidationError('AMMBid: BidMax must be an Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.AuthAccounts != null) {
|
||||||
|
if (!Array.isArray(tx.AuthAccounts)) {
|
||||||
|
throw new ValidationError(
|
||||||
|
`AMMBid: AuthAccounts must be an AuthAccount array`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (tx.AuthAccounts.length > MAX_AUTH_ACCOUNTS) {
|
||||||
|
throw new ValidationError(
|
||||||
|
`AMMBid: AuthAccounts length must not be greater than ${MAX_AUTH_ACCOUNTS}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
76
packages/xrpl/src/models/transactions/AMMCreate.ts
Normal file
76
packages/xrpl/src/models/transactions/AMMCreate.ts
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
import { Amount } from '../common'
|
||||||
|
|
||||||
|
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
export const AMM_MAX_TRADING_FEE = 1000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMCreate is used to create AccountRoot and the corresponding
|
||||||
|
* AMM ledger entries.
|
||||||
|
*
|
||||||
|
* This allows for the creation of only one AMM instance per unique asset pair.
|
||||||
|
*/
|
||||||
|
export interface AMMCreate extends BaseTransaction {
|
||||||
|
TransactionType: 'AMMCreate'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies one of the pool assets (XRP or token) of the AMM instance.
|
||||||
|
*/
|
||||||
|
Amount: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the other pool asset of the AMM instance.
|
||||||
|
*/
|
||||||
|
Amount2: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the fee, in basis point, to be charged
|
||||||
|
* to the traders for the trades executed against the AMM instance.
|
||||||
|
* Trading fee is a percentage of the trading volume.
|
||||||
|
* Valid values for this field are between 0 and 1000 inclusive.
|
||||||
|
* A value of 1 is equivalent to 1/10 bps or 0.001%, allowing trading fee
|
||||||
|
* between 0% and 1%.
|
||||||
|
*/
|
||||||
|
TradingFee: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an AMMCreate at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An AMMCreate Transaction.
|
||||||
|
* @throws When the AMMCreate is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateAMMCreate(tx: Record<string, unknown>): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.Amount == null) {
|
||||||
|
throw new ValidationError('AMMCreate: missing field Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAmount(tx.Amount)) {
|
||||||
|
throw new ValidationError('AMMCreate: Amount must be an Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Amount2 == null) {
|
||||||
|
throw new ValidationError('AMMCreate: missing field Amount2')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAmount(tx.Amount2)) {
|
||||||
|
throw new ValidationError('AMMCreate: Amount2 must be an Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.TradingFee == null) {
|
||||||
|
throw new ValidationError('AMMCreate: missing field TradingFee')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof tx.TradingFee !== 'number') {
|
||||||
|
throw new ValidationError('AMMCreate: TradingFee must be a number')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.TradingFee < 0 || tx.TradingFee > AMM_MAX_TRADING_FEE) {
|
||||||
|
throw new ValidationError(
|
||||||
|
`AMMCreate: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
135
packages/xrpl/src/models/transactions/AMMDeposit.ts
Normal file
135
packages/xrpl/src/models/transactions/AMMDeposit.ts
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/* eslint-disable complexity -- required for validateAMMDeposit */
|
||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
import { Amount, Currency, IssuedCurrencyAmount } from '../common'
|
||||||
|
|
||||||
|
import {
|
||||||
|
BaseTransaction,
|
||||||
|
GlobalFlags,
|
||||||
|
isAmount,
|
||||||
|
isCurrency,
|
||||||
|
isIssuedCurrency,
|
||||||
|
validateBaseTransaction,
|
||||||
|
} from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum representing values for AMMDeposit Transaction Flags.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*/
|
||||||
|
export enum AMMDepositFlags {
|
||||||
|
tfLPToken = 0x00010000,
|
||||||
|
tfSingleAsset = 0x00080000,
|
||||||
|
tfTwoAsset = 0x00100000,
|
||||||
|
tfOneAssetLPToken = 0x00200000,
|
||||||
|
tfLimitLPToken = 0x00400000,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AMMDepositFlagsInterface extends GlobalFlags {
|
||||||
|
tfLPToken?: boolean
|
||||||
|
tfSingleAsset?: boolean
|
||||||
|
tfTwoAsset?: boolean
|
||||||
|
tfOneAssetLPToken?: boolean
|
||||||
|
tfLimitLPToken?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMDeposit is the deposit transaction used to add liquidity to the AMM instance pool,
|
||||||
|
* thus obtaining some share of the instance's pools in the form of LPTokenOut.
|
||||||
|
*
|
||||||
|
* The following are the recommended valid combinations:
|
||||||
|
* - LPTokenOut
|
||||||
|
* - Amount
|
||||||
|
* - Amount and Amount2
|
||||||
|
* - Amount and LPTokenOut
|
||||||
|
* - Amount and EPrice
|
||||||
|
*/
|
||||||
|
export interface AMMDeposit extends BaseTransaction {
|
||||||
|
TransactionType: 'AMMDeposit'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies one of the pool assets (XRP or token) of the AMM instance.
|
||||||
|
*/
|
||||||
|
Asset: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the other pool asset of the AMM instance.
|
||||||
|
*/
|
||||||
|
Asset2: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the amount of shares of the AMM instance pools that the trader
|
||||||
|
* wants to redeem or trade in.
|
||||||
|
*/
|
||||||
|
LPTokenOut?: IssuedCurrencyAmount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies one of the pool assets (XRP or token) of the AMM instance to
|
||||||
|
* deposit more of its value.
|
||||||
|
*/
|
||||||
|
Amount?: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the other pool asset of the AMM instance to deposit more of
|
||||||
|
* its value.
|
||||||
|
*/
|
||||||
|
Amount2?: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the maximum effective-price that LPTokenOut can be traded out.
|
||||||
|
*/
|
||||||
|
EPrice?: Amount
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an AMMDeposit at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An AMMDeposit Transaction.
|
||||||
|
* @throws When the AMMDeposit is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateAMMDeposit(tx: Record<string, unknown>): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.Asset == null) {
|
||||||
|
throw new ValidationError('AMMDeposit: missing field Asset')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCurrency(tx.Asset)) {
|
||||||
|
throw new ValidationError('AMMDeposit: Asset must be an Issue')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Asset2 == null) {
|
||||||
|
throw new ValidationError('AMMDeposit: missing field Asset2')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCurrency(tx.Asset2)) {
|
||||||
|
throw new ValidationError('AMMDeposit: Asset2 must be an Issue')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Amount2 != null && tx.Amount == null) {
|
||||||
|
throw new ValidationError('AMMDeposit: must set Amount with Amount2')
|
||||||
|
} else if (tx.EPrice != null && tx.Amount == null) {
|
||||||
|
throw new ValidationError('AMMDeposit: must set Amount with EPrice')
|
||||||
|
} else if (tx.LPTokenOut == null && tx.Amount == null) {
|
||||||
|
throw new ValidationError(
|
||||||
|
'AMMDeposit: must set at least LPTokenOut or Amount',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.LPTokenOut != null && !isIssuedCurrency(tx.LPTokenOut)) {
|
||||||
|
throw new ValidationError(
|
||||||
|
'AMMDeposit: LPTokenOut must be an IssuedCurrencyAmount',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Amount != null && !isAmount(tx.Amount)) {
|
||||||
|
throw new ValidationError('AMMDeposit: Amount must be an Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Amount2 != null && !isAmount(tx.Amount2)) {
|
||||||
|
throw new ValidationError('AMMDeposit: Amount2 must be an Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.EPrice != null && !isAmount(tx.EPrice)) {
|
||||||
|
throw new ValidationError('AMMDeposit: EPrice must be an Amount')
|
||||||
|
}
|
||||||
|
}
|
||||||
73
packages/xrpl/src/models/transactions/AMMVote.ts
Normal file
73
packages/xrpl/src/models/transactions/AMMVote.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
import { Currency } from '../common'
|
||||||
|
|
||||||
|
import { AMM_MAX_TRADING_FEE } from './AMMCreate'
|
||||||
|
import { BaseTransaction, isCurrency, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMVote is used for submitting a vote for the trading fee of an AMM Instance.
|
||||||
|
*
|
||||||
|
* Any XRPL account that holds LPToken for an AMM instance may submit this
|
||||||
|
* transaction to vote for the trading fee for that instance.
|
||||||
|
*/
|
||||||
|
export interface AMMVote extends BaseTransaction {
|
||||||
|
TransactionType: 'AMMVote'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies one of the pool assets (XRP or token) of the AMM instance.
|
||||||
|
*/
|
||||||
|
Asset: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the other pool asset of the AMM instance.
|
||||||
|
*/
|
||||||
|
Asset2: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the fee, in basis point.
|
||||||
|
* Valid values for this field are between 0 and 1000 inclusive.
|
||||||
|
* A value of 1 is equivalent to 1/10 bps or 0.001%, allowing trading fee
|
||||||
|
* between 0% and 1%. This field is required.
|
||||||
|
*/
|
||||||
|
TradingFee: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an AMMVote at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An AMMVote Transaction.
|
||||||
|
* @throws When the AMMVote is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateAMMVote(tx: Record<string, unknown>): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.Asset == null) {
|
||||||
|
throw new ValidationError('AMMVote: missing field Asset')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCurrency(tx.Asset)) {
|
||||||
|
throw new ValidationError('AMMVote: Asset must be an Issue')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Asset2 == null) {
|
||||||
|
throw new ValidationError('AMMVote: missing field Asset2')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCurrency(tx.Asset2)) {
|
||||||
|
throw new ValidationError('AMMVote: Asset2 must be an Issue')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.TradingFee == null) {
|
||||||
|
throw new ValidationError('AMMVote: missing field TradingFee')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof tx.TradingFee !== 'number') {
|
||||||
|
throw new ValidationError('AMMVote: TradingFee must be a number')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.TradingFee < 0 || tx.TradingFee > AMM_MAX_TRADING_FEE) {
|
||||||
|
throw new ValidationError(
|
||||||
|
`AMMVote: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
137
packages/xrpl/src/models/transactions/AMMWithdraw.ts
Normal file
137
packages/xrpl/src/models/transactions/AMMWithdraw.ts
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
/* eslint-disable complexity -- required for validateAMMWithdraw */
|
||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
import { Amount, Currency, IssuedCurrencyAmount } from '../common'
|
||||||
|
|
||||||
|
import {
|
||||||
|
BaseTransaction,
|
||||||
|
GlobalFlags,
|
||||||
|
isAmount,
|
||||||
|
isCurrency,
|
||||||
|
isIssuedCurrency,
|
||||||
|
validateBaseTransaction,
|
||||||
|
} from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum representing values for AMMWithdrawFlags Transaction Flags.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*/
|
||||||
|
export enum AMMWithdrawFlags {
|
||||||
|
tfLPToken = 0x00010000,
|
||||||
|
tfWithdrawAll = 0x00020000,
|
||||||
|
tfOneAssetWithdrawAll = 0x00040000,
|
||||||
|
tfSingleAsset = 0x00080000,
|
||||||
|
tfTwoAsset = 0x00100000,
|
||||||
|
tfOneAssetLPToken = 0x00200000,
|
||||||
|
tfLimitLPToken = 0x00400000,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AMMWithdrawFlagsInterface extends GlobalFlags {
|
||||||
|
tfLPToken?: boolean
|
||||||
|
tfWithdrawAll?: boolean
|
||||||
|
tfOneAssetWithdrawAll?: boolean
|
||||||
|
tfSingleAsset?: boolean
|
||||||
|
tfTwoAsset?: boolean
|
||||||
|
tfOneAssetLPToken?: boolean
|
||||||
|
tfLimitLPToken?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMWithdraw is the withdraw transaction used to remove liquidity from the AMM
|
||||||
|
* instance pool, thus redeeming some share of the pools that one owns in the form
|
||||||
|
* of LPTokenIn.
|
||||||
|
*
|
||||||
|
* The following are the recommended valid combinations:
|
||||||
|
* - LPTokenIn
|
||||||
|
* - Amount
|
||||||
|
* - Amount and Amount2
|
||||||
|
* - Amount and LPTokenIn
|
||||||
|
* - Amount and EPrice
|
||||||
|
*/
|
||||||
|
export interface AMMWithdraw extends BaseTransaction {
|
||||||
|
TransactionType: 'AMMWithdraw'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies one of the pool assets (XRP or token) of the AMM instance.
|
||||||
|
*/
|
||||||
|
Asset: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the other pool asset of the AMM instance.
|
||||||
|
*/
|
||||||
|
Asset2: Currency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the amount of shares of the AMM instance pools that the trader
|
||||||
|
* wants to redeem or trade in.
|
||||||
|
*/
|
||||||
|
LPTokenIn?: IssuedCurrencyAmount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies one of the pools assets that the trader wants to remove.
|
||||||
|
* If the asset is XRP, then the Amount is a string specifying the number of drops.
|
||||||
|
* Otherwise it is an IssuedCurrencyAmount object.
|
||||||
|
*/
|
||||||
|
Amount?: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the other pool asset that the trader wants to remove.
|
||||||
|
*/
|
||||||
|
Amount2?: Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the effective-price of the token out after successful execution of
|
||||||
|
* the transaction.
|
||||||
|
*/
|
||||||
|
EPrice?: Amount
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an AMMWithdraw at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An AMMWithdraw Transaction.
|
||||||
|
* @throws When the AMMWithdraw is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateAMMWithdraw(tx: Record<string, unknown>): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.Asset == null) {
|
||||||
|
throw new ValidationError('AMMWithdraw: missing field Asset')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCurrency(tx.Asset)) {
|
||||||
|
throw new ValidationError('AMMWithdraw: Asset must be an Issue')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Asset2 == null) {
|
||||||
|
throw new ValidationError('AMMWithdraw: missing field Asset2')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCurrency(tx.Asset2)) {
|
||||||
|
throw new ValidationError('AMMWithdraw: Asset2 must be an Issue')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Amount2 != null && tx.Amount == null) {
|
||||||
|
throw new ValidationError('AMMWithdraw: must set Amount with Amount2')
|
||||||
|
} else if (tx.EPrice != null && tx.Amount == null) {
|
||||||
|
throw new ValidationError('AMMWithdraw: must set Amount with EPrice')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.LPTokenIn != null && !isIssuedCurrency(tx.LPTokenIn)) {
|
||||||
|
throw new ValidationError(
|
||||||
|
'AMMWithdraw: LPTokenIn must be an IssuedCurrencyAmount',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Amount != null && !isAmount(tx.Amount)) {
|
||||||
|
throw new ValidationError('AMMWithdraw: Amount must be an Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.Amount2 != null && !isAmount(tx.Amount2)) {
|
||||||
|
throw new ValidationError('AMMWithdraw: Amount2 must be an Amount')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.EPrice != null && !isAmount(tx.EPrice)) {
|
||||||
|
throw new ValidationError('AMMWithdraw: EPrice must be an Amount')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable complexity -- Necessary for validateAccountSet */
|
/* eslint-disable complexity -- Necessary for validateAccountSet */
|
||||||
|
|
||||||
import { isValidClassicAddress } from '@transia/ripple-address-codec'
|
import { isValidClassicAddress } from 'ripple-address-codec'
|
||||||
|
|
||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
|
|
||||||
@@ -48,7 +48,6 @@ export enum AccountSetAsfFlags {
|
|||||||
*/
|
*/
|
||||||
asfAuthorizedNFTokenMinter = 10,
|
asfAuthorizedNFTokenMinter = 10,
|
||||||
/** asf 11 is reserved for Hooks amendment */
|
/** asf 11 is reserved for Hooks amendment */
|
||||||
asfTshCollect = 11,
|
|
||||||
/** Disallow other accounts from creating incoming NFTOffers */
|
/** Disallow other accounts from creating incoming NFTOffers */
|
||||||
asfDisallowIncomingNFTokenOffer = 12,
|
asfDisallowIncomingNFTokenOffer = 12,
|
||||||
/** Disallow other accounts from creating incoming Checks */
|
/** Disallow other accounts from creating incoming Checks */
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import { ValidationError } from '../../errors'
|
|
||||||
|
|
||||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClaimReward is a transaction model that allows an account to claim rewards.
|
|
||||||
*
|
|
||||||
* @category Transaction Models
|
|
||||||
*/
|
|
||||||
export interface ClaimReward extends BaseTransaction {
|
|
||||||
TransactionType: 'ClaimReward'
|
|
||||||
/** The unique address of the issuer where the reward.c hook is installed. */
|
|
||||||
Issuer?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify the form and type of an ClaimReward at runtime.
|
|
||||||
*
|
|
||||||
* @param tx - An ClaimReward Transaction.
|
|
||||||
* @throws When the ClaimReward is Malformed.
|
|
||||||
*/
|
|
||||||
export function validateClaimReward(tx: Record<string, unknown>): void {
|
|
||||||
validateBaseTransaction(tx)
|
|
||||||
|
|
||||||
if (tx.Issuer !== undefined && typeof tx.Issuer !== 'string') {
|
|
||||||
throw new ValidationError('ClaimReward: invalid Issuer')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,10 @@
|
|||||||
/* eslint-disable max-lines-per-function -- Necessary for validateBaseTransaction */
|
/* eslint-disable max-lines-per-function -- Necessary for validateBaseTransaction */
|
||||||
/* eslint-disable complexity -- Necessary for validateBaseTransaction */
|
/* eslint-disable complexity -- Necessary for validateBaseTransaction */
|
||||||
/* eslint-disable max-statements -- Necessary for validateBaseTransaction */
|
/* eslint-disable max-statements -- Necessary for validateBaseTransaction */
|
||||||
import { TRANSACTION_TYPES } from '@transia/ripple-binary-codec'
|
import { TRANSACTION_TYPES } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import {
|
import { Amount, Currency, IssuedCurrencyAmount, Memo, Signer } from '../common'
|
||||||
Amount,
|
|
||||||
HookParameter,
|
|
||||||
IssuedCurrencyAmount,
|
|
||||||
Memo,
|
|
||||||
Signer,
|
|
||||||
EmitDetails,
|
|
||||||
} from '../common'
|
|
||||||
import { onlyHasFields } from '../utils'
|
import { onlyHasFields } from '../utils'
|
||||||
|
|
||||||
const MEMO_SIZE = 3
|
const MEMO_SIZE = 3
|
||||||
@@ -57,17 +50,36 @@ function isSigner(obj: unknown): boolean {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const XRP_CURRENCY_SIZE = 1
|
||||||
|
const ISSUE_SIZE = 2
|
||||||
const ISSUED_CURRENCY_SIZE = 3
|
const ISSUED_CURRENCY_SIZE = 3
|
||||||
|
|
||||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||||
return value !== null && typeof value === 'object'
|
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 isCurrency(input: unknown): input is Currency {
|
||||||
|
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.
|
* Verify the form and type of an IssuedCurrencyAmount at runtime.
|
||||||
*
|
*
|
||||||
* @param input - The input to check the form and type of.
|
* @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(
|
export function isIssuedCurrency(
|
||||||
input: unknown,
|
input: unknown,
|
||||||
@@ -85,7 +97,7 @@ export function isIssuedCurrency(
|
|||||||
* Verify the form and type of an Amount at runtime.
|
* Verify the form and type of an Amount at runtime.
|
||||||
*
|
*
|
||||||
* @param amount - The object to check the form and type of.
|
* @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 {
|
export function isAmount(amount: unknown): amount is Amount {
|
||||||
return typeof amount === 'string' || isIssuedCurrency(amount)
|
return typeof amount === 'string' || isIssuedCurrency(amount)
|
||||||
@@ -166,18 +178,7 @@ export interface BaseTransaction {
|
|||||||
* account it says it is from.
|
* account it says it is from.
|
||||||
*/
|
*/
|
||||||
TxnSignature?: string
|
TxnSignature?: string
|
||||||
/**
|
|
||||||
* The network id of the transaction.
|
|
||||||
*/
|
|
||||||
NetworkID?: number
|
NetworkID?: number
|
||||||
/**
|
|
||||||
* The hook parameters of the transaction.
|
|
||||||
*/
|
|
||||||
HookParameters?: HookParameter[]
|
|
||||||
/**
|
|
||||||
* The hook parameters of the transaction.
|
|
||||||
*/
|
|
||||||
EmitDetails?: EmitDetails
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { ValidationError } from '../../errors'
|
|||||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return escrowed amount to the sender.
|
* Return escrowed XRP to the sender.
|
||||||
*
|
*
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
/* eslint-disable complexity -- Necessary for validateEscrowCreate */
|
/* eslint-disable complexity -- Necessary for validateEscrowCreate */
|
||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import { Amount } from '../common'
|
|
||||||
|
|
||||||
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sequester amount until the escrow process either finishes or is canceled.
|
* Sequester XRP until the escrow process either finishes or is canceled.
|
||||||
*
|
*
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
*/
|
*/
|
||||||
export interface EscrowCreate extends BaseTransaction {
|
export interface EscrowCreate extends BaseTransaction {
|
||||||
TransactionType: 'EscrowCreate'
|
TransactionType: 'EscrowCreate'
|
||||||
/**
|
/**
|
||||||
* Amount to deduct from the sender's balance and escrow. Once escrowed, the
|
* Amount of XRP, in drops, to deduct from the sender's balance and escrow.
|
||||||
* amount can either go to the Destination address (after the FinishAfter time)
|
* Once escrowed, the XRP can either go to the Destination address (after the.
|
||||||
* or returned to the sender (after the CancelAfter time).
|
* FinishAfter time) or returned to the sender (after the CancelAfter time).
|
||||||
*/
|
*/
|
||||||
Amount: Amount
|
Amount: string
|
||||||
/** Address to receive escrowed amount. */
|
/** Address to receive escrowed XRP. */
|
||||||
Destination: string
|
Destination: string
|
||||||
/**
|
/**
|
||||||
* The time, in seconds since the Ripple Epoch, when this escrow expires.
|
* The time, in seconds since the Ripple Epoch, when this escrow expires.
|
||||||
@@ -26,7 +25,7 @@ export interface EscrowCreate extends BaseTransaction {
|
|||||||
*/
|
*/
|
||||||
CancelAfter?: number
|
CancelAfter?: number
|
||||||
/**
|
/**
|
||||||
* The time, in seconds since the Ripple Epoch, when the escrowed amount can be
|
* The time, in seconds since the Ripple Epoch, when the escrowed XRP can be
|
||||||
* released to the recipient. This value is immutable; the funds cannot move.
|
* released to the recipient. This value is immutable; the funds cannot move.
|
||||||
* until this time is reached.
|
* until this time is reached.
|
||||||
*/
|
*/
|
||||||
@@ -56,8 +55,8 @@ export function validateEscrowCreate(tx: Record<string, unknown>): void {
|
|||||||
throw new ValidationError('EscrowCreate: missing field Amount')
|
throw new ValidationError('EscrowCreate: missing field Amount')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
|
if (typeof tx.Amount !== 'string') {
|
||||||
throw new ValidationError('EscrowCreate: Amount must be an Amount')
|
throw new ValidationError('EscrowCreate: Amount must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.Destination === undefined) {
|
if (tx.Destination === undefined) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { ValidationError } from '../../errors'
|
|||||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deliver amount from a held payment to the recipient.
|
* Deliver XRP from a held payment to the recipient.
|
||||||
*
|
*
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import { ValidationError } from '../../errors'
|
|
||||||
|
|
||||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @category Transaction Models
|
|
||||||
*/
|
|
||||||
export interface Import extends BaseTransaction {
|
|
||||||
TransactionType: 'Import'
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
Issuer?: string
|
|
||||||
/**
|
|
||||||
* Hex value representing a VL Blob.
|
|
||||||
*/
|
|
||||||
Blob?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify the form and type of an Import at runtime.
|
|
||||||
*
|
|
||||||
* @param tx - An Import Transaction.
|
|
||||||
* @throws When the Import is Malformed.
|
|
||||||
*/
|
|
||||||
export function validateImport(tx: Record<string, unknown>): void {
|
|
||||||
validateBaseTransaction(tx)
|
|
||||||
|
|
||||||
if (tx.Issuer !== undefined && typeof tx.Issuer !== 'string') {
|
|
||||||
throw new ValidationError('Import: Issuer must be a string')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tx.Account === tx.Issuer) {
|
|
||||||
throw new ValidationError('Import: Issuer and Account must not be equal')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,15 +7,26 @@ export {
|
|||||||
AccountSet,
|
AccountSet,
|
||||||
} from './accountSet'
|
} from './accountSet'
|
||||||
export { AccountDelete } from './accountDelete'
|
export { AccountDelete } from './accountDelete'
|
||||||
|
export { AMMBid } from './AMMBid'
|
||||||
|
export {
|
||||||
|
AMMDepositFlags,
|
||||||
|
AMMDepositFlagsInterface,
|
||||||
|
AMMDeposit,
|
||||||
|
} from './AMMDeposit'
|
||||||
|
export { AMMCreate } from './AMMCreate'
|
||||||
|
export { AMMVote } from './AMMVote'
|
||||||
|
export {
|
||||||
|
AMMWithdrawFlags,
|
||||||
|
AMMWithdrawFlagsInterface,
|
||||||
|
AMMWithdraw,
|
||||||
|
} from './AMMWithdraw'
|
||||||
export { CheckCancel } from './checkCancel'
|
export { CheckCancel } from './checkCancel'
|
||||||
export { CheckCash } from './checkCash'
|
export { CheckCash } from './checkCash'
|
||||||
export { CheckCreate } from './checkCreate'
|
export { CheckCreate } from './checkCreate'
|
||||||
export { ClaimReward } from './claimReward'
|
|
||||||
export { DepositPreauth } from './depositPreauth'
|
export { DepositPreauth } from './depositPreauth'
|
||||||
export { EscrowCancel } from './escrowCancel'
|
export { EscrowCancel } from './escrowCancel'
|
||||||
export { EscrowCreate } from './escrowCreate'
|
export { EscrowCreate } from './escrowCreate'
|
||||||
export { EscrowFinish } from './escrowFinish'
|
export { EscrowFinish } from './escrowFinish'
|
||||||
export { Import } from './import'
|
|
||||||
export { Invoke } from './invoke'
|
export { Invoke } from './invoke'
|
||||||
export { NFTokenAcceptOffer } from './NFTokenAcceptOffer'
|
export { NFTokenAcceptOffer } from './NFTokenAcceptOffer'
|
||||||
export { NFTokenBurn } from './NFTokenBurn'
|
export { NFTokenBurn } from './NFTokenBurn'
|
||||||
@@ -45,7 +56,7 @@ export {
|
|||||||
export { PaymentChannelCreate } from './paymentChannelCreate'
|
export { PaymentChannelCreate } from './paymentChannelCreate'
|
||||||
export { PaymentChannelFund } from './paymentChannelFund'
|
export { PaymentChannelFund } from './paymentChannelFund'
|
||||||
export { SetRegularKey } from './setRegularKey'
|
export { SetRegularKey } from './setRegularKey'
|
||||||
export { SetHookFlagsInterface, SetHookFlags, SetHook } from './setHook'
|
export { SetHook } from './setHook'
|
||||||
export { SignerListSet } from './signerListSet'
|
export { SignerListSet } from './signerListSet'
|
||||||
export { TicketCreate } from './ticketCreate'
|
export { TicketCreate } from './ticketCreate'
|
||||||
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ export interface Invoke extends BaseTransaction {
|
|||||||
* If present, invokes the Hook on the Destination account.
|
* If present, invokes the Hook on the Destination account.
|
||||||
*/
|
*/
|
||||||
Destination?: string
|
Destination?: string
|
||||||
/**
|
|
||||||
* Hex value representing a VL Blob.
|
|
||||||
*/
|
|
||||||
Blob?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,19 +1,5 @@
|
|||||||
import { Amount } from '../common'
|
import { Amount } from '../common'
|
||||||
|
|
||||||
export interface HookExecution {
|
|
||||||
HookExecution: {
|
|
||||||
HookAccount: string
|
|
||||||
HookEmitCount: number
|
|
||||||
HookExecutionIndex: number
|
|
||||||
HookHash: string
|
|
||||||
HookInstructionCount: string
|
|
||||||
HookResult: number
|
|
||||||
HookReturnCode: string
|
|
||||||
HookReturnString: string
|
|
||||||
HookStateChangeCount: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CreatedNode {
|
export interface CreatedNode {
|
||||||
CreatedNode: {
|
CreatedNode: {
|
||||||
LedgerEntryType: string
|
LedgerEntryType: string
|
||||||
@@ -74,7 +60,6 @@ export function isDeletedNode(node: Node): node is DeletedNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface TransactionMetadata {
|
export interface TransactionMetadata {
|
||||||
HookExecutions?: HookExecution[]
|
|
||||||
AffectedNodes: Node[]
|
AffectedNodes: Node[]
|
||||||
DeliveredAmount?: Amount
|
DeliveredAmount?: Amount
|
||||||
// "unavailable" possible for transactions before 2014-01-20
|
// "unavailable" possible for transactions before 2014-01-20
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
/* eslint-disable complexity -- Necessary for validatePaymentChannelClaim */
|
/* eslint-disable complexity -- Necessary for validatePaymentChannelClaim */
|
||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import { Amount } from '../common'
|
|
||||||
|
|
||||||
import {
|
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
|
||||||
BaseTransaction,
|
|
||||||
GlobalFlags,
|
|
||||||
validateBaseTransaction,
|
|
||||||
isAmount,
|
|
||||||
} from './common'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representing values for PaymentChannelClaim transaction flags.
|
* Enum representing values for PaymentChannelClaim transaction flags.
|
||||||
@@ -24,15 +18,15 @@ export enum PaymentChannelClaimFlags {
|
|||||||
/**
|
/**
|
||||||
* Request to close the channel. Only the channel source and destination
|
* Request to close the channel. Only the channel source and destination
|
||||||
* addresses can use this flag. This flag closes the channel immediately if it
|
* addresses can use this flag. This flag closes the channel immediately if it
|
||||||
* has no more funds allocated to it after processing the current claim, or if
|
* has no more XRP allocated to it after processing the current claim, or if
|
||||||
* the destination address uses it. If the source address uses this flag when
|
* the destination address uses it. If the source address uses this flag when
|
||||||
* the channel still holds an amount, this schedules the channel to close after
|
* the channel still holds XRP, this schedules the channel to close after
|
||||||
* SettleDelay seconds have passed. (Specifically, this sets the Expiration of
|
* SettleDelay seconds have passed. (Specifically, this sets the Expiration of
|
||||||
* the channel to the close time of the previous ledger plus the channel's
|
* the channel to the close time of the previous ledger plus the channel's
|
||||||
* SettleDelay time, unless the channel already has an earlier Expiration
|
* SettleDelay time, unless the channel already has an earlier Expiration
|
||||||
* time.) If the destination address uses this flag when the channel still
|
* time.) If the destination address uses this flag when the channel still
|
||||||
* holds an amount, any amount that remains after processing the claim is
|
* holds XRP, any XRP that remains after processing the claim is returned to
|
||||||
* returned to the source address.
|
* the source address.
|
||||||
*/
|
*/
|
||||||
tfClose = 0x00020000,
|
tfClose = 0x00020000,
|
||||||
}
|
}
|
||||||
@@ -84,21 +78,21 @@ export interface PaymentChannelClaimFlagsInterface extends GlobalFlags {
|
|||||||
/**
|
/**
|
||||||
* Request to close the channel. Only the channel source and destination
|
* Request to close the channel. Only the channel source and destination
|
||||||
* addresses can use this flag. This flag closes the channel immediately if it
|
* addresses can use this flag. This flag closes the channel immediately if it
|
||||||
* has no more funds allocated to it after processing the current claim, or if
|
* has no more XRP allocated to it after processing the current claim, or if
|
||||||
* the destination address uses it. If the source address uses this flag when
|
* the destination address uses it. If the source address uses this flag when
|
||||||
* the channel still holds an amount, this schedules the channel to close after
|
* the channel still holds XRP, this schedules the channel to close after
|
||||||
* SettleDelay seconds have passed. (Specifically, this sets the Expiration of
|
* SettleDelay seconds have passed. (Specifically, this sets the Expiration of
|
||||||
* the channel to the close time of the previous ledger plus the channel's
|
* the channel to the close time of the previous ledger plus the channel's
|
||||||
* SettleDelay time, unless the channel already has an earlier Expiration
|
* SettleDelay time, unless the channel already has an earlier Expiration
|
||||||
* time.) If the destination address uses this flag when the channel still
|
* time.) If the destination address uses this flag when the channel still
|
||||||
* holds an amount, any amount that remains after processing the claim is
|
* holds XRP, any XRP that remains after processing the claim is returned to
|
||||||
* returned to the source address.
|
* the source address.
|
||||||
*/
|
*/
|
||||||
tfClose?: boolean
|
tfClose?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Claim amount from a payment channel, adjust the payment channel's expiration,
|
* Claim XRP from a payment channel, adjust the payment channel's expiration,
|
||||||
* or both.
|
* or both.
|
||||||
*
|
*
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
@@ -109,18 +103,18 @@ export interface PaymentChannelClaim extends BaseTransaction {
|
|||||||
/** The unique ID of the channel as a 64-character hexadecimal string. */
|
/** The unique ID of the channel as a 64-character hexadecimal string. */
|
||||||
Channel: string
|
Channel: string
|
||||||
/**
|
/**
|
||||||
* Total amount delivered by this channel after processing this claim. Required
|
* Total amount of XRP, in drops, delivered by this channel after processing
|
||||||
* to deliver amount. Must be more than the total amount delivered by the channel
|
* this claim. Required to deliver XRP. Must be more than the total amount
|
||||||
* so far, but not greater than the Amount of the signed claim. Must be provided
|
* delivered by the channel so far, but not greater than the Amount of the
|
||||||
* except when closing the channel.
|
* signed claim. Must be provided except when closing the channel.
|
||||||
*/
|
*/
|
||||||
Balance?: Amount
|
Balance?: string
|
||||||
/**
|
/**
|
||||||
* The amount authorized by the Signature. This must match the amount in the
|
* The amount of XRP, in drops, authorized by the Signature. This must match
|
||||||
* signed message. This is the cumulative amount that can be dispensed by the
|
* the amount in the signed message. This is the cumulative amount of XRP that
|
||||||
* channel, including amounts previously redeemed. Required unless closing the channel.
|
* can be dispensed by the channel, including XRP previously redeemed.
|
||||||
*/
|
*/
|
||||||
Amount?: Amount
|
Amount?: string
|
||||||
/**
|
/**
|
||||||
* The signature of this claim, as hexadecimal. The signed message contains
|
* The signature of this claim, as hexadecimal. The signed message contains
|
||||||
* the channel ID and the amount of the claim. Required unless the sender of
|
* the channel ID and the amount of the claim. Required unless the sender of
|
||||||
@@ -153,12 +147,12 @@ export function validatePaymentChannelClaim(tx: Record<string, unknown>): void {
|
|||||||
throw new ValidationError('PaymentChannelClaim: Channel must be a string')
|
throw new ValidationError('PaymentChannelClaim: Channel must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.Balance !== undefined && !isAmount(tx.Balance)) {
|
if (tx.Balance !== undefined && typeof tx.Balance !== 'string') {
|
||||||
throw new ValidationError('PaymentChannelClaim: Balance must be an Amount')
|
throw new ValidationError('PaymentChannelClaim: Balance must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.Amount !== undefined && !isAmount(tx.Amount)) {
|
if (tx.Amount !== undefined && typeof tx.Amount !== 'string') {
|
||||||
throw new ValidationError('PaymentChannelClaim: Amount must be an Amount')
|
throw new ValidationError('PaymentChannelClaim: Amount must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.Signature !== undefined && typeof tx.Signature !== 'string') {
|
if (tx.Signature !== undefined && typeof tx.Signature !== 'string') {
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
/* eslint-disable complexity -- Necessary for validatePaymentChannelCreate */
|
/* eslint-disable complexity -- Necessary for validatePaymentChannelCreate */
|
||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import { Amount } from '../common'
|
|
||||||
|
|
||||||
import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a unidirectional channel and fund it. The address sending
|
* Create a unidirectional channel and fund it with XRP. The address sending
|
||||||
* this transaction becomes the "source address" of the payment channel.
|
* this transaction becomes the "source address" of the payment channel.
|
||||||
*
|
*
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
@@ -13,20 +12,20 @@ import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
|
|||||||
export interface PaymentChannelCreate extends BaseTransaction {
|
export interface PaymentChannelCreate extends BaseTransaction {
|
||||||
TransactionType: 'PaymentChannelCreate'
|
TransactionType: 'PaymentChannelCreate'
|
||||||
/**
|
/**
|
||||||
* Amount to deduct from the sender's balance and set aside in this channel.
|
* Amount of XRP, in drops, to deduct from the sender's balance and set aside
|
||||||
* While the channel is open, the amount can only go to the Destination
|
* in this channel. While the channel is open, the XRP can only go to the
|
||||||
* address. When the channel closes, any unclaimed amount is returned to
|
* Destination address. When the channel closes, any unclaimed XRP is returned
|
||||||
* the source address's balance.
|
* to the source address's balance.
|
||||||
*/
|
*/
|
||||||
Amount: Amount
|
Amount: string
|
||||||
/**
|
/**
|
||||||
* Address to receive claims against this channel. This is also known as
|
* Address to receive XRP claims against this channel. This is also known as
|
||||||
* the "destination address" for the channel.
|
* the "destination address" for the channel.
|
||||||
*/
|
*/
|
||||||
Destination: string
|
Destination: string
|
||||||
/**
|
/**
|
||||||
* Amount of time the source address must wait before closing the channel if
|
* Amount of time the source address must wait before closing the channel if
|
||||||
* it has unclaimed amount.
|
* it has unclaimed XRP.
|
||||||
*/
|
*/
|
||||||
SettleDelay: number
|
SettleDelay: number
|
||||||
/**
|
/**
|
||||||
@@ -66,8 +65,8 @@ export function validatePaymentChannelCreate(
|
|||||||
throw new ValidationError('PaymentChannelCreate: missing Amount')
|
throw new ValidationError('PaymentChannelCreate: missing Amount')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
|
if (typeof tx.Amount !== 'string') {
|
||||||
throw new ValidationError('PaymentChannelCreate: Amount must be an Amount')
|
throw new ValidationError('PaymentChannelCreate: Amount must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.Destination === undefined) {
|
if (tx.Destination === undefined) {
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import { Amount } from '../common'
|
|
||||||
|
|
||||||
import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add additional amount to an open payment channel, and optionally update the
|
* Add additional XRP to an open payment channel, and optionally update the
|
||||||
* expiration time of the channel. Only the source address of the channel can
|
* expiration time of the channel. Only the source address of the channel can
|
||||||
* use this transaction.
|
* use this transaction.
|
||||||
*
|
*
|
||||||
@@ -18,15 +17,16 @@ export interface PaymentChannelFund extends BaseTransaction {
|
|||||||
*/
|
*/
|
||||||
Channel: string
|
Channel: string
|
||||||
/**
|
/**
|
||||||
* Amount to add to the channel. Must be a positive amount
|
* Amount of XRP in drops to add to the channel. Must be a positive amount
|
||||||
|
* of XRP.
|
||||||
*/
|
*/
|
||||||
Amount: Amount
|
Amount: string
|
||||||
/**
|
/**
|
||||||
* New Expiration time to set for the channel in seconds since the Ripple
|
* 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
|
* 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
|
* of the channel, or the existing Expiration of the channel. After the
|
||||||
* Expiration time, any transaction that would access the channel closes the
|
* Expiration time, any transaction that would access the channel closes the
|
||||||
* channel without taking its normal action. Any unspent amount is returned to
|
* channel without taking its normal action. Any unspent XRP is returned to
|
||||||
* the source address when the channel closes. (Expiration is separate from
|
* the source address when the channel closes. (Expiration is separate from
|
||||||
* the channel's immutable CancelAfter time.) For more information, see the
|
* the channel's immutable CancelAfter time.) For more information, see the
|
||||||
* PayChannel ledger object type.
|
* PayChannel ledger object type.
|
||||||
@@ -55,8 +55,8 @@ export function validatePaymentChannelFund(tx: Record<string, unknown>): void {
|
|||||||
throw new ValidationError('PaymentChannelFund: missing Amount')
|
throw new ValidationError('PaymentChannelFund: missing Amount')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
|
if (typeof tx.Amount !== 'string') {
|
||||||
throw new ValidationError('PaymentChannelFund: Amount must be an Amount')
|
throw new ValidationError('PaymentChannelFund: Amount must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
|
if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
|
||||||
|
|||||||
@@ -1,30 +1,7 @@
|
|||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import { Hook } from '../common'
|
import { Hook } from '../common'
|
||||||
|
|
||||||
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum representing values for Set Hook Transaction Flags.
|
|
||||||
*
|
|
||||||
* @category Transaction Flags
|
|
||||||
*/
|
|
||||||
export enum SetHookFlags {
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
hsfOverride = 0x00000001,
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
hsfNSDelete = 0x0000002,
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
hsfCollect = 0x00000004,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SetHookFlagsInterface extends GlobalFlags {
|
|
||||||
hsfOverride?: boolean
|
|
||||||
hsfNSDelete?: boolean
|
|
||||||
hsfCollect?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -37,11 +14,9 @@ export interface SetHook extends BaseTransaction {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Hooks: Hook[]
|
Hooks: Hook[]
|
||||||
|
|
||||||
Flags?: number | SetHookFlagsInterface
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_HOOKS = 10
|
const MAX_HOOKS = 4
|
||||||
const HEX_REGEX = /^[0-9A-Fa-f]{64}$/u
|
const HEX_REGEX = /^[0-9A-Fa-f]{64}$/u
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export interface SignerListSet extends BaseTransaction {
|
|||||||
* more than 32 members. No address may appear more than once in the list, nor
|
* more than 32 members. No address may appear more than once in the list, nor
|
||||||
* may the Account submitting the transaction appear in the list.
|
* may the Account submitting the transaction appear in the list.
|
||||||
*/
|
*/
|
||||||
SignerEntries?: SignerEntry[]
|
SignerEntries: SignerEntry[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_SIGNERS = 32
|
const MAX_SIGNERS = 32
|
||||||
@@ -36,7 +36,6 @@ const HEX_WALLET_LOCATOR_REGEX = /^[0-9A-Fa-f]{64}$/u
|
|||||||
* @param tx - An SignerListSet Transaction.
|
* @param tx - An SignerListSet Transaction.
|
||||||
* @throws When the SignerListSet is Malformed.
|
* @throws When the SignerListSet is Malformed.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line complexity -- validation can be complex
|
|
||||||
export function validateSignerListSet(tx: Record<string, unknown>): void {
|
export function validateSignerListSet(tx: Record<string, unknown>): void {
|
||||||
validateBaseTransaction(tx)
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
@@ -48,10 +47,6 @@ export function validateSignerListSet(tx: Record<string, unknown>): void {
|
|||||||
throw new ValidationError('SignerListSet: invalid SignerQuorum')
|
throw new ValidationError('SignerListSet: invalid SignerQuorum')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.SignerQuorum === 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tx.SignerEntries === undefined) {
|
if (tx.SignerEntries === undefined) {
|
||||||
throw new ValidationError('SignerListSet: missing field SignerEntries')
|
throw new ValidationError('SignerListSet: missing field SignerEntries')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,16 +6,18 @@ import { setTransactionFlagsToNumber } from '../utils/flags'
|
|||||||
|
|
||||||
import { AccountDelete, validateAccountDelete } from './accountDelete'
|
import { AccountDelete, validateAccountDelete } from './accountDelete'
|
||||||
import { AccountSet, validateAccountSet } from './accountSet'
|
import { AccountSet, validateAccountSet } from './accountSet'
|
||||||
|
import { AMMBid, validateAMMBid } from './AMMBid'
|
||||||
|
import { AMMCreate, validateAMMCreate } from './AMMCreate'
|
||||||
|
import { AMMDeposit, validateAMMDeposit } from './AMMDeposit'
|
||||||
|
import { AMMVote, validateAMMVote } from './AMMVote'
|
||||||
|
import { AMMWithdraw, validateAMMWithdraw } from './AMMWithdraw'
|
||||||
import { CheckCancel, validateCheckCancel } from './checkCancel'
|
import { CheckCancel, validateCheckCancel } from './checkCancel'
|
||||||
import { CheckCash, validateCheckCash } from './checkCash'
|
import { CheckCash, validateCheckCash } from './checkCash'
|
||||||
import { CheckCreate, validateCheckCreate } from './checkCreate'
|
import { CheckCreate, validateCheckCreate } from './checkCreate'
|
||||||
import { ClaimReward, validateClaimReward } from './claimReward'
|
|
||||||
import { DepositPreauth, validateDepositPreauth } from './depositPreauth'
|
import { DepositPreauth, validateDepositPreauth } from './depositPreauth'
|
||||||
import { EscrowCancel, validateEscrowCancel } from './escrowCancel'
|
import { EscrowCancel, validateEscrowCancel } from './escrowCancel'
|
||||||
import { EscrowCreate, validateEscrowCreate } from './escrowCreate'
|
import { EscrowCreate, validateEscrowCreate } from './escrowCreate'
|
||||||
import { EscrowFinish, validateEscrowFinish } from './escrowFinish'
|
import { EscrowFinish, validateEscrowFinish } from './escrowFinish'
|
||||||
import { Import, validateImport } from './import'
|
|
||||||
import { Invoke, validateInvoke } from './invoke'
|
|
||||||
import { TransactionMetadata } from './metadata'
|
import { TransactionMetadata } from './metadata'
|
||||||
import {
|
import {
|
||||||
NFTokenAcceptOffer,
|
NFTokenAcceptOffer,
|
||||||
@@ -69,16 +71,18 @@ import { URITokenMint, validateURITokenMint } from './uriTokenMint'
|
|||||||
export type Transaction =
|
export type Transaction =
|
||||||
| AccountDelete
|
| AccountDelete
|
||||||
| AccountSet
|
| AccountSet
|
||||||
|
| AMMBid
|
||||||
|
| AMMDeposit
|
||||||
|
| AMMCreate
|
||||||
|
| AMMVote
|
||||||
|
| AMMWithdraw
|
||||||
| CheckCancel
|
| CheckCancel
|
||||||
| CheckCash
|
| CheckCash
|
||||||
| CheckCreate
|
| CheckCreate
|
||||||
| ClaimReward
|
|
||||||
| DepositPreauth
|
| DepositPreauth
|
||||||
| EscrowCancel
|
| EscrowCancel
|
||||||
| EscrowCreate
|
| EscrowCreate
|
||||||
| EscrowFinish
|
| EscrowFinish
|
||||||
| Import
|
|
||||||
| Invoke
|
|
||||||
| NFTokenAcceptOffer
|
| NFTokenAcceptOffer
|
||||||
| NFTokenBurn
|
| NFTokenBurn
|
||||||
| NFTokenCancelOffer
|
| NFTokenCancelOffer
|
||||||
@@ -136,6 +140,26 @@ export function validate(transaction: Record<string, unknown>): void {
|
|||||||
validateAccountSet(tx)
|
validateAccountSet(tx)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'AMMBid':
|
||||||
|
validateAMMBid(tx)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'AMMDeposit':
|
||||||
|
validateAMMDeposit(tx)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'AMMCreate':
|
||||||
|
validateAMMCreate(tx)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'AMMVote':
|
||||||
|
validateAMMVote(tx)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'AMMWithdraw':
|
||||||
|
validateAMMWithdraw(tx)
|
||||||
|
break
|
||||||
|
|
||||||
case 'CheckCancel':
|
case 'CheckCancel':
|
||||||
validateCheckCancel(tx)
|
validateCheckCancel(tx)
|
||||||
break
|
break
|
||||||
@@ -148,10 +172,6 @@ export function validate(transaction: Record<string, unknown>): void {
|
|||||||
validateCheckCreate(tx)
|
validateCheckCreate(tx)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'ClaimReward':
|
|
||||||
validateClaimReward(tx)
|
|
||||||
break
|
|
||||||
|
|
||||||
case 'DepositPreauth':
|
case 'DepositPreauth':
|
||||||
validateDepositPreauth(tx)
|
validateDepositPreauth(tx)
|
||||||
break
|
break
|
||||||
@@ -168,14 +188,6 @@ export function validate(transaction: Record<string, unknown>): void {
|
|||||||
validateEscrowFinish(tx)
|
validateEscrowFinish(tx)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'Import':
|
|
||||||
validateImport(tx)
|
|
||||||
break
|
|
||||||
|
|
||||||
case 'Invoke':
|
|
||||||
validateInvoke(tx)
|
|
||||||
break
|
|
||||||
|
|
||||||
case 'NFTokenAcceptOffer':
|
case 'NFTokenAcceptOffer':
|
||||||
validateNFTokenAcceptOffer(tx)
|
validateNFTokenAcceptOffer(tx)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -2,28 +2,19 @@
|
|||||||
/* eslint-disable no-bitwise -- flags require bitwise operations */
|
/* eslint-disable no-bitwise -- flags require bitwise operations */
|
||||||
|
|
||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import { Hook } from '../common'
|
|
||||||
import {
|
import {
|
||||||
AccountRootFlagsInterface,
|
AccountRootFlagsInterface,
|
||||||
AccountRootFlags,
|
AccountRootFlags,
|
||||||
} from '../ledger/AccountRoot'
|
} from '../ledger/AccountRoot'
|
||||||
import {
|
import { AccountSetTfFlags } from '../transactions/accountSet'
|
||||||
AccountSetFlagsInterface,
|
import { AMMDepositFlags } from '../transactions/AMMDeposit'
|
||||||
AccountSetTfFlags,
|
import { AMMWithdrawFlags } from '../transactions/AMMWithdraw'
|
||||||
} from '../transactions/accountSet'
|
|
||||||
import { GlobalFlags } from '../transactions/common'
|
import { GlobalFlags } from '../transactions/common'
|
||||||
import {
|
import { OfferCreateFlags } from '../transactions/offerCreate'
|
||||||
OfferCreateFlagsInterface,
|
import { PaymentFlags } from '../transactions/payment'
|
||||||
OfferCreateFlags,
|
import { PaymentChannelClaimFlags } from '../transactions/paymentChannelClaim'
|
||||||
} from '../transactions/offerCreate'
|
|
||||||
import { PaymentFlagsInterface, PaymentFlags } from '../transactions/payment'
|
|
||||||
import {
|
|
||||||
PaymentChannelClaimFlagsInterface,
|
|
||||||
PaymentChannelClaimFlags,
|
|
||||||
} from '../transactions/paymentChannelClaim'
|
|
||||||
import { SetHookFlagsInterface, SetHookFlags } from '../transactions/setHook'
|
|
||||||
import type { Transaction } from '../transactions/transaction'
|
import type { Transaction } from '../transactions/transaction'
|
||||||
import { TrustSetFlagsInterface, TrustSetFlags } from '../transactions/trustSet'
|
import { TrustSetFlags } from '../transactions/trustSet'
|
||||||
|
|
||||||
import { isFlagEnabled } from '.'
|
import { isFlagEnabled } from '.'
|
||||||
|
|
||||||
@@ -63,68 +54,33 @@ export function setTransactionFlagsToNumber(tx: Transaction): void {
|
|||||||
|
|
||||||
switch (tx.TransactionType) {
|
switch (tx.TransactionType) {
|
||||||
case 'AccountSet':
|
case 'AccountSet':
|
||||||
tx.Flags = convertAccountSetFlagsToNumber(tx.Flags)
|
tx.Flags = convertFlagsToNumber(tx.Flags, AccountSetTfFlags)
|
||||||
|
return
|
||||||
|
case 'AMMDeposit':
|
||||||
|
tx.Flags = convertFlagsToNumber(tx.Flags, AMMDepositFlags)
|
||||||
|
return
|
||||||
|
case 'AMMWithdraw':
|
||||||
|
tx.Flags = convertFlagsToNumber(tx.Flags, AMMWithdrawFlags)
|
||||||
return
|
return
|
||||||
case 'OfferCreate':
|
case 'OfferCreate':
|
||||||
tx.Flags = convertOfferCreateFlagsToNumber(tx.Flags)
|
tx.Flags = convertFlagsToNumber(tx.Flags, OfferCreateFlags)
|
||||||
return
|
return
|
||||||
case 'PaymentChannelClaim':
|
case 'PaymentChannelClaim':
|
||||||
tx.Flags = convertPaymentChannelClaimFlagsToNumber(tx.Flags)
|
tx.Flags = convertFlagsToNumber(tx.Flags, PaymentChannelClaimFlags)
|
||||||
return
|
return
|
||||||
case 'Payment':
|
case 'Payment':
|
||||||
tx.Flags = convertPaymentTransactionFlagsToNumber(tx.Flags)
|
tx.Flags = convertFlagsToNumber(tx.Flags, PaymentFlags)
|
||||||
return
|
return
|
||||||
case 'TrustSet':
|
case 'TrustSet':
|
||||||
tx.Flags = convertTrustSetFlagsToNumber(tx.Flags)
|
tx.Flags = convertFlagsToNumber(tx.Flags, TrustSetFlags)
|
||||||
return
|
|
||||||
case 'SetHook':
|
|
||||||
tx.Flags = convertSetHookFlagsToNumber(tx.Flags)
|
|
||||||
tx.Hooks.forEach((hook: Hook) => {
|
|
||||||
hook.Hook.Flags = convertSetHookFlagsToNumber(
|
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- idk
|
|
||||||
hook.Hook.Flags as SetHookFlagsInterface,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
tx.Flags = 0
|
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
function convertSetHookFlagsToNumber(flags: SetHookFlagsInterface): number {
|
|
||||||
return reduceFlags(flags, SetHookFlags)
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- added ValidationError check for flagEnum
|
// 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) => {
|
return Object.keys(flags).reduce((resultFlags, flag) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- safe member access
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- safe member access
|
||||||
if (flagEnum[flag] == null) {
|
if (flagEnum[flag] == null) {
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import {
|
|
||||||
xAddressToClassicAddress,
|
|
||||||
isValidXAddress,
|
|
||||||
} from '@transia/ripple-address-codec'
|
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
|
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
||||||
|
|
||||||
import type { Client } from '..'
|
import type { Client } from '..'
|
||||||
import { ValidationError, XrplError } from '../errors'
|
import { ValidationError, XrplError } from '../errors'
|
||||||
@@ -146,7 +143,7 @@ async function setNextValidSequenceNumber(
|
|||||||
tx.Sequence = data.result.account_data.Sequence
|
tx.Sequence = data.result.account_data.Sequence
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAccountDeleteFee(client: Client): Promise<BigNumber> {
|
async function fetchOwnerReserveFee(client: Client): Promise<BigNumber> {
|
||||||
const response = await client.request({ command: 'server_state' })
|
const response = await client.request({ command: 'server_state' })
|
||||||
const fee = response.result.state.validated_ledger?.reserve_inc
|
const fee = response.result.state.validated_ledger?.reserve_inc
|
||||||
|
|
||||||
@@ -178,9 +175,11 @@ async function calculateFeePerTransactionType(
|
|||||||
baseFee = product.dp(0, BigNumber.ROUND_CEIL)
|
baseFee = product.dp(0, BigNumber.ROUND_CEIL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountDelete Transaction
|
if (
|
||||||
if (tx.TransactionType === 'AccountDelete') {
|
tx.TransactionType === 'AccountDelete' ||
|
||||||
baseFee = await fetchAccountDeleteFee(client)
|
tx.TransactionType === 'AMMCreate'
|
||||||
|
) {
|
||||||
|
baseFee = await fetchOwnerReserveFee(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { decode, encode } from '@transia/ripple-binary-codec'
|
import { decode, encode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import type { Client, SubmitRequest, SubmitResponse, Wallet } from '..'
|
import type { Client, SubmitRequest, SubmitResponse, Wallet } from '..'
|
||||||
import { ValidationError, XrplError } from '../errors'
|
import { ValidationError, XrplError } from '../errors'
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import {
|
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
||||||
xAddressToClassicAddress,
|
|
||||||
isValidXAddress,
|
|
||||||
} from '@transia/ripple-address-codec'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If an address is an X-Address, converts it to a classic address.
|
* If an address is an X-Address, converts it to a classic address.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { classicAddressToXAddress } from '@transia/ripple-address-codec'
|
import { classicAddressToXAddress } from 'ripple-address-codec'
|
||||||
import { deriveKeypair, deriveAddress } from '@transia/ripple-keypairs'
|
import { deriveKeypair, deriveAddress } from 'ripple-keypairs'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derive an X-Address from a public key and a destination tag.
|
* Derive an X-Address from a public key and a destination tag.
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
/* eslint-disable no-bitwise -- this file mimics behavior in rippled. It uses
|
/* eslint-disable no-bitwise -- this file mimics behavior in rippled. It uses
|
||||||
bitwise operators for and-ing numbers with a mask and bit shifting. */
|
bitwise operators for and-ing numbers with a mask and bit shifting. */
|
||||||
|
|
||||||
import { decode, encode } from '@transia/ripple-binary-codec'
|
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
|
import { decode, encode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import { ValidationError, XrplError } from '../../errors'
|
import { ValidationError, XrplError } from '../../errors'
|
||||||
import type { Ledger } from '../../models/ledger'
|
import type { Ledger } from '../../models/ledger'
|
||||||
@@ -83,11 +83,7 @@ export function hashSignedTx(tx: Transaction | string): string {
|
|||||||
txObject = tx
|
txObject = tx
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (txObject.TxnSignature === undefined && txObject.Signers === undefined) {
|
||||||
!txObject.EmitDetails &&
|
|
||||||
txObject.TxnSignature === undefined &&
|
|
||||||
txObject.Signers === undefined
|
|
||||||
) {
|
|
||||||
throw new ValidationError('The transaction must be signed to hash it.')
|
throw new ValidationError('The transaction must be signed to hash it.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,8 @@
|
|||||||
/* eslint-disable no-bitwise -- this file mimics behavior in rippled. It uses
|
/* eslint-disable no-bitwise -- this file mimics behavior in rippled. It uses
|
||||||
bitwise operators for and-ing numbers with a mask and bit shifting. */
|
bitwise operators for and-ing numbers with a mask and bit shifting. */
|
||||||
|
|
||||||
import { decodeAccountID } from '@transia/ripple-address-codec'
|
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
|
import { decodeAccountID } from 'ripple-address-codec'
|
||||||
import { convertStringToHex } from '../stringConversion'
|
|
||||||
|
|
||||||
import hashLedger, {
|
import hashLedger, {
|
||||||
hashLedgerHeader,
|
hashLedgerHeader,
|
||||||
@@ -186,18 +184,4 @@ export function hashPaymentChannel(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the Hash of an URIToken LedgerEntry.
|
|
||||||
*
|
|
||||||
* @param issuer - Address of the issuer of the URIToken.
|
|
||||||
* @param uri - string uri of the URIToken (not the hex).
|
|
||||||
* @returns The hash of the URIToken LedgerEntry.
|
|
||||||
* @category Utilities
|
|
||||||
*/
|
|
||||||
export function hashURIToken(issuer: string, uri: string): string {
|
|
||||||
return sha512Half(
|
|
||||||
ledgerSpaceHex('uriToken') + addressToHex(issuer) + convertStringToHex(uri),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { hashLedgerHeader, hashSignedTx, hashLedger, hashStateTree, hashTxTree }
|
export { hashLedgerHeader, hashSignedTx, hashLedger, hashStateTree, hashTxTree }
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ const ledgerSpaces = {
|
|||||||
signerList: 'S',
|
signerList: 'S',
|
||||||
paychan: 'x',
|
paychan: 'x',
|
||||||
check: 'C',
|
check: 'C',
|
||||||
uriToken: 'U',
|
|
||||||
depositPreauth: 'p',
|
depositPreauth: 'p',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,9 @@
|
|||||||
* This module contains the transaction types and the function to calculate the hook on
|
* This module contains the transaction types and the function to calculate the hook on
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
// eslint-disable-next-line @typescript-eslint/no-require-imports -- Required
|
||||||
TRANSACTION_TYPES,
|
import createHash = require('create-hash')
|
||||||
TRANSACTION_TYPE_MAP,
|
import { TRANSACTION_TYPES, TRANSACTION_TYPE_MAP } from 'ripple-binary-codec'
|
||||||
} from '@transia/ripple-binary-codec'
|
|
||||||
// import createHash = require('create-hash')
|
|
||||||
|
|
||||||
import { XrplError } from '../errors'
|
import { XrplError } from '../errors'
|
||||||
import { HookParameter } from '../models/common'
|
import { HookParameter } from '../models/common'
|
||||||
@@ -44,7 +42,7 @@ export function calculateHookOn(arr: Array<keyof TTS>): string {
|
|||||||
`invalid transaction type '${String(nth)}' in HookOn array`,
|
`invalid transaction type '${String(nth)}' in HookOn array`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Required
|
||||||
const tts: Record<string, number> = TRANSACTION_TYPE_MAP
|
const tts: Record<string, number> = TRANSACTION_TYPE_MAP
|
||||||
let value = BigInt(hash)
|
let value = BigInt(hash)
|
||||||
// eslint-disable-next-line no-bitwise -- Required
|
// eslint-disable-next-line no-bitwise -- Required
|
||||||
@@ -58,12 +56,32 @@ export function calculateHookOn(arr: Array<keyof TTS>): string {
|
|||||||
return hash.toUpperCase()
|
return hash.toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
function isHex(value: string): boolean {
|
/**
|
||||||
return /^[0-9A-F]+$/iu.test(value)
|
* Calculate the sha256 of a string
|
||||||
|
*
|
||||||
|
* @param string - the string to calculate the sha256
|
||||||
|
* @returns the sha256
|
||||||
|
*/
|
||||||
|
export async function sha256(string: string): Promise<string> {
|
||||||
|
const hash = createHash('sha256')
|
||||||
|
hash.update(string)
|
||||||
|
const hashBuffer = hash.digest()
|
||||||
|
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||||
|
const hashHex = hashArray
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- Required
|
||||||
|
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
||||||
|
.join('')
|
||||||
|
return hashHex
|
||||||
}
|
}
|
||||||
|
|
||||||
function hexValue(value: string): string {
|
/**
|
||||||
return Buffer.from(value, 'utf8').toString('hex').toUpperCase()
|
* Calculate the hex of a namespace
|
||||||
|
*
|
||||||
|
* @param namespace - the namespace to calculate the hex
|
||||||
|
* @returns the hex
|
||||||
|
*/
|
||||||
|
export async function hexNamespace(namespace: string): Promise<string> {
|
||||||
|
return (await sha256(namespace)).toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,21 +93,20 @@ function hexValue(value: string): string {
|
|||||||
export function hexHookParameters(data: HookParameter[]): HookParameter[] {
|
export function hexHookParameters(data: HookParameter[]): HookParameter[] {
|
||||||
const hookParameters: HookParameter[] = []
|
const hookParameters: HookParameter[] = []
|
||||||
for (const parameter of data) {
|
for (const parameter of data) {
|
||||||
let hookPName = parameter.HookParameter.HookParameterName
|
|
||||||
let hookPValue = parameter.HookParameter.HookParameterValue
|
|
||||||
|
|
||||||
if (!isHex(hookPName)) {
|
|
||||||
hookPName = hexValue(hookPName)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isHex(hookPValue)) {
|
|
||||||
hookPValue = hexValue(hookPValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
hookParameters.push({
|
hookParameters.push({
|
||||||
HookParameter: {
|
HookParameter: {
|
||||||
HookParameterName: hookPName,
|
HookParameterName: Buffer.from(
|
||||||
HookParameterValue: hookPValue,
|
parameter.HookParameter.HookParameterName,
|
||||||
|
'utf8',
|
||||||
|
)
|
||||||
|
.toString('hex')
|
||||||
|
.toUpperCase(),
|
||||||
|
HookParameterValue: Buffer.from(
|
||||||
|
parameter.HookParameter.HookParameterValue,
|
||||||
|
'utf8',
|
||||||
|
)
|
||||||
|
.toString('hex')
|
||||||
|
.toUpperCase(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import {
|
|||||||
isValidClassicAddress,
|
isValidClassicAddress,
|
||||||
isValidXAddress,
|
isValidXAddress,
|
||||||
xAddressToClassicAddress,
|
xAddressToClassicAddress,
|
||||||
} from '@transia/ripple-address-codec'
|
} from 'ripple-address-codec'
|
||||||
import * as rbc from '@transia/ripple-binary-codec'
|
import * as rbc from 'ripple-binary-codec'
|
||||||
import { verify as verifyKeypairSignature } from '@transia/ripple-keypairs'
|
import { verify as verifyKeypairSignature } from 'ripple-keypairs'
|
||||||
|
|
||||||
import { LedgerEntry } from '../models/ledger'
|
import { LedgerEntry } from '../models/ledger'
|
||||||
import { Response } from '../models/methods'
|
import { Response } from '../models/methods'
|
||||||
@@ -39,9 +39,8 @@ import {
|
|||||||
hashLedgerHeader,
|
hashLedgerHeader,
|
||||||
hashEscrow,
|
hashEscrow,
|
||||||
hashPaymentChannel,
|
hashPaymentChannel,
|
||||||
hashURIToken,
|
|
||||||
} from './hashes'
|
} from './hashes'
|
||||||
import { calculateHookOn, hexHookParameters, TTS } from './hooks'
|
import { calculateHookOn, hexNamespace, hexHookParameters, TTS } from './hooks'
|
||||||
import parseNFTokenID from './parseNFTokenID'
|
import parseNFTokenID from './parseNFTokenID'
|
||||||
import {
|
import {
|
||||||
percentToTransferRate,
|
percentToTransferRate,
|
||||||
@@ -174,7 +173,6 @@ const hashes = {
|
|||||||
hashLedgerHeader,
|
hashLedgerHeader,
|
||||||
hashEscrow,
|
hashEscrow,
|
||||||
hashPaymentChannel,
|
hashPaymentChannel,
|
||||||
hashURIToken,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -226,6 +224,7 @@ export {
|
|||||||
createCrossChainPayment,
|
createCrossChainPayment,
|
||||||
parseNFTokenID,
|
parseNFTokenID,
|
||||||
calculateHookOn,
|
calculateHookOn,
|
||||||
|
hexNamespace,
|
||||||
hexHookParameters,
|
hexHookParameters,
|
||||||
TTS,
|
TTS,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-magic-numbers -- Doing hex string parsing. */
|
/* eslint-disable @typescript-eslint/no-magic-numbers -- Doing hex string parsing. */
|
||||||
import { encodeAccountID } from '@transia/ripple-address-codec'
|
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
|
import { encodeAccountID } from 'ripple-address-codec'
|
||||||
|
|
||||||
import { XrplError } from '../errors'
|
import { XrplError } from '../errors'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { encodeForSigningClaim } from '@transia/ripple-binary-codec'
|
import { encodeForSigningClaim } from 'ripple-binary-codec'
|
||||||
import { sign } from '@transia/ripple-keypairs'
|
import { sign } from 'ripple-keypairs'
|
||||||
|
|
||||||
import { xrpToDrops } from './xrpConversion'
|
import { xrpToDrops } from './xrpConversion'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { encodeForSigningClaim } from '@transia/ripple-binary-codec'
|
import { encodeForSigningClaim } from 'ripple-binary-codec'
|
||||||
import { verify } from '@transia/ripple-keypairs'
|
import { verify } from 'ripple-keypairs'
|
||||||
|
|
||||||
import { xrpToDrops } from './xrpConversion'
|
import { xrpToDrops } from './xrpConversion'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { decode } from '@transia/ripple-binary-codec'
|
|
||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
import { decode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AccountSet,
|
AccountSet,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { decode } from '@transia/ripple-binary-codec'
|
|
||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
import { decode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AccountSet,
|
AccountSet,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Client } from '@transia/xrpl'
|
|
||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import { Client } from 'xrpl'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
convertStringToHex,
|
convertStringToHex,
|
||||||
|
|||||||
@@ -18,9 +18,8 @@ describe('SignerListSet', function () {
|
|||||||
})
|
})
|
||||||
afterEach(async () => teardownClient(testContext))
|
afterEach(async () => teardownClient(testContext))
|
||||||
|
|
||||||
// Add signerlist
|
|
||||||
it(
|
it(
|
||||||
'add',
|
'base',
|
||||||
async () => {
|
async () => {
|
||||||
const tx: SignerListSet = {
|
const tx: SignerListSet = {
|
||||||
TransactionType: 'SignerListSet',
|
TransactionType: 'SignerListSet',
|
||||||
@@ -45,18 +44,4 @@ describe('SignerListSet', function () {
|
|||||||
},
|
},
|
||||||
TIMEOUT,
|
TIMEOUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Remove signerlist
|
|
||||||
it(
|
|
||||||
'remove',
|
|
||||||
async () => {
|
|
||||||
const tx: SignerListSet = {
|
|
||||||
TransactionType: 'SignerListSet',
|
|
||||||
Account: testContext.wallet.classicAddress,
|
|
||||||
SignerQuorum: 0,
|
|
||||||
}
|
|
||||||
await testTransaction(testContext.client, tx, testContext.wallet)
|
|
||||||
},
|
|
||||||
TIMEOUT,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { decode } from '@transia/ripple-binary-codec'
|
|
||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
import omit from 'lodash/omit'
|
import omit from 'lodash/omit'
|
||||||
import throttle from 'lodash/throttle'
|
import throttle from 'lodash/throttle'
|
||||||
|
import { decode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Client,
|
Client,
|
||||||
|
|||||||
123
packages/xrpl/test/models/AMMBid.test.ts
Normal file
123
packages/xrpl/test/models/AMMBid.test.ts
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
|
import { validate, ValidationError } from '../../src'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMBid Transaction Verification Testing.
|
||||||
|
*
|
||||||
|
* Providing runtime verification testing for each specific transaction type.
|
||||||
|
*/
|
||||||
|
describe('AMMBid', function () {
|
||||||
|
let bid
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
bid = {
|
||||||
|
TransactionType: 'AMMBid',
|
||||||
|
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||||
|
Asset: {
|
||||||
|
currency: 'XRP',
|
||||||
|
},
|
||||||
|
Asset2: {
|
||||||
|
currency: 'ETH',
|
||||||
|
issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd',
|
||||||
|
},
|
||||||
|
BidMin: '5',
|
||||||
|
BidMax: '10',
|
||||||
|
AuthAccounts: [
|
||||||
|
{
|
||||||
|
AuthAccount: {
|
||||||
|
Account: 'rNZdsTBP5tH1M6GHC6bTreHAp6ouP8iZSh',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AuthAccount: {
|
||||||
|
Account: 'rfpFv97Dwu89FTyUwPjtpZBbuZxTqqgTmH',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AuthAccount: {
|
||||||
|
Account: 'rzzYHPGb8Pa64oqxCzmuffm122bitq3Vb',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
AuthAccount: {
|
||||||
|
Account: 'rhwxHxaHok86fe4LykBom1jSJ3RYQJs1h4',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Sequence: 1337,
|
||||||
|
} as any
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMBid`, function () {
|
||||||
|
assert.doesNotThrow(() => validate(bid))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field Asset`, function () {
|
||||||
|
delete bid.Asset
|
||||||
|
assert.throws(
|
||||||
|
() => validate(bid),
|
||||||
|
ValidationError,
|
||||||
|
'AMMBid: missing field Asset',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Asset must be an Issue`, function () {
|
||||||
|
bid.Asset = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(bid),
|
||||||
|
ValidationError,
|
||||||
|
'AMMBid: Asset must be an Issue',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field Asset2`, function () {
|
||||||
|
delete bid.Asset2
|
||||||
|
assert.throws(
|
||||||
|
() => validate(bid),
|
||||||
|
ValidationError,
|
||||||
|
'AMMBid: missing field Asset2',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Asset2 must be an Issue`, function () {
|
||||||
|
bid.Asset2 = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(bid),
|
||||||
|
ValidationError,
|
||||||
|
'AMMBid: Asset2 must be an Issue',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ BidMin must be an Amount`, function () {
|
||||||
|
bid.BidMin = 5
|
||||||
|
assert.throws(
|
||||||
|
() => validate(bid),
|
||||||
|
ValidationError,
|
||||||
|
'AMMBid: BidMin must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ BidMax must be an Amount`, function () {
|
||||||
|
bid.BidMax = 10
|
||||||
|
assert.throws(
|
||||||
|
() => validate(bid),
|
||||||
|
ValidationError,
|
||||||
|
'AMMBid: BidMax must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ AuthAccounts length must not be greater than 4`, function () {
|
||||||
|
bid.AuthAccounts.push({
|
||||||
|
AuthAccount: {
|
||||||
|
Account: 'r3X6noRsvaLapAKCG78zAtWcbhB3sggS1s',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => validate(bid),
|
||||||
|
ValidationError,
|
||||||
|
'AMMBid: AuthAccounts length must not be greater than 4',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
103
packages/xrpl/test/models/AMMCreate.test.ts
Normal file
103
packages/xrpl/test/models/AMMCreate.test.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
|
import { validate, ValidationError } from '../../src'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMCreate Transaction Verification Testing.
|
||||||
|
*
|
||||||
|
* Providing runtime verification testing for each specific transaction type.
|
||||||
|
*/
|
||||||
|
describe('AMMCreate', function () {
|
||||||
|
let ammCreate
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
ammCreate = {
|
||||||
|
TransactionType: 'AMMCreate',
|
||||||
|
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||||
|
Amount: '1000',
|
||||||
|
Amount2: {
|
||||||
|
currency: 'USD',
|
||||||
|
issuer: 'rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9',
|
||||||
|
value: '1000',
|
||||||
|
},
|
||||||
|
TradingFee: 12,
|
||||||
|
Sequence: 1337,
|
||||||
|
} as any
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMCreate`, function () {
|
||||||
|
assert.doesNotThrow(() => validate(ammCreate))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing Amount`, function () {
|
||||||
|
delete ammCreate.Amount
|
||||||
|
assert.throws(
|
||||||
|
() => validate(ammCreate),
|
||||||
|
ValidationError,
|
||||||
|
'AMMCreate: missing field Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Amount must be an Amount`, function () {
|
||||||
|
ammCreate.Amount = 1000
|
||||||
|
assert.throws(
|
||||||
|
() => validate(ammCreate),
|
||||||
|
ValidationError,
|
||||||
|
'AMMCreate: Amount must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing Amount2`, function () {
|
||||||
|
delete ammCreate.Amount2
|
||||||
|
assert.throws(
|
||||||
|
() => validate(ammCreate),
|
||||||
|
ValidationError,
|
||||||
|
'AMMCreate: missing field Amount2',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Amount2 must be an Amount`, function () {
|
||||||
|
ammCreate.Amount2 = 1000
|
||||||
|
assert.throws(
|
||||||
|
() => validate(ammCreate),
|
||||||
|
ValidationError,
|
||||||
|
'AMMCreate: Amount2 must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing TradingFee`, function () {
|
||||||
|
delete ammCreate.TradingFee
|
||||||
|
assert.throws(
|
||||||
|
() => validate(ammCreate),
|
||||||
|
ValidationError,
|
||||||
|
'AMMCreate: missing field TradingFee',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ TradingFee must be a number`, function () {
|
||||||
|
ammCreate.TradingFee = '12'
|
||||||
|
assert.throws(
|
||||||
|
() => validate(ammCreate),
|
||||||
|
ValidationError,
|
||||||
|
'AMMCreate: TradingFee must be a number',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws when TradingFee is greater than 1000`, function () {
|
||||||
|
ammCreate.TradingFee = 1001
|
||||||
|
assert.throws(
|
||||||
|
() => validate(ammCreate),
|
||||||
|
ValidationError,
|
||||||
|
`AMMCreate: TradingFee must be between 0 and 1000`,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws when TradingFee is a negative number`, function () {
|
||||||
|
ammCreate.TradingFee = -1
|
||||||
|
assert.throws(
|
||||||
|
() => validate(ammCreate),
|
||||||
|
ValidationError,
|
||||||
|
`AMMCreate: TradingFee must be between 0 and 1000`,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
175
packages/xrpl/test/models/AMMDeposit.test.ts
Normal file
175
packages/xrpl/test/models/AMMDeposit.test.ts
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/* eslint-disable no-bitwise -- bitwise necessary for enabling flags */
|
||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
|
import { AMMDepositFlags, validate, ValidationError } from '../../src'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMDeposit Transaction Verification Testing.
|
||||||
|
*
|
||||||
|
* Providing runtime verification testing for each specific transaction type.
|
||||||
|
*/
|
||||||
|
describe('AMMDeposit', function () {
|
||||||
|
const LPTokenOut = {
|
||||||
|
currency: 'B3813FCAB4EE68B3D0D735D6849465A9113EE048',
|
||||||
|
issuer: 'rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg',
|
||||||
|
value: '1000',
|
||||||
|
}
|
||||||
|
let deposit
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
deposit = {
|
||||||
|
TransactionType: 'AMMDeposit',
|
||||||
|
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||||
|
Asset: {
|
||||||
|
currency: 'XRP',
|
||||||
|
},
|
||||||
|
Asset2: {
|
||||||
|
currency: 'ETH',
|
||||||
|
issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd',
|
||||||
|
},
|
||||||
|
Sequence: 1337,
|
||||||
|
Flags: 0,
|
||||||
|
} as any
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMDeposit with LPTokenOut`, function () {
|
||||||
|
deposit.LPTokenOut = LPTokenOut
|
||||||
|
deposit.Flags |= AMMDepositFlags.tfLPToken
|
||||||
|
assert.doesNotThrow(() => validate(deposit))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMDeposit with Amount`, function () {
|
||||||
|
deposit.Amount = '1000'
|
||||||
|
deposit.Flags |= AMMDepositFlags.tfSingleAsset
|
||||||
|
assert.doesNotThrow(() => validate(deposit))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMDeposit with Amount and Amount2`, function () {
|
||||||
|
deposit.Amount = '1000'
|
||||||
|
deposit.Amount2 = {
|
||||||
|
currency: 'ETH',
|
||||||
|
issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd',
|
||||||
|
value: '2.5',
|
||||||
|
}
|
||||||
|
deposit.Flags |= AMMDepositFlags.tfTwoAsset
|
||||||
|
assert.doesNotThrow(() => validate(deposit))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMDeposit with Amount and LPTokenOut`, function () {
|
||||||
|
deposit.Amount = '1000'
|
||||||
|
deposit.LPTokenOut = LPTokenOut
|
||||||
|
deposit.Flags |= AMMDepositFlags.tfOneAssetLPToken
|
||||||
|
assert.doesNotThrow(() => validate(deposit))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMDeposit with Amount and EPrice`, function () {
|
||||||
|
deposit.Amount = '1000'
|
||||||
|
deposit.EPrice = '25'
|
||||||
|
deposit.Flags |= AMMDepositFlags.tfLimitLPToken
|
||||||
|
assert.doesNotThrow(() => validate(deposit))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field Asset`, function () {
|
||||||
|
delete deposit.Asset
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: missing field Asset',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Asset must be an Issue`, function () {
|
||||||
|
deposit.Asset = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: Asset must be an Issue',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field Asset2`, function () {
|
||||||
|
delete deposit.Asset2
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: missing field Asset2',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Asset2 must be an Issue`, function () {
|
||||||
|
deposit.Asset2 = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: Asset2 must be an Issue',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ must set at least LPTokenOut or Amount`, function () {
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: must set at least LPTokenOut or Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ must set Amount with Amount2`, function () {
|
||||||
|
deposit.Amount2 = {
|
||||||
|
currency: 'ETH',
|
||||||
|
issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd',
|
||||||
|
value: '2.5',
|
||||||
|
}
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: must set Amount with Amount2',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ must set Amount with EPrice`, function () {
|
||||||
|
deposit.EPrice = '25'
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: must set Amount with EPrice',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ LPTokenOut must be an IssuedCurrencyAmount`, function () {
|
||||||
|
deposit.LPTokenOut = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: LPTokenOut must be an IssuedCurrencyAmount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Amount must be an Amount`, function () {
|
||||||
|
deposit.Amount = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: Amount must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Amount2 must be an Amount`, function () {
|
||||||
|
deposit.Amount = '1000'
|
||||||
|
deposit.Amount2 = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: Amount2 must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ EPrice must be an Amount`, function () {
|
||||||
|
deposit.Amount = '1000'
|
||||||
|
deposit.EPrice = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(deposit),
|
||||||
|
ValidationError,
|
||||||
|
'AMMDeposit: EPrice must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
104
packages/xrpl/test/models/AMMVote.test.ts
Normal file
104
packages/xrpl/test/models/AMMVote.test.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
|
import { validate, ValidationError } from '../../src'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMVote Transaction Verification Testing.
|
||||||
|
*
|
||||||
|
* Providing runtime verification testing for each specific transaction type.
|
||||||
|
*/
|
||||||
|
describe('AMMVote', function () {
|
||||||
|
let vote
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
vote = {
|
||||||
|
TransactionType: 'AMMVote',
|
||||||
|
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||||
|
Asset: {
|
||||||
|
currency: 'XRP',
|
||||||
|
},
|
||||||
|
Asset2: {
|
||||||
|
currency: 'ETH',
|
||||||
|
issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd',
|
||||||
|
},
|
||||||
|
TradingFee: 25,
|
||||||
|
Sequence: 1337,
|
||||||
|
} as any
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMVote`, function () {
|
||||||
|
assert.doesNotThrow(() => validate(vote))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field Asset`, function () {
|
||||||
|
delete vote.Asset
|
||||||
|
assert.throws(
|
||||||
|
() => validate(vote),
|
||||||
|
ValidationError,
|
||||||
|
'AMMVote: missing field Asset',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Asset must be an Issue`, function () {
|
||||||
|
vote.Asset = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(vote),
|
||||||
|
ValidationError,
|
||||||
|
'AMMVote: Asset must be an Issue',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field Asset2`, function () {
|
||||||
|
delete vote.Asset2
|
||||||
|
assert.throws(
|
||||||
|
() => validate(vote),
|
||||||
|
ValidationError,
|
||||||
|
'AMMVote: missing field Asset2',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Asset2 must be an Issue`, function () {
|
||||||
|
vote.Asset2 = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(vote),
|
||||||
|
ValidationError,
|
||||||
|
'AMMVote: Asset2 must be an Issue',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field TradingFee`, function () {
|
||||||
|
delete vote.TradingFee
|
||||||
|
assert.throws(
|
||||||
|
() => validate(vote),
|
||||||
|
ValidationError,
|
||||||
|
'AMMVote: missing field TradingFee',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ TradingFee must be a number`, function () {
|
||||||
|
vote.TradingFee = '25'
|
||||||
|
assert.throws(
|
||||||
|
() => validate(vote),
|
||||||
|
ValidationError,
|
||||||
|
'AMMVote: TradingFee must be a number',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws when TradingFee is greater than AMM_MAX_TRADING_FEE`, function () {
|
||||||
|
vote.TradingFee = 1001
|
||||||
|
assert.throws(
|
||||||
|
() => validate(vote),
|
||||||
|
ValidationError,
|
||||||
|
'AMMVote: TradingFee must be between 0 and 1000',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws when TradingFee is a negative number`, function () {
|
||||||
|
vote.TradingFee = -1
|
||||||
|
assert.throws(
|
||||||
|
() => validate(vote),
|
||||||
|
ValidationError,
|
||||||
|
'AMMVote: TradingFee must be between 0 and 1000',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
178
packages/xrpl/test/models/AMMWithdraw.test.ts
Normal file
178
packages/xrpl/test/models/AMMWithdraw.test.ts
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
/* eslint-disable no-bitwise -- bitwise necessary for enabling flags */
|
||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
|
import { AMMWithdrawFlags, validate, ValidationError } from '../../src'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMMWithdraw Transaction Verification Testing.
|
||||||
|
*
|
||||||
|
* Providing runtime verification testing for each specific transaction type.
|
||||||
|
*/
|
||||||
|
describe('AMMWithdraw', function () {
|
||||||
|
const LPTokenIn = {
|
||||||
|
currency: 'B3813FCAB4EE68B3D0D735D6849465A9113EE048',
|
||||||
|
issuer: 'rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg',
|
||||||
|
value: '1000',
|
||||||
|
}
|
||||||
|
let withdraw
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
withdraw = {
|
||||||
|
TransactionType: 'AMMWithdraw',
|
||||||
|
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||||
|
Asset: {
|
||||||
|
currency: 'XRP',
|
||||||
|
},
|
||||||
|
Asset2: {
|
||||||
|
currency: 'ETH',
|
||||||
|
issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd',
|
||||||
|
},
|
||||||
|
Sequence: 1337,
|
||||||
|
Flags: 0,
|
||||||
|
} as any
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMWithdraw with LPTokenIn`, function () {
|
||||||
|
withdraw.LPTokenIn = LPTokenIn
|
||||||
|
withdraw.Flags |= AMMWithdrawFlags.tfLPToken
|
||||||
|
assert.doesNotThrow(() => validate(withdraw))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMWithdraw with Amount`, function () {
|
||||||
|
withdraw.Amount = '1000'
|
||||||
|
withdraw.Flags |= AMMWithdrawFlags.tfSingleAsset
|
||||||
|
assert.doesNotThrow(() => validate(withdraw))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMWithdraw with Amount and Amount2`, function () {
|
||||||
|
withdraw.Amount = '1000'
|
||||||
|
withdraw.Amount2 = {
|
||||||
|
currency: 'ETH',
|
||||||
|
issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd',
|
||||||
|
value: '2.5',
|
||||||
|
}
|
||||||
|
withdraw.Flags |= AMMWithdrawFlags.tfTwoAsset
|
||||||
|
assert.doesNotThrow(() => validate(withdraw))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMWithdraw with Amount and LPTokenIn`, function () {
|
||||||
|
withdraw.Amount = '1000'
|
||||||
|
withdraw.LPTokenIn = LPTokenIn
|
||||||
|
withdraw.Flags |= AMMWithdrawFlags.tfOneAssetLPToken
|
||||||
|
assert.doesNotThrow(() => validate(withdraw))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMWithdraw with Amount and EPrice`, function () {
|
||||||
|
withdraw.Amount = '1000'
|
||||||
|
withdraw.EPrice = '25'
|
||||||
|
withdraw.Flags |= AMMWithdrawFlags.tfLimitLPToken
|
||||||
|
assert.doesNotThrow(() => validate(withdraw))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMWithdraw one asset withdraw all`, function () {
|
||||||
|
withdraw.Amount = '1000'
|
||||||
|
withdraw.Flags |= AMMWithdrawFlags.tfOneAssetWithdrawAll
|
||||||
|
assert.doesNotThrow(() => validate(withdraw))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`verifies valid AMMWithdraw withdraw all`, function () {
|
||||||
|
withdraw.Flags |= AMMWithdrawFlags.tfWithdrawAll
|
||||||
|
assert.doesNotThrow(() => validate(withdraw))
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field Asset`, function () {
|
||||||
|
delete withdraw.Asset
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: missing field Asset',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Asset must be an Issue`, function () {
|
||||||
|
withdraw.Asset = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: Asset must be an Issue',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ missing field Asset2`, function () {
|
||||||
|
delete withdraw.Asset2
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: missing field Asset2',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Asset2 must be an Issue`, function () {
|
||||||
|
withdraw.Asset2 = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: Asset2 must be an Issue',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ must set Amount with Amount2`, function () {
|
||||||
|
withdraw.Amount2 = {
|
||||||
|
currency: 'ETH',
|
||||||
|
issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd',
|
||||||
|
value: '2.5',
|
||||||
|
}
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: must set Amount with Amount2',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ must set Amount with EPrice`, function () {
|
||||||
|
withdraw.EPrice = '25'
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: must set Amount with EPrice',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ LPTokenIn must be an IssuedCurrencyAmount`, function () {
|
||||||
|
withdraw.LPTokenIn = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: LPTokenIn must be an IssuedCurrencyAmount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Amount must be an Amount`, function () {
|
||||||
|
withdraw.Amount = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: Amount must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ Amount2 must be an Amount`, function () {
|
||||||
|
withdraw.Amount = '1000'
|
||||||
|
withdraw.Amount2 = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: Amount2 must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`throws w/ EPrice must be an Amount`, function () {
|
||||||
|
withdraw.Amount = '1000'
|
||||||
|
withdraw.EPrice = 1234
|
||||||
|
assert.throws(
|
||||||
|
() => validate(withdraw),
|
||||||
|
ValidationError,
|
||||||
|
'AMMWithdraw: EPrice must be an Amount',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -82,12 +82,12 @@ describe('EscrowCreate', function () {
|
|||||||
assert.throws(
|
assert.throws(
|
||||||
() => validateEscrowCreate(escrow),
|
() => validateEscrowCreate(escrow),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'EscrowCreate: Amount must be an Amount',
|
'EscrowCreate: Amount must be a string',
|
||||||
)
|
)
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => validate(escrow),
|
() => validate(escrow),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'EscrowCreate: Amount must be an Amount',
|
'EscrowCreate: Amount must be a string',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -77,12 +77,12 @@ describe('PaymentChannelClaim', function () {
|
|||||||
assert.throws(
|
assert.throws(
|
||||||
() => validatePaymentChannelClaim(channel),
|
() => validatePaymentChannelClaim(channel),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'PaymentChannelClaim: Balance must be an Amount',
|
'PaymentChannelClaim: Balance must be a string',
|
||||||
)
|
)
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => validate(channel),
|
() => validate(channel),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'PaymentChannelClaim: Balance must be an Amount',
|
'PaymentChannelClaim: Balance must be a string',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -92,12 +92,12 @@ describe('PaymentChannelClaim', function () {
|
|||||||
assert.throws(
|
assert.throws(
|
||||||
() => validatePaymentChannelClaim(channel),
|
() => validatePaymentChannelClaim(channel),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'PaymentChannelClaim: Amount must be an Amount',
|
'PaymentChannelClaim: Amount must be a string',
|
||||||
)
|
)
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => validate(channel),
|
() => validate(channel),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'PaymentChannelClaim: Amount must be an Amount',
|
'PaymentChannelClaim: Amount must be a string',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -106,12 +106,12 @@ describe('PaymentChannelCreate', function () {
|
|||||||
assert.throws(
|
assert.throws(
|
||||||
() => validatePaymentChannelCreate(channel),
|
() => validatePaymentChannelCreate(channel),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'PaymentChannelCreate: Amount must be an Amount',
|
'PaymentChannelCreate: Amount must be a string',
|
||||||
)
|
)
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => validate(channel),
|
() => validate(channel),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'PaymentChannelCreate: Amount must be an Amount',
|
'PaymentChannelCreate: Amount must be a string',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -70,12 +70,12 @@ describe('PaymentChannelFund', function () {
|
|||||||
assert.throws(
|
assert.throws(
|
||||||
() => validatePaymentChannelFund(channel),
|
() => validatePaymentChannelFund(channel),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'PaymentChannelFund: Amount must be an Amount',
|
'PaymentChannelFund: Amount must be a string',
|
||||||
)
|
)
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => validate(channel),
|
() => validate(channel),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
'PaymentChannelFund: Amount must be an Amount',
|
'PaymentChannelFund: Amount must be a string',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ describe('SetHook', function () {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it(`throws w/ maximum of 10 members allowed in Hooks`, function () {
|
it(`throws w/ maximum of 4 members allowed in Hooks`, function () {
|
||||||
setHookTx.Hooks = []
|
setHookTx.Hooks = []
|
||||||
const hook = {
|
const hook = {
|
||||||
Hook: {
|
Hook: {
|
||||||
@@ -88,14 +88,8 @@ describe('SetHook', function () {
|
|||||||
setHookTx.Hooks.push(hook)
|
setHookTx.Hooks.push(hook)
|
||||||
setHookTx.Hooks.push(hook)
|
setHookTx.Hooks.push(hook)
|
||||||
setHookTx.Hooks.push(hook)
|
setHookTx.Hooks.push(hook)
|
||||||
setHookTx.Hooks.push(hook)
|
|
||||||
setHookTx.Hooks.push(hook)
|
|
||||||
setHookTx.Hooks.push(hook)
|
|
||||||
setHookTx.Hooks.push(hook)
|
|
||||||
setHookTx.Hooks.push(hook)
|
|
||||||
setHookTx.Hooks.push(hook)
|
|
||||||
|
|
||||||
const errorMessage = 'SetHook: maximum of 10 hooks allowed in Hooks'
|
const errorMessage = 'SetHook: maximum of 4 hooks allowed in Hooks'
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => validateSetHook(setHookTx),
|
() => validateSetHook(setHookTx),
|
||||||
ValidationError,
|
ValidationError,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
import { encode } from '@transia/ripple-binary-codec'
|
|
||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
import { encode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import { OfferCreate, Transaction, ValidationError } from '../../src'
|
import { OfferCreate, Transaction, ValidationError } from '../../src'
|
||||||
import {
|
import {
|
||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
hashAccountRoot,
|
hashAccountRoot,
|
||||||
hashOfferId,
|
hashOfferId,
|
||||||
hashSignerListId,
|
hashSignerListId,
|
||||||
hashURIToken,
|
|
||||||
} from '../../src/utils/hashes'
|
} from '../../src/utils/hashes'
|
||||||
import fixtures from '../fixtures/rippled'
|
import fixtures from '../fixtures/rippled'
|
||||||
import { assertResultMatch } from '../testUtils'
|
import { assertResultMatch } from '../testUtils'
|
||||||
@@ -144,16 +143,6 @@ describe('Hashes', function () {
|
|||||||
assert.equal(actualEntryHash, expectedEntryHash)
|
assert.equal(actualEntryHash, expectedEntryHash)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calcURITokenEntryHash', function () {
|
|
||||||
const issuer = 'rDx69ebzbowuqztksVDmZXjizTd12BVr4x'
|
|
||||||
const uri = 'ipfs://cid'
|
|
||||||
const expectedEntryHash =
|
|
||||||
'AFC4233E5C4094952DEF5483DC41488C8744D1268F897C0CB25DE66399591399'
|
|
||||||
const actualEntryHash = hashURIToken(issuer, uri)
|
|
||||||
|
|
||||||
assert.equal(actualEntryHash, expectedEntryHash)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Hash a signed transaction correctly', function () {
|
it('Hash a signed transaction correctly', function () {
|
||||||
const expected_hash =
|
const expected_hash =
|
||||||
'458101D51051230B1D56E9ACAFAA34451BF65FA000F95DF6F0FF5B3A62D83FC2'
|
'458101D51051230B1D56E9ACAFAA34451BF65FA000F95DF6F0FF5B3A62D83FC2'
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
|
||||||
import { calculateHookOn, hexHookParameters, TTS } from '../../src'
|
import {
|
||||||
|
calculateHookOn,
|
||||||
|
hexNamespace,
|
||||||
|
hexHookParameters,
|
||||||
|
TTS,
|
||||||
|
} from '../../src'
|
||||||
|
|
||||||
describe('test hook on', function () {
|
describe('test hook on', function () {
|
||||||
it('invalid', function () {
|
it('invalid', function () {
|
||||||
@@ -26,6 +31,16 @@ describe('test hook on', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('test hook namespace', function () {
|
||||||
|
it('basic', async function () {
|
||||||
|
const result = await hexNamespace('starter')
|
||||||
|
assert.equal(
|
||||||
|
result,
|
||||||
|
'4FF9961269BF7630D32E15276569C94470174A5DA79FA567C0F62251AA9A36B9',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('test hook parameters', function () {
|
describe('test hook parameters', function () {
|
||||||
it('basic', async function () {
|
it('basic', async function () {
|
||||||
const parameters = [
|
const parameters = [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { decode } from '@transia/ripple-binary-codec'
|
|
||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
import { decode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import { NFTokenMint, Payment, Transaction } from '../../src'
|
import { NFTokenMint, Payment, Transaction } from '../../src'
|
||||||
import ECDSA from '../../src/ECDSA'
|
import ECDSA from '../../src/ECDSA'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { decode, encode } from '@transia/ripple-binary-codec'
|
|
||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
import { decode, encode } from 'ripple-binary-codec'
|
||||||
|
|
||||||
import { Transaction, ValidationError } from '../../src'
|
import { Transaction, ValidationError } from '../../src'
|
||||||
import Wallet from '../../src/Wallet'
|
import Wallet from '../../src/Wallet'
|
||||||
|
|||||||
Reference in New Issue
Block a user