abstractionkit 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -5
- package/dist/Bundler.d.ts +8 -16
- package/dist/Bundler.d.ts.map +1 -1
- package/dist/abstractionkit.d.ts +6 -10
- package/dist/abstractionkit.d.ts.map +1 -1
- package/dist/account/Safe/SafeAccountV0_2_0.d.ts +36 -0
- package/dist/account/Safe/SafeAccountV0_2_0.d.ts.map +1 -0
- package/dist/account/Safe/multisend.d.ts +4 -0
- package/dist/account/Safe/multisend.d.ts.map +1 -0
- package/dist/account/Safe/types.d.ts +26 -0
- package/dist/account/Safe/types.d.ts.map +1 -0
- package/dist/account/SendUseroperationResponse.d.ts +11 -0
- package/dist/account/SendUseroperationResponse.d.ts.map +1 -0
- package/dist/account/SmartAccount.d.ts +9 -12
- package/dist/account/SmartAccount.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/errors.d.ts +24 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/factory/SafeAccountFactory.d.ts +5 -0
- package/dist/factory/SafeAccountFactory.d.ts.map +1 -0
- package/dist/factory/SmartAccountFactory.d.ts +1 -2
- package/dist/factory/SmartAccountFactory.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/paymaster/CandidePaymaster.d.ts +22 -0
- package/dist/paymaster/CandidePaymaster.d.ts.map +1 -0
- package/dist/paymaster/Paymaster.d.ts +3 -6
- package/dist/paymaster/Paymaster.d.ts.map +1 -1
- package/dist/paymaster/types.d.ts +4 -0
- package/dist/paymaster/types.d.ts.map +1 -0
- package/dist/types.d.ts +72 -44
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +8 -6
- package/dist/utils.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/account/Candide/CandideAccount.d.ts +0 -21
- package/dist/account/Candide/CandideAccount.d.ts.map +0 -1
- package/dist/account/Candide/multisend.d.ts +0 -3
- package/dist/account/Candide/multisend.d.ts.map +0 -1
- package/dist/account/Candide/types.d.ts +0 -9
- package/dist/account/Candide/types.d.ts.map +0 -1
- package/dist/account/SimpleAccount.d.ts +0 -17
- package/dist/account/SimpleAccount.d.ts.map +0 -1
- package/dist/factory/CandideAccountFactory.d.ts +0 -5
- package/dist/factory/CandideAccountFactory.d.ts.map +0 -1
- package/dist/factory/SimpleAccountFactory.d.ts +0 -5
- package/dist/factory/SimpleAccountFactory.d.ts.map +0 -1
- package/dist/paymaster/CandideValidationPaymaster.d.ts +0 -13
- package/dist/paymaster/CandideValidationPaymaster.d.ts.map +0 -1
package/dist/index.m.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"isomorphic-unfetch";import{keccak256 as e,AbiCoder as r,id as n,ethers as i,ZeroAddress as a,solidityPacked as f,solidityPackedKeccak256 as c}from"ethers";var o=function(e,r,n){try{var i=t.default||t,a=JSON.stringify({method:r,params:n,id:1,jsonrpc:"2.0"});return Promise.resolve(i(e,{method:"POST",body:a,redirect:"follow"})).then(function(t){return Promise.resolve(t.json())})}catch(t){return Promise.reject(t)}};function s(t,n,i){var a=e(function(t){var n=[t.sender,t.nonce,e(t.initCode),e(t.callData),t.callGasLimit,t.verificationGasLimit,t.preVerificationGas,t.maxFeePerGas,t.maxPriorityFeePerGas,e(t.paymasterAndData)];return r.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(t)),f=r.defaultAbiCoder().encode(["bytes32","address","uint256"],[a,n,i]);return e(f)}function d(t,e,n){return t+r.defaultAbiCoder().encode(e,n).slice(2)}function u(t){return n(t).slice(0,10)}var b,l=/*#__PURE__*/function(){function t(t,e,r,n,i,a){this.singletonAddress=void 0,this.proxyByteCode=void 0,this.initializerFunctionSelector=void 0,this.initializerFunctionInputAbi=void 0,this.executorFunctionSelector=void 0,this.executorFunctionInputAbi=void 0,this.singletonAddress=t,this.proxyByteCode=e,this.initializerFunctionSelector=r,this.initializerFunctionInputAbi=n,this.executorFunctionSelector=i,this.executorFunctionInputAbi=a}var e=t.prototype;return e.getInitializerCallData=function(t){return d(this.initializerFunctionSelector,this.initializerFunctionInputAbi,t)},e.getExecutorCallData=function(t){return d(this.executorFunctionSelector,this.executorFunctionInputAbi,t)},t}();function h(){return h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},h.apply(this,arguments)}function p(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,y(t,e)}function y(t,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},y(t,e)}!function(t){t[t.Call=0]="Call",t[t.Delegate=1]="Delegate"}(b||(b={}));var x=/*#__PURE__*/function(){function t(t,e,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=t,this.generatorFunctionSelector=e,this.generatorFunctionInputAbi=r}return t.prototype.getFactoryGeneratorFunctionCallData=function(t){var e=d(this.generatorFunctionSelector,this.generatorFunctionInputAbi,t);return this.address+e.slice(2)},t}(),v=/*#__PURE__*/function(t){function e(e){return void 0===e&&(e="0xb73Eb505Abc30d0e7e15B73A492863235B3F4309"),t.call(this,e,"0x1688f0b9",["address","bytes","uint256"])||this}return p(e,t),e}(x);function m(t){return"0x"+t.map(function(t){return function(t){var e=i.getBytes(t.data);return i.solidityPacked(["uint8","address","uint256","uint256","bytes"],[t.operation,t.to,t.value,e.length,e]).slice(2)}(t)}).join("")}var A=/*#__PURE__*/function(t){function r(e,r,n){var i;return void 0===e&&(e="0x3A0a17Bcc84576b099373ab3Eed9702b07D30402"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new v),(i=t.call(this,e,"0x608060405234801561001057600080fd5b5060405161017338038061017383398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607c806100f76000396000f3fe6080604052600080546001600160a01b0316813563530ca43760e11b1415602857808252602082f35b3682833781823684845af490503d82833e806041573d82fd5b503d81f3fea2646970667358221220022b6bb97dd1e16cb867add83d4159f7550336cbb5b40514145e43f493c1377664736f6c634300080c0033","0x6a1e9826",["address[]","uint256","address","bytes","address","address","uint256","address","address"],"0xf34308ef",["address","uint256","bytes","uint8","address","address","uint256"])||this).entrypointAddress=void 0,i.candideAccountFactory=void 0,i.entrypointAddress=r,i.candideAccountFactory=n,i}p(r,t);var n=r.prototype;return n.createNewAccount=function(t,e,r,n){void 0===e&&(e=1),void 0===r&&(r=0),void 0===n&&(n="0x2a15DE4410d4c8af0A7b6c12803120f43C42B820");var i=this.getInitializerCallData([t,e,a,"0x",n,a,0,a,this.entrypointAddress]);return[this.getProxyAddress(i,this.candideAccountFactory.address,r),this.candideAccountFactory.getFactoryGeneratorFunctionCallData([this.singletonAddress,i,r])]},n.createSendEthCallData=function(t,e){return this.createCallData(t,e,"0x",0,a,a,0)},n.createCallData=function(t,e,r,n,i,a,f){return this.getExecutorCallData([t,e,r,n,i,a,f])},n.getProxyAddress=function(t,r,n){var i=e(f(["bytes32","uint256"],[e(t),n])),a=e(f(["bytes","uint256"],[this.proxyByteCode,this.singletonAddress]));return"0x"+c(["bytes1","address","bytes32","bytes32"],["0xff",r,i,a]).slice(-40)},n.createCallDataSingleTransactionWithPaymaster=function(t,e,r,n){return this.getExecutorCallData([t.to,t.value,t.data,t.operation,e,r,n])},n.createCallDataSingleTransaction=function(t){return this.createCallDataSingleTransactionWithPaymaster(t,a,a,0)},n.createCallDataBatchTransactionWithPaymaster=function(t,e,r,n){var i=d("0x8d80ff0a",["bytes"],[m(t)]);return this.getExecutorCallData(["0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",0,i,b.Delegate,e,r,n])},n.createCallDataBatchTransaction=function(t){return this.createCallDataBatchTransactionWithPaymaster(t,a,a,0)},r}(l),g=/*#__PURE__*/function(t){function e(e){return void 0===e&&(e="0x9406Cc6185a346906296840746125a0E44976454"),t.call(this,e,"0x5fbfb9cf",["address","uint256"])||this}return p(e,t),e}(x),F=/*#__PURE__*/function(t){function n(e,r,n){var i;return void 0===e&&(e="0x8ABB13360b87Be5EEb1B98647A016adD927a136c"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new g),(i=t.call(this,e,"0x60806040526040516107c13803806107c183398101604081905261002291610321565b61002e82826000610035565b505061043e565b61003e8361006b565b60008251118061004b5750805b156100665761006483836100ab60201b6100291760201c565b505b505050565b610074816100d7565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606100d0838360405180606001604052806027815260200161079a602791396101a9565b9392505050565b6100ea8161022260201b6100551760201c565b6101515760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806101887f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61023160201b6100711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080856001600160a01b0316856040516101c691906103ef565b600060405180830381855af49150503d8060008114610201576040519150601f19603f3d011682016040523d82523d6000602084013e610206565b606091505b50909250905061021886838387610234565b9695505050505050565b6001600160a01b03163b151590565b90565b606083156102a357825160000361029c576001600160a01b0385163b61029c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610148565b50816102ad565b6102ad83836102b5565b949350505050565b8151156102c55781518083602001fd5b8060405162461bcd60e51b8152600401610148919061040b565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103105781810151838201526020016102f8565b838111156100645750506000910152565b6000806040838503121561033457600080fd5b82516001600160a01b038116811461034b57600080fd5b60208401519092506001600160401b038082111561036857600080fd5b818501915085601f83011261037c57600080fd5b81518181111561038e5761038e6102df565b604051601f8201601f19908116603f011681019083821181831017156103b6576103b66102df565b816040528281528860208487010111156103cf57600080fd5b6103e08360208301602088016102f5565b80955050505050509250929050565b600082516104018184602087016102f5565b9190910192915050565b602081526000825180602084015261042a8160408501602087016102f5565b601f01601f19169190910160400192915050565b61034d8061044d6000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b6100b9565b565b606061004e83836040518060600160405280602781526020016102f1602791396100dd565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b3660008037600080366000845af43d6000803e8080156100d8573d6000f35b3d6000fd5b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516101079190610283565b600060405180830381855af49150503d8060008114610142576040519150601f19603f3d011682016040523d82523d6000602084013e610147565b606091505b509150915061015886838387610162565b9695505050505050565b606083156101fd5782516000036101f65773ffffffffffffffffffffffffffffffffffffffff85163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610207565b610207838361020f565b949350505050565b81511561021f5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061029f565b60005b8381101561026e578181015183820152602001610256565b8381111561027d576000848401525b50505050565b60008251610295818460208701610253565b9190910192915050565b60208152600082518060208401526102be816040850160208701610253565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201cd78ab6a31213989661cff2d7d05fc9b9c38b1a848e8249e2e398659a9eb7e364736f6c634300080f0033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564","0xc4d66de8",["address"],"0xb61d27f6",["address","uint256","bytes"])||this).entrypointAddress=void 0,i.simpleAccountFactory=void 0,i.batchExecutorFunctionSelector=void 0,i.batchExecutorFunctionInputAbi=void 0,i.entrypointAddress=r,i.simpleAccountFactory=n,i.batchExecutorFunctionSelector="0x18dfb3c7",i.batchExecutorFunctionInputAbi=["address[]","bytes[]"],i}p(n,t);var i=n.prototype;return i.createNewAccount=function(t,e){void 0===e&&(e=0);var r=this.getInitializerCallData([t]),n=this.simpleAccountFactory.getFactoryGeneratorFunctionCallData([t,e]);return[this.getProxyAddress(r,this.simpleAccountFactory.address,e),n]},i.getProxyAddress=function(t,n,i){var a=r.defaultAbiCoder(),o=a.encode(["uint256"],[i]),s=a.encode(["address","bytes"],[this.singletonAddress,t]),d=e(f(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+c(["bytes1","address","bytes32","bytes32"],["0xff",n,o,d]).slice(-40)},i.createSendEthCallData=function(t,e){return this.createCallData(t,e,"0x")},i.createCallData=function(t,e,r){return this.getExecutorCallData([t,e,r])},i.createBatchCallData=function(t,e){return d(this.batchExecutorFunctionSelector,this.batchExecutorFunctionInputAbi,[t,e])},n}(l),P=/*#__PURE__*/function(){function t(t,e){this.rpcUrl=void 0,this.entrypointAddress=void 0,this.rpcUrl=t,this.entrypointAddress=e}var e=t.prototype;return e.chainId=function(){try{return Promise.resolve(o(this.rpcUrl,"eth_chainId",[])).then(function(t){return"result"in t?{chainId:t.result}:t.error})}catch(t){return Promise.reject(t)}},e.supportedEntryPoints=function(){try{return Promise.resolve(o(this.rpcUrl,"eth_supportedEntryPoints",[])).then(function(t){return"result"in t?{supportedEntryPoints:t.result}:t.error})}catch(t){return Promise.reject(t)}},e.estimateUserOperationGas=function(t){try{return Promise.resolve(o(this.rpcUrl,"eth_estimateUserOperationGas",[t,this.entrypointAddress])).then(function(t){return"result"in t?t.result:t.error})}catch(t){return Promise.reject(t)}},e.sendUserOperation=function(t){try{return Promise.resolve(o(this.rpcUrl,"eth_sendUserOperation",[t,this.entrypointAddress])).then(function(t){return"result"in t?{userOperationHash:t.result}:t.error})}catch(t){return Promise.reject(t)}},e.getUserOperationReceipt=function(t){try{return Promise.resolve(o(this.rpcUrl,"eth_getUserOperationReceipt",[t])).then(function(t){if("result"in t){var e=t.result,r=h({},e.receipt,{logs:JSON.stringify(e.receipt.logs)});return h({},e,{logs:JSON.stringify(e.logs),receipt:r})}return t.error})}catch(t){return Promise.reject(t)}},e.getUserOperationByHash=function(t){try{return Promise.resolve(o(this.rpcUrl,"eth_getUserOperationByHash",[t])).then(function(t){return"result"in t?t.result:t.error})}catch(t){return Promise.reject(t)}},t}(),C=/*#__PURE__*/function(t){function e(e,r){var n;return(n=t.call(this)||this).rpcUrl=void 0,n.entrypointAddress=void 0,n.rpcUrl=r,n.entrypointAddress=e,n}p(e,t);var r=e.prototype;return r.getSupportedERC20Tokens=function(){try{return Promise.resolve(o(this.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(t){if("result"in t){var e=t.result;return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}}return t.error})}catch(t){return Promise.reject(t)}},r.getSupportedEntrypoint=function(){try{return Promise.resolve(o(this.rpcUrl,"pm_supportedEntryPoint",[])).then(function(t){return"result"in t?t.result:t.error})}catch(t){return Promise.reject(t)}},r.getPaymasterCallDataForPayingGasWithErc20=function(t,e){try{var r=this;return Promise.resolve(r.getPaymasterCallData(t,[r.rpcUrl,r.entrypointAddress,e]))}catch(t){return Promise.reject(t)}},r.getPaymasterCallDataForGaslessTx=function(t){try{var e=this;return Promise.resolve(e.getPaymasterCallData(t,[e.rpcUrl,e.entrypointAddress]))}catch(t){return Promise.reject(t)}},r.getPaymasterCallData=function(t,e){try{return Promise.resolve(o(e[0],"pm_sponsorUserOperation",[t,e[1],{token:e[2]}])).then(function(t){return"result"in t?t.result:t.error})}catch(t){return Promise.reject(t)}},e}(function(){}),D={sender:a,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0x00",verificationGasLimit:"0x00",preVerificationGas:"0x00",maxFeePerGas:"0x00",maxPriorityFeePerGas:"0x00",paymasterAndData:"0x",signature:"0x"},E={sender:a,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0xffffff",verificationGasLimit:"0xffffff",preVerificationGas:"0xffffff",maxFeePerGas:"0xffffff",maxPriorityFeePerGas:"0xfffffff",paymasterAndData:"0x",signature:"0x"},S={__proto__:null,SmartAccount:l,CandideAccount:A,SimpleAccount:F,SmartAccountFactory:x,CandideAccountFactory:v,SimpleAccountFactory:g,Bundler:P,CandideValidationPaymaster:C,getUserOperationHash:s,getCallData:d,getFunctionSelector:u,UserOperationEmptyValues:D,UserOperationDummyValues:E,get Operation(){return b}};export{P as Bundler,A as CandideAccount,v as CandideAccountFactory,C as CandideValidationPaymaster,b as Operation,F as SimpleAccount,g as SimpleAccountFactory,l as SmartAccount,x as SmartAccountFactory,E as UserOperationDummyValues,D as UserOperationEmptyValues,S as abstractionkit,d as getCallData,u as getFunctionSelector,s as getUserOperationHash};
|
|
1
|
+
import{keccak256 as e,AbiCoder as t,id as r,JsonRpcProvider as n,getBytes as i,solidityPacked as a,solidityPackedKeccak256 as o,Wallet as s,TypedDataEncoder as f}from"ethers";import*as c from"isomorphic-unfetch";var u,l,d=function(e){this.accountAddress=void 0,this.accountAddress=e};function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h.apply(this,arguments)}function v(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,y(e,t)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function A(e){var t="function"==typeof Map?new Map:void 0;return A=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(p())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&y(i,r.prototype),i}(e,arguments,m(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,e)},A(e)}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}d.proxyByteCode=void 0,d.initializerFunctionSelector=void 0,d.initializerFunctionInputAbi=void 0,d.executorFunctionSelector=void 0,d.executorFunctionInputAbi=void 0,function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(u||(u={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(l||(l={}));var g={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"},E=/*#__PURE__*/function(e){function t(t,r,n){var i;void 0===n&&(n={});var a=n.errno,o=n.context;return(i=e.call(this,r,{cause:n.cause})||this).code=void 0,i.context=void 0,i.errno=void 0,i.name=i.constructor.name,i.code=t,i.errno=a,i.context=o,i}return v(t,e),t}(/*#__PURE__*/A(Error));function D(e){if(e instanceof Error)return e;var t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error("This value was thrown as is, not through an Error: "+t)}var b=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:O(_("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(G(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new E("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=D(e);throw new E("BAD_DATA","getNonce returned ill formed data",{cause:t})}})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=D(e);throw new E("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},G=function(e,t,r){try{var n=c.default||c,i={method:"POST",body:JSON.stringify({method:t,params:r,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(n(e,i)).then(function(t){return Promise.resolve(t.json()).then(function(t){if("result"in t)return t.result;var r=t.error,n=String(r.code);throw new E(n in g?g[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(i)}})})})}catch(e){return Promise.reject(e)}};function R(r,n,i){var a=e(function(r){var n=[r.sender,r.nonce,e(r.initCode),e(r.callData),r.callGasLimit,r.verificationGasLimit,r.preVerificationGas,r.maxFeePerGas,r.maxPriorityFeePerGas,e(r.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(r)),o=t.defaultAbiCoder().encode(["bytes32","address","uint256"],[a,n,i]);return e(o)}function O(e,r,n){return e+t.defaultAbiCoder().encode(r,n).slice(2)}function _(e){return r(e).slice(0,10)}function S(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var U,x="0x0000000000000000000000000000000000000000",T={sender:x,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},F=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=O(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),L=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return v(t,e),t}(F);function w(e){return"0x"+e.map(function(e){return n=null!=(r=(t=e).operation)?r:u.Call,o=i(t.data),a(["uint8","address","uint256","uint256","bytes"],[n,t.to,t.value,o.length,o]).slice(2);var t,r,n,o}).join("")}function I(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(U||(U={}));var C=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{var e=this;return Promise.resolve(I(function(){return Promise.resolve(G(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new E("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=D(e);throw new E("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{var e=this;return Promise.resolve(I(function(){return Promise.resolve(G(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=D(e);throw new E("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=this;return Promise.resolve(I(function(){function i(){var e=a;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var a={},o=void 0===r?Promise.resolve(G(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(G(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=D(e);throw new E("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{var r=this;return Promise.resolve(I(function(){return Promise.resolve(G(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=D(e);throw new E("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{var t=this;return Promise.resolve(I(function(){return Promise.resolve(G(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=h({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return h({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:r})}return null})},function(t){var r=D(t);throw new E("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{var t=this;return Promise.resolve(I(function(){return Promise.resolve(G(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?h({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=D(t);throw new E("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function N(e,t,r){if(!e.s){if(r instanceof B){if(!r.s)return void(r.o=N.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(N.bind(null,e,t),N.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var B=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{N(n,1,a(this.v))}catch(e){N(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?N(n,1,t?t(i):i):r?N(n,1,r(i)):N(n,2,i)}catch(e){N(n,2,e)}},n},e}();function M(e){return e instanceof B&&1&e.s}var j=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=180),void 0===t&&(t=2);try{var r,n=function(e){if(r)return e;throw new E("TIMEOUT","can't find useroperation",{context:i.userOperationHash})},i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o=function(e,t,r){for(var n;;){var i=e();if(M(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!M(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!M(o)){n=2;break}}}var s=new B,f=N.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,f),s;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!M(o))return void o.then(l).then(void 0,f);if(!(i=e())||M(i)&&!i.v)return void N(s,1,a);if(i.then)return void i.then(u).then(void 0,f);M(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,f)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,f):c(a):N(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):N(s,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){if(null!=e)return r=1,e;a++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),k=/*#__PURE__*/function(r){function i(e,t,n){var a;return void 0===t&&(t=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=i.DEFAULT_ENTRYPOINT_ADDRESS),(a=r.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.initCode=void 0,a.entrypointAddress=n,a.safe4337ModuleAddress=t,a.initCode=null,a}v(i,r),i.initializeNewAccount=function(e,t){void 0===t&&(t={});var r=i.createAccountAddressAndInitCode(e,t),n=r[1],a=new i(r[0]);return a.initCode=n,a},i.createAccountAddressAndInitCode=function(e,t){var r,n,a,o,s;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(r=t.threshold)?r:1,c=null!=(n=t.c2Nonce)?n:0n,u=null!=(a=t.singletonAddress)?a:i.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:i.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:i.DEFAULT_ADD_MODULE_LIB_ADDRESS,p=new L;null!=t.safeAccountFactoryAddress&&(p=new L(t.safeAccountFactoryAddress));var h=i.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(h,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,h,c])]},i.createInitializerCallData=function(e,t,r,n){if(void 0===r&&(r=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=i.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=O("0x8d0dc49f",["address[]"],[[r]]);return O(i.initializerFunctionSelector,i.initializerFunctionInputAbi,[e,t,n,a,r,x,0,x])},i.createInitCode=function(e,t,r,n,a,o,s){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===n&&(n=i.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new L),void 0===o&&(o=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=i.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");var f=i.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([n,f,r])},i.createProxyAddress=function(r,n,i,s){if(n<0n)throw RangeError("c2Nonce can't be negative");var f=t.defaultAbiCoder(),c=e(a(["bytes32","uint256"],[e(r),n])),u=f.encode(["uint256"],[s]),l=e(a(["bytes","bytes"],[this.proxyByteCode,u]));return"0x"+o(["bytes1","address","bytes32","bytes32"],["0xff",i,c,l]).slice(-40)},i.createAccountCallDataSingleTransaction=function(e){var t,r,n,a=null!=(t=e.value)?t:0,o=null!=(r=e.data)?r:"0x",s=null!=(n=e.operation)?n:u.Call;return i.createAccountCallData(e.to,a,o,s)},i.createAccountCallDataBatchTransactions=function(e,t){if(void 0===t&&(t=i.DEFAULT_MULTISEND_CONTRACT_ADDRESS),e.length<1)throw RangeError("There should be at least one metaTransaction");var r=O("0x8d80ff0a",["bytes"],[w(e)]);return i.createAccountCallData(t,0n,r,u.Delegate)},i.createAccountCallData=function(e,t,r,n,a){return void 0===a&&(a=i.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),O(a,i.executorFunctionInputAbi,[e,t,r,n])};var c=i.prototype;return c.decodeAccountCallData=function(e){if(e.startsWith(U.executeUserOpWithErrorString)||e.startsWith(U.executeUserOp)){var r=t.defaultAbiCoder(),n="0x"+e.slice(10),i=r.decode(["address","uint256","bytes","uint8"],n);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new E("BAD_DATA","Invalid calldata, should start with "+U.executeUserOpWithErrorString+" or "+U.executeUserOp,{context:{callData:e}})},c.prependTokenPaymasterApproveToCallData=function(e,r,n,a,o){void 0===o&&(o=i.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=this.decodeAccountCallData(e),f=s[0],c=s[1],l=s[2],d=s[3],p="";p="string"!=typeof l?(new TextDecoder).decode(l):l;var h=w([{to:r,value:0n,data:O(_("approve(address,uint256)"),["address","uint256"],[n,a]),operation:u.Call}]),v="",m="0x8d80ff0a";if(p.startsWith(m)){var y=function(e){return t.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(p);v=y+h.slice(2)}else v=w([{to:f,value:c,data:l,operation:d}])+h.slice(2);var A=O(m,["bytes"],[v]);return i.createAccountCallData(o,0n,A,u.Delegate)},c.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<0n)throw RangeError("numberOfSigners can't be negative");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new C(t);return Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n,BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},c.createUserOperation=function(e,t,r,a){void 0===a&&(a={});try{var o=function(){var o;function c(){var e,t;function n(){var e,t,r;if("bigint"==typeof a.preVerificationGas&&a.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof a.verificationGasLimit&&a.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof a.callGasLimit&&a.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return i.preVerificationGas=null!=(e=a.preVerificationGas)?e:o,i.verificationGasLimit=null!=(t=a.verificationGasLimit)?t:c,i.callGasLimit=null!=(r=a.callGasLimit)?r:l,i}if("bigint"==typeof a.maxFeePerGas&&a.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof a.maxPriorityFeePerGas&&a.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");p=null!=(e=a.maxFeePerGas)?e:p,v=null!=(t=a.maxPriorityFeePerGas)?t:v;var i=h({},T,{sender:s.accountAddress,nonce:f,initCode:u,callData:d,maxFeePerGas:p,maxPriorityFeePerGas:v}),o=T.preVerificationGas,c=T.verificationGasLimit,l=T.callGasLimit,m=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return Promise.resolve(s.estimateUserOperationGas(i,r,a.state_override_set,a.numberOfSigners)).then(function(e){o=e[0],c=e[1],l=e[2]})}();return m&&m.then?m.then(n):n()}var u=null!=(o=a.initCode)?o:s.initCode;if((null==u||f>0n)&&(u="0x"),f<0n)throw RangeError("nonce can't be negative");var d="0x";d=null==a.callData?1==e.length?i.createAccountCallDataSingleTransaction(e[0]):i.createAccountCallDataBatchTransactions(e):a.callData;var p=T.maxFeePerGas,v=T.maxPriorityFeePerGas,m=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return Promise.resolve(function(e,t){try{void 0===t&&(t=l.Medium);var r=new n(e);return Promise.resolve(r.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*t)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*t))]})}catch(e){return Promise.reject(e)}}(t)).then(function(e){p=e[0],v=e[1]})}();return m&&m.then?m.then(c):c()},s=this;if(e.length<1)throw RangeError("There should be at least one transaction");var f=0n,c=function(){if(null==a.nonce)return Promise.resolve(b(t,s.entrypointAddress,s.accountAddress)).then(function(e){f=e});f=a.nonce}();return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}},c.signUserOperation=function(e,t,r,n,i){if(void 0===n&&(n=0n),void 0===i&&(i=0n),t.length<1)throw RangeError("There should be at least one privateKey");if(r<0n)throw RangeError("chainId can't be negative");if(n<0n)throw RangeError("validAfter can't be negative");if(i<0n)throw RangeError("validUntil can't be negative");for(var o,c={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:n,validUntil:i,entryPoint:this.entrypointAddress},u={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},l="0x",d=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(o=d()).done;)l+=new s(o.value).signingKey.sign(f.hash({chainId:r,verifyingContract:this.safe4337ModuleAddress},u,c)).serialized.slice(2);return a(["uint48","uint48","bytes"],[n,i,l])},c.sendUserOperation=function(e,t){try{var r=this,n=new C(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new j(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},i}(d);function V(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}k.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",k.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",k.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",k.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",k.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",k.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",k.initializerFunctionSelector="0xb63e800d",k.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],k.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=U.executeUserOpWithErrorString,k.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var z=/*#__PURE__*/function(e){function t(t){var r;return(r=e.call(this)||this).rpcUrl=void 0,r.entrypointAddress=void 0,r.supportedTokens=void 0,r.paymasterMetadata=void 0,r.rpcUrl=t,r}v(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(V(function(){return Promise.resolve(e.getSupportedEntrypoint()).then(function(t){return e.entrypointAddress=t,Promise.resolve(e.getSupportedERC20TokensAndPaymasterMetadata()).then(function(t){return e.supportedTokens=t.tokens,e.paymasterMetadata=t.paymasterMetadata,null})})},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}))}catch(e){return Promise.reject(e)}},r.getPaymasterMetaData=function(){try{var e=function(){return t.paymasterMetadata},t=this,r=function(){if(null==t.paymasterMetadata)return Promise.resolve(t.initialize()).then(function(){})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokensAndPaymasterMetadata=function(){try{var e=this;return Promise.resolve(null==e.supportedTokens||null==e.paymasterMetadata?V(function(){return Promise.resolve(G(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}):{tokens:e.supportedTokens,paymasterMetadata:e.paymasterMetadata})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{var e=this;return Promise.resolve(null==e.entrypointAddress?V(function(){return Promise.resolve(G(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}):e.entrypointAddress)}catch(e){return Promise.reject(e)}},r.isSupportedERC20Token=function(e){try{var t=function(){return!!r.supportedTokens.find(function(t){return t.address===e.toLowerCase()})},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokenData=function(e){try{var t=function(){var t=r.supportedTokens.find(function(t){return t.address.toLowerCase()===e.toLowerCase()});return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.createPaymasterUserOperation=function(e,t,r,n){void 0===r&&(r={});try{var i=function(){return V(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new C(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(G(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,f={paymasterAndData:s.paymasterAndData,callGasLimit:null==s.callGasLimit?void 0:BigInt(s.callGasLimit),preVerificationGas:null==s.preVerificationGas?void 0:BigInt(s.preVerificationGas),verificationGasLimit:null==s.verificationGasLimit?void 0:BigInt(s.verificationGasLimit),maxFeePerGas:null==s.maxFeePerGas?void 0:BigInt(s.maxFeePerGas),maxPriorityFeePerGas:null==s.maxPriorityFeePerGas?void 0:BigInt(s.maxPriorityFeePerGas)};return e.paymasterAndData=f.paymasterAndData,e.callGasLimit=null!=(r=f.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=f.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=f.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=f.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})})},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},a=this,o=function(){if(null==a.entrypointAddress||null==a.supportedTokens||null==a.paymasterMetadata)return Promise.resolve(a.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,i){void 0===i&&(i={});try{var a=this;return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new E("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=S(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})}catch(e){return Promise.reject(e)}},t}(function(){}),H={__proto__:null,SmartAccount:d,SafeAccountV0_2_0:k,SendUseroperationResponse:j,SmartAccountFactory:F,SafeAccountFactory:L,Bundler:C,CandidePaymaster:z,createUserOperationHash:R,createCallData:O,getFunctionSelector:_,fetchAccountNonce:b,calculateUserOperationMaxGasCost:S,get Operation(){return u}};export{C as Bundler,z as CandidePaymaster,u as Operation,L as SafeAccountFactory,k as SafeAccountV0_2_0,j as SendUseroperationResponse,d as SmartAccount,F as SmartAccountFactory,H as abstractionkit,S as calculateUserOperationMaxGasCost,O as createCallData,R as createUserOperationHash,b as fetchAccountNonce,_ as getFunctionSelector};
|
package/dist/index.modern.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"isomorphic-unfetch";import{keccak256 as e,AbiCoder as a,id as r,ethers as s,ZeroAddress as f,solidityPacked as i,solidityPackedKeccak256 as n}from"ethers";function c(t,r,s){const f=e(function(t){const r=[t.sender,t.nonce,e(t.initCode),e(t.callData),t.callGasLimit,t.verificationGasLimit,t.preVerificationGas,t.maxFeePerGas,t.maxPriorityFeePerGas,e(t.paymasterAndData)];return a.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(t)),i=a.defaultAbiCoder().encode(["bytes32","address","uint256"],[f,r,s]);return e(i)}function o(t,e,r){return t+a.defaultAbiCoder().encode(e,r).slice(2)}async function d(e,a,r){const s=t.default||t,f={method:"POST",body:JSON.stringify({method:a,params:r,id:1,jsonrpc:"2.0"}),redirect:"follow"},i=await s(e,f);return await i.json()}function b(t){return r(t).slice(0,10)}class u{constructor(t,e,a,r,s,f){this.singletonAddress=void 0,this.proxyByteCode=void 0,this.initializerFunctionSelector=void 0,this.initializerFunctionInputAbi=void 0,this.executorFunctionSelector=void 0,this.executorFunctionInputAbi=void 0,this.singletonAddress=t,this.proxyByteCode=e,this.initializerFunctionSelector=a,this.initializerFunctionInputAbi=r,this.executorFunctionSelector=s,this.executorFunctionInputAbi=f}getInitializerCallData(t){return o(this.initializerFunctionSelector,this.initializerFunctionInputAbi,t)}getExecutorCallData(t){return o(this.executorFunctionSelector,this.executorFunctionInputAbi,t)}}var l;!function(t){t[t.Call=0]="Call",t[t.Delegate=1]="Delegate"}(l||(l={}));class h{constructor(t,e,a){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=t,this.generatorFunctionSelector=e,this.generatorFunctionInputAbi=a}getFactoryGeneratorFunctionCallData(t){const e=o(this.generatorFunctionSelector,this.generatorFunctionInputAbi,t);return this.address+e.slice(2)}}class p extends h{constructor(t="0xb73Eb505Abc30d0e7e15B73A492863235B3F4309"){super(t,"0x1688f0b9",["address","bytes","uint256"])}}function y(t){return"0x"+t.map(t=>function(t){const e=s.getBytes(t.data);return s.solidityPacked(["uint8","address","uint256","uint256","bytes"],[t.operation,t.to,t.value,e.length,e]).slice(2)}(t)).join("")}class x extends u{constructor(t="0x3A0a17Bcc84576b099373ab3Eed9702b07D30402",e="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",a=new p){super(t,"0x608060405234801561001057600080fd5b5060405161017338038061017383398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607c806100f76000396000f3fe6080604052600080546001600160a01b0316813563530ca43760e11b1415602857808252602082f35b3682833781823684845af490503d82833e806041573d82fd5b503d81f3fea2646970667358221220022b6bb97dd1e16cb867add83d4159f7550336cbb5b40514145e43f493c1377664736f6c634300080c0033","0x6a1e9826",["address[]","uint256","address","bytes","address","address","uint256","address","address"],"0xf34308ef",["address","uint256","bytes","uint8","address","address","uint256"]),this.entrypointAddress=void 0,this.candideAccountFactory=void 0,this.entrypointAddress=e,this.candideAccountFactory=a}createNewAccount(t,e=1,a=0,r="0x2a15DE4410d4c8af0A7b6c12803120f43C42B820"){const s=this.getInitializerCallData([t,e,f,"0x",r,f,0,f,this.entrypointAddress]);return[this.getProxyAddress(s,this.candideAccountFactory.address,a),this.candideAccountFactory.getFactoryGeneratorFunctionCallData([this.singletonAddress,s,a])]}createSendEthCallData(t,e){return this.createCallData(t,e,"0x",0,f,f,0)}createCallData(t,e,a,r,s,f,i){return this.getExecutorCallData([t,e,a,r,s,f,i])}getProxyAddress(t,a,r){const s=e(i(["bytes32","uint256"],[e(t),r])),f=e(i(["bytes","uint256"],[this.proxyByteCode,this.singletonAddress]));return"0x"+n(["bytes1","address","bytes32","bytes32"],["0xff",a,s,f]).slice(-40)}createCallDataSingleTransactionWithPaymaster(t,e,a,r){return this.getExecutorCallData([t.to,t.value,t.data,t.operation,e,a,r])}createCallDataSingleTransaction(t){return this.createCallDataSingleTransactionWithPaymaster(t,f,f,0)}createCallDataBatchTransactionWithPaymaster(t,e,a,r){const s=o("0x8d80ff0a",["bytes"],[y(t)]);return this.getExecutorCallData(["0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",0,s,l.Delegate,e,a,r])}createCallDataBatchTransaction(t){return this.createCallDataBatchTransactionWithPaymaster(t,f,f,0)}}class A extends h{constructor(t="0x9406Cc6185a346906296840746125a0E44976454"){super(t,"0x5fbfb9cf",["address","uint256"])}}class g extends u{constructor(t="0x8ABB13360b87Be5EEb1B98647A016adD927a136c",e="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",a=new A){super(t,"0x60806040526040516107c13803806107c183398101604081905261002291610321565b61002e82826000610035565b505061043e565b61003e8361006b565b60008251118061004b5750805b156100665761006483836100ab60201b6100291760201c565b505b505050565b610074816100d7565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606100d0838360405180606001604052806027815260200161079a602791396101a9565b9392505050565b6100ea8161022260201b6100551760201c565b6101515760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806101887f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61023160201b6100711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080856001600160a01b0316856040516101c691906103ef565b600060405180830381855af49150503d8060008114610201576040519150601f19603f3d011682016040523d82523d6000602084013e610206565b606091505b50909250905061021886838387610234565b9695505050505050565b6001600160a01b03163b151590565b90565b606083156102a357825160000361029c576001600160a01b0385163b61029c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610148565b50816102ad565b6102ad83836102b5565b949350505050565b8151156102c55781518083602001fd5b8060405162461bcd60e51b8152600401610148919061040b565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103105781810151838201526020016102f8565b838111156100645750506000910152565b6000806040838503121561033457600080fd5b82516001600160a01b038116811461034b57600080fd5b60208401519092506001600160401b038082111561036857600080fd5b818501915085601f83011261037c57600080fd5b81518181111561038e5761038e6102df565b604051601f8201601f19908116603f011681019083821181831017156103b6576103b66102df565b816040528281528860208487010111156103cf57600080fd5b6103e08360208301602088016102f5565b80955050505050509250929050565b600082516104018184602087016102f5565b9190910192915050565b602081526000825180602084015261042a8160408501602087016102f5565b601f01601f19169190910160400192915050565b61034d8061044d6000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b6100b9565b565b606061004e83836040518060600160405280602781526020016102f1602791396100dd565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b3660008037600080366000845af43d6000803e8080156100d8573d6000f35b3d6000fd5b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516101079190610283565b600060405180830381855af49150503d8060008114610142576040519150601f19603f3d011682016040523d82523d6000602084013e610147565b606091505b509150915061015886838387610162565b9695505050505050565b606083156101fd5782516000036101f65773ffffffffffffffffffffffffffffffffffffffff85163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610207565b610207838361020f565b949350505050565b81511561021f5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061029f565b60005b8381101561026e578181015183820152602001610256565b8381111561027d576000848401525b50505050565b60008251610295818460208701610253565b9190910192915050565b60208152600082518060208401526102be816040850160208701610253565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201cd78ab6a31213989661cff2d7d05fc9b9c38b1a848e8249e2e398659a9eb7e364736f6c634300080f0033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564","0xc4d66de8",["address"],"0xb61d27f6",["address","uint256","bytes"]),this.entrypointAddress=void 0,this.simpleAccountFactory=void 0,this.batchExecutorFunctionSelector=void 0,this.batchExecutorFunctionInputAbi=void 0,this.entrypointAddress=e,this.simpleAccountFactory=a,this.batchExecutorFunctionSelector="0x18dfb3c7",this.batchExecutorFunctionInputAbi=["address[]","bytes[]"]}createNewAccount(t,e=0){const a=this.getInitializerCallData([t]),r=this.simpleAccountFactory.getFactoryGeneratorFunctionCallData([t,e]);return[this.getProxyAddress(a,this.simpleAccountFactory.address,e),r]}getProxyAddress(t,r,s){const f=a.defaultAbiCoder(),c=f.encode(["uint256"],[s]),o=f.encode(["address","bytes"],[this.singletonAddress,t]),d=e(i(["bytes","bytes"],[this.proxyByteCode,o]));return"0x"+n(["bytes1","address","bytes32","bytes32"],["0xff",r,c,d]).slice(-40)}createSendEthCallData(t,e){return this.createCallData(t,e,"0x")}createCallData(t,e,a){return this.getExecutorCallData([t,e,a])}createBatchCallData(t,e){return o(this.batchExecutorFunctionSelector,this.batchExecutorFunctionInputAbi,[t,e])}}function F(){return F=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},F.apply(this,arguments)}class C{constructor(t,e){this.rpcUrl=void 0,this.entrypointAddress=void 0,this.rpcUrl=t,this.entrypointAddress=e}async chainId(){const t=await d(this.rpcUrl,"eth_chainId",[]);return"result"in t?{chainId:t.result}:t.error}async supportedEntryPoints(){const t=await d(this.rpcUrl,"eth_supportedEntryPoints",[]);return"result"in t?{supportedEntryPoints:t.result}:t.error}async estimateUserOperationGas(t){const e=await d(this.rpcUrl,"eth_estimateUserOperationGas",[t,this.entrypointAddress]);return"result"in e?e.result:e.error}async sendUserOperation(t){const e=await d(this.rpcUrl,"eth_sendUserOperation",[t,this.entrypointAddress]);return"result"in e?{userOperationHash:e.result}:e.error}async getUserOperationReceipt(t){const e=await d(this.rpcUrl,"eth_getUserOperationReceipt",[t]);if("result"in e){const t=e.result,a=F({},t.receipt,{logs:JSON.stringify(t.receipt.logs)});return F({},t,{logs:JSON.stringify(t.logs),receipt:a})}return e.error}async getUserOperationByHash(t){const e=await d(this.rpcUrl,"eth_getUserOperationByHash",[t]);return"result"in e?e.result:e.error}}class D{}class m extends D{constructor(t,e){super(),this.rpcUrl=void 0,this.entrypointAddress=void 0,this.rpcUrl=e,this.entrypointAddress=t}async getSupportedERC20Tokens(){const t=await d(this.rpcUrl,"pm_supportedERC20Tokens",[]);if("result"in t){const e=t.result;return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}}return t.error}async getSupportedEntrypoint(){const t=await d(this.rpcUrl,"pm_supportedEntryPoint",[]);return"result"in t?t.result:t.error}async getPaymasterCallDataForPayingGasWithErc20(t,e){return this.getPaymasterCallData(t,[this.rpcUrl,this.entrypointAddress,e])}async getPaymasterCallDataForGaslessTx(t){return this.getPaymasterCallData(t,[this.rpcUrl,this.entrypointAddress])}async getPaymasterCallData(t,e){const a=e[0],r=e[1],s=e[2],f=await d(a,"pm_sponsorUserOperation",[t,r,{token:s}]);return"result"in f?f.result:f.error}}const E={sender:f,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0x00",verificationGasLimit:"0x00",preVerificationGas:"0x00",maxFeePerGas:"0x00",maxPriorityFeePerGas:"0x00",paymasterAndData:"0x",signature:"0x"},P={sender:f,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0xffffff",verificationGasLimit:"0xffffff",preVerificationGas:"0xffffff",maxFeePerGas:"0xffffff",maxPriorityFeePerGas:"0xfffffff",paymasterAndData:"0x",signature:"0x"};var v={__proto__:null,SmartAccount:u,CandideAccount:x,SimpleAccount:g,SmartAccountFactory:h,CandideAccountFactory:p,SimpleAccountFactory:A,Bundler:C,CandideValidationPaymaster:m,getUserOperationHash:c,getCallData:o,getFunctionSelector:b,UserOperationEmptyValues:E,UserOperationDummyValues:P,get Operation(){return l}};export{C as Bundler,x as CandideAccount,p as CandideAccountFactory,m as CandideValidationPaymaster,l as Operation,g as SimpleAccount,A as SimpleAccountFactory,u as SmartAccount,h as SmartAccountFactory,P as UserOperationDummyValues,E as UserOperationEmptyValues,v as abstractionkit,o as getCallData,b as getFunctionSelector,c as getUserOperationHash};
|
|
1
|
+
import{keccak256 as e,AbiCoder as t,id as a,JsonRpcProvider as r,getBytes as n,solidityPacked as i,solidityPackedKeccak256 as s,Wallet as o,TypedDataEncoder as f}from"ethers";import*as c from"isomorphic-unfetch";class l{constructor(e){this.accountAddress=void 0,this.accountAddress=e}}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},d.apply(this,arguments)}var u,p;l.proxyByteCode=void 0,l.initializerFunctionSelector=void 0,l.initializerFunctionInputAbi=void 0,l.executorFunctionSelector=void 0,l.executorFunctionInputAbi=void 0,function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(u||(u={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(p||(p={}));const h={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"};class y extends Error{constructor(e,t,a={}){const{cause:r,errno:n,context:i}=a;super(t,{cause:r}),this.code=void 0,this.context=void 0,this.errno=void 0,this.name=this.constructor.name,this.code=e,this.errno=n,this.context=i}}function m(e){if(e instanceof Error)return e;let t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error(`This value was thrown as is, not through an Error: ${t}`)}function A(a,r,n){const i=e(function(a){const r=[a.sender,a.nonce,e(a.initCode),e(a.callData),a.callGasLimit,a.verificationGasLimit,a.preVerificationGas,a.maxFeePerGas,a.maxPriorityFeePerGas,e(a.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(a)),s=t.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return e(s)}function D(e,a,r){return e+t.defaultAbiCoder().encode(a,r).slice(2)}async function g(e,t,a){const r=c.default||c,n={method:"POST",body:JSON.stringify({method:t,params:a,id:(new Date).getTime(),jsonrpc:"2.0"},(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t),redirect:"follow"},i=await r(e,n),s=await i.json();if("result"in s)return s.result;{const t=s.error,a=String(t.code);throw new y(a in h?h[a]:"UNKNOWN_ERROR",t.message,{errno:t.code,context:{url:e,requestOptions:JSON.stringify(n)}})}}function E(e){return a(e).slice(0,10)}async function G(e,t,a,r=0){const n=[{from:"0x0000000000000000000000000000000000000000",to:t,data:D(E("getNonce(address,uint192)"),["address","uint192"],[a,r])},"latest"];try{const t=await g(e,"eth_call",n);if("string"!=typeof t)throw new y("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(t)});try{return BigInt(t)}catch(e){const t=m(e);throw new y("BAD_DATA","getNonce returned ill formed data",{cause:t})}}catch(e){const t=m(e);throw new y("BAD_DATA","getNonce failed",{cause:t})}}function R(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}const w="0x0000000000000000000000000000000000000000",b={sender:w,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"};class U{constructor(e,t,a){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=a}getFactoryGeneratorFunctionCallData(e){const t=D(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)}}class _ extends U{constructor(e="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"){super(e,"0x1688f0b9",["address","bytes","uint256"])}}var x;function S(e){return"0x"+e.map(e=>function(e){var t;const a=null!=(t=e.operation)?t:u.Call,r=n(e.data);return i(["uint8","address","uint256","uint256","bytes"],[a,e.to,e.value,r.length,r]).slice(2)}(e)).join("")}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(x||(x={}));class T{constructor(e){this.rpcUrl=void 0,this.rpcUrl=e}async chainId(){try{const e=await g(this.rpcUrl,"eth_chainId",[]);if("string"==typeof e)return e;throw new y("BAD_DATA","bundler eth_chainId rpc call failed")}catch(e){const t=m(e);throw new y("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}}async supportedEntryPoints(){try{return await g(this.rpcUrl,"eth_supportedEntryPoints",[])}catch(e){const t=m(e);throw new y("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}}async estimateUserOperationGas(e,t,a){try{let r={};r=void 0===a?await g(this.rpcUrl,"eth_estimateUserOperationGas",[e,t]):await g(this.rpcUrl,"eth_estimateUserOperationGas",[e,t,a]);const n=r;return{callGasLimit:BigInt(n.callGasLimit),preVerificationGas:BigInt(n.preVerificationGas),verificationGasLimit:BigInt(n.verificationGasLimit)}}catch(e){const t=m(e);throw new y("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}}async sendUserOperation(e,t){try{return await g(this.rpcUrl,"eth_sendUserOperation",[e,t])}catch(e){const t=m(e);throw new y("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}}async getUserOperationReceipt(e){try{const t=await g(this.rpcUrl,"eth_getUserOperationReceipt",[e]);if(null!=t){const e=d({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return d({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:e})}return null}catch(t){const a=m(t);throw new y("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:a,context:{useroperationhash:e}})}}async getUserOperationByHash(e){try{const t=await g(this.rpcUrl,"eth_getUserOperationByHash",[e]);return null!=t?d({},t,{blockNumber:null==t.blockNumber?null:BigInt(t.blockNumber)}):null}catch(t){const a=m(t);throw new y("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:a,context:{useroperationhash:e}})}}}class O{constructor(e,t,a){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=a}delay(e){return new Promise(t=>setTimeout(t,e))}async included(e=180,t=2){if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");let a=0;for(;a<=e;){await this.delay(1e3*t);const e=await this.bundler.getUserOperationReceipt(this.userOperationHash);if(null!=e)return e;a++}throw new y("TIMEOUT","can't find useroperation",{context:this.userOperationHash})}}class F extends l{constructor(e,t=F.DEFAULT_SAFE_4337_MODULE_ADDRESS,a=F.DEFAULT_ENTRYPOINT_ADDRESS){super(e),this.entrypointAddress=void 0,this.safe4337ModuleAddress=void 0,this.initCode=void 0,this.entrypointAddress=a,this.safe4337ModuleAddress=t,this.initCode=null}static initializeNewAccount(e,t={}){const[a,r]=F.createAccountAddressAndInitCode(e,t),n=new F(a);return n.initCode=r,n}static createAccountAddressAndInitCode(e,t={}){var a,r,n,i,s;if(e.length<1)throw RangeError("There should be at least one owner");const o=null!=(a=t.threshold)?a:1,f=null!=(r=t.c2Nonce)?r:0n,c=null!=(n=t.singletonAddress)?n:F.DEFAULT_SINGLETON_ADDRESS,l=null!=(i=t.safe4337ModuleAddress)?i:F.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:F.DEFAULT_ADD_MODULE_LIB_ADDRESS;let u=new _;null!=t.safeAccountFactoryAddress&&(u=new _(t.safeAccountFactoryAddress));const p=F.createInitializerCallData(e,o,l,d);return[this.createProxyAddress(p,f,u.address,c),u.getFactoryGeneratorFunctionCallData([c,p,f])]}static createInitializerCallData(e,t,a=F.DEFAULT_SAFE_4337_MODULE_ADDRESS,r=F.DEFAULT_ADD_MODULE_LIB_ADDRESS){if(e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");const n=D("0x8d0dc49f",["address[]"],[[a]]);return D(F.initializerFunctionSelector,F.initializerFunctionInputAbi,[e,t,r,n,a,w,0,w])}static createInitCode(e,t=1,a=0n,r=F.DEFAULT_SINGLETON_ADDRESS,n=new _,i=F.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=F.DEFAULT_ADD_MODULE_LIB_ADDRESS){if(e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(a<0n)throw RangeError("c2Nonce can't be negative");const o=F.createInitializerCallData(e,t,i,s);return n.getFactoryGeneratorFunctionCallData([r,o,a])}static createProxyAddress(a,r,n,o){if(r<0n)throw RangeError("c2Nonce can't be negative");const f=t.defaultAbiCoder(),c=e(i(["bytes32","uint256"],[e(a),r])),l=f.encode(["uint256"],[o]),d=e(i(["bytes","bytes"],[this.proxyByteCode,l]));return"0x"+s(["bytes1","address","bytes32","bytes32"],["0xff",n,c,d]).slice(-40)}static createAccountCallDataSingleTransaction(e){var t,a,r;const n=null!=(t=e.value)?t:0,i=null!=(a=e.data)?a:"0x",s=null!=(r=e.operation)?r:u.Call;return F.createAccountCallData(e.to,n,i,s)}static createAccountCallDataBatchTransactions(e,t=F.DEFAULT_MULTISEND_CONTRACT_ADDRESS){if(e.length<1)throw RangeError("There should be at least one metaTransaction");const a=D("0x8d80ff0a",["bytes"],[S(e)]);return F.createAccountCallData(t,0n,a,u.Delegate)}static createAccountCallData(e,t,a,r,n=F.DEFAULT_EXECUTOR_FUCNTION_SELECTOR){return D(n,F.executorFunctionInputAbi,[e,t,a,r])}decodeAccountCallData(e){if(e.startsWith(x.executeUserOpWithErrorString)||e.startsWith(x.executeUserOp)){const a=t.defaultAbiCoder(),r="0x"+e.slice(10),n=a.decode(["address","uint256","bytes","uint8"],r);return[n[0],BigInt(n[1]),n[2],Number(n[3])]}throw new y("BAD_DATA","Invalid calldata, should start with "+x.executeUserOpWithErrorString+" or "+x.executeUserOp,{context:{callData:e}})}prependTokenPaymasterApproveToCallData(e,a,r,n,i=F.DEFAULT_MULTISEND_CONTRACT_ADDRESS){const[s,o,f,c]=this.decodeAccountCallData(e);let l="";l="string"!=typeof f?(new TextDecoder).decode(f):f;const d=S([{to:a,value:0n,data:D(E("approve(address,uint256)"),["address","uint256"],[r,n]),operation:u.Call}]);let p="";const h="0x8d80ff0a";if(l.startsWith(h)){const e=function(e){return t.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(l);p=e+d.slice(2)}else p=S([{to:s,value:o,data:f,operation:c}])+d.slice(2);const y=D(h,["bytes"],[p]);return F.createAccountCallData(i,0n,y,u.Delegate)}async estimateUserOperationGas(e,t,a,r=1){if(r<0n)throw RangeError("numberOfSigners can't be negative");let n="";for(let e=0;e<r;e++)n+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+n;const i=new T(t),s=await i.estimateUserOperationGas(e,this.entrypointAddress,a);return[BigInt(s.preVerificationGas),BigInt(s.verificationGasLimit)+5000n,BigInt(s.callGasLimit)]}async createUserOperation(e,t,a,n={}){var i,s,o,f,c,l;if(e.length<1)throw RangeError("There should be at least one transaction");let u=0n;u=null==n.nonce?await G(t,this.entrypointAddress,this.accountAddress):n.nonce;let h=null!=(i=n.initCode)?i:this.initCode;if((null==h||u>0n)&&(h="0x"),u<0n)throw RangeError("nonce can't be negative");let y="0x";y=null==n.callData?1==e.length?F.createAccountCallDataSingleTransaction(e[0]):F.createAccountCallDataBatchTransactions(e):n.callData;let m=b.maxFeePerGas,A=b.maxPriorityFeePerGas;if(null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas||([m,A]=await async function(e,t=p.Medium){const a=new r(e),n=await a.getFeeData();return[BigInt(Math.ceil(Number(n.maxFeePerGas)*t)),BigInt(Math.ceil(Number(n.maxPriorityFeePerGas)*t))]}(t)),"bigint"==typeof n.maxFeePerGas&&n.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof n.maxPriorityFeePerGas&&n.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");m=null!=(s=n.maxFeePerGas)?s:m,A=null!=(o=n.maxPriorityFeePerGas)?o:A;const D=d({},b,{sender:this.accountAddress,nonce:u,initCode:h,callData:y,maxFeePerGas:m,maxPriorityFeePerGas:A});let g=b.preVerificationGas,E=b.verificationGasLimit,R=b.callGasLimit;if(null!=n.preVerificationGas&&null!=n.verificationGasLimit&&null!=n.callGasLimit||([g,E,R]=await this.estimateUserOperationGas(D,a,n.state_override_set,n.numberOfSigners)),"bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return D.preVerificationGas=null!=(f=n.preVerificationGas)?f:g,D.verificationGasLimit=null!=(c=n.verificationGasLimit)?c:E,D.callGasLimit=null!=(l=n.callGasLimit)?l:R,D}signUserOperation(e,t,a,r=0n,n=0n){if(t.length<1)throw RangeError("There should be at least one privateKey");if(a<0n)throw RangeError("chainId can't be negative");if(r<0n)throw RangeError("validAfter can't be negative");if(n<0n)throw RangeError("validUntil can't be negative");const s={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:r,validUntil:n,entryPoint:this.entrypointAddress},c={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]};let l="0x";for(const e of t)l+=new o(e).signingKey.sign(f.hash({chainId:a,verifyingContract:this.safe4337ModuleAddress},c,s)).serialized.slice(2);return i(["uint48","uint48","bytes"],[r,n,l])}async sendUserOperation(e,t){const a=new T(t),r=await a.sendUserOperation(e,this.entrypointAddress);return new O(r,a,this.entrypointAddress)}}F.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",F.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",F.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",F.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",F.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",F.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",F.initializerFunctionSelector="0xb63e800d",F.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],F.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=x.executeUserOpWithErrorString,F.executorFunctionInputAbi=["address","uint256","bytes","uint8"];class v{}class L extends v{constructor(e){super(),this.rpcUrl=void 0,this.entrypointAddress=void 0,this.supportedTokens=void 0,this.paymasterMetadata=void 0,this.rpcUrl=e}async initialize(){try{this.entrypointAddress=await this.getSupportedEntrypoint();const e=await this.getSupportedERC20TokensAndPaymasterMetadata();return this.supportedTokens=e.tokens,this.paymasterMetadata=e.paymasterMetadata,null}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}}async getPaymasterMetaData(){return null==this.paymasterMetadata&&await this.initialize(),this.paymasterMetadata}async getSupportedERC20TokensAndPaymasterMetadata(){if(null!=this.supportedTokens&&null!=this.paymasterMetadata)return{tokens:this.supportedTokens,paymasterMetadata:this.paymasterMetadata};try{const e=await g(this.rpcUrl,"pm_supportedERC20Tokens",[]);return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}}async getSupportedEntrypoint(){if(null!=this.entrypointAddress)return this.entrypointAddress;try{return await g(this.rpcUrl,"pm_supportedEntryPoint",[])}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}}async isSupportedERC20Token(e){return null!=this.entrypointAddress&&null!=this.supportedTokens&&null!=this.paymasterMetadata||await this.initialize(),!!this.supportedTokens.find(t=>t.address===e.toLowerCase())}async getSupportedERC20TokenData(e){null!=this.entrypointAddress&&null!=this.supportedTokens&&null!=this.paymasterMetadata||await this.initialize();const t=this.supportedTokens.find(t=>t.address.toLowerCase()===e.toLowerCase());return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null}async createPaymasterUserOperation(e,t,a={},r){null!=this.entrypointAddress&&null!=this.supportedTokens&&null!=this.paymasterMetadata||await this.initialize();try{var n,i,s,o,f;e.paymasterAndData=this.paymasterMetadata.dummyPaymasterAndData;const c=new T(t),l=await c.estimateUserOperationGas(e,this.entrypointAddress,r);e.preVerificationGas=l.preVerificationGas,e.verificationGasLimit=l.verificationGasLimit+10000n,e.callGasLimit=l.callGasLimit;const d=await g(this.rpcUrl,"pm_sponsorUserOperation",[e,this.entrypointAddress,a]),u={paymasterAndData:d.paymasterAndData,callGasLimit:null==d.callGasLimit?void 0:BigInt(d.callGasLimit),preVerificationGas:null==d.preVerificationGas?void 0:BigInt(d.preVerificationGas),verificationGasLimit:null==d.verificationGasLimit?void 0:BigInt(d.verificationGasLimit),maxFeePerGas:null==d.maxFeePerGas?void 0:BigInt(d.maxFeePerGas),maxPriorityFeePerGas:null==d.maxPriorityFeePerGas?void 0:BigInt(d.maxPriorityFeePerGas)};return e.paymasterAndData=u.paymasterAndData,e.callGasLimit=null!=(n=u.callGasLimit)?n:e.callGasLimit,e.preVerificationGas=null!=(i=u.preVerificationGas)?i:e.preVerificationGas,e.verificationGasLimit=null!=(s=u.verificationGasLimit)?s:e.verificationGasLimit,e.maxFeePerGas=null!=(o=u.maxFeePerGas)?o:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(f=u.maxPriorityFeePerGas)?f:e.maxPriorityFeePerGas,e}catch(e){const t=m(e);throw new y("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})}}async createSponsorPaymasterUserOperation(e,t,a){return await this.createPaymasterUserOperation(e,t,{},a)}async createTokenPaymasterUserOperation(e,t,a,r,n={}){const i=2n*await this.calculateUserOperationErc20TokenMaxGasCost(t,a);let s=await this.getPaymasterMetaData();const o=e.prependTokenPaymasterApproveToCallData(t.callData,a,s.address,i);return t.callData=o,await this.createPaymasterUserOperation(t,r,{token:a},n)}async calculateUserOperationErc20TokenMaxGasCost(e,t){const a=await this.getSupportedERC20TokenData(t);if(null==a)throw new y("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(await this.getSupportedERC20TokensAndPaymasterMetadata())}});{const t=R(e);return a.exchangeRate*t/BigInt(10**18)}}}var P={__proto__:null,SmartAccount:l,SafeAccountV0_2_0:F,SendUseroperationResponse:O,SmartAccountFactory:U,SafeAccountFactory:_,Bundler:T,CandidePaymaster:L,createUserOperationHash:A,createCallData:D,getFunctionSelector:E,fetchAccountNonce:G,calculateUserOperationMaxGasCost:R,get Operation(){return u}};export{T as Bundler,L as CandidePaymaster,u as Operation,_ as SafeAccountFactory,F as SafeAccountV0_2_0,O as SendUseroperationResponse,l as SmartAccount,U as SmartAccountFactory,P as abstractionkit,R as calculateUserOperationMaxGasCost,D as createCallData,A as createUserOperationHash,G as fetchAccountNonce,E as getFunctionSelector};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("isomorphic-unfetch"),require("ethers")):"function"==typeof define&&define.amd?define(["exports","isomorphic-unfetch","ethers"],t):t((e||self).abstractionkit={},e.isomorphicUnfetch,e.ethers)}(this,function(e,t,r){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var i=/*#__PURE__*/n(t),a=function(e,t,r){try{var n=i.default||i,a=JSON.stringify({method:t,params:r,id:1,jsonrpc:"2.0"});return Promise.resolve(n(e,{method:"POST",body:a,redirect:"follow"})).then(function(e){return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function f(e,t,n){var i=r.keccak256(function(e){var t=[e.sender,e.nonce,r.keccak256(e.initCode),r.keccak256(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,r.keccak256(e.paymasterAndData)];return r.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],t)}(e)),a=r.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,t,n]);return r.keccak256(a)}function c(e,t,n){return e+r.AbiCoder.defaultAbiCoder().encode(t,n).slice(2)}function o(e){return r.id(e).slice(0,10)}var s,d=/*#__PURE__*/function(){function e(e,t,r,n,i,a){this.singletonAddress=void 0,this.proxyByteCode=void 0,this.initializerFunctionSelector=void 0,this.initializerFunctionInputAbi=void 0,this.executorFunctionSelector=void 0,this.executorFunctionInputAbi=void 0,this.singletonAddress=e,this.proxyByteCode=t,this.initializerFunctionSelector=r,this.initializerFunctionInputAbi=n,this.executorFunctionSelector=i,this.executorFunctionInputAbi=a}var t=e.prototype;return t.getInitializerCallData=function(e){return c(this.initializerFunctionSelector,this.initializerFunctionInputAbi,e)},t.getExecutorCallData=function(e){return c(this.executorFunctionSelector,this.executorFunctionInputAbi,e)},e}();function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function b(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}e.Operation=void 0,(s=e.Operation||(e.Operation={}))[s.Call=0]="Call",s[s.Delegate=1]="Delegate";var p=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=c(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),h=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0xb73Eb505Abc30d0e7e15B73A492863235B3F4309"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return b(t,e),t}(p);function y(e){return"0x"+e.map(function(e){return function(e){var t=r.ethers.getBytes(e.data);return r.ethers.solidityPacked(["uint8","address","uint256","uint256","bytes"],[e.operation,e.to,e.value,t.length,t]).slice(2)}(e)}).join("")}var A=/*#__PURE__*/function(t){function n(e,r,n){var i;return void 0===e&&(e="0x3A0a17Bcc84576b099373ab3Eed9702b07D30402"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new h),(i=t.call(this,e,"0x608060405234801561001057600080fd5b5060405161017338038061017383398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607c806100f76000396000f3fe6080604052600080546001600160a01b0316813563530ca43760e11b1415602857808252602082f35b3682833781823684845af490503d82833e806041573d82fd5b503d81f3fea2646970667358221220022b6bb97dd1e16cb867add83d4159f7550336cbb5b40514145e43f493c1377664736f6c634300080c0033","0x6a1e9826",["address[]","uint256","address","bytes","address","address","uint256","address","address"],"0xf34308ef",["address","uint256","bytes","uint8","address","address","uint256"])||this).entrypointAddress=void 0,i.candideAccountFactory=void 0,i.entrypointAddress=r,i.candideAccountFactory=n,i}b(n,t);var i=n.prototype;return i.createNewAccount=function(e,t,n,i){void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i="0x2a15DE4410d4c8af0A7b6c12803120f43C42B820");var a=this.getInitializerCallData([e,t,r.ZeroAddress,"0x",i,r.ZeroAddress,0,r.ZeroAddress,this.entrypointAddress]);return[this.getProxyAddress(a,this.candideAccountFactory.address,n),this.candideAccountFactory.getFactoryGeneratorFunctionCallData([this.singletonAddress,a,n])]},i.createSendEthCallData=function(e,t){return this.createCallData(e,t,"0x",0,r.ZeroAddress,r.ZeroAddress,0)},i.createCallData=function(e,t,r,n,i,a,f){return this.getExecutorCallData([e,t,r,n,i,a,f])},i.getProxyAddress=function(e,t,n){var i=r.keccak256(r.solidityPacked(["bytes32","uint256"],[r.keccak256(e),n])),a=r.keccak256(r.solidityPacked(["bytes","uint256"],[this.proxyByteCode,this.singletonAddress]));return"0x"+r.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",t,i,a]).slice(-40)},i.createCallDataSingleTransactionWithPaymaster=function(e,t,r,n){return this.getExecutorCallData([e.to,e.value,e.data,e.operation,t,r,n])},i.createCallDataSingleTransaction=function(e){return this.createCallDataSingleTransactionWithPaymaster(e,r.ZeroAddress,r.ZeroAddress,0)},i.createCallDataBatchTransactionWithPaymaster=function(t,r,n,i){var a=c("0x8d80ff0a",["bytes"],[y(t)]);return this.getExecutorCallData(["0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",0,a,e.Operation.Delegate,r,n,i])},i.createCallDataBatchTransaction=function(e){return this.createCallDataBatchTransactionWithPaymaster(e,r.ZeroAddress,r.ZeroAddress,0)},n}(d),m=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x9406Cc6185a346906296840746125a0E44976454"),e.call(this,t,"0x5fbfb9cf",["address","uint256"])||this}return b(t,e),t}(p),v=/*#__PURE__*/function(e){function t(t,r,n){var i;return void 0===t&&(t="0x8ABB13360b87Be5EEb1B98647A016adD927a136c"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new m),(i=e.call(this,t,"0x60806040526040516107c13803806107c183398101604081905261002291610321565b61002e82826000610035565b505061043e565b61003e8361006b565b60008251118061004b5750805b156100665761006483836100ab60201b6100291760201c565b505b505050565b610074816100d7565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606100d0838360405180606001604052806027815260200161079a602791396101a9565b9392505050565b6100ea8161022260201b6100551760201c565b6101515760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806101887f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61023160201b6100711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080856001600160a01b0316856040516101c691906103ef565b600060405180830381855af49150503d8060008114610201576040519150601f19603f3d011682016040523d82523d6000602084013e610206565b606091505b50909250905061021886838387610234565b9695505050505050565b6001600160a01b03163b151590565b90565b606083156102a357825160000361029c576001600160a01b0385163b61029c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610148565b50816102ad565b6102ad83836102b5565b949350505050565b8151156102c55781518083602001fd5b8060405162461bcd60e51b8152600401610148919061040b565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103105781810151838201526020016102f8565b838111156100645750506000910152565b6000806040838503121561033457600080fd5b82516001600160a01b038116811461034b57600080fd5b60208401519092506001600160401b038082111561036857600080fd5b818501915085601f83011261037c57600080fd5b81518181111561038e5761038e6102df565b604051601f8201601f19908116603f011681019083821181831017156103b6576103b66102df565b816040528281528860208487010111156103cf57600080fd5b6103e08360208301602088016102f5565b80955050505050509250929050565b600082516104018184602087016102f5565b9190910192915050565b602081526000825180602084015261042a8160408501602087016102f5565b601f01601f19169190910160400192915050565b61034d8061044d6000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b6100b9565b565b606061004e83836040518060600160405280602781526020016102f1602791396100dd565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b3660008037600080366000845af43d6000803e8080156100d8573d6000f35b3d6000fd5b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516101079190610283565b600060405180830381855af49150503d8060008114610142576040519150601f19603f3d011682016040523d82523d6000602084013e610147565b606091505b509150915061015886838387610162565b9695505050505050565b606083156101fd5782516000036101f65773ffffffffffffffffffffffffffffffffffffffff85163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610207565b610207838361020f565b949350505050565b81511561021f5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061029f565b60005b8381101561026e578181015183820152602001610256565b8381111561027d576000848401525b50505050565b60008251610295818460208701610253565b9190910192915050565b60208152600082518060208401526102be816040850160208701610253565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201cd78ab6a31213989661cff2d7d05fc9b9c38b1a848e8249e2e398659a9eb7e364736f6c634300080f0033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564","0xc4d66de8",["address"],"0xb61d27f6",["address","uint256","bytes"])||this).entrypointAddress=void 0,i.simpleAccountFactory=void 0,i.batchExecutorFunctionSelector=void 0,i.batchExecutorFunctionInputAbi=void 0,i.entrypointAddress=r,i.simpleAccountFactory=n,i.batchExecutorFunctionSelector="0x18dfb3c7",i.batchExecutorFunctionInputAbi=["address[]","bytes[]"],i}b(t,e);var n=t.prototype;return n.createNewAccount=function(e,t){void 0===t&&(t=0);var r=this.getInitializerCallData([e]),n=this.simpleAccountFactory.getFactoryGeneratorFunctionCallData([e,t]);return[this.getProxyAddress(r,this.simpleAccountFactory.address,t),n]},n.getProxyAddress=function(e,t,n){var i=r.AbiCoder.defaultAbiCoder(),a=i.encode(["uint256"],[n]),f=i.encode(["address","bytes"],[this.singletonAddress,e]),c=r.keccak256(r.solidityPacked(["bytes","bytes"],[this.proxyByteCode,f]));return"0x"+r.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",t,a,c]).slice(-40)},n.createSendEthCallData=function(e,t){return this.createCallData(e,t,"0x")},n.createCallData=function(e,t,r){return this.getExecutorCallData([e,t,r])},n.createBatchCallData=function(e,t){return c(this.batchExecutorFunctionSelector,this.batchExecutorFunctionInputAbi,[e,t])},t}(d),x=/*#__PURE__*/function(){function e(e,t){this.rpcUrl=void 0,this.entrypointAddress=void 0,this.rpcUrl=e,this.entrypointAddress=t}var t=e.prototype;return t.chainId=function(){try{return Promise.resolve(a(this.rpcUrl,"eth_chainId",[])).then(function(e){return"result"in e?{chainId:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{return Promise.resolve(a(this.rpcUrl,"eth_supportedEntryPoints",[])).then(function(e){return"result"in e?{supportedEntryPoints:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_estimateUserOperationGas",[e,this.entrypointAddress])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_sendUserOperation",[e,this.entrypointAddress])).then(function(e){return"result"in e?{userOperationHash:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){if("result"in e){var t=e.result,r=u({},t.receipt,{logs:JSON.stringify(t.receipt.logs)});return u({},t,{logs:JSON.stringify(t.logs),receipt:r})}return e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},e}(),g=/*#__PURE__*/function(e){function t(t,r){var n;return(n=e.call(this)||this).rpcUrl=void 0,n.entrypointAddress=void 0,n.rpcUrl=r,n.entrypointAddress=t,n}b(t,e);var r=t.prototype;return r.getSupportedERC20Tokens=function(){try{return Promise.resolve(a(this.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){if("result"in e){var t=e.result;return{tokens:t.tokens,paymasterMetadata:t.paymasterMetadata}}return e.error})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{return Promise.resolve(a(this.rpcUrl,"pm_supportedEntryPoint",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForPayingGasWithErc20=function(e,t){try{var r=this;return Promise.resolve(r.getPaymasterCallData(e,[r.rpcUrl,r.entrypointAddress,t]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForGaslessTx=function(e){try{var t=this;return Promise.resolve(t.getPaymasterCallData(e,[t.rpcUrl,t.entrypointAddress]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallData=function(e,t){try{return Promise.resolve(a(t[0],"pm_sponsorUserOperation",[e,t[1],{token:t[2]}])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t}(function(){}),P={sender:r.ZeroAddress,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0x00",verificationGasLimit:"0x00",preVerificationGas:"0x00",maxFeePerGas:"0x00",maxPriorityFeePerGas:"0x00",paymasterAndData:"0x",signature:"0x"},F={sender:r.ZeroAddress,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0xffffff",verificationGasLimit:"0xffffff",preVerificationGas:"0xffffff",maxFeePerGas:"0xffffff",maxPriorityFeePerGas:"0xfffffff",paymasterAndData:"0x",signature:"0x"},C={__proto__:null,SmartAccount:d,CandideAccount:A,SimpleAccount:v,SmartAccountFactory:p,CandideAccountFactory:h,SimpleAccountFactory:m,Bundler:x,CandideValidationPaymaster:g,getUserOperationHash:f,getCallData:c,getFunctionSelector:o,UserOperationEmptyValues:P,UserOperationDummyValues:F,get Operation(){return e.Operation}};e.Bundler=x,e.CandideAccount=A,e.CandideAccountFactory=h,e.CandideValidationPaymaster=g,e.SimpleAccount=v,e.SimpleAccountFactory=m,e.SmartAccount=d,e.SmartAccountFactory=p,e.UserOperationDummyValues=F,e.UserOperationEmptyValues=P,e.abstractionkit=C,e.getCallData=c,e.getFunctionSelector=o,e.getUserOperationHash=f});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ethers"),require("isomorphic-unfetch")):"function"==typeof define&&define.amd?define(["exports","ethers","isomorphic-unfetch"],t):t((e||self).abstractionkit={},e.ethers,e.isomorphicUnfetch)}(this,function(e,t,r){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var i,a,o=/*#__PURE__*/n(r),s=function(e){this.accountAddress=void 0,this.accountAddress=e};function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function p(e){var t="function"==typeof Map?new Map:void 0;return p=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(f())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&d(i,r.prototype),i}(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},p(e)}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}s.proxyByteCode=void 0,s.initializerFunctionSelector=void 0,s.initializerFunctionInputAbi=void 0,s.executorFunctionSelector=void 0,s.executorFunctionInputAbi=void 0,e.Operation=void 0,(i=e.Operation||(e.Operation={}))[i.Call=0]="Call",i[i.Delegate=1]="Delegate",function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(a||(a={}));var v={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"},m=/*#__PURE__*/function(e){function t(t,r,n){var i;void 0===n&&(n={});var a=n.errno,o=n.context;return(i=e.call(this,r,{cause:n.cause})||this).code=void 0,i.context=void 0,i.errno=void 0,i.name=i.constructor.name,i.code=t,i.errno=a,i.context=o,i}return u(t,e),t}(/*#__PURE__*/p(Error));function y(e){if(e instanceof Error)return e;var t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error("This value was thrown as is, not through an Error: "+t)}var A=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:b(D("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(P(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new m("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=y(e);throw new m("BAD_DATA","getNonce returned ill formed data",{cause:t})}})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=y(e);throw new m("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},P=function(e,t,r){try{var n=o.default||o,i={method:"POST",body:JSON.stringify({method:t,params:r,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(n(e,i)).then(function(t){return Promise.resolve(t.json()).then(function(t){if("result"in t)return t.result;var r=t.error,n=String(r.code);throw new m(n in v?v[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(i)}})})})}catch(e){return Promise.reject(e)}};function g(e,r,n){var i=t.keccak256(function(e){var r=[e.sender,e.nonce,t.keccak256(e.initCode),t.keccak256(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,t.keccak256(e.paymasterAndData)];return t.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(e)),a=t.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return t.keccak256(a)}function b(e,r,n){return e+t.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function D(e){return t.id(e).slice(0,10)}function E(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var G,O="0x0000000000000000000000000000000000000000",R={sender:O,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},_=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=b(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),S=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return u(t,e),t}(_);function U(r){return"0x"+r.map(function(r){return a=null!=(i=(n=r).operation)?i:e.Operation.Call,o=t.getBytes(n.data),t.solidityPacked(["uint8","address","uint256","uint256","bytes"],[a,n.to,n.value,o.length,o]).slice(2);var n,i,a,o}).join("")}function x(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(G||(G={}));var T=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{var e=this;return Promise.resolve(x(function(){return Promise.resolve(P(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new m("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=y(e);throw new m("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{var e=this;return Promise.resolve(x(function(){return Promise.resolve(P(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=y(e);throw new m("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=this;return Promise.resolve(x(function(){function i(){var e=a;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var a={},o=void 0===r?Promise.resolve(P(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(P(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=y(e);throw new m("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{var r=this;return Promise.resolve(x(function(){return Promise.resolve(P(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=y(e);throw new m("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{var t=this;return Promise.resolve(x(function(){return Promise.resolve(P(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=c({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return c({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:r})}return null})},function(t){var r=y(t);throw new m("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{var t=this;return Promise.resolve(x(function(){return Promise.resolve(P(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?c({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=y(t);throw new m("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function F(e,t,r){if(!e.s){if(r instanceof L){if(!r.s)return void(r.o=F.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(F.bind(null,e,t),F.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var L=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{F(n,1,a(this.v))}catch(e){F(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?F(n,1,t?t(i):i):r?F(n,1,r(i)):F(n,2,i)}catch(e){F(n,2,e)}},n},e}();function w(e){return e instanceof L&&1&e.s}var C=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=180),void 0===t&&(t=2);try{var r,n=function(e){if(r)return e;throw new m("TIMEOUT","can't find useroperation",{context:i.userOperationHash})},i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o=function(e,t,r){for(var n;;){var i=e();if(w(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!w(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!w(o)){n=2;break}}}var s=new L,f=F.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,f),s;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!w(o))return void o.then(l).then(void 0,f);if(!(i=e())||w(i)&&!i.v)return void F(s,1,a);if(i.then)return void i.then(u).then(void 0,f);w(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,f)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,f):c(a):F(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):F(s,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){if(null!=e)return r=1,e;a++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),I=/*#__PURE__*/function(r){function n(e,t,i){var a;return void 0===t&&(t=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=n.DEFAULT_ENTRYPOINT_ADDRESS),(a=r.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.initCode=void 0,a.entrypointAddress=i,a.safe4337ModuleAddress=t,a.initCode=null,a}u(n,r),n.initializeNewAccount=function(e,t){void 0===t&&(t={});var r=n.createAccountAddressAndInitCode(e,t),i=r[1],a=new n(r[0]);return a.initCode=i,a},n.createAccountAddressAndInitCode=function(e,t){var r,i,a,o,s;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(r=t.threshold)?r:1,c=null!=(i=t.c2Nonce)?i:0n,u=null!=(a=t.singletonAddress)?a:n.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:n.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:n.DEFAULT_ADD_MODULE_LIB_ADDRESS,p=new S;null!=t.safeAccountFactoryAddress&&(p=new S(t.safeAccountFactoryAddress));var h=n.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(h,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,h,c])]},n.createInitializerCallData=function(e,t,r,i){if(void 0===r&&(r=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=n.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=b("0x8d0dc49f",["address[]"],[[r]]);return b(n.initializerFunctionSelector,n.initializerFunctionInputAbi,[e,t,i,a,r,O,0,O])},n.createInitCode=function(e,t,r,i,a,o,s){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===i&&(i=n.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new S),void 0===o&&(o=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=n.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");var f=n.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([i,f,r])},n.createProxyAddress=function(e,r,n,i){if(r<0n)throw RangeError("c2Nonce can't be negative");var a=t.AbiCoder.defaultAbiCoder(),o=t.keccak256(t.solidityPacked(["bytes32","uint256"],[t.keccak256(e),r])),s=a.encode(["uint256"],[i]),f=t.keccak256(t.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,f]).slice(-40)},n.createAccountCallDataSingleTransaction=function(t){var r,i,a,o=null!=(r=t.value)?r:0,s=null!=(i=t.data)?i:"0x",f=null!=(a=t.operation)?a:e.Operation.Call;return n.createAccountCallData(t.to,o,s,f)},n.createAccountCallDataBatchTransactions=function(t,r){if(void 0===r&&(r=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS),t.length<1)throw RangeError("There should be at least one metaTransaction");var i=b("0x8d80ff0a",["bytes"],[U(t)]);return n.createAccountCallData(r,0n,i,e.Operation.Delegate)},n.createAccountCallData=function(e,t,r,i,a){return void 0===a&&(a=n.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),b(a,n.executorFunctionInputAbi,[e,t,r,i])};var i=n.prototype;return i.decodeAccountCallData=function(e){if(e.startsWith(G.executeUserOpWithErrorString)||e.startsWith(G.executeUserOp)){var r=t.AbiCoder.defaultAbiCoder(),n="0x"+e.slice(10),i=r.decode(["address","uint256","bytes","uint8"],n);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new m("BAD_DATA","Invalid calldata, should start with "+G.executeUserOpWithErrorString+" or "+G.executeUserOp,{context:{callData:e}})},i.prependTokenPaymasterApproveToCallData=function(r,i,a,o,s){void 0===s&&(s=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var f=this.decodeAccountCallData(r),c=f[0],u=f[1],l=f[2],d=f[3],p="";p="string"!=typeof l?(new TextDecoder).decode(l):l;var h=U([{to:i,value:0n,data:b(D("approve(address,uint256)"),["address","uint256"],[a,o]),operation:e.Operation.Call}]),v="",m="0x8d80ff0a";if(p.startsWith(m)){var y=function(e){return t.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(p);v=y+h.slice(2)}else v=U([{to:c,value:u,data:l,operation:d}])+h.slice(2);var A=b(m,["bytes"],[v]);return n.createAccountCallData(s,0n,A,e.Operation.Delegate)},i.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<0n)throw RangeError("numberOfSigners can't be negative");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new T(t);return Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n,BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},i.createUserOperation=function(e,r,i,o){void 0===o&&(o={});try{var s=function(){var s;function l(){var e,t;function r(){var e,t,r;if("bigint"==typeof o.preVerificationGas&&o.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof o.verificationGasLimit&&o.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof o.callGasLimit&&o.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return n.preVerificationGas=null!=(e=o.preVerificationGas)?e:a,n.verificationGasLimit=null!=(t=o.verificationGasLimit)?t:s,n.callGasLimit=null!=(r=o.callGasLimit)?r:l,n}if("bigint"==typeof o.maxFeePerGas&&o.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof o.maxPriorityFeePerGas&&o.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");h=null!=(e=o.maxFeePerGas)?e:h,v=null!=(t=o.maxPriorityFeePerGas)?t:v;var n=c({},R,{sender:f.accountAddress,nonce:u,initCode:d,callData:p,maxFeePerGas:h,maxPriorityFeePerGas:v}),a=R.preVerificationGas,s=R.verificationGasLimit,l=R.callGasLimit,m=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return Promise.resolve(f.estimateUserOperationGas(n,i,o.state_override_set,o.numberOfSigners)).then(function(e){a=e[0],s=e[1],l=e[2]})}();return m&&m.then?m.then(r):r()}var d=null!=(s=o.initCode)?s:f.initCode;if((null==d||u>0n)&&(d="0x"),u<0n)throw RangeError("nonce can't be negative");var p="0x";p=null==o.callData?1==e.length?n.createAccountCallDataSingleTransaction(e[0]):n.createAccountCallDataBatchTransactions(e):o.callData;var h=R.maxFeePerGas,v=R.maxPriorityFeePerGas,m=function(){if(null==o.maxFeePerGas||null==o.maxPriorityFeePerGas)return Promise.resolve(function(e,r){try{void 0===r&&(r=a.Medium);var n=new t.JsonRpcProvider(e);return Promise.resolve(n.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*r)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*r))]})}catch(e){return Promise.reject(e)}}(r)).then(function(e){h=e[0],v=e[1]})}();return m&&m.then?m.then(l):l()},f=this;if(e.length<1)throw RangeError("There should be at least one transaction");var u=0n,l=function(){if(null==o.nonce)return Promise.resolve(A(r,f.entrypointAddress,f.accountAddress)).then(function(e){u=e});u=o.nonce}();return Promise.resolve(l&&l.then?l.then(s):s())}catch(e){return Promise.reject(e)}},i.signUserOperation=function(e,r,n,i,a){if(void 0===i&&(i=0n),void 0===a&&(a=0n),r.length<1)throw RangeError("There should be at least one privateKey");if(n<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(a<0n)throw RangeError("validUntil can't be negative");for(var o,s={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:i,validUntil:a,entryPoint:this.entrypointAddress},f={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},c="0x",u=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(o=u()).done;)c+=new t.Wallet(o.value).signingKey.sign(t.TypedDataEncoder.hash({chainId:n,verifyingContract:this.safe4337ModuleAddress},f,s)).serialized.slice(2);return t.solidityPacked(["uint48","uint48","bytes"],[i,a,c])},i.sendUserOperation=function(e,t){try{var r=this,n=new T(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new C(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},n}(s);function N(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}I.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",I.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",I.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",I.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",I.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",I.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",I.initializerFunctionSelector="0xb63e800d",I.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],I.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=G.executeUserOpWithErrorString,I.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var B=/*#__PURE__*/function(e){function t(t){var r;return(r=e.call(this)||this).rpcUrl=void 0,r.entrypointAddress=void 0,r.supportedTokens=void 0,r.paymasterMetadata=void 0,r.rpcUrl=t,r}u(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(N(function(){return Promise.resolve(e.getSupportedEntrypoint()).then(function(t){return e.entrypointAddress=t,Promise.resolve(e.getSupportedERC20TokensAndPaymasterMetadata()).then(function(t){return e.supportedTokens=t.tokens,e.paymasterMetadata=t.paymasterMetadata,null})})},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}))}catch(e){return Promise.reject(e)}},r.getPaymasterMetaData=function(){try{var e=function(){return t.paymasterMetadata},t=this,r=function(){if(null==t.paymasterMetadata)return Promise.resolve(t.initialize()).then(function(){})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokensAndPaymasterMetadata=function(){try{var e=this;return Promise.resolve(null==e.supportedTokens||null==e.paymasterMetadata?N(function(){return Promise.resolve(P(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}):{tokens:e.supportedTokens,paymasterMetadata:e.paymasterMetadata})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{var e=this;return Promise.resolve(null==e.entrypointAddress?N(function(){return Promise.resolve(P(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}):e.entrypointAddress)}catch(e){return Promise.reject(e)}},r.isSupportedERC20Token=function(e){try{var t=function(){return!!r.supportedTokens.find(function(t){return t.address===e.toLowerCase()})},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokenData=function(e){try{var t=function(){var t=r.supportedTokens.find(function(t){return t.address.toLowerCase()===e.toLowerCase()});return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.createPaymasterUserOperation=function(e,t,r,n){void 0===r&&(r={});try{var i=function(){return N(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new T(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(P(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,f={paymasterAndData:s.paymasterAndData,callGasLimit:null==s.callGasLimit?void 0:BigInt(s.callGasLimit),preVerificationGas:null==s.preVerificationGas?void 0:BigInt(s.preVerificationGas),verificationGasLimit:null==s.verificationGasLimit?void 0:BigInt(s.verificationGasLimit),maxFeePerGas:null==s.maxFeePerGas?void 0:BigInt(s.maxFeePerGas),maxPriorityFeePerGas:null==s.maxPriorityFeePerGas?void 0:BigInt(s.maxPriorityFeePerGas)};return e.paymasterAndData=f.paymasterAndData,e.callGasLimit=null!=(r=f.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=f.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=f.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=f.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})})},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},a=this,o=function(){if(null==a.entrypointAddress||null==a.supportedTokens||null==a.paymasterMetadata)return Promise.resolve(a.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,i){void 0===i&&(i={});try{var a=this;return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new m("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=E(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})}catch(e){return Promise.reject(e)}},t}(function(){}),k={__proto__:null,SmartAccount:s,SafeAccountV0_2_0:I,SendUseroperationResponse:C,SmartAccountFactory:_,SafeAccountFactory:S,Bundler:T,CandidePaymaster:B,createUserOperationHash:g,createCallData:b,getFunctionSelector:D,fetchAccountNonce:A,calculateUserOperationMaxGasCost:E,get Operation(){return e.Operation}};e.Bundler=T,e.CandidePaymaster=B,e.SafeAccountFactory=S,e.SafeAccountV0_2_0=I,e.SendUseroperationResponse=C,e.SmartAccount=s,e.SmartAccountFactory=_,e.abstractionkit=k,e.calculateUserOperationMaxGasCost=E,e.createCallData=b,e.createUserOperationHash=g,e.fetchAccountNonce=A,e.getFunctionSelector=D});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Paymaster } from "./Paymaster";
|
|
2
|
+
import { UserOperation, SupportedERC20TokensAndMetadata, PaymasterMetadata, ERC20Token, StateOverrideSet } from "../types";
|
|
3
|
+
import { CandidePaymasterContext } from "./types";
|
|
4
|
+
import { SmartAccount } from "src/abstractionkit";
|
|
5
|
+
export declare class CandidePaymaster extends Paymaster {
|
|
6
|
+
readonly rpcUrl: string;
|
|
7
|
+
private entrypointAddress;
|
|
8
|
+
private supportedTokens;
|
|
9
|
+
private paymasterMetadata;
|
|
10
|
+
constructor(rpcUrl: string);
|
|
11
|
+
initialize(): Promise<null>;
|
|
12
|
+
getPaymasterMetaData(): Promise<PaymasterMetadata>;
|
|
13
|
+
getSupportedERC20TokensAndPaymasterMetadata(): Promise<SupportedERC20TokensAndMetadata>;
|
|
14
|
+
getSupportedEntrypoint(): Promise<string>;
|
|
15
|
+
isSupportedERC20Token(erc20TokenAddress: string): Promise<boolean>;
|
|
16
|
+
getSupportedERC20TokenData(erc20TokenAddress: string): Promise<ERC20Token | null>;
|
|
17
|
+
createPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, context?: CandidePaymasterContext, state_override_set?: StateOverrideSet): Promise<UserOperation>;
|
|
18
|
+
createSponsorPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, state_override_set?: StateOverrideSet): Promise<UserOperation>;
|
|
19
|
+
createTokenPaymasterUserOperation(smartAccount: SmartAccount, userOperation: UserOperation, tokenAddress: string, bundlerRpc: string, state_override_set?: StateOverrideSet): Promise<UserOperation>;
|
|
20
|
+
calculateUserOperationErc20TokenMaxGasCost(userOperation: UserOperation, erc20TokenAddress: string): Promise<bigint>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=CandidePaymaster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CandidePaymaster.d.ts","sourceRoot":"","sources":["../../src/paymaster/CandidePaymaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACN,aAAa,EACb,+BAA+B,EAE/B,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,qBAAa,gBAAiB,SAAQ,SAAS;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,iBAAiB,CAAgC;gBAE7C,MAAM,EAAE,MAAM;IAUpB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB3B,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAOlD,2CAA2C,IAAI,OAAO,CAAC,+BAA+B,CAAC;IAgCvF,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IA8BzC,qBAAqB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAyBlE,0BAA0B,CAC/B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAoCvB,4BAA4B,CACjC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,uBAA4B,EACrC,kBAAkB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,aAAa,CAAC;IAqFnB,mCAAmC,CACxC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,MAAM,EAClB,kBAAkB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,aAAa,CAAC;IAmBnB,iCAAiC,CACtC,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,kBAAkB,GAAE,gBAAqB,GACvC,OAAO,CAAC,aAAa,CAAC;IAgCnB,0CAA0C,CAC/C,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC;CAuBlB"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import
|
|
3
|
-
import type { UserOperation, JsonRpcError } from "../types";
|
|
1
|
+
import type { UserOperation, StateOverrideSet } from "../types";
|
|
2
|
+
import { CandidePaymasterContext } from "./types";
|
|
4
3
|
export declare abstract class Paymaster {
|
|
5
|
-
abstract
|
|
6
|
-
paymasterAndData: BytesLike;
|
|
7
|
-
} | JsonRpcError>;
|
|
4
|
+
abstract createPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, context: CandidePaymasterContext, state_override_set?: StateOverrideSet): Promise<UserOperation>;
|
|
8
5
|
}
|
|
9
6
|
//# sourceMappingURL=Paymaster.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paymaster.d.ts","sourceRoot":"","sources":["../../src/paymaster/Paymaster.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Paymaster.d.ts","sourceRoot":"","sources":["../../src/paymaster/Paymaster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,8BAAsB,SAAS;IAC9B,QAAQ,CAAC,4BAA4B,CACpC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,uBAAuB,EAChC,kBAAkB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,aAAa,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paymaster/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CACf"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,82 +1,92 @@
|
|
|
1
|
-
import type { BigNumberish, BytesLike } from "ethers";
|
|
2
1
|
export type UserOperation = {
|
|
3
2
|
sender: string;
|
|
4
|
-
nonce:
|
|
5
|
-
initCode:
|
|
6
|
-
callData:
|
|
7
|
-
callGasLimit:
|
|
8
|
-
verificationGasLimit:
|
|
9
|
-
preVerificationGas:
|
|
10
|
-
maxFeePerGas:
|
|
11
|
-
maxPriorityFeePerGas:
|
|
12
|
-
paymasterAndData:
|
|
13
|
-
signature:
|
|
3
|
+
nonce: bigint;
|
|
4
|
+
initCode: string;
|
|
5
|
+
callData: string;
|
|
6
|
+
callGasLimit: bigint;
|
|
7
|
+
verificationGasLimit: bigint;
|
|
8
|
+
preVerificationGas: bigint;
|
|
9
|
+
maxFeePerGas: bigint;
|
|
10
|
+
maxPriorityFeePerGas: bigint;
|
|
11
|
+
paymasterAndData: string;
|
|
12
|
+
signature: string;
|
|
14
13
|
};
|
|
15
|
-
export type AbiInputValue = string |
|
|
16
|
-
export type JsonRpcParam = string |
|
|
14
|
+
export type AbiInputValue = string | bigint | number | boolean | AbiInputValue[];
|
|
15
|
+
export type JsonRpcParam = string | bigint | boolean | object | JsonRpcParam[];
|
|
17
16
|
export type JsonRpcResponse = {
|
|
18
|
-
id: number;
|
|
17
|
+
id: number | null;
|
|
18
|
+
jsonrpc: string;
|
|
19
19
|
result?: JsonRpcResult;
|
|
20
20
|
error?: JsonRpcError;
|
|
21
21
|
};
|
|
22
|
-
export type
|
|
22
|
+
export type ChainIdResult = string;
|
|
23
|
+
export type SupportedEntryPointsResult = string[];
|
|
24
|
+
export type JsonRpcResult = ChainIdResult | SupportedEntryPointsResult | GasEstimationResult | UserOperationByHashResult | UserOperationReceipt | UserOperationReceiptResult | SupportedERC20TokensAndMetadata | PmUserOperationResult;
|
|
23
25
|
export type JsonRpcError = {
|
|
24
26
|
code: number;
|
|
25
27
|
message: string;
|
|
28
|
+
data: object;
|
|
26
29
|
};
|
|
27
30
|
export type GasEstimationResult = {
|
|
28
|
-
callGasLimit:
|
|
29
|
-
preVerificationGas:
|
|
30
|
-
verificationGasLimit:
|
|
31
|
+
callGasLimit: bigint;
|
|
32
|
+
preVerificationGas: bigint;
|
|
33
|
+
verificationGasLimit: bigint;
|
|
31
34
|
};
|
|
32
35
|
export type UserOperationByHashResult = {
|
|
33
36
|
userOperation: UserOperation;
|
|
34
37
|
entryPoint: string;
|
|
35
|
-
blockNumber:
|
|
36
|
-
blockHash:
|
|
37
|
-
transactionHash:
|
|
38
|
-
};
|
|
38
|
+
blockNumber: bigint | null;
|
|
39
|
+
blockHash: string | null;
|
|
40
|
+
transactionHash: string | null;
|
|
41
|
+
} | null;
|
|
39
42
|
export type UserOperationReceipt = {
|
|
40
|
-
blockHash:
|
|
41
|
-
blockNumber:
|
|
43
|
+
blockHash: string;
|
|
44
|
+
blockNumber: bigint;
|
|
42
45
|
from: string;
|
|
43
|
-
cumulativeGasUsed:
|
|
44
|
-
gasUsed:
|
|
46
|
+
cumulativeGasUsed: bigint;
|
|
47
|
+
gasUsed: bigint;
|
|
45
48
|
logs: string;
|
|
46
49
|
logsBloom: string;
|
|
47
|
-
transactionHash:
|
|
48
|
-
transactionIndex:
|
|
50
|
+
transactionHash: string;
|
|
51
|
+
transactionIndex: bigint;
|
|
52
|
+
effectiveGasPrice?: bigint;
|
|
49
53
|
};
|
|
50
54
|
export type UserOperationReceiptResult = {
|
|
51
|
-
userOpHash:
|
|
55
|
+
userOpHash: string;
|
|
52
56
|
entryPoint: string;
|
|
53
57
|
sender: string;
|
|
54
|
-
nonce:
|
|
58
|
+
nonce: bigint;
|
|
55
59
|
paymaster: string;
|
|
56
|
-
actualGasCost:
|
|
57
|
-
actualGasUsed:
|
|
58
|
-
success:
|
|
60
|
+
actualGasCost: bigint;
|
|
61
|
+
actualGasUsed: bigint;
|
|
62
|
+
success: boolean;
|
|
59
63
|
logs: string;
|
|
60
64
|
receipt: UserOperationReceipt;
|
|
61
|
-
};
|
|
62
|
-
export type
|
|
63
|
-
paymasterAndData:
|
|
64
|
-
callGasLimit
|
|
65
|
-
preVerificationGas
|
|
66
|
-
verificationGasLimit
|
|
67
|
-
maxFeePerGas
|
|
68
|
-
maxPriorityFeePerGas
|
|
65
|
+
} | null;
|
|
66
|
+
export type PmUserOperationResult = {
|
|
67
|
+
paymasterAndData: string;
|
|
68
|
+
callGasLimit?: bigint;
|
|
69
|
+
preVerificationGas?: bigint;
|
|
70
|
+
verificationGasLimit?: bigint;
|
|
71
|
+
maxFeePerGas?: bigint;
|
|
72
|
+
maxPriorityFeePerGas?: bigint;
|
|
69
73
|
};
|
|
70
74
|
export declare enum Operation {
|
|
71
75
|
Call = 0,
|
|
72
76
|
Delegate = 1
|
|
73
77
|
}
|
|
78
|
+
export interface MetaTransaction {
|
|
79
|
+
to: string;
|
|
80
|
+
value: bigint;
|
|
81
|
+
data: string;
|
|
82
|
+
operation?: Operation;
|
|
83
|
+
}
|
|
74
84
|
export interface ERC20Token {
|
|
75
85
|
symbol: string;
|
|
76
86
|
address: string;
|
|
77
87
|
decimal: number;
|
|
78
|
-
fee:
|
|
79
|
-
exchangeRate:
|
|
88
|
+
fee: bigint;
|
|
89
|
+
exchangeRate: bigint;
|
|
80
90
|
}
|
|
81
91
|
export interface PaymasterMetadata {
|
|
82
92
|
name: string;
|
|
@@ -86,8 +96,26 @@ export interface PaymasterMetadata {
|
|
|
86
96
|
sponsoredEventTopic: string;
|
|
87
97
|
dummyPaymasterAndData: string;
|
|
88
98
|
}
|
|
89
|
-
export interface
|
|
99
|
+
export interface SupportedERC20TokensAndMetadata {
|
|
90
100
|
paymasterMetadata: PaymasterMetadata;
|
|
91
101
|
tokens: ERC20Token[];
|
|
92
102
|
}
|
|
103
|
+
export interface Dictionary<T> {
|
|
104
|
+
[Key: string]: T;
|
|
105
|
+
}
|
|
106
|
+
export type AddressToState = {
|
|
107
|
+
balance?: bigint;
|
|
108
|
+
nonce?: bigint;
|
|
109
|
+
code?: string;
|
|
110
|
+
state?: Dictionary<string>;
|
|
111
|
+
stateDiff?: Dictionary<string>;
|
|
112
|
+
};
|
|
113
|
+
export type StateOverrideSet = {
|
|
114
|
+
[key: string]: AddressToState;
|
|
115
|
+
};
|
|
116
|
+
export declare enum GasOption {
|
|
117
|
+
Slow = 1,
|
|
118
|
+
Medium = 1.2,
|
|
119
|
+
Fast = 1.5
|
|
120
|
+
}
|
|
93
121
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GACtB,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,aAAa,EAAE,CAAC;AAEnB,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,EAAE,CAAC;AAE/E,MAAM,MAAM,eAAe,GAAG;IAC7B,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,MAAM,MAAM,0BAA0B,GAAG,MAAM,EAAE,CAAC;AAElD,MAAM,MAAM,aAAa,GACtB,aAAa,GACb,0BAA0B,GAC1B,mBAAmB,GACnB,yBAAyB,GACzB,oBAAoB,GACpB,0BAA0B,GAC1B,+BAA+B,GAC/B,qBAAqB,CAAC;AAEzB,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACvC,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,GAAG,IAAI,CAAC;AAET,MAAM,MAAM,oBAAoB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,oBAAoB,CAAC;CAC9B,GAAG,IAAI,CAAC;AAET,MAAM,MAAM,qBAAqB,GAAG;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAKF,oBAAY,SAAS;IACpB,IAAI,IAAI;IACR,QAAQ,IAAI;CACZ;AAKD,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;CACtB;AAKD,MAAM,WAAW,UAAU;IAE1B,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,MAAM,CAAC;IAEhB,GAAG,EAAE,MAAM,CAAC;IAEZ,YAAY,EAAE,MAAM,CAAC;CACrB;AAKD,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAEhB,OAAO,EAAE,MAAM,CAAC;IAEhB,mBAAmB,EAAE,MAAM,CAAC;IAE5B,qBAAqB,EAAE,MAAM,CAAC;CAC9B;AAKD,MAAM,WAAW,+BAA+B;IAC/C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,UAAU,EAAE,CAAC;CACrB;AAKD,MAAM,WAAW,UAAU,CAAC,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CACjB;AAKD,MAAM,MAAM,cAAc,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAKF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC9B,CAAC;AAKF,oBAAY,SAAS;IACpB,IAAI,IAAI;IACR,MAAM,MAAM;IACZ,IAAI,MAAM;CACV"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function sendJsonRpcRequest(rpcUrl: string, method: string, params: JsonRpcParam): Promise<JsonRpcResponse>;
|
|
1
|
+
import { AbiInputValue, UserOperation, JsonRpcParam, GasOption, JsonRpcResult } from "./types";
|
|
2
|
+
export declare function createUserOperationHash(useroperation: UserOperation, entrypointAddress: string, chainId: bigint): string;
|
|
3
|
+
export declare function createPackedUserOperation(useroperation: UserOperation): string;
|
|
4
|
+
export declare function createCallData(functionSelector: string, functionInputAbi: string[], functionInputParameters: AbiInputValue[]): string;
|
|
5
|
+
export declare function sendJsonRpcRequest(rpcUrl: string, method: string, params: JsonRpcParam): Promise<JsonRpcResult>;
|
|
7
6
|
export declare function getFunctionSelector(functionSignature: string): string;
|
|
7
|
+
export declare function fetchAccountNonce(rpcUrl: string, entryPoint: string, account: string, key?: number): Promise<bigint>;
|
|
8
|
+
export declare function fetchGasPrice(provideRpc: string, gasLevel?: GasOption): Promise<[bigint, bigint]>;
|
|
9
|
+
export declare function calculateUserOperationMaxGasCost(useroperation: UserOperation): bigint;
|
|
8
10
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,aAAa,EACb,aAAa,EAEb,YAAY,EAEZ,SAAS,EACT,aAAa,EACb,MAAM,SAAS,CAAC;AAcjB,wBAAgB,uBAAuB,CACtC,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,GACb,MAAM,CAcR;AAOD,wBAAgB,yBAAyB,CACxC,aAAa,EAAE,aAAa,GAC1B,MAAM,CA+BR;AASD,wBAAgB,cAAc,CAC7B,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,uBAAuB,EAAE,aAAa,EAAE,GACtC,MAAM,CASR;AAED,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,aAAa,CAAC,CAmDxB;AAWD,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAErE;AAUD,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAU,GACb,OAAO,CAAC,MAAM,CAAC,CAqDjB;AAED,wBAAsB,aAAa,CAClC,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,SAA4B,GACpC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAW3B;AAED,wBAAgB,gCAAgC,CAC/C,aAAa,EAAE,aAAa,GAC1B,MAAM,CAWR"}
|