@dodoex/wallet-web3 0.0.22-6 → 0.0.22-7

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.
Files changed (58) hide show
  1. package/dist/__node-resolve_empty-3ea76c19.js +1 -0
  2. package/dist/__tslib-9045586a.js +1 -0
  3. package/dist/{blocto-43d279d2.js → blocto-1dbb37d1.js} +1 -1
  4. package/dist/{bn-53e8d860.js → bn-b3726d58.js} +1 -1
  5. package/dist/{browser-ponyfill-994ca52a.js → browser-ponyfill-e64b3b84.js} +1 -1
  6. package/dist/cjs/{__node-resolve_empty-f8a7d2a6.cjs → __node-resolve_empty-7021817d.cjs} +1 -1
  7. package/dist/cjs/__tslib-6bd8f508.cjs +1 -0
  8. package/dist/cjs/{blocto-ad73be40.cjs → blocto-d2d6df5c.cjs} +1 -1
  9. package/dist/cjs/{bn-259a0e46.cjs → bn-15297ad5.cjs} +1 -1
  10. package/dist/cjs/{browser-ponyfill-a1801dcd.cjs → browser-ponyfill-74bc5aba.cjs} +1 -1
  11. package/dist/cjs/{ethers-ad66123b.cjs → ethers-04b4ff48.cjs} +1 -1
  12. package/dist/cjs/{id-075436d1.cjs → id-ba5cc51c.cjs} +1 -1
  13. package/dist/cjs/{index-7e27ff20.cjs → index-01744c67.cjs} +1 -1
  14. package/dist/cjs/{index-39f908aa.cjs → index-0f70968d.cjs} +1 -1
  15. package/dist/cjs/{index-d3bc48e5.cjs → index-13b012fa.cjs} +1 -1
  16. package/dist/cjs/{index-3ceb25c2.cjs → index-50edf9ef.cjs} +1 -1
  17. package/dist/cjs/{index-4e48c14e.cjs → index-64400201.cjs} +1 -1
  18. package/dist/cjs/{index-b62db8cd.cjs → index-790aa731.cjs} +1 -1
  19. package/dist/cjs/{index-071d6906.cjs → index-8a12a633.cjs} +1 -1
  20. package/dist/cjs/{index-1ff0c9e7.cjs → index-a21ee568.cjs} +1 -1
  21. package/dist/cjs/{index-f15c7553.cjs → index-a7044d0d.cjs} +1 -1
  22. package/dist/cjs/{index-09ee60f0.cjs → index-e5d95faa.cjs} +1 -1
  23. package/dist/cjs/index.cjs +1 -1
  24. package/dist/cjs/{index.es-7c468257.cjs → index.es-314a08e7.cjs} +1 -1
  25. package/dist/cjs/{interface-69fe257c.cjs → interface-70d885c7.cjs} +1 -1
  26. package/dist/cjs/{portis-1ee952f4.cjs → portis-fdc80fdb.cjs} +1 -1
  27. package/dist/cjs/{provider-e526ab57.cjs → provider-2ec88e39.cjs} +1 -1
  28. package/dist/cjs/{rainbow-7eee2fcc.cjs → rainbow-8c6b2e5a.cjs} +1 -1
  29. package/dist/cjs/{uAuth-56734b8c.cjs → uAuth-d77c2003.cjs} +1 -1
  30. package/dist/cjs/walletConnect-8ee8a33a.cjs +1 -0
  31. package/dist/cjs/{walletLink-90050887.cjs → walletLink-0165d84c.cjs} +1 -1
  32. package/dist/{ethers-8bf83ff3.js → ethers-4c9477d5.js} +1 -1
  33. package/dist/{id-981e85d0.js → id-a69f4178.js} +1 -1
  34. package/dist/{index-70702df7.js → index-010049fc.js} +1 -1
  35. package/dist/{index-9e7ee149.js → index-24cc2ad8.js} +1 -1
  36. package/dist/{index-6da89242.js → index-409267ec.js} +1 -1
  37. package/dist/{index-3c27c6a5.js → index-52eeb766.js} +1 -1
  38. package/dist/index-5c902c62.js +1 -0
  39. package/dist/{index-b6ae07d2.js → index-93261ef1.js} +1 -1
  40. package/dist/{index-37e0a7f3.js → index-a19b40db.js} +1 -1
  41. package/dist/{index-98b9bf3a.js → index-a522b51e.js} +1 -1
  42. package/dist/{index-dd5d2630.js → index-bd9b3102.js} +1 -1
  43. package/dist/{index-c0034721.js → index-cf18864d.js} +1 -1
  44. package/dist/{index.es-02a694c6.js → index.es-8af76fca.js} +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/{interface-b385b75d.js → interface-5dda5024.js} +1 -1
  47. package/dist/{portis-0cfaaaa6.js → portis-fee24e00.js} +1 -1
  48. package/dist/{provider-f0ecad3a.js → provider-ff6e2cff.js} +1 -1
  49. package/dist/{rainbow-198d46f6.js → rainbow-21396fc6.js} +1 -1
  50. package/dist/{uAuth-4e89f540.js → uAuth-f3667d04.js} +1 -1
  51. package/dist/{walletConnect-caeb4392.js → walletConnect-926d346c.js} +1 -1
  52. package/dist/{walletLink-250c7f26.js → walletLink-6db64762.js} +1 -1
  53. package/package.json +1 -1
  54. package/dist/__node-resolve_empty-347980cf.js +0 -1
  55. package/dist/__tslib-19cf4b7c.js +0 -1
  56. package/dist/cjs/__tslib-3398fe80.cjs +0 -1
  57. package/dist/cjs/walletConnect-5726a111.cjs +0 -1
  58. package/dist/index-e5ff145a.js +0 -1
@@ -1 +1 @@
1
- import{getAddress as r}from"@ethersproject/address";import{hexZeroPad as t,hexConcat as e,isHexString as n,hexlify as i,arrayify as o}from"@ethersproject/bytes";import{k as s}from"./index-98b9bf3a.js";import{defineReadOnly as a,deepCopy as c,shallowCopy as u,resolveProperties as h}from"@ethersproject/properties";import{L as d,B as f,i as m}from"./id-981e85d0.js";const l="hash/5.7.0";var y=function(r,t,e,n){return new(e||(e=Promise))((function(i,o){function s(r){try{c(n.next(r))}catch(r){o(r)}}function a(r){try{c(n.throw(r))}catch(r){o(r)}}function c(r){var t;r.done?i(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(s,a)}c((n=n.apply(r,t||[])).next())}))};const g=new d(l),p=new Uint8Array(32);p.fill(0);const v=f.from(-1),P=f.from(0),E=f.from(1),w=f.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const x=t(E.toHexString(),32),A=t(P.toHexString(),32),T={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},_=["name","version","chainId","verifyingContract","salt"];function I(r){return function(t){return"string"!=typeof t&&g.throwArgumentError(`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,t),t}}const S={name:I("name"),version:I("version"),chainId:function(r){try{return f.from(r).toString()}catch(r){}return g.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",r)},verifyingContract:function(t){try{return r(t).toLowerCase()}catch(r){}return g.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(r){try{const t=o(r);if(32!==t.length)throw new Error("bad length");return i(t)}catch(r){}return g.throwArgumentError('invalid domain value "salt"',"domain.salt",r)}};function G(n){{const r=n.match(/^(u?)int(\d*)$/);if(r){const e=""===r[1],i=parseInt(r[2]||"256");(i%8!=0||i>256||r[2]&&r[2]!==String(i))&&g.throwArgumentError("invalid numeric width","type",n);const o=w.mask(e?i-1:i),s=e?o.add(E).mul(v):P;return function(r){const e=f.from(r);return(e.lt(s)||e.gt(o))&&g.throwArgumentError(`value out-of-bounds for ${n}`,"value",r),t(e.toTwos(256).toHexString(),32)}}}{const r=n.match(/^bytes(\d+)$/);if(r){const t=parseInt(r[1]);return(0===t||t>32||r[1]!==String(t))&&g.throwArgumentError("invalid bytes width","type",n),function(r){return o(r).length!==t&&g.throwArgumentError(`invalid length for ${n}`,"value",r),function(r){const t=o(r),n=t.length%32;return n?e([t,p.slice(n)]):i(t)}(r)}}}switch(n){case"address":return function(e){return t(r(e),32)};case"bool":return function(r){return r?x:A};case"bytes":return function(r){return s(r)};case"string":return function(r){return m(r)}}return null}function C(r,t){return`${r}(${t.map((({name:r,type:t})=>t+" "+r)).join(",")})`}class F{constructor(r){a(this,"types",Object.freeze(c(r))),a(this,"_encoderCache",{}),a(this,"_types",{});const t={},e={},n={};Object.keys(r).forEach((r=>{t[r]={},e[r]=[],n[r]={}}));for(const n in r){const i={};r[n].forEach((o=>{i[o.name]&&g.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",r),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&g.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",r);G(s)||(e[s]||g.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",r),e[s].push(n),t[n][s]=!0)}))}const i=Object.keys(e).filter((r=>0===e[r].length));0===i.length?g.throwArgumentError("missing primary type","types",r):i.length>1&&g.throwArgumentError(`ambiguous primary types or unused types: ${i.map((r=>JSON.stringify(r))).join(", ")}`,"types",r),a(this,"primaryType",i[0]),function i(o,s){s[o]&&g.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",r),s[o]=!0,Object.keys(t[o]).forEach((r=>{e[r]&&(i(r,s),Object.keys(s).forEach((t=>{n[t][r]=!0})))})),delete s[o]}(this.primaryType,{});for(const t in n){const e=Object.keys(n[t]);e.sort(),this._types[t]=C(t,r[t])+e.map((t=>C(t,r[t]))).join("")}}getEncoder(r){let t=this._encoderCache[r];return t||(t=this._encoderCache[r]=this._getEncoder(r)),t}_getEncoder(r){{const t=G(r);if(t)return t}const t=r.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const r=t[1],n=this.getEncoder(r),i=parseInt(t[3]);return t=>{i>=0&&t.length!==i&&g.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t);let o=t.map(n);return this._types[r]&&(o=o.map(s)),s(e(o))}}const n=this.types[r];if(n){const t=m(this._types[r]);return r=>{const i=n.map((({name:t,type:e})=>{const n=this.getEncoder(e)(r[t]);return this._types[e]?s(n):n}));return i.unshift(t),e(i)}}return g.throwArgumentError(`unknown type: ${r}`,"type",r)}encodeType(r){const t=this._types[r];return t||g.throwArgumentError(`unknown type: ${JSON.stringify(r)}`,"name",r),t}encodeData(r,t){return this.getEncoder(r)(t)}hashStruct(r,t){return s(this.encodeData(r,t))}encode(r){return this.encodeData(this.primaryType,r)}hash(r){return this.hashStruct(this.primaryType,r)}_visit(r,t,e){if(G(r))return e(r,t);const n=r.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const r=n[1],i=parseInt(n[3]);return i>=0&&t.length!==i&&g.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map((t=>this._visit(r,t,e)))}const i=this.types[r];return i?i.reduce(((r,{name:n,type:i})=>(r[n]=this._visit(i,t[n],e),r)),{}):g.throwArgumentError(`unknown type: ${r}`,"type",r)}visit(r,t){return this._visit(this.primaryType,r,t)}static from(r){return new F(r)}static getPrimaryType(r){return F.from(r).primaryType}static hashStruct(r,t,e){return F.from(t).hashStruct(r,e)}static hashDomain(r){const t=[];for(const e in r){const n=T[e];n||g.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(e)}`,"domain",r),t.push({name:e,type:n})}return t.sort(((r,t)=>_.indexOf(r.name)-_.indexOf(t.name))),F.hashStruct("EIP712Domain",{EIP712Domain:t},r)}static encode(r,t,n){return e(["0x1901",F.hashDomain(r),F.from(t).hash(n)])}static hash(r,t,e){return s(F.encode(r,t,e))}static resolveNames(r,t,e,i){return y(this,void 0,void 0,(function*(){r=u(r);const o={};r.verifyingContract&&!n(r.verifyingContract,20)&&(o[r.verifyingContract]="0x");const s=F.from(t);s.visit(e,((r,t)=>("address"!==r||n(t,20)||(o[t]="0x"),t)));for(const r in o)o[r]=yield i(r);return r.verifyingContract&&o[r.verifyingContract]&&(r.verifyingContract=o[r.verifyingContract]),e=s.visit(e,((r,t)=>"address"===r&&o[t]?o[t]:t)),{domain:r,value:e}}))}static getPayload(r,t,e){F.hashDomain(r);const n={},s=[];_.forEach((t=>{const e=r[t];null!=e&&(n[t]=S[t](e),s.push({name:t,type:T[t]}))}));const a=F.from(t),c=u(t);return c.EIP712Domain?g.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",t):c.EIP712Domain=s,a.encode(e),{types:c,domain:n,primaryType:a.primaryType,message:a.visit(e,((r,t)=>{if(r.match(/^bytes(\d*)/))return i(o(t));if(r.match(/^u?int/))return f.from(t).toString();switch(r){case"address":return t.toLowerCase();case"bool":return!!t;case"string":return"string"!=typeof t&&g.throwArgumentError("invalid string","value",t),t}return g.throwArgumentError("unsupported type","type",r)}))}}}var N=function(r,t,e,n){return new(e||(e=Promise))((function(i,o){function s(r){try{c(n.next(r))}catch(r){o(r)}}function a(r){try{c(n.throw(r))}catch(r){o(r)}}function c(r){var t;r.done?i(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(s,a)}c((n=n.apply(r,t||[])).next())}))};const O=new d("abstract-signer/5.7.0"),k=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],D=[d.errors.INSUFFICIENT_FUNDS,d.errors.NONCE_EXPIRED,d.errors.REPLACEMENT_UNDERPRICED];class b{constructor(){O.checkAbstract(new.target,b),a(this,"_isSigner",!0)}getBalance(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),r)}))}getTransactionCount(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),r)}))}estimateGas(r){return N(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const t=yield h(this.checkTransaction(r));return yield this.provider.estimateGas(t)}))}call(r,t){return N(this,void 0,void 0,(function*(){this._checkProvider("call");const e=yield h(this.checkTransaction(r));return yield this.provider.call(e,t)}))}sendTransaction(r){return N(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const t=yield this.populateTransaction(r),e=yield this.signTransaction(t);return yield this.provider.sendTransaction(e)}))}getChainId(){return N(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return N(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return N(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(r)}))}checkTransaction(r){for(const t in r)-1===k.indexOf(t)&&O.throwArgumentError("invalid transaction key: "+t,"transaction",r);const t=u(r);return null==t.from?t.from=this.getAddress():t.from=Promise.all([Promise.resolve(t.from),this.getAddress()]).then((t=>(t[0].toLowerCase()!==t[1].toLowerCase()&&O.throwArgumentError("from address mismatch","transaction",r),t[0]))),t}populateTransaction(r){return N(this,void 0,void 0,(function*(){const t=yield h(this.checkTransaction(r));null!=t.to&&(t.to=Promise.resolve(t.to).then((r=>N(this,void 0,void 0,(function*(){if(null==r)return null;const t=yield this.resolveName(r);return null==t&&O.throwArgumentError("provided ENS name resolves to null","tx.to",r),t})))),t.to.catch((r=>{})));const e=null!=t.maxFeePerGas||null!=t.maxPriorityFeePerGas;if(null==t.gasPrice||2!==t.type&&!e?0!==t.type&&1!==t.type||!e||O.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",r):O.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",r),2!==t.type&&null!=t.type||null==t.maxFeePerGas||null==t.maxPriorityFeePerGas)if(0===t.type||1===t.type)null==t.gasPrice&&(t.gasPrice=this.getGasPrice());else{const r=yield this.getFeeData();if(null==t.type)if(null!=r.maxFeePerGas&&null!=r.maxPriorityFeePerGas)if(t.type=2,null!=t.gasPrice){const r=t.gasPrice;delete t.gasPrice,t.maxFeePerGas=r,t.maxPriorityFeePerGas=r}else null==t.maxFeePerGas&&(t.maxFeePerGas=r.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=r.maxPriorityFeePerGas);else null!=r.gasPrice?(e&&O.throwError("network does not support EIP-1559",d.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==t.gasPrice&&(t.gasPrice=r.gasPrice),t.type=0):O.throwError("failed to get consistent fee data",d.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===t.type&&(null==t.maxFeePerGas&&(t.maxFeePerGas=r.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=r.maxPriorityFeePerGas))}else t.type=2;return null==t.nonce&&(t.nonce=this.getTransactionCount("pending")),null==t.gasLimit&&(t.gasLimit=this.estimateGas(t).catch((r=>{if(D.indexOf(r.code)>=0)throw r;return O.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",d.errors.UNPREDICTABLE_GAS_LIMIT,{error:r,tx:t})}))),null==t.chainId?t.chainId=this.getChainId():t.chainId=Promise.all([Promise.resolve(t.chainId),this.getChainId()]).then((t=>(0!==t[1]&&t[0]!==t[1]&&O.throwArgumentError("chainId address mismatch","transaction",r),t[0]))),yield h(t)}))}_checkProvider(r){this.provider||O.throwError("missing provider",d.errors.UNSUPPORTED_OPERATION,{operation:r||"_checkProvider"})}static isSigner(r){return!(!r||!r._isSigner)}}class $ extends b{constructor(r,t){super(),a(this,"address",r),a(this,"provider",t||null)}getAddress(){return Promise.resolve(this.address)}_fail(r,t){return Promise.resolve().then((()=>{O.throwError(r,d.errors.UNSUPPORTED_OPERATION,{operation:t})}))}signMessage(r){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(r){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(r,t,e){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(r){return new $(this.address,r)}}export{b as S,F as T,$ as V,l as v};
1
+ import{getAddress as r}from"@ethersproject/address";import{hexZeroPad as t,hexConcat as e,isHexString as n,hexlify as i,arrayify as o}from"@ethersproject/bytes";import{k as s}from"./index-a522b51e.js";import{defineReadOnly as a,deepCopy as c,shallowCopy as u,resolveProperties as h}from"@ethersproject/properties";import{L as d,B as f,i as m}from"./id-a69f4178.js";const l="hash/5.7.0";var y=function(r,t,e,n){return new(e||(e=Promise))((function(i,o){function s(r){try{c(n.next(r))}catch(r){o(r)}}function a(r){try{c(n.throw(r))}catch(r){o(r)}}function c(r){var t;r.done?i(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(s,a)}c((n=n.apply(r,t||[])).next())}))};const g=new d(l),p=new Uint8Array(32);p.fill(0);const v=f.from(-1),P=f.from(0),E=f.from(1),w=f.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const x=t(E.toHexString(),32),A=t(P.toHexString(),32),T={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},_=["name","version","chainId","verifyingContract","salt"];function I(r){return function(t){return"string"!=typeof t&&g.throwArgumentError(`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,t),t}}const S={name:I("name"),version:I("version"),chainId:function(r){try{return f.from(r).toString()}catch(r){}return g.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",r)},verifyingContract:function(t){try{return r(t).toLowerCase()}catch(r){}return g.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(r){try{const t=o(r);if(32!==t.length)throw new Error("bad length");return i(t)}catch(r){}return g.throwArgumentError('invalid domain value "salt"',"domain.salt",r)}};function G(n){{const r=n.match(/^(u?)int(\d*)$/);if(r){const e=""===r[1],i=parseInt(r[2]||"256");(i%8!=0||i>256||r[2]&&r[2]!==String(i))&&g.throwArgumentError("invalid numeric width","type",n);const o=w.mask(e?i-1:i),s=e?o.add(E).mul(v):P;return function(r){const e=f.from(r);return(e.lt(s)||e.gt(o))&&g.throwArgumentError(`value out-of-bounds for ${n}`,"value",r),t(e.toTwos(256).toHexString(),32)}}}{const r=n.match(/^bytes(\d+)$/);if(r){const t=parseInt(r[1]);return(0===t||t>32||r[1]!==String(t))&&g.throwArgumentError("invalid bytes width","type",n),function(r){return o(r).length!==t&&g.throwArgumentError(`invalid length for ${n}`,"value",r),function(r){const t=o(r),n=t.length%32;return n?e([t,p.slice(n)]):i(t)}(r)}}}switch(n){case"address":return function(e){return t(r(e),32)};case"bool":return function(r){return r?x:A};case"bytes":return function(r){return s(r)};case"string":return function(r){return m(r)}}return null}function C(r,t){return`${r}(${t.map((({name:r,type:t})=>t+" "+r)).join(",")})`}class F{constructor(r){a(this,"types",Object.freeze(c(r))),a(this,"_encoderCache",{}),a(this,"_types",{});const t={},e={},n={};Object.keys(r).forEach((r=>{t[r]={},e[r]=[],n[r]={}}));for(const n in r){const i={};r[n].forEach((o=>{i[o.name]&&g.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",r),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&g.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",r);G(s)||(e[s]||g.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",r),e[s].push(n),t[n][s]=!0)}))}const i=Object.keys(e).filter((r=>0===e[r].length));0===i.length?g.throwArgumentError("missing primary type","types",r):i.length>1&&g.throwArgumentError(`ambiguous primary types or unused types: ${i.map((r=>JSON.stringify(r))).join(", ")}`,"types",r),a(this,"primaryType",i[0]),function i(o,s){s[o]&&g.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",r),s[o]=!0,Object.keys(t[o]).forEach((r=>{e[r]&&(i(r,s),Object.keys(s).forEach((t=>{n[t][r]=!0})))})),delete s[o]}(this.primaryType,{});for(const t in n){const e=Object.keys(n[t]);e.sort(),this._types[t]=C(t,r[t])+e.map((t=>C(t,r[t]))).join("")}}getEncoder(r){let t=this._encoderCache[r];return t||(t=this._encoderCache[r]=this._getEncoder(r)),t}_getEncoder(r){{const t=G(r);if(t)return t}const t=r.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const r=t[1],n=this.getEncoder(r),i=parseInt(t[3]);return t=>{i>=0&&t.length!==i&&g.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t);let o=t.map(n);return this._types[r]&&(o=o.map(s)),s(e(o))}}const n=this.types[r];if(n){const t=m(this._types[r]);return r=>{const i=n.map((({name:t,type:e})=>{const n=this.getEncoder(e)(r[t]);return this._types[e]?s(n):n}));return i.unshift(t),e(i)}}return g.throwArgumentError(`unknown type: ${r}`,"type",r)}encodeType(r){const t=this._types[r];return t||g.throwArgumentError(`unknown type: ${JSON.stringify(r)}`,"name",r),t}encodeData(r,t){return this.getEncoder(r)(t)}hashStruct(r,t){return s(this.encodeData(r,t))}encode(r){return this.encodeData(this.primaryType,r)}hash(r){return this.hashStruct(this.primaryType,r)}_visit(r,t,e){if(G(r))return e(r,t);const n=r.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const r=n[1],i=parseInt(n[3]);return i>=0&&t.length!==i&&g.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map((t=>this._visit(r,t,e)))}const i=this.types[r];return i?i.reduce(((r,{name:n,type:i})=>(r[n]=this._visit(i,t[n],e),r)),{}):g.throwArgumentError(`unknown type: ${r}`,"type",r)}visit(r,t){return this._visit(this.primaryType,r,t)}static from(r){return new F(r)}static getPrimaryType(r){return F.from(r).primaryType}static hashStruct(r,t,e){return F.from(t).hashStruct(r,e)}static hashDomain(r){const t=[];for(const e in r){const n=T[e];n||g.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(e)}`,"domain",r),t.push({name:e,type:n})}return t.sort(((r,t)=>_.indexOf(r.name)-_.indexOf(t.name))),F.hashStruct("EIP712Domain",{EIP712Domain:t},r)}static encode(r,t,n){return e(["0x1901",F.hashDomain(r),F.from(t).hash(n)])}static hash(r,t,e){return s(F.encode(r,t,e))}static resolveNames(r,t,e,i){return y(this,void 0,void 0,(function*(){r=u(r);const o={};r.verifyingContract&&!n(r.verifyingContract,20)&&(o[r.verifyingContract]="0x");const s=F.from(t);s.visit(e,((r,t)=>("address"!==r||n(t,20)||(o[t]="0x"),t)));for(const r in o)o[r]=yield i(r);return r.verifyingContract&&o[r.verifyingContract]&&(r.verifyingContract=o[r.verifyingContract]),e=s.visit(e,((r,t)=>"address"===r&&o[t]?o[t]:t)),{domain:r,value:e}}))}static getPayload(r,t,e){F.hashDomain(r);const n={},s=[];_.forEach((t=>{const e=r[t];null!=e&&(n[t]=S[t](e),s.push({name:t,type:T[t]}))}));const a=F.from(t),c=u(t);return c.EIP712Domain?g.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",t):c.EIP712Domain=s,a.encode(e),{types:c,domain:n,primaryType:a.primaryType,message:a.visit(e,((r,t)=>{if(r.match(/^bytes(\d*)/))return i(o(t));if(r.match(/^u?int/))return f.from(t).toString();switch(r){case"address":return t.toLowerCase();case"bool":return!!t;case"string":return"string"!=typeof t&&g.throwArgumentError("invalid string","value",t),t}return g.throwArgumentError("unsupported type","type",r)}))}}}var N=function(r,t,e,n){return new(e||(e=Promise))((function(i,o){function s(r){try{c(n.next(r))}catch(r){o(r)}}function a(r){try{c(n.throw(r))}catch(r){o(r)}}function c(r){var t;r.done?i(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(s,a)}c((n=n.apply(r,t||[])).next())}))};const O=new d("abstract-signer/5.7.0"),k=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],D=[d.errors.INSUFFICIENT_FUNDS,d.errors.NONCE_EXPIRED,d.errors.REPLACEMENT_UNDERPRICED];class b{constructor(){O.checkAbstract(new.target,b),a(this,"_isSigner",!0)}getBalance(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),r)}))}getTransactionCount(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),r)}))}estimateGas(r){return N(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const t=yield h(this.checkTransaction(r));return yield this.provider.estimateGas(t)}))}call(r,t){return N(this,void 0,void 0,(function*(){this._checkProvider("call");const e=yield h(this.checkTransaction(r));return yield this.provider.call(e,t)}))}sendTransaction(r){return N(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const t=yield this.populateTransaction(r),e=yield this.signTransaction(t);return yield this.provider.sendTransaction(e)}))}getChainId(){return N(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return N(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return N(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(r)}))}checkTransaction(r){for(const t in r)-1===k.indexOf(t)&&O.throwArgumentError("invalid transaction key: "+t,"transaction",r);const t=u(r);return null==t.from?t.from=this.getAddress():t.from=Promise.all([Promise.resolve(t.from),this.getAddress()]).then((t=>(t[0].toLowerCase()!==t[1].toLowerCase()&&O.throwArgumentError("from address mismatch","transaction",r),t[0]))),t}populateTransaction(r){return N(this,void 0,void 0,(function*(){const t=yield h(this.checkTransaction(r));null!=t.to&&(t.to=Promise.resolve(t.to).then((r=>N(this,void 0,void 0,(function*(){if(null==r)return null;const t=yield this.resolveName(r);return null==t&&O.throwArgumentError("provided ENS name resolves to null","tx.to",r),t})))),t.to.catch((r=>{})));const e=null!=t.maxFeePerGas||null!=t.maxPriorityFeePerGas;if(null==t.gasPrice||2!==t.type&&!e?0!==t.type&&1!==t.type||!e||O.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",r):O.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",r),2!==t.type&&null!=t.type||null==t.maxFeePerGas||null==t.maxPriorityFeePerGas)if(0===t.type||1===t.type)null==t.gasPrice&&(t.gasPrice=this.getGasPrice());else{const r=yield this.getFeeData();if(null==t.type)if(null!=r.maxFeePerGas&&null!=r.maxPriorityFeePerGas)if(t.type=2,null!=t.gasPrice){const r=t.gasPrice;delete t.gasPrice,t.maxFeePerGas=r,t.maxPriorityFeePerGas=r}else null==t.maxFeePerGas&&(t.maxFeePerGas=r.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=r.maxPriorityFeePerGas);else null!=r.gasPrice?(e&&O.throwError("network does not support EIP-1559",d.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==t.gasPrice&&(t.gasPrice=r.gasPrice),t.type=0):O.throwError("failed to get consistent fee data",d.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===t.type&&(null==t.maxFeePerGas&&(t.maxFeePerGas=r.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=r.maxPriorityFeePerGas))}else t.type=2;return null==t.nonce&&(t.nonce=this.getTransactionCount("pending")),null==t.gasLimit&&(t.gasLimit=this.estimateGas(t).catch((r=>{if(D.indexOf(r.code)>=0)throw r;return O.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",d.errors.UNPREDICTABLE_GAS_LIMIT,{error:r,tx:t})}))),null==t.chainId?t.chainId=this.getChainId():t.chainId=Promise.all([Promise.resolve(t.chainId),this.getChainId()]).then((t=>(0!==t[1]&&t[0]!==t[1]&&O.throwArgumentError("chainId address mismatch","transaction",r),t[0]))),yield h(t)}))}_checkProvider(r){this.provider||O.throwError("missing provider",d.errors.UNSUPPORTED_OPERATION,{operation:r||"_checkProvider"})}static isSigner(r){return!(!r||!r._isSigner)}}class $ extends b{constructor(r,t){super(),a(this,"address",r),a(this,"provider",t||null)}getAddress(){return Promise.resolve(this.address)}_fail(r,t){return Promise.resolve().then((()=>{O.throwError(r,d.errors.UNSUPPORTED_OPERATION,{operation:t})}))}signMessage(r){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(r){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(r,t,e){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(r){return new $(this.address,r)}}export{b as S,F as T,$ as V,l as v};
@@ -0,0 +1 @@
1
+ import{g as a}from"./index-a522b51e.js";import{C as r,E as e,a as s,F as t,b as o,P as n,c as i,A as c,d as m,I as d,f as p,e as F,L as f,T as g}from"./interface-5dda5024.js";var b=a(Object.freeze({__proto__:null,ConstructorFragment:r,ErrorFragment:e,EventFragment:s,Fragment:t,FunctionFragment:o,ParamType:n,FormatTypes:i,AbiCoder:c,defaultAbiCoder:m,Interface:d,Indexed:p,checkResultErrors:F,LogDescription:f,TransactionDescription:g}));export{b as r};
@@ -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-98b9bf3a.js";import{JsonRpcProvider as c}from"@ethersproject/providers";import u,{getAddress as p}from"@ethersproject/address";import{T as l,S as f}from"./index-3c27c6a5.js";import d,{arrayify as h}from"@ethersproject/bytes";import{r as g}from"./index-e5ff145a.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,C as F}from"./ethers-8bf83ff3.js";import{d as z,t as B,c as W,a as G,e as V,f as J,U as H,i as K,l as Z}from"./id-981e85d0.js";import q,{deepCopy as $}from"@ethersproject/properties";import{l as Y}from"./index-70702df7.js";import Q from"@ethersproject/transactions";import{l as X,f as ee}from"./index-37e0a7f3.js";import{Contract as te}from"@ethersproject/contracts";import"events";import"zustand";import"@ethersproject/constants";import"./interface-b385b75d.js";import"./__node-resolve_empty-347980cf.js";import"./hash-a9ebd52a.js";import"./inherits_browser-06ba108b.js";var ne,re=Object.freeze({__proto__:null,_toEscapedUtf8String:z,toUtf8Bytes:B,toUtf8CodePoints:W,toUtf8String:G,Utf8ErrorFuncs:V,get Utf8ErrorReason(){return J},get UnicodeNormalizationForm(){return H},formatBytes32String:y,parseBytes32String:m,nameprep:b}),oe=Object.freeze({__proto__:null,id:K,dnsEncode:v,namehash:w,isValidName:P,ensNormalize:x,messagePrefix:O,hashMessage:j,_TypedDataEncoder:l}),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 f{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 fe(){return fe=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},fe.apply(this,arguments)}!function(e){e.LIGHT="light",e.DARK="dark"}(ce||(ce={}));var de=function(e){return h(function(e){var t=fe({},e.types);return delete t.EIP712Domain,l.hash(e.domain,t,e.message)}(e))},he={},ge=t(A),ye=t(C),me=t(oe),be=t(N),ve=t(I),we=t(n),Pe=t(Z),xe=t(ie),Oe=t(D),je=t(ae),_e=t(Y),Se=t(M),Ee=t(re),ke=t(R),Te=t(F),Ue=t(X);function Le(){Le=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 f?t:f,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 f(){}function d(){}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=f.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 d.prototype=h,r(b,"constructor",{value:h,configurable:!0}),r(h,"constructor",{value:d,configurable:!0}),d.displayName=c(h,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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 Ae(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 Ce(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Ae(i,r,o,a,s,"next",e)}function s(e){Ae(i,r,o,a,s,"throw",e)}a(void 0)}))}}function Ne(){return Ne=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},Ne.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=ve;Object.defineProperty(e,"getJsonWalletAddress",{enumerable:!0,get:function(){return h.getJsonWalletAddress}});var y=we;Object.defineProperty(e,"keccak256",{enumerable:!0,get:function(){return y.keccak256}});var m=Pe;Object.defineProperty(e,"Logger",{enumerable:!0,get:function(){return m.Logger}});var b=xe;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=Oe;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=je;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(_e);e.RLP=x;var O=Se;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=Ee;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=ke;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=Te;Object.defineProperty(e,"verifyMessage",{enumerable:!0,get:function(){return E.verifyMessage}}),Object.defineProperty(e,"verifyTypedData",{enumerable:!0,get:function(){return E.verifyTypedData}});var k=Ue;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=xe;Object.defineProperty(e,"SupportedAlgorithm",{enumerable:!0,get:function(){return T.SupportedAlgorithm}});var U=Ee;Object.defineProperty(e,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return U.UnicodeNormalizationForm}}),Object.defineProperty(e,"Utf8ErrorReason",{enumerable:!0,get:function(){return U.Utf8ErrorReason}})}(he);var Ie="wallet.unipass.id",De={upDomain:Ie,upConnectUrl:"https://"+Ie+"/connect",upLogoutUrl:"https://"+Ie+"/logout",upSignMessageUrl:"https://"+Ie+"/sign-message",upTransactionUrl:"https://"+Ie+"/send-transaction",upLoadingUrl:"https://"+Ie+"/connect/loading"},Me=function(){return De},Re={protocol:"https",domain:"testnet.wallet.unipass.id"},Fe={protocol:"https",domain:"wallet.unipass.id"},ze={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"}},Be=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)}}},We=function(){var e=Ce(Le().mark((function e(t,n){var r,o;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(t.storageType).get(rt),e.t0=r&&JSON.parse(r),e.t0){e.next=6;break}return e.next=5,Ve(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)}}(),Ge=function(){var e=Ce(Le().mark((function e(t){var n;return Le().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,ot(n);case 4:Be("localStorage").remove(rt),Be("sessionStorage").remove(rt);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ve=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i;return Le().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,ot(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&&Be(t.storageType).set(rt,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)}}(),Je="UP_WALLET_POP",He=null,Ke=null;function Ze(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 qe(e,t,n){return $e.apply(this,arguments)}function $e(){return($e=Ce(Le().mark((function e(t,n,r){var o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(null==He||null!=(o=He)&&o.closed)){e.next=8;break}if(null!=(He=Ze(t,Je,window))){e.next=6;break}return e.next=5,Ye(t,n,r);case 5:return e.abrupt("return",e.sent);case 6:e.next=9;break;case 8:Ke!==t?(He.location.replace(t),He.focus()):He.focus();case 9:return i=setInterval((function(){if(He&&He.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(){He&&!He.closed&&He.close(),He=null},e.abrupt("return",{popup:He,unmount:a});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ye(e,t,n){return Qe.apply(this,arguments)}function Qe(){return(Qe=Ce(Le().mark((function e(t,n,r){var o,i;return Le().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(qe(t,n,r))}),!1)})));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Xe=function(){};function et(e,t,n){if("UP_LOGIN"===e)return"google"===t?Me().upConnectUrl+"?connectType=google&forceLogin="+(n?"1":"0"):"email"===t?Me().upConnectUrl+"?connectType=email&forceLogin="+(n?"1":"0"):Me().upConnectUrl+"?forceLogin="+(n?"1":"0");if("UP_LOGOUT"===e)return Me().upLogoutUrl;if("UP_SIGN_MESSAGE"===e)return Me().upSignMessageUrl;if("UP_TRANSACTION"===e)return Me().upTransactionUrl;if("UP_READY"===e)return Me().upLoadingUrl;throw new Error("unsupport type "+e)}function tt(e,t,n,r){return nt.apply(this,arguments)}function nt(){return nt=Ce(Le().mark((function e(t,n,r,o){var i,a,s,c,u,p,l,f,d,h;return Le().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)}},d=function(){try{window.removeEventListener("message",f),l(),i()}catch(e){console.error("Popup Close Error",e)}},f=function(e){try{if("object"!=typeof e.data)return;var t=e.data;if(!t||!t.type)return;"UP_CLOSE"===e.data.type&&d(),"UP_READY"===t.type&&s(e,{send:h,close:d}),"UP_RESPONSE"===t.type&&c(e,{send:h,close:d}),"UP_EVENT"===t.type&&a(e,{send:h,close:d})}catch(e){console.error("Popup Callback Error",e),d()}},null!=t){e.next=5;break}return e.abrupt("return",{send:Xe,close:Xe});case 5:return i=(null==o?void 0:o.onClose)||Xe,a=(null==o?void 0:o.onMessage)||Xe,s=(null==o?void 0:o.onReady)||Xe,c=(null==o?void 0:o.onResponse)||Xe,window.addEventListener("message",f),e.next=12,qe(et(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:d});case 16:case"end":return e.stop()}}),e)}))),nt.apply(this,arguments)}var rt="UP-A";function ot(e,t,n,r){return new Promise(function(){var o=Ce(Le().mark((function o(i,a){return Le().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,tt(e,t,n,{onReady:function(t,n){return Ce(Le().mark((function t(){var r;return Le().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 Ce(Le().mark((function r(){var o,s,c;return Le().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 Ge(!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 Ce(Le().mark((function t(){var n,o;return Le().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 Ce(Le().mark((function e(){return Le().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 it=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(n.storageType).get(rt),(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,ot(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=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(n.storageType).get(rt),(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,ot(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)}}(),st="0x1626ba7e";var ct=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?ze.mainnet[n]:ze.testnet[n],chainType:n,walletUrl:"prod"===t?Fe:Re});this._config.nodeRPC=e.nodeRPC||r.nodeRPC,this._config.appSettings=function(e,t){return Ne({},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?ze.mainnet.polygon:ze.testnet.polygon}(this._config.env));var o,i,a,s=e.walletUrl||r.walletUrl;s&&(i=(o=s).domain,a=o.protocol,De={upDomain:i=i||Ie,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=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,We(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=Be(e).get(rt))?JSON.parse(t):void 0},t.logout=function(){var e=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=!1),e.next=3,Ge(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=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),e.next=3,at(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=Ce(Le().mark((function e(t,n){var r,o,i,a,s;return Le().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,it(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=Ce(Le().mark((function e(t,n,r){var o,i;return Le().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===st);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=Ce(Le().mark((function e(t,n){var r,o;return Le().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,it(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=Ce(Le().mark((function e(t,n,r){var o,i,a;return Le().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=de(t),e.next=7,o.isValidSignature(i,r);case 7:return a=e.sent,e.abrupt("return",a===st);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),e}();function ut(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 pt(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 f=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 ct({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(f,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),ut).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 f}))}function lt(t,n){return e(this,void 0,void 0,(function*(){const e=yield pt(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 ft(){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 ht(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{pt as createProvider,lt as default,ft as disconnectWallet,dt as signTypedData,ht 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-a522b51e.js";import{JsonRpcProvider as c}from"@ethersproject/providers";import u,{getAddress as p}from"@ethersproject/address";import{T as l,S as d}from"./index-52eeb766.js";import f,{arrayify as h}from"@ethersproject/bytes";import{r as g}from"./index-5c902c62.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,C as F}from"./ethers-4c9477d5.js";import{d as z,t as B,c as W,a as G,e as V,f as J,U as H,i as K,l as Z}from"./id-a69f4178.js";import q,{deepCopy as $}from"@ethersproject/properties";import{l as Y}from"./index-010049fc.js";import Q from"@ethersproject/transactions";import{l as X,f as ee}from"./index-a19b40db.js";import{Contract as te}from"@ethersproject/contracts";import"events";import"zustand";import"@ethersproject/constants";import"./interface-5dda5024.js";import"./__node-resolve_empty-3ea76c19.js";import"./hash-a9ebd52a.js";import"./inherits_browser-06ba108b.js";var ne,re=Object.freeze({__proto__:null,_toEscapedUtf8String:z,toUtf8Bytes:B,toUtf8CodePoints:W,toUtf8String:G,Utf8ErrorFuncs:V,get Utf8ErrorReason(){return J},get UnicodeNormalizationForm(){return H},formatBytes32String:y,parseBytes32String:m,nameprep:b}),oe=Object.freeze({__proto__:null,id:K,dnsEncode:v,namehash:w,isValidName:P,ensNormalize:x,messagePrefix:O,hashMessage:j,_TypedDataEncoder:l}),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 d{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 h(function(e){var t=de({},e.types);return delete t.EIP712Domain,l.hash(e.domain,t,e.message)}(e))},he={},ge=t(A),ye=t(C),me=t(oe),be=t(N),ve=t(I),we=t(n),Pe=t(Z),xe=t(ie),Oe=t(D),je=t(ae),_e=t(Y),Se=t(M),Ee=t(re),ke=t(R),Te=t(F),Ue=t(X);function Le(){Le=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 Ae(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 Ce(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Ae(i,r,o,a,s,"next",e)}function s(e){Ae(i,r,o,a,s,"throw",e)}a(void 0)}))}}function Ne(){return Ne=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},Ne.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=f;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 d=be;Object.defineProperty(e,"defaultPath",{enumerable:!0,get:function(){return d.defaultPath}}),Object.defineProperty(e,"entropyToMnemonic",{enumerable:!0,get:function(){return d.entropyToMnemonic}}),Object.defineProperty(e,"getAccountPath",{enumerable:!0,get:function(){return d.getAccountPath}}),Object.defineProperty(e,"HDNode",{enumerable:!0,get:function(){return d.HDNode}}),Object.defineProperty(e,"isValidMnemonic",{enumerable:!0,get:function(){return d.isValidMnemonic}}),Object.defineProperty(e,"mnemonicToEntropy",{enumerable:!0,get:function(){return d.mnemonicToEntropy}}),Object.defineProperty(e,"mnemonicToSeed",{enumerable:!0,get:function(){return d.mnemonicToSeed}});var h=ve;Object.defineProperty(e,"getJsonWalletAddress",{enumerable:!0,get:function(){return h.getJsonWalletAddress}});var y=we;Object.defineProperty(e,"keccak256",{enumerable:!0,get:function(){return y.keccak256}});var m=Pe;Object.defineProperty(e,"Logger",{enumerable:!0,get:function(){return m.Logger}});var b=xe;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=Oe;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=je;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(_e);e.RLP=x;var O=Se;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=Ee;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=ke;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=Te;Object.defineProperty(e,"verifyMessage",{enumerable:!0,get:function(){return E.verifyMessage}}),Object.defineProperty(e,"verifyTypedData",{enumerable:!0,get:function(){return E.verifyTypedData}});var k=Ue;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=xe;Object.defineProperty(e,"SupportedAlgorithm",{enumerable:!0,get:function(){return T.SupportedAlgorithm}});var U=Ee;Object.defineProperty(e,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return U.UnicodeNormalizationForm}}),Object.defineProperty(e,"Utf8ErrorReason",{enumerable:!0,get:function(){return U.Utf8ErrorReason}})}(he);var Ie="wallet.unipass.id",De={upDomain:Ie,upConnectUrl:"https://"+Ie+"/connect",upLogoutUrl:"https://"+Ie+"/logout",upSignMessageUrl:"https://"+Ie+"/sign-message",upTransactionUrl:"https://"+Ie+"/send-transaction",upLoadingUrl:"https://"+Ie+"/connect/loading"},Me=function(){return De},Re={protocol:"https",domain:"testnet.wallet.unipass.id"},Fe={protocol:"https",domain:"wallet.unipass.id"},ze={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"}},Be=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)}}},We=function(){var e=Ce(Le().mark((function e(t,n){var r,o;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(t.storageType).get(rt),e.t0=r&&JSON.parse(r),e.t0){e.next=6;break}return e.next=5,Ve(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)}}(),Ge=function(){var e=Ce(Le().mark((function e(t){var n;return Le().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,ot(n);case 4:Be("localStorage").remove(rt),Be("sessionStorage").remove(rt);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ve=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i;return Le().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,ot(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&&Be(t.storageType).set(rt,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)}}(),Je="UP_WALLET_POP",He=null,Ke=null;function Ze(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 qe(e,t,n){return $e.apply(this,arguments)}function $e(){return($e=Ce(Le().mark((function e(t,n,r){var o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(null==He||null!=(o=He)&&o.closed)){e.next=8;break}if(null!=(He=Ze(t,Je,window))){e.next=6;break}return e.next=5,Ye(t,n,r);case 5:return e.abrupt("return",e.sent);case 6:e.next=9;break;case 8:Ke!==t?(He.location.replace(t),He.focus()):He.focus();case 9:return i=setInterval((function(){if(He&&He.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(){He&&!He.closed&&He.close(),He=null},e.abrupt("return",{popup:He,unmount:a});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ye(e,t,n){return Qe.apply(this,arguments)}function Qe(){return(Qe=Ce(Le().mark((function e(t,n,r){var o,i;return Le().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(qe(t,n,r))}),!1)})));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Xe=function(){};function et(e,t,n){if("UP_LOGIN"===e)return"google"===t?Me().upConnectUrl+"?connectType=google&forceLogin="+(n?"1":"0"):"email"===t?Me().upConnectUrl+"?connectType=email&forceLogin="+(n?"1":"0"):Me().upConnectUrl+"?forceLogin="+(n?"1":"0");if("UP_LOGOUT"===e)return Me().upLogoutUrl;if("UP_SIGN_MESSAGE"===e)return Me().upSignMessageUrl;if("UP_TRANSACTION"===e)return Me().upTransactionUrl;if("UP_READY"===e)return Me().upLoadingUrl;throw new Error("unsupport type "+e)}function tt(e,t,n,r){return nt.apply(this,arguments)}function nt(){return nt=Ce(Le().mark((function e(t,n,r,o){var i,a,s,c,u,p,l,d,f,h;return Le().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:Xe,close:Xe});case 5:return i=(null==o?void 0:o.onClose)||Xe,a=(null==o?void 0:o.onMessage)||Xe,s=(null==o?void 0:o.onReady)||Xe,c=(null==o?void 0:o.onResponse)||Xe,window.addEventListener("message",d),e.next=12,qe(et(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)}))),nt.apply(this,arguments)}var rt="UP-A";function ot(e,t,n,r){return new Promise(function(){var o=Ce(Le().mark((function o(i,a){return Le().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,tt(e,t,n,{onReady:function(t,n){return Ce(Le().mark((function t(){var r;return Le().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 Ce(Le().mark((function r(){var o,s,c;return Le().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 Ge(!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 Ce(Le().mark((function t(){var n,o;return Le().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 Ce(Le().mark((function e(){return Le().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 it=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(n.storageType).get(rt),(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,ot(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=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(n.storageType).get(rt),(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,ot(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)}}(),st="0x1626ba7e";var ct=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?ze.mainnet[n]:ze.testnet[n],chainType:n,walletUrl:"prod"===t?Fe:Re});this._config.nodeRPC=e.nodeRPC||r.nodeRPC,this._config.appSettings=function(e,t){return Ne({},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?ze.mainnet.polygon:ze.testnet.polygon}(this._config.env));var o,i,a,s=e.walletUrl||r.walletUrl;s&&(i=(o=s).domain,a=o.protocol,De={upDomain:i=i||Ie,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=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,We(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=Be(e).get(rt))?JSON.parse(t):void 0},t.logout=function(){var e=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=!1),e.next=3,Ge(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=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),e.next=3,at(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=Ce(Le().mark((function e(t,n){var r,o,i,a,s;return Le().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,it(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=Ce(Le().mark((function e(t,n,r){var o,i;return Le().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===st);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=Ce(Le().mark((function e(t,n){var r,o;return Le().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,it(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=Ce(Le().mark((function e(t,n,r){var o,i,a;return Le().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===st);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),e}();function ut(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 pt(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 ct({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),ut).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 lt(t,n){return e(this,void 0,void 0,(function*(){const e=yield pt(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 dt(){var e;null===(e=s.getState().provider)||void 0===e||e.disconnect()}function ft(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 ht(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{pt as createProvider,lt as default,dt as disconnectWallet,ft as signTypedData,ht 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-981e85d0.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 g=null;const w={method:"GET"};let b=!1,R=12e4;if("string"==typeof e)g=e;else if("object"==typeof e){if(null!=e&&null!=e.url||d.throwArgumentError("missing URL","connection.url",e),g=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&&(b=!0);if(w.allowGzip=!!e.allowGzip,null!=e.user&&null!=e.password){"https:"!==g.substring(0,6)&&!0!==e.allowInsecureAuthentication&&d.throwError("basic authentication requires a secure https url",n.errors.INVALID_ARGUMENT,{argument:"url",url:g,user:e.user,password:"[REDACTED]"});const t=e.user+":"+e.password;E.authorization={key:"Authorization",value:"Basic "+c(s(t))}}null!=e.skipFetchSetup&&(w.skipFetchSetup=!!e.skipFetchSetup),null!=e.fetchOptions&&(w.fetchOptions=o(e.fetchOptions))}const v=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),C=g?g.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:g})}var S;t&&(w.method="POST",w.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})),w.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(w.body,O["content-type"]),requestMethod:w.method,timeout:R,url:g})))}),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(g,w),e<i)if(301===t.statusCode||302===t.statusCode){const e=t.headers.location||"";if("GET"===w.method&&e.match(/^https:/)){g=t.headers.location;continue}}else if(429===t.statusCode){let r=!0;if(a&&(r=yield a(e,g)),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(w.body,O["content-type"]),requestMethod:w.method,serverError:e,url:g}))}let o=t.body;if(b&&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(w.body,O["content-type"]),requestMethod:w.method,url:g})),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,g)),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(w.body,O["content-type"]),requestMethod:w.method,url:g})}return T.cancel(),o}return d.throwError("failed response",n.errors.SERVER_ERROR,{requestBody:p(w.body,O["content-type"]),requestMethod:w.method,url:g})}))}();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 g=Object.freeze({__proto__:null,_fetchData:y,fetchJson:m,poll:E});export{y as _,l as d,c as e,m as f,g as l,E as p};
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-a69f4178.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 g=null;const w={method:"GET"};let b=!1,R=12e4;if("string"==typeof e)g=e;else if("object"==typeof e){if(null!=e&&null!=e.url||d.throwArgumentError("missing URL","connection.url",e),g=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&&(b=!0);if(w.allowGzip=!!e.allowGzip,null!=e.user&&null!=e.password){"https:"!==g.substring(0,6)&&!0!==e.allowInsecureAuthentication&&d.throwError("basic authentication requires a secure https url",n.errors.INVALID_ARGUMENT,{argument:"url",url:g,user:e.user,password:"[REDACTED]"});const t=e.user+":"+e.password;E.authorization={key:"Authorization",value:"Basic "+c(s(t))}}null!=e.skipFetchSetup&&(w.skipFetchSetup=!!e.skipFetchSetup),null!=e.fetchOptions&&(w.fetchOptions=o(e.fetchOptions))}const v=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),C=g?g.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:g})}var S;t&&(w.method="POST",w.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})),w.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(w.body,O["content-type"]),requestMethod:w.method,timeout:R,url:g})))}),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(g,w),e<i)if(301===t.statusCode||302===t.statusCode){const e=t.headers.location||"";if("GET"===w.method&&e.match(/^https:/)){g=t.headers.location;continue}}else if(429===t.statusCode){let r=!0;if(a&&(r=yield a(e,g)),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(w.body,O["content-type"]),requestMethod:w.method,serverError:e,url:g}))}let o=t.body;if(b&&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(w.body,O["content-type"]),requestMethod:w.method,url:g})),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,g)),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(w.body,O["content-type"]),requestMethod:w.method,url:g})}return T.cancel(),o}return d.throwError("failed response",n.errors.SERVER_ERROR,{requestBody:p(w.body,O["content-type"]),requestMethod:w.method,url:g})}))}();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 g=Object.freeze({__proto__:null,_fetchData:y,fetchJson:m,poll:E});export{y as _,l as d,c as e,m as f,g as l,E as p};