Skip to content

Commit

Permalink
Merge pull request #82 from Augmint/staging
Browse files Browse the repository at this point in the history
Release v0.3.2
  • Loading branch information
rszaloki authored May 27, 2019
2 parents 4b81fd3 + e8d761c commit 0ab2656
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@ augmint-cli : start / stop augmint contracts. Docker image: augmint/contracts:vx
Also recreates the container if it exists but image is not as expected (ie. there was a version upgrade)
## Publish NPM package
bump the version property in the package.json
release a new version as usual
- merge staging into master
- create a release in github with the vX.X.X tag on master
before npm publish, you need to build the library:
- checkout the master(!) branch
- `yarn clean`
- `yarn build`
npm publish from master branch. test it with --dry-run
## Contributions
Augmint is an open and transparent project.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augmint/js",
"version": "0.3.1",
"version": "0.3.2",
"description": "Augmint Javascript Library",
"keywords": [
"augmint javascript library A-EUR stablecoin web3 dapp"
Expand Down
10 changes: 7 additions & 3 deletions src/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ abstract class FixedPoint {
// conversion
//

public zeroToNull(): this | null {
return this.isZero() ? null : this;
}

public toJSON(): string {
return this.toString();
}
Expand Down Expand Up @@ -103,7 +107,7 @@ export class Wei extends FixedPoint {
static readonly DIV_PRECISON: BN = Wei.DIV_BN.divn(Wei.PRECISION);

public static parse(str: string): Wei {
return new Wei(new BN(str));
return new Wei(new BN(str.toString()));
}

public static of(num: number): Wei {
Expand All @@ -128,7 +132,7 @@ export class Tokens extends FixedPoint {
static readonly DIV: number = 100;

public static parse(str: string): Tokens {
return new Tokens(new BN(str));
return new Tokens(new BN(str.toString()));
}

public static of(num: number): Tokens {
Expand Down Expand Up @@ -164,7 +168,7 @@ export class Ratio extends FixedPoint {
static readonly DIV_BN: BN = new BN(Ratio.DIV);

public static parse(str: string): Ratio {
return new Ratio(new BN(str));
return new Ratio(new BN(str.toString()));
}

public static of(num: number): Ratio {
Expand Down
9 changes: 7 additions & 2 deletions test/units.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Units", () => {
assert.throws(() => new Type());
assert.throws(() => new Type(null));
})
});
});

it("no operations accross types", () => {
assert.throws(() => Wei.of(1).add(Tokens.of(100)));
Expand All @@ -21,7 +21,12 @@ describe("Units", () => {
assert.equal(Tokens.of(100.01).toString(16), "2711");
assert.equal(Ratio.of(1.01).toNumber(), 1.01);
assert.equal(JSON.stringify({ tokens: Tokens.of(100.01) }), '{"tokens":"10001"}');
});
assert.equal("10001", Tokens.parse("10001").toString());
assert.equal("10001", Tokens.parse(10001).toString());
assert.throws(() => Tokens.parse(null));
assert.isNull(Tokens.parse("0").zeroToNull());
assert.equal("10001", Tokens.parse(10001).zeroToNull().toString());
});

it("rounds Ratio properly", () => {
assert.equal(Ratio.of(1.025).toString(), "1025000")
Expand Down

0 comments on commit 0ab2656

Please sign in to comment.