Skip to content

Commit

Permalink
Merge pull request #21 from multiversx/upgrade-framework
Browse files Browse the repository at this point in the history
upgrade framework
  • Loading branch information
BiancaIalangi authored Dec 13, 2024
2 parents 204acc2 + 4f1fa75 commit c6c1068
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 39 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ca051fc3d0c03ec1ce5624cf81bdada57b5fc3e2
mx-scenario-go-version: v3.0.0
enable-contracts-size-report: false
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[workspace]
members = [
"ping-pong",
"ping-pong/meta"
]
resolver = "2"
members = ["ping-pong", "ping-pong/meta"]
1 change: 0 additions & 1 deletion elrond.workspace.json

This file was deleted.

4 changes: 2 additions & 2 deletions ping-pong/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion ping-pong/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ version = "0.0.0"
authors = ["Bruda Claudiu-Marcel <[email protected]>"]
edition = "2021"
publish = false

[dependencies.ping-pong]
path = ".."

[dependencies.multiversx-sc-meta-lib]
version = "0.52.3"
version = "0.54.6"
20 changes: 0 additions & 20 deletions ping-pong/mxpy.json

This file was deleted.

4 changes: 2 additions & 2 deletions ping-pong/scenarios/ping-pong-call-ping-second-user.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
]
}
}
4 changes: 2 additions & 2 deletions ping-pong/scenarios/ping-pong-call-ping.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
]
}
}
2 changes: 1 addition & 1 deletion ping-pong/scenarios/ping-pong-call-pong.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ping-pong/scenarios/ping-pong-init.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions ping-pong/src/ping_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion ping-pong/tests/ping_pong_egld_scenario_rs_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion ping-pong/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ panic = "abort"
path = ".."

[dependencies.multiversx-sc-wasm-adapter]
version = "0.52.3"
version = "0.54.6"

[workspace]
members = ["."]
4 changes: 3 additions & 1 deletion ping-pong/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -18,6 +19,7 @@ multiversx_sc_wasm_adapter::endpoints! {
ping_pong
(
init => init
upgrade => upgrade
ping => ping
pong => pong
didUserPing => did_user_ping
Expand Down

0 comments on commit c6c1068

Please sign in to comment.