-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wasm for upgrade write-bytes contract
- Loading branch information
Showing
22 changed files
with
59 additions
and
17 deletions.
There are no files selected for viewing
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
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
Binary file modified
BIN
+0 Bytes
(100%)
soroban-test-wasms/wasm-workspace/opt/auth_test_contract.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-856 Bytes
(78%)
soroban-test-wasms/wasm-workspace/opt/example_contract_data.wasm
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
soroban-test-wasms/wasm-workspace/opt/example_create_contract.wasm
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
soroban-test-wasms/wasm-workspace/opt/example_fannkuch.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
soroban-test-wasms/wasm-workspace/opt/example_invoke_contract.wasm
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
soroban-test-wasms/wasm-workspace/opt/example_linear_memory.wasm
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
soroban-test-wasms/wasm-workspace/opt/example_simple_account.wasm
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
soroban-test-wasms/wasm-workspace/opt/example_updateable_contract.wasm
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+641 Bytes
soroban-test-wasms/wasm-workspace/opt/soroban_write_upgrade_bytes_contract.wasm
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
soroban-test-wasms/wasm-workspace/opt/test_delegated_account.wasm
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
soroban-test-wasms/wasm-workspace/write_upgrade_bytes/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,15 @@ | ||
[package] | ||
name = "soroban-write-upgrade-bytes-contract" | ||
version = "0.0.0" | ||
authors = ["Stellar Development Foundation <[email protected]>"] | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
publish = false | ||
rust-version = "1.65" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
doctest = false | ||
|
||
[dependencies] | ||
soroban-sdk = { workspace = true } |
28 changes: 28 additions & 0 deletions
28
soroban-test-wasms/wasm-workspace/write_upgrade_bytes/src/lib.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] | ||
use soroban_sdk::{contract, contractimpl, Env, Bytes, BytesN}; | ||
|
||
pub(crate) const BUMP_AMOUNT: u32 = 518400; // 30 days | ||
|
||
#[contract] | ||
pub struct WriteBytesContract; | ||
|
||
/* | ||
This contract is used by a stellar core test case to do a Soroban ConfigSetting upgrade. | ||
A copy of this contract also exists in the scripts directory of stellar-core, which is used | ||
by a python script to execute the upgrade. If there's an easy way for the python script to use | ||
this contract in env, the one in stellar-core should be deleted. | ||
*/ | ||
#[contractimpl] | ||
impl WriteBytesContract { | ||
pub fn write(env: Env, xdr_bytes: Bytes) -> BytesN<32> { | ||
let hash = env.crypto().sha256(&xdr_bytes); | ||
env.storage().temporary().set(&hash, &xdr_bytes); | ||
env.storage().temporary().bump(&hash, BUMP_AMOUNT); | ||
|
||
env.storage().instance().bump(BUMP_AMOUNT); | ||
|
||
hash | ||
} | ||
} | ||
|
||
mod test; |