If you don't have Rust:
Install Rust https://rustup.rs/
Add wasm32
target to Rust
rustup target add wasm32-unknown-unknown
Check for Rust version 1.51.0.
To compile the simulation tests mg-sim
, make sure to have at least Rust 1.51.0.
The mg-sim
tests depend indirectly on the arrayvec
library.
This library in v0.7.0
uses a Rust feature available from 1.51.0,
const generics.
You can check Rust version with rustc --version
.
If an update is needed, run
rustup update stable
near-ts
and near-md
(optional)near-ts
is a utility to generate TypeScript bindings from a Rust contract.
On the other hand, near-md
is a utility to generate Markdown documentation from a Rust contract.
You can install it with
cargo install near-syn
Or alternatively you can install it directly from GitHub
cargo install --git https://github.com/epam/near-syn --branch main
The package.json
contains scripts to facilitate running compilation targets and tests.
The following are the most relevant scripts.
build:contracts
.
Builds both mg_nft.wasm
and mg_market.wasm
contracts for the wasm32-unknown-unknown
target.
The wasm binaries can be found under release/wasm32-unknown-unknown/release
folder.unit-test:contracts
.
Runs both mg-nft
and mg-market
contract unit tests.
These tests are being executed locally using the host architecture.
In other words, they are not compile down to WebAssembly.app-test:contracts
.
Executes the application tests.
The application tests run both contracts in testnet
.
It creates user and contract accounts to test the contracts.
The accounts IDs used are cached in the neardev
folder.
Moreover, the script automatically deploys contracts to the testnet
contract accounts.
It ensures that both contracts are already built before running the tests.app-test:contracts:clean
.
Removes the neardev
folder which contains the account IDs created for app-test:contracts
.ts:contracts
.
Generates both mg-nft
and mg-market
contracts TypeScript bindings in src
folder.
The near-ts
utility (from near-syn
package) needs to be installed to execute this script.md:contracts
.
Generates both mg-nft
and mg-market
contracts documentation README.md
in their respective folders.
The near-md
utility (from near-syn
package) needs to be installed to execute this script.dev-deploy:contract
.
WIP. Deploys contracts to a dev account.deploy:contract
.
WIP. Deploys contracts to an already logged in account.build:lib
.
Builds the contract client library.lint:lib
.
Provides linting checks for the contract client library.measure:storage-costs
.
Performs an arbitrary number of operations for collectibles
and tokens
on nft-contract
and market-contract
.
Collects the information on how much Ⓝ reserved for storage. Generates data.js
file in tests
folder.measure:storage-costs
script measures the costs of storage for nft-contract
and market-contract
. It performs operations on collectibles
and tokens
on the contracts, collects the information on changes in Ⓝ reserved for storage for different methods.
By default, measure:storage-costs
adds 20 collectibes
and 40 tokens
for test account (it reuses already present accounts or creates new ones and deploys contracts if needed).
It is also possible to instruct the script to add the arbitrary number of collectibles
and tokens
.
To do so run from project's root:
ts-node test/measure.ts --collectibles 100 -- tokens 200
where:
--collectibles
: number of collectibles to add. Number of times create_collectible
, delete_collectible
will be executed.--tokens
: number of tokens to add. claim_token
, nft_transfer
, nft_approve
, batch_approve
, nft_revoke
, buy_token
will be executed for this number of tokens.The script generates data.js
file in tests
folder. The information from data.js
as datasets for charts in chart.html
file also located in tests
folder. To see the charts open chart.html
in any browser.
Example of storage costs charts with data generated by running measure
script with default values: