@jpool/bond-sdk 0.8.0-next.0 → 0.8.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.mjs CHANGED
@@ -123,6 +123,73 @@ var jbond_default = {
123
123
  }
124
124
  ]
125
125
  },
126
+ {
127
+ name: "configure",
128
+ docs: [
129
+ "Updates the global program configuration, including authority and reserve fields.",
130
+ "Allows changing the program's authority and updating the reserve account.",
131
+ "",
132
+ "# Arguments",
133
+ "* `data` - Configuration data containing optional new authority and reserve keys.",
134
+ "",
135
+ "# Errors",
136
+ "Fails if the signer is not authorized to update the global configuration."
137
+ ],
138
+ discriminator: [
139
+ 245,
140
+ 7,
141
+ 108,
142
+ 117,
143
+ 95,
144
+ 196,
145
+ 54,
146
+ 217
147
+ ],
148
+ accounts: [
149
+ {
150
+ name: "global_state",
151
+ writable: true,
152
+ pda: {
153
+ seeds: [
154
+ {
155
+ kind: "const",
156
+ value: [
157
+ 103,
158
+ 108,
159
+ 111,
160
+ 98,
161
+ 97,
162
+ 108,
163
+ 95,
164
+ 115,
165
+ 116,
166
+ 97,
167
+ 116,
168
+ 101
169
+ ]
170
+ }
171
+ ]
172
+ }
173
+ },
174
+ {
175
+ name: "authority",
176
+ signer: true,
177
+ relations: [
178
+ "global_state"
179
+ ]
180
+ }
181
+ ],
182
+ args: [
183
+ {
184
+ name: "data",
185
+ type: {
186
+ defined: {
187
+ name: "ConfigureData"
188
+ }
189
+ }
190
+ }
191
+ ]
192
+ },
126
193
  {
127
194
  name: "initialize",
128
195
  docs: [
@@ -288,72 +355,72 @@ var jbond_default = {
288
355
  {
289
356
  name: "initial_collateral",
290
357
  type: "u64"
291
- },
292
- {
293
- name: "withdrawal_authority",
294
- type: {
295
- option: "pubkey"
296
- }
297
358
  }
298
359
  ]
299
360
  },
300
361
  {
301
- name: "set_authority",
362
+ name: "set_withdraw_authority",
302
363
  docs: [
303
364
  "Sets a new withdrawal authority for a validator's bond account.",
304
365
  "Allows changing who can withdraw collateral in the future.",
305
366
  "",
306
367
  "# Arguments",
307
- "* `new_authority` - Optional new authority key (None to restrict to identity).",
368
+ "* `new_withdraw_authority` - Optional new withdrawal authority key (None to restrict to",
369
+ "identity).",
308
370
  "",
309
371
  "# Errors",
310
- "Fails if the signer is not authorized to change the authority."
372
+ "Fails if the signer is not authorized to change the withdrawal authority."
311
373
  ],
312
374
  discriminator: [
313
- 133,
314
- 250,
315
- 37,
316
- 21,
317
- 110,
318
- 163,
319
- 26,
320
- 121
375
+ 199,
376
+ 146,
377
+ 140,
378
+ 67,
379
+ 1,
380
+ 90,
381
+ 8,
382
+ 222
321
383
  ],
322
384
  accounts: [
323
385
  {
324
- name: "global_state",
386
+ name: "validator_bond",
325
387
  writable: true,
326
388
  pda: {
327
389
  seeds: [
328
390
  {
329
391
  kind: "const",
330
392
  value: [
331
- 103,
332
- 108,
333
- 111,
334
- 98,
393
+ 118,
335
394
  97,
336
395
  108,
337
- 95,
338
- 115,
339
- 116,
396
+ 105,
397
+ 100,
340
398
  97,
341
399
  116,
342
- 101
400
+ 111,
401
+ 114,
402
+ 95,
403
+ 98,
404
+ 111,
405
+ 110,
406
+ 100
343
407
  ]
408
+ },
409
+ {
410
+ kind: "account",
411
+ path: "validator_bond.vote_account",
412
+ account: "ValidatorBond"
344
413
  }
345
414
  ]
346
415
  }
347
416
  },
348
417
  {
349
- name: "authority",
350
- signer: true,
351
- relations: [
352
- "global_state"
353
- ]
418
+ name: "identity",
419
+ signer: true
354
420
  },
355
421
  {
356
- name: "new_authority"
422
+ name: "new_withdraw_authority",
423
+ optional: true
357
424
  }
358
425
  ],
359
426
  args: []
@@ -630,7 +697,7 @@ var jbond_default = {
630
697
  {
631
698
  code: 6006,
632
699
  name: "ValidatorNotActive",
633
- msg: "Validator boost account is not active"
700
+ msg: "Validator bond account is not active"
634
701
  },
635
702
  {
636
703
  code: 6007,
@@ -725,6 +792,26 @@ var jbond_default = {
725
792
  ]
726
793
  }
727
794
  },
795
+ {
796
+ name: "ConfigureData",
797
+ type: {
798
+ kind: "struct",
799
+ fields: [
800
+ {
801
+ name: "new_authority",
802
+ type: {
803
+ option: "pubkey"
804
+ }
805
+ },
806
+ {
807
+ name: "new_reserve",
808
+ type: {
809
+ option: "pubkey"
810
+ }
811
+ }
812
+ ]
813
+ }
814
+ },
728
815
  {
729
816
  name: "GlobalState",
730
817
  type: {
@@ -972,12 +1059,12 @@ var JBondClient = class _JBondClient {
972
1059
  * Set the environment.
973
1060
  */
974
1061
  env(env) {
975
- return this.configure("programId", ENV_PROGRAM_ID[env]);
1062
+ return this.configureEnv("programId", ENV_PROGRAM_ID[env]);
976
1063
  }
977
1064
  /**
978
1065
  * Configure a specific option.
979
1066
  */
980
- configure(key, val) {
1067
+ configureEnv(key, val) {
981
1068
  this.options[key] = val;
982
1069
  return this;
983
1070
  }
@@ -1045,12 +1132,23 @@ var JBondClient = class _JBondClient {
1045
1132
  return await this.provider.sendAndConfirm(new Transaction().add(ix));
1046
1133
  }
1047
1134
  /**
1048
- * Set a new authority for the program
1135
+ * Update global configuration for the program
1049
1136
  * Default authority is the provider's wallet
1137
+ * Only the current authority can call this
1138
+ * @return Transaction signature
1139
+ */
1140
+ async configure(props) {
1141
+ const ix = await this.buildConfigureInstruction(props);
1142
+ return await this.provider.sendAndConfirm(new Transaction().add(ix));
1143
+ }
1144
+ /**
1145
+ * Set withdrawal authority for validator bond
1146
+ * Only the validator identity can call this
1147
+ * Default identity is the provider's wallet
1050
1148
  * @return Transaction signature
1051
1149
  */
1052
- async setAuthority(props) {
1053
- const ix = await this.buildSetAuthorityInstruction(props);
1150
+ async setWithdrawAuthority(props) {
1151
+ const ix = await this.buildSetWithdrawAuthorityInstruction(props);
1054
1152
  return await this.provider.sendAndConfirm(new Transaction().add(ix));
1055
1153
  }
1056
1154
  /**
@@ -1070,12 +1168,12 @@ var JBondClient = class _JBondClient {
1070
1168
  * Build register validator instruction
1071
1169
  */
1072
1170
  async buildRegisterValidatorInstruction(props) {
1073
- const { identity, voteAccount, initialCollateral, withdrawalAuthority } = props;
1171
+ const { identity, voteAccount, initialCollateral } = props;
1074
1172
  const [globalState] = this.pda.globalState();
1075
1173
  const [validatorBond] = this.pda.validatorBond(voteAccount);
1076
1174
  const lamports = new BN(initialCollateral * LAMPORTS_PER_SOL);
1077
1175
  const creator = props.creator ?? this.provider.wallet.publicKey;
1078
- return this.program.methods.register(lamports, withdrawalAuthority ?? null).accountsPartial({
1176
+ return this.program.methods.register(lamports).accountsPartial({
1079
1177
  creator,
1080
1178
  globalState,
1081
1179
  validatorBond,
@@ -1136,15 +1234,30 @@ var JBondClient = class _JBondClient {
1136
1234
  }).instruction();
1137
1235
  }
1138
1236
  /**
1139
- * Build set authority instruction
1237
+ * Build configure instruction
1140
1238
  */
1141
- async buildSetAuthorityInstruction(props) {
1239
+ async buildConfigureInstruction(props) {
1142
1240
  const [globalState] = this.pda.globalState();
1143
1241
  const authority = props.authority ?? this.provider.wallet.publicKey;
1144
- return this.program.methods.setAuthority().accountsStrict({
1242
+ return this.program.methods.configure({
1243
+ newAuthority: props.newAuthority ?? null,
1244
+ newReserve: props.newReserve ?? null
1245
+ }).accountsStrict({
1145
1246
  globalState,
1146
- authority,
1147
- newAuthority: props.newAuthority
1247
+ authority
1248
+ }).instruction();
1249
+ }
1250
+ /**
1251
+ * Build set withdraw authority instruction
1252
+ */
1253
+ async buildSetWithdrawAuthorityInstruction(props) {
1254
+ const { voteAccount, newWithdrawAuthority } = props;
1255
+ const [validatorBond] = this.pda.validatorBond(voteAccount);
1256
+ const identity = props.identity ?? this.provider.wallet.publicKey;
1257
+ return this.program.methods.setWithdrawAuthority().accountsPartial({
1258
+ validatorBond,
1259
+ identity,
1260
+ newWithdrawAuthority: newWithdrawAuthority ?? null
1148
1261
  }).instruction();
1149
1262
  }
1150
1263
  /**