@metamask/snaps-jest 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/dist/cjs/internals/structs.js +4 -5
- package/dist/cjs/internals/structs.js.map +1 -1
- package/dist/esm/internals/structs.js +3 -4
- package/dist/esm/internals/structs.js.map +1 -1
- package/dist/types/internals/network.d.ts +1 -1
- package/dist/types/internals/request.d.ts +18 -0
- package/dist/types/internals/structs.d.ts +76 -16
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [4.0.1]
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fix coercing of address values in `sendTransaction` function ([#1970](https://github.com/MetaMask/snaps/pull/1970))
|
|
12
|
+
|
|
9
13
|
## [4.0.0]
|
|
10
14
|
### Changed
|
|
11
15
|
- Use `@metamask/snaps-sdk` package ([#1930](https://github.com/MetaMask/snaps/pull/1930),
|
|
@@ -77,7 +81,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
77
81
|
- The version of the package no longer needs to match the version of all other
|
|
78
82
|
MetaMask Snaps packages.
|
|
79
83
|
|
|
80
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@4.0.
|
|
84
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@4.0.1...HEAD
|
|
85
|
+
[4.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@4.0.0...@metamask/snaps-jest@4.0.1
|
|
81
86
|
[4.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@3.1.0...@metamask/snaps-jest@4.0.0
|
|
82
87
|
[3.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@3.0.0...@metamask/snaps-jest@3.1.0
|
|
83
88
|
[3.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@2.0.0...@metamask/snaps-jest@3.0.0
|
|
@@ -23,7 +23,6 @@ _export(exports, {
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
const _snapssdk = require("@metamask/snaps-sdk");
|
|
26
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
27
26
|
const _utils = require("@metamask/utils");
|
|
28
27
|
const _crypto = require("crypto");
|
|
29
28
|
const _superstruct = require("superstruct");
|
|
@@ -47,7 +46,7 @@ const TransactionOptionsStruct = (0, _superstruct.object)({
|
|
|
47
46
|
*/ // TODO: Move this coercer to `@metamask/utils`.
|
|
48
47
|
from: (0, _superstruct.coerce)(_utils.StrictHexStruct, (0, _superstruct.optional)(BytesLikeStruct), (value)=>{
|
|
49
48
|
if (value) {
|
|
50
|
-
return (0, _utils.valueToBytes)(value);
|
|
49
|
+
return (0, _utils.bytesToHex)((0, _utils.valueToBytes)(value));
|
|
51
50
|
}
|
|
52
51
|
return (0, _utils.bytesToHex)((0, _crypto.randomBytes)(20));
|
|
53
52
|
}),
|
|
@@ -57,7 +56,7 @@ const TransactionOptionsStruct = (0, _superstruct.object)({
|
|
|
57
56
|
*/ // TODO: Move this coercer to `@metamask/utils`.
|
|
58
57
|
to: (0, _superstruct.coerce)(_utils.StrictHexStruct, (0, _superstruct.optional)(BytesLikeStruct), (value)=>{
|
|
59
58
|
if (value) {
|
|
60
|
-
return (0, _utils.valueToBytes)(value);
|
|
59
|
+
return (0, _utils.bytesToHex)((0, _utils.valueToBytes)(value));
|
|
61
60
|
}
|
|
62
61
|
return (0, _utils.bytesToHex)((0, _crypto.randomBytes)(20));
|
|
63
62
|
}),
|
|
@@ -114,8 +113,8 @@ const SnapResponseStruct = (0, _superstruct.assign)(InterfaceStruct, (0, _supers
|
|
|
114
113
|
id: (0, _superstruct.string)(),
|
|
115
114
|
message: (0, _superstruct.string)(),
|
|
116
115
|
type: (0, _superstruct.union)([
|
|
117
|
-
(0,
|
|
118
|
-
(0,
|
|
116
|
+
(0, _snapssdk.enumValue)(_snapssdk.NotificationType.InApp),
|
|
117
|
+
(0, _snapssdk.enumValue)(_snapssdk.NotificationType.Native)
|
|
119
118
|
])
|
|
120
119
|
}))
|
|
121
120
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/internals/structs.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/structs.ts"],"sourcesContent":["import {\n NotificationType,\n ComponentStruct,\n enumValue,\n} from '@metamask/snaps-sdk';\nimport {\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n type,\n union,\n} from 'superstruct';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const InterfaceStruct = type({\n content: optional(ComponentStruct),\n});\n\nexport const SnapResponseStruct = assign(\n InterfaceStruct,\n object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n }),\n ),\n }),\n);\n"],"names":["TransactionOptionsStruct","SnapOptionsStruct","InterfaceStruct","SnapResponseStruct","BytesLikeStruct","union","bigint","number","string","instance","Uint8Array","object","chainId","defaulted","origin","from","coerce","StrictHexStruct","optional","value","bytesToHex","valueToBytes","randomBytes","to","gasLimit","maxFeePerGas","maxPriorityFeePerGas","nonce","data","literal","timeout","type","content","ComponentStruct","assign","id","response","result","JsonStruct","error","notifications","array","message","enumValue","NotificationType","InApp","Native"],"mappings":";;;;;;;;;;;IAoCaA,wBAAwB;eAAxBA;;IA0GAC,iBAAiB;eAAjBA;;IAQAC,eAAe;eAAfA;;IAIAC,kBAAkB;eAAlBA;;;0BAtJN;uBAMA;wBACqB;6BAerB;AAEP,oDAAoD;AACpD,MAAMC,kBAAkBC,IAAAA,kBAAK,EAAC;IAC5BC,IAAAA,mBAAM;IACNC,IAAAA,mBAAM;IACNC,IAAAA,mBAAM;IACNC,IAAAA,qBAAQ,EAACC;CACV;AAEM,MAAMV,2BAA2BW,IAAAA,mBAAM,EAAC;IAC7C;;GAEC,GACDC,SAASC,IAAAA,sBAAS,EAACL,IAAAA,mBAAM,KAAI;IAE7B;;GAEC,GACDM,QAAQD,IAAAA,sBAAS,EAACL,IAAAA,mBAAM,KAAI;IAE5B;;;GAGC,GACD,gDAAgD;IAChDO,MAAMC,IAAAA,mBAAM,EAACC,sBAAe,EAAEC,IAAAA,qBAAQ,EAACd,kBAAkB,CAACe;QACxD,IAAIA,OAAO;YACT,OAAOC,IAAAA,iBAAU,EAACC,IAAAA,mBAAY,EAACF;QACjC;QAEA,OAAOC,IAAAA,iBAAU,EAAC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ACY,sBAAe;QAAEY,IAAAA,oBAAO,EAAC;KAAM,GAAGzB,iBAAiB,CAACe,QAChEC,IAAAA,iBAAU,EAACC,IAAAA,mBAAY,EAACF,UAE1B;AAEJ;AAEO,MAAMlB,oBAAoBU,IAAAA,mBAAM,EAAC;IACtC;;;GAGC,GACDmB,SAASjB,IAAAA,sBAAS,EAACK,IAAAA,qBAAQ,EAACX,IAAAA,mBAAM,MAAK;AACzC;AAEO,MAAML,kBAAkB6B,IAAAA,iBAAI,EAAC;IAClCC,SAASd,IAAAA,qBAAQ,EAACe,yBAAe;AACnC;AAEO,MAAM9B,qBAAqB+B,IAAAA,mBAAM,EACtChC,iBACAS,IAAAA,mBAAM,EAAC;IACLwB,IAAI3B,IAAAA,mBAAM;IAEV4B,UAAU/B,IAAAA,kBAAK,EAAC;QACdM,IAAAA,mBAAM,EAAC;YACL0B,QAAQC,iBAAU;QACpB;QACA3B,IAAAA,mBAAM,EAAC;YACL4B,OAAOD,iBAAU;QACnB;KACD;IAEDE,eAAeC,IAAAA,kBAAK,EAClB9B,IAAAA,mBAAM,EAAC;QACLwB,IAAI3B,IAAAA,mBAAM;QACVkC,SAASlC,IAAAA,mBAAM;QACfuB,MAAM1B,IAAAA,kBAAK,EAAC;YACVsC,IAAAA,mBAAS,EAACC,0BAAgB,CAACC,KAAK;YAChCF,IAAAA,mBAAS,EAACC,0BAAgB,CAACE,MAAM;SAClC;IACH;AAEJ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { NotificationType, ComponentStruct } from '@metamask/snaps-sdk';
|
|
2
|
-
import { enumValue } from '@metamask/snaps-utils';
|
|
1
|
+
import { NotificationType, ComponentStruct, enumValue } from '@metamask/snaps-sdk';
|
|
3
2
|
import { bytesToHex, JsonStruct, StrictHexStruct, valueToBytes } from '@metamask/utils';
|
|
4
3
|
import { randomBytes } from 'crypto';
|
|
5
4
|
import { array, assign, bigint, coerce, defaulted, instance, literal, number, object, optional, string, type, union } from 'superstruct';
|
|
@@ -23,7 +22,7 @@ export const TransactionOptionsStruct = object({
|
|
|
23
22
|
*/ // TODO: Move this coercer to `@metamask/utils`.
|
|
24
23
|
from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value)=>{
|
|
25
24
|
if (value) {
|
|
26
|
-
return valueToBytes(value);
|
|
25
|
+
return bytesToHex(valueToBytes(value));
|
|
27
26
|
}
|
|
28
27
|
return bytesToHex(randomBytes(20));
|
|
29
28
|
}),
|
|
@@ -33,7 +32,7 @@ export const TransactionOptionsStruct = object({
|
|
|
33
32
|
*/ // TODO: Move this coercer to `@metamask/utils`.
|
|
34
33
|
to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value)=>{
|
|
35
34
|
if (value) {
|
|
36
|
-
return valueToBytes(value);
|
|
35
|
+
return bytesToHex(valueToBytes(value));
|
|
37
36
|
}
|
|
38
37
|
return bytesToHex(randomBytes(20));
|
|
39
38
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/internals/structs.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/internals/structs.ts"],"sourcesContent":["import {\n NotificationType,\n ComponentStruct,\n enumValue,\n} from '@metamask/snaps-sdk';\nimport {\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n type,\n union,\n} from 'superstruct';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const InterfaceStruct = type({\n content: optional(ComponentStruct),\n});\n\nexport const SnapResponseStruct = assign(\n InterfaceStruct,\n object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n }),\n ),\n }),\n);\n"],"names":["NotificationType","ComponentStruct","enumValue","bytesToHex","JsonStruct","StrictHexStruct","valueToBytes","randomBytes","array","assign","bigint","coerce","defaulted","instance","literal","number","object","optional","string","type","union","BytesLikeStruct","Uint8Array","TransactionOptionsStruct","chainId","origin","from","value","to","gasLimit","maxFeePerGas","maxPriorityFeePerGas","nonce","data","SnapOptionsStruct","timeout","InterfaceStruct","content","SnapResponseStruct","id","response","result","error","notifications","message","InApp","Native"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,eAAe,EACfC,SAAS,QACJ,sBAAsB;AAC7B,SACEC,UAAU,EACVC,UAAU,EACVC,eAAe,EACfC,YAAY,QACP,kBAAkB;AACzB,SAASC,WAAW,QAAQ,SAAS;AACrC,SACEC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,IAAI,EACJC,KAAK,QACA,cAAc;AAErB,oDAAo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tC;;;GAGC,GACDmB,SAASvB,UAAUK,SAASF,WAAW;AACzC,GAAG;AAEH,OAAO,MAAMqB,kBAAkBjB,KAAK;IAClCkB,SAASpB,SAAShB;AACpB,GAAG;AAEH,OAAO,MAAMqC,qBAAqB7B,OAChC2B,iBACApB,OAAO;IACLuB,IAAIrB;IAEJsB,UAAUpB,MAAM;QACdJ,OAAO;YACLyB,QAAQrC;QACV;QACAY,OAAO;YACL0B,OAAOtC;QACT;KACD;IAEDuC,eAAenC,MACbQ,OAAO;QACLuB,IAAIrB;QACJ0B,SAAS1B;QACTC,MAAMC,MAAM;YACVlB,UAAUF,iBAAiB6C,KAAK;YAChC3C,UAAUF,iBAAiB8C,MAAM;SAClC;IACH;AAEJ,IACA"}
|
|
@@ -65,8 +65,8 @@ export declare type MockOptions = Infer<typeof MockOptionsStruct>;
|
|
|
65
65
|
*/
|
|
66
66
|
export declare function mock(page: Page, options: DeepPartial<MockOptions>): Promise<Mock>;
|
|
67
67
|
declare const MockJsonRpcOptionsStruct: Struct<{
|
|
68
|
-
method: string;
|
|
69
68
|
result: import("@metamask/utils").Json;
|
|
69
|
+
method: string;
|
|
70
70
|
}, {
|
|
71
71
|
method: Struct<string, null>;
|
|
72
72
|
result: Struct<import("@metamask/utils").Json, unknown>;
|
|
@@ -51,6 +51,24 @@ export declare function sendTransaction(page: Page, options: Partial<Transaction
|
|
|
51
51
|
value: string;
|
|
52
52
|
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
53
53
|
markdown?: boolean | undefined;
|
|
54
|
+
} | {
|
|
55
|
+
value: string;
|
|
56
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
57
|
+
} | {
|
|
58
|
+
value: {
|
|
59
|
+
value: string;
|
|
60
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
61
|
+
} | {
|
|
62
|
+
value: string;
|
|
63
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
64
|
+
markdown?: boolean | undefined;
|
|
65
|
+
} | {
|
|
66
|
+
value: string;
|
|
67
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
68
|
+
};
|
|
69
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
70
|
+
label: string;
|
|
71
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
54
72
|
};
|
|
55
73
|
}>;
|
|
56
74
|
/**
|
|
@@ -87,11 +87,26 @@ export declare const InterfaceStruct: import("superstruct").Struct<{
|
|
|
87
87
|
type: import("@metamask/snaps-sdk").NodeType.Spinner;
|
|
88
88
|
} | {
|
|
89
89
|
value: string;
|
|
90
|
-
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
91
|
-
* The timeout in milliseconds to use for requests to the snap. Defaults to
|
|
92
|
-
* `1000`.
|
|
93
|
-
*/
|
|
90
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
94
91
|
markdown?: boolean | undefined;
|
|
92
|
+
} | {
|
|
93
|
+
value: string;
|
|
94
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
95
|
+
} | {
|
|
96
|
+
value: {
|
|
97
|
+
value: string;
|
|
98
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
99
|
+
} | {
|
|
100
|
+
value: string;
|
|
101
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
102
|
+
markdown?: boolean | undefined;
|
|
103
|
+
} | {
|
|
104
|
+
value: string;
|
|
105
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
106
|
+
};
|
|
107
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
108
|
+
label: string;
|
|
109
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
95
110
|
} | undefined;
|
|
96
111
|
}, {
|
|
97
112
|
content: import("superstruct").Struct<import("@metamask/snaps-sdk").Panel | {
|
|
@@ -110,11 +125,26 @@ export declare const InterfaceStruct: import("superstruct").Struct<{
|
|
|
110
125
|
type: import("@metamask/snaps-sdk").NodeType.Spinner;
|
|
111
126
|
} | {
|
|
112
127
|
value: string;
|
|
113
|
-
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
114
|
-
* The timeout in milliseconds to use for requests to the snap. Defaults to
|
|
115
|
-
* `1000`.
|
|
116
|
-
*/
|
|
128
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
117
129
|
markdown?: boolean | undefined;
|
|
130
|
+
} | {
|
|
131
|
+
value: string;
|
|
132
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
133
|
+
} | {
|
|
134
|
+
value: {
|
|
135
|
+
value: string;
|
|
136
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
137
|
+
} | {
|
|
138
|
+
value: string;
|
|
139
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
140
|
+
markdown?: boolean | undefined;
|
|
141
|
+
} | {
|
|
142
|
+
value: string;
|
|
143
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
144
|
+
};
|
|
145
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
146
|
+
label: string;
|
|
147
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
118
148
|
} | undefined, null>;
|
|
119
149
|
}>;
|
|
120
150
|
export declare const SnapResponseStruct: import("superstruct").Struct<{
|
|
@@ -145,11 +175,26 @@ export declare const SnapResponseStruct: import("superstruct").Struct<{
|
|
|
145
175
|
type: import("@metamask/snaps-sdk").NodeType.Spinner;
|
|
146
176
|
} | {
|
|
147
177
|
value: string;
|
|
148
|
-
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
149
|
-
* The timeout in milliseconds to use for requests to the snap. Defaults to
|
|
150
|
-
* `1000`.
|
|
151
|
-
*/
|
|
178
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
152
179
|
markdown?: boolean | undefined;
|
|
180
|
+
} | {
|
|
181
|
+
value: string;
|
|
182
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
183
|
+
} | {
|
|
184
|
+
value: {
|
|
185
|
+
value: string;
|
|
186
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
187
|
+
} | {
|
|
188
|
+
value: string;
|
|
189
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
190
|
+
markdown?: boolean | undefined;
|
|
191
|
+
} | {
|
|
192
|
+
value: string;
|
|
193
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
194
|
+
};
|
|
195
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
196
|
+
label: string;
|
|
197
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
153
198
|
} | undefined;
|
|
154
199
|
}, {
|
|
155
200
|
id: import("superstruct").Struct<string, null>;
|
|
@@ -187,10 +232,25 @@ export declare const SnapResponseStruct: import("superstruct").Struct<{
|
|
|
187
232
|
type: import("@metamask/snaps-sdk").NodeType.Spinner;
|
|
188
233
|
} | {
|
|
189
234
|
value: string;
|
|
190
|
-
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
191
|
-
* The timeout in milliseconds to use for requests to the snap. Defaults to
|
|
192
|
-
* `1000`.
|
|
193
|
-
*/
|
|
235
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
194
236
|
markdown?: boolean | undefined;
|
|
237
|
+
} | {
|
|
238
|
+
value: string;
|
|
239
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
240
|
+
} | {
|
|
241
|
+
value: {
|
|
242
|
+
value: string;
|
|
243
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
244
|
+
} | {
|
|
245
|
+
value: string;
|
|
246
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
247
|
+
markdown?: boolean | undefined;
|
|
248
|
+
} | {
|
|
249
|
+
value: string;
|
|
250
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
251
|
+
};
|
|
252
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
253
|
+
label: string;
|
|
254
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
195
255
|
} | undefined, null>;
|
|
196
256
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-jest",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "A Jest preset for end-to-end testing MetaMask Snaps, including a Jest environment, and a set of Jest matchers.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"@jest/environment": "^29.5.0",
|
|
37
37
|
"@jest/expect": "^29.5.0",
|
|
38
38
|
"@jest/globals": "^29.5.0",
|
|
39
|
-
"@metamask/snaps-execution-environments": "^3.
|
|
40
|
-
"@metamask/snaps-sdk": "^1.
|
|
41
|
-
"@metamask/snaps-simulator": "^2.4.
|
|
42
|
-
"@metamask/snaps-utils": "^
|
|
43
|
-
"@metamask/utils": "^8.1
|
|
39
|
+
"@metamask/snaps-execution-environments": "^3.4.1",
|
|
40
|
+
"@metamask/snaps-sdk": "^1.2.0",
|
|
41
|
+
"@metamask/snaps-simulator": "^2.4.1",
|
|
42
|
+
"@metamask/snaps-utils": "^5.0.0",
|
|
43
|
+
"@metamask/utils": "^8.2.1",
|
|
44
44
|
"express": "^4.18.2",
|
|
45
45
|
"jest-environment-node": "^29.5.0",
|
|
46
46
|
"jest-matcher-utils": "^29.5.0",
|