@metamask-previews/bridge-controller 77.8.0-preview-5959fe813 → 77.8.0-preview-0d2cbf546
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 -12
- package/dist/bridge-controller.cjs +3 -8
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts +3 -4
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts +3 -4
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +3 -8
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/index.cjs +2 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -7
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +29 -31
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +36410 -5110
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +36410 -5110
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs +29 -31
- package/dist/selectors.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +7 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +7 -2
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/bridge.cjs +5 -1
- package/dist/utils/bridge.cjs.map +1 -1
- package/dist/utils/bridge.d.cts +19 -2
- package/dist/utils/bridge.d.cts.map +1 -1
- package/dist/utils/bridge.d.mts +19 -2
- package/dist/utils/bridge.d.mts.map +1 -1
- package/dist/utils/bridge.mjs +3 -0
- package/dist/utils/bridge.mjs.map +1 -1
- package/dist/utils/caip-formatters.cjs +3 -0
- package/dist/utils/caip-formatters.cjs.map +1 -1
- package/dist/utils/caip-formatters.d.cts.map +1 -1
- package/dist/utils/caip-formatters.d.mts.map +1 -1
- package/dist/utils/caip-formatters.mjs +3 -0
- package/dist/utils/caip-formatters.mjs.map +1 -1
- package/dist/utils/feature-flags.d.cts +2 -2
- package/dist/utils/feature-flags.d.mts +2 -2
- package/dist/utils/fetch.cjs +40 -37
- package/dist/utils/fetch.cjs.map +1 -1
- package/dist/utils/fetch.d.cts +4 -10
- package/dist/utils/fetch.d.cts.map +1 -1
- package/dist/utils/fetch.d.mts +4 -10
- package/dist/utils/fetch.d.mts.map +1 -1
- package/dist/utils/fetch.mjs +40 -37
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/metrics/properties.cjs +6 -6
- package/dist/utils/metrics/properties.cjs.map +1 -1
- package/dist/utils/metrics/properties.d.cts +5 -8
- package/dist/utils/metrics/properties.d.cts.map +1 -1
- package/dist/utils/metrics/properties.d.mts +5 -8
- package/dist/utils/metrics/properties.d.mts.map +1 -1
- package/dist/utils/metrics/properties.mjs +6 -6
- package/dist/utils/metrics/properties.mjs.map +1 -1
- package/dist/utils/metrics/types.cjs.map +1 -1
- package/dist/utils/metrics/types.d.cts +1 -1
- package/dist/utils/metrics/types.d.cts.map +1 -1
- package/dist/utils/metrics/types.d.mts +1 -1
- package/dist/utils/metrics/types.d.mts.map +1 -1
- package/dist/utils/metrics/types.mjs.map +1 -1
- package/dist/utils/number-formatters.cjs +1 -74
- package/dist/utils/number-formatters.cjs.map +1 -1
- package/dist/utils/number-formatters.d.cts +0 -18
- package/dist/utils/number-formatters.d.cts.map +1 -1
- package/dist/utils/number-formatters.d.mts +0 -18
- package/dist/utils/number-formatters.d.mts.map +1 -1
- package/dist/utils/number-formatters.mjs +0 -71
- package/dist/utils/number-formatters.mjs.map +1 -1
- package/dist/utils/quote-fees.cjs +22 -23
- package/dist/utils/quote-fees.cjs.map +1 -1
- package/dist/utils/quote-fees.d.cts +2 -4
- package/dist/utils/quote-fees.d.cts.map +1 -1
- package/dist/utils/quote-fees.d.mts +2 -4
- package/dist/utils/quote-fees.d.mts.map +1 -1
- package/dist/utils/quote-fees.mjs +23 -24
- package/dist/utils/quote-fees.mjs.map +1 -1
- package/dist/utils/quote-metadata/calculators.cjs +35 -33
- package/dist/utils/quote-metadata/calculators.cjs.map +1 -1
- package/dist/utils/quote-metadata/calculators.d.cts +14 -20
- package/dist/utils/quote-metadata/calculators.d.cts.map +1 -1
- package/dist/utils/quote-metadata/calculators.d.mts +14 -20
- package/dist/utils/quote-metadata/calculators.d.mts.map +1 -1
- package/dist/utils/quote-metadata/calculators.mjs +36 -34
- package/dist/utils/quote-metadata/calculators.mjs.map +1 -1
- package/dist/utils/quote-metadata/merge.cjs +2 -24
- package/dist/utils/quote-metadata/merge.cjs.map +1 -1
- package/dist/utils/quote-metadata/merge.d.cts +2 -3
- package/dist/utils/quote-metadata/merge.d.cts.map +1 -1
- package/dist/utils/quote-metadata/merge.d.mts +2 -3
- package/dist/utils/quote-metadata/merge.d.mts.map +1 -1
- package/dist/utils/quote-metadata/merge.mjs +2 -24
- package/dist/utils/quote-metadata/merge.mjs.map +1 -1
- package/dist/utils/slippage.d.cts +1 -1
- package/dist/utils/slippage.d.mts +1 -1
- package/dist/validators/batch-sell.d.cts +8 -8
- package/dist/validators/batch-sell.d.mts +8 -8
- package/dist/validators/bridge-asset.cjs +1 -65
- package/dist/validators/bridge-asset.cjs.map +1 -1
- package/dist/validators/bridge-asset.d.cts +5 -99
- package/dist/validators/bridge-asset.d.cts.map +1 -1
- package/dist/validators/bridge-asset.d.mts +5 -99
- package/dist/validators/bridge-asset.d.mts.map +1 -1
- package/dist/validators/bridge-asset.mjs +1 -64
- package/dist/validators/bridge-asset.mjs.map +1 -1
- package/dist/validators/feature-flags.d.cts +5 -5
- package/dist/validators/feature-flags.d.mts +5 -5
- package/dist/validators/intent.d.cts +3 -3
- package/dist/validators/intent.d.mts +3 -3
- package/dist/validators/quote-response-v1.d.cts +179 -179
- package/dist/validators/quote-response-v1.d.mts +179 -179
- package/dist/validators/quote.cjs +3 -73
- package/dist/validators/quote.cjs.map +1 -1
- package/dist/validators/quote.d.cts +45 -407
- package/dist/validators/quote.d.cts.map +1 -1
- package/dist/validators/quote.d.mts +45 -407
- package/dist/validators/quote.d.mts.map +1 -1
- package/dist/validators/quote.mjs +4 -74
- package/dist/validators/quote.mjs.map +1 -1
- package/dist/validators/step.cjs +1 -7
- package/dist/validators/step.cjs.map +1 -1
- package/dist/validators/step.d.cts +26 -197
- package/dist/validators/step.d.cts.map +1 -1
- package/dist/validators/step.d.mts +26 -197
- package/dist/validators/step.d.mts.map +1 -1
- package/dist/validators/step.mjs +1 -7
- package/dist/validators/step.mjs.map +1 -1
- package/dist/validators/token-feature.d.cts +2 -2
- package/dist/validators/token-feature.d.mts +2 -2
- package/dist/validators/trade.d.cts +2 -2
- package/dist/validators/trade.d.mts +2 -2
- package/package.json +1 -1
- package/dist/coercers/quote-response-v1-to-v2.cjs +0 -137
- package/dist/coercers/quote-response-v1-to-v2.cjs.map +0 -1
- package/dist/coercers/quote-response-v1-to-v2.d.cts +0 -13
- package/dist/coercers/quote-response-v1-to-v2.d.cts.map +0 -1
- package/dist/coercers/quote-response-v1-to-v2.d.mts +0 -13
- package/dist/coercers/quote-response-v1-to-v2.d.mts.map +0 -1
- package/dist/coercers/quote-response-v1-to-v2.mjs +0 -132
- package/dist/coercers/quote-response-v1-to-v2.mjs.map +0 -1
- package/dist/coercers/quote-response-v2-to-v1.cjs +0 -173
- package/dist/coercers/quote-response-v2-to-v1.cjs.map +0 -1
- package/dist/coercers/quote-response-v2-to-v1.d.cts +0 -13
- package/dist/coercers/quote-response-v2-to-v1.d.cts.map +0 -1
- package/dist/coercers/quote-response-v2-to-v1.d.mts +0 -13
- package/dist/coercers/quote-response-v2-to-v1.d.mts.map +0 -1
- package/dist/coercers/quote-response-v2-to-v1.mjs +0 -169
- package/dist/coercers/quote-response-v2-to-v1.mjs.map +0 -1
- package/dist/utils/quote-metadata/to-normalized-amounts.cjs +0 -38
- package/dist/utils/quote-metadata/to-normalized-amounts.cjs.map +0 -1
- package/dist/utils/quote-metadata/to-normalized-amounts.d.cts +0 -10
- package/dist/utils/quote-metadata/to-normalized-amounts.d.cts.map +0 -1
- package/dist/utils/quote-metadata/to-normalized-amounts.d.mts +0 -10
- package/dist/utils/quote-metadata/to-normalized-amounts.d.mts.map +0 -1
- package/dist/utils/quote-metadata/to-normalized-amounts.mjs +0 -34
- package/dist/utils/quote-metadata/to-normalized-amounts.mjs.map +0 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.cjs +0 -39
- package/dist/utils/quote-metadata/to-quote-metadata-v1.cjs.map +0 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.d.cts +0 -13
- package/dist/utils/quote-metadata/to-quote-metadata-v1.d.cts.map +0 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.d.mts +0 -13
- package/dist/utils/quote-metadata/to-quote-metadata-v1.d.mts.map +0 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v1.mjs +0 -36
- package/dist/utils/quote-metadata/to-quote-metadata-v1.mjs.map +0 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v2.cjs +0 -94
- package/dist/utils/quote-metadata/to-quote-metadata-v2.cjs.map +0 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v2.d.cts +0 -12
- package/dist/utils/quote-metadata/to-quote-metadata-v2.d.cts.map +0 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v2.d.mts +0 -12
- package/dist/utils/quote-metadata/to-quote-metadata-v2.d.mts.map +0 -1
- package/dist/utils/quote-metadata/to-quote-metadata-v2.mjs +0 -90
- package/dist/utils/quote-metadata/to-quote-metadata-v2.mjs.map +0 -1
- package/dist/validators/amount-and-asset.cjs +0 -27
- package/dist/validators/amount-and-asset.cjs.map +0 -1
- package/dist/validators/amount-and-asset.d.cts +0 -62
- package/dist/validators/amount-and-asset.d.cts.map +0 -1
- package/dist/validators/amount-and-asset.d.mts +0 -62
- package/dist/validators/amount-and-asset.d.mts.map +0 -1
- package/dist/validators/amount-and-asset.mjs +0 -24
- package/dist/validators/amount-and-asset.mjs.map +0 -1
- package/dist/validators/quote-response.cjs +0 -116
- package/dist/validators/quote-response.cjs.map +0 -1
- package/dist/validators/quote-response.d.cts +0 -1979
- package/dist/validators/quote-response.d.cts.map +0 -1
- package/dist/validators/quote-response.d.mts +0 -1979
- package/dist/validators/quote-response.d.mts.map +0 -1
- package/dist/validators/quote-response.mjs +0 -112
- package/dist/validators/quote-response.mjs.map +0 -1
|
@@ -4,28 +4,28 @@ export declare enum ActionTypes {
|
|
|
4
4
|
REFUEL = "refuel"
|
|
5
5
|
}
|
|
6
6
|
export declare const StepSchema: import("@metamask/superstruct").Struct<{
|
|
7
|
-
srcChainId: number;
|
|
8
7
|
action: ActionTypes;
|
|
8
|
+
srcChainId: number;
|
|
9
9
|
destChainId?: number | undefined;
|
|
10
10
|
srcAsset?: {
|
|
11
11
|
symbol: string;
|
|
12
12
|
chainId: number;
|
|
13
|
-
|
|
13
|
+
address: string;
|
|
14
14
|
assetId: `${string}:${string}/${string}:${string}`;
|
|
15
|
+
name: string;
|
|
15
16
|
decimals: number;
|
|
16
|
-
address: string;
|
|
17
|
-
iconUrl?: string | null | undefined;
|
|
18
17
|
icon?: string | null | undefined;
|
|
18
|
+
iconUrl?: string | null | undefined;
|
|
19
19
|
} | undefined;
|
|
20
20
|
destAsset?: {
|
|
21
21
|
symbol: string;
|
|
22
22
|
chainId: number;
|
|
23
|
-
|
|
23
|
+
address: string;
|
|
24
24
|
assetId: `${string}:${string}/${string}:${string}`;
|
|
25
|
+
name: string;
|
|
25
26
|
decimals: number;
|
|
26
|
-
address: string;
|
|
27
|
-
iconUrl?: string | null | undefined;
|
|
28
27
|
icon?: string | null | undefined;
|
|
28
|
+
iconUrl?: string | null | undefined;
|
|
29
29
|
} | undefined;
|
|
30
30
|
}, {
|
|
31
31
|
action: import("@metamask/superstruct").Struct<ActionTypes, {
|
|
@@ -38,12 +38,12 @@ export declare const StepSchema: import("@metamask/superstruct").Struct<{
|
|
|
38
38
|
srcAsset: import("@metamask/superstruct").Struct<{
|
|
39
39
|
symbol: string;
|
|
40
40
|
chainId: number;
|
|
41
|
-
|
|
41
|
+
address: string;
|
|
42
42
|
assetId: `${string}:${string}/${string}:${string}`;
|
|
43
|
+
name: string;
|
|
43
44
|
decimals: number;
|
|
44
|
-
address: string;
|
|
45
|
-
iconUrl?: string | null | undefined;
|
|
46
45
|
icon?: string | null | undefined;
|
|
46
|
+
iconUrl?: string | null | undefined;
|
|
47
47
|
} | undefined, {
|
|
48
48
|
chainId: import("@metamask/superstruct").Struct<number, null>;
|
|
49
49
|
address: import("@metamask/superstruct").Struct<string, null>;
|
|
@@ -57,12 +57,12 @@ export declare const StepSchema: import("@metamask/superstruct").Struct<{
|
|
|
57
57
|
destAsset: import("@metamask/superstruct").Struct<{
|
|
58
58
|
symbol: string;
|
|
59
59
|
chainId: number;
|
|
60
|
-
|
|
60
|
+
address: string;
|
|
61
61
|
assetId: `${string}:${string}/${string}:${string}`;
|
|
62
|
+
name: string;
|
|
62
63
|
decimals: number;
|
|
63
|
-
address: string;
|
|
64
|
-
iconUrl?: string | null | undefined;
|
|
65
64
|
icon?: string | null | undefined;
|
|
65
|
+
iconUrl?: string | null | undefined;
|
|
66
66
|
} | undefined, {
|
|
67
67
|
chainId: import("@metamask/superstruct").Struct<number, null>;
|
|
68
68
|
address: import("@metamask/superstruct").Struct<string, null>;
|
|
@@ -75,28 +75,28 @@ export declare const StepSchema: import("@metamask/superstruct").Struct<{
|
|
|
75
75
|
}>;
|
|
76
76
|
}>;
|
|
77
77
|
export declare const RefuelDataSchema: import("@metamask/superstruct").Struct<{
|
|
78
|
-
srcChainId: number;
|
|
79
78
|
action: ActionTypes;
|
|
79
|
+
srcChainId: number;
|
|
80
80
|
destChainId?: number | undefined;
|
|
81
81
|
srcAsset?: {
|
|
82
82
|
symbol: string;
|
|
83
83
|
chainId: number;
|
|
84
|
-
|
|
84
|
+
address: string;
|
|
85
85
|
assetId: `${string}:${string}/${string}:${string}`;
|
|
86
|
+
name: string;
|
|
86
87
|
decimals: number;
|
|
87
|
-
address: string;
|
|
88
|
-
iconUrl?: string | null | undefined;
|
|
89
88
|
icon?: string | null | undefined;
|
|
89
|
+
iconUrl?: string | null | undefined;
|
|
90
90
|
} | undefined;
|
|
91
91
|
destAsset?: {
|
|
92
92
|
symbol: string;
|
|
93
93
|
chainId: number;
|
|
94
|
-
|
|
94
|
+
address: string;
|
|
95
95
|
assetId: `${string}:${string}/${string}:${string}`;
|
|
96
|
+
name: string;
|
|
96
97
|
decimals: number;
|
|
97
|
-
address: string;
|
|
98
|
-
iconUrl?: string | null | undefined;
|
|
99
98
|
icon?: string | null | undefined;
|
|
99
|
+
iconUrl?: string | null | undefined;
|
|
100
100
|
} | undefined;
|
|
101
101
|
}, {
|
|
102
102
|
action: import("@metamask/superstruct").Struct<ActionTypes, {
|
|
@@ -109,12 +109,12 @@ export declare const RefuelDataSchema: import("@metamask/superstruct").Struct<{
|
|
|
109
109
|
srcAsset: import("@metamask/superstruct").Struct<{
|
|
110
110
|
symbol: string;
|
|
111
111
|
chainId: number;
|
|
112
|
-
|
|
112
|
+
address: string;
|
|
113
113
|
assetId: `${string}:${string}/${string}:${string}`;
|
|
114
|
+
name: string;
|
|
114
115
|
decimals: number;
|
|
115
|
-
address: string;
|
|
116
|
-
iconUrl?: string | null | undefined;
|
|
117
116
|
icon?: string | null | undefined;
|
|
117
|
+
iconUrl?: string | null | undefined;
|
|
118
118
|
} | undefined, {
|
|
119
119
|
chainId: import("@metamask/superstruct").Struct<number, null>;
|
|
120
120
|
address: import("@metamask/superstruct").Struct<string, null>;
|
|
@@ -128,12 +128,12 @@ export declare const RefuelDataSchema: import("@metamask/superstruct").Struct<{
|
|
|
128
128
|
destAsset: import("@metamask/superstruct").Struct<{
|
|
129
129
|
symbol: string;
|
|
130
130
|
chainId: number;
|
|
131
|
-
|
|
131
|
+
address: string;
|
|
132
132
|
assetId: `${string}:${string}/${string}:${string}`;
|
|
133
|
+
name: string;
|
|
133
134
|
decimals: number;
|
|
134
|
-
address: string;
|
|
135
|
-
iconUrl?: string | null | undefined;
|
|
136
135
|
icon?: string | null | undefined;
|
|
136
|
+
iconUrl?: string | null | undefined;
|
|
137
137
|
} | undefined, {
|
|
138
138
|
chainId: import("@metamask/superstruct").Struct<number, null>;
|
|
139
139
|
address: import("@metamask/superstruct").Struct<string, null>;
|
|
@@ -145,175 +145,4 @@ export declare const RefuelDataSchema: import("@metamask/superstruct").Struct<{
|
|
|
145
145
|
iconUrl: import("@metamask/superstruct").Struct<string | null | undefined, null>;
|
|
146
146
|
}>;
|
|
147
147
|
}>;
|
|
148
|
-
export declare const StepSchemaV2: import("@metamask/superstruct").Struct<{
|
|
149
|
-
action: ActionTypes;
|
|
150
|
-
src: {
|
|
151
|
-
asset: {
|
|
152
|
-
symbol: string;
|
|
153
|
-
name: string;
|
|
154
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
155
|
-
decimals: number;
|
|
156
|
-
} & {
|
|
157
|
-
isVerified?: boolean | undefined;
|
|
158
|
-
securityData?: {
|
|
159
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
160
|
-
metadata?: {
|
|
161
|
-
features: {
|
|
162
|
-
featureId: string;
|
|
163
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
164
|
-
description: string;
|
|
165
|
-
}[];
|
|
166
|
-
} | undefined;
|
|
167
|
-
} | undefined;
|
|
168
|
-
} & {
|
|
169
|
-
iconUrl?: string | null | undefined;
|
|
170
|
-
noFee?: {
|
|
171
|
-
isDestination?: boolean | null | undefined;
|
|
172
|
-
isSource?: boolean | null | undefined;
|
|
173
|
-
} | undefined;
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
dest: {
|
|
177
|
-
asset: {
|
|
178
|
-
symbol: string;
|
|
179
|
-
name: string;
|
|
180
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
181
|
-
decimals: number;
|
|
182
|
-
} & {
|
|
183
|
-
isVerified?: boolean | undefined;
|
|
184
|
-
securityData?: {
|
|
185
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
186
|
-
metadata?: {
|
|
187
|
-
features: {
|
|
188
|
-
featureId: string;
|
|
189
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
190
|
-
description: string;
|
|
191
|
-
}[];
|
|
192
|
-
} | undefined;
|
|
193
|
-
} | undefined;
|
|
194
|
-
} & {
|
|
195
|
-
iconUrl?: string | null | undefined;
|
|
196
|
-
noFee?: {
|
|
197
|
-
isDestination?: boolean | null | undefined;
|
|
198
|
-
isSource?: boolean | null | undefined;
|
|
199
|
-
} | undefined;
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
}, {
|
|
203
|
-
action: import("@metamask/superstruct").Struct<ActionTypes, {
|
|
204
|
-
bridge: ActionTypes.BRIDGE;
|
|
205
|
-
swap: ActionTypes.SWAP;
|
|
206
|
-
refuel: ActionTypes.REFUEL;
|
|
207
|
-
}>;
|
|
208
|
-
src: import("@metamask/superstruct").Struct<{
|
|
209
|
-
asset: {
|
|
210
|
-
symbol: string;
|
|
211
|
-
name: string;
|
|
212
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
213
|
-
decimals: number;
|
|
214
|
-
} & {
|
|
215
|
-
isVerified?: boolean | undefined;
|
|
216
|
-
securityData?: {
|
|
217
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
218
|
-
metadata?: {
|
|
219
|
-
features: {
|
|
220
|
-
featureId: string;
|
|
221
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
222
|
-
description: string;
|
|
223
|
-
}[];
|
|
224
|
-
} | undefined;
|
|
225
|
-
} | undefined;
|
|
226
|
-
} & {
|
|
227
|
-
iconUrl?: string | null | undefined;
|
|
228
|
-
noFee?: {
|
|
229
|
-
isDestination?: boolean | null | undefined;
|
|
230
|
-
isSource?: boolean | null | undefined;
|
|
231
|
-
} | undefined;
|
|
232
|
-
};
|
|
233
|
-
}, Pick<{
|
|
234
|
-
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
235
|
-
normalizedAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
236
|
-
asset: import("@metamask/superstruct").Struct<{
|
|
237
|
-
symbol: string;
|
|
238
|
-
name: string;
|
|
239
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
240
|
-
decimals: number;
|
|
241
|
-
} & {
|
|
242
|
-
isVerified?: boolean | undefined;
|
|
243
|
-
securityData?: {
|
|
244
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
245
|
-
metadata?: {
|
|
246
|
-
features: {
|
|
247
|
-
featureId: string;
|
|
248
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
249
|
-
description: string;
|
|
250
|
-
}[];
|
|
251
|
-
} | undefined;
|
|
252
|
-
} | undefined;
|
|
253
|
-
} & {
|
|
254
|
-
iconUrl?: string | null | undefined;
|
|
255
|
-
noFee?: {
|
|
256
|
-
isDestination?: boolean | null | undefined;
|
|
257
|
-
isSource?: boolean | null | undefined;
|
|
258
|
-
} | undefined;
|
|
259
|
-
}, null>;
|
|
260
|
-
usd: import("@metamask/superstruct").Struct<string | null | undefined, null>;
|
|
261
|
-
valueInCurrency: import("@metamask/superstruct").Struct<string | null | undefined, null>;
|
|
262
|
-
}, "asset">>;
|
|
263
|
-
dest: import("@metamask/superstruct").Struct<{
|
|
264
|
-
asset: {
|
|
265
|
-
symbol: string;
|
|
266
|
-
name: string;
|
|
267
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
268
|
-
decimals: number;
|
|
269
|
-
} & {
|
|
270
|
-
isVerified?: boolean | undefined;
|
|
271
|
-
securityData?: {
|
|
272
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
273
|
-
metadata?: {
|
|
274
|
-
features: {
|
|
275
|
-
featureId: string;
|
|
276
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
277
|
-
description: string;
|
|
278
|
-
}[];
|
|
279
|
-
} | undefined;
|
|
280
|
-
} | undefined;
|
|
281
|
-
} & {
|
|
282
|
-
iconUrl?: string | null | undefined;
|
|
283
|
-
noFee?: {
|
|
284
|
-
isDestination?: boolean | null | undefined;
|
|
285
|
-
isSource?: boolean | null | undefined;
|
|
286
|
-
} | undefined;
|
|
287
|
-
};
|
|
288
|
-
}, Pick<{
|
|
289
|
-
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
290
|
-
normalizedAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
291
|
-
asset: import("@metamask/superstruct").Struct<{
|
|
292
|
-
symbol: string;
|
|
293
|
-
name: string;
|
|
294
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
295
|
-
decimals: number;
|
|
296
|
-
} & {
|
|
297
|
-
isVerified?: boolean | undefined;
|
|
298
|
-
securityData?: {
|
|
299
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
300
|
-
metadata?: {
|
|
301
|
-
features: {
|
|
302
|
-
featureId: string;
|
|
303
|
-
type: import("./bridge-asset.mjs").BridgeAssetSecurityDataType;
|
|
304
|
-
description: string;
|
|
305
|
-
}[];
|
|
306
|
-
} | undefined;
|
|
307
|
-
} | undefined;
|
|
308
|
-
} & {
|
|
309
|
-
iconUrl?: string | null | undefined;
|
|
310
|
-
noFee?: {
|
|
311
|
-
isDestination?: boolean | null | undefined;
|
|
312
|
-
isSource?: boolean | null | undefined;
|
|
313
|
-
} | undefined;
|
|
314
|
-
}, null>;
|
|
315
|
-
usd: import("@metamask/superstruct").Struct<string | null | undefined, null>;
|
|
316
|
-
valueInCurrency: import("@metamask/superstruct").Struct<string | null | undefined, null>;
|
|
317
|
-
}, "asset">>;
|
|
318
|
-
}>;
|
|
319
148
|
//# sourceMappingURL=step.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.mts","sourceRoot":"","sources":["../../src/validators/step.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"step.d.mts","sourceRoot":"","sources":["../../src/validators/step.ts"],"names":[],"mappings":"AAIA,oBAAY,WAAW;IACrB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMrB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAa,CAAC"}
|
package/dist/validators/step.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type, enums, optional
|
|
2
|
-
import { AmountsAndAssetSchema } from "./amount-and-asset.mjs";
|
|
1
|
+
import { type, enums, optional } from "@metamask/superstruct";
|
|
3
2
|
import { BridgeAssetSchema, ChainIdSchema } from "./bridge-asset.mjs";
|
|
4
3
|
export var ActionTypes;
|
|
5
4
|
(function (ActionTypes) {
|
|
@@ -15,9 +14,4 @@ export const StepSchema = type({
|
|
|
15
14
|
destAsset: optional(BridgeAssetSchema),
|
|
16
15
|
});
|
|
17
16
|
export const RefuelDataSchema = StepSchema;
|
|
18
|
-
export const StepSchemaV2 = type({
|
|
19
|
-
action: enums(Object.values(ActionTypes)),
|
|
20
|
-
src: pick(AmountsAndAssetSchema, ['asset']),
|
|
21
|
-
dest: pick(AmountsAndAssetSchema, ['asset']),
|
|
22
|
-
});
|
|
23
17
|
//# sourceMappingURL=step.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.mjs","sourceRoot":"","sources":["../../src/validators/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"step.mjs","sourceRoot":"","sources":["../../src/validators/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,8BAA8B;AAE9D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,2BAAuB;AAElE,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACzC,UAAU,EAAE,aAAa;IACzB,WAAW,EAAE,QAAQ,CAAC,aAAa,CAAC;IACpC,QAAQ,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IACrC,SAAS,EAAE,QAAQ,CAAC,iBAAiB,CAAC;CACvC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC","sourcesContent":["import { type, enums, optional } from '@metamask/superstruct';\n\nimport { BridgeAssetSchema, ChainIdSchema } from './bridge-asset';\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nexport const StepSchema = type({\n action: enums(Object.values(ActionTypes)),\n srcChainId: ChainIdSchema,\n destChainId: optional(ChainIdSchema),\n srcAsset: optional(BridgeAssetSchema),\n destAsset: optional(BridgeAssetSchema),\n});\n\nexport const RefuelDataSchema = StepSchema;\n"]}
|
|
@@ -6,8 +6,8 @@ export declare enum TokenFeatureType {
|
|
|
6
6
|
}
|
|
7
7
|
export declare const TokenFeatureSchema: import("@metamask/superstruct").Struct<{
|
|
8
8
|
type: TokenFeatureType;
|
|
9
|
-
description: string;
|
|
10
9
|
feature_id: string;
|
|
10
|
+
description: string;
|
|
11
11
|
}, {
|
|
12
12
|
feature_id: import("@metamask/superstruct").Struct<string, null>;
|
|
13
13
|
type: import("@metamask/superstruct").Struct<TokenFeatureType, {
|
|
@@ -20,7 +20,7 @@ export declare const TokenFeatureSchema: import("@metamask/superstruct").Struct<
|
|
|
20
20
|
}>;
|
|
21
21
|
export declare const validateTokenFeature: (data: unknown) => data is {
|
|
22
22
|
type: TokenFeatureType;
|
|
23
|
-
description: string;
|
|
24
23
|
feature_id: string;
|
|
24
|
+
description: string;
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=token-feature.d.cts.map
|
|
@@ -6,8 +6,8 @@ export declare enum TokenFeatureType {
|
|
|
6
6
|
}
|
|
7
7
|
export declare const TokenFeatureSchema: import("@metamask/superstruct").Struct<{
|
|
8
8
|
type: TokenFeatureType;
|
|
9
|
-
description: string;
|
|
10
9
|
feature_id: string;
|
|
10
|
+
description: string;
|
|
11
11
|
}, {
|
|
12
12
|
feature_id: import("@metamask/superstruct").Struct<string, null>;
|
|
13
13
|
type: import("@metamask/superstruct").Struct<TokenFeatureType, {
|
|
@@ -20,7 +20,7 @@ export declare const TokenFeatureSchema: import("@metamask/superstruct").Struct<
|
|
|
20
20
|
}>;
|
|
21
21
|
export declare const validateTokenFeature: (data: unknown) => data is {
|
|
22
22
|
type: TokenFeatureType;
|
|
23
|
-
description: string;
|
|
24
23
|
feature_id: string;
|
|
24
|
+
description: string;
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=token-feature.d.mts.map
|
|
@@ -2,8 +2,8 @@ import type { Infer } from "@metamask/superstruct";
|
|
|
2
2
|
export declare const HexString: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
3
3
|
export declare const TxDataSchema: import("@metamask/superstruct").Struct<{
|
|
4
4
|
chainId: number;
|
|
5
|
-
from: `0x${string}`;
|
|
6
5
|
to: `0x${string}`;
|
|
6
|
+
from: `0x${string}`;
|
|
7
7
|
value: `0x${string}`;
|
|
8
8
|
data: `0x${string}`;
|
|
9
9
|
gasLimit: number | null;
|
|
@@ -69,8 +69,8 @@ export type Trade = TxData | string | BitcoinTradeData | TronTradeData | Stellar
|
|
|
69
69
|
*/
|
|
70
70
|
export declare const isEvmTxData: (trade: Trade) => trade is {
|
|
71
71
|
chainId: number;
|
|
72
|
-
from: `0x${string}`;
|
|
73
72
|
to: `0x${string}`;
|
|
73
|
+
from: `0x${string}`;
|
|
74
74
|
value: `0x${string}`;
|
|
75
75
|
data: `0x${string}`;
|
|
76
76
|
gasLimit: number | null;
|
|
@@ -2,8 +2,8 @@ import type { Infer } from "@metamask/superstruct";
|
|
|
2
2
|
export declare const HexString: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
3
3
|
export declare const TxDataSchema: import("@metamask/superstruct").Struct<{
|
|
4
4
|
chainId: number;
|
|
5
|
-
from: `0x${string}`;
|
|
6
5
|
to: `0x${string}`;
|
|
6
|
+
from: `0x${string}`;
|
|
7
7
|
value: `0x${string}`;
|
|
8
8
|
data: `0x${string}`;
|
|
9
9
|
gasLimit: number | null;
|
|
@@ -69,8 +69,8 @@ export type Trade = TxData | string | BitcoinTradeData | TronTradeData | Stellar
|
|
|
69
69
|
*/
|
|
70
70
|
export declare const isEvmTxData: (trade: Trade) => trade is {
|
|
71
71
|
chainId: number;
|
|
72
|
-
from: `0x${string}`;
|
|
73
72
|
to: `0x${string}`;
|
|
73
|
+
from: `0x${string}`;
|
|
74
74
|
value: `0x${string}`;
|
|
75
75
|
data: `0x${string}`;
|
|
76
76
|
gasLimit: number | null;
|
package/package.json
CHANGED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toQuoteResponseV2 = exports.toBridgeAssetV2 = void 0;
|
|
4
|
-
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
-
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
7
|
-
const caip_formatters_1 = require("../utils/caip-formatters.cjs");
|
|
8
|
-
const bridge_asset_1 = require("../validators/bridge-asset.cjs");
|
|
9
|
-
const quote_1 = require("../validators/quote.cjs");
|
|
10
|
-
const quote_response_1 = require("../validators/quote-response.cjs");
|
|
11
|
-
const quote_response_v1_1 = require("../validators/quote-response-v1.cjs");
|
|
12
|
-
const step_1 = require("../validators/step.cjs");
|
|
13
|
-
const BridgeAssetV2FromV1 = (0, superstruct_1.coerce)(bridge_asset_1.BridgeAssetV2Schema, (0, superstruct_1.intersection)([bridge_asset_1.BridgeAssetSchema, bridge_asset_1.MinimalAssetSchema]), (value) => {
|
|
14
|
-
const { chainId, address,
|
|
15
|
-
// @ts-expect-error - chainAgnosticId is not in the schema
|
|
16
|
-
chainAgnosticId,
|
|
17
|
-
// @ts-expect-error - logoURI is not in the schema
|
|
18
|
-
logoURI, iconUrl, icon, assetId, ...rest } = value;
|
|
19
|
-
const resolvedIconUrl = iconUrl ?? logoURI ?? icon;
|
|
20
|
-
return {
|
|
21
|
-
assetId: assetId ??
|
|
22
|
-
/* istanbul ignore next */ (0, caip_formatters_1.formatAddressToAssetId)(address, chainId),
|
|
23
|
-
...(resolvedIconUrl && { iconUrl: resolvedIconUrl }),
|
|
24
|
-
...rest,
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
const toBridgeAssetV2 = (data) => {
|
|
28
|
-
return (0, superstruct_1.create)(data, BridgeAssetV2FromV1);
|
|
29
|
-
};
|
|
30
|
-
exports.toBridgeAssetV2 = toBridgeAssetV2;
|
|
31
|
-
const StepSchemaV2FromV1 = (0, superstruct_1.coerce)(step_1.StepSchemaV2, step_1.StepSchema, (value) => {
|
|
32
|
-
const { srcAsset, destAsset, action } = value;
|
|
33
|
-
return {
|
|
34
|
-
action,
|
|
35
|
-
src: {
|
|
36
|
-
asset: (0, exports.toBridgeAssetV2)(srcAsset),
|
|
37
|
-
},
|
|
38
|
-
dest: {
|
|
39
|
-
asset: (0, exports.toBridgeAssetV2)(destAsset),
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
const toStepV2 = (step) => (0, superstruct_1.create)(step, StepSchemaV2FromV1);
|
|
44
|
-
const QuoteV2FromV1 = (0, superstruct_1.coerce)(quote_1.QuoteSchemaV2, quote_1.QuoteSchema, (value) => {
|
|
45
|
-
const { srcTokenAmount, destTokenAmount, minDestTokenAmount, srcAsset, destAsset, srcChainId, destChainId, walletAddress, destWalletAddress, priceData, feeData, bridgeId, bridges, steps, intent, ...restQuote } = value;
|
|
46
|
-
return {
|
|
47
|
-
src: {
|
|
48
|
-
amount: new bignumber_js_1.BigNumber(srcTokenAmount)
|
|
49
|
-
.plus(intent ? 0 : feeData[quote_1.FeeType.METABRIDGE].amount)
|
|
50
|
-
.toFixed(),
|
|
51
|
-
asset: (0, exports.toBridgeAssetV2)(srcAsset),
|
|
52
|
-
...(walletAddress && { walletAddress }),
|
|
53
|
-
},
|
|
54
|
-
dest: {
|
|
55
|
-
amount: destTokenAmount,
|
|
56
|
-
asset: (0, exports.toBridgeAssetV2)(destAsset),
|
|
57
|
-
...(destWalletAddress && { walletAddress: destWalletAddress }),
|
|
58
|
-
minAmount: minDestTokenAmount,
|
|
59
|
-
},
|
|
60
|
-
priceData: {
|
|
61
|
-
...(value.priceData?.priceImpact && {
|
|
62
|
-
priceImpact: {
|
|
63
|
-
amount: value.priceData?.priceImpact,
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
},
|
|
67
|
-
feeData: {
|
|
68
|
-
[quote_1.FeeType.METABRIDGE]: [
|
|
69
|
-
{
|
|
70
|
-
...feeData[quote_1.FeeType.METABRIDGE],
|
|
71
|
-
asset: (0, exports.toBridgeAssetV2)(feeData[quote_1.FeeType.METABRIDGE].asset),
|
|
72
|
-
...(priceData?.totalFeeAmountUsd && /* istanbul ignore next */ {
|
|
73
|
-
usd: priceData?.totalFeeAmountUsd,
|
|
74
|
-
}),
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
...(feeData[quote_1.FeeType.TX_FEE] && {
|
|
78
|
-
[quote_1.FeeType.TX_FEE]: [
|
|
79
|
-
{
|
|
80
|
-
...feeData[quote_1.FeeType.TX_FEE],
|
|
81
|
-
asset: (0, exports.toBridgeAssetV2)(feeData[quote_1.FeeType.TX_FEE].asset),
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
}),
|
|
85
|
-
},
|
|
86
|
-
steps: steps?.map(toStepV2),
|
|
87
|
-
...restQuote,
|
|
88
|
-
protocols: bridges,
|
|
89
|
-
aggregator: bridgeId,
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
const toQuoteV2 = (quote) => {
|
|
93
|
-
const quoteV2 = (0, superstruct_1.create)(quote, QuoteV2FromV1);
|
|
94
|
-
return quoteV2;
|
|
95
|
-
};
|
|
96
|
-
const QuoteResponseV2FromV1 = (0, superstruct_1.coerce)(quote_response_1.QuoteResponseSchemaV2, quote_response_v1_1.QuoteResponseSchemaV1, (value) => {
|
|
97
|
-
const { quote, l1GasFeesInHexWei, nonEvmFeesInNative, ...rest } = value;
|
|
98
|
-
const { srcAsset } = quote;
|
|
99
|
-
const { chain: { namespace }, chainId, } = (0, utils_1.parseCaipAssetType)(srcAsset.assetId);
|
|
100
|
-
return {
|
|
101
|
-
...rest,
|
|
102
|
-
...(nonEvmFeesInNative && { nonEvmFeesInNative }),
|
|
103
|
-
...(l1GasFeesInHexWei && { l1GasFeesInHexWei }),
|
|
104
|
-
namespace,
|
|
105
|
-
chainId,
|
|
106
|
-
quote: toQuoteV2(quote),
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
/**
|
|
110
|
-
* Converts a partial quote response to a {@link QuoteResponse}.
|
|
111
|
-
* This does not preserve any post-fetch metadata.
|
|
112
|
-
*
|
|
113
|
-
* @param quoteResponse - The {@link QuoteResponseV1} to convert
|
|
114
|
-
* @returns The {@link QuoteResponse}
|
|
115
|
-
*/
|
|
116
|
-
function toQuoteResponseV2(quoteResponse) {
|
|
117
|
-
let quoteResponseV2 = null;
|
|
118
|
-
// V1 quote
|
|
119
|
-
/* istanbul ignore else */
|
|
120
|
-
if ((0, superstruct_1.is)(quoteResponse, quote_response_v1_1.QuoteResponseSchemaV1)) {
|
|
121
|
-
quoteResponseV2 = (0, superstruct_1.create)(quoteResponse, QuoteResponseV2FromV1);
|
|
122
|
-
}
|
|
123
|
-
// V2 quote
|
|
124
|
-
else if ((0, quote_response_1.validateQuoteResponse)(quoteResponse)) {
|
|
125
|
-
quoteResponseV2 = quoteResponse;
|
|
126
|
-
}
|
|
127
|
-
/* istanbul ignore else */
|
|
128
|
-
if (quoteResponseV2) {
|
|
129
|
-
const { chain: { namespace }, chainId, } = (0, utils_1.parseCaipAssetType)(quoteResponseV2.quote.src.asset.assetId);
|
|
130
|
-
// Add namespace, chainId
|
|
131
|
-
return { ...quoteResponseV2, namespace: namespace, chainId };
|
|
132
|
-
}
|
|
133
|
-
/* istanbul ignore next */
|
|
134
|
-
throw new Error('QuoteResponseV1 to V2 conversion failed');
|
|
135
|
-
}
|
|
136
|
-
exports.toQuoteResponseV2 = toQuoteResponseV2;
|
|
137
|
-
//# sourceMappingURL=quote-response-v1-to-v2.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote-response-v1-to-v2.cjs","sourceRoot":"","sources":["../../src/coercers/quote-response-v1-to-v2.ts"],"names":[],"mappings":";;;AAAA,uDAAgF;AAChF,2CAAqD;AACrD,+CAAyC;AAEzC,kEAAkE;AAClE,iEAIoC;AACpC,mDAA0E;AAC1E,qEAGsC;AAEtC,2EAAwE;AAExE,iDAA8D;AAE9D,MAAM,mBAAmB,GAAG,IAAA,oBAAM,EAChC,kCAAmB,EACnB,IAAA,0BAAY,EAAC,CAAC,gCAAiB,EAAE,iCAAkB,CAAC,CAAC,EACrD,CAAC,KAAK,EAAE,EAAE;IACR,MAAM,EACJ,OAAO,EACP,OAAO;IACP,0DAA0D;IAC1D,eAAe;IACf,kDAAkD;IAClD,OAAO,E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AAa,EAAE,yCAAqB,CAAC,EAAE,CAAC;QAC7C,eAAe,GAAG,IAAA,oBAAM,EAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;IACjE,CAAC;IACD,WAAW;SACN,IAAI,IAAA,sCAAqB,EAAC,aAAa,CAAC,EAAE,CAAC;QAC9C,eAAe,GAAG,aAAa,CAAC;IAClC,CAAC;IAED,0BAA0B;IAC1B,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,EACJ,KAAK,EAAE,EAAE,SAAS,EAAE,EACpB,OAAO,GACR,GAAG,IAAA,0BAAkB,EAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEhE,yBAAyB;QACzB,OAAO,EAAE,GAAG,eAAe,EAAE,SAAS,EAAE,SAAkB,EAAE,OAAO,EAAE,CAAC;IACxE,CAAC;IAED,0BAA0B;IAC1B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC7D,CAAC;AA1BD,8CA0BC","sourcesContent":["import { create, coerce, Infer, is, intersection } from '@metamask/superstruct';\nimport { parseCaipAssetType } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { formatAddressToAssetId } from '../utils/caip-formatters';\nimport {\n BridgeAssetSchema,\n BridgeAssetV2Schema,\n MinimalAssetSchema,\n} from '../validators/bridge-asset';\nimport { QuoteSchemaV2, FeeType, QuoteSchema } from '../validators/quote';\nimport {\n QuoteResponseSchemaV2,\n validateQuoteResponse,\n} from '../validators/quote-response';\nimport type { QuoteResponse } from '../validators/quote-response';\nimport { QuoteResponseSchemaV1 } from '../validators/quote-response-v1';\nimport type { QuoteResponseV1 } from '../validators/quote-response-v1';\nimport { StepSchemaV2, StepSchema } from '../validators/step';\n\nconst BridgeAssetV2FromV1 = coerce(\n BridgeAssetV2Schema,\n intersection([BridgeAssetSchema, MinimalAssetSchema]),\n (value) => {\n const {\n chainId,\n address,\n // @ts-expect-error - chainAgnosticId is not in the schema\n chainAgnosticId,\n // @ts-expect-error - logoURI is not in the schema\n logoURI,\n iconUrl,\n icon,\n assetId,\n ...rest\n } = value;\n\n const resolvedIconUrl = iconUrl ?? logoURI ?? icon;\n\n return {\n assetId:\n assetId ??\n /* istanbul ignore next */ formatAddressToAssetId(address, chainId),\n ...(resolvedIconUrl && { iconUrl: resolvedIconUrl }),\n ...rest,\n };\n },\n);\n\nexport const toBridgeAssetV2 = (\n data: unknown,\n): Infer<typeof BridgeAssetV2Schema> => {\n return create(data, BridgeAssetV2FromV1);\n};\n\nconst StepSchemaV2FromV1 = coerce(StepSchemaV2, StepSchema, (value) => {\n const { srcAsset, destAsset, action } = value;\n return {\n action,\n src: {\n asset: toBridgeAssetV2(srcAsset),\n },\n dest: {\n asset: toBridgeAssetV2(destAsset),\n },\n };\n});\nconst toStepV2 = (step: unknown): Infer<typeof StepSchemaV2> =>\n create(step, StepSchemaV2FromV1);\n\nconst QuoteV2FromV1 = coerce(QuoteSchemaV2, QuoteSchema, (value) => {\n const {\n srcTokenAmount,\n destTokenAmount,\n minDestTokenAmount,\n srcAsset,\n destAsset,\n srcChainId,\n destChainId,\n walletAddress,\n destWalletAddress,\n priceData,\n feeData,\n bridgeId,\n bridges,\n steps,\n intent,\n ...restQuote\n } = value;\n\n return {\n src: {\n amount: new BigNumber(srcTokenAmount)\n .plus(intent ? 0 : feeData[FeeType.METABRIDGE].amount)\n .toFixed(),\n asset: toBridgeAssetV2(srcAsset),\n ...(walletAddress && { walletAddress }),\n },\n dest: {\n amount: destTokenAmount,\n asset: toBridgeAssetV2(destAsset),\n ...(destWalletAddress && { walletAddress: destWalletAddress }),\n minAmount: minDestTokenAmount,\n },\n priceData: {\n ...(value.priceData?.priceImpact && {\n priceImpact: {\n amount: value.priceData?.priceImpact,\n },\n }),\n },\n feeData: {\n [FeeType.METABRIDGE]: [\n {\n ...feeData[FeeType.METABRIDGE],\n asset: toBridgeAssetV2(feeData[FeeType.METABRIDGE].asset),\n ...(priceData?.totalFeeAmountUsd && /* istanbul ignore next */ {\n usd: priceData?.totalFeeAmountUsd,\n }),\n },\n ],\n ...(feeData[FeeType.TX_FEE] && {\n [FeeType.TX_FEE]: [\n {\n ...feeData[FeeType.TX_FEE],\n asset: toBridgeAssetV2(feeData[FeeType.TX_FEE].asset),\n },\n ],\n }),\n },\n steps: steps?.map(toStepV2),\n ...restQuote,\n protocols: bridges,\n aggregator: bridgeId,\n };\n});\n\nconst toQuoteV2 = (quote: unknown): Infer<typeof QuoteSchemaV2> => {\n const quoteV2 = create(quote, QuoteV2FromV1);\n return quoteV2;\n};\n\nconst QuoteResponseV2FromV1 = coerce(\n QuoteResponseSchemaV2,\n QuoteResponseSchemaV1,\n (value: QuoteResponseV1) => {\n const { quote, l1GasFeesInHexWei, nonEvmFeesInNative, ...rest } = value;\n const { srcAsset } = quote;\n\n const {\n chain: { namespace },\n chainId,\n } = parseCaipAssetType(srcAsset.assetId);\n\n return {\n ...rest,\n ...(nonEvmFeesInNative && { nonEvmFeesInNative }),\n ...(l1GasFeesInHexWei && { l1GasFeesInHexWei }),\n namespace,\n chainId,\n quote: toQuoteV2(quote),\n };\n },\n);\n\n/**\n * Converts a partial quote response to a {@link QuoteResponse}.\n * This does not preserve any post-fetch metadata.\n *\n * @param quoteResponse - The {@link QuoteResponseV1} to convert\n * @returns The {@link QuoteResponse}\n */\nexport function toQuoteResponseV2(quoteResponse: unknown): QuoteResponse {\n let quoteResponseV2: QuoteResponse | null = null;\n\n // V1 quote\n /* istanbul ignore else */\n if (is(quoteResponse, QuoteResponseSchemaV1)) {\n quoteResponseV2 = create(quoteResponse, QuoteResponseV2FromV1);\n }\n // V2 quote\n else if (validateQuoteResponse(quoteResponse)) {\n quoteResponseV2 = quoteResponse;\n }\n\n /* istanbul ignore else */\n if (quoteResponseV2) {\n const {\n chain: { namespace },\n chainId,\n } = parseCaipAssetType(quoteResponseV2.quote.src.asset.assetId);\n\n // Add namespace, chainId\n return { ...quoteResponseV2, namespace: namespace as never, chainId };\n }\n\n /* istanbul ignore next */\n throw new Error('QuoteResponseV1 to V2 conversion failed');\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Infer } from "@metamask/superstruct";
|
|
2
|
-
import { BridgeAssetV2Schema } from "../validators/bridge-asset.cjs";
|
|
3
|
-
import type { QuoteResponse } from "../validators/quote-response.cjs";
|
|
4
|
-
export declare const toBridgeAssetV2: (data: unknown) => Infer<typeof BridgeAssetV2Schema>;
|
|
5
|
-
/**
|
|
6
|
-
* Converts a partial quote response to a {@link QuoteResponse}.
|
|
7
|
-
* This does not preserve any post-fetch metadata.
|
|
8
|
-
*
|
|
9
|
-
* @param quoteResponse - The {@link QuoteResponseV1} to convert
|
|
10
|
-
* @returns The {@link QuoteResponse}
|
|
11
|
-
*/
|
|
12
|
-
export declare function toQuoteResponseV2(quoteResponse: unknown): QuoteResponse;
|
|
13
|
-
//# sourceMappingURL=quote-response-v1-to-v2.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote-response-v1-to-v2.d.cts","sourceRoot":"","sources":["../../src/coercers/quote-response-v1-to-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,EAAoB,8BAA8B;AAKhF,OAAO,EAEL,mBAAmB,EAEpB,uCAAmC;AAMpC,OAAO,KAAK,EAAE,aAAa,EAAE,yCAAqC;AAkClE,eAAO,MAAM,eAAe,SACpB,OAAO,KACZ,MAAM,0BAA0B,CAElC,CAAC;AAgHF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,OAAO,GAAG,aAAa,CA0BvE"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Infer } from "@metamask/superstruct";
|
|
2
|
-
import { BridgeAssetV2Schema } from "../validators/bridge-asset.mjs";
|
|
3
|
-
import type { QuoteResponse } from "../validators/quote-response.mjs";
|
|
4
|
-
export declare const toBridgeAssetV2: (data: unknown) => Infer<typeof BridgeAssetV2Schema>;
|
|
5
|
-
/**
|
|
6
|
-
* Converts a partial quote response to a {@link QuoteResponse}.
|
|
7
|
-
* This does not preserve any post-fetch metadata.
|
|
8
|
-
*
|
|
9
|
-
* @param quoteResponse - The {@link QuoteResponseV1} to convert
|
|
10
|
-
* @returns The {@link QuoteResponse}
|
|
11
|
-
*/
|
|
12
|
-
export declare function toQuoteResponseV2(quoteResponse: unknown): QuoteResponse;
|
|
13
|
-
//# sourceMappingURL=quote-response-v1-to-v2.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote-response-v1-to-v2.d.mts","sourceRoot":"","sources":["../../src/coercers/quote-response-v1-to-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,EAAoB,8BAA8B;AAKhF,OAAO,EAEL,mBAAmB,EAEpB,uCAAmC;AAMpC,OAAO,KAAK,EAAE,aAAa,EAAE,yCAAqC;AAkClE,eAAO,MAAM,eAAe,SACpB,OAAO,KACZ,MAAM,0BAA0B,CAElC,CAAC;AAgHF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,OAAO,GAAG,aAAa,CA0BvE"}
|