mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-02 18:15:56 +00:00
Compare commits
41 Commits
beta
...
denis-urit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
015f92d9e7 | ||
|
|
10ea540984 | ||
|
|
a47d7e34a7 | ||
|
|
77e475ae2d | ||
|
|
925eee464c | ||
|
|
3e929eff56 | ||
|
|
e1a3594ff3 | ||
|
|
f570b89d71 | ||
|
|
0b4cd01f94 | ||
|
|
93b15ee9f6 | ||
|
|
29b718b52e | ||
|
|
b127b2e616 | ||
|
|
f85f35cb4d | ||
|
|
f292d9e716 | ||
|
|
c167b3a22d | ||
|
|
baae6b9a9a | ||
|
|
25ab1d08fc | ||
|
|
9a0e2aa8f8 | ||
|
|
8779ef41d7 | ||
|
|
606babe01a | ||
|
|
4fbd5383c4 | ||
|
|
a97c7bb21b | ||
|
|
c00e36bf50 | ||
|
|
c24197f202 | ||
|
|
d50417acbc | ||
|
|
f8b7c6ab15 | ||
|
|
678c5f5fda | ||
|
|
6264c5f3f7 | ||
|
|
f80d6e1747 | ||
|
|
df1897be10 | ||
|
|
bcbba483c5 | ||
|
|
0560a5867f | ||
|
|
f19466cabe | ||
|
|
f6a90a31c4 | ||
|
|
818d12d68c | ||
|
|
277288f1e9 | ||
|
|
ee59c64b65 | ||
|
|
d36349e410 | ||
|
|
2e38cf54a8 | ||
|
|
3a2a0918f8 | ||
|
|
6d6b5a5863 |
4130
package-lock.json
generated
4130
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
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.6-alpha.0",
|
"version": "4.2.8-alpha.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ripple-address-codec",
|
"name": "ripple-address-codec",
|
||||||
"version": "4.2.6-alpha.0",
|
"version": "4.2.8-alpha.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"base-x": "^3.0.9",
|
"base-x": "^3.0.9",
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-address-codec",
|
"name": "@transia/ripple-address-codec",
|
||||||
"publishConfig": {
|
"version": "4.2.8-alpha.0",
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"version": "4.2.6-alpha.0",
|
|
||||||
"description": "encodes/decodes base58 encoded XRP Ledger identifiers",
|
"description": "encodes/decodes base58 encoded XRP Ledger identifiers",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-binary-codec",
|
"name": "@transia/ripple-binary-codec",
|
||||||
"publishConfig": {
|
"version": "1.4.6-alpha.1",
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"version": "1.4.4-alpha.3",
|
|
||||||
"description": "XRP Ledger binary codec",
|
"description": "XRP Ledger binary codec",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
@@ -15,7 +12,7 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.6-alpha.0",
|
"@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",
|
||||||
@@ -42,6 +39,5 @@
|
|||||||
"prettier": "@xrplf/prettier-config",
|
"prettier": "@xrplf/prettier-config",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
},
|
}
|
||||||
"gitHead": "943142cb73821de7a4662cc660c5693a3ec2ff81"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -786,6 +786,26 @@
|
|||||||
"type": "UInt32"
|
"type": "UInt32"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"FirstNFTokenSequence",
|
||||||
|
{
|
||||||
|
"nth": 50,
|
||||||
|
"isVLEncoded": false,
|
||||||
|
"isSerialized": true,
|
||||||
|
"isSigningField": true,
|
||||||
|
"type": "UInt32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ImportSequence",
|
||||||
|
{
|
||||||
|
"nth": 97,
|
||||||
|
"isVLEncoded": false,
|
||||||
|
"isSerialized": true,
|
||||||
|
"isSigningField": true,
|
||||||
|
"type": "UInt32"
|
||||||
|
}
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"IndexNext",
|
"IndexNext",
|
||||||
{
|
{
|
||||||
@@ -1496,6 +1516,36 @@
|
|||||||
"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",
|
||||||
{
|
{
|
||||||
@@ -2275,6 +2325,8 @@
|
|||||||
"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,
|
||||||
@@ -2346,6 +2398,7 @@
|
|||||||
"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,
|
||||||
|
|
||||||
"terRETRY": -99,
|
"terRETRY": -99,
|
||||||
"terFUNDS_SPENT": -98,
|
"terFUNDS_SPENT": -98,
|
||||||
@@ -2435,7 +2488,8 @@
|
|||||||
"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,
|
||||||
@@ -2472,6 +2526,7 @@
|
|||||||
"URITokenBuy": 47,
|
"URITokenBuy": 47,
|
||||||
"URITokenCreateSellOffer": 48,
|
"URITokenCreateSellOffer": 48,
|
||||||
"URITokenCancelSellOffer": 49,
|
"URITokenCancelSellOffer": 49,
|
||||||
|
"Import": 97,
|
||||||
"Invoke": 99,
|
"Invoke": 99,
|
||||||
"EnableAmendment": 100,
|
"EnableAmendment": 100,
|
||||||
"SetFee": 101,
|
"SetFee": 101,
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-keypairs",
|
"name": "@transia/ripple-keypairs",
|
||||||
"publishConfig": {
|
"version": "1.1.8-alpha.0",
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"version": "1.1.6-alpha.3",
|
|
||||||
"description": "Cryptographic key pairs for the XRP Ledger",
|
"description": "Cryptographic key pairs for the XRP Ledger",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -b",
|
"build": "tsc -b",
|
||||||
@@ -20,7 +17,7 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.6-alpha.0",
|
"@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",
|
||||||
@@ -34,6 +31,5 @@
|
|||||||
"prettier": "@xrplf/prettier-config",
|
"prettier": "@xrplf/prettier-config",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
},
|
}
|
||||||
"gitHead": "943142cb73821de7a4662cc660c5693a3ec2ff81"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/xrpl",
|
"name": "@transia/xrpl",
|
||||||
"publishConfig": {
|
"version": "2.7.3-alpha.1",
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"version": "2.7.1-alpha.6",
|
|
||||||
"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": [
|
||||||
@@ -25,9 +22,9 @@
|
|||||||
"https-proxy-agent": false
|
"https-proxy-agent": false
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.6-alpha.0",
|
"@transia/ripple-address-codec": "^4.2.8-alpha.0",
|
||||||
"@transia/ripple-binary-codec": "^1.4.4-alpha.3",
|
"@transia/ripple-binary-codec": "^1.4.6-alpha.1",
|
||||||
"@transia/ripple-keypairs": "^1.1.6-alpha.3",
|
"@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",
|
||||||
@@ -83,6 +80,5 @@
|
|||||||
"readmeFilename": "README.md",
|
"readmeFilename": "README.md",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.13.0"
|
"node": ">=10.13.0"
|
||||||
},
|
}
|
||||||
"gitHead": "943142cb73821de7a4662cc660c5693a3ec2ff81"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
/* 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 {
|
||||||
|
classicAddressToXAddress,
|
||||||
|
isValidXAddress,
|
||||||
|
xAddressToClassicAddress,
|
||||||
|
encodeSeed,
|
||||||
|
} from '@transia/ripple-address-codec'
|
||||||
import {
|
import {
|
||||||
decode,
|
decode,
|
||||||
encodeForSigning,
|
encodeForSigning,
|
||||||
@@ -17,12 +23,6 @@ import { fromSeed } from 'bip32'
|
|||||||
import { mnemonicToSeedSync, validateMnemonic } from 'bip39'
|
import { mnemonicToSeedSync, validateMnemonic } from 'bip39'
|
||||||
import isEqual from 'lodash/isEqual'
|
import isEqual from 'lodash/isEqual'
|
||||||
import omitBy from 'lodash/omitBy'
|
import omitBy from 'lodash/omitBy'
|
||||||
import {
|
|
||||||
classicAddressToXAddress,
|
|
||||||
isValidXAddress,
|
|
||||||
xAddressToClassicAddress,
|
|
||||||
encodeSeed,
|
|
||||||
} from '@transia/ripple-address-codec'
|
|
||||||
|
|
||||||
import ECDSA from '../ECDSA'
|
import ECDSA from '../ECDSA'
|
||||||
import { ValidationError, XrplError } from '../errors'
|
import { ValidationError, XrplError } from '../errors'
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { decodeAccountID } from '@transia/ripple-address-codec'
|
||||||
import {
|
import {
|
||||||
decode,
|
decode,
|
||||||
encode,
|
encode,
|
||||||
@@ -7,7 +8,6 @@ import {
|
|||||||
import { sign as signWithKeypair, verify } from '@transia/ripple-keypairs'
|
import { sign as signWithKeypair, verify } from '@transia/ripple-keypairs'
|
||||||
import { BigNumber } from 'bignumber.js'
|
import { BigNumber } from 'bignumber.js'
|
||||||
import { flatMap } from 'lodash'
|
import { flatMap } from 'lodash'
|
||||||
import { decodeAccountID } from '@transia/ripple-address-codec'
|
|
||||||
|
|
||||||
import { ValidationError } from '../errors'
|
import { ValidationError } from '../errors'
|
||||||
import { Signer } from '../models/common'
|
import { Signer } from '../models/common'
|
||||||
|
|||||||
@@ -97,14 +97,15 @@ 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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ export interface BaseTransaction {
|
|||||||
*/
|
*/
|
||||||
NetworkID?: number
|
NetworkID?: number
|
||||||
/**
|
/**
|
||||||
* The hook parameters of the transaction
|
* The hook parameters of the transaction.
|
||||||
*/
|
*/
|
||||||
HookParameters?: HookParameter[]
|
HookParameters?: HookParameter[]
|
||||||
}
|
}
|
||||||
|
|||||||
24
packages/xrpl/src/models/transactions/import.ts
Normal file
24
packages/xrpl/src/models/transactions/import.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @category Transaction Models
|
||||||
|
*/
|
||||||
|
export interface Import extends BaseTransaction {
|
||||||
|
TransactionType: 'Import'
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ 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'
|
||||||
@@ -43,7 +44,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 { SetHook } from './setHook'
|
export { SetHookFlagsInterface, SetHookFlags, 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,6 +13,10 @@ 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,5 +1,19 @@
|
|||||||
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: number
|
||||||
|
HookReturnString: string
|
||||||
|
HookStateChangeCount: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export interface CreatedNode {
|
export interface CreatedNode {
|
||||||
CreatedNode: {
|
CreatedNode: {
|
||||||
LedgerEntryType: string
|
LedgerEntryType: string
|
||||||
@@ -29,20 +43,6 @@ export interface DeletedNode {
|
|||||||
|
|
||||||
export type Node = CreatedNode | ModifiedNode | DeletedNode
|
export type Node = CreatedNode | ModifiedNode | DeletedNode
|
||||||
|
|
||||||
export interface HookExecution {
|
|
||||||
HookExecution: {
|
|
||||||
HookAccount: string
|
|
||||||
HookEmitCount: number
|
|
||||||
HookExecutionIndex: number
|
|
||||||
HookHash: string
|
|
||||||
HookInstructionCount: string
|
|
||||||
HookResult: number
|
|
||||||
HookReturnCode: number
|
|
||||||
HookReturnString: string
|
|
||||||
HookStateChangeCount: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A typeguard to check if a node is a CreatedNode.
|
* A typeguard to check if a node is a CreatedNode.
|
||||||
*
|
*
|
||||||
@@ -74,10 +74,10 @@ 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
|
||||||
HookExecutions: HookExecution[]
|
|
||||||
delivered_amount?: Amount | 'unavailable'
|
delivered_amount?: Amount | 'unavailable'
|
||||||
TransactionIndex: number
|
TransactionIndex: number
|
||||||
TransactionResult: string
|
TransactionResult: string
|
||||||
|
|||||||
@@ -1,7 +1,30 @@
|
|||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import { Hook } from '../common'
|
import { Hook } from '../common'
|
||||||
|
|
||||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum representing values for Set Hook Transaction Flags.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*/
|
||||||
|
export enum SetHookFlags {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
hsfOverride = 0x00000001,
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
hsfNSDelete = 0x00000010,
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
hsfCollect = 0x00000100,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SetHookFlagsInterface extends GlobalFlags {
|
||||||
|
hsfOverride?: boolean
|
||||||
|
hsfNSDelete?: boolean
|
||||||
|
hsfCollect?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -14,6 +37,8 @@ export interface SetHook extends BaseTransaction {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Hooks: Hook[]
|
Hooks: Hook[]
|
||||||
|
|
||||||
|
Flags?: number | SetHookFlagsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_HOOKS = 4
|
const MAX_HOOKS = 4
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ 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 { Invoke, validateInvoke } from './invoke'
|
||||||
import { TransactionMetadata } from './metadata'
|
import { TransactionMetadata } from './metadata'
|
||||||
import {
|
import {
|
||||||
@@ -74,6 +75,7 @@ export type Transaction =
|
|||||||
| EscrowCancel
|
| EscrowCancel
|
||||||
| EscrowCreate
|
| EscrowCreate
|
||||||
| EscrowFinish
|
| EscrowFinish
|
||||||
|
| Import
|
||||||
| Invoke
|
| Invoke
|
||||||
| NFTokenAcceptOffer
|
| NFTokenAcceptOffer
|
||||||
| NFTokenBurn
|
| NFTokenBurn
|
||||||
@@ -160,6 +162,10 @@ export function validate(transaction: Record<string, unknown>): void {
|
|||||||
validateEscrowFinish(tx)
|
validateEscrowFinish(tx)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'Import':
|
||||||
|
validateImport(tx)
|
||||||
|
break
|
||||||
|
|
||||||
case 'Invoke':
|
case 'Invoke':
|
||||||
validateInvoke(tx)
|
validateInvoke(tx)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
/* 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,
|
||||||
@@ -20,6 +21,7 @@ import {
|
|||||||
PaymentChannelClaimFlagsInterface,
|
PaymentChannelClaimFlagsInterface,
|
||||||
PaymentChannelClaimFlags,
|
PaymentChannelClaimFlags,
|
||||||
} from '../transactions/paymentChannelClaim'
|
} 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 { TrustSetFlagsInterface, TrustSetFlags } from '../transactions/trustSet'
|
||||||
|
|
||||||
@@ -75,6 +77,15 @@ export function setTransactionFlagsToNumber(tx: Transaction): void {
|
|||||||
case 'TrustSet':
|
case 'TrustSet':
|
||||||
tx.Flags = convertTrustSetFlagsToNumber(tx.Flags)
|
tx.Flags = convertTrustSetFlagsToNumber(tx.Flags)
|
||||||
return
|
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
|
||||||
default:
|
default:
|
||||||
tx.Flags = 0
|
tx.Flags = 0
|
||||||
}
|
}
|
||||||
@@ -108,6 +119,10 @@ function convertTrustSetFlagsToNumber(flags: TrustSetFlagsInterface): number {
|
|||||||
return reduceFlags(flags, TrustSetFlags)
|
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 reduceFlags(flags: GlobalFlags, flagEnum: any): number {
|
||||||
return Object.keys(flags).reduce((resultFlags, flag) => {
|
return Object.keys(flags).reduce((resultFlags, flag) => {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import BigNumber from 'bignumber.js'
|
|
||||||
import {
|
import {
|
||||||
xAddressToClassicAddress,
|
xAddressToClassicAddress,
|
||||||
isValidXAddress,
|
isValidXAddress,
|
||||||
} from '@transia/ripple-address-codec'
|
} from '@transia/ripple-address-codec'
|
||||||
|
import BigNumber from 'bignumber.js'
|
||||||
|
|
||||||
import type { Client } from '..'
|
import type { Client } from '..'
|
||||||
import { ValidationError, XrplError } from '../errors'
|
import { ValidationError, XrplError } from '../errors'
|
||||||
|
|||||||
@@ -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 BigNumber from 'bignumber.js'
|
|
||||||
import { decodeAccountID } from '@transia/ripple-address-codec'
|
import { decodeAccountID } from '@transia/ripple-address-codec'
|
||||||
|
import BigNumber from 'bignumber.js'
|
||||||
|
|
||||||
import hashLedger, {
|
import hashLedger, {
|
||||||
hashLedgerHeader,
|
hashLedgerHeader,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
TRANSACTION_TYPES,
|
TRANSACTION_TYPES,
|
||||||
TRANSACTION_TYPE_MAP,
|
TRANSACTION_TYPE_MAP,
|
||||||
} from '@transia/ripple-binary-codec'
|
} from '@transia/ripple-binary-codec'
|
||||||
import createHash = require('create-hash')
|
// import createHash = require('create-hash')
|
||||||
|
|
||||||
import { XrplError } from '../errors'
|
import { XrplError } from '../errors'
|
||||||
import { HookParameter } from '../models/common'
|
import { HookParameter } from '../models/common'
|
||||||
@@ -58,32 +58,12 @@ export function calculateHookOn(arr: Array<keyof TTS>): string {
|
|||||||
return hash.toUpperCase()
|
return hash.toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function isHex(value: string): boolean {
|
||||||
* Calculate the sha256 of a string
|
return /^[0-9A-F]+$/iu.test(value)
|
||||||
*
|
|
||||||
* @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 {
|
||||||
* Calculate the hex of a namespace
|
return Buffer.from(value, 'utf8').toString('hex').toUpperCase()
|
||||||
*
|
|
||||||
* @param namespace - the namespace to calculate the hex
|
|
||||||
* @returns the hex
|
|
||||||
*/
|
|
||||||
export async function hexNamespace(namespace: string): Promise<string> {
|
|
||||||
return (await sha256(namespace)).toUpperCase()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,31 +75,21 @@ export async function hexNamespace(namespace: string): Promise<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 nameValue
|
let hookPName = parameter.HookParameter.HookParameterName
|
||||||
let valueValue
|
let hookPValue = parameter.HookParameter.HookParameterValue
|
||||||
// eslint-disable-next-line require-unicode-regexp -- Required
|
|
||||||
if (/^[0-9a-fA-F]{2,}$/.exec(parameter.HookParameter.HookParameterName)) {
|
if (!isHex(hookPName)) {
|
||||||
nameValue = parameter.HookParameter.HookParameterName
|
hookPName = hexValue(hookPName)
|
||||||
} else {
|
|
||||||
nameValue = Buffer.from(parameter.HookParameter.HookParameterName, 'utf8')
|
|
||||||
.toString('hex')
|
|
||||||
.toUpperCase()
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line require-unicode-regexp -- Required
|
|
||||||
if (/^[0-9a-fA-F]{2,}$/.exec(parameter.HookParameter.HookParameterValue)) {
|
if (!isHex(hookPValue)) {
|
||||||
valueValue = parameter.HookParameter.HookParameterValue
|
hookPValue = hexValue(hookPValue)
|
||||||
} else {
|
|
||||||
valueValue = Buffer.from(
|
|
||||||
parameter.HookParameter.HookParameterValue,
|
|
||||||
'utf8',
|
|
||||||
)
|
|
||||||
.toString('hex')
|
|
||||||
.toUpperCase()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hookParameters.push({
|
hookParameters.push({
|
||||||
HookParameter: {
|
HookParameter: {
|
||||||
HookParameterName: String(nameValue),
|
HookParameterName: hookPName,
|
||||||
HookParameterValue: String(valueValue),
|
HookParameterValue: hookPValue,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import * as rbc from '@transia/ripple-binary-codec'
|
|
||||||
import { verify as verifyKeypairSignature } from '@transia/ripple-keypairs'
|
|
||||||
import {
|
import {
|
||||||
classicAddressToXAddress,
|
classicAddressToXAddress,
|
||||||
decodeAccountID,
|
decodeAccountID,
|
||||||
@@ -16,6 +14,8 @@ import {
|
|||||||
isValidXAddress,
|
isValidXAddress,
|
||||||
xAddressToClassicAddress,
|
xAddressToClassicAddress,
|
||||||
} from '@transia/ripple-address-codec'
|
} from '@transia/ripple-address-codec'
|
||||||
|
import * as rbc from '@transia/ripple-binary-codec'
|
||||||
|
import { verify as verifyKeypairSignature } from '@transia/ripple-keypairs'
|
||||||
|
|
||||||
import { LedgerEntry } from '../models/ledger'
|
import { LedgerEntry } from '../models/ledger'
|
||||||
import { Response } from '../models/methods'
|
import { Response } from '../models/methods'
|
||||||
@@ -40,7 +40,7 @@ import {
|
|||||||
hashEscrow,
|
hashEscrow,
|
||||||
hashPaymentChannel,
|
hashPaymentChannel,
|
||||||
} from './hashes'
|
} from './hashes'
|
||||||
import { calculateHookOn, hexNamespace, hexHookParameters, TTS } from './hooks'
|
import { calculateHookOn, hexHookParameters, TTS } from './hooks'
|
||||||
import parseNFTokenID from './parseNFTokenID'
|
import parseNFTokenID from './parseNFTokenID'
|
||||||
import {
|
import {
|
||||||
percentToTransferRate,
|
percentToTransferRate,
|
||||||
@@ -224,7 +224,6 @@ 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 BigNumber from 'bignumber.js'
|
|
||||||
import { encodeAccountID } from '@transia/ripple-address-codec'
|
import { encodeAccountID } from '@transia/ripple-address-codec'
|
||||||
|
import BigNumber from 'bignumber.js'
|
||||||
|
|
||||||
import { XrplError } from '../errors'
|
import { XrplError } from '../errors'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { assert } from 'chai'
|
|
||||||
import { decode } from '@transia/ripple-binary-codec'
|
import { decode } from '@transia/ripple-binary-codec'
|
||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AccountSet,
|
AccountSet,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { assert } from 'chai'
|
|
||||||
import { decode } from '@transia/ripple-binary-codec'
|
import { decode } from '@transia/ripple-binary-codec'
|
||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
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,
|
||||||
|
|||||||
@@ -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 '@transia/ripple-binary-codec'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Client,
|
Client,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
import { assert } from 'chai'
|
|
||||||
import { encode } from '@transia/ripple-binary-codec'
|
import { encode } from '@transia/ripple-binary-codec'
|
||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
import { OfferCreate, Transaction, ValidationError } from '../../src'
|
import { OfferCreate, Transaction, ValidationError } from '../../src'
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
|
||||||
import {
|
import { calculateHookOn, hexHookParameters, TTS } from '../../src'
|
||||||
calculateHookOn,
|
|
||||||
hexNamespace,
|
|
||||||
hexHookParameters,
|
|
||||||
TTS,
|
|
||||||
} from '../../src'
|
|
||||||
|
|
||||||
describe('test hook on', function () {
|
describe('test hook on', function () {
|
||||||
it('invalid', function () {
|
it('invalid', function () {
|
||||||
@@ -31,16 +26,6 @@ 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 { assert } from 'chai'
|
|
||||||
import { decode } from '@transia/ripple-binary-codec'
|
import { decode } from '@transia/ripple-binary-codec'
|
||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
import { NFTokenMint, Payment, Transaction } from '../../src'
|
import { NFTokenMint, Payment, Transaction } from '../../src'
|
||||||
import ECDSA from '../../src/ECDSA'
|
import ECDSA from '../../src/ECDSA'
|
||||||
|
|||||||
Reference in New Issue
Block a user