@metamask-previews/multichain-transactions-controller 0.1.0-preview-99939da3 → 0.2.0-preview-224dff25
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 +15 -1
- package/dist/MultichainTransactionsController.cjs +51 -76
- package/dist/MultichainTransactionsController.cjs.map +1 -1
- package/dist/MultichainTransactionsController.d.cts +5 -24
- package/dist/MultichainTransactionsController.d.cts.map +1 -1
- package/dist/MultichainTransactionsController.d.mts +5 -24
- package/dist/MultichainTransactionsController.d.mts.map +1 -1
- package/dist/MultichainTransactionsController.mjs +52 -77
- package/dist/MultichainTransactionsController.mjs.map +1 -1
- package/dist/constants.cjs +1 -11
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +0 -4
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +0 -4
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +0 -10
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +1 -2
- 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 +9 -9
- package/dist/MultichainTransactionsTracker.cjs +0 -124
- package/dist/MultichainTransactionsTracker.cjs.map +0 -1
- package/dist/MultichainTransactionsTracker.d.cts +0 -62
- package/dist/MultichainTransactionsTracker.d.cts.map +0 -1
- package/dist/MultichainTransactionsTracker.d.mts +0 -62
- package/dist/MultichainTransactionsTracker.d.mts.map +0 -1
- package/dist/MultichainTransactionsTracker.mjs +0 -120
- package/dist/MultichainTransactionsTracker.mjs.map +0 -1
- package/dist/Poller.cjs +0 -40
- package/dist/Poller.cjs.map +0 -1
- package/dist/Poller.d.cts +0 -7
- package/dist/Poller.d.cts.map +0 -1
- package/dist/Poller.d.mts +0 -7
- package/dist/Poller.d.mts.map +0 -1
- package/dist/Poller.mjs +0 -36
- package/dist/Poller.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^22.0.0` to `^23.0.0` ([#5292](https://github.com/MetaMask/core/pull/5292))
|
|
15
|
+
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.10.0` to `^9.19.0` ([#5265](https://github.com/MetaMask/core/pull/5265))
|
|
16
|
+
- Bump `@metamask/snaps-sdk` from `^6.7.0` to `^6.17.1` ([#5220](https://github.com/MetaMask/core/pull/5220)), ([#5265](https://github.com/MetaMask/core/pull/5265))
|
|
17
|
+
- Bump `@metamask/snaps-utils` from `^8.9.0` to `^8.10.0` ([#5265](https://github.com/MetaMask/core/pull/5265))
|
|
18
|
+
- Bump `@metamask/snaps-controllers` from `^9.10.0` to `^9.19.0` ([#5265](https://github.com/MetaMask/core/pull/5265))
|
|
19
|
+
- Bump `@metamask/keyring-api"` from `^16.1.0` to `^17.0.0` ([#5280](https://github.com/MetaMask/core/pull/5280))
|
|
20
|
+
- Bump `@metamask/utils` from `^11.0.1` to `^11.1.0` ([#5223](https://github.com/MetaMask/core/pull/5223))
|
|
21
|
+
- Removed polling mechanism and now relies on the new `AccountsController:accountTransactionsUpdated` event ([#5221](https://github.com/MetaMask/core/pull/5221))
|
|
22
|
+
|
|
10
23
|
## [0.1.0]
|
|
11
24
|
|
|
12
25
|
### Changed
|
|
@@ -22,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
22
35
|
|
|
23
36
|
- Initial release ([#5133](https://github.com/MetaMask/core/pull/5133)), ([#5177](https://github.com/MetaMask/core/pull/5177))
|
|
24
37
|
|
|
25
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/multichain-transactions-controller@0.
|
|
38
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/multichain-transactions-controller@0.2.0...HEAD
|
|
39
|
+
[0.2.0]: https://github.com/MetaMask/core/compare/@metamask/multichain-transactions-controller@0.1.0...@metamask/multichain-transactions-controller@0.2.0
|
|
26
40
|
[0.1.0]: https://github.com/MetaMask/core/compare/@metamask/multichain-transactions-controller@0.0.1...@metamask/multichain-transactions-controller@0.1.0
|
|
27
41
|
[0.0.1]: https://github.com/MetaMask/core/releases/tag/@metamask/multichain-transactions-controller@0.0.1
|
|
@@ -4,21 +4,15 @@ 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
|
|
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;
|
|
7
|
+
var _MultichainTransactionsController_instances, _MultichainTransactionsController_listMultichainAccounts, _MultichainTransactionsController_listAccounts, _MultichainTransactionsController_getTransactions, _MultichainTransactionsController_isNonEvmAccount, _MultichainTransactionsController_handleOnAccountAdded, _MultichainTransactionsController_handleOnAccountRemoved, _MultichainTransactionsController_handleOnAccountTransactionsUpdated, _MultichainTransactionsController_getClient;
|
|
14
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
9
|
exports.MultichainTransactionsController = exports.getDefaultMultichainTransactionsControllerState = void 0;
|
|
16
10
|
const base_controller_1 = require("@metamask/base-controller");
|
|
17
11
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
18
12
|
const keyring_snap_client_1 = require("@metamask/keyring-snap-client");
|
|
19
13
|
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
14
|
+
const utils_1 = require("@metamask/utils");
|
|
20
15
|
const constants_1 = require("./constants.cjs");
|
|
21
|
-
const MultichainTransactionsTracker_1 = require("./MultichainTransactionsTracker.cjs");
|
|
22
16
|
const controllerName = 'MultichainTransactionsController';
|
|
23
17
|
/**
|
|
24
18
|
* Constructs the default {@link MultichainTransactionsController} state.
|
|
@@ -60,82 +54,62 @@ class MultichainTransactionsController extends base_controller_1.BaseController
|
|
|
60
54
|
},
|
|
61
55
|
});
|
|
62
56
|
_MultichainTransactionsController_instances.add(this);
|
|
63
|
-
|
|
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
|
|
57
|
+
// Fetch initial transactions for all non-EVM accounts
|
|
66
58
|
for (const account of __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_listAccounts).call(this)) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
59
|
+
this.updateTransactionsForAccount(account.id).catch((error) => {
|
|
60
|
+
console.error(`Failed to fetch initial transactions for account ${account.id}:`, error);
|
|
61
|
+
});
|
|
70
62
|
}
|
|
71
63
|
this.messagingSystem.subscribe('AccountsController:accountAdded', (account) => __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_handleOnAccountAdded).call(this, account));
|
|
72
64
|
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));
|
|
73
66
|
}
|
|
74
67
|
/**
|
|
75
|
-
* Updates transactions for a specific account
|
|
68
|
+
* Updates transactions for a specific account. This is used for the initial fetch
|
|
69
|
+
* when an account is first added.
|
|
76
70
|
*
|
|
77
71
|
* @param accountId - The ID of the account to get transactions for.
|
|
78
72
|
*/
|
|
79
73
|
async updateTransactionsForAccount(accountId) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
74
|
+
try {
|
|
75
|
+
const account = __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_listAccounts).call(this).find((accountItem) => accountItem.id === accountId);
|
|
76
|
+
if (account?.metadata.snap) {
|
|
77
|
+
const response = await __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_getTransactions).call(this, account.id, account.metadata.snap.id, { limit: 10 });
|
|
78
|
+
// Filter only Solana transactions to ensure they're on mainnet.
|
|
79
|
+
// All other chain transactions are included as-is.
|
|
80
|
+
// TODO: Maybe we should not do any filtering here? Or maybe have it
|
|
81
|
+
// being configurable somehow?
|
|
82
|
+
const transactions = response.data.filter((tx) => {
|
|
83
|
+
const chain = tx.chain;
|
|
84
|
+
const { namespace } = (0, utils_1.parseCaipChainId)(chain);
|
|
85
|
+
// Enum comparison is safe here as we control both enum values
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
87
|
+
if (namespace === utils_1.KnownCaipNamespace.Solana) {
|
|
88
|
+
return chain === constants_1.MultichainNetwork.Solana;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
});
|
|
92
|
+
this.update((state) => {
|
|
93
|
+
const entry = {
|
|
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
|
+
}
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
exports.MultichainTransactionsController = MultichainTransactionsController;
|
|
103
|
-
|
|
108
|
+
_MultichainTransactionsController_instances = new WeakSet(), _MultichainTransactionsController_listMultichainAccounts = function _MultichainTransactionsController_listMultichainAccounts() {
|
|
104
109
|
return this.messagingSystem.call('AccountsController:listMultichainAccounts');
|
|
105
110
|
}, _MultichainTransactionsController_listAccounts = function _MultichainTransactionsController_listAccounts() {
|
|
106
111
|
const accounts = __classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_listMultichainAccounts).call(this);
|
|
107
112
|
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
|
-
}
|
|
139
113
|
}, _MultichainTransactionsController_getTransactions =
|
|
140
114
|
/**
|
|
141
115
|
* Gets transactions for an account.
|
|
@@ -147,11 +121,6 @@ async function _MultichainTransactionsController_updateTransactions(accountId, p
|
|
|
147
121
|
*/
|
|
148
122
|
async function _MultichainTransactionsController_getTransactions(accountId, snapId, pagination) {
|
|
149
123
|
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}`);
|
|
155
124
|
}, _MultichainTransactionsController_isNonEvmAccount = function _MultichainTransactionsController_isNonEvmAccount(account) {
|
|
156
125
|
return (!(0, keyring_api_1.isEvmAccountType)(account.type) &&
|
|
157
126
|
// Non-EVM accounts are backed by a Snap for now
|
|
@@ -166,7 +135,7 @@ async function _MultichainTransactionsController_handleOnAccountAdded(account) {
|
|
|
166
135
|
if (!__classPrivateFieldGet(this, _MultichainTransactionsController_instances, "m", _MultichainTransactionsController_isNonEvmAccount).call(this, account)) {
|
|
167
136
|
return;
|
|
168
137
|
}
|
|
169
|
-
|
|
138
|
+
await this.updateTransactionsForAccount(account.id);
|
|
170
139
|
}, _MultichainTransactionsController_handleOnAccountRemoved =
|
|
171
140
|
/**
|
|
172
141
|
* Handles changes when a new account has been removed.
|
|
@@ -174,14 +143,20 @@ async function _MultichainTransactionsController_handleOnAccountAdded(account) {
|
|
|
174
143
|
* @param accountId - The account ID being removed.
|
|
175
144
|
*/
|
|
176
145
|
async function _MultichainTransactionsController_handleOnAccountRemoved(accountId) {
|
|
177
|
-
if (__classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").isTracked(accountId)) {
|
|
178
|
-
__classPrivateFieldGet(this, _MultichainTransactionsController_tracker, "f").untrack(accountId);
|
|
179
|
-
}
|
|
180
146
|
if (accountId in this.state.nonEvmTransactions) {
|
|
181
147
|
this.update((state) => {
|
|
182
148
|
delete state.nonEvmTransactions[accountId];
|
|
183
149
|
});
|
|
184
150
|
}
|
|
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
|
+
});
|
|
185
160
|
}, _MultichainTransactionsController_getClient = function _MultichainTransactionsController_getClient(snapId) {
|
|
186
161
|
return new keyring_snap_client_1.KeyringClient({
|
|
187
162
|
send: async (request) => (await this.messagingSystem.call('SnapController:handleRequest', {
|
|
@@ -1 +1 @@
|
|
|
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,CAAC;AAJD,0GAIC;AAkED;;;;;;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;IAGC,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,SAAS;YACT,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,wCAAwC;YAClD,KAAK,EAAE;gBACL,GAAG,+CAA+C,EAAE;gBACpD,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAjBI,4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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
|
+
{"version":3,"file":"MultichainTransactionsController.cjs","sourceRoot":"","sources":["../src/MultichainTransactionsController.ts"],"names":[],"mappings":";;;;;;;;;AAMA,+DAKmC;AACnC,uDAI+B;AAE/B,uEAA8D;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ACH,KAAK,mEAAyB,SAAiB;IAC7C,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,uJAQC,kBAA0D;IAE1D,IAAI,CAAC,MAAM,CAAC,CAAC,KAAmD,EAAE,EAAE;QAClE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,OAAO,CACrD,CAAC,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,EAAE;YAC5B,IAAI,SAAS,IAAI,KAAK,CAAC,kBAAkB,EAAE;gBACzC,KAAK,CAAC,kBAAkB,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,4 +1,4 @@
|
|
|
1
|
-
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
1
|
+
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerListMultichainAccountsAction, AccountsControllerAccountTransactionsUpdatedEvent } 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,13 +32,6 @@ 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
|
-
};
|
|
42
35
|
/**
|
|
43
36
|
* Event emitted when the state of the {@link MultichainTransactionsController} changes.
|
|
44
37
|
*/
|
|
@@ -46,7 +39,7 @@ export type MultichainTransactionsControllerStateChange = ControllerStateChangeE
|
|
|
46
39
|
/**
|
|
47
40
|
* Actions exposed by the {@link MultichainTransactionsController}.
|
|
48
41
|
*/
|
|
49
|
-
export type MultichainTransactionsControllerActions = MultichainTransactionsControllerGetStateAction
|
|
42
|
+
export type MultichainTransactionsControllerActions = MultichainTransactionsControllerGetStateAction;
|
|
50
43
|
/**
|
|
51
44
|
* Events emitted by {@link MultichainTransactionsController}.
|
|
52
45
|
*/
|
|
@@ -62,7 +55,7 @@ export type AllowedActions = HandleSnapRequest | AccountsControllerListMultichai
|
|
|
62
55
|
/**
|
|
63
56
|
* Events that this controller is allowed to subscribe.
|
|
64
57
|
*/
|
|
65
|
-
export type AllowedEvents = AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent;
|
|
58
|
+
export type AllowedEvents = AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent | AccountsControllerAccountTransactionsUpdatedEvent;
|
|
66
59
|
/**
|
|
67
60
|
* The state of transactions for a specific account.
|
|
68
61
|
*/
|
|
@@ -82,24 +75,12 @@ export declare class MultichainTransactionsController extends BaseController<typ
|
|
|
82
75
|
state?: Partial<MultichainTransactionsControllerState>;
|
|
83
76
|
});
|
|
84
77
|
/**
|
|
85
|
-
* Updates transactions for a specific account
|
|
78
|
+
* Updates transactions for a specific account. This is used for the initial fetch
|
|
79
|
+
* when an account is first added.
|
|
86
80
|
*
|
|
87
81
|
* @param accountId - The ID of the account to get transactions for.
|
|
88
82
|
*/
|
|
89
83
|
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;
|
|
103
84
|
}
|
|
104
85
|
export {};
|
|
105
86
|
//# 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,EAC9C,iDAAiD,EAClD,sCAAsC;AACvC,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACzB,kCAAkC;AACnC,OAAO,EAEL,KAAK,WAAW,EAEjB,8BAA8B;AAG/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAarE,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,2CAA2C,GACrD,0BAA0B,CACxB,OAAO,cAAc,EACrB,qCAAqC,CACtC,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,uCAAuC,GACjD,8CAA8C,CAAC;AAEjD;;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,GACrC,iDAAiD,CAAC;AAgBtD;;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;;gBACa,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,yCAAyC,CAAC;QACrD,KAAK,CAAC,EAAE,OAAO,CAAC,qCAAqC,CAAC,CAAC;KACxD;IA+ED;;;;;OAKG;IACG,4BAA4B,CAAC,SAAS,EAAE,MAAM;CA2HrD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
1
|
+
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerListMultichainAccountsAction, AccountsControllerAccountTransactionsUpdatedEvent } 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,13 +32,6 @@ 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
|
-
};
|
|
42
35
|
/**
|
|
43
36
|
* Event emitted when the state of the {@link MultichainTransactionsController} changes.
|
|
44
37
|
*/
|
|
@@ -46,7 +39,7 @@ export type MultichainTransactionsControllerStateChange = ControllerStateChangeE
|
|
|
46
39
|
/**
|
|
47
40
|
* Actions exposed by the {@link MultichainTransactionsController}.
|
|
48
41
|
*/
|
|
49
|
-
export type MultichainTransactionsControllerActions = MultichainTransactionsControllerGetStateAction
|
|
42
|
+
export type MultichainTransactionsControllerActions = MultichainTransactionsControllerGetStateAction;
|
|
50
43
|
/**
|
|
51
44
|
* Events emitted by {@link MultichainTransactionsController}.
|
|
52
45
|
*/
|
|
@@ -62,7 +55,7 @@ export type AllowedActions = HandleSnapRequest | AccountsControllerListMultichai
|
|
|
62
55
|
/**
|
|
63
56
|
* Events that this controller is allowed to subscribe.
|
|
64
57
|
*/
|
|
65
|
-
export type AllowedEvents = AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent;
|
|
58
|
+
export type AllowedEvents = AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent | AccountsControllerAccountTransactionsUpdatedEvent;
|
|
66
59
|
/**
|
|
67
60
|
* The state of transactions for a specific account.
|
|
68
61
|
*/
|
|
@@ -82,24 +75,12 @@ export declare class MultichainTransactionsController extends BaseController<typ
|
|
|
82
75
|
state?: Partial<MultichainTransactionsControllerState>;
|
|
83
76
|
});
|
|
84
77
|
/**
|
|
85
|
-
* Updates transactions for a specific account
|
|
78
|
+
* Updates transactions for a specific account. This is used for the initial fetch
|
|
79
|
+
* when an account is first added.
|
|
86
80
|
*
|
|
87
81
|
* @param accountId - The ID of the account to get transactions for.
|
|
88
82
|
*/
|
|
89
83
|
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;
|
|
103
84
|
}
|
|
104
85
|
export {};
|
|
105
86
|
//# 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,EAC9C,iDAAiD,EAClD,sCAAsC;AACvC,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACzB,kCAAkC;AACnC,OAAO,EAEL,KAAK,WAAW,EAEjB,8BAA8B;AAG/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAarE,QAAA,MAAM,cAAc,qCAAqC,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,iB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