-
Notifications
You must be signed in to change notification settings - Fork 46
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
Showing
5 changed files
with
320 additions
and
16 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
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
55 changes: 55 additions & 0 deletions
55
contract/vm_dummy/test_files/feature_multicall_contract.lua
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,55 @@ | ||
state.var { | ||
dict = state.map() | ||
} | ||
|
||
function set_value(key, value) | ||
dict[key] = value | ||
end | ||
|
||
function get_value(key) | ||
return dict[key] | ||
end | ||
|
||
abi.register(set_value) | ||
abi.register_view(get_value) | ||
|
||
function call(...) | ||
return contract.call(...) | ||
end | ||
|
||
function delegate_call(...) | ||
return contract.delegatecall(...) | ||
end | ||
|
||
function multicall(script) | ||
return contract.delegatecall("multicall", script) | ||
end | ||
|
||
function multicall_and_check(script) | ||
local result1, result2 = contract.delegatecall("multicall", script) | ||
assert(contract.balance() == "875000000000000000") | ||
assert(contract.balance("AmhXhR3Eguhu5qjVoqcg7aCFMpw1GGZJfqDDqfy6RsTP7MrpWeJ9") == "125000000000000000") | ||
return result1, result2 | ||
end | ||
|
||
abi.register(call, delegate_call, multicall, multicall_and_check) | ||
|
||
function recv_aergo() | ||
-- does nothing | ||
end | ||
|
||
function default() | ||
-- does nothing | ||
end | ||
|
||
function send_to(address, amount) | ||
contract.send(address, amount) | ||
end | ||
|
||
function get_balance() | ||
return contract.balance() | ||
end | ||
|
||
abi.payable(recv_aergo, default) | ||
abi.register(send_to) | ||
abi.register_view(get_balance) |
Oops, something went wrong.