@jpool/bond-sdk 0.9.0-next.1 → 0.9.0-next.2

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,6 +1,6 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
2
  import { PublicKey, Transaction, VersionedTransaction, Keypair, Connection, PublicKeyInitData } from '@solana/web3.js';
3
- import { BN, AnchorProvider, Program } from '@coral-xyz/anchor';
3
+ import { BN, Provider, Program } from '@coral-xyz/anchor';
4
4
 
5
5
  /**
6
6
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -1076,14 +1076,13 @@ declare enum BondClientEnv {
1076
1076
  * Options for configuring the JBondClient.
1077
1077
  */
1078
1078
  type ClientOptions = {
1079
- programId?: PublicKey;
1080
1079
  debug?: boolean;
1081
1080
  } & Record<string, any>;
1082
1081
  declare class JBondClient {
1083
- readonly provider: AnchorProvider;
1082
+ readonly provider: Provider;
1084
1083
  readonly options: ClientOptions;
1085
1084
  readonly program: Program<Jbond>;
1086
- constructor(provider: AnchorProvider, options?: ClientOptions);
1085
+ constructor(provider: Provider, options?: ClientOptions);
1087
1086
  /**
1088
1087
  * Creates an instance of `JBondClient` using a provided connection and wallet.
1089
1088
  */
@@ -1095,7 +1094,7 @@ declare class JBondClient {
1095
1094
  /**
1096
1095
  * Get the current program ID.
1097
1096
  */
1098
- get programId(): PublicKey;
1097
+ get programId(): any;
1099
1098
  /**
1100
1099
  * Get the current connection.
1101
1100
  */
@@ -1119,44 +1118,44 @@ declare class JBondClient {
1119
1118
  * Initialize the program
1120
1119
  * Default authority is the provider's wallet
1121
1120
  */
1122
- initialize(props: InitializeProps): Promise<string>;
1121
+ initialize(props: InitializeProps): Promise<string | undefined>;
1123
1122
  /**
1124
1123
  * Register a new validator
1125
1124
  * Default creator is the provider's wallet
1126
1125
  */
1127
- registerValidator(props: RegisterValidatorProps): Promise<string>;
1126
+ registerValidator(props: RegisterValidatorProps): Promise<string | undefined>;
1128
1127
  /**
1129
1128
  * Top up collateral
1130
1129
  * Default payer is the provider's wallet
1131
1130
  */
1132
- topUpCollateral(props: TopUpCollateralProps): Promise<string>;
1131
+ topUpCollateral(props: TopUpCollateralProps): Promise<string | undefined>;
1133
1132
  /**
1134
1133
  * Withdraw collateral
1135
1134
  * Default withdrawal authority is the provider's wallet
1136
1135
  * Default destination is the provider's wallet
1137
1136
  * @return Transaction signature
1138
1137
  */
1139
- withdrawCollateral(props: WithdrawCollateralProps): Promise<string>;
1138
+ withdrawCollateral(props: WithdrawCollateralProps): Promise<string | undefined>;
1140
1139
  /**
1141
1140
  * Claim compensation
1142
1141
  * Default authority is the provider's wallet
1143
1142
  * @return Transaction signature
1144
1143
  */
1145
- claimCompensation(props: ClaimProps): Promise<string>;
1144
+ claimCompensation(props: ClaimProps): Promise<string | undefined>;
1146
1145
  /**
1147
1146
  * Update global configuration for the program
1148
1147
  * Default authority is the provider's wallet
1149
1148
  * Only the current authority can call this
1150
1149
  * @return Transaction signature
1151
1150
  */
1152
- configure(props: ConfigureProps): Promise<string>;
1151
+ configure(props: ConfigureProps): Promise<string | undefined>;
1153
1152
  /**
1154
1153
  * Set withdrawal authority for validator bond
1155
1154
  * Only the validator identity can call this
1156
1155
  * Default identity is the provider's wallet
1157
1156
  * @return Transaction signature
1158
1157
  */
1159
- setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string>;
1158
+ setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string | undefined>;
1160
1159
  /**
1161
1160
  * Build initialize instruction
1162
1161
  */
@@ -1217,12 +1216,21 @@ declare class JBondClient {
1217
1216
  private getInstructionDiscriminator;
1218
1217
  private fetchSignaturesForValidator;
1219
1218
  private fetchParsedTransactions;
1219
+ /**
1220
+ * Decode instruction data to determine transaction type and amount
1221
+ * @param data
1222
+ * @private
1223
+ */
1220
1224
  private decodeInstructionData;
1221
1225
  }
1222
1226
 
1227
+ declare enum Seeds {
1228
+ GlobalState = "global_state",
1229
+ ValidatorBond = "validator_bond"
1230
+ }
1223
1231
  /**
1224
1232
  * Program IDs for different environments
1225
1233
  */
1226
1234
  declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
1227
1235
 
1228
- export { BondClientEnv, BondTransactionType, type ClaimProps, type ClientOptions, type ConfigureProps, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };
1236
+ export { BondClientEnv, BondTransactionType, type ClaimProps, type ClientOptions, type ConfigureProps, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, Seeds, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
2
  import { PublicKey, Transaction, VersionedTransaction, Keypair, Connection, PublicKeyInitData } from '@solana/web3.js';
3
- import { BN, AnchorProvider, Program } from '@coral-xyz/anchor';
3
+ import { BN, Provider, Program } from '@coral-xyz/anchor';
4
4
 
5
5
  /**
6
6
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -1076,14 +1076,13 @@ declare enum BondClientEnv {
1076
1076
  * Options for configuring the JBondClient.
1077
1077
  */
1078
1078
  type ClientOptions = {
1079
- programId?: PublicKey;
1080
1079
  debug?: boolean;
1081
1080
  } & Record<string, any>;
1082
1081
  declare class JBondClient {
1083
- readonly provider: AnchorProvider;
1082
+ readonly provider: Provider;
1084
1083
  readonly options: ClientOptions;
1085
1084
  readonly program: Program<Jbond>;
1086
- constructor(provider: AnchorProvider, options?: ClientOptions);
1085
+ constructor(provider: Provider, options?: ClientOptions);
1087
1086
  /**
1088
1087
  * Creates an instance of `JBondClient` using a provided connection and wallet.
1089
1088
  */
@@ -1095,7 +1094,7 @@ declare class JBondClient {
1095
1094
  /**
1096
1095
  * Get the current program ID.
1097
1096
  */
1098
- get programId(): PublicKey;
1097
+ get programId(): any;
1099
1098
  /**
1100
1099
  * Get the current connection.
1101
1100
  */
@@ -1119,44 +1118,44 @@ declare class JBondClient {
1119
1118
  * Initialize the program
1120
1119
  * Default authority is the provider's wallet
1121
1120
  */
1122
- initialize(props: InitializeProps): Promise<string>;
1121
+ initialize(props: InitializeProps): Promise<string | undefined>;
1123
1122
  /**
1124
1123
  * Register a new validator
1125
1124
  * Default creator is the provider's wallet
1126
1125
  */
1127
- registerValidator(props: RegisterValidatorProps): Promise<string>;
1126
+ registerValidator(props: RegisterValidatorProps): Promise<string | undefined>;
1128
1127
  /**
1129
1128
  * Top up collateral
1130
1129
  * Default payer is the provider's wallet
1131
1130
  */
1132
- topUpCollateral(props: TopUpCollateralProps): Promise<string>;
1131
+ topUpCollateral(props: TopUpCollateralProps): Promise<string | undefined>;
1133
1132
  /**
1134
1133
  * Withdraw collateral
1135
1134
  * Default withdrawal authority is the provider's wallet
1136
1135
  * Default destination is the provider's wallet
1137
1136
  * @return Transaction signature
1138
1137
  */
1139
- withdrawCollateral(props: WithdrawCollateralProps): Promise<string>;
1138
+ withdrawCollateral(props: WithdrawCollateralProps): Promise<string | undefined>;
1140
1139
  /**
1141
1140
  * Claim compensation
1142
1141
  * Default authority is the provider's wallet
1143
1142
  * @return Transaction signature
1144
1143
  */
1145
- claimCompensation(props: ClaimProps): Promise<string>;
1144
+ claimCompensation(props: ClaimProps): Promise<string | undefined>;
1146
1145
  /**
1147
1146
  * Update global configuration for the program
1148
1147
  * Default authority is the provider's wallet
1149
1148
  * Only the current authority can call this
1150
1149
  * @return Transaction signature
1151
1150
  */
1152
- configure(props: ConfigureProps): Promise<string>;
1151
+ configure(props: ConfigureProps): Promise<string | undefined>;
1153
1152
  /**
1154
1153
  * Set withdrawal authority for validator bond
1155
1154
  * Only the validator identity can call this
1156
1155
  * Default identity is the provider's wallet
1157
1156
  * @return Transaction signature
1158
1157
  */
1159
- setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string>;
1158
+ setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string | undefined>;
1160
1159
  /**
1161
1160
  * Build initialize instruction
1162
1161
  */
@@ -1217,12 +1216,21 @@ declare class JBondClient {
1217
1216
  private getInstructionDiscriminator;
1218
1217
  private fetchSignaturesForValidator;
1219
1218
  private fetchParsedTransactions;
1219
+ /**
1220
+ * Decode instruction data to determine transaction type and amount
1221
+ * @param data
1222
+ * @private
1223
+ */
1220
1224
  private decodeInstructionData;
1221
1225
  }
1222
1226
 
1227
+ declare enum Seeds {
1228
+ GlobalState = "global_state",
1229
+ ValidatorBond = "validator_bond"
1230
+ }
1223
1231
  /**
1224
1232
  * Program IDs for different environments
1225
1233
  */
1226
1234
  declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
1227
1235
 
1228
- export { BondClientEnv, BondTransactionType, type ClaimProps, type ClientOptions, type ConfigureProps, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };
1236
+ export { BondClientEnv, BondTransactionType, type ClaimProps, type ClientOptions, type ConfigureProps, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, Seeds, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };
package/dist/index.js CHANGED
@@ -11,6 +11,11 @@ var bs58__default = /*#__PURE__*/_interopDefault(bs58);
11
11
  // src/client.ts
12
12
 
13
13
  // src/constants.ts
14
+ var Seeds = /* @__PURE__ */ ((Seeds2) => {
15
+ Seeds2["GlobalState"] = "global_state";
16
+ Seeds2["ValidatorBond"] = "validator_bond";
17
+ return Seeds2;
18
+ })(Seeds || {});
14
19
  var ENV_PROGRAM_ID = {
15
20
  // [BondClientEnv.DEV]: new PublicKey('...'),
16
21
  };
@@ -1080,14 +1085,14 @@ var JBondClient = class _JBondClient {
1080
1085
  pda = {
1081
1086
  globalState: () => {
1082
1087
  return web3_js.PublicKey.findProgramAddressSync(
1083
- [Buffer.from("global_state")],
1088
+ [Buffer.from("global_state" /* GlobalState */)],
1084
1089
  this.programId
1085
1090
  );
1086
1091
  },
1087
1092
  validatorBond: (vote) => {
1088
1093
  return web3_js.PublicKey.findProgramAddressSync(
1089
1094
  [
1090
- Buffer.from("validator_bond"),
1095
+ Buffer.from("validator_bond" /* ValidatorBond */),
1091
1096
  new web3_js.PublicKey(vote).toBuffer()
1092
1097
  ],
1093
1098
  this.programId
@@ -1100,7 +1105,7 @@ var JBondClient = class _JBondClient {
1100
1105
  */
1101
1106
  async initialize(props) {
1102
1107
  const ix = await this.buildInitializeInstruction(props);
1103
- return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
1108
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
1104
1109
  }
1105
1110
  /**
1106
1111
  * Register a new validator
@@ -1108,7 +1113,7 @@ var JBondClient = class _JBondClient {
1108
1113
  */
1109
1114
  async registerValidator(props) {
1110
1115
  const ix = await this.buildRegisterValidatorInstruction(props);
1111
- return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
1116
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
1112
1117
  }
1113
1118
  /**
1114
1119
  * Top up collateral
@@ -1116,7 +1121,7 @@ var JBondClient = class _JBondClient {
1116
1121
  */
1117
1122
  async topUpCollateral(props) {
1118
1123
  const ix = await this.buildTopUpCollateralInstruction(props);
1119
- return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
1124
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
1120
1125
  }
1121
1126
  /**
1122
1127
  * Withdraw collateral
@@ -1126,7 +1131,7 @@ var JBondClient = class _JBondClient {
1126
1131
  */
1127
1132
  async withdrawCollateral(props) {
1128
1133
  const ix = await this.buildWithdrawCollateralInstruction(props);
1129
- return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
1134
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
1130
1135
  }
1131
1136
  /**
1132
1137
  * Claim compensation
@@ -1135,7 +1140,7 @@ var JBondClient = class _JBondClient {
1135
1140
  */
1136
1141
  async claimCompensation(props) {
1137
1142
  const ix = await this.buildClaimInstruction(props);
1138
- return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
1143
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
1139
1144
  }
1140
1145
  /**
1141
1146
  * Update global configuration for the program
@@ -1145,7 +1150,7 @@ var JBondClient = class _JBondClient {
1145
1150
  */
1146
1151
  async configure(props) {
1147
1152
  const ix = await this.buildConfigureInstruction(props);
1148
- return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
1153
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
1149
1154
  }
1150
1155
  /**
1151
1156
  * Set withdrawal authority for validator bond
@@ -1155,7 +1160,7 @@ var JBondClient = class _JBondClient {
1155
1160
  */
1156
1161
  async setWithdrawAuthority(props) {
1157
1162
  const ix = await this.buildSetWithdrawAuthorityInstruction(props);
1158
- return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
1163
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
1159
1164
  }
1160
1165
  /**
1161
1166
  * Build initialize instruction
@@ -1163,7 +1168,7 @@ var JBondClient = class _JBondClient {
1163
1168
  async buildInitializeInstruction(props) {
1164
1169
  const [globalState] = this.pda.globalState();
1165
1170
  const { reserve } = props;
1166
- const authority = props.authority ?? this.provider.wallet.publicKey;
1171
+ const authority = props.authority ?? this.provider.wallet?.publicKey;
1167
1172
  return this.program.methods.initialize().accountsPartial({
1168
1173
  globalState,
1169
1174
  authority,
@@ -1178,7 +1183,7 @@ var JBondClient = class _JBondClient {
1178
1183
  const [globalState] = this.pda.globalState();
1179
1184
  const [validatorBond] = this.pda.validatorBond(voteAccount);
1180
1185
  const lamports = new anchor.BN(initialCollateral * web3_js.LAMPORTS_PER_SOL);
1181
- const creator = props.creator ?? this.provider.wallet.publicKey;
1186
+ const creator = props.creator ?? this.provider.wallet?.publicKey;
1182
1187
  return this.program.methods.register(lamports).accountsPartial({
1183
1188
  creator,
1184
1189
  globalState,
@@ -1194,7 +1199,7 @@ var JBondClient = class _JBondClient {
1194
1199
  const { voteAccount, amount } = props;
1195
1200
  const [validatorBond] = this.pda.validatorBond(voteAccount);
1196
1201
  const lamports = new anchor.BN(amount * web3_js.LAMPORTS_PER_SOL);
1197
- const payer = props.payer ?? this.provider.wallet.publicKey;
1202
+ const payer = props.payer ?? this.provider.wallet?.publicKey;
1198
1203
  return this.program.methods.topUp(lamports).accountsPartial({
1199
1204
  validatorBond,
1200
1205
  payer
@@ -1207,8 +1212,8 @@ var JBondClient = class _JBondClient {
1207
1212
  const { voteAccount, amount } = props;
1208
1213
  const [validatorBond] = this.pda.validatorBond(voteAccount);
1209
1214
  const lamports = new anchor.BN(amount * web3_js.LAMPORTS_PER_SOL);
1210
- const withdrawalAuthority = props.withdrawalAuthority ?? this.provider.wallet.publicKey;
1211
- const destination = props.destination ?? this.provider.wallet.publicKey;
1215
+ const withdrawalAuthority = props.withdrawalAuthority ?? this.provider.wallet?.publicKey;
1216
+ const destination = props.destination ?? this.provider.wallet?.publicKey;
1212
1217
  return this.program.methods.withdraw(lamports).accountsPartial({
1213
1218
  validatorBond,
1214
1219
  withdrawalAuthority,
@@ -1223,7 +1228,7 @@ var JBondClient = class _JBondClient {
1223
1228
  const [globalState] = this.pda.globalState();
1224
1229
  const [validatorBond] = this.pda.validatorBond(props.voteAccount);
1225
1230
  const lamports = new anchor.BN(props.amount * web3_js.LAMPORTS_PER_SOL);
1226
- const authority = props.authority ?? this.provider.wallet.publicKey;
1231
+ const authority = props.authority ?? this.provider.wallet?.publicKey;
1227
1232
  let reserve = props.reserve;
1228
1233
  if (!reserve) {
1229
1234
  const globalStateData = await this.getGlobalState();
@@ -1244,7 +1249,7 @@ var JBondClient = class _JBondClient {
1244
1249
  */
1245
1250
  async buildConfigureInstruction(props) {
1246
1251
  const [globalState] = this.pda.globalState();
1247
- const authority = props.authority ?? this.provider.wallet.publicKey;
1252
+ const authority = props.authority ?? this.provider.wallet?.publicKey;
1248
1253
  return this.program.methods.configure({
1249
1254
  newAuthority: props.newAuthority ?? null,
1250
1255
  newReserve: props.newReserve ?? null
@@ -1259,7 +1264,7 @@ var JBondClient = class _JBondClient {
1259
1264
  async buildSetWithdrawAuthorityInstruction(props) {
1260
1265
  const { voteAccount, newWithdrawAuthority } = props;
1261
1266
  const [validatorBond] = this.pda.validatorBond(voteAccount);
1262
- const identity = props.identity ?? this.provider.wallet.publicKey;
1267
+ const identity = props.identity ?? this.provider.wallet?.publicKey;
1263
1268
  return this.program.methods.setWithdrawAuthority().accountsPartial({
1264
1269
  validatorBond,
1265
1270
  identity,
@@ -1412,7 +1417,11 @@ var JBondClient = class _JBondClient {
1412
1417
  }
1413
1418
  return allTxs;
1414
1419
  }
1415
- // Decode instruction data to determine transaction type and amount
1420
+ /**
1421
+ * Decode instruction data to determine transaction type and amount
1422
+ * @param data
1423
+ * @private
1424
+ */
1416
1425
  decodeInstructionData(data) {
1417
1426
  if (!data) {
1418
1427
  return { type: null, amount: 0 };
@@ -1455,5 +1464,6 @@ exports.BondTransactionType = BondTransactionType;
1455
1464
  exports.ENV_PROGRAM_ID = ENV_PROGRAM_ID;
1456
1465
  exports.JBondClient = JBondClient;
1457
1466
  exports.NodeWallet = NodeWallet;
1467
+ exports.Seeds = Seeds;
1458
1468
  //# sourceMappingURL=index.js.map
1459
1469
  //# sourceMappingURL=index.js.map