atfi 1.1.2 → 1.1.3

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/index.d.mts CHANGED
@@ -541,6 +541,10 @@ declare class ATFiSDK {
541
541
  * Claim rewards after event settlement
542
542
  */
543
543
  claim(params: ClaimParams): Promise<ClaimAction>;
544
+ /**
545
+ * Approve token spending
546
+ */
547
+ approve(token: Address, spender: Address, amount: bigint): Promise<Hash>;
544
548
  /**
545
549
  * Get detailed event information
546
550
  */
package/dist/index.d.ts CHANGED
@@ -541,6 +541,10 @@ declare class ATFiSDK {
541
541
  * Claim rewards after event settlement
542
542
  */
543
543
  claim(params: ClaimParams): Promise<ClaimAction>;
544
+ /**
545
+ * Approve token spending
546
+ */
547
+ approve(token: Address, spender: Address, amount: bigint): Promise<Hash>;
544
548
  /**
545
549
  * Get detailed event information
546
550
  */
package/dist/index.js CHANGED
@@ -735,6 +735,20 @@ var ATFiSDK = class _ATFiSDK {
735
735
  }
736
736
  };
737
737
  }
738
+ /**
739
+ * Approve token spending
740
+ */
741
+ async approve(token, spender, amount) {
742
+ const wallet = this.ensureWallet();
743
+ return wallet.writeContract({
744
+ address: token,
745
+ abi: ERC20ABI,
746
+ functionName: "approve",
747
+ account: wallet.account,
748
+ args: [spender, amount],
749
+ chain: null
750
+ });
751
+ }
738
752
  // ============ Read Functions ============
739
753
  /**
740
754
  * Get detailed event information
@@ -1058,6 +1072,17 @@ var ATFiSDK = class _ATFiSDK {
1058
1072
  needsApproval
1059
1073
  };
1060
1074
  }
1075
+ if (needsApproval) {
1076
+ return {
1077
+ success: true,
1078
+ needsApproval: true,
1079
+ gasEstimate: 0n,
1080
+ // Cannot estimate register gas yet
1081
+ ...baseResult,
1082
+ userBalance: fromTokenUnits(balance, decimals),
1083
+ currentAllowance: fromTokenUnits(allowance, decimals)
1084
+ };
1085
+ }
1061
1086
  await this.publicClient.simulateContract({ address: vaultAddress, abi: VaultATFiABI, functionName: "stake", account });
1062
1087
  const gasEstimate = await this.publicClient.estimateContractGas({ address: vaultAddress, abi: VaultATFiABI, functionName: "stake", account });
1063
1088
  return {
@@ -1065,7 +1090,7 @@ var ATFiSDK = class _ATFiSDK {
1065
1090
  ...baseResult,
1066
1091
  userBalance: fromTokenUnits(balance, decimals),
1067
1092
  currentAllowance: fromTokenUnits(allowance, decimals),
1068
- needsApproval,
1093
+ needsApproval: false,
1069
1094
  gasEstimate
1070
1095
  };
1071
1096
  } catch (error) {
package/dist/index.mjs CHANGED
@@ -684,6 +684,20 @@ var ATFiSDK = class _ATFiSDK {
684
684
  }
685
685
  };
686
686
  }
687
+ /**
688
+ * Approve token spending
689
+ */
690
+ async approve(token, spender, amount) {
691
+ const wallet = this.ensureWallet();
692
+ return wallet.writeContract({
693
+ address: token,
694
+ abi: ERC20ABI,
695
+ functionName: "approve",
696
+ account: wallet.account,
697
+ args: [spender, amount],
698
+ chain: null
699
+ });
700
+ }
687
701
  // ============ Read Functions ============
688
702
  /**
689
703
  * Get detailed event information
@@ -1007,6 +1021,17 @@ var ATFiSDK = class _ATFiSDK {
1007
1021
  needsApproval
1008
1022
  };
1009
1023
  }
1024
+ if (needsApproval) {
1025
+ return {
1026
+ success: true,
1027
+ needsApproval: true,
1028
+ gasEstimate: 0n,
1029
+ // Cannot estimate register gas yet
1030
+ ...baseResult,
1031
+ userBalance: fromTokenUnits(balance, decimals),
1032
+ currentAllowance: fromTokenUnits(allowance, decimals)
1033
+ };
1034
+ }
1010
1035
  await this.publicClient.simulateContract({ address: vaultAddress, abi: VaultATFiABI, functionName: "stake", account });
1011
1036
  const gasEstimate = await this.publicClient.estimateContractGas({ address: vaultAddress, abi: VaultATFiABI, functionName: "stake", account });
1012
1037
  return {
@@ -1014,7 +1039,7 @@ var ATFiSDK = class _ATFiSDK {
1014
1039
  ...baseResult,
1015
1040
  userBalance: fromTokenUnits(balance, decimals),
1016
1041
  currentAllowance: fromTokenUnits(allowance, decimals),
1017
- needsApproval,
1042
+ needsApproval: false,
1018
1043
  gasEstimate
1019
1044
  };
1020
1045
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atfi",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "TypeScript SDK for ATFi commitment vaults on Base",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",