Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,8 @@ This module provides some utility functions for more convenient work with Ever o
````typescript
import { toNano, fromNano, getRandomNonce, convertAmount, isValidEverAddress, stringToBytesArray } from "locklift";

toNano(10); // 10000000000
fromNano(10000000000); // 10```
toNano(10); // 10000000000 nano evers
fromNano(10000000000); // 10 evers```
````

## Plugins
Expand Down
4 changes: 4 additions & 0 deletions sample-project-typescript/contracts/Sample.tsol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ contract Sample {
emit StateChange(_state);
}

function fail() public {
require( 1 < 0, 101); // 100 is default error code, it is good to set non-default codes beforehand
}

function getDetails()
external
view
Expand Down
13 changes: 12 additions & 1 deletion sample-project-typescript/test/sample-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { expect } from "chai";
import { Contract, Signer } from "locklift";
import { FactorySource } from "../build/factorySource";
import { lockliftChai } from "locklift";
import chai from "chai";
chai.use(lockliftChai);

let sample: Contract<FactorySource["Sample"]>;
let signer: Signer;
Expand Down Expand Up @@ -29,7 +32,7 @@ describe("Test Sample contract", async function () {
constructorParams: {
_state: INIT_STATE,
},
value: locklift.utils.toNano(2),
value: locklift.utils.toNano(2), // converts 2 evers to nanos
});
sample = contract;

Expand All @@ -45,5 +48,13 @@ describe("Test Sample contract", async function () {

expect(Number(response._state)).to.be.equal(NEW_STATE, "Wrong state");
});

it("Test error tracing", async function () {
const { traceTree } = await locklift.tracing.trace(
await sample.methods.fail({}).sendExternal({ publicKey: signer.publicKey }),
{rise: false}
);
expect(traceTree).to.have.error(101);
});
});
});