@circle-fin/usdckit 0.22.0 → 0.23.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.
Files changed (59) hide show
  1. package/dist/cjs/abis/EIP2612.d.ts +197 -0
  2. package/dist/cjs/abis/EIP2612.js +78 -0
  3. package/dist/cjs/actions/index.d.ts +66 -0
  4. package/dist/cjs/actions/index.js +7 -0
  5. package/dist/cjs/actions/index.test.js +4 -0
  6. package/dist/cjs/actions/permit.d.ts +19 -0
  7. package/dist/cjs/actions/permit.js +50 -0
  8. package/dist/cjs/actions/permit.test.d.ts +1 -0
  9. package/dist/cjs/actions/permit.test.js +652 -0
  10. package/dist/cjs/actions/signEIP2612Permit.d.ts +130 -0
  11. package/dist/cjs/actions/signEIP2612Permit.js +128 -0
  12. package/dist/cjs/actions/signEIP2612Permit.test.d.ts +1 -0
  13. package/dist/cjs/actions/signEIP2612Permit.test.js +434 -0
  14. package/dist/cjs/chains/ARC_TESTNET.d.ts +180 -0
  15. package/dist/cjs/chains/ARC_TESTNET.js +57 -0
  16. package/dist/cjs/chains/index.d.ts +1 -0
  17. package/dist/cjs/chains/index.js +3 -1
  18. package/dist/cjs/chains/index.test.js +1 -0
  19. package/dist/cjs/extractChain.d.ts +179 -0
  20. package/dist/cjs/extractChain.test.js +1 -0
  21. package/dist/cjs/metadata.js +1 -1
  22. package/dist/cjs/providers/circle-wallets/actions/createAccount.d.ts +179 -0
  23. package/dist/cjs/providers/circle-wallets/actions/createAccount.js +3 -0
  24. package/dist/cjs/providers/circle-wallets/actions/estimateContractExecutionFee.d.ts +6 -0
  25. package/dist/cjs/providers/circle-wallets/actions/estimateTransferFee.d.ts +6 -0
  26. package/dist/cjs/providers/circle-wallets/actions/getAccounts.d.ts +179 -0
  27. package/dist/cjs/providers/circle-wallets/index.d.ts +358 -0
  28. package/dist/cjs/providers/circle-wallets/index.js +2 -0
  29. package/dist/cjs/providers/circle-wallets/transports/index.d.ts +12 -0
  30. package/dist/esm/abis/EIP2612.d.ts +197 -0
  31. package/dist/esm/abis/EIP2612.js +76 -0
  32. package/dist/esm/actions/index.d.ts +66 -0
  33. package/dist/esm/actions/index.js +7 -0
  34. package/dist/esm/actions/index.test.js +4 -0
  35. package/dist/esm/actions/permit.d.ts +19 -0
  36. package/dist/esm/actions/permit.js +44 -0
  37. package/dist/esm/actions/permit.test.d.ts +1 -0
  38. package/dist/esm/actions/permit.test.js +650 -0
  39. package/dist/esm/actions/signEIP2612Permit.d.ts +130 -0
  40. package/dist/esm/actions/signEIP2612Permit.js +122 -0
  41. package/dist/esm/actions/signEIP2612Permit.test.d.ts +1 -0
  42. package/dist/esm/actions/signEIP2612Permit.test.js +432 -0
  43. package/dist/esm/chains/ARC_TESTNET.d.ts +180 -0
  44. package/dist/esm/chains/ARC_TESTNET.js +54 -0
  45. package/dist/esm/chains/index.d.ts +1 -0
  46. package/dist/esm/chains/index.js +1 -0
  47. package/dist/esm/chains/index.test.js +1 -0
  48. package/dist/esm/extractChain.d.ts +179 -0
  49. package/dist/esm/extractChain.test.js +2 -1
  50. package/dist/esm/metadata.js +1 -1
  51. package/dist/esm/providers/circle-wallets/actions/createAccount.d.ts +179 -0
  52. package/dist/esm/providers/circle-wallets/actions/createAccount.js +3 -0
  53. package/dist/esm/providers/circle-wallets/actions/estimateContractExecutionFee.d.ts +6 -0
  54. package/dist/esm/providers/circle-wallets/actions/estimateTransferFee.d.ts +6 -0
  55. package/dist/esm/providers/circle-wallets/actions/getAccounts.d.ts +179 -0
  56. package/dist/esm/providers/circle-wallets/index.d.ts +358 -0
  57. package/dist/esm/providers/circle-wallets/index.js +3 -1
  58. package/dist/esm/providers/circle-wallets/transports/index.d.ts +12 -0
  59. package/package.json +5 -4
@@ -0,0 +1,76 @@
1
+ import { erc20Abi } from 'viem';
2
+ /**
3
+ * EIP-2612 ABI extension
4
+ */
5
+ export default [
6
+ ...erc20Abi,
7
+ {
8
+ inputs: [
9
+ {
10
+ internalType: 'address',
11
+ name: 'owner',
12
+ type: 'address',
13
+ },
14
+ ],
15
+ stateMutability: 'view',
16
+ type: 'function',
17
+ name: 'nonces',
18
+ outputs: [
19
+ {
20
+ internalType: 'uint256',
21
+ name: '',
22
+ type: 'uint256',
23
+ },
24
+ ],
25
+ },
26
+ {
27
+ inputs: [],
28
+ name: 'version',
29
+ outputs: [{ internalType: 'string', name: '', type: 'string' }],
30
+ stateMutability: 'view',
31
+ type: 'function',
32
+ },
33
+ {
34
+ inputs: [
35
+ {
36
+ internalType: 'address',
37
+ name: 'owner',
38
+ type: 'address',
39
+ },
40
+ {
41
+ internalType: 'address',
42
+ name: 'spender',
43
+ type: 'address',
44
+ },
45
+ {
46
+ internalType: 'uint256',
47
+ name: 'value',
48
+ type: 'uint256',
49
+ },
50
+ {
51
+ internalType: 'uint256',
52
+ name: 'deadline',
53
+ type: 'uint256',
54
+ },
55
+ {
56
+ internalType: 'uint8',
57
+ name: 'v',
58
+ type: 'uint8',
59
+ },
60
+ {
61
+ internalType: 'bytes32',
62
+ name: 'r',
63
+ type: 'bytes32',
64
+ },
65
+ {
66
+ internalType: 'bytes32',
67
+ name: 's',
68
+ type: 'bytes32',
69
+ },
70
+ ],
71
+ name: 'permit',
72
+ outputs: [],
73
+ stateMutability: 'nonpayable',
74
+ type: 'function',
75
+ },
76
+ ];
@@ -1,6 +1,8 @@
1
1
  import { generateTransferLink } from './generateTransferLink.js';
2
2
  import { getSwapExactInQuote } from './getSwapExactInQuote.js';
3
3
  import { getTokenBalance } from './getTokenBalance.js';
4
+ import { permit } from './permit.js';
5
+ import { signEIP2612Permit } from './signEIP2612Permit.js';
4
6
  import { swapExactIn } from './swapExactIn.js';
5
7
  import { sweep } from './sweep.js';
6
8
  import { transfer } from './transfer.js';
@@ -9,6 +11,8 @@ import type { Account } from '../types.js';
9
11
  import type { GenerateTransferLinkParams } from './generateTransferLink.js';
10
12
  import type { GetSwapExactInQuoteParams } from './getSwapExactInQuote.js';
11
13
  import type { GetTokenBalanceInput } from './getTokenBalance.js';
14
+ import type { PermitParams } from './permit.js';
15
+ import type { SignEIP2612PermitParams } from './signEIP2612Permit.js';
12
16
  import type { SwapExactInParams } from './swapExactIn.js';
13
17
  import type { SweepParams } from './sweep.js';
14
18
  import type { TransferParams } from './transfer.js';
@@ -18,6 +22,7 @@ export * from './sweep.js';
18
22
  export * from './generateTransferLink.js';
19
23
  export * from './getSwapExactInQuote.js';
20
24
  export * from './getTokenBalance.js';
25
+ export * from './permit.js';
21
26
  export * from './swapExactIn.js';
22
27
  export { FEE_LEVEL_WITH_PREPARE } from '../providers/circle-wallets/actions/index.js';
23
28
  export type Actions<transport extends Transport = Transport, chain extends ViemChain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = {
@@ -35,6 +40,10 @@ export type Actions<transport extends Transport = Transport, chain extends ViemC
35
40
  getSwapExactInQuote: (params: Parameters<typeof getSwapExactInQuote>[1]) => ReturnType<typeof getSwapExactInQuote>;
36
41
  /** See {@link getTokenBalance} action */
37
42
  getTokenBalance: (params: Parameters<typeof getTokenBalance>[1]) => ReturnType<typeof getTokenBalance>;
43
+ /** See {@link signEIP2612Permit} action */
44
+ signEIP2612Permit: (params: Parameters<typeof signEIP2612Permit>[1]) => ReturnType<typeof signEIP2612Permit>;
45
+ /** See {@link permit} action */
46
+ permit: (params: Parameters<typeof permit>[1]) => ReturnType<typeof permit>;
38
47
  /** See {@link swapExactIn} action */
39
48
  swap: (params: Parameters<typeof swapExactIn>[1]) => ReturnType<typeof swapExactIn>;
40
49
  /** See {@link swapExactIn} action */
@@ -61,6 +70,63 @@ export declare function actions(client: Client): {
61
70
  getSwapExactInQuote: (params: GetSwapExactInQuoteParams) => Promise<import("./getSwapExactInQuote.js").GetSwapExactInQuoteReturnType>;
62
71
  /** See {@link getTokenBalance} action */
63
72
  getTokenBalance: (params: GetTokenBalanceInput) => Promise<import("./getTokenBalance.js").GetTokenBalanceReturnType>;
73
+ /** See {@link signEIP2612Permit} action */
74
+ signEIP2612Permit: (params: SignEIP2612PermitParams) => Promise<{
75
+ typedData: {
76
+ readonly types: {
77
+ readonly EIP712Domain: readonly [{
78
+ readonly name: "name";
79
+ readonly type: "string";
80
+ }, {
81
+ readonly name: "version";
82
+ readonly type: "string";
83
+ }, {
84
+ readonly name: "chainId";
85
+ readonly type: "uint256";
86
+ }, {
87
+ readonly name: "verifyingContract";
88
+ readonly type: "address";
89
+ }];
90
+ readonly Permit: readonly [{
91
+ readonly name: "owner";
92
+ readonly type: "address";
93
+ }, {
94
+ readonly name: "spender";
95
+ readonly type: "address";
96
+ }, {
97
+ readonly name: "value";
98
+ readonly type: "uint256";
99
+ }, {
100
+ readonly name: "nonce";
101
+ readonly type: "uint256";
102
+ }, {
103
+ readonly name: "deadline";
104
+ readonly type: "uint256";
105
+ }];
106
+ };
107
+ readonly primaryType: "Permit";
108
+ readonly domain: {
109
+ readonly name: string;
110
+ readonly version: string;
111
+ readonly chainId: bigint;
112
+ readonly verifyingContract: `0x${string}`;
113
+ };
114
+ readonly message: {
115
+ readonly owner: `0x${string}`;
116
+ readonly spender: `0x${string}`;
117
+ readonly value: bigint;
118
+ readonly nonce: bigint;
119
+ readonly deadline: bigint;
120
+ };
121
+ };
122
+ signature: `0x${string}`;
123
+ r: `0x${string}`;
124
+ s: `0x${string}`;
125
+ yParity: number;
126
+ v: number;
127
+ }>;
128
+ /** See {@link permit} action */
129
+ permit: (params: PermitParams) => Promise<`0x${string}`>;
64
130
  /** See {@link swapExactIn} action */
65
131
  swap: (params: SwapExactInParams) => Promise<`0x${string}`>;
66
132
  /** See {@link swapExactIn} action */
@@ -11,6 +11,8 @@
11
11
  import { generateTransferLink } from './generateTransferLink.js';
12
12
  import { getSwapExactInQuote } from './getSwapExactInQuote.js';
13
13
  import { getTokenBalance } from './getTokenBalance.js';
14
+ import { permit } from './permit.js';
15
+ import { signEIP2612Permit } from './signEIP2612Permit.js';
14
16
  import { swapExactIn } from './swapExactIn.js';
15
17
  import { sweep } from './sweep.js';
16
18
  import { transfer } from './transfer.js';
@@ -19,6 +21,7 @@ export * from './sweep.js';
19
21
  export * from './generateTransferLink.js';
20
22
  export * from './getSwapExactInQuote.js';
21
23
  export * from './getTokenBalance.js';
24
+ export * from './permit.js';
22
25
  export * from './swapExactIn.js';
23
26
  export { FEE_LEVEL_WITH_PREPARE } from '../providers/circle-wallets/actions/index.js';
24
27
  /**
@@ -43,6 +46,10 @@ export function actions(client) {
43
46
  getSwapExactInQuote: (params) => getSwapExactInQuote(client, params),
44
47
  /** See {@link getTokenBalance} action */
45
48
  getTokenBalance: (params) => getTokenBalance(client, params),
49
+ /** See {@link signEIP2612Permit} action */
50
+ signEIP2612Permit: (params) => signEIP2612Permit(client, params),
51
+ /** See {@link permit} action */
52
+ permit: (params) => permit(client, params),
46
53
  /** See {@link swapExactIn} action */
47
54
  swap: (params) => swapExactIn(client, params),
48
55
  /** See {@link swapExactIn} action */
@@ -36,6 +36,10 @@ describe.concurrent('actions', () => {
36
36
  swapExactIn: expect.any(Function),
37
37
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
38
38
  getTokenBalance: expect.any(Function),
39
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
40
+ signEIP2612Permit: expect.any(Function),
41
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
42
+ permit: expect.any(Function),
39
43
  });
40
44
  });
41
45
  });
@@ -0,0 +1,19 @@
1
+ import type { ControlFlowOptions } from '../types.js';
2
+ import type { SignEIP2612PermitParams } from './signEIP2612Permit.js';
3
+ import type { Client, FeeValuesEIP1559, Hash } from 'viem';
4
+ /**
5
+ * Parameters for the {@link permit} function.
6
+ */
7
+ export type PermitParams = SignEIP2612PermitParams & {
8
+ gas?: bigint;
9
+ fees?: FeeValuesEIP1559;
10
+ };
11
+ export type PermitReturnType = Hash;
12
+ /**
13
+ * Signs and executes an EIP-2612 permit
14
+ *
15
+ * @param client - The client instance.
16
+ * @param params - The permit parameters.
17
+ * @returns A transaction hash (`Hash`).
18
+ */
19
+ export declare function permit(client: Client, params: PermitParams & ControlFlowOptions): Promise<`0x${string}`>;
@@ -0,0 +1,44 @@
1
+ // Copyright (c) 2025, Circle Internet Group, Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Circle Internet Group, Inc. CONFIDENTIAL
5
+ //
6
+ // This file includes unpublished proprietary source code of Circle Internet
7
+ // Group, Inc. The copyright notice above does not
8
+ // evidence any actual or intended publication of such source code. Disclosure
9
+ // of this source code or any related proprietary information is strictly
10
+ // prohibited without the express written permission of Circle Internet Group, Inc.
11
+ import { simulateContract as _simulateContract, writeContract as _writeContract } from 'viem/actions';
12
+ import { getAction } from 'viem/utils';
13
+ import EIP2612 from '../abis/EIP2612.js';
14
+ import { getClient } from '../utils/getClient.js';
15
+ import { parseAccount } from '../utils/parseAccount.js';
16
+ import { parseAddress } from '../utils/parseAddress.js';
17
+ import { signEIP2612Permit } from './signEIP2612Permit.js';
18
+ /**
19
+ * Signs and executes an EIP-2612 permit
20
+ *
21
+ * @param client - The client instance.
22
+ * @param params - The permit parameters.
23
+ * @returns A transaction hash (`Hash`).
24
+ */
25
+ export async function permit(client, params) {
26
+ const { token: _token, owner: _owner, chain = client.chain, gas, fees } = params;
27
+ const { address: verifyingContractAddress } = parseAddress(_token);
28
+ const ownerAccount = parseAccount(_owner, { chain });
29
+ const _client = getClient(client, chain);
30
+ const simulateContract = getAction(_client, _simulateContract, 'simulateContract');
31
+ const writeContract = getAction(_client, _writeContract, 'writeContract');
32
+ const result = await signEIP2612Permit(_client, params);
33
+ const { typedData: { message }, v, r, s, } = result;
34
+ const { request } = await simulateContract({
35
+ address: verifyingContractAddress,
36
+ abi: EIP2612,
37
+ functionName: 'permit',
38
+ args: [message.owner, message.spender, message.value, message.deadline, v, r, s],
39
+ account: ownerAccount,
40
+ gas,
41
+ ...fees,
42
+ });
43
+ return await writeContract({ ...request, chain });
44
+ }
@@ -0,0 +1 @@
1
+ export {};