@metamask/interactive-ui-example-snap 2.3.0 → 2.4.0
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 +8 -1
- package/dist/bundle.js +1 -1
- package/package.json +11 -24
- package/snap.manifest.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.4.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add disabled state ([#3293](https://github.com/MetaMask/snaps/pull/3293))
|
|
15
|
+
|
|
10
16
|
## [2.3.0]
|
|
11
17
|
|
|
12
18
|
### Added
|
|
@@ -60,7 +66,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
60
66
|
|
|
61
67
|
- Add interactive UI example Snap ([#2171](https://github.com/MetaMask/snaps/pull/2171))
|
|
62
68
|
|
|
63
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.
|
|
69
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.4.0...HEAD
|
|
70
|
+
[2.4.0]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.3.0...@metamask/interactive-ui-example-snap@2.4.0
|
|
64
71
|
[2.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/interactive-ui-example-snap@2.2.1...@metamask/interactive-ui-example-snap@2.3.0
|
|
65
72
|
[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
|
|
66
73
|
[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
|
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={12:e=>{e.exports=a,a.default=a,a.stable=d,a.stableStringify=d;var t="[...]",n="[Circular]",r=[],o=[];function i(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function a(e,t,n,a){var s;void 0===a&&(a=i()),c(e,"",0,[],void 0,0,a);try{s=0===o.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 a=Object.getOwnPropertyDescriptor(i,n);void 0!==a.get?a.configurable?(Object.defineProperty(i,n,{value:e}),r.push([i,n,t,a])):o.push([t,n,e]):(i[n]=e,r.push([i,n,t]))}function c(e,r,o,i,a,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,a);if(void 0!==d.depthLimit&&u>d.depthLimit)return void s(t,e,r,a);if(void 0!==d.edgesLimit&&o+1>d.edgesLimit)return void s(t,e,r,a);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,a){void 0===a&&(a=i());var s,c=l(e,"",0,[],void 0,0,a)||e;try{s=0===o.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,o,i,a,c,d,p){var f;if(d+=1,"object"==typeof e&&null!==e){for(f=0;f<a.length;f++)if(a[f]===e)return void s(n,e,o,c);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==p.depthLimit&&d>p.depthLimit)return void s(t,e,o,c);if(void 0!==p.edgesLimit&&i+1>p.edgesLimit)return void s(t,e,o,c);if(a.push(e),Array.isArray(e))for(f=0;f<e.length;f++)l(e[f],f,f,a,e,d,p);else{var h={},m=Object.keys(e).sort(u);for(f=0;f<m.length;f++){var v=m[f];l(e[v],v,f,a,e,d,p),h[v]=e[v]}if(void 0===c)return h;r.push([c,o,e]),c[o]=h}a.pop()}}function p(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 i=o[r];if(i[1]===t&&i[0]===n){n=i[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 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)}n.r(r),n.d(r,{onHomePage:()=>pt,onRpcRequest:()=>lt,onTransaction:()=>ft,onUserInput:()=>ht});var o={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},i={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},a={"-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,...i}=e,{path:a}=e,s=0===a.length?r:`At path: ${a.join(".")} -- ${r}`;super(o??s),null!=o&&(this.cause=s),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}}function l(e){return"object"==typeof e&&null!==e}function p(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function f(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:o,branch:i}=t,{type:a}=n,{refinement:s,message:c=`Expected a value of type \`${a}\`${s?` with refinement \`${s}\``:""}, but received: \`${p(r)}\``}=e;return{value:r,type:a,refinement:s,key:o[o.length-1],path:o,branch:i,...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=f(o,t,n,r);e&&(yield e)}}function*m(e,t,n={}){const{path:r=[],branch:o=[e],coerce:i=!1,mask:a=!1}=n,s={path:r,branch:o};if(i&&(e=t.coercer(e,s),a&&"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,p]of t.entries(e,s)){const t=m(d,p,{path:void 0===u?r:[...r,u],branch:void 0===u?o:[...o,d],coerce:i,mask:a,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&&(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:i=(e=>e),entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=i,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=E(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return E(e,this,t)}}function y(e,t,n){const r=E(e,t,{message:n});if(r[0])throw r[0]}function g(e,t,n){const r=E(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function b(e,t){return!E(e,t)[0]}function E(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 O(...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: ${p(e)}`,coercer:e=>l(e)?{...e}:e})}(r):A(r)}function S(e,t){return new v({type:e,schema:null,validator:t})}function w(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: ${p(e)}`})}function j(){return S("boolean",(e=>"boolean"==typeof e))}function N(e){const t=p(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: ${p(n)}`})}function k(){return S("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 S("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${p(e)}`))}function A(e){const t=e?Object.keys(e):[],n=k();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: ${p(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: ${p(e)}`})}function C(){return S("string",(e=>"string"==typeof e||`Expected a string, but received: ${p(e)}`))}function _(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),[i]=e;if(!i?.[0])return[];for(const[t]of e)t&&o.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${p(n)}`,...o]}})}function T(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 U=e=>A(e);function z({path:e,branch:t}){const n=e[e.length-1];return c(t[t.length-2],n)}function M(e){return new v({...e,type:`optional ${e.type}`,validator:(t,n)=>!z(n)||e.validator(t,n),refiner:(t,n)=>!z(n)||e.refiner(t,n)})}const B=_([N(null),j(),S("finite number",(e=>b(e,P())&&Number.isFinite(e))),C(),x(w((()=>B))),$(C(),w((()=>B)))]),L=T(B,S("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 D(e){try{return function(e){g(e,L)}(e),!0}catch{return!1}}const G=N("2.0"),W=I(_([P(),C()])),X=U({code:S("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${p(e)}`)),message:C(),data:M(L),stack:M(C())}),H=_([$(C(),L),x(L)]);U({id:W,jsonrpc:G,method:C(),params:M(H)}),U({jsonrpc:G,method:C(),params:M(H)});A({id:W,jsonrpc:G,result:R(S("unknown",(()=>!0))),error:R(X)});const Q=U({id:W,jsonrpc:G,result:L}),Y=U({id:W,jsonrpc:G,error:X});_([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(a,t))return a[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=>D(e)?e:s(e)?ne(e):null)):s(e)?ne(e):D(e)?e:null}function ne(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return D(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(),ae,2)}},ie=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 ae(e,t){if("[Circular]"!==t)return t}var se=e=>we(o.parse,e),ce=e=>we(o.invalidRequest,e),ue=e=>we(o.invalidParams,e),de=e=>we(o.methodNotFound,e),le=e=>we(o.internal,e),pe=e=>we(o.invalidInput,e),fe=e=>we(o.resourceNotFound,e),he=e=>we(o.resourceUnavailable,e),me=e=>we(o.transactionRejected,e),ve=e=>we(o.methodNotSupported,e),ye=e=>we(o.limitExceeded,e),ge=e=>xe(i.userRejectedRequest,e),be=e=>xe(i.unauthorized,e),Ee=e=>xe(i.unsupportedMethod,e),Oe=e=>xe(i.disconnected,e),Se=e=>xe(i.chainDisconnected,e);function we(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 ie(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 Ne(e){return s(e)&&c(e,"data")&&"object"==typeof e.data&&null!==e.data&&D(e.data)&&!Array.isArray(e.data)?e.data:{}}class ke extends Error{#e;#t;#n;#r;constructor(e,t={}){const n=function(e){return s(e)&&c(e,"message")&&"string"==typeof e.message?e.message:String(e)}(e);super(n),this.#t=n,this.#e=function(e){return s(e)&&c(e,"code")&&"number"==typeof e.code&&Number.isInteger(e.code)?e.code:-32603}(e);const r={...Ne(e),...t};Object.keys(r).length>0&&(this.#n=r),this.#r=super.stack}get name(){return"SnapError"}get code(){return this.#e}get message(){return this.#t}get data(){return this.#n}get stack(){return this.#r}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 Ie(e){return class extends ke{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})}}}Ie(le),Ie(pe),Ie(ue),Ie(ce),Ie(ye);const Pe=Ie(de);Ie(ve),Ie(se),Ie(fe),Ie(he),Ie(me),Ie(Se),Ie(Oe),Ie(be),Ie(Ee),Ie(ge);var Ae;!function(e){e.ButtonClickEvent="ButtonClickEvent",e.FormSubmitEvent="FormSubmitEvent",e.InputChangeEvent="InputChangeEvent",e.FileUploadEvent="FileUploadEvent"}(Ae||(Ae={}));const Re=A({type:C(),name:R(C())}),$e=O(Re,A({type:N(Ae.ButtonClickEvent),name:R(C())})),Ce=A({name:C(),size:P(),contentType:C(),contents:C()}),_e=O(Re,A({type:N(Ae.FormSubmitEvent),value:$(C(),I(_([C(),Ce,j()]))),name:C()})),Te=O(Re,A({type:N(Ae.InputChangeEvent),name:C(),value:_([C(),j()])}));_([$e,_e,Te,O(Re,A({type:N(Ae.FileUploadEvent),name:C(),file:I(Ce)}))]);function Je(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e)))}function Fe(e){return t=>{const{key:n=null,...r}=t;return{type:e,props:Je(r),key:n}}}const qe=Fe("Box"),Ue=Fe("Heading"),ze=Fe("Form"),Me=Fe("Field"),Be=Fe("Input"),Le=Fe("Dropdown"),De=Fe("Option"),Ge=Fe("RadioGroup"),We=Fe("Radio"),Xe=Fe("Checkbox"),He=Fe("Selector"),Qe=Fe("SelectorOption"),Ye=Fe("Card"),Ke=Fe("Button"),Ve=()=>t(qe,{children:[e(Ue,{children:"Interactive UI Example Snap"}),t(ze,{name:"example-form",children:[e(Me,{label:"Example Input",children:e(Be,{name:"example-input",placeholder:"Enter something..."})}),e(Me,{label:"Example Dropdown",children:t(Le,{name:"example-dropdown",children:[e(De,{value:"option1",children:"Option 1"}),e(De,{value:"option2",children:"Option 2"}),e(De,{value:"option3",children:"Option 3"})]})}),e(Me,{label:"Example RadioGroup",children:t(Ge,{name:"example-radiogroup",children:[e(We,{value:"option1",children:"Option 1"}),e(We,{value:"option2",children:"Option 2"}),e(We,{value:"option3",children:"Option 3"})]})}),e(Me,{label:"Example Checkbox",children:e(Xe,{name:"example-checkbox",label:"Checkbox"})}),e(Me,{label:"Example Selector",children:t(He,{name:"example-selector",title:"Choose an option",value:"option1",children:[e(Qe,{value:"option1",children:e(Ye,{title:"Option 1",value:"option1"})}),e(Qe,{value:"option2",children:e(Ye,{title:"Option 2",value:"option2"})}),e(Qe,{value:"option3",children:e(Ye,{title:"Option 3",value:"option3"})})]})}),e(qe,{center:!0,children:e(Ke,{type:"submit",name:"submit",children:"Submit"})})]})]}),Ze=Fe("Row"),et=Fe("Address"),tt=Fe("Text"),nt=({from:n,to:r})=>t(qe,{children:[e(Ze,{label:"From",children:e(et,{address:n})}),e(Ze,{label:"To",children:r?e(et,{address:r}):e(tt,{children:"None"})}),e(Ke,{name:"transaction-type",children:"See transaction type"})]}),rt=Fe("Bold"),ot=({type:n})=>t(qe,{children:[e(Ze,{label:"Transaction Type",children:e(tt,{children:e(rt,{children:n})})}),e(Ke,{name:"go-back",children:"Back"})]}),it=Fe("Copyable"),at=({values:n})=>t(qe,{children:[e(Ue,{children:"Interactive UI Example Snap"}),e(tt,{children:"You submitted the following values:"}),e(qe,{children:Object.values(n).map((t=>{var n;return e(it,{value:(null===(n=t)||void 0===n?void 0:n.toString())??""})}))}),e(qe,{center:!0,children:e(Ke,{name:"back",children:"Back"})})]});function st(e,t){return ct(e,"pattern",(n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`))}function ct(e,t,n){return new v({...e,*refiner(r,o){yield*e.refiner(r,o);const i=h(n(r,o),o,e,r);for(const e of i)yield{...e,refinement:t}}})}st(C(),/^(?:0x)?[0-9a-f]+$/iu),st(C(),/^0x[0-9a-f]+$/iu),st(C(),/^0x[0-9a-f]{40}$/u),st(C(),/^0x[0-9a-fA-F]{40}$/u);function ut(e){return e.startsWith("0x")||e.startsWith("0X")?e.substring(2):e}const dt=[{name:"ERC-20",signature:"a9059cbb"},{name:"ERC-721",signature:"23b872dd"},{name:"ERC-1155",signature:"f242432a"}];const lt=async({request:t})=>{if("dialog"===t.method)return await snap.request({method:"snap_dialog",params:{type:"confirmation",content:e(Ve,{})}});throw new Pe({method:t.method})},pt=async()=>({content:e(Ve,{})}),ft=async({transaction:t})=>{const{from:n,to:r}=t;return{id:await snap.request({method:"snap_createInterface",params:{ui:e(nt,{from:n,to:r}),context:{transaction:t}}})}},ht=async({id:t,event:n,context:r})=>{if(n.type===Ae.ButtonClickEvent)switch(n.name){case"transaction-type":{var o;const n=function(e){if(e&&"string"==typeof e){var t;const n=ut(e).slice(0,8);return(null===(t=dt.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(ot,{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(nt,{from:n.from,to:n.to})}});break}case"back":await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(Ve,{})}})}if(n.type===Ae.FormSubmitEvent&&"example-form"===n.name){const r=n.value;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(at,{values:r})}})}}})();var o=exports;for(var i in r)o[i]=r[i];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{var e={836:e=>{e.exports=i,i.default=i,i.stable=d,i.stableStringify=d;var t="[...]",n="[Circular]",r=[],a=[];function o(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function i(e,t,n,i){var s;void 0===i&&(i=o()),c(e,"",0,[],void 0,0,i);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,o){var i=Object.getOwnPropertyDescriptor(o,n);void 0!==i.get?i.configurable?(Object.defineProperty(o,n,{value:e}),r.push([o,n,t,i])):a.push([t,n,e]):(o[n]=e,r.push([o,n,t]))}function c(e,r,a,o,i,u,d){var l;if(u+=1,"object"==typeof e&&null!==e){for(l=0;l<o.length;l++)if(o[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&&a+1>d.edgesLimit)return void s(t,e,r,i);if(o.push(e),Array.isArray(e))for(l=0;l<e.length;l++)c(e[l],l,l,o,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,o,e,u,d)}}o.pop()}}function u(e,t){return e<t?-1:e>t?1:0}function d(e,t,n,i){void 0===i&&(i=o());var s,c=l(e,"",0,[],void 0,0,i)||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,o,i,c,d,p){var f;if(d+=1,"object"==typeof e&&null!==e){for(f=0;f<i.length;f++)if(i[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&&o+1>p.edgesLimit)return void s(t,e,a,c);if(i.push(e),Array.isArray(e))for(f=0;f<e.length;f++)l(e[f],f,f,i,e,d,p);else{var h={},m=Object.keys(e).sort(u);for(f=0;f<m.length;f++){var v=m[f];l(e[v],v,f,i,e,d,p),h[v]=e[v]}if(void 0===c)return h;r.push([c,a,e]),c[a]=h}i.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 o=a[r];if(o[1]===t&&o[0]===n){n=o[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 o=t[r]={exports:{}};return e[r](o,o.exports,n),o.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:()=>$t,onRpcRequest:()=>Pt,onTransaction:()=>zt,onUserInput:()=>Rt});const o=(e,t)=>Object.hasOwnProperty.call(e,t);var i;!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"}(i=i||(i={}));var s=n(836);class c extends TypeError{constructor(e,t){let n;const{message:r,explanation:a,...o}=e,{path:i}=e,s=0===i.length?r:`At path: ${i.join(".")} -- ${r}`;super(a??s),null!=a&&(this.cause=s),Object.assign(this,o),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:o}=t,{type:i}=n,{refinement:s,message:c=`Expected a value of type \`${i}\`${s?` with refinement \`${s}\``:""}, but received: \`${d(r)}\``}=e;return{value:r,type:i,refinement:s,key:a[a.length-1],path:a,branch:o,...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:o=!1,mask:i=!1}=n,s={path:r,branch:a};if(o&&(e=t.coercer(e,s),i&&"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:o,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]):o&&(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 h{constructor(e){const{type:t,schema:n,validator:r,refiner:a,coercer:o=e=>e,entries:i=function*(){}}=e;this.type=t,this.schema=n,this.entries=i,this.coercer=o,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 function(e,t,n){const r=g(e,t,{message:n});if(r[0])throw r[0]}(e,this,t)}create(e,t){return y(e,this,t)}is(e){return b(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)}}const m="EXACT_OPTIONAL";class v extends h{constructor(e){super({...e,type:`exact optional ${e.type}`}),this.brand=m}static isExactOptional(e){return u(e)&&"brand"in e&&e.brand===m}}function y(e,t,n){const r=g(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function b(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 w(...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 h({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):I(r)}function E(e,t){return new h({type:e,schema:null,validator:t})}function O(){return E("boolean",(e=>"boolean"==typeof e))}function x(e){const t=d(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: ${d(n)}`})}function S(){return E("never",(()=>!1))}function A(e){return new h({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}function j(){return E("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${d(e)}`))}function I(e){const t=e?Object.keys(e):[],n=S();return new h({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);const t=e[n];v.isExactOptional(t)&&!Object.prototype.hasOwnProperty.call(r,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 k(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 N(e,t){return new h({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 C(){return E("string",(e=>"string"==typeof e||`Expected a string, but received: ${d(e)}`))}function P(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]=f(n,t,r),[o]=e;if(!o?.[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 $(e,t,n){return new h({...e,coercer:(r,a)=>b(r,t)?e.coercer(n(r,a),a):e.coercer(r,a)})}function z(e,t){return R(e,"pattern",(n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`))}function R(e,t,n){return new h({...e,*refiner(r,a){yield*e.refiner(r,a);const o=p(n(r,a),a,e,r);for(const e of o)yield{...e,refinement:t}}})}const T=e=>I(e);function _({path:e,branch:t}){const n=e[e.length-1];return o(t[t.length-2],n)}function J(e){return new h({...e,type:`optional ${e.type}`,validator:(t,n)=>!_(n)||e.validator(t,n),refiner:(t,n)=>!_(n)||e.refiner(t,n)})}function F(e){if(null===e||"boolean"==typeof e||"string"==typeof e)return!0;if("number"==typeof e&&Number.isFinite(e))return!0;if("object"==typeof e){let t=!0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)if(!F(e[n])){t=!1;break}return t}const n=Object.entries(e);for(let e=0;e<n.length;e++)if("string"!=typeof n[e][0]||!F(n[e][1])){t=!1;break}return t}return!1}const q=E("JSON",(e=>F(e))),M=$(q,R(E("any",(()=>!0)),"JSON",(e=>b(e,q))),(e=>JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t})))));function U(e){try{return function(e){y(e,M)}(e),!0}catch{return!1}}const Z=x("2.0"),L=A(P([j(),C()])),B=T({code:E("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${d(e)}`)),message:C(),data:J(M),stack:J(C())}),W=P([N(C(),M),(D=M,new h({type:"array",schema:D,*entries(e){if(D&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,D]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${d(e)}`}))]);var D;T({id:L,jsonrpc:Z,method:C(),params:J(W)}),T({jsonrpc:Z,method:C(),params:J(W)});I({id:L,jsonrpc:Z,result:k(E("unknown",(()=>!0))),error:k(B)});const X=T({id:L,jsonrpc:Z,result:M}),G=T({id:L,jsonrpc:Z,error:B});P([X,G]);const H={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},Q={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},K={"-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."}},Y=H.internal,V=(ee(Y),"Unspecified server error.");function ee(e,t="Unspecified error message. This is a bug, please report it."){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(o(K,t))return K[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return V}return t}function te(e){return Array.isArray(e)?e.map((e=>U(e)?e:a(e)?ne(e):null)):a(e)?ne(e):U(e)?e:null}function ne(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return U(r)&&(t[n]=r),t}),{})}const re=function(e){return e?.__esModule?e.default:e}(s);class ae 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.');!function(e){return a(e)&&o(e,"cause")&&a(e.cause)}(n)?super(t):(super(t,{cause:n.cause}),o(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)}}class oe extends ae{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}const se=e=>xe(H.parse,e),ce=e=>xe(H.invalidRequest,e),ue=e=>xe(H.invalidParams,e),de=e=>xe(H.methodNotFound,e),le=e=>xe(H.internal,e),pe=e=>xe(H.invalidInput,e),fe=e=>xe(H.resourceNotFound,e),he=e=>xe(H.resourceUnavailable,e),me=e=>xe(H.transactionRejected,e),ve=e=>xe(H.methodNotSupported,e),ye=e=>xe(H.limitExceeded,e),be=e=>Se(Q.userRejectedRequest,e),ge=e=>Se(Q.unauthorized,e),we=e=>Se(Q.unsupportedMethod,e),Ee=e=>Se(Q.disconnected,e),Oe=e=>Se(Q.chainDisconnected,e);function xe(e,t){const[n,r]=Ae(t);return new ae(e,n??ee(e),r)}function Se(e,t){const[n,r]=Ae(t);return new oe(e,n??ee(e),r)}function Ae(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 je(e){return a(e)&&o(e,"data")&&"object"==typeof e.data&&null!==e.data&&U(e.data)&&!Array.isArray(e.data)?e.data:{}}var Ie,ke,Ne,Ce,Pe=function(e,t,n,r,a){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?a.call(e,n):a?a.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 ze extends Error{constructor(e,t={}){const n=function(e){return a(e)&&o(e,"message")&&"string"==typeof e.message?e.message:String(e)}(e);super(n),Ie.set(this,void 0),ke.set(this,void 0),Ne.set(this,void 0),Ce.set(this,void 0),Pe(this,ke,n,"f"),Pe(this,Ie,function(e){return a(e)&&o(e,"code")&&"number"==typeof e.code&&Number.isInteger(e.code)?e.code:-32603}(e),"f");const r={...je(e),...t};Object.keys(r).length>0&&Pe(this,Ne,r,"f"),Pe(this,Ce,super.stack,"f")}get name(){return"SnapError"}get code(){return $e(this,Ie,"f")}get message(){return $e(this,ke,"f")}get data(){return $e(this,Ne,"f")}get stack(){return $e(this,Ce,"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 Re(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})}}}Ie=new WeakMap,ke=new WeakMap,Ne=new WeakMap,Ce=new WeakMap;Re(le),Re(pe),Re(ue),Re(ce),Re(ye);const Te=Re(de);Re(ve),Re(se),Re(fe),Re(he),Re(me),Re(Oe),Re(Ee),Re(ge),Re(we),Re(be);function _e(e,t){return E(e,(e=>"string"==typeof e&&t.test(e)))}const Je=/^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})$/u,Fe=/^[-a-z0-9]{3,8}$/u,qe=/^[-_a-zA-Z0-9]{1,32}$/u,Me=/^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})):(?<accountAddress>[-.%a-zA-Z0-9]{1,128})$/u,Ue=/^[-.%a-zA-Z0-9]{1,128}$/u,Ze=/^[-a-z0-9]{3,8}$/u,Le=/^[-.%a-zA-Z0-9]{1,128}$/u,Be=/^[-.%a-zA-Z0-9]{1,78}$/u,We=/^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u,De=/^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u,Xe=(_e("CaipChainId",Je),_e("CaipNamespace",Fe),_e("CaipReference",qe),_e("CaipAccountId",Me),_e("CaipAccountAddress",Ue),_e("CaipAssetNamespace",Ze),_e("CaipAssetReference",Le),_e("CaipTokenId",Be),_e("CaipAssetType",We));_e("CaipAssetId",De),_e("CaipAssetTypeOrId",/^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})(\/(?<tokenId>[-.%a-zA-Z0-9]{1,78}))?$/u);var Ge,He;!function(e){e.Bip122="bip122",e.Solana="solana",e.Eip155="eip155",e.Wallet="wallet"}(Ge=Ge||(Ge={})),function(e){e.ButtonClickEvent="ButtonClickEvent",e.FormSubmitEvent="FormSubmitEvent",e.InputChangeEvent="InputChangeEvent",e.FileUploadEvent="FileUploadEvent"}(He||(He={}));const Qe=I({type:C(),name:k(C())}),Ke=w(Qe,I({type:x(He.ButtonClickEvent),name:k(C())})),Ye=I({name:C(),size:j(),contentType:C(),contents:C()}),Ve=I({asset:Xe,name:C(),symbol:C()}),et=w(Qe,I({type:x(He.FormSubmitEvent),value:N(C(),A(P([C(),Ye,O(),Ve]))),name:C()})),tt=w(Qe,I({type:x(He.InputChangeEvent),name:C(),value:P([C(),O(),Ve])}));P([Ke,et,tt,w(Qe,I({type:x(He.FileUploadEvent),name:C(),file:A(Ye)}))]);function nt(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e)))}function rt(e){return t=>{const{key:n=null,...r}=t;return{type:e,props:nt(r),key:n}}}const at=rt("Container"),ot=rt("Box"),it=rt("Heading"),st=rt("Form"),ct=rt("Field"),ut=rt("Input"),dt=rt("Dropdown"),lt=rt("Option"),pt=rt("RadioGroup"),ft=rt("Radio"),ht=rt("Checkbox"),mt=rt("Selector"),vt=rt("SelectorOption"),yt=rt("Card"),bt=rt("Footer"),gt=rt("Button"),wt=({disabled:n})=>t(at,{children:[t(ot,{children:[e(it,{children:"Interactive UI Example Snap"}),t(st,{name:"example-form",children:[e(ct,{label:"Example Input",children:e(ut,{name:"example-input",placeholder:"Enter something...",disabled:n})}),e(ct,{label:"Example Dropdown",children:t(dt,{name:"example-dropdown",disabled:n,children:[e(lt,{value:"option1",children:"Option 1"}),e(lt,{value:"option2",children:"Option 2"}),e(lt,{value:"option3",children:"Option 3"})]})}),e(ct,{label:"Example RadioGroup",children:t(pt,{name:"example-radiogroup",disabled:n,children:[e(ft,{value:"option1",children:"Option 1"}),e(ft,{value:"option2",children:"Option 2"}),e(ft,{value:"option3",children:"Option 3"})]})}),e(ct,{label:"Example Checkbox",children:e(ht,{name:"example-checkbox",label:"Checkbox",disabled:n})}),e(ct,{label:"Example Selector",children:t(mt,{name:"example-selector",title:"Choose an option",value:"option1",disabled:n,children:[e(vt,{value:"option1",children:e(yt,{title:"Option 1",value:"option1"})}),e(vt,{value:"option2",children:e(yt,{title:"Option 2",value:"option2"})}),e(vt,{value:"option3",children:e(yt,{title:"Option 3",value:"option3"})})]})})]})]}),e(bt,{children:e(gt,{type:"submit",name:"submit",form:"example-form",disabled:n,children:"Submit"})})]}),Et=rt("Row"),Ot=rt("Address"),xt=rt("Text"),St=({from:n,to:r})=>t(ot,{children:[e(Et,{label:"From",children:e(Ot,{address:n})}),e(Et,{label:"To",children:r?e(Ot,{address:r}):e(xt,{children:"None"})}),e(gt,{name:"transaction-type",children:"See transaction type"})]}),At=rt("Bold"),jt=({type:n})=>t(ot,{children:[e(Et,{label:"Transaction Type",children:e(xt,{children:e(At,{children:n})})}),e(gt,{name:"go-back",children:"Back"})]}),It=rt("Copyable"),kt=({values:n})=>t(at,{children:[t(ot,{children:[e(it,{children:"Interactive UI Example Snap"}),e(xt,{children:"You submitted the following values:"}),e(ot,{children:Object.values(n).map((t=>{var n;return e(It,{value:(null===(n=t)||void 0===n?void 0:n.toString())??""})}))})]}),t(bt,{children:[e(gt,{name:"back",children:"Back"}),e(gt,{name:"ok",children:"OK"})]})]});z(C(),/^(?:0x)?[0-9a-f]+$/iu),z(C(),/^0x[0-9a-f]+$/iu),z(C(),/^0x[0-9a-f]{40}$/u),z(C(),/^0x[0-9a-fA-F]{40}$/u);function Nt(e){return e.startsWith("0x")||e.startsWith("0X")?e.substring(2):e}const Ct=[{name:"ERC-20",signature:"a9059cbb"},{name:"ERC-721",signature:"23b872dd"},{name:"ERC-1155",signature:"f242432a"}];const Pt=async({request:t})=>{if("dialog"===t.method){var n;const r=null===(n=t.params)||void 0===n?void 0:n.disabled,a=await snap.request({method:"snap_createInterface",params:{ui:e(wt,{disabled:r}),context:{disabled:r}}});return await snap.request({method:"snap_dialog",params:{id:a}})}throw new Te({method:t.method})},$t=async()=>({content:e(wt,{})}),zt=async({transaction:t})=>{const{from:n,to:r}=t;return{id:await snap.request({method:"snap_createInterface",params:{ui:e(St,{from:n,to:r}),context:{transaction:t}}})}},Rt=async({id:t,event:n,context:r})=>{if(n.type===He.ButtonClickEvent)switch(n.name){case"transaction-type":{var a;const n=function(e){if(e&&"string"==typeof e){var t;const n=Nt(e).slice(0,8);return(null===(t=Ct.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(jt,{type:n})}});break}case"go-back":{var o;const n=null===(o=r)||void 0===o?void 0:o.transaction;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(St,{from:n.from,to:n.to})}});break}case"back":var i;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(wt,{disabled:null===(i=r)||void 0===i?void 0:i.disabled})}});break;case"ok":await snap.request({method:"snap_resolveInterface",params:{id:t,value:null}})}if(n.type===He.FormSubmitEvent&&"example-form"===n.name){const r=n.value;await snap.request({method:"snap_updateInterface",params:{id:t,ui:e(kt,{values:r})}})}}})(),module.exports=r})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/interactive-ui-example-snap",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "MetaMask example snap demonstrating the use of interactive UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn changelog:validate && yarn lint:dependencies",
|
|
32
32
|
"lint:ci": "yarn lint",
|
|
33
33
|
"lint:dependencies": "depcheck",
|
|
34
|
-
"lint:eslint": "eslint . --cache
|
|
34
|
+
"lint:eslint": "eslint . --cache",
|
|
35
35
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
|
|
36
|
-
"lint:misc": "prettier --no-error-on-unmatched-pattern --
|
|
36
|
+
"lint:misc": "prettier --no-error-on-unmatched-pattern --log-level warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" \"!snap.manifest.json\" --ignore-path ../../../../.gitignore",
|
|
37
37
|
"publish:preview": "yarn npm publish --tag preview",
|
|
38
38
|
"since-latest-release": "../../../../scripts/since-latest-release.sh",
|
|
39
39
|
"start": "mm-snap watch",
|
|
@@ -43,37 +43,24 @@
|
|
|
43
43
|
"test:watch": "jest --watch"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@metamask/snaps-sdk": "^6.
|
|
47
|
-
"@metamask/utils": "^
|
|
46
|
+
"@metamask/snaps-sdk": "^6.22.0",
|
|
47
|
+
"@metamask/utils": "^11.2.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@jest/globals": "^29.5.0",
|
|
51
51
|
"@lavamoat/allow-scripts": "^3.0.4",
|
|
52
|
-
"@metamask/auto-changelog": "^
|
|
53
|
-
"@metamask/
|
|
54
|
-
"@metamask/
|
|
55
|
-
"@metamask/eslint-config-nodejs": "^12.1.0",
|
|
56
|
-
"@metamask/eslint-config-typescript": "^12.1.0",
|
|
57
|
-
"@metamask/snaps-cli": "^6.3.3",
|
|
58
|
-
"@metamask/snaps-jest": "^8.4.0",
|
|
52
|
+
"@metamask/auto-changelog": "^5.0.1",
|
|
53
|
+
"@metamask/snaps-cli": "^6.7.0",
|
|
54
|
+
"@metamask/snaps-jest": "^8.14.1",
|
|
59
55
|
"@swc/core": "1.3.78",
|
|
60
56
|
"@swc/jest": "^0.2.26",
|
|
61
|
-
"@
|
|
62
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
57
|
+
"@types/node": "18.14.2",
|
|
63
58
|
"deepmerge": "^4.2.2",
|
|
64
59
|
"depcheck": "^1.4.7",
|
|
65
|
-
"eslint": "^
|
|
66
|
-
"eslint-config-prettier": "^8.5.0",
|
|
67
|
-
"eslint-plugin-import": "^2.26.0",
|
|
68
|
-
"eslint-plugin-jest": "^27.1.5",
|
|
69
|
-
"eslint-plugin-jsdoc": "^41.1.2",
|
|
70
|
-
"eslint-plugin-n": "^15.7.0",
|
|
71
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
72
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
60
|
+
"eslint": "^9.11.0",
|
|
73
61
|
"jest": "^29.0.2",
|
|
74
62
|
"jest-silent-reporter": "^0.6.0",
|
|
75
|
-
"prettier": "^
|
|
76
|
-
"prettier-plugin-packagejson": "^2.5.2",
|
|
63
|
+
"prettier": "^3.3.3",
|
|
77
64
|
"rimraf": "^4.1.2",
|
|
78
65
|
"ts-node": "^10.9.1",
|
|
79
66
|
"typescript": "~5.3.3"
|
package/snap.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.4.0",
|
|
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": "
|
|
10
|
+
"shasum": "I+kz7pvB5o7oyC/2z5LnURYG7TrTHR9+oWueIcsuDyA=",
|
|
11
11
|
"location": {
|
|
12
12
|
"npm": {
|
|
13
13
|
"filePath": "dist/bundle.js",
|
|
@@ -25,5 +25,6 @@
|
|
|
25
25
|
"endowment:transaction-insight": {},
|
|
26
26
|
"endowment:page-home": {}
|
|
27
27
|
},
|
|
28
|
+
"platformVersion": "6.22.0",
|
|
28
29
|
"manifestVersion": "0.1"
|
|
29
30
|
}
|