Move-to-TypeScript Transpiler
`move-to-ts` is a Move-to-TypeScript transpiler and development framework for Aptos.
const {client, account} = ...;
// Load auto-generated App
const app = new App(client).hippo_tutorial.lend2;
// load User and LendingProtocol struct from chain
const user = await app.loadUser(account.address());
const protocol = await app.loadLendingProtocol(app.moduleAddress, false);
// call user_get_limits to compute some info about user's state
const [isUserHealthy, totalBorrow, totalDeposit] = user.user_get_limits(protocol);
console.log(isUserHealthy, totalBorrow, totalDeposit);
// make a withdrawal
await app.withdraw(account, u64(1000000), [app.FakeBTC.getTag()]);With move-to-ts(github), you can:
Interact with your Aptos contract using auto-generated TypeScript SDK
Interact with your Aptos contract using auto-generated CLI utility
Execute all your Move unit tests from TypeScript, and obtain better debugging information
The snippets below are taken from a simple lending tutorial.
Installation
Generate TypeScript SDK
Interact with contract using generated SDK
Interact with contract using generated CLI utility
When you add the #[cmd] attribute to your Move contract's public entry function, move-to-ts can help you automatically generate the corresponding CLI commandline invocation utility.
For example, for the public entry function admin_add_pool taken from our lending tutorial:
The auto-generated CLI utility has the following usage:
Debug Move unit tests
Currently it is probably easier to debug move unit tests via move-to-ts than it is using the native Move toolchain, because when a unit test throw error, its stack trace is printed by default and you can very quickly locate where the error has happened.
Last updated