Local Development
Sui Owned Object Pools (SuiOOP) is a beta library. Enhancements and changes are likely during development.
Installing the library
If you would like to extend the library by developing on your local machine, first you need to clone the repository.
git clone https://github.com/MystenLabs/Sui_Owned_Object_Pools.git
Use a package manager to install dependencies from the root of the project.
npm install
Testing
Tests, apart from checking if your changes break the existing codebase, are also a great way to get familiar with the library. For each test scenario, there is a small description of the test's purpose and the library's commands to achieve that.
To be able to run the tests, first you need to:
- Publish the package in the
move_examples/nft_app/
folder. - Have an account to use as an Admin account to create and execute transactions, from coin transfers to NFT minting.
- Have a test user account to use as a receiver of the transactions.
You can run the ./test/initial_setup.sh
script to perform these steps for you, or perform them
manually.
Before proceeding make sure that you are using the testnet
environment:
sui client switch --env testnet && sui client envs
Also, make sure that your admin account (the account sui client active-address
identifies) owns
enough SUI. You can get SUI for a test network from the
Sui faucet (opens in a new tab).
Next, run the setup script:
cd test && chmod u+x test/initial_setup.sh # give the user the right to execute the setup script
./initial_setup.sh testnet # create a setup for testnet
The script creates a .test.env
file in the test/
folder. When the script is complete, you need
to add an ADMIN_SECRET_KEY
and a TEST_USER_SECRET
to the .env
.
The Testnet network is typically used for testing. Switch to Testnet with:
sui client switch --env testnet
At the end of the setup, your .env
should look like the template
.test.env.example.
(opens in a new tab):
# The Admin should also be the publisher of the nft_app smart contract
ADMIN_ADDRESS= ...
ADMIN_SECRET_KEY= ...
# A user address that is used as a receiver of txbs. Used for testing.
TEST_USER_ADDRESS= ...
TEST_USER_SECRET= ...
# Used for testing. Get this by publishing the move_examples/nft_app/
NFT_APP_PACKAGE_ID= ...
NFT_APP_ADMIN_CAP= ...
# Example: "https://fullnode.testnet.sui.io:443"
SUI_NODE= ...
GET_WORKER_TIMEOUT_MS=1000
You can run cat ~/.sui/sui_config/sui.keystore
to see your addresses' secret keys. Each secret's
corresponding address is in the same row line that appears in sui client addresses
.
The jest framework (opens in a new tab) is recommended for testing. Having installed the project's
packages with npm install
, you can run the tests by either:
-
[Recommended] The vscode
jest
extension (Extension ID: Orta.vscode-jest)The extension provides a flask to the IDE sidebar where you run the tests (altogether or one-by-one) and shows the results in the editor. You can also run the tests in debug mode and set breakpoints in the code. Useful when performing test-driven development (opens in a new tab).
-
[Best for CI/CD] Run
npm run test
from the command line.
Code consistency
Before committing your changes, run the linter to check for code style consistency.
npm run lint