@compass-labs/api-sdk 2.1.9-rc.2 → 2.1.10-rc.2
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/README.md +7 -0
- package/dist/commonjs/funcs/cctpCCTPBurn.d.ts +37 -0
- package/dist/commonjs/funcs/cctpCCTPBurn.d.ts.map +1 -0
- package/dist/commonjs/funcs/cctpCCTPBurn.js +137 -0
- package/dist/commonjs/funcs/cctpCCTPBurn.js.map +1 -0
- package/dist/commonjs/funcs/cctpCCTPMint.d.ts +52 -0
- package/dist/commonjs/funcs/cctpCCTPMint.d.ts.map +1 -0
- package/dist/commonjs/funcs/cctpCCTPMint.js +152 -0
- package/dist/commonjs/funcs/cctpCCTPMint.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/lib/encodings.d.ts +1 -0
- package/dist/commonjs/lib/encodings.d.ts.map +1 -1
- package/dist/commonjs/lib/encodings.js +9 -0
- package/dist/commonjs/lib/encodings.js.map +1 -1
- package/dist/commonjs/models/components/depositforburnrequest.d.ts +96 -0
- package/dist/commonjs/models/components/depositforburnrequest.d.ts.map +1 -0
- package/dist/commonjs/models/components/depositforburnrequest.js +87 -0
- package/dist/commonjs/models/components/depositforburnrequest.js.map +1 -0
- package/dist/commonjs/models/components/depositforburnresponse.d.ts +37 -0
- package/dist/commonjs/models/components/depositforburnresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/depositforburnresponse.js +60 -0
- package/dist/commonjs/models/components/depositforburnresponse.js.map +1 -0
- package/dist/commonjs/models/components/index.d.ts +5 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +5 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/mintpreparependingresponse.d.ts +43 -0
- package/dist/commonjs/models/components/mintpreparependingresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/mintpreparependingresponse.js +64 -0
- package/dist/commonjs/models/components/mintpreparependingresponse.js.map +1 -0
- package/dist/commonjs/models/components/mintpreparereadyresponse.d.ts +41 -0
- package/dist/commonjs/models/components/mintpreparereadyresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/mintpreparereadyresponse.js +64 -0
- package/dist/commonjs/models/components/mintpreparereadyresponse.js.map +1 -0
- package/dist/commonjs/models/components/mintpreparerequest.d.ts +39 -0
- package/dist/commonjs/models/components/mintpreparerequest.d.ts.map +1 -0
- package/dist/commonjs/models/components/mintpreparerequest.js +57 -0
- package/dist/commonjs/models/components/mintpreparerequest.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +1 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +1 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/v2cctpmint.d.ts +9 -0
- package/dist/commonjs/models/operations/v2cctpmint.d.ts.map +1 -0
- package/dist/commonjs/models/operations/v2cctpmint.js +52 -0
- package/dist/commonjs/models/operations/v2cctpmint.js.map +1 -0
- package/dist/commonjs/sdk/cctp.d.ts +72 -0
- package/dist/commonjs/sdk/cctp.d.ts.map +1 -0
- package/dist/commonjs/sdk/cctp.js +84 -0
- package/dist/commonjs/sdk/cctp.js.map +1 -0
- package/dist/commonjs/sdk/sdk.d.ts +3 -0
- package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
- package/dist/commonjs/sdk/sdk.js +4 -0
- package/dist/commonjs/sdk/sdk.js.map +1 -1
- package/dist/commonjs/types/unrecognized.d.ts +7 -1
- package/dist/commonjs/types/unrecognized.d.ts.map +1 -1
- package/dist/commonjs/types/unrecognized.js +9 -1
- package/dist/commonjs/types/unrecognized.js.map +1 -1
- package/dist/esm/funcs/cctpCCTPBurn.d.ts +37 -0
- package/dist/esm/funcs/cctpCCTPBurn.d.ts.map +1 -0
- package/dist/esm/funcs/cctpCCTPBurn.js +101 -0
- package/dist/esm/funcs/cctpCCTPBurn.js.map +1 -0
- package/dist/esm/funcs/cctpCCTPMint.d.ts +52 -0
- package/dist/esm/funcs/cctpCCTPMint.d.ts.map +1 -0
- package/dist/esm/funcs/cctpCCTPMint.js +116 -0
- package/dist/esm/funcs/cctpCCTPMint.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/lib/encodings.d.ts +1 -0
- package/dist/esm/lib/encodings.d.ts.map +1 -1
- package/dist/esm/lib/encodings.js +9 -0
- package/dist/esm/lib/encodings.js.map +1 -1
- package/dist/esm/models/components/depositforburnrequest.d.ts +96 -0
- package/dist/esm/models/components/depositforburnrequest.d.ts.map +1 -0
- package/dist/esm/models/components/depositforburnrequest.js +49 -0
- package/dist/esm/models/components/depositforburnrequest.js.map +1 -0
- package/dist/esm/models/components/depositforburnresponse.d.ts +37 -0
- package/dist/esm/models/components/depositforburnresponse.d.ts.map +1 -0
- package/dist/esm/models/components/depositforburnresponse.js +23 -0
- package/dist/esm/models/components/depositforburnresponse.js.map +1 -0
- package/dist/esm/models/components/index.d.ts +5 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +5 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/mintpreparependingresponse.d.ts +43 -0
- package/dist/esm/models/components/mintpreparependingresponse.d.ts.map +1 -0
- package/dist/esm/models/components/mintpreparependingresponse.js +27 -0
- package/dist/esm/models/components/mintpreparependingresponse.js.map +1 -0
- package/dist/esm/models/components/mintpreparereadyresponse.d.ts +41 -0
- package/dist/esm/models/components/mintpreparereadyresponse.d.ts.map +1 -0
- package/dist/esm/models/components/mintpreparereadyresponse.js +27 -0
- package/dist/esm/models/components/mintpreparereadyresponse.js.map +1 -0
- package/dist/esm/models/components/mintpreparerequest.d.ts +39 -0
- package/dist/esm/models/components/mintpreparerequest.d.ts.map +1 -0
- package/dist/esm/models/components/mintpreparerequest.js +20 -0
- package/dist/esm/models/components/mintpreparerequest.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +1 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +1 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/v2cctpmint.d.ts +9 -0
- package/dist/esm/models/operations/v2cctpmint.d.ts.map +1 -0
- package/dist/esm/models/operations/v2cctpmint.js +15 -0
- package/dist/esm/models/operations/v2cctpmint.js.map +1 -0
- package/dist/esm/sdk/cctp.d.ts +72 -0
- package/dist/esm/sdk/cctp.d.ts.map +1 -0
- package/dist/esm/sdk/cctp.js +80 -0
- package/dist/esm/sdk/cctp.js.map +1 -0
- package/dist/esm/sdk/sdk.d.ts +3 -0
- package/dist/esm/sdk/sdk.d.ts.map +1 -1
- package/dist/esm/sdk/sdk.js +4 -0
- package/dist/esm/sdk/sdk.js.map +1 -1
- package/dist/esm/types/unrecognized.d.ts +7 -1
- package/dist/esm/types/unrecognized.d.ts.map +1 -1
- package/dist/esm/types/unrecognized.js +9 -1
- package/dist/esm/types/unrecognized.js.map +1 -1
- package/package.json +1 -1
- package/src/funcs/cctpCCTPBurn.ts +188 -0
- package/src/funcs/cctpCCTPMint.ts +204 -0
- package/src/lib/config.ts +2 -2
- package/src/lib/encodings.ts +13 -0
- package/src/models/components/depositforburnrequest.ts +153 -0
- package/src/models/components/depositforburnresponse.ts +72 -0
- package/src/models/components/index.ts +5 -0
- package/src/models/components/mintpreparependingresponse.ts +78 -0
- package/src/models/components/mintpreparereadyresponse.ts +80 -0
- package/src/models/components/mintpreparerequest.ts +66 -0
- package/src/models/operations/index.ts +1 -0
- package/src/models/operations/v2cctpmint.ts +33 -0
- package/src/sdk/cctp.ts +98 -0
- package/src/sdk/sdk.ts +6 -0
- package/src/types/unrecognized.ts +9 -1
- package/tsconfig.json +0 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CompassApiSDKCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import * as components from "../models/components/index.js";
|
|
14
|
+
import { CompassAPISDKError } from "../models/errors/compassapisdkerror.js";
|
|
15
|
+
import {
|
|
16
|
+
ConnectionError,
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
RequestAbortedError,
|
|
19
|
+
RequestTimeoutError,
|
|
20
|
+
UnexpectedClientError,
|
|
21
|
+
} from "../models/errors/httpclienterrors.js";
|
|
22
|
+
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Build depositForBurn transaction for Earn Account
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Build a transaction to burn USDC from an Earn Account (Safe) on the source chain
|
|
33
|
+
* and initiate a cross-chain transfer via Circle's CCTP (Cross-Chain Transfer Protocol).
|
|
34
|
+
*
|
|
35
|
+
* **Flow:**
|
|
36
|
+
* 1. Call this endpoint with `gas_sponsorship=false` to get an unsigned transaction,
|
|
37
|
+
* or `gas_sponsorship=true` to get EIP-712 typed data for gas-sponsored execution
|
|
38
|
+
* 2. Owner signs the transaction or typed data
|
|
39
|
+
* 3. Broadcast the transaction on the source chain (or submit to `/gas_sponsorship/prepare`)
|
|
40
|
+
* 4. Wait for Circle's attestation service to attest the burn
|
|
41
|
+
* 5. Call the mint endpoint (when available) to receive USDC on the destination chain
|
|
42
|
+
*
|
|
43
|
+
* **Supported chains:**
|
|
44
|
+
* - Ethereum (domain 0)
|
|
45
|
+
* - Arbitrum (domain 3)
|
|
46
|
+
* - Base (domain 6)
|
|
47
|
+
*
|
|
48
|
+
* **Note:** The USDC must already be deposited in the Earn Account. If approval is needed
|
|
49
|
+
* for the TokenMessenger contract, it will be included in the transaction automatically.
|
|
50
|
+
*
|
|
51
|
+
* **Gas estimate:** ~200,000 gas units (includes Safe execTransaction overhead)
|
|
52
|
+
*/
|
|
53
|
+
export function cctpCCTPBurn(
|
|
54
|
+
client: CompassApiSDKCore,
|
|
55
|
+
request: components.DepositForBurnRequest,
|
|
56
|
+
options?: RequestOptions,
|
|
57
|
+
): APIPromise<
|
|
58
|
+
Result<
|
|
59
|
+
components.DepositForBurnResponse,
|
|
60
|
+
| errors.HTTPValidationError
|
|
61
|
+
| CompassAPISDKError
|
|
62
|
+
| ResponseValidationError
|
|
63
|
+
| ConnectionError
|
|
64
|
+
| RequestAbortedError
|
|
65
|
+
| RequestTimeoutError
|
|
66
|
+
| InvalidRequestError
|
|
67
|
+
| UnexpectedClientError
|
|
68
|
+
| SDKValidationError
|
|
69
|
+
>
|
|
70
|
+
> {
|
|
71
|
+
return new APIPromise($do(
|
|
72
|
+
client,
|
|
73
|
+
request,
|
|
74
|
+
options,
|
|
75
|
+
));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function $do(
|
|
79
|
+
client: CompassApiSDKCore,
|
|
80
|
+
request: components.DepositForBurnRequest,
|
|
81
|
+
options?: RequestOptions,
|
|
82
|
+
): Promise<
|
|
83
|
+
[
|
|
84
|
+
Result<
|
|
85
|
+
components.DepositForBurnResponse,
|
|
86
|
+
| errors.HTTPValidationError
|
|
87
|
+
| CompassAPISDKError
|
|
88
|
+
| ResponseValidationError
|
|
89
|
+
| ConnectionError
|
|
90
|
+
| RequestAbortedError
|
|
91
|
+
| RequestTimeoutError
|
|
92
|
+
| InvalidRequestError
|
|
93
|
+
| UnexpectedClientError
|
|
94
|
+
| SDKValidationError
|
|
95
|
+
>,
|
|
96
|
+
APICall,
|
|
97
|
+
]
|
|
98
|
+
> {
|
|
99
|
+
const parsed = safeParse(
|
|
100
|
+
request,
|
|
101
|
+
(value) => components.DepositForBurnRequest$outboundSchema.parse(value),
|
|
102
|
+
"Input validation failed",
|
|
103
|
+
);
|
|
104
|
+
if (!parsed.ok) {
|
|
105
|
+
return [parsed, { status: "invalid" }];
|
|
106
|
+
}
|
|
107
|
+
const payload = parsed.value;
|
|
108
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
109
|
+
|
|
110
|
+
const path = pathToFunc("/v2/cctp/burn")();
|
|
111
|
+
|
|
112
|
+
const headers = new Headers(compactMap({
|
|
113
|
+
"Content-Type": "application/json",
|
|
114
|
+
Accept: "application/json",
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
const secConfig = await extractSecurity(client._options.apiKeyAuth);
|
|
118
|
+
const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
|
|
119
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
120
|
+
|
|
121
|
+
const context = {
|
|
122
|
+
options: client._options,
|
|
123
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
124
|
+
operationID: "v2_cctp_burn",
|
|
125
|
+
oAuth2Scopes: null,
|
|
126
|
+
|
|
127
|
+
resolvedSecurity: requestSecurity,
|
|
128
|
+
|
|
129
|
+
securitySource: client._options.apiKeyAuth,
|
|
130
|
+
retryConfig: options?.retries
|
|
131
|
+
|| client._options.retryConfig
|
|
132
|
+
|| { strategy: "none" },
|
|
133
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const requestRes = client._createRequest(context, {
|
|
137
|
+
security: requestSecurity,
|
|
138
|
+
method: "POST",
|
|
139
|
+
baseURL: options?.serverURL,
|
|
140
|
+
path: path,
|
|
141
|
+
headers: headers,
|
|
142
|
+
body: body,
|
|
143
|
+
userAgent: client._options.userAgent,
|
|
144
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
145
|
+
}, options);
|
|
146
|
+
if (!requestRes.ok) {
|
|
147
|
+
return [requestRes, { status: "invalid" }];
|
|
148
|
+
}
|
|
149
|
+
const req = requestRes.value;
|
|
150
|
+
|
|
151
|
+
const doResult = await client._do(req, {
|
|
152
|
+
context,
|
|
153
|
+
errorCodes: ["422", "4XX", "5XX"],
|
|
154
|
+
retryConfig: context.retryConfig,
|
|
155
|
+
retryCodes: context.retryCodes,
|
|
156
|
+
});
|
|
157
|
+
if (!doResult.ok) {
|
|
158
|
+
return [doResult, { status: "request-error", request: req }];
|
|
159
|
+
}
|
|
160
|
+
const response = doResult.value;
|
|
161
|
+
|
|
162
|
+
const responseFields = {
|
|
163
|
+
HttpMeta: { Response: response, Request: req },
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const [result] = await M.match<
|
|
167
|
+
components.DepositForBurnResponse,
|
|
168
|
+
| errors.HTTPValidationError
|
|
169
|
+
| CompassAPISDKError
|
|
170
|
+
| ResponseValidationError
|
|
171
|
+
| ConnectionError
|
|
172
|
+
| RequestAbortedError
|
|
173
|
+
| RequestTimeoutError
|
|
174
|
+
| InvalidRequestError
|
|
175
|
+
| UnexpectedClientError
|
|
176
|
+
| SDKValidationError
|
|
177
|
+
>(
|
|
178
|
+
M.json(200, components.DepositForBurnResponse$inboundSchema),
|
|
179
|
+
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
180
|
+
M.fail("4XX"),
|
|
181
|
+
M.fail("5XX"),
|
|
182
|
+
)(response, req, { extraFields: responseFields });
|
|
183
|
+
if (!result.ok) {
|
|
184
|
+
return [result, { status: "complete", request: req, response }];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return [result, { status: "complete", request: req, response }];
|
|
188
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CompassApiSDKCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import * as components from "../models/components/index.js";
|
|
14
|
+
import { CompassAPISDKError } from "../models/errors/compassapisdkerror.js";
|
|
15
|
+
import {
|
|
16
|
+
ConnectionError,
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
RequestAbortedError,
|
|
19
|
+
RequestTimeoutError,
|
|
20
|
+
UnexpectedClientError,
|
|
21
|
+
} from "../models/errors/httpclienterrors.js";
|
|
22
|
+
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Prepare mint transaction for Earn Account on destination chain
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Prepare a receiveMessage transaction to mint USDC to an Earn Account (Safe) on the
|
|
34
|
+
* destination chain.
|
|
35
|
+
*
|
|
36
|
+
* **How it works:**
|
|
37
|
+
*
|
|
38
|
+
* This endpoint uses the `bridge_id` from `/burn` to:
|
|
39
|
+
* 1. Look up the bridge session (no burn tx hash needed!)
|
|
40
|
+
* 2. Find the DepositForBurn event on the source chain using stored nonce
|
|
41
|
+
* 3. Extract the CCTP message and compute its hash
|
|
42
|
+
* 4. Check if Circle's attestation is ready
|
|
43
|
+
* 5. Return the mint transaction wrapped in Safe execTransaction
|
|
44
|
+
*
|
|
45
|
+
* **Request parameters:**
|
|
46
|
+
*
|
|
47
|
+
* - `bridge_id`: The bridge ID returned from `/burn`
|
|
48
|
+
* - `owner`: The wallet address that owns the Earn Account (Safe) on the destination chain
|
|
49
|
+
* - `gas_sponsorship`: If true, returns EIP-712 typed data for gas-sponsored execution
|
|
50
|
+
*
|
|
51
|
+
* **Response codes:**
|
|
52
|
+
*
|
|
53
|
+
* - **200 OK**: Attestation is ready, mint transaction is included
|
|
54
|
+
* - **202 Accepted**: Attestation is pending, SSE URL for real-time updates is included
|
|
55
|
+
* - **400 Bad Request**: Bridge not found, or burn event not found yet
|
|
56
|
+
*
|
|
57
|
+
* **After receiving 202:**
|
|
58
|
+
*
|
|
59
|
+
* Either:
|
|
60
|
+
* - Connect to the SSE stream at `sse_url` and wait for `attestation_ready` event
|
|
61
|
+
* - Poll this endpoint periodically until you get 200
|
|
62
|
+
*
|
|
63
|
+
* **After receiving 200:**
|
|
64
|
+
*
|
|
65
|
+
* Sign and broadcast the returned transaction on the destination chain to mint USDC
|
|
66
|
+
* to your Earn Account.
|
|
67
|
+
*/
|
|
68
|
+
export function cctpCCTPMint(
|
|
69
|
+
client: CompassApiSDKCore,
|
|
70
|
+
request: components.MintPrepareRequest,
|
|
71
|
+
options?: RequestOptions,
|
|
72
|
+
): APIPromise<
|
|
73
|
+
Result<
|
|
74
|
+
operations.V2CctpMintResponse,
|
|
75
|
+
| errors.HTTPValidationError
|
|
76
|
+
| CompassAPISDKError
|
|
77
|
+
| ResponseValidationError
|
|
78
|
+
| ConnectionError
|
|
79
|
+
| RequestAbortedError
|
|
80
|
+
| RequestTimeoutError
|
|
81
|
+
| InvalidRequestError
|
|
82
|
+
| UnexpectedClientError
|
|
83
|
+
| SDKValidationError
|
|
84
|
+
>
|
|
85
|
+
> {
|
|
86
|
+
return new APIPromise($do(
|
|
87
|
+
client,
|
|
88
|
+
request,
|
|
89
|
+
options,
|
|
90
|
+
));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function $do(
|
|
94
|
+
client: CompassApiSDKCore,
|
|
95
|
+
request: components.MintPrepareRequest,
|
|
96
|
+
options?: RequestOptions,
|
|
97
|
+
): Promise<
|
|
98
|
+
[
|
|
99
|
+
Result<
|
|
100
|
+
operations.V2CctpMintResponse,
|
|
101
|
+
| errors.HTTPValidationError
|
|
102
|
+
| CompassAPISDKError
|
|
103
|
+
| ResponseValidationError
|
|
104
|
+
| ConnectionError
|
|
105
|
+
| RequestAbortedError
|
|
106
|
+
| RequestTimeoutError
|
|
107
|
+
| InvalidRequestError
|
|
108
|
+
| UnexpectedClientError
|
|
109
|
+
| SDKValidationError
|
|
110
|
+
>,
|
|
111
|
+
APICall,
|
|
112
|
+
]
|
|
113
|
+
> {
|
|
114
|
+
const parsed = safeParse(
|
|
115
|
+
request,
|
|
116
|
+
(value) => components.MintPrepareRequest$outboundSchema.parse(value),
|
|
117
|
+
"Input validation failed",
|
|
118
|
+
);
|
|
119
|
+
if (!parsed.ok) {
|
|
120
|
+
return [parsed, { status: "invalid" }];
|
|
121
|
+
}
|
|
122
|
+
const payload = parsed.value;
|
|
123
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
124
|
+
|
|
125
|
+
const path = pathToFunc("/v2/cctp/mint")();
|
|
126
|
+
|
|
127
|
+
const headers = new Headers(compactMap({
|
|
128
|
+
"Content-Type": "application/json",
|
|
129
|
+
Accept: "application/json",
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
const secConfig = await extractSecurity(client._options.apiKeyAuth);
|
|
133
|
+
const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
|
|
134
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
135
|
+
|
|
136
|
+
const context = {
|
|
137
|
+
options: client._options,
|
|
138
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
139
|
+
operationID: "v2_cctp_mint",
|
|
140
|
+
oAuth2Scopes: null,
|
|
141
|
+
|
|
142
|
+
resolvedSecurity: requestSecurity,
|
|
143
|
+
|
|
144
|
+
securitySource: client._options.apiKeyAuth,
|
|
145
|
+
retryConfig: options?.retries
|
|
146
|
+
|| client._options.retryConfig
|
|
147
|
+
|| { strategy: "none" },
|
|
148
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const requestRes = client._createRequest(context, {
|
|
152
|
+
security: requestSecurity,
|
|
153
|
+
method: "POST",
|
|
154
|
+
baseURL: options?.serverURL,
|
|
155
|
+
path: path,
|
|
156
|
+
headers: headers,
|
|
157
|
+
body: body,
|
|
158
|
+
userAgent: client._options.userAgent,
|
|
159
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
160
|
+
}, options);
|
|
161
|
+
if (!requestRes.ok) {
|
|
162
|
+
return [requestRes, { status: "invalid" }];
|
|
163
|
+
}
|
|
164
|
+
const req = requestRes.value;
|
|
165
|
+
|
|
166
|
+
const doResult = await client._do(req, {
|
|
167
|
+
context,
|
|
168
|
+
errorCodes: ["422", "4XX", "5XX"],
|
|
169
|
+
retryConfig: context.retryConfig,
|
|
170
|
+
retryCodes: context.retryCodes,
|
|
171
|
+
});
|
|
172
|
+
if (!doResult.ok) {
|
|
173
|
+
return [doResult, { status: "request-error", request: req }];
|
|
174
|
+
}
|
|
175
|
+
const response = doResult.value;
|
|
176
|
+
|
|
177
|
+
const responseFields = {
|
|
178
|
+
HttpMeta: { Response: response, Request: req },
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const [result] = await M.match<
|
|
182
|
+
operations.V2CctpMintResponse,
|
|
183
|
+
| errors.HTTPValidationError
|
|
184
|
+
| CompassAPISDKError
|
|
185
|
+
| ResponseValidationError
|
|
186
|
+
| ConnectionError
|
|
187
|
+
| RequestAbortedError
|
|
188
|
+
| RequestTimeoutError
|
|
189
|
+
| InvalidRequestError
|
|
190
|
+
| UnexpectedClientError
|
|
191
|
+
| SDKValidationError
|
|
192
|
+
>(
|
|
193
|
+
M.json(200, operations.V2CctpMintResponse$inboundSchema),
|
|
194
|
+
M.json(202, operations.V2CctpMintResponse$inboundSchema),
|
|
195
|
+
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
196
|
+
M.fail("4XX"),
|
|
197
|
+
M.fail("5XX"),
|
|
198
|
+
)(response, req, { extraFields: responseFields });
|
|
199
|
+
if (!result.ok) {
|
|
200
|
+
return [result, { status: "complete", request: req, response }];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return [result, { status: "complete", request: req, response }];
|
|
204
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -62,7 +62,7 @@ export const SDK_METADATA = {
|
|
|
62
62
|
language: "typescript",
|
|
63
63
|
openapiDocVersion: "0.0.1",
|
|
64
64
|
sdkVersion: "2.0.0",
|
|
65
|
-
genVersion: "2.
|
|
65
|
+
genVersion: "2.767.2",
|
|
66
66
|
userAgent:
|
|
67
|
-
"speakeasy-sdk/typescript 2.0.0 2.
|
|
67
|
+
"speakeasy-sdk/typescript 2.0.0 2.767.2 0.0.1 @compass-labs/api-sdk",
|
|
68
68
|
} as const;
|
package/src/lib/encodings.ts
CHANGED
|
@@ -427,6 +427,7 @@ export function queryJoin(...args: (string | undefined)[]): string {
|
|
|
427
427
|
type QueryEncoderOptions = {
|
|
428
428
|
explode?: boolean;
|
|
429
429
|
charEncoding?: "percent" | "none";
|
|
430
|
+
allowEmptyValue?: string[];
|
|
430
431
|
};
|
|
431
432
|
|
|
432
433
|
type QueryEncoder = (
|
|
@@ -451,7 +452,19 @@ export function queryEncoder(f: QueryEncoder): BulkQueryEncoder {
|
|
|
451
452
|
charEncoding: options?.charEncoding ?? "percent",
|
|
452
453
|
};
|
|
453
454
|
|
|
455
|
+
const allowEmptySet = new Set(options?.allowEmptyValue ?? []);
|
|
456
|
+
|
|
454
457
|
const encoded = Object.entries(values).map(([key, value]) => {
|
|
458
|
+
if (allowEmptySet.has(key)) {
|
|
459
|
+
if (
|
|
460
|
+
value === undefined
|
|
461
|
+
|| value === null
|
|
462
|
+
|| value === ""
|
|
463
|
+
|| (Array.isArray(value) && value.length === 0)
|
|
464
|
+
) {
|
|
465
|
+
return `${encodeURIComponent(key)}=`;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
455
468
|
return f(key, value, opts);
|
|
456
469
|
});
|
|
457
470
|
return queryJoin(...encoded);
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The source chain where USDC will be burned.
|
|
11
|
+
*/
|
|
12
|
+
export const DepositForBurnRequestChain = {
|
|
13
|
+
Ethereum: "ethereum",
|
|
14
|
+
Arbitrum: "arbitrum",
|
|
15
|
+
Base: "base",
|
|
16
|
+
} as const;
|
|
17
|
+
/**
|
|
18
|
+
* The source chain where USDC will be burned.
|
|
19
|
+
*/
|
|
20
|
+
export type DepositForBurnRequestChain = ClosedEnum<
|
|
21
|
+
typeof DepositForBurnRequestChain
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The amount of USDC to bridge (in token units, e.g., 100.5 for 100.5 USDC).
|
|
26
|
+
*/
|
|
27
|
+
export type DepositForBurnRequestAmount = number | string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The destination chain where USDC will be minted.
|
|
31
|
+
*/
|
|
32
|
+
export const DestinationChain = {
|
|
33
|
+
Ethereum: "ethereum",
|
|
34
|
+
Arbitrum: "arbitrum",
|
|
35
|
+
Base: "base",
|
|
36
|
+
} as const;
|
|
37
|
+
/**
|
|
38
|
+
* The destination chain where USDC will be minted.
|
|
39
|
+
*/
|
|
40
|
+
export type DestinationChain = ClosedEnum<typeof DestinationChain>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Request model for CCTP depositForBurn transaction from a smart account.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
*
|
|
47
|
+
* Burns USDC from an Earn Account (Safe) to initiate a cross-chain transfer
|
|
48
|
+
* via Circle's CCTP. The transaction is executed through the Safe contract,
|
|
49
|
+
* supporting both direct owner execution and gas-sponsored transactions.
|
|
50
|
+
*
|
|
51
|
+
* Flow:
|
|
52
|
+
* 1. Owner calls this endpoint to get either:
|
|
53
|
+
* - An unsigned transaction (gas_sponsorship=False)
|
|
54
|
+
* - EIP-712 typed data for signing (gas_sponsorship=True)
|
|
55
|
+
* 2. Owner signs the transaction/typed data
|
|
56
|
+
* 3. Transaction is broadcast on source chain
|
|
57
|
+
* 4. Wait for Circle's attestation service
|
|
58
|
+
* 5. Call receiveMessage on destination chain to mint USDC
|
|
59
|
+
*/
|
|
60
|
+
export type DepositForBurnRequest = {
|
|
61
|
+
/**
|
|
62
|
+
* The primary wallet address that owns and controls the Earn Account (Safe).
|
|
63
|
+
*/
|
|
64
|
+
owner: string;
|
|
65
|
+
/**
|
|
66
|
+
* The source chain where USDC will be burned.
|
|
67
|
+
*/
|
|
68
|
+
chain: DepositForBurnRequestChain;
|
|
69
|
+
/**
|
|
70
|
+
* The amount of USDC to bridge (in token units, e.g., 100.5 for 100.5 USDC).
|
|
71
|
+
*/
|
|
72
|
+
amount: number | string;
|
|
73
|
+
/**
|
|
74
|
+
* The destination chain where USDC will be minted.
|
|
75
|
+
*/
|
|
76
|
+
destinationChain: DestinationChain;
|
|
77
|
+
/**
|
|
78
|
+
* The recipient address on the destination chain.
|
|
79
|
+
*/
|
|
80
|
+
destinationAddress: string;
|
|
81
|
+
/**
|
|
82
|
+
* Optionally request gas sponsorship. If set to `true`, EIP-712 typed data will be returned that must be signed by the `owner` and submitted to the 'Prepare gas-sponsored transaction' endpoint (`/gas_sponsorship/prepare`).
|
|
83
|
+
*/
|
|
84
|
+
gasSponsorship?: boolean | undefined;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** @internal */
|
|
88
|
+
export const DepositForBurnRequestChain$outboundSchema: z.ZodNativeEnum<
|
|
89
|
+
typeof DepositForBurnRequestChain
|
|
90
|
+
> = z.nativeEnum(DepositForBurnRequestChain);
|
|
91
|
+
|
|
92
|
+
/** @internal */
|
|
93
|
+
export type DepositForBurnRequestAmount$Outbound = number | string;
|
|
94
|
+
|
|
95
|
+
/** @internal */
|
|
96
|
+
export const DepositForBurnRequestAmount$outboundSchema: z.ZodType<
|
|
97
|
+
DepositForBurnRequestAmount$Outbound,
|
|
98
|
+
z.ZodTypeDef,
|
|
99
|
+
DepositForBurnRequestAmount
|
|
100
|
+
> = z.union([z.number(), z.string()]);
|
|
101
|
+
|
|
102
|
+
export function depositForBurnRequestAmountToJSON(
|
|
103
|
+
depositForBurnRequestAmount: DepositForBurnRequestAmount,
|
|
104
|
+
): string {
|
|
105
|
+
return JSON.stringify(
|
|
106
|
+
DepositForBurnRequestAmount$outboundSchema.parse(
|
|
107
|
+
depositForBurnRequestAmount,
|
|
108
|
+
),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** @internal */
|
|
113
|
+
export const DestinationChain$outboundSchema: z.ZodNativeEnum<
|
|
114
|
+
typeof DestinationChain
|
|
115
|
+
> = z.nativeEnum(DestinationChain);
|
|
116
|
+
|
|
117
|
+
/** @internal */
|
|
118
|
+
export type DepositForBurnRequest$Outbound = {
|
|
119
|
+
owner: string;
|
|
120
|
+
chain: string;
|
|
121
|
+
amount: number | string;
|
|
122
|
+
destination_chain: string;
|
|
123
|
+
destination_address: string;
|
|
124
|
+
gas_sponsorship?: boolean | undefined;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** @internal */
|
|
128
|
+
export const DepositForBurnRequest$outboundSchema: z.ZodType<
|
|
129
|
+
DepositForBurnRequest$Outbound,
|
|
130
|
+
z.ZodTypeDef,
|
|
131
|
+
DepositForBurnRequest
|
|
132
|
+
> = z.object({
|
|
133
|
+
owner: z.string(),
|
|
134
|
+
chain: DepositForBurnRequestChain$outboundSchema,
|
|
135
|
+
amount: z.union([z.number(), z.string()]),
|
|
136
|
+
destinationChain: DestinationChain$outboundSchema,
|
|
137
|
+
destinationAddress: z.string(),
|
|
138
|
+
gasSponsorship: z.boolean().optional(),
|
|
139
|
+
}).transform((v) => {
|
|
140
|
+
return remap$(v, {
|
|
141
|
+
destinationChain: "destination_chain",
|
|
142
|
+
destinationAddress: "destination_address",
|
|
143
|
+
gasSponsorship: "gas_sponsorship",
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export function depositForBurnRequestToJSON(
|
|
148
|
+
depositForBurnRequest: DepositForBurnRequest,
|
|
149
|
+
): string {
|
|
150
|
+
return JSON.stringify(
|
|
151
|
+
DepositForBurnRequest$outboundSchema.parse(depositForBurnRequest),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
BatchedSafeOperationsResponseOutput,
|
|
12
|
+
BatchedSafeOperationsResponseOutput$inboundSchema,
|
|
13
|
+
} from "./batchedsafeoperationsresponseoutput.js";
|
|
14
|
+
import {
|
|
15
|
+
UnsignedTransaction,
|
|
16
|
+
UnsignedTransaction$inboundSchema,
|
|
17
|
+
} from "./unsignedtransaction.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Response model for CCTP depositForBurn transaction from a smart account.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
*
|
|
24
|
+
* Contains either an unsigned transaction for direct submission or EIP-712 typed
|
|
25
|
+
* data for gas-sponsored transactions. Also includes a bridge_id for tracking
|
|
26
|
+
* the cross-chain transfer.
|
|
27
|
+
*
|
|
28
|
+
* Attributes:
|
|
29
|
+
* bridge_id: Unique identifier for this bridge operation. Use this ID when
|
|
30
|
+
* calling /mint/prepare to complete the cross-chain transfer. The API
|
|
31
|
+
* tracks the bridge state and will automatically poll for Circle's
|
|
32
|
+
* attestation.
|
|
33
|
+
* transaction: Unsigned transaction for the owner to sign and submit directly.
|
|
34
|
+
* Present when gas_sponsorship=False.
|
|
35
|
+
* eip_712: EIP-712 typed data for off-chain signing. The owner signs this
|
|
36
|
+
* data and submits it to /gas_sponsorship/prepare for a relayer to execute.
|
|
37
|
+
* Present when gas_sponsorship=True.
|
|
38
|
+
*/
|
|
39
|
+
export type DepositForBurnResponse = {
|
|
40
|
+
/**
|
|
41
|
+
* Unique bridge identifier for tracking this cross-chain transfer. Use this ID when calling /mint/prepare to complete the transfer. Only present when Redis is configured on the server.
|
|
42
|
+
*/
|
|
43
|
+
bridgeId?: string | null | undefined;
|
|
44
|
+
transaction: UnsignedTransaction | null;
|
|
45
|
+
eip712: BatchedSafeOperationsResponseOutput | null;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** @internal */
|
|
49
|
+
export const DepositForBurnResponse$inboundSchema: z.ZodType<
|
|
50
|
+
DepositForBurnResponse,
|
|
51
|
+
z.ZodTypeDef,
|
|
52
|
+
unknown
|
|
53
|
+
> = z.object({
|
|
54
|
+
bridge_id: z.nullable(z.string()).optional(),
|
|
55
|
+
transaction: z.nullable(UnsignedTransaction$inboundSchema),
|
|
56
|
+
eip_712: z.nullable(BatchedSafeOperationsResponseOutput$inboundSchema),
|
|
57
|
+
}).transform((v) => {
|
|
58
|
+
return remap$(v, {
|
|
59
|
+
"bridge_id": "bridgeId",
|
|
60
|
+
"eip_712": "eip712",
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export function depositForBurnResponseFromJSON(
|
|
65
|
+
jsonString: string,
|
|
66
|
+
): SafeParseResult<DepositForBurnResponse, SDKValidationError> {
|
|
67
|
+
return safeParse(
|
|
68
|
+
jsonString,
|
|
69
|
+
(x) => DepositForBurnResponse$inboundSchema.parse(JSON.parse(x)),
|
|
70
|
+
`Failed to parse 'DepositForBurnResponse' from JSON`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -78,6 +78,8 @@ export * from "./compassapibackendv2modelssafetransactresponsebatchedsafeoperati
|
|
|
78
78
|
export * from "./cooldownposition.js";
|
|
79
79
|
export * from "./createaccountrequest.js";
|
|
80
80
|
export * from "./createaccountresponse.js";
|
|
81
|
+
export * from "./depositforburnrequest.js";
|
|
82
|
+
export * from "./depositforburnresponse.js";
|
|
81
83
|
export * from "./details.js";
|
|
82
84
|
export * from "./earnmanagerequest.js";
|
|
83
85
|
export * from "./earnmanageresponse.js";
|
|
@@ -108,6 +110,9 @@ export * from "./market.js";
|
|
|
108
110
|
export * from "./marketposition.js";
|
|
109
111
|
export * from "./markettokens.js";
|
|
110
112
|
export * from "./maxsupplyapydata.js";
|
|
113
|
+
export * from "./mintpreparependingresponse.js";
|
|
114
|
+
export * from "./mintpreparereadyresponse.js";
|
|
115
|
+
export * from "./mintpreparerequest.js";
|
|
111
116
|
export * from "./morphoborrowparams.js";
|
|
112
117
|
export * from "./morphoborrowrequest.js";
|
|
113
118
|
export * from "./morphocheckmarketpositionresponse.js";
|