@jpool/bond-sdk 0.9.0-next.17 → 0.9.0-next.19
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 +38 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4570,6 +4570,10 @@ var BondTypeVariant = {
|
|
|
4570
4570
|
Performance: { performance: {} },
|
|
4571
4571
|
Crowdfunding: { crowdfunding: {} }
|
|
4572
4572
|
};
|
|
4573
|
+
var BondStateStatusVariant = {
|
|
4574
|
+
Active: { active: {} },
|
|
4575
|
+
Disabled: { disabled: {} }
|
|
4576
|
+
};
|
|
4573
4577
|
var BondTransactionType = /* @__PURE__ */ ((BondTransactionType2) => {
|
|
4574
4578
|
BondTransactionType2["Deposit"] = "deposit";
|
|
4575
4579
|
BondTransactionType2["Withdrawal"] = "withdrawal";
|
|
@@ -4803,7 +4807,7 @@ var HistoryManager = class {
|
|
|
4803
4807
|
|
|
4804
4808
|
// src/idl/jbond.json
|
|
4805
4809
|
var jbond_default = {
|
|
4806
|
-
address: "
|
|
4810
|
+
address: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
|
|
4807
4811
|
metadata: {
|
|
4808
4812
|
name: "jbond",
|
|
4809
4813
|
version: "0.2.1",
|
|
@@ -4959,68 +4963,6 @@ var jbond_default = {
|
|
|
4959
4963
|
}
|
|
4960
4964
|
]
|
|
4961
4965
|
},
|
|
4962
|
-
{
|
|
4963
|
-
name: "bond_disable",
|
|
4964
|
-
docs: [
|
|
4965
|
-
"Disables a validator's bond, preventing it from participating further."
|
|
4966
|
-
],
|
|
4967
|
-
discriminator: [
|
|
4968
|
-
159,
|
|
4969
|
-
156,
|
|
4970
|
-
97,
|
|
4971
|
-
253,
|
|
4972
|
-
70,
|
|
4973
|
-
122,
|
|
4974
|
-
117,
|
|
4975
|
-
129
|
|
4976
|
-
],
|
|
4977
|
-
accounts: [
|
|
4978
|
-
{
|
|
4979
|
-
name: "bond_state",
|
|
4980
|
-
writable: true
|
|
4981
|
-
},
|
|
4982
|
-
{
|
|
4983
|
-
name: "authority",
|
|
4984
|
-
writable: true,
|
|
4985
|
-
signer: true,
|
|
4986
|
-
relations: [
|
|
4987
|
-
"bond_state"
|
|
4988
|
-
]
|
|
4989
|
-
}
|
|
4990
|
-
],
|
|
4991
|
-
args: []
|
|
4992
|
-
},
|
|
4993
|
-
{
|
|
4994
|
-
name: "bond_enable",
|
|
4995
|
-
docs: [
|
|
4996
|
-
"Enables a previously disabled validator's bond."
|
|
4997
|
-
],
|
|
4998
|
-
discriminator: [
|
|
4999
|
-
133,
|
|
5000
|
-
48,
|
|
5001
|
-
84,
|
|
5002
|
-
9,
|
|
5003
|
-
117,
|
|
5004
|
-
131,
|
|
5005
|
-
164,
|
|
5006
|
-
128
|
|
5007
|
-
],
|
|
5008
|
-
accounts: [
|
|
5009
|
-
{
|
|
5010
|
-
name: "bond_state",
|
|
5011
|
-
writable: true
|
|
5012
|
-
},
|
|
5013
|
-
{
|
|
5014
|
-
name: "authority",
|
|
5015
|
-
writable: true,
|
|
5016
|
-
signer: true,
|
|
5017
|
-
relations: [
|
|
5018
|
-
"bond_state"
|
|
5019
|
-
]
|
|
5020
|
-
}
|
|
5021
|
-
],
|
|
5022
|
-
args: []
|
|
5023
|
-
},
|
|
5024
4966
|
{
|
|
5025
4967
|
name: "bond_initialize",
|
|
5026
4968
|
docs: [
|
|
@@ -5948,6 +5890,16 @@ var jbond_default = {
|
|
|
5948
5890
|
type: {
|
|
5949
5891
|
kind: "struct",
|
|
5950
5892
|
fields: [
|
|
5893
|
+
{
|
|
5894
|
+
name: "status",
|
|
5895
|
+
type: {
|
|
5896
|
+
option: {
|
|
5897
|
+
defined: {
|
|
5898
|
+
name: "BondStatus"
|
|
5899
|
+
}
|
|
5900
|
+
}
|
|
5901
|
+
}
|
|
5902
|
+
},
|
|
5951
5903
|
{
|
|
5952
5904
|
name: "new_reserve",
|
|
5953
5905
|
type: {
|
|
@@ -6120,6 +6072,9 @@ var jbond_default = {
|
|
|
6120
6072
|
},
|
|
6121
6073
|
{
|
|
6122
6074
|
name: "status",
|
|
6075
|
+
docs: [
|
|
6076
|
+
"Current status of the bond"
|
|
6077
|
+
],
|
|
6123
6078
|
type: {
|
|
6124
6079
|
defined: {
|
|
6125
6080
|
name: "BondStatus"
|
|
@@ -6604,14 +6559,6 @@ var JBondClient = class _JBondClient {
|
|
|
6604
6559
|
const ix = await this.buildBondFinishIx(props);
|
|
6605
6560
|
return this.provider.sendAndConfirm?.(new Transaction().add(ix));
|
|
6606
6561
|
}
|
|
6607
|
-
async bondEnable(props) {
|
|
6608
|
-
const ix = await this.buildBondEnableIx(props);
|
|
6609
|
-
return this.provider.sendAndConfirm?.(new Transaction().add(ix));
|
|
6610
|
-
}
|
|
6611
|
-
async bondDisable(props) {
|
|
6612
|
-
const ix = await this.buildBondDisableIx(props);
|
|
6613
|
-
return this.provider.sendAndConfirm?.(new Transaction().add(ix));
|
|
6614
|
-
}
|
|
6615
6562
|
async buildBondGlobalStateInitializeIx(props) {
|
|
6616
6563
|
const [globalState] = this.pda.globalState();
|
|
6617
6564
|
const authority = props.authority ?? this.provider.wallet?.publicKey;
|
|
@@ -6669,6 +6616,7 @@ var JBondClient = class _JBondClient {
|
|
|
6669
6616
|
async buildConfigureIx(props) {
|
|
6670
6617
|
const [bondState] = this.pda.bondState(props.bondType, props.name);
|
|
6671
6618
|
return this.program.methods.bondConfigure({
|
|
6619
|
+
status: props.bondStateStatus ?? null,
|
|
6672
6620
|
newReserve: props.newReserve ?? null,
|
|
6673
6621
|
newAuthority: props.newAuthority ?? null
|
|
6674
6622
|
}).accountsStrict({
|
|
@@ -6684,7 +6632,7 @@ var JBondClient = class _JBondClient {
|
|
|
6684
6632
|
if (!creator) {
|
|
6685
6633
|
throw new Error("Missing creator");
|
|
6686
6634
|
}
|
|
6687
|
-
const collateralType = (await this.getBondState(bondType, name))
|
|
6635
|
+
const collateralType = (await this.getBondState(bondType, name)).bond_state.collateralType;
|
|
6688
6636
|
const accounts = {
|
|
6689
6637
|
bondState,
|
|
6690
6638
|
validatorBond,
|
|
@@ -6727,7 +6675,7 @@ var JBondClient = class _JBondClient {
|
|
|
6727
6675
|
creator: props.payer
|
|
6728
6676
|
}));
|
|
6729
6677
|
}
|
|
6730
|
-
const collateralType = (await this.getBondState(bondType, name))
|
|
6678
|
+
const collateralType = (await this.getBondState(bondType, name)).bond_state.collateralType;
|
|
6731
6679
|
const accounts = {
|
|
6732
6680
|
bondState,
|
|
6733
6681
|
validatorBond,
|
|
@@ -6764,7 +6712,7 @@ var JBondClient = class _JBondClient {
|
|
|
6764
6712
|
if (!payer || !destination) {
|
|
6765
6713
|
throw new Error("Missing payer/destination");
|
|
6766
6714
|
}
|
|
6767
|
-
const collateralType = (await this.getBondState(bondType, name))
|
|
6715
|
+
const collateralType = (await this.getBondState(bondType, name)).bond_state.collateralType;
|
|
6768
6716
|
const accounts = {
|
|
6769
6717
|
bondState,
|
|
6770
6718
|
validatorBond,
|
|
@@ -6792,12 +6740,12 @@ var JBondClient = class _JBondClient {
|
|
|
6792
6740
|
const { bondType, name } = props;
|
|
6793
6741
|
const [bondState] = this.pda.bondState(bondType, name);
|
|
6794
6742
|
const [validatorBond] = this.pda.validatorBond(bondType, name, props.voteAccount);
|
|
6795
|
-
const reserve = props.reserve ?? (await this.getBondState(bondType, name))
|
|
6743
|
+
const reserve = props.reserve ?? (await this.getBondState(bondType, name)).bond_state.reserve;
|
|
6796
6744
|
const authority = props.authority ?? this.program.provider.wallet?.publicKey;
|
|
6797
6745
|
if (!reserve) {
|
|
6798
6746
|
throw new Error("Reserve not set");
|
|
6799
6747
|
}
|
|
6800
|
-
const collateralType = (await this.getBondState(bondType, name))
|
|
6748
|
+
const collateralType = (await this.getBondState(bondType, name)).bond_state.collateralType;
|
|
6801
6749
|
const accounts = {
|
|
6802
6750
|
bondState,
|
|
6803
6751
|
validatorBond,
|
|
@@ -6846,20 +6794,6 @@ var JBondClient = class _JBondClient {
|
|
|
6846
6794
|
authority: this.program.provider.wallet?.publicKey
|
|
6847
6795
|
}).instruction();
|
|
6848
6796
|
}
|
|
6849
|
-
async buildBondEnableIx(props) {
|
|
6850
|
-
const [bondState] = this.pda.bondState(props.bondType, props.name);
|
|
6851
|
-
return this.program.methods.bondEnable().accountsPartial({
|
|
6852
|
-
bondState,
|
|
6853
|
-
authority: this.program.provider.wallet?.publicKey
|
|
6854
|
-
}).instruction();
|
|
6855
|
-
}
|
|
6856
|
-
async buildBondDisableIx(props) {
|
|
6857
|
-
const [bondState] = this.pda.bondState(props.bondType, props.name);
|
|
6858
|
-
return this.program.methods.bondDisable().accountsPartial({
|
|
6859
|
-
bondState,
|
|
6860
|
-
authority: this.program.provider.wallet?.publicKey
|
|
6861
|
-
}).instruction();
|
|
6862
|
-
}
|
|
6863
6797
|
/**
|
|
6864
6798
|
* Fetch global state or throw if not found
|
|
6865
6799
|
*/
|
|
@@ -6875,7 +6809,10 @@ var JBondClient = class _JBondClient {
|
|
|
6875
6809
|
*/
|
|
6876
6810
|
async getBondState(bondType, bondName, withStats = false) {
|
|
6877
6811
|
const bondState = await this.program.account.bondState.fetch(this.pda.bondState(bondType, bondName)[0]);
|
|
6878
|
-
return
|
|
6812
|
+
return {
|
|
6813
|
+
bond_state: bondState,
|
|
6814
|
+
state_stats: withStats ? await this.getBondStateStats(bondState) : null
|
|
6815
|
+
};
|
|
6879
6816
|
}
|
|
6880
6817
|
/**
|
|
6881
6818
|
* Get all bond states with total collected collateral
|
|
@@ -6891,7 +6828,12 @@ var JBondClient = class _JBondClient {
|
|
|
6891
6828
|
continue;
|
|
6892
6829
|
}
|
|
6893
6830
|
const bondStateStats = await this.getBondStateStats(state);
|
|
6894
|
-
bondStates.push(
|
|
6831
|
+
bondStates.push(
|
|
6832
|
+
{
|
|
6833
|
+
bond_state: state,
|
|
6834
|
+
state_stats: bondStateStats
|
|
6835
|
+
}
|
|
6836
|
+
);
|
|
6895
6837
|
}
|
|
6896
6838
|
return bondStates;
|
|
6897
6839
|
}
|
|
@@ -6941,7 +6883,7 @@ var JBondClient = class _JBondClient {
|
|
|
6941
6883
|
*/
|
|
6942
6884
|
async getBondCollateralType(bondType, bondName) {
|
|
6943
6885
|
const bondState = await this.getBondState(bondType, bondName);
|
|
6944
|
-
return bondState
|
|
6886
|
+
return bondState.bond_state.collateralType;
|
|
6945
6887
|
}
|
|
6946
6888
|
/**
|
|
6947
6889
|
* Get validator bond account balance (in SOL)
|
|
@@ -6953,7 +6895,7 @@ var JBondClient = class _JBondClient {
|
|
|
6953
6895
|
async getValidatorBondBalance(bondType, bondName, vote) {
|
|
6954
6896
|
const [address] = this.pda.validatorBond(bondType, bondName, new PublicKey(vote));
|
|
6955
6897
|
const bondStateData = await this.getBondState(bondType, bondName);
|
|
6956
|
-
const bondStateCollateralType = bondStateData
|
|
6898
|
+
const bondStateCollateralType = bondStateData.bond_state.collateralType;
|
|
6957
6899
|
return await matchVariant(bondStateCollateralType, {
|
|
6958
6900
|
native: async () => {
|
|
6959
6901
|
const accountInfo = await this.connection.getAccountInfo(address).catch(() => null);
|
|
@@ -6980,7 +6922,7 @@ var JBondClient = class _JBondClient {
|
|
|
6980
6922
|
*/
|
|
6981
6923
|
async getBondStateTotalCollected(bondType, bondName, votes) {
|
|
6982
6924
|
const bondStateData = await this.getBondState(bondType, bondName);
|
|
6983
|
-
const bondStateCollateralType = bondStateData
|
|
6925
|
+
const bondStateCollateralType = bondStateData.bond_state.collateralType;
|
|
6984
6926
|
const chunk = (arr, n = 100) => {
|
|
6985
6927
|
const res = [];
|
|
6986
6928
|
for (let i = 0; i < arr.length; i += n) {
|
|
@@ -7100,6 +7042,6 @@ buffer/index.js:
|
|
|
7100
7042
|
*)
|
|
7101
7043
|
*/
|
|
7102
7044
|
|
|
7103
|
-
export { BondClientEnv, BondTransactionType, BondTypeVariant, ENV_PROGRAM_ID, JBondClient, JPOOL_STAKE_POOL, NodeWallet, Seeds, SessionStatus, bondTypeToSeed };
|
|
7045
|
+
export { BondClientEnv, BondStateStatusVariant, BondTransactionType, BondTypeVariant, ENV_PROGRAM_ID, JBondClient, JPOOL_STAKE_POOL, NodeWallet, Seeds, SessionStatus, bondTypeToSeed };
|
|
7104
7046
|
//# sourceMappingURL=index.mjs.map
|
|
7105
7047
|
//# sourceMappingURL=index.mjs.map
|