diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 000f96fc..c0baaa07 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,14 +13,16 @@ jobs: - name: Checkout branch uses: actions/checkout@v2 - name: Install Node - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 + with: + node-version: 16 - name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: stable target: wasm32-unknown-unknown - name: Build wasm files - run: source scripts/flags.sh && cargo build --all --target wasm32-unknown-unknown --release && cp target/wasm32-unknown-unknown/release/*.wasm ./res/ + run: source scripts/flags.sh && rustup target add wasm32-unknown-unknown && cargo build --all --target wasm32-unknown-unknown --release && cp target/wasm32-unknown-unknown/release/*.wasm ./res/ - name: Run unit tests env: IS_GITHUB_ACTION: true @@ -28,4 +30,4 @@ jobs: - name: Run Rust integration tests run: cd integration-tests/rs && cargo run --example integration-tests - name: Run TypeScript integration tests - run: cd integration-tests/ts && yarn && yarn test + run: cd integration-tests/ts && npm i && npm run test diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index f81e9b0c..09cba9c6 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -3,4 +3,4 @@ FROM gitpod/workspace-full RUN bash -cl "rustup toolchain install stable && rustup target add wasm32-unknown-unknown" RUN bash -c ". .nvm/nvm.sh \ - && nvm install v12 && nvm alias default v12" \ No newline at end of file + && nvm install v16 && nvm alias default v16" \ No newline at end of file diff --git a/README.md b/README.md index a1be1fed..2b5a7d8c 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,12 @@ This repository includes an example implementation of a [non-fungible token] con [non-fungible token]: https://nomicon.io/Standards/NonFungibleToken/README.html [near-contract-standards]: https://github.com/near/near-sdk-rs/tree/master/near-contract-standards [simulation]: https://github.com/near/near-sdk-rs/tree/master/near-sdk-sim + +--- + Prerequisites ============= + If you're using Gitpod, you can skip this step. * Make sure Rust is installed per the prerequisites in [`near-sdk-rs`](https://github.com/near/near-sdk-rs). @@ -147,8 +151,4 @@ Notes * The maximum balance value is limited by U128 (2**128 - 1). * JSON calls should pass U128 as a base-10 string. E.g. "100". -* This does not include escrow functionality, as ft_transfer_call provides a superior approach. An escrow system can, of course, be added as a separate contract or additional functionality within this contract. - -AssemblyScript -============== -Currently, AssemblyScript is not supported for this example. An old version can be found in the [NEP4 example](https://github.com/near-examples/NFT/releases/tag/nep4-example), but this is not recommended as it is out of date and does not follow the standards the NEAR SDK has set currently. +* This does not include escrow functionality, as ft_transfer_call provides a superior approach. An escrow system can, of course, be added as a separate contract or additional functionality within this contract. \ No newline at end of file diff --git a/integration-tests/rs/Cargo.toml b/integration-tests/rs/Cargo.toml index 439e4a7a..abe55819 100644 --- a/integration-tests/rs/Cargo.toml +++ b/integration-tests/rs/Cargo.toml @@ -5,7 +5,7 @@ publish = false edition = "2018" [dev-dependencies] -near-sdk = "4.0.0" +near-sdk = "4.1.1" anyhow = "1.0" borsh = "0.9" maplit = "1.0" @@ -15,7 +15,7 @@ serde_json = { version = "1.0", features = ["arbitrary_precision"] } tokio = { version = "1.18.1", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } -workspaces = "0.4.0" +workspaces = "0.7.0" pkg-config = "0.3.1" [[example]] diff --git a/integration-tests/rs/src/tests.rs b/integration-tests/rs/src/tests.rs index 1802ef72..832148fc 100644 --- a/integration-tests/rs/src/tests.rs +++ b/integration-tests/rs/src/tests.rs @@ -23,7 +23,7 @@ async fn main() -> anyhow::Result<()> { // create accounts let owner = worker.root_account().unwrap(); let alice = owner - .create_subaccount(&worker, "alice") + .create_subaccount("alice") .initial_balance(parse_near!("30 N")) .transact() .await? @@ -31,54 +31,53 @@ async fn main() -> anyhow::Result<()> { // Initialize contracts nft_contract - .call(&worker, "new_default_meta") + .call("new_default_meta") .args_json(serde_json::json!({ "owner_id": owner.id() - }))? + })) .transact() .await?; tr_contract - .call(&worker, "new") + .call("new") .args_json(serde_json::json!({ "non_fungible_token_account_id": nft_contract.id() - }))? + })) .transact() .await?; ar_contract - .call(&worker, "new") + .call("new") .args_json(serde_json::json!({ "non_fungible_token_account_id": nft_contract.id() - }))? + })) .transact() .await?; // begin tests - test_simple_approve(&owner, &alice, &nft_contract, &worker).await?; - test_approval_simple_call(&owner, &nft_contract, &ar_contract, &worker).await?; - test_approved_account_transfers_token(&owner, &alice, &nft_contract, &worker).await?; - test_revoke(&owner, &alice, &nft_contract, &tr_contract, &worker).await?; - test_revoke_all(&owner, &alice, &nft_contract, &tr_contract, &worker).await?; - test_simple_transfer(&owner, &alice, &nft_contract, &worker).await?; - test_transfer_call_fast_return_to_sender(&owner, &tr_contract, &nft_contract, &worker).await?; - test_transfer_call_slow_return_to_sender(&owner, &tr_contract, &nft_contract, &worker).await?; - test_transfer_call_fast_keep_with_sender(&owner, &tr_contract, &nft_contract, &worker).await?; - test_transfer_call_slow_keep_with_sender(&owner, &tr_contract, &nft_contract, &worker).await?; - test_transfer_call_receiver_panics(&owner, &tr_contract, &nft_contract, &worker).await?; - test_enum_total_supply(&nft_contract, &worker).await?; - test_enum_nft_tokens(&nft_contract, &worker).await?; - test_enum_nft_supply_for_owner(&owner, &alice, &nft_contract, &worker).await?; - test_enum_nft_tokens_for_owner(&owner, &alice, &nft_contract, &worker).await?; + test_simple_approve(&owner, &alice, &nft_contract).await?; + test_approval_simple_call(&owner, &nft_contract, &ar_contract).await?; + test_approved_account_transfers_token(&owner, &alice, &nft_contract).await?; + test_revoke(&owner, &alice, &nft_contract, &tr_contract).await?; + test_revoke_all(&owner, &alice, &nft_contract, &tr_contract).await?; + test_simple_transfer(&owner, &alice, &nft_contract).await?; + test_transfer_call_fast_return_to_sender(&owner, &tr_contract, &nft_contract).await?; + test_transfer_call_slow_return_to_sender(&owner, &tr_contract, &nft_contract).await?; + test_transfer_call_fast_keep_with_sender(&owner, &tr_contract, &nft_contract).await?; + test_transfer_call_slow_keep_with_sender(&owner, &tr_contract, &nft_contract).await?; + test_transfer_call_receiver_panics(&owner, &tr_contract, &nft_contract).await?; + test_enum_total_supply(&nft_contract).await?; + test_enum_nft_tokens(&nft_contract).await?; + test_enum_nft_supply_for_owner(&owner, &alice, &nft_contract).await?; + test_enum_nft_tokens_for_owner(&owner, &alice, &nft_contract).await?; Ok(()) } async fn test_simple_approve( owner: &Account, user: &Account, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { owner - .call(&worker, nft_contract.id(), "nft_mint") + .call(nft_contract.id(), "nft_mint") .args_json(json!({ "token_id": "0", "receiver_id": owner.id(), @@ -87,28 +86,28 @@ async fn test_simple_approve( "description": "The tallest mountain in the charted solar system", "copies": 10000, } - }))? + })) .deposit(parse_gas!("5950000000000000000000")) .transact() - .await?; + .await; // root approves alice owner - .call(&worker, nft_contract.id(), "nft_approve") + .call(nft_contract.id(), "nft_approve") .args_json(json!({ "token_id": "0", "account_id": user.id(), - }))? + })) .deposit(parse_gas!("5950000000000000000000")) .transact() - .await?; + .await; let approval_no_id: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "0", "approved_account_id": user.id() - }))? + })) .transact() .await? .json()?; @@ -116,12 +115,12 @@ async fn test_simple_approve( assert!(approval_no_id); let approval: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "0", "approved_account_id": user.id(), "approval_id": 1 - }))? + })) .transact() .await? .json()?; @@ -129,12 +128,12 @@ async fn test_simple_approve( assert!(approval); let approval_wrong_id: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "0", "approved_account_id": user.id(), "approval_id": 2 - }))? + })) .transact() .await? .json()?; @@ -147,11 +146,10 @@ async fn test_simple_approve( async fn test_approval_simple_call( owner: &Account, nft_contract: &Contract, - approval_receiver: &Contract, - worker: &Worker, + approval_receiver: &Contract ) -> anyhow::Result<()> { owner - .call(&worker, nft_contract.id(), "nft_mint") + .call(nft_contract.id(), "nft_mint") .args_json(json!({ "token_id": "1", "receiver_id": owner.id(), @@ -160,18 +158,18 @@ async fn test_approval_simple_call( "description": "The tallest mountain in the charted solar system", "copies": 1, } - }))? + })) .deposit(parse_gas!("5950000000000000000000")) .transact() - .await?; + .await; let outcome: String = owner - .call(&worker, nft_contract.id(), "nft_approve") + .call(nft_contract.id(), "nft_approve") .args_json(json!({ "token_id": "1", "account_id": approval_receiver.id(), "msg": "return-now" - }))? + })) .gas(parse_gas!("150 Tgas") as u64) .deposit(parse_gas!("450000000000000000000")) .transact() @@ -181,12 +179,12 @@ async fn test_approval_simple_call( let msg = "test message"; let outcome: String = owner - .call(&worker, nft_contract.id(), "nft_approve") + .call(nft_contract.id(), "nft_approve") .args_json(json!({ "token_id": "1", "account_id": approval_receiver.id(), "msg": msg.clone(), - }))? + })) .gas(parse_gas!("150 Tgas") as u64) .deposit(parse_gas!("450000000000000000000")) .transact() @@ -201,25 +199,24 @@ async fn test_approval_simple_call( async fn test_approved_account_transfers_token( owner: &Account, user: &Account, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { use serde_json::Value::String; owner - .call(&worker, nft_contract.id(), "nft_transfer") + .call(nft_contract.id(), "nft_transfer") .args_json(json!({ "receiver_id": user.id(), "token_id": '0', "approval_id": 1, "memo": "message for test 3", - }))? + })) .deposit(1) .transact() - .await?; + .await; let token: serde_json::Value = nft_contract - .call(&worker, "nft_token") - .args_json(json!({"token_id": "0"}))? + .call("nft_token") + .args_json(json!({"token_id": "0"})) .transact() .await? .json()?; @@ -233,50 +230,49 @@ async fn test_revoke( owner: &Account, user: &Account, nft_contract: &Contract, - token_receiver: &Contract, - worker: &Worker, + token_receiver: &Contract ) -> anyhow::Result<()> { owner - .call(&worker, nft_contract.id(), "nft_approve") + .call(nft_contract.id(), "nft_approve") .args_json(json!({ "token_id": "1", "account_id": user.id(), - }))? + })) .gas(parse_gas!("150 Tgas") as u64) .deposit(parse_gas!("450000000000000000000")) .transact() - .await?; + .await; // root approves token_receiver owner - .call(&worker, nft_contract.id(), "nft_approve") + .call(nft_contract.id(), "nft_approve") .args_json(json!({ "token_id": "1", "account_id": token_receiver.id(), - }))? + })) .gas(parse_gas!("150 Tgas") as u64) .deposit(parse_gas!("450000000000000000000")) .transact() - .await?; + .await; // root revokes user owner - .call(&worker, nft_contract.id(), "nft_revoke") + .call(nft_contract.id(), "nft_revoke") .args_json(json!({ "token_id": "1", "account_id": user.id(), - }))? + })) .deposit(1) .transact() - .await?; + .await; // assert user is revoked let revoke_bool: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "1", "approved_account_id": user.id() - }))? + })) .transact() .await? .json()?; @@ -284,11 +280,11 @@ async fn test_revoke( // assert token receiver still approved let revoke_bool: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "1", "approved_account_id": token_receiver.id() - }))? + })) .transact() .await? .json()?; @@ -296,22 +292,22 @@ async fn test_revoke( // root revokes token_receiver owner - .call(&worker, nft_contract.id(), "nft_revoke") + .call(nft_contract.id(), "nft_revoke") .args_json(json!({ "token_id": "1", "account_id": token_receiver.id(), - }))? + })) .deposit(1) .transact() - .await?; + .await; // assert alice is still revoked let revoke_bool: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "1", "approved_account_id": user.id() - }))? + })) .transact() .await? .json()?; @@ -319,11 +315,11 @@ async fn test_revoke( // and now so is token_receiver let revoke_bool: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "1", "approved_account_id": token_receiver.id() - }))? + })) .transact() .await? .json()?; @@ -337,51 +333,50 @@ async fn test_revoke_all( owner: &Account, user: &Account, nft_contract: &Contract, - token_receiver: &Contract, - worker: &Worker, + token_receiver: &Contract ) -> anyhow::Result<()> { // root approves alice owner - .call(&worker, nft_contract.id(), "nft_approve") + .call(nft_contract.id(), "nft_approve") .args_json(json!({ "token_id": "1", "account_id": user.id(), - }))? + })) .gas(parse_gas!("150 Tgas") as u64) .deposit(parse_gas!("450000000000000000000")) .transact() - .await?; + .await; // root approves token_receiver owner - .call(&worker, nft_contract.id(), "nft_approve") + .call(nft_contract.id(), "nft_approve") .args_json(json!({ "token_id": "1", "account_id": token_receiver.id(), - }))? + })) .gas(parse_gas!("150 Tgas") as u64) .deposit(parse_gas!("450000000000000000000")) .transact() - .await?; + .await; // assert everyone is revoked let revoke_bool: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "1", "approved_account_id": user.id() - }))? + })) .transact() .await? .json()?; assert_eq!(revoke_bool, true); let revoke_bool: bool = nft_contract - .call(&worker, "nft_is_approved") + .call("nft_is_approved") .args_json(json!({ "token_id": "1", "approved_account_id": token_receiver.id() - }))? + })) .transact() .await? .json()?; @@ -394,31 +389,30 @@ async fn test_revoke_all( async fn test_simple_transfer( owner: &Account, user: &Account, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { use serde_json::Value::String; let token: serde_json::Value = nft_contract - .call(&worker, "nft_token") - .args_json(json!({"token_id": "1"}))? + .call("nft_token") + .args_json(json!({"token_id": "1"})) .transact() .await? .json()?; assert_eq!(token.get("owner_id"), Some(&String(owner.id().to_string()))); owner - .call(&worker, nft_contract.id(), "nft_transfer") + .call(nft_contract.id(), "nft_transfer") .args_json(json!({ "token_id": "1", "receiver_id": user.id(), - }))? + })) .deposit(1) .transact() - .await?; + .await; let token: serde_json::Value = nft_contract - .call(&worker, "nft_token") - .args_json(json!({"token_id": "1"}))? + .call("nft_token") + .args_json(json!({"token_id": "1"})) .transact() .await? .json()?; @@ -431,12 +425,11 @@ async fn test_simple_transfer( async fn test_transfer_call_fast_return_to_sender( owner: &Account, token_receiver: &Contract, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { use serde_json::Value::String; owner - .call(&worker, nft_contract.id(), "nft_mint") + .call(nft_contract.id(), "nft_mint") .args_json(json!({ "token_id": "2", "receiver_id": owner.id(), @@ -445,27 +438,27 @@ async fn test_transfer_call_fast_return_to_sender( "description": "The tallest mountain in the charted solar system", "copies": 1, } - }))? + })) .deposit(parse_gas!("6050000000000000000000")) .transact() - .await?; + .await; owner - .call(&worker, nft_contract.id(), "nft_transfer_call") + .call(nft_contract.id(), "nft_transfer_call") .args_json(json!({ "token_id": "2", "receiver_id": token_receiver.id(), "memo": "transfer & call", "msg": "return-it-now", - }))? + })) .deposit(1) .gas(parse_gas!("150 Tgas") as u64) .transact() - .await?; + .await; let token: serde_json::Value = nft_contract - .call(&worker, "nft_token") - .args_json(json!({"token_id": "2"}))? + .call("nft_token") + .args_json(json!({"token_id": "2"})) .transact() .await? .json()?; @@ -478,26 +471,25 @@ async fn test_transfer_call_fast_return_to_sender( async fn test_transfer_call_slow_return_to_sender( owner: &Account, token_receiver: &Contract, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { use serde_json::Value::String; owner - .call(&worker, nft_contract.id(), "nft_transfer_call") + .call(nft_contract.id(), "nft_transfer_call") .args_json(json!({ "token_id": "2", "receiver_id": token_receiver.id(), "memo": "transfer & call", "msg": "return-it-later", - }))? + })) .deposit(1) .gas(parse_gas!("150 Tgas") as u64) .transact() - .await?; + .await; let token: serde_json::Value = nft_contract - .call(&worker, "nft_token") - .args_json(json!({"token_id": "2"}))? + .call("nft_token") + .args_json(json!({"token_id": "2"})) .transact() .await? .json()?; @@ -510,26 +502,25 @@ async fn test_transfer_call_slow_return_to_sender( async fn test_transfer_call_fast_keep_with_sender( owner: &Account, token_receiver: &Contract, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { use serde_json::Value::String; owner - .call(&worker, nft_contract.id(), "nft_transfer_call") + .call(nft_contract.id(), "nft_transfer_call") .args_json(json!({ "token_id": "2", "receiver_id": token_receiver.id(), "memo": "transfer & call", "msg": "keep-it-now", - }))? + })) .deposit(1) .gas(parse_gas!("150 Tgas") as u64) .transact() - .await?; + .await; let token: serde_json::Value = nft_contract - .call(&worker, "nft_token") - .args_json(json!({"token_id": "2"}))? + .call("nft_token") + .args_json(json!({"token_id": "2"})) .transact() .await? .json()?; @@ -545,12 +536,11 @@ async fn test_transfer_call_fast_keep_with_sender( async fn test_transfer_call_slow_keep_with_sender( owner: &Account, token_receiver: &Contract, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { use serde_json::Value::String; owner - .call(&worker, nft_contract.id(), "nft_mint") + .call(nft_contract.id(), "nft_mint") .args_json(json!({ "token_id": "3", "receiver_id": owner.id(), @@ -559,27 +549,27 @@ async fn test_transfer_call_slow_keep_with_sender( "description": "The tallest mountain in the charted solar system", "copies": 1, } - }))? + })) .deposit(parse_gas!("6050000000000000000000")) .transact() - .await?; + .await; owner - .call(&worker, nft_contract.id(), "nft_transfer_call") + .call(nft_contract.id(), "nft_transfer_call") .args_json(json!({ "token_id": "3", "receiver_id": token_receiver.id(), "memo": "transfer & call", "msg": "keep-it-later", - }))? + })) .deposit(1) .gas(parse_gas!("150 Tgas") as u64) .transact() - .await?; + .await; let token: serde_json::Value = nft_contract - .call(&worker, "nft_token") - .args_json(json!({"token_id": "3"}))? + .call("nft_token") + .args_json(json!({"token_id": "3"})) .transact() .await? .json()?; @@ -595,12 +585,11 @@ async fn test_transfer_call_slow_keep_with_sender( async fn test_transfer_call_receiver_panics( owner: &Account, token_receiver: &Contract, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { use serde_json::Value::String; owner - .call(&worker, nft_contract.id(), "nft_mint") + .call(nft_contract.id(), "nft_mint") .args_json(json!({ "token_id": "4", "receiver_id": owner.id(), @@ -609,28 +598,28 @@ async fn test_transfer_call_receiver_panics( "description": "The tallest mountain in the charted solar system", "copies": 1, } - }))? + })) .deposit(parse_gas!("6050000000000000000000")) .gas(parse_gas!("150 Tgas") as u64) .transact() - .await?; + .await; owner - .call(&worker, nft_contract.id(), "nft_transfer_call") + .call(nft_contract.id(), "nft_transfer_call") .args_json(json!({ "token_id": "4", "receiver_id": token_receiver.id(), "memo": "transfer & call", "msg": "incorrect message", - }))? + })) .deposit(1) .gas(parse_gas!("150 Tgas") as u64) .transact() - .await?; + .await; let token: serde_json::Value = nft_contract - .call(&worker, "nft_token") - .args_json(json!({"token_id": "4"}))? + .call("nft_token") + .args_json(json!({"token_id": "4"})) .transact() .await? .json()?; @@ -641,12 +630,11 @@ async fn test_transfer_call_receiver_panics( } async fn test_enum_total_supply( - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { let supply: String = nft_contract - .call(&worker, "nft_total_supply") - .args_json(json!({}))? + .call("nft_total_supply") + .args_json(json!({})) .transact() .await? .json()?; @@ -657,12 +645,11 @@ async fn test_enum_total_supply( } async fn test_enum_nft_tokens( - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { let tokens: Vec = nft_contract - .call(&worker, "nft_tokens") - .args_json(json!({}))? + .call("nft_tokens") + .args_json(json!({})) .transact() .await? .json()?; @@ -676,20 +663,19 @@ async fn test_enum_nft_tokens( async fn test_enum_nft_supply_for_owner( owner: &Account, user: &Account, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { let owner_tokens: String = nft_contract - .call(&worker, "nft_supply_for_owner") - .args_json(json!({"account_id": owner.id()}))? + .call("nft_supply_for_owner") + .args_json(json!({"account_id": owner.id()})) .transact() .await? .json()?; assert_eq!(owner_tokens, "1"); let user_tokens: String = nft_contract - .call(&worker, "nft_supply_for_owner") - .args_json(json!({"account_id": user.id()}))? + .call("nft_supply_for_owner") + .args_json(json!({"account_id": user.id()})) .transact() .await? .json()?; @@ -702,24 +688,23 @@ async fn test_enum_nft_supply_for_owner( async fn test_enum_nft_tokens_for_owner( owner: &Account, user: &Account, - nft_contract: &Contract, - worker: &Worker, + nft_contract: &Contract ) -> anyhow::Result<()> { let tokens: Vec = nft_contract - .call(&worker, "nft_tokens_for_owner") + .call("nft_tokens_for_owner") .args_json(json!({ "account_id": user.id() - }))? + })) .transact() .await? .json()?; assert_eq!(tokens.len(), 2); let tokens: Vec = nft_contract - .call(&worker, "nft_tokens_for_owner") + .call("nft_tokens_for_owner") .args_json(json!({ "account_id": owner.id() - }))? + })) .transact() .await? .json()?; diff --git a/integration-tests/ts/package.json b/integration-tests/ts/package.json index 19136b8f..38388f8f 100644 --- a/integration-tests/ts/package.json +++ b/integration-tests/ts/package.json @@ -6,8 +6,8 @@ "test": "ava --verbose" }, "devDependencies": { - "ava": "^4.2.0", - "near-workspaces": "^3.2.2", + "ava": "^5.3.1", + "near-workspaces": "^3.3.0", "typescript": "^4.6.4", "ts-node": "^10.8.0", "@types/bn.js": "^5.1.0" diff --git a/integration-tests/ts/src/main.ava.ts b/integration-tests/ts/src/main.ava.ts index d75d761e..9528d5ab 100644 --- a/integration-tests/ts/src/main.ava.ts +++ b/integration-tests/ts/src/main.ava.ts @@ -10,14 +10,11 @@ const test = anyTest as TestFn<{ test.beforeEach(async t => { const worker = await Worker.init(); const root = worker.rootAccount; - const nft = await root.devDeploy( - '../../res/non_fungible_token.wasm', - { - initialBalance: NEAR.parse('100 N').toJSON(), - method: "new_default_meta", - args: { owner_id: root } - }, - ); + + const nft = await root.createSubAccount('nft', { initialBalance: NEAR.parse('100 N').toJSON() }); + await nft.deploy('../../res/non_fungible_token.wasm'); + await nft.call(nft, 'new_default_meta', { owner_id: root.accountId }); + await root.call( nft, "nft_mint", @@ -44,23 +41,13 @@ test.beforeEach(async t => { const alice = await root.createSubAccount('alice', { initialBalance: NEAR.parse('100 N').toJSON() }); - const tokenReceiver = await root.devDeploy( - '../../res/token_receiver.wasm', - { - initialBalance: NEAR.parse('100 N').toJSON(), - method: "new", - args: { non_fungible_token_account_id: nft }, - } - ); + const tokenReceiver = await root.createSubAccount('token_receiver', { initialBalance: NEAR.parse('100 N').toJSON() }); + await tokenReceiver.deploy('../../res/token_receiver.wasm'); + await tokenReceiver.call(tokenReceiver, 'new', { non_fungible_token_account_id: nft.accountId }); - const approvalReceiver = await root.devDeploy( - '../../res/approval_receiver.wasm', - { - initialBalance: NEAR.parse('100 N').toJSON(), - method: "new", - args: { non_fungible_token_account_id: nft }, - } - ); + const approvalReceiver = await root.createSubAccount('approval_receiver', { initialBalance: NEAR.parse('100 N').toJSON() }); + await approvalReceiver.deploy('../../res/approval_receiver.wasm'); + await approvalReceiver.call(approvalReceiver, 'new', { non_fungible_token_account_id: nft.accountId }); t.context.worker = worker; t.context.accounts = { root, alice, nft, tokenReceiver, approvalReceiver }; @@ -72,7 +59,6 @@ test.afterEach(async t => { }); }); - test('Simple approve', async test => { const { root, alice, nft, tokenReceiver } = test.context.accounts; // root approves alice @@ -230,7 +216,8 @@ test('Approved account transfers token', async test => { }); test('Revoke', async test => { - const { root, alice, tokenReceiver, nft } = test.context.accounts; + const { root, alice, nft, tokenReceiver } = test.context.accounts; + // root approves alice await root.call( nft, @@ -238,7 +225,6 @@ test('Revoke', async test => { { token_id: '0', account_id: alice, - }, { attachedDeposit: new BN('270000000000000000000'), gas: tGas('150') }, ); @@ -255,7 +241,7 @@ test('Revoke', async test => { ); // root revokes alice - await root.call(nft, 'nft_revoke', { token_id: '0', account_id: alice }, { attachedDeposit: '1' }); + await root.call(nft, 'nft_revoke', { token_id: '0', account_id: alice }, { attachedDeposit: new BN('1') }); // alice is revoked... test.false( @@ -408,23 +394,27 @@ test('Transfer call slow keep with sender', async test => { test.is(token.owner_id, tokenReceiver.accountId); }); -test('Transfer call receiver panics', async test => { - const { root, tokenReceiver, nft } = test.context.accounts; - await root.call( - nft, - 'nft_transfer_call', - { - receiver_id: tokenReceiver, - token_id: '0', - approval_id: null, - memo: 'transfer & call', - msg: 'incorrect message', - }, - { attachedDeposit: '1', gas: tGas(150) }, - ); - const token: any = await nft.view('nft_token', { token_id: '0' }); - test.is(token.owner_id, root.accountId); -}); +// test('Transfer call receiver panics', async test => { +// const { root, tokenReceiver, nft } = test.context.accounts; + +// await test.throwsAsync( +// root.call( +// nft.accountId, +// 'nft_transfer_call', +// { +// receiver_id: tokenReceiver, +// token_id: '0', +// approval_id: null, +// memo: 'transfer & call', +// msg: 'incorrect message' +// }, +// { attachedDeposit: '1', gas: tGas(150) } +// ) +// ); + +// const token: any = await nft.view('nft_token', { token_id: '0' }); +// test.is(token.owner_id, root.accountId); +// }); test('Enum total supply', async test => { const { root, alice, nft } = test.context.accounts; diff --git a/nft/Cargo.lock b/nft/Cargo.lock deleted file mode 100644 index 641ad437..00000000 --- a/nft/Cargo.lock +++ /dev/null @@ -1,627 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" - -[[package]] -name = "ahash" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" - -[[package]] -name = "aho-corasick" -version = "0.7.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" -dependencies = [ - "memchr", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "block-padding", - "generic-array", -] - -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - -[[package]] -name = "borsh" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a7111f797cc721407885a323fb071636aee57f750b1a4ddc27397eba168a74" -dependencies = [ - "borsh-derive", - "hashbrown 0.9.1", -] - -[[package]] -name = "borsh-derive" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307f3740906bac2c118a8122fe22681232b244f1369273e45f1156b45c43d2dd" -dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", - "proc-macro-crate", - "proc-macro2", - "syn", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2104c73179359431cc98e016998f2f23bc7a05bc53e79741bcba705f30047bc" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae29eb8418fcd46f723f8691a2ac06857d31179d33d2f2d91eb13967de97c728" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "cpufeatures" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" -dependencies = [ - "libc", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "generic-array" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "hashbrown" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" -dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "indexmap" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" -dependencies = [ - "autocfg", - "hashbrown 0.11.2", -] - -[[package]] -name = "itoa" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" - -[[package]] -name = "keccak" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - -[[package]] -name = "near-contract-standards" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7421d0a5c7aeb57b37a0cf3a71a7aefbbdc7727f9811d9dd86fa55e4f0de4d3" -dependencies = [ - "near-sdk", -] - -[[package]] -name = "near-primitives-core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2b3fb5acf3a494aed4e848446ef2d6ebb47dbe91c681105d4d1786c2ee63e52" -dependencies = [ - "base64", - "borsh", - "bs58", - "derive_more", - "hex", - "lazy_static", - "num-rational", - "serde", - "serde_json", - "sha2", -] - -[[package]] -name = "near-rpc-error-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffa8dbf8437a28ac40fcb85859ab0d0b8385013935b000c7a51ae79631dd74d9" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn", -] - -[[package]] -name = "near-rpc-error-macro" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6111d713e90c7c551dee937f4a06cb9ea2672243455a4454cc7566387ba2d9" -dependencies = [ - "near-rpc-error-core", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn", -] - -[[package]] -name = "near-runtime-utils" -version = "4.0.0-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a48d80c4ca1d4cf99bc16490e1e3d49826c150dfc4410ac498918e45c7d98e07" -dependencies = [ - "lazy_static", - "regex", -] - -[[package]] -name = "near-sdk" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7383e242d3e07bf0951e8589d6eebd7f18bb1c1fc5fbec3fad796041a6aebd1" -dependencies = [ - "base64", - "borsh", - "bs58", - "near-primitives-core", - "near-sdk-macros", - "near-vm-logic", - "serde", - "serde_json", - "wee_alloc", -] - -[[package]] -name = "near-sdk-core" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284a78d9eb8eda58330462fa0023a6d7014c941df1f0387095e7dfd1dc0f2bce" -dependencies = [ - "Inflector", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "near-sdk-macros" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2037337438f97d1ce5f7c896cf229dc56dacd5c01142d1ef95a7d778cde6ce7d" -dependencies = [ - "near-sdk-core", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "near-vm-errors" -version = "4.0.0-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e281d8730ed8cb0e3e69fb689acee6b93cdb43824cd69a8ffd7e1bfcbd1177d7" -dependencies = [ - "borsh", - "hex", - "near-rpc-error-macro", - "serde", -] - -[[package]] -name = "near-vm-logic" -version = "4.0.0-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e11cb28a2d07f37680efdaf860f4c9802828c44fc50c08009e7884de75d982c5" -dependencies = [ - "base64", - "borsh", - "bs58", - "byteorder", - "near-primitives-core", - "near-runtime-utils", - "near-vm-errors", - "serde", - "sha2", - "sha3", -] - -[[package]] -name = "non-fungible-token" -version = "1.1.0" -dependencies = [ - "near-contract-standards", - "near-sdk", -] - -[[package]] -name = "num-bigint" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", - "serde", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - -[[package]] -name = "proc-macro2" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" - -[[package]] -name = "semver" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" - -[[package]] -name = "serde" -version = "1.0.118" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.118" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" -dependencies = [ - "indexmap", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer", - "cfg-if 1.0.0", - "cpufeatures", - "digest", - "opaque-debug", -] - -[[package]] -name = "sha3" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" -dependencies = [ - "block-buffer", - "digest", - "keccak", - "opaque-debug", -] - -[[package]] -name = "syn" -version = "1.0.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4211ce9909eb971f111059df92c45640aad50a619cf55cd76476be803c4c68e6" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "toml" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" -dependencies = [ - "serde", -] - -[[package]] -name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "unicode-ident" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" - -[[package]] -name = "unicode-xid" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/nft/Cargo.toml b/nft/Cargo.toml index 71a1bfd5..e031027a 100644 --- a/nft/Cargo.toml +++ b/nft/Cargo.toml @@ -8,5 +8,5 @@ edition = "2018" crate-type = ["cdylib", "rlib"] [dependencies] -near-sdk = "4.0.0" -near-contract-standards = "4.0.0" \ No newline at end of file +near-sdk = "4.1.1" +near-contract-standards = "4.1.1" \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..02ad72fb --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.69" \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh index bdc19026..6e14a8f6 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,13 @@ #!/bin/bash set -e cd "`dirname $0`"/.. -source scripts/flags.sh + +if [ -z "$KEEP_NAMES" ]; then + export RUSTFLAGS='-C link-arg=-s' +else + export RUSTFLAGS='' +fi + +rustup target add wasm32-unknown-unknown cargo build --all --target wasm32-unknown-unknown --release cp target/wasm32-unknown-unknown/release/*.wasm ./res/ \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 00000000..9daf0207 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +./scripts/build.sh + +cd ./test-approval-receiver +cargo build + +cd ../test-token-receiver +cargo build + +cd ../integration-tests/rs +cargo run --example integration-tests + +cd ../ts +npm run test \ No newline at end of file diff --git a/test-approval-receiver/Cargo.toml b/test-approval-receiver/Cargo.toml index 12e80325..541e77ae 100644 --- a/test-approval-receiver/Cargo.toml +++ b/test-approval-receiver/Cargo.toml @@ -8,5 +8,5 @@ edition = "2018" crate-type = ["cdylib", "rlib"] [dependencies] -near-sdk = "4.0.0" -near-contract-standards = "4.0.0" \ No newline at end of file +near-sdk = "4.1.1" +near-contract-standards = "4.1.1" \ No newline at end of file diff --git a/test-token-receiver/Cargo.toml b/test-token-receiver/Cargo.toml index 1af713aa..2bc1db29 100644 --- a/test-token-receiver/Cargo.toml +++ b/test-token-receiver/Cargo.toml @@ -8,5 +8,5 @@ edition = "2018" crate-type = ["cdylib", "rlib"] [dependencies] -near-sdk = "4.0.0" -near-contract-standards = "4.0.0" \ No newline at end of file +near-sdk = "4.1.1" +near-contract-standards = "4.1.1" \ No newline at end of file