@metamask-previews/bridge-controller 64.1.0-preview-cb4a07d5 → 64.1.0-preview-565dfca2
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 +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.d.cts +1836 -354
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +1836 -354
- package/dist/selectors.d.mts.map +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +4 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +4 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/bridge.d.cts +2 -2
- package/dist/utils/bridge.d.mts +2 -2
- package/dist/utils/trade-utils.d.cts +1 -1
- package/dist/utils/trade-utils.d.mts +1 -1
- package/dist/utils/validators.cjs +30 -1
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +281 -7
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +281 -7
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +29 -0
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Infer } from "@metamask/superstruct";
|
|
1
2
|
export declare enum FeeType {
|
|
2
3
|
METABRIDGE = "metabridge",
|
|
3
4
|
REFUEL = "refuel",
|
|
@@ -433,6 +434,93 @@ export declare const StepSchema: import("@metamask/superstruct").Struct<{
|
|
|
433
434
|
icon: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
434
435
|
}>;
|
|
435
436
|
}>;
|
|
437
|
+
export declare const IntentOrderSchema: import("@metamask/superstruct").Struct<{
|
|
438
|
+
sellToken: string;
|
|
439
|
+
buyToken: string;
|
|
440
|
+
validTo: string | number;
|
|
441
|
+
appData: string;
|
|
442
|
+
appDataHash: string;
|
|
443
|
+
feeAmount: string;
|
|
444
|
+
kind: "sell" | "buy";
|
|
445
|
+
partiallyFillable: boolean;
|
|
446
|
+
receiver?: string | undefined;
|
|
447
|
+
sellAmount?: string | undefined;
|
|
448
|
+
buyAmount?: string | undefined;
|
|
449
|
+
from?: string | undefined;
|
|
450
|
+
}, {
|
|
451
|
+
sellToken: import("@metamask/superstruct").Struct<string, null>;
|
|
452
|
+
buyToken: import("@metamask/superstruct").Struct<string, null>;
|
|
453
|
+
receiver: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
454
|
+
validTo: import("@metamask/superstruct").Struct<string | number, null>;
|
|
455
|
+
appData: import("@metamask/superstruct").Struct<string, null>;
|
|
456
|
+
appDataHash: import("@metamask/superstruct").Struct<string, null>;
|
|
457
|
+
feeAmount: import("@metamask/superstruct").Struct<string, null>;
|
|
458
|
+
kind: import("@metamask/superstruct").Struct<"sell" | "buy", {
|
|
459
|
+
sell: "sell";
|
|
460
|
+
buy: "buy";
|
|
461
|
+
}>;
|
|
462
|
+
partiallyFillable: import("@metamask/superstruct").Struct<boolean, null>;
|
|
463
|
+
sellAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
464
|
+
buyAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
465
|
+
from: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
466
|
+
}>;
|
|
467
|
+
export declare const IntentSchema: import("@metamask/superstruct").Struct<{
|
|
468
|
+
protocol: "cowswap";
|
|
469
|
+
order: {
|
|
470
|
+
sellToken: string;
|
|
471
|
+
buyToken: string;
|
|
472
|
+
validTo: string | number;
|
|
473
|
+
appData: string;
|
|
474
|
+
appDataHash: string;
|
|
475
|
+
feeAmount: string;
|
|
476
|
+
kind: "sell" | "buy";
|
|
477
|
+
partiallyFillable: boolean;
|
|
478
|
+
receiver?: string | undefined;
|
|
479
|
+
sellAmount?: string | undefined;
|
|
480
|
+
buyAmount?: string | undefined;
|
|
481
|
+
from?: string | undefined;
|
|
482
|
+
};
|
|
483
|
+
settlementContract?: string | undefined;
|
|
484
|
+
relayer?: string | undefined;
|
|
485
|
+
}, {
|
|
486
|
+
protocol: import("@metamask/superstruct").Struct<"cowswap", {
|
|
487
|
+
cowswap: "cowswap";
|
|
488
|
+
}>;
|
|
489
|
+
order: import("@metamask/superstruct").Struct<{
|
|
490
|
+
sellToken: string;
|
|
491
|
+
buyToken: string;
|
|
492
|
+
validTo: string | number;
|
|
493
|
+
appData: string;
|
|
494
|
+
appDataHash: string;
|
|
495
|
+
feeAmount: string;
|
|
496
|
+
kind: "sell" | "buy";
|
|
497
|
+
partiallyFillable: boolean;
|
|
498
|
+
receiver?: string | undefined;
|
|
499
|
+
sellAmount?: string | undefined;
|
|
500
|
+
buyAmount?: string | undefined;
|
|
501
|
+
from?: string | undefined;
|
|
502
|
+
}, {
|
|
503
|
+
sellToken: import("@metamask/superstruct").Struct<string, null>;
|
|
504
|
+
buyToken: import("@metamask/superstruct").Struct<string, null>;
|
|
505
|
+
receiver: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
506
|
+
validTo: import("@metamask/superstruct").Struct<string | number, null>;
|
|
507
|
+
appData: import("@metamask/superstruct").Struct<string, null>;
|
|
508
|
+
appDataHash: import("@metamask/superstruct").Struct<string, null>;
|
|
509
|
+
feeAmount: import("@metamask/superstruct").Struct<string, null>;
|
|
510
|
+
kind: import("@metamask/superstruct").Struct<"sell" | "buy", {
|
|
511
|
+
sell: "sell";
|
|
512
|
+
buy: "buy";
|
|
513
|
+
}>;
|
|
514
|
+
partiallyFillable: import("@metamask/superstruct").Struct<boolean, null>;
|
|
515
|
+
sellAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
516
|
+
buyAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
517
|
+
from: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
518
|
+
}>;
|
|
519
|
+
settlementContract: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
520
|
+
relayer: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
521
|
+
}>;
|
|
522
|
+
export type IntentOrder = Infer<typeof IntentOrderSchema>;
|
|
523
|
+
export type Intent = Infer<typeof IntentSchema>;
|
|
436
524
|
export declare const QuoteSchema: import("@metamask/superstruct").Struct<{
|
|
437
525
|
srcChainId: number;
|
|
438
526
|
destChainId: number;
|
|
@@ -565,6 +653,25 @@ export declare const QuoteSchema: import("@metamask/superstruct").Struct<{
|
|
|
565
653
|
priceImpact?: string | undefined;
|
|
566
654
|
totalFeeAmountUsd?: string | undefined;
|
|
567
655
|
} | undefined;
|
|
656
|
+
intent?: {
|
|
657
|
+
protocol: "cowswap";
|
|
658
|
+
order: {
|
|
659
|
+
sellToken: string;
|
|
660
|
+
buyToken: string;
|
|
661
|
+
validTo: string | number;
|
|
662
|
+
appData: string;
|
|
663
|
+
appDataHash: string;
|
|
664
|
+
feeAmount: string;
|
|
665
|
+
kind: "sell" | "buy";
|
|
666
|
+
partiallyFillable: boolean;
|
|
667
|
+
receiver?: string | undefined;
|
|
668
|
+
sellAmount?: string | undefined;
|
|
669
|
+
buyAmount?: string | undefined;
|
|
670
|
+
from?: string | undefined;
|
|
671
|
+
};
|
|
672
|
+
settlementContract?: string | undefined;
|
|
673
|
+
relayer?: string | undefined;
|
|
674
|
+
} | undefined;
|
|
568
675
|
gasSponsored?: boolean | undefined;
|
|
569
676
|
}, {
|
|
570
677
|
requestId: import("@metamask/superstruct").Struct<string, null>;
|
|
@@ -1081,6 +1188,61 @@ export declare const QuoteSchema: import("@metamask/superstruct").Struct<{
|
|
|
1081
1188
|
priceImpact: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1082
1189
|
totalFeeAmountUsd: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1083
1190
|
}>;
|
|
1191
|
+
intent: import("@metamask/superstruct").Struct<{
|
|
1192
|
+
protocol: "cowswap";
|
|
1193
|
+
order: {
|
|
1194
|
+
sellToken: string;
|
|
1195
|
+
buyToken: string;
|
|
1196
|
+
validTo: string | number;
|
|
1197
|
+
appData: string;
|
|
1198
|
+
appDataHash: string;
|
|
1199
|
+
feeAmount: string;
|
|
1200
|
+
kind: "sell" | "buy";
|
|
1201
|
+
partiallyFillable: boolean;
|
|
1202
|
+
receiver?: string | undefined;
|
|
1203
|
+
sellAmount?: string | undefined;
|
|
1204
|
+
buyAmount?: string | undefined;
|
|
1205
|
+
from?: string | undefined;
|
|
1206
|
+
};
|
|
1207
|
+
settlementContract?: string | undefined;
|
|
1208
|
+
relayer?: string | undefined;
|
|
1209
|
+
} | undefined, {
|
|
1210
|
+
protocol: import("@metamask/superstruct").Struct<"cowswap", {
|
|
1211
|
+
cowswap: "cowswap";
|
|
1212
|
+
}>;
|
|
1213
|
+
order: import("@metamask/superstruct").Struct<{
|
|
1214
|
+
sellToken: string;
|
|
1215
|
+
buyToken: string;
|
|
1216
|
+
validTo: string | number;
|
|
1217
|
+
appData: string;
|
|
1218
|
+
appDataHash: string;
|
|
1219
|
+
feeAmount: string;
|
|
1220
|
+
kind: "sell" | "buy";
|
|
1221
|
+
partiallyFillable: boolean;
|
|
1222
|
+
receiver?: string | undefined;
|
|
1223
|
+
sellAmount?: string | undefined;
|
|
1224
|
+
buyAmount?: string | undefined;
|
|
1225
|
+
from?: string | undefined;
|
|
1226
|
+
}, {
|
|
1227
|
+
sellToken: import("@metamask/superstruct").Struct<string, null>;
|
|
1228
|
+
buyToken: import("@metamask/superstruct").Struct<string, null>;
|
|
1229
|
+
receiver: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1230
|
+
validTo: import("@metamask/superstruct").Struct<string | number, null>;
|
|
1231
|
+
appData: import("@metamask/superstruct").Struct<string, null>;
|
|
1232
|
+
appDataHash: import("@metamask/superstruct").Struct<string, null>;
|
|
1233
|
+
feeAmount: import("@metamask/superstruct").Struct<string, null>;
|
|
1234
|
+
kind: import("@metamask/superstruct").Struct<"sell" | "buy", {
|
|
1235
|
+
sell: "sell";
|
|
1236
|
+
buy: "buy";
|
|
1237
|
+
}>;
|
|
1238
|
+
partiallyFillable: import("@metamask/superstruct").Struct<boolean, null>;
|
|
1239
|
+
sellAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1240
|
+
buyAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1241
|
+
from: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1242
|
+
}>;
|
|
1243
|
+
settlementContract: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1244
|
+
relayer: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1245
|
+
}>;
|
|
1084
1246
|
/**
|
|
1085
1247
|
* A third party sponsors the gas. If true, then gasIncluded7702 is also true.
|
|
1086
1248
|
*/
|
|
@@ -1088,8 +1250,8 @@ export declare const QuoteSchema: import("@metamask/superstruct").Struct<{
|
|
|
1088
1250
|
}>;
|
|
1089
1251
|
export declare const TxDataSchema: import("@metamask/superstruct").Struct<{
|
|
1090
1252
|
chainId: number;
|
|
1091
|
-
to: string;
|
|
1092
1253
|
from: string;
|
|
1254
|
+
to: string;
|
|
1093
1255
|
value: string;
|
|
1094
1256
|
data: string;
|
|
1095
1257
|
gasLimit: number | null;
|
|
@@ -1271,13 +1433,32 @@ export declare const QuoteResponseSchema: import("@metamask/superstruct").Struct
|
|
|
1271
1433
|
priceImpact?: string | undefined;
|
|
1272
1434
|
totalFeeAmountUsd?: string | undefined;
|
|
1273
1435
|
} | undefined;
|
|
1436
|
+
intent?: {
|
|
1437
|
+
protocol: "cowswap";
|
|
1438
|
+
order: {
|
|
1439
|
+
sellToken: string;
|
|
1440
|
+
buyToken: string;
|
|
1441
|
+
validTo: string | number;
|
|
1442
|
+
appData: string;
|
|
1443
|
+
appDataHash: string;
|
|
1444
|
+
feeAmount: string;
|
|
1445
|
+
kind: "sell" | "buy";
|
|
1446
|
+
partiallyFillable: boolean;
|
|
1447
|
+
receiver?: string | undefined;
|
|
1448
|
+
sellAmount?: string | undefined;
|
|
1449
|
+
buyAmount?: string | undefined;
|
|
1450
|
+
from?: string | undefined;
|
|
1451
|
+
};
|
|
1452
|
+
settlementContract?: string | undefined;
|
|
1453
|
+
relayer?: string | undefined;
|
|
1454
|
+
} | undefined;
|
|
1274
1455
|
gasSponsored?: boolean | undefined;
|
|
1275
1456
|
};
|
|
1276
1457
|
estimatedProcessingTimeInSeconds: number;
|
|
1277
1458
|
trade: string | {
|
|
1278
1459
|
chainId: number;
|
|
1279
|
-
to: string;
|
|
1280
1460
|
from: string;
|
|
1461
|
+
to: string;
|
|
1281
1462
|
value: string;
|
|
1282
1463
|
data: string;
|
|
1283
1464
|
gasLimit: number | null;
|
|
@@ -1297,8 +1478,8 @@ export declare const QuoteResponseSchema: import("@metamask/superstruct").Struct
|
|
|
1297
1478
|
};
|
|
1298
1479
|
approval?: {
|
|
1299
1480
|
chainId: number;
|
|
1300
|
-
to: string;
|
|
1301
1481
|
from: string;
|
|
1482
|
+
to: string;
|
|
1302
1483
|
value: string;
|
|
1303
1484
|
data: string;
|
|
1304
1485
|
gasLimit: number | null;
|
|
@@ -1446,6 +1627,25 @@ export declare const QuoteResponseSchema: import("@metamask/superstruct").Struct
|
|
|
1446
1627
|
priceImpact?: string | undefined;
|
|
1447
1628
|
totalFeeAmountUsd?: string | undefined;
|
|
1448
1629
|
} | undefined;
|
|
1630
|
+
intent?: {
|
|
1631
|
+
protocol: "cowswap";
|
|
1632
|
+
order: {
|
|
1633
|
+
sellToken: string;
|
|
1634
|
+
buyToken: string;
|
|
1635
|
+
validTo: string | number;
|
|
1636
|
+
appData: string;
|
|
1637
|
+
appDataHash: string;
|
|
1638
|
+
feeAmount: string;
|
|
1639
|
+
kind: "sell" | "buy";
|
|
1640
|
+
partiallyFillable: boolean;
|
|
1641
|
+
receiver?: string | undefined;
|
|
1642
|
+
sellAmount?: string | undefined;
|
|
1643
|
+
buyAmount?: string | undefined;
|
|
1644
|
+
from?: string | undefined;
|
|
1645
|
+
};
|
|
1646
|
+
settlementContract?: string | undefined;
|
|
1647
|
+
relayer?: string | undefined;
|
|
1648
|
+
} | undefined;
|
|
1449
1649
|
gasSponsored?: boolean | undefined;
|
|
1450
1650
|
}, {
|
|
1451
1651
|
requestId: import("@metamask/superstruct").Struct<string, null>;
|
|
@@ -1962,6 +2162,61 @@ export declare const QuoteResponseSchema: import("@metamask/superstruct").Struct
|
|
|
1962
2162
|
priceImpact: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1963
2163
|
totalFeeAmountUsd: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
1964
2164
|
}>;
|
|
2165
|
+
intent: import("@metamask/superstruct").Struct<{
|
|
2166
|
+
protocol: "cowswap";
|
|
2167
|
+
order: {
|
|
2168
|
+
sellToken: string;
|
|
2169
|
+
buyToken: string;
|
|
2170
|
+
validTo: string | number;
|
|
2171
|
+
appData: string;
|
|
2172
|
+
appDataHash: string;
|
|
2173
|
+
feeAmount: string;
|
|
2174
|
+
kind: "sell" | "buy";
|
|
2175
|
+
partiallyFillable: boolean;
|
|
2176
|
+
receiver?: string | undefined;
|
|
2177
|
+
sellAmount?: string | undefined;
|
|
2178
|
+
buyAmount?: string | undefined;
|
|
2179
|
+
from?: string | undefined;
|
|
2180
|
+
};
|
|
2181
|
+
settlementContract?: string | undefined;
|
|
2182
|
+
relayer?: string | undefined;
|
|
2183
|
+
} | undefined, {
|
|
2184
|
+
protocol: import("@metamask/superstruct").Struct<"cowswap", {
|
|
2185
|
+
cowswap: "cowswap";
|
|
2186
|
+
}>;
|
|
2187
|
+
order: import("@metamask/superstruct").Struct<{
|
|
2188
|
+
sellToken: string;
|
|
2189
|
+
buyToken: string;
|
|
2190
|
+
validTo: string | number;
|
|
2191
|
+
appData: string;
|
|
2192
|
+
appDataHash: string;
|
|
2193
|
+
feeAmount: string;
|
|
2194
|
+
kind: "sell" | "buy";
|
|
2195
|
+
partiallyFillable: boolean;
|
|
2196
|
+
receiver?: string | undefined;
|
|
2197
|
+
sellAmount?: string | undefined;
|
|
2198
|
+
buyAmount?: string | undefined;
|
|
2199
|
+
from?: string | undefined;
|
|
2200
|
+
}, {
|
|
2201
|
+
sellToken: import("@metamask/superstruct").Struct<string, null>;
|
|
2202
|
+
buyToken: import("@metamask/superstruct").Struct<string, null>;
|
|
2203
|
+
receiver: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
2204
|
+
validTo: import("@metamask/superstruct").Struct<string | number, null>;
|
|
2205
|
+
appData: import("@metamask/superstruct").Struct<string, null>;
|
|
2206
|
+
appDataHash: import("@metamask/superstruct").Struct<string, null>;
|
|
2207
|
+
feeAmount: import("@metamask/superstruct").Struct<string, null>;
|
|
2208
|
+
kind: import("@metamask/superstruct").Struct<"sell" | "buy", {
|
|
2209
|
+
sell: "sell";
|
|
2210
|
+
buy: "buy";
|
|
2211
|
+
}>;
|
|
2212
|
+
partiallyFillable: import("@metamask/superstruct").Struct<boolean, null>;
|
|
2213
|
+
sellAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
2214
|
+
buyAmount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
2215
|
+
from: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
2216
|
+
}>;
|
|
2217
|
+
settlementContract: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
2218
|
+
relayer: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
2219
|
+
}>;
|
|
1965
2220
|
/**
|
|
1966
2221
|
* A third party sponsors the gas. If true, then gasIncluded7702 is also true.
|
|
1967
2222
|
*/
|
|
@@ -1970,8 +2225,8 @@ export declare const QuoteResponseSchema: import("@metamask/superstruct").Struct
|
|
|
1970
2225
|
estimatedProcessingTimeInSeconds: import("@metamask/superstruct").Struct<number, null>;
|
|
1971
2226
|
approval: import("@metamask/superstruct").Struct<{
|
|
1972
2227
|
chainId: number;
|
|
1973
|
-
to: string;
|
|
1974
2228
|
from: string;
|
|
2229
|
+
to: string;
|
|
1975
2230
|
value: string;
|
|
1976
2231
|
data: string;
|
|
1977
2232
|
gasLimit: number | null;
|
|
@@ -1988,8 +2243,8 @@ export declare const QuoteResponseSchema: import("@metamask/superstruct").Struct
|
|
|
1988
2243
|
} | undefined, null>;
|
|
1989
2244
|
trade: import("@metamask/superstruct").Struct<string | {
|
|
1990
2245
|
chainId: number;
|
|
1991
|
-
to: string;
|
|
1992
2246
|
from: string;
|
|
2247
|
+
to: string;
|
|
1993
2248
|
value: string;
|
|
1994
2249
|
data: string;
|
|
1995
2250
|
gasLimit: number | null;
|
|
@@ -2141,13 +2396,32 @@ export declare const validateQuoteResponse: (data: unknown) => data is {
|
|
|
2141
2396
|
priceImpact?: string | undefined;
|
|
2142
2397
|
totalFeeAmountUsd?: string | undefined;
|
|
2143
2398
|
} | undefined;
|
|
2399
|
+
intent?: {
|
|
2400
|
+
protocol: "cowswap";
|
|
2401
|
+
order: {
|
|
2402
|
+
sellToken: string;
|
|
2403
|
+
buyToken: string;
|
|
2404
|
+
validTo: string | number;
|
|
2405
|
+
appData: string;
|
|
2406
|
+
appDataHash: string;
|
|
2407
|
+
feeAmount: string;
|
|
2408
|
+
kind: "sell" | "buy";
|
|
2409
|
+
partiallyFillable: boolean;
|
|
2410
|
+
receiver?: string | undefined;
|
|
2411
|
+
sellAmount?: string | undefined;
|
|
2412
|
+
buyAmount?: string | undefined;
|
|
2413
|
+
from?: string | undefined;
|
|
2414
|
+
};
|
|
2415
|
+
settlementContract?: string | undefined;
|
|
2416
|
+
relayer?: string | undefined;
|
|
2417
|
+
} | undefined;
|
|
2144
2418
|
gasSponsored?: boolean | undefined;
|
|
2145
2419
|
};
|
|
2146
2420
|
estimatedProcessingTimeInSeconds: number;
|
|
2147
2421
|
trade: string | {
|
|
2148
2422
|
chainId: number;
|
|
2149
|
-
to: string;
|
|
2150
2423
|
from: string;
|
|
2424
|
+
to: string;
|
|
2151
2425
|
value: string;
|
|
2152
2426
|
data: string;
|
|
2153
2427
|
gasLimit: number | null;
|
|
@@ -2167,8 +2441,8 @@ export declare const validateQuoteResponse: (data: unknown) => data is {
|
|
|
2167
2441
|
};
|
|
2168
2442
|
approval?: {
|
|
2169
2443
|
chainId: number;
|
|
2170
|
-
to: string;
|
|
2171
2444
|
from: string;
|
|
2445
|
+
to: string;
|
|
2172
2446
|
value: string;
|
|
2173
2447
|
data: string;
|
|
2174
2448
|
gasLimit: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.mts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validators.d.mts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAoBnD,oBAAY,OAAO;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,UAAU;CACjB;AAED,oBAAY,SAAS;IACnB,KAAK,UAAU;CAChB;AAED,oBAAY,WAAW;IACrB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAkBD,eAAO,MAAM,YAAY,MAAO,MAAM,YAAuB,CAAC;AAK9D,eAAO,MAAM,iBAAiB;;;;;;;;;;IAC5B;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;IAGH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAeH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAZnC;;;WAGG;;QAEH;;;WAGG;;;EAeH,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;EAGrC,CAAC;AAUH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;I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= StepSchema;
|
|
143
|
+
// Allow digit strings for amounts/validTo for flexibility across providers
|
|
144
|
+
const DigitStringOrNumberSchema = union([TruthyDigitStringSchema, number()]);
|
|
145
|
+
// Intent support (e.g., CoW Swap EIP-712 order signing)
|
|
146
|
+
const IntentProtocolSchema = enums(['cowswap']);
|
|
147
|
+
export const IntentOrderSchema = type({
|
|
148
|
+
// EIP-712 Order fields (subset required for signing/submission)
|
|
149
|
+
sellToken: HexAddressSchema,
|
|
150
|
+
buyToken: HexAddressSchema,
|
|
151
|
+
receiver: optional(HexAddressSchema),
|
|
152
|
+
validTo: DigitStringOrNumberSchema,
|
|
153
|
+
appData: string(),
|
|
154
|
+
appDataHash: HexStringSchema,
|
|
155
|
+
feeAmount: TruthyDigitStringSchema,
|
|
156
|
+
kind: enums(['sell', 'buy']),
|
|
157
|
+
partiallyFillable: boolean(),
|
|
158
|
+
// One of these is required by CoW depending on kind; we keep both optional here and rely on backend validation
|
|
159
|
+
sellAmount: optional(TruthyDigitStringSchema),
|
|
160
|
+
buyAmount: optional(TruthyDigitStringSchema),
|
|
161
|
+
// Optional owner/from for convenience when building domain/message
|
|
162
|
+
from: optional(HexAddressSchema),
|
|
163
|
+
});
|
|
164
|
+
export const IntentSchema = type({
|
|
165
|
+
protocol: IntentProtocolSchema,
|
|
166
|
+
order: IntentOrderSchema,
|
|
167
|
+
// Optional metadata to aid submission/routing
|
|
168
|
+
settlementContract: optional(HexAddressSchema),
|
|
169
|
+
relayer: optional(HexAddressSchema),
|
|
170
|
+
});
|
|
143
171
|
export const QuoteSchema = type({
|
|
144
172
|
requestId: string(),
|
|
145
173
|
srcChainId: ChainIdSchema,
|
|
@@ -188,6 +216,7 @@ export const QuoteSchema = type({
|
|
|
188
216
|
priceImpact: optional(string()),
|
|
189
217
|
totalFeeAmountUsd: optional(string()),
|
|
190
218
|
})),
|
|
219
|
+
intent: optional(IntentSchema),
|
|
191
220
|
/**
|
|
192
221
|
* A third party sponsors the gas. If true, then gasIncluded7702 is also true.
|
|
193
222
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mCAAmC;AAE/D,OAAO,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,IAAI,EACJ,EAAE,EACF,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACb,8BAA8B;AAC/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,wBAAwB;AAEzE,MAAM,CAAN,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,4BAAiB,CAAA;IACjB,2BAAgB,CAAA;AAClB,CAAC,EAJW,OAAO,KAAP,OAAO,QAIlB;AAED,MAAM,CAAN,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,4BAAe,CAAA;AACjB,CAAC,EAFW,SAAS,KAAT,SAAS,QAEpB;AAED,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,gBAAgB,GAAG,MAAM,CAAS,YAAY,EAAE,CAAC,CAAU,EAAE,EAAE,CACnE,iBAAiB,CAAC,CAAW,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAC5D,CAAC;AAEF,MAAM,eAAe,GAAG,MAAM,CAAS,WAAW,EAAE,CAAC,CAAU,EAAE,EAAE,CACjE,iBAAiB,CAAC,CAAW,CAAC,CAC/B,CAAC;AAEF,MAAM,mBAAmB,GAAG,MAAM,CAChC,eAAe,EACf,CAAC,CAAU,EAAE,EAAE,CACb,OAAO,CAAC,KAAK,QAAQ;IACrB,mBAAmB,CAAC,IAAI,CAAC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EAAE;IAC7C,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import { isValidHexAddress } from '@metamask/controller-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n boolean,\n number,\n type,\n is,\n record,\n array,\n nullable,\n optional,\n enums,\n define,\n union,\n assert,\n pattern,\n intersection,\n} from '@metamask/superstruct';\nimport { CaipAssetTypeStruct, isStrictHexString } from '@metamask/utils';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n TX_FEE = 'txFee',\n}\n\nexport enum FeatureId {\n PERPS = 'perps',\n}\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nconst HexAddressSchema = define<string>('HexAddress', (v: unknown) =>\n isValidHexAddress(v as string, { allowNonPrefixed: false }),\n);\n\nconst HexStringSchema = define<string>('HexString', (v: unknown) =>\n isStrictHexString(v as string),\n);\n\nconst VersionStringSchema = define<string>(\n 'VersionString',\n (v: unknown) =>\n typeof v === 'string' &&\n /^(\\d+\\.*){2}\\d+$/u.test(v) &&\n v.split('.').length === 3,\n);\n\nexport const truthyString = (s: string) => Boolean(s?.length);\nconst TruthyDigitStringSchema = pattern(string(), /^\\d+$/u);\n\nconst ChainIdSchema = number();\n\nexport const BridgeAssetSchema = type({\n /**\n * The chainId of the token\n */\n chainId: ChainIdSchema,\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string(),\n /**\n * The assetId of the token\n */\n assetId: CaipAssetTypeStruct,\n /**\n * The symbol of token object\n */\n symbol: string(),\n /**\n * The name for the network\n */\n name: string(),\n decimals: number(),\n /**\n * URL for token icon\n */\n icon: optional(nullable(string())),\n /**\n * URL for token icon\n */\n iconUrl: optional(nullable(string())),\n});\n\nconst DefaultPairSchema = type({\n /**\n * The standard default pairs. Use this if the pair is only set once.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n standard: record(string(), string()),\n /**\n * The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n other: record(string(), string()),\n});\n\nexport const ChainConfigurationSchema = type({\n isActiveSrc: boolean(),\n isActiveDest: boolean(),\n refreshRate: optional(number()),\n topAssets: optional(array(string())),\n stablecoins: optional(array(string())),\n isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\n noFeeAssets: optional(array(string())),\n defaultPairs: optional(DefaultPairSchema),\n});\n\nexport const PriceImpactThresholdSchema = type({\n gasless: number(),\n normal: number(),\n});\n\nconst GenericQuoteRequestSchema = type({\n aggIds: optional(array(string())),\n bridgeIds: optional(array(string())),\n fee: optional(number()),\n});\n\nconst FeatureIdSchema = enums(Object.values(FeatureId));\n\n/**\n * This is the schema for the feature flags response from the RemoteFeatureFlagController\n */\nexport const PlatformConfigSchema = type({\n priceImpactThreshold: optional(PriceImpactThresholdSchema),\n quoteRequestOverrides: optional(\n record(FeatureIdSchema, optional(GenericQuoteRequestSchema)),\n ),\n minimumVersion: string(),\n refreshRate: number(),\n maxRefreshCount: number(),\n support: boolean(),\n chains: record(string(), ChainConfigurationSchema),\n /**\n * The bip44 default pairs for the chains\n * Key is the CAIP chainId namespace\n */\n bip44DefaultPairs: optional(record(string(), optional(DefaultPairSchema))),\n sse: optional(\n type({\n enabled: boolean(),\n /**\n * The minimum version of the client required to enable SSE, for example 13.8.0\n */\n minimumVersion: VersionStringSchema,\n }),\n ),\n});\n\nexport const validateFeatureFlagsResponse = (\n data: unknown,\n): data is Infer<typeof PlatformConfigSchema> => {\n return is(data, PlatformConfigSchema);\n};\n\nexport const validateSwapsTokenObject = (\n data: unknown,\n): data is Infer<typeof BridgeAssetSchema> => {\n return is(data, BridgeAssetSchema);\n};\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n});\n\nexport const ProtocolSchema = type({\n name: string(),\n displayName: optional(string()),\n icon: optional(string()),\n});\n\nexport const StepSchema = type({\n action: enums(Object.values(ActionTypes)),\n srcChainId: ChainIdSchema,\n destChainId: optional(ChainIdSchema),\n srcAsset: BridgeAssetSchema,\n destAsset: BridgeAssetSchema,\n srcAmount: string(),\n destAmount: string(),\n protocol: ProtocolSchema,\n});\n\nconst RefuelDataSchema = StepSchema;\n\nexport const QuoteSchema = type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: string(),\n feeData: type({\n [FeeType.METABRIDGE]: FeeDataSchema,\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([\n FeeDataSchema,\n type({\n maxFeePerGas: string(),\n maxPriorityFeePerGas: string(),\n }),\n ]),\n ),\n }),\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n bridgeId: string(),\n bridges: array(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n /**\n * A third party sponsors the gas. If true, then gasIncluded7702 is also true.\n */\n gasSponsored: optional(boolean()),\n});\n\nexport const TxDataSchema = type({\n chainId: number(),\n to: HexAddressSchema,\n from: HexAddressSchema,\n value: HexStringSchema,\n data: HexStringSchema,\n gasLimit: nullable(number()),\n effectiveGas: optional(number()),\n});\n\nexport const BitcoinTradeDataSchema = type({\n unsignedPsbtBase64: string(),\n inputsToSign: nullable(array(type({}))),\n});\n\nexport const TronTradeDataSchema = type({\n raw_data_hex: string(),\n visible: optional(boolean()),\n raw_data: optional(\n nullable(\n type({\n contract: optional(\n array(\n type({\n type: optional(string()),\n }),\n ),\n ),\n fee_limit: optional(number()),\n }),\n ),\n ),\n});\n\nexport const QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(union([TxDataSchema, TronTradeDataSchema])),\n trade: union([\n TxDataSchema,\n BitcoinTradeDataSchema,\n TronTradeDataSchema,\n string(),\n ]),\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mCAAmC;AAE/D,OAAO,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,IAAI,EACJ,EAAE,EACF,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACb,8BAA8B;AAC/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,wBAAwB;AAEzE,MAAM,CAAN,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,4BAAiB,CAAA;IACjB,2BAAgB,CAAA;AAClB,CAAC,EAJW,OAAO,KAAP,OAAO,QAIlB;AAED,MAAM,CAAN,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,4BAAe,CAAA;AACjB,CAAC,EAFW,SAAS,KAAT,SAAS,QAEpB;AAED,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;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,gCAAgC,EAAE,MAAM,EAAE;IAC1C,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC9D,KAAK,EAAE,KAAK,CAAC;QACX,YAAY;QACZ,sBAAsB;QACtB,mBAAmB;QACnB,MAAM,EAAE;KACT,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,IAAa,EAC8B,EAAE;IAC7C,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import { isValidHexAddress } from '@metamask/controller-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n boolean,\n number,\n type,\n is,\n record,\n array,\n nullable,\n optional,\n enums,\n define,\n union,\n assert,\n pattern,\n intersection,\n} from '@metamask/superstruct';\nimport { CaipAssetTypeStruct, isStrictHexString } from '@metamask/utils';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n TX_FEE = 'txFee',\n}\n\nexport enum FeatureId {\n PERPS = 'perps',\n}\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nconst HexAddressSchema = define<string>('HexAddress', (v: unknown) =>\n isValidHexAddress(v as string, { allowNonPrefixed: false }),\n);\n\nconst HexStringSchema = define<string>('HexString', (v: unknown) =>\n isStrictHexString(v as string),\n);\n\nconst VersionStringSchema = define<string>(\n 'VersionString',\n (v: unknown) =>\n typeof v === 'string' &&\n /^(\\d+\\.*){2}\\d+$/u.test(v) &&\n v.split('.').length === 3,\n);\n\nexport const truthyString = (s: string) => Boolean(s?.length);\nconst TruthyDigitStringSchema = pattern(string(), /^\\d+$/u);\n\nconst ChainIdSchema = number();\n\nexport const BridgeAssetSchema = type({\n /**\n * The chainId of the token\n */\n chainId: ChainIdSchema,\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string(),\n /**\n * The assetId of the token\n */\n assetId: CaipAssetTypeStruct,\n /**\n * The symbol of token object\n */\n symbol: string(),\n /**\n * The name for the network\n */\n name: string(),\n decimals: number(),\n /**\n * URL for token icon\n */\n icon: optional(nullable(string())),\n /**\n * URL for token icon\n */\n iconUrl: optional(nullable(string())),\n});\n\nconst DefaultPairSchema = type({\n /**\n * The standard default pairs. Use this if the pair is only set once.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n standard: record(string(), string()),\n /**\n * The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n other: record(string(), string()),\n});\n\nexport const ChainConfigurationSchema = type({\n isActiveSrc: boolean(),\n isActiveDest: boolean(),\n refreshRate: optional(number()),\n topAssets: optional(array(string())),\n stablecoins: optional(array(string())),\n isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\n noFeeAssets: optional(array(string())),\n defaultPairs: optional(DefaultPairSchema),\n});\n\nexport const PriceImpactThresholdSchema = type({\n gasless: number(),\n normal: number(),\n});\n\nconst GenericQuoteRequestSchema = type({\n aggIds: optional(array(string())),\n bridgeIds: optional(array(string())),\n fee: optional(number()),\n});\n\nconst FeatureIdSchema = enums(Object.values(FeatureId));\n\n/**\n * This is the schema for the feature flags response from the RemoteFeatureFlagController\n */\nexport const PlatformConfigSchema = type({\n priceImpactThreshold: optional(PriceImpactThresholdSchema),\n quoteRequestOverrides: optional(\n record(FeatureIdSchema, optional(GenericQuoteRequestSchema)),\n ),\n minimumVersion: string(),\n refreshRate: number(),\n maxRefreshCount: number(),\n support: boolean(),\n chains: record(string(), ChainConfigurationSchema),\n /**\n * The bip44 default pairs for the chains\n * Key is the CAIP chainId namespace\n */\n bip44DefaultPairs: optional(record(string(), optional(DefaultPairSchema))),\n sse: optional(\n type({\n enabled: boolean(),\n /**\n * The minimum version of the client required to enable SSE, for example 13.8.0\n */\n minimumVersion: VersionStringSchema,\n }),\n ),\n});\n\nexport const validateFeatureFlagsResponse = (\n data: unknown,\n): data is Infer<typeof PlatformConfigSchema> => {\n return is(data, PlatformConfigSchema);\n};\n\nexport const validateSwapsTokenObject = (\n data: unknown,\n): data is Infer<typeof BridgeAssetSchema> => {\n return is(data, BridgeAssetSchema);\n};\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n});\n\nexport const ProtocolSchema = type({\n name: string(),\n displayName: optional(string()),\n icon: optional(string()),\n});\n\nexport const StepSchema = type({\n action: enums(Object.values(ActionTypes)),\n srcChainId: ChainIdSchema,\n destChainId: optional(ChainIdSchema),\n srcAsset: BridgeAssetSchema,\n destAsset: BridgeAssetSchema,\n srcAmount: string(),\n destAmount: string(),\n protocol: ProtocolSchema,\n});\n\nconst RefuelDataSchema = StepSchema;\n\n// Allow digit strings for amounts/validTo for flexibility across providers\nconst DigitStringOrNumberSchema = union([TruthyDigitStringSchema, number()]);\n\n// Intent support (e.g., CoW Swap EIP-712 order signing)\nconst IntentProtocolSchema = enums(['cowswap']);\n\nexport const IntentOrderSchema = type({\n // EIP-712 Order fields (subset required for signing/submission)\n sellToken: HexAddressSchema,\n buyToken: HexAddressSchema,\n receiver: optional(HexAddressSchema),\n validTo: DigitStringOrNumberSchema,\n appData: string(),\n appDataHash: HexStringSchema,\n feeAmount: TruthyDigitStringSchema,\n kind: enums(['sell', 'buy']),\n partiallyFillable: boolean(),\n // One of these is required by CoW depending on kind; we keep both optional here and rely on backend validation\n sellAmount: optional(TruthyDigitStringSchema),\n buyAmount: optional(TruthyDigitStringSchema),\n // Optional owner/from for convenience when building domain/message\n from: optional(HexAddressSchema),\n});\n\nexport const IntentSchema = type({\n protocol: IntentProtocolSchema,\n order: IntentOrderSchema,\n // Optional metadata to aid submission/routing\n settlementContract: optional(HexAddressSchema),\n relayer: optional(HexAddressSchema),\n});\n\n// Export types for use in other modules\nexport type IntentOrder = Infer<typeof IntentOrderSchema>;\nexport type Intent = Infer<typeof IntentSchema>;\n\nexport const QuoteSchema = type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: string(),\n feeData: type({\n [FeeType.METABRIDGE]: FeeDataSchema,\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([\n FeeDataSchema,\n type({\n maxFeePerGas: string(),\n maxPriorityFeePerGas: string(),\n }),\n ]),\n ),\n }),\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n bridgeId: string(),\n bridges: array(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n intent: optional(IntentSchema),\n /**\n * A third party sponsors the gas. If true, then gasIncluded7702 is also true.\n */\n gasSponsored: optional(boolean()),\n});\n\nexport const TxDataSchema = type({\n chainId: number(),\n to: HexAddressSchema,\n from: HexAddressSchema,\n value: HexStringSchema,\n data: HexStringSchema,\n gasLimit: nullable(number()),\n effectiveGas: optional(number()),\n});\n\nexport const BitcoinTradeDataSchema = type({\n unsignedPsbtBase64: string(),\n inputsToSign: nullable(array(type({}))),\n});\n\nexport const TronTradeDataSchema = type({\n raw_data_hex: string(),\n visible: optional(boolean()),\n raw_data: optional(\n nullable(\n type({\n contract: optional(\n array(\n type({\n type: optional(string()),\n }),\n ),\n ),\n fee_limit: optional(number()),\n }),\n ),\n ),\n});\n\nexport const QuoteResponseSchema = type({\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(union([TxDataSchema, TronTradeDataSchema])),\n trade: union([\n TxDataSchema,\n BitcoinTradeDataSchema,\n TronTradeDataSchema,\n string(),\n ]),\n});\n\nexport const validateQuoteResponse = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n"]}
|
package/package.json
CHANGED