@metamask/interactive-ui-example-snap 2.2.0 → 2.2.1

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/CHANGELOG.md CHANGED
@@ -6,9 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.2.1]
10
+ ### Fixed
11
+ - Bump MetaMask dependencies
12
+
9
13
  ## [2.2.0]
10
14
  ### Added
11
- - Add `RadioButton` to interactive UI example ([#2592](https://github.com/MetaMask/snaps-skunkworks.git/pull/2592))
15
+ - Add `RadioGroup` to interactive UI example ([#2592](https://github.com/MetaMask/snaps/pull/2592))
12
16
 
13
17
  ## [2.1.0]
14
18
  ### Added
@@ -31,7 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
31
35
  ### Added
32
36
  - Add interactive UI example Snap ([#2171](https://github.com/MetaMask/snaps/pull/2171))
33
37
 
34
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.2.0...HEAD
38
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.2.1...HEAD
39
+ [2.2.1]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.2.0...@metamask/interactive-ui-example-snap@2.2.1
35
40
  [2.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.1.0...@metamask/interactive-ui-example-snap@2.2.0
36
41
  [2.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.0.0...@metamask/interactive-ui-example-snap@2.1.0
37
42
  [2.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@1.0.2...@metamask/interactive-ui-example-snap@2.0.0
package/dist/bundle.js CHANGED
@@ -1 +1 @@
1
- (()=>{var e={12:e=>{e.exports=o,o.default=o,o.stable=d,o.stableStringify=d;var t="[...]",n="[Circular]",r=[],a=[];function i(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function o(e,t,n,o){var s;void 0===o&&(o=i()),c(e,"",0,[],void 0,0,o);try{s=0===a.length?JSON.stringify(e,t,n):JSON.stringify(e,p(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==r.length;){var u=r.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return s}function s(e,t,n,i){var o=Object.getOwnPropertyDescriptor(i,n);void 0!==o.get?o.configurable?(Object.defineProperty(i,n,{value:e}),r.push([i,n,t,o])):a.push([t,n,e]):(i[n]=e,r.push([i,n,t]))}function c(e,r,a,i,o,u,d){var l;if(u+=1,"object"==typeof e&&null!==e){for(l=0;l<i.length;l++)if(i[l]===e)return void s(n,e,r,o);if(void 0!==d.depthLimit&&u>d.depthLimit)return void s(t,e,r,o);if(void 0!==d.edgesLimit&&a+1>d.edgesLimit)return void s(t,e,r,o);if(i.push(e),Array.isArray(e))for(l=0;l<e.length;l++)c(e[l],l,l,i,e,u,d);else{var p=Object.keys(e);for(l=0;l<p.length;l++){var f=p[l];c(e[f],f,l,i,e,u,d)}}i.pop()}}function u(e,t){return e<t?-1:e>t?1:0}function d(e,t,n,o){void 0===o&&(o=i());var s,c=l(e,"",0,[],void 0,0,o)||e;try{s=0===a.length?JSON.stringify(c,t,n):JSON.stringify(c,p(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==r.length;){var u=r.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return s}function l(e,a,i,o,c,d,p){var f;if(d+=1,"object"==typeof e&&null!==e){for(f=0;f<o.length;f++)if(o[f]===e)return void s(n,e,a,c);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==p.depthLimit&&d>p.depthLimit)return void s(t,e,a,c);if(void 0!==p.edgesLimit&&i+1>p.edgesLimit)return void s(t,e,a,c);if(o.push(e),Array.isArray(e))for(f=0;f<e.length;f++)l(e[f],f,f,o,e,d,p);else{var m={},h=Object.keys(e).sort(u);for(f=0;f<h.length;f++){var v=h[f];l(e[v],v,f,o,e,d,p),m[v]=e[v]}if(void 0===c)return m;r.push([c,a,e]),c[a]=m}o.pop()}}function p(e){return e=void 0!==e?e:function(e,t){return t},function(t,n){if(a.length>0)for(var r=0;r<a.length;r++){var i=a[r];if(i[1]===t&&i[0]===n){n=i[2],a.splice(r,1);break}}return e.call(this,t,n)}}}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";function e(e,t,n){if("string"==typeof e)throw new Error(`An HTML element ("${String(e)}") was used in a Snap component, which is not supported by Snaps UI. Please use one of the supported Snap components.`);if(!e)throw new Error("A JSX fragment was used in a Snap component, which is not supported by Snaps UI. Please use one of the supported Snap components.");return e({...t,key:n})}function t(t,n,r){return e(t,n,r)}function a(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}n.r(r),n.d(r,{onHomePage:()=>Lr,onRpcRequest:()=>Dr,onTransaction:()=>Gr,onUserInput:()=>Wr});const i=(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={}));function s(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}}class c extends TypeError{constructor(e,t){let n;const{message:r,explanation:a,...i}=e,{path:o}=e,s=0===o.length?r:`At path: ${o.join(".")} -- ${r}`;super(a??s),null!=a&&(this.cause=s),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}}function u(e){return"object"==typeof e&&null!==e}function d(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function l(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:a,branch:i}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:""}, but received: \`${d(r)}\``}=e;return{value:r,type:o,refinement:s,key:a[a.length-1],path:a,branch:i,...e,message:c}}function*p(e,t,n,r){(function(e){return u(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const a of e){const e=l(a,t,n,r);e&&(yield e)}}function*f(e,t,n={}){const{path:r=[],branch:a=[e],coerce:i=!1,mask:o=!1}=n,s={path:r,branch:a};if(i&&(e=t.coercer(e,s),o&&"type"!==t.type&&u(t.schema)&&u(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let c="valid";for(const r of t.validator(e,s))r.explanation=n.message,c="not_valid",yield[r,void 0];for(let[d,l,p]of t.entries(e,s)){const t=f(l,p,{path:void 0===d?r:[...r,d],branch:void 0===d?a:[...a,l],coerce:i,mask:o,message:n.message});for(const n of t)n[0]?(c=null===n[0].refinement||void 0===n[0].refinement?"not_valid":"not_refined",yield[n[0],void 0]):i&&(l=n[1],void 0===d?e=l:e instanceof Map?e.set(d,l):e instanceof Set?e.add(l):u(e)&&(void 0!==l||d in e)&&(e[d]=l))}if("not_valid"!==c)for(const r of t.refiner(e,s))r.explanation=n.message,c="not_refined",yield[r,void 0];"valid"===c&&(yield[void 0,e])}class m{constructor(e){const{type:t,schema:n,validator:r,refiner:a,coercer:i=(e=>e),entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=i,this.validator=r?(e,t)=>p(r(e,t),t,this,e):()=>[],this.refiner=a?(e,t)=>p(a(e,t),t,this,e):()=>[]}assert(e,t){return h(e,this,t)}create(e,t){return v(e,this,t)}is(e){return y(e,this)}mask(e,t){return function(e,t,n){const r=g(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return g(e,this,t)}}function h(e,t,n){const r=g(e,t,{message:n});if(r[0])throw r[0]}function v(e,t,n){const r=g(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function y(e,t){return!g(e,t)[0]}function g(e,t,n={}){const r=f(e,t,n),a=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(r);if(a[0]){return[new c(a[0],(function*(){for(const e of r)e[0]&&(yield e[0])})),void 0]}return[void 0,a[1]]}function b(...e){const t="type"===e[0]?.type,n=e.map((({schema:e})=>e)),r=Object.assign({},...n);return t?function(e){const t=Object.keys(e);return new m({type:"type",schema:e,*entries(n){if(u(n))for(const r of t)yield[r,n[r],e[r]]},validator:e=>u(e)||`Expected an object, but received: ${d(e)}`,coercer:e=>u(e)?{...e}:e})}(r):N(r)}function w(e,t){return new m({type:e,schema:null,validator:t})}function x(e){let t;return new m({type:"lazy",schema:null,*entries(n,r){t??(t=e()),yield*t.entries(n,r)},validator:(n,r)=>(t??(t=e()),t.validator(n,r)),coercer:(n,r)=>(t??(t=e()),t.coercer(n,r)),refiner:(n,r)=>(t??(t=e()),t.refiner(n,r))})}function E(e){return new m({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[n,r]of t.entries())yield[n,r,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${d(e)}`})}function S(){return w("boolean",(e=>"boolean"==typeof e))}function O(e){const t=d(e),n=typeof e;return new m({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||`Expected the literal \`${t}\`, but received: ${d(n)}`})}function k(){return w("never",(()=>!1))}function I(e){return new m({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}function j(){return w("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${d(e)}`))}function N(e){const t=e?Object.keys(e):[],n=k();return new m({type:"object",schema:e??null,*entries(r){if(e&&u(r)){const a=new Set(Object.keys(r));for(const n of t)a.delete(n),yield[n,r[n],e[n]];for(const e of a)yield[e,r[e],n]}},validator:e=>u(e)||`Expected an object, but received: ${d(e)}`,coercer:e=>u(e)?{...e}:e})}function C(e){return new m({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function A(e,t){return new m({type:"record",schema:null,*entries(n){if(u(n))for(const r in n){const a=n[r];yield[r,r,e],yield[r,a,t]}},validator:e=>u(e)||`Expected an object, but received: ${d(e)}`})}function P(){return w("string",(e=>"string"==typeof e||`Expected a string, but received: ${d(e)}`))}function R(e){const t=k();return new m({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(e.length,n.length);for(let a=0;a<r;a++)yield[a,n[a],e[a]||t]}},validator:e=>Array.isArray(e)||`Expected an array, but received: ${d(e)}`})}function $(e){const t=e.map((e=>e.type)).join(" | ");return new m({type:"union",schema:null,coercer(t){for(const n of e){const[e,r]=n.validate(t,{coerce:!0});if(!e)return r}return t},validator(n,r){const a=[];for(const t of e){const[...e]=f(n,t,r),[i]=e;if(!i?.[0])return[];for(const[t]of e)t&&a.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${d(n)}`,...a]}})}function T(){return w("unknown",(()=>!0))}function F(e,t,n){return new m({...e,coercer:(r,a)=>y(r,t)?e.coercer(n(r,a),a):e.coercer(r,a)})}function _(e){return function(e){return function(e){return"object"==typeof e&&null!==e&&"message"in e}(e)&&"string"==typeof e.message?e.message:null==e?"":String(e)}(e).replace(/\.$/u,"")}function J(e,t){return n=e,Boolean("string"==typeof n?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var n}class B extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}}function q(e,t,n="Assertion failed",r=B){try{h(e,t)}catch(e){throw J(r,`${n}: ${_(e)}.`)}}const M=e=>N(e);function U({path:e,branch:t}){const n=e[e.length-1];return i(t[t.length-2],n)}function z(e){return new m({...e,type:`optional ${e.type}`,validator:(t,n)=>!U(n)||e.validator(t,n),refiner:(t,n)=>!U(n)||e.refiner(t,n)})}const D=$([O(null),S(),w("finite number",(e=>y(e,j())&&Number.isFinite(e))),P(),E(x((()=>D))),A(P(),x((()=>D)))]),L=F(D,w("any",(()=>!0)),(e=>(q(e,D),JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t}))))));function G(e){try{return function(e){v(e,L)}(e),!0}catch{return!1}}const W=O("2.0"),V=I($([j(),P()])),H=M({code:w("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${d(e)}`)),message:P(),data:z(L),stack:z(P())}),X=$([A(P(),L),E(L)]);M({id:V,jsonrpc:W,method:P(),params:z(X)}),M({jsonrpc:W,method:P(),params:z(X)});N({id:V,jsonrpc:W,result:C(T()),error:C(H)});const Q=M({id:V,jsonrpc:W,result:L}),Y=M({id:V,jsonrpc:W,error:H});$([Q,Y]);function K(e,t){return Z(e,"pattern",(n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`))}function Z(e,t,n){return new m({...e,*refiner(r,a){yield*e.refiner(r,a);const i=p(n(r,a),a,e,r);for(const e of i)yield{...e,refinement:t}}})}var ee={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},te={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},ne={"-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."}},re=ee.internal,ae="Unspecified error message. This is a bug, please report it.",ie=(oe(re),"Unspecified server error.");function oe(e,t=ae){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(i(ne,t))return ne[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return ie}return t}function se(e){return Array.isArray(e)?e.map((e=>G(e)?e:a(e)?ce(e):null)):a(e)?ce(e):G(e)?e:null}function ce(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return G(r)&&(t[n]=r),t}),{})}var ue=n(12),de=class extends Error{constructor(e,t,n){var r=(...e)=>{super(...e)};if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a non-empty string.');!function(e){return a(e)&&i(e,"cause")&&a(e.cause)}(n)?r(t):(r(t,{cause:n.cause}),i(this,"cause")||Object.assign(this,{cause:n.cause})),void 0!==n&&(this.data=n),this.code=e}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data,s(this.data)&&(e.data.cause=se(this.data.cause))),this.stack&&(e.stack=this.stack),e}toString(){return ue(this.serialize(),pe,2)}},le=class extends de{constructor(e,t,n){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,n)}};function pe(e,t){if("[Circular]"!==t)return t}var fe=e=>Ce(ee.parse,e),me=e=>Ce(ee.invalidRequest,e),he=e=>Ce(ee.invalidParams,e),ve=e=>Ce(ee.methodNotFound,e),ye=e=>Ce(ee.internal,e),ge=e=>Ce(ee.invalidInput,e),be=e=>Ce(ee.resourceNotFound,e),we=e=>Ce(ee.resourceUnavailable,e),xe=e=>Ce(ee.transactionRejected,e),Ee=e=>Ce(ee.methodNotSupported,e),Se=e=>Ce(ee.limitExceeded,e),Oe=e=>Ae(te.userRejectedRequest,e),ke=e=>Ae(te.unauthorized,e),Ie=e=>Ae(te.unsupportedMethod,e),je=e=>Ae(te.disconnected,e),Ne=e=>Ae(te.chainDisconnected,e);function Ce(e,t){const[n,r]=Pe(t);return new de(e,n??oe(e),r)}function Ae(e,t){const[n,r]=Pe(t);return new le(e,n??oe(e),r)}function Pe(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t??void 0,n]}}return[]}K(P(),/^(?:0x)?[0-9a-f]+$/iu),K(P(),/^0x[0-9a-f]+$/iu),K(P(),/^0x[0-9a-f]{40}$/u);const Re=K(P(),/^0x[0-9a-fA-F]{40}$/u);function $e(e){return e.startsWith("0x")||e.startsWith("0X")?e.substring(2):e}var Te,Fe,_e,Je,Be=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},qe=(e,t,n)=>(Be(e,t,"read from private field"),n?n.call(e):t.get(e)),Me=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Ue=(e,t,n,r)=>(Be(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ze=class extends Error{constructor(e,t={}){const n=function(e){if(a(e)&&i(e,"message")&&"string"==typeof e.message)return e.message;return String(e)}(e);super(n),Me(this,Te,void 0),Me(this,Fe,void 0),Me(this,_e,void 0),Me(this,Je,void 0),Ue(this,Fe,n),Ue(this,Te,function(e){if(a(e)&&i(e,"code")&&"number"==typeof e.code&&Number.isInteger(e.code))return e.code;return-32603}(e));const r={...We(e),...t};Object.keys(r).length>0&&Ue(this,_e,r),Ue(this,Je,super.stack)}get name(){return"SnapError"}get code(){return qe(this,Te)}get message(){return qe(this,Fe)}get data(){return qe(this,_e)}get stack(){return qe(this,Je)}toJSON(){return{code:Le,message:Ge,data:{cause:{code:this.code,message:this.message,stack:this.stack,...this.data?{data:this.data}:{}}}}}serialize(){return this.toJSON()}};function De(e){return class extends ze{constructor(t,n){if("object"==typeof t){const n=e();return void super({code:n.code,message:n.message,data:t})}const r=e(t);super({code:r.code,message:r.message,data:n})}}}Te=new WeakMap,Fe=new WeakMap,_e=new WeakMap,Je=new WeakMap;var Le=-31002,Ge="Snap Error";function We(e){return a(e)&&i(e,"data")&&"object"==typeof e.data&&null!==e.data&&G(e.data)&&!Array.isArray(e.data)?e.data:{}}function Ve(e){return w(JSON.stringify(e),O(e).validator)}function He(e){return Ve(e)}function Xe(e){return new m({type:"union",schema:null,*entries(t,n){if(!s(t)||!i(t,"type"))return;const{type:r}=t,a=e.find((({schema:e})=>y(r,e.type)));if(a)for(const e of a.entries(t,n))yield e},validator(t,n){const r=e.map((({schema:e})=>e.type.type));if(!s(t)||!i(t,"type")||"string"!=typeof t.type)return`Expected type to be one of: ${r.join(", ")}, but received: undefined`;const{type:a}=t,o=e.find((({schema:e})=>y(a,e.type)));return o?o.validator(t,n):`Expected type to be one of: ${r.join(", ")}, but received: "${a}"`}})}function Qe(e){return function([e,...t]){const n=$([e,...t]);return new m({...n,schema:[e,...t]})}(e)}function Ye(){return Z(P(),"SVG",(e=>!!e.includes("<svg")||"Value is not a valid SVG."))}De(ye),De(ge),De(he),De(me),De(Se);var Ke=De(ve);De(Ee),De(fe),De(be),De(we),De(xe),De(Ne),De(je),De(ke),De(Ie),De(Oe);function Ze(e,t,n=[]){return(...r)=>{if(1===r.length&&s(r[0])){const n={...r[0],type:e};return q(n,t,`Invalid ${e} component`),n}const a=n.reduce(((e,t,n)=>void 0!==r[n]?{...e,[t]:r[n]}:e),{type:e});return q(a,t,`Invalid ${e} component`),a}}var et,tt,nt,rt,at,it=((et=it||{}).Copyable="copyable",et.Divider="divider",et.Heading="heading",et.Panel="panel",et.Spinner="spinner",et.Text="text",et.Image="image",et.Row="row",et.Address="address",et.Button="button",et.Input="input",et.Form="form",et),ot=N({type:P()}),st=b(ot,N({value:T()})),ct=b(st,N({type:O("address"),value:Re})),ut=(Ze("address",ct,["value"]),b(st,N({type:O("copyable"),value:P(),sensitive:C(S())}))),dt=(Ze("copyable",ut,["value","sensitive"]),b(ot,N({type:O("divider")}))),lt=(Ze("divider",dt),b(st,N({type:O("heading"),value:P()}))),pt=(Ze("heading",lt,["value"]),b(ot,N({type:O("image"),value:Ye()}))),ft=(Ze("image",pt,["value"]),(tt=ft||{}).Primary="primary",tt.Secondary="secondary",tt),mt=((nt=mt||{}).Button="button",nt.Submit="submit",nt),ht=b(st,N({type:O("button"),value:P(),variant:C($([He("primary"),He("secondary")])),buttonType:C($([He("button"),He("submit")])),name:C(P())})),vt=(Ze("button",ht,["value","buttonType","name","variant"]),(rt=vt||{}).Text="text",rt.Number="number",rt.Password="password",rt),yt=b(st,N({type:O("input"),value:C(P()),name:P(),inputType:C($([He("text"),He("password"),He("number")])),placeholder:C(P()),label:C(P()),error:C(P())})),gt=(Ze("input",yt,["name","inputType","placeholder","value","label"]),$([yt,ht])),bt=b(ot,N({type:O("form"),children:E(gt),name:P()})),wt=(Ze("form",bt,["name","children"]),b(st,N({type:O("text"),value:P(),markdown:C(S())}))),xt=(Ze("text",wt,["value","markdown"]),(at=xt||{}).Default="default",at.Critical="critical",at.Warning="warning",at),Et=$([pt,wt,ct]),St=b(st,N({type:O("row"),variant:C($([He("default"),He("critical"),He("warning")])),label:P(),value:Et})),Ot=(Ze("row",St,["label","value","variant"]),b(ot,N({type:O("spinner")}))),kt=(Ze("spinner",Ot),b(ot,N({children:E(x((()=>jt)))}))),It=b(kt,N({type:O("panel")})),jt=(Ze("panel",It,["children"]),Xe([ut,dt,lt,pt,It,Ot,wt,St,ct,yt,bt,ht]));var Nt,Ct,At,Pt,Rt,$t,Tt=((Nt=Tt||{}).Critical="critical",Nt),Ft=((Ct=Ft||{}).ButtonClickEvent="ButtonClickEvent",Ct.FormSubmitEvent="FormSubmitEvent",Ct.InputChangeEvent="InputChangeEvent",Ct.FileUploadEvent="FileUploadEvent",Ct),_t=N({type:P(),name:C(P())}),Jt=b(_t,N({type:O("ButtonClickEvent"),name:C(P())})),Bt=N({name:P(),size:j(),contentType:P(),contents:P()}),qt=b(_t,N({type:O("FormSubmitEvent"),value:A(P(),I($([P(),Bt,S()]))),name:P()})),Mt=b(_t,N({type:O("InputChangeEvent"),name:P(),value:$([P(),S()])})),Ut=($([Jt,qt,Mt,b(_t,N({type:O("FileUploadEvent"),name:P(),file:I(Bt)}))]),(At=Ut||{}).Alert="alert",At.Confirmation="confirmation",At.Prompt="prompt",At),zt=((Pt=zt||{}).Base64="base64",Pt.Hex="hex",Pt.Utf8="utf8",Pt),Dt=((Rt=Dt||{}).ClearState="clear",Rt.GetState="get",Rt.UpdateState="update",Rt),Lt=(($t=Lt||{}).InApp="inApp",$t.Native="native",$t),Gt=Qe([P(),j()]),Wt=Vt([P()]);N({type:P(),props:A(P(),L),key:I(Gt)});function Vt(e){return function(e){const t=Qe([e,E(x((()=>t)))]);return t}(I(Qe([...e,S()])))}function Ht(e,t={}){return N({type:Ve(e),props:N(t),key:I(Gt)})}var Xt=Ht("Button",{children:Wt,name:C(P()),type:C(Qe([Ve("button"),Ve("submit")])),variant:C(Qe([Ve("primary"),Ve("destructive")])),disabled:C(S())}),Qt=Ht("Checkbox",{name:P(),checked:C(S()),label:C(P()),variant:C(Qe([Ve("default"),Ve("toggle")]))}),Yt=Ht("Input",{name:P(),type:C(Qe([Ve("text"),Ve("password"),Ve("number")])),value:C(P()),placeholder:C(P())}),Kt=Ht("Option",{value:P(),children:P()}),Zt=Ht("Dropdown",{name:P(),value:C(P()),children:Vt([Kt])}),en=Ht("Radio",{value:P(),children:P()}),tn=Ht("RadioGroup",{name:P(),value:C(P()),children:Vt([en])}),nn=Ht("FileInput",{name:P(),accept:Qe([C(E(P()))]),compact:C(S())}),rn=[Yt,Xt],an=[Yt,Zt,tn,nn,Qt],on=(Qe([...an,...rn]),Qe([R(rn),...an])),sn=Ht("Field",{label:C(P()),error:C(P()),children:on}),cn=Ht("Form",{children:Vt([sn,x((()=>Cn))]),name:P()}),un=Ht("Bold",{children:Vt([P(),x((()=>dn))])}),dn=Ht("Italic",{children:Vt([P(),x((()=>un))])}),ln=Qe([un,dn]),pn=Ht("Address",{address:Re}),fn=Ht("Box",{children:Vt([x((()=>Cn))]),direction:C(Qe([Ve("horizontal"),Ve("vertical")])),alignment:C(Qe([Ve("start"),Ve("center"),Ve("end"),Ve("space-between"),Ve("space-around")]))}),mn=Ht("Footer",{children:Qe([R([Xt,Xt]),Xt])}),hn=Ht("Container",{children:Qe([R([fn,mn]),fn])}),vn=Ht("Copyable",{value:P(),sensitive:C(S())}),yn=Ht("Divider"),gn=Ht("Value",{value:P(),extra:P()}),bn=Ht("Card",{image:C(P()),title:P(),description:C(P()),value:P(),extra:C(P())}),wn=Ht("Heading",{children:Wt}),xn=Ht("Image",{src:Ye(),alt:C(P())}),En=Ht("Link",{href:P(),children:Vt([ln,P()])}),Sn=Ht("Text",{children:Vt([P(),un,dn,En]),alignment:C(Qe([Ve("start"),Ve("center"),Ve("end")]))}),On=Qe([Sn,un,dn,En,xn,S()]),kn=Qe([Sn,un,dn,En,P()]),In=Ht("Tooltip",{children:I(On),content:kn}),jn=Ht("Row",{label:P(),children:Qe([pn,xn,Sn,gn]),variant:C(Qe([Ve("default"),Ve("warning"),Ve("critical")])),tooltip:C(P())}),Nn=Ht("Spinner"),Cn=Xe([pn,un,fn,Xt,vn,yn,Zt,tn,nn,cn,wn,Yt,xn,dn,En,jn,Nn,Sn,In,Qt,bn]),An=Qe([Cn,hn]),Pn=(Xe([Xt,Yt,nn,sn,cn,un,dn,pn,fn,vn,yn,wn,xn,En,jn,Nn,Sn,Zt,Kt,tn,en,gn,In,Qt,mn,hn,bn]),$([Bt,P(),S()])),Rn=A(P(),I(Pn));A(P(),$([Rn,I(Pn)])),$([jt,An]),A(P(),L);function $n(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e)))}function Tn(e){return t=>{const{key:n=null,...r}=t;return{type:e,props:$n(r),key:n}}}var Fn=Tn("Button"),_n=Tn("Checkbox"),Jn=Tn("Dropdown"),Bn=Tn("Option"),qn=Tn("Radio"),Mn=Tn("RadioGroup"),Un=Tn("Field"),zn=(Tn("FileInput"),Tn("Form")),Dn=Tn("Input"),Ln=Tn("Bold"),Gn=(Tn("Italic"),Tn("Address")),Wn=Tn("Box"),Vn=(Tn("Card"),Tn("Copyable")),Hn=(Tn("Divider"),Tn("Value"),Tn("Heading")),Xn=(Tn("Image"),Tn("Link"),Tn("Row")),Qn=(Tn("Spinner"),Tn("Text"));Tn("Tooltip"),Tn("Footer"),Tn("Container");function Yn(e){return w(JSON.stringify(e),O(e).validator)}function Kn(e){return new m({type:"union",schema:null,*entries(t,n){if(!s(t)||!i(t,"type"))return;const{type:r}=t,a=e.find((({schema:e})=>y(r,e.type)));if(a)for(const e of a.entries(t,n))yield e},validator(t,n){const r=e.map((({schema:e})=>e.type.type));if(!s(t)||!i(t,"type")||"string"!=typeof t.type)return`Expected type to be one of: ${r.join(", ")}, but received: undefined`;const{type:a}=t,o=e.find((({schema:e})=>y(a,e.type)));return o?o.validator(t,n):`Expected type to be one of: ${r.join(", ")}, but received: "${a}"`}})}function Zn(e){return function([e,...t]){const n=$([e,...t]);return new m({...n,schema:[e,...t]})}(e)}var er=Zn([P(),j()]),tr=nr([P()]);N({type:P(),props:A(P(),L),key:I(er)});function nr(e){return function(e){const t=Zn([e,E(x((()=>t)))]);return t}(I(Zn([...e,S()])))}function rr(e,t={}){return N({type:Yn(e),props:N(t),key:I(er)})}var ar=rr("Button",{children:tr,name:C(P()),type:C(Zn([Yn("button"),Yn("submit")])),variant:C(Zn([Yn("primary"),Yn("destructive")])),disabled:C(S())}),ir=rr("Checkbox",{name:P(),checked:C(S()),label:C(P()),variant:C(Zn([Yn("default"),Yn("toggle")]))}),or=rr("Input",{name:P(),type:C(Zn([Yn("text"),Yn("password"),Yn("number")])),value:C(P()),placeholder:C(P())}),sr=rr("Option",{value:P(),children:P()}),cr=rr("Dropdown",{name:P(),value:C(P()),children:nr([sr])}),ur=rr("Radio",{value:P(),children:P()}),dr=rr("RadioGroup",{name:P(),value:C(P()),children:nr([ur])}),lr=rr("FileInput",{name:P(),accept:Zn([C(E(P()))]),compact:C(S())}),pr=[or,ar],fr=[or,cr,dr,lr,ir],mr=(Zn([...fr,...pr]),Zn([R(pr),...fr])),hr=rr("Field",{label:C(P()),error:C(P()),children:mr}),vr=rr("Form",{children:nr([hr,x((()=>Jr))]),name:P()}),yr=rr("Bold",{children:nr([P(),x((()=>gr))])}),gr=rr("Italic",{children:nr([P(),x((()=>yr))])}),br=Zn([yr,gr]),wr=rr("Address",{address:Re}),xr=rr("Box",{children:nr([x((()=>Jr))]),direction:C(Zn([Yn("horizontal"),Yn("vertical")])),alignment:C(Zn([Yn("start"),Yn("center"),Yn("end"),Yn("space-between"),Yn("space-around")]))}),Er=rr("Footer",{children:Zn([R([ar,ar]),ar])}),Sr=rr("Container",{children:Zn([R([xr,Er]),xr])}),Or=rr("Copyable",{value:P(),sensitive:C(S())}),kr=rr("Divider"),Ir=rr("Value",{value:P(),extra:P()}),jr=rr("Card",{image:C(P()),title:P(),description:C(P()),value:P(),extra:C(P())}),Nr=rr("Heading",{children:tr}),Cr=rr("Image",{src:Z(P(),"SVG",(e=>!!e.includes("<svg")||"Value is not a valid SVG.")),alt:C(P())}),Ar=rr("Link",{href:P(),children:nr([br,P()])}),Pr=rr("Text",{children:nr([P(),yr,gr,Ar]),alignment:C(Zn([Yn("start"),Yn("center"),Yn("end")]))}),Rr=Zn([Pr,yr,gr,Ar,Cr,S()]),$r=Zn([Pr,yr,gr,Ar,P()]),Tr=rr("Tooltip",{children:I(Rr),content:$r}),Fr=rr("Row",{label:P(),children:Zn([wr,Cr,Pr,Ir]),variant:C(Zn([Yn("default"),Yn("warning"),Yn("critical")])),tooltip:C(P())}),_r=rr("Spinner"),Jr=Kn([wr,yr,xr,ar,Or,kr,cr,dr,lr,vr,Nr,or,Cr,gr,Ar,Fr,_r,Pr,Tr,ir,jr]);Zn([Jr,Sr]),Kn([ar,or,lr,hr,vr,yr,gr,wr,xr,Or,kr,Nr,Cr,Ar,Fr,_r,Pr,cr,sr,dr,ur,Ir,Tr,ir,Er,Sr,jr]);const Br=()=>t(Wn,{children:[e(Hn,{children:"Interactive UI Example Snap"}),t(zn,{name:"example-form",children:[e(Un,{label:"Example Input",children:e(Dn,{name:"example-input",placeholder:"Enter something..."})}),e(Un,{label:"Example Dropdown",children:t(Jn,{name:"example-dropdown",children:[e(Bn,{value:"option1",children:"Option 1"}),e(Bn,{value:"option2",children:"Option 2"}),e(Bn,{value:"option3",children:"Option 3"})]})}),e(Un,{label:"Example RadioGroup",children:t(Mn,{name:"example-radiogroup",children:[e(qn,{value:"option1",children:"Option 1"}),e(qn,{value:"option2",children:"Option 2"}),e(qn,{value:"option3",children:"Option 3"})]})}),e(Un,{label:"Example Checkbox",children:e(_n,{name:"example-checkbox",label:"Checkbox"})}),e(Fn,{type:"submit",name:"submit",children:"Submit"})]})]}),qr=({from:n,to:r})=>t(Wn,{children:[e(Xn,{label:"From",children:e(Gn,{address:n})}),e(Xn,{label:"To",children:r?e(Gn,{address:n}):e(Qn,{children:"None"})}),e(Fn,{name:"transaction-type",children:"See transaction type"})]}),Mr=({type:n})=>t(Wn,{children:[e(Xn,{label:"Transaction Type",children:e(Qn,{children:e(Ln,{children:n})})}),e(Fn,{name:"go-back",children:"Back"})]}),Ur=({values:n})=>t(Wn,{children:[e(Hn,{children:"Interactive UI Example Snap"}),e(Qn,{children:"You submitted the following values:"}),e(Wn,{children:Object.values(n).map((t=>{var n;return e(Vn,{value:(null===(n=t)||void 0===n?void 0:n.toString())??""})}))}),e(Fn,{name:"back",children:"Back"})]}),zr=[{name:"ERC-20",signature:"a9059cbb"},{name:"ERC-721",signature:"23b872dd"},{name:"ERC-1155",signature:"f242432a"}];const Dr=async({request:t})=>{if("dialog"===t.method)return await snap.request({method:"snap_dialog",params:{type:"confirmation",content:e(Br,{})}});throw new Ke({method:t.method})},Lr=async()=>({content:e(Br,{})}),Gr=async({transaction:t})=>{const{from:n,to:r}=t;return{id:await snap.request({method:"snap_createInterface",params:{ui:e(qr,{from:n,to:r}),context:{transaction:t}}})}},Wr=async({id:t,event:n,context:r})=>{if(n.type===Ft.ButtonClickEvent)switch(n.name){case"transaction-type":{var a;const n=function(e){if(e&&"string"==typeof e){var t;const n=$e(e).slice(0,8);return(null===(t=zr.find((e=>e.signature===n)))||void 0===t?void 0:t.name)??"Unknown"}return"Unknown"}((null===(a=r)||void 0===a?void 0:a.transaction).data);await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(Mr,{type:n})}});break}case"go-back":{var i;const n=null===(i=r)||void 0===i?void 0:i.transaction;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(qr,{from:n.from,to:n.to})}});break}case"back":await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(Br,{})}})}if(n.type===Ft.FormSubmitEvent&&"example-form"===n.name){const r=n.value;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(Ur,{values:r})}})}}})();var a=exports;for(var i in r)a[i]=r[i];r.__esModule&&Object.defineProperty(a,"__esModule",{value:!0})})();
1
+ (()=>{var e={12:e=>{e.exports=i,i.default=i,i.stable=d,i.stableStringify=d;var t="[...]",n="[Circular]",r=[],o=[];function a(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function i(e,t,n,i){var s;void 0===i&&(i=a()),c(e,"",0,[],void 0,0,i);try{s=0===o.length?JSON.stringify(e,t,n):JSON.stringify(e,f(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==r.length;){var u=r.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return s}function s(e,t,n,a){var i=Object.getOwnPropertyDescriptor(a,n);void 0!==i.get?i.configurable?(Object.defineProperty(a,n,{value:e}),r.push([a,n,t,i])):o.push([t,n,e]):(a[n]=e,r.push([a,n,t]))}function c(e,r,o,a,i,u,d){var l;if(u+=1,"object"==typeof e&&null!==e){for(l=0;l<a.length;l++)if(a[l]===e)return void s(n,e,r,i);if(void 0!==d.depthLimit&&u>d.depthLimit)return void s(t,e,r,i);if(void 0!==d.edgesLimit&&o+1>d.edgesLimit)return void s(t,e,r,i);if(a.push(e),Array.isArray(e))for(l=0;l<e.length;l++)c(e[l],l,l,a,e,u,d);else{var f=Object.keys(e);for(l=0;l<f.length;l++){var p=f[l];c(e[p],p,l,a,e,u,d)}}a.pop()}}function u(e,t){return e<t?-1:e>t?1:0}function d(e,t,n,i){void 0===i&&(i=a());var s,c=l(e,"",0,[],void 0,0,i)||e;try{s=0===o.length?JSON.stringify(c,t,n):JSON.stringify(c,f(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==r.length;){var u=r.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return s}function l(e,o,a,i,c,d,f){var p;if(d+=1,"object"==typeof e&&null!==e){for(p=0;p<i.length;p++)if(i[p]===e)return void s(n,e,o,c);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==f.depthLimit&&d>f.depthLimit)return void s(t,e,o,c);if(void 0!==f.edgesLimit&&a+1>f.edgesLimit)return void s(t,e,o,c);if(i.push(e),Array.isArray(e))for(p=0;p<e.length;p++)l(e[p],p,p,i,e,d,f);else{var h={},m=Object.keys(e).sort(u);for(p=0;p<m.length;p++){var v=m[p];l(e[v],v,p,i,e,d,f),h[v]=e[v]}if(void 0===c)return h;r.push([c,o,e]),c[o]=h}i.pop()}}function f(e){return e=void 0!==e?e:function(e,t){return t},function(t,n){if(o.length>0)for(var r=0;r<o.length;r++){var a=o[r];if(a[1]===t&&a[0]===n){n=a[2],o.splice(r,1);break}}return e.call(this,t,n)}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";function e(e,t,n){if("string"==typeof e)throw new Error(`An HTML element ("${String(e)}") was used in a Snap component, which is not supported by Snaps UI. Please use one of the supported Snap components.`);if(!e)throw new Error("A JSX fragment was used in a Snap component, which is not supported by Snaps UI. Please use one of the supported Snap components.");return e({...t,key:n})}function t(t,n,r){return e(t,n,r)}n.r(r),n.d(r,{onHomePage:()=>mt,onRpcRequest:()=>ht,onTransaction:()=>vt,onUserInput:()=>yt});var o={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},a={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},i={"-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."}};function s(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}const c=(e,t)=>Object.hasOwnProperty.call(e,t);var u;!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"}(u=u||(u={}));class d extends TypeError{constructor(e,t){let n;const{message:r,explanation:o,...a}=e,{path:i}=e,s=0===i.length?r:`At path: ${i.join(".")} -- ${r}`;super(o??s),null!=o&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}}function l(e){return"object"==typeof e&&null!==e}function f(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function p(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:o,branch:a}=t,{type:i}=n,{refinement:s,message:c=`Expected a value of type \`${i}\`${s?` with refinement \`${s}\``:""}, but received: \`${f(r)}\``}=e;return{value:r,type:i,refinement:s,key:o[o.length-1],path:o,branch:a,...e,message:c}}function*h(e,t,n,r){(function(e){return l(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const o of e){const e=p(o,t,n,r);e&&(yield e)}}function*m(e,t,n={}){const{path:r=[],branch:o=[e],coerce:a=!1,mask:i=!1}=n,s={path:r,branch:o};if(a&&(e=t.coercer(e,s),i&&"type"!==t.type&&l(t.schema)&&l(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let c="valid";for(const r of t.validator(e,s))r.explanation=n.message,c="not_valid",yield[r,void 0];for(let[u,d,f]of t.entries(e,s)){const t=m(d,f,{path:void 0===u?r:[...r,u],branch:void 0===u?o:[...o,d],coerce:a,mask:i,message:n.message});for(const n of t)n[0]?(c=null===n[0].refinement||void 0===n[0].refinement?"not_valid":"not_refined",yield[n[0],void 0]):a&&(d=n[1],void 0===u?e=d:e instanceof Map?e.set(u,d):e instanceof Set?e.add(d):l(e)&&(void 0!==d||u in e)&&(e[u]=d))}if("not_valid"!==c)for(const r of t.refiner(e,s))r.explanation=n.message,c="not_refined",yield[r,void 0];"valid"===c&&(yield[void 0,e])}class v{constructor(e){const{type:t,schema:n,validator:r,refiner:o,coercer:a=(e=>e),entries:i=function*(){}}=e;this.type=t,this.schema=n,this.entries=i,this.coercer=a,this.validator=r?(e,t)=>h(r(e,t),t,this,e):()=>[],this.refiner=o?(e,t)=>h(o(e,t),t,this,e):()=>[]}assert(e,t){return y(e,this,t)}create(e,t){return g(e,this,t)}is(e){return b(e,this)}mask(e,t){return function(e,t,n){const r=w(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return w(e,this,t)}}function y(e,t,n){const r=w(e,t,{message:n});if(r[0])throw r[0]}function g(e,t,n){const r=w(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function b(e,t){return!w(e,t)[0]}function w(e,t,n={}){const r=m(e,t,n),o=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(r);if(o[0]){return[new d(o[0],(function*(){for(const e of r)e[0]&&(yield e[0])})),void 0]}return[void 0,o[1]]}function E(...e){const t="type"===e[0]?.type,n=e.map((({schema:e})=>e)),r=Object.assign({},...n);return t?function(e){const t=Object.keys(e);return new v({type:"type",schema:e,*entries(n){if(l(n))for(const r of t)yield[r,n[r],e[r]]},validator:e=>l(e)||`Expected an object, but received: ${f(e)}`,coercer:e=>l(e)?{...e}:e})}(r):A(r)}function O(e,t){return new v({type:e,schema:null,validator:t})}function S(e){let t;return new v({type:"lazy",schema:null,*entries(n,r){t??(t=e()),yield*t.entries(n,r)},validator:(n,r)=>(t??(t=e()),t.validator(n,r)),coercer:(n,r)=>(t??(t=e()),t.coercer(n,r)),refiner:(n,r)=>(t??(t=e()),t.refiner(n,r))})}function x(e){return new v({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[n,r]of t.entries())yield[n,r,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${f(e)}`})}function j(){return O("boolean",(e=>"boolean"==typeof e))}function k(e){const t=f(e),n=typeof e;return new v({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||`Expected the literal \`${t}\`, but received: ${f(n)}`})}function N(){return O("never",(()=>!1))}function I(e){return new v({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}function P(){return O("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${f(e)}`))}function A(e){const t=e?Object.keys(e):[],n=N();return new v({type:"object",schema:e??null,*entries(r){if(e&&l(r)){const o=new Set(Object.keys(r));for(const n of t)o.delete(n),yield[n,r[n],e[n]];for(const e of o)yield[e,r[e],n]}},validator:e=>l(e)||`Expected an object, but received: ${f(e)}`,coercer:e=>l(e)?{...e}:e})}function R(e){return new v({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function $(e,t){return new v({type:"record",schema:null,*entries(n){if(l(n))for(const r in n){const o=n[r];yield[r,r,e],yield[r,o,t]}},validator:e=>l(e)||`Expected an object, but received: ${f(e)}`})}function C(){return O("string",(e=>"string"==typeof e||`Expected a string, but received: ${f(e)}`))}function T(e){const t=e.map((e=>e.type)).join(" | ");return new v({type:"union",schema:null,coercer(t){for(const n of e){const[e,r]=n.validate(t,{coerce:!0});if(!e)return r}return t},validator(n,r){const o=[];for(const t of e){const[...e]=m(n,t,r),[a]=e;if(!a?.[0])return[];for(const[t]of e)t&&o.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${f(n)}`,...o]}})}function _(e,t,n){return new v({...e,coercer:(r,o)=>b(r,t)?e.coercer(n(r,o),o):e.coercer(r,o)})}function J(e){return function(e){return function(e){return"object"==typeof e&&null!==e&&"message"in e}(e)&&"string"==typeof e.message?e.message:null==e?"":String(e)}(e).replace(/\.$/u,"")}function F(e,t){return n=e,Boolean("string"==typeof n?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var n}class q extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}}const M=e=>A(e);function U({path:e,branch:t}){const n=e[e.length-1];return c(t[t.length-2],n)}function z(e){return new v({...e,type:`optional ${e.type}`,validator:(t,n)=>!U(n)||e.validator(t,n),refiner:(t,n)=>!U(n)||e.refiner(t,n)})}const B=T([k(null),j(),O("finite number",(e=>b(e,P())&&Number.isFinite(e))),C(),x(S((()=>B))),$(C(),S((()=>B)))]),L=_(B,O("any",(()=>!0)),(e=>(function(e,t,n="Assertion failed",r=q){try{y(e,t)}catch(e){throw F(r,`${n}: ${J(e)}.`)}}(e,B),JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t}))))));function W(e){try{return function(e){g(e,L)}(e),!0}catch{return!1}}const D=k("2.0"),G=I(T([P(),C()])),X=M({code:O("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${f(e)}`)),message:C(),data:z(L),stack:z(C())}),H=T([$(C(),L),x(L)]);M({id:G,jsonrpc:D,method:C(),params:z(H)}),M({jsonrpc:D,method:C(),params:z(H)});A({id:G,jsonrpc:D,result:R(O("unknown",(()=>!0))),error:R(X)});const Q=M({id:G,jsonrpc:D,result:L}),Y=M({id:G,jsonrpc:D,error:X});T([Q,Y]);var K=o.internal,V="Unspecified error message. This is a bug, please report it.",Z=(ee(K),"Unspecified server error.");function ee(e,t=V){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(c(i,t))return i[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return Z}return t}function te(e){return Array.isArray(e)?e.map((e=>W(e)?e:s(e)?ne(e):null)):s(e)?ne(e):W(e)?e:null}function ne(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return W(r)&&(t[n]=r),t}),{})}var re=n(12),oe=class extends Error{constructor(e,t,n){var r=(...e)=>{super(...e)};if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a non-empty string.');!function(e){return s(e)&&c(e,"cause")&&s(e.cause)}(n)?r(t):(r(t,{cause:n.cause}),c(this,"cause")||Object.assign(this,{cause:n.cause})),void 0!==n&&(this.data=n),this.code=e}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=te(this.data.cause))),this.stack&&(e.stack=this.stack),e}toString(){return re(this.serialize(),ie,2)}},ae=class extends oe{constructor(e,t,n){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,n)}};function ie(e,t){if("[Circular]"!==t)return t}var se=e=>Se(o.parse,e),ce=e=>Se(o.invalidRequest,e),ue=e=>Se(o.invalidParams,e),de=e=>Se(o.methodNotFound,e),le=e=>Se(o.internal,e),fe=e=>Se(o.invalidInput,e),pe=e=>Se(o.resourceNotFound,e),he=e=>Se(o.resourceUnavailable,e),me=e=>Se(o.transactionRejected,e),ve=e=>Se(o.methodNotSupported,e),ye=e=>Se(o.limitExceeded,e),ge=e=>xe(a.userRejectedRequest,e),be=e=>xe(a.unauthorized,e),we=e=>xe(a.unsupportedMethod,e),Ee=e=>xe(a.disconnected,e),Oe=e=>xe(a.chainDisconnected,e);function Se(e,t){const[n,r]=je(t);return new oe(e,n??ee(e),r)}function xe(e,t){const[n,r]=je(t);return new ae(e,n??ee(e),r)}function je(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t??void 0,n]}}return[]}function ke(e){return s(e)&&c(e,"data")&&"object"==typeof e.data&&null!==e.data&&W(e.data)&&!Array.isArray(e.data)?e.data:{}}var Ne,Ie,Pe,Ae,Re=function(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!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"===r?o.call(e,n):o?o.value=n:t.set(e,n),n},$e=function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)};class Ce extends Error{constructor(e,t={}){const n=function(e){return s(e)&&c(e,"message")&&"string"==typeof e.message?e.message:String(e)}(e);super(n),Ne.set(this,void 0),Ie.set(this,void 0),Pe.set(this,void 0),Ae.set(this,void 0),Re(this,Ie,n,"f"),Re(this,Ne,function(e){return s(e)&&c(e,"code")&&"number"==typeof e.code&&Number.isInteger(e.code)?e.code:-32603}(e),"f");const r={...ke(e),...t};Object.keys(r).length>0&&Re(this,Pe,r,"f"),Re(this,Ae,super.stack,"f")}get name(){return"SnapError"}get code(){return $e(this,Ne,"f")}get message(){return $e(this,Ie,"f")}get data(){return $e(this,Pe,"f")}get stack(){return $e(this,Ae,"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 Te(e){return class extends Ce{constructor(t,n){if("object"==typeof t){const n=e();return void super({code:n.code,message:n.message,data:t})}const r=e(t);super({code:r.code,message:r.message,data:n})}}}Ne=new WeakMap,Ie=new WeakMap,Pe=new WeakMap,Ae=new WeakMap;Te(le),Te(fe),Te(ue),Te(ce),Te(ye);const _e=Te(de);Te(ve),Te(se),Te(pe),Te(he),Te(me),Te(Oe),Te(Ee),Te(be),Te(we),Te(ge);var Je;!function(e){e.ButtonClickEvent="ButtonClickEvent",e.FormSubmitEvent="FormSubmitEvent",e.InputChangeEvent="InputChangeEvent",e.FileUploadEvent="FileUploadEvent"}(Je||(Je={}));const Fe=A({type:C(),name:R(C())}),qe=E(Fe,A({type:k(Je.ButtonClickEvent),name:R(C())})),Me=A({name:C(),size:P(),contentType:C(),contents:C()}),Ue=E(Fe,A({type:k(Je.FormSubmitEvent),value:$(C(),I(T([C(),Me,j()]))),name:C()})),ze=E(Fe,A({type:k(Je.InputChangeEvent),name:C(),value:T([C(),j()])}));T([qe,Ue,ze,E(Fe,A({type:k(Je.FileUploadEvent),name:C(),file:I(Me)}))]);function Be(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e)))}function Le(e){return t=>{const{key:n=null,...r}=t;return{type:e,props:Be(r),key:n}}}const We=Le("Box"),De=Le("Heading"),Ge=Le("Form"),Xe=Le("Field"),He=Le("Input"),Qe=Le("Dropdown"),Ye=Le("Option"),Ke=Le("RadioGroup"),Ve=Le("Radio"),Ze=Le("Checkbox"),et=Le("Button"),tt=()=>t(We,{children:[e(De,{children:"Interactive UI Example Snap"}),t(Ge,{name:"example-form",children:[e(Xe,{label:"Example Input",children:e(He,{name:"example-input",placeholder:"Enter something..."})}),e(Xe,{label:"Example Dropdown",children:t(Qe,{name:"example-dropdown",children:[e(Ye,{value:"option1",children:"Option 1"}),e(Ye,{value:"option2",children:"Option 2"}),e(Ye,{value:"option3",children:"Option 3"})]})}),e(Xe,{label:"Example RadioGroup",children:t(Ke,{name:"example-radiogroup",children:[e(Ve,{value:"option1",children:"Option 1"}),e(Ve,{value:"option2",children:"Option 2"}),e(Ve,{value:"option3",children:"Option 3"})]})}),e(Xe,{label:"Example Checkbox",children:e(Ze,{name:"example-checkbox",label:"Checkbox"})}),e(et,{type:"submit",name:"submit",children:"Submit"})]})]}),nt=Le("Row"),rt=Le("Address"),ot=Le("Text"),at=({from:n,to:r})=>t(We,{children:[e(nt,{label:"From",children:e(rt,{address:n})}),e(nt,{label:"To",children:r?e(rt,{address:n}):e(ot,{children:"None"})}),e(et,{name:"transaction-type",children:"See transaction type"})]}),it=Le("Bold"),st=({type:n})=>t(We,{children:[e(nt,{label:"Transaction Type",children:e(ot,{children:e(it,{children:n})})}),e(et,{name:"go-back",children:"Back"})]}),ct=Le("Copyable"),ut=({values:n})=>t(We,{children:[e(De,{children:"Interactive UI Example Snap"}),e(ot,{children:"You submitted the following values:"}),e(We,{children:Object.values(n).map((t=>{var n;return e(ct,{value:(null===(n=t)||void 0===n?void 0:n.toString())??""})}))}),e(et,{name:"back",children:"Back"})]});function dt(e,t){return lt(e,"pattern",(n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`))}function lt(e,t,n){return new v({...e,*refiner(r,o){yield*e.refiner(r,o);const a=h(n(r,o),o,e,r);for(const e of a)yield{...e,refinement:t}}})}dt(C(),/^(?:0x)?[0-9a-f]+$/iu),dt(C(),/^0x[0-9a-f]+$/iu),dt(C(),/^0x[0-9a-f]{40}$/u),dt(C(),/^0x[0-9a-fA-F]{40}$/u);function ft(e){return e.startsWith("0x")||e.startsWith("0X")?e.substring(2):e}const pt=[{name:"ERC-20",signature:"a9059cbb"},{name:"ERC-721",signature:"23b872dd"},{name:"ERC-1155",signature:"f242432a"}];const ht=async({request:t})=>{if("dialog"===t.method)return await snap.request({method:"snap_dialog",params:{type:"confirmation",content:e(tt,{})}});throw new _e({method:t.method})},mt=async()=>({content:e(tt,{})}),vt=async({transaction:t})=>{const{from:n,to:r}=t;return{id:await snap.request({method:"snap_createInterface",params:{ui:e(at,{from:n,to:r}),context:{transaction:t}}})}},yt=async({id:t,event:n,context:r})=>{if(n.type===Je.ButtonClickEvent)switch(n.name){case"transaction-type":{var o;const n=function(e){if(e&&"string"==typeof e){var t;const n=ft(e).slice(0,8);return(null===(t=pt.find((e=>e.signature===n)))||void 0===t?void 0:t.name)??"Unknown"}return"Unknown"}((null===(o=r)||void 0===o?void 0:o.transaction).data);await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(st,{type:n})}});break}case"go-back":{var a;const n=null===(a=r)||void 0===a?void 0:a.transaction;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(at,{from:n.from,to:n.to})}});break}case"back":await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(tt,{})}})}if(n.type===Je.FormSubmitEvent&&"example-form"===n.name){const r=n.value;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(ut,{values:r})}})}}})();var o=exports;for(var a in r)o[a]=r[a];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/interactive-ui-example-snap",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "MetaMask example snap demonstrating the use of interactive UI.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,8 +30,8 @@
30
30
  "lint:dependencies": "depcheck"
31
31
  },
32
32
  "dependencies": {
33
- "@metamask/snaps-sdk": "^6.2.0",
34
- "@metamask/utils": "^9.1.0"
33
+ "@metamask/snaps-sdk": "^6.4.0",
34
+ "@metamask/utils": "^9.2.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@jest/globals": "^29.5.0",
@@ -41,19 +41,19 @@
41
41
  "@metamask/eslint-config-jest": "^12.1.0",
42
42
  "@metamask/eslint-config-nodejs": "^12.1.0",
43
43
  "@metamask/eslint-config-typescript": "^12.1.0",
44
- "@metamask/snaps-cli": "^6.3.0",
45
- "@metamask/snaps-jest": "^8.3.0",
44
+ "@metamask/snaps-cli": "^6.3.2",
45
+ "@metamask/snaps-jest": "^8.3.1",
46
46
  "@swc/core": "1.3.78",
47
47
  "@swc/jest": "^0.2.26",
48
48
  "@typescript-eslint/eslint-plugin": "^5.42.1",
49
- "@typescript-eslint/parser": "^5.42.1",
49
+ "@typescript-eslint/parser": "^6.21.0",
50
50
  "deepmerge": "^4.2.2",
51
51
  "depcheck": "^1.4.7",
52
52
  "eslint": "^8.27.0",
53
53
  "eslint-config-prettier": "^8.5.0",
54
54
  "eslint-plugin-import": "^2.26.0",
55
55
  "eslint-plugin-jest": "^27.1.5",
56
- "eslint-plugin-jsdoc": "^39.6.2",
56
+ "eslint-plugin-jsdoc": "^41.1.2",
57
57
  "eslint-plugin-n": "^15.7.0",
58
58
  "eslint-plugin-prettier": "^4.2.1",
59
59
  "eslint-plugin-promise": "^6.1.1",
@@ -62,7 +62,7 @@
62
62
  "prettier-plugin-packagejson": "^2.2.11",
63
63
  "rimraf": "^4.1.2",
64
64
  "ts-node": "^10.9.1",
65
- "typescript": "~5.0.4"
65
+ "typescript": "~5.3.3"
66
66
  },
67
67
  "engines": {
68
68
  "node": "^18.16 || >=20"
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0",
2
+ "version": "2.2.1",
3
3
  "description": "MetaMask example snap demonstrating the use of interactive UI",
4
4
  "proposedName": "Interactive UI Example Snap",
5
5
  "repository": {
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/MetaMask/snaps.git"
8
8
  },
9
9
  "source": {
10
- "shasum": "gAlUmrpqDhqJ7Suu3Fpr7Do1y7MFEi7qR22uyjhRDb8=",
10
+ "shasum": "uOuMArCEwmOmCl0Bl1WnRRm+DKcq0Y+O+5n8Z1KBMr8=",
11
11
  "location": {
12
12
  "npm": {
13
13
  "filePath": "dist/bundle.js",