Local Development
IOTA Owned Object Pools (IOTAOOP) 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/iotaledger/Iota_Owned_Object_Pools.git
Use a package manager to install dependencies from the root of the project.
- npm
- Yarn
- pnpm
npm install
yarn install
pnpm 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:
iota client switch --env testnet && iota client envs
Also, make sure that your admin account (the account iota client active-address
identifies) owns
enough IOTA. You can get IOTA for a test network from the
IOTA faucet.
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:
iota client switch --env testnet
At the end of the setup, your .env
should look like the template
.test.env.example.
:
# 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 txs. 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://api.testnet.iota.cafe:443"
IOTA_NODE= ...
GET_WORKER_TIMEOUT_MS=1000
You can run cat ~/.iota/iota_config/iota.keystore
to see your addresses' secret keys. Each
secret's corresponding address is in the same row line that appears in iota client addresses
.
The jest framework 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.
-
[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
- Yarn
- pnpm
npm run lint
yarn lint
pnpm run lint