@1stdex/first-sdk 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/calls/approval/order.js +17 -26
- package/dist/cjs/calls/approval/order.js.map +1 -1
- package/dist/cjs/calls/approval/token.js +34 -121
- package/dist/cjs/calls/approval/token.js.map +1 -1
- package/dist/esm/calls/approval/order.js +33 -55
- package/dist/esm/calls/approval/order.js.map +1 -1
- package/dist/esm/calls/approval/token.js +47 -146
- package/dist/esm/calls/approval/token.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/calls/approval/order.d.ts +23 -36
- package/dist/types/calls/approval/order.d.ts.map +1 -1
- package/dist/types/calls/approval/token.d.ts +16 -18
- package/dist/types/calls/approval/token.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,69 +1,56 @@
|
|
|
1
|
-
import { WalletClient } from 'viem';
|
|
2
1
|
import { CHAIN_IDS } from '../../constants/chain-configs/chain';
|
|
3
|
-
import { DefaultWriteContractOptions } from '../../types';
|
|
2
|
+
import { DefaultWriteContractOptions, Transaction } from '../../types';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Sets the order operator approval for the specified operator address on the given chain.
|
|
4
|
+
* Prepares a transaction to set the order operator approval for the specified operator address on the given chain.
|
|
7
5
|
*
|
|
8
6
|
* @param {CHAIN_IDS} chainId The chain ID.
|
|
9
|
-
* @param {
|
|
7
|
+
* @param {`0x${string}`} userAddress The user address.
|
|
10
8
|
* @param {`0x${string}`} operator The operator address to approve or revoke.
|
|
11
9
|
* @param {boolean} approved Whether to approve or revoke the operator.
|
|
12
10
|
* @param {Object} [options] Optional parameters for setting approval.
|
|
13
|
-
* @param {string} options.rpcUrl The RPC URL to use for
|
|
14
|
-
* @returns {Promise
|
|
11
|
+
* @param {string} options.rpcUrl The RPC URL to use for building the transaction.
|
|
12
|
+
* @returns {Promise<Transaction>} Promise resolving to the transaction object.
|
|
15
13
|
* @example
|
|
16
14
|
* import { setOrderOperatorApproval } from '@clober/v2-sdk'
|
|
17
|
-
* import { mnemonicToAccount } from 'viem/accounts'
|
|
18
15
|
*
|
|
19
|
-
* const
|
|
20
|
-
* chain: arbitrumSepolia,
|
|
21
|
-
* account: mnemonicToAccount('legal ...'),
|
|
22
|
-
* transport: http(),
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* const hash = await setOrderOperatorApproval({
|
|
16
|
+
* const transaction = await setOrderOperatorApproval({
|
|
26
17
|
* chainId: 421614,
|
|
27
|
-
*
|
|
18
|
+
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69',
|
|
28
19
|
* operator: '0x1234567890123456789012345678901234567890',
|
|
29
20
|
* approved: true
|
|
30
21
|
* })
|
|
22
|
+
*
|
|
23
|
+
* const hash = await walletClient.sendTransaction(transaction)
|
|
31
24
|
*/
|
|
32
|
-
export declare const setOrderOperatorApproval: ({ chainId,
|
|
25
|
+
export declare const setOrderOperatorApproval: ({ chainId, userAddress, operator, approved, options, }: {
|
|
33
26
|
chainId: CHAIN_IDS;
|
|
34
|
-
|
|
27
|
+
userAddress: `0x${string}`;
|
|
35
28
|
operator: `0x${string}`;
|
|
36
29
|
approved: boolean;
|
|
37
30
|
options?: DefaultWriteContractOptions;
|
|
38
|
-
}) => Promise
|
|
31
|
+
}) => Promise<Transaction | undefined>;
|
|
39
32
|
/**
|
|
40
|
-
*
|
|
41
|
-
* Approves the controller as an order operator for the specified chain.
|
|
33
|
+
* Prepares a transaction to approve the controller as an order operator for the specified chain.
|
|
42
34
|
* This is a convenience function that delegates to `setOrderOperatorApproval`.
|
|
43
35
|
*
|
|
44
36
|
* @param {CHAIN_IDS} chainId The chain ID.
|
|
45
|
-
* @param {
|
|
37
|
+
* @param {`0x${string}`} userAddress The user address.
|
|
46
38
|
* @param {Object} [options] Optional parameters for setting approval.
|
|
47
|
-
* @param {string} options.rpcUrl The RPC URL to use for
|
|
48
|
-
* @returns {Promise
|
|
39
|
+
* @param {string} options.rpcUrl The RPC URL to use for building the transaction.
|
|
40
|
+
* @returns {Promise<Transaction>} Promise resolving to the transaction object.
|
|
49
41
|
* @example
|
|
50
42
|
* import { approveControllerAsOrderOperator } from '@clober/v2-sdk'
|
|
51
|
-
* import { mnemonicToAccount } from 'viem/accounts'
|
|
52
43
|
*
|
|
53
|
-
* const
|
|
54
|
-
* chain: arbitrumSepolia,
|
|
55
|
-
* account: mnemonicToAccount('legal ...'),
|
|
56
|
-
* transport: http(),
|
|
57
|
-
* })
|
|
58
|
-
*
|
|
59
|
-
* const hash = await approveControllerAsOrderOperator({
|
|
44
|
+
* const transaction = await approveControllerAsOrderOperator({
|
|
60
45
|
* chainId: 421614,
|
|
61
|
-
*
|
|
46
|
+
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69'
|
|
62
47
|
* })
|
|
48
|
+
*
|
|
49
|
+
* const hash = await walletClient.sendTransaction(transaction)
|
|
63
50
|
*/
|
|
64
|
-
export declare const approveControllerAsOrderOperator: ({ chainId,
|
|
51
|
+
export declare const approveControllerAsOrderOperator: ({ chainId, userAddress, options, }: {
|
|
65
52
|
chainId: CHAIN_IDS;
|
|
66
|
-
|
|
53
|
+
userAddress: `0x${string}`;
|
|
67
54
|
options?: DefaultWriteContractOptions;
|
|
68
|
-
}) => Promise
|
|
55
|
+
}) => Promise<Transaction | undefined>;
|
|
69
56
|
//# sourceMappingURL=order.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../../src/calls/approval/order.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../../src/calls/approval/order.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAa,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAKvE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,wBAAwB,2DAMlC;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,KAAG,QAAQ,WAAW,GAAG,SAAS,CAsClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gCAAgC,uCAI1C;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,KAAG,QAAQ,WAAW,GAAG,SAAS,CAQlC,CAAC"}
|
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
import { WalletClient } from 'viem';
|
|
2
1
|
import { CHAIN_IDS } from '../../constants/chain-configs/chain';
|
|
3
|
-
import { DefaultWriteContractOptions } from '../../types';
|
|
2
|
+
import { DefaultWriteContractOptions, Transaction } from '../../types';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Sets maximum allowance for a token and its vault to the respective contracts.
|
|
4
|
+
* Prepares approval transactions for a token and its vault.
|
|
7
5
|
* This includes:
|
|
8
6
|
* - Max allowance for the token to controller
|
|
9
7
|
* - Max allowance for the token's vault to controller
|
|
10
8
|
* - Max allowance for the token's vault to book manager
|
|
11
9
|
*
|
|
12
|
-
* Only
|
|
10
|
+
* Only includes approvals where current allowance is below threshold (max - 1 million tokens).
|
|
13
11
|
*
|
|
14
12
|
* @param {CHAIN_IDS} chainId The chain ID.
|
|
15
|
-
* @param {
|
|
13
|
+
* @param {`0x${string}`} userAddress The user address.
|
|
16
14
|
* @param {`0x${string}`} tokenAddress The token address.
|
|
17
15
|
* @param options
|
|
18
16
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
19
|
-
* @returns {Promise
|
|
17
|
+
* @returns {Promise<Transaction[]>} Promise resolving to array of approval transactions. Empty array if no approvals needed.
|
|
20
18
|
* @example
|
|
21
19
|
* import { setTokenAllowances } from '@clober/v2-sdk'
|
|
22
20
|
*
|
|
23
|
-
* const
|
|
24
|
-
* chain: arbitrumSepolia,
|
|
25
|
-
* account: mnemonicToAccount('legal ...'),
|
|
26
|
-
* transport: http(),
|
|
27
|
-
* })
|
|
28
|
-
*
|
|
29
|
-
* const hashes = await setTokenAllowances({
|
|
21
|
+
* const transactions = await setTokenAllowances({
|
|
30
22
|
* chainId: 421614,
|
|
31
|
-
*
|
|
23
|
+
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69',
|
|
32
24
|
* tokenAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
33
25
|
* })
|
|
26
|
+
*
|
|
27
|
+
* // Send transactions sequentially
|
|
28
|
+
* for (const tx of transactions) {
|
|
29
|
+
* const hash = await walletClient.sendTransaction(tx)
|
|
30
|
+
* await publicClient.waitForTransactionReceipt({ hash })
|
|
31
|
+
* }
|
|
34
32
|
*/
|
|
35
|
-
export declare const setTokenAllowances: ({ chainId,
|
|
33
|
+
export declare const setTokenAllowances: ({ chainId, userAddress, tokenAddress, options, }: {
|
|
36
34
|
chainId: CHAIN_IDS;
|
|
37
|
-
|
|
35
|
+
userAddress: `0x${string}`;
|
|
38
36
|
tokenAddress: `0x${string}`;
|
|
39
37
|
options?: DefaultWriteContractOptions;
|
|
40
|
-
}) => Promise
|
|
38
|
+
}) => Promise<Transaction[]>;
|
|
41
39
|
//# sourceMappingURL=token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/calls/approval/token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/calls/approval/token.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAa,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAOvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,kBAAkB,qDAK5B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,KAAG,QAAQ,WAAW,EAAE,CA+GxB,CAAC"}
|