Skip to content

Commit

Permalink
update dependencies and adjust the code
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancwirko committed Jul 31, 2023
1 parent eaff27b commit c8441f7
Show file tree
Hide file tree
Showing 13 changed files with 1,747 additions and 591 deletions.
1,611 changes: 1,351 additions & 260 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "piggybank"
version = "0.5.2"
version = "0.5.3"
authors = ["Julian Ćwirko <[email protected]>"]
edition = "2021"
publish = false
Expand All @@ -9,12 +9,7 @@ publish = false
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "0.39.6"
version = "0.42.0"

[dev-dependencies.multiversx-sc-scenario]
version = "0.39.6"

[dev-dependencies]
num-bigint = "0.4.2"
num-traits = "0.2"
hex = "0.4"
version = "0.42.0"
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ To use testnet switch to `--chain="T"` and --proxy="https://testnet-gateway.mult
**Deploy the contract:**

```
mxpy --verbose contract deploy --chain="D" --project=multiversx-simple-sc --pem="../walletKey.pem" --gas-limit=80000000 --proxy="https://devnet-gateway.multiversx.com" --recall-nonce --send
mxpy --verbose contract deploy --chain="D" --bytecode="./output/piggybank.wasm" --pem="../walletKey.pem" --gas-limit=80000000 --proxy="https://devnet-gateway.multiversx.com" --recall-nonce --send
```

Smart Contract deployment. You will need to do this once.
In the example, the project name is `multiversx-simple-sc`, and the PEM file is located in `../walletKey.pem`.

You can also use [VSCode MultiversX SDK](https://marketplace.visualstudio.com/items?itemName=Elrond.vscode-elrond-ide) and run a snippet called `deploy`.
You can also use snippets. In the terminal run `. interactions/devnet.snippets.sh && deploy`.

**Create the Piggy:**
(here, with the working SC address example, change it, if you deployed yours, you should have one)
Expand All @@ -58,7 +58,7 @@ mxpy --verbose contract call erd1qqqqqqqqqqqqqpgq59rkyerlfv70635d5ym7s8tmx37e6q5

As an argument for the `createPiggy` function, we will pass the timestamp for the lock time (it should be in the future, of course, use https://www.epochconverter.com/).

You can also use [VSCode MultiversX SDK](https://marketplace.visualstudio.com/items?itemName=Elrond.vscode-elrond-ide) and run a snippet called `createPiggy`.
You can also use snippets. In the terminal run `. interactions/devnet.snippets.sh && createPiggy`.

**Add amount:**
(here, with the working SC address example, change it, if you deployed yours, you should have one)
Expand All @@ -69,7 +69,7 @@ mxpy --verbose contract call erd1qqqqqqqqqqqqqpgq59rkyerlfv70635d5ym7s8tmx37e6q5

We are adding one xEGLD (denomination 18, this is why it is, in fact, 1000000000000000000).

You can also use [VSCode MultiversX SDK](https://marketplace.visualstudio.com/items?itemName=Elrond.vscode-elrond-ide) and run a snippet called `addAmount`.
You can also use snippets. In the terminal run `. interactions/devnet.snippets.sh && addAmount`.

**Payout:**
(here, with the working SC address example, change it, if you deployed yours, you should have one)
Expand All @@ -80,16 +80,16 @@ mxpy --verbose contract call erd1qqqqqqqqqqqqqpgq59rkyerlfv70635d5ym7s8tmx37e6q5

It will check if you can withdraw. It will compare lock time and the current block timestamp.

You can also use [VSCode MultiversX SDK](https://marketplace.visualstudio.com/items?itemName=Elrond.vscode-elrond-ide) and run a snippet called `payOut`.
You can also use snippets. In the terminal run `. interactions/devnet.snippets.sh && payOut`.

**Upgrade the contract:**
(here, with the working SC address example, change it, if you deployed yours, you should have one)

```
mxpy --verbose contract upgrade erd1qqqqqqqqqqqqqpgq59rkyerlfv70635d5ym7s8tmx37e6q5avafsxcqpta --chain="D" --project=multiversx-simple-sc --pem="../walletKey.pem" --gas-limit=20000000 --proxy="https://devnet-gateway.multiversx.com" --recall-nonce --send
mxpy --verbose contract upgrade erd1qqqqqqqqqqqqqpgq59rkyerlfv70635d5ym7s8tmx37e6q5avafsxcqpta --chain="D" --bytecode="./output/piggybank.wasm" --pem="../walletKey.pem" --gas-limit=20000000 --proxy="https://devnet-gateway.multiversx.com" --recall-nonce --send
```

You can also use [VSCode MultiversX SDK](https://marketplace.visualstudio.com/items?itemName=Elrond.vscode-elrond-ide) and run a snippet called `upgrade`.
You can also use snippets. In the terminal run `. interactions/devnet.snippets.sh && upgrade`.

### Snippets

Expand Down
5 changes: 3 additions & 2 deletions interactions/devnet.snippets.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
USER_PEM="../walletKey.pem"
PROXY="https://devnet-gateway.multiversx.com"
CHAIN_ID="D"
BYTECODE_PATH="./output/piggybank.wasm"

SC_ADDRESS=$(mxpy data load --key=address-devnet)

Expand All @@ -9,7 +10,7 @@ SC_ADDRESS=$(mxpy data load --key=address-devnet)
# AMOUNT_TO_LOCK=1000000000000000000

deploy() {
mxpy --verbose contract deploy --chain=${CHAIN_ID} --project=${PROJECT} --pem=${USER_PEM} --gas-limit=20000000 --proxy=${PROXY} --recall-nonce --outfile="deploy-devnet.interaction.json" --send
mxpy --verbose contract deploy --chain=${CHAIN_ID} --bytecode=${BYTECODE_PATH} --pem=${USER_PEM} --gas-limit=20000000 --proxy=${PROXY} --recall-nonce --outfile="deploy-devnet.interaction.json" --send

SC_ADDRESS=$(mxpy data parse --file="deploy-devnet.interaction.json" --expression="data['contractAddress']")
mxpy data store --key=address-devnet --value=${SC_ADDRESS}
Expand All @@ -33,5 +34,5 @@ payOut() {
}

upgrade() {
mxpy --verbose contract upgrade ${SC_ADDRESS} --project=${PROJECT} --chain=${CHAIN_ID} --pem=${USER_PEM} --gas-limit=2000000 --proxy=${PROXY} --recall-nonce --send
mxpy --verbose contract upgrade ${SC_ADDRESS} --bytecode=${BYTECODE_PATH} --chain=${CHAIN_ID} --pem=${USER_PEM} --gas-limit=2000000 --proxy=${PROXY} --recall-nonce --send
}
Loading

0 comments on commit c8441f7

Please sign in to comment.