Merge pull request #1096 from magmel48/typescript3.7-TransactionJSON-conflict-fix

TransactionJSON conflict fix
This commit is contained in:
FKSRipple
2019-11-19 15:04:10 -08:00
committed by GitHub
9 changed files with 28 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
import {TransactionJSON, prepareTransaction} from './utils'
import {prepareTransaction} from './utils'
import {validate} from '../common'
import {Instructions, Prepare} from './types'
import {Instructions, Prepare, TransactionJSON} from './types'
import {RippleAPI} from '..'
export type CheckCancelParameters = {

View File

@@ -1,7 +1,7 @@
import * as utils from './utils'
const validate = utils.common.validate
const ValidationError = utils.common.errors.ValidationError
import {Instructions, Prepare} from './types'
import {Instructions, Prepare, TransactionJSON} from './types'
import {Memo} from '../common/types/objects'
import {RippleAPI} from '..'
@@ -15,7 +15,7 @@ export type EscrowExecution = {
function createEscrowExecutionTransaction(account: string,
payment: EscrowExecution
): utils.TransactionJSON {
): TransactionJSON {
const txJSON: any = {
TransactionType: 'EscrowFinish',
Account: account,

View File

@@ -2,7 +2,7 @@ import * as utils from './utils'
const ValidationError = utils.common.errors.ValidationError
const claimFlags = utils.common.txFlags.PaymentChannelClaim
import {validate, xrpToDrops} from '../common'
import {Instructions, Prepare} from './types'
import {Instructions, Prepare, TransactionJSON} from './types'
import {RippleAPI} from '..'
export type PaymentChannelClaim = {
@@ -17,8 +17,8 @@ export type PaymentChannelClaim = {
function createPaymentChannelClaimTransaction(account: string,
claim: PaymentChannelClaim
): utils.TransactionJSON {
const txJSON: utils.TransactionJSON = {
): TransactionJSON {
const txJSON: TransactionJSON = {
Account: account,
TransactionType: 'PaymentChannelClaim',
Channel: claim.channel,

View File

@@ -1,6 +1,6 @@
import * as utils from './utils'
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
import {Instructions, Prepare} from './types'
import {Instructions, Prepare, TransactionJSON} from './types'
import {RippleAPI} from '..'
export type PaymentChannelCreate = {
@@ -15,7 +15,7 @@ export type PaymentChannelCreate = {
function createPaymentChannelCreateTransaction(account: string,
paymentChannel: PaymentChannelCreate
): utils.TransactionJSON {
): TransactionJSON {
const txJSON: any = {
Account: account,
TransactionType: 'PaymentChannelCreate',

View File

@@ -1,6 +1,6 @@
import * as utils from './utils'
import {validate, iso8601ToRippleTime, xrpToDrops} from '../common'
import {Instructions, Prepare} from './types'
import {Instructions, Prepare, TransactionJSON} from './types'
import {RippleAPI} from '..'
export type PaymentChannelFund = {
@@ -11,8 +11,8 @@ export type PaymentChannelFund = {
function createPaymentChannelFundTransaction(account: string,
fund: PaymentChannelFund
): utils.TransactionJSON {
const txJSON: utils.TransactionJSON = {
): TransactionJSON {
const txJSON: TransactionJSON = {
Account: account,
TransactionType: 'PaymentChannelFund',
Channel: fund.channel,

View File

@@ -4,11 +4,11 @@ import * as utils from './utils'
const validate = utils.common.validate
const AccountFlagIndices = utils.common.constants.AccountFlagIndices
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 {RippleAPI} from '..'
function setTransactionFlags(txJSON: utils.TransactionJSON, values: FormattedSettings) {
function setTransactionFlags(txJSON: TransactionJSON, values: FormattedSettings) {
const keys = Object.keys(values)
assert.ok(keys.length === 1, 'ERROR: can only set one setting per transaction')
const flagName = keys[0]
@@ -24,7 +24,7 @@ function setTransactionFlags(txJSON: utils.TransactionJSON, values: FormattedSet
}
// Sets `null` fields to their `default`.
function setTransactionFields(txJSON: utils.TransactionJSON, input: FormattedSettings) {
function setTransactionFields(txJSON: TransactionJSON, input: FormattedSettings) {
const fieldSchema = AccountFields
for (const fieldName in fieldSchema) {
const field = fieldSchema[fieldName]

View File

@@ -3,7 +3,7 @@ import * as utils from './utils'
import keypairs from 'ripple-keypairs'
import binaryCodec from 'ripple-binary-codec'
import {computeBinaryTransactionHash} from '../common/hashes'
import {SignOptions, KeyPair} from './types'
import {SignOptions, KeyPair, TransactionJSON} from './types'
import {BigNumber} from 'bignumber.js'
import {xrpToDrops} from '../common'
import {RippleAPI} from '..'
@@ -131,11 +131,11 @@ function objectDiff(a: object, b: object): object {
* and verify that it matches the transaction prior to signing.
*
* @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.
*/
function checkTxSerialization(serialized: string, tx: utils.TransactionJSON): void {
function checkTxSerialization(serialized: string, tx: TransactionJSON): void {
// Decode the serialized transaction:
const decoded = binaryCodec.decode(serialized)

View File

@@ -9,10 +9,16 @@ import {
} from '../common/types/objects'
import {
ApiMemo,
TransactionJSON
} 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 = {
sequence?: number,

View File

@@ -1,7 +1,7 @@
import BigNumber from 'bignumber.js'
import * as common from '../common'
import {Memo, RippledAmount} from '../common/types/objects'
import {Instructions, Prepare} from './types'
import {Memo} from '../common/types/objects'
import {Instructions, Prepare, TransactionJSON} from './types'
import {RippleAPI} from '..'
import {ValidationError} from '../common/errors'
import {xAddressToClassicAddress, isValidXAddress} from 'ripple-address-codec'
@@ -15,15 +15,6 @@ export type ApiMemo = {
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 {
const instructions = {
fee: common.dropsToXrp(txJSON.Fee),