mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-11 16:25:48 +00:00
Compare commits
13 Commits
@transia/r
...
@transia/r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30dd582835 | ||
|
|
2ecbefcb25 | ||
|
|
943142cb73 | ||
|
|
d81d401a56 | ||
|
|
3409d56315 | ||
|
|
78d1b9dc0f | ||
|
|
870eb86c96 | ||
|
|
fb898a5b30 | ||
|
|
ab343cf690 | ||
|
|
05bea18d66 | ||
|
|
a2576ab74a | ||
|
|
ef3f95475e | ||
|
|
25f267b81f |
4132
package-lock.json
generated
4132
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.7-alpha.0",
|
"version": "4.2.6-alpha.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ripple-address-codec",
|
"name": "ripple-address-codec",
|
||||||
"version": "4.2.7-alpha.0",
|
"version": "4.2.6-alpha.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"base-x": "^3.0.9",
|
"base-x": "^3.0.9",
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-address-codec",
|
"name": "@transia/ripple-address-codec",
|
||||||
"version": "4.2.7-alpha.0",
|
"publishConfig": {
|
||||||
|
"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,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-binary-codec",
|
"name": "@transia/ripple-binary-codec",
|
||||||
"version": "1.4.5-alpha.0",
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"version": "1.4.4-alpha.3",
|
||||||
"description": "XRP Ledger binary codec",
|
"description": "XRP Ledger binary codec",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
@@ -12,7 +15,7 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.7-alpha.0",
|
"@transia/ripple-address-codec": "^4.2.6-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",
|
||||||
@@ -39,5 +42,6 @@
|
|||||||
"prettier": "@xrplf/prettier-config",
|
"prettier": "@xrplf/prettier-config",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
}
|
},
|
||||||
|
"gitHead": "943142cb73821de7a4662cc660c5693a3ec2ff81"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import {
|
|||||||
XrplDefinitionsBase,
|
XrplDefinitionsBase,
|
||||||
} from '../enums'
|
} from '../enums'
|
||||||
import { SerializedType, JsonObject } from './serialized-type'
|
import { SerializedType, JsonObject } from './serialized-type'
|
||||||
import { xAddressToClassicAddress, isValidXAddress } from '@transia/ripple-address-codec'
|
import {
|
||||||
|
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,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/ripple-keypairs",
|
"name": "@transia/ripple-keypairs",
|
||||||
"version": "1.1.7-alpha.0",
|
"publishConfig": {
|
||||||
|
"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",
|
||||||
@@ -17,7 +20,7 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.7-alpha.0",
|
"@transia/ripple-address-codec": "^4.2.6-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",
|
||||||
@@ -31,5 +34,6 @@
|
|||||||
"prettier": "@xrplf/prettier-config",
|
"prettier": "@xrplf/prettier-config",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
}
|
},
|
||||||
|
"gitHead": "943142cb73821de7a4662cc660c5693a3ec2ff81"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@transia/xrpl",
|
"name": "@transia/xrpl",
|
||||||
"version": "2.7.1-alpha.0",
|
"publishConfig": {
|
||||||
|
"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": [
|
||||||
@@ -22,9 +25,9 @@
|
|||||||
"https-proxy-agent": false
|
"https-proxy-agent": false
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@transia/ripple-address-codec": "^4.2.7-alpha.0",
|
"@transia/ripple-address-codec": "^4.2.6-alpha.0",
|
||||||
"@transia/ripple-binary-codec": "^1.4.5-alpha.0",
|
"@transia/ripple-binary-codec": "^1.4.4-alpha.3",
|
||||||
"@transia/ripple-keypairs": "^1.1.7-alpha.0",
|
"@transia/ripple-keypairs": "^1.1.6-alpha.3",
|
||||||
"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",
|
||||||
@@ -80,5 +83,6 @@
|
|||||||
"readmeFilename": "README.md",
|
"readmeFilename": "README.md",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.13.0"
|
"node": ">=10.13.0"
|
||||||
}
|
},
|
||||||
|
"gitHead": "943142cb73821de7a4662cc660c5693a3ec2ff81"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,4 @@
|
|||||||
/* 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 {
|
|
||||||
classicAddressToXAddress,
|
|
||||||
isValidXAddress,
|
|
||||||
xAddressToClassicAddress,
|
|
||||||
encodeSeed,
|
|
||||||
} from '@transia/ripple-address-codec'
|
|
||||||
import {
|
import {
|
||||||
decode,
|
decode,
|
||||||
encodeForSigning,
|
encodeForSigning,
|
||||||
@@ -23,6 +12,17 @@ import {
|
|||||||
verify,
|
verify,
|
||||||
sign,
|
sign,
|
||||||
} from '@transia/ripple-keypairs'
|
} from '@transia/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 {
|
||||||
|
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,6 +1,3 @@
|
|||||||
import { BigNumber } from 'bignumber.js'
|
|
||||||
import { flatMap } from 'lodash'
|
|
||||||
import { decodeAccountID } from '@transia/ripple-address-codec'
|
|
||||||
import {
|
import {
|
||||||
decode,
|
decode,
|
||||||
encode,
|
encode,
|
||||||
@@ -8,6 +5,9 @@ import {
|
|||||||
encodeForSigningClaim,
|
encodeForSigningClaim,
|
||||||
} from '@transia/ripple-binary-codec'
|
} from '@transia/ripple-binary-codec'
|
||||||
import { sign as signWithKeypair, verify } from '@transia/ripple-keypairs'
|
import { sign as signWithKeypair, verify } from '@transia/ripple-keypairs'
|
||||||
|
import { BigNumber } from 'bignumber.js'
|
||||||
|
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'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import BigNumber from 'bignumber.js'
|
|
||||||
import { decode } from '@transia/ripple-binary-codec'
|
import { decode } from '@transia/ripple-binary-codec'
|
||||||
|
import BigNumber from 'bignumber.js'
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
AccountTxResponse,
|
AccountTxResponse,
|
||||||
|
|||||||
@@ -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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,13 +4,7 @@
|
|||||||
import { TRANSACTION_TYPES } from '@transia/ripple-binary-codec'
|
import { TRANSACTION_TYPES } from '@transia/ripple-binary-codec'
|
||||||
|
|
||||||
import { ValidationError } from '../../errors'
|
import { ValidationError } from '../../errors'
|
||||||
import {
|
import { Amount, IssuedCurrencyAmount, Memo, Signer } from '../common'
|
||||||
Amount,
|
|
||||||
HookParameter,
|
|
||||||
IssuedCurrencyAmount,
|
|
||||||
Memo,
|
|
||||||
Signer,
|
|
||||||
} from '../common'
|
|
||||||
import { onlyHasFields } from '../utils'
|
import { onlyHasFields } from '../utils'
|
||||||
|
|
||||||
const MEMO_SIZE = 3
|
const MEMO_SIZE = 3
|
||||||
@@ -169,10 +163,6 @@ export interface BaseTransaction {
|
|||||||
* The network id of the transaction.
|
* The network id of the transaction.
|
||||||
*/
|
*/
|
||||||
NetworkID?: number
|
NetworkID?: number
|
||||||
/**
|
|
||||||
* The hook parameters of the transaction.
|
|
||||||
*/
|
|
||||||
HookParameters?: HookParameter[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,7 +43,16 @@ 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'
|
||||||
|
export {
|
||||||
|
URITokenMintFlagsInterface,
|
||||||
|
URITokenMintFlags,
|
||||||
|
URITokenMint,
|
||||||
|
} from './uriTokenMint'
|
||||||
|
export { URITokenBurn } from './uriTokenBurn'
|
||||||
|
export { URITokenCreateSellOffer } from './uriTokenCreateSellOffer'
|
||||||
|
export { URITokenBuy } from './uriTokenBuy'
|
||||||
|
export { URITokenCancelSellOffer } from './uriTokenCancelSellOffer'
|
||||||
|
|||||||
@@ -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: number
|
|
||||||
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,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 = 0x00000010,
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
hsfCollect = 0x00000100,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SetHookFlagsInterface extends GlobalFlags {
|
|
||||||
hsfOverride?: boolean
|
|
||||||
hsfNSDelete?: boolean
|
|
||||||
hsfCollect?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -37,8 +14,6 @@ export interface SetHook extends BaseTransaction {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Hooks: Hook[]
|
Hooks: Hook[]
|
||||||
|
|
||||||
Flags?: number | SetHookFlagsInterface
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_HOOKS = 4
|
const MAX_HOOKS = 4
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ 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 { Invoke, validateInvoke } from './invoke'
|
|
||||||
import { TransactionMetadata } from './metadata'
|
import { TransactionMetadata } from './metadata'
|
||||||
import {
|
import {
|
||||||
NFTokenAcceptOffer,
|
NFTokenAcceptOffer,
|
||||||
@@ -49,6 +48,17 @@ import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
|
|||||||
import { SignerListSet, validateSignerListSet } from './signerListSet'
|
import { SignerListSet, validateSignerListSet } from './signerListSet'
|
||||||
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
||||||
import { TrustSet, validateTrustSet } from './trustSet'
|
import { TrustSet, validateTrustSet } from './trustSet'
|
||||||
|
import { URITokenBurn, validateURITokenBurn } from './uriTokenBurn'
|
||||||
|
import { URITokenBuy, validateURITokenBuy } from './uriTokenBuy'
|
||||||
|
import {
|
||||||
|
URITokenCancelSellOffer,
|
||||||
|
validateURITokenCancelSellOffer,
|
||||||
|
} from './uriTokenCancelSellOffer'
|
||||||
|
import {
|
||||||
|
URITokenCreateSellOffer,
|
||||||
|
validateURITokenCreateSellOffer,
|
||||||
|
} from './uriTokenCreateSellOffer'
|
||||||
|
import { URITokenMint, validateURITokenMint } from './uriTokenMint'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
@@ -63,7 +73,6 @@ export type Transaction =
|
|||||||
| EscrowCancel
|
| EscrowCancel
|
||||||
| EscrowCreate
|
| EscrowCreate
|
||||||
| EscrowFinish
|
| EscrowFinish
|
||||||
| Invoke
|
|
||||||
| NFTokenAcceptOffer
|
| NFTokenAcceptOffer
|
||||||
| NFTokenBurn
|
| NFTokenBurn
|
||||||
| NFTokenCancelOffer
|
| NFTokenCancelOffer
|
||||||
@@ -80,6 +89,11 @@ export type Transaction =
|
|||||||
| SignerListSet
|
| SignerListSet
|
||||||
| TicketCreate
|
| TicketCreate
|
||||||
| TrustSet
|
| TrustSet
|
||||||
|
| URITokenBurn
|
||||||
|
| URITokenBuy
|
||||||
|
| URITokenCancelSellOffer
|
||||||
|
| URITokenMint
|
||||||
|
| URITokenCreateSellOffer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Transaction Models
|
* @category Transaction Models
|
||||||
@@ -144,10 +158,6 @@ export function validate(transaction: Record<string, unknown>): void {
|
|||||||
validateEscrowFinish(tx)
|
validateEscrowFinish(tx)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'Invoke':
|
|
||||||
validateInvoke(tx)
|
|
||||||
break
|
|
||||||
|
|
||||||
case 'NFTokenAcceptOffer':
|
case 'NFTokenAcceptOffer':
|
||||||
validateNFTokenAcceptOffer(tx)
|
validateNFTokenAcceptOffer(tx)
|
||||||
break
|
break
|
||||||
@@ -212,6 +222,26 @@ export function validate(transaction: Record<string, unknown>): void {
|
|||||||
validateTrustSet(tx)
|
validateTrustSet(tx)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'URITokenMint':
|
||||||
|
validateURITokenMint(tx)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'URITokenBurn':
|
||||||
|
validateURITokenBurn(tx)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'URITokenCreateSellOffer':
|
||||||
|
validateURITokenCreateSellOffer(tx)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'URITokenBuy':
|
||||||
|
validateURITokenBuy(tx)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'URITokenCancelSellOffer':
|
||||||
|
validateURITokenCancelSellOffer(tx)
|
||||||
|
break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ValidationError(
|
throw new ValidationError(
|
||||||
`Invalid field TransactionType: ${tx.TransactionType}`,
|
`Invalid field TransactionType: ${tx.TransactionType}`,
|
||||||
|
|||||||
60
packages/xrpl/src/models/transactions/uriTokenBurn.ts
Normal file
60
packages/xrpl/src/models/transactions/uriTokenBurn.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
|
||||||
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of flags to boolean values representing {@link URITokenBurn} transaction
|
||||||
|
* flags.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const tx: URITokenBurn = {
|
||||||
|
* Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
|
||||||
|
* TransactionType: 'URITokenBurn',
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // Autofill the tx to see how flags actually look compared to the interface usage.
|
||||||
|
* const autofilledTx = await client.autofill(tx)
|
||||||
|
* console.log(autofilledTx)
|
||||||
|
* // {
|
||||||
|
* // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* // URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
|
||||||
|
* // TransactionType: 'URITokenBurn',
|
||||||
|
* // Sequence: 21970384,
|
||||||
|
* // Fee: '12',
|
||||||
|
* // LastLedgerSequence: 21970404
|
||||||
|
* // }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An URITokenBurn transaction is effectively a limit order . It defines an
|
||||||
|
* intent to exchange currencies, and creates an Offer object if not completely.
|
||||||
|
* Fulfilled when placed. Offers can be partially fulfilled.
|
||||||
|
*
|
||||||
|
* @category Transaction Models
|
||||||
|
*/
|
||||||
|
export interface URITokenBurn extends BaseTransaction {
|
||||||
|
TransactionType: 'URITokenBurn'
|
||||||
|
/**
|
||||||
|
* Identifies the URIToken object to be removed by the transaction.
|
||||||
|
*/
|
||||||
|
URITokenID: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an URITokenBurn at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An URITokenBurn Transaction.
|
||||||
|
* @throws When the URITokenBurn is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateURITokenBurn(tx: Record<string, unknown>): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.URITokenID == null) {
|
||||||
|
throw new ValidationError('NFTokenBurn: missing field URITokenID')
|
||||||
|
}
|
||||||
|
}
|
||||||
83
packages/xrpl/src/models/transactions/uriTokenBuy.ts
Normal file
83
packages/xrpl/src/models/transactions/uriTokenBuy.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
import { Amount } from '../common'
|
||||||
|
|
||||||
|
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of flags to boolean values representing {@link URITokenBuy} transaction
|
||||||
|
* flags.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const tx: URITokenBuy = {
|
||||||
|
* Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
|
||||||
|
* Amount: '1000000',
|
||||||
|
* TransactionType: 'URITokenBuy',
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // Autofill the tx to see how flags actually look compared to the interface usage.
|
||||||
|
* const autofilledTx = await client.autofill(tx)
|
||||||
|
* console.log(autofilledTx)
|
||||||
|
* // {
|
||||||
|
* // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* // URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
|
||||||
|
* // Amount: '1000000',
|
||||||
|
* // TransactionType: 'URITokenBuy',
|
||||||
|
* // Sequence: 21970384,
|
||||||
|
* // Fee: '12',
|
||||||
|
* // LastLedgerSequence: 21970404
|
||||||
|
* // }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An URITokenBuy transaction is effectively a limit order . It defines an
|
||||||
|
* intent to exchange currencies, and creates an Offer object if not completely.
|
||||||
|
* Fulfilled when placed. Offers can be partially fulfilled.
|
||||||
|
*
|
||||||
|
* @category Transaction Models
|
||||||
|
*/
|
||||||
|
export interface URITokenBuy extends BaseTransaction {
|
||||||
|
TransactionType: 'URITokenBuy'
|
||||||
|
/**
|
||||||
|
* Identifies the URITokenID of the NFToken object that the
|
||||||
|
* offer references.
|
||||||
|
*/
|
||||||
|
URITokenID: string
|
||||||
|
/**
|
||||||
|
* Indicates the amount expected or offered for the Token.
|
||||||
|
*
|
||||||
|
* The amount must be non-zero, except when this is a sell
|
||||||
|
* offer and the asset is XRP. This would indicate that the current
|
||||||
|
* owner of the token is giving it away free, either to anyone at all,
|
||||||
|
* or to the account identified by the Destination field.
|
||||||
|
*/
|
||||||
|
Amount: Amount
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an URITokenBuy at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An URITokenBuy Transaction.
|
||||||
|
* @throws When the URITokenBuy is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateURITokenBuy(tx: Record<string, unknown>): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.Account === tx.Destination) {
|
||||||
|
throw new ValidationError(
|
||||||
|
'URITokenBuy: Destination and Account must not be equal',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.URITokenID == null) {
|
||||||
|
throw new ValidationError('URITokenBuy: missing field URITokenID')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAmount(tx.Amount)) {
|
||||||
|
throw new ValidationError('URITokenBuy: invalid Amount')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
|
||||||
|
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of flags to boolean values representing {@link URITokenCancelSellOffer} transaction
|
||||||
|
* flags.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const tx: URITokenCancelSellOffer = {
|
||||||
|
* Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
|
||||||
|
* TransactionType: 'URITokenCancelSellOffer',
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // Autofill the tx to see how flags actually look compared to the interface usage.
|
||||||
|
* const autofilledTx = await client.autofill(tx)
|
||||||
|
* console.log(autofilledTx)
|
||||||
|
* // {
|
||||||
|
* // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* // URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
|
||||||
|
* // TransactionType: 'URITokenCancelSellOffer',
|
||||||
|
* // Sequence: 21970384,
|
||||||
|
* // Fee: '12',
|
||||||
|
* // LastLedgerSequence: 21970404
|
||||||
|
* // }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An URITokenCancelSellOffer transaction is effectively a limit order . It defines an
|
||||||
|
* intent to exchange currencies, and creates an Offer object if not completely.
|
||||||
|
* Fulfilled when placed. Offers can be partially fulfilled.
|
||||||
|
*
|
||||||
|
* @category Transaction Models
|
||||||
|
*/
|
||||||
|
export interface URITokenCancelSellOffer extends BaseTransaction {
|
||||||
|
TransactionType: 'URITokenCancelSellOffer'
|
||||||
|
/**
|
||||||
|
* Identifies the URITokenID of the NFToken object that the
|
||||||
|
* offer references.
|
||||||
|
*/
|
||||||
|
URITokenID: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an URITokenCancelSellOffer at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An URITokenCancelSellOffer Transaction.
|
||||||
|
* @throws When the URITokenCancelSellOffer is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateURITokenCancelSellOffer(
|
||||||
|
tx: Record<string, unknown>,
|
||||||
|
): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.URITokenID == null) {
|
||||||
|
throw new ValidationError(
|
||||||
|
'URITokenCancelSellOffer: missing field URITokenID',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
import { Amount } from '../common'
|
||||||
|
|
||||||
|
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of flags to boolean values representing {@link URITokenCreateSellOffer} transaction
|
||||||
|
* flags.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const tx: URITokenCreateSellOffer = {
|
||||||
|
* Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
|
||||||
|
* Amount: '1000000',
|
||||||
|
* TransactionType: 'URITokenCreateSellOffer',
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // Autofill the tx to see how flags actually look compared to the interface usage.
|
||||||
|
* const autofilledTx = await client.autofill(tx)
|
||||||
|
* console.log(autofilledTx)
|
||||||
|
* // {
|
||||||
|
* // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* // URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
|
||||||
|
* // Amount: '1000000',
|
||||||
|
* // TransactionType: 'URITokenCreateSellOffer',
|
||||||
|
* // Sequence: 21970384,
|
||||||
|
* // Fee: '12',
|
||||||
|
* // LastLedgerSequence: 21970404
|
||||||
|
* // }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An URITokenCreateSellOffer transaction is effectively a limit order . It defines an
|
||||||
|
* intent to exchange currencies, and creates an Offer object if not completely.
|
||||||
|
* Fulfilled when placed. Offers can be partially fulfilled.
|
||||||
|
*
|
||||||
|
* @category Transaction Models
|
||||||
|
*/
|
||||||
|
export interface URITokenCreateSellOffer extends BaseTransaction {
|
||||||
|
TransactionType: 'URITokenCreateSellOffer'
|
||||||
|
/**
|
||||||
|
* Identifies the URITokenID of the NFToken object that the
|
||||||
|
* offer references.
|
||||||
|
*/
|
||||||
|
URITokenID: string
|
||||||
|
/**
|
||||||
|
* Indicates the amount expected or offered for the Token.
|
||||||
|
*
|
||||||
|
* The amount must be non-zero, except when this is a sell
|
||||||
|
* offer and the asset is XRP. This would indicate that the current
|
||||||
|
* owner of the token is giving it away free, either to anyone at all,
|
||||||
|
* or to the account identified by the Destination field.
|
||||||
|
*/
|
||||||
|
Amount: Amount
|
||||||
|
/**
|
||||||
|
* If present, indicates that this offer may only be
|
||||||
|
* accepted by the specified account. Attempts by other
|
||||||
|
* accounts to accept this offer MUST fail.
|
||||||
|
*/
|
||||||
|
Destination?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an URITokenCreateSellOffer at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An URITokenCreateSellOffer Transaction.
|
||||||
|
* @throws When the URITokenCreateSellOffer is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateURITokenCreateSellOffer(
|
||||||
|
tx: Record<string, unknown>,
|
||||||
|
): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (tx.Account === tx.Destination) {
|
||||||
|
throw new ValidationError(
|
||||||
|
'URITokenCreateSellOffer: Destination and Account must not be equal',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.URITokenID == null) {
|
||||||
|
throw new ValidationError(
|
||||||
|
'URITokenCreateSellOffer: missing field URITokenID',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAmount(tx.Amount)) {
|
||||||
|
throw new ValidationError('URITokenCreateSellOffer: invalid Amount')
|
||||||
|
}
|
||||||
|
}
|
||||||
92
packages/xrpl/src/models/transactions/uriTokenMint.ts
Normal file
92
packages/xrpl/src/models/transactions/uriTokenMint.ts
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
import { ValidationError } from '../../errors'
|
||||||
|
import { isHex } from '../utils'
|
||||||
|
|
||||||
|
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transaction Flags for an URITokenMint Transaction.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*/
|
||||||
|
export enum URITokenMintFlags {
|
||||||
|
/**
|
||||||
|
* If set, indicates that the minted token may be burned by the issuer even
|
||||||
|
* if the issuer does not currently hold the token. The current holder of
|
||||||
|
* the token may always burn it.
|
||||||
|
*/
|
||||||
|
tfBurnable = 0x00000001,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of flags to boolean values representing {@link URITokenMint} transaction
|
||||||
|
* flags.
|
||||||
|
*
|
||||||
|
* @category Transaction Flags
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const tx: URITokenMint = {
|
||||||
|
* Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* URI: '697066733A2F2F434944',
|
||||||
|
* TransactionType: 'URITokenMint',
|
||||||
|
* Flags: {
|
||||||
|
* tfBurnable: true,
|
||||||
|
* },
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // Autofill the tx to see how flags actually look compared to the interface usage.
|
||||||
|
* const autofilledTx = await client.autofill(tx)
|
||||||
|
* console.log(autofilledTx)
|
||||||
|
* // {
|
||||||
|
* // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
|
||||||
|
* // URI: '697066733A2F2F434944',
|
||||||
|
* // TransactionType: 'URITokenMint',
|
||||||
|
* // Flags: 0,
|
||||||
|
* // Sequence: 21970384,
|
||||||
|
* // Fee: '12',
|
||||||
|
* // LastLedgerSequence: 21970404
|
||||||
|
* // }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export interface URITokenMintFlagsInterface extends GlobalFlags {
|
||||||
|
tfBurnable?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An URITokenMint transaction is effectively a limit order . It defines an
|
||||||
|
* intent to exchange currencies, and creates an Offer object if not completely.
|
||||||
|
* Fulfilled when placed. Offers can be partially fulfilled.
|
||||||
|
*
|
||||||
|
* @category Transaction Models
|
||||||
|
*/
|
||||||
|
export interface URITokenMint extends BaseTransaction {
|
||||||
|
TransactionType: 'URITokenMint'
|
||||||
|
Flags?: number | URITokenMintFlagsInterface
|
||||||
|
/**
|
||||||
|
* URI that points to the data and/or metadata associated with the NFT.
|
||||||
|
* This field need not be an HTTP or HTTPS URL; it could be an IPFS URI, a
|
||||||
|
* magnet link, immediate data encoded as an RFC2379 "data" URL, or even an
|
||||||
|
* opaque issuer-specific encoding. The URI is NOT checked for validity, but
|
||||||
|
* the field is limited to a maximum length of 256 bytes.
|
||||||
|
*
|
||||||
|
* This field must be hex-encoded. You can use `convertStringToHex` to
|
||||||
|
* convert this field to the proper encoding.
|
||||||
|
*/
|
||||||
|
URI: string
|
||||||
|
|
||||||
|
Digest?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the form and type of an URITokenMint at runtime.
|
||||||
|
*
|
||||||
|
* @param tx - An URITokenMint Transaction.
|
||||||
|
* @throws When the URITokenMint is Malformed.
|
||||||
|
*/
|
||||||
|
export function validateURITokenMint(tx: Record<string, unknown>): void {
|
||||||
|
validateBaseTransaction(tx)
|
||||||
|
|
||||||
|
if (typeof tx.URI === 'string' && !isHex(tx.URI)) {
|
||||||
|
throw new ValidationError('URITokenMint: URI must be in hex format')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,6 @@ 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'
|
||||||
|
|
||||||
@@ -76,15 +75,6 @@ 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((h) => {
|
|
||||||
h.Hook.Flags = convertSetHookFlagsToNumber(
|
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- idk
|
|
||||||
h.Hook.Flags as SetHookFlagsInterface,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
return
|
|
||||||
default:
|
default:
|
||||||
tx.Flags = 0
|
tx.Flags = 0
|
||||||
}
|
}
|
||||||
@@ -118,10 +108,6 @@ 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,5 +1,8 @@
|
|||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import { xAddressToClassicAddress, isValidXAddress } from '@transia/ripple-address-codec'
|
import {
|
||||||
|
xAddressToClassicAddress,
|
||||||
|
isValidXAddress,
|
||||||
|
} from '@transia/ripple-address-codec'
|
||||||
|
|
||||||
import type { Client } from '..'
|
import type { Client } from '..'
|
||||||
import { ValidationError, XrplError } from '../errors'
|
import { ValidationError, XrplError } from '../errors'
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { xAddressToClassicAddress, isValidXAddress } from '@transia/ripple-address-codec'
|
import {
|
||||||
|
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.
|
||||||
|
|||||||
@@ -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 { decode, encode } from '@transia/ripple-binary-codec'
|
import { decode, encode } from '@transia/ripple-binary-codec'
|
||||||
|
import BigNumber from 'bignumber.js'
|
||||||
|
|
||||||
import { ValidationError, XrplError } from '../../errors'
|
import { ValidationError, XrplError } from '../../errors'
|
||||||
import type { Ledger } from '../../models/ledger'
|
import type { Ledger } from '../../models/ledger'
|
||||||
|
|||||||
@@ -86,14 +86,6 @@ export async function hexNamespace(namespace: string): Promise<string> {
|
|||||||
return (await sha256(namespace)).toUpperCase()
|
return (await sha256(namespace)).toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
function isHex(value: string): boolean {
|
|
||||||
return /^[0-9A-F]+$/iu.test(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
function hexValue(value: string): string {
|
|
||||||
return Buffer.from(value, 'utf8').toString('hex').toUpperCase()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the hex of the hook parameters
|
* Calculate the hex of the hook parameters
|
||||||
*
|
*
|
||||||
@@ -103,21 +95,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(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import * as rbc from '@transia/ripple-binary-codec'
|
||||||
|
import { verify as verifyKeypairSignature } from '@transia/ripple-keypairs'
|
||||||
import {
|
import {
|
||||||
classicAddressToXAddress,
|
classicAddressToXAddress,
|
||||||
decodeAccountID,
|
decodeAccountID,
|
||||||
@@ -14,8 +16,6 @@ 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'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { assert } from 'chai'
|
|
||||||
import { decode, encode } from '@transia/ripple-binary-codec'
|
import { decode, encode } from '@transia/ripple-binary-codec'
|
||||||
|
import { assert } from 'chai'
|
||||||
|
|
||||||
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