Skip to content

Commit

Permalink
fix(parseResponse): revert the changes from parseResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcticae committed Jun 20, 2022
1 parent 6d7ab29 commit d51996f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/contract/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
Overrides,
ParsedStruct,
Result,
ResultAccessor,
StructAbi,
} from '../types';
import { BigNumberish, toBN, toFelt } from '../utils/number';
Expand Down Expand Up @@ -524,10 +523,7 @@ export class Contract implements ContractInterface {
* @param response - response from the method
* @return - parsed response corresponding to the abi
*/
protected parseResponse(method: string, response?: string[]): Result {
if (!response) {
return undefined;
}
protected parseResponse(method: string, response: string[]): Result {
const { outputs } = this.abi.find((abi) => abi.name === method) as FunctionAbi;
const responseIterator = response.flat()[Symbol.iterator]();
const resultObject = outputs.flat().reduce((acc, output) => {
Expand All @@ -541,7 +537,7 @@ export class Contract implements ContractInterface {
acc.push(value);
acc[key] = value;
return acc;
}, [] as ResultAccessor);
}, [] as Result);
}

public invoke(
Expand Down
3 changes: 1 addition & 2 deletions src/types/contract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export type AsyncContractFunction<T = any> = (...args: Array<any>) => Promise<T>;
export type ContractFunction = (...args: Array<any>) => any;
export interface ResultAccessor extends Array<any> {
export interface Result extends Array<any> {
[key: string]: any;
}
export type Result = ResultAccessor | undefined;

0 comments on commit d51996f

Please sign in to comment.