@compass-labs/api-sdk 2.1.9 → 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,78 @@
|
|
|
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
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Response when attestation is not yet ready.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
*
|
|
16
|
+
* Returned with 202 Accepted status code. The client should either:
|
|
17
|
+
* - Connect to the SSE stream for real-time updates
|
|
18
|
+
* - Poll the status endpoint periodically
|
|
19
|
+
* - Call /mint/prepare again after some time
|
|
20
|
+
*/
|
|
21
|
+
export type MintPreparePendingResponse = {
|
|
22
|
+
/**
|
|
23
|
+
* Indicates the attestation is still being awaited.
|
|
24
|
+
*/
|
|
25
|
+
status?: "pending" | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The bridge identifier.
|
|
28
|
+
*/
|
|
29
|
+
bridgeId: string;
|
|
30
|
+
/**
|
|
31
|
+
* The CCTP message hash being polled for attestation.
|
|
32
|
+
*/
|
|
33
|
+
messageHash: string;
|
|
34
|
+
/**
|
|
35
|
+
* SSE endpoint URL for real-time attestation updates.
|
|
36
|
+
*/
|
|
37
|
+
sseUrl: string;
|
|
38
|
+
/**
|
|
39
|
+
* HTTP endpoint URL for polling bridge status.
|
|
40
|
+
*/
|
|
41
|
+
statusUrl: string;
|
|
42
|
+
/**
|
|
43
|
+
* Estimated wait time in seconds. Fast mode is typically ~30 seconds, standard mode is 15-19 minutes.
|
|
44
|
+
*/
|
|
45
|
+
estimatedWaitSeconds: number;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** @internal */
|
|
49
|
+
export const MintPreparePendingResponse$inboundSchema: z.ZodType<
|
|
50
|
+
MintPreparePendingResponse,
|
|
51
|
+
z.ZodTypeDef,
|
|
52
|
+
unknown
|
|
53
|
+
> = z.object({
|
|
54
|
+
status: z.literal("pending").default("pending").optional(),
|
|
55
|
+
bridge_id: z.string(),
|
|
56
|
+
message_hash: z.string(),
|
|
57
|
+
sse_url: z.string(),
|
|
58
|
+
status_url: z.string(),
|
|
59
|
+
estimated_wait_seconds: z.number().int(),
|
|
60
|
+
}).transform((v) => {
|
|
61
|
+
return remap$(v, {
|
|
62
|
+
"bridge_id": "bridgeId",
|
|
63
|
+
"message_hash": "messageHash",
|
|
64
|
+
"sse_url": "sseUrl",
|
|
65
|
+
"status_url": "statusUrl",
|
|
66
|
+
"estimated_wait_seconds": "estimatedWaitSeconds",
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export function mintPreparePendingResponseFromJSON(
|
|
71
|
+
jsonString: string,
|
|
72
|
+
): SafeParseResult<MintPreparePendingResponse, SDKValidationError> {
|
|
73
|
+
return safeParse(
|
|
74
|
+
jsonString,
|
|
75
|
+
(x) => MintPreparePendingResponse$inboundSchema.parse(JSON.parse(x)),
|
|
76
|
+
`Failed to parse 'MintPreparePendingResponse' from JSON`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 when attestation is ready and mint transaction can be built.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
*
|
|
24
|
+
* Returned with 200 OK status code. Contains either an unsigned transaction for direct
|
|
25
|
+
* submission or EIP-712 typed data for gas-sponsored transactions. The transaction
|
|
26
|
+
* calls receiveMessage on the MessageTransmitter contract through the Earn Account
|
|
27
|
+
* (Safe).
|
|
28
|
+
*/
|
|
29
|
+
export type MintPrepareReadyResponse = {
|
|
30
|
+
/**
|
|
31
|
+
* Indicates the attestation is ready and mint transaction is available.
|
|
32
|
+
*/
|
|
33
|
+
status?: "ready" | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The bridge identifier.
|
|
36
|
+
*/
|
|
37
|
+
bridgeId: string;
|
|
38
|
+
/**
|
|
39
|
+
* Unsigned Safe execTransaction for the destination chain that calls receiveMessage on the MessageTransmitter contract. Sign and broadcast this to mint USDC to your Earn Account. Present when gas_sponsorship=False.
|
|
40
|
+
*/
|
|
41
|
+
transaction?: UnsignedTransaction | null | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* EIP-712 typed data for off-chain signing. The owner signs this data and submits it to /gas_sponsorship/prepare for a relayer to execute. Present when gas_sponsorship=True.
|
|
44
|
+
*/
|
|
45
|
+
eip712?: BatchedSafeOperationsResponseOutput | null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The CCTP message hash used to obtain the attestation.
|
|
48
|
+
*/
|
|
49
|
+
messageHash: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** @internal */
|
|
53
|
+
export const MintPrepareReadyResponse$inboundSchema: z.ZodType<
|
|
54
|
+
MintPrepareReadyResponse,
|
|
55
|
+
z.ZodTypeDef,
|
|
56
|
+
unknown
|
|
57
|
+
> = z.object({
|
|
58
|
+
status: z.literal("ready").default("ready").optional(),
|
|
59
|
+
bridge_id: z.string(),
|
|
60
|
+
transaction: z.nullable(UnsignedTransaction$inboundSchema).optional(),
|
|
61
|
+
eip_712: z.nullable(BatchedSafeOperationsResponseOutput$inboundSchema)
|
|
62
|
+
.optional(),
|
|
63
|
+
message_hash: z.string(),
|
|
64
|
+
}).transform((v) => {
|
|
65
|
+
return remap$(v, {
|
|
66
|
+
"bridge_id": "bridgeId",
|
|
67
|
+
"eip_712": "eip712",
|
|
68
|
+
"message_hash": "messageHash",
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export function mintPrepareReadyResponseFromJSON(
|
|
73
|
+
jsonString: string,
|
|
74
|
+
): SafeParseResult<MintPrepareReadyResponse, SDKValidationError> {
|
|
75
|
+
return safeParse(
|
|
76
|
+
jsonString,
|
|
77
|
+
(x) => MintPrepareReadyResponse$inboundSchema.parse(JSON.parse(x)),
|
|
78
|
+
`Failed to parse 'MintPrepareReadyResponse' from JSON`,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Request model for preparing a CCTP mint transaction on an Earn Account.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
*
|
|
13
|
+
* The mint/prepare endpoint uses the bridge_id to:
|
|
14
|
+
* 1. Look up the bridge session created during burn/prepare
|
|
15
|
+
* 2. Find the DepositForBurn event on the source chain
|
|
16
|
+
* 3. Extract the CCTP message and compute its hash
|
|
17
|
+
* 4. Check if Circle's attestation is ready
|
|
18
|
+
* 5. Return the mint transaction wrapped in Safe execTransaction
|
|
19
|
+
*
|
|
20
|
+
* This eliminates the need for users to provide the burn transaction hash.
|
|
21
|
+
*/
|
|
22
|
+
export type MintPrepareRequest = {
|
|
23
|
+
/**
|
|
24
|
+
* The bridge identifier returned from /burn endpoint. This is used to look up the bridge session and find the burn event.
|
|
25
|
+
*/
|
|
26
|
+
bridgeId: string;
|
|
27
|
+
/**
|
|
28
|
+
* The primary wallet address that owns and controls the Earn Account (Safe) on the destination chain. This is used to determine the Safe address that will receive and execute the receiveMessage transaction.
|
|
29
|
+
*/
|
|
30
|
+
owner: string;
|
|
31
|
+
/**
|
|
32
|
+
* 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`).
|
|
33
|
+
*/
|
|
34
|
+
gasSponsorship?: boolean | undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** @internal */
|
|
38
|
+
export type MintPrepareRequest$Outbound = {
|
|
39
|
+
bridge_id: string;
|
|
40
|
+
owner: string;
|
|
41
|
+
gas_sponsorship?: boolean | undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** @internal */
|
|
45
|
+
export const MintPrepareRequest$outboundSchema: z.ZodType<
|
|
46
|
+
MintPrepareRequest$Outbound,
|
|
47
|
+
z.ZodTypeDef,
|
|
48
|
+
MintPrepareRequest
|
|
49
|
+
> = z.object({
|
|
50
|
+
bridgeId: z.string(),
|
|
51
|
+
owner: z.string(),
|
|
52
|
+
gasSponsorship: z.boolean().optional(),
|
|
53
|
+
}).transform((v) => {
|
|
54
|
+
return remap$(v, {
|
|
55
|
+
bridgeId: "bridge_id",
|
|
56
|
+
gasSponsorship: "gas_sponsorship",
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export function mintPrepareRequestToJSON(
|
|
61
|
+
mintPrepareRequest: MintPrepareRequest,
|
|
62
|
+
): string {
|
|
63
|
+
return JSON.stringify(
|
|
64
|
+
MintPrepareRequest$outboundSchema.parse(mintPrepareRequest),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -40,6 +40,7 @@ export * from "./v1uniswapquotebuyexactly.js";
|
|
|
40
40
|
export * from "./v1uniswapquotesellexactly.js";
|
|
41
41
|
export * from "./v1vaultsvault.js";
|
|
42
42
|
export * from "./v1wildcatmarket.js";
|
|
43
|
+
export * from "./v2cctpmint.js";
|
|
43
44
|
export * from "./v2earnaavetokenrates.js";
|
|
44
45
|
export * from "./v2earnpositions.js";
|
|
45
46
|
export * from "./v2earnpositionspositionid.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import * as components from "../components/index.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
export type V2CctpMintResponse =
|
|
12
|
+
| components.MintPreparePendingResponse
|
|
13
|
+
| components.MintPrepareReadyResponse;
|
|
14
|
+
|
|
15
|
+
/** @internal */
|
|
16
|
+
export const V2CctpMintResponse$inboundSchema: z.ZodType<
|
|
17
|
+
V2CctpMintResponse,
|
|
18
|
+
z.ZodTypeDef,
|
|
19
|
+
unknown
|
|
20
|
+
> = z.union([
|
|
21
|
+
components.MintPreparePendingResponse$inboundSchema,
|
|
22
|
+
components.MintPrepareReadyResponse$inboundSchema,
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
export function v2CctpMintResponseFromJSON(
|
|
26
|
+
jsonString: string,
|
|
27
|
+
): SafeParseResult<V2CctpMintResponse, SDKValidationError> {
|
|
28
|
+
return safeParse(
|
|
29
|
+
jsonString,
|
|
30
|
+
(x) => V2CctpMintResponse$inboundSchema.parse(JSON.parse(x)),
|
|
31
|
+
`Failed to parse 'V2CctpMintResponse' from JSON`,
|
|
32
|
+
);
|
|
33
|
+
}
|
package/src/sdk/cctp.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { cctpCCTPBurn } from "../funcs/cctpCCTPBurn.js";
|
|
6
|
+
import { cctpCCTPMint } from "../funcs/cctpCCTPMint.js";
|
|
7
|
+
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
8
|
+
import * as components from "../models/components/index.js";
|
|
9
|
+
import * as operations from "../models/operations/index.js";
|
|
10
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
11
|
+
|
|
12
|
+
export class Cctp extends ClientSDK {
|
|
13
|
+
/**
|
|
14
|
+
* Build depositForBurn transaction for Earn Account
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Build a transaction to burn USDC from an Earn Account (Safe) on the source chain
|
|
18
|
+
* and initiate a cross-chain transfer via Circle's CCTP (Cross-Chain Transfer Protocol).
|
|
19
|
+
*
|
|
20
|
+
* **Flow:**
|
|
21
|
+
* 1. Call this endpoint with `gas_sponsorship=false` to get an unsigned transaction,
|
|
22
|
+
* or `gas_sponsorship=true` to get EIP-712 typed data for gas-sponsored execution
|
|
23
|
+
* 2. Owner signs the transaction or typed data
|
|
24
|
+
* 3. Broadcast the transaction on the source chain (or submit to `/gas_sponsorship/prepare`)
|
|
25
|
+
* 4. Wait for Circle's attestation service to attest the burn
|
|
26
|
+
* 5. Call the mint endpoint (when available) to receive USDC on the destination chain
|
|
27
|
+
*
|
|
28
|
+
* **Supported chains:**
|
|
29
|
+
* - Ethereum (domain 0)
|
|
30
|
+
* - Arbitrum (domain 3)
|
|
31
|
+
* - Base (domain 6)
|
|
32
|
+
*
|
|
33
|
+
* **Note:** The USDC must already be deposited in the Earn Account. If approval is needed
|
|
34
|
+
* for the TokenMessenger contract, it will be included in the transaction automatically.
|
|
35
|
+
*
|
|
36
|
+
* **Gas estimate:** ~200,000 gas units (includes Safe execTransaction overhead)
|
|
37
|
+
*/
|
|
38
|
+
async cctpBurn(
|
|
39
|
+
request: components.DepositForBurnRequest,
|
|
40
|
+
options?: RequestOptions,
|
|
41
|
+
): Promise<components.DepositForBurnResponse> {
|
|
42
|
+
return unwrapAsync(cctpCCTPBurn(
|
|
43
|
+
this,
|
|
44
|
+
request,
|
|
45
|
+
options,
|
|
46
|
+
));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Prepare mint transaction for Earn Account on destination chain
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* Prepare a receiveMessage transaction to mint USDC to an Earn Account (Safe) on the
|
|
54
|
+
* destination chain.
|
|
55
|
+
*
|
|
56
|
+
* **How it works:**
|
|
57
|
+
*
|
|
58
|
+
* This endpoint uses the `bridge_id` from `/burn` to:
|
|
59
|
+
* 1. Look up the bridge session (no burn tx hash needed!)
|
|
60
|
+
* 2. Find the DepositForBurn event on the source chain using stored nonce
|
|
61
|
+
* 3. Extract the CCTP message and compute its hash
|
|
62
|
+
* 4. Check if Circle's attestation is ready
|
|
63
|
+
* 5. Return the mint transaction wrapped in Safe execTransaction
|
|
64
|
+
*
|
|
65
|
+
* **Request parameters:**
|
|
66
|
+
*
|
|
67
|
+
* - `bridge_id`: The bridge ID returned from `/burn`
|
|
68
|
+
* - `owner`: The wallet address that owns the Earn Account (Safe) on the destination chain
|
|
69
|
+
* - `gas_sponsorship`: If true, returns EIP-712 typed data for gas-sponsored execution
|
|
70
|
+
*
|
|
71
|
+
* **Response codes:**
|
|
72
|
+
*
|
|
73
|
+
* - **200 OK**: Attestation is ready, mint transaction is included
|
|
74
|
+
* - **202 Accepted**: Attestation is pending, SSE URL for real-time updates is included
|
|
75
|
+
* - **400 Bad Request**: Bridge not found, or burn event not found yet
|
|
76
|
+
*
|
|
77
|
+
* **After receiving 202:**
|
|
78
|
+
*
|
|
79
|
+
* Either:
|
|
80
|
+
* - Connect to the SSE stream at `sse_url` and wait for `attestation_ready` event
|
|
81
|
+
* - Poll this endpoint periodically until you get 200
|
|
82
|
+
*
|
|
83
|
+
* **After receiving 200:**
|
|
84
|
+
*
|
|
85
|
+
* Sign and broadcast the returned transaction on the destination chain to mint USDC
|
|
86
|
+
* to your Earn Account.
|
|
87
|
+
*/
|
|
88
|
+
async cctpMint(
|
|
89
|
+
request: components.MintPrepareRequest,
|
|
90
|
+
options?: RequestOptions,
|
|
91
|
+
): Promise<operations.V2CctpMintResponse> {
|
|
92
|
+
return unwrapAsync(cctpCCTPMint(
|
|
93
|
+
this,
|
|
94
|
+
request,
|
|
95
|
+
options,
|
|
96
|
+
));
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { ClientSDK } from "../lib/sdks.js";
|
|
6
6
|
import { AaveV3 } from "./aavev3.js";
|
|
7
7
|
import { AerodromeSlipstream } from "./aerodromeslipstream.js";
|
|
8
|
+
import { Cctp } from "./cctp.js";
|
|
8
9
|
import { Earn } from "./earn.js";
|
|
9
10
|
import { Erc4626Vaults } from "./erc4626vaults.js";
|
|
10
11
|
import { Ethena } from "./ethena.js";
|
|
@@ -102,4 +103,9 @@ export class CompassApiSDK extends ClientSDK {
|
|
|
102
103
|
get earn(): Earn {
|
|
103
104
|
return (this._earn ??= new Earn(this._options));
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
private _cctp?: Cctp;
|
|
108
|
+
get cctp(): Cctp {
|
|
109
|
+
return (this._cctp ??= new Cctp(this._options));
|
|
110
|
+
}
|
|
105
111
|
}
|
|
@@ -16,8 +16,16 @@ export function startCountingUnrecognized() {
|
|
|
16
16
|
refCount++;
|
|
17
17
|
const start = globalCount;
|
|
18
18
|
return {
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Ends counting and returns the delta.
|
|
21
|
+
* @param delta - If provided, only this amount is added to the parent counter
|
|
22
|
+
* (used for nested unions where we only want to record the winning option's count).
|
|
23
|
+
* If not provided, records all counts since start().
|
|
24
|
+
*/
|
|
25
|
+
end: (delta?: number) => {
|
|
20
26
|
const count = globalCount - start;
|
|
27
|
+
// Reset globalCount back to start, then add only the specified delta
|
|
28
|
+
globalCount = start + (delta ?? count);
|
|
21
29
|
if (--refCount === 0) globalCount = 0;
|
|
22
30
|
return count;
|
|
23
31
|
},
|