diff --git a/src/transaction/check-cancel.ts b/src/transaction/check-cancel.ts index afe5980c..fedd86f4 100644 --- a/src/transaction/check-cancel.ts +++ b/src/transaction/check-cancel.ts @@ -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 = { diff --git a/src/transaction/escrow-execution.ts b/src/transaction/escrow-execution.ts index 0746191e..0db0f3bd 100644 --- a/src/transaction/escrow-execution.ts +++ b/src/transaction/escrow-execution.ts @@ -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, diff --git a/src/transaction/payment-channel-claim.ts b/src/transaction/payment-channel-claim.ts index 49a87835..e19978ff 100644 --- a/src/transaction/payment-channel-claim.ts +++ b/src/transaction/payment-channel-claim.ts @@ -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, diff --git a/src/transaction/payment-channel-create.ts b/src/transaction/payment-channel-create.ts index f8d80049..ae48f37e 100644 --- a/src/transaction/payment-channel-create.ts +++ b/src/transaction/payment-channel-create.ts @@ -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', diff --git a/src/transaction/payment-channel-fund.ts b/src/transaction/payment-channel-fund.ts index e526a0d7..717b152c 100644 --- a/src/transaction/payment-channel-fund.ts +++ b/src/transaction/payment-channel-fund.ts @@ -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, diff --git a/src/transaction/settings.ts b/src/transaction/settings.ts index bc3a5787..c82d9155 100644 --- a/src/transaction/settings.ts +++ b/src/transaction/settings.ts @@ -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] diff --git a/src/transaction/sign.ts b/src/transaction/sign.ts index af4dc5f7..6a1ffce2 100644 --- a/src/transaction/sign.ts +++ b/src/transaction/sign.ts @@ -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) diff --git a/src/transaction/types.ts b/src/transaction/types.ts index 2e72fad8..6b5bcbb4 100644 --- a/src/transaction/types.ts +++ b/src/transaction/types.ts @@ -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 | RippledAmount | undefined +} export type Instructions = { sequence?: number, diff --git a/src/transaction/utils.ts b/src/transaction/utils.ts index f859ff3c..07ea900b 100644 --- a/src/transaction/utils.ts +++ b/src/transaction/utils.ts @@ -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 | RippledAmount | undefined -} - function formatPrepareResponse(txJSON: any): Prepare { const instructions = { fee: common.dropsToXrp(txJSON.Fee),