Replace suspended payments with escrow

This commit is contained in:
wilsonianb
2017-03-22 10:29:49 -07:00
parent 68d7864f93
commit 15a0ededc8
55 changed files with 379 additions and 391 deletions

View File

@@ -3,14 +3,14 @@
const assert = require('assert')
const utils = require('./utils')
function parseSuspendedPaymentCancellation(tx: Object): Object {
assert(tx.TransactionType === 'SuspendedPaymentCancel')
function parseEscrowCancellation(tx: Object): Object {
assert(tx.TransactionType === 'EscrowCancel')
return utils.removeUndefined({
memos: utils.parseMemos(tx),
owner: tx.Owner,
suspensionSequence: tx.OfferSequence
escrowSequence: tx.OfferSequence
})
}
module.exports = parseSuspendedPaymentCancellation
module.exports = parseEscrowCancellation

View File

@@ -10,8 +10,8 @@ function removeGenericCounterparty(amount, address) {
_.omit(amount, 'counterparty') : amount
}
function parseSuspendedPaymentCreation(tx: Object): Object {
assert(tx.TransactionType === 'SuspendedPaymentCreate')
function parseEscrowCreation(tx: Object): Object {
assert(tx.TransactionType === 'EscrowCreate')
const source = {
address: tx.Account,
@@ -30,10 +30,10 @@ function parseSuspendedPaymentCreation(tx: Object): Object {
source: utils.removeUndefined(source),
destination: utils.removeUndefined(destination),
memos: utils.parseMemos(tx),
digest: tx.Digest,
condition: tx.Condition,
allowCancelAfter: utils.parseTimestamp(tx.CancelAfter),
allowExecuteAfter: utils.parseTimestamp(tx.FinishAfter)
})
}
module.exports = parseSuspendedPaymentCreation
module.exports = parseEscrowCreation

View File

@@ -3,17 +3,16 @@
const assert = require('assert')
const utils = require('./utils')
function parseSuspendedPaymentExecution(tx: Object): Object {
assert(tx.TransactionType === 'SuspendedPaymentFinish')
function parseEscrowExecution(tx: Object): Object {
assert(tx.TransactionType === 'EscrowFinish')
return utils.removeUndefined({
memos: utils.parseMemos(tx),
owner: tx.Owner,
suspensionSequence: tx.OfferSequence,
method: tx.Method,
digest: tx.Digest,
proof: tx.Proof ? utils.hexToString(tx.Proof) : undefined
escrowSequence: tx.OfferSequence,
condition: tx.Condition,
fulfillment: tx.Fulfillment ? utils.hexToString(tx.Fulfillment) : undefined
})
}
module.exports = parseSuspendedPaymentExecution
module.exports = parseEscrowExecution

View File

@@ -7,10 +7,9 @@ const parseTrustline = require('./trustline')
const parseOrder = require('./order')
const parseOrderCancellation = require('./cancellation')
const parseSettings = require('./settings')
const parseSuspendedPaymentCreation = require('./suspended-payment-creation')
const parseSuspendedPaymentExecution = require('./suspended-payment-execution')
const parseSuspendedPaymentCancellation =
require('./suspended-payment-cancellation')
const parseEscrowCreation = require('./escrow-creation')
const parseEscrowExecution = require('./escrow-execution')
const parseEscrowCancellation = require('./escrow-cancellation')
const parseFeeUpdate = require('./fee-update')
const parseAmendment = require('./amendment')
@@ -22,9 +21,9 @@ function parseTransactionType(type) {
OfferCancel: 'orderCancellation',
AccountSet: 'settings',
SetRegularKey: 'settings',
SuspendedPaymentCreate: 'suspendedPaymentCreation',
SuspendedPaymentFinish: 'suspendedPaymentExecution',
SuspendedPaymentCancel: 'suspendedPaymentCancellation',
EscrowCreate: 'escrowCreation',
EscrowFinish: 'escrowExecution',
EscrowCancel: 'escrowCancellation',
SignerListSet: 'settings',
SetFee: 'feeUpdate', // pseudo-transaction
EnableAmendment: 'amendment' // pseudo-transaction
@@ -40,9 +39,9 @@ function parseTransaction(tx: Object): Object {
'order': parseOrder,
'orderCancellation': parseOrderCancellation,
'settings': parseSettings,
'suspendedPaymentCreation': parseSuspendedPaymentCreation,
'suspendedPaymentExecution': parseSuspendedPaymentExecution,
'suspendedPaymentCancellation': parseSuspendedPaymentCancellation,
'escrowCreation': parseEscrowCreation,
'escrowExecution': parseEscrowExecution,
'escrowCancellation': parseEscrowCancellation,
'feeUpdate': parseFeeUpdate,
'amendment': parseAmendment
}