rename method for clarity since we return a Token and not tokenMetadata
This commit is contained in:
@@ -24,7 +24,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
|
||||
const addresses = await tokenRegistryContract.getTokenAddresses.call();
|
||||
const tokenPromises: Array<Promise<Token|undefined>> = _.map(
|
||||
addresses,
|
||||
(address: string) => (this.getTokenMetadataIfExistsAsync(address)),
|
||||
(address: string) => (this.getTokenIfExistsAsync(address)),
|
||||
);
|
||||
const tokens = await Promise.all(tokenPromises);
|
||||
return tokens as Token[];
|
||||
@@ -33,7 +33,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
|
||||
* Retrieves a token by address currently listed in the Token Registry smart contract
|
||||
* @return An object that conforms to the Token interface or undefined if token not found.
|
||||
*/
|
||||
public async getTokenMetadataIfExistsAsync(address: string): Promise<Token|undefined> {
|
||||
public async getTokenIfExistsAsync(address: string): Promise<Token|undefined> {
|
||||
assert.isETHAddressHex('address', address);
|
||||
|
||||
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
|
||||
|
@@ -38,19 +38,19 @@ describe('TokenRegistryWrapper', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('#getTokenMetadataIfExistsAsync', () => {
|
||||
describe('#getTokenIfExistsAsync', () => {
|
||||
it('should return the token added to the tokenRegistry during the migration', async () => {
|
||||
const tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
const aToken = tokens[0];
|
||||
|
||||
const token = await zeroEx.tokenRegistry.getTokenMetadataIfExistsAsync(aToken.address);
|
||||
const token = await zeroEx.tokenRegistry.getTokenIfExistsAsync(aToken.address);
|
||||
const schemaValidator = new SchemaValidator();
|
||||
const validationResult = schemaValidator.validate(token, tokenSchema);
|
||||
expect(validationResult.errors).to.have.lengthOf(0);
|
||||
});
|
||||
it('should return return undefined when passed a token address not in the tokenRegistry', async () => {
|
||||
const tokenIfExists = await zeroEx.tokenRegistry.getTokenMetadataIfExistsAsync(unregisteredTokenAddress);
|
||||
const unregisteredTokenAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
|
||||
const tokenIfExists = await zeroEx.tokenRegistry.getTokenIfExistsAsync(unregisteredTokenAddress);
|
||||
expect(tokenIfExists).to.be.undefined();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user