@dodoex/wallet-web3 0.0.26 → 0.0.28
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/dist/__node-resolve_empty-7f3920c0.js +1 -0
- package/dist/__tslib-94b604c6.js +1 -0
- package/dist/{blocto-19dae445.js → blocto-a36963cc.js} +1 -1
- package/dist/{bn-e0d348aa.js → bn-0790fcbe.js} +1 -1
- package/dist/{browser-ponyfill-b51b2c03.js → browser-ponyfill-1b463cf8.js} +1 -1
- package/dist/cjs/{__node-resolve_empty-2737d9bf.cjs → __node-resolve_empty-bc5af16b.cjs} +1 -1
- package/dist/cjs/__tslib-1ec3daf4.cjs +1 -0
- package/dist/cjs/{blocto-adfaee07.cjs → blocto-16e8f1b3.cjs} +1 -1
- package/dist/cjs/{bn-688cda2d.cjs → bn-4dd7f2eb.cjs} +1 -1
- package/dist/cjs/{browser-ponyfill-b8b49748.cjs → browser-ponyfill-1a96c588.cjs} +1 -1
- package/dist/cjs/{ethers-ee680fbb.cjs → ethers-5ee3d401.cjs} +1 -1
- package/dist/cjs/{id-c014d392.cjs → id-c2902d71.cjs} +1 -1
- package/dist/cjs/{index-9f87f923.cjs → index-27a468e4.cjs} +1 -1
- package/dist/cjs/{index-dff4439e.cjs → index-47edd493.cjs} +1 -1
- package/dist/cjs/{index-0918c8d5.cjs → index-726fa5d3.cjs} +1 -1
- package/dist/cjs/{index-a197572a.cjs → index-8ddd70a4.cjs} +1 -1
- package/dist/cjs/{index-317848de.cjs → index-a152dfe5.cjs} +1 -1
- package/dist/cjs/{index-4786d18b.cjs → index-ad504910.cjs} +1 -1
- package/dist/cjs/{index-44470a7c.cjs → index-d1f28d47.cjs} +1 -1
- package/dist/cjs/{index-0c4d4a4b.cjs → index-db125e58.cjs} +1 -1
- package/dist/cjs/{index-8b171ae1.cjs → index-f211bfc7.cjs} +1 -1
- package/dist/cjs/{index-aa30a39c.cjs → index-f8ed3316.cjs} +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/{index.es-996b27c7.cjs → index.es-76c3ee67.cjs} +1 -1
- package/dist/cjs/{interface-a1a293c0.cjs → interface-38f58c72.cjs} +1 -1
- package/dist/cjs/{portis-4c61c658.cjs → portis-a41fa079.cjs} +1 -1
- package/dist/cjs/{provider-339c3efd.cjs → provider-7dbf7bc1.cjs} +1 -1
- package/dist/cjs/{rainbow-7c3833bf.cjs → rainbow-684484cd.cjs} +1 -1
- package/dist/cjs/{typed-data-10fba9b8.cjs → typed-data-e9e9d817.cjs} +1 -1
- package/dist/cjs/{uAuth-94b82fcd.cjs → uAuth-a7a13114.cjs} +1 -1
- package/dist/cjs/{walletConnect-a4d08cd2.cjs → walletConnect-834254aa.cjs} +1 -1
- package/dist/cjs/walletLink-6a3fa2ad.cjs +1 -0
- package/dist/{ethers-85ce2662.js → ethers-2313fc7c.js} +1 -1
- package/dist/{id-c0507d8c.js → id-fe4b4d37.js} +1 -1
- package/dist/{index-f3680a5d.js → index-0311b59b.js} +1 -1
- package/dist/{index-5b064706.js → index-075c9d7c.js} +1 -1
- package/dist/{index-921d33c9.js → index-29e65daf.js} +1 -1
- package/dist/index-46feeec1.js +1 -0
- package/dist/{index-8f80892d.js → index-71b3715c.js} +1 -1
- package/dist/{index-a95b7ad7.js → index-91e932a7.js} +1 -1
- package/dist/{index-f08f2425.js → index-b5e7ed2d.js} +1 -1
- package/dist/{index-8cd14b03.js → index-bcd1d272.js} +1 -1
- package/dist/{index-034fbdf8.js → index-d1afa2bd.js} +1 -1
- package/dist/{index-77a007d6.js → index-f538e2f0.js} +1 -1
- package/dist/{index.es-4d15e9f8.js → index.es-7178bcb8.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{interface-a77d6d24.js → interface-0693e0ec.js} +1 -1
- package/dist/{portis-57b85d93.js → portis-fd675b02.js} +1 -1
- package/dist/{provider-406799de.js → provider-99297f01.js} +1 -1
- package/dist/{rainbow-1715bd5e.js → rainbow-739403e3.js} +1 -1
- package/dist/{typed-data-6eb1c9d6.js → typed-data-9988323b.js} +1 -1
- package/dist/{uAuth-8cd70ace.js → uAuth-5af4b438.js} +1 -1
- package/dist/{walletConnect-b5b4ab10.js → walletConnect-e2b526ac.js} +1 -1
- package/dist/walletLink-0f23b38e.js +1 -0
- package/package.json +1 -1
- package/dist/__node-resolve_empty-5887e83d.js +0 -1
- package/dist/__tslib-b8bc3a35.js +0 -1
- package/dist/cjs/__tslib-36244895.cjs +0 -1
- package/dist/cjs/walletLink-82bc59c9.cjs +0 -1
- package/dist/index-317ac511.js +0 -1
- package/dist/walletLink-006df4f1.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,g as t,b as s,_ as a,d as r,u as n}from"./index-77a007d6.js";import{b as i}from"./browser-ponyfill-b51b2c03.js";import{e as o,W as d,F as c,l as u,u as l,w as f,v as h,a as g}from"./ethers-85ce2662.js";import{Signer as p,VoidSigner as _}from"@ethersproject/abstract-signer";import*as E from"@ethersproject/providers";import{getDefaultProvider as m}from"@ethersproject/providers";import{BaseContract as v,Contract as T,ContractFactory as y}from"@ethersproject/contracts";import{B as w,E as S}from"./id-c0507d8c.js";import*as I from"@ethersproject/constants";import b from"events";import"zustand";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";import"@ethersproject/abstract-provider";import"./typed-data-6eb1c9d6.js";import"./__node-resolve_empty-5887e83d.js";import"./hash-a9ebd52a.js";import"./inherits_browser-06ba108b.js";import"@ethersproject/json-wallets";import"./interface-a77d6d24.js";import"./index-a95b7ad7.js";import"./index-f08f2425.js";var A={},P={},M={},O={},C={},R={name:"@safe-global/safe-apps-sdk",version:"7.10.1",description:"SDK developed to integrate third-party apps with Safe app.",main:"dist/src/index.js",typings:"dist/src/index.d.ts",_files:["dist/**/*","src/**/*","CHANGELOG.md","README.md"],keywords:["Safe","sdk","apps"],scripts:{test:"jest","format-dist":"sed -i '' 's/\"files\":/\"_files\":/' dist/package.json",build:"yarn rimraf dist && tsc && yarn format-dist"},author:"Safe (https://safe.global)",license:"MIT",dependencies:{"@safe-global/safe-gateway-typescript-sdk":"^3.5.3",ethers:"^5.7.2"},devDependencies:{rimraf:"^3.0.2"},repository:{type:"git",url:"git+https://github.com/safe-global/safe-apps-sdk.git"},bugs:{url:"https://github.com/safe-global/safe-apps-sdk/issues"},homepage:"https://github.com/safe-global/safe-apps-sdk#readme",publishConfig:{access:"public"}},N=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0}),C.getSDKVersion=void 0;const L=N(R);C.getSDKVersion=()=>L.default.version.split("-")[0];var D={};Object.defineProperty(D,"__esModule",{value:!0}),D.generateRequestId=void 0;const j=e=>e.toString(16).padStart(2,"0");D.generateRequestId=()=>"undefined"!=typeof window?(e=>{const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,j).join("")})(10):(new Date).getTime().toString(36),Object.defineProperty(O,"__esModule",{value:!0}),O.MessageFormatter=void 0;const x=C,H=D;class B{}O.MessageFormatter=B,B.makeRequest=(e,t)=>({id:(0,H.generateRequestId)(),method:e,params:t,env:{sdkVersion:(0,x.getSDKVersion)()}}),B.makeResponse=(e,t,s)=>({id:e,success:!0,version:s,data:t}),B.makeErrorResponse=(e,t,s)=>({id:e,success:!1,error:t,version:s});var k,q,U={};k=U,Object.defineProperty(k,"__esModule",{value:!0}),k.RestrictedMethods=k.Methods=void 0,(q=k.Methods||(k.Methods={})).sendTransactions="sendTransactions",q.rpcCall="rpcCall",q.getChainInfo="getChainInfo",q.getSafeInfo="getSafeInfo",q.getTxBySafeTxHash="getTxBySafeTxHash",q.getSafeBalances="getSafeBalances",q.signMessage="signMessage",q.signTypedMessage="signTypedMessage",q.getEnvironmentInfo="getEnvironmentInfo",q.getOffChainSignature="getOffChainSignature",q.requestAddressBook="requestAddressBook",q.wallet_getPermissions="wallet_getPermissions",q.wallet_requestPermissions="wallet_requestPermissions",(k.RestrictedMethods||(k.RestrictedMethods={})).requestAddressBook="requestAddressBook",function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0});const r=O;t.default=class{constructor(e=null,t=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer="undefined"==typeof window,this.isValidMessage=({origin:e,data:t,source:s})=>{const a=!t,r=!this.isServer&&s===window.parent,n=(void 0!==t.version&&parseInt(t.version.split(".")[0]))>=1;let i=!0;return Array.isArray(this.allowedOrigins)&&(i=void 0!==this.allowedOrigins.find((t=>t.test(e)))),!a&&r&&n&&i},this.logIncomingMessage=e=>{console.info(`Safe Apps SDK v1: A message was received from origin ${e.origin}. `,e.data)},this.onParentMessage=e=>{this.isValidMessage(e)&&(this.debugMode&&this.logIncomingMessage(e),this.handleIncomingMessage(e.data))},this.handleIncomingMessage=e=>{const{id:t}=e,s=this.callbacks.get(t);s&&(s(e),this.callbacks.delete(t))},this.send=(e,t)=>{const s=r.MessageFormatter.makeRequest(e,t);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(s,"*"),new Promise(((e,t)=>{this.callbacks.set(s.id,(s=>{s.success?e(s):t(new Error(s.error))}))}))},this.allowedOrigins=e,this.debugMode=t,this.isServer||window.addEventListener("message",this.onParentMessage)}},a(U,t)}(M);var G={},$={},F={};Object.defineProperty(F,"__esModule",{value:!0}),F.isObjectEIP712TypedData=void 0;F.isObjectEIP712TypedData=e=>"object"==typeof e&&null!=e&&"domain"in e&&"types"in e&&"message"in e;var V={};Object.defineProperty(V,"__esModule",{value:!0});var W={},K={},Q={},X={},Y=e&&e.__awaiter||function(e,t,s,a){return new(s||(s=Promise))((function(r,n){function i(e){try{d(a.next(e))}catch(e){n(e)}}function o(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(i,o)}d((a=a.apply(e,t||[])).next())}))},J=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.fetchData=X.stringifyQuery=X.insertParams=void 0;const z=J(i.exports);X.insertParams=function(e,t){return t?Object.keys(t).reduce(((e,s)=>function(e,t,s){return e.replace(new RegExp(`\\{${t}\\}`,"g"),s)}(e,s,String(t[s]))),e):e},X.stringifyQuery=function(e){if(!e)return"";const t=new URLSearchParams;Object.keys(e).forEach((s=>{null!=e[s]&&t.append(s,String(e[s]))}));const s=t.toString();return s?`?${s}`:""},X.fetchData=function(e,t){return Y(this,void 0,void 0,(function*(){let s;null!=t&&(s={method:"POST",body:"string"==typeof t?t:JSON.stringify(t),headers:{"Content-Type":"application/json"}});const a=yield(0,z.default)(e,s);let r;try{r=yield a.json()}catch(e){if(a.headers&&"0"!==a.headers.get("content-length"))throw new Error(`Invalid response content: ${a.statusText}`)}if(!a.ok){const e="object"==typeof(n=r)&&null!==n&&"code"in n&&"message"in n?`${r.code}: ${r.message}`:a.statusText;throw new Error(e)}var n;return r}))},Object.defineProperty(Q,"__esModule",{value:!0}),Q.getEndpoint=Q.postEndpoint=void 0;const Z=X;function ee(e,t,s,a){return`${e}${(0,Z.insertParams)(t,s)}${(0,Z.stringifyQuery)(a)}`}Q.postEndpoint=function(e,t,s){const a=ee(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,Z.fetchData)(a,null==s?void 0:s.body)},Q.getEndpoint=function(e,t,s,a){if(a)return(0,Z.fetchData)(a);const r=ee(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,Z.fetchData)(r)};var te={};Object.defineProperty(te,"__esModule",{value:!0}),te.DEFAULT_BASE_URL=void 0,te.DEFAULT_BASE_URL="https://safe-client.safe.global";var se={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ImplementationVersionState=void 0,(t=e.ImplementationVersionState||(e.ImplementationVersionState={})).UP_TO_DATE="UP_TO_DATE",t.OUTDATED="OUTDATED",t.UNKNOWN="UNKNOWN"}(se);var ae={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppSocialPlatforms=e.SafeAppFeatures=e.SafeAppAccessPolicyTypes=void 0,(t=e.SafeAppAccessPolicyTypes||(e.SafeAppAccessPolicyTypes={})).NoRestrictions="NO_RESTRICTIONS",t.DomainAllowlist="DOMAIN_ALLOWLIST",(e.SafeAppFeatures||(e.SafeAppFeatures={})).BATCHED_TRANSACTIONS="BATCHED_TRANSACTIONS",(s=e.SafeAppSocialPlatforms||(e.SafeAppSocialPlatforms={})).TWITTER="TWITTER",s.GITHUB="GITHUB",s.DISCORD="DISCORD"}(ae);var re={};!function(e){var t,s,a,r,n,i,o,d,c,u;Object.defineProperty(e,"__esModule",{value:!0}),e.LabelValue=e.DetailedExecutionInfoType=e.TransactionListItemType=e.ConflictType=e.TransactionInfoType=e.SettingsInfoType=e.TransactionTokenType=e.TransferDirection=e.TransactionStatus=e.Operation=void 0,(t=e.Operation||(e.Operation={}))[t.CALL=0]="CALL",t[t.DELEGATE=1]="DELEGATE",(s=e.TransactionStatus||(e.TransactionStatus={})).AWAITING_CONFIRMATIONS="AWAITING_CONFIRMATIONS",s.AWAITING_EXECUTION="AWAITING_EXECUTION",s.CANCELLED="CANCELLED",s.FAILED="FAILED",s.SUCCESS="SUCCESS",(a=e.TransferDirection||(e.TransferDirection={})).INCOMING="INCOMING",a.OUTGOING="OUTGOING",a.UNKNOWN="UNKNOWN",(r=e.TransactionTokenType||(e.TransactionTokenType={})).ERC20="ERC20",r.ERC721="ERC721",r.NATIVE_COIN="NATIVE_COIN",(n=e.SettingsInfoType||(e.SettingsInfoType={})).SET_FALLBACK_HANDLER="SET_FALLBACK_HANDLER",n.ADD_OWNER="ADD_OWNER",n.REMOVE_OWNER="REMOVE_OWNER",n.SWAP_OWNER="SWAP_OWNER",n.CHANGE_THRESHOLD="CHANGE_THRESHOLD",n.CHANGE_IMPLEMENTATION="CHANGE_IMPLEMENTATION",n.ENABLE_MODULE="ENABLE_MODULE",n.DISABLE_MODULE="DISABLE_MODULE",n.SET_GUARD="SET_GUARD",n.DELETE_GUARD="DELETE_GUARD",(i=e.TransactionInfoType||(e.TransactionInfoType={})).TRANSFER="Transfer",i.SETTINGS_CHANGE="SettingsChange",i.CUSTOM="Custom",i.CREATION="Creation",(o=e.ConflictType||(e.ConflictType={})).NONE="None",o.HAS_NEXT="HasNext",o.END="End",(d=e.TransactionListItemType||(e.TransactionListItemType={})).TRANSACTION="TRANSACTION",d.LABEL="LABEL",d.CONFLICT_HEADER="CONFLICT_HEADER",d.DATE_LABEL="DATE_LABEL",(c=e.DetailedExecutionInfoType||(e.DetailedExecutionInfoType={})).MULTISIG="MULTISIG",c.MODULE="MODULE",(u=e.LabelValue||(e.LabelValue={})).Queued="Queued",u.Next="Next"}(re);var ne={};!function(e){var t,s,a;Object.defineProperty(e,"__esModule",{value:!0}),e.FEATURES=e.GAS_PRICE_TYPE=e.RPC_AUTHENTICATION=void 0,(t=e.RPC_AUTHENTICATION||(e.RPC_AUTHENTICATION={})).API_KEY_PATH="API_KEY_PATH",t.NO_AUTHENTICATION="NO_AUTHENTICATION",t.UNKNOWN="UNKNOWN",(s=e.GAS_PRICE_TYPE||(e.GAS_PRICE_TYPE={})).ORACLE="ORACLE",s.FIXED="FIXED",s.UNKNOWN="UNKNOWN",(a=e.FEATURES||(e.FEATURES={})).ERC721="ERC721",a.SAFE_APPS="SAFE_APPS",a.CONTRACT_INTERACTION="CONTRACT_INTERACTION",a.DOMAIN_LOOKUP="DOMAIN_LOOKUP",a.SPENDING_LIMIT="SPENDING_LIMIT",a.EIP1559="EIP1559",a.SAFE_TX_GAS_OPTIONAL="SAFE_TX_GAS_OPTIONAL",a.TX_SIMULATION="TX_SIMULATION",a.EIP1271="EIP1271"}(ne);var ie={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.TokenType=void 0,(t=e.TokenType||(e.TokenType={})).ERC20="ERC20",t.ERC721="ERC721",t.NATIVE_TOKEN="NATIVE_TOKEN"}(ie);var oe={};Object.defineProperty(oe,"__esModule",{value:!0});var de={};Object.defineProperty(de,"__esModule",{value:!0});var ce={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeMessageStatus=e.SafeMessageListItemType=void 0,(t=e.SafeMessageListItemType||(e.SafeMessageListItemType={})).DATE_LABEL="DATE_LABEL",t.MESSAGE="MESSAGE",(s=e.SafeMessageStatus||(e.SafeMessageStatus={})).NEEDS_CONFIRMATION="NEEDS_CONFIRMATION",s.CONFIRMED="CONFIRMED"}(ce),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.confirmSafeMessage=t.proposeSafeMessage=t.getSafeMessage=t.getSafeMessages=t.getDecodedData=t.getMasterCopies=t.getSafeApps=t.getChainConfig=t.getChainsConfig=t.proposeTransaction=t.postSafeGasEstimation=t.getTransactionDetails=t.getTransactionQueue=t.getTransactionHistory=t.getCollectiblesPage=t.getCollectibles=t.getOwnedSafes=t.getFiatCurrencies=t.getBalances=t.getMultisigTransactions=t.getModuleTransactions=t.getIncomingTransfers=t.getSafeInfo=t.setBaseUrl=void 0;const r=Q,n=te;a(se,t),a(ae,t),a(re,t),a(ne,t),a(ie,t),a(oe,t),a(de,t),a(ce,t);let i=n.DEFAULT_BASE_URL;t.setBaseUrl=e=>{i=e},t.getSafeInfo=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}",{path:{chainId:e,address:t}})},t.getIncomingTransfers=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/incoming-transfers/",{path:{chainId:e,address:t},query:s},a)},t.getModuleTransactions=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/module-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getMultisigTransactions=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/multisig-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getBalances=function(e,t,s="usd",a={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/balances/{currency}",{path:{chainId:e,address:t,currency:s},query:a})},t.getFiatCurrencies=function(){return(0,r.getEndpoint)(i,"/v1/balances/supported-fiat-codes")},t.getOwnedSafes=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/owners/{address}/safes",{path:{chainId:e,address:t}})},t.getCollectibles=function(e,t,s={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s})},t.getCollectiblesPage=function(e,t,s={},a){return(0,r.getEndpoint)(i,"/v2/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s},a)},t.getTransactionHistory=function(e,t,s){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/history",{path:{chainId:e,safe_address:t},query:{}},s)},t.getTransactionQueue=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/queued",{path:{chainId:e,safe_address:t},query:{trusted:a}},s)},t.getTransactionDetails=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/transactions/{transactionId}",{path:{chainId:e,transactionId:t}})},t.postSafeGasEstimation=function(e,t,s){return(0,r.postEndpoint)(i,"/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations",{path:{chainId:e,safe_address:t},body:s})},t.proposeTransaction=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/transactions/{safe_address}/propose",{path:{chainId:e,safe_address:t},body:s})},t.getChainsConfig=function(e){return(0,r.getEndpoint)(i,"/v1/chains",{query:e})},t.getChainConfig=function(e){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}",{path:{chainId:e}})},t.getSafeApps=function(e,t={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safe-apps",{path:{chainId:e},query:t})},t.getMasterCopies=function(e){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/about/master-copies",{path:{chainId:e}})},t.getDecodedData=function(e,t){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/data-decoder",{path:{chainId:e},body:{data:t}})},t.getSafeMessages=function(e,t,s){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},query:{}},s)},t.getSafeMessage=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}",{path:{chainId:e,message_hash:t}})},t.proposeSafeMessage=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},body:s})},t.confirmSafeMessage=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}/signatures",{path:{chainId:e,message_hash:t},body:s})}}(K),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TransferDirection=e.TransactionStatus=e.TokenType=e.Operation=void 0;var t=K;Object.defineProperty(e,"Operation",{enumerable:!0,get:function(){return t.Operation}}),Object.defineProperty(e,"TokenType",{enumerable:!0,get:function(){return t.TokenType}}),Object.defineProperty(e,"TransactionStatus",{enumerable:!0,get:function(){return t.TransactionStatus}}),Object.defineProperty(e,"TransferDirection",{enumerable:!0,get:function(){return t.TransferDirection}})}(W);var ue={};Object.defineProperty(ue,"__esModule",{value:!0}),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),a(F,t),a(V,t),a(W,t),a(ue,t)}($),Object.defineProperty(G,"__esModule",{value:!0}),G.TXs=void 0;const le=U,fe=$;G.TXs=class{constructor(e){this.communicator=e}async getBySafeTxHash(e){if(!e)throw new Error("Invalid safeTxHash");return(await this.communicator.send(le.Methods.getTxBySafeTxHash,{safeTxHash:e})).data}async signMessage(e){const t={message:e};return(await this.communicator.send(le.Methods.signMessage,t)).data}async signTypedMessage(e){if(!(0,fe.isObjectEIP712TypedData)(e))throw new Error("Invalid typed data");return(await this.communicator.send(le.Methods.signTypedMessage,{typedData:e})).data}async send({txs:e,params:t}){if(!e||!e.length)throw new Error("No transactions were passed");const s={txs:e,params:t};return(await this.communicator.send(le.Methods.sendTransactions,s)).data}};var he={},ge={};Object.defineProperty(ge,"__esModule",{value:!0}),ge.RPC_CALLS=void 0,ge.RPC_CALLS={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},Object.defineProperty(he,"__esModule",{value:!0}),he.Eth=void 0;const pe=ge,_e=U,Ee={defaultBlockParam:(e="latest")=>e,returnFullTxObjectParam:(e=!1)=>e,blockNumberToHex:e=>Number.isInteger(e)?`0x${e.toString(16)}`:e};he.Eth=class{constructor(e){this.communicator=e,this.call=this.buildRequest({call:pe.RPC_CALLS.eth_call,formatters:[null,Ee.defaultBlockParam]}),this.getBalance=this.buildRequest({call:pe.RPC_CALLS.eth_getBalance,formatters:[null,Ee.defaultBlockParam]}),this.getCode=this.buildRequest({call:pe.RPC_CALLS.eth_getCode,formatters:[null,Ee.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:pe.RPC_CALLS.eth_getStorageAt,formatters:[null,Ee.blockNumberToHex,Ee.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:pe.RPC_CALLS.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:pe.RPC_CALLS.eth_getBlockByHash,formatters:[null,Ee.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:pe.RPC_CALLS.eth_getBlockByNumber,formatters:[Ee.blockNumberToHex,Ee.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionCount,formatters:[null,Ee.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:pe.RPC_CALLS.eth_gasPrice}),this.getEstimateGas=e=>this.buildRequest({call:pe.RPC_CALLS.eth_estimateGas})([e]),this.setSafeSettings=this.buildRequest({call:pe.RPC_CALLS.safe_setSettings})}buildRequest(e){const{call:t,formatters:s}=e;return async e=>{s&&Array.isArray(e)&&s.forEach(((t,s)=>{t&&(e[s]=t(e[s]))}));const a={call:t,params:e||[]};return(await this.communicator.send(_e.Methods.rpcCall,a)).data}}};var me={};try{const e=window;null==e._ethers&&(e._ethers=o)}catch(e){}var ve=t(Object.freeze({__proto__:null,ethers:o,Signer:p,Wallet:d,VoidSigner:_,getDefaultProvider:m,providers:E,BaseContract:v,Contract:T,ContractFactory:y,BigNumber:w,FixedNumber:c,constants:I,get errors(){return S},logger:u,utils:l,wordlists:f,version:h,Wordlist:g})),Te={};Object.defineProperty(Te,"__esModule",{value:!0}),Te.MAGIC_VALUE_BYTES=Te.MAGIC_VALUE=Te.EIP_1271_BYTES_INTERFACE=Te.EIP_1271_INTERFACE=void 0;const ye=ve;Te.MAGIC_VALUE="0x1626ba7e";Te.MAGIC_VALUE_BYTES="0x20c13b0b";const we=new ye.ethers.utils.Interface(["function isValidSignature(bytes32 _dataHash, bytes calldata _signature) external view"]);Te.EIP_1271_INTERFACE=we;const Se=new ye.ethers.utils.Interface(["function isValidSignature(bytes calldata _data, bytes calldata _signature) public view"]);Te.EIP_1271_BYTES_INTERFACE=Se;var Ie={},be={},Ae={};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.PermissionsError=Ae.PERMISSIONS_REQUEST_REJECTED=void 0,Ae.PERMISSIONS_REQUEST_REJECTED=4001;class Pe extends Error{constructor(e,t,s){super(e),this.code=t,this.data=s,Object.setPrototypeOf(this,Pe.prototype)}}Ae.PermissionsError=Pe,Object.defineProperty(be,"__esModule",{value:!0}),be.Wallet=void 0;const Me=U,Oe=Ae;be.Wallet=class{constructor(e){this.communicator=e}async getPermissions(){return(await this.communicator.send(Me.Methods.wallet_getPermissions,void 0)).data}async requestPermissions(e){if(!this.isPermissionRequestValid(e))throw new Oe.PermissionsError("Permissions request is invalid",Oe.PERMISSIONS_REQUEST_REJECTED);try{return(await this.communicator.send(Me.Methods.wallet_requestPermissions,e)).data}catch(e){throw new Oe.PermissionsError("Permissions rejected",Oe.PERMISSIONS_REQUEST_REJECTED)}}isPermissionRequestValid(e){return e.every((e=>"object"==typeof e&&Object.keys(e).every((e=>!!Object.values(Me.RestrictedMethods).includes(e)))))}},Object.defineProperty(Ie,"__esModule",{value:!0});const Ce=be,Re=Ae,Ne=(e,t)=>t.some((t=>t.parentCapability===e));Ie.default=()=>(e,t,s)=>{const a=s.value;return s.value=async function(){const e=new Ce.Wallet(this.communicator);let s=await e.getPermissions();if(Ne(t,s)||(s=await e.requestPermissions([{[t]:{}}])),!Ne(t,s))throw new Re.PermissionsError("Permissions rejected",Re.PERMISSIONS_REQUEST_REJECTED);return a.apply(this)},s};var Le=e&&e.__decorate||function(e,t,s,a){var r,n=arguments.length,i=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,s):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(i=(n<3?r(i):n>3?r(t,s,i):r(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i},De=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(me,"__esModule",{value:!0}),me.Safe=void 0;const je=ve,xe=Te,He=U,Be=ge,ke=$,qe=De(Ie);class Ue{constructor(e){this.communicator=e}async getChainInfo(){return(await this.communicator.send(He.Methods.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(He.Methods.getSafeInfo,void 0)).data}async experimental_getBalances({currency:e="usd"}={}){return(await this.communicator.send(He.Methods.getSafeBalances,{currency:e})).data}async check1271Signature(e,t="0x"){const s=await this.getInfo(),a=xe.EIP_1271_INTERFACE.encodeFunctionData("isValidSignature",[e,t]),r={call:Be.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:a},"latest"]};try{return(await this.communicator.send(He.Methods.rpcCall,r)).data.slice(0,10).toLowerCase()===xe.MAGIC_VALUE}catch(e){return!1}}async check1271SignatureBytes(e,t="0x"){const s=await this.getInfo(),a=je.ethers.utils.arrayify(e),r=xe.EIP_1271_BYTES_INTERFACE.encodeFunctionData("isValidSignature",[a,t]),n={call:Be.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(He.Methods.rpcCall,n)).data.slice(0,10).toLowerCase()===xe.MAGIC_VALUE_BYTES}catch(e){return!1}}calculateMessageHash(e){return je.ethers.utils.hashMessage(e)}calculateTypedMessageHash(e){return je.ethers.utils._TypedDataEncoder.hash(e.domain,e.types,e.message)}async getOffChainSignature(e){return(await this.communicator.send(He.Methods.getOffChainSignature,e)).data}async isMessageSigned(e,t="0x"){let s;if("string"==typeof e&&(s=async()=>{const s=this.calculateMessageHash(e);return await this.isMessageHashSigned(s,t)}),(0,ke.isObjectEIP712TypedData)(e)&&(s=async()=>{const s=this.calculateTypedMessageHash(e);return await this.isMessageHashSigned(s,t)}),s){return await s()}throw new Error("Invalid message type")}async isMessageHashSigned(e,t="0x"){const s=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const a of s){if(await a(e,t))return!0}return!1}async getEnvironmentInfo(){return(await this.communicator.send(He.Methods.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(He.Methods.requestAddressBook,void 0)).data}}Le([(0,qe.default)()],Ue.prototype,"requestAddressBook",null),me.Safe=Ue;var Ge=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(P,"__esModule",{value:!0});const $e=Ge(M),Fe=G,Ve=he,We=me,Ke=be;P.default=class{constructor(e={}){const{allowedDomains:t=null,debug:s=!1}=e;this.communicator=new $e.default(t,s),this.eth=new Ve.Eth(this.communicator),this.txs=new Fe.TXs(this.communicator),this.safe=new We.Safe(this.communicator),this.wallet=new Ke.Wallet(this.communicator)}},function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSDKVersion=void 0;const n=r(P);t.default=n.default,a(P,t),a($,t),a(U,t),a(O,t);var i=C;Object.defineProperty(t,"getSDKVersion",{enumerable:!0,get:function(){return i.getSDKVersion}})}(A);var Qe=s(A),Xe={},Ye={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.getLowerCase=void 0,Je.getLowerCase=function(e){return e?e.toLowerCase():e},Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.SafeAppProvider=void 0;const ze=b,Ze=Je;class et extends ze.EventEmitter{constructor(e,t){super(),this.submittedTxs=new Map,this.safe=e,this.sdk=t}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(e){const{method:t,params:s=[]}=e;switch(t){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(e),"0x"}case"eth_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase()||!t.startsWith("0x"))throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(t),"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[e,t]=s,a="string"==typeof t?JSON.parse(t):t;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase())throw new Error("The address is invalid");return await this.sdk.txs.signTypedMessage(a),"0x"}case"eth_sendTransaction":const t=Object.assign({value:"0",data:"0x"},s[0]);"string"==typeof t.gas&&t.gas.startsWith("0x")&&(t.gas=parseInt(t.gas,16));const a=await this.sdk.txs.send({txs:[t],params:{safeTxGas:t.gas}});return this.submittedTxs.set(a.safeTxHash,{from:this.safe.safeAddress,hash:a.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:t.data,value:t.value,to:t.to,blockHash:null,blockNumber:null,transactionIndex:null}),a.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,Ze.getLowerCase)(s[0]),s[1],s[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([s[0],s[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([s[0],s[1]]);case"eth_getTransactionByHash":let r=s[0];try{r=(await this.sdk.txs.getBySafeTxHash(r)).txHash||r}catch(e){}return this.submittedTxs.has(r)?this.submittedTxs.get(r):this.sdk.eth.getTransactionByHash([r]).then((e=>(e&&(e.hash=s[0]),e)));case"eth_getTransactionReceipt":{let e=s[0];try{e=(await this.sdk.txs.getBySafeTxHash(e)).txHash||e}catch(e){}return this.sdk.eth.getTransactionReceipt([e]).then((e=>(e&&(e.transactionHash=s[0]),e)))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(s[0]);case"eth_call":return this.sdk.eth.call([s[0],s[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([s[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(s[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([s[0]]);default:throw Error(`"${e.method}" not implemented`)}}send(e,t){e||t("Undefined request"),this.request(e).then((s=>t(null,{jsonrpc:"2.0",id:e.id,result:s}))).catch((e=>t(e,null)))}}let tt,st;function at(){return a(this,void 0,void 0,(function*(){return st||(st=new Qe),void 0===tt&&(tt=yield Promise.race([st.safe.getInfo(),new Promise((e=>setTimeout(e,200)))])),tt}))}function rt(){return a(this,void 0,void 0,(function*(){return!!(yield at())}))}function nt(e){return a(this,void 0,void 0,(function*(){const t=yield at();if(!t)throw Error("Could not load Safe information");const s=new Xe.SafeAppProvider(t,st);return s.on("connect",e.connect),s.on("disconnect",e.disconnect),s.on("accountsChanged",e.accountsChanged),s.on("chainChanged",e.chainChanged),s.on("message",e.message),r(s)}))}Ye.SafeAppProvider=et,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppProvider=void 0;var t=Ye;Object.defineProperty(e,"SafeAppProvider",{enumerable:!0,get:function(){return t.SafeAppProvider}})}(Xe);var it={},ot={},dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.getTxServiceBaseUrl=void 0,dt.getTxServiceBaseUrl=function(e){return`${e}/api`};var ct={},ut={exports:{}};!function(t,s){var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();t.exports=s=a.fetch,a.fetch&&(s.default=a.fetch.bind(a)),s.Headers=a.Headers,s.Request=a.Request,s.Response=a.Response}(ut,ut.exports),function(t){var s=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendRequest=t.HttpMethod=void 0;const a=s(ut.exports);var r;(r=t.HttpMethod||(t.HttpMethod={})).Get="get",r.Post="post",r.Delete="delete",t.sendRequest=async function({url:e,method:t,body:s}){const r=await(0,a.default)(e,{method:t,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)});let n;try{n=await r.json()}catch(e){if(!r.ok)throw new Error(r.statusText)}if(r.ok)return n;if(n.data)throw new Error(n.data);if(n.detail)throw new Error(n.detail);if(n.message)throw new Error(n.message);if(n.nonFieldErrors)throw new Error(n.nonFieldErrors);if(n.delegate)throw new Error(n.delegate);if(n.safe)throw new Error(n.safe);if(n.delegator)throw new Error(n.delegator);throw new Error(r.statusText)}}(ct);var lt,ft,ht=e&&e.__classPrivateFieldSet||function(e,t,s,a,r){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?r.call(e,s):r?r.value=s:t.set(e,s),s},gt=e&&e.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(ot,"__esModule",{value:!0});const pt=dt,_t=ct;lt=new WeakMap,ft=new WeakMap,ot.default=class{constructor({txServiceUrl:e,ethAdapter:t}){lt.set(this,void 0),ft.set(this,void 0),ht(this,lt,(0,pt.getTxServiceBaseUrl)(e),"f"),ht(this,ft,t,"f")}async getServiceInfo(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/about`,method:_t.HttpMethod.Get})}async getServiceMasterCopiesInfo(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/about/master-copies`,method:_t.HttpMethod.Get})}async decodeData(e){if(""===e)throw new Error("Invalid data");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/data-decoder/`,method:_t.HttpMethod.Post,body:{data:e}})}async getSafesByOwner(e){if(""===e)throw new Error("Invalid owner address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/owners/${t}/safes/`,method:_t.HttpMethod.Get})}async getSafesByModule(e){if(""===e)throw new Error("Invalid module address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/modules/${t}/safes/`,method:_t.HttpMethod.Get})}async getTransaction(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/`,method:_t.HttpMethod.Get})}async getTransactionConfirmations(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:_t.HttpMethod.Get})}async confirmTransaction(e,t){if(""===e)throw new Error("Invalid safeTxHash");if(""===t)throw new Error("Invalid signature");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:_t.HttpMethod.Post,body:{signature:t}})}async getSafeInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/`,method:_t.HttpMethod.Get})}async getSafeDelegates({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,limit:r,offset:n}){const i=new URL(`${gt(this,lt,"f")}/v1/delegates`);if(e){const{address:t}=await gt(this,ft,"f").getEip3770Address(e);i.searchParams.set("safe",t)}if(t){const{address:e}=await gt(this,ft,"f").getEip3770Address(t);i.searchParams.set("delegate",e)}if(s){const{address:e}=await gt(this,ft,"f").getEip3770Address(s);i.searchParams.set("delegator",e)}return a&&i.searchParams.set("label",a),r&&i.searchParams.set("limit",r),n&&i.searchParams.set("offset",n),(0,_t.sendRequest)({url:i.toString(),method:_t.HttpMethod.Get})}async addSafeDelegate({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,signer:r}){if(""===t)throw new Error("Invalid Safe delegate address");if(""===s)throw new Error("Invalid Safe delegator address");if(""===a)throw new Error("Invalid label");const{address:n}=await gt(this,ft,"f").getEip3770Address(t),{address:i}=await gt(this,ft,"f").getEip3770Address(s),o=n+Math.floor(Date.now()/1e3/3600),d=await r.signMessage(o),c={safe:e?(await gt(this,ft,"f").getEip3770Address(e)).address:null,delegate:n,delegator:i,label:a,signature:d};return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/delegates/`,method:_t.HttpMethod.Post,body:c})}async removeSafeDelegate({delegateAddress:e,delegatorAddress:t,signer:s}){if(""===e)throw new Error("Invalid Safe delegate address");if(""===t)throw new Error("Invalid Safe delegator address");const{address:a}=await gt(this,ft,"f").getEip3770Address(e),{address:r}=await gt(this,ft,"f").getEip3770Address(t),n=a+Math.floor(Date.now()/1e3/3600),i=await s.signMessage(n);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/delegates/${a}`,method:_t.HttpMethod.Delete,body:{delegate:a,delegator:r,signature:i}})}async getSafeCreationInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/creation/`,method:_t.HttpMethod.Get})}async estimateSafeTransaction(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${s}/multisig-transactions/estimations/`,method:_t.HttpMethod.Post,body:t})}async proposeTransaction({safeAddress:e,safeTransactionData:t,safeTxHash:s,senderAddress:a,senderSignature:r,origin:n}){if(""===e)throw new Error("Invalid Safe address");const{address:i}=await gt(this,ft,"f").getEip3770Address(e),{address:o}=await gt(this,ft,"f").getEip3770Address(a);if(""===s)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${i}/multisig-transactions/`,method:_t.HttpMethod.Post,body:{...t,contractTransactionHash:s,sender:o,signature:r,origin:n}})}async getIncomingTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/incoming-transfers?executed=true`,method:_t.HttpMethod.Get})}async getModuleTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/module-transactions/`,method:_t.HttpMethod.Get})}async getMultisigTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/multisig-transactions/`,method:_t.HttpMethod.Get})}async getPendingTransactions(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await gt(this,ft,"f").getEip3770Address(e),a=t||(await this.getSafeInfo(s)).nonce;return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${s}/multisig-transactions/?executed=false&nonce__gte=${a}`,method:_t.HttpMethod.Get})}async getAllTransactions(e,t){var s,a,r;if(""===e)throw new Error("Invalid Safe address");const{address:n}=await gt(this,ft,"f").getEip3770Address(e),i=new URL(`${gt(this,lt,"f")}/v1/safes/${n}/all-transactions/`),o=(null===(s=null==t?void 0:t.trusted)||void 0===s?void 0:s.toString())||"true";i.searchParams.set("trusted",o);const d=(null===(a=null==t?void 0:t.queued)||void 0===a?void 0:a.toString())||"true";i.searchParams.set("queued",d);const c=(null===(r=null==t?void 0:t.executed)||void 0===r?void 0:r.toString())||"false";return i.searchParams.set("executed",c),(0,_t.sendRequest)({url:i.toString(),method:_t.HttpMethod.Get})}async getNextNonce(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e),s=await this.getPendingTransactions(t);if(s.results.length>0){const e=s.results.map((e=>e.nonce));return Math.max(...e)+1}return(await this.getSafeInfo(t)).nonce}async getTokenList(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/tokens/`,method:_t.HttpMethod.Get})}async getToken(e){if(""===e)throw new Error("Invalid token address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/tokens/${t}/`,method:_t.HttpMethod.Get})}};var Et={};Object.defineProperty(Et,"__esModule",{value:!0}),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(ot);a(Et,t),t.default=n.default}(it);var mt=s(it);const vt={1:"https://safe-transaction-mainnet.safe.global/",5:"https://safe-transaction-goerli.safe.global/",42161:"https://safe-transaction-arbitrum.safe.global/",43114:"https://safe-transaction-avalanche.safe.global/",1313161554:"https://safe-transaction-aurora.safe.global/",56:"https://safe-transaction-bsc.safe.global/",10:"https://safe-transaction-optimism.safe.global/",137:"https://safe-transaction-polygon.safe.global/"};let Tt;function yt(e){return a(this,void 0,void 0,(function*(){if((null==Tt?void 0:Tt.chainId)===e)return Tt.safeService;if(!n.getState().provider)throw new Error("provider is undefined");const t=function(){return{getEip3770Address:e=>a(this,void 0,void 0,(function*(){const{address:t,prefix:s}=function(e){const t=e.split(":"),s=t.length>1?t[1]:t[0];return{prefix:t.length>1?t[0]:"",address:s}}(e);return{address:t,prefix:s}}))}}(),s=vt[e];if(!s)return;const r=new mt({txServiceUrl:s,ethAdapter:t});return Tt={safeService:r,chainId:e},Tt.safeService}))}function wt(e,t){return a(this,void 0,void 0,(function*(){if(!t)return!1;const s=yield yt(e);if(!s)return!1;try{return!!(yield s.getSafeInfo(t))}catch(e){return console.error(e),!1}}))}function St(e,t,s){return a(this,void 0,void 0,(function*(){const a=yield yt(e);if(!a)return console.error(`chainId: ${e} is not supported safe`),s;if(s!==t)return s;const r=yield a.getMultisigTransactions(s),[n]=r.results;return n.safeTxHash}))}function It(e,t,s){return a(this,void 0,void 0,(function*(){const a=yield yt(e);if(!a)throw new Error(`chainId: ${e} is not supported safe`);try{const{results:e}=yield a.getMultisigTransactions(s),r=e.find((e=>e.safeTxHash.toLocaleLowerCase()===t.toLocaleLowerCase()));if(!r)return null;if(e.some((e=>!(e.nonce!==r.nonce||e.safeTxHash.toLocaleLowerCase()===t.toLocaleLowerCase()||!e.isExecuted||!e.isSuccessful))))return"rejected";if(null===r.isExecuted||null===r.isSuccessful)return null;return{status:r.isExecuted&&r.isSuccessful||!1,transactionHash:r.transactionHash,blockNumber:r.blockNumber||null}}catch(e){throw console.error(e),new Error(`safeTxHash: ${t} is not valid.`)}}))}function bt(e,t,s){const a={1:"eth",5:"gor",137:"matic",56:"bnb",42161:"arb1",10:"oeth",43114:"avax",1313161554:"aurora"}[t];if(!a)throw new Error(`Not Supported network: ${t}`);return`https://app.safe.global/transactions/tx?id=multisig_${s}_${e}&safe=${a}%3A${s}`}export{nt as default,wt as getAccountIsSafe,at as getConnectedSafe,rt as getIsSafe,bt as getSafeHashDetailUrl,St as getSafeTxHash,It as getSafeTxStatus};
|
|
1
|
+
import{c as e,g as t,b as s,_ as a,d as r,u as n}from"./index-f538e2f0.js";import{b as i}from"./browser-ponyfill-1b463cf8.js";import{e as o,W as d,F as c,l as u,u as l,w as f,v as h,a as g}from"./ethers-2313fc7c.js";import{Signer as p,VoidSigner as _}from"@ethersproject/abstract-signer";import*as E from"@ethersproject/providers";import{getDefaultProvider as m}from"@ethersproject/providers";import{BaseContract as v,Contract as T,ContractFactory as y}from"@ethersproject/contracts";import{B as w,E as S}from"./id-fe4b4d37.js";import*as I from"@ethersproject/constants";import b from"events";import"zustand";import"@ethersproject/address";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";import"@ethersproject/abstract-provider";import"./typed-data-9988323b.js";import"./__node-resolve_empty-7f3920c0.js";import"./hash-a9ebd52a.js";import"./inherits_browser-06ba108b.js";import"@ethersproject/json-wallets";import"./interface-0693e0ec.js";import"./index-91e932a7.js";import"./index-b5e7ed2d.js";var A={},P={},M={},O={},C={},R={name:"@safe-global/safe-apps-sdk",version:"7.10.1",description:"SDK developed to integrate third-party apps with Safe app.",main:"dist/src/index.js",typings:"dist/src/index.d.ts",_files:["dist/**/*","src/**/*","CHANGELOG.md","README.md"],keywords:["Safe","sdk","apps"],scripts:{test:"jest","format-dist":"sed -i '' 's/\"files\":/\"_files\":/' dist/package.json",build:"yarn rimraf dist && tsc && yarn format-dist"},author:"Safe (https://safe.global)",license:"MIT",dependencies:{"@safe-global/safe-gateway-typescript-sdk":"^3.5.3",ethers:"^5.7.2"},devDependencies:{rimraf:"^3.0.2"},repository:{type:"git",url:"git+https://github.com/safe-global/safe-apps-sdk.git"},bugs:{url:"https://github.com/safe-global/safe-apps-sdk/issues"},homepage:"https://github.com/safe-global/safe-apps-sdk#readme",publishConfig:{access:"public"}},N=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0}),C.getSDKVersion=void 0;const L=N(R);C.getSDKVersion=()=>L.default.version.split("-")[0];var D={};Object.defineProperty(D,"__esModule",{value:!0}),D.generateRequestId=void 0;const j=e=>e.toString(16).padStart(2,"0");D.generateRequestId=()=>"undefined"!=typeof window?(e=>{const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,j).join("")})(10):(new Date).getTime().toString(36),Object.defineProperty(O,"__esModule",{value:!0}),O.MessageFormatter=void 0;const x=C,H=D;class B{}O.MessageFormatter=B,B.makeRequest=(e,t)=>({id:(0,H.generateRequestId)(),method:e,params:t,env:{sdkVersion:(0,x.getSDKVersion)()}}),B.makeResponse=(e,t,s)=>({id:e,success:!0,version:s,data:t}),B.makeErrorResponse=(e,t,s)=>({id:e,success:!1,error:t,version:s});var k,q,U={};k=U,Object.defineProperty(k,"__esModule",{value:!0}),k.RestrictedMethods=k.Methods=void 0,(q=k.Methods||(k.Methods={})).sendTransactions="sendTransactions",q.rpcCall="rpcCall",q.getChainInfo="getChainInfo",q.getSafeInfo="getSafeInfo",q.getTxBySafeTxHash="getTxBySafeTxHash",q.getSafeBalances="getSafeBalances",q.signMessage="signMessage",q.signTypedMessage="signTypedMessage",q.getEnvironmentInfo="getEnvironmentInfo",q.getOffChainSignature="getOffChainSignature",q.requestAddressBook="requestAddressBook",q.wallet_getPermissions="wallet_getPermissions",q.wallet_requestPermissions="wallet_requestPermissions",(k.RestrictedMethods||(k.RestrictedMethods={})).requestAddressBook="requestAddressBook",function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0});const r=O;t.default=class{constructor(e=null,t=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer="undefined"==typeof window,this.isValidMessage=({origin:e,data:t,source:s})=>{const a=!t,r=!this.isServer&&s===window.parent,n=(void 0!==t.version&&parseInt(t.version.split(".")[0]))>=1;let i=!0;return Array.isArray(this.allowedOrigins)&&(i=void 0!==this.allowedOrigins.find((t=>t.test(e)))),!a&&r&&n&&i},this.logIncomingMessage=e=>{console.info(`Safe Apps SDK v1: A message was received from origin ${e.origin}. `,e.data)},this.onParentMessage=e=>{this.isValidMessage(e)&&(this.debugMode&&this.logIncomingMessage(e),this.handleIncomingMessage(e.data))},this.handleIncomingMessage=e=>{const{id:t}=e,s=this.callbacks.get(t);s&&(s(e),this.callbacks.delete(t))},this.send=(e,t)=>{const s=r.MessageFormatter.makeRequest(e,t);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(s,"*"),new Promise(((e,t)=>{this.callbacks.set(s.id,(s=>{s.success?e(s):t(new Error(s.error))}))}))},this.allowedOrigins=e,this.debugMode=t,this.isServer||window.addEventListener("message",this.onParentMessage)}},a(U,t)}(M);var G={},$={},F={};Object.defineProperty(F,"__esModule",{value:!0}),F.isObjectEIP712TypedData=void 0;F.isObjectEIP712TypedData=e=>"object"==typeof e&&null!=e&&"domain"in e&&"types"in e&&"message"in e;var V={};Object.defineProperty(V,"__esModule",{value:!0});var W={},K={},Q={},X={},Y=e&&e.__awaiter||function(e,t,s,a){return new(s||(s=Promise))((function(r,n){function i(e){try{d(a.next(e))}catch(e){n(e)}}function o(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(i,o)}d((a=a.apply(e,t||[])).next())}))},J=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(X,"__esModule",{value:!0}),X.fetchData=X.stringifyQuery=X.insertParams=void 0;const z=J(i.exports);X.insertParams=function(e,t){return t?Object.keys(t).reduce(((e,s)=>function(e,t,s){return e.replace(new RegExp(`\\{${t}\\}`,"g"),s)}(e,s,String(t[s]))),e):e},X.stringifyQuery=function(e){if(!e)return"";const t=new URLSearchParams;Object.keys(e).forEach((s=>{null!=e[s]&&t.append(s,String(e[s]))}));const s=t.toString();return s?`?${s}`:""},X.fetchData=function(e,t){return Y(this,void 0,void 0,(function*(){let s;null!=t&&(s={method:"POST",body:"string"==typeof t?t:JSON.stringify(t),headers:{"Content-Type":"application/json"}});const a=yield(0,z.default)(e,s);let r;try{r=yield a.json()}catch(e){if(a.headers&&"0"!==a.headers.get("content-length"))throw new Error(`Invalid response content: ${a.statusText}`)}if(!a.ok){const e="object"==typeof(n=r)&&null!==n&&"code"in n&&"message"in n?`${r.code}: ${r.message}`:a.statusText;throw new Error(e)}var n;return r}))},Object.defineProperty(Q,"__esModule",{value:!0}),Q.getEndpoint=Q.postEndpoint=void 0;const Z=X;function ee(e,t,s,a){return`${e}${(0,Z.insertParams)(t,s)}${(0,Z.stringifyQuery)(a)}`}Q.postEndpoint=function(e,t,s){const a=ee(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,Z.fetchData)(a,null==s?void 0:s.body)},Q.getEndpoint=function(e,t,s,a){if(a)return(0,Z.fetchData)(a);const r=ee(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,Z.fetchData)(r)};var te={};Object.defineProperty(te,"__esModule",{value:!0}),te.DEFAULT_BASE_URL=void 0,te.DEFAULT_BASE_URL="https://safe-client.safe.global";var se={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ImplementationVersionState=void 0,(t=e.ImplementationVersionState||(e.ImplementationVersionState={})).UP_TO_DATE="UP_TO_DATE",t.OUTDATED="OUTDATED",t.UNKNOWN="UNKNOWN"}(se);var ae={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppSocialPlatforms=e.SafeAppFeatures=e.SafeAppAccessPolicyTypes=void 0,(t=e.SafeAppAccessPolicyTypes||(e.SafeAppAccessPolicyTypes={})).NoRestrictions="NO_RESTRICTIONS",t.DomainAllowlist="DOMAIN_ALLOWLIST",(e.SafeAppFeatures||(e.SafeAppFeatures={})).BATCHED_TRANSACTIONS="BATCHED_TRANSACTIONS",(s=e.SafeAppSocialPlatforms||(e.SafeAppSocialPlatforms={})).TWITTER="TWITTER",s.GITHUB="GITHUB",s.DISCORD="DISCORD"}(ae);var re={};!function(e){var t,s,a,r,n,i,o,d,c,u;Object.defineProperty(e,"__esModule",{value:!0}),e.LabelValue=e.DetailedExecutionInfoType=e.TransactionListItemType=e.ConflictType=e.TransactionInfoType=e.SettingsInfoType=e.TransactionTokenType=e.TransferDirection=e.TransactionStatus=e.Operation=void 0,(t=e.Operation||(e.Operation={}))[t.CALL=0]="CALL",t[t.DELEGATE=1]="DELEGATE",(s=e.TransactionStatus||(e.TransactionStatus={})).AWAITING_CONFIRMATIONS="AWAITING_CONFIRMATIONS",s.AWAITING_EXECUTION="AWAITING_EXECUTION",s.CANCELLED="CANCELLED",s.FAILED="FAILED",s.SUCCESS="SUCCESS",(a=e.TransferDirection||(e.TransferDirection={})).INCOMING="INCOMING",a.OUTGOING="OUTGOING",a.UNKNOWN="UNKNOWN",(r=e.TransactionTokenType||(e.TransactionTokenType={})).ERC20="ERC20",r.ERC721="ERC721",r.NATIVE_COIN="NATIVE_COIN",(n=e.SettingsInfoType||(e.SettingsInfoType={})).SET_FALLBACK_HANDLER="SET_FALLBACK_HANDLER",n.ADD_OWNER="ADD_OWNER",n.REMOVE_OWNER="REMOVE_OWNER",n.SWAP_OWNER="SWAP_OWNER",n.CHANGE_THRESHOLD="CHANGE_THRESHOLD",n.CHANGE_IMPLEMENTATION="CHANGE_IMPLEMENTATION",n.ENABLE_MODULE="ENABLE_MODULE",n.DISABLE_MODULE="DISABLE_MODULE",n.SET_GUARD="SET_GUARD",n.DELETE_GUARD="DELETE_GUARD",(i=e.TransactionInfoType||(e.TransactionInfoType={})).TRANSFER="Transfer",i.SETTINGS_CHANGE="SettingsChange",i.CUSTOM="Custom",i.CREATION="Creation",(o=e.ConflictType||(e.ConflictType={})).NONE="None",o.HAS_NEXT="HasNext",o.END="End",(d=e.TransactionListItemType||(e.TransactionListItemType={})).TRANSACTION="TRANSACTION",d.LABEL="LABEL",d.CONFLICT_HEADER="CONFLICT_HEADER",d.DATE_LABEL="DATE_LABEL",(c=e.DetailedExecutionInfoType||(e.DetailedExecutionInfoType={})).MULTISIG="MULTISIG",c.MODULE="MODULE",(u=e.LabelValue||(e.LabelValue={})).Queued="Queued",u.Next="Next"}(re);var ne={};!function(e){var t,s,a;Object.defineProperty(e,"__esModule",{value:!0}),e.FEATURES=e.GAS_PRICE_TYPE=e.RPC_AUTHENTICATION=void 0,(t=e.RPC_AUTHENTICATION||(e.RPC_AUTHENTICATION={})).API_KEY_PATH="API_KEY_PATH",t.NO_AUTHENTICATION="NO_AUTHENTICATION",t.UNKNOWN="UNKNOWN",(s=e.GAS_PRICE_TYPE||(e.GAS_PRICE_TYPE={})).ORACLE="ORACLE",s.FIXED="FIXED",s.UNKNOWN="UNKNOWN",(a=e.FEATURES||(e.FEATURES={})).ERC721="ERC721",a.SAFE_APPS="SAFE_APPS",a.CONTRACT_INTERACTION="CONTRACT_INTERACTION",a.DOMAIN_LOOKUP="DOMAIN_LOOKUP",a.SPENDING_LIMIT="SPENDING_LIMIT",a.EIP1559="EIP1559",a.SAFE_TX_GAS_OPTIONAL="SAFE_TX_GAS_OPTIONAL",a.TX_SIMULATION="TX_SIMULATION",a.EIP1271="EIP1271"}(ne);var ie={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.TokenType=void 0,(t=e.TokenType||(e.TokenType={})).ERC20="ERC20",t.ERC721="ERC721",t.NATIVE_TOKEN="NATIVE_TOKEN"}(ie);var oe={};Object.defineProperty(oe,"__esModule",{value:!0});var de={};Object.defineProperty(de,"__esModule",{value:!0});var ce={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeMessageStatus=e.SafeMessageListItemType=void 0,(t=e.SafeMessageListItemType||(e.SafeMessageListItemType={})).DATE_LABEL="DATE_LABEL",t.MESSAGE="MESSAGE",(s=e.SafeMessageStatus||(e.SafeMessageStatus={})).NEEDS_CONFIRMATION="NEEDS_CONFIRMATION",s.CONFIRMED="CONFIRMED"}(ce),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.confirmSafeMessage=t.proposeSafeMessage=t.getSafeMessage=t.getSafeMessages=t.getDecodedData=t.getMasterCopies=t.getSafeApps=t.getChainConfig=t.getChainsConfig=t.proposeTransaction=t.postSafeGasEstimation=t.getTransactionDetails=t.getTransactionQueue=t.getTransactionHistory=t.getCollectiblesPage=t.getCollectibles=t.getOwnedSafes=t.getFiatCurrencies=t.getBalances=t.getMultisigTransactions=t.getModuleTransactions=t.getIncomingTransfers=t.getSafeInfo=t.setBaseUrl=void 0;const r=Q,n=te;a(se,t),a(ae,t),a(re,t),a(ne,t),a(ie,t),a(oe,t),a(de,t),a(ce,t);let i=n.DEFAULT_BASE_URL;t.setBaseUrl=e=>{i=e},t.getSafeInfo=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}",{path:{chainId:e,address:t}})},t.getIncomingTransfers=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/incoming-transfers/",{path:{chainId:e,address:t},query:s},a)},t.getModuleTransactions=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/module-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getMultisigTransactions=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/multisig-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getBalances=function(e,t,s="usd",a={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/balances/{currency}",{path:{chainId:e,address:t,currency:s},query:a})},t.getFiatCurrencies=function(){return(0,r.getEndpoint)(i,"/v1/balances/supported-fiat-codes")},t.getOwnedSafes=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/owners/{address}/safes",{path:{chainId:e,address:t}})},t.getCollectibles=function(e,t,s={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s})},t.getCollectiblesPage=function(e,t,s={},a){return(0,r.getEndpoint)(i,"/v2/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s},a)},t.getTransactionHistory=function(e,t,s){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/history",{path:{chainId:e,safe_address:t},query:{}},s)},t.getTransactionQueue=function(e,t,s,a){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/queued",{path:{chainId:e,safe_address:t},query:{trusted:a}},s)},t.getTransactionDetails=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/transactions/{transactionId}",{path:{chainId:e,transactionId:t}})},t.postSafeGasEstimation=function(e,t,s){return(0,r.postEndpoint)(i,"/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations",{path:{chainId:e,safe_address:t},body:s})},t.proposeTransaction=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/transactions/{safe_address}/propose",{path:{chainId:e,safe_address:t},body:s})},t.getChainsConfig=function(e){return(0,r.getEndpoint)(i,"/v1/chains",{query:e})},t.getChainConfig=function(e){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}",{path:{chainId:e}})},t.getSafeApps=function(e,t={}){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safe-apps",{path:{chainId:e},query:t})},t.getMasterCopies=function(e){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/about/master-copies",{path:{chainId:e}})},t.getDecodedData=function(e,t){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/data-decoder",{path:{chainId:e},body:{data:t}})},t.getSafeMessages=function(e,t,s){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},query:{}},s)},t.getSafeMessage=function(e,t){return(0,r.getEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}",{path:{chainId:e,message_hash:t}})},t.proposeSafeMessage=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},body:s})},t.confirmSafeMessage=function(e,t,s){return(0,r.postEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}/signatures",{path:{chainId:e,message_hash:t},body:s})}}(K),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TransferDirection=e.TransactionStatus=e.TokenType=e.Operation=void 0;var t=K;Object.defineProperty(e,"Operation",{enumerable:!0,get:function(){return t.Operation}}),Object.defineProperty(e,"TokenType",{enumerable:!0,get:function(){return t.TokenType}}),Object.defineProperty(e,"TransactionStatus",{enumerable:!0,get:function(){return t.TransactionStatus}}),Object.defineProperty(e,"TransferDirection",{enumerable:!0,get:function(){return t.TransferDirection}})}(W);var ue={};Object.defineProperty(ue,"__esModule",{value:!0}),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),a(F,t),a(V,t),a(W,t),a(ue,t)}($),Object.defineProperty(G,"__esModule",{value:!0}),G.TXs=void 0;const le=U,fe=$;G.TXs=class{constructor(e){this.communicator=e}async getBySafeTxHash(e){if(!e)throw new Error("Invalid safeTxHash");return(await this.communicator.send(le.Methods.getTxBySafeTxHash,{safeTxHash:e})).data}async signMessage(e){const t={message:e};return(await this.communicator.send(le.Methods.signMessage,t)).data}async signTypedMessage(e){if(!(0,fe.isObjectEIP712TypedData)(e))throw new Error("Invalid typed data");return(await this.communicator.send(le.Methods.signTypedMessage,{typedData:e})).data}async send({txs:e,params:t}){if(!e||!e.length)throw new Error("No transactions were passed");const s={txs:e,params:t};return(await this.communicator.send(le.Methods.sendTransactions,s)).data}};var he={},ge={};Object.defineProperty(ge,"__esModule",{value:!0}),ge.RPC_CALLS=void 0,ge.RPC_CALLS={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},Object.defineProperty(he,"__esModule",{value:!0}),he.Eth=void 0;const pe=ge,_e=U,Ee={defaultBlockParam:(e="latest")=>e,returnFullTxObjectParam:(e=!1)=>e,blockNumberToHex:e=>Number.isInteger(e)?`0x${e.toString(16)}`:e};he.Eth=class{constructor(e){this.communicator=e,this.call=this.buildRequest({call:pe.RPC_CALLS.eth_call,formatters:[null,Ee.defaultBlockParam]}),this.getBalance=this.buildRequest({call:pe.RPC_CALLS.eth_getBalance,formatters:[null,Ee.defaultBlockParam]}),this.getCode=this.buildRequest({call:pe.RPC_CALLS.eth_getCode,formatters:[null,Ee.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:pe.RPC_CALLS.eth_getStorageAt,formatters:[null,Ee.blockNumberToHex,Ee.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:pe.RPC_CALLS.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:pe.RPC_CALLS.eth_getBlockByHash,formatters:[null,Ee.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:pe.RPC_CALLS.eth_getBlockByNumber,formatters:[Ee.blockNumberToHex,Ee.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:pe.RPC_CALLS.eth_getTransactionCount,formatters:[null,Ee.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:pe.RPC_CALLS.eth_gasPrice}),this.getEstimateGas=e=>this.buildRequest({call:pe.RPC_CALLS.eth_estimateGas})([e]),this.setSafeSettings=this.buildRequest({call:pe.RPC_CALLS.safe_setSettings})}buildRequest(e){const{call:t,formatters:s}=e;return async e=>{s&&Array.isArray(e)&&s.forEach(((t,s)=>{t&&(e[s]=t(e[s]))}));const a={call:t,params:e||[]};return(await this.communicator.send(_e.Methods.rpcCall,a)).data}}};var me={};try{const e=window;null==e._ethers&&(e._ethers=o)}catch(e){}var ve=t(Object.freeze({__proto__:null,ethers:o,Signer:p,Wallet:d,VoidSigner:_,getDefaultProvider:m,providers:E,BaseContract:v,Contract:T,ContractFactory:y,BigNumber:w,FixedNumber:c,constants:I,get errors(){return S},logger:u,utils:l,wordlists:f,version:h,Wordlist:g})),Te={};Object.defineProperty(Te,"__esModule",{value:!0}),Te.MAGIC_VALUE_BYTES=Te.MAGIC_VALUE=Te.EIP_1271_BYTES_INTERFACE=Te.EIP_1271_INTERFACE=void 0;const ye=ve;Te.MAGIC_VALUE="0x1626ba7e";Te.MAGIC_VALUE_BYTES="0x20c13b0b";const we=new ye.ethers.utils.Interface(["function isValidSignature(bytes32 _dataHash, bytes calldata _signature) external view"]);Te.EIP_1271_INTERFACE=we;const Se=new ye.ethers.utils.Interface(["function isValidSignature(bytes calldata _data, bytes calldata _signature) public view"]);Te.EIP_1271_BYTES_INTERFACE=Se;var Ie={},be={},Ae={};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.PermissionsError=Ae.PERMISSIONS_REQUEST_REJECTED=void 0,Ae.PERMISSIONS_REQUEST_REJECTED=4001;class Pe extends Error{constructor(e,t,s){super(e),this.code=t,this.data=s,Object.setPrototypeOf(this,Pe.prototype)}}Ae.PermissionsError=Pe,Object.defineProperty(be,"__esModule",{value:!0}),be.Wallet=void 0;const Me=U,Oe=Ae;be.Wallet=class{constructor(e){this.communicator=e}async getPermissions(){return(await this.communicator.send(Me.Methods.wallet_getPermissions,void 0)).data}async requestPermissions(e){if(!this.isPermissionRequestValid(e))throw new Oe.PermissionsError("Permissions request is invalid",Oe.PERMISSIONS_REQUEST_REJECTED);try{return(await this.communicator.send(Me.Methods.wallet_requestPermissions,e)).data}catch(e){throw new Oe.PermissionsError("Permissions rejected",Oe.PERMISSIONS_REQUEST_REJECTED)}}isPermissionRequestValid(e){return e.every((e=>"object"==typeof e&&Object.keys(e).every((e=>!!Object.values(Me.RestrictedMethods).includes(e)))))}},Object.defineProperty(Ie,"__esModule",{value:!0});const Ce=be,Re=Ae,Ne=(e,t)=>t.some((t=>t.parentCapability===e));Ie.default=()=>(e,t,s)=>{const a=s.value;return s.value=async function(){const e=new Ce.Wallet(this.communicator);let s=await e.getPermissions();if(Ne(t,s)||(s=await e.requestPermissions([{[t]:{}}])),!Ne(t,s))throw new Re.PermissionsError("Permissions rejected",Re.PERMISSIONS_REQUEST_REJECTED);return a.apply(this)},s};var Le=e&&e.__decorate||function(e,t,s,a){var r,n=arguments.length,i=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,s):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(i=(n<3?r(i):n>3?r(t,s,i):r(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i},De=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(me,"__esModule",{value:!0}),me.Safe=void 0;const je=ve,xe=Te,He=U,Be=ge,ke=$,qe=De(Ie);class Ue{constructor(e){this.communicator=e}async getChainInfo(){return(await this.communicator.send(He.Methods.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(He.Methods.getSafeInfo,void 0)).data}async experimental_getBalances({currency:e="usd"}={}){return(await this.communicator.send(He.Methods.getSafeBalances,{currency:e})).data}async check1271Signature(e,t="0x"){const s=await this.getInfo(),a=xe.EIP_1271_INTERFACE.encodeFunctionData("isValidSignature",[e,t]),r={call:Be.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:a},"latest"]};try{return(await this.communicator.send(He.Methods.rpcCall,r)).data.slice(0,10).toLowerCase()===xe.MAGIC_VALUE}catch(e){return!1}}async check1271SignatureBytes(e,t="0x"){const s=await this.getInfo(),a=je.ethers.utils.arrayify(e),r=xe.EIP_1271_BYTES_INTERFACE.encodeFunctionData("isValidSignature",[a,t]),n={call:Be.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(He.Methods.rpcCall,n)).data.slice(0,10).toLowerCase()===xe.MAGIC_VALUE_BYTES}catch(e){return!1}}calculateMessageHash(e){return je.ethers.utils.hashMessage(e)}calculateTypedMessageHash(e){return je.ethers.utils._TypedDataEncoder.hash(e.domain,e.types,e.message)}async getOffChainSignature(e){return(await this.communicator.send(He.Methods.getOffChainSignature,e)).data}async isMessageSigned(e,t="0x"){let s;if("string"==typeof e&&(s=async()=>{const s=this.calculateMessageHash(e);return await this.isMessageHashSigned(s,t)}),(0,ke.isObjectEIP712TypedData)(e)&&(s=async()=>{const s=this.calculateTypedMessageHash(e);return await this.isMessageHashSigned(s,t)}),s){return await s()}throw new Error("Invalid message type")}async isMessageHashSigned(e,t="0x"){const s=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const a of s){if(await a(e,t))return!0}return!1}async getEnvironmentInfo(){return(await this.communicator.send(He.Methods.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(He.Methods.requestAddressBook,void 0)).data}}Le([(0,qe.default)()],Ue.prototype,"requestAddressBook",null),me.Safe=Ue;var Ge=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(P,"__esModule",{value:!0});const $e=Ge(M),Fe=G,Ve=he,We=me,Ke=be;P.default=class{constructor(e={}){const{allowedDomains:t=null,debug:s=!1}=e;this.communicator=new $e.default(t,s),this.eth=new Ve.Eth(this.communicator),this.txs=new Fe.TXs(this.communicator),this.safe=new We.Safe(this.communicator),this.wallet=new Ke.Wallet(this.communicator)}},function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSDKVersion=void 0;const n=r(P);t.default=n.default,a(P,t),a($,t),a(U,t),a(O,t);var i=C;Object.defineProperty(t,"getSDKVersion",{enumerable:!0,get:function(){return i.getSDKVersion}})}(A);var Qe=s(A),Xe={},Ye={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.getLowerCase=void 0,Je.getLowerCase=function(e){return e?e.toLowerCase():e},Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.SafeAppProvider=void 0;const ze=b,Ze=Je;class et extends ze.EventEmitter{constructor(e,t){super(),this.submittedTxs=new Map,this.safe=e,this.sdk=t}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(e){const{method:t,params:s=[]}=e;switch(t){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(e),"0x"}case"eth_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase()||!t.startsWith("0x"))throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(t),"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[e,t]=s,a="string"==typeof t?JSON.parse(t):t;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase())throw new Error("The address is invalid");return await this.sdk.txs.signTypedMessage(a),"0x"}case"eth_sendTransaction":const t=Object.assign({value:"0",data:"0x"},s[0]);"string"==typeof t.gas&&t.gas.startsWith("0x")&&(t.gas=parseInt(t.gas,16));const a=await this.sdk.txs.send({txs:[t],params:{safeTxGas:t.gas}});return this.submittedTxs.set(a.safeTxHash,{from:this.safe.safeAddress,hash:a.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:t.data,value:t.value,to:t.to,blockHash:null,blockNumber:null,transactionIndex:null}),a.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,Ze.getLowerCase)(s[0]),s[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,Ze.getLowerCase)(s[0]),s[1],s[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([s[0],s[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([s[0],s[1]]);case"eth_getTransactionByHash":let r=s[0];try{r=(await this.sdk.txs.getBySafeTxHash(r)).txHash||r}catch(e){}return this.submittedTxs.has(r)?this.submittedTxs.get(r):this.sdk.eth.getTransactionByHash([r]).then((e=>(e&&(e.hash=s[0]),e)));case"eth_getTransactionReceipt":{let e=s[0];try{e=(await this.sdk.txs.getBySafeTxHash(e)).txHash||e}catch(e){}return this.sdk.eth.getTransactionReceipt([e]).then((e=>(e&&(e.transactionHash=s[0]),e)))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(s[0]);case"eth_call":return this.sdk.eth.call([s[0],s[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([s[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(s[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([s[0]]);default:throw Error(`"${e.method}" not implemented`)}}send(e,t){e||t("Undefined request"),this.request(e).then((s=>t(null,{jsonrpc:"2.0",id:e.id,result:s}))).catch((e=>t(e,null)))}}let tt,st;function at(){return a(this,void 0,void 0,(function*(){return st||(st=new Qe),void 0===tt&&(tt=yield Promise.race([st.safe.getInfo(),new Promise((e=>setTimeout(e,200)))])),tt}))}function rt(){return a(this,void 0,void 0,(function*(){return!!(yield at())}))}function nt(e){return a(this,void 0,void 0,(function*(){const t=yield at();if(!t)throw Error("Could not load Safe information");const s=new Xe.SafeAppProvider(t,st);return s.on("connect",e.connect),s.on("disconnect",e.disconnect),s.on("accountsChanged",e.accountsChanged),s.on("chainChanged",e.chainChanged),s.on("message",e.message),r(s)}))}Ye.SafeAppProvider=et,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppProvider=void 0;var t=Ye;Object.defineProperty(e,"SafeAppProvider",{enumerable:!0,get:function(){return t.SafeAppProvider}})}(Xe);var it={},ot={},dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.getTxServiceBaseUrl=void 0,dt.getTxServiceBaseUrl=function(e){return`${e}/api`};var ct={},ut={exports:{}};!function(t,s){var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();t.exports=s=a.fetch,a.fetch&&(s.default=a.fetch.bind(a)),s.Headers=a.Headers,s.Request=a.Request,s.Response=a.Response}(ut,ut.exports),function(t){var s=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendRequest=t.HttpMethod=void 0;const a=s(ut.exports);var r;(r=t.HttpMethod||(t.HttpMethod={})).Get="get",r.Post="post",r.Delete="delete",t.sendRequest=async function({url:e,method:t,body:s}){const r=await(0,a.default)(e,{method:t,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)});let n;try{n=await r.json()}catch(e){if(!r.ok)throw new Error(r.statusText)}if(r.ok)return n;if(n.data)throw new Error(n.data);if(n.detail)throw new Error(n.detail);if(n.message)throw new Error(n.message);if(n.nonFieldErrors)throw new Error(n.nonFieldErrors);if(n.delegate)throw new Error(n.delegate);if(n.safe)throw new Error(n.safe);if(n.delegator)throw new Error(n.delegator);throw new Error(r.statusText)}}(ct);var lt,ft,ht=e&&e.__classPrivateFieldSet||function(e,t,s,a,r){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?r.call(e,s):r?r.value=s:t.set(e,s),s},gt=e&&e.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(ot,"__esModule",{value:!0});const pt=dt,_t=ct;lt=new WeakMap,ft=new WeakMap,ot.default=class{constructor({txServiceUrl:e,ethAdapter:t}){lt.set(this,void 0),ft.set(this,void 0),ht(this,lt,(0,pt.getTxServiceBaseUrl)(e),"f"),ht(this,ft,t,"f")}async getServiceInfo(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/about`,method:_t.HttpMethod.Get})}async getServiceMasterCopiesInfo(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/about/master-copies`,method:_t.HttpMethod.Get})}async decodeData(e){if(""===e)throw new Error("Invalid data");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/data-decoder/`,method:_t.HttpMethod.Post,body:{data:e}})}async getSafesByOwner(e){if(""===e)throw new Error("Invalid owner address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/owners/${t}/safes/`,method:_t.HttpMethod.Get})}async getSafesByModule(e){if(""===e)throw new Error("Invalid module address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/modules/${t}/safes/`,method:_t.HttpMethod.Get})}async getTransaction(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/`,method:_t.HttpMethod.Get})}async getTransactionConfirmations(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:_t.HttpMethod.Get})}async confirmTransaction(e,t){if(""===e)throw new Error("Invalid safeTxHash");if(""===t)throw new Error("Invalid signature");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:_t.HttpMethod.Post,body:{signature:t}})}async getSafeInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/`,method:_t.HttpMethod.Get})}async getSafeDelegates({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,limit:r,offset:n}){const i=new URL(`${gt(this,lt,"f")}/v1/delegates`);if(e){const{address:t}=await gt(this,ft,"f").getEip3770Address(e);i.searchParams.set("safe",t)}if(t){const{address:e}=await gt(this,ft,"f").getEip3770Address(t);i.searchParams.set("delegate",e)}if(s){const{address:e}=await gt(this,ft,"f").getEip3770Address(s);i.searchParams.set("delegator",e)}return a&&i.searchParams.set("label",a),r&&i.searchParams.set("limit",r),n&&i.searchParams.set("offset",n),(0,_t.sendRequest)({url:i.toString(),method:_t.HttpMethod.Get})}async addSafeDelegate({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,signer:r}){if(""===t)throw new Error("Invalid Safe delegate address");if(""===s)throw new Error("Invalid Safe delegator address");if(""===a)throw new Error("Invalid label");const{address:n}=await gt(this,ft,"f").getEip3770Address(t),{address:i}=await gt(this,ft,"f").getEip3770Address(s),o=n+Math.floor(Date.now()/1e3/3600),d=await r.signMessage(o),c={safe:e?(await gt(this,ft,"f").getEip3770Address(e)).address:null,delegate:n,delegator:i,label:a,signature:d};return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/delegates/`,method:_t.HttpMethod.Post,body:c})}async removeSafeDelegate({delegateAddress:e,delegatorAddress:t,signer:s}){if(""===e)throw new Error("Invalid Safe delegate address");if(""===t)throw new Error("Invalid Safe delegator address");const{address:a}=await gt(this,ft,"f").getEip3770Address(e),{address:r}=await gt(this,ft,"f").getEip3770Address(t),n=a+Math.floor(Date.now()/1e3/3600),i=await s.signMessage(n);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/delegates/${a}`,method:_t.HttpMethod.Delete,body:{delegate:a,delegator:r,signature:i}})}async getSafeCreationInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/creation/`,method:_t.HttpMethod.Get})}async estimateSafeTransaction(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${s}/multisig-transactions/estimations/`,method:_t.HttpMethod.Post,body:t})}async proposeTransaction({safeAddress:e,safeTransactionData:t,safeTxHash:s,senderAddress:a,senderSignature:r,origin:n}){if(""===e)throw new Error("Invalid Safe address");const{address:i}=await gt(this,ft,"f").getEip3770Address(e),{address:o}=await gt(this,ft,"f").getEip3770Address(a);if(""===s)throw new Error("Invalid safeTxHash");return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${i}/multisig-transactions/`,method:_t.HttpMethod.Post,body:{...t,contractTransactionHash:s,sender:o,signature:r,origin:n}})}async getIncomingTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/incoming-transfers?executed=true`,method:_t.HttpMethod.Get})}async getModuleTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/module-transactions/`,method:_t.HttpMethod.Get})}async getMultisigTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${t}/multisig-transactions/`,method:_t.HttpMethod.Get})}async getPendingTransactions(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await gt(this,ft,"f").getEip3770Address(e),a=t||(await this.getSafeInfo(s)).nonce;return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/safes/${s}/multisig-transactions/?executed=false&nonce__gte=${a}`,method:_t.HttpMethod.Get})}async getAllTransactions(e,t){var s,a,r;if(""===e)throw new Error("Invalid Safe address");const{address:n}=await gt(this,ft,"f").getEip3770Address(e),i=new URL(`${gt(this,lt,"f")}/v1/safes/${n}/all-transactions/`),o=(null===(s=null==t?void 0:t.trusted)||void 0===s?void 0:s.toString())||"true";i.searchParams.set("trusted",o);const d=(null===(a=null==t?void 0:t.queued)||void 0===a?void 0:a.toString())||"true";i.searchParams.set("queued",d);const c=(null===(r=null==t?void 0:t.executed)||void 0===r?void 0:r.toString())||"false";return i.searchParams.set("executed",c),(0,_t.sendRequest)({url:i.toString(),method:_t.HttpMethod.Get})}async getNextNonce(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e),s=await this.getPendingTransactions(t);if(s.results.length>0){const e=s.results.map((e=>e.nonce));return Math.max(...e)+1}return(await this.getSafeInfo(t)).nonce}async getTokenList(){return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/tokens/`,method:_t.HttpMethod.Get})}async getToken(e){if(""===e)throw new Error("Invalid token address");const{address:t}=await gt(this,ft,"f").getEip3770Address(e);return(0,_t.sendRequest)({url:`${gt(this,lt,"f")}/v1/tokens/${t}/`,method:_t.HttpMethod.Get})}};var Et={};Object.defineProperty(Et,"__esModule",{value:!0}),function(t){var s=e&&e.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e&&e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(ot);a(Et,t),t.default=n.default}(it);var mt=s(it);const vt={1:"https://safe-transaction-mainnet.safe.global/",5:"https://safe-transaction-goerli.safe.global/",42161:"https://safe-transaction-arbitrum.safe.global/",43114:"https://safe-transaction-avalanche.safe.global/",1313161554:"https://safe-transaction-aurora.safe.global/",56:"https://safe-transaction-bsc.safe.global/",10:"https://safe-transaction-optimism.safe.global/",137:"https://safe-transaction-polygon.safe.global/"};let Tt;function yt(e){return a(this,void 0,void 0,(function*(){if((null==Tt?void 0:Tt.chainId)===e)return Tt.safeService;if(!n.getState().provider)throw new Error("provider is undefined");const t=function(){return{getEip3770Address:e=>a(this,void 0,void 0,(function*(){const{address:t,prefix:s}=function(e){const t=e.split(":"),s=t.length>1?t[1]:t[0];return{prefix:t.length>1?t[0]:"",address:s}}(e);return{address:t,prefix:s}}))}}(),s=vt[e];if(!s)return;const r=new mt({txServiceUrl:s,ethAdapter:t});return Tt={safeService:r,chainId:e},Tt.safeService}))}function wt(e,t){return a(this,void 0,void 0,(function*(){if(!t)return!1;const s=yield yt(e);if(!s)return!1;try{return!!(yield s.getSafeInfo(t))}catch(e){return console.error(e),!1}}))}function St(e,t,s){return a(this,void 0,void 0,(function*(){const a=yield yt(e);if(!a)return console.error(`chainId: ${e} is not supported safe`),s;if(s!==t)return s;const r=yield a.getMultisigTransactions(s),[n]=r.results;return n.safeTxHash}))}function It(e,t,s){return a(this,void 0,void 0,(function*(){const a=yield yt(e);if(!a)throw new Error(`chainId: ${e} is not supported safe`);try{const{results:e}=yield a.getMultisigTransactions(s),r=e.find((e=>e.safeTxHash.toLocaleLowerCase()===t.toLocaleLowerCase()));if(!r)return null;if(e.some((e=>!(e.nonce!==r.nonce||e.safeTxHash.toLocaleLowerCase()===t.toLocaleLowerCase()||!e.isExecuted||!e.isSuccessful))))return"rejected";if(null===r.isExecuted||null===r.isSuccessful)return null;return{status:r.isExecuted&&r.isSuccessful||!1,transactionHash:r.transactionHash,blockNumber:r.blockNumber||null}}catch(e){throw console.error(e),new Error(`safeTxHash: ${t} is not valid.`)}}))}function bt(e,t,s){const a={1:"eth",5:"gor",137:"matic",56:"bnb",42161:"arb1",10:"oeth",43114:"avax",1313161554:"aurora"}[t];if(!a)throw new Error(`Not Supported network: ${t}`);return`https://app.safe.global/transactions/tx?id=multisig_${s}_${e}&safe=${a}%3A${s}`}export{nt as default,wt as getAccountIsSafe,at as getConnectedSafe,rt as getIsSafe,bt as getSafeHashDetailUrl,St as getSafeTxHash,It as getSafeTxStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as a}from"./index-f538e2f0.js";import{C as e,E as r,a as s,F as t,b as o,P as n,c,A as i,d as m,I as f,f as p,e as F,L as d,T as g}from"./interface-0693e0ec.js";var u=a(Object.freeze({__proto__:null,ConstructorFragment:e,ErrorFragment:r,EventFragment:s,Fragment:t,FunctionFragment:o,ParamType:n,FormatTypes:c,AbiCoder:i,defaultAbiCoder:m,Interface:f,Indexed:p,checkResultErrors:F,LogDescription:d,TransactionDescription:g}));export{u as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,l as r,m as t,n as o,E as n,o as s,p as i,u as d}from"./index-
|
|
1
|
+
import{_ as e,l as r,m as t,n as o,E as n,o as s,p as i,u as d}from"./index-f538e2f0.js";export{q as getIsCyber}from"./index-f538e2f0.js";import{JsonRpcProvider as a}from"@ethersproject/providers";import{getAddress as c}from"@ethersproject/address";import"events";import{hexlify as h}from"@ethersproject/bytes";import{t as p}from"./id-fe4b4d37.js";import{T as u}from"./typed-data-9988323b.js";import{Signer as l}from"@ethersproject/abstract-signer";import{deepCopy as m}from"@ethersproject/properties";import{f as v}from"./index-91e932a7.js";import"zustand";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/transactions";import"./__node-resolve_empty-7f3920c0.js";class f extends l{constructor(e,r,t,o){super(),this._address=r,this._index=null!=t?t:0,this.provider=e,this.app=o}_legacySignMessage(e){throw new Error("Method not implemented.")}sendUncheckedTransaction(e){throw new Error("Method not implemented.")}unlock(e){throw new Error("Method not implemented.")}getAddress(){return e(this,void 0,void 0,(function*(){return Promise.resolve(c(this._address))}))}signMessage(t){return e(this,void 0,void 0,(function*(){const e=r(),o="string"==typeof t?p(t):t,n=yield this.getAddress();return yield e.send("personal_sign",[h(o),n.toLowerCase()])}))}_signTypedData(o,n,s){var i,d;return e(this,void 0,void 0,(function*(){const a=r(),c=yield u.resolveNames(o,n,s,(r=>e(this,void 0,void 0,(function*(){return yield a.resolveName(r)})))),h=null!==(d=null===(i=t())||void 0===i?void 0:i.ownerAddress)&&void 0!==d?d:"";return yield a.send("eth_signTypedData_v4",[h.toLowerCase(),JSON.stringify(u.getPayload(c.domain,n,c.value))])}))}signTransaction(r){return e(this,void 0,void 0,(function*(){throw new Error("Method not implemented.")}))}sendTransaction(r){return e(this,void 0,void 0,(function*(){const e=yield this.getChainId(),t=o(this.app,e);return{hash:yield t.sendTransaction({to:r.to,value:r.value,data:r.data}).catch((e=>{if(e.name===n.SendTransactionError&&(console.error(e.shortMessage),e.shortMessage))throw new Error(e.shortMessage);throw e}))}}))}connect(e){return new f(null!=e?e:this.provider,this._address,this._index,this.app)}connectUnchecked(){return new f(this.provider,this._address,this._index,this.app)}}function g(e){if(e.error){const r=new Error(e.error.message);throw r.code=e.error.code,r.data=e.error.data,r}return e.result}function w(r,t){return e(this,void 0,void 0,(function*(){const o=yield function({appName:r,appLogoUrl:t,rpcUrl:o,rpc:n,chainId:d,cyberParams:h}){return e(this,void 0,void 0,(function*(){if(!r||!t)throw new Error("appName and appLogoUrl is required.");if(!(null==h?void 0:h.appId))throw new Error("cyberParams.appId and appLogoUrl is required.");const{app:p,cyberAccount:u}=yield s({appName:r,appLogoUrl:t,appId:null==h?void 0:h.appId});if(!u)throw new Error("cyberAccount is not valid.");const l=u.address,w=new class extends a{constructor(e,r){super(e,r),this.updateUpWalletConfig=e=>{const r=null==n?void 0:n[e];if(!i.includes(e)||!r)throw new Error(`chainId ${e} not supported`);return this.chainId=e,r&&(this.rpcUrl=r),this.emit("chainChanged",`0x${e.toString(16)}`),{result:!0}},this.rpcUrl=e,this.chainId=d}getSigner(){return new f(w,l,0,p)}listAccounts(){return e(this,void 0,void 0,(function*(){return[l]}))}getNetwork(){return this.chainId?Promise.resolve({chainId:this.chainId,name:"unknown"}):super.getNetwork()}send(e,r){const t={method:e,params:r,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:m(t),provider:this});const o=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(o&&this._cache[e])return this._cache[e];const n=v({url:this.rpcUrl},JSON.stringify(t),g).then((e=>(this.emit("debug",{action:"response",request:t,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:t,provider:this}),e}));return o&&(this._cache[e]=n,setTimeout((()=>{this._cache[e]=null}),0)),n}getAddress(){return Promise.resolve(c(l))}}(o,d);return w}))}(r);return o.on("connect",t.connect),o.on("disconnect",t.disconnect),o.on("accountsChanged",t.accountsChanged),o.on("chainChanged",t.chainChanged),o.on("message",t.message),o}))}function y(e){var r;const t=e.addChainParameters.chainId,o="string"==typeof t&&(null==t?void 0:t.startsWith("0x"))?parseInt(t,16):Number(t);if(!i.includes(o))throw new Error(`chainId ${o} not supported`);return null===(r=d.getState().provider)||void 0===r?void 0:r.updateUpWalletConfig(o)}export{w as default,y as switchChain};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{arrayify as e,isBytesLike as t,hexlify as r}from"@ethersproject/bytes";import{shallowCopy as o}from"@ethersproject/properties";import{L as n,t as s,a as i}from"./id-
|
|
1
|
+
import{arrayify as e,isBytesLike as t,hexlify as r}from"@ethersproject/bytes";import{shallowCopy as o}from"@ethersproject/properties";import{L as n,t as s,a as i}from"./id-fe4b4d37.js";function l(t){t=atob(t);const r=[];for(let e=0;e<t.length;e++)r.push(t.charCodeAt(e));return e(r)}function c(t){t=e(t);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return btoa(r)}var a=function(e,t,r,o){return new(r||(r=Promise))((function(n,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function l(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,l)}c((o=o.apply(e,t||[])).next())}))};function u(t,r){return a(this,void 0,void 0,(function*(){null==r&&(r={});const o={method:r.method||"GET",headers:r.headers||{},body:r.body||void 0};if(!0!==r.skipFetchSetup&&(o.mode="cors",o.cache="no-cache",o.credentials="same-origin",o.redirect="follow",o.referrer="client"),null!=r.fetchOptions){const e=r.fetchOptions;e.mode&&(o.mode=e.mode),e.cache&&(o.cache=e.cache),e.credentials&&(o.credentials=e.credentials),e.redirect&&(o.redirect=e.redirect),e.referrer&&(o.referrer=e.referrer)}const n=yield fetch(t,o),s=yield n.arrayBuffer(),i={};return n.headers.forEach?n.headers.forEach(((e,t)=>{i[t.toLowerCase()]=e})):n.headers.keys().forEach((e=>{i[e.toLowerCase()]=n.headers.get(e)})),{headers:i,statusCode:n.status,statusMessage:n.statusText,body:e(new Uint8Array(s))}}))}var h=function(e,t,r,o){return new(r||(r=Promise))((function(n,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function l(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,l)}c((o=o.apply(e,t||[])).next())}))};const d=new n("web/5.7.1");function f(e){return new Promise((t=>{setTimeout(t,e)}))}function p(e,o){if(null==e)return null;if("string"==typeof e)return e;if(t(e)){if(o&&("text"===o.split("/")[0]||"application/json"===o.split(";")[0].trim()))try{return i(e)}catch(e){}return r(e)}return e}function y(e,t,r){const i="object"==typeof e&&null!=e.throttleLimit?e.throttleLimit:12;d.assertArgument(i>0&&i%1==0,"invalid connection throttle limit","connection.throttleLimit",i);const a="object"==typeof e?e.throttleCallback:null,y="object"==typeof e&&"number"==typeof e.throttleSlotInterval?e.throttleSlotInterval:100;d.assertArgument(y>0&&y%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",y);const m="object"==typeof e&&!!e.errorPassThrough,E={};let b=null;const g={method:"GET"};let w=!1,R=12e4;if("string"==typeof e)b=e;else if("object"==typeof e){if(null!=e&&null!=e.url||d.throwArgumentError("missing URL","connection.url",e),b=e.url,"number"==typeof e.timeout&&e.timeout>0&&(R=e.timeout),e.headers)for(const t in e.headers)E[t.toLowerCase()]={key:t,value:String(e.headers[t])},["if-none-match","if-modified-since"].indexOf(t.toLowerCase())>=0&&(w=!0);if(g.allowGzip=!!e.allowGzip,null!=e.user&&null!=e.password){"https:"!==b.substring(0,6)&&!0!==e.allowInsecureAuthentication&&d.throwError("basic authentication requires a secure https url",n.errors.INVALID_ARGUMENT,{argument:"url",url:b,user:e.user,password:"[REDACTED]"});const t=e.user+":"+e.password;E.authorization={key:"Authorization",value:"Basic "+c(s(t))}}null!=e.skipFetchSetup&&(g.skipFetchSetup=!!e.skipFetchSetup),null!=e.fetchOptions&&(g.fetchOptions=o(e.fetchOptions))}const v=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),C=b?b.match(v):null;if(C)try{const e={statusCode:200,statusMessage:"OK",headers:{"content-type":C[1]||"text/plain"},body:C[2]?l(C[3]):(S=C[3],s(S.replace(/%([0-9a-f][0-9a-f])/gi,((e,t)=>String.fromCharCode(parseInt(t,16))))))};let t=e.body;return r&&(t=r(e.body,e)),Promise.resolve(t)}catch(e){d.throwError("processing response error",n.errors.SERVER_ERROR,{body:p(C[1],C[2]),error:e,requestBody:null,requestMethod:"GET",url:b})}var S;t&&(g.method="POST",g.body=t,null==E["content-type"]&&(E["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==E["content-length"]&&(E["content-length"]={key:"Content-Length",value:String(t.length)}));const O={};Object.keys(E).forEach((e=>{const t=E[e];O[t.key]=t.value})),g.headers=O;const T=function(){let e=null;return{promise:new Promise((function(t,r){R&&(e=setTimeout((()=>{null!=e&&(e=null,r(d.makeError("timeout",n.errors.TIMEOUT,{requestBody:p(g.body,O["content-type"]),requestMethod:g.method,timeout:R,url:b})))}),R))})),cancel:function(){null!=e&&(clearTimeout(e),e=null)}}}(),k=function(){return h(this,void 0,void 0,(function*(){for(let e=0;e<i;e++){let t=null;try{if(t=yield u(b,g),e<i)if(301===t.statusCode||302===t.statusCode){const e=t.headers.location||"";if("GET"===g.method&&e.match(/^https:/)){b=t.headers.location;continue}}else if(429===t.statusCode){let r=!0;if(a&&(r=yield a(e,b)),r){let r=0;const o=t.headers["retry-after"];r="string"==typeof o&&o.match(/^[1-9][0-9]*$/)?1e3*parseInt(o):y*parseInt(String(Math.random()*Math.pow(2,e))),yield f(r);continue}}}catch(e){t=e.response,null==t&&(T.cancel(),d.throwError("missing response",n.errors.SERVER_ERROR,{requestBody:p(g.body,O["content-type"]),requestMethod:g.method,serverError:e,url:b}))}let o=t.body;if(w&&304===t.statusCode?o=null:!m&&(t.statusCode<200||t.statusCode>=300)&&(T.cancel(),d.throwError("bad response",n.errors.SERVER_ERROR,{status:t.statusCode,headers:t.headers,body:p(o,t.headers?t.headers["content-type"]:null),requestBody:p(g.body,O["content-type"]),requestMethod:g.method,url:b})),r)try{const e=yield r(o,t);return T.cancel(),e}catch(r){if(r.throttleRetry&&e<i){let t=!0;if(a&&(t=yield a(e,b)),t){const t=y*parseInt(String(Math.random()*Math.pow(2,e)));yield f(t);continue}}T.cancel(),d.throwError("processing response error",n.errors.SERVER_ERROR,{body:p(o,t.headers?t.headers["content-type"]:null),error:r,requestBody:p(g.body,O["content-type"]),requestMethod:g.method,url:b})}return T.cancel(),o}return d.throwError("failed response",n.errors.SERVER_ERROR,{requestBody:p(g.body,O["content-type"]),requestMethod:g.method,url:b})}))}();return Promise.race([T.promise,k])}function m(e,t,r){let l=null;if(null!=t){l=s(t);const r="string"==typeof e?{url:e}:o(e);if(r.headers){0!==Object.keys(r.headers).filter((e=>"content-type"===e.toLowerCase())).length||(r.headers=o(r.headers),r.headers["content-type"]="application/json")}else r.headers={"content-type":"application/json"};e=r}return y(e,l,((e,t)=>{let o=null;if(null!=e)try{o=JSON.parse(i(e))}catch(t){d.throwError("invalid JSON",n.errors.SERVER_ERROR,{body:e,error:t})}return r&&(o=r(o,t)),o}))}function E(e,t){return t||(t={}),null==(t=o(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise((function(r,o){let n=null,s=!1;const i=()=>!s&&(s=!0,n&&clearTimeout(n),!0);t.timeout&&(n=setTimeout((()=>{i()&&o(new Error("timeout"))}),t.timeout));const l=t.retryLimit;let c=0;!function n(){return e().then((function(e){if(void 0!==e)i()&&r(e);else if(t.oncePoll)t.oncePoll.once("poll",n);else if(t.onceBlock)t.onceBlock.once("block",n);else if(!s){if(c++,c>l)return void(i()&&o(new Error("retry limit reached")));let e=t.interval*parseInt(String(Math.random()*Math.pow(2,c)));e<t.floor&&(e=t.floor),e>t.ceiling&&(e=t.ceiling),setTimeout(n,e)}return null}),(function(e){i()&&o(e)}))}()}))}var b=Object.freeze({__proto__:null,_fetchData:y,fetchJson:m,poll:E});export{y as _,l as d,c as e,m as f,b as l,E as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hexlify as r,arrayify as t,isBytesLike as o}from"@ethersproject/bytes";import{L as e}from"./id-
|
|
1
|
+
import{hexlify as r,arrayify as t,isBytesLike as o}from"@ethersproject/bytes";import{L as e}from"./id-fe4b4d37.js";const n=new e("rlp/5.7.0");function s(r){const t=[];for(;r;)t.unshift(255&r),r>>=8;return t}function c(r,t,o){let e=0;for(let n=0;n<o;n++)e=256*e+r[t+n];return e}function h(r){if(Array.isArray(r)){let t=[];if(r.forEach((function(r){t=t.concat(h(r))})),t.length<=55)return t.unshift(192+t.length),t;const o=s(t.length);return o.unshift(247+o.length),o.concat(t)}o(r)||n.throwArgumentError("RLP object must be BytesLike","object",r);const e=Array.prototype.slice.call(t(r));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const c=s(e.length);return c.unshift(183+c.length),c.concat(e)}function u(t){return r(h(t))}function a(r,t,o,s){const c=[];for(;o<t+1+s;){const h=l(r,o);c.push(h.result),(o+=h.consumed)>t+1+s&&n.throwError("child data too short",e.errors.BUFFER_OVERRUN,{})}return{consumed:1+s,result:c}}function l(t,o){if(0===t.length&&n.throwError("data too short",e.errors.BUFFER_OVERRUN,{}),t[o]>=248){const r=t[o]-247;o+1+r>t.length&&n.throwError("data short segment too short",e.errors.BUFFER_OVERRUN,{});const s=c(t,o+1,r);return o+1+r+s>t.length&&n.throwError("data long segment too short",e.errors.BUFFER_OVERRUN,{}),a(t,o,o+1+r,r+s)}if(t[o]>=192){const r=t[o]-192;return o+1+r>t.length&&n.throwError("data array too short",e.errors.BUFFER_OVERRUN,{}),a(t,o,o+1,r)}if(t[o]>=184){const s=t[o]-183;o+1+s>t.length&&n.throwError("data array too short",e.errors.BUFFER_OVERRUN,{});const h=c(t,o+1,s);o+1+s+h>t.length&&n.throwError("data array too short",e.errors.BUFFER_OVERRUN,{});return{consumed:1+s+h,result:r(t.slice(o+1+s,o+1+s+h))}}if(t[o]>=128){const s=t[o]-128;o+1+s>t.length&&n.throwError("data too short",e.errors.BUFFER_OVERRUN,{});return{consumed:1+s,result:r(t.slice(o+1,o+1+s))}}return{consumed:1,result:r(t[o])}}function i(r){const o=t(r),e=l(o,0);return e.consumed!==o.length&&n.throwArgumentError("invalid rlp data","data",r),e.result}var f=Object.freeze({__proto__:null,encode:u,decode:i});export{i as d,u as e,f as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,g as t,r as n,c as r,S as o,t as i,v as a,u as s}from"./index-77a007d6.js";import{JsonRpcProvider as c}from"@ethersproject/providers";import u,{getAddress as p}from"@ethersproject/address";import{Signer as l}from"@ethersproject/abstract-signer";import d,{arrayify as f}from"@ethersproject/bytes";import{T as h}from"./typed-data-6eb1c9d6.js";import{r as g}from"./index-317ac511.js";import{f as y,p as m,n as b,d as v,b as w,i as P,c as x,m as O,h as j,g as _,r as S,s as E,j as k,S as T,k as U,o as L,q as A,t as C,x as N,y as I,z as D,A as M,B as R}from"./ethers-85ce2662.js";import{d as F,t as z,c as B,a as W,e as G,f as V,U as J,i as H,l as K}from"./id-c0507d8c.js";import Z from"@ethersproject/json-wallets";import q,{deepCopy as $}from"@ethersproject/properties";import{l as Y}from"./index-f08f2425.js";import Q from"@ethersproject/transactions";import{l as X,f as ee}from"./index-a95b7ad7.js";import{Contract as te}from"@ethersproject/contracts";import"zustand";import"events";import"@ethersproject/constants";import"./interface-a77d6d24.js";import"@ethersproject/abstract-provider";import"./__node-resolve_empty-5887e83d.js";import"./hash-a9ebd52a.js";import"./inherits_browser-06ba108b.js";var ne,re=Object.freeze({__proto__:null,_toEscapedUtf8String:F,toUtf8Bytes:z,toUtf8CodePoints:B,toUtf8String:W,Utf8ErrorFuncs:G,get Utf8ErrorReason(){return V},get UnicodeNormalizationForm(){return J},formatBytes32String:y,parseBytes32String:m,nameprep:b}),oe=Object.freeze({__proto__:null,id:H,dnsEncode:v,namehash:w,isValidName:P,ensNormalize:x,messagePrefix:O,hashMessage:j,_TypedDataEncoder:h}),ie=Object.freeze({__proto__:null,computeHmac:_,ripemd160:S,sha256:E,sha512:k,get SupportedAlgorithm(){return T}}),ae=Object.freeze({__proto__:null,randomBytes:U,shuffled:L});class se extends l{constructor(e,t,n,r){super(),this._address=n,this._index=null!=r?r:0,this.provider=e,this.upWallet=t}_legacySignMessage(e){throw new Error("Method not implemented.")}sendUncheckedTransaction(e){throw new Error("Method not implemented.")}unlock(e){throw new Error("Method not implemented.")}getAddress(){return e(this,void 0,void 0,(function*(){return Promise.resolve(p(this._address))}))}signMessage(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t}'`);return yield this.upWallet.signMessage(t,{isEIP191Prefix:!0,onAuthChain:!0})}))}_signTypedData(t,n,r){return e(this,void 0,void 0,(function*(){throw new Error("Method not implemented.")}))}signTransaction(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t.from}'`);return this.upWallet.sendTransaction({from:t.from,to:t.to,value:t.value,data:t.data})}))}sendTransaction(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t.from}'`);return{hash:yield this.upWallet.sendTransaction({from:t.from,to:t.to,value:t.value,data:t.data}),from:t.from}}))}connect(e){return new se(null!=e?e:this.provider,this.upWallet,this._address,this._index)}connectUnchecked(){return new se(this.provider,this.upWallet,this._address,this._index)}}!function(e){e.REGISTER="register"}(ne||(ne={}));var ce,ue=function(e,t,n,r,o){this.from=e,this.msg=t,this.type=n,this.isEIP191Prefix=r,this.onAuthChain=o},pe=function(e,t){this.type=e,this.data=t},le=function(e,t,n){this.type=e,this.payload=t,this.appSetting=n};function de(){return de=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},de.apply(this,arguments)}!function(e){e.LIGHT="light",e.DARK="dark"}(ce||(ce={}));var fe=function(e){return f(function(e){var t=de({},e.types);return delete t.EIP712Domain,h.hash(e.domain,t,e.message)}(e))},he={},ge=t(A),ye=t(C),me=t(oe),be=t(N),ve=t(n),we=t(K),Pe=t(ie),xe=t(I),Oe=t(ae),je=t(Y),_e=t(D),Se=t(re),Ee=t(M),ke=t(R),Te=t(X);function Ue(){Ue=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,o){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype),s=new _(o||[]);return r(a,"_invoke",{value:P(e,n,s)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function d(){}function f(){}function h(){}var g={};c(g,i,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(S([])));m&&m!==t&&n.call(m,i)&&(g=m);var b=h.prototype=d.prototype=Object.create(g);function v(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function o(r,i,a,s){var c=p(e[r],e,i);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){o("next",e,a,s)}),(function(e){o("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return o("throw",e,a,s)}))}s(c.arg)}var i;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){o(e,n,t,r)}))}return i=i?i.then(r,r):r()}})}function P(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return E()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=x(a,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=p(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function x(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var o=p(r,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,l;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function j(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return f.prototype=h,r(b,"constructor",{value:h,configurable:!0}),r(h,"constructor",{value:f,configurable:!0}),f.displayName=c(h,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,c(e,s,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},v(w.prototype),c(w.prototype,a,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new w(u(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(b),c(b,s,"Generator"),c(b,i,(function(){return this})),c(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),j(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;j(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}function Le(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function Ae(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Le(i,r,o,a,s,"next",e)}function s(e){Le(i,r,o,a,s,"throw",e)}a(void 0)}))}}function Ce(){return Ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ce.apply(this,arguments)}!function(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=r&&r.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&t(r,e,o);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.formatBytes32String=e.Utf8ErrorFuncs=e.toUtf8String=e.toUtf8CodePoints=e.toUtf8Bytes=e._toEscapedUtf8String=e.nameprep=e.hexDataSlice=e.hexDataLength=e.hexZeroPad=e.hexValue=e.hexStripZeros=e.hexConcat=e.isHexString=e.hexlify=e.base64=e.base58=e.TransactionDescription=e.LogDescription=e.Interface=e.SigningKey=e.HDNode=e.defaultPath=e.isBytesLike=e.isBytes=e.zeroPad=e.stripZeros=e.concat=e.arrayify=e.shallowCopy=e.resolveProperties=e.getStatic=e.defineReadOnly=e.deepCopy=e.checkProperties=e.poll=e.fetchJson=e._fetchData=e.RLP=e.Logger=e.checkResultErrors=e.FormatTypes=e.ParamType=e.FunctionFragment=e.EventFragment=e.ErrorFragment=e.ConstructorFragment=e.Fragment=e.defaultAbiCoder=e.AbiCoder=void 0,e.Indexed=e.Utf8ErrorReason=e.UnicodeNormalizationForm=e.SupportedAlgorithm=e.mnemonicToSeed=e.isValidMnemonic=e.entropyToMnemonic=e.mnemonicToEntropy=e.getAccountPath=e.verifyTypedData=e.verifyMessage=e.recoverPublicKey=e.computePublicKey=e.recoverAddress=e.computeAddress=e.getJsonWalletAddress=e.TransactionTypes=e.serializeTransaction=e.parseTransaction=e.accessListify=e.joinSignature=e.splitSignature=e.soliditySha256=e.solidityKeccak256=e.solidityPack=e.shuffled=e.randomBytes=e.sha512=e.sha256=e.ripemd160=e.keccak256=e.computeHmac=e.commify=e.parseUnits=e.formatUnits=e.parseEther=e.formatEther=e.isAddress=e.getCreate2Address=e.getContractAddress=e.getIcapAddress=e.getAddress=e._TypedDataEncoder=e.id=e.isValidName=e.namehash=e.hashMessage=e.dnsEncode=e.parseBytes32String=void 0;var i=g;Object.defineProperty(e,"AbiCoder",{enumerable:!0,get:function(){return i.AbiCoder}}),Object.defineProperty(e,"checkResultErrors",{enumerable:!0,get:function(){return i.checkResultErrors}}),Object.defineProperty(e,"ConstructorFragment",{enumerable:!0,get:function(){return i.ConstructorFragment}}),Object.defineProperty(e,"defaultAbiCoder",{enumerable:!0,get:function(){return i.defaultAbiCoder}}),Object.defineProperty(e,"ErrorFragment",{enumerable:!0,get:function(){return i.ErrorFragment}}),Object.defineProperty(e,"EventFragment",{enumerable:!0,get:function(){return i.EventFragment}}),Object.defineProperty(e,"FormatTypes",{enumerable:!0,get:function(){return i.FormatTypes}}),Object.defineProperty(e,"Fragment",{enumerable:!0,get:function(){return i.Fragment}}),Object.defineProperty(e,"FunctionFragment",{enumerable:!0,get:function(){return i.FunctionFragment}}),Object.defineProperty(e,"Indexed",{enumerable:!0,get:function(){return i.Indexed}}),Object.defineProperty(e,"Interface",{enumerable:!0,get:function(){return i.Interface}}),Object.defineProperty(e,"LogDescription",{enumerable:!0,get:function(){return i.LogDescription}}),Object.defineProperty(e,"ParamType",{enumerable:!0,get:function(){return i.ParamType}}),Object.defineProperty(e,"TransactionDescription",{enumerable:!0,get:function(){return i.TransactionDescription}});var a=u;Object.defineProperty(e,"getAddress",{enumerable:!0,get:function(){return a.getAddress}}),Object.defineProperty(e,"getCreate2Address",{enumerable:!0,get:function(){return a.getCreate2Address}}),Object.defineProperty(e,"getContractAddress",{enumerable:!0,get:function(){return a.getContractAddress}}),Object.defineProperty(e,"getIcapAddress",{enumerable:!0,get:function(){return a.getIcapAddress}}),Object.defineProperty(e,"isAddress",{enumerable:!0,get:function(){return a.isAddress}});var s=o(ge);e.base64=s;var c=ye;Object.defineProperty(e,"base58",{enumerable:!0,get:function(){return c.Base58}});var p=d;Object.defineProperty(e,"arrayify",{enumerable:!0,get:function(){return p.arrayify}}),Object.defineProperty(e,"concat",{enumerable:!0,get:function(){return p.concat}}),Object.defineProperty(e,"hexConcat",{enumerable:!0,get:function(){return p.hexConcat}}),Object.defineProperty(e,"hexDataSlice",{enumerable:!0,get:function(){return p.hexDataSlice}}),Object.defineProperty(e,"hexDataLength",{enumerable:!0,get:function(){return p.hexDataLength}}),Object.defineProperty(e,"hexlify",{enumerable:!0,get:function(){return p.hexlify}}),Object.defineProperty(e,"hexStripZeros",{enumerable:!0,get:function(){return p.hexStripZeros}}),Object.defineProperty(e,"hexValue",{enumerable:!0,get:function(){return p.hexValue}}),Object.defineProperty(e,"hexZeroPad",{enumerable:!0,get:function(){return p.hexZeroPad}}),Object.defineProperty(e,"isBytes",{enumerable:!0,get:function(){return p.isBytes}}),Object.defineProperty(e,"isBytesLike",{enumerable:!0,get:function(){return p.isBytesLike}}),Object.defineProperty(e,"isHexString",{enumerable:!0,get:function(){return p.isHexString}}),Object.defineProperty(e,"joinSignature",{enumerable:!0,get:function(){return p.joinSignature}}),Object.defineProperty(e,"zeroPad",{enumerable:!0,get:function(){return p.zeroPad}}),Object.defineProperty(e,"splitSignature",{enumerable:!0,get:function(){return p.splitSignature}}),Object.defineProperty(e,"stripZeros",{enumerable:!0,get:function(){return p.stripZeros}});var l=me;Object.defineProperty(e,"_TypedDataEncoder",{enumerable:!0,get:function(){return l._TypedDataEncoder}}),Object.defineProperty(e,"dnsEncode",{enumerable:!0,get:function(){return l.dnsEncode}}),Object.defineProperty(e,"hashMessage",{enumerable:!0,get:function(){return l.hashMessage}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return l.id}}),Object.defineProperty(e,"isValidName",{enumerable:!0,get:function(){return l.isValidName}}),Object.defineProperty(e,"namehash",{enumerable:!0,get:function(){return l.namehash}});var f=be;Object.defineProperty(e,"defaultPath",{enumerable:!0,get:function(){return f.defaultPath}}),Object.defineProperty(e,"entropyToMnemonic",{enumerable:!0,get:function(){return f.entropyToMnemonic}}),Object.defineProperty(e,"getAccountPath",{enumerable:!0,get:function(){return f.getAccountPath}}),Object.defineProperty(e,"HDNode",{enumerable:!0,get:function(){return f.HDNode}}),Object.defineProperty(e,"isValidMnemonic",{enumerable:!0,get:function(){return f.isValidMnemonic}}),Object.defineProperty(e,"mnemonicToEntropy",{enumerable:!0,get:function(){return f.mnemonicToEntropy}}),Object.defineProperty(e,"mnemonicToSeed",{enumerable:!0,get:function(){return f.mnemonicToSeed}});var h=Z;Object.defineProperty(e,"getJsonWalletAddress",{enumerable:!0,get:function(){return h.getJsonWalletAddress}});var y=ve;Object.defineProperty(e,"keccak256",{enumerable:!0,get:function(){return y.keccak256}});var m=we;Object.defineProperty(e,"Logger",{enumerable:!0,get:function(){return m.Logger}});var b=Pe;Object.defineProperty(e,"computeHmac",{enumerable:!0,get:function(){return b.computeHmac}}),Object.defineProperty(e,"ripemd160",{enumerable:!0,get:function(){return b.ripemd160}}),Object.defineProperty(e,"sha256",{enumerable:!0,get:function(){return b.sha256}}),Object.defineProperty(e,"sha512",{enumerable:!0,get:function(){return b.sha512}});var v=xe;Object.defineProperty(e,"solidityKeccak256",{enumerable:!0,get:function(){return v.keccak256}}),Object.defineProperty(e,"solidityPack",{enumerable:!0,get:function(){return v.pack}}),Object.defineProperty(e,"soliditySha256",{enumerable:!0,get:function(){return v.sha256}});var w=Oe;Object.defineProperty(e,"randomBytes",{enumerable:!0,get:function(){return w.randomBytes}}),Object.defineProperty(e,"shuffled",{enumerable:!0,get:function(){return w.shuffled}});var P=q;Object.defineProperty(e,"checkProperties",{enumerable:!0,get:function(){return P.checkProperties}}),Object.defineProperty(e,"deepCopy",{enumerable:!0,get:function(){return P.deepCopy}}),Object.defineProperty(e,"defineReadOnly",{enumerable:!0,get:function(){return P.defineReadOnly}}),Object.defineProperty(e,"getStatic",{enumerable:!0,get:function(){return P.getStatic}}),Object.defineProperty(e,"resolveProperties",{enumerable:!0,get:function(){return P.resolveProperties}}),Object.defineProperty(e,"shallowCopy",{enumerable:!0,get:function(){return P.shallowCopy}});var x=o(je);e.RLP=x;var O=_e;Object.defineProperty(e,"computePublicKey",{enumerable:!0,get:function(){return O.computePublicKey}}),Object.defineProperty(e,"recoverPublicKey",{enumerable:!0,get:function(){return O.recoverPublicKey}}),Object.defineProperty(e,"SigningKey",{enumerable:!0,get:function(){return O.SigningKey}});var j=Se;Object.defineProperty(e,"formatBytes32String",{enumerable:!0,get:function(){return j.formatBytes32String}}),Object.defineProperty(e,"nameprep",{enumerable:!0,get:function(){return j.nameprep}}),Object.defineProperty(e,"parseBytes32String",{enumerable:!0,get:function(){return j.parseBytes32String}}),Object.defineProperty(e,"_toEscapedUtf8String",{enumerable:!0,get:function(){return j._toEscapedUtf8String}}),Object.defineProperty(e,"toUtf8Bytes",{enumerable:!0,get:function(){return j.toUtf8Bytes}}),Object.defineProperty(e,"toUtf8CodePoints",{enumerable:!0,get:function(){return j.toUtf8CodePoints}}),Object.defineProperty(e,"toUtf8String",{enumerable:!0,get:function(){return j.toUtf8String}}),Object.defineProperty(e,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return j.Utf8ErrorFuncs}});var _=Q;Object.defineProperty(e,"accessListify",{enumerable:!0,get:function(){return _.accessListify}}),Object.defineProperty(e,"computeAddress",{enumerable:!0,get:function(){return _.computeAddress}}),Object.defineProperty(e,"parseTransaction",{enumerable:!0,get:function(){return _.parse}}),Object.defineProperty(e,"recoverAddress",{enumerable:!0,get:function(){return _.recoverAddress}}),Object.defineProperty(e,"serializeTransaction",{enumerable:!0,get:function(){return _.serialize}}),Object.defineProperty(e,"TransactionTypes",{enumerable:!0,get:function(){return _.TransactionTypes}});var S=Ee;Object.defineProperty(e,"commify",{enumerable:!0,get:function(){return S.commify}}),Object.defineProperty(e,"formatEther",{enumerable:!0,get:function(){return S.formatEther}}),Object.defineProperty(e,"parseEther",{enumerable:!0,get:function(){return S.parseEther}}),Object.defineProperty(e,"formatUnits",{enumerable:!0,get:function(){return S.formatUnits}}),Object.defineProperty(e,"parseUnits",{enumerable:!0,get:function(){return S.parseUnits}});var E=ke;Object.defineProperty(e,"verifyMessage",{enumerable:!0,get:function(){return E.verifyMessage}}),Object.defineProperty(e,"verifyTypedData",{enumerable:!0,get:function(){return E.verifyTypedData}});var k=Te;Object.defineProperty(e,"_fetchData",{enumerable:!0,get:function(){return k._fetchData}}),Object.defineProperty(e,"fetchJson",{enumerable:!0,get:function(){return k.fetchJson}}),Object.defineProperty(e,"poll",{enumerable:!0,get:function(){return k.poll}});var T=Pe;Object.defineProperty(e,"SupportedAlgorithm",{enumerable:!0,get:function(){return T.SupportedAlgorithm}});var U=Se;Object.defineProperty(e,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return U.UnicodeNormalizationForm}}),Object.defineProperty(e,"Utf8ErrorReason",{enumerable:!0,get:function(){return U.Utf8ErrorReason}})}(he);var Ne="wallet.unipass.id",Ie={upDomain:Ne,upConnectUrl:"https://"+Ne+"/connect",upLogoutUrl:"https://"+Ne+"/logout",upSignMessageUrl:"https://"+Ne+"/sign-message",upTransactionUrl:"https://"+Ne+"/send-transaction",upLoadingUrl:"https://"+Ne+"/connect/loading"},De=function(){return Ie},Me={protocol:"https",domain:"testnet.wallet.unipass.id"},Re={protocol:"https",domain:"wallet.unipass.id"},Fe={mainnet:{eth:"https://node.wallet.unipass.id/eth-mainnet",polygon:"https://node.wallet.unipass.id/polygon-mainnet",bsc:"https://node.wallet.unipass.id/bsc-mainnet",rangers:"https://node.wallet.unipass.id/rangers-mainnet",scroll:"https://node.wallet.unipass.id/scroll-mainnet",arbitrum:"https://node.wallet.unipass.id/arbitrum-mainnet",avalanche:"https://node.wallet.unipass.id/avalanche-mainnet",kcc:"https://node.wallet.unipass.id/kcc-mainnet",platon:"https://node.wallet.unipass.id/platon-mainnet",okc:"https://node.wallet.unipass.id/okc-mainnet"},testnet:{eth:"https://node.wallet.unipass.id/eth-goerli",polygon:"https://node.wallet.unipass.id/polygon-mumbai",bsc:"https://node.wallet.unipass.id/bsc-testnet",rangers:"https://node.wallet.unipass.id/rangers-robin",scroll:"https://node.wallet.unipass.id/scroll-testnet",arbitrum:"https://node.wallet.unipass.id/arbitrum-testnet",avalanche:"https://node.wallet.unipass.id/avalanche-testnet",kcc:"https://node.wallet.unipass.id/kcc-testnet",platon:"https://node.wallet.unipass.id/platon-testnet",okc:"https://node.wallet.unipass.id/okc-testnet"}},ze=function(e){var t;t="localStorage"===e?window.localStorage||localStorage:window.sessionStorage||sessionStorage;return{get:function(e){return t.getItem(e)||""},set:function(e,n){return t.setItem(e,n||"")},remove:function(e){return t.removeItem(e)}}},Be=function(){var e=Ae(Ue().mark((function e(t,n){var r,o;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ze(t.storageType).get(nt),e.t0=r&&JSON.parse(r),e.t0){e.next=6;break}return e.next=5,Ge(t,n);case 5:e.t0=e.sent;case 6:return o=e.t0,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),We=function(){var e=Ae(Ue().mark((function e(t){var n;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=4;break}return n=new le("UP_LOGOUT"),e.next=4,rt(n);case 4:ze("localStorage").remove(nt),ze("sessionStorage").remove(nt);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ge=function(){var e=Ae(Ue().mark((function e(t,n){var r,o,i;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=n?JSON.stringify(n):"",o=new le("UP_LOGIN",r,t.appSettings),e.next=5,rt(o,null==n?void 0:n.connectType,null==n?void 0:n.forceLogin,null==n?void 0:n.eventListener);case 5:return(i=e.sent)&&i.address&&ze(t.storageType).set(nt,JSON.stringify(i)),e.abrupt("return",i);case 10:throw e.prev=10,e.t0=e.catch(0),new Error("Account Not Available");case 13:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(t,n){return e.apply(this,arguments)}}(),Ve="UP_WALLET_POP",Je=null,He=null;function Ke(e,t,n){var r="innerWidth=462,width=462,innerHeight=810,height=810,top="+.5*(n.screen.availHeight-30-810)+",left="+.8*(n.screen.availWidth-10-462)+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,";return n.open(e,t,r)}function Ze(e,t,n){return qe.apply(this,arguments)}function qe(){return(qe=Ae(Ue().mark((function e(t,n,r){var o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(null==Je||null!=(o=Je)&&o.closed)){e.next=8;break}if(null!=(Je=Ke(t,Ve,window))){e.next=6;break}return e.next=5,$e(t,n,r);case 5:return e.abrupt("return",e.sent);case 6:e.next=9;break;case 8:He!==t?(Je.location.replace(t),Je.focus()):Je.focus();case 9:return i=setInterval((function(){if(Je&&Je.closed){var e={data:new le("UP_RESPONSE",JSON.stringify(new pe("DECLINE","user reject connection")))};n(e,{close:function(){},send:function(){}}),clearInterval(i)}}),1e3),a=function(){Je&&!Je.closed&&Je.close(),Je=null},e.abrupt("return",{popup:Je,unmount:a});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $e(e,t,n){return Ye.apply(this,arguments)}function Ye(){return(Ye=Ae(Ue().mark((function e(t,n,r){var o,i;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=document.createElement("div"),'\n <div\n class="up_notification"\n style="\n position: fixed;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n top: 26px;\n right: 26px;\n width: 340px;\n height: 96px;\n z-index: 100001;\n background-color: #362866;\n box-sizing: border-box;\n border: 2px solid #ffffff;\n border-radius: 8px;\n padding: 16px 20px;\n "\n>\n <div class="up_notification_left" style="color: white">\n <div\n class="up_notification_title"\n style="\n font-weight: 500;\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 8px;\n "\n >\n Request Pop-up\n </div>\n <div\n class="up_notification_tip"\n style="\n font-weight: 450;\n font-size: 12px;\n line-height: 20px;\n color: rgba(255, 255, 255, 0.8);\n "\n >\n Click Approve to complete creating or using wallet\n </div>\n </div>\n <div\n class="up_notification_right"\n style="\n width: 90px;\n height: 35px;\n font-size: 12px;\n text-align: center;\n background: linear-gradient(270deg, #997afb 0%, #7a55f8 63.6%);\n border-radius: 6px;\n line-height: 35px;\n color: white;\n margin-left: 20px;\n cursor: pointer;\n "\n >\n Approve\n </div>\n</div>\n ',o.innerHTML='\n <div\n class="up_notification"\n style="\n position: fixed;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n top: 26px;\n right: 26px;\n width: 340px;\n height: 96px;\n z-index: 100001;\n background-color: #362866;\n box-sizing: border-box;\n border: 2px solid #ffffff;\n border-radius: 8px;\n padding: 16px 20px;\n "\n>\n <div class="up_notification_left" style="color: white">\n <div\n class="up_notification_title"\n style="\n font-weight: 500;\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 8px;\n "\n >\n Request Pop-up\n </div>\n <div\n class="up_notification_tip"\n style="\n font-weight: 450;\n font-size: 12px;\n line-height: 20px;\n color: rgba(255, 255, 255, 0.8);\n "\n >\n Click Approve to complete creating or using wallet\n </div>\n </div>\n <div\n class="up_notification_right"\n style="\n width: 90px;\n height: 35px;\n font-size: 12px;\n text-align: center;\n background: linear-gradient(270deg, #997afb 0%, #7a55f8 63.6%);\n border-radius: 6px;\n line-height: 35px;\n color: white;\n margin-left: 20px;\n cursor: pointer;\n "\n >\n Approve\n </div>\n</div>\n ',document.body.appendChild(o),i=document.querySelector(".up_notification_right"),e.abrupt("return",new Promise((function(e){null==i||i.addEventListener("click",(function(){document.body.removeChild(o),e(Ze(t,n,r))}),!1)})));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Qe=function(){};function Xe(e,t,n){if("UP_LOGIN"===e)return"google"===t?De().upConnectUrl+"?connectType=google&forceLogin="+(n?"1":"0"):"email"===t?De().upConnectUrl+"?connectType=email&forceLogin="+(n?"1":"0"):De().upConnectUrl+"?forceLogin="+(n?"1":"0");if("UP_LOGOUT"===e)return De().upLogoutUrl;if("UP_SIGN_MESSAGE"===e)return De().upSignMessageUrl;if("UP_TRANSACTION"===e)return De().upTransactionUrl;if("UP_READY"===e)return De().upLoadingUrl;throw new Error("unsupport type "+e)}function et(e,t,n,r){return tt.apply(this,arguments)}function tt(){return tt=Ae(Ue().mark((function e(t,n,r,o){var i,a,s,c,u,p,l,d,f,h;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h=function(e){try{null==p||p.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Popup Send Error",e,t)}},f=function(){try{window.removeEventListener("message",d),l(),i()}catch(e){console.error("Popup Close Error",e)}},d=function(e){try{if("object"!=typeof e.data)return;var t=e.data;if(!t||!t.type)return;"UP_CLOSE"===e.data.type&&f(),"UP_READY"===t.type&&s(e,{send:h,close:f}),"UP_RESPONSE"===t.type&&c(e,{send:h,close:f}),"UP_EVENT"===t.type&&a(e,{send:h,close:f})}catch(e){console.error("Popup Callback Error",e),f()}},null!=t){e.next=5;break}return e.abrupt("return",{send:Qe,close:Qe});case 5:return i=(null==o?void 0:o.onClose)||Qe,a=(null==o?void 0:o.onMessage)||Qe,s=(null==o?void 0:o.onReady)||Qe,c=(null==o?void 0:o.onResponse)||Qe,window.addEventListener("message",d),e.next=12,Ze(Xe(t.type,n,r),c,t.appSetting);case 12:return u=e.sent,p=u.popup,l=u.unmount,e.abrupt("return",{send:h,close:f});case 16:case"end":return e.stop()}}),e)}))),tt.apply(this,arguments)}var nt="UP-A";function rt(e,t,n,r){return new Promise(function(){var o=Ae(Ue().mark((function o(i,a){return Ue().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,et(e,t,n,{onReady:function(t,n){return Ae(Ue().mark((function t(){var r;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.send,t.prev=1,r(e),t.next=8;break;case 5:throw t.prev=5,t.t0=t.catch(1),t.t0;case 8:case"end":return t.stop()}}),t,null,[[1,5]])})))()},onResponse:function(t,n){return Ae(Ue().mark((function r(){var o,s,c;return Ue().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(o=n.close,r.prev=1,"object"==typeof t.data){r.next=4;break}return r.abrupt("return");case 4:s=t.data,c=JSON.parse(s.payload),r.t0=c.type,r.next="APPROVE"===r.t0?9:"DECLINE"===r.t0?12:27;break;case 9:return i(c.data),o(),r.abrupt("break",30);case 12:if("expired"!==c.data){r.next=24;break}if("UP_LOGIN"!==e.type){r.next=15;break}return r.abrupt("return");case 15:if("UP_LOGOUT"!==e.type){r.next=19;break}return i(c.data),o(),r.abrupt("return");case 19:if("UP_TRANSACTION"!==e.type&&"UP_SIGN_MESSAGE"!==e.type){r.next=24;break}return We(!1),a("can not authorize without login"),o(),r.abrupt("break",30);case 24:return a("Declined: "+(c.data||"No reason supplied")),o(),r.abrupt("break",30);case 27:return a("Declined: No reason supplied"),o(),r.abrupt("break",30);case 30:r.next=35;break;case 32:throw r.prev=32,r.t1=r.catch(1),r.t1;case 35:case"end":return r.stop()}}),r,null,[[1,32]])})))()},onMessage:function(e,t){return Ae(Ue().mark((function t(){var n,o;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:if(t.prev=2,"object"==typeof e.data){t.next=5;break}return t.abrupt("return");case 5:n=e.data,o=JSON.parse(n.payload),r(o),t.next=13;break;case 10:throw t.prev=10,t.t0=t.catch(2),t.t0;case 13:case"end":return t.stop()}}),t,null,[[2,10]])})))()},onClose:function(){return Ae(Ue().mark((function e(){return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a("Declined: Externally Halted");case 1:case"end":return e.stop()}}),e)})))()}});case 2:case"end":return o.stop()}}),o)})));return function(e,t){return o.apply(this,arguments)}}())}var ot=function(){var e=Ae(Ue().mark((function e(t,n){var r,o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ze(n.storageType).get(nt),(o=r&&JSON.parse(r))&&t.from&&o.address.toLowerCase()===t.from.toLowerCase()){e.next=4;break}throw new Error("can not authorize without login");case 4:return i=new le("UP_SIGN_MESSAGE",JSON.stringify(t),null==n?void 0:n.appSettings),e.prev=5,e.next=8,rt(i);case 8:return a=e.sent,e.abrupt("return",a);case 12:throw e.prev=12,e.t0=e.catch(5),new Error(e.t0);case 15:case"end":return e.stop()}}),e,null,[[5,12]])})));return function(t,n){return e.apply(this,arguments)}}(),it=function(){var e=Ae(Ue().mark((function e(t,n){var r,o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ze(n.storageType).get(nt),(o=r&&JSON.parse(r))&&t.from&&o.address.toLowerCase()===t.from.toLowerCase()){e.next=4;break}throw new Error("can not authorize without login");case 4:return i=new le("UP_TRANSACTION",JSON.stringify(t),n.appSettings),e.prev=5,e.next=8,rt(i);case 8:return a=e.sent,e.abrupt("return",a);case 12:throw e.prev=12,e.t0=e.catch(5),new Error(e.t0);case 15:case"end":return e.stop()}}),e,null,[[5,12]])})));return function(t,n){return e.apply(this,arguments)}}(),at="0x1626ba7e";var st=function(){function e(e){this.initConfig(e)}var t=e.prototype;return t.initConfig=function(e){this._config={env:"prod",nodeRPC:"",chainType:"polygon",storageType:"sessionStorage"},this._config.env=e.env||"prod",this._config.chainType=e.chainType||"polygon";var t,n,r=(t=this._config.env,n=this._config.chainType,{env:t,nodeRPC:"prod"===t?Fe.mainnet[n]:Fe.testnet[n],chainType:n,walletUrl:"prod"===t?Re:Me});this._config.nodeRPC=e.nodeRPC||r.nodeRPC,this._config.appSettings=function(e,t){return Ce({},t||{},{chain:(null==t?void 0:t.chain)||e,appName:(null==t?void 0:t.appName)||"MyDemo"})}(this._config.chainType,e.appSettings),this._provider=new c(this._config.nodeRPC),this._auth_provider=new c(function(e){return"prod"===e?Fe.mainnet.polygon:Fe.testnet.polygon}(this._config.env));var o,i,a,s=e.walletUrl||r.walletUrl;s&&(i=(o=s).domain,a=o.protocol,Ie={upDomain:i=i||Ne,upConnectUrl:(a=a||"https")+"://"+i+"/connect",upLogoutUrl:a+"://"+i+"/logout",upSignMessageUrl:a+"://"+i+"/sign-message",upTransactionUrl:a+"://"+i+"/send-transaction",upLoadingUrl:a+"://"+i+"/connect/loading"}),this._config.storageType=e.storageType||"sessionStorage"},t.updateConfig=function(e){this._config&&(e.chainType&&(this._config.chainType=e.chainType),e.nodeRPC&&(this._config.nodeRPC=e.nodeRPC,this._provider=new c(this._config.nodeRPC)),e.appSettings&&(this._config.appSettings=e.appSettings))},t.login=function(){var e=Ae(Ue().mark((function e(t){return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Be(this._config,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getAccount=function(){var e,t;return e=this._config.storageType,(t=ze(e).get(nt))?JSON.parse(t):void 0},t.logout=function(){var e=Ae(Ue().mark((function e(t){return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=!1),e.next=3,We(t);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.getProvider=function(){return this._provider},t.getAuthProvider=function(){return this._auth_provider},t.isLogin=function(){return!!this.getAccount()},t.assertLogin=function(){if(!this.isLogin())throw new Error("user is not login")},t.getAddress=function(){return this.assertLogin(),this.getAccount().address},t.sendTransaction=function(){var e=Ae(Ue().mark((function e(t){return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),e.next=3,it(t,this._config);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.signMessage=function(){var e=Ae(Ue().mark((function e(t,n){var r,o,i,a,s;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),o=(r=n||{}).isEIP191Prefix,i=void 0!==o&&o,a=r.onAuthChain,s=void 0===a||a,"string"==typeof t&&(t=he.toUtf8Bytes(t)),e.next=5,ot(new ue(this.getAddress(),he.hexlify(t),"V1",i,s),this._config);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.isValidSignature=function(){var e=Ae(Ue().mark((function e(t,n,r){var o,i;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r||(this.assertLogin(),r=this.getAddress()),o=new te(r,[{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magicValue",type:"bytes4"}],stateMutability:"view",type:"function"}],this._auth_provider),e.next=4,o.isValidSignature(("string"==typeof(a=t)&&(a=he.toUtf8Bytes(a)),he.keccak256(he.concat([he.toUtf8Bytes("UniPass Signed Message:\n"),he.toUtf8Bytes(String(a.length)),a]))),n);case 4:return i=e.sent,e.abrupt("return",i===at);case 6:case"end":return e.stop()}var a}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.signTypedData=function(){var e=Ae(Ue().mark((function e(t,n){var r,o;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.assertLogin(),null!=t){e.next=3;break}throw new Error("Missing data parameter");case 3:return r=(n||{}).onAuthChain,o=void 0===r||r,e.next=6,ot(new ue(this.getAddress(),JSON.stringify(t),"V4",!1,o),this._config);case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.isValidTypedSignature=function(){var e=Ae(Ue().mark((function e(t,n,r){var o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new Error("Missing data parameter");case 2:return n||(this.assertLogin(),n=this.getAddress()),o=new te(n,[{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magicValue",type:"bytes4"}],stateMutability:"view",type:"function"}],this._auth_provider),i=fe(t),e.next=7,o.isValidSignature(i,r);case 7:return a=e.sent,e.abrupt("return",a===at);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),e}();function ct(e){if(e.error){const t=new Error(e.error.message);throw t.code=e.error.code,t.data=e.error.data,t}return e.result}function ut(t){var n,r,s;return e(this,void 0,void 0,(function*(){const u=null!==(n=t.chainId)&&void 0!==n?n:1;let l=null!==(r=t.rpcUrl)&&void 0!==r?r:null===(s=t.rpc)||void 0===s?void 0:s[u];const d=new class extends c{constructor(e,n){super(e,n),this.updateUpWalletConfig=e=>{var n;const r=null===(n=t.rpc)||void 0===n?void 0:n[e];if(!o.includes(e)||!r)throw new Error(`chainId ${e} not supported`);return this.upWallet.updateConfig({chainType:i(e),nodeRPC:r,appSettings:{chain:i(e)}}),this.chainId=e,this.rpcUrl=r,this.emit("chainChanged",`0x${e.toString(16)}`),{result:!0}},this.rpcUrl=e,this.chainId=u,this.upWallet=new st({env:a(u),chainType:i(u),appSettings:{appIcon:t.appLogoUrl,appName:t.appName,chain:i(u)},rpcUrl:l,storageType:"sessionStorage"})}getSigner(){var e;const t=this.upWallet.getAccount();return new se(d,this.upWallet,null!==(e=null==t?void 0:t.address)&&void 0!==e?e:"",0)}connect(){return e(this,void 0,void 0,(function*(){const e=this.upWallet.getAccount();return e||(yield this.upWallet.login({email:false}))}))}disconnect(){return e(this,void 0,void 0,(function*(){yield this.upWallet.logout()}))}listAccounts(){return e(this,void 0,void 0,(function*(){const e=this.upWallet.getAccount();return(null==e?void 0:e.address)?[null==e?void 0:e.address]:[]}))}getAddress(){const e=this.upWallet.getAccount();return Promise.resolve((null==e?void 0:e.address)?p(null==e?void 0:e.address):null)}send(e,t){const n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:$(n),provider:this});const r=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(r&&this._cache[e])return this._cache[e];const o=ee({url:this.rpcUrl},JSON.stringify(n),ct).then((e=>(this.emit("debug",{action:"response",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:n,provider:this}),e}));return r&&(this._cache[e]=o,setTimeout((()=>{this._cache[e]=null}),0)),o}}(l);return d}))}function pt(t,n){return e(this,void 0,void 0,(function*(){const e=yield ut(t);return e.on("connect",n.connect),e.on("disconnect",(e=>{n.disconnect(e),n.accountsChanged([])})),e.on("accountsChanged",n.accountsChanged),e.on("chainChanged",n.chainChanged),e.on("message",(({type:e,data:t})=>n.message(e,t))),yield e.connect(),e}))}function lt(){var e;null===(e=s.getState().provider)||void 0===e||e.disconnect()}function dt(e){var t,n;return null===(n=null===(t=s.getState().provider)||void 0===t?void 0:t.upWallet)||void 0===n?void 0:n.signTypedData(e)}function ft(e){var t;const n=e.addChainParameters.chainId,r="string"==typeof n&&(null==n?void 0:n.startsWith("0x"))?parseInt(n,16):Number(n);if(!o.includes(r))throw new Error(`chainId ${r} not supported`);return null===(t=s.getState().provider)||void 0===t?void 0:t.updateUpWalletConfig(r)}export{ut as createProvider,pt as default,lt as disconnectWallet,dt as signTypedData,ft as switchChain};
|
|
1
|
+
import{_ as e,g as t,r as n,c as r,S as o,t as i,v as a,u as s}from"./index-f538e2f0.js";import{JsonRpcProvider as c}from"@ethersproject/providers";import u,{getAddress as p}from"@ethersproject/address";import{Signer as l}from"@ethersproject/abstract-signer";import d,{arrayify as f}from"@ethersproject/bytes";import{T as h}from"./typed-data-9988323b.js";import{r as g}from"./index-46feeec1.js";import{f as y,p as m,n as b,d as v,b as w,i as P,c as x,m as O,h as j,g as _,r as S,s as E,j as k,S as T,k as U,o as L,q as A,t as C,x as N,y as I,z as D,A as M,B as R}from"./ethers-2313fc7c.js";import{d as F,t as z,c as B,a as W,e as G,f as V,U as J,i as H,l as K}from"./id-fe4b4d37.js";import Z from"@ethersproject/json-wallets";import q,{deepCopy as $}from"@ethersproject/properties";import{l as Y}from"./index-b5e7ed2d.js";import Q from"@ethersproject/transactions";import{l as X,f as ee}from"./index-91e932a7.js";import{Contract as te}from"@ethersproject/contracts";import"zustand";import"events";import"@ethersproject/constants";import"./interface-0693e0ec.js";import"@ethersproject/abstract-provider";import"./__node-resolve_empty-7f3920c0.js";import"./hash-a9ebd52a.js";import"./inherits_browser-06ba108b.js";var ne,re=Object.freeze({__proto__:null,_toEscapedUtf8String:F,toUtf8Bytes:z,toUtf8CodePoints:B,toUtf8String:W,Utf8ErrorFuncs:G,get Utf8ErrorReason(){return V},get UnicodeNormalizationForm(){return J},formatBytes32String:y,parseBytes32String:m,nameprep:b}),oe=Object.freeze({__proto__:null,id:H,dnsEncode:v,namehash:w,isValidName:P,ensNormalize:x,messagePrefix:O,hashMessage:j,_TypedDataEncoder:h}),ie=Object.freeze({__proto__:null,computeHmac:_,ripemd160:S,sha256:E,sha512:k,get SupportedAlgorithm(){return T}}),ae=Object.freeze({__proto__:null,randomBytes:U,shuffled:L});class se extends l{constructor(e,t,n,r){super(),this._address=n,this._index=null!=r?r:0,this.provider=e,this.upWallet=t}_legacySignMessage(e){throw new Error("Method not implemented.")}sendUncheckedTransaction(e){throw new Error("Method not implemented.")}unlock(e){throw new Error("Method not implemented.")}getAddress(){return e(this,void 0,void 0,(function*(){return Promise.resolve(p(this._address))}))}signMessage(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t}'`);return yield this.upWallet.signMessage(t,{isEIP191Prefix:!0,onAuthChain:!0})}))}_signTypedData(t,n,r){return e(this,void 0,void 0,(function*(){throw new Error("Method not implemented.")}))}signTransaction(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t.from}'`);return this.upWallet.sendTransaction({from:t.from,to:t.to,value:t.value,data:t.data})}))}sendTransaction(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t.from}'`);return{hash:yield this.upWallet.sendTransaction({from:t.from,to:t.to,value:t.value,data:t.data}),from:t.from}}))}connect(e){return new se(null!=e?e:this.provider,this.upWallet,this._address,this._index)}connectUnchecked(){return new se(this.provider,this.upWallet,this._address,this._index)}}!function(e){e.REGISTER="register"}(ne||(ne={}));var ce,ue=function(e,t,n,r,o){this.from=e,this.msg=t,this.type=n,this.isEIP191Prefix=r,this.onAuthChain=o},pe=function(e,t){this.type=e,this.data=t},le=function(e,t,n){this.type=e,this.payload=t,this.appSetting=n};function de(){return de=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},de.apply(this,arguments)}!function(e){e.LIGHT="light",e.DARK="dark"}(ce||(ce={}));var fe=function(e){return f(function(e){var t=de({},e.types);return delete t.EIP712Domain,h.hash(e.domain,t,e.message)}(e))},he={},ge=t(A),ye=t(C),me=t(oe),be=t(N),ve=t(n),we=t(K),Pe=t(ie),xe=t(I),Oe=t(ae),je=t(Y),_e=t(D),Se=t(re),Ee=t(M),ke=t(R),Te=t(X);function Ue(){Ue=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,o){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype),s=new _(o||[]);return r(a,"_invoke",{value:P(e,n,s)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function d(){}function f(){}function h(){}var g={};c(g,i,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(S([])));m&&m!==t&&n.call(m,i)&&(g=m);var b=h.prototype=d.prototype=Object.create(g);function v(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function o(r,i,a,s){var c=p(e[r],e,i);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){o("next",e,a,s)}),(function(e){o("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return o("throw",e,a,s)}))}s(c.arg)}var i;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){o(e,n,t,r)}))}return i=i?i.then(r,r):r()}})}function P(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return E()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=x(a,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=p(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function x(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var o=p(r,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,l;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function j(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return f.prototype=h,r(b,"constructor",{value:h,configurable:!0}),r(h,"constructor",{value:f,configurable:!0}),f.displayName=c(h,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,c(e,s,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},v(w.prototype),c(w.prototype,a,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new w(u(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(b),c(b,s,"Generator"),c(b,i,(function(){return this})),c(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),j(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;j(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}function Le(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function Ae(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Le(i,r,o,a,s,"next",e)}function s(e){Le(i,r,o,a,s,"throw",e)}a(void 0)}))}}function Ce(){return Ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ce.apply(this,arguments)}!function(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=r&&r.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&t(r,e,o);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.formatBytes32String=e.Utf8ErrorFuncs=e.toUtf8String=e.toUtf8CodePoints=e.toUtf8Bytes=e._toEscapedUtf8String=e.nameprep=e.hexDataSlice=e.hexDataLength=e.hexZeroPad=e.hexValue=e.hexStripZeros=e.hexConcat=e.isHexString=e.hexlify=e.base64=e.base58=e.TransactionDescription=e.LogDescription=e.Interface=e.SigningKey=e.HDNode=e.defaultPath=e.isBytesLike=e.isBytes=e.zeroPad=e.stripZeros=e.concat=e.arrayify=e.shallowCopy=e.resolveProperties=e.getStatic=e.defineReadOnly=e.deepCopy=e.checkProperties=e.poll=e.fetchJson=e._fetchData=e.RLP=e.Logger=e.checkResultErrors=e.FormatTypes=e.ParamType=e.FunctionFragment=e.EventFragment=e.ErrorFragment=e.ConstructorFragment=e.Fragment=e.defaultAbiCoder=e.AbiCoder=void 0,e.Indexed=e.Utf8ErrorReason=e.UnicodeNormalizationForm=e.SupportedAlgorithm=e.mnemonicToSeed=e.isValidMnemonic=e.entropyToMnemonic=e.mnemonicToEntropy=e.getAccountPath=e.verifyTypedData=e.verifyMessage=e.recoverPublicKey=e.computePublicKey=e.recoverAddress=e.computeAddress=e.getJsonWalletAddress=e.TransactionTypes=e.serializeTransaction=e.parseTransaction=e.accessListify=e.joinSignature=e.splitSignature=e.soliditySha256=e.solidityKeccak256=e.solidityPack=e.shuffled=e.randomBytes=e.sha512=e.sha256=e.ripemd160=e.keccak256=e.computeHmac=e.commify=e.parseUnits=e.formatUnits=e.parseEther=e.formatEther=e.isAddress=e.getCreate2Address=e.getContractAddress=e.getIcapAddress=e.getAddress=e._TypedDataEncoder=e.id=e.isValidName=e.namehash=e.hashMessage=e.dnsEncode=e.parseBytes32String=void 0;var i=g;Object.defineProperty(e,"AbiCoder",{enumerable:!0,get:function(){return i.AbiCoder}}),Object.defineProperty(e,"checkResultErrors",{enumerable:!0,get:function(){return i.checkResultErrors}}),Object.defineProperty(e,"ConstructorFragment",{enumerable:!0,get:function(){return i.ConstructorFragment}}),Object.defineProperty(e,"defaultAbiCoder",{enumerable:!0,get:function(){return i.defaultAbiCoder}}),Object.defineProperty(e,"ErrorFragment",{enumerable:!0,get:function(){return i.ErrorFragment}}),Object.defineProperty(e,"EventFragment",{enumerable:!0,get:function(){return i.EventFragment}}),Object.defineProperty(e,"FormatTypes",{enumerable:!0,get:function(){return i.FormatTypes}}),Object.defineProperty(e,"Fragment",{enumerable:!0,get:function(){return i.Fragment}}),Object.defineProperty(e,"FunctionFragment",{enumerable:!0,get:function(){return i.FunctionFragment}}),Object.defineProperty(e,"Indexed",{enumerable:!0,get:function(){return i.Indexed}}),Object.defineProperty(e,"Interface",{enumerable:!0,get:function(){return i.Interface}}),Object.defineProperty(e,"LogDescription",{enumerable:!0,get:function(){return i.LogDescription}}),Object.defineProperty(e,"ParamType",{enumerable:!0,get:function(){return i.ParamType}}),Object.defineProperty(e,"TransactionDescription",{enumerable:!0,get:function(){return i.TransactionDescription}});var a=u;Object.defineProperty(e,"getAddress",{enumerable:!0,get:function(){return a.getAddress}}),Object.defineProperty(e,"getCreate2Address",{enumerable:!0,get:function(){return a.getCreate2Address}}),Object.defineProperty(e,"getContractAddress",{enumerable:!0,get:function(){return a.getContractAddress}}),Object.defineProperty(e,"getIcapAddress",{enumerable:!0,get:function(){return a.getIcapAddress}}),Object.defineProperty(e,"isAddress",{enumerable:!0,get:function(){return a.isAddress}});var s=o(ge);e.base64=s;var c=ye;Object.defineProperty(e,"base58",{enumerable:!0,get:function(){return c.Base58}});var p=d;Object.defineProperty(e,"arrayify",{enumerable:!0,get:function(){return p.arrayify}}),Object.defineProperty(e,"concat",{enumerable:!0,get:function(){return p.concat}}),Object.defineProperty(e,"hexConcat",{enumerable:!0,get:function(){return p.hexConcat}}),Object.defineProperty(e,"hexDataSlice",{enumerable:!0,get:function(){return p.hexDataSlice}}),Object.defineProperty(e,"hexDataLength",{enumerable:!0,get:function(){return p.hexDataLength}}),Object.defineProperty(e,"hexlify",{enumerable:!0,get:function(){return p.hexlify}}),Object.defineProperty(e,"hexStripZeros",{enumerable:!0,get:function(){return p.hexStripZeros}}),Object.defineProperty(e,"hexValue",{enumerable:!0,get:function(){return p.hexValue}}),Object.defineProperty(e,"hexZeroPad",{enumerable:!0,get:function(){return p.hexZeroPad}}),Object.defineProperty(e,"isBytes",{enumerable:!0,get:function(){return p.isBytes}}),Object.defineProperty(e,"isBytesLike",{enumerable:!0,get:function(){return p.isBytesLike}}),Object.defineProperty(e,"isHexString",{enumerable:!0,get:function(){return p.isHexString}}),Object.defineProperty(e,"joinSignature",{enumerable:!0,get:function(){return p.joinSignature}}),Object.defineProperty(e,"zeroPad",{enumerable:!0,get:function(){return p.zeroPad}}),Object.defineProperty(e,"splitSignature",{enumerable:!0,get:function(){return p.splitSignature}}),Object.defineProperty(e,"stripZeros",{enumerable:!0,get:function(){return p.stripZeros}});var l=me;Object.defineProperty(e,"_TypedDataEncoder",{enumerable:!0,get:function(){return l._TypedDataEncoder}}),Object.defineProperty(e,"dnsEncode",{enumerable:!0,get:function(){return l.dnsEncode}}),Object.defineProperty(e,"hashMessage",{enumerable:!0,get:function(){return l.hashMessage}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return l.id}}),Object.defineProperty(e,"isValidName",{enumerable:!0,get:function(){return l.isValidName}}),Object.defineProperty(e,"namehash",{enumerable:!0,get:function(){return l.namehash}});var f=be;Object.defineProperty(e,"defaultPath",{enumerable:!0,get:function(){return f.defaultPath}}),Object.defineProperty(e,"entropyToMnemonic",{enumerable:!0,get:function(){return f.entropyToMnemonic}}),Object.defineProperty(e,"getAccountPath",{enumerable:!0,get:function(){return f.getAccountPath}}),Object.defineProperty(e,"HDNode",{enumerable:!0,get:function(){return f.HDNode}}),Object.defineProperty(e,"isValidMnemonic",{enumerable:!0,get:function(){return f.isValidMnemonic}}),Object.defineProperty(e,"mnemonicToEntropy",{enumerable:!0,get:function(){return f.mnemonicToEntropy}}),Object.defineProperty(e,"mnemonicToSeed",{enumerable:!0,get:function(){return f.mnemonicToSeed}});var h=Z;Object.defineProperty(e,"getJsonWalletAddress",{enumerable:!0,get:function(){return h.getJsonWalletAddress}});var y=ve;Object.defineProperty(e,"keccak256",{enumerable:!0,get:function(){return y.keccak256}});var m=we;Object.defineProperty(e,"Logger",{enumerable:!0,get:function(){return m.Logger}});var b=Pe;Object.defineProperty(e,"computeHmac",{enumerable:!0,get:function(){return b.computeHmac}}),Object.defineProperty(e,"ripemd160",{enumerable:!0,get:function(){return b.ripemd160}}),Object.defineProperty(e,"sha256",{enumerable:!0,get:function(){return b.sha256}}),Object.defineProperty(e,"sha512",{enumerable:!0,get:function(){return b.sha512}});var v=xe;Object.defineProperty(e,"solidityKeccak256",{enumerable:!0,get:function(){return v.keccak256}}),Object.defineProperty(e,"solidityPack",{enumerable:!0,get:function(){return v.pack}}),Object.defineProperty(e,"soliditySha256",{enumerable:!0,get:function(){return v.sha256}});var w=Oe;Object.defineProperty(e,"randomBytes",{enumerable:!0,get:function(){return w.randomBytes}}),Object.defineProperty(e,"shuffled",{enumerable:!0,get:function(){return w.shuffled}});var P=q;Object.defineProperty(e,"checkProperties",{enumerable:!0,get:function(){return P.checkProperties}}),Object.defineProperty(e,"deepCopy",{enumerable:!0,get:function(){return P.deepCopy}}),Object.defineProperty(e,"defineReadOnly",{enumerable:!0,get:function(){return P.defineReadOnly}}),Object.defineProperty(e,"getStatic",{enumerable:!0,get:function(){return P.getStatic}}),Object.defineProperty(e,"resolveProperties",{enumerable:!0,get:function(){return P.resolveProperties}}),Object.defineProperty(e,"shallowCopy",{enumerable:!0,get:function(){return P.shallowCopy}});var x=o(je);e.RLP=x;var O=_e;Object.defineProperty(e,"computePublicKey",{enumerable:!0,get:function(){return O.computePublicKey}}),Object.defineProperty(e,"recoverPublicKey",{enumerable:!0,get:function(){return O.recoverPublicKey}}),Object.defineProperty(e,"SigningKey",{enumerable:!0,get:function(){return O.SigningKey}});var j=Se;Object.defineProperty(e,"formatBytes32String",{enumerable:!0,get:function(){return j.formatBytes32String}}),Object.defineProperty(e,"nameprep",{enumerable:!0,get:function(){return j.nameprep}}),Object.defineProperty(e,"parseBytes32String",{enumerable:!0,get:function(){return j.parseBytes32String}}),Object.defineProperty(e,"_toEscapedUtf8String",{enumerable:!0,get:function(){return j._toEscapedUtf8String}}),Object.defineProperty(e,"toUtf8Bytes",{enumerable:!0,get:function(){return j.toUtf8Bytes}}),Object.defineProperty(e,"toUtf8CodePoints",{enumerable:!0,get:function(){return j.toUtf8CodePoints}}),Object.defineProperty(e,"toUtf8String",{enumerable:!0,get:function(){return j.toUtf8String}}),Object.defineProperty(e,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return j.Utf8ErrorFuncs}});var _=Q;Object.defineProperty(e,"accessListify",{enumerable:!0,get:function(){return _.accessListify}}),Object.defineProperty(e,"computeAddress",{enumerable:!0,get:function(){return _.computeAddress}}),Object.defineProperty(e,"parseTransaction",{enumerable:!0,get:function(){return _.parse}}),Object.defineProperty(e,"recoverAddress",{enumerable:!0,get:function(){return _.recoverAddress}}),Object.defineProperty(e,"serializeTransaction",{enumerable:!0,get:function(){return _.serialize}}),Object.defineProperty(e,"TransactionTypes",{enumerable:!0,get:function(){return _.TransactionTypes}});var S=Ee;Object.defineProperty(e,"commify",{enumerable:!0,get:function(){return S.commify}}),Object.defineProperty(e,"formatEther",{enumerable:!0,get:function(){return S.formatEther}}),Object.defineProperty(e,"parseEther",{enumerable:!0,get:function(){return S.parseEther}}),Object.defineProperty(e,"formatUnits",{enumerable:!0,get:function(){return S.formatUnits}}),Object.defineProperty(e,"parseUnits",{enumerable:!0,get:function(){return S.parseUnits}});var E=ke;Object.defineProperty(e,"verifyMessage",{enumerable:!0,get:function(){return E.verifyMessage}}),Object.defineProperty(e,"verifyTypedData",{enumerable:!0,get:function(){return E.verifyTypedData}});var k=Te;Object.defineProperty(e,"_fetchData",{enumerable:!0,get:function(){return k._fetchData}}),Object.defineProperty(e,"fetchJson",{enumerable:!0,get:function(){return k.fetchJson}}),Object.defineProperty(e,"poll",{enumerable:!0,get:function(){return k.poll}});var T=Pe;Object.defineProperty(e,"SupportedAlgorithm",{enumerable:!0,get:function(){return T.SupportedAlgorithm}});var U=Se;Object.defineProperty(e,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return U.UnicodeNormalizationForm}}),Object.defineProperty(e,"Utf8ErrorReason",{enumerable:!0,get:function(){return U.Utf8ErrorReason}})}(he);var Ne="wallet.unipass.id",Ie={upDomain:Ne,upConnectUrl:"https://"+Ne+"/connect",upLogoutUrl:"https://"+Ne+"/logout",upSignMessageUrl:"https://"+Ne+"/sign-message",upTransactionUrl:"https://"+Ne+"/send-transaction",upLoadingUrl:"https://"+Ne+"/connect/loading"},De=function(){return Ie},Me={protocol:"https",domain:"testnet.wallet.unipass.id"},Re={protocol:"https",domain:"wallet.unipass.id"},Fe={mainnet:{eth:"https://node.wallet.unipass.id/eth-mainnet",polygon:"https://node.wallet.unipass.id/polygon-mainnet",bsc:"https://node.wallet.unipass.id/bsc-mainnet",rangers:"https://node.wallet.unipass.id/rangers-mainnet",scroll:"https://node.wallet.unipass.id/scroll-mainnet",arbitrum:"https://node.wallet.unipass.id/arbitrum-mainnet",avalanche:"https://node.wallet.unipass.id/avalanche-mainnet",kcc:"https://node.wallet.unipass.id/kcc-mainnet",platon:"https://node.wallet.unipass.id/platon-mainnet",okc:"https://node.wallet.unipass.id/okc-mainnet"},testnet:{eth:"https://node.wallet.unipass.id/eth-goerli",polygon:"https://node.wallet.unipass.id/polygon-mumbai",bsc:"https://node.wallet.unipass.id/bsc-testnet",rangers:"https://node.wallet.unipass.id/rangers-robin",scroll:"https://node.wallet.unipass.id/scroll-testnet",arbitrum:"https://node.wallet.unipass.id/arbitrum-testnet",avalanche:"https://node.wallet.unipass.id/avalanche-testnet",kcc:"https://node.wallet.unipass.id/kcc-testnet",platon:"https://node.wallet.unipass.id/platon-testnet",okc:"https://node.wallet.unipass.id/okc-testnet"}},ze=function(e){var t;t="localStorage"===e?window.localStorage||localStorage:window.sessionStorage||sessionStorage;return{get:function(e){return t.getItem(e)||""},set:function(e,n){return t.setItem(e,n||"")},remove:function(e){return t.removeItem(e)}}},Be=function(){var e=Ae(Ue().mark((function e(t,n){var r,o;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ze(t.storageType).get(nt),e.t0=r&&JSON.parse(r),e.t0){e.next=6;break}return e.next=5,Ge(t,n);case 5:e.t0=e.sent;case 6:return o=e.t0,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),We=function(){var e=Ae(Ue().mark((function e(t){var n;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=4;break}return n=new le("UP_LOGOUT"),e.next=4,rt(n);case 4:ze("localStorage").remove(nt),ze("sessionStorage").remove(nt);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ge=function(){var e=Ae(Ue().mark((function e(t,n){var r,o,i;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=n?JSON.stringify(n):"",o=new le("UP_LOGIN",r,t.appSettings),e.next=5,rt(o,null==n?void 0:n.connectType,null==n?void 0:n.forceLogin,null==n?void 0:n.eventListener);case 5:return(i=e.sent)&&i.address&&ze(t.storageType).set(nt,JSON.stringify(i)),e.abrupt("return",i);case 10:throw e.prev=10,e.t0=e.catch(0),new Error("Account Not Available");case 13:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(t,n){return e.apply(this,arguments)}}(),Ve="UP_WALLET_POP",Je=null,He=null;function Ke(e,t,n){var r="innerWidth=462,width=462,innerHeight=810,height=810,top="+.5*(n.screen.availHeight-30-810)+",left="+.8*(n.screen.availWidth-10-462)+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,";return n.open(e,t,r)}function Ze(e,t,n){return qe.apply(this,arguments)}function qe(){return(qe=Ae(Ue().mark((function e(t,n,r){var o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(null==Je||null!=(o=Je)&&o.closed)){e.next=8;break}if(null!=(Je=Ke(t,Ve,window))){e.next=6;break}return e.next=5,$e(t,n,r);case 5:return e.abrupt("return",e.sent);case 6:e.next=9;break;case 8:He!==t?(Je.location.replace(t),Je.focus()):Je.focus();case 9:return i=setInterval((function(){if(Je&&Je.closed){var e={data:new le("UP_RESPONSE",JSON.stringify(new pe("DECLINE","user reject connection")))};n(e,{close:function(){},send:function(){}}),clearInterval(i)}}),1e3),a=function(){Je&&!Je.closed&&Je.close(),Je=null},e.abrupt("return",{popup:Je,unmount:a});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $e(e,t,n){return Ye.apply(this,arguments)}function Ye(){return(Ye=Ae(Ue().mark((function e(t,n,r){var o,i;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=document.createElement("div"),'\n <div\n class="up_notification"\n style="\n position: fixed;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n top: 26px;\n right: 26px;\n width: 340px;\n height: 96px;\n z-index: 100001;\n background-color: #362866;\n box-sizing: border-box;\n border: 2px solid #ffffff;\n border-radius: 8px;\n padding: 16px 20px;\n "\n>\n <div class="up_notification_left" style="color: white">\n <div\n class="up_notification_title"\n style="\n font-weight: 500;\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 8px;\n "\n >\n Request Pop-up\n </div>\n <div\n class="up_notification_tip"\n style="\n font-weight: 450;\n font-size: 12px;\n line-height: 20px;\n color: rgba(255, 255, 255, 0.8);\n "\n >\n Click Approve to complete creating or using wallet\n </div>\n </div>\n <div\n class="up_notification_right"\n style="\n width: 90px;\n height: 35px;\n font-size: 12px;\n text-align: center;\n background: linear-gradient(270deg, #997afb 0%, #7a55f8 63.6%);\n border-radius: 6px;\n line-height: 35px;\n color: white;\n margin-left: 20px;\n cursor: pointer;\n "\n >\n Approve\n </div>\n</div>\n ',o.innerHTML='\n <div\n class="up_notification"\n style="\n position: fixed;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n top: 26px;\n right: 26px;\n width: 340px;\n height: 96px;\n z-index: 100001;\n background-color: #362866;\n box-sizing: border-box;\n border: 2px solid #ffffff;\n border-radius: 8px;\n padding: 16px 20px;\n "\n>\n <div class="up_notification_left" style="color: white">\n <div\n class="up_notification_title"\n style="\n font-weight: 500;\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 8px;\n "\n >\n Request Pop-up\n </div>\n <div\n class="up_notification_tip"\n style="\n font-weight: 450;\n font-size: 12px;\n line-height: 20px;\n color: rgba(255, 255, 255, 0.8);\n "\n >\n Click Approve to complete creating or using wallet\n </div>\n </div>\n <div\n class="up_notification_right"\n style="\n width: 90px;\n height: 35px;\n font-size: 12px;\n text-align: center;\n background: linear-gradient(270deg, #997afb 0%, #7a55f8 63.6%);\n border-radius: 6px;\n line-height: 35px;\n color: white;\n margin-left: 20px;\n cursor: pointer;\n "\n >\n Approve\n </div>\n</div>\n ',document.body.appendChild(o),i=document.querySelector(".up_notification_right"),e.abrupt("return",new Promise((function(e){null==i||i.addEventListener("click",(function(){document.body.removeChild(o),e(Ze(t,n,r))}),!1)})));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Qe=function(){};function Xe(e,t,n){if("UP_LOGIN"===e)return"google"===t?De().upConnectUrl+"?connectType=google&forceLogin="+(n?"1":"0"):"email"===t?De().upConnectUrl+"?connectType=email&forceLogin="+(n?"1":"0"):De().upConnectUrl+"?forceLogin="+(n?"1":"0");if("UP_LOGOUT"===e)return De().upLogoutUrl;if("UP_SIGN_MESSAGE"===e)return De().upSignMessageUrl;if("UP_TRANSACTION"===e)return De().upTransactionUrl;if("UP_READY"===e)return De().upLoadingUrl;throw new Error("unsupport type "+e)}function et(e,t,n,r){return tt.apply(this,arguments)}function tt(){return tt=Ae(Ue().mark((function e(t,n,r,o){var i,a,s,c,u,p,l,d,f,h;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h=function(e){try{null==p||p.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Popup Send Error",e,t)}},f=function(){try{window.removeEventListener("message",d),l(),i()}catch(e){console.error("Popup Close Error",e)}},d=function(e){try{if("object"!=typeof e.data)return;var t=e.data;if(!t||!t.type)return;"UP_CLOSE"===e.data.type&&f(),"UP_READY"===t.type&&s(e,{send:h,close:f}),"UP_RESPONSE"===t.type&&c(e,{send:h,close:f}),"UP_EVENT"===t.type&&a(e,{send:h,close:f})}catch(e){console.error("Popup Callback Error",e),f()}},null!=t){e.next=5;break}return e.abrupt("return",{send:Qe,close:Qe});case 5:return i=(null==o?void 0:o.onClose)||Qe,a=(null==o?void 0:o.onMessage)||Qe,s=(null==o?void 0:o.onReady)||Qe,c=(null==o?void 0:o.onResponse)||Qe,window.addEventListener("message",d),e.next=12,Ze(Xe(t.type,n,r),c,t.appSetting);case 12:return u=e.sent,p=u.popup,l=u.unmount,e.abrupt("return",{send:h,close:f});case 16:case"end":return e.stop()}}),e)}))),tt.apply(this,arguments)}var nt="UP-A";function rt(e,t,n,r){return new Promise(function(){var o=Ae(Ue().mark((function o(i,a){return Ue().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,et(e,t,n,{onReady:function(t,n){return Ae(Ue().mark((function t(){var r;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.send,t.prev=1,r(e),t.next=8;break;case 5:throw t.prev=5,t.t0=t.catch(1),t.t0;case 8:case"end":return t.stop()}}),t,null,[[1,5]])})))()},onResponse:function(t,n){return Ae(Ue().mark((function r(){var o,s,c;return Ue().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(o=n.close,r.prev=1,"object"==typeof t.data){r.next=4;break}return r.abrupt("return");case 4:s=t.data,c=JSON.parse(s.payload),r.t0=c.type,r.next="APPROVE"===r.t0?9:"DECLINE"===r.t0?12:27;break;case 9:return i(c.data),o(),r.abrupt("break",30);case 12:if("expired"!==c.data){r.next=24;break}if("UP_LOGIN"!==e.type){r.next=15;break}return r.abrupt("return");case 15:if("UP_LOGOUT"!==e.type){r.next=19;break}return i(c.data),o(),r.abrupt("return");case 19:if("UP_TRANSACTION"!==e.type&&"UP_SIGN_MESSAGE"!==e.type){r.next=24;break}return We(!1),a("can not authorize without login"),o(),r.abrupt("break",30);case 24:return a("Declined: "+(c.data||"No reason supplied")),o(),r.abrupt("break",30);case 27:return a("Declined: No reason supplied"),o(),r.abrupt("break",30);case 30:r.next=35;break;case 32:throw r.prev=32,r.t1=r.catch(1),r.t1;case 35:case"end":return r.stop()}}),r,null,[[1,32]])})))()},onMessage:function(e,t){return Ae(Ue().mark((function t(){var n,o;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:if(t.prev=2,"object"==typeof e.data){t.next=5;break}return t.abrupt("return");case 5:n=e.data,o=JSON.parse(n.payload),r(o),t.next=13;break;case 10:throw t.prev=10,t.t0=t.catch(2),t.t0;case 13:case"end":return t.stop()}}),t,null,[[2,10]])})))()},onClose:function(){return Ae(Ue().mark((function e(){return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a("Declined: Externally Halted");case 1:case"end":return e.stop()}}),e)})))()}});case 2:case"end":return o.stop()}}),o)})));return function(e,t){return o.apply(this,arguments)}}())}var ot=function(){var e=Ae(Ue().mark((function e(t,n){var r,o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ze(n.storageType).get(nt),(o=r&&JSON.parse(r))&&t.from&&o.address.toLowerCase()===t.from.toLowerCase()){e.next=4;break}throw new Error("can not authorize without login");case 4:return i=new le("UP_SIGN_MESSAGE",JSON.stringify(t),null==n?void 0:n.appSettings),e.prev=5,e.next=8,rt(i);case 8:return a=e.sent,e.abrupt("return",a);case 12:throw e.prev=12,e.t0=e.catch(5),new Error(e.t0);case 15:case"end":return e.stop()}}),e,null,[[5,12]])})));return function(t,n){return e.apply(this,arguments)}}(),it=function(){var e=Ae(Ue().mark((function e(t,n){var r,o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ze(n.storageType).get(nt),(o=r&&JSON.parse(r))&&t.from&&o.address.toLowerCase()===t.from.toLowerCase()){e.next=4;break}throw new Error("can not authorize without login");case 4:return i=new le("UP_TRANSACTION",JSON.stringify(t),n.appSettings),e.prev=5,e.next=8,rt(i);case 8:return a=e.sent,e.abrupt("return",a);case 12:throw e.prev=12,e.t0=e.catch(5),new Error(e.t0);case 15:case"end":return e.stop()}}),e,null,[[5,12]])})));return function(t,n){return e.apply(this,arguments)}}(),at="0x1626ba7e";var st=function(){function e(e){this.initConfig(e)}var t=e.prototype;return t.initConfig=function(e){this._config={env:"prod",nodeRPC:"",chainType:"polygon",storageType:"sessionStorage"},this._config.env=e.env||"prod",this._config.chainType=e.chainType||"polygon";var t,n,r=(t=this._config.env,n=this._config.chainType,{env:t,nodeRPC:"prod"===t?Fe.mainnet[n]:Fe.testnet[n],chainType:n,walletUrl:"prod"===t?Re:Me});this._config.nodeRPC=e.nodeRPC||r.nodeRPC,this._config.appSettings=function(e,t){return Ce({},t||{},{chain:(null==t?void 0:t.chain)||e,appName:(null==t?void 0:t.appName)||"MyDemo"})}(this._config.chainType,e.appSettings),this._provider=new c(this._config.nodeRPC),this._auth_provider=new c(function(e){return"prod"===e?Fe.mainnet.polygon:Fe.testnet.polygon}(this._config.env));var o,i,a,s=e.walletUrl||r.walletUrl;s&&(i=(o=s).domain,a=o.protocol,Ie={upDomain:i=i||Ne,upConnectUrl:(a=a||"https")+"://"+i+"/connect",upLogoutUrl:a+"://"+i+"/logout",upSignMessageUrl:a+"://"+i+"/sign-message",upTransactionUrl:a+"://"+i+"/send-transaction",upLoadingUrl:a+"://"+i+"/connect/loading"}),this._config.storageType=e.storageType||"sessionStorage"},t.updateConfig=function(e){this._config&&(e.chainType&&(this._config.chainType=e.chainType),e.nodeRPC&&(this._config.nodeRPC=e.nodeRPC,this._provider=new c(this._config.nodeRPC)),e.appSettings&&(this._config.appSettings=e.appSettings))},t.login=function(){var e=Ae(Ue().mark((function e(t){return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Be(this._config,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getAccount=function(){var e,t;return e=this._config.storageType,(t=ze(e).get(nt))?JSON.parse(t):void 0},t.logout=function(){var e=Ae(Ue().mark((function e(t){return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=!1),e.next=3,We(t);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.getProvider=function(){return this._provider},t.getAuthProvider=function(){return this._auth_provider},t.isLogin=function(){return!!this.getAccount()},t.assertLogin=function(){if(!this.isLogin())throw new Error("user is not login")},t.getAddress=function(){return this.assertLogin(),this.getAccount().address},t.sendTransaction=function(){var e=Ae(Ue().mark((function e(t){return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),e.next=3,it(t,this._config);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.signMessage=function(){var e=Ae(Ue().mark((function e(t,n){var r,o,i,a,s;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),o=(r=n||{}).isEIP191Prefix,i=void 0!==o&&o,a=r.onAuthChain,s=void 0===a||a,"string"==typeof t&&(t=he.toUtf8Bytes(t)),e.next=5,ot(new ue(this.getAddress(),he.hexlify(t),"V1",i,s),this._config);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.isValidSignature=function(){var e=Ae(Ue().mark((function e(t,n,r){var o,i;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r||(this.assertLogin(),r=this.getAddress()),o=new te(r,[{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magicValue",type:"bytes4"}],stateMutability:"view",type:"function"}],this._auth_provider),e.next=4,o.isValidSignature(("string"==typeof(a=t)&&(a=he.toUtf8Bytes(a)),he.keccak256(he.concat([he.toUtf8Bytes("UniPass Signed Message:\n"),he.toUtf8Bytes(String(a.length)),a]))),n);case 4:return i=e.sent,e.abrupt("return",i===at);case 6:case"end":return e.stop()}var a}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.signTypedData=function(){var e=Ae(Ue().mark((function e(t,n){var r,o;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.assertLogin(),null!=t){e.next=3;break}throw new Error("Missing data parameter");case 3:return r=(n||{}).onAuthChain,o=void 0===r||r,e.next=6,ot(new ue(this.getAddress(),JSON.stringify(t),"V4",!1,o),this._config);case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.isValidTypedSignature=function(){var e=Ae(Ue().mark((function e(t,n,r){var o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new Error("Missing data parameter");case 2:return n||(this.assertLogin(),n=this.getAddress()),o=new te(n,[{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magicValue",type:"bytes4"}],stateMutability:"view",type:"function"}],this._auth_provider),i=fe(t),e.next=7,o.isValidSignature(i,r);case 7:return a=e.sent,e.abrupt("return",a===at);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),e}();function ct(e){if(e.error){const t=new Error(e.error.message);throw t.code=e.error.code,t.data=e.error.data,t}return e.result}function ut(t){var n,r,s;return e(this,void 0,void 0,(function*(){const u=null!==(n=t.chainId)&&void 0!==n?n:1;let l=null!==(r=t.rpcUrl)&&void 0!==r?r:null===(s=t.rpc)||void 0===s?void 0:s[u];const d=new class extends c{constructor(e,n){super(e,n),this.updateUpWalletConfig=e=>{var n;const r=null===(n=t.rpc)||void 0===n?void 0:n[e];if(!o.includes(e)||!r)throw new Error(`chainId ${e} not supported`);return this.upWallet.updateConfig({chainType:i(e),nodeRPC:r,appSettings:{chain:i(e)}}),this.chainId=e,this.rpcUrl=r,this.emit("chainChanged",`0x${e.toString(16)}`),{result:!0}},this.rpcUrl=e,this.chainId=u,this.upWallet=new st({env:a(u),chainType:i(u),appSettings:{appIcon:t.appLogoUrl,appName:t.appName,chain:i(u)},rpcUrl:l,storageType:"sessionStorage"})}getSigner(){var e;const t=this.upWallet.getAccount();return new se(d,this.upWallet,null!==(e=null==t?void 0:t.address)&&void 0!==e?e:"",0)}connect(){return e(this,void 0,void 0,(function*(){const e=this.upWallet.getAccount();return e||(yield this.upWallet.login({email:false}))}))}disconnect(){return e(this,void 0,void 0,(function*(){yield this.upWallet.logout()}))}listAccounts(){return e(this,void 0,void 0,(function*(){const e=this.upWallet.getAccount();return(null==e?void 0:e.address)?[null==e?void 0:e.address]:[]}))}getAddress(){const e=this.upWallet.getAccount();return Promise.resolve((null==e?void 0:e.address)?p(null==e?void 0:e.address):null)}send(e,t){const n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:$(n),provider:this});const r=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(r&&this._cache[e])return this._cache[e];const o=ee({url:this.rpcUrl},JSON.stringify(n),ct).then((e=>(this.emit("debug",{action:"response",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:n,provider:this}),e}));return r&&(this._cache[e]=o,setTimeout((()=>{this._cache[e]=null}),0)),o}}(l);return d}))}function pt(t,n){return e(this,void 0,void 0,(function*(){const e=yield ut(t);return e.on("connect",n.connect),e.on("disconnect",(e=>{n.disconnect(e),n.accountsChanged([])})),e.on("accountsChanged",n.accountsChanged),e.on("chainChanged",n.chainChanged),e.on("message",(({type:e,data:t})=>n.message(e,t))),yield e.connect(),e}))}function lt(){var e;null===(e=s.getState().provider)||void 0===e||e.disconnect()}function dt(e){var t,n;return null===(n=null===(t=s.getState().provider)||void 0===t?void 0:t.upWallet)||void 0===n?void 0:n.signTypedData(e)}function ft(e){var t;const n=e.addChainParameters.chainId,r="string"==typeof n&&(null==n?void 0:n.startsWith("0x"))?parseInt(n,16):Number(n);if(!o.includes(r))throw new Error(`chainId ${r} not supported`);return null===(t=s.getState().provider)||void 0===t?void 0:t.updateUpWalletConfig(r)}export{ut as createProvider,pt as default,lt as disconnectWallet,dt as signTypedData,ft as switchChain};
|