Cleanup/fix ABI arg consistency (#1126)

This commit is contained in:
Jaco Greeff
2019-07-14 18:24:42 +02:00
committed by GitHub
parent a091464172
commit 729db495a8
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { CodecArg, Constructor } from '@polkadot/types/types';
import { ContractABIFn, ContractABIArg, ContractABIMethod, ContractABIMethodBase, ContractABITypes } from './types';
import { ContractABIFn, ContractABIFnArg, ContractABIMethod, ContractABIMethodBase, ContractABITypes } from './types';
import { Compact, createClass } from '@polkadot/types';
import { assert, isString, isUndefined, stringCamelCase } from '@polkadot/util';
@@ -26,7 +26,7 @@ export function typeToString (type: ContractABITypes): string {
throw new Error(`Unknown type specified ${JSON.stringify(type)}`);
}
export function createArgClass (args: ContractABIArg[], baseDef: Record<string, string>): Constructor {
export function createArgClass (args: ContractABIFnArg[], baseDef: Record<string, string>): Constructor {
return createClass(
JSON.stringify(
args.reduce((base: Record<string, any>, { name, type }): Record<string, any> => {
@@ -39,7 +39,7 @@ export function createArgClass (args: ContractABIArg[], baseDef: Record<string,
}
export function createMethod (name: string, method: Partial<ContractABIMethod> & ContractABIMethodBase): ContractABIFn {
const args: ContractABIArg[] = method.args.map(({ name, type }): ContractABIArg => ({
const args: ContractABIFnArg[] = method.args.map(({ name, type }): ContractABIFnArg => ({
name: stringCamelCase(name),
type: typeToString(type)
}));
+2 -2
View File
@@ -53,13 +53,13 @@ export interface ContractABI {
name: string;
}
export interface ContractABIMetaArg {
export interface ContractABIFnArg {
name: string;
type: string;
}
export interface ContractABIMeta {
args: ContractABIArg[];
args: ContractABIFnArg[];
isConstant: boolean;
type: string | null;
}