@metamask/bridge-controller 9.0.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -1
- package/dist/bridge-controller.cjs +96 -25
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts +5 -5
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts +5 -5
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +97 -26
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/constants/bridge.cjs +2 -1
- package/dist/constants/bridge.cjs.map +1 -1
- package/dist/constants/bridge.d.cts +2 -1
- package/dist/constants/bridge.d.cts.map +1 -1
- package/dist/constants/bridge.d.mts +2 -1
- package/dist/constants/bridge.d.mts.map +1 -1
- package/dist/constants/bridge.mjs +2 -1
- package/dist/constants/bridge.mjs.map +1 -1
- package/dist/constants/chains.cjs +1 -12
- package/dist/constants/chains.cjs.map +1 -1
- package/dist/constants/chains.d.cts +0 -2
- package/dist/constants/chains.d.cts.map +1 -1
- package/dist/constants/chains.d.mts +0 -2
- package/dist/constants/chains.d.mts.map +1 -1
- package/dist/constants/chains.mjs +0 -11
- package/dist/constants/chains.mjs.map +1 -1
- package/dist/constants/tokens.cjs +61 -38
- package/dist/constants/tokens.cjs.map +1 -1
- package/dist/constants/tokens.d.cts +100 -48
- package/dist/constants/tokens.d.cts.map +1 -1
- package/dist/constants/tokens.d.mts +100 -48
- package/dist/constants/tokens.d.mts.map +1 -1
- package/dist/constants/tokens.mjs +37 -14
- package/dist/constants/tokens.mjs.map +1 -1
- package/dist/index.cjs +21 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +16 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +11 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +4 -3
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +108 -54
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +108 -54
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +4 -3
- package/dist/types.mjs.map +1 -1
- package/dist/utils/balance.cjs +2 -2
- package/dist/utils/balance.cjs.map +1 -1
- package/dist/utils/balance.d.cts.map +1 -1
- package/dist/utils/balance.d.mts.map +1 -1
- package/dist/utils/balance.mjs +2 -2
- package/dist/utils/balance.mjs.map +1 -1
- package/dist/utils/bridge.cjs +65 -5
- package/dist/utils/bridge.cjs.map +1 -1
- package/dist/utils/bridge.d.cts +27 -4
- package/dist/utils/bridge.d.cts.map +1 -1
- package/dist/utils/bridge.d.mts +27 -4
- package/dist/utils/bridge.d.mts.map +1 -1
- package/dist/utils/bridge.mjs +62 -5
- package/dist/utils/bridge.mjs.map +1 -1
- package/dist/utils/caip-formatters.cjs +102 -0
- package/dist/utils/caip-formatters.cjs.map +1 -0
- package/dist/utils/caip-formatters.d.cts +31 -0
- package/dist/utils/caip-formatters.d.cts.map +1 -0
- package/dist/utils/caip-formatters.d.mts +31 -0
- package/dist/utils/caip-formatters.d.mts.map +1 -0
- package/dist/utils/caip-formatters.mjs +95 -0
- package/dist/utils/caip-formatters.mjs.map +1 -0
- package/dist/utils/fetch.cjs +34 -26
- package/dist/utils/fetch.cjs.map +1 -1
- package/dist/utils/fetch.d.cts +6 -5
- package/dist/utils/fetch.d.cts.map +1 -1
- package/dist/utils/fetch.d.mts +6 -5
- package/dist/utils/fetch.d.mts.map +1 -1
- package/dist/utils/fetch.mjs +32 -24
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/quote.cjs +12 -2
- package/dist/utils/quote.cjs.map +1 -1
- package/dist/utils/quote.d.cts +2 -2
- package/dist/utils/quote.d.cts.map +1 -1
- package/dist/utils/quote.d.mts +2 -2
- package/dist/utils/quote.d.mts.map +1 -1
- package/dist/utils/quote.mjs +12 -2
- package/dist/utils/quote.mjs.map +1 -1
- package/dist/utils/validators.cjs +15 -16
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +2 -3
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +2 -3
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +16 -17
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +9 -4
package/dist/types.d.cts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountsControllerGetSelectedMultichainAccountAction } from "@metamask/accounts-controller";
|
|
2
2
|
import type { ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
|
|
3
3
|
import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetStateAction, NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller";
|
|
4
|
-
import type {
|
|
4
|
+
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
|
|
5
|
+
import type { CaipAccountId, CaipAssetId, CaipChainId, Hex } from "@metamask/utils";
|
|
5
6
|
import type { BigNumber } from "bignumber.js";
|
|
6
7
|
import type { BridgeController } from "./bridge-controller.cjs";
|
|
7
8
|
import type { BRIDGE_CONTROLLER_NAME } from "./constants/bridge.cjs";
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Additional options accepted by the extension's fetchWithCache function
|
|
11
|
+
*/
|
|
12
|
+
type FetchWithCacheOptions = {
|
|
13
|
+
cacheOptions?: {
|
|
14
|
+
cacheRefreshTime: number;
|
|
15
|
+
};
|
|
16
|
+
functionName?: string;
|
|
17
|
+
};
|
|
18
|
+
export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit & FetchWithCacheOptions) => Promise<any>;
|
|
9
19
|
/**
|
|
10
20
|
* The types of assets that a user can send
|
|
11
|
-
*
|
|
12
21
|
*/
|
|
13
22
|
export declare enum AssetType {
|
|
14
23
|
/** The native asset for the current network, such as ETH */
|
|
@@ -26,54 +35,92 @@ export declare enum AssetType {
|
|
|
26
35
|
export type ChainConfiguration = {
|
|
27
36
|
isActiveSrc: boolean;
|
|
28
37
|
isActiveDest: boolean;
|
|
38
|
+
refreshRate?: number;
|
|
39
|
+
topAssets?: string[];
|
|
29
40
|
};
|
|
30
41
|
export type L1GasFees = {
|
|
31
42
|
l1GasFeesInHexWei?: string;
|
|
32
43
|
};
|
|
44
|
+
export type SolanaFees = {
|
|
45
|
+
solanaFeesInLamports?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* valueInCurrency values are calculated based on the user's selected currency
|
|
49
|
+
*/
|
|
50
|
+
export type TokenAmountValues = {
|
|
51
|
+
amount: BigNumber;
|
|
52
|
+
valueInCurrency: BigNumber | null;
|
|
53
|
+
usd: BigNumber | null;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Values derived from the quote response
|
|
57
|
+
*/
|
|
33
58
|
export type QuoteMetadata = {
|
|
34
|
-
gasFee:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
valueInCurrency: BigNumber | null;
|
|
41
|
-
};
|
|
42
|
-
totalMaxNetworkFee: {
|
|
43
|
-
amount: BigNumber;
|
|
44
|
-
valueInCurrency: BigNumber | null;
|
|
45
|
-
};
|
|
46
|
-
toTokenAmount: {
|
|
47
|
-
amount: BigNumber;
|
|
48
|
-
valueInCurrency: BigNumber | null;
|
|
49
|
-
};
|
|
50
|
-
adjustedReturn: {
|
|
51
|
-
valueInCurrency: BigNumber | null;
|
|
52
|
-
};
|
|
53
|
-
sentAmount: {
|
|
54
|
-
amount: BigNumber;
|
|
55
|
-
valueInCurrency: BigNumber | null;
|
|
56
|
-
};
|
|
59
|
+
gasFee: TokenAmountValues;
|
|
60
|
+
totalNetworkFee: TokenAmountValues;
|
|
61
|
+
totalMaxNetworkFee: TokenAmountValues;
|
|
62
|
+
toTokenAmount: TokenAmountValues;
|
|
63
|
+
adjustedReturn: Omit<TokenAmountValues, 'amount'>;
|
|
64
|
+
sentAmount: TokenAmountValues;
|
|
57
65
|
swapRate: BigNumber;
|
|
58
|
-
cost:
|
|
59
|
-
valueInCurrency: BigNumber | null;
|
|
60
|
-
};
|
|
66
|
+
cost: Omit<TokenAmountValues, 'amount'>;
|
|
61
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Sort order set by the user
|
|
70
|
+
*/
|
|
62
71
|
export declare enum SortOrder {
|
|
63
72
|
COST_ASC = "cost_ascending",
|
|
64
73
|
ETA_ASC = "time_descending"
|
|
65
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* This is the interface for the asset object returned by the bridge-api
|
|
77
|
+
* This type is used in the QuoteResponse and in the fetchBridgeTokens response
|
|
78
|
+
*/
|
|
79
|
+
export type BridgeAsset = {
|
|
80
|
+
/**
|
|
81
|
+
* The chainId of the token
|
|
82
|
+
*/
|
|
83
|
+
chainId: ChainId;
|
|
84
|
+
/**
|
|
85
|
+
* An address that the metaswap-api recognizes as the default token
|
|
86
|
+
*/
|
|
87
|
+
address: string;
|
|
88
|
+
/**
|
|
89
|
+
* The symbol of token object
|
|
90
|
+
*/
|
|
91
|
+
symbol: string;
|
|
92
|
+
/**
|
|
93
|
+
* The name for the network
|
|
94
|
+
*/
|
|
95
|
+
name: string;
|
|
96
|
+
/**
|
|
97
|
+
* Number of digits after decimal point
|
|
98
|
+
*/
|
|
99
|
+
decimals: number;
|
|
100
|
+
icon?: string;
|
|
101
|
+
/**
|
|
102
|
+
* URL for token icon
|
|
103
|
+
*/
|
|
104
|
+
iconUrl?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The assetId of the token
|
|
107
|
+
*/
|
|
108
|
+
assetId: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* This is the interface for the token object used in the extension client
|
|
112
|
+
* In addition to the {@link BridgeAsset} fields, it includes balance information
|
|
113
|
+
*/
|
|
66
114
|
export type BridgeToken = {
|
|
67
|
-
type: AssetType.native | AssetType.token;
|
|
68
115
|
address: string;
|
|
69
116
|
symbol: string;
|
|
70
117
|
image: string;
|
|
71
118
|
decimals: number;
|
|
72
|
-
chainId: Hex;
|
|
119
|
+
chainId: number | Hex | ChainId | CaipChainId;
|
|
73
120
|
balance: string;
|
|
74
121
|
string: string | undefined;
|
|
75
122
|
tokenFiatAmount?: number | null;
|
|
76
|
-
}
|
|
123
|
+
};
|
|
77
124
|
export declare enum BridgeFlag {
|
|
78
125
|
EXTENSION_CONFIG = "extension-config",
|
|
79
126
|
MOBILE_CONFIG = "mobile-config"
|
|
@@ -90,32 +137,38 @@ export type FeatureFlagResponse = {
|
|
|
90
137
|
[BridgeFlag.EXTENSION_CONFIG]: FeatureFlagResponsePlatformConfig;
|
|
91
138
|
[BridgeFlag.MOBILE_CONFIG]: FeatureFlagResponsePlatformConfig;
|
|
92
139
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
destChainId: ChainId;
|
|
106
|
-
srcTokenAddress: string;
|
|
107
|
-
destTokenAddress: string;
|
|
140
|
+
/**
|
|
141
|
+
* This is the interface for the quote request sent to the bridge-api
|
|
142
|
+
* and should only be used by the fetchBridgeQuotes utility function
|
|
143
|
+
* Components and redux stores should use the {@link GenericQuoteRequest} type
|
|
144
|
+
*/
|
|
145
|
+
export type QuoteRequest<ChainIdType = ChainId | number, TokenAddressType = string, WalletAddressType = string> = {
|
|
146
|
+
walletAddress: WalletAddressType;
|
|
147
|
+
destWalletAddress?: WalletAddressType;
|
|
148
|
+
srcChainId: ChainIdType;
|
|
149
|
+
destChainId: ChainIdType;
|
|
150
|
+
srcTokenAddress: TokenAddressType;
|
|
151
|
+
destTokenAddress: TokenAddressType;
|
|
108
152
|
/**
|
|
109
153
|
* This is the amount sent, in atomic amount
|
|
110
154
|
*/
|
|
111
155
|
srcTokenAmount: string;
|
|
112
|
-
slippage
|
|
156
|
+
slippage?: number;
|
|
113
157
|
aggIds?: string[];
|
|
114
158
|
bridgeIds?: string[];
|
|
115
159
|
insufficientBal?: boolean;
|
|
116
160
|
resetApproval?: boolean;
|
|
117
161
|
refuel?: boolean;
|
|
118
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* These are types that components pass in. Since data is a mix of types when coming from the redux store, we need to use a generic type that can cover all the types.
|
|
165
|
+
* Payloads with this type are transformed into QuoteRequest by fetchBridgeQuotes right before fetching quotes
|
|
166
|
+
*/
|
|
167
|
+
export type GenericQuoteRequest = QuoteRequest<Hex | CaipChainId | string | number, // chainIds
|
|
168
|
+
// chainIds
|
|
169
|
+
Hex | CaipAssetId | string, // assetIds/addresses
|
|
170
|
+
// assetIds/addresses
|
|
171
|
+
Hex | CaipAccountId | string>;
|
|
119
172
|
export type Protocol = {
|
|
120
173
|
name: string;
|
|
121
174
|
displayName?: string;
|
|
@@ -166,7 +219,8 @@ export declare enum ChainId {
|
|
|
166
219
|
BASE = 8453,
|
|
167
220
|
ARBITRUM = 42161,
|
|
168
221
|
AVALANCHE = 43114,
|
|
169
|
-
LINEA = 59144
|
|
222
|
+
LINEA = 59144,
|
|
223
|
+
SOLANA = 1151111081099710
|
|
170
224
|
}
|
|
171
225
|
export declare enum FeeType {
|
|
172
226
|
METABRIDGE = "metabridge",
|
|
@@ -192,7 +246,7 @@ type FeatureFlagsPlatformConfig = {
|
|
|
192
246
|
refreshRate: number;
|
|
193
247
|
maxRefreshCount: number;
|
|
194
248
|
support: boolean;
|
|
195
|
-
chains: Record<
|
|
249
|
+
chains: Record<CaipChainId, ChainConfiguration>;
|
|
196
250
|
};
|
|
197
251
|
export type BridgeFeatureFlags = {
|
|
198
252
|
[BridgeFeatureFlagsKey.EXTENSION_CONFIG]: FeatureFlagsPlatformConfig;
|
|
@@ -214,8 +268,8 @@ export declare enum BridgeBackgroundAction {
|
|
|
214
268
|
}
|
|
215
269
|
export type BridgeControllerState = {
|
|
216
270
|
bridgeFeatureFlags: BridgeFeatureFlags;
|
|
217
|
-
quoteRequest: Partial<
|
|
218
|
-
quotes: (QuoteResponse & L1GasFees)[];
|
|
271
|
+
quoteRequest: Partial<GenericQuoteRequest>;
|
|
272
|
+
quotes: (QuoteResponse & L1GasFees & SolanaFees)[];
|
|
219
273
|
quotesInitialLoadTime: number | null;
|
|
220
274
|
quotesLastFetched: number | null;
|
|
221
275
|
quotesLoadingStatus: RequestStatus | null;
|
|
@@ -228,7 +282,7 @@ export type BridgeControllerAction<FunctionName extends keyof BridgeController>
|
|
|
228
282
|
};
|
|
229
283
|
export type BridgeControllerActions = BridgeControllerAction<BridgeBackgroundAction.SET_FEATURE_FLAGS> | BridgeControllerAction<BridgeBackgroundAction.RESET_STATE> | BridgeControllerAction<BridgeBackgroundAction.GET_BRIDGE_ERC20_ALLOWANCE> | BridgeControllerAction<BridgeUserAction.UPDATE_QUOTE_PARAMS>;
|
|
230
284
|
export type BridgeControllerEvents = ControllerStateChangeEvent<typeof BRIDGE_CONTROLLER_NAME, BridgeControllerState>;
|
|
231
|
-
export type AllowedActions =
|
|
285
|
+
export type AllowedActions = AccountsControllerGetSelectedMultichainAccountAction | HandleSnapRequest | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction;
|
|
232
286
|
export type AllowedEvents = never;
|
|
233
287
|
/**
|
|
234
288
|
* The messenger for the BridgeController.
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oDAAoD,EAAE,sCAAsC;AAC1G,OAAO,KAAK,EACV,0BAA0B,EAC1B,mBAAmB,EACpB,kCAAk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7B,qBAAqB,CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB,oDAAoD,GACpD,iBAAiB,GACjB,mDAAmD,GACnD,+BAA+B,GAC/B,2CAA2C,CAAC;AAChD,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,CACzD,OAAO,sBAAsB,EAC7B,uBAAuB,GAAG,cAAc,EACxC,sBAAsB,GAAG,aAAa,EACtC,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountsControllerGetSelectedMultichainAccountAction } from "@metamask/accounts-controller";
|
|
2
2
|
import type { ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
|
|
3
3
|
import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetStateAction, NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller";
|
|
4
|
-
import type {
|
|
4
|
+
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
|
|
5
|
+
import type { CaipAccountId, CaipAssetId, CaipChainId, Hex } from "@metamask/utils";
|
|
5
6
|
import type { BigNumber } from "bignumber.js";
|
|
6
7
|
import type { BridgeController } from "./bridge-controller.mjs";
|
|
7
8
|
import type { BRIDGE_CONTROLLER_NAME } from "./constants/bridge.mjs";
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Additional options accepted by the extension's fetchWithCache function
|
|
11
|
+
*/
|
|
12
|
+
type FetchWithCacheOptions = {
|
|
13
|
+
cacheOptions?: {
|
|
14
|
+
cacheRefreshTime: number;
|
|
15
|
+
};
|
|
16
|
+
functionName?: string;
|
|
17
|
+
};
|
|
18
|
+
export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit & FetchWithCacheOptions) => Promise<any>;
|
|
9
19
|
/**
|
|
10
20
|
* The types of assets that a user can send
|
|
11
|
-
*
|
|
12
21
|
*/
|
|
13
22
|
export declare enum AssetType {
|
|
14
23
|
/** The native asset for the current network, such as ETH */
|
|
@@ -26,54 +35,92 @@ export declare enum AssetType {
|
|
|
26
35
|
export type ChainConfiguration = {
|
|
27
36
|
isActiveSrc: boolean;
|
|
28
37
|
isActiveDest: boolean;
|
|
38
|
+
refreshRate?: number;
|
|
39
|
+
topAssets?: string[];
|
|
29
40
|
};
|
|
30
41
|
export type L1GasFees = {
|
|
31
42
|
l1GasFeesInHexWei?: string;
|
|
32
43
|
};
|
|
44
|
+
export type SolanaFees = {
|
|
45
|
+
solanaFeesInLamports?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* valueInCurrency values are calculated based on the user's selected currency
|
|
49
|
+
*/
|
|
50
|
+
export type TokenAmountValues = {
|
|
51
|
+
amount: BigNumber;
|
|
52
|
+
valueInCurrency: BigNumber | null;
|
|
53
|
+
usd: BigNumber | null;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Values derived from the quote response
|
|
57
|
+
*/
|
|
33
58
|
export type QuoteMetadata = {
|
|
34
|
-
gasFee:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
valueInCurrency: BigNumber | null;
|
|
41
|
-
};
|
|
42
|
-
totalMaxNetworkFee: {
|
|
43
|
-
amount: BigNumber;
|
|
44
|
-
valueInCurrency: BigNumber | null;
|
|
45
|
-
};
|
|
46
|
-
toTokenAmount: {
|
|
47
|
-
amount: BigNumber;
|
|
48
|
-
valueInCurrency: BigNumber | null;
|
|
49
|
-
};
|
|
50
|
-
adjustedReturn: {
|
|
51
|
-
valueInCurrency: BigNumber | null;
|
|
52
|
-
};
|
|
53
|
-
sentAmount: {
|
|
54
|
-
amount: BigNumber;
|
|
55
|
-
valueInCurrency: BigNumber | null;
|
|
56
|
-
};
|
|
59
|
+
gasFee: TokenAmountValues;
|
|
60
|
+
totalNetworkFee: TokenAmountValues;
|
|
61
|
+
totalMaxNetworkFee: TokenAmountValues;
|
|
62
|
+
toTokenAmount: TokenAmountValues;
|
|
63
|
+
adjustedReturn: Omit<TokenAmountValues, 'amount'>;
|
|
64
|
+
sentAmount: TokenAmountValues;
|
|
57
65
|
swapRate: BigNumber;
|
|
58
|
-
cost:
|
|
59
|
-
valueInCurrency: BigNumber | null;
|
|
60
|
-
};
|
|
66
|
+
cost: Omit<TokenAmountValues, 'amount'>;
|
|
61
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Sort order set by the user
|
|
70
|
+
*/
|
|
62
71
|
export declare enum SortOrder {
|
|
63
72
|
COST_ASC = "cost_ascending",
|
|
64
73
|
ETA_ASC = "time_descending"
|
|
65
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* This is the interface for the asset object returned by the bridge-api
|
|
77
|
+
* This type is used in the QuoteResponse and in the fetchBridgeTokens response
|
|
78
|
+
*/
|
|
79
|
+
export type BridgeAsset = {
|
|
80
|
+
/**
|
|
81
|
+
* The chainId of the token
|
|
82
|
+
*/
|
|
83
|
+
chainId: ChainId;
|
|
84
|
+
/**
|
|
85
|
+
* An address that the metaswap-api recognizes as the default token
|
|
86
|
+
*/
|
|
87
|
+
address: string;
|
|
88
|
+
/**
|
|
89
|
+
* The symbol of token object
|
|
90
|
+
*/
|
|
91
|
+
symbol: string;
|
|
92
|
+
/**
|
|
93
|
+
* The name for the network
|
|
94
|
+
*/
|
|
95
|
+
name: string;
|
|
96
|
+
/**
|
|
97
|
+
* Number of digits after decimal point
|
|
98
|
+
*/
|
|
99
|
+
decimals: number;
|
|
100
|
+
icon?: string;
|
|
101
|
+
/**
|
|
102
|
+
* URL for token icon
|
|
103
|
+
*/
|
|
104
|
+
iconUrl?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The assetId of the token
|
|
107
|
+
*/
|
|
108
|
+
assetId: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* This is the interface for the token object used in the extension client
|
|
112
|
+
* In addition to the {@link BridgeAsset} fields, it includes balance information
|
|
113
|
+
*/
|
|
66
114
|
export type BridgeToken = {
|
|
67
|
-
type: AssetType.native | AssetType.token;
|
|
68
115
|
address: string;
|
|
69
116
|
symbol: string;
|
|
70
117
|
image: string;
|
|
71
118
|
decimals: number;
|
|
72
|
-
chainId: Hex;
|
|
119
|
+
chainId: number | Hex | ChainId | CaipChainId;
|
|
73
120
|
balance: string;
|
|
74
121
|
string: string | undefined;
|
|
75
122
|
tokenFiatAmount?: number | null;
|
|
76
|
-
}
|
|
123
|
+
};
|
|
77
124
|
export declare enum BridgeFlag {
|
|
78
125
|
EXTENSION_CONFIG = "extension-config",
|
|
79
126
|
MOBILE_CONFIG = "mobile-config"
|
|
@@ -90,32 +137,38 @@ export type FeatureFlagResponse = {
|
|
|
90
137
|
[BridgeFlag.EXTENSION_CONFIG]: FeatureFlagResponsePlatformConfig;
|
|
91
138
|
[BridgeFlag.MOBILE_CONFIG]: FeatureFlagResponsePlatformConfig;
|
|
92
139
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
destChainId: ChainId;
|
|
106
|
-
srcTokenAddress: string;
|
|
107
|
-
destTokenAddress: string;
|
|
140
|
+
/**
|
|
141
|
+
* This is the interface for the quote request sent to the bridge-api
|
|
142
|
+
* and should only be used by the fetchBridgeQuotes utility function
|
|
143
|
+
* Components and redux stores should use the {@link GenericQuoteRequest} type
|
|
144
|
+
*/
|
|
145
|
+
export type QuoteRequest<ChainIdType = ChainId | number, TokenAddressType = string, WalletAddressType = string> = {
|
|
146
|
+
walletAddress: WalletAddressType;
|
|
147
|
+
destWalletAddress?: WalletAddressType;
|
|
148
|
+
srcChainId: ChainIdType;
|
|
149
|
+
destChainId: ChainIdType;
|
|
150
|
+
srcTokenAddress: TokenAddressType;
|
|
151
|
+
destTokenAddress: TokenAddressType;
|
|
108
152
|
/**
|
|
109
153
|
* This is the amount sent, in atomic amount
|
|
110
154
|
*/
|
|
111
155
|
srcTokenAmount: string;
|
|
112
|
-
slippage
|
|
156
|
+
slippage?: number;
|
|
113
157
|
aggIds?: string[];
|
|
114
158
|
bridgeIds?: string[];
|
|
115
159
|
insufficientBal?: boolean;
|
|
116
160
|
resetApproval?: boolean;
|
|
117
161
|
refuel?: boolean;
|
|
118
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* These are types that components pass in. Since data is a mix of types when coming from the redux store, we need to use a generic type that can cover all the types.
|
|
165
|
+
* Payloads with this type are transformed into QuoteRequest by fetchBridgeQuotes right before fetching quotes
|
|
166
|
+
*/
|
|
167
|
+
export type GenericQuoteRequest = QuoteRequest<Hex | CaipChainId | string | number, // chainIds
|
|
168
|
+
// chainIds
|
|
169
|
+
Hex | CaipAssetId | string, // assetIds/addresses
|
|
170
|
+
// assetIds/addresses
|
|
171
|
+
Hex | CaipAccountId | string>;
|
|
119
172
|
export type Protocol = {
|
|
120
173
|
name: string;
|
|
121
174
|
displayName?: string;
|
|
@@ -166,7 +219,8 @@ export declare enum ChainId {
|
|
|
166
219
|
BASE = 8453,
|
|
167
220
|
ARBITRUM = 42161,
|
|
168
221
|
AVALANCHE = 43114,
|
|
169
|
-
LINEA = 59144
|
|
222
|
+
LINEA = 59144,
|
|
223
|
+
SOLANA = 1151111081099710
|
|
170
224
|
}
|
|
171
225
|
export declare enum FeeType {
|
|
172
226
|
METABRIDGE = "metabridge",
|
|
@@ -192,7 +246,7 @@ type FeatureFlagsPlatformConfig = {
|
|
|
192
246
|
refreshRate: number;
|
|
193
247
|
maxRefreshCount: number;
|
|
194
248
|
support: boolean;
|
|
195
|
-
chains: Record<
|
|
249
|
+
chains: Record<CaipChainId, ChainConfiguration>;
|
|
196
250
|
};
|
|
197
251
|
export type BridgeFeatureFlags = {
|
|
198
252
|
[BridgeFeatureFlagsKey.EXTENSION_CONFIG]: FeatureFlagsPlatformConfig;
|
|
@@ -214,8 +268,8 @@ export declare enum BridgeBackgroundAction {
|
|
|
214
268
|
}
|
|
215
269
|
export type BridgeControllerState = {
|
|
216
270
|
bridgeFeatureFlags: BridgeFeatureFlags;
|
|
217
|
-
quoteRequest: Partial<
|
|
218
|
-
quotes: (QuoteResponse & L1GasFees)[];
|
|
271
|
+
quoteRequest: Partial<GenericQuoteRequest>;
|
|
272
|
+
quotes: (QuoteResponse & L1GasFees & SolanaFees)[];
|
|
219
273
|
quotesInitialLoadTime: number | null;
|
|
220
274
|
quotesLastFetched: number | null;
|
|
221
275
|
quotesLoadingStatus: RequestStatus | null;
|
|
@@ -228,7 +282,7 @@ export type BridgeControllerAction<FunctionName extends keyof BridgeController>
|
|
|
228
282
|
};
|
|
229
283
|
export type BridgeControllerActions = BridgeControllerAction<BridgeBackgroundAction.SET_FEATURE_FLAGS> | BridgeControllerAction<BridgeBackgroundAction.RESET_STATE> | BridgeControllerAction<BridgeBackgroundAction.GET_BRIDGE_ERC20_ALLOWANCE> | BridgeControllerAction<BridgeUserAction.UPDATE_QUOTE_PARAMS>;
|
|
230
284
|
export type BridgeControllerEvents = ControllerStateChangeEvent<typeof BRIDGE_CONTROLLER_NAME, BridgeControllerState>;
|
|
231
|
-
export type AllowedActions =
|
|
285
|
+
export type AllowedActions = AccountsControllerGetSelectedMultichainAccountAction | HandleSnapRequest | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction;
|
|
232
286
|
export type AllowedEvents = never;
|
|
233
287
|
/**
|
|
234
288
|
* The messenger for the BridgeController.
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":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0B,CAAC,GACzE,sBAAsB,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,CAC7D,OAAO,sBAAsB,EAC7B,qBAAqB,CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB,oDAAoD,GACpD,iBAAiB,GACjB,mDAAmD,GACnD,+BAA+B,GAC/B,2CAA2C,CAAC;AAChD,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,CACzD,OAAO,sBAAsB,EAC7B,uBAAuB,GAAG,cAAc,EACxC,sBAAsB,GAAG,aAAa,EACtC,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
|
package/dist/types.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The types of assets that a user can send
|
|
3
|
-
*
|
|
4
3
|
*/
|
|
5
4
|
export var AssetType;
|
|
6
5
|
(function (AssetType) {
|
|
@@ -16,13 +15,14 @@ export var AssetType;
|
|
|
16
15
|
*/
|
|
17
16
|
AssetType["unknown"] = "UNKNOWN";
|
|
18
17
|
})(AssetType || (AssetType = {}));
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Sort order set by the user
|
|
20
|
+
*/
|
|
20
21
|
export var SortOrder;
|
|
21
22
|
(function (SortOrder) {
|
|
22
23
|
SortOrder["COST_ASC"] = "cost_ascending";
|
|
23
24
|
SortOrder["ETA_ASC"] = "time_descending";
|
|
24
25
|
})(SortOrder || (SortOrder = {}));
|
|
25
|
-
// Types copied from Metabridge API
|
|
26
26
|
export var BridgeFlag;
|
|
27
27
|
(function (BridgeFlag) {
|
|
28
28
|
BridgeFlag["EXTENSION_CONFIG"] = "extension-config";
|
|
@@ -45,6 +45,7 @@ export var ChainId;
|
|
|
45
45
|
ChainId[ChainId["ARBITRUM"] = 42161] = "ARBITRUM";
|
|
46
46
|
ChainId[ChainId["AVALANCHE"] = 43114] = "AVALANCHE";
|
|
47
47
|
ChainId[ChainId["LINEA"] = 59144] = "LINEA";
|
|
48
|
+
ChainId[ChainId["SOLANA"] = 1151111081099710] = "SOLANA";
|
|
48
49
|
})(ChainId || (ChainId = {}));
|
|
49
50
|
export var FeeType;
|
|
50
51
|
(function (FeeType) {
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,MAAM,CAAN,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,4DAA4D;IAC5D,8BAAiB,CAAA;IACjB,qBAAqB;IACrB,4BAAe,CAAA;IACf,kCAAkC;IAClC,wBAAW,CAAA;IACX;;;OAGG;IACH,gCAAmB,CAAA;AACrB,CAAC,EAZW,SAAS,KAAT,SAAS,QAYpB;AAuBD,6BAA6B;AAE7B,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,wCAA2B,CAAA;AAC7B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAaD,mCAAmC;AAEnC,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,mDAAqC,CAAA;IACrC,6CAA+B,CAAA;AACjC,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAkDD,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAuCD,MAAM,CAAN,IAAY,OAUX;AAVD,WAAY,OAAO;IACjB,mCAAO,CAAA;IACP,8CAAa,CAAA;IACb,oCAAQ,CAAA;IACR,6CAAa,CAAA;IACb,2CAAY,CAAA;IACZ,wCAAW,CAAA;IACX,iDAAgB,CAAA;IAChB,mDAAiB,CAAA;IACjB,2CAAa,CAAA;AACf,CAAC,EAVW,OAAO,KAAP,OAAO,QAUlB;AAED,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,4BAAiB,CAAA;AACnB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAaD,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,6DAAoC,CAAA;IACpC,uDAA8B,CAAA;AAChC,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC;AAaD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,mDAAK,CAAA;AACP,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AACD,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,6DAAyC,CAAA;IACzC,0EAAsD,CAAA;AACxD,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AACD,MAAM,CAAN,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,qEAA2C,CAAA;IAC3C,oDAA0B,CAAA;IAC1B,gFAAsD,CAAA;AACxD,CAAC,EAJW,sBAAsB,KAAtB,sBAAsB,QAIjC","sourcesContent":["import type { AccountsControllerGetSelectedAccountAction } from '@metamask/accounts-controller';\nimport type {\n ControllerStateChangeEvent,\n RestrictedMessenger,\n} from '@metamask/base-controller';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetStateAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\nimport type { BigNumber } from 'bignumber.js';\n\nimport type { BridgeController } from './bridge-controller';\nimport type { BRIDGE_CONTROLLER_NAME } from './constants/bridge';\n\nexport type FetchFunction = (\n input: RequestInfo | URL,\n init?: RequestInit,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => Promise<any>;\n\n/**\n * The types of assets that a user can send\n *\n */\nexport enum AssetType {\n /** The native asset for the current network, such as ETH */\n native = 'NATIVE',\n /** An ERC20 token */\n token = 'TOKEN',\n /** An ERC721 or ERC1155 token. */\n NFT = 'NFT',\n /**\n * A transaction interacting with a contract that isn't a token method\n * interaction will be marked as dealing with an unknown asset type.\n */\n unknown = 'UNKNOWN',\n}\n\nexport type ChainConfiguration = {\n isActiveSrc: boolean;\n isActiveDest: boolean;\n};\n\nexport type L1GasFees = {\n l1GasFeesInHexWei?: string; // l1 fees for approval and trade in hex wei, appended by controller\n};\n// Values derived from the quote response\n// valueInCurrency values are calculated based on the user's selected currency\n\nexport type QuoteMetadata = {\n gasFee: { amount: BigNumber; valueInCurrency: BigNumber | null };\n totalNetworkFee: { amount: BigNumber; valueInCurrency: BigNumber | null }; // estimatedGasFees + relayerFees\n totalMaxNetworkFee: { amount: BigNumber; valueInCurrency: BigNumber | null }; // maxGasFees + relayerFees\n toTokenAmount: { amount: BigNumber; valueInCurrency: BigNumber | null };\n adjustedReturn: { valueInCurrency: BigNumber | null }; // destTokenAmount - totalNetworkFee\n sentAmount: { amount: BigNumber; valueInCurrency: BigNumber | null }; // srcTokenAmount + metabridgeFee\n swapRate: BigNumber; // destTokenAmount / sentAmount\n cost: { valueInCurrency: BigNumber | null }; // sentAmount - adjustedReturn\n};\n// Sort order set by the user\n\nexport enum SortOrder {\n COST_ASC = 'cost_ascending',\n ETA_ASC = 'time_descending',\n}\n\nexport type BridgeToken = {\n type: AssetType.native | AssetType.token;\n address: string;\n symbol: string;\n image: string;\n decimals: number;\n chainId: Hex;\n balance: string; // raw balance\n string: string | undefined; // normalized balance as a stringified number\n tokenFiatAmount?: number | null;\n} | null;\n// Types copied from Metabridge API\n\nexport enum BridgeFlag {\n EXTENSION_CONFIG = 'extension-config',\n MOBILE_CONFIG = 'mobile-config',\n}\ntype DecimalChainId = string;\nexport type GasMultiplierByChainId = Record<DecimalChainId, number>;\n\ntype FeatureFlagResponsePlatformConfig = {\n refreshRate: number;\n maxRefreshCount: number;\n support: boolean;\n chains: Record<string, ChainConfiguration>;\n};\n\nexport type FeatureFlagResponse = {\n [BridgeFlag.EXTENSION_CONFIG]: FeatureFlagResponsePlatformConfig;\n [BridgeFlag.MOBILE_CONFIG]: FeatureFlagResponsePlatformConfig;\n};\n\nexport type BridgeAsset = {\n chainId: ChainId;\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n icon?: string;\n};\n\nexport type QuoteRequest = {\n walletAddress: string;\n destWalletAddress?: string;\n srcChainId: ChainId;\n destChainId: ChainId;\n srcTokenAddress: string;\n destTokenAddress: string;\n /**\n * This is the amount sent, in atomic amount\n */\n srcTokenAmount: string;\n slippage: number;\n aggIds?: string[];\n bridgeIds?: string[];\n insufficientBal?: boolean;\n resetApproval?: boolean;\n refuel?: boolean;\n};\n\nexport type Protocol = {\n name: string;\n displayName?: string;\n icon?: string;\n};\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nexport type Step = {\n action: ActionTypes;\n srcChainId: ChainId;\n destChainId?: ChainId;\n srcAsset: BridgeAsset;\n destAsset: BridgeAsset;\n srcAmount: string;\n destAmount: string;\n protocol: Protocol;\n};\n\nexport type RefuelData = Step;\n\nexport type Quote = {\n requestId: string;\n srcChainId: ChainId;\n srcAsset: BridgeAsset;\n // Some tokens have a fee of 0, so sometimes it's equal to amount sent\n srcTokenAmount: string; // Atomic amount, the amount sent - fees\n destChainId: ChainId;\n destAsset: BridgeAsset;\n destTokenAmount: string; // Atomic amount, the amount received\n feeData: Record<FeeType.METABRIDGE, FeeData> &\n Partial<Record<FeeType, FeeData>>;\n bridgeId: string;\n bridges: string[];\n steps: Step[];\n refuel?: RefuelData;\n};\n\nexport type QuoteResponse = {\n quote: Quote;\n approval?: TxData | null;\n trade: TxData;\n estimatedProcessingTimeInSeconds: number;\n};\n\nexport enum ChainId {\n ETH = 1,\n OPTIMISM = 10,\n BSC = 56,\n POLYGON = 137,\n ZKSYNC = 324,\n BASE = 8453,\n ARBITRUM = 42161,\n AVALANCHE = 43114,\n LINEA = 59144,\n}\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n}\nexport type FeeData = {\n amount: string;\n asset: BridgeAsset;\n};\nexport type TxData = {\n chainId: ChainId;\n to: string;\n from: string;\n value: string;\n data: string;\n gasLimit: number | null;\n};\nexport enum BridgeFeatureFlagsKey {\n EXTENSION_CONFIG = 'extensionConfig',\n MOBILE_CONFIG = 'mobileConfig',\n}\n\ntype FeatureFlagsPlatformConfig = {\n refreshRate: number;\n maxRefreshCount: number;\n support: boolean;\n chains: Record<Hex, ChainConfiguration>;\n};\n\nexport type BridgeFeatureFlags = {\n [BridgeFeatureFlagsKey.EXTENSION_CONFIG]: FeatureFlagsPlatformConfig;\n [BridgeFeatureFlagsKey.MOBILE_CONFIG]: FeatureFlagsPlatformConfig;\n};\nexport enum RequestStatus {\n LOADING,\n FETCHED,\n ERROR,\n}\nexport enum BridgeUserAction {\n SELECT_DEST_NETWORK = 'selectDestNetwork',\n UPDATE_QUOTE_PARAMS = 'updateBridgeQuoteRequestParams',\n}\nexport enum BridgeBackgroundAction {\n SET_FEATURE_FLAGS = 'setBridgeFeatureFlags',\n RESET_STATE = 'resetState',\n GET_BRIDGE_ERC20_ALLOWANCE = 'getBridgeERC20Allowance',\n}\nexport type BridgeControllerState = {\n bridgeFeatureFlags: BridgeFeatureFlags;\n quoteRequest: Partial<QuoteRequest>;\n quotes: (QuoteResponse & L1GasFees)[];\n quotesInitialLoadTime: number | null;\n quotesLastFetched: number | null;\n quotesLoadingStatus: RequestStatus | null;\n quoteFetchError: string | null;\n quotesRefreshCount: number;\n};\n\nexport type BridgeControllerAction<\n FunctionName extends keyof BridgeController,\n> = {\n type: `${typeof BRIDGE_CONTROLLER_NAME}:${FunctionName}`;\n handler: BridgeController[FunctionName];\n};\n\n// Maps to BridgeController function names\nexport type BridgeControllerActions =\n | BridgeControllerAction<BridgeBackgroundAction.SET_FEATURE_FLAGS>\n | BridgeControllerAction<BridgeBackgroundAction.RESET_STATE>\n | BridgeControllerAction<BridgeBackgroundAction.GET_BRIDGE_ERC20_ALLOWANCE>\n | BridgeControllerAction<BridgeUserAction.UPDATE_QUOTE_PARAMS>;\n\nexport type BridgeControllerEvents = ControllerStateChangeEvent<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState\n>;\n\nexport type AllowedActions =\n | AccountsControllerGetSelectedAccountAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction;\nexport type AllowedEvents = never;\n\n/**\n * The messenger for the BridgeController.\n */\nexport type BridgeControllerMessenger = RestrictedMessenger<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerActions | AllowedActions,\n BridgeControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAsCA;;GAEG;AACH,MAAM,CAAN,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,4DAA4D;IAC5D,8BAAiB,CAAA;IACjB,qBAAqB;IACrB,4BAAe,CAAA;IACf,kCAAkC;IAClC,wBAAW,CAAA;IACX;;;OAGG;IACH,gCAAmB,CAAA;AACrB,CAAC,EAZW,SAAS,KAAT,SAAS,QAYpB;AAwCD;;GAEG;AACH,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,wCAA2B,CAAA;AAC7B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAsDD,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,mDAAqC,CAAA;IACrC,6CAA+B,CAAA;AACjC,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AA6DD,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAuCD,MAAM,CAAN,IAAY,OAWX;AAXD,WAAY,OAAO;IACjB,mCAAO,CAAA;IACP,8CAAa,CAAA;IACb,oCAAQ,CAAA;IACR,6CAAa,CAAA;IACb,2CAAY,CAAA;IACZ,wCAAW,CAAA;IACX,iDAAgB,CAAA;IAChB,mDAAiB,CAAA;IACjB,2CAAa,CAAA;IACb,wDAAyB,CAAA;AAC3B,CAAC,EAXW,OAAO,KAAP,OAAO,QAWlB;AAED,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,4BAAiB,CAAA;AACnB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAaD,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,6DAAoC,CAAA;IACpC,uDAA8B,CAAA;AAChC,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC;AAaD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,mDAAK,CAAA;AACP,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AACD,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,6DAAyC,CAAA;IACzC,0EAAsD,CAAA;AACxD,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AACD,MAAM,CAAN,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,qEAA2C,CAAA;IAC3C,oDAA0B,CAAA;IAC1B,gFAAsD,CAAA;AACxD,CAAC,EAJW,sBAAsB,KAAtB,sBAAsB,QAIjC","sourcesContent":["import type { AccountsControllerGetSelectedMultichainAccountAction } from '@metamask/accounts-controller';\nimport type {\n ControllerStateChangeEvent,\n RestrictedMessenger,\n} from '@metamask/base-controller';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetStateAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type {\n CaipAccountId,\n CaipAssetId,\n CaipChainId,\n Hex,\n} from '@metamask/utils';\nimport type { BigNumber } from 'bignumber.js';\n\nimport type { BridgeController } from './bridge-controller';\nimport type { BRIDGE_CONTROLLER_NAME } from './constants/bridge';\n\n/**\n * Additional options accepted by the extension's fetchWithCache function\n */\ntype FetchWithCacheOptions = {\n cacheOptions?: {\n cacheRefreshTime: number;\n };\n functionName?: string;\n};\n\nexport type FetchFunction = (\n input: RequestInfo | URL,\n init?: RequestInit & FetchWithCacheOptions,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => Promise<any>;\n\n/**\n * The types of assets that a user can send\n */\nexport enum AssetType {\n /** The native asset for the current network, such as ETH */\n native = 'NATIVE',\n /** An ERC20 token */\n token = 'TOKEN',\n /** An ERC721 or ERC1155 token. */\n NFT = 'NFT',\n /**\n * A transaction interacting with a contract that isn't a token method\n * interaction will be marked as dealing with an unknown asset type.\n */\n unknown = 'UNKNOWN',\n}\n\nexport type ChainConfiguration = {\n isActiveSrc: boolean;\n isActiveDest: boolean;\n refreshRate?: number;\n topAssets?: string[];\n};\n\nexport type L1GasFees = {\n l1GasFeesInHexWei?: string; // l1 fees for approval and trade in hex wei, appended by BridgeController.#appendL1GasFees\n};\n\nexport type SolanaFees = {\n solanaFeesInLamports?: string; // solana fees in lamports, appended by BridgeController.#appendSolanaFees\n};\n\n/**\n * valueInCurrency values are calculated based on the user's selected currency\n */\nexport type TokenAmountValues = {\n amount: BigNumber;\n valueInCurrency: BigNumber | null;\n usd: BigNumber | null;\n};\n\n/**\n * Values derived from the quote response\n */\nexport type QuoteMetadata = {\n gasFee: TokenAmountValues;\n totalNetworkFee: TokenAmountValues; // estimatedGasFees + relayerFees\n totalMaxNetworkFee: TokenAmountValues; // maxGasFees + relayerFees\n toTokenAmount: TokenAmountValues;\n adjustedReturn: Omit<TokenAmountValues, 'amount'>; // destTokenAmount - totalNetworkFee\n sentAmount: TokenAmountValues; // srcTokenAmount + metabridgeFee\n swapRate: BigNumber; // destTokenAmount / sentAmount\n cost: Omit<TokenAmountValues, 'amount'>; // sentAmount - adjustedReturn\n};\n\n/**\n * Sort order set by the user\n */\nexport enum SortOrder {\n COST_ASC = 'cost_ascending',\n ETA_ASC = 'time_descending',\n}\n\n/**\n * This is the interface for the asset object returned by the bridge-api\n * This type is used in the QuoteResponse and in the fetchBridgeTokens response\n */\nexport type BridgeAsset = {\n /**\n * The chainId of the token\n */\n chainId: ChainId;\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string;\n /**\n * The symbol of token object\n */\n symbol: string;\n /**\n * The name for the network\n */\n name: string;\n /**\n * Number of digits after decimal point\n */\n decimals: number;\n icon?: string;\n /**\n * URL for token icon\n */\n iconUrl?: string;\n /**\n * The assetId of the token\n */\n assetId: string;\n};\n\n/**\n * This is the interface for the token object used in the extension client\n * In addition to the {@link BridgeAsset} fields, it includes balance information\n */\nexport type BridgeToken = {\n address: string;\n symbol: string;\n image: string;\n decimals: number;\n chainId: number | Hex | ChainId | CaipChainId;\n balance: string; // raw balance\n // TODO deprecate this field and use balance instead\n string: string | undefined; // normalized balance as a stringified number\n tokenFiatAmount?: number | null;\n};\n\nexport enum BridgeFlag {\n EXTENSION_CONFIG = 'extension-config',\n MOBILE_CONFIG = 'mobile-config',\n}\ntype DecimalChainId = string;\nexport type GasMultiplierByChainId = Record<DecimalChainId, number>;\n\ntype FeatureFlagResponsePlatformConfig = {\n refreshRate: number;\n maxRefreshCount: number;\n support: boolean;\n chains: Record<string, ChainConfiguration>;\n};\n\nexport type FeatureFlagResponse = {\n [BridgeFlag.EXTENSION_CONFIG]: FeatureFlagResponsePlatformConfig;\n [BridgeFlag.MOBILE_CONFIG]: FeatureFlagResponsePlatformConfig;\n};\n\n/**\n * This is the interface for the quote request sent to the bridge-api\n * and should only be used by the fetchBridgeQuotes utility function\n * Components and redux stores should use the {@link GenericQuoteRequest} type\n */\nexport type QuoteRequest<\n ChainIdType = ChainId | number,\n TokenAddressType = string,\n WalletAddressType = string,\n> = {\n walletAddress: WalletAddressType;\n destWalletAddress?: WalletAddressType;\n srcChainId: ChainIdType;\n destChainId: ChainIdType;\n srcTokenAddress: TokenAddressType;\n destTokenAddress: TokenAddressType;\n /**\n * This is the amount sent, in atomic amount\n */\n srcTokenAmount: string;\n slippage?: number;\n aggIds?: string[];\n bridgeIds?: string[];\n insufficientBal?: boolean;\n resetApproval?: boolean;\n refuel?: boolean;\n};\n\n/**\n * These are types that components pass in. Since data is a mix of types when coming from the redux store, we need to use a generic type that can cover all the types.\n * Payloads with this type are transformed into QuoteRequest by fetchBridgeQuotes right before fetching quotes\n */\nexport type GenericQuoteRequest = QuoteRequest<\n Hex | CaipChainId | string | number, // chainIds\n Hex | CaipAssetId | string, // assetIds/addresses\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments\n Hex | CaipAccountId | string // accountIds/addresses\n>;\n\nexport type Protocol = {\n name: string;\n displayName?: string;\n icon?: string;\n};\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nexport type Step = {\n action: ActionTypes;\n srcChainId: ChainId;\n destChainId?: ChainId;\n srcAsset: BridgeAsset;\n destAsset: BridgeAsset;\n srcAmount: string;\n destAmount: string;\n protocol: Protocol;\n};\n\nexport type RefuelData = Step;\n\nexport type Quote = {\n requestId: string;\n srcChainId: ChainId;\n srcAsset: BridgeAsset;\n // Some tokens have a fee of 0, so sometimes it's equal to amount sent\n srcTokenAmount: string; // Atomic amount, the amount sent - fees\n destChainId: ChainId;\n destAsset: BridgeAsset;\n destTokenAmount: string; // Atomic amount, the amount received\n feeData: Record<FeeType.METABRIDGE, FeeData> &\n Partial<Record<FeeType, FeeData>>;\n bridgeId: string;\n bridges: string[];\n steps: Step[];\n refuel?: RefuelData;\n};\n\nexport type QuoteResponse = {\n quote: Quote;\n approval?: TxData | null;\n trade: TxData;\n estimatedProcessingTimeInSeconds: number;\n};\n\nexport enum ChainId {\n ETH = 1,\n OPTIMISM = 10,\n BSC = 56,\n POLYGON = 137,\n ZKSYNC = 324,\n BASE = 8453,\n ARBITRUM = 42161,\n AVALANCHE = 43114,\n LINEA = 59144,\n SOLANA = 1151111081099710,\n}\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n}\nexport type FeeData = {\n amount: string;\n asset: BridgeAsset;\n};\nexport type TxData = {\n chainId: ChainId;\n to: string;\n from: string;\n value: string;\n data: string;\n gasLimit: number | null;\n};\nexport enum BridgeFeatureFlagsKey {\n EXTENSION_CONFIG = 'extensionConfig',\n MOBILE_CONFIG = 'mobileConfig',\n}\n\ntype FeatureFlagsPlatformConfig = {\n refreshRate: number;\n maxRefreshCount: number;\n support: boolean;\n chains: Record<CaipChainId, ChainConfiguration>;\n};\n\nexport type BridgeFeatureFlags = {\n [BridgeFeatureFlagsKey.EXTENSION_CONFIG]: FeatureFlagsPlatformConfig;\n [BridgeFeatureFlagsKey.MOBILE_CONFIG]: FeatureFlagsPlatformConfig;\n};\nexport enum RequestStatus {\n LOADING,\n FETCHED,\n ERROR,\n}\nexport enum BridgeUserAction {\n SELECT_DEST_NETWORK = 'selectDestNetwork',\n UPDATE_QUOTE_PARAMS = 'updateBridgeQuoteRequestParams',\n}\nexport enum BridgeBackgroundAction {\n SET_FEATURE_FLAGS = 'setBridgeFeatureFlags',\n RESET_STATE = 'resetState',\n GET_BRIDGE_ERC20_ALLOWANCE = 'getBridgeERC20Allowance',\n}\n\nexport type BridgeControllerState = {\n bridgeFeatureFlags: BridgeFeatureFlags;\n quoteRequest: Partial<GenericQuoteRequest>;\n quotes: (QuoteResponse & L1GasFees & SolanaFees)[];\n quotesInitialLoadTime: number | null;\n quotesLastFetched: number | null;\n quotesLoadingStatus: RequestStatus | null;\n quoteFetchError: string | null;\n quotesRefreshCount: number;\n};\n\nexport type BridgeControllerAction<\n FunctionName extends keyof BridgeController,\n> = {\n type: `${typeof BRIDGE_CONTROLLER_NAME}:${FunctionName}`;\n handler: BridgeController[FunctionName];\n};\n\n// Maps to BridgeController function names\nexport type BridgeControllerActions =\n | BridgeControllerAction<BridgeBackgroundAction.SET_FEATURE_FLAGS>\n | BridgeControllerAction<BridgeBackgroundAction.RESET_STATE>\n | BridgeControllerAction<BridgeBackgroundAction.GET_BRIDGE_ERC20_ALLOWANCE>\n | BridgeControllerAction<BridgeUserAction.UPDATE_QUOTE_PARAMS>;\n\nexport type BridgeControllerEvents = ControllerStateChangeEvent<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState\n>;\n\nexport type AllowedActions =\n | AccountsControllerGetSelectedMultichainAccountAction\n | HandleSnapRequest\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction;\nexport type AllowedEvents = never;\n\n/**\n * The messenger for the BridgeController.\n */\nexport type BridgeControllerMessenger = RestrictedMessenger<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerActions | AllowedActions,\n BridgeControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
|