From 1240280b79f59637efac734d9600227e993e808a Mon Sep 17 00:00:00 2001 From: Ruslan Serebriakov Date: Thu, 1 Jun 2023 19:03:53 +0100 Subject: [PATCH] =?UTF-8?q?[ERC-4337]=20Making=20UserOp=20generation=20com?= =?UTF-8?q?patible=20with=20different=20wallet=20=E2=80=A6=20(#3173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ERC-4337] Making UserOp generation compatible with different wallet implementations * Add init code * Update BarzTests.swift * update user op construction * Fix swift tests * remove old tests * fix issues related to the new ethereum proto size * update android tests * Update TestBarz.kt * Update TestBarz.kt * Update TestBarz.kt * Update TestBarz.kt * Update TestBarz.kt * disable unity build and fix some warnings * Fix android codegen Init check * commit missing files * Update TestBarz.kt * Update TestBarz.kt * Update TestBarz.kt * Update TestBarz.kt * Update Barz.cpp * Update TestBarz.kt * Update TestBarz.kt * Update TestBarz.kt * Update TestBarz.kt * Update TestBarz.kt --------- Co-authored-by: hewigovens <360470+hewigovens@users.noreply.github.com> --- .../core/app/blockchains/ethereum/TestBarz.kt | 155 +++++++-- .../ethereum/TestEthereumAddress.kt | 9 - .../ethereum/TestEthereumTransactionSigner.kt | 231 ------------- .../lib/templates/jni/parameter_access.erb | 2 +- .../lib/templates/jni/parameter_release.erb | 2 +- .../templates/kotlin_jni/parameter_access.erb | 2 +- .../kotlin_jni/parameter_release.erb | 2 +- include/TrustWalletCore/TWBarz.h | 18 + include/TrustWalletCore/TWEthereum.h | 8 - samples/kmp/shared/build.gradle.kts | 4 +- src/Ethereum/Barz.cpp | 50 ++- src/Ethereum/Barz.h | 5 +- src/Ethereum/EIP4337.cpp | 63 ---- src/Ethereum/EIP4337.h | 20 -- src/Ethereum/ERC4337.cpp | 32 ++ src/Ethereum/ERC4337.h | 16 + src/Ethereum/Signer.cpp | 56 ++-- src/Ethereum/Transaction.cpp | 91 ++--- src/Ethereum/Transaction.h | 44 +-- src/interface/TWBarz.cpp | 18 + src/interface/TWEthereum.cpp | 8 - src/proto/Barz.proto | 17 +- src/proto/Ethereum.proto | 20 +- swift/Tests/BarzTests.swift | 115 ++++++- swift/Tests/Blockchains/EthereumTests.swift | 237 ------------- tests/chains/Ethereum/BarzTests.cpp | 201 +++++++++-- tests/chains/Ethereum/EIP4337Tests.cpp | 67 ---- tests/chains/Ethereum/SignerTests.cpp | 187 +---------- tests/chains/Ethereum/TWAnySignerTests.cpp | 315 ------------------ tests/common/TransactionCompilerTests.cpp | 2 +- .../interface/TWTransactionCompilerTests.cpp | 2 +- 31 files changed, 647 insertions(+), 1352 deletions(-) delete mode 100644 src/Ethereum/EIP4337.cpp delete mode 100644 src/Ethereum/EIP4337.h create mode 100644 src/Ethereum/ERC4337.cpp create mode 100644 src/Ethereum/ERC4337.h delete mode 100644 tests/chains/Ethereum/EIP4337Tests.cpp diff --git a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestBarz.kt b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestBarz.kt index 766ec9e752d..2dd5514e40e 100644 --- a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestBarz.kt +++ b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestBarz.kt @@ -1,9 +1,20 @@ package com.trustwallet.core.app.blockchains.ethereum -import com.trustwallet.core.app.utils.Numeric +import com.google.protobuf.ByteString +import com.trustwallet.core.app.utils.toHexByteArray import org.junit.Assert.assertEquals import org.junit.Test -import org.junit.Assert.assertFalse +import wallet.core.jni.PrivateKey +import wallet.core.java.AnySigner +import wallet.core.jni.CoinType +import wallet.core.jni.CoinType.ETHEREUM +import wallet.core.jni.proto.Ethereum +import wallet.core.jni.EthereumAbi +import wallet.core.jni.EthereumAbiFunction +import wallet.core.jni.proto.Ethereum.SigningOutput +import wallet.core.jni.proto.Ethereum.TransactionMode +import com.trustwallet.core.app.utils.Numeric +import org.junit.Assert.assertArrayEquals import wallet.core.jni.proto.Barz import wallet.core.jni.Barz as WCBarz @@ -13,43 +24,143 @@ class TestBarz { System.loadLibrary("TrustWalletCore") } + // https://testnet.bscscan.com/tx/0x434f5861b7d14b3bf790b57e5eb1be98355d77f528defe732f2994fc9d6d3f2e + @Test + fun testInitCodeFromPublicKey() { + val factoryAddress = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800" + val publicKey = "0x1dba683ee34242c993f7588c30099969a1e58e64bdd0657958ced8e4220f69678a77e6fdf4633151105bdb1a9dd419fbd65f7d8b7a39923757534d4a578e9b58" + val verificationFacet = "0x6BF22ff186CC97D88ECfbA47d1473a234CEBEFDf" + val result = WCBarz.getInitCodeFromPublicKey(factoryAddress, publicKey, verificationFacet) + assertEquals(Numeric.toHexString(result), "0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000006bf22ff186cc97d88ecfba47d1473a234cebefdf0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000401dba683ee34242c993f7588c30099969a1e58e64bdd0657958ced8e4220f69678a77e6fdf4633151105bdb1a9dd419fbd65f7d8b7a39923757534d4a578e9b58") + } + + // https://testnet.bscscan.com/tx/0x6c6e1fe81c722c0abce1856b9b4e078ab2cad06d51f2d1b04945e5ba2286d1b4 + @Test + fun testInitCodeFromAttestationObject() { + val factoryAddress = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800" + val attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d0000000000000000000000000000000000000000001464193b58d01d4047694ba4634750047a5fcd637ea5010203262001215820e6f4e0351e2f556fd7284a9a033832bae046ac31fd529ad02ab6220870624b79225820eb760e718fdaed7a037dd1d77a561759cee9f2706eb55a729dc953e0d5719b02" + val verificationFacet = "0x6BF22ff186CC97D88ECfbA47d1473a234CEBEFDf" + val result = WCBarz.getInitCodeFromAttestationObject(factoryAddress, attestationObject, verificationFacet) + assertEquals(Numeric.toHexString(result), "0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000006bf22ff186cc97d88ecfba47d1473a234cebefdf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040e6f4e0351e2f556fd7284a9a033832bae046ac31fd529ad02ab6220870624b79eb760e718fdaed7a037dd1d77a561759cee9f2706eb55a729dc953e0d5719b02") + } + + // https://testnet.bscscan.com/address/0x5d51930e0ce5cc08a67a1763fadb66892c0994d1 @Test fun testCounterfactualAddressFromPublicKey() { val input = Barz.ContractAddressInput.newBuilder() input.apply { - factory = "0xb7f8bc63bbcad18155201308c8f3540b07f84f5e" - diamondCutFacet = "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9" - accountFacet = "0xdc64a140aa3e981100a9beca4e685f962f0cf6c9" - verificationFacet = "0x5fc8d32690cc91d4c39d9d3abcbd16989f875707" - entryPoint = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" - securityManager = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512" - facetRegistry = "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0" - bytecode = "0x60808060405261127d80380380916100178285610943565b833981019060e0818303126108de5761002f81610966565b9161003c60208301610966565b9161004960408201610966565b9161005660608301610966565b9161006360808201610966565b61006f60a08301610966565b60c083015190926001600160401b0382116108de570183601f820112156108de57805161009b8161097a565b946100a96040519687610943565b818652602082840101116108de576100c79160208087019101610995565b604051633253960f60e01b815260208160048160006001600160a01b038b165af19081156108eb576000916108a3575b506001600160e01b031981161561085f576040979695975196610119886108f7565b6002885260005b6040811061082b57509161026693916102749695936040519061014282610928565b60018252602036818401376040519161015a83610928565b60018352602036818501376307e4c70760e21b610176826109b8565b5260405191610184836108f7565b6001600160a01b031682526000602083015260408201526101a48b6109b8565b526101ae8a6109b8565b506001600160e01b031982166101c3826109b8565b52604051906101d1826108f7565b6001600160a01b038c1682526000602083015260408201526101f28a6109db565b526101fc896109db565b506001805464ffffffff00191660d89290921c64ffffffff0016919091179055604051634a93641760e01b60208201526001600160a01b03958616602482015298851660448a015284166064890152909216608487015260a060a4870152859160c48301906109ff565b03601f198101855284610943565b6000915b805183101561070457602061028d84836109eb565b51015160038110156106ee578061041457506001600160a01b036102b184836109eb565b5151169160406102c185846109eb565b510151916102d183511515610a49565b6102dc841515610aa9565b6001600160a01b038416600090815260008051602061125d83398151915260205260409020546001600160601b0316918215610406575b6000925b84518410156103ec576001600160e01b031961033385876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031661038157816103708861037b9461037594610c3b565b610b0a565b93610a24565b92610317565b60405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c72656164792065786973747300000000000000000000006064820152608490fd5b509491509492506103fe91505b610a24565b919092610278565b61040f85610b49565b610313565b9193916001810361058d57506001600160a01b0361043284836109eb565b51511693604061044285846109eb565b5101519161045283511515610a49565b61045d861515610aa9565b6001600160a01b038616600090815260008051602061125d83398151915260205260409020546001600160601b031691821561057f575b6000925b845184101561056f576001600160e01b03196104b485876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031691898314610504576103708a82846104f9610375966104fe98610d26565b610c3b565b92610498565b60405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608490fd5b5094915094506103fe9150610a24565b61058887610b49565b610494565b600203610699576001600160a01b036105a684836109eb565b5151169360406105b685846109eb565b510151946105c686511515610a49565b61062e5760005b85518110156106215761061c906103f96001600160e01b03196105f0838a6109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b0316610d26565b6105cd565b50926103fe919450610a24565b60405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d7573742062652061646472657373283029000000000000000000006064820152608490fd5b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b8382604051606081016060825284518091526080820190602060808260051b8501019601916000905b828210610793576001600160a01b0386166020860152848803604086015261078587877f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673888061077d8e866109ff565b0390a161101f565b60405160e2908161113b8239f35b848803607f19018152835180516001600160a01b03168952602081015194989394929391929060038210156106ee576040916020840152015190606060408201526020608060608301928451809452019201906000905b8082106108085750505060208060019299019201920190929161072d565b82516001600160e01b0319168452602093840193909201916001909101906107ea565b60209060409a98999a5161083e816108f7565b600081526000838201526060604082015282828d0101520198979698610120565b606460405162461bcd60e51b815260206004820152602060248201527f4261727a3a20496e76616c696420566572696669636174696f6e2046616365746044820152fd5b90506020813d6020116108e3575b816108be60209383610943565b810103126108de57516001600160e01b0319811681036108de57386100f7565b600080fd5b3d91506108b1565b6040513d6000823e3d90fd5b606081019081106001600160401b0382111761091257604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b0382111761091257604052565b601f909101601f19168101906001600160401b0382119082101761091257604052565b51906001600160a01b03821682036108de57565b6001600160401b03811161091257601f01601f191660200190565b60005b8381106109a85750506000910152565b8181015183820152602001610998565b8051156109c55760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156109c55760400190565b80518210156109c55760209160051b010190565b90602091610a1881518092818552858086019101610995565b601f01601f1916010190565b6000198114610a335760010190565b634e487b7160e01b600052601160045260246000fd5b15610a5057565b60405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b6064820152608490fd5b15610ab057565b60405162461bcd60e51b815260206004820152602c60248201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260448201526b65206164647265737328302960a01b6064820152608490fd5b6001600160601b03908116908114610a335760010190565b60008051602061123d83398151915280548210156109c55760005260206000200190600090565b610b95604051610b58816108f7565b602481527f4c69624469616d6f6e644375743a204e657720666163657420686173206e6f20602082015263636f646560e01b60408201528261110d565b60008051602061123d83398151915280546001600160a01b038316600090815260008051602061125d833981519152602052604090206001018190559190680100000000000000008310156109125782610bf7916001610c1695019055610b22565b90919082549060031b9160018060a01b03809116831b921b1916179055565b565b91909180548310156109c557600052601c60206000208360031c019260021b1690565b6001600160e01b03198116600081815260008051602061121d83398151915260208190526040822080546001600160a01b031660a09690961b6001600160a01b031916959095179094559194939092906001600160a01b031680835260008051602061125d8339815191526020526040832080549194919068010000000000000000821015610d125796610cdc8260409798996001610cf995018155610c18565b90919063ffffffff83549160031b9260e01c831b921b1916179055565b82526020522080546001600160a01b0319169091179055565b634e487b7160e01b85526041600452602485fd5b9091906001600160a01b039081168015610fb457308114610f585763ffffffff60e01b80941660009281845260008051602061121d833981519152926020918483526040948587205460a01c9083885260008051602061125d8339815191529586865287892054926000199b8c8501948511610f4457908991888c898c89808703610ed6575b505090525050508787525087892080548015610ec2578c0190610dcf8282610c18565b63ffffffff82549160031b1b191690555588528452868681205515610df9575b5050505050509050565b60008051602061123d8339815191528054898101908111610eae57838852858552826001888a20015491808303610e7c575b5050508054988915610e685760019798990191610e4783610b22565b909182549160031b1b19169055558552528220015580388080808080610def565b634e487b7160e01b88526031600452602488fd5b610e8590610b22565b90549060031b1c16610e9a81610bf784610b22565b885285855260018789200155388281610e2b565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b8b52603160045260248bfd5b610f379784610cdc93610ef58a9487610f0b9952828a52848420610c18565b90549060031b1c60e01b97889683525220610c18565b168b52838852898b2080546001600160a01b031660a09290921b6001600160a01b031916919091179055565b873880888c898c89610dac565b634e487b7160e01b8b52601160045260248bfd5b60405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608490fd5b60405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608490fd5b6001600160a01b038116919082156111085760008091611085604051611044816108f7565b602881527f4c69624469616d6f6e644375743a205f696e6974206164647265737320686173602082015267206e6f20636f646560c01b60408201528261110d565b83519060208501905af4913d15611100573d926110a18461097a565b936110af6040519586610943565b84523d6000602086013e5b156110c457505050565b8251156110d357825160208401fd5b6110fc60405192839263192105d760e01b845260048401526040602484015260448301906109ff565b0390fd5b6060926110ba565b505050565b3b156111165750565b60405162461bcd60e51b8152602060048201529081906110fc9060248301906109ff56fe6080604052361560aa57600080356001600160e01b03191681527f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f60205260408120546001600160a01b03168015606c57818091368280378136915af43d82803e156068573d90f35b3d90fd5b62461bcd60e51b6080526020608452602060a4527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460c45260646080fd5b00fea26469706673582212203df3feea7f1aa6ea31eb82d2ad84790e47617c094ced4ce17015a8a7487295da64736f6c63430008120033183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4921183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4920" + factory = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800" + diamondCutFacet = "0x312382b3B302bDcC0711fe710314BE298426296f" + accountFacet = "0x84E684272903737d807375197f9a581FEa094Bc3" + verificationFacet = "0xDcfbDE24847FdF29E6d0311f4bAEb2b49ae8B5a3" + entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + diamondLoupeFacet = "0x518834B7EE4461d703ED2de8bCdfC5eCf761bBCA" + diamondInit = "0x02a3C76D089c50615139B904c4dbD62F20e74a1b" + facetRegistry = "0x77A4259d76897bA1eC8D6c3EFc5c35e0D7572A8f" + bytecode = "0x608060405260405162003cc638038062003cc68339818101604052810190620000299190620019ad565b60008673ffffffffffffffffffffffffffffffffffffffff16633253960f6040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000079573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009f919062001aec565b9050600060e01b817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603620000fe576040517f5a5b4d3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600267ffffffffffffffff8111156200011e576200011d6200196b565b5b6040519080825280602002602001820160405280156200015b57816020015b62000147620018ff565b8152602001906001900390816200013d5790505b5090506000600167ffffffffffffffff8111156200017e576200017d6200196b565b5b604051908082528060200260200182016040528015620001ad5781602001602082028036833780820191505090505b5090506000600167ffffffffffffffff811115620001d057620001cf6200196b565b5b604051908082528060200260200182016040528015620001ff5781602001602082028036833780820191505090505b509050631f931c1c60e01b8260008151811062000221576200022062001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808d73ffffffffffffffffffffffffffffffffffffffff16815260200160006002811115620002ab57620002aa62001b37565b5b81526020018381525083600081518110620002cb57620002ca62001b21565b5b60200260200101819052508381600081518110620002ee57620002ed62001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020016000600281111562000378576200037762001b37565b5b8152602001828152508360018151811062000398576200039762001b21565b5b6020026020010181905250620003b9846200047e60201b620001671760201c565b6200046c838c8b8e8e8d8d8d8d604051602401620003de979695949392919062001b8c565b6040516020818303038152906040527f95a21aec000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050620004b060201b620001911760201c565b5050505050505050505050506200211f565b806200048f6200073460201b60201c565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b8351811015620006df576000848281518110620004d557620004d462001b21565b5b602002602001015160200151905060006002811115620004fa57620004f962001b37565b5b81600281111562000510576200050f62001b37565b5b0362000570576200056a85838151811062000530576200052f62001b21565b5b60200260200101516000015186848151811062000552576200055162001b21565b5b6020026020010151604001516200073960201b60201c565b620006c8565b6001600281111562000587576200058662001b37565b5b8160028111156200059d576200059c62001b37565b5b03620005fd57620005f7858381518110620005bd57620005bc62001b21565b5b602002602001015160000151868481518110620005df57620005de62001b21565b5b602002602001015160400151620009db60201b60201c565b620006c7565b60028081111562000613576200061262001b37565b5b81600281111562000629576200062862001b37565b5b0362000689576200068385838151811062000649576200064862001b21565b5b6020026020010151600001518684815181106200066b576200066a62001b21565b5b60200260200101516040015162000c8f60201b60201c565b620006c6565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620006bd9062001be7565b60405180910390fd5b5b5b508080620006d69062001c61565b915050620004b3565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673838383604051620007159392919062001c82565b60405180910390a16200072f828262000e3760201b60201c565b505050565b600090565b600081511162000780576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007779062001d97565b60405180910390fd5b60006200079262000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000806576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007fd9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036200087c576200087b828562000f9860201b60201c565b5b60005b8351811015620009d4576000848281518110620008a157620008a062001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161462000998576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200098f9062001e5f565b60405180910390fd5b620009ac8583868a6200107c60201b60201c565b8380620009b99062001ec3565b94505050508080620009cb9062001c61565b9150506200087f565b5050505050565b600081511162000a22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a199062001d97565b60405180910390fd5b600062000a3462000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000aa8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a9f9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff160362000b1e5762000b1d828562000f9860201b60201c565b5b60005b835181101562000c8857600084828151811062000b435762000b4262001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160362000c39576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000c309062001eef565b60405180910390fd5b62000c4c8582846200122960201b60201c565b62000c608583868a6200107c60201b60201c565b838062000c6d9062001ec3565b9450505050808062000c7f9062001c61565b91505062000b21565b5050505050565b600081511162000cd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000ccd9062001d97565b60405180910390fd5b600062000ce862000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161462000d5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000d539062001f53565b60405180910390fd5b60005b825181101562000e3157600083828151811062000d815762000d8062001b21565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905062000e198482846200122960201b60201c565b5050808062000e289062001c61565b91505062000d5f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16031562000f675762000e988260405180606001604052806028815260200162003c7a60289139620018aa60201b60201c565b6000808373ffffffffffffffffffffffffffffffffffffffff168360405162000ec2919062001fb7565b600060405180830381855af49150503d806000811462000eff576040519150601f19603f3d011682016040523d82523d6000602084013e62000f04565b606091505b50915091508162000f645760008151111562000f235780518082602001fd5b83836040517f192105d700000000000000000000000000000000000000000000000000000000815260040162000f5b92919062001fd7565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b62000fc38160405180606001604052806024815260200162003ca260249139620018aa60201b60201c565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200129b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620012929062002003565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200130c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013039062002067565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050620013e59190620020cb565b9050808214620015805760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000182815481106200144a576200144962001b21565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018481548110620014c957620014c862001b21565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805480620015d757620015d6620020ec565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff0219169055505060008103620018a357600060018660020180549050620016c49190620020cb565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146200180c57600087600201838154811062001732576200173162001b21565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811062001779576200177862001b21565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b86600201805480620018235762001822620020ec565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b9050600081118290620018f9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620018f0919062002102565b60405180910390fd5b50505050565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600060028111156200193e576200193d62001b37565b5b8152602001606081525090565b60008151905060018060a01b03811681146200196657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620019a157808201518184015260208101905062001984565b50600083830152505050565b600080600080600080600080610100898b031215620019cb57600080fd5b620019d6896200194b565b9750620019e660208a016200194b565b9650620019f660408a016200194b565b955062001a0660608a016200194b565b945062001a1660808a016200194b565b935062001a2660a08a016200194b565b925062001a3660c08a016200194b565b915060e089015160018060401b038082111562001a5257600080fd5b818b0191508b601f83011262001a6757600080fd5b81518181111562001a7d5762001a7c6200196b565b5b601f1960405181603f83601f860116011681019150808210848311171562001aaa5762001aa96200196b565b5b816040528281528e602084870101111562001ac457600080fd5b62001ad783602083016020880162001981565b80955050505050509295985092959890939650565b60006020828403121562001aff57600080fd5b815163ffffffff60e01b8116811462001b1757600080fd5b8091505092915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60018060a01b03811682525050565b6000815180845262001b7681602086016020860162001981565b6020601f19601f83011685010191505092915050565b600060018060a01b03808a168352808916602084015280881660408401528087166060840152808616608084015280851660a08401525060e060c083015262001bd960e083018462001b5c565b905098975050505050505050565b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b60008019820362001c775762001c7662001c4b565b5b600182019050919050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101562001d6357607f198a8503018652815188850160018060a01b038251168652848201516003811062001cf157634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b8083101562001d465763ffffffff60e01b84511682528682019150868401935060018301925062001d1a565b508096505050508282019150828601955060018101905062001cab565b505062001d738189018b62001b4d565b50868103604088015262001d88818962001b5c565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b600060018060601b0380831681810362001ee25762001ee162001c4b565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825162001fcb81846020870162001981565b80830191505092915050565b60018060a01b038316815260406020820152600062001ffa604083018462001b5c565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115620020e657620020e562001c4b565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b60208152600062002117602083018462001b5c565b905092915050565b611b4b806200212f6000396000f3fe60806040523661000b57005b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f9050809150600082600001600080357fffffffff00000000000000000000000000000000000000000000000000000000167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610141576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610138906114d3565b60405180910390fd5b3660008037600080366000845af43d6000803e8060008114610162573d6000f35b3d6000fd5b806101706103c0565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b83518110156103755760008482815181106101b2576101b1611510565b5b6020026020010151602001519050600060028111156101d4576101d3611526565b5b8160028111156101e7576101e6611526565b5b036102375761023285838151811061020257610201611510565b5b60200260200101516000015186848151811061022157610220611510565b5b6020026020010151604001516103c5565b610361565b6001600281111561024b5761024a611526565b5b81600281111561025e5761025d611526565b5b036102ae576102a985838151811061027957610278611510565b5b60200260200101516000015186848151811061029857610297611510565b5b60200260200101516040015161063c565b610360565b6002808111156102c1576102c0611526565b5b8160028111156102d4576102d3611526565b5b036103245761031f8583815181106102ef576102ee611510565b5b60200260200101516000015186848151811061030e5761030d611510565b5b6020026020010151604001516108bd565b61035f565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103569061153c565b60405180910390fd5b5b5b50808061036d906115b6565b915050610194565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103a99392919061163b565b60405180910390a16103bb8282610a48565b505050565b600090565b6000815111610409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040090611747565b60405180910390fd5b6000610413610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047b906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036104f1576104f08285610b97565b5b60005b835181101561063557600084828151811061051257610511611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610606576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105fd9061180f565b60405180910390fd5b6106128583868a610c72565b838061061d90611873565b9450505050808061062d906115b6565b9150506104f4565b5050505050565b6000815111610680576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067790611747565b60405180910390fd5b600061068a610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f2906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff1603610768576107678285610b97565b5b60005b83518110156108b657600084828151811061078957610788611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361087c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610873906118a2565b60405180910390fd5b610887858284610e1f565b6108938583868a610c72565b838061089e90611873565b945050505080806108ae906115b6565b91505061076b565b5050505050565b6000815111610901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f890611747565b60405180910390fd5b600061090b610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461097c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097390611906565b60405180910390fd5b60005b8251811015610a4257600083828151811061099d5761099c611510565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610a2d848284610e1f565b50508080610a3a906115b6565b91505061097f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160315610b6657610a9f82604051806060016040528060288152602001611aca60289139611481565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610ac7919061196a565b600060405180830381855af49150503d8060008114610b02576040519150601f19603f3d011682016040523d82523d6000602084013e610b07565b606091505b509150915081610b6357600081511115610b245780518082602001fd5b83836040517f192105d7000000000000000000000000000000000000000000000000000000008152600401610b5a929190611988565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b610bb981604051806060016040528060248152602001611af260249139611481565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610e8e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e85906119b2565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610efc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef390611a16565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050610fd39190611a7a565b90508082146111675760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001828154811061103457611033611510565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000184815481106110b0576110af611510565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054806111bb576111ba611a98565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff021916905550506000810361147a576000600186600201805490506112a59190611a7a565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146113e657600087600201838154811061130f5761130e611510565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811061135357611352611510565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b866002018054806113fa576113f9611a98565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b90506000811182906114cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c49190611aae565b60405180910390fd5b50505050565b602081526020808201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460408201526000606082019050919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b6000801982036115c9576115c86115a0565b5b600182019050919050565b60018060a01b03811682525050565b60005b838110156116015780820151818401526020810190506115e6565b50600083830152505050565b600081518084526116258160208601602086016115e3565b6020601f19601f83011685010191505092915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101561171757607f198a8503018652815188850160018060a01b03825116865284820151600381106116a857634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b808310156116fb5763ffffffff60e01b8451168252868201915086840193506001830192506116d1565b5080965050505082820191508286019550600181019050611664565b50506117258189018b6115d4565b508681036040880152611738818961160d565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b60006bffffffffffffffffffffffff808316818103611895576118946115a0565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825161197c8184602087016115e3565b80830191505092915050565b60018060a01b03831681526040602082015260006119a9604083018461160d565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115611a9257611a916115a0565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b602081526000611ac1602083018461160d565b90509291505056fe4c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465a264697066735822122045b771fb2128a1a34c5b052e9a86464933844b34929cf0d65bbea6a4e76e3b2764736f6c634300081200334c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465" owner = Barz.ContractOwner.newBuilder().apply { - publicKey = "0x019b4ee7ad22ffd4c215e5f424faf4c75577dc36" + publicKey = "0xB5547FBdC56DCE45e1B8ef75569916D438e09c46" }.build() } val result = WCBarz.getCounterfactualAddress(input.build().toByteArray()) - assertEquals(result, "0xE9C377EFCE644fd54614d77C177c14148502496F") + assertEquals(result, "0xb16Db98B365B1f89191996942612B14F1Da4Bd5f") } @Test fun testCounterfactualAddressFromAttestationObject() { val input = Barz.ContractAddressInput.newBuilder() input.apply { - factory = "0xb7f8bc63bbcad18155201308c8f3540b07f84f5e" - diamondCutFacet = "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9" - accountFacet = "0xdc64a140aa3e981100a9beca4e685f962f0cf6c9" - verificationFacet = "0x5fc8d32690cc91d4c39d9d3abcbd16989f875707" - entryPoint = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" - securityManager = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512" - facetRegistry = "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0" - bytecode = "0x60808060405261127d80380380916100178285610943565b833981019060e0818303126108de5761002f81610966565b9161003c60208301610966565b9161004960408201610966565b9161005660608301610966565b9161006360808201610966565b61006f60a08301610966565b60c083015190926001600160401b0382116108de570183601f820112156108de57805161009b8161097a565b946100a96040519687610943565b818652602082840101116108de576100c79160208087019101610995565b604051633253960f60e01b815260208160048160006001600160a01b038b165af19081156108eb576000916108a3575b506001600160e01b031981161561085f576040979695975196610119886108f7565b6002885260005b6040811061082b57509161026693916102749695936040519061014282610928565b60018252602036818401376040519161015a83610928565b60018352602036818501376307e4c70760e21b610176826109b8565b5260405191610184836108f7565b6001600160a01b031682526000602083015260408201526101a48b6109b8565b526101ae8a6109b8565b506001600160e01b031982166101c3826109b8565b52604051906101d1826108f7565b6001600160a01b038c1682526000602083015260408201526101f28a6109db565b526101fc896109db565b506001805464ffffffff00191660d89290921c64ffffffff0016919091179055604051634a93641760e01b60208201526001600160a01b03958616602482015298851660448a015284166064890152909216608487015260a060a4870152859160c48301906109ff565b03601f198101855284610943565b6000915b805183101561070457602061028d84836109eb565b51015160038110156106ee578061041457506001600160a01b036102b184836109eb565b5151169160406102c185846109eb565b510151916102d183511515610a49565b6102dc841515610aa9565b6001600160a01b038416600090815260008051602061125d83398151915260205260409020546001600160601b0316918215610406575b6000925b84518410156103ec576001600160e01b031961033385876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031661038157816103708861037b9461037594610c3b565b610b0a565b93610a24565b92610317565b60405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c72656164792065786973747300000000000000000000006064820152608490fd5b509491509492506103fe91505b610a24565b919092610278565b61040f85610b49565b610313565b9193916001810361058d57506001600160a01b0361043284836109eb565b51511693604061044285846109eb565b5101519161045283511515610a49565b61045d861515610aa9565b6001600160a01b038616600090815260008051602061125d83398151915260205260409020546001600160601b031691821561057f575b6000925b845184101561056f576001600160e01b03196104b485876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031691898314610504576103708a82846104f9610375966104fe98610d26565b610c3b565b92610498565b60405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608490fd5b5094915094506103fe9150610a24565b61058887610b49565b610494565b600203610699576001600160a01b036105a684836109eb565b5151169360406105b685846109eb565b510151946105c686511515610a49565b61062e5760005b85518110156106215761061c906103f96001600160e01b03196105f0838a6109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b0316610d26565b6105cd565b50926103fe919450610a24565b60405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d7573742062652061646472657373283029000000000000000000006064820152608490fd5b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b8382604051606081016060825284518091526080820190602060808260051b8501019601916000905b828210610793576001600160a01b0386166020860152848803604086015261078587877f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673888061077d8e866109ff565b0390a161101f565b60405160e2908161113b8239f35b848803607f19018152835180516001600160a01b03168952602081015194989394929391929060038210156106ee576040916020840152015190606060408201526020608060608301928451809452019201906000905b8082106108085750505060208060019299019201920190929161072d565b82516001600160e01b0319168452602093840193909201916001909101906107ea565b60209060409a98999a5161083e816108f7565b600081526000838201526060604082015282828d0101520198979698610120565b606460405162461bcd60e51b815260206004820152602060248201527f4261727a3a20496e76616c696420566572696669636174696f6e2046616365746044820152fd5b90506020813d6020116108e3575b816108be60209383610943565b810103126108de57516001600160e01b0319811681036108de57386100f7565b600080fd5b3d91506108b1565b6040513d6000823e3d90fd5b606081019081106001600160401b0382111761091257604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b0382111761091257604052565b601f909101601f19168101906001600160401b0382119082101761091257604052565b51906001600160a01b03821682036108de57565b6001600160401b03811161091257601f01601f191660200190565b60005b8381106109a85750506000910152565b8181015183820152602001610998565b8051156109c55760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156109c55760400190565b80518210156109c55760209160051b010190565b90602091610a1881518092818552858086019101610995565b601f01601f1916010190565b6000198114610a335760010190565b634e487b7160e01b600052601160045260246000fd5b15610a5057565b60405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b6064820152608490fd5b15610ab057565b60405162461bcd60e51b815260206004820152602c60248201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260448201526b65206164647265737328302960a01b6064820152608490fd5b6001600160601b03908116908114610a335760010190565b60008051602061123d83398151915280548210156109c55760005260206000200190600090565b610b95604051610b58816108f7565b602481527f4c69624469616d6f6e644375743a204e657720666163657420686173206e6f20602082015263636f646560e01b60408201528261110d565b60008051602061123d83398151915280546001600160a01b038316600090815260008051602061125d833981519152602052604090206001018190559190680100000000000000008310156109125782610bf7916001610c1695019055610b22565b90919082549060031b9160018060a01b03809116831b921b1916179055565b565b91909180548310156109c557600052601c60206000208360031c019260021b1690565b6001600160e01b03198116600081815260008051602061121d83398151915260208190526040822080546001600160a01b031660a09690961b6001600160a01b031916959095179094559194939092906001600160a01b031680835260008051602061125d8339815191526020526040832080549194919068010000000000000000821015610d125796610cdc8260409798996001610cf995018155610c18565b90919063ffffffff83549160031b9260e01c831b921b1916179055565b82526020522080546001600160a01b0319169091179055565b634e487b7160e01b85526041600452602485fd5b9091906001600160a01b039081168015610fb457308114610f585763ffffffff60e01b80941660009281845260008051602061121d833981519152926020918483526040948587205460a01c9083885260008051602061125d8339815191529586865287892054926000199b8c8501948511610f4457908991888c898c89808703610ed6575b505090525050508787525087892080548015610ec2578c0190610dcf8282610c18565b63ffffffff82549160031b1b191690555588528452868681205515610df9575b5050505050509050565b60008051602061123d8339815191528054898101908111610eae57838852858552826001888a20015491808303610e7c575b5050508054988915610e685760019798990191610e4783610b22565b909182549160031b1b19169055558552528220015580388080808080610def565b634e487b7160e01b88526031600452602488fd5b610e8590610b22565b90549060031b1c16610e9a81610bf784610b22565b885285855260018789200155388281610e2b565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b8b52603160045260248bfd5b610f379784610cdc93610ef58a9487610f0b9952828a52848420610c18565b90549060031b1c60e01b97889683525220610c18565b168b52838852898b2080546001600160a01b031660a09290921b6001600160a01b031916919091179055565b873880888c898c89610dac565b634e487b7160e01b8b52601160045260248bfd5b60405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608490fd5b60405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608490fd5b6001600160a01b038116919082156111085760008091611085604051611044816108f7565b602881527f4c69624469616d6f6e644375743a205f696e6974206164647265737320686173602082015267206e6f20636f646560c01b60408201528261110d565b83519060208501905af4913d15611100573d926110a18461097a565b936110af6040519586610943565b84523d6000602086013e5b156110c457505050565b8251156110d357825160208401fd5b6110fc60405192839263192105d760e01b845260048401526040602484015260448301906109ff565b0390fd5b6060926110ba565b505050565b3b156111165750565b60405162461bcd60e51b8152602060048201529081906110fc9060248301906109ff56fe6080604052361560aa57600080356001600160e01b03191681527f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f60205260408120546001600160a01b03168015606c57818091368280378136915af43d82803e156068573d90f35b3d90fd5b62461bcd60e51b6080526020608452602060a4527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460c45260646080fd5b00fea26469706673582212203df3feea7f1aa6ea31eb82d2ad84790e47617c094ced4ce17015a8a7487295da64736f6c63430008120033183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4921183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4920" + factory = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800" + diamondCutFacet = "0x312382b3B302bDcC0711fe710314BE298426296f" + accountFacet = "0x84E684272903737d807375197f9a581FEa094Bc3" + verificationFacet = "0x5034534Efe9902779eD6eA6983F435c00f3bc510" + entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + diamondLoupeFacet = "0x518834B7EE4461d703ED2de8bCdfC5eCf761bBCA" + diamondInit = "0x02a3C76D089c50615139B904c4dbD62F20e74a1b" + facetRegistry = "0x77A4259d76897bA1eC8D6c3EFc5c35e0D7572A8f" + bytecode = "0x608060405260405162003cc638038062003cc68339818101604052810190620000299190620019ad565b60008673ffffffffffffffffffffffffffffffffffffffff16633253960f6040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000079573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009f919062001aec565b9050600060e01b817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603620000fe576040517f5a5b4d3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600267ffffffffffffffff8111156200011e576200011d6200196b565b5b6040519080825280602002602001820160405280156200015b57816020015b62000147620018ff565b8152602001906001900390816200013d5790505b5090506000600167ffffffffffffffff8111156200017e576200017d6200196b565b5b604051908082528060200260200182016040528015620001ad5781602001602082028036833780820191505090505b5090506000600167ffffffffffffffff811115620001d057620001cf6200196b565b5b604051908082528060200260200182016040528015620001ff5781602001602082028036833780820191505090505b509050631f931c1c60e01b8260008151811062000221576200022062001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808d73ffffffffffffffffffffffffffffffffffffffff16815260200160006002811115620002ab57620002aa62001b37565b5b81526020018381525083600081518110620002cb57620002ca62001b21565b5b60200260200101819052508381600081518110620002ee57620002ed62001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020016000600281111562000378576200037762001b37565b5b8152602001828152508360018151811062000398576200039762001b21565b5b6020026020010181905250620003b9846200047e60201b620001671760201c565b6200046c838c8b8e8e8d8d8d8d604051602401620003de979695949392919062001b8c565b6040516020818303038152906040527f95a21aec000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050620004b060201b620001911760201c565b5050505050505050505050506200211f565b806200048f6200073460201b60201c565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b8351811015620006df576000848281518110620004d557620004d462001b21565b5b602002602001015160200151905060006002811115620004fa57620004f962001b37565b5b81600281111562000510576200050f62001b37565b5b0362000570576200056a85838151811062000530576200052f62001b21565b5b60200260200101516000015186848151811062000552576200055162001b21565b5b6020026020010151604001516200073960201b60201c565b620006c8565b6001600281111562000587576200058662001b37565b5b8160028111156200059d576200059c62001b37565b5b03620005fd57620005f7858381518110620005bd57620005bc62001b21565b5b602002602001015160000151868481518110620005df57620005de62001b21565b5b602002602001015160400151620009db60201b60201c565b620006c7565b60028081111562000613576200061262001b37565b5b81600281111562000629576200062862001b37565b5b0362000689576200068385838151811062000649576200064862001b21565b5b6020026020010151600001518684815181106200066b576200066a62001b21565b5b60200260200101516040015162000c8f60201b60201c565b620006c6565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620006bd9062001be7565b60405180910390fd5b5b5b508080620006d69062001c61565b915050620004b3565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673838383604051620007159392919062001c82565b60405180910390a16200072f828262000e3760201b60201c565b505050565b600090565b600081511162000780576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007779062001d97565b60405180910390fd5b60006200079262000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000806576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007fd9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036200087c576200087b828562000f9860201b60201c565b5b60005b8351811015620009d4576000848281518110620008a157620008a062001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161462000998576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200098f9062001e5f565b60405180910390fd5b620009ac8583868a6200107c60201b60201c565b8380620009b99062001ec3565b94505050508080620009cb9062001c61565b9150506200087f565b5050505050565b600081511162000a22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a199062001d97565b60405180910390fd5b600062000a3462000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000aa8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a9f9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff160362000b1e5762000b1d828562000f9860201b60201c565b5b60005b835181101562000c8857600084828151811062000b435762000b4262001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160362000c39576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000c309062001eef565b60405180910390fd5b62000c4c8582846200122960201b60201c565b62000c608583868a6200107c60201b60201c565b838062000c6d9062001ec3565b9450505050808062000c7f9062001c61565b91505062000b21565b5050505050565b600081511162000cd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000ccd9062001d97565b60405180910390fd5b600062000ce862000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161462000d5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000d539062001f53565b60405180910390fd5b60005b825181101562000e3157600083828151811062000d815762000d8062001b21565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905062000e198482846200122960201b60201c565b5050808062000e289062001c61565b91505062000d5f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16031562000f675762000e988260405180606001604052806028815260200162003c7a60289139620018aa60201b60201c565b6000808373ffffffffffffffffffffffffffffffffffffffff168360405162000ec2919062001fb7565b600060405180830381855af49150503d806000811462000eff576040519150601f19603f3d011682016040523d82523d6000602084013e62000f04565b606091505b50915091508162000f645760008151111562000f235780518082602001fd5b83836040517f192105d700000000000000000000000000000000000000000000000000000000815260040162000f5b92919062001fd7565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b62000fc38160405180606001604052806024815260200162003ca260249139620018aa60201b60201c565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200129b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620012929062002003565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200130c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013039062002067565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050620013e59190620020cb565b9050808214620015805760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000182815481106200144a576200144962001b21565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018481548110620014c957620014c862001b21565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805480620015d757620015d6620020ec565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff0219169055505060008103620018a357600060018660020180549050620016c49190620020cb565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146200180c57600087600201838154811062001732576200173162001b21565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811062001779576200177862001b21565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b86600201805480620018235762001822620020ec565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b9050600081118290620018f9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620018f0919062002102565b60405180910390fd5b50505050565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600060028111156200193e576200193d62001b37565b5b8152602001606081525090565b60008151905060018060a01b03811681146200196657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620019a157808201518184015260208101905062001984565b50600083830152505050565b600080600080600080600080610100898b031215620019cb57600080fd5b620019d6896200194b565b9750620019e660208a016200194b565b9650620019f660408a016200194b565b955062001a0660608a016200194b565b945062001a1660808a016200194b565b935062001a2660a08a016200194b565b925062001a3660c08a016200194b565b915060e089015160018060401b038082111562001a5257600080fd5b818b0191508b601f83011262001a6757600080fd5b81518181111562001a7d5762001a7c6200196b565b5b601f1960405181603f83601f860116011681019150808210848311171562001aaa5762001aa96200196b565b5b816040528281528e602084870101111562001ac457600080fd5b62001ad783602083016020880162001981565b80955050505050509295985092959890939650565b60006020828403121562001aff57600080fd5b815163ffffffff60e01b8116811462001b1757600080fd5b8091505092915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60018060a01b03811682525050565b6000815180845262001b7681602086016020860162001981565b6020601f19601f83011685010191505092915050565b600060018060a01b03808a168352808916602084015280881660408401528087166060840152808616608084015280851660a08401525060e060c083015262001bd960e083018462001b5c565b905098975050505050505050565b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b60008019820362001c775762001c7662001c4b565b5b600182019050919050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101562001d6357607f198a8503018652815188850160018060a01b038251168652848201516003811062001cf157634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b8083101562001d465763ffffffff60e01b84511682528682019150868401935060018301925062001d1a565b508096505050508282019150828601955060018101905062001cab565b505062001d738189018b62001b4d565b50868103604088015262001d88818962001b5c565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b600060018060601b0380831681810362001ee25762001ee162001c4b565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825162001fcb81846020870162001981565b80830191505092915050565b60018060a01b038316815260406020820152600062001ffa604083018462001b5c565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115620020e657620020e562001c4b565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b60208152600062002117602083018462001b5c565b905092915050565b611b4b806200212f6000396000f3fe60806040523661000b57005b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f9050809150600082600001600080357fffffffff00000000000000000000000000000000000000000000000000000000167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610141576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610138906114d3565b60405180910390fd5b3660008037600080366000845af43d6000803e8060008114610162573d6000f35b3d6000fd5b806101706103c0565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b83518110156103755760008482815181106101b2576101b1611510565b5b6020026020010151602001519050600060028111156101d4576101d3611526565b5b8160028111156101e7576101e6611526565b5b036102375761023285838151811061020257610201611510565b5b60200260200101516000015186848151811061022157610220611510565b5b6020026020010151604001516103c5565b610361565b6001600281111561024b5761024a611526565b5b81600281111561025e5761025d611526565b5b036102ae576102a985838151811061027957610278611510565b5b60200260200101516000015186848151811061029857610297611510565b5b60200260200101516040015161063c565b610360565b6002808111156102c1576102c0611526565b5b8160028111156102d4576102d3611526565b5b036103245761031f8583815181106102ef576102ee611510565b5b60200260200101516000015186848151811061030e5761030d611510565b5b6020026020010151604001516108bd565b61035f565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103569061153c565b60405180910390fd5b5b5b50808061036d906115b6565b915050610194565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103a99392919061163b565b60405180910390a16103bb8282610a48565b505050565b600090565b6000815111610409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040090611747565b60405180910390fd5b6000610413610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047b906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036104f1576104f08285610b97565b5b60005b835181101561063557600084828151811061051257610511611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610606576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105fd9061180f565b60405180910390fd5b6106128583868a610c72565b838061061d90611873565b9450505050808061062d906115b6565b9150506104f4565b5050505050565b6000815111610680576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067790611747565b60405180910390fd5b600061068a610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f2906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff1603610768576107678285610b97565b5b60005b83518110156108b657600084828151811061078957610788611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361087c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610873906118a2565b60405180910390fd5b610887858284610e1f565b6108938583868a610c72565b838061089e90611873565b945050505080806108ae906115b6565b91505061076b565b5050505050565b6000815111610901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f890611747565b60405180910390fd5b600061090b610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461097c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097390611906565b60405180910390fd5b60005b8251811015610a4257600083828151811061099d5761099c611510565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610a2d848284610e1f565b50508080610a3a906115b6565b91505061097f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160315610b6657610a9f82604051806060016040528060288152602001611aca60289139611481565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610ac7919061196a565b600060405180830381855af49150503d8060008114610b02576040519150601f19603f3d011682016040523d82523d6000602084013e610b07565b606091505b509150915081610b6357600081511115610b245780518082602001fd5b83836040517f192105d7000000000000000000000000000000000000000000000000000000008152600401610b5a929190611988565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b610bb981604051806060016040528060248152602001611af260249139611481565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610e8e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e85906119b2565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610efc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef390611a16565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050610fd39190611a7a565b90508082146111675760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001828154811061103457611033611510565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000184815481106110b0576110af611510565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054806111bb576111ba611a98565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff021916905550506000810361147a576000600186600201805490506112a59190611a7a565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146113e657600087600201838154811061130f5761130e611510565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811061135357611352611510565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b866002018054806113fa576113f9611a98565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b90506000811182906114cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c49190611aae565b60405180910390fd5b50505050565b602081526020808201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460408201526000606082019050919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b6000801982036115c9576115c86115a0565b5b600182019050919050565b60018060a01b03811682525050565b60005b838110156116015780820151818401526020810190506115e6565b50600083830152505050565b600081518084526116258160208601602086016115e3565b6020601f19601f83011685010191505092915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101561171757607f198a8503018652815188850160018060a01b03825116865284820151600381106116a857634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b808310156116fb5763ffffffff60e01b8451168252868201915086840193506001830192506116d1565b5080965050505082820191508286019550600181019050611664565b50506117258189018b6115d4565b508681036040880152611738818961160d565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b60006bffffffffffffffffffffffff808316818103611895576118946115a0565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825161197c8184602087016115e3565b80830191505092915050565b60018060a01b03831681526040602082015260006119a9604083018461160d565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115611a9257611a916115a0565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b602081526000611ac1602083018461160d565b90509291505056fe4c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465a264697066735822122045b771fb2128a1a34c5b052e9a86464933844b34929cf0d65bbea6a4e76e3b2764736f6c634300081200334c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465" owner = Barz.ContractOwner.newBuilder().apply { - attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158a4f95bc73828ee210f9fd3bbe72d97908013b0a3759e9aea3d0ae318766cd2e1ad4500000000adce000235bcc60a648b0b25f1f055030020c720eb493e167ce93183dd91f5661e1004ed8cc1be23d3340d92381da5c0c80ca5010203262001215820a620a8cfc88fd062b11eab31663e56cad95278bef612959be214d98779f645b82258204e7b905b42917570148b0432f99ba21f2e7eebe018cbf837247e38150a89f771" + attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d000000000000000000000000000000000000000000147d0d9cf0634ebd79b5df0c91c7de42c567aac588a50102032620012158207868c62a834763bae747bd9db14d9d159ccd1052a8f81287e3f039c5c9c0f91e225820000e4fc74a22560d3bd22866c6b9fe88c10c170be073d2a838c8019586a7a4eb" }.build() } val result = WCBarz.getCounterfactualAddress(input.build().toByteArray()) - assertEquals(result, "0xc3d477e5D4CEd32835574bBAFE51a0A8c9c17272") + assertEquals(result, "0x85a6290917d1DC2C507Ff2D545Ba5aF13e964Ba1") + } + + // https://testnet.bscscan.com/tx/0x43fc13dfdf06bbb09da8ce070953753764f1e43782d0c8b621946d8b45749419 + @Test + fun testSignK1TransferAccountDeployed() { + val signingInput = Ethereum.SigningInput.newBuilder() + signingInput.apply { + privateKey = ByteString.copyFrom(PrivateKey("3c90badc15c4d35733769093d3733501e92e7f16e101df284cee9a310d36c483".toHexByteArray()).data()) + chainId = ByteString.copyFrom("0x61".toHexByteArray()) + nonce = ByteString.copyFrom("0x2".toHexByteArray()) + toAddress = "0x61061fCAE11fD5461535e134EfF67A98CFFF44E9" + txMode = TransactionMode.UserOp + + gasLimit = ByteString.copyFrom("0x0186A0".toHexByteArray()) + maxFeePerGas = ByteString.copyFrom("0x01a339c9e9".toHexByteArray()) + maxInclusionFeePerGas = ByteString.copyFrom("0x01a339c9e9".toHexByteArray()) + + userOperation = Ethereum.UserOperation.newBuilder().apply { + entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + sender = "0xb16Db98B365B1f89191996942612B14F1Da4Bd5f" + preVerificationGas = ByteString.copyFrom("0xb708".toHexByteArray()) + verificationGasLimit = ByteString.copyFrom("0x0186a0".toHexByteArray()) + }.build() + + transaction = Ethereum.Transaction.newBuilder().apply { + transfer = Ethereum.Transaction.Transfer.newBuilder().apply { + amount = ByteString.copyFrom("0x2386f26fc10000".toHexByteArray()) + }.build() + }.build() + } + + val output = AnySigner.sign(signingInput.build(), ETHEREUM, SigningOutput.parser()) + + assertEquals(Numeric.toHexString(output.preHash.toByteArray()), "0x731dd74cbf212bee883c6decbad07ad8980be89ca2e6c64de310af04e562d866"); + + assertEquals(output.encoded.toStringUtf8(), "{\"callData\":\"0xb61d27f600000000000000000000000061061fcae11fd5461535e134eff67a98cfff44e9000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"100000\",\"initCode\":\"0x\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"7033440745\",\"nonce\":\"2\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0xb16db98b365b1f89191996942612b14f1da4bd5f\",\"signature\":\"0x3d29240a2decf2a1f47c88d1cb5923815ed50d24f8f01a9697e229ba69ce18d13779d2d96a5c93f5df29110677de62e75f4d751ab7baf5830276eb4ca257fb471b\",\"verificationGasLimit\":\"100000\"}"); + } + + // https://testnet.bscscan.com/tx/0xea1f5cddc0653e116327cbcb3bc770360a642891176eff2ec69c227e46791c31 + @Test + fun testSignR1TransferAccountNotDeployed() { + val factoryAddress = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800" + val attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d00000000000000000000000000000000000000000014c14f8a2dfd8f451581fad6e4e1c11821abcaacd6a5010203262001215820b173a6a812025c40c38bac46343646bd0a8137c807aae6e04aac238cc24d2ad2225820116ca14d23d357588ff2aabd7db29d5976f4ecc8037775db86f67e873a306b1f" + val verificationFacet = "0x5034534Efe9902779eD6eA6983F435c00f3bc510" + + val signingInput = Ethereum.SigningInput.newBuilder() + signingInput.apply { + privateKey = ByteString.copyFrom(PrivateKey("3c90badc15c4d35733769093d3733501e92e7f16e101df284cee9a310d36c483".toHexByteArray()).data()) + chainId = ByteString.copyFrom("0x61".toHexByteArray()) + nonce = ByteString.copyFrom("0x00".toHexByteArray()) + toAddress = "0x61061fCAE11fD5461535e134EfF67A98CFFF44E9" + txMode = TransactionMode.UserOp + + gasLimit = ByteString.copyFrom("0x2625A0".toHexByteArray()) + maxFeePerGas = ByteString.copyFrom("0x01a339c9e9".toHexByteArray()) + maxInclusionFeePerGas = ByteString.copyFrom("0x01a339c9e9".toHexByteArray()) + + userOperation = Ethereum.UserOperation.newBuilder().apply { + entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + sender = "0x1392Ae041BfBdBAA0cFF9234a0C8F64df97B7218" + preVerificationGas = ByteString.copyFrom("0xb708".toHexByteArray()) + verificationGasLimit = ByteString.copyFrom("0x2DC6C0".toHexByteArray()) + initCode = ByteString.copyFrom(WCBarz.getInitCodeFromAttestationObject(factoryAddress, attestationObject, verificationFacet)) + }.build() + + transaction = Ethereum.Transaction.newBuilder().apply { + transfer = Ethereum.Transaction.Transfer.newBuilder().apply { + amount = ByteString.copyFrom("0x2386f26fc10000".toHexByteArray()) + }.build() + }.build() + } + + val output = AnySigner.sign(signingInput.build(), ETHEREUM, SigningOutput.parser()) + + assertEquals(Numeric.toHexString(output.preHash.toByteArray()), "0xb884c13821af6794e2fed1f5906f847251123adde02bd84723b50eda24fe2c93"); + + assertEquals(output.encoded.toStringUtf8(), "{\"callData\":\"0xb61d27f600000000000000000000000061061fcae11fd5461535e134eff67a98cfff44e9000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"2500000\",\"initCode\":\"0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000005034534efe9902779ed6ea6983f435c00f3bc510000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040b173a6a812025c40c38bac46343646bd0a8137c807aae6e04aac238cc24d2ad2116ca14d23d357588ff2aabd7db29d5976f4ecc8037775db86f67e873a306b1f\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"7033440745\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0x1392ae041bfbdbaa0cff9234a0c8f64df97b7218\",\"signature\":\"0x670d22e5361a75add1a90f2e86abf23a7e7b860795ca882e33efad17f0c6ff9a5c8e25260c89f1dd2aafba56ba0efdaec6cd976df399f848f443876fdb64867e1c\",\"verificationGasLimit\":\"3000000\"}"); } } diff --git a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumAddress.kt b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumAddress.kt index 9c3ec88fd7d..86f725fdd2e 100644 --- a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumAddress.kt +++ b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumAddress.kt @@ -23,13 +23,4 @@ class TestEthereumAddress { assertFalse(AnyAddress.isValid("0xMQqpqMQgCBuiPkoXfgZZsJvuzCeI1zc00z6vHJj4", CoinType.ETHEREUM)) } - - @Test - fun testEthereumEIP4337DeploymentAddress() { - val factoryAddress = "0xd9145CCE52D386f254917e481eB44e9943F39138" - val logicAddress = "0x5C9eb5D6a6C2c1B3EFc52255C0b356f116f6f66D" - val ownerAddress = "0xA5a1dddEF094095AfB7b6e322dE72961DF2e1988" - val result = Ethereum.eip4337GetDeploymentAddress(factoryAddress, logicAddress, ownerAddress) - assertEquals(result, "0xbEaA87cEEaC906C21aaacd258FbFB87CfA3c90a8") - } } diff --git a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumTransactionSigner.kt b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumTransactionSigner.kt index ed4c5a3d88f..61a6b9a42df 100644 --- a/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumTransactionSigner.kt +++ b/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumTransactionSigner.kt @@ -229,235 +229,4 @@ class TestEthereumTransactionSigner { assertEquals("f86a8084d693a400825208947d8bf18c7ce84b3e175b339c4ca93aed1dd166f1870348bca5a160008025a0fe5802b49e04c6b1705088310e133605ed8b549811a18968ad409ea02ad79f21a05bf845646fb1e1b9365f63a7fd5eb5e984094e3ed35c3bed7361aebbcbf41f10", result) } - - // EIP4337 - @Test - fun testEIP4337TransactionSigningAccountNotDeployed() { - val signingInput = Ethereum.SigningInput.newBuilder() - signingInput.apply { - privateKey = ByteString.copyFrom(PrivateKey("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8".toHexByteArray()).data()) - chainId = ByteString.copyFrom("0x5".toHexByteArray()) - nonce = ByteString.copyFrom("0x0".toHexByteArray()) - toAddress = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - txMode = TransactionMode.UserOp - - gasLimit = ByteString.copyFrom("0x5580".toHexByteArray()) - maxFeePerGas = ByteString.copyFrom("0x01952f1f85".toHexByteArray()) - maxInclusionFeePerGas = ByteString.copyFrom("0x0f".toHexByteArray()) - - userOperation = Ethereum.UserOperation.newBuilder().apply { - entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - isAccountDeployed = false - - preVerificationGas = ByteString.copyFrom("0xbc18".toHexByteArray()) - verificationGasLimit = ByteString.copyFrom("0x073272".toHexByteArray()) - }.build() - - transaction = Ethereum.Transaction.newBuilder().apply { - transfer = Ethereum.Transaction.Transfer.newBuilder().apply { - amount = ByteString.copyFrom("0x2386f26fc10000".toHexByteArray()) - }.build() - }.build() - } - - val output = AnySigner.sign(signingInput.build(), ETHEREUM, SigningOutput.parser()) - - assertEquals(output.encoded.toStringUtf8(), "{\"callData\":\"0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"21888\",\"initCode\":\"0x5a87209b755781cf65feeedd3855ade0317f4a925fbfb9cf00000000000000000000000078d9c32b96bb872d66d51818227563f44e67e2380000000000000000000000000000000000000000000000000000000000000000\",\"maxFeePerGas\":\"6797860741\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"48152\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x1560b19d17613ec8580cb0feaf7ac2953771404c5bd7830f585e5062e6ddd4b82ae3bb8dbddb659c0300e8009857b5c77501e1cfd5bbab48d03de0ea7207d07c1b\",\"verificationGasLimit\":\"471666\"}"); - } - - @Test - fun testEIP4337TransactionSigningAccountDeployed() { - val signingInput = Ethereum.SigningInput.newBuilder() - signingInput.apply { - privateKey = ByteString.copyFrom(PrivateKey("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8".toHexByteArray()).data()) - chainId = ByteString.copyFrom("0x5".toHexByteArray()) - nonce = ByteString.copyFrom("0x1".toHexByteArray()) - - toAddress = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - txMode = TransactionMode.UserOp - - gasLimit = ByteString.copyFrom("0x9d55".toHexByteArray()) - maxFeePerGas = ByteString.copyFrom("0x1a339c9e9".toHexByteArray()) - maxInclusionFeePerGas = ByteString.copyFrom("0x0f".toHexByteArray()) - - userOperation = Ethereum.UserOperation.newBuilder().apply { - entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - isAccountDeployed = true - - preVerificationGas = ByteString.copyFrom("0xb708".toHexByteArray()) - verificationGasLimit = ByteString.copyFrom("0x186a0".toHexByteArray()) - }.build() - - transaction = Ethereum.Transaction.newBuilder().apply { - transfer = Ethereum.Transaction.Transfer.newBuilder().apply { - amount = ByteString.copyFrom("0x2386f26fc10000".toHexByteArray()) - }.build() - }.build() - } - - val output = AnySigner.sign(signingInput.build(), ETHEREUM, SigningOutput.parser()) - - assertEquals(output.encoded.toStringUtf8(), "{\"callData\":\"0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"40277\",\"initCode\":\"0x\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"1\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0xaed2011e5cf267de495b38ecf86ad6f1d4c05217a99e59f47e8d52ba3d41c10144785893fa3e7c116a054999e3902fc2771064d0545148bc49f6d7c827fc7a9a1c\",\"verificationGasLimit\":\"100000\"}"); - } - - @Test - fun testEIP4337ERC20TransferAccountDeployed() { - val signingInput = Ethereum.SigningInput.newBuilder() - signingInput.apply { - privateKey = ByteString.copyFrom(PrivateKey("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8".toHexByteArray()).data()) - chainId = ByteString.copyFrom("0x5".toHexByteArray()) - nonce = ByteString.copyFrom("0x6".toHexByteArray()) - toAddress = "0x98339d8c260052b7ad81c28c16c0b98420f2b46a" - txMode = TransactionMode.UserOp - - gasLimit = ByteString.copyFrom("0xf78e".toHexByteArray()) - maxFeePerGas = ByteString.copyFrom("0x168ad5950f".toHexByteArray()) - maxInclusionFeePerGas = ByteString.copyFrom("0x0f".toHexByteArray()) - - userOperation = Ethereum.UserOperation.newBuilder().apply { - entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - isAccountDeployed = true - - preVerificationGas = ByteString.copyFrom("0xbb10".toHexByteArray()) - verificationGasLimit = ByteString.copyFrom("0x186a0".toHexByteArray()) - }.build() - - transaction = Ethereum.Transaction.newBuilder().apply { - erc20Transfer = Ethereum.Transaction.ERC20Transfer.newBuilder().apply { - amount = ByteString.copyFrom("0x186a0".toHexByteArray()) - to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - }.build() - }.build() - } - - val output = AnySigner.sign(signingInput.build(), ETHEREUM, SigningOutput.parser()) - - assertEquals(output.encoded.toStringUtf8(), "{\"callData\":\"0xb61d27f600000000000000000000000098339d8c260052b7ad81c28c16c0b98420f2b46a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"63374\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"6\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"47888\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0xd006c93d6a8753b5e7c1e6349de0dea34eab2e7a533106e0f2e1a3a3b013c8e97b007546dab9d7b8fc471ad14ff2e8aa351dc4f1ecb63bf20f33858dc7366cbe1c\",\"verificationGasLimit\":\"100000\"}"); - } - - @Test - fun testEIP4337ERC20ApproveAccountDeployed() { - val signingInput = Ethereum.SigningInput.newBuilder() - signingInput.apply { - privateKey = ByteString.copyFrom(PrivateKey("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8".toHexByteArray()).data()) - chainId = ByteString.copyFrom("0x5".toHexByteArray()) - nonce = ByteString.copyFrom("0x9".toHexByteArray()) - - toAddress = "0x98339d8c260052b7ad81c28c16c0b98420f2b46a" - txMode = TransactionMode.UserOp - - gasLimit = ByteString.copyFrom("0xf78e".toHexByteArray()) - maxFeePerGas = ByteString.copyFrom("0x168ad5950f".toHexByteArray()) - maxInclusionFeePerGas = ByteString.copyFrom("0x0f".toHexByteArray()) - - userOperation = Ethereum.UserOperation.newBuilder().apply { - entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - isAccountDeployed = true - - preVerificationGas = ByteString.copyFrom("0xbb10".toHexByteArray()) - verificationGasLimit = ByteString.copyFrom("0x186a0".toHexByteArray()) - }.build() - - transaction = Ethereum.Transaction.newBuilder().apply { - erc20Approve = Ethereum.Transaction.ERC20Approve.newBuilder().apply { - amount = ByteString.copyFrom("0x186a0".toHexByteArray()) - spender = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - }.build() - }.build() - } - - val output = AnySigner.sign(signingInput.build(), ETHEREUM, SigningOutput.parser()) - - assertEquals(output.encoded.toStringUtf8(), "{\"callData\":\"0xb61d27f600000000000000000000000098339d8c260052b7ad81c28c16c0b98420f2b46a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"63374\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"9\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"47888\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x262a67dd8cf3d16a72b7809b3b5ed55e9f4c2b93eedd5a3c6be035fbbd7111164464ec933d0fdfa359e266e318f3ac22702ae428ce14fc142e4475603e6ec15e1c\",\"verificationGasLimit\":\"100000\"}"); - } - - @Test - fun testEIP4337ERC721TransferAccountDeployed() { - val signingInput = Ethereum.SigningInput.newBuilder() - signingInput.apply { - privateKey = ByteString.copyFrom(PrivateKey("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8".toHexByteArray()).data()) - chainId = ByteString.copyFrom("0x5".toHexByteArray()) - nonce = ByteString.copyFrom("0xc".toHexByteArray()) - toAddress = "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b" - txMode = TransactionMode.UserOp - - gasLimit = ByteString.copyFrom("0x60B378".toHexByteArray()) - maxFeePerGas = ByteString.copyFrom("0x168ad5950f".toHexByteArray()) - maxInclusionFeePerGas = ByteString.copyFrom("0x0f".toHexByteArray()) - - userOperation = Ethereum.UserOperation.newBuilder().apply { - entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - isAccountDeployed = true - - preVerificationGas = ByteString.copyFrom("0xC34F".toHexByteArray()) - verificationGasLimit = ByteString.copyFrom("0x16E360".toHexByteArray()) - }.build() - - transaction = Ethereum.Transaction.newBuilder().apply { - erc721Transfer = Ethereum.Transaction.ERC721Transfer.newBuilder().apply { - tokenId = ByteString.copyFrom("0x2A8E57".toHexByteArray()) - from = "0x8cE23B8769ac01d0df0d5f47Be1A38FeA97F3879" - to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - }.build() - }.build() - } - - val output = AnySigner.sign(signingInput.build(), ETHEREUM, SigningOutput.parser()) - - assertEquals(output.encoded.toStringUtf8(), "{\"callData\":\"0xb61d27f6000000000000000000000000f5de760f2e916647fd766b4ad9e85ff943ce3a2b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006423b872dd0000000000000000000000008ce23b8769ac01d0df0d5f47be1a38fea97f3879000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000002a8e5700000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"6337400\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"12\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"49999\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x5951cc161a4d60d6b59503efb93e446f5d1a2e3a41d4503ba6393bcf2a2637340d0a865ed5d4d7650a68cbb95915eaa7ed54fd2c42b4bf7c83376f5c5d70691d1b\",\"verificationGasLimit\":\"1500000\"}"); - } - - @Test - fun testEIP4337ERC1155TransferAccountDeployed() { - val signingInput = Ethereum.SigningInput.newBuilder() - signingInput.apply { - privateKey = ByteString.copyFrom(PrivateKey("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8".toHexByteArray()).data()) - chainId = ByteString.copyFrom("0x5".toHexByteArray()) - nonce = ByteString.copyFrom("0x0".toHexByteArray()) - toAddress = "0x428ce4b916332e1afccfddce08baecc97cb40b12" - txMode = TransactionMode.UserOp - - gasLimit = ByteString.copyFrom("0x60B378".toHexByteArray()) - maxFeePerGas = ByteString.copyFrom("0x168ad5950f".toHexByteArray()) - maxInclusionFeePerGas = ByteString.copyFrom("0x0f".toHexByteArray()) - - userOperation = Ethereum.UserOperation.newBuilder().apply { - entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - accountFactory = "0x76627b8D1E01fAF0C73B69625BC1fCb8FA19a2AD" - accountLogic = "0x510ab68bd111ce7115df797118b0334d727d564b" - owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - isAccountDeployed = true - - preVerificationGas = ByteString.copyFrom("0xC738".toHexByteArray()) - verificationGasLimit = ByteString.copyFrom("0x16E360".toHexByteArray()) - }.build() - - transaction = Ethereum.Transaction.newBuilder().apply { - erc1155Transfer = Ethereum.Transaction.ERC1155Transfer.newBuilder().apply { - tokenId = ByteString.copyFrom("0x01".toHexByteArray()) - from = "0x8c560E00680b973645900528EDe71a99b8d4dca8" - to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - }.build() - }.build() - } - - val output = AnySigner.sign(signingInput.build(), ETHEREUM, SigningOutput.parser()) - - assertEquals(output.encoded.toStringUtf8(), "{\"callData\":\"0xb61d27f6000000000000000000000000428ce4b916332e1afccfddce08baecc97cb40b120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c4f242432a0000000000000000000000008c560e00680b973645900528ede71a99b8d4dca8000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"6337400\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"51000\",\"sender\":\"0x8c560e00680b973645900528ede71a99b8d4dca8\",\"signature\":\"0xaae38bcf9f946921541b44c2a66596968beecb9420471e2c9c531f758a2d652930ffdeeab95742e57e8520fb5c8ca4fee6a8e47e37336d4201fe104103f85e111c\",\"verificationGasLimit\":\"1500000\"}"); - } } diff --git a/codegen/lib/templates/jni/parameter_access.erb b/codegen/lib/templates/jni/parameter_access.erb index 71bc2641c41..4c3ceb9f2fa 100644 --- a/codegen/lib/templates/jni/parameter_access.erb +++ b/codegen/lib/templates/jni/parameter_access.erb @@ -1,6 +1,6 @@ <% method = locals[:method] - if method.static && !method.name.include?('Init') + if method.static && !method.name.start_with?('Init') parameters = method.parameters else parameters = method.parameters.drop(1) diff --git a/codegen/lib/templates/jni/parameter_release.erb b/codegen/lib/templates/jni/parameter_release.erb index 147e40c3496..1db6f1a86e1 100644 --- a/codegen/lib/templates/jni/parameter_release.erb +++ b/codegen/lib/templates/jni/parameter_release.erb @@ -1,6 +1,6 @@ <% method = locals[:method] - if method.static && !method.name.include?('Init') + if method.static && !method.name.start_with?('Init') parameters = method.parameters else parameters = method.parameters.drop(1) diff --git a/codegen/lib/templates/kotlin_jni/parameter_access.erb b/codegen/lib/templates/kotlin_jni/parameter_access.erb index 8022686514b..a5dcae13aa1 100644 --- a/codegen/lib/templates/kotlin_jni/parameter_access.erb +++ b/codegen/lib/templates/kotlin_jni/parameter_access.erb @@ -1,6 +1,6 @@ <% method = locals[:method] - if method.static && !method.name.include?('Init') + if method.static && !method.name.start_with?('Init') parameters = method.parameters else parameters = method.parameters.drop(1) diff --git a/codegen/lib/templates/kotlin_jni/parameter_release.erb b/codegen/lib/templates/kotlin_jni/parameter_release.erb index 147e40c3496..1db6f1a86e1 100644 --- a/codegen/lib/templates/kotlin_jni/parameter_release.erb +++ b/codegen/lib/templates/kotlin_jni/parameter_release.erb @@ -1,6 +1,6 @@ <% method = locals[:method] - if method.static && !method.name.include?('Init') + if method.static && !method.name.start_with?('Init') parameters = method.parameters else parameters = method.parameters.drop(1) diff --git a/include/TrustWalletCore/TWBarz.h b/include/TrustWalletCore/TWBarz.h index adc3cb60839..77971329725 100644 --- a/include/TrustWalletCore/TWBarz.h +++ b/include/TrustWalletCore/TWBarz.h @@ -22,4 +22,22 @@ struct TWBarz; TW_EXPORT_STATIC_METHOD TWString *_Nonnull TWBarzGetCounterfactualAddress(TWData *_Nonnull input); +/// Returns the init code parameter of ERC-4337 User Operation +/// +/// \param factory Wallet factory address (BarzFactory) +/// \param publicKey Public key for the verification facet +/// \param verificationFacet Verification facet address +/// \return The address. +TW_EXPORT_STATIC_METHOD +TWData *_Nonnull TWBarzGetInitCodeFromPublicKey(TWString* _Nonnull factory, TWString* _Nonnull publicKey, TWString* _Nonnull verificationFacet); + +/// Returns the init code parameter of ERC-4337 User Operation +/// +/// \param factory Wallet factory address (BarzFactory) +/// \param attestationObject Attestation object from created webauthn credentials +/// \param verificationFacet Verification facet address +/// \return The address. +TW_EXPORT_STATIC_METHOD +TWData *_Nonnull TWBarzGetInitCodeFromAttestationObject(TWString* _Nonnull factory, TWString* _Nonnull attestationObject, TWString* _Nonnull verificationFacet); + TW_EXTERN_C_END diff --git a/include/TrustWalletCore/TWEthereum.h b/include/TrustWalletCore/TWEthereum.h index b65a9281a97..20007e4aaff 100644 --- a/include/TrustWalletCore/TWEthereum.h +++ b/include/TrustWalletCore/TWEthereum.h @@ -25,12 +25,4 @@ struct TWEthereum; TW_EXPORT_STATIC_METHOD TWString* _Nonnull TWEthereumEip2645GetPath(TWString* _Nonnull ethAddress, TWString* _Nonnull layer, TWString* _Nonnull application, TWString* _Nonnull index); -/// Generates a deployment address for a ERC-4337 compatible smart contract wallet -/// -/// \param factoryAddress non-null address of the account factory -/// \param logicAddress non-null address of the wallet's logic smart contract -/// \param ownerAddress non-null address of the signing key that controls the smart contract wallet -/// \return Ethereum resulting address -TW_EXPORT_STATIC_METHOD -TWString* _Nonnull TWEthereumEip4337GetDeploymentAddress(TWString* _Nonnull factoryAddress, TWString* _Nonnull logicAddress, TWString* _Nonnull ownerAddress); TW_EXTERN_C_END diff --git a/samples/kmp/shared/build.gradle.kts b/samples/kmp/shared/build.gradle.kts index 48e26d33e84..a2a4c941831 100644 --- a/samples/kmp/shared/build.gradle.kts +++ b/samples/kmp/shared/build.gradle.kts @@ -31,11 +31,11 @@ kotlin { baseName = "shared" } } - + sourceSets { val commonMain by getting { dependencies { - implementation("com.trustwallet:wallet-core-kotlin:3.1.31") + implementation("com.trustwallet:wallet-core-kotlin:3.1.36") } } val commonTest by getting { diff --git a/src/Ethereum/Barz.cpp b/src/Ethereum/Barz.cpp index 95bfed2c0bf..eab3fe60fe6 100644 --- a/src/Ethereum/Barz.cpp +++ b/src/Ethereum/Barz.cpp @@ -14,31 +14,32 @@ namespace TW::Barz { -using ParamBasePtr = std::shared_ptr; +using ParamBasePtr = std::shared_ptr; using ParamCollection = std::vector; -std::string getCounterfactualAddress(const TW::Barz::Proto::ContractAddressInput input) { - auto params = TW::Ethereum::ABI::ParamTuple(); - params.addParam(std::make_shared(parse_hex(input.diamond_cut_facet()))); - params.addParam(std::make_shared(parse_hex(input.account_facet()))); - params.addParam(std::make_shared(parse_hex(input.verification_facet()))); - params.addParam(std::make_shared(parse_hex(input.entry_point()))); - params.addParam(std::make_shared(parse_hex(input.security_manager()))); - params.addParam(std::make_shared(parse_hex(input.facet_registry()))); +std::string getCounterfactualAddress(const Proto::ContractAddressInput input) { + auto params = Ethereum::ABI::ParamTuple(); + params.addParam(std::make_shared(parse_hex(input.diamond_cut_facet()))); + params.addParam(std::make_shared(parse_hex(input.account_facet()))); + params.addParam(std::make_shared(parse_hex(input.verification_facet()))); + params.addParam(std::make_shared(parse_hex(input.entry_point()))); + params.addParam(std::make_shared(parse_hex(input.diamond_loupe_facet()))); + params.addParam(std::make_shared(parse_hex(input.diamond_init()))); + params.addParam(std::make_shared(parse_hex(input.facet_registry()))); Data publicKey; switch (input.owner().kind_case()) { - case TW::Barz::Proto::ContractOwner::KindCase::KIND_NOT_SET: + case Proto::ContractOwner::KindCase::KIND_NOT_SET: return ""; - case TW::Barz::Proto::ContractOwner::KindCase::kPublicKey: + case Proto::ContractOwner::KindCase::kPublicKey: publicKey = parse_hex(input.owner().public_key()); break; - case TW::Barz::Proto::ContractOwner::KindCase::kAttestationObject: + case Proto::ContractOwner::KindCase::kAttestationObject: const auto attestationObject = parse_hex(input.owner().attestation_object()); - publicKey = subData(TW::WebAuthn::getPublicKey(attestationObject)->bytes, 1); // Drop the first byte which corresponds to the public key type + publicKey = subData(WebAuthn::getPublicKey(attestationObject)->bytes, 1); // Drop the first byte which corresponds to the public key type break; } - params.addParam(std::make_shared(publicKey)); + params.addParam(std::make_shared(publicKey)); Data encoded; params.encode(encoded); @@ -48,7 +49,26 @@ std::string getCounterfactualAddress(const TW::Barz::Proto::ContractAddressInput const Data initCodeHash = Hash::keccak256(initCode); const Data salt(32, 0); - return Ethereum::checksumed(TW::Ethereum::Address(hexEncoded(TW::Ethereum::create2Address(input.factory(), salt, initCodeHash)))); + return Ethereum::checksumed(Ethereum::Address(hexEncoded(Ethereum::create2Address(input.factory(), salt, initCodeHash)))); +} + +Data getInitCodeFromPublicKey(const std::string& factoryAddress, const std::string& publicKey, const std::string& verificationFacet) { + auto createAccountFunc = Ethereum::ABI::Function("createAccount", ParamCollection{ + std::make_shared(parse_hex(verificationFacet)), + std::make_shared(parse_hex(publicKey)), + std::make_shared(0)}); + Data createAccountFuncEncoded; + createAccountFunc.encode(createAccountFuncEncoded); + + Data envelope; + append(envelope, parse_hex(factoryAddress)); + append(envelope, createAccountFuncEncoded); + return envelope; +} + +Data getInitCodeFromAttestationObject(const std::string& factoryAddress, const std::string& attestationObject, const std::string& verificationFacet) { + const auto publicKey = subData(WebAuthn::getPublicKey(parse_hex(attestationObject))->bytes, 1); + return getInitCodeFromPublicKey(factoryAddress, hexEncoded(publicKey), verificationFacet); } } // namespace TW::Barz diff --git a/src/Ethereum/Barz.h b/src/Ethereum/Barz.h index 86ca3277407..8c4d331cf97 100644 --- a/src/Ethereum/Barz.h +++ b/src/Ethereum/Barz.h @@ -12,6 +12,7 @@ namespace TW::Barz { -std::string getCounterfactualAddress(const TW::Barz::Proto::ContractAddressInput input); - +std::string getCounterfactualAddress(const Proto::ContractAddressInput input); +Data getInitCodeFromPublicKey(const std::string& factoryAddress, const std::string& owner, const std::string& verificationFacet); +Data getInitCodeFromAttestationObject(const std::string& factoryAddress, const std::string& attestationObject, const std::string& verificationFacet); } diff --git a/src/Ethereum/EIP4337.cpp b/src/Ethereum/EIP4337.cpp deleted file mode 100644 index f80e9d59c27..00000000000 --- a/src/Ethereum/EIP4337.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright © 2017-2023 Trust Wallet. -// -// This file is part of Trust. The full Trust copyright notice, including -// terms governing use, modification, and redistribution, is contained in the -// file LICENSE at the root of the source code distribution tree. - -#include "ABI.h" -#include "AddressChecksum.h" -#include "EIP1014.h" -#include "EIP1967.h" -#include "Hash.h" -#include "HexCoding.h" -#include - -namespace TW::Ethereum { - -using ParamBasePtr = std::shared_ptr; -using ParamCollection = std::vector; - -// https://github.com/thomas-waite/bundler/blob/b083680059a52d3121c5e33cea67c86652370562/packages/sdk/src/SimpleAccountAPI.ts#L63-L75 -Data getEIP4337AccountInitializeBytecode(const std::string& ownerAddress, const std::string& factoryAddress) { - auto createAccountFunc = ABI::Function("createAccount", ParamCollection{ - std::make_shared(parse_hex(ownerAddress)), - std::make_shared(0)}); - Data createAccountFuncEncoded; - createAccountFunc.encode(createAccountFuncEncoded); - - Data envelope; - append(envelope, parse_hex(factoryAddress)); - append(envelope, createAccountFuncEncoded); - return envelope; -} - -// https://github.com/eth-infinitism/account-abstraction/blob/5a1ad4072438d9e9f7c934b66464dc05a4b37d02/contracts/samples/SimpleAccountFactory.sol#L48 -Data getEIP4337LogicInitializeBytecode(const std::string& ownerAddress) { - auto initializeFunc = ABI::Function("initialize", ParamCollection{ - std::make_shared(parse_hex(ownerAddress))}); - Data initializeFuncEncoded; - initializeFunc.encode(initializeFuncEncoded); - return initializeFuncEncoded; -} - -// https://github.com/thomas-waite/bundler/blob/b083680059a52d3121c5e33cea67c86652370562/packages/sdk/src/SimpleAccountAPI.ts#L91-L100 -Data getEIP4337ExecuteBytecode(const Data& toAddress, const uint256_t& value, const Data& data) { - auto executeFunc = ABI::Function("execute", ParamCollection{ - std::make_shared(toAddress), - std::make_shared(value), - std::make_shared(data)}); - Data executeFuncEncoded; - executeFunc.encode(executeFuncEncoded); - return executeFuncEncoded; -} - -// https://github.com/eth-infinitism/account-abstraction/blob/5a1ad4072438d9e9f7c934b66464dc05a4b37d02/contracts/samples/SimpleAccountFactory.sol#L43-L51 -std::string getEIP4337DeploymentAddress(const std::string& factoryAddress, const std::string& logicAddress, const std::string& ownerAddress) { - const Data logicInitializeBytecode = getEIP4337LogicInitializeBytecode(ownerAddress); - const Data proxyInitCode = getEIP1967ProxyInitCode(logicAddress, logicInitializeBytecode); - const Data salt = parse_hex("0x0000000000000000000000000000000000000000000000000000000000000000"); - const Data initCodeHash = Hash::keccak256(proxyInitCode); - return Ethereum::checksumed(Address(hexEncoded(create2Address(factoryAddress, salt, initCodeHash)))); -} - -} // namespace TW::Ethereum diff --git a/src/Ethereum/EIP4337.h b/src/Ethereum/EIP4337.h deleted file mode 100644 index a72ca4eec55..00000000000 --- a/src/Ethereum/EIP4337.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright © 2017-2023 Trust Wallet. -// -// This file is part of Trust. The full Trust copyright notice, including -// terms governing use, modification, and redistribution, is contained in the -// file LICENSE at the root of the source code distribution tree. - -#pragma once - -#include "Data.h" -#include "uint256.h" - -namespace TW::Ethereum { - -std::string getEIP4337DeploymentAddress(const std::string& factoryAddress, const std::string& logicAddress, const std::string& ownerAddress); - -Data getEIP4337AccountInitializeBytecode(const std::string& ownerAddress, const std::string& factoryAddress); -Data getEIP4337LogicInitializeBytecode(const std::string& ownerAddress); -Data getEIP4337ExecuteBytecode(const Data& toAddress, const uint256_t& value, const Data& data); - -} diff --git a/src/Ethereum/ERC4337.cpp b/src/Ethereum/ERC4337.cpp new file mode 100644 index 00000000000..74505f8e88b --- /dev/null +++ b/src/Ethereum/ERC4337.cpp @@ -0,0 +1,32 @@ +// Copyright © 2017-2023 Trust Wallet. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#include "ABI.h" +#include "AddressChecksum.h" +#include "EIP1014.h" +#include "EIP1967.h" +#include "Hash.h" +#include "HexCoding.h" +#include + +namespace TW::Ethereum { + +using ParamBasePtr = std::shared_ptr; +using ParamCollection = std::vector; + +// https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleAccount.sol#L57 +Data getERC4337ExecuteBytecode(const Data& toAddress, const uint256_t& value, const Data& data) { + auto executeFunc = ABI::Function("execute", ParamCollection{ + std::make_shared(toAddress), + std::make_shared(value), + std::make_shared(data)}); + Data executeFuncEncoded; + executeFunc.encode(executeFuncEncoded); + return executeFuncEncoded; +} + + +} // namespace TW::Ethereum diff --git a/src/Ethereum/ERC4337.h b/src/Ethereum/ERC4337.h new file mode 100644 index 00000000000..33cc5479dd0 --- /dev/null +++ b/src/Ethereum/ERC4337.h @@ -0,0 +1,16 @@ +// Copyright © 2017-2023 Trust Wallet. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#pragma once + +#include "Data.h" +#include "uint256.h" + +namespace TW::Ethereum { + +Data getERC4337ExecuteBytecode(const Data& toAddress, const uint256_t& value, const Data& data); + +} diff --git a/src/Ethereum/Signer.cpp b/src/Ethereum/Signer.cpp index 5692274e820..1de57ee4485 100644 --- a/src/Ethereum/Signer.cpp +++ b/src/Ethereum/Signer.cpp @@ -22,6 +22,9 @@ Proto::SigningOutput Signer::sign(const Proto::SigningInput& input) noexcept { auto output = Proto::SigningOutput(); + auto pre_hash = transaction->preHash(chainID); + output.set_pre_hash(pre_hash.data(), pre_hash.size()); + auto encoded = transaction->encoded(signature, chainID); output.set_encoded(encoded.data(), encoded.size()); @@ -58,6 +61,9 @@ Proto::SigningOutput Signer::compile(const Proto::SigningInput& input, const Dat auto output = Proto::SigningOutput(); + auto pre_hash = transaction->preHash(chainID); + output.set_pre_hash(pre_hash.data(), pre_hash.size()); + auto encoded = transaction->encoded(sigStruct, chainID); output.set_encoded(encoded.data(), encoded.size()); @@ -141,10 +147,8 @@ std::shared_ptr Signer::build(const Proto::SigningInput& input) // EIP4337 Data entryPointAddress = addressStringToData(input.user_operation().entry_point()); - Data accountFactoryAddress = addressStringToData(input.user_operation().account_factory()); - Data accountLogicAddress = addressStringToData(input.user_operation().account_logic()); - Data ownerAddress = addressStringToData(input.user_operation().owner()); - bool isAccountDeployed = input.user_operation().is_account_deployed(); + Data senderAddress = addressStringToData(input.user_operation().sender()); + Data initCode = Data(input.user_operation().init_code().begin(), input.user_operation().init_code().end()); uint256_t preVerificationGas = load(input.user_operation().pre_verification_gas()); uint256_t verificationGasLimit = load(input.user_operation().verification_gas_limit()); Data paymasterAndData = Data(input.user_operation().paymaster_and_data().begin(), input.user_operation().paymaster_and_data().end()); @@ -170,19 +174,17 @@ std::shared_ptr Signer::build(const Proto::SigningInput& input) case Proto::TransactionMode::UserOp: return UserOperation::buildNativeTransfer( entryPointAddress, - accountFactoryAddress, - accountLogicAddress, - ownerAddress, + senderAddress, toAddress, load(input.transaction().transfer().amount()), nonce, - isAccountDeployed, gasLimit, verificationGasLimit, maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, paymasterAndData, + initCode, Data(input.transaction().transfer().data().begin(), input.transaction().transfer().data().end()) ); } @@ -209,20 +211,18 @@ std::shared_ptr Signer::build(const Proto::SigningInput& input) case Proto::TransactionMode::UserOp: return UserOperation::buildERC20Transfer( entryPointAddress, - accountFactoryAddress, - accountLogicAddress, - ownerAddress, + senderAddress, toAddress, tokenToAddress, load(input.transaction().erc20_transfer().amount()), nonce, - isAccountDeployed, gasLimit, verificationGasLimit, maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - paymasterAndData); + paymasterAndData, + initCode); } } @@ -247,20 +247,18 @@ std::shared_ptr Signer::build(const Proto::SigningInput& input) case Proto::TransactionMode::UserOp: return UserOperation::buildERC20Approve( entryPointAddress, - accountFactoryAddress, - accountLogicAddress, - ownerAddress, + senderAddress, toAddress, spenderAddress, load(input.transaction().erc20_approve().amount()), nonce, - isAccountDeployed, gasLimit, verificationGasLimit, maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - paymasterAndData); + paymasterAndData, + initCode); } } @@ -288,21 +286,19 @@ std::shared_ptr Signer::build(const Proto::SigningInput& input) case Proto::TransactionMode::UserOp: return UserOperation::buildERC721Transfer( entryPointAddress, - accountFactoryAddress, - accountLogicAddress, - ownerAddress, + senderAddress, toAddress, tokenFromAddress, tokenToAddress, load(input.transaction().erc721_transfer().token_id()), nonce, - isAccountDeployed, gasLimit, verificationGasLimit, maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - paymasterAndData); + paymasterAndData, + initCode); } } @@ -334,9 +330,7 @@ std::shared_ptr Signer::build(const Proto::SigningInput& input) case Proto::TransactionMode::UserOp: return UserOperation::buildERC1155Transfer( entryPointAddress, - accountFactoryAddress, - accountLogicAddress, - ownerAddress, + senderAddress, toAddress, tokenFromAddress, tokenToAddress, @@ -344,13 +338,13 @@ std::shared_ptr Signer::build(const Proto::SigningInput& input) load(input.transaction().erc1155_transfer().value()), Data(input.transaction().erc1155_transfer().data().begin(), input.transaction().erc1155_transfer().data().end()), nonce, - isAccountDeployed, gasLimit, verificationGasLimit, maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - paymasterAndData); + paymasterAndData, + initCode); } } @@ -375,19 +369,17 @@ std::shared_ptr Signer::build(const Proto::SigningInput& input) case Proto::TransactionMode::UserOp: return UserOperation::buildNativeTransfer( entryPointAddress, - accountFactoryAddress, - accountLogicAddress, - ownerAddress, + senderAddress, toAddress, load(input.transaction().contract_generic().amount()), nonce, - isAccountDeployed, gasLimit, verificationGasLimit, maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, paymasterAndData, + initCode, Data(input.transaction().contract_generic().data().begin(), input.transaction().contract_generic().data().end())); } } diff --git a/src/Ethereum/Transaction.cpp b/src/Ethereum/Transaction.cpp index fba9673896c..f9592720601 100644 --- a/src/Ethereum/Transaction.cpp +++ b/src/Ethereum/Transaction.cpp @@ -9,7 +9,7 @@ #include "HexCoding.h" #include "RLP.h" #include "Signer.h" -#include +#include #include #include @@ -238,19 +238,18 @@ Data UserOperation::serialize([[maybe_unused]] const uint256_t chainID) const { auto params = ABI::ParamTuple(ParamCollection{ std::make_shared(sender), std::make_shared(nonce), - std::make_shared(initCode), - std::make_shared(payload), + std::make_shared(32, Hash::keccak256(initCode)), + std::make_shared(32, Hash::keccak256(payload)), std::make_shared(gasLimit), std::make_shared(verificationGasLimit), std::make_shared(preVerificationGas), std::make_shared(maxFeePerGas), std::make_shared(maxInclusionFeePerGas), - std::make_shared(paymasterAndData), - std::make_shared(parse_hex("0x"))}); + std::make_shared(32, Hash::keccak256(paymasterAndData))}); Data serialized; params.encode(serialized); - return Data(serialized.begin(), serialized.end() - 32); // remove trailing word (zero-length signature) + return serialized; } Data UserOperation::encoded(const Signature& signature, [[maybe_unused]] const uint256_t chainID) const { @@ -274,17 +273,13 @@ Data UserOperation::encoded(const Signature& signature, [[maybe_unused]] const u } UserOperationPtr -UserOperation::buildNativeTransfer(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& toAddress, const uint256_t& amount, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData, const Data& payload) { - Data initCode = {}; - if (!isAccountDeployed) { - initCode = Ethereum::getEIP4337AccountInitializeBytecode(hex(ownerAddress), hex(factoryAddress)); - } +UserOperation::buildNativeTransfer(const Data& entryPointAddress, const Data& senderAddress, + const Data& toAddress, const uint256_t& amount, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData, const Data& initCode, const Data& payload) { return std::make_shared( entryPointAddress, - parse_hex(Ethereum::getEIP4337DeploymentAddress(hex(factoryAddress), hex(logicAddress), hex(ownerAddress))), + senderAddress, nonce, initCode, gasLimit, @@ -292,22 +287,18 @@ UserOperation::buildNativeTransfer(const Data& entryPointAddress, const Data& fa maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - Ethereum::getEIP4337ExecuteBytecode(toAddress, amount, payload), + Ethereum::getERC4337ExecuteBytecode(toAddress, amount, payload), paymasterAndData); } UserOperationPtr -UserOperation::buildERC20Transfer(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& tokenContract, const Data& toAddress, const uint256_t& amount, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData) { - Data initCode = {}; - if (!isAccountDeployed) { - initCode = Ethereum::getEIP4337AccountInitializeBytecode(hex(ownerAddress), hex(factoryAddress)); - } +UserOperation::buildERC20Transfer(const Data& entryPointAddress, const Data& senderAddress, + const Data& tokenContract, const Data& toAddress, const uint256_t& amount, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData, const Data& initCode) { return std::make_shared( entryPointAddress, - parse_hex(Ethereum::getEIP4337DeploymentAddress(hex(factoryAddress), hex(logicAddress), hex(ownerAddress))), + senderAddress, nonce, initCode, gasLimit, @@ -315,22 +306,18 @@ UserOperation::buildERC20Transfer(const Data& entryPointAddress, const Data& fac maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - Ethereum::getEIP4337ExecuteBytecode(tokenContract, 0, TransactionNonTyped::buildERC20TransferCall(toAddress, amount)), + Ethereum::getERC4337ExecuteBytecode(tokenContract, 0, TransactionNonTyped::buildERC20TransferCall(toAddress, amount)), paymasterAndData); } UserOperationPtr -UserOperation::buildERC20Approve(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& tokenContract, const Data& spenderAddress, const uint256_t& amount, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData) { - Data initCode = {}; - if (!isAccountDeployed) { - initCode = Ethereum::getEIP4337AccountInitializeBytecode(hex(ownerAddress), hex(factoryAddress)); - } +UserOperation::buildERC20Approve(const Data& entryPointAddress, const Data& senderAddress, + const Data& tokenContract, const Data& spenderAddress, const uint256_t& amount, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData, const Data& initCode) { return std::make_shared( entryPointAddress, - parse_hex(Ethereum::getEIP4337DeploymentAddress(hex(factoryAddress), hex(logicAddress), hex(ownerAddress))), + senderAddress, nonce, initCode, gasLimit, @@ -338,22 +325,18 @@ UserOperation::buildERC20Approve(const Data& entryPointAddress, const Data& fact maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - Ethereum::getEIP4337ExecuteBytecode(tokenContract, 0, TransactionNonTyped::buildERC20ApproveCall(spenderAddress, amount)), + Ethereum::getERC4337ExecuteBytecode(tokenContract, 0, TransactionNonTyped::buildERC20ApproveCall(spenderAddress, amount)), paymasterAndData); } UserOperationPtr -UserOperation::buildERC721Transfer(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& tokenContract, const Data& from, const Data& to, const uint256_t& tokenId, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData) { - Data initCode = {}; - if (!isAccountDeployed) { - initCode = Ethereum::getEIP4337AccountInitializeBytecode(hex(ownerAddress), hex(factoryAddress)); - } +UserOperation::buildERC721Transfer(const Data& entryPointAddress, const Data& senderAddress, + const Data& tokenContract, const Data& from, const Data& to, const uint256_t& tokenId, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData, const Data& initCode) { return std::make_shared( entryPointAddress, - parse_hex(Ethereum::getEIP4337DeploymentAddress(hex(factoryAddress), hex(logicAddress), hex(ownerAddress))), + senderAddress, nonce, initCode, gasLimit, @@ -361,22 +344,18 @@ UserOperation::buildERC721Transfer(const Data& entryPointAddress, const Data& fa maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - Ethereum::getEIP4337ExecuteBytecode(tokenContract, 0, TransactionNonTyped::buildERC721TransferFromCall(from, to, tokenId)), + Ethereum::getERC4337ExecuteBytecode(tokenContract, 0, TransactionNonTyped::buildERC721TransferFromCall(from, to, tokenId)), paymasterAndData); } UserOperationPtr -UserOperation::buildERC1155Transfer(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& tokenContract, const Data& from, const Data& to, const uint256_t& tokenId, const uint256_t& value, const Data& data, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData) { - Data initCode = {}; - if (!isAccountDeployed) { - initCode = Ethereum::getEIP4337AccountInitializeBytecode(hex(ownerAddress), hex(factoryAddress)); - } +UserOperation::buildERC1155Transfer(const Data& entryPointAddress, const Data& senderAddress, + const Data& tokenContract, const Data& from, const Data& to, const uint256_t& tokenId, const uint256_t& value, const Data& data, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData, const Data& initCode) { return std::make_shared( entryPointAddress, - parse_hex(Ethereum::getEIP4337DeploymentAddress(hex(factoryAddress), hex(logicAddress), hex(ownerAddress))), + senderAddress, nonce, initCode, gasLimit, @@ -384,7 +363,7 @@ UserOperation::buildERC1155Transfer(const Data& entryPointAddress, const Data& f maxFeePerGas, maxInclusionFeePerGas, preVerificationGas, - Ethereum::getEIP4337ExecuteBytecode(tokenContract, 0, TransactionNonTyped::buildERC1155TransferFromCall(from, to, tokenId, value, data)), + Ethereum::getERC4337ExecuteBytecode(tokenContract, 0, TransactionNonTyped::buildERC1155TransferFromCall(from, to, tokenId, value, data)), paymasterAndData); } diff --git a/src/Ethereum/Transaction.h b/src/Ethereum/Transaction.h index 60729f5e1a5..794af3e7bf4 100644 --- a/src/Ethereum/Transaction.h +++ b/src/Ethereum/Transaction.h @@ -187,30 +187,30 @@ class UserOperation: public TransactionTyped { // Factory methods // Create a native transfer transaction - static UserOperationPtr buildNativeTransfer(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& toAddress, const uint256_t& amount, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData = {}, const Data& payload = {}); + static UserOperationPtr buildNativeTransfer(const Data& entryPointAddress, const Data& senderAddress, + const Data& toAddress, const uint256_t& amount, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData = {}, const Data& initCode = {}, const Data& payload = {}); // Create an ERC20 token transfer transaction - static UserOperationPtr buildERC20Transfer(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& tokenContract, const Data& toAddress, const uint256_t& amount, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData = {}); + static UserOperationPtr buildERC20Transfer(const Data& entryPointAddress, const Data& senderAddress, + const Data& tokenContract, const Data& toAddress, const uint256_t& amount, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData = {}, const Data& initCode = {}); // Create an ERC20 approve transaction - static UserOperationPtr buildERC20Approve(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& tokenContract, const Data& spenderAddress, const uint256_t& amount, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData = {}); + static UserOperationPtr buildERC20Approve(const Data& entryPointAddress, const Data& senderAddress, + const Data& tokenContract, const Data& spenderAddress, const uint256_t& amount, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData = {}, const Data& initCode = {}); // Create an ERC721 NFT transfer transaction - static UserOperationPtr buildERC721Transfer(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& tokenContract, const Data& from, const Data& to, const uint256_t& tokenId, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData = {}); + static UserOperationPtr buildERC721Transfer(const Data& entryPointAddress, const Data& senderAddress, + const Data& tokenContract, const Data& from, const Data& to, const uint256_t& tokenId, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData = {}, const Data& initCode = {}); // Create an ERC1155 NFT transfer transaction - static UserOperationPtr buildERC1155Transfer(const Data& entryPointAddress, const Data& factoryAddress, const Data& logicAddress, const Data& ownerAddress, - const Data& tokenContract, const Data& from, const Data& to, const uint256_t& tokenId, const uint256_t& value, const Data& data, const uint256_t& nonce, const bool& isAccountDeployed, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& paymasterAndData = {}); + static UserOperationPtr buildERC1155Transfer(const Data& entryPointAddress, const Data& senderAddress, + const Data& tokenContract, const Data& from, const Data& to, const uint256_t& tokenId, const uint256_t& value, const Data& data, const uint256_t& nonce, + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& paymasterAndData = {}, const Data& initCode = {}); virtual Data preHash(const uint256_t chainID) const; virtual Data serialize(const uint256_t chainID) const; @@ -218,8 +218,8 @@ class UserOperation: public TransactionTyped { public: UserOperation(const Data& entryPoint, const Data& sender, const uint256_t& nonce, const Data& initCode, - const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, - const Data& payload = {}, const Data& paymasterAndData = {}) + const uint256_t& gasLimit, const uint256_t& verificationGasLimit, const uint256_t& maxFeePerGas, const uint256_t& maxInclusionFeePerGas, const uint256_t& preVerificationGas, + const Data& payload = {}, const Data& paymasterAndData = {}) : TransactionTyped(TxType_Eip4337, nonce, payload) , entryPoint(std::move(entryPoint)) , sender(std::move(sender)) diff --git a/src/interface/TWBarz.cpp b/src/interface/TWBarz.cpp index 953cb4c757f..58776c1c750 100644 --- a/src/interface/TWBarz.cpp +++ b/src/interface/TWBarz.cpp @@ -5,6 +5,7 @@ // file LICENSE at the root of the source code distribution tree. #include +#include #include #include "Ethereum/Barz.h" @@ -18,4 +19,21 @@ TWString *_Nonnull TWBarzGetCounterfactualAddress(TWData *_Nonnull input) { } return TWStringCreateWithUTF8Bytes(TW::Barz::getCounterfactualAddress(inputProto).c_str()); +} + +TWData *_Nonnull TWBarzGetInitCodeFromPublicKey(TWString* _Nonnull factory, TWString* _Nonnull publicKey, TWString* _Nonnull verificationFacet) { + const auto& factoryStr = *reinterpret_cast(factory); + const auto& publicKeyStr = *reinterpret_cast(publicKey); + const auto& verificationFacetStr = *reinterpret_cast(verificationFacet); + + const auto initCode = TW::Barz::getInitCodeFromPublicKey(factoryStr, publicKeyStr, verificationFacetStr); + return TWDataCreateWithData(&initCode); +} + +TWData *_Nonnull TWBarzGetInitCodeFromAttestationObject(TWString* _Nonnull factory, TWString* _Nonnull attestationObject, TWString* _Nonnull verificationFacet) { + const auto& factoryStr = *reinterpret_cast(factory); + const auto& attestationObjectStr = *reinterpret_cast(attestationObject); + const auto& verificationFacetStr = *reinterpret_cast(verificationFacet); + const auto initCode = TW::Barz::getInitCodeFromAttestationObject(factoryStr, attestationObjectStr, verificationFacetStr); + return TWDataCreateWithData(&initCode); } \ No newline at end of file diff --git a/src/interface/TWEthereum.cpp b/src/interface/TWEthereum.cpp index 4e9440268d5..ca3299a87be 100644 --- a/src/interface/TWEthereum.cpp +++ b/src/interface/TWEthereum.cpp @@ -6,7 +6,6 @@ #include "Data.h" #include "Ethereum/EIP1014.h" -#include "Ethereum/EIP4337.h" #include "Ethereum/EIP2645.h" #include @@ -18,11 +17,4 @@ TWString* TWEthereumEip2645GetPath(TWString* ethAddress, TWString* layer, TWStri const auto& applicationStr = *reinterpret_cast(application); const auto& indexStr = *reinterpret_cast(index); return new std::string(TW::Ethereum::accountPathFromAddress(ethAddressStr, layerStr, applicationStr, indexStr)); -} - -TWString* TWEthereumEip4337GetDeploymentAddress(TWString* _Nonnull factoryAddress, TWString* _Nonnull logicAddress, TWString* _Nonnull ownerAddress) { - const auto& factoryAddressStr = *reinterpret_cast(factoryAddress); - const auto& logicAddressStr = *reinterpret_cast(logicAddress); - const auto& ownerAddressStr = *reinterpret_cast(ownerAddress); - return new std::string(TW::Ethereum::getEIP4337DeploymentAddress(factoryAddressStr, logicAddressStr, ownerAddressStr)); } \ No newline at end of file diff --git a/src/proto/Barz.proto b/src/proto/Barz.proto index 405e315d509..921d5716319 100644 --- a/src/proto/Barz.proto +++ b/src/proto/Barz.proto @@ -9,8 +9,6 @@ syntax = "proto3"; package TW.Barz.Proto; option java_package = "wallet.core.jni.proto"; -import "Common.proto"; - // Represents the access control to the wallet message ContractOwner { oneof kind { @@ -32,15 +30,18 @@ message ContractAddressInput { // ERC-4337 entry point string entry_point = 5; - // Address of the contract that defines security constraints - string security_manager = 6; + // Diamond Loupe from ERC-2535: Diamonds, Multi-Facet Proxy + string diamond_loupe_facet = 6; + + // Diamond init from ERC-2535: Diamonds, Multi-Facet Proxy + string diamond_init = 7; // Address of the contract that defines if a facet is secure - string facet_registry = 7; + string facet_registry = 8; // Bytecode of the smart contract to deploy - string bytecode = 8; + string bytecode = 9; // Owner of the wallet - ContractOwner owner = 9; -} \ No newline at end of file + ContractOwner owner = 10; +} diff --git a/src/proto/Ethereum.proto b/src/proto/Ethereum.proto index b84af3e1a70..020ad840e4c 100644 --- a/src/proto/Ethereum.proto +++ b/src/proto/Ethereum.proto @@ -101,25 +101,19 @@ message UserOperation { string entry_point = 1; // Account factory contract address - string account_factory = 2; + bytes init_code = 2; // Account logic contract address - string account_logic = 3; - - // Public address of the account signer - string owner = 4; - - // Whether the smart contract for this address has already been deployed - bool is_account_deployed = 5; + string sender = 3; // The amount of gas to pay for to compensate the bundler for pre-verification execution and calldata - bytes pre_verification_gas = 6; + bytes pre_verification_gas = 4; // The amount of gas to allocate for the verification step - bytes verification_gas_limit = 7; + bytes verification_gas_limit = 5; // Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (empty for self-sponsored transaction) - bytes paymaster_and_data = 8; + bytes paymaster_and_data = 6; } // Input data necessary to create a signed transaction. @@ -165,6 +159,7 @@ message SigningInput { // Result containing the signed and encoded transaction. message SigningOutput { + // Signed and encoded transaction bytes. bytes encoded = 1; @@ -181,4 +176,7 @@ message SigningOutput { // error code description string error_message = 7; + + // Encoded transaction bytes. + bytes pre_hash = 8; } diff --git a/swift/Tests/BarzTests.swift b/swift/Tests/BarzTests.swift index fabc7c229d1..087bbfc118d 100644 --- a/swift/Tests/BarzTests.swift +++ b/swift/Tests/BarzTests.swift @@ -9,49 +9,136 @@ import WalletCore class BarzTests: XCTestCase { + // https://testnet.bscscan.com/tx/0x434f5861b7d14b3bf790b57e5eb1be98355d77f528defe732f2994fc9d6d3f2e + func testInitCodeFromPublicKey() { + let factoryAddress = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800" + let publicKey = "0x1dba683ee34242c993f7588c30099969a1e58e64bdd0657958ced8e4220f69678a77e6fdf4633151105bdb1a9dd419fbd65f7d8b7a39923757534d4a578e9b58" + let verificationFacet = "0x6BF22ff186CC97D88ECfbA47d1473a234CEBEFDf" + let result = Barz.getInitCodeFromPublicKey(factory: factoryAddress, publicKey: publicKey, verificationFacet: verificationFacet) + XCTAssertEqual(result.hexString, "3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000006bf22ff186cc97d88ecfba47d1473a234cebefdf0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000401dba683ee34242c993f7588c30099969a1e58e64bdd0657958ced8e4220f69678a77e6fdf4633151105bdb1a9dd419fbd65f7d8b7a39923757534d4a578e9b58") + } + + // https://testnet.bscscan.com/tx/0x6c6e1fe81c722c0abce1856b9b4e078ab2cad06d51f2d1b04945e5ba2286d1b4 + func testInitCodeFromAttestationObject() { + let factoryAddress = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800" + let attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d0000000000000000000000000000000000000000001464193b58d01d4047694ba4634750047a5fcd637ea5010203262001215820e6f4e0351e2f556fd7284a9a033832bae046ac31fd529ad02ab6220870624b79225820eb760e718fdaed7a037dd1d77a561759cee9f2706eb55a729dc953e0d5719b02" + let verificationFacet = "0x6BF22ff186CC97D88ECfbA47d1473a234CEBEFDf" + let result = Barz.getInitCodeFromAttestationObject(factory: factoryAddress, attestationObject: attestationObject, verificationFacet: verificationFacet) + XCTAssertEqual(result.hexString, "3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000006bf22ff186cc97d88ecfba47d1473a234cebefdf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040e6f4e0351e2f556fd7284a9a033832bae046ac31fd529ad02ab6220870624b79eb760e718fdaed7a037dd1d77a561759cee9f2706eb55a729dc953e0d5719b02") + } + + // https://testnet.bscscan.com/address/0x5d51930e0ce5cc08a67a1763fadb66892c0994d1 func testCounterfactualAddressFromPublicKey() { + let verificationFacet = "0xDcfbDE24847FdF29E6d0311f4bAEb2b49ae8B5a3" let input = BarzContractAddressInput.with { $0.factory = factory $0.diamondCutFacet = diamondCutFacet $0.accountFacet = accountFacet $0.verificationFacet = verificationFacet $0.entryPoint = entryPoint - $0.securityManager = securityManager + $0.diamondLoupeFacet = diamondLoupeFacet + $0.diamondInit = diamondInit $0.facetRegistry = facetRegistry $0.bytecode = bytecode $0.owner = BarzContractOwner.with { - $0.publicKey = "0x019b4ee7ad22ffd4c215e5f424faf4c75577dc36" + $0.publicKey = "0xB5547FBdC56DCE45e1B8ef75569916D438e09c46" } } - XCTAssertEqual(Barz.getCounterfactualAddress(input: try! input.serializedData()), "0xE9C377EFCE644fd54614d77C177c14148502496F"); + XCTAssertEqual(Barz.getCounterfactualAddress(input: try! input.serializedData()), "0xb16Db98B365B1f89191996942612B14F1Da4Bd5f"); } func testCounterfactualAddressFromAttestationObject() { + let verificationFacet = "0x5034534Efe9902779eD6eA6983F435c00f3bc510" let input = BarzContractAddressInput.with { $0.factory = factory $0.diamondCutFacet = diamondCutFacet $0.accountFacet = accountFacet $0.verificationFacet = verificationFacet $0.entryPoint = entryPoint - $0.securityManager = securityManager + $0.diamondLoupeFacet = diamondLoupeFacet + $0.diamondInit = diamondInit $0.facetRegistry = facetRegistry $0.bytecode = bytecode $0.owner = BarzContractOwner.with { - $0.attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158a4f95bc73828ee210f9fd3bbe72d97908013b0a3759e9aea3d0ae318766cd2e1ad4500000000adce000235bcc60a648b0b25f1f055030020c720eb493e167ce93183dd91f5661e1004ed8cc1be23d3340d92381da5c0c80ca5010203262001215820a620a8cfc88fd062b11eab31663e56cad95278bef612959be214d98779f645b82258204e7b905b42917570148b0432f99ba21f2e7eebe018cbf837247e38150a89f771" + $0.attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d000000000000000000000000000000000000000000147d0d9cf0634ebd79b5df0c91c7de42c567aac588a50102032620012158207868c62a834763bae747bd9db14d9d159ccd1052a8f81287e3f039c5c9c0f91e225820000e4fc74a22560d3bd22866c6b9fe88c10c170be073d2a838c8019586a7a4eb" } } - XCTAssertEqual(Barz.getCounterfactualAddress(input: try! input.serializedData()), "0xc3d477e5D4CEd32835574bBAFE51a0A8c9c17272"); + XCTAssertEqual(Barz.getCounterfactualAddress(input: try! input.serializedData()), "0x85a6290917d1DC2C507Ff2D545Ba5aF13e964Ba1"); } + // https://testnet.bscscan.com/tx/0x43fc13dfdf06bbb09da8ce070953753764f1e43782d0c8b621946d8b45749419 + func testSignK1TransferAccountDeployed() { + let input = EthereumSigningInput.with { + $0.chainID = Data(hexString: "61")! + $0.nonce = Data(hexString: "02")! + $0.txMode = .userOp + $0.gasLimit = Data(hexString: "0186A0")! + $0.maxFeePerGas = Data(hexString: "01a339c9e9")! + $0.maxInclusionFeePerGas = Data(hexString: "01a339c9e9")! + $0.toAddress = "0x61061fCAE11fD5461535e134EfF67A98CFFF44E9" + $0.privateKey = Data(hexString: "3c90badc15c4d35733769093d3733501e92e7f16e101df284cee9a310d36c483")! + + $0.userOperation = EthereumUserOperation.with { + $0.verificationGasLimit = Data(hexString: "0186a0")! + $0.preVerificationGas = Data(hexString: "b708")! + $0.entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + $0.sender = "0xb16Db98B365B1f89191996942612B14F1Da4Bd5f" + } + + $0.transaction = EthereumTransaction.with { + $0.transfer = EthereumTransaction.Transfer.with { + $0.amount = Data(hexString: "2386f26fc10000")! + } + } + } + let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum) + XCTAssertEqual(output.preHash.hexString, "731dd74cbf212bee883c6decbad07ad8980be89ca2e6c64de310af04e562d866") + XCTAssertEqual(String(data: output.encoded, encoding: .utf8), "{\"callData\":\"0xb61d27f600000000000000000000000061061fcae11fd5461535e134eff67a98cfff44e9000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"100000\",\"initCode\":\"0x\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"7033440745\",\"nonce\":\"2\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0xb16db98b365b1f89191996942612b14f1da4bd5f\",\"signature\":\"0x3d29240a2decf2a1f47c88d1cb5923815ed50d24f8f01a9697e229ba69ce18d13779d2d96a5c93f5df29110677de62e75f4d751ab7baf5830276eb4ca257fb471b\",\"verificationGasLimit\":\"100000\"}") + } + + // https://testnet.bscscan.com/tx/0xea1f5cddc0653e116327cbcb3bc770360a642891176eff2ec69c227e46791c31 + func testSignR1TransferAccountNotDeployed() { + let input = EthereumSigningInput.with { + $0.chainID = Data(hexString: "61")! + $0.nonce = Data(hexString: "00")! + $0.txMode = .userOp + $0.gasLimit = Data(hexString: "2625A0")! + $0.maxFeePerGas = Data(hexString: "01a339c9e9")! + $0.maxInclusionFeePerGas = Data(hexString: "01a339c9e9")! + $0.toAddress = "0x61061fCAE11fD5461535e134EfF67A98CFFF44E9" + $0.privateKey = Data(hexString: "3c90badc15c4d35733769093d3733501e92e7f16e101df284cee9a310d36c483")! + + $0.userOperation = EthereumUserOperation.with { + $0.verificationGasLimit = Data(hexString: "2DC6C0")! + $0.preVerificationGas = Data(hexString: "b708")! + $0.entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + $0.sender = "0x1392Ae041BfBdBAA0cFF9234a0C8F64df97B7218" + $0.initCode = Barz.getInitCodeFromAttestationObject( + factory: factory, + attestationObject: "0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d00000000000000000000000000000000000000000014c14f8a2dfd8f451581fad6e4e1c11821abcaacd6a5010203262001215820b173a6a812025c40c38bac46343646bd0a8137c807aae6e04aac238cc24d2ad2225820116ca14d23d357588ff2aabd7db29d5976f4ecc8037775db86f67e873a306b1f", + verificationFacet: "0x5034534Efe9902779eD6eA6983F435c00f3bc510" + ) + } + + $0.transaction = EthereumTransaction.with { + $0.transfer = EthereumTransaction.Transfer.with { + $0.amount = Data(hexString: "2386f26fc10000")! + } + } + } + let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum) + XCTAssertEqual(output.preHash.hexString, "b884c13821af6794e2fed1f5906f847251123adde02bd84723b50eda24fe2c93") + XCTAssertEqual(String(data: output.encoded, encoding: .utf8), "{\"callData\":\"0xb61d27f600000000000000000000000061061fcae11fd5461535e134eff67a98cfff44e9000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"2500000\",\"initCode\":\"0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000005034534efe9902779ed6ea6983f435c00f3bc510000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040b173a6a812025c40c38bac46343646bd0a8137c807aae6e04aac238cc24d2ad2116ca14d23d357588ff2aabd7db29d5976f4ecc8037775db86f67e873a306b1f\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"7033440745\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0x1392ae041bfbdbaa0cff9234a0c8f64df97b7218\",\"signature\":\"0x670d22e5361a75add1a90f2e86abf23a7e7b860795ca882e33efad17f0c6ff9a5c8e25260c89f1dd2aafba56ba0efdaec6cd976df399f848f443876fdb64867e1c\",\"verificationGasLimit\":\"3000000\"}") + } - let factory = "0xb7f8bc63bbcad18155201308c8f3540b07f84f5e" - let diamondCutFacet = "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9" - let accountFacet = "0xdc64a140aa3e981100a9beca4e685f962f0cf6c9" - let verificationFacet = "0x5fc8d32690cc91d4c39d9d3abcbd16989f875707" - let entryPoint = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" - let securityManager = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512" - let facetRegistry = "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0" - let bytecode = "0x60808060405261127d80380380916100178285610943565b833981019060e0818303126108de5761002f81610966565b9161003c60208301610966565b9161004960408201610966565b9161005660608301610966565b9161006360808201610966565b61006f60a08301610966565b60c083015190926001600160401b0382116108de570183601f820112156108de57805161009b8161097a565b946100a96040519687610943565b818652602082840101116108de576100c79160208087019101610995565b604051633253960f60e01b815260208160048160006001600160a01b038b165af19081156108eb576000916108a3575b506001600160e01b031981161561085f576040979695975196610119886108f7565b6002885260005b6040811061082b57509161026693916102749695936040519061014282610928565b60018252602036818401376040519161015a83610928565b60018352602036818501376307e4c70760e21b610176826109b8565b5260405191610184836108f7565b6001600160a01b031682526000602083015260408201526101a48b6109b8565b526101ae8a6109b8565b506001600160e01b031982166101c3826109b8565b52604051906101d1826108f7565b6001600160a01b038c1682526000602083015260408201526101f28a6109db565b526101fc896109db565b506001805464ffffffff00191660d89290921c64ffffffff0016919091179055604051634a93641760e01b60208201526001600160a01b03958616602482015298851660448a015284166064890152909216608487015260a060a4870152859160c48301906109ff565b03601f198101855284610943565b6000915b805183101561070457602061028d84836109eb565b51015160038110156106ee578061041457506001600160a01b036102b184836109eb565b5151169160406102c185846109eb565b510151916102d183511515610a49565b6102dc841515610aa9565b6001600160a01b038416600090815260008051602061125d83398151915260205260409020546001600160601b0316918215610406575b6000925b84518410156103ec576001600160e01b031961033385876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031661038157816103708861037b9461037594610c3b565b610b0a565b93610a24565b92610317565b60405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c72656164792065786973747300000000000000000000006064820152608490fd5b509491509492506103fe91505b610a24565b919092610278565b61040f85610b49565b610313565b9193916001810361058d57506001600160a01b0361043284836109eb565b51511693604061044285846109eb565b5101519161045283511515610a49565b61045d861515610aa9565b6001600160a01b038616600090815260008051602061125d83398151915260205260409020546001600160601b031691821561057f575b6000925b845184101561056f576001600160e01b03196104b485876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031691898314610504576103708a82846104f9610375966104fe98610d26565b610c3b565b92610498565b60405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608490fd5b5094915094506103fe9150610a24565b61058887610b49565b610494565b600203610699576001600160a01b036105a684836109eb565b5151169360406105b685846109eb565b510151946105c686511515610a49565b61062e5760005b85518110156106215761061c906103f96001600160e01b03196105f0838a6109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b0316610d26565b6105cd565b50926103fe919450610a24565b60405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d7573742062652061646472657373283029000000000000000000006064820152608490fd5b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b8382604051606081016060825284518091526080820190602060808260051b8501019601916000905b828210610793576001600160a01b0386166020860152848803604086015261078587877f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673888061077d8e866109ff565b0390a161101f565b60405160e2908161113b8239f35b848803607f19018152835180516001600160a01b03168952602081015194989394929391929060038210156106ee576040916020840152015190606060408201526020608060608301928451809452019201906000905b8082106108085750505060208060019299019201920190929161072d565b82516001600160e01b0319168452602093840193909201916001909101906107ea565b60209060409a98999a5161083e816108f7565b600081526000838201526060604082015282828d0101520198979698610120565b606460405162461bcd60e51b815260206004820152602060248201527f4261727a3a20496e76616c696420566572696669636174696f6e2046616365746044820152fd5b90506020813d6020116108e3575b816108be60209383610943565b810103126108de57516001600160e01b0319811681036108de57386100f7565b600080fd5b3d91506108b1565b6040513d6000823e3d90fd5b606081019081106001600160401b0382111761091257604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b0382111761091257604052565b601f909101601f19168101906001600160401b0382119082101761091257604052565b51906001600160a01b03821682036108de57565b6001600160401b03811161091257601f01601f191660200190565b60005b8381106109a85750506000910152565b8181015183820152602001610998565b8051156109c55760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156109c55760400190565b80518210156109c55760209160051b010190565b90602091610a1881518092818552858086019101610995565b601f01601f1916010190565b6000198114610a335760010190565b634e487b7160e01b600052601160045260246000fd5b15610a5057565b60405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b6064820152608490fd5b15610ab057565b60405162461bcd60e51b815260206004820152602c60248201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260448201526b65206164647265737328302960a01b6064820152608490fd5b6001600160601b03908116908114610a335760010190565b60008051602061123d83398151915280548210156109c55760005260206000200190600090565b610b95604051610b58816108f7565b602481527f4c69624469616d6f6e644375743a204e657720666163657420686173206e6f20602082015263636f646560e01b60408201528261110d565b60008051602061123d83398151915280546001600160a01b038316600090815260008051602061125d833981519152602052604090206001018190559190680100000000000000008310156109125782610bf7916001610c1695019055610b22565b90919082549060031b9160018060a01b03809116831b921b1916179055565b565b91909180548310156109c557600052601c60206000208360031c019260021b1690565b6001600160e01b03198116600081815260008051602061121d83398151915260208190526040822080546001600160a01b031660a09690961b6001600160a01b031916959095179094559194939092906001600160a01b031680835260008051602061125d8339815191526020526040832080549194919068010000000000000000821015610d125796610cdc8260409798996001610cf995018155610c18565b90919063ffffffff83549160031b9260e01c831b921b1916179055565b82526020522080546001600160a01b0319169091179055565b634e487b7160e01b85526041600452602485fd5b9091906001600160a01b039081168015610fb457308114610f585763ffffffff60e01b80941660009281845260008051602061121d833981519152926020918483526040948587205460a01c9083885260008051602061125d8339815191529586865287892054926000199b8c8501948511610f4457908991888c898c89808703610ed6575b505090525050508787525087892080548015610ec2578c0190610dcf8282610c18565b63ffffffff82549160031b1b191690555588528452868681205515610df9575b5050505050509050565b60008051602061123d8339815191528054898101908111610eae57838852858552826001888a20015491808303610e7c575b5050508054988915610e685760019798990191610e4783610b22565b909182549160031b1b19169055558552528220015580388080808080610def565b634e487b7160e01b88526031600452602488fd5b610e8590610b22565b90549060031b1c16610e9a81610bf784610b22565b885285855260018789200155388281610e2b565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b8b52603160045260248bfd5b610f379784610cdc93610ef58a9487610f0b9952828a52848420610c18565b90549060031b1c60e01b97889683525220610c18565b168b52838852898b2080546001600160a01b031660a09290921b6001600160a01b031916919091179055565b873880888c898c89610dac565b634e487b7160e01b8b52601160045260248bfd5b60405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608490fd5b60405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608490fd5b6001600160a01b038116919082156111085760008091611085604051611044816108f7565b602881527f4c69624469616d6f6e644375743a205f696e6974206164647265737320686173602082015267206e6f20636f646560c01b60408201528261110d565b83519060208501905af4913d15611100573d926110a18461097a565b936110af6040519586610943565b84523d6000602086013e5b156110c457505050565b8251156110d357825160208401fd5b6110fc60405192839263192105d760e01b845260048401526040602484015260448301906109ff565b0390fd5b6060926110ba565b505050565b3b156111165750565b60405162461bcd60e51b8152602060048201529081906110fc9060248301906109ff56fe6080604052361560aa57600080356001600160e01b03191681527f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f60205260408120546001600160a01b03168015606c57818091368280378136915af43d82803e156068573d90f35b3d90fd5b62461bcd60e51b6080526020608452602060a4527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460c45260646080fd5b00fea26469706673582212203df3feea7f1aa6ea31eb82d2ad84790e47617c094ced4ce17015a8a7487295da64736f6c63430008120033183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4921183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4920" + let factory = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800" + let diamondCutFacet = "0x312382b3B302bDcC0711fe710314BE298426296f" + let accountFacet = "0x84E684272903737d807375197f9a581FEa094Bc3" + let entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + let diamondLoupeFacet = "0x518834B7EE4461d703ED2de8bCdfC5eCf761bBCA" + let diamondInit = "0x02a3C76D089c50615139B904c4dbD62F20e74a1b" + let facetRegistry = "0x77A4259d76897bA1eC8D6c3EFc5c35e0D7572A8f" + let bytecode = "0x608060405260405162003cc638038062003cc68339818101604052810190620000299190620019ad565b60008673ffffffffffffffffffffffffffffffffffffffff16633253960f6040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000079573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009f919062001aec565b9050600060e01b817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603620000fe576040517f5a5b4d3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600267ffffffffffffffff8111156200011e576200011d6200196b565b5b6040519080825280602002602001820160405280156200015b57816020015b62000147620018ff565b8152602001906001900390816200013d5790505b5090506000600167ffffffffffffffff8111156200017e576200017d6200196b565b5b604051908082528060200260200182016040528015620001ad5781602001602082028036833780820191505090505b5090506000600167ffffffffffffffff811115620001d057620001cf6200196b565b5b604051908082528060200260200182016040528015620001ff5781602001602082028036833780820191505090505b509050631f931c1c60e01b8260008151811062000221576200022062001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808d73ffffffffffffffffffffffffffffffffffffffff16815260200160006002811115620002ab57620002aa62001b37565b5b81526020018381525083600081518110620002cb57620002ca62001b21565b5b60200260200101819052508381600081518110620002ee57620002ed62001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020016000600281111562000378576200037762001b37565b5b8152602001828152508360018151811062000398576200039762001b21565b5b6020026020010181905250620003b9846200047e60201b620001671760201c565b6200046c838c8b8e8e8d8d8d8d604051602401620003de979695949392919062001b8c565b6040516020818303038152906040527f95a21aec000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050620004b060201b620001911760201c565b5050505050505050505050506200211f565b806200048f6200073460201b60201c565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b8351811015620006df576000848281518110620004d557620004d462001b21565b5b602002602001015160200151905060006002811115620004fa57620004f962001b37565b5b81600281111562000510576200050f62001b37565b5b0362000570576200056a85838151811062000530576200052f62001b21565b5b60200260200101516000015186848151811062000552576200055162001b21565b5b6020026020010151604001516200073960201b60201c565b620006c8565b6001600281111562000587576200058662001b37565b5b8160028111156200059d576200059c62001b37565b5b03620005fd57620005f7858381518110620005bd57620005bc62001b21565b5b602002602001015160000151868481518110620005df57620005de62001b21565b5b602002602001015160400151620009db60201b60201c565b620006c7565b60028081111562000613576200061262001b37565b5b81600281111562000629576200062862001b37565b5b0362000689576200068385838151811062000649576200064862001b21565b5b6020026020010151600001518684815181106200066b576200066a62001b21565b5b60200260200101516040015162000c8f60201b60201c565b620006c6565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620006bd9062001be7565b60405180910390fd5b5b5b508080620006d69062001c61565b915050620004b3565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673838383604051620007159392919062001c82565b60405180910390a16200072f828262000e3760201b60201c565b505050565b600090565b600081511162000780576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007779062001d97565b60405180910390fd5b60006200079262000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000806576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007fd9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036200087c576200087b828562000f9860201b60201c565b5b60005b8351811015620009d4576000848281518110620008a157620008a062001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161462000998576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200098f9062001e5f565b60405180910390fd5b620009ac8583868a6200107c60201b60201c565b8380620009b99062001ec3565b94505050508080620009cb9062001c61565b9150506200087f565b5050505050565b600081511162000a22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a199062001d97565b60405180910390fd5b600062000a3462000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000aa8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a9f9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff160362000b1e5762000b1d828562000f9860201b60201c565b5b60005b835181101562000c8857600084828151811062000b435762000b4262001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160362000c39576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000c309062001eef565b60405180910390fd5b62000c4c8582846200122960201b60201c565b62000c608583868a6200107c60201b60201c565b838062000c6d9062001ec3565b9450505050808062000c7f9062001c61565b91505062000b21565b5050505050565b600081511162000cd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000ccd9062001d97565b60405180910390fd5b600062000ce862000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161462000d5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000d539062001f53565b60405180910390fd5b60005b825181101562000e3157600083828151811062000d815762000d8062001b21565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905062000e198482846200122960201b60201c565b5050808062000e289062001c61565b91505062000d5f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16031562000f675762000e988260405180606001604052806028815260200162003c7a60289139620018aa60201b60201c565b6000808373ffffffffffffffffffffffffffffffffffffffff168360405162000ec2919062001fb7565b600060405180830381855af49150503d806000811462000eff576040519150601f19603f3d011682016040523d82523d6000602084013e62000f04565b606091505b50915091508162000f645760008151111562000f235780518082602001fd5b83836040517f192105d700000000000000000000000000000000000000000000000000000000815260040162000f5b92919062001fd7565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b62000fc38160405180606001604052806024815260200162003ca260249139620018aa60201b60201c565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200129b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620012929062002003565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200130c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013039062002067565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050620013e59190620020cb565b9050808214620015805760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000182815481106200144a576200144962001b21565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018481548110620014c957620014c862001b21565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805480620015d757620015d6620020ec565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff0219169055505060008103620018a357600060018660020180549050620016c49190620020cb565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146200180c57600087600201838154811062001732576200173162001b21565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811062001779576200177862001b21565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b86600201805480620018235762001822620020ec565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b9050600081118290620018f9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620018f0919062002102565b60405180910390fd5b50505050565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600060028111156200193e576200193d62001b37565b5b8152602001606081525090565b60008151905060018060a01b03811681146200196657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620019a157808201518184015260208101905062001984565b50600083830152505050565b600080600080600080600080610100898b031215620019cb57600080fd5b620019d6896200194b565b9750620019e660208a016200194b565b9650620019f660408a016200194b565b955062001a0660608a016200194b565b945062001a1660808a016200194b565b935062001a2660a08a016200194b565b925062001a3660c08a016200194b565b915060e089015160018060401b038082111562001a5257600080fd5b818b0191508b601f83011262001a6757600080fd5b81518181111562001a7d5762001a7c6200196b565b5b601f1960405181603f83601f860116011681019150808210848311171562001aaa5762001aa96200196b565b5b816040528281528e602084870101111562001ac457600080fd5b62001ad783602083016020880162001981565b80955050505050509295985092959890939650565b60006020828403121562001aff57600080fd5b815163ffffffff60e01b8116811462001b1757600080fd5b8091505092915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60018060a01b03811682525050565b6000815180845262001b7681602086016020860162001981565b6020601f19601f83011685010191505092915050565b600060018060a01b03808a168352808916602084015280881660408401528087166060840152808616608084015280851660a08401525060e060c083015262001bd960e083018462001b5c565b905098975050505050505050565b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b60008019820362001c775762001c7662001c4b565b5b600182019050919050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101562001d6357607f198a8503018652815188850160018060a01b038251168652848201516003811062001cf157634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b8083101562001d465763ffffffff60e01b84511682528682019150868401935060018301925062001d1a565b508096505050508282019150828601955060018101905062001cab565b505062001d738189018b62001b4d565b50868103604088015262001d88818962001b5c565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b600060018060601b0380831681810362001ee25762001ee162001c4b565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825162001fcb81846020870162001981565b80830191505092915050565b60018060a01b038316815260406020820152600062001ffa604083018462001b5c565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115620020e657620020e562001c4b565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b60208152600062002117602083018462001b5c565b905092915050565b611b4b806200212f6000396000f3fe60806040523661000b57005b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f9050809150600082600001600080357fffffffff00000000000000000000000000000000000000000000000000000000167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610141576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610138906114d3565b60405180910390fd5b3660008037600080366000845af43d6000803e8060008114610162573d6000f35b3d6000fd5b806101706103c0565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b83518110156103755760008482815181106101b2576101b1611510565b5b6020026020010151602001519050600060028111156101d4576101d3611526565b5b8160028111156101e7576101e6611526565b5b036102375761023285838151811061020257610201611510565b5b60200260200101516000015186848151811061022157610220611510565b5b6020026020010151604001516103c5565b610361565b6001600281111561024b5761024a611526565b5b81600281111561025e5761025d611526565b5b036102ae576102a985838151811061027957610278611510565b5b60200260200101516000015186848151811061029857610297611510565b5b60200260200101516040015161063c565b610360565b6002808111156102c1576102c0611526565b5b8160028111156102d4576102d3611526565b5b036103245761031f8583815181106102ef576102ee611510565b5b60200260200101516000015186848151811061030e5761030d611510565b5b6020026020010151604001516108bd565b61035f565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103569061153c565b60405180910390fd5b5b5b50808061036d906115b6565b915050610194565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103a99392919061163b565b60405180910390a16103bb8282610a48565b505050565b600090565b6000815111610409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040090611747565b60405180910390fd5b6000610413610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047b906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036104f1576104f08285610b97565b5b60005b835181101561063557600084828151811061051257610511611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610606576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105fd9061180f565b60405180910390fd5b6106128583868a610c72565b838061061d90611873565b9450505050808061062d906115b6565b9150506104f4565b5050505050565b6000815111610680576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067790611747565b60405180910390fd5b600061068a610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f2906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff1603610768576107678285610b97565b5b60005b83518110156108b657600084828151811061078957610788611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361087c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610873906118a2565b60405180910390fd5b610887858284610e1f565b6108938583868a610c72565b838061089e90611873565b945050505080806108ae906115b6565b91505061076b565b5050505050565b6000815111610901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f890611747565b60405180910390fd5b600061090b610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461097c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097390611906565b60405180910390fd5b60005b8251811015610a4257600083828151811061099d5761099c611510565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610a2d848284610e1f565b50508080610a3a906115b6565b91505061097f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160315610b6657610a9f82604051806060016040528060288152602001611aca60289139611481565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610ac7919061196a565b600060405180830381855af49150503d8060008114610b02576040519150601f19603f3d011682016040523d82523d6000602084013e610b07565b606091505b509150915081610b6357600081511115610b245780518082602001fd5b83836040517f192105d7000000000000000000000000000000000000000000000000000000008152600401610b5a929190611988565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b610bb981604051806060016040528060248152602001611af260249139611481565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610e8e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e85906119b2565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610efc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef390611a16565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050610fd39190611a7a565b90508082146111675760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001828154811061103457611033611510565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000184815481106110b0576110af611510565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054806111bb576111ba611a98565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff021916905550506000810361147a576000600186600201805490506112a59190611a7a565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146113e657600087600201838154811061130f5761130e611510565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811061135357611352611510565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b866002018054806113fa576113f9611a98565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b90506000811182906114cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c49190611aae565b60405180910390fd5b50505050565b602081526020808201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460408201526000606082019050919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b6000801982036115c9576115c86115a0565b5b600182019050919050565b60018060a01b03811682525050565b60005b838110156116015780820151818401526020810190506115e6565b50600083830152505050565b600081518084526116258160208601602086016115e3565b6020601f19601f83011685010191505092915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101561171757607f198a8503018652815188850160018060a01b03825116865284820151600381106116a857634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b808310156116fb5763ffffffff60e01b8451168252868201915086840193506001830192506116d1565b5080965050505082820191508286019550600181019050611664565b50506117258189018b6115d4565b508681036040880152611738818961160d565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b60006bffffffffffffffffffffffff808316818103611895576118946115a0565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825161197c8184602087016115e3565b80830191505092915050565b60018060a01b03831681526040602082015260006119a9604083018461160d565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115611a9257611a916115a0565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b602081526000611ac1602083018461160d565b90509291505056fe4c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465a264697066735822122045b771fb2128a1a34c5b052e9a86464933844b34929cf0d65bbea6a4e76e3b2764736f6c634300081200334c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465" } diff --git a/swift/Tests/Blockchains/EthereumTests.swift b/swift/Tests/Blockchains/EthereumTests.swift index fc6e0e6dd4d..51eb515585f 100644 --- a/swift/Tests/Blockchains/EthereumTests.swift +++ b/swift/Tests/Blockchains/EthereumTests.swift @@ -371,241 +371,4 @@ class EthereumTests: XCTestCase { let pubKey = privateKey.getPublicKey(coinType: .ethereum) XCTAssertTrue(EthereumMessageSigner.verifyMessage(pubKey: pubKey, message: msg, signature: signature)) } - - // EIP4337 - - func testEIP4337DeploymentAddress() { - let factoryAddress = "0xd9145CCE52D386f254917e481eB44e9943F39138" - let logicAddress = "0x5C9eb5D6a6C2c1B3EFc52255C0b356f116f6f66D" - let ownerAddress = "0xA5a1dddEF094095AfB7b6e322dE72961DF2e1988" - let result = Ethereum.eip4337GetDeploymentAddress(factoryAddress: factoryAddress, logicAddress: logicAddress, ownerAddress: ownerAddress) - XCTAssertEqual(result, "0xbEaA87cEEaC906C21aaacd258FbFB87CfA3c90a8") - } - - func testEIP4337NativeTransferAccountNotDeployed() throws { - let input = EthereumSigningInput.with { - $0.txMode = .userOp - $0.chainID = Data(hexString: "05")! - $0.nonce = Data(hexString: "00")! - $0.toAddress = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - - $0.gasLimit = Data(hexString: "0x5580")! - $0.maxFeePerGas = Data(hexString: "0x01952f1f85")! - $0.maxInclusionFeePerGas = Data(hexString: "0x0f")! - - $0.userOperation = EthereumUserOperation.with { - $0.entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - $0.accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - $0.accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - $0.owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - $0.isAccountDeployed = false - - $0.preVerificationGas = Data(hexString: "0xbc18")! - $0.verificationGasLimit = Data(hexString: "0x073272")! - } - - $0.privateKey = Data(hexString: "0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")! - $0.transaction = EthereumTransaction.with { - $0.transfer = EthereumTransaction.Transfer.with { - $0.amount = Data(hexString: "0x2386f26fc10000")! - } - } - } - - let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum) - let json = String(data: output.encoded, encoding: .utf8) - - XCTAssertEqual(try input.serializedData().hexString, "0a010512010018022a02558032010f3a0501952f1f85422a3078636536343233353546613535336634303843333461323635304164324634413136333464303333614a20f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8520b0a090a072386f26fc100005ab9010a2a307831333036623031624333653441443230323631324433383433333837653934373337363733463533122a3078354138373230396237353537383163463635664565456464333835356164653033313766346139321a2a307832316363323764376462346661313938353761333730323635336137613637656533306361363230222a3078373864394333326239364262383732443636443531383138323237353633663434653637453233383202bc183a03073272") - XCTAssertEqual(json, "{\"callData\":\"0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"21888\",\"initCode\":\"0x5a87209b755781cf65feeedd3855ade0317f4a925fbfb9cf00000000000000000000000078d9c32b96bb872d66d51818227563f44e67e2380000000000000000000000000000000000000000000000000000000000000000\",\"maxFeePerGas\":\"6797860741\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"48152\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x1560b19d17613ec8580cb0feaf7ac2953771404c5bd7830f585e5062e6ddd4b82ae3bb8dbddb659c0300e8009857b5c77501e1cfd5bbab48d03de0ea7207d07c1b\",\"verificationGasLimit\":\"471666\"}"); - } - - func testEIP4337NativeTransferAccountDeployed() throws { - let input = EthereumSigningInput.with { - $0.txMode = .userOp - $0.chainID = Data(hexString: "05")! - $0.nonce = Data(hexString: "01")! - $0.toAddress = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - - $0.gasLimit = Data(hexString: "0x9d55")! - $0.maxFeePerGas = Data(hexString: "0x01a339c9e9")! - $0.maxInclusionFeePerGas = Data(hexString: "0x0f")! - - $0.userOperation = EthereumUserOperation.with { - $0.entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - $0.accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - $0.accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - $0.owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - $0.isAccountDeployed = true - - $0.preVerificationGas = Data(hexString: "0xb708")! - $0.verificationGasLimit = Data(hexString: "0x0186a0")! - } - - $0.privateKey = Data(hexString: "0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")! - $0.transaction = EthereumTransaction.with { - $0.transfer = EthereumTransaction.Transfer.with { - $0.amount = Data(hexString: "0x2386f26fc10000")! - } - } - } - - let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum) - let json = String(data: output.encoded, encoding: .utf8) - - XCTAssertEqual(try input.serializedData().hexString, "0a010512010118022a029d5532010f3a0501a339c9e9422a3078636536343233353546613535336634303843333461323635304164324634413136333464303333614a20f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8520b0a090a072386f26fc100005abb010a2a307831333036623031624333653441443230323631324433383433333837653934373337363733463533122a3078354138373230396237353537383163463635664565456464333835356164653033313766346139321a2a307832316363323764376462346661313938353761333730323635336137613637656533306361363230222a30783738643943333262393642623837324436364435313831383232373536336634346536374532333828013202b7083a030186a0") - XCTAssertEqual(json, "{\"callData\":\"0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"40277\",\"initCode\":\"0x\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"1\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0xaed2011e5cf267de495b38ecf86ad6f1d4c05217a99e59f47e8d52ba3d41c10144785893fa3e7c116a054999e3902fc2771064d0545148bc49f6d7c827fc7a9a1c\",\"verificationGasLimit\":\"100000\"}"); - } - - func testEIP4337ERC20TransferAccountDeployed() throws { - let input = EthereumSigningInput.with { - $0.txMode = .userOp - $0.chainID = Data(hexString: "05")! - $0.nonce = Data(hexString: "06")! - $0.toAddress = "0x98339d8c260052b7ad81c28c16c0b98420f2b46a" - - $0.gasLimit = Data(hexString: "0xf78e")! - $0.maxFeePerGas = Data(hexString: "0x168ad5950f")! - $0.maxInclusionFeePerGas = Data(hexString: "0x0f")! - - - $0.userOperation = EthereumUserOperation.with { - $0.entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - $0.accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - $0.accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - $0.owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - $0.isAccountDeployed = true - - $0.preVerificationGas = Data(hexString: "0xbb10")! - $0.verificationGasLimit = Data(hexString: "0x0186a0")! - } - - $0.privateKey = Data(hexString: "0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")! - $0.transaction = EthereumTransaction.with { - $0.erc20Transfer = EthereumTransaction.ERC20Transfer.with { - $0.to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - $0.amount = Data(hexString: "0x0186a0")! - } - } - } - - let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum) - let json = String(data: output.encoded, encoding: .utf8) - - XCTAssertEqual(json, "{\"callData\":\"0xb61d27f600000000000000000000000098339d8c260052b7ad81c28c16c0b98420f2b46a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"63374\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"6\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"47888\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0xd006c93d6a8753b5e7c1e6349de0dea34eab2e7a533106e0f2e1a3a3b013c8e97b007546dab9d7b8fc471ad14ff2e8aa351dc4f1ecb63bf20f33858dc7366cbe1c\",\"verificationGasLimit\":\"100000\"}"); - } - - func testEIP4337ERC20ApproveAccountDeployed() throws { - let input = EthereumSigningInput.with { - $0.txMode = .userOp - $0.chainID = Data(hexString: "05")! - $0.nonce = Data(hexString: "09")! - $0.toAddress = "0x98339d8c260052b7ad81c28c16c0b98420f2b46a" - - $0.gasLimit = Data(hexString: "0xf78e")! - $0.maxFeePerGas = Data(hexString: "0x168ad5950f")! - $0.maxInclusionFeePerGas = Data(hexString: "0x0f")! - - $0.userOperation = EthereumUserOperation.with { - $0.entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - $0.accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - $0.accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - $0.owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - $0.isAccountDeployed = true - - $0.preVerificationGas = Data(hexString: "0xbb10")! - $0.verificationGasLimit = Data(hexString: "0x0186a0")! - } - - $0.privateKey = Data(hexString: "0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")! - $0.transaction = EthereumTransaction.with { - $0.erc20Approve = EthereumTransaction.ERC20Approve.with { - $0.spender = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - $0.amount = Data(hexString: "0x0186a0")! - } - } - } - - let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum) - let json = String(data: output.encoded, encoding: .utf8) - - XCTAssertEqual(json, "{\"callData\":\"0xb61d27f600000000000000000000000098339d8c260052b7ad81c28c16c0b98420f2b46a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"63374\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"9\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"47888\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x262a67dd8cf3d16a72b7809b3b5ed55e9f4c2b93eedd5a3c6be035fbbd7111164464ec933d0fdfa359e266e318f3ac22702ae428ce14fc142e4475603e6ec15e1c\",\"verificationGasLimit\":\"100000\"}"); - } - - func testEIP4337ERC721TransferAccountDeployed() throws { - let input = EthereumSigningInput.with { - $0.txMode = .userOp - $0.chainID = Data(hexString: "05")! - $0.nonce = Data(hexString: "0x0C")! - $0.toAddress = "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b" - - $0.gasLimit = Data(hexString: "0x60B378")! - $0.maxFeePerGas = Data(hexString: "0x168ad5950f")! - $0.maxInclusionFeePerGas = Data(hexString: "0x0f")! - - $0.userOperation = EthereumUserOperation.with { - $0.entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - $0.accountFactory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92" - $0.accountLogic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620" - $0.owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - $0.isAccountDeployed = true - - $0.preVerificationGas = Data(hexString: "0xC34F")! - $0.verificationGasLimit = Data(hexString: "0x16E360")! - } - - $0.privateKey = Data(hexString: "0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")! - $0.transaction = EthereumTransaction.with { - $0.erc721Transfer = EthereumTransaction.ERC721Transfer.with { - $0.from = "0x8cE23B8769ac01d0df0d5f47Be1A38FeA97F3879" - $0.to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - $0.tokenID = Data(hexString: "0x2A8E57")! - } - } - } - - let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum) - let json = String(data: output.encoded, encoding: .utf8) - - XCTAssertEqual(json, "{\"callData\":\"0xb61d27f6000000000000000000000000f5de760f2e916647fd766b4ad9e85ff943ce3a2b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006423b872dd0000000000000000000000008ce23b8769ac01d0df0d5f47be1a38fea97f3879000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000002a8e5700000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"6337400\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"12\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"49999\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x5951cc161a4d60d6b59503efb93e446f5d1a2e3a41d4503ba6393bcf2a2637340d0a865ed5d4d7650a68cbb95915eaa7ed54fd2c42b4bf7c83376f5c5d70691d1b\",\"verificationGasLimit\":\"1500000\"}"); - } - - func testEIP4337ERC1155TransferAccountDeployed() throws { - let input = EthereumSigningInput.with { - $0.txMode = .userOp - $0.chainID = Data(hexString: "05")! - $0.nonce = Data(hexString: "0x")! - $0.toAddress = "0x428ce4b916332e1afccfddce08baecc97cb40b12" - - $0.gasLimit = Data(hexString: "0x60B378")! - $0.maxFeePerGas = Data(hexString: "0x168ad5950f")! - $0.maxInclusionFeePerGas = Data(hexString: "0x0f")! - - $0.userOperation = EthereumUserOperation.with { - $0.entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53" - $0.accountFactory = "0x76627b8D1E01fAF0C73B69625BC1fCb8FA19a2AD" - $0.accountLogic = "0x510ab68bd111ce7115df797118b0334d727d564b" - $0.owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238" - $0.isAccountDeployed = true - - $0.preVerificationGas = Data(hexString: "0xC738")! - $0.verificationGasLimit = Data(hexString: "0x16E360")! - } - - $0.privateKey = Data(hexString: "0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")! - $0.transaction = EthereumTransaction.with { - $0.erc1155Transfer = EthereumTransaction.ERC1155Transfer.with { - $0.from = "0x8c560E00680b973645900528EDe71a99b8d4dca8" - $0.to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a" - $0.tokenID = Data(hexString: "0x01")! - $0.value = Data(hexString: "0x")! - $0.data = Data(hexString: "0x")! - } - } - } - - let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum) - let json = String(data: output.encoded, encoding: .utf8) - - XCTAssertEqual(json, "{\"callData\":\"0xb61d27f6000000000000000000000000428ce4b916332e1afccfddce08baecc97cb40b120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c4f242432a0000000000000000000000008c560e00680b973645900528ede71a99b8d4dca8000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"6337400\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"51000\",\"sender\":\"0x8c560e00680b973645900528ede71a99b8d4dca8\",\"signature\":\"0xaae38bcf9f946921541b44c2a66596968beecb9420471e2c9c531f758a2d652930ffdeeab95742e57e8520fb5c8ca4fee6a8e47e37336d4201fe104103f85e111c\",\"verificationGasLimit\":\"1500000\"}"); - } } diff --git a/tests/chains/Ethereum/BarzTests.cpp b/tests/chains/Ethereum/BarzTests.cpp index 4e9c150f4fd..d1d4e212956 100644 --- a/tests/chains/Ethereum/BarzTests.cpp +++ b/tests/chains/Ethereum/BarzTests.cpp @@ -10,28 +10,81 @@ #include #include #include +#include "proto/Ethereum.pb.h" +#include "HexCoding.h" +#include namespace TW::Barz::tests { -TEST(EthereumEip4337, GetCounterfactualAddressFromPublicKey) { +// https://testnet.bscscan.com/tx/0x434f5861b7d14b3bf790b57e5eb1be98355d77f528defe732f2994fc9d6d3f2e +TEST(Barz, GetInitCodeFromPublicKey) { + // C++ + { + const std::string& factoryAddress = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800"; + const std::string& publicKey = "0x1dba683ee34242c993f7588c30099969a1e58e64bdd0657958ced8e4220f69678a77e6fdf4633151105bdb1a9dd419fbd65f7d8b7a39923757534d4a578e9b58"; + const std::string& verificationFacetAddress = "0x6BF22ff186CC97D88ECfbA47d1473a234CEBEFDf"; + + const auto& initCode = Barz::getInitCodeFromPublicKey(factoryAddress, publicKey, verificationFacetAddress); + ASSERT_EQ(hexEncoded(initCode), "0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000006bf22ff186cc97d88ecfba47d1473a234cebefdf0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000401dba683ee34242c993f7588c30099969a1e58e64bdd0657958ced8e4220f69678a77e6fdf4633151105bdb1a9dd419fbd65f7d8b7a39923757534d4a578e9b58"); + } + + // C + { + const auto factoryAddress = STRING("0x3fC708630d85A3B5ec217E53100eC2b735d4f800"); + const auto publicKey = STRING("0x1dba683ee34242c993f7588c30099969a1e58e64bdd0657958ced8e4220f69678a77e6fdf4633151105bdb1a9dd419fbd65f7d8b7a39923757534d4a578e9b58"); + const auto verificationFacetAddress = STRING("0x6BF22ff186CC97D88ECfbA47d1473a234CEBEFDf"); + + const auto& initCodeData = TWBarzGetInitCodeFromPublicKey(factoryAddress.get(), publicKey.get(), verificationFacetAddress.get()); + const auto& initCode = hexEncoded(*reinterpret_cast(WRAPD(initCodeData).get())); + EXPECT_EQ(initCode, "0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000006bf22ff186cc97d88ecfba47d1473a234cebefdf0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000401dba683ee34242c993f7588c30099969a1e58e64bdd0657958ced8e4220f69678a77e6fdf4633151105bdb1a9dd419fbd65f7d8b7a39923757534d4a578e9b58"); + } +} + +// https://testnet.bscscan.com/tx/0x6c6e1fe81c722c0abce1856b9b4e078ab2cad06d51f2d1b04945e5ba2286d1b4 +TEST(Barz, GetInitCodeFromAttestationObject) { + // C++ + { + const std::string& factoryAddress = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800"; + const std::string& attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d0000000000000000000000000000000000000000001464193b58d01d4047694ba4634750047a5fcd637ea5010203262001215820e6f4e0351e2f556fd7284a9a033832bae046ac31fd529ad02ab6220870624b79225820eb760e718fdaed7a037dd1d77a561759cee9f2706eb55a729dc953e0d5719b02"; + const std::string& verificationFacetAddress = "0x6BF22ff186CC97D88ECfbA47d1473a234CEBEFDf"; + + const auto& initCode = Barz::getInitCodeFromAttestationObject(factoryAddress, attestationObject, verificationFacetAddress); + ASSERT_EQ(hexEncoded(initCode), "0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000006bf22ff186cc97d88ecfba47d1473a234cebefdf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040e6f4e0351e2f556fd7284a9a033832bae046ac31fd529ad02ab6220870624b79eb760e718fdaed7a037dd1d77a561759cee9f2706eb55a729dc953e0d5719b02"); + } + + // C + { + const auto factoryAddress = STRING("0x3fC708630d85A3B5ec217E53100eC2b735d4f800"); + const auto attestationObject = STRING("0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d0000000000000000000000000000000000000000001464193b58d01d4047694ba4634750047a5fcd637ea5010203262001215820e6f4e0351e2f556fd7284a9a033832bae046ac31fd529ad02ab6220870624b79225820eb760e718fdaed7a037dd1d77a561759cee9f2706eb55a729dc953e0d5719b02"); + const auto verificationFacetAddress = STRING("0x6BF22ff186CC97D88ECfbA47d1473a234CEBEFDf"); + + const auto& initCodeData = TWBarzGetInitCodeFromAttestationObject(factoryAddress.get(), attestationObject.get(), verificationFacetAddress.get()); + const auto& initCode = hexEncoded(*reinterpret_cast(WRAPD(initCodeData).get())); + EXPECT_EQ(initCode, "0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000006bf22ff186cc97d88ecfba47d1473a234cebefdf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040e6f4e0351e2f556fd7284a9a033832bae046ac31fd529ad02ab6220870624b79eb760e718fdaed7a037dd1d77a561759cee9f2706eb55a729dc953e0d5719b02"); + } +} + +// https://testnet.bscscan.com/address/0x5d51930e0ce5cc08a67a1763fadb66892c0994d1 +TEST(Barz, GetCounterfactualAddressFromPublicKey) { TW::Barz::Proto::ContractAddressInput input; - input.set_factory("0xb7f8bc63bbcad18155201308c8f3540b07f84f5e"); - input.set_diamond_cut_facet("0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9"); - input.set_account_facet("0xdc64a140aa3e981100a9beca4e685f962f0cf6c9"); - input.set_verification_facet("0x5fc8d32690cc91d4c39d9d3abcbd16989f875707"); - input.set_entry_point("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"); - input.set_security_manager("0xe7f1725e7734ce288f8367e1bb143e90bb3f0512"); - input.set_facet_registry("0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0"); - input.set_bytecode("0x60808060405261127d80380380916100178285610943565b833981019060e0818303126108de5761002f81610966565b9161003c60208301610966565b9161004960408201610966565b9161005660608301610966565b9161006360808201610966565b61006f60a08301610966565b60c083015190926001600160401b0382116108de570183601f820112156108de57805161009b8161097a565b946100a96040519687610943565b818652602082840101116108de576100c79160208087019101610995565b604051633253960f60e01b815260208160048160006001600160a01b038b165af19081156108eb576000916108a3575b506001600160e01b031981161561085f576040979695975196610119886108f7565b6002885260005b6040811061082b57509161026693916102749695936040519061014282610928565b60018252602036818401376040519161015a83610928565b60018352602036818501376307e4c70760e21b610176826109b8565b5260405191610184836108f7565b6001600160a01b031682526000602083015260408201526101a48b6109b8565b526101ae8a6109b8565b506001600160e01b031982166101c3826109b8565b52604051906101d1826108f7565b6001600160a01b038c1682526000602083015260408201526101f28a6109db565b526101fc896109db565b506001805464ffffffff00191660d89290921c64ffffffff0016919091179055604051634a93641760e01b60208201526001600160a01b03958616602482015298851660448a015284166064890152909216608487015260a060a4870152859160c48301906109ff565b03601f198101855284610943565b6000915b805183101561070457602061028d84836109eb565b51015160038110156106ee578061041457506001600160a01b036102b184836109eb565b5151169160406102c185846109eb565b510151916102d183511515610a49565b6102dc841515610aa9565b6001600160a01b038416600090815260008051602061125d83398151915260205260409020546001600160601b0316918215610406575b6000925b84518410156103ec576001600160e01b031961033385876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031661038157816103708861037b9461037594610c3b565b610b0a565b93610a24565b92610317565b60405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c72656164792065786973747300000000000000000000006064820152608490fd5b509491509492506103fe91505b610a24565b919092610278565b61040f85610b49565b610313565b9193916001810361058d57506001600160a01b0361043284836109eb565b51511693604061044285846109eb565b5101519161045283511515610a49565b61045d861515610aa9565b6001600160a01b038616600090815260008051602061125d83398151915260205260409020546001600160601b031691821561057f575b6000925b845184101561056f576001600160e01b03196104b485876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031691898314610504576103708a82846104f9610375966104fe98610d26565b610c3b565b92610498565b60405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608490fd5b5094915094506103fe9150610a24565b61058887610b49565b610494565b600203610699576001600160a01b036105a684836109eb565b5151169360406105b685846109eb565b510151946105c686511515610a49565b61062e5760005b85518110156106215761061c906103f96001600160e01b03196105f0838a6109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b0316610d26565b6105cd565b50926103fe919450610a24565b60405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d7573742062652061646472657373283029000000000000000000006064820152608490fd5b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b8382604051606081016060825284518091526080820190602060808260051b8501019601916000905b828210610793576001600160a01b0386166020860152848803604086015261078587877f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673888061077d8e866109ff565b0390a161101f565b60405160e2908161113b8239f35b848803607f19018152835180516001600160a01b03168952602081015194989394929391929060038210156106ee576040916020840152015190606060408201526020608060608301928451809452019201906000905b8082106108085750505060208060019299019201920190929161072d565b82516001600160e01b0319168452602093840193909201916001909101906107ea565b60209060409a98999a5161083e816108f7565b600081526000838201526060604082015282828d0101520198979698610120565b606460405162461bcd60e51b815260206004820152602060248201527f4261727a3a20496e76616c696420566572696669636174696f6e2046616365746044820152fd5b90506020813d6020116108e3575b816108be60209383610943565b810103126108de57516001600160e01b0319811681036108de57386100f7565b600080fd5b3d91506108b1565b6040513d6000823e3d90fd5b606081019081106001600160401b0382111761091257604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b0382111761091257604052565b601f909101601f19168101906001600160401b0382119082101761091257604052565b51906001600160a01b03821682036108de57565b6001600160401b03811161091257601f01601f191660200190565b60005b8381106109a85750506000910152565b8181015183820152602001610998565b8051156109c55760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156109c55760400190565b80518210156109c55760209160051b010190565b90602091610a1881518092818552858086019101610995565b601f01601f1916010190565b6000198114610a335760010190565b634e487b7160e01b600052601160045260246000fd5b15610a5057565b60405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b6064820152608490fd5b15610ab057565b60405162461bcd60e51b815260206004820152602c60248201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260448201526b65206164647265737328302960a01b6064820152608490fd5b6001600160601b03908116908114610a335760010190565b60008051602061123d83398151915280548210156109c55760005260206000200190600090565b610b95604051610b58816108f7565b602481527f4c69624469616d6f6e644375743a204e657720666163657420686173206e6f20602082015263636f646560e01b60408201528261110d565b60008051602061123d83398151915280546001600160a01b038316600090815260008051602061125d833981519152602052604090206001018190559190680100000000000000008310156109125782610bf7916001610c1695019055610b22565b90919082549060031b9160018060a01b03809116831b921b1916179055565b565b91909180548310156109c557600052601c60206000208360031c019260021b1690565b6001600160e01b03198116600081815260008051602061121d83398151915260208190526040822080546001600160a01b031660a09690961b6001600160a01b031916959095179094559194939092906001600160a01b031680835260008051602061125d8339815191526020526040832080549194919068010000000000000000821015610d125796610cdc8260409798996001610cf995018155610c18565b90919063ffffffff83549160031b9260e01c831b921b1916179055565b82526020522080546001600160a01b0319169091179055565b634e487b7160e01b85526041600452602485fd5b9091906001600160a01b039081168015610fb457308114610f585763ffffffff60e01b80941660009281845260008051602061121d833981519152926020918483526040948587205460a01c9083885260008051602061125d8339815191529586865287892054926000199b8c8501948511610f4457908991888c898c89808703610ed6575b505090525050508787525087892080548015610ec2578c0190610dcf8282610c18565b63ffffffff82549160031b1b191690555588528452868681205515610df9575b5050505050509050565b60008051602061123d8339815191528054898101908111610eae57838852858552826001888a20015491808303610e7c575b5050508054988915610e685760019798990191610e4783610b22565b909182549160031b1b19169055558552528220015580388080808080610def565b634e487b7160e01b88526031600452602488fd5b610e8590610b22565b90549060031b1c16610e9a81610bf784610b22565b885285855260018789200155388281610e2b565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b8b52603160045260248bfd5b610f379784610cdc93610ef58a9487610f0b9952828a52848420610c18565b90549060031b1c60e01b97889683525220610c18565b168b52838852898b2080546001600160a01b031660a09290921b6001600160a01b031916919091179055565b873880888c898c89610dac565b634e487b7160e01b8b52601160045260248bfd5b60405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608490fd5b60405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608490fd5b6001600160a01b038116919082156111085760008091611085604051611044816108f7565b602881527f4c69624469616d6f6e644375743a205f696e6974206164647265737320686173602082015267206e6f20636f646560c01b60408201528261110d565b83519060208501905af4913d15611100573d926110a18461097a565b936110af6040519586610943565b84523d6000602086013e5b156110c457505050565b8251156110d357825160208401fd5b6110fc60405192839263192105d760e01b845260048401526040602484015260448301906109ff565b0390fd5b6060926110ba565b505050565b3b156111165750565b60405162461bcd60e51b8152602060048201529081906110fc9060248301906109ff56fe6080604052361560aa57600080356001600160e01b03191681527f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f60205260408120546001600160a01b03168015606c57818091368280378136915af43d82803e156068573d90f35b3d90fd5b62461bcd60e51b6080526020608452602060a4527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460c45260646080fd5b00fea26469706673582212203df3feea7f1aa6ea31eb82d2ad84790e47617c094ced4ce17015a8a7487295da64736f6c63430008120033183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4921183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4920"); + input.set_factory("0x3fC708630d85A3B5ec217E53100eC2b735d4f800"); + input.set_diamond_cut_facet("0x312382b3B302bDcC0711fe710314BE298426296f"); + input.set_account_facet("0x84E684272903737d807375197f9a581FEa094Bc3"); + input.set_verification_facet("0xDcfbDE24847FdF29E6d0311f4bAEb2b49ae8B5a3"); + input.set_entry_point("0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"); + input.set_diamond_loupe_facet("0x518834B7EE4461d703ED2de8bCdfC5eCf761bBCA"); + input.set_diamond_init("0x02a3C76D089c50615139B904c4dbD62F20e74a1b"); + input.set_facet_registry("0x77A4259d76897bA1eC8D6c3EFc5c35e0D7572A8f"); + input.set_bytecode("0x608060405260405162003cc638038062003cc68339818101604052810190620000299190620019ad565b60008673ffffffffffffffffffffffffffffffffffffffff16633253960f6040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000079573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009f919062001aec565b9050600060e01b817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603620000fe576040517f5a5b4d3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600267ffffffffffffffff8111156200011e576200011d6200196b565b5b6040519080825280602002602001820160405280156200015b57816020015b62000147620018ff565b8152602001906001900390816200013d5790505b5090506000600167ffffffffffffffff8111156200017e576200017d6200196b565b5b604051908082528060200260200182016040528015620001ad5781602001602082028036833780820191505090505b5090506000600167ffffffffffffffff811115620001d057620001cf6200196b565b5b604051908082528060200260200182016040528015620001ff5781602001602082028036833780820191505090505b509050631f931c1c60e01b8260008151811062000221576200022062001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808d73ffffffffffffffffffffffffffffffffffffffff16815260200160006002811115620002ab57620002aa62001b37565b5b81526020018381525083600081518110620002cb57620002ca62001b21565b5b60200260200101819052508381600081518110620002ee57620002ed62001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020016000600281111562000378576200037762001b37565b5b8152602001828152508360018151811062000398576200039762001b21565b5b6020026020010181905250620003b9846200047e60201b620001671760201c565b6200046c838c8b8e8e8d8d8d8d604051602401620003de979695949392919062001b8c565b6040516020818303038152906040527f95a21aec000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050620004b060201b620001911760201c565b5050505050505050505050506200211f565b806200048f6200073460201b60201c565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b8351811015620006df576000848281518110620004d557620004d462001b21565b5b602002602001015160200151905060006002811115620004fa57620004f962001b37565b5b81600281111562000510576200050f62001b37565b5b0362000570576200056a85838151811062000530576200052f62001b21565b5b60200260200101516000015186848151811062000552576200055162001b21565b5b6020026020010151604001516200073960201b60201c565b620006c8565b6001600281111562000587576200058662001b37565b5b8160028111156200059d576200059c62001b37565b5b03620005fd57620005f7858381518110620005bd57620005bc62001b21565b5b602002602001015160000151868481518110620005df57620005de62001b21565b5b602002602001015160400151620009db60201b60201c565b620006c7565b60028081111562000613576200061262001b37565b5b81600281111562000629576200062862001b37565b5b0362000689576200068385838151811062000649576200064862001b21565b5b6020026020010151600001518684815181106200066b576200066a62001b21565b5b60200260200101516040015162000c8f60201b60201c565b620006c6565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620006bd9062001be7565b60405180910390fd5b5b5b508080620006d69062001c61565b915050620004b3565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673838383604051620007159392919062001c82565b60405180910390a16200072f828262000e3760201b60201c565b505050565b600090565b600081511162000780576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007779062001d97565b60405180910390fd5b60006200079262000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000806576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007fd9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036200087c576200087b828562000f9860201b60201c565b5b60005b8351811015620009d4576000848281518110620008a157620008a062001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161462000998576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200098f9062001e5f565b60405180910390fd5b620009ac8583868a6200107c60201b60201c565b8380620009b99062001ec3565b94505050508080620009cb9062001c61565b9150506200087f565b5050505050565b600081511162000a22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a199062001d97565b60405180910390fd5b600062000a3462000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000aa8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a9f9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff160362000b1e5762000b1d828562000f9860201b60201c565b5b60005b835181101562000c8857600084828151811062000b435762000b4262001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160362000c39576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000c309062001eef565b60405180910390fd5b62000c4c8582846200122960201b60201c565b62000c608583868a6200107c60201b60201c565b838062000c6d9062001ec3565b9450505050808062000c7f9062001c61565b91505062000b21565b5050505050565b600081511162000cd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000ccd9062001d97565b60405180910390fd5b600062000ce862000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161462000d5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000d539062001f53565b60405180910390fd5b60005b825181101562000e3157600083828151811062000d815762000d8062001b21565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905062000e198482846200122960201b60201c565b5050808062000e289062001c61565b91505062000d5f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16031562000f675762000e988260405180606001604052806028815260200162003c7a60289139620018aa60201b60201c565b6000808373ffffffffffffffffffffffffffffffffffffffff168360405162000ec2919062001fb7565b600060405180830381855af49150503d806000811462000eff576040519150601f19603f3d011682016040523d82523d6000602084013e62000f04565b606091505b50915091508162000f645760008151111562000f235780518082602001fd5b83836040517f192105d700000000000000000000000000000000000000000000000000000000815260040162000f5b92919062001fd7565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b62000fc38160405180606001604052806024815260200162003ca260249139620018aa60201b60201c565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200129b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620012929062002003565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200130c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013039062002067565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050620013e59190620020cb565b9050808214620015805760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000182815481106200144a576200144962001b21565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018481548110620014c957620014c862001b21565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805480620015d757620015d6620020ec565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff0219169055505060008103620018a357600060018660020180549050620016c49190620020cb565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146200180c57600087600201838154811062001732576200173162001b21565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811062001779576200177862001b21565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b86600201805480620018235762001822620020ec565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b9050600081118290620018f9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620018f0919062002102565b60405180910390fd5b50505050565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600060028111156200193e576200193d62001b37565b5b8152602001606081525090565b60008151905060018060a01b03811681146200196657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620019a157808201518184015260208101905062001984565b50600083830152505050565b600080600080600080600080610100898b031215620019cb57600080fd5b620019d6896200194b565b9750620019e660208a016200194b565b9650620019f660408a016200194b565b955062001a0660608a016200194b565b945062001a1660808a016200194b565b935062001a2660a08a016200194b565b925062001a3660c08a016200194b565b915060e089015160018060401b038082111562001a5257600080fd5b818b0191508b601f83011262001a6757600080fd5b81518181111562001a7d5762001a7c6200196b565b5b601f1960405181603f83601f860116011681019150808210848311171562001aaa5762001aa96200196b565b5b816040528281528e602084870101111562001ac457600080fd5b62001ad783602083016020880162001981565b80955050505050509295985092959890939650565b60006020828403121562001aff57600080fd5b815163ffffffff60e01b8116811462001b1757600080fd5b8091505092915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60018060a01b03811682525050565b6000815180845262001b7681602086016020860162001981565b6020601f19601f83011685010191505092915050565b600060018060a01b03808a168352808916602084015280881660408401528087166060840152808616608084015280851660a08401525060e060c083015262001bd960e083018462001b5c565b905098975050505050505050565b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b60008019820362001c775762001c7662001c4b565b5b600182019050919050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101562001d6357607f198a8503018652815188850160018060a01b038251168652848201516003811062001cf157634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b8083101562001d465763ffffffff60e01b84511682528682019150868401935060018301925062001d1a565b508096505050508282019150828601955060018101905062001cab565b505062001d738189018b62001b4d565b50868103604088015262001d88818962001b5c565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b600060018060601b0380831681810362001ee25762001ee162001c4b565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825162001fcb81846020870162001981565b80830191505092915050565b60018060a01b038316815260406020820152600062001ffa604083018462001b5c565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115620020e657620020e562001c4b565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b60208152600062002117602083018462001b5c565b905092915050565b611b4b806200212f6000396000f3fe60806040523661000b57005b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f9050809150600082600001600080357fffffffff00000000000000000000000000000000000000000000000000000000167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610141576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610138906114d3565b60405180910390fd5b3660008037600080366000845af43d6000803e8060008114610162573d6000f35b3d6000fd5b806101706103c0565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b83518110156103755760008482815181106101b2576101b1611510565b5b6020026020010151602001519050600060028111156101d4576101d3611526565b5b8160028111156101e7576101e6611526565b5b036102375761023285838151811061020257610201611510565b5b60200260200101516000015186848151811061022157610220611510565b5b6020026020010151604001516103c5565b610361565b6001600281111561024b5761024a611526565b5b81600281111561025e5761025d611526565b5b036102ae576102a985838151811061027957610278611510565b5b60200260200101516000015186848151811061029857610297611510565b5b60200260200101516040015161063c565b610360565b6002808111156102c1576102c0611526565b5b8160028111156102d4576102d3611526565b5b036103245761031f8583815181106102ef576102ee611510565b5b60200260200101516000015186848151811061030e5761030d611510565b5b6020026020010151604001516108bd565b61035f565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103569061153c565b60405180910390fd5b5b5b50808061036d906115b6565b915050610194565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103a99392919061163b565b60405180910390a16103bb8282610a48565b505050565b600090565b6000815111610409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040090611747565b60405180910390fd5b6000610413610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047b906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036104f1576104f08285610b97565b5b60005b835181101561063557600084828151811061051257610511611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610606576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105fd9061180f565b60405180910390fd5b6106128583868a610c72565b838061061d90611873565b9450505050808061062d906115b6565b9150506104f4565b5050505050565b6000815111610680576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067790611747565b60405180910390fd5b600061068a610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f2906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff1603610768576107678285610b97565b5b60005b83518110156108b657600084828151811061078957610788611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361087c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610873906118a2565b60405180910390fd5b610887858284610e1f565b6108938583868a610c72565b838061089e90611873565b945050505080806108ae906115b6565b91505061076b565b5050505050565b6000815111610901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f890611747565b60405180910390fd5b600061090b610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461097c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097390611906565b60405180910390fd5b60005b8251811015610a4257600083828151811061099d5761099c611510565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610a2d848284610e1f565b50508080610a3a906115b6565b91505061097f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160315610b6657610a9f82604051806060016040528060288152602001611aca60289139611481565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610ac7919061196a565b600060405180830381855af49150503d8060008114610b02576040519150601f19603f3d011682016040523d82523d6000602084013e610b07565b606091505b509150915081610b6357600081511115610b245780518082602001fd5b83836040517f192105d7000000000000000000000000000000000000000000000000000000008152600401610b5a929190611988565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b610bb981604051806060016040528060248152602001611af260249139611481565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610e8e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e85906119b2565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610efc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef390611a16565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050610fd39190611a7a565b90508082146111675760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001828154811061103457611033611510565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000184815481106110b0576110af611510565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054806111bb576111ba611a98565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff021916905550506000810361147a576000600186600201805490506112a59190611a7a565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146113e657600087600201838154811061130f5761130e611510565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811061135357611352611510565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b866002018054806113fa576113f9611a98565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b90506000811182906114cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c49190611aae565b60405180910390fd5b50505050565b602081526020808201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460408201526000606082019050919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b6000801982036115c9576115c86115a0565b5b600182019050919050565b60018060a01b03811682525050565b60005b838110156116015780820151818401526020810190506115e6565b50600083830152505050565b600081518084526116258160208601602086016115e3565b6020601f19601f83011685010191505092915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101561171757607f198a8503018652815188850160018060a01b03825116865284820151600381106116a857634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b808310156116fb5763ffffffff60e01b8451168252868201915086840193506001830192506116d1565b5080965050505082820191508286019550600181019050611664565b50506117258189018b6115d4565b508681036040880152611738818961160d565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b60006bffffffffffffffffffffffff808316818103611895576118946115a0565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825161197c8184602087016115e3565b80830191505092915050565b60018060a01b03831681526040602082015260006119a9604083018461160d565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115611a9257611a916115a0565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b602081526000611ac1602083018461160d565b90509291505056fe4c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465a264697066735822122045b771fb2128a1a34c5b052e9a86464933844b34929cf0d65bbea6a4e76e3b2764736f6c634300081200334c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465"); auto owner = TW::Barz::Proto::ContractOwner(); - owner.set_public_key("0x019b4ee7ad22ffd4c215e5f424faf4c75577dc36"); + owner.set_public_key("0xB5547FBdC56DCE45e1B8ef75569916D438e09c46"); *input.mutable_owner() = owner; // C++ { const std::string& address = getCounterfactualAddress(input); - ASSERT_EQ(address, "0xE9C377EFCE644fd54614d77C177c14148502496F"); + ASSERT_EQ(address, "0xb16Db98B365B1f89191996942612B14F1Da4Bd5f"); } // C @@ -39,29 +92,30 @@ TEST(EthereumEip4337, GetCounterfactualAddressFromPublicKey) { const auto inputData = input.SerializeAsString(); const auto inputTWData = WRAPD(TWDataCreateWithBytes((const uint8_t *)inputData.data(), inputData.size())); const auto& result = WRAPS(TWBarzGetCounterfactualAddress(inputTWData.get())); - assertStringsEqual(result, "0xE9C377EFCE644fd54614d77C177c14148502496F"); + assertStringsEqual(result, "0xb16Db98B365B1f89191996942612B14F1Da4Bd5f"); } } -TEST(EthereumEip4337, GetCounterfactualAddressFromAttestationObject) { +TEST(Barz, GetCounterfactualAddressFromAttestationObject) { TW::Barz::Proto::ContractAddressInput input; - input.set_factory("0xb7f8bc63bbcad18155201308c8f3540b07f84f5e"); - input.set_diamond_cut_facet("0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9"); - input.set_account_facet("0xdc64a140aa3e981100a9beca4e685f962f0cf6c9"); - input.set_verification_facet("0x5fc8d32690cc91d4c39d9d3abcbd16989f875707"); - input.set_entry_point("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"); - input.set_security_manager("0xe7f1725e7734ce288f8367e1bb143e90bb3f0512"); - input.set_facet_registry("0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0"); - input.set_bytecode("0x60808060405261127d80380380916100178285610943565b833981019060e0818303126108de5761002f81610966565b9161003c60208301610966565b9161004960408201610966565b9161005660608301610966565b9161006360808201610966565b61006f60a08301610966565b60c083015190926001600160401b0382116108de570183601f820112156108de57805161009b8161097a565b946100a96040519687610943565b818652602082840101116108de576100c79160208087019101610995565b604051633253960f60e01b815260208160048160006001600160a01b038b165af19081156108eb576000916108a3575b506001600160e01b031981161561085f576040979695975196610119886108f7565b6002885260005b6040811061082b57509161026693916102749695936040519061014282610928565b60018252602036818401376040519161015a83610928565b60018352602036818501376307e4c70760e21b610176826109b8565b5260405191610184836108f7565b6001600160a01b031682526000602083015260408201526101a48b6109b8565b526101ae8a6109b8565b506001600160e01b031982166101c3826109b8565b52604051906101d1826108f7565b6001600160a01b038c1682526000602083015260408201526101f28a6109db565b526101fc896109db565b506001805464ffffffff00191660d89290921c64ffffffff0016919091179055604051634a93641760e01b60208201526001600160a01b03958616602482015298851660448a015284166064890152909216608487015260a060a4870152859160c48301906109ff565b03601f198101855284610943565b6000915b805183101561070457602061028d84836109eb565b51015160038110156106ee578061041457506001600160a01b036102b184836109eb565b5151169160406102c185846109eb565b510151916102d183511515610a49565b6102dc841515610aa9565b6001600160a01b038416600090815260008051602061125d83398151915260205260409020546001600160601b0316918215610406575b6000925b84518410156103ec576001600160e01b031961033385876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031661038157816103708861037b9461037594610c3b565b610b0a565b93610a24565b92610317565b60405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c72656164792065786973747300000000000000000000006064820152608490fd5b509491509492506103fe91505b610a24565b919092610278565b61040f85610b49565b610313565b9193916001810361058d57506001600160a01b0361043284836109eb565b51511693604061044285846109eb565b5101519161045283511515610a49565b61045d861515610aa9565b6001600160a01b038616600090815260008051602061125d83398151915260205260409020546001600160601b031691821561057f575b6000925b845184101561056f576001600160e01b03196104b485876109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b031691898314610504576103708a82846104f9610375966104fe98610d26565b610c3b565b92610498565b60405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608490fd5b5094915094506103fe9150610a24565b61058887610b49565b610494565b600203610699576001600160a01b036105a684836109eb565b5151169360406105b685846109eb565b510151946105c686511515610a49565b61062e5760005b85518110156106215761061c906103f96001600160e01b03196105f0838a6109eb565b5116600081815260008051602061121d83398151915260205260409020546001600160a01b0316610d26565b6105cd565b50926103fe919450610a24565b60405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d7573742062652061646472657373283029000000000000000000006064820152608490fd5b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b8382604051606081016060825284518091526080820190602060808260051b8501019601916000905b828210610793576001600160a01b0386166020860152848803604086015261078587877f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673888061077d8e866109ff565b0390a161101f565b60405160e2908161113b8239f35b848803607f19018152835180516001600160a01b03168952602081015194989394929391929060038210156106ee576040916020840152015190606060408201526020608060608301928451809452019201906000905b8082106108085750505060208060019299019201920190929161072d565b82516001600160e01b0319168452602093840193909201916001909101906107ea565b60209060409a98999a5161083e816108f7565b600081526000838201526060604082015282828d0101520198979698610120565b606460405162461bcd60e51b815260206004820152602060248201527f4261727a3a20496e76616c696420566572696669636174696f6e2046616365746044820152fd5b90506020813d6020116108e3575b816108be60209383610943565b810103126108de57516001600160e01b0319811681036108de57386100f7565b600080fd5b3d91506108b1565b6040513d6000823e3d90fd5b606081019081106001600160401b0382111761091257604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b0382111761091257604052565b601f909101601f19168101906001600160401b0382119082101761091257604052565b51906001600160a01b03821682036108de57565b6001600160401b03811161091257601f01601f191660200190565b60005b8381106109a85750506000910152565b8181015183820152602001610998565b8051156109c55760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156109c55760400190565b80518210156109c55760209160051b010190565b90602091610a1881518092818552858086019101610995565b601f01601f1916010190565b6000198114610a335760010190565b634e487b7160e01b600052601160045260246000fd5b15610a5057565b60405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b6064820152608490fd5b15610ab057565b60405162461bcd60e51b815260206004820152602c60248201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260448201526b65206164647265737328302960a01b6064820152608490fd5b6001600160601b03908116908114610a335760010190565b60008051602061123d83398151915280548210156109c55760005260206000200190600090565b610b95604051610b58816108f7565b602481527f4c69624469616d6f6e644375743a204e657720666163657420686173206e6f20602082015263636f646560e01b60408201528261110d565b60008051602061123d83398151915280546001600160a01b038316600090815260008051602061125d833981519152602052604090206001018190559190680100000000000000008310156109125782610bf7916001610c1695019055610b22565b90919082549060031b9160018060a01b03809116831b921b1916179055565b565b91909180548310156109c557600052601c60206000208360031c019260021b1690565b6001600160e01b03198116600081815260008051602061121d83398151915260208190526040822080546001600160a01b031660a09690961b6001600160a01b031916959095179094559194939092906001600160a01b031680835260008051602061125d8339815191526020526040832080549194919068010000000000000000821015610d125796610cdc8260409798996001610cf995018155610c18565b90919063ffffffff83549160031b9260e01c831b921b1916179055565b82526020522080546001600160a01b0319169091179055565b634e487b7160e01b85526041600452602485fd5b9091906001600160a01b039081168015610fb457308114610f585763ffffffff60e01b80941660009281845260008051602061121d833981519152926020918483526040948587205460a01c9083885260008051602061125d8339815191529586865287892054926000199b8c8501948511610f4457908991888c898c89808703610ed6575b505090525050508787525087892080548015610ec2578c0190610dcf8282610c18565b63ffffffff82549160031b1b191690555588528452868681205515610df9575b5050505050509050565b60008051602061123d8339815191528054898101908111610eae57838852858552826001888a20015491808303610e7c575b5050508054988915610e685760019798990191610e4783610b22565b909182549160031b1b19169055558552528220015580388080808080610def565b634e487b7160e01b88526031600452602488fd5b610e8590610b22565b90549060031b1c16610e9a81610bf784610b22565b885285855260018789200155388281610e2b565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b8b52603160045260248bfd5b610f379784610cdc93610ef58a9487610f0b9952828a52848420610c18565b90549060031b1c60e01b97889683525220610c18565b168b52838852898b2080546001600160a01b031660a09290921b6001600160a01b031916919091179055565b873880888c898c89610dac565b634e487b7160e01b8b52601160045260248bfd5b60405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608490fd5b60405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608490fd5b6001600160a01b038116919082156111085760008091611085604051611044816108f7565b602881527f4c69624469616d6f6e644375743a205f696e6974206164647265737320686173602082015267206e6f20636f646560c01b60408201528261110d565b83519060208501905af4913d15611100573d926110a18461097a565b936110af6040519586610943565b84523d6000602086013e5b156110c457505050565b8251156110d357825160208401fd5b6110fc60405192839263192105d760e01b845260048401526040602484015260448301906109ff565b0390fd5b6060926110ba565b505050565b3b156111165750565b60405162461bcd60e51b8152602060048201529081906110fc9060248301906109ff56fe6080604052361560aa57600080356001600160e01b03191681527f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f60205260408120546001600160a01b03168015606c57818091368280378136915af43d82803e156068573d90f35b3d90fd5b62461bcd60e51b6080526020608452602060a4527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460c45260646080fd5b00fea26469706673582212203df3feea7f1aa6ea31eb82d2ad84790e47617c094ced4ce17015a8a7487295da64736f6c63430008120033183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4921183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd4920"); + input.set_factory("0x3fC708630d85A3B5ec217E53100eC2b735d4f800"); + input.set_diamond_cut_facet("0x312382b3B302bDcC0711fe710314BE298426296f"); + input.set_account_facet("0x84E684272903737d807375197f9a581FEa094Bc3"); + input.set_verification_facet("0x5034534Efe9902779eD6eA6983F435c00f3bc510"); + input.set_entry_point("0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"); + input.set_diamond_loupe_facet("0x518834B7EE4461d703ED2de8bCdfC5eCf761bBCA"); + input.set_diamond_init("0x02a3C76D089c50615139B904c4dbD62F20e74a1b"); + input.set_facet_registry("0x77A4259d76897bA1eC8D6c3EFc5c35e0D7572A8f"); + input.set_bytecode("0x608060405260405162003cc638038062003cc68339818101604052810190620000299190620019ad565b60008673ffffffffffffffffffffffffffffffffffffffff16633253960f6040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000079573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009f919062001aec565b9050600060e01b817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603620000fe576040517f5a5b4d3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600267ffffffffffffffff8111156200011e576200011d6200196b565b5b6040519080825280602002602001820160405280156200015b57816020015b62000147620018ff565b8152602001906001900390816200013d5790505b5090506000600167ffffffffffffffff8111156200017e576200017d6200196b565b5b604051908082528060200260200182016040528015620001ad5781602001602082028036833780820191505090505b5090506000600167ffffffffffffffff811115620001d057620001cf6200196b565b5b604051908082528060200260200182016040528015620001ff5781602001602082028036833780820191505090505b509050631f931c1c60e01b8260008151811062000221576200022062001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808d73ffffffffffffffffffffffffffffffffffffffff16815260200160006002811115620002ab57620002aa62001b37565b5b81526020018381525083600081518110620002cb57620002ca62001b21565b5b60200260200101819052508381600081518110620002ee57620002ed62001b21565b5b60200260200101907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152505060405180606001604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020016000600281111562000378576200037762001b37565b5b8152602001828152508360018151811062000398576200039762001b21565b5b6020026020010181905250620003b9846200047e60201b620001671760201c565b6200046c838c8b8e8e8d8d8d8d604051602401620003de979695949392919062001b8c565b6040516020818303038152906040527f95a21aec000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050620004b060201b620001911760201c565b5050505050505050505050506200211f565b806200048f6200073460201b60201c565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b8351811015620006df576000848281518110620004d557620004d462001b21565b5b602002602001015160200151905060006002811115620004fa57620004f962001b37565b5b81600281111562000510576200050f62001b37565b5b0362000570576200056a85838151811062000530576200052f62001b21565b5b60200260200101516000015186848151811062000552576200055162001b21565b5b6020026020010151604001516200073960201b60201c565b620006c8565b6001600281111562000587576200058662001b37565b5b8160028111156200059d576200059c62001b37565b5b03620005fd57620005f7858381518110620005bd57620005bc62001b21565b5b602002602001015160000151868481518110620005df57620005de62001b21565b5b602002602001015160400151620009db60201b60201c565b620006c7565b60028081111562000613576200061262001b37565b5b81600281111562000629576200062862001b37565b5b0362000689576200068385838151811062000649576200064862001b21565b5b6020026020010151600001518684815181106200066b576200066a62001b21565b5b60200260200101516040015162000c8f60201b60201c565b620006c6565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620006bd9062001be7565b60405180910390fd5b5b5b508080620006d69062001c61565b915050620004b3565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb673838383604051620007159392919062001c82565b60405180910390a16200072f828262000e3760201b60201c565b505050565b600090565b600081511162000780576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007779062001d97565b60405180910390fd5b60006200079262000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000806576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007fd9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036200087c576200087b828562000f9860201b60201c565b5b60005b8351811015620009d4576000848281518110620008a157620008a062001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161462000998576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200098f9062001e5f565b60405180910390fd5b620009ac8583868a6200107c60201b60201c565b8380620009b99062001ec3565b94505050508080620009cb9062001c61565b9150506200087f565b5050505050565b600081511162000a22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a199062001d97565b60405180910390fd5b600062000a3462000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160362000aa8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000a9f9062001dfb565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff160362000b1e5762000b1d828562000f9860201b60201c565b5b60005b835181101562000c8857600084828151811062000b435762000b4262001b21565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160362000c39576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000c309062001eef565b60405180910390fd5b62000c4c8582846200122960201b60201c565b62000c608583868a6200107c60201b60201c565b838062000c6d9062001ec3565b9450505050808062000c7f9062001c61565b91505062000b21565b5050505050565b600081511162000cd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000ccd9062001d97565b60405180910390fd5b600062000ce862000f6b60201b60201c565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161462000d5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000d539062001f53565b60405180910390fd5b60005b825181101562000e3157600083828151811062000d815762000d8062001b21565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905062000e198482846200122960201b60201c565b5050808062000e289062001c61565b91505062000d5f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16031562000f675762000e988260405180606001604052806028815260200162003c7a60289139620018aa60201b60201c565b6000808373ffffffffffffffffffffffffffffffffffffffff168360405162000ec2919062001fb7565b600060405180830381855af49150503d806000811462000eff576040519150601f19603f3d011682016040523d82523d6000602084013e62000f04565b606091505b50915091508162000f645760008151111562000f235780518082602001fd5b83836040517f192105d700000000000000000000000000000000000000000000000000000000815260040162000f5b92919062001fd7565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b62000fc38160405180606001604052806024815260200162003ca260249139620018aa60201b60201c565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200129b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620012929062002003565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200130c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013039062002067565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050620013e59190620020cb565b9050808214620015805760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000182815481106200144a576200144962001b21565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018481548110620014c957620014c862001b21565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805480620015d757620015d6620020ec565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff0219169055505060008103620018a357600060018660020180549050620016c49190620020cb565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146200180c57600087600201838154811062001732576200173162001b21565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811062001779576200177862001b21565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b86600201805480620018235762001822620020ec565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b9050600081118290620018f9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620018f0919062002102565b60405180910390fd5b50505050565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600060028111156200193e576200193d62001b37565b5b8152602001606081525090565b60008151905060018060a01b03811681146200196657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620019a157808201518184015260208101905062001984565b50600083830152505050565b600080600080600080600080610100898b031215620019cb57600080fd5b620019d6896200194b565b9750620019e660208a016200194b565b9650620019f660408a016200194b565b955062001a0660608a016200194b565b945062001a1660808a016200194b565b935062001a2660a08a016200194b565b925062001a3660c08a016200194b565b915060e089015160018060401b038082111562001a5257600080fd5b818b0191508b601f83011262001a6757600080fd5b81518181111562001a7d5762001a7c6200196b565b5b601f1960405181603f83601f860116011681019150808210848311171562001aaa5762001aa96200196b565b5b816040528281528e602084870101111562001ac457600080fd5b62001ad783602083016020880162001981565b80955050505050509295985092959890939650565b60006020828403121562001aff57600080fd5b815163ffffffff60e01b8116811462001b1757600080fd5b8091505092915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60018060a01b03811682525050565b6000815180845262001b7681602086016020860162001981565b6020601f19601f83011685010191505092915050565b600060018060a01b03808a168352808916602084015280881660408401528087166060840152808616608084015280851660a08401525060e060c083015262001bd960e083018462001b5c565b905098975050505050505050565b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b60008019820362001c775762001c7662001c4b565b5b600182019050919050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101562001d6357607f198a8503018652815188850160018060a01b038251168652848201516003811062001cf157634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b8083101562001d465763ffffffff60e01b84511682528682019150868401935060018301925062001d1a565b508096505050508282019150828601955060018101905062001cab565b505062001d738189018b62001b4d565b50868103604088015262001d88818962001b5c565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b600060018060601b0380831681810362001ee25762001ee162001c4b565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825162001fcb81846020870162001981565b80830191505092915050565b60018060a01b038316815260406020820152600062001ffa604083018462001b5c565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115620020e657620020e562001c4b565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b60208152600062002117602083018462001b5c565b905092915050565b611b4b806200212f6000396000f3fe60806040523661000b57005b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f9050809150600082600001600080357fffffffff00000000000000000000000000000000000000000000000000000000167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610141576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610138906114d3565b60405180910390fd5b3660008037600080366000845af43d6000803e8060008114610162573d6000f35b3d6000fd5b806101706103c0565b60010160016101000a81548163ffffffff021916908360e01c021790555050565b60005b83518110156103755760008482815181106101b2576101b1611510565b5b6020026020010151602001519050600060028111156101d4576101d3611526565b5b8160028111156101e7576101e6611526565b5b036102375761023285838151811061020257610201611510565b5b60200260200101516000015186848151811061022157610220611510565b5b6020026020010151604001516103c5565b610361565b6001600281111561024b5761024a611526565b5b81600281111561025e5761025d611526565b5b036102ae576102a985838151811061027957610278611510565b5b60200260200101516000015186848151811061029857610297611510565b5b60200260200101516040015161063c565b610360565b6002808111156102c1576102c0611526565b5b8160028111156102d4576102d3611526565b5b036103245761031f8583815181106102ef576102ee611510565b5b60200260200101516000015186848151811061030e5761030d611510565b5b6020026020010151604001516108bd565b61035f565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103569061153c565b60405180910390fd5b5b5b50808061036d906115b6565b915050610194565b507f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738383836040516103a99392919061163b565b60405180910390a16103bb8282610a48565b505050565b600090565b6000815111610409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040090611747565b60405180910390fd5b6000610413610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047b906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff16036104f1576104f08285610b97565b5b60005b835181101561063557600084828151811061051257610511611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610606576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105fd9061180f565b60405180910390fd5b6106128583868a610c72565b838061061d90611873565b9450505050808061062d906115b6565b9150506104f4565b5050505050565b6000815111610680576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067790611747565b60405180910390fd5b600061068a610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f2906117ab565b60405180910390fd5b60008160010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054905090506000816bffffffffffffffffffffffff1603610768576107678285610b97565b5b60005b83518110156108b657600084828151811061078957610788611510565b5b602002602001015190506000846000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361087c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610873906118a2565b60405180910390fd5b610887858284610e1f565b6108938583868a610c72565b838061089e90611873565b945050505080806108ae906115b6565b91505061076b565b5050505050565b6000815111610901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f890611747565b60405180910390fd5b600061090b610b6a565b9050600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461097c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097390611906565b60405180910390fd5b60005b8251811015610a4257600083828151811061099d5761099c611510565b5b602002602001015190506000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610a2d848284610e1f565b50508080610a3a906115b6565b91505061097f565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160315610b6657610a9f82604051806060016040528060288152602001611aca60289139611481565b6000808373ffffffffffffffffffffffffffffffffffffffff1683604051610ac7919061196a565b600060405180830381855af49150503d8060008114610b02576040519150601f19603f3d011682016040523d82523d6000602084013e610b07565b606091505b509150915081610b6357600081511115610b245780518082602001fd5b83836040517f192105d7000000000000000000000000000000000000000000000000000000008152600401610b5a929190611988565b60405180910390fd5b50505b5050565b6000807f183cde5d4f6bb7b445b8fc2f7f15d0fd1d162275aded24183babbffee7cd491f90508091505090565b610bb981604051806060016040528060248152602001611af260249139611481565b81600201805490508260010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555081600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b81846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508360010160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018390806001815401808255809150506001900390600052602060002090600891828204019190066004029091909190916101000a81548163ffffffff021916908360e01c021790555080846000016000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610e8e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e85906119b2565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610efc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef390611a16565b60405180910390fd5b6000836000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050600060018560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000180549050610fd39190611a7a565b90508082146111675760008560010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001828154811061103457611033611510565b5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050808660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000184815481106110b0576110af611510565b5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c021790555082866000016000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060000160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550505b8460010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054806111bb576111ba611a98565b5b60019003818190600052602060002090600891828204019190066004026101000a81549063ffffffff02191690559055846000016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a8154906bffffffffffffffffffffffff021916905550506000810361147a576000600186600201805490506112a59190611a7a565b905060008660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490508181146113e657600087600201838154811061130f5761130e611510565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508088600201838154811061135357611352611510565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818860010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505b866002018054806113fa576113f9611a98565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558660010160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000905550505b5050505050565b6000823b90506000811182906114cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c49190611aae565b60405180910390fd5b50505050565b602081526020808201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460408201526000606082019050919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b60208152602760208201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560408201527f74416374696f6e0000000000000000000000000000000000000000000000000060608201526000608082019050919050565b634e487b7160e01b600052601160045260246000fd5b6000801982036115c9576115c86115a0565b5b600182019050919050565b60018060a01b03811682525050565b60005b838110156116015780820151818401526020810190506115e6565b50600083830152505050565b600081518084526116258160208601602086016115e3565b6020601f19601f83011685010191505092915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101561171757607f198a8503018652815188850160018060a01b03825116865284820151600381106116a857634e487b7160e01b600052602160045260246000fd5b80868801525060408083015192508a81880152508082518083528a880191508684019350600092505b808310156116fb5763ffffffff60e01b8451168252868201915086840193506001830192506116d1565b5080965050505082820191508286019550600181019050611664565b50506117258189018b6115d4565b508681036040880152611738818961160d565b95505050505050949350505050565b60208152602b60208201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660408201527f6163657420746f2063757400000000000000000000000000000000000000000060608201526000608082019050919050565b60208152602c60208201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260408201527f652061646472657373283029000000000000000000000000000000000000000060608201526000608082019050919050565b60208152603560208201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60408201527f6e207468617420616c726561647920657869737473000000000000000000000060608201526000608082019050919050565b60006bffffffffffffffffffffffff808316818103611895576118946115a0565b5b6001810192505050919050565b60208152603860208201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60408201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060608201526000608082019050919050565b60208152603660208201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260408201527f657373206d75737420626520616464726573732830290000000000000000000060608201526000608082019050919050565b6000825161197c8184602087016115e3565b80830191505092915050565b60018060a01b03831681526040602082015260006119a9604083018461160d565b90509392505050565b60208152603760208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360408201527f74696f6e207468617420646f65736e277420657869737400000000000000000060608201526000608082019050919050565b60208152602e60208201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560408201527f7461626c652066756e6374696f6e00000000000000000000000000000000000060608201526000608082019050919050565b6000828203905081811115611a9257611a916115a0565b5b92915050565b634e487b7160e01b600052603160045260246000fd5b602081526000611ac1602083018461160d565b90509291505056fe4c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465a264697066735822122045b771fb2128a1a34c5b052e9a86464933844b34929cf0d65bbea6a4e76e3b2764736f6c634300081200334c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a204e657720666163657420686173206e6f20636f6465"); auto owner = TW::Barz::Proto::ContractOwner(); - owner.set_attestation_object("0xa363666d74646e6f6e656761747453746d74a068617574684461746158a4f95bc73828ee210f9fd3bbe72d97908013b0a3759e9aea3d0ae318766cd2e1ad4500000000adce000235bcc60a648b0b25f1f055030020c720eb493e167ce93183dd91f5661e1004ed8cc1be23d3340d92381da5c0c80ca5010203262001215820a620a8cfc88fd062b11eab31663e56cad95278bef612959be214d98779f645b82258204e7b905b42917570148b0432f99ba21f2e7eebe018cbf837247e38150a89f771"); + owner.set_attestation_object("0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d000000000000000000000000000000000000000000147d0d9cf0634ebd79b5df0c91c7de42c567aac588a50102032620012158207868c62a834763bae747bd9db14d9d159ccd1052a8f81287e3f039c5c9c0f91e225820000e4fc74a22560d3bd22866c6b9fe88c10c170be073d2a838c8019586a7a4eb"); *input.mutable_owner() = owner; // C++ { const std::string& address = getCounterfactualAddress(input); - ASSERT_EQ(address, "0xc3d477e5D4CEd32835574bBAFE51a0A8c9c17272"); + ASSERT_EQ(address, "0x85a6290917d1DC2C507Ff2D545Ba5aF13e964Ba1"); } // C @@ -69,7 +123,106 @@ TEST(EthereumEip4337, GetCounterfactualAddressFromAttestationObject) { const auto inputData = input.SerializeAsString(); const auto inputTWData = WRAPD(TWDataCreateWithBytes((const uint8_t *)inputData.data(), inputData.size())); const auto& result = WRAPS(TWBarzGetCounterfactualAddress(inputTWData.get())); - assertStringsEqual(result, "0xc3d477e5D4CEd32835574bBAFE51a0A8c9c17272"); + assertStringsEqual(result, "0x85a6290917d1DC2C507Ff2D545Ba5aF13e964Ba1"); + } +} + +// https://testnet.bscscan.com/tx/0x43fc13dfdf06bbb09da8ce070953753764f1e43782d0c8b621946d8b45749419 +TEST(Barz, SignK1TransferAccountDeployed) { + TW::Ethereum::Proto::SigningInput input; + auto chainId = store(uint256_t(97)); + auto nonce = store(uint256_t(2)); + auto amount = store(uint256_t(0x2386f26fc10000)); + auto gasLimit = store(uint256_t(0x186A0)); + auto verificationGasLimit = store(uint256_t(0x186a0)); + auto maxFeePerGas = store(uint256_t(0x1a339c9e9)); + auto maxInclusionFeePerGas = store(uint256_t(0x1a339c9e9)); + auto preVerificationGas = store(uint256_t(0xb708)); + auto entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"; + auto sender = "0xb16Db98B365B1f89191996942612B14F1Da4Bd5f"; + auto to = "0x61061fCAE11fD5461535e134EfF67A98CFFF44E9"; + + auto key = parse_hex("0x3c90badc15c4d35733769093d3733501e92e7f16e101df284cee9a310d36c483"); + + input.set_chain_id(chainId.data(), chainId.size()); + input.set_nonce(nonce.data(), nonce.size()); + input.set_tx_mode(TW::Ethereum::Proto::TransactionMode::UserOp); + input.set_gas_limit(gasLimit.data(), gasLimit.size()); + input.set_max_fee_per_gas(maxFeePerGas.data(), maxFeePerGas.size()); + input.set_max_inclusion_fee_per_gas(maxInclusionFeePerGas.data(), maxInclusionFeePerGas.size()); + input.set_to_address(to); + + auto& user_operation = *input.mutable_user_operation(); + user_operation.set_verification_gas_limit(verificationGasLimit.data(), verificationGasLimit.size()); + user_operation.set_pre_verification_gas(preVerificationGas.data(), preVerificationGas.size()); + user_operation.set_entry_point(entryPoint); + user_operation.set_sender(sender); + + input.set_private_key(key.data(), key.size()); + auto& transfer = *input.mutable_transaction()->mutable_transfer(); + transfer.set_amount(amount.data(), amount.size()); + + std::string expected = "{\"callData\":\"0xb61d27f600000000000000000000000061061fcae11fd5461535e134eff67a98cfff44e9000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"100000\",\"initCode\":\"0x\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"7033440745\",\"nonce\":\"2\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0xb16db98b365b1f89191996942612b14f1da4bd5f\",\"signature\":\"0x3d29240a2decf2a1f47c88d1cb5923815ed50d24f8f01a9697e229ba69ce18d13779d2d96a5c93f5df29110677de62e75f4d751ab7baf5830276eb4ca257fb471b\",\"verificationGasLimit\":\"100000\"}"; + + { + // sign test + TW::Ethereum::Proto::SigningOutput output; + ANY_SIGN(input, TWCoinTypeEthereum); + + ASSERT_EQ(hexEncoded(output.pre_hash()), "0x731dd74cbf212bee883c6decbad07ad8980be89ca2e6c64de310af04e562d866"); + ASSERT_EQ(std::string(output.encoded()), expected); + } +} + +// https://testnet.bscscan.com/tx/0xea1f5cddc0653e116327cbcb3bc770360a642891176eff2ec69c227e46791c31 +TEST(Barz, SignR1TransferAccountNotDeployed) { + TW::Ethereum::Proto::SigningInput input; + auto chainId = store(uint256_t(97)); + auto nonce = store(uint256_t(0)); + auto amount = store(uint256_t(0x2386f26fc10000)); + auto gasLimit = store(uint256_t(0x2625A0)); + auto verificationGasLimit = store(uint256_t(0x2DC6C0)); + auto maxFeePerGas = store(uint256_t(0x1a339c9e9)); + auto maxInclusionFeePerGas = store(uint256_t(0x1a339c9e9)); + auto preVerificationGas = store(uint256_t(0xb708)); + auto entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"; + auto sender = "0x1392Ae041BfBdBAA0cFF9234a0C8F64df97B7218"; + auto to = "0x61061fCAE11fD5461535e134EfF67A98CFFF44E9"; + auto factory = "0x3fC708630d85A3B5ec217E53100eC2b735d4f800"; + auto attestationObject = "0xa363666d74646e6f6e656761747453746d74a068617574684461746158981a70842af8c1feb7133b81e6a160a6a2be45ee057f0eb6d3f7f5126daa202e075d00000000000000000000000000000000000000000014c14f8a2dfd8f451581fad6e4e1c11821abcaacd6a5010203262001215820b173a6a812025c40c38bac46343646bd0a8137c807aae6e04aac238cc24d2ad2225820116ca14d23d357588ff2aabd7db29d5976f4ecc8037775db86f67e873a306b1f"; + auto verificationFacet = "0x5034534Efe9902779eD6eA6983F435c00f3bc510"; + auto initCode = TW::Barz::getInitCodeFromAttestationObject(factory, attestationObject, verificationFacet); + + auto key = parse_hex("0x3c90badc15c4d35733769093d3733501e92e7f16e101df284cee9a310d36c483"); + + input.set_chain_id(chainId.data(), chainId.size()); + input.set_nonce(nonce.data(), nonce.size()); + input.set_tx_mode(TW::Ethereum::Proto::TransactionMode::UserOp); + input.set_gas_limit(gasLimit.data(), gasLimit.size()); + input.set_max_fee_per_gas(maxFeePerGas.data(), maxFeePerGas.size()); + input.set_max_inclusion_fee_per_gas(maxInclusionFeePerGas.data(), maxInclusionFeePerGas.size()); + input.set_to_address(to); + + auto& user_operation = *input.mutable_user_operation(); + user_operation.set_verification_gas_limit(verificationGasLimit.data(), verificationGasLimit.size()); + user_operation.set_pre_verification_gas(preVerificationGas.data(), preVerificationGas.size()); + user_operation.set_entry_point(entryPoint); + user_operation.set_sender(sender); + user_operation.set_init_code(initCode.data(), initCode.size()); + + input.set_private_key(key.data(), key.size()); + auto& transfer = *input.mutable_transaction()->mutable_transfer(); + transfer.set_amount(amount.data(), amount.size()); + + std::string expected = "{\"callData\":\"0xb61d27f600000000000000000000000061061fcae11fd5461535e134eff67a98cfff44e9000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"2500000\",\"initCode\":\"0x3fc708630d85a3b5ec217e53100ec2b735d4f800296601cd0000000000000000000000005034534efe9902779ed6ea6983f435c00f3bc510000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040b173a6a812025c40c38bac46343646bd0a8137c807aae6e04aac238cc24d2ad2116ca14d23d357588ff2aabd7db29d5976f4ecc8037775db86f67e873a306b1f\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"7033440745\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0x1392ae041bfbdbaa0cff9234a0c8f64df97b7218\",\"signature\":\"0x670d22e5361a75add1a90f2e86abf23a7e7b860795ca882e33efad17f0c6ff9a5c8e25260c89f1dd2aafba56ba0efdaec6cd976df399f848f443876fdb64867e1c\",\"verificationGasLimit\":\"3000000\"}"; + + { + // sign test + TW::Ethereum::Proto::SigningOutput output; + ANY_SIGN(input, TWCoinTypeEthereum); + + ASSERT_EQ(hexEncoded(output.pre_hash()), "0xb884c13821af6794e2fed1f5906f847251123adde02bd84723b50eda24fe2c93"); + ASSERT_EQ(std::string(output.encoded()), expected); } } diff --git a/tests/chains/Ethereum/EIP4337Tests.cpp b/tests/chains/Ethereum/EIP4337Tests.cpp deleted file mode 100644 index 0d702aabde4..00000000000 --- a/tests/chains/Ethereum/EIP4337Tests.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright © 2017-2023 Trust Wallet. -// -// This file is part of Trust. The full Trust copyright notice, including -// terms governing use, modification, and redistribution, is contained in the -// file LICENSE at the root of the source code distribution tree. - -#include "TestUtilities.h" -#include -#include -#include -#include -#include - -#include - -namespace TW::Ethereum::tests { - -TEST(EthereumEip4337, GetEIP4337AccountInitializeBytecode) { - { - const std::string& ownerAddress = "0x78d9C32b96Bb872D66D51818227563f44e67E238"; - const std::string& factoryAddress = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92"; - const auto& initializeEncoded = Ethereum::getEIP4337AccountInitializeBytecode(ownerAddress, factoryAddress); - ASSERT_EQ(hexEncoded(initializeEncoded), "0x5a87209b755781cf65feeedd3855ade0317f4a925fbfb9cf00000000000000000000000078d9c32b96bb872d66d51818227563f44e67e2380000000000000000000000000000000000000000000000000000000000000000"); - } -} - -TEST(EthereumEip4337, GetEIP4337LogicInitializeBytecode) { - { - const std::string& ownerAddress = "0xA5a1dddEF094095AfB7b6e322dE72961DF2e1988"; - const auto& initializeEncoded = Ethereum::getEIP4337LogicInitializeBytecode(ownerAddress); - ASSERT_EQ(hexEncoded(initializeEncoded), "0xc4d66de8000000000000000000000000a5a1dddef094095afb7b6e322de72961df2e1988"); - } -} - -TEST(EthereumEip4337, GetEIP4337ExecuteBytecode) { - { - const Data& toAddress = parse_hex("0xce642355Fa553f408C34a2650Ad2F4A1634d033a"); - const uint256_t& value = 0x2386f26fc10000; - const Data data = {}; - const auto& executeEncoded = Ethereum::getEIP4337ExecuteBytecode(toAddress, value, data); - ASSERT_EQ(hexEncoded(executeEncoded), "0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"); - } -} - -// -// https://goerli.etherscan.io/address/0x5a87209b755781cf65feeedd3855ade0317f4a92#readContract -TEST(EthereumEip4337, GetEIP4337DeploymentAddress) { - // C++ - { - const std::string& factoryAddress = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92"; - const std::string& logicAddress = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620"; - const std::string& ownerAddress = "0x78d9C32b96Bb872D66D51818227563f44e67E238"; - const std::string& deploymentAddress = Ethereum::getEIP4337DeploymentAddress(factoryAddress, logicAddress, ownerAddress); - ASSERT_EQ(deploymentAddress, "0x8cE23B8769ac01d0df0d5f47Be1A38FeA97F3879"); - } - - // C - { - const auto factoryAddress = STRING("0x5A87209b755781cF65fEeEdd3855ade0317f4a92"); - const auto logicAddress = STRING("0x21cc27d7db4fa19857a3702653a7a67ee30ca620"); - const auto ownerAddress = STRING("0x78d9C32b96Bb872D66D51818227563f44e67E238"); - const auto& result = WRAPS(TWEthereumEip4337GetDeploymentAddress(factoryAddress.get(), logicAddress.get(), ownerAddress.get())); - assertStringsEqual(result, "0x8cE23B8769ac01d0df0d5f47Be1A38FeA97F3879"); - } -} - -} diff --git a/tests/chains/Ethereum/SignerTests.cpp b/tests/chains/Ethereum/SignerTests.cpp index 33973a748ed..524542ff212 100644 --- a/tests/chains/Ethereum/SignerTests.cpp +++ b/tests/chains/Ethereum/SignerTests.cpp @@ -88,13 +88,13 @@ TEST(EthereumSigner, SignERC20Transfer) { TEST(EthereumSigner, EIP1559_1442) { const auto transaction = TransactionEip1559::buildNativeTransfer( - 6, // nonce - 2000000000, // maxInclusionFeePerGas - 3000000000, // maxFeePerGas - 21100, // gasLimit - parse_hex("B9F5771C27664bF2282D98E09D7F50cEc7cB01a7"), - 543210987654321, // amount - Data() // data + /* nonce: */ 6, + /* maxInclusionFeePerGas */ 2000000000, + /* maxFeePerGas */ 3000000000, + /* gasLimit */ 21100, + /* toAddress */ parse_hex("B9F5771C27664bF2282D98E09D7F50cEc7cB01a7"), + /* amount */ 543210987654321, + /* data */ Data() ); const uint256_t chainID = 3; @@ -109,179 +109,6 @@ TEST(EthereumSigner, EIP1559_1442) { EXPECT_EQ(hex(encoded), "02f8710306847735940084b2d05e0082526c94b9f5771c27664bf2282d98e09d7f50cec7cb01a78701ee0c29f50cb180c080a092c336138f7d0231fe9422bb30ee9ef10bf222761fe9e04442e3a11e88880c64a06487026011dae03dc281bc21c7d7ede5c2226d197befb813a4ecad686b559e58"); } -TEST(EthereumSigner, EIP4337_NativeTransfer_Account_Not_Deployed) { - const uint256_t chainID = 5; - const auto transaction = UserOperation::buildNativeTransfer( - parse_hex("0x1306b01bC3e4AD202612D3843387e94737673F53"), - parse_hex("0x5A87209b755781cF65fEeEdd3855ade0317f4a92"), - parse_hex("0x21cc27d7db4fa19857a3702653a7a67ee30ca620"), - parse_hex("0x78d9C32b96Bb872D66D51818227563f44e67E238"), - parse_hex("0xce642355Fa553f408C34a2650Ad2F4A1634d033a"), - 0x2386f26fc10000, - 0x00, - false, - 0x5580, - 0x073272, - 0x01952f1f85, - 0x0f, - 0xbc18 - ); - - const auto serialized = transaction->serialize(chainID); - const auto key = PrivateKey(parse_hex("f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")); - const auto signature = Signer::sign(key, chainID, transaction); - const auto encoded = transaction->encoded(signature, chainID); - const auto result = std::string(encoded.begin(), encoded.end()); - - // https://goerli.etherscan.io/tx/0xf4e9c9899da7d083f260fd8d0d326a6a0e965f03444a32c73e30cd30ccc609f7 - EXPECT_EQ(result, "{\"callData\":\"0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"21888\",\"initCode\":\"0x5a87209b755781cf65feeedd3855ade0317f4a925fbfb9cf00000000000000000000000078d9c32b96bb872d66d51818227563f44e67e2380000000000000000000000000000000000000000000000000000000000000000\",\"maxFeePerGas\":\"6797860741\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"48152\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x1560b19d17613ec8580cb0feaf7ac2953771404c5bd7830f585e5062e6ddd4b82ae3bb8dbddb659c0300e8009857b5c77501e1cfd5bbab48d03de0ea7207d07c1b\",\"verificationGasLimit\":\"471666\"}"); -} - -TEST(EthereumSigner, EIP4337_NativeTransfer_Account_Deployed) { - const uint256_t chainID = 5; - const auto transaction = UserOperation::buildNativeTransfer( - parse_hex("0x1306b01bC3e4AD202612D3843387e94737673F53"), - parse_hex("0x5A87209b755781cF65fEeEdd3855ade0317f4a92"), - parse_hex("0x21cc27d7db4fa19857a3702653a7a67ee30ca620"), - parse_hex("0x78d9C32b96Bb872D66D51818227563f44e67E238"), - parse_hex("0xce642355Fa553f408C34a2650Ad2F4A1634d033a"), - 0x2386f26fc10000, - 0x1, - true, - 0x9d55, - 0x186a0, - 0x1a339c9e9, - 0xf, - 0xb708 - ); - - const auto serialized = transaction->serialize(chainID); - const auto key = PrivateKey(parse_hex("f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")); - const auto signature = Signer::sign(key, chainID, transaction); - const auto encoded = transaction->encoded(signature, chainID); - const auto result = std::string(encoded.begin(), encoded.end()); - - // https://goerli.etherscan.io/tx/0x707ee622b87a35eb2ffc3762553db8ba0efc5053cfdbeb44a841562df2a7c2bf - EXPECT_EQ(result, "{\"callData\":\"0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"40277\",\"initCode\":\"0x\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"1\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0xaed2011e5cf267de495b38ecf86ad6f1d4c05217a99e59f47e8d52ba3d41c10144785893fa3e7c116a054999e3902fc2771064d0545148bc49f6d7c827fc7a9a1c\",\"verificationGasLimit\":\"100000\"}"); -} - -TEST(EthereumSigner, EIP4337_ERC20_Transfer_Account_Deployed) { - const uint256_t chainID = 5; - const auto transaction = UserOperation::buildERC20Transfer( - parse_hex("0x1306b01bC3e4AD202612D3843387e94737673F53"), - parse_hex("0x5A87209b755781cF65fEeEdd3855ade0317f4a92"), - parse_hex("0x21cc27d7db4fa19857a3702653a7a67ee30ca620"), - parse_hex("0x78d9C32b96Bb872D66D51818227563f44e67E238"), - parse_hex("0x98339d8c260052b7ad81c28c16c0b98420f2b46a"), - parse_hex("0xce642355Fa553f408C34a2650Ad2F4A1634d033a"), - 0x186a0, - 0x6, - true, - 0xf78e, - 0x186a0, - 0x168ad5950f, - 0xf, - 0xbb10 - ); - - const auto serialized = transaction->serialize(chainID); - const auto key = PrivateKey(parse_hex("f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")); - const auto signature = Signer::sign(key, chainID, transaction); - const auto encoded = transaction->encoded(signature, chainID); - const auto result = std::string(encoded.begin(), encoded.end()); - - // https://goerli.etherscan.io/tx/0xe1c45f163cec0b9b2c3fd2307f75e48337d35c7c336ad96675c0adb6ce6fc58f - EXPECT_EQ(result, "{\"callData\":\"0xb61d27f600000000000000000000000098339d8c260052b7ad81c28c16c0b98420f2b46a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"63374\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"6\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"47888\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0xd006c93d6a8753b5e7c1e6349de0dea34eab2e7a533106e0f2e1a3a3b013c8e97b007546dab9d7b8fc471ad14ff2e8aa351dc4f1ecb63bf20f33858dc7366cbe1c\",\"verificationGasLimit\":\"100000\"}"); -} - -TEST(EthereumSigner, EIP4337_ERC20_Approve_Account_Deployed) { - const uint256_t chainID = 5; - const auto transaction = UserOperation::buildERC20Approve( - parse_hex("0x1306b01bC3e4AD202612D3843387e94737673F53"), - parse_hex("0x5A87209b755781cF65fEeEdd3855ade0317f4a92"), - parse_hex("0x21cc27d7db4fa19857a3702653a7a67ee30ca620"), - parse_hex("0x78d9C32b96Bb872D66D51818227563f44e67E238"), - parse_hex("0x98339d8c260052b7ad81c28c16c0b98420f2b46a"), - parse_hex("0xce642355Fa553f408C34a2650Ad2F4A1634d033a"), - 0x186a0, - 0x9, - true, - 0xf78e, - 0x186a0, - 0x168ad5950f, - 0xf, - 0xbb10); - - const auto serialized = transaction->serialize(chainID); - const auto key = PrivateKey(parse_hex("f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")); - const auto signature = Signer::sign(key, chainID, transaction); - const auto encoded = transaction->encoded(signature, chainID); - const auto result = std::string(encoded.begin(), encoded.end()); - - // https://goerli.etherscan.io/tx/0xa267136c0a66534f86b04ef5ba0939e22b547d71ddc2e0ab31018696ef1c916f - EXPECT_EQ(result, "{\"callData\":\"0xb61d27f600000000000000000000000098339d8c260052b7ad81c28c16c0b98420f2b46a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"63374\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"9\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"47888\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x262a67dd8cf3d16a72b7809b3b5ed55e9f4c2b93eedd5a3c6be035fbbd7111164464ec933d0fdfa359e266e318f3ac22702ae428ce14fc142e4475603e6ec15e1c\",\"verificationGasLimit\":\"100000\"}"); -} - -TEST(EthereumSigner, EIP4337_ERC721_Transfer_Account_Deployed) { - const uint256_t chainID = 5; - const auto transaction = UserOperation::buildERC721Transfer( - parse_hex("0x1306b01bC3e4AD202612D3843387e94737673F53"), - parse_hex("0x5A87209b755781cF65fEeEdd3855ade0317f4a92"), - parse_hex("0x21cc27d7db4fa19857a3702653a7a67ee30ca620"), - parse_hex("0x78d9C32b96Bb872D66D51818227563f44e67E238"), - parse_hex("0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b"), - parse_hex("0x8cE23B8769ac01d0df0d5f47Be1A38FeA97F3879"), - parse_hex("0xce642355Fa553f408C34a2650Ad2F4A1634d033a"), - 0x2A8E57, - 12, - true, - 6337400, - 1500000, - 0x168ad5950f, - 0xf, - 49999); - - const auto serialized = transaction->serialize(chainID); - const auto key = PrivateKey(parse_hex("f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")); - const auto signature = Signer::sign(key, chainID, transaction); - const auto encoded = transaction->encoded(signature, chainID); - const auto result = std::string(encoded.begin(), encoded.end()); - - // https://goerli.etherscan.io/tx/0x043f7cf4858c8480c8abbd5a5485bee11c8e70e7c6b87825a78eef00a42b662d - EXPECT_EQ(result, "{\"callData\":\"0xb61d27f6000000000000000000000000f5de760f2e916647fd766b4ad9e85ff943ce3a2b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006423b872dd0000000000000000000000008ce23b8769ac01d0df0d5f47be1a38fea97f3879000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000002a8e5700000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"6337400\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"12\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"49999\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x5951cc161a4d60d6b59503efb93e446f5d1a2e3a41d4503ba6393bcf2a2637340d0a865ed5d4d7650a68cbb95915eaa7ed54fd2c42b4bf7c83376f5c5d70691d1b\",\"verificationGasLimit\":\"1500000\"}"); -} - -TEST(EthereumSigner, EIP4337_ERC1155_Transfer_Account_Deployed) { - const uint256_t chainID = 5; - const auto transaction = UserOperation::buildERC1155Transfer( - parse_hex("0x1306b01bC3e4AD202612D3843387e94737673F53"), - parse_hex("0x76627b8D1E01fAF0C73B69625BC1fCb8FA19a2AD"), - parse_hex("0x510ab68bd111ce7115df797118b0334d727d564b"), - parse_hex("0x78d9C32b96Bb872D66D51818227563f44e67E238"), - parse_hex("0x428ce4b916332e1afccfddce08baecc97cb40b12"), - parse_hex("0x8c560E00680b973645900528EDe71a99b8d4dca8"), - parse_hex("0xce642355Fa553f408C34a2650Ad2F4A1634d033a"), - 0x01, - 0, - {}, - 0, - true, - 6337400, - 1500000, - 0x168ad5950f, - 0xf, - 51000); - - const auto serialized = transaction->serialize(chainID); - const auto key = PrivateKey(parse_hex("f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")); - const auto signature = Signer::sign(key, chainID, transaction); - const auto encoded = transaction->encoded(signature, chainID); - const auto result = std::string(encoded.begin(), encoded.end()); - - // https://goerli.etherscan.io/tx/0x6e9875715f2e46dfb45f6d7ba15dc8bd1561abb3ae7d19e549929835fca5f6af - EXPECT_EQ(result, "{\"callData\":\"0xb61d27f6000000000000000000000000428ce4b916332e1afccfddce08baecc97cb40b120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c4f242432a0000000000000000000000008c560e00680b973645900528ede71a99b8d4dca8000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"6337400\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"51000\",\"sender\":\"0x8c560e00680b973645900528ede71a99b8d4dca8\",\"signature\":\"0xaae38bcf9f946921541b44c2a66596968beecb9420471e2c9c531f758a2d652930ffdeeab95742e57e8520fb5c8ca4fee6a8e47e37336d4201fe104103f85e111c\",\"verificationGasLimit\":\"1500000\"}"); -} - TEST(EthereumSigner, SignatureBreakdownNoEip155) { const auto key = PrivateKey(parse_hex("f9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8")); const auto hash = parse_hex("0xf86a808509c7652400830130b9946b175474e89094c44da98b954eedeac495271d0f80b844a9059cbb0000000000000000000000005322b34c88ed0691971bf52a7047448f0f4efc840000000000000000000000000000000000000000000000001bc16d674ec80000808080"); diff --git a/tests/chains/Ethereum/TWAnySignerTests.cpp b/tests/chains/Ethereum/TWAnySignerTests.cpp index bab337b3a78..1008271ca04 100644 --- a/tests/chains/Ethereum/TWAnySignerTests.cpp +++ b/tests/chains/Ethereum/TWAnySignerTests.cpp @@ -297,321 +297,6 @@ TEST(TWAnySignerEthereum, SignERC1155Transfer) { ASSERT_EQ(hex(output.data()), "f242432a000000000000000000000000718046867b5b1782379a14ea4fc0c9b724da94fc0000000000000000000000005322b34c88ed0691971bf52a7047448f0f4efc840000000000000000000000000000000000000000000000000000000023c47ee50000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000040102030400000000000000000000000000000000000000000000000000000000"); } -// EIP4337 - -TEST(TWAnySignerEthereum, EIP4337_SignTransferAccountNotDeployed) { - // https://goerli.etherscan.io/tx/0xf4e9c9899da7d083f260fd8d0d326a6a0e965f03444a32c73e30cd30ccc609f7 - Proto::SigningInput input; - auto chainId = store(uint256_t(5)); - auto nonce = store(uint256_t(0)); - auto amount = store(uint256_t(0x2386f26fc10000)); - auto gasLimit = store(uint256_t(0x5580)); - auto verificationGasLimit = store(uint256_t(0x073272)); - auto maxFeePerGas = store(uint256_t(0x01952f1f85)); - auto maxInclusionFeePerGas = store(uint256_t(0x0f)); - auto preVerificationGas = store(uint256_t(0xbc18)); - auto entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53"; - auto factory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92"; - auto logic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620"; - auto owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238"; - auto to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a"; - - auto key = parse_hex("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8"); - - input.set_chain_id(chainId.data(), chainId.size()); - input.set_nonce(nonce.data(), nonce.size()); - input.set_tx_mode(Proto::TransactionMode::UserOp); - input.set_gas_limit(gasLimit.data(), gasLimit.size()); - input.set_max_fee_per_gas(maxFeePerGas.data(), maxFeePerGas.size()); - input.set_max_inclusion_fee_per_gas(maxInclusionFeePerGas.data(), maxInclusionFeePerGas.size()); - input.set_to_address(to); - - auto& user_operation = *input.mutable_user_operation(); - user_operation.set_verification_gas_limit(verificationGasLimit.data(), verificationGasLimit.size()); - user_operation.set_pre_verification_gas(preVerificationGas.data(), preVerificationGas.size()); - user_operation.set_is_account_deployed(false); - user_operation.set_entry_point(entryPoint); - user_operation.set_account_factory(factory); - user_operation.set_account_logic(logic); - user_operation.set_owner(owner); - - input.set_private_key(key.data(), key.size()); - auto& transfer = *input.mutable_transaction()->mutable_transfer(); - transfer.set_amount(amount.data(), amount.size()); - - std::string expected = "{\"callData\":\"0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"21888\",\"initCode\":\"0x5a87209b755781cf65feeedd3855ade0317f4a925fbfb9cf00000000000000000000000078d9c32b96bb872d66d51818227563f44e67e2380000000000000000000000000000000000000000000000000000000000000000\",\"maxFeePerGas\":\"6797860741\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"48152\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x1560b19d17613ec8580cb0feaf7ac2953771404c5bd7830f585e5062e6ddd4b82ae3bb8dbddb659c0300e8009857b5c77501e1cfd5bbab48d03de0ea7207d07c1b\",\"verificationGasLimit\":\"471666\"}"; - { - // sign test - Proto::SigningOutput output; - ANY_SIGN(input, TWCoinTypeEthereum); - - ASSERT_EQ(std::string(output.encoded()), expected); - } -} - -TEST(TWAnySignerEthereum, EIP4337_SignTransferAccountDeployed) { - // https://goerli.etherscan.io/tx/0x707ee622b87a35eb2ffc3762553db8ba0efc5053cfdbeb44a841562df2a7c2bf - Proto::SigningInput input; - auto chainId = store(uint256_t(5)); - auto nonce = store(uint256_t(1)); - auto amount = store(uint256_t(0x2386f26fc10000)); - auto gasLimit = store(uint256_t(0x9d55)); - auto verificationGasLimit = store(uint256_t(0x186a0)); - auto maxFeePerGas = store(uint256_t(0x1a339c9e9)); - auto maxInclusionFeePerGas = store(uint256_t(0xf)); - auto preVerificationGas = store(uint256_t(0xb708)); - auto entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53"; - auto factory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92"; - auto logic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620"; - auto owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238"; - auto to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a"; - - auto key = parse_hex("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8"); - - input.set_chain_id(chainId.data(), chainId.size()); - input.set_nonce(nonce.data(), nonce.size()); - input.set_tx_mode(Proto::TransactionMode::UserOp); - input.set_gas_limit(gasLimit.data(), gasLimit.size()); - input.set_max_fee_per_gas(maxFeePerGas.data(), maxFeePerGas.size()); - input.set_max_inclusion_fee_per_gas(maxInclusionFeePerGas.data(), maxInclusionFeePerGas.size()); - input.set_to_address(to); - - auto& user_operation = *input.mutable_user_operation(); - user_operation.set_verification_gas_limit(verificationGasLimit.data(), verificationGasLimit.size()); - user_operation.set_pre_verification_gas(preVerificationGas.data(), preVerificationGas.size()); - user_operation.set_is_account_deployed(true); - user_operation.set_entry_point(entryPoint); - user_operation.set_account_factory(factory); - user_operation.set_account_logic(logic); - user_operation.set_owner(owner); - - input.set_private_key(key.data(), key.size()); - auto& transfer = *input.mutable_transaction()->mutable_transfer(); - transfer.set_amount(amount.data(), amount.size()); - - std::string expected = "{\"callData\":\"0xb61d27f6000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"40277\",\"initCode\":\"0x\",\"maxFeePerGas\":\"7033440745\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"1\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"46856\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0xaed2011e5cf267de495b38ecf86ad6f1d4c05217a99e59f47e8d52ba3d41c10144785893fa3e7c116a054999e3902fc2771064d0545148bc49f6d7c827fc7a9a1c\",\"verificationGasLimit\":\"100000\"}"; - - { - // sign test - Proto::SigningOutput output; - ANY_SIGN(input, TWCoinTypeEthereum); - - ASSERT_EQ(std::string(output.encoded()), expected); - } -} - -TEST(TWAnySignerEthereum, EIP4337_SignERC20TransferAccountDeployed) { - // https://goerli.etherscan.io/tx/0xe1c45f163cec0b9b2c3fd2307f75e48337d35c7c336ad96675c0adb6ce6fc58f - Proto::SigningInput input; - auto chainId = store(uint256_t(5)); - auto nonce = store(uint256_t(6)); - auto amount = store(uint256_t(0x186a0)); - auto gasLimit = store(uint256_t(0xf78e)); - auto verificationGasLimit = store(uint256_t(0x186a0)); - auto maxFeePerGas = store(uint256_t(0x168ad5950f)); - auto maxInclusionFeePerGas = store(uint256_t(0xf)); - auto preVerificationGas = store(uint256_t(0xbb10)); - auto entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53"; - auto factory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92"; - auto logic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620"; - auto owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238"; - auto tokenContract = "0x98339d8c260052b7ad81c28c16c0b98420f2b46a"; - auto to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a"; - - auto key = parse_hex("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8"); - - input.set_chain_id(chainId.data(), chainId.size()); - input.set_nonce(nonce.data(), nonce.size()); - input.set_tx_mode(Proto::TransactionMode::UserOp); - input.set_gas_limit(gasLimit.data(), gasLimit.size()); - input.set_max_fee_per_gas(maxFeePerGas.data(), maxFeePerGas.size()); - input.set_max_inclusion_fee_per_gas(maxInclusionFeePerGas.data(), maxInclusionFeePerGas.size()); - input.set_to_address(tokenContract); - - auto& user_operation = *input.mutable_user_operation(); - user_operation.set_verification_gas_limit(verificationGasLimit.data(), verificationGasLimit.size()); - user_operation.set_pre_verification_gas(preVerificationGas.data(), preVerificationGas.size()); - user_operation.set_is_account_deployed(true); - user_operation.set_entry_point(entryPoint); - user_operation.set_account_factory(factory); - user_operation.set_account_logic(logic); - user_operation.set_owner(owner); - - input.set_private_key(key.data(), key.size()); - auto& transfer = *input.mutable_transaction()->mutable_erc20_transfer(); - transfer.set_amount(amount.data(), amount.size()); - transfer.set_to(to); - - std::string expected = "{\"callData\":\"0xb61d27f600000000000000000000000098339d8c260052b7ad81c28c16c0b98420f2b46a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"63374\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"6\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"47888\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0xd006c93d6a8753b5e7c1e6349de0dea34eab2e7a533106e0f2e1a3a3b013c8e97b007546dab9d7b8fc471ad14ff2e8aa351dc4f1ecb63bf20f33858dc7366cbe1c\",\"verificationGasLimit\":\"100000\"}"; - { - // sign test - Proto::SigningOutput output; - ANY_SIGN(input, TWCoinTypeEthereum); - - ASSERT_EQ(std::string(output.encoded()), expected); - } -} - -TEST(TWAnySignerEthereum, EIP4337_SignERC20ApproveAccountDeployed) { - // https://goerli.etherscan.io/tx/0xe1c45f163cec0b9b2c3fd2307f75e48337d35c7c336ad96675c0adb6ce6fc58f - Proto::SigningInput input; - auto chainId = store(uint256_t(5)); - auto nonce = store(uint256_t(9)); - auto amount = store(uint256_t(0x186a0)); - auto gasLimit = store(uint256_t(0xf78e)); - auto verificationGasLimit = store(uint256_t(0x186a0)); - auto maxFeePerGas = store(uint256_t(0x168ad5950f)); - auto maxInclusionFeePerGas = store(uint256_t(0xf)); - auto preVerificationGas = store(uint256_t(0xbb10)); - auto entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53"; - auto factory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92"; - auto logic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620"; - auto owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238"; - auto tokenContract = "0x98339d8c260052b7ad81c28c16c0b98420f2b46a"; - auto to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a"; - - auto key = parse_hex("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8"); - - input.set_chain_id(chainId.data(), chainId.size()); - input.set_nonce(nonce.data(), nonce.size()); - input.set_tx_mode(Proto::TransactionMode::UserOp); - input.set_gas_limit(gasLimit.data(), gasLimit.size()); - input.set_max_fee_per_gas(maxFeePerGas.data(), maxFeePerGas.size()); - input.set_max_inclusion_fee_per_gas(maxInclusionFeePerGas.data(), maxInclusionFeePerGas.size()); - input.set_to_address(tokenContract); - - auto& user_operation = *input.mutable_user_operation(); - user_operation.set_verification_gas_limit(verificationGasLimit.data(), verificationGasLimit.size()); - user_operation.set_pre_verification_gas(preVerificationGas.data(), preVerificationGas.size()); - user_operation.set_is_account_deployed(true); - user_operation.set_entry_point(entryPoint); - user_operation.set_account_factory(factory); - user_operation.set_account_logic(logic); - user_operation.set_owner(owner); - - input.set_private_key(key.data(), key.size()); - auto& transfer = *input.mutable_transaction()->mutable_erc20_approve(); - transfer.set_amount(amount.data(), amount.size()); - transfer.set_spender(to); - - std::string expected = "{\"callData\":\"0xb61d27f600000000000000000000000098339d8c260052b7ad81c28c16c0b98420f2b46a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"63374\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"9\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"47888\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x262a67dd8cf3d16a72b7809b3b5ed55e9f4c2b93eedd5a3c6be035fbbd7111164464ec933d0fdfa359e266e318f3ac22702ae428ce14fc142e4475603e6ec15e1c\",\"verificationGasLimit\":\"100000\"}"; - { - // sign test - Proto::SigningOutput output; - ANY_SIGN(input, TWCoinTypeEthereum); - - ASSERT_EQ(std::string(output.encoded()), expected); - } -} - -TEST(TWAnySignerEthereum, EIP4337_SignERC721TransferAccountDeployed) { - // https://goerli.etherscan.io/tx/0x043f7cf4858c8480c8abbd5a5485bee11c8e70e7c6b87825a78eef00a42b662d - Proto::SigningInput input; - auto chainId = store(uint256_t(5)); - auto nonce = store(uint256_t(12)); - auto tokenId = store(uint256_t(0x2A8E57)); - auto gasLimit = store(uint256_t(6337400)); - auto verificationGasLimit = store(uint256_t(1500000)); - auto maxFeePerGas = store(uint256_t(0x168ad5950f)); - auto maxInclusionFeePerGas = store(uint256_t(0xf)); - auto preVerificationGas = store(uint256_t(49999)); - auto entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53"; - auto factory = "0x5A87209b755781cF65fEeEdd3855ade0317f4a92"; - auto logic = "0x21cc27d7db4fa19857a3702653a7a67ee30ca620"; - auto owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238"; - auto tokenContract = "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b"; - auto to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a"; - auto from = "0x8cE23B8769ac01d0df0d5f47Be1A38FeA97F3879"; - - auto key = parse_hex("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8"); - - input.set_chain_id(chainId.data(), chainId.size()); - input.set_nonce(nonce.data(), nonce.size()); - input.set_tx_mode(Proto::TransactionMode::UserOp); - input.set_gas_limit(gasLimit.data(), gasLimit.size()); - input.set_max_fee_per_gas(maxFeePerGas.data(), maxFeePerGas.size()); - input.set_max_inclusion_fee_per_gas(maxInclusionFeePerGas.data(), maxInclusionFeePerGas.size()); - input.set_to_address(tokenContract); - - auto& user_operation = *input.mutable_user_operation(); - user_operation.set_verification_gas_limit(verificationGasLimit.data(), verificationGasLimit.size()); - user_operation.set_pre_verification_gas(preVerificationGas.data(), preVerificationGas.size()); - user_operation.set_is_account_deployed(true); - user_operation.set_entry_point(entryPoint); - user_operation.set_account_factory(factory); - user_operation.set_account_logic(logic); - user_operation.set_owner(owner); - - input.set_private_key(key.data(), key.size()); - auto& transfer = *input.mutable_transaction()->mutable_erc721_transfer(); - transfer.set_token_id(tokenId.data(), tokenId.size()); - transfer.set_to(to); - transfer.set_from(from); - - std::string expected = "{\"callData\":\"0xb61d27f6000000000000000000000000f5de760f2e916647fd766b4ad9e85ff943ce3a2b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006423b872dd0000000000000000000000008ce23b8769ac01d0df0d5f47be1a38fea97f3879000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a00000000000000000000000000000000000000000000000000000000002a8e5700000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"6337400\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"12\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"49999\",\"sender\":\"0x8ce23b8769ac01d0df0d5f47be1a38fea97f3879\",\"signature\":\"0x5951cc161a4d60d6b59503efb93e446f5d1a2e3a41d4503ba6393bcf2a2637340d0a865ed5d4d7650a68cbb95915eaa7ed54fd2c42b4bf7c83376f5c5d70691d1b\",\"verificationGasLimit\":\"1500000\"}"; - { - // sign test - Proto::SigningOutput output; - ANY_SIGN(input, TWCoinTypeEthereum); - - ASSERT_EQ(std::string(output.encoded()), expected); - } -} - -TEST(TWAnySignerEthereum, EIP4337_SignERC1155TransferAccountDeployed) { - // https://goerli.etherscan.io/tx/0x6e9875715f2e46dfb45f6d7ba15dc8bd1561abb3ae7d19e549929835fca5f6af - Proto::SigningInput input; - auto chainId = store(uint256_t(5)); - auto nonce = store(uint256_t(0)); - auto tokenId = store(uint256_t(0x01)); - auto gasLimit = store(uint256_t(6337400)); - auto verificationGasLimit = store(uint256_t(1500000)); - auto maxFeePerGas = store(uint256_t(0x168ad5950f)); - auto maxInclusionFeePerGas = store(uint256_t(0xf)); - auto preVerificationGas = store(uint256_t(51000)); - auto entryPoint = "0x1306b01bC3e4AD202612D3843387e94737673F53"; - auto factory = "0x76627b8D1E01fAF0C73B69625BC1fCb8FA19a2AD"; - auto logic = "0x510ab68bd111ce7115df797118b0334d727d564b"; - auto owner = "0x78d9C32b96Bb872D66D51818227563f44e67E238"; - auto tokenContract = "0x428ce4b916332e1afccfddce08baecc97cb40b12"; - auto to = "0xce642355Fa553f408C34a2650Ad2F4A1634d033a"; - auto from = "0x8c560E00680b973645900528EDe71a99b8d4dca8"; - - auto key = parse_hex("0xf9fb27c90dcaa5631f373330eeef62ae7931587a19bd8215d0c2addf28e439c8"); - - input.set_chain_id(chainId.data(), chainId.size()); - input.set_nonce(nonce.data(), nonce.size()); - input.set_tx_mode(Proto::TransactionMode::UserOp); - input.set_gas_limit(gasLimit.data(), gasLimit.size()); - input.set_max_fee_per_gas(maxFeePerGas.data(), maxFeePerGas.size()); - input.set_max_inclusion_fee_per_gas(maxInclusionFeePerGas.data(), maxInclusionFeePerGas.size()); - input.set_to_address(tokenContract); - - auto& user_operation = *input.mutable_user_operation(); - user_operation.set_verification_gas_limit(verificationGasLimit.data(), verificationGasLimit.size()); - user_operation.set_pre_verification_gas(preVerificationGas.data(), preVerificationGas.size()); - user_operation.set_is_account_deployed(true); - user_operation.set_entry_point(entryPoint); - user_operation.set_account_factory(factory); - user_operation.set_account_logic(logic); - user_operation.set_owner(owner); - - input.set_private_key(key.data(), key.size()); - auto& transfer = *input.mutable_transaction()->mutable_erc1155_transfer(); - transfer.set_token_id(tokenId.data(), tokenId.size()); - transfer.set_to(to); - transfer.set_from(from); - - std::string expected = "{\"callData\":\"0xb61d27f6000000000000000000000000428ce4b916332e1afccfddce08baecc97cb40b120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c4f242432a0000000000000000000000008c560e00680b973645900528ede71a99b8d4dca8000000000000000000000000ce642355fa553f408c34a2650ad2f4a1634d033a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"callGasLimit\":\"6337400\",\"initCode\":\"0x\",\"maxFeePerGas\":\"96818533647\",\"maxPriorityFeePerGas\":\"15\",\"nonce\":\"0\",\"paymasterAndData\":\"0x\",\"preVerificationGas\":\"51000\",\"sender\":\"0x8c560e00680b973645900528ede71a99b8d4dca8\",\"signature\":\"0xaae38bcf9f946921541b44c2a66596968beecb9420471e2c9c531f758a2d652930ffdeeab95742e57e8520fb5c8ca4fee6a8e47e37336d4201fe104103f85e111c\",\"verificationGasLimit\":\"1500000\"}"; - { - // sign test - Proto::SigningOutput output; - ANY_SIGN(input, TWCoinTypeEthereum); - - ASSERT_EQ(std::string(output.encoded()), expected); - } -} - TEST(TWAnySignerEthereum, SignJSON) { auto json = STRING(R"({"chainId":"AQ==","gasPrice":"1pOkAA==","gasLimit":"Ugg=","toAddress":"0x7d8bf18C7cE84b3E175b339c4Ca93aEd1dD166F1","transaction":{"transfer":{"amount":"A0i8paFgAA=="}}})"); auto key = DATA("17209af590a86462395d5881e60d11c7fa7d482cfb02b5a01b93c2eeef243543"); diff --git a/tests/common/TransactionCompilerTests.cpp b/tests/common/TransactionCompilerTests.cpp index 398f10e8dde..44d0f7d40c6 100644 --- a/tests/common/TransactionCompilerTests.cpp +++ b/tests/common/TransactionCompilerTests.cpp @@ -380,7 +380,7 @@ TEST(TransactionCompiler, EthereumCompileWithSignatures) { const auto ExpectedTx = "f86c0b8504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a0360a84fb41ad07f07c845fedc34cde728421803ebbaae392fc39c116b29fc07ba053bd9d1376e15a191d844db458893b928f3efbfee90c9febf51ab84c97966779"; { - EXPECT_EQ(outputData.size(), 183ul); + EXPECT_EQ(outputData.size(), 217ul); Ethereum::Proto::SigningOutput output; ASSERT_TRUE(output.ParseFromArray(outputData.data(), (int)outputData.size())); diff --git a/tests/interface/TWTransactionCompilerTests.cpp b/tests/interface/TWTransactionCompilerTests.cpp index 6d5be5d8f5d..b33b64a8826 100644 --- a/tests/interface/TWTransactionCompilerTests.cpp +++ b/tests/interface/TWTransactionCompilerTests.cpp @@ -172,7 +172,7 @@ TEST(TWTransactionCompiler, ExternalSignatureSignEthereum) { const auto ExpectedTx = "f86c0b8504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a0360a84fb41ad07f07c845fedc34cde728421803ebbaae392fc39c116b29fc07ba053bd9d1376e15a191d844db458893b928f3efbfee90c9febf51ab84c97966779"; { - EXPECT_EQ(TWDataSize(outputData.get()), 183ul); + EXPECT_EQ(TWDataSize(outputData.get()), 217ul); Ethereum::Proto::SigningOutput output; ASSERT_TRUE(output.ParseFromArray(TWDataBytes(outputData.get()), (int)TWDataSize(outputData.get())));