diff --git a/docs/3.tutorials/examples/advanced-xcc.md b/docs/3.tutorials/examples/advanced-xcc.md index 54169353f56..a04d44d49e0 100644 --- a/docs/3.tutorials/examples/advanced-xcc.md +++ b/docs/3.tutorials/examples/advanced-xcc.md @@ -43,14 +43,11 @@ The smart contract is available in two flavors: Rust and JavaScript ```bash ┌── sandbox-ts # sandbox testing -│ ├── src -│ │ ├── external-contracts -│ │ │ ├── counter.wasm -│ │ │ ├── guest-book.wasm -│ │ │ └── hello-near.wasm -│ │ └── main.ava.ts -│ ├── ava.config.cjs -│ └── package.json +│ ├── external-contracts +│ │ ├── counter.wasm +│ │ ├── guest-book.wasm +│ │ └── hello-near.wasm +│ └── main.ava.ts ├── src # contract's code │ ├── internal │ │ ├── batch_actions.ts @@ -69,25 +66,20 @@ The smart contract is available in two flavors: Rust and JavaScript ```bash -┌── sandbox-ts # sandbox testing -│ ├── src -│ │ ├── external-contracts -│ │ │ ├── counter.wasm -│ │ │ ├── guest-book.wasm -│ │ │ └── hello-near.wasm -│ │ └── main.ava.ts -│ ├── ava.config.cjs -│ └── package.json +┌── tests # sandbox testing +│ ├── external-contracts +│ │ ├── counter.wasm +│ │ ├── guest-book.wasm +│ │ └── hello-near.wasm +│ └── main.ava.ts ├── src # contract's code │ ├── batch_actions.rs │ ├── lib.rs │ ├── multiple_contracts.rs │ └── similar_contracts.rs -├── build.sh # build script ├── Cargo.toml # package manager ├── README.md -├── rust-toolchain.toml -└── test.sh # test script +└── rust-toolchain.toml ``` @@ -105,8 +97,8 @@ Methods called this way are executed sequentially, with the added benefit that, they **all get reverted**. - - + - + + url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-advanced-ts/src/internal/multiple_contracts.ts" + start="6" end="21" /> + start="52" end="55" /> @@ -187,7 +179,7 @@ value returned by each call, or an error message. + start="58" end="92" /> @@ -203,16 +195,16 @@ In this case, we call multiple contracts that will return the same type: + url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-advanced-ts/src/contract.ts" + start="57" end="60" /> + url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-advanced-ts/src/internal/similar_contracts.ts" + start="6" end="35" /> + start="7" end="30" /> @@ -225,9 +217,9 @@ results. + start="62" end="65" /> + start="32" end="57" /> @@ -260,7 +252,7 @@ yarn test ```bash cd contract-advanced-rs - ./test.sh + cargo test ``` @@ -299,9 +291,10 @@ near create-account --useFaucet # Deploy the contract cd contract-advanced-rs -./build.sh -near deploy ./target/wasm32-unknown-unknown/release/cross_contract.wasm --initFunction init --initArgs '{"hello_account":"hello.near-example.testnet","guestbook_account":"guestbook_account.near-example.testnet","counter_account":"counter_account.near-example.testnet"}' +cargo near build +# During deploying pass {"hello_account":"hello.near-example.testnet","guestbook_account":"guestbook_account.near-example.testnet","counter_account":"counter_account.near-example.testnet"} as init arguments +cargo near deploy ``` diff --git a/docs/3.tutorials/examples/xcc.md b/docs/3.tutorials/examples/xcc.md index 1df4016df84..0e3dc3421af 100644 --- a/docs/3.tutorials/examples/xcc.md +++ b/docs/3.tutorials/examples/xcc.md @@ -18,7 +18,7 @@ Check the tutorial on how to perform cross-contract calls [in batches and in par ## Obtaining the Cross Contract Call Example -You have two options to start the Donation Example: +You have two options to start the project: 1. You can use the app through `Github Codespaces`, which will open a web-based interactive environment. 2. Clone the repository locally and use it from your computer. @@ -39,12 +39,9 @@ The smart contract is available in two flavors: Rust and JavaScript ```bash ┌── sandbox-ts # sandbox testing -│ ├── src -│ │ ├── hello-near -│ │ │ └── hello-near.wasm -│ │ └── main.ava.ts -│ ├── ava.config.cjs -│ └── package.json +│ ├── hello-near +│ │ └── hello-near.wasm +│ └── main.ava.ts ├── src # contract's code │ └── contract.ts ├── package.json @@ -56,22 +53,18 @@ The smart contract is available in two flavors: Rust and JavaScript +======= ```bash -┌── sandbox-ts # sandbox testing -│ ├── src -│ │ ├── hello-near -│ │ │ └── hello-near.wasm -│ │ └── main.ava.ts -│ ├── ava.config.cjs -│ └── package.json +┌── tests # sandbox testing +│ ├── hello-near +│ │ └── hello-near.wasm +│ └── tests.rs ├── src # contract's code │ ├── external.rs │ └── lib.rs -├── build.sh # build script ├── Cargo.toml # package manager ├── README.md -├── rust-toolchain.toml -└── test.sh # test script +└── rust-toolchain.toml ``` @@ -82,6 +75,7 @@ The smart contract is available in two flavors: Rust and JavaScript ## Smart Contract +### Contract The contract exposes methods to query the greeting and change it. These methods do nothing but calling `get_greeting` and `set_greeting` in the `hello-near` example. @@ -118,7 +112,7 @@ yarn test ```bash cd contract-simple-rs - ./test.sh + cargo test ``` @@ -129,6 +123,24 @@ yarn test The `integration tests` use a sandbox to create NEAR users and simulate interactions with the contract. ::: +In this project in particular, the integration tests first deploy the `hello-near` contract. Then, +they test that the cross-contract call correctly sets and retrieves the message. You will find the integration tests +in `sandbox-ts/` for the JavaScript version and in `tests/` for the Rust version. + + + + + + + + + + +
### Deploying the Contract to the NEAR network @@ -157,11 +169,12 @@ near create-account --useFaucet # Deploy the contract cd contract-simple-rs -./build.sh -near deploy ./target/wasm32-unknown-unknown/release/cross_contract.wasm --initFunction init --initArgs '{"hello_account":"hello.near-example.testnet"}' -``` +cargo near build +# During deploying pass {"hello_account":"hello.near-example.testnet"} as init arguments +cargo near deploy +```