-
Notifications
You must be signed in to change notification settings - Fork 2
shuffle_dex_modules
Peter Maksymowsky edited this page Jan 20, 2022
·
5 revisions
Install brew: https://brew.sh/
Install deno: https://deno.land/#installation
From diem directory:
- Install Diem dependencies including Rust, Clang, Deno, etc, by running the
following script in
diem
root directory:
./scripts/dev_setup.sh
- Install shuffle binary
cargo install --path shuffle/cli
├── e2e # Directory contains end to end tests (currently irrelevant test)
├── integration # Directory contains integration tests (current irrelevant tests)
├── main # main directory
│ ├── build # Build directory
│ ├── generated # Generated type definitions for Typescript (including our scripts)
│ ├── sources # Our Move modules and scripts
| ├── devapi.ts # Typescript API functions (kind of useful)
| ...
| └── mod.ts # Other API functions (need to add manually)
└── stdlib # Move standard libarary
- Run
shuffle node
to bring up a local testnet -
cd
into theshuffle_dex_modules
directory - Run
shuffle account
which generates 2 accounts, our Parent VASP account for modules and a second for testing P2P transactions - Run
shuffle build
to do a test build and see if everything works as intended - Run
shuffle deploy
to deploy the modules once you are happy. You should see them be deployed in the output. - Run
shuffle console
to run an interactive repl console where you can run functions from the .ts files.
-
await devapi.accountTransactions()
to get your account's transactions -
await devapi.resources()
to get the resources for your account
We will want to write code/scripts in main/mod.ts
which can then be ran in the console. Helpers are generated in main/generated/diemStdlib/mod.ts
.
You will want to write your scripts inside the modules (don't know how to run them in the other way) like so:
public(script) fun mint_coin_b(account: signer, amt: u64) {
mint(amt, &account);
}
Then run shuffle deploy
and go to main.mod.ts
.
In there, write a new function like:
export async function mintCoinBFunction2(
amt: bigint,
) {
const payload = codegen.Stdlib.encodeMintCoinBScriptFunction( //This function is generated in generated/diemStdlib/mod.ts
amt,
);
return await DiemHelpers.buildAndSubmitTransaction(
defaultUserContext.address,
await devapi.sequenceNumber(),
await defaultUserContext.readPrivateKey(),
payload,
);
}
shuffle console -a 0xB1E55ED -k ~/.shuffle/nodeconfig/mint.key