From a5eed197d2c5e7164bf66dccd6b873a7a45d3fca Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sat, 20 Oct 2012 19:11:30 -0700 Subject: [PATCH] JS: Add Date support to offer_create. --- js/remote.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/remote.js b/js/remote.js index ee23fc2e..7a124177 100644 --- a/js/remote.js +++ b/js/remote.js @@ -808,8 +808,6 @@ var SUBMIT_LOST = 8; // Give up tracking. var Transaction = function (remote) { var self = this; - this.prototype = EventEmitter; // XXX Node specific. - this.remote = remote; this.secret = undefined; this.transaction = { // Transaction data. @@ -1033,7 +1031,7 @@ Transaction.prototype.offer_cancel = function (src, sequence) { return this; }; -// XXX Expiration should use a time. +// --> expiration : Date or Number Transaction.prototype.offer_create = function (src, taker_pays, taker_gets, expiration) { this.secret = this.account_secret(src); this.transaction.TransactionType = 'OfferCreate'; @@ -1042,8 +1040,12 @@ Transaction.prototype.offer_create = function (src, taker_pays, taker_gets, expi this.transaction.TakerPays = Amount.json_rewrite(taker_pays); this.transaction.TakerGets = Amount.json_rewrite(taker_gets); + this.prototype = EventEmitter; // XXX Node specific. + if (expiration) - this.transaction.Expiration = expiration; + this.transaction.Expiration = Date === expiration.constructor + ? expiration.getTime() + : Number(expiration); return this; };