@jpool/bond-sdk 0.9.0-next.17 → 0.9.0-next.18
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 +751 -754
- package/dist/index.d.ts +751 -754
- package/dist/index.js +37 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -95
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4600,6 +4600,10 @@ var BondTypeVariant = {
|
|
|
4600
4600
|
Performance: { performance: {} },
|
|
4601
4601
|
Crowdfunding: { crowdfunding: {} }
|
|
4602
4602
|
};
|
|
4603
|
+
var BondStateStatusVariant = {
|
|
4604
|
+
Active: { active: {} },
|
|
4605
|
+
Disabled: { disabled: {} }
|
|
4606
|
+
};
|
|
4603
4607
|
var BondTransactionType = /* @__PURE__ */ ((BondTransactionType2) => {
|
|
4604
4608
|
BondTransactionType2["Deposit"] = "deposit";
|
|
4605
4609
|
BondTransactionType2["Withdrawal"] = "withdrawal";
|
|
@@ -4994,68 +4998,6 @@ var jbond_default = {
|
|
|
4994
4998
|
}
|
|
4995
4999
|
]
|
|
4996
5000
|
},
|
|
4997
|
-
{
|
|
4998
|
-
name: "bond_disable",
|
|
4999
|
-
docs: [
|
|
5000
|
-
"Disables a validator's bond, preventing it from participating further."
|
|
5001
|
-
],
|
|
5002
|
-
discriminator: [
|
|
5003
|
-
159,
|
|
5004
|
-
156,
|
|
5005
|
-
97,
|
|
5006
|
-
253,
|
|
5007
|
-
70,
|
|
5008
|
-
122,
|
|
5009
|
-
117,
|
|
5010
|
-
129
|
|
5011
|
-
],
|
|
5012
|
-
accounts: [
|
|
5013
|
-
{
|
|
5014
|
-
name: "bond_state",
|
|
5015
|
-
writable: true
|
|
5016
|
-
},
|
|
5017
|
-
{
|
|
5018
|
-
name: "authority",
|
|
5019
|
-
writable: true,
|
|
5020
|
-
signer: true,
|
|
5021
|
-
relations: [
|
|
5022
|
-
"bond_state"
|
|
5023
|
-
]
|
|
5024
|
-
}
|
|
5025
|
-
],
|
|
5026
|
-
args: []
|
|
5027
|
-
},
|
|
5028
|
-
{
|
|
5029
|
-
name: "bond_enable",
|
|
5030
|
-
docs: [
|
|
5031
|
-
"Enables a previously disabled validator's bond."
|
|
5032
|
-
],
|
|
5033
|
-
discriminator: [
|
|
5034
|
-
133,
|
|
5035
|
-
48,
|
|
5036
|
-
84,
|
|
5037
|
-
9,
|
|
5038
|
-
117,
|
|
5039
|
-
131,
|
|
5040
|
-
164,
|
|
5041
|
-
128
|
|
5042
|
-
],
|
|
5043
|
-
accounts: [
|
|
5044
|
-
{
|
|
5045
|
-
name: "bond_state",
|
|
5046
|
-
writable: true
|
|
5047
|
-
},
|
|
5048
|
-
{
|
|
5049
|
-
name: "authority",
|
|
5050
|
-
writable: true,
|
|
5051
|
-
signer: true,
|
|
5052
|
-
relations: [
|
|
5053
|
-
"bond_state"
|
|
5054
|
-
]
|
|
5055
|
-
}
|
|
5056
|
-
],
|
|
5057
|
-
args: []
|
|
5058
|
-
},
|
|
5059
5001
|
{
|
|
5060
5002
|
name: "bond_initialize",
|
|
5061
5003
|
docs: [
|
|
@@ -5983,6 +5925,16 @@ var jbond_default = {
|
|
|
5983
5925
|
type: {
|
|
5984
5926
|
kind: "struct",
|
|
5985
5927
|
fields: [
|
|
5928
|
+
{
|
|
5929
|
+
name: "status",
|
|
5930
|
+
type: {
|
|
5931
|
+
option: {
|
|
5932
|
+
defined: {
|
|
5933
|
+
name: "BondStatus"
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
},
|
|
5986
5938
|
{
|
|
5987
5939
|
name: "new_reserve",
|
|
5988
5940
|
type: {
|
|
@@ -6155,6 +6107,9 @@ var jbond_default = {
|
|
|
6155
6107
|
},
|
|
6156
6108
|
{
|
|
6157
6109
|
name: "status",
|
|
6110
|
+
docs: [
|
|
6111
|
+
"Current status of the bond"
|
|
6112
|
+
],
|
|
6158
6113
|
type: {
|
|
6159
6114
|
defined: {
|
|
6160
6115
|
name: "BondStatus"
|
|
@@ -6640,14 +6595,6 @@ var JBondClient = class _JBondClient {
|
|
|
6640
6595
|
const ix = await this.buildBondFinishIx(props);
|
|
6641
6596
|
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
6642
6597
|
}
|
|
6643
|
-
async bondEnable(props) {
|
|
6644
|
-
const ix = await this.buildBondEnableIx(props);
|
|
6645
|
-
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
6646
|
-
}
|
|
6647
|
-
async bondDisable(props) {
|
|
6648
|
-
const ix = await this.buildBondDisableIx(props);
|
|
6649
|
-
return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
|
|
6650
|
-
}
|
|
6651
6598
|
async buildBondGlobalStateInitializeIx(props) {
|
|
6652
6599
|
const [globalState] = this.pda.globalState();
|
|
6653
6600
|
const authority = props.authority ?? this.provider.wallet?.publicKey;
|
|
@@ -6705,6 +6652,7 @@ var JBondClient = class _JBondClient {
|
|
|
6705
6652
|
async buildConfigureIx(props) {
|
|
6706
6653
|
const [bondState] = this.pda.bondState(props.bondType, props.name);
|
|
6707
6654
|
return this.program.methods.bondConfigure({
|
|
6655
|
+
status: props.bondStateStatus ?? null,
|
|
6708
6656
|
newReserve: props.newReserve ?? null,
|
|
6709
6657
|
newAuthority: props.newAuthority ?? null
|
|
6710
6658
|
}).accountsStrict({
|
|
@@ -6720,7 +6668,7 @@ var JBondClient = class _JBondClient {
|
|
|
6720
6668
|
if (!creator) {
|
|
6721
6669
|
throw new Error("Missing creator");
|
|
6722
6670
|
}
|
|
6723
|
-
const collateralType = (await this.getBondState(bondType, name))
|
|
6671
|
+
const collateralType = (await this.getBondState(bondType, name)).bond_state.collateralType;
|
|
6724
6672
|
const accounts = {
|
|
6725
6673
|
bondState,
|
|
6726
6674
|
validatorBond,
|
|
@@ -6763,7 +6711,7 @@ var JBondClient = class _JBondClient {
|
|
|
6763
6711
|
creator: props.payer
|
|
6764
6712
|
}));
|
|
6765
6713
|
}
|
|
6766
|
-
const collateralType = (await this.getBondState(bondType, name))
|
|
6714
|
+
const collateralType = (await this.getBondState(bondType, name)).bond_state.collateralType;
|
|
6767
6715
|
const accounts = {
|
|
6768
6716
|
bondState,
|
|
6769
6717
|
validatorBond,
|
|
@@ -6800,7 +6748,7 @@ var JBondClient = class _JBondClient {
|
|
|
6800
6748
|
if (!payer || !destination) {
|
|
6801
6749
|
throw new Error("Missing payer/destination");
|
|
6802
6750
|
}
|
|
6803
|
-
const collateralType = (await this.getBondState(bondType, name))
|
|
6751
|
+
const collateralType = (await this.getBondState(bondType, name)).bond_state.collateralType;
|
|
6804
6752
|
const accounts = {
|
|
6805
6753
|
bondState,
|
|
6806
6754
|
validatorBond,
|
|
@@ -6828,12 +6776,12 @@ var JBondClient = class _JBondClient {
|
|
|
6828
6776
|
const { bondType, name } = props;
|
|
6829
6777
|
const [bondState] = this.pda.bondState(bondType, name);
|
|
6830
6778
|
const [validatorBond] = this.pda.validatorBond(bondType, name, props.voteAccount);
|
|
6831
|
-
const reserve = props.reserve ?? (await this.getBondState(bondType, name))
|
|
6779
|
+
const reserve = props.reserve ?? (await this.getBondState(bondType, name)).bond_state.reserve;
|
|
6832
6780
|
const authority = props.authority ?? this.program.provider.wallet?.publicKey;
|
|
6833
6781
|
if (!reserve) {
|
|
6834
6782
|
throw new Error("Reserve not set");
|
|
6835
6783
|
}
|
|
6836
|
-
const collateralType = (await this.getBondState(bondType, name))
|
|
6784
|
+
const collateralType = (await this.getBondState(bondType, name)).bond_state.collateralType;
|
|
6837
6785
|
const accounts = {
|
|
6838
6786
|
bondState,
|
|
6839
6787
|
validatorBond,
|
|
@@ -6882,20 +6830,6 @@ var JBondClient = class _JBondClient {
|
|
|
6882
6830
|
authority: this.program.provider.wallet?.publicKey
|
|
6883
6831
|
}).instruction();
|
|
6884
6832
|
}
|
|
6885
|
-
async buildBondEnableIx(props) {
|
|
6886
|
-
const [bondState] = this.pda.bondState(props.bondType, props.name);
|
|
6887
|
-
return this.program.methods.bondEnable().accountsPartial({
|
|
6888
|
-
bondState,
|
|
6889
|
-
authority: this.program.provider.wallet?.publicKey
|
|
6890
|
-
}).instruction();
|
|
6891
|
-
}
|
|
6892
|
-
async buildBondDisableIx(props) {
|
|
6893
|
-
const [bondState] = this.pda.bondState(props.bondType, props.name);
|
|
6894
|
-
return this.program.methods.bondDisable().accountsPartial({
|
|
6895
|
-
bondState,
|
|
6896
|
-
authority: this.program.provider.wallet?.publicKey
|
|
6897
|
-
}).instruction();
|
|
6898
|
-
}
|
|
6899
6833
|
/**
|
|
6900
6834
|
* Fetch global state or throw if not found
|
|
6901
6835
|
*/
|
|
@@ -6911,7 +6845,10 @@ var JBondClient = class _JBondClient {
|
|
|
6911
6845
|
*/
|
|
6912
6846
|
async getBondState(bondType, bondName, withStats = false) {
|
|
6913
6847
|
const bondState = await this.program.account.bondState.fetch(this.pda.bondState(bondType, bondName)[0]);
|
|
6914
|
-
return
|
|
6848
|
+
return {
|
|
6849
|
+
bond_state: bondState,
|
|
6850
|
+
state_stats: withStats ? await this.getBondStateStats(bondState) : null
|
|
6851
|
+
};
|
|
6915
6852
|
}
|
|
6916
6853
|
/**
|
|
6917
6854
|
* Get all bond states with total collected collateral
|
|
@@ -6927,7 +6864,12 @@ var JBondClient = class _JBondClient {
|
|
|
6927
6864
|
continue;
|
|
6928
6865
|
}
|
|
6929
6866
|
const bondStateStats = await this.getBondStateStats(state);
|
|
6930
|
-
bondStates.push(
|
|
6867
|
+
bondStates.push(
|
|
6868
|
+
{
|
|
6869
|
+
bond_state: state,
|
|
6870
|
+
state_stats: bondStateStats
|
|
6871
|
+
}
|
|
6872
|
+
);
|
|
6931
6873
|
}
|
|
6932
6874
|
return bondStates;
|
|
6933
6875
|
}
|
|
@@ -6977,7 +6919,7 @@ var JBondClient = class _JBondClient {
|
|
|
6977
6919
|
*/
|
|
6978
6920
|
async getBondCollateralType(bondType, bondName) {
|
|
6979
6921
|
const bondState = await this.getBondState(bondType, bondName);
|
|
6980
|
-
return bondState
|
|
6922
|
+
return bondState.bond_state.collateralType;
|
|
6981
6923
|
}
|
|
6982
6924
|
/**
|
|
6983
6925
|
* Get validator bond account balance (in SOL)
|
|
@@ -6989,7 +6931,7 @@ var JBondClient = class _JBondClient {
|
|
|
6989
6931
|
async getValidatorBondBalance(bondType, bondName, vote) {
|
|
6990
6932
|
const [address] = this.pda.validatorBond(bondType, bondName, new web3_js.PublicKey(vote));
|
|
6991
6933
|
const bondStateData = await this.getBondState(bondType, bondName);
|
|
6992
|
-
const bondStateCollateralType = bondStateData
|
|
6934
|
+
const bondStateCollateralType = bondStateData.bond_state.collateralType;
|
|
6993
6935
|
return await matchVariant(bondStateCollateralType, {
|
|
6994
6936
|
native: async () => {
|
|
6995
6937
|
const accountInfo = await this.connection.getAccountInfo(address).catch(() => null);
|
|
@@ -7016,7 +6958,7 @@ var JBondClient = class _JBondClient {
|
|
|
7016
6958
|
*/
|
|
7017
6959
|
async getBondStateTotalCollected(bondType, bondName, votes) {
|
|
7018
6960
|
const bondStateData = await this.getBondState(bondType, bondName);
|
|
7019
|
-
const bondStateCollateralType = bondStateData
|
|
6961
|
+
const bondStateCollateralType = bondStateData.bond_state.collateralType;
|
|
7020
6962
|
const chunk = (arr, n = 100) => {
|
|
7021
6963
|
const res = [];
|
|
7022
6964
|
for (let i = 0; i < arr.length; i += n) {
|
|
@@ -7137,6 +7079,7 @@ buffer/index.js:
|
|
|
7137
7079
|
*/
|
|
7138
7080
|
|
|
7139
7081
|
exports.BondClientEnv = BondClientEnv;
|
|
7082
|
+
exports.BondStateStatusVariant = BondStateStatusVariant;
|
|
7140
7083
|
exports.BondTransactionType = BondTransactionType;
|
|
7141
7084
|
exports.BondTypeVariant = BondTypeVariant;
|
|
7142
7085
|
exports.ENV_PROGRAM_ID = ENV_PROGRAM_ID;
|