@metamask-previews/bridge-controller 10.0.0-preview-e7013a54 → 10.0.0-preview-e56c504a
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 +0 -18
- package/dist/bridge-controller.cjs +25 -96
- 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 +26 -97
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/constants/bridge.cjs +1 -2
- package/dist/constants/bridge.cjs.map +1 -1
- package/dist/constants/bridge.d.cts +1 -2
- package/dist/constants/bridge.d.cts.map +1 -1
- package/dist/constants/bridge.d.mts +1 -2
- package/dist/constants/bridge.d.mts.map +1 -1
- package/dist/constants/bridge.mjs +1 -2
- package/dist/constants/bridge.mjs.map +1 -1
- package/dist/constants/chains.cjs +12 -1
- package/dist/constants/chains.cjs.map +1 -1
- package/dist/constants/chains.d.cts +2 -0
- package/dist/constants/chains.d.cts.map +1 -1
- package/dist/constants/chains.d.mts +2 -0
- package/dist/constants/chains.d.mts.map +1 -1
- package/dist/constants/chains.mjs +11 -0
- package/dist/constants/chains.mjs.map +1 -1
- package/dist/constants/tokens.cjs +38 -61
- package/dist/constants/tokens.cjs.map +1 -1
- package/dist/constants/tokens.d.cts +48 -100
- package/dist/constants/tokens.d.cts.map +1 -1
- package/dist/constants/tokens.d.mts +48 -100
- package/dist/constants/tokens.d.mts.map +1 -1
- package/dist/constants/tokens.mjs +14 -37
- package/dist/constants/tokens.mjs.map +1 -1
- package/dist/index.cjs +1 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -11
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +3 -4
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +54 -108
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +54 -108
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +3 -4
- 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 +5 -65
- package/dist/utils/bridge.cjs.map +1 -1
- package/dist/utils/bridge.d.cts +4 -27
- package/dist/utils/bridge.d.cts.map +1 -1
- package/dist/utils/bridge.d.mts +4 -27
- package/dist/utils/bridge.d.mts.map +1 -1
- package/dist/utils/bridge.mjs +5 -62
- package/dist/utils/bridge.mjs.map +1 -1
- package/dist/utils/fetch.cjs +26 -34
- package/dist/utils/fetch.cjs.map +1 -1
- package/dist/utils/fetch.d.cts +5 -6
- package/dist/utils/fetch.d.cts.map +1 -1
- package/dist/utils/fetch.d.mts +5 -6
- package/dist/utils/fetch.d.mts.map +1 -1
- package/dist/utils/fetch.mjs +24 -32
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/quote.cjs +2 -12
- 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 +2 -12
- package/dist/utils/quote.mjs.map +1 -1
- package/dist/utils/validators.cjs +16 -15
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +3 -2
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +3 -2
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +17 -16
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +2 -7
- package/dist/utils/caip-formatters.cjs +0 -102
- package/dist/utils/caip-formatters.cjs.map +0 -1
- package/dist/utils/caip-formatters.d.cts +0 -31
- package/dist/utils/caip-formatters.d.cts.map +0 -1
- package/dist/utils/caip-formatters.d.mts +0 -31
- package/dist/utils/caip-formatters.d.mts.map +0 -1
- package/dist/utils/caip-formatters.mjs +0 -95
- package/dist/utils/caip-formatters.mjs.map +0 -1
package/dist/types.d.cts
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountsControllerGetSelectedAccountAction } 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 {
|
|
5
|
-
import type { CaipAccountId, CaipAssetId, CaipChainId, Hex } from "@metamask/utils";
|
|
4
|
+
import type { Hex } from "@metamask/utils";
|
|
6
5
|
import type { BigNumber } from "bignumber.js";
|
|
7
6
|
import type { BridgeController } from "./bridge-controller.cjs";
|
|
8
7
|
import type { BRIDGE_CONTROLLER_NAME } from "./constants/bridge.cjs";
|
|
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>;
|
|
8
|
+
export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<any>;
|
|
19
9
|
/**
|
|
20
10
|
* The types of assets that a user can send
|
|
11
|
+
*
|
|
21
12
|
*/
|
|
22
13
|
export declare enum AssetType {
|
|
23
14
|
/** The native asset for the current network, such as ETH */
|
|
@@ -35,92 +26,54 @@ export declare enum AssetType {
|
|
|
35
26
|
export type ChainConfiguration = {
|
|
36
27
|
isActiveSrc: boolean;
|
|
37
28
|
isActiveDest: boolean;
|
|
38
|
-
refreshRate?: number;
|
|
39
|
-
topAssets?: string[];
|
|
40
29
|
};
|
|
41
30
|
export type L1GasFees = {
|
|
42
31
|
l1GasFeesInHexWei?: string;
|
|
43
32
|
};
|
|
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
|
-
*/
|
|
58
33
|
export type QuoteMetadata = {
|
|
59
|
-
gasFee:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
gasFee: {
|
|
35
|
+
amount: BigNumber;
|
|
36
|
+
valueInCurrency: BigNumber | null;
|
|
37
|
+
};
|
|
38
|
+
totalNetworkFee: {
|
|
39
|
+
amount: BigNumber;
|
|
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
|
+
};
|
|
65
57
|
swapRate: BigNumber;
|
|
66
|
-
cost:
|
|
58
|
+
cost: {
|
|
59
|
+
valueInCurrency: BigNumber | null;
|
|
60
|
+
};
|
|
67
61
|
};
|
|
68
|
-
/**
|
|
69
|
-
* Sort order set by the user
|
|
70
|
-
*/
|
|
71
62
|
export declare enum SortOrder {
|
|
72
63
|
COST_ASC = "cost_ascending",
|
|
73
64
|
ETA_ASC = "time_descending"
|
|
74
65
|
}
|
|
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
|
-
*/
|
|
114
66
|
export type BridgeToken = {
|
|
67
|
+
type: AssetType.native | AssetType.token;
|
|
115
68
|
address: string;
|
|
116
69
|
symbol: string;
|
|
117
70
|
image: string;
|
|
118
71
|
decimals: number;
|
|
119
|
-
chainId:
|
|
72
|
+
chainId: Hex;
|
|
120
73
|
balance: string;
|
|
121
74
|
string: string | undefined;
|
|
122
75
|
tokenFiatAmount?: number | null;
|
|
123
|
-
};
|
|
76
|
+
} | null;
|
|
124
77
|
export declare enum BridgeFlag {
|
|
125
78
|
EXTENSION_CONFIG = "extension-config",
|
|
126
79
|
MOBILE_CONFIG = "mobile-config"
|
|
@@ -137,38 +90,32 @@ export type FeatureFlagResponse = {
|
|
|
137
90
|
[BridgeFlag.EXTENSION_CONFIG]: FeatureFlagResponsePlatformConfig;
|
|
138
91
|
[BridgeFlag.MOBILE_CONFIG]: FeatureFlagResponsePlatformConfig;
|
|
139
92
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
93
|
+
export type BridgeAsset = {
|
|
94
|
+
chainId: ChainId;
|
|
95
|
+
address: string;
|
|
96
|
+
symbol: string;
|
|
97
|
+
name: string;
|
|
98
|
+
decimals: number;
|
|
99
|
+
icon?: string;
|
|
100
|
+
};
|
|
101
|
+
export type QuoteRequest = {
|
|
102
|
+
walletAddress: string;
|
|
103
|
+
destWalletAddress?: string;
|
|
104
|
+
srcChainId: ChainId;
|
|
105
|
+
destChainId: ChainId;
|
|
106
|
+
srcTokenAddress: string;
|
|
107
|
+
destTokenAddress: string;
|
|
152
108
|
/**
|
|
153
109
|
* This is the amount sent, in atomic amount
|
|
154
110
|
*/
|
|
155
111
|
srcTokenAmount: string;
|
|
156
|
-
slippage
|
|
112
|
+
slippage: number;
|
|
157
113
|
aggIds?: string[];
|
|
158
114
|
bridgeIds?: string[];
|
|
159
115
|
insufficientBal?: boolean;
|
|
160
116
|
resetApproval?: boolean;
|
|
161
117
|
refuel?: boolean;
|
|
162
118
|
};
|
|
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>;
|
|
172
119
|
export type Protocol = {
|
|
173
120
|
name: string;
|
|
174
121
|
displayName?: string;
|
|
@@ -219,8 +166,7 @@ export declare enum ChainId {
|
|
|
219
166
|
BASE = 8453,
|
|
220
167
|
ARBITRUM = 42161,
|
|
221
168
|
AVALANCHE = 43114,
|
|
222
|
-
LINEA = 59144
|
|
223
|
-
SOLANA = 1151111081099710
|
|
169
|
+
LINEA = 59144
|
|
224
170
|
}
|
|
225
171
|
export declare enum FeeType {
|
|
226
172
|
METABRIDGE = "metabridge",
|
|
@@ -246,7 +192,7 @@ type FeatureFlagsPlatformConfig = {
|
|
|
246
192
|
refreshRate: number;
|
|
247
193
|
maxRefreshCount: number;
|
|
248
194
|
support: boolean;
|
|
249
|
-
chains: Record<
|
|
195
|
+
chains: Record<Hex, ChainConfiguration>;
|
|
250
196
|
};
|
|
251
197
|
export type BridgeFeatureFlags = {
|
|
252
198
|
[BridgeFeatureFlagsKey.EXTENSION_CONFIG]: FeatureFlagsPlatformConfig;
|
|
@@ -268,8 +214,8 @@ export declare enum BridgeBackgroundAction {
|
|
|
268
214
|
}
|
|
269
215
|
export type BridgeControllerState = {
|
|
270
216
|
bridgeFeatureFlags: BridgeFeatureFlags;
|
|
271
|
-
quoteRequest: Partial<
|
|
272
|
-
quotes: (QuoteResponse & L1GasFees
|
|
217
|
+
quoteRequest: Partial<QuoteRequest>;
|
|
218
|
+
quotes: (QuoteResponse & L1GasFees)[];
|
|
273
219
|
quotesInitialLoadTime: number | null;
|
|
274
220
|
quotesLastFetched: number | null;
|
|
275
221
|
quotesLoadingStatus: RequestStatus | null;
|
|
@@ -282,7 +228,7 @@ export type BridgeControllerAction<FunctionName extends keyof BridgeController>
|
|
|
282
228
|
};
|
|
283
229
|
export type BridgeControllerActions = BridgeControllerAction<BridgeBackgroundAction.SET_FEATURE_FLAGS> | BridgeControllerAction<BridgeBackgroundAction.RESET_STATE> | BridgeControllerAction<BridgeBackgroundAction.GET_BRIDGE_ERC20_ALLOWANCE> | BridgeControllerAction<BridgeUserAction.UPDATE_QUOTE_PARAMS>;
|
|
284
230
|
export type BridgeControllerEvents = ControllerStateChangeEvent<typeof BRIDGE_CONTROLLER_NAME, BridgeControllerState>;
|
|
285
|
-
export type AllowedActions =
|
|
231
|
+
export type AllowedActions = AccountsControllerGetSelectedAccountAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction;
|
|
286
232
|
export type AllowedEvents = never;
|
|
287
233
|
/**
|
|
288
234
|
* 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,0CAA0C,EAAE,sCAAsC;AAChG,OAAO,KAAK,EACV,0BAA0B,EAC1B,mBAAmB,EACpB,kCAAkC;AACnC,OAAO,KAAK,EACV,mDAAmD,EACnD,+BAA+B,EAC/B,2CAA2C,EAC5C,qCAAqC;AACtC,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAC5D,OAAO,KAAK,EAAE,sBA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,sBAAsB,CAAC,WAAW,CAAC,GAC1D,sBAAsB,CAAC,sBAAsB,CAAC,0BAA0B,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,0CAA0C,GAC1C,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,23 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountsControllerGetSelectedAccountAction } 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 {
|
|
5
|
-
import type { CaipAccountId, CaipAssetId, CaipChainId, Hex } from "@metamask/utils";
|
|
4
|
+
import type { Hex } from "@metamask/utils";
|
|
6
5
|
import type { BigNumber } from "bignumber.js";
|
|
7
6
|
import type { BridgeController } from "./bridge-controller.mjs";
|
|
8
7
|
import type { BRIDGE_CONTROLLER_NAME } from "./constants/bridge.mjs";
|
|
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>;
|
|
8
|
+
export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<any>;
|
|
19
9
|
/**
|
|
20
10
|
* The types of assets that a user can send
|
|
11
|
+
*
|
|
21
12
|
*/
|
|
22
13
|
export declare enum AssetType {
|
|
23
14
|
/** The native asset for the current network, such as ETH */
|
|
@@ -35,92 +26,54 @@ export declare enum AssetType {
|
|
|
35
26
|
export type ChainConfiguration = {
|
|
36
27
|
isActiveSrc: boolean;
|
|
37
28
|
isActiveDest: boolean;
|
|
38
|
-
refreshRate?: number;
|
|
39
|
-
topAssets?: string[];
|
|
40
29
|
};
|
|
41
30
|
export type L1GasFees = {
|
|
42
31
|
l1GasFeesInHexWei?: string;
|
|
43
32
|
};
|
|
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
|
-
*/
|
|
58
33
|
export type QuoteMetadata = {
|
|
59
|
-
gasFee:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
gasFee: {
|
|
35
|
+
amount: BigNumber;
|
|
36
|
+
valueInCurrency: BigNumber | null;
|
|
37
|
+
};
|
|
38
|
+
totalNetworkFee: {
|
|
39
|
+
amount: BigNumber;
|
|
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
|
+
};
|
|
65
57
|
swapRate: BigNumber;
|
|
66
|
-
cost:
|
|
58
|
+
cost: {
|
|
59
|
+
valueInCurrency: BigNumber | null;
|
|
60
|
+
};
|
|
67
61
|
};
|
|
68
|
-
/**
|
|
69
|
-
* Sort order set by the user
|
|
70
|
-
*/
|
|
71
62
|
export declare enum SortOrder {
|
|
72
63
|
COST_ASC = "cost_ascending",
|
|
73
64
|
ETA_ASC = "time_descending"
|
|
74
65
|
}
|
|
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
|
-
*/
|
|
114
66
|
export type BridgeToken = {
|
|
67
|
+
type: AssetType.native | AssetType.token;
|
|
115
68
|
address: string;
|
|
116
69
|
symbol: string;
|
|
117
70
|
image: string;
|
|
118
71
|
decimals: number;
|
|
119
|
-
chainId:
|
|
72
|
+
chainId: Hex;
|
|
120
73
|
balance: string;
|
|
121
74
|
string: string | undefined;
|
|
122
75
|
tokenFiatAmount?: number | null;
|
|
123
|
-
};
|
|
76
|
+
} | null;
|
|
124
77
|
export declare enum BridgeFlag {
|
|
125
78
|
EXTENSION_CONFIG = "extension-config",
|
|
126
79
|
MOBILE_CONFIG = "mobile-config"
|
|
@@ -137,38 +90,32 @@ export type FeatureFlagResponse = {
|
|
|
137
90
|
[BridgeFlag.EXTENSION_CONFIG]: FeatureFlagResponsePlatformConfig;
|
|
138
91
|
[BridgeFlag.MOBILE_CONFIG]: FeatureFlagResponsePlatformConfig;
|
|
139
92
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
93
|
+
export type BridgeAsset = {
|
|
94
|
+
chainId: ChainId;
|
|
95
|
+
address: string;
|
|
96
|
+
symbol: string;
|
|
97
|
+
name: string;
|
|
98
|
+
decimals: number;
|
|
99
|
+
icon?: string;
|
|
100
|
+
};
|
|
101
|
+
export type QuoteRequest = {
|
|
102
|
+
walletAddress: string;
|
|
103
|
+
destWalletAddress?: string;
|
|
104
|
+
srcChainId: ChainId;
|
|
105
|
+
destChainId: ChainId;
|
|
106
|
+
srcTokenAddress: string;
|
|
107
|
+
destTokenAddress: string;
|
|
152
108
|
/**
|
|
153
109
|
* This is the amount sent, in atomic amount
|
|
154
110
|
*/
|
|
155
111
|
srcTokenAmount: string;
|
|
156
|
-
slippage
|
|
112
|
+
slippage: number;
|
|
157
113
|
aggIds?: string[];
|
|
158
114
|
bridgeIds?: string[];
|
|
159
115
|
insufficientBal?: boolean;
|
|
160
116
|
resetApproval?: boolean;
|
|
161
117
|
refuel?: boolean;
|
|
162
118
|
};
|
|
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>;
|
|
172
119
|
export type Protocol = {
|
|
173
120
|
name: string;
|
|
174
121
|
displayName?: string;
|
|
@@ -219,8 +166,7 @@ export declare enum ChainId {
|
|
|
219
166
|
BASE = 8453,
|
|
220
167
|
ARBITRUM = 42161,
|
|
221
168
|
AVALANCHE = 43114,
|
|
222
|
-
LINEA = 59144
|
|
223
|
-
SOLANA = 1151111081099710
|
|
169
|
+
LINEA = 59144
|
|
224
170
|
}
|
|
225
171
|
export declare enum FeeType {
|
|
226
172
|
METABRIDGE = "metabridge",
|
|
@@ -246,7 +192,7 @@ type FeatureFlagsPlatformConfig = {
|
|
|
246
192
|
refreshRate: number;
|
|
247
193
|
maxRefreshCount: number;
|
|
248
194
|
support: boolean;
|
|
249
|
-
chains: Record<
|
|
195
|
+
chains: Record<Hex, ChainConfiguration>;
|
|
250
196
|
};
|
|
251
197
|
export type BridgeFeatureFlags = {
|
|
252
198
|
[BridgeFeatureFlagsKey.EXTENSION_CONFIG]: FeatureFlagsPlatformConfig;
|
|
@@ -268,8 +214,8 @@ export declare enum BridgeBackgroundAction {
|
|
|
268
214
|
}
|
|
269
215
|
export type BridgeControllerState = {
|
|
270
216
|
bridgeFeatureFlags: BridgeFeatureFlags;
|
|
271
|
-
quoteRequest: Partial<
|
|
272
|
-
quotes: (QuoteResponse & L1GasFees
|
|
217
|
+
quoteRequest: Partial<QuoteRequest>;
|
|
218
|
+
quotes: (QuoteResponse & L1GasFees)[];
|
|
273
219
|
quotesInitialLoadTime: number | null;
|
|
274
220
|
quotesLastFetched: number | null;
|
|
275
221
|
quotesLoadingStatus: RequestStatus | null;
|
|
@@ -282,7 +228,7 @@ export type BridgeControllerAction<FunctionName extends keyof BridgeController>
|
|
|
282
228
|
};
|
|
283
229
|
export type BridgeControllerActions = BridgeControllerAction<BridgeBackgroundAction.SET_FEATURE_FLAGS> | BridgeControllerAction<BridgeBackgroundAction.RESET_STATE> | BridgeControllerAction<BridgeBackgroundAction.GET_BRIDGE_ERC20_ALLOWANCE> | BridgeControllerAction<BridgeUserAction.UPDATE_QUOTE_PARAMS>;
|
|
284
230
|
export type BridgeControllerEvents = ControllerStateChangeEvent<typeof BRIDGE_CONTROLLER_NAME, BridgeControllerState>;
|
|
285
|
-
export type AllowedActions =
|
|
231
|
+
export type AllowedActions = AccountsControllerGetSelectedAccountAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction;
|
|
286
232
|
export type AllowedEvents = never;
|
|
287
233
|
/**
|
|
288
234
|
* 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":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0CAA0C,EAAE,sCAAsC;AAChG,OAAO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5B,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAChC,YAAY,SAAS,MAAM,gBAAgB,IACzC;IACF,IAAI,EAAE,GAAG,OAAO,sBAAsB,IAAI,YAAY,EAAE,CAAC;IACzD,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACzC,CAAC;AAGF,MAAM,MAAM,uBAAuB,GAC/B,sBAAsB,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,GAChE,sBAAsB,CAAC,sBAAsB,CAAC,WAAW,CAAC,GAC1D,sBAAsB,CAAC,sBAAsB,CAAC,0BAA0B,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,0CAA0C,GAC1C,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,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The types of assets that a user can send
|
|
3
|
+
*
|
|
3
4
|
*/
|
|
4
5
|
export var AssetType;
|
|
5
6
|
(function (AssetType) {
|
|
@@ -15,14 +16,13 @@ export var AssetType;
|
|
|
15
16
|
*/
|
|
16
17
|
AssetType["unknown"] = "UNKNOWN";
|
|
17
18
|
})(AssetType || (AssetType = {}));
|
|
18
|
-
|
|
19
|
-
* Sort order set by the user
|
|
20
|
-
*/
|
|
19
|
+
// Sort order set by the user
|
|
21
20
|
export var SortOrder;
|
|
22
21
|
(function (SortOrder) {
|
|
23
22
|
SortOrder["COST_ASC"] = "cost_ascending";
|
|
24
23
|
SortOrder["ETA_ASC"] = "time_descending";
|
|
25
24
|
})(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,7 +45,6 @@ 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";
|
|
49
48
|
})(ChainId || (ChainId = {}));
|
|
50
49
|
export var FeeType;
|
|
51
50
|
(function (FeeType) {
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"]}
|
|
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;AAH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,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"]}
|