@jpool/bond-sdk 0.1.0-next.3 → 0.1.0-next.4
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 +40 -13
- package/dist/index.d.ts +40 -13
- package/dist/index.js +65 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,6 @@ import { PublicKey, Connection, Keypair, TransactionInstruction } from '@solana/
|
|
|
3
3
|
|
|
4
4
|
type Config = {
|
|
5
5
|
rpcUrl: string;
|
|
6
|
-
programId: PublicKey;
|
|
7
|
-
reserveAddress: PublicKey;
|
|
8
6
|
};
|
|
9
7
|
type ValidatorBondAccount = {
|
|
10
8
|
identity: PublicKey;
|
|
@@ -18,6 +16,7 @@ type ValidatorBondAccount = {
|
|
|
18
16
|
};
|
|
19
17
|
type InitializeProps = {
|
|
20
18
|
authority: PublicKey;
|
|
19
|
+
reserveAddress: PublicKey;
|
|
21
20
|
};
|
|
22
21
|
type RegisterValidatorProps = {
|
|
23
22
|
creator: PublicKey;
|
|
@@ -90,7 +89,7 @@ declare enum BondTransactionType {
|
|
|
90
89
|
* IDL can be found at `target/idl/jbond.json`.
|
|
91
90
|
*/
|
|
92
91
|
type Jbond = {
|
|
93
|
-
address: '
|
|
92
|
+
address: '8vrqsFHnDdjMYMwahytRzmmYgRqCMmka8X6DJUXGQzWr';
|
|
94
93
|
metadata: {
|
|
95
94
|
name: 'jbond';
|
|
96
95
|
version: '0.1.0';
|
|
@@ -321,6 +320,10 @@ type Jbond = {
|
|
|
321
320
|
name: 'destination';
|
|
322
321
|
writable: true;
|
|
323
322
|
},
|
|
323
|
+
{
|
|
324
|
+
name: 'epochSchedule';
|
|
325
|
+
address: 'SysvarEpochSchedu1e111111111111111111111111';
|
|
326
|
+
},
|
|
324
327
|
{
|
|
325
328
|
name: 'systemProgram';
|
|
326
329
|
address: '11111111111111111111111111111111';
|
|
@@ -667,6 +670,11 @@ type Jbond = {
|
|
|
667
670
|
code: 6008;
|
|
668
671
|
name: 'unauthorized';
|
|
669
672
|
msg: 'unauthorized';
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
code: 6009;
|
|
676
|
+
name: 'withdrawalLockedNearEpochEnd';
|
|
677
|
+
msg: 'Withdrawals are locked near the end of the epoch.';
|
|
670
678
|
}
|
|
671
679
|
];
|
|
672
680
|
types: [
|
|
@@ -851,20 +859,37 @@ type Jbond = {
|
|
|
851
859
|
];
|
|
852
860
|
};
|
|
853
861
|
|
|
862
|
+
declare enum BondClientEnv {
|
|
863
|
+
DEV = "dev",
|
|
864
|
+
PROD = "prod"
|
|
865
|
+
}
|
|
854
866
|
declare class JBondClient {
|
|
855
867
|
connection: Connection;
|
|
856
868
|
program: Program<Jbond>;
|
|
857
869
|
provider: AnchorProvider;
|
|
858
870
|
config: Config;
|
|
859
|
-
|
|
871
|
+
readonly options: ClientOptions;
|
|
872
|
+
constructor(config: Config, wallet?: Wallet, options?: ClientOptions);
|
|
860
873
|
/**
|
|
861
874
|
* Creates an instance of `JBondClient` using a provided connection and wallet.
|
|
862
875
|
*/
|
|
863
|
-
static fromWallet(config: Config, wallet?: Wallet): JBondClient;
|
|
876
|
+
static fromWallet(config: Config, wallet?: Wallet, options?: ClientOptions): JBondClient;
|
|
864
877
|
/**
|
|
865
878
|
* Creates an instance of `JBondClient` using the provided connection and keypair.
|
|
866
879
|
*/
|
|
867
|
-
static fromKeypair(config: Config, keypair: Keypair): JBondClient;
|
|
880
|
+
static fromKeypair(config: Config, keypair: Keypair, options?: ClientOptions): JBondClient;
|
|
881
|
+
/**
|
|
882
|
+
* Get the current program ID.
|
|
883
|
+
*/
|
|
884
|
+
get programId(): PublicKey;
|
|
885
|
+
/**
|
|
886
|
+
* Set the environment.
|
|
887
|
+
*/
|
|
888
|
+
env(env: BondClientEnv): this;
|
|
889
|
+
/**
|
|
890
|
+
* Configure a specific option.
|
|
891
|
+
*/
|
|
892
|
+
configure<K extends keyof ClientOptions>(key: K, val: ClientOptions[K]): this;
|
|
868
893
|
getGlobalStatePDA(): [PublicKey, number];
|
|
869
894
|
getValidatorBondPDA(voteAccount: PublicKey): [PublicKey, number];
|
|
870
895
|
buildInitializeInstruction(props: InitializeProps): Promise<TransactionInstruction>;
|
|
@@ -891,9 +916,10 @@ declare class JBondClient {
|
|
|
891
916
|
authority: string;
|
|
892
917
|
totalValidators: number;
|
|
893
918
|
totalWithdrawn: number;
|
|
919
|
+
reserveAddress: string;
|
|
894
920
|
} | null>;
|
|
895
921
|
getCurrentEpoch(): Promise<number>;
|
|
896
|
-
initialize(authority?: PublicKey): Promise<string>;
|
|
922
|
+
initialize(reserveAddress: PublicKey, authority?: PublicKey): Promise<string>;
|
|
897
923
|
registerValidator(voteAccount: PublicKey, initialCollateral: number, withdrawalAuthority?: PublicKey, identity?: PublicKey): Promise<string>;
|
|
898
924
|
topUpCollateral(voteAccount: PublicKey, amount: number, validator?: PublicKey): Promise<string>;
|
|
899
925
|
withdrawCollateral(voteAccount: PublicKey, destination: PublicKey, amount: number, withdrawalAuthority?: PublicKey): Promise<string>;
|
|
@@ -914,11 +940,12 @@ declare class JBondClient {
|
|
|
914
940
|
getFullHistory(voteAccount: PublicKey, pageSize?: number): Promise<TransactionHistoryItem[]>;
|
|
915
941
|
private getInstructionDiscriminator;
|
|
916
942
|
}
|
|
943
|
+
type ClientOptions = {
|
|
944
|
+
programId?: PublicKey;
|
|
945
|
+
debug?: boolean;
|
|
946
|
+
} & Record<string, any>;
|
|
917
947
|
|
|
918
|
-
declare const PROGRAM_ID
|
|
919
|
-
declare const
|
|
920
|
-
|
|
921
|
-
declare function loadConfig(): Config;
|
|
922
|
-
declare function loadKeypair(keypairPath: string): Keypair;
|
|
948
|
+
declare const PROGRAM_ID: PublicKey;
|
|
949
|
+
declare const DEV_PROGRAM_ID: PublicKey;
|
|
923
950
|
|
|
924
|
-
export { BondTransactionType, type Config, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, PROGRAM_ID,
|
|
951
|
+
export { BondClientEnv, BondTransactionType, type ClientOptions, type Config, DEV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, PROGRAM_ID, type RegisterValidatorProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBondAccount, type WithdrawCollateralProps, type WithdrawCompensationProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import { PublicKey, Connection, Keypair, TransactionInstruction } from '@solana/
|
|
|
3
3
|
|
|
4
4
|
type Config = {
|
|
5
5
|
rpcUrl: string;
|
|
6
|
-
programId: PublicKey;
|
|
7
|
-
reserveAddress: PublicKey;
|
|
8
6
|
};
|
|
9
7
|
type ValidatorBondAccount = {
|
|
10
8
|
identity: PublicKey;
|
|
@@ -18,6 +16,7 @@ type ValidatorBondAccount = {
|
|
|
18
16
|
};
|
|
19
17
|
type InitializeProps = {
|
|
20
18
|
authority: PublicKey;
|
|
19
|
+
reserveAddress: PublicKey;
|
|
21
20
|
};
|
|
22
21
|
type RegisterValidatorProps = {
|
|
23
22
|
creator: PublicKey;
|
|
@@ -90,7 +89,7 @@ declare enum BondTransactionType {
|
|
|
90
89
|
* IDL can be found at `target/idl/jbond.json`.
|
|
91
90
|
*/
|
|
92
91
|
type Jbond = {
|
|
93
|
-
address: '
|
|
92
|
+
address: '8vrqsFHnDdjMYMwahytRzmmYgRqCMmka8X6DJUXGQzWr';
|
|
94
93
|
metadata: {
|
|
95
94
|
name: 'jbond';
|
|
96
95
|
version: '0.1.0';
|
|
@@ -321,6 +320,10 @@ type Jbond = {
|
|
|
321
320
|
name: 'destination';
|
|
322
321
|
writable: true;
|
|
323
322
|
},
|
|
323
|
+
{
|
|
324
|
+
name: 'epochSchedule';
|
|
325
|
+
address: 'SysvarEpochSchedu1e111111111111111111111111';
|
|
326
|
+
},
|
|
324
327
|
{
|
|
325
328
|
name: 'systemProgram';
|
|
326
329
|
address: '11111111111111111111111111111111';
|
|
@@ -667,6 +670,11 @@ type Jbond = {
|
|
|
667
670
|
code: 6008;
|
|
668
671
|
name: 'unauthorized';
|
|
669
672
|
msg: 'unauthorized';
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
code: 6009;
|
|
676
|
+
name: 'withdrawalLockedNearEpochEnd';
|
|
677
|
+
msg: 'Withdrawals are locked near the end of the epoch.';
|
|
670
678
|
}
|
|
671
679
|
];
|
|
672
680
|
types: [
|
|
@@ -851,20 +859,37 @@ type Jbond = {
|
|
|
851
859
|
];
|
|
852
860
|
};
|
|
853
861
|
|
|
862
|
+
declare enum BondClientEnv {
|
|
863
|
+
DEV = "dev",
|
|
864
|
+
PROD = "prod"
|
|
865
|
+
}
|
|
854
866
|
declare class JBondClient {
|
|
855
867
|
connection: Connection;
|
|
856
868
|
program: Program<Jbond>;
|
|
857
869
|
provider: AnchorProvider;
|
|
858
870
|
config: Config;
|
|
859
|
-
|
|
871
|
+
readonly options: ClientOptions;
|
|
872
|
+
constructor(config: Config, wallet?: Wallet, options?: ClientOptions);
|
|
860
873
|
/**
|
|
861
874
|
* Creates an instance of `JBondClient` using a provided connection and wallet.
|
|
862
875
|
*/
|
|
863
|
-
static fromWallet(config: Config, wallet?: Wallet): JBondClient;
|
|
876
|
+
static fromWallet(config: Config, wallet?: Wallet, options?: ClientOptions): JBondClient;
|
|
864
877
|
/**
|
|
865
878
|
* Creates an instance of `JBondClient` using the provided connection and keypair.
|
|
866
879
|
*/
|
|
867
|
-
static fromKeypair(config: Config, keypair: Keypair): JBondClient;
|
|
880
|
+
static fromKeypair(config: Config, keypair: Keypair, options?: ClientOptions): JBondClient;
|
|
881
|
+
/**
|
|
882
|
+
* Get the current program ID.
|
|
883
|
+
*/
|
|
884
|
+
get programId(): PublicKey;
|
|
885
|
+
/**
|
|
886
|
+
* Set the environment.
|
|
887
|
+
*/
|
|
888
|
+
env(env: BondClientEnv): this;
|
|
889
|
+
/**
|
|
890
|
+
* Configure a specific option.
|
|
891
|
+
*/
|
|
892
|
+
configure<K extends keyof ClientOptions>(key: K, val: ClientOptions[K]): this;
|
|
868
893
|
getGlobalStatePDA(): [PublicKey, number];
|
|
869
894
|
getValidatorBondPDA(voteAccount: PublicKey): [PublicKey, number];
|
|
870
895
|
buildInitializeInstruction(props: InitializeProps): Promise<TransactionInstruction>;
|
|
@@ -891,9 +916,10 @@ declare class JBondClient {
|
|
|
891
916
|
authority: string;
|
|
892
917
|
totalValidators: number;
|
|
893
918
|
totalWithdrawn: number;
|
|
919
|
+
reserveAddress: string;
|
|
894
920
|
} | null>;
|
|
895
921
|
getCurrentEpoch(): Promise<number>;
|
|
896
|
-
initialize(authority?: PublicKey): Promise<string>;
|
|
922
|
+
initialize(reserveAddress: PublicKey, authority?: PublicKey): Promise<string>;
|
|
897
923
|
registerValidator(voteAccount: PublicKey, initialCollateral: number, withdrawalAuthority?: PublicKey, identity?: PublicKey): Promise<string>;
|
|
898
924
|
topUpCollateral(voteAccount: PublicKey, amount: number, validator?: PublicKey): Promise<string>;
|
|
899
925
|
withdrawCollateral(voteAccount: PublicKey, destination: PublicKey, amount: number, withdrawalAuthority?: PublicKey): Promise<string>;
|
|
@@ -914,11 +940,12 @@ declare class JBondClient {
|
|
|
914
940
|
getFullHistory(voteAccount: PublicKey, pageSize?: number): Promise<TransactionHistoryItem[]>;
|
|
915
941
|
private getInstructionDiscriminator;
|
|
916
942
|
}
|
|
943
|
+
type ClientOptions = {
|
|
944
|
+
programId?: PublicKey;
|
|
945
|
+
debug?: boolean;
|
|
946
|
+
} & Record<string, any>;
|
|
917
947
|
|
|
918
|
-
declare const PROGRAM_ID
|
|
919
|
-
declare const
|
|
920
|
-
|
|
921
|
-
declare function loadConfig(): Config;
|
|
922
|
-
declare function loadKeypair(keypairPath: string): Keypair;
|
|
948
|
+
declare const PROGRAM_ID: PublicKey;
|
|
949
|
+
declare const DEV_PROGRAM_ID: PublicKey;
|
|
923
950
|
|
|
924
|
-
export { BondTransactionType, type Config, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, PROGRAM_ID,
|
|
951
|
+
export { BondClientEnv, BondTransactionType, type ClientOptions, type Config, DEV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, PROGRAM_ID, type RegisterValidatorProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBondAccount, type WithdrawCollateralProps, type WithdrawCompensationProps };
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
var anchor = require('@coral-xyz/anchor');
|
|
4
4
|
var web3_js = require('@solana/web3.js');
|
|
5
5
|
var bs58 = require('bs58');
|
|
6
|
-
var fs = require('fs');
|
|
7
6
|
|
|
8
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
8
|
|
|
10
9
|
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
11
10
|
|
|
12
11
|
// src/client.ts
|
|
12
|
+
var PROGRAM_ID = new web3_js.PublicKey("8vrqsFHnDdjMYMwahytRzmmYgRqCMmka8X6DJUXGQzWr");
|
|
13
|
+
var DEV_PROGRAM_ID = new web3_js.PublicKey("8vrqsFHnDdjMYMwahytRzmmYgRqCMmka8X6DJUXGQzWr");
|
|
13
14
|
|
|
14
15
|
// src/helpers.ts
|
|
15
16
|
var SLOTS_PER_EPOCH_MAINNET = 432e3;
|
|
@@ -21,7 +22,7 @@ function slotToEpoch(slot, cluster) {
|
|
|
21
22
|
|
|
22
23
|
// src/idl/jbond.json
|
|
23
24
|
var jbond_default = {
|
|
24
|
-
address: "
|
|
25
|
+
address: "8vrqsFHnDdjMYMwahytRzmmYgRqCMmka8X6DJUXGQzWr",
|
|
25
26
|
metadata: {
|
|
26
27
|
name: "jbond",
|
|
27
28
|
version: "0.1.0",
|
|
@@ -252,6 +253,10 @@ var jbond_default = {
|
|
|
252
253
|
name: "destination",
|
|
253
254
|
writable: true
|
|
254
255
|
},
|
|
256
|
+
{
|
|
257
|
+
name: "epoch_schedule",
|
|
258
|
+
address: "SysvarEpochSchedu1e111111111111111111111111"
|
|
259
|
+
},
|
|
255
260
|
{
|
|
256
261
|
name: "system_program",
|
|
257
262
|
address: "11111111111111111111111111111111"
|
|
@@ -598,6 +603,11 @@ var jbond_default = {
|
|
|
598
603
|
code: 6008,
|
|
599
604
|
name: "Unauthorized",
|
|
600
605
|
msg: "Unauthorized"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
code: 6009,
|
|
609
|
+
name: "WithdrawalLockedNearEpochEnd",
|
|
610
|
+
msg: "Withdrawals are locked near the end of the epoch."
|
|
601
611
|
}
|
|
602
612
|
],
|
|
603
613
|
types: [
|
|
@@ -822,14 +832,21 @@ var NodeWallet = class {
|
|
|
822
832
|
};
|
|
823
833
|
|
|
824
834
|
// src/client.ts
|
|
835
|
+
var BondClientEnv = /* @__PURE__ */ ((BondClientEnv2) => {
|
|
836
|
+
BondClientEnv2["DEV"] = "dev";
|
|
837
|
+
BondClientEnv2["PROD"] = "prod";
|
|
838
|
+
return BondClientEnv2;
|
|
839
|
+
})(BondClientEnv || {});
|
|
825
840
|
var JBondClient = class _JBondClient {
|
|
826
841
|
connection;
|
|
827
842
|
program;
|
|
828
843
|
provider;
|
|
829
844
|
config;
|
|
830
|
-
|
|
845
|
+
options;
|
|
846
|
+
constructor(config, wallet, options) {
|
|
831
847
|
this.config = config;
|
|
832
848
|
this.connection = new web3_js.Connection(config.rpcUrl, "confirmed");
|
|
849
|
+
this.options = options ?? {};
|
|
833
850
|
this.provider = new anchor.AnchorProvider(
|
|
834
851
|
this.connection,
|
|
835
852
|
// @ts-expect-error support anonymous
|
|
@@ -841,20 +858,42 @@ var JBondClient = class _JBondClient {
|
|
|
841
858
|
/**
|
|
842
859
|
* Creates an instance of `JBondClient` using a provided connection and wallet.
|
|
843
860
|
*/
|
|
844
|
-
static fromWallet(config, wallet) {
|
|
845
|
-
return new this(config, wallet);
|
|
861
|
+
static fromWallet(config, wallet, options) {
|
|
862
|
+
return new this(config, wallet, options);
|
|
846
863
|
}
|
|
847
864
|
/**
|
|
848
865
|
* Creates an instance of `JBondClient` using the provided connection and keypair.
|
|
849
866
|
*/
|
|
850
|
-
static fromKeypair(config, keypair) {
|
|
851
|
-
return _JBondClient.fromWallet(config, new NodeWallet(keypair));
|
|
867
|
+
static fromKeypair(config, keypair, options) {
|
|
868
|
+
return _JBondClient.fromWallet(config, new NodeWallet(keypair), options);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Get the current program ID.
|
|
872
|
+
*/
|
|
873
|
+
get programId() {
|
|
874
|
+
return this.options.programId ?? PROGRAM_ID;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Set the environment.
|
|
878
|
+
*/
|
|
879
|
+
env(env) {
|
|
880
|
+
if (env === "prod" /* PROD */) {
|
|
881
|
+
return this.configure("programId", PROGRAM_ID);
|
|
882
|
+
}
|
|
883
|
+
return this.configure("programId", DEV_PROGRAM_ID);
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Configure a specific option.
|
|
887
|
+
*/
|
|
888
|
+
configure(key, val) {
|
|
889
|
+
this.options[key] = val;
|
|
890
|
+
return this;
|
|
852
891
|
}
|
|
853
892
|
// Get PDA for global state
|
|
854
893
|
getGlobalStatePDA() {
|
|
855
894
|
return web3_js.PublicKey.findProgramAddressSync(
|
|
856
895
|
[Buffer.from("global_state")],
|
|
857
|
-
this.program.programId
|
|
896
|
+
this.options.programId ?? this.program.programId
|
|
858
897
|
);
|
|
859
898
|
}
|
|
860
899
|
// Get PDA for validator bond account
|
|
@@ -864,16 +903,17 @@ var JBondClient = class _JBondClient {
|
|
|
864
903
|
Buffer.from("validator_bond"),
|
|
865
904
|
voteAccount.toBuffer()
|
|
866
905
|
],
|
|
867
|
-
this.program.programId
|
|
906
|
+
this.options.programId ?? this.program.programId
|
|
868
907
|
);
|
|
869
908
|
}
|
|
870
909
|
// Build initialize instruction
|
|
871
910
|
async buildInitializeInstruction(props) {
|
|
872
911
|
const [globalState] = this.getGlobalStatePDA();
|
|
912
|
+
const { authority, reserveAddress } = props;
|
|
873
913
|
return this.program.methods.initialize().accountsStrict({
|
|
874
914
|
globalState,
|
|
875
|
-
authority
|
|
876
|
-
reserve:
|
|
915
|
+
authority,
|
|
916
|
+
reserve: reserveAddress,
|
|
877
917
|
systemProgram: web3_js.SystemProgram.programId
|
|
878
918
|
}).instruction();
|
|
879
919
|
}
|
|
@@ -915,19 +955,24 @@ var JBondClient = class _JBondClient {
|
|
|
915
955
|
validatorBondAccount: validatorBondAccountAddress,
|
|
916
956
|
withdrawalAuthority: user,
|
|
917
957
|
destination,
|
|
958
|
+
epochSchedule: web3_js.SYSVAR_EPOCH_SCHEDULE_PUBKEY,
|
|
918
959
|
systemProgram: web3_js.SystemProgram.programId
|
|
919
960
|
}).instruction();
|
|
920
961
|
}
|
|
921
962
|
// Build withdraw compensation instruction
|
|
922
|
-
buildWithdrawCompensationInstruction(props) {
|
|
963
|
+
async buildWithdrawCompensationInstruction(props) {
|
|
923
964
|
const { authority, voteAccount, amount } = props;
|
|
924
965
|
const [globalState] = this.getGlobalStatePDA();
|
|
925
966
|
const [validatorBondAccountAddress] = this.getValidatorBondPDA(voteAccount);
|
|
926
967
|
const amountLamports = new anchor.BN(amount * web3_js.LAMPORTS_PER_SOL);
|
|
968
|
+
const reserveAddress = (await this.getGlobalState())?.reserveAddress;
|
|
969
|
+
if (!reserveAddress) {
|
|
970
|
+
throw new Error("Reserve address is not set in the global state. The program might not be initialized yet.");
|
|
971
|
+
}
|
|
927
972
|
return this.program.methods.withdrawCompensation(amountLamports).accountsStrict({
|
|
928
973
|
globalState,
|
|
929
974
|
validatorBondAccount: validatorBondAccountAddress,
|
|
930
|
-
reserve:
|
|
975
|
+
reserve: reserveAddress,
|
|
931
976
|
authority,
|
|
932
977
|
systemProgram: web3_js.SystemProgram.programId
|
|
933
978
|
}).instruction();
|
|
@@ -994,7 +1039,8 @@ var JBondClient = class _JBondClient {
|
|
|
994
1039
|
return {
|
|
995
1040
|
authority: account.authority.toString(),
|
|
996
1041
|
totalValidators: account.totalValidators,
|
|
997
|
-
totalWithdrawn: account.totalWithdrawn.toNumber() / web3_js.LAMPORTS_PER_SOL
|
|
1042
|
+
totalWithdrawn: account.totalWithdrawn.toNumber() / web3_js.LAMPORTS_PER_SOL,
|
|
1043
|
+
reserveAddress: account.reserve.toString()
|
|
998
1044
|
};
|
|
999
1045
|
} catch {
|
|
1000
1046
|
return null;
|
|
@@ -1006,9 +1052,9 @@ var JBondClient = class _JBondClient {
|
|
|
1006
1052
|
return epochInfo.epoch;
|
|
1007
1053
|
}
|
|
1008
1054
|
// Helper methods for backward compatibility (can be removed if not needed)
|
|
1009
|
-
async initialize(authority) {
|
|
1055
|
+
async initialize(reserveAddress, authority) {
|
|
1010
1056
|
const authorityPubkey = authority || this.provider.wallet.publicKey;
|
|
1011
|
-
const ix = await this.buildInitializeInstruction({ authority: authorityPubkey });
|
|
1057
|
+
const ix = await this.buildInitializeInstruction({ authority: authorityPubkey, reserveAddress });
|
|
1012
1058
|
const tx = await this.provider.sendAndConfirm(
|
|
1013
1059
|
new web3_js.Transaction().add(ix),
|
|
1014
1060
|
[]
|
|
@@ -1133,7 +1179,7 @@ var JBondClient = class _JBondClient {
|
|
|
1133
1179
|
const slot = tx.slot || 0;
|
|
1134
1180
|
const instructions = tx.transaction.message.instructions;
|
|
1135
1181
|
for (const instruction of instructions) {
|
|
1136
|
-
if ("programId" in instruction && instruction.programId.equals(this.program.programId)) {
|
|
1182
|
+
if ("programId" in instruction && instruction.programId.equals(this.options.programId ?? this.program.programId)) {
|
|
1137
1183
|
const ixData = instruction;
|
|
1138
1184
|
if ("parsed" in ixData && ixData.parsed) {
|
|
1139
1185
|
continue;
|
|
@@ -1228,38 +1274,10 @@ var JBondClient = class _JBondClient {
|
|
|
1228
1274
|
}
|
|
1229
1275
|
};
|
|
1230
1276
|
|
|
1231
|
-
|
|
1232
|
-
var PROGRAM_ID = "4a3YovKEfm4jWhczCzJciHXL1xVkXWfGQjRCaMft7M4G";
|
|
1233
|
-
var RESERVE_ADDRESS = "61mS9nEir6jx6cvte6NzQpyrFk3Fj4krMNLuHhi4tjJz";
|
|
1234
|
-
function loadConfig() {
|
|
1235
|
-
const rpcUrl = process.env.SOLANA_RPC_URL || "https://api.devnet.solana.com";
|
|
1236
|
-
const programId = new web3_js.PublicKey(
|
|
1237
|
-
PROGRAM_ID
|
|
1238
|
-
);
|
|
1239
|
-
const reserveAddress = new web3_js.PublicKey(
|
|
1240
|
-
RESERVE_ADDRESS
|
|
1241
|
-
);
|
|
1242
|
-
return {
|
|
1243
|
-
rpcUrl,
|
|
1244
|
-
programId,
|
|
1245
|
-
reserveAddress
|
|
1246
|
-
};
|
|
1247
|
-
}
|
|
1248
|
-
function loadKeypair(keypairPath) {
|
|
1249
|
-
try {
|
|
1250
|
-
const keypairString = fs.readFileSync(keypairPath, "utf8");
|
|
1251
|
-
const keypairData = JSON.parse(keypairString);
|
|
1252
|
-
return web3_js.Keypair.fromSecretKey(new Uint8Array(keypairData));
|
|
1253
|
-
} catch (error) {
|
|
1254
|
-
throw new Error(`Failed to load keypair from ${keypairPath}: ${error}`);
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1277
|
+
exports.BondClientEnv = BondClientEnv;
|
|
1258
1278
|
exports.BondTransactionType = BondTransactionType;
|
|
1279
|
+
exports.DEV_PROGRAM_ID = DEV_PROGRAM_ID;
|
|
1259
1280
|
exports.JBondClient = JBondClient;
|
|
1260
1281
|
exports.PROGRAM_ID = PROGRAM_ID;
|
|
1261
|
-
exports.RESERVE_ADDRESS = RESERVE_ADDRESS;
|
|
1262
|
-
exports.loadConfig = loadConfig;
|
|
1263
|
-
exports.loadKeypair = loadKeypair;
|
|
1264
1282
|
//# sourceMappingURL=index.js.map
|
|
1265
1283
|
//# sourceMappingURL=index.js.map
|