@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.
@@ -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
- * @dev This function relates with `viem` dependency
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 {WalletClient} walletClient The wallet client.
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 executing the transaction.
14
- * @returns {Promise<`0x${string}`>} Promise resolving to the transaction hash.
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 walletClient = createWalletClient({
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
- * walletClient,
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, walletClient, operator, approved, options, }: {
25
+ export declare const setOrderOperatorApproval: ({ chainId, userAddress, operator, approved, options, }: {
33
26
  chainId: CHAIN_IDS;
34
- walletClient: WalletClient;
27
+ userAddress: `0x${string}`;
35
28
  operator: `0x${string}`;
36
29
  approved: boolean;
37
30
  options?: DefaultWriteContractOptions;
38
- }) => Promise<`0x${string}`>;
31
+ }) => Promise<Transaction | undefined>;
39
32
  /**
40
- * @dev This function relates with `viem` dependency
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 {WalletClient} walletClient The wallet client.
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 executing the transaction.
48
- * @returns {Promise<`0x${string}`>} Promise resolving to the transaction hash.
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 walletClient = createWalletClient({
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
- * walletClient
46
+ * userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69'
62
47
  * })
48
+ *
49
+ * const hash = await walletClient.sendTransaction(transaction)
63
50
  */
64
- export declare const approveControllerAsOrderOperator: ({ chainId, walletClient, options, }: {
51
+ export declare const approveControllerAsOrderOperator: ({ chainId, userAddress, options, }: {
65
52
  chainId: CHAIN_IDS;
66
- walletClient: WalletClient;
53
+ userAddress: `0x${string}`;
67
54
  options?: DefaultWriteContractOptions;
68
- }) => Promise<`0x${string}`>;
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":"AAAA,OAAO,EAA4B,YAAY,EAAE,MAAM,MAAM,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAa,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,wBAAwB,4DAMlC;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,KAAG,QAAQ,KAAK,MAAM,EAAE,CAsCxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gCAAgC,wCAI1C;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,KAAG,QAAQ,KAAK,MAAM,EAAE,CAaxB,CAAC"}
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
- * @dev This function relates with `viem` dependency
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 adds allowance if current allowance is below threshold (max - 1 million tokens).
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 {WalletClient} walletClient The wallet client.
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<`0x${string}`[]>} Promise resolving to array of transaction hashes. Empty array if no approvals needed.
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 walletClient = createWalletClient({
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
- * walletClient,
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, walletClient, tokenAddress, options, }: {
33
+ export declare const setTokenAllowances: ({ chainId, userAddress, tokenAddress, options, }: {
36
34
  chainId: CHAIN_IDS;
37
- walletClient: WalletClient;
35
+ userAddress: `0x${string}`;
38
36
  tokenAddress: `0x${string}`;
39
37
  options?: DefaultWriteContractOptions;
40
- }) => Promise<`0x${string}`[]>;
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":"AAAA,OAAO,EAA4B,YAAY,EAAE,MAAM,MAAM,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAa,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAM1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,kBAAkB,sDAK5B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,KAAG,QAAQ,KAAK,MAAM,EAAE,EAAE,CAuN1B,CAAC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1stdex/first-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "🛠 An SDK for building applications on top of 1st V2",
5
5
  "files": [
6
6
  "dist"