Browse Source

Update accountsArray types

Ian Macalinao 4 years ago
parent
commit
9cdb365190
1 changed files with 11 additions and 6 deletions
  1. 11 6
      ts/src/program/namespace/instruction.ts

+ 11 - 6
ts/src/program/namespace/instruction.ts

@@ -1,4 +1,8 @@
-import { PublicKey, TransactionInstruction } from "@solana/web3.js";
+import {
+  AccountMeta,
+  PublicKey,
+  TransactionInstruction,
+} from "@solana/web3.js";
 import { IdlAccount, IdlInstruction, IdlAccountItem } from "../../idl";
 import { IdlError } from "../../error";
 import {
@@ -48,17 +52,18 @@ export default class InstructionNamespaceFactory {
     return ix;
   }
 
-  public static accountsArray(ctx: Accounts, accounts: IdlAccountItem[]): any {
+  public static accountsArray(
+    ctx: Accounts,
+    accounts: IdlAccountItem[]
+  ): AccountMeta[] {
     return accounts
       .map((acc: IdlAccountItem) => {
         // Nested accounts.
-        // @ts-ignore
-        const nestedAccounts: IdlAccountItem[] | undefined = acc.accounts;
-        if (nestedAccounts !== undefined) {
+        if ("accounts" in acc) {
           const rpcAccs = ctx[acc.name] as Accounts;
           return InstructionNamespaceFactory.accountsArray(
             rpcAccs,
-            nestedAccounts
+            acc.accounts
           ).flat();
         } else {
           const account: IdlAccount = acc as IdlAccount;