stellar-base
Advanced tools
Comparing version 0.3.10 to 0.3.11
@@ -143,3 +143,3 @@ --- | ||
var keypair = Keypair.fromSeed('SECRETSEED'); | ||
transaction.sign([keypair]); | ||
transaction.sign(keypair); | ||
``` | ||
@@ -146,0 +146,0 @@ |
@@ -29,2 +29,4 @@ "use strict"; | ||
var trimRight = _lodash.trimRight; | ||
var isUndefined = _lodash.isUndefined; | ||
var isString = _lodash.isString; | ||
@@ -170,3 +172,3 @@ /** | ||
* @param {string} [opts.limit] - The limit for the asset, defaults to max int64. | ||
* If the limit is set to 0 it deletes the trustline. | ||
* If the limit is set to "0" it deletes the trustline. | ||
* @param {string} [opts.source] - The source account (defaults to transaction source). | ||
@@ -179,2 +181,5 @@ * @returns {xdr.ChangeTrustOp} | ||
attributes.line = opts.asset.toXdrObject(); | ||
if (!isUndefined(opts.limit) && !isString(opts.limit)) { | ||
throw new TypeError("limit argument must be of type String"); | ||
} | ||
var limit = opts.limit ? opts.limit : "9223372036854775807"; | ||
@@ -449,2 +454,3 @@ attributes.limit = Hyper.fromString(limit); | ||
result.line = Asset.fromOperation(attrs.line()); | ||
result.limit = attrs.limit().toString(); | ||
break; | ||
@@ -451,0 +457,0 @@ case "allowTrust": |
@@ -70,3 +70,3 @@ "use strict"; | ||
* Signs the transaction with the given Keypair. | ||
* @param {Keypair[]} keypairs | ||
* @param {...Keypair} keypairs | ||
*/ | ||
@@ -73,0 +73,0 @@ |
{ | ||
"name": "stellar-base", | ||
"version": "0.3.10", | ||
"version": "0.3.11", | ||
"description": "Low level stellar support library", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,3 +5,3 @@ import {xdr, Keypair, Hyper, UnsignedHyper, hash} from "./index"; | ||
import {best_r} from "./util/continued_fraction"; | ||
import {padRight, trimRight} from 'lodash'; | ||
import {padRight, trimRight, isUndefined, isString} from 'lodash'; | ||
@@ -107,3 +107,2 @@ /** | ||
let attributes = {}; | ||
@@ -133,3 +132,3 @@ attributes.sendAsset = opts.sendAsset.toXdrObject(); | ||
* @param {string} [opts.limit] - The limit for the asset, defaults to max int64. | ||
* If the limit is set to 0 it deletes the trustline. | ||
* If the limit is set to "0" it deletes the trustline. | ||
* @param {string} [opts.source] - The source account (defaults to transaction source). | ||
@@ -141,2 +140,5 @@ * @returns {xdr.ChangeTrustOp} | ||
attributes.line = opts.asset.toXdrObject(); | ||
if (!isUndefined(opts.limit) && !isString(opts.limit)) { | ||
throw new TypeError('limit argument must be of type String'); | ||
} | ||
let limit = opts.limit ? opts.limit : "9223372036854775807"; | ||
@@ -389,2 +391,3 @@ attributes.limit = Hyper.fromString(limit); | ||
result.line = Asset.fromOperation(attrs.line()); | ||
result.limit = attrs.limit().toString(); | ||
break; | ||
@@ -391,0 +394,0 @@ case "allowTrust": |
@@ -44,3 +44,3 @@ import {xdr, hash} from "./index"; | ||
* Signs the transaction with the given Keypair. | ||
* @param {Keypair[]} keypairs | ||
* @param {...Keypair} keypairs | ||
*/ | ||
@@ -47,0 +47,0 @@ sign(...keypairs) { |
@@ -74,4 +74,22 @@ describe('Operation', function() { | ||
expect(obj.type).to.be.equal("changeTrust"); | ||
expect(obj.line.equals(asset)).to.be.true; | ||
expect(obj.line).to.be.deep.equal(asset); | ||
expect(obj.limit).to.be.equal("9223372036854775807"); | ||
}); | ||
it("deletes a trustline", function () { | ||
let asset = new StellarBase.Asset("USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"); | ||
let op = StellarBase.Operation.changeTrust({asset: asset, limit: "0"}); | ||
var xdr = op.toXDR("hex"); | ||
var operation = StellarBase.xdr.Operation.fromXDR(new Buffer(xdr, "hex")); | ||
var obj = StellarBase.Operation.operationToObject(operation); | ||
expect(obj.type).to.be.equal("changeTrust"); | ||
expect(obj.line).to.be.deep.equal(asset); | ||
expect(obj.limit).to.be.equal("0"); | ||
}); | ||
it("throws TypeError for incorrect limit argument", function () { | ||
let asset = new StellarBase.Asset("USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"); | ||
let changeTrust = () => StellarBase.Operation.changeTrust({asset: asset, limit: 0}); | ||
expect(changeTrust).to.throw(TypeError); | ||
}); | ||
}); | ||
@@ -78,0 +96,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1683867
74
37453