@metamask/webpack-plugin-example-snap
Version:
MetaMask example snap demonstrating how to use the Webpack plugin to bundle a snap
2 lines • 15.5 kB
JavaScript
(()=>{var e={836:e=>{e.exports=s,s.default=s,s.stable=d,s.stableStringify=d;var t="[...]",r="[Circular]",n=[],o=[];function i(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function s(e,t,r,s){var a;void 0===s&&(s=i()),c(e,"",0,[],void 0,0,s);try{a=0===o.length?JSON.stringify(e,t,r):JSON.stringify(e,l(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function a(e,t,r,i){var s=Object.getOwnPropertyDescriptor(i,r);void 0!==s.get?s.configurable?(Object.defineProperty(i,r,{value:e}),n.push([i,r,t,s])):o.push([t,r,e]):(i[r]=e,n.push([i,r,t]))}function c(e,n,o,i,s,u,d){var f;if(u+=1,"object"==typeof e&&null!==e){for(f=0;f<i.length;f++)if(i[f]===e)return void a(r,e,n,s);if(void 0!==d.depthLimit&&u>d.depthLimit)return void a(t,e,n,s);if(void 0!==d.edgesLimit&&o+1>d.edgesLimit)return void a(t,e,n,s);if(i.push(e),Array.isArray(e))for(f=0;f<e.length;f++)c(e[f],f,f,i,e,u,d);else{var l=Object.keys(e);for(f=0;f<l.length;f++){var p=l[f];c(e[p],p,f,i,e,u,d)}}i.pop()}}function u(e,t){return e<t?-1:e>t?1:0}function d(e,t,r,s){void 0===s&&(s=i());var a,c=f(e,"",0,[],void 0,0,s)||e;try{a=0===o.length?JSON.stringify(c,t,r):JSON.stringify(c,l(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function f(e,o,i,s,c,d,l){var p;if(d+=1,"object"==typeof e&&null!==e){for(p=0;p<s.length;p++)if(s[p]===e)return void a(r,e,o,c);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==l.depthLimit&&d>l.depthLimit)return void a(t,e,o,c);if(void 0!==l.edgesLimit&&i+1>l.edgesLimit)return void a(t,e,o,c);if(s.push(e),Array.isArray(e))for(p=0;p<e.length;p++)f(e[p],p,p,s,e,d,l);else{var h={},m=Object.keys(e).sort(u);for(p=0;p<m.length;p++){var y=m[p];f(e[y],y,p,s,e,d,l),h[y]=e[y]}if(void 0===c)return h;n.push([c,o,e]),c[o]=h}s.pop()}}function l(e){return e=void 0!==e?e:function(e,t){return t},function(t,r){if(o.length>0)for(var n=0;n<o.length;n++){var i=o[n];if(i[1]===t&&i[0]===r){r=i[2],o.splice(n,1);break}}return e.call(this,t,r)}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";function e(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}r.r(n),r.d(n,{onRpcRequest:()=>ke});const t=(e,t)=>Object.hasOwnProperty.call(e,t);var o;!function(e){e[e.Null=4]="Null",e[e.Comma=1]="Comma",e[e.Wrapper=1]="Wrapper",e[e.True=4]="True",e[e.False=5]="False",e[e.Quote=1]="Quote",e[e.Colon=1]="Colon",e[e.Date=24]="Date"}(o=o||(o={}));var i=r(836);class s extends TypeError{constructor(e,t){let r;const{message:n,explanation:o,...i}=e,{path:s}=e,a=0===s.length?n:`At path: ${s.join(".")} -- ${n}`;super(o??a),null!=o&&(this.cause=a),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function a(e){return"object"==typeof e&&null!==e}function c(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function u(e,t,r,n){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:o,branch:i}=t,{type:s}=r,{refinement:a,message:u=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${c(n)}\``}=e;return{value:n,type:s,refinement:a,key:o[o.length-1],path:o,branch:i,...e,message:u}}function*d(e,t,r,n){(function(e){return a(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const o of e){const e=u(o,t,r,n);e&&(yield e)}}function*f(e,t,r={}){const{path:n=[],branch:o=[e],coerce:i=!1,mask:s=!1}=r,c={path:n,branch:o};if(i&&(e=t.coercer(e,c),s&&"type"!==t.type&&a(t.schema)&&a(e)&&!Array.isArray(e)))for(const r in e)void 0===t.schema[r]&&delete e[r];let u="valid";for(const n of t.validator(e,c))n.explanation=r.message,u="not_valid",yield[n,void 0];for(let[d,l,p]of t.entries(e,c)){const t=f(l,p,{path:void 0===d?n:[...n,d],branch:void 0===d?o:[...o,l],coerce:i,mask:s,message:r.message});for(const r of t)r[0]?(u=null===r[0].refinement||void 0===r[0].refinement?"not_valid":"not_refined",yield[r[0],void 0]):i&&(l=r[1],void 0===d?e=l:e instanceof Map?e.set(d,l):e instanceof Set?e.add(l):a(e)&&(void 0!==l||d in e)&&(e[d]=l))}if("not_valid"!==u)for(const n of t.refiner(e,c))n.explanation=r.message,u="not_refined",yield[n,void 0];"valid"===u&&(yield[void 0,e])}class l{constructor(e){const{type:t,schema:r,validator:n,refiner:o,coercer:i=e=>e,entries:s=function*(){}}=e;this.type=t,this.schema=r,this.entries=s,this.coercer=i,this.validator=n?(e,t)=>d(n(e,t),t,this,e):()=>[],this.refiner=o?(e,t)=>d(o(e,t),t,this,e):()=>[]}assert(e,t){return function(e,t,r){const n=m(e,t,{message:r});if(n[0])throw n[0]}(e,this,t)}create(e,t){return p(e,this,t)}is(e){return h(e,this)}mask(e,t){return function(e,t,r){const n=m(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}(e,this,t)}validate(e,t={}){return m(e,this,t)}}function p(e,t,r){const n=m(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function h(e,t){return!m(e,t)[0]}function m(e,t,r={}){const n=f(e,t,r),o=function(e){const{done:t,value:r}=e.next();return t?void 0:r}(n);if(o[0]){return[new s(o[0],(function*(){for(const e of n)e[0]&&(yield e[0])})),void 0]}return[void 0,o[1]]}function y(e,t){return new l({type:e,schema:null,validator:t})}function v(){return y("never",(()=>!1))}function g(e){const t=e?Object.keys(e):[],r=v();return new l({type:"object",schema:e??null,*entries(n){if(e&&a(n)){const o=new Set(Object.keys(n));for(const r of t)o.delete(r),yield[r,n[r],e[r]];for(const e of o)yield[e,n[e],r]}},validator:e=>a(e)||`Expected an object, but received: ${c(e)}`,coercer:e=>a(e)?{...e}:e})}function b(e){return new l({...e,validator:(t,r)=>void 0===t||e.validator(t,r),refiner:(t,r)=>void 0===t||e.refiner(t,r)})}function w(){return y("string",(e=>"string"==typeof e||`Expected a string, but received: ${c(e)}`))}function O(e){const t=e.map((e=>e.type)).join(" | ");return new l({type:"union",schema:null,coercer(t){for(const r of e){const[e,n]=r.validate(t,{coerce:!0});if(!e)return n}return t},validator(r,n){const o=[];for(const t of e){const[...e]=f(r,t,n),[i]=e;if(!i?.[0])return[];for(const[t]of e)t&&o.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${c(r)}`,...o]}})}function j(e,t,r){return new l({...e,coercer:(n,o)=>h(n,t)?e.coercer(r(n,o),o):e.coercer(n,o)})}function N(e,t,r){return new l({...e,*refiner(n,o){yield*e.refiner(n,o);const i=d(r(n,o),o,e,n);for(const e of i)yield{...e,refinement:t}}})}const E=e=>g(e);function S({path:e,branch:r}){const n=e[e.length-1];return t(r[r.length-2],n)}function P(e){return new l({...e,type:`optional ${e.type}`,validator:(t,r)=>!S(r)||e.validator(t,r),refiner:(t,r)=>!S(r)||e.refiner(t,r)})}function x(e){if(null===e||"boolean"==typeof e||"string"==typeof e)return!0;if("number"==typeof e&&Number.isFinite(e))return!0;if("object"==typeof e){let t=!0;if(Array.isArray(e)){for(let r=0;r<e.length;r++)if(!x(e[r])){t=!1;break}return t}const r=Object.entries(e);for(let e=0;e<r.length;e++)if("string"!=typeof r[e][0]||!x(r[e][1])){t=!1;break}return t}return!1}const A=y("JSON",(e=>x(e))),k=j(A,N(y("any",(()=>!0)),"JSON",(e=>h(e,A))),(e=>JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t})))));function I(e){try{return function(e){p(e,k)}(e),!0}catch{return!1}}const J=function(e){const t=c(e),r=typeof e;return new l({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?e:null,validator:r=>r===e||`Expected the literal \`${t}\`, but received: ${c(r)}`})}("2.0"),R=(_=O([y("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${c(e)}`)),w()]),new l({..._,validator:(e,t)=>null===e||_.validator(e,t),refiner:(e,t)=>null===e||_.refiner(e,t)}));var _;const T=E({code:y("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${c(e)}`)),message:w(),data:P(k),stack:P(w())}),$=O([(C=w(),q=k,new l({type:"record",schema:null,*entries(e){if(a(e))for(const t in e){const r=e[t];yield[t,t,C],yield[t,r,q]}},validator:e=>a(e)||`Expected an object, but received: ${c(e)}`})),(M=k,new l({type:"array",schema:M,*entries(e){if(M&&Array.isArray(e))for(const[t,r]of e.entries())yield[t,r,M]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${c(e)}`}))]);var M,C,q;E({id:R,jsonrpc:J,method:w(),params:P($)}),E({jsonrpc:J,method:w(),params:P($)});g({id:R,jsonrpc:J,result:b(y("unknown",(()=>!0))),error:b(T)});const z=E({id:R,jsonrpc:J,result:k}),L=E({id:R,jsonrpc:J,error:T});O([z,L]);const F={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},W={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},D={"-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."}},U=F.internal,G=(Q(U),"Unspecified server error.");function Q(e,r="Unspecified error message. This is a bug, please report it."){if(function(e){return Number.isInteger(e)}(e)){const r=e.toString();if(t(D,r))return D[r].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return G}return r}function X(t){return Array.isArray(t)?t.map((t=>I(t)?t:e(t)?B(t):null)):e(t)?B(t):I(t)?t:null}function B(e){return Object.getOwnPropertyNames(e).reduce(((t,r)=>{const n=e[r];return I(n)&&(t[r]=n),t}),{})}const H=(K=i,K?.__esModule?K.default:K);var K;class V extends Error{constructor(r,n,o){if(!Number.isInteger(r))throw new Error('"code" must be an integer.');if(!n||"string"!=typeof n)throw new Error('"message" must be a non-empty string.');!function(r){return e(r)&&t(r,"cause")&&e(r.cause)}(o)?super(n):(super(n,{cause:o.cause}),t(this,"cause")||Object.assign(this,{cause:o.cause})),void 0!==o&&(this.data=o),this.code=r}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data,function(e){if("object"!=typeof e||null===e)return!1;try{let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}catch(e){return!1}}(this.data)&&(e.data.cause=X(this.data.cause))),this.stack&&(e.stack=this.stack),e}toString(){return H(this.serialize(),Z,2)}}class Y extends V{constructor(e,t,r){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,r)}}function Z(e,t){if("[Circular]"!==t)return t}const ee=e=>ye(F.parse,e),te=e=>ye(F.invalidRequest,e),re=e=>ye(F.invalidParams,e),ne=e=>ye(F.methodNotFound,e),oe=e=>ye(F.internal,e),ie=e=>ye(F.invalidInput,e),se=e=>ye(F.resourceNotFound,e),ae=e=>ye(F.resourceUnavailable,e),ce=e=>ye(F.transactionRejected,e),ue=e=>ye(F.methodNotSupported,e),de=e=>ye(F.limitExceeded,e),fe=e=>ve(W.userRejectedRequest,e),le=e=>ve(W.unauthorized,e),pe=e=>ve(W.unsupportedMethod,e),he=e=>ve(W.disconnected,e),me=e=>ve(W.chainDisconnected,e);function ye(e,t){const[r,n]=ge(t);return new V(e,r??Q(e),n)}function ve(e,t){const[r,n]=ge(t);return new Y(e,r??Q(e),n)}function ge(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:r}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t??void 0,r]}}return[]}function be(r){return e(r)&&t(r,"data")&&"object"==typeof r.data&&null!==r.data&&I(r.data)&&!Array.isArray(r.data)?r.data:{}}var we,Oe,je,Ne,Ee=function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},Se=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};class Pe extends Error{constructor(r,n={}){const o=function(r){return e(r)&&t(r,"message")&&"string"==typeof r.message?r.message:String(r)}(r);super(o),we.set(this,void 0),Oe.set(this,void 0),je.set(this,void 0),Ne.set(this,void 0),Ee(this,Oe,o,"f"),Ee(this,we,function(r){return e(r)&&t(r,"code")&&"number"==typeof r.code&&Number.isInteger(r.code)?r.code:-32603}(r),"f");const i={...be(r),...n};Object.keys(i).length>0&&Ee(this,je,i,"f"),Ee(this,Ne,super.stack,"f")}get name(){return"SnapError"}get code(){return Se(this,we,"f")}get message(){return Se(this,Oe,"f")}get data(){return Se(this,je,"f")}get stack(){return Se(this,Ne,"f")}toJSON(){return{code:-31002,message:"Snap Error",data:{cause:{code:this.code,message:this.message,stack:this.stack,...this.data?{data:this.data}:{}}}}}serialize(){return this.toJSON()}}function xe(e){return class extends Pe{constructor(t,r){if("object"==typeof t){const r=e();return void super({code:r.code,message:r.message,data:t})}const n=e(t);super({code:n.code,message:n.message,data:r})}}}we=new WeakMap,Oe=new WeakMap,je=new WeakMap,Ne=new WeakMap;xe(oe),xe(ie),xe(re),xe(te),xe(de);const Ae=xe(ne),ke=(xe(ue),xe(ee),xe(se),xe(ae),xe(ce),xe(me),xe(he),xe(le),xe(pe),xe(fe),async({request:e})=>{if("hello"===e.method)return"Hello from Webpack!";throw new Ae({method:e.method})})})();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
//# sourceMappingURL=bundle.js.map