@dodoex/wallet-web3 0.0.41-4 → 0.0.41-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DefaultJsonRpcProvider-6a21f359.js → DefaultJsonRpcProvider-39051876.js} +1 -1
- package/dist/__node-resolve_empty-8d36ef45.js +1 -0
- package/dist/__tslib-028c435c.js +1 -0
- package/dist/{blocto-1e01ed61.js → blocto-b1fd16e0.js} +1 -1
- package/dist/{bn-43db0a80.js → bn-6691dc4b.js} +1 -1
- package/dist/{browser-ponyfill-dbcd3487.js → browser-ponyfill-45febd35.js} +1 -1
- package/dist/cjs/{DefaultJsonRpcProvider-2896bdc6.cjs → DefaultJsonRpcProvider-9c49bc74.cjs} +1 -1
- package/dist/cjs/{__node-resolve_empty-1e1ab047.cjs → __node-resolve_empty-cc04456f.cjs} +1 -1
- package/dist/cjs/__tslib-1a913bb4.cjs +1 -0
- package/dist/cjs/{blocto-66f8432e.cjs → blocto-21bcf508.cjs} +1 -1
- package/dist/cjs/{bn-6c93fb4c.cjs → bn-f78d1a17.cjs} +1 -1
- package/dist/cjs/{browser-ponyfill-5cbcbec7.cjs → browser-ponyfill-1a8d200e.cjs} +1 -1
- package/dist/cjs/{draggabilly-f0c0e597.cjs → draggabilly-f1bb3b36.cjs} +1 -1
- package/dist/cjs/{ethers-5799ca27.cjs → ethers-b4443d90.cjs} +1 -1
- package/dist/cjs/{id-48662e0b.cjs → id-81d6569b.cjs} +1 -1
- package/dist/cjs/{index-7a5facb5.cjs → index-1cf2025a.cjs} +1 -1
- package/dist/cjs/index-2b6e2d0e.cjs +9 -0
- package/dist/cjs/{index-9898e190.cjs → index-2faa3982.cjs} +1 -1
- package/dist/cjs/{index-9bc0d4c3.cjs → index-39d0684d.cjs} +1 -1
- package/dist/cjs/{index-d36fba96.cjs → index-50ef639c.cjs} +1 -1
- package/dist/cjs/{index-6c6c6323.cjs → index-603ccd56.cjs} +1 -1
- package/dist/cjs/{index-48d95e72.cjs → index-61c5fbfc.cjs} +1 -1
- package/dist/cjs/{index-0dd9ae9a.cjs → index-7fb18b59.cjs} +1 -1
- package/dist/cjs/{index-0984de48.cjs → index-81e04477.cjs} +1 -1
- package/dist/cjs/{index-84bddb78.cjs → index-bb9d8efd.cjs} +2 -2
- package/dist/cjs/index-fec2b0e7.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/{index.es-d276a0c3.cjs → index.es-c188e54b.cjs} +1 -1
- package/dist/cjs/{interface-27dc9126.cjs → interface-847c070f.cjs} +1 -1
- package/dist/cjs/{lib-typedarrays-bf82ea24.cjs → lib-typedarrays-924fdb15.cjs} +1 -1
- package/dist/cjs/{portis-282159f7.cjs → portis-04649135.cjs} +1 -1
- package/dist/cjs/{provider-e4b2bc55.cjs → provider-55f49a37.cjs} +1 -1
- package/dist/cjs/{rainbow-77aec431.cjs → rainbow-331b4b7f.cjs} +1 -1
- package/dist/cjs/{sha224-770ad141.cjs → sha224-ec932277.cjs} +1 -1
- package/dist/cjs/{sha256-8765e543.cjs → sha256-a9306fd5.cjs} +1 -1
- package/dist/cjs/state.d.ts +1 -0
- package/dist/cjs/{uAuth-66e7f842.cjs → uAuth-f08a6bc1.cjs} +1 -1
- package/dist/cjs/{walletConnect-67671d50.cjs → walletConnect-4a8a9594.cjs} +1 -1
- package/dist/cjs/{walletLink-75d77597.cjs → walletLink-55148573.cjs} +1 -1
- package/dist/{draggabilly-542c5cae.js → draggabilly-bfad3669.js} +1 -1
- package/dist/{ethers-fe9fa84f.js → ethers-149a03bf.js} +1 -1
- package/dist/{id-693d7c84.js → id-9ebc6c25.js} +1 -1
- package/dist/{index-1bf00f8f.js → index-1fbb15b5.js} +2 -2
- package/dist/{index-3c3d04d7.js → index-2421fbca.js} +1 -1
- package/dist/{index-d5b21786.js → index-33d9ef5d.js} +1 -1
- package/dist/{index-1f918a4b.js → index-3fa89254.js} +1 -1
- package/dist/index-5bdb764f.js +9 -0
- package/dist/{index-ff04a168.js → index-660d9f03.js} +1 -1
- package/dist/{index-3bb899bf.js → index-b40bcea4.js} +1 -1
- package/dist/{index-e1a91fd3.js → index-bf8de361.js} +2 -2
- package/dist/{index-79f8a14f.js → index-c900ddbc.js} +1 -1
- package/dist/index-c953d0ac.js +1 -0
- package/dist/{index-f728f8ed.js → index-e4bf19f4.js} +1 -1
- package/dist/{index.es-c9a2db2c.js → index.es-5eecb376.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{interface-936da3ce.js → interface-b85b700d.js} +1 -1
- package/dist/{lib-typedarrays-38faff47.js → lib-typedarrays-a8e83421.js} +1 -1
- package/dist/{portis-76a8e487.js → portis-43f60af4.js} +1 -1
- package/dist/{provider-db6426ff.js → provider-301ac332.js} +1 -1
- package/dist/rainbow-23c1faed.js +1 -0
- package/dist/{sha224-2ced289a.js → sha224-c866b8af.js} +1 -1
- package/dist/{sha256-c1265a22.js → sha256-aa67d92b.js} +1 -1
- package/dist/state.d.ts +1 -0
- package/dist/{uAuth-b6bee9b3.js → uAuth-0c0662eb.js} +1 -1
- package/dist/{walletConnect-0903c9e0.js → walletConnect-6fa1fc97.js} +1 -1
- package/dist/{walletLink-a9316447.js → walletLink-88727a96.js} +1 -1
- package/package.json +1 -1
- package/dist/__node-resolve_empty-cca64a4a.js +0 -1
- package/dist/__tslib-b24ce2ae.js +0 -1
- package/dist/cjs/__tslib-e13a96b6.cjs +0 -1
- package/dist/cjs/index-529b9846.cjs +0 -1
- package/dist/cjs/index-fd18f5c9.cjs +0 -9
- package/dist/index-1137a917.js +0 -1
- package/dist/index-51ac6957.js +0 -9
- package/dist/rainbow-9a1e9915.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./index-
|
|
1
|
+
"use strict";var e=require("./index-2b6e2d0e.cjs"),r=require("@ethersproject/address");require("events");var t=require("@ethersproject/bytes"),n=require("./id-81d6569b.cjs"),i=require("./index-7fb18b59.cjs"),o=require("@ethersproject/abstract-signer"),s=require("./DefaultJsonRpcProvider-9c49bc74.cjs"),a=require("@ethersproject/properties");require("@ethersproject/providers"),require("zustand"),require("@ethersproject/constants"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("./bn-f78d1a17.cjs"),require("./__node-resolve_empty-cc04456f.cjs");class d extends o.Signer{constructor(e,r,t,n){super(),this._address=r,this._index=null!=t?t:0,this.provider=e,this.app=n}_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.__awaiter(this,void 0,void 0,(function*(){return Promise.resolve(r.getAddress(this._address))}))}signMessage(r){return e.__awaiter(this,void 0,void 0,(function*(){const i=e.getOwnerProvider(),o="string"==typeof r?n.toUtf8Bytes(r):r,s=yield this.getAddress();return yield i.send("personal_sign",[t.hexlify(o),s.toLowerCase()])}))}_signTypedData(r,t,n){var o,s;return e.__awaiter(this,void 0,void 0,(function*(){const a=e.getOwnerProvider(),d=yield i.TypedDataEncoder.resolveNames(r,t,n,(r=>e.__awaiter(this,void 0,void 0,(function*(){return yield a.resolveName(r)})))),c=null!==(s=null===(o=e.getCyberAccount())||void 0===o?void 0:o.ownerAddress)&&void 0!==s?s:"";return yield a.send("eth_signTypedData_v4",[c.toLowerCase(),JSON.stringify(i.TypedDataEncoder.getPayload(d.domain,t,d.value))])}))}signTransaction(r){return e.__awaiter(this,void 0,void 0,(function*(){throw new Error("Method not implemented.")}))}sendTransaction(r){return e.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getChainId(),n=e.getCyberChain(this.app,t);return{hash:yield n.sendTransaction({to:r.to,value:r.value,data:r.data}).catch((r=>{if(r.name===e.ErrorType.SendTransactionError&&(console.error(r.shortMessage),r.shortMessage))throw new Error(r.shortMessage);throw r}))}}))}connect(e){return new d(null!=e?e:this.provider,this._address,this._index,this.app)}connectUnchecked(){return new d(this.provider,this._address,this._index,this.app)}}exports.getIsCyber=e.getIsCyber,exports.default=function(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const i=yield function({appName:t,appLogoUrl:n,rpcUrl:i,rpc:o,chainId:c,cyberParams:u,JsonRpcProvider:h=s.DefaultJsonRpcProvider}){return e.__awaiter(this,void 0,void 0,(function*(){if(!t||!n)throw new Error("appName and appLogoUrl is required.");if(!(null==u?void 0:u.appId))throw new Error("cyberParams.appId and appLogoUrl is required.");const{app:s,cyberAccount:p}=yield e.connect({appName:t,appLogoUrl:n,appId:null==u?void 0:u.appId});if(!p)throw new Error("cyberAccount is not valid.");const l=p.address,v=new class extends h{constructor(r,t){super(r,t),this.updateUpWalletConfig=r=>{const t=null==o?void 0:o[r];if(!e.supportChains.includes(r))throw new Error(`chainId ${r} not supported`);if("object"==typeof this.network)this.network.chainId=r;else{const e={chainId:r,name:"unknown"};a.defineReadOnly(this,"_network",e),this.emit("network",e,null)}return this.rpcUrl=t,this.emit("chainChanged",`0x${r.toString(16)}`),{result:!0}}}getSigner(){return new d(v,l,0,s)}listAccounts(){return e.__awaiter(this,void 0,void 0,(function*(){return[l]}))}getAddress(){return Promise.resolve(r.getAddress(l))}}(i,c);return v}))}(t);return i.on("connect",n.connect),i.on("disconnect",n.disconnect),i.on("accountsChanged",n.accountsChanged),i.on("chainChanged",n.chainChanged),i.on("message",n.message),i}))},exports.switchChain=function(r){var t;const n=r.addChainParameters.chainId,i="string"==typeof n&&(null==n?void 0:n.startsWith("0x"))?parseInt(n,16):Number(n);if(!e.supportChains.includes(i))throw new Error(`chainId ${i} not supported`);return null===(t=e.useWalletStore.getState().provider)||void 0===t?void 0:t.updateUpWalletConfig(i)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./index-fd18f5c9.cjs"),t=require("@ethersproject/address"),n=require("@ethersproject/abstract-signer"),r=require("@ethersproject/providers"),o=require("@ethersproject/bytes"),i=require("./index-0dd9ae9a.cjs"),a=require("./index-d36fba96.cjs"),s=require("./ethers-5799ca27.cjs"),u=require("./id-48662e0b.cjs"),c=require("@ethersproject/json-wallets"),p=require("@ethersproject/properties"),l=require("./index-529b9846.cjs"),d=require("@ethersproject/transactions"),f=require("@ethersproject/contracts"),h=require("./DefaultJsonRpcProvider-2896bdc6.cjs");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("zustand"),require("events"),require("@ethersproject/constants"),require("./interface-27dc9126.cjs"),require("@ethersproject/abstract-provider"),require("./bn-6c93fb4c.cjs"),require("./__node-resolve_empty-1e1ab047.cjs"),require("./hash-7ce6fed5.cjs"),require("./inherits_browser-50deae74.cjs");var m,y=g(t),b=g(o),v=g(c),w=g(p),P=g(d),x=Object.freeze({__proto__:null,_toEscapedUtf8String:u._toEscapedUtf8String,toUtf8Bytes:u.toUtf8Bytes,toUtf8CodePoints:u.toUtf8CodePoints,toUtf8String:u.toUtf8String,Utf8ErrorFuncs:u.Utf8ErrorFuncs,get Utf8ErrorReason(){return u.Utf8ErrorReason},get UnicodeNormalizationForm(){return u.UnicodeNormalizationForm},formatBytes32String:s.formatBytes32String,parseBytes32String:s.parseBytes32String,nameprep:s.nameprep}),_=Object.freeze({__proto__:null,id:u.id,dnsEncode:s.dnsEncode,namehash:s.namehash,isValidName:s.isValidName,ensNormalize:s.ensNormalize,messagePrefix:s.messagePrefix,hashMessage:s.hashMessage,_TypedDataEncoder:i.TypedDataEncoder}),O=Object.freeze({__proto__:null,computeHmac:s.computeHmac,ripemd160:s.ripemd160,sha256:s.sha256,sha512:s.sha512,get SupportedAlgorithm(){return s.SupportedAlgorithm}}),j=Object.freeze({__proto__:null,randomBytes:s.randomBytes,shuffled:s.shuffled});class S extends n.Signer{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.__awaiter(this,void 0,void 0,(function*(){return Promise.resolve(t.getAddress(this._address))}))}signMessage(t){return e.__awaiter(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.__awaiter(this,void 0,void 0,(function*(){throw new Error("Method not implemented.")}))}signTransaction(t){return e.__awaiter(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.__awaiter(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 S(null!=e?e:this.provider,this.upWallet,this._address,this._index)}connectUnchecked(){return new S(this.provider,this.upWallet,this._address,this._index)}}!function(e){e.REGISTER="register"}(m||(m={}));var E,k=function(e,t,n,r,o){this.from=e,this.msg=t,this.type=n,this.isEIP191Prefix=r,this.onAuthChain=o},T=function(e,t){this.type=e,this.data=t},A=function(e,t,n){this.type=e,this.payload=t,this.appSetting=n};function U(){return U=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},U.apply(this,arguments)}!function(e){e.LIGHT="light",e.DARK="dark"}(E||(E={}));var C=function(e){return o.arrayify(function(e){var t=U({},e.types);return delete t.EIP712Domain,i.TypedDataEncoder.hash(e.domain,t,e.message)}(e))},L={},N=e.getAugmentedNamespace(s.lib_esm),I=e.getAugmentedNamespace(s.lib_esm$1),D=e.getAugmentedNamespace(_),R=e.getAugmentedNamespace(s.lib_esm$2),M=e.getAugmentedNamespace(e.lib_esm),B=e.getAugmentedNamespace(u.lib_esm),F=e.getAugmentedNamespace(O),z=e.getAugmentedNamespace(s.lib_esm$3),W=e.getAugmentedNamespace(j),q=e.getAugmentedNamespace(l.lib_esm),G=e.getAugmentedNamespace(s.lib_esm$4),J=e.getAugmentedNamespace(x),V=e.getAugmentedNamespace(s.lib_esm$5),H=e.getAugmentedNamespace(s.lib_esm$6),$=e.getAugmentedNamespace(i.lib_esm);function K(){K=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 u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function c(e,t,n,o){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype),s=new j(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=c;var l={};function d(){}function f(){}function h(){}var g={};u(g,i,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(S([])));y&&y!==t&&n.call(y,i)&&(g=y);var b=h.prototype=d.prototype=Object.create(g);function v(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function o(r,i,a,s){var u=p(e[r],e,i);if("throw"!==u.type){var c=u.arg,l=c.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){c.value=e,a(c)}),(function(e){return o("throw",e,a,s)}))}s(u.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 u=p(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.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 _(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 O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,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=u(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,u(e,s,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},v(w.prototype),u(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(c(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(b),u(b,s,"Generator"),u(b,i,(function(){return this})),u(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,j.prototype={constructor:j,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(O),!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"),u=n.call(i,"finallyLoc");if(s&&u){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(!u)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),O(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;O(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 Z(e,t,n,r,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,o)}function Y(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Z(i,r,o,a,s,"next",e)}function s(e){Z(i,r,o,a,s,"throw",e)}a(void 0)}))}}function Q(){return Q=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},Q.apply(this,arguments)}!function(t){var n=e.commonjsGlobal&&e.commonjsGlobal.__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]}),r=e.commonjsGlobal&&e.commonjsGlobal.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=e.commonjsGlobal&&e.commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&n(t,e,o);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=t.Utf8ErrorFuncs=t.toUtf8String=t.toUtf8CodePoints=t.toUtf8Bytes=t._toEscapedUtf8String=t.nameprep=t.hexDataSlice=t.hexDataLength=t.hexZeroPad=t.hexValue=t.hexStripZeros=t.hexConcat=t.isHexString=t.hexlify=t.base64=t.base58=t.TransactionDescription=t.LogDescription=t.Interface=t.SigningKey=t.HDNode=t.defaultPath=t.isBytesLike=t.isBytes=t.zeroPad=t.stripZeros=t.concat=t.arrayify=t.shallowCopy=t.resolveProperties=t.getStatic=t.defineReadOnly=t.deepCopy=t.checkProperties=t.poll=t.fetchJson=t._fetchData=t.RLP=t.Logger=t.checkResultErrors=t.FormatTypes=t.ParamType=t.FunctionFragment=t.EventFragment=t.ErrorFragment=t.ConstructorFragment=t.Fragment=t.defaultAbiCoder=t.AbiCoder=void 0,t.Indexed=t.Utf8ErrorReason=t.UnicodeNormalizationForm=t.SupportedAlgorithm=t.mnemonicToSeed=t.isValidMnemonic=t.entropyToMnemonic=t.mnemonicToEntropy=t.getAccountPath=t.verifyTypedData=t.verifyMessage=t.recoverPublicKey=t.computePublicKey=t.recoverAddress=t.computeAddress=t.getJsonWalletAddress=t.TransactionTypes=t.serializeTransaction=t.parseTransaction=t.accessListify=t.joinSignature=t.splitSignature=t.soliditySha256=t.solidityKeccak256=t.solidityPack=t.shuffled=t.randomBytes=t.sha512=t.sha256=t.ripemd160=t.keccak256=t.computeHmac=t.commify=t.parseUnits=t.formatUnits=t.parseEther=t.formatEther=t.isAddress=t.getCreate2Address=t.getContractAddress=t.getIcapAddress=t.getAddress=t._TypedDataEncoder=t.id=t.isValidName=t.namehash=t.hashMessage=t.dnsEncode=t.parseBytes32String=void 0;var i=a.require$$0;Object.defineProperty(t,"AbiCoder",{enumerable:!0,get:function(){return i.AbiCoder}}),Object.defineProperty(t,"checkResultErrors",{enumerable:!0,get:function(){return i.checkResultErrors}}),Object.defineProperty(t,"ConstructorFragment",{enumerable:!0,get:function(){return i.ConstructorFragment}}),Object.defineProperty(t,"defaultAbiCoder",{enumerable:!0,get:function(){return i.defaultAbiCoder}}),Object.defineProperty(t,"ErrorFragment",{enumerable:!0,get:function(){return i.ErrorFragment}}),Object.defineProperty(t,"EventFragment",{enumerable:!0,get:function(){return i.EventFragment}}),Object.defineProperty(t,"FormatTypes",{enumerable:!0,get:function(){return i.FormatTypes}}),Object.defineProperty(t,"Fragment",{enumerable:!0,get:function(){return i.Fragment}}),Object.defineProperty(t,"FunctionFragment",{enumerable:!0,get:function(){return i.FunctionFragment}}),Object.defineProperty(t,"Indexed",{enumerable:!0,get:function(){return i.Indexed}}),Object.defineProperty(t,"Interface",{enumerable:!0,get:function(){return i.Interface}}),Object.defineProperty(t,"LogDescription",{enumerable:!0,get:function(){return i.LogDescription}}),Object.defineProperty(t,"ParamType",{enumerable:!0,get:function(){return i.ParamType}}),Object.defineProperty(t,"TransactionDescription",{enumerable:!0,get:function(){return i.TransactionDescription}});var s=y.default;Object.defineProperty(t,"getAddress",{enumerable:!0,get:function(){return s.getAddress}}),Object.defineProperty(t,"getCreate2Address",{enumerable:!0,get:function(){return s.getCreate2Address}}),Object.defineProperty(t,"getContractAddress",{enumerable:!0,get:function(){return s.getContractAddress}}),Object.defineProperty(t,"getIcapAddress",{enumerable:!0,get:function(){return s.getIcapAddress}}),Object.defineProperty(t,"isAddress",{enumerable:!0,get:function(){return s.isAddress}});var u=o(N);t.base64=u;var c=I;Object.defineProperty(t,"base58",{enumerable:!0,get:function(){return c.Base58}});var p=b.default;Object.defineProperty(t,"arrayify",{enumerable:!0,get:function(){return p.arrayify}}),Object.defineProperty(t,"concat",{enumerable:!0,get:function(){return p.concat}}),Object.defineProperty(t,"hexConcat",{enumerable:!0,get:function(){return p.hexConcat}}),Object.defineProperty(t,"hexDataSlice",{enumerable:!0,get:function(){return p.hexDataSlice}}),Object.defineProperty(t,"hexDataLength",{enumerable:!0,get:function(){return p.hexDataLength}}),Object.defineProperty(t,"hexlify",{enumerable:!0,get:function(){return p.hexlify}}),Object.defineProperty(t,"hexStripZeros",{enumerable:!0,get:function(){return p.hexStripZeros}}),Object.defineProperty(t,"hexValue",{enumerable:!0,get:function(){return p.hexValue}}),Object.defineProperty(t,"hexZeroPad",{enumerable:!0,get:function(){return p.hexZeroPad}}),Object.defineProperty(t,"isBytes",{enumerable:!0,get:function(){return p.isBytes}}),Object.defineProperty(t,"isBytesLike",{enumerable:!0,get:function(){return p.isBytesLike}}),Object.defineProperty(t,"isHexString",{enumerable:!0,get:function(){return p.isHexString}}),Object.defineProperty(t,"joinSignature",{enumerable:!0,get:function(){return p.joinSignature}}),Object.defineProperty(t,"zeroPad",{enumerable:!0,get:function(){return p.zeroPad}}),Object.defineProperty(t,"splitSignature",{enumerable:!0,get:function(){return p.splitSignature}}),Object.defineProperty(t,"stripZeros",{enumerable:!0,get:function(){return p.stripZeros}});var l=D;Object.defineProperty(t,"_TypedDataEncoder",{enumerable:!0,get:function(){return l._TypedDataEncoder}}),Object.defineProperty(t,"dnsEncode",{enumerable:!0,get:function(){return l.dnsEncode}}),Object.defineProperty(t,"hashMessage",{enumerable:!0,get:function(){return l.hashMessage}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return l.id}}),Object.defineProperty(t,"isValidName",{enumerable:!0,get:function(){return l.isValidName}}),Object.defineProperty(t,"namehash",{enumerable:!0,get:function(){return l.namehash}});var d=R;Object.defineProperty(t,"defaultPath",{enumerable:!0,get:function(){return d.defaultPath}}),Object.defineProperty(t,"entropyToMnemonic",{enumerable:!0,get:function(){return d.entropyToMnemonic}}),Object.defineProperty(t,"getAccountPath",{enumerable:!0,get:function(){return d.getAccountPath}}),Object.defineProperty(t,"HDNode",{enumerable:!0,get:function(){return d.HDNode}}),Object.defineProperty(t,"isValidMnemonic",{enumerable:!0,get:function(){return d.isValidMnemonic}}),Object.defineProperty(t,"mnemonicToEntropy",{enumerable:!0,get:function(){return d.mnemonicToEntropy}}),Object.defineProperty(t,"mnemonicToSeed",{enumerable:!0,get:function(){return d.mnemonicToSeed}});var f=v.default;Object.defineProperty(t,"getJsonWalletAddress",{enumerable:!0,get:function(){return f.getJsonWalletAddress}});var h=M;Object.defineProperty(t,"keccak256",{enumerable:!0,get:function(){return h.keccak256}});var g=B;Object.defineProperty(t,"Logger",{enumerable:!0,get:function(){return g.Logger}});var m=F;Object.defineProperty(t,"computeHmac",{enumerable:!0,get:function(){return m.computeHmac}}),Object.defineProperty(t,"ripemd160",{enumerable:!0,get:function(){return m.ripemd160}}),Object.defineProperty(t,"sha256",{enumerable:!0,get:function(){return m.sha256}}),Object.defineProperty(t,"sha512",{enumerable:!0,get:function(){return m.sha512}});var x=z;Object.defineProperty(t,"solidityKeccak256",{enumerable:!0,get:function(){return x.keccak256}}),Object.defineProperty(t,"solidityPack",{enumerable:!0,get:function(){return x.pack}}),Object.defineProperty(t,"soliditySha256",{enumerable:!0,get:function(){return x.sha256}});var _=W;Object.defineProperty(t,"randomBytes",{enumerable:!0,get:function(){return _.randomBytes}}),Object.defineProperty(t,"shuffled",{enumerable:!0,get:function(){return _.shuffled}});var O=w.default;Object.defineProperty(t,"checkProperties",{enumerable:!0,get:function(){return O.checkProperties}}),Object.defineProperty(t,"deepCopy",{enumerable:!0,get:function(){return O.deepCopy}}),Object.defineProperty(t,"defineReadOnly",{enumerable:!0,get:function(){return O.defineReadOnly}}),Object.defineProperty(t,"getStatic",{enumerable:!0,get:function(){return O.getStatic}}),Object.defineProperty(t,"resolveProperties",{enumerable:!0,get:function(){return O.resolveProperties}}),Object.defineProperty(t,"shallowCopy",{enumerable:!0,get:function(){return O.shallowCopy}});var j=o(q);t.RLP=j;var S=G;Object.defineProperty(t,"computePublicKey",{enumerable:!0,get:function(){return S.computePublicKey}}),Object.defineProperty(t,"recoverPublicKey",{enumerable:!0,get:function(){return S.recoverPublicKey}}),Object.defineProperty(t,"SigningKey",{enumerable:!0,get:function(){return S.SigningKey}});var E=J;Object.defineProperty(t,"formatBytes32String",{enumerable:!0,get:function(){return E.formatBytes32String}}),Object.defineProperty(t,"nameprep",{enumerable:!0,get:function(){return E.nameprep}}),Object.defineProperty(t,"parseBytes32String",{enumerable:!0,get:function(){return E.parseBytes32String}}),Object.defineProperty(t,"_toEscapedUtf8String",{enumerable:!0,get:function(){return E._toEscapedUtf8String}}),Object.defineProperty(t,"toUtf8Bytes",{enumerable:!0,get:function(){return E.toUtf8Bytes}}),Object.defineProperty(t,"toUtf8CodePoints",{enumerable:!0,get:function(){return E.toUtf8CodePoints}}),Object.defineProperty(t,"toUtf8String",{enumerable:!0,get:function(){return E.toUtf8String}}),Object.defineProperty(t,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return E.Utf8ErrorFuncs}});var k=P.default;Object.defineProperty(t,"accessListify",{enumerable:!0,get:function(){return k.accessListify}}),Object.defineProperty(t,"computeAddress",{enumerable:!0,get:function(){return k.computeAddress}}),Object.defineProperty(t,"parseTransaction",{enumerable:!0,get:function(){return k.parse}}),Object.defineProperty(t,"recoverAddress",{enumerable:!0,get:function(){return k.recoverAddress}}),Object.defineProperty(t,"serializeTransaction",{enumerable:!0,get:function(){return k.serialize}}),Object.defineProperty(t,"TransactionTypes",{enumerable:!0,get:function(){return k.TransactionTypes}});var T=V;Object.defineProperty(t,"commify",{enumerable:!0,get:function(){return T.commify}}),Object.defineProperty(t,"formatEther",{enumerable:!0,get:function(){return T.formatEther}}),Object.defineProperty(t,"parseEther",{enumerable:!0,get:function(){return T.parseEther}}),Object.defineProperty(t,"formatUnits",{enumerable:!0,get:function(){return T.formatUnits}}),Object.defineProperty(t,"parseUnits",{enumerable:!0,get:function(){return T.parseUnits}});var A=H;Object.defineProperty(t,"verifyMessage",{enumerable:!0,get:function(){return A.verifyMessage}}),Object.defineProperty(t,"verifyTypedData",{enumerable:!0,get:function(){return A.verifyTypedData}});var U=$;Object.defineProperty(t,"_fetchData",{enumerable:!0,get:function(){return U._fetchData}}),Object.defineProperty(t,"fetchJson",{enumerable:!0,get:function(){return U.fetchJson}}),Object.defineProperty(t,"poll",{enumerable:!0,get:function(){return U.poll}});var C=F;Object.defineProperty(t,"SupportedAlgorithm",{enumerable:!0,get:function(){return C.SupportedAlgorithm}});var L=J;Object.defineProperty(t,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return L.UnicodeNormalizationForm}}),Object.defineProperty(t,"Utf8ErrorReason",{enumerable:!0,get:function(){return L.Utf8ErrorReason}})}(L);var X="wallet.unipass.id",ee={upDomain:X,upConnectUrl:"https://"+X+"/connect",upLogoutUrl:"https://"+X+"/logout",upSignMessageUrl:"https://"+X+"/sign-message",upTransactionUrl:"https://"+X+"/send-transaction",upLoadingUrl:"https://"+X+"/connect/loading"},te=function(){return ee},ne={protocol:"https",domain:"testnet.wallet.unipass.id"},re={protocol:"https",domain:"wallet.unipass.id"},oe={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"}},ie=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)}}},ae=function(){var e=Y(K().mark((function e(t,n){var r,o;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ie(t.storageType).get(Pe),e.t0=r&&JSON.parse(r),e.t0){e.next=6;break}return e.next=5,ue(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)}}(),se=function(){var e=Y(K().mark((function e(t){var n;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=4;break}return n=new A("UP_LOGOUT"),e.next=4,xe(n);case 4:ie("localStorage").remove(Pe),ie("sessionStorage").remove(Pe);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ue=function(){var e=Y(K().mark((function e(t,n){var r,o,i;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=n?JSON.stringify(n):"",o=new A("UP_LOGIN",r,t.appSettings),e.next=5,xe(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&&ie(t.storageType).set(Pe,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)}}(),ce="UP_WALLET_POP",pe=null,le=null;function de(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 fe(e,t,n){return he.apply(this,arguments)}function he(){return(he=Y(K().mark((function e(t,n,r){var o,i,a;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(null==pe||null!=(o=pe)&&o.closed)){e.next=8;break}if(null!=(pe=de(t,ce,window))){e.next=6;break}return e.next=5,ge(t,n,r);case 5:return e.abrupt("return",e.sent);case 6:e.next=9;break;case 8:le!==t?(pe.location.replace(t),pe.focus()):pe.focus();case 9:return i=setInterval((function(){if(pe&&pe.closed){var e={data:new A("UP_RESPONSE",JSON.stringify(new T("DECLINE","user reject connection")))};n(e,{close:function(){},send:function(){}}),clearInterval(i)}}),1e3),a=function(){pe&&!pe.closed&&pe.close(),pe=null},e.abrupt("return",{popup:pe,unmount:a});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ge(e,t,n){return me.apply(this,arguments)}function me(){return(me=Y(K().mark((function e(t,n,r){var o,i;return K().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(fe(t,n,r))}),!1)})));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ye=function(){};function be(e,t,n){if("UP_LOGIN"===e)return"google"===t?te().upConnectUrl+"?connectType=google&forceLogin="+(n?"1":"0"):"email"===t?te().upConnectUrl+"?connectType=email&forceLogin="+(n?"1":"0"):te().upConnectUrl+"?forceLogin="+(n?"1":"0");if("UP_LOGOUT"===e)return te().upLogoutUrl;if("UP_SIGN_MESSAGE"===e)return te().upSignMessageUrl;if("UP_TRANSACTION"===e)return te().upTransactionUrl;if("UP_READY"===e)return te().upLoadingUrl;throw new Error("unsupport type "+e)}function ve(e,t,n,r){return we.apply(this,arguments)}function we(){return we=Y(K().mark((function e(t,n,r,o){var i,a,s,u,c,p,l,d,f,h;return K().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&&u(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:ye,close:ye});case 5:return i=(null==o?void 0:o.onClose)||ye,a=(null==o?void 0:o.onMessage)||ye,s=(null==o?void 0:o.onReady)||ye,u=(null==o?void 0:o.onResponse)||ye,window.addEventListener("message",d),e.next=12,fe(be(t.type,n,r),u,t.appSetting);case 12:return c=e.sent,p=c.popup,l=c.unmount,e.abrupt("return",{send:h,close:f});case 16:case"end":return e.stop()}}),e)}))),we.apply(this,arguments)}var Pe="UP-A";function xe(e,t,n,r){return new Promise(function(){var o=Y(K().mark((function o(i,a){return K().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,ve(e,t,n,{onReady:function(t,n){return Y(K().mark((function t(){var r;return K().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 Y(K().mark((function r(){var o,s,u;return K().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,u=JSON.parse(s.payload),r.t0=u.type,r.next="APPROVE"===r.t0?9:"DECLINE"===r.t0?12:27;break;case 9:return i(u.data),o(),r.abrupt("break",30);case 12:if("expired"!==u.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(u.data),o(),r.abrupt("return");case 19:if("UP_TRANSACTION"!==e.type&&"UP_SIGN_MESSAGE"!==e.type){r.next=24;break}return se(!1),a("can not authorize without login"),o(),r.abrupt("break",30);case 24:return a("Declined: "+(u.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 Y(K().mark((function t(){var n,o;return K().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 Y(K().mark((function e(){return K().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 _e=function(){var e=Y(K().mark((function e(t,n){var r,o,i,a;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ie(n.storageType).get(Pe),(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 A("UP_SIGN_MESSAGE",JSON.stringify(t),null==n?void 0:n.appSettings),e.prev=5,e.next=8,xe(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)}}(),Oe=function(){var e=Y(K().mark((function e(t,n){var r,o,i,a;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ie(n.storageType).get(Pe),(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 A("UP_TRANSACTION",JSON.stringify(t),n.appSettings),e.prev=5,e.next=8,xe(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)}}(),je="0x1626ba7e";var Se=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,o=(t=this._config.env,n=this._config.chainType,{env:t,nodeRPC:"prod"===t?oe.mainnet[n]:oe.testnet[n],chainType:n,walletUrl:"prod"===t?re:ne});this._config.nodeRPC=e.nodeRPC||o.nodeRPC,this._config.appSettings=function(e,t){return Q({},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 r.JsonRpcProvider(this._config.nodeRPC),this._auth_provider=new r.JsonRpcProvider(function(e){return"prod"===e?oe.mainnet.polygon:oe.testnet.polygon}(this._config.env));var i,a,s,u=e.walletUrl||o.walletUrl;u&&(a=(i=u).domain,s=i.protocol,ee={upDomain:a=a||X,upConnectUrl:(s=s||"https")+"://"+a+"/connect",upLogoutUrl:s+"://"+a+"/logout",upSignMessageUrl:s+"://"+a+"/sign-message",upTransactionUrl:s+"://"+a+"/send-transaction",upLoadingUrl:s+"://"+a+"/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 r.JsonRpcProvider(this._config.nodeRPC)),e.appSettings&&(this._config.appSettings=e.appSettings))},t.login=function(){var e=Y(K().mark((function e(t){return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ae(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=ie(e).get(Pe))?JSON.parse(t):void 0},t.logout=function(){var e=Y(K().mark((function e(t){return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=!1),e.next=3,se(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=Y(K().mark((function e(t){return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),e.next=3,Oe(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=Y(K().mark((function e(t,n){var r,o,i,a,s;return K().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=L.toUtf8Bytes(t)),e.next=5,_e(new k(this.getAddress(),L.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=Y(K().mark((function e(t,n,r){var o,i;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r||(this.assertLogin(),r=this.getAddress()),o=new f.Contract(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=L.toUtf8Bytes(a)),L.keccak256(L.concat([L.toUtf8Bytes("UniPass Signed Message:\n"),L.toUtf8Bytes(String(a.length)),a]))),n);case 4:return i=e.sent,e.abrupt("return",i===je);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=Y(K().mark((function e(t,n){var r,o;return K().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,_e(new k(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=Y(K().mark((function e(t,n,r){var o,i,a;return K().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 f.Contract(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=C(t),e.next=7,o.isValidSignature(i,r);case 7:return a=e.sent,e.abrupt("return",a===je);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),e}();function Ee(n){var r,o,i;return e.__awaiter(this,void 0,void 0,(function*(){const a=n.JsonRpcProvider||h.DefaultJsonRpcProvider,s=null!==(r=n.chainId)&&void 0!==r?r:1;let u=null!==(o=n.rpcUrl)&&void 0!==o?o:null===(i=n.rpc)||void 0===i?void 0:i[s];const c=new class extends a{constructor(t,r){super(t,r),this.updateUpWalletConfig=t=>{var r;const o=null===(r=n.rpc)||void 0===r?void 0:r[t];if(!e.SUPPORTED_CHAIN_ID.includes(t))throw new Error(`chainId ${t} not supported`);if(this.upWallet.updateConfig({chainType:e.getChainNameByChainId(t),nodeRPC:o,appSettings:{chain:e.getChainNameByChainId(t)}}),"object"==typeof this.network)this.network.chainId=t;else{const e={chainId:t,name:"unknown"};p.defineReadOnly(this,"_network",e),this.emit("network",e,null)}return this.rpcUrl=o,this.emit("chainChanged",`0x${t.toString(16)}`),{result:!0}},this.rpcUrl=t,this.upWallet=new Se({env:e.getENVByChainId(s),chainType:e.getChainNameByChainId(s),appSettings:{appIcon:n.appLogoUrl,appName:n.appName,chain:e.getChainNameByChainId(s)},rpcUrl:u,storageType:"sessionStorage"})}getSigner(){var e;const t=this.upWallet.getAccount();return new S(c,this.upWallet,null!==(e=null==t?void 0:t.address)&&void 0!==e?e:"",0)}connect(){return e.__awaiter(this,void 0,void 0,(function*(){const e=this.upWallet.getAccount();return e||(yield this.upWallet.login({email:false}))}))}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.upWallet.logout()}))}listAccounts(){return e.__awaiter(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)?t.getAddress(null==e?void 0:e.address):null)}}(u,s);return c}))}exports.createProvider=Ee,exports.default=function(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield Ee(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}))},exports.disconnectWallet=function(){var t;null===(t=e.useWalletStore.getState().provider)||void 0===t||t.disconnect()},exports.signTypedData=function(t){var n,r;return null===(r=null===(n=e.useWalletStore.getState().provider)||void 0===n?void 0:n.upWallet)||void 0===r?void 0:r.signTypedData(t)},exports.switchChain=function(t){var n;const r=t.addChainParameters.chainId,o="string"==typeof r&&(null==r?void 0:r.startsWith("0x"))?parseInt(r,16):Number(r);if(!e.SUPPORTED_CHAIN_ID.includes(o))throw new Error(`chainId ${o} not supported`);return null===(n=e.useWalletStore.getState().provider)||void 0===n?void 0:n.updateUpWalletConfig(o)};
|
|
1
|
+
"use strict";var e=require("./index-2b6e2d0e.cjs"),t=require("@ethersproject/address"),n=require("@ethersproject/abstract-signer"),r=require("@ethersproject/providers"),o=require("@ethersproject/bytes"),i=require("./index-7fb18b59.cjs"),a=require("./index-50ef639c.cjs"),s=require("./ethers-b4443d90.cjs"),c=require("./id-81d6569b.cjs"),u=require("@ethersproject/json-wallets"),p=require("@ethersproject/properties"),l=require("./index-fec2b0e7.cjs"),d=require("@ethersproject/transactions"),f=require("@ethersproject/contracts"),h=require("./DefaultJsonRpcProvider-9c49bc74.cjs");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("zustand"),require("events"),require("@ethersproject/constants"),require("./interface-847c070f.cjs"),require("@ethersproject/abstract-provider"),require("./bn-f78d1a17.cjs"),require("./__node-resolve_empty-cc04456f.cjs"),require("./hash-7ce6fed5.cjs"),require("./inherits_browser-50deae74.cjs");var m,y=g(t),b=g(o),v=g(u),w=g(p),P=g(d),x=Object.freeze({__proto__:null,_toEscapedUtf8String:c._toEscapedUtf8String,toUtf8Bytes:c.toUtf8Bytes,toUtf8CodePoints:c.toUtf8CodePoints,toUtf8String:c.toUtf8String,Utf8ErrorFuncs:c.Utf8ErrorFuncs,get Utf8ErrorReason(){return c.Utf8ErrorReason},get UnicodeNormalizationForm(){return c.UnicodeNormalizationForm},formatBytes32String:s.formatBytes32String,parseBytes32String:s.parseBytes32String,nameprep:s.nameprep}),_=Object.freeze({__proto__:null,id:c.id,dnsEncode:s.dnsEncode,namehash:s.namehash,isValidName:s.isValidName,ensNormalize:s.ensNormalize,messagePrefix:s.messagePrefix,hashMessage:s.hashMessage,_TypedDataEncoder:i.TypedDataEncoder}),O=Object.freeze({__proto__:null,computeHmac:s.computeHmac,ripemd160:s.ripemd160,sha256:s.sha256,sha512:s.sha512,get SupportedAlgorithm(){return s.SupportedAlgorithm}}),j=Object.freeze({__proto__:null,randomBytes:s.randomBytes,shuffled:s.shuffled});class S extends n.Signer{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.__awaiter(this,void 0,void 0,(function*(){return Promise.resolve(t.getAddress(this._address))}))}signMessage(t){return e.__awaiter(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.__awaiter(this,void 0,void 0,(function*(){throw new Error("Method not implemented.")}))}signTransaction(t){return e.__awaiter(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.__awaiter(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 S(null!=e?e:this.provider,this.upWallet,this._address,this._index)}connectUnchecked(){return new S(this.provider,this.upWallet,this._address,this._index)}}!function(e){e.REGISTER="register"}(m||(m={}));var E,k=function(e,t,n,r,o){this.from=e,this.msg=t,this.type=n,this.isEIP191Prefix=r,this.onAuthChain=o},T=function(e,t){this.type=e,this.data=t},A=function(e,t,n){this.type=e,this.payload=t,this.appSetting=n};function U(){return U=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},U.apply(this,arguments)}!function(e){e.LIGHT="light",e.DARK="dark"}(E||(E={}));var C=function(e){return o.arrayify(function(e){var t=U({},e.types);return delete t.EIP712Domain,i.TypedDataEncoder.hash(e.domain,t,e.message)}(e))},L={},N=e.getAugmentedNamespace(s.lib_esm),I=e.getAugmentedNamespace(s.lib_esm$1),D=e.getAugmentedNamespace(_),R=e.getAugmentedNamespace(s.lib_esm$2),M=e.getAugmentedNamespace(e.lib_esm),B=e.getAugmentedNamespace(c.lib_esm),F=e.getAugmentedNamespace(O),z=e.getAugmentedNamespace(s.lib_esm$3),W=e.getAugmentedNamespace(j),q=e.getAugmentedNamespace(l.lib_esm),G=e.getAugmentedNamespace(s.lib_esm$4),J=e.getAugmentedNamespace(x),V=e.getAugmentedNamespace(s.lib_esm$5),H=e.getAugmentedNamespace(s.lib_esm$6),$=e.getAugmentedNamespace(i.lib_esm);function K(){K=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 j(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 m=Object.getPrototypeOf,y=m&&m(m(S([])));y&&y!==t&&n.call(y,i)&&(g=y);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 _(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 O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,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,j.prototype={constructor:j,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(O),!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),O(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;O(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 Z(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 Y(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Z(i,r,o,a,s,"next",e)}function s(e){Z(i,r,o,a,s,"throw",e)}a(void 0)}))}}function Q(){return Q=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},Q.apply(this,arguments)}!function(t){var n=e.commonjsGlobal&&e.commonjsGlobal.__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]}),r=e.commonjsGlobal&&e.commonjsGlobal.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=e.commonjsGlobal&&e.commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&n(t,e,o);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=t.Utf8ErrorFuncs=t.toUtf8String=t.toUtf8CodePoints=t.toUtf8Bytes=t._toEscapedUtf8String=t.nameprep=t.hexDataSlice=t.hexDataLength=t.hexZeroPad=t.hexValue=t.hexStripZeros=t.hexConcat=t.isHexString=t.hexlify=t.base64=t.base58=t.TransactionDescription=t.LogDescription=t.Interface=t.SigningKey=t.HDNode=t.defaultPath=t.isBytesLike=t.isBytes=t.zeroPad=t.stripZeros=t.concat=t.arrayify=t.shallowCopy=t.resolveProperties=t.getStatic=t.defineReadOnly=t.deepCopy=t.checkProperties=t.poll=t.fetchJson=t._fetchData=t.RLP=t.Logger=t.checkResultErrors=t.FormatTypes=t.ParamType=t.FunctionFragment=t.EventFragment=t.ErrorFragment=t.ConstructorFragment=t.Fragment=t.defaultAbiCoder=t.AbiCoder=void 0,t.Indexed=t.Utf8ErrorReason=t.UnicodeNormalizationForm=t.SupportedAlgorithm=t.mnemonicToSeed=t.isValidMnemonic=t.entropyToMnemonic=t.mnemonicToEntropy=t.getAccountPath=t.verifyTypedData=t.verifyMessage=t.recoverPublicKey=t.computePublicKey=t.recoverAddress=t.computeAddress=t.getJsonWalletAddress=t.TransactionTypes=t.serializeTransaction=t.parseTransaction=t.accessListify=t.joinSignature=t.splitSignature=t.soliditySha256=t.solidityKeccak256=t.solidityPack=t.shuffled=t.randomBytes=t.sha512=t.sha256=t.ripemd160=t.keccak256=t.computeHmac=t.commify=t.parseUnits=t.formatUnits=t.parseEther=t.formatEther=t.isAddress=t.getCreate2Address=t.getContractAddress=t.getIcapAddress=t.getAddress=t._TypedDataEncoder=t.id=t.isValidName=t.namehash=t.hashMessage=t.dnsEncode=t.parseBytes32String=void 0;var i=a.require$$0;Object.defineProperty(t,"AbiCoder",{enumerable:!0,get:function(){return i.AbiCoder}}),Object.defineProperty(t,"checkResultErrors",{enumerable:!0,get:function(){return i.checkResultErrors}}),Object.defineProperty(t,"ConstructorFragment",{enumerable:!0,get:function(){return i.ConstructorFragment}}),Object.defineProperty(t,"defaultAbiCoder",{enumerable:!0,get:function(){return i.defaultAbiCoder}}),Object.defineProperty(t,"ErrorFragment",{enumerable:!0,get:function(){return i.ErrorFragment}}),Object.defineProperty(t,"EventFragment",{enumerable:!0,get:function(){return i.EventFragment}}),Object.defineProperty(t,"FormatTypes",{enumerable:!0,get:function(){return i.FormatTypes}}),Object.defineProperty(t,"Fragment",{enumerable:!0,get:function(){return i.Fragment}}),Object.defineProperty(t,"FunctionFragment",{enumerable:!0,get:function(){return i.FunctionFragment}}),Object.defineProperty(t,"Indexed",{enumerable:!0,get:function(){return i.Indexed}}),Object.defineProperty(t,"Interface",{enumerable:!0,get:function(){return i.Interface}}),Object.defineProperty(t,"LogDescription",{enumerable:!0,get:function(){return i.LogDescription}}),Object.defineProperty(t,"ParamType",{enumerable:!0,get:function(){return i.ParamType}}),Object.defineProperty(t,"TransactionDescription",{enumerable:!0,get:function(){return i.TransactionDescription}});var s=y.default;Object.defineProperty(t,"getAddress",{enumerable:!0,get:function(){return s.getAddress}}),Object.defineProperty(t,"getCreate2Address",{enumerable:!0,get:function(){return s.getCreate2Address}}),Object.defineProperty(t,"getContractAddress",{enumerable:!0,get:function(){return s.getContractAddress}}),Object.defineProperty(t,"getIcapAddress",{enumerable:!0,get:function(){return s.getIcapAddress}}),Object.defineProperty(t,"isAddress",{enumerable:!0,get:function(){return s.isAddress}});var c=o(N);t.base64=c;var u=I;Object.defineProperty(t,"base58",{enumerable:!0,get:function(){return u.Base58}});var p=b.default;Object.defineProperty(t,"arrayify",{enumerable:!0,get:function(){return p.arrayify}}),Object.defineProperty(t,"concat",{enumerable:!0,get:function(){return p.concat}}),Object.defineProperty(t,"hexConcat",{enumerable:!0,get:function(){return p.hexConcat}}),Object.defineProperty(t,"hexDataSlice",{enumerable:!0,get:function(){return p.hexDataSlice}}),Object.defineProperty(t,"hexDataLength",{enumerable:!0,get:function(){return p.hexDataLength}}),Object.defineProperty(t,"hexlify",{enumerable:!0,get:function(){return p.hexlify}}),Object.defineProperty(t,"hexStripZeros",{enumerable:!0,get:function(){return p.hexStripZeros}}),Object.defineProperty(t,"hexValue",{enumerable:!0,get:function(){return p.hexValue}}),Object.defineProperty(t,"hexZeroPad",{enumerable:!0,get:function(){return p.hexZeroPad}}),Object.defineProperty(t,"isBytes",{enumerable:!0,get:function(){return p.isBytes}}),Object.defineProperty(t,"isBytesLike",{enumerable:!0,get:function(){return p.isBytesLike}}),Object.defineProperty(t,"isHexString",{enumerable:!0,get:function(){return p.isHexString}}),Object.defineProperty(t,"joinSignature",{enumerable:!0,get:function(){return p.joinSignature}}),Object.defineProperty(t,"zeroPad",{enumerable:!0,get:function(){return p.zeroPad}}),Object.defineProperty(t,"splitSignature",{enumerable:!0,get:function(){return p.splitSignature}}),Object.defineProperty(t,"stripZeros",{enumerable:!0,get:function(){return p.stripZeros}});var l=D;Object.defineProperty(t,"_TypedDataEncoder",{enumerable:!0,get:function(){return l._TypedDataEncoder}}),Object.defineProperty(t,"dnsEncode",{enumerable:!0,get:function(){return l.dnsEncode}}),Object.defineProperty(t,"hashMessage",{enumerable:!0,get:function(){return l.hashMessage}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return l.id}}),Object.defineProperty(t,"isValidName",{enumerable:!0,get:function(){return l.isValidName}}),Object.defineProperty(t,"namehash",{enumerable:!0,get:function(){return l.namehash}});var d=R;Object.defineProperty(t,"defaultPath",{enumerable:!0,get:function(){return d.defaultPath}}),Object.defineProperty(t,"entropyToMnemonic",{enumerable:!0,get:function(){return d.entropyToMnemonic}}),Object.defineProperty(t,"getAccountPath",{enumerable:!0,get:function(){return d.getAccountPath}}),Object.defineProperty(t,"HDNode",{enumerable:!0,get:function(){return d.HDNode}}),Object.defineProperty(t,"isValidMnemonic",{enumerable:!0,get:function(){return d.isValidMnemonic}}),Object.defineProperty(t,"mnemonicToEntropy",{enumerable:!0,get:function(){return d.mnemonicToEntropy}}),Object.defineProperty(t,"mnemonicToSeed",{enumerable:!0,get:function(){return d.mnemonicToSeed}});var f=v.default;Object.defineProperty(t,"getJsonWalletAddress",{enumerable:!0,get:function(){return f.getJsonWalletAddress}});var h=M;Object.defineProperty(t,"keccak256",{enumerable:!0,get:function(){return h.keccak256}});var g=B;Object.defineProperty(t,"Logger",{enumerable:!0,get:function(){return g.Logger}});var m=F;Object.defineProperty(t,"computeHmac",{enumerable:!0,get:function(){return m.computeHmac}}),Object.defineProperty(t,"ripemd160",{enumerable:!0,get:function(){return m.ripemd160}}),Object.defineProperty(t,"sha256",{enumerable:!0,get:function(){return m.sha256}}),Object.defineProperty(t,"sha512",{enumerable:!0,get:function(){return m.sha512}});var x=z;Object.defineProperty(t,"solidityKeccak256",{enumerable:!0,get:function(){return x.keccak256}}),Object.defineProperty(t,"solidityPack",{enumerable:!0,get:function(){return x.pack}}),Object.defineProperty(t,"soliditySha256",{enumerable:!0,get:function(){return x.sha256}});var _=W;Object.defineProperty(t,"randomBytes",{enumerable:!0,get:function(){return _.randomBytes}}),Object.defineProperty(t,"shuffled",{enumerable:!0,get:function(){return _.shuffled}});var O=w.default;Object.defineProperty(t,"checkProperties",{enumerable:!0,get:function(){return O.checkProperties}}),Object.defineProperty(t,"deepCopy",{enumerable:!0,get:function(){return O.deepCopy}}),Object.defineProperty(t,"defineReadOnly",{enumerable:!0,get:function(){return O.defineReadOnly}}),Object.defineProperty(t,"getStatic",{enumerable:!0,get:function(){return O.getStatic}}),Object.defineProperty(t,"resolveProperties",{enumerable:!0,get:function(){return O.resolveProperties}}),Object.defineProperty(t,"shallowCopy",{enumerable:!0,get:function(){return O.shallowCopy}});var j=o(q);t.RLP=j;var S=G;Object.defineProperty(t,"computePublicKey",{enumerable:!0,get:function(){return S.computePublicKey}}),Object.defineProperty(t,"recoverPublicKey",{enumerable:!0,get:function(){return S.recoverPublicKey}}),Object.defineProperty(t,"SigningKey",{enumerable:!0,get:function(){return S.SigningKey}});var E=J;Object.defineProperty(t,"formatBytes32String",{enumerable:!0,get:function(){return E.formatBytes32String}}),Object.defineProperty(t,"nameprep",{enumerable:!0,get:function(){return E.nameprep}}),Object.defineProperty(t,"parseBytes32String",{enumerable:!0,get:function(){return E.parseBytes32String}}),Object.defineProperty(t,"_toEscapedUtf8String",{enumerable:!0,get:function(){return E._toEscapedUtf8String}}),Object.defineProperty(t,"toUtf8Bytes",{enumerable:!0,get:function(){return E.toUtf8Bytes}}),Object.defineProperty(t,"toUtf8CodePoints",{enumerable:!0,get:function(){return E.toUtf8CodePoints}}),Object.defineProperty(t,"toUtf8String",{enumerable:!0,get:function(){return E.toUtf8String}}),Object.defineProperty(t,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return E.Utf8ErrorFuncs}});var k=P.default;Object.defineProperty(t,"accessListify",{enumerable:!0,get:function(){return k.accessListify}}),Object.defineProperty(t,"computeAddress",{enumerable:!0,get:function(){return k.computeAddress}}),Object.defineProperty(t,"parseTransaction",{enumerable:!0,get:function(){return k.parse}}),Object.defineProperty(t,"recoverAddress",{enumerable:!0,get:function(){return k.recoverAddress}}),Object.defineProperty(t,"serializeTransaction",{enumerable:!0,get:function(){return k.serialize}}),Object.defineProperty(t,"TransactionTypes",{enumerable:!0,get:function(){return k.TransactionTypes}});var T=V;Object.defineProperty(t,"commify",{enumerable:!0,get:function(){return T.commify}}),Object.defineProperty(t,"formatEther",{enumerable:!0,get:function(){return T.formatEther}}),Object.defineProperty(t,"parseEther",{enumerable:!0,get:function(){return T.parseEther}}),Object.defineProperty(t,"formatUnits",{enumerable:!0,get:function(){return T.formatUnits}}),Object.defineProperty(t,"parseUnits",{enumerable:!0,get:function(){return T.parseUnits}});var A=H;Object.defineProperty(t,"verifyMessage",{enumerable:!0,get:function(){return A.verifyMessage}}),Object.defineProperty(t,"verifyTypedData",{enumerable:!0,get:function(){return A.verifyTypedData}});var U=$;Object.defineProperty(t,"_fetchData",{enumerable:!0,get:function(){return U._fetchData}}),Object.defineProperty(t,"fetchJson",{enumerable:!0,get:function(){return U.fetchJson}}),Object.defineProperty(t,"poll",{enumerable:!0,get:function(){return U.poll}});var C=F;Object.defineProperty(t,"SupportedAlgorithm",{enumerable:!0,get:function(){return C.SupportedAlgorithm}});var L=J;Object.defineProperty(t,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return L.UnicodeNormalizationForm}}),Object.defineProperty(t,"Utf8ErrorReason",{enumerable:!0,get:function(){return L.Utf8ErrorReason}})}(L);var X="wallet.unipass.id",ee={upDomain:X,upConnectUrl:"https://"+X+"/connect",upLogoutUrl:"https://"+X+"/logout",upSignMessageUrl:"https://"+X+"/sign-message",upTransactionUrl:"https://"+X+"/send-transaction",upLoadingUrl:"https://"+X+"/connect/loading"},te=function(){return ee},ne={protocol:"https",domain:"testnet.wallet.unipass.id"},re={protocol:"https",domain:"wallet.unipass.id"},oe={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"}},ie=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)}}},ae=function(){var e=Y(K().mark((function e(t,n){var r,o;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ie(t.storageType).get(Pe),e.t0=r&&JSON.parse(r),e.t0){e.next=6;break}return e.next=5,ce(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)}}(),se=function(){var e=Y(K().mark((function e(t){var n;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=4;break}return n=new A("UP_LOGOUT"),e.next=4,xe(n);case 4:ie("localStorage").remove(Pe),ie("sessionStorage").remove(Pe);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=Y(K().mark((function e(t,n){var r,o,i;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=n?JSON.stringify(n):"",o=new A("UP_LOGIN",r,t.appSettings),e.next=5,xe(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&&ie(t.storageType).set(Pe,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)}}(),ue="UP_WALLET_POP",pe=null,le=null;function de(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 fe(e,t,n){return he.apply(this,arguments)}function he(){return(he=Y(K().mark((function e(t,n,r){var o,i,a;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(null==pe||null!=(o=pe)&&o.closed)){e.next=8;break}if(null!=(pe=de(t,ue,window))){e.next=6;break}return e.next=5,ge(t,n,r);case 5:return e.abrupt("return",e.sent);case 6:e.next=9;break;case 8:le!==t?(pe.location.replace(t),pe.focus()):pe.focus();case 9:return i=setInterval((function(){if(pe&&pe.closed){var e={data:new A("UP_RESPONSE",JSON.stringify(new T("DECLINE","user reject connection")))};n(e,{close:function(){},send:function(){}}),clearInterval(i)}}),1e3),a=function(){pe&&!pe.closed&&pe.close(),pe=null},e.abrupt("return",{popup:pe,unmount:a});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ge(e,t,n){return me.apply(this,arguments)}function me(){return(me=Y(K().mark((function e(t,n,r){var o,i;return K().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(fe(t,n,r))}),!1)})));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ye=function(){};function be(e,t,n){if("UP_LOGIN"===e)return"google"===t?te().upConnectUrl+"?connectType=google&forceLogin="+(n?"1":"0"):"email"===t?te().upConnectUrl+"?connectType=email&forceLogin="+(n?"1":"0"):te().upConnectUrl+"?forceLogin="+(n?"1":"0");if("UP_LOGOUT"===e)return te().upLogoutUrl;if("UP_SIGN_MESSAGE"===e)return te().upSignMessageUrl;if("UP_TRANSACTION"===e)return te().upTransactionUrl;if("UP_READY"===e)return te().upLoadingUrl;throw new Error("unsupport type "+e)}function ve(e,t,n,r){return we.apply(this,arguments)}function we(){return we=Y(K().mark((function e(t,n,r,o){var i,a,s,c,u,p,l,d,f,h;return K().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:ye,close:ye});case 5:return i=(null==o?void 0:o.onClose)||ye,a=(null==o?void 0:o.onMessage)||ye,s=(null==o?void 0:o.onReady)||ye,c=(null==o?void 0:o.onResponse)||ye,window.addEventListener("message",d),e.next=12,fe(be(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)}))),we.apply(this,arguments)}var Pe="UP-A";function xe(e,t,n,r){return new Promise(function(){var o=Y(K().mark((function o(i,a){return K().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,ve(e,t,n,{onReady:function(t,n){return Y(K().mark((function t(){var r;return K().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 Y(K().mark((function r(){var o,s,c;return K().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 se(!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 Y(K().mark((function t(){var n,o;return K().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 Y(K().mark((function e(){return K().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 _e=function(){var e=Y(K().mark((function e(t,n){var r,o,i,a;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ie(n.storageType).get(Pe),(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 A("UP_SIGN_MESSAGE",JSON.stringify(t),null==n?void 0:n.appSettings),e.prev=5,e.next=8,xe(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)}}(),Oe=function(){var e=Y(K().mark((function e(t,n){var r,o,i,a;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ie(n.storageType).get(Pe),(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 A("UP_TRANSACTION",JSON.stringify(t),n.appSettings),e.prev=5,e.next=8,xe(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)}}(),je="0x1626ba7e";var Se=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,o=(t=this._config.env,n=this._config.chainType,{env:t,nodeRPC:"prod"===t?oe.mainnet[n]:oe.testnet[n],chainType:n,walletUrl:"prod"===t?re:ne});this._config.nodeRPC=e.nodeRPC||o.nodeRPC,this._config.appSettings=function(e,t){return Q({},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 r.JsonRpcProvider(this._config.nodeRPC),this._auth_provider=new r.JsonRpcProvider(function(e){return"prod"===e?oe.mainnet.polygon:oe.testnet.polygon}(this._config.env));var i,a,s,c=e.walletUrl||o.walletUrl;c&&(a=(i=c).domain,s=i.protocol,ee={upDomain:a=a||X,upConnectUrl:(s=s||"https")+"://"+a+"/connect",upLogoutUrl:s+"://"+a+"/logout",upSignMessageUrl:s+"://"+a+"/sign-message",upTransactionUrl:s+"://"+a+"/send-transaction",upLoadingUrl:s+"://"+a+"/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 r.JsonRpcProvider(this._config.nodeRPC)),e.appSettings&&(this._config.appSettings=e.appSettings))},t.login=function(){var e=Y(K().mark((function e(t){return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ae(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=ie(e).get(Pe))?JSON.parse(t):void 0},t.logout=function(){var e=Y(K().mark((function e(t){return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=!1),e.next=3,se(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=Y(K().mark((function e(t){return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),e.next=3,Oe(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=Y(K().mark((function e(t,n){var r,o,i,a,s;return K().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=L.toUtf8Bytes(t)),e.next=5,_e(new k(this.getAddress(),L.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=Y(K().mark((function e(t,n,r){var o,i;return K().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r||(this.assertLogin(),r=this.getAddress()),o=new f.Contract(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=L.toUtf8Bytes(a)),L.keccak256(L.concat([L.toUtf8Bytes("UniPass Signed Message:\n"),L.toUtf8Bytes(String(a.length)),a]))),n);case 4:return i=e.sent,e.abrupt("return",i===je);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=Y(K().mark((function e(t,n){var r,o;return K().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,_e(new k(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=Y(K().mark((function e(t,n,r){var o,i,a;return K().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 f.Contract(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=C(t),e.next=7,o.isValidSignature(i,r);case 7:return a=e.sent,e.abrupt("return",a===je);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),e}();function Ee(n){var r,o,i;return e.__awaiter(this,void 0,void 0,(function*(){const a=n.JsonRpcProvider||h.DefaultJsonRpcProvider,s=null!==(r=n.chainId)&&void 0!==r?r:1;let c=null!==(o=n.rpcUrl)&&void 0!==o?o:null===(i=n.rpc)||void 0===i?void 0:i[s];const u=new class extends a{constructor(t,r){super(t,r),this.updateUpWalletConfig=t=>{var r;const o=null===(r=n.rpc)||void 0===r?void 0:r[t];if(!e.SUPPORTED_CHAIN_ID.includes(t))throw new Error(`chainId ${t} not supported`);if(this.upWallet.updateConfig({chainType:e.getChainNameByChainId(t),nodeRPC:o,appSettings:{chain:e.getChainNameByChainId(t)}}),"object"==typeof this.network)this.network.chainId=t;else{const e={chainId:t,name:"unknown"};p.defineReadOnly(this,"_network",e),this.emit("network",e,null)}return this.rpcUrl=o,this.emit("chainChanged",`0x${t.toString(16)}`),{result:!0}},this.rpcUrl=t,this.upWallet=new Se({env:e.getENVByChainId(s),chainType:e.getChainNameByChainId(s),appSettings:{appIcon:n.appLogoUrl,appName:n.appName,chain:e.getChainNameByChainId(s)},rpcUrl:c,storageType:"sessionStorage"})}getSigner(){var e;const t=this.upWallet.getAccount();return new S(u,this.upWallet,null!==(e=null==t?void 0:t.address)&&void 0!==e?e:"",0)}connect(){return e.__awaiter(this,void 0,void 0,(function*(){const e=this.upWallet.getAccount();return e||(yield this.upWallet.login({email:false}))}))}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.upWallet.logout()}))}listAccounts(){return e.__awaiter(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)?t.getAddress(null==e?void 0:e.address):null)}}(c,s);return u}))}exports.createProvider=Ee,exports.default=function(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield Ee(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}))},exports.disconnectWallet=function(){var t;null===(t=e.useWalletStore.getState().provider)||void 0===t||t.disconnect()},exports.signTypedData=function(t){var n,r;return null===(r=null===(n=e.useWalletStore.getState().provider)||void 0===n?void 0:n.upWallet)||void 0===r?void 0:r.signTypedData(t)},exports.switchChain=function(t){var n;const r=t.addChainParameters.chainId,o="string"==typeof r&&(null==r?void 0:r.startsWith("0x"))?parseInt(r,16):Number(r);if(!e.SUPPORTED_CHAIN_ID.includes(o))throw new Error(`chainId ${o} not supported`);return null===(n=e.useWalletStore.getState().provider)||void 0===n?void 0:n.updateUpWalletConfig(o)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@ethersproject/address"),e=require("@ethersproject/bytes"),r=require("./index-fd18f5c9.cjs"),n=require("@ethersproject/properties"),o=require("./id-48662e0b.cjs");const i="hash/5.7.0";function s(t){t=atob(t);const r=[];for(let e=0;e<t.length;e++)r.push(t.charCodeAt(e));return e.arrayify(r)}function a(t){t=e.arrayify(t);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return btoa(r)}var c=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};const u=new o.Logger(i),l=new Uint8Array(32);l.fill(0);const f=o.BigNumber.from(-1),h=o.BigNumber.from(0),d=o.BigNumber.from(1),y=o.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const p=e.hexZeroPad(d.toHexString(),32),m=e.hexZeroPad(h.toHexString(),32),g={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},v=["name","version","chainId","verifyingContract","salt"];function w(t){return function(e){return"string"!=typeof e&&u.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const E={name:w("name"),version:w("version"),chainId:function(t){try{return o.BigNumber.from(t).toString()}catch(t){}return u.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(e){try{return t.getAddress(e).toLowerCase()}catch(t){}return u.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",e)},salt:function(t){try{const r=e.arrayify(t);if(32!==r.length)throw new Error("bad length");return e.hexlify(r)}catch(t){}return u.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function b(n){{const t=n.match(/^(u?)int(\d*)$/);if(t){const r=""===t[1],i=parseInt(t[2]||"256");(i%8!=0||i>256||t[2]&&t[2]!==String(i))&&u.throwArgumentError("invalid numeric width","type",n);const s=y.mask(r?i-1:i),a=r?s.add(d).mul(f):h;return function(t){const r=o.BigNumber.from(t);return(r.lt(a)||r.gt(s))&&u.throwArgumentError(`value out-of-bounds for ${n}`,"value",t),e.hexZeroPad(r.toTwos(256).toHexString(),32)}}}{const t=n.match(/^bytes(\d+)$/);if(t){const r=parseInt(t[1]);return(0===r||r>32||t[1]!==String(r))&&u.throwArgumentError("invalid bytes width","type",n),function(t){return e.arrayify(t).length!==r&&u.throwArgumentError(`invalid length for ${n}`,"value",t),function(t){const r=e.arrayify(t),n=r.length%32;return n?e.hexConcat([r,l.slice(n)]):e.hexlify(r)}(t)}}}switch(n){case"address":return function(r){return e.hexZeroPad(t.getAddress(r),32)};case"bool":return function(t){return t?p:m};case"bytes":return function(t){return r.keccak256(t)};case"string":return function(t){return o.id(t)}}return null}function x(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class C{constructor(t){n.defineReadOnly(this,"types",Object.freeze(n.deepCopy(t))),n.defineReadOnly(this,"_encoderCache",{}),n.defineReadOnly(this,"_types",{});const e={},r={},o={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],o[t]={}}));for(const n in t){const o={};t[n].forEach((i=>{o[i.name]&&u.throwArgumentError(`duplicate variable name ${JSON.stringify(i.name)} in ${JSON.stringify(n)}`,"types",t),o[i.name]=!0;const s=i.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&u.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",t);b(s)||(r[s]||u.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",t),r[s].push(n),e[n][s]=!0)}))}const i=Object.keys(r).filter((t=>0===r[t].length));0===i.length?u.throwArgumentError("missing primary type","types",t):i.length>1&&u.throwArgumentError(`ambiguous primary types or unused types: ${i.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),n.defineReadOnly(this,"primaryType",i[0]),function n(i,s){s[i]&&u.throwArgumentError(`circular type reference to ${JSON.stringify(i)}`,"types",t),s[i]=!0,Object.keys(e[i]).forEach((t=>{r[t]&&(n(t,s),Object.keys(s).forEach((e=>{o[e][t]=!0})))})),delete s[i]}(this.primaryType,{});for(const e in o){const r=Object.keys(o[e]);r.sort(),this._types[e]=x(e,t[e])+r.map((e=>x(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=b(t);if(e)return e}const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],o=this.getEncoder(t),i=parseInt(n[3]);return n=>{i>=0&&n.length!==i&&u.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",n);let s=n.map(o);return this._types[t]&&(s=s.map(r.keccak256)),r.keccak256(e.hexConcat(s))}}const i=this.types[t];if(i){const n=o.id(this._types[t]);return t=>{const o=i.map((({name:e,type:n})=>{const o=this.getEncoder(n)(t[e]);return this._types[n]?r.keccak256(o):o}));return o.unshift(n),e.hexConcat(o)}}return u.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||u.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return r.keccak256(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(b(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],o=parseInt(n[3]);return o>=0&&e.length!==o&&u.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const o=this.types[t];return o?o.reduce(((t,{name:n,type:o})=>(t[n]=this._visit(o,e[n],r),t)),{}):u.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new C(t)}static getPrimaryType(t){return C.from(t).primaryType}static hashStruct(t,e,r){return C.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=g[r];n||u.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort(((t,e)=>v.indexOf(t.name)-v.indexOf(e.name))),C.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,r,n){return e.hexConcat(["0x1901",C.hashDomain(t),C.from(r).hash(n)])}static hash(t,e,n){return r.keccak256(C.encode(t,e,n))}static resolveNames(t,r,o,i){return c(this,void 0,void 0,(function*(){t=n.shallowCopy(t);const s={};t.verifyingContract&&!e.isHexString(t.verifyingContract,20)&&(s[t.verifyingContract]="0x");const a=C.from(r);a.visit(o,((t,r)=>("address"!==t||e.isHexString(r,20)||(s[r]="0x"),r)));for(const t in s)s[t]=yield i(t);return t.verifyingContract&&s[t.verifyingContract]&&(t.verifyingContract=s[t.verifyingContract]),o=a.visit(o,((t,e)=>"address"===t&&s[e]?s[e]:e)),{domain:t,value:o}}))}static getPayload(t,r,i){C.hashDomain(t);const s={},a=[];v.forEach((e=>{const r=t[e];null!=r&&(s[e]=E[e](r),a.push({name:e,type:g[e]}))}));const c=C.from(r),l=n.shallowCopy(r);return l.EIP712Domain?u.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",r):l.EIP712Domain=a,c.encode(i),{types:l,domain:s,primaryType:c.primaryType,message:c.visit(i,((t,r)=>{if(t.match(/^bytes(\d*)/))return e.hexlify(e.arrayify(r));if(t.match(/^u?int/))return o.BigNumber.from(r).toString();switch(t){case"address":return r.toLowerCase();case"bool":return!!r;case"string":return"string"!=typeof r&&u.throwArgumentError("invalid string","value",r),r}return u.throwArgumentError("unsupported type","type",t)}))}}}var S=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};function k(t,r){return S(this,void 0,void 0,(function*(){null==r&&(r={});const n={method:r.method||"GET",headers:r.headers||{},body:r.body||void 0};if(!0!==r.skipFetchSetup&&(n.mode="cors",n.cache="no-cache",n.credentials="same-origin",n.redirect="follow",n.referrer="client"),null!=r.fetchOptions){const t=r.fetchOptions;t.mode&&(n.mode=t.mode),t.cache&&(n.cache=t.cache),t.credentials&&(n.credentials=t.credentials),t.redirect&&(n.redirect=t.redirect),t.referrer&&(n.referrer=t.referrer)}const o=yield fetch(t,n),i=yield o.arrayBuffer(),s={};return o.headers.forEach?o.headers.forEach(((t,e)=>{s[e.toLowerCase()]=t})):o.headers.keys().forEach((t=>{s[t.toLowerCase()]=o.headers.get(t)})),{headers:s,statusCode:o.status,statusMessage:o.statusText,body:e.arrayify(new Uint8Array(i))}}))}var O=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};const R=new o.Logger("web/5.7.1");function A(t){return new Promise((e=>{setTimeout(e,t)}))}function T(t,r){if(null==t)return null;if("string"==typeof t)return t;if(e.isBytesLike(t)){if(r&&("text"===r.split("/")[0]||"application/json"===r.split(";")[0].trim()))try{return o.toUtf8String(t)}catch(t){}return e.hexlify(t)}return t}function _(t,e,r){const i="object"==typeof t&&null!=t.throttleLimit?t.throttleLimit:12;R.assertArgument(i>0&&i%1==0,"invalid connection throttle limit","connection.throttleLimit",i);const c="object"==typeof t?t.throttleCallback:null,u="object"==typeof t&&"number"==typeof t.throttleSlotInterval?t.throttleSlotInterval:100;R.assertArgument(u>0&&u%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",u);const l="object"==typeof t&&!!t.errorPassThrough,f={};let h=null;const d={method:"GET"};let y=!1,p=12e4;if("string"==typeof t)h=t;else if("object"==typeof t){if(null!=t&&null!=t.url||R.throwArgumentError("missing URL","connection.url",t),h=t.url,"number"==typeof t.timeout&&t.timeout>0&&(p=t.timeout),t.headers)for(const e in t.headers)f[e.toLowerCase()]={key:e,value:String(t.headers[e])},["if-none-match","if-modified-since"].indexOf(e.toLowerCase())>=0&&(y=!0);if(d.allowGzip=!!t.allowGzip,null!=t.user&&null!=t.password){"https:"!==h.substring(0,6)&&!0!==t.allowInsecureAuthentication&&R.throwError("basic authentication requires a secure https url",o.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:h,user:t.user,password:"[REDACTED]"});const e=t.user+":"+t.password;f.authorization={key:"Authorization",value:"Basic "+a(o.toUtf8Bytes(e))}}null!=t.skipFetchSetup&&(d.skipFetchSetup=!!t.skipFetchSetup),null!=t.fetchOptions&&(d.fetchOptions=n.shallowCopy(t.fetchOptions))}const m=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),g=h?h.match(m):null;if(g)try{const t={statusCode:200,statusMessage:"OK",headers:{"content-type":g[1]||"text/plain"},body:g[2]?s(g[3]):(v=g[3],o.toUtf8Bytes(v.replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))};let e=t.body;return r&&(e=r(t.body,t)),Promise.resolve(e)}catch(t){R.throwError("processing response error",o.Logger.errors.SERVER_ERROR,{body:T(g[1],g[2]),error:t,requestBody:null,requestMethod:"GET",url:h})}var v;e&&(d.method="POST",d.body=e,null==f["content-type"]&&(f["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==f["content-length"]&&(f["content-length"]={key:"Content-Length",value:String(e.length)}));const w={};Object.keys(f).forEach((t=>{const e=f[t];w[e.key]=e.value})),d.headers=w;const E=function(){let t=null;return{promise:new Promise((function(e,r){p&&(t=setTimeout((()=>{null!=t&&(t=null,r(R.makeError("timeout",o.Logger.errors.TIMEOUT,{requestBody:T(d.body,w["content-type"]),requestMethod:d.method,timeout:p,url:h})))}),p))})),cancel:function(){null!=t&&(clearTimeout(t),t=null)}}}(),b=function(){return O(this,void 0,void 0,(function*(){for(let t=0;t<i;t++){let e=null;try{if(e=yield k(h,d),t<i)if(301===e.statusCode||302===e.statusCode){const t=e.headers.location||"";if("GET"===d.method&&t.match(/^https:/)){h=e.headers.location;continue}}else if(429===e.statusCode){let r=!0;if(c&&(r=yield c(t,h)),r){let r=0;const n=e.headers["retry-after"];r="string"==typeof n&&n.match(/^[1-9][0-9]*$/)?1e3*parseInt(n):u*parseInt(String(Math.random()*Math.pow(2,t))),yield A(r);continue}}}catch(t){e=t.response,null==e&&(E.cancel(),R.throwError("missing response",o.Logger.errors.SERVER_ERROR,{requestBody:T(d.body,w["content-type"]),requestMethod:d.method,serverError:t,url:h}))}let n=e.body;if(y&&304===e.statusCode?n=null:!l&&(e.statusCode<200||e.statusCode>=300)&&(E.cancel(),R.throwError("bad response",o.Logger.errors.SERVER_ERROR,{status:e.statusCode,headers:e.headers,body:T(n,e.headers?e.headers["content-type"]:null),requestBody:T(d.body,w["content-type"]),requestMethod:d.method,url:h})),r)try{const t=yield r(n,e);return E.cancel(),t}catch(r){if(r.throttleRetry&&t<i){let e=!0;if(c&&(e=yield c(t,h)),e){const e=u*parseInt(String(Math.random()*Math.pow(2,t)));yield A(e);continue}}E.cancel(),R.throwError("processing response error",o.Logger.errors.SERVER_ERROR,{body:T(n,e.headers?e.headers["content-type"]:null),error:r,requestBody:T(d.body,w["content-type"]),requestMethod:d.method,url:h})}return E.cancel(),n}return R.throwError("failed response",o.Logger.errors.SERVER_ERROR,{requestBody:T(d.body,w["content-type"]),requestMethod:d.method,url:h})}))}();return Promise.race([E.promise,b])}function I(t,e,r){let i=null;if(null!=e){i=o.toUtf8Bytes(e);const r="string"==typeof t?{url:t}:n.shallowCopy(t);if(r.headers){0!==Object.keys(r.headers).filter((t=>"content-type"===t.toLowerCase())).length||(r.headers=n.shallowCopy(r.headers),r.headers["content-type"]="application/json")}else r.headers={"content-type":"application/json"};t=r}return _(t,i,((t,e)=>{let n=null;if(null!=t)try{n=JSON.parse(o.toUtf8String(t))}catch(e){R.throwError("invalid JSON",o.Logger.errors.SERVER_ERROR,{body:t,error:e})}return r&&(n=r(n,e)),n}))}function L(t,e){return e||(e={}),null==(e=n.shallowCopy(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise((function(r,n){let o=null,i=!1;const s=()=>!i&&(i=!0,o&&clearTimeout(o),!0);e.timeout&&(o=setTimeout((()=>{s()&&n(new Error("timeout"))}),e.timeout));const a=e.retryLimit;let c=0;!function o(){return t().then((function(t){if(void 0!==t)s()&&r(t);else if(e.oncePoll)e.oncePoll.once("poll",o);else if(e.onceBlock)e.onceBlock.once("block",o);else if(!i){if(c++,c>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,c)));t<e.floor&&(t=e.floor),t>e.ceiling&&(t=e.ceiling),setTimeout(o,t)}return null}),(function(t){s()&&n(t)}))}()}))}var j=Object.freeze({__proto__:null,_fetchData:_,fetchJson:I,poll:L});exports.TypedDataEncoder=C,exports._fetchData=_,exports.decode=s,exports.encode=a,exports.fetchJson=I,exports.lib_esm=j,exports.poll=L,exports.version=i;
|
|
1
|
+
"use strict";var t=require("@ethersproject/address"),e=require("@ethersproject/bytes"),r=require("./index-2b6e2d0e.cjs"),n=require("@ethersproject/properties"),o=require("./id-81d6569b.cjs");const i="hash/5.7.0";function s(t){t=atob(t);const r=[];for(let e=0;e<t.length;e++)r.push(t.charCodeAt(e));return e.arrayify(r)}function a(t){t=e.arrayify(t);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return btoa(r)}var c=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};const u=new o.Logger(i),l=new Uint8Array(32);l.fill(0);const f=o.BigNumber.from(-1),h=o.BigNumber.from(0),d=o.BigNumber.from(1),y=o.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const p=e.hexZeroPad(d.toHexString(),32),m=e.hexZeroPad(h.toHexString(),32),g={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},v=["name","version","chainId","verifyingContract","salt"];function w(t){return function(e){return"string"!=typeof e&&u.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const E={name:w("name"),version:w("version"),chainId:function(t){try{return o.BigNumber.from(t).toString()}catch(t){}return u.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(e){try{return t.getAddress(e).toLowerCase()}catch(t){}return u.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",e)},salt:function(t){try{const r=e.arrayify(t);if(32!==r.length)throw new Error("bad length");return e.hexlify(r)}catch(t){}return u.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function b(n){{const t=n.match(/^(u?)int(\d*)$/);if(t){const r=""===t[1],i=parseInt(t[2]||"256");(i%8!=0||i>256||t[2]&&t[2]!==String(i))&&u.throwArgumentError("invalid numeric width","type",n);const s=y.mask(r?i-1:i),a=r?s.add(d).mul(f):h;return function(t){const r=o.BigNumber.from(t);return(r.lt(a)||r.gt(s))&&u.throwArgumentError(`value out-of-bounds for ${n}`,"value",t),e.hexZeroPad(r.toTwos(256).toHexString(),32)}}}{const t=n.match(/^bytes(\d+)$/);if(t){const r=parseInt(t[1]);return(0===r||r>32||t[1]!==String(r))&&u.throwArgumentError("invalid bytes width","type",n),function(t){return e.arrayify(t).length!==r&&u.throwArgumentError(`invalid length for ${n}`,"value",t),function(t){const r=e.arrayify(t),n=r.length%32;return n?e.hexConcat([r,l.slice(n)]):e.hexlify(r)}(t)}}}switch(n){case"address":return function(r){return e.hexZeroPad(t.getAddress(r),32)};case"bool":return function(t){return t?p:m};case"bytes":return function(t){return r.keccak256(t)};case"string":return function(t){return o.id(t)}}return null}function x(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class C{constructor(t){n.defineReadOnly(this,"types",Object.freeze(n.deepCopy(t))),n.defineReadOnly(this,"_encoderCache",{}),n.defineReadOnly(this,"_types",{});const e={},r={},o={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],o[t]={}}));for(const n in t){const o={};t[n].forEach((i=>{o[i.name]&&u.throwArgumentError(`duplicate variable name ${JSON.stringify(i.name)} in ${JSON.stringify(n)}`,"types",t),o[i.name]=!0;const s=i.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&u.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",t);b(s)||(r[s]||u.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",t),r[s].push(n),e[n][s]=!0)}))}const i=Object.keys(r).filter((t=>0===r[t].length));0===i.length?u.throwArgumentError("missing primary type","types",t):i.length>1&&u.throwArgumentError(`ambiguous primary types or unused types: ${i.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),n.defineReadOnly(this,"primaryType",i[0]),function n(i,s){s[i]&&u.throwArgumentError(`circular type reference to ${JSON.stringify(i)}`,"types",t),s[i]=!0,Object.keys(e[i]).forEach((t=>{r[t]&&(n(t,s),Object.keys(s).forEach((e=>{o[e][t]=!0})))})),delete s[i]}(this.primaryType,{});for(const e in o){const r=Object.keys(o[e]);r.sort(),this._types[e]=x(e,t[e])+r.map((e=>x(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=b(t);if(e)return e}const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],o=this.getEncoder(t),i=parseInt(n[3]);return n=>{i>=0&&n.length!==i&&u.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",n);let s=n.map(o);return this._types[t]&&(s=s.map(r.keccak256)),r.keccak256(e.hexConcat(s))}}const i=this.types[t];if(i){const n=o.id(this._types[t]);return t=>{const o=i.map((({name:e,type:n})=>{const o=this.getEncoder(n)(t[e]);return this._types[n]?r.keccak256(o):o}));return o.unshift(n),e.hexConcat(o)}}return u.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||u.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return r.keccak256(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(b(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],o=parseInt(n[3]);return o>=0&&e.length!==o&&u.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const o=this.types[t];return o?o.reduce(((t,{name:n,type:o})=>(t[n]=this._visit(o,e[n],r),t)),{}):u.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new C(t)}static getPrimaryType(t){return C.from(t).primaryType}static hashStruct(t,e,r){return C.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=g[r];n||u.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort(((t,e)=>v.indexOf(t.name)-v.indexOf(e.name))),C.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,r,n){return e.hexConcat(["0x1901",C.hashDomain(t),C.from(r).hash(n)])}static hash(t,e,n){return r.keccak256(C.encode(t,e,n))}static resolveNames(t,r,o,i){return c(this,void 0,void 0,(function*(){t=n.shallowCopy(t);const s={};t.verifyingContract&&!e.isHexString(t.verifyingContract,20)&&(s[t.verifyingContract]="0x");const a=C.from(r);a.visit(o,((t,r)=>("address"!==t||e.isHexString(r,20)||(s[r]="0x"),r)));for(const t in s)s[t]=yield i(t);return t.verifyingContract&&s[t.verifyingContract]&&(t.verifyingContract=s[t.verifyingContract]),o=a.visit(o,((t,e)=>"address"===t&&s[e]?s[e]:e)),{domain:t,value:o}}))}static getPayload(t,r,i){C.hashDomain(t);const s={},a=[];v.forEach((e=>{const r=t[e];null!=r&&(s[e]=E[e](r),a.push({name:e,type:g[e]}))}));const c=C.from(r),l=n.shallowCopy(r);return l.EIP712Domain?u.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",r):l.EIP712Domain=a,c.encode(i),{types:l,domain:s,primaryType:c.primaryType,message:c.visit(i,((t,r)=>{if(t.match(/^bytes(\d*)/))return e.hexlify(e.arrayify(r));if(t.match(/^u?int/))return o.BigNumber.from(r).toString();switch(t){case"address":return r.toLowerCase();case"bool":return!!r;case"string":return"string"!=typeof r&&u.throwArgumentError("invalid string","value",r),r}return u.throwArgumentError("unsupported type","type",t)}))}}}var S=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};function k(t,r){return S(this,void 0,void 0,(function*(){null==r&&(r={});const n={method:r.method||"GET",headers:r.headers||{},body:r.body||void 0};if(!0!==r.skipFetchSetup&&(n.mode="cors",n.cache="no-cache",n.credentials="same-origin",n.redirect="follow",n.referrer="client"),null!=r.fetchOptions){const t=r.fetchOptions;t.mode&&(n.mode=t.mode),t.cache&&(n.cache=t.cache),t.credentials&&(n.credentials=t.credentials),t.redirect&&(n.redirect=t.redirect),t.referrer&&(n.referrer=t.referrer)}const o=yield fetch(t,n),i=yield o.arrayBuffer(),s={};return o.headers.forEach?o.headers.forEach(((t,e)=>{s[e.toLowerCase()]=t})):o.headers.keys().forEach((t=>{s[t.toLowerCase()]=o.headers.get(t)})),{headers:s,statusCode:o.status,statusMessage:o.statusText,body:e.arrayify(new Uint8Array(i))}}))}var O=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};const R=new o.Logger("web/5.7.1");function A(t){return new Promise((e=>{setTimeout(e,t)}))}function T(t,r){if(null==t)return null;if("string"==typeof t)return t;if(e.isBytesLike(t)){if(r&&("text"===r.split("/")[0]||"application/json"===r.split(";")[0].trim()))try{return o.toUtf8String(t)}catch(t){}return e.hexlify(t)}return t}function _(t,e,r){const i="object"==typeof t&&null!=t.throttleLimit?t.throttleLimit:12;R.assertArgument(i>0&&i%1==0,"invalid connection throttle limit","connection.throttleLimit",i);const c="object"==typeof t?t.throttleCallback:null,u="object"==typeof t&&"number"==typeof t.throttleSlotInterval?t.throttleSlotInterval:100;R.assertArgument(u>0&&u%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",u);const l="object"==typeof t&&!!t.errorPassThrough,f={};let h=null;const d={method:"GET"};let y=!1,p=12e4;if("string"==typeof t)h=t;else if("object"==typeof t){if(null!=t&&null!=t.url||R.throwArgumentError("missing URL","connection.url",t),h=t.url,"number"==typeof t.timeout&&t.timeout>0&&(p=t.timeout),t.headers)for(const e in t.headers)f[e.toLowerCase()]={key:e,value:String(t.headers[e])},["if-none-match","if-modified-since"].indexOf(e.toLowerCase())>=0&&(y=!0);if(d.allowGzip=!!t.allowGzip,null!=t.user&&null!=t.password){"https:"!==h.substring(0,6)&&!0!==t.allowInsecureAuthentication&&R.throwError("basic authentication requires a secure https url",o.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:h,user:t.user,password:"[REDACTED]"});const e=t.user+":"+t.password;f.authorization={key:"Authorization",value:"Basic "+a(o.toUtf8Bytes(e))}}null!=t.skipFetchSetup&&(d.skipFetchSetup=!!t.skipFetchSetup),null!=t.fetchOptions&&(d.fetchOptions=n.shallowCopy(t.fetchOptions))}const m=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),g=h?h.match(m):null;if(g)try{const t={statusCode:200,statusMessage:"OK",headers:{"content-type":g[1]||"text/plain"},body:g[2]?s(g[3]):(v=g[3],o.toUtf8Bytes(v.replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))};let e=t.body;return r&&(e=r(t.body,t)),Promise.resolve(e)}catch(t){R.throwError("processing response error",o.Logger.errors.SERVER_ERROR,{body:T(g[1],g[2]),error:t,requestBody:null,requestMethod:"GET",url:h})}var v;e&&(d.method="POST",d.body=e,null==f["content-type"]&&(f["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==f["content-length"]&&(f["content-length"]={key:"Content-Length",value:String(e.length)}));const w={};Object.keys(f).forEach((t=>{const e=f[t];w[e.key]=e.value})),d.headers=w;const E=function(){let t=null;return{promise:new Promise((function(e,r){p&&(t=setTimeout((()=>{null!=t&&(t=null,r(R.makeError("timeout",o.Logger.errors.TIMEOUT,{requestBody:T(d.body,w["content-type"]),requestMethod:d.method,timeout:p,url:h})))}),p))})),cancel:function(){null!=t&&(clearTimeout(t),t=null)}}}(),b=function(){return O(this,void 0,void 0,(function*(){for(let t=0;t<i;t++){let e=null;try{if(e=yield k(h,d),t<i)if(301===e.statusCode||302===e.statusCode){const t=e.headers.location||"";if("GET"===d.method&&t.match(/^https:/)){h=e.headers.location;continue}}else if(429===e.statusCode){let r=!0;if(c&&(r=yield c(t,h)),r){let r=0;const n=e.headers["retry-after"];r="string"==typeof n&&n.match(/^[1-9][0-9]*$/)?1e3*parseInt(n):u*parseInt(String(Math.random()*Math.pow(2,t))),yield A(r);continue}}}catch(t){e=t.response,null==e&&(E.cancel(),R.throwError("missing response",o.Logger.errors.SERVER_ERROR,{requestBody:T(d.body,w["content-type"]),requestMethod:d.method,serverError:t,url:h}))}let n=e.body;if(y&&304===e.statusCode?n=null:!l&&(e.statusCode<200||e.statusCode>=300)&&(E.cancel(),R.throwError("bad response",o.Logger.errors.SERVER_ERROR,{status:e.statusCode,headers:e.headers,body:T(n,e.headers?e.headers["content-type"]:null),requestBody:T(d.body,w["content-type"]),requestMethod:d.method,url:h})),r)try{const t=yield r(n,e);return E.cancel(),t}catch(r){if(r.throttleRetry&&t<i){let e=!0;if(c&&(e=yield c(t,h)),e){const e=u*parseInt(String(Math.random()*Math.pow(2,t)));yield A(e);continue}}E.cancel(),R.throwError("processing response error",o.Logger.errors.SERVER_ERROR,{body:T(n,e.headers?e.headers["content-type"]:null),error:r,requestBody:T(d.body,w["content-type"]),requestMethod:d.method,url:h})}return E.cancel(),n}return R.throwError("failed response",o.Logger.errors.SERVER_ERROR,{requestBody:T(d.body,w["content-type"]),requestMethod:d.method,url:h})}))}();return Promise.race([E.promise,b])}function I(t,e,r){let i=null;if(null!=e){i=o.toUtf8Bytes(e);const r="string"==typeof t?{url:t}:n.shallowCopy(t);if(r.headers){0!==Object.keys(r.headers).filter((t=>"content-type"===t.toLowerCase())).length||(r.headers=n.shallowCopy(r.headers),r.headers["content-type"]="application/json")}else r.headers={"content-type":"application/json"};t=r}return _(t,i,((t,e)=>{let n=null;if(null!=t)try{n=JSON.parse(o.toUtf8String(t))}catch(e){R.throwError("invalid JSON",o.Logger.errors.SERVER_ERROR,{body:t,error:e})}return r&&(n=r(n,e)),n}))}function L(t,e){return e||(e={}),null==(e=n.shallowCopy(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise((function(r,n){let o=null,i=!1;const s=()=>!i&&(i=!0,o&&clearTimeout(o),!0);e.timeout&&(o=setTimeout((()=>{s()&&n(new Error("timeout"))}),e.timeout));const a=e.retryLimit;let c=0;!function o(){return t().then((function(t){if(void 0!==t)s()&&r(t);else if(e.oncePoll)e.oncePoll.once("poll",o);else if(e.onceBlock)e.onceBlock.once("block",o);else if(!i){if(c++,c>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,c)));t<e.floor&&(t=e.floor),t>e.ceiling&&(t=e.ceiling),setTimeout(o,t)}return null}),(function(t){s()&&n(t)}))}()}))}var j=Object.freeze({__proto__:null,_fetchData:_,fetchJson:I,poll:L});exports.TypedDataEncoder=C,exports._fetchData=_,exports.decode=s,exports.encode=a,exports.fetchJson=I,exports.lib_esm=j,exports.poll=L,exports.version=i;
|