@jpool/bond-sdk 0.8.0-next.0 → 0.8.0-next.1
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 +84 -9
- package/dist/index.d.ts +84 -9
- package/dist/index.js +92 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -286,12 +286,6 @@ type Jbond = {
|
|
|
286
286
|
{
|
|
287
287
|
"name": "initialCollateral";
|
|
288
288
|
"type": "u64";
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
"name": "withdrawalAuthority";
|
|
292
|
-
"type": {
|
|
293
|
-
"option": "pubkey";
|
|
294
|
-
};
|
|
295
289
|
}
|
|
296
290
|
];
|
|
297
291
|
},
|
|
@@ -356,6 +350,72 @@ type Jbond = {
|
|
|
356
350
|
];
|
|
357
351
|
"args": [];
|
|
358
352
|
},
|
|
353
|
+
{
|
|
354
|
+
"name": "setWithdrawAuthority";
|
|
355
|
+
"docs": [
|
|
356
|
+
"Sets a new withdrawal authority for a validator's bond account.",
|
|
357
|
+
"Allows changing who can withdraw collateral in the future.",
|
|
358
|
+
"",
|
|
359
|
+
"# Arguments",
|
|
360
|
+
"* `new_withdraw_authority` - Optional new withdrawal authority key (None to restrict to identity).",
|
|
361
|
+
"",
|
|
362
|
+
"# Errors",
|
|
363
|
+
"Fails if the signer is not authorized to change the withdrawal authority."
|
|
364
|
+
];
|
|
365
|
+
"discriminator": [
|
|
366
|
+
199,
|
|
367
|
+
146,
|
|
368
|
+
140,
|
|
369
|
+
67,
|
|
370
|
+
1,
|
|
371
|
+
90,
|
|
372
|
+
8,
|
|
373
|
+
222
|
|
374
|
+
];
|
|
375
|
+
"accounts": [
|
|
376
|
+
{
|
|
377
|
+
"name": "validatorBond";
|
|
378
|
+
"writable": true;
|
|
379
|
+
"pda": {
|
|
380
|
+
"seeds": [
|
|
381
|
+
{
|
|
382
|
+
"kind": "const";
|
|
383
|
+
"value": [
|
|
384
|
+
118,
|
|
385
|
+
97,
|
|
386
|
+
108,
|
|
387
|
+
105,
|
|
388
|
+
100,
|
|
389
|
+
97,
|
|
390
|
+
116,
|
|
391
|
+
111,
|
|
392
|
+
114,
|
|
393
|
+
95,
|
|
394
|
+
98,
|
|
395
|
+
111,
|
|
396
|
+
110,
|
|
397
|
+
100
|
|
398
|
+
];
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"kind": "account";
|
|
402
|
+
"path": "validator_bond.vote_account";
|
|
403
|
+
"account": "validatorBond";
|
|
404
|
+
}
|
|
405
|
+
];
|
|
406
|
+
};
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"name": "identity";
|
|
410
|
+
"signer": true;
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "newWithdrawAuthority";
|
|
414
|
+
"optional": true;
|
|
415
|
+
}
|
|
416
|
+
];
|
|
417
|
+
"args": [];
|
|
418
|
+
},
|
|
359
419
|
{
|
|
360
420
|
"name": "topUp";
|
|
361
421
|
"docs": [
|
|
@@ -628,7 +688,7 @@ type Jbond = {
|
|
|
628
688
|
{
|
|
629
689
|
"code": 6006;
|
|
630
690
|
"name": "validatorNotActive";
|
|
631
|
-
"msg": "Validator
|
|
691
|
+
"msg": "Validator bond account is not active";
|
|
632
692
|
},
|
|
633
693
|
{
|
|
634
694
|
"code": 6007;
|
|
@@ -891,7 +951,6 @@ type RegisterValidatorProps = {
|
|
|
891
951
|
identity: PublicKey;
|
|
892
952
|
voteAccount: PublicKey;
|
|
893
953
|
initialCollateral: number;
|
|
894
|
-
withdrawalAuthority?: PublicKey;
|
|
895
954
|
creator?: PublicKey;
|
|
896
955
|
};
|
|
897
956
|
type TopUpCollateralProps = {
|
|
@@ -927,6 +986,11 @@ type SetAuthorityProps = {
|
|
|
927
986
|
newAuthority: PublicKey;
|
|
928
987
|
authority?: PublicKey;
|
|
929
988
|
};
|
|
989
|
+
type SetWithdrawAuthorityProps = {
|
|
990
|
+
voteAccount: PublicKey;
|
|
991
|
+
newWithdrawAuthority?: PublicKey | null;
|
|
992
|
+
identity?: PublicKey;
|
|
993
|
+
};
|
|
930
994
|
type GlobalState = {
|
|
931
995
|
authority: PublicKey;
|
|
932
996
|
totalValidators: number;
|
|
@@ -1055,6 +1119,13 @@ declare class JBondClient {
|
|
|
1055
1119
|
* @return Transaction signature
|
|
1056
1120
|
*/
|
|
1057
1121
|
setAuthority(props: SetAuthorityProps): Promise<string>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Set withdrawal authority for validator bond
|
|
1124
|
+
* Only the validator identity can call this
|
|
1125
|
+
* Default identity is the provider's wallet
|
|
1126
|
+
* @return Transaction signature
|
|
1127
|
+
*/
|
|
1128
|
+
setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string>;
|
|
1058
1129
|
/**
|
|
1059
1130
|
* Build initialize instruction
|
|
1060
1131
|
*/
|
|
@@ -1079,6 +1150,10 @@ declare class JBondClient {
|
|
|
1079
1150
|
* Build set authority instruction
|
|
1080
1151
|
*/
|
|
1081
1152
|
buildSetAuthorityInstruction(props: SetAuthorityProps): Promise<_solana_web3_js.TransactionInstruction>;
|
|
1153
|
+
/**
|
|
1154
|
+
* Build set withdraw authority instruction
|
|
1155
|
+
*/
|
|
1156
|
+
buildSetWithdrawAuthorityInstruction(props: SetWithdrawAuthorityProps): Promise<_solana_web3_js.TransactionInstruction>;
|
|
1082
1157
|
/**
|
|
1083
1158
|
* Fetch global state or throw if not found
|
|
1084
1159
|
*/
|
|
@@ -1146,4 +1221,4 @@ declare class JBondClient {
|
|
|
1146
1221
|
*/
|
|
1147
1222
|
declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
|
|
1148
1223
|
|
|
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 };
|
|
1224
|
+
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 SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -286,12 +286,6 @@ type Jbond = {
|
|
|
286
286
|
{
|
|
287
287
|
"name": "initialCollateral";
|
|
288
288
|
"type": "u64";
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
"name": "withdrawalAuthority";
|
|
292
|
-
"type": {
|
|
293
|
-
"option": "pubkey";
|
|
294
|
-
};
|
|
295
289
|
}
|
|
296
290
|
];
|
|
297
291
|
},
|
|
@@ -356,6 +350,72 @@ type Jbond = {
|
|
|
356
350
|
];
|
|
357
351
|
"args": [];
|
|
358
352
|
},
|
|
353
|
+
{
|
|
354
|
+
"name": "setWithdrawAuthority";
|
|
355
|
+
"docs": [
|
|
356
|
+
"Sets a new withdrawal authority for a validator's bond account.",
|
|
357
|
+
"Allows changing who can withdraw collateral in the future.",
|
|
358
|
+
"",
|
|
359
|
+
"# Arguments",
|
|
360
|
+
"* `new_withdraw_authority` - Optional new withdrawal authority key (None to restrict to identity).",
|
|
361
|
+
"",
|
|
362
|
+
"# Errors",
|
|
363
|
+
"Fails if the signer is not authorized to change the withdrawal authority."
|
|
364
|
+
];
|
|
365
|
+
"discriminator": [
|
|
366
|
+
199,
|
|
367
|
+
146,
|
|
368
|
+
140,
|
|
369
|
+
67,
|
|
370
|
+
1,
|
|
371
|
+
90,
|
|
372
|
+
8,
|
|
373
|
+
222
|
|
374
|
+
];
|
|
375
|
+
"accounts": [
|
|
376
|
+
{
|
|
377
|
+
"name": "validatorBond";
|
|
378
|
+
"writable": true;
|
|
379
|
+
"pda": {
|
|
380
|
+
"seeds": [
|
|
381
|
+
{
|
|
382
|
+
"kind": "const";
|
|
383
|
+
"value": [
|
|
384
|
+
118,
|
|
385
|
+
97,
|
|
386
|
+
108,
|
|
387
|
+
105,
|
|
388
|
+
100,
|
|
389
|
+
97,
|
|
390
|
+
116,
|
|
391
|
+
111,
|
|
392
|
+
114,
|
|
393
|
+
95,
|
|
394
|
+
98,
|
|
395
|
+
111,
|
|
396
|
+
110,
|
|
397
|
+
100
|
|
398
|
+
];
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"kind": "account";
|
|
402
|
+
"path": "validator_bond.vote_account";
|
|
403
|
+
"account": "validatorBond";
|
|
404
|
+
}
|
|
405
|
+
];
|
|
406
|
+
};
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"name": "identity";
|
|
410
|
+
"signer": true;
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "newWithdrawAuthority";
|
|
414
|
+
"optional": true;
|
|
415
|
+
}
|
|
416
|
+
];
|
|
417
|
+
"args": [];
|
|
418
|
+
},
|
|
359
419
|
{
|
|
360
420
|
"name": "topUp";
|
|
361
421
|
"docs": [
|
|
@@ -628,7 +688,7 @@ type Jbond = {
|
|
|
628
688
|
{
|
|
629
689
|
"code": 6006;
|
|
630
690
|
"name": "validatorNotActive";
|
|
631
|
-
"msg": "Validator
|
|
691
|
+
"msg": "Validator bond account is not active";
|
|
632
692
|
},
|
|
633
693
|
{
|
|
634
694
|
"code": 6007;
|
|
@@ -891,7 +951,6 @@ type RegisterValidatorProps = {
|
|
|
891
951
|
identity: PublicKey;
|
|
892
952
|
voteAccount: PublicKey;
|
|
893
953
|
initialCollateral: number;
|
|
894
|
-
withdrawalAuthority?: PublicKey;
|
|
895
954
|
creator?: PublicKey;
|
|
896
955
|
};
|
|
897
956
|
type TopUpCollateralProps = {
|
|
@@ -927,6 +986,11 @@ type SetAuthorityProps = {
|
|
|
927
986
|
newAuthority: PublicKey;
|
|
928
987
|
authority?: PublicKey;
|
|
929
988
|
};
|
|
989
|
+
type SetWithdrawAuthorityProps = {
|
|
990
|
+
voteAccount: PublicKey;
|
|
991
|
+
newWithdrawAuthority?: PublicKey | null;
|
|
992
|
+
identity?: PublicKey;
|
|
993
|
+
};
|
|
930
994
|
type GlobalState = {
|
|
931
995
|
authority: PublicKey;
|
|
932
996
|
totalValidators: number;
|
|
@@ -1055,6 +1119,13 @@ declare class JBondClient {
|
|
|
1055
1119
|
* @return Transaction signature
|
|
1056
1120
|
*/
|
|
1057
1121
|
setAuthority(props: SetAuthorityProps): Promise<string>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Set withdrawal authority for validator bond
|
|
1124
|
+
* Only the validator identity can call this
|
|
1125
|
+
* Default identity is the provider's wallet
|
|
1126
|
+
* @return Transaction signature
|
|
1127
|
+
*/
|
|
1128
|
+
setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string>;
|
|
1058
1129
|
/**
|
|
1059
1130
|
* Build initialize instruction
|
|
1060
1131
|
*/
|
|
@@ -1079,6 +1150,10 @@ declare class JBondClient {
|
|
|
1079
1150
|
* Build set authority instruction
|
|
1080
1151
|
*/
|
|
1081
1152
|
buildSetAuthorityInstruction(props: SetAuthorityProps): Promise<_solana_web3_js.TransactionInstruction>;
|
|
1153
|
+
/**
|
|
1154
|
+
* Build set withdraw authority instruction
|
|
1155
|
+
*/
|
|
1156
|
+
buildSetWithdrawAuthorityInstruction(props: SetWithdrawAuthorityProps): Promise<_solana_web3_js.TransactionInstruction>;
|
|
1082
1157
|
/**
|
|
1083
1158
|
* Fetch global state or throw if not found
|
|
1084
1159
|
*/
|
|
@@ -1146,4 +1221,4 @@ declare class JBondClient {
|
|
|
1146
1221
|
*/
|
|
1147
1222
|
declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
|
|
1148
1223
|
|
|
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 };
|
|
1224
|
+
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 SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };
|
package/dist/index.js
CHANGED
|
@@ -294,12 +294,6 @@ var jbond_default = {
|
|
|
294
294
|
{
|
|
295
295
|
name: "initial_collateral",
|
|
296
296
|
type: "u64"
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
name: "withdrawal_authority",
|
|
300
|
-
type: {
|
|
301
|
-
option: "pubkey"
|
|
302
|
-
}
|
|
303
297
|
}
|
|
304
298
|
]
|
|
305
299
|
},
|
|
@@ -364,6 +358,72 @@ var jbond_default = {
|
|
|
364
358
|
],
|
|
365
359
|
args: []
|
|
366
360
|
},
|
|
361
|
+
{
|
|
362
|
+
name: "set_withdraw_authority",
|
|
363
|
+
docs: [
|
|
364
|
+
"Sets a new withdrawal authority for a validator's bond account.",
|
|
365
|
+
"Allows changing who can withdraw collateral in the future.",
|
|
366
|
+
"",
|
|
367
|
+
"# Arguments",
|
|
368
|
+
"* `new_withdraw_authority` - Optional new withdrawal authority key (None to restrict to identity).",
|
|
369
|
+
"",
|
|
370
|
+
"# Errors",
|
|
371
|
+
"Fails if the signer is not authorized to change the withdrawal authority."
|
|
372
|
+
],
|
|
373
|
+
discriminator: [
|
|
374
|
+
199,
|
|
375
|
+
146,
|
|
376
|
+
140,
|
|
377
|
+
67,
|
|
378
|
+
1,
|
|
379
|
+
90,
|
|
380
|
+
8,
|
|
381
|
+
222
|
|
382
|
+
],
|
|
383
|
+
accounts: [
|
|
384
|
+
{
|
|
385
|
+
name: "validator_bond",
|
|
386
|
+
writable: true,
|
|
387
|
+
pda: {
|
|
388
|
+
seeds: [
|
|
389
|
+
{
|
|
390
|
+
kind: "const",
|
|
391
|
+
value: [
|
|
392
|
+
118,
|
|
393
|
+
97,
|
|
394
|
+
108,
|
|
395
|
+
105,
|
|
396
|
+
100,
|
|
397
|
+
97,
|
|
398
|
+
116,
|
|
399
|
+
111,
|
|
400
|
+
114,
|
|
401
|
+
95,
|
|
402
|
+
98,
|
|
403
|
+
111,
|
|
404
|
+
110,
|
|
405
|
+
100
|
|
406
|
+
]
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
kind: "account",
|
|
410
|
+
path: "validator_bond.vote_account",
|
|
411
|
+
account: "ValidatorBond"
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: "identity",
|
|
418
|
+
signer: true
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
name: "new_withdraw_authority",
|
|
422
|
+
optional: true
|
|
423
|
+
}
|
|
424
|
+
],
|
|
425
|
+
args: []
|
|
426
|
+
},
|
|
367
427
|
{
|
|
368
428
|
name: "top_up",
|
|
369
429
|
docs: [
|
|
@@ -636,7 +696,7 @@ var jbond_default = {
|
|
|
636
696
|
{
|
|
637
697
|
code: 6006,
|
|
638
698
|
name: "ValidatorNotActive",
|
|
639
|
-
msg: "Validator
|
|
699
|
+
msg: "Validator bond account is not active"
|
|
640
700
|
},
|
|
641
701
|
{
|
|
642
702
|
code: 6007,
|
|
@@ -1059,6 +1119,16 @@ var JBondClient = class _JBondClient {
|
|
|
1059
1119
|
const ix = await this.buildSetAuthorityInstruction(props);
|
|
1060
1120
|
return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
|
|
1061
1121
|
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Set withdrawal authority for validator bond
|
|
1124
|
+
* Only the validator identity can call this
|
|
1125
|
+
* Default identity is the provider's wallet
|
|
1126
|
+
* @return Transaction signature
|
|
1127
|
+
*/
|
|
1128
|
+
async setWithdrawAuthority(props) {
|
|
1129
|
+
const ix = await this.buildSetWithdrawAuthorityInstruction(props);
|
|
1130
|
+
return await this.provider.sendAndConfirm(new web3_js.Transaction().add(ix));
|
|
1131
|
+
}
|
|
1062
1132
|
/**
|
|
1063
1133
|
* Build initialize instruction
|
|
1064
1134
|
*/
|
|
@@ -1076,12 +1146,12 @@ var JBondClient = class _JBondClient {
|
|
|
1076
1146
|
* Build register validator instruction
|
|
1077
1147
|
*/
|
|
1078
1148
|
async buildRegisterValidatorInstruction(props) {
|
|
1079
|
-
const { identity, voteAccount, initialCollateral
|
|
1149
|
+
const { identity, voteAccount, initialCollateral } = props;
|
|
1080
1150
|
const [globalState] = this.pda.globalState();
|
|
1081
1151
|
const [validatorBond] = this.pda.validatorBond(voteAccount);
|
|
1082
1152
|
const lamports = new anchor.BN(initialCollateral * web3_js.LAMPORTS_PER_SOL);
|
|
1083
1153
|
const creator = props.creator ?? this.provider.wallet.publicKey;
|
|
1084
|
-
return this.program.methods.register(lamports
|
|
1154
|
+
return this.program.methods.register(lamports).accountsPartial({
|
|
1085
1155
|
creator,
|
|
1086
1156
|
globalState,
|
|
1087
1157
|
validatorBond,
|
|
@@ -1153,6 +1223,19 @@ var JBondClient = class _JBondClient {
|
|
|
1153
1223
|
newAuthority: props.newAuthority
|
|
1154
1224
|
}).instruction();
|
|
1155
1225
|
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Build set withdraw authority instruction
|
|
1228
|
+
*/
|
|
1229
|
+
async buildSetWithdrawAuthorityInstruction(props) {
|
|
1230
|
+
const { voteAccount, newWithdrawAuthority } = props;
|
|
1231
|
+
const [validatorBond] = this.pda.validatorBond(voteAccount);
|
|
1232
|
+
const identity = props.identity ?? this.provider.wallet.publicKey;
|
|
1233
|
+
return this.program.methods.setWithdrawAuthority().accountsPartial({
|
|
1234
|
+
validatorBond,
|
|
1235
|
+
identity,
|
|
1236
|
+
newWithdrawAuthority: newWithdrawAuthority ?? null
|
|
1237
|
+
}).instruction();
|
|
1238
|
+
}
|
|
1156
1239
|
/**
|
|
1157
1240
|
* Fetch global state or throw if not found
|
|
1158
1241
|
*/
|