浏览代码

Update generate-clients.mjs

Loris Leiva 1 年之前
父节点
当前提交
b9deaa0adf
共有 1 个文件被更改,包括 14 次插入30 次删除
  1. 14 30
      template/clients/base/scripts/generate-clients.mjs

+ 14 - 30
template/clients/base/scripts/generate-clients.mjs

@@ -9,17 +9,13 @@ const kinobi = k.createFromIdls(getAllProgramIdls());
 // Update accounts.
 kinobi.update(
   k.updateAccountsVisitor({
-    addressLookupTable: {
+    counter: {
       seeds: [
+        k.constantPdaSeedNodeFromString("counter"),
         k.variablePdaSeedNode(
           "authority",
           k.publicKeyTypeNode(),
-          "The address of the LUT's authority"
-        ),
-        k.variablePdaSeedNode(
-          "recentSlot",
-          k.numberTypeNode("u64"),
-          "The recent slot associated with the LUT"
+          "The authority of the counter account"
         ),
       ],
     },
@@ -29,41 +25,29 @@ kinobi.update(
 // Update instructions.
 kinobi.update(
   k.updateInstructionsVisitor({
-    createLookupTable: {
-      byteDeltas: [k.instructionByteDeltaNode(k.numberValueNode(56))],
+    create: {
+      byteDeltas: [k.instructionByteDeltaNode(k.accountLinkNode("counter"))],
       accounts: {
-        address: { defaultValue: k.pdaValueNode("addressLookupTable") },
+        counter: { defaultValue: k.pdaValueNode("counter") },
         payer: { defaultValue: k.accountValueNode("authority") },
       },
+    },
+    increment: {
+      accounts: {
+        counter: { defaultValue: k.pdaValueNode("counter") },
+      },
       arguments: {
-        bump: { defaultValue: k.accountBumpValueNode("address") },
+        amount: { defaultValue: k.noneValueNode() },
       },
     },
-    extendLookupTable: {
-      byteDeltas: [
-        k.instructionByteDeltaNode(
-          k.resolverValueNode("resolveExtendLookupTableBytes", {
-            dependsOn: [k.argumentValueNode("addresses")],
-          })
-        ),
-      ],
-    },
   })
 );
 
 // Set account discriminators.
+const key = (name) => ({ field: "key", value: k.enumValueNode("Key", name) });
 kinobi.update(
   k.setAccountDiscriminatorFromFieldVisitor({
-    addressLookupTable: { field: "discriminator", value: k.numberValueNode(1) },
-  })
-);
-
-// Set default values for structs.
-kinobi.update(
-  k.setStructDefaultValuesVisitor({
-    addressLookupTable: {
-      padding: { value: k.numberValueNode(0), strategy: "omitted" },
-    },
+    counter: key("counter"),
   })
 );