mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 11:45:49 +00:00
Merge pull request #1096 from magmel48/typescript3.7-TransactionJSON-conflict-fix
TransactionJSON conflict fix
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import {TransactionJSON, prepareTransaction} from './utils'
|
import {prepareTransaction} from './utils'
|
||||||
import {validate} from '../common'
|
import {validate} from '../common'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {RippleAPI} from '..'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type CheckCancelParameters = {
|
export type CheckCancelParameters = {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
const validate = utils.common.validate
|
const validate = utils.common.validate
|
||||||
const ValidationError = utils.common.errors.ValidationError
|
const ValidationError = utils.common.errors.ValidationError
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {Memo} from '../common/types/objects'
|
import {Memo} from '../common/types/objects'
|
||||||
import {RippleAPI} from '..'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ export type EscrowExecution = {
|
|||||||
|
|
||||||
function createEscrowExecutionTransaction(account: string,
|
function createEscrowExecutionTransaction(account: string,
|
||||||
payment: EscrowExecution
|
payment: EscrowExecution
|
||||||
): utils.TransactionJSON {
|
): TransactionJSON {
|
||||||
const txJSON: any = {
|
const txJSON: any = {
|
||||||
TransactionType: 'EscrowFinish',
|
TransactionType: 'EscrowFinish',
|
||||||
Account: account,
|
Account: account,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as utils from './utils'
|
|||||||
const ValidationError = utils.common.errors.ValidationError
|
const ValidationError = utils.common.errors.ValidationError
|
||||||
const claimFlags = utils.common.txFlags.PaymentChannelClaim
|
const claimFlags = utils.common.txFlags.PaymentChannelClaim
|
||||||
import {validate, xrpToDrops} from '../common'
|
import {validate, xrpToDrops} from '../common'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {RippleAPI} from '..'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type PaymentChannelClaim = {
|
export type PaymentChannelClaim = {
|
||||||
@@ -17,8 +17,8 @@ export type PaymentChannelClaim = {
|
|||||||
|
|
||||||
function createPaymentChannelClaimTransaction(account: string,
|
function createPaymentChannelClaimTransaction(account: string,
|
||||||
claim: PaymentChannelClaim
|
claim: PaymentChannelClaim
|
||||||
): utils.TransactionJSON {
|
): TransactionJSON {
|
||||||
const txJSON: utils.TransactionJSON = {
|
const txJSON: TransactionJSON = {
|
||||||
Account: account,
|
Account: account,
|
||||||
TransactionType: 'PaymentChannelClaim',
|
TransactionType: 'PaymentChannelClaim',
|
||||||
Channel: claim.channel,
|
Channel: claim.channel,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {RippleAPI} from '..'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type PaymentChannelCreate = {
|
export type PaymentChannelCreate = {
|
||||||
@@ -15,7 +15,7 @@ export type PaymentChannelCreate = {
|
|||||||
|
|
||||||
function createPaymentChannelCreateTransaction(account: string,
|
function createPaymentChannelCreateTransaction(account: string,
|
||||||
paymentChannel: PaymentChannelCreate
|
paymentChannel: PaymentChannelCreate
|
||||||
): utils.TransactionJSON {
|
): TransactionJSON {
|
||||||
const txJSON: any = {
|
const txJSON: any = {
|
||||||
Account: account,
|
Account: account,
|
||||||
TransactionType: 'PaymentChannelCreate',
|
TransactionType: 'PaymentChannelCreate',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {RippleAPI} from '..'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
export type PaymentChannelFund = {
|
export type PaymentChannelFund = {
|
||||||
@@ -11,8 +11,8 @@ export type PaymentChannelFund = {
|
|||||||
|
|
||||||
function createPaymentChannelFundTransaction(account: string,
|
function createPaymentChannelFundTransaction(account: string,
|
||||||
fund: PaymentChannelFund
|
fund: PaymentChannelFund
|
||||||
): utils.TransactionJSON {
|
): TransactionJSON {
|
||||||
const txJSON: utils.TransactionJSON = {
|
const txJSON: TransactionJSON = {
|
||||||
Account: account,
|
Account: account,
|
||||||
TransactionType: 'PaymentChannelFund',
|
TransactionType: 'PaymentChannelFund',
|
||||||
Channel: fund.channel,
|
Channel: fund.channel,
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import * as utils from './utils'
|
|||||||
const validate = utils.common.validate
|
const validate = utils.common.validate
|
||||||
const AccountFlagIndices = utils.common.constants.AccountFlagIndices
|
const AccountFlagIndices = utils.common.constants.AccountFlagIndices
|
||||||
const AccountFields = utils.common.constants.AccountFields
|
const AccountFields = utils.common.constants.AccountFields
|
||||||
import {Instructions, Prepare, SettingsTransaction} from './types'
|
import {Instructions, Prepare, SettingsTransaction, TransactionJSON} from './types'
|
||||||
import {FormattedSettings, WeightedSigner} from '../common/types/objects'
|
import {FormattedSettings, WeightedSigner} from '../common/types/objects'
|
||||||
import {RippleAPI} from '..'
|
import {RippleAPI} from '..'
|
||||||
|
|
||||||
function setTransactionFlags(txJSON: utils.TransactionJSON, values: FormattedSettings) {
|
function setTransactionFlags(txJSON: TransactionJSON, values: FormattedSettings) {
|
||||||
const keys = Object.keys(values)
|
const keys = Object.keys(values)
|
||||||
assert.ok(keys.length === 1, 'ERROR: can only set one setting per transaction')
|
assert.ok(keys.length === 1, 'ERROR: can only set one setting per transaction')
|
||||||
const flagName = keys[0]
|
const flagName = keys[0]
|
||||||
@@ -24,7 +24,7 @@ function setTransactionFlags(txJSON: utils.TransactionJSON, values: FormattedSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sets `null` fields to their `default`.
|
// Sets `null` fields to their `default`.
|
||||||
function setTransactionFields(txJSON: utils.TransactionJSON, input: FormattedSettings) {
|
function setTransactionFields(txJSON: TransactionJSON, input: FormattedSettings) {
|
||||||
const fieldSchema = AccountFields
|
const fieldSchema = AccountFields
|
||||||
for (const fieldName in fieldSchema) {
|
for (const fieldName in fieldSchema) {
|
||||||
const field = fieldSchema[fieldName]
|
const field = fieldSchema[fieldName]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as utils from './utils'
|
|||||||
import keypairs from 'ripple-keypairs'
|
import keypairs from 'ripple-keypairs'
|
||||||
import binaryCodec from 'ripple-binary-codec'
|
import binaryCodec from 'ripple-binary-codec'
|
||||||
import {computeBinaryTransactionHash} from '../common/hashes'
|
import {computeBinaryTransactionHash} from '../common/hashes'
|
||||||
import {SignOptions, KeyPair} from './types'
|
import {SignOptions, KeyPair, TransactionJSON} from './types'
|
||||||
import {BigNumber} from 'bignumber.js'
|
import {BigNumber} from 'bignumber.js'
|
||||||
import {xrpToDrops} from '../common'
|
import {xrpToDrops} from '../common'
|
||||||
import {RippleAPI} from '..'
|
import {RippleAPI} from '..'
|
||||||
@@ -131,11 +131,11 @@ function objectDiff(a: object, b: object): object {
|
|||||||
* and verify that it matches the transaction prior to signing.
|
* and verify that it matches the transaction prior to signing.
|
||||||
*
|
*
|
||||||
* @param {string} serialized A signed and serialized transaction.
|
* @param {string} serialized A signed and serialized transaction.
|
||||||
* @param {utils.TransactionJSON} tx The transaction prior to signing.
|
* @param {TransactionJSON} tx The transaction prior to signing.
|
||||||
*
|
*
|
||||||
* @returns {void} This method does not return a value, but throws an error if the check fails.
|
* @returns {void} This method does not return a value, but throws an error if the check fails.
|
||||||
*/
|
*/
|
||||||
function checkTxSerialization(serialized: string, tx: utils.TransactionJSON): void {
|
function checkTxSerialization(serialized: string, tx: TransactionJSON): void {
|
||||||
// Decode the serialized transaction:
|
// Decode the serialized transaction:
|
||||||
const decoded = binaryCodec.decode(serialized)
|
const decoded = binaryCodec.decode(serialized)
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,16 @@ import {
|
|||||||
} from '../common/types/objects'
|
} from '../common/types/objects'
|
||||||
import {
|
import {
|
||||||
ApiMemo,
|
ApiMemo,
|
||||||
TransactionJSON
|
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
export type TransactionJSON = TransactionJSON
|
export type TransactionJSON = {
|
||||||
|
Account: string,
|
||||||
|
TransactionType: string,
|
||||||
|
Memos?: {Memo: ApiMemo}[],
|
||||||
|
Flags?: number,
|
||||||
|
Fulfillment?: string,
|
||||||
|
[Field: string]: string | number | Array<any> | RippledAmount | undefined
|
||||||
|
}
|
||||||
|
|
||||||
export type Instructions = {
|
export type Instructions = {
|
||||||
sequence?: number,
|
sequence?: number,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import * as common from '../common'
|
import * as common from '../common'
|
||||||
import {Memo, RippledAmount} from '../common/types/objects'
|
import {Memo} from '../common/types/objects'
|
||||||
import {Instructions, Prepare} from './types'
|
import {Instructions, Prepare, TransactionJSON} from './types'
|
||||||
import {RippleAPI} from '..'
|
import {RippleAPI} from '..'
|
||||||
import {ValidationError} from '../common/errors'
|
import {ValidationError} from '../common/errors'
|
||||||
import {xAddressToClassicAddress, isValidXAddress} from 'ripple-address-codec'
|
import {xAddressToClassicAddress, isValidXAddress} from 'ripple-address-codec'
|
||||||
@@ -15,15 +15,6 @@ export type ApiMemo = {
|
|||||||
MemoFormat?: string
|
MemoFormat?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TransactionJSON = {
|
|
||||||
Account: string,
|
|
||||||
TransactionType: string,
|
|
||||||
Memos?: {Memo: ApiMemo}[],
|
|
||||||
Flags?: number,
|
|
||||||
Fulfillment?: string,
|
|
||||||
[Field: string]: string | number | Array<any> | RippledAmount | undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatPrepareResponse(txJSON: any): Prepare {
|
function formatPrepareResponse(txJSON: any): Prepare {
|
||||||
const instructions = {
|
const instructions = {
|
||||||
fee: common.dropsToXrp(txJSON.Fee),
|
fee: common.dropsToXrp(txJSON.Fee),
|
||||||
|
|||||||
Reference in New Issue
Block a user