Skip to content

Commit a3b1b6c

Browse files
committed
chore: rename files etc
1 parent bd1c1ee commit a3b1b6c

25 files changed

Lines changed: 182 additions & 249 deletions

packages/bridge-controller/src/bridge-controller.sse.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { formatChainIdToDec } from './utils/caip-formatters';
3636
import * as featureFlagUtils from './utils/feature-flags';
3737
import * as fetchUtils from './utils/fetch';
3838
import { FeatureId } from './validators/feature-flags';
39+
import { validateQuoteResponseV1 } from './validators/quote-response-v1';
3940
import { QuoteStreamCompleteReason } from './validators/quote-stream-complete';
4041
import { TokenFeatureType } from './validators/token-feature';
4142
import type { TxData } from './validators/trade';

packages/bridge-controller/src/bridge-controller.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
UnifiedSwapBridgeEventName,
5757
} from './utils/metrics/constants';
5858
import { FeatureId } from './validators/feature-flags';
59+
import type { QuoteResponseV1 } from './validators/quote-response-v1';
5960

6061
const EMPTY_INIT_STATE = DEFAULT_BRIDGE_CONTROLLER_STATE;
6162

packages/bridge-controller/src/bridge-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import type {
3131
GenericQuoteRequest,
3232
NonEvmFees,
3333
QuoteRequest,
34-
QuoteResponseV1,
3534
BridgeControllerState,
3635
BridgeControllerMessenger,
3736
FetchFunction,
@@ -95,6 +94,7 @@ import {
9594
import { appendFeesToQuotes } from './utils/quote-fees';
9695
import { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps';
9796
import type { FeatureId } from './validators/feature-flags';
97+
import type { QuoteResponseV1 } from './validators/quote-response-v1';
9898

9999
const metadata: StateMetadata<BridgeControllerState> = {
100100
quoteRequest: {

packages/bridge-controller/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { DiscountType } from './validators/quote-response';
2-
31
export { BridgeController } from './bridge-controller';
42

53
export {
@@ -55,8 +53,6 @@ export type {
5553
TokenAmountValues,
5654
Step,
5755
RefuelData,
58-
Quote,
59-
QuoteResponseV1 as QuoteResponse,
6056
FeeData,
6157
Intent,
6258
IntentOrderLike,
@@ -111,11 +107,15 @@ export {
111107
isEvmTxData,
112108
isStellarTrade,
113109
} from './validators/trade';
110+
export type {
111+
Quote,
112+
QuoteResponseV1 as QuoteResponse,
113+
} from './validators/quote-response-v1';
114114
export {
115115
DiscountType,
116116
FeeType,
117117
ActionTypes,
118-
} from './validators/quote-response';
118+
} from './validators/quote-response-v1';
119119
export {
120120
validateQuoteStreamComplete,
121121
QuoteStreamCompleteReason,

packages/bridge-controller/src/selectors.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
ChainId,
2929
BridgeAsset,
3030
NonEvmFees,
31-
QuoteResponseV1,
3231
} from './types';
3332
import { getNativeAssetForChainId, isNativeAddress } from './utils/bridge';
3433
import {
@@ -39,7 +38,8 @@ import {
3938
formatChainIdToHex,
4039
} from './utils/caip-formatters';
4140
import { BatchSellTransactionType } from './validators/batch-sell';
42-
import { validateQuoteResponseV1 } from './validators/quote-response';
41+
import type { QuoteResponseV1 } from './validators/quote-response-v1';
42+
import { validateQuoteResponseV1 } from './validators/quote-response-v1';
4343

4444
const MOCK_USDC_ADDRESS = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
4545
const MOCK_MUSD_ADDRESS = '0x12345A7890123456789012345678901234567890';

packages/bridge-controller/src/selectors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import type {
2323
BridgeControllerState,
2424
ExchangeRate,
2525
QuoteMetadata,
26-
QuoteResponseV1,
2726
TokenAmountValues,
2827
} from './types';
2928
import { RequestStatus, SortOrder } from './types';
@@ -55,6 +54,7 @@ import {
5554
calcBatchFees,
5655
} from './utils/quote';
5756
import { getDefaultSlippagePercentage } from './utils/slippage';
57+
import type { QuoteResponseV1 } from './validators/quote-response-v1';
5858

5959
/**
6060
* The controller states that provide exchange rates

packages/bridge-controller/src/types.ts

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import type { BRIDGE_CONTROLLER_NAME } from './constants/bridge';
3333
import type { SimulatedGasFeeLimitsSchema } from './validators/batch-sell';
3434
import type { BatchSellTradesResponseSchema } from './validators/batch-sell';
3535
import type { BridgeAssetSchema } from './validators/bridge-asset';
36-
import type { FeatureId } from './validators/feature-flags';
3736
import type {
3837
ChainConfigurationSchema,
3938
ChainRankingSchema,
@@ -43,20 +42,13 @@ import type {
4342
FeeDataSchema,
4443
IntentSchema,
4544
ProtocolSchema,
46-
QuoteResponseSchema,
47-
QuoteSchema,
48-
StepSchema,
4945
GaslessPropertiesSchema,
5046
TxFeeGasLimitsSchema,
51-
} from './validators/quote-response';
47+
QuoteResponseV1,
48+
StepSchema,
49+
} from './validators/quote-response-v1';
5250
import type { QuoteStreamCompleteSchema } from './validators/quote-stream-complete';
5351
import type { TokenFeatureSchema } from './validators/token-feature';
54-
import type {
55-
BitcoinTradeData,
56-
StellarTradeData,
57-
TronTradeData,
58-
TxData,
59-
} from './validators/trade';
6052

6153
export type FetchFunction = (
6254
input: RequestInfo | URL | string,
@@ -85,10 +77,16 @@ export type ChainConfiguration = Infer<typeof ChainConfigurationSchema>;
8577

8678
export type ChainRanking = Infer<typeof ChainRankingSchema>;
8779

80+
/**
81+
* @deprecated Avoid introducing new usages and use the QuoteResponseV2 feeData.network value instead
82+
*/
8883
export type L1GasFees = {
89-
l1GasFeesInHexWei?: string; // l1 fees for approval and trade in hex wei, appended by BridgeController.#appendL1GasFees
84+
l1GasFeesInHexWei?: Hex; // l1 fees for approval and trade in hex wei, appended by BridgeController.#appendL1GasFees
9085
};
9186

87+
/**
88+
* @deprecated Avoid introducing new usages and use the QuoteResponseV2 feeData.network value instead
89+
*/
9290
export type NonEvmFees = {
9391
nonEvmFeesInNative?: string; // Non-EVM chain fees in native units (SOL for Solana, BTC for Bitcoin)
9492
};
@@ -126,6 +124,8 @@ export type ExchangeRate = { exchangeRate?: string; usdExchangeRate?: string };
126124

127125
/**
128126
* Values derived from the quote response
127+
*
128+
* @deprecated Avoid introducing new usages and use the QuoteResponse V2 type instead
129129
*/
130130
export type QuoteMetadata = {
131131
/**
@@ -284,43 +284,9 @@ export type RefuelData = Step;
284284

285285
export type FeeData = Infer<typeof FeeDataSchema>;
286286

287-
export type Quote = Infer<typeof QuoteSchema>;
288-
289287
export type Intent = Infer<typeof IntentSchema>;
290288
export type IntentOrderLike = Intent['order'];
291289

292-
/**
293-
* This is the type for the quote response from the bridge-api
294-
* TxDataType can be overriden to be a string when the quote is non-evm
295-
* ApprovalType can be overriden when you know the specific approval type (e.g., TxData for EVM-only contexts)
296-
*/
297-
export type QuoteResponseV1<
298-
TxDataType =
299-
| TxData
300-
| string
301-
| BitcoinTradeData
302-
| TronTradeData
303-
| StellarTradeData,
304-
ApprovalType = TxData | TronTradeData,
305-
> = Infer<typeof QuoteResponseSchema> & {
306-
trade: TxDataType;
307-
approval?: ApprovalType;
308-
/**
309-
* Appended to the quote response based on the quote request
310-
*/
311-
featureId?: FeatureId;
312-
/**
313-
* Appended to the quote response based on the quote request resetApproval flag
314-
* If defined, the quote's total network fee will include the reset approval's gas limit.
315-
*/
316-
resetApproval?: TxData;
317-
/**
318-
* Appended to the quote if there are multiple quote requests in a batch. This
319-
* indicates which quoteRequest the quote is for
320-
*/
321-
quoteRequestIndex?: number;
322-
};
323-
324290
export type BatchSellTradesRequest = {
325291
quotes: QuoteResponseV1[];
326292
stxEnabled: boolean;

packages/bridge-controller/src/utils/bridge.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
12
import { AddressZero } from '@ethersproject/constants';
23
import { Contract } from '@ethersproject/contracts';
34
import { BtcScope, SolScope, TrxScope, XlmScope } from '@metamask/keyring-api';
@@ -21,9 +22,9 @@ import type {
2122
BridgeAsset,
2223
BridgeControllerState,
2324
GenericQuoteRequest,
24-
QuoteResponseV1,
2525
} from '../types';
2626
import { ChainId } from '../types';
27+
import type { QuoteResponseV1 } from '../validators/quote-response-v1';
2728
import type { TxData } from '../validators/trade';
2829
import {
2930
formatChainIdToCaip,

packages/bridge-controller/src/utils/fetch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { StructError } from '@metamask/superstruct';
33
import type { CaipAssetType, CaipChainId, Hex } from '@metamask/utils';
44

55
import type {
6-
QuoteResponseV1,
76
FetchFunction,
87
GenericQuoteRequest,
98
QuoteRequest,
@@ -16,7 +15,8 @@ import type {
1615
import { validateBatchSellTradesResponse } from '../validators/batch-sell';
1716
import { validateBridgeAsset } from '../validators/bridge-asset';
1817
import type { FeatureId } from '../validators/feature-flags';
19-
import { validateQuoteResponseV1 } from '../validators/quote-response';
18+
import type { QuoteResponseV1 } from '../validators/quote-response-v1';
19+
import { validateQuoteResponseV1 } from '../validators/quote-response-v1';
2020
import { validateQuoteStreamComplete } from '../validators/quote-stream-complete';
2121
import { validateTokenFeature } from '../validators/token-feature';
2222
import { isEvmTxData } from '../validators/trade';

packages/bridge-controller/src/utils/metrics/properties.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { SolScope } from '@metamask/keyring-api';
22
import type { CaipChainId } from '@metamask/utils';
33

4-
import type { QuoteMetadata, QuoteResponseV1 } from '../../types';
4+
import type { QuoteMetadata } from '../../types';
5+
import type { QuoteResponseV1 } from '../../validators/quote-response-v1';
56
import { getNativeAssetForChainId } from '../bridge';
67
import { formatChainIdToCaip } from '../caip-formatters';
78
import { MetricsSwapType } from './constants';

0 commit comments

Comments
 (0)