@compass-labs/api-sdk 2.2.21 → 2.2.22-rc.0
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 +2 -2
- package/codeSamples_typescript.yaml +1 -1
- package/dist/commonjs/funcs/creditCreditTransfer.d.ts +10 -9
- package/dist/commonjs/funcs/creditCreditTransfer.d.ts.map +1 -1
- package/dist/commonjs/funcs/creditCreditTransfer.js +10 -9
- package/dist/commonjs/funcs/creditCreditTransfer.js.map +1 -1
- package/dist/commonjs/funcs/gasSponsorshipGasSponsorshipApproveTransfer.d.ts +1 -1
- package/dist/commonjs/funcs/gasSponsorshipGasSponsorshipApproveTransfer.js +1 -1
- package/dist/commonjs/funcs/gasSponsorshipGasSponsorshipPrepare.d.ts +2 -2
- package/dist/commonjs/funcs/gasSponsorshipGasSponsorshipPrepare.js +2 -2
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/components/credittransferrequest.d.ts +30 -1
- package/dist/commonjs/models/components/credittransferrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/credittransferrequest.js +18 -1
- package/dist/commonjs/models/components/credittransferrequest.js.map +1 -1
- package/dist/commonjs/models/components/credittransferresponse.d.ts +8 -1
- package/dist/commonjs/models/components/credittransferresponse.d.ts.map +1 -1
- package/dist/commonjs/models/components/credittransferresponse.js +17 -2
- package/dist/commonjs/models/components/credittransferresponse.js.map +1 -1
- package/dist/commonjs/sdk/credit.d.ts +10 -9
- package/dist/commonjs/sdk/credit.d.ts.map +1 -1
- package/dist/commonjs/sdk/credit.js +10 -9
- package/dist/commonjs/sdk/credit.js.map +1 -1
- package/dist/commonjs/sdk/gassponsorship.d.ts +3 -3
- package/dist/commonjs/sdk/gassponsorship.js +3 -3
- package/dist/esm/funcs/creditCreditTransfer.d.ts +10 -9
- package/dist/esm/funcs/creditCreditTransfer.d.ts.map +1 -1
- package/dist/esm/funcs/creditCreditTransfer.js +10 -9
- package/dist/esm/funcs/creditCreditTransfer.js.map +1 -1
- package/dist/esm/funcs/gasSponsorshipGasSponsorshipApproveTransfer.d.ts +1 -1
- package/dist/esm/funcs/gasSponsorshipGasSponsorshipApproveTransfer.js +1 -1
- package/dist/esm/funcs/gasSponsorshipGasSponsorshipPrepare.d.ts +2 -2
- package/dist/esm/funcs/gasSponsorshipGasSponsorshipPrepare.js +2 -2
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/components/credittransferrequest.d.ts +30 -1
- package/dist/esm/models/components/credittransferrequest.d.ts.map +1 -1
- package/dist/esm/models/components/credittransferrequest.js +17 -0
- package/dist/esm/models/components/credittransferrequest.js.map +1 -1
- package/dist/esm/models/components/credittransferresponse.d.ts +8 -1
- package/dist/esm/models/components/credittransferresponse.d.ts.map +1 -1
- package/dist/esm/models/components/credittransferresponse.js +15 -1
- package/dist/esm/models/components/credittransferresponse.js.map +1 -1
- package/dist/esm/sdk/credit.d.ts +10 -9
- package/dist/esm/sdk/credit.d.ts.map +1 -1
- package/dist/esm/sdk/credit.js +10 -9
- package/dist/esm/sdk/credit.js.map +1 -1
- package/dist/esm/sdk/gassponsorship.d.ts +3 -3
- package/dist/esm/sdk/gassponsorship.js +3 -3
- package/docs/models/components/credittransferrequest.md +10 -6
- package/docs/models/components/credittransferrequestaction.md +17 -0
- package/docs/models/components/credittransferresponse.md +4 -3
- package/docs/models/components/credittransferresponseeip712.md +97 -0
- package/docs/sdks/credit/README.md +12 -9
- package/docs/sdks/gassponsorship/README.md +3 -3
- package/package.json +1 -1
- package/src/funcs/creditCreditTransfer.ts +10 -9
- package/src/funcs/gasSponsorshipGasSponsorshipApproveTransfer.ts +1 -1
- package/src/funcs/gasSponsorshipGasSponsorshipPrepare.ts +2 -2
- package/src/lib/config.ts +2 -2
- package/src/models/components/credittransferrequest.ts +44 -1
- package/src/models/components/credittransferresponse.ts +45 -2
- package/src/sdk/credit.ts +10 -9
- package/src/sdk/gassponsorship.ts +3 -3
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# CreditTransferResponseEip712
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Supported Types
|
|
5
|
+
|
|
6
|
+
### `components.BatchedSafeOperationsResponseOutput`
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
const value: components.BatchedSafeOperationsResponseOutput = {
|
|
10
|
+
domain: {
|
|
11
|
+
chainId: 359509,
|
|
12
|
+
verifyingContract: "<value>",
|
|
13
|
+
},
|
|
14
|
+
types: {
|
|
15
|
+
eip712Domain: [],
|
|
16
|
+
safeTx: [],
|
|
17
|
+
},
|
|
18
|
+
primaryType: "SafeTx",
|
|
19
|
+
message: {
|
|
20
|
+
to: "<value>",
|
|
21
|
+
value: "<value>",
|
|
22
|
+
data: "<value>",
|
|
23
|
+
operation: 0,
|
|
24
|
+
safeTxGas: "<value>",
|
|
25
|
+
baseGas: "<value>",
|
|
26
|
+
gasPrice: "<value>",
|
|
27
|
+
gasToken: "<value>",
|
|
28
|
+
refundReceiver: "<value>",
|
|
29
|
+
nonce: "<value>",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### `components.Permit2TypedDataOutput`
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const value: components.Permit2TypedDataOutput = {
|
|
38
|
+
types: {
|
|
39
|
+
eip712Domain: [
|
|
40
|
+
{
|
|
41
|
+
name: "name",
|
|
42
|
+
type: "string",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "chainId",
|
|
46
|
+
type: "uint256",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "verifyingContract",
|
|
50
|
+
type: "address",
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
tokenPermissions: [
|
|
54
|
+
{
|
|
55
|
+
name: "token",
|
|
56
|
+
type: "address",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "amount",
|
|
60
|
+
type: "uint256",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
permitTransferFrom: [
|
|
64
|
+
{
|
|
65
|
+
name: "permitted",
|
|
66
|
+
type: "TokenPermissions",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "spender",
|
|
70
|
+
type: "address",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "nonce",
|
|
74
|
+
type: "uint256",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "deadline",
|
|
78
|
+
type: "uint256",
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
domain: {
|
|
83
|
+
chainId: 659817,
|
|
84
|
+
verifyingContract: "<value>",
|
|
85
|
+
},
|
|
86
|
+
message: {
|
|
87
|
+
permitted: {
|
|
88
|
+
token: "<value>",
|
|
89
|
+
amount: 387057,
|
|
90
|
+
},
|
|
91
|
+
spender: "<value>",
|
|
92
|
+
nonce: 382019,
|
|
93
|
+
deadline: 22738,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* [creditPositions](#creditpositions) - List credit positions
|
|
8
8
|
* [creditCreateAccount](#creditcreateaccount) - Create credit account
|
|
9
9
|
* [creditBorrow](#creditborrow) - Borrow against collateral
|
|
10
|
-
* [creditTransfer](#credittransfer) -
|
|
10
|
+
* [creditTransfer](#credittransfer) - Transfer tokens to/from Credit Account
|
|
11
11
|
* [creditRepay](#creditrepay) - Repay debt and withdraw collateral
|
|
12
12
|
* [creditBundle](#creditbundle) - Execute multiple credit actions atomically
|
|
13
13
|
|
|
@@ -277,16 +277,17 @@ run();
|
|
|
277
277
|
|
|
278
278
|
## creditTransfer
|
|
279
279
|
|
|
280
|
-
|
|
281
|
-
to a Credit Account.
|
|
280
|
+
Transfer tokens between the owner's EOA and their Credit Account.
|
|
282
281
|
|
|
283
|
-
|
|
284
|
-
|
|
282
|
+
**DEPOSIT** (EOA → Credit Account):
|
|
283
|
+
- With `gas_sponsorship=true`: returns Permit2 EIP-712 typed data to sign. The gas sponsor
|
|
284
|
+
calls `permitTransferFrom` to pull tokens (1 signature).
|
|
285
|
+
- With `gas_sponsorship=false`: returns an unsigned ERC-20 transfer transaction.
|
|
285
286
|
|
|
286
|
-
**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
**WITHDRAW** (Credit Account → EOA):
|
|
288
|
+
- With `gas_sponsorship=true`: returns SafeTx EIP-712 typed data to sign. The gas sponsor
|
|
289
|
+
broadcasts the `execTransaction` (1 signature).
|
|
290
|
+
- With `gas_sponsorship=false`: returns an unsigned `execTransaction`.
|
|
290
291
|
|
|
291
292
|
### Example Usage
|
|
292
293
|
|
|
@@ -304,6 +305,7 @@ async function run() {
|
|
|
304
305
|
chain: "base",
|
|
305
306
|
token: "USDC",
|
|
306
307
|
amount: 100,
|
|
308
|
+
action: "DEPOSIT",
|
|
307
309
|
});
|
|
308
310
|
|
|
309
311
|
console.log(result);
|
|
@@ -332,6 +334,7 @@ async function run() {
|
|
|
332
334
|
chain: "base",
|
|
333
335
|
token: "USDC",
|
|
334
336
|
amount: 100,
|
|
337
|
+
action: "DEPOSIT",
|
|
335
338
|
});
|
|
336
339
|
if (res.ok) {
|
|
337
340
|
const { value: result } = res;
|
|
@@ -14,12 +14,12 @@ Prepare a gas-sponsored transaction from signed EIP-712 typed data.
|
|
|
14
14
|
Submit the `owner`'s off-chain signature along with the EIP-712 typed data that was signed. Returns an unsigned transaction for the `sender` to sign and broadcast.
|
|
15
15
|
|
|
16
16
|
**How gas sponsorship works:**
|
|
17
|
-
1. Call an endpoint with `gas_sponsorship=true` (e.g., [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), [/earn/manage](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position)) to get EIP-712 typed data
|
|
17
|
+
1. Call an endpoint with `gas_sponsorship=true` (e.g., [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), [/earn/manage](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position), [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account)) to get EIP-712 typed data
|
|
18
18
|
2. Owner signs the typed data off-chain
|
|
19
19
|
3. Submit signature + typed data to this endpoint
|
|
20
20
|
4. Sender signs and broadcasts the returned transaction, paying gas on behalf of the owner
|
|
21
21
|
|
|
22
|
-
**Note:** For gas-sponsored deposits via [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), the owner must first set up a Permit2 allowance using [/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) (once per token).
|
|
22
|
+
**Note:** For gas-sponsored deposits via [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account), the owner must first set up a Permit2 allowance using [/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) (once per token).
|
|
23
23
|
|
|
24
24
|
### Example Usage
|
|
25
25
|
|
|
@@ -217,7 +217,7 @@ run();
|
|
|
217
217
|
|
|
218
218
|
Set up a one-time Permit2 allowance for gas-sponsored token transfers.
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
Required when using [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account) with `gas_sponsorship=true`. This allowance only needs to be set up once per token.
|
|
221
221
|
|
|
222
222
|
**With gas sponsorship (`gas_sponsorship=true`):**
|
|
223
223
|
- Returns EIP-712 typed data for the owner to sign off-chain
|
package/package.json
CHANGED
|
@@ -26,19 +26,20 @@ import { APICall, APIPromise } from "../types/async.js";
|
|
|
26
26
|
import { Result } from "../types/fp.js";
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Transfer tokens to/from Credit Account
|
|
30
30
|
*
|
|
31
31
|
* @remarks
|
|
32
|
-
*
|
|
33
|
-
* to a Credit Account.
|
|
32
|
+
* Transfer tokens between the owner's EOA and their Credit Account.
|
|
34
33
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* **DEPOSIT** (EOA → Credit Account):
|
|
35
|
+
* - With `gas_sponsorship=true`: returns Permit2 EIP-712 typed data to sign. The gas sponsor
|
|
36
|
+
* calls `permitTransferFrom` to pull tokens (1 signature).
|
|
37
|
+
* - With `gas_sponsorship=false`: returns an unsigned ERC-20 transfer transaction.
|
|
37
38
|
*
|
|
38
|
-
* **
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* **WITHDRAW** (Credit Account → EOA):
|
|
40
|
+
* - With `gas_sponsorship=true`: returns SafeTx EIP-712 typed data to sign. The gas sponsor
|
|
41
|
+
* broadcasts the `execTransaction` (1 signature).
|
|
42
|
+
* - With `gas_sponsorship=false`: returns an unsigned `execTransaction`.
|
|
42
43
|
*/
|
|
43
44
|
export function creditCreditTransfer(
|
|
44
45
|
client: CompassApiSDKCore,
|
|
@@ -31,7 +31,7 @@ import { Result } from "../types/fp.js";
|
|
|
31
31
|
* @remarks
|
|
32
32
|
* Set up a one-time Permit2 allowance for gas-sponsored token transfers.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
34
|
+
* Required when using [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account) with `gas_sponsorship=true`. This allowance only needs to be set up once per token.
|
|
35
35
|
*
|
|
36
36
|
* **With gas sponsorship (`gas_sponsorship=true`):**
|
|
37
37
|
* - Returns EIP-712 typed data for the owner to sign off-chain
|
|
@@ -34,12 +34,12 @@ import { Result } from "../types/fp.js";
|
|
|
34
34
|
* Submit the `owner`'s off-chain signature along with the EIP-712 typed data that was signed. Returns an unsigned transaction for the `sender` to sign and broadcast.
|
|
35
35
|
*
|
|
36
36
|
* **How gas sponsorship works:**
|
|
37
|
-
* 1. Call an endpoint with `gas_sponsorship=true` (e.g., [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), [/earn/manage](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position)) to get EIP-712 typed data
|
|
37
|
+
* 1. Call an endpoint with `gas_sponsorship=true` (e.g., [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), [/earn/manage](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position), [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account)) to get EIP-712 typed data
|
|
38
38
|
* 2. Owner signs the typed data off-chain
|
|
39
39
|
* 3. Submit signature + typed data to this endpoint
|
|
40
40
|
* 4. Sender signs and broadcasts the returned transaction, paying gas on behalf of the owner
|
|
41
41
|
*
|
|
42
|
-
* **Note:** For gas-sponsored deposits via [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), the owner must first set up a Permit2 allowance using [/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) (once per token).
|
|
42
|
+
* **Note:** For gas-sponsored deposits via [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account), the owner must first set up a Permit2 allowance using [/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) (once per token).
|
|
43
43
|
*/
|
|
44
44
|
export function gasSponsorshipGasSponsorshipPrepare(
|
|
45
45
|
client: CompassApiSDKCore,
|
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.841.0",
|
|
66
66
|
userAgent:
|
|
67
|
-
"speakeasy-sdk/typescript 2.0.0 2.
|
|
67
|
+
"speakeasy-sdk/typescript 2.0.0 2.841.0 0.0.1 @compass-labs/api-sdk",
|
|
68
68
|
} as const;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
6
8
|
import { Chain, Chain$outboundSchema } from "./chain.js";
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -10,6 +12,20 @@ import { Chain, Chain$outboundSchema } from "./chain.js";
|
|
|
10
12
|
*/
|
|
11
13
|
export type CreditTransferRequestAmount = number | string;
|
|
12
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Whether you are depositing to or withdrawing from your credit account.
|
|
17
|
+
*/
|
|
18
|
+
export const CreditTransferRequestAction = {
|
|
19
|
+
Deposit: "DEPOSIT",
|
|
20
|
+
Withdraw: "WITHDRAW",
|
|
21
|
+
} as const;
|
|
22
|
+
/**
|
|
23
|
+
* Whether you are depositing to or withdrawing from your credit account.
|
|
24
|
+
*/
|
|
25
|
+
export type CreditTransferRequestAction = ClosedEnum<
|
|
26
|
+
typeof CreditTransferRequestAction
|
|
27
|
+
>;
|
|
28
|
+
|
|
13
29
|
export type CreditTransferRequest = {
|
|
14
30
|
/**
|
|
15
31
|
* The owner's wallet address (EOA).
|
|
@@ -20,13 +36,25 @@ export type CreditTransferRequest = {
|
|
|
20
36
|
*/
|
|
21
37
|
chain: Chain;
|
|
22
38
|
/**
|
|
23
|
-
* The token to transfer
|
|
39
|
+
* The token to transfer.
|
|
24
40
|
*/
|
|
25
41
|
token: string;
|
|
26
42
|
/**
|
|
27
43
|
* The amount of tokens to transfer (in token units, not wei).
|
|
28
44
|
*/
|
|
29
45
|
amount: number | string;
|
|
46
|
+
/**
|
|
47
|
+
* Whether you are depositing to or withdrawing from your credit account.
|
|
48
|
+
*/
|
|
49
|
+
action: CreditTransferRequestAction;
|
|
50
|
+
/**
|
|
51
|
+
* Optionally request gas sponsorship. If set to `true`, EIP-712 signature data will be returned that must be signed by the `owner` and submitted to the `/gas_sponsorship/prepare` endpoint.
|
|
52
|
+
*/
|
|
53
|
+
gasSponsorship?: boolean | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The address that will call Permit2's permitTransferFrom to execute the transfer. When `action` is 'DEPOSIT' and `gas_sponsorship` is `true`: - If provided, the signature will authorize this address (typically a gas sponsor) to pull tokens. - If not provided, defaults to the Credit Account (Safe) address, allowing the transfer to be included in a bundle transaction where the Safe pulls the tokens itself.
|
|
56
|
+
*/
|
|
57
|
+
spender?: string | null | undefined;
|
|
30
58
|
};
|
|
31
59
|
|
|
32
60
|
/** @internal */
|
|
@@ -49,12 +77,20 @@ export function creditTransferRequestAmountToJSON(
|
|
|
49
77
|
);
|
|
50
78
|
}
|
|
51
79
|
|
|
80
|
+
/** @internal */
|
|
81
|
+
export const CreditTransferRequestAction$outboundSchema: z.ZodNativeEnum<
|
|
82
|
+
typeof CreditTransferRequestAction
|
|
83
|
+
> = z.nativeEnum(CreditTransferRequestAction);
|
|
84
|
+
|
|
52
85
|
/** @internal */
|
|
53
86
|
export type CreditTransferRequest$Outbound = {
|
|
54
87
|
owner: string;
|
|
55
88
|
chain: string;
|
|
56
89
|
token: string;
|
|
57
90
|
amount: number | string;
|
|
91
|
+
action: string;
|
|
92
|
+
gas_sponsorship?: boolean | undefined;
|
|
93
|
+
spender?: string | null | undefined;
|
|
58
94
|
};
|
|
59
95
|
|
|
60
96
|
/** @internal */
|
|
@@ -67,6 +103,13 @@ export const CreditTransferRequest$outboundSchema: z.ZodType<
|
|
|
67
103
|
chain: Chain$outboundSchema,
|
|
68
104
|
token: z.string(),
|
|
69
105
|
amount: z.union([z.number(), z.string()]),
|
|
106
|
+
action: CreditTransferRequestAction$outboundSchema,
|
|
107
|
+
gasSponsorship: z.boolean().optional(),
|
|
108
|
+
spender: z.nullable(z.string()).optional(),
|
|
109
|
+
}).transform((v) => {
|
|
110
|
+
return remap$(v, {
|
|
111
|
+
gasSponsorship: "gas_sponsorship",
|
|
112
|
+
});
|
|
70
113
|
});
|
|
71
114
|
|
|
72
115
|
export function creditTransferRequestToJSON(
|
|
@@ -7,22 +7,65 @@ import { remap as remap$ } from "../../lib/primitives.js";
|
|
|
7
7
|
import { safeParse } from "../../lib/schemas.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
BatchedSafeOperationsResponseOutput,
|
|
12
|
+
BatchedSafeOperationsResponseOutput$inboundSchema,
|
|
13
|
+
} from "./batchedsafeoperationsresponseoutput.js";
|
|
10
14
|
import {
|
|
11
15
|
Permit2TypedDataOutput,
|
|
12
16
|
Permit2TypedDataOutput$inboundSchema,
|
|
13
17
|
} from "./permit2typeddataoutput.js";
|
|
18
|
+
import {
|
|
19
|
+
UnsignedTransaction,
|
|
20
|
+
UnsignedTransaction$inboundSchema,
|
|
21
|
+
} from "./unsignedtransaction.js";
|
|
22
|
+
|
|
23
|
+
export type CreditTransferResponseEip712 =
|
|
24
|
+
| BatchedSafeOperationsResponseOutput
|
|
25
|
+
| Permit2TypedDataOutput;
|
|
14
26
|
|
|
15
27
|
export type CreditTransferResponse = {
|
|
16
|
-
|
|
28
|
+
transaction?: UnsignedTransaction | null | undefined;
|
|
29
|
+
eip712?:
|
|
30
|
+
| BatchedSafeOperationsResponseOutput
|
|
31
|
+
| Permit2TypedDataOutput
|
|
32
|
+
| null
|
|
33
|
+
| undefined;
|
|
17
34
|
};
|
|
18
35
|
|
|
36
|
+
/** @internal */
|
|
37
|
+
export const CreditTransferResponseEip712$inboundSchema: z.ZodType<
|
|
38
|
+
CreditTransferResponseEip712,
|
|
39
|
+
z.ZodTypeDef,
|
|
40
|
+
unknown
|
|
41
|
+
> = z.union([
|
|
42
|
+
BatchedSafeOperationsResponseOutput$inboundSchema,
|
|
43
|
+
Permit2TypedDataOutput$inboundSchema,
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
export function creditTransferResponseEip712FromJSON(
|
|
47
|
+
jsonString: string,
|
|
48
|
+
): SafeParseResult<CreditTransferResponseEip712, SDKValidationError> {
|
|
49
|
+
return safeParse(
|
|
50
|
+
jsonString,
|
|
51
|
+
(x) => CreditTransferResponseEip712$inboundSchema.parse(JSON.parse(x)),
|
|
52
|
+
`Failed to parse 'CreditTransferResponseEip712' from JSON`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
19
56
|
/** @internal */
|
|
20
57
|
export const CreditTransferResponse$inboundSchema: z.ZodType<
|
|
21
58
|
CreditTransferResponse,
|
|
22
59
|
z.ZodTypeDef,
|
|
23
60
|
unknown
|
|
24
61
|
> = z.object({
|
|
25
|
-
|
|
62
|
+
transaction: z.nullable(UnsignedTransaction$inboundSchema).optional(),
|
|
63
|
+
eip_712: z.nullable(
|
|
64
|
+
z.union([
|
|
65
|
+
BatchedSafeOperationsResponseOutput$inboundSchema,
|
|
66
|
+
Permit2TypedDataOutput$inboundSchema,
|
|
67
|
+
]),
|
|
68
|
+
).optional(),
|
|
26
69
|
}).transform((v) => {
|
|
27
70
|
return remap$(v, {
|
|
28
71
|
"eip_712": "eip712",
|
package/src/sdk/credit.ts
CHANGED
|
@@ -84,19 +84,20 @@ export class Credit extends ClientSDK {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
87
|
+
* Transfer tokens to/from Credit Account
|
|
88
88
|
*
|
|
89
89
|
* @remarks
|
|
90
|
-
*
|
|
91
|
-
* to a Credit Account.
|
|
90
|
+
* Transfer tokens between the owner's EOA and their Credit Account.
|
|
92
91
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
92
|
+
* **DEPOSIT** (EOA → Credit Account):
|
|
93
|
+
* - With `gas_sponsorship=true`: returns Permit2 EIP-712 typed data to sign. The gas sponsor
|
|
94
|
+
* calls `permitTransferFrom` to pull tokens (1 signature).
|
|
95
|
+
* - With `gas_sponsorship=false`: returns an unsigned ERC-20 transfer transaction.
|
|
95
96
|
*
|
|
96
|
-
* **
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
97
|
+
* **WITHDRAW** (Credit Account → EOA):
|
|
98
|
+
* - With `gas_sponsorship=true`: returns SafeTx EIP-712 typed data to sign. The gas sponsor
|
|
99
|
+
* broadcasts the `execTransaction` (1 signature).
|
|
100
|
+
* - With `gas_sponsorship=false`: returns an unsigned `execTransaction`.
|
|
100
101
|
*/
|
|
101
102
|
async creditTransfer(
|
|
102
103
|
request: components.CreditTransferRequest,
|
|
@@ -18,12 +18,12 @@ export class GasSponsorship extends ClientSDK {
|
|
|
18
18
|
* Submit the `owner`'s off-chain signature along with the EIP-712 typed data that was signed. Returns an unsigned transaction for the `sender` to sign and broadcast.
|
|
19
19
|
*
|
|
20
20
|
* **How gas sponsorship works:**
|
|
21
|
-
* 1. Call an endpoint with `gas_sponsorship=true` (e.g., [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), [/earn/manage](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position)) to get EIP-712 typed data
|
|
21
|
+
* 1. Call an endpoint with `gas_sponsorship=true` (e.g., [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), [/earn/manage](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position), [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account)) to get EIP-712 typed data
|
|
22
22
|
* 2. Owner signs the typed data off-chain
|
|
23
23
|
* 3. Submit signature + typed data to this endpoint
|
|
24
24
|
* 4. Sender signs and broadcasts the returned transaction, paying gas on behalf of the owner
|
|
25
25
|
*
|
|
26
|
-
* **Note:** For gas-sponsored deposits via [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), the owner must first set up a Permit2 allowance using [/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) (once per token).
|
|
26
|
+
* **Note:** For gas-sponsored deposits via [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account), the owner must first set up a Permit2 allowance using [/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) (once per token).
|
|
27
27
|
*/
|
|
28
28
|
async gasSponsorshipPrepare(
|
|
29
29
|
request: components.SponsorGasRequest,
|
|
@@ -42,7 +42,7 @@ export class GasSponsorship extends ClientSDK {
|
|
|
42
42
|
* @remarks
|
|
43
43
|
* Set up a one-time Permit2 allowance for gas-sponsored token transfers.
|
|
44
44
|
*
|
|
45
|
-
*
|
|
45
|
+
* Required when using [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account) with `gas_sponsorship=true`. This allowance only needs to be set up once per token.
|
|
46
46
|
*
|
|
47
47
|
* **With gas sponsorship (`gas_sponsorship=true`):**
|
|
48
48
|
* - Returns EIP-712 typed data for the owner to sign off-chain
|