-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0793d68
commit 14c0426
Showing
9 changed files
with
219 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
smart_contracts/contracts/test/payment-purse-persist/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "payment-purse-persist" | ||
version = "0.1.0" | ||
authors = ["Ed Hastings <[email protected]>", "Michał Papierski <[email protected]>"] | ||
edition = "2021" | ||
|
||
[[bin]] | ||
name = "payment_purse_persist" | ||
path = "src/main.rs" | ||
bench = false | ||
doctest = false | ||
test = false | ||
|
||
[dependencies] | ||
casper-contract = { path = "../../../contract" } | ||
casper-types = { path = "../../../../types" } |
28 changes: 28 additions & 0 deletions
28
smart_contracts/contracts/test/payment-purse-persist/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
extern crate alloc; | ||
|
||
use casper_contract::contract_api::{runtime, runtime::put_key, system}; | ||
use casper_types::{RuntimeArgs, URef}; | ||
|
||
const GET_PAYMENT_PURSE: &str = "get_payment_purse"; | ||
const THIS_SHOULD_FAIL: &str = "this_should_fail"; | ||
|
||
/// This logic is intended to be used as SESSION PAYMENT LOGIC | ||
/// It gets the payment purse and attempts and attempts to persist it, | ||
/// which should fail. | ||
#[no_mangle] | ||
pub extern "C" fn call() { | ||
// handle payment contract | ||
let handle_payment_contract_hash = system::get_handle_payment(); | ||
|
||
// get payment purse for current execution | ||
let payment_purse: URef = runtime::call_contract( | ||
handle_payment_contract_hash, | ||
GET_PAYMENT_PURSE, | ||
RuntimeArgs::default(), | ||
); | ||
// attempt to persist the payment purse, which should fail | ||
put_key(THIS_SHOULD_FAIL, payment_purse.into()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters