solana.js: doc comments

This commit is contained in:
Conner Gallagher 2022-12-01 00:07:18 -07:00
parent fe1a52a1eb
commit 9623cd8481
1 changed files with 32 additions and 4 deletions

View File

@ -56,15 +56,36 @@ const isBrowser =
/** /**
* Wrapper class for the Switchboard anchor Program. * Wrapper class for the Switchboard anchor Program.
*
* Basic usage example:
*
* ```ts
* import { Connection } from "@solana/web3.js";
* import { SwitchboardProgram, TransactionObject } from '@switchboard-xyz/solana.js';
*
* const program = await SwitchboardProgram.load(
* "mainnet-beta",
* new Connection("https://api.mainnet-beta.solana.com"),
* payerKeypair
* );
*
* const txn = new TransactionObject(program.walletPubkey, [], []);
* const txnSignature = await program.signAndSend(txn);
* ```
*/ */
export class SwitchboardProgram { export class SwitchboardProgram {
private static readonly _readOnlyKeypair = READ_ONLY_KEYPAIR; private static readonly _readOnlyKeypair = READ_ONLY_KEYPAIR;
private readonly _program: anchor.Program; private readonly _program: anchor.Program;
/** The solana cluster to load the Switchboard program for. */
readonly cluster: Cluster | 'localnet'; readonly cluster: Cluster | 'localnet';
readonly programState: { readonly programState: {
publicKey: PublicKey; publicKey: PublicKey;
bump: number; bump: number;
}; };
readonly mint: Mint; readonly mint: Mint;
/** /**
@ -123,10 +144,17 @@ export class SwitchboardProgram {
* Basic usage example: * Basic usage example:
* *
* ```ts * ```ts
* import {Connection} from "@solana/web3.js"; * import { Connection } from "@solana/web3.js";
* import {SwitchboardProgram} from '@switchboard-xyz/solana.js'; * import { SwitchboardProgram, TransactionObject } from '@switchboard-xyz/solana.js';
* const program = await SwitchboardProgram.load("mainnet-beta", new Connection("https://api.mainnet-beta.solana.com"), payerKeypair); *
* console.log(program.programId); * const program = await SwitchboardProgram.load(
* "mainnet-beta",
* new Connection("https://api.mainnet-beta.solana.com"),
* payerKeypair
* );
*
* const txn = new TransactionObject(program.walletPubkey, [], []);
* const txnSignature = await program.signAndSend(txn);
* ``` * ```
*/ */
static load = async ( static load = async (