@metamask/snaps-utils 11.6.3 → 11.7.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 +21 -1
- package/dist/checksum.cjs +1 -9
- package/dist/checksum.cjs.map +1 -1
- package/dist/checksum.d.cts.map +1 -1
- package/dist/checksum.d.mts.map +1 -1
- package/dist/checksum.mjs +2 -10
- package/dist/checksum.mjs.map +1 -1
- package/dist/handlers/assets-market-data.cjs +2 -2
- package/dist/handlers/assets-market-data.cjs.map +1 -1
- package/dist/handlers/assets-market-data.d.cts +2 -2
- package/dist/handlers/assets-market-data.d.mts +2 -2
- package/dist/handlers/assets-market-data.mjs +2 -2
- package/dist/handlers/assets-market-data.mjs.map +1 -1
- package/dist/handlers/home-page.d.cts +6 -0
- package/dist/handlers/home-page.d.cts.map +1 -1
- package/dist/handlers/home-page.d.mts +6 -0
- package/dist/handlers/home-page.d.mts.map +1 -1
- package/dist/handlers/settings-page.d.cts +2 -0
- package/dist/handlers/settings-page.d.cts.map +1 -1
- package/dist/handlers/settings-page.d.mts +2 -0
- package/dist/handlers/settings-page.d.mts.map +1 -1
- package/dist/handlers/signature.d.cts +2 -0
- package/dist/handlers/signature.d.cts.map +1 -1
- package/dist/handlers/signature.d.mts +2 -0
- package/dist/handlers/signature.d.mts.map +1 -1
- package/dist/handlers/transaction.d.cts +6 -0
- package/dist/handlers/transaction.d.cts.map +1 -1
- package/dist/handlers/transaction.d.mts +6 -0
- package/dist/handlers/transaction.d.mts.map +1 -1
- package/dist/iframe.cjs +1 -1
- package/dist/iframe.cjs.map +1 -1
- package/dist/iframe.d.cts.map +1 -1
- package/dist/iframe.d.mts.map +1 -1
- package/dist/iframe.mjs +1 -1
- package/dist/iframe.mjs.map +1 -1
- package/dist/types.cjs +3 -16
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +11 -19
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +11 -19
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +3 -16
- package/dist/types.mjs.map +1 -1
- package/dist/ui.cjs +9 -1
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +3 -1
- package/dist/ui.d.cts.map +1 -1
- package/dist/ui.d.mts +3 -1
- package/dist/ui.d.mts.map +1 -1
- package/dist/ui.mjs +9 -1
- package/dist/ui.mjs.map +1 -1
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [11.7.1]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Use `sha256` utility from `@metamask/utils` ([#3781](https://github.com/MetaMask/snaps/pull/3781))
|
|
15
|
+
- Bump MetaMask dependencies ([#3783](https://github.com/MetaMask/snaps/pull/3783), [#3748](https://github.com/MetaMask/snaps/pull/3748), [#3791](https://github.com/MetaMask/snaps/pull/3791))
|
|
16
|
+
- Fix some typos in the documentation ([#3739](https://github.com/MetaMask/snaps/pull/3739))
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Ensure iframe load listener is removed ([#3797](https://github.com/MetaMask/snaps/pull/3797))
|
|
21
|
+
|
|
22
|
+
## [11.7.0]
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Add support for external images ([#3769](https://github.com/MetaMask/snaps/pull/3769))
|
|
27
|
+
|
|
10
28
|
## [11.6.3]
|
|
11
29
|
|
|
12
30
|
### Changed
|
|
@@ -736,7 +754,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
736
754
|
- The version of the package no longer needs to match the version of all other
|
|
737
755
|
MetaMask Snaps packages.
|
|
738
756
|
|
|
739
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.
|
|
757
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.7.1...HEAD
|
|
758
|
+
[11.7.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.7.0...@metamask/snaps-utils@11.7.1
|
|
759
|
+
[11.7.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.6.3...@metamask/snaps-utils@11.7.0
|
|
740
760
|
[11.6.3]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.6.2...@metamask/snaps-utils@11.6.3
|
|
741
761
|
[11.6.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.6.1...@metamask/snaps-utils@11.6.2
|
|
742
762
|
[11.6.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.6.0...@metamask/snaps-utils@11.6.1
|
package/dist/checksum.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checksumFiles = exports.checksum = void 0;
|
|
4
4
|
const utils_1 = require("@metamask/utils");
|
|
5
|
-
const sha256_1 = require("@noble/hashes/sha256");
|
|
6
5
|
const bytes_1 = require("./bytes.cjs");
|
|
7
6
|
/**
|
|
8
7
|
* Calculates checksum for a single byte array.
|
|
@@ -11,14 +10,7 @@ const bytes_1 = require("./bytes.cjs");
|
|
|
11
10
|
* @returns A single sha-256 checksum.
|
|
12
11
|
*/
|
|
13
12
|
async function checksum(bytes) {
|
|
14
|
-
|
|
15
|
-
// Use crypto.subtle.digest whenever possible as it is faster.
|
|
16
|
-
if ('crypto' in globalThis &&
|
|
17
|
-
typeof globalThis.crypto === 'object' &&
|
|
18
|
-
crypto.subtle?.digest) {
|
|
19
|
-
return new Uint8Array(await crypto.subtle.digest('SHA-256', value));
|
|
20
|
-
}
|
|
21
|
-
return (0, sha256_1.sha256)(value);
|
|
13
|
+
return await (0, utils_1.sha256)((0, bytes_1.getBytes)(bytes));
|
|
22
14
|
}
|
|
23
15
|
exports.checksum = checksum;
|
|
24
16
|
/**
|
package/dist/checksum.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checksum.cjs","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"checksum.cjs","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAE9D,uCAAmC;AAGnC;;;;;GAKG;AACI,KAAK,UAAU,QAAQ,CAC5B,KAAwC;IAExC,OAAO,MAAM,IAAA,cAAM,EAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC;AACvC,CAAC;AAJD,4BAIC;AAED;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,aAAa,CAAC,KAAoB;IACtD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,CAAC,GAAG,KAAK,CAAC;SACP,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACb,IAAA,cAAM,EAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,4CAA4C,CAAC,CAAC;QACxE,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YACpB,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;SACD,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACvC,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAA,mBAAW,EAAC,SAAS,CAAC,CAAC,CAAC;AAC1C,CAAC;AAdD,sCAcC","sourcesContent":["import { assert, concatBytes, sha256 } from '@metamask/utils';\n\nimport { getBytes } from './bytes';\nimport type { VirtualFile } from './virtual-file';\n\n/**\n * Calculates checksum for a single byte array.\n *\n * @param bytes - The byte array to calculate the checksum for.\n * @returns A single sha-256 checksum.\n */\nexport async function checksum(\n bytes: VirtualFile | Uint8Array | string,\n): Promise<Uint8Array> {\n return await sha256(getBytes(bytes));\n}\n\n/**\n * Calculates checksum over multiple files in a reproducible way.\n *\n * 1. Sort all the files by their paths.\n * 2. Calculate sha-256 checksum of each file separately.\n * 3. Concatenate all the checksums into one buffer and sha-256 that buffer.\n *\n * The sorting of paths is done using {@link https://tc39.es/ecma262/#sec-islessthan UTF-16 Code Units}.\n *\n * @param files - The files over which to calculate the checksum.\n * @returns A single sha-256 checksum.\n */\nexport async function checksumFiles(files: VirtualFile[]) {\n const checksums = await Promise.all(\n [...files]\n .sort((a, b) => {\n assert(a.path !== b.path, 'Tried to sort files with non-unique paths.');\n if (a.path < b.path) {\n return -1;\n }\n return 1;\n })\n .map(async (file) => checksum(file)),\n );\n\n return checksum(concatBytes(checksums));\n}\n"]}
|
package/dist/checksum.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checksum.d.cts","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checksum.d.cts","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,iCAAuB;AAElD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GACvC,OAAO,CAAC,UAAU,CAAC,CAErB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,uBAcvD"}
|
package/dist/checksum.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checksum.d.mts","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checksum.d.mts","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,iCAAuB;AAElD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GACvC,OAAO,CAAC,UAAU,CAAC,CAErB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,uBAcvD"}
|
package/dist/checksum.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { assert, concatBytes } from "@metamask/utils";
|
|
2
|
-
import { sha256 } from "@noble/hashes/sha256";
|
|
1
|
+
import { assert, concatBytes, sha256 } from "@metamask/utils";
|
|
3
2
|
import { getBytes } from "./bytes.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* Calculates checksum for a single byte array.
|
|
@@ -8,14 +7,7 @@ import { getBytes } from "./bytes.mjs";
|
|
|
8
7
|
* @returns A single sha-256 checksum.
|
|
9
8
|
*/
|
|
10
9
|
export async function checksum(bytes) {
|
|
11
|
-
|
|
12
|
-
// Use crypto.subtle.digest whenever possible as it is faster.
|
|
13
|
-
if ('crypto' in globalThis &&
|
|
14
|
-
typeof globalThis.crypto === 'object' &&
|
|
15
|
-
crypto.subtle?.digest) {
|
|
16
|
-
return new Uint8Array(await crypto.subtle.digest('SHA-256', value));
|
|
17
|
-
}
|
|
18
|
-
return sha256(value);
|
|
10
|
+
return await sha256(getBytes(bytes));
|
|
19
11
|
}
|
|
20
12
|
/**
|
|
21
13
|
* Calculates checksum over multiple files in a reproducible way.
|
package/dist/checksum.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checksum.mjs","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"checksum.mjs","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,wBAAwB;AAE9D,OAAO,EAAE,QAAQ,EAAE,oBAAgB;AAGnC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAAwC;IAExC,OAAO,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAoB;IACtD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,CAAC,GAAG,KAAK,CAAC;SACP,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACb,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,4CAA4C,CAAC,CAAC;QACxE,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YACpB,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;SACD,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACvC,CAAC;IAEF,OAAO,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import { assert, concatBytes, sha256 } from '@metamask/utils';\n\nimport { getBytes } from './bytes';\nimport type { VirtualFile } from './virtual-file';\n\n/**\n * Calculates checksum for a single byte array.\n *\n * @param bytes - The byte array to calculate the checksum for.\n * @returns A single sha-256 checksum.\n */\nexport async function checksum(\n bytes: VirtualFile | Uint8Array | string,\n): Promise<Uint8Array> {\n return await sha256(getBytes(bytes));\n}\n\n/**\n * Calculates checksum over multiple files in a reproducible way.\n *\n * 1. Sort all the files by their paths.\n * 2. Calculate sha-256 checksum of each file separately.\n * 3. Concatenate all the checksums into one buffer and sha-256 that buffer.\n *\n * The sorting of paths is done using {@link https://tc39.es/ecma262/#sec-islessthan UTF-16 Code Units}.\n *\n * @param files - The files over which to calculate the checksum.\n * @returns A single sha-256 checksum.\n */\nexport async function checksumFiles(files: VirtualFile[]) {\n const checksums = await Promise.all(\n [...files]\n .sort((a, b) => {\n assert(a.path !== b.path, 'Tried to sort files with non-unique paths.');\n if (a.path < b.path) {\n return -1;\n }\n return 1;\n })\n .map(async (file) => checksum(file)),\n );\n\n return checksum(concatBytes(checksums));\n}\n"]}
|
|
@@ -36,7 +36,7 @@ exports.FungibleAssetMarketDataStruct = (0, superstruct_1.object)({
|
|
|
36
36
|
* A struct representing an asset value, which includes the asset type and the amount.
|
|
37
37
|
*
|
|
38
38
|
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
39
|
-
* @property amount - The
|
|
39
|
+
* @property amount - The price represented as a number in string format.
|
|
40
40
|
*/
|
|
41
41
|
exports.AssetValueStruct = (0, superstruct_1.object)({
|
|
42
42
|
asset: utils_1.CaipAssetTypeOrIdStruct,
|
|
@@ -46,7 +46,7 @@ exports.AssetValueStruct = (0, superstruct_1.object)({
|
|
|
46
46
|
* A struct representing the market data for a non-fungible asset.
|
|
47
47
|
*
|
|
48
48
|
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
49
|
-
* @property amount - The
|
|
49
|
+
* @property amount - The price represented as a number in string format.
|
|
50
50
|
* @property fungible - Indicates that this is a non-fungible asset.
|
|
51
51
|
* This is always `false` for non-fungible assets.
|
|
52
52
|
* @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets-market-data.cjs","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":";;;AAAA,mDAAqE;AACrE,uDAS+B;AAC/B,2CAIyB;AAEzB,sCAAgD;AAEhD;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAA,0BAAc,EACpD,IAAA,mBAAK,EAAC,CAAC,IAAA,qBAAO,EAAC,KAAK,CAAC,EAAE,4BAAqB,CAAC,CAAC,EAC9C,IAAA,oBAAM,GAAE,CACT,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACU,QAAA,6BAA6B,GAAG,IAAA,oBAAM,EAAC;IAClD,QAAQ,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;IACvB,SAAS,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC7B,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC/B,iBAAiB,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACrC,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC/B,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC9B,kBAAkB,EAAE,IAAA,sBAAQ,EAAC,gCAAwB,CAAC;CACvD,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAM,EAAC;IACrC,KAAK,EAAE,+BAAuB;IAC9B,MAAM,EAAE,IAAA,oBAAM,GAAE;CACjB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,QAAQ,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACxB,QAAQ,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IACpC,MAAM,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IAClC,UAAU,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IACtC,MAAM,EAAE,IAAA,sBAAQ,EACd,IAAA,oBAAM,EAAC;QACL,OAAO,EAAE,IAAA,sBAAQ,EACf,IAAA,oBAAM,EAAC;YACL,MAAM,EAAE,IAAA,oBAAM,GAAE;YAChB,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC,CACH;QACD,QAAQ,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC;KAC/C,CAAC,CACH;CACF,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,0BAAc,EAAC,CAAC,UAAU,EAAE,EAAE;IACjE,IAAI,IAAA,gBAAQ,EAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,qCAA6B,CAAC;IACvC,CAAC;IAED,OAAO,wCAAgC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,UAAU,EAAE,IAAA,oBAAM,EAChB,+BAAuB,EACvB,IAAA,oBAAM,EAAC,2BAAmB,EAAE,IAAA,sBAAQ,EAAC,6BAAqB,CAAC,CAAC,CAC7D;CACF,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord, selectiveUnion } from '@metamask/snaps-sdk';\nimport {\n literal,\n nullable,\n number,\n object,\n optional,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeOrIdStruct,\n CaipAssetTypeStruct,\n isObject,\n} from '@metamask/utils';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing the market data for an asset.\n */\nexport const PricePercentChangeStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n number(),\n);\n\n/**\n * A struct representing the market data for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport const FungibleAssetMarketDataStruct = object({\n fungible: literal(true),\n marketCap: optional(string()),\n totalVolume: optional(string()),\n circulatingSupply: optional(string()),\n allTimeHigh: optional(string()),\n allTimeLow: optional(string()),\n pricePercentChange: optional(PricePercentChangeStruct),\n});\n\n/**\n * A struct representing an asset value, which includes the asset type and the amount.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The
|
|
1
|
+
{"version":3,"file":"assets-market-data.cjs","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":";;;AAAA,mDAAqE;AACrE,uDAS+B;AAC/B,2CAIyB;AAEzB,sCAAgD;AAEhD;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAA,0BAAc,EACpD,IAAA,mBAAK,EAAC,CAAC,IAAA,qBAAO,EAAC,KAAK,CAAC,EAAE,4BAAqB,CAAC,CAAC,EAC9C,IAAA,oBAAM,GAAE,CACT,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACU,QAAA,6BAA6B,GAAG,IAAA,oBAAM,EAAC;IAClD,QAAQ,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;IACvB,SAAS,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC7B,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC/B,iBAAiB,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACrC,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC/B,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC9B,kBAAkB,EAAE,IAAA,sBAAQ,EAAC,gCAAwB,CAAC;CACvD,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAM,EAAC;IACrC,KAAK,EAAE,+BAAuB;IAC9B,MAAM,EAAE,IAAA,oBAAM,GAAE;CACjB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,QAAQ,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACxB,QAAQ,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IACpC,MAAM,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IAClC,UAAU,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IACtC,MAAM,EAAE,IAAA,sBAAQ,EACd,IAAA,oBAAM,EAAC;QACL,OAAO,EAAE,IAAA,sBAAQ,EACf,IAAA,oBAAM,EAAC;YACL,MAAM,EAAE,IAAA,oBAAM,GAAE;YAChB,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC,CACH;QACD,QAAQ,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC;KAC/C,CAAC,CACH;CACF,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,0BAAc,EAAC,CAAC,UAAU,EAAE,EAAE;IACjE,IAAI,IAAA,gBAAQ,EAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,qCAA6B,CAAC;IACvC,CAAC;IAED,OAAO,wCAAgC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,UAAU,EAAE,IAAA,oBAAM,EAChB,+BAAuB,EACvB,IAAA,oBAAM,EAAC,2BAAmB,EAAE,IAAA,sBAAQ,EAAC,6BAAqB,CAAC,CAAC,CAC7D;CACF,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord, selectiveUnion } from '@metamask/snaps-sdk';\nimport {\n literal,\n nullable,\n number,\n object,\n optional,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeOrIdStruct,\n CaipAssetTypeStruct,\n isObject,\n} from '@metamask/utils';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing the market data for an asset.\n */\nexport const PricePercentChangeStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n number(),\n);\n\n/**\n * A struct representing the market data for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport const FungibleAssetMarketDataStruct = object({\n fungible: literal(true),\n marketCap: optional(string()),\n totalVolume: optional(string()),\n circulatingSupply: optional(string()),\n allTimeHigh: optional(string()),\n allTimeLow: optional(string()),\n pricePercentChange: optional(PricePercentChangeStruct),\n});\n\n/**\n * A struct representing an asset value, which includes the asset type and the amount.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The price represented as a number in string format.\n */\nexport const AssetValueStruct = object({\n asset: CaipAssetTypeOrIdStruct,\n amount: string(),\n});\n\n/**\n * A struct representing the market data for a non-fungible asset.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The price represented as a number in string format.\n * @property fungible - Indicates that this is a non-fungible asset.\n * This is always `false` for non-fungible assets.\n * @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.\n * @property topBid - The top bid price for the asset, if available. See {@link AssetValueStruct}.\n * @property floorPrice - The floor price of the asset, if available. See {@link AssetValueStruct}.\n * @property rarity - The rarity information for the asset, if available.\n * @property rarity.ranking - The ranking of the asset's rarity, if available.\n * @property rarity.ranking.source - The source of the rarity ranking.\n * @property rarity.ranking.rank - The rank of the asset in the rarity ranking.\n * @property rarity.metadata - Additional metadata about the asset's rarity, if available.\n * This is a record of string keys and number values.\n */\nexport const NonFungibleAssetMarketDataStruct = object({\n fungible: literal(false),\n lastSale: optional(AssetValueStruct),\n topBid: optional(AssetValueStruct),\n floorPrice: optional(AssetValueStruct),\n rarity: optional(\n object({\n ranking: optional(\n object({\n source: string(),\n rank: number(),\n }),\n ),\n metadata: optional(record(string(), number())),\n }),\n ),\n});\n\n/**\n * A struct representing the market data for an asset, which can be either {@link FungibleAssetMarketDataStruct} or {@link NonFungibleAssetMarketDataStruct}.\n */\nexport const AssetMarketDataStruct = selectiveUnion((marketData) => {\n if (isObject(marketData) && marketData.fungible) {\n return FungibleAssetMarketDataStruct;\n }\n\n return NonFungibleAssetMarketDataStruct;\n});\n\n/**\n * A struct representing the response of the `onAssetsMarketData` method.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.\n */\nexport const OnAssetsMarketDataResponseStruct = object({\n marketData: record(\n CaipAssetTypeOrIdStruct,\n record(CaipAssetTypeStruct, nullable(AssetMarketDataStruct)),\n ),\n});\n"]}
|
|
@@ -37,7 +37,7 @@ export declare const FungibleAssetMarketDataStruct: import("@metamask/superstruc
|
|
|
37
37
|
* A struct representing an asset value, which includes the asset type and the amount.
|
|
38
38
|
*
|
|
39
39
|
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
40
|
-
* @property amount - The
|
|
40
|
+
* @property amount - The price represented as a number in string format.
|
|
41
41
|
*/
|
|
42
42
|
export declare const AssetValueStruct: import("@metamask/superstruct").Struct<{
|
|
43
43
|
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
@@ -50,7 +50,7 @@ export declare const AssetValueStruct: import("@metamask/superstruct").Struct<{
|
|
|
50
50
|
* A struct representing the market data for a non-fungible asset.
|
|
51
51
|
*
|
|
52
52
|
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
53
|
-
* @property amount - The
|
|
53
|
+
* @property amount - The price represented as a number in string format.
|
|
54
54
|
* @property fungible - Indicates that this is a non-fungible asset.
|
|
55
55
|
* This is always `false` for non-fungible assets.
|
|
56
56
|
* @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.
|
|
@@ -37,7 +37,7 @@ export declare const FungibleAssetMarketDataStruct: import("@metamask/superstruc
|
|
|
37
37
|
* A struct representing an asset value, which includes the asset type and the amount.
|
|
38
38
|
*
|
|
39
39
|
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
40
|
-
* @property amount - The
|
|
40
|
+
* @property amount - The price represented as a number in string format.
|
|
41
41
|
*/
|
|
42
42
|
export declare const AssetValueStruct: import("@metamask/superstruct").Struct<{
|
|
43
43
|
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
@@ -50,7 +50,7 @@ export declare const AssetValueStruct: import("@metamask/superstruct").Struct<{
|
|
|
50
50
|
* A struct representing the market data for a non-fungible asset.
|
|
51
51
|
*
|
|
52
52
|
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
53
|
-
* @property amount - The
|
|
53
|
+
* @property amount - The price represented as a number in string format.
|
|
54
54
|
* @property fungible - Indicates that this is a non-fungible asset.
|
|
55
55
|
* This is always `false` for non-fungible assets.
|
|
56
56
|
* @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.
|
|
@@ -33,7 +33,7 @@ export const FungibleAssetMarketDataStruct = object({
|
|
|
33
33
|
* A struct representing an asset value, which includes the asset type and the amount.
|
|
34
34
|
*
|
|
35
35
|
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
36
|
-
* @property amount - The
|
|
36
|
+
* @property amount - The price represented as a number in string format.
|
|
37
37
|
*/
|
|
38
38
|
export const AssetValueStruct = object({
|
|
39
39
|
asset: CaipAssetTypeOrIdStruct,
|
|
@@ -43,7 +43,7 @@ export const AssetValueStruct = object({
|
|
|
43
43
|
* A struct representing the market data for a non-fungible asset.
|
|
44
44
|
*
|
|
45
45
|
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
46
|
-
* @property amount - The
|
|
46
|
+
* @property amount - The price represented as a number in string format.
|
|
47
47
|
* @property fungible - Indicates that this is a non-fungible asset.
|
|
48
48
|
* This is always `false` for non-fungible assets.
|
|
49
49
|
* @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets-market-data.mjs","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,4BAA4B;AACrE,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,EACT,wBAAwB;AAEzB,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CACpD,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAC9C,MAAM,EAAE,CACT,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;IAClD,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;IACvB,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC7B,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC9B,kBAAkB,EAAE,QAAQ,CAAC,wBAAwB,CAAC;CACvD,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;IACrC,KAAK,EAAE,uBAAuB;IAC9B,MAAM,EAAE,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IACpC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAClC,UAAU,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IACtC,MAAM,EAAE,QAAQ,CACd,MAAM,CAAC;QACL,OAAO,EAAE,QAAQ,CACf,MAAM,CAAC;YACL,MAAM,EAAE,MAAM,EAAE;YAChB,IAAI,EAAE,MAAM,EAAE;SACf,CAAC,CACH;QACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;KAC/C,CAAC,CACH;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC,CAAC,UAAU,EAAE,EAAE;IACjE,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,6BAA6B,CAAC;IACvC,CAAC;IAED,OAAO,gCAAgC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,UAAU,EAAE,MAAM,CAChB,uBAAuB,EACvB,MAAM,CAAC,mBAAmB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAC7D;CACF,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord, selectiveUnion } from '@metamask/snaps-sdk';\nimport {\n literal,\n nullable,\n number,\n object,\n optional,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeOrIdStruct,\n CaipAssetTypeStruct,\n isObject,\n} from '@metamask/utils';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing the market data for an asset.\n */\nexport const PricePercentChangeStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n number(),\n);\n\n/**\n * A struct representing the market data for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport const FungibleAssetMarketDataStruct = object({\n fungible: literal(true),\n marketCap: optional(string()),\n totalVolume: optional(string()),\n circulatingSupply: optional(string()),\n allTimeHigh: optional(string()),\n allTimeLow: optional(string()),\n pricePercentChange: optional(PricePercentChangeStruct),\n});\n\n/**\n * A struct representing an asset value, which includes the asset type and the amount.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The
|
|
1
|
+
{"version":3,"file":"assets-market-data.mjs","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,4BAA4B;AACrE,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,EACT,wBAAwB;AAEzB,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CACpD,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAC9C,MAAM,EAAE,CACT,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;IAClD,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;IACvB,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC7B,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC9B,kBAAkB,EAAE,QAAQ,CAAC,wBAAwB,CAAC;CACvD,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;IACrC,KAAK,EAAE,uBAAuB;IAC9B,MAAM,EAAE,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IACpC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAClC,UAAU,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IACtC,MAAM,EAAE,QAAQ,CACd,MAAM,CAAC;QACL,OAAO,EAAE,QAAQ,CACf,MAAM,CAAC;YACL,MAAM,EAAE,MAAM,EAAE;YAChB,IAAI,EAAE,MAAM,EAAE;SACf,CAAC,CACH;QACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;KAC/C,CAAC,CACH;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC,CAAC,UAAU,EAAE,EAAE;IACjE,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,6BAA6B,CAAC;IACvC,CAAC;IAED,OAAO,gCAAgC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,UAAU,EAAE,MAAM,CAChB,uBAAuB,EACvB,MAAM,CAAC,mBAAmB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAC7D;CACF,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord, selectiveUnion } from '@metamask/snaps-sdk';\nimport {\n literal,\n nullable,\n number,\n object,\n optional,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeOrIdStruct,\n CaipAssetTypeStruct,\n isObject,\n} from '@metamask/utils';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing the market data for an asset.\n */\nexport const PricePercentChangeStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n number(),\n);\n\n/**\n * A struct representing the market data for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport const FungibleAssetMarketDataStruct = object({\n fungible: literal(true),\n marketCap: optional(string()),\n totalVolume: optional(string()),\n circulatingSupply: optional(string()),\n allTimeHigh: optional(string()),\n allTimeLow: optional(string()),\n pricePercentChange: optional(PricePercentChangeStruct),\n});\n\n/**\n * A struct representing an asset value, which includes the asset type and the amount.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The price represented as a number in string format.\n */\nexport const AssetValueStruct = object({\n asset: CaipAssetTypeOrIdStruct,\n amount: string(),\n});\n\n/**\n * A struct representing the market data for a non-fungible asset.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The price represented as a number in string format.\n * @property fungible - Indicates that this is a non-fungible asset.\n * This is always `false` for non-fungible assets.\n * @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.\n * @property topBid - The top bid price for the asset, if available. See {@link AssetValueStruct}.\n * @property floorPrice - The floor price of the asset, if available. See {@link AssetValueStruct}.\n * @property rarity - The rarity information for the asset, if available.\n * @property rarity.ranking - The ranking of the asset's rarity, if available.\n * @property rarity.ranking.source - The source of the rarity ranking.\n * @property rarity.ranking.rank - The rank of the asset in the rarity ranking.\n * @property rarity.metadata - Additional metadata about the asset's rarity, if available.\n * This is a record of string keys and number values.\n */\nexport const NonFungibleAssetMarketDataStruct = object({\n fungible: literal(false),\n lastSale: optional(AssetValueStruct),\n topBid: optional(AssetValueStruct),\n floorPrice: optional(AssetValueStruct),\n rarity: optional(\n object({\n ranking: optional(\n object({\n source: string(),\n rank: number(),\n }),\n ),\n metadata: optional(record(string(), number())),\n }),\n ),\n});\n\n/**\n * A struct representing the market data for an asset, which can be either {@link FungibleAssetMarketDataStruct} or {@link NonFungibleAssetMarketDataStruct}.\n */\nexport const AssetMarketDataStruct = selectiveUnion((marketData) => {\n if (isObject(marketData) && marketData.fungible) {\n return FungibleAssetMarketDataStruct;\n }\n\n return NonFungibleAssetMarketDataStruct;\n});\n\n/**\n * A struct representing the response of the `onAssetsMarketData` method.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.\n */\nexport const OnAssetsMarketDataResponseStruct = object({\n marketData: record(\n CaipAssetTypeOrIdStruct,\n record(CaipAssetTypeStruct, nullable(AssetMarketDataStruct)),\n ),\n});\n"]}
|
|
@@ -71,6 +71,8 @@ export declare const OnHomePageResponseWithContentStruct: import("@metamask/supe
|
|
|
71
71
|
src: string;
|
|
72
72
|
alt?: string | undefined;
|
|
73
73
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
74
|
+
height?: number | undefined;
|
|
75
|
+
width?: number | undefined;
|
|
74
76
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
75
77
|
name: string;
|
|
76
78
|
value?: string | undefined;
|
|
@@ -157,6 +159,8 @@ export declare const OnHomePageResponseWithContentStruct: import("@metamask/supe
|
|
|
157
159
|
src: string;
|
|
158
160
|
alt?: string | undefined;
|
|
159
161
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
162
|
+
height?: number | undefined;
|
|
163
|
+
width?: number | undefined;
|
|
160
164
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
161
165
|
name: string;
|
|
162
166
|
value?: string | undefined;
|
|
@@ -249,6 +253,8 @@ export declare const OnHomePageResponseStruct: import("@metamask/superstruct").S
|
|
|
249
253
|
src: string;
|
|
250
254
|
alt?: string | undefined;
|
|
251
255
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
256
|
+
height?: number | undefined;
|
|
257
|
+
width?: number | undefined;
|
|
252
258
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
253
259
|
name: string;
|
|
254
260
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"home-page.d.cts","sourceRoot":"","sources":["../../src/handlers/home-page.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mCAAmC
|
|
1
|
+
{"version":3,"file":"home-page.d.cts","sourceRoot":"","sources":["../../src/handlers/home-page.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE9C,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;EAEzC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGnC,CAAC"}
|
|
@@ -71,6 +71,8 @@ export declare const OnHomePageResponseWithContentStruct: import("@metamask/supe
|
|
|
71
71
|
src: string;
|
|
72
72
|
alt?: string | undefined;
|
|
73
73
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
74
|
+
height?: number | undefined;
|
|
75
|
+
width?: number | undefined;
|
|
74
76
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
75
77
|
name: string;
|
|
76
78
|
value?: string | undefined;
|
|
@@ -157,6 +159,8 @@ export declare const OnHomePageResponseWithContentStruct: import("@metamask/supe
|
|
|
157
159
|
src: string;
|
|
158
160
|
alt?: string | undefined;
|
|
159
161
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
162
|
+
height?: number | undefined;
|
|
163
|
+
width?: number | undefined;
|
|
160
164
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
161
165
|
name: string;
|
|
162
166
|
value?: string | undefined;
|
|
@@ -249,6 +253,8 @@ export declare const OnHomePageResponseStruct: import("@metamask/superstruct").S
|
|
|
249
253
|
src: string;
|
|
250
254
|
alt?: string | undefined;
|
|
251
255
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
256
|
+
height?: number | undefined;
|
|
257
|
+
width?: number | undefined;
|
|
252
258
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
253
259
|
name: string;
|
|
254
260
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"home-page.d.mts","sourceRoot":"","sources":["../../src/handlers/home-page.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mCAAmC
|
|
1
|
+
{"version":3,"file":"home-page.d.mts","sourceRoot":"","sources":["../../src/handlers/home-page.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE9C,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;EAEzC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGnC,CAAC"}
|
|
@@ -71,6 +71,8 @@ export declare const OnSettingsPageResponseStruct: import("@metamask/superstruct
|
|
|
71
71
|
src: string;
|
|
72
72
|
alt?: string | undefined;
|
|
73
73
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
74
|
+
height?: number | undefined;
|
|
75
|
+
width?: number | undefined;
|
|
74
76
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
75
77
|
name: string;
|
|
76
78
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-page.d.cts","sourceRoot":"","sources":["../../src/handlers/settings-page.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B
|
|
1
|
+
{"version":3,"file":"settings-page.d.cts","sourceRoot":"","sources":["../../src/handlers/settings-page.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAA2B,CAAC"}
|
|
@@ -71,6 +71,8 @@ export declare const OnSettingsPageResponseStruct: import("@metamask/superstruct
|
|
|
71
71
|
src: string;
|
|
72
72
|
alt?: string | undefined;
|
|
73
73
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
74
|
+
height?: number | undefined;
|
|
75
|
+
width?: number | undefined;
|
|
74
76
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
75
77
|
name: string;
|
|
76
78
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-page.d.mts","sourceRoot":"","sources":["../../src/handlers/settings-page.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B
|
|
1
|
+
{"version":3,"file":"settings-page.d.mts","sourceRoot":"","sources":["../../src/handlers/settings-page.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAA2B,CAAC"}
|
|
@@ -74,6 +74,8 @@ export declare const OnSignatureResponseStruct: import("@metamask/superstruct").
|
|
|
74
74
|
src: string;
|
|
75
75
|
alt?: string | undefined;
|
|
76
76
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
77
|
+
height?: number | undefined;
|
|
78
|
+
width?: number | undefined;
|
|
77
79
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
78
80
|
name: string;
|
|
79
81
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.cts","sourceRoot":"","sources":["../../src/handlers/signature.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"signature.d.cts","sourceRoot":"","sources":["../../src/handlers/signature.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAA8B,CAAC"}
|
|
@@ -74,6 +74,8 @@ export declare const OnSignatureResponseStruct: import("@metamask/superstruct").
|
|
|
74
74
|
src: string;
|
|
75
75
|
alt?: string | undefined;
|
|
76
76
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
77
|
+
height?: number | undefined;
|
|
78
|
+
width?: number | undefined;
|
|
77
79
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
78
80
|
name: string;
|
|
79
81
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.mts","sourceRoot":"","sources":["../../src/handlers/signature.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"signature.d.mts","sourceRoot":"","sources":["../../src/handlers/signature.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAA8B,CAAC"}
|
|
@@ -84,6 +84,8 @@ export declare const OnTransactionResponseWithContentStruct: import("@metamask/s
|
|
|
84
84
|
src: string;
|
|
85
85
|
alt?: string | undefined;
|
|
86
86
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
87
|
+
height?: number | undefined;
|
|
88
|
+
width?: number | undefined;
|
|
87
89
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
88
90
|
name: string;
|
|
89
91
|
value?: string | undefined;
|
|
@@ -171,6 +173,8 @@ export declare const OnTransactionResponseWithContentStruct: import("@metamask/s
|
|
|
171
173
|
src: string;
|
|
172
174
|
alt?: string | undefined;
|
|
173
175
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
176
|
+
height?: number | undefined;
|
|
177
|
+
width?: number | undefined;
|
|
174
178
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
175
179
|
name: string;
|
|
176
180
|
value?: string | undefined;
|
|
@@ -262,6 +266,8 @@ export declare const OnTransactionResponseStruct: import("@metamask/superstruct"
|
|
|
262
266
|
src: string;
|
|
263
267
|
alt?: string | undefined;
|
|
264
268
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
269
|
+
height?: number | undefined;
|
|
270
|
+
width?: number | undefined;
|
|
265
271
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
266
272
|
name: string;
|
|
267
273
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.cts","sourceRoot":"","sources":["../../src/handlers/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,4BAA4B;AAW9E,eAAO,MAAM,mCAAmC;;;;EAE9C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;EAK7C,CAAC;AAEF,eAAO,MAAM,sCAAsC
|
|
1
|
+
{"version":3,"file":"transaction.d.cts","sourceRoot":"","sources":["../../src/handlers/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,4BAA4B;AAW9E,eAAO,MAAM,mCAAmC;;;;EAE9C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;EAK7C,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKlD,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAKvC,CAAC"}
|
|
@@ -84,6 +84,8 @@ export declare const OnTransactionResponseWithContentStruct: import("@metamask/s
|
|
|
84
84
|
src: string;
|
|
85
85
|
alt?: string | undefined;
|
|
86
86
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
87
|
+
height?: number | undefined;
|
|
88
|
+
width?: number | undefined;
|
|
87
89
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
88
90
|
name: string;
|
|
89
91
|
value?: string | undefined;
|
|
@@ -171,6 +173,8 @@ export declare const OnTransactionResponseWithContentStruct: import("@metamask/s
|
|
|
171
173
|
src: string;
|
|
172
174
|
alt?: string | undefined;
|
|
173
175
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
176
|
+
height?: number | undefined;
|
|
177
|
+
width?: number | undefined;
|
|
174
178
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
175
179
|
name: string;
|
|
176
180
|
value?: string | undefined;
|
|
@@ -262,6 +266,8 @@ export declare const OnTransactionResponseStruct: import("@metamask/superstruct"
|
|
|
262
266
|
src: string;
|
|
263
267
|
alt?: string | undefined;
|
|
264
268
|
borderRadius?: import("@metamask/snaps-sdk/jsx").BorderRadius;
|
|
269
|
+
height?: number | undefined;
|
|
270
|
+
width?: number | undefined;
|
|
265
271
|
}, "Image"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CheckboxProps, "Checkbox"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DateTimePickerProps, "DateTimePicker"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FormProps, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").InputProps, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").DropdownProps, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
266
272
|
name: string;
|
|
267
273
|
value?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.mts","sourceRoot":"","sources":["../../src/handlers/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,4BAA4B;AAW9E,eAAO,MAAM,mCAAmC;;;;EAE9C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;EAK7C,CAAC;AAEF,eAAO,MAAM,sCAAsC
|
|
1
|
+
{"version":3,"file":"transaction.d.mts","sourceRoot":"","sources":["../../src/handlers/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,4BAA4B;AAW9E,eAAO,MAAM,mCAAmC;;;;EAE9C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;EAK7C,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKlD,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAKvC,CAAC"}
|
package/dist/iframe.cjs
CHANGED
|
@@ -49,7 +49,7 @@ async function createWindow({ uri, id, sandbox = true, testId = 'snaps-iframe',
|
|
|
49
49
|
// fast if it does.
|
|
50
50
|
reject(new Error(`iframe.contentWindow not present on load for job "${id}".`));
|
|
51
51
|
}
|
|
52
|
-
});
|
|
52
|
+
}, { once: true });
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
exports.createWindow = createWindow;
|
package/dist/iframe.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.cjs","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,YAAY,CAAC,EACjC,GAAG,EACH,EAAE,EACF,OAAO,GAAG,IAAI,EACd,MAAM,GAAG,cAAc,GAMxB;IACC,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,uEAAuE;QACvE,yCAAyC;QACzC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAE3C,IAAI,OAAO,EAAE,CAAC;YACZ,gGAAgG;YAChG,kEAAkE;YAClE,WAAW;YACX,qFAAqF;YACrF,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAClD,CAAC;QAED,uEAAuE;QACvE,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,uBAAuB;QACvB,EAAE;QACF,mEAAmE;QACnE,kCAAkC;QAClC,EAAE;QACF,mGAAmG;QACnG,iJAAiJ;QACjJ,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAElC,MAAM,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"iframe.cjs","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,YAAY,CAAC,EACjC,GAAG,EACH,EAAE,EACF,OAAO,GAAG,IAAI,EACd,MAAM,GAAG,cAAc,GAMxB;IACC,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,uEAAuE;QACvE,yCAAyC;QACzC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAE3C,IAAI,OAAO,EAAE,CAAC;YACZ,gGAAgG;YAChG,kEAAkE;YAClE,WAAW;YACX,qFAAqF;YACrF,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAClD,CAAC;QAED,uEAAuE;QACvE,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,uBAAuB;QACvB,EAAE;QACF,mEAAmE;QACnE,kCAAkC;QAClC,EAAE;QACF,mGAAmG;QACnG,iJAAiJ;QACjJ,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAElC,MAAM,CAAC,gBAAgB,CACrB,MAAM,EACN,GAAG,EAAE;YACH,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;gBACzB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,qEAAqE;gBACrE,mBAAmB;gBACnB,MAAM,CACJ,IAAI,KAAK,CACP,qDAAqD,EAAE,IAAI,CAC5D,CACF,CAAC;YACJ,CAAC;QACH,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA1DD,oCA0DC","sourcesContent":["/**\n * Creates the iframe to be used as the execution environment. This may run\n * forever if the iframe never loads, but the promise should be wrapped in\n * an initialization timeout in the SnapController.\n *\n * @param options - The options for createWindow.\n * @param options.uri - The iframe URI.\n * @param options.id - The ID to assign to the iframe.\n * @param options.sandbox - Whether to enable the sandbox attribute.\n * @param options.testId - The data-testid attribute to assign to the iframe.\n * @returns A promise that resolves to the contentWindow of the iframe.\n */\nexport async function createWindow({\n uri,\n id,\n sandbox = true,\n testId = 'snaps-iframe',\n}: {\n uri: string;\n id: string;\n sandbox?: boolean;\n testId?: string;\n}): Promise<Window> {\n return await new Promise((resolve, reject) => {\n const iframe = document.createElement('iframe');\n // The order of operations appears to matter for everything except this\n // attribute. We may as well set it here.\n iframe.setAttribute('id', id);\n iframe.setAttribute('data-testid', testId);\n\n if (sandbox) {\n // For the sandbox property to have any effect it needs to be set before the iframe is appended.\n // We apply this property as a principle of least authority (POLA)\n // measure.\n // Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n iframe.setAttribute('sandbox', 'allow-scripts');\n }\n\n // In the past, we've had problems that appear to be symptomatic of the\n // iframe firing the `load` event before its scripts are actually loaded,\n // which has prevented snaps from executing properly. Therefore, we set\n // the `src` attribute and append the iframe to the DOM before attaching\n // the `load` listener.\n //\n // `load` should only fire when \"all dependent resources\" have been\n // loaded, which includes scripts.\n //\n // MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event\n // Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489\n iframe.setAttribute('src', uri);\n document.body.appendChild(iframe);\n\n iframe.addEventListener(\n 'load',\n () => {\n if (iframe.contentWindow) {\n resolve(iframe.contentWindow);\n } else {\n // We don't know of a case when this would happen, but better to fail\n // fast if it does.\n reject(\n new Error(\n `iframe.contentWindow not present on load for job \"${id}\".`,\n ),\n );\n }\n },\n { once: true },\n );\n });\n}\n"]}
|
package/dist/iframe.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.d.cts","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,EACjC,GAAG,EACH,EAAE,EACF,OAAc,EACd,MAAuB,GACxB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"iframe.d.cts","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,EACjC,GAAG,EACH,EAAE,EACF,OAAc,EACd,MAAuB,GACxB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgDlB"}
|
package/dist/iframe.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.d.mts","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,EACjC,GAAG,EACH,EAAE,EACF,OAAc,EACd,MAAuB,GACxB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"iframe.d.mts","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,EACjC,GAAG,EACH,EAAE,EACF,OAAc,EACd,MAAuB,GACxB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgDlB"}
|
package/dist/iframe.mjs
CHANGED
|
@@ -46,7 +46,7 @@ export async function createWindow({ uri, id, sandbox = true, testId = 'snaps-if
|
|
|
46
46
|
// fast if it does.
|
|
47
47
|
reject(new Error(`iframe.contentWindow not present on load for job "${id}".`));
|
|
48
48
|
}
|
|
49
|
-
});
|
|
49
|
+
}, { once: true });
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
//# sourceMappingURL=iframe.mjs.map
|
package/dist/iframe.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.mjs","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,GAAG,EACH,EAAE,EACF,OAAO,GAAG,IAAI,EACd,MAAM,GAAG,cAAc,GAMxB;IACC,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,uEAAuE;QACvE,yCAAyC;QACzC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAE3C,IAAI,OAAO,EAAE,CAAC;YACZ,gGAAgG;YAChG,kEAAkE;YAClE,WAAW;YACX,qFAAqF;YACrF,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAClD,CAAC;QAED,uEAAuE;QACvE,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,uBAAuB;QACvB,EAAE;QACF,mEAAmE;QACnE,kCAAkC;QAClC,EAAE;QACF,mGAAmG;QACnG,iJAAiJ;QACjJ,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAElC,MAAM,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"iframe.mjs","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,GAAG,EACH,EAAE,EACF,OAAO,GAAG,IAAI,EACd,MAAM,GAAG,cAAc,GAMxB;IACC,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,uEAAuE;QACvE,yCAAyC;QACzC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAE3C,IAAI,OAAO,EAAE,CAAC;YACZ,gGAAgG;YAChG,kEAAkE;YAClE,WAAW;YACX,qFAAqF;YACrF,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAClD,CAAC;QAED,uEAAuE;QACvE,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,uBAAuB;QACvB,EAAE;QACF,mEAAmE;QACnE,kCAAkC;QAClC,EAAE;QACF,mGAAmG;QACnG,iJAAiJ;QACjJ,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAElC,MAAM,CAAC,gBAAgB,CACrB,MAAM,EACN,GAAG,EAAE;YACH,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;gBACzB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,qEAAqE;gBACrE,mBAAmB;gBACnB,MAAM,CACJ,IAAI,KAAK,CACP,qDAAqD,EAAE,IAAI,CAC5D,CACF,CAAC;YACJ,CAAC;QACH,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Creates the iframe to be used as the execution environment. This may run\n * forever if the iframe never loads, but the promise should be wrapped in\n * an initialization timeout in the SnapController.\n *\n * @param options - The options for createWindow.\n * @param options.uri - The iframe URI.\n * @param options.id - The ID to assign to the iframe.\n * @param options.sandbox - Whether to enable the sandbox attribute.\n * @param options.testId - The data-testid attribute to assign to the iframe.\n * @returns A promise that resolves to the contentWindow of the iframe.\n */\nexport async function createWindow({\n uri,\n id,\n sandbox = true,\n testId = 'snaps-iframe',\n}: {\n uri: string;\n id: string;\n sandbox?: boolean;\n testId?: string;\n}): Promise<Window> {\n return await new Promise((resolve, reject) => {\n const iframe = document.createElement('iframe');\n // The order of operations appears to matter for everything except this\n // attribute. We may as well set it here.\n iframe.setAttribute('id', id);\n iframe.setAttribute('data-testid', testId);\n\n if (sandbox) {\n // For the sandbox property to have any effect it needs to be set before the iframe is appended.\n // We apply this property as a principle of least authority (POLA)\n // measure.\n // Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n iframe.setAttribute('sandbox', 'allow-scripts');\n }\n\n // In the past, we've had problems that appear to be symptomatic of the\n // iframe firing the `load` event before its scripts are actually loaded,\n // which has prevented snaps from executing properly. Therefore, we set\n // the `src` attribute and append the iframe to the DOM before attaching\n // the `load` listener.\n //\n // `load` should only fire when \"all dependent resources\" have been\n // loaded, which includes scripts.\n //\n // MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event\n // Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489\n iframe.setAttribute('src', uri);\n document.body.appendChild(iframe);\n\n iframe.addEventListener(\n 'load',\n () => {\n if (iframe.contentWindow) {\n resolve(iframe.contentWindow);\n } else {\n // We don't know of a case when this would happen, but better to fail\n // fast if it does.\n reject(\n new Error(\n `iframe.contentWindow not present on load for job \"${id}\".`,\n ),\n );\n }\n },\n { once: true },\n );\n });\n}\n"]}
|