@metamask/eip-5792-middleware 1.0.0
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 +17 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/constants.cjs +22 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +13 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +13 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +19 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index.cjs +10 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/methods/getCallsStatus.cjs +73 -0
- package/dist/methods/getCallsStatus.cjs.map +1 -0
- package/dist/methods/getCallsStatus.d.cts +13 -0
- package/dist/methods/getCallsStatus.d.cts.map +1 -0
- package/dist/methods/getCallsStatus.d.mts +13 -0
- package/dist/methods/getCallsStatus.d.mts.map +1 -0
- package/dist/methods/getCallsStatus.mjs +69 -0
- package/dist/methods/getCallsStatus.mjs.map +1 -0
- package/dist/methods/getCapabilities.cjs +96 -0
- package/dist/methods/getCapabilities.cjs.map +1 -0
- package/dist/methods/getCapabilities.d.cts +30 -0
- package/dist/methods/getCapabilities.d.cts.map +1 -0
- package/dist/methods/getCapabilities.d.mts +30 -0
- package/dist/methods/getCapabilities.d.mts.map +1 -0
- package/dist/methods/getCapabilities.mjs +92 -0
- package/dist/methods/getCapabilities.mjs.map +1 -0
- package/dist/methods/processSendCalls.cjs +249 -0
- package/dist/methods/processSendCalls.cjs.map +1 -0
- package/dist/methods/processSendCalls.d.cts +39 -0
- package/dist/methods/processSendCalls.d.cts.map +1 -0
- package/dist/methods/processSendCalls.d.mts +39 -0
- package/dist/methods/processSendCalls.d.mts.map +1 -0
- package/dist/methods/processSendCalls.mjs +245 -0
- package/dist/methods/processSendCalls.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +9 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +9 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.cjs +24 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +13 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +13 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +20 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +74 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Initial release ([#6458](https://github.com/MetaMask/core/pull/6458))
|
|
15
|
+
|
|
16
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/eip-5792-middleware@1.0.0...HEAD
|
|
17
|
+
[1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/eip-5792-middleware@1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MetaMask
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@metamask/eip-5792-middleware`
|
|
2
|
+
|
|
3
|
+
Implements the hooks required by the wallet middleware in [eth-json-rpc-middleware](https://github.com/MetaMask/eth-json-rpc-middleware), for JSON-RPC methods for sending multiple calls from the user's wallet and checking their status referenced in [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @metamask/eip-5792-middleware`
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
`npm install @metamask/eip-5792-middleware`
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EIP5792ErrorCode = exports.MessageType = exports.KEYRING_TYPES_SUPPORTING_7702 = exports.VERSION = void 0;
|
|
4
|
+
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
5
|
+
exports.VERSION = '2.0.0';
|
|
6
|
+
exports.KEYRING_TYPES_SUPPORTING_7702 = [
|
|
7
|
+
keyring_controller_1.KeyringTypes.hd,
|
|
8
|
+
keyring_controller_1.KeyringTypes.simple,
|
|
9
|
+
];
|
|
10
|
+
var MessageType;
|
|
11
|
+
(function (MessageType) {
|
|
12
|
+
MessageType["SendTransaction"] = "eth_sendTransaction";
|
|
13
|
+
})(MessageType || (exports.MessageType = MessageType = {}));
|
|
14
|
+
// To be moved to @metamask/rpc-errors in future.
|
|
15
|
+
var EIP5792ErrorCode;
|
|
16
|
+
(function (EIP5792ErrorCode) {
|
|
17
|
+
EIP5792ErrorCode[EIP5792ErrorCode["UnsupportedNonOptionalCapability"] = 5700] = "UnsupportedNonOptionalCapability";
|
|
18
|
+
EIP5792ErrorCode[EIP5792ErrorCode["UnsupportedChainId"] = 5710] = "UnsupportedChainId";
|
|
19
|
+
EIP5792ErrorCode[EIP5792ErrorCode["UnknownBundleId"] = 5730] = "UnknownBundleId";
|
|
20
|
+
EIP5792ErrorCode[EIP5792ErrorCode["RejectedUpgrade"] = 5750] = "RejectedUpgrade";
|
|
21
|
+
})(EIP5792ErrorCode || (exports.EIP5792ErrorCode = EIP5792ErrorCode = {}));
|
|
22
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,qEAA4D;AAE/C,QAAA,OAAO,GAAG,OAAO,CAAC;AAElB,QAAA,6BAA6B,GAAG;IAC3C,iCAAY,CAAC,EAAE;IACf,iCAAY,CAAC,MAAM;CACpB,CAAC;AAEF,IAAY,WAEX;AAFD,WAAY,WAAW;IACrB,sDAAuC,CAAA;AACzC,CAAC,EAFW,WAAW,2BAAX,WAAW,QAEtB;AAED,iDAAiD;AACjD,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,kHAAuC,CAAA;IACvC,sFAAyB,CAAA;IACzB,gFAAsB,CAAA;IACtB,gFAAsB,CAAA;AACxB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\n\nexport const VERSION = '2.0.0';\n\nexport const KEYRING_TYPES_SUPPORTING_7702 = [\n KeyringTypes.hd,\n KeyringTypes.simple,\n];\n\nexport enum MessageType {\n SendTransaction = 'eth_sendTransaction',\n}\n\n// To be moved to @metamask/rpc-errors in future.\nexport enum EIP5792ErrorCode {\n UnsupportedNonOptionalCapability = 5700,\n UnsupportedChainId = 5710,\n UnknownBundleId = 5730,\n RejectedUpgrade = 5750,\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
2
|
+
export declare const VERSION = "2.0.0";
|
|
3
|
+
export declare const KEYRING_TYPES_SUPPORTING_7702: KeyringTypes[];
|
|
4
|
+
export declare enum MessageType {
|
|
5
|
+
SendTransaction = "eth_sendTransaction"
|
|
6
|
+
}
|
|
7
|
+
export declare enum EIP5792ErrorCode {
|
|
8
|
+
UnsupportedNonOptionalCapability = 5700,
|
|
9
|
+
UnsupportedChainId = 5710,
|
|
10
|
+
UnknownBundleId = 5730,
|
|
11
|
+
RejectedUpgrade = 5750
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAE5D,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,eAAO,MAAM,6BAA6B,gBAGzC,CAAC;AAEF,oBAAY,WAAW;IACrB,eAAe,wBAAwB;CACxC;AAGD,oBAAY,gBAAgB;IAC1B,gCAAgC,OAAO;IACvC,kBAAkB,OAAO;IACzB,eAAe,OAAO;IACtB,eAAe,OAAO;CACvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
2
|
+
export declare const VERSION = "2.0.0";
|
|
3
|
+
export declare const KEYRING_TYPES_SUPPORTING_7702: KeyringTypes[];
|
|
4
|
+
export declare enum MessageType {
|
|
5
|
+
SendTransaction = "eth_sendTransaction"
|
|
6
|
+
}
|
|
7
|
+
export declare enum EIP5792ErrorCode {
|
|
8
|
+
UnsupportedNonOptionalCapability = 5700,
|
|
9
|
+
UnsupportedChainId = 5710,
|
|
10
|
+
UnknownBundleId = 5730,
|
|
11
|
+
RejectedUpgrade = 5750
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAE5D,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,eAAO,MAAM,6BAA6B,gBAGzC,CAAC;AAEF,oBAAY,WAAW;IACrB,eAAe,wBAAwB;CACxC;AAGD,oBAAY,gBAAgB;IAC1B,gCAAgC,OAAO;IACvC,kBAAkB,OAAO;IACzB,eAAe,OAAO;IACtB,eAAe,OAAO;CACvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
2
|
+
export const VERSION = '2.0.0';
|
|
3
|
+
export const KEYRING_TYPES_SUPPORTING_7702 = [
|
|
4
|
+
KeyringTypes.hd,
|
|
5
|
+
KeyringTypes.simple,
|
|
6
|
+
];
|
|
7
|
+
export var MessageType;
|
|
8
|
+
(function (MessageType) {
|
|
9
|
+
MessageType["SendTransaction"] = "eth_sendTransaction";
|
|
10
|
+
})(MessageType || (MessageType = {}));
|
|
11
|
+
// To be moved to @metamask/rpc-errors in future.
|
|
12
|
+
export var EIP5792ErrorCode;
|
|
13
|
+
(function (EIP5792ErrorCode) {
|
|
14
|
+
EIP5792ErrorCode[EIP5792ErrorCode["UnsupportedNonOptionalCapability"] = 5700] = "UnsupportedNonOptionalCapability";
|
|
15
|
+
EIP5792ErrorCode[EIP5792ErrorCode["UnsupportedChainId"] = 5710] = "UnsupportedChainId";
|
|
16
|
+
EIP5792ErrorCode[EIP5792ErrorCode["UnknownBundleId"] = 5730] = "UnknownBundleId";
|
|
17
|
+
EIP5792ErrorCode[EIP5792ErrorCode["RejectedUpgrade"] = 5750] = "RejectedUpgrade";
|
|
18
|
+
})(EIP5792ErrorCode || (EIP5792ErrorCode = {}));
|
|
19
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAE5D,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,YAAY,CAAC,EAAE;IACf,YAAY,CAAC,MAAM;CACpB,CAAC;AAEF,MAAM,CAAN,IAAY,WAEX;AAFD,WAAY,WAAW;IACrB,sDAAuC,CAAA;AACzC,CAAC,EAFW,WAAW,KAAX,WAAW,QAEtB;AAED,iDAAiD;AACjD,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,kHAAuC,CAAA;IACvC,sFAAyB,CAAA;IACzB,gFAAsB,CAAA;IACtB,gFAAsB,CAAA;AACxB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\n\nexport const VERSION = '2.0.0';\n\nexport const KEYRING_TYPES_SUPPORTING_7702 = [\n KeyringTypes.hd,\n KeyringTypes.simple,\n];\n\nexport enum MessageType {\n SendTransaction = 'eth_sendTransaction',\n}\n\n// To be moved to @metamask/rpc-errors in future.\nexport enum EIP5792ErrorCode {\n UnsupportedNonOptionalCapability = 5700,\n UnsupportedChainId = 5710,\n UnknownBundleId = 5730,\n RejectedUpgrade = 5750,\n}\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCapabilities = exports.getCallsStatus = exports.processSendCalls = void 0;
|
|
4
|
+
var processSendCalls_1 = require("./methods/processSendCalls.cjs");
|
|
5
|
+
Object.defineProperty(exports, "processSendCalls", { enumerable: true, get: function () { return processSendCalls_1.processSendCalls; } });
|
|
6
|
+
var getCallsStatus_1 = require("./methods/getCallsStatus.cjs");
|
|
7
|
+
Object.defineProperty(exports, "getCallsStatus", { enumerable: true, get: function () { return getCallsStatus_1.getCallsStatus; } });
|
|
8
|
+
var getCapabilities_1 = require("./methods/getCapabilities.cjs");
|
|
9
|
+
Object.defineProperty(exports, "getCapabilities", { enumerable: true, get: function () { return getCapabilities_1.getCapabilities; } });
|
|
10
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,mEAA8D;AAArD,oHAAA,gBAAgB,OAAA;AACzB,+DAA0D;AAAjD,gHAAA,cAAc,OAAA;AACvB,iEAGmC;AAFjC,kHAAA,eAAe,OAAA","sourcesContent":["export type {\n ProcessSendCallsRequest,\n ProcessSendCallsHooks,\n} from './methods/processSendCalls';\nexport { processSendCalls } from './methods/processSendCalls';\nexport { getCallsStatus } from './methods/getCallsStatus';\nexport {\n getCapabilities,\n type GetCapabilitiesHooks,\n} from './methods/getCapabilities';\nexport type { EIP5792Messenger } from './types';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { ProcessSendCallsRequest, ProcessSendCallsHooks, } from "./methods/processSendCalls.cjs";
|
|
2
|
+
export { processSendCalls } from "./methods/processSendCalls.cjs";
|
|
3
|
+
export { getCallsStatus } from "./methods/getCallsStatus.cjs";
|
|
4
|
+
export { getCapabilities, type GetCapabilitiesHooks, } from "./methods/getCapabilities.cjs";
|
|
5
|
+
export type { EIP5792Messenger } from "./types.cjs";
|
|
6
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,uCAAmC;AACpC,OAAO,EAAE,gBAAgB,EAAE,uCAAmC;AAC9D,OAAO,EAAE,cAAc,EAAE,qCAAiC;AAC1D,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,sCAAkC;AACnC,YAAY,EAAE,gBAAgB,EAAE,oBAAgB"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { ProcessSendCallsRequest, ProcessSendCallsHooks, } from "./methods/processSendCalls.mjs";
|
|
2
|
+
export { processSendCalls } from "./methods/processSendCalls.mjs";
|
|
3
|
+
export { getCallsStatus } from "./methods/getCallsStatus.mjs";
|
|
4
|
+
export { getCapabilities, type GetCapabilitiesHooks, } from "./methods/getCapabilities.mjs";
|
|
5
|
+
export type { EIP5792Messenger } from "./types.mjs";
|
|
6
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,uCAAmC;AACpC,OAAO,EAAE,gBAAgB,EAAE,uCAAmC;AAC9D,OAAO,EAAE,cAAc,EAAE,qCAAiC;AAC1D,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,sCAAkC;AACnC,YAAY,EAAE,gBAAgB,EAAE,oBAAgB"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,uCAAmC;AAC9D,OAAO,EAAE,cAAc,EAAE,qCAAiC;AAC1D,OAAO,EACL,eAAe,EAEhB,sCAAkC","sourcesContent":["export type {\n ProcessSendCallsRequest,\n ProcessSendCallsHooks,\n} from './methods/processSendCalls';\nexport { processSendCalls } from './methods/processSendCalls';\nexport { getCallsStatus } from './methods/getCallsStatus';\nexport {\n getCapabilities,\n type GetCapabilitiesHooks,\n} from './methods/getCapabilities';\nexport type { EIP5792Messenger } from './types';\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCallsStatus = void 0;
|
|
4
|
+
const eth_json_rpc_middleware_1 = require("@metamask/eth-json-rpc-middleware");
|
|
5
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
6
|
+
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
7
|
+
const constants_1 = require("../constants.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the status of a transaction batch by its ID.
|
|
10
|
+
*
|
|
11
|
+
* @param messenger - Messenger instance for controller communication.
|
|
12
|
+
* @param id - The batch ID to look up (hexadecimal string).
|
|
13
|
+
* @returns GetCallsStatusResult containing the batch status, receipts, and metadata.
|
|
14
|
+
* @throws JsonRpcError with EIP5792ErrorCode.UnknownBundleId if no matching bundle is found.
|
|
15
|
+
*/
|
|
16
|
+
function getCallsStatus(messenger, id) {
|
|
17
|
+
const transactions = messenger
|
|
18
|
+
.call('TransactionController:getState')
|
|
19
|
+
.transactions.filter((tx) => tx.batchId === id);
|
|
20
|
+
if (!transactions?.length) {
|
|
21
|
+
throw new rpc_errors_1.JsonRpcError(constants_1.EIP5792ErrorCode.UnknownBundleId, `No matching bundle found`);
|
|
22
|
+
}
|
|
23
|
+
const transaction = transactions[0];
|
|
24
|
+
const { chainId, txReceipt: rawTxReceipt } = transaction;
|
|
25
|
+
const status = getStatusCode(transaction);
|
|
26
|
+
const txReceipt = rawTxReceipt;
|
|
27
|
+
const logs = (txReceipt?.logs ?? []);
|
|
28
|
+
const receipts = txReceipt && [
|
|
29
|
+
{
|
|
30
|
+
blockHash: txReceipt.blockHash,
|
|
31
|
+
blockNumber: txReceipt.blockNumber,
|
|
32
|
+
gasUsed: txReceipt.gasUsed,
|
|
33
|
+
logs: logs.map((log) => ({
|
|
34
|
+
address: log.address,
|
|
35
|
+
data: log.data,
|
|
36
|
+
topics: log.topics,
|
|
37
|
+
})),
|
|
38
|
+
status: txReceipt.status,
|
|
39
|
+
transactionHash: txReceipt.transactionHash,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
return {
|
|
43
|
+
version: constants_1.VERSION,
|
|
44
|
+
id,
|
|
45
|
+
chainId,
|
|
46
|
+
atomic: true,
|
|
47
|
+
status,
|
|
48
|
+
receipts,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.getCallsStatus = getCallsStatus;
|
|
52
|
+
/**
|
|
53
|
+
* Maps transaction status to EIP-5792 call status codes.
|
|
54
|
+
*
|
|
55
|
+
* @param transactionMeta - The transaction metadata containing status and hash information.
|
|
56
|
+
* @returns GetCallsStatusCode representing the current status of the transaction.
|
|
57
|
+
*/
|
|
58
|
+
function getStatusCode(transactionMeta) {
|
|
59
|
+
const { hash, status } = transactionMeta;
|
|
60
|
+
if (status === transaction_controller_1.TransactionStatus.confirmed) {
|
|
61
|
+
return eth_json_rpc_middleware_1.GetCallsStatusCode.CONFIRMED;
|
|
62
|
+
}
|
|
63
|
+
if (status === transaction_controller_1.TransactionStatus.failed) {
|
|
64
|
+
return hash
|
|
65
|
+
? eth_json_rpc_middleware_1.GetCallsStatusCode.REVERTED
|
|
66
|
+
: eth_json_rpc_middleware_1.GetCallsStatusCode.FAILED_OFFCHAIN;
|
|
67
|
+
}
|
|
68
|
+
if (status === transaction_controller_1.TransactionStatus.dropped) {
|
|
69
|
+
return eth_json_rpc_middleware_1.GetCallsStatusCode.REVERTED;
|
|
70
|
+
}
|
|
71
|
+
return eth_json_rpc_middleware_1.GetCallsStatusCode.PENDING;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=getCallsStatus.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.cjs","sourceRoot":"","sources":["../../src/methods/getCallsStatus.ts"],"names":[],"mappings":";;;AACA,+EAAuE;AACvE,qDAAoD;AAMpD,6EAAqE;AAGrE,gDAAyD;AAGzD;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC5B,SAA2B,EAC3B,EAAO;IAEP,MAAM,YAAY,GAAG,SAAS;SAC3B,IAAI,CAAC,gCAAgC,CAAC;SACtC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;IAElD,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE;QACzB,MAAM,IAAI,yBAAY,CACpB,4BAAgB,CAAC,eAAe,EAChC,0BAA0B,CAC3B,CAAC;KACH;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC;IACzD,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,YAAwD,CAAC;IAC3E,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAoB,CAAC;IAExD,MAAM,QAAQ,GAAqC,SAAS,IAAI;QAC9D;YACE,SAAS,EAAE,SAAS,CAAC,SAAgB;YACrC,WAAW,EAAE,SAAS,CAAC,WAAkB;YACzC,OAAO,EAAE,SAAS,CAAC,OAAc;YACjC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAkC,EAAE,EAAE,CAAC,CAAC;gBACtD,OAAO,EAAE,GAAG,CAAC,OAAc;gBAC3B,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,MAAM,EAAE,GAAG,CAAC,MAA0B;aACvC,CAAC,CAAC;YACH,MAAM,EAAE,SAAS,CAAC,MAAuB;YACzC,eAAe,EAAE,SAAS,CAAC,eAAe;SAC3C;KACF,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,mBAAO;QAChB,EAAE;QACF,OAAO;QACP,MAAM,EAAE,IAAI;QACZ,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC;AA5CD,wCA4CC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,eAAgC;IACrD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;IAEzC,IAAI,MAAM,KAAK,0CAAiB,CAAC,SAAS,EAAE;QAC1C,OAAO,4CAAkB,CAAC,SAAS,CAAC;KACrC;IAED,IAAI,MAAM,KAAK,0CAAiB,CAAC,MAAM,EAAE;QACvC,OAAO,IAAI;YACT,CAAC,CAAC,4CAAkB,CAAC,QAAQ;YAC7B,CAAC,CAAC,4CAAkB,CAAC,eAAe,CAAC;KACxC;IAED,IAAI,MAAM,KAAK,0CAAiB,CAAC,OAAO,EAAE;QACxC,OAAO,4CAAkB,CAAC,QAAQ,CAAC;KACpC;IAED,OAAO,4CAAkB,CAAC,OAAO,CAAC;AACpC,CAAC","sourcesContent":["import type { GetCallsStatusResult } from '@metamask/eth-json-rpc-middleware';\nimport { GetCallsStatusCode } from '@metamask/eth-json-rpc-middleware';\nimport { JsonRpcError } from '@metamask/rpc-errors';\nimport type {\n Log,\n TransactionMeta,\n TransactionReceipt,\n} from '@metamask/transaction-controller';\nimport { TransactionStatus } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { EIP5792ErrorCode, VERSION } from '../constants';\nimport type { EIP5792Messenger } from '../types';\n\n/**\n * Retrieves the status of a transaction batch by its ID.\n *\n * @param messenger - Messenger instance for controller communication.\n * @param id - The batch ID to look up (hexadecimal string).\n * @returns GetCallsStatusResult containing the batch status, receipts, and metadata.\n * @throws JsonRpcError with EIP5792ErrorCode.UnknownBundleId if no matching bundle is found.\n */\nexport function getCallsStatus(\n messenger: EIP5792Messenger,\n id: Hex,\n): GetCallsStatusResult {\n const transactions = messenger\n .call('TransactionController:getState')\n .transactions.filter((tx) => tx.batchId === id);\n\n if (!transactions?.length) {\n throw new JsonRpcError(\n EIP5792ErrorCode.UnknownBundleId,\n `No matching bundle found`,\n );\n }\n\n const transaction = transactions[0];\n const { chainId, txReceipt: rawTxReceipt } = transaction;\n const status = getStatusCode(transaction);\n const txReceipt = rawTxReceipt as Required<TransactionReceipt> | undefined;\n const logs = (txReceipt?.logs ?? []) as Required<Log>[];\n\n const receipts: GetCallsStatusResult['receipts'] = txReceipt && [\n {\n blockHash: txReceipt.blockHash as Hex,\n blockNumber: txReceipt.blockNumber as Hex,\n gasUsed: txReceipt.gasUsed as Hex,\n logs: logs.map((log: Required<Log> & { data: Hex }) => ({\n address: log.address as Hex,\n data: log.data,\n topics: log.topics as unknown as Hex[],\n })),\n status: txReceipt.status as '0x0' | '0x1',\n transactionHash: txReceipt.transactionHash,\n },\n ];\n\n return {\n version: VERSION,\n id,\n chainId,\n atomic: true, // Always atomic as we currently only support EIP-7702 batches\n status,\n receipts,\n };\n}\n\n/**\n * Maps transaction status to EIP-5792 call status codes.\n *\n * @param transactionMeta - The transaction metadata containing status and hash information.\n * @returns GetCallsStatusCode representing the current status of the transaction.\n */\nfunction getStatusCode(transactionMeta: TransactionMeta) {\n const { hash, status } = transactionMeta;\n\n if (status === TransactionStatus.confirmed) {\n return GetCallsStatusCode.CONFIRMED;\n }\n\n if (status === TransactionStatus.failed) {\n return hash\n ? GetCallsStatusCode.REVERTED\n : GetCallsStatusCode.FAILED_OFFCHAIN;\n }\n\n if (status === TransactionStatus.dropped) {\n return GetCallsStatusCode.REVERTED;\n }\n\n return GetCallsStatusCode.PENDING;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GetCallsStatusResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
|
+
import type { Hex } from "@metamask/utils";
|
|
3
|
+
import type { EIP5792Messenger } from "../types.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the status of a transaction batch by its ID.
|
|
6
|
+
*
|
|
7
|
+
* @param messenger - Messenger instance for controller communication.
|
|
8
|
+
* @param id - The batch ID to look up (hexadecimal string).
|
|
9
|
+
* @returns GetCallsStatusResult containing the batch status, receipts, and metadata.
|
|
10
|
+
* @throws JsonRpcError with EIP5792ErrorCode.UnknownBundleId if no matching bundle is found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCallsStatus(messenger: EIP5792Messenger, id: Hex): GetCallsStatusResult;
|
|
13
|
+
//# sourceMappingURL=getCallsStatus.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.d.cts","sourceRoot":"","sources":["../../src/methods/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,0CAA0C;AAS9E,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAiB;AAEjD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,gBAAgB,EAC3B,EAAE,EAAE,GAAG,GACN,oBAAoB,CAyCtB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GetCallsStatusResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
|
+
import type { Hex } from "@metamask/utils";
|
|
3
|
+
import type { EIP5792Messenger } from "../types.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the status of a transaction batch by its ID.
|
|
6
|
+
*
|
|
7
|
+
* @param messenger - Messenger instance for controller communication.
|
|
8
|
+
* @param id - The batch ID to look up (hexadecimal string).
|
|
9
|
+
* @returns GetCallsStatusResult containing the batch status, receipts, and metadata.
|
|
10
|
+
* @throws JsonRpcError with EIP5792ErrorCode.UnknownBundleId if no matching bundle is found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCallsStatus(messenger: EIP5792Messenger, id: Hex): GetCallsStatusResult;
|
|
13
|
+
//# sourceMappingURL=getCallsStatus.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.d.mts","sourceRoot":"","sources":["../../src/methods/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,0CAA0C;AAS9E,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAiB;AAEjD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,gBAAgB,EAC3B,EAAE,EAAE,GAAG,GACN,oBAAoB,CAyCtB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { GetCallsStatusCode } from "@metamask/eth-json-rpc-middleware";
|
|
2
|
+
import { JsonRpcError } from "@metamask/rpc-errors";
|
|
3
|
+
import { TransactionStatus } from "@metamask/transaction-controller";
|
|
4
|
+
import { EIP5792ErrorCode, VERSION } from "../constants.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the status of a transaction batch by its ID.
|
|
7
|
+
*
|
|
8
|
+
* @param messenger - Messenger instance for controller communication.
|
|
9
|
+
* @param id - The batch ID to look up (hexadecimal string).
|
|
10
|
+
* @returns GetCallsStatusResult containing the batch status, receipts, and metadata.
|
|
11
|
+
* @throws JsonRpcError with EIP5792ErrorCode.UnknownBundleId if no matching bundle is found.
|
|
12
|
+
*/
|
|
13
|
+
export function getCallsStatus(messenger, id) {
|
|
14
|
+
const transactions = messenger
|
|
15
|
+
.call('TransactionController:getState')
|
|
16
|
+
.transactions.filter((tx) => tx.batchId === id);
|
|
17
|
+
if (!transactions?.length) {
|
|
18
|
+
throw new JsonRpcError(EIP5792ErrorCode.UnknownBundleId, `No matching bundle found`);
|
|
19
|
+
}
|
|
20
|
+
const transaction = transactions[0];
|
|
21
|
+
const { chainId, txReceipt: rawTxReceipt } = transaction;
|
|
22
|
+
const status = getStatusCode(transaction);
|
|
23
|
+
const txReceipt = rawTxReceipt;
|
|
24
|
+
const logs = (txReceipt?.logs ?? []);
|
|
25
|
+
const receipts = txReceipt && [
|
|
26
|
+
{
|
|
27
|
+
blockHash: txReceipt.blockHash,
|
|
28
|
+
blockNumber: txReceipt.blockNumber,
|
|
29
|
+
gasUsed: txReceipt.gasUsed,
|
|
30
|
+
logs: logs.map((log) => ({
|
|
31
|
+
address: log.address,
|
|
32
|
+
data: log.data,
|
|
33
|
+
topics: log.topics,
|
|
34
|
+
})),
|
|
35
|
+
status: txReceipt.status,
|
|
36
|
+
transactionHash: txReceipt.transactionHash,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
return {
|
|
40
|
+
version: VERSION,
|
|
41
|
+
id,
|
|
42
|
+
chainId,
|
|
43
|
+
atomic: true,
|
|
44
|
+
status,
|
|
45
|
+
receipts,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Maps transaction status to EIP-5792 call status codes.
|
|
50
|
+
*
|
|
51
|
+
* @param transactionMeta - The transaction metadata containing status and hash information.
|
|
52
|
+
* @returns GetCallsStatusCode representing the current status of the transaction.
|
|
53
|
+
*/
|
|
54
|
+
function getStatusCode(transactionMeta) {
|
|
55
|
+
const { hash, status } = transactionMeta;
|
|
56
|
+
if (status === TransactionStatus.confirmed) {
|
|
57
|
+
return GetCallsStatusCode.CONFIRMED;
|
|
58
|
+
}
|
|
59
|
+
if (status === TransactionStatus.failed) {
|
|
60
|
+
return hash
|
|
61
|
+
? GetCallsStatusCode.REVERTED
|
|
62
|
+
: GetCallsStatusCode.FAILED_OFFCHAIN;
|
|
63
|
+
}
|
|
64
|
+
if (status === TransactionStatus.dropped) {
|
|
65
|
+
return GetCallsStatusCode.REVERTED;
|
|
66
|
+
}
|
|
67
|
+
return GetCallsStatusCode.PENDING;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=getCallsStatus.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.mjs","sourceRoot":"","sources":["../../src/methods/getCallsStatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,0CAA0C;AACvE,OAAO,EAAE,YAAY,EAAE,6BAA6B;AAMpD,OAAO,EAAE,iBAAiB,EAAE,yCAAyC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,yBAAqB;AAGzD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,SAA2B,EAC3B,EAAO;IAEP,MAAM,YAAY,GAAG,SAAS;SAC3B,IAAI,CAAC,gCAAgC,CAAC;SACtC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;IAElD,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE;QACzB,MAAM,IAAI,YAAY,CACpB,gBAAgB,CAAC,eAAe,EAChC,0BAA0B,CAC3B,CAAC;KACH;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC;IACzD,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,YAAwD,CAAC;IAC3E,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAoB,CAAC;IAExD,MAAM,QAAQ,GAAqC,SAAS,IAAI;QAC9D;YACE,SAAS,EAAE,SAAS,CAAC,SAAgB;YACrC,WAAW,EAAE,SAAS,CAAC,WAAkB;YACzC,OAAO,EAAE,SAAS,CAAC,OAAc;YACjC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAkC,EAAE,EAAE,CAAC,CAAC;gBACtD,OAAO,EAAE,GAAG,CAAC,OAAc;gBAC3B,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,MAAM,EAAE,GAAG,CAAC,MAA0B;aACvC,CAAC,CAAC;YACH,MAAM,EAAE,SAAS,CAAC,MAAuB;YACzC,eAAe,EAAE,SAAS,CAAC,eAAe;SAC3C;KACF,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,EAAE;QACF,OAAO;QACP,MAAM,EAAE,IAAI;QACZ,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,eAAgC;IACrD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;IAEzC,IAAI,MAAM,KAAK,iBAAiB,CAAC,SAAS,EAAE;QAC1C,OAAO,kBAAkB,CAAC,SAAS,CAAC;KACrC;IAED,IAAI,MAAM,KAAK,iBAAiB,CAAC,MAAM,EAAE;QACvC,OAAO,IAAI;YACT,CAAC,CAAC,kBAAkB,CAAC,QAAQ;YAC7B,CAAC,CAAC,kBAAkB,CAAC,eAAe,CAAC;KACxC;IAED,IAAI,MAAM,KAAK,iBAAiB,CAAC,OAAO,EAAE;QACxC,OAAO,kBAAkB,CAAC,QAAQ,CAAC;KACpC;IAED,OAAO,kBAAkB,CAAC,OAAO,CAAC;AACpC,CAAC","sourcesContent":["import type { GetCallsStatusResult } from '@metamask/eth-json-rpc-middleware';\nimport { GetCallsStatusCode } from '@metamask/eth-json-rpc-middleware';\nimport { JsonRpcError } from '@metamask/rpc-errors';\nimport type {\n Log,\n TransactionMeta,\n TransactionReceipt,\n} from '@metamask/transaction-controller';\nimport { TransactionStatus } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { EIP5792ErrorCode, VERSION } from '../constants';\nimport type { EIP5792Messenger } from '../types';\n\n/**\n * Retrieves the status of a transaction batch by its ID.\n *\n * @param messenger - Messenger instance for controller communication.\n * @param id - The batch ID to look up (hexadecimal string).\n * @returns GetCallsStatusResult containing the batch status, receipts, and metadata.\n * @throws JsonRpcError with EIP5792ErrorCode.UnknownBundleId if no matching bundle is found.\n */\nexport function getCallsStatus(\n messenger: EIP5792Messenger,\n id: Hex,\n): GetCallsStatusResult {\n const transactions = messenger\n .call('TransactionController:getState')\n .transactions.filter((tx) => tx.batchId === id);\n\n if (!transactions?.length) {\n throw new JsonRpcError(\n EIP5792ErrorCode.UnknownBundleId,\n `No matching bundle found`,\n );\n }\n\n const transaction = transactions[0];\n const { chainId, txReceipt: rawTxReceipt } = transaction;\n const status = getStatusCode(transaction);\n const txReceipt = rawTxReceipt as Required<TransactionReceipt> | undefined;\n const logs = (txReceipt?.logs ?? []) as Required<Log>[];\n\n const receipts: GetCallsStatusResult['receipts'] = txReceipt && [\n {\n blockHash: txReceipt.blockHash as Hex,\n blockNumber: txReceipt.blockNumber as Hex,\n gasUsed: txReceipt.gasUsed as Hex,\n logs: logs.map((log: Required<Log> & { data: Hex }) => ({\n address: log.address as Hex,\n data: log.data,\n topics: log.topics as unknown as Hex[],\n })),\n status: txReceipt.status as '0x0' | '0x1',\n transactionHash: txReceipt.transactionHash,\n },\n ];\n\n return {\n version: VERSION,\n id,\n chainId,\n atomic: true, // Always atomic as we currently only support EIP-7702 batches\n status,\n receipts,\n };\n}\n\n/**\n * Maps transaction status to EIP-5792 call status codes.\n *\n * @param transactionMeta - The transaction metadata containing status and hash information.\n * @returns GetCallsStatusCode representing the current status of the transaction.\n */\nfunction getStatusCode(transactionMeta: TransactionMeta) {\n const { hash, status } = transactionMeta;\n\n if (status === TransactionStatus.confirmed) {\n return GetCallsStatusCode.CONFIRMED;\n }\n\n if (status === TransactionStatus.failed) {\n return hash\n ? GetCallsStatusCode.REVERTED\n : GetCallsStatusCode.FAILED_OFFCHAIN;\n }\n\n if (status === TransactionStatus.dropped) {\n return GetCallsStatusCode.REVERTED;\n }\n\n return GetCallsStatusCode.PENDING;\n}\n"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCapabilities = void 0;
|
|
4
|
+
const constants_1 = require("../constants.cjs");
|
|
5
|
+
const utils_1 = require("../utils.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves the capabilities for atomic transactions on specified chains.
|
|
8
|
+
*
|
|
9
|
+
* @param hooks - Object containing required controller hooks and utilities.
|
|
10
|
+
* @param messenger - Messenger instance for controller communication.
|
|
11
|
+
* @param address - The account address to check capabilities for.
|
|
12
|
+
* @param chainIds - Array of chain IDs to check capabilities for (if undefined, checks all configured networks).
|
|
13
|
+
* @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.
|
|
14
|
+
*/
|
|
15
|
+
async function getCapabilities(hooks, messenger, address, chainIds) {
|
|
16
|
+
const { getDismissSmartAccountSuggestionEnabled, getIsSmartTransaction, isAtomicBatchSupported, isRelaySupported, getSendBundleSupportedChains, } = hooks;
|
|
17
|
+
let chainIdsNormalized = chainIds?.map((chainId) => chainId.toLowerCase());
|
|
18
|
+
if (!chainIdsNormalized?.length) {
|
|
19
|
+
const networkConfigurations = messenger.call('NetworkController:getState').networkConfigurationsByChainId;
|
|
20
|
+
chainIdsNormalized = Object.keys(networkConfigurations);
|
|
21
|
+
}
|
|
22
|
+
const batchSupport = await isAtomicBatchSupported({
|
|
23
|
+
address,
|
|
24
|
+
chainIds: chainIdsNormalized,
|
|
25
|
+
});
|
|
26
|
+
const alternateGasFeesAcc = await getAlternateGasFeesCapability(chainIdsNormalized, batchSupport, getIsSmartTransaction, isRelaySupported, getSendBundleSupportedChains, messenger);
|
|
27
|
+
return chainIdsNormalized.reduce((acc, chainId) => {
|
|
28
|
+
const chainBatchSupport = (batchSupport.find(({ chainId: batchChainId }) => batchChainId === chainId) ?? {});
|
|
29
|
+
const { delegationAddress, isSupported, upgradeContractAddress } = chainBatchSupport;
|
|
30
|
+
const isUpgradeDisabled = getDismissSmartAccountSuggestionEnabled();
|
|
31
|
+
let isSupportedAccount = false;
|
|
32
|
+
try {
|
|
33
|
+
const keyringType = (0, utils_1.getAccountKeyringType)(address, messenger);
|
|
34
|
+
isSupportedAccount = constants_1.KEYRING_TYPES_SUPPORTING_7702.includes(keyringType);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Intentionally empty
|
|
38
|
+
}
|
|
39
|
+
const canUpgrade = !isUpgradeDisabled &&
|
|
40
|
+
upgradeContractAddress &&
|
|
41
|
+
!delegationAddress &&
|
|
42
|
+
isSupportedAccount;
|
|
43
|
+
if (!isSupported && !canUpgrade) {
|
|
44
|
+
return acc;
|
|
45
|
+
}
|
|
46
|
+
const status = isSupported ? 'supported' : 'ready';
|
|
47
|
+
if (acc[chainId] === undefined) {
|
|
48
|
+
acc[chainId] = {};
|
|
49
|
+
}
|
|
50
|
+
acc[chainId].atomic = {
|
|
51
|
+
status,
|
|
52
|
+
};
|
|
53
|
+
return acc;
|
|
54
|
+
}, alternateGasFeesAcc);
|
|
55
|
+
}
|
|
56
|
+
exports.getCapabilities = getCapabilities;
|
|
57
|
+
/**
|
|
58
|
+
* Determines alternate gas fees capability for the specified chains.
|
|
59
|
+
*
|
|
60
|
+
* @param chainIds - Array of chain IDs to check for alternate gas fees support.
|
|
61
|
+
* @param batchSupport - Information about atomic batch support for each chain.
|
|
62
|
+
* @param getIsSmartTransaction - Function to check if a chain supports smart transactions.
|
|
63
|
+
* @param isRelaySupported - Function to check if relay is supported on a chain.
|
|
64
|
+
* @param getSendBundleSupportedChains - Function to get chains that support send bundle.
|
|
65
|
+
* @param messenger - Messenger instance for controller communication.
|
|
66
|
+
* @returns Promise resolving to GetCapabilitiesResult with alternate gas fees information.
|
|
67
|
+
*/
|
|
68
|
+
async function getAlternateGasFeesCapability(chainIds, batchSupport, getIsSmartTransaction, isRelaySupported, getSendBundleSupportedChains, messenger) {
|
|
69
|
+
const simulationEnabled = messenger.call('PreferencesController:getState').useTransactionSimulations;
|
|
70
|
+
const relaySupportedChains = await Promise.all(batchSupport
|
|
71
|
+
.map(({ chainId }) => chainId)
|
|
72
|
+
.map((chainId) => isRelaySupported(chainId)));
|
|
73
|
+
const sendBundleSupportedChains = await getSendBundleSupportedChains(chainIds);
|
|
74
|
+
const updatedBatchSupport = batchSupport.map((support, index) => ({
|
|
75
|
+
...support,
|
|
76
|
+
relaySupportedForChain: relaySupportedChains[index],
|
|
77
|
+
}));
|
|
78
|
+
return chainIds.reduce((acc, chainId) => {
|
|
79
|
+
const chainBatchSupport = (updatedBatchSupport.find(({ chainId: batchChainId }) => batchChainId === chainId) ?? {});
|
|
80
|
+
const { isSupported = false, relaySupportedForChain } = chainBatchSupport;
|
|
81
|
+
const isSmartTransaction = getIsSmartTransaction(chainId);
|
|
82
|
+
const isSendBundleSupported = sendBundleSupportedChains[chainId] ?? false;
|
|
83
|
+
const alternateGasFees = simulationEnabled &&
|
|
84
|
+
((isSmartTransaction && isSendBundleSupported) ||
|
|
85
|
+
(isSupported && relaySupportedForChain));
|
|
86
|
+
if (alternateGasFees) {
|
|
87
|
+
acc[chainId] = {
|
|
88
|
+
alternateGasFees: {
|
|
89
|
+
supported: true,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return acc;
|
|
94
|
+
}, {});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=getCapabilities.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCapabilities.cjs","sourceRoot":"","sources":["../../src/methods/getCapabilities.ts"],"names":[],"mappings":"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","sourcesContent":["import type { GetCapabilitiesResult } from '@metamask/eth-json-rpc-middleware';\nimport type {\n IsAtomicBatchSupportedResult,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { KEYRING_TYPES_SUPPORTING_7702 } from '../constants';\nimport type { EIP5792Messenger } from '../types';\nimport { getAccountKeyringType } from '../utils';\n\n/**\n * Type definition for required controller hooks and utilities of {@link getCapabilities}\n */\nexport type GetCapabilitiesHooks = {\n /** Function to check if smart account suggestions are disabled */\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n /** Function to check if a chain supports smart transactions */\n getIsSmartTransaction: (chainId: Hex) => boolean;\n /** Function to check if atomic batching is supported */\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n /** Function to check if relay is supported on a chain */\n isRelaySupported: (chainId: Hex) => Promise<boolean>;\n /** Function to get chains that support send bundle */\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>;\n};\n\n/**\n * Retrieves the capabilities for atomic transactions on specified chains.\n *\n * @param hooks - Object containing required controller hooks and utilities.\n * @param messenger - Messenger instance for controller communication.\n * @param address - The account address to check capabilities for.\n * @param chainIds - Array of chain IDs to check capabilities for (if undefined, checks all configured networks).\n * @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.\n */\nexport async function getCapabilities(\n hooks: GetCapabilitiesHooks,\n messenger: EIP5792Messenger,\n address: Hex,\n chainIds: Hex[] | undefined,\n) {\n const {\n getDismissSmartAccountSuggestionEnabled,\n getIsSmartTransaction,\n isAtomicBatchSupported,\n isRelaySupported,\n getSendBundleSupportedChains,\n } = hooks;\n\n let chainIdsNormalized = chainIds?.map(\n (chainId) => chainId.toLowerCase() as Hex,\n );\n\n if (!chainIdsNormalized?.length) {\n const networkConfigurations = messenger.call(\n 'NetworkController:getState',\n ).networkConfigurationsByChainId;\n chainIdsNormalized = Object.keys(networkConfigurations) as Hex[];\n }\n\n const batchSupport = await isAtomicBatchSupported({\n address,\n chainIds: chainIdsNormalized,\n });\n\n const alternateGasFeesAcc = await getAlternateGasFeesCapability(\n chainIdsNormalized,\n batchSupport,\n getIsSmartTransaction,\n isRelaySupported,\n getSendBundleSupportedChains,\n messenger,\n );\n\n return chainIdsNormalized.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (batchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n isRelaySupported: boolean;\n };\n\n const { delegationAddress, isSupported, upgradeContractAddress } =\n chainBatchSupport;\n\n const isUpgradeDisabled = getDismissSmartAccountSuggestionEnabled();\n let isSupportedAccount = false;\n\n try {\n const keyringType = getAccountKeyringType(address, messenger);\n isSupportedAccount = KEYRING_TYPES_SUPPORTING_7702.includes(keyringType);\n } catch {\n // Intentionally empty\n }\n\n const canUpgrade =\n !isUpgradeDisabled &&\n upgradeContractAddress &&\n !delegationAddress &&\n isSupportedAccount;\n\n if (!isSupported && !canUpgrade) {\n return acc;\n }\n\n const status = isSupported ? 'supported' : 'ready';\n\n if (acc[chainId as Hex] === undefined) {\n acc[chainId as Hex] = {};\n }\n\n acc[chainId as Hex].atomic = {\n status,\n };\n\n return acc;\n }, alternateGasFeesAcc);\n}\n\n/**\n * Determines alternate gas fees capability for the specified chains.\n *\n * @param chainIds - Array of chain IDs to check for alternate gas fees support.\n * @param batchSupport - Information about atomic batch support for each chain.\n * @param getIsSmartTransaction - Function to check if a chain supports smart transactions.\n * @param isRelaySupported - Function to check if relay is supported on a chain.\n * @param getSendBundleSupportedChains - Function to get chains that support send bundle.\n * @param messenger - Messenger instance for controller communication.\n * @returns Promise resolving to GetCapabilitiesResult with alternate gas fees information.\n */\nasync function getAlternateGasFeesCapability(\n chainIds: Hex[],\n batchSupport: IsAtomicBatchSupportedResult,\n getIsSmartTransaction: (chainId: Hex) => boolean,\n isRelaySupported: (chainId: Hex) => Promise<boolean>,\n getSendBundleSupportedChains: (\n chainIds: Hex[],\n ) => Promise<Record<string, boolean>>,\n messenger: EIP5792Messenger,\n) {\n const simulationEnabled = messenger.call(\n 'PreferencesController:getState',\n ).useTransactionSimulations;\n\n const relaySupportedChains = await Promise.all(\n batchSupport\n .map(({ chainId }) => chainId)\n .map((chainId) => isRelaySupported(chainId)),\n );\n\n const sendBundleSupportedChains =\n await getSendBundleSupportedChains(chainIds);\n\n const updatedBatchSupport = batchSupport.map((support, index) => ({\n ...support,\n relaySupportedForChain: relaySupportedChains[index],\n }));\n\n return chainIds.reduce<GetCapabilitiesResult>((acc, chainId) => {\n const chainBatchSupport = (updatedBatchSupport.find(\n ({ chainId: batchChainId }) => batchChainId === chainId,\n ) ?? {}) as IsAtomicBatchSupportedResultEntry & {\n relaySupportedForChain: boolean;\n };\n\n const { isSupported = false, relaySupportedForChain } = chainBatchSupport;\n\n const isSmartTransaction = getIsSmartTransaction(chainId);\n const isSendBundleSupported = sendBundleSupportedChains[chainId] ?? false;\n\n const alternateGasFees =\n simulationEnabled &&\n ((isSmartTransaction && isSendBundleSupported) ||\n (isSupported && relaySupportedForChain));\n\n if (alternateGasFees) {\n acc[chainId as Hex] = {\n alternateGasFees: {\n supported: true,\n },\n };\n }\n\n return acc;\n }, {});\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GetCapabilitiesResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
|
+
import type { TransactionController } from "@metamask/transaction-controller";
|
|
3
|
+
import type { Hex } from "@metamask/utils";
|
|
4
|
+
import type { EIP5792Messenger } from "../types.cjs";
|
|
5
|
+
/**
|
|
6
|
+
* Type definition for required controller hooks and utilities of {@link getCapabilities}
|
|
7
|
+
*/
|
|
8
|
+
export type GetCapabilitiesHooks = {
|
|
9
|
+
/** Function to check if smart account suggestions are disabled */
|
|
10
|
+
getDismissSmartAccountSuggestionEnabled: () => boolean;
|
|
11
|
+
/** Function to check if a chain supports smart transactions */
|
|
12
|
+
getIsSmartTransaction: (chainId: Hex) => boolean;
|
|
13
|
+
/** Function to check if atomic batching is supported */
|
|
14
|
+
isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];
|
|
15
|
+
/** Function to check if relay is supported on a chain */
|
|
16
|
+
isRelaySupported: (chainId: Hex) => Promise<boolean>;
|
|
17
|
+
/** Function to get chains that support send bundle */
|
|
18
|
+
getSendBundleSupportedChains: (chainIds: Hex[]) => Promise<Record<string, boolean>>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the capabilities for atomic transactions on specified chains.
|
|
22
|
+
*
|
|
23
|
+
* @param hooks - Object containing required controller hooks and utilities.
|
|
24
|
+
* @param messenger - Messenger instance for controller communication.
|
|
25
|
+
* @param address - The account address to check capabilities for.
|
|
26
|
+
* @param chainIds - Array of chain IDs to check capabilities for (if undefined, checks all configured networks).
|
|
27
|
+
* @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getCapabilities(hooks: GetCapabilitiesHooks, messenger: EIP5792Messenger, address: Hex, chainIds: Hex[] | undefined): Promise<GetCapabilitiesResult>;
|
|
30
|
+
//# sourceMappingURL=getCapabilities.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCapabilities.d.cts","sourceRoot":"","sources":["../../src/methods/getCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,0CAA0C;AAC/E,OAAO,KAAK,EAGV,qBAAqB,EACtB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAiB;AAGjD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,kEAAkE;IAClE,uCAAuC,EAAE,MAAM,OAAO,CAAC;IACvD,+DAA+D;IAC/D,qBAAqB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;IACjD,wDAAwD;IACxD,sBAAsB,EAAE,qBAAqB,CAAC,wBAAwB,CAAC,CAAC;IACxE,yDAAyD;IACzD,gBAAgB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,sDAAsD;IACtD,4BAA4B,EAAE,CAC5B,QAAQ,EAAE,GAAG,EAAE,KACZ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,oBAAoB,EAC3B,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,GAAG,EAAE,GAAG,SAAS,kCA6E5B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GetCapabilitiesResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
|
+
import type { TransactionController } from "@metamask/transaction-controller";
|
|
3
|
+
import type { Hex } from "@metamask/utils";
|
|
4
|
+
import type { EIP5792Messenger } from "../types.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* Type definition for required controller hooks and utilities of {@link getCapabilities}
|
|
7
|
+
*/
|
|
8
|
+
export type GetCapabilitiesHooks = {
|
|
9
|
+
/** Function to check if smart account suggestions are disabled */
|
|
10
|
+
getDismissSmartAccountSuggestionEnabled: () => boolean;
|
|
11
|
+
/** Function to check if a chain supports smart transactions */
|
|
12
|
+
getIsSmartTransaction: (chainId: Hex) => boolean;
|
|
13
|
+
/** Function to check if atomic batching is supported */
|
|
14
|
+
isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];
|
|
15
|
+
/** Function to check if relay is supported on a chain */
|
|
16
|
+
isRelaySupported: (chainId: Hex) => Promise<boolean>;
|
|
17
|
+
/** Function to get chains that support send bundle */
|
|
18
|
+
getSendBundleSupportedChains: (chainIds: Hex[]) => Promise<Record<string, boolean>>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the capabilities for atomic transactions on specified chains.
|
|
22
|
+
*
|
|
23
|
+
* @param hooks - Object containing required controller hooks and utilities.
|
|
24
|
+
* @param messenger - Messenger instance for controller communication.
|
|
25
|
+
* @param address - The account address to check capabilities for.
|
|
26
|
+
* @param chainIds - Array of chain IDs to check capabilities for (if undefined, checks all configured networks).
|
|
27
|
+
* @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getCapabilities(hooks: GetCapabilitiesHooks, messenger: EIP5792Messenger, address: Hex, chainIds: Hex[] | undefined): Promise<GetCapabilitiesResult>;
|
|
30
|
+
//# sourceMappingURL=getCapabilities.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCapabilities.d.mts","sourceRoot":"","sources":["../../src/methods/getCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,0CAA0C;AAC/E,OAAO,KAAK,EAGV,qBAAqB,EACtB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAiB;AAGjD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,kEAAkE;IAClE,uCAAuC,EAAE,MAAM,OAAO,CAAC;IACvD,+DAA+D;IAC/D,qBAAqB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;IACjD,wDAAwD;IACxD,sBAAsB,EAAE,qBAAqB,CAAC,wBAAwB,CAAC,CAAC;IACxE,yDAAyD;IACzD,gBAAgB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,sDAAsD;IACtD,4BAA4B,EAAE,CAC5B,QAAQ,EAAE,GAAG,EAAE,KACZ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,oBAAoB,EAC3B,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,GAAG,EAAE,GAAG,SAAS,kCA6E5B"}
|