Skip to content

Commit

Permalink
feat: commiting to get suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginowine committed Jul 15, 2024
1 parent 3ca0b14 commit b861cff
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 46 deletions.
2 changes: 1 addition & 1 deletion packages/evm/evmtest/wiki_how_tos/L1Assets.abi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"inputs":[{"components":[{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct L1Address","name":"to","type":"tuple"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
[{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"components":[{"components":[{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct NativeTokenID","name":"ID","type":"tuple"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct NativeToken[]","name":"_amount","type":"tuple[]"}],"name":"allow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct L1Address","name":"to","type":"tuple"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
2 changes: 1 addition & 1 deletion packages/evm/evmtest/wiki_how_tos/L1Assets.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6080604052348015600e575f80fd5b506110228061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c80639505f6dc1461002d575b5f80fd5b6100476004803603810190610042919061047b565b610049565b005b5f73107400000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a714b58d336040518263ffffffff1660e01b81526004016100979190610501565b5f60405180830381865afa1580156100b1573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906100d99190610932565b905073107400000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663423fa15133836040518363ffffffff1660e01b815260040161012a929190610c21565b5f604051808303815f87803b158015610141575f80fd5b505af1158015610153573d5f803e3d5ffd5b5050505061015f6101ef565b61016761023d565b73107400000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663b7a53f5385855f86866040518663ffffffff1660e01b81526004016101bc959493929190610f7f565b5f604051808303815f87803b1580156101d3575f80fd5b505af11580156101e5573d5f803e3d5ffd5b5050505050505050565b6040518060a001604052805f63ffffffff1681526020015f63ffffffff16815260200161021a61025f565b8152602001610227610272565b81526020015f67ffffffffffffffff1681525090565b60405180604001604052805f60070b815260200161025961029c565b81525090565b6040518060200160405280606081525090565b60405180606001604052805f67ffffffffffffffff16815260200160608152602001606081525090565b60405180604001604052805f60070b81526020016102b86102be565b81525090565b6040518060200160405280606081525090565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61032c826102e6565b810181811067ffffffffffffffff8211171561034b5761034a6102f6565b5b80604052505050565b5f61035d6102d1565b90506103698282610323565b919050565b5f80fd5b5f80fd5b5f80fd5b5f67ffffffffffffffff821115610394576103936102f6565b5b61039d826102e6565b9050602081019050919050565b828183375f83830152505050565b5f6103ca6103c58461037a565b610354565b9050828152602081018484840111156103e6576103e5610376565b5b6103f18482856103aa565b509392505050565b5f82601f83011261040d5761040c610372565b5b813561041d8482602086016103b8565b91505092915050565b5f6020828403121561043b5761043a6102e2565b5b6104456020610354565b90505f82013567ffffffffffffffff8111156104645761046361036e565b5b610470848285016103f9565b5f8301525092915050565b5f602082840312156104905761048f6102da565b5b5f82013567ffffffffffffffff8111156104ad576104ac6102de565b5b6104b984828501610426565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6104eb826104c2565b9050919050565b6104fb816104e1565b82525050565b5f6020820190506105145f8301846104f2565b92915050565b5f67ffffffffffffffff82169050919050565b6105368161051a565b8114610540575f80fd5b50565b5f815190506105518161052d565b92915050565b5f67ffffffffffffffff821115610571576105706102f6565b5b602082029050602081019050919050565b5f80fd5b8281835e5f83830152505050565b5f6105a66105a18461037a565b610354565b9050828152602081018484840111156105c2576105c1610376565b5b6105cd848285610586565b509392505050565b5f82601f8301126105e9576105e8610372565b5b81516105f9848260208601610594565b91505092915050565b5f60208284031215610617576106166102e2565b5b6106216020610354565b90505f82015167ffffffffffffffff8111156106405761063f61036e565b5b61064c848285016105d5565b5f8301525092915050565b5f819050919050565b61066981610657565b8114610673575f80fd5b50565b5f8151905061068481610660565b92915050565b5f6040828403121561069f5761069e6102e2565b5b6106a96040610354565b90505f82015167ffffffffffffffff8111156106c8576106c761036e565b5b6106d484828501610602565b5f8301525060206106e784828501610676565b60208301525092915050565b5f61070561070084610557565b610354565b9050808382526020820190506020840283018581111561072857610727610582565b5b835b8181101561076f57805167ffffffffffffffff81111561074d5761074c610372565b5b80860161075a898261068a565b8552602085019450505060208101905061072a565b5050509392505050565b5f82601f83011261078d5761078c610372565b5b815161079d8482602086016106f3565b91505092915050565b5f67ffffffffffffffff8211156107c0576107bf6102f6565b5b602082029050602081019050919050565b5f819050919050565b6107e3816107d1565b81146107ed575f80fd5b50565b5f815190506107fe816107da565b92915050565b5f610816610811846107a6565b610354565b9050808382526020820190506020840283018581111561083957610838610582565b5b835b81811015610862578061084e88826107f0565b84526020840193505060208101905061083b565b5050509392505050565b5f82601f8301126108805761087f610372565b5b8151610890848260208601610804565b91505092915050565b5f606082840312156108ae576108ad6102e2565b5b6108b86060610354565b90505f6108c784828501610543565b5f83015250602082015167ffffffffffffffff8111156108ea576108e961036e565b5b6108f684828501610779565b602083015250604082015167ffffffffffffffff81111561091a5761091961036e565b5b6109268482850161086c565b60408301525092915050565b5f60208284031215610947576109466102da565b5b5f82015167ffffffffffffffff811115610964576109636102de565b5b61097084828501610899565b91505092915050565b6109828161051a565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f81519050919050565b5f82825260208201905092915050565b5f6109d5826109b1565b6109df81856109bb565b93506109ef818560208601610586565b6109f8816102e6565b840191505092915050565b5f602083015f8301518482035f860152610a1d82826109cb565b9150508091505092915050565b610a3381610657565b82525050565b5f604083015f8301518482035f860152610a538282610a03565b9150506020830151610a686020860182610a2a565b508091505092915050565b5f610a7e8383610a39565b905092915050565b5f602082019050919050565b5f610a9c82610988565b610aa68185610992565b935083602082028501610ab8856109a2565b805f5b85811015610af35784840389528151610ad48582610a73565b9450610adf83610a86565b925060208a01995050600181019050610abb565b50829750879550505050505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f610b38826107d1565b9050919050565b610b4881610b2e565b82525050565b5f610b598383610b3f565b60208301905092915050565b5f602082019050919050565b5f610b7b82610b05565b610b858185610b0f565b9350610b9083610b1f565b805f5b83811015610bc0578151610ba78882610b4e565b9750610bb283610b65565b925050600181019050610b93565b5085935050505092915050565b5f606083015f830151610be25f860182610979565b5060208301518482036020860152610bfa8282610a92565b91505060408301518482036040860152610c148282610b71565b9150508091505092915050565b5f604082019050610c345f8301856104f2565b8181036020830152610c468184610bcd565b90509392505050565b5f602083015f8301518482035f860152610c6982826109cb565b9150508091505092915050565b5f8115159050919050565b610c8a81610c76565b82525050565b5f63ffffffff82169050919050565b5f819050919050565b5f610cc2610cbd610cb884610c90565b610c9f565b610c90565b9050919050565b610cd281610ca8565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f604083015f8301518482035f860152610d1b82826109cb565b91505060208301518482036020860152610d3582826109cb565b9150508091505092915050565b5f610d4d8383610d01565b905092915050565b5f602082019050919050565b5f610d6b82610cd8565b610d758185610ce2565b935083602082028501610d8785610cf2565b805f5b85811015610dc25784840389528151610da38582610d42565b9450610dae83610d55565b925060208a01995050600181019050610d8a565b50829750879550505050505092915050565b5f602083015f8301518482035f860152610dee8282610d61565b9150508091505092915050565b5f606083015f830151610e105f860182610979565b5060208301518482036020860152610e288282610a92565b91505060408301518482036040860152610e428282610b71565b9150508091505092915050565b5f60a083015f830151610e645f860182610cc9565b506020830151610e776020860182610cc9565b5060408301518482036040860152610e8f8282610dd4565b91505060608301518482036060860152610ea98282610dfb565b9150506080830151610ebe6080860182610979565b508091505092915050565b5f8160070b9050919050565b610ede81610ec9565b82525050565b5f602083015f8301518482035f860152610efe82826109cb565b9150508091505092915050565b5f604083015f830151610f205f860182610ed5565b5060208301518482036020860152610f388282610ee4565b9150508091505092915050565b5f604083015f830151610f5a5f860182610ed5565b5060208301518482036020860152610f728282610f0b565b9150508091505092915050565b5f60a0820190508181035f830152610f978188610c4f565b90508181036020830152610fab8187610bcd565b9050610fba6040830186610c81565b8181036060830152610fcc8185610e4f565b90508181036080830152610fe08184610f45565b9050969550505050505056fea2646970667358221220bc9fb66c19a0073be20bc438e3354360e47b6904ffba39e99e0e5e38acf3c32464736f6c63430008190033
6080604052348015600e575f80fd5b506112e48061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80631d62c241146100385780639505f6dc14610054575b5f80fd5b610052600480360381019061004d919061070c565b610070565b005b61006e600480360381019061006991906107bb565b610102565b005b6100786102a8565b81816020018190525073107400000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663765f4f9e84836040518363ffffffff1660e01b81526004016100d0929190610ae3565b5f604051808303815f87803b1580156100e7575f80fd5b505af11580156100f9573d5f803e3d5ffd5b50505050505050565b5f73107400000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a714b58d336040518263ffffffff1660e01b81526004016101509190610b11565b5f60405180830381865afa15801561016a573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906101929190610eca565b905073107400000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663423fa15133836040518363ffffffff1660e01b81526004016101e3929190610ae3565b5f604051808303815f87803b1580156101fa575f80fd5b505af115801561020c573d5f803e3d5ffd5b505050506102186102d2565b610220610320565b73107400000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663b7a53f5385855f86866040518663ffffffff1660e01b8152600401610275959493929190611241565b5f604051808303815f87803b15801561028c575f80fd5b505af115801561029e573d5f803e3d5ffd5b5050505050505050565b60405180606001604052805f67ffffffffffffffff16815260200160608152602001606081525090565b6040518060a001604052805f63ffffffff1681526020015f63ffffffff1681526020016102fd610342565b815260200161030a6102a8565b81526020015f67ffffffffffffffff1681525090565b60405180604001604052805f60070b815260200161033c610355565b81525090565b6040518060200160405280606081525090565b60405180604001604052805f60070b8152602001610371610377565b81525090565b6040518060200160405280606081525090565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6103c48261039b565b9050919050565b6103d4816103ba565b81146103de575f80fd5b50565b5f813590506103ef816103cb565b92915050565b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61043f826103f9565b810181811067ffffffffffffffff8211171561045e5761045d610409565b5b80604052505050565b5f61047061038a565b905061047c8282610436565b919050565b5f67ffffffffffffffff82111561049b5761049a610409565b5b602082029050602081019050919050565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f67ffffffffffffffff8211156104d6576104d5610409565b5b6104df826103f9565b9050602081019050919050565b828183375f83830152505050565b5f61050c610507846104bc565b610467565b905082815260208101848484011115610528576105276104b8565b5b6105338482856104ec565b509392505050565b5f82601f83011261054f5761054e6103f5565b5b813561055f8482602086016104fa565b91505092915050565b5f6020828403121561057d5761057c6104b0565b5b6105876020610467565b90505f82013567ffffffffffffffff8111156105a6576105a56104b4565b5b6105b28482850161053b565b5f8301525092915050565b5f819050919050565b6105cf816105bd565b81146105d9575f80fd5b50565b5f813590506105ea816105c6565b92915050565b5f60408284031215610605576106046104b0565b5b61060f6040610467565b90505f82013567ffffffffffffffff81111561062e5761062d6104b4565b5b61063a84828501610568565b5f83015250602061064d848285016105dc565b60208301525092915050565b5f61066b61066684610481565b610467565b9050808382526020820190506020840283018581111561068e5761068d6104ac565b5b835b818110156106d557803567ffffffffffffffff8111156106b3576106b26103f5565b5b8086016106c089826105f0565b85526020850194505050602081019050610690565b5050509392505050565b5f82601f8301126106f3576106f26103f5565b5b8135610703848260208601610659565b91505092915050565b5f806040838503121561072257610721610393565b5b5f61072f858286016103e1565b925050602083013567ffffffffffffffff8111156107505761074f610397565b5b61075c858286016106df565b9150509250929050565b5f6020828403121561077b5761077a6104b0565b5b6107856020610467565b90505f82013567ffffffffffffffff8111156107a4576107a36104b4565b5b6107b08482850161053b565b5f8301525092915050565b5f602082840312156107d0576107cf610393565b5b5f82013567ffffffffffffffff8111156107ed576107ec610397565b5b6107f984828501610766565b91505092915050565b61080b816103ba565b82525050565b5f67ffffffffffffffff82169050919050565b61082d81610811565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f61088e8261085c565b6108988185610866565b93506108a8818560208601610876565b6108b1816103f9565b840191505092915050565b5f602083015f8301518482035f8601526108d68282610884565b9150508091505092915050565b6108ec816105bd565b82525050565b5f604083015f8301518482035f86015261090c82826108bc565b915050602083015161092160208601826108e3565b508091505092915050565b5f61093783836108f2565b905092915050565b5f602082019050919050565b5f61095582610833565b61095f818561083d565b9350836020820285016109718561084d565b805f5b858110156109ac578484038952815161098d858261092c565b94506109988361093f565b925060208a01995050600181019050610974565b50829750879550505050505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f819050919050565b5f6109fa826109e7565b9050919050565b610a0a816109f0565b82525050565b5f610a1b8383610a01565b60208301905092915050565b5f602082019050919050565b5f610a3d826109be565b610a4781856109c8565b9350610a52836109d8565b805f5b83811015610a82578151610a698882610a10565b9750610a7483610a27565b925050600181019050610a55565b5085935050505092915050565b5f606083015f830151610aa45f860182610824565b5060208301518482036020860152610abc828261094b565b91505060408301518482036040860152610ad68282610a33565b9150508091505092915050565b5f604082019050610af65f830185610802565b8181036020830152610b088184610a8f565b90509392505050565b5f602082019050610b245f830184610802565b92915050565b610b3381610811565b8114610b3d575f80fd5b50565b5f81519050610b4e81610b2a565b92915050565b5f610b66610b61846104bc565b610467565b905082815260208101848484011115610b8257610b816104b8565b5b610b8d848285610876565b509392505050565b5f82601f830112610ba957610ba86103f5565b5b8151610bb9848260208601610b54565b91505092915050565b5f60208284031215610bd757610bd66104b0565b5b610be16020610467565b90505f82015167ffffffffffffffff811115610c0057610bff6104b4565b5b610c0c84828501610b95565b5f8301525092915050565b5f81519050610c25816105c6565b92915050565b5f60408284031215610c4057610c3f6104b0565b5b610c4a6040610467565b90505f82015167ffffffffffffffff811115610c6957610c686104b4565b5b610c7584828501610bc2565b5f830152506020610c8884828501610c17565b60208301525092915050565b5f610ca6610ca184610481565b610467565b90508083825260208201905060208402830185811115610cc957610cc86104ac565b5b835b81811015610d1057805167ffffffffffffffff811115610cee57610ced6103f5565b5b808601610cfb8982610c2b565b85526020850194505050602081019050610ccb565b5050509392505050565b5f82601f830112610d2e57610d2d6103f5565b5b8151610d3e848260208601610c94565b91505092915050565b5f67ffffffffffffffff821115610d6157610d60610409565b5b602082029050602081019050919050565b610d7b816109e7565b8114610d85575f80fd5b50565b5f81519050610d9681610d72565b92915050565b5f610dae610da984610d47565b610467565b90508083825260208201905060208402830185811115610dd157610dd06104ac565b5b835b81811015610dfa5780610de68882610d88565b845260208401935050602081019050610dd3565b5050509392505050565b5f82601f830112610e1857610e176103f5565b5b8151610e28848260208601610d9c565b91505092915050565b5f60608284031215610e4657610e456104b0565b5b610e506060610467565b90505f610e5f84828501610b40565b5f83015250602082015167ffffffffffffffff811115610e8257610e816104b4565b5b610e8e84828501610d1a565b602083015250604082015167ffffffffffffffff811115610eb257610eb16104b4565b5b610ebe84828501610e04565b60408301525092915050565b5f60208284031215610edf57610ede610393565b5b5f82015167ffffffffffffffff811115610efc57610efb610397565b5b610f0884828501610e31565b91505092915050565b5f602083015f8301518482035f860152610f2b8282610884565b9150508091505092915050565b5f8115159050919050565b610f4c81610f38565b82525050565b5f63ffffffff82169050919050565b5f819050919050565b5f610f84610f7f610f7a84610f52565b610f61565b610f52565b9050919050565b610f9481610f6a565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f604083015f8301518482035f860152610fdd8282610884565b91505060208301518482036020860152610ff78282610884565b9150508091505092915050565b5f61100f8383610fc3565b905092915050565b5f602082019050919050565b5f61102d82610f9a565b6110378185610fa4565b93508360208202850161104985610fb4565b805f5b8581101561108457848403895281516110658582611004565b945061107083611017565b925060208a0199505060018101905061104c565b50829750879550505050505092915050565b5f602083015f8301518482035f8601526110b08282611023565b9150508091505092915050565b5f606083015f8301516110d25f860182610824565b50602083015184820360208601526110ea828261094b565b915050604083015184820360408601526111048282610a33565b9150508091505092915050565b5f60a083015f8301516111265f860182610f8b565b5060208301516111396020860182610f8b565b50604083015184820360408601526111518282611096565b9150506060830151848203606086015261116b82826110bd565b91505060808301516111806080860182610824565b508091505092915050565b5f8160070b9050919050565b6111a08161118b565b82525050565b5f602083015f8301518482035f8601526111c08282610884565b9150508091505092915050565b5f604083015f8301516111e25f860182611197565b50602083015184820360208601526111fa82826111a6565b9150508091505092915050565b5f604083015f83015161121c5f860182611197565b506020830151848203602086015261123482826111cd565b9150508091505092915050565b5f60a0820190508181035f8301526112598188610f11565b9050818103602083015261126d8187610a8f565b905061127c6040830186610f43565b818103606083015261128e8185611111565b905081810360808301526112a28184611207565b9050969550505050505056fea2646970667358221220a198779f8d262a5281c4c07b99f49391656edf0a14408696531fc65ded20a3a664736f6c63430008190033
9 changes: 9 additions & 0 deletions packages/evm/evmtest/wiki_how_tos/L1Assets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ pragma solidity ^0.8.0;
import "@iscmagic/ISC.sol";

contract L1Assets {

function allow(address memory _address, NativeTokenID memory _nativeTokenId) public {
NativeTokenID[] memory nativeTokenIds = new NativeTokenID[](1);
nativeTokenIds[0] = NativeTokenID.wrap(_nativeTokenId);
ISCAssets memory assets;
assets.nativeTokens = _nativeTokenIds;
ISC.sandbox.allow(_address, assets);
}

function withdraw(L1Address memory to) public {
ISCAssets memory allowance = ISC.sandbox.getAllowanceFrom(msg.sender);
ISC.sandbox.takeAllowedFunds(msg.sender, allowance);
Expand Down
Loading

0 comments on commit b861cff

Please sign in to comment.