Skip to content

Commit 398c4a4

Browse files
committed
:recucle: Keeping Entity PDA derivation from World ID
1 parent afcc44d commit 398c4a4

File tree

9 files changed

+32
-728
lines changed

9 files changed

+32
-728
lines changed

clients/bolt-sdk/idl/world.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
],
7676
"args": [
7777
{
78-
"name": "seed",
78+
"name": "extraSeed",
7979
"type": {
8080
"option": "string"
8181
}

clients/bolt-sdk/src/generated/idl/world.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
],
7979
"args": [
8080
{
81-
"name": "seed",
81+
"name": "extra_seed",
8282
"type": {
8383
"option": "bytes"
8484
}

clients/bolt-sdk/src/generated/instructions/addEntity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as web3 from "@solana/web3.js";
1414
* @category generated
1515
*/
1616
export interface AddEntityInstructionArgs {
17-
seed: beet.COption<Uint8Array>;
17+
extraSeed: beet.COption<Uint8Array>;
1818
}
1919
/**
2020
* @category Instructions
@@ -28,7 +28,7 @@ export const addEntityStruct = new beet.FixableBeetArgsStruct<
2828
>(
2929
[
3030
["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)],
31-
["seed", beet.coption(beet.bytes)],
31+
["extraSeed", beet.coption(beet.bytes)],
3232
],
3333
"AddEntityInstructionArgs",
3434
);

clients/bolt-sdk/src/generated/types/world.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export type World = {
6666
];
6767
args: [
6868
{
69-
name: "seed";
69+
name: "extra_seed";
7070
type: {
7171
option: "bytes";
7272
};

clients/bolt-sdk/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PublicKey } from "@solana/web3.js";
22
import type BN from "bn.js";
3-
import * as PROGRAM_IDL from "./world/idl.json";
43
import { PROGRAM_ID } from "./generated";
4+
import { World as PROGRAM_IDL } from "./generated/types/world";
55
export * from "./generated/accounts";
66
export * from "./generated/instructions";
77
export * from "./world/transactions";
@@ -42,22 +42,23 @@ export function FindWorldPda({
4242
}
4343

4444
export function FindEntityPda({
45-
world,
45+
worldId,
4646
entityId,
4747
seed,
4848
programId,
4949
}: {
50-
world: PublicKey;
50+
worldId: BN;
5151
entityId?: BN;
5252
seed?: Uint8Array;
5353
programId?: PublicKey;
5454
}) {
55-
const seeds = [Buffer.from("entity"), world.toBytes()];
55+
const worldIdBuffer = Buffer.from(worldId.toArrayLike(Buffer, "be", 8));
56+
const seeds = [Buffer.from("entity"), worldIdBuffer];
5657
if (seed !== undefined) {
5758
seeds.push(Buffer.from(new Uint8Array(8)));
5859
seeds.push(Buffer.from(seed));
5960
} else if (entityId !== undefined) {
60-
const entityIdBuffer = entityId.toArrayLike(Buffer, "be", 8);
61+
const entityIdBuffer = Buffer.from(entityId.toArrayLike(Buffer, "be", 8));
6162
seeds.push(entityIdBuffer);
6263
} else {
6364
throw new Error("An entity must have either an Id or a Seed");

0 commit comments

Comments
 (0)