@jpool/bond-sdk 0.3.0-next.6 → 0.3.0-next.8

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
@@ -1,5 +1,5 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
- import { PublicKey, Connection, Keypair, Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ import { PublicKey, Connection, Keypair, PublicKeyInitData, Transaction, VersionedTransaction } from '@solana/web3.js';
3
3
  import { BN, AnchorProvider, Program, Wallet as Wallet$1 } from '@coral-xyz/anchor';
4
4
 
5
5
  /**
@@ -884,31 +884,32 @@ type ValidatorBond = {
884
884
  bump: number;
885
885
  };
886
886
  type InitializeProps = {
887
- authority: PublicKey;
888
- reserveAddress: PublicKey;
887
+ authority?: PublicKey;
888
+ reserve: PublicKey;
889
889
  };
890
890
  type RegisterValidatorProps = {
891
- creator: PublicKey;
892
891
  identity: PublicKey;
893
892
  voteAccount: PublicKey;
894
893
  initialCollateral: number;
895
894
  withdrawalAuthority?: PublicKey;
895
+ creator?: PublicKey;
896
896
  };
897
897
  type TopUpCollateralProps = {
898
- user: PublicKey;
899
- voteAccount: PublicKey;
900
898
  amount: number;
899
+ voteAccount: PublicKey;
900
+ payer?: PublicKey;
901
901
  };
902
902
  type WithdrawCollateralProps = {
903
- withdrawalAuthority: PublicKey;
904
- voteAccount: PublicKey;
905
- destination: PublicKey;
906
903
  amount: number;
907
- };
908
- type WithdrawCompensationProps = {
909
- authority: PublicKey;
910
904
  voteAccount: PublicKey;
905
+ destination?: PublicKey;
906
+ withdrawalAuthority?: PublicKey;
907
+ };
908
+ type ClaimProps = {
911
909
  amount: number;
910
+ voteAccount: PublicKey;
911
+ reserve?: PublicKey;
912
+ authority?: PublicKey;
912
913
  };
913
914
  type GetHistoryProps = {
914
915
  voteAccount: PublicKey;
@@ -922,6 +923,10 @@ type GetHistoryGroupedProps = {
922
923
  voteAccount: PublicKey;
923
924
  epochsCount?: number;
924
925
  };
926
+ type SetAuthorityProps = {
927
+ newAuthority: PublicKey;
928
+ authority?: PublicKey;
929
+ };
925
930
  type GlobalState = {
926
931
  authority: PublicKey;
927
932
  totalValidators: number;
@@ -1000,94 +1005,109 @@ declare class JBondClient {
1000
1005
  */
1001
1006
  pda: {
1002
1007
  globalState: () => [PublicKey, number];
1003
- validatorBond: (voteAccount: PublicKey) => [PublicKey, number];
1008
+ validatorBond: (vote: PublicKeyInitData) => [PublicKey, number];
1004
1009
  };
1010
+ /**
1011
+ * Initialize the program
1012
+ * Default authority is the provider's wallet
1013
+ */
1014
+ initialize(props: InitializeProps): Promise<string>;
1015
+ /**
1016
+ * Register a new validator
1017
+ * Default creator is the provider's wallet
1018
+ */
1019
+ registerValidator(props: RegisterValidatorProps): Promise<string>;
1020
+ /**
1021
+ * Top up collateral
1022
+ * Default payer is the provider's wallet
1023
+ */
1024
+ topUpCollateral(props: TopUpCollateralProps): Promise<string>;
1025
+ /**
1026
+ * Withdraw collateral
1027
+ * Default withdrawal authority is the provider's wallet
1028
+ * Default destination is the provider's wallet
1029
+ * @return Transaction signature
1030
+ */
1031
+ withdrawCollateral(props: WithdrawCollateralProps): Promise<string>;
1032
+ /**
1033
+ * Claim compensation
1034
+ * Default authority is the provider's wallet
1035
+ * @return Transaction signature
1036
+ */
1037
+ claimCompensation(props: ClaimProps): Promise<string>;
1038
+ /**
1039
+ * Set a new authority for the program
1040
+ * Default authority is the provider's wallet
1041
+ * @return Transaction signature
1042
+ */
1043
+ setAuthority(props: SetAuthorityProps): Promise<string>;
1005
1044
  /**
1006
1045
  * Build initialize instruction
1007
- * @param props
1008
1046
  */
1009
1047
  buildInitializeInstruction(props: InitializeProps): Promise<_solana_web3_js.TransactionInstruction>;
1010
1048
  /**
1011
1049
  * Build register validator instruction
1012
- * @param props
1013
1050
  */
1014
1051
  buildRegisterValidatorInstruction(props: RegisterValidatorProps): Promise<_solana_web3_js.TransactionInstruction>;
1015
1052
  /**
1016
1053
  * Build top up collateral instruction
1017
- * @param props
1018
1054
  */
1019
1055
  buildTopUpCollateralInstruction(props: TopUpCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1020
- buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1021
- /**
1022
- * Build withdraw compensation instruction
1023
- * @param props
1024
- */
1025
- buildWithdrawCompensationInstruction(props: WithdrawCompensationProps): Promise<_solana_web3_js.TransactionInstruction>;
1026
1056
  /**
1027
- * Build multiple withdraw compensation instructions
1028
- * @param authority
1029
- * @param withdrawals
1057
+ * Build withdraw collateral instruction
1030
1058
  */
1031
- buildWithdrawCompensationsInstructions(authority: PublicKey, withdrawals: Array<{
1032
- voteAccount: PublicKey;
1033
- amount: number;
1034
- }>): Promise<_solana_web3_js.TransactionInstruction[]>;
1059
+ buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1035
1060
  /**
1036
- * Get validator bond account state
1037
- * @param vote
1061
+ * Build claim compensation instruction
1038
1062
  */
1039
- getValidatorBond(vote: PublicKey): Promise<{
1040
- identity: any;
1041
- voteAccount: any;
1042
- withdrawalAuthority: any;
1043
- totalCompensationAmount: number;
1044
- isActive: any;
1045
- createdAt: number;
1046
- bump: any;
1047
- } | null>;
1063
+ buildClaimInstruction(props: ClaimProps): Promise<_solana_web3_js.TransactionInstruction>;
1048
1064
  /**
1049
1065
  * Build set authority instruction
1050
1066
  */
1051
- buildSetAuthorityInstruction(props: {
1052
- authority: PublicKey;
1053
- newAuthority: PublicKey;
1054
- }): Promise<_solana_web3_js.TransactionInstruction>;
1055
- /**
1056
- * Get the collateral balance of a validator bond account
1057
- * @param vote - The vote account public key
1058
- * @returns The available collateral balance in SOL (excluding rent-exempt amount)
1059
- */
1060
- getValidatorCollateralBalance(vote: PublicKey): Promise<number>;
1067
+ buildSetAuthorityInstruction(props: SetAuthorityProps): Promise<_solana_web3_js.TransactionInstruction>;
1061
1068
  /**
1062
- * Get global state
1069
+ * Fetch global state or throw if not found
1063
1070
  */
1064
1071
  getGlobalState(): Promise<{
1065
- authority: string;
1072
+ authority: PublicKey;
1073
+ reserve: PublicKey;
1066
1074
  totalValidators: number;
1067
- totalCompensationAmount: number;
1068
- reserveAddress: string;
1075
+ totalCompensationAmount: BN;
1076
+ bump: number;
1069
1077
  }>;
1070
1078
  /**
1071
- * Get current epoch
1079
+ * Fetch validator bond data or null if not found
1080
+ * @param vote
1072
1081
  */
1073
- getCurrentEpoch(): Promise<number>;
1082
+ getValidatorBond(vote: PublicKeyInitData): Promise<{
1083
+ identity: PublicKey;
1084
+ voteAccount: PublicKey;
1085
+ creator: PublicKey;
1086
+ withdrawalAuthority: PublicKey | null;
1087
+ totalCompensationAmount: BN;
1088
+ lastCompensationAmount: BN;
1089
+ lastCompensationEpoch: BN;
1090
+ createdAt: BN;
1091
+ isActive: boolean;
1092
+ bump: number;
1093
+ } | null>;
1074
1094
  /**
1075
- * Helper methods for backward compatibility (can be removed if not needed)
1076
- * @param props
1095
+ * Get validator bond account balance (in SOL)
1096
+ * @param vote - Vote account public key
1097
+ * @return Balance in SOL
1077
1098
  */
1078
- initialize(props: WithOptionalAuthority<InitializeProps>): Promise<string>;
1079
- registerValidator(voteAccount: PublicKey, initialCollateral: number, withdrawalAuthority?: PublicKey, identity?: PublicKey): Promise<string>;
1080
- topUpCollateral(voteAccount: PublicKey, amount: number, validator?: PublicKey): Promise<string>;
1081
- withdrawCollateral(voteAccount: PublicKey, destination: PublicKey, amount: number, withdrawalAuthority?: PublicKey): Promise<string>;
1082
- claimCompensation(voteAccount: PublicKey, amount: number, authority?: PublicKey): Promise<string>;
1099
+ getValidatorBondBalance(vote: PublicKeyInitData): Promise<number>;
1083
1100
  /**
1084
1101
  * Get transaction history grouped by epochs
1085
- * @param voteAccount - The vote account to get history for
1102
+ * @param vote - The vote account to get history for
1086
1103
  * @param epochsCount - Number of recent epochs to return (default: 10)
1087
1104
  * @returns Array of epoch history items sorted by epoch (descending)
1088
1105
  */
1089
- getHistoryGroupedByEpochs(voteAccount: PublicKey, epochsCount?: number): Promise<EpochHistoryItem[]>;
1090
- getHistory(voteAccount: PublicKey, options?: {
1106
+ getHistoryGroupedByEpochs(vote: PublicKeyInitData, epochsCount?: number): Promise<EpochHistoryItem[]>;
1107
+ /**
1108
+ * Get transaction history for a specific validator bond account
1109
+ */
1110
+ getHistory(vote: PublicKey, options?: {
1091
1111
  cluster?: 'mainnet-beta' | 'testnet' | 'devnet';
1092
1112
  limit?: number;
1093
1113
  before?: string;
@@ -1106,11 +1126,6 @@ declare class JBondClient {
1106
1126
  */
1107
1127
  private getInstructionDiscriminator;
1108
1128
  }
1109
- type WithOptionalAuthority<T extends {
1110
- authority: PublicKey;
1111
- }> = Omit<T, 'authority'> & {
1112
- authority?: PublicKey;
1113
- };
1114
1129
 
1115
1130
  /**
1116
1131
  * Program IDs for different environments
@@ -1131,4 +1146,4 @@ declare class NodeWallet implements Wallet {
1131
1146
  get publicKey(): PublicKey;
1132
1147
  }
1133
1148
 
1134
- export { BondClientEnv, BondTransactionType, type ClientOptions, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps, type WithdrawCompensationProps };
1149
+ export { BondClientEnv, BondTransactionType, type ClaimProps, type ClientOptions, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, type SetAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
- import { PublicKey, Connection, Keypair, Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ import { PublicKey, Connection, Keypair, PublicKeyInitData, Transaction, VersionedTransaction } from '@solana/web3.js';
3
3
  import { BN, AnchorProvider, Program, Wallet as Wallet$1 } from '@coral-xyz/anchor';
4
4
 
5
5
  /**
@@ -884,31 +884,32 @@ type ValidatorBond = {
884
884
  bump: number;
885
885
  };
886
886
  type InitializeProps = {
887
- authority: PublicKey;
888
- reserveAddress: PublicKey;
887
+ authority?: PublicKey;
888
+ reserve: PublicKey;
889
889
  };
890
890
  type RegisterValidatorProps = {
891
- creator: PublicKey;
892
891
  identity: PublicKey;
893
892
  voteAccount: PublicKey;
894
893
  initialCollateral: number;
895
894
  withdrawalAuthority?: PublicKey;
895
+ creator?: PublicKey;
896
896
  };
897
897
  type TopUpCollateralProps = {
898
- user: PublicKey;
899
- voteAccount: PublicKey;
900
898
  amount: number;
899
+ voteAccount: PublicKey;
900
+ payer?: PublicKey;
901
901
  };
902
902
  type WithdrawCollateralProps = {
903
- withdrawalAuthority: PublicKey;
904
- voteAccount: PublicKey;
905
- destination: PublicKey;
906
903
  amount: number;
907
- };
908
- type WithdrawCompensationProps = {
909
- authority: PublicKey;
910
904
  voteAccount: PublicKey;
905
+ destination?: PublicKey;
906
+ withdrawalAuthority?: PublicKey;
907
+ };
908
+ type ClaimProps = {
911
909
  amount: number;
910
+ voteAccount: PublicKey;
911
+ reserve?: PublicKey;
912
+ authority?: PublicKey;
912
913
  };
913
914
  type GetHistoryProps = {
914
915
  voteAccount: PublicKey;
@@ -922,6 +923,10 @@ type GetHistoryGroupedProps = {
922
923
  voteAccount: PublicKey;
923
924
  epochsCount?: number;
924
925
  };
926
+ type SetAuthorityProps = {
927
+ newAuthority: PublicKey;
928
+ authority?: PublicKey;
929
+ };
925
930
  type GlobalState = {
926
931
  authority: PublicKey;
927
932
  totalValidators: number;
@@ -1000,94 +1005,109 @@ declare class JBondClient {
1000
1005
  */
1001
1006
  pda: {
1002
1007
  globalState: () => [PublicKey, number];
1003
- validatorBond: (voteAccount: PublicKey) => [PublicKey, number];
1008
+ validatorBond: (vote: PublicKeyInitData) => [PublicKey, number];
1004
1009
  };
1010
+ /**
1011
+ * Initialize the program
1012
+ * Default authority is the provider's wallet
1013
+ */
1014
+ initialize(props: InitializeProps): Promise<string>;
1015
+ /**
1016
+ * Register a new validator
1017
+ * Default creator is the provider's wallet
1018
+ */
1019
+ registerValidator(props: RegisterValidatorProps): Promise<string>;
1020
+ /**
1021
+ * Top up collateral
1022
+ * Default payer is the provider's wallet
1023
+ */
1024
+ topUpCollateral(props: TopUpCollateralProps): Promise<string>;
1025
+ /**
1026
+ * Withdraw collateral
1027
+ * Default withdrawal authority is the provider's wallet
1028
+ * Default destination is the provider's wallet
1029
+ * @return Transaction signature
1030
+ */
1031
+ withdrawCollateral(props: WithdrawCollateralProps): Promise<string>;
1032
+ /**
1033
+ * Claim compensation
1034
+ * Default authority is the provider's wallet
1035
+ * @return Transaction signature
1036
+ */
1037
+ claimCompensation(props: ClaimProps): Promise<string>;
1038
+ /**
1039
+ * Set a new authority for the program
1040
+ * Default authority is the provider's wallet
1041
+ * @return Transaction signature
1042
+ */
1043
+ setAuthority(props: SetAuthorityProps): Promise<string>;
1005
1044
  /**
1006
1045
  * Build initialize instruction
1007
- * @param props
1008
1046
  */
1009
1047
  buildInitializeInstruction(props: InitializeProps): Promise<_solana_web3_js.TransactionInstruction>;
1010
1048
  /**
1011
1049
  * Build register validator instruction
1012
- * @param props
1013
1050
  */
1014
1051
  buildRegisterValidatorInstruction(props: RegisterValidatorProps): Promise<_solana_web3_js.TransactionInstruction>;
1015
1052
  /**
1016
1053
  * Build top up collateral instruction
1017
- * @param props
1018
1054
  */
1019
1055
  buildTopUpCollateralInstruction(props: TopUpCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1020
- buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1021
- /**
1022
- * Build withdraw compensation instruction
1023
- * @param props
1024
- */
1025
- buildWithdrawCompensationInstruction(props: WithdrawCompensationProps): Promise<_solana_web3_js.TransactionInstruction>;
1026
1056
  /**
1027
- * Build multiple withdraw compensation instructions
1028
- * @param authority
1029
- * @param withdrawals
1057
+ * Build withdraw collateral instruction
1030
1058
  */
1031
- buildWithdrawCompensationsInstructions(authority: PublicKey, withdrawals: Array<{
1032
- voteAccount: PublicKey;
1033
- amount: number;
1034
- }>): Promise<_solana_web3_js.TransactionInstruction[]>;
1059
+ buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1035
1060
  /**
1036
- * Get validator bond account state
1037
- * @param vote
1061
+ * Build claim compensation instruction
1038
1062
  */
1039
- getValidatorBond(vote: PublicKey): Promise<{
1040
- identity: any;
1041
- voteAccount: any;
1042
- withdrawalAuthority: any;
1043
- totalCompensationAmount: number;
1044
- isActive: any;
1045
- createdAt: number;
1046
- bump: any;
1047
- } | null>;
1063
+ buildClaimInstruction(props: ClaimProps): Promise<_solana_web3_js.TransactionInstruction>;
1048
1064
  /**
1049
1065
  * Build set authority instruction
1050
1066
  */
1051
- buildSetAuthorityInstruction(props: {
1052
- authority: PublicKey;
1053
- newAuthority: PublicKey;
1054
- }): Promise<_solana_web3_js.TransactionInstruction>;
1055
- /**
1056
- * Get the collateral balance of a validator bond account
1057
- * @param vote - The vote account public key
1058
- * @returns The available collateral balance in SOL (excluding rent-exempt amount)
1059
- */
1060
- getValidatorCollateralBalance(vote: PublicKey): Promise<number>;
1067
+ buildSetAuthorityInstruction(props: SetAuthorityProps): Promise<_solana_web3_js.TransactionInstruction>;
1061
1068
  /**
1062
- * Get global state
1069
+ * Fetch global state or throw if not found
1063
1070
  */
1064
1071
  getGlobalState(): Promise<{
1065
- authority: string;
1072
+ authority: PublicKey;
1073
+ reserve: PublicKey;
1066
1074
  totalValidators: number;
1067
- totalCompensationAmount: number;
1068
- reserveAddress: string;
1075
+ totalCompensationAmount: BN;
1076
+ bump: number;
1069
1077
  }>;
1070
1078
  /**
1071
- * Get current epoch
1079
+ * Fetch validator bond data or null if not found
1080
+ * @param vote
1072
1081
  */
1073
- getCurrentEpoch(): Promise<number>;
1082
+ getValidatorBond(vote: PublicKeyInitData): Promise<{
1083
+ identity: PublicKey;
1084
+ voteAccount: PublicKey;
1085
+ creator: PublicKey;
1086
+ withdrawalAuthority: PublicKey | null;
1087
+ totalCompensationAmount: BN;
1088
+ lastCompensationAmount: BN;
1089
+ lastCompensationEpoch: BN;
1090
+ createdAt: BN;
1091
+ isActive: boolean;
1092
+ bump: number;
1093
+ } | null>;
1074
1094
  /**
1075
- * Helper methods for backward compatibility (can be removed if not needed)
1076
- * @param props
1095
+ * Get validator bond account balance (in SOL)
1096
+ * @param vote - Vote account public key
1097
+ * @return Balance in SOL
1077
1098
  */
1078
- initialize(props: WithOptionalAuthority<InitializeProps>): Promise<string>;
1079
- registerValidator(voteAccount: PublicKey, initialCollateral: number, withdrawalAuthority?: PublicKey, identity?: PublicKey): Promise<string>;
1080
- topUpCollateral(voteAccount: PublicKey, amount: number, validator?: PublicKey): Promise<string>;
1081
- withdrawCollateral(voteAccount: PublicKey, destination: PublicKey, amount: number, withdrawalAuthority?: PublicKey): Promise<string>;
1082
- claimCompensation(voteAccount: PublicKey, amount: number, authority?: PublicKey): Promise<string>;
1099
+ getValidatorBondBalance(vote: PublicKeyInitData): Promise<number>;
1083
1100
  /**
1084
1101
  * Get transaction history grouped by epochs
1085
- * @param voteAccount - The vote account to get history for
1102
+ * @param vote - The vote account to get history for
1086
1103
  * @param epochsCount - Number of recent epochs to return (default: 10)
1087
1104
  * @returns Array of epoch history items sorted by epoch (descending)
1088
1105
  */
1089
- getHistoryGroupedByEpochs(voteAccount: PublicKey, epochsCount?: number): Promise<EpochHistoryItem[]>;
1090
- getHistory(voteAccount: PublicKey, options?: {
1106
+ getHistoryGroupedByEpochs(vote: PublicKeyInitData, epochsCount?: number): Promise<EpochHistoryItem[]>;
1107
+ /**
1108
+ * Get transaction history for a specific validator bond account
1109
+ */
1110
+ getHistory(vote: PublicKey, options?: {
1091
1111
  cluster?: 'mainnet-beta' | 'testnet' | 'devnet';
1092
1112
  limit?: number;
1093
1113
  before?: string;
@@ -1106,11 +1126,6 @@ declare class JBondClient {
1106
1126
  */
1107
1127
  private getInstructionDiscriminator;
1108
1128
  }
1109
- type WithOptionalAuthority<T extends {
1110
- authority: PublicKey;
1111
- }> = Omit<T, 'authority'> & {
1112
- authority?: PublicKey;
1113
- };
1114
1129
 
1115
1130
  /**
1116
1131
  * Program IDs for different environments
@@ -1131,4 +1146,4 @@ declare class NodeWallet implements Wallet {
1131
1146
  get publicKey(): PublicKey;
1132
1147
  }
1133
1148
 
1134
- export { BondClientEnv, BondTransactionType, type ClientOptions, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps, type WithdrawCompensationProps };
1149
+ export { BondClientEnv, BondTransactionType, type ClaimProps, type ClientOptions, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, type SetAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };