From 0c9243fffb3c1c3e955843f1a456ae9242582412 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Tue, 10 Dec 2024 13:15:21 +0200 Subject: [PATCH 1/3] upgrade framework --- Cargo.toml | 6 ++---- elrond.workspace.json | 1 - ping-pong/Cargo.toml | 4 ++-- ping-pong/meta/Cargo.toml | 3 ++- ping-pong/mxpy.json | 20 ------------------- .../ping-pong-call-ping-second-user.scen.json | 4 ++-- .../scenarios/ping-pong-call-ping.scen.json | 4 ++-- .../scenarios/ping-pong-call-pong.scen.json | 2 +- ping-pong/scenarios/ping-pong-init.scen.json | 4 ++-- ping-pong/src/ping_pong.rs | 9 +++++++++ .../tests/ping_pong_egld_scenario_rs_test.rs | 5 ++++- ping-pong/wasm/Cargo.toml | 2 +- ping-pong/wasm/src/lib.rs | 4 +++- 13 files changed, 30 insertions(+), 38 deletions(-) delete mode 100644 elrond.workspace.json delete mode 100644 ping-pong/mxpy.json diff --git a/Cargo.toml b/Cargo.toml index d596a09..81d78ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,3 @@ [workspace] -members = [ - "ping-pong", - "ping-pong/meta" -] +resolver = "2" +members = ["ping-pong", "ping-pong/meta"] diff --git a/elrond.workspace.json b/elrond.workspace.json deleted file mode 100644 index 9e26dfe..0000000 --- a/elrond.workspace.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/ping-pong/Cargo.toml b/ping-pong/Cargo.toml index b2f7724..4b7804e 100644 --- a/ping-pong/Cargo.toml +++ b/ping-pong/Cargo.toml @@ -9,7 +9,7 @@ publish = false path = "src/ping_pong.rs" [dependencies.multiversx-sc] -version = "0.52.3" +version = "0.54.6" [dev-dependencies.multiversx-sc-scenario] -version = "0.52.3" +version = "0.54.6" diff --git a/ping-pong/meta/Cargo.toml b/ping-pong/meta/Cargo.toml index dd9e623..a106cb4 100644 --- a/ping-pong/meta/Cargo.toml +++ b/ping-pong/meta/Cargo.toml @@ -4,8 +4,9 @@ version = "0.0.0" authors = ["Bruda Claudiu-Marcel "] edition = "2021" publish = false + [dependencies.ping-pong] path = ".." [dependencies.multiversx-sc-meta-lib] -version = "0.52.3" +version = "0.54.6" diff --git a/ping-pong/mxpy.json b/ping-pong/mxpy.json deleted file mode 100644 index 88346ce..0000000 --- a/ping-pong/mxpy.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "configurations": { - "default": { - "proxy": "https://devnet-api.multiversx.com", - "chainID": "D" - } - }, - "contract":{ - "deploy":{ - "verbose": true, - "bytecode": "output/ping-pong.wasm", - "recall-nonce": true, - "pem": "../../wallet/wallet-owner.pem", - "gas-limit": 59999999, - "arguments": [1000000000000000000, 600], - "send": true, - "outfile": "deploy-testnet.interaction.json" - } - } -} diff --git a/ping-pong/scenarios/ping-pong-call-ping-second-user.scen.json b/ping-pong/scenarios/ping-pong-call-ping-second-user.scen.json index 2512614..978dfe1 100644 --- a/ping-pong/scenarios/ping-pong-call-ping-second-user.scen.json +++ b/ping-pong/scenarios/ping-pong-call-ping-second-user.scen.json @@ -57,9 +57,9 @@ "str:userPingTimestamp|address:participant1": "781", "str:userPingTimestamp|address:participant2": "781" }, - "code": "file:../output/ping-pong.wasm" + "code": "mxsc:../output/ping-pong.mxsc.json" } } } ] -} +} \ No newline at end of file diff --git a/ping-pong/scenarios/ping-pong-call-ping.scen.json b/ping-pong/scenarios/ping-pong-call-ping.scen.json index 65cf135..45fa8fd 100644 --- a/ping-pong/scenarios/ping-pong-call-ping.scen.json +++ b/ping-pong/scenarios/ping-pong-call-ping.scen.json @@ -56,9 +56,9 @@ "str:acceptedPaymentTokenId": "str:EGLD", "str:userPingTimestamp|address:participant1": "781" }, - "code": "file:../output/ping-pong.wasm" + "code": "mxsc:../output/ping-pong.mxsc.json" } } } ] -} +} \ No newline at end of file diff --git a/ping-pong/scenarios/ping-pong-call-pong.scen.json b/ping-pong/scenarios/ping-pong-call-pong.scen.json index 91b501b..9224e4d 100644 --- a/ping-pong/scenarios/ping-pong-call-pong.scen.json +++ b/ping-pong/scenarios/ping-pong-call-pong.scen.json @@ -56,7 +56,7 @@ "str:durationInSeconds": "123,000", "str:acceptedPaymentTokenId": "str:EGLD" }, - "code": "file:../output/ping-pong.wasm" + "code": "mxsc:../output/ping-pong.mxsc.json" } } } diff --git a/ping-pong/scenarios/ping-pong-init.scen.json b/ping-pong/scenarios/ping-pong-init.scen.json index b6d5fd8..34a4fae 100644 --- a/ping-pong/scenarios/ping-pong-init.scen.json +++ b/ping-pong/scenarios/ping-pong-init.scen.json @@ -34,7 +34,7 @@ "txId": "deploy", "tx": { "from": "address:my_address", - "contractCode": "file:../output/ping-pong.wasm", + "contractCode": "mxsc:../output/ping-pong.mxsc.json", "value": "0", "arguments": [ "500,000,000,000", @@ -75,7 +75,7 @@ "str:durationInSeconds": "123,000", "str:acceptedPaymentTokenId": "str:EGLD" }, - "code": "file:../output/ping-pong.wasm" + "code": "mxsc:../output/ping-pong.mxsc.json" } } } diff --git a/ping-pong/src/ping_pong.rs b/ping-pong/src/ping_pong.rs index 686995f..fedf3ba 100644 --- a/ping-pong/src/ping_pong.rs +++ b/ping-pong/src/ping_pong.rs @@ -38,6 +38,15 @@ pub trait PingPong { self.accepted_payment_token_id().set(&token_id); } + #[upgrade] + fn upgrade(&self, ping_amount: BigUint, duration_in_seconds: u64) { + self.init( + ping_amount, + duration_in_seconds, + OptionalValue::Some(self.accepted_payment_token_id().get()), + ) + } + // endpoints /// User sends some tokens to be locked in the contract for a period of time. diff --git a/ping-pong/tests/ping_pong_egld_scenario_rs_test.rs b/ping-pong/tests/ping_pong_egld_scenario_rs_test.rs index 99b1f2f..e6656d2 100644 --- a/ping-pong/tests/ping_pong_egld_scenario_rs_test.rs +++ b/ping-pong/tests/ping_pong_egld_scenario_rs_test.rs @@ -3,7 +3,10 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); - blockchain.register_contract("file:output/ping-pong.wasm", ping_pong::ContractBuilder); + blockchain.register_contract( + "mxsc:output/ping-pong.mxsc.json", + ping_pong::ContractBuilder, + ); blockchain } diff --git a/ping-pong/wasm/Cargo.toml b/ping-pong/wasm/Cargo.toml index 2aea6fc..3f203e8 100644 --- a/ping-pong/wasm/Cargo.toml +++ b/ping-pong/wasm/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.52.3" +version = "0.54.6" [workspace] members = ["."] diff --git a/ping-pong/wasm/src/lib.rs b/ping-pong/wasm/src/lib.rs index 69a0c04..ca90d6b 100644 --- a/ping-pong/wasm/src/lib.rs +++ b/ping-pong/wasm/src/lib.rs @@ -5,9 +5,10 @@ //////////////////////////////////////////////////// // Init: 1 +// Upgrade: 1 // Endpoints: 9 // Async Callback (empty): 1 -// Total number of exported functions: 11 +// Total number of exported functions: 12 #![no_std] @@ -18,6 +19,7 @@ multiversx_sc_wasm_adapter::endpoints! { ping_pong ( init => init + upgrade => upgrade ping => ping pong => pong didUserPing => did_user_ping From c39322d19cc17d4fdbe56c3d80e92380dd8b8928 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Tue, 10 Dec 2024 13:21:37 +0200 Subject: [PATCH 2/3] update github actions --- .github/workflows/actions.yml | 4 +++- ping-pong/Cargo.toml | 8 ++++++-- ping-pong/meta/Cargo.toml | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 1f01ab9..5abacbf 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -13,9 +13,11 @@ permissions: jobs: contracts: name: Contracts - uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v3.3.1 + uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@72dc7659e6945c8749d01ec28638843bae33437e with: rust-toolchain: stable + sc-meta-hash-git: 51791cb3c23f8084e97c5ef0af82a9d16ab70cb9 + mx-scenario-go-version: v3.0.0 enable-contracts-size-report: false secrets: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/ping-pong/Cargo.toml b/ping-pong/Cargo.toml index 4b7804e..d44e121 100644 --- a/ping-pong/Cargo.toml +++ b/ping-pong/Cargo.toml @@ -9,7 +9,11 @@ publish = false path = "src/ping_pong.rs" [dependencies.multiversx-sc] -version = "0.54.6" +version = "=0.54.6" +git = "https://github.com/multiversx/mx-sdk-rs" +rev = "51791cb3c23f8084e97c5ef0af82a9d16ab70cb9" [dev-dependencies.multiversx-sc-scenario] -version = "0.54.6" +version = "=0.54.6" +git = "https://github.com/multiversx/mx-sdk-rs" +rev = "51791cb3c23f8084e97c5ef0af82a9d16ab70cb9" diff --git a/ping-pong/meta/Cargo.toml b/ping-pong/meta/Cargo.toml index a106cb4..fc4d53a 100644 --- a/ping-pong/meta/Cargo.toml +++ b/ping-pong/meta/Cargo.toml @@ -9,4 +9,6 @@ publish = false path = ".." [dependencies.multiversx-sc-meta-lib] -version = "0.54.6" +version = "=0.54.6" +git = "https://github.com/multiversx/mx-sdk-rs" +rev = "51791cb3c23f8084e97c5ef0af82a9d16ab70cb9" From 4f1fa75eadac1b9e696ec577404e88a1b16e514d Mon Sep 17 00:00:00 2001 From: Bianca Ialangi Date: Fri, 13 Dec 2024 16:28:12 +0200 Subject: [PATCH 3/3] remove git dependency framework version --- .github/workflows/actions.yml | 2 +- ping-pong/Cargo.toml | 8 ++------ ping-pong/meta/Cargo.toml | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 5abacbf..04bb65a 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -16,7 +16,7 @@ jobs: uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@72dc7659e6945c8749d01ec28638843bae33437e with: rust-toolchain: stable - sc-meta-hash-git: 51791cb3c23f8084e97c5ef0af82a9d16ab70cb9 + sc-meta-hash-git: ca051fc3d0c03ec1ce5624cf81bdada57b5fc3e2 mx-scenario-go-version: v3.0.0 enable-contracts-size-report: false secrets: diff --git a/ping-pong/Cargo.toml b/ping-pong/Cargo.toml index d44e121..4b7804e 100644 --- a/ping-pong/Cargo.toml +++ b/ping-pong/Cargo.toml @@ -9,11 +9,7 @@ publish = false path = "src/ping_pong.rs" [dependencies.multiversx-sc] -version = "=0.54.6" -git = "https://github.com/multiversx/mx-sdk-rs" -rev = "51791cb3c23f8084e97c5ef0af82a9d16ab70cb9" +version = "0.54.6" [dev-dependencies.multiversx-sc-scenario] -version = "=0.54.6" -git = "https://github.com/multiversx/mx-sdk-rs" -rev = "51791cb3c23f8084e97c5ef0af82a9d16ab70cb9" +version = "0.54.6" diff --git a/ping-pong/meta/Cargo.toml b/ping-pong/meta/Cargo.toml index fc4d53a..a106cb4 100644 --- a/ping-pong/meta/Cargo.toml +++ b/ping-pong/meta/Cargo.toml @@ -9,6 +9,4 @@ publish = false path = ".." [dependencies.multiversx-sc-meta-lib] -version = "=0.54.6" -git = "https://github.com/multiversx/mx-sdk-rs" -rev = "51791cb3c23f8084e97c5ef0af82a9d16ab70cb9" +version = "0.54.6"