@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.d.mts +145 -41
- package/dist/index.d.ts +145 -41
- package/dist/index.js +158 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -129,6 +129,73 @@ var jbond_default = {
|
|
|
129
129
|
}
|
|
130
130
|
]
|
|
131
131
|
},
|
|
132
|
+
{
|
|
133
|
+
name: "configure",
|
|
134
|
+
docs: [
|
|
135
|
+
"Updates the global program configuration, including authority and reserve fields.",
|
|
136
|
+
"Allows changing the program's authority and updating the reserve account.",
|
|
137
|
+
"",
|
|
138
|
+
"# Arguments",
|
|
139
|
+
"* `data` - Configuration data containing optional new authority and reserve keys.",
|
|
140
|
+
"",
|
|
141
|
+
"# Errors",
|
|
142
|
+
"Fails if the signer is not authorized to update the global configuration."
|
|
143
|
+
],
|
|
144
|
+
discriminator: [
|
|
145
|
+
245,
|
|
146
|
+
7,
|
|
147
|
+
108,
|
|
148
|
+
117,
|
|
149
|
+
95,
|
|
150
|
+
196,
|
|
151
|
+
54,
|
|
152
|
+
217
|
|
153
|
+
],
|
|
154
|
+
accounts: [
|
|
155
|
+
{
|
|
156
|
+
name: "global_state",
|
|
157
|
+
writable: true,
|
|
158
|
+
pda: {
|
|
159
|
+
seeds: [
|
|
160
|
+
{
|
|
161
|
+
kind: "const",
|
|
162
|
+
value: [
|
|
163
|
+
103,
|
|
164
|
+
108,
|
|
165
|
+
111,
|
|
166
|
+
98,
|
|
167
|
+
97,
|
|
168
|
+
108,
|
|
169
|
+
95,
|
|
170
|
+
115,
|
|
171
|
+
116,
|
|
172
|
+
97,
|
|
173
|
+
116,
|
|
174
|
+
101
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "authority",
|
|
182
|
+
signer: true,
|
|
183
|
+
relations: [
|
|
184
|
+
"global_state"
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
args: [
|
|
189
|
+
{
|
|
190
|
+
name: "data",
|
|
191
|
+
type: {
|
|
192
|
+
defined: {
|
|
193
|
+
name: "ConfigureData"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
},
|
|
132
199
|
{
|
|
133
200
|
name: "initialize",
|
|
134
201
|
docs: [
|
|
@@ -294,72 +361,72 @@ var jbond_default = {
|
|
|
294
361
|
{
|
|
295
362
|
name: "initial_collateral",
|
|
296
363
|
type: "u64"
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
name: "withdrawal_authority",
|
|
300
|
-
type: {
|
|
301
|
-
option: "pubkey"
|
|
302
|
-
}
|
|
303
364
|
}
|
|
304
365
|
]
|
|
305
366
|
},
|
|
306
367
|
{
|
|
307
|
-
name: "
|
|
368
|
+
name: "set_withdraw_authority",
|
|
308
369
|
docs: [
|
|
309
370
|
"Sets a new withdrawal authority for a validator's bond account.",
|
|
310
371
|
"Allows changing who can withdraw collateral in the future.",
|
|
311
372
|
"",
|
|
312
373
|
"# Arguments",
|
|
313
|
-
"* `
|
|
374
|
+
"* `new_withdraw_authority` - Optional new withdrawal authority key (None to restrict to",
|
|
375
|
+
"identity).",
|
|
314
376
|
"",
|
|
315
377
|
"# Errors",
|
|
316
|
-
"Fails if the signer is not authorized to change the authority."
|
|
378
|
+
"Fails if the signer is not authorized to change the withdrawal authority."
|
|
317
379
|
],
|
|
318
380
|
discriminator: [
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
381
|
+
199,
|
|
382
|
+
146,
|
|
383
|
+
140,
|
|
384
|
+
67,
|
|
385
|
+
1,
|
|
386
|
+
90,
|
|
387
|
+
8,
|
|
388
|
+
222
|
|
327
389
|
],
|
|
328
390
|
accounts: [
|
|
329
391
|
{
|
|
330
|
-
name: "
|
|
392
|
+
name: "validator_bond",
|
|
331
393
|
writable: true,
|
|
332
394
|
pda: {
|
|
333
395
|
seeds: [
|
|
334
396
|
{
|
|
335
397
|
kind: "const",
|
|
336
398
|
value: [
|
|
337
|
-
|
|
338
|
-
108,
|
|
339
|
-
111,
|
|
340
|
-
98,
|
|
399
|
+
118,
|
|
341
400
|
97,
|
|
342
401
|
108,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
116,
|
|
402
|
+
105,
|
|
403
|
+
100,
|
|
346
404
|
97,
|
|
347
405
|
116,
|
|
348
|
-
|
|
406
|
+
111,
|
|
407
|
+
114,
|
|
408
|
+
95,
|
|
409
|
+
98,
|
|
410
|
+
111,
|
|
411
|
+
110,
|
|
412
|
+
100
|
|
349
413
|
]
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
kind: "account",
|
|
417
|
+
path: "validator_bond.vote_account",
|
|
418
|
+
account: "ValidatorBond"
|
|
350
419
|
}
|
|
351
420
|
]
|
|
352
421
|
}
|
|
353
422
|
},
|
|
354
423
|
{
|
|
355
|
-
name: "
|
|
356
|
-
signer: true
|
|
357
|
-
relations: [
|
|
358
|
-
"global_state"
|
|
359
|
-
]
|
|
424
|
+
name: "identity",
|
|
425
|
+
signer: true
|
|
360
426
|
},
|
|
361
427
|
{
|
|
362
|
-
name: "
|
|
428
|
+
name: "new_withdraw_authority",
|
|
429
|
+
optional: true
|
|
363
430
|
}
|
|
364
431
|
],
|
|
365
432
|
args: []
|
|
@@ -636,7 +703,7 @@ var jbond_default = {
|
|
|
636
703
|
{
|
|
637
704
|
code: 6006,
|
|
638
705
|
name: "ValidatorNotActive",
|
|
639
|
-
msg: "Validator
|
|
706
|
+
msg: "Validator bond account is not active"
|
|
640
707
|
},
|
|
641
708
|
{
|
|
642
709
|
code: 6007,
|
|
@@ -731,6 +798,26 @@ var jbond_default = {
|
|
|
731
798
|
]
|
|
732
799
|
}
|
|
733
800
|
},
|
|
801
|
+
{
|
|
802
|
+
name: "ConfigureData",
|
|
803
|
+
type: {
|
|
804
|
+
kind: "struct",
|
|
805
|
+
fields: [
|
|
806
|
+
{
|
|
807
|
+
name: "new_authority",
|
|
808
|
+
type: {
|
|
809
|
+
option: "pubkey"
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
name: "new_reserve",
|
|
814
|
+
type: {
|
|
815
|
+
option: "pubkey"
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
]
|
|
819
|
+
}
|
|
820
|
+
},
|
|
734
821
|
{
|
|
735
822
|
name: "GlobalState",
|
|
736
823
|
type: {
|
|
@@ -978,12 +1065,12 @@ var JBondClient = class _JBondClient {
|
|
|
978
1065
|
* Set the environment.
|
|
979
1066
|
*/
|
|
980
1067
|
env(env) {
|
|
981
|
-
return this.
|
|
1068
|
+
return this.configureEnv("programId", ENV_PROGRAM_ID[env]);
|
|
982
1069
|
}
|
|
983
1070
|
/**
|
|
984
1071
|
* Configure a specific option.
|
|
985
1072
|
*/
|
|
986
|
-
|
|
1073
|
+
configureEnv(key, val) {
|
|
987
1074
|
this.options[key] = val;
|
|
988
1075
|
return this;
|
|
989
1076
|
}
|
|
@@ -1051,12 +1138,23 @@ var JBondClient = class _JBondClient {
|
|
|
1051
1138
|
return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
|
|
1052
1139
|
}
|
|
1053
1140
|
/**
|
|
1054
|
-
*
|
|
1141
|
+
* Update global configuration for the program
|
|
1055
1142
|
* Default authority is the provider's wallet
|
|
1143
|
+
* Only the current authority can call this
|
|
1144
|
+
* @return Transaction signature
|
|
1145
|
+
*/
|
|
1146
|
+
async configure(props) {
|
|
1147
|
+
const ix = await this.buildConfigureInstruction(props);
|
|
1148
|
+
return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Set withdrawal authority for validator bond
|
|
1152
|
+
* Only the validator identity can call this
|
|
1153
|
+
* Default identity is the provider's wallet
|
|
1056
1154
|
* @return Transaction signature
|
|
1057
1155
|
*/
|
|
1058
|
-
async
|
|
1059
|
-
const ix = await this.
|
|
1156
|
+
async setWithdrawAuthority(props) {
|
|
1157
|
+
const ix = await this.buildSetWithdrawAuthorityInstruction(props);
|
|
1060
1158
|
return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
|
|
1061
1159
|
}
|
|
1062
1160
|
/**
|
|
@@ -1076,12 +1174,12 @@ var JBondClient = class _JBondClient {
|
|
|
1076
1174
|
* Build register validator instruction
|
|
1077
1175
|
*/
|
|
1078
1176
|
async buildRegisterValidatorInstruction(props) {
|
|
1079
|
-
const { identity, voteAccount, initialCollateral
|
|
1177
|
+
const { identity, voteAccount, initialCollateral } = props;
|
|
1080
1178
|
const [globalState] = this.pda.globalState();
|
|
1081
1179
|
const [validatorBond] = this.pda.validatorBond(voteAccount);
|
|
1082
1180
|
const lamports = new anchor.BN(initialCollateral * web3_js.LAMPORTS_PER_SOL);
|
|
1083
1181
|
const creator = props.creator ?? this.provider.wallet.publicKey;
|
|
1084
|
-
return this.program.methods.register(lamports
|
|
1182
|
+
return this.program.methods.register(lamports).accountsPartial({
|
|
1085
1183
|
creator,
|
|
1086
1184
|
globalState,
|
|
1087
1185
|
validatorBond,
|
|
@@ -1142,15 +1240,30 @@ var JBondClient = class _JBondClient {
|
|
|
1142
1240
|
}).instruction();
|
|
1143
1241
|
}
|
|
1144
1242
|
/**
|
|
1145
|
-
* Build
|
|
1243
|
+
* Build configure instruction
|
|
1146
1244
|
*/
|
|
1147
|
-
async
|
|
1245
|
+
async buildConfigureInstruction(props) {
|
|
1148
1246
|
const [globalState] = this.pda.globalState();
|
|
1149
1247
|
const authority = props.authority ?? this.provider.wallet.publicKey;
|
|
1150
|
-
return this.program.methods.
|
|
1248
|
+
return this.program.methods.configure({
|
|
1249
|
+
newAuthority: props.newAuthority ?? null,
|
|
1250
|
+
newReserve: props.newReserve ?? null
|
|
1251
|
+
}).accountsStrict({
|
|
1151
1252
|
globalState,
|
|
1152
|
-
authority
|
|
1153
|
-
|
|
1253
|
+
authority
|
|
1254
|
+
}).instruction();
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Build set withdraw authority instruction
|
|
1258
|
+
*/
|
|
1259
|
+
async buildSetWithdrawAuthorityInstruction(props) {
|
|
1260
|
+
const { voteAccount, newWithdrawAuthority } = props;
|
|
1261
|
+
const [validatorBond] = this.pda.validatorBond(voteAccount);
|
|
1262
|
+
const identity = props.identity ?? this.provider.wallet.publicKey;
|
|
1263
|
+
return this.program.methods.setWithdrawAuthority().accountsPartial({
|
|
1264
|
+
validatorBond,
|
|
1265
|
+
identity,
|
|
1266
|
+
newWithdrawAuthority: newWithdrawAuthority ?? null
|
|
1154
1267
|
}).instruction();
|
|
1155
1268
|
}
|
|
1156
1269
|
/**
|