forked from solana-labs/solana-program-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jxiao/fix log truncation (solana-labs#121)
* Initial implementation of log truncation fix * Add new files * refactor bubblegum pda * amend me * update basic ts sdk * better bgum convenience * addProof modifies instructions to add proof fluently * better bg init * fix rebase issues * fix sugar shack tests * use convenience initializer * revert maxSeq change, update smokeTest Co-authored-by: Noah Gundotra <noahgundotra@noahs-mbp.mynetworksettings.com>
- Loading branch information
1 parent
6092366
commit 9bd6fe7
Showing
3 changed files
with
93 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { PublicKey, Keypair, TransactionInstruction, SystemProgram, Connection } from "@solana/web3.js"; | ||
import { PROGRAM_ID } from "."; | ||
import { getMerkleRollAccountSize } from "./accounts"; | ||
import * as anchor from '@project-serum/anchor'; | ||
import { Gummyroll } from "./types"; | ||
import { CANDY_WRAPPER_PROGRAM_ID } from "../utils"; | ||
|
||
export async function createAllocTreeIx( | ||
connection: Connection, | ||
maxBufferSize: number, | ||
maxDepth: number, | ||
canopyDepth: number, | ||
payer: PublicKey, | ||
merkleRoll: PublicKey, | ||
): Promise<TransactionInstruction> { | ||
const requiredSpace = getMerkleRollAccountSize( | ||
maxDepth, | ||
maxBufferSize, | ||
canopyDepth ?? 0 | ||
); | ||
return SystemProgram.createAccount({ | ||
fromPubkey: payer, | ||
newAccountPubkey: merkleRoll, | ||
lamports: | ||
await connection.getMinimumBalanceForRentExemption( | ||
requiredSpace | ||
), | ||
space: requiredSpace, | ||
programId: PROGRAM_ID | ||
}); | ||
} | ||
|
||
export async function getCreateTreeIxs( | ||
gummyroll: anchor.Program<Gummyroll>, | ||
maxBufferSize: number, | ||
maxDepth: number, | ||
canopyDepth: number, | ||
payer: PublicKey, | ||
merkleRoll: PublicKey, | ||
authority: Keypair, | ||
appendAuthority: PublicKey, | ||
): Promise<TransactionInstruction[]> { | ||
const allocAccountIx = await createAllocTreeIx( | ||
gummyroll.provider.connection, | ||
maxBufferSize, | ||
maxDepth, | ||
canopyDepth, | ||
payer, | ||
merkleRoll, | ||
); | ||
const initIx = gummyroll.instruction.initEmptyGummyroll( | ||
maxDepth, | ||
maxBufferSize, | ||
{ | ||
accounts: { | ||
merkleRoll, | ||
authority, | ||
appendAuthority, | ||
candyWrapper: CANDY_WRAPPER_PROGRAM_ID | ||
}, | ||
signers: [authority], | ||
}, | ||
) | ||
|
||
return [allocAccountIx, initIx]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters