Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-vincent committed Jun 17, 2024
1 parent 695ea93 commit ef603a4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 529 deletions.
3 changes: 2 additions & 1 deletion clients/bolt-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ export * from "./generated/instructions";
export * from "./world/transactions";
export * from "./delegation/accounts";
export * from "./delegation/delegate";
export * from "./delegation/undelegate";

export const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey(
"Sysvar1nstructions1111111111111111111111111"
);

export function FindWorldRegistryPda({ programId }: { programId?: PublicKey }) {
export function FindRegistryPda({ programId }: { programId?: PublicKey }) {
return PublicKey.findProgramAddressSync(
[Buffer.from("registry")],
programId ?? PROGRAM_ID
Expand Down
20 changes: 9 additions & 11 deletions clients/bolt-sdk/src/world/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
FindComponentPda,
FindEntityPda,
FindWorldPda,
FindWorldRegistryPda,
FindRegistryPda,
Registry,
SerializeArgs,
SYSVAR_INSTRUCTIONS_PUBKEY,
Expand All @@ -36,12 +36,10 @@ export async function InitializeNewWorld({
payer: PublicKey;
connection: Connection;
}): Promise<{ transaction: Transaction; worldPda: PublicKey; worldId: BN }> {
const registryPda = FindWorldRegistryPda({});
const registryPda = FindRegistryPda({});
const registry = await Registry.fromAccountAddress(connection, registryPda);
const worldId = new BN(registry.worlds);
const worldPda = FindWorldPda({
worldId,
});
const worldPda = FindWorldPda({ worldId });
const initializeWorldIx = createInitializeNewWorldInstruction({
world: worldPda,
registry: registryPda,
Expand Down Expand Up @@ -78,7 +76,7 @@ export async function AddEntity({
seed !== undefined
? FindEntityPda({ worldId, seed })
: FindEntityPda({ worldId, entityId: new BN(worldInstance.entities) });
const createEntityIx = createAddEntityInstruction(
const addEntityIx = createAddEntityInstruction(
{
world,
payer,
Expand All @@ -87,7 +85,7 @@ export async function AddEntity({
{ extraSeed: seed ?? null }
);
return {
transaction: new Transaction().add(createEntityIx),
transaction: new Transaction().add(addEntityIx),
entityPda,
};
}
Expand Down Expand Up @@ -118,7 +116,7 @@ export async function InitializeComponent({
anchorRemainingAccounts?: web3.AccountMeta[];
}): Promise<{ transaction: Transaction; componentPda: PublicKey }> {
const componentPda = FindComponentPda({ componentId, entity, seed });
const initComponentIx = createInitializeComponentInstruction({
const initializeComponentIx = createInitializeComponentInstruction({
payer,
entity,
data: componentPda,
Expand All @@ -128,7 +126,7 @@ export async function InitializeComponent({
anchorRemainingAccounts,
});
return {
transaction: new Transaction().add(initComponentIx),
transaction: new Transaction().add(initializeComponentIx),
componentPda,
};
}
Expand Down Expand Up @@ -183,13 +181,13 @@ function createApplySystemInstruction({
entities.forEach(function (entity) {
entity.components.forEach(function (component) {
const componentPda = FindComponentPda({
componentId: component.id,
componentId: component.componentId,
entity: entity.entity,
seed: component.seed,
});
instructionArgs[
getBoltComponentProgramName(componentCount, componentCount)
] = component.id;
] = component.componentId;
instructionArgs[getBoltComponentName(componentCount, componentCount)] =
componentPda;
});
Expand Down
Loading

0 comments on commit ef603a4

Please sign in to comment.