diff --git a/packages/harmony-contract/src/abi/abiCoder.ts b/packages/harmony-contract/src/abi/abiCoder.ts index b61e62b..e99d6e0 100644 --- a/packages/harmony-contract/src/abi/abiCoder.ts +++ b/packages/harmony-contract/src/abi/abiCoder.ts @@ -197,8 +197,8 @@ const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); export const defaultCoerceFunc: CoerceFunc = (type: string, value: any): any => { const match = type.match(paramTypeNumber); if (match && parseInt(match[2], 10) <= 48) { - // return value.toNumber(); - return value.toString('hex'); + return value.toNumber(); + //return value.toString('hex'); } return value; }; diff --git a/packages/harmony-contract/src/methods/method.ts b/packages/harmony-contract/src/methods/method.ts index cf4a5c8..b689424 100644 --- a/packages/harmony-contract/src/methods/method.ts +++ b/packages/harmony-contract/src/methods/method.ts @@ -75,7 +75,7 @@ export class ContractMethod { } async call(options: any, blockNumber: any = 'latest') { try { - options = { ...this.contract.options, ...options }; + options = { ...this.contract.options, data: this.encodeABI(), ...options }; const shardID = options !== undefined && options.shardID !== undefined ? options.shardID diff --git a/packages/harmony-crypto/src/keyTool.ts b/packages/harmony-crypto/src/keyTool.ts index 29f5959..7bb1f91 100644 --- a/packages/harmony-crypto/src/keyTool.ts +++ b/packages/harmony-crypto/src/keyTool.ts @@ -9,7 +9,8 @@ import * as errors from './errors'; import { keccak256 } from './keccak256'; import { randomBytes } from './random'; -import { isPrivateKey, strip0x, isAddress } from '@harmony-js/utils'; +import { isPrivateKey, strip0x, isAddress, isBech32Address } from '@harmony-js/utils'; +import { fromBech32 } from './bech32'; import { encode } from './rlp'; const secp256k1 = elliptic.ec('secp256k1'); @@ -81,6 +82,9 @@ export const getAddressFromPublicKey = (publicKey: string): string => { * @return {string} checksumed address */ export const toChecksumAddress = (address: string): string => { + if (typeof address === 'string' && isBech32Address(address)) { + address = fromBech32(address); + } if (typeof address !== 'string' || !address.match(/^0x[0-9A-Fa-f]{40}$/)) { errors.throwError('invalid address', errors.INVALID_ARGUMENT, { arg: 'address',