multicoyn-sdk 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 +95 -0
- package/dist/ccip-BXLlQVZi.cjs +1 -0
- package/dist/ccip-Do0z8AZp.js +237 -0
- package/dist/index-C71hhSSX.cjs +34 -0
- package/dist/index-QyDcHjLV.js +5417 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +25 -0
- package/dist/multicoyn-sdk.css +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),j=require("react"),A=require("wagmi"),ce=require("viem"),zt=require("@tanstack/react-query"),_t=require("@rainbow-me/rainbowkit");function or({size:e=26,className:t=""}){return c.jsx("svg",{width:e,height:e,viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:c.jsx("path",{d:"M6.5 6.5L19.5 19.5M6.5 19.5L19.5 6.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function cr({size:e=16,className:t=""}){return c.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[c.jsx("path",{d:"M7.33333 12.6667C10.2789 12.6667 12.6667 10.2789 12.6667 7.33333C12.6667 4.38781 10.2789 2 7.33333 2C4.38781 2 2 4.38781 2 7.33333C2 10.2789 4.38781 12.6667 7.33333 12.6667Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M14 14L11.1 11.1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ur({size:e=16,className:t=""}){return c.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[c.jsx("path",{d:"M8 14.6667C11.6819 14.6667 14.6667 11.6819 14.6667 8C14.6667 4.3181 11.6819 1.33333 8 1.33333C4.3181 1.33333 1.33333 4.3181 1.33333 8C1.33333 11.6819 4.3181 14.6667 8 14.6667Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M8 10.6667V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M8 5.33333H8.00667",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function dr({size:e=134,className:t=""}){return c.jsxs("svg",{width:e,height:e,viewBox:"0 0 134 132",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[c.jsx("circle",{cx:"67",cy:"66",r:"55",fill:"#5EEAD4",fillOpacity:"0.2"}),c.jsx("circle",{cx:"67",cy:"66",r:"45",fill:"#5EEAD4",fillOpacity:"0.3"}),c.jsx("rect",{x:"35",y:"30",width:"45",height:"72",rx:"4",fill:"#14B8A6"}),c.jsx("rect",{x:"38",y:"35",width:"39",height:"55",rx:"2",fill:"#0D9488"}),c.jsxs("g",{className:"animate-pulse",children:[c.jsx("rect",{x:"55",y:"50",width:"50",height:"32",rx:"3",fill:"#1E293B"}),c.jsx("rect",{x:"60",y:"56",width:"20",height:"3",rx:"1",fill:"#475569"}),c.jsx("rect",{x:"60",y:"62",width:"30",height:"2",rx:"1",fill:"#475569"}),c.jsx("rect",{x:"60",y:"68",width:"15",height:"2",rx:"1",fill:"#475569"})]}),c.jsx("ellipse",{cx:"95",cy:"85",rx:"12",ry:"8",fill:"#FCD9BD"}),c.jsx("rect",{x:"88",y:"78",width:"8",height:"20",rx:"4",fill:"#FCD9BD"}),c.jsx("circle",{cx:"20",cy:"25",r:"8",fill:"#FCD34D"}),c.jsx("text",{x:"20",y:"29",textAnchor:"middle",fontSize:"10",fill:"#92400E",children:"$"}),c.jsx("circle",{cx:"115",cy:"35",r:"6",fill:"#FCD34D"}),c.jsx("text",{x:"115",y:"38",textAnchor:"middle",fontSize:"8",fill:"#92400E",children:"$"}),c.jsx("circle",{cx:"110",cy:"20",r:"5",fill:"#FCD34D",fillOpacity:"0.6"})]})}function lr({size:e=95,className:t=""}){return c.jsxs("svg",{width:e*2.1,height:e,viewBox:"0 0 200 95",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[c.jsx("circle",{cx:"30",cy:"20",r:"3",fill:"#FCD34D"}),c.jsx("circle",{cx:"170",cy:"25",r:"4",fill:"#5EEAD4"}),c.jsx("circle",{cx:"25",cy:"70",r:"2",fill:"#A78BFA"}),c.jsx("circle",{cx:"175",cy:"65",r:"3",fill:"#F472B6"}),c.jsx("circle",{cx:"50",cy:"85",r:"2",fill:"#60A5FA"}),c.jsx("circle",{cx:"150",cy:"80",r:"2",fill:"#FCD34D"}),c.jsx("path",{d:"M45 30L46 33L49 33L47 35L48 38L45 36L42 38L43 35L41 33L44 33Z",fill:"#FCD34D"}),c.jsx("path",{d:"M160 45L161 47L163 47L161.5 48.5L162 51L160 49.5L158 51L158.5 48.5L157 47L159 47Z",fill:"#FCD34D"}),c.jsx("circle",{cx:"100",cy:"47",r:"35",fill:"url(#successGradient)"}),c.jsx("circle",{cx:"100",cy:"47",r:"30",fill:"#22C55E"}),c.jsx("path",{d:"M85 47L95 57L115 37",stroke:"white",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("circle",{cx:"100",cy:"47",r:"38",stroke:"#22C55E",strokeWidth:"2",strokeOpacity:"0.3"}),c.jsx("circle",{cx:"100",cy:"47",r:"42",stroke:"#22C55E",strokeWidth:"1",strokeOpacity:"0.2"}),c.jsx("defs",{children:c.jsxs("linearGradient",{id:"successGradient",x1:"65",y1:"12",x2:"135",y2:"82",gradientUnits:"userSpaceOnUse",children:[c.jsx("stop",{stopColor:"#4ADE80"}),c.jsx("stop",{offset:"1",stopColor:"#16A34A"})]})})]})}function fr({token:e,onChange:t,totalAmount:n}){const r=u=>{t(Number(u.target.value))},s=n*e.percentage/100,i=e.priceUSD>0?s/e.priceUSD:0,a=i<=e.amount,o=e.priceUSD>0;return c.jsxs("div",{className:"flex items-center gap-1.5 w-full",children:[c.jsxs("div",{className:"flex items-center gap-3 w-35",children:[c.jsxs("div",{className:"relative size-[30px]",children:[c.jsx("div",{className:`size-[30px] rounded-full bg-dark-4 overflow-hidden flex items-center justify-center ${o?"":"opacity-50"}`,children:e.tokenIcon?c.jsx("img",{src:e.tokenIcon,alt:e.name,className:"size-full object-cover"}):c.jsx("span",{className:"text-xs font-semibold text-white",children:e.symbol.slice(0,2)})}),c.jsx("div",{className:"absolute right-[-2px] bottom-[-2px] size-[12px] rounded-full bg-dark-3 border border-dark-2 overflow-hidden flex items-center justify-center",children:e.chainIcon?c.jsx("img",{src:e.chainIcon,alt:e.chain,className:"size-full object-cover"}):c.jsx("span",{className:"text-[6px] font-semibold text-white",children:e.chain.slice(0,1)})})]}),c.jsxs("div",{className:"flex flex-col gap-1 text-xs text-white",children:[c.jsx("span",{className:"font-semibold",children:e.name}),c.jsxs("span",{className:"font-normal opacity-75",children:[e.amount.toFixed(4)," ",e.symbol]}),c.jsx("span",{className:`text-[10px] ${o?"text-white/50":"text-yellow-500"}`,children:o?`$${e.priceUSD.toFixed(2)}/${e.symbol}`:"Price loading..."})]})]}),c.jsxs("div",{className:"flex-1 relative h-1.5",children:[c.jsx("div",{className:"absolute inset-0 bg-white/40 rounded-full"}),c.jsx("div",{className:"absolute left-0 top-0 h-full bg-secondary rounded-full transition-all",style:{width:`${e.percentage}%`}}),c.jsx("input",{type:"range",min:"0",max:"100",value:e.percentage,onChange:r,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:e.amount===0||!o})]}),c.jsxs("div",{className:"flex flex-col items-end gap-0.5 min-w-25",children:[c.jsxs("span",{className:"text-xs font-semibold text-white",children:[e.percentage,"% = $",s.toFixed(2)]}),e.percentage>0&&c.jsxs("span",{className:`text-[10px] ${a?"text-white/60":"text-red-500"}`,children:[i.toFixed(4)," ",e.symbol,!a&&" ⚠️"]})]})]})}function Gt({items:e,fee:t=.3}){const r=e.reduce((s,i)=>s+i.price,0)+t;return c.jsxs("div",{className:"bg-dark-4 rounded-md p-3 flex flex-col gap-3 w-full",children:[c.jsx("p",{className:"font-medium text-base text-white",children:"Payment Summary"}),e.map((s,i)=>c.jsxs("div",{className:"flex items-center justify-between text-xs text-white",children:[c.jsx("span",{className:"flex-1",children:s.name}),c.jsxs("span",{className:"text-right",children:["$",s.price.toFixed(2)]})]},i)),c.jsxs("div",{className:"flex items-center justify-between text-xs text-white",children:[c.jsx("span",{className:"flex-1",children:"Fee"}),c.jsxs("span",{className:"text-right",children:["$",t.toFixed(2)]})]}),c.jsx("div",{className:"h-px bg-white/20"}),c.jsxs("div",{className:"flex items-center justify-between text-white",children:[c.jsx("span",{className:"text-xs",children:"Total Payment"}),c.jsxs("span",{className:"text-base font-semibold text-right",children:["$",r.toFixed(2)]})]})]})}const I={PAYMENT_ROUTER:"0x7b3dfd5A3F3903237faC3D2de69d4c1915A09C9A",TOKEN_REGISTRY:"0x8515a560284AedE5D78Ff5b73f2CeCa247DCAab7"},S={NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0x5DD8eEF51d251a53D6368CfD79a88F3BC186514B",USDT:"0xc9013AD6e74A7dC418b2e601aaCD772044E59c22",DAI:"0xF84851B3A4253b74813112A5488E38E724731E2a",WBTC:"0x437f0b6328892ac36E01836aBc865d16c875D291",IDRX:"0x5324Cd3e781cf85Cf63253138Ef6c6E84143de7B"},pr=JSON.parse('[{"inputs":[{"internalType":"address","name":"_tokenRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CashbackSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"CollectedTokensWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"EmergencyPoolWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"merchant","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MerchantSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"newMinimum","type":"uint256"}],"name":"MinimumPoolBalanceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"paymentId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"merchant","type":"address"},{"indexed":true,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalPaidUSD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"productPriceUSD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeUSD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"excessUSD","type":"uint256"},{"indexed":false,"internalType":"bool","name":"settleInIDR","type":"bool"},{"indexed":false,"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cashbackAmount","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"PaymentExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SettlementPoolFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"idrx","type":"address"},{"indexed":true,"internalType":"address","name":"usdt","type":"address"}],"name":"SettlementTokensUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"FEE_BASIS_POINTS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IDRX_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_CASHBACK_USD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NATIVE_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDT_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"calculateTotalValue","outputs":[{"internalType":"uint256","name":"totalUSD","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateUSDValue","outputs":[{"internalType":"uint256","name":"usdValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collectedBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyWithdrawPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fundSettlementPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getCollectedBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"paymentId","type":"bytes32"}],"name":"getPayment","outputs":[{"components":[{"internalType":"address","name":"merchant","type":"address"},{"internalType":"address","name":"payer","type":"address"},{"internalType":"uint256","name":"totalPaidUSD","type":"uint256"},{"internalType":"uint256","name":"productPriceUSD","type":"uint256"},{"internalType":"uint256","name":"feeUSD","type":"uint256"},{"internalType":"uint256","name":"excessUSD","type":"uint256"},{"internalType":"bool","name":"settleInIDR","type":"bool"},{"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"internalType":"uint256","name":"cashbackAmount","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct IPaymentRouter.Payment","name":"payment","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getSettlementPoolBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minimumPoolBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"merchantAddress","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"productPriceUSD","type":"uint256"},{"internalType":"bool","name":"settleInIDR","type":"bool"}],"name":"pay","outputs":[{"internalType":"bytes32","name":"paymentId","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"minimum","type":"uint256"}],"name":"setMinimumPoolBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_idrx","type":"address"},{"internalType":"address","name":"_usdt","type":"address"}],"name":"setSettlementTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"settlementPools","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenRegistry","outputs":[{"internalType":"contract ITokenRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"expectedUSD","type":"uint256"}],"name":"validatePayment","outputs":[{"internalType":"bool","name":"valid","type":"bool"},{"internalType":"uint256","name":"actualUSD","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawCollectedTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]'),yr=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessControlBadConfirmation",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bytes32",name:"neededRole",type:"bytes32"}],name:"AccessControlUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"previousAdminRole",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"newAdminRole",type:"bytes32"}],name:"RoleAdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleGranted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleRevoked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"token",type:"address"},{indexed:!1,internalType:"bool",name:"enabled",type:"bool"}],name:"TokenEnabled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"token",type:"address"},{indexed:!0,internalType:"address",name:"priceFeed",type:"address"}],name:"TokenRegistered",type:"event"},{inputs:[],name:"ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"DEFAULT_ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"MAX_PRICE_STALENESS",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"NATIVE_TOKEN",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRegisteredTokenCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRegisteredTokens",outputs:[{internalType:"address[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"}],name:"getTokenConfig",outputs:[{components:[{internalType:"bool",name:"enabled",type:"bool"},{internalType:"address",name:"priceFeed",type:"address"},{internalType:"uint8",name:"decimals",type:"uint8"},{internalType:"uint256",name:"minPaymentAmount",type:"uint256"}],internalType:"struct ITokenRegistry.TokenConfig",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"}],name:"getTokenPriceUSD",outputs:[{internalType:"uint256",name:"price",type:"uint256"},{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"grantRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"hasRole",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"}],name:"isTokenEnabled",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"priceFeed",type:"address"},{internalType:"uint8",name:"decimals",type:"uint8"},{internalType:"uint256",name:"minPaymentAmount",type:"uint256"}],name:"registerToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"callerConfirmation",type:"address"}],name:"renounceRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"revokeRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"bool",name:"enabled",type:"bool"}],name:"setTokenEnabled",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"priceFeed",type:"address"}],name:"updatePriceFeed",outputs:[],stateMutability:"nonpayable",type:"function"}],br=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"faucet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],Ne=pr,V=yr,Y=br;function Oe(){const{writeContract:e,data:t,isPending:n,error:r}=A.useWriteContract(),{isLoading:s,isSuccess:i}=A.useWaitForTransactionReceipt({hash:t});return{registerToken:(p,x,P,U)=>{e({address:I.TOKEN_REGISTRY,abi:V,functionName:"registerToken",args:[p,x,P,U]})},setTokenEnabled:(p,x)=>{e({address:I.TOKEN_REGISTRY,abi:V,functionName:"setTokenEnabled",args:[p,x]})},updatePriceFeed:(p,x)=>{e({address:I.TOKEN_REGISTRY,abi:V,functionName:"updatePriceFeed",args:[p,x]})},setMinPaymentAmount:(p,x)=>{e({address:I.TOKEN_REGISTRY,abi:V,functionName:"setMinPaymentAmount",args:[p,x]})},grantRole:(p,x)=>{e({address:I.TOKEN_REGISTRY,abi:V,functionName:"grantRole",args:[p,x]})},revokeRole:(p,x)=>{e({address:I.TOKEN_REGISTRY,abi:V,functionName:"revokeRole",args:[p,x]})},useGetTokenConfig:p=>A.useReadContract({address:I.TOKEN_REGISTRY,abi:V,functionName:"getTokenConfig",args:[p]}),useGetTokenPrice:p=>A.useReadContract({address:I.TOKEN_REGISTRY,abi:V,functionName:"getTokenPriceUSD",args:[p]}),useGetRegisteredTokens:()=>A.useReadContract({address:I.TOKEN_REGISTRY,abi:V,functionName:"getRegisteredTokens"}),useGetRegisteredTokenCount:()=>A.useReadContract({address:I.TOKEN_REGISTRY,abi:V,functionName:"getRegisteredTokenCount"}),useIsTokenEnabled:p=>A.useReadContract({address:I.TOKEN_REGISTRY,abi:V,functionName:"isTokenEnabled",args:[p]}),useHasRole:(p,x)=>A.useReadContract({address:I.TOKEN_REGISTRY,abi:V,functionName:"hasRole",args:[p,x]}),hash:t,isPending:n,isConfirming:s,isConfirmed:i,error:r}}function mr({isOpen:e,onClose:t,totalAmount:n,currency:r="USDT",items:s,tokens:i,onPaymentSubmit:a,fee:o=.3,transactionHash:u,isProcessing:d,isSuccess:l}){const[y,b]=j.useState([]),[m,h]=j.useState(""),[v,w]=j.useState(!0),[T,p]=j.useState("form"),[x,P]=j.useState(0),[U,K]=j.useState(""),[ee,_]=j.useState("Preparing payment..."),[$,G]=j.useState([]),N=Oe(),{data:te}=N.useGetTokenPrice(S.NATIVE),{data:X}=N.useGetTokenPrice(S.USDC),{data:k}=N.useGetTokenPrice(S.USDT),{data:D}=N.useGetTokenPrice(S.DAI),{data:F}=N.useGetTokenPrice(S.WBTC),me=1e8,L=j.useMemo(()=>JSON.stringify(i.map(g=>({id:g.id,amount:g.amount,priceUSD:g.priceUSD}))),[i]),z=g=>{if(!g)return 0;if(Array.isArray(g)&&g.length>=1){const E=g[0];if(typeof E=="bigint")return Number(E)/me}return 0};j.useEffect(()=>{if(e&&i.length>0){const g=i.map(E=>{let R=E.priceUSD;return E.address===S.NATIVE&&te?R=z(te):E.address===S.USDC&&X?R=z(X):E.address===S.USDT&&k?R=z(k):E.address===S.DAI&&D?R=z(D):E.address===S.WBTC&&F&&(R=z(F)),{...E,priceUSD:R}});if(v){const E=g.filter(R=>R.amount>0&&R.priceUSD>0);if(E.length>0){const R=Math.floor(100/E.length),Q=100-R*E.length;g.forEach((le,Ge)=>{le.percentage=le.amount>0&&le.priceUSD>0?R+(Ge===0?Q:0):0})}}b(g)}},[e,L,te,X,k,D,F]),j.useEffect(()=>{e||(p("form"),P(0),K(""))},[e]),j.useEffect(()=>{l&&u?(P(100),K(u),p("success"),_("Payment completed!")):d&&(P(80),_("Confirming transaction..."))},[l,d,u]);const J=y.reduce((g,E)=>g+E.percentage,0),je=s.reduce((g,E)=>g+E.price,0)+o,H=y.some(g=>g.percentage===0?!1:!g.priceUSD||g.priceUSD<=0),_e=y.some(g=>{if(g.percentage===0)return!1;const E=n*g.percentage/100;return(g.priceUSD>0?E/g.priceUSD:0)>g.amount}),tr=(g,E)=>{b(R=>R.map(Q=>Q.id===g?{...Q,percentage:E}:Q))},nr=()=>{if(!v){const g=y.filter(Q=>Q.amount>0&&Q.priceUSD>0),E=Math.floor(100/g.length),R=100-E*g.length;b(Q=>Q.map((le,Ge)=>({...le,percentage:le.amount>0&&le.priceUSD>0?E+(Ge===0?R:0):0})))}w(!v)},rr=y.filter(g=>g.name.toLowerCase().includes(m.toLowerCase())||g.symbol.toLowerCase().includes(m.toLowerCase())||g.chain.toLowerCase().includes(m.toLowerCase())),sr=async()=>{p("processing"),P(10),_("Checking token approvals...");const g=y.filter(E=>E.percentage>0&&E.address!==S.NATIVE);g.length>0&&(_(`Requesting approval for ${g.length} token(s)...`),G(g.map(E=>E.symbol))),P(30),_("Processing payment..."),a(y),P(60)},ir=()=>{t()},ar=()=>new Date().toLocaleDateString("en-US",{day:"numeric",month:"long",year:"numeric"});return e?c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:T==="form"?t:void 0}),T==="processing"&&c.jsxs("div",{className:"relative bg-dark-2 border border-border rounded-xl p-4 flex flex-col gap-5 items-center justify-center w-[400px] min-h-[280px] mx-4 animate-slide-in-right",children:[c.jsx(dr,{size:134}),c.jsxs("div",{className:"flex flex-col gap-3 items-center w-[300px]",children:[c.jsxs("div",{className:"relative w-[234px] h-1.5",children:[c.jsx("div",{className:"absolute inset-0 bg-dark-4 rounded-full"}),c.jsx("div",{className:"absolute left-0 top-0 h-full bg-secondary rounded-full transition-all duration-300",style:{width:`${Math.min(x,100)}%`}})]}),c.jsx("p",{className:"text-sm text-white text-center",children:ee}),$.length>0&&c.jsxs("div",{className:"text-xs text-white/60 text-center",children:["Approving: ",$.join(", ")]})]})]}),T==="success"&&c.jsxs("div",{className:"relative bg-dark-2 border border-border rounded-xl p-4 flex flex-col gap-8 items-start w-[380px] mx-4 animate-slide-in-right",children:[c.jsxs("div",{className:"flex flex-col gap-6 items-center w-full",children:[c.jsx(lr,{size:95}),c.jsx("div",{className:"flex flex-col items-center justify-center w-full",children:c.jsxs("div",{className:"flex flex-col gap-1 items-center text-white",children:[c.jsx("p",{className:"text-lg font-semibold",children:"Payment Success"}),c.jsx("p",{className:"text-sm",children:"Your payment has been successfully done."})]})}),c.jsx("div",{className:"bg-dark-4 border border-white/10 rounded-lg py-3 px-0 w-[348px] flex flex-col items-center",children:c.jsxs("div",{className:"flex flex-col gap-2 w-[318px]",children:[c.jsx("p",{className:"text-xs text-white",children:"Order Details:"}),c.jsxs("div",{className:"flex items-center gap-8 text-sm text-white w-full",children:[c.jsx("span",{className:"w-[85px]",children:"Item"}),c.jsx("span",{className:"flex-1 text-right",children:s[0]?.name||"Item"})]}),c.jsxs("div",{className:"flex items-center gap-8 text-white w-full",children:[c.jsx("span",{className:"text-sm w-[106px]",children:"Total Payment"}),c.jsxs("span",{className:"flex-1 text-base font-semibold text-right",children:["$",je.toFixed(2)]})]})]})})]}),c.jsx("div",{className:"h-px w-[320px] bg-white/20"}),c.jsxs("div",{className:"flex flex-col gap-2 items-center justify-center w-full text-xs text-white px-5",children:[c.jsx("p",{children:ar()}),U&&c.jsx("a",{href:`https://sepolia-blockscout.lisk.com/tx/${U}`,target:"_blank",rel:"noopener noreferrer",className:"text-cyan hover:underline",children:"View Transaction"})]}),c.jsx("button",{onClick:ir,className:"w-full h-[42px] bg-secondary hover:bg-secondary/90 rounded-lg flex items-center justify-center text-sm font-semibold text-white transition-all",children:"Back to Home"})]}),T==="form"&&c.jsxs("div",{className:"relative bg-dark-2 border border-border rounded-xl p-4 flex flex-col gap-5 max-w-[1000px] w-full mx-4 max-h-[90vh] overflow-y-auto animate-slide-in-right",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsxs("div",{className:"flex-1 flex flex-col gap-1",children:[c.jsx("h2",{className:"text-xl text-white font-normal",children:"Complete Payment"}),c.jsx("p",{className:"text-base text-white/70",children:"Choose how you want to pay (supports multi-token for wallets)"})]}),c.jsx("button",{onClick:t,className:"text-white/60 hover:text-white transition-colors",children:c.jsx(or,{size:26})})]}),c.jsxs("div",{className:"flex gap-5 flex-col lg:flex-row",children:[c.jsxs("div",{className:"flex-1 flex flex-col gap-5",children:[c.jsxs("div",{className:"bg-dark-4 rounded-md p-4 flex items-center gap-5",children:[c.jsx("span",{className:"text-base text-white/60 w-[340px]",children:"Total Required"}),c.jsxs("span",{className:"text-xl font-bold text-white text-right flex-1",children:[n," ",r]})]}),c.jsxs("div",{className:"flex items-center gap-5",children:[c.jsx("span",{className:"text-base text-white flex-1",children:"Use your tokens"}),c.jsxs("div",{className:"bg-dark-4 rounded-md px-3 py-2 flex items-center gap-2",children:[c.jsx(cr,{size:16,className:"text-white/60"}),c.jsx("input",{type:"text",placeholder:"Search token or chain..",value:m,onChange:g=>h(g.target.value),className:"bg-transparent border-none outline-none text-base text-white/60 placeholder:text-white/60"})]})]}),c.jsxs("div",{className:"bg-dark-3 rounded-md p-3 flex flex-col gap-4",children:[c.jsxs("div",{className:"flex items-center gap-6",children:[c.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[c.jsx(ur,{size:16,className:"text-white/60"}),c.jsx("span",{className:"text-sm italic text-white",children:"Set the coins amount until 100%"}),c.jsxs("span",{className:`bg-dark-4 rounded-full px-2 py-1 text-xs font-semibold ${J===100?"text-cyan":"text-warning"}`,children:[J,"/100%"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-white",children:"Auto Optimize"}),c.jsx("button",{onClick:nr,className:`w-7 h-4 rounded-full relative transition-colors ${v?"bg-cyan":"bg-white/40"}`,children:c.jsx("div",{className:`absolute top-0.5 size-3 rounded-full bg-white transition-transform ${v?"translate-x-3.5":"translate-x-0.5"}`})})]})]}),rr.map(g=>c.jsx(fr,{token:g,totalAmount:n,onChange:E=>tr(g.id,E)},g.id))]})]}),c.jsx("div",{className:"w-full lg:w-[320px]",children:c.jsx(Gt,{items:s,fee:o})})]}),c.jsx("button",{onClick:sr,disabled:J!==100||_e||H,className:`w-full lg:w-[620px] h-[42px] rounded-lg flex items-center justify-center text-sm font-semibold text-white transition-all ${J===100&&!_e&&!H?"bg-secondary hover:bg-secondary/90":"bg-secondary/50 cursor-not-allowed"}`,children:H?"Price data unavailable - Please wait":_e?"Insufficient Balance":J!==100?`Complete to 100% (${J}%)`:"Pay with MultiCoyn"})]})]}):null}function hr(){const[e,t]=j.useState(!1),[n,r]=j.useState("form");return{isOpen:e,view:n,open:()=>{t(!0),r("form")},close:()=>{t(!1),setTimeout(()=>r("form"),300)},showProcessing:()=>r("processing"),showSuccess:()=>r("success"),showForm:()=>r("form")}}const Pt=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"}],gr=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}];function pe(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new Ir(e.type);return`${e.name}(${ft(e.inputs,{includeName:t})})`}function ft(e,{includeName:t=!1}={}){return e?e.map(n=>xr(n,{includeName:t})).join(t?", ":","):""}function xr(e,{includeName:t}){return e.type.startsWith("tuple")?`(${ft(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function xe(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function O(e){return xe(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Ht="2.43.5";let He={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${Ht}`},f=class Je extends Error{constructor(t,n={}){const r=n.cause instanceof Je?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Je&&n.cause.docsPath||n.docsPath,i=He.getDocsUrl?.({...n,docsPath:s}),a=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...He.version?[`Version: ${He.version}`]:[]].join(`
|
|
2
|
+
`);super(a,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=Ht}walk(t){return Vt(this,t)}};function Vt(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Vt(e.cause,t):t?null:e}class wr extends f{constructor({docsPath:t}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(`
|
|
3
|
+
`),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class At extends f{constructor({docsPath:t}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(`
|
|
4
|
+
`),{docsPath:t,name:"AbiConstructorParamsNotFoundError"})}}class Tr extends f{constructor({data:t,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(`
|
|
5
|
+
`),{metaMessages:[`Params: (${ft(n,{includeName:!0})})`,`Data: ${t} (${r} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t,this.params=n,this.size=r}}class pt extends f{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class vr extends f{constructor({expectedLength:t,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${t}`,`Given length: ${n}`].join(`
|
|
6
|
+
`),{name:"AbiEncodingArrayLengthMismatchError"})}}class Er extends f{constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${O(n)}) does not match expected size (bytes${t}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class Pr extends f{constructor({expectedLength:t,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${t}`,`Given length (values): ${n}`].join(`
|
|
7
|
+
`),{name:"AbiEncodingLengthMismatchError"})}}class Ar extends f{constructor(t,{docsPath:n}){super([`Arguments (\`args\`) were provided to "${t}", but "${t}" on the ABI does not contain any parameters (\`inputs\`).`,"Cannot encode error result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the inputs exist on it."].join(`
|
|
8
|
+
`),{docsPath:n,name:"AbiErrorInputsNotFoundError"})}}class Sr extends f{constructor(t,{docsPath:n}={}){super([`Error ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join(`
|
|
9
|
+
`),{docsPath:n,name:"AbiErrorNotFoundError"})}}class Wt extends f{constructor(t,{docsPath:n}){super([`Encoded error signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${t}.`].join(`
|
|
10
|
+
`),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=t}}class Ae extends f{constructor(t,{docsPath:n}={}){super([`Function ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(`
|
|
11
|
+
`),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class Kt extends f{constructor(t,{docsPath:n}){super([`Function "${t}" does not contain any \`outputs\` on ABI.`,"Cannot decode function result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the function exists on it."].join(`
|
|
12
|
+
`),{docsPath:n,name:"AbiFunctionOutputsNotFoundError"})}}class $r extends f{constructor(t,{docsPath:n}){super([`Encoded function signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${t}.`].join(`
|
|
13
|
+
`),{docsPath:n,name:"AbiFunctionSignatureNotFoundError"})}}class Cr extends f{constructor(t,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${t.type}\` in \`${pe(t.abiItem)}\`, and`,`\`${n.type}\` in \`${pe(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class jr extends f{constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
|
|
14
|
+
`),{docsPath:n,name:"InvalidAbiEncodingType"})}}class Nr extends f{constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(`
|
|
15
|
+
`),{docsPath:n,name:"InvalidAbiDecodingType"})}}class Yt extends f{constructor(t){super([`Value "${t}" is not a valid array.`].join(`
|
|
16
|
+
`),{name:"InvalidArrayError"})}}class Ir extends f{constructor(t){super([`"${t}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(`
|
|
17
|
+
`),{name:"InvalidDefinitionTypeError"})}}class Se extends f{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Zt extends f{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}let Xt=class extends f{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}};class St extends f{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${t} ${r} long.`,{name:"InvalidBytesLengthError"})}}function we(e,{dir:t,size:n=32}={}){return typeof e=="string"?ue(e,{dir:t,size:n}):kr(e,{dir:t,size:n})}function ue(e,{dir:t,size:n=32}={}){if(n===null)return e;const r=e.replace("0x","");if(r.length>n*2)throw new Xt({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function kr(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new Xt({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=t==="right";r[i?s:n-s-1]=e[i?s:e.length-s-1]}return r}let Jt=class extends f{constructor({max:t,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}};class Rr extends f{constructor(t){super(`Bytes value "${t}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class Mr extends f{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function yt(e,{dir:t="left"}={}){let n=typeof e=="string"?e.replace("0x",""):e,r=0;for(let s=0;s<n.length-1&&n[t==="left"?s:n.length-s-1].toString()==="0";s++)r++;return n=t==="left"?n.slice(r):n.slice(0,n.length-r),typeof e=="string"?(n.length===1&&t==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function q(e,{size:t}){if(O(e)>t)throw new Mr({givenSize:O(e),maxSize:t})}function Qt(e,t={}){const{signed:n}=t;t.size&&q(e,{size:t.size});const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<BigInt(s)*8n-1n)-1n;return r<=i?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function Or(e,t={}){return Number(Qt(e,t))}const Dr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Br(e,t={}){return typeof e=="number"||typeof e=="bigint"?C(e,t):typeof e=="string"?en(e,t):typeof e=="boolean"?qt(e,t):ae(e,t)}function qt(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(q(n,{size:t.size}),we(n,{size:t.size})):n}function ae(e,t={}){let n="";for(let s=0;s<e.length;s++)n+=Dr[e[s]];const r=`0x${n}`;return typeof t.size=="number"?(q(r,{size:t.size}),we(r,{dir:"right",size:t.size})):r}function C(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<a){const u=typeof e=="bigint"?"n":"";throw new Jt({max:i?`${i}${u}`:void 0,min:`${a}${u}`,signed:n,size:r,value:`${e}${u}`})}const o=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?we(o,{size:r}):o}const Ur=new TextEncoder;function en(e,t={}){const n=Ur.encode(e);return ae(n,t)}const Fr=new TextEncoder;function tn(e,t={}){return typeof e=="number"||typeof e=="bigint"?zr(e,t):typeof e=="boolean"?Lr(e,t):xe(e)?bt(e,t):nn(e,t)}function Lr(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(q(n,{size:t.size}),we(n,{size:t.size})):n}const ne={zero:48,nine:57,A:65,F:70,a:97,f:102};function $t(e){if(e>=ne.zero&&e<=ne.nine)return e-ne.zero;if(e>=ne.A&&e<=ne.F)return e-(ne.A-10);if(e>=ne.a&&e<=ne.f)return e-(ne.a-10)}function bt(e,t={}){let n=e;t.size&&(q(n,{size:t.size}),n=we(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let a=0,o=0;a<s;a++){const u=$t(r.charCodeAt(o++)),d=$t(r.charCodeAt(o++));if(u===void 0||d===void 0)throw new f(`Invalid byte sequence ("${r[o-2]}${r[o-1]}" in "${r}").`);i[a]=u*16+d}return i}function zr(e,t){const n=C(e,t);return bt(n)}function nn(e,t={}){const n=Fr.encode(e);return typeof t.size=="number"?(q(n,{size:t.size}),we(n,{dir:"right",size:t.size})):n}const Ie=BigInt(2**32-1),Ct=BigInt(32);function _r(e,t=!1){return t?{h:Number(e&Ie),l:Number(e>>Ct&Ie)}:{h:Number(e>>Ct&Ie)|0,l:Number(e&Ie)|0}}function Gr(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:a,l:o}=_r(e[i],t);[r[i],s[i]]=[a,o]}return[r,s]}const Hr=(e,t,n)=>e<<n|t>>>32-n,Vr=(e,t,n)=>t<<n|e>>>32-n,Wr=(e,t,n)=>t<<n-32|e>>>64-n,Kr=(e,t,n)=>e<<n-32|t>>>64-n;function Yr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function jt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ke(e,...t){if(!Yr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Nt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Zr(e,t){ke(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Xr(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function rn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Jr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Qr(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function qr(e){for(let t=0;t<e.length;t++)e[t]=Qr(e[t]);return e}const It=Jr?e=>e:qr;function es(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function sn(e){return typeof e=="string"&&(e=es(e)),ke(e),e}class ts{}function ns(e){const t=r=>e().update(sn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const rs=BigInt(0),ve=BigInt(1),ss=BigInt(2),is=BigInt(7),as=BigInt(256),os=BigInt(113),an=[],on=[],cn=[];for(let e=0,t=ve,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],an.push(2*(5*r+n)),on.push((e+1)*(e+2)/2%64);let s=rs;for(let i=0;i<7;i++)t=(t<<ve^(t>>is)*os)%as,t&ss&&(s^=ve<<(ve<<BigInt(i))-ve);cn.push(s)}const un=Gr(cn,!0),cs=un[0],us=un[1],kt=(e,t,n)=>n>32?Wr(e,t,n):Hr(e,t,n),Rt=(e,t,n)=>n>32?Kr(e,t,n):Vr(e,t,n);function ds(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){const o=(a+8)%10,u=(a+2)%10,d=n[u],l=n[u+1],y=kt(d,l,1)^n[o],b=Rt(d,l,1)^n[o+1];for(let m=0;m<50;m+=10)e[a+m]^=y,e[a+m+1]^=b}let s=e[2],i=e[3];for(let a=0;a<24;a++){const o=on[a],u=kt(s,i,o),d=Rt(s,i,o),l=an[a];s=e[l],i=e[l+1],e[l]=u,e[l+1]=d}for(let a=0;a<50;a+=10){for(let o=0;o<10;o++)n[o]=e[a+o];for(let o=0;o<10;o++)e[a+o]^=~n[(o+2)%10]&n[(o+4)%10]}e[0]^=cs[r],e[1]^=us[r]}rn(n)}class mt extends ts{constructor(t,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,jt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Xr(this.state)}clone(){return this._cloneInto()}keccak(){It(this.state32),ds(this.state32,this.rounds),It(this.state32),this.posOut=0,this.pos=0}update(t){Nt(this),t=sn(t),ke(t);const{blockLen:n,state:r}=this,s=t.length;for(let i=0;i<s;){const a=Math.min(n-this.pos,s-i);for(let o=0;o<a;o++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Nt(this,!1),ke(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=t.length;s<i;){this.posOut>=r&&this.keccak();const a=Math.min(r-this.posOut,i-s);t.set(n.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return jt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Zr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,rn(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:a}=this;return t||(t=new mt(n,r,s,a,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=s,t.enableXOF=a,t.destroyed=this.destroyed,t}}const ls=(e,t,n)=>ns(()=>new mt(t,e,n)),fs=ls(1,136,256/8);function dn(e,t){const n=t||"hex",r=fs(xe(e,{strict:!1})?tn(e):e);return n==="bytes"?r:Br(r)}class ln extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const ps=/^0x[a-fA-F0-9]{40}$/,Ve=new ln(8192);function de(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Ve.has(r))return Ve.get(r);const s=ps.test(e)?e.toLowerCase()===e?!0:n?fn(e)===e:!0:!1;return Ve.set(r,s),s}const We=new ln(8192);function fn(e,t){if(We.has(`${e}.${t}`))return We.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=dn(nn(n),"bytes"),s=n.split("");for(let a=0;a<40;a+=2)r[a>>1]>>4>=8&&s[a]&&(s[a]=s[a].toUpperCase()),(r[a>>1]&15)>=8&&s[a+1]&&(s[a+1]=s[a+1].toUpperCase());const i=`0x${s.join("")}`;return We.set(`${e}.${t}`,i),i}class Mt extends f{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class ys extends f{constructor({length:t,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}}class bs extends f{constructor({count:t,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}const ms={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new bs({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new ys({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Mt({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new Mt({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function hs(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(ms);return n.bytes=e,n.dataView=new DataView(e.buffer??e,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function $e(e,t,n,{strict:r}={}){return xe(e,{strict:!1})?gs(e,t,n,{strict:r}):bn(e,t,n,{strict:r})}function pn(e,t){if(typeof t=="number"&&t>0&&t>O(e)-1)throw new Zt({offset:t,position:"start",size:O(e)})}function yn(e,t,n){if(typeof t=="number"&&typeof n=="number"&&O(e)!==n-t)throw new Zt({offset:n,position:"end",size:O(e)})}function bn(e,t,n,{strict:r}={}){pn(e,t);const s=e.slice(t,n);return r&&yn(s,t,n),s}function gs(e,t,n,{strict:r}={}){pn(e,t);const s=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return r&&yn(s,t,n),s}function xs(e,t={}){typeof t.size<"u"&&q(e,{size:t.size});const n=ae(e,t);return Qt(n,t)}function ws(e,t={}){let n=e;if(typeof t.size<"u"&&(q(n,{size:t.size}),n=yt(n)),n.length>1||n[0]>1)throw new Rr(n);return!!n[0]}function ie(e,t={}){typeof t.size<"u"&&q(e,{size:t.size});const n=ae(e,t);return Or(n,t)}function Ts(e,t={}){let n=e;return typeof t.size<"u"&&(q(n,{size:t.size}),n=yt(n,{dir:"right"})),new TextDecoder().decode(n)}function ye(e){return typeof e[0]=="string"?De(e):vs(e)}function vs(e){let t=0;for(const s of e)t+=s.length;const n=new Uint8Array(t);let r=0;for(const s of e)n.set(s,r),r+=s.length;return n}function De(e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}const Es=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function ht(e,t){if(e.length!==t.length)throw new Pr({expectedLength:e.length,givenLength:t.length});const n=Ps({params:e,values:t}),r=xt(n);return r.length===0?"0x":r}function Ps({params:e,values:t}){const n=[];for(let r=0;r<e.length;r++)n.push(gt({param:e[r],value:t[r]}));return n}function gt({param:e,value:t}){const n=wt(e.type);if(n){const[r,s]=n;return Ss(t,{length:r,param:{...e,type:s}})}if(e.type==="tuple")return Is(t,{param:e});if(e.type==="address")return As(t);if(e.type==="bool")return Cs(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const r=e.type.startsWith("int"),[,,s="256"]=Es.exec(e.type)??[];return js(t,{signed:r,size:Number(s)})}if(e.type.startsWith("bytes"))return $s(t,{param:e});if(e.type==="string")return Ns(t);throw new jr(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function xt(e){let t=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?t+=32:t+=O(o)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(C(t+s,{size:32})),r.push(o),s+=O(o)):n.push(o)}return ye([...n,...r])}function As(e){if(!de(e))throw new Se({address:e});return{dynamic:!1,encoded:ue(e.toLowerCase())}}function Ss(e,{length:t,param:n}){const r=t===null;if(!Array.isArray(e))throw new Yt(e);if(!r&&e.length!==t)throw new vr({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let s=!1;const i=[];for(let a=0;a<e.length;a++){const o=gt({param:n,value:e[a]});o.dynamic&&(s=!0),i.push(o)}if(r||s){const a=xt(i);if(r){const o=C(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?ye([o,a]):o}}if(s)return{dynamic:!0,encoded:a}}return{dynamic:!1,encoded:ye(i.map(({encoded:a})=>a))}}function $s(e,{param:t}){const[,n]=t.type.split("bytes"),r=O(e);if(!n){let s=e;return r%32!==0&&(s=ue(s,{dir:"right",size:Math.ceil((e.length-2)/2/32)*32})),{dynamic:!0,encoded:ye([ue(C(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new Er({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:ue(e,{dir:"right"})}}function Cs(e){if(typeof e!="boolean")throw new f(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:ue(qt(e))}}function js(e,{signed:t,size:n=256}){if(typeof n=="number"){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new Jt({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:C(e,{size:32,signed:t})}}function Ns(e){const t=en(e),n=Math.ceil(O(t)/32),r=[];for(let s=0;s<n;s++)r.push(ue($e(t,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:ye([ue(C(O(t),{size:32})),...r])}}function Is(e,{param:t}){let n=!1;const r=[];for(let s=0;s<t.components.length;s++){const i=t.components[s],a=Array.isArray(e)?s:i.name,o=gt({param:i,value:e[a]});r.push(o),o.dynamic&&(n=!0)}return{dynamic:n,encoded:n?xt(r):ye(r.map(({encoded:s})=>s))}}function wt(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Tt(e,t){const n=typeof t=="string"?bt(t):t,r=hs(n);if(O(n)===0&&e.length>0)throw new pt;if(O(t)&&O(t)<32)throw new Tr({data:typeof t=="string"?t:ae(t),params:e,size:O(t)});let s=0;const i=[];for(let a=0;a<e.length;++a){const o=e[a];r.setPosition(s);const[u,d]=ge(r,o,{staticPosition:0});s+=d,i.push(u)}return i}function ge(e,t,{staticPosition:n}){const r=wt(t.type);if(r){const[s,i]=r;return Rs(e,{...t,type:i},{length:s,staticPosition:n})}if(t.type==="tuple")return Bs(e,t,{staticPosition:n});if(t.type==="address")return ks(e);if(t.type==="bool")return Ms(e);if(t.type.startsWith("bytes"))return Os(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return Ds(e,t);if(t.type==="string")return Us(e,{staticPosition:n});throw new Nr(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Ot=32,Qe=32;function ks(e){const t=e.readBytes(32);return[fn(ae(bn(t,-20))),32]}function Rs(e,t,{length:n,staticPosition:r}){if(!n){const a=ie(e.readBytes(Qe)),o=r+a,u=o+Ot;e.setPosition(o);const d=ie(e.readBytes(Ot)),l=Ce(t);let y=0;const b=[];for(let m=0;m<d;++m){e.setPosition(u+(l?m*32:y));const[h,v]=ge(e,t,{staticPosition:u});y+=v,b.push(h)}return e.setPosition(r+32),[b,32]}if(Ce(t)){const a=ie(e.readBytes(Qe)),o=r+a,u=[];for(let d=0;d<n;++d){e.setPosition(o+d*32);const[l]=ge(e,t,{staticPosition:o});u.push(l)}return e.setPosition(r+32),[u,32]}let s=0;const i=[];for(let a=0;a<n;++a){const[o,u]=ge(e,t,{staticPosition:r+s});s+=u,i.push(o)}return[i,s]}function Ms(e){return[ws(e.readBytes(32),{size:32}),32]}function Os(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const a=ie(e.readBytes(32));e.setPosition(n+a);const o=ie(e.readBytes(32));if(o===0)return e.setPosition(n+32),["0x",32];const u=e.readBytes(o);return e.setPosition(n+32),[ae(u),32]}return[ae(e.readBytes(Number.parseInt(s,10),32)),32]}function Ds(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),s=e.readBytes(32);return[r>48?xs(s,{signed:n}):ie(s,{signed:n}),32]}function Bs(e,t,{staticPosition:n}){const r=t.components.length===0||t.components.some(({name:a})=>!a),s=r?[]:{};let i=0;if(Ce(t)){const a=ie(e.readBytes(Qe)),o=n+a;for(let u=0;u<t.components.length;++u){const d=t.components[u];e.setPosition(o+i);const[l,y]=ge(e,d,{staticPosition:o});i+=y,s[r?u:d?.name]=l}return e.setPosition(n+32),[s,32]}for(let a=0;a<t.components.length;++a){const o=t.components[a],[u,d]=ge(e,o,{staticPosition:n});s[r?a:o?.name]=u,i+=d}return[s,i]}function Us(e,{staticPosition:t}){const n=ie(e.readBytes(32)),r=t+n;e.setPosition(r);const s=ie(e.readBytes(32));if(s===0)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=Ts(yt(i));return e.setPosition(t+32),[a,32]}function Ce(e){const{type:t}=e;if(t==="string"||t==="bytes"||t.endsWith("[]"))return!0;if(t==="tuple")return e.components?.some(Ce);const n=wt(e.type);return!!(n&&Ce({...e,type:n[1]}))}const Fs=e=>dn(tn(e));function Ls(e){return Fs(e)}const zs="1.2.3";let W=class qe extends Error{constructor(t,n={}){const r=n.cause instanceof qe?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof qe&&n.cause.docsPath||n.docsPath,i=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...r?[`Details: ${r}`]:[],`Version: abitype@${zs}`].join(`
|
|
18
|
+
`);super(i),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=t}};function oe(e,t){return e.exec(t)?.groups}const mn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,hn=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,gn=/^\(.+?\).*?$/,Dt=/^tuple(?<array>(\[(\d*)\])*)$/;function et(e){let t=e.type;if(Dt.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let s=0;s<n;s++){const i=e.components[s];t+=et(i),s<n-1&&(t+=", ")}const r=oe(Dt,e.type);return t+=`)${r?.array||""}`,et({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Ee(e){let t="";const n=e.length;for(let r=0;r<n;r++){const s=e[r];t+=et(s),r!==n-1&&(t+=", ")}return t}function _s(e){return e.type==="function"?`function ${e.name}(${Ee(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${Ee(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${Ee(e.inputs)})`:e.type==="error"?`error ${e.name}(${Ee(e.inputs)})`:e.type==="constructor"?`constructor(${Ee(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const xn=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function Gs(e){return xn.test(e)}function Hs(e){return oe(xn,e)}const wn=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function Vs(e){return wn.test(e)}function Ws(e){return oe(wn,e)}const Tn=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function Ks(e){return Tn.test(e)}function Ys(e){return oe(Tn,e)}const vn=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function En(e){return vn.test(e)}function Zs(e){return oe(vn,e)}const Pn=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function Xs(e){return Pn.test(e)}function Js(e){return oe(Pn,e)}const An=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function Qs(e){return An.test(e)}function qs(e){return oe(An,e)}const ei=/^receive\(\) external payable$/;function ti(e){return ei.test(e)}const ni=new Set(["indexed"]),tt=new Set(["calldata","memory","storage"]);class ri extends W{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class si extends W{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class ii extends W{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class ai extends W{constructor({param:t,name:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${n}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class oi extends W{constructor({param:t,type:n,modifier:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class ci extends W{constructor({param:t,type:n,modifier:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${r}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class ui extends W{constructor({abiParameter:t}){super("Invalid ABI parameter.",{details:JSON.stringify(t,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class Te extends W{constructor({signature:t,type:n}){super(`Invalid ${n} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class di extends W{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class li extends W{constructor({signature:t}){super("Invalid struct signature.",{details:t,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class fi extends W{constructor({type:t}){super("Circular reference detected.",{metaMessages:[`Struct "${t}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class pi extends W{constructor({current:t,depth:n}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${n>0?"opening":"closing"} parentheses.`],details:`Depth "${n}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function yi(e,t,n){let r="";if(n)for(const s of Object.entries(n)){if(!s)continue;let i="";for(const a of s[1])i+=`[${a.type}${a.name?`:${a.name}`:""}]`;r+=`(${s[0]}{${i}})`}return t?`${t}:${e}${r}`:`${e}${r}`}const Ke=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function bi(e,t={}){if(Ks(e))return mi(e,t);if(Vs(e))return hi(e,t);if(Gs(e))return gi(e,t);if(Xs(e))return xi(e,t);if(Qs(e))return wi(e);if(ti(e))return{type:"receive",stateMutability:"payable"};throw new di({signature:e})}function mi(e,t={}){const n=Ys(e);if(!n)throw new Te({signature:e,type:"function"});const r=Z(n.parameters),s=[],i=r.length;for(let o=0;o<i;o++)s.push(be(r[o],{modifiers:tt,structs:t,type:"function"}));const a=[];if(n.returns){const o=Z(n.returns),u=o.length;for(let d=0;d<u;d++)a.push(be(o[d],{modifiers:tt,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}function hi(e,t={}){const n=Ws(e);if(!n)throw new Te({signature:e,type:"event"});const r=Z(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(be(r[a],{modifiers:ni,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}function gi(e,t={}){const n=Hs(e);if(!n)throw new Te({signature:e,type:"error"});const r=Z(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(be(r[a],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}function xi(e,t={}){const n=Js(e);if(!n)throw new Te({signature:e,type:"constructor"});const r=Z(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(be(r[a],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}function wi(e){const t=qs(e);if(!t)throw new Te({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const Ti=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,vi=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Ei=/^u?int$/;function be(e,t){const n=yi(e,t?.type,t?.structs);if(Ke.has(n))return Ke.get(n);const r=gn.test(e),s=oe(r?vi:Ti,e);if(!s)throw new ii({param:e});if(s.name&&Ai(s.name))throw new ai({param:e,name:s.name});const i=s.name?{name:s.name}:{},a=s.modifier==="indexed"?{indexed:!0}:{},o=t?.structs??{};let u,d={};if(r){u="tuple";const y=Z(s.type),b=[],m=y.length;for(let h=0;h<m;h++)b.push(be(y[h],{structs:o}));d={components:b}}else if(s.type in o)u="tuple",d={components:o[s.type]};else if(Ei.test(s.type))u=`${s.type}256`;else if(s.type==="address payable")u="address";else if(u=s.type,t?.type!=="struct"&&!Sn(u))throw new si({type:u});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new oi({param:e,type:t?.type,modifier:s.modifier});if(tt.has(s.modifier)&&!Si(u,!!s.array))throw new ci({param:e,type:t?.type,modifier:s.modifier})}const l={type:`${u}${s.array??""}`,...i,...a,...d};return Ke.set(n,l),l}function Z(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const a=e[i],o=e.slice(i+1);switch(a){case",":return r===0?Z(o,[...t,n.trim()]):Z(o,t,`${n}${a}`,r);case"(":return Z(o,t,`${n}${a}`,r+1);case")":return Z(o,t,`${n}${a}`,r-1);default:return Z(o,t,`${n}${a}`,r)}}if(n==="")return t;if(r!==0)throw new pi({current:n,depth:r});return t.push(n.trim()),t}function Sn(e){return e==="address"||e==="bool"||e==="function"||e==="string"||mn.test(e)||hn.test(e)}const Pi=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function Ai(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||mn.test(e)||hn.test(e)||Pi.test(e)}function Si(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function $i(e){const t={},n=e.length;for(let a=0;a<n;a++){const o=e[a];if(!En(o))continue;const u=Zs(o);if(!u)throw new Te({signature:o,type:"struct"});const d=u.properties.split(";"),l=[],y=d.length;for(let b=0;b<y;b++){const h=d[b].trim();if(!h)continue;const v=be(h,{type:"struct"});l.push(v)}if(!l.length)throw new li({signature:o});t[u.name]=l}const r={},s=Object.entries(t),i=s.length;for(let a=0;a<i;a++){const[o,u]=s[a];r[o]=$n(u,t)}return r}const Ci=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function $n(e=[],t={},n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const a=e[i];if(gn.test(a.type))r.push(a);else{const u=oe(Ci,a.type);if(!u?.type)throw new ui({abiParameter:a});const{array:d,type:l}=u;if(l in t){if(n.has(l))throw new fi({type:l});r.push({...a,type:`tuple${d??""}`,components:$n(t[l],t,new Set([...n,l]))})}else if(Sn(l))r.push(a);else throw new ri({type:l})}}return r}function Cn(e){const t=$i(e),n=[],r=e.length;for(let s=0;s<r;s++){const i=e[s];En(i)||n.push(bi(i,t))}return n}function ji(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),o==="("&&r++,o===")"&&r--,!!t){if(r===0){if(o===" "&&["event","function",""].includes(s))s="";else if(s+=o,o===")"){i=!0;break}continue}if(o===" "){e[a-1]!==","&&n!==","&&n!==",("&&(n="",t=!1);continue}s+=o,n+=o}}if(!i)throw new f("Unable to normalize signature.");return s}const Ni=e=>{const t=typeof e=="string"?e:_s(e);return ji(t)};function jn(e){return Ls(Ni(e))}const Ii=jn,Be=e=>$e(jn(e),0,4);function Ue(e){const{abi:t,args:n=[],name:r}=e,s=xe(r,{strict:!1}),i=t.filter(o=>s?o.type==="function"?Be(o)===r:o.type==="event"?Ii(o)===r:!1:"name"in o&&o.name===r);if(i.length===0)return;if(i.length===1)return i[0];let a;for(const o of i){if(!("inputs"in o))continue;if(!n||n.length===0){if(!o.inputs||o.inputs.length===0)return o;continue}if(!o.inputs||o.inputs.length===0||o.inputs.length!==n.length)continue;if(n.every((d,l)=>{const y="inputs"in o&&o.inputs[l];return y?nt(d,y):!1})){if(a&&"inputs"in a&&a.inputs){const d=Nn(o.inputs,a.inputs,n);if(d)throw new Cr({abiItem:o,type:d[0]},{abiItem:a,type:d[1]})}a=o}}return a||i[0]}function nt(e,t){const n=typeof e,r=t.type;switch(r){case"address":return de(e,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in t?Object.values(t.components).every((s,i)=>n==="object"&&nt(Object.values(e)[i],s)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(e)&&e.every(s=>nt(s,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Nn(e,t,n){for(const r in e){const s=e[r],i=t[r];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return Nn(s.components,i.components,n[r]);const a=[s.type,i.type];if(a.includes("address")&&a.includes("bytes20")?!0:a.includes("address")&&a.includes("string")?de(n[r],{strict:!1}):a.includes("address")&&a.includes("bytes")?de(n[r],{strict:!1}):!1)return a}}const Ye="/docs/contract/decodeFunctionResult";function In(e){const{abi:t,args:n,functionName:r,data:s}=e;let i=t[0];if(r){const o=Ue({abi:t,args:n,name:r});if(!o)throw new Ae(r,{docsPath:Ye});i=o}if(i.type!=="function")throw new Ae(void 0,{docsPath:Ye});if(!i.outputs)throw new Kt(i.name,{docsPath:Ye});const a=Tt(i.outputs,s);if(a&&a.length>1)return a;if(a&&a.length===1)return a[0]}const Bt="/docs/contract/encodeFunctionData";function ki(e){const{abi:t,args:n,functionName:r}=e;let s=t[0];if(r){const i=Ue({abi:t,args:n,name:r});if(!i)throw new Ae(r,{docsPath:Bt});s=i}if(s.type!=="function")throw new Ae(void 0,{docsPath:Bt});return{abi:[s],functionName:Be(pe(s))}}function kn(e){const{args:t}=e,{abi:n,functionName:r}=e.abi.length===1&&e.functionName?.startsWith("0x")?e:ki(e),s=n[0],i=r,a="inputs"in s&&s.inputs?ht(s.inputs,t??[]):void 0;return De([i,a??"0x"])}class rt extends f{constructor({blockNumber:t,chain:n,contract:r}){super(`Chain "${n.name}" does not support contract "${r.name}".`,{metaMessages:["This could be due to any of the following:",...t&&r.blockCreated&&r.blockCreated>t?[`- The contract "${r.name}" was not deployed until block ${r.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${r.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class Rn extends f{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}function Ri({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new rt({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new rt({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function vt(e){return typeof e=="string"?{address:e,type:"json-rpc"}:e}const Mi={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},Mn={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},Oi={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function On(e){const{abi:t,data:n}=e,r=$e(n,0,4);if(r==="0x")throw new pt;const i=[...t||[],Mn,Oi].find(a=>a.type==="error"&&r===Be(pe(a)));if(!i)throw new Wt(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?Tt(i.inputs,$e(n,4)):void 0,errorName:i.name}}const Fe=(e,t,n)=>JSON.stringify(e,(r,s)=>typeof s=="bigint"?s.toString():s,n);function Dn({abiItem:e,args:t,includeFunctionName:n=!0,includeName:r=!1}){if("name"in e&&"inputs"in e&&e.inputs)return`${n?e.name:""}(${e.inputs.map((s,i)=>`${r&&s.name?`${s.name}: `:""}${typeof t[i]=="object"?Fe(t[i]):t[i]}`).join(", ")})`}const Di={gwei:9,wei:18},Bi={ether:-9,wei:9};function Bn(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,i]=[n.slice(0,n.length-t),n.slice(n.length-t)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function Ui(e,t="wei"){return Bn(e,Di[t])}function fe(e,t="wei"){return Bn(e,Bi[t])}class Fi extends f{constructor({address:t}){super(`State for account "${t}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Li extends f{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Ut(e){return e.reduce((t,{slot:n,value:r})=>`${t} ${n}: ${r}
|
|
19
|
+
`,"")}function zi(e){return e.reduce((t,{address:n,...r})=>{let s=`${t} ${n}:
|
|
20
|
+
`;return r.nonce&&(s+=` nonce: ${r.nonce}
|
|
21
|
+
`),r.balance&&(s+=` balance: ${r.balance}
|
|
22
|
+
`),r.code&&(s+=` code: ${r.code}
|
|
23
|
+
`),r.state&&(s+=` state:
|
|
24
|
+
`,s+=Ut(r.state)),r.stateDiff&&(s+=` stateDiff:
|
|
25
|
+
`,s+=Ut(r.stateDiff)),s},` State Override:
|
|
26
|
+
`).slice(0,-1)}function Un(e){const t=Object.entries(e).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=t.reduce((r,[s])=>Math.max(r,s.length),0);return t.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
|
|
27
|
+
`)}const _i=e=>e,Et=e=>e;class Gi extends f{constructor(t,{account:n,docsPath:r,chain:s,data:i,gas:a,gasPrice:o,maxFeePerGas:u,maxPriorityFeePerGas:d,nonce:l,to:y,value:b,stateOverride:m}){const h=n?vt(n):void 0;let v=Un({from:h?.address,to:y,value:typeof b<"u"&&`${Ui(b)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:a,gasPrice:typeof o<"u"&&`${fe(o)} gwei`,maxFeePerGas:typeof u<"u"&&`${fe(u)} gwei`,maxPriorityFeePerGas:typeof d<"u"&&`${fe(d)} gwei`,nonce:l});m&&(v+=`
|
|
28
|
+
${zi(m)}`),super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Raw Call Arguments:",v].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class Hi extends f{constructor(t,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:a,sender:o}){const u=Ue({abi:n,args:r,name:a}),d=u?Dn({abiItem:u,args:r,includeFunctionName:!1,includeName:!1}):void 0,l=u?pe(u,{includeName:!0}):void 0,y=Un({address:s&&_i(s),function:l,args:d&&d!=="()"&&`${[...Array(a?.length??0).keys()].map(()=>" ").join("")}${d}`,sender:o});super(t.shortMessage||`An unknown error occurred while executing the contract function "${a}".`,{cause:t,docsPath:i,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],y&&"Contract Call:",y].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=n,this.args=r,this.cause=t,this.contractAddress=s,this.functionName=a,this.sender=o}}class Vi extends f{constructor({abi:t,data:n,functionName:r,message:s}){let i,a,o,u;if(n&&n!=="0x")try{a=On({abi:t,data:n});const{abiItem:l,errorName:y,args:b}=a;if(y==="Error")u=b[0];else if(y==="Panic"){const[m]=b;u=Mi[m]}else{const m=l?pe(l,{includeName:!0}):void 0,h=l&&b?Dn({abiItem:l,args:b,includeFunctionName:!1,includeName:!1}):void 0;o=[m?`Error: ${m}`:"",h&&h!=="()"?` ${[...Array(y?.length??0).keys()].map(()=>" ").join("")}${h}`:""]}}catch(l){i=l}else s&&(u=s);let d;i instanceof Wt&&(d=i.signature,o=[`Unable to decode signature "${d}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${d}.`]),super(u&&u!=="execution reverted"||d?[`The contract function "${r}" reverted with the following ${d?"signature":"reason"}:`,u||d].join(`
|
|
29
|
+
`):`The contract function "${r}" reverted.`,{cause:i,metaMessages:o,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=a,this.raw=n,this.reason=u,this.signature=d}}class Wi extends f{constructor({functionName:t}){super(`The contract function "${t}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${t}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Ki extends f{constructor({factory:t}){super(`Deployment for counterfactual contract call failed${t?` for factory "${t}".`:""}`,{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class Fn extends f{constructor({data:t,message:n}){super(n||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t}}function Yi(e,t,n){const r=e[t.name];if(typeof r=="function")return r;const s=e[n];return typeof s=="function"?s:i=>t(e,i)}class Zi extends f{constructor({body:t,cause:n,details:r,headers:s,status:i,url:a}){super("HTTP request failed.",{cause:n,details:r,metaMessages:[i&&`Status: ${i}`,`URL: ${Et(a)}`,t&&`Request body: ${Fe(t)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=t,this.headers=s,this.status=i,this.url=a}}class Ln extends f{constructor({body:t,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${Et(r)}`,`Request body: ${Fe(t)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n.code,this.data=n.data,this.url=r}}const Xi=-1;class zn extends f{constructor(t,{code:n,docsPath:r,metaMessages:s,name:i,shortMessage:a}){super(a,{cause:t,docsPath:r,metaMessages:s||t?.metaMessages,name:i||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i||t.name,this.code=t instanceof Ln?t.code:n??Xi}}class Le extends zn{constructor(t){super(t,{code:Le.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(Le,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class ze extends zn{constructor(t){super(t,{code:ze.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
|
|
30
|
+
`)})}}Object.defineProperty(ze,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});const Ji=3;function Qi(e,{abi:t,address:n,args:r,docsPath:s,functionName:i,sender:a}){const o=e instanceof Fn?e:e instanceof f?e.walk(h=>"data"in h)||e.walk():{},{code:u,data:d,details:l,message:y,shortMessage:b}=o,m=e instanceof pt?new Wi({functionName:i}):[Ji,Le.code].includes(u)&&(d||l||y||b)||u===ze.code&&l==="execution reverted"&&d?new Vi({abi:t,data:typeof d=="object"?d.data:d,functionName:i,message:o instanceof Ln?l:b??y}):e;return new Hi(m,{abi:t,args:r,contractAddress:n,docsPath:s,functionName:i,sender:a})}const qi="0.1.1";function ea(){return qi}class B extends Error{static setStaticOptions(t){B.prototype.docsOrigin=t.docsOrigin,B.prototype.showVersion=t.showVersion,B.prototype.version=t.version}constructor(t,n={}){const r=(()=>{if(n.cause instanceof B){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),s=n.cause instanceof B&&n.cause.docsPath||n.docsPath,i=n.docsOrigin??B.prototype.docsOrigin,a=`${i}${s??""}`,o=!!(n.version??B.prototype.showVersion),u=n.version??B.prototype.version,d=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s||o?["",r?`Details: ${r}`:void 0,s?`See: ${a}`:void 0,o?`Version: ${u}`:void 0]:[]].filter(l=>typeof l=="string").join(`
|
|
31
|
+
`);super(d,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsOrigin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showVersion",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.cause=n.cause,this.details=r,this.docs=a,this.docsOrigin=i,this.docsPath=s,this.shortMessage=t,this.showVersion=o,this.version=u}walk(t){return _n(this,t)}}Object.defineProperty(B,"defaultStaticOptions",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:"https://oxlib.sh",showVersion:!1,version:`ox@${ea()}`}});B.setStaticOptions(B.defaultStaticOptions);function _n(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?_n(e.cause,t):t?null:e}function ta(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const s=e.replace("0x","");if(s.length>r*2)throw new sa({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s[n==="right"?"padEnd":"padStart"](r*2,"0")}`}function se(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<a){const d=typeof e=="bigint"?"n":"";throw new ra({max:i?`${i}${d}`:void 0,min:`${a}${d}`,signed:n,size:r,value:`${e}${d}`})}const u=`0x${(n&&s<0?BigInt.asUintN(r*8,BigInt(s)):s).toString(16)}`;return r?na(u,r):u}function na(e,t){return ta(e,{dir:"left",size:t})}class ra extends B{constructor({max:t,min:n,signed:r,size:s,value:i}){super(`Number \`${i}\` is not in safe${s?` ${s*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class sa extends B{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function ia(e){return{address:e.address,amount:se(e.amount),index:se(e.index),validatorIndex:se(e.validatorIndex)}}function aa(e){return{...typeof e.baseFeePerGas=="bigint"&&{baseFeePerGas:se(e.baseFeePerGas)},...typeof e.blobBaseFee=="bigint"&&{blobBaseFee:se(e.blobBaseFee)},...typeof e.feeRecipient=="string"&&{feeRecipient:e.feeRecipient},...typeof e.gasLimit=="bigint"&&{gasLimit:se(e.gasLimit)},...typeof e.number=="bigint"&&{number:se(e.number)},...typeof e.prevRandao=="bigint"&&{prevRandao:se(e.prevRandao)},...typeof e.time=="bigint"&&{time:se(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(ia)}}}const oa="0x82ad56cb",ca="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",ua="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",da="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033",Ze="/docs/contract/encodeDeployData";function Gn(e){const{abi:t,args:n,bytecode:r}=e;if(!n||n.length===0)return r;const s=t.find(a=>"type"in a&&a.type==="constructor");if(!s)throw new wr({docsPath:Ze});if(!("inputs"in s))throw new At({docsPath:Ze});if(!s.inputs||s.inputs.length===0)throw new At({docsPath:Ze});const i=ht(s.inputs,n);return De([r,i])}class he extends f{constructor({cause:t,message:n}={}){const r=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}}Object.defineProperty(he,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(he,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class Re extends f{constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${fe(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(Re,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class st extends f{constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${fe(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(st,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class it extends f{constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty(it,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class at extends f{constructor({cause:t,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
|
|
32
|
+
`),{cause:t,name:"NonceTooLowError"})}}Object.defineProperty(at,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class ot extends f{constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}}Object.defineProperty(ot,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class ct extends f{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
|
|
33
|
+
`),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(ct,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class ut extends f{constructor({cause:t,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(ut,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class dt extends f{constructor({cause:t,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(dt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class lt extends f{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(lt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Me extends f{constructor({cause:t,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${fe(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${fe(r)} gwei`:""}).`].join(`
|
|
34
|
+
`),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(Me,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class Hn extends f{constructor({cause:t}){super(`An error occurred while executing: ${t?.shortMessage}`,{cause:t,name:"UnknownNodeError"})}}function la(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof f?e.walk(s=>s?.code===he.code):e;return r instanceof f?new he({cause:e,message:r.details}):he.nodeMessage.test(n)?new he({cause:e,message:e.details}):Re.nodeMessage.test(n)?new Re({cause:e,maxFeePerGas:t?.maxFeePerGas}):st.nodeMessage.test(n)?new st({cause:e,maxFeePerGas:t?.maxFeePerGas}):it.nodeMessage.test(n)?new it({cause:e,nonce:t?.nonce}):at.nodeMessage.test(n)?new at({cause:e,nonce:t?.nonce}):ot.nodeMessage.test(n)?new ot({cause:e,nonce:t?.nonce}):ct.nodeMessage.test(n)?new ct({cause:e}):ut.nodeMessage.test(n)?new ut({cause:e,gas:t?.gas}):dt.nodeMessage.test(n)?new dt({cause:e,gas:t?.gas}):lt.nodeMessage.test(n)?new lt({cause:e}):Me.nodeMessage.test(n)?new Me({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new Hn({cause:e})}function fa(e,{docsPath:t,...n}){const r=(()=>{const s=la(e,n);return s instanceof Hn?e:s})();return new Gi(r,{docsPath:t,...n})}function pa(e,{format:t}){if(!t)return{};const n={};function r(i){const a=Object.keys(i);for(const o of a)o in e&&(n[o]=e[o]),i[o]&&typeof i[o]=="object"&&!Array.isArray(i[o])&&r(i[o])}const s=t(e||{});return r(s),n}const ya={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function ba(e,t){const n={};return typeof e.authorizationList<"u"&&(n.authorizationList=ma(e.authorizationList)),typeof e.accessList<"u"&&(n.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(n.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?n.blobs=e.blobs.map(r=>ae(r)):n.blobs=e.blobs),typeof e.data<"u"&&(n.data=e.data),e.account&&(n.from=e.account.address),typeof e.from<"u"&&(n.from=e.from),typeof e.gas<"u"&&(n.gas=C(e.gas)),typeof e.gasPrice<"u"&&(n.gasPrice=C(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=C(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(n.maxFeePerGas=C(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=C(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(n.nonce=C(e.nonce)),typeof e.to<"u"&&(n.to=e.to),typeof e.type<"u"&&(n.type=ya[e.type]),typeof e.value<"u"&&(n.value=C(e.value)),n}function ma(e){return e.map(t=>({address:t.address,r:t.r?C(BigInt(t.r)):t.r,s:t.s?C(BigInt(t.s)):t.s,chainId:C(t.chainId),nonce:C(t.nonce),...typeof t.yParity<"u"?{yParity:C(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:C(t.v)}:{}}))}function ha(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}const Xe=new Map;function ga({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:s}){const i=async()=>{const l=u();a();const y=l.map(({args:b})=>b);y.length!==0&&e(y).then(b=>{s&&Array.isArray(b)&&b.sort(s);for(let m=0;m<l.length;m++){const{resolve:h}=l[m];h?.([b[m],b])}}).catch(b=>{for(let m=0;m<l.length;m++){const{reject:h}=l[m];h?.(b)}})},a=()=>Xe.delete(t),o=()=>u().map(({args:l})=>l),u=()=>Xe.get(t)||[],d=l=>Xe.set(t,[...u(),l]);return{flush:a,async schedule(l){const{promise:y,resolve:b,reject:m}=ha();return n?.([...o(),l])&&i(),u().length>0?(d({args:l,resolve:b,reject:m}),y):(d({args:l,resolve:b,reject:m}),setTimeout(i,r),y)}}}function Ft(e){if(!(!e||e.length===0))return e.reduce((t,{slot:n,value:r})=>{if(n.length!==66)throw new St({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new St({size:r.length,targetSize:66,type:"hex"});return t[n]=r,t},{})}function xa(e){const{balance:t,nonce:n,state:r,stateDiff:s,code:i}=e,a={};if(i!==void 0&&(a.code=i),t!==void 0&&(a.balance=C(t)),n!==void 0&&(a.nonce=C(n)),r!==void 0&&(a.state=Ft(r)),s!==void 0){if(a.state)throw new Li;a.stateDiff=Ft(s)}return a}function wa(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!de(n,{strict:!1}))throw new Se({address:n});if(t[n])throw new Fi({address:n});t[n]=xa(r)}return t}const Ta=2n**256n-1n;function va(e){const{account:t,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=e,i=t?vt(t):void 0;if(i&&!de(i.address))throw new Se({address:i.address});if(s&&!de(s))throw new Se({address:s});if(n&&n>Ta)throw new Re({maxFeePerGas:n});if(r&&n&&r>n)throw new Me({maxFeePerGas:n,maxPriorityFeePerGas:r})}async function Vn(e,t){const{account:n=e.account,authorizationList:r,batch:s=!!e.batch?.multicall,blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",accessList:o,blobs:u,blockOverrides:d,code:l,data:y,factory:b,factoryData:m,gas:h,gasPrice:v,maxFeePerBlobGas:w,maxFeePerGas:T,maxPriorityFeePerGas:p,nonce:x,to:P,value:U,stateOverride:K,...ee}=t,_=n?vt(n):void 0;if(l&&(b||m))throw new f("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&P)throw new f("Cannot provide both `code` & `to` as parameters.");const $=l&&y,G=b&&m&&P&&y,N=$||G,te=$?Wn({code:l,data:y}):G?Aa({data:y,factory:b,factoryData:m,to:P}):y;try{va(t);const k=(typeof i=="bigint"?C(i):void 0)||a,D=d?aa(d):void 0,F=wa(K),me=e.chain?.formatters?.transactionRequest?.format,z=(me||ba)({...pa(ee,{format:me}),accessList:o,account:_,authorizationList:r,blobs:u,data:te,gas:h,gasPrice:v,maxFeePerBlobGas:w,maxFeePerGas:T,maxPriorityFeePerGas:p,nonce:x,to:N?void 0:P,value:U},"call");if(s&&Ea({request:z})&&!F&&!D)try{return await Pa(e,{...z,blockNumber:i,blockTag:a})}catch(H){if(!(H instanceof Rn)&&!(H instanceof rt))throw H}const J=(()=>{const H=[z,k];return F&&D?[...H,F,D]:F?[...H,F]:D?[...H,{},D]:H})(),je=await e.request({method:"eth_call",params:J});return je==="0x"?{data:void 0}:{data:je}}catch(X){const k=Sa(X),{offchainLookup:D,offchainLookupSignature:F}=await Promise.resolve().then(()=>require("./ccip-BXLlQVZi.cjs"));if(e.ccipRead!==!1&&k?.slice(0,10)===F&&P)return{data:await D(e,{data:k,to:P})};throw N&&k?.slice(0,10)==="0x101bb98d"?new Ki({factory:b}):fa(X,{...t,account:_,chain:e.chain})}}function Ea({request:e}){const{data:t,to:n,...r}=e;return!(!t||t.startsWith(oa)||!n||Object.values(r).filter(s=>typeof s<"u").length>0)}async function Pa(e,t){const{batchSize:n=1024,deployless:r=!1,wait:s=0}=typeof e.batch?.multicall=="object"?e.batch.multicall:{},{blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",data:o,to:u}=t,d=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return Ri({blockNumber:i,chain:e.chain,contract:"multicall3"});throw new Rn})(),y=(typeof i=="bigint"?C(i):void 0)||a,{schedule:b}=ga({id:`${e.uid}.${y}`,wait:s,shouldSplitBatch(v){return v.reduce((T,{data:p})=>T+(p.length-2),0)>n*2},fn:async v=>{const w=v.map(x=>({allowFailure:!0,callData:x.data,target:x.to})),T=kn({abi:Pt,args:[w],functionName:"aggregate3"}),p=await e.request({method:"eth_call",params:[{...d===null?{data:Wn({code:da,data:T})}:{to:d,data:T}},y]});return In({abi:Pt,args:[w],functionName:"aggregate3",data:p||"0x"})}}),[{returnData:m,success:h}]=await b({data:o,to:u});if(!h)throw new Fn({data:m});return m==="0x"?{data:void 0}:{data:m}}function Wn(e){const{code:t,data:n}=e;return Gn({abi:Cn(["constructor(bytes, bytes)"]),bytecode:ca,args:[t,n]})}function Aa(e){const{data:t,factory:n,factoryData:r,to:s}=e;return Gn({abi:Cn(["constructor(address, bytes, address, bytes)"]),bytecode:ua,args:[s,t,n,r]})}function Sa(e){if(!(e instanceof f))return;const t=e.walk();return typeof t?.data=="object"?t.data?.data:t.data}async function $a(e,t){const{abi:n,address:r,args:s,functionName:i,...a}=t,o=kn({abi:n,args:s,functionName:i});try{const{data:u}=await Yi(e,Vn,"call")({...a,data:o,to:r});return In({abi:n,args:s,functionName:i,data:u||"0x"})}catch(u){throw Qi(u,{abi:n,address:r,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}function Ca(e,t,n){const r=e[t.name];if(typeof r=="function")return r;const s=e[n];return typeof s=="function"?s:i=>t(e,i)}function ja(e,t){const{chainId:n,...r}=t,s=e.getClient({chainId:n});return Ca(s,$a,"readContract")(r)}const Na=30,Ia=.003,ka=5,Kn=8,Yn=10**Kn,Ra=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),M={ETH:{symbol:"ETH",decimals:18,name:"Ether"},USDC:{symbol:"USDC",decimals:6,name:"USD Coin"},USDT:{symbol:"USDT",decimals:6,name:"Tether USD"},DAI:{symbol:"DAI",decimals:18,name:"Dai Stablecoin"},WBTC:{symbol:"WBTC",decimals:8,name:"Wrapped Bitcoin"},IDRX:{symbol:"IDRX",decimals:18,name:"Indonesian Rupiah"}};function Zn(){const{address:e}=A.useAccount(),t=A.useConfig(),{writeContractAsync:n,data:r,isPending:s,error:i}=A.useWriteContract(),{isLoading:a,isSuccess:o}=A.useWaitForTransactionReceipt({hash:r}),u=()=>A.useReadContract({address:I.PAYMENT_ROUTER,abi:Ne,functionName:"tokenRegistry"}),d=()=>A.useReadContract({address:I.PAYMENT_ROUTER,abi:Ne,functionName:"feePercentage"}),l=()=>A.useReadContract({address:I.PAYMENT_ROUTER,abi:Ne,functionName:"paused"}),y=async(h,v)=>{try{return await ja(t,{address:h,abi:Y,functionName:"allowance",args:[v,I.PAYMENT_ROUTER]})}catch(w){return console.error("Error checking allowance:",w),BigInt(0)}},b=async(h,v)=>{if(!e)throw new Error("Wallet not connected");if(h==="0x0000000000000000000000000000000000000000")return null;try{return await y(h,e)>=v?(console.log(`Sufficient allowance for ${h}, skipping approval`),null):(console.log(`Requesting infinite approval for ${h}`),await n({address:h,abi:Y,functionName:"approve",args:[I.PAYMENT_ROUTER,ce.maxUint256]}))}catch(w){throw console.error(`Error in approveToken for ${h}:`,w),w}};return{executePayment:async({merchantAddress:h,tokens:v,totalAmountUSD:w,settleInIDR:T})=>{if(!e)throw new Error("Wallet not connected");const p=v.filter($=>$.percentage>0),x=[],P=[];let U=BigInt(0);const K=w*.003,ee=w+K;for(const $ of p){if(!$.priceUSD||$.priceUSD<=0)throw new Error(`Invalid price for ${$.symbol}. Price data may not be available yet. Please wait a moment and try again.`);const N=ee*$.percentage/100/$.priceUSD;if(!isFinite(N)||N<=0)throw new Error(`Invalid amount calculated for ${$.symbol}`);const te=Math.min($.decimals+2,18),X=N.toFixed(te);let k=ce.parseUnits(X,$.decimals);k=k+BigInt(1),$.address==="0x0000000000000000000000000000000000000000"?(U=k,x.push($.address),P.push(k)):(x.push($.address),P.push(k))}for(let $=0;$<p.length;$++){const G=p[$];if(G.address!=="0x0000000000000000000000000000000000000000")try{await b(G.address,P[$])&&console.log(`Approved infinite allowance for ${G.symbol}`)}catch(N){throw new Error(`Failed to approve ${G.symbol}: ${N}`)}}const _=BigInt(Math.floor(w*Yn));return await n({address:I.PAYMENT_ROUTER,abi:Ne,functionName:"pay",args:[h,x,P,_,T],value:U})},useTokenRegistry:u,useFeePercentage:d,usePaused:l,hash:r,isPending:s,isConfirming:a,isConfirmed:o,error:i}}function Pe(e){const{address:t}=A.useAccount(),{writeContract:n,data:r,isPending:s,error:i}=A.useWriteContract(),{isLoading:a,isSuccess:o}=A.useWaitForTransactionReceipt({hash:r});return{transfer:(T,p)=>{n({address:e,abi:Y,functionName:"transfer",args:[T,p]})},approve:(T,p)=>{n({address:e,abi:Y,functionName:"approve",args:[T,p]})},transferFrom:(T,p,x)=>{n({address:e,abi:Y,functionName:"transferFrom",args:[T,p,x]})},useName:()=>A.useReadContract({address:e,abi:Y,functionName:"name"}),useSymbol:()=>A.useReadContract({address:e,abi:Y,functionName:"symbol"}),useDecimals:()=>A.useReadContract({address:e,abi:Y,functionName:"decimals"}),useTotalSupply:()=>A.useReadContract({address:e,abi:Y,functionName:"totalSupply"}),useBalanceOf:T=>{const p=T||t;return A.useReadContract({address:e,abi:Y,functionName:"balanceOf",args:p?[p]:void 0,query:{enabled:!!p}})},useAllowance:(T,p)=>A.useReadContract({address:e,abi:Y,functionName:"allowance",args:T&&p?[T,p]:void 0,query:{enabled:!!(T&&p)}}),hash:r,isPending:s,isConfirming:a,isConfirmed:o,error:i}}function Xn(){const{address:e}=A.useAccount(),{data:t,isLoading:n}=A.useBalance({address:e}),r=Pe(S.USDC),s=Pe(S.USDT),i=Pe(S.DAI),a=Pe(S.WBTC),{data:o,isLoading:u}=r.useBalanceOf(e),{data:d,isLoading:l}=s.useBalanceOf(e),{data:y,isLoading:b}=i.useBalanceOf(e),{data:m,isLoading:h}=a.useBalanceOf(e);return{balances:{ETH:t?parseFloat(ce.formatUnits(t.value,18)):0,USDC:o?parseFloat(ce.formatUnits(o,6)):0,USDT:d?parseFloat(ce.formatUnits(d,6)):0,DAI:y?parseFloat(ce.formatUnits(y,18)):0,WBTC:m?parseFloat(ce.formatUnits(m,8)):0},isLoading:!e||n||u||l||b||h}}function Jn(){const e=Oe(),{data:t,isLoading:n,error:r}=e.useGetTokenPrice(S.NATIVE),{data:s,isLoading:i,error:a}=e.useGetTokenPrice(S.USDC),{data:o,isLoading:u,error:d}=e.useGetTokenPrice(S.USDT),{data:l,isLoading:y,error:b}=e.useGetTokenPrice(S.DAI),{data:m,isLoading:h,error:v}=e.useGetTokenPrice(S.WBTC),w=1e8,T=x=>{if(!x)return 0;try{if(Array.isArray(x)&&x.length>=1){const P=x[0];if(typeof P=="bigint")return Number(P)/w;if(typeof P=="number")return P/w;if(typeof P=="string")return Number(P)/w}return typeof x=="bigint"?Number(x)/w:typeof x=="number"?x/w:0}catch(P){return console.error("Error converting price:",P),0}};r&&console.error("ETH price error:",r),a&&console.error("USDC price error:",a),d&&console.error("USDT price error:",d),b&&console.error("DAI price error:",b),v&&console.error("WBTC price error:",v);const p={ETH:T(t),USDC:T(s)||1,USDT:T(o)||1,DAI:T(l)||1,WBTC:T(m)};return console.log("Converted prices:",p),{prices:p,isLoading:n||i||u||y||h,errors:{ETH:r,USDC:a,USDT:d,DAI:b,WBTC:v}}}class re extends Error{code;details;constructor(t,n,r){super(t),this.name="PaymentError",this.code=n,this.details=r}}function Lt(e){if(e instanceof Error){if(e.message.includes("User rejected")||e.message.includes("User denied"))return new re("Transaction cancelled by user","USER_REJECTED",e);if(e.message.includes("Failed to approve"))return new re(e.message,"APPROVAL_FAILED",e);if(e.message.includes("insufficient funds"))return new re("Insufficient funds for gas","INSUFFICIENT_FUNDS",e);if(e.message.includes("Wallet not connected"))return new re("Please connect your wallet","WALLET_NOT_CONNECTED",e);if(e.message.includes("network"))return new re("Network error. Please check your connection","NETWORK_ERROR",e);if(e.message.includes("insufficient payment")||e.message.includes("PaymentRouter: insufficient"))return new re("Payment amount is insufficient. This may be due to price fluctuation. Please try again.","INSUFFICIENT_PAYMENT",e);if(e.message.includes("execution reverted"))return new re("Transaction failed. Please try again","CONTRACT_ERROR",e);if(e.message)return new re(e.message,"ERROR",e)}return new re("An unknown error occurred. Please try again","UNKNOWN",e)}function Ma({totalAmount:e,merchantAddress:t,currency:n="USD",items:r,settleInIDR:s=!1,onPaymentComplete:i,onPaymentError:a,className:o="",children:u}){const{isConnected:d}=A.useAccount(),{connect:l,connectors:y}=A.useConnect(),[b,m]=j.useState(!1),[h,v]=j.useState([]),{balances:w,isLoading:T}=Xn(),{prices:p,isLoading:x}=Jn();console.log("Token prices from useMultiTokenPrices:",p);const{executePayment:P,isConfirmed:U,hash:K,error:ee,isPending:_,isConfirming:$}=Zn(),G=Oe(),{data:N}=G.useGetTokenPrice(S.IDRX),te=1e8,k=(()=>{if(!N)return 1/15600;if(Array.isArray(N)&&N.length>=1){const L=N[0];if(typeof L=="bigint")return Number(L)/te}return 1/15600})();j.useEffect(()=>{if(!T&&!x){const L=[{id:"eth",name:M.ETH.name,symbol:M.ETH.symbol,amount:w.ETH,chain:"Lisk Sepolia",percentage:0,address:S.NATIVE,decimals:M.ETH.decimals,priceUSD:p.ETH},{id:"usdc",name:M.USDC.name,symbol:M.USDC.symbol,amount:w.USDC,chain:"Lisk Sepolia",percentage:0,address:S.USDC,decimals:M.USDC.decimals,priceUSD:p.USDC},{id:"usdt",name:M.USDT.name,symbol:M.USDT.symbol,amount:w.USDT,chain:"Lisk Sepolia",percentage:0,address:S.USDT,decimals:M.USDT.decimals,priceUSD:p.USDT},{id:"dai",name:M.DAI.name,symbol:M.DAI.symbol,amount:w.DAI,chain:"Lisk Sepolia",percentage:0,address:S.DAI,decimals:M.DAI.decimals,priceUSD:p.DAI},{id:"wbtc",name:M.WBTC.name,symbol:M.WBTC.symbol,amount:w.WBTC,chain:"Lisk Sepolia",percentage:0,address:S.WBTC,decimals:M.WBTC.decimals,priceUSD:p.WBTC}];v(L)}},[w.ETH,w.USDC,w.USDT,w.DAI,w.WBTC,p.ETH,p.USDC,p.USDT,p.DAI,p.WBTC,T,x]),j.useEffect(()=>{if(U&&K){const L={success:!0,transactionId:K,tokens:h.filter(z=>z.percentage>0)};i?.(L)}},[U,K]),j.useEffect(()=>{if(ee){const L=Lt(ee);a?.(L)}},[ee]);const D=n==="IDR"?e*k:e,F=()=>{d?m(!0):l({connector:y[0]})},me=async L=>{try{await P({merchantAddress:t,tokens:L,totalAmountUSD:D,settleInIDR:s})}catch(z){const J=Lt(z);a?.(J)}};return c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:F,disabled:T||x,className:`bg-secondary hover:bg-secondary/90 text-white font-semibold py-3 px-6 rounded-lg transition-all disabled:opacity-50 disabled:cursor-not-allowed ${o}`,children:u||(d?"Pay with MultiCoyn":"Connect Wallet to Pay")}),d&&c.jsx(mr,{isOpen:b,onClose:()=>m(!1),totalAmount:D,currency:n,items:r,tokens:h,onPaymentSubmit:me,transactionHash:K,isProcessing:_||$,isSuccess:U})]})}const Qn=ce.defineChain({id:4202,name:"Lisk Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia-api.lisk.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-blockscout.lisk.com"}},testnet:!0}),qn=_t.getDefaultConfig({appName:"MultiCoyn Payment SDK",projectId:"YOUR_PROJECT_ID_HERE",chains:[Qn],ssr:!1}),Oa=new zt.QueryClient;function Da({children:e}){return c.jsx(A.WagmiProvider,{config:qn,children:c.jsx(zt.QueryClientProvider,{client:Oa,children:c.jsx(_t.RainbowKitProvider,{children:e})})})}const er=j.createContext(void 0);function Ba({children:e,initialConfig:t={}}){const[n,r]=j.useState(t),s=i=>{r(a=>({...a,...i}))};return c.jsx(er.Provider,{value:{config:n,updateConfig:s},children:e})}function Ua(){const e=j.useContext(er);if(!e)throw new Error("usePaymentConfig must be used within PaymentProvider");return e}exports.AbiErrorInputsNotFoundError=Ar;exports.AbiErrorNotFoundError=Sr;exports.AbiFunctionNotFoundError=Ae;exports.AbiFunctionOutputsNotFoundError=Kt;exports.AbiFunctionSignatureNotFoundError=$r;exports.BaseError=f;exports.CONTRACTS=I;exports.FEE_BASIS_POINTS=Na;exports.FEE_PERCENTAGE=Ia;exports.HttpRequestError=Zi;exports.InvalidAddressError=Se;exports.InvalidArrayError=Yt;exports.MAX_TOKENS_PER_PAYMENT=ka;exports.MAX_UINT256=Ra;exports.MulticoynButton=Ma;exports.PaymentProvider=Ba;exports.PaymentSummary=Gt;exports.TOKENS=S;exports.TOKEN_METADATA=M;exports.USD_DECIMALS=Kn;exports.USD_SCALE=Yn;exports.Web3Provider=Da;exports.batchGatewayAbi=gr;exports.call=Vn;exports.concat=ye;exports.concatHex=De;exports.decodeAbiParameters=Tt;exports.decodeErrorResult=On;exports.encodeAbiParameters=ht;exports.formatAbiItem=pe;exports.getAbiItem=Ue;exports.getUrl=Et;exports.isAddress=de;exports.isHex=xe;exports.liskSepolia=Qn;exports.slice=$e;exports.solidityError=Mn;exports.stringify=Fe;exports.toFunctionSelector=Be;exports.useERC20=Pe;exports.useMultiTokenBalances=Xn;exports.useMultiTokenPrices=Jn;exports.usePaymentConfig=Ua;exports.usePaymentModal=hr;exports.usePaymentRouter=Zn;exports.useTokenRegistry=Oe;exports.wagmiConfig=qn;
|