Skip to content

Commit

Permalink
Export types and IDLs
Browse files Browse the repository at this point in the history
  • Loading branch information
macalinao committed Jan 1, 2022
1 parent 62b80aa commit b183b34
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
11 changes: 11 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { SuperCoder } from "@saberhq/anchor-contrib";
import { PublicKey } from "@solana/web3.js";

import type { MerkleDistributorTypes } from ".";
import { MerkleDistributorJSON } from "./idls/merkle_distributor";

export const PROGRAM_ID = new PublicKey(
"MRKGLMizK9XSTaD1d1jbVkdHZbQVCSnPpYiTw9aKQv8"
);

export const MERKLE_DISTRIBUTOR_PROGRAM_ID = PROGRAM_ID;

export const MERKLE_DISTRIBUTOR_CODER = new SuperCoder<MerkleDistributorTypes>(
MERKLE_DISTRIBUTOR_PROGRAM_ID,
MerkleDistributorJSON
);
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./constants";
export * from "./idls/merkle_distributor";
export * from "./pda";
export * from "./sdk";
export * from "./types";
Expand Down
29 changes: 10 additions & 19 deletions src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Program, Provider as AnchorProvider } from "@project-serum/anchor";
import type { Provider } from "@saberhq/solana-contrib";
import { SignerWallet, SolanaProvider } from "@saberhq/solana-contrib";
import { newProgram } from "@saberhq/anchor-contrib";
import type { AugmentedProvider, Provider } from "@saberhq/solana-contrib";
import { SolanaAugmentedProvider } from "@saberhq/solana-contrib";
import type { PublicKey, Signer } from "@solana/web3.js";

import { PROGRAM_ID } from "./constants";
Expand All @@ -14,18 +14,13 @@ import { MerkleDistributorWrapper } from "./wrapper";

export class MerkleDistributorSDK {
constructor(
readonly provider: Provider,
readonly provider: AugmentedProvider,
readonly program: MerkleDistributorProgram
) {}

withSigner(signer: Signer): MerkleDistributorSDK {
return MerkleDistributorSDK.load({
provider: new SolanaProvider(
this.provider.connection,
this.provider.broadcaster,
new SignerWallet(signer),
this.provider.opts
),
provider: this.provider.withSigner(signer),
});
}

Expand All @@ -39,18 +34,14 @@ export class MerkleDistributorSDK {
// Provider
provider: Provider;
}): MerkleDistributorSDK {
const anchorProvider = new AnchorProvider(
provider.connection,
provider.wallet,
provider.opts
);
const aug = new SolanaAugmentedProvider(provider);
return new MerkleDistributorSDK(
provider,
new Program(
aug,
newProgram<MerkleDistributorProgram>(
MerkleDistributorJSON,
PROGRAM_ID,
anchorProvider
) as unknown as MerkleDistributorProgram
aug
)
);
}

Expand Down

0 comments on commit b183b34

Please sign in to comment.