Skip to content

Commit

Permalink
feat: default contract args
Browse files Browse the repository at this point in the history
  • Loading branch information
janek26 committed Mar 10, 2022
1 parent a9b4103 commit 2a3956d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/contract/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export class Contract implements ContractInterface {
}, [] as Result);
}

public invoke(method: string, args: Array<any>): Promise<AddTransactionResponse> {
public invoke(method: string, args: Array<any> = []): Promise<AddTransactionResponse> {
// ensure contract is connected
assert(this.address !== null, 'contract isnt connected to an address');
// validate method and args
Expand Down Expand Up @@ -563,7 +563,7 @@ export class Contract implements ContractInterface {
});
}

public async call(method: string, args: Array<any>): Promise<Result> {
public async call(method: string, args: Array<any> = []): Promise<Result> {
// ensure contract is connected
assert(this.address !== null, 'contract isnt connected to an address');

Expand Down Expand Up @@ -591,7 +591,7 @@ export class Contract implements ContractInterface {
.then((x) => this.parseResponse(method, x.result));
}

public async estimate(_method: string, _args: Array<any>) {
public async estimate(_method: string, _args: Array<any> = []) {
// TODO; remove error as soon as estimate fees are supported
throw Error('Estimation of the fees are not yet supported');
// // ensure contract is connected
Expand All @@ -610,7 +610,7 @@ export class Contract implements ContractInterface {
// });
}

public populate(method: string, args: Array<any>): Invocation {
public populate(method: string, args: Array<any> = []): Invocation {
const { inputs } = this.abi.find((abi) => abi.name === method) as FunctionAbi;
return {
contractAddress: this.address,
Expand Down
8 changes: 4 additions & 4 deletions src/contract/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export abstract class ContractInterface {
* @param args Array of the arguments for the call
* @returns Result of the call as an array with key value pars
*/
public abstract call(method: string, args: Array<any>): Promise<Result>;
public abstract call(method: string, args?: Array<any>): Promise<Result>;

/**
* Invokes a method on a contract
Expand All @@ -66,15 +66,15 @@ export abstract class ContractInterface {
* @param args Array of the arguments for the invoke
* @returns Add Transaction Response
*/
public abstract invoke(method: string, args: Array<any>): Promise<AddTransactionResponse>;
public abstract invoke(method: string, args?: Array<any>): Promise<AddTransactionResponse>;

/**
* Calls a method on a contract
*
* @param method name of the method
* @param args Array of the arguments for the call
*/
public abstract estimate(method: string, args: Array<any>): Promise<any>;
public abstract estimate(method: string, args?: Array<any>): Promise<any>;

/**
* Calls a method on a contract
Expand All @@ -83,5 +83,5 @@ export abstract class ContractInterface {
* @param args Array of the arguments for the call
* @returns Invocation objet
*/
public abstract populate(method: string, args: Array<any>): Invocation;
public abstract populate(method: string, args?: Array<any>): Invocation;
}

0 comments on commit 2a3956d

Please sign in to comment.