diff --git a/test/token.js b/test/token.js index 6e01709..632c2e8 100644 --- a/test/token.js +++ b/test/token.js @@ -74,7 +74,6 @@ test('balanceOf(address) invalid address', async (t) => { await t.throwsAsync(token.balanceOf({ }), TypeError) await t.throwsAsync(token.balanceOf(1234), TypeError) await t.throwsAsync(token.balanceOf([]), TypeError) - await t.throwsAsync(token.balanceOf(TEST_OWNER_ADDRESS), Error) await t.throwsAsync(token.balanceOf('did:ara:1234'), Error) await t.throwsAsync(token.balanceOf(RANDOM_DID), Error) }) diff --git a/token.js b/token.js index af45b55..676f8da 100644 --- a/token.js +++ b/token.js @@ -29,9 +29,9 @@ const { * @return {Number} * @throws {Error|TypeError} */ -async function balanceOf(account, keyringOpts) { +async function balanceOf(acct, keyringOpts) { try { - account = await _normalizeIDInput(account) + acct = await _normalizeIDInput(acct, keyringOpts) } catch (err) { throw err } @@ -42,7 +42,7 @@ async function balanceOf(account, keyringOpts) { abi: tokenAbi, address: ARA_TOKEN_ADDRESS, functionName: 'balanceOf', - arguments: [ account ] + arguments: [ acct ] }) } catch (err) { throw err @@ -537,11 +537,11 @@ function _validateApprovalOpts(opts) { } } -async function _normalizeIDInput(id) { +async function _normalizeIDInput(id, keyringOpts) { try { if (!isAddress(id)) { id = getIdentifier(id) - id = await getAddressFromDID(id) + id = await getAddressFromDID(id, keyringOpts) } } catch (err) { throw err