damm-sdk 1.4.25 → 1.4.26
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/dist/index.cjs +4609 -4628
- package/dist/index.cjs.map +15 -16
- package/dist/index.js +436 -546
- package/dist/index.js.map +4 -6
- package/dist/integrations/enso/enso.route.api.d.ts +18 -2
- package/dist/integrations/enso/enso.route.api.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/integrations/enso/enso.route.api.ts +31 -6
|
@@ -44,11 +44,27 @@ export type EnsoRouteArgs = Readonly<{
|
|
|
44
44
|
* string").
|
|
45
45
|
*/
|
|
46
46
|
slippageBips: number;
|
|
47
|
-
/**
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Enso API key. **Required** to use this integration — calls without a
|
|
49
|
+
* key share a global 1 rps limit and fail often in production. Sign up
|
|
50
|
+
* at https://developers.enso.build.
|
|
51
|
+
*
|
|
52
|
+
* If this is falsy (undefined, empty string), `fetchEnsoRoute` throws
|
|
53
|
+
* `EnsoApiKeyMissingError` before hitting the network.
|
|
54
|
+
*/
|
|
55
|
+
apiKey: string;
|
|
49
56
|
/** Override the API base URL (useful for tests). */
|
|
50
57
|
apiBase?: string;
|
|
51
58
|
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Thrown when `fetchEnsoRoute` is called without an API key. Without a
|
|
61
|
+
* key the caller shares Enso's global 1 rps limit and will hit 429 in
|
|
62
|
+
* production — we fail fast so the misconfiguration shows up immediately
|
|
63
|
+
* in logs instead of after a long, confusing 429 trail.
|
|
64
|
+
*/
|
|
65
|
+
export declare class EnsoApiKeyMissingError extends Error {
|
|
66
|
+
constructor();
|
|
67
|
+
}
|
|
52
68
|
export declare class EnsoRouteApiError extends Error {
|
|
53
69
|
readonly status: number;
|
|
54
70
|
readonly statusText: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enso.route.api.d.ts","sourceRoot":"","sources":["../../../src/integrations/enso/enso.route.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,aAAa,4BAAsC,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACrC,EAAE,EAAE,QAAQ,CAAC;QACT,EAAE,EAAE,SAAS,CAAC;QACd,IAAI,EAAE,SAAS,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;IAClB,oFAAoF;IACpF,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,WAAW,EAAE,OAAO,CAAC;IACrB,oFAAoF;IACpF,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB
|
|
1
|
+
{"version":3,"file":"enso.route.api.d.ts","sourceRoot":"","sources":["../../../src/integrations/enso/enso.route.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,aAAa,4BAAsC,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACrC,EAAE,EAAE,QAAQ,CAAC;QACT,EAAE,EAAE,SAAS,CAAC;QACd,IAAI,EAAE,SAAS,CA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|
49
49
|
*/
|
|
50
50
|
slippageBips: number;
|
|
51
|
-
/**
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Enso API key. **Required** to use this integration — calls without a
|
|
53
|
+
* key share a global 1 rps limit and fail often in production. Sign up
|
|
54
|
+
* at https://developers.enso.build.
|
|
55
|
+
*
|
|
56
|
+
* If this is falsy (undefined, empty string), `fetchEnsoRoute` throws
|
|
57
|
+
* `EnsoApiKeyMissingError` before hitting the network.
|
|
58
|
+
*/
|
|
59
|
+
apiKey: string;
|
|
53
60
|
/** Override the API base URL (useful for tests). */
|
|
54
61
|
apiBase?: string;
|
|
55
62
|
}>;
|
|
56
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Thrown when `fetchEnsoRoute` is called without an API key. Without a
|
|
66
|
+
* key the caller shares Enso's global 1 rps limit and will hit 429 in
|
|
67
|
+
* production — we fail fast so the misconfiguration shows up immediately
|
|
68
|
+
* in logs instead of after a long, confusing 429 trail.
|
|
69
|
+
*/
|
|
70
|
+
export class EnsoApiKeyMissingError extends Error {
|
|
71
|
+
constructor() {
|
|
72
|
+
super("Enso API key required; pass `apiKey`.");
|
|
73
|
+
this.name = "EnsoApiKeyMissingError";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
57
77
|
export class EnsoRouteApiError extends Error {
|
|
58
78
|
readonly status: number;
|
|
59
79
|
readonly statusText: string;
|
|
@@ -99,6 +119,11 @@ export const fetchEnsoRoute = async (args: EnsoRouteArgs): Promise<EnsoRouteResp
|
|
|
99
119
|
apiBase = ENSO_API_BASE,
|
|
100
120
|
} = args;
|
|
101
121
|
|
|
122
|
+
// Fail fast if no API key — see EnsoApiKeyMissingError doc for rationale.
|
|
123
|
+
if (!apiKey) {
|
|
124
|
+
throw new EnsoApiKeyMissingError();
|
|
125
|
+
}
|
|
126
|
+
|
|
102
127
|
const params = new URLSearchParams({
|
|
103
128
|
chainId: String(chainId),
|
|
104
129
|
fromAddress,
|
|
@@ -109,10 +134,10 @@ export const fetchEnsoRoute = async (args: EnsoRouteArgs): Promise<EnsoRouteResp
|
|
|
109
134
|
slippage: String(slippageBips),
|
|
110
135
|
});
|
|
111
136
|
|
|
112
|
-
const headers: Record<string, string> = {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
137
|
+
const headers: Record<string, string> = {
|
|
138
|
+
Accept: "application/json",
|
|
139
|
+
Authorization: `Bearer ${apiKey}`,
|
|
140
|
+
};
|
|
116
141
|
|
|
117
142
|
const response = await fetch(`${apiBase}/api/v1/shortcuts/route?${params.toString()}`, {
|
|
118
143
|
headers,
|