@metamask/eip-5792-middleware 1.0.0 → 1.1.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 +8 -1
- package/dist/constants.cjs +10 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +7 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +7 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +9 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/{methods → hooks}/getCallsStatus.cjs +5 -6
- package/dist/hooks/getCallsStatus.cjs.map +1 -0
- package/dist/{methods → hooks}/getCallsStatus.d.cts +1 -2
- package/dist/hooks/getCallsStatus.d.cts.map +1 -0
- package/dist/{methods → hooks}/getCallsStatus.d.mts +1 -2
- package/dist/hooks/getCallsStatus.d.mts.map +1 -0
- package/dist/{methods → hooks}/getCallsStatus.mjs +1 -2
- package/dist/hooks/getCallsStatus.mjs.map +1 -0
- package/dist/hooks/getCapabilities.cjs.map +1 -0
- package/dist/{methods → hooks}/getCapabilities.d.cts +1 -2
- package/dist/hooks/getCapabilities.d.cts.map +1 -0
- package/dist/{methods → hooks}/getCapabilities.d.mts +1 -2
- package/dist/hooks/getCapabilities.d.mts.map +1 -0
- package/dist/hooks/getCapabilities.mjs.map +1 -0
- package/dist/hooks/processSendCalls.cjs.map +1 -0
- package/dist/{methods → hooks}/processSendCalls.d.cts +2 -3
- package/dist/hooks/processSendCalls.d.cts.map +1 -0
- package/dist/{methods → hooks}/processSendCalls.d.mts +2 -3
- package/dist/hooks/processSendCalls.d.mts.map +1 -0
- package/dist/hooks/processSendCalls.mjs.map +1 -0
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/dist/methods/wallet_getCallsStatus.cjs +24 -0
- package/dist/methods/wallet_getCallsStatus.cjs.map +1 -0
- package/dist/methods/wallet_getCallsStatus.d.cts +14 -0
- package/dist/methods/wallet_getCallsStatus.d.cts.map +1 -0
- package/dist/methods/wallet_getCallsStatus.d.mts +14 -0
- package/dist/methods/wallet_getCallsStatus.d.mts.map +1 -0
- package/dist/methods/wallet_getCallsStatus.mjs +20 -0
- package/dist/methods/wallet_getCallsStatus.mjs.map +1 -0
- package/dist/methods/wallet_getCapabilities.cjs +30 -0
- package/dist/methods/wallet_getCapabilities.cjs.map +1 -0
- package/dist/methods/wallet_getCapabilities.d.cts +16 -0
- package/dist/methods/wallet_getCapabilities.d.cts.map +1 -0
- package/dist/methods/wallet_getCapabilities.d.mts +16 -0
- package/dist/methods/wallet_getCapabilities.d.mts.map +1 -0
- package/dist/methods/wallet_getCapabilities.mjs +26 -0
- package/dist/methods/wallet_getCapabilities.mjs.map +1 -0
- package/dist/methods/wallet_sendCalls.cjs +34 -0
- package/dist/methods/wallet_sendCalls.cjs.map +1 -0
- package/dist/methods/wallet_sendCalls.d.cts +16 -0
- package/dist/methods/wallet_sendCalls.d.cts.map +1 -0
- package/dist/methods/wallet_sendCalls.d.mts +16 -0
- package/dist/methods/wallet_sendCalls.d.mts.map +1 -0
- package/dist/methods/wallet_sendCalls.mjs +30 -0
- package/dist/methods/wallet_sendCalls.mjs.map +1 -0
- package/dist/types.cjs +30 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +57 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +57 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +29 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.cjs +70 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +31 -1
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +31 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +67 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +3 -1
- package/dist/methods/getCallsStatus.cjs.map +0 -1
- package/dist/methods/getCallsStatus.d.cts.map +0 -1
- package/dist/methods/getCallsStatus.d.mts.map +0 -1
- package/dist/methods/getCallsStatus.mjs.map +0 -1
- package/dist/methods/getCapabilities.cjs.map +0 -1
- package/dist/methods/getCapabilities.d.cts.map +0 -1
- package/dist/methods/getCapabilities.d.mts.map +0 -1
- package/dist/methods/getCapabilities.mjs.map +0 -1
- package/dist/methods/processSendCalls.cjs.map +0 -1
- package/dist/methods/processSendCalls.d.cts.map +0 -1
- package/dist/methods/processSendCalls.d.mts.map +0 -1
- package/dist/methods/processSendCalls.mjs.map +0 -1
- /package/dist/{methods → hooks}/getCapabilities.cjs +0 -0
- /package/dist/{methods → hooks}/getCapabilities.mjs +0 -0
- /package/dist/{methods → hooks}/processSendCalls.cjs +0 -0
- /package/dist/{methods → hooks}/processSendCalls.mjs +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,11 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add and export EIP-5792 RPC method handler middlewares and utility types ([#6477](https://github.com/MetaMask/core/pull/6477))
|
|
15
|
+
|
|
10
16
|
## [1.0.0]
|
|
11
17
|
|
|
12
18
|
### Added
|
|
13
19
|
|
|
14
20
|
- Initial release ([#6458](https://github.com/MetaMask/core/pull/6458))
|
|
15
21
|
|
|
16
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/eip-5792-middleware@1.
|
|
22
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/eip-5792-middleware@1.1.0...HEAD
|
|
23
|
+
[1.1.0]: https://github.com/MetaMask/core/compare/@metamask/eip-5792-middleware@1.0.0...@metamask/eip-5792-middleware@1.1.0
|
|
17
24
|
[1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/eip-5792-middleware@1.0.0
|
package/dist/constants.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EIP5792ErrorCode = exports.MessageType = exports.KEYRING_TYPES_SUPPORTING_7702 = exports.VERSION = void 0;
|
|
3
|
+
exports.GetCallsStatusCode = exports.EIP5792ErrorCode = exports.MessageType = exports.KEYRING_TYPES_SUPPORTING_7702 = exports.VERSION = void 0;
|
|
4
4
|
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
5
5
|
exports.VERSION = '2.0.0';
|
|
6
6
|
exports.KEYRING_TYPES_SUPPORTING_7702 = [
|
|
@@ -19,4 +19,13 @@ var EIP5792ErrorCode;
|
|
|
19
19
|
EIP5792ErrorCode[EIP5792ErrorCode["UnknownBundleId"] = 5730] = "UnknownBundleId";
|
|
20
20
|
EIP5792ErrorCode[EIP5792ErrorCode["RejectedUpgrade"] = 5750] = "RejectedUpgrade";
|
|
21
21
|
})(EIP5792ErrorCode || (exports.EIP5792ErrorCode = EIP5792ErrorCode = {}));
|
|
22
|
+
// wallet_getCallStatus
|
|
23
|
+
var GetCallsStatusCode;
|
|
24
|
+
(function (GetCallsStatusCode) {
|
|
25
|
+
GetCallsStatusCode[GetCallsStatusCode["PENDING"] = 100] = "PENDING";
|
|
26
|
+
GetCallsStatusCode[GetCallsStatusCode["CONFIRMED"] = 200] = "CONFIRMED";
|
|
27
|
+
GetCallsStatusCode[GetCallsStatusCode["FAILED_OFFCHAIN"] = 400] = "FAILED_OFFCHAIN";
|
|
28
|
+
GetCallsStatusCode[GetCallsStatusCode["REVERTED"] = 500] = "REVERTED";
|
|
29
|
+
GetCallsStatusCode[GetCallsStatusCode["REVERTED_PARTIAL"] = 600] = "REVERTED_PARTIAL";
|
|
30
|
+
})(GetCallsStatusCode || (exports.GetCallsStatusCode = GetCallsStatusCode = {}));
|
|
22
31
|
//# sourceMappingURL=constants.cjs.map
|
package/dist/constants.cjs.map
CHANGED
|
@@ -1 +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"]}
|
|
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;AAED,uBAAuB;AACvB,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,mEAAa,CAAA;IACb,uEAAe,CAAA;IACf,mFAAqB,CAAA;IACrB,qEAAc,CAAA;IACd,qFAAsB,CAAA;AACxB,CAAC,EANW,kBAAkB,kCAAlB,kBAAkB,QAM7B","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\n// wallet_getCallStatus\nexport enum GetCallsStatusCode {\n PENDING = 100,\n CONFIRMED = 200,\n FAILED_OFFCHAIN = 400,\n REVERTED = 500,\n REVERTED_PARTIAL = 600,\n}\n"]}
|
package/dist/constants.d.cts
CHANGED
|
@@ -10,4 +10,11 @@ export declare enum EIP5792ErrorCode {
|
|
|
10
10
|
UnknownBundleId = 5730,
|
|
11
11
|
RejectedUpgrade = 5750
|
|
12
12
|
}
|
|
13
|
+
export declare enum GetCallsStatusCode {
|
|
14
|
+
PENDING = 100,
|
|
15
|
+
CONFIRMED = 200,
|
|
16
|
+
FAILED_OFFCHAIN = 400,
|
|
17
|
+
REVERTED = 500,
|
|
18
|
+
REVERTED_PARTIAL = 600
|
|
19
|
+
}
|
|
13
20
|
//# sourceMappingURL=constants.d.cts.map
|
package/dist/constants.d.cts.map
CHANGED
|
@@ -1 +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"}
|
|
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;AAGD,oBAAY,kBAAkB;IAC5B,OAAO,MAAM;IACb,SAAS,MAAM;IACf,eAAe,MAAM;IACrB,QAAQ,MAAM;IACd,gBAAgB,MAAM;CACvB"}
|
package/dist/constants.d.mts
CHANGED
|
@@ -10,4 +10,11 @@ export declare enum EIP5792ErrorCode {
|
|
|
10
10
|
UnknownBundleId = 5730,
|
|
11
11
|
RejectedUpgrade = 5750
|
|
12
12
|
}
|
|
13
|
+
export declare enum GetCallsStatusCode {
|
|
14
|
+
PENDING = 100,
|
|
15
|
+
CONFIRMED = 200,
|
|
16
|
+
FAILED_OFFCHAIN = 400,
|
|
17
|
+
REVERTED = 500,
|
|
18
|
+
REVERTED_PARTIAL = 600
|
|
19
|
+
}
|
|
13
20
|
//# sourceMappingURL=constants.d.mts.map
|
package/dist/constants.d.mts.map
CHANGED
|
@@ -1 +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"}
|
|
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;AAGD,oBAAY,kBAAkB;IAC5B,OAAO,MAAM;IACb,SAAS,MAAM;IACf,eAAe,MAAM;IACrB,QAAQ,MAAM;IACd,gBAAgB,MAAM;CACvB"}
|
package/dist/constants.mjs
CHANGED
|
@@ -16,4 +16,13 @@ export var EIP5792ErrorCode;
|
|
|
16
16
|
EIP5792ErrorCode[EIP5792ErrorCode["UnknownBundleId"] = 5730] = "UnknownBundleId";
|
|
17
17
|
EIP5792ErrorCode[EIP5792ErrorCode["RejectedUpgrade"] = 5750] = "RejectedUpgrade";
|
|
18
18
|
})(EIP5792ErrorCode || (EIP5792ErrorCode = {}));
|
|
19
|
+
// wallet_getCallStatus
|
|
20
|
+
export var GetCallsStatusCode;
|
|
21
|
+
(function (GetCallsStatusCode) {
|
|
22
|
+
GetCallsStatusCode[GetCallsStatusCode["PENDING"] = 100] = "PENDING";
|
|
23
|
+
GetCallsStatusCode[GetCallsStatusCode["CONFIRMED"] = 200] = "CONFIRMED";
|
|
24
|
+
GetCallsStatusCode[GetCallsStatusCode["FAILED_OFFCHAIN"] = 400] = "FAILED_OFFCHAIN";
|
|
25
|
+
GetCallsStatusCode[GetCallsStatusCode["REVERTED"] = 500] = "REVERTED";
|
|
26
|
+
GetCallsStatusCode[GetCallsStatusCode["REVERTED_PARTIAL"] = 600] = "REVERTED_PARTIAL";
|
|
27
|
+
})(GetCallsStatusCode || (GetCallsStatusCode = {}));
|
|
19
28
|
//# sourceMappingURL=constants.mjs.map
|
package/dist/constants.mjs.map
CHANGED
|
@@ -1 +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"]}
|
|
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;AAED,uBAAuB;AACvB,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,mEAAa,CAAA;IACb,uEAAe,CAAA;IACf,mFAAqB,CAAA;IACrB,qEAAc,CAAA;IACd,qFAAsB,CAAA;AACxB,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B","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\n// wallet_getCallStatus\nexport enum GetCallsStatusCode {\n PENDING = 100,\n CONFIRMED = 200,\n FAILED_OFFCHAIN = 400,\n REVERTED = 500,\n REVERTED_PARTIAL = 600,\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCallsStatus = void 0;
|
|
4
|
-
const eth_json_rpc_middleware_1 = require("@metamask/eth-json-rpc-middleware");
|
|
5
4
|
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
6
5
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
7
6
|
const constants_1 = require("../constants.cjs");
|
|
@@ -58,16 +57,16 @@ exports.getCallsStatus = getCallsStatus;
|
|
|
58
57
|
function getStatusCode(transactionMeta) {
|
|
59
58
|
const { hash, status } = transactionMeta;
|
|
60
59
|
if (status === transaction_controller_1.TransactionStatus.confirmed) {
|
|
61
|
-
return
|
|
60
|
+
return constants_1.GetCallsStatusCode.CONFIRMED;
|
|
62
61
|
}
|
|
63
62
|
if (status === transaction_controller_1.TransactionStatus.failed) {
|
|
64
63
|
return hash
|
|
65
|
-
?
|
|
66
|
-
:
|
|
64
|
+
? constants_1.GetCallsStatusCode.REVERTED
|
|
65
|
+
: constants_1.GetCallsStatusCode.FAILED_OFFCHAIN;
|
|
67
66
|
}
|
|
68
67
|
if (status === transaction_controller_1.TransactionStatus.dropped) {
|
|
69
|
-
return
|
|
68
|
+
return constants_1.GetCallsStatusCode.REVERTED;
|
|
70
69
|
}
|
|
71
|
-
return
|
|
70
|
+
return constants_1.GetCallsStatusCode.PENDING;
|
|
72
71
|
}
|
|
73
72
|
//# sourceMappingURL=getCallsStatus.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.cjs","sourceRoot":"","sources":["../../src/hooks/getCallsStatus.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAMpD,6EAAqE;AAGrE,gDAA6E;AAG7E;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC5B,SAA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a,CAAC,eAAgC;IACrD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;IAEzC,IAAI,MAAM,KAAK,0CAAiB,CAAC,SAAS,EAAE;QAC1C,OAAO,8BAAkB,CAAC,SAAS,CAAC;KACrC;IAED,IAAI,MAAM,KAAK,0CAAiB,CAAC,MAAM,EAAE;QACvC,OAAO,IAAI;YACT,CAAC,CAAC,8BAAkB,CAAC,QAAQ;YAC7B,CAAC,CAAC,8BAAkB,CAAC,eAAe,CAAC;KACxC;IAED,IAAI,MAAM,KAAK,0CAAiB,CAAC,OAAO,EAAE;QACxC,OAAO,8BAAkB,CAAC,QAAQ,CAAC;KACpC;IAED,OAAO,8BAAkB,CAAC,OAAO,CAAC;AACpC,CAAC","sourcesContent":["import { 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, GetCallsStatusCode, VERSION } from '../constants';\nimport type { EIP5792Messenger, GetCallsStatusResult } 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"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { GetCallsStatusResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
1
|
import type { Hex } from "@metamask/utils";
|
|
3
|
-
import type { EIP5792Messenger } from "../types.cjs";
|
|
2
|
+
import type { EIP5792Messenger, GetCallsStatusResult } from "../types.cjs";
|
|
4
3
|
/**
|
|
5
4
|
* Retrieves the status of a transaction batch by its ID.
|
|
6
5
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.d.cts","sourceRoot":"","sources":["../../src/hooks/getCallsStatus.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,qBAAiB;AAEvE;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,gBAAgB,EAC3B,EAAE,EAAE,GAAG,GACN,oBAAoB,CAyCtB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { GetCallsStatusResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
1
|
import type { Hex } from "@metamask/utils";
|
|
3
|
-
import type { EIP5792Messenger } from "../types.mjs";
|
|
2
|
+
import type { EIP5792Messenger, GetCallsStatusResult } from "../types.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* Retrieves the status of a transaction batch by its ID.
|
|
6
5
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.d.mts","sourceRoot":"","sources":["../../src/hooks/getCallsStatus.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,qBAAiB;AAEvE;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,gBAAgB,EAC3B,EAAE,EAAE,GAAG,GACN,oBAAoB,CAyCtB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { GetCallsStatusCode } from "@metamask/eth-json-rpc-middleware";
|
|
2
1
|
import { JsonRpcError } from "@metamask/rpc-errors";
|
|
3
2
|
import { TransactionStatus } from "@metamask/transaction-controller";
|
|
4
|
-
import { EIP5792ErrorCode, VERSION } from "../constants.mjs";
|
|
3
|
+
import { EIP5792ErrorCode, GetCallsStatusCode, VERSION } from "../constants.mjs";
|
|
5
4
|
/**
|
|
6
5
|
* Retrieves the status of a transaction batch by its ID.
|
|
7
6
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.mjs","sourceRoot":"","sources":["../../src/hooks/getCallsStatus.ts"],"names":[],"mappings":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AAC,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 { 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, GetCallsStatusCode, VERSION } from '../constants';\nimport type { EIP5792Messenger, GetCallsStatusResult } 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 @@
|
|
|
1
|
+
{"version":3,"file":"getCapabilities.cjs","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":";;;AAOA,gDAA6D;AAE7D,wCAAiD;AAoBjD;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CACnC,KAA2B,EAC3B,SAA2B,EAC3B,OAAY,EACZ,QAA2B;IAE3B,MAAM,EACJ,u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AAC,CAAC;IAEJ,OAAO,QAAQ,CAAC,MAAM,CAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAC7D,MAAM,iBAAiB,GAAG,CAAC,mBAAmB,CAAC,IAAI,CACjD,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAY,KAAK,OAAO,CACxD,IAAI,EAAE,CAEN,CAAC;QAEF,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,sBAAsB,EAAE,GAAG,iBAAiB,CAAC;QAE1E,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,qBAAqB,GAAG,yBAAyB,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;QAE1E,MAAM,gBAAgB,GACpB,iBAAiB;YACjB,CAAC,CAAC,kBAAkB,IAAI,qBAAqB,CAAC;gBAC5C,CAAC,WAAW,IAAI,sBAAsB,CAAC,CAAC,CAAC;QAE7C,IAAI,gBAAgB,EAAE;YACpB,GAAG,CAAC,OAAc,CAAC,GAAG;gBACpB,gBAAgB,EAAE;oBAChB,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;SACH;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import 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, GetCapabilitiesResult } 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"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { GetCapabilitiesResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
1
|
import type { TransactionController } from "@metamask/transaction-controller";
|
|
3
2
|
import type { Hex } from "@metamask/utils";
|
|
4
|
-
import type { EIP5792Messenger } from "../types.cjs";
|
|
3
|
+
import type { EIP5792Messenger, GetCapabilitiesResult } from "../types.cjs";
|
|
5
4
|
/**
|
|
6
5
|
* Type definition for required controller hooks and utilities of {@link getCapabilities}
|
|
7
6
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCapabilities.d.cts","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,qBAAqB,EACtB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,qBAAiB;AAGxE;;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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { GetCapabilitiesResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
1
|
import type { TransactionController } from "@metamask/transaction-controller";
|
|
3
2
|
import type { Hex } from "@metamask/utils";
|
|
4
|
-
import type { EIP5792Messenger } from "../types.mjs";
|
|
3
|
+
import type { EIP5792Messenger, GetCapabilitiesResult } from "../types.mjs";
|
|
5
4
|
/**
|
|
6
5
|
* Type definition for required controller hooks and utilities of {@link getCapabilities}
|
|
7
6
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCapabilities.d.mts","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,qBAAqB,EACtB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,qBAAiB;AAGxE;;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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AC;gBAC5C,CAAC,WAAW,IAAI,sBAAsB,CAAC,CAAC,CAAC;QAE7C,IAAI,gBAAgB,EAAE;YACpB,GAAG,CAAC,OAAc,CAAC,GAAG;gBACpB,gBAAgB,EAAE;oBAChB,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;SACH;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import 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, GetCapabilitiesResult } 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 @@
|
|
|
1
|
+
{"version":3,"file":"processSendCalls.cjs","sourceRoot":"","sources":["../../src/hooks/processSendCalls.ts"],"names":[],"mappings":";;;AACA,qDAA+D;AAQ/D,6EAA2E;AAE3E,2CAA6C;AAC7C,+BAAyC;AAEzC,gDAKsB;AAMtB,wCA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AAC,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,CACzC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CACtD,CACF,CAAC;IAEF,MAAM,oBAAoB,GAAG;QAC3B,GAAG,4BAA4B;QAC/B,GAAG,wBAAwB;KAC5B,CAAC;IAEF,IAAI,oBAAoB,EAAE,MAAM,EAAE;QAChC,MAAM,IAAI,yBAAY,CACpB,4BAAgB,CAAC,gCAAgC,EACjD,0CAA0C,oBAAoB,CAAC,IAAI,CACjE,IAAI,CACL,EAAE,CACJ,CAAC;KACH;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,eAAe,CACtB,oCAA6C,EAC7C,iBAAgE,EAChE,WAAyB;IAEzB,IAAI,iBAAiB,EAAE,iBAAiB,EAAE;QACxC,OAAO;KACR;IAED,IAAI,oCAAoC,EAAE;QACxC,MAAM,IAAI,yBAAY,CACpB,4BAAgB,CAAC,eAAe,EAChC,uCAAuC,CACxC,CAAC;KACH;IAED,IAAI,CAAC,yCAA6B,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACxD,MAAM,IAAI,yBAAY,CACpB,4BAAgB,CAAC,eAAe,EAChC,2CAA2C,CAC5C,CAAC;KACH;AACH,CAAC","sourcesContent":["import type { KeyringTypes } from '@metamask/keyring-controller';\nimport { JsonRpcError, rpcErrors } from '@metamask/rpc-errors';\nimport type {\n BatchTransactionParams,\n IsAtomicBatchSupportedResultEntry,\n SecurityAlertResponse,\n TransactionController,\n ValidateSecurityRequest,\n} from '@metamask/transaction-controller';\nimport { TransactionEnvelopeType } from '@metamask/transaction-controller';\nimport type { Hex, JsonRpcRequest } from '@metamask/utils';\nimport { bytesToHex } from '@metamask/utils';\nimport { parse, v4 as uuid } from 'uuid';\n\nimport {\n EIP5792ErrorCode,\n KEYRING_TYPES_SUPPORTING_7702,\n MessageType,\n VERSION,\n} from '../constants';\nimport type {\n EIP5792Messenger,\n SendCallsPayload,\n SendCallsResult,\n} from '../types';\nimport { getAccountKeyringType } from '../utils';\n\n/**\n * Type definition for required controller hooks and utilities of {@link processSendCalls}\n */\nexport type ProcessSendCallsHooks = {\n /** Function to add a batch of transactions atomically */\n addTransactionBatch: TransactionController['addTransactionBatch'];\n /** Function to add a single transaction */\n addTransaction: TransactionController['addTransaction'];\n /** Function to check if smart account suggestions are disabled */\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n /** Function to check if atomic batching is supported for given parameters */\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n /** Function to validate security for transaction requests */\n validateSecurity: (\n securityAlertId: string,\n request: ValidateSecurityRequest,\n chainId: Hex,\n ) => Promise<void>;\n};\n\n/**\n * A valid JSON-RPC request object for `wallet_sendCalls`.\n */\nexport type ProcessSendCallsRequest = JsonRpcRequest & {\n /** The identifier for the network client that has been created for this RPC endpoint */\n networkClientId: string;\n /** The origin of the RPC request */\n origin?: string;\n};\n\n/**\n * Processes a sendCalls request for EIP-5792 transactions.\n *\n * @param hooks - Object containing required controller hooks and utilities.\n * @param messenger - Messenger instance for controller communication.\n * @param params - The sendCalls parameters containing transaction calls and metadata.\n * @param req - The original JSON-RPC request.\n * @returns Promise resolving to a SendCallsResult containing the batch ID.\n */\nexport async function processSendCalls(\n hooks: ProcessSendCallsHooks,\n messenger: EIP5792Messenger,\n params: SendCallsPayload,\n req: ProcessSendCallsRequest,\n): Promise<SendCallsResult> {\n const {\n addTransactionBatch,\n addTransaction,\n getDismissSmartAccountSuggestionEnabled,\n isAtomicBatchSupported,\n validateSecurity: validateSecurityHook,\n } = hooks;\n\n const { calls, from: paramFrom } = params;\n const { networkClientId, origin } = req;\n const transactions = calls.map((call) => ({ params: call }));\n\n const { chainId } = messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n ).configuration;\n\n const from =\n paramFrom ??\n (messenger.call('AccountsController:getSelectedAccount').address as Hex);\n\n const securityAlertId = uuid();\n const validateSecurity = validateSecurityHook.bind(null, securityAlertId);\n\n let batchId: Hex;\n if (Object.keys(transactions).length === 1) {\n batchId = await processSingleTransaction({\n addTransaction,\n chainId,\n from,\n networkClientId,\n origin,\n securityAlertId,\n sendCalls: params,\n transactions,\n validateSecurity,\n });\n } else {\n batchId = await processMultipleTransaction({\n addTransactionBatch,\n isAtomicBatchSupported,\n chainId,\n from,\n getDismissSmartAccountSuggestionEnabled,\n messenger,\n networkClientId,\n origin,\n sendCalls: params,\n securityAlertId,\n transactions,\n validateSecurity,\n });\n }\n\n return { id: batchId };\n}\n\n/**\n * Processes a single transaction from a sendCalls request.\n *\n * @param params - Object containing all parameters needed for single transaction processing.\n * @param params.addTransaction - Function to add a single transaction.\n * @param params.chainId - The chain ID for the transaction.\n * @param params.from - The sender address.\n * @param params.networkClientId - The network client ID.\n * @param params.origin - The origin of the request (optional).\n * @param params.securityAlertId - The security alert ID for this transaction.\n * @param params.sendCalls - The original sendCalls request.\n * @param params.transactions - Array containing the single transaction.\n * @param params.validateSecurity - Function to validate security for the transaction.\n * @returns Promise resolving to the generated batch ID for the transaction.\n */\nasync function processSingleTransaction({\n addTransaction,\n chainId,\n from,\n networkClientId,\n origin,\n securityAlertId,\n sendCalls,\n transactions,\n validateSecurity,\n}: {\n addTransaction: TransactionController['addTransaction'];\n chainId: Hex;\n from: Hex;\n networkClientId: string;\n origin?: string;\n securityAlertId: string;\n sendCalls: SendCallsPayload;\n transactions: { params: BatchTransactionParams }[];\n validateSecurity: (\n securityRequest: ValidateSecurityRequest,\n chainId: Hex,\n ) => void;\n}) {\n validateSingleSendCall(sendCalls, chainId);\n\n const txParams = {\n from,\n ...transactions[0].params,\n type: TransactionEnvelopeType.feeMarket,\n };\n\n const securityRequest: ValidateSecurityRequest = {\n method: MessageType.SendTransaction,\n params: [txParams],\n origin,\n };\n validateSecurity(securityRequest, chainId);\n\n const batchId = generateBatchId();\n\n await addTransaction(txParams, {\n networkClientId,\n origin,\n securityAlertResponse: { securityAlertId } as SecurityAlertResponse,\n batchId,\n });\n return batchId;\n}\n\n/**\n * Processes multiple transactions from a sendCalls request as an atomic batch.\n *\n * @param params - Object containing all parameters needed for multiple transaction processing.\n * @param params.addTransactionBatch - Function to add a batch of transactions atomically.\n * @param params.isAtomicBatchSupported - Function to check if atomic batching is supported.\n * @param params.chainId - The chain ID for the transactions.\n * @param params.from - The sender address.\n * @param params.getDismissSmartAccountSuggestionEnabled - Function to check if smart account suggestions are disabled.\n * @param params.networkClientId - The network client ID.\n * @param params.messenger - Messenger instance for controller communication.\n * @param params.origin - The origin of the request (optional).\n * @param params.sendCalls - The original sendCalls request.\n * @param params.securityAlertId - The security alert ID for this batch.\n * @param params.transactions - Array of transactions to process.\n * @param params.validateSecurity - Function to validate security for the transactions.\n * @returns Promise resolving to the generated batch ID for the transaction batch.\n */\nasync function processMultipleTransaction({\n addTransactionBatch,\n isAtomicBatchSupported,\n chainId,\n from,\n getDismissSmartAccountSuggestionEnabled,\n networkClientId,\n messenger,\n origin,\n sendCalls,\n securityAlertId,\n transactions,\n validateSecurity,\n}: {\n addTransactionBatch: TransactionController['addTransactionBatch'];\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n chainId: Hex;\n from: Hex;\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n messenger: EIP5792Messenger;\n networkClientId: string;\n origin?: string;\n sendCalls: SendCallsPayload;\n securityAlertId: string;\n transactions: { params: BatchTransactionParams }[];\n validateSecurity: (\n securityRequest: ValidateSecurityRequest,\n chainId: Hex,\n ) => Promise<void>;\n}) {\n const batchSupport = await isAtomicBatchSupported({\n address: from,\n chainIds: [chainId],\n });\n\n const chainBatchSupport = batchSupport?.[0];\n\n const keyringType = getAccountKeyringType(from, messenger);\n\n const dismissSmartAccountSuggestionEnabled =\n getDismissSmartAccountSuggestionEnabled();\n\n validateSendCalls(\n sendCalls,\n chainId,\n dismissSmartAccountSuggestionEnabled,\n chainBatchSupport,\n keyringType,\n );\n\n const result = await addTransactionBatch({\n from,\n networkClientId,\n origin,\n securityAlertId,\n transactions,\n validateSecurity,\n });\n return result.batchId;\n}\n\n/**\n * Generate a transaction batch ID.\n *\n * @returns A unique batch ID as a hexadecimal string.\n */\nfunction generateBatchId(): Hex {\n const idString = uuid();\n const idBytes = new Uint8Array(parse(idString));\n return bytesToHex(idBytes);\n}\n\n/**\n * Validates a single sendCalls request.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @param dappChainId - The chain ID that the dApp is connected to.\n */\nfunction validateSingleSendCall(sendCalls: SendCallsPayload, dappChainId: Hex) {\n validateSendCallsVersion(sendCalls);\n validateCapabilities(sendCalls);\n validateDappChainId(sendCalls, dappChainId);\n}\n\n/**\n * Validates a sendCalls request for multiple transactions.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @param dappChainId - The chain ID that the dApp is connected to\n * @param dismissSmartAccountSuggestionEnabled - Whether smart account suggestions are disabled.\n * @param chainBatchSupport - Information about atomic batch support for the chain.\n * @param keyringType - The type of keyring associated with the account.\n */\nfunction validateSendCalls(\n sendCalls: SendCallsPayload,\n dappChainId: Hex,\n dismissSmartAccountSuggestionEnabled: boolean,\n chainBatchSupport: IsAtomicBatchSupportedResultEntry | undefined,\n keyringType: KeyringTypes,\n) {\n validateSendCallsVersion(sendCalls);\n validateSendCallsChainId(sendCalls, dappChainId, chainBatchSupport);\n validateCapabilities(sendCalls);\n validateUpgrade(\n dismissSmartAccountSuggestionEnabled,\n chainBatchSupport,\n keyringType,\n );\n}\n\n/**\n * Validates the version of a sendCalls request.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @throws JsonRpcError if the version is not supported.\n */\nfunction validateSendCallsVersion(sendCalls: SendCallsPayload) {\n const { version } = sendCalls;\n\n if (version !== VERSION) {\n throw rpcErrors.invalidInput(\n `Version not supported: Got ${version}, expected ${VERSION}`,\n );\n }\n}\n\n/**\n * Validates that the chain ID in the sendCalls request matches the dApp's selected network.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @param dappChainId - The chain ID that the dApp is connected to\n * @throws JsonRpcError if the chain IDs don't match\n */\nfunction validateDappChainId(sendCalls: SendCallsPayload, dappChainId: Hex) {\n const { chainId: requestChainId } = sendCalls;\n\n if (\n requestChainId &&\n requestChainId.toLowerCase() !== dappChainId.toLowerCase()\n ) {\n throw rpcErrors.invalidParams(\n `Chain ID must match the dApp selected network: Got ${requestChainId}, expected ${dappChainId}`,\n );\n }\n}\n\n/**\n * Validates the chain ID for sendCalls requests with additional EIP-7702 support checks.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @param dappChainId - The chain ID that the dApp is connected to\n * @param chainBatchSupport - Information about atomic batch support for the chain\n * @throws JsonRpcError if the chain ID doesn't match or EIP-7702 is not supported\n */\nfunction validateSendCallsChainId(\n sendCalls: SendCallsPayload,\n dappChainId: Hex,\n chainBatchSupport: IsAtomicBatchSupportedResultEntry | undefined,\n) {\n validateDappChainId(sendCalls, dappChainId);\n if (!chainBatchSupport) {\n throw new JsonRpcError(\n EIP5792ErrorCode.UnsupportedChainId,\n `EIP-7702 not supported on chain: ${dappChainId}`,\n );\n }\n}\n\n/**\n * Validates that all required capabilities in the sendCalls request are supported.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @throws JsonRpcError if unsupported non-optional capabilities are requested.\n */\nfunction validateCapabilities(sendCalls: SendCallsPayload) {\n const { calls, capabilities } = sendCalls;\n\n const requiredTopLevelCapabilities = Object.keys(capabilities ?? {}).filter(\n (name) => capabilities?.[name].optional !== true,\n );\n\n const requiredCallCapabilities = calls.flatMap((call) =>\n Object.keys(call.capabilities ?? {}).filter(\n (name) => call.capabilities?.[name].optional !== true,\n ),\n );\n\n const requiredCapabilities = [\n ...requiredTopLevelCapabilities,\n ...requiredCallCapabilities,\n ];\n\n if (requiredCapabilities?.length) {\n throw new JsonRpcError(\n EIP5792ErrorCode.UnsupportedNonOptionalCapability,\n `Unsupported non-optional capabilities: ${requiredCapabilities.join(\n ', ',\n )}`,\n );\n }\n}\n\n/**\n * Validates whether an EIP-7702 upgrade is allowed for the given parameters.\n *\n * @param dismissSmartAccountSuggestionEnabled - Whether smart account suggestions are disabled.\n * @param chainBatchSupport - Information about atomic batch support for the chain.\n * @param keyringType - The type of keyring associated with the account.\n * @throws JsonRpcError if the upgrade is rejected due to user settings or account type.\n */\nfunction validateUpgrade(\n dismissSmartAccountSuggestionEnabled: boolean,\n chainBatchSupport: IsAtomicBatchSupportedResultEntry | undefined,\n keyringType: KeyringTypes,\n) {\n if (chainBatchSupport?.delegationAddress) {\n return;\n }\n\n if (dismissSmartAccountSuggestionEnabled) {\n throw new JsonRpcError(\n EIP5792ErrorCode.RejectedUpgrade,\n 'EIP-7702 upgrade disabled by the user',\n );\n }\n\n if (!KEYRING_TYPES_SUPPORTING_7702.includes(keyringType)) {\n throw new JsonRpcError(\n EIP5792ErrorCode.RejectedUpgrade,\n 'EIP-7702 upgrade not supported on account',\n );\n }\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { SendCalls, SendCallsResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
1
|
import type { TransactionController, ValidateSecurityRequest } from "@metamask/transaction-controller";
|
|
3
2
|
import type { Hex, JsonRpcRequest } from "@metamask/utils";
|
|
4
|
-
import type { EIP5792Messenger } from "../types.cjs";
|
|
3
|
+
import type { EIP5792Messenger, SendCallsPayload, SendCallsResult } from "../types.cjs";
|
|
5
4
|
/**
|
|
6
5
|
* Type definition for required controller hooks and utilities of {@link processSendCalls}
|
|
7
6
|
*/
|
|
@@ -35,5 +34,5 @@ export type ProcessSendCallsRequest = JsonRpcRequest & {
|
|
|
35
34
|
* @param req - The original JSON-RPC request.
|
|
36
35
|
* @returns Promise resolving to a SendCallsResult containing the batch ID.
|
|
37
36
|
*/
|
|
38
|
-
export declare function processSendCalls(hooks: ProcessSendCallsHooks, messenger: EIP5792Messenger, params:
|
|
37
|
+
export declare function processSendCalls(hooks: ProcessSendCallsHooks, messenger: EIP5792Messenger, params: SendCallsPayload, req: ProcessSendCallsRequest): Promise<SendCallsResult>;
|
|
39
38
|
//# sourceMappingURL=processSendCalls.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processSendCalls.d.cts","sourceRoot":"","sources":["../../src/hooks/processSendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,qBAAqB,EACrB,uBAAuB,EACxB,yCAAyC;AAE1C,OAAO,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,wBAAwB;AAU3D,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAChB,qBAAiB;AAGlB;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,yDAAyD;IACzD,mBAAmB,EAAE,qBAAqB,CAAC,qBAAqB,CAAC,CAAC;IAClE,2CAA2C;IAC3C,cAAc,EAAE,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACxD,kEAAkE;IAClE,uCAAuC,EAAE,MAAM,OAAO,CAAC;IACvD,6EAA6E;IAC7E,sBAAsB,EAAE,qBAAqB,CAAC,wBAAwB,CAAC,CAAC;IACxE,6DAA6D;IAC7D,gBAAgB,EAAE,CAChB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,GAAG,KACT,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG;IACrD,wFAAwF;IACxF,eAAe,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,qBAAqB,EAC5B,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,uBAAuB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAwD1B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { SendCalls, SendCallsResult } from "@metamask/eth-json-rpc-middleware";
|
|
2
1
|
import type { TransactionController, ValidateSecurityRequest } from "@metamask/transaction-controller";
|
|
3
2
|
import type { Hex, JsonRpcRequest } from "@metamask/utils";
|
|
4
|
-
import type { EIP5792Messenger } from "../types.mjs";
|
|
3
|
+
import type { EIP5792Messenger, SendCallsPayload, SendCallsResult } from "../types.mjs";
|
|
5
4
|
/**
|
|
6
5
|
* Type definition for required controller hooks and utilities of {@link processSendCalls}
|
|
7
6
|
*/
|
|
@@ -35,5 +34,5 @@ export type ProcessSendCallsRequest = JsonRpcRequest & {
|
|
|
35
34
|
* @param req - The original JSON-RPC request.
|
|
36
35
|
* @returns Promise resolving to a SendCallsResult containing the batch ID.
|
|
37
36
|
*/
|
|
38
|
-
export declare function processSendCalls(hooks: ProcessSendCallsHooks, messenger: EIP5792Messenger, params:
|
|
37
|
+
export declare function processSendCalls(hooks: ProcessSendCallsHooks, messenger: EIP5792Messenger, params: SendCallsPayload, req: ProcessSendCallsRequest): Promise<SendCallsResult>;
|
|
39
38
|
//# sourceMappingURL=processSendCalls.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processSendCalls.d.mts","sourceRoot":"","sources":["../../src/hooks/processSendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,qBAAqB,EACrB,uBAAuB,EACxB,yCAAyC;AAE1C,OAAO,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,wBAAwB;AAU3D,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAChB,qBAAiB;AAGlB;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,yDAAyD;IACzD,mBAAmB,EAAE,qBAAqB,CAAC,qBAAqB,CAAC,CAAC;IAClE,2CAA2C;IAC3C,cAAc,EAAE,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACxD,kEAAkE;IAClE,uCAAuC,EAAE,MAAM,OA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BAAoB,EAAE,MAAM,EAAE;QAChC,MAAM,IAAI,YAAY,CACpB,gBAAgB,CAAC,gCAAgC,EACjD,0CAA0C,oBAAoB,CAAC,IAAI,CACjE,IAAI,CACL,EAAE,CACJ,CAAC;KACH;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,eAAe,CACtB,oCAA6C,EAC7C,iBAAgE,EAChE,WAAyB;IAEzB,IAAI,iBAAiB,EAAE,iBAAiB,EAAE;QACxC,OAAO;KACR;IAED,IAAI,oCAAoC,EAAE;QACxC,MAAM,IAAI,YAAY,CACpB,gBAAgB,CAAC,eAAe,EAChC,uCAAuC,CACxC,CAAC;KACH;IAED,IAAI,CAAC,6BAA6B,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACxD,MAAM,IAAI,YAAY,CACpB,gBAAgB,CAAC,eAAe,EAChC,2CAA2C,CAC5C,CAAC;KACH;AACH,CAAC","sourcesContent":["import type { KeyringTypes } from '@metamask/keyring-controller';\nimport { JsonRpcError, rpcErrors } from '@metamask/rpc-errors';\nimport type {\n BatchTransactionParams,\n IsAtomicBatchSupportedResultEntry,\n SecurityAlertResponse,\n TransactionController,\n ValidateSecurityRequest,\n} from '@metamask/transaction-controller';\nimport { TransactionEnvelopeType } from '@metamask/transaction-controller';\nimport type { Hex, JsonRpcRequest } from '@metamask/utils';\nimport { bytesToHex } from '@metamask/utils';\nimport { parse, v4 as uuid } from 'uuid';\n\nimport {\n EIP5792ErrorCode,\n KEYRING_TYPES_SUPPORTING_7702,\n MessageType,\n VERSION,\n} from '../constants';\nimport type {\n EIP5792Messenger,\n SendCallsPayload,\n SendCallsResult,\n} from '../types';\nimport { getAccountKeyringType } from '../utils';\n\n/**\n * Type definition for required controller hooks and utilities of {@link processSendCalls}\n */\nexport type ProcessSendCallsHooks = {\n /** Function to add a batch of transactions atomically */\n addTransactionBatch: TransactionController['addTransactionBatch'];\n /** Function to add a single transaction */\n addTransaction: TransactionController['addTransaction'];\n /** Function to check if smart account suggestions are disabled */\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n /** Function to check if atomic batching is supported for given parameters */\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n /** Function to validate security for transaction requests */\n validateSecurity: (\n securityAlertId: string,\n request: ValidateSecurityRequest,\n chainId: Hex,\n ) => Promise<void>;\n};\n\n/**\n * A valid JSON-RPC request object for `wallet_sendCalls`.\n */\nexport type ProcessSendCallsRequest = JsonRpcRequest & {\n /** The identifier for the network client that has been created for this RPC endpoint */\n networkClientId: string;\n /** The origin of the RPC request */\n origin?: string;\n};\n\n/**\n * Processes a sendCalls request for EIP-5792 transactions.\n *\n * @param hooks - Object containing required controller hooks and utilities.\n * @param messenger - Messenger instance for controller communication.\n * @param params - The sendCalls parameters containing transaction calls and metadata.\n * @param req - The original JSON-RPC request.\n * @returns Promise resolving to a SendCallsResult containing the batch ID.\n */\nexport async function processSendCalls(\n hooks: ProcessSendCallsHooks,\n messenger: EIP5792Messenger,\n params: SendCallsPayload,\n req: ProcessSendCallsRequest,\n): Promise<SendCallsResult> {\n const {\n addTransactionBatch,\n addTransaction,\n getDismissSmartAccountSuggestionEnabled,\n isAtomicBatchSupported,\n validateSecurity: validateSecurityHook,\n } = hooks;\n\n const { calls, from: paramFrom } = params;\n const { networkClientId, origin } = req;\n const transactions = calls.map((call) => ({ params: call }));\n\n const { chainId } = messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n ).configuration;\n\n const from =\n paramFrom ??\n (messenger.call('AccountsController:getSelectedAccount').address as Hex);\n\n const securityAlertId = uuid();\n const validateSecurity = validateSecurityHook.bind(null, securityAlertId);\n\n let batchId: Hex;\n if (Object.keys(transactions).length === 1) {\n batchId = await processSingleTransaction({\n addTransaction,\n chainId,\n from,\n networkClientId,\n origin,\n securityAlertId,\n sendCalls: params,\n transactions,\n validateSecurity,\n });\n } else {\n batchId = await processMultipleTransaction({\n addTransactionBatch,\n isAtomicBatchSupported,\n chainId,\n from,\n getDismissSmartAccountSuggestionEnabled,\n messenger,\n networkClientId,\n origin,\n sendCalls: params,\n securityAlertId,\n transactions,\n validateSecurity,\n });\n }\n\n return { id: batchId };\n}\n\n/**\n * Processes a single transaction from a sendCalls request.\n *\n * @param params - Object containing all parameters needed for single transaction processing.\n * @param params.addTransaction - Function to add a single transaction.\n * @param params.chainId - The chain ID for the transaction.\n * @param params.from - The sender address.\n * @param params.networkClientId - The network client ID.\n * @param params.origin - The origin of the request (optional).\n * @param params.securityAlertId - The security alert ID for this transaction.\n * @param params.sendCalls - The original sendCalls request.\n * @param params.transactions - Array containing the single transaction.\n * @param params.validateSecurity - Function to validate security for the transaction.\n * @returns Promise resolving to the generated batch ID for the transaction.\n */\nasync function processSingleTransaction({\n addTransaction,\n chainId,\n from,\n networkClientId,\n origin,\n securityAlertId,\n sendCalls,\n transactions,\n validateSecurity,\n}: {\n addTransaction: TransactionController['addTransaction'];\n chainId: Hex;\n from: Hex;\n networkClientId: string;\n origin?: string;\n securityAlertId: string;\n sendCalls: SendCallsPayload;\n transactions: { params: BatchTransactionParams }[];\n validateSecurity: (\n securityRequest: ValidateSecurityRequest,\n chainId: Hex,\n ) => void;\n}) {\n validateSingleSendCall(sendCalls, chainId);\n\n const txParams = {\n from,\n ...transactions[0].params,\n type: TransactionEnvelopeType.feeMarket,\n };\n\n const securityRequest: ValidateSecurityRequest = {\n method: MessageType.SendTransaction,\n params: [txParams],\n origin,\n };\n validateSecurity(securityRequest, chainId);\n\n const batchId = generateBatchId();\n\n await addTransaction(txParams, {\n networkClientId,\n origin,\n securityAlertResponse: { securityAlertId } as SecurityAlertResponse,\n batchId,\n });\n return batchId;\n}\n\n/**\n * Processes multiple transactions from a sendCalls request as an atomic batch.\n *\n * @param params - Object containing all parameters needed for multiple transaction processing.\n * @param params.addTransactionBatch - Function to add a batch of transactions atomically.\n * @param params.isAtomicBatchSupported - Function to check if atomic batching is supported.\n * @param params.chainId - The chain ID for the transactions.\n * @param params.from - The sender address.\n * @param params.getDismissSmartAccountSuggestionEnabled - Function to check if smart account suggestions are disabled.\n * @param params.networkClientId - The network client ID.\n * @param params.messenger - Messenger instance for controller communication.\n * @param params.origin - The origin of the request (optional).\n * @param params.sendCalls - The original sendCalls request.\n * @param params.securityAlertId - The security alert ID for this batch.\n * @param params.transactions - Array of transactions to process.\n * @param params.validateSecurity - Function to validate security for the transactions.\n * @returns Promise resolving to the generated batch ID for the transaction batch.\n */\nasync function processMultipleTransaction({\n addTransactionBatch,\n isAtomicBatchSupported,\n chainId,\n from,\n getDismissSmartAccountSuggestionEnabled,\n networkClientId,\n messenger,\n origin,\n sendCalls,\n securityAlertId,\n transactions,\n validateSecurity,\n}: {\n addTransactionBatch: TransactionController['addTransactionBatch'];\n isAtomicBatchSupported: TransactionController['isAtomicBatchSupported'];\n chainId: Hex;\n from: Hex;\n getDismissSmartAccountSuggestionEnabled: () => boolean;\n messenger: EIP5792Messenger;\n networkClientId: string;\n origin?: string;\n sendCalls: SendCallsPayload;\n securityAlertId: string;\n transactions: { params: BatchTransactionParams }[];\n validateSecurity: (\n securityRequest: ValidateSecurityRequest,\n chainId: Hex,\n ) => Promise<void>;\n}) {\n const batchSupport = await isAtomicBatchSupported({\n address: from,\n chainIds: [chainId],\n });\n\n const chainBatchSupport = batchSupport?.[0];\n\n const keyringType = getAccountKeyringType(from, messenger);\n\n const dismissSmartAccountSuggestionEnabled =\n getDismissSmartAccountSuggestionEnabled();\n\n validateSendCalls(\n sendCalls,\n chainId,\n dismissSmartAccountSuggestionEnabled,\n chainBatchSupport,\n keyringType,\n );\n\n const result = await addTransactionBatch({\n from,\n networkClientId,\n origin,\n securityAlertId,\n transactions,\n validateSecurity,\n });\n return result.batchId;\n}\n\n/**\n * Generate a transaction batch ID.\n *\n * @returns A unique batch ID as a hexadecimal string.\n */\nfunction generateBatchId(): Hex {\n const idString = uuid();\n const idBytes = new Uint8Array(parse(idString));\n return bytesToHex(idBytes);\n}\n\n/**\n * Validates a single sendCalls request.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @param dappChainId - The chain ID that the dApp is connected to.\n */\nfunction validateSingleSendCall(sendCalls: SendCallsPayload, dappChainId: Hex) {\n validateSendCallsVersion(sendCalls);\n validateCapabilities(sendCalls);\n validateDappChainId(sendCalls, dappChainId);\n}\n\n/**\n * Validates a sendCalls request for multiple transactions.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @param dappChainId - The chain ID that the dApp is connected to\n * @param dismissSmartAccountSuggestionEnabled - Whether smart account suggestions are disabled.\n * @param chainBatchSupport - Information about atomic batch support for the chain.\n * @param keyringType - The type of keyring associated with the account.\n */\nfunction validateSendCalls(\n sendCalls: SendCallsPayload,\n dappChainId: Hex,\n dismissSmartAccountSuggestionEnabled: boolean,\n chainBatchSupport: IsAtomicBatchSupportedResultEntry | undefined,\n keyringType: KeyringTypes,\n) {\n validateSendCallsVersion(sendCalls);\n validateSendCallsChainId(sendCalls, dappChainId, chainBatchSupport);\n validateCapabilities(sendCalls);\n validateUpgrade(\n dismissSmartAccountSuggestionEnabled,\n chainBatchSupport,\n keyringType,\n );\n}\n\n/**\n * Validates the version of a sendCalls request.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @throws JsonRpcError if the version is not supported.\n */\nfunction validateSendCallsVersion(sendCalls: SendCallsPayload) {\n const { version } = sendCalls;\n\n if (version !== VERSION) {\n throw rpcErrors.invalidInput(\n `Version not supported: Got ${version}, expected ${VERSION}`,\n );\n }\n}\n\n/**\n * Validates that the chain ID in the sendCalls request matches the dApp's selected network.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @param dappChainId - The chain ID that the dApp is connected to\n * @throws JsonRpcError if the chain IDs don't match\n */\nfunction validateDappChainId(sendCalls: SendCallsPayload, dappChainId: Hex) {\n const { chainId: requestChainId } = sendCalls;\n\n if (\n requestChainId &&\n requestChainId.toLowerCase() !== dappChainId.toLowerCase()\n ) {\n throw rpcErrors.invalidParams(\n `Chain ID must match the dApp selected network: Got ${requestChainId}, expected ${dappChainId}`,\n );\n }\n}\n\n/**\n * Validates the chain ID for sendCalls requests with additional EIP-7702 support checks.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @param dappChainId - The chain ID that the dApp is connected to\n * @param chainBatchSupport - Information about atomic batch support for the chain\n * @throws JsonRpcError if the chain ID doesn't match or EIP-7702 is not supported\n */\nfunction validateSendCallsChainId(\n sendCalls: SendCallsPayload,\n dappChainId: Hex,\n chainBatchSupport: IsAtomicBatchSupportedResultEntry | undefined,\n) {\n validateDappChainId(sendCalls, dappChainId);\n if (!chainBatchSupport) {\n throw new JsonRpcError(\n EIP5792ErrorCode.UnsupportedChainId,\n `EIP-7702 not supported on chain: ${dappChainId}`,\n );\n }\n}\n\n/**\n * Validates that all required capabilities in the sendCalls request are supported.\n *\n * @param sendCalls - The sendCalls request to validate.\n * @throws JsonRpcError if unsupported non-optional capabilities are requested.\n */\nfunction validateCapabilities(sendCalls: SendCallsPayload) {\n const { calls, capabilities } = sendCalls;\n\n const requiredTopLevelCapabilities = Object.keys(capabilities ?? {}).filter(\n (name) => capabilities?.[name].optional !== true,\n );\n\n const requiredCallCapabilities = calls.flatMap((call) =>\n Object.keys(call.capabilities ?? {}).filter(\n (name) => call.capabilities?.[name].optional !== true,\n ),\n );\n\n const requiredCapabilities = [\n ...requiredTopLevelCapabilities,\n ...requiredCallCapabilities,\n ];\n\n if (requiredCapabilities?.length) {\n throw new JsonRpcError(\n EIP5792ErrorCode.UnsupportedNonOptionalCapability,\n `Unsupported non-optional capabilities: ${requiredCapabilities.join(\n ', ',\n )}`,\n );\n }\n}\n\n/**\n * Validates whether an EIP-7702 upgrade is allowed for the given parameters.\n *\n * @param dismissSmartAccountSuggestionEnabled - Whether smart account suggestions are disabled.\n * @param chainBatchSupport - Information about atomic batch support for the chain.\n * @param keyringType - The type of keyring associated with the account.\n * @throws JsonRpcError if the upgrade is rejected due to user settings or account type.\n */\nfunction validateUpgrade(\n dismissSmartAccountSuggestionEnabled: boolean,\n chainBatchSupport: IsAtomicBatchSupportedResultEntry | undefined,\n keyringType: KeyringTypes,\n) {\n if (chainBatchSupport?.delegationAddress) {\n return;\n }\n\n if (dismissSmartAccountSuggestionEnabled) {\n throw new JsonRpcError(\n EIP5792ErrorCode.RejectedUpgrade,\n 'EIP-7702 upgrade disabled by the user',\n );\n }\n\n if (!KEYRING_TYPES_SUPPORTING_7702.includes(keyringType)) {\n throw new JsonRpcError(\n EIP5792ErrorCode.RejectedUpgrade,\n 'EIP-7702 upgrade not supported on account',\n );\n }\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCapabilities = exports.getCallsStatus = exports.processSendCalls = void 0;
|
|
4
|
-
var processSendCalls_1 = require("./
|
|
3
|
+
exports.walletGetCapabilities = exports.walletGetCallsStatus = exports.walletSendCalls = exports.getCapabilities = exports.getCallsStatus = exports.processSendCalls = void 0;
|
|
4
|
+
var processSendCalls_1 = require("./hooks/processSendCalls.cjs");
|
|
5
5
|
Object.defineProperty(exports, "processSendCalls", { enumerable: true, get: function () { return processSendCalls_1.processSendCalls; } });
|
|
6
|
-
var getCallsStatus_1 = require("./
|
|
6
|
+
var getCallsStatus_1 = require("./hooks/getCallsStatus.cjs");
|
|
7
7
|
Object.defineProperty(exports, "getCallsStatus", { enumerable: true, get: function () { return getCallsStatus_1.getCallsStatus; } });
|
|
8
|
-
var getCapabilities_1 = require("./
|
|
8
|
+
var getCapabilities_1 = require("./hooks/getCapabilities.cjs");
|
|
9
9
|
Object.defineProperty(exports, "getCapabilities", { enumerable: true, get: function () { return getCapabilities_1.getCapabilities; } });
|
|
10
|
+
var wallet_sendCalls_1 = require("./methods/wallet_sendCalls.cjs");
|
|
11
|
+
Object.defineProperty(exports, "walletSendCalls", { enumerable: true, get: function () { return wallet_sendCalls_1.walletSendCalls; } });
|
|
12
|
+
var wallet_getCallsStatus_1 = require("./methods/wallet_getCallsStatus.cjs");
|
|
13
|
+
Object.defineProperty(exports, "walletGetCallsStatus", { enumerable: true, get: function () { return wallet_getCallsStatus_1.walletGetCallsStatus; } });
|
|
14
|
+
var wallet_getCapabilities_1 = require("./methods/wallet_getCapabilities.cjs");
|
|
15
|
+
Object.defineProperty(exports, "walletGetCapabilities", { enumerable: true, get: function () { return wallet_getCapabilities_1.walletGetCapabilities; } });
|
|
10
16
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,iEAA4D;AAAnD,oHAAA,gBAAgB,OAAA;AACzB,6DAAwD;AAA/C,gHAAA,cAAc,OAAA;AACvB,+DAGiC;AAF/B,kHAAA,eAAe,OAAA;AAGjB,mEAA6D;AAApD,mHAAA,eAAe,OAAA;AACxB,6EAAuE;AAA9D,6HAAA,oBAAoB,OAAA;AAC7B,+EAAyE;AAAhE,+HAAA,qBAAqB,OAAA","sourcesContent":["export type {\n ProcessSendCallsRequest,\n ProcessSendCallsHooks,\n} from './hooks/processSendCalls';\nexport { processSendCalls } from './hooks/processSendCalls';\nexport { getCallsStatus } from './hooks/getCallsStatus';\nexport {\n getCapabilities,\n type GetCapabilitiesHooks,\n} from './hooks/getCapabilities';\nexport { walletSendCalls } from './methods/wallet_sendCalls';\nexport { walletGetCallsStatus } from './methods/wallet_getCallsStatus';\nexport { walletGetCapabilities } from './methods/wallet_getCapabilities';\nexport type { EIP5792Messenger } from './types';\n\nexport type {\n GetCallsStatusHook,\n GetCallsStatusParams,\n GetCallsStatusResult,\n GetCapabilitiesHook,\n GetCapabilitiesParams,\n GetCapabilitiesResult,\n ProcessSendCallsHook,\n SendCallsPayload as SendCalls,\n SendCallsParams,\n SendCallsResult,\n} from './types';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export type { ProcessSendCallsRequest, ProcessSendCallsHooks, } from "./
|
|
2
|
-
export { processSendCalls } from "./
|
|
3
|
-
export { getCallsStatus } from "./
|
|
4
|
-
export { getCapabilities, type GetCapabilitiesHooks, } from "./
|
|
1
|
+
export type { ProcessSendCallsRequest, ProcessSendCallsHooks, } from "./hooks/processSendCalls.cjs";
|
|
2
|
+
export { processSendCalls } from "./hooks/processSendCalls.cjs";
|
|
3
|
+
export { getCallsStatus } from "./hooks/getCallsStatus.cjs";
|
|
4
|
+
export { getCapabilities, type GetCapabilitiesHooks, } from "./hooks/getCapabilities.cjs";
|
|
5
|
+
export { walletSendCalls } from "./methods/wallet_sendCalls.cjs";
|
|
6
|
+
export { walletGetCallsStatus } from "./methods/wallet_getCallsStatus.cjs";
|
|
7
|
+
export { walletGetCapabilities } from "./methods/wallet_getCapabilities.cjs";
|
|
5
8
|
export type { EIP5792Messenger } from "./types.cjs";
|
|
9
|
+
export type { GetCallsStatusHook, GetCallsStatusParams, GetCallsStatusResult, GetCapabilitiesHook, GetCapabilitiesParams, GetCapabilitiesResult, ProcessSendCallsHook, SendCallsPayload as SendCalls, SendCallsParams, SendCallsResult, } from "./types.cjs";
|
|
6
10
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,qCAAiC;AAClC,OAAO,EAAE,gBAAgB,EAAE,qCAAiC;AAC5D,OAAO,EAAE,cAAc,EAAE,mCAA+B;AACxD,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,oCAAgC;AACjC,OAAO,EAAE,eAAe,EAAE,uCAAmC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,4CAAwC;AACvE,OAAO,EAAE,qBAAqB,EAAE,6CAAyC;AACzE,YAAY,EAAE,gBAAgB,EAAE,oBAAgB;AAEhD,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,IAAI,SAAS,EAC7B,eAAe,EACf,eAAe,GAChB,oBAAgB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export type { ProcessSendCallsRequest, ProcessSendCallsHooks, } from "./
|
|
2
|
-
export { processSendCalls } from "./
|
|
3
|
-
export { getCallsStatus } from "./
|
|
4
|
-
export { getCapabilities, type GetCapabilitiesHooks, } from "./
|
|
1
|
+
export type { ProcessSendCallsRequest, ProcessSendCallsHooks, } from "./hooks/processSendCalls.mjs";
|
|
2
|
+
export { processSendCalls } from "./hooks/processSendCalls.mjs";
|
|
3
|
+
export { getCallsStatus } from "./hooks/getCallsStatus.mjs";
|
|
4
|
+
export { getCapabilities, type GetCapabilitiesHooks, } from "./hooks/getCapabilities.mjs";
|
|
5
|
+
export { walletSendCalls } from "./methods/wallet_sendCalls.mjs";
|
|
6
|
+
export { walletGetCallsStatus } from "./methods/wallet_getCallsStatus.mjs";
|
|
7
|
+
export { walletGetCapabilities } from "./methods/wallet_getCapabilities.mjs";
|
|
5
8
|
export type { EIP5792Messenger } from "./types.mjs";
|
|
9
|
+
export type { GetCallsStatusHook, GetCallsStatusParams, GetCallsStatusResult, GetCapabilitiesHook, GetCapabilitiesParams, GetCapabilitiesResult, ProcessSendCallsHook, SendCallsPayload as SendCalls, SendCallsParams, SendCallsResult, } from "./types.mjs";
|
|
6
10
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,qCAAiC;AAClC,OAAO,EAAE,gBAAgB,EAAE,qCAAiC;AAC5D,OAAO,EAAE,cAAc,EAAE,mCAA+B;AACxD,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,oCAAgC;AACjC,OAAO,EAAE,eAAe,EAAE,uCAAmC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,4CAAwC;AACvE,OAAO,EAAE,qBAAqB,EAAE,6CAAyC;AACzE,YAAY,EAAE,gBAAgB,EAAE,oBAAgB;AAEhD,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,IAAI,SAAS,EAC7B,eAAe,EACf,eAAe,GAChB,oBAAgB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export { processSendCalls } from "./
|
|
2
|
-
export { getCallsStatus } from "./
|
|
3
|
-
export { getCapabilities } from "./
|
|
1
|
+
export { processSendCalls } from "./hooks/processSendCalls.mjs";
|
|
2
|
+
export { getCallsStatus } from "./hooks/getCallsStatus.mjs";
|
|
3
|
+
export { getCapabilities } from "./hooks/getCapabilities.mjs";
|
|
4
|
+
export { walletSendCalls } from "./methods/wallet_sendCalls.mjs";
|
|
5
|
+
export { walletGetCallsStatus } from "./methods/wallet_getCallsStatus.mjs";
|
|
6
|
+
export { walletGetCapabilities } from "./methods/wallet_getCapabilities.mjs";
|
|
4
7
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,qCAAiC;AAC5D,OAAO,EAAE,cAAc,EAAE,mCAA+B;AACxD,OAAO,EACL,eAAe,EAEhB,oCAAgC;AACjC,OAAO,EAAE,eAAe,EAAE,uCAAmC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,4CAAwC;AACvE,OAAO,EAAE,qBAAqB,EAAE,6CAAyC","sourcesContent":["export type {\n ProcessSendCallsRequest,\n ProcessSendCallsHooks,\n} from './hooks/processSendCalls';\nexport { processSendCalls } from './hooks/processSendCalls';\nexport { getCallsStatus } from './hooks/getCallsStatus';\nexport {\n getCapabilities,\n type GetCapabilitiesHooks,\n} from './hooks/getCapabilities';\nexport { walletSendCalls } from './methods/wallet_sendCalls';\nexport { walletGetCallsStatus } from './methods/wallet_getCallsStatus';\nexport { walletGetCapabilities } from './methods/wallet_getCapabilities';\nexport type { EIP5792Messenger } from './types';\n\nexport type {\n GetCallsStatusHook,\n GetCallsStatusParams,\n GetCallsStatusResult,\n GetCapabilitiesHook,\n GetCapabilitiesParams,\n GetCapabilitiesResult,\n ProcessSendCallsHook,\n SendCallsPayload as SendCalls,\n SendCallsParams,\n SendCallsResult,\n} from './types';\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walletGetCallsStatus = void 0;
|
|
4
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
5
|
+
const types_1 = require("../types.cjs");
|
|
6
|
+
const utils_1 = require("../utils.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* The RPC method handler middleware for `wallet_getCallStatus`
|
|
9
|
+
*
|
|
10
|
+
* @param req - The JSON RPC request's end callback.
|
|
11
|
+
* @param res - The JSON RPC request's pending response object.
|
|
12
|
+
* @param hooks - The hooks object.
|
|
13
|
+
* @param hooks.getCallsStatus - Function that retrieves the status of a transaction batch by its ID.
|
|
14
|
+
*/
|
|
15
|
+
async function walletGetCallsStatus(req, res, { getCallsStatus, }) {
|
|
16
|
+
if (!getCallsStatus) {
|
|
17
|
+
throw rpc_errors_1.rpcErrors.methodNotSupported();
|
|
18
|
+
}
|
|
19
|
+
(0, utils_1.validateParams)(req.params, types_1.GetCallsStatusStruct);
|
|
20
|
+
const id = req.params[0];
|
|
21
|
+
res.result = await getCallsStatus(id, req);
|
|
22
|
+
}
|
|
23
|
+
exports.walletGetCallsStatus = walletGetCallsStatus;
|
|
24
|
+
//# sourceMappingURL=wallet_getCallsStatus.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_getCallsStatus.cjs","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,wCAAyE;AACzE,wCAA0C;AAE1C;;;;;;;GAOG;AACI,KAAK,UAAU,oBAAoB,CACxC,GAAmB,EACnB,GAA2B,EAC3B,EACE,cAAc,GAGf;IAED,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,sBAAS,CAAC,kBAAkB,EAAE,CAAC;KACtC;IAED,IAAA,sBAAc,EAAC,GAAG,CAAC,MAAM,EAAE,4BAAoB,CAAC,CAAC;IAEjD,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEzB,GAAG,CAAC,MAAM,GAAG,MAAM,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC;AAlBD,oDAkBC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { type GetCallsStatusHook, GetCallsStatusStruct } from '../types';\nimport { validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_getCallStatus`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getCallsStatus - Function that retrieves the status of a transaction batch by its ID.\n */\nexport async function walletGetCallsStatus(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getCallsStatus,\n }: {\n getCallsStatus?: GetCallsStatusHook;\n },\n): Promise<void> {\n if (!getCallsStatus) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, GetCallsStatusStruct);\n\n const id = req.params[0];\n\n res.result = await getCallsStatus(id, req);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JsonRpcRequest, PendingJsonRpcResponse } from "@metamask/utils";
|
|
2
|
+
import { type GetCallsStatusHook } from "../types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* The RPC method handler middleware for `wallet_getCallStatus`
|
|
5
|
+
*
|
|
6
|
+
* @param req - The JSON RPC request's end callback.
|
|
7
|
+
* @param res - The JSON RPC request's pending response object.
|
|
8
|
+
* @param hooks - The hooks object.
|
|
9
|
+
* @param hooks.getCallsStatus - Function that retrieves the status of a transaction batch by its ID.
|
|
10
|
+
*/
|
|
11
|
+
export declare function walletGetCallsStatus(req: JsonRpcRequest, res: PendingJsonRpcResponse, { getCallsStatus, }: {
|
|
12
|
+
getCallsStatus?: GetCallsStatusHook;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=wallet_getCallsStatus.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_getCallsStatus.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAE9E,OAAO,EAAE,KAAK,kBAAkB,EAAwB,qBAAiB;AAGzE;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,cAAc,GACf,EAAE;IACD,cAAc,CAAC,EAAE,kBAAkB,CAAC;CACrC,GACA,OAAO,CAAC,IAAI,CAAC,CAUf"}
|