@dodoex/wallet-web3 0.0.22-2 → 0.0.22-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__node-resolve_empty-0100ccbe.js +1 -0
- package/dist/__tslib-edb9da71.js +1 -0
- package/dist/blocto-8d7de7b5.js +7 -0
- package/dist/bn-e338479f.js +1 -0
- package/dist/browser-ponyfill-4f8ec4cc.js +1 -0
- package/dist/cjs/__node-resolve_empty-db84e05a.cjs +1 -0
- package/dist/cjs/__tslib-12427cac.cjs +1 -0
- package/dist/cjs/blocto-5784523c.cjs +7 -0
- package/dist/cjs/bn-595d299a.cjs +1 -0
- package/dist/cjs/browser-ponyfill-99cd2b2a.cjs +1 -0
- package/dist/cjs/ethers-8dd84195.cjs +1 -0
- package/dist/cjs/id-ae785b22.cjs +1 -0
- package/dist/cjs/{index-5d7b94fd.cjs → index-095f26b3.cjs} +1 -1
- package/dist/cjs/index-1eddf6b7.cjs +1 -0
- package/dist/cjs/index-1ee2a405.cjs +1 -0
- package/dist/cjs/index-2dac57a4.cjs +1 -0
- package/dist/cjs/{index-f2c04d55.cjs → index-3bc984a2.cjs} +1 -1
- package/dist/cjs/index-47036dc9.cjs +15 -0
- package/dist/cjs/index-4d18447a.cjs +1 -0
- package/dist/cjs/{index-4585c950.cjs → index-4ee3ab7f.cjs} +1 -1
- package/dist/cjs/index-773f2765.cjs +46 -0
- package/dist/cjs/index-99b925f5.cjs +10 -0
- package/dist/cjs/index-cf3bf3b5.cjs +3 -0
- package/dist/cjs/{index-3d1a3da9.cjs → index-df8e5839.cjs} +1 -1
- package/dist/cjs/index-eb09e54d.cjs +60 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.es-6f21f76e.cjs +9 -0
- package/dist/cjs/{interface-1b54eefa.cjs → interface-6285bef3.cjs} +1 -1
- package/dist/cjs/portis-ec351600.cjs +24 -0
- package/dist/cjs/{provider-403219c9.cjs → provider-6f06969f.cjs} +1 -1
- package/dist/cjs/rainbow-cb1bd1d4.cjs +1 -0
- package/dist/cjs/uAuth-21c58fc5.cjs +1 -0
- package/dist/cjs/walletConnect-4e88eea6.cjs +1 -0
- package/dist/cjs/walletLink-4cf61eb3.cjs +1 -0
- package/dist/ethers-d98a529c.js +1 -0
- package/dist/id-bb7887d8.js +1 -0
- package/dist/index-0ee5ef8d.js +60 -0
- package/dist/index-1dc7fa04.js +1 -0
- package/dist/index-32669120.js +15 -0
- package/dist/index-5a901c0e.js +2 -0
- package/dist/{index-235259d8.js → index-9201db0c.js} +1 -1
- package/dist/index-98f05edd.js +1 -0
- package/dist/{index-de37f6bb.js → index-a0101310.js} +1 -1
- package/dist/index-c2c32c9a.js +46 -0
- package/dist/index-d1e775cf.js +10 -0
- package/dist/{index-5f9e8321.js → index-e0d3617a.js} +1 -1
- package/dist/index-e17029da.js +1 -0
- package/dist/index-fbd509d6.js +1 -0
- package/dist/{index-650785ec.js → index-fe1624e3.js} +1 -1
- package/dist/index.es-e051edf2.js +9 -0
- package/dist/index.js +1 -1
- package/dist/{interface-f97a878a.js → interface-2066cc0e.js} +1 -1
- package/dist/portis-a96be943.js +24 -0
- package/dist/{provider-453e2483.js → provider-01f3e885.js} +1 -1
- package/dist/rainbow-5bfe748a.js +1 -0
- package/dist/uAuth-4cf1112e.js +1 -0
- package/dist/walletConnect-7c22cd4c.js +1 -0
- package/dist/walletLink-ad1c9d2e.js +1 -0
- package/package.json +1 -1
- package/dist/__tslib-dd22ed7d.js +0 -1
- package/dist/blocto-69a506f8.js +0 -1
- package/dist/bn-3e892825.js +0 -1
- package/dist/cjs/__tslib-8344f379.cjs +0 -1
- package/dist/cjs/blocto-bdab3cea.cjs +0 -1
- package/dist/cjs/bn-ce9dbccd.cjs +0 -1
- package/dist/cjs/ethers-767c2337.cjs +0 -1
- package/dist/cjs/id-6c4d97dd.cjs +0 -1
- package/dist/cjs/index-2428f0a6.cjs +0 -1
- package/dist/cjs/index-4abb9db3.cjs +0 -1
- package/dist/cjs/index-659dc842.cjs +0 -61
- package/dist/cjs/index-67e59d1a.cjs +0 -1
- package/dist/cjs/index-795ad993.cjs +0 -46
- package/dist/cjs/index-a5fa1e6e.cjs +0 -15
- package/dist/cjs/index-aa04e7a3.cjs +0 -1
- package/dist/cjs/index-cfe3e391.cjs +0 -10
- package/dist/cjs/index-d226aab9.cjs +0 -8
- package/dist/cjs/index-e875b498.cjs +0 -1
- package/dist/cjs/index.es-a3704620.cjs +0 -9
- package/dist/cjs/node-ponyfill-a7a0b431.cjs +0 -1
- package/dist/cjs/portis-ec0ce54d.cjs +0 -1
- package/dist/cjs/rainbow-caa66e39.cjs +0 -1
- package/dist/cjs/uAuth-a2d2617a.cjs +0 -1
- package/dist/cjs/walletConnect-c57b3b5d.cjs +0 -1
- package/dist/cjs/walletLink-f0f9e2a7.cjs +0 -3
- package/dist/ethers-51e19435.js +0 -1
- package/dist/id-830e09aa.js +0 -1
- package/dist/index-3158e93a.js +0 -46
- package/dist/index-46c2059e.js +0 -1
- package/dist/index-5091218e.js +0 -1
- package/dist/index-6bf494b0.js +0 -1
- package/dist/index-80483be2.js +0 -8
- package/dist/index-82b4fd64.js +0 -60
- package/dist/index-88837567.js +0 -1
- package/dist/index-c699a924.js +0 -1
- package/dist/index-cc453bb1.js +0 -10
- package/dist/index-f3052552.js +0 -15
- package/dist/index.es-877101c5.js +0 -9
- package/dist/node-ponyfill-55b945e1.js +0 -1
- package/dist/portis-7d46b7ed.js +0 -1
- package/dist/rainbow-61a52379.js +0 -1
- package/dist/uAuth-40d8acab.js +0 -1
- package/dist/walletConnect-d6a9aa67.js +0 -1
- package/dist/walletLink-106461e6.js +0 -3
- /package/dist/cjs/{index-47f3e61d.cjs → index-70269942.cjs} +0 -0
- /package/dist/{index-0103e089.js → index-6be6f872.js} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import r from"buffer";var e={exports:{}};
|
|
2
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */!function(e,o){var n=r,t=n.Buffer;function f(r,e){for(var o in r)e[o]=r[o]}function u(r,e,o){return t(r,e,o)}t.from&&t.alloc&&t.allocUnsafe&&t.allocUnsafeSlow?e.exports=n:(f(n,o),o.Buffer=u),u.prototype=Object.create(t.prototype),f(t,u),u.from=function(r,e,o){if("number"==typeof r)throw new TypeError("Argument must not be a number");return t(r,e,o)},u.alloc=function(r,e,o){if("number"!=typeof r)throw new TypeError("Argument must be a number");var n=t(r);return void 0!==e?"string"==typeof o?n.fill(e,o):n.fill(e):n.fill(0),n},u.allocUnsafe=function(r){if("number"!=typeof r)throw new TypeError("Argument must be a number");return t(r)},u.allocUnsafeSlow=function(r){if("number"!=typeof r)throw new TypeError("Argument must be a number");return n.SlowBuffer(r)}}(e,e.exports);export{e as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hexlify as r,arrayify as t,isBytesLike as o}from"@ethersproject/bytes";import{L as e}from"./id-
|
|
1
|
+
import{hexlify as r,arrayify as t,isBytesLike as o}from"@ethersproject/bytes";import{L as e}from"./id-bb7887d8.js";const n=new e("rlp/5.7.0");function s(r){const t=[];for(;r;)t.unshift(255&r),r>>=8;return t}function c(r,t,o){let e=0;for(let n=0;n<o;n++)e=256*e+r[t+n];return e}function h(r){if(Array.isArray(r)){let t=[];if(r.forEach((function(r){t=t.concat(h(r))})),t.length<=55)return t.unshift(192+t.length),t;const o=s(t.length);return o.unshift(247+o.length),o.concat(t)}o(r)||n.throwArgumentError("RLP object must be BytesLike","object",r);const e=Array.prototype.slice.call(t(r));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const c=s(e.length);return c.unshift(183+c.length),c.concat(e)}function u(t){return r(h(t))}function a(r,t,o,s){const c=[];for(;o<t+1+s;){const h=l(r,o);c.push(h.result),(o+=h.consumed)>t+1+s&&n.throwError("child data too short",e.errors.BUFFER_OVERRUN,{})}return{consumed:1+s,result:c}}function l(t,o){if(0===t.length&&n.throwError("data too short",e.errors.BUFFER_OVERRUN,{}),t[o]>=248){const r=t[o]-247;o+1+r>t.length&&n.throwError("data short segment too short",e.errors.BUFFER_OVERRUN,{});const s=c(t,o+1,r);return o+1+r+s>t.length&&n.throwError("data long segment too short",e.errors.BUFFER_OVERRUN,{}),a(t,o,o+1+r,r+s)}if(t[o]>=192){const r=t[o]-192;return o+1+r>t.length&&n.throwError("data array too short",e.errors.BUFFER_OVERRUN,{}),a(t,o,o+1,r)}if(t[o]>=184){const s=t[o]-183;o+1+s>t.length&&n.throwError("data array too short",e.errors.BUFFER_OVERRUN,{});const h=c(t,o+1,s);o+1+s+h>t.length&&n.throwError("data array too short",e.errors.BUFFER_OVERRUN,{});return{consumed:1+s+h,result:r(t.slice(o+1+s,o+1+s+h))}}if(t[o]>=128){const s=t[o]-128;o+1+s>t.length&&n.throwError("data too short",e.errors.BUFFER_OVERRUN,{});return{consumed:1+s,result:r(t.slice(o+1,o+1+s))}}return{consumed:1,result:r(t[o])}}function i(r){const o=t(r),e=l(o,0);return e.consumed!==o.length&&n.throwArgumentError("invalid rlp data","data",r),e.result}var f=Object.freeze({__proto__:null,encode:u,decode:i});export{i as d,u as e,f as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,g as t,w as n,c as r,S as o,x as i,y as a,u as s}from"./index-d1e775cf.js";import{JsonRpcProvider as c}from"@ethersproject/providers";import u,{getAddress as p}from"@ethersproject/address";import{T as l,S as d}from"./index-a0101310.js";import f,{arrayify as h}from"@ethersproject/bytes";import{r as g}from"./index-e17029da.js";import{f as y,p as m,n as b,d as v,b as w,i as P,c as x,m as O,h as j,g as _,r as S,s as E,j as k,S as T,k as U,o as L,q as A,t as C,x as N,y as I,z as D,A as M,B as R,C as F}from"./ethers-d98a529c.js";import{d as z,t as B,c as W,a as G,e as V,f as J,U as H,i as K,l as Z}from"./id-bb7887d8.js";import q,{deepCopy as $}from"@ethersproject/properties";import{l as Y}from"./index-9201db0c.js";import Q from"@ethersproject/transactions";import{l as X,f as ee}from"./index-fe1624e3.js";import{Contract as te}from"@ethersproject/contracts";import"events";import"zustand";import"@ethersproject/constants";import"./interface-2066cc0e.js";import"./__node-resolve_empty-0100ccbe.js";var ne,re=Object.freeze({__proto__:null,_toEscapedUtf8String:z,toUtf8Bytes:B,toUtf8CodePoints:W,toUtf8String:G,Utf8ErrorFuncs:V,get Utf8ErrorReason(){return J},get UnicodeNormalizationForm(){return H},formatBytes32String:y,parseBytes32String:m,nameprep:b}),oe=Object.freeze({__proto__:null,id:K,dnsEncode:v,namehash:w,isValidName:P,ensNormalize:x,messagePrefix:O,hashMessage:j,_TypedDataEncoder:l}),ie=Object.freeze({__proto__:null,computeHmac:_,ripemd160:S,sha256:E,sha512:k,get SupportedAlgorithm(){return T}}),ae=Object.freeze({__proto__:null,randomBytes:U,shuffled:L});class se extends d{constructor(e,t,n,r){super(),this._address=n,this._index=null!=r?r:0,this.provider=e,this.upWallet=t}_legacySignMessage(e){throw new Error("Method not implemented.")}sendUncheckedTransaction(e){throw new Error("Method not implemented.")}unlock(e){throw new Error("Method not implemented.")}getAddress(){return e(this,void 0,void 0,(function*(){return Promise.resolve(p(this._address))}))}signMessage(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t}'`);return yield this.upWallet.signMessage(t,{isEIP191Prefix:!0,onAuthChain:!0})}))}_signTypedData(t,n,r){return e(this,void 0,void 0,(function*(){throw new Error("Method not implemented.")}))}signTransaction(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t.from}'`);return this.upWallet.sendTransaction({from:t.from,to:t.to,value:t.value,data:t.data})}))}sendTransaction(t){return e(this,void 0,void 0,(function*(){if(!this.upWallet)throw new Error(`address unknown '${t.from}'`);return{hash:yield this.upWallet.sendTransaction({from:t.from,to:t.to,value:t.value,data:t.data}),from:t.from}}))}connect(e){return new se(null!=e?e:this.provider,this.upWallet,this._address,this._index)}connectUnchecked(){return new se(this.provider,this.upWallet,this._address,this._index)}}!function(e){e.REGISTER="register"}(ne||(ne={}));var ce,ue=function(e,t,n,r,o){this.from=e,this.msg=t,this.type=n,this.isEIP191Prefix=r,this.onAuthChain=o},pe=function(e,t){this.type=e,this.data=t},le=function(e,t,n){this.type=e,this.payload=t,this.appSetting=n};function de(){return de=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},de.apply(this,arguments)}!function(e){e.LIGHT="light",e.DARK="dark"}(ce||(ce={}));var fe=function(e){return h(function(e){var t=de({},e.types);return delete t.EIP712Domain,l.hash(e.domain,t,e.message)}(e))},he={},ge=t(A),ye=t(C),me=t(oe),be=t(N),ve=t(I),we=t(n),Pe=t(Z),xe=t(ie),Oe=t(D),je=t(ae),_e=t(Y),Se=t(M),Ee=t(re),ke=t(R),Te=t(F),Ue=t(X);function Le(){Le=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,o){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype),s=new _(o||[]);return r(a,"_invoke",{value:P(e,n,s)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function d(){}function f(){}function h(){}var g={};c(g,i,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(S([])));m&&m!==t&&n.call(m,i)&&(g=m);var b=h.prototype=d.prototype=Object.create(g);function v(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function o(r,i,a,s){var c=p(e[r],e,i);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){o("next",e,a,s)}),(function(e){o("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return o("throw",e,a,s)}))}s(c.arg)}var i;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){o(e,n,t,r)}))}return i=i?i.then(r,r):r()}})}function P(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return E()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=x(a,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=p(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function x(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var o=p(r,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,l;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function j(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return f.prototype=h,r(b,"constructor",{value:h,configurable:!0}),r(h,"constructor",{value:f,configurable:!0}),f.displayName=c(h,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,c(e,s,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},v(w.prototype),c(w.prototype,a,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new w(u(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(b),c(b,s,"Generator"),c(b,i,(function(){return this})),c(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),j(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;j(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}function Ae(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function Ce(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Ae(i,r,o,a,s,"next",e)}function s(e){Ae(i,r,o,a,s,"throw",e)}a(void 0)}))}}function Ne(){return Ne=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ne.apply(this,arguments)}!function(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=r&&r.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&t(r,e,o);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.formatBytes32String=e.Utf8ErrorFuncs=e.toUtf8String=e.toUtf8CodePoints=e.toUtf8Bytes=e._toEscapedUtf8String=e.nameprep=e.hexDataSlice=e.hexDataLength=e.hexZeroPad=e.hexValue=e.hexStripZeros=e.hexConcat=e.isHexString=e.hexlify=e.base64=e.base58=e.TransactionDescription=e.LogDescription=e.Interface=e.SigningKey=e.HDNode=e.defaultPath=e.isBytesLike=e.isBytes=e.zeroPad=e.stripZeros=e.concat=e.arrayify=e.shallowCopy=e.resolveProperties=e.getStatic=e.defineReadOnly=e.deepCopy=e.checkProperties=e.poll=e.fetchJson=e._fetchData=e.RLP=e.Logger=e.checkResultErrors=e.FormatTypes=e.ParamType=e.FunctionFragment=e.EventFragment=e.ErrorFragment=e.ConstructorFragment=e.Fragment=e.defaultAbiCoder=e.AbiCoder=void 0,e.Indexed=e.Utf8ErrorReason=e.UnicodeNormalizationForm=e.SupportedAlgorithm=e.mnemonicToSeed=e.isValidMnemonic=e.entropyToMnemonic=e.mnemonicToEntropy=e.getAccountPath=e.verifyTypedData=e.verifyMessage=e.recoverPublicKey=e.computePublicKey=e.recoverAddress=e.computeAddress=e.getJsonWalletAddress=e.TransactionTypes=e.serializeTransaction=e.parseTransaction=e.accessListify=e.joinSignature=e.splitSignature=e.soliditySha256=e.solidityKeccak256=e.solidityPack=e.shuffled=e.randomBytes=e.sha512=e.sha256=e.ripemd160=e.keccak256=e.computeHmac=e.commify=e.parseUnits=e.formatUnits=e.parseEther=e.formatEther=e.isAddress=e.getCreate2Address=e.getContractAddress=e.getIcapAddress=e.getAddress=e._TypedDataEncoder=e.id=e.isValidName=e.namehash=e.hashMessage=e.dnsEncode=e.parseBytes32String=void 0;var i=g;Object.defineProperty(e,"AbiCoder",{enumerable:!0,get:function(){return i.AbiCoder}}),Object.defineProperty(e,"checkResultErrors",{enumerable:!0,get:function(){return i.checkResultErrors}}),Object.defineProperty(e,"ConstructorFragment",{enumerable:!0,get:function(){return i.ConstructorFragment}}),Object.defineProperty(e,"defaultAbiCoder",{enumerable:!0,get:function(){return i.defaultAbiCoder}}),Object.defineProperty(e,"ErrorFragment",{enumerable:!0,get:function(){return i.ErrorFragment}}),Object.defineProperty(e,"EventFragment",{enumerable:!0,get:function(){return i.EventFragment}}),Object.defineProperty(e,"FormatTypes",{enumerable:!0,get:function(){return i.FormatTypes}}),Object.defineProperty(e,"Fragment",{enumerable:!0,get:function(){return i.Fragment}}),Object.defineProperty(e,"FunctionFragment",{enumerable:!0,get:function(){return i.FunctionFragment}}),Object.defineProperty(e,"Indexed",{enumerable:!0,get:function(){return i.Indexed}}),Object.defineProperty(e,"Interface",{enumerable:!0,get:function(){return i.Interface}}),Object.defineProperty(e,"LogDescription",{enumerable:!0,get:function(){return i.LogDescription}}),Object.defineProperty(e,"ParamType",{enumerable:!0,get:function(){return i.ParamType}}),Object.defineProperty(e,"TransactionDescription",{enumerable:!0,get:function(){return i.TransactionDescription}});var a=u;Object.defineProperty(e,"getAddress",{enumerable:!0,get:function(){return a.getAddress}}),Object.defineProperty(e,"getCreate2Address",{enumerable:!0,get:function(){return a.getCreate2Address}}),Object.defineProperty(e,"getContractAddress",{enumerable:!0,get:function(){return a.getContractAddress}}),Object.defineProperty(e,"getIcapAddress",{enumerable:!0,get:function(){return a.getIcapAddress}}),Object.defineProperty(e,"isAddress",{enumerable:!0,get:function(){return a.isAddress}});var s=o(ge);e.base64=s;var c=ye;Object.defineProperty(e,"base58",{enumerable:!0,get:function(){return c.Base58}});var p=f;Object.defineProperty(e,"arrayify",{enumerable:!0,get:function(){return p.arrayify}}),Object.defineProperty(e,"concat",{enumerable:!0,get:function(){return p.concat}}),Object.defineProperty(e,"hexConcat",{enumerable:!0,get:function(){return p.hexConcat}}),Object.defineProperty(e,"hexDataSlice",{enumerable:!0,get:function(){return p.hexDataSlice}}),Object.defineProperty(e,"hexDataLength",{enumerable:!0,get:function(){return p.hexDataLength}}),Object.defineProperty(e,"hexlify",{enumerable:!0,get:function(){return p.hexlify}}),Object.defineProperty(e,"hexStripZeros",{enumerable:!0,get:function(){return p.hexStripZeros}}),Object.defineProperty(e,"hexValue",{enumerable:!0,get:function(){return p.hexValue}}),Object.defineProperty(e,"hexZeroPad",{enumerable:!0,get:function(){return p.hexZeroPad}}),Object.defineProperty(e,"isBytes",{enumerable:!0,get:function(){return p.isBytes}}),Object.defineProperty(e,"isBytesLike",{enumerable:!0,get:function(){return p.isBytesLike}}),Object.defineProperty(e,"isHexString",{enumerable:!0,get:function(){return p.isHexString}}),Object.defineProperty(e,"joinSignature",{enumerable:!0,get:function(){return p.joinSignature}}),Object.defineProperty(e,"zeroPad",{enumerable:!0,get:function(){return p.zeroPad}}),Object.defineProperty(e,"splitSignature",{enumerable:!0,get:function(){return p.splitSignature}}),Object.defineProperty(e,"stripZeros",{enumerable:!0,get:function(){return p.stripZeros}});var l=me;Object.defineProperty(e,"_TypedDataEncoder",{enumerable:!0,get:function(){return l._TypedDataEncoder}}),Object.defineProperty(e,"dnsEncode",{enumerable:!0,get:function(){return l.dnsEncode}}),Object.defineProperty(e,"hashMessage",{enumerable:!0,get:function(){return l.hashMessage}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return l.id}}),Object.defineProperty(e,"isValidName",{enumerable:!0,get:function(){return l.isValidName}}),Object.defineProperty(e,"namehash",{enumerable:!0,get:function(){return l.namehash}});var d=be;Object.defineProperty(e,"defaultPath",{enumerable:!0,get:function(){return d.defaultPath}}),Object.defineProperty(e,"entropyToMnemonic",{enumerable:!0,get:function(){return d.entropyToMnemonic}}),Object.defineProperty(e,"getAccountPath",{enumerable:!0,get:function(){return d.getAccountPath}}),Object.defineProperty(e,"HDNode",{enumerable:!0,get:function(){return d.HDNode}}),Object.defineProperty(e,"isValidMnemonic",{enumerable:!0,get:function(){return d.isValidMnemonic}}),Object.defineProperty(e,"mnemonicToEntropy",{enumerable:!0,get:function(){return d.mnemonicToEntropy}}),Object.defineProperty(e,"mnemonicToSeed",{enumerable:!0,get:function(){return d.mnemonicToSeed}});var h=ve;Object.defineProperty(e,"getJsonWalletAddress",{enumerable:!0,get:function(){return h.getJsonWalletAddress}});var y=we;Object.defineProperty(e,"keccak256",{enumerable:!0,get:function(){return y.keccak256}});var m=Pe;Object.defineProperty(e,"Logger",{enumerable:!0,get:function(){return m.Logger}});var b=xe;Object.defineProperty(e,"computeHmac",{enumerable:!0,get:function(){return b.computeHmac}}),Object.defineProperty(e,"ripemd160",{enumerable:!0,get:function(){return b.ripemd160}}),Object.defineProperty(e,"sha256",{enumerable:!0,get:function(){return b.sha256}}),Object.defineProperty(e,"sha512",{enumerable:!0,get:function(){return b.sha512}});var v=Oe;Object.defineProperty(e,"solidityKeccak256",{enumerable:!0,get:function(){return v.keccak256}}),Object.defineProperty(e,"solidityPack",{enumerable:!0,get:function(){return v.pack}}),Object.defineProperty(e,"soliditySha256",{enumerable:!0,get:function(){return v.sha256}});var w=je;Object.defineProperty(e,"randomBytes",{enumerable:!0,get:function(){return w.randomBytes}}),Object.defineProperty(e,"shuffled",{enumerable:!0,get:function(){return w.shuffled}});var P=q;Object.defineProperty(e,"checkProperties",{enumerable:!0,get:function(){return P.checkProperties}}),Object.defineProperty(e,"deepCopy",{enumerable:!0,get:function(){return P.deepCopy}}),Object.defineProperty(e,"defineReadOnly",{enumerable:!0,get:function(){return P.defineReadOnly}}),Object.defineProperty(e,"getStatic",{enumerable:!0,get:function(){return P.getStatic}}),Object.defineProperty(e,"resolveProperties",{enumerable:!0,get:function(){return P.resolveProperties}}),Object.defineProperty(e,"shallowCopy",{enumerable:!0,get:function(){return P.shallowCopy}});var x=o(_e);e.RLP=x;var O=Se;Object.defineProperty(e,"computePublicKey",{enumerable:!0,get:function(){return O.computePublicKey}}),Object.defineProperty(e,"recoverPublicKey",{enumerable:!0,get:function(){return O.recoverPublicKey}}),Object.defineProperty(e,"SigningKey",{enumerable:!0,get:function(){return O.SigningKey}});var j=Ee;Object.defineProperty(e,"formatBytes32String",{enumerable:!0,get:function(){return j.formatBytes32String}}),Object.defineProperty(e,"nameprep",{enumerable:!0,get:function(){return j.nameprep}}),Object.defineProperty(e,"parseBytes32String",{enumerable:!0,get:function(){return j.parseBytes32String}}),Object.defineProperty(e,"_toEscapedUtf8String",{enumerable:!0,get:function(){return j._toEscapedUtf8String}}),Object.defineProperty(e,"toUtf8Bytes",{enumerable:!0,get:function(){return j.toUtf8Bytes}}),Object.defineProperty(e,"toUtf8CodePoints",{enumerable:!0,get:function(){return j.toUtf8CodePoints}}),Object.defineProperty(e,"toUtf8String",{enumerable:!0,get:function(){return j.toUtf8String}}),Object.defineProperty(e,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return j.Utf8ErrorFuncs}});var _=Q;Object.defineProperty(e,"accessListify",{enumerable:!0,get:function(){return _.accessListify}}),Object.defineProperty(e,"computeAddress",{enumerable:!0,get:function(){return _.computeAddress}}),Object.defineProperty(e,"parseTransaction",{enumerable:!0,get:function(){return _.parse}}),Object.defineProperty(e,"recoverAddress",{enumerable:!0,get:function(){return _.recoverAddress}}),Object.defineProperty(e,"serializeTransaction",{enumerable:!0,get:function(){return _.serialize}}),Object.defineProperty(e,"TransactionTypes",{enumerable:!0,get:function(){return _.TransactionTypes}});var S=ke;Object.defineProperty(e,"commify",{enumerable:!0,get:function(){return S.commify}}),Object.defineProperty(e,"formatEther",{enumerable:!0,get:function(){return S.formatEther}}),Object.defineProperty(e,"parseEther",{enumerable:!0,get:function(){return S.parseEther}}),Object.defineProperty(e,"formatUnits",{enumerable:!0,get:function(){return S.formatUnits}}),Object.defineProperty(e,"parseUnits",{enumerable:!0,get:function(){return S.parseUnits}});var E=Te;Object.defineProperty(e,"verifyMessage",{enumerable:!0,get:function(){return E.verifyMessage}}),Object.defineProperty(e,"verifyTypedData",{enumerable:!0,get:function(){return E.verifyTypedData}});var k=Ue;Object.defineProperty(e,"_fetchData",{enumerable:!0,get:function(){return k._fetchData}}),Object.defineProperty(e,"fetchJson",{enumerable:!0,get:function(){return k.fetchJson}}),Object.defineProperty(e,"poll",{enumerable:!0,get:function(){return k.poll}});var T=xe;Object.defineProperty(e,"SupportedAlgorithm",{enumerable:!0,get:function(){return T.SupportedAlgorithm}});var U=Ee;Object.defineProperty(e,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return U.UnicodeNormalizationForm}}),Object.defineProperty(e,"Utf8ErrorReason",{enumerable:!0,get:function(){return U.Utf8ErrorReason}})}(he);var Ie="wallet.unipass.id",De={upDomain:Ie,upConnectUrl:"https://"+Ie+"/connect",upLogoutUrl:"https://"+Ie+"/logout",upSignMessageUrl:"https://"+Ie+"/sign-message",upTransactionUrl:"https://"+Ie+"/send-transaction",upLoadingUrl:"https://"+Ie+"/connect/loading"},Me=function(){return De},Re={protocol:"https",domain:"testnet.wallet.unipass.id"},Fe={protocol:"https",domain:"wallet.unipass.id"},ze={mainnet:{eth:"https://node.wallet.unipass.id/eth-mainnet",polygon:"https://node.wallet.unipass.id/polygon-mainnet",bsc:"https://node.wallet.unipass.id/bsc-mainnet",rangers:"https://node.wallet.unipass.id/rangers-mainnet",scroll:"https://node.wallet.unipass.id/scroll-mainnet",arbitrum:"https://node.wallet.unipass.id/arbitrum-mainnet",avalanche:"https://node.wallet.unipass.id/avalanche-mainnet",kcc:"https://node.wallet.unipass.id/kcc-mainnet",platon:"https://node.wallet.unipass.id/platon-mainnet",okc:"https://node.wallet.unipass.id/okc-mainnet"},testnet:{eth:"https://node.wallet.unipass.id/eth-goerli",polygon:"https://node.wallet.unipass.id/polygon-mumbai",bsc:"https://node.wallet.unipass.id/bsc-testnet",rangers:"https://node.wallet.unipass.id/rangers-robin",scroll:"https://node.wallet.unipass.id/scroll-testnet",arbitrum:"https://node.wallet.unipass.id/arbitrum-testnet",avalanche:"https://node.wallet.unipass.id/avalanche-testnet",kcc:"https://node.wallet.unipass.id/kcc-testnet",platon:"https://node.wallet.unipass.id/platon-testnet",okc:"https://node.wallet.unipass.id/okc-testnet"}},Be=function(e){var t;t="localStorage"===e?window.localStorage||localStorage:window.sessionStorage||sessionStorage;return{get:function(e){return t.getItem(e)||""},set:function(e,n){return t.setItem(e,n||"")},remove:function(e){return t.removeItem(e)}}},We=function(){var e=Ce(Le().mark((function e(t,n){var r,o;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(t.storageType).get(rt),e.t0=r&&JSON.parse(r),e.t0){e.next=6;break}return e.next=5,Ve(t,n);case 5:e.t0=e.sent;case 6:return o=e.t0,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),Ge=function(){var e=Ce(Le().mark((function e(t){var n;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=4;break}return n=new le("UP_LOGOUT"),e.next=4,ot(n);case 4:Be("localStorage").remove(rt),Be("sessionStorage").remove(rt);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ve=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=n?JSON.stringify(n):"",o=new le("UP_LOGIN",r,t.appSettings),e.next=5,ot(o,null==n?void 0:n.connectType,null==n?void 0:n.forceLogin,null==n?void 0:n.eventListener);case 5:return(i=e.sent)&&i.address&&Be(t.storageType).set(rt,JSON.stringify(i)),e.abrupt("return",i);case 10:throw e.prev=10,e.t0=e.catch(0),new Error("Account Not Available");case 13:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(t,n){return e.apply(this,arguments)}}(),Je="UP_WALLET_POP",He=null,Ke=null;function Ze(e,t,n){var r="innerWidth=462,width=462,innerHeight=810,height=810,top="+.5*(n.screen.availHeight-30-810)+",left="+.8*(n.screen.availWidth-10-462)+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,";return n.open(e,t,r)}function qe(e,t,n){return $e.apply(this,arguments)}function $e(){return($e=Ce(Le().mark((function e(t,n,r){var o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(null==He||null!=(o=He)&&o.closed)){e.next=8;break}if(null!=(He=Ze(t,Je,window))){e.next=6;break}return e.next=5,Ye(t,n,r);case 5:return e.abrupt("return",e.sent);case 6:e.next=9;break;case 8:Ke!==t?(He.location.replace(t),He.focus()):He.focus();case 9:return i=setInterval((function(){if(He&&He.closed){var e={data:new le("UP_RESPONSE",JSON.stringify(new pe("DECLINE","user reject connection")))};n(e,{close:function(){},send:function(){}}),clearInterval(i)}}),1e3),a=function(){He&&!He.closed&&He.close(),He=null},e.abrupt("return",{popup:He,unmount:a});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ye(e,t,n){return Qe.apply(this,arguments)}function Qe(){return(Qe=Ce(Le().mark((function e(t,n,r){var o,i;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=document.createElement("div"),'\n <div\n class="up_notification"\n style="\n position: fixed;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n top: 26px;\n right: 26px;\n width: 340px;\n height: 96px;\n z-index: 100001;\n background-color: #362866;\n box-sizing: border-box;\n border: 2px solid #ffffff;\n border-radius: 8px;\n padding: 16px 20px;\n "\n>\n <div class="up_notification_left" style="color: white">\n <div\n class="up_notification_title"\n style="\n font-weight: 500;\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 8px;\n "\n >\n Request Pop-up\n </div>\n <div\n class="up_notification_tip"\n style="\n font-weight: 450;\n font-size: 12px;\n line-height: 20px;\n color: rgba(255, 255, 255, 0.8);\n "\n >\n Click Approve to complete creating or using wallet\n </div>\n </div>\n <div\n class="up_notification_right"\n style="\n width: 90px;\n height: 35px;\n font-size: 12px;\n text-align: center;\n background: linear-gradient(270deg, #997afb 0%, #7a55f8 63.6%);\n border-radius: 6px;\n line-height: 35px;\n color: white;\n margin-left: 20px;\n cursor: pointer;\n "\n >\n Approve\n </div>\n</div>\n ',o.innerHTML='\n <div\n class="up_notification"\n style="\n position: fixed;\n display: flex;\n flex-flow: row nowrap;\n justify-content: space-between;\n align-items: center;\n top: 26px;\n right: 26px;\n width: 340px;\n height: 96px;\n z-index: 100001;\n background-color: #362866;\n box-sizing: border-box;\n border: 2px solid #ffffff;\n border-radius: 8px;\n padding: 16px 20px;\n "\n>\n <div class="up_notification_left" style="color: white">\n <div\n class="up_notification_title"\n style="\n font-weight: 500;\n font-size: 14px;\n line-height: 20px;\n margin-bottom: 8px;\n "\n >\n Request Pop-up\n </div>\n <div\n class="up_notification_tip"\n style="\n font-weight: 450;\n font-size: 12px;\n line-height: 20px;\n color: rgba(255, 255, 255, 0.8);\n "\n >\n Click Approve to complete creating or using wallet\n </div>\n </div>\n <div\n class="up_notification_right"\n style="\n width: 90px;\n height: 35px;\n font-size: 12px;\n text-align: center;\n background: linear-gradient(270deg, #997afb 0%, #7a55f8 63.6%);\n border-radius: 6px;\n line-height: 35px;\n color: white;\n margin-left: 20px;\n cursor: pointer;\n "\n >\n Approve\n </div>\n</div>\n ',document.body.appendChild(o),i=document.querySelector(".up_notification_right"),e.abrupt("return",new Promise((function(e){null==i||i.addEventListener("click",(function(){document.body.removeChild(o),e(qe(t,n,r))}),!1)})));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Xe=function(){};function et(e,t,n){if("UP_LOGIN"===e)return"google"===t?Me().upConnectUrl+"?connectType=google&forceLogin="+(n?"1":"0"):"email"===t?Me().upConnectUrl+"?connectType=email&forceLogin="+(n?"1":"0"):Me().upConnectUrl+"?forceLogin="+(n?"1":"0");if("UP_LOGOUT"===e)return Me().upLogoutUrl;if("UP_SIGN_MESSAGE"===e)return Me().upSignMessageUrl;if("UP_TRANSACTION"===e)return Me().upTransactionUrl;if("UP_READY"===e)return Me().upLoadingUrl;throw new Error("unsupport type "+e)}function tt(e,t,n,r){return nt.apply(this,arguments)}function nt(){return nt=Ce(Le().mark((function e(t,n,r,o){var i,a,s,c,u,p,l,d,f,h;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h=function(e){try{null==p||p.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Popup Send Error",e,t)}},f=function(){try{window.removeEventListener("message",d),l(),i()}catch(e){console.error("Popup Close Error",e)}},d=function(e){try{if("object"!=typeof e.data)return;var t=e.data;if(!t||!t.type)return;"UP_CLOSE"===e.data.type&&f(),"UP_READY"===t.type&&s(e,{send:h,close:f}),"UP_RESPONSE"===t.type&&c(e,{send:h,close:f}),"UP_EVENT"===t.type&&a(e,{send:h,close:f})}catch(e){console.error("Popup Callback Error",e),f()}},null!=t){e.next=5;break}return e.abrupt("return",{send:Xe,close:Xe});case 5:return i=(null==o?void 0:o.onClose)||Xe,a=(null==o?void 0:o.onMessage)||Xe,s=(null==o?void 0:o.onReady)||Xe,c=(null==o?void 0:o.onResponse)||Xe,window.addEventListener("message",d),e.next=12,qe(et(t.type,n,r),c,t.appSetting);case 12:return u=e.sent,p=u.popup,l=u.unmount,e.abrupt("return",{send:h,close:f});case 16:case"end":return e.stop()}}),e)}))),nt.apply(this,arguments)}var rt="UP-A";function ot(e,t,n,r){return new Promise(function(){var o=Ce(Le().mark((function o(i,a){return Le().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,tt(e,t,n,{onReady:function(t,n){return Ce(Le().mark((function t(){var r;return Le().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n.send,t.prev=1,r(e),t.next=8;break;case 5:throw t.prev=5,t.t0=t.catch(1),t.t0;case 8:case"end":return t.stop()}}),t,null,[[1,5]])})))()},onResponse:function(t,n){return Ce(Le().mark((function r(){var o,s,c;return Le().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(o=n.close,r.prev=1,"object"==typeof t.data){r.next=4;break}return r.abrupt("return");case 4:s=t.data,c=JSON.parse(s.payload),r.t0=c.type,r.next="APPROVE"===r.t0?9:"DECLINE"===r.t0?12:27;break;case 9:return i(c.data),o(),r.abrupt("break",30);case 12:if("expired"!==c.data){r.next=24;break}if("UP_LOGIN"!==e.type){r.next=15;break}return r.abrupt("return");case 15:if("UP_LOGOUT"!==e.type){r.next=19;break}return i(c.data),o(),r.abrupt("return");case 19:if("UP_TRANSACTION"!==e.type&&"UP_SIGN_MESSAGE"!==e.type){r.next=24;break}return Ge(!1),a("can not authorize without login"),o(),r.abrupt("break",30);case 24:return a("Declined: "+(c.data||"No reason supplied")),o(),r.abrupt("break",30);case 27:return a("Declined: No reason supplied"),o(),r.abrupt("break",30);case 30:r.next=35;break;case 32:throw r.prev=32,r.t1=r.catch(1),r.t1;case 35:case"end":return r.stop()}}),r,null,[[1,32]])})))()},onMessage:function(e,t){return Ce(Le().mark((function t(){var n,o;return Le().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:if(t.prev=2,"object"==typeof e.data){t.next=5;break}return t.abrupt("return");case 5:n=e.data,o=JSON.parse(n.payload),r(o),t.next=13;break;case 10:throw t.prev=10,t.t0=t.catch(2),t.t0;case 13:case"end":return t.stop()}}),t,null,[[2,10]])})))()},onClose:function(){return Ce(Le().mark((function e(){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a("Declined: Externally Halted");case 1:case"end":return e.stop()}}),e)})))()}});case 2:case"end":return o.stop()}}),o)})));return function(e,t){return o.apply(this,arguments)}}())}var it=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(n.storageType).get(rt),(o=r&&JSON.parse(r))&&t.from&&o.address.toLowerCase()===t.from.toLowerCase()){e.next=4;break}throw new Error("can not authorize without login");case 4:return i=new le("UP_SIGN_MESSAGE",JSON.stringify(t),null==n?void 0:n.appSettings),e.prev=5,e.next=8,ot(i);case 8:return a=e.sent,e.abrupt("return",a);case 12:throw e.prev=12,e.t0=e.catch(5),new Error(e.t0);case 15:case"end":return e.stop()}}),e,null,[[5,12]])})));return function(t,n){return e.apply(this,arguments)}}(),at=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Be(n.storageType).get(rt),(o=r&&JSON.parse(r))&&t.from&&o.address.toLowerCase()===t.from.toLowerCase()){e.next=4;break}throw new Error("can not authorize without login");case 4:return i=new le("UP_TRANSACTION",JSON.stringify(t),n.appSettings),e.prev=5,e.next=8,ot(i);case 8:return a=e.sent,e.abrupt("return",a);case 12:throw e.prev=12,e.t0=e.catch(5),new Error(e.t0);case 15:case"end":return e.stop()}}),e,null,[[5,12]])})));return function(t,n){return e.apply(this,arguments)}}(),st="0x1626ba7e";var ct=function(){function e(e){this.initConfig(e)}var t=e.prototype;return t.initConfig=function(e){this._config={env:"prod",nodeRPC:"",chainType:"polygon",storageType:"sessionStorage"},this._config.env=e.env||"prod",this._config.chainType=e.chainType||"polygon";var t,n,r=(t=this._config.env,n=this._config.chainType,{env:t,nodeRPC:"prod"===t?ze.mainnet[n]:ze.testnet[n],chainType:n,walletUrl:"prod"===t?Fe:Re});this._config.nodeRPC=e.nodeRPC||r.nodeRPC,this._config.appSettings=function(e,t){return Ne({},t||{},{chain:(null==t?void 0:t.chain)||e,appName:(null==t?void 0:t.appName)||"MyDemo"})}(this._config.chainType,e.appSettings),this._provider=new c(this._config.nodeRPC),this._auth_provider=new c(function(e){return"prod"===e?ze.mainnet.polygon:ze.testnet.polygon}(this._config.env));var o,i,a,s=e.walletUrl||r.walletUrl;s&&(i=(o=s).domain,a=o.protocol,De={upDomain:i=i||Ie,upConnectUrl:(a=a||"https")+"://"+i+"/connect",upLogoutUrl:a+"://"+i+"/logout",upSignMessageUrl:a+"://"+i+"/sign-message",upTransactionUrl:a+"://"+i+"/send-transaction",upLoadingUrl:a+"://"+i+"/connect/loading"}),this._config.storageType=e.storageType||"sessionStorage"},t.updateConfig=function(e){this._config&&(e.chainType&&(this._config.chainType=e.chainType),e.nodeRPC&&(this._config.nodeRPC=e.nodeRPC,this._provider=new c(this._config.nodeRPC)),e.appSettings&&(this._config.appSettings=e.appSettings))},t.login=function(){var e=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,We(this._config,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getAccount=function(){var e,t;return e=this._config.storageType,(t=Be(e).get(rt))?JSON.parse(t):void 0},t.logout=function(){var e=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=!1),e.next=3,Ge(t);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.getProvider=function(){return this._provider},t.getAuthProvider=function(){return this._auth_provider},t.isLogin=function(){return!!this.getAccount()},t.assertLogin=function(){if(!this.isLogin())throw new Error("user is not login")},t.getAddress=function(){return this.assertLogin(),this.getAccount().address},t.sendTransaction=function(){var e=Ce(Le().mark((function e(t){return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),e.next=3,at(t,this._config);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.signMessage=function(){var e=Ce(Le().mark((function e(t,n){var r,o,i,a,s;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.assertLogin(),o=(r=n||{}).isEIP191Prefix,i=void 0!==o&&o,a=r.onAuthChain,s=void 0===a||a,"string"==typeof t&&(t=he.toUtf8Bytes(t)),e.next=5,it(new ue(this.getAddress(),he.hexlify(t),"V1",i,s),this._config);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.isValidSignature=function(){var e=Ce(Le().mark((function e(t,n,r){var o,i;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r||(this.assertLogin(),r=this.getAddress()),o=new te(r,[{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magicValue",type:"bytes4"}],stateMutability:"view",type:"function"}],this._auth_provider),e.next=4,o.isValidSignature(("string"==typeof(a=t)&&(a=he.toUtf8Bytes(a)),he.keccak256(he.concat([he.toUtf8Bytes("UniPass Signed Message:\n"),he.toUtf8Bytes(String(a.length)),a]))),n);case 4:return i=e.sent,e.abrupt("return",i===st);case 6:case"end":return e.stop()}var a}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.signTypedData=function(){var e=Ce(Le().mark((function e(t,n){var r,o;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.assertLogin(),null!=t){e.next=3;break}throw new Error("Missing data parameter");case 3:return r=(n||{}).onAuthChain,o=void 0===r||r,e.next=6,it(new ue(this.getAddress(),JSON.stringify(t),"V4",!1,o),this._config);case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.isValidTypedSignature=function(){var e=Ce(Le().mark((function e(t,n,r){var o,i,a;return Le().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new Error("Missing data parameter");case 2:return n||(this.assertLogin(),n=this.getAddress()),o=new te(n,[{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magicValue",type:"bytes4"}],stateMutability:"view",type:"function"}],this._auth_provider),i=fe(t),e.next=7,o.isValidSignature(i,r);case 7:return a=e.sent,e.abrupt("return",a===st);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),e}();function ut(e){if(e.error){const t=new Error(e.error.message);throw t.code=e.error.code,t.data=e.error.data,t}return e.result}function pt(t){var n,r,s;return e(this,void 0,void 0,(function*(){const u=null!==(n=t.chainId)&&void 0!==n?n:1;let l=null!==(r=t.rpcUrl)&&void 0!==r?r:null===(s=t.rpc)||void 0===s?void 0:s[u];const d=new class extends c{constructor(e,n){super(e,n),this.updateUpWalletConfig=e=>{var n;const r=null===(n=t.rpc)||void 0===n?void 0:n[e];if(!o.includes(e)||!r)throw new Error(`chainId ${e} not supported`);return this.upWallet.updateConfig({chainType:i(e),nodeRPC:r,appSettings:{chain:i(e)}}),this.chainId=e,this.rpcUrl=r,this.emit("chainChanged",`0x${e.toString(16)}`),{result:!0}},this.rpcUrl=e,this.chainId=u,this.upWallet=new ct({env:a(u),chainType:i(u),appSettings:{appIcon:t.appLogoUrl,appName:t.appName,chain:i(u)},rpcUrl:l,storageType:"sessionStorage"})}getSigner(){var e;const t=this.upWallet.getAccount();return new se(d,this.upWallet,null!==(e=null==t?void 0:t.address)&&void 0!==e?e:"",0)}connect(){return e(this,void 0,void 0,(function*(){const e=this.upWallet.getAccount();return e||(yield this.upWallet.login({email:false}))}))}disconnect(){return e(this,void 0,void 0,(function*(){yield this.upWallet.logout()}))}listAccounts(){return e(this,void 0,void 0,(function*(){const e=this.upWallet.getAccount();return(null==e?void 0:e.address)?[null==e?void 0:e.address]:[]}))}getAddress(){const e=this.upWallet.getAccount();return Promise.resolve((null==e?void 0:e.address)?p(null==e?void 0:e.address):null)}send(e,t){const n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:$(n),provider:this});const r=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(r&&this._cache[e])return this._cache[e];const o=ee({url:this.rpcUrl},JSON.stringify(n),ut).then((e=>(this.emit("debug",{action:"response",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:n,provider:this}),e}));return r&&(this._cache[e]=o,setTimeout((()=>{this._cache[e]=null}),0)),o}}(l);return d}))}function lt(t,n){return e(this,void 0,void 0,(function*(){const e=yield pt(t);return e.on("connect",n.connect),e.on("disconnect",(e=>{n.disconnect(e),n.accountsChanged([])})),e.on("accountsChanged",n.accountsChanged),e.on("chainChanged",n.chainChanged),e.on("message",(({type:e,data:t})=>n.message(e,t))),yield e.connect(),e}))}function dt(){var e;null===(e=s.getState().provider)||void 0===e||e.disconnect()}function ft(e){var t,n;return null===(n=null===(t=s.getState().provider)||void 0===t?void 0:t.upWallet)||void 0===n?void 0:n.signTypedData(e)}function ht(e){var t;const n=e.addChainParameters.chainId,r="string"==typeof n&&(null==n?void 0:n.startsWith("0x"))?parseInt(n,16):Number(n);if(!o.includes(r))throw new Error(`chainId ${r} not supported`);return null===(t=s.getState().provider)||void 0===t?void 0:t.updateUpWalletConfig(r)}export{pt as createProvider,lt as default,dt as disconnectWallet,ft as signTypedData,ht as switchChain};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getAddress as r}from"@ethersproject/address";import{hexZeroPad as t,hexConcat as e,isHexString as n,hexlify as i,arrayify as o}from"@ethersproject/bytes";import{k as s}from"./index-cc453bb1.js";import{defineReadOnly as a,deepCopy as c,shallowCopy as u,resolveProperties as h}from"@ethersproject/properties";import{L as d,B as f,i as m}from"./id-830e09aa.js";const l="hash/5.7.0";var y=function(r,t,e,n){return new(e||(e=Promise))((function(i,o){function s(r){try{c(n.next(r))}catch(r){o(r)}}function a(r){try{c(n.throw(r))}catch(r){o(r)}}function c(r){var t;r.done?i(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(s,a)}c((n=n.apply(r,t||[])).next())}))};const g=new d(l),p=new Uint8Array(32);p.fill(0);const v=f.from(-1),P=f.from(0),E=f.from(1),w=f.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const x=t(E.toHexString(),32),A=t(P.toHexString(),32),T={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},_=["name","version","chainId","verifyingContract","salt"];function I(r){return function(t){return"string"!=typeof t&&g.throwArgumentError(`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,t),t}}const S={name:I("name"),version:I("version"),chainId:function(r){try{return f.from(r).toString()}catch(r){}return g.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",r)},verifyingContract:function(t){try{return r(t).toLowerCase()}catch(r){}return g.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(r){try{const t=o(r);if(32!==t.length)throw new Error("bad length");return i(t)}catch(r){}return g.throwArgumentError('invalid domain value "salt"',"domain.salt",r)}};function G(n){{const r=n.match(/^(u?)int(\d*)$/);if(r){const e=""===r[1],i=parseInt(r[2]||"256");(i%8!=0||i>256||r[2]&&r[2]!==String(i))&&g.throwArgumentError("invalid numeric width","type",n);const o=w.mask(e?i-1:i),s=e?o.add(E).mul(v):P;return function(r){const e=f.from(r);return(e.lt(s)||e.gt(o))&&g.throwArgumentError(`value out-of-bounds for ${n}`,"value",r),t(e.toTwos(256).toHexString(),32)}}}{const r=n.match(/^bytes(\d+)$/);if(r){const t=parseInt(r[1]);return(0===t||t>32||r[1]!==String(t))&&g.throwArgumentError("invalid bytes width","type",n),function(r){return o(r).length!==t&&g.throwArgumentError(`invalid length for ${n}`,"value",r),function(r){const t=o(r),n=t.length%32;return n?e([t,p.slice(n)]):i(t)}(r)}}}switch(n){case"address":return function(e){return t(r(e),32)};case"bool":return function(r){return r?x:A};case"bytes":return function(r){return s(r)};case"string":return function(r){return m(r)}}return null}function C(r,t){return`${r}(${t.map((({name:r,type:t})=>t+" "+r)).join(",")})`}class F{constructor(r){a(this,"types",Object.freeze(c(r))),a(this,"_encoderCache",{}),a(this,"_types",{});const t={},e={},n={};Object.keys(r).forEach((r=>{t[r]={},e[r]=[],n[r]={}}));for(const n in r){const i={};r[n].forEach((o=>{i[o.name]&&g.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",r),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&g.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",r);G(s)||(e[s]||g.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",r),e[s].push(n),t[n][s]=!0)}))}const i=Object.keys(e).filter((r=>0===e[r].length));0===i.length?g.throwArgumentError("missing primary type","types",r):i.length>1&&g.throwArgumentError(`ambiguous primary types or unused types: ${i.map((r=>JSON.stringify(r))).join(", ")}`,"types",r),a(this,"primaryType",i[0]),function i(o,s){s[o]&&g.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",r),s[o]=!0,Object.keys(t[o]).forEach((r=>{e[r]&&(i(r,s),Object.keys(s).forEach((t=>{n[t][r]=!0})))})),delete s[o]}(this.primaryType,{});for(const t in n){const e=Object.keys(n[t]);e.sort(),this._types[t]=C(t,r[t])+e.map((t=>C(t,r[t]))).join("")}}getEncoder(r){let t=this._encoderCache[r];return t||(t=this._encoderCache[r]=this._getEncoder(r)),t}_getEncoder(r){{const t=G(r);if(t)return t}const t=r.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const r=t[1],n=this.getEncoder(r),i=parseInt(t[3]);return t=>{i>=0&&t.length!==i&&g.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t);let o=t.map(n);return this._types[r]&&(o=o.map(s)),s(e(o))}}const n=this.types[r];if(n){const t=m(this._types[r]);return r=>{const i=n.map((({name:t,type:e})=>{const n=this.getEncoder(e)(r[t]);return this._types[e]?s(n):n}));return i.unshift(t),e(i)}}return g.throwArgumentError(`unknown type: ${r}`,"type",r)}encodeType(r){const t=this._types[r];return t||g.throwArgumentError(`unknown type: ${JSON.stringify(r)}`,"name",r),t}encodeData(r,t){return this.getEncoder(r)(t)}hashStruct(r,t){return s(this.encodeData(r,t))}encode(r){return this.encodeData(this.primaryType,r)}hash(r){return this.hashStruct(this.primaryType,r)}_visit(r,t,e){if(G(r))return e(r,t);const n=r.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const r=n[1],i=parseInt(n[3]);return i>=0&&t.length!==i&&g.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map((t=>this._visit(r,t,e)))}const i=this.types[r];return i?i.reduce(((r,{name:n,type:i})=>(r[n]=this._visit(i,t[n],e),r)),{}):g.throwArgumentError(`unknown type: ${r}`,"type",r)}visit(r,t){return this._visit(this.primaryType,r,t)}static from(r){return new F(r)}static getPrimaryType(r){return F.from(r).primaryType}static hashStruct(r,t,e){return F.from(t).hashStruct(r,e)}static hashDomain(r){const t=[];for(const e in r){const n=T[e];n||g.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(e)}`,"domain",r),t.push({name:e,type:n})}return t.sort(((r,t)=>_.indexOf(r.name)-_.indexOf(t.name))),F.hashStruct("EIP712Domain",{EIP712Domain:t},r)}static encode(r,t,n){return e(["0x1901",F.hashDomain(r),F.from(t).hash(n)])}static hash(r,t,e){return s(F.encode(r,t,e))}static resolveNames(r,t,e,i){return y(this,void 0,void 0,(function*(){r=u(r);const o={};r.verifyingContract&&!n(r.verifyingContract,20)&&(o[r.verifyingContract]="0x");const s=F.from(t);s.visit(e,((r,t)=>("address"!==r||n(t,20)||(o[t]="0x"),t)));for(const r in o)o[r]=yield i(r);return r.verifyingContract&&o[r.verifyingContract]&&(r.verifyingContract=o[r.verifyingContract]),e=s.visit(e,((r,t)=>"address"===r&&o[t]?o[t]:t)),{domain:r,value:e}}))}static getPayload(r,t,e){F.hashDomain(r);const n={},s=[];_.forEach((t=>{const e=r[t];null!=e&&(n[t]=S[t](e),s.push({name:t,type:T[t]}))}));const a=F.from(t),c=u(t);return c.EIP712Domain?g.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",t):c.EIP712Domain=s,a.encode(e),{types:c,domain:n,primaryType:a.primaryType,message:a.visit(e,((r,t)=>{if(r.match(/^bytes(\d*)/))return i(o(t));if(r.match(/^u?int/))return f.from(t).toString();switch(r){case"address":return t.toLowerCase();case"bool":return!!t;case"string":return"string"!=typeof t&&g.throwArgumentError("invalid string","value",t),t}return g.throwArgumentError("unsupported type","type",r)}))}}}var N=function(r,t,e,n){return new(e||(e=Promise))((function(i,o){function s(r){try{c(n.next(r))}catch(r){o(r)}}function a(r){try{c(n.throw(r))}catch(r){o(r)}}function c(r){var t;r.done?i(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(s,a)}c((n=n.apply(r,t||[])).next())}))};const O=new d("abstract-signer/5.7.0"),k=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],D=[d.errors.INSUFFICIENT_FUNDS,d.errors.NONCE_EXPIRED,d.errors.REPLACEMENT_UNDERPRICED];class b{constructor(){O.checkAbstract(new.target,b),a(this,"_isSigner",!0)}getBalance(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),r)}))}getTransactionCount(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),r)}))}estimateGas(r){return N(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const t=yield h(this.checkTransaction(r));return yield this.provider.estimateGas(t)}))}call(r,t){return N(this,void 0,void 0,(function*(){this._checkProvider("call");const e=yield h(this.checkTransaction(r));return yield this.provider.call(e,t)}))}sendTransaction(r){return N(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const t=yield this.populateTransaction(r),e=yield this.signTransaction(t);return yield this.provider.sendTransaction(e)}))}getChainId(){return N(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return N(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return N(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(r)}))}checkTransaction(r){for(const t in r)-1===k.indexOf(t)&&O.throwArgumentError("invalid transaction key: "+t,"transaction",r);const t=u(r);return null==t.from?t.from=this.getAddress():t.from=Promise.all([Promise.resolve(t.from),this.getAddress()]).then((t=>(t[0].toLowerCase()!==t[1].toLowerCase()&&O.throwArgumentError("from address mismatch","transaction",r),t[0]))),t}populateTransaction(r){return N(this,void 0,void 0,(function*(){const t=yield h(this.checkTransaction(r));null!=t.to&&(t.to=Promise.resolve(t.to).then((r=>N(this,void 0,void 0,(function*(){if(null==r)return null;const t=yield this.resolveName(r);return null==t&&O.throwArgumentError("provided ENS name resolves to null","tx.to",r),t})))),t.to.catch((r=>{})));const e=null!=t.maxFeePerGas||null!=t.maxPriorityFeePerGas;if(null==t.gasPrice||2!==t.type&&!e?0!==t.type&&1!==t.type||!e||O.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",r):O.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",r),2!==t.type&&null!=t.type||null==t.maxFeePerGas||null==t.maxPriorityFeePerGas)if(0===t.type||1===t.type)null==t.gasPrice&&(t.gasPrice=this.getGasPrice());else{const r=yield this.getFeeData();if(null==t.type)if(null!=r.maxFeePerGas&&null!=r.maxPriorityFeePerGas)if(t.type=2,null!=t.gasPrice){const r=t.gasPrice;delete t.gasPrice,t.maxFeePerGas=r,t.maxPriorityFeePerGas=r}else null==t.maxFeePerGas&&(t.maxFeePerGas=r.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=r.maxPriorityFeePerGas);else null!=r.gasPrice?(e&&O.throwError("network does not support EIP-1559",d.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==t.gasPrice&&(t.gasPrice=r.gasPrice),t.type=0):O.throwError("failed to get consistent fee data",d.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===t.type&&(null==t.maxFeePerGas&&(t.maxFeePerGas=r.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=r.maxPriorityFeePerGas))}else t.type=2;return null==t.nonce&&(t.nonce=this.getTransactionCount("pending")),null==t.gasLimit&&(t.gasLimit=this.estimateGas(t).catch((r=>{if(D.indexOf(r.code)>=0)throw r;return O.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",d.errors.UNPREDICTABLE_GAS_LIMIT,{error:r,tx:t})}))),null==t.chainId?t.chainId=this.getChainId():t.chainId=Promise.all([Promise.resolve(t.chainId),this.getChainId()]).then((t=>(0!==t[1]&&t[0]!==t[1]&&O.throwArgumentError("chainId address mismatch","transaction",r),t[0]))),yield h(t)}))}_checkProvider(r){this.provider||O.throwError("missing provider",d.errors.UNSUPPORTED_OPERATION,{operation:r||"_checkProvider"})}static isSigner(r){return!(!r||!r._isSigner)}}class $ extends b{constructor(r,t){super(),a(this,"address",r),a(this,"provider",t||null)}getAddress(){return Promise.resolve(this.address)}_fail(r,t){return Promise.resolve().then((()=>{O.throwError(r,d.errors.UNSUPPORTED_OPERATION,{operation:t})}))}signMessage(r){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(r){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(r,t,e){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(r){return new $(this.address,r)}}export{b as S,F as T,$ as V,l as v};
|
|
1
|
+
import{getAddress as r}from"@ethersproject/address";import{hexZeroPad as t,hexConcat as e,isHexString as n,hexlify as i,arrayify as o}from"@ethersproject/bytes";import{k as s}from"./index-d1e775cf.js";import{defineReadOnly as a,deepCopy as c,shallowCopy as u,resolveProperties as h}from"@ethersproject/properties";import{L as d,B as f,i as m}from"./id-bb7887d8.js";const l="hash/5.7.0";var y=function(r,t,e,n){return new(e||(e=Promise))((function(i,o){function s(r){try{c(n.next(r))}catch(r){o(r)}}function a(r){try{c(n.throw(r))}catch(r){o(r)}}function c(r){var t;r.done?i(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(s,a)}c((n=n.apply(r,t||[])).next())}))};const g=new d(l),p=new Uint8Array(32);p.fill(0);const v=f.from(-1),P=f.from(0),E=f.from(1),w=f.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const x=t(E.toHexString(),32),A=t(P.toHexString(),32),T={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},_=["name","version","chainId","verifyingContract","salt"];function I(r){return function(t){return"string"!=typeof t&&g.throwArgumentError(`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,t),t}}const S={name:I("name"),version:I("version"),chainId:function(r){try{return f.from(r).toString()}catch(r){}return g.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",r)},verifyingContract:function(t){try{return r(t).toLowerCase()}catch(r){}return g.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(r){try{const t=o(r);if(32!==t.length)throw new Error("bad length");return i(t)}catch(r){}return g.throwArgumentError('invalid domain value "salt"',"domain.salt",r)}};function G(n){{const r=n.match(/^(u?)int(\d*)$/);if(r){const e=""===r[1],i=parseInt(r[2]||"256");(i%8!=0||i>256||r[2]&&r[2]!==String(i))&&g.throwArgumentError("invalid numeric width","type",n);const o=w.mask(e?i-1:i),s=e?o.add(E).mul(v):P;return function(r){const e=f.from(r);return(e.lt(s)||e.gt(o))&&g.throwArgumentError(`value out-of-bounds for ${n}`,"value",r),t(e.toTwos(256).toHexString(),32)}}}{const r=n.match(/^bytes(\d+)$/);if(r){const t=parseInt(r[1]);return(0===t||t>32||r[1]!==String(t))&&g.throwArgumentError("invalid bytes width","type",n),function(r){return o(r).length!==t&&g.throwArgumentError(`invalid length for ${n}`,"value",r),function(r){const t=o(r),n=t.length%32;return n?e([t,p.slice(n)]):i(t)}(r)}}}switch(n){case"address":return function(e){return t(r(e),32)};case"bool":return function(r){return r?x:A};case"bytes":return function(r){return s(r)};case"string":return function(r){return m(r)}}return null}function C(r,t){return`${r}(${t.map((({name:r,type:t})=>t+" "+r)).join(",")})`}class F{constructor(r){a(this,"types",Object.freeze(c(r))),a(this,"_encoderCache",{}),a(this,"_types",{});const t={},e={},n={};Object.keys(r).forEach((r=>{t[r]={},e[r]=[],n[r]={}}));for(const n in r){const i={};r[n].forEach((o=>{i[o.name]&&g.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",r),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&g.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",r);G(s)||(e[s]||g.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",r),e[s].push(n),t[n][s]=!0)}))}const i=Object.keys(e).filter((r=>0===e[r].length));0===i.length?g.throwArgumentError("missing primary type","types",r):i.length>1&&g.throwArgumentError(`ambiguous primary types or unused types: ${i.map((r=>JSON.stringify(r))).join(", ")}`,"types",r),a(this,"primaryType",i[0]),function i(o,s){s[o]&&g.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",r),s[o]=!0,Object.keys(t[o]).forEach((r=>{e[r]&&(i(r,s),Object.keys(s).forEach((t=>{n[t][r]=!0})))})),delete s[o]}(this.primaryType,{});for(const t in n){const e=Object.keys(n[t]);e.sort(),this._types[t]=C(t,r[t])+e.map((t=>C(t,r[t]))).join("")}}getEncoder(r){let t=this._encoderCache[r];return t||(t=this._encoderCache[r]=this._getEncoder(r)),t}_getEncoder(r){{const t=G(r);if(t)return t}const t=r.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const r=t[1],n=this.getEncoder(r),i=parseInt(t[3]);return t=>{i>=0&&t.length!==i&&g.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t);let o=t.map(n);return this._types[r]&&(o=o.map(s)),s(e(o))}}const n=this.types[r];if(n){const t=m(this._types[r]);return r=>{const i=n.map((({name:t,type:e})=>{const n=this.getEncoder(e)(r[t]);return this._types[e]?s(n):n}));return i.unshift(t),e(i)}}return g.throwArgumentError(`unknown type: ${r}`,"type",r)}encodeType(r){const t=this._types[r];return t||g.throwArgumentError(`unknown type: ${JSON.stringify(r)}`,"name",r),t}encodeData(r,t){return this.getEncoder(r)(t)}hashStruct(r,t){return s(this.encodeData(r,t))}encode(r){return this.encodeData(this.primaryType,r)}hash(r){return this.hashStruct(this.primaryType,r)}_visit(r,t,e){if(G(r))return e(r,t);const n=r.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const r=n[1],i=parseInt(n[3]);return i>=0&&t.length!==i&&g.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map((t=>this._visit(r,t,e)))}const i=this.types[r];return i?i.reduce(((r,{name:n,type:i})=>(r[n]=this._visit(i,t[n],e),r)),{}):g.throwArgumentError(`unknown type: ${r}`,"type",r)}visit(r,t){return this._visit(this.primaryType,r,t)}static from(r){return new F(r)}static getPrimaryType(r){return F.from(r).primaryType}static hashStruct(r,t,e){return F.from(t).hashStruct(r,e)}static hashDomain(r){const t=[];for(const e in r){const n=T[e];n||g.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(e)}`,"domain",r),t.push({name:e,type:n})}return t.sort(((r,t)=>_.indexOf(r.name)-_.indexOf(t.name))),F.hashStruct("EIP712Domain",{EIP712Domain:t},r)}static encode(r,t,n){return e(["0x1901",F.hashDomain(r),F.from(t).hash(n)])}static hash(r,t,e){return s(F.encode(r,t,e))}static resolveNames(r,t,e,i){return y(this,void 0,void 0,(function*(){r=u(r);const o={};r.verifyingContract&&!n(r.verifyingContract,20)&&(o[r.verifyingContract]="0x");const s=F.from(t);s.visit(e,((r,t)=>("address"!==r||n(t,20)||(o[t]="0x"),t)));for(const r in o)o[r]=yield i(r);return r.verifyingContract&&o[r.verifyingContract]&&(r.verifyingContract=o[r.verifyingContract]),e=s.visit(e,((r,t)=>"address"===r&&o[t]?o[t]:t)),{domain:r,value:e}}))}static getPayload(r,t,e){F.hashDomain(r);const n={},s=[];_.forEach((t=>{const e=r[t];null!=e&&(n[t]=S[t](e),s.push({name:t,type:T[t]}))}));const a=F.from(t),c=u(t);return c.EIP712Domain?g.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",t):c.EIP712Domain=s,a.encode(e),{types:c,domain:n,primaryType:a.primaryType,message:a.visit(e,((r,t)=>{if(r.match(/^bytes(\d*)/))return i(o(t));if(r.match(/^u?int/))return f.from(t).toString();switch(r){case"address":return t.toLowerCase();case"bool":return!!t;case"string":return"string"!=typeof t&&g.throwArgumentError("invalid string","value",t),t}return g.throwArgumentError("unsupported type","type",r)}))}}}var N=function(r,t,e,n){return new(e||(e=Promise))((function(i,o){function s(r){try{c(n.next(r))}catch(r){o(r)}}function a(r){try{c(n.throw(r))}catch(r){o(r)}}function c(r){var t;r.done?i(r.value):(t=r.value,t instanceof e?t:new e((function(r){r(t)}))).then(s,a)}c((n=n.apply(r,t||[])).next())}))};const O=new d("abstract-signer/5.7.0"),k=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],D=[d.errors.INSUFFICIENT_FUNDS,d.errors.NONCE_EXPIRED,d.errors.REPLACEMENT_UNDERPRICED];class b{constructor(){O.checkAbstract(new.target,b),a(this,"_isSigner",!0)}getBalance(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),r)}))}getTransactionCount(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),r)}))}estimateGas(r){return N(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const t=yield h(this.checkTransaction(r));return yield this.provider.estimateGas(t)}))}call(r,t){return N(this,void 0,void 0,(function*(){this._checkProvider("call");const e=yield h(this.checkTransaction(r));return yield this.provider.call(e,t)}))}sendTransaction(r){return N(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const t=yield this.populateTransaction(r),e=yield this.signTransaction(t);return yield this.provider.sendTransaction(e)}))}getChainId(){return N(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return N(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return N(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(r){return N(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(r)}))}checkTransaction(r){for(const t in r)-1===k.indexOf(t)&&O.throwArgumentError("invalid transaction key: "+t,"transaction",r);const t=u(r);return null==t.from?t.from=this.getAddress():t.from=Promise.all([Promise.resolve(t.from),this.getAddress()]).then((t=>(t[0].toLowerCase()!==t[1].toLowerCase()&&O.throwArgumentError("from address mismatch","transaction",r),t[0]))),t}populateTransaction(r){return N(this,void 0,void 0,(function*(){const t=yield h(this.checkTransaction(r));null!=t.to&&(t.to=Promise.resolve(t.to).then((r=>N(this,void 0,void 0,(function*(){if(null==r)return null;const t=yield this.resolveName(r);return null==t&&O.throwArgumentError("provided ENS name resolves to null","tx.to",r),t})))),t.to.catch((r=>{})));const e=null!=t.maxFeePerGas||null!=t.maxPriorityFeePerGas;if(null==t.gasPrice||2!==t.type&&!e?0!==t.type&&1!==t.type||!e||O.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",r):O.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",r),2!==t.type&&null!=t.type||null==t.maxFeePerGas||null==t.maxPriorityFeePerGas)if(0===t.type||1===t.type)null==t.gasPrice&&(t.gasPrice=this.getGasPrice());else{const r=yield this.getFeeData();if(null==t.type)if(null!=r.maxFeePerGas&&null!=r.maxPriorityFeePerGas)if(t.type=2,null!=t.gasPrice){const r=t.gasPrice;delete t.gasPrice,t.maxFeePerGas=r,t.maxPriorityFeePerGas=r}else null==t.maxFeePerGas&&(t.maxFeePerGas=r.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=r.maxPriorityFeePerGas);else null!=r.gasPrice?(e&&O.throwError("network does not support EIP-1559",d.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==t.gasPrice&&(t.gasPrice=r.gasPrice),t.type=0):O.throwError("failed to get consistent fee data",d.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===t.type&&(null==t.maxFeePerGas&&(t.maxFeePerGas=r.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=r.maxPriorityFeePerGas))}else t.type=2;return null==t.nonce&&(t.nonce=this.getTransactionCount("pending")),null==t.gasLimit&&(t.gasLimit=this.estimateGas(t).catch((r=>{if(D.indexOf(r.code)>=0)throw r;return O.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",d.errors.UNPREDICTABLE_GAS_LIMIT,{error:r,tx:t})}))),null==t.chainId?t.chainId=this.getChainId():t.chainId=Promise.all([Promise.resolve(t.chainId),this.getChainId()]).then((t=>(0!==t[1]&&t[0]!==t[1]&&O.throwArgumentError("chainId address mismatch","transaction",r),t[0]))),yield h(t)}))}_checkProvider(r){this.provider||O.throwError("missing provider",d.errors.UNSUPPORTED_OPERATION,{operation:r||"_checkProvider"})}static isSigner(r){return!(!r||!r._isSigner)}}class $ extends b{constructor(r,t){super(),a(this,"address",r),a(this,"provider",t||null)}getAddress(){return Promise.resolve(this.address)}_fail(r,t){return Promise.resolve().then((()=>{O.throwError(r,d.errors.UNSUPPORTED_OPERATION,{operation:t})}))}signMessage(r){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(r){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(r,t,e){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(r){return new $(this.address,r)}}export{b as S,F as T,$ as V,l as v};
|