@metamask/snaps-simulation 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.3.0]
11
+
12
+ ### Added
13
+
14
+ - Add Snap metadata to simulated accounts ([#3528](https://github.com/MetaMask/snaps/pull/3528))
15
+
10
16
  ## [3.2.0]
11
17
 
12
18
  ### Added
@@ -190,7 +196,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
190
196
 
191
197
  - Initial release of `@metamask/snaps-simulation` package ([#2727](https://github.com/MetaMask/snaps/pull/2727))
192
198
 
193
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@3.2.0...HEAD
199
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@3.3.0...HEAD
200
+ [3.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@3.2.0...@metamask/snaps-simulation@3.3.0
194
201
  [3.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@3.1.0...@metamask/snaps-simulation@3.2.0
195
202
  [3.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@3.0.0...@metamask/snaps-simulation@3.1.0
196
203
  [3.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@2.7.0...@metamask/snaps-simulation@3.0.0
@@ -33,6 +33,7 @@ exports.DEFAULT_ACCOUNTS = [
33
33
  id: '29bc7513-d1b9-4466-98a6-f5f9e0b90137',
34
34
  scopes: ['eip155:0'],
35
35
  selected: false,
36
+ owned: false,
36
37
  // We don't expose assets for EVM accounts as it's not supported in the AssetSelector.
37
38
  assets: [],
38
39
  },
@@ -45,6 +46,7 @@ exports.DEFAULT_ACCOUNTS = [
45
46
  'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
46
47
  ],
47
48
  selected: true,
49
+ owned: true,
48
50
  assets: [
49
51
  'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501',
50
52
  'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACU,QAAA,WAAW,GACtB,6DAA6D,CAAC;AAEhE;;;GAGG;AACU,QAAA,uBAAuB,GAClC,+FAA+F,CAAC;AAElG;;GAEG;AACU,QAAA,cAAc,GAAG,IAAI,CAAC;AAEnC;;GAEG;AACU,QAAA,gBAAgB,GAAG,KAAK,CAAC;AAEtC;;GAEG;AACU,QAAA,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE;;GAEG;AACU,QAAA,eAAe,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAE5C,QAAA,gBAAgB,GAAwB;IACnD;QACE,OAAO,EAAE,4CAA4C;QACrD,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE,CAAC,UAAU,CAAC;QACpB,QAAQ,EAAE,KAAK;QACf,sFAAsF;QACtF,MAAM,EAAE,EAAE;KACX;IACD;QACE,OAAO,EAAE,8CAA8C;QACvD,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE;YACN,yCAAyC;YACzC,yCAAyC;YACzC,yCAAyC;SAC1C;QACD,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE;YACN,oDAAoD;YACpD,4FAA4F;SAC7F;KACF;CACF,CAAC;AAEW,QAAA,cAAc,GAAG;IAC5B,oDAAoD,EAAE;QACpD,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;KACd;IACD,4FAA4F,EAC1F;QACE,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,MAAM;KACf;CACJ,CAAC","sourcesContent":["import type { SimulationAccount } from './options';\n\n/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * An alternative secret recovery phrase that is used for testing purposes. Do\n * not use this to store any real funds!\n */\nexport const DEFAULT_ALTERNATIVE_SRP =\n 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default currency.\n */\nexport const DEFAULT_CURRENCY = 'usd';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n\n/**\n * The types of inputs that can be used in the `typeInField` interface action.\n */\nexport const TYPEABLE_INPUTS = ['Input', 'AddressInput'];\n\nexport const DEFAULT_ACCOUNTS: SimulationAccount[] = [\n {\n address: '0x1234567890abcdef1234567890abcdef12345678',\n id: '29bc7513-d1b9-4466-98a6-f5f9e0b90137',\n scopes: ['eip155:0'],\n selected: false,\n // We don't expose assets for EVM accounts as it's not supported in the AssetSelector.\n assets: [],\n },\n {\n address: '7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv',\n id: 'e051723c-85d0-43a3-b9bf-568a90d3f378',\n scopes: [\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',\n ],\n selected: true,\n assets: [\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501',\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n ],\n },\n];\n\nexport const DEFAULT_ASSETS = {\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501': {\n name: 'Solana',\n symbol: 'SOL',\n },\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v':\n {\n name: 'USDC',\n symbol: 'USDC',\n },\n};\n"]}
1
+ {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACU,QAAA,WAAW,GACtB,6DAA6D,CAAC;AAEhE;;;GAGG;AACU,QAAA,uBAAuB,GAClC,+FAA+F,CAAC;AAElG;;GAEG;AACU,QAAA,cAAc,GAAG,IAAI,CAAC;AAEnC;;GAEG;AACU,QAAA,gBAAgB,GAAG,KAAK,CAAC;AAEtC;;GAEG;AACU,QAAA,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE;;GAEG;AACU,QAAA,eAAe,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAE5C,QAAA,gBAAgB,GAAwB;IACnD;QACE,OAAO,EAAE,4CAA4C;QACrD,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE,CAAC,UAAU,CAAC;QACpB,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,KAAK;QACZ,sFAAsF;QACtF,MAAM,EAAE,EAAE;KACX;IACD;QACE,OAAO,EAAE,8CAA8C;QACvD,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE;YACN,yCAAyC;YACzC,yCAAyC;YACzC,yCAAyC;SAC1C;QACD,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,IAAI;QACX,MAAM,EAAE;YACN,oDAAoD;YACpD,4FAA4F;SAC7F;KACF;CACF,CAAC;AAEW,QAAA,cAAc,GAAG;IAC5B,oDAAoD,EAAE;QACpD,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;KACd;IACD,4FAA4F,EAC1F;QACE,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,MAAM;KACf;CACJ,CAAC","sourcesContent":["import type { SimulationAccount } from './options';\n\n/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * An alternative secret recovery phrase that is used for testing purposes. Do\n * not use this to store any real funds!\n */\nexport const DEFAULT_ALTERNATIVE_SRP =\n 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default currency.\n */\nexport const DEFAULT_CURRENCY = 'usd';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n\n/**\n * The types of inputs that can be used in the `typeInField` interface action.\n */\nexport const TYPEABLE_INPUTS = ['Input', 'AddressInput'];\n\nexport const DEFAULT_ACCOUNTS: SimulationAccount[] = [\n {\n address: '0x1234567890abcdef1234567890abcdef12345678',\n id: '29bc7513-d1b9-4466-98a6-f5f9e0b90137',\n scopes: ['eip155:0'],\n selected: false,\n owned: false,\n // We don't expose assets for EVM accounts as it's not supported in the AssetSelector.\n assets: [],\n },\n {\n address: '7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv',\n id: 'e051723c-85d0-43a3-b9bf-568a90d3f378',\n scopes: [\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',\n ],\n selected: true,\n owned: true,\n assets: [\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501',\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n ],\n },\n];\n\nexport const DEFAULT_ASSETS = {\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501': {\n name: 'Solana',\n symbol: 'SOL',\n },\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v':\n {\n name: 'USDC',\n symbol: 'USDC',\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAkB;AAEnD;;;GAGG;AACH,eAAO,MAAM,WAAW,gEACuC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,kGAC6D,CAAC;AAElG;;GAEG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,eAAe,UAA4B,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,EAuB/C,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;CAU1B,CAAC"}
1
+ {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAkB;AAEnD;;;GAGG;AACH,eAAO,MAAM,WAAW,gEACuC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,kGAC6D,CAAC;AAElG;;GAEG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,eAAe,UAA4B,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,EAyB/C,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;CAU1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAkB;AAEnD;;;GAGG;AACH,eAAO,MAAM,WAAW,gEACuC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,kGAC6D,CAAC;AAElG;;GAEG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,eAAe,UAA4B,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,EAuB/C,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;CAU1B,CAAC"}
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAkB;AAEnD;;;GAGG;AACH,eAAO,MAAM,WAAW,gEACuC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,kGAC6D,CAAC;AAElG;;GAEG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,eAAe,UAA4B,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,EAyB/C,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;CAU1B,CAAC"}
@@ -30,6 +30,7 @@ export const DEFAULT_ACCOUNTS = [
30
30
  id: '29bc7513-d1b9-4466-98a6-f5f9e0b90137',
31
31
  scopes: ['eip155:0'],
32
32
  selected: false,
33
+ owned: false,
33
34
  // We don't expose assets for EVM accounts as it's not supported in the AssetSelector.
34
35
  assets: [],
35
36
  },
@@ -42,6 +43,7 @@ export const DEFAULT_ACCOUNTS = [
42
43
  'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
43
44
  ],
44
45
  selected: true,
46
+ owned: true,
45
47
  assets: [
46
48
  'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501',
47
49
  'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,6DAA6D,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,+FAA+F,CAAC;AAElG;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAwB;IACnD;QACE,OAAO,EAAE,4CAA4C;QACrD,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE,CAAC,UAAU,CAAC;QACpB,QAAQ,EAAE,KAAK;QACf,sFAAsF;QACtF,MAAM,EAAE,EAAE;KACX;IACD;QACE,OAAO,EAAE,8CAA8C;QACvD,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE;YACN,yCAAyC;YACzC,yCAAyC;YACzC,yCAAyC;SAC1C;QACD,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE;YACN,oDAAoD;YACpD,4FAA4F;SAC7F;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,oDAAoD,EAAE;QACpD,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;KACd;IACD,4FAA4F,EAC1F;QACE,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,MAAM;KACf;CACJ,CAAC","sourcesContent":["import type { SimulationAccount } from './options';\n\n/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * An alternative secret recovery phrase that is used for testing purposes. Do\n * not use this to store any real funds!\n */\nexport const DEFAULT_ALTERNATIVE_SRP =\n 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default currency.\n */\nexport const DEFAULT_CURRENCY = 'usd';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n\n/**\n * The types of inputs that can be used in the `typeInField` interface action.\n */\nexport const TYPEABLE_INPUTS = ['Input', 'AddressInput'];\n\nexport const DEFAULT_ACCOUNTS: SimulationAccount[] = [\n {\n address: '0x1234567890abcdef1234567890abcdef12345678',\n id: '29bc7513-d1b9-4466-98a6-f5f9e0b90137',\n scopes: ['eip155:0'],\n selected: false,\n // We don't expose assets for EVM accounts as it's not supported in the AssetSelector.\n assets: [],\n },\n {\n address: '7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv',\n id: 'e051723c-85d0-43a3-b9bf-568a90d3f378',\n scopes: [\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',\n ],\n selected: true,\n assets: [\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501',\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n ],\n },\n];\n\nexport const DEFAULT_ASSETS = {\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501': {\n name: 'Solana',\n symbol: 'SOL',\n },\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v':\n {\n name: 'USDC',\n symbol: 'USDC',\n },\n};\n"]}
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,6DAA6D,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,+FAA+F,CAAC;AAElG;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAwB;IACnD;QACE,OAAO,EAAE,4CAA4C;QACrD,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE,CAAC,UAAU,CAAC;QACpB,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,KAAK;QACZ,sFAAsF;QACtF,MAAM,EAAE,EAAE;KACX;IACD;QACE,OAAO,EAAE,8CAA8C;QACvD,EAAE,EAAE,sCAAsC;QAC1C,MAAM,EAAE;YACN,yCAAyC;YACzC,yCAAyC;YACzC,yCAAyC;SAC1C;QACD,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,IAAI;QACX,MAAM,EAAE;YACN,oDAAoD;YACpD,4FAA4F;SAC7F;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,oDAAoD,EAAE;QACpD,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;KACd;IACD,4FAA4F,EAC1F;QACE,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,MAAM;KACf;CACJ,CAAC","sourcesContent":["import type { SimulationAccount } from './options';\n\n/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * An alternative secret recovery phrase that is used for testing purposes. Do\n * not use this to store any real funds!\n */\nexport const DEFAULT_ALTERNATIVE_SRP =\n 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default currency.\n */\nexport const DEFAULT_CURRENCY = 'usd';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n\n/**\n * The types of inputs that can be used in the `typeInField` interface action.\n */\nexport const TYPEABLE_INPUTS = ['Input', 'AddressInput'];\n\nexport const DEFAULT_ACCOUNTS: SimulationAccount[] = [\n {\n address: '0x1234567890abcdef1234567890abcdef12345678',\n id: '29bc7513-d1b9-4466-98a6-f5f9e0b90137',\n scopes: ['eip155:0'],\n selected: false,\n owned: false,\n // We don't expose assets for EVM accounts as it's not supported in the AssetSelector.\n assets: [],\n },\n {\n address: '7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv',\n id: 'e051723c-85d0-43a3-b9bf-568a90d3f378',\n scopes: [\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',\n ],\n selected: true,\n owned: true,\n assets: [\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501',\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n ],\n },\n];\n\nexport const DEFAULT_ASSETS = {\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501': {\n name: 'Solana',\n symbol: 'SOL',\n },\n 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v':\n {\n name: 'USDC',\n symbol: 'USDC',\n },\n};\n"]}
package/dist/options.cjs CHANGED
@@ -9,6 +9,7 @@ const SimulationAccountStruct = (0, superstruct_1.object)({
9
9
  id: (0, superstruct_1.string)(),
10
10
  scopes: (0, superstruct_1.array)(utils_1.CaipChainIdStruct),
11
11
  selected: (0, superstruct_1.defaulted)((0, superstruct_1.optional)((0, superstruct_1.boolean)()), false),
12
+ owned: (0, superstruct_1.defaulted)((0, superstruct_1.optional)((0, superstruct_1.boolean)()), false),
12
13
  assets: (0, superstruct_1.defaulted)((0, superstruct_1.optional)((0, superstruct_1.array)(utils_1.CaipAssetTypeStruct)), []),
13
14
  });
14
15
  const SimulationAssetStruct = (0, superstruct_1.object)({
@@ -1 +1 @@
1
- {"version":3,"file":"options.cjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AACA,uDAU+B;AAC/B,2CAIyB;AAEzB,+CAMqB;AAErB,MAAM,uBAAuB,GAAG,IAAA,oBAAM,EAAC;IACrC,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,EAAE,EAAE,IAAA,oBAAM,GAAE;IACZ,MAAM,EAAE,IAAA,mBAAK,EAAC,yBAAiB,CAAC;IAChC,QAAQ,EA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AAM,EAAC,2BAAmB,EAAE,qBAAqB,CAAC,CAAC,EAC5D,0BAAc,CACf;IACD,YAAY,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,KAAK,CAAC;IACnD,iBAAiB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACvD,sBAAsB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,iBAAiB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACvD,kBAAkB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACxD,eAAe,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACrD,eAAe,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACrD,sBAAsB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,YAAY,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;CACnD,CAAC,CAAC;AAmCH;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,OAA8B;IACvD,OAAO,IAAA,oBAAM,EACX,OAAO,EACP,uBAAuB,CACW,CAAC;AACvC,CAAC;AALD,gCAKC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n DEFAULT_ACCOUNTS,\n DEFAULT_ASSETS,\n DEFAULT_CURRENCY,\n DEFAULT_LOCALE,\n DEFAULT_SRP,\n} from './constants';\n\nconst SimulationAccountStruct = object({\n address: string(),\n id: string(),\n scopes: array(CaipChainIdStruct),\n selected: defaulted(optional(boolean()), false),\n assets: defaulted(optional(array(CaipAssetTypeStruct)), []),\n});\n\nexport type SimulationAccount = Infer<typeof SimulationAccountStruct>;\n\nconst SimulationAssetStruct = object({\n name: string(),\n symbol: string(),\n});\n\nexport type SimulationAsset = Infer<typeof SimulationAssetStruct>;\n\nconst SimulationOptionsStruct = object({\n currency: defaulted(optional(string()), DEFAULT_CURRENCY),\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n accounts: defaulted(\n optional(array(SimulationAccountStruct)),\n DEFAULT_ACCOUNTS,\n ),\n assets: defaulted(\n optional(record(CaipAssetTypeStruct, SimulationAssetStruct)),\n DEFAULT_ASSETS,\n ),\n hideBalances: defaulted(optional(boolean()), false),\n useSecurityAlerts: defaulted(optional(boolean()), true),\n simulateOnChainActions: defaulted(optional(boolean()), true),\n useTokenDetection: defaulted(optional(boolean()), true),\n batchCheckBalances: defaulted(optional(boolean()), true),\n displayNftMedia: defaulted(optional(boolean()), true),\n useNftDetection: defaulted(optional(boolean()), true),\n useExternalPricingData: defaulted(optional(boolean()), true),\n showTestnets: defaulted(optional(boolean()), true),\n});\n\n/**\n * Options for the simulation.\n *\n * @property currency - The currency to use. Defaults to `usd`.\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n * @property unencryptedState - The initial unencrypted state of the Snap, if\n * any. Defaults to `null`.\n * @property accounts - The accounts to use in the simulation, if any. Defaults\n * to an empty array.\n * @property assets - The assets to use in the simulation, if any. Defaults to\n * an empty object.\n * @property useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @property simulateOnChainActions - Whether to simulate transactions and signatures.\n * @property useTokenDetection - Whether to auto-detect tokens.\n * @property batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @property displayNftMedia - Whether to display NFT media.\n * @property useNftDetection - Whether to auto-detect NFTs.\n * @property useExternalPricingData - Whether to get token price data from an external source.\n * @property showTestnets - Whether to show testnets.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
1
+ {"version":3,"file":"options.cjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AACA,uDAU+B;AAC/B,2CAIyB;AAEzB,+CAMqB;AAErB,MAAM,uBAAuB,GAAG,IAAA,oBAAM,EAAC;IACrC,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,EAAE,EAAE,IAAA,oBAAM,GAAE;IACZ,MAAM,EAAE,IAAA,mBAAK,EAAC,yBAAiB,CAAC;IAChC,QAAQ,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,KAAK,CAAC;IAC/C,KAAK,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAA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ACD,YAAY,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,KAAK,CAAC;IACnD,iBAAiB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACvD,sBAAsB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,iBAAiB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACvD,kBAAkB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACxD,eAAe,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACrD,eAAe,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACrD,sBAAsB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,YAAY,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;CACnD,CAAC,CAAC;AAmCH;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,OAA8B;IACvD,OAAO,IAAA,oBAAM,EACX,OAAO,EACP,uBAAuB,CACW,CAAC;AACvC,CAAC;AALD,gCAKC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n DEFAULT_ACCOUNTS,\n DEFAULT_ASSETS,\n DEFAULT_CURRENCY,\n DEFAULT_LOCALE,\n DEFAULT_SRP,\n} from './constants';\n\nconst SimulationAccountStruct = object({\n address: string(),\n id: string(),\n scopes: array(CaipChainIdStruct),\n selected: defaulted(optional(boolean()), false),\n owned: defaulted(optional(boolean()), false),\n assets: defaulted(optional(array(CaipAssetTypeStruct)), []),\n});\n\nexport type SimulationAccount = Infer<typeof SimulationAccountStruct>;\n\nconst SimulationAssetStruct = object({\n name: string(),\n symbol: string(),\n});\n\nexport type SimulationAsset = Infer<typeof SimulationAssetStruct>;\n\nconst SimulationOptionsStruct = object({\n currency: defaulted(optional(string()), DEFAULT_CURRENCY),\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n accounts: defaulted(\n optional(array(SimulationAccountStruct)),\n DEFAULT_ACCOUNTS,\n ),\n assets: defaulted(\n optional(record(CaipAssetTypeStruct, SimulationAssetStruct)),\n DEFAULT_ASSETS,\n ),\n hideBalances: defaulted(optional(boolean()), false),\n useSecurityAlerts: defaulted(optional(boolean()), true),\n simulateOnChainActions: defaulted(optional(boolean()), true),\n useTokenDetection: defaulted(optional(boolean()), true),\n batchCheckBalances: defaulted(optional(boolean()), true),\n displayNftMedia: defaulted(optional(boolean()), true),\n useNftDetection: defaulted(optional(boolean()), true),\n useExternalPricingData: defaulted(optional(boolean()), true),\n showTestnets: defaulted(optional(boolean()), true),\n});\n\n/**\n * Options for the simulation.\n *\n * @property currency - The currency to use. Defaults to `usd`.\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n * @property unencryptedState - The initial unencrypted state of the Snap, if\n * any. Defaults to `null`.\n * @property accounts - The accounts to use in the simulation, if any. Defaults\n * to an empty array.\n * @property assets - The assets to use in the simulation, if any. Defaults to\n * an empty object.\n * @property useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @property simulateOnChainActions - Whether to simulate transactions and signatures.\n * @property useTokenDetection - Whether to auto-detect tokens.\n * @property batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @property displayNftMedia - Whether to display NFT media.\n * @property useNftDetection - Whether to auto-detect NFTs.\n * @property useExternalPricingData - Whether to get token price data from an external source.\n * @property showTestnets - Whether to show testnets.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
@@ -4,12 +4,14 @@ declare const SimulationAccountStruct: import("@metamask/superstruct").Struct<{
4
4
  id: string;
5
5
  scopes: `${string}:${string}`[];
6
6
  selected?: boolean | undefined;
7
+ owned?: boolean | undefined;
7
8
  assets?: `${string}:${string}/${string}:${string}`[] | undefined;
8
9
  }, {
9
10
  address: import("@metamask/superstruct").Struct<string, null>;
10
11
  id: import("@metamask/superstruct").Struct<string, null>;
11
12
  scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
12
13
  selected: import("@metamask/superstruct").Struct<boolean | undefined, null>;
14
+ owned: import("@metamask/superstruct").Struct<boolean | undefined, null>;
13
15
  assets: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
14
16
  }>;
15
17
  export type SimulationAccount = Infer<typeof SimulationAccountStruct>;
@@ -36,6 +38,7 @@ declare const SimulationOptionsStruct: import("@metamask/superstruct").Struct<{
36
38
  id: string;
37
39
  scopes: `${string}:${string}`[];
38
40
  selected?: boolean | undefined;
41
+ owned?: boolean | undefined;
39
42
  assets?: `${string}:${string}/${string}:${string}`[] | undefined;
40
43
  }[] | undefined;
41
44
  hideBalances?: boolean | undefined;
@@ -58,18 +61,21 @@ declare const SimulationOptionsStruct: import("@metamask/superstruct").Struct<{
58
61
  id: string;
59
62
  scopes: `${string}:${string}`[];
60
63
  selected?: boolean | undefined;
64
+ owned?: boolean | undefined;
61
65
  assets?: `${string}:${string}/${string}:${string}`[] | undefined;
62
66
  }[] | undefined, import("@metamask/superstruct").Struct<{
63
67
  address: string;
64
68
  id: string;
65
69
  scopes: `${string}:${string}`[];
66
70
  selected?: boolean | undefined;
71
+ owned?: boolean | undefined;
67
72
  assets?: `${string}:${string}/${string}:${string}`[] | undefined;
68
73
  }, {
69
74
  address: import("@metamask/superstruct").Struct<string, null>;
70
75
  id: import("@metamask/superstruct").Struct<string, null>;
71
76
  scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
72
77
  selected: import("@metamask/superstruct").Struct<boolean | undefined, null>;
78
+ owned: import("@metamask/superstruct").Struct<boolean | undefined, null>;
73
79
  assets: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
74
80
  }>>;
75
81
  assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, {
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.cts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AA0BnD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;EAM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,CAAC,qBAAqB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAK5E"}
@@ -4,12 +4,14 @@ declare const SimulationAccountStruct: import("@metamask/superstruct").Struct<{
4
4
  id: string;
5
5
  scopes: `${string}:${string}`[];
6
6
  selected?: boolean | undefined;
7
+ owned?: boolean | undefined;
7
8
  assets?: `${string}:${string}/${string}:${string}`[] | undefined;
8
9
  }, {
9
10
  address: import("@metamask/superstruct").Struct<string, null>;
10
11
  id: import("@metamask/superstruct").Struct<string, null>;
11
12
  scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
12
13
  selected: import("@metamask/superstruct").Struct<boolean | undefined, null>;
14
+ owned: import("@metamask/superstruct").Struct<boolean | undefined, null>;
13
15
  assets: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
14
16
  }>;
15
17
  export type SimulationAccount = Infer<typeof SimulationAccountStruct>;
@@ -36,6 +38,7 @@ declare const SimulationOptionsStruct: import("@metamask/superstruct").Struct<{
36
38
  id: string;
37
39
  scopes: `${string}:${string}`[];
38
40
  selected?: boolean | undefined;
41
+ owned?: boolean | undefined;
39
42
  assets?: `${string}:${string}/${string}:${string}`[] | undefined;
40
43
  }[] | undefined;
41
44
  hideBalances?: boolean | undefined;
@@ -58,18 +61,21 @@ declare const SimulationOptionsStruct: import("@metamask/superstruct").Struct<{
58
61
  id: string;
59
62
  scopes: `${string}:${string}`[];
60
63
  selected?: boolean | undefined;
64
+ owned?: boolean | undefined;
61
65
  assets?: `${string}:${string}/${string}:${string}`[] | undefined;
62
66
  }[] | undefined, import("@metamask/superstruct").Struct<{
63
67
  address: string;
64
68
  id: string;
65
69
  scopes: `${string}:${string}`[];
66
70
  selected?: boolean | undefined;
71
+ owned?: boolean | undefined;
67
72
  assets?: `${string}:${string}/${string}:${string}`[] | undefined;
68
73
  }, {
69
74
  address: import("@metamask/superstruct").Struct<string, null>;
70
75
  id: import("@metamask/superstruct").Struct<string, null>;
71
76
  scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
72
77
  selected: import("@metamask/superstruct").Struct<boolean | undefined, null>;
78
+ owned: import("@metamask/superstruct").Struct<boolean | undefined, null>;
73
79
  assets: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
74
80
  }>>;
75
81
  assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, {
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.mts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AA0BnD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;EAM3B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEtE,QAAA,MAAM,qBAAqB;;;;;;EAGzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAElE,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B3B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAK5E"}
1
+ {"version":3,"file":"options.d.mts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AA0BnD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;EAO3B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEtE,QAAA,MAAM,qBAAqB;;;;;;EAGzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAElE,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B3B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAK5E"}
package/dist/options.mjs CHANGED
@@ -6,6 +6,7 @@ const SimulationAccountStruct = object({
6
6
  id: string(),
7
7
  scopes: array(CaipChainIdStruct),
8
8
  selected: defaulted(optional(boolean()), false),
9
+ owned: defaulted(optional(boolean()), false),
9
10
  assets: defaulted(optional(array(CaipAssetTypeStruct)), []),
10
11
  });
11
12
  const SimulationAssetStruct = object({
@@ -1 +1 @@
1
- {"version":3,"file":"options.mjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACX,wB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,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC,EAC5D,cAAc,CACf;IACD,YAAY,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC;IACnD,iBAAiB,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACvD,sBAAsB,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,iBAAiB,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACvD,kBAAkB,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACxD,eAAe,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACrD,eAAe,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACrD,sBAAsB,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,YAAY,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;CACnD,CAAC,CAAC;AAmCH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAA8B;IACvD,OAAO,MAAM,CACX,OAAO,EACP,uBAAuB,CACW,CAAC;AACvC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n DEFAULT_ACCOUNTS,\n DEFAULT_ASSETS,\n DEFAULT_CURRENCY,\n DEFAULT_LOCALE,\n DEFAULT_SRP,\n} from './constants';\n\nconst SimulationAccountStruct = object({\n address: string(),\n id: string(),\n scopes: array(CaipChainIdStruct),\n selected: defaulted(optional(boolean()), false),\n assets: defaulted(optional(array(CaipAssetTypeStruct)), []),\n});\n\nexport type SimulationAccount = Infer<typeof SimulationAccountStruct>;\n\nconst SimulationAssetStruct = object({\n name: string(),\n symbol: string(),\n});\n\nexport type SimulationAsset = Infer<typeof SimulationAssetStruct>;\n\nconst SimulationOptionsStruct = object({\n currency: defaulted(optional(string()), DEFAULT_CURRENCY),\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n accounts: defaulted(\n optional(array(SimulationAccountStruct)),\n DEFAULT_ACCOUNTS,\n ),\n assets: defaulted(\n optional(record(CaipAssetTypeStruct, SimulationAssetStruct)),\n DEFAULT_ASSETS,\n ),\n hideBalances: defaulted(optional(boolean()), false),\n useSecurityAlerts: defaulted(optional(boolean()), true),\n simulateOnChainActions: defaulted(optional(boolean()), true),\n useTokenDetection: defaulted(optional(boolean()), true),\n batchCheckBalances: defaulted(optional(boolean()), true),\n displayNftMedia: defaulted(optional(boolean()), true),\n useNftDetection: defaulted(optional(boolean()), true),\n useExternalPricingData: defaulted(optional(boolean()), true),\n showTestnets: defaulted(optional(boolean()), true),\n});\n\n/**\n * Options for the simulation.\n *\n * @property currency - The currency to use. Defaults to `usd`.\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n * @property unencryptedState - The initial unencrypted state of the Snap, if\n * any. Defaults to `null`.\n * @property accounts - The accounts to use in the simulation, if any. Defaults\n * to an empty array.\n * @property assets - The assets to use in the simulation, if any. Defaults to\n * an empty object.\n * @property useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @property simulateOnChainActions - Whether to simulate transactions and signatures.\n * @property useTokenDetection - Whether to auto-detect tokens.\n * @property batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @property displayNftMedia - Whether to display NFT media.\n * @property useNftDetection - Whether to auto-detect NFTs.\n * @property useExternalPricingData - Whether to get token price data from an external source.\n * @property showTestnets - Whether to show testnets.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
1
+ {"version":3,"file":"options.mjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACX,wBAAwB;AAEzB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,EACZ,wBAAoB;AAErB,MAAM,uBAAuB,GAAG,MAAM,CAAC;IACrC,OAAO,EAAE,MAAM,EAAE;IACjB,EAAE,EAAE,MAAM,EAAE;IACZ,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAChC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC;IAC/C,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC;IAC5C,MAAM,EAAE,SAAS,CAAC,QA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O,EAAE,CAAC,EAAE,IAAI,CAAC;IACvD,kBAAkB,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACxD,eAAe,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACrD,eAAe,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACrD,sBAAsB,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,YAAY,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;CACnD,CAAC,CAAC;AAmCH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAA8B;IACvD,OAAO,MAAM,CACX,OAAO,EACP,uBAAuB,CACW,CAAC;AACvC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n DEFAULT_ACCOUNTS,\n DEFAULT_ASSETS,\n DEFAULT_CURRENCY,\n DEFAULT_LOCALE,\n DEFAULT_SRP,\n} from './constants';\n\nconst SimulationAccountStruct = object({\n address: string(),\n id: string(),\n scopes: array(CaipChainIdStruct),\n selected: defaulted(optional(boolean()), false),\n owned: defaulted(optional(boolean()), false),\n assets: defaulted(optional(array(CaipAssetTypeStruct)), []),\n});\n\nexport type SimulationAccount = Infer<typeof SimulationAccountStruct>;\n\nconst SimulationAssetStruct = object({\n name: string(),\n symbol: string(),\n});\n\nexport type SimulationAsset = Infer<typeof SimulationAssetStruct>;\n\nconst SimulationOptionsStruct = object({\n currency: defaulted(optional(string()), DEFAULT_CURRENCY),\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n accounts: defaulted(\n optional(array(SimulationAccountStruct)),\n DEFAULT_ACCOUNTS,\n ),\n assets: defaulted(\n optional(record(CaipAssetTypeStruct, SimulationAssetStruct)),\n DEFAULT_ASSETS,\n ),\n hideBalances: defaulted(optional(boolean()), false),\n useSecurityAlerts: defaulted(optional(boolean()), true),\n simulateOnChainActions: defaulted(optional(boolean()), true),\n useTokenDetection: defaulted(optional(boolean()), true),\n batchCheckBalances: defaulted(optional(boolean()), true),\n displayNftMedia: defaulted(optional(boolean()), true),\n useNftDetection: defaulted(optional(boolean()), true),\n useExternalPricingData: defaulted(optional(boolean()), true),\n showTestnets: defaulted(optional(boolean()), true),\n});\n\n/**\n * Options for the simulation.\n *\n * @property currency - The currency to use. Defaults to `usd`.\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n * @property unencryptedState - The initial unencrypted state of the Snap, if\n * any. Defaults to `null`.\n * @property accounts - The accounts to use in the simulation, if any. Defaults\n * to an empty array.\n * @property assets - The assets to use in the simulation, if any. Defaults to\n * an empty object.\n * @property useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @property simulateOnChainActions - Whether to simulate transactions and signatures.\n * @property useTokenDetection - Whether to auto-detect tokens.\n * @property batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @property displayNftMedia - Whether to display NFT media.\n * @property useNftDetection - Whether to auto-detect NFTs.\n * @property useExternalPricingData - Whether to get token price data from an external source.\n * @property showTestnets - Whether to show testnets.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
@@ -19,6 +19,7 @@ const get_mnemonic_seed_1 = require("./methods/hooks/get-mnemonic-seed.cjs");
19
19
  const middleware_1 = require("./middleware/index.cjs");
20
20
  const options_1 = require("./options.cjs");
21
21
  const store_1 = require("./store/index.cjs");
22
+ const account_1 = require("./utils/account.cjs");
22
23
  /**
23
24
  * Install a Snap in a simulated environment. This will fetch the Snap files,
24
25
  * create a Redux store, set up the controllers and JSON-RPC stack, register the
@@ -44,7 +45,7 @@ async function installSnap(snapId, { executionService, executionServiceOptions,
44
45
  // Create Redux store.
45
46
  const { store, runSaga } = (0, store_1.createStore)(options);
46
47
  const controllerMessenger = new base_controller_1.Messenger();
47
- registerActions(controllerMessenger, runSaga, options);
48
+ registerActions(controllerMessenger, runSaga, options, snapId);
48
49
  // Set up controllers and JSON-RPC stack.
49
50
  const restrictedHooks = getRestrictedHooks(options);
50
51
  const permittedHooks = getPermittedHooks(snapId, snapFiles, controllerMessenger, runSaga);
@@ -163,21 +164,34 @@ exports.getPermittedHooks = getPermittedHooks;
163
164
  * @param controllerMessenger - The controller messenger.
164
165
  * @param runSaga - The run saga function.
165
166
  * @param options - The simulation options.
167
+ * @param snapId - The ID of the Snap.
166
168
  */
167
- function registerActions(controllerMessenger, runSaga, options) {
169
+ function registerActions(controllerMessenger, runSaga, options, snapId) {
168
170
  controllerMessenger.registerActionHandler('PhishingController:testOrigin', () => ({ result: false, type: phishing_controller_1.PhishingDetectorResultType.All }));
169
- controllerMessenger.registerActionHandler('AccountsController:getAccountByAddress', (address) =>
171
+ controllerMessenger.registerActionHandler('AccountsController:getAccountByAddress',
170
172
  // @ts-expect-error - This is a partial account with only the necessary
171
173
  // data used by the interface controller.
172
- options.accounts.find((account) => address === account.address));
174
+ (address) => {
175
+ const matchingAccount = options.accounts.find((account) => address === account.address);
176
+ if (!matchingAccount) {
177
+ return undefined;
178
+ }
179
+ return (0, account_1.addSnapMetadataToAccount)(matchingAccount, snapId);
180
+ });
173
181
  controllerMessenger.registerActionHandler('AccountsController:getSelectedMultichainAccount',
174
182
  // @ts-expect-error - This is a partial account with only the necessary
175
183
  // data used by the interface controller.
176
- () => options.accounts.find((account) => account.selected));
177
- controllerMessenger.registerActionHandler('AccountsController:listMultichainAccounts',
184
+ () => {
185
+ const selectedAccount = options.accounts.find((account) => account.selected);
186
+ if (!selectedAccount) {
187
+ return undefined;
188
+ }
189
+ return (0, account_1.addSnapMetadataToAccount)(selectedAccount, snapId);
190
+ });
191
+ controllerMessenger.registerActionHandler('AccountsController:listMultichainAccounts', () =>
178
192
  // @ts-expect-error - These are partial accounts with only the necessary
179
193
  // data used by the interface controller.
180
- () => options.accounts);
194
+ options.accounts.map((account) => (0, account_1.addSnapMetadataToAccount)(account, snapId)));
181
195
  controllerMessenger.registerActionHandler('MultichainAssetsController:getState', () => ({
182
196
  // @ts-expect-error - These are partial assets with only the
183
197
  // necessary data used by the interface controller.
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.cjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":";;;AAIA,+DAAsD;AACtD,qFAA0E;AAE1E,uEAA2E;AAE3E,2DAK0C;AAC1C,mEAAoE;AAUpE,uDAAiD;AAGjD,qDAA2C;AAE3C,gDAA4C;AAG5C,mDAA6D;AAC7D,uCAAsC;AAEtC,2CAAuC;AACvC,+CAA8C;AAC9C,iDAAwD;AACxD,qDAMyB;AACzB,6EAAqF;AACrF,uDAAmD;AAEnD,2CAAuC;AAEvC,6CAA2D;AAqN3D;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,WAAW,CAK/B,MAAc,EACd,EACE,gBAAgB,EAChB,uBAAuB,EACvB,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mBAAmB,CAAC,qBAAqB,CACvC,qCAAqC,EACrC,GAAG,EAAE,CAAC,CAAC;QACL,4DAA4D;QAC5D,mDAAmD;QACnD,cAAc,EAAE,OAAO,CAAC,MAAM;QAC9B,cAAc,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;YACf,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;YACvC,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAAE,CACH;KACF,CAAC,CACH,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,+BAA+B,EAC/B,CAAC,IAAI,EAAE,EAAE;QACP;;;;;WAKG;QACH,QAAQ,CAAC,CAAC,uBAAuB;YAC/B,MAAM,gBAAgB,GAAc,MAAM,IAAA,gBAAM,EAAC,2BAAmB,CAAC,CAAC;YACtE,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QAED,MAAM,gBAAgB,GAA0B,OAAO,CACrD,uBAAuB,CACxB,CAAC,MAAM,EAAE,CAAC;QACX,OAAO,CACL,gBAAgB,EAAE,IAAI,KAAK,yCAAqB,CAAC,OAAO;YACxD,gBAAgB,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,CAClC,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,kCAAkC,EAClC,KAAK,EAAE,GAAW,EAAE,KAAc,EAAE,EAAE;QACpC,MAAM,OAAO,CAAC,2BAAe,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;QAElD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC;AAhFD,0CAgFC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n} from '@metamask/base-controller';\nimport { Messenger } from '@metamask/base-controller';\nimport { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport { PhishingDetectorResultType } from '@metamask/phishing-controller';\nimport type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n detectSnapLocation,\n fetchSnap,\n NodeThreadExecutionService,\n setupMultiplex,\n} from '@metamask/snaps-controllers/node';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport {\n type AuxiliaryFileEncoding,\n type Component,\n type InterfaceState,\n type InterfaceContext,\n type SnapId,\n type EntropySource,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { CaipAssetType, Json } from '@metamask/utils';\nimport type { Duplex } from 'readable-stream';\nimport { pipeline } from 'readable-stream';\nimport type { SagaIterator } from 'redux-saga';\nimport { select } from 'redux-saga/effects';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getControllers, registerSnap } from './controllers';\nimport { getSnapFile } from './files';\nimport type { SnapHelpers } from './helpers';\nimport { getHelpers } from './helpers';\nimport { resolveWithSaga } from './interface';\nimport { asyncResolve, getEndowments } from './methods';\nimport {\n getPermittedClearSnapStateMethodImplementation,\n getPermittedGetSnapStateMethodImplementation,\n getPermittedUpdateSnapStateMethodImplementation,\n getGetEntropySourcesImplementation,\n getGetMnemonicImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\nimport { createJsonRpcEngine } from './middleware';\nimport type { SimulationOptions, SimulationUserOptions } from './options';\nimport { getOptions } from './options';\nimport type { Interface, RunSagaFunction, Store } from './store';\nimport { createStore, getCurrentInterface } from './store';\n\n/**\n * Options for the execution service, without the options that are shared\n * between all execution services.\n *\n * @template Service - The type of the execution service, i.e., the class that\n * creates the execution service.\n */\nexport type ExecutionServiceOptions<\n Service extends new (...args: any[]) => any,\n> = Omit<\n ConstructorParameters<Service>[0],\n keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]\n>;\n\n/**\n * The options for running a Snap in a simulated environment.\n *\n * @property executionService - The execution service to use.\n * @property executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @property options - The simulation options.\n * @template Service - The type of the execution service.\n */\nexport type InstallSnapOptions<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService<unknown>>,\n> =\n ExecutionServiceOptions<Service> extends Record<string, never>\n ? {\n executionService: Service;\n executionServiceOptions?: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n }\n : {\n executionService: Service;\n executionServiceOptions: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n };\n\nexport type InstalledSnap = {\n snapId: SnapId;\n store: Store;\n executionService: InstanceType<typeof AbstractExecutionService>;\n controllerMessenger: Messenger<ActionConstraint, EventConstraint>;\n runSaga: RunSagaFunction;\n};\n\nexport type RestrictedMiddlewareHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the mnemonic from.\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns the seed derived from the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the seed from.\n * @returns The seed.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n};\n\nexport type PermittedMiddlewareHooks = {\n /**\n * A hook that gets whether the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * A hook that returns the entropy sources available to the Snap.\n *\n * @returns The entropy sources available to the Snap.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * A hook that returns a promise that resolves once the extension is unlocked.\n *\n * @param shouldShowUnlockRequest - Whether to show the unlock request.\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * A hook that returns whether the client is active or not.\n *\n * @returns A boolean flag signaling whether the client is opened.\n */\n getIsActive: () => boolean;\n\n /**\n * A hook that returns the Snap's auxiliary file for the given path. This hook\n * is bound to the Snap ID.\n *\n * @param path - The path of the auxiliary file to get.\n * @param encoding - The encoding to use when returning the file.\n * @returns The Snap's auxiliary file for the given path.\n */\n getSnapFile: (\n path: string,\n encoding: AuxiliaryFileEncoding,\n ) => Promise<string | null>;\n\n /**\n * A hook that gets the state of the Snap. This hook is bound to the Snap ID.\n *\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * @returns The current state of the Snap.\n */\n getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;\n\n /**\n * A hook that updates the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n */\n updateSnapState: (\n newState: Record<string, Json>,\n encrypted: boolean,\n ) => Promise<void>;\n\n /**\n * A hook that clears the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n */\n clearSnapState: (encrypted: boolean) => Promise<void>;\n\n /**\n * A hook that creates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param content - The content of the interface.\n * @param context - The context of the interface.\n * @returns The ID of the created interface.\n */\n createInterface: (\n content: Component,\n context?: InterfaceContext,\n ) => Promise<string>;\n\n /**\n * A hook that updates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to update.\n * @param content - The content of the interface.\n */\n updateInterface: (id: string, content: Component) => Promise<void>;\n\n /**\n * A hook that gets the state of an interface for the Snap. This hook is bound\n * to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The state of the interface.\n */\n getInterfaceState: (id: string) => InterfaceState;\n\n /**\n * A hook that gets the context of an interface for the Snap. This hook is\n * bound to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The context of the interface.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n\n /**\n * A hook that resolves an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to resolve.\n * @param value - The value to resolve the interface with.\n */\n resolveInterface: (id: string, value: Json) => Promise<void>;\n};\n\n/**\n * Install a Snap in a simulated environment. This will fetch the Snap files,\n * create a Redux store, set up the controllers and JSON-RPC stack, register the\n * Snap, and run the Snap code in the execution service.\n *\n * @param snapId - The ID of the Snap to install.\n * @param options - The options to use when installing the Snap.\n * @param options.executionService - The execution service to use.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The installed Snap object.\n * @template Service - The type of the execution service.\n */\nexport async function installSnap<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService>,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap & SnapHelpers> {\n const options = getOptions(rawOptions);\n\n // Fetch Snap files.\n const location = detectSnapLocation(snapId, {\n allowLocal: true,\n });\n\n const snapFiles = await fetchSnap(snapId, location);\n\n // Create Redux store.\n const { store, runSaga } = createStore(options);\n\n const controllerMessenger = new Messenger<any, any>();\n\n registerActions(controllerMessenger, runSaga, options);\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options);\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware: permissionController.createPermissionMiddleware({\n origin: snapId,\n }),\n });\n\n // Create execution service.\n const ExecutionService = executionService ?? NodeThreadExecutionService;\n const service = new ExecutionService({\n ...executionServiceOptions,\n messenger: controllerMessenger.getRestricted({\n name: 'ExecutionService',\n allowedActions: [],\n allowedEvents: [],\n }),\n setupSnapProvider: (_snapId: string, rpcStream: Duplex) => {\n const mux = setupMultiplex(rpcStream, 'snapStream');\n const stream = mux.createStream('metamask-provider');\n const providerStream = createEngineStream({ engine });\n\n // Error function is difficult to test, so we ignore it.\n /* istanbul ignore next 2 */\n pipeline(stream, providerStream, stream, (error: unknown) => {\n if (error) {\n logError(`Provider stream failure.`, error);\n }\n });\n },\n });\n\n // Register the Snap. This sets up the Snap's permissions and subject\n // metadata.\n await registerSnap(snapId, snapFiles.manifest.result, {\n permissionController,\n subjectMetadataController,\n });\n\n // Run the Snap code in the execution service.\n await service.executeSnap({\n snapId,\n sourceCode: snapFiles.sourceCode.toString('utf8'),\n endowments: await getEndowments(permissionController, snapId),\n });\n\n const helpers = getHelpers({\n snapId,\n store,\n controllerMessenger,\n runSaga,\n executionService: service,\n options,\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n ...helpers,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getMnemonicSeed: getGetMnemonicSeedImplementation(\n options.secretRecoveryPhrase,\n ),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param snapId - The ID of the Snap.\n * @param snapFiles - The fetched Snap files.\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n snapId: SnapId,\n snapFiles: FetchedSnapFiles,\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n hasPermission: () => true,\n getUnlockPromise: asyncResolve(),\n getIsLocked: () => false,\n getIsActive: () => true,\n\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n\n createInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterface',\n snapId,\n ...args,\n ),\n getInterfaceState: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).state,\n getInterfaceContext: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).context,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n\n getEntropySources: getGetEntropySourcesImplementation(),\n getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),\n updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),\n clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @param options - The simulation options.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getAccountByAddress',\n (address) =>\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n options.accounts.find((account) => address === account.address),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getSelectedMultichainAccount',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n () => options.accounts.find((account) => account.selected),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:listMultichainAccounts',\n // @ts-expect-error - These are partial accounts with only the necessary\n // data used by the interface controller.\n () => options.accounts,\n );\n\n controllerMessenger.registerActionHandler(\n 'MultichainAssetsController:getState',\n () => ({\n // @ts-expect-error - These are partial assets with only the\n // necessary data used by the interface controller.\n assetsMetadata: options.assets,\n accountsAssets: options.accounts.reduce<Record<string, CaipAssetType[]>>(\n (acc, account) => {\n acc[account.id] = account.assets ?? [];\n return acc;\n },\n {},\n ),\n }),\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:hasRequest',\n (opts) => {\n /**\n * Get the current interface from the store.\n *\n * @yields Selects the current interface from the store.\n * @returns The current interface.\n */\n function* getCurrentInterfaceSaga(): SagaIterator {\n const currentInterface: Interface = yield select(getCurrentInterface);\n return currentInterface;\n }\n\n const currentInterface: Interface | undefined = runSaga(\n getCurrentInterfaceSaga,\n ).result();\n return (\n currentInterface?.type === DIALOG_APPROVAL_TYPES.default &&\n currentInterface?.id === opts?.id\n );\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:acceptRequest',\n async (_id: string, value: unknown) => {\n await runSaga(resolveWithSaga, value).toPromise();\n\n return { value };\n },\n );\n}\n"]}
1
+ {"version":3,"file":"simulation.cjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":";;;AAIA,+DAAsD;AACtD,qFAA0E;AAE1E,uEAA2E;AAE3E,2DAK0C;AAC1C,mEAAoE;AAUpE,uDAAiD;AAGjD,qDAA2C;AAE3C,gDAA4C;AAG5C,mDAA6D;AAC7D,uCAAsC;AAEtC,2CAAuC;AACvC,+CAA8C;AAC9C,iDAAwD;AACxD,qDAMyB;AACzB,6EAAqF;AACrF,uDAAmD;AAEnD,2CAAuC;AAEvC,6CAA2D;AAC3D,iDAA2D;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,CACxB,CAAC,MAAM,EAAE,CAAC;QACX,OAAO,CACL,gBAAgB,EAAE,IAAI,KAAK,yCAAqB,CAAC,OAAO;YACxD,gBAAgB,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,CAClC,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,kCAAkC,EAClC,KAAK,EAAE,GAAW,EAAE,KAAc,EAAE,EAAE;QACpC,MAAM,OAAO,CAAC,2BAAe,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;QAElD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC;AAxGD,0CAwGC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n} from '@metamask/base-controller';\nimport { Messenger } from '@metamask/base-controller';\nimport { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport { PhishingDetectorResultType } from '@metamask/phishing-controller';\nimport type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n detectSnapLocation,\n fetchSnap,\n NodeThreadExecutionService,\n setupMultiplex,\n} from '@metamask/snaps-controllers/node';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport {\n type AuxiliaryFileEncoding,\n type Component,\n type InterfaceState,\n type InterfaceContext,\n type SnapId,\n type EntropySource,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { CaipAssetType, Json } from '@metamask/utils';\nimport type { Duplex } from 'readable-stream';\nimport { pipeline } from 'readable-stream';\nimport type { SagaIterator } from 'redux-saga';\nimport { select } from 'redux-saga/effects';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getControllers, registerSnap } from './controllers';\nimport { getSnapFile } from './files';\nimport type { SnapHelpers } from './helpers';\nimport { getHelpers } from './helpers';\nimport { resolveWithSaga } from './interface';\nimport { asyncResolve, getEndowments } from './methods';\nimport {\n getPermittedClearSnapStateMethodImplementation,\n getPermittedGetSnapStateMethodImplementation,\n getPermittedUpdateSnapStateMethodImplementation,\n getGetEntropySourcesImplementation,\n getGetMnemonicImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\nimport { createJsonRpcEngine } from './middleware';\nimport type { SimulationOptions, SimulationUserOptions } from './options';\nimport { getOptions } from './options';\nimport type { Interface, RunSagaFunction, Store } from './store';\nimport { createStore, getCurrentInterface } from './store';\nimport { addSnapMetadataToAccount } from './utils/account';\n\n/**\n * Options for the execution service, without the options that are shared\n * between all execution services.\n *\n * @template Service - The type of the execution service, i.e., the class that\n * creates the execution service.\n */\nexport type ExecutionServiceOptions<\n Service extends new (...args: any[]) => any,\n> = Omit<\n ConstructorParameters<Service>[0],\n keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]\n>;\n\n/**\n * The options for running a Snap in a simulated environment.\n *\n * @property executionService - The execution service to use.\n * @property executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @property options - The simulation options.\n * @template Service - The type of the execution service.\n */\nexport type InstallSnapOptions<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService<unknown>>,\n> =\n ExecutionServiceOptions<Service> extends Record<string, never>\n ? {\n executionService: Service;\n executionServiceOptions?: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n }\n : {\n executionService: Service;\n executionServiceOptions: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n };\n\nexport type InstalledSnap = {\n snapId: SnapId;\n store: Store;\n executionService: InstanceType<typeof AbstractExecutionService>;\n controllerMessenger: Messenger<ActionConstraint, EventConstraint>;\n runSaga: RunSagaFunction;\n};\n\nexport type RestrictedMiddlewareHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the mnemonic from.\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns the seed derived from the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the seed from.\n * @returns The seed.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n};\n\nexport type PermittedMiddlewareHooks = {\n /**\n * A hook that gets whether the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * A hook that returns the entropy sources available to the Snap.\n *\n * @returns The entropy sources available to the Snap.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * A hook that returns a promise that resolves once the extension is unlocked.\n *\n * @param shouldShowUnlockRequest - Whether to show the unlock request.\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * A hook that returns whether the client is active or not.\n *\n * @returns A boolean flag signaling whether the client is opened.\n */\n getIsActive: () => boolean;\n\n /**\n * A hook that returns the Snap's auxiliary file for the given path. This hook\n * is bound to the Snap ID.\n *\n * @param path - The path of the auxiliary file to get.\n * @param encoding - The encoding to use when returning the file.\n * @returns The Snap's auxiliary file for the given path.\n */\n getSnapFile: (\n path: string,\n encoding: AuxiliaryFileEncoding,\n ) => Promise<string | null>;\n\n /**\n * A hook that gets the state of the Snap. This hook is bound to the Snap ID.\n *\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * @returns The current state of the Snap.\n */\n getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;\n\n /**\n * A hook that updates the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n */\n updateSnapState: (\n newState: Record<string, Json>,\n encrypted: boolean,\n ) => Promise<void>;\n\n /**\n * A hook that clears the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n */\n clearSnapState: (encrypted: boolean) => Promise<void>;\n\n /**\n * A hook that creates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param content - The content of the interface.\n * @param context - The context of the interface.\n * @returns The ID of the created interface.\n */\n createInterface: (\n content: Component,\n context?: InterfaceContext,\n ) => Promise<string>;\n\n /**\n * A hook that updates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to update.\n * @param content - The content of the interface.\n */\n updateInterface: (id: string, content: Component) => Promise<void>;\n\n /**\n * A hook that gets the state of an interface for the Snap. This hook is bound\n * to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The state of the interface.\n */\n getInterfaceState: (id: string) => InterfaceState;\n\n /**\n * A hook that gets the context of an interface for the Snap. This hook is\n * bound to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The context of the interface.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n\n /**\n * A hook that resolves an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to resolve.\n * @param value - The value to resolve the interface with.\n */\n resolveInterface: (id: string, value: Json) => Promise<void>;\n};\n\n/**\n * Install a Snap in a simulated environment. This will fetch the Snap files,\n * create a Redux store, set up the controllers and JSON-RPC stack, register the\n * Snap, and run the Snap code in the execution service.\n *\n * @param snapId - The ID of the Snap to install.\n * @param options - The options to use when installing the Snap.\n * @param options.executionService - The execution service to use.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The installed Snap object.\n * @template Service - The type of the execution service.\n */\nexport async function installSnap<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService>,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap & SnapHelpers> {\n const options = getOptions(rawOptions);\n\n // Fetch Snap files.\n const location = detectSnapLocation(snapId, {\n allowLocal: true,\n });\n\n const snapFiles = await fetchSnap(snapId, location);\n\n // Create Redux store.\n const { store, runSaga } = createStore(options);\n\n const controllerMessenger = new Messenger<any, any>();\n\n registerActions(controllerMessenger, runSaga, options, snapId);\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options);\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware: permissionController.createPermissionMiddleware({\n origin: snapId,\n }),\n });\n\n // Create execution service.\n const ExecutionService = executionService ?? NodeThreadExecutionService;\n const service = new ExecutionService({\n ...executionServiceOptions,\n messenger: controllerMessenger.getRestricted({\n name: 'ExecutionService',\n allowedActions: [],\n allowedEvents: [],\n }),\n setupSnapProvider: (_snapId: string, rpcStream: Duplex) => {\n const mux = setupMultiplex(rpcStream, 'snapStream');\n const stream = mux.createStream('metamask-provider');\n const providerStream = createEngineStream({ engine });\n\n // Error function is difficult to test, so we ignore it.\n /* istanbul ignore next 2 */\n pipeline(stream, providerStream, stream, (error: unknown) => {\n if (error) {\n logError(`Provider stream failure.`, error);\n }\n });\n },\n });\n\n // Register the Snap. This sets up the Snap's permissions and subject\n // metadata.\n await registerSnap(snapId, snapFiles.manifest.result, {\n permissionController,\n subjectMetadataController,\n });\n\n // Run the Snap code in the execution service.\n await service.executeSnap({\n snapId,\n sourceCode: snapFiles.sourceCode.toString('utf8'),\n endowments: await getEndowments(permissionController, snapId),\n });\n\n const helpers = getHelpers({\n snapId,\n store,\n controllerMessenger,\n runSaga,\n executionService: service,\n options,\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n ...helpers,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getMnemonicSeed: getGetMnemonicSeedImplementation(\n options.secretRecoveryPhrase,\n ),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param snapId - The ID of the Snap.\n * @param snapFiles - The fetched Snap files.\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n snapId: SnapId,\n snapFiles: FetchedSnapFiles,\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n hasPermission: () => true,\n getUnlockPromise: asyncResolve(),\n getIsLocked: () => false,\n getIsActive: () => true,\n\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n\n createInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterface',\n snapId,\n ...args,\n ),\n getInterfaceState: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).state,\n getInterfaceContext: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).context,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n\n getEntropySources: getGetEntropySourcesImplementation(),\n getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),\n updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),\n clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @param options - The simulation options.\n * @param snapId - The ID of the Snap.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n snapId: SnapId,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getAccountByAddress',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n (address) => {\n const matchingAccount = options.accounts.find(\n (account) => address === account.address,\n );\n\n if (!matchingAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(matchingAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getSelectedMultichainAccount',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n () => {\n const selectedAccount = options.accounts.find(\n (account) => account.selected,\n );\n\n if (!selectedAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(selectedAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:listMultichainAccounts',\n\n () =>\n // @ts-expect-error - These are partial accounts with only the necessary\n // data used by the interface controller.\n options.accounts.map((account) =>\n addSnapMetadataToAccount(account, snapId),\n ),\n );\n\n controllerMessenger.registerActionHandler(\n 'MultichainAssetsController:getState',\n () => ({\n // @ts-expect-error - These are partial assets with only the\n // necessary data used by the interface controller.\n assetsMetadata: options.assets,\n accountsAssets: options.accounts.reduce<Record<string, CaipAssetType[]>>(\n (acc, account) => {\n acc[account.id] = account.assets ?? [];\n return acc;\n },\n {},\n ),\n }),\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:hasRequest',\n (opts) => {\n /**\n * Get the current interface from the store.\n *\n * @yields Selects the current interface from the store.\n * @returns The current interface.\n */\n function* getCurrentInterfaceSaga(): SagaIterator {\n const currentInterface: Interface = yield select(getCurrentInterface);\n return currentInterface;\n }\n\n const currentInterface: Interface | undefined = runSaga(\n getCurrentInterfaceSaga,\n ).result();\n return (\n currentInterface?.type === DIALOG_APPROVAL_TYPES.default &&\n currentInterface?.id === opts?.id\n );\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:acceptRequest',\n async (_id: string, value: unknown) => {\n await runSaga(resolveWithSaga, value).toPromise();\n\n return { value };\n },\n );\n}\n"]}
@@ -217,6 +217,7 @@ export declare function getPermittedHooks(snapId: SnapId, snapFiles: FetchedSnap
217
217
  * @param controllerMessenger - The controller messenger.
218
218
  * @param runSaga - The run saga function.
219
219
  * @param options - The simulation options.
220
+ * @param snapId - The ID of the Snap.
220
221
  */
221
- export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction, options: SimulationOptions): void;
222
+ export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction, options: SimulationOptions, snapId: SnapId): void;
222
223
  //# sourceMappingURL=simulation.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.d.cts","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAChB,kCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AAEjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAQ5E,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,MAAM,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,MAAM,EAAE,KAAK,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,OAAO,SAAS,KACd,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,YAAY,CAAC,OAAO,wBAAwB,CAAC,EAElD,MAAM,EAAE,MAAM,EACd,EACE,gBAAgB,EAChB,uBAAuB,EACvB,OAAO,EAAE,UAAe,GACzB,GAAE,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAM,GAC3C,OAAO,CAAC,aAAa,GAAG,WAAW,CAAC,CAiGtC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,iBAAiB,GACzB,yBAAyB,CAS3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,gBAAgB,EAC3B,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,GACvB,wBAAwB,CA8C1B;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,QAoGf"}
@@ -217,6 +217,7 @@ export declare function getPermittedHooks(snapId: SnapId, snapFiles: FetchedSnap
217
217
  * @param controllerMessenger - The controller messenger.
218
218
  * @param runSaga - The run saga function.
219
219
  * @param options - The simulation options.
220
+ * @param snapId - The ID of the Snap.
220
221
  */
221
- export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction, options: SimulationOptions): void;
222
+ export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction, options: SimulationOptions, snapId: SnapId): void;
222
223
  //# sourceMappingURL=simulation.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.d.mts","sourceRoot":"","sources":["../src/simulation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index.mjs";
17
17
  import { getOptions } from "./options.mjs";
18
18
  import { createStore, getCurrentInterface } from "./store/index.mjs";
19
+ import { addSnapMetadataToAccount } from "./utils/account.mjs";
19
20
  /**
20
21
  * Install a Snap in a simulated environment. This will fetch the Snap files,
21
22
  * create a Redux store, set up the controllers and JSON-RPC stack, register the
@@ -41,7 +42,7 @@ export async function installSnap(snapId, { executionService, executionServiceOp
41
42
  // Create Redux store.
42
43
  const { store, runSaga } = createStore(options);
43
44
  const controllerMessenger = new Messenger();
44
- registerActions(controllerMessenger, runSaga, options);
45
+ registerActions(controllerMessenger, runSaga, options, snapId);
45
46
  // Set up controllers and JSON-RPC stack.
46
47
  const restrictedHooks = getRestrictedHooks(options);
47
48
  const permittedHooks = getPermittedHooks(snapId, snapFiles, controllerMessenger, runSaga);
@@ -157,21 +158,34 @@ export function getPermittedHooks(snapId, snapFiles, controllerMessenger, runSag
157
158
  * @param controllerMessenger - The controller messenger.
158
159
  * @param runSaga - The run saga function.
159
160
  * @param options - The simulation options.
161
+ * @param snapId - The ID of the Snap.
160
162
  */
161
- export function registerActions(controllerMessenger, runSaga, options) {
163
+ export function registerActions(controllerMessenger, runSaga, options, snapId) {
162
164
  controllerMessenger.registerActionHandler('PhishingController:testOrigin', () => ({ result: false, type: PhishingDetectorResultType.All }));
163
- controllerMessenger.registerActionHandler('AccountsController:getAccountByAddress', (address) =>
165
+ controllerMessenger.registerActionHandler('AccountsController:getAccountByAddress',
164
166
  // @ts-expect-error - This is a partial account with only the necessary
165
167
  // data used by the interface controller.
166
- options.accounts.find((account) => address === account.address));
168
+ (address) => {
169
+ const matchingAccount = options.accounts.find((account) => address === account.address);
170
+ if (!matchingAccount) {
171
+ return undefined;
172
+ }
173
+ return addSnapMetadataToAccount(matchingAccount, snapId);
174
+ });
167
175
  controllerMessenger.registerActionHandler('AccountsController:getSelectedMultichainAccount',
168
176
  // @ts-expect-error - This is a partial account with only the necessary
169
177
  // data used by the interface controller.
170
- () => options.accounts.find((account) => account.selected));
171
- controllerMessenger.registerActionHandler('AccountsController:listMultichainAccounts',
178
+ () => {
179
+ const selectedAccount = options.accounts.find((account) => account.selected);
180
+ if (!selectedAccount) {
181
+ return undefined;
182
+ }
183
+ return addSnapMetadataToAccount(selectedAccount, snapId);
184
+ });
185
+ controllerMessenger.registerActionHandler('AccountsController:listMultichainAccounts', () =>
172
186
  // @ts-expect-error - These are partial accounts with only the necessary
173
187
  // data used by the interface controller.
174
- () => options.accounts);
188
+ options.accounts.map((account) => addSnapMetadataToAccount(account, snapId)));
175
189
  controllerMessenger.registerActionHandler('MultichainAssetsController:getState', () => ({
176
190
  // @ts-expect-error - These are partial assets with only the
177
191
  // necessary data used by the interface controller.
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.mjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AACtD,OAAO,EAAE,kBAAkB,EAAE,6CAA6C;AAE1E,OAAO,EAAE,0BAA0B,EAAE,sCAAsC;AAE3E,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACf,yCAAyC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,oCAAoC;AAUpE,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAGjD,OAAO,EAAE,QAAQ,EAAE,wBAAwB;AAE3C,OAAO,EAAE,MAAM,EAAE,2BAA2B;AAG5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,0BAAsB;AAC7D,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,OAAO,EAAE,UAAU,EAAE,sBAAkB;AACvC,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,4BAAkB;AACxD,OAAO,EACL,8CAA8C,EAC9C,4CAA4C,EAC5C,+CAA+C,EAC/C,kCAAkC,EAClC,4BAA4B,EAC7B,kCAAwB;AACzB,OAAO,EAAE,gCAAgC,EAA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AC3C,wEAAwE;IACxE,yCAAyC;IACzC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CACvB,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,qCAAqC,EACrC,GAAG,EAAE,CAAC,CAAC;QACL,4DAA4D;QAC5D,mDAAmD;QACnD,cAAc,EAAE,OAAO,CAAC,MAAM;QAC9B,cAAc,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;YACf,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;YACvC,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAAE,CACH;KACF,CAAC,CACH,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,+BAA+B,EAC/B,CAAC,IAAI,EAAE,EAAE;QACP;;;;;WAKG;QACH,QAAQ,CAAC,CAAC,uBAAuB;YAC/B,MAAM,gBAAgB,GAAc,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACtE,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QAED,MAAM,gBAAgB,GAA0B,OAAO,CACrD,uBAAuB,CACxB,CAAC,MAAM,EAAE,CAAC;QACX,OAAO,CACL,gBAAgB,EAAE,IAAI,KAAK,qBAAqB,CAAC,OAAO;YACxD,gBAAgB,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,CAClC,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,kCAAkC,EAClC,KAAK,EAAE,GAAW,EAAE,KAAc,EAAE,EAAE;QACpC,MAAM,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;QAElD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n} from '@metamask/base-controller';\nimport { Messenger } from '@metamask/base-controller';\nimport { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport { PhishingDetectorResultType } from '@metamask/phishing-controller';\nimport type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n detectSnapLocation,\n fetchSnap,\n NodeThreadExecutionService,\n setupMultiplex,\n} from '@metamask/snaps-controllers/node';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport {\n type AuxiliaryFileEncoding,\n type Component,\n type InterfaceState,\n type InterfaceContext,\n type SnapId,\n type EntropySource,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { CaipAssetType, Json } from '@metamask/utils';\nimport type { Duplex } from 'readable-stream';\nimport { pipeline } from 'readable-stream';\nimport type { SagaIterator } from 'redux-saga';\nimport { select } from 'redux-saga/effects';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getControllers, registerSnap } from './controllers';\nimport { getSnapFile } from './files';\nimport type { SnapHelpers } from './helpers';\nimport { getHelpers } from './helpers';\nimport { resolveWithSaga } from './interface';\nimport { asyncResolve, getEndowments } from './methods';\nimport {\n getPermittedClearSnapStateMethodImplementation,\n getPermittedGetSnapStateMethodImplementation,\n getPermittedUpdateSnapStateMethodImplementation,\n getGetEntropySourcesImplementation,\n getGetMnemonicImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\nimport { createJsonRpcEngine } from './middleware';\nimport type { SimulationOptions, SimulationUserOptions } from './options';\nimport { getOptions } from './options';\nimport type { Interface, RunSagaFunction, Store } from './store';\nimport { createStore, getCurrentInterface } from './store';\n\n/**\n * Options for the execution service, without the options that are shared\n * between all execution services.\n *\n * @template Service - The type of the execution service, i.e., the class that\n * creates the execution service.\n */\nexport type ExecutionServiceOptions<\n Service extends new (...args: any[]) => any,\n> = Omit<\n ConstructorParameters<Service>[0],\n keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]\n>;\n\n/**\n * The options for running a Snap in a simulated environment.\n *\n * @property executionService - The execution service to use.\n * @property executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @property options - The simulation options.\n * @template Service - The type of the execution service.\n */\nexport type InstallSnapOptions<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService<unknown>>,\n> =\n ExecutionServiceOptions<Service> extends Record<string, never>\n ? {\n executionService: Service;\n executionServiceOptions?: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n }\n : {\n executionService: Service;\n executionServiceOptions: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n };\n\nexport type InstalledSnap = {\n snapId: SnapId;\n store: Store;\n executionService: InstanceType<typeof AbstractExecutionService>;\n controllerMessenger: Messenger<ActionConstraint, EventConstraint>;\n runSaga: RunSagaFunction;\n};\n\nexport type RestrictedMiddlewareHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the mnemonic from.\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns the seed derived from the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the seed from.\n * @returns The seed.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n};\n\nexport type PermittedMiddlewareHooks = {\n /**\n * A hook that gets whether the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * A hook that returns the entropy sources available to the Snap.\n *\n * @returns The entropy sources available to the Snap.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * A hook that returns a promise that resolves once the extension is unlocked.\n *\n * @param shouldShowUnlockRequest - Whether to show the unlock request.\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * A hook that returns whether the client is active or not.\n *\n * @returns A boolean flag signaling whether the client is opened.\n */\n getIsActive: () => boolean;\n\n /**\n * A hook that returns the Snap's auxiliary file for the given path. This hook\n * is bound to the Snap ID.\n *\n * @param path - The path of the auxiliary file to get.\n * @param encoding - The encoding to use when returning the file.\n * @returns The Snap's auxiliary file for the given path.\n */\n getSnapFile: (\n path: string,\n encoding: AuxiliaryFileEncoding,\n ) => Promise<string | null>;\n\n /**\n * A hook that gets the state of the Snap. This hook is bound to the Snap ID.\n *\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * @returns The current state of the Snap.\n */\n getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;\n\n /**\n * A hook that updates the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n */\n updateSnapState: (\n newState: Record<string, Json>,\n encrypted: boolean,\n ) => Promise<void>;\n\n /**\n * A hook that clears the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n */\n clearSnapState: (encrypted: boolean) => Promise<void>;\n\n /**\n * A hook that creates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param content - The content of the interface.\n * @param context - The context of the interface.\n * @returns The ID of the created interface.\n */\n createInterface: (\n content: Component,\n context?: InterfaceContext,\n ) => Promise<string>;\n\n /**\n * A hook that updates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to update.\n * @param content - The content of the interface.\n */\n updateInterface: (id: string, content: Component) => Promise<void>;\n\n /**\n * A hook that gets the state of an interface for the Snap. This hook is bound\n * to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The state of the interface.\n */\n getInterfaceState: (id: string) => InterfaceState;\n\n /**\n * A hook that gets the context of an interface for the Snap. This hook is\n * bound to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The context of the interface.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n\n /**\n * A hook that resolves an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to resolve.\n * @param value - The value to resolve the interface with.\n */\n resolveInterface: (id: string, value: Json) => Promise<void>;\n};\n\n/**\n * Install a Snap in a simulated environment. This will fetch the Snap files,\n * create a Redux store, set up the controllers and JSON-RPC stack, register the\n * Snap, and run the Snap code in the execution service.\n *\n * @param snapId - The ID of the Snap to install.\n * @param options - The options to use when installing the Snap.\n * @param options.executionService - The execution service to use.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The installed Snap object.\n * @template Service - The type of the execution service.\n */\nexport async function installSnap<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService>,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap & SnapHelpers> {\n const options = getOptions(rawOptions);\n\n // Fetch Snap files.\n const location = detectSnapLocation(snapId, {\n allowLocal: true,\n });\n\n const snapFiles = await fetchSnap(snapId, location);\n\n // Create Redux store.\n const { store, runSaga } = createStore(options);\n\n const controllerMessenger = new Messenger<any, any>();\n\n registerActions(controllerMessenger, runSaga, options);\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options);\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware: permissionController.createPermissionMiddleware({\n origin: snapId,\n }),\n });\n\n // Create execution service.\n const ExecutionService = executionService ?? NodeThreadExecutionService;\n const service = new ExecutionService({\n ...executionServiceOptions,\n messenger: controllerMessenger.getRestricted({\n name: 'ExecutionService',\n allowedActions: [],\n allowedEvents: [],\n }),\n setupSnapProvider: (_snapId: string, rpcStream: Duplex) => {\n const mux = setupMultiplex(rpcStream, 'snapStream');\n const stream = mux.createStream('metamask-provider');\n const providerStream = createEngineStream({ engine });\n\n // Error function is difficult to test, so we ignore it.\n /* istanbul ignore next 2 */\n pipeline(stream, providerStream, stream, (error: unknown) => {\n if (error) {\n logError(`Provider stream failure.`, error);\n }\n });\n },\n });\n\n // Register the Snap. This sets up the Snap's permissions and subject\n // metadata.\n await registerSnap(snapId, snapFiles.manifest.result, {\n permissionController,\n subjectMetadataController,\n });\n\n // Run the Snap code in the execution service.\n await service.executeSnap({\n snapId,\n sourceCode: snapFiles.sourceCode.toString('utf8'),\n endowments: await getEndowments(permissionController, snapId),\n });\n\n const helpers = getHelpers({\n snapId,\n store,\n controllerMessenger,\n runSaga,\n executionService: service,\n options,\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n ...helpers,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getMnemonicSeed: getGetMnemonicSeedImplementation(\n options.secretRecoveryPhrase,\n ),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param snapId - The ID of the Snap.\n * @param snapFiles - The fetched Snap files.\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n snapId: SnapId,\n snapFiles: FetchedSnapFiles,\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n hasPermission: () => true,\n getUnlockPromise: asyncResolve(),\n getIsLocked: () => false,\n getIsActive: () => true,\n\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n\n createInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterface',\n snapId,\n ...args,\n ),\n getInterfaceState: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).state,\n getInterfaceContext: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).context,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n\n getEntropySources: getGetEntropySourcesImplementation(),\n getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),\n updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),\n clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @param options - The simulation options.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getAccountByAddress',\n (address) =>\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n options.accounts.find((account) => address === account.address),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getSelectedMultichainAccount',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n () => options.accounts.find((account) => account.selected),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:listMultichainAccounts',\n // @ts-expect-error - These are partial accounts with only the necessary\n // data used by the interface controller.\n () => options.accounts,\n );\n\n controllerMessenger.registerActionHandler(\n 'MultichainAssetsController:getState',\n () => ({\n // @ts-expect-error - These are partial assets with only the\n // necessary data used by the interface controller.\n assetsMetadata: options.assets,\n accountsAssets: options.accounts.reduce<Record<string, CaipAssetType[]>>(\n (acc, account) => {\n acc[account.id] = account.assets ?? [];\n return acc;\n },\n {},\n ),\n }),\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:hasRequest',\n (opts) => {\n /**\n * Get the current interface from the store.\n *\n * @yields Selects the current interface from the store.\n * @returns The current interface.\n */\n function* getCurrentInterfaceSaga(): SagaIterator {\n const currentInterface: Interface = yield select(getCurrentInterface);\n return currentInterface;\n }\n\n const currentInterface: Interface | undefined = runSaga(\n getCurrentInterfaceSaga,\n ).result();\n return (\n currentInterface?.type === DIALOG_APPROVAL_TYPES.default &&\n currentInterface?.id === opts?.id\n );\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:acceptRequest',\n async (_id: string, value: unknown) => {\n await runSaga(resolveWithSaga, value).toPromise();\n\n return { value };\n },\n );\n}\n"]}
1
+ {"version":3,"file":"simulation.mjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AACtD,OAAO,EAAE,kBAAkB,EAAE,6CAA6C;AAE1E,OAAO,EAAE,0BAA0B,EAAE,sCAAsC;AAE3E,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACf,yCAAyC;AAC1C,OAAO,EAAE,qBAAqB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C,QAAQ,CAAC,MAAM,CACrC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;YACf,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;YACvC,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAAE,CACH;KACF,CAAC,CACH,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,+BAA+B,EAC/B,CAAC,IAAI,EAAE,EAAE;QACP;;;;;WAKG;QACH,QAAQ,CAAC,CAAC,uBAAuB;YAC/B,MAAM,gBAAgB,GAAc,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACtE,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QAED,MAAM,gBAAgB,GAA0B,OAAO,CACrD,uBAAuB,CACxB,CAAC,MAAM,EAAE,CAAC;QACX,OAAO,CACL,gBAAgB,EAAE,IAAI,KAAK,qBAAqB,CAAC,OAAO;YACxD,gBAAgB,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,CAClC,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,kCAAkC,EAClC,KAAK,EAAE,GAAW,EAAE,KAAc,EAAE,EAAE;QACpC,MAAM,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;QAElD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n} from '@metamask/base-controller';\nimport { Messenger } from '@metamask/base-controller';\nimport { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport { PhishingDetectorResultType } from '@metamask/phishing-controller';\nimport type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n detectSnapLocation,\n fetchSnap,\n NodeThreadExecutionService,\n setupMultiplex,\n} from '@metamask/snaps-controllers/node';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport {\n type AuxiliaryFileEncoding,\n type Component,\n type InterfaceState,\n type InterfaceContext,\n type SnapId,\n type EntropySource,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { CaipAssetType, Json } from '@metamask/utils';\nimport type { Duplex } from 'readable-stream';\nimport { pipeline } from 'readable-stream';\nimport type { SagaIterator } from 'redux-saga';\nimport { select } from 'redux-saga/effects';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getControllers, registerSnap } from './controllers';\nimport { getSnapFile } from './files';\nimport type { SnapHelpers } from './helpers';\nimport { getHelpers } from './helpers';\nimport { resolveWithSaga } from './interface';\nimport { asyncResolve, getEndowments } from './methods';\nimport {\n getPermittedClearSnapStateMethodImplementation,\n getPermittedGetSnapStateMethodImplementation,\n getPermittedUpdateSnapStateMethodImplementation,\n getGetEntropySourcesImplementation,\n getGetMnemonicImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\nimport { createJsonRpcEngine } from './middleware';\nimport type { SimulationOptions, SimulationUserOptions } from './options';\nimport { getOptions } from './options';\nimport type { Interface, RunSagaFunction, Store } from './store';\nimport { createStore, getCurrentInterface } from './store';\nimport { addSnapMetadataToAccount } from './utils/account';\n\n/**\n * Options for the execution service, without the options that are shared\n * between all execution services.\n *\n * @template Service - The type of the execution service, i.e., the class that\n * creates the execution service.\n */\nexport type ExecutionServiceOptions<\n Service extends new (...args: any[]) => any,\n> = Omit<\n ConstructorParameters<Service>[0],\n keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]\n>;\n\n/**\n * The options for running a Snap in a simulated environment.\n *\n * @property executionService - The execution service to use.\n * @property executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @property options - The simulation options.\n * @template Service - The type of the execution service.\n */\nexport type InstallSnapOptions<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService<unknown>>,\n> =\n ExecutionServiceOptions<Service> extends Record<string, never>\n ? {\n executionService: Service;\n executionServiceOptions?: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n }\n : {\n executionService: Service;\n executionServiceOptions: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n };\n\nexport type InstalledSnap = {\n snapId: SnapId;\n store: Store;\n executionService: InstanceType<typeof AbstractExecutionService>;\n controllerMessenger: Messenger<ActionConstraint, EventConstraint>;\n runSaga: RunSagaFunction;\n};\n\nexport type RestrictedMiddlewareHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the mnemonic from.\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns the seed derived from the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the seed from.\n * @returns The seed.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n};\n\nexport type PermittedMiddlewareHooks = {\n /**\n * A hook that gets whether the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * A hook that returns the entropy sources available to the Snap.\n *\n * @returns The entropy sources available to the Snap.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * A hook that returns a promise that resolves once the extension is unlocked.\n *\n * @param shouldShowUnlockRequest - Whether to show the unlock request.\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n\n /**\n * A hook that returns whether the client is active or not.\n *\n * @returns A boolean flag signaling whether the client is opened.\n */\n getIsActive: () => boolean;\n\n /**\n * A hook that returns the Snap's auxiliary file for the given path. This hook\n * is bound to the Snap ID.\n *\n * @param path - The path of the auxiliary file to get.\n * @param encoding - The encoding to use when returning the file.\n * @returns The Snap's auxiliary file for the given path.\n */\n getSnapFile: (\n path: string,\n encoding: AuxiliaryFileEncoding,\n ) => Promise<string | null>;\n\n /**\n * A hook that gets the state of the Snap. This hook is bound to the Snap ID.\n *\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * @returns The current state of the Snap.\n */\n getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;\n\n /**\n * A hook that updates the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n */\n updateSnapState: (\n newState: Record<string, Json>,\n encrypted: boolean,\n ) => Promise<void>;\n\n /**\n * A hook that clears the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n */\n clearSnapState: (encrypted: boolean) => Promise<void>;\n\n /**\n * A hook that creates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param content - The content of the interface.\n * @param context - The context of the interface.\n * @returns The ID of the created interface.\n */\n createInterface: (\n content: Component,\n context?: InterfaceContext,\n ) => Promise<string>;\n\n /**\n * A hook that updates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to update.\n * @param content - The content of the interface.\n */\n updateInterface: (id: string, content: Component) => Promise<void>;\n\n /**\n * A hook that gets the state of an interface for the Snap. This hook is bound\n * to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The state of the interface.\n */\n getInterfaceState: (id: string) => InterfaceState;\n\n /**\n * A hook that gets the context of an interface for the Snap. This hook is\n * bound to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The context of the interface.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n\n /**\n * A hook that resolves an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to resolve.\n * @param value - The value to resolve the interface with.\n */\n resolveInterface: (id: string, value: Json) => Promise<void>;\n};\n\n/**\n * Install a Snap in a simulated environment. This will fetch the Snap files,\n * create a Redux store, set up the controllers and JSON-RPC stack, register the\n * Snap, and run the Snap code in the execution service.\n *\n * @param snapId - The ID of the Snap to install.\n * @param options - The options to use when installing the Snap.\n * @param options.executionService - The execution service to use.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The installed Snap object.\n * @template Service - The type of the execution service.\n */\nexport async function installSnap<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService>,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap & SnapHelpers> {\n const options = getOptions(rawOptions);\n\n // Fetch Snap files.\n const location = detectSnapLocation(snapId, {\n allowLocal: true,\n });\n\n const snapFiles = await fetchSnap(snapId, location);\n\n // Create Redux store.\n const { store, runSaga } = createStore(options);\n\n const controllerMessenger = new Messenger<any, any>();\n\n registerActions(controllerMessenger, runSaga, options, snapId);\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options);\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware: permissionController.createPermissionMiddleware({\n origin: snapId,\n }),\n });\n\n // Create execution service.\n const ExecutionService = executionService ?? NodeThreadExecutionService;\n const service = new ExecutionService({\n ...executionServiceOptions,\n messenger: controllerMessenger.getRestricted({\n name: 'ExecutionService',\n allowedActions: [],\n allowedEvents: [],\n }),\n setupSnapProvider: (_snapId: string, rpcStream: Duplex) => {\n const mux = setupMultiplex(rpcStream, 'snapStream');\n const stream = mux.createStream('metamask-provider');\n const providerStream = createEngineStream({ engine });\n\n // Error function is difficult to test, so we ignore it.\n /* istanbul ignore next 2 */\n pipeline(stream, providerStream, stream, (error: unknown) => {\n if (error) {\n logError(`Provider stream failure.`, error);\n }\n });\n },\n });\n\n // Register the Snap. This sets up the Snap's permissions and subject\n // metadata.\n await registerSnap(snapId, snapFiles.manifest.result, {\n permissionController,\n subjectMetadataController,\n });\n\n // Run the Snap code in the execution service.\n await service.executeSnap({\n snapId,\n sourceCode: snapFiles.sourceCode.toString('utf8'),\n endowments: await getEndowments(permissionController, snapId),\n });\n\n const helpers = getHelpers({\n snapId,\n store,\n controllerMessenger,\n runSaga,\n executionService: service,\n options,\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n ...helpers,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getMnemonicSeed: getGetMnemonicSeedImplementation(\n options.secretRecoveryPhrase,\n ),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param snapId - The ID of the Snap.\n * @param snapFiles - The fetched Snap files.\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n snapId: SnapId,\n snapFiles: FetchedSnapFiles,\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n hasPermission: () => true,\n getUnlockPromise: asyncResolve(),\n getIsLocked: () => false,\n getIsActive: () => true,\n\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n\n createInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterface',\n snapId,\n ...args,\n ),\n getInterfaceState: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).state,\n getInterfaceContext: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).context,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n\n getEntropySources: getGetEntropySourcesImplementation(),\n getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),\n updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),\n clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @param options - The simulation options.\n * @param snapId - The ID of the Snap.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n snapId: SnapId,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getAccountByAddress',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n (address) => {\n const matchingAccount = options.accounts.find(\n (account) => address === account.address,\n );\n\n if (!matchingAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(matchingAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getSelectedMultichainAccount',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n () => {\n const selectedAccount = options.accounts.find(\n (account) => account.selected,\n );\n\n if (!selectedAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(selectedAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:listMultichainAccounts',\n\n () =>\n // @ts-expect-error - These are partial accounts with only the necessary\n // data used by the interface controller.\n options.accounts.map((account) =>\n addSnapMetadataToAccount(account, snapId),\n ),\n );\n\n controllerMessenger.registerActionHandler(\n 'MultichainAssetsController:getState',\n () => ({\n // @ts-expect-error - These are partial assets with only the\n // necessary data used by the interface controller.\n assetsMetadata: options.assets,\n accountsAssets: options.accounts.reduce<Record<string, CaipAssetType[]>>(\n (acc, account) => {\n acc[account.id] = account.assets ?? [];\n return acc;\n },\n {},\n ),\n }),\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:hasRequest',\n (opts) => {\n /**\n * Get the current interface from the store.\n *\n * @yields Selects the current interface from the store.\n * @returns The current interface.\n */\n function* getCurrentInterfaceSaga(): SagaIterator {\n const currentInterface: Interface = yield select(getCurrentInterface);\n return currentInterface;\n }\n\n const currentInterface: Interface | undefined = runSaga(\n getCurrentInterfaceSaga,\n ).result();\n return (\n currentInterface?.type === DIALOG_APPROVAL_TYPES.default &&\n currentInterface?.id === opts?.id\n );\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:acceptRequest',\n async (_id: string, value: unknown) => {\n await runSaga(resolveWithSaga, value).toPromise();\n\n return { value };\n },\n );\n}\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSnapMetadataToAccount = void 0;
4
+ const addSnapMetadataToAccount = (account, snapId) => {
5
+ if (!account.owned) {
6
+ return {
7
+ ...account,
8
+ metadata: {},
9
+ };
10
+ }
11
+ return {
12
+ ...account,
13
+ metadata: {
14
+ snap: {
15
+ id: snapId,
16
+ },
17
+ },
18
+ };
19
+ };
20
+ exports.addSnapMetadataToAccount = addSnapMetadataToAccount;
21
+ //# sourceMappingURL=account.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":";;;AAIO,MAAM,wBAAwB,GAAG,CACtC,OAA0B,EAC1B,MAAc,EACd,EAAE;IACF,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO;YACL,GAAG,OAAO;YACV,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,QAAQ,EAAE;YACR,IAAI,EAAE;gBACJ,EAAE,EAAE,MAAM;aACX;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,wBAAwB,4BAmBnC","sourcesContent":["import type { SnapId } from '@metamask/snaps-sdk';\n\nimport type { SimulationAccount } from '../options';\n\nexport const addSnapMetadataToAccount = (\n account: SimulationAccount,\n snapId: SnapId,\n) => {\n if (!account.owned) {\n return {\n ...account,\n metadata: {},\n };\n }\n\n return {\n ...account,\n metadata: {\n snap: {\n id: snapId,\n },\n },\n };\n};\n"]}
@@ -0,0 +1,26 @@
1
+ import type { SnapId } from "@metamask/snaps-sdk";
2
+ import type { SimulationAccount } from "../options.cjs";
3
+ export declare const addSnapMetadataToAccount: (account: SimulationAccount, snapId: SnapId) => {
4
+ metadata: {
5
+ snap?: undefined;
6
+ };
7
+ address: string;
8
+ id: string;
9
+ scopes: `${string}:${string}`[];
10
+ selected?: boolean | undefined;
11
+ owned?: boolean | undefined;
12
+ assets?: `${string}:${string}/${string}:${string}`[] | undefined;
13
+ } | {
14
+ metadata: {
15
+ snap: {
16
+ id: SnapId;
17
+ };
18
+ };
19
+ address: string;
20
+ id: string;
21
+ scopes: `${string}:${string}`[];
22
+ selected?: boolean | undefined;
23
+ owned?: boolean | undefined;
24
+ assets?: `${string}:${string}/${string}:${string}`[] | undefined;
25
+ };
26
+ //# sourceMappingURL=account.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD,eAAO,MAAM,wBAAwB,YAC1B,iBAAiB,UAClB,MAAM;;;;;;;;;;;;;;;;;;;;;;CAiBf,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { SnapId } from "@metamask/snaps-sdk";
2
+ import type { SimulationAccount } from "../options.mjs";
3
+ export declare const addSnapMetadataToAccount: (account: SimulationAccount, snapId: SnapId) => {
4
+ metadata: {
5
+ snap?: undefined;
6
+ };
7
+ address: string;
8
+ id: string;
9
+ scopes: `${string}:${string}`[];
10
+ selected?: boolean | undefined;
11
+ owned?: boolean | undefined;
12
+ assets?: `${string}:${string}/${string}:${string}`[] | undefined;
13
+ } | {
14
+ metadata: {
15
+ snap: {
16
+ id: SnapId;
17
+ };
18
+ };
19
+ address: string;
20
+ id: string;
21
+ scopes: `${string}:${string}`[];
22
+ selected?: boolean | undefined;
23
+ owned?: boolean | undefined;
24
+ assets?: `${string}:${string}/${string}:${string}`[] | undefined;
25
+ };
26
+ //# sourceMappingURL=account.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD,eAAO,MAAM,wBAAwB,YAC1B,iBAAiB,UAClB,MAAM;;;;;;;;;;;;;;;;;;;;;;CAiBf,CAAC"}
@@ -0,0 +1,17 @@
1
+ export const addSnapMetadataToAccount = (account, snapId) => {
2
+ if (!account.owned) {
3
+ return {
4
+ ...account,
5
+ metadata: {},
6
+ };
7
+ }
8
+ return {
9
+ ...account,
10
+ metadata: {
11
+ snap: {
12
+ id: snapId,
13
+ },
14
+ },
15
+ };
16
+ };
17
+ //# sourceMappingURL=account.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.mjs","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,OAA0B,EAC1B,MAAc,EACd,EAAE;IACF,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO;YACL,GAAG,OAAO;YACV,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,QAAQ,EAAE;YACR,IAAI,EAAE;gBACJ,EAAE,EAAE,MAAM;aACX;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { SnapId } from '@metamask/snaps-sdk';\n\nimport type { SimulationAccount } from '../options';\n\nexport const addSnapMetadataToAccount = (\n account: SimulationAccount,\n snapId: SnapId,\n) => {\n if (!account.owned) {\n return {\n ...account,\n metadata: {},\n };\n }\n\n return {\n ...account,\n metadata: {\n snap: {\n id: snapId,\n },\n },\n };\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-simulation",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -62,13 +62,13 @@
62
62
  "@metamask/key-tree": "^10.1.1",
63
63
  "@metamask/permission-controller": "^11.0.6",
64
64
  "@metamask/phishing-controller": "^12.6.0",
65
- "@metamask/snaps-controllers": "^14.0.0",
66
- "@metamask/snaps-execution-environments": "^10.0.0",
67
- "@metamask/snaps-rpc-methods": "^13.2.0",
68
- "@metamask/snaps-sdk": "^9.0.0",
69
- "@metamask/snaps-utils": "^11.0.0",
65
+ "@metamask/snaps-controllers": "^14.1.0",
66
+ "@metamask/snaps-execution-environments": "^10.1.0",
67
+ "@metamask/snaps-rpc-methods": "^13.3.0",
68
+ "@metamask/snaps-sdk": "^9.2.0",
69
+ "@metamask/snaps-utils": "^11.1.0",
70
70
  "@metamask/superstruct": "^3.2.1",
71
- "@metamask/utils": "^11.4.0",
71
+ "@metamask/utils": "^11.4.2",
72
72
  "@reduxjs/toolkit": "^1.9.5",
73
73
  "fast-deep-equal": "^3.1.3",
74
74
  "mime": "^3.0.0",