Browse Source

quick updates

jpcaulfi 3 years ago
parent
commit
2bb022d614

+ 1 - 1
accounts/create-system-account/native/program/src/lib.rs

@@ -33,7 +33,7 @@ fn process_instruction(
             &payer.key,             // From pubkey
             &new_account.key,       // To pubkey
             LAMPORTS_PER_SOL,       // Lamports (1 SOL)
-            32,                     // Space
+            0,                      // Space
             &system_program::ID,    // Owner
         ),
         &[

+ 7 - 7
program-basics/custom-instruction-data/native/tests/test.ts

@@ -30,7 +30,11 @@ describe("custom-instruction-data", () => {
         };
     };
 
-    class InstructionData extends Assignable {};
+    class InstructionData extends Assignable {
+        toBuffer() {
+            return Buffer.from(borsh.serialize(InstructionDataSchema, this));
+        }
+    };
 
     const InstructionDataSchema = new Map([
         [
@@ -56,21 +60,17 @@ describe("custom-instruction-data", () => {
             height: 10
         });
 
-        function toBuffer(obj: InstructionData): Buffer {
-            return Buffer.from(borsh.serialize(InstructionDataSchema, obj));
-        }
-
         let ix1 = new TransactionInstruction({
             keys: [
                 {pubkey: payer.publicKey, isSigner: true, isWritable: true}
             ],
             programId: program.publicKey,
-            data: toBuffer(jimmy),
+            data: jimmy.toBuffer(),
         });
 
         let ix2 = new TransactionInstruction({
             ...ix1,
-            data: toBuffer(mary),
+            data: mary.toBuffer(),
         });
 
         await sendAndConfirmTransaction(