1.0.3 • Published 8 months ago

test-maven-sdk v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Start a localnet and deploy contract

  1. Install SUI and add to path. Build SUI location.
yarn deps

If there is any issue regarding installation with rust, please check out the prerequisites and requirements in Sui official installation guide.

  1. Start SUI localnet
yarn localnet
  1. Clone ESafe repo

Clone ESafe repository to directory ../ESafe.

The repository need to be located at location ../ESafe

  1. Deploy ESafe smart contract

Go to Maven-SDK, deploy ESafe contract to localnet.

yarn deploy

At the end of execution, two contract addresses are given:

contract address of ./move: 0x5691dd8cec80295b52817695a2c53598817332c276ae58d46bfc3643b1d64d05
global_pause of ./move: 0xcf540a9fa0da8ce7b15b6504f1e1668b731f727f002cfa0541a136e3c5223bf6
  1. Copy the addresses to SDK repo

The target contants is stored at src/constants/maven.ts.

Both the address need to be replaced.

  1. Run tests to verify
yarn test

All tests shall pass.

=======

Doc

High Level Operations

Init

// implement a customized signer by using browser wallet
class WebSigner extends SignerProvider {}

// instantiate provider and clientt
const signerProvider = new WebSigner(CHAIN_ID);
const client = new TreasuryClient(signerProvider);

Create

//create a treasury with only one owner, which is the creator itself
const {treasury} = await client.create("Treasury")

CreateWithOwners

//create a treasury with two owners, the creator itself and account2
const account2 = await createKeypair();
const {treasury} = await client.createWithOwners("Test", [account2.getPublicKey().toSuiAddress()], 2, "");
//create from existing treasury
client.getTreasuryFromId("1", "2")

Treasury Information Read

//read the permissions of the treasury
await treasury.permissionBook()
//read the roles of the treasury
await treasury.roles()
//get the treasury owned coins
await treasury.ownedCoins()
//get all proposed transactions
await treasury.pendingTransactions()
//get treasury owners
await treasury.owners()
//get treasury threshold
await treasury.threshold()

DepositCoin

//deposit some amount of coin into the Treasury
await treasury.depositCoin(1000n, "0x02::sui::SUI");
//deposit multiple coins
await treasury.depositCoins([10n, 10n], ["0x02::sui::SUI", "dummyCoin"]);

TransferCoin

await treasury.proposeTransferCoin("0x02::sui::SUI", "0xreceiver", 1000n)

//transfer coins
await treasury.proposeTransferCoins([{coin: "dummyCoin", amount: 1n, receiver: "dummyReceiver"}])

DepositObject

//deposit object to treasury
await treasury.depositObject("1");
//depost multiple objects to treasury
await treasury.depositObjects([{objectId: "1"}])

TransferObject

//transfer object
await treasury.proposeTransferObject("id", "receiver");
//transfer multiple objects
await treasury.proposeTransferObjects([{id: "id", receiver: "receiver"}])

Simulation

//simulate single coin transfer
await treasury.transferCoin("dummyoin", "receiver", 100n, {simulation: true})
//simulate multiple coin transfer
await treasury.transferCoins([
  {coin: "coin1", receiver: "receiver", amount: 1n},
  {coin: "coin2", receiver: "receiver", amount: 1n},
], {simulation: true})

Update Threshold / Owners

await treasury.updateTreasury({addedOwners: ["a"], removedOwners: ["b"], threshold: 10})

Get wallet coins

// To be deprecated
await client.coinList()

Helper functions

await client.helper.coinList(address);
await client.helper.getBalance(owner, "0x2::sui::SUI");
await client.helper.getOwnedObjects(owner)
await client.helper.getCoinMeta(coinType);
await client.helper.isMavenAccount(mavenAddress);
await client.helper.isSuiAddress("0x123");

18.1.0

9 months ago

18.0.7

9 months ago

18.0.6

9 months ago

1.0.3

8 months ago

18.0.4

9 months ago

18.0.3

9 months ago

18.0.2

9 months ago

18.0.1

9 months ago

18.0.0

12 months ago

17.7.0

12 months ago

17.6.0

12 months ago

17.5.0

12 months ago

17.1.0

12 months ago

17.0.0

12 months ago

16.10.0

1 year ago

16.7.0

1 year ago

16.6.0

1 year ago

16.5.0

1 year ago

16.3.0

1 year ago

16.1.0

1 year ago

16.0.0

1 year ago

14.0.0

1 year ago

13.1.0

1 year ago

13.0.0

1 year ago

12.1.0

1 year ago

12.0.0

1 year ago

10.18.0

1 year ago

10.17.0

1 year ago

10.16.0

1 year ago

10.15.0

1 year ago

10.12.0

1 year ago

10.11.0

1 year ago

10.10.0

1 year ago

10.9.0

1 year ago

10.8.0

1 year ago

10.7.0

1 year ago

10.6.0

1 year ago

10.5.0

1 year ago

10.3.0

1 year ago

10.2.0

1 year ago

10.1.0

1 year ago

10.0.0

1 year ago

9.7.0

1 year ago

9.6.0

1 year ago

9.5.0

1 year ago

9.3.0

1 year ago

9.2.0

1 year ago

9.1.0

1 year ago

9.0.0

1 year ago

8.24.0

1 year ago

8.23.0

1 year ago

8.22.0

1 year ago

8.21.0

1 year ago

8.20.0

1 year ago

8.19.0

1 year ago

8.18.0

1 year ago

8.17.0

1 year ago

8.16.0

1 year ago

8.15.0

1 year ago

8.14.0

1 year ago

8.13.0

1 year ago

8.12.0

1 year ago

8.10.0

1 year ago

8.2.0

1 year ago

8.1.0

1 year ago

7.5.0

1 year ago

7.4.0

1 year ago

7.3.0

1 year ago

7.2.0

1 year ago

7.1.0

1 year ago

7.0.0

1 year ago

6.12.0

1 year ago

6.11.0

1 year ago

6.10.0

1 year ago

6.5.0

1 year ago

6.2.0

1 year ago

6.1.0

1 year ago

6.0.0

1 year ago

5.5.0

1 year ago

5.2.0

1 year ago

5.1.0

1 year ago

5.0.0

1 year ago

4.1.0

1 year ago

4.0.0

1 year ago

3.7.0

1 year ago

3.6.0

1 year ago

3.5.0

1 year ago

3.4.0

1 year ago

3.3.0

1 year ago

3.2.0

1 year ago

3.1.0

1 year ago

3.0.0

1 year ago

2.21.0

1 year ago

2.20.0

1 year ago

2.12.0

1 year ago

2.11.0

1 year ago

2.10.0

1 year ago

2.9.0

1 year ago

2.8.0

1 year ago

2.7.0

1 year ago

2.6.0

1 year ago

2.4.0

1 year ago

2.3.0

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.2.0

1 year ago

0.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

0.15.0

1 year ago

0.14.0

1 year ago

0.13.0

1 year ago

0.12.0

1 year ago

0.11.0

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago