forked from argotorg/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage_packed_array.fe
More file actions
34 lines (31 loc) · 1019 Bytes
/
Copy pathstorage_packed_array.fe
File metadata and controls
34 lines (31 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::abi::sol
use std::evm::StoragePackedArray
pub msg BenchMsg {
#[selector = sol("set(uint256,uint256)")]
Set { idx: u256, value: u256 },
#[selector = sol("setTwoLanes(uint256,uint256,uint256,uint256)")]
SetTwoLanes { idxA: u256, valA: u256, idxB: u256, valB: u256 },
#[selector = sol("get(uint256)")]
Get { idx: u256 } -> u256,
#[selector = sol("setThenGet(uint256,uint256)")]
SetThenGet { idx: u256, value: u256 } -> u256,
}
pub contract Bench {
mut pack: StoragePackedArray<8, 0>,
recv BenchMsg {
Set { idx, value } uses (mut pack) {
pack.set(i: idx, value)
}
SetTwoLanes { idxA, valA, idxB, valB } uses (mut pack) {
pack.set(i: idxA, value: valA)
pack.set(i: idxB, value: valB)
}
Get { idx } -> u256 uses (pack) {
pack.get(idx)
}
SetThenGet { idx, value } -> u256 uses (mut pack) {
pack.set(i: idx, value)
pack.get(idx)
}
}
}