@metamask/interactive-ui-example-snap 2.2.1 → 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 +34 -1
- package/dist/bundle.js +1 -1
- package/package.json +33 -32
- package/snap.manifest.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
2
3
|
All notable changes to this project will be documented in this file.
|
|
3
4
|
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
@@ -6,36 +7,68 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
7
|
|
|
7
8
|
## [Unreleased]
|
|
8
9
|
|
|
10
|
+
## [2.4.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add disabled state ([#3293](https://github.com/MetaMask/snaps/pull/3293))
|
|
15
|
+
|
|
16
|
+
## [2.3.0]
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Add example for `Selector` component ([#2724](https://github.com/MetaMask/snaps/pull/2724))
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- Fix wrong address being shown on transaction insights ([#2733](https://github.com/MetaMask/snaps/pull/2733))
|
|
25
|
+
|
|
9
26
|
## [2.2.1]
|
|
27
|
+
|
|
10
28
|
### Fixed
|
|
29
|
+
|
|
11
30
|
- Bump MetaMask dependencies
|
|
12
31
|
|
|
13
32
|
## [2.2.0]
|
|
33
|
+
|
|
14
34
|
### Added
|
|
35
|
+
|
|
15
36
|
- Add `RadioGroup` to interactive UI example ([#2592](https://github.com/MetaMask/snaps/pull/2592))
|
|
16
37
|
|
|
17
38
|
## [2.1.0]
|
|
39
|
+
|
|
18
40
|
### Added
|
|
41
|
+
|
|
19
42
|
- Add `Checkbox` to interactive UI example ([#2515](https://github.com/MetaMask/snaps/pull/2515))
|
|
20
43
|
|
|
21
44
|
## [2.0.0]
|
|
45
|
+
|
|
22
46
|
### Changed
|
|
47
|
+
|
|
23
48
|
- **BREAKING:** Revamp interactive UI example using JSX ([#2427](https://github.com/MetaMask/snaps/pull/2427))
|
|
24
49
|
- The `getState` RPC method was removed as part of this refactor.
|
|
25
50
|
|
|
26
51
|
## [1.0.2]
|
|
52
|
+
|
|
27
53
|
### Fixed
|
|
54
|
+
|
|
28
55
|
- Fix a crash when submitting an empty string ([#2333](https://github.com/MetaMask/snaps/pull/2333))
|
|
29
56
|
|
|
30
57
|
## [1.0.1]
|
|
58
|
+
|
|
31
59
|
### Changed
|
|
60
|
+
|
|
32
61
|
- Use error wrappers ([#2178](https://github.com/MetaMask/snaps/pull/2178))
|
|
33
62
|
|
|
34
63
|
## [1.0.0]
|
|
64
|
+
|
|
35
65
|
### Added
|
|
66
|
+
|
|
36
67
|
- Add interactive UI example Snap ([#2171](https://github.com/MetaMask/snaps/pull/2171))
|
|
37
68
|
|
|
38
|
-
[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
|
|
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
|
|
39
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
|
|
40
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
|
|
41
74
|
[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
|
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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})})();
|
|
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,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/interactive-ui-example-snap",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "MetaMask example snap demonstrating the use of interactive UI
|
|
3
|
+
"version": "2.4.0",
|
|
4
|
+
"description": "MetaMask example snap demonstrating the use of interactive UI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"MetaMask",
|
|
7
|
+
"Snaps",
|
|
8
|
+
"Ethereum"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/MetaMask/snaps/tree/main/packages/examples/packages/interactive-ui#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/MetaMask/snaps/issues"
|
|
13
|
+
},
|
|
5
14
|
"repository": {
|
|
6
15
|
"type": "git",
|
|
7
16
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -10,56 +19,48 @@
|
|
|
10
19
|
"sideEffects": false,
|
|
11
20
|
"main": "./dist/bundle.js",
|
|
12
21
|
"files": [
|
|
13
|
-
"dist
|
|
22
|
+
"dist",
|
|
14
23
|
"snap.manifest.json"
|
|
15
24
|
],
|
|
16
25
|
"scripts": {
|
|
17
26
|
"build": "mm-snap build",
|
|
18
27
|
"build:clean": "yarn clean && yarn build",
|
|
28
|
+
"changelog:update": "../../../../scripts/update-changelog.sh @metamask/interactive-ui-example-snap",
|
|
29
|
+
"changelog:validate": "../../../../scripts/validate-changelog.sh @metamask/interactive-ui-example-snap",
|
|
19
30
|
"clean": "rimraf \"dist\"",
|
|
20
|
-
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn
|
|
21
|
-
"lint:changelog": "../../../../scripts/validate-changelog.sh @metamask/interactive-ui-example-snap",
|
|
31
|
+
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn changelog:validate && yarn lint:dependencies",
|
|
22
32
|
"lint:ci": "yarn lint",
|
|
23
|
-
"lint:
|
|
33
|
+
"lint:dependencies": "depcheck",
|
|
34
|
+
"lint:eslint": "eslint . --cache",
|
|
24
35
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
|
|
25
|
-
"lint:misc": "prettier --no-error-on-unmatched-pattern --
|
|
26
|
-
"start": "mm-snap watch",
|
|
27
|
-
"test": "yarn test:e2e",
|
|
28
|
-
"test:e2e": "jest",
|
|
36
|
+
"lint:misc": "prettier --no-error-on-unmatched-pattern --log-level warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" \"!snap.manifest.json\" --ignore-path ../../../../.gitignore",
|
|
29
37
|
"publish:preview": "yarn npm publish --tag preview",
|
|
30
|
-
"
|
|
38
|
+
"since-latest-release": "../../../../scripts/since-latest-release.sh",
|
|
39
|
+
"start": "mm-snap watch",
|
|
40
|
+
"test": "jest --reporters=jest-silent-reporter",
|
|
41
|
+
"test:clean": "jest --clearCache",
|
|
42
|
+
"test:verbose": "jest --verbose",
|
|
43
|
+
"test:watch": "jest --watch"
|
|
31
44
|
},
|
|
32
45
|
"dependencies": {
|
|
33
|
-
"@metamask/snaps-sdk": "^6.
|
|
34
|
-
"@metamask/utils": "^
|
|
46
|
+
"@metamask/snaps-sdk": "^6.22.0",
|
|
47
|
+
"@metamask/utils": "^11.2.0"
|
|
35
48
|
},
|
|
36
49
|
"devDependencies": {
|
|
37
50
|
"@jest/globals": "^29.5.0",
|
|
38
51
|
"@lavamoat/allow-scripts": "^3.0.4",
|
|
39
|
-
"@metamask/auto-changelog": "^
|
|
40
|
-
"@metamask/
|
|
41
|
-
"@metamask/
|
|
42
|
-
"@metamask/eslint-config-nodejs": "^12.1.0",
|
|
43
|
-
"@metamask/eslint-config-typescript": "^12.1.0",
|
|
44
|
-
"@metamask/snaps-cli": "^6.3.2",
|
|
45
|
-
"@metamask/snaps-jest": "^8.3.1",
|
|
52
|
+
"@metamask/auto-changelog": "^5.0.1",
|
|
53
|
+
"@metamask/snaps-cli": "^6.7.0",
|
|
54
|
+
"@metamask/snaps-jest": "^8.14.1",
|
|
46
55
|
"@swc/core": "1.3.78",
|
|
47
56
|
"@swc/jest": "^0.2.26",
|
|
48
|
-
"@
|
|
49
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
57
|
+
"@types/node": "18.14.2",
|
|
50
58
|
"deepmerge": "^4.2.2",
|
|
51
59
|
"depcheck": "^1.4.7",
|
|
52
|
-
"eslint": "^
|
|
53
|
-
"eslint-config-prettier": "^8.5.0",
|
|
54
|
-
"eslint-plugin-import": "^2.26.0",
|
|
55
|
-
"eslint-plugin-jest": "^27.1.5",
|
|
56
|
-
"eslint-plugin-jsdoc": "^41.1.2",
|
|
57
|
-
"eslint-plugin-n": "^15.7.0",
|
|
58
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
59
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
60
|
+
"eslint": "^9.11.0",
|
|
60
61
|
"jest": "^29.0.2",
|
|
61
|
-
"
|
|
62
|
-
"prettier
|
|
62
|
+
"jest-silent-reporter": "^0.6.0",
|
|
63
|
+
"prettier": "^3.3.3",
|
|
63
64
|
"rimraf": "^4.1.2",
|
|
64
65
|
"ts-node": "^10.9.1",
|
|
65
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
|
}
|