From 396b1032aeb90098b349e65479abb8b1e44f0f01 Mon Sep 17 00:00:00 2001 From: metaproph3t Date: Tue, 24 Oct 2023 00:00:00 +0000 Subject: [PATCH] Add a default `programId` to ts client Caveat emptor, this is a non-backwards-compatible change. But I think it makes the interface a little simpler, since you don't have to dig up the OpenBook program ID. --- ts/client/src/client.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 8be075149..8f0c13793 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -59,6 +59,10 @@ export function nameToString(name: number[]): string { const BooksideSpace = 90944 + 8; const EventHeapSpace = 91280 + 8; +const OPENBOOK_PROGRAM_ID = new PublicKey( + "opnbkNkqux64GppQhwbyEVc3axhssFhVYuwar8rDHCu" +); + export class OpenBookV2Client { public program: Program; @@ -68,8 +72,8 @@ export class OpenBookV2Client { private readonly txConfirmationCommitment: Commitment; constructor( - public programId: PublicKey, public provider: AnchorProvider, + public programId: PublicKey = OPENBOOK_PROGRAM_ID, public opts: OpenBookClientOptions = {}, ) { this.program = new Program(IDL, programId, provider);