atfi 1.1.2 → 1.1.4

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,14 @@ 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>;
548
+ /**
549
+ * Get all participants for a vault
550
+ */
551
+ getParticipants(vaultAddress: Address): Promise<ParticipantInfo[]>;
544
552
  /**
545
553
  * Get detailed event information
546
554
  */
package/dist/index.d.ts CHANGED
@@ -541,6 +541,14 @@ 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>;
548
+ /**
549
+ * Get all participants for a vault
550
+ */
551
+ getParticipants(vaultAddress: Address): Promise<ParticipantInfo[]>;
544
552
  /**
545
553
  * Get detailed event information
546
554
  */
package/dist/index.js CHANGED
@@ -735,7 +735,55 @@ 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 ============
753
+ /**
754
+ * Get all participants for a vault
755
+ */
756
+ async getParticipants(vaultAddress) {
757
+ const count = await this.publicClient.readContract({
758
+ address: vaultAddress,
759
+ abi: VaultATFiABI,
760
+ functionName: "getParticipantCount"
761
+ });
762
+ const participantCount = Number(count);
763
+ if (participantCount === 0) return [];
764
+ const addressCalls = [];
765
+ for (let i = 0; i < participantCount; i++) {
766
+ addressCalls.push({
767
+ address: vaultAddress,
768
+ abi: VaultATFiABI,
769
+ functionName: "participantList",
770
+ args: [BigInt(i)]
771
+ });
772
+ }
773
+ const addresses = await Promise.all(
774
+ Array.from(
775
+ { length: participantCount },
776
+ (_, i) => this.publicClient.readContract({
777
+ address: vaultAddress,
778
+ abi: VaultATFiABI,
779
+ functionName: "participantList",
780
+ args: [BigInt(i)]
781
+ })
782
+ )
783
+ );
784
+ const statusPromises = addresses.map((addr) => this.getParticipantStatus(vaultAddress, addr));
785
+ return Promise.all(statusPromises);
786
+ }
739
787
  /**
740
788
  * Get detailed event information
741
789
  */
@@ -1058,6 +1106,17 @@ var ATFiSDK = class _ATFiSDK {
1058
1106
  needsApproval
1059
1107
  };
1060
1108
  }
1109
+ if (needsApproval) {
1110
+ return {
1111
+ success: true,
1112
+ needsApproval: true,
1113
+ gasEstimate: 0n,
1114
+ // Cannot estimate register gas yet
1115
+ ...baseResult,
1116
+ userBalance: fromTokenUnits(balance, decimals),
1117
+ currentAllowance: fromTokenUnits(allowance, decimals)
1118
+ };
1119
+ }
1061
1120
  await this.publicClient.simulateContract({ address: vaultAddress, abi: VaultATFiABI, functionName: "stake", account });
1062
1121
  const gasEstimate = await this.publicClient.estimateContractGas({ address: vaultAddress, abi: VaultATFiABI, functionName: "stake", account });
1063
1122
  return {
@@ -1065,7 +1124,7 @@ var ATFiSDK = class _ATFiSDK {
1065
1124
  ...baseResult,
1066
1125
  userBalance: fromTokenUnits(balance, decimals),
1067
1126
  currentAllowance: fromTokenUnits(allowance, decimals),
1068
- needsApproval,
1127
+ needsApproval: false,
1069
1128
  gasEstimate
1070
1129
  };
1071
1130
  } catch (error) {
package/dist/index.mjs CHANGED
@@ -684,7 +684,55 @@ 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 ============
702
+ /**
703
+ * Get all participants for a vault
704
+ */
705
+ async getParticipants(vaultAddress) {
706
+ const count = await this.publicClient.readContract({
707
+ address: vaultAddress,
708
+ abi: VaultATFiABI,
709
+ functionName: "getParticipantCount"
710
+ });
711
+ const participantCount = Number(count);
712
+ if (participantCount === 0) return [];
713
+ const addressCalls = [];
714
+ for (let i = 0; i < participantCount; i++) {
715
+ addressCalls.push({
716
+ address: vaultAddress,
717
+ abi: VaultATFiABI,
718
+ functionName: "participantList",
719
+ args: [BigInt(i)]
720
+ });
721
+ }
722
+ const addresses = await Promise.all(
723
+ Array.from(
724
+ { length: participantCount },
725
+ (_, i) => this.publicClient.readContract({
726
+ address: vaultAddress,
727
+ abi: VaultATFiABI,
728
+ functionName: "participantList",
729
+ args: [BigInt(i)]
730
+ })
731
+ )
732
+ );
733
+ const statusPromises = addresses.map((addr) => this.getParticipantStatus(vaultAddress, addr));
734
+ return Promise.all(statusPromises);
735
+ }
688
736
  /**
689
737
  * Get detailed event information
690
738
  */
@@ -1007,6 +1055,17 @@ var ATFiSDK = class _ATFiSDK {
1007
1055
  needsApproval
1008
1056
  };
1009
1057
  }
1058
+ if (needsApproval) {
1059
+ return {
1060
+ success: true,
1061
+ needsApproval: true,
1062
+ gasEstimate: 0n,
1063
+ // Cannot estimate register gas yet
1064
+ ...baseResult,
1065
+ userBalance: fromTokenUnits(balance, decimals),
1066
+ currentAllowance: fromTokenUnits(allowance, decimals)
1067
+ };
1068
+ }
1010
1069
  await this.publicClient.simulateContract({ address: vaultAddress, abi: VaultATFiABI, functionName: "stake", account });
1011
1070
  const gasEstimate = await this.publicClient.estimateContractGas({ address: vaultAddress, abi: VaultATFiABI, functionName: "stake", account });
1012
1071
  return {
@@ -1014,7 +1073,7 @@ var ATFiSDK = class _ATFiSDK {
1014
1073
  ...baseResult,
1015
1074
  userBalance: fromTokenUnits(balance, decimals),
1016
1075
  currentAllowance: fromTokenUnits(allowance, decimals),
1017
- needsApproval,
1076
+ needsApproval: false,
1018
1077
  gasEstimate
1019
1078
  };
1020
1079
  } 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.4",
4
4
  "description": "TypeScript SDK for ATFi commitment vaults on Base",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",