@metamask-previews/bridge-status-controller 64.2.0-preview-749d0638 → 64.2.0-preview-e69ede40
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 +2 -2
- package/dist/bridge-status-controller.cjs +15 -403
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +1 -16
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +1 -16
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +15 -403
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/types.cjs +7 -9
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +16 -26
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +16 -26
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +7 -9
- package/dist/types.mjs.map +1 -1
- package/dist/utils/transaction.d.cts +2 -21
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +2 -21
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/validators.cjs +1 -23
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +0 -51
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +0 -51
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +1 -22
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/utils/intent-api.cjs +0 -73
- package/dist/utils/intent-api.cjs.map +0 -1
- package/dist/utils/intent-api.d.cts +0 -24
- package/dist/utils/intent-api.d.cts.map +0 -1
- package/dist/utils/intent-api.d.mts +0 -24
- package/dist/utils/intent-api.d.mts.map +0 -1
- package/dist/utils/intent-api.mjs +0 -68
- package/dist/utils/intent-api.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StatusTypes, BridgeAssetSchema } from "@metamask/bridge-controller";
|
|
2
|
-
import { string, boolean, number, optional, enums, union, type, assert
|
|
2
|
+
import { string, boolean, number, optional, enums, union, type, assert } from "@metamask/superstruct";
|
|
3
3
|
const ChainIdSchema = number();
|
|
4
4
|
const EmptyObjectSchema = type({});
|
|
5
5
|
const SrcChainStatusSchema = type({
|
|
@@ -38,25 +38,4 @@ export const validateBridgeStatusResponse = (data) => {
|
|
|
38
38
|
assert(data, StatusResponseSchema);
|
|
39
39
|
return true;
|
|
40
40
|
};
|
|
41
|
-
export var IntentOrderStatus;
|
|
42
|
-
(function (IntentOrderStatus) {
|
|
43
|
-
IntentOrderStatus["PENDING"] = "pending";
|
|
44
|
-
IntentOrderStatus["SUBMITTED"] = "submitted";
|
|
45
|
-
IntentOrderStatus["CONFIRMED"] = "confirmed";
|
|
46
|
-
IntentOrderStatus["COMPLETED"] = "completed";
|
|
47
|
-
IntentOrderStatus["FAILED"] = "failed";
|
|
48
|
-
IntentOrderStatus["CANCELLED"] = "cancelled";
|
|
49
|
-
IntentOrderStatus["EXPIRED"] = "expired";
|
|
50
|
-
})(IntentOrderStatus || (IntentOrderStatus = {}));
|
|
51
|
-
export const IntentOrderResponseSchema = type({
|
|
52
|
-
id: string(),
|
|
53
|
-
status: enums(Object.values(IntentOrderStatus)),
|
|
54
|
-
txHash: optional(string()),
|
|
55
|
-
metadata: type({
|
|
56
|
-
txHashes: optional(union([array(string()), string()])),
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
59
|
-
export const validateIntentOrderResponse = (data) => {
|
|
60
|
-
return is(data, IntentOrderResponseSchema);
|
|
61
|
-
};
|
|
62
41
|
//# sourceMappingURL=validators.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,oCAAoC;AAE7E,OAAO,EACL,MAAM,EACN,OAAO,EACP,MAAM,EAC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AqB,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,CAC1C,IAAa,EAC+B,EAAE;IAC9C,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import { StatusTypes, BridgeAssetSchema } from '@metamask/bridge-controller';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n string,\n boolean,\n number,\n optional,\n enums,\n union,\n type,\n assert,\n} from '@metamask/superstruct';\n\nconst ChainIdSchema = number();\n\nconst EmptyObjectSchema = type({});\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 = (\n data: unknown,\n): data is Infer<typeof StatusResponseSchema> => {\n assert(data, StatusResponseSchema);\n return true;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/bridge-status-controller",
|
|
3
|
-
"version": "64.2.0-preview-
|
|
3
|
+
"version": "64.2.0-preview-e69ede40",
|
|
4
4
|
"description": "Manages bridge-related status fetching functionality for MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@metamask/gas-fee-controller": "^26.0.0",
|
|
56
56
|
"@metamask/network-controller": "^27.1.0",
|
|
57
57
|
"@metamask/polling-controller": "^16.0.0",
|
|
58
|
-
"@metamask/snaps-controllers": "^
|
|
58
|
+
"@metamask/snaps-controllers": "^17.2.0",
|
|
59
59
|
"@metamask/superstruct": "^3.1.0",
|
|
60
60
|
"@metamask/transaction-controller": "^62.7.0",
|
|
61
|
-
"@metamask/utils": "^11.
|
|
61
|
+
"@metamask/utils": "^11.9.0",
|
|
62
62
|
"bignumber.js": "^9.1.2",
|
|
63
63
|
"uuid": "^8.3.2"
|
|
64
64
|
},
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _IntentApiImpl_baseUrl, _IntentApiImpl_fetchFn;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.IntentApiImpl = exports.getClientIdHeader = void 0;
|
|
16
|
-
const validators_1 = require("./validators.cjs");
|
|
17
|
-
const getClientIdHeader = (clientId) => ({
|
|
18
|
-
'X-Client-Id': clientId,
|
|
19
|
-
});
|
|
20
|
-
exports.getClientIdHeader = getClientIdHeader;
|
|
21
|
-
class IntentApiImpl {
|
|
22
|
-
constructor(baseUrl, fetchFn) {
|
|
23
|
-
_IntentApiImpl_baseUrl.set(this, void 0);
|
|
24
|
-
_IntentApiImpl_fetchFn.set(this, void 0);
|
|
25
|
-
__classPrivateFieldSet(this, _IntentApiImpl_baseUrl, baseUrl, "f");
|
|
26
|
-
__classPrivateFieldSet(this, _IntentApiImpl_fetchFn, fetchFn, "f");
|
|
27
|
-
}
|
|
28
|
-
async submitIntent(params, clientId) {
|
|
29
|
-
const endpoint = `${__classPrivateFieldGet(this, _IntentApiImpl_baseUrl, "f")}/submitOrder`;
|
|
30
|
-
try {
|
|
31
|
-
const response = await __classPrivateFieldGet(this, _IntentApiImpl_fetchFn, "f").call(this, endpoint, {
|
|
32
|
-
method: 'POST',
|
|
33
|
-
headers: {
|
|
34
|
-
'Content-Type': 'application/json',
|
|
35
|
-
...(0, exports.getClientIdHeader)(clientId),
|
|
36
|
-
},
|
|
37
|
-
body: JSON.stringify(params),
|
|
38
|
-
});
|
|
39
|
-
if (!(0, validators_1.validateIntentOrderResponse)(response)) {
|
|
40
|
-
throw new Error('Invalid submitOrder response');
|
|
41
|
-
}
|
|
42
|
-
return response;
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
if (error instanceof Error) {
|
|
46
|
-
throw new Error(`Failed to submit intent: ${error.message}`);
|
|
47
|
-
}
|
|
48
|
-
throw new Error('Failed to submit intent');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async getOrderStatus(orderId, aggregatorId, srcChainId, clientId) {
|
|
52
|
-
const endpoint = `${__classPrivateFieldGet(this, _IntentApiImpl_baseUrl, "f")}/getOrderStatus?orderId=${orderId}&aggregatorId=${encodeURIComponent(aggregatorId)}&srcChainId=${srcChainId}`;
|
|
53
|
-
try {
|
|
54
|
-
const response = await __classPrivateFieldGet(this, _IntentApiImpl_fetchFn, "f").call(this, endpoint, {
|
|
55
|
-
method: 'GET',
|
|
56
|
-
headers: (0, exports.getClientIdHeader)(clientId),
|
|
57
|
-
});
|
|
58
|
-
if (!(0, validators_1.validateIntentOrderResponse)(response)) {
|
|
59
|
-
throw new Error('Invalid submitOrder response');
|
|
60
|
-
}
|
|
61
|
-
return response;
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
if (error instanceof Error) {
|
|
65
|
-
throw new Error(`Failed to get order status: ${error.message}`);
|
|
66
|
-
}
|
|
67
|
-
throw new Error('Failed to get order status');
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.IntentApiImpl = IntentApiImpl;
|
|
72
|
-
_IntentApiImpl_baseUrl = new WeakMap(), _IntentApiImpl_fetchFn = new WeakMap();
|
|
73
|
-
//# sourceMappingURL=intent-api.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-api.cjs","sourceRoot":"","sources":["../../src/utils/intent-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAAwE;AAYjE,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC;IACtD,aAAa,EAAE,QAAQ;CACxB,CAAC,CAAC;AAFU,QAAA,iBAAiB,qBAE3B;AAeH,MAAa,aAAa;IAKxB,YAAY,OAAe,EAAE,OAAsB;QAJ1C,yCAAiB;QAEjB,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7C,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,IAAA,yBAAiB,EAAC,QAAQ,CAAC;aACrC,CAAC,CAAC;YACH,IAAI,CAAC,IAAA,wCAA2B,EAAC,QAAQ,CAAC,EAAE,CAAC;gBAC3C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAClE,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AA3DD,sCA2DC","sourcesContent":["import { IntentOrder, validateIntentOrderResponse } from './validators';\nimport type { FetchFunction } from '../types';\n\nexport type IntentSubmissionParams = {\n srcChainId: string;\n quoteId: string;\n signature: string;\n order: unknown;\n userAddress: string;\n aggregatorId: string;\n};\n\nexport const getClientIdHeader = (clientId: string) => ({\n 'X-Client-Id': clientId,\n});\n\nexport type IntentApi = {\n submitIntent(\n params: IntentSubmissionParams,\n clientId: string,\n ): Promise<IntentOrder>;\n getOrderStatus(\n orderId: string,\n aggregatorId: string,\n srcChainId: string,\n clientId: string,\n ): Promise<IntentOrder>;\n};\n\nexport class IntentApiImpl implements IntentApi {\n readonly #baseUrl: string;\n\n readonly #fetchFn: FetchFunction;\n\n constructor(baseUrl: string, fetchFn: FetchFunction) {\n this.#baseUrl = baseUrl;\n this.#fetchFn = fetchFn;\n }\n\n async submitIntent(\n params: IntentSubmissionParams,\n clientId: string,\n ): Promise<IntentOrder> {\n const endpoint = `${this.#baseUrl}/submitOrder`;\n try {\n const response = await this.#fetchFn(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...getClientIdHeader(clientId),\n },\n body: JSON.stringify(params),\n });\n if (!validateIntentOrderResponse(response)) {\n throw new Error('Invalid submitOrder response');\n }\n return response;\n } catch (error: unknown) {\n if (error instanceof Error) {\n throw new Error(`Failed to submit intent: ${error.message}`);\n }\n throw new Error('Failed to submit intent');\n }\n }\n\n async getOrderStatus(\n orderId: string,\n aggregatorId: string,\n srcChainId: string,\n clientId: string,\n ): Promise<IntentOrder> {\n const endpoint = `${this.#baseUrl}/getOrderStatus?orderId=${orderId}&aggregatorId=${encodeURIComponent(aggregatorId)}&srcChainId=${srcChainId}`;\n try {\n const response = await this.#fetchFn(endpoint, {\n method: 'GET',\n headers: getClientIdHeader(clientId),\n });\n if (!validateIntentOrderResponse(response)) {\n throw new Error('Invalid submitOrder response');\n }\n return response;\n } catch (error: unknown) {\n if (error instanceof Error) {\n throw new Error(`Failed to get order status: ${error.message}`);\n }\n throw new Error('Failed to get order status');\n }\n }\n}\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { IntentOrder } from "./validators.cjs";
|
|
2
|
-
import type { FetchFunction } from "../types.cjs";
|
|
3
|
-
export type IntentSubmissionParams = {
|
|
4
|
-
srcChainId: string;
|
|
5
|
-
quoteId: string;
|
|
6
|
-
signature: string;
|
|
7
|
-
order: unknown;
|
|
8
|
-
userAddress: string;
|
|
9
|
-
aggregatorId: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const getClientIdHeader: (clientId: string) => {
|
|
12
|
-
'X-Client-Id': string;
|
|
13
|
-
};
|
|
14
|
-
export type IntentApi = {
|
|
15
|
-
submitIntent(params: IntentSubmissionParams, clientId: string): Promise<IntentOrder>;
|
|
16
|
-
getOrderStatus(orderId: string, aggregatorId: string, srcChainId: string, clientId: string): Promise<IntentOrder>;
|
|
17
|
-
};
|
|
18
|
-
export declare class IntentApiImpl implements IntentApi {
|
|
19
|
-
#private;
|
|
20
|
-
constructor(baseUrl: string, fetchFn: FetchFunction);
|
|
21
|
-
submitIntent(params: IntentSubmissionParams, clientId: string): Promise<IntentOrder>;
|
|
22
|
-
getOrderStatus(orderId: string, aggregatorId: string, srcChainId: string, clientId: string): Promise<IntentOrder>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=intent-api.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-api.d.cts","sourceRoot":"","sources":["../../src/utils/intent-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA+B,yBAAqB;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAiB;AAE9C,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,MAAM;;CAEhD,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,CACV,MAAM,EAAE,sBAAsB,EAC9B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAAC;IACxB,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB,CAAC;AAEF,qBAAa,aAAc,YAAW,SAAS;;gBAKjC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAK7C,YAAY,CAChB,MAAM,EAAE,sBAAsB,EAC9B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC;IAuBjB,cAAc,CAClB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC;CAkBxB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { IntentOrder } from "./validators.mjs";
|
|
2
|
-
import type { FetchFunction } from "../types.mjs";
|
|
3
|
-
export type IntentSubmissionParams = {
|
|
4
|
-
srcChainId: string;
|
|
5
|
-
quoteId: string;
|
|
6
|
-
signature: string;
|
|
7
|
-
order: unknown;
|
|
8
|
-
userAddress: string;
|
|
9
|
-
aggregatorId: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const getClientIdHeader: (clientId: string) => {
|
|
12
|
-
'X-Client-Id': string;
|
|
13
|
-
};
|
|
14
|
-
export type IntentApi = {
|
|
15
|
-
submitIntent(params: IntentSubmissionParams, clientId: string): Promise<IntentOrder>;
|
|
16
|
-
getOrderStatus(orderId: string, aggregatorId: string, srcChainId: string, clientId: string): Promise<IntentOrder>;
|
|
17
|
-
};
|
|
18
|
-
export declare class IntentApiImpl implements IntentApi {
|
|
19
|
-
#private;
|
|
20
|
-
constructor(baseUrl: string, fetchFn: FetchFunction);
|
|
21
|
-
submitIntent(params: IntentSubmissionParams, clientId: string): Promise<IntentOrder>;
|
|
22
|
-
getOrderStatus(orderId: string, aggregatorId: string, srcChainId: string, clientId: string): Promise<IntentOrder>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=intent-api.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-api.d.mts","sourceRoot":"","sources":["../../src/utils/intent-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA+B,yBAAqB;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAiB;AAE9C,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,MAAM;;CAEhD,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,CACV,MAAM,EAAE,sBAAsB,EAC9B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAAC;IACxB,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB,CAAC;AAEF,qBAAa,aAAc,YAAW,SAAS;;gBAKjC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAK7C,YAAY,CAChB,MAAM,EAAE,sBAAsB,EAC9B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC;IAuBjB,cAAc,CAClB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC;CAkBxB"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _IntentApiImpl_baseUrl, _IntentApiImpl_fetchFn;
|
|
13
|
-
import { validateIntentOrderResponse } from "./validators.mjs";
|
|
14
|
-
export const getClientIdHeader = (clientId) => ({
|
|
15
|
-
'X-Client-Id': clientId,
|
|
16
|
-
});
|
|
17
|
-
export class IntentApiImpl {
|
|
18
|
-
constructor(baseUrl, fetchFn) {
|
|
19
|
-
_IntentApiImpl_baseUrl.set(this, void 0);
|
|
20
|
-
_IntentApiImpl_fetchFn.set(this, void 0);
|
|
21
|
-
__classPrivateFieldSet(this, _IntentApiImpl_baseUrl, baseUrl, "f");
|
|
22
|
-
__classPrivateFieldSet(this, _IntentApiImpl_fetchFn, fetchFn, "f");
|
|
23
|
-
}
|
|
24
|
-
async submitIntent(params, clientId) {
|
|
25
|
-
const endpoint = `${__classPrivateFieldGet(this, _IntentApiImpl_baseUrl, "f")}/submitOrder`;
|
|
26
|
-
try {
|
|
27
|
-
const response = await __classPrivateFieldGet(this, _IntentApiImpl_fetchFn, "f").call(this, endpoint, {
|
|
28
|
-
method: 'POST',
|
|
29
|
-
headers: {
|
|
30
|
-
'Content-Type': 'application/json',
|
|
31
|
-
...getClientIdHeader(clientId),
|
|
32
|
-
},
|
|
33
|
-
body: JSON.stringify(params),
|
|
34
|
-
});
|
|
35
|
-
if (!validateIntentOrderResponse(response)) {
|
|
36
|
-
throw new Error('Invalid submitOrder response');
|
|
37
|
-
}
|
|
38
|
-
return response;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
if (error instanceof Error) {
|
|
42
|
-
throw new Error(`Failed to submit intent: ${error.message}`);
|
|
43
|
-
}
|
|
44
|
-
throw new Error('Failed to submit intent');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async getOrderStatus(orderId, aggregatorId, srcChainId, clientId) {
|
|
48
|
-
const endpoint = `${__classPrivateFieldGet(this, _IntentApiImpl_baseUrl, "f")}/getOrderStatus?orderId=${orderId}&aggregatorId=${encodeURIComponent(aggregatorId)}&srcChainId=${srcChainId}`;
|
|
49
|
-
try {
|
|
50
|
-
const response = await __classPrivateFieldGet(this, _IntentApiImpl_fetchFn, "f").call(this, endpoint, {
|
|
51
|
-
method: 'GET',
|
|
52
|
-
headers: getClientIdHeader(clientId),
|
|
53
|
-
});
|
|
54
|
-
if (!validateIntentOrderResponse(response)) {
|
|
55
|
-
throw new Error('Invalid submitOrder response');
|
|
56
|
-
}
|
|
57
|
-
return response;
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
if (error instanceof Error) {
|
|
61
|
-
throw new Error(`Failed to get order status: ${error.message}`);
|
|
62
|
-
}
|
|
63
|
-
throw new Error('Failed to get order status');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
_IntentApiImpl_baseUrl = new WeakMap(), _IntentApiImpl_fetchFn = new WeakMap();
|
|
68
|
-
//# sourceMappingURL=intent-api.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-api.mjs","sourceRoot":"","sources":["../../src/utils/intent-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAe,2BAA2B,EAAE,yBAAqB;AAYxE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC;IACtD,aAAa,EAAE,QAAQ;CACxB,CAAC,CAAC;AAeH,MAAM,OAAO,aAAa;IAKxB,YAAY,OAAe,EAAE,OAAsB;QAJ1C,yCAAiB;QAEjB,yCAAwB;QAG/B,uBAAA,IAAI,0BAAY,OAAO,MAAA,CAAC;QACxB,uBAAA,IAAI,0BAAY,OAAO,MAAA,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,MAA8B,EAC9B,QAAgB;QAEhB,MAAM,QAAQ,GAAG,GAAG,uBAAA,IAAI,8BAAS,cAAc,CAAC;QAChD,IAAI,CAAC;YACH,MAAM,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AAC;YACxB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAClE,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { IntentOrder, validateIntentOrderResponse } from './validators';\nimport type { FetchFunction } from '../types';\n\nexport type IntentSubmissionParams = {\n srcChainId: string;\n quoteId: string;\n signature: string;\n order: unknown;\n userAddress: string;\n aggregatorId: string;\n};\n\nexport const getClientIdHeader = (clientId: string) => ({\n 'X-Client-Id': clientId,\n});\n\nexport type IntentApi = {\n submitIntent(\n params: IntentSubmissionParams,\n clientId: string,\n ): Promise<IntentOrder>;\n getOrderStatus(\n orderId: string,\n aggregatorId: string,\n srcChainId: string,\n clientId: string,\n ): Promise<IntentOrder>;\n};\n\nexport class IntentApiImpl implements IntentApi {\n readonly #baseUrl: string;\n\n readonly #fetchFn: FetchFunction;\n\n constructor(baseUrl: string, fetchFn: FetchFunction) {\n this.#baseUrl = baseUrl;\n this.#fetchFn = fetchFn;\n }\n\n async submitIntent(\n params: IntentSubmissionParams,\n clientId: string,\n ): Promise<IntentOrder> {\n const endpoint = `${this.#baseUrl}/submitOrder`;\n try {\n const response = await this.#fetchFn(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...getClientIdHeader(clientId),\n },\n body: JSON.stringify(params),\n });\n if (!validateIntentOrderResponse(response)) {\n throw new Error('Invalid submitOrder response');\n }\n return response;\n } catch (error: unknown) {\n if (error instanceof Error) {\n throw new Error(`Failed to submit intent: ${error.message}`);\n }\n throw new Error('Failed to submit intent');\n }\n }\n\n async getOrderStatus(\n orderId: string,\n aggregatorId: string,\n srcChainId: string,\n clientId: string,\n ): Promise<IntentOrder> {\n const endpoint = `${this.#baseUrl}/getOrderStatus?orderId=${orderId}&aggregatorId=${encodeURIComponent(aggregatorId)}&srcChainId=${srcChainId}`;\n try {\n const response = await this.#fetchFn(endpoint, {\n method: 'GET',\n headers: getClientIdHeader(clientId),\n });\n if (!validateIntentOrderResponse(response)) {\n throw new Error('Invalid submitOrder response');\n }\n return response;\n } catch (error: unknown) {\n if (error instanceof Error) {\n throw new Error(`Failed to get order status: ${error.message}`);\n }\n throw new Error('Failed to get order status');\n }\n }\n}\n"]}
|