@metamask-previews/bridge-status-controller 73.1.0-preview-e12e4a38f → 74.0.0-preview-4f9d41d
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 +9 -1
- package/dist/bridge-status-controller.cjs +167 -21
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +6 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +6 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +167 -21
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +1 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +12 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -1
- package/dist/quote-status-manager/constants.cjs +181 -0
- package/dist/quote-status-manager/constants.cjs.map +1 -0
- package/dist/quote-status-manager/constants.d.cts +137 -0
- package/dist/quote-status-manager/constants.d.cts.map +1 -0
- package/dist/quote-status-manager/constants.d.mts +137 -0
- package/dist/quote-status-manager/constants.d.mts.map +1 -0
- package/dist/quote-status-manager/constants.mjs +178 -0
- package/dist/quote-status-manager/constants.mjs.map +1 -0
- package/dist/quote-status-manager/errors.cjs +51 -0
- package/dist/quote-status-manager/errors.cjs.map +1 -0
- package/dist/quote-status-manager/errors.d.cts +45 -0
- package/dist/quote-status-manager/errors.d.cts.map +1 -0
- package/dist/quote-status-manager/errors.d.mts +45 -0
- package/dist/quote-status-manager/errors.d.mts.map +1 -0
- package/dist/quote-status-manager/errors.mjs +46 -0
- package/dist/quote-status-manager/errors.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.cjs +241 -0
- package/dist/quote-status-manager/quote-status-api-service.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.d.cts +93 -0
- package/dist/quote-status-manager/quote-status-api-service.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.d.mts +93 -0
- package/dist/quote-status-manager/quote-status-api-service.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.mjs +237 -0
- package/dist/quote-status-manager/quote-status-api-service.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.cjs +271 -0
- package/dist/quote-status-manager/quote-status-entry-store.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.cts +144 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.mts +144 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.mjs +267 -0
- package/dist/quote-status-manager/quote-status-entry-store.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.cjs +29 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.cts +32 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.mts +32 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.mjs +25 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.cjs +107 -0
- package/dist/quote-status-manager/quote-status-state-fsm.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.cts +57 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.mts +57 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.mjs +103 -0
- package/dist/quote-status-manager/quote-status-state-fsm.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.cjs +27 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.cts +30 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.mts +30 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.mjs +23 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.mjs.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.cjs +477 -0
- package/dist/quote-status-manager/quotes-status-manager.cjs.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.d.cts +124 -0
- package/dist/quote-status-manager/quotes-status-manager.d.cts.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.d.mts +124 -0
- package/dist/quote-status-manager/quotes-status-manager.d.mts.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.mjs +473 -0
- package/dist/quote-status-manager/quotes-status-manager.mjs.map +1 -0
- package/dist/quote-status-manager/types.cjs +8 -0
- package/dist/quote-status-manager/types.cjs.map +1 -0
- package/dist/quote-status-manager/types.d.cts +145 -0
- package/dist/quote-status-manager/types.d.cts.map +1 -0
- package/dist/quote-status-manager/types.d.mts +145 -0
- package/dist/quote-status-manager/types.d.mts.map +1 -0
- package/dist/quote-status-manager/types.mjs +6 -0
- package/dist/quote-status-manager/types.mjs.map +1 -0
- package/dist/quote-status-manager/utils.cjs +11 -0
- package/dist/quote-status-manager/utils.cjs.map +1 -0
- package/dist/quote-status-manager/utils.d.cts +7 -0
- package/dist/quote-status-manager/utils.d.cts.map +1 -0
- package/dist/quote-status-manager/utils.d.mts +7 -0
- package/dist/quote-status-manager/utils.d.mts.map +1 -0
- package/dist/quote-status-manager/utils.mjs +7 -0
- package/dist/quote-status-manager/utils.mjs.map +1 -0
- package/dist/quote-status-manager/validators.cjs +44 -0
- package/dist/quote-status-manager/validators.cjs.map +1 -0
- package/dist/quote-status-manager/validators.d.cts +172 -0
- package/dist/quote-status-manager/validators.d.cts.map +1 -0
- package/dist/quote-status-manager/validators.d.mts +172 -0
- package/dist/quote-status-manager/validators.d.mts.map +1 -0
- package/dist/quote-status-manager/validators.mjs +39 -0
- package/dist/quote-status-manager/validators.mjs.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +15 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +15 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/history.cjs +1 -0
- package/dist/utils/history.cjs.map +1 -1
- package/dist/utils/history.d.cts.map +1 -1
- package/dist/utils/history.d.mts.map +1 -1
- package/dist/utils/history.mjs +1 -0
- package/dist/utils/history.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { QuoteStatusGetResponse, QuoteStatusUpdateResponse } from "./types.mjs";
|
|
2
|
+
export declare const QuoteStatusUpdateResponseSchema: import("@metamask/superstruct").Struct<{
|
|
3
|
+
type: import("./constants.mjs").QuoteStatusUpdateBackendErrorType.InvalidStatusTransaction | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.QuoteStatusOnChainMismatch;
|
|
4
|
+
message: string;
|
|
5
|
+
statusCode: number;
|
|
6
|
+
currentStatus: import("./constants.mjs").QuoteStatusBackendStatus;
|
|
7
|
+
newStatus: import("./constants.mjs").QuoteStatusBackendStatus;
|
|
8
|
+
} | {
|
|
9
|
+
type: import("./constants.mjs").QuoteStatusUpdateBackendErrorType.QuoteNotFound | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.ConcurrentUpdate | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.SrcTxHashRequiredForFinalized | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.PersistQuoteStatusFailed | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.TransactionNotIndexed | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.TxDataMissingHash | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.TxDataMissingTrade | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.TxDataMismatch | import("./constants.mjs").QuoteStatusUpdateBackendErrorType.SvmTradeDeserializeFailed;
|
|
10
|
+
message: string;
|
|
11
|
+
statusCode: number;
|
|
12
|
+
}, null>;
|
|
13
|
+
export declare function validateQuoteStatusUpdateResponse(data: unknown): asserts data is QuoteStatusUpdateResponse;
|
|
14
|
+
/**
|
|
15
|
+
* **Note**: This struct is big and not all fields are used atm.
|
|
16
|
+
* For that reason we have decided to only include the fields we
|
|
17
|
+
* consume in production. In the future, once we need it to be strongly type,
|
|
18
|
+
* we will refactor.
|
|
19
|
+
*/
|
|
20
|
+
export declare const QuoteStatusGetResponseSchema: import("@metamask/superstruct").Struct<{
|
|
21
|
+
submittedTx?: {
|
|
22
|
+
status: import("@metamask/bridge-controller").StatusTypes;
|
|
23
|
+
srcChain: {
|
|
24
|
+
chainId: number;
|
|
25
|
+
txHash?: string | undefined;
|
|
26
|
+
amount?: string | undefined;
|
|
27
|
+
token?: {} | {
|
|
28
|
+
symbol: string;
|
|
29
|
+
chainId: number;
|
|
30
|
+
address: string;
|
|
31
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
32
|
+
name: string;
|
|
33
|
+
decimals: number;
|
|
34
|
+
icon?: string | null | undefined;
|
|
35
|
+
iconUrl?: string | null | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
};
|
|
38
|
+
destChain?: {
|
|
39
|
+
chainId: number;
|
|
40
|
+
txHash?: string | undefined;
|
|
41
|
+
amount?: string | undefined;
|
|
42
|
+
token?: {} | {
|
|
43
|
+
symbol: string;
|
|
44
|
+
chainId: number;
|
|
45
|
+
address: string;
|
|
46
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
47
|
+
name: string;
|
|
48
|
+
decimals: number;
|
|
49
|
+
icon?: string | null | undefined;
|
|
50
|
+
iconUrl?: string | null | undefined;
|
|
51
|
+
} | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
bridge?: string | undefined;
|
|
54
|
+
isExpectedToken?: boolean | undefined;
|
|
55
|
+
isUnrecognizedRouterAddress?: boolean | undefined;
|
|
56
|
+
refuel?: {} | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
/**
|
|
60
|
+
* Submitted transaction: StatusResponseDto with at least srcChain (chainId + txHash).
|
|
61
|
+
* Prefilled by updateQuoteStatus; replaced with full provider status by getQuoteStatus.
|
|
62
|
+
*/
|
|
63
|
+
submittedTx: import("@metamask/superstruct").Struct<{
|
|
64
|
+
status: import("@metamask/bridge-controller").StatusTypes;
|
|
65
|
+
srcChain: {
|
|
66
|
+
chainId: number;
|
|
67
|
+
txHash?: string | undefined;
|
|
68
|
+
amount?: string | undefined;
|
|
69
|
+
token?: {} | {
|
|
70
|
+
symbol: string;
|
|
71
|
+
chainId: number;
|
|
72
|
+
address: string;
|
|
73
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
74
|
+
name: string;
|
|
75
|
+
decimals: number;
|
|
76
|
+
icon?: string | null | undefined;
|
|
77
|
+
iconUrl?: string | null | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
};
|
|
80
|
+
destChain?: {
|
|
81
|
+
chainId: number;
|
|
82
|
+
txHash?: string | undefined;
|
|
83
|
+
amount?: string | undefined;
|
|
84
|
+
token?: {} | {
|
|
85
|
+
symbol: string;
|
|
86
|
+
chainId: number;
|
|
87
|
+
address: string;
|
|
88
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
89
|
+
name: string;
|
|
90
|
+
decimals: number;
|
|
91
|
+
icon?: string | null | undefined;
|
|
92
|
+
iconUrl?: string | null | undefined;
|
|
93
|
+
} | undefined;
|
|
94
|
+
} | undefined;
|
|
95
|
+
bridge?: string | undefined;
|
|
96
|
+
isExpectedToken?: boolean | undefined;
|
|
97
|
+
isUnrecognizedRouterAddress?: boolean | undefined;
|
|
98
|
+
refuel?: {} | undefined;
|
|
99
|
+
} | undefined, {
|
|
100
|
+
status: import("@metamask/superstruct").Struct<import("@metamask/bridge-controller").StatusTypes, {
|
|
101
|
+
SUBMITTED: import("@metamask/bridge-controller").StatusTypes.SUBMITTED;
|
|
102
|
+
UNKNOWN: import("@metamask/bridge-controller").StatusTypes.UNKNOWN;
|
|
103
|
+
FAILED: import("@metamask/bridge-controller").StatusTypes.FAILED;
|
|
104
|
+
PENDING: import("@metamask/bridge-controller").StatusTypes.PENDING;
|
|
105
|
+
COMPLETE: import("@metamask/bridge-controller").StatusTypes.COMPLETE;
|
|
106
|
+
}>;
|
|
107
|
+
srcChain: import("@metamask/superstruct").Struct<{
|
|
108
|
+
chainId: number;
|
|
109
|
+
txHash?: string | undefined;
|
|
110
|
+
amount?: string | undefined;
|
|
111
|
+
token?: {} | {
|
|
112
|
+
symbol: string;
|
|
113
|
+
chainId: number;
|
|
114
|
+
address: string;
|
|
115
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
116
|
+
name: string;
|
|
117
|
+
decimals: number;
|
|
118
|
+
icon?: string | null | undefined;
|
|
119
|
+
iconUrl?: string | null | undefined;
|
|
120
|
+
} | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
chainId: import("@metamask/superstruct").Struct<number, null>;
|
|
123
|
+
txHash: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
124
|
+
amount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
125
|
+
token: import("@metamask/superstruct").Struct<{} | {
|
|
126
|
+
symbol: string;
|
|
127
|
+
chainId: number;
|
|
128
|
+
address: string;
|
|
129
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
130
|
+
name: string;
|
|
131
|
+
decimals: number;
|
|
132
|
+
icon?: string | null | undefined;
|
|
133
|
+
iconUrl?: string | null | undefined;
|
|
134
|
+
} | undefined, null>;
|
|
135
|
+
}>;
|
|
136
|
+
destChain: import("@metamask/superstruct").Struct<{
|
|
137
|
+
chainId: number;
|
|
138
|
+
txHash?: string | undefined;
|
|
139
|
+
amount?: string | undefined;
|
|
140
|
+
token?: {} | {
|
|
141
|
+
symbol: string;
|
|
142
|
+
chainId: number;
|
|
143
|
+
address: string;
|
|
144
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
145
|
+
name: string;
|
|
146
|
+
decimals: number;
|
|
147
|
+
icon?: string | null | undefined;
|
|
148
|
+
iconUrl?: string | null | undefined;
|
|
149
|
+
} | undefined;
|
|
150
|
+
} | undefined, {
|
|
151
|
+
chainId: import("@metamask/superstruct").Struct<number, null>;
|
|
152
|
+
txHash: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
153
|
+
amount: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
154
|
+
token: import("@metamask/superstruct").Struct<{} | {
|
|
155
|
+
symbol: string;
|
|
156
|
+
chainId: number;
|
|
157
|
+
address: string;
|
|
158
|
+
assetId: `${string}:${string}/${string}:${string}`;
|
|
159
|
+
name: string;
|
|
160
|
+
decimals: number;
|
|
161
|
+
icon?: string | null | undefined;
|
|
162
|
+
iconUrl?: string | null | undefined;
|
|
163
|
+
} | undefined, null>;
|
|
164
|
+
}>;
|
|
165
|
+
bridge: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
166
|
+
isExpectedToken: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
167
|
+
isUnrecognizedRouterAddress: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
168
|
+
refuel: import("@metamask/superstruct").Struct<{} | undefined, {}>;
|
|
169
|
+
}>;
|
|
170
|
+
}>;
|
|
171
|
+
export declare function validateQuoteStatusGetResponse(data: unknown): asserts data is QuoteStatusGetResponse;
|
|
172
|
+
//# sourceMappingURL=validators.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.mts","sourceRoot":"","sources":["../../src/quote-status-manager/validators.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,oBAAgB;AAgB5E,eAAO,MAAM,+BAA+B;;;;;;;;;;QAG1C,CAAC;AAEH,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,IAAI,IAAI,yBAAyB,CAE3C;AAED;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACvC;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAC;AAEH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,IAAI,IAAI,sBAAsB,CAExC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { string, number, enums, union, type, assert, optional } from "@metamask/superstruct";
|
|
2
|
+
import { StatusResponseSchema } from "../utils/validators.mjs";
|
|
3
|
+
import { BaseQuoteStatusUpdateErrorTypes, QuoteStatusUpdateBackendOnChainMismatchTypes, QuoteStatusBackendValues } from "./constants.mjs";
|
|
4
|
+
const QuoteStatusUpdateResponseWithCurrentStatusSchema = type({
|
|
5
|
+
statusCode: number(),
|
|
6
|
+
message: string(),
|
|
7
|
+
type: enums(QuoteStatusUpdateBackendOnChainMismatchTypes),
|
|
8
|
+
currentStatus: enums(QuoteStatusBackendValues),
|
|
9
|
+
newStatus: enums(QuoteStatusBackendValues),
|
|
10
|
+
});
|
|
11
|
+
const QuoteStatusUpdateResponseBaseSchema = type({
|
|
12
|
+
statusCode: number(),
|
|
13
|
+
message: string(),
|
|
14
|
+
type: enums(BaseQuoteStatusUpdateErrorTypes),
|
|
15
|
+
});
|
|
16
|
+
export const QuoteStatusUpdateResponseSchema = union([
|
|
17
|
+
QuoteStatusUpdateResponseWithCurrentStatusSchema,
|
|
18
|
+
QuoteStatusUpdateResponseBaseSchema,
|
|
19
|
+
]);
|
|
20
|
+
export function validateQuoteStatusUpdateResponse(data) {
|
|
21
|
+
assert(data, QuoteStatusUpdateResponseSchema);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* **Note**: This struct is big and not all fields are used atm.
|
|
25
|
+
* For that reason we have decided to only include the fields we
|
|
26
|
+
* consume in production. In the future, once we need it to be strongly type,
|
|
27
|
+
* we will refactor.
|
|
28
|
+
*/
|
|
29
|
+
export const QuoteStatusGetResponseSchema = type({
|
|
30
|
+
/**
|
|
31
|
+
* Submitted transaction: StatusResponseDto with at least srcChain (chainId + txHash).
|
|
32
|
+
* Prefilled by updateQuoteStatus; replaced with full provider status by getQuoteStatus.
|
|
33
|
+
*/
|
|
34
|
+
submittedTx: optional(StatusResponseSchema),
|
|
35
|
+
});
|
|
36
|
+
export function validateQuoteStatusGetResponse(data) {
|
|
37
|
+
assert(data, QuoteStatusGetResponseSchema);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=validators.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/quote-status-manager/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACT,8BAA8B;AAE/B,OAAO,EAAE,oBAAoB,EAAE,gCAA4B;AAC3D,OAAO,EACL,+BAA+B,EAC/B,4CAA4C,EAC5C,wBAAwB,EACzB,wBAAoB;AAGrB,MAAM,gDAAgD,GAAG,IAAI,CAAC;IAC5D,UAAU,EAAE,MAAM,EAAE;IACpB,OAAO,EAAE,MAAM,EAAE;IACjB,IAAI,EAAE,KAAK,CAAC,4CAA4C,CAAC;IACzD,aAAa,EAAE,KAAK,CAAC,wBAAwB,CAAC;IAC9C,SAAS,EAAE,KAAK,CAAC,wBAAwB,CAAC;CAC3C,CAAC,CAAC;AAEH,MAAM,mCAAmC,GAAG,IAAI,CAAC;IAC/C,UAAU,EAAE,MAAM,EAAE;IACpB,OAAO,EAAE,MAAM,EAAE;IACjB,IAAI,EAAE,KAAK,CAAC,+BAA+B,CAAC;CAC7C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;IACnD,gDAAgD;IAChD,mCAAmC;CACpC,CAAC,CAAC;AAEH,MAAM,UAAU,iCAAiC,CAC/C,IAAa;IAEb,MAAM,CAAC,IAAI,EAAE,+BAA+B,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC;CAC5C,CAAC,CAAC;AAEH,MAAM,UAAU,8BAA8B,CAC5C,IAAa;IAEb,MAAM,CAAC,IAAI,EAAE,4BAA4B,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {\n string,\n number,\n enums,\n union,\n type,\n assert,\n optional,\n} from '@metamask/superstruct';\n\nimport { StatusResponseSchema } from '../utils/validators';\nimport {\n BaseQuoteStatusUpdateErrorTypes,\n QuoteStatusUpdateBackendOnChainMismatchTypes,\n QuoteStatusBackendValues,\n} from './constants';\nimport { QuoteStatusGetResponse, QuoteStatusUpdateResponse } from './types';\n\nconst QuoteStatusUpdateResponseWithCurrentStatusSchema = type({\n statusCode: number(),\n message: string(),\n type: enums(QuoteStatusUpdateBackendOnChainMismatchTypes),\n currentStatus: enums(QuoteStatusBackendValues),\n newStatus: enums(QuoteStatusBackendValues),\n});\n\nconst QuoteStatusUpdateResponseBaseSchema = type({\n statusCode: number(),\n message: string(),\n type: enums(BaseQuoteStatusUpdateErrorTypes),\n});\n\nexport const QuoteStatusUpdateResponseSchema = union([\n QuoteStatusUpdateResponseWithCurrentStatusSchema,\n QuoteStatusUpdateResponseBaseSchema,\n]);\n\nexport function validateQuoteStatusUpdateResponse(\n data: unknown,\n): asserts data is QuoteStatusUpdateResponse {\n assert(data, QuoteStatusUpdateResponseSchema);\n}\n\n/**\n * **Note**: This struct is big and not all fields are used atm.\n * For that reason we have decided to only include the fields we\n * consume in production. In the future, once we need it to be strongly type,\n * we will refactor.\n */\nexport const QuoteStatusGetResponseSchema = type({\n /**\n * Submitted transaction: StatusResponseDto with at least srcChain (chainId + txHash).\n * Prefilled by updateQuoteStatus; replaced with full provider status by getQuoteStatus.\n */\n submittedTx: optional(StatusResponseSchema),\n});\n\nexport function validateQuoteStatusGetResponse(\n data: unknown,\n): asserts data is QuoteStatusGetResponse {\n assert(data, QuoteStatusGetResponseSchema);\n}\n"]}
|
package/dist/types.cjs
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BridgeStatusAction = exports.BridgeId = exports.BridgeClientId = void 0;
|
|
4
4
|
const constants_1 = require("./constants.cjs");
|
|
5
|
+
const constants_2 = require("./quote-status-manager/constants.cjs");
|
|
6
|
+
const validators_1 = require("./utils/validators.cjs");
|
|
5
7
|
// All fields need to be types not interfaces, same with their children fields
|
|
6
8
|
// o/w you get a type error
|
|
7
9
|
var BridgeClientId;
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA6CA,+CAA4D;AAG5D,8EAA8E;AAC9E,2BAA2B;AAE3B,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAyCD,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,2BAAe,CAAA;IACf,uCAA2B,CAAA;IAC3B,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,mCAAuB,CAAA;IACvB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,CAAC,EAbW,QAAQ,wBAAR,QAAQ,QAanB;AA8GD;;;GAGG;AACH,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC5B,qFAA+D,CAAA;IAC/D,2DAAqC,CAAA;IACrC,2CAAqB,CAAA;IACrB,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;IACrB,mDAA6B,CAAA;IAC7B,yFAAmE,CAAA;IACnE,uFAAiE,CAAA;AACnE,CAAC,EATW,kBAAkB,kCAAlB,kBAAkB,QAS7B","sourcesContent":["import type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type {\n ChainId,\n FeatureId,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n MetaMetricsSwapsEventSource,\n SimulatedGasFeeLimits,\n TxData,\n TxFeeGasLimits,\n BridgeControllerTrackUnifiedSwapBridgeEventAction,\n BridgeControllerStopPollingForQuotesAction,\n BatchSellTradesResponse,\n BridgeControllerGetStateAction,\n InputPrimaryDenomination,\n} from '@metamask/bridge-controller';\nimport type { KeyringControllerSignTypedMessageAction } from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusControllerMethodActions } from './bridge-status-controller-method-action-types';\nimport { BRIDGE_STATUS_CONTROLLER_NAME } from './constants';\nimport type { StatusResponseSchema } from './utils/validators';\n\n// All fields need to be types not interfaces, same with their children fields\n// o/w you get a type error\n\nexport enum BridgeClientId {\n EXTENSION = 'extension',\n MOBILE = 'mobile',\n}\n\nexport type FetchFunction = (\n input: RequestInfo | URL,\n init?: RequestInit,\n) => Promise<unknown>;\n\n/**\n * These fields are specific to Solana transactions and can likely be infered from TransactionMeta\n *\n * @deprecated these should be removed eventually\n */\nexport type SolanaTransactionMeta = {\n isSolana: boolean;\n isBridgeTx: boolean;\n};\n\nexport type StatusRequest = {\n bridgeId: string; // lifi, socket, squid\n srcTxHash?: string; // lifi, socket, squid, might be undefined for STX\n bridge: string; // lifi, socket, squid\n srcChainId: ChainId; // lifi, socket, squid\n destChainId: ChainId; // lifi, socket, squid\n quote?: Quote; // squid\n refuel?: boolean; // lifi\n};\n\nexport type StatusRequestDto = Omit<\n StatusRequest,\n 'quote' | 'srcChainId' | 'destChainId' | 'refuel'\n> & {\n srcChainId: string; // lifi, socket, squid\n destChainId: string; // lifi, socket, squid\n requestId?: string;\n refuel?: string; // lifi\n};\n\nexport type StatusRequestWithSrcTxHash = StatusRequest & {\n srcTxHash: string;\n};\n\nexport enum BridgeId {\n HOP = 'hop',\n CELER = 'celer',\n CELERCIRCLE = 'celercircle',\n CONNEXT = 'connext',\n POLYGON = 'polygon',\n AVALANCHE = 'avalanche',\n MULTICHAIN = 'multichain',\n AXELAR = 'axelar',\n ACROSS = 'across',\n STARGATE = 'stargate',\n RELAY = 'relay',\n MAYAN = 'mayan',\n}\n\nexport type StatusResponse = Infer<typeof StatusResponseSchema>;\n\nexport type RefuelStatusResponse = object & StatusResponse;\n\n/**\n * This type ties together the quote, its tx params and the submitted txMeta.\n * Each trade/approval will have its own QuoteAndTxMetadata object.\n */\nexport type QuoteAndTxMetadata = {\n type: TransactionType;\n quoteResponse: QuoteResponse & QuoteMetadata;\n /**\n * The approval or trade object from the quote response\n */\n tx: TxData;\n assetsFiatValues?: { sending?: string; receiving?: string };\n /**\n * The simulated gas fee limits for the transaction provided by the bridge-api\n */\n txFee?: SimulatedGasFeeLimits | TxFeeGasLimits;\n /**\n * Transaction metadata from the TransactionController after submission\n */\n txMeta?: TransactionMeta;\n};\n\nexport type BridgeHistoryItem = {\n txMetaId?: string; // Optional: not available pre-submission or on sync failure\n actionId?: string; // Only for non-batch EVM transactions\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string; // Keep original transaction ID for intent transactions\n batchId?: string;\n /**\n * This is defined when the history item is for a batch sell transaction\n */\n batchSellData?: BatchSellTradesResponse;\n /**\n * This is defined when the history item corresponds to the 7702 batch's delegation tx.\n * It contains the list of quoteIds for the BatchSell quotes that are part of the 7702 batch.\n * Each quote can be retrieved from txHistory as `txHistory[quoteId]`.\n */\n quoteIds?: string[];\n quote: Quote;\n status: StatusResponse;\n startTime: number; // timestamp in ms\n estimatedProcessingTimeInSeconds: number;\n slippagePercentage: number;\n completionTime?: number; // timestamp in ms\n pricingData?: {\n /**\n * The actual amount sent by user in non-atomic decimal form\n */\n amountSent: QuoteMetadata['sentAmount']['amount'];\n amountSentInUsd?: QuoteMetadata['sentAmount']['usd'];\n quotedGasInUsd?: QuoteMetadata['gasFee']['effective']['usd'];\n quotedGasAmount?: QuoteMetadata['gasFee']['effective']['amount'];\n quotedReturnInUsd?: QuoteMetadata['toTokenAmount']['usd'];\n quotedRefuelSrcAmountInUsd?: string;\n quotedRefuelDestAmountInUsd?: string;\n };\n initialDestAssetBalance?: string;\n targetContractAddress?: string;\n account: string;\n hasApprovalTx: boolean;\n approvalTxId?: string;\n featureId?: FeatureId;\n isStxEnabled?: boolean;\n /**\n * The location/entry point from which the user initiated the swap or bridge.\n * Used to attribute swaps to specific flows (e.g. Trending Explore).\n */\n location?: MetaMetricsSwapsEventSource;\n /**\n * Legacy A/B test metrics context (`ab_tests`) kept for backward compatibility.\n * Keys are test names, values are variant names (e.g. { token_details_layout: 'treatment' }).\n */\n abTests?: Record<string, string>;\n /**\n * New A/B test metrics context (`active_ab_tests`) that replaces `ab_tests`.\n * Kept separate so migration can run both payloads in parallel.\n * This field is an array of test objects.\n */\n activeAbTests?: { key: string; value: string }[];\n /**\n * Attempts tracking for exponential backoff on failed fetches.\n * We track the number of attempts and the last attempt time for each txMetaId that has failed at least once\n */\n attempts?: {\n counter: number;\n lastAttemptTime: number; // timestamp in ms\n };\n /**\n * Client-supplied security classification for the destination token at the\n * time the swap/bridge was submitted. Persisted so post-submit analytics\n * events (Completed, Failed, StatusValidationFailed) can include\n * `token_security_type_destination`. `null` when no security data was\n * available for the destination token.\n */\n tokenSecurityTypeDestination?: string | null;\n /**\n * The denomination shown as the primary source amount input when the\n * swap/bridge was submitted.\n */\n inputPrimaryDenomination?: InputPrimaryDenomination;\n};\n\n/**\n * @deprecated Use the separate action types instead (e.g.\n * `BridgeStatusControllerStartPollingForBridgeTxStatusAction`).\n */\nexport enum BridgeStatusAction {\n StartPollingForBridgeTxStatus = 'StartPollingForBridgeTxStatus',\n WipeBridgeStatus = 'WipeBridgeStatus',\n GetState = 'GetState',\n ResetState = 'ResetState',\n SubmitTx = 'SubmitTx',\n SubmitIntent = 'SubmitIntent',\n RestartPollingForFailedAttempts = 'RestartPollingForFailedAttempts',\n GetBridgeHistoryItemByTxMetaId = 'GetBridgeHistoryItemByTxMetaId',\n}\n\nexport type TokenAmountValuesSerialized = {\n amount: string;\n valueInCurrency: string | null;\n usd: string | null;\n};\n\nexport type QuoteMetadataSerialized = {\n gasFee: TokenAmountValuesSerialized;\n /**\n * The total network fee for the bridge transaction\n * estimatedGasFees + relayerFees\n */\n totalNetworkFee: TokenAmountValuesSerialized;\n /**\n * The total max network fee for the bridge transaction\n * maxGasFees + relayerFees\n */\n totalMaxNetworkFee: TokenAmountValuesSerialized;\n toTokenAmount: TokenAmountValuesSerialized;\n /**\n * The adjusted return for the bridge transaction\n * destTokenAmount - totalNetworkFee\n */\n adjustedReturn: Omit<TokenAmountValuesSerialized, 'amount'>;\n /**\n * The actual amount sent by user in non-atomic decimal form\n * srcTokenAmount + metabridgeFee\n */\n sentAmount: TokenAmountValuesSerialized;\n swapRate: string; // destTokenAmount / sentAmount\n /**\n * The cost of the bridge transaction\n * sentAmount - adjustedReturn\n */\n cost: Omit<TokenAmountValuesSerialized, 'amount'>;\n};\n\nexport type StartPollingForBridgeTxStatusArgs = {\n bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;\n actionId?: string;\n batchSellData?: BridgeHistoryItem['batchSellData'];\n quoteIds?: BridgeHistoryItem['quoteIds'];\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string;\n quoteResponse: QuoteResponse & QuoteMetadata;\n startTime: BridgeHistoryItem['startTime'];\n slippagePercentage: BridgeHistoryItem['slippagePercentage'];\n initialDestAssetBalance?: BridgeHistoryItem['initialDestAssetBalance'];\n targetContractAddress?: BridgeHistoryItem['targetContractAddress'];\n approvalTxId?: BridgeHistoryItem['approvalTxId'];\n isStxEnabled?: BridgeHistoryItem['isStxEnabled'];\n location: MetaMetricsSwapsEventSource;\n // Legacy field for `ab_tests` metrics payload.\n abTests?: BridgeHistoryItem['abTests'];\n // New field for `active_ab_tests` metrics payload.\n activeAbTests?: BridgeHistoryItem['activeAbTests'];\n accountAddress: string;\n // Client-supplied destination token security classification, persisted on\n // the history item for post-submit analytics events.\n tokenSecurityTypeDestination?: BridgeHistoryItem['tokenSecurityTypeDestination'];\n // Primary denomination at submission time, persisted for post-submit analytics.\n inputPrimaryDenomination?: BridgeHistoryItem['inputPrimaryDenomination'];\n};\n\n/**\n * Chrome: The BigNumber values are automatically serialized to strings when sent to the background\n * Firefox: The BigNumber values are not serialized to strings when sent to the background,\n * so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action\n */\nexport type StartPollingForBridgeTxStatusArgsSerialized = Omit<\n StartPollingForBridgeTxStatusArgs,\n 'quoteResponse'\n> & {\n quoteResponse: QuoteResponse & QuoteMetadata;\n};\n\nexport type SourceChainTxMetaId = string;\n\nexport type BridgeStatusControllerState = {\n txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;\n};\n\n// Actions\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerMethodActions;\n\n// Events\nexport type BridgeStatusControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n/**\n * This event is published when the destination bridge transaction is completed\n * The payload is the asset received on the destination chain\n */\nexport type BridgeStatusControllerDestinationTransactionCompletedEvent = {\n type: 'BridgeStatusController:destinationTransactionCompleted';\n payload: [CaipAssetType];\n};\n\nexport type BridgeStatusControllerEvents =\n | BridgeStatusControllerStateChangeEvent\n | BridgeStatusControllerDestinationTransactionCompletedEvent;\n\n/**\n * The external actions available to the BridgeStatusController.\n */\ntype AllowedActions =\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | SnapControllerHandleRequestAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerGetStateAction\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent;\n\n/**\n * The messenger for the BridgeStatusController.\n */\nexport type BridgeStatusControllerMessenger = Messenger<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerActions | AllowedActions,\n BridgeStatusControllerEvents | AllowedEvents\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA8CA,+CAA4D;AAC5D,oEAAoE;AACpE,uDAA0D;AAE1D,8EAA8E;AAC9E,2BAA2B;AAE3B,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAyCD,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,2BAAe,CAAA;IACf,uCAA2B,CAAA;IAC3B,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,mCAAuB,CAAA;IACvB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,CAAC,EAbW,QAAQ,wBAAR,QAAQ,QAanB;AAgHD;;;GAGG;AACH,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC5B,qFAA+D,CAAA;IAC/D,2DAAqC,CAAA;IACrC,2CAAqB,CAAA;IACrB,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;IACrB,mDAA6B,CAAA;IAC7B,yFAAmE,CAAA;IACnE,uFAAiE,CAAA;AACnE,CAAC,EATW,kBAAkB,kCAAlB,kBAAkB,QAS7B","sourcesContent":["import type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type {\n ChainId,\n FeatureId,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n MetaMetricsSwapsEventSource,\n SimulatedGasFeeLimits,\n TxData,\n TxFeeGasLimits,\n BridgeControllerTrackUnifiedSwapBridgeEventAction,\n BridgeControllerStopPollingForQuotesAction,\n BatchSellTradesResponse,\n BridgeControllerGetStateAction,\n InputPrimaryDenomination,\n} from '@metamask/bridge-controller';\nimport type { KeyringControllerSignTypedMessageAction } from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerTransactionSubmittedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusControllerMethodActions } from './bridge-status-controller-method-action-types';\nimport { BRIDGE_STATUS_CONTROLLER_NAME } from './constants';\nimport { QuoteStatusState } from './quote-status-manager/constants';\nimport { StatusResponseSchema } from './utils/validators';\n\n// All fields need to be types not interfaces, same with their children fields\n// o/w you get a type error\n\nexport enum BridgeClientId {\n EXTENSION = 'extension',\n MOBILE = 'mobile',\n}\n\nexport type FetchFunction = (\n input: RequestInfo | URL,\n init?: RequestInit,\n) => Promise<unknown>;\n\n/**\n * These fields are specific to Solana transactions and can likely be infered from TransactionMeta\n *\n * @deprecated these should be removed eventually\n */\nexport type SolanaTransactionMeta = {\n isSolana: boolean;\n isBridgeTx: boolean;\n};\n\nexport type StatusRequest = {\n bridgeId: string; // lifi, socket, squid\n srcTxHash?: string; // lifi, socket, squid, might be undefined for STX\n bridge: string; // lifi, socket, squid\n srcChainId: ChainId; // lifi, socket, squid\n destChainId: ChainId; // lifi, socket, squid\n quote?: Quote; // squid\n refuel?: boolean; // lifi\n};\n\nexport type StatusRequestDto = Omit<\n StatusRequest,\n 'quote' | 'srcChainId' | 'destChainId' | 'refuel'\n> & {\n srcChainId: string; // lifi, socket, squid\n destChainId: string; // lifi, socket, squid\n requestId?: string;\n refuel?: string; // lifi\n};\n\nexport type StatusRequestWithSrcTxHash = StatusRequest & {\n srcTxHash: string;\n};\n\nexport enum BridgeId {\n HOP = 'hop',\n CELER = 'celer',\n CELERCIRCLE = 'celercircle',\n CONNEXT = 'connext',\n POLYGON = 'polygon',\n AVALANCHE = 'avalanche',\n MULTICHAIN = 'multichain',\n AXELAR = 'axelar',\n ACROSS = 'across',\n STARGATE = 'stargate',\n RELAY = 'relay',\n MAYAN = 'mayan',\n}\n\nexport type StatusResponse = Infer<typeof StatusResponseSchema>;\n\nexport type RefuelStatusResponse = object & StatusResponse;\n\n/**\n * This type ties together the quote, its tx params and the submitted txMeta.\n * Each trade/approval will have its own QuoteAndTxMetadata object.\n */\nexport type QuoteAndTxMetadata = {\n type: TransactionType;\n quoteResponse: QuoteResponse & QuoteMetadata;\n /**\n * The approval or trade object from the quote response\n */\n tx: TxData;\n assetsFiatValues?: { sending?: string; receiving?: string };\n /**\n * The simulated gas fee limits for the transaction provided by the bridge-api\n */\n txFee?: SimulatedGasFeeLimits | TxFeeGasLimits;\n /**\n * Transaction metadata from the TransactionController after submission\n */\n txMeta?: TransactionMeta;\n};\n\nexport type BridgeHistoryItem = {\n txMetaId?: string; // Optional: not available pre-submission or on sync failure\n actionId?: string; // Only for non-batch EVM transactions\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string; // Keep original transaction ID for intent transactions\n batchId?: string;\n /**\n * This is defined when the history item is for a batch sell transaction\n */\n batchSellData?: BatchSellTradesResponse;\n /**\n * This is defined when the history item corresponds to the 7702 batch's delegation tx.\n * It contains the list of quoteIds for the BatchSell quotes that are part of the 7702 batch.\n * Each quote can be retrieved from txHistory as `txHistory[quoteId]`.\n */\n quoteIds?: string[];\n quote: Quote;\n quoteId?: string; // Optional: absent on history items persisted before this field was introduced\n reportedSubmittedTxHash?: string;\n status: StatusResponse;\n startTime: number; // timestamp in ms\n estimatedProcessingTimeInSeconds: number;\n slippagePercentage: number;\n completionTime?: number; // timestamp in ms\n pricingData?: {\n /**\n * The actual amount sent by user in non-atomic decimal form\n */\n amountSent: QuoteMetadata['sentAmount']['amount'];\n amountSentInUsd?: QuoteMetadata['sentAmount']['usd'];\n quotedGasInUsd?: QuoteMetadata['gasFee']['effective']['usd'];\n quotedGasAmount?: QuoteMetadata['gasFee']['effective']['amount'];\n quotedReturnInUsd?: QuoteMetadata['toTokenAmount']['usd'];\n quotedRefuelSrcAmountInUsd?: string;\n quotedRefuelDestAmountInUsd?: string;\n };\n initialDestAssetBalance?: string;\n targetContractAddress?: string;\n account: string;\n hasApprovalTx: boolean;\n approvalTxId?: string;\n featureId?: FeatureId;\n isStxEnabled?: boolean;\n /**\n * The location/entry point from which the user initiated the swap or bridge.\n * Used to attribute swaps to specific flows (e.g. Trending Explore).\n */\n location?: MetaMetricsSwapsEventSource;\n /**\n * Legacy A/B test metrics context (`ab_tests`) kept for backward compatibility.\n * Keys are test names, values are variant names (e.g. { token_details_layout: 'treatment' }).\n */\n abTests?: Record<string, string>;\n /**\n * New A/B test metrics context (`active_ab_tests`) that replaces `ab_tests`.\n * Kept separate so migration can run both payloads in parallel.\n * This field is an array of test objects.\n */\n activeAbTests?: { key: string; value: string }[];\n /**\n * Attempts tracking for exponential backoff on failed fetches.\n * We track the number of attempts and the last attempt time for each txMetaId that has failed at least once\n */\n attempts?: {\n counter: number;\n lastAttemptTime: number; // timestamp in ms\n };\n /**\n * Client-supplied security classification for the destination token at the\n * time the swap/bridge was submitted. Persisted so post-submit analytics\n * events (Completed, Failed, StatusValidationFailed) can include\n * `token_security_type_destination`. `null` when no security data was\n * available for the destination token.\n */\n tokenSecurityTypeDestination?: string | null;\n /**\n * The denomination shown as the primary source amount input when the\n * swap/bridge was submitted.\n */\n inputPrimaryDenomination?: InputPrimaryDenomination;\n};\n\n/**\n * @deprecated Use the separate action types instead (e.g.\n * `BridgeStatusControllerStartPollingForBridgeTxStatusAction`).\n */\nexport enum BridgeStatusAction {\n StartPollingForBridgeTxStatus = 'StartPollingForBridgeTxStatus',\n WipeBridgeStatus = 'WipeBridgeStatus',\n GetState = 'GetState',\n ResetState = 'ResetState',\n SubmitTx = 'SubmitTx',\n SubmitIntent = 'SubmitIntent',\n RestartPollingForFailedAttempts = 'RestartPollingForFailedAttempts',\n GetBridgeHistoryItemByTxMetaId = 'GetBridgeHistoryItemByTxMetaId',\n}\n\nexport type TokenAmountValuesSerialized = {\n amount: string;\n valueInCurrency: string | null;\n usd: string | null;\n};\n\nexport type QuoteMetadataSerialized = {\n gasFee: TokenAmountValuesSerialized;\n /**\n * The total network fee for the bridge transaction\n * estimatedGasFees + relayerFees\n */\n totalNetworkFee: TokenAmountValuesSerialized;\n /**\n * The total max network fee for the bridge transaction\n * maxGasFees + relayerFees\n */\n totalMaxNetworkFee: TokenAmountValuesSerialized;\n toTokenAmount: TokenAmountValuesSerialized;\n /**\n * The adjusted return for the bridge transaction\n * destTokenAmount - totalNetworkFee\n */\n adjustedReturn: Omit<TokenAmountValuesSerialized, 'amount'>;\n /**\n * The actual amount sent by user in non-atomic decimal form\n * srcTokenAmount + metabridgeFee\n */\n sentAmount: TokenAmountValuesSerialized;\n swapRate: string; // destTokenAmount / sentAmount\n /**\n * The cost of the bridge transaction\n * sentAmount - adjustedReturn\n */\n cost: Omit<TokenAmountValuesSerialized, 'amount'>;\n};\n\nexport type StartPollingForBridgeTxStatusArgs = {\n bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;\n actionId?: string;\n batchSellData?: BridgeHistoryItem['batchSellData'];\n quoteIds?: BridgeHistoryItem['quoteIds'];\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string;\n quoteResponse: QuoteResponse & QuoteMetadata;\n startTime: BridgeHistoryItem['startTime'];\n slippagePercentage: BridgeHistoryItem['slippagePercentage'];\n initialDestAssetBalance?: BridgeHistoryItem['initialDestAssetBalance'];\n targetContractAddress?: BridgeHistoryItem['targetContractAddress'];\n approvalTxId?: BridgeHistoryItem['approvalTxId'];\n isStxEnabled?: BridgeHistoryItem['isStxEnabled'];\n location: MetaMetricsSwapsEventSource;\n // Legacy field for `ab_tests` metrics payload.\n abTests?: BridgeHistoryItem['abTests'];\n // New field for `active_ab_tests` metrics payload.\n activeAbTests?: BridgeHistoryItem['activeAbTests'];\n accountAddress: string;\n // Client-supplied destination token security classification, persisted on\n // the history item for post-submit analytics events.\n tokenSecurityTypeDestination?: BridgeHistoryItem['tokenSecurityTypeDestination'];\n // Primary denomination at submission time, persisted for post-submit analytics.\n inputPrimaryDenomination?: BridgeHistoryItem['inputPrimaryDenomination'];\n};\n\n/**\n * Chrome: The BigNumber values are automatically serialized to strings when sent to the background\n * Firefox: The BigNumber values are not serialized to strings when sent to the background,\n * so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action\n */\nexport type StartPollingForBridgeTxStatusArgsSerialized = Omit<\n StartPollingForBridgeTxStatusArgs,\n 'quoteResponse'\n> & {\n quoteResponse: QuoteResponse & QuoteMetadata;\n};\n\nexport type SourceChainTxMetaId = string;\n\nexport type QuoteStatusPersistEntry = {\n quoteId: string;\n srcTxHash: string;\n status: QuoteStatusState;\n createdAt: number;\n lastAttemptAt: number;\n txMetaId?: string;\n};\n\nexport type BridgeStatusControllerState = {\n txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;\n quoteUpdateStatusStore: Record<string, QuoteStatusPersistEntry>;\n};\n\n// Actions\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerMethodActions;\n\n// Events\nexport type BridgeStatusControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n/**\n * This event is published when the destination bridge transaction is completed\n * The payload is the asset received on the destination chain\n */\nexport type BridgeStatusControllerDestinationTransactionCompletedEvent = {\n type: 'BridgeStatusController:destinationTransactionCompleted';\n payload: [CaipAssetType];\n};\n\nexport type BridgeStatusControllerEvents =\n | BridgeStatusControllerStateChangeEvent\n | BridgeStatusControllerDestinationTransactionCompletedEvent;\n\n/**\n * The external actions available to the BridgeStatusController.\n */\ntype AllowedActions =\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | SnapControllerHandleRequestAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerGetStateAction\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents =\n | TransactionControllerTransactionStatusUpdatedEvent\n | TransactionControllerTransactionSubmittedEvent;\n\n/**\n * The messenger for the BridgeStatusController.\n */\nexport type BridgeStatusControllerMessenger = Messenger<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerActions | AllowedActions,\n BridgeStatusControllerEvents | AllowedEvents\n>;\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -8,11 +8,12 @@ import type { AuthenticationControllerGetBearerTokenAction } from "@metamask/pro
|
|
|
8
8
|
import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
|
|
9
9
|
import type { SnapControllerHandleRequestAction } from "@metamask/snaps-controllers";
|
|
10
10
|
import type { Infer } from "@metamask/superstruct";
|
|
11
|
-
import type { TransactionControllerAddTransactionAction, TransactionControllerEstimateGasFeeAction, TransactionControllerGetStateAction, TransactionControllerIsAtomicBatchSupportedAction, TransactionControllerTransactionStatusUpdatedEvent, TransactionControllerUpdateTransactionAction, TransactionMeta, TransactionType } from "@metamask/transaction-controller";
|
|
11
|
+
import type { TransactionControllerAddTransactionAction, TransactionControllerEstimateGasFeeAction, TransactionControllerGetStateAction, TransactionControllerIsAtomicBatchSupportedAction, TransactionControllerTransactionStatusUpdatedEvent, TransactionControllerTransactionSubmittedEvent, TransactionControllerUpdateTransactionAction, TransactionMeta, TransactionType } from "@metamask/transaction-controller";
|
|
12
12
|
import type { CaipAssetType } from "@metamask/utils";
|
|
13
13
|
import type { BridgeStatusControllerMethodActions } from "./bridge-status-controller-method-action-types.cjs";
|
|
14
14
|
import { BRIDGE_STATUS_CONTROLLER_NAME } from "./constants.cjs";
|
|
15
|
-
import
|
|
15
|
+
import { QuoteStatusState } from "./quote-status-manager/constants.cjs";
|
|
16
|
+
import { StatusResponseSchema } from "./utils/validators.cjs";
|
|
16
17
|
export declare enum BridgeClientId {
|
|
17
18
|
EXTENSION = "extension",
|
|
18
19
|
MOBILE = "mobile"
|
|
@@ -104,6 +105,8 @@ export type BridgeHistoryItem = {
|
|
|
104
105
|
*/
|
|
105
106
|
quoteIds?: string[];
|
|
106
107
|
quote: Quote;
|
|
108
|
+
quoteId?: string;
|
|
109
|
+
reportedSubmittedTxHash?: string;
|
|
107
110
|
status: StatusResponse;
|
|
108
111
|
startTime: number;
|
|
109
112
|
estimatedProcessingTimeInSeconds: number;
|
|
@@ -250,8 +253,17 @@ export type StartPollingForBridgeTxStatusArgsSerialized = Omit<StartPollingForBr
|
|
|
250
253
|
quoteResponse: QuoteResponse & QuoteMetadata;
|
|
251
254
|
};
|
|
252
255
|
export type SourceChainTxMetaId = string;
|
|
256
|
+
export type QuoteStatusPersistEntry = {
|
|
257
|
+
quoteId: string;
|
|
258
|
+
srcTxHash: string;
|
|
259
|
+
status: QuoteStatusState;
|
|
260
|
+
createdAt: number;
|
|
261
|
+
lastAttemptAt: number;
|
|
262
|
+
txMetaId?: string;
|
|
263
|
+
};
|
|
253
264
|
export type BridgeStatusControllerState = {
|
|
254
265
|
txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;
|
|
266
|
+
quoteUpdateStatusStore: Record<string, QuoteStatusPersistEntry>;
|
|
255
267
|
};
|
|
256
268
|
export type BridgeStatusControllerGetStateAction = ControllerGetStateAction<typeof BRIDGE_STATUS_CONTROLLER_NAME, BridgeStatusControllerState>;
|
|
257
269
|
export type BridgeStatusControllerActions = BridgeStatusControllerGetStateAction | BridgeStatusControllerMethodActions;
|
|
@@ -272,7 +284,7 @@ type AllowedActions = NetworkControllerFindNetworkClientIdByChainIdAction | Netw
|
|
|
272
284
|
/**
|
|
273
285
|
* The external events available to the BridgeStatusController.
|
|
274
286
|
*/
|
|
275
|
-
type AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent;
|
|
287
|
+
type AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent | TransactionControllerTransactionSubmittedEvent;
|
|
276
288
|
/**
|
|
277
289
|
* The messenger for the BridgeStatusController.
|
|
278
290
|
*/
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2CAA2C,EAAE,sCAAsC;AACjG,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,EACN,cAAc,EACd,iDAAiD,EACjD,0CAA0C,EAC1C,uBAAuB,EACvB,8BAA8B,EAC9B,wBAAwB,EACzB,oCAAoC;AACrC,OAAO,KAAK,EAAE,uCAAuC,EAAE,qCAAqC;AAC5F,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CAA2C,EAC3C,+BAA+B,EAChC,qCAAqC;AACtC,OAAO,KAAK,EAAE,4CAA4C,EAAE,+CAA+C;AAC3G,OAAO,KAAK,EAAE,yCAAyC,EAAE,iDAAiD;AAC1G,OAAO,KAAK,EAAE,iCAAiC,EAAE,oCAAoC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AACnD,OAAO,KAAK,EACV,yCAAyC,EACzC,yCAAyC,EACzC,mCAAmC,EACnC,iDAAiD,EACjD,kDAAkD,EAClD,4CAA4C,EAC5C,eAAe,EACf,eAAe,EAChB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD,OAAO,KAAK,EAAE,mCAAmC,EAAE,2DAAuD;AAC1G,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sour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O,EAAE,CAAC,aAAa,CAAC,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,4BAA4B,GACpC,sCAAsC,GACtC,0DAA0D,CAAC;AAE/D;;GAEG;AACH,KAAK,cAAc,GACf,mDAAmD,GACnD,+BAA+B,GAC/B,2CAA2C,GAC3C,yCAAyC,GACzC,iCAAiC,GACjC,mCAAmC,GACnC,4CAA4C,GAC5C,yCAAyC,GACzC,yCAAyC,GACzC,iDAAiD,GACjD,iDAAiD,GACjD,0CAA0C,GAC1C,8BAA8B,GAC9B,2CAA2C,GAC3C,4CAA4C,GAC5C,uCAAuC,CAAC;AAE5C;;GAEG;AACH,KAAK,aAAa,GACd,kDAAkD,GAClD,8CAA8C,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,6BAA6B,EACpC,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -8,11 +8,12 @@ import type { AuthenticationControllerGetBearerTokenAction } from "@metamask/pro
|
|
|
8
8
|
import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
|
|
9
9
|
import type { SnapControllerHandleRequestAction } from "@metamask/snaps-controllers";
|
|
10
10
|
import type { Infer } from "@metamask/superstruct";
|
|
11
|
-
import type { TransactionControllerAddTransactionAction, TransactionControllerEstimateGasFeeAction, TransactionControllerGetStateAction, TransactionControllerIsAtomicBatchSupportedAction, TransactionControllerTransactionStatusUpdatedEvent, TransactionControllerUpdateTransactionAction, TransactionMeta, TransactionType } from "@metamask/transaction-controller";
|
|
11
|
+
import type { TransactionControllerAddTransactionAction, TransactionControllerEstimateGasFeeAction, TransactionControllerGetStateAction, TransactionControllerIsAtomicBatchSupportedAction, TransactionControllerTransactionStatusUpdatedEvent, TransactionControllerTransactionSubmittedEvent, TransactionControllerUpdateTransactionAction, TransactionMeta, TransactionType } from "@metamask/transaction-controller";
|
|
12
12
|
import type { CaipAssetType } from "@metamask/utils";
|
|
13
13
|
import type { BridgeStatusControllerMethodActions } from "./bridge-status-controller-method-action-types.mjs";
|
|
14
14
|
import { BRIDGE_STATUS_CONTROLLER_NAME } from "./constants.mjs";
|
|
15
|
-
import
|
|
15
|
+
import { QuoteStatusState } from "./quote-status-manager/constants.mjs";
|
|
16
|
+
import { StatusResponseSchema } from "./utils/validators.mjs";
|
|
16
17
|
export declare enum BridgeClientId {
|
|
17
18
|
EXTENSION = "extension",
|
|
18
19
|
MOBILE = "mobile"
|
|
@@ -104,6 +105,8 @@ export type BridgeHistoryItem = {
|
|
|
104
105
|
*/
|
|
105
106
|
quoteIds?: string[];
|
|
106
107
|
quote: Quote;
|
|
108
|
+
quoteId?: string;
|
|
109
|
+
reportedSubmittedTxHash?: string;
|
|
107
110
|
status: StatusResponse;
|
|
108
111
|
startTime: number;
|
|
109
112
|
estimatedProcessingTimeInSeconds: number;
|
|
@@ -250,8 +253,17 @@ export type StartPollingForBridgeTxStatusArgsSerialized = Omit<StartPollingForBr
|
|
|
250
253
|
quoteResponse: QuoteResponse & QuoteMetadata;
|
|
251
254
|
};
|
|
252
255
|
export type SourceChainTxMetaId = string;
|
|
256
|
+
export type QuoteStatusPersistEntry = {
|
|
257
|
+
quoteId: string;
|
|
258
|
+
srcTxHash: string;
|
|
259
|
+
status: QuoteStatusState;
|
|
260
|
+
createdAt: number;
|
|
261
|
+
lastAttemptAt: number;
|
|
262
|
+
txMetaId?: string;
|
|
263
|
+
};
|
|
253
264
|
export type BridgeStatusControllerState = {
|
|
254
265
|
txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;
|
|
266
|
+
quoteUpdateStatusStore: Record<string, QuoteStatusPersistEntry>;
|
|
255
267
|
};
|
|
256
268
|
export type BridgeStatusControllerGetStateAction = ControllerGetStateAction<typeof BRIDGE_STATUS_CONTROLLER_NAME, BridgeStatusControllerState>;
|
|
257
269
|
export type BridgeStatusControllerActions = BridgeStatusControllerGetStateAction | BridgeStatusControllerMethodActions;
|
|
@@ -272,7 +284,7 @@ type AllowedActions = NetworkControllerFindNetworkClientIdByChainIdAction | Netw
|
|
|
272
284
|
/**
|
|
273
285
|
* The external events available to the BridgeStatusController.
|
|
274
286
|
*/
|
|
275
|
-
type AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent;
|
|
287
|
+
type AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent | TransactionControllerTransactionSubmittedEvent;
|
|
276
288
|
/**
|
|
277
289
|
* The messenger for the BridgeStatusController.
|
|
278
290
|
*/
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2CAA2C,EAAE,sCAAsC;AACjG,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,EACN,cAAc,EACd,iDAAiD,EACjD,0CAA0C,EAC1C,uBAAuB,EACvB,8BAA8B,EAC9B,wBAAwB,EACzB,oCAAoC;AACrC,OAAO,KAAK,EAAE,uCAAuC,EAAE,qCAAqC;AAC5F,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CAA2C,EAC3C,+BAA+B,EAChC,qCAAqC;AACtC,OAAO,KAAK,EAAE,4CAA4C,EAAE,+CAA+C;AAC3G,OAAO,KAAK,EAAE,yCAAyC,EAAE,iDAAiD;AAC1G,OAAO,KAAK,EAAE,iCAAiC,EAAE,oCAAoC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AACnD,OAAO,KAAK,EACV,yCAAyC,EACzC,yCAAyC,EACzC,mCAAmC,EACnC,iDAAiD,EACjD,kDAAk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AEF,MAAM,MAAM,6BAA6B,GACrC,oCAAoC,GACpC,mCAAmC,CAAC;AAGxC,MAAM,MAAM,sCAAsC,GAAG,0BAA0B,CAC7E,OAAO,6BAA6B,EACpC,2BAA2B,CAC5B,CAAC;AACF;;;GAGG;AACH,MAAM,MAAM,0DAA0D,GAAG;IACvE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,4BAA4B,GACpC,sCAAsC,GACtC,0DAA0D,CAAC;AAE/D;;GAEG;AACH,KAAK,cAAc,GACf,mDAAmD,GACnD,+BAA+B,GAC/B,2CAA2C,GAC3C,yCAAyC,GACzC,iCAAiC,GACjC,mCAAmC,GACnC,4CAA4C,GAC5C,yCAAyC,GACzC,yCAAyC,GACzC,iDAAiD,GACjD,iDAAiD,GACjD,0CAA0C,GAC1C,8BAA8B,GAC9B,2CAA2C,GAC3C,4CAA4C,GAC5C,uCAAuC,CAAC;AAE5C;;GAEG;AACH,KAAK,aAAa,GACd,kDAAkD,GAClD,8CAA8C,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,6BAA6B,EACpC,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC"}
|
package/dist/types.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BRIDGE_STATUS_CONTROLLER_NAME } from "./constants.mjs";
|
|
2
|
+
import { QuoteStatusState } from "./quote-status-manager/constants.mjs";
|
|
3
|
+
import { StatusResponseSchema } from "./utils/validators.mjs";
|
|
2
4
|
// All fields need to be types not interfaces, same with their children fields
|
|
3
5
|
// o/w you get a type error
|
|
4
6
|
export var BridgeClientId;
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA6CA,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AAG5D,8EAA8E;AAC9E,2BAA2B;AAE3B,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAyCD,MAAM,CAAN,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,2BAAe,CAAA;IACf,uCAA2B,CAAA;IAC3B,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,mCAAuB,CAAA;IACvB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,CAAC,EAbW,QAAQ,KAAR,QAAQ,QAanB;AA8GD;;;GAGG;AACH,MAAM,CAAN,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC5B,qFAA+D,CAAA;IAC/D,2DAAqC,CAAA;IACrC,2CAAqB,CAAA;IACrB,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;IACrB,mDAA6B,CAAA;IAC7B,yFAAmE,CAAA;IACnE,uFAAiE,CAAA;AACnE,CAAC,EATW,kBAAkB,KAAlB,kBAAkB,QAS7B","sourcesContent":["import type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type {\n ChainId,\n FeatureId,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n MetaMetricsSwapsEventSource,\n SimulatedGasFeeLimits,\n TxData,\n TxFeeGasLimits,\n BridgeControllerTrackUnifiedSwapBridgeEventAction,\n BridgeControllerStopPollingForQuotesAction,\n BatchSellTradesResponse,\n BridgeControllerGetStateAction,\n InputPrimaryDenomination,\n} from '@metamask/bridge-controller';\nimport type { KeyringControllerSignTypedMessageAction } from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusControllerMethodActions } from './bridge-status-controller-method-action-types';\nimport { BRIDGE_STATUS_CONTROLLER_NAME } from './constants';\nimport type { StatusResponseSchema } from './utils/validators';\n\n// All fields need to be types not interfaces, same with their children fields\n// o/w you get a type error\n\nexport enum BridgeClientId {\n EXTENSION = 'extension',\n MOBILE = 'mobile',\n}\n\nexport type FetchFunction = (\n input: RequestInfo | URL,\n init?: RequestInit,\n) => Promise<unknown>;\n\n/**\n * These fields are specific to Solana transactions and can likely be infered from TransactionMeta\n *\n * @deprecated these should be removed eventually\n */\nexport type SolanaTransactionMeta = {\n isSolana: boolean;\n isBridgeTx: boolean;\n};\n\nexport type StatusRequest = {\n bridgeId: string; // lifi, socket, squid\n srcTxHash?: string; // lifi, socket, squid, might be undefined for STX\n bridge: string; // lifi, socket, squid\n srcChainId: ChainId; // lifi, socket, squid\n destChainId: ChainId; // lifi, socket, squid\n quote?: Quote; // squid\n refuel?: boolean; // lifi\n};\n\nexport type StatusRequestDto = Omit<\n StatusRequest,\n 'quote' | 'srcChainId' | 'destChainId' | 'refuel'\n> & {\n srcChainId: string; // lifi, socket, squid\n destChainId: string; // lifi, socket, squid\n requestId?: string;\n refuel?: string; // lifi\n};\n\nexport type StatusRequestWithSrcTxHash = StatusRequest & {\n srcTxHash: string;\n};\n\nexport enum BridgeId {\n HOP = 'hop',\n CELER = 'celer',\n CELERCIRCLE = 'celercircle',\n CONNEXT = 'connext',\n POLYGON = 'polygon',\n AVALANCHE = 'avalanche',\n MULTICHAIN = 'multichain',\n AXELAR = 'axelar',\n ACROSS = 'across',\n STARGATE = 'stargate',\n RELAY = 'relay',\n MAYAN = 'mayan',\n}\n\nexport type StatusResponse = Infer<typeof StatusResponseSchema>;\n\nexport type RefuelStatusResponse = object & StatusResponse;\n\n/**\n * This type ties together the quote, its tx params and the submitted txMeta.\n * Each trade/approval will have its own QuoteAndTxMetadata object.\n */\nexport type QuoteAndTxMetadata = {\n type: TransactionType;\n quoteResponse: QuoteResponse & QuoteMetadata;\n /**\n * The approval or trade object from the quote response\n */\n tx: TxData;\n assetsFiatValues?: { sending?: string; receiving?: string };\n /**\n * The simulated gas fee limits for the transaction provided by the bridge-api\n */\n txFee?: SimulatedGasFeeLimits | TxFeeGasLimits;\n /**\n * Transaction metadata from the TransactionController after submission\n */\n txMeta?: TransactionMeta;\n};\n\nexport type BridgeHistoryItem = {\n txMetaId?: string; // Optional: not available pre-submission or on sync failure\n actionId?: string; // Only for non-batch EVM transactions\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string; // Keep original transaction ID for intent transactions\n batchId?: string;\n /**\n * This is defined when the history item is for a batch sell transaction\n */\n batchSellData?: BatchSellTradesResponse;\n /**\n * This is defined when the history item corresponds to the 7702 batch's delegation tx.\n * It contains the list of quoteIds for the BatchSell quotes that are part of the 7702 batch.\n * Each quote can be retrieved from txHistory as `txHistory[quoteId]`.\n */\n quoteIds?: string[];\n quote: Quote;\n status: StatusResponse;\n startTime: number; // timestamp in ms\n estimatedProcessingTimeInSeconds: number;\n slippagePercentage: number;\n completionTime?: number; // timestamp in ms\n pricingData?: {\n /**\n * The actual amount sent by user in non-atomic decimal form\n */\n amountSent: QuoteMetadata['sentAmount']['amount'];\n amountSentInUsd?: QuoteMetadata['sentAmount']['usd'];\n quotedGasInUsd?: QuoteMetadata['gasFee']['effective']['usd'];\n quotedGasAmount?: QuoteMetadata['gasFee']['effective']['amount'];\n quotedReturnInUsd?: QuoteMetadata['toTokenAmount']['usd'];\n quotedRefuelSrcAmountInUsd?: string;\n quotedRefuelDestAmountInUsd?: string;\n };\n initialDestAssetBalance?: string;\n targetContractAddress?: string;\n account: string;\n hasApprovalTx: boolean;\n approvalTxId?: string;\n featureId?: FeatureId;\n isStxEnabled?: boolean;\n /**\n * The location/entry point from which the user initiated the swap or bridge.\n * Used to attribute swaps to specific flows (e.g. Trending Explore).\n */\n location?: MetaMetricsSwapsEventSource;\n /**\n * Legacy A/B test metrics context (`ab_tests`) kept for backward compatibility.\n * Keys are test names, values are variant names (e.g. { token_details_layout: 'treatment' }).\n */\n abTests?: Record<string, string>;\n /**\n * New A/B test metrics context (`active_ab_tests`) that replaces `ab_tests`.\n * Kept separate so migration can run both payloads in parallel.\n * This field is an array of test objects.\n */\n activeAbTests?: { key: string; value: string }[];\n /**\n * Attempts tracking for exponential backoff on failed fetches.\n * We track the number of attempts and the last attempt time for each txMetaId that has failed at least once\n */\n attempts?: {\n counter: number;\n lastAttemptTime: number; // timestamp in ms\n };\n /**\n * Client-supplied security classification for the destination token at the\n * time the swap/bridge was submitted. Persisted so post-submit analytics\n * events (Completed, Failed, StatusValidationFailed) can include\n * `token_security_type_destination`. `null` when no security data was\n * available for the destination token.\n */\n tokenSecurityTypeDestination?: string | null;\n /**\n * The denomination shown as the primary source amount input when the\n * swap/bridge was submitted.\n */\n inputPrimaryDenomination?: InputPrimaryDenomination;\n};\n\n/**\n * @deprecated Use the separate action types instead (e.g.\n * `BridgeStatusControllerStartPollingForBridgeTxStatusAction`).\n */\nexport enum BridgeStatusAction {\n StartPollingForBridgeTxStatus = 'StartPollingForBridgeTxStatus',\n WipeBridgeStatus = 'WipeBridgeStatus',\n GetState = 'GetState',\n ResetState = 'ResetState',\n SubmitTx = 'SubmitTx',\n SubmitIntent = 'SubmitIntent',\n RestartPollingForFailedAttempts = 'RestartPollingForFailedAttempts',\n GetBridgeHistoryItemByTxMetaId = 'GetBridgeHistoryItemByTxMetaId',\n}\n\nexport type TokenAmountValuesSerialized = {\n amount: string;\n valueInCurrency: string | null;\n usd: string | null;\n};\n\nexport type QuoteMetadataSerialized = {\n gasFee: TokenAmountValuesSerialized;\n /**\n * The total network fee for the bridge transaction\n * estimatedGasFees + relayerFees\n */\n totalNetworkFee: TokenAmountValuesSerialized;\n /**\n * The total max network fee for the bridge transaction\n * maxGasFees + relayerFees\n */\n totalMaxNetworkFee: TokenAmountValuesSerialized;\n toTokenAmount: TokenAmountValuesSerialized;\n /**\n * The adjusted return for the bridge transaction\n * destTokenAmount - totalNetworkFee\n */\n adjustedReturn: Omit<TokenAmountValuesSerialized, 'amount'>;\n /**\n * The actual amount sent by user in non-atomic decimal form\n * srcTokenAmount + metabridgeFee\n */\n sentAmount: TokenAmountValuesSerialized;\n swapRate: string; // destTokenAmount / sentAmount\n /**\n * The cost of the bridge transaction\n * sentAmount - adjustedReturn\n */\n cost: Omit<TokenAmountValuesSerialized, 'amount'>;\n};\n\nexport type StartPollingForBridgeTxStatusArgs = {\n bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;\n actionId?: string;\n batchSellData?: BridgeHistoryItem['batchSellData'];\n quoteIds?: BridgeHistoryItem['quoteIds'];\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string;\n quoteResponse: QuoteResponse & QuoteMetadata;\n startTime: BridgeHistoryItem['startTime'];\n slippagePercentage: BridgeHistoryItem['slippagePercentage'];\n initialDestAssetBalance?: BridgeHistoryItem['initialDestAssetBalance'];\n targetContractAddress?: BridgeHistoryItem['targetContractAddress'];\n approvalTxId?: BridgeHistoryItem['approvalTxId'];\n isStxEnabled?: BridgeHistoryItem['isStxEnabled'];\n location: MetaMetricsSwapsEventSource;\n // Legacy field for `ab_tests` metrics payload.\n abTests?: BridgeHistoryItem['abTests'];\n // New field for `active_ab_tests` metrics payload.\n activeAbTests?: BridgeHistoryItem['activeAbTests'];\n accountAddress: string;\n // Client-supplied destination token security classification, persisted on\n // the history item for post-submit analytics events.\n tokenSecurityTypeDestination?: BridgeHistoryItem['tokenSecurityTypeDestination'];\n // Primary denomination at submission time, persisted for post-submit analytics.\n inputPrimaryDenomination?: BridgeHistoryItem['inputPrimaryDenomination'];\n};\n\n/**\n * Chrome: The BigNumber values are automatically serialized to strings when sent to the background\n * Firefox: The BigNumber values are not serialized to strings when sent to the background,\n * so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action\n */\nexport type StartPollingForBridgeTxStatusArgsSerialized = Omit<\n StartPollingForBridgeTxStatusArgs,\n 'quoteResponse'\n> & {\n quoteResponse: QuoteResponse & QuoteMetadata;\n};\n\nexport type SourceChainTxMetaId = string;\n\nexport type BridgeStatusControllerState = {\n txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;\n};\n\n// Actions\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerMethodActions;\n\n// Events\nexport type BridgeStatusControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n/**\n * This event is published when the destination bridge transaction is completed\n * The payload is the asset received on the destination chain\n */\nexport type BridgeStatusControllerDestinationTransactionCompletedEvent = {\n type: 'BridgeStatusController:destinationTransactionCompleted';\n payload: [CaipAssetType];\n};\n\nexport type BridgeStatusControllerEvents =\n | BridgeStatusControllerStateChangeEvent\n | BridgeStatusControllerDestinationTransactionCompletedEvent;\n\n/**\n * The external actions available to the BridgeStatusController.\n */\ntype AllowedActions =\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | SnapControllerHandleRequestAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerGetStateAction\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent;\n\n/**\n * The messenger for the BridgeStatusController.\n */\nexport type BridgeStatusControllerMessenger = Messenger<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerActions | AllowedActions,\n BridgeStatusControllerEvents | AllowedEvents\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA8CA,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AAC5D,OAAO,EAAE,gBAAgB,EAAE,6CAAyC;AACpE,OAAO,EAAE,oBAAoB,EAAE,+BAA2B;AAE1D,8EAA8E;AAC9E,2BAA2B;AAE3B,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAyCD,MAAM,CAAN,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,2BAAe,CAAA;IACf,uCAA2B,CAAA;IAC3B,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,mCAAuB,CAAA;IACvB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,CAAC,EAbW,QAAQ,KAAR,QAAQ,QAanB;AAgHD;;;GAGG;AACH,MAAM,CAAN,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC5B,qFAA+D,CAAA;IAC/D,2DAAqC,CAAA;IACrC,2CAAqB,CAAA;IACrB,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;IACrB,mDAA6B,CAAA;IAC7B,yFAAmE,CAAA;IACnE,uFAAiE,CAAA;AACnE,CAAC,EATW,kBAAkB,KAAlB,kBAAkB,QAS7B","sourcesContent":["import type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type {\n ChainId,\n FeatureId,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n MetaMetricsSwapsEventSource,\n SimulatedGasFeeLimits,\n TxData,\n TxFeeGasLimits,\n BridgeControllerTrackUnifiedSwapBridgeEventAction,\n BridgeControllerStopPollingForQuotesAction,\n BatchSellTradesResponse,\n BridgeControllerGetStateAction,\n InputPrimaryDenomination,\n} from '@metamask/bridge-controller';\nimport type { KeyringControllerSignTypedMessageAction } from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerTransactionSubmittedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusControllerMethodActions } from './bridge-status-controller-method-action-types';\nimport { BRIDGE_STATUS_CONTROLLER_NAME } from './constants';\nimport { QuoteStatusState } from './quote-status-manager/constants';\nimport { StatusResponseSchema } from './utils/validators';\n\n// All fields need to be types not interfaces, same with their children fields\n// o/w you get a type error\n\nexport enum BridgeClientId {\n EXTENSION = 'extension',\n MOBILE = 'mobile',\n}\n\nexport type FetchFunction = (\n input: RequestInfo | URL,\n init?: RequestInit,\n) => Promise<unknown>;\n\n/**\n * These fields are specific to Solana transactions and can likely be infered from TransactionMeta\n *\n * @deprecated these should be removed eventually\n */\nexport type SolanaTransactionMeta = {\n isSolana: boolean;\n isBridgeTx: boolean;\n};\n\nexport type StatusRequest = {\n bridgeId: string; // lifi, socket, squid\n srcTxHash?: string; // lifi, socket, squid, might be undefined for STX\n bridge: string; // lifi, socket, squid\n srcChainId: ChainId; // lifi, socket, squid\n destChainId: ChainId; // lifi, socket, squid\n quote?: Quote; // squid\n refuel?: boolean; // lifi\n};\n\nexport type StatusRequestDto = Omit<\n StatusRequest,\n 'quote' | 'srcChainId' | 'destChainId' | 'refuel'\n> & {\n srcChainId: string; // lifi, socket, squid\n destChainId: string; // lifi, socket, squid\n requestId?: string;\n refuel?: string; // lifi\n};\n\nexport type StatusRequestWithSrcTxHash = StatusRequest & {\n srcTxHash: string;\n};\n\nexport enum BridgeId {\n HOP = 'hop',\n CELER = 'celer',\n CELERCIRCLE = 'celercircle',\n CONNEXT = 'connext',\n POLYGON = 'polygon',\n AVALANCHE = 'avalanche',\n MULTICHAIN = 'multichain',\n AXELAR = 'axelar',\n ACROSS = 'across',\n STARGATE = 'stargate',\n RELAY = 'relay',\n MAYAN = 'mayan',\n}\n\nexport type StatusResponse = Infer<typeof StatusResponseSchema>;\n\nexport type RefuelStatusResponse = object & StatusResponse;\n\n/**\n * This type ties together the quote, its tx params and the submitted txMeta.\n * Each trade/approval will have its own QuoteAndTxMetadata object.\n */\nexport type QuoteAndTxMetadata = {\n type: TransactionType;\n quoteResponse: QuoteResponse & QuoteMetadata;\n /**\n * The approval or trade object from the quote response\n */\n tx: TxData;\n assetsFiatValues?: { sending?: string; receiving?: string };\n /**\n * The simulated gas fee limits for the transaction provided by the bridge-api\n */\n txFee?: SimulatedGasFeeLimits | TxFeeGasLimits;\n /**\n * Transaction metadata from the TransactionController after submission\n */\n txMeta?: TransactionMeta;\n};\n\nexport type BridgeHistoryItem = {\n txMetaId?: string; // Optional: not available pre-submission or on sync failure\n actionId?: string; // Only for non-batch EVM transactions\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string; // Keep original transaction ID for intent transactions\n batchId?: string;\n /**\n * This is defined when the history item is for a batch sell transaction\n */\n batchSellData?: BatchSellTradesResponse;\n /**\n * This is defined when the history item corresponds to the 7702 batch's delegation tx.\n * It contains the list of quoteIds for the BatchSell quotes that are part of the 7702 batch.\n * Each quote can be retrieved from txHistory as `txHistory[quoteId]`.\n */\n quoteIds?: string[];\n quote: Quote;\n quoteId?: string; // Optional: absent on history items persisted before this field was introduced\n reportedSubmittedTxHash?: string;\n status: StatusResponse;\n startTime: number; // timestamp in ms\n estimatedProcessingTimeInSeconds: number;\n slippagePercentage: number;\n completionTime?: number; // timestamp in ms\n pricingData?: {\n /**\n * The actual amount sent by user in non-atomic decimal form\n */\n amountSent: QuoteMetadata['sentAmount']['amount'];\n amountSentInUsd?: QuoteMetadata['sentAmount']['usd'];\n quotedGasInUsd?: QuoteMetadata['gasFee']['effective']['usd'];\n quotedGasAmount?: QuoteMetadata['gasFee']['effective']['amount'];\n quotedReturnInUsd?: QuoteMetadata['toTokenAmount']['usd'];\n quotedRefuelSrcAmountInUsd?: string;\n quotedRefuelDestAmountInUsd?: string;\n };\n initialDestAssetBalance?: string;\n targetContractAddress?: string;\n account: string;\n hasApprovalTx: boolean;\n approvalTxId?: string;\n featureId?: FeatureId;\n isStxEnabled?: boolean;\n /**\n * The location/entry point from which the user initiated the swap or bridge.\n * Used to attribute swaps to specific flows (e.g. Trending Explore).\n */\n location?: MetaMetricsSwapsEventSource;\n /**\n * Legacy A/B test metrics context (`ab_tests`) kept for backward compatibility.\n * Keys are test names, values are variant names (e.g. { token_details_layout: 'treatment' }).\n */\n abTests?: Record<string, string>;\n /**\n * New A/B test metrics context (`active_ab_tests`) that replaces `ab_tests`.\n * Kept separate so migration can run both payloads in parallel.\n * This field is an array of test objects.\n */\n activeAbTests?: { key: string; value: string }[];\n /**\n * Attempts tracking for exponential backoff on failed fetches.\n * We track the number of attempts and the last attempt time for each txMetaId that has failed at least once\n */\n attempts?: {\n counter: number;\n lastAttemptTime: number; // timestamp in ms\n };\n /**\n * Client-supplied security classification for the destination token at the\n * time the swap/bridge was submitted. Persisted so post-submit analytics\n * events (Completed, Failed, StatusValidationFailed) can include\n * `token_security_type_destination`. `null` when no security data was\n * available for the destination token.\n */\n tokenSecurityTypeDestination?: string | null;\n /**\n * The denomination shown as the primary source amount input when the\n * swap/bridge was submitted.\n */\n inputPrimaryDenomination?: InputPrimaryDenomination;\n};\n\n/**\n * @deprecated Use the separate action types instead (e.g.\n * `BridgeStatusControllerStartPollingForBridgeTxStatusAction`).\n */\nexport enum BridgeStatusAction {\n StartPollingForBridgeTxStatus = 'StartPollingForBridgeTxStatus',\n WipeBridgeStatus = 'WipeBridgeStatus',\n GetState = 'GetState',\n ResetState = 'ResetState',\n SubmitTx = 'SubmitTx',\n SubmitIntent = 'SubmitIntent',\n RestartPollingForFailedAttempts = 'RestartPollingForFailedAttempts',\n GetBridgeHistoryItemByTxMetaId = 'GetBridgeHistoryItemByTxMetaId',\n}\n\nexport type TokenAmountValuesSerialized = {\n amount: string;\n valueInCurrency: string | null;\n usd: string | null;\n};\n\nexport type QuoteMetadataSerialized = {\n gasFee: TokenAmountValuesSerialized;\n /**\n * The total network fee for the bridge transaction\n * estimatedGasFees + relayerFees\n */\n totalNetworkFee: TokenAmountValuesSerialized;\n /**\n * The total max network fee for the bridge transaction\n * maxGasFees + relayerFees\n */\n totalMaxNetworkFee: TokenAmountValuesSerialized;\n toTokenAmount: TokenAmountValuesSerialized;\n /**\n * The adjusted return for the bridge transaction\n * destTokenAmount - totalNetworkFee\n */\n adjustedReturn: Omit<TokenAmountValuesSerialized, 'amount'>;\n /**\n * The actual amount sent by user in non-atomic decimal form\n * srcTokenAmount + metabridgeFee\n */\n sentAmount: TokenAmountValuesSerialized;\n swapRate: string; // destTokenAmount / sentAmount\n /**\n * The cost of the bridge transaction\n * sentAmount - adjustedReturn\n */\n cost: Omit<TokenAmountValuesSerialized, 'amount'>;\n};\n\nexport type StartPollingForBridgeTxStatusArgs = {\n bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;\n actionId?: string;\n batchSellData?: BridgeHistoryItem['batchSellData'];\n quoteIds?: BridgeHistoryItem['quoteIds'];\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string;\n quoteResponse: QuoteResponse & QuoteMetadata;\n startTime: BridgeHistoryItem['startTime'];\n slippagePercentage: BridgeHistoryItem['slippagePercentage'];\n initialDestAssetBalance?: BridgeHistoryItem['initialDestAssetBalance'];\n targetContractAddress?: BridgeHistoryItem['targetContractAddress'];\n approvalTxId?: BridgeHistoryItem['approvalTxId'];\n isStxEnabled?: BridgeHistoryItem['isStxEnabled'];\n location: MetaMetricsSwapsEventSource;\n // Legacy field for `ab_tests` metrics payload.\n abTests?: BridgeHistoryItem['abTests'];\n // New field for `active_ab_tests` metrics payload.\n activeAbTests?: BridgeHistoryItem['activeAbTests'];\n accountAddress: string;\n // Client-supplied destination token security classification, persisted on\n // the history item for post-submit analytics events.\n tokenSecurityTypeDestination?: BridgeHistoryItem['tokenSecurityTypeDestination'];\n // Primary denomination at submission time, persisted for post-submit analytics.\n inputPrimaryDenomination?: BridgeHistoryItem['inputPrimaryDenomination'];\n};\n\n/**\n * Chrome: The BigNumber values are automatically serialized to strings when sent to the background\n * Firefox: The BigNumber values are not serialized to strings when sent to the background,\n * so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action\n */\nexport type StartPollingForBridgeTxStatusArgsSerialized = Omit<\n StartPollingForBridgeTxStatusArgs,\n 'quoteResponse'\n> & {\n quoteResponse: QuoteResponse & QuoteMetadata;\n};\n\nexport type SourceChainTxMetaId = string;\n\nexport type QuoteStatusPersistEntry = {\n quoteId: string;\n srcTxHash: string;\n status: QuoteStatusState;\n createdAt: number;\n lastAttemptAt: number;\n txMetaId?: string;\n};\n\nexport type BridgeStatusControllerState = {\n txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;\n quoteUpdateStatusStore: Record<string, QuoteStatusPersistEntry>;\n};\n\n// Actions\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerMethodActions;\n\n// Events\nexport type BridgeStatusControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n/**\n * This event is published when the destination bridge transaction is completed\n * The payload is the asset received on the destination chain\n */\nexport type BridgeStatusControllerDestinationTransactionCompletedEvent = {\n type: 'BridgeStatusController:destinationTransactionCompleted';\n payload: [CaipAssetType];\n};\n\nexport type BridgeStatusControllerEvents =\n | BridgeStatusControllerStateChangeEvent\n | BridgeStatusControllerDestinationTransactionCompletedEvent;\n\n/**\n * The external actions available to the BridgeStatusController.\n */\ntype AllowedActions =\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | SnapControllerHandleRequestAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerGetStateAction\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents =\n | TransactionControllerTransactionStatusUpdatedEvent\n | TransactionControllerTransactionSubmittedEvent;\n\n/**\n * The messenger for the BridgeStatusController.\n */\nexport type BridgeStatusControllerMessenger = Messenger<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerActions | AllowedActions,\n BridgeStatusControllerEvents | AllowedEvents\n>;\n"]}
|
package/dist/utils/history.cjs
CHANGED
|
@@ -134,6 +134,7 @@ const getInitialHistoryItem = (args) => {
|
|
|
134
134
|
originalTransactionId: originalTransactionId ?? bridgeTxMeta?.id, // Keep original for intent transactions
|
|
135
135
|
batchId: bridgeTxMeta?.batchId,
|
|
136
136
|
quote: quoteResponse.quote,
|
|
137
|
+
quoteId: quoteResponse.quoteId,
|
|
137
138
|
startTime,
|
|
138
139
|
estimatedProcessingTimeInSeconds: quoteResponse.estimatedProcessingTimeInSeconds,
|
|
139
140
|
slippagePercentage,
|