mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-25 06:35:48 +00:00
JS: Add Date support to offer_create.
This commit is contained in:
committed by
Stefan Thomas
parent
a6a8b0b29a
commit
a5eed197d2
10
js/remote.js
10
js/remote.js
@@ -808,8 +808,6 @@ var SUBMIT_LOST = 8; // Give up tracking.
|
|||||||
var Transaction = function (remote) {
|
var Transaction = function (remote) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.prototype = EventEmitter; // XXX Node specific.
|
|
||||||
|
|
||||||
this.remote = remote;
|
this.remote = remote;
|
||||||
this.secret = undefined;
|
this.secret = undefined;
|
||||||
this.transaction = { // Transaction data.
|
this.transaction = { // Transaction data.
|
||||||
@@ -1033,7 +1031,7 @@ Transaction.prototype.offer_cancel = function (src, sequence) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
// XXX Expiration should use a time.
|
// --> expiration : Date or Number
|
||||||
Transaction.prototype.offer_create = function (src, taker_pays, taker_gets, expiration) {
|
Transaction.prototype.offer_create = function (src, taker_pays, taker_gets, expiration) {
|
||||||
this.secret = this.account_secret(src);
|
this.secret = this.account_secret(src);
|
||||||
this.transaction.TransactionType = 'OfferCreate';
|
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.TakerPays = Amount.json_rewrite(taker_pays);
|
||||||
this.transaction.TakerGets = Amount.json_rewrite(taker_gets);
|
this.transaction.TakerGets = Amount.json_rewrite(taker_gets);
|
||||||
|
|
||||||
|
this.prototype = EventEmitter; // XXX Node specific.
|
||||||
|
|
||||||
if (expiration)
|
if (expiration)
|
||||||
this.transaction.Expiration = expiration;
|
this.transaction.Expiration = Date === expiration.constructor
|
||||||
|
? expiration.getTime()
|
||||||
|
: Number(expiration);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user