Skip to content

Commit

Permalink
Merge pull request solana-labs#100 from jarry-xiao/gummyshop
Browse files Browse the repository at this point in the history
Sugar Shack Contract, Test + SDK
  • Loading branch information
samwise2 authored Jun 27, 2022
2 parents f6a8873 + 7ed1807 commit 6092366
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/sdk/gummyroll/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PublicKey } from '@solana/web3.js';
export * from './instructions';
export * from './accounts';
export * from './types';
export * from './utils';

/**
* Program address
Expand Down
20 changes: 20 additions & 0 deletions contracts/sdk/gummyroll/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
decodeMerkleRoll,
getMerkleRollAccountSize,
} from "../accounts";
import {
PublicKey,
Keypair,
SystemProgram,
Transaction,
Connection as web3Connection,
LAMPORTS_PER_SOL,
Connection,
} from "@solana/web3.js";

export async function getRootOfOnChainMerkleRoot(connection: Connection, merkleRollAccountKey: PublicKey): Promise<Buffer> {
const merkleRootAcct = await connection.getAccountInfo(merkleRollAccountKey);
const merkleRoll = decodeMerkleRoll(merkleRootAcct.data);
return merkleRoll.roll.changeLogs[merkleRoll.roll.activeIndex].root.toBuffer();
}

0 comments on commit 6092366

Please sign in to comment.