Browse Source

fix: 0 is falsey for arg filling (#2258)

Noah Prince 2 years ago
parent
commit
91a2b7ec96

+ 1 - 1
ts/packages/anchor/src/program/accounts-resolver.ts

@@ -335,7 +335,7 @@ export class AccountsResolver<IDL extends Idl, I extends AllInstructions<IDL>> {
 
   private async toBufferArg(seedDesc: IdlSeed): Promise<Buffer | undefined> {
     const argValue = this.argValue(seedDesc);
-    if (!argValue) {
+    if (typeof argValue === "undefined") {
       return;
     }
     return this.toBufferValue(

+ 11 - 0
ts/packages/anchor/src/program/namespace/methods.ts

@@ -173,6 +173,17 @@ export class MethodsBuilder<IDL extends Idl, I extends AllInstructions<IDL>> {
     });
   }
 
+  public async rpcAndKeys(options?: ConfirmOptions): Promise<{
+    pubkeys: Partial<InstructionAccountAddresses<IDL, I>>;
+    signature: TransactionSignature;
+  }> {
+    const pubkeys = await this.pubkeys();
+    return {
+      pubkeys,
+      signature: await this.rpc(options),
+    };
+  }
+
   public async view(options?: ConfirmOptions): Promise<any> {
     if (this._autoResolveAccounts) {
       await this._accountsResolver.resolve();