@jpool/bond-sdk 0.11.0-next.18 → 0.11.0-next.20
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 +15 -11
- package/dist/index.d.ts +15 -11
- package/dist/index.js +40 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { utils,
|
|
1
|
+
import { utils, AnchorProvider, Program, BN } from '@coral-xyz/anchor';
|
|
2
2
|
import { getAssociatedTokenAddressSync, ACCOUNT_SIZE, AccountLayout } from '@solana/spl-token';
|
|
3
3
|
import { PublicKey, Transaction, LAMPORTS_PER_SOL } from '@solana/web3.js';
|
|
4
4
|
|
|
@@ -4547,17 +4547,13 @@ var require_bn = __commonJS({
|
|
|
4547
4547
|
// src/client.ts
|
|
4548
4548
|
var import_bn = __toESM(require_bn());
|
|
4549
4549
|
|
|
4550
|
-
// src/constants.ts
|
|
4551
|
-
var GLOBAL_STATE_SEED = "global_state";
|
|
4552
|
-
var BOND_STATE_SEED = "bond_state";
|
|
4553
|
-
var VALIDATOR_BOND_SEED = "validator_bond";
|
|
4554
|
-
var STANDARD_BOND_SEED = "standard";
|
|
4555
|
-
var CROWDFUNDING_BOND_SEED = "crowdfunding";
|
|
4556
|
-
var ENV_PROGRAM_ID = {
|
|
4557
|
-
// [JBondClientEnv.DEV]: new PublicKey('...'),
|
|
4558
|
-
};
|
|
4559
|
-
|
|
4560
4550
|
// src/types/index.ts
|
|
4551
|
+
var JBondClientEnv = /* @__PURE__ */ ((JBondClientEnv2) => {
|
|
4552
|
+
JBondClientEnv2["DEV"] = "dev";
|
|
4553
|
+
JBondClientEnv2["STAGE"] = "stage";
|
|
4554
|
+
JBondClientEnv2["PROD"] = "prod";
|
|
4555
|
+
return JBondClientEnv2;
|
|
4556
|
+
})(JBondClientEnv || {});
|
|
4561
4557
|
var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
|
|
4562
4558
|
SessionStatus2[SessionStatus2["Live"] = 0] = "Live";
|
|
4563
4559
|
SessionStatus2[SessionStatus2["Finished"] = 1] = "Finished";
|
|
@@ -4575,7 +4571,16 @@ var BondTransactionType = /* @__PURE__ */ ((BondTransactionType2) => {
|
|
|
4575
4571
|
return BondTransactionType2;
|
|
4576
4572
|
})(BondTransactionType || {});
|
|
4577
4573
|
|
|
4578
|
-
// src/
|
|
4574
|
+
// src/constants.ts
|
|
4575
|
+
var GLOBAL_STATE_SEED = "global_state";
|
|
4576
|
+
var BOND_STATE_SEED = "bond_state";
|
|
4577
|
+
var VALIDATOR_BOND_SEED = "validator_bond";
|
|
4578
|
+
var STANDARD_BOND_SEED = "standard";
|
|
4579
|
+
var CROWDFUNDING_BOND_SEED = "crowdfunding";
|
|
4580
|
+
var ENV_PROGRAM_ID = {
|
|
4581
|
+
["dev" /* DEV */]: new PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
|
|
4582
|
+
["prod" /* PROD */]: new PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
|
|
4583
|
+
};
|
|
4579
4584
|
var { bs58 } = utils.bytes;
|
|
4580
4585
|
var HistoryManager = class {
|
|
4581
4586
|
constructor(client) {
|
|
@@ -6655,20 +6660,13 @@ function getBondTypeSeed(type) {
|
|
|
6655
6660
|
}
|
|
6656
6661
|
|
|
6657
6662
|
// src/client.ts
|
|
6658
|
-
var JBondClientEnv = /* @__PURE__ */ ((JBondClientEnv2) => {
|
|
6659
|
-
JBondClientEnv2["DEV"] = "dev";
|
|
6660
|
-
JBondClientEnv2["STAGE"] = "stage";
|
|
6661
|
-
JBondClientEnv2["PROD"] = "prod";
|
|
6662
|
-
return JBondClientEnv2;
|
|
6663
|
-
})(JBondClientEnv || {});
|
|
6664
6663
|
var JBondClient = class _JBondClient {
|
|
6665
6664
|
constructor(provider, options) {
|
|
6666
6665
|
this.provider = provider;
|
|
6667
6666
|
this.options = options ?? {};
|
|
6668
|
-
this.program = new Program(jbond_default, this.provider);
|
|
6669
6667
|
}
|
|
6670
6668
|
options;
|
|
6671
|
-
|
|
6669
|
+
_program = null;
|
|
6672
6670
|
get history() {
|
|
6673
6671
|
return new HistoryManager(this);
|
|
6674
6672
|
}
|
|
@@ -6697,11 +6695,24 @@ var JBondClient = class _JBondClient {
|
|
|
6697
6695
|
static fromKeypair(connection, keypair, options) {
|
|
6698
6696
|
return _JBondClient.fromWallet(connection, new NodeWallet(keypair), options);
|
|
6699
6697
|
}
|
|
6698
|
+
/**
|
|
6699
|
+
* Get or create the program instance
|
|
6700
|
+
*/
|
|
6701
|
+
get program() {
|
|
6702
|
+
if (!this._program) {
|
|
6703
|
+
jbond_default.address = this.programId.toBase58();
|
|
6704
|
+
this._program = new Program(jbond_default, this.provider);
|
|
6705
|
+
}
|
|
6706
|
+
return this._program;
|
|
6707
|
+
}
|
|
6700
6708
|
/**
|
|
6701
6709
|
* Get the current program ID.
|
|
6702
6710
|
*/
|
|
6703
6711
|
get programId() {
|
|
6704
|
-
|
|
6712
|
+
if (this.options.programId) {
|
|
6713
|
+
return this.options.programId;
|
|
6714
|
+
}
|
|
6715
|
+
return ENV_PROGRAM_ID["prod" /* PROD */];
|
|
6705
6716
|
}
|
|
6706
6717
|
/**
|
|
6707
6718
|
* Get the current connection.
|
|
@@ -6713,7 +6724,13 @@ var JBondClient = class _JBondClient {
|
|
|
6713
6724
|
* Set the environment.
|
|
6714
6725
|
*/
|
|
6715
6726
|
env(env) {
|
|
6716
|
-
|
|
6727
|
+
const envProgramId = ENV_PROGRAM_ID[env];
|
|
6728
|
+
if (!envProgramId) {
|
|
6729
|
+
throw new Error(`Invalid environment: ${env}`);
|
|
6730
|
+
}
|
|
6731
|
+
this._program = null;
|
|
6732
|
+
this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
|
|
6733
|
+
return this.configure("programId", envProgramId);
|
|
6717
6734
|
}
|
|
6718
6735
|
/**
|
|
6719
6736
|
* Configure a specific option.
|