@metamask-previews/user-operation-controller 41.2.9-preview-4f4c98e → 41.2.9-preview-eb263b0ee
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 -4
- package/dist/BlockTrackerPollingController.cjs +68 -0
- package/dist/BlockTrackerPollingController.cjs.map +1 -0
- package/dist/{BlockTrackerPollingController.d.ts → BlockTrackerPollingController.d.cts} +11 -11
- package/dist/BlockTrackerPollingController.d.cts.map +1 -0
- package/dist/BlockTrackerPollingController.d.mts +41 -0
- package/dist/BlockTrackerPollingController.d.mts.map +1 -0
- package/dist/{BlockTrackerPollingController.js → BlockTrackerPollingController.mjs} +16 -17
- package/dist/BlockTrackerPollingController.mjs.map +1 -0
- package/dist/UserOperationController-method-action-types.cjs +7 -0
- package/dist/UserOperationController-method-action-types.cjs.map +1 -0
- package/dist/{UserOperationController-method-action-types.d.ts → UserOperationController-method-action-types.d.cts} +2 -2
- package/dist/UserOperationController-method-action-types.d.cts.map +1 -0
- package/dist/UserOperationController-method-action-types.d.mts +57 -0
- package/dist/UserOperationController-method-action-types.d.mts.map +1 -0
- package/dist/{UserOperationController-method-action-types.js → UserOperationController-method-action-types.mjs} +1 -1
- package/dist/UserOperationController-method-action-types.mjs.map +1 -0
- package/dist/UserOperationController.cjs +495 -0
- package/dist/UserOperationController.cjs.map +1 -0
- package/dist/{UserOperationController.d.ts → UserOperationController.d.cts} +15 -13
- package/dist/UserOperationController.d.cts.map +1 -0
- package/dist/UserOperationController.d.mts +136 -0
- package/dist/UserOperationController.d.mts.map +1 -0
- package/dist/{UserOperationController.js → UserOperationController.mjs} +20 -19
- package/dist/UserOperationController.mjs.map +1 -0
- package/dist/constants.cjs +7 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{constants.d.ts → constants.d.cts} +1 -1
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +4 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/{constants.js → constants.mjs} +1 -1
- package/dist/constants.mjs.map +1 -0
- package/dist/helpers/Bundler.cjs +91 -0
- package/dist/helpers/Bundler.cjs.map +1 -0
- package/dist/helpers/{Bundler.d.ts → Bundler.d.cts} +2 -2
- package/dist/helpers/Bundler.d.cts.map +1 -0
- package/dist/helpers/Bundler.d.mts +46 -0
- package/dist/helpers/Bundler.d.mts.map +1 -0
- package/dist/helpers/{Bundler.js → Bundler.mjs} +2 -2
- package/dist/helpers/Bundler.mjs.map +1 -0
- package/dist/helpers/PendingUserOperationTracker.cjs +127 -0
- package/dist/helpers/PendingUserOperationTracker.cjs.map +1 -0
- package/dist/helpers/{PendingUserOperationTracker.d.ts → PendingUserOperationTracker.d.cts} +12 -10
- package/dist/helpers/PendingUserOperationTracker.d.cts.map +1 -0
- package/dist/helpers/PendingUserOperationTracker.d.mts +51 -0
- package/dist/helpers/PendingUserOperationTracker.d.mts.map +1 -0
- package/dist/helpers/{PendingUserOperationTracker.js → PendingUserOperationTracker.mjs} +16 -9
- package/dist/helpers/PendingUserOperationTracker.mjs.map +1 -0
- package/dist/helpers/SnapSmartContractAccount.cjs +64 -0
- package/dist/helpers/SnapSmartContractAccount.cjs.map +1 -0
- package/dist/helpers/{SnapSmartContractAccount.d.ts → SnapSmartContractAccount.d.cts} +3 -3
- package/dist/helpers/SnapSmartContractAccount.d.cts.map +1 -0
- package/dist/helpers/SnapSmartContractAccount.d.mts +10 -0
- package/dist/helpers/SnapSmartContractAccount.d.mts.map +1 -0
- package/dist/helpers/{SnapSmartContractAccount.js → SnapSmartContractAccount.mjs} +3 -3
- package/dist/helpers/SnapSmartContractAccount.mjs.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger.cjs +8 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +5 -0
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +5 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/{logger.js → logger.mjs} +2 -2
- package/dist/logger.mjs.map +1 -0
- package/dist/types.cjs +16 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +3 -3
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +294 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/{types.js → types.mjs} +1 -1
- package/dist/types.mjs.map +1 -0
- package/dist/utils/chain-id.cjs +17 -0
- package/dist/utils/chain-id.cjs.map +1 -0
- package/dist/utils/{chain-id.d.ts → chain-id.d.cts} +1 -1
- package/dist/utils/chain-id.d.cts.map +1 -0
- package/dist/utils/chain-id.d.mts +8 -0
- package/dist/utils/chain-id.d.mts.map +1 -0
- package/dist/utils/{chain-id.js → chain-id.mjs} +1 -1
- package/dist/utils/chain-id.mjs.map +1 -0
- package/dist/utils/gas-fees.cjs +194 -0
- package/dist/utils/gas-fees.cjs.map +1 -0
- package/dist/utils/{gas-fees.d.ts → gas-fees.d.cts} +6 -6
- package/dist/utils/gas-fees.d.cts.map +1 -0
- package/dist/utils/gas-fees.d.mts +24 -0
- package/dist/utils/gas-fees.d.mts.map +1 -0
- package/dist/utils/{gas-fees.js → gas-fees.mjs} +15 -8
- package/dist/utils/gas-fees.mjs.map +1 -0
- package/dist/utils/gas.cjs +72 -0
- package/dist/utils/gas.cjs.map +1 -0
- package/dist/utils/{gas.d.ts → gas.d.cts} +2 -2
- package/dist/utils/gas.d.cts.map +1 -0
- package/dist/utils/gas.d.mts +10 -0
- package/dist/utils/gas.d.mts.map +1 -0
- package/dist/utils/{gas.js → gas.mjs} +14 -7
- package/dist/utils/gas.mjs.map +1 -0
- package/dist/utils/transaction.cjs +117 -0
- package/dist/utils/transaction.cjs.map +1 -0
- package/dist/utils/{transaction.d.ts → transaction.d.cts} +3 -3
- package/dist/utils/transaction.d.cts.map +1 -0
- package/dist/utils/transaction.d.mts +10 -0
- package/dist/utils/transaction.d.mts.map +1 -0
- package/dist/utils/{transaction.js → transaction.mjs} +13 -6
- package/dist/utils/transaction.mjs.map +1 -0
- package/dist/utils/validation.cjs +162 -0
- package/dist/utils/validation.cjs.map +1 -0
- package/dist/utils/{validation.d.ts → validation.d.cts} +3 -3
- package/dist/utils/validation.d.cts.map +1 -0
- package/dist/utils/validation.d.mts +33 -0
- package/dist/utils/validation.d.mts.map +1 -0
- package/dist/utils/{validation.js → validation.mjs} +5 -5
- package/dist/utils/validation.mjs.map +1 -0
- package/package.json +17 -13
- package/dist/BlockTrackerPollingController.d.ts.map +0 -1
- package/dist/BlockTrackerPollingController.js.map +0 -1
- package/dist/UserOperationController-method-action-types.d.ts.map +0 -1
- package/dist/UserOperationController-method-action-types.js.map +0 -1
- package/dist/UserOperationController.d.ts.map +0 -1
- package/dist/UserOperationController.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/helpers/Bundler.d.ts.map +0 -1
- package/dist/helpers/Bundler.js.map +0 -1
- package/dist/helpers/PendingUserOperationTracker.d.ts.map +0 -1
- package/dist/helpers/PendingUserOperationTracker.js.map +0 -1
- package/dist/helpers/SnapSmartContractAccount.d.ts.map +0 -1
- package/dist/helpers/SnapSmartContractAccount.js.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts +0 -4
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/chain-id.d.ts.map +0 -1
- package/dist/utils/chain-id.js.map +0 -1
- package/dist/utils/gas-fees.d.ts.map +0 -1
- package/dist/utils/gas-fees.js.map +0 -1
- package/dist/utils/gas.d.ts.map +0 -1
- package/dist/utils/gas.js.map +0 -1
- package/dist/utils/transaction.d.ts.map +0 -1
- package/dist/utils/transaction.js.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js.map +0 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _PendingUserOperationTracker_instances, _PendingUserOperationTracker_getUserOperations, _PendingUserOperationTracker_messenger, _PendingUserOperationTracker_checkUserOperations, _PendingUserOperationTracker_checkUserOperation, _PendingUserOperationTracker_onUserOperationConfirmed, _PendingUserOperationTracker_onUserOperationFailed, _PendingUserOperationTracker_getPendingUserOperations, _PendingUserOperationTracker_updateUserOperation, _PendingUserOperationTracker_getUserOperationReceipt, _PendingUserOperationTracker_normalizeGasValue;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PendingUserOperationTracker = void 0;
|
|
19
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
20
|
+
const eth_query_1 = __importDefault(require("@metamask/eth-query"));
|
|
21
|
+
const utils_1 = require("@metamask/utils");
|
|
22
|
+
// This package purposefully relies on Node's EventEmitter module.
|
|
23
|
+
// eslint-disable-next-line import-x/no-nodejs-modules
|
|
24
|
+
const events_1 = __importDefault(require("events"));
|
|
25
|
+
const BlockTrackerPollingController_js_1 = require("../BlockTrackerPollingController.cjs");
|
|
26
|
+
const logger_js_1 = require("../logger.cjs");
|
|
27
|
+
const types_js_1 = require("../types.cjs");
|
|
28
|
+
const Bundler_js_1 = require("./Bundler.cjs");
|
|
29
|
+
const log = (0, utils_1.createModuleLogger)(logger_js_1.projectLogger, 'pending-user-operations');
|
|
30
|
+
/**
|
|
31
|
+
* A helper class to periodically query the bundlers
|
|
32
|
+
* and update the status of any submitted user operations.
|
|
33
|
+
*/
|
|
34
|
+
class PendingUserOperationTracker extends (0, BlockTrackerPollingController_js_1.BlockTrackerPollingControllerOnly)() {
|
|
35
|
+
constructor({ getUserOperations, messenger, }) {
|
|
36
|
+
super();
|
|
37
|
+
_PendingUserOperationTracker_instances.add(this);
|
|
38
|
+
_PendingUserOperationTracker_getUserOperations.set(this, void 0);
|
|
39
|
+
_PendingUserOperationTracker_messenger.set(this, void 0);
|
|
40
|
+
this.hub = new events_1.default();
|
|
41
|
+
__classPrivateFieldSet(this, _PendingUserOperationTracker_getUserOperations, getUserOperations, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _PendingUserOperationTracker_messenger, messenger, "f");
|
|
43
|
+
}
|
|
44
|
+
async _executePoll({ networkClientId }) {
|
|
45
|
+
try {
|
|
46
|
+
const { blockTracker, configuration, provider } = this._getNetworkClientById(networkClientId);
|
|
47
|
+
log('Polling', {
|
|
48
|
+
blockNumber: blockTracker.getCurrentBlock(),
|
|
49
|
+
chainId: configuration.chainId,
|
|
50
|
+
});
|
|
51
|
+
await __classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_checkUserOperations).call(this, configuration.chainId, provider);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
/* istanbul ignore next */
|
|
55
|
+
log('Failed to check user operations', error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
_getNetworkClientById(networkClientId) {
|
|
59
|
+
return __classPrivateFieldGet(this, _PendingUserOperationTracker_messenger, "f").call('NetworkController:getNetworkClientById', networkClientId);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.PendingUserOperationTracker = PendingUserOperationTracker;
|
|
63
|
+
_PendingUserOperationTracker_getUserOperations = new WeakMap(), _PendingUserOperationTracker_messenger = new WeakMap(), _PendingUserOperationTracker_instances = new WeakSet(), _PendingUserOperationTracker_checkUserOperations = async function _PendingUserOperationTracker_checkUserOperations(chainId, provider) {
|
|
64
|
+
const pendingUserOperations = __classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_getPendingUserOperations).call(this).filter((metadata) => metadata.chainId === chainId);
|
|
65
|
+
if (!pendingUserOperations.length) {
|
|
66
|
+
log('No pending user operations to check');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
log('Found pending user operations to check', {
|
|
70
|
+
count: pendingUserOperations.length,
|
|
71
|
+
ids: pendingUserOperations.map((userOperation) => userOperation.id),
|
|
72
|
+
});
|
|
73
|
+
await Promise.all(pendingUserOperations.map((userOperation) => __classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_checkUserOperation).call(this, userOperation, provider)));
|
|
74
|
+
}, _PendingUserOperationTracker_checkUserOperation = async function _PendingUserOperationTracker_checkUserOperation(metadata, provider) {
|
|
75
|
+
const { bundlerUrl, hash, id } = metadata;
|
|
76
|
+
if (!hash || !bundlerUrl) {
|
|
77
|
+
log('Skipping user operation as missing hash or bundler', id);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const receipt = await __classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_getUserOperationReceipt).call(this, hash, bundlerUrl);
|
|
82
|
+
const isSuccess = receipt?.success;
|
|
83
|
+
if (receipt && !isSuccess) {
|
|
84
|
+
__classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_onUserOperationFailed).call(this, metadata, receipt);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (isSuccess) {
|
|
88
|
+
await __classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_onUserOperationConfirmed).call(this, metadata, receipt, provider);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
log('No receipt found for user operation', { id, hash });
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
log('Failed to check user operation', id, error);
|
|
95
|
+
}
|
|
96
|
+
}, _PendingUserOperationTracker_onUserOperationConfirmed = async function _PendingUserOperationTracker_onUserOperationConfirmed(metadata, receipt, provider) {
|
|
97
|
+
const { id } = metadata;
|
|
98
|
+
const { actualGasCost, actualGasUsed, receipt: { blockHash, transactionHash }, } = receipt;
|
|
99
|
+
log('User operation confirmed', id, transactionHash);
|
|
100
|
+
const { baseFeePerGas } = await (0, controller_utils_1.query)(new eth_query_1.default(provider), 'getBlockByHash', [blockHash, false]);
|
|
101
|
+
metadata.actualGasCost = __classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_normalizeGasValue).call(this, actualGasCost);
|
|
102
|
+
metadata.actualGasUsed = __classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_normalizeGasValue).call(this, actualGasUsed);
|
|
103
|
+
metadata.baseFeePerGas = baseFeePerGas;
|
|
104
|
+
metadata.status = types_js_1.UserOperationStatus.Confirmed;
|
|
105
|
+
metadata.transactionHash = transactionHash;
|
|
106
|
+
__classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_updateUserOperation).call(this, metadata);
|
|
107
|
+
this.hub.emit('user-operation-confirmed', metadata);
|
|
108
|
+
}, _PendingUserOperationTracker_onUserOperationFailed = function _PendingUserOperationTracker_onUserOperationFailed(metadata, _receipt) {
|
|
109
|
+
const { id } = metadata;
|
|
110
|
+
log('User operation failed', id);
|
|
111
|
+
metadata.status = types_js_1.UserOperationStatus.Failed;
|
|
112
|
+
__classPrivateFieldGet(this, _PendingUserOperationTracker_instances, "m", _PendingUserOperationTracker_updateUserOperation).call(this, metadata);
|
|
113
|
+
this.hub.emit('user-operation-failed', metadata, new Error('User operation receipt has failed status'));
|
|
114
|
+
}, _PendingUserOperationTracker_getPendingUserOperations = function _PendingUserOperationTracker_getPendingUserOperations() {
|
|
115
|
+
return __classPrivateFieldGet(this, _PendingUserOperationTracker_getUserOperations, "f").call(this).filter((userOperation) => userOperation.status === types_js_1.UserOperationStatus.Submitted);
|
|
116
|
+
}, _PendingUserOperationTracker_updateUserOperation = function _PendingUserOperationTracker_updateUserOperation(metadata) {
|
|
117
|
+
this.hub.emit('user-operation-updated', metadata);
|
|
118
|
+
}, _PendingUserOperationTracker_getUserOperationReceipt = async function _PendingUserOperationTracker_getUserOperationReceipt(hash, bundlerUrl) {
|
|
119
|
+
const bundler = new Bundler_js_1.Bundler(bundlerUrl);
|
|
120
|
+
return bundler.getUserOperationReceipt(hash);
|
|
121
|
+
}, _PendingUserOperationTracker_normalizeGasValue = function _PendingUserOperationTracker_normalizeGasValue(gasValue) {
|
|
122
|
+
if (typeof gasValue === 'number') {
|
|
123
|
+
return (0, controller_utils_1.toHex)(gasValue);
|
|
124
|
+
}
|
|
125
|
+
return gasValue;
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=PendingUserOperationTracker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingUserOperationTracker.cjs","sourceRoot":"","sources":["../../src/helpers/PendingUserOperationTracker.ts"],"names":[],"m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EpC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC,mHAGC,QAA+B,EAC/B,QAA8B;IAE9B,MAAM,EAAE,EAAE,EAAE,GAAG,QAAQ,CAAC;IAExB,GAAG,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAEjC,QAAQ,CAAC,MAAM,GAAG,8BAAmB,CAAC,MAAM,CAAC;IAE7C,uBAAA,IAAI,gGAAqB,MAAzB,IAAI,EAAsB,QAAQ,CAAC,CAAC;IAEpC,IAAI,CAAC,GAAG,CAAC,IAAI,CACX,uBAAuB,EACvB,QAAQ,EACR,IAAI,KAAK,CAAC,0CAA0C,CAAC,CACtD,CAAC;AACJ,CAAC;IAGC,OAAO,uBAAA,IAAI,sDAAmB,MAAvB,IAAI,CAAqB,CAAC,MAAM,CACrC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,KAAK,8BAAmB,CAAC,SAAS,CAC1E,CAAC;AACJ,CAAC,+GAEoB,QAA+B;IAClD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC,yDAED,KAAK,+DACH,IAAY,EACZ,UAAkB;IAElB,MAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC,2GAEkB,QAAsB;IACvC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,IAAA,wBAAK,EAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { query, toHex } from '@metamask/controller-utils';\nimport EthQuery from '@metamask/eth-query';\nimport type {\n NetworkClient,\n NetworkClientId,\n Provider,\n} from '@metamask/network-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n// This package purposefully relies on Node's EventEmitter module.\n// eslint-disable-next-line import-x/no-nodejs-modules\nimport EventEmitter from 'events';\n\nimport { BlockTrackerPollingControllerOnly } from '../BlockTrackerPollingController.js';\nimport { projectLogger } from '../logger.js';\nimport type { UserOperationMetadata, UserOperationReceipt } from '../types.js';\nimport { UserOperationStatus } from '../types.js';\nimport type { UserOperationControllerMessenger } from '../UserOperationController.js';\nimport { Bundler } from './Bundler.js';\n\nconst log = createModuleLogger(projectLogger, 'pending-user-operations');\n\ntype Events = {\n 'user-operation-confirmed': [metadata: UserOperationMetadata];\n 'user-operation-failed': [txMeta: UserOperationMetadata, error: Error];\n 'user-operation-updated': [txMeta: UserOperationMetadata];\n};\n\nexport type PendingUserOperationTrackerEventEmitter = EventEmitter & {\n on<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): PendingUserOperationTrackerEventEmitter;\n\n once<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): PendingUserOperationTrackerEventEmitter;\n\n emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;\n};\n\n/** The input to start polling for the {@link PendingUserOperationTracker} */\ntype PendingUserOperationPollingInput = {\n networkClientId: NetworkClientId;\n};\n\n/**\n * A helper class to periodically query the bundlers\n * and update the status of any submitted user operations.\n */\nexport class PendingUserOperationTracker extends BlockTrackerPollingControllerOnly<PendingUserOperationPollingInput>() {\n hub: PendingUserOperationTrackerEventEmitter;\n\n readonly #getUserOperations: () => UserOperationMetadata[];\n\n readonly #messenger: UserOperationControllerMessenger;\n\n constructor({\n getUserOperations,\n messenger,\n }: {\n getUserOperations: () => UserOperationMetadata[];\n messenger: UserOperationControllerMessenger;\n }) {\n super();\n\n this.hub = new EventEmitter() as PendingUserOperationTrackerEventEmitter;\n\n this.#getUserOperations = getUserOperations;\n this.#messenger = messenger;\n }\n\n async _executePoll({ networkClientId }: PendingUserOperationPollingInput) {\n try {\n const { blockTracker, configuration, provider } =\n this._getNetworkClientById(networkClientId) as NetworkClient;\n\n log('Polling', {\n blockNumber: blockTracker.getCurrentBlock(),\n chainId: configuration.chainId,\n });\n\n await this.#checkUserOperations(configuration.chainId, provider);\n } catch (error) {\n /* istanbul ignore next */\n log('Failed to check user operations', error);\n }\n }\n\n _getNetworkClientById(networkClientId: string): NetworkClient | undefined {\n return this.#messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n }\n\n async #checkUserOperations(chainId: string, provider: Provider) {\n const pendingUserOperations = this.#getPendingUserOperations().filter(\n (metadata) => metadata.chainId === chainId,\n );\n\n if (!pendingUserOperations.length) {\n log('No pending user operations to check');\n return;\n }\n\n log('Found pending user operations to check', {\n count: pendingUserOperations.length,\n ids: pendingUserOperations.map((userOperation) => userOperation.id),\n });\n\n await Promise.all(\n pendingUserOperations.map((userOperation) =>\n this.#checkUserOperation(userOperation, provider),\n ),\n );\n }\n\n async #checkUserOperation(\n metadata: UserOperationMetadata,\n provider: Provider,\n ) {\n const { bundlerUrl, hash, id } = metadata;\n\n if (!hash || !bundlerUrl) {\n log('Skipping user operation as missing hash or bundler', id);\n return;\n }\n\n try {\n const receipt = await this.#getUserOperationReceipt(hash, bundlerUrl);\n const isSuccess = receipt?.success;\n\n if (receipt && !isSuccess) {\n this.#onUserOperationFailed(metadata, receipt);\n return;\n }\n\n if (isSuccess) {\n await this.#onUserOperationConfirmed(metadata, receipt, provider);\n return;\n }\n\n log('No receipt found for user operation', { id, hash });\n } catch (error) {\n log('Failed to check user operation', id, error);\n }\n }\n\n async #onUserOperationConfirmed(\n metadata: UserOperationMetadata,\n receipt: UserOperationReceipt,\n provider: Provider,\n ) {\n const { id } = metadata;\n\n const {\n actualGasCost,\n actualGasUsed,\n receipt: { blockHash, transactionHash },\n } = receipt;\n\n log('User operation confirmed', id, transactionHash);\n\n const { baseFeePerGas } = await query(\n new EthQuery(provider),\n 'getBlockByHash',\n [blockHash, false],\n );\n\n metadata.actualGasCost = this.#normalizeGasValue(actualGasCost);\n metadata.actualGasUsed = this.#normalizeGasValue(actualGasUsed);\n metadata.baseFeePerGas = baseFeePerGas;\n metadata.status = UserOperationStatus.Confirmed;\n metadata.transactionHash = transactionHash;\n\n this.#updateUserOperation(metadata);\n\n this.hub.emit('user-operation-confirmed', metadata);\n }\n\n #onUserOperationFailed(\n metadata: UserOperationMetadata,\n _receipt: UserOperationReceipt,\n ) {\n const { id } = metadata;\n\n log('User operation failed', id);\n\n metadata.status = UserOperationStatus.Failed;\n\n this.#updateUserOperation(metadata);\n\n this.hub.emit(\n 'user-operation-failed',\n metadata,\n new Error('User operation receipt has failed status'),\n );\n }\n\n #getPendingUserOperations(): UserOperationMetadata[] {\n return this.#getUserOperations().filter(\n (userOperation) => userOperation.status === UserOperationStatus.Submitted,\n );\n }\n\n #updateUserOperation(metadata: UserOperationMetadata) {\n this.hub.emit('user-operation-updated', metadata);\n }\n\n async #getUserOperationReceipt(\n hash: string,\n bundlerUrl: string,\n ): Promise<UserOperationReceipt | undefined> {\n const bundler = new Bundler(bundlerUrl);\n return bundler.getUserOperationReceipt(hash);\n }\n\n #normalizeGasValue(gasValue: Hex | number): string {\n if (typeof gasValue === 'number') {\n return toHex(gasValue);\n }\n return gasValue;\n }\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="npm-which/node_modules/@types/node/events.js" />
|
|
3
|
+
import type { NetworkClient, NetworkClientId } from "@metamask/network-controller";
|
|
4
|
+
import EventEmitter from "events";
|
|
5
|
+
import type { UserOperationMetadata } from "../types.cjs";
|
|
6
|
+
import type { UserOperationControllerMessenger } from "../UserOperationController.cjs";
|
|
5
7
|
type Events = {
|
|
6
8
|
'user-operation-confirmed': [metadata: UserOperationMetadata];
|
|
7
9
|
'user-operation-failed': [txMeta: UserOperationMetadata, error: Error];
|
|
@@ -17,12 +19,12 @@ type PendingUserOperationPollingInput = {
|
|
|
17
19
|
networkClientId: NetworkClientId;
|
|
18
20
|
};
|
|
19
21
|
declare const PendingUserOperationTracker_base: (abstract new (...args: any[]) => {
|
|
20
|
-
|
|
21
|
-
_getNetworkClientById(networkClientId:
|
|
22
|
+
"__#21@#activeListeners": Record<string, (options: import("@metamask/utils").Json) => Promise<void>>;
|
|
23
|
+
_getNetworkClientById(networkClientId: string): NetworkClient | undefined;
|
|
22
24
|
_startPolling(input: PendingUserOperationPollingInput): void;
|
|
23
|
-
_stopPollingByPollingTokenSetId(key:
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
25
|
+
_stopPollingByPollingTokenSetId(key: string): void;
|
|
26
|
+
readonly "__#3@#pollingTokenSets": Map<string, Set<string>>;
|
|
27
|
+
readonly "__#3@#callbacks": Map<string, Set<(input: PendingUserOperationPollingInput) => void>>;
|
|
26
28
|
_executePoll(input: PendingUserOperationPollingInput): Promise<void>;
|
|
27
29
|
startPolling(input: PendingUserOperationPollingInput): string;
|
|
28
30
|
stopAllPolling(): void;
|
|
@@ -46,4 +48,4 @@ export declare class PendingUserOperationTracker extends PendingUserOperationTra
|
|
|
46
48
|
_getNetworkClientById(networkClientId: string): NetworkClient | undefined;
|
|
47
49
|
}
|
|
48
50
|
export {};
|
|
49
|
-
//# sourceMappingURL=PendingUserOperationTracker.d.
|
|
51
|
+
//# sourceMappingURL=PendingUserOperationTracker.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingUserOperationTracker.d.cts","sourceRoot":"","sources":["../../src/helpers/PendingUserOperationTracker.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAEhB,qCAAqC;AAKtC,OAAO,YAAY,eAAe;AAIlC,OAAO,KAAK,EAAE,qBAAqB,EAAwB,qBAAoB;AAE/E,OAAO,KAAK,EAAE,gCAAgC,EAAE,uCAAsC;AAKtF,KAAK,MAAM,GAAG;IACZ,0BAA0B,E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<reference types="npm-which/node_modules/@types/node/events.js" />
|
|
3
|
+
import type { NetworkClient, NetworkClientId } from "@metamask/network-controller";
|
|
4
|
+
import EventEmitter from "events";
|
|
5
|
+
import type { UserOperationMetadata } from "../types.mjs";
|
|
6
|
+
import type { UserOperationControllerMessenger } from "../UserOperationController.mjs";
|
|
7
|
+
type Events = {
|
|
8
|
+
'user-operation-confirmed': [metadata: UserOperationMetadata];
|
|
9
|
+
'user-operation-failed': [txMeta: UserOperationMetadata, error: Error];
|
|
10
|
+
'user-operation-updated': [txMeta: UserOperationMetadata];
|
|
11
|
+
};
|
|
12
|
+
export type PendingUserOperationTrackerEventEmitter = EventEmitter & {
|
|
13
|
+
on<T extends keyof Events>(eventName: T, listener: (...args: Events[T]) => void): PendingUserOperationTrackerEventEmitter;
|
|
14
|
+
once<T extends keyof Events>(eventName: T, listener: (...args: Events[T]) => void): PendingUserOperationTrackerEventEmitter;
|
|
15
|
+
emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;
|
|
16
|
+
};
|
|
17
|
+
/** The input to start polling for the {@link PendingUserOperationTracker} */
|
|
18
|
+
type PendingUserOperationPollingInput = {
|
|
19
|
+
networkClientId: NetworkClientId;
|
|
20
|
+
};
|
|
21
|
+
declare const PendingUserOperationTracker_base: (abstract new (...args: any[]) => {
|
|
22
|
+
"__#21@#activeListeners": Record<string, (options: import("@metamask/utils").Json) => Promise<void>>;
|
|
23
|
+
_getNetworkClientById(networkClientId: string): NetworkClient | undefined;
|
|
24
|
+
_startPolling(input: PendingUserOperationPollingInput): void;
|
|
25
|
+
_stopPollingByPollingTokenSetId(key: string): void;
|
|
26
|
+
readonly "__#3@#pollingTokenSets": Map<string, Set<string>>;
|
|
27
|
+
readonly "__#3@#callbacks": Map<string, Set<(input: PendingUserOperationPollingInput) => void>>;
|
|
28
|
+
_executePoll(input: PendingUserOperationPollingInput): Promise<void>;
|
|
29
|
+
startPolling(input: PendingUserOperationPollingInput): string;
|
|
30
|
+
stopAllPolling(): void;
|
|
31
|
+
stopPollingByPollingToken(pollingToken: string): void;
|
|
32
|
+
onPollingComplete(input: PendingUserOperationPollingInput, callback: (input: PendingUserOperationPollingInput) => void): void;
|
|
33
|
+
}) & {
|
|
34
|
+
new (): {};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A helper class to periodically query the bundlers
|
|
38
|
+
* and update the status of any submitted user operations.
|
|
39
|
+
*/
|
|
40
|
+
export declare class PendingUserOperationTracker extends PendingUserOperationTracker_base {
|
|
41
|
+
#private;
|
|
42
|
+
hub: PendingUserOperationTrackerEventEmitter;
|
|
43
|
+
constructor({ getUserOperations, messenger, }: {
|
|
44
|
+
getUserOperations: () => UserOperationMetadata[];
|
|
45
|
+
messenger: UserOperationControllerMessenger;
|
|
46
|
+
});
|
|
47
|
+
_executePoll({ networkClientId }: PendingUserOperationPollingInput): Promise<void>;
|
|
48
|
+
_getNetworkClientById(networkClientId: string): NetworkClient | undefined;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=PendingUserOperationTracker.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingUserOperationTracker.d.mts","sourceRoot":"","sources":["../../src/helpers/PendingUserOperationTracker.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAEhB,qCAAqC;AAKtC,OAAO,YAAY,eAAe;AAIlC,OAAO,KAAK,EAAE,qBAAqB,EAAwB,qBAAoB;AAE/E,OAAO,KAAK,EAAE,gCAAgC,EAAE,uCAAsC;AAKtF,KAAK,MAAM,GAAG;IACZ,0BAA0B,EAAE,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IAC9D,uBAAuB,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACvE,wBAAwB,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG,YAAY,GAAG;IACnE,EAAE,CAAC,CAAC,SAAS,MAAM,MAAM,EACvB,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GACrC,uCAAuC,CAAC;IAE3C,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EACzB,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GACrC,uCAAuC,CAAC;IAE3C,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CACzE,CAAC;AAEF,6EAA6E;AAC7E,KAAK,gCAAgC,GAAG;IACtC,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;;;;;;;;;;;;;;;;AAEF;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,gCAAqE;;IACpH,GAAG,EAAE,uCAAuC,CAAC;gBAMjC,EACV,iBAAiB,EACjB,SAAS,GACV,EAAE;QACD,iBAAiB,EAAE,MAAM,qBAAqB,EAAE,CAAC;QACjD,SAAS,EAAE,gCAAgC,CAAC;KAC7C;IASK,YAAY,CAAC,EAAE,eAAe,EAAE,EAAE,gCAAgC;IAiBxE,qBAAqB,CAAC,eAAe,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;CAuI1E"}
|
|
@@ -10,16 +10,23 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _PendingUserOperationTracker_instances, _PendingUserOperationTracker_getUserOperations, _PendingUserOperationTracker_messenger, _PendingUserOperationTracker_checkUserOperations, _PendingUserOperationTracker_checkUserOperation, _PendingUserOperationTracker_onUserOperationConfirmed, _PendingUserOperationTracker_onUserOperationFailed, _PendingUserOperationTracker_getPendingUserOperations, _PendingUserOperationTracker_updateUserOperation, _PendingUserOperationTracker_getUserOperationReceipt, _PendingUserOperationTracker_normalizeGasValue;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
function $importDefault(module) {
|
|
14
|
+
if (module?.__esModule) {
|
|
15
|
+
return module.default;
|
|
16
|
+
}
|
|
17
|
+
return module;
|
|
18
|
+
}
|
|
19
|
+
import { query, toHex } from "@metamask/controller-utils";
|
|
20
|
+
import $EthQuery from "@metamask/eth-query";
|
|
21
|
+
const EthQuery = $importDefault($EthQuery);
|
|
22
|
+
import { createModuleLogger } from "@metamask/utils";
|
|
16
23
|
// This package purposefully relies on Node's EventEmitter module.
|
|
17
24
|
// eslint-disable-next-line import-x/no-nodejs-modules
|
|
18
|
-
import EventEmitter from
|
|
19
|
-
import { BlockTrackerPollingControllerOnly } from
|
|
20
|
-
import { projectLogger } from
|
|
21
|
-
import { UserOperationStatus } from
|
|
22
|
-
import { Bundler } from
|
|
25
|
+
import EventEmitter from "events";
|
|
26
|
+
import { BlockTrackerPollingControllerOnly } from "../BlockTrackerPollingController.mjs";
|
|
27
|
+
import { projectLogger } from "../logger.mjs";
|
|
28
|
+
import { UserOperationStatus } from "../types.mjs";
|
|
29
|
+
import { Bundler } from "./Bundler.mjs";
|
|
23
30
|
const log = createModuleLogger(projectLogger, 'pending-user-operations');
|
|
24
31
|
/**
|
|
25
32
|
* A helper class to periodically query the bundlers
|
|
@@ -117,4 +124,4 @@ _PendingUserOperationTracker_getUserOperations = new WeakMap(), _PendingUserOper
|
|
|
117
124
|
}
|
|
118
125
|
return gasValue;
|
|
119
126
|
};
|
|
120
|
-
//# sourceMappingURL=PendingUserOperationTracker.
|
|
127
|
+
//# sourceMappingURL=PendingUserOperationTracker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingUserOperationTrac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AAC;IACzB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { query, toHex } from '@metamask/controller-utils';\nimport EthQuery from '@metamask/eth-query';\nimport type {\n NetworkClient,\n NetworkClientId,\n Provider,\n} from '@metamask/network-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n// This package purposefully relies on Node's EventEmitter module.\n// eslint-disable-next-line import-x/no-nodejs-modules\nimport EventEmitter from 'events';\n\nimport { BlockTrackerPollingControllerOnly } from '../BlockTrackerPollingController.js';\nimport { projectLogger } from '../logger.js';\nimport type { UserOperationMetadata, UserOperationReceipt } from '../types.js';\nimport { UserOperationStatus } from '../types.js';\nimport type { UserOperationControllerMessenger } from '../UserOperationController.js';\nimport { Bundler } from './Bundler.js';\n\nconst log = createModuleLogger(projectLogger, 'pending-user-operations');\n\ntype Events = {\n 'user-operation-confirmed': [metadata: UserOperationMetadata];\n 'user-operation-failed': [txMeta: UserOperationMetadata, error: Error];\n 'user-operation-updated': [txMeta: UserOperationMetadata];\n};\n\nexport type PendingUserOperationTrackerEventEmitter = EventEmitter & {\n on<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): PendingUserOperationTrackerEventEmitter;\n\n once<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): PendingUserOperationTrackerEventEmitter;\n\n emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;\n};\n\n/** The input to start polling for the {@link PendingUserOperationTracker} */\ntype PendingUserOperationPollingInput = {\n networkClientId: NetworkClientId;\n};\n\n/**\n * A helper class to periodically query the bundlers\n * and update the status of any submitted user operations.\n */\nexport class PendingUserOperationTracker extends BlockTrackerPollingControllerOnly<PendingUserOperationPollingInput>() {\n hub: PendingUserOperationTrackerEventEmitter;\n\n readonly #getUserOperations: () => UserOperationMetadata[];\n\n readonly #messenger: UserOperationControllerMessenger;\n\n constructor({\n getUserOperations,\n messenger,\n }: {\n getUserOperations: () => UserOperationMetadata[];\n messenger: UserOperationControllerMessenger;\n }) {\n super();\n\n this.hub = new EventEmitter() as PendingUserOperationTrackerEventEmitter;\n\n this.#getUserOperations = getUserOperations;\n this.#messenger = messenger;\n }\n\n async _executePoll({ networkClientId }: PendingUserOperationPollingInput) {\n try {\n const { blockTracker, configuration, provider } =\n this._getNetworkClientById(networkClientId) as NetworkClient;\n\n log('Polling', {\n blockNumber: blockTracker.getCurrentBlock(),\n chainId: configuration.chainId,\n });\n\n await this.#checkUserOperations(configuration.chainId, provider);\n } catch (error) {\n /* istanbul ignore next */\n log('Failed to check user operations', error);\n }\n }\n\n _getNetworkClientById(networkClientId: string): NetworkClient | undefined {\n return this.#messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n }\n\n async #checkUserOperations(chainId: string, provider: Provider) {\n const pendingUserOperations = this.#getPendingUserOperations().filter(\n (metadata) => metadata.chainId === chainId,\n );\n\n if (!pendingUserOperations.length) {\n log('No pending user operations to check');\n return;\n }\n\n log('Found pending user operations to check', {\n count: pendingUserOperations.length,\n ids: pendingUserOperations.map((userOperation) => userOperation.id),\n });\n\n await Promise.all(\n pendingUserOperations.map((userOperation) =>\n this.#checkUserOperation(userOperation, provider),\n ),\n );\n }\n\n async #checkUserOperation(\n metadata: UserOperationMetadata,\n provider: Provider,\n ) {\n const { bundlerUrl, hash, id } = metadata;\n\n if (!hash || !bundlerUrl) {\n log('Skipping user operation as missing hash or bundler', id);\n return;\n }\n\n try {\n const receipt = await this.#getUserOperationReceipt(hash, bundlerUrl);\n const isSuccess = receipt?.success;\n\n if (receipt && !isSuccess) {\n this.#onUserOperationFailed(metadata, receipt);\n return;\n }\n\n if (isSuccess) {\n await this.#onUserOperationConfirmed(metadata, receipt, provider);\n return;\n }\n\n log('No receipt found for user operation', { id, hash });\n } catch (error) {\n log('Failed to check user operation', id, error);\n }\n }\n\n async #onUserOperationConfirmed(\n metadata: UserOperationMetadata,\n receipt: UserOperationReceipt,\n provider: Provider,\n ) {\n const { id } = metadata;\n\n const {\n actualGasCost,\n actualGasUsed,\n receipt: { blockHash, transactionHash },\n } = receipt;\n\n log('User operation confirmed', id, transactionHash);\n\n const { baseFeePerGas } = await query(\n new EthQuery(provider),\n 'getBlockByHash',\n [blockHash, false],\n );\n\n metadata.actualGasCost = this.#normalizeGasValue(actualGasCost);\n metadata.actualGasUsed = this.#normalizeGasValue(actualGasUsed);\n metadata.baseFeePerGas = baseFeePerGas;\n metadata.status = UserOperationStatus.Confirmed;\n metadata.transactionHash = transactionHash;\n\n this.#updateUserOperation(metadata);\n\n this.hub.emit('user-operation-confirmed', metadata);\n }\n\n #onUserOperationFailed(\n metadata: UserOperationMetadata,\n _receipt: UserOperationReceipt,\n ) {\n const { id } = metadata;\n\n log('User operation failed', id);\n\n metadata.status = UserOperationStatus.Failed;\n\n this.#updateUserOperation(metadata);\n\n this.hub.emit(\n 'user-operation-failed',\n metadata,\n new Error('User operation receipt has failed status'),\n );\n }\n\n #getPendingUserOperations(): UserOperationMetadata[] {\n return this.#getUserOperations().filter(\n (userOperation) => userOperation.status === UserOperationStatus.Submitted,\n );\n }\n\n #updateUserOperation(metadata: UserOperationMetadata) {\n this.hub.emit('user-operation-updated', metadata);\n }\n\n async #getUserOperationReceipt(\n hash: string,\n bundlerUrl: string,\n ): Promise<UserOperationReceipt | undefined> {\n const bundler = new Bundler(bundlerUrl);\n return bundler.getUserOperationReceipt(hash);\n }\n\n #normalizeGasValue(gasValue: Hex | number): string {\n if (typeof gasValue === 'number') {\n return toHex(gasValue);\n }\n return gasValue;\n }\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _SnapSmartContractAccount_messenger;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SnapSmartContractAccount = void 0;
|
|
16
|
+
const constants_js_1 = require("../constants.cjs");
|
|
17
|
+
const chain_id_js_1 = require("../utils/chain-id.cjs");
|
|
18
|
+
class SnapSmartContractAccount {
|
|
19
|
+
constructor(messenger) {
|
|
20
|
+
_SnapSmartContractAccount_messenger.set(this, void 0);
|
|
21
|
+
__classPrivateFieldSet(this, _SnapSmartContractAccount_messenger, messenger, "f");
|
|
22
|
+
}
|
|
23
|
+
async prepareUserOperation(request) {
|
|
24
|
+
const { chainId, data: requestData, from: sender, to: requestTo, value: requestValue, } = request;
|
|
25
|
+
const data = requestData ?? constants_js_1.EMPTY_BYTES;
|
|
26
|
+
const to = requestTo ?? constants_js_1.ADDRESS_ZERO;
|
|
27
|
+
const value = requestValue ?? constants_js_1.VALUE_ZERO;
|
|
28
|
+
const response = await __classPrivateFieldGet(this, _SnapSmartContractAccount_messenger, "f").call('KeyringController:prepareUserOperation', sender, [{ data, to, value }], { chainId: (0, chain_id_js_1.toEip155ChainId)(chainId) });
|
|
29
|
+
const { bundlerUrl: bundler, callData, dummyPaymasterAndData, dummySignature, gasLimits: gas, initCode, nonce, } = response;
|
|
30
|
+
return {
|
|
31
|
+
bundler,
|
|
32
|
+
callData,
|
|
33
|
+
dummyPaymasterAndData,
|
|
34
|
+
dummySignature,
|
|
35
|
+
gas,
|
|
36
|
+
initCode,
|
|
37
|
+
nonce,
|
|
38
|
+
sender,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async updateUserOperation(request) {
|
|
42
|
+
const { userOperation, chainId } = request;
|
|
43
|
+
const { sender } = userOperation;
|
|
44
|
+
const { paymasterAndData: responsePaymasterAndData, verificationGasLimit, preVerificationGas, callGasLimit, } = await __classPrivateFieldGet(this, _SnapSmartContractAccount_messenger, "f").call('KeyringController:patchUserOperation', sender, userOperation, { chainId: (0, chain_id_js_1.toEip155ChainId)(chainId) });
|
|
45
|
+
const paymasterAndData = responsePaymasterAndData === constants_js_1.EMPTY_BYTES
|
|
46
|
+
? undefined
|
|
47
|
+
: responsePaymasterAndData;
|
|
48
|
+
return {
|
|
49
|
+
paymasterAndData,
|
|
50
|
+
verificationGasLimit,
|
|
51
|
+
preVerificationGas,
|
|
52
|
+
callGasLimit,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async signUserOperation(request) {
|
|
56
|
+
const { userOperation, chainId } = request;
|
|
57
|
+
const { sender } = userOperation;
|
|
58
|
+
const signature = await __classPrivateFieldGet(this, _SnapSmartContractAccount_messenger, "f").call('KeyringController:signUserOperation', sender, userOperation, { chainId: (0, chain_id_js_1.toEip155ChainId)(chainId) });
|
|
59
|
+
return { signature };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.SnapSmartContractAccount = SnapSmartContractAccount;
|
|
63
|
+
_SnapSmartContractAccount_messenger = new WeakMap();
|
|
64
|
+
//# sourceMappingURL=SnapSmartContractAccount.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapSmartContractAccount.cjs","sourceRoot":"","sources":["../../src/helpers/SnapSmartContractAccount.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAwE;AAWxE,uD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CAC5B,sCAAsC,EACtC,MAAM,EACN,aAAa,EACb,EAAE,OAAO,EAAE,IAAA,6BAAe,EAAC,OAAO,CAAC,EAAE,CACtC,CAAC;QAEF,MAAM,gBAAgB,GACpB,wBAAwB,KAAK,0BAAW;YACtC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,wBAAwB,CAAC;QAE/B,OAAO;YACL,gBAAgB;YAChB,oBAAoB;YACpB,kBAAkB;YAClB,YAAY;SACb,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,OAAiC;QAEjC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;QAEjC,MAAM,SAAS,GAAG,MAAM,uBAAA,IAAI,2CAAW,CAAC,IAAI,CAC1C,qCAAqC,EACrC,MAAM,EACN,aAAa,EACb,EAAE,OAAO,EAAE,IAAA,6BAAe,EAAC,OAAO,CAAC,EAAE,CACtC,CAAC;QAEF,OAAO,EAAE,SAAS,EAAE,CAAC;IACvB,CAAC;CACF;AAjGD,4DAiGC","sourcesContent":["import { ADDRESS_ZERO, EMPTY_BYTES, VALUE_ZERO } from '../constants.js';\nimport type {\n PrepareUserOperationRequest,\n PrepareUserOperationResponse,\n SignUserOperationRequest,\n SignUserOperationResponse,\n SmartContractAccount,\n UpdateUserOperationRequest,\n UpdateUserOperationResponse,\n} from '../types.js';\nimport type { UserOperationControllerMessenger } from '../UserOperationController.js';\nimport { toEip155ChainId } from '../utils/chain-id.js';\n\nexport class SnapSmartContractAccount implements SmartContractAccount {\n readonly #messenger: UserOperationControllerMessenger;\n\n constructor(messenger: UserOperationControllerMessenger) {\n this.#messenger = messenger;\n }\n\n async prepareUserOperation(\n request: PrepareUserOperationRequest,\n ): Promise<PrepareUserOperationResponse> {\n const {\n chainId,\n data: requestData,\n from: sender,\n to: requestTo,\n value: requestValue,\n } = request;\n\n const data = requestData ?? EMPTY_BYTES;\n const to = requestTo ?? ADDRESS_ZERO;\n const value = requestValue ?? VALUE_ZERO;\n\n const response = await this.#messenger.call(\n 'KeyringController:prepareUserOperation',\n sender,\n [{ data, to, value }],\n { chainId: toEip155ChainId(chainId) },\n );\n\n const {\n bundlerUrl: bundler,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n gasLimits: gas,\n initCode,\n nonce,\n } = response;\n\n return {\n bundler,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n gas,\n initCode,\n nonce,\n sender,\n };\n }\n\n async updateUserOperation(\n request: UpdateUserOperationRequest,\n ): Promise<UpdateUserOperationResponse> {\n const { userOperation, chainId } = request;\n const { sender } = userOperation;\n\n const {\n paymasterAndData: responsePaymasterAndData,\n verificationGasLimit,\n preVerificationGas,\n callGasLimit,\n } = await this.#messenger.call(\n 'KeyringController:patchUserOperation',\n sender,\n userOperation,\n { chainId: toEip155ChainId(chainId) },\n );\n\n const paymasterAndData =\n responsePaymasterAndData === EMPTY_BYTES\n ? undefined\n : responsePaymasterAndData;\n\n return {\n paymasterAndData,\n verificationGasLimit,\n preVerificationGas,\n callGasLimit,\n };\n }\n\n async signUserOperation(\n request: SignUserOperationRequest,\n ): Promise<SignUserOperationResponse> {\n const { userOperation, chainId } = request;\n const { sender } = userOperation;\n\n const signature = await this.#messenger.call(\n 'KeyringController:signUserOperation',\n sender,\n userOperation,\n { chainId: toEip155ChainId(chainId) },\n );\n\n return { signature };\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PrepareUserOperationRequest, PrepareUserOperationResponse, SignUserOperationRequest, SignUserOperationResponse, SmartContractAccount, UpdateUserOperationRequest, UpdateUserOperationResponse } from
|
|
2
|
-
import type { UserOperationControllerMessenger } from
|
|
1
|
+
import type { PrepareUserOperationRequest, PrepareUserOperationResponse, SignUserOperationRequest, SignUserOperationResponse, SmartContractAccount, UpdateUserOperationRequest, UpdateUserOperationResponse } from "../types.cjs";
|
|
2
|
+
import type { UserOperationControllerMessenger } from "../UserOperationController.cjs";
|
|
3
3
|
export declare class SnapSmartContractAccount implements SmartContractAccount {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(messenger: UserOperationControllerMessenger);
|
|
@@ -7,4 +7,4 @@ export declare class SnapSmartContractAccount implements SmartContractAccount {
|
|
|
7
7
|
updateUserOperation(request: UpdateUserOperationRequest): Promise<UpdateUserOperationResponse>;
|
|
8
8
|
signUserOperation(request: SignUserOperationRequest): Promise<SignUserOperationResponse>;
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=SnapSmartContractAccount.d.
|
|
10
|
+
//# sourceMappingURL=SnapSmartContractAccount.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapSmartContractAccount.d.cts","sourceRoot":"","sources":["../../src/helpers/SnapSmartContractAccount.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC5B,qBAAoB;AACrB,OAAO,KAAK,EAAE,gCAAgC,EAAE,uCAAsC;AAGtF,qBAAa,wBAAyB,YAAW,oBAAoB;;gBAGvD,SAAS,EAAE,gCAAgC;IAIjD,oBAAoB,CACxB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,4BAA4B,CAAC;IA0ClC,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,2BAA2B,CAAC;IA6BjC,iBAAiB,CACrB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC;CAatC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PrepareUserOperationRequest, PrepareUserOperationResponse, SignUserOperationRequest, SignUserOperationResponse, SmartContractAccount, UpdateUserOperationRequest, UpdateUserOperationResponse } from "../types.mjs";
|
|
2
|
+
import type { UserOperationControllerMessenger } from "../UserOperationController.mjs";
|
|
3
|
+
export declare class SnapSmartContractAccount implements SmartContractAccount {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(messenger: UserOperationControllerMessenger);
|
|
6
|
+
prepareUserOperation(request: PrepareUserOperationRequest): Promise<PrepareUserOperationResponse>;
|
|
7
|
+
updateUserOperation(request: UpdateUserOperationRequest): Promise<UpdateUserOperationResponse>;
|
|
8
|
+
signUserOperation(request: SignUserOperationRequest): Promise<SignUserOperationResponse>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=SnapSmartContractAccount.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapSmartContractAccount.d.mts","sourceRoot":"","sources":["../../src/helpers/SnapSmartContractAccount.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC5B,qBAAoB;AACrB,OAAO,KAAK,EAAE,gCAAgC,EAAE,uCAAsC;AAGtF,qBAAa,wBAAyB,YAAW,oBAAoB;;gBAGvD,SAAS,EAAE,gCAAgC;IAIjD,oBAAoB,CACxB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,4BAA4B,CAAC;IA0ClC,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,2BAA2B,CAAC;IA6BjC,iBAAiB,CACrB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC;CAatC"}
|
|
@@ -10,8 +10,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _SnapSmartContractAccount_messenger;
|
|
13
|
-
import { ADDRESS_ZERO, EMPTY_BYTES, VALUE_ZERO } from
|
|
14
|
-
import { toEip155ChainId } from
|
|
13
|
+
import { ADDRESS_ZERO, EMPTY_BYTES, VALUE_ZERO } from "../constants.mjs";
|
|
14
|
+
import { toEip155ChainId } from "../utils/chain-id.mjs";
|
|
15
15
|
export class SnapSmartContractAccount {
|
|
16
16
|
constructor(messenger) {
|
|
17
17
|
_SnapSmartContractAccount_messenger.set(this, void 0);
|
|
@@ -57,4 +57,4 @@ export class SnapSmartContractAccount {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
_SnapSmartContractAccount_messenger = new WeakMap();
|
|
60
|
-
//# sourceMappingURL=SnapSmartContractAccount.
|
|
60
|
+
//# sourceMappingURL=SnapSmartContractAccount.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapSmartContractAccount.mjs","sourceRoot":"","sources":["../../src/helpers/SnapSmartContractAccount.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,yBAAwB;AAWxE,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAEvD,MAAM,OAAO,wBAAwB;IAGnC,YAAY,SAA2C;QAF9C,sDAA6C;QAGpD,uBAAA,IAAI,uCAAc,SAAS,MAAA,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,OAAoC;QAEpC,MAAM,EACJ,OAAO,EACP,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,YAAY,GACpB,GAAG,OAAO,CAAC;QAEZ,MAAM,IAAI,GAAG,WAAW,IAAI,WAAW,CAAC;QACxC,MAAM,EAAE,GAAG,SAAS,IAAI,YAAY,CAAC;QACrC,MAAM,KAAK,GAAG,YAAY,IAAI,UAAU,CAAC;QAEzC,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,2CAAW,CAAC,IAAI,CACzC,wCAAwC,EACxC,MAAM,EACN,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,E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QAEF,OAAO,EAAE,SAAS,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { ADDRESS_ZERO, EMPTY_BYTES, VALUE_ZERO } from '../constants.js';\nimport type {\n PrepareUserOperationRequest,\n PrepareUserOperationResponse,\n SignUserOperationRequest,\n SignUserOperationResponse,\n SmartContractAccount,\n UpdateUserOperationRequest,\n UpdateUserOperationResponse,\n} from '../types.js';\nimport type { UserOperationControllerMessenger } from '../UserOperationController.js';\nimport { toEip155ChainId } from '../utils/chain-id.js';\n\nexport class SnapSmartContractAccount implements SmartContractAccount {\n readonly #messenger: UserOperationControllerMessenger;\n\n constructor(messenger: UserOperationControllerMessenger) {\n this.#messenger = messenger;\n }\n\n async prepareUserOperation(\n request: PrepareUserOperationRequest,\n ): Promise<PrepareUserOperationResponse> {\n const {\n chainId,\n data: requestData,\n from: sender,\n to: requestTo,\n value: requestValue,\n } = request;\n\n const data = requestData ?? EMPTY_BYTES;\n const to = requestTo ?? ADDRESS_ZERO;\n const value = requestValue ?? VALUE_ZERO;\n\n const response = await this.#messenger.call(\n 'KeyringController:prepareUserOperation',\n sender,\n [{ data, to, value }],\n { chainId: toEip155ChainId(chainId) },\n );\n\n const {\n bundlerUrl: bundler,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n gasLimits: gas,\n initCode,\n nonce,\n } = response;\n\n return {\n bundler,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n gas,\n initCode,\n nonce,\n sender,\n };\n }\n\n async updateUserOperation(\n request: UpdateUserOperationRequest,\n ): Promise<UpdateUserOperationResponse> {\n const { userOperation, chainId } = request;\n const { sender } = userOperation;\n\n const {\n paymasterAndData: responsePaymasterAndData,\n verificationGasLimit,\n preVerificationGas,\n callGasLimit,\n } = await this.#messenger.call(\n 'KeyringController:patchUserOperation',\n sender,\n userOperation,\n { chainId: toEip155ChainId(chainId) },\n );\n\n const paymasterAndData =\n responsePaymasterAndData === EMPTY_BYTES\n ? undefined\n : responsePaymasterAndData;\n\n return {\n paymasterAndData,\n verificationGasLimit,\n preVerificationGas,\n callGasLimit,\n };\n }\n\n async signUserOperation(\n request: SignUserOperationRequest,\n ): Promise<SignUserOperationResponse> {\n const { userOperation, chainId } = request;\n const { sender } = userOperation;\n\n const signature = await this.#messenger.call(\n 'KeyringController:signUserOperation',\n sender,\n userOperation,\n { chainId: toEip155ChainId(chainId) },\n );\n\n return { signature };\n }\n}\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./UserOperationController.cjs"), exports);
|
|
18
|
+
__exportStar(require("./types.cjs"), exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA6C;AAM7C,8CAA2B","sourcesContent":["export * from './UserOperationController.js';\nexport type {\n UserOperationControllerAddUserOperationAction,\n UserOperationControllerAddUserOperationFromTransactionAction,\n UserOperationControllerStartPollingByNetworkClientIdAction,\n} from './UserOperationController-method-action-types.js';\nexport * from './types.js';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./UserOperationController.cjs";
|
|
2
|
+
export type { UserOperationControllerAddUserOperationAction, UserOperationControllerAddUserOperationFromTransactionAction, UserOperationControllerStartPollingByNetworkClientIdAction, } from "./UserOperationController-method-action-types.cjs";
|
|
3
|
+
export * from "./types.cjs";
|
|
4
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA6C;AAC7C,YAAY,EACV,6CAA6C,EAC7C,4DAA4D,EAC5D,0DAA0D,GAC3D,0DAAyD;AAC1D,4BAA2B"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./UserOperationController.mjs";
|
|
2
|
+
export type { UserOperationControllerAddUserOperationAction, UserOperationControllerAddUserOperationFromTransactionAction, UserOperationControllerStartPollingByNetworkClientIdAction, } from "./UserOperationController-method-action-types.mjs";
|
|
3
|
+
export * from "./types.mjs";
|
|
4
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA6C;AAC7C,YAAY,EACV,6CAA6C,EAC7C,4DAA4D,EAC5D,0DAA0D,GAC3D,0DAAyD;AAC1D,4BAA2B"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA6C;AAM7C,4BAA2B","sourcesContent":["export * from './UserOperationController.js';\nexport type {\n UserOperationControllerAddUserOperationAction,\n UserOperationControllerAddUserOperationFromTransactionAction,\n UserOperationControllerStartPollingByNetworkClientIdAction,\n} from './UserOperationController-method-action-types.js';\nexport * from './types.js';\n"]}
|
package/dist/logger.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createModuleLogger = exports.projectLogger = void 0;
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
Object.defineProperty(exports, "createModuleLogger", { enumerable: true, get: function () { return utils_1.createModuleLogger; } });
|
|
7
|
+
exports.projectLogger = (0, utils_1.createProjectLogger)('user-operation-controller');
|
|
8
|
+
//# sourceMappingURL=logger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.cjs","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;AAE1B,2CAA0E;AAIjE,mGAJqB,0BAAkB,OAIrB;AAFd,QAAA,aAAa,GAAG,IAAA,2BAAmB,EAAC,2BAA2B,CAAC,CAAC","sourcesContent":["/* istanbul ignore file */\n\nimport { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('user-operation-controller');\n\nexport { createModuleLogger };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.cts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAEA,OAAO,EAAuB,kBAAkB,EAAE,wBAAwB;AAE1E,eAAO,MAAM,aAAa,0BAAmD,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.mts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAEA,OAAO,EAAuB,kBAAkB,EAAE,wBAAwB;AAE1E,eAAO,MAAM,aAAa,0BAAmD,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
|
-
import { createProjectLogger, createModuleLogger } from
|
|
2
|
+
import { createProjectLogger, createModuleLogger } from "@metamask/utils";
|
|
3
3
|
export const projectLogger = createProjectLogger('user-operation-controller');
|
|
4
4
|
export { createModuleLogger };
|
|
5
|
-
//# sourceMappingURL=logger.
|
|
5
|
+
//# sourceMappingURL=logger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.mjs","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,wBAAwB;AAE1E,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC,2BAA2B,CAAC,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/* istanbul ignore file */\n\nimport { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('user-operation-controller');\n\nexport { createModuleLogger };\n"]}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserOperationStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The possible statuses of a single user operation.
|
|
6
|
+
*/
|
|
7
|
+
var UserOperationStatus;
|
|
8
|
+
(function (UserOperationStatus) {
|
|
9
|
+
UserOperationStatus["Unapproved"] = "unapproved";
|
|
10
|
+
UserOperationStatus["Approved"] = "approved";
|
|
11
|
+
UserOperationStatus["Signed"] = "signed";
|
|
12
|
+
UserOperationStatus["Submitted"] = "submitted";
|
|
13
|
+
UserOperationStatus["Failed"] = "failed";
|
|
14
|
+
UserOperationStatus["Confirmed"] = "confirmed";
|
|
15
|
+
})(UserOperationStatus || (exports.UserOperationStatus = UserOperationStatus = {}));
|
|
16
|
+
//# sourceMappingURL=types.cjs.map
|