mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-14 09:35:48 +00:00
Compare commits
4 Commits
@transia/r
...
beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bf6ae0b51 | ||
|
|
925bfef971 | ||
|
|
d5d5350425 | ||
|
|
301c6d6beb |
@@ -4,7 +4,13 @@
|
|||||||
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 { Amount, IssuedCurrencyAmount, Memo, Signer } from '../common'
|
import {
|
||||||
|
Amount,
|
||||||
|
HookParameter,
|
||||||
|
IssuedCurrencyAmount,
|
||||||
|
Memo,
|
||||||
|
Signer,
|
||||||
|
} from '../common'
|
||||||
import { onlyHasFields } from '../utils'
|
import { onlyHasFields } from '../utils'
|
||||||
|
|
||||||
const MEMO_SIZE = 3
|
const MEMO_SIZE = 3
|
||||||
@@ -163,6 +169,10 @@ 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[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,6 +29,20 @@ 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.
|
||||||
*
|
*
|
||||||
@@ -63,6 +77,7 @@ export interface TransactionMetadata {
|
|||||||
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
|
||||||
|
|||||||
@@ -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 { Invoke, validateInvoke } from './invoke'
|
||||||
import { TransactionMetadata } from './metadata'
|
import { TransactionMetadata } from './metadata'
|
||||||
import {
|
import {
|
||||||
NFTokenAcceptOffer,
|
NFTokenAcceptOffer,
|
||||||
@@ -73,6 +74,7 @@ export type Transaction =
|
|||||||
| EscrowCancel
|
| EscrowCancel
|
||||||
| EscrowCreate
|
| EscrowCreate
|
||||||
| EscrowFinish
|
| EscrowFinish
|
||||||
|
| Invoke
|
||||||
| NFTokenAcceptOffer
|
| NFTokenAcceptOffer
|
||||||
| NFTokenBurn
|
| NFTokenBurn
|
||||||
| NFTokenCancelOffer
|
| NFTokenCancelOffer
|
||||||
@@ -158,6 +160,10 @@ 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
|
||||||
|
|||||||
@@ -95,20 +95,31 @@ 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 valueValue
|
||||||
|
// eslint-disable-next-line require-unicode-regexp -- Required
|
||||||
|
if (/^[0-9a-fA-F]{2,}$/.exec(parameter.HookParameter.HookParameterName)) {
|
||||||
|
nameValue = parameter.HookParameter.HookParameterName
|
||||||
|
} 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)) {
|
||||||
|
valueValue = parameter.HookParameter.HookParameterValue
|
||||||
|
} else {
|
||||||
|
valueValue = Buffer.from(
|
||||||
|
parameter.HookParameter.HookParameterValue,
|
||||||
|
'utf8',
|
||||||
|
)
|
||||||
|
.toString('hex')
|
||||||
|
.toUpperCase()
|
||||||
|
}
|
||||||
hookParameters.push({
|
hookParameters.push({
|
||||||
HookParameter: {
|
HookParameter: {
|
||||||
HookParameterName: Buffer.from(
|
HookParameterName: String(nameValue),
|
||||||
parameter.HookParameter.HookParameterName,
|
HookParameterValue: String(valueValue),
|
||||||
'utf8',
|
|
||||||
)
|
|
||||||
.toString('hex')
|
|
||||||
.toUpperCase(),
|
|
||||||
HookParameterValue: Buffer.from(
|
|
||||||
parameter.HookParameter.HookParameterValue,
|
|
||||||
'utf8',
|
|
||||||
)
|
|
||||||
.toString('hex')
|
|
||||||
.toUpperCase(),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user