@metamask/bridge-controller 62.0.0 → 63.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 +35 -1
- package/dist/bridge-controller.cjs +46 -19
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +46 -19
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/constants/swaps.cjs +95 -1
- package/dist/constants/swaps.cjs.map +1 -1
- package/dist/constants/swaps.d.cts +5 -0
- package/dist/constants/swaps.d.cts.map +1 -1
- package/dist/constants/swaps.d.mts +5 -0
- package/dist/constants/swaps.d.mts.map +1 -1
- package/dist/constants/swaps.mjs +94 -0
- package/dist/constants/swaps.mjs.map +1 -1
- package/dist/index.cjs +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/fetch-server-events.cjs +2 -2
- package/dist/utils/fetch-server-events.cjs.map +1 -1
- package/dist/utils/fetch-server-events.d.cts +2 -2
- package/dist/utils/fetch-server-events.d.cts.map +1 -1
- package/dist/utils/fetch-server-events.d.mts +2 -2
- package/dist/utils/fetch-server-events.d.mts.map +1 -1
- package/dist/utils/fetch-server-events.mjs +2 -2
- package/dist/utils/fetch-server-events.mjs.map +1 -1
- package/dist/utils/fetch.cjs +9 -13
- package/dist/utils/fetch.cjs.map +1 -1
- package/dist/utils/fetch.d.cts +2 -2
- package/dist/utils/fetch.d.cts.map +1 -1
- package/dist/utils/fetch.d.mts +2 -2
- package/dist/utils/fetch.d.mts.map +1 -1
- package/dist/utils/fetch.mjs +9 -13
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/swaps.cjs +29 -0
- package/dist/utils/swaps.cjs.map +1 -0
- package/dist/utils/swaps.d.cts +17 -0
- package/dist/utils/swaps.d.cts.map +1 -0
- package/dist/utils/swaps.d.mts +17 -0
- package/dist/utils/swaps.d.mts.map +1 -0
- package/dist/utils/swaps.mjs +24 -0
- package/dist/utils/swaps.mjs.map +1 -0
- package/package.json +7 -15
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSwapsContractAddress = exports.isValidSwapsContractAddress = void 0;
|
|
4
|
+
const swaps_1 = require("../constants/swaps.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the given contract address is valid for the given chain ID.
|
|
7
|
+
*
|
|
8
|
+
* @param chainId - The chain ID.
|
|
9
|
+
* @param contract - The contract address.
|
|
10
|
+
* @returns True if the contract address is valid, false otherwise.
|
|
11
|
+
*/
|
|
12
|
+
function isValidSwapsContractAddress(chainId, contract) {
|
|
13
|
+
if (!contract || !swaps_1.ALLOWED_CONTRACT_ADDRESSES[chainId]) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return swaps_1.ALLOWED_CONTRACT_ADDRESSES[chainId].some((allowedContract) => contract.toLowerCase() === allowedContract.toLowerCase());
|
|
17
|
+
}
|
|
18
|
+
exports.isValidSwapsContractAddress = isValidSwapsContractAddress;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the swaps contract address for the given chain ID.
|
|
21
|
+
*
|
|
22
|
+
* @param chainId - The chain ID.
|
|
23
|
+
* @returns The swaps contract address.
|
|
24
|
+
*/
|
|
25
|
+
function getSwapsContractAddress(chainId) {
|
|
26
|
+
return swaps_1.SWAPS_CONTRACT_ADDRESSES[chainId];
|
|
27
|
+
}
|
|
28
|
+
exports.getSwapsContractAddress = getSwapsContractAddress;
|
|
29
|
+
//# sourceMappingURL=swaps.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swaps.cjs","sourceRoot":"","sources":["../../src/utils/swaps.ts"],"names":[],"mappings":";;;AAEA,kDAG4B;AAE5B;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,OAAY,EACZ,QAAyB;IAEzB,IAAI,CAAC,QAAQ,IAAI,CAAC,kCAA0B,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,kCAA0B,CAAC,OAAO,CAAC,CAAC,IAAI,CAC7C,CAAC,eAAe,EAAE,EAAE,CAClB,QAAQ,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,WAAW,EAAE,CAC3D,CAAC;AACJ,CAAC;AAXD,kEAWC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,OAAY;IAClD,OAAO,gCAAwB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAFD,0DAEC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport {\n ALLOWED_CONTRACT_ADDRESSES,\n SWAPS_CONTRACT_ADDRESSES,\n} from '../constants/swaps';\n\n/**\n * Checks if the given contract address is valid for the given chain ID.\n *\n * @param chainId - The chain ID.\n * @param contract - The contract address.\n * @returns True if the contract address is valid, false otherwise.\n */\nexport function isValidSwapsContractAddress(\n chainId: Hex,\n contract: Hex | undefined,\n): boolean {\n if (!contract || !ALLOWED_CONTRACT_ADDRESSES[chainId]) {\n return false;\n }\n return ALLOWED_CONTRACT_ADDRESSES[chainId].some(\n (allowedContract) =>\n contract.toLowerCase() === allowedContract.toLowerCase(),\n );\n}\n\n/**\n * Gets the swaps contract address for the given chain ID.\n *\n * @param chainId - The chain ID.\n * @returns The swaps contract address.\n */\nexport function getSwapsContractAddress(chainId: Hex): string {\n return SWAPS_CONTRACT_ADDRESSES[chainId];\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given contract address is valid for the given chain ID.
|
|
4
|
+
*
|
|
5
|
+
* @param chainId - The chain ID.
|
|
6
|
+
* @param contract - The contract address.
|
|
7
|
+
* @returns True if the contract address is valid, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidSwapsContractAddress(chainId: Hex, contract: Hex | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the swaps contract address for the given chain ID.
|
|
12
|
+
*
|
|
13
|
+
* @param chainId - The chain ID.
|
|
14
|
+
* @returns The swaps contract address.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSwapsContractAddress(chainId: Hex): string;
|
|
17
|
+
//# sourceMappingURL=swaps.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swaps.d.cts","sourceRoot":"","sources":["../../src/utils/swaps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAO3C;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,GAAG,GAAG,SAAS,GACxB,OAAO,CAQT;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given contract address is valid for the given chain ID.
|
|
4
|
+
*
|
|
5
|
+
* @param chainId - The chain ID.
|
|
6
|
+
* @param contract - The contract address.
|
|
7
|
+
* @returns True if the contract address is valid, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidSwapsContractAddress(chainId: Hex, contract: Hex | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the swaps contract address for the given chain ID.
|
|
12
|
+
*
|
|
13
|
+
* @param chainId - The chain ID.
|
|
14
|
+
* @returns The swaps contract address.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSwapsContractAddress(chainId: Hex): string;
|
|
17
|
+
//# sourceMappingURL=swaps.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swaps.d.mts","sourceRoot":"","sources":["../../src/utils/swaps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAO3C;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,GAAG,GAAG,SAAS,GACxB,OAAO,CAQT;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ALLOWED_CONTRACT_ADDRESSES, SWAPS_CONTRACT_ADDRESSES } from "../constants/swaps.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given contract address is valid for the given chain ID.
|
|
4
|
+
*
|
|
5
|
+
* @param chainId - The chain ID.
|
|
6
|
+
* @param contract - The contract address.
|
|
7
|
+
* @returns True if the contract address is valid, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export function isValidSwapsContractAddress(chainId, contract) {
|
|
10
|
+
if (!contract || !ALLOWED_CONTRACT_ADDRESSES[chainId]) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return ALLOWED_CONTRACT_ADDRESSES[chainId].some((allowedContract) => contract.toLowerCase() === allowedContract.toLowerCase());
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Gets the swaps contract address for the given chain ID.
|
|
17
|
+
*
|
|
18
|
+
* @param chainId - The chain ID.
|
|
19
|
+
* @returns The swaps contract address.
|
|
20
|
+
*/
|
|
21
|
+
export function getSwapsContractAddress(chainId) {
|
|
22
|
+
return SWAPS_CONTRACT_ADDRESSES[chainId];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=swaps.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swaps.mjs","sourceRoot":"","sources":["../../src/utils/swaps.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACzB,+BAA2B;AAE5B;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAY,EACZ,QAAyB;IAEzB,IAAI,CAAC,QAAQ,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC,IAAI,CAC7C,CAAC,eAAe,EAAE,EAAE,CAClB,QAAQ,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,WAAW,EAAE,CAC3D,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAY;IAClD,OAAO,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport {\n ALLOWED_CONTRACT_ADDRESSES,\n SWAPS_CONTRACT_ADDRESSES,\n} from '../constants/swaps';\n\n/**\n * Checks if the given contract address is valid for the given chain ID.\n *\n * @param chainId - The chain ID.\n * @param contract - The contract address.\n * @returns True if the contract address is valid, false otherwise.\n */\nexport function isValidSwapsContractAddress(\n chainId: Hex,\n contract: Hex | undefined,\n): boolean {\n if (!contract || !ALLOWED_CONTRACT_ADDRESSES[chainId]) {\n return false;\n }\n return ALLOWED_CONTRACT_ADDRESSES[chainId].some(\n (allowedContract) =>\n contract.toLowerCase() === allowedContract.toLowerCase(),\n );\n}\n\n/**\n * Gets the swaps contract address for the given chain ID.\n *\n * @param chainId - The chain ID.\n * @returns The swaps contract address.\n */\nexport function getSwapsContractAddress(chainId: Hex): string {\n return SWAPS_CONTRACT_ADDRESSES[chainId];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/bridge-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "63.1.0",
|
|
4
4
|
"description": "Manages bridge-related quote fetching functionality for MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -53,6 +53,8 @@
|
|
|
53
53
|
"@ethersproject/constants": "^5.7.0",
|
|
54
54
|
"@ethersproject/contracts": "^5.7.0",
|
|
55
55
|
"@ethersproject/providers": "^5.7.0",
|
|
56
|
+
"@metamask/accounts-controller": "^35.0.0",
|
|
57
|
+
"@metamask/assets-controllers": "^91.0.0",
|
|
56
58
|
"@metamask/base-controller": "^9.0.0",
|
|
57
59
|
"@metamask/controller-utils": "^11.16.0",
|
|
58
60
|
"@metamask/gas-fee-controller": "^26.0.0",
|
|
@@ -60,22 +62,20 @@
|
|
|
60
62
|
"@metamask/messenger": "^0.3.0",
|
|
61
63
|
"@metamask/metamask-eth-abis": "^3.1.1",
|
|
62
64
|
"@metamask/multichain-network-controller": "^3.0.0",
|
|
65
|
+
"@metamask/network-controller": "^26.0.0",
|
|
63
66
|
"@metamask/polling-controller": "^16.0.0",
|
|
67
|
+
"@metamask/remote-feature-flag-controller": "^2.0.1",
|
|
68
|
+
"@metamask/snaps-controllers": "^14.0.1",
|
|
69
|
+
"@metamask/transaction-controller": "^62.3.0",
|
|
64
70
|
"@metamask/utils": "^11.8.1",
|
|
65
71
|
"bignumber.js": "^9.1.2",
|
|
66
72
|
"reselect": "^5.1.1",
|
|
67
73
|
"uuid": "^8.3.2"
|
|
68
74
|
},
|
|
69
75
|
"devDependencies": {
|
|
70
|
-
"@metamask/accounts-controller": "^35.0.0",
|
|
71
|
-
"@metamask/assets-controllers": "^90.0.0",
|
|
72
76
|
"@metamask/auto-changelog": "^3.4.4",
|
|
73
77
|
"@metamask/eth-json-rpc-provider": "^6.0.0",
|
|
74
|
-
"@metamask/network-controller": "^26.0.0",
|
|
75
|
-
"@metamask/remote-feature-flag-controller": "^2.0.1",
|
|
76
|
-
"@metamask/snaps-controllers": "^14.0.1",
|
|
77
78
|
"@metamask/superstruct": "^3.1.0",
|
|
78
|
-
"@metamask/transaction-controller": "^62.0.0",
|
|
79
79
|
"@ts-bridge/cli": "^0.6.4",
|
|
80
80
|
"@types/jest": "^27.4.1",
|
|
81
81
|
"deepmerge": "^4.2.2",
|
|
@@ -88,14 +88,6 @@
|
|
|
88
88
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
89
89
|
"typescript": "~5.3.3"
|
|
90
90
|
},
|
|
91
|
-
"peerDependencies": {
|
|
92
|
-
"@metamask/accounts-controller": "^35.0.0",
|
|
93
|
-
"@metamask/assets-controllers": "^90.0.0",
|
|
94
|
-
"@metamask/network-controller": "^26.0.0",
|
|
95
|
-
"@metamask/remote-feature-flag-controller": "^2.0.0",
|
|
96
|
-
"@metamask/snaps-controllers": "^14.0.0",
|
|
97
|
-
"@metamask/transaction-controller": "^62.0.0"
|
|
98
|
-
},
|
|
99
91
|
"engines": {
|
|
100
92
|
"node": "^18.18 || >=20"
|
|
101
93
|
},
|