@metamask-previews/multichain-transactions-controller 0.1.0-preview-958adf52 → 0.1.0-preview-553ac792
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 +0 -1
- package/dist/MultichainTransactionsController.cjs +76 -51
- package/dist/MultichainTransactionsController.cjs.map +1 -1
- package/dist/MultichainTransactionsController.d.cts +24 -5
- package/dist/MultichainTransactionsController.d.cts.map +1 -1
- package/dist/MultichainTransactionsController.d.mts +24 -5
- package/dist/MultichainTransactionsController.d.mts.map +1 -1
- package/dist/MultichainTransactionsController.mjs +77 -52
- package/dist/MultichainTransactionsController.mjs.map +1 -1
- package/dist/MultichainTransactionsTracker.cjs +124 -0
- package/dist/MultichainTransactionsTracker.cjs.map +1 -0
- package/dist/MultichainTransactionsTracker.d.cts +62 -0
- package/dist/MultichainTransactionsTracker.d.cts.map +1 -0
- package/dist/MultichainTransactionsTracker.d.mts +62 -0
- package/dist/MultichainTransactionsTracker.d.mts.map +1 -0
- package/dist/MultichainTransactionsTracker.mjs +120 -0
- package/dist/MultichainTransactionsTracker.mjs.map +1 -0
- package/dist/Poller.cjs +40 -0
- package/dist/Poller.cjs.map +1 -0
- package/dist/Poller.d.cts +7 -0
- package/dist/Poller.d.cts.map +1 -0
- package/dist/Poller.d.mts +7 -0
- package/dist/Poller.d.mts.map +1 -0
- package/dist/Poller.mjs +36 -0
- package/dist/Poller.mjs.map +1 -0
- package/dist/constants.cjs +11 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +4 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +4 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +10 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -13,7 +13,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
13
|
- Bump `@metamask/snaps-sdk` from `^6.16.0` to `^6.17.1` ([#5265](https://github.com/MetaMask/core/pull/5265))
|
|
14
14
|
- Bump `@metamask/snaps-utils` from `^8.9.0` to `^8.10.0` ([#5265](https://github.com/MetaMask/core/pull/5265))
|
|
15
15
|
- Bump `@metamask/snaps-controllers` from `^9.10.0` to `^9.19.0` ([#5265](https://github.com/MetaMask/core/pull/5265))
|
|
16
|
-
- Bump `@metamask/keyring-api"` from `^16.1.0` to `^17.0.0` ([#5280](https://github.com/MetaMask/core/pull/5280))
|
|
17
16
|
|
|
18
17
|
## [0.1.0]
|
|
19
18
|
|
|
@@ -4,15 +4,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
+
};
|
|
13
|
+
var _MultichainTransactionsController_instances, _MultichainTransactionsController_tracker, _MultichainTransactionsController_listMultichainAccounts, _MultichainTransactionsController_listAccounts, _MultichainTransactionsController_updateTransactions, _MultichainTransactionsController_getTransactions, _MultichainTransactionsController_getBlockTimeFor, _MultichainTransactionsController_isNonEvmAccount, _MultichainTransactionsController_handleOnAccountAdded, _MultichainTransactionsController_handleOnAccountRemoved, _MultichainTransactionsController_getClient;
|
|
8
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
15
|
exports.MultichainTransactionsController = exports.getDefaultMultichainTransactionsControllerState = void 0;
|
|
10
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
11
17
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
12
18
|
const keyring_snap_client_1 = require("@metamask/keyring-snap-client");
|
|
13
19
|
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
14
|
-
const utils_1 = require("@metamask/utils");
|
|
15
20
|
const constants_1 = require("./constants.cjs");
|
|
21
|
+
const MultichainTransactionsTracker_1 = require("./MultichainTransactionsTracker.cjs");
|
|
16
22
|
const controllerName = 'MultichainTransactionsController';
|
|
17
23
|
/**
|
|
18
24
|
* Constructs the default {@link MultichainTransactionsController} state.
|
|
@@ -54,62 +60,82 @@ class MultichainTransactionsController extends base_controller_1.BaseController
|
|
|
54
60
|
},
|
|
55
61
|
});
|
|
56
62
|
_MultichainTransactionsController_instances.add(this);
|
|
57
|
-
|
|
63
|
+
_MultichainTransactionsController_tracker.set(this, void 0);
|
|
64
|
+
__classPrivateFieldSet(this, _MultichainTransactionsController_tracker, new MultichainTransactionsTracker_1.MultichainTransactionsTracker(async (accountId, pagination) => await __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_updateTransactions).call(this, accountId, pagination)), "f");
|
|
65
|
+
// Register all non-EVM accounts into the tracker
|
|
58
66
|
for (const account of __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_listAccounts).call(this)) {
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
}
|
|
67
|
+
if (__classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_isNonEvmAccount).call(this, account)) {
|
|
68
|
+
__classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").track(account.id, __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_getBlockTimeFor).call(this, account));
|
|
69
|
+
}
|
|
62
70
|
}
|
|
63
71
|
this.messagingSystem.subscribe('AccountsController:accountAdded', (account) => __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_handleOnAccountAdded).call(this, account));
|
|
64
72
|
this.messagingSystem.subscribe('AccountsController:accountRemoved', (accountId) => __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_handleOnAccountRemoved).call(this, accountId));
|
|
65
|
-
this.messagingSystem.subscribe('AccountsController:accountTransactionsUpdated', (transactionsUpdate) => __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_handleOnAccountTransactionsUpdated).call(this, transactionsUpdate));
|
|
66
73
|
}
|
|
67
74
|
/**
|
|
68
|
-
* Updates transactions for a specific account
|
|
69
|
-
* when an account is first added.
|
|
75
|
+
* Updates transactions for a specific account
|
|
70
76
|
*
|
|
71
77
|
* @param accountId - The ID of the account to get transactions for.
|
|
72
78
|
*/
|
|
73
79
|
async updateTransactionsForAccount(accountId) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
transactions,
|
|
95
|
-
next: response.next,
|
|
96
|
-
lastUpdated: Date.now(),
|
|
97
|
-
};
|
|
98
|
-
Object.assign(state.nonEvmTransactions, { [account.id]: entry });
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
console.error(`Failed to fetch transactions for account ${accountId}:`, error);
|
|
104
|
-
}
|
|
80
|
+
await __classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").updateTransactionsForAccount(accountId);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Updates the transactions of all supported accounts. This method doesn't return
|
|
84
|
+
* anything, but it updates the state of the controller.
|
|
85
|
+
*/
|
|
86
|
+
async updateTransactions() {
|
|
87
|
+
await __classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").updateTransactions();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Starts the polling process.
|
|
91
|
+
*/
|
|
92
|
+
start() {
|
|
93
|
+
__classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").start();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Stops the polling process.
|
|
97
|
+
*/
|
|
98
|
+
stop() {
|
|
99
|
+
__classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").stop();
|
|
105
100
|
}
|
|
106
101
|
}
|
|
107
102
|
exports.MultichainTransactionsController = MultichainTransactionsController;
|
|
108
|
-
_MultichainTransactionsController_instances = new WeakSet(), _MultichainTransactionsController_listMultichainAccounts = function _MultichainTransactionsController_listMultichainAccounts() {
|
|
103
|
+
_MultichainTransactionsController_tracker = new WeakMap(), _MultichainTransactionsController_instances = new WeakSet(), _MultichainTransactionsController_listMultichainAccounts = function _MultichainTransactionsController_listMultichainAccounts() {
|
|
109
104
|
return this.messagingSystem.call('AccountsController:listMultichainAccounts');
|
|
110
105
|
}, _MultichainTransactionsController_listAccounts = function _MultichainTransactionsController_listAccounts() {
|
|
111
106
|
const accounts = __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_listMultichainAccounts).call(this);
|
|
112
107
|
return accounts.filter((account) => __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_isNonEvmAccount).call(this, account));
|
|
108
|
+
}, _MultichainTransactionsController_updateTransactions =
|
|
109
|
+
/**
|
|
110
|
+
* Updates the transactions for one account.
|
|
111
|
+
*
|
|
112
|
+
* @param accountId - The ID of the account to update transactions for.
|
|
113
|
+
* @param pagination - Options for paginating transaction results.
|
|
114
|
+
*/
|
|
115
|
+
async function _MultichainTransactionsController_updateTransactions(accountId, pagination) {
|
|
116
|
+
const account = __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_listAccounts).call(this).find((accountItem) => accountItem.id === accountId);
|
|
117
|
+
if (account?.metadata.snap) {
|
|
118
|
+
const response = await __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_getTransactions).call(this, account.id, account.metadata.snap.id, pagination);
|
|
119
|
+
/**
|
|
120
|
+
* Filter only Solana transactions to ensure they're mainnet
|
|
121
|
+
* All other chain transactions are included as-is
|
|
122
|
+
*/
|
|
123
|
+
const transactions = response.data.filter((tx) => {
|
|
124
|
+
const chain = tx.chain;
|
|
125
|
+
if (chain.startsWith(constants_1.MultichainNetwork.Solana)) {
|
|
126
|
+
return chain === constants_1.MultichainNetwork.Solana;
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
});
|
|
130
|
+
this.update((state) => {
|
|
131
|
+
const entry = {
|
|
132
|
+
transactions,
|
|
133
|
+
next: response.next,
|
|
134
|
+
lastUpdated: Date.now(),
|
|
135
|
+
};
|
|
136
|
+
Object.assign(state.nonEvmTransactions, { [account.id]: entry });
|
|
137
|
+
});
|
|
138
|
+
}
|
|
113
139
|
}, _MultichainTransactionsController_getTransactions =
|
|
114
140
|
/**
|
|
115
141
|
* Gets transactions for an account.
|
|
@@ -121,6 +147,11 @@ _MultichainTransactionsController_instances = new WeakSet(), _MultichainTransact
|
|
|
121
147
|
*/
|
|
122
148
|
async function _MultichainTransactionsController_getTransactions(accountId, snapId, pagination) {
|
|
123
149
|
return await __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_getClient).call(this, snapId).listAccountTransactions(accountId, pagination);
|
|
150
|
+
}, _MultichainTransactionsController_getBlockTimeFor = function _MultichainTransactionsController_getBlockTimeFor(account) {
|
|
151
|
+
if (account.type in constants_1.TRANSACTIONS_CHECK_INTERVALS) {
|
|
152
|
+
return constants_1.TRANSACTIONS_CHECK_INTERVALS[account.type];
|
|
153
|
+
}
|
|
154
|
+
throw new Error(`Unsupported account type for transactions tracking: ${account.type}`);
|
|
124
155
|
}, _MultichainTransactionsController_isNonEvmAccount = function _MultichainTransactionsController_isNonEvmAccount(account) {
|
|
125
156
|
return (!(0, keyring_api_1.isEvmAccountType)(account.type) &&
|
|
126
157
|
// Non-EVM accounts are backed by a Snap for now
|
|
@@ -135,7 +166,7 @@ async function _MultichainTransactionsController_handleOnAccountAdded(account) {
|
|
|
135
166
|
if (!__classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_isNonEvmAccount).call(this, account)) {
|
|
136
167
|
return;
|
|
137
168
|
}
|
|
138
|
-
|
|
169
|
+
__classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").track(account.id, __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_getBlockTimeFor).call(this, account));
|
|
139
170
|
}, _MultichainTransactionsController_handleOnAccountRemoved =
|
|
140
171
|
/**
|
|
141
172
|
* Handles changes when a new account has been removed.
|
|
@@ -143,20 +174,14 @@ async function _MultichainTransactionsController_handleOnAccountAdded(account) {
|
|
|
143
174
|
* @param accountId - The account ID being removed.
|
|
144
175
|
*/
|
|
145
176
|
async function _MultichainTransactionsController_handleOnAccountRemoved(accountId) {
|
|
177
|
+
if (__classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").isTracked(accountId)) {
|
|
178
|
+
__classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").untrack(accountId);
|
|
179
|
+
}
|
|
146
180
|
if (accountId in this.state.nonEvmTransactions) {
|
|
147
181
|
this.update((state) => {
|
|
148
182
|
delete state.nonEvmTransactions[accountId];
|
|
149
183
|
});
|
|
150
184
|
}
|
|
151
|
-
}, _MultichainTransactionsController_handleOnAccountTransactionsUpdated = function _MultichainTransactionsController_handleOnAccountTransactionsUpdated(transactionsUpdate) {
|
|
152
|
-
this.update((state) => {
|
|
153
|
-
Object.entries(transactionsUpdate.transactions).forEach(([accountId, transactions]) => {
|
|
154
|
-
if (accountId in state.nonEvmTransactions) {
|
|
155
|
-
state.nonEvmTransactions[accountId].transactions = transactions;
|
|
156
|
-
state.nonEvmTransactions[accountId].lastUpdated = Date.now();
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
185
|
}, _MultichainTransactionsController_getClient = function _MultichainTransactionsController_getClient(snapId) {
|
|
161
186
|
return new keyring_snap_client_1.KeyringClient({
|
|
162
187
|
send: async (request) => (await this.messagingSystem.call('SnapController:handleRequest', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultichainTransactionsController.cjs","sourceRoot":"","sources":["../src/MultichainTransactionsController.ts"],"names":[],"mappings":";;;;;;;;;AAMA,+DAKmC;AACnC,uDAI+B;AAE/B,uEAA8D;AAG9D,uDAAoD;AACpD,2CAKyB;AAGzB,+CAAgD;AAEhD,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAuB1D;;;;GAIG;AACH,SAAgB,+CAA+C;IAC7D,OAAO;QACL,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACJ,CAAC;AAJD,0GAIC;AA0DD;;;;;;GAMG;AACH,MAAM,wCAAwC,GAAG;IAC/C,kBAAkB,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AAWF;;;GAGG;AACH,MAAa,gCAAiC,SAAQ,gCAIrD;IACC,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,SAAS;YACT,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,wCAAwC;YAClD,KAAK,EAAE;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kB,CAAC,SAAS,CAAC,CAAC,YAAY,GAAG,YAAY,CAAC;gBAChE,KAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;aAC9D;QACH,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,qGAQU,MAAc;IACvB,OAAO,IAAI,mCAAa,CAAC;QACvB,IAAI,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE,CACtC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,8BAA8B,EAAE;YAC/D,MAAM,EAAE,MAAgB;YACxB,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,yBAAW,CAAC,gBAAgB;YACrC,OAAO;SACR,CAAC,CAAkB;KACvB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerListMultichainAccountsAction,\n AccountsControllerAccountTransactionsUpdatedEvent,\n} from '@metamask/accounts-controller';\nimport {\n BaseController,\n type ControllerGetStateAction,\n type ControllerStateChangeEvent,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport {\n isEvmAccountType,\n type Transaction,\n type AccountTransactionsUpdatedEventPayload,\n} from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { KeyringClient } from '@metamask/keyring-snap-client';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport {\n KnownCaipNamespace,\n parseCaipChainId,\n type Json,\n type JsonRpcRequest,\n} from '@metamask/utils';\nimport type { Draft } from 'immer';\n\nimport { MultichainNetwork } from './constants';\n\nconst controllerName = 'MultichainTransactionsController';\n\n/**\n * PaginationOptions\n *\n * Represents options for paginating transaction results\n * limit - The maximum number of transactions to return\n * next - The cursor for the next page of transactions, or null if there is no next page\n */\nexport type PaginationOptions = {\n limit: number;\n next?: string | null;\n};\n\n/**\n * State used by the {@link MultichainTransactionsController} to cache account transactions.\n */\nexport type MultichainTransactionsControllerState = {\n nonEvmTransactions: {\n [accountId: string]: TransactionStateEntry;\n };\n};\n\n/**\n * Constructs the default {@link MultichainTransactionsController} state.\n *\n * @returns The default {@link MultichainTransactionsController} state.\n */\nexport function getDefaultMultichainTransactionsControllerState(): MultichainTransactionsControllerState {\n return {\n nonEvmTransactions: {},\n };\n}\n\n/**\n * Returns the state of the {@link MultichainTransactionsController}.\n */\nexport type MultichainTransactionsControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n MultichainTransactionsControllerState\n >;\n\n/**\n * Event emitted when the state of the {@link MultichainTransactionsController} changes.\n */\nexport type MultichainTransactionsControllerStateChange =\n ControllerStateChangeEvent<\n typeof controllerName,\n MultichainTransactionsControllerState\n >;\n\n/**\n * Actions exposed by the {@link MultichainTransactionsController}.\n */\nexport type MultichainTransactionsControllerActions =\n MultichainTransactionsControllerGetStateAction;\n\n/**\n * Events emitted by {@link MultichainTransactionsController}.\n */\nexport type MultichainTransactionsControllerEvents =\n MultichainTransactionsControllerStateChange;\n\n/**\n * Messenger type for the MultichainTransactionsController.\n */\nexport type MultichainTransactionsControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n MultichainTransactionsControllerActions | AllowedActions,\n MultichainTransactionsControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Actions that this controller is allowed to call.\n */\nexport type AllowedActions =\n | HandleSnapRequest\n | AccountsControllerListMultichainAccountsAction;\n\n/**\n * Events that this controller is allowed to subscribe.\n */\nexport type AllowedEvents =\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerAccountTransactionsUpdatedEvent;\n\n/**\n * {@link MultichainTransactionsController}'s metadata.\n *\n * This allows us to choose if fields of the state should be persisted or not\n * using the `persist` flag; and if they can be sent to Sentry or not, using\n * the `anonymous` flag.\n */\nconst multichainTransactionsControllerMetadata = {\n nonEvmTransactions: {\n persist: true,\n anonymous: false,\n },\n};\n\n/**\n * The state of transactions for a specific account.\n */\nexport type TransactionStateEntry = {\n transactions: Transaction[];\n next: string | null;\n lastUpdated: number;\n};\n\n/**\n * The MultichainTransactionsController is responsible for fetching and caching account\n * transactions for non-EVM accounts.\n */\nexport class MultichainTransactionsController extends BaseController<\n typeof controllerName,\n MultichainTransactionsControllerState,\n MultichainTransactionsControllerMessenger\n> {\n constructor({\n messenger,\n state,\n }: {\n messenger: MultichainTransactionsControllerMessenger;\n state?: Partial<MultichainTransactionsControllerState>;\n }) {\n super({\n messenger,\n name: controllerName,\n metadata: multichainTransactionsControllerMetadata,\n state: {\n ...getDefaultMultichainTransactionsControllerState(),\n ...state,\n },\n });\n\n // Fetch initial transactions for all non-EVM accounts\n for (const account of this.#listAccounts()) {\n this.updateTransactionsForAccount(account.id).catch((error) => {\n console.error(\n `Failed to fetch initial transactions for account ${account.id}:`,\n error,\n );\n });\n }\n\n this.messagingSystem.subscribe(\n 'AccountsController:accountAdded',\n (account: InternalAccount) => this.#handleOnAccountAdded(account),\n );\n this.messagingSystem.subscribe(\n 'AccountsController:accountRemoved',\n (accountId: string) => this.#handleOnAccountRemoved(accountId),\n );\n this.messagingSystem.subscribe(\n 'AccountsController:accountTransactionsUpdated',\n (transactionsUpdate: AccountTransactionsUpdatedEventPayload) =>\n this.#handleOnAccountTransactionsUpdated(transactionsUpdate),\n );\n }\n\n /**\n * Lists the multichain accounts coming from the `AccountsController`.\n *\n * @returns A list of multichain accounts.\n */\n #listMultichainAccounts(): InternalAccount[] {\n return this.messagingSystem.call(\n 'AccountsController:listMultichainAccounts',\n );\n }\n\n /**\n * Lists the accounts that we should get transactions for.\n *\n * @returns A list of accounts that we should get transactions for.\n */\n #listAccounts(): InternalAccount[] {\n const accounts = this.#listMultichainAccounts();\n return accounts.filter((account) => this.#isNonEvmAccount(account));\n }\n\n /**\n * Gets transactions for an account.\n *\n * @param accountId - The ID of the account to get transactions for.\n * @param snapId - The ID of the snap that manages the account.\n * @param pagination - Options for paginating transaction results.\n * @returns A promise that resolves to the transaction data and pagination info.\n */\n async #getTransactions(\n accountId: string,\n snapId: string,\n pagination: PaginationOptions,\n ): Promise<{\n data: Transaction[];\n next: string | null;\n }> {\n return await this.#getClient(snapId).listAccountTransactions(\n accountId,\n pagination,\n );\n }\n\n /**\n * Updates transactions for a specific account. This is used for the initial fetch\n * when an account is first added.\n *\n * @param accountId - The ID of the account to get transactions for.\n */\n async updateTransactionsForAccount(accountId: string) {\n try {\n const account = this.#listAccounts().find(\n (accountItem) => accountItem.id === accountId,\n );\n\n if (account?.metadata.snap) {\n const response = await this.#getTransactions(\n account.id,\n account.metadata.snap.id,\n { limit: 10 },\n );\n\n // Filter only Solana transactions to ensure they're on mainnet.\n // All other chain transactions are included as-is.\n // TODO: Maybe we should not do any filtering here? Or maybe have it\n // being configurable somehow?\n const transactions = response.data.filter((tx) => {\n const chain = tx.chain as MultichainNetwork;\n const { namespace } = parseCaipChainId(chain);\n // Enum comparison is safe here as we control both enum values\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n if (namespace === KnownCaipNamespace.Solana) {\n return chain === MultichainNetwork.Solana;\n }\n return true;\n });\n\n this.update((state: Draft<MultichainTransactionsControllerState>) => {\n const entry: TransactionStateEntry = {\n transactions,\n next: response.next,\n lastUpdated: Date.now(),\n };\n\n Object.assign(state.nonEvmTransactions, { [account.id]: entry });\n });\n }\n } catch (error) {\n console.error(\n `Failed to fetch transactions for account ${accountId}:`,\n error,\n );\n }\n }\n\n /**\n * Checks for non-EVM accounts.\n *\n * @param account - The new account to be checked.\n * @returns True if the account is a non-EVM account, false otherwise.\n */\n #isNonEvmAccount(account: InternalAccount): boolean {\n return (\n !isEvmAccountType(account.type) &&\n // Non-EVM accounts are backed by a Snap for now\n account.metadata.snap !== undefined\n );\n }\n\n /**\n * Handles changes when a new account has been added.\n *\n * @param account - The new account being added.\n */\n async #handleOnAccountAdded(account: InternalAccount) {\n if (!this.#isNonEvmAccount(account)) {\n return;\n }\n\n await this.updateTransactionsForAccount(account.id);\n }\n\n /**\n * Handles changes when a new account has been removed.\n *\n * @param accountId - The account ID being removed.\n */\n async #handleOnAccountRemoved(accountId: string) {\n if (accountId in this.state.nonEvmTransactions) {\n this.update((state: Draft<MultichainTransactionsControllerState>) => {\n delete state.nonEvmTransactions[accountId];\n });\n }\n }\n\n /**\n * Handles transaction updates received from the AccountsController.\n *\n * @param transactionsUpdate - The transaction update event containing new transactions.\n */\n #handleOnAccountTransactionsUpdated(\n transactionsUpdate: AccountTransactionsUpdatedEventPayload,\n ): void {\n this.update((state: Draft<MultichainTransactionsControllerState>) => {\n Object.entries(transactionsUpdate.transactions).forEach(\n ([accountId, transactions]) => {\n if (accountId in state.nonEvmTransactions) {\n state.nonEvmTransactions[accountId].transactions = transactions;\n state.nonEvmTransactions[accountId].lastUpdated = Date.now();\n }\n },\n );\n });\n }\n\n /**\n * Gets a `KeyringClient` for a Snap.\n *\n * @param snapId - ID of the Snap to get the client for.\n * @returns A `KeyringClient` for the Snap.\n */\n #getClient(snapId: string): KeyringClient {\n return new KeyringClient({\n send: async (request: JsonRpcRequest) =>\n (await this.messagingSystem.call('SnapController:handleRequest', {\n snapId: snapId as SnapId,\n origin: 'metamask',\n handler: HandlerType.OnKeyringRequest,\n request,\n })) as Promise<Json>,\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MultichainTransactionsController.cjs","sourceRoot":"","sources":["../src/MultichainTransactionsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAKmC;AACnC,uDAA2E;AAE3E,uEAA8D;AAG9D,uDAAoD;AAIpD,+CAA8E;AAC9E,uFAAgF;AAEhF,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAuB1D;;;;GAIG;AACH,SAAgB,+CAA+C;IAC7D,OAAO;QACL,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACJ,C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uB,OAAwB;IAClD,IAAI,CAAC,uBAAA,IAAI,sGAAiB,MAArB,IAAI,EAAkB,OAAO,CAAC,EAAE;QACnC,OAAO;KACR;IAED,uBAAA,IAAI,iDAAS,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,uBAAA,IAAI,sGAAiB,MAArB,IAAI,EAAkB,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;;GAIG;AACH,KAAK,mEAAyB,SAAiB;IAC7C,IAAI,uBAAA,IAAI,iDAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;QACtC,uBAAA,IAAI,iDAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;KAClC;IAED,IAAI,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE;QAC9C,IAAI,CAAC,MAAM,CAAC,CAAC,KAAmD,EAAE,EAAE;YAClE,OAAO,KAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;KACJ;AACH,CAAC,qGAQU,MAAc;IACvB,OAAO,IAAI,mCAAa,CAAC;QACvB,IAAI,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE,CACtC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,8BAA8B,EAAE;YAC/D,MAAM,EAAE,MAAgB;YACxB,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,yBAAW,CAAC,gBAAgB;YACrC,OAAO;SACR,CAAC,CAAkB;KACvB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport {\n BaseController,\n type ControllerGetStateAction,\n type ControllerStateChangeEvent,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { isEvmAccountType, type Transaction } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { KeyringClient } from '@metamask/keyring-snap-client';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport type { Json, JsonRpcRequest } from '@metamask/utils';\nimport type { Draft } from 'immer';\n\nimport { MultichainNetwork, TRANSACTIONS_CHECK_INTERVALS } from './constants';\nimport { MultichainTransactionsTracker } from './MultichainTransactionsTracker';\n\nconst controllerName = 'MultichainTransactionsController';\n\n/**\n * PaginationOptions\n *\n * Represents options for paginating transaction results\n * limit - The maximum number of transactions to return\n * next - The cursor for the next page of transactions, or null if there is no next page\n */\nexport type PaginationOptions = {\n limit: number;\n next?: string | null;\n};\n\n/**\n * State used by the {@link MultichainTransactionsController} to cache account transactions.\n */\nexport type MultichainTransactionsControllerState = {\n nonEvmTransactions: {\n [accountId: string]: TransactionStateEntry;\n };\n};\n\n/**\n * Constructs the default {@link MultichainTransactionsController} state.\n *\n * @returns The default {@link MultichainTransactionsController} state.\n */\nexport function getDefaultMultichainTransactionsControllerState(): MultichainTransactionsControllerState {\n return {\n nonEvmTransactions: {},\n };\n}\n\n/**\n * Returns the state of the {@link MultichainTransactionsController}.\n */\nexport type MultichainTransactionsControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n MultichainTransactionsControllerState\n >;\n\n/**\n * Updates the transactions of all supported accounts.\n */\nexport type MultichainTransactionsControllerListTransactionsAction = {\n type: `${typeof controllerName}:updateTransactions`;\n handler: MultichainTransactionsController['updateTransactions'];\n};\n\n/**\n * Event emitted when the state of the {@link MultichainTransactionsController} changes.\n */\nexport type MultichainTransactionsControllerStateChange =\n ControllerStateChangeEvent<\n typeof controllerName,\n MultichainTransactionsControllerState\n >;\n\n/**\n * Actions exposed by the {@link MultichainTransactionsController}.\n */\nexport type MultichainTransactionsControllerActions =\n | MultichainTransactionsControllerGetStateAction\n | MultichainTransactionsControllerListTransactionsAction;\n\n/**\n * Events emitted by {@link MultichainTransactionsController}.\n */\nexport type MultichainTransactionsControllerEvents =\n MultichainTransactionsControllerStateChange;\n\n/**\n * Messenger type for the MultichainTransactionsController.\n */\nexport type MultichainTransactionsControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n MultichainTransactionsControllerActions | AllowedActions,\n MultichainTransactionsControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Actions that this controller is allowed to call.\n */\nexport type AllowedActions =\n | HandleSnapRequest\n | AccountsControllerListMultichainAccountsAction;\n\n/**\n * Events that this controller is allowed to subscribe.\n */\nexport type AllowedEvents =\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent;\n\n/**\n * {@link MultichainTransactionsController}'s metadata.\n *\n * This allows us to choose if fields of the state should be persisted or not\n * using the `persist` flag; and if they can be sent to Sentry or not, using\n * the `anonymous` flag.\n */\nconst multichainTransactionsControllerMetadata = {\n nonEvmTransactions: {\n persist: true,\n anonymous: false,\n },\n};\n\n/**\n * The state of transactions for a specific account.\n */\nexport type TransactionStateEntry = {\n transactions: Transaction[];\n next: string | null;\n lastUpdated: number;\n};\n\n/**\n * The MultichainTransactionsController is responsible for fetching and caching account\n * transactions for non-EVM accounts.\n */\nexport class MultichainTransactionsController extends BaseController<\n typeof controllerName,\n MultichainTransactionsControllerState,\n MultichainTransactionsControllerMessenger\n> {\n readonly #tracker: MultichainTransactionsTracker;\n\n constructor({\n messenger,\n state,\n }: {\n messenger: MultichainTransactionsControllerMessenger;\n state?: Partial<MultichainTransactionsControllerState>;\n }) {\n super({\n messenger,\n name: controllerName,\n metadata: multichainTransactionsControllerMetadata,\n state: {\n ...getDefaultMultichainTransactionsControllerState(),\n ...state,\n },\n });\n\n this.#tracker = new MultichainTransactionsTracker(\n async (accountId: string, pagination: PaginationOptions) =>\n await this.#updateTransactions(accountId, pagination),\n );\n\n // Register all non-EVM accounts into the tracker\n for (const account of this.#listAccounts()) {\n if (this.#isNonEvmAccount(account)) {\n this.#tracker.track(account.id, this.#getBlockTimeFor(account));\n }\n }\n\n this.messagingSystem.subscribe(\n 'AccountsController:accountAdded',\n (account) => this.#handleOnAccountAdded(account),\n );\n this.messagingSystem.subscribe(\n 'AccountsController:accountRemoved',\n (accountId: string) => this.#handleOnAccountRemoved(accountId),\n );\n }\n\n /**\n * Lists the multichain accounts coming from the `AccountsController`.\n *\n * @returns A list of multichain accounts.\n */\n #listMultichainAccounts(): InternalAccount[] {\n return this.messagingSystem.call(\n 'AccountsController:listMultichainAccounts',\n );\n }\n\n /**\n * Lists the accounts that we should get transactions for.\n *\n * @returns A list of accounts that we should get transactions for.\n */\n #listAccounts(): InternalAccount[] {\n const accounts = this.#listMultichainAccounts();\n return accounts.filter((account) => this.#isNonEvmAccount(account));\n }\n\n /**\n * Updates the transactions for one account.\n *\n * @param accountId - The ID of the account to update transactions for.\n * @param pagination - Options for paginating transaction results.\n */\n async #updateTransactions(accountId: string, pagination: PaginationOptions) {\n const account = this.#listAccounts().find(\n (accountItem) => accountItem.id === accountId,\n );\n\n if (account?.metadata.snap) {\n const response = await this.#getTransactions(\n account.id,\n account.metadata.snap.id,\n pagination,\n );\n\n /**\n * Filter only Solana transactions to ensure they're mainnet\n * All other chain transactions are included as-is\n */\n const transactions = response.data.filter((tx) => {\n const chain = tx.chain as MultichainNetwork;\n if (chain.startsWith(MultichainNetwork.Solana)) {\n return chain === MultichainNetwork.Solana;\n }\n return true;\n });\n\n this.update((state: Draft<MultichainTransactionsControllerState>) => {\n const entry: TransactionStateEntry = {\n transactions,\n next: response.next,\n lastUpdated: Date.now(),\n };\n\n Object.assign(state.nonEvmTransactions, { [account.id]: entry });\n });\n }\n }\n\n /**\n * Gets transactions for an account.\n *\n * @param accountId - The ID of the account to get transactions for.\n * @param snapId - The ID of the snap that manages the account.\n * @param pagination - Options for paginating transaction results.\n * @returns A promise that resolves to the transaction data and pagination info.\n */\n async #getTransactions(\n accountId: string,\n snapId: string,\n pagination: PaginationOptions,\n ): Promise<{\n data: Transaction[];\n next: string | null;\n }> {\n return await this.#getClient(snapId).listAccountTransactions(\n accountId,\n pagination,\n );\n }\n\n /**\n * Updates transactions for a specific account\n *\n * @param accountId - The ID of the account to get transactions for.\n */\n async updateTransactionsForAccount(accountId: string) {\n await this.#tracker.updateTransactionsForAccount(accountId);\n }\n\n /**\n * Updates the transactions of all supported accounts. This method doesn't return\n * anything, but it updates the state of the controller.\n */\n async updateTransactions() {\n await this.#tracker.updateTransactions();\n }\n\n /**\n * Starts the polling process.\n */\n start(): void {\n this.#tracker.start();\n }\n\n /**\n * Stops the polling process.\n */\n stop(): void {\n this.#tracker.stop();\n }\n\n /**\n * Gets the block time for a given account.\n *\n * @param account - The account to get the block time for.\n * @returns The block time for the account.\n */\n #getBlockTimeFor(account: InternalAccount): number {\n if (account.type in TRANSACTIONS_CHECK_INTERVALS) {\n return TRANSACTIONS_CHECK_INTERVALS[\n account.type as keyof typeof TRANSACTIONS_CHECK_INTERVALS\n ];\n }\n throw new Error(\n `Unsupported account type for transactions tracking: ${account.type}`,\n );\n }\n\n /**\n * Checks for non-EVM accounts.\n *\n * @param account - The new account to be checked.\n * @returns True if the account is a non-EVM account, false otherwise.\n */\n #isNonEvmAccount(account: InternalAccount): boolean {\n return (\n !isEvmAccountType(account.type) &&\n // Non-EVM accounts are backed by a Snap for now\n account.metadata.snap !== undefined\n );\n }\n\n /**\n * Handles changes when a new account has been added.\n *\n * @param account - The new account being added.\n */\n async #handleOnAccountAdded(account: InternalAccount) {\n if (!this.#isNonEvmAccount(account)) {\n return;\n }\n\n this.#tracker.track(account.id, this.#getBlockTimeFor(account));\n }\n\n /**\n * Handles changes when a new account has been removed.\n *\n * @param accountId - The account ID being removed.\n */\n async #handleOnAccountRemoved(accountId: string) {\n if (this.#tracker.isTracked(accountId)) {\n this.#tracker.untrack(accountId);\n }\n\n if (accountId in this.state.nonEvmTransactions) {\n this.update((state: Draft<MultichainTransactionsControllerState>) => {\n delete state.nonEvmTransactions[accountId];\n });\n }\n }\n\n /**\n * Gets a `KeyringClient` for a Snap.\n *\n * @param snapId - ID of the Snap to get the client for.\n * @returns A `KeyringClient` for the Snap.\n */\n #getClient(snapId: string): KeyringClient {\n return new KeyringClient({\n send: async (request: JsonRpcRequest) =>\n (await this.messagingSystem.call('SnapController:handleRequest', {\n snapId: snapId as SnapId,\n origin: 'metamask',\n handler: HandlerType.OnKeyringRequest,\n request,\n })) as Promise<Json>,\n });\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerListMultichainAccountsAction
|
|
1
|
+
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
2
2
|
import { BaseController, type ControllerGetStateAction, type ControllerStateChangeEvent, type RestrictedMessenger } from "@metamask/base-controller";
|
|
3
3
|
import { type Transaction } from "@metamask/keyring-api";
|
|
4
4
|
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
|
|
@@ -32,6 +32,13 @@ export declare function getDefaultMultichainTransactionsControllerState(): Multi
|
|
|
32
32
|
* Returns the state of the {@link MultichainTransactionsController}.
|
|
33
33
|
*/
|
|
34
34
|
export type MultichainTransactionsControllerGetStateAction = ControllerGetStateAction<typeof controllerName, MultichainTransactionsControllerState>;
|
|
35
|
+
/**
|
|
36
|
+
* Updates the transactions of all supported accounts.
|
|
37
|
+
*/
|
|
38
|
+
export type MultichainTransactionsControllerListTransactionsAction = {
|
|
39
|
+
type: `${typeof controllerName}:updateTransactions`;
|
|
40
|
+
handler: MultichainTransactionsController['updateTransactions'];
|
|
41
|
+
};
|
|
35
42
|
/**
|
|
36
43
|
* Event emitted when the state of the {@link MultichainTransactionsController} changes.
|
|
37
44
|
*/
|
|
@@ -39,7 +46,7 @@ export type MultichainTransactionsControllerStateChange = ControllerStateChangeE
|
|
|
39
46
|
/**
|
|
40
47
|
* Actions exposed by the {@link MultichainTransactionsController}.
|
|
41
48
|
*/
|
|
42
|
-
export type MultichainTransactionsControllerActions = MultichainTransactionsControllerGetStateAction;
|
|
49
|
+
export type MultichainTransactionsControllerActions = MultichainTransactionsControllerGetStateAction | MultichainTransactionsControllerListTransactionsAction;
|
|
43
50
|
/**
|
|
44
51
|
* Events emitted by {@link MultichainTransactionsController}.
|
|
45
52
|
*/
|
|
@@ -55,7 +62,7 @@ export type AllowedActions = HandleSnapRequest | AccountsControllerListMultichai
|
|
|
55
62
|
/**
|
|
56
63
|
* Events that this controller is allowed to subscribe.
|
|
57
64
|
*/
|
|
58
|
-
export type AllowedEvents = AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent
|
|
65
|
+
export type AllowedEvents = AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent;
|
|
59
66
|
/**
|
|
60
67
|
* The state of transactions for a specific account.
|
|
61
68
|
*/
|
|
@@ -75,12 +82,24 @@ export declare class MultichainTransactionsController extends BaseController<typ
|
|
|
75
82
|
state?: Partial<MultichainTransactionsControllerState>;
|
|
76
83
|
});
|
|
77
84
|
/**
|
|
78
|
-
* Updates transactions for a specific account
|
|
79
|
-
* when an account is first added.
|
|
85
|
+
* Updates transactions for a specific account
|
|
80
86
|
*
|
|
81
87
|
* @param accountId - The ID of the account to get transactions for.
|
|
82
88
|
*/
|
|
83
89
|
updateTransactionsForAccount(accountId: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Updates the transactions of all supported accounts. This method doesn't return
|
|
92
|
+
* anything, but it updates the state of the controller.
|
|
93
|
+
*/
|
|
94
|
+
updateTransactions(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Starts the polling process.
|
|
97
|
+
*/
|
|
98
|
+
start(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Stops the polling process.
|
|
101
|
+
*/
|
|
102
|
+
stop(): void;
|
|
84
103
|
}
|
|
85
104
|
export {};
|
|
86
105
|
//# sourceMappingURL=MultichainTransactionsController.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultichainTransactionsController.d.cts","sourceRoot":"","sources":["../src/MultichainTransactionsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,8CAA8C,
|
|
1
|
+
{"version":3,"file":"MultichainTransactionsController.d.cts","sourceRoot":"","sources":["../src/MultichainTransactionsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACzB,kCAAkC;AACnC,OAAO,EAAoB,KAAK,WAAW,EAAE,8BAA8B;AAG3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AASrE,QAAA,MAAM,cAAc,qCAAqC,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,kBAAkB,EAAE;QAClB,CAAC,SAAS,EAAE,MAAM,GAAG,qBAAqB,CAAC;KAC5C,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,+CAA+C,IAAI,qCAAqC,CAIvG;AAED;;GAEG;AACH,MAAM,MAAM,8CAA8C,GACxD,wBAAwB,CACtB,OAAO,cAAc,EACrB,qCAAqC,CACtC,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,GAAG,OAAO,cAAc,qBAAqB,CAAC;IACpD,OAAO,EAAE,gCAAgC,CAAC,oBAAoB,CAAC,CAAC;CACjE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2CAA2C,GACrD,0BAA0B,CACxB,OAAO,cAAc,EACrB,qCAAqC,CACtC,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAC/C,8CAA8C,GAC9C,sDAAsD,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAChD,2CAA2C,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG,mBAAmB,CACzE,OAAO,cAAc,EACrB,uCAAuC,GAAG,cAAc,EACxD,sCAAsC,GAAG,aAAa,EACtD,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,iBAAiB,GACjB,8CAA8C,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,mCAAmC,GACnC,qCAAqC,CAAC;AAgB1C;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,qBAAa,gCAAiC,SAAQ,cAAc,CAClE,OAAO,cAAc,EACrB,qCAAqC,EACrC,yCAAyC,CAC1C;;gBAGa,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,yCAAyC,CAAC;QACrD,KAAK,CAAC,EAAE,OAAO,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAsHD;;;;OAIG;IACG,4BAA4B,CAAC,SAAS,EAAE,MAAM;IAIpD;;;OAGG;IACG,kBAAkB;IAIxB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,IAAI;CAkFb"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerListMultichainAccountsAction
|
|
1
|
+
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
2
2
|
import { BaseController, type ControllerGetStateAction, type ControllerStateChangeEvent, type RestrictedMessenger } from "@metamask/base-controller";
|
|
3
3
|
import { type Transaction } from "@metamask/keyring-api";
|
|
4
4
|
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
|
|
@@ -32,6 +32,13 @@ export declare function getDefaultMultichainTransactionsControllerState(): Multi
|
|
|
32
32
|
* Returns the state of the {@link MultichainTransactionsController}.
|
|
33
33
|
*/
|
|
34
34
|
export type MultichainTransactionsControllerGetStateAction = ControllerGetStateAction<typeof controllerName, MultichainTransactionsControllerState>;
|
|
35
|
+
/**
|
|
36
|
+
* Updates the transactions of all supported accounts.
|
|
37
|
+
*/
|
|
38
|
+
export type MultichainTransactionsControllerListTransactionsAction = {
|
|
39
|
+
type: `${typeof controllerName}:updateTransactions`;
|
|
40
|
+
handler: MultichainTransactionsController['updateTransactions'];
|
|
41
|
+
};
|
|
35
42
|
/**
|
|
36
43
|
* Event emitted when the state of the {@link MultichainTransactionsController} changes.
|
|
37
44
|
*/
|
|
@@ -39,7 +46,7 @@ export type MultichainTransactionsControllerStateChange = ControllerStateChangeE
|
|
|
39
46
|
/**
|
|
40
47
|
* Actions exposed by the {@link MultichainTransactionsController}.
|
|
41
48
|
*/
|
|
42
|
-
export type MultichainTransactionsControllerActions = MultichainTransactionsControllerGetStateAction;
|
|
49
|
+
export type MultichainTransactionsControllerActions = MultichainTransactionsControllerGetStateAction | MultichainTransactionsControllerListTransactionsAction;
|
|
43
50
|
/**
|
|
44
51
|
* Events emitted by {@link MultichainTransactionsController}.
|
|
45
52
|
*/
|
|
@@ -55,7 +62,7 @@ export type AllowedActions = HandleSnapRequest | AccountsControllerListMultichai
|
|
|
55
62
|
/**
|
|
56
63
|
* Events that this controller is allowed to subscribe.
|
|
57
64
|
*/
|
|
58
|
-
export type AllowedEvents = AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent
|
|
65
|
+
export type AllowedEvents = AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent;
|
|
59
66
|
/**
|
|
60
67
|
* The state of transactions for a specific account.
|
|
61
68
|
*/
|
|
@@ -75,12 +82,24 @@ export declare class MultichainTransactionsController extends BaseController<typ
|
|
|
75
82
|
state?: Partial<MultichainTransactionsControllerState>;
|
|
76
83
|
});
|
|
77
84
|
/**
|
|
78
|
-
* Updates transactions for a specific account
|
|
79
|
-
* when an account is first added.
|
|
85
|
+
* Updates transactions for a specific account
|
|
80
86
|
*
|
|
81
87
|
* @param accountId - The ID of the account to get transactions for.
|
|
82
88
|
*/
|
|
83
89
|
updateTransactionsForAccount(accountId: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Updates the transactions of all supported accounts. This method doesn't return
|
|
92
|
+
* anything, but it updates the state of the controller.
|
|
93
|
+
*/
|
|
94
|
+
updateTransactions(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Starts the polling process.
|
|
97
|
+
*/
|
|
98
|
+
start(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Stops the polling process.
|
|
101
|
+
*/
|
|
102
|
+
stop(): void;
|
|
84
103
|
}
|
|
85
104
|
export {};
|
|
86
105
|
//# sourceMappingURL=MultichainTransactionsController.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultichainTransactionsController.d.mts","sourceRoot":"","sources":["../src/MultichainTransactionsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,8CAA8C,
|
|
1
|
+
{"version":3,"file":"MultichainTransactionsController.d.mts","sourceRoot":"","sources":["../src/MultichainTransactionsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,m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