Explorar o código

:sparkles: Improve Bolt typescript SDK (#41)

* :sparkles: Improve ts sdk

* :recycle: Code Refactor

* :bug: Fix generated example
Gabriele Picco hai 1 ano
pai
achega
fcd0b4bcee

+ 4 - 4
cli/src/rust_template.rs

@@ -443,7 +443,7 @@ describe("{}", () => {{
   it("Add an entity", async () => {{
       const addEntity = await AddEntity({{
         payer: provider.wallet.publicKey,
-        worldPda: worldPda,
+        world: worldPda,
         connection: provider.connection,
       }});
       const txSign = await provider.sendAndConfirm(addEntity.transaction);
@@ -454,7 +454,7 @@ describe("{}", () => {{
   it("Add a component", async () => {{
       const initComponent = await InitializeComponent({{
           payer: provider.wallet.publicKey,
-          entityPda,
+          entity: entityPda,
           componentId: positionComponent.programId,
       }});
       const txSign = await provider.sendAndConfirm(initComponent.transaction);
@@ -470,8 +470,8 @@ describe("{}", () => {{
 
       const applySystem = await ApplySystem({{
         authority: provider.wallet.publicKey,
-        boltSystem: systemMovement.programId,
-        entityPda,
+        system: systemMovement.programId,
+        entity: entityPda,
         components: [positionComponent.programId],
       }});
       const txSign = await provider.sendAndConfirm(applySystem.transaction);

+ 7 - 4
clients/bolt-sdk/lib/index.d.ts

@@ -1,6 +1,6 @@
 /// <reference types="node" />
 import { PublicKey } from "@solana/web3.js";
-import type BN from "bn.js";
+import BN from "bn.js";
 export * from "./accounts";
 export * from "./instructions";
 export * from "./transactions/transactions";
@@ -9,10 +9,13 @@ export declare const PROGRAM_ADDRESS =
 export declare const SYSVAR_INSTRUCTIONS_PUBKEY: PublicKey;
 export declare const PROGRAM_ID: PublicKey;
 export declare function FindWorldRegistryPda(programId?: PublicKey): PublicKey;
-export declare function FindWorldPda(id: BN, programId?: PublicKey): PublicKey;
+export declare function FindWorldPda(
+  id: BN | string | number | Uint8Array,
+  programId?: PublicKey
+): PublicKey;
 export declare function FindEntityPda(
-  worldId: BN,
-  entityId: BN,
+  worldId: BN | string | number | Uint8Array,
+  entityId: BN | string | number | Uint8Array,
   extraSeed?: string,
   programId?: PublicKey
 ): PublicKey;

+ 1 - 1
clients/bolt-sdk/lib/index.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/generated/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,OAAO,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAQ5C,eAAO,MAAM,eAAe,gDAAgD,CAAC;AAE7E,eAAO,MAAM,0BAA0B,WAEtC,CAAC;AAQF,eAAO,MAAM,UAAU,WAAiC,CAAC;AAEzD,wBAAgB,oBAAoB,CAClC,SAAS,GAAE,SAAqC,aAMjD;AAED,wBAAgB,YAAY,CAC1B,EAAE,EAAE,EAAE,EACN,SAAS,GAAE,SAAqC,aAMjD;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,EAAE,EACX,QAAQ,EAAE,EAAE,EACZ,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,GAAE,SAAqC,aAUjD;AAED,wBAAgB,gBAAgB,CAC9B,kBAAkB,EAAE,SAAS,EAC7B,MAAM,EAAE,SAAS,EACjB,WAAW,GAAE,MAAW,aAMzB;AAOD,wBAAgB,aAAa,CAAC,IAAI,GAAE,GAAQ,UAS3C"}
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/generated/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAQ5C,eAAO,MAAM,eAAe,gDAAgD,CAAC;AAE7E,eAAO,MAAM,0BAA0B,WAEtC,CAAC;AAQF,eAAO,MAAM,UAAU,WAAiC,CAAC;AAEzD,wBAAgB,oBAAoB,CAClC,SAAS,GAAE,SAAqC,aAMjD;AAED,wBAAgB,YAAY,CAC1B,EAAE,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,EACrC,SAAS,GAAE,SAAqC,aAQjD;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,EAC1C,QAAQ,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,EAC3C,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,GAAE,SAAqC,aAcjD;AAED,wBAAgB,gBAAgB,CAC9B,kBAAkB,EAAE,SAAS,EAC7B,MAAM,EAAE,SAAS,EACjB,WAAW,GAAE,MAAW,aAMzB;AAcD,wBAAgB,aAAa,CAAC,IAAI,GAAE,GAAQ,UAS3C"}

+ 21 - 3
clients/bolt-sdk/lib/index.js

@@ -29,6 +29,11 @@ var __exportStar =
       if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
         __createBinding(exports, m, p);
   };
+var __importDefault =
+  (this && this.__importDefault) ||
+  function (mod) {
+    return mod && mod.__esModule ? mod : { default: mod };
+  };
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.SerializeArgs =
   exports.FindComponentPda =
@@ -40,6 +45,7 @@ exports.SerializeArgs =
   exports.PROGRAM_ADDRESS =
     void 0;
 var web3_js_1 = require("@solana/web3.js");
+var bn_js_1 = __importDefault(require("bn.js"));
 __exportStar(require("./accounts"), exports);
 __exportStar(require("./instructions"), exports);
 __exportStar(require("./transactions/transactions"), exports);
@@ -62,8 +68,10 @@ function FindWorldPda(id, programId) {
   if (programId === void 0) {
     programId = new web3_js_1.PublicKey(exports.PROGRAM_ID);
   }
+  id = CastToBN(id);
+  var idBuffer = Buffer.from(id.toArrayLike(Buffer, "be", 8));
   return web3_js_1.PublicKey.findProgramAddressSync(
-    [Buffer.from("world"), id.toBuffer("be", 8)],
+    [Buffer.from("world"), idBuffer],
     programId
   )[0];
 }
@@ -72,12 +80,16 @@ function FindEntityPda(worldId, entityId, extraSeed, programId) {
   if (programId === void 0) {
     programId = new web3_js_1.PublicKey(exports.PROGRAM_ID);
   }
-  var seeds = [Buffer.from("entity"), worldId.toBuffer("be", 8)];
+  worldId = CastToBN(worldId);
+  entityId = CastToBN(entityId);
+  var worldIdBuffer = Buffer.from(worldId.toArrayLike(Buffer, "be", 8));
+  var entityIdBuffer = Buffer.from(entityId.toArrayLike(Buffer, "be", 8));
+  var seeds = [Buffer.from("entity"), worldIdBuffer];
   if (extraSeed != null) {
     seeds.push(Buffer.from(new Uint8Array(8)));
     seeds.push(Buffer.from(extraSeed));
   } else {
-    seeds.push(entityId.toBuffer("be", 8));
+    seeds.push(entityIdBuffer);
   }
   return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
 }
@@ -92,6 +104,12 @@ function FindComponentPda(componentProgramId, entity, componentId) {
   )[0];
 }
 exports.FindComponentPda = FindComponentPda;
+function CastToBN(id) {
+  if (!(id instanceof bn_js_1.default)) {
+    id = new bn_js_1.default(id);
+  }
+  return id;
+}
 function SerializeArgs(args) {
   if (args === void 0) {
     args = {};

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 1
clients/bolt-sdk/lib/index.js.map


+ 1 - 1
clients/bolt-sdk/lib/instructions/apply5.js

@@ -73,7 +73,7 @@ exports.apply5Struct = new beet.FixableBeetArgsStruct(
   ],
   "Apply5InstructionArgs"
 );
-exports.apply5InstructionDiscriminator = [223, 104, 24, 79, 252, 196, 14, 109];
+exports.apply5InstructionDiscriminator = [70, 164, 214, 28, 136, 116, 84, 153];
 function createApply5Instruction(accounts, args, programId) {
   var _a, _b;
   if (programId === void 0) {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
clients/bolt-sdk/lib/instructions/apply5.js.map


+ 1 - 1
clients/bolt-sdk/lib/instructions/initializeComponent.d.ts

@@ -5,7 +5,7 @@ export declare const initializeComponentStruct: beet.BeetArgsStruct<{
 }>;
 export interface InitializeComponentInstructionAccounts {
   payer: web3.PublicKey;
-  data: web3.PublicKey;
+  data?: web3.PublicKey;
   entity: web3.PublicKey;
   componentProgram: web3.PublicKey;
   authority?: web3.PublicKey;

+ 1 - 1
clients/bolt-sdk/lib/instructions/initializeComponent.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"initializeComponent.d.ts","sourceRoot":"","sources":["../../src/generated/instructions/initializeComponent.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAQxC,eAAO,MAAM,yBAAyB;8BACV,MAAM,EAAE;EAInC,CAAC;AAcF,MAAM,WAAW,sCAAsC;IACrD,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;IACrB,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IACvB,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC;IACjC,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,wBAAwB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAC1C,aAAa,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAC/B,uBAAuB,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;CAC9C;AAED,eAAO,MAAM,2CAA2C,UAEvD,CAAC;AAUF,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,sCAAsC,EAChD,SAAS,iBAAoE,+BAuD9E"}
+{"version":3,"file":"initializeComponent.d.ts","sourceRoot":"","sources":["../../src/generated/instructions/initializeComponent.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAQxC,eAAO,MAAM,yBAAyB;8BACV,MAAM,EAAE;EAInC,CAAC;AAcF,MAAM,WAAW,sCAAsC;IACrD,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IACvB,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC;IACjC,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,wBAAwB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAC1C,aAAa,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAC/B,uBAAuB,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;CAC9C;AAED,eAAO,MAAM,2CAA2C,UAEvD,CAAC;AAUF,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,sCAAsC,EAChD,SAAS,iBAAoE,+BAyD9E"}

+ 16 - 10
clients/bolt-sdk/lib/instructions/initializeComponent.js

@@ -59,7 +59,7 @@ exports.initializeComponentInstructionDiscriminator = [
   36, 143, 233, 113, 12, 234, 61, 30,
 ];
 function createInitializeComponentInstruction(accounts, programId) {
-  var _a, _b, _c;
+  var _a, _b, _c, _d;
   if (programId === void 0) {
     programId = new web3.PublicKey(
       "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n"
@@ -76,7 +76,13 @@ function createInitializeComponentInstruction(accounts, programId) {
       isSigner: true,
     },
     {
-      pubkey: accounts.data,
+      pubkey:
+        (_a = accounts.data) !== null && _a !== void 0
+          ? _a
+          : (0, index_1.FindComponentPda)(
+              accounts.componentProgram,
+              accounts.entity
+            ),
       isWritable: true,
       isSigner: false,
     },
@@ -92,22 +98,22 @@ function createInitializeComponentInstruction(accounts, programId) {
     },
     {
       pubkey:
-        (_a = accounts.authority) !== null && _a !== void 0 ? _a : programId,
+        (_b = accounts.authority) !== null && _b !== void 0 ? _b : programId,
       isWritable: false,
       isSigner: false,
     },
     {
       pubkey:
-        (_b = accounts.instructionSysvarAccount) !== null && _b !== void 0
-          ? _b
+        (_c = accounts.instructionSysvarAccount) !== null && _c !== void 0
+          ? _c
           : index_1.SYSVAR_INSTRUCTIONS_PUBKEY,
       isWritable: false,
       isSigner: false,
     },
     {
       pubkey:
-        (_c = accounts.systemProgram) !== null && _c !== void 0
-          ? _c
+        (_d = accounts.systemProgram) !== null && _d !== void 0
+          ? _d
           : web3.SystemProgram.programId,
       isWritable: false,
       isSigner: false,
@@ -115,11 +121,11 @@ function createInitializeComponentInstruction(accounts, programId) {
   ];
   if (accounts.anchorRemainingAccounts != null) {
     for (
-      var _i = 0, _d = accounts.anchorRemainingAccounts;
-      _i < _d.length;
+      var _i = 0, _e = accounts.anchorRemainingAccounts;
+      _i < _e.length;
       _i++
     ) {
-      var acc = _d[_i];
+      var acc = _e[_i];
       keys.push(acc);
     }
   }

+ 1 - 1
clients/bolt-sdk/lib/instructions/initializeComponent.js.map

@@ -1 +1 @@
-{"version":3,"file":"initializeComponent.js","sourceRoot":"","sources":["../../src/generated/instructions/initializeComponent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,8DAAkD;AAClD,oDAAwC;AACxC,kCAAsD;AAOzC,QAAA,yBAAyB,GAAG,IAAI,IAAI,CAAC,cAAc,CAG9D,CAAC,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACtE,oCAAoC,CACrC,CAAC;AAyBW,QAAA,2CAA2C,GAAG;IACzD,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE;CACnC,CAAC;AAUF,SAAgB,oCAAoC,CAClD,QAAgD,EAChD,SAA6E;;IAA7E,0BAAA,EAAA,gBAAgB,IAAI,CAAC,SAAS,CAAC,6CAA6C,CAAC;IAEtE,IAAA,IAAI,GAAI,iCAAyB,CAAC,SAAS,CAAC;QACjD,wBAAwB,EAAE,mDAA2C;KACtE,CAAC,GAFS,CAER;IACH,IAAM,IAA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KAAK;YACjB,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,MAAM,EAAE,MAAA,QAAQ,CAAC,wBAAwB,mCAAI,kCAA0B;YACvE,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,MAAM,EAAE,MAAA,QAAQ,CAAC,aAAa,mCAAI,IAAI,CAAC,aAAa,CAAC,SAAS;YAC9D,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;SAChB;KACF,CAAC;IAEF,IAAI,QAAQ,CAAC,uBAAuB,IAAI,IAAI,EAAE;QAC5C,KAAkB,UAAgC,EAAhC,KAAA,QAAQ,CAAC,uBAAuB,EAAhC,cAAgC,EAAhC,IAAgC,EAAE;YAA/C,IAAM,GAAG,SAAA;YACZ,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAChB;KACF;IAED,IAAM,EAAE,GAAG,IAAI,IAAI,CAAC,sBAAsB,CAAC;QACzC,SAAS,WAAA;QACT,IAAI,MAAA;QACJ,IAAI,MAAA;KACL,CAAC,CAAC;IACH,OAAO,EAAE,CAAC;AACZ,CAAC;AA3DD,oFA2DC"}

+ 30 - 11
clients/bolt-sdk/lib/transactions/transactions.d.ts

@@ -1,6 +1,6 @@
 import BN from "bn.js";
-import { type PublicKey, Transaction, type Connection } from "@solana/web3.js";
 import type web3 from "@solana/web3.js";
+import { type Connection, type PublicKey, Transaction } from "@solana/web3.js";
 export declare function InitializeNewWorld({
   payer,
   connection,
@@ -14,11 +14,11 @@ export declare function InitializeNewWorld({
 }>;
 export declare function AddEntity({
   payer,
-  worldPda,
+  world,
   connection,
 }: {
   payer: PublicKey;
-  worldPda: PublicKey;
+  world: PublicKey;
   connection: Connection;
 }): Promise<{
   transaction: Transaction;
@@ -27,14 +27,14 @@ export declare function AddEntity({
 }>;
 export declare function InitializeComponent({
   payer,
-  entityPda,
+  entity,
   componentId,
   seed,
   authority,
   anchorRemainingAccounts,
 }: {
   payer: PublicKey;
-  entityPda: PublicKey;
+  entity: PublicKey;
   componentId: PublicKey;
   seed?: string;
   authority?: web3.PublicKey;
@@ -43,23 +43,42 @@ export declare function InitializeComponent({
   transaction: Transaction;
   componentPda: PublicKey;
 }>;
+interface ApplySystemInstruction {
+  entity: PublicKey;
+  components: PublicKey[];
+  system: PublicKey;
+  authority: PublicKey;
+  seeds?: string[];
+  extraAccounts?: web3.AccountMeta[];
+  args?: object;
+}
+export declare function createApplySystemInstruction({
+  entity,
+  components,
+  system,
+  seeds,
+  authority,
+  extraAccounts,
+  args,
+}: ApplySystemInstruction): web3.TransactionInstruction;
 export declare function ApplySystem({
   authority,
-  boltSystem,
-  entityPda,
+  system,
+  entity,
   components,
   args,
   extraAccounts,
-  seed,
+  seeds,
 }: {
   authority: PublicKey;
-  boltSystem: PublicKey;
-  entityPda: PublicKey;
+  system: PublicKey;
+  entity: PublicKey;
   components: PublicKey[];
   args?: object;
   extraAccounts?: web3.AccountMeta[];
-  seed?: string[];
+  seeds?: string[];
 }): Promise<{
   transaction: Transaction;
 }>;
+export {};
 //# sourceMappingURL=transactions.d.ts.map

+ 1 - 1
clients/bolt-sdk/lib/transactions/transactions.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/generated/transactions/transactions.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,KAAK,SAAS,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAUxC,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,UAAU,GACX,EAAE;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,EAAE,CAAA;CAAE,CAA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AAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,SAAS,EACT,aAAa,EACb,IAAI,GACL,EAAE,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,CAyCtD;AAaD,wBAAsB,WAAW,CAAC,EAChC,SAAS,EACT,MAAM,EACN,MAAM,EACN,UAAU,EACV,IAAS,EACT,aAAa,EACb,KAAK,GACN,EAAE;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,GAAG,OAAO,CAAC;IAAE,WAAW,EAAE,WAAW,CAAA;CAAE,CAAC,CAaxC"}

+ 72 - 62
clients/bolt-sdk/lib/transactions/transactions.js

@@ -139,6 +139,7 @@ var __importDefault =
   };
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.ApplySystem =
+  exports.createApplySystemInstruction =
   exports.InitializeComponent =
   exports.AddEntity =
   exports.InitializeNewWorld =
@@ -184,23 +185,23 @@ function InitializeNewWorld(_a) {
 exports.InitializeNewWorld = InitializeNewWorld;
 function AddEntity(_a) {
   var payer = _a.payer,
-    worldPda = _a.worldPda,
+    world = _a.world,
     connection = _a.connection;
   return __awaiter(this, void 0, void 0, function () {
-    var world, entityId, entityPda, createEntityIx;
+    var worldInstance, entityId, entityPda, createEntityIx;
     return __generator(this, function (_b) {
       switch (_b.label) {
         case 0:
-          return [4, index_1.World.fromAccountAddress(connection, worldPda)];
+          return [4, index_1.World.fromAccountAddress(connection, world)];
         case 1:
-          world = _b.sent();
-          entityId = new bn_js_1.default(world.entities);
+          worldInstance = _b.sent();
+          entityId = new bn_js_1.default(worldInstance.entities);
           entityPda = (0, index_1.FindEntityPda)(
-            new bn_js_1.default(world.id),
+            new bn_js_1.default(worldInstance.id),
             entityId
           );
           createEntityIx = (0, index_1.createAddEntityInstruction)({
-            world: worldPda,
+            world: world,
             payer: payer,
             entity: entityPda,
           });
@@ -219,7 +220,7 @@ function AddEntity(_a) {
 exports.AddEntity = AddEntity;
 function InitializeComponent(_a) {
   var payer = _a.payer,
-    entityPda = _a.entityPda,
+    entity = _a.entity,
     componentId = _a.componentId,
     _b = _a.seed,
     seed = _b === void 0 ? "" : _b,
@@ -228,14 +229,10 @@ function InitializeComponent(_a) {
   return __awaiter(this, void 0, void 0, function () {
     var componentPda, initComponentIx;
     return __generator(this, function (_c) {
-      componentPda = (0, index_1.FindComponentPda)(
-        componentId,
-        entityPda,
-        seed
-      );
+      componentPda = (0, index_1.FindComponentPda)(componentId, entity, seed);
       initComponentIx = (0, index_1.createInitializeComponentInstruction)({
         payer: payer,
-        entity: entityPda,
+        entity: entity,
         data: componentPda,
         componentProgram: componentId,
         authority: authority,
@@ -252,63 +249,76 @@ function InitializeComponent(_a) {
   });
 }
 exports.InitializeComponent = InitializeComponent;
+function createApplySystemInstruction(_a) {
+  var entity = _a.entity,
+    components = _a.components,
+    system = _a.system,
+    seeds = _a.seeds,
+    authority = _a.authority,
+    extraAccounts = _a.extraAccounts,
+    args = _a.args;
+  var instructionFunctions = {
+    createApplyInstruction: index_1.createApplyInstruction,
+    createApply2Instruction: index_1.createApply2Instruction,
+    createApply3Instruction: index_1.createApply3Instruction,
+    createApply4Instruction: index_1.createApply4Instruction,
+    createApply5Instruction: index_1.createApply5Instruction,
+  };
+  if (components.length === 0) throw new Error("No components provided");
+  if (seeds == null) seeds = new Array(components.length).fill("");
+  if (seeds.length !== components.length)
+    throw new Error("Seed length does not match components length");
+  var componentPdas = [];
+  for (var i = 0; i < components.length; i++) {
+    var componentPda = (0, index_1.FindComponentPda)(
+      components[i],
+      entity,
+      seeds[i]
+    );
+    componentPdas.push(componentPda);
+  }
+  if (components.length < 1 || components.length > MAX_COMPONENTS) {
+    throw new Error(
+      "Not implemented for component counts outside 1-".concat(MAX_COMPONENTS)
+    );
+  }
+  var instructionArgs = {
+    authority: authority,
+    boltSystem: system,
+    anchorRemainingAccounts: extraAccounts,
+  };
+  components.forEach(function (component, index) {
+    instructionArgs[getBoltComponentProgramName(index, components.length)] =
+      component;
+    instructionArgs[getBoltComponentName(index, components.length)] =
+      componentPdas[index];
+  });
+  var functionName = getApplyInstructionFunctionName(components.length);
+  return instructionFunctions[functionName](instructionArgs, {
+    args: (0, index_1.SerializeArgs)(args),
+  });
+}
+exports.createApplySystemInstruction = createApplySystemInstruction;
 function ApplySystem(_a) {
   var authority = _a.authority,
-    boltSystem = _a.boltSystem,
-    entityPda = _a.entityPda,
+    system = _a.system,
+    entity = _a.entity,
     components = _a.components,
     _b = _a.args,
     args = _b === void 0 ? {} : _b,
     extraAccounts = _a.extraAccounts,
-    seed = _a.seed;
+    seeds = _a.seeds;
   return __awaiter(this, void 0, void 0, function () {
-    var instructionFunctions,
-      componentPdas,
-      instructionArgs,
-      functionName,
-      applySystemIx;
+    var applySystemIx;
     return __generator(this, function (_c) {
-      instructionFunctions = {
-        createApplyInstruction: index_1.createApplyInstruction,
-        createApply2Instruction: index_1.createApply2Instruction,
-        createApply3Instruction: index_1.createApply3Instruction,
-        createApply4Instruction: index_1.createApply4Instruction,
-        createApply5Instruction: index_1.createApply5Instruction,
-      };
-      if (components.length === 0) throw new Error("No components provided");
-      if (seed == null) seed = new Array(components.length).fill("");
-      if (seed.length !== components.length)
-        throw new Error("Seed length does not match components length");
-      componentPdas = [];
-      components.forEach(function (component) {
-        var componentPda = (0, index_1.FindComponentPda)(
-          component,
-          entityPda,
-          ""
-        );
-        componentPdas.push(componentPda);
-      });
-      if (components.length < 1 || components.length > MAX_COMPONENTS) {
-        throw new Error(
-          "Not implemented for component counts outside 1-".concat(
-            MAX_COMPONENTS
-          )
-        );
-      }
-      instructionArgs = {
+      applySystemIx = createApplySystemInstruction({
+        entity: entity,
+        components: components,
+        system: system,
         authority: authority,
-        boltSystem: boltSystem,
-        anchorRemainingAccounts: extraAccounts,
-      };
-      components.forEach(function (component, index) {
-        instructionArgs[getBoltComponentProgramName(index, components.length)] =
-          component;
-        instructionArgs[getBoltComponentName(index, components.length)] =
-          componentPdas[index];
-      });
-      functionName = getApplyInstructionFunctionName(components.length);
-      applySystemIx = instructionFunctions[functionName](instructionArgs, {
-        args: (0, index_1.SerializeArgs)(args),
+        seeds: seeds,
+        extraAccounts: extraAccounts,
+        args: args,
       });
       return [
         2,

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
clients/bolt-sdk/lib/transactions/transactions.js.map


+ 20 - 7
clients/bolt-sdk/src/generated/index.ts

@@ -1,5 +1,5 @@
 import { PublicKey } from "@solana/web3.js";
-import type BN from "bn.js";
+import BN from "bn.js";
 export * from "./accounts";
 export * from "./instructions";
 export * from "./transactions/transactions";
@@ -34,27 +34,33 @@ export function FindWorldRegistryPda(
 }
 
 export function FindWorldPda(
-  id: BN,
+  id: BN | string | number | Uint8Array,
   programId: PublicKey = new PublicKey(PROGRAM_ID)
 ) {
+  id = CastToBN(id);
+  const idBuffer = Buffer.from(id.toArrayLike(Buffer, "be", 8));
   return PublicKey.findProgramAddressSync(
-    [Buffer.from("world"), id.toBuffer("be", 8)],
+    [Buffer.from("world"), idBuffer],
     programId
   )[0];
 }
 
 export function FindEntityPda(
-  worldId: BN,
-  entityId: BN,
+  worldId: BN | string | number | Uint8Array,
+  entityId: BN | string | number | Uint8Array,
   extraSeed?: string,
   programId: PublicKey = new PublicKey(PROGRAM_ID)
 ) {
-  const seeds = [Buffer.from("entity"), worldId.toBuffer("be", 8)];
+  worldId = CastToBN(worldId);
+  entityId = CastToBN(entityId);
+  const worldIdBuffer = Buffer.from(worldId.toArrayLike(Buffer, "be", 8));
+  const entityIdBuffer = Buffer.from(entityId.toArrayLike(Buffer, "be", 8));
+  const seeds = [Buffer.from("entity"), worldIdBuffer];
   if (extraSeed != null) {
     seeds.push(Buffer.from(new Uint8Array(8)));
     seeds.push(Buffer.from(extraSeed));
   } else {
-    seeds.push(entityId.toBuffer("be", 8));
+    seeds.push(entityIdBuffer);
   }
   return PublicKey.findProgramAddressSync(seeds, programId)[0];
 }
@@ -70,6 +76,13 @@ export function FindComponentPda(
   )[0];
 }
 
+function CastToBN(id: BN | string | number | Uint8Array) {
+  if (!(id instanceof BN)) {
+    id = new BN(id);
+  }
+  return id;
+}
+
 /**
  * Serialize arguments to a buffer
  * @param args

+ 1 - 1
clients/bolt-sdk/src/generated/instructions/apply5.ts

@@ -71,7 +71,7 @@ export interface Apply5InstructionAccounts {
 }
 
 export const apply5InstructionDiscriminator = [
-  223, 104, 24, 79, 252, 196, 14, 109,
+  70, 164, 214, 28, 136, 116, 84, 153,
 ];
 
 /**

+ 5 - 3
clients/bolt-sdk/src/generated/instructions/initializeComponent.ts

@@ -7,7 +7,7 @@
 
 import * as beet from "@metaplex-foundation/beet";
 import * as web3 from "@solana/web3.js";
-import { SYSVAR_INSTRUCTIONS_PUBKEY } from "../index";
+import { FindComponentPda, SYSVAR_INSTRUCTIONS_PUBKEY } from "../index";
 
 /**
  * @category Instructions
@@ -35,7 +35,7 @@ export const initializeComponentStruct = new beet.BeetArgsStruct<{
  */
 export interface InitializeComponentInstructionAccounts {
   payer: web3.PublicKey;
-  data: web3.PublicKey;
+  data?: web3.PublicKey;
   entity: web3.PublicKey;
   componentProgram: web3.PublicKey;
   authority?: web3.PublicKey;
@@ -70,7 +70,9 @@ export function createInitializeComponentInstruction(
       isSigner: true,
     },
     {
-      pubkey: accounts.data,
+      pubkey:
+        accounts.data ??
+        FindComponentPda(accounts.componentProgram, accounts.entity),
       isWritable: true,
       isSigner: false,
     },

+ 80 - 51
clients/bolt-sdk/src/generated/transactions/transactions.ts

@@ -1,5 +1,10 @@
 import {
   createAddEntityInstruction,
+  createApply2Instruction,
+  createApply3Instruction,
+  createApply4Instruction,
+  createApply5Instruction,
+  createApplyInstruction,
   createInitializeComponentInstruction,
   createInitializeNewWorldInstruction,
   FindComponentPda,
@@ -9,15 +14,10 @@ import {
   Registry,
   SerializeArgs,
   World,
-  createApplyInstruction,
-  createApply2Instruction,
-  createApply3Instruction,
-  createApply4Instruction,
-  createApply5Instruction,
 } from "../index";
 import BN from "bn.js";
-import { type PublicKey, Transaction, type Connection } from "@solana/web3.js";
 import type web3 from "@solana/web3.js";
+import { type Connection, type PublicKey, Transaction } from "@solana/web3.js";
 
 const MAX_COMPONENTS = 5;
 
@@ -59,19 +59,19 @@ export async function InitializeNewWorld({
  */
 export async function AddEntity({
   payer,
-  worldPda,
+  world,
   connection,
 }: {
   payer: PublicKey;
-  worldPda: PublicKey;
+  world: PublicKey;
   connection: Connection;
 }): Promise<{ transaction: Transaction; entityPda: PublicKey; entityId: BN }> {
-  const world = await World.fromAccountAddress(connection, worldPda);
-  const entityId = new BN(world.entities);
-  const entityPda = FindEntityPda(new BN(world.id), entityId);
+  const worldInstance = await World.fromAccountAddress(connection, world);
+  const entityId = new BN(worldInstance.entities);
+  const entityPda = FindEntityPda(new BN(worldInstance.id), entityId);
 
   const createEntityIx = createAddEntityInstruction({
-    world: worldPda,
+    world,
     payer,
     entity: entityPda,
   });
@@ -87,30 +87,30 @@ export async function AddEntity({
  * @param payer
  * @param entityPda
  * @param componentId
- * @param seed
+ * @param seeds
  * @param authority
  * @param anchorRemainingAccounts
  * @constructor
  */
 export async function InitializeComponent({
   payer,
-  entityPda,
+  entity,
   componentId,
   seed = "",
   authority,
   anchorRemainingAccounts,
 }: {
   payer: PublicKey;
-  entityPda: PublicKey;
+  entity: PublicKey;
   componentId: PublicKey;
   seed?: string;
   authority?: web3.PublicKey;
   anchorRemainingAccounts?: web3.AccountMeta[];
 }): Promise<{ transaction: Transaction; componentPda: PublicKey }> {
-  const componentPda = FindComponentPda(componentId, entityPda, seed);
+  const componentPda = FindComponentPda(componentId, entity, seed);
   const initComponentIx = createInitializeComponentInstruction({
     payer,
-    entity: entityPda,
+    entity,
     data: componentPda,
     componentProgram: componentId,
     authority,
@@ -123,34 +123,25 @@ export async function InitializeComponent({
   };
 }
 
-/**
- * Apply a system to an entity and its components
- * @param authority
- * @param boltSystem
- * @param entityPda
- * @param components
- * @param args
- * @param extraAccounts
- * @param seed
- * @constructor
- */
-export async function ApplySystem({
-  authority,
-  boltSystem,
-  entityPda,
-  components,
-  args = {},
-  extraAccounts,
-  seed,
-}: {
-  authority: PublicKey;
-  boltSystem: PublicKey;
-  entityPda: PublicKey;
+interface ApplySystemInstruction {
+  entity: PublicKey;
   components: PublicKey[];
-  args?: object;
+  system: PublicKey;
+  authority: PublicKey;
+  seeds?: string[];
   extraAccounts?: web3.AccountMeta[];
-  seed?: string[];
-}): Promise<{ transaction: Transaction }> {
+  args?: object;
+}
+
+export function createApplySystemInstruction({
+  entity,
+  components,
+  system,
+  seeds,
+  authority,
+  extraAccounts,
+  args,
+}: ApplySystemInstruction): web3.TransactionInstruction {
   const instructionFunctions = {
     createApplyInstruction,
     createApply2Instruction,
@@ -159,15 +150,15 @@ export async function ApplySystem({
     createApply5Instruction,
   };
   if (components.length === 0) throw new Error("No components provided");
-  if (seed == null) seed = new Array(components.length).fill("");
-  if (seed.length !== components.length)
+  if (seeds == null) seeds = new Array(components.length).fill("");
+  if (seeds.length !== components.length)
     throw new Error("Seed length does not match components length");
   const componentPdas: PublicKey[] = [];
-  components.forEach((component) => {
-    const componentPda = FindComponentPda(component, entityPda, "");
-    componentPdas.push(componentPda);
-  });
 
+  for (let i = 0; i < components.length; i++) {
+    const componentPda = FindComponentPda(components[i], entity, seeds[i]);
+    componentPdas.push(componentPda);
+  }
   if (components.length < 1 || components.length > MAX_COMPONENTS) {
     throw new Error(
       `Not implemented for component counts outside 1-${MAX_COMPONENTS}`
@@ -176,7 +167,7 @@ export async function ApplySystem({
 
   const instructionArgs = {
     authority,
-    boltSystem,
+    boltSystem: system,
     anchorRemainingAccounts: extraAccounts,
   };
 
@@ -188,10 +179,48 @@ export async function ApplySystem({
   });
 
   const functionName = getApplyInstructionFunctionName(components.length);
-  const applySystemIx = instructionFunctions[functionName](instructionArgs, {
+  return instructionFunctions[functionName](instructionArgs, {
     args: SerializeArgs(args),
   });
+}
 
+/**
+ * Apply a system to an entity and its components
+ * @param authority
+ * @param system
+ * @param entity
+ * @param components
+ * @param args
+ * @param extraAccounts
+ * @param seeds
+ * @constructor
+ */
+export async function ApplySystem({
+  authority,
+  system,
+  entity,
+  components,
+  args = {},
+  extraAccounts,
+  seeds,
+}: {
+  authority: PublicKey;
+  system: PublicKey;
+  entity: PublicKey;
+  components: PublicKey[];
+  args?: object;
+  extraAccounts?: web3.AccountMeta[];
+  seeds?: string[];
+}): Promise<{ transaction: Transaction }> {
+  const applySystemIx = createApplySystemInstruction({
+    entity,
+    components,
+    system,
+    authority,
+    seeds,
+    extraAccounts,
+    args,
+  });
   return {
     transaction: new Transaction().add(applySystemIx),
   };

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio