@metamask/interactive-ui-example-snap 2.1.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,6 +6,14 @@ 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
+
13
+ ## [2.2.0]
14
+ ### Added
15
+ - Add `RadioGroup` to interactive UI example ([#2592](https://github.com/MetaMask/snaps/pull/2592))
16
+
9
17
  ## [2.1.0]
10
18
  ### Added
11
19
  - Add `Checkbox` to interactive UI example ([#2515](https://github.com/MetaMask/snaps/pull/2515))
@@ -27,7 +35,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
27
35
  ### Added
28
36
  - Add interactive UI example Snap ([#2171](https://github.com/MetaMask/snaps/pull/2171))
29
37
 
30
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.1.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
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
31
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
32
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
33
43
  [1.0.2]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@1.0.1...@metamask/interactive-ui-example-snap@1.0.2
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:()=>Ir,onRpcRequest:()=>kr,onTransaction:()=>jr,onUserInput:()=>Nr});var i=(e,t)=>Object.hasOwnProperty.call(e,t);var o,s=((o=s||{})[o.Null=4]="Null",o[o.Comma=1]="Comma",o[o.Wrapper=1]="Wrapper",o[o.True=4]="True",o[o.False=5]="False",o[o.Quote=1]="Quote",o[o.Colon=1]="Colon",o[o.Date=24]="Date",o);function c(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 u 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 d(e){return"object"==typeof e&&null!=e}function l(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:a,branch:i}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:""}, but received: \`${l(r)}\``}=e;return{value:r,type:o,refinement:s,key:a[a.length-1],path:a,branch:i,...e,message:c}}function*f(e,t,n,r){var a;d(a=e)&&"function"==typeof a[Symbol.iterator]||(e=[e]);for(const a of e){const e=p(a,t,n,r);e&&(yield e)}}function*m(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&&d(t.schema)&&d(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,l,p]of t.entries(e,s)){const t=m(l,p,{path:void 0===u?r:[...r,u],branch:void 0===u?a:[...a,l],coerce:i,mask:o,message:n.message});for(const n of t)n[0]?(c=null!=n[0].refinement?"not_refined":"not_valid",yield[n[0],void 0]):i&&(l=n[1],void 0===u?e=l:e instanceof Map?e.set(u,l):e instanceof Set?e.add(l):d(e)&&(void 0!==l||u in e)&&(e[u]=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 h{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)=>f(r(e,t),t,this,e):()=>[],this.refiner=a?(e,t)=>f(a(e,t),t,this,e):()=>[]}assert(e,t){return v(e,this,t)}create(e,t){return y(e,this,t)}is(e){return g(e,this)}mask(e,t){return function(e,t,n){const r=b(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return b(e,this,t)}}function v(e,t,n){const r=b(e,t,{message:n});if(r[0])throw r[0]}function y(e,t,n){const r=b(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function g(e,t){return!b(e,t)[0]}function b(e,t,n={}){const r=m(e,t,n),a=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(r);if(a[0]){return[new u(a[0],(function*(){for(const e of r)e[0]&&(yield e[0])})),void 0]}return[void 0,a[1]]}function w(...e){const t="type"===e[0].type,n=e.map((e=>e.schema)),r=Object.assign({},...n);return t?R(r):A(r)}function x(e,t){return new h({type:e,schema:null,validator:t})}function S(e){let t;return new h({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 h({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: ${l(e)}`})}function O(){return x("boolean",(e=>"boolean"==typeof e))}function k(e){const t=l(e),n=typeof e;return new h({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||`Expected the literal \`${t}\`, but received: ${l(n)}`})}function I(){return x("never",(()=>!1))}function j(e){return new h({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}function N(){return x("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${l(e)}`))}function A(e){const t=e?Object.keys(e):[],n=I();return new h({type:"object",schema:e||null,*entries(r){if(e&&d(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=>d(e)||`Expected an object, but received: ${l(e)}`,coercer:e=>d(e)?{...e}:e})}function P(e){return new h({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function C(e,t){return new h({type:"record",schema:null,*entries(n){if(d(n))for(const r in n){const a=n[r];yield[r,r,e],yield[r,a,t]}},validator:e=>d(e)||`Expected an object, but received: ${l(e)}`})}function T(){return x("string",(e=>"string"==typeof e||`Expected a string, but received: ${l(e)}`))}function $(e){const t=I();return new h({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: ${l(e)}`})}function R(e){const t=Object.keys(e);return new h({type:"type",schema:e,*entries(n){if(d(n))for(const r of t)yield[r,n[r],e[r]]},validator:e=>d(e)||`Expected an object, but received: ${l(e)}`,coercer:e=>d(e)?{...e}:e})}function F(e){const t=e.map((e=>e.type)).join(" | ");return new h({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]=m(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: ${l(n)}`,...a]}})}function _(){return x("unknown",(()=>!0))}function J(e,t,n){return new h({...e,coercer:(r,a)=>g(r,t)?e.coercer(n(r,a),a):e.coercer(r,a)})}function B(e,t){return q(e,"pattern",(n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`))}function q(e,t,n){return new h({...e,*refiner(r,a){yield*e.refiner(r,a);const i=f(n(r,a),a,e,r);for(const e of i)yield{...e,refinement:t}}})}function M(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 U(e,t){return n=e,Boolean("string"==typeof n?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var n}var z=class extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}};function D(e,t,n="Assertion failed",r=z){try{v(e,t)}catch(e){throw U(r,`${n}: ${M(e)}.`)}}var L=e=>A(e);function W({path:e,branch:t}){const n=e[e.length-1];return i(t[t.length-2],n)}function V(e){return new h({...e,type:`optional ${e.type}`,validator:(t,n)=>!W(n)||e.validator(t,n),refiner:(t,n)=>!W(n)||e.refiner(t,n)})}var G=F([k(null),O(),x("finite number",(e=>g(e,N())&&Number.isFinite(e))),T(),E(S((()=>G))),C(T(),S((()=>G)))]),H=J(G,x("any",(()=>!0)),(e=>(D(e,G),JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t}))))));function X(e){try{return function(e){y(e,H)}(e),!0}catch{return!1}}var Q=k("2.0"),Y=j(F([N(),T()])),K=L({code:x("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${l(e)}`)),message:T(),data:V(H),stack:V(T())}),Z=F([C(T(),H),E(H)]);L({id:Y,jsonrpc:Q,method:T(),params:V(Z)}),L({jsonrpc:Q,method:T(),params:V(Z)});A({id:Y,jsonrpc:Q,result:P(_()),error:P(K)});var ee=L({id:Y,jsonrpc:Q,result:H}),te=L({id:Y,jsonrpc:Q,error:K});F([ee,te]);var ne={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},re={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},ae={"-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."}},ie=ne.internal,oe="Unspecified error message. This is a bug, please report it.",se=(ce(ie),"Unspecified server error.");function ce(e,t=oe){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(i(ae,t))return ae[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return se}return t}function ue(e){return Array.isArray(e)?e.map((e=>X(e)?e:a(e)?de(e):null)):a(e)?de(e):X(e)?e:null}function de(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return X(r)&&(t[n]=r),t}),{})}var le=n(12),pe=class extends Error{constructor(e,t,n){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.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data,c(this.data)&&(e.data.cause=ue(this.data.cause))),this.stack&&(e.stack=this.stack),e}toString(){return le(this.serialize(),me,2)}},fe=class extends pe{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 me(e,t){if("[Circular]"!==t)return t}var he=e=>Ce(ne.parse,e),ve=e=>Ce(ne.invalidRequest,e),ye=e=>Ce(ne.invalidParams,e),ge=e=>Ce(ne.methodNotFound,e),be=e=>Ce(ne.internal,e),we=e=>Ce(ne.invalidInput,e),xe=e=>Ce(ne.resourceNotFound,e),Se=e=>Ce(ne.resourceUnavailable,e),Ee=e=>Ce(ne.transactionRejected,e),Oe=e=>Ce(ne.methodNotSupported,e),ke=e=>Ce(ne.limitExceeded,e),Ie=e=>Te(re.userRejectedRequest,e),je=e=>Te(re.unauthorized,e),Ne=e=>Te(re.unsupportedMethod,e),Ae=e=>Te(re.disconnected,e),Pe=e=>Te(re.chainDisconnected,e);function Ce(e,t){const[n,r]=$e(t);return new pe(e,n??ce(e),r)}function Te(e,t){const[n,r]=$e(t);return new fe(e,n??ce(e),r)}function $e(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(){const e=[]}();B(T(),/^(?:0x)?[0-9a-f]+$/iu),B(T(),/^0x[0-9a-f]+$/iu),B(T(),/^0x[0-9a-f]{40}$/u);var Re=B(T(),/^0x[0-9a-fA-F]{40}$/u);function Fe(e){return e.startsWith("0x")||e.startsWith("0X")?e.substring(2):e}var _e,Je,Be,qe,Me=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Ue=(e,t,n)=>(Me(e,t,"read from private field"),n?n.call(e):t.get(e)),ze=(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)},De=(e,t,n,r)=>(Me(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Le=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),ze(this,_e,void 0),ze(this,Je,void 0),ze(this,Be,void 0),ze(this,qe,void 0),De(this,Je,n),De(this,_e,function(e){if(a(e)&&i(e,"code")&&"number"==typeof e.code&&Number.isInteger(e.code))return e.code;return-32603}(e));const r={...He(e),...t};Object.keys(r).length>0&&De(this,Be,r),De(this,qe,super.stack)}get name(){return"SnapError"}get code(){return Ue(this,_e)}get message(){return Ue(this,Je)}get data(){return Ue(this,Be)}get stack(){return Ue(this,qe)}toJSON(){return{code:Ve,message:Ge,data:{cause:{code:this.code,message:this.message,stack:this.stack,...this.data?{data:this.data}:{}}}}}serialize(){return this.toJSON()}};function We(e){return class extends Le{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})}}}_e=new WeakMap,Je=new WeakMap,Be=new WeakMap,qe=new WeakMap;var Ve=-31002,Ge="Snap Error";function He(e){return a(e)&&i(e,"data")&&"object"==typeof e.data&&null!==e.data&&X(e.data)&&!Array.isArray(e.data)?e.data:{}}function Xe(e){return x(JSON.stringify(e),k(e).validator)}function Qe(e){return Xe(e)}function Ye(e){return function([e,...t]){const n=F([e,...t]);return new h({...n,schema:[e,...t]})}(e)}function Ke(){return q(T(),"SVG",(e=>!!e.includes("<svg")||"Value is not a valid SVG."))}We(be),We(we),We(ye),We(ve),We(ke);var Ze=We(ge);We(Oe),We(he),We(xe),We(Se),We(Ee),We(Pe),We(Ae),We(je),We(Ne),We(Ie);function et(e,t,n=[]){return(...r)=>{if(1===r.length&&c(r[0])){const n={...r[0],type:e};return D(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 D(a,t,`Invalid ${e} component`),a}}var tt,nt,rt,at,it,ot=((tt=ot||{}).Copyable="copyable",tt.Divider="divider",tt.Heading="heading",tt.Panel="panel",tt.Spinner="spinner",tt.Text="text",tt.Image="image",tt.Row="row",tt.Address="address",tt.Button="button",tt.Input="input",tt.Form="form",tt),st=A({type:T()}),ct=w(st,A({value:_()})),ut=w(ct,A({type:k("address"),value:Re})),dt=(et("address",ut,["value"]),w(ct,A({type:k("copyable"),value:T(),sensitive:P(O())}))),lt=(et("copyable",dt,["value","sensitive"]),w(st,A({type:k("divider")}))),pt=(et("divider",lt),w(ct,A({type:k("heading"),value:T()}))),ft=(et("heading",pt,["value"]),w(st,A({type:k("image"),value:Ke()}))),mt=(et("image",ft,["value"]),(nt=mt||{}).Primary="primary",nt.Secondary="secondary",nt),ht=((rt=ht||{}).Button="button",rt.Submit="submit",rt),vt=w(ct,A({type:k("button"),value:T(),variant:P(F([Qe("primary"),Qe("secondary")])),buttonType:P(F([Qe("button"),Qe("submit")])),name:P(T())})),yt=(et("button",vt,["value","buttonType","name","variant"]),(at=yt||{}).Text="text",at.Number="number",at.Password="password",at),gt=w(ct,A({type:k("input"),value:P(T()),name:T(),inputType:P(F([Qe("text"),Qe("password"),Qe("number")])),placeholder:P(T()),label:P(T()),error:P(T())})),bt=(et("input",gt,["name","inputType","placeholder","value","label"]),F([gt,vt])),wt=w(st,A({type:k("form"),children:E(bt),name:T()})),xt=(et("form",wt,["name","children"]),w(ct,A({type:k("text"),value:T(),markdown:P(O())}))),St=(et("text",xt,["value","markdown"]),(it=St||{}).Default="default",it.Critical="critical",it.Warning="warning",it),Et=F([ft,xt,ut]),Ot=w(ct,A({type:k("row"),variant:P(F([Qe("default"),Qe("critical"),Qe("warning")])),label:T(),value:Et})),kt=(et("row",Ot,["label","value","variant"]),w(st,A({type:k("spinner")}))),It=(et("spinner",kt),w(st,A({children:E(S((()=>Nt)))}))),jt=w(It,A({type:k("panel")})),Nt=(et("panel",jt,["children"]),F([dt,lt,pt,ft,jt,kt,xt,Ot,ut,gt,wt,vt]));var At,Pt,Ct,Tt,$t,Rt,Ft=((At=Ft||{}).Critical="critical",At),_t=((Pt=_t||{}).ButtonClickEvent="ButtonClickEvent",Pt.FormSubmitEvent="FormSubmitEvent",Pt.InputChangeEvent="InputChangeEvent",Pt.FileUploadEvent="FileUploadEvent",Pt),Jt=A({type:T(),name:P(T())}),Bt=w(Jt,A({type:k("ButtonClickEvent"),name:P(T())})),qt=A({name:T(),size:N(),contentType:T(),contents:T()}),Mt=w(Jt,A({type:k("FormSubmitEvent"),value:C(T(),j(F([T(),qt,O()]))),name:T()})),Ut=w(Jt,A({type:k("InputChangeEvent"),name:T(),value:F([T(),O()])})),zt=(F([Bt,Mt,Ut,w(Jt,A({type:k("FileUploadEvent"),name:T(),file:j(qt)}))]),(Ct=zt||{}).Alert="alert",Ct.Confirmation="confirmation",Ct.Prompt="prompt",Ct),Dt=((Tt=Dt||{}).Base64="base64",Tt.Hex="hex",Tt.Utf8="utf8",Tt),Lt=(($t=Lt||{}).ClearState="clear",$t.GetState="get",$t.UpdateState="update",$t),Wt=((Rt=Wt||{}).InApp="inApp",Rt.Native="native",Rt),Vt=Ye([T(),N()]),Gt=Ht([T()]);A({type:T(),props:C(T(),H),key:j(Vt)});function Ht(e){return function(e){const t=Ye([e,E(S((()=>t)))]);return t}(j(Ye([...e,O()])))}function Xt(e,t={}){return A({type:Xe(e),props:A(t),key:j(Vt)})}var Qt=Xt("Button",{children:Gt,name:P(T()),type:P(Ye([Xe("button"),Xe("submit")])),variant:P(Ye([Xe("primary"),Xe("destructive")])),disabled:P(O())}),Yt=Xt("Checkbox",{name:T(),checked:P(O()),label:P(T()),variant:P(Ye([Xe("default"),Xe("toggle")]))}),Kt=Xt("Input",{name:T(),type:P(Ye([Xe("text"),Xe("password"),Xe("number")])),value:P(T()),placeholder:P(T())}),Zt=Xt("Option",{value:T(),children:T()}),en=Xt("Dropdown",{name:T(),value:P(T()),children:Ht([Zt])}),tn=Xt("FileInput",{name:T(),accept:Ye([P(E(T()))]),compact:P(O())}),nn=Xt("Field",{label:P(T()),error:P(T()),children:Ye([$([Kt,Qt]),en,tn,Kt,Yt])}),rn=Xt("Form",{children:Ht([nn,S((()=>Sn))]),name:T()}),an=Xt("Bold",{children:Ht([T(),S((()=>on))])}),on=Xt("Italic",{children:Ht([T(),S((()=>an))])}),sn=Ye([an,on]),cn=Xt("Address",{address:Re}),un=Xt("Box",{children:Ht([S((()=>Sn))]),direction:P(Ye([Xe("horizontal"),Xe("vertical")])),alignment:P(Ye([Xe("start"),Xe("center"),Xe("end"),Xe("space-between"),Xe("space-around")]))}),dn=Xt("Copyable",{value:T(),sensitive:P(O())}),ln=Xt("Divider"),pn=Xt("Value",{value:T(),extra:T()}),fn=Xt("Heading",{children:Gt}),mn=Xt("Image",{src:Ke(),alt:P(T())}),hn=Xt("Link",{href:T(),children:Ht([sn,T()])}),vn=Xt("Text",{children:Ht([T(),an,on,hn]),alignment:P(Ye([Xe("start"),Xe("center"),Xe("end")]))}),yn=Ye([vn,an,on,hn,mn,O()]),gn=Ye([vn,an,on,hn,T()]),bn=Xt("Tooltip",{children:j(yn),content:gn}),wn=Xt("Row",{label:T(),children:Ye([cn,mn,vn,pn]),variant:P(Ye([Xe("default"),Xe("warning"),Xe("critical")])),tooltip:P(T())}),xn=Xt("Spinner"),Sn=Ye([cn,an,un,Qt,dn,ln,en,tn,rn,fn,Kt,mn,on,hn,wn,xn,vn,bn,Yt]),En=Sn,On=(Ye([Qt,Kt,tn,nn,rn,an,on,cn,un,dn,ln,fn,mn,hn,wn,xn,vn,en,Zt,pn,bn,Yt]),F([qt,T(),O()])),kn=C(T(),j(On));C(T(),F([kn,j(On)])),F([Nt,En]),C(T(),H);function In(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e)))}function jn(e){return t=>{const{key:n=null,...r}=t;return{type:e,props:In(r),key:n}}}var Nn=jn("Button"),An=jn("Checkbox"),Pn=jn("Dropdown"),Cn=jn("Option"),Tn=jn("Field"),$n=(jn("FileInput"),jn("Form")),Rn=jn("Input"),Fn=jn("Bold"),_n=(jn("Italic"),jn("Address")),Jn=jn("Box"),Bn=jn("Copyable"),qn=(jn("Divider"),jn("Value"),jn("Heading")),Mn=(jn("Image"),jn("Link"),jn("Row")),Un=(jn("Spinner"),jn("Text"));jn("Tooltip");function zn(e){return x(JSON.stringify(e),k(e).validator)}function Dn(e){return function([e,...t]){const n=F([e,...t]);return new h({...n,schema:[e,...t]})}(e)}var Ln=Dn([T(),N()]),Wn=Vn([T()]);A({type:T(),props:C(T(),H),key:j(Ln)});function Vn(e){return function(e){const t=Dn([e,E(S((()=>t)))]);return t}(j(Dn([...e,O()])))}function Gn(e,t={}){return A({type:zn(e),props:A(t),key:j(Ln)})}var Hn=Gn("Button",{children:Wn,name:P(T()),type:P(Dn([zn("button"),zn("submit")])),variant:P(Dn([zn("primary"),zn("destructive")])),disabled:P(O())}),Xn=Gn("Checkbox",{name:T(),checked:P(O()),label:P(T()),variant:P(Dn([zn("default"),zn("toggle")]))}),Qn=Gn("Input",{name:T(),type:P(Dn([zn("text"),zn("password"),zn("number")])),value:P(T()),placeholder:P(T())}),Yn=Gn("Option",{value:T(),children:T()}),Kn=Gn("Dropdown",{name:T(),value:P(T()),children:Vn([Yn])}),Zn=Gn("FileInput",{name:T(),accept:Dn([P(E(T()))]),compact:P(O())}),er=Gn("Field",{label:P(T()),error:P(T()),children:Dn([$([Qn,Hn]),Kn,Zn,Qn,Xn])}),tr=Gn("Form",{children:Vn([er,S((()=>br))]),name:T()}),nr=Gn("Bold",{children:Vn([T(),S((()=>rr))])}),rr=Gn("Italic",{children:Vn([T(),S((()=>nr))])}),ar=Dn([nr,rr]),ir=Gn("Address",{address:Re}),or=Gn("Box",{children:Vn([S((()=>br))]),direction:P(Dn([zn("horizontal"),zn("vertical")])),alignment:P(Dn([zn("start"),zn("center"),zn("end"),zn("space-between"),zn("space-around")]))}),sr=Gn("Copyable",{value:T(),sensitive:P(O())}),cr=Gn("Divider"),ur=Gn("Value",{value:T(),extra:T()}),dr=Gn("Heading",{children:Wn}),lr=Gn("Image",{src:q(T(),"SVG",(e=>!!e.includes("<svg")||"Value is not a valid SVG.")),alt:P(T())}),pr=Gn("Link",{href:T(),children:Vn([ar,T()])}),fr=Gn("Text",{children:Vn([T(),nr,rr,pr]),alignment:P(Dn([zn("start"),zn("center"),zn("end")]))}),mr=Dn([fr,nr,rr,pr,lr,O()]),hr=Dn([fr,nr,rr,pr,T()]),vr=Gn("Tooltip",{children:j(mr),content:hr}),yr=Gn("Row",{label:T(),children:Dn([ir,lr,fr,ur]),variant:P(Dn([zn("default"),zn("warning"),zn("critical")])),tooltip:P(T())}),gr=Gn("Spinner"),br=Dn([ir,nr,or,Hn,sr,cr,Kn,Zn,tr,dr,Qn,lr,rr,pr,yr,gr,fr,vr,Xn]);Dn([Hn,Qn,Zn,er,tr,nr,rr,ir,or,sr,cr,dr,lr,pr,yr,gr,fr,Kn,Yn,ur,vr,Xn]);const wr=()=>t(Jn,{children:[e(qn,{children:"Interactive UI Example Snap"}),t($n,{name:"example-form",children:[e(Tn,{label:"Example Input",children:e(Rn,{name:"example-input",placeholder:"Enter something..."})}),e(Tn,{label:"Example Dropdown",children:t(Pn,{name:"example-dropdown",children:[e(Cn,{value:"option1",children:"Option 1"}),e(Cn,{value:"option2",children:"Option 2"}),e(Cn,{value:"option3",children:"Option 3"})]})}),e(Tn,{label:"Example Checkbox",children:e(An,{name:"example-checkbox",label:"Checkbox"})}),e(Nn,{type:"submit",name:"submit",children:"Submit"})]})]}),xr=({from:n,to:r})=>t(Jn,{children:[e(Mn,{label:"From",children:e(_n,{address:n})}),e(Mn,{label:"To",children:r?e(_n,{address:n}):e(Un,{children:"None"})}),e(Nn,{name:"transaction-type",children:"See transaction type"})]}),Sr=({type:n})=>t(Jn,{children:[e(Mn,{label:"Transaction Type",children:e(Un,{children:e(Fn,{children:n})})}),e(Nn,{name:"go-back",children:"Back"})]}),Er=({values:n})=>t(Jn,{children:[e(qn,{children:"Interactive UI Example Snap"}),e(Un,{children:"You submitted the following values:"}),e(Jn,{children:Object.values(n).map((t=>{var n;return e(Bn,{value:(null===(n=t)||void 0===n?void 0:n.toString())??""})}))}),e(Nn,{name:"back",children:"Back"})]}),Or=[{name:"ERC-20",signature:"a9059cbb"},{name:"ERC-721",signature:"23b872dd"},{name:"ERC-1155",signature:"f242432a"}];const kr=async({request:t})=>{if("dialog"===t.method)return await snap.request({method:"snap_dialog",params:{type:"confirmation",content:e(wr,{})}});throw new Ze({method:t.method})},Ir=async()=>({content:e(wr,{})}),jr=async({transaction:t})=>{const{from:n,to:r}=t;return{id:await snap.request({method:"snap_createInterface",params:{ui:e(xr,{from:n,to:r}),context:{transaction:t}}})}},Nr=async({id:t,event:n,context:r})=>{if(n.type===_t.ButtonClickEvent)switch(n.name){case"transaction-type":{var a;const n=function(e){if(e&&"string"==typeof e){var t;const n=Fe(e).slice(0,8);return(null===(t=Or.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(Sr,{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(xr,{from:n.from,to:n.to})}});break}case"back":await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(wr,{})}})}if(n.type===_t.FormSubmitEvent&&"example-form"===n.name){const r=n.value;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(Er,{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.1.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.0.0",
34
- "@metamask/utils": "^8.3.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.2.1",
45
- "@metamask/snaps-jest": "^8.2.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": "~4.8.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.1.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": "Ko9xBAU/AMTQmdJHIKVaXEvIMRKil4LMaFj+3gS3eZo=",
10
+ "shasum": "uOuMArCEwmOmCl0Bl1WnRRm+DKcq0Y+O+5n8Z1KBMr8=",
11
11
  "location": {
12
12
  "npm": {
13
13
  "filePath": "dist/bundle.js",