@depay/coinbase-wallet-sdk
Version:
Coinbase Wallet SDK browser pre-built usable in rollup bundles.
9 lines • 138 kB
JavaScript
var CoinbaseWalletSdk=function(t){var e={};function n(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(r,s,function(e){return t[e]}.bind(null,s));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=29)}([function(t,e,n){"use strict";(function(t){n.d(e,"m",(function(){return a})),n.d(e,"n",(function(){return c})),n.d(e,"k",(function(){return u})),n.d(e,"i",(function(){return l})),n.d(e,"b",(function(){return h})),n.d(e,"a",(function(){return d})),n.d(e,"j",(function(){return f})),n.d(e,"l",(function(){return b})),n.d(e,"c",(function(){return w})),n.d(e,"e",(function(){return _})),n.d(e,"f",(function(){return v})),n.d(e,"d",(function(){return k})),n.d(e,"g",(function(){return E})),n.d(e,"h",(function(){return C}));var r=n(1),s=n(4);const i=/^[0-9]*$/,o=/^[a-f0-9]*$/;function a(t){return c(crypto.getRandomValues(new Uint8Array(t)))}function c(t){return[...t].map(t=>t.toString(16).padStart(2,"0")).join("")}function u(t){return new Uint8Array(t.match(/.{1,2}/g).map(t=>Number.parseInt(t,16)))}function l(t,e=!1){const n=t.toString("hex");return Object(s.c)(e?"0x"+n:n)}function h(t){return l(_(t),!0)}function d(t){return Object(s.b)(t.toString(10))}function f(t){return Object(s.c)("0x"+BigInt(t).toString(16))}function p(t){return t.startsWith("0x")||t.startsWith("0X")}function g(t){return p(t)?t.slice(2):t}function b(t){return p(t)?"0x"+t.slice(2):"0x"+t}function y(t){if("string"!=typeof t)return!1;const e=g(t).toLowerCase();return o.test(e)}function m(t,e=!1){let n=function(t,e=!1){if("string"==typeof t){const n=g(t).toLowerCase();if(o.test(n))return Object(s.c)(e?"0x"+n:n)}throw r.a.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}(t,!1);return n.length%2==1&&(n=Object(s.c)("0"+n)),e?Object(s.c)("0x"+n):n}function w(t){if("string"==typeof t){const e=g(t).toLowerCase();if(y(e)&&40===e.length)return Object(s.a)(b(e))}throw r.a.rpc.invalidParams("Invalid Ethereum address: "+String(t))}function _(e){if(t.isBuffer(e))return e;if("string"==typeof e){if(y(e)){const n=m(e,!1);return t.from(n,"hex")}return t.from(e,"utf8")}throw r.a.rpc.invalidParams("Not binary data: "+String(e))}function v(t){if("number"==typeof t&&Number.isInteger(t))return Object(s.d)(t);if("string"==typeof t){if(i.test(t))return Object(s.d)(Number(t));if(y(t))return Object(s.d)(Number(BigInt(m(t,!0))))}throw r.a.rpc.invalidParams("Not an integer: "+String(t))}function k(t){if(null!==t&&("bigint"==typeof t||function(t){if(null==t||"function"!=typeof t.constructor)return!1;const{constructor:e}=t;return"function"==typeof e.config&&"number"==typeof e.EUCLID}(t)))return BigInt(t.toString(10));if("number"==typeof t)return BigInt(v(t));if("string"==typeof t){if(i.test(t))return BigInt(t);if(y(t))return BigInt(m(t,!0))}throw r.a.rpc.invalidParams("Not an integer: "+String(t))}function E(t){if("string"==typeof t)return JSON.parse(t);if("object"==typeof t)return t;throw r.a.rpc.invalidParams("Not a JSON string or an object: "+String(t))}function C(){const t=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:n}=document.location,r=t?t.getAttribute("href"):null;return!r||r.startsWith("javascript:")||r.startsWith("vbscript:")?`${e}//${n}/favicon.ico`:r.startsWith("http://")||r.startsWith("https://")||r.startsWith("data:")?r:r.startsWith("//")?e+r:`${e}//${n}${r}`}}).call(this,n(10).Buffer)},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(2),s=n(12);const i={rpc:{parse:t=>o(r.b.rpc.parse,t),invalidRequest:t=>o(r.b.rpc.invalidRequest,t),invalidParams:t=>o(r.b.rpc.invalidParams,t),methodNotFound:t=>o(r.b.rpc.methodNotFound,t),internal:t=>o(r.b.rpc.internal,t),server:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return o(e,t)},invalidInput:t=>o(r.b.rpc.invalidInput,t),resourceNotFound:t=>o(r.b.rpc.resourceNotFound,t),resourceUnavailable:t=>o(r.b.rpc.resourceUnavailable,t),transactionRejected:t=>o(r.b.rpc.transactionRejected,t),methodNotSupported:t=>o(r.b.rpc.methodNotSupported,t),limitExceeded:t=>o(r.b.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>a(r.b.provider.userRejectedRequest,t),unauthorized:t=>a(r.b.provider.unauthorized,t),unsupportedMethod:t=>a(r.b.provider.unsupportedMethod,t),disconnected:t=>a(r.b.provider.disconnected,t),chainDisconnected:t=>a(r.b.provider.chainDisconnected,t),unsupportedChain:t=>a(r.b.provider.unsupportedChain,t),custom:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:r}=t;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new l(e,n,r)}}};function o(t,e){const[n,r]=c(e);return new u(t,n||Object(s.a)(t),r)}function a(t,e){const[n,r]=c(e);return new l(t,n||Object(s.a)(t),r)}function c(t){if(t){if("string"==typeof t)return[t];if("object"==typeof t&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&"string"!=typeof e)throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}class u extends Error{constructor(t,e,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||"string"!=typeof e)throw new Error('"message" must be a nonempty string.');super(e),this.code=t,void 0!==n&&(this.data=n)}}class l extends u{constructor(t,e,n){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,n)}}},function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"a",(function(){return s}));const r={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},s={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}}},function(t,e,n){"use strict";function r(t){return void 0!==t.errorMessage}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";n.d(e,"c",(function(){return r})),n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return i})),n.d(e,"d",(function(){return o})),n.d(e,"e",(function(){return a}));const r=t=>t,s=t=>t,i=t=>t;function o(t){return Math.floor(t)}const a=t=>t},function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));class r{constructor(t,e){this.scope=t,this.module=e}storeObject(t,e){this.setItem(t,JSON.stringify(e))}loadObject(t){const e=this.getItem(t);return e?JSON.parse(e):void 0}setItem(t,e){localStorage.setItem(this.scopedKey(t),e)}getItem(t){return localStorage.getItem(this.scopedKey(t))}removeItem(t){localStorage.removeItem(this.scopedKey(t))}clear(){const t=this.scopedKey(""),e=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);"string"==typeof r&&r.startsWith(t)&&e.push(r)}e.forEach(t=>localStorage.removeItem(t))}scopedKey(t){return`-${this.scope}${this.module?":"+this.module:""}:${t}`}static clearAll(){new r("CBWSDK").clear(),new r("walletlink").clear()}}},function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"a",(function(){return s}));const r="4.2.3",s="@coinbase/wallet-sdk"},function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return o})),n.d(e,"a",(function(){return a}));var r=n(6),s=n(1);async function i(t,e){const n=Object.assign(Object.assign({},t),{jsonrpc:"2.0",id:crypto.randomUUID()}),s=await window.fetch(e,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":r.b,"X-Cbw-Sdk-Platform":r.a}}),{result:i,error:o}=await s.json();if(o)throw o;return i}function o({metadata:t,preference:e}){var n,r;const{appName:s,appLogoUrl:i,appChainIds:o}=t;if("smartWalletOnly"!==e.options){const t=globalThis.coinbaseWalletExtension;if(t)return null===(n=t.setAppInfo)||void 0===n||n.call(t,s,i,o,e),t}const a=function(){var t,e;try{const n=globalThis;return null!==(t=n.ethereum)&&void 0!==t?t:null===(e=n.top)||void 0===e?void 0:e.ethereum}catch(t){return}}();if(null==a?void 0:a.isCoinbaseBrowser)return null===(r=a.setAppInfo)||void 0===r||r.call(a,s,i,o,e),a}function a(t){if(!t||"object"!=typeof t||Array.isArray(t))throw s.a.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:t});const{method:e,params:n}=t;if("string"!=typeof e||0===e.length)throw s.a.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:t});if(void 0!==n&&!Array.isArray(n)&&("object"!=typeof n||null===n))throw s.a.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:t});switch(e){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw s.a.provider.unsupportedMethod()}}},function(t,e,n){"use strict";n.d(e,"c",(function(){return r})),n.d(e,"b",(function(){return s})),n.d(e,"a",(function(){return i}));const r="walletUsername",s="Addresses",i="AppVersion"},function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return s})),n.d(e,"a",(function(){return i}));const r="https://keys.coinbase.com/connect",s="https://www.walletlink.org",i="https://go.cb-w.com/walletlink"},function(t,e,n){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var r=n(21),s=n(22),i=n(23);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return h(this,t)}return u(this,t,e,n)}function u(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=d(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(e,n),s=(t=a(t,r)).write(e,n);s!==r&&(t=t.slice(0,s));return t}(t,e,n):function(t,e){if(c.isBuffer(e)){var n=0|f(e.length);return 0===(t=a(t,n)).length||e.copy(t,0,0,n),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?a(t,0):d(t,e);if("Buffer"===e.type&&i(e.data))return d(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function h(t,e){if(l(e),t=a(t,e<0?0:0|f(e)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function d(t,e){var n=e.length<0?0:0|f(e.length);t=a(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function f(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(t).length;default:if(r)return H(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,n);case"utf8":case"utf-8":return S(this,e,n);case"ascii":return x(this,e,n);case"latin1":case"binary":return A(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,s){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=s?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(s)return-1;n=t.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,s);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,s);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,s){var i,o=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,n/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(s){var l=-1;for(i=n;i<a;i++)if(u(t,i)===u(e,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*o}else-1!==l&&(i-=i-l),l=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,d=0;d<c;d++)if(u(t,i+d)!==u(e,d)){h=!1;break}if(h)return i}return-1}function w(t,e,n,r){n=Number(n)||0;var s=t.length-n;r?(r=Number(r))>s&&(r=s):r=s;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var o=0;o<r;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[n+o]=a}return o}function _(t,e,n,r){return q(H(e,t.length-n),t,n,r)}function v(t,e,n,r){return q(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function k(t,e,n,r){return v(t,e,n,r)}function E(t,e,n,r){return q(W(e),t,n,r)}function C(t,e,n,r){return q(function(t,e){for(var n,r,s,i=[],o=0;o<t.length&&!((e-=2)<0);++o)n=t.charCodeAt(o),r=n>>8,s=n%256,i.push(s),i.push(r);return i}(e,t.length-n),t,n,r)}function I(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function S(t,e,n){n=Math.min(t.length,n);for(var r=[],s=e;s<n;){var i,o,a,c,u=t[s],l=null,h=u>239?4:u>223?3:u>191?2:1;if(s+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(i=t[s+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=t[s+1],o=t[s+2],128==(192&i)&&128==(192&o)&&(c=(15&u)<<12|(63&i)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=t[s+1],o=t[s+2],a=t[s+3],128==(192&i)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),s+=h}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=4096));return n}(r)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=o(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,n){return u(null,t,e,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,n){return function(t,e,n,r){return l(e),e<=0?a(t,e):void 0!==n?"string"==typeof r?a(t,e).fill(n,r):a(t,e).fill(n):a(t,e)}(null,t,e,n)},c.allocUnsafe=function(t){return h(null,t)},c.allocUnsafeSlow=function(t){return h(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,s=0,i=Math.min(n,r);s<i;++s)if(t[s]!==e[s]){n=t[s],r=e[s];break}return n<r?-1:r<n?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=c.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){var o=t[n];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,s),s+=o.length}return r},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)b(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?S(this,0,t):g.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,n,r,s){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===s&&(s=this.length),e<0||n>t.length||r<0||s>this.length)throw new RangeError("out of range index");if(r>=s&&e>=n)return 0;if(r>=s)return-1;if(e>=n)return 1;if(this===t)return 0;for(var i=(s>>>=0)-(r>>>=0),o=(n>>>=0)-(e>>>=0),a=Math.min(i,o),u=this.slice(r,s),l=t.slice(e,n),h=0;h<a;++h)if(u[h]!==l[h]){i=u[h],o=l[h];break}return i<o?-1:o<i?1:0},c.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},c.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},c.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},c.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var s=this.length-e;if((void 0===n||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return w(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":return v(this,t,e,n);case"latin1":case"binary":return k(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(t,e,n){var r="";n=Math.min(t.length,n);for(var s=e;s<n;++s)r+=String.fromCharCode(127&t[s]);return r}function A(t,e,n){var r="";n=Math.min(t.length,n);for(var s=e;s<n;++s)r+=String.fromCharCode(t[s]);return r}function M(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var s="",i=e;i<n;++i)s+=B(t[i]);return s}function O(t,e,n){for(var r=t.slice(e,n),s="",i=0;i<r.length;i+=2)s+=String.fromCharCode(r[i]+256*r[i+1]);return s}function L(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,n,r,s,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function P(t,e,n,r){e<0&&(e=65535+e+1);for(var s=0,i=Math.min(t.length-n,2);s<i;++s)t[n+s]=(e&255<<8*(r?s:1-s))>>>8*(r?s:1-s)}function R(t,e,n,r){e<0&&(e=4294967295+e+1);for(var s=0,i=Math.min(t.length-n,4);s<i;++s)t[n+s]=e>>>8*(r?s:3-s)&255}function T(t,e,n,r,s,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(t,e,n,r,i){return i||T(t,0,n,4),s.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,i){return i||T(t,0,n,8),s.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=c.prototype;else{var s=e-t;n=new c(s,void 0);for(var i=0;i<s;++i)n[i]=this[i+t]}return n},c.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||L(t,e,this.length);for(var r=this[t],s=1,i=0;++i<e&&(s*=256);)r+=this[t+i]*s;return r},c.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||L(t,e,this.length);for(var r=this[t+--e],s=1;e>0&&(s*=256);)r+=this[t+--e]*s;return r},c.prototype.readUInt8=function(t,e){return e||L(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||L(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||L(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||L(t,e,this.length);for(var r=this[t],s=1,i=0;++i<e&&(s*=256);)r+=this[t+i]*s;return r>=(s*=128)&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||L(t,e,this.length);for(var r=e,s=1,i=this[t+--r];r>0&&(s*=256);)i+=this[t+--r]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*e)),i},c.prototype.readInt8=function(t,e){return e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||L(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){e||L(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||L(t,4,this.length),s.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||L(t,4,this.length),s.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||L(t,8,this.length),s.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||L(t,8,this.length),s.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||j(this,t,e,n,Math.pow(2,8*n)-1,0);var s=1,i=0;for(this[e]=255&t;++i<n&&(s*=256);)this[e+i]=t/s&255;return e+n},c.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||j(this,t,e,n,Math.pow(2,8*n)-1,0);var s=n-1,i=1;for(this[e+s]=255&t;--s>=0&&(i*=256);)this[e+s]=t/i&255;return e+n},c.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):R(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):R(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var s=Math.pow(2,8*n-1);j(this,t,e,n,s-1,-s)}var i=0,o=1,a=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+n},c.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var s=Math.pow(2,8*n-1);j(this,t,e,n,s-1,-s)}var i=n-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):R(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):R(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,n){return D(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return D(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var s,i=r-n;if(this===t&&n<e&&e<r)for(s=i-1;s>=0;--s)t[s+e]=this[s+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(s=0;s<i;++s)t[s+e]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+i),e);return i},c.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var s=t.charCodeAt(0);s<256&&(t=s)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{var o=c.isBuffer(t)?t:H(new c(t,r).toString()),a=o.length;for(i=0;i<n-e;++i)this[i+e]=o[i%a]}return this};var N=/[^+\/0-9A-Za-z-_]/g;function B(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,e){var n;e=e||1/0;for(var r=t.length,s=null,i=[],o=0;o<r;++o){if((n=t.charCodeAt(o))>55295&&n<57344){if(!s){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&i.push(239,191,189);continue}s=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),s=n;continue}n=65536+(s-55296<<10|n-56320)}else s&&(e-=3)>-1&&i.push(239,191,189);if(s=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function W(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function q(t,e,n,r){for(var s=0;s<r&&!(s+n>=e.length||s>=t.length);++s)e[s+n]=t[s];return s}}).call(this,n(20))},function(t,e,n){"use strict";
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let n=0;n<t.length;n++)t[n]=(0,e.byteSwap)(t[n])},e.bytesToHex=function(t){(0,s.bytes)(t);let e="";for(let n=0;n<t.length;n++)e+=i[t[n]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,s=0;e<n;e++,s+=2){const n=d(t.charCodeAt(s)),i=d(t.charCodeAt(s+1));if(void 0===n||void 0===i){const e=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+s)}r[e]=16*n+i}return r},e.asyncLoop=async function(t,n,r){let s=Date.now();for(let i=0;i<t;i++){r(i);const t=Date.now()-s;t>=0&&t<n||(await(0,e.nextTick)(),s+=t)}},e.utf8ToBytes=f,e.toBytes=p,e.concatBytes=function(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];(0,s.bytes)(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const s=t[e];n.set(s,r),r+=s.length}return n},e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==g.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(p(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(p(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(p(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(t));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return r.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const r=n(26),s=n(14);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<<e|t>>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t);const i=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));const o=48,a=57,c=65,u=70,l=97,h=102;function d(t){return t>=o&&t<=a?t-o:t>=c&&t<=u?t-(c-10):t>=l&&t<=h?t-(l-10):void 0}function f(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function p(t){return"string"==typeof t&&(t=f(t)),(0,s.bytes)(t),t}e.nextTick=async()=>{};e.Hash=class{clone(){return this._cloneInto()}};const g={}.toString},function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return i}));var r=n(2);function s(t,e="Unspecified error message."){if(t&&Number.isInteger(t)){const e=t.toString();if(c(r.a,e))return r.a[e].message;if(o(t))return"Unspecified server error."}return e}function i(t,{shouldIncludeStack:e=!1}={}){const n={};if(t&&"object"==typeof t&&!Array.isArray(t)&&c(t,"code")&&function(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!r.a[e]||!!o(t)}(t.code)){const e=t;n.code=e.code,e.message&&"string"==typeof e.message?(n.message=e.message,c(e,"data")&&(n.data=e.data)):(n.message=s(n.code),n.data={originalError:a(t)})}else n.code=r.b.rpc.internal,n.message=u(t,"message")?t.message:"Unspecified error message.",n.data={originalError:a(t)};return e&&(n.stack=u(t,"stack")?t.stack:void 0),n}function o(t){return t>=-32099&&t<=-32e3}function a(t){return t&&"object"==typeof t&&!Array.isArray(t)?Object.assign({},t):t}function c(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function u(t,e){return"object"==typeof t&&null!==t&&e in t&&"string"==typeof t[e]}},function(t,e,n){(function(e){const r=n(16),s=n(27),i={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},o={encodeData(t,n,i,o=!0){const a=["bytes32"],c=[this.hashType(t,i)];if(o){const u=(t,n,a)=>{if(void 0!==i[n])return["bytes32",null==a?"0x0000000000000000000000000000000000000000000000000000000000000000":r.keccak(this.encodeData(n,a,i,o))];if(void 0===a)throw new Error(`missing value for field ${t} of type ${n}`);if("bytes"===n)return["bytes32",r.keccak(a)];if("string"===n)return"string"==typeof a&&(a=e.from(a,"utf8")),["bytes32",r.keccak(a)];if(n.lastIndexOf("]")===n.length-1){const e=n.slice(0,n.lastIndexOf("[")),i=a.map(n=>u(t,e,n));return["bytes32",r.keccak(s.rawEncode(i.map(([t])=>t),i.map(([,t])=>t)))]}return[n,a]};for(const e of i[t]){const[t,r]=u(e.name,e.type,n[e.name]);a.push(t),c.push(r)}}else for(const s of i[t]){let t=n[s.name];if(void 0!==t)if("bytes"===s.type)a.push("bytes32"),t=r.keccak(t),c.push(t);else if("string"===s.type)a.push("bytes32"),"string"==typeof t&&(t=e.from(t,"utf8")),t=r.keccak(t),c.push(t);else if(void 0!==i[s.type])a.push("bytes32"),t=r.keccak(this.encodeData(s.type,t,i,o)),c.push(t);else{if(s.type.lastIndexOf("]")===s.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");a.push(s.type),c.push(t)}}return s.rawEncode(a,c)},encodeType(t,e){let n="",r=this.findTypeDependencies(t,e).filter(e=>e!==t);r=[t].concat(r.sort());for(const t of r){if(!e[t])throw new Error("No type definition specified: "+t);n+=t+"("+e[t].map(({name:t,type:e})=>e+" "+t).join(",")+")"}return n},findTypeDependencies(t,e,n=[]){if(t=t.match(/^\w*/)[0],n.includes(t)||void 0===e[t])return n;n.push(t);for(const r of e[t])for(const t of this.findTypeDependencies(r.type,e,n))!n.includes(t)&&n.push(t);return n},hashStruct(t,e,n,s=!0){return r.keccak(this.encodeData(t,e,n,s))},hashType(t,e){return r.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const n in i.properties)t[n]&&(e[n]=t[n]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,n=!0){const s=this.sanitizeData(t),i=[e.from("1901","hex")];return i.push(this.hashStruct("EIP712Domain",s.domain,s.types,n)),"EIP712Domain"!==s.primaryType&&i.push(this.hashStruct(s.primaryType,s.message,s.types,n)),r.keccak(e.concat(i))}};t.exports={TYPED_MESSAGE_SCHEMA:i,TypedDataUtils:o,hashForSignTypedDataLegacy:function(t){return function(t){const e=new Error("Expect argument to be non-empty array");if("object"!=typeof t||!t.length)throw e;const n=t.map((function(t){return"bytes"===t.type?r.toBuffer(t.value):t.value})),i=t.map((function(t){return t.type})),o=t.map((function(t){if(!t.name)throw e;return t.type+" "+t.name}));return s.soliditySHA3(["bytes32","bytes32"],[s.soliditySHA3(new Array(t.length).fill("string"),o),s.soliditySHA3(i,n)])}(t.data)},hashForSignTypedData_v3:function(t){return o.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return o.hash(t.data)}}}).call(this,n(10).Buffer)},function(t,e,n){"use strict";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, not "+t)}function s(t){if("boolean"!=typeof t)throw new Error("boolean expected, not "+t)}function i(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function a(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function c(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function u(t,e){o(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}Object.defineProperty(e,"__esModule",{value:!0}),e.isBytes=i,e.number=r,e.bool=s,e.bytes=o,e.hash=a,e.exists=c,e.output=u;const l={number:r,bool:s,bytes:o,hash:a,exists:c,output:u};e.default=l},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return f}));var r=n(13),s=n.n(r),i=n(8),o=n(3),a=n(19),c=n(9),u=n(1),l=n(5),h=n(0),d=n(7);class f{constructor(t){this._relay=null,this._addresses=[],this.metadata=t.metadata,this._storage=new l.a("walletlink",c.c),this.callback=t.callback||null;const e=this._storage.getItem(i.b);if(e){const t=e.split(" ");""!==t[0]&&(this._addresses=t.map(t=>Object(h.c)(t)))}this.initializeRelay()}getSession(){const t=this.initializeRelay(),{id:e,secret:n}=t.getWalletLinkSession();return{id:e,secret:n}}async handshake(){await this._eth_requestAccounts()}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var t;return null!==(t=this._storage.getItem("DefaultJsonRpcUrl"))&&void 0!==t?t:void 0}set jsonRpcUrl(t){this._storage.setItem("DefaultJsonRpcUrl",t)}updateProviderInfo(t,e){var n;this.jsonRpcUrl=t;const r=this.getChainId();this._storage.setItem("DefaultChainId",e.toString(10));Object(h.f)(e)!==r&&(null===(n=this.callback)||void 0===n||n.call(this,"chainChanged",Object(h.j)(e)))}async watchAsset(t){const e=Array.isArray(t)?t[0]:t;if(!e.type)throw u.a.rpc.invalidParams("Type is required");if("ERC20"!==(null==e?void 0:e.type))throw u.a.rpc.invalidParams(`Asset of type '${e.type}' is not supported`);if(!(null==e?void 0:e.options))throw u.a.rpc.invalidParams("Options are required");if(!(null==e?void 0:e.options.address))throw u.a.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:r,symbol:s,image:i,decimals:a}=e.options,c=this.initializeRelay(),l=await c.watchAsset(e.type,r,s,a,i,null==n?void 0:n.toString());return!Object(o.a)(l)&&!!l.result}async addEthereumChain(t){var e,n;const r=t[0];if(0===(null===(e=r.rpcUrls)||void 0===e?void 0:e.length))throw u.a.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!r.chainName||""===r.chainName.trim())throw u.a.rpc.invalidParams("chainName is a required field");if(!r.nativeCurrency)throw u.a.rpc.invalidParams("nativeCurrency is a required field");const s=Number.parseInt(r.chainId,16);if(s===this.getChainId())return!1;const i=this.initializeRelay(),{rpcUrls:a=[],blockExplorerUrls:c=[],chainName:l,iconUrls:h=[],nativeCurrency:d}=r,f=await i.addEthereumChain(s.toString(),a,h,c,l,d);if(Object(o.a)(f))return!1;if(!0===(null===(n=f.result)||void 0===n?void 0:n.isApproved))return this.updateProviderInfo(a[0],s),null;throw u.a.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(t){const e=t[0],n=Number.parseInt(e.chainId,16),r=this.initializeRelay(),s=await r.switchEthereumChain(n.toString(10),this.selectedAddress||void 0);if(Object(o.a)(s))throw s;const i=s.result;return i.isApproved&&i.rpcUrl.length>0&&this.updateProviderInfo(i.rpcUrl,n),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(t,e){var n;if(!Array.isArray(t))throw new Error("addresses is not an array");const r=t.map(t=>Object(h.c)(t));JSON.stringify(r)!==JSON.stringify(this._addresses)&&(this._addresses=r,null===(n=this.callback)||void 0===n||n.call(this,"accountsChanged",r),this._storage.setItem(i.b,r.join(" ")))}async request(t){const e=t.params||[];switch(t.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return Object(h.j)(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(t);case"personal_sign":return this.personalSign(t);case"eth_signTransaction":return this._eth_signTransaction(e);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(e);case"eth_sendTransaction":return this._eth_sendTransaction(e);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(t);case"wallet_addEthereumChain":return this.addEthereumChain(e);case"wallet_switchEthereumChain":return this.switchEthereumChain(e);case"wallet_watchAsset":return this.watchAsset(e);default:if(!this.jsonRpcUrl)throw u.a.rpc.internal("No RPC URL set for chain");return Object(d.b)(t,this.jsonRpcUrl)}}_ensureKnownAddress(t){const e=Object(h.c)(t);if(!this._addresses.map(t=>Object(h.c)(t)).includes(e))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const n=e.from?Object(h.c)(e.from):this.selectedAddress;if(!n)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(n);return{fromAddress:n,toAddress:e.to?Object(h.c)(e.to):null,weiValue:null!=e.value?Object(h.d)(e.value):BigInt(0),data:e.data?Object(h.e)(e.data):t.alloc(0),nonce:null!=e.nonce?Object(h.f)(e.nonce):null,gasPriceInWei:null!=e.gasPrice?Object(h.d)(e.gasPrice):null,maxFeePerGas:null!=e.maxFeePerGas?Object(h.d)(e.maxFeePerGas):null,maxPriorityFeePerGas:null!=e.maxPriorityFeePerGas?Object(h.d)(e.maxPriorityFeePerGas):null,gasLimit:null!=e.gas?Object(h.d)(e.gas):null,chainId:e.chainId?Object(h.f)(e.chainId):this.getChainId()}}async ecRecover(t){const{method:e,params:n}=t;if(!Array.isArray(n))throw u.a.rpc.invalidParams();const r=this.initializeRelay(),s=await r.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:Object(h.b)(n[0]),signature:Object(h.b)(n[1]),addPrefix:"personal_ecRecover"===e}});if(Object(o.a)(s))throw s;return s.result}getChainId(){var t;return Number.parseInt(null!==(t=this._storage.getItem("DefaultChainId"))&&void 0!==t?t:"1",10)}async _eth_requestAccounts(){var t,e;if(this._addresses.length>0)return null===(t=this.callback)||void 0===t||t.call(this,"connect",{chainId:Object(h.j)(this.getChainId())}),this._addresses;const n=this.initializeRelay(),r=await n.requestEthereumAccounts();if(Object(o.a)(r))throw r;if(!r.result)throw new Error("accounts received is empty");return this._setAddresses(r.result),null===(e=this.callback)||void 0===e||e.call(this,"connect",{chainId:Object(h.j)(this.getChainId())}),this._addresses}async personalSign({params:t}){if(!Array.isArray(t))throw u.a.rpc.invalidParams();const e=t[1],n=t[0];this._ensureKnownAddress(e);const r=this.initializeRelay(),s=await r.sendRequest({method:"signEthereumMessage",params:{address:Object(h.c)(e),message:Object(h.b)(n),addPrefix:!0,typedDataJson:null}});if(Object(o.a)(s))throw s;return s.result}async _eth_signTransaction(t){const e=this._prepareTransactionParams(t[0]||{}),n=this.initializeRelay(),r=await n.signEthereumTransaction(e);if(Object(o.a)(r))throw r;return r.result}async _eth_sendRawTransaction(t){const e=Object(h.e)(t[0]),n=this.initializeRelay(),r=await n.submitEthereumTransaction(e,this.getChainId());if(Object(o.a)(r))throw r;return r.result}async _eth_sendTransaction(t){const e=this._prepareTransactionParams(t[0]||{}),n=this.initializeRelay(),r=await n.signAndSubmitEthereumTransaction(e);if(Object(o.a)(r))throw r;return r.result}async signTypedData(t){const{method:e,params:n}=t;if(!Array.isArray(n))throw u.a.rpc.invalidParams();const r=n["eth_signTypedData_v1"===e?1:0],i=n["eth_signTypedData_v1"===e?0:1];this._ensureKnownAddress(r);const a=this.initializeRelay(),c=await a.sendRequest({method:"signEthereumMessage",params:{address:Object(h.c)(r),message:(t=>{const n={eth_signTypedData_v1:s.a.hashForSignTypedDataLegacy,eth_signTypedData_v3:s.a.hashForSignTypedData_v3,eth_signTypedData_v4:s.a.hashForSignTypedData_v4,eth_signTypedData:s.a.hashForSignTypedData_v4};return Object(h.i)(n[e]({data:Object(h.g)(t)}),!0)})(i),typedDataJson:JSON.stringify(i,null,2),addPrefix:!1}});if(Object(o.a)(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new a.a({linkAPIUrl:c.c,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}}).call(this,n(10).Buffer)},function(t,e,n){(function(e){const{keccak_256:r}=n(24);function s(t){return e.allocUnsafe(t).fill(0)}function i(t,n){let r=t.toString(16);r.length%2!=0&&(r="0"+r);const s=r.match(/.{1,2}/g).map(t=>parseInt(t,16));for(;s.length<n;)s.unshift(0);return e.from(s)}function o(t,e,n){const r=s(e);return t=a(t),n?t.length<e?(t.copy(r),r):t.slice(0,e):t.length<e?(t.copy(r,e-t.length),r):t.slice(-e)}function a(t){if(!e.isBuffer(t))if(Array.isArray(t))t=e.from(t);else if("string"==typeof t)t=c(t)?e.from((n=u(t)).length%2?"0"+n:n,"hex"):e.from(t);else if("number"==typeof t)t=intToBuffer(t);else if(null==t)t=e.allocUnsafe(0);else if("bigint"==typeof t)t=i(t);else{if(!t.toArray)throw new Error("invalid type");t=e.from(t.toArray())}var n;return t}function c(t){return"string"==typeof t&&t.match(/^0x[0-9A-Fa-f]*$/)}function u(t){return"string"==typeof t&&t.startsWith("0x")?t.slice(2):t}t.exports={zeros:s,setLength:o,setLengthRight:function(t,e){return o(t,e,!0)},isHexString:c,stripHexPrefix:u,toBuffer:a,bufferToHex:function(t){return"0x"+(t=a(t)).toString("hex")},keccak:function(t,n){if(t=a(t),n||(n=256),256!==n)throw new Error("unsupported");return e.from(r(new Uint8Array(t)))},bitLengthFromBigInt:function(t){return t.toString(2).length},bufferBEFromBigInt:i,twosFromBigInt:function(t,e){let n;if(t<0n){n=(~t&(1n<<BigInt(e))-1n)+1n}else n=t;return n&=(1n<<BigInt(e))-1n,n}}}).call(this,n(10).Buffer)},function(t,e,n){"use strict";var r=Object.prototype.hasOwnProperty,s="~";function i(){}function o(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function a(t,e,n,r,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,r||t,i),c=s?s+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function c(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function u(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Ob