@metamask-previews/assets-controllers 45.1.1-preview-23fc04cd → 45.1.1-preview-a1e11fbb

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.
Files changed (63) hide show
  1. package/dist/MultichainBalancesController/BalancesTracker.cjs +119 -0
  2. package/dist/MultichainBalancesController/BalancesTracker.cjs.map +1 -0
  3. package/dist/MultichainBalancesController/BalancesTracker.d.cts +54 -0
  4. package/dist/MultichainBalancesController/BalancesTracker.d.cts.map +1 -0
  5. package/dist/MultichainBalancesController/BalancesTracker.d.mts +54 -0
  6. package/dist/MultichainBalancesController/BalancesTracker.d.mts.map +1 -0
  7. package/dist/MultichainBalancesController/BalancesTracker.mjs +115 -0
  8. package/dist/MultichainBalancesController/BalancesTracker.mjs.map +1 -0
  9. package/dist/MultichainBalancesController/MultichainBalancesController.cjs +214 -0
  10. package/dist/MultichainBalancesController/MultichainBalancesController.cjs.map +1 -0
  11. package/dist/MultichainBalancesController/MultichainBalancesController.d.cts +89 -0
  12. package/dist/MultichainBalancesController/MultichainBalancesController.d.cts.map +1 -0
  13. package/dist/MultichainBalancesController/MultichainBalancesController.d.mts +89 -0
  14. package/dist/MultichainBalancesController/MultichainBalancesController.d.mts.map +1 -0
  15. package/dist/MultichainBalancesController/MultichainBalancesController.mjs +212 -0
  16. package/dist/MultichainBalancesController/MultichainBalancesController.mjs.map +1 -0
  17. package/dist/MultichainBalancesController/Poller.cjs +42 -0
  18. package/dist/MultichainBalancesController/Poller.cjs.map +1 -0
  19. package/dist/MultichainBalancesController/Poller.d.cts +7 -0
  20. package/dist/MultichainBalancesController/Poller.d.cts.map +1 -0
  21. package/dist/MultichainBalancesController/Poller.d.mts +7 -0
  22. package/dist/MultichainBalancesController/Poller.d.mts.map +1 -0
  23. package/dist/MultichainBalancesController/Poller.mjs +38 -0
  24. package/dist/MultichainBalancesController/Poller.mjs.map +1 -0
  25. package/dist/MultichainBalancesController/constants.cjs +45 -0
  26. package/dist/MultichainBalancesController/constants.cjs.map +1 -0
  27. package/dist/MultichainBalancesController/constants.d.cts +29 -0
  28. package/dist/MultichainBalancesController/constants.d.cts.map +1 -0
  29. package/dist/MultichainBalancesController/constants.d.mts +29 -0
  30. package/dist/MultichainBalancesController/constants.d.mts.map +1 -0
  31. package/dist/MultichainBalancesController/constants.mjs +43 -0
  32. package/dist/MultichainBalancesController/constants.mjs.map +1 -0
  33. package/dist/MultichainBalancesController/index.cjs +13 -0
  34. package/dist/MultichainBalancesController/index.cjs.map +1 -0
  35. package/dist/MultichainBalancesController/index.d.cts +5 -0
  36. package/dist/MultichainBalancesController/index.d.cts.map +1 -0
  37. package/dist/MultichainBalancesController/index.d.mts +5 -0
  38. package/dist/MultichainBalancesController/index.d.mts.map +1 -0
  39. package/dist/MultichainBalancesController/index.mjs +4 -0
  40. package/dist/MultichainBalancesController/index.mjs.map +1 -0
  41. package/dist/MultichainBalancesController/utils.cjs +60 -0
  42. package/dist/MultichainBalancesController/utils.cjs.map +1 -0
  43. package/dist/MultichainBalancesController/utils.d.cts +29 -0
  44. package/dist/MultichainBalancesController/utils.d.cts.map +1 -0
  45. package/dist/MultichainBalancesController/utils.d.mts +29 -0
  46. package/dist/MultichainBalancesController/utils.d.mts.map +1 -0
  47. package/dist/MultichainBalancesController/utils.mjs +55 -0
  48. package/dist/MultichainBalancesController/utils.mjs.map +1 -0
  49. package/dist/NftController.cjs.map +1 -1
  50. package/dist/NftController.mjs.map +1 -1
  51. package/dist/TokenRatesController.cjs.map +1 -1
  52. package/dist/TokenRatesController.mjs.map +1 -1
  53. package/dist/TokensController.cjs.map +1 -1
  54. package/dist/TokensController.mjs.map +1 -1
  55. package/dist/index.cjs +9 -1
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +2 -0
  58. package/dist/index.d.cts.map +1 -1
  59. package/dist/index.d.mts +2 -0
  60. package/dist/index.d.mts.map +1 -1
  61. package/dist/index.mjs +3 -0
  62. package/dist/index.mjs.map +1 -1
  63. package/package.json +8 -2
@@ -0,0 +1,29 @@
1
+ export declare const BALANCE_UPDATE_INTERVALS: {
2
+ "bip122:p2wpkh": number;
3
+ "solana:data-account": number;
4
+ };
5
+ /**
6
+ * The network identifiers for supported networks in CAIP-2 format.
7
+ * Note: This is a temporary workaround until we have a more robust
8
+ * solution for network identifiers.
9
+ */
10
+ export declare enum MultichainNetworks {
11
+ Bitcoin = "bip122:000000000019d6689c085ae165831e93",
12
+ BitcoinTestnet = "bip122:000000000933ea01ad0ee984209779ba",
13
+ Solana = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
14
+ SolanaDevnet = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
15
+ SolanaTestnet = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"
16
+ }
17
+ export declare enum MultichainNativeAssets {
18
+ Bitcoin = "bip122:000000000019d6689c085ae165831e93/slip44:0",
19
+ BitcoinTestnet = "bip122:000000000933ea01ad0ee984209779ba/slip44:0",
20
+ Solana = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501",
21
+ SolanaDevnet = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1/slip44:501",
22
+ SolanaTestnet = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z/slip44:501"
23
+ }
24
+ /**
25
+ * Maps network identifiers to their corresponding native asset types.
26
+ * Each network is mapped to an array containing its native asset for consistency.
27
+ */
28
+ export declare const NETWORK_ASSETS_MAP: Record<string, MultichainNativeAssets[]>;
29
+ //# sourceMappingURL=constants.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../src/MultichainBalancesController/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,wBAAwB;;;CAKpC,CAAC;AAEF;;;;GAIG;AACH,oBAAY,kBAAkB;IAC5B,OAAO,4CAA4C;IACnD,cAAc,4CAA4C;IAC1D,MAAM,4CAA4C;IAClD,YAAY,4CAA4C;IACxD,aAAa,4CAA4C;CAC1D;AAED,oBAAY,sBAAsB;IAChC,OAAO,qDAA2C;IAClD,cAAc,qDAAkD;IAChE,MAAM,uDAA4C;IAClD,YAAY,uDAAkD;IAC9D,aAAa,uDAAmD;CACjE;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAMvE,CAAC"}
@@ -0,0 +1,29 @@
1
+ export declare const BALANCE_UPDATE_INTERVALS: {
2
+ "bip122:p2wpkh": number;
3
+ "solana:data-account": number;
4
+ };
5
+ /**
6
+ * The network identifiers for supported networks in CAIP-2 format.
7
+ * Note: This is a temporary workaround until we have a more robust
8
+ * solution for network identifiers.
9
+ */
10
+ export declare enum MultichainNetworks {
11
+ Bitcoin = "bip122:000000000019d6689c085ae165831e93",
12
+ BitcoinTestnet = "bip122:000000000933ea01ad0ee984209779ba",
13
+ Solana = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
14
+ SolanaDevnet = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
15
+ SolanaTestnet = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"
16
+ }
17
+ export declare enum MultichainNativeAssets {
18
+ Bitcoin = "bip122:000000000019d6689c085ae165831e93/slip44:0",
19
+ BitcoinTestnet = "bip122:000000000933ea01ad0ee984209779ba/slip44:0",
20
+ Solana = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501",
21
+ SolanaDevnet = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1/slip44:501",
22
+ SolanaTestnet = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z/slip44:501"
23
+ }
24
+ /**
25
+ * Maps network identifiers to their corresponding native asset types.
26
+ * Each network is mapped to an array containing its native asset for consistency.
27
+ */
28
+ export declare const NETWORK_ASSETS_MAP: Record<string, MultichainNativeAssets[]>;
29
+ //# sourceMappingURL=constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/MultichainBalancesController/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,wBAAwB;;;CAKpC,CAAC;AAEF;;;;GAIG;AACH,oBAAY,kBAAkB;IAC5B,OAAO,4CAA4C;IACnD,cAAc,4CAA4C;IAC1D,MAAM,4CAA4C;IAClD,YAAY,4CAA4C;IACxD,aAAa,4CAA4C;CAC1D;AAED,oBAAY,sBAAsB;IAChC,OAAO,qDAA2C;IAClD,cAAc,qDAAkD;IAChE,MAAM,uDAA4C;IAClD,YAAY,uDAAkD;IAC9D,aAAa,uDAAmD;CACjE;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAMvE,CAAC"}
@@ -0,0 +1,43 @@
1
+ import $metamaskkeyringapi from "@metamask/keyring-api";
2
+ const { BtcAccountType, SolAccountType } = $metamaskkeyringapi;
3
+ const BTC_AVG_BLOCK_TIME = 10 * 60 * 1000; // 10 minutes in milliseconds
4
+ const SOLANA_AVG_BLOCK_TIME = 400; // 400 milliseconds
5
+ export const BALANCE_UPDATE_INTERVALS = {
6
+ // NOTE: We set an interval of half the average block time fot bitcoin
7
+ // to mitigate when our interval is de-synchronized with the actual block time.
8
+ [BtcAccountType.P2wpkh]: BTC_AVG_BLOCK_TIME / 2,
9
+ [SolAccountType.DataAccount]: SOLANA_AVG_BLOCK_TIME,
10
+ };
11
+ /**
12
+ * The network identifiers for supported networks in CAIP-2 format.
13
+ * Note: This is a temporary workaround until we have a more robust
14
+ * solution for network identifiers.
15
+ */
16
+ export var MultichainNetworks;
17
+ (function (MultichainNetworks) {
18
+ MultichainNetworks["Bitcoin"] = "bip122:000000000019d6689c085ae165831e93";
19
+ MultichainNetworks["BitcoinTestnet"] = "bip122:000000000933ea01ad0ee984209779ba";
20
+ MultichainNetworks["Solana"] = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
21
+ MultichainNetworks["SolanaDevnet"] = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
22
+ MultichainNetworks["SolanaTestnet"] = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";
23
+ })(MultichainNetworks || (MultichainNetworks = {}));
24
+ export var MultichainNativeAssets;
25
+ (function (MultichainNativeAssets) {
26
+ MultichainNativeAssets["Bitcoin"] = "bip122:000000000019d6689c085ae165831e93/slip44:0";
27
+ MultichainNativeAssets["BitcoinTestnet"] = "bip122:000000000933ea01ad0ee984209779ba/slip44:0";
28
+ MultichainNativeAssets["Solana"] = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501";
29
+ MultichainNativeAssets["SolanaDevnet"] = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1/slip44:501";
30
+ MultichainNativeAssets["SolanaTestnet"] = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z/slip44:501";
31
+ })(MultichainNativeAssets || (MultichainNativeAssets = {}));
32
+ /**
33
+ * Maps network identifiers to their corresponding native asset types.
34
+ * Each network is mapped to an array containing its native asset for consistency.
35
+ */
36
+ export const NETWORK_ASSETS_MAP = {
37
+ [MultichainNetworks.Solana]: [MultichainNativeAssets.Solana],
38
+ [MultichainNetworks.SolanaTestnet]: [MultichainNativeAssets.SolanaTestnet],
39
+ [MultichainNetworks.SolanaDevnet]: [MultichainNativeAssets.SolanaDevnet],
40
+ [MultichainNetworks.Bitcoin]: [MultichainNativeAssets.Bitcoin],
41
+ [MultichainNetworks.BitcoinTestnet]: [MultichainNativeAssets.BitcoinTestnet],
42
+ };
43
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/MultichainBalancesController/constants.ts"],"names":[],"mappings":";;AAEA,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,6BAA6B;AACxE,MAAM,qBAAqB,GAAG,GAAG,CAAC,CAAC,mBAAmB;AAEtD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,sEAAsE;IACtE,+EAA+E;IAC/E,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,CAAC;IAC/C,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,qBAAqB;CACpD,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,yEAAmD,CAAA;IACnD,gFAA0D,CAAA;IAC1D,wEAAkD,CAAA;IAClD,8EAAwD,CAAA;IACxD,+EAAyD,CAAA;AAC3D,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B;AAED,MAAM,CAAN,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAChC,sFAAkD,CAAA;IAClD,6FAAgE,CAAA;IAChE,uFAAkD,CAAA;IAClD,6FAA8D,CAAA;IAC9D,8FAAgE,CAAA;AAClE,CAAC,EANW,sBAAsB,KAAtB,sBAAsB,QAMjC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA6C;IAC1E,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,sBAAsB,CAAC,MAAM,CAAC;IAC5D,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE,CAAC,sBAAsB,CAAC,aAAa,CAAC;IAC1E,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC,sBAAsB,CAAC,YAAY,CAAC;IACxE,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC;IAC9D,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,CAAC,sBAAsB,CAAC,cAAc,CAAC;CAC7E,CAAC","sourcesContent":["import { BtcAccountType, SolAccountType } from '@metamask/keyring-api';\n\nconst BTC_AVG_BLOCK_TIME = 10 * 60 * 1000; // 10 minutes in milliseconds\nconst SOLANA_AVG_BLOCK_TIME = 400; // 400 milliseconds\n\nexport const BALANCE_UPDATE_INTERVALS = {\n // NOTE: We set an interval of half the average block time fot bitcoin\n // to mitigate when our interval is de-synchronized with the actual block time.\n [BtcAccountType.P2wpkh]: BTC_AVG_BLOCK_TIME / 2,\n [SolAccountType.DataAccount]: SOLANA_AVG_BLOCK_TIME,\n};\n\n/**\n * The network identifiers for supported networks in CAIP-2 format.\n * Note: This is a temporary workaround until we have a more robust\n * solution for network identifiers.\n */\nexport enum MultichainNetworks {\n Bitcoin = 'bip122:000000000019d6689c085ae165831e93',\n BitcoinTestnet = 'bip122:000000000933ea01ad0ee984209779ba',\n Solana = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n SolanaDevnet = 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n SolanaTestnet = 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',\n}\n\nexport enum MultichainNativeAssets {\n Bitcoin = `${MultichainNetworks.Bitcoin}/slip44:0`,\n BitcoinTestnet = `${MultichainNetworks.BitcoinTestnet}/slip44:0`,\n Solana = `${MultichainNetworks.Solana}/slip44:501`,\n SolanaDevnet = `${MultichainNetworks.SolanaDevnet}/slip44:501`,\n SolanaTestnet = `${MultichainNetworks.SolanaTestnet}/slip44:501`,\n}\n\n/**\n * Maps network identifiers to their corresponding native asset types.\n * Each network is mapped to an array containing its native asset for consistency.\n */\nexport const NETWORK_ASSETS_MAP: Record<string, MultichainNativeAssets[]> = {\n [MultichainNetworks.Solana]: [MultichainNativeAssets.Solana],\n [MultichainNetworks.SolanaTestnet]: [MultichainNativeAssets.SolanaTestnet],\n [MultichainNetworks.SolanaDevnet]: [MultichainNativeAssets.SolanaDevnet],\n [MultichainNetworks.Bitcoin]: [MultichainNativeAssets.Bitcoin],\n [MultichainNetworks.BitcoinTestnet]: [MultichainNativeAssets.BitcoinTestnet],\n};\n"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MultichainNativeAssets = exports.MultichainNetworks = exports.NETWORK_ASSETS_MAP = exports.BALANCE_UPDATE_INTERVALS = exports.MultichainBalancesController = exports.BalancesTracker = void 0;
4
+ var BalancesTracker_1 = require("./BalancesTracker.cjs");
5
+ Object.defineProperty(exports, "BalancesTracker", { enumerable: true, get: function () { return BalancesTracker_1.BalancesTracker; } });
6
+ var MultichainBalancesController_1 = require("./MultichainBalancesController.cjs");
7
+ Object.defineProperty(exports, "MultichainBalancesController", { enumerable: true, get: function () { return MultichainBalancesController_1.MultichainBalancesController; } });
8
+ var constants_1 = require("./constants.cjs");
9
+ Object.defineProperty(exports, "BALANCE_UPDATE_INTERVALS", { enumerable: true, get: function () { return constants_1.BALANCE_UPDATE_INTERVALS; } });
10
+ Object.defineProperty(exports, "NETWORK_ASSETS_MAP", { enumerable: true, get: function () { return constants_1.NETWORK_ASSETS_MAP; } });
11
+ Object.defineProperty(exports, "MultichainNetworks", { enumerable: true, get: function () { return constants_1.MultichainNetworks; } });
12
+ Object.defineProperty(exports, "MultichainNativeAssets", { enumerable: true, get: function () { return constants_1.MultichainNativeAssets; } });
13
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/MultichainBalancesController/index.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,mFAA8E;AAArE,4IAAA,4BAA4B,OAAA;AACrC,6CAKqB;AAJnB,qHAAA,wBAAwB,OAAA;AACxB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,mHAAA,sBAAsB,OAAA","sourcesContent":["export { BalancesTracker } from './BalancesTracker';\nexport { MultichainBalancesController } from './MultichainBalancesController';\nexport {\n BALANCE_UPDATE_INTERVALS,\n NETWORK_ASSETS_MAP,\n MultichainNetworks,\n MultichainNativeAssets,\n} from './constants';\nexport type {\n MultichainBalancesControllerState,\n MultichainBalancesControllerGetStateAction,\n MultichainBalancesControllerUpdateBalancesAction,\n MultichainBalancesControllerStateChange,\n MultichainBalancesControllerActions,\n MultichainBalancesControllerEvents,\n MultichainBalancesControllerMessenger,\n} from './MultichainBalancesController';\n"]}
@@ -0,0 +1,5 @@
1
+ export { BalancesTracker } from "./BalancesTracker.cjs";
2
+ export { MultichainBalancesController } from "./MultichainBalancesController.cjs";
3
+ export { BALANCE_UPDATE_INTERVALS, NETWORK_ASSETS_MAP, MultichainNetworks, MultichainNativeAssets, } from "./constants.cjs";
4
+ export type { MultichainBalancesControllerState, MultichainBalancesControllerGetStateAction, MultichainBalancesControllerUpdateBalancesAction, MultichainBalancesControllerStateChange, MultichainBalancesControllerActions, MultichainBalancesControllerEvents, MultichainBalancesControllerMessenger, } from "./MultichainBalancesController.cjs";
5
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/MultichainBalancesController/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,8BAA0B;AACpD,OAAO,EAAE,4BAA4B,EAAE,2CAAuC;AAC9E,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,wBAAoB;AACrB,YAAY,EACV,iCAAiC,EACjC,0CAA0C,EAC1C,gDAAgD,EAChD,uCAAuC,EACvC,mCAAmC,EACnC,kCAAkC,EAClC,qCAAqC,GACtC,2CAAuC"}
@@ -0,0 +1,5 @@
1
+ export { BalancesTracker } from "./BalancesTracker.mjs";
2
+ export { MultichainBalancesController } from "./MultichainBalancesController.mjs";
3
+ export { BALANCE_UPDATE_INTERVALS, NETWORK_ASSETS_MAP, MultichainNetworks, MultichainNativeAssets, } from "./constants.mjs";
4
+ export type { MultichainBalancesControllerState, MultichainBalancesControllerGetStateAction, MultichainBalancesControllerUpdateBalancesAction, MultichainBalancesControllerStateChange, MultichainBalancesControllerActions, MultichainBalancesControllerEvents, MultichainBalancesControllerMessenger, } from "./MultichainBalancesController.mjs";
5
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/MultichainBalancesController/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,8BAA0B;AACpD,OAAO,EAAE,4BAA4B,EAAE,2CAAuC;AAC9E,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,wBAAoB;AACrB,YAAY,EACV,iCAAiC,EACjC,0CAA0C,EAC1C,gDAAgD,EAChD,uCAAuC,EACvC,mCAAmC,EACnC,kCAAkC,EAClC,qCAAqC,GACtC,2CAAuC"}
@@ -0,0 +1,4 @@
1
+ export { BalancesTracker } from "./BalancesTracker.mjs";
2
+ export { MultichainBalancesController } from "./MultichainBalancesController.mjs";
3
+ export { BALANCE_UPDATE_INTERVALS, NETWORK_ASSETS_MAP, MultichainNetworks, MultichainNativeAssets } from "./constants.mjs";
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/MultichainBalancesController/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,8BAA0B;AACpD,OAAO,EAAE,4BAA4B,EAAE,2CAAuC;AAC9E,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACvB,wBAAoB","sourcesContent":["export { BalancesTracker } from './BalancesTracker';\nexport { MultichainBalancesController } from './MultichainBalancesController';\nexport {\n BALANCE_UPDATE_INTERVALS,\n NETWORK_ASSETS_MAP,\n MultichainNetworks,\n MultichainNativeAssets,\n} from './constants';\nexport type {\n MultichainBalancesControllerState,\n MultichainBalancesControllerGetStateAction,\n MultichainBalancesControllerUpdateBalancesAction,\n MultichainBalancesControllerStateChange,\n MultichainBalancesControllerActions,\n MultichainBalancesControllerEvents,\n MultichainBalancesControllerMessenger,\n} from './MultichainBalancesController';\n"]}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getScopeForAddress = exports.getScopeForSolAddress = exports.getScopeForBtcAddress = void 0;
4
+ const keyring_api_1 = require("@metamask/keyring-api");
5
+ const bitcoin_address_validation_1 = require("bitcoin-address-validation");
6
+ const constants_1 = require("./constants.cjs");
7
+ /**
8
+ * Gets the scope for a specific and supported Bitcoin account.
9
+ * Note: This is a temporary method and will be replaced by a more robust solution
10
+ * once the new `account.scopes` is available in the `@metamask/keyring-api` module.
11
+ *
12
+ * @param account - Bitcoin account
13
+ * @returns The scope for the given account.
14
+ */
15
+ const getScopeForBtcAddress = (account) => {
16
+ if ((0, bitcoin_address_validation_1.validate)(account.address, bitcoin_address_validation_1.Network.mainnet)) {
17
+ return constants_1.MultichainNetworks.Bitcoin;
18
+ }
19
+ if ((0, bitcoin_address_validation_1.validate)(account.address, bitcoin_address_validation_1.Network.testnet)) {
20
+ return constants_1.MultichainNetworks.BitcoinTestnet;
21
+ }
22
+ throw new Error(`Invalid Bitcoin address: ${account.address}`);
23
+ };
24
+ exports.getScopeForBtcAddress = getScopeForBtcAddress;
25
+ /**
26
+ * Gets the scope for a specific and supported Solana account.
27
+ * Note: This is a temporary method and will be replaced by a more robust solution
28
+ * once the new `account.scopes` is available in the `keyring-api`.
29
+ *
30
+ * @param account - Solana account
31
+ * @returns The scope for the given account.
32
+ */
33
+ const getScopeForSolAddress = (account) => {
34
+ // For Solana accounts, we know we have a `scope` on the account's `options` bag.
35
+ if (!account.options.scope) {
36
+ throw new Error('Solana account scope is undefined');
37
+ }
38
+ return account.options.scope;
39
+ };
40
+ exports.getScopeForSolAddress = getScopeForSolAddress;
41
+ /**
42
+ * Get the scope for a given address.
43
+ * Note: This is a temporary method and will be replaced by a more robust solution
44
+ * once the new `account.scopes` is available in the `keyring-api`.
45
+ *
46
+ * @param account - The account to get the scope for.
47
+ * @returns The scope for the given account.
48
+ */
49
+ const getScopeForAddress = (account) => {
50
+ switch (account.type) {
51
+ case keyring_api_1.BtcAccountType.P2wpkh:
52
+ return (0, exports.getScopeForBtcAddress)(account);
53
+ case keyring_api_1.SolAccountType.DataAccount:
54
+ return (0, exports.getScopeForSolAddress)(account);
55
+ default:
56
+ throw new Error(`Unsupported non-EVM account type: ${account.type}`);
57
+ }
58
+ };
59
+ exports.getScopeForAddress = getScopeForAddress;
60
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../src/MultichainBalancesController/utils.ts"],"names":[],"mappings":";;;AACA,uDAAuE;AACvE,2EAA+D;AAE/D,+CAAiD;AAEjD;;;;;;;GAOG;AACI,MAAM,qBAAqB,GAAG,CAAC,OAAwB,EAAU,EAAE;IACxE,IAAI,IAAA,qCAAQ,EAAC,OAAO,CAAC,OAAO,EAAE,oCAAO,CAAC,OAAO,CAAC,EAAE;QAC9C,OAAO,8BAAkB,CAAC,OAAO,CAAC;KACnC;IAED,IAAI,IAAA,qCAAQ,EAAC,OAAO,CAAC,OAAO,EAAE,oCAAO,CAAC,OAAO,CAAC,EAAE;QAC9C,OAAO,8BAAkB,CAAC,cAAc,CAAC;KAC1C;IAED,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC,CAAC;AAVW,QAAA,qBAAqB,yBAUhC;AAEF;;;;;;;GAOG;AACI,MAAM,qBAAqB,GAAG,CAAC,OAAwB,EAAU,EAAE;IACxE,iFAAiF;IACjF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,KAAe,CAAC;AACzC,CAAC,CAAC;AANW,QAAA,qBAAqB,yBAMhC;AAEF;;;;;;;GAOG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAAwB,EAAU,EAAE;IACrE,QAAQ,OAAO,CAAC,IAAI,EAAE;QACpB,KAAK,4BAAc,CAAC,MAAM;YACxB,OAAO,IAAA,6BAAqB,EAAC,OAAO,CAAC,CAAC;QACxC,KAAK,4BAAc,CAAC,WAAW;YAC7B,OAAO,IAAA,6BAAqB,EAAC,OAAO,CAAC,CAAC;QACxC;YACE,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;KACxE;AACH,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-api';\nimport { BtcAccountType, SolAccountType } from '@metamask/keyring-api';\nimport { validate, Network } from 'bitcoin-address-validation';\n\nimport { MultichainNetworks } from './constants';\n\n/**\n * Gets the scope for a specific and supported Bitcoin account.\n * Note: This is a temporary method and will be replaced by a more robust solution\n * once the new `account.scopes` is available in the `@metamask/keyring-api` module.\n *\n * @param account - Bitcoin account\n * @returns The scope for the given account.\n */\nexport const getScopeForBtcAddress = (account: InternalAccount): string => {\n if (validate(account.address, Network.mainnet)) {\n return MultichainNetworks.Bitcoin;\n }\n\n if (validate(account.address, Network.testnet)) {\n return MultichainNetworks.BitcoinTestnet;\n }\n\n throw new Error(`Invalid Bitcoin address: ${account.address}`);\n};\n\n/**\n * Gets the scope for a specific and supported Solana account.\n * Note: This is a temporary method and will be replaced by a more robust solution\n * once the new `account.scopes` is available in the `keyring-api`.\n *\n * @param account - Solana account\n * @returns The scope for the given account.\n */\nexport const getScopeForSolAddress = (account: InternalAccount): string => {\n // For Solana accounts, we know we have a `scope` on the account's `options` bag.\n if (!account.options.scope) {\n throw new Error('Solana account scope is undefined');\n }\n return account.options.scope as string;\n};\n\n/**\n * Get the scope for a given address.\n * Note: This is a temporary method and will be replaced by a more robust solution\n * once the new `account.scopes` is available in the `keyring-api`.\n *\n * @param account - The account to get the scope for.\n * @returns The scope for the given account.\n */\nexport const getScopeForAddress = (account: InternalAccount): string => {\n switch (account.type) {\n case BtcAccountType.P2wpkh:\n return getScopeForBtcAddress(account);\n case SolAccountType.DataAccount:\n return getScopeForSolAddress(account);\n default:\n throw new Error(`Unsupported non-EVM account type: ${account.type}`);\n }\n};\n"]}
@@ -0,0 +1,29 @@
1
+ import type { InternalAccount } from "@metamask/keyring-api";
2
+ /**
3
+ * Gets the scope for a specific and supported Bitcoin account.
4
+ * Note: This is a temporary method and will be replaced by a more robust solution
5
+ * once the new `account.scopes` is available in the `@metamask/keyring-api` module.
6
+ *
7
+ * @param account - Bitcoin account
8
+ * @returns The scope for the given account.
9
+ */
10
+ export declare const getScopeForBtcAddress: (account: InternalAccount) => string;
11
+ /**
12
+ * Gets the scope for a specific and supported Solana account.
13
+ * Note: This is a temporary method and will be replaced by a more robust solution
14
+ * once the new `account.scopes` is available in the `keyring-api`.
15
+ *
16
+ * @param account - Solana account
17
+ * @returns The scope for the given account.
18
+ */
19
+ export declare const getScopeForSolAddress: (account: InternalAccount) => string;
20
+ /**
21
+ * Get the scope for a given address.
22
+ * Note: This is a temporary method and will be replaced by a more robust solution
23
+ * once the new `account.scopes` is available in the `keyring-api`.
24
+ *
25
+ * @param account - The account to get the scope for.
26
+ * @returns The scope for the given account.
27
+ */
28
+ export declare const getScopeForAddress: (account: InternalAccount) => string;
29
+ //# sourceMappingURL=utils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../src/MultichainBalancesController/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAM7D;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YAAa,eAAe,KAAG,MAUhE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YAAa,eAAe,KAAG,MAMhE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,YAAa,eAAe,KAAG,MAS7D,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { InternalAccount } from "@metamask/keyring-api";
2
+ /**
3
+ * Gets the scope for a specific and supported Bitcoin account.
4
+ * Note: This is a temporary method and will be replaced by a more robust solution
5
+ * once the new `account.scopes` is available in the `@metamask/keyring-api` module.
6
+ *
7
+ * @param account - Bitcoin account
8
+ * @returns The scope for the given account.
9
+ */
10
+ export declare const getScopeForBtcAddress: (account: InternalAccount) => string;
11
+ /**
12
+ * Gets the scope for a specific and supported Solana account.
13
+ * Note: This is a temporary method and will be replaced by a more robust solution
14
+ * once the new `account.scopes` is available in the `keyring-api`.
15
+ *
16
+ * @param account - Solana account
17
+ * @returns The scope for the given account.
18
+ */
19
+ export declare const getScopeForSolAddress: (account: InternalAccount) => string;
20
+ /**
21
+ * Get the scope for a given address.
22
+ * Note: This is a temporary method and will be replaced by a more robust solution
23
+ * once the new `account.scopes` is available in the `keyring-api`.
24
+ *
25
+ * @param account - The account to get the scope for.
26
+ * @returns The scope for the given account.
27
+ */
28
+ export declare const getScopeForAddress: (account: InternalAccount) => string;
29
+ //# sourceMappingURL=utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../src/MultichainBalancesController/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAM7D;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YAAa,eAAe,KAAG,MAUhE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YAAa,eAAe,KAAG,MAMhE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,YAAa,eAAe,KAAG,MAS7D,CAAC"}
@@ -0,0 +1,55 @@
1
+ import $metamaskkeyringapi from "@metamask/keyring-api";
2
+ const { BtcAccountType, SolAccountType } = $metamaskkeyringapi;
3
+ import { validate, Network } from "bitcoin-address-validation";
4
+ import { MultichainNetworks } from "./constants.mjs";
5
+ /**
6
+ * Gets the scope for a specific and supported Bitcoin account.
7
+ * Note: This is a temporary method and will be replaced by a more robust solution
8
+ * once the new `account.scopes` is available in the `@metamask/keyring-api` module.
9
+ *
10
+ * @param account - Bitcoin account
11
+ * @returns The scope for the given account.
12
+ */
13
+ export const getScopeForBtcAddress = (account) => {
14
+ if (validate(account.address, Network.mainnet)) {
15
+ return MultichainNetworks.Bitcoin;
16
+ }
17
+ if (validate(account.address, Network.testnet)) {
18
+ return MultichainNetworks.BitcoinTestnet;
19
+ }
20
+ throw new Error(`Invalid Bitcoin address: ${account.address}`);
21
+ };
22
+ /**
23
+ * Gets the scope for a specific and supported Solana account.
24
+ * Note: This is a temporary method and will be replaced by a more robust solution
25
+ * once the new `account.scopes` is available in the `keyring-api`.
26
+ *
27
+ * @param account - Solana account
28
+ * @returns The scope for the given account.
29
+ */
30
+ export const getScopeForSolAddress = (account) => {
31
+ // For Solana accounts, we know we have a `scope` on the account's `options` bag.
32
+ if (!account.options.scope) {
33
+ throw new Error('Solana account scope is undefined');
34
+ }
35
+ return account.options.scope;
36
+ };
37
+ /**
38
+ * Get the scope for a given address.
39
+ * Note: This is a temporary method and will be replaced by a more robust solution
40
+ * once the new `account.scopes` is available in the `keyring-api`.
41
+ *
42
+ * @param account - The account to get the scope for.
43
+ * @returns The scope for the given account.
44
+ */
45
+ export const getScopeForAddress = (account) => {
46
+ switch (account.type) {
47
+ case BtcAccountType.P2wpkh:
48
+ return getScopeForBtcAddress(account);
49
+ case SolAccountType.DataAccount:
50
+ return getScopeForSolAddress(account);
51
+ default:
52
+ throw new Error(`Unsupported non-EVM account type: ${account.type}`);
53
+ }
54
+ };
55
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../src/MultichainBalancesController/utils.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,mCAAmC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,wBAAoB;AAEjD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAwB,EAAU,EAAE;IACxE,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9C,OAAO,kBAAkB,CAAC,OAAO,CAAC;KACnC;IAED,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9C,OAAO,kBAAkB,CAAC,cAAc,CAAC;KAC1C;IAED,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAwB,EAAU,EAAE;IACxE,iFAAiF;IACjF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,KAAe,CAAC;AACzC,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAwB,EAAU,EAAE;IACrE,QAAQ,OAAO,CAAC,IAAI,EAAE;QACpB,KAAK,cAAc,CAAC,MAAM;YACxB,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,cAAc,CAAC,WAAW;YAC7B,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC;YACE,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;KACxE;AACH,CAAC,CAAC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-api';\nimport { BtcAccountType, SolAccountType } from '@metamask/keyring-api';\nimport { validate, Network } from 'bitcoin-address-validation';\n\nimport { MultichainNetworks } from './constants';\n\n/**\n * Gets the scope for a specific and supported Bitcoin account.\n * Note: This is a temporary method and will be replaced by a more robust solution\n * once the new `account.scopes` is available in the `@metamask/keyring-api` module.\n *\n * @param account - Bitcoin account\n * @returns The scope for the given account.\n */\nexport const getScopeForBtcAddress = (account: InternalAccount): string => {\n if (validate(account.address, Network.mainnet)) {\n return MultichainNetworks.Bitcoin;\n }\n\n if (validate(account.address, Network.testnet)) {\n return MultichainNetworks.BitcoinTestnet;\n }\n\n throw new Error(`Invalid Bitcoin address: ${account.address}`);\n};\n\n/**\n * Gets the scope for a specific and supported Solana account.\n * Note: This is a temporary method and will be replaced by a more robust solution\n * once the new `account.scopes` is available in the `keyring-api`.\n *\n * @param account - Solana account\n * @returns The scope for the given account.\n */\nexport const getScopeForSolAddress = (account: InternalAccount): string => {\n // For Solana accounts, we know we have a `scope` on the account's `options` bag.\n if (!account.options.scope) {\n throw new Error('Solana account scope is undefined');\n }\n return account.options.scope as string;\n};\n\n/**\n * Get the scope for a given address.\n * Note: This is a temporary method and will be replaced by a more robust solution\n * once the new `account.scopes` is available in the `keyring-api`.\n *\n * @param account - The account to get the scope for.\n * @returns The scope for the given account.\n */\nexport const getScopeForAddress = (account: InternalAccount): string => {\n switch (account.type) {\n case BtcAccountType.P2wpkh:\n return getScopeForBtcAddress(account);\n case SolAccountType.DataAccount:\n return getScopeForSolAddress(account);\n default:\n throw new Error(`Unsupported non-EVM account type: ${account.type}`);\n }\n};\n"]}