From cc07a1ba51531292e7faff5423c9dbf028f76b71 Mon Sep 17 00:00:00 2001 From: gagdiez Date: Fri, 29 Sep 2023 17:26:15 -0300 Subject: [PATCH] fixed formatting --- docs/2.develop/deploy.md | 128 ++++++++---------- docs/2.develop/lock.md | 46 +++---- docs/2.develop/upgrade.md | 88 +++++------- docs/sdk/js/building/prototyping.md | 20 +-- docs/sdk/js/promises/token-tx.md | 25 ++-- docs/sdk/rust/building/prototyping.md | 20 +-- .../serialization-interface.md | 9 +- docs/sdk/rust/promises/token-tx.md | 36 ++--- 8 files changed, 159 insertions(+), 213 deletions(-) diff --git a/docs/2.develop/deploy.md b/docs/2.develop/deploy.md index ec4cb2d1f0d..cec45da93d1 100644 --- a/docs/2.develop/deploy.md +++ b/docs/2.develop/deploy.md @@ -29,56 +29,53 @@ Thanks to the `NEAR CLI` deploying a contract is as simple as: - + -```bash -# Automatically deploy the wasm in a new account -near dev-deploy + ```bash + # Automatically deploy the wasm in a new account + near dev-deploy -# Get the account name -cat ./neardev/dev-account -``` + # Get the account name + cat ./neardev/dev-account + ``` - + -```bash -# Automatically deploy the wasm in a new account -near account create-account sponsor-by-faucet-service .testnet autogenerate-new-keypair save-to-keychain network-config testnet create + ```bash + # Automatically deploy the wasm in a new account + near account create-account sponsor-by-faucet-service .testnet autogenerate-new-keypair save-to-keychain network-config testnet create - -near contract deploy .testnet use-file without-init-call network-config testnet sign-with-keychain -``` + near contract deploy .testnet use-file without-init-call network-config testnet sign-with-keychain + ``` - #### Deploy in an Existing Account - + -```bash -# login into your account -near login + ```bash + # login into your account + near login -# deploy the contract -near deploy -``` + # deploy the contract + near deploy + ``` - - -```bash -# login into your account -near account import-account using-web-wallet network-config testnet + -# deploy the contract -near contract deploy use-file without-init-call network-config testnet sign-with-keychain send + ```bash + # login into your account + near account import-account using-web-wallet network-config testnet -``` + # deploy the contract + near contract deploy use-file without-init-call network-config testnet sign-with-keychain send + ``` @@ -104,30 +101,25 @@ Considering this, we advise to name methods using `snake_case` in all SDKs as th If your contract has an [initialization method](./contracts/anatomy.md#initialization-functions) you can call it to initialize the state. This is not necessary if your contract implements `default` values for the state. - - - + -```bash -# Call the initialization method (`init` in our examples) -near call [] --accountId -``` - - + ```bash + # Call the initialization method (`init` in our examples) + near call [] --accountId + ``` + + -```bash -# Call the initialization method (`init` in our examples) -near contract call-function as-transaction json-args [] prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send -``` + ```bash + # Call the initialization method (`init` in our examples) + near contract call-function as-transaction json-args [] prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send + ``` - + - - - :::info You can initialize your contract [during deployment](#deploying-the-contract) using the `--initFunction` & `--initArgs` arguments. ::: @@ -142,22 +134,19 @@ Once your contract is deployed you can interact with it right away using [NEAR C ### View methods View methods are those that perform **read-only** operations. Calling these methods is free, and do not require to specify which account is being used to make the call: - - - - + -```bash -near view -``` - + ```bash + near view + ``` - + + -```bash -near contract call-function as-read-only text-args '' network-config testnet now -``` + ```bash + near contract call-function as-read-only text-args '' network-config testnet now + ``` @@ -171,22 +160,19 @@ View methods have by default 200 TGAS for execution Change methods are those that perform both read and write operations. For these methods we do need to specify the account being used to make the call, since that account will expend GAS in the call. - - + -```bash -near call --accountId [--deposit ] [--gas ] -``` + ```bash + near call --accountId [--deposit ] [--gas ] + ``` + - - -```bash - -near contract call-function as-transaction json-args prepaid-gas attached-deposit sign-as network-config testnet sign-with-keychain send -``` + ```bash + near contract call-function as-transaction json-args prepaid-gas attached-deposit sign-as network-config testnet sign-with-keychain send + ``` - + \ No newline at end of file diff --git a/docs/2.develop/lock.md b/docs/2.develop/lock.md index a08bb12a06a..e1e2e730859 100644 --- a/docs/2.develop/lock.md +++ b/docs/2.develop/lock.md @@ -12,43 +12,37 @@ When an account is locked nobody can perform transactions in the account's name #### How to Lock an Account - + -```bash -near keys -# result: [access_key: {"nonce": ..., "public_key": ''}] + ```bash + near keys + # result: [access_key: {"nonce": ..., "public_key": ''}] -near delete-key '' -``` - - + near delete-key '' + ``` + + -```bash -near account list-keys network-config testnet now -# result: + ```bash + near account list-keys network-config testnet now + # result: -+---+------------+-------+-------------+ -| # | Public Key | Nonce | Permissions | -+---+------------+-------+-------------+ - .. '' ... ... -+---+------------+-------+-------------+ + +---+------------+-------+-------------+ + | # | Public Key | Nonce | Permissions | + +---+------------+-------+-------------+ + .. '' ... ... + +---+------------+-------+-------------+ -near account delete-key '' network-config testnet sign-with-keychain send + near account delete-key '' network-config testnet sign-with-keychain send + ``` -``` - - - - + - - - #### Why Locking an Account Locking an account brings more reassurance to end-users, since they know no external actor will be able to manipulate the account's contract or balance. :::tip Upgrading Locked Contracts Please do note that, while no external actor can update the contract, the contract **can still upgrade itself**. See [this article](upgrade.md#programmatic-update) for details. -::: +::: \ No newline at end of file diff --git a/docs/2.develop/upgrade.md b/docs/2.develop/upgrade.md index b17a37480d2..ef7dcc51a84 100644 --- a/docs/2.develop/upgrade.md +++ b/docs/2.develop/upgrade.md @@ -20,40 +20,30 @@ Contract's can be updated in two ways: ## Updating Through Tools Simply re-deploy another contract using your preferred tool, for example, using [NEAR CLI](../4.tools/cli.md): - - - -```bash -# If you already used dev-deploy the same account will be used -near dev-deploy --wasmFile - -# If you logged in -near deploy --wasmFile -``` - - - - - - - -```bash -# If you already used dev-deploy the same account will be used -near contract deploy .testnet use-file without-init-call network-config testnet sign-with-keychain + + ```bash + # If you already used dev-deploy the same account will be used + near dev-deploy --wasmFile -# If you logged in -near contract deploy use-file without-init-call network-config testnet sign-with-keychain send + # If you logged in + near deploy --wasmFile + ``` -``` + + + ```bash + # If you already used dev-deploy the same account will be used + near contract deploy .testnet use-file without-init-call network-config testnet sign-with-keychain - + # If you logged in + near contract deploy use-file without-init-call network-config testnet sign-with-keychain send + ``` + - - --- ## Programmatic Update @@ -71,40 +61,37 @@ A smart contract can also update itself by implementing a method that: #### How to Invoke Such Method? - + -```bash -# Load the contract's raw bytes -CONTRACT_BYTES=`cat ./path/to/wasm.wasm | base64` + ```bash + # Load the contract's raw bytes + CONTRACT_BYTES=`cat ./path/to/wasm.wasm | base64` -# Call the update_contract method -near call update_contract "$CONTRACT_BYTES" --base64 --accountId --gas 300000000000000 -``` + # Call the update_contract method + near call update_contract "$CONTRACT_BYTES" --base64 --accountId --gas 300000000000000 + ``` + - + ```bash + # Load the contract's raw bytes + CONTRACT_BYTES=`cat ./path/to/wasm.wasm | base64` -```bash -# Load the contract's raw bytes -CONTRACT_BYTES=`cat ./path/to/wasm.wasm | base64` - -# Call the update_contract method -near contract call-function as-transaction update_contract base64-args "$CONTRACT_BYTES" prepaid-gas '300 TeraGas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send - -``` + # Call the update_contract method + near contract call-function as-transaction update_contract base64-args "$CONTRACT_BYTES" prepaid-gas '300 TeraGas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send + ``` - + -```js -// Load the contract's raw bytes -const code = fs.readFileSync("./path/to/wasm.wasm"); - -// Call the update_contract method -await wallet.callMethod({contractId: guestBook, method: "update_contract", args: code, gas: "300000000000000"}); -``` + ```js + // Load the contract's raw bytes + const code = fs.readFileSync("./path/to/wasm.wasm"); + // Call the update_contract method + await wallet.callMethod({contractId: guestBook, method: "update_contract", args: code, gas: "300000000000000"}); + ``` @@ -138,7 +125,6 @@ If you have no option but to migrate the state, then you need to implement a met This is how DAOs [update themselves](https://github.com/near-daos/sputnik-dao-contract/blob/main/sputnikdao2/src/upgrade.rs#L59) ::: -
### Example: Guest Book Migration diff --git a/docs/sdk/js/building/prototyping.md b/docs/sdk/js/building/prototyping.md index 140e7aa3525..c758e8a7bf4 100644 --- a/docs/sdk/js/building/prototyping.md +++ b/docs/sdk/js/building/prototyping.md @@ -36,14 +36,14 @@ For both cases, let's consider the following example. Let's say you deploy [a JS status message contract](https://github.com/near/near-sdk-js/blob/263c9695ab7bb853ced12886c4b3f8663070d900/examples/src/status-message-collections.js#L10-L42) contract to testnet, then call it with: - + ```bash near call [contract] set_status '{"message": "lol"}' --accountId you.testnet near view [contract] get_status '{"account_id": "you.testnet"}' ``` - + ```bash near contract call-function as-transaction [contract] set_status json-args '{"message": "lol"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as you.testnet network-config testnet sign-with-keychain send @@ -76,13 +76,13 @@ When first getting started with a new project, the fastest way to deploy a contr - + ```bash near dev-deploy [--wasmFile ./path/to/compiled.wasm] ``` - + ```bash near account create-account sponsor-by-faucet-service .testnet autogenerate-new-keypair save-to-keychain network-config testnet create @@ -120,13 +120,13 @@ The easiest way is just to delete the `neardev` folder, then run `near dev-deplo If you want to have a predictable account name rather than an ever-changing `dev-*` account, the best way is probably to create a sub-account: - + ```bash title="Create sub-account" near create-account app-name.you.testnet --masterAccount you.testnet ``` - + ```bash title="Create sub-account" near account create-account fund-myself app-name.you.testnet '100 NEAR' autogenerate-new-keypair save-to-keychain sign-as you.testnet network-config testnet sign-with-keychain send @@ -141,13 +141,13 @@ near account create-account fund-myself app-name.you.testnet '100 NEAR' autogene Then deploy your contract to it: - + ```bash title="Deploy to sub-account" near deploy --accountId app-name.you.testnet [--wasmFile ./path/to/compiled.wasm] ``` - + ```bash title="Deploy to sub-account" near contract deploy app-name.you.testnet use-file <./path/to/compiled.wasm> without-init-call network-config testnet sign-with-keychain send @@ -161,13 +161,13 @@ near contract deploy app-name.you.testnet use-file <./path/to/compiled.wasm> wit In this case, how do you delete all contract state and start again? Delete the sub-account and recreate it. - + ```bash title="Delete sub-account" near delete app-name.you.testnet you.testnet ``` - + ```bash title="Delete sub-account" near account delete-account app-name.you.testnet beneficiary you.testnet network-config testnet sign-with-keychain send diff --git a/docs/sdk/js/promises/token-tx.md b/docs/sdk/js/promises/token-tx.md index c87b09eb735..0e971a250e2 100644 --- a/docs/sdk/js/promises/token-tx.md +++ b/docs/sdk/js/promises/token-tx.md @@ -47,24 +47,19 @@ Most of this is boilerplate you're probably familiar with by now – imports, s Using near-cli or near-cli-rs, someone could invoke this function with a call like: - + + ```bash + near call pay '{"amount": "1000000000000000000000000", "to": "example.near"}' --accountId benjiman.near + ``` -```bash -near call pay '{"amount": "1000000000000000000000000", "to": "example.near"}' --accountId benjiman.near -``` - - - - - - -```bash -near contract call-function as-transaction pay json-args '{"amount": "1000000000000000000000000", "to": "example.near"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as benjiman.near network-config testnet sign-with-keychain send -``` - + + + ```bash + near contract call-function as-transaction pay json-args '{"amount": "1000000000000000000000000", "to": "example.near"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as benjiman.near network-config testnet sign-with-keychain send + ``` - + diff --git a/docs/sdk/rust/building/prototyping.md b/docs/sdk/rust/building/prototyping.md index 1cc42422d21..22da91501df 100644 --- a/docs/sdk/rust/building/prototyping.md +++ b/docs/sdk/rust/building/prototyping.md @@ -45,7 +45,7 @@ The [rust-status-message](https://github.com/near-examples/rust-status-message) Let's say you deploy this contract to testnet, then call it with: - + ```bash near call [contract] set_status '{"message": "lol"}' --accountId you.testnet @@ -53,7 +53,7 @@ near view [contract] get_status '{"account_id": "you.testnet"}' ``` - + ```bash near contract call-function as-transaction [contract] set_status json-args '{"message": "lol"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as you.testnet network-config testnet sign-with-keychain send @@ -113,13 +113,13 @@ You build & deploy the contract again, thinking that maybe because the new `tagl When first getting started with a new project, the fastest way to deploy a contract is [`dev-deploy`](/concepts/basics/accounts/creating-accounts): - + ```bash near dev-deploy [--wasmFile ./path/to/compiled.wasm] ``` - + ```bash near account create-account sponsor-by-faucet-service .testnet autogenerate-new-keypair save-to-keychain network-config testnet create @@ -151,13 +151,13 @@ The easiest way is just to delete the `neardev` folder, then run `near dev-deplo If you want to have a predictable account name rather than an ever-changing `dev-*` account, the best way is probably to create a sub-account: - + ```bash title="Create sub-account" near create-account app-name.you.testnet --masterAccount you.testnet ``` - + ```bash title="Create sub-account" near account create-account fund-myself app-name.you.testnet '100 NEAR' autogenerate-new-keypair save-to-keychain sign-as you.testnet network-config testnet sign-with-keychain send @@ -169,13 +169,13 @@ near account create-account fund-myself app-name.you.testnet '100 NEAR' autogene Then deploy your contract to it: - + ```bash title="Deploy to sub-account" near deploy --accountId app-name.you.testnet [--wasmFile ./path/to/compiled.wasm] ``` - + ```bash title="Deploy to sub-account" near contract deploy app-name.you.testnet use-file <./path/to/compiled.wasm> without-init-call network-config testnet sign-with-keychain send @@ -189,13 +189,13 @@ In this case, how do you delete all contract state and start again? Delete the s - + ```bash title="Delete sub-account" near delete app-name.you.testnet you.testnet ``` - + ```bash title="Delete sub-account" near account delete-account app-name.you.testnet beneficiary you.testnet network-config testnet sign-with-keychain send diff --git a/docs/sdk/rust/contract-interface/serialization-interface.md b/docs/sdk/rust/contract-interface/serialization-interface.md index 97e7f49c9e5..d941f9a4971 100644 --- a/docs/sdk/rust/contract-interface/serialization-interface.md +++ b/docs/sdk/rust/contract-interface/serialization-interface.md @@ -60,22 +60,17 @@ https://github.com/mikedotexe/rust-status-message/blob/b83c5126fdbe0f19bc904e547 To call this with NEAR CLI, use a command similar to this: - + ```bash near call rust-status-message.demo.testnet set_status_borsh --base64 'DAAAAEFsb2hhIGhvbnVhIQ==' --accountId demo.testnet ``` - - - - - + ```bash near contract call-function as-transaction rust-status-message.demo.testnet set_status_borsh base64-args 'DAAAAEFsb2hhIGhvbnVhIQ==' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as demo.testnet network-config testnet sign-with-keychain send ``` - diff --git a/docs/sdk/rust/promises/token-tx.md b/docs/sdk/rust/promises/token-tx.md index 4f3f74b463e..f452ddd6d88 100644 --- a/docs/sdk/rust/promises/token-tx.md +++ b/docs/sdk/rust/promises/token-tx.md @@ -53,26 +53,16 @@ Most of this is boilerplate you're probably familiar with by now – imports, s Using near-cli or near-cli-rs, someone could invoke this function with a call like: - - - -```bash -near call pay '{"amount": "1000000000000000000000000", "to": "example.near"}' --accountId benjiman.near -``` - - - - - - -```bash -near contract call-function as-transaction pay json-args '{"amount": "1000000000000000000000000", "to": "example.near"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as benjiman.near network-config testnet sign-with-keychain send -``` - - - - - - - - + + + ```bash + near call pay '{"amount": "1000000000000000000000000", "to": "example.near"}' --accountId benjiman.near + ``` + + + + ```bash + near contract call-function as-transaction pay json-args '{"amount": "1000000000000000000000000", "to": "example.near"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as benjiman.near network-config testnet sign-with-keychain send + ``` + + \ No newline at end of file