@metamask-previews/bridge-status-controller 32.0.0-preview-dccbb1e2 → 33.0.0-preview-f9a5dd05
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 +23 -1
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +1 -12
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +9 -74
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +9 -74
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +0 -11
- package/dist/types.mjs.map +1 -1
- package/dist/utils/metrics.cjs +2 -2
- package/dist/utils/metrics.cjs.map +1 -1
- package/dist/utils/metrics.mjs +2 -2
- package/dist/utils/metrics.mjs.map +1 -1
- package/dist/utils/transaction.d.cts +149 -6
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +149 -6
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/validators.cjs +36 -34
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +117 -0
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +117 -0
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +36 -34
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +3 -3
@@ -1,2 +1,119 @@
|
|
1
|
+
import { StatusTypes } from "@metamask/bridge-controller";
|
2
|
+
export declare const StatusResponseSchema: import("@metamask/superstruct").Struct<{
|
3
|
+
status: StatusTypes;
|
4
|
+
srcChain: {
|
5
|
+
chainId: number;
|
6
|
+
amount?: string | undefined;
|
7
|
+
token?: {
|
8
|
+
symbol: string;
|
9
|
+
address: string;
|
10
|
+
name: string;
|
11
|
+
chainId: number;
|
12
|
+
decimals: number;
|
13
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
14
|
+
iconUrl?: string | null | undefined;
|
15
|
+
icon?: string | null | undefined;
|
16
|
+
} | {} | undefined;
|
17
|
+
txHash?: string | undefined;
|
18
|
+
};
|
19
|
+
bridge?: string | undefined;
|
20
|
+
refuel?: {} | undefined;
|
21
|
+
destChain?: {
|
22
|
+
chainId: number;
|
23
|
+
amount?: string | undefined;
|
24
|
+
token?: {
|
25
|
+
symbol: string;
|
26
|
+
address: string;
|
27
|
+
name: string;
|
28
|
+
chainId: number;
|
29
|
+
decimals: number;
|
30
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
31
|
+
iconUrl?: string | null | undefined;
|
32
|
+
icon?: string | null | undefined;
|
33
|
+
} | {} | undefined;
|
34
|
+
txHash?: string | undefined;
|
35
|
+
} | undefined;
|
36
|
+
isExpectedToken?: boolean | undefined;
|
37
|
+
isUnrecognizedRouterAddress?: boolean | undefined;
|
38
|
+
}, {
|
39
|
+
status: import("@metamask/superstruct").Struct<StatusTypes, {
|
40
|
+
UNKNOWN: StatusTypes.UNKNOWN;
|
41
|
+
FAILED: StatusTypes.FAILED;
|
42
|
+
PENDING: StatusTypes.PENDING;
|
43
|
+
COMPLETE: StatusTypes.COMPLETE;
|
44
|
+
}>;
|
45
|
+
srcChain: import("@metamask/superstruct").Struct<{
|
46
|
+
chainId: number;
|
47
|
+
amount?: string | undefined;
|
48
|
+
token?: {
|
49
|
+
symbol: string;
|
50
|
+
address: string;
|
51
|
+
name: string;
|
52
|
+
chainId: number;
|
53
|
+
decimals: number;
|
54
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
55
|
+
iconUrl?: string | null | undefined;
|
56
|
+
icon?: string | null | undefined;
|
57
|
+
} | {} | undefined;
|
58
|
+
txHash?: string | undefined;
|
59
|
+
}, {
|
60
|
+
chainId: import("@metamask/superstruct").Struct<number, null>;
|
61
|
+
/**
|
62
|
+
* The txHash of the transaction on the source chain.
|
63
|
+
* This might be undefined for smart transactions (STX)
|
64
|
+
*/
|
65
|
+
txHash: import("@metamask/superstruct").Struct<string | undefined, null>;
|
66
|
+
/**
|
67
|
+
* The atomic amount of the token sent minus fees on the source chain
|
68
|
+
*/
|
69
|
+
amount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
70
|
+
token: import("@metamask/superstruct").Struct<{
|
71
|
+
symbol: string;
|
72
|
+
address: string;
|
73
|
+
name: string;
|
74
|
+
chainId: number;
|
75
|
+
decimals: number;
|
76
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
77
|
+
iconUrl?: string | null | undefined;
|
78
|
+
icon?: string | null | undefined;
|
79
|
+
} | {} | undefined, null>;
|
80
|
+
}>;
|
81
|
+
destChain: import("@metamask/superstruct").Struct<{
|
82
|
+
chainId: number;
|
83
|
+
amount?: string | undefined;
|
84
|
+
token?: {
|
85
|
+
symbol: string;
|
86
|
+
address: string;
|
87
|
+
name: string;
|
88
|
+
chainId: number;
|
89
|
+
decimals: number;
|
90
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
91
|
+
iconUrl?: string | null | undefined;
|
92
|
+
icon?: string | null | undefined;
|
93
|
+
} | {} | undefined;
|
94
|
+
txHash?: string | undefined;
|
95
|
+
} | undefined, {
|
96
|
+
chainId: import("@metamask/superstruct").Struct<number, null>;
|
97
|
+
txHash: import("@metamask/superstruct").Struct<string | undefined, null>;
|
98
|
+
/**
|
99
|
+
* The atomic amount of the token received on the destination chain
|
100
|
+
*/
|
101
|
+
amount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
102
|
+
token: import("@metamask/superstruct").Struct<{
|
103
|
+
symbol: string;
|
104
|
+
address: string;
|
105
|
+
name: string;
|
106
|
+
chainId: number;
|
107
|
+
decimals: number;
|
108
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
109
|
+
iconUrl?: string | null | undefined;
|
110
|
+
icon?: string | null | undefined;
|
111
|
+
} | {} | undefined, null>;
|
112
|
+
}>;
|
113
|
+
bridge: import("@metamask/superstruct").Struct<string | undefined, null>;
|
114
|
+
isExpectedToken: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
115
|
+
isUnrecognizedRouterAddress: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
116
|
+
refuel: import("@metamask/superstruct").Struct<{} | undefined, {}>;
|
117
|
+
}>;
|
1
118
|
export declare const validateBridgeStatusResponse: (data: unknown) => void;
|
2
119
|
//# sourceMappingURL=validators.d.cts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"validators.d.cts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"validators.d.cts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,oCAAoC;AA4C7E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAxB/B;;;WAGG;;QAEH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAQH;;WAEG;;;;;;;;;;;;;;;;;EAeH,CAAC;AAEH,eAAO,MAAM,4BAA4B,SAAU,OAAO,SAkBzD,CAAC"}
|
@@ -1,2 +1,119 @@
|
|
1
|
+
import { StatusTypes } from "@metamask/bridge-controller";
|
2
|
+
export declare const StatusResponseSchema: import("@metamask/superstruct").Struct<{
|
3
|
+
status: StatusTypes;
|
4
|
+
srcChain: {
|
5
|
+
chainId: number;
|
6
|
+
amount?: string | undefined;
|
7
|
+
token?: {
|
8
|
+
symbol: string;
|
9
|
+
address: string;
|
10
|
+
name: string;
|
11
|
+
chainId: number;
|
12
|
+
decimals: number;
|
13
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
14
|
+
iconUrl?: string | null | undefined;
|
15
|
+
icon?: string | null | undefined;
|
16
|
+
} | {} | undefined;
|
17
|
+
txHash?: string | undefined;
|
18
|
+
};
|
19
|
+
bridge?: string | undefined;
|
20
|
+
refuel?: {} | undefined;
|
21
|
+
destChain?: {
|
22
|
+
chainId: number;
|
23
|
+
amount?: string | undefined;
|
24
|
+
token?: {
|
25
|
+
symbol: string;
|
26
|
+
address: string;
|
27
|
+
name: string;
|
28
|
+
chainId: number;
|
29
|
+
decimals: number;
|
30
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
31
|
+
iconUrl?: string | null | undefined;
|
32
|
+
icon?: string | null | undefined;
|
33
|
+
} | {} | undefined;
|
34
|
+
txHash?: string | undefined;
|
35
|
+
} | undefined;
|
36
|
+
isExpectedToken?: boolean | undefined;
|
37
|
+
isUnrecognizedRouterAddress?: boolean | undefined;
|
38
|
+
}, {
|
39
|
+
status: import("@metamask/superstruct").Struct<StatusTypes, {
|
40
|
+
UNKNOWN: StatusTypes.UNKNOWN;
|
41
|
+
FAILED: StatusTypes.FAILED;
|
42
|
+
PENDING: StatusTypes.PENDING;
|
43
|
+
COMPLETE: StatusTypes.COMPLETE;
|
44
|
+
}>;
|
45
|
+
srcChain: import("@metamask/superstruct").Struct<{
|
46
|
+
chainId: number;
|
47
|
+
amount?: string | undefined;
|
48
|
+
token?: {
|
49
|
+
symbol: string;
|
50
|
+
address: string;
|
51
|
+
name: string;
|
52
|
+
chainId: number;
|
53
|
+
decimals: number;
|
54
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
55
|
+
iconUrl?: string | null | undefined;
|
56
|
+
icon?: string | null | undefined;
|
57
|
+
} | {} | undefined;
|
58
|
+
txHash?: string | undefined;
|
59
|
+
}, {
|
60
|
+
chainId: import("@metamask/superstruct").Struct<number, null>;
|
61
|
+
/**
|
62
|
+
* The txHash of the transaction on the source chain.
|
63
|
+
* This might be undefined for smart transactions (STX)
|
64
|
+
*/
|
65
|
+
txHash: import("@metamask/superstruct").Struct<string | undefined, null>;
|
66
|
+
/**
|
67
|
+
* The atomic amount of the token sent minus fees on the source chain
|
68
|
+
*/
|
69
|
+
amount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
70
|
+
token: import("@metamask/superstruct").Struct<{
|
71
|
+
symbol: string;
|
72
|
+
address: string;
|
73
|
+
name: string;
|
74
|
+
chainId: number;
|
75
|
+
decimals: number;
|
76
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
77
|
+
iconUrl?: string | null | undefined;
|
78
|
+
icon?: string | null | undefined;
|
79
|
+
} | {} | undefined, null>;
|
80
|
+
}>;
|
81
|
+
destChain: import("@metamask/superstruct").Struct<{
|
82
|
+
chainId: number;
|
83
|
+
amount?: string | undefined;
|
84
|
+
token?: {
|
85
|
+
symbol: string;
|
86
|
+
address: string;
|
87
|
+
name: string;
|
88
|
+
chainId: number;
|
89
|
+
decimals: number;
|
90
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
91
|
+
iconUrl?: string | null | undefined;
|
92
|
+
icon?: string | null | undefined;
|
93
|
+
} | {} | undefined;
|
94
|
+
txHash?: string | undefined;
|
95
|
+
} | undefined, {
|
96
|
+
chainId: import("@metamask/superstruct").Struct<number, null>;
|
97
|
+
txHash: import("@metamask/superstruct").Struct<string | undefined, null>;
|
98
|
+
/**
|
99
|
+
* The atomic amount of the token received on the destination chain
|
100
|
+
*/
|
101
|
+
amount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
102
|
+
token: import("@metamask/superstruct").Struct<{
|
103
|
+
symbol: string;
|
104
|
+
address: string;
|
105
|
+
name: string;
|
106
|
+
chainId: number;
|
107
|
+
decimals: number;
|
108
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
109
|
+
iconUrl?: string | null | undefined;
|
110
|
+
icon?: string | null | undefined;
|
111
|
+
} | {} | undefined, null>;
|
112
|
+
}>;
|
113
|
+
bridge: import("@metamask/superstruct").Struct<string | undefined, null>;
|
114
|
+
isExpectedToken: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
115
|
+
isUnrecognizedRouterAddress: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
116
|
+
refuel: import("@metamask/superstruct").Struct<{} | undefined, {}>;
|
117
|
+
}>;
|
1
118
|
export declare const validateBridgeStatusResponse: (data: unknown) => void;
|
2
119
|
//# sourceMappingURL=validators.d.mts.map
|
@@ -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":"AAAA,OAAO,EAAE,WAAW,EAAqB,oCAAoC;AA4C7E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAxB/B;;;WAGG;;QAEH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAQH;;WAEG;;;;;;;;;;;;;;;;;EAeH,CAAC;AAEH,eAAO,MAAM,4BAA4B,SAAU,OAAO,SAkBzD,CAAC"}
|
@@ -1,38 +1,40 @@
|
|
1
|
-
import { StatusTypes } from "@metamask/bridge-controller";
|
2
|
-
import { object, string, boolean, number, optional, enums, union, type,
|
1
|
+
import { StatusTypes, BridgeAssetSchema } from "@metamask/bridge-controller";
|
2
|
+
import { object, string, boolean, number, optional, enums, union, type, assert, StructError } from "@metamask/superstruct";
|
3
|
+
const ChainIdSchema = number();
|
4
|
+
const EmptyObjectSchema = object({});
|
5
|
+
const SrcChainStatusSchema = type({
|
6
|
+
chainId: ChainIdSchema,
|
7
|
+
/**
|
8
|
+
* The txHash of the transaction on the source chain.
|
9
|
+
* This might be undefined for smart transactions (STX)
|
10
|
+
*/
|
11
|
+
txHash: optional(string()),
|
12
|
+
/**
|
13
|
+
* The atomic amount of the token sent minus fees on the source chain
|
14
|
+
*/
|
15
|
+
amount: optional(string()),
|
16
|
+
token: optional(union([EmptyObjectSchema, BridgeAssetSchema])),
|
17
|
+
});
|
18
|
+
const DestChainStatusSchema = type({
|
19
|
+
chainId: ChainIdSchema,
|
20
|
+
txHash: optional(string()),
|
21
|
+
/**
|
22
|
+
* The atomic amount of the token received on the destination chain
|
23
|
+
*/
|
24
|
+
amount: optional(string()),
|
25
|
+
token: optional(union([EmptyObjectSchema, BridgeAssetSchema])),
|
26
|
+
});
|
27
|
+
const RefuelStatusResponseSchema = type({});
|
28
|
+
export const StatusResponseSchema = type({
|
29
|
+
status: enums(Object.values(StatusTypes)),
|
30
|
+
srcChain: SrcChainStatusSchema,
|
31
|
+
destChain: optional(DestChainStatusSchema),
|
32
|
+
bridge: optional(string()),
|
33
|
+
isExpectedToken: optional(boolean()),
|
34
|
+
isUnrecognizedRouterAddress: optional(boolean()),
|
35
|
+
refuel: optional(RefuelStatusResponseSchema),
|
36
|
+
});
|
3
37
|
export const validateBridgeStatusResponse = (data) => {
|
4
|
-
const ChainIdSchema = union([number(), string()]);
|
5
|
-
const AssetSchema = type({
|
6
|
-
chainId: ChainIdSchema,
|
7
|
-
address: string(),
|
8
|
-
symbol: string(),
|
9
|
-
name: string(),
|
10
|
-
decimals: number(),
|
11
|
-
icon: optional(nullable(string())),
|
12
|
-
});
|
13
|
-
const EmptyObjectSchema = object({});
|
14
|
-
const SrcChainStatusSchema = type({
|
15
|
-
chainId: ChainIdSchema,
|
16
|
-
txHash: optional(string()),
|
17
|
-
amount: optional(string()),
|
18
|
-
token: optional(union([EmptyObjectSchema, AssetSchema])),
|
19
|
-
});
|
20
|
-
const DestChainStatusSchema = type({
|
21
|
-
chainId: ChainIdSchema,
|
22
|
-
txHash: optional(string()),
|
23
|
-
amount: optional(string()),
|
24
|
-
token: optional(union([EmptyObjectSchema, AssetSchema])),
|
25
|
-
});
|
26
|
-
const RefuelStatusResponseSchema = object();
|
27
|
-
const StatusResponseSchema = type({
|
28
|
-
status: enums(Object.values(StatusTypes)),
|
29
|
-
srcChain: SrcChainStatusSchema,
|
30
|
-
destChain: optional(DestChainStatusSchema),
|
31
|
-
bridge: optional(string()),
|
32
|
-
isExpectedToken: optional(boolean()),
|
33
|
-
isUnrecognizedRouterAddress: optional(boolean()),
|
34
|
-
refuel: optional(RefuelStatusResponseSchema),
|
35
|
-
});
|
36
38
|
const validationFailures = {};
|
37
39
|
try {
|
38
40
|
assert(data, StatusResponseSchema);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,oCAAoC;
|
1
|
+
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,oCAAoC;AAC7E,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,IAAI,EACJ,MAAM,EACN,WAAW,EACZ,8BAA8B;AAE/B,MAAM,aAAa,GAAG,MAAM,EAAE,CAAC;AAE/B,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAErC,MAAM,oBAAoB,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,aAAa;IACtB;;;OAGG;IACH,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;IACvC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACzC,QAAQ,EAAE,oBAAoB;IAC9B,SAAS,EAAE,QAAQ,CAAC,qBAAqB,CAAC;IAC1C,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,2BAA2B,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChD,MAAM,EAAE,QAAQ,CAAC,0BAA0B,CAAC;CAC7C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAAa,EAAE,EAAE;IAC5D,MAAM,kBAAkB,GAA+B,EAAE,CAAC;IAC1D,IAAI;QACF,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;KACpC;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,YAAY,WAAW,EAAE;YAChC,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;gBACrD,MAAM,UAAU,GAAG,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;gBAChD,kBAAkB,CAAC,UAAU,CAAC;oBAC5B,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;YACvD,CAAC,CAAC,CAAC;SACJ;QACD,MAAM,KAAK,CAAC;KACb;YAAS;QACR,IAAI,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9C,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,kBAAkB,CAAC,CAAC;SACtE;KACF;AACH,CAAC,CAAC","sourcesContent":["import { StatusTypes, BridgeAssetSchema } from '@metamask/bridge-controller';\nimport {\n object,\n string,\n boolean,\n number,\n optional,\n enums,\n union,\n type,\n assert,\n StructError,\n} from '@metamask/superstruct';\n\nconst ChainIdSchema = number();\n\nconst EmptyObjectSchema = object({});\n\nconst SrcChainStatusSchema = type({\n chainId: ChainIdSchema,\n /**\n * The txHash of the transaction on the source chain.\n * This might be undefined for smart transactions (STX)\n */\n txHash: optional(string()),\n /**\n * The atomic amount of the token sent minus fees on the source chain\n */\n amount: optional(string()),\n token: optional(union([EmptyObjectSchema, BridgeAssetSchema])),\n});\n\nconst DestChainStatusSchema = type({\n chainId: ChainIdSchema,\n txHash: optional(string()),\n /**\n * The atomic amount of the token received on the destination chain\n */\n amount: optional(string()),\n token: optional(union([EmptyObjectSchema, BridgeAssetSchema])),\n});\n\nconst RefuelStatusResponseSchema = type({});\n\nexport const StatusResponseSchema = type({\n status: enums(Object.values(StatusTypes)),\n srcChain: SrcChainStatusSchema,\n destChain: optional(DestChainStatusSchema),\n bridge: optional(string()),\n isExpectedToken: optional(boolean()),\n isUnrecognizedRouterAddress: optional(boolean()),\n refuel: optional(RefuelStatusResponseSchema),\n});\n\nexport const validateBridgeStatusResponse = (data: unknown) => {\n const validationFailures: { [path: string]: string } = {};\n try {\n assert(data, StatusResponseSchema);\n } catch (error) {\n if (error instanceof StructError) {\n error.failures().forEach(({ branch, path, message }) => {\n const pathString = path?.join('.') || 'unknown';\n validationFailures[pathString] =\n `[${branch?.[0]?.bridge || 'unknown'}] ${message}`;\n });\n }\n throw error;\n } finally {\n if (Object.keys(validationFailures).length > 0) {\n console.error(`Bridge status validation failed`, validationFailures);\n }\n }\n};\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@metamask-previews/bridge-status-controller",
|
3
|
-
"version": "
|
3
|
+
"version": "33.0.0-preview-f9a5dd05",
|
4
4
|
"description": "Manages bridge-related status fetching functionality for MetaMask",
|
5
5
|
"keywords": [
|
6
6
|
"MetaMask",
|
@@ -60,7 +60,7 @@
|
|
60
60
|
"devDependencies": {
|
61
61
|
"@metamask/accounts-controller": "^31.0.0",
|
62
62
|
"@metamask/auto-changelog": "^3.4.4",
|
63
|
-
"@metamask/bridge-controller": "^
|
63
|
+
"@metamask/bridge-controller": "^34.0.0",
|
64
64
|
"@metamask/gas-fee-controller": "^24.0.0",
|
65
65
|
"@metamask/network-controller": "^24.0.0",
|
66
66
|
"@metamask/snaps-controllers": "^12.3.1",
|
@@ -78,7 +78,7 @@
|
|
78
78
|
},
|
79
79
|
"peerDependencies": {
|
80
80
|
"@metamask/accounts-controller": "^31.0.0",
|
81
|
-
"@metamask/bridge-controller": "^
|
81
|
+
"@metamask/bridge-controller": "^34.0.0",
|
82
82
|
"@metamask/gas-fee-controller": "^24.0.0",
|
83
83
|
"@metamask/network-controller": "^24.0.0",
|
84
84
|
"@metamask/snaps-controllers": "^12.0.0",
|