Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Development in Main #696

Merged
merged 8 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/developers/developer-reference/code-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ For example, if we wish to deploy a contract that is payable and upgradeable our

We hope these flags will make it a lot easier to create and upgrade smart contracts.

If you want to take a look at some more examples of how Code Metadata is used, take a look here: https://github.com/multiversx/mx-sdk-rs/tree/master/contracts/examples
If you want to take a look at some more examples of how Code Metadata is used, take a look [here](https://github.com/multiversx/mx-sdk-rs/tree/master/contracts/examples).
4 changes: 2 additions & 2 deletions docs/developers/developer-reference/sc-build-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn world() -> ScenarioWorld {

### Calling `build`

A build can be triggered by calling either `mxpy contract build <project>` or `cargo run build` in the meta crate. In fact, mxpy calls the meta crate itself.
A build can be triggered by calling either `mxpy contract build --path <project>` or `cargo run build` in the meta crate. In fact, mxpy calls the meta crate itself.

By default, this command will produce three files for each output contract: the ABI (`<contract>.abi.json`), the contract (`<contract>.wasm`) and a json file with all the used VM EI imported functions (`<contract>.imports.json`). For the multisig example above, the produced files are as follows:

Expand Down Expand Up @@ -271,7 +271,7 @@ This command is similar to `build-dbg`, in that it provides a shorthand for buil

### Calling `clean`

Calling `mxpy contract clean <project>` or `cargo run clean` in the meta crate will delete the `output` folder and clean outputs of the Rust crates.
Calling `mxpy contract clean --path <project>` or `cargo run clean` in the meta crate will delete the `output` folder and clean outputs of the Rust crates.

[comment]: # (mx-context-auto)

Expand Down
4 changes: 2 additions & 2 deletions docs/developers/tutorials/counter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This is a mere example. We **do not offer support for writing contracts in C**.

## **Prerequisites**

You need to have [mxpy](/sdk-and-tools/sdk-py/installing-mxpy) installed.
You need to have `mxpy` installed. Follow the installation guide [here](/sdk-and-tools/sdk-py/installing-mxpy).

[comment]: # (mx-context-auto)

Expand All @@ -34,7 +34,7 @@ The file `counter.c` is the implementation of the Smart Contract, which defines
In order to build the contract to WASM, run the following command:

```
mxpy --verbose contract build mycounter
mxpy --verbose contract build --path mycounter
```

Above, `mycounter` refers to the folder that holds the source code. After executing the command, you can inspect the generated files in `mycounter/output`.
Expand Down
19 changes: 10 additions & 9 deletions docs/developers/tutorials/staking-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ If you find anything not answered here, feel free to ask further questions on th

## Prerequisites

First and foremost, you need to have mxpy installed: https://docs.multiversx.com/sdk-and-tools/sdk-py/installing-mxpy/. If you already have mxpy installed, make sure to update it to the latest version, using the same instructions as for the installation.
First and foremost, you need to have `mxpy` installed. You can follow the installation guide [here](/sdk-and-tools/sdk-py/installing-mxpy/). If you already have `mxpy` installed, make sure to update it to the latest version, using the same instructions as for the installation.

[comment]: # (mx-context-auto)

### mxpy

We're going to use mxpy for interacting with our contracts, so if you need more details about some of the steps we will perform, you can check here for more detailed explanations regarding what each command does: https://docs.multiversx.com/sdk-and-tools/sdk-py/smart-contract-interactions/
We're going to use mxpy for interacting with our contracts, so if you need more details about some of the steps we will perform, you can check [here](/sdk-and-tools/sdk-py/smart-contract-interactions/) for more detailed explanations regarding what each command does.

[comment]: # (mx-context-auto)

Expand Down Expand Up @@ -161,7 +161,7 @@ pub trait StakingContract {

`require!` is a macro that is a shortcut for `if !condition { signal_error(msg) }`. Signalling an error will terminate the execution and revert any changes made to the internal state, including token transfers from and to the SC. In this case, there is no reason to continue if the user did not pay anything.

We've also added #[view] annotation for the storage mappers, so we can later perform queries on those storage entries. You can read more about annotations here: https://docs.multiversx.com/developers/developer-reference/sc-annotations/
We've also added `#[view]` annotation for the storage mappers, so we can later perform queries on those storage entries. You can read more about annotations [here](/developers/developer-reference/sc-annotations/).

Also, if you're confused about some of the functions used or the storage mappers, you can read more here:

Expand All @@ -170,7 +170,7 @@ Also, if you're confused about some of the functions used or the storage mappers

Now, I've intentionally written some bad code here. Can you spot the improvements we can make?

Firstly, the last _clone_ is not needed. If you clone variables all the time, then you need to take some time to read the Rust ownership chapter of the Rust book: https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html and also about the implications of cloning types from the Rust framework: https://docs.multiversx.com/developers/best-practices/biguint-operations/
Firstly, the last _clone_ is not needed. If you clone variables all the time, then you need to take some time to read the Rust ownership chapter of the Rust book: https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html and also about the implications of cloning types from the Rust framework: https://docs.multiversx.com/developers/best-practices/biguint-operations/.

Secondly, the `staking_position` does not need an owned value of the `addr` argument. We can take a reference instead.

Expand Down Expand Up @@ -224,7 +224,7 @@ Every smart contract needs to have a function annotated with `#[init]`. This fun
You can skip this section if you already have a devnet wallet setup.
:::

Let's create a devnet wallet. Go to https://devnet-wallet.multiversx.com/, and select "create wallet". Save your 24 words (in the given order!), and create a password for your keystore file.
Let's create a devnet wallet. Access the [Web Wallet](https://devnet-wallet.multiversx.com/), and select "create new wallet". Save your 24 words (in the given order!), and create a password for your keystore file.

Now, we could use the keystore file with a password, but it's more convenient to use a PEM file. To generate the PEM file from your secret phrase, follow these instructions: https://docs.multiversx.com/sdk-and-tools/sdk-py/deriving-the-wallet-pem-file/

Expand Down Expand Up @@ -260,7 +260,7 @@ If you wanted to use testnet, the proxy would be "https://testnet-gateway.multiv
More details can be found [here](/developers/constants/).
:::

The things you need to edit are the CLI parameters --pem and --project with your local paths.
The things you need to edit are the CLI parameters `--pem` and `--bytecode` with your local paths.

[comment]: # (mx-context-auto)

Expand Down Expand Up @@ -438,7 +438,7 @@ getAllStakers

### Converting erd1 addresses to hex

The smart contracts never work with the erd1 address format, but rather with the hex format. This is NOT an ASCII to hex conversion. This is a bech32 to ASCII conversion.
The smart contracts never work with the `erd1...` address format, but rather with the hex format. This is NOT an ASCII to hex conversion. This is a bech32 to ASCII conversion.

But then, why did the previous query work?

Expand Down Expand Up @@ -875,9 +875,10 @@ Then, we've staked the user's entire balance, unstaked half, then unstaked fully
### Running the test

To run a test, you can use click on the `Run Test` button from under the test name.

![img](/developers/staking-contract-tutorial-img/running_rust_test.png)

There is also a `Debug` button, which can be used to debug smart contracts. More details on that here: https://docs.multiversx.com/developers/developer-reference/sc-debugging/
There is also a `Debug` button, which can be used to debug smart contracts. More details on that [here](/developers/developer-reference/sc-debugging/).

Alternatively, you can run all the tests in the file by running the following command in the VSCode terminal, in the `./staking-contract` folder:

Expand Down Expand Up @@ -936,7 +937,7 @@ We've also added `TypeAbi`, since this is required for ABI generation. ABIs are

Additionally, we've added `PartialEq` and `Debug` derives, for easier use within tests. This will not affect performance in any way, as the code for these is only used during testing/debugging. `PartialEq` allows us to use `==` for comparing instances, while `Debug` will pretty-print the struct, field by field, in case of errors.

If you want to learn more about how such a struct is encoded, and the difference between top and nested encoding/decoding, you can read more [here](/developers/developer-reference/serialization-format):
If you want to learn more about how such a struct is encoded, and the difference between top and nested encoding/decoding, you can read more [here](/developers/developer-reference/serialization-format).

[comment]: # (mx-context-auto)

Expand Down
2 changes: 1 addition & 1 deletion docs/developers/tutorials/wallet-connect-v2-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Using `@multiversx/sdk-wallet-connect-provider` >= 3.0.1 or `@elrondnetwork/erdj

Since the WalletConnect 2.0 implementation was complimentary to the existing 1.0 version, there should be no breaking changes to upgrade the library

Check out some detailed examples [here](/sdk-and-tools/sdk-js/sdk-js-signing-providers/#the-wallet-connect-provider)
Check out some detailed examples [here](/sdk-and-tools/sdk-js/sdk-js-signing-providers/#the-wallet-connect-provider).

To Set up the 2.0 functionality you can check out the examples here: [https://github.com/multiversx/mx-sdk-js-examples](https://github.com/multiversx/mx-sdk-js-examples) or a more advanced implementation on sdk-dapp here: [https://github.com/multiversx/mx-sdk-dapp/blob/main/src/hooks/login/useWalletConnectV2Login.ts](https://github.com/multiversx/mx-sdk-dapp/blob/main/src/hooks/login/useWalletConnectV2Login.ts)

Expand Down
2 changes: 1 addition & 1 deletion docs/developers/tutorials/your-first-dapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ sudo apt install libncurses5 build-essential python3-pip nodejs npm python3.8-ve
```

We'll also need `mxpy`, the MultiversX command line tool, which is helpful for signing transactions, deploying smart contracts, managing wallets, accounts and validators. We'll use it to deploy our smart contract.
mxpy can be installed using the MultiversX documentation page [https://docs.multiversx.com/sdk-and-tools/sdk-py/installing-mxpy](https://docs.multiversx.com/sdk-and-tools/sdk-py/installing-mxpy)
mxpy can be installed using the MultiversX [documentation page](/sdk-and-tools/sdk-py/installing-mxpy).

We'll download the `mxpy` installer and we run it

Expand Down
6 changes: 5 additions & 1 deletion docs/sdk-and-tools/rest-api/addresses.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,14 @@ Balance successfully retrieved.

[comment]: # (mx-context-auto)

## <span class="badge badge--primary">GET</span> **Get Address Transactions** {#get-address-transactions}
## <span class="badge badge--primary">GET</span> **Get Address Transactions (deprecated)** {#get-address-transactions}

`https://gateway.multiversx.com/address/:bech32Address/transactions`

:::caution
This endpoint is deprecated. In order to fetch the Transactions involving an Address, use the [transactions](https://api.multiversx.com/#/accounts/AccountController_getAccountTransactions) endpoint of MultiversX API, instead.
:::

This endpoint allows one to retrieve the latest 20 Transactions sent from an Address.

<Tabs
Expand Down
58 changes: 49 additions & 9 deletions docs/sdk-and-tools/sdk-js/sdk-js-cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This page will guide you through the process of handling common tasks using **sd
This cookbook makes use of `sdk-js 12`. In order to migrate from `sdk-js 11.x` to `sdk-js 12`, please follow [the migration guide](/sdk-and-tools/sdk-js/sdk-js-migration-guides).
:::

<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/2a9ddac3f13b2bf6060ad36420054d79c9a62204/cookbook/generated/basic.md" } -->
<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/v0.5.1/cookbook/generated/basic.md" } -->

[comment]: # (mx-context-auto)

Expand Down Expand Up @@ -223,7 +223,7 @@ For a different awaiting strategy, also see [extending sdk-js](https://docs.mult

<!-- END_INCLUDE_FILE -->

<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/2a9ddac3f13b2bf6060ad36420054d79c9a62204/cookbook/generated/transfers.md" } -->
<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/v0.5.1/cookbook/generated/transfers.md" } -->

[comment]: # (mx-context-auto)

Expand Down Expand Up @@ -305,7 +305,7 @@ const tx4 = factory.createMultiESDTNFTTransfer({

<!-- END_INCLUDE_FILE -->

<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/2a9ddac3f13b2bf6060ad36420054d79c9a62204/cookbook/generated/contracts_01_deployments.md" } -->
<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/v0.5.1/cookbook/generated/contracts_01_deployments.md" } -->

[comment]: # (mx-context-auto)

Expand Down Expand Up @@ -415,8 +415,7 @@ console.log("Return code:", returnCode);

<!-- END_INCLUDE_FILE -->

<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/2a9ddac3f13b2bf6060ad36420054d79c9a62204/cookbook/generated/contracts_02_abi.md" } -->

<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/v0.5.1/cookbook/generated/contracts_02_abi.md" } -->
[comment]: # (mx-context-auto)

## ABI
Expand Down Expand Up @@ -450,7 +449,7 @@ existingContract = new SmartContract({ address: existingContractAddress, abi: ab

<!-- END_INCLUDE_FILE -->

<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/2a9ddac3f13b2bf6060ad36420054d79c9a62204/cookbook/generated/contracts_03_queries.md" } -->
<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/v0.5.1/cookbook/generated/contracts_03_queries.md" } -->

[comment]: # (mx-context-auto)

Expand Down Expand Up @@ -566,7 +565,7 @@ let firstValueAsStruct = <Struct>firstValue;

<!-- END_INCLUDE_FILE -->

<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/2a9ddac3f13b2bf6060ad36420054d79c9a62204/cookbook/generated/contracts_04_interactions.md" } -->
<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/v0.5.1/cookbook/generated/contracts_04_interactions.md" } -->

[comment]: # (mx-context-auto)

Expand Down Expand Up @@ -623,7 +622,7 @@ Then, sign, broadcast `tx` and wait for its completion.
```
import { AbiRegistry } from "@multiversx/sdk-core";

const abiRegistry = AbiRegistry.create({
let abiRegistry = AbiRegistry.create({
"endpoints": [
{
"name": "foobar",
Expand Down Expand Up @@ -657,6 +656,47 @@ let tx3 = contract.methods.doSomethingWithValue([1, 2, 3])
.buildTransaction();
```

Now let's see an example using variadic arguments, as well:

```
import { StringValue, VariadicValue } from "@multiversx/sdk-core";

abiRegistry = AbiRegistry.create({
"endpoints": [
{
"name": "foobar",
"inputs": [],
"outputs": []
},
{
"name": "doSomething",
"inputs": [{
"type": "counted-variadic<utf-8 string>"
},
{
"type": "variadic<u64>"
}],
"outputs": []
}
]
});

contract = new SmartContract({ address: contractAddress, abi: abiRegistry });

let tx4 = contract.methods.doSomething(
[
// Counted variadic must be explicitly typed
VariadicValue.fromItemsCounted(StringValue.fromUTF8("foo"), StringValue.fromUTF8("bar")),
// Regular variadic can be implicitly typed
1, 2, 3
])
.withSender(addressOfAlice)
.withNonce(45)
.withGasLimit(20000000)
.withChainID("D")
.buildTransaction();
```

[comment]: # (mx-context-auto)

### Transfer & execute
Expand Down Expand Up @@ -748,7 +788,7 @@ For customizing the default parser, also see [extending sdk-js](/sdk-and-tools/s

<!-- END_INCLUDE_FILE -->

<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/2a9ddac3f13b2bf6060ad36420054d79c9a62204/cookbook/generated/signing.md" } -->
<!-- BEGIN_INCLUDE_FILE { "url": "https://raw.githubusercontent.com/multiversx/mx-sdk-js-examples/v0.5.1/cookbook/generated/signing.md" } -->

[comment]: # (mx-context-auto)

Expand Down
Loading
Loading