@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,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateSignUserOperationResponse = exports.validateUpdateUserOperationResponse = exports.validatePrepareUserOperationResponse = exports.validateAddUserOperationOptions = exports.validateAddUserOperationRequest = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
6
|
+
const utils_1 = require("@metamask/utils");
|
|
7
|
+
const constants_js_1 = require("../constants.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* Validate a request to add a user operation.
|
|
10
|
+
*
|
|
11
|
+
* @param request - The request to validate.
|
|
12
|
+
*/
|
|
13
|
+
function validateAddUserOperationRequest(request) {
|
|
14
|
+
const Hex = defineHex();
|
|
15
|
+
const HexOrEmptyBytes = defineHexOrEmptyBytes();
|
|
16
|
+
const ValidRequest = (0, superstruct_1.object)({
|
|
17
|
+
data: (0, superstruct_1.optional)(HexOrEmptyBytes),
|
|
18
|
+
from: Hex,
|
|
19
|
+
maxFeePerGas: (0, superstruct_1.optional)(Hex),
|
|
20
|
+
maxPriorityFeePerGas: (0, superstruct_1.optional)(Hex),
|
|
21
|
+
to: (0, superstruct_1.optional)(Hex),
|
|
22
|
+
value: (0, superstruct_1.optional)(Hex),
|
|
23
|
+
});
|
|
24
|
+
validate(request, ValidRequest, 'Invalid request to add user operation');
|
|
25
|
+
}
|
|
26
|
+
exports.validateAddUserOperationRequest = validateAddUserOperationRequest;
|
|
27
|
+
/**
|
|
28
|
+
* Validate the options when adding a user operation.
|
|
29
|
+
*
|
|
30
|
+
* @param options - The options to validate.
|
|
31
|
+
*/
|
|
32
|
+
function validateAddUserOperationOptions(options) {
|
|
33
|
+
const ValidOptions = (0, superstruct_1.object)({
|
|
34
|
+
networkClientId: (0, superstruct_1.string)(),
|
|
35
|
+
origin: (0, superstruct_1.string)(),
|
|
36
|
+
requireApproval: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
37
|
+
smartContractAccount: (0, superstruct_1.optional)((0, superstruct_1.object)({
|
|
38
|
+
prepareUserOperation: (0, superstruct_1.func)(),
|
|
39
|
+
updateUserOperation: (0, superstruct_1.func)(),
|
|
40
|
+
signUserOperation: (0, superstruct_1.func)(),
|
|
41
|
+
})),
|
|
42
|
+
swaps: (0, superstruct_1.optional)((0, superstruct_1.object)({
|
|
43
|
+
approvalTxId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
44
|
+
destinationTokenAddress: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
45
|
+
destinationTokenDecimals: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
46
|
+
destinationTokenSymbol: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
47
|
+
estimatedBaseFee: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
48
|
+
sourceTokenSymbol: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
49
|
+
swapMetaData: (0, superstruct_1.optional)((0, superstruct_1.object)()),
|
|
50
|
+
swapTokenValue: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
51
|
+
destinationTokenAmount: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
52
|
+
sourceTokenAddress: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
53
|
+
sourceTokenAmount: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
54
|
+
sourceTokenDecimals: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
55
|
+
swapAndSendRecipient: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
56
|
+
})),
|
|
57
|
+
type: (0, superstruct_1.optional)((0, superstruct_1.enums)(Object.values(transaction_controller_1.TransactionType))),
|
|
58
|
+
});
|
|
59
|
+
validate(options, ValidOptions, 'Invalid options to add user operation');
|
|
60
|
+
}
|
|
61
|
+
exports.validateAddUserOperationOptions = validateAddUserOperationOptions;
|
|
62
|
+
/**
|
|
63
|
+
* Validate the response from a smart contract account when preparing the user operation.
|
|
64
|
+
*
|
|
65
|
+
* @param response - The response to validate.
|
|
66
|
+
*/
|
|
67
|
+
function validatePrepareUserOperationResponse(response) {
|
|
68
|
+
const Hex = defineHex();
|
|
69
|
+
const HexOrEmptyBytes = defineHexOrEmptyBytes();
|
|
70
|
+
const ValidResponse = (0, superstruct_1.refine)((0, superstruct_1.object)({
|
|
71
|
+
bundler: (0, superstruct_1.string)(),
|
|
72
|
+
callData: Hex,
|
|
73
|
+
dummyPaymasterAndData: (0, superstruct_1.optional)(HexOrEmptyBytes),
|
|
74
|
+
dummySignature: (0, superstruct_1.optional)(HexOrEmptyBytes),
|
|
75
|
+
gas: (0, superstruct_1.optional)((0, superstruct_1.object)({
|
|
76
|
+
callGasLimit: Hex,
|
|
77
|
+
preVerificationGas: Hex,
|
|
78
|
+
verificationGasLimit: Hex,
|
|
79
|
+
})),
|
|
80
|
+
initCode: (0, superstruct_1.optional)(HexOrEmptyBytes),
|
|
81
|
+
nonce: Hex,
|
|
82
|
+
sender: Hex,
|
|
83
|
+
}), 'ValidPrepareUserOperationResponse', ({ gas, dummySignature }) => {
|
|
84
|
+
if (!gas && (!dummySignature || dummySignature === constants_js_1.EMPTY_BYTES)) {
|
|
85
|
+
return 'Must specify dummySignature if not specifying gas';
|
|
86
|
+
}
|
|
87
|
+
/* istanbul ignore next */
|
|
88
|
+
return true;
|
|
89
|
+
});
|
|
90
|
+
validate(response, ValidResponse, 'Invalid response when preparing user operation');
|
|
91
|
+
}
|
|
92
|
+
exports.validatePrepareUserOperationResponse = validatePrepareUserOperationResponse;
|
|
93
|
+
/**
|
|
94
|
+
* Validate the response from a smart contract account when updating the user operation.
|
|
95
|
+
*
|
|
96
|
+
* @param response - The response to validate.
|
|
97
|
+
*/
|
|
98
|
+
function validateUpdateUserOperationResponse(response) {
|
|
99
|
+
const ValidResponse = (0, superstruct_1.optional)((0, superstruct_1.object)({
|
|
100
|
+
paymasterAndData: (0, superstruct_1.optional)(defineHexOrEmptyBytes()),
|
|
101
|
+
callGasLimit: (0, superstruct_1.optional)(defineHexOrEmptyBytes()),
|
|
102
|
+
preVerificationGas: (0, superstruct_1.optional)(defineHexOrEmptyBytes()),
|
|
103
|
+
verificationGasLimit: (0, superstruct_1.optional)(defineHexOrEmptyBytes()),
|
|
104
|
+
}));
|
|
105
|
+
validate(response, ValidResponse, 'Invalid response when updating user operation');
|
|
106
|
+
}
|
|
107
|
+
exports.validateUpdateUserOperationResponse = validateUpdateUserOperationResponse;
|
|
108
|
+
/**
|
|
109
|
+
* Validate the response from a smart contract account when signing the user operation.
|
|
110
|
+
*
|
|
111
|
+
* @param response - The response to validate.
|
|
112
|
+
*/
|
|
113
|
+
function validateSignUserOperationResponse(response) {
|
|
114
|
+
const Hex = defineHex();
|
|
115
|
+
const ValidResponse = (0, superstruct_1.object)({
|
|
116
|
+
signature: Hex,
|
|
117
|
+
});
|
|
118
|
+
validate(response, ValidResponse, 'Invalid response when signing user operation');
|
|
119
|
+
}
|
|
120
|
+
exports.validateSignUserOperationResponse = validateSignUserOperationResponse;
|
|
121
|
+
/**
|
|
122
|
+
* Validate data against a struct.
|
|
123
|
+
*
|
|
124
|
+
* @param data - The data to validate.
|
|
125
|
+
* @param struct - The struct to validate against.
|
|
126
|
+
* @param message - The message to throw if validation fails.
|
|
127
|
+
*/
|
|
128
|
+
function validate(data, struct, message) {
|
|
129
|
+
try {
|
|
130
|
+
(0, superstruct_1.assert)(data, struct, message);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
const causes = error
|
|
134
|
+
.failures()
|
|
135
|
+
.map((failure) => {
|
|
136
|
+
if (!failure.path.length) {
|
|
137
|
+
return failure.message;
|
|
138
|
+
}
|
|
139
|
+
return `${failure.path.join('.')} - ${failure.message}`;
|
|
140
|
+
})
|
|
141
|
+
.join('\n');
|
|
142
|
+
const finalMessage = `${message}\n${causes}`;
|
|
143
|
+
throw new Error(finalMessage);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Define the Hex type used by superstruct.
|
|
148
|
+
*
|
|
149
|
+
* @returns The Hex superstruct type.
|
|
150
|
+
*/
|
|
151
|
+
function defineHex() {
|
|
152
|
+
return (0, superstruct_1.define)('Hexadecimal String', (value) => (0, utils_1.isStrictHexString)(value));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Define the HexOrEmptyBytes type used by superstruct.
|
|
156
|
+
*
|
|
157
|
+
* @returns The HexOrEmptyBytes superstruct type.
|
|
158
|
+
*/
|
|
159
|
+
function defineHexOrEmptyBytes() {
|
|
160
|
+
return (0, superstruct_1.define)('Hexadecimal String or 0x', (value) => (0, utils_1.isStrictHexString)(value) || value === constants_js_1.EMPTY_BYTES);
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=validation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.cjs","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":";;;AACA,uDAW+B;AAC/B,6EAAmE;AACnE,2CAAoD;AAEpD,mDAA8C;AAW9C;;;;GAIG;AACH,SAAgB,+BAA+B,CAC7C,OAAgC;IAEhC,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,eAAe,GAAG,qBAAqB,EAAE,CAAC;IAEhD,MAAM,YAAY,GAAG,IAAA,oBAAM,EAAC;QAC1B,IAAI,EAAE,IAAA,sBAAQ,EAAC,eAAe,CAAC;QAC/B,IAAI,EAAE,GAAG;QACT,YAAY,EAAE,IAAA,sBAAQ,EAAC,GAAG,CAAC;QAC3B,oBAAoB,EAAE,IAAA,sBAAQ,EAAC,GAAG,CAAC;QACnC,EAAE,EAAE,IAAA,sBAAQ,EAAC,GAAG,CAA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;aACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACzB,OAAO,OAAO,CAAC,OAAO,CAAC;YACzB,CAAC;YAED,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1D,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,MAAM,YAAY,GAAG,GAAG,OAAO,KAAK,MAAM,EAAE,CAAC;QAE7C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS;IAChB,OAAO,IAAA,oBAAM,EAAS,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CACpD,IAAA,yBAAiB,EAAC,KAAK,CAAC,CACzB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB;IAC5B,OAAO,IAAA,oBAAM,EACX,0BAA0B,EAC1B,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,yBAAiB,EAAC,KAAK,CAAC,IAAI,KAAK,KAAK,0BAAW,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import type { Struct, StructError } from '@metamask/superstruct';\nimport {\n assert,\n boolean,\n define,\n enums,\n func,\n number,\n object,\n optional,\n refine,\n string,\n} from '@metamask/superstruct';\nimport { TransactionType } from '@metamask/transaction-controller';\nimport { isStrictHexString } from '@metamask/utils';\n\nimport { EMPTY_BYTES } from '../constants.js';\nimport type {\n PrepareUserOperationResponse,\n SignUserOperationResponse,\n UpdateUserOperationResponse,\n} from '../types.js';\nimport type {\n AddUserOperationOptions,\n AddUserOperationRequest,\n} from '../UserOperationController.js';\n\n/**\n * Validate a request to add a user operation.\n *\n * @param request - The request to validate.\n */\nexport function validateAddUserOperationRequest(\n request: AddUserOperationRequest,\n) {\n const Hex = defineHex();\n const HexOrEmptyBytes = defineHexOrEmptyBytes();\n\n const ValidRequest = object({\n data: optional(HexOrEmptyBytes),\n from: Hex,\n maxFeePerGas: optional(Hex),\n maxPriorityFeePerGas: optional(Hex),\n to: optional(Hex),\n value: optional(Hex),\n });\n\n validate(request, ValidRequest, 'Invalid request to add user operation');\n}\n\n/**\n * Validate the options when adding a user operation.\n *\n * @param options - The options to validate.\n */\nexport function validateAddUserOperationOptions(\n options: AddUserOperationOptions,\n) {\n const ValidOptions = object({\n networkClientId: string(),\n origin: string(),\n requireApproval: optional(boolean()),\n smartContractAccount: optional(\n object({\n prepareUserOperation: func(),\n updateUserOperation: func(),\n signUserOperation: func(),\n }),\n ),\n swaps: optional(\n object({\n approvalTxId: optional(string()),\n destinationTokenAddress: optional(string()),\n destinationTokenDecimals: optional(number()),\n destinationTokenSymbol: optional(string()),\n estimatedBaseFee: optional(string()),\n sourceTokenSymbol: optional(string()),\n swapMetaData: optional(object()),\n swapTokenValue: optional(string()),\n destinationTokenAmount: optional(string()),\n sourceTokenAddress: optional(string()),\n sourceTokenAmount: optional(string()),\n sourceTokenDecimals: optional(number()),\n swapAndSendRecipient: optional(string()),\n }),\n ),\n type: optional(enums(Object.values(TransactionType))),\n });\n\n validate(options, ValidOptions, 'Invalid options to add user operation');\n}\n\n/**\n * Validate the response from a smart contract account when preparing the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validatePrepareUserOperationResponse(\n response: PrepareUserOperationResponse,\n) {\n const Hex = defineHex();\n const HexOrEmptyBytes = defineHexOrEmptyBytes();\n\n const ValidResponse = refine(\n object({\n bundler: string(),\n callData: Hex,\n dummyPaymasterAndData: optional(HexOrEmptyBytes),\n dummySignature: optional(HexOrEmptyBytes),\n gas: optional(\n object({\n callGasLimit: Hex,\n preVerificationGas: Hex,\n verificationGasLimit: Hex,\n }),\n ),\n initCode: optional(HexOrEmptyBytes),\n nonce: Hex,\n sender: Hex,\n }),\n 'ValidPrepareUserOperationResponse',\n ({ gas, dummySignature }) => {\n if (!gas && (!dummySignature || dummySignature === EMPTY_BYTES)) {\n return 'Must specify dummySignature if not specifying gas';\n }\n\n /* istanbul ignore next */\n return true;\n },\n );\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when preparing user operation',\n );\n}\n\n/**\n * Validate the response from a smart contract account when updating the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validateUpdateUserOperationResponse(\n response: UpdateUserOperationResponse,\n) {\n const ValidResponse = optional(\n object({\n paymasterAndData: optional(defineHexOrEmptyBytes()),\n callGasLimit: optional(defineHexOrEmptyBytes()),\n preVerificationGas: optional(defineHexOrEmptyBytes()),\n verificationGasLimit: optional(defineHexOrEmptyBytes()),\n }),\n );\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when updating user operation',\n );\n}\n\n/**\n * Validate the response from a smart contract account when signing the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validateSignUserOperationResponse(\n response: SignUserOperationResponse,\n) {\n const Hex = defineHex();\n\n const ValidResponse = object({\n signature: Hex,\n });\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when signing user operation',\n );\n}\n\n/**\n * Validate data against a struct.\n *\n * @param data - The data to validate.\n * @param struct - The struct to validate against.\n * @param message - The message to throw if validation fails.\n */\nfunction validate<T>(data: unknown, struct: Struct<T>, message: string) {\n try {\n assert(data, struct, message);\n } catch (error) {\n const causes = (error as StructError)\n .failures()\n .map((failure) => {\n if (!failure.path.length) {\n return failure.message;\n }\n\n return `${failure.path.join('.')} - ${failure.message}`;\n })\n .join('\\n');\n\n const finalMessage = `${message}\\n${causes}`;\n\n throw new Error(finalMessage);\n }\n}\n\n/**\n * Define the Hex type used by superstruct.\n *\n * @returns The Hex superstruct type.\n */\nfunction defineHex() {\n return define<string>('Hexadecimal String', (value) =>\n isStrictHexString(value),\n );\n}\n\n/**\n * Define the HexOrEmptyBytes type used by superstruct.\n *\n * @returns The HexOrEmptyBytes superstruct type.\n */\nfunction defineHexOrEmptyBytes() {\n return define<string>(\n 'Hexadecimal String or 0x',\n (value) => isStrictHexString(value) || value === EMPTY_BYTES,\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PrepareUserOperationResponse, SignUserOperationResponse, UpdateUserOperationResponse } from
|
|
2
|
-
import type { AddUserOperationOptions, AddUserOperationRequest } from
|
|
1
|
+
import type { PrepareUserOperationResponse, SignUserOperationResponse, UpdateUserOperationResponse } from "../types.cjs";
|
|
2
|
+
import type { AddUserOperationOptions, AddUserOperationRequest } from "../UserOperationController.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Validate a request to add a user operation.
|
|
5
5
|
*
|
|
@@ -30,4 +30,4 @@ export declare function validateUpdateUserOperationResponse(response: UpdateUser
|
|
|
30
30
|
* @param response - The response to validate.
|
|
31
31
|
*/
|
|
32
32
|
export declare function validateSignUserOperationResponse(response: SignUserOperationResponse): void;
|
|
33
|
-
//# sourceMappingURL=validation.d.
|
|
33
|
+
//# sourceMappingURL=validation.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.cts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC5B,qBAAoB;AACrB,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,uCAAsC;AAEvC;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,QAejC;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,QAkCjC;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,4BAA4B,QAsCvC;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,2BAA2B,QAgBtC;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,QAapC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PrepareUserOperationResponse, SignUserOperationResponse, UpdateUserOperationResponse } from "../types.mjs";
|
|
2
|
+
import type { AddUserOperationOptions, AddUserOperationRequest } from "../UserOperationController.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Validate a request to add a user operation.
|
|
5
|
+
*
|
|
6
|
+
* @param request - The request to validate.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateAddUserOperationRequest(request: AddUserOperationRequest): void;
|
|
9
|
+
/**
|
|
10
|
+
* Validate the options when adding a user operation.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The options to validate.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateAddUserOperationOptions(options: AddUserOperationOptions): void;
|
|
15
|
+
/**
|
|
16
|
+
* Validate the response from a smart contract account when preparing the user operation.
|
|
17
|
+
*
|
|
18
|
+
* @param response - The response to validate.
|
|
19
|
+
*/
|
|
20
|
+
export declare function validatePrepareUserOperationResponse(response: PrepareUserOperationResponse): void;
|
|
21
|
+
/**
|
|
22
|
+
* Validate the response from a smart contract account when updating the user operation.
|
|
23
|
+
*
|
|
24
|
+
* @param response - The response to validate.
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateUpdateUserOperationResponse(response: UpdateUserOperationResponse): void;
|
|
27
|
+
/**
|
|
28
|
+
* Validate the response from a smart contract account when signing the user operation.
|
|
29
|
+
*
|
|
30
|
+
* @param response - The response to validate.
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateSignUserOperationResponse(response: SignUserOperationResponse): void;
|
|
33
|
+
//# sourceMappingURL=validation.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.mts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC5B,qBAAoB;AACrB,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,uCAAsC;AAEvC;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,QAejC;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,QAkCjC;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,4BAA4B,QAsCvC;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,2BAA2B,QAgBtC;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,QAapC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { assert, boolean, define, enums, func, number, object, optional, refine, string
|
|
2
|
-
import { TransactionType } from
|
|
3
|
-
import { isStrictHexString } from
|
|
4
|
-
import { EMPTY_BYTES } from
|
|
1
|
+
import { assert, boolean, define, enums, func, number, object, optional, refine, string } from "@metamask/superstruct";
|
|
2
|
+
import { TransactionType } from "@metamask/transaction-controller";
|
|
3
|
+
import { isStrictHexString } from "@metamask/utils";
|
|
4
|
+
import { EMPTY_BYTES } from "../constants.mjs";
|
|
5
5
|
/**
|
|
6
6
|
* Validate a request to add a user operation.
|
|
7
7
|
*
|
|
@@ -151,4 +151,4 @@ function defineHex() {
|
|
|
151
151
|
function defineHexOrEmptyBytes() {
|
|
152
152
|
return define('Hexadecimal String or 0x', (value) => isStrictHexString(value) || value === EMPTY_BYTES);
|
|
153
153
|
}
|
|
154
|
-
//# sourceMappingURL=validation.
|
|
154
|
+
//# sourceMappingURL=validation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.mjs","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EAAE,eAAe,EAAE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E;aACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACzB,OAAO,OAAO,CAAC,OAAO,CAAC;YACzB,CAAC;YAED,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1D,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,MAAM,YAAY,GAAG,GAAG,OAAO,KAAK,MAAM,EAAE,CAAC;QAE7C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS;IAChB,OAAO,MAAM,CAAS,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CACpD,iBAAiB,CAAC,KAAK,CAAC,CACzB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB;IAC5B,OAAO,MAAM,CACX,0BAA0B,EAC1B,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,WAAW,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import type { Struct, StructError } from '@metamask/superstruct';\nimport {\n assert,\n boolean,\n define,\n enums,\n func,\n number,\n object,\n optional,\n refine,\n string,\n} from '@metamask/superstruct';\nimport { TransactionType } from '@metamask/transaction-controller';\nimport { isStrictHexString } from '@metamask/utils';\n\nimport { EMPTY_BYTES } from '../constants.js';\nimport type {\n PrepareUserOperationResponse,\n SignUserOperationResponse,\n UpdateUserOperationResponse,\n} from '../types.js';\nimport type {\n AddUserOperationOptions,\n AddUserOperationRequest,\n} from '../UserOperationController.js';\n\n/**\n * Validate a request to add a user operation.\n *\n * @param request - The request to validate.\n */\nexport function validateAddUserOperationRequest(\n request: AddUserOperationRequest,\n) {\n const Hex = defineHex();\n const HexOrEmptyBytes = defineHexOrEmptyBytes();\n\n const ValidRequest = object({\n data: optional(HexOrEmptyBytes),\n from: Hex,\n maxFeePerGas: optional(Hex),\n maxPriorityFeePerGas: optional(Hex),\n to: optional(Hex),\n value: optional(Hex),\n });\n\n validate(request, ValidRequest, 'Invalid request to add user operation');\n}\n\n/**\n * Validate the options when adding a user operation.\n *\n * @param options - The options to validate.\n */\nexport function validateAddUserOperationOptions(\n options: AddUserOperationOptions,\n) {\n const ValidOptions = object({\n networkClientId: string(),\n origin: string(),\n requireApproval: optional(boolean()),\n smartContractAccount: optional(\n object({\n prepareUserOperation: func(),\n updateUserOperation: func(),\n signUserOperation: func(),\n }),\n ),\n swaps: optional(\n object({\n approvalTxId: optional(string()),\n destinationTokenAddress: optional(string()),\n destinationTokenDecimals: optional(number()),\n destinationTokenSymbol: optional(string()),\n estimatedBaseFee: optional(string()),\n sourceTokenSymbol: optional(string()),\n swapMetaData: optional(object()),\n swapTokenValue: optional(string()),\n destinationTokenAmount: optional(string()),\n sourceTokenAddress: optional(string()),\n sourceTokenAmount: optional(string()),\n sourceTokenDecimals: optional(number()),\n swapAndSendRecipient: optional(string()),\n }),\n ),\n type: optional(enums(Object.values(TransactionType))),\n });\n\n validate(options, ValidOptions, 'Invalid options to add user operation');\n}\n\n/**\n * Validate the response from a smart contract account when preparing the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validatePrepareUserOperationResponse(\n response: PrepareUserOperationResponse,\n) {\n const Hex = defineHex();\n const HexOrEmptyBytes = defineHexOrEmptyBytes();\n\n const ValidResponse = refine(\n object({\n bundler: string(),\n callData: Hex,\n dummyPaymasterAndData: optional(HexOrEmptyBytes),\n dummySignature: optional(HexOrEmptyBytes),\n gas: optional(\n object({\n callGasLimit: Hex,\n preVerificationGas: Hex,\n verificationGasLimit: Hex,\n }),\n ),\n initCode: optional(HexOrEmptyBytes),\n nonce: Hex,\n sender: Hex,\n }),\n 'ValidPrepareUserOperationResponse',\n ({ gas, dummySignature }) => {\n if (!gas && (!dummySignature || dummySignature === EMPTY_BYTES)) {\n return 'Must specify dummySignature if not specifying gas';\n }\n\n /* istanbul ignore next */\n return true;\n },\n );\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when preparing user operation',\n );\n}\n\n/**\n * Validate the response from a smart contract account when updating the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validateUpdateUserOperationResponse(\n response: UpdateUserOperationResponse,\n) {\n const ValidResponse = optional(\n object({\n paymasterAndData: optional(defineHexOrEmptyBytes()),\n callGasLimit: optional(defineHexOrEmptyBytes()),\n preVerificationGas: optional(defineHexOrEmptyBytes()),\n verificationGasLimit: optional(defineHexOrEmptyBytes()),\n }),\n );\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when updating user operation',\n );\n}\n\n/**\n * Validate the response from a smart contract account when signing the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validateSignUserOperationResponse(\n response: SignUserOperationResponse,\n) {\n const Hex = defineHex();\n\n const ValidResponse = object({\n signature: Hex,\n });\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when signing user operation',\n );\n}\n\n/**\n * Validate data against a struct.\n *\n * @param data - The data to validate.\n * @param struct - The struct to validate against.\n * @param message - The message to throw if validation fails.\n */\nfunction validate<T>(data: unknown, struct: Struct<T>, message: string) {\n try {\n assert(data, struct, message);\n } catch (error) {\n const causes = (error as StructError)\n .failures()\n .map((failure) => {\n if (!failure.path.length) {\n return failure.message;\n }\n\n return `${failure.path.join('.')} - ${failure.message}`;\n })\n .join('\\n');\n\n const finalMessage = `${message}\\n${causes}`;\n\n throw new Error(finalMessage);\n }\n}\n\n/**\n * Define the Hex type used by superstruct.\n *\n * @returns The Hex superstruct type.\n */\nfunction defineHex() {\n return define<string>('Hexadecimal String', (value) =>\n isStrictHexString(value),\n );\n}\n\n/**\n * Define the HexOrEmptyBytes type used by superstruct.\n *\n * @returns The HexOrEmptyBytes superstruct type.\n */\nfunction defineHexOrEmptyBytes() {\n return define<string>(\n 'Hexadecimal String or 0x',\n (value) => isStrictHexString(value) || value === EMPTY_BYTES,\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/user-operation-controller",
|
|
3
|
-
"version": "41.2.9-preview-
|
|
3
|
+
"version": "41.2.9-preview-eb263b0ee",
|
|
4
4
|
"description": "Creates user operations and manages their life cycle",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -18,12 +18,19 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist/"
|
|
20
20
|
],
|
|
21
|
-
"type": "module",
|
|
22
21
|
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
23
24
|
"exports": {
|
|
24
25
|
".": {
|
|
25
|
-
"
|
|
26
|
-
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/index.d.mts",
|
|
28
|
+
"default": "./dist/index.mjs"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/index.d.cts",
|
|
32
|
+
"default": "./dist/index.cjs"
|
|
33
|
+
}
|
|
27
34
|
},
|
|
28
35
|
"./package.json": "./package.json"
|
|
29
36
|
},
|
|
@@ -32,11 +39,9 @@
|
|
|
32
39
|
"registry": "https://registry.npmjs.org/"
|
|
33
40
|
},
|
|
34
41
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"build:all": "
|
|
37
|
-
"build:clean": "yarn build:only-clean && yarn build",
|
|
42
|
+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
43
|
+
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
38
44
|
"build:docs": "typedoc",
|
|
39
|
-
"build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
|
|
40
45
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/user-operation-controller",
|
|
41
46
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/user-operation-controller",
|
|
42
47
|
"lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
|
|
@@ -66,27 +71,26 @@
|
|
|
66
71
|
"@metamask/utils": "^11.11.0",
|
|
67
72
|
"bn.js": "^5.2.1",
|
|
68
73
|
"immer": "^9.0.6",
|
|
69
|
-
"lodash
|
|
74
|
+
"lodash": "^4.17.21",
|
|
70
75
|
"uuid": "^8.3.2"
|
|
71
76
|
},
|
|
72
77
|
"devDependencies": {
|
|
73
78
|
"@metamask/auto-changelog": "^6.1.0",
|
|
74
79
|
"@metamask/eth-block-tracker": "^15.0.0",
|
|
80
|
+
"@ts-bridge/cli": "^0.6.4",
|
|
75
81
|
"@types/jest": "^30.0.0",
|
|
76
|
-
"@typescript/native": "npm:typescript@^7.0.2",
|
|
77
82
|
"deepmerge": "^4.2.2",
|
|
78
83
|
"jest": "^30.4.2",
|
|
79
|
-
"rimraf": "^5.0.5",
|
|
80
84
|
"ts-jest": "^29.4.11",
|
|
81
85
|
"tsx": "^4.20.5",
|
|
82
86
|
"typedoc": "^0.25.13",
|
|
83
87
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
84
|
-
"typescript": "
|
|
88
|
+
"typescript": "~5.3.3"
|
|
85
89
|
},
|
|
86
90
|
"peerDependencies": {
|
|
87
91
|
"@metamask/eth-block-tracker": ">=9"
|
|
88
92
|
},
|
|
89
93
|
"engines": {
|
|
90
|
-
"node": "^
|
|
94
|
+
"node": "^18.18 || >=20"
|
|
91
95
|
}
|
|
92
96
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockTrackerPollingController.d.ts","sourceRoot":"","sources":["../src/BlockTrackerPollingController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAIL,iBAAiB,EAClB,MAAM,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AM,iCAAiC,GAAG,GAK7C,EAAE,CAAC,kCAAkC,CAA6B,KAAK,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAKzC,EAAE,CACJ,kCAAkC,CAChC,cAAc,CACf,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n NetworkClientId,\n NetworkClient,\n} from '@metamask/network-controller';\nimport {\n AbstractPollingControllerBaseMixin,\n getKey,\n Constructor,\n PollingTokenSetId,\n} from '@metamask/polling-controller';\nimport type { Json } from '@metamask/utils';\n\n/**\n * The minimum input required to start polling for a {@link BlockTrackerPollingController}.\n * Implementing classes may provide additional properties.\n */\nexport type BlockTrackerPollingInput = {\n networkClientId: NetworkClientId;\n};\n\n/**\n * BlockTrackerPollingControllerMixin\n * A polling controller that polls using a block tracker.\n *\n * @param Base - The base class to mix onto.\n * @returns The composed class.\n */\n// This is a function that's used as class, and the return type is inferred from\n// the class defined inside the function scope, so this can't be easily typed.\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/naming-convention\nfunction BlockTrackerPollingControllerMixin<\n TBase extends Constructor,\n PollingInput extends BlockTrackerPollingInput,\n>(Base: TBase) {\n abstract class BlockTrackerPollingController extends AbstractPollingControllerBaseMixin<\n TBase,\n PollingInput\n >(Base) {\n // This field is public (rather than using `#`) so that declaration\n // emission can describe it. Private/protected members on the class\n // returned by an exported mixin function trigger TS4094, and giving the\n // mixin an explicit return type to work around that breaks consumers\n // that supply the base class's own type arguments via\n // `BlockTrackerPollingController()<Name, State, Messenger>`. The\n // leading underscore signals \"internal, do not use\" without needing\n // true privacy.\n _activeListeners: Record<string, (options: Json) => Promise<void>> = {};\n\n abstract _getNetworkClientById(\n networkClientId: NetworkClientId,\n ): NetworkClient | undefined;\n\n _startPolling(input: PollingInput): void {\n const key = getKey(input);\n\n if (this._activeListeners[key]) {\n return;\n }\n\n const networkClient = this._getNetworkClientById(input.networkClientId);\n if (networkClient) {\n const updateOnNewBlock = this._executePoll.bind(this, input);\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n networkClient.blockTracker.addListener('latest', updateOnNewBlock);\n this._activeListeners[key] = updateOnNewBlock;\n } else {\n throw new Error(\n `Unable to retrieve blockTracker for networkClientId ${input.networkClientId}`,\n );\n }\n }\n\n _stopPollingByPollingTokenSetId(key: PollingTokenSetId): void {\n const { networkClientId } = JSON.parse(key);\n const networkClient = this._getNetworkClientById(\n networkClientId as NetworkClientId,\n );\n\n if (networkClient && this._activeListeners[key]) {\n const listener = this._activeListeners[key];\n if (listener) {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n networkClient.blockTracker.removeListener('latest', listener);\n delete this._activeListeners[key];\n }\n }\n }\n }\n\n return BlockTrackerPollingController;\n}\n\nclass Empty {}\n\nexport const BlockTrackerPollingControllerOnly = <\n PollingInput extends BlockTrackerPollingInput,\n // The return type is inferred from the class defined inside the function\n // scope, so this can't be easily typed.\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n>() => BlockTrackerPollingControllerMixin<typeof Empty, PollingInput>(Empty);\n\nexport const BlockTrackerPollingController = <\n PollingInput extends BlockTrackerPollingInput,\n // The return type is inferred from the class defined inside the function\n // scope, so this can't be easily typed.\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n>() =>\n BlockTrackerPollingControllerMixin<typeof BaseController, PollingInput>(\n BaseController,\n );\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserOperationController-method-action-types.d.ts","sourceRoot":"","sources":["../src/UserOperationController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,4DAA4D,GAAG;IACzE,IAAI,EAAE,yDAAyD,CAAC;IAChE,OAAO,EAAE,uBAAuB,CAAC,iCAAiC,CAAC,CAAC;CACrE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,0DAA0D,GAAG;IACvE,IAAI,EAAE,uDAAuD,CAAC;IAC9D,OAAO,EAAE,uBAAuB,CAAC,+BAA+B,CAAC,CAAC;CACnE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAC5C,6CAA6C,GAC7C,4DAA4D,GAC5D,0DAA0D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserOperationController-method-action-types.js","sourceRoot":"","sources":["../src/UserOperationController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { UserOperationController } from './UserOperationController.js';\n\n/**\n * Create and submit a user operation.\n *\n * @param request - Information required to create a user operation.\n * @param request.data - Data to include in the resulting transaction.\n * @param request.maxFeePerGas - Maximum fee per gas to pay towards the transaction.\n * @param request.maxPriorityFeePerGas - Maximum priority fee per gas to pay towards the transaction.\n * @param request.to - Destination address of the resulting transaction.\n * @param request.value - Value to include in the resulting transaction.\n * @param options - Configuration options when creating a user operation.\n * @param options.networkClientId - ID of the network client used to query the chain.\n * @param options.origin - Origin of the user operation, such as the hostname of a dApp.\n * @param options.requireApproval - Whether to require user approval before submitting the user operation. Defaults to true.\n * @param options.smartContractAccount - Smart contract abstraction to provide the contract specific values such as call data and nonce. Defaults to the current snap account.\n * @param options.swaps - Swap metadata to record with the user operation.\n * @param options.type - Type of the transaction.\n */\nexport type UserOperationControllerAddUserOperationAction = {\n type: `UserOperationController:addUserOperation`;\n handler: UserOperationController['addUserOperation'];\n};\n\n/**\n * Create and submit a user operation equivalent to the provided transaction.\n *\n * @param transaction - Transaction to use as the basis for the user operation.\n * @param options - Configuration options when creating a user operation.\n * @param options.networkClientId - ID of the network client used to query the chain.\n * @param options.origin - Origin of the user operation, such as the hostname of a dApp.\n * @param options.requireApproval - Whether to require user approval before submitting the user operation. Defaults to true.\n * @param options.smartContractAccount - Smart contract abstraction to provide the contract specific values such as call data and nonce. Defaults to the current snap account.\n * @param options.swaps - Swap metadata to record with the user operation.\n * @param options.type - Type of the transaction.\n */\nexport type UserOperationControllerAddUserOperationFromTransactionAction = {\n type: `UserOperationController:addUserOperationFromTransaction`;\n handler: UserOperationController['addUserOperationFromTransaction'];\n};\n\n/**\n * Starts polling for pending user operations on the given network.\n *\n * @param networkClientId - The ID of the network client to poll.\n * @returns The polling token that can be used to stop polling.\n */\nexport type UserOperationControllerStartPollingByNetworkClientIdAction = {\n type: `UserOperationController:startPollingByNetworkClientId`;\n handler: UserOperationController['startPollingByNetworkClientId'];\n};\n\n/**\n * Union of all UserOperationController action types.\n */\nexport type UserOperationControllerMethodActions =\n | UserOperationControllerAddUserOperationAction\n | UserOperationControllerAddUserOperationFromTransactionAction\n | UserOperationControllerStartPollingByNetworkClientIdAction;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserOperationController.d.ts","sourceRoot":"","sources":["../src/UserOperationController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kCAAkC,EAEnC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EACV,2CAA2C,EAC3C,yCAAyC,EACzC,wCAAwC,EACzC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MA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QzC;;;;;;;;OAQG;IACH,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,KAAK,GACN,EAAE,8BAA8B,EAyBhC;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,gBAAgB,CACpB,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC,CAKnC;IAED;;;;;;;;;;;OAWG;IACG,+BAA+B,CACnC,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC,CAkBnC;IAED;;;;;OAKG;IACH,6BAA6B,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAI7D;CAijBF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserOperationController.js","sourceRoot":"","sources":["../src/UserOperationController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAK3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAY1D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAKnE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,kEAAkE;AAClE,sDAAsD;AACtD,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,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CAAC,4BAA4B,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import type {\n AcceptResultCallbacks,\n ApprovalControllerAddRequestAction,\n AddResult,\n} from '@metamask/approval-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport type {\n KeyringControllerPrepareUserOperationAction,\n KeyringControllerPatchUserOperationAction,\n KeyringControllerSignUserOperationAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerGetNetworkClientByIdAction,\n Provider,\n} from '@metamask/network-controller';\nimport { errorCodes } from '@metamask/rpc-errors';\nimport { TransactionType } from '@metamask/transaction-controller';\nimport type {\n TransactionMeta,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport { add0x } 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';\nimport { cloneDeep } from 'lodash-es';\nimport { v1 as random } from 'uuid';\n\nimport { ADDRESS_ZERO, EMPTY_BYTES, VALUE_ZERO } from './constants.js';\nimport { Bundler } from './helpers/Bundler.js';\nimport { PendingUserOperationTracker } from './helpers/PendingUserOperationTracker.js';\nimport { SnapSmartContractAccount } from './helpers/SnapSmartContractAccount.js';\nimport { projectLogger as log } from './logger.js';\nimport type {\n SmartContractAccount,\n UserOperation,\n UserOperationMetadata,\n} from './types.js';\nimport { UserOperationStatus } from './types.js';\nimport type { UserOperationControllerMethodActions } from './UserOperationController-method-action-types.js';\nimport { updateGasFees } from './utils/gas-fees.js';\nimport { updateGas } from './utils/gas.js';\nimport { getTransactionMetadata } from './utils/transaction.js';\nimport {\n validateAddUserOperationOptions,\n validateAddUserOperationRequest,\n validatePrepareUserOperationResponse,\n validateSignUserOperationResponse,\n validateUpdateUserOperationResponse,\n} from './utils/validation.js';\n\nconst controllerName = 'UserOperationController';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'addUserOperation',\n 'addUserOperationFromTransaction',\n 'startPollingByNetworkClientId',\n] as const;\n\nconst stateMetadata = {\n userOperations: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst getDefaultState = () => ({\n userOperations: {},\n});\n\ntype Events = {\n 'transaction-updated': [metadata: TransactionMeta];\n 'user-operation-added': [metadata: UserOperationMetadata];\n 'user-operation-confirmed': [metadata: UserOperationMetadata];\n 'user-operation-failed': [metadata: UserOperationMetadata, error: Error];\n [key: `${string}:confirmed`]: [metadata: UserOperationMetadata];\n [key: `${string}:failed`]: [metadata: UserOperationMetadata, error: Error];\n};\n\nexport type UserOperationControllerEventEmitter = EventEmitter & {\n on<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): UserOperationControllerEventEmitter;\n\n once<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): UserOperationControllerEventEmitter;\n\n emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;\n};\n\nexport type UserOperationControllerState = {\n userOperations: Record<string, UserOperationMetadata>;\n};\n\nexport type GetUserOperationState = ControllerGetStateAction<\n typeof controllerName,\n UserOperationControllerState\n>;\n\nexport type UserOperationStateChange = ControllerStateChangeEvent<\n typeof controllerName,\n UserOperationControllerState\n>;\n\nexport type UserOperationControllerActions =\n | GetUserOperationState\n | UserOperationControllerMethodActions\n | NetworkControllerGetNetworkClientByIdAction\n | ApprovalControllerAddRequestAction\n | KeyringControllerPrepareUserOperationAction\n | KeyringControllerPatchUserOperationAction\n | KeyringControllerSignUserOperationAction;\n\nexport type UserOperationControllerEvents = UserOperationStateChange;\n\nexport type UserOperationControllerMessenger = Messenger<\n typeof controllerName,\n UserOperationControllerActions,\n UserOperationControllerEvents\n>;\n\nexport type UserOperationControllerOptions = {\n entrypoint: string;\n getGasFeeEstimates: () => Promise<GasFeeState>;\n interval?: number;\n messenger: UserOperationControllerMessenger;\n state?: Partial<UserOperationControllerState>;\n};\n\nexport type AddUserOperationRequest = {\n data?: string;\n from: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n to?: string;\n value?: string;\n};\n\nexport type AddUserOperationSwapOptions = {\n approvalTxId?: string;\n destinationTokenAddress?: string;\n destinationTokenAmount?: string;\n destinationTokenDecimals?: number;\n destinationTokenSymbol?: string;\n estimatedBaseFee?: string;\n sourceTokenAddress?: string;\n sourceTokenAmount?: string;\n sourceTokenDecimals?: number;\n sourceTokenSymbol?: string;\n swapAndSendRecipient?: string;\n swapMetaData?: Record<string, unknown>;\n swapTokenValue?: string;\n};\n\nexport type AddUserOperationOptions = {\n networkClientId: string;\n origin: string;\n requireApproval?: boolean;\n smartContractAccount?: SmartContractAccount;\n swaps?: AddUserOperationSwapOptions;\n type?: TransactionType;\n};\n\nexport type AddUserOperationResponse = {\n id: string;\n hash: () => Promise<string | undefined>;\n transactionHash: () => Promise<string | undefined>;\n};\n\n/**\n * All the objects related to a pending user operation in order to:\n * - Avoid duplicated effort to derive the same properties.\n * - Minimise duplicate arguments in private methods.\n */\ntype UserOperationCache = {\n chainId: string;\n metadata: UserOperationMetadata;\n options: AddUserOperationOptions & {\n smartContractAccount: SmartContractAccount;\n };\n provider: Provider;\n request: AddUserOperationRequest;\n transaction?: TransactionParams;\n};\n\n/**\n * Controller for creating and managing the life cycle of user operations.\n */\nexport class UserOperationController extends BaseController<\n typeof controllerName,\n UserOperationControllerState,\n UserOperationControllerMessenger\n> {\n hub: UserOperationControllerEventEmitter;\n\n readonly #entrypoint: string;\n\n readonly #getGasFeeEstimates: () => Promise<GasFeeState>;\n\n readonly #pendingUserOperationTracker: PendingUserOperationTracker;\n\n /**\n * Construct a UserOperationController instance.\n *\n * @param options - Controller options.\n * @param options.entrypoint - Address of the entrypoint contract.\n * @param options.getGasFeeEstimates - Callback to get gas fee estimates.\n * @param options.messenger - Restricted messenger for the user operation controller.\n * @param options.state - Initial state to set on the controller.\n */\n constructor({\n entrypoint,\n getGasFeeEstimates,\n messenger,\n state,\n }: UserOperationControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.hub = new EventEmitter() as UserOperationControllerEventEmitter;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#entrypoint = entrypoint;\n this.#getGasFeeEstimates = getGasFeeEstimates;\n\n this.#pendingUserOperationTracker = new PendingUserOperationTracker({\n getUserOperations: () =>\n cloneDeep(Object.values(this.state.userOperations)),\n messenger,\n });\n\n this.#addPendingUserOperationTrackerListeners();\n }\n\n /**\n * Create and submit a user operation.\n *\n * @param request - Information required to create a user operation.\n * @param request.data - Data to include in the resulting transaction.\n * @param request.maxFeePerGas - Maximum fee per gas to pay towards the transaction.\n * @param request.maxPriorityFeePerGas - Maximum priority fee per gas to pay towards the transaction.\n * @param request.to - Destination address of the resulting transaction.\n * @param request.value - Value to include in the resulting transaction.\n * @param options - Configuration options when creating a user operation.\n * @param options.networkClientId - ID of the network client used to query the chain.\n * @param options.origin - Origin of the user operation, such as the hostname of a dApp.\n * @param options.requireApproval - Whether to require user approval before submitting the user operation. Defaults to true.\n * @param options.smartContractAccount - Smart contract abstraction to provide the contract specific values such as call data and nonce. Defaults to the current snap account.\n * @param options.swaps - Swap metadata to record with the user operation.\n * @param options.type - Type of the transaction.\n */\n async addUserOperation(\n request: AddUserOperationRequest,\n options: AddUserOperationOptions,\n ): Promise<AddUserOperationResponse> {\n validateAddUserOperationRequest(request);\n validateAddUserOperationOptions(options);\n\n return await this.#addUserOperation(request, options);\n }\n\n /**\n * Create and submit a user operation equivalent to the provided transaction.\n *\n * @param transaction - Transaction to use as the basis for the user operation.\n * @param options - Configuration options when creating a user operation.\n * @param options.networkClientId - ID of the network client used to query the chain.\n * @param options.origin - Origin of the user operation, such as the hostname of a dApp.\n * @param options.requireApproval - Whether to require user approval before submitting the user operation. Defaults to true.\n * @param options.smartContractAccount - Smart contract abstraction to provide the contract specific values such as call data and nonce. Defaults to the current snap account.\n * @param options.swaps - Swap metadata to record with the user operation.\n * @param options.type - Type of the transaction.\n */\n async addUserOperationFromTransaction(\n transaction: TransactionParams,\n options: AddUserOperationOptions,\n ): Promise<AddUserOperationResponse> {\n validateAddUserOperationOptions(options);\n\n const { data, from, maxFeePerGas, maxPriorityFeePerGas, to, value } =\n transaction;\n\n const request: AddUserOperationRequest = {\n data: data === '' ? undefined : data,\n from,\n maxFeePerGas,\n maxPriorityFeePerGas,\n to,\n value,\n };\n\n validateAddUserOperationRequest(request);\n\n return await this.#addUserOperation(request, { ...options, transaction });\n }\n\n /**\n * Starts polling for pending user operations on the given network.\n *\n * @param networkClientId - The ID of the network client to poll.\n * @returns The polling token that can be used to stop polling.\n */\n startPollingByNetworkClientId(networkClientId: string): string {\n return this.#pendingUserOperationTracker.startPolling({\n networkClientId,\n });\n }\n\n async #addUserOperation(\n request: AddUserOperationRequest,\n options: AddUserOperationOptions & { transaction?: TransactionParams },\n ): Promise<AddUserOperationResponse> {\n log('Adding user operation', { request, options });\n\n const {\n networkClientId,\n origin,\n smartContractAccount: requestSmartContractAccount,\n swaps,\n transaction,\n } = options;\n\n const { chainId, provider } = await this.#getProvider(networkClientId);\n\n const metadata = await this.#createMetadata(\n chainId,\n origin,\n transaction,\n swaps,\n );\n\n const smartContractAccount =\n requestSmartContractAccount ??\n new SnapSmartContractAccount(this.messenger);\n\n const cache: UserOperationCache = {\n chainId,\n metadata,\n options: { ...options, smartContractAccount },\n provider,\n request,\n transaction,\n };\n\n const { id } = metadata;\n let throwError = false;\n\n const hashValue = (async () => {\n try {\n return await this.#prepareAndSubmitUserOperation(cache);\n } catch (error) {\n this.#failUserOperation(metadata, error);\n\n if (throwError) {\n throw error;\n }\n\n return undefined;\n }\n })();\n\n const hash = async () => {\n throwError = true;\n return await hashValue;\n };\n\n const transactionHash = async () => {\n await hash();\n\n const { transactionHash: finalTransactionHash } =\n await this.#waitForConfirmation(metadata);\n\n return finalTransactionHash as string;\n };\n\n return {\n id,\n hash,\n transactionHash,\n };\n }\n\n async #prepareAndSubmitUserOperation(cache: UserOperationCache) {\n const { metadata, options } = cache;\n const { requireApproval, smartContractAccount } = options;\n let resultCallbacks: AcceptResultCallbacks | undefined;\n\n try {\n await this.#prepareUserOperation(cache);\n await this.#addPaymasterData(metadata, smartContractAccount);\n\n this.hub.emit('user-operation-added', metadata);\n\n if (requireApproval !== false) {\n resultCallbacks = await this.#approveUserOperation(cache);\n }\n\n await this.#signUserOperation(metadata, smartContractAccount);\n await this.#submitUserOperation(metadata);\n\n resultCallbacks?.success();\n\n return metadata.hash as string;\n } catch (error) {\n /* istanbul ignore next */\n resultCallbacks?.error(error as Error);\n throw error;\n }\n }\n\n async #waitForConfirmation(\n metadata: UserOperationMetadata,\n ): Promise<UserOperationMetadata> {\n const { id, hash } = metadata;\n\n log('Waiting for confirmation', id, hash);\n\n return new Promise((resolve, reject) => {\n this.hub.once(`${id}:confirmed`, (finalMetadata) => {\n resolve(finalMetadata);\n });\n\n this.hub.once(`${id}:failed`, (_finalMetadata, error) => {\n reject(error);\n });\n });\n }\n\n async #createMetadata(\n chainId: string,\n origin: string,\n transaction?: TransactionParams,\n swaps?: AddUserOperationSwapOptions,\n ): Promise<UserOperationMetadata> {\n const metadata: UserOperationMetadata = {\n actualGasCost: null,\n actualGasUsed: null,\n baseFeePerGas: null,\n bundlerUrl: null,\n chainId,\n error: null,\n hash: null,\n id: random(),\n origin,\n status: UserOperationStatus.Unapproved,\n swapsMetadata: swaps\n ? {\n approvalTxId: swaps.approvalTxId ?? null,\n destinationTokenAddress: swaps.destinationTokenAddress ?? null,\n destinationTokenAmount: swaps.destinationTokenAmount ?? null,\n destinationTokenDecimals: swaps.destinationTokenDecimals ?? null,\n destinationTokenSymbol: swaps.destinationTokenSymbol ?? null,\n estimatedBaseFee: swaps.estimatedBaseFee ?? null,\n sourceTokenAddress: swaps.sourceTokenAddress ?? null,\n sourceTokenAmount: swaps.sourceTokenAmount ?? null,\n sourceTokenDecimals: swaps.sourceTokenDecimals ?? null,\n sourceTokenSymbol: swaps.sourceTokenSymbol ?? null,\n swapAndSendRecipient: swaps.swapAndSendRecipient ?? null,\n swapMetaData: (swaps.swapMetaData as Record<string, never>) ?? null,\n swapTokenValue: swaps.swapTokenValue ?? null,\n }\n : null,\n time: Date.now(),\n transactionHash: null,\n transactionParams: (transaction as Required<TransactionParams>) ?? null,\n transactionType: null,\n userFeeLevel: null,\n userOperation: this.#createEmptyUserOperation(transaction),\n };\n\n this.#updateMetadata(metadata);\n\n log('Added user operation', metadata.id);\n\n return metadata;\n }\n\n async #prepareUserOperation(cache: UserOperationCache) {\n const { chainId, metadata, options, provider, request, transaction } =\n cache;\n\n const { data, from, to, value } = request;\n const { id, transactionParams, userOperation } = metadata;\n const { smartContractAccount } = options;\n\n log('Preparing user operation', { id });\n\n const transactionType = await this.#getTransactionType(\n transaction,\n options,\n );\n\n metadata.transactionType = transactionType ?? null;\n\n log('Determined transaction type', transactionType);\n\n await updateGasFees({\n getGasFeeEstimates: this.#getGasFeeEstimates,\n metadata,\n originalRequest: request,\n provider,\n transaction: transactionParams ?? undefined,\n });\n\n const response = await smartContractAccount.prepareUserOperation({\n chainId,\n data,\n from,\n to,\n value,\n });\n\n validatePrepareUserOperationResponse(response);\n\n const {\n bundler: bundlerUrl,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n initCode,\n nonce,\n sender,\n } = response;\n\n userOperation.callData = callData;\n userOperation.initCode = initCode ?? EMPTY_BYTES;\n userOperation.nonce = nonce;\n userOperation.paymasterAndData = dummyPaymasterAndData ?? EMPTY_BYTES;\n userOperation.sender = sender;\n userOperation.signature = dummySignature ?? EMPTY_BYTES;\n\n metadata.bundlerUrl = bundlerUrl;\n\n await updateGas(metadata, response, this.#entrypoint);\n\n this.#updateMetadata(metadata);\n }\n\n async #addPaymasterData(\n metadata: UserOperationMetadata,\n smartContractAccount: SmartContractAccount,\n ) {\n const { id, userOperation, chainId } = metadata;\n\n log('Requesting paymaster data', { id });\n\n const response = await smartContractAccount.updateUserOperation({\n userOperation,\n chainId,\n });\n\n validateUpdateUserOperationResponse(response);\n\n userOperation.paymasterAndData = response.paymasterAndData ?? EMPTY_BYTES;\n if (response.callGasLimit) {\n userOperation.callGasLimit = response.callGasLimit;\n }\n if (response.preVerificationGas) {\n userOperation.preVerificationGas = response.preVerificationGas;\n }\n if (response.verificationGasLimit) {\n userOperation.verificationGasLimit = response.verificationGasLimit;\n }\n\n this.#updateMetadata(metadata);\n }\n\n async #approveUserOperation(cache: UserOperationCache) {\n log('Requesting approval');\n\n const { metadata } = cache;\n\n const { resultCallbacks, value } = await this.#requestApproval(metadata);\n const updatedTransaction = value?.txMeta;\n\n if (updatedTransaction) {\n await this.#updateUserOperationAfterApproval(cache, updatedTransaction);\n }\n\n metadata.status = UserOperationStatus.Approved;\n\n this.#updateMetadata(metadata);\n\n return resultCallbacks;\n }\n\n async #signUserOperation(\n metadata: UserOperationMetadata,\n smartContractAccount: SmartContractAccount,\n ) {\n const { id, chainId, userOperation } = metadata;\n\n log('Signing user operation', id, userOperation);\n\n const response = await smartContractAccount.signUserOperation({\n userOperation,\n chainId,\n });\n\n validateSignUserOperationResponse(response);\n\n const { signature } = response;\n\n userOperation.signature = signature;\n\n log('Signed user operation', signature);\n\n metadata.status = UserOperationStatus.Signed;\n\n this.#updateMetadata(metadata);\n }\n\n async #submitUserOperation(metadata: UserOperationMetadata) {\n const { userOperation } = metadata;\n\n log('Submitting user operation', userOperation);\n\n const bundler = new Bundler(metadata.bundlerUrl as string);\n\n const hash = await bundler.sendUserOperation(\n userOperation,\n this.#entrypoint,\n );\n\n metadata.hash = hash;\n metadata.status = UserOperationStatus.Submitted;\n\n this.#updateMetadata(metadata);\n }\n\n #failUserOperation(metadata: UserOperationMetadata, error: unknown) {\n const { id } = metadata;\n const rawError = error as Record<string, string>;\n\n log('User operation failed', id, error);\n\n metadata.error = {\n name: rawError.name,\n message: rawError.message,\n stack: rawError.stack,\n code: rawError.code,\n rpc: rawError.value,\n };\n\n metadata.status = UserOperationStatus.Failed;\n\n this.#updateMetadata(metadata);\n\n if (\n String(rawError.code) === String(errorCodes.provider.userRejectedRequest)\n ) {\n this.#deleteMetadata(id);\n }\n }\n\n #createEmptyUserOperation(transaction?: TransactionParams): UserOperation {\n return {\n callData: EMPTY_BYTES,\n callGasLimit: EMPTY_BYTES,\n initCode: EMPTY_BYTES,\n maxFeePerGas: transaction?.maxFeePerGas ?? EMPTY_BYTES,\n maxPriorityFeePerGas: transaction?.maxPriorityFeePerGas ?? EMPTY_BYTES,\n nonce: EMPTY_BYTES,\n paymasterAndData: EMPTY_BYTES,\n preVerificationGas: EMPTY_BYTES,\n sender: ADDRESS_ZERO,\n signature: EMPTY_BYTES,\n verificationGasLimit: EMPTY_BYTES,\n };\n }\n\n #updateMetadata(metadata: UserOperationMetadata) {\n const { id } = metadata;\n\n this.update((state) => {\n state.userOperations[id] = cloneDeep(metadata);\n });\n\n this.#updateTransaction(metadata);\n }\n\n #deleteMetadata(id: string) {\n this.update((state) => {\n delete state.userOperations[id];\n });\n }\n\n #updateTransaction(metadata: UserOperationMetadata) {\n if (!metadata.transactionParams) {\n return;\n }\n\n const transactionMetadata = getTransactionMetadata(metadata);\n\n this.hub.emit('transaction-updated', transactionMetadata);\n }\n\n #addPendingUserOperationTrackerListeners() {\n this.#pendingUserOperationTracker.hub.on(\n 'user-operation-confirmed',\n (metadata) => {\n log('In listener...');\n this.hub.emit('user-operation-confirmed', metadata);\n this.hub.emit(`${metadata.id}:confirmed`, metadata);\n },\n );\n\n this.#pendingUserOperationTracker.hub.on(\n 'user-operation-failed',\n (metadata, error) => {\n this.hub.emit('user-operation-failed', metadata, error);\n this.hub.emit(`${metadata.id}:failed`, metadata, error);\n },\n );\n\n this.#pendingUserOperationTracker.hub.on(\n 'user-operation-updated',\n (metadata) => {\n this.#updateMetadata(metadata);\n },\n );\n }\n\n async #requestApproval(metadata: UserOperationMetadata) {\n const { id, origin } = metadata;\n const type = ApprovalType.Transaction;\n const requestData = { txId: id };\n\n return (await this.messenger.call(\n 'ApprovalController:addRequest',\n {\n id,\n origin,\n type,\n requestData,\n expectsResult: true,\n },\n true, // Should display approval request to user\n )) as AddResult & { value?: { txMeta?: TransactionMeta } };\n }\n\n async #getTransactionType(\n transaction: TransactionParams | undefined,\n options: AddUserOperationOptions,\n ): Promise<TransactionType | undefined> {\n if (!transaction) {\n return undefined;\n }\n\n if (options.type) {\n return options.type;\n }\n\n return TransactionType.contractInteraction;\n }\n\n async #getProvider(\n networkClientId: string,\n ): Promise<{ provider: Provider; chainId: string }> {\n const { provider, configuration } = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n\n const { chainId } = configuration;\n\n return { provider, chainId };\n }\n\n async #updateUserOperationAfterApproval(\n cache: UserOperationCache,\n updatedTransaction: TransactionMeta,\n ) {\n log('Found updated transaction in approval', { updatedTransaction });\n\n const { metadata, request } = cache;\n\n const { userOperation } = metadata;\n const usingPaymaster = userOperation.paymasterAndData !== EMPTY_BYTES;\n\n const updatedMaxFeePerGas = add0x(\n updatedTransaction.txParams.maxFeePerGas as string,\n );\n\n const updatedMaxPriorityFeePerGas = add0x(\n updatedTransaction.txParams.maxPriorityFeePerGas as string,\n );\n\n let regenerateUserOperation = false;\n const previousMaxFeePerGas = userOperation.maxFeePerGas;\n const previousMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\n const gasFeesUpdated =\n previousMaxFeePerGas !== updatedMaxFeePerGas ||\n previousMaxPriorityFeePerGas !== updatedMaxPriorityFeePerGas;\n\n /**\n * true when we detect {@link getTransactionMetadata} has set the gas fees to zero\n * because the userOperation has a paymaster. This should not be mistaken for gas\n * fees being updated during the approval process.\n */\n const areGasFeesZeroBecauseOfPaymaster =\n usingPaymaster &&\n updatedMaxFeePerGas === VALUE_ZERO &&\n updatedMaxPriorityFeePerGas === VALUE_ZERO;\n\n if (gasFeesUpdated && !areGasFeesZeroBecauseOfPaymaster) {\n log('Gas fees updated during approval', {\n previousMaxFeePerGas,\n previousMaxPriorityFeePerGas,\n updatedMaxFeePerGas,\n updatedMaxPriorityFeePerGas,\n });\n\n userOperation.maxFeePerGas = updatedMaxFeePerGas;\n userOperation.maxPriorityFeePerGas = updatedMaxPriorityFeePerGas;\n\n regenerateUserOperation = usingPaymaster;\n }\n\n const previousData = request.data ?? EMPTY_BYTES;\n const updatedData = updatedTransaction.txParams.data ?? EMPTY_BYTES;\n\n if (previousData !== updatedData) {\n log('Data updated during approval', { previousData, updatedData });\n regenerateUserOperation = true;\n }\n\n const previousValue = request.value ?? VALUE_ZERO;\n const updatedValue = updatedTransaction.txParams.value ?? VALUE_ZERO;\n\n if (previousValue !== updatedValue) {\n log('Value updated during approval', { previousValue, updatedValue });\n regenerateUserOperation = true;\n }\n\n if (regenerateUserOperation) {\n const updatedRequest = {\n ...request,\n data: updatedData,\n maxFeePerGas: updatedMaxFeePerGas,\n maxPriorityFeePerGas: updatedMaxPriorityFeePerGas,\n value: updatedValue,\n };\n\n await this.#regenerateUserOperation({\n ...cache,\n request: updatedRequest,\n });\n }\n }\n\n async #regenerateUserOperation(cache: UserOperationCache) {\n log(\n 'Regenerating user operation as parameters were updated during approval',\n );\n\n const {\n options: { smartContractAccount },\n metadata,\n } = cache;\n\n await this.#prepareUserOperation(cache);\n await this.#addPaymasterData(metadata, smartContractAccount);\n\n log('Regenerated user operation', metadata.userOperation);\n }\n}\n"]}
|
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,YAAY,+CAA+C,CAAC;AACzE,eAAO,MAAM,UAAU,QAAQ,CAAC"}
|
package/dist/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,4CAA4C,CAAC;AACzE,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC","sourcesContent":["export const EMPTY_BYTES = '0x';\nexport const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000';\nexport const VALUE_ZERO = '0x0';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Bundler.d.ts","sourceRoot":"","sources":["../../src/helpers/Bundler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIvE;;;GAGG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,iFAAiF;IACjF,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAAC;IAEpC,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAElC,2DAA2D;IAC3D,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvC,sEAAsE;IACtE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAO;;IAGlB,YAAY,GAAG,EAAE,MAAM,EAEtB;IAED;;;;;;OAMG;IACG,wBAAwB,CAC5B,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,uCAAuC,CAAC,CAWlD;IAED;;;;;OAKG;IACG,uBAAuB,CAC3B,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAO3C;IAED;;;;;;OAMG;IACG,iBAAiB,CACrB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,MAAM,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uBAAA,IAAI,oBAAK;YACd,aAAa;YACb,UAAU;SACX,CAAC,CAAC;QAEH,MAAM,IAAI,GAAW,MAAM,uBAAA,IAAI,0CAAO,MAAX,IAAI,EAAQ,uBAAuB,EAAE;YAC9D,aAAa;YACb,UAAU;SACX,CAAC,CAAC;QAEH,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;QAEjC,OAAO,IAAI,CAAC;IACd,CAAC;CA0BF;mFAxBC,KAAK,yBAAW,MAAc,EAAE,MAAiB;IAC/C,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;KAChE,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,uBAAA,IAAI,oBAAK,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAE3C,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;QAEzE,KAA2C,CAAC,IAAI;YAC/C,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC;QAE1B,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,YAAY,CAAC,MAAM,CAAC;AAC7B,CAAC","sourcesContent":["import { createModuleLogger, projectLogger } from '../logger.js';\nimport type { UserOperation, UserOperationReceipt } from '../types.js';\n\nconst log = createModuleLogger(projectLogger, 'bundler');\n\n/**\n * Response from the `eth_estimateUserOperationGas` bundler method.\n * Includes the estimated gas limits required by a user operation.\n */\nexport type BundlerEstimateUserOperationGasResponse = {\n /** Estimated gas required to compensate the bundler for any pre-verification. */\n preVerificationGas: number | string;\n\n /** Estimated gas required to verify the user operation. */\n verificationGas?: number | string;\n\n /** Estimated gas required to verify the user operation. */\n verificationGasLimit?: number | string;\n\n /** Estimated gas required for the execution of the user operation. */\n callGasLimit: number | string;\n};\n\n/**\n * A helper class for interacting with a bundler.\n */\nexport class Bundler {\n readonly #url: string;\n\n constructor(url: string) {\n this.#url = url;\n }\n\n /**\n * Estimate the gas required to execute a user operation.\n *\n * @param userOperation - The user operation to estimate gas for.\n * @param entrypoint - The address of entrypoint to use for the user operation.\n * @returns The estimated gas limits for the user operation.\n */\n async estimateUserOperationGas(\n userOperation: UserOperation,\n entrypoint: string,\n ): Promise<BundlerEstimateUserOperationGasResponse> {\n log('Estimating gas', { url: this.#url, userOperation, entrypoint });\n\n const response: BundlerEstimateUserOperationGasResponse = await this.#query(\n 'eth_estimateUserOperationGas',\n [userOperation, entrypoint],\n );\n\n log('Estimated gas', { response });\n\n return response;\n }\n\n /**\n * Retrieve the receipt for a user operation.\n *\n * @param hash - The hash of the user operation.\n * @returns The receipt for the user operation, or `undefined` if the user operation is pending.\n */\n async getUserOperationReceipt(\n hash?: string,\n ): Promise<UserOperationReceipt | undefined> {\n log('Getting user operation receipt', { url: this.#url, hash });\n\n return await this.#query<UserOperationReceipt | undefined>(\n 'eth_getUserOperationReceipt',\n [hash],\n );\n }\n\n /**\n * Submit a user operation to the bundler.\n *\n * @param userOperation - The signed user operation to submit.\n * @param entrypoint - The address of entrypoint to use for the user operation.\n * @returns The hash of the user operation.\n */\n async sendUserOperation(\n userOperation: UserOperation,\n entrypoint: string,\n ): Promise<string> {\n log('Sending user operation', {\n url: this.#url,\n userOperation,\n entrypoint,\n });\n\n const hash: string = await this.#query('eth_sendUserOperation', [\n userOperation,\n entrypoint,\n ]);\n\n log('Sent user operation', hash);\n\n return hash;\n }\n\n async #query<T>(method: string, params: unknown[]): Promise<T> {\n const request = {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),\n };\n\n const response = await fetch(this.#url, request);\n const responseJson = await response.json();\n\n if (responseJson.error) {\n const error = new Error(responseJson.error.message || responseJson.error);\n\n (error as unknown as Record<string, string>).code =\n responseJson.error.code;\n\n throw error;\n }\n\n return responseJson.result;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PendingUserOperationTracker.d.ts","sourceRoot":"","sources":["../../src/helpers/PendingUserOperationTracker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAEhB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,YAAY,MAAM,QAAQ,CAAC;AAIlC,OAAO,KAAK,EAAE,qBAAqB,EAAwB,MAAM,aAAa,CAAC;AAE/E,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;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,IAA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7C,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,mBAAmB,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,OAAO,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,KAAK,CAAC,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SnapSmartContractAccount.d.ts","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,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAGtF,qBAAa,wBAAyB,YAAW,oBAAoB;;IAGnE,YAAY,SAAS,EAAE,gCAAgC,EAEtD;IAEK,oBAAoB,CACxB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,4BAA4B,CAAC,CAwCvC;IAEK,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,2BAA2B,CAAC,CA2BtC;IAEK,iBAAiB,CACrB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC,CAYpC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SnapSmartContractAccount.js","sourceRoot":"","sources":["../../src/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E,MAAM,EAAE,GAAG,aAAa,CAAC;QAEjC,MAAM,EACJ,gBAAgB,EAAE,wBAAwB,EAC1C,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,GACb,GAAG,MAAM,uBAAA,IAAI,2CAAW,CAAC,IAAI,CAC5B,sCAAsC,EACtC,MAAM,EACN,aAAa,EACb,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CACtC,CAAC;QAEF,MAAM,gBAAgB,GACpB,wBAAwB,KAAK,WAAW;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,eAAe,CAAC,OAAO,CAAC,EAAE,CACtC,CAAC;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.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export * from './UserOperationController.js';
|
|
2
|
-
export type { UserOperationControllerAddUserOperationAction, UserOperationControllerAddUserOperationFromTransactionAction, UserOperationControllerStartPollingByNetworkClientIdAction, } from './UserOperationController-method-action-types.js';
|
|
3
|
-
export * from './types.js';
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|