@version 1
condition triggered_by: transaction, on: provision(_evm_contract, _url), as: [
previous_public_key: (
# Transaction is not yet validated so we need to use previous address
# to get the genesis address
previous_address = Chain.get_previous_address()
Chain.get_genesis_address(previous_address) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
)
]
actions triggered_by: transaction, on: provision(evm_contract, url) do
next_code = """
@version 1
# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: 1702047180 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 49.75
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702047180
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 49.75
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x9AAFAA03287D1CC28AF3EB5D717016EA0706A4128E4D85912A688DA3D1866F5F,
address: (
valid? = false
abi_data = Evm.abi_encode("status()")
tx = [to: "#{evm_contract}", data: "0x\#{abi_data}"]
request = [jsonrpc: "2.0", id: "1", method: "eth_call", params: [tx, "latest"]]
headers = ["Content-Type": "application/json"]
body = Json.to_string(request)
res = Http.request("#{url}", "POST", headers, body)
if res.status == 200 && Json.is_valid?(res.body) do
response = Json.parse(res.body)
result = Map.get(response, "result")
if result != nil do
decoded_abi = Evm.abi_decode("(uint)", result)
# Withdrawn status is 1
valid? = List.at(decoded_abi, 0) == 1
end
end
valid?
)
]
actions triggered_by: transaction, on: reveal_secret(secret) do
Contract.set_type "transfer"
Contract.add_uco_transfer to: 0x0000FC5DC578B178F5C4F099B5886BED6EF94D4707245D25AB30CA63514FA4CCBB4C, amount: 49.60075
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.14925
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
5AB022FAED29E247CA0C7EF6060E26064F867BD315DBC6E89B4349C94C62A963A0449E8808FD0410B502DD9F5F992A8E7A41069B5DD447852EF65AC5
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00003EC6...C042request_funds
[ 1702047180, 49.75, "0000fc5dc578b178f5c4f099b5886bed6ef94d4707245d25ab30ca63514fa4ccbb4c", "9aafaa03287d1cc28af3eb5d717016ea0706a4128e4d85912a688da3d1866f5f", "0x864e32ecd3ea202258e30da3a233c9b97c7cb488c55fd6b77b6c8644807827cc", "0xd6a29f244efcb65036286aedb4433679981001f6", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000F7BD...B5AAAt 2023-12-08 12:54:29 UTCAmount 0.24249051 UCO
Previous public key
0001D92C854F7EEBD80605D7EAFBAE6E02DB86CBB26EDBB89ED408D76E8BEAE74545
Previous signature
8998B6632595F647EA9456617FD89C6C54B4387E6D6DD6605A9260C128953BBB9B8798F7F58E293EDD2CD89087EED3C23BAE3F22D33A3120DB3E83AC2F63F70A
Origin signature
30450221008B446633CF7994856B67D7D1B86373A2F02023BD300F0548171525B2382B747202202CB1A6A4D5C3CBF77E9DFB91049EBA5590FD870828BAD78253A1DB0395CADAFD
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00981CEBF18FE2C9A4B54F1592F53E3DABEA59444F944E0F167012237C3C09AFC3
Coordinator signature
CA81453B9791DD38D9DF453952CD825F6149319A16484109D7AC4E45C3007B234E5C736FDE2CFEE6951025C39533B1F099B7BC9636C0B49FF64D97EF48753209
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
7BCD224C0DDEDC9A37710D1DDDD2250C654F028623736A81AE6FAEC12AE950AA0C81D8E09B7E9BCAED7F676C327E8802AB6CF3878702AF47DFA0911C937E2702
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
9521AF861493DBB587FA60239ADA48117391DCA3C96BBF9E0879992A2EF8CBB211B228ED7A21DD90B60FBD84FBCDD29D9CAE1A11B363A95D263021C010D1D306