@metamask/eip-5792-middleware 1.0.0 → 1.2.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/constants.cjs +21 -1
  3. package/dist/constants.cjs.map +1 -1
  4. package/dist/constants.d.cts +15 -0
  5. package/dist/constants.d.cts.map +1 -1
  6. package/dist/constants.d.mts +15 -0
  7. package/dist/constants.d.mts.map +1 -1
  8. package/dist/constants.mjs +20 -0
  9. package/dist/constants.mjs.map +1 -1
  10. package/dist/{methods → hooks}/getCallsStatus.cjs +5 -6
  11. package/dist/hooks/getCallsStatus.cjs.map +1 -0
  12. package/dist/{methods → hooks}/getCallsStatus.d.cts +1 -2
  13. package/dist/hooks/getCallsStatus.d.cts.map +1 -0
  14. package/dist/{methods → hooks}/getCallsStatus.d.mts +1 -2
  15. package/dist/hooks/getCallsStatus.d.mts.map +1 -0
  16. package/dist/{methods → hooks}/getCallsStatus.mjs +1 -2
  17. package/dist/hooks/getCallsStatus.mjs.map +1 -0
  18. package/dist/{methods → hooks}/getCapabilities.cjs +10 -4
  19. package/dist/hooks/getCapabilities.cjs.map +1 -0
  20. package/dist/{methods → hooks}/getCapabilities.d.cts +3 -2
  21. package/dist/hooks/getCapabilities.d.cts.map +1 -0
  22. package/dist/{methods → hooks}/getCapabilities.d.mts +3 -2
  23. package/dist/hooks/getCapabilities.d.mts.map +1 -0
  24. package/dist/{methods → hooks}/getCapabilities.mjs +10 -4
  25. package/dist/hooks/getCapabilities.mjs.map +1 -0
  26. package/dist/{methods → hooks}/processSendCalls.cjs +104 -13
  27. package/dist/hooks/processSendCalls.cjs.map +1 -0
  28. package/dist/{methods → hooks}/processSendCalls.d.cts +4 -3
  29. package/dist/hooks/processSendCalls.d.cts.map +1 -0
  30. package/dist/{methods → hooks}/processSendCalls.d.mts +4 -3
  31. package/dist/hooks/processSendCalls.d.mts.map +1 -0
  32. package/dist/{methods → hooks}/processSendCalls.mjs +107 -15
  33. package/dist/hooks/processSendCalls.mjs.map +1 -0
  34. package/dist/index.cjs +10 -4
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +8 -4
  37. package/dist/index.d.cts.map +1 -1
  38. package/dist/index.d.mts +8 -4
  39. package/dist/index.d.mts.map +1 -1
  40. package/dist/index.mjs +6 -3
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/methods/wallet_getCallsStatus.cjs +24 -0
  43. package/dist/methods/wallet_getCallsStatus.cjs.map +1 -0
  44. package/dist/methods/wallet_getCallsStatus.d.cts +14 -0
  45. package/dist/methods/wallet_getCallsStatus.d.cts.map +1 -0
  46. package/dist/methods/wallet_getCallsStatus.d.mts +14 -0
  47. package/dist/methods/wallet_getCallsStatus.d.mts.map +1 -0
  48. package/dist/methods/wallet_getCallsStatus.mjs +20 -0
  49. package/dist/methods/wallet_getCallsStatus.mjs.map +1 -0
  50. package/dist/methods/wallet_getCapabilities.cjs +30 -0
  51. package/dist/methods/wallet_getCapabilities.cjs.map +1 -0
  52. package/dist/methods/wallet_getCapabilities.d.cts +16 -0
  53. package/dist/methods/wallet_getCapabilities.d.cts.map +1 -0
  54. package/dist/methods/wallet_getCapabilities.d.mts +16 -0
  55. package/dist/methods/wallet_getCapabilities.d.mts.map +1 -0
  56. package/dist/methods/wallet_getCapabilities.mjs +26 -0
  57. package/dist/methods/wallet_getCapabilities.mjs.map +1 -0
  58. package/dist/methods/wallet_sendCalls.cjs +34 -0
  59. package/dist/methods/wallet_sendCalls.cjs.map +1 -0
  60. package/dist/methods/wallet_sendCalls.d.cts +16 -0
  61. package/dist/methods/wallet_sendCalls.d.cts.map +1 -0
  62. package/dist/methods/wallet_sendCalls.d.mts +16 -0
  63. package/dist/methods/wallet_sendCalls.d.mts.map +1 -0
  64. package/dist/methods/wallet_sendCalls.mjs +30 -0
  65. package/dist/methods/wallet_sendCalls.mjs.map +1 -0
  66. package/dist/types.cjs +36 -0
  67. package/dist/types.cjs.map +1 -1
  68. package/dist/types.d.cts +82 -0
  69. package/dist/types.d.cts.map +1 -1
  70. package/dist/types.d.mts +82 -0
  71. package/dist/types.d.mts.map +1 -1
  72. package/dist/types.mjs +35 -1
  73. package/dist/types.mjs.map +1 -1
  74. package/dist/utils.cjs +70 -1
  75. package/dist/utils.cjs.map +1 -1
  76. package/dist/utils.d.cts +31 -1
  77. package/dist/utils.d.cts.map +1 -1
  78. package/dist/utils.d.mts +31 -1
  79. package/dist/utils.d.mts.map +1 -1
  80. package/dist/utils.mjs +67 -1
  81. package/dist/utils.mjs.map +1 -1
  82. package/package.json +7 -4
  83. package/dist/methods/getCallsStatus.cjs.map +0 -1
  84. package/dist/methods/getCallsStatus.d.cts.map +0 -1
  85. package/dist/methods/getCallsStatus.d.mts.map +0 -1
  86. package/dist/methods/getCallsStatus.mjs.map +0 -1
  87. package/dist/methods/getCapabilities.cjs.map +0 -1
  88. package/dist/methods/getCapabilities.d.cts.map +0 -1
  89. package/dist/methods/getCapabilities.d.mts.map +0 -1
  90. package/dist/methods/getCapabilities.mjs.map +0 -1
  91. package/dist/methods/processSendCalls.cjs.map +0 -1
  92. package/dist/methods/processSendCalls.d.cts.map +0 -1
  93. package/dist/methods/processSendCalls.d.mts.map +0 -1
  94. package/dist/methods/processSendCalls.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,11 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.0]
11
+
12
+ ### Changed
13
+
14
+ - Add `auxiliaryFunds` + `requiredAssets` support defined under [ERC-7682](https://eips.ethereum.org/EIPS/eip-7682) ([#6623](https://github.com/MetaMask/core/pull/6623))
15
+ - Bump `@metamask/transaction-controller` from `^60.2.0` to `^60.4.0` ([#6561](https://github.com/MetaMask/core/pull/6561), [#6641](https://github.com/MetaMask/core/pull/6641))
16
+ - Bump `@metamask/utils` from `^11.4.2` to `^11.8.0` ([#6588](https://github.com/MetaMask/core/pull/6588))
17
+
18
+ ## [1.1.0]
19
+
20
+ ### Added
21
+
22
+ - Add and export EIP-5792 RPC method handler middlewares and utility types ([#6477](https://github.com/MetaMask/core/pull/6477))
23
+
10
24
  ## [1.0.0]
11
25
 
12
26
  ### Added
13
27
 
14
28
  - Initial release ([#6458](https://github.com/MetaMask/core/pull/6458))
15
29
 
16
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/eip-5792-middleware@1.0.0...HEAD
30
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/eip-5792-middleware@1.2.0...HEAD
31
+ [1.2.0]: https://github.com/MetaMask/core/compare/@metamask/eip-5792-middleware@1.1.0...@metamask/eip-5792-middleware@1.2.0
32
+ [1.1.0]: https://github.com/MetaMask/core/compare/@metamask/eip-5792-middleware@1.0.0...@metamask/eip-5792-middleware@1.1.0
17
33
  [1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/eip-5792-middleware@1.0.0
@@ -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.EIP7682ErrorCode = exports.EIP5792ErrorCode = exports.SupportedCapabilities = 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 = [
@@ -11,6 +11,10 @@ var MessageType;
11
11
  (function (MessageType) {
12
12
  MessageType["SendTransaction"] = "eth_sendTransaction";
13
13
  })(MessageType || (exports.MessageType = MessageType = {}));
14
+ var SupportedCapabilities;
15
+ (function (SupportedCapabilities) {
16
+ SupportedCapabilities["AuxiliaryFunds"] = "auxiliaryFunds";
17
+ })(SupportedCapabilities || (exports.SupportedCapabilities = SupportedCapabilities = {}));
14
18
  // To be moved to @metamask/rpc-errors in future.
15
19
  var EIP5792ErrorCode;
16
20
  (function (EIP5792ErrorCode) {
@@ -19,4 +23,20 @@ var EIP5792ErrorCode;
19
23
  EIP5792ErrorCode[EIP5792ErrorCode["UnknownBundleId"] = 5730] = "UnknownBundleId";
20
24
  EIP5792ErrorCode[EIP5792ErrorCode["RejectedUpgrade"] = 5750] = "RejectedUpgrade";
21
25
  })(EIP5792ErrorCode || (exports.EIP5792ErrorCode = EIP5792ErrorCode = {}));
26
+ // To be moved to @metamask/rpc-errors in future.
27
+ var EIP7682ErrorCode;
28
+ (function (EIP7682ErrorCode) {
29
+ EIP7682ErrorCode[EIP7682ErrorCode["UnsupportedAsset"] = 5771] = "UnsupportedAsset";
30
+ EIP7682ErrorCode[EIP7682ErrorCode["UnsupportedChain"] = 5772] = "UnsupportedChain";
31
+ EIP7682ErrorCode[EIP7682ErrorCode["MalformedRequiredAssets"] = 5773] = "MalformedRequiredAssets";
32
+ })(EIP7682ErrorCode || (exports.EIP7682ErrorCode = EIP7682ErrorCode = {}));
33
+ // wallet_getCallStatus
34
+ var GetCallsStatusCode;
35
+ (function (GetCallsStatusCode) {
36
+ GetCallsStatusCode[GetCallsStatusCode["PENDING"] = 100] = "PENDING";
37
+ GetCallsStatusCode[GetCallsStatusCode["CONFIRMED"] = 200] = "CONFIRMED";
38
+ GetCallsStatusCode[GetCallsStatusCode["FAILED_OFFCHAIN"] = 400] = "FAILED_OFFCHAIN";
39
+ GetCallsStatusCode[GetCallsStatusCode["REVERTED"] = 500] = "REVERTED";
40
+ GetCallsStatusCode[GetCallsStatusCode["REVERTED_PARTIAL"] = 600] = "REVERTED_PARTIAL";
41
+ })(GetCallsStatusCode || (exports.GetCallsStatusCode = GetCallsStatusCode = {}));
22
42
  //# sourceMappingURL=constants.cjs.map
@@ -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,IAAY,qBAEX;AAFD,WAAY,qBAAqB;IAC/B,0DAAiC,CAAA;AACnC,CAAC,EAFW,qBAAqB,qCAArB,qBAAqB,QAEhC;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,iDAAiD;AACjD,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,kFAAuB,CAAA;IACvB,kFAAuB,CAAA;IACvB,gGAA8B,CAAA;AAChC,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;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\nexport enum SupportedCapabilities {\n AuxiliaryFunds = 'auxiliaryFunds',\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// To be moved to @metamask/rpc-errors in future.\nexport enum EIP7682ErrorCode {\n UnsupportedAsset = 5771,\n UnsupportedChain = 5772,\n MalformedRequiredAssets = 5773,\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"]}
@@ -4,10 +4,25 @@ export declare const KEYRING_TYPES_SUPPORTING_7702: KeyringTypes[];
4
4
  export declare enum MessageType {
5
5
  SendTransaction = "eth_sendTransaction"
6
6
  }
7
+ export declare enum SupportedCapabilities {
8
+ AuxiliaryFunds = "auxiliaryFunds"
9
+ }
7
10
  export declare enum EIP5792ErrorCode {
8
11
  UnsupportedNonOptionalCapability = 5700,
9
12
  UnsupportedChainId = 5710,
10
13
  UnknownBundleId = 5730,
11
14
  RejectedUpgrade = 5750
12
15
  }
16
+ export declare enum EIP7682ErrorCode {
17
+ UnsupportedAsset = 5771,
18
+ UnsupportedChain = 5772,
19
+ MalformedRequiredAssets = 5773
20
+ }
21
+ export declare enum GetCallsStatusCode {
22
+ PENDING = 100,
23
+ CONFIRMED = 200,
24
+ FAILED_OFFCHAIN = 400,
25
+ REVERTED = 500,
26
+ REVERTED_PARTIAL = 600
27
+ }
13
28
  //# sourceMappingURL=constants.d.cts.map
@@ -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;AAED,oBAAY,qBAAqB;IAC/B,cAAc,mBAAmB;CAClC;AAGD,oBAAY,gBAAgB;IAC1B,gCAAgC,OAAO;IACvC,kBAAkB,OAAO;IACzB,eAAe,OAAO;IACtB,eAAe,OAAO;CACvB;AAGD,oBAAY,gBAAgB;IAC1B,gBAAgB,OAAO;IACvB,gBAAgB,OAAO;IACvB,uBAAuB,OAAO;CAC/B;AAGD,oBAAY,kBAAkB;IAC5B,OAAO,MAAM;IACb,SAAS,MAAM;IACf,eAAe,MAAM;IACrB,QAAQ,MAAM;IACd,gBAAgB,MAAM;CACvB"}
@@ -4,10 +4,25 @@ export declare const KEYRING_TYPES_SUPPORTING_7702: KeyringTypes[];
4
4
  export declare enum MessageType {
5
5
  SendTransaction = "eth_sendTransaction"
6
6
  }
7
+ export declare enum SupportedCapabilities {
8
+ AuxiliaryFunds = "auxiliaryFunds"
9
+ }
7
10
  export declare enum EIP5792ErrorCode {
8
11
  UnsupportedNonOptionalCapability = 5700,
9
12
  UnsupportedChainId = 5710,
10
13
  UnknownBundleId = 5730,
11
14
  RejectedUpgrade = 5750
12
15
  }
16
+ export declare enum EIP7682ErrorCode {
17
+ UnsupportedAsset = 5771,
18
+ UnsupportedChain = 5772,
19
+ MalformedRequiredAssets = 5773
20
+ }
21
+ export declare enum GetCallsStatusCode {
22
+ PENDING = 100,
23
+ CONFIRMED = 200,
24
+ FAILED_OFFCHAIN = 400,
25
+ REVERTED = 500,
26
+ REVERTED_PARTIAL = 600
27
+ }
13
28
  //# sourceMappingURL=constants.d.mts.map
@@ -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;AAED,oBAAY,qBAAqB;IAC/B,cAAc,mBAAmB;CAClC;AAGD,oBAAY,gBAAgB;IAC1B,gCAAgC,OAAO;IACvC,kBAAkB,OAAO;IACzB,eAAe,OAAO;IACtB,eAAe,OAAO;CACvB;AAGD,oBAAY,gBAAgB;IAC1B,gBAAgB,OAAO;IACvB,gBAAgB,OAAO;IACvB,uBAAuB,OAAO;CAC/B;AAGD,oBAAY,kBAAkB;IAC5B,OAAO,MAAM;IACb,SAAS,MAAM;IACf,eAAe,MAAM;IACrB,QAAQ,MAAM;IACd,gBAAgB,MAAM;CACvB"}
@@ -8,6 +8,10 @@ export var MessageType;
8
8
  (function (MessageType) {
9
9
  MessageType["SendTransaction"] = "eth_sendTransaction";
10
10
  })(MessageType || (MessageType = {}));
11
+ export var SupportedCapabilities;
12
+ (function (SupportedCapabilities) {
13
+ SupportedCapabilities["AuxiliaryFunds"] = "auxiliaryFunds";
14
+ })(SupportedCapabilities || (SupportedCapabilities = {}));
11
15
  // To be moved to @metamask/rpc-errors in future.
12
16
  export var EIP5792ErrorCode;
13
17
  (function (EIP5792ErrorCode) {
@@ -16,4 +20,20 @@ export var EIP5792ErrorCode;
16
20
  EIP5792ErrorCode[EIP5792ErrorCode["UnknownBundleId"] = 5730] = "UnknownBundleId";
17
21
  EIP5792ErrorCode[EIP5792ErrorCode["RejectedUpgrade"] = 5750] = "RejectedUpgrade";
18
22
  })(EIP5792ErrorCode || (EIP5792ErrorCode = {}));
23
+ // To be moved to @metamask/rpc-errors in future.
24
+ export var EIP7682ErrorCode;
25
+ (function (EIP7682ErrorCode) {
26
+ EIP7682ErrorCode[EIP7682ErrorCode["UnsupportedAsset"] = 5771] = "UnsupportedAsset";
27
+ EIP7682ErrorCode[EIP7682ErrorCode["UnsupportedChain"] = 5772] = "UnsupportedChain";
28
+ EIP7682ErrorCode[EIP7682ErrorCode["MalformedRequiredAssets"] = 5773] = "MalformedRequiredAssets";
29
+ })(EIP7682ErrorCode || (EIP7682ErrorCode = {}));
30
+ // wallet_getCallStatus
31
+ export var GetCallsStatusCode;
32
+ (function (GetCallsStatusCode) {
33
+ GetCallsStatusCode[GetCallsStatusCode["PENDING"] = 100] = "PENDING";
34
+ GetCallsStatusCode[GetCallsStatusCode["CONFIRMED"] = 200] = "CONFIRMED";
35
+ GetCallsStatusCode[GetCallsStatusCode["FAILED_OFFCHAIN"] = 400] = "FAILED_OFFCHAIN";
36
+ GetCallsStatusCode[GetCallsStatusCode["REVERTED"] = 500] = "REVERTED";
37
+ GetCallsStatusCode[GetCallsStatusCode["REVERTED_PARTIAL"] = 600] = "REVERTED_PARTIAL";
38
+ })(GetCallsStatusCode || (GetCallsStatusCode = {}));
19
39
  //# sourceMappingURL=constants.mjs.map
@@ -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,MAAM,CAAN,IAAY,qBAEX;AAFD,WAAY,qBAAqB;IAC/B,0DAAiC,CAAA;AACnC,CAAC,EAFW,qBAAqB,KAArB,qBAAqB,QAEhC;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,iDAAiD;AACjD,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,kFAAuB,CAAA;IACvB,kFAAuB,CAAA;IACvB,gGAA8B,CAAA;AAChC,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;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\nexport enum SupportedCapabilities {\n AuxiliaryFunds = 'auxiliaryFunds',\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// To be moved to @metamask/rpc-errors in future.\nexport enum EIP7682ErrorCode {\n UnsupportedAsset = 5771,\n UnsupportedChain = 5772,\n MalformedRequiredAssets = 5773,\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 eth_json_rpc_middleware_1.GetCallsStatusCode.CONFIRMED;
60
+ return constants_1.GetCallsStatusCode.CONFIRMED;
62
61
  }
63
62
  if (status === transaction_controller_1.TransactionStatus.failed) {
64
63
  return hash
65
- ? eth_json_rpc_middleware_1.GetCallsStatusCode.REVERTED
66
- : eth_json_rpc_middleware_1.GetCallsStatusCode.FAILED_OFFCHAIN;
64
+ ? constants_1.GetCallsStatusCode.REVERTED
65
+ : constants_1.GetCallsStatusCode.FAILED_OFFCHAIN;
67
66
  }
68
67
  if (status === transaction_controller_1.TransactionStatus.dropped) {
69
- return eth_json_rpc_middleware_1.GetCallsStatusCode.REVERTED;
68
+ return constants_1.GetCallsStatusCode.REVERTED;
70
69
  }
71
- return eth_json_rpc_middleware_1.GetCallsStatusCode.PENDING;
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,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,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":"AAAA,OAAO,EAAE,YAAY,EAAE,6BAA6B;AAMpD,OAAO,EAAE,iBAAiB,EAAE,yCAAyC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,OAAO,EAAE,yBAAqB;AAG7E;;;;;;;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 { 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"]}
@@ -13,7 +13,7 @@ const utils_1 = require("../utils.cjs");
13
13
  * @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.
14
14
  */
15
15
  async function getCapabilities(hooks, messenger, address, chainIds) {
16
- const { getDismissSmartAccountSuggestionEnabled, getIsSmartTransaction, isAtomicBatchSupported, isRelaySupported, getSendBundleSupportedChains, } = hooks;
16
+ const { getDismissSmartAccountSuggestionEnabled, getIsSmartTransaction, isAtomicBatchSupported, isRelaySupported, getSendBundleSupportedChains, isAuxiliaryFundsSupported, } = hooks;
17
17
  let chainIdsNormalized = chainIds?.map((chainId) => chainId.toLowerCase());
18
18
  if (!chainIdsNormalized?.length) {
19
19
  const networkConfigurations = messenger.call('NetworkController:getState').networkConfigurationsByChainId;
@@ -44,12 +44,18 @@ async function getCapabilities(hooks, messenger, address, chainIds) {
44
44
  return acc;
45
45
  }
46
46
  const status = isSupported ? 'supported' : 'ready';
47
- if (acc[chainId] === undefined) {
48
- acc[chainId] = {};
47
+ const hexChainId = chainId;
48
+ if (acc[hexChainId] === undefined) {
49
+ acc[hexChainId] = {};
49
50
  }
50
- acc[chainId].atomic = {
51
+ acc[hexChainId].atomic = {
51
52
  status,
52
53
  };
54
+ if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) {
55
+ acc[hexChainId].auxiliaryFunds = {
56
+ supported: true,
57
+ };
58
+ }
53
59
  return acc;
54
60
  }, alternateGasFeesAcc);
55
61
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCapabilities.cjs","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":";;;AAOA,gDAA6D;AAE7D,wCAAiD;AAsBjD;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CACnC,KAA2B,EAC3B,SAA2B,EAC3B,OAAY,EACZ,QAA2B;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B,MAAM,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,mBAAmB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAChE,GAAG,OAAO;QACV,sBAAsB,EAAE,oBAAoB,CAAC,KAAK,CAAC;KACpD,CAAC,CAAC,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 /** Function to validate if auxiliary funds capability is supported. */\n isAuxiliaryFundsSupported: (chainId: Hex) => 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 isAuxiliaryFundsSupported,\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 const hexChainId = chainId as Hex;\n\n if (acc[hexChainId] === undefined) {\n acc[hexChainId] = {};\n }\n\n acc[hexChainId].atomic = {\n status,\n };\n\n if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) {\n acc[hexChainId].auxiliaryFunds = {\n supported: true,\n };\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
  */
@@ -16,6 +15,8 @@ export type GetCapabilitiesHooks = {
16
15
  isRelaySupported: (chainId: Hex) => Promise<boolean>;
17
16
  /** Function to get chains that support send bundle */
18
17
  getSendBundleSupportedChains: (chainIds: Hex[]) => Promise<Record<string, boolean>>;
18
+ /** Function to validate if auxiliary funds capability is supported. */
19
+ isAuxiliaryFundsSupported: (chainId: Hex) => boolean;
19
20
  };
20
21
  /**
21
22
  * Retrieves the capabilities for atomic transactions on specified chains.
@@ -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;IACtC,uEAAuE;IACvE,yBAAyB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;CACtD,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,kCAqF5B"}
@@ -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
  */
@@ -16,6 +15,8 @@ export type GetCapabilitiesHooks = {
16
15
  isRelaySupported: (chainId: Hex) => Promise<boolean>;
17
16
  /** Function to get chains that support send bundle */
18
17
  getSendBundleSupportedChains: (chainIds: Hex[]) => Promise<Record<string, boolean>>;
18
+ /** Function to validate if auxiliary funds capability is supported. */
19
+ isAuxiliaryFundsSupported: (chainId: Hex) => boolean;
19
20
  };
20
21
  /**
21
22
  * Retrieves the capabilities for atomic transactions on specified chains.
@@ -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,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;IACtC,uEAAuE;IACvE,yBAAyB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;CACtD,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,kCAqF5B"}
@@ -10,7 +10,7 @@ import { getAccountKeyringType } from "../utils.mjs";
10
10
  * @returns Promise resolving to GetCapabilitiesResult mapping chain IDs to their capabilities.
11
11
  */
12
12
  export async function getCapabilities(hooks, messenger, address, chainIds) {
13
- const { getDismissSmartAccountSuggestionEnabled, getIsSmartTransaction, isAtomicBatchSupported, isRelaySupported, getSendBundleSupportedChains, } = hooks;
13
+ const { getDismissSmartAccountSuggestionEnabled, getIsSmartTransaction, isAtomicBatchSupported, isRelaySupported, getSendBundleSupportedChains, isAuxiliaryFundsSupported, } = hooks;
14
14
  let chainIdsNormalized = chainIds?.map((chainId) => chainId.toLowerCase());
15
15
  if (!chainIdsNormalized?.length) {
16
16
  const networkConfigurations = messenger.call('NetworkController:getState').networkConfigurationsByChainId;
@@ -41,12 +41,18 @@ export async function getCapabilities(hooks, messenger, address, chainIds) {
41
41
  return acc;
42
42
  }
43
43
  const status = isSupported ? 'supported' : 'ready';
44
- if (acc[chainId] === undefined) {
45
- acc[chainId] = {};
44
+ const hexChainId = chainId;
45
+ if (acc[hexChainId] === undefined) {
46
+ acc[hexChainId] = {};
46
47
  }
47
- acc[chainId].atomic = {
48
+ acc[hexChainId].atomic = {
48
49
  status,
49
50
  };
51
+ if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) {
52
+ acc[hexChainId].auxiliaryFunds = {
53
+ supported: true,
54
+ };
55
+ }
50
56
  return acc;
51
57
  }, alternateGasFeesAcc);
52
58
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCapabilities.mjs","sourceRoot":"","sources":["../../src/hooks/getCapabilities.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,6BAA6B,EAAE,yBAAqB;AAE7D,OAAO,EAAE,qBAAqB,EAAE,qBAAiB;AAsBjD;;;;;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CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAC/C,CAAC;IAEF,MAAM,yBAAyB,GAC7B,MAAM,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,mBAAmB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAChE,GAAG,OAAO;QACV,sBAAsB,EAAE,oBAAoB,CAAC,KAAK,CAAC;KACpD,CAAC,CAAC,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 /** Function to validate if auxiliary funds capability is supported. */\n isAuxiliaryFundsSupported: (chainId: Hex) => 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 isAuxiliaryFundsSupported,\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 const hexChainId = chainId as Hex;\n\n if (acc[hexChainId] === undefined) {\n acc[hexChainId] = {};\n }\n\n acc[hexChainId].atomic = {\n status,\n };\n\n if (isSupportedAccount && isAuxiliaryFundsSupported(chainId)) {\n acc[hexChainId].auxiliaryFunds = {\n supported: true,\n };\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"]}