Skip to content

Commit

Permalink
refactor: call erc725Version only 1 for getAllData
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugoo committed Oct 30, 2021
1 parent 47dfd6b commit 86c856e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/providers/ethereumProviderWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ export class EthereumProviderWrapper {
);
}

async getData(address: string, keyHash: string) {
const erc725Version = await this.getErc725YVersion(address);
async getData(
address: string,
keyHash: string,
providedErc725Version?: ERC725_VERSION,
) {
const erc725Version =
providedErc725Version ?? (await this.getErc725YVersion(address));

switch (erc725Version) {
case 'ERC725':
Expand Down Expand Up @@ -125,9 +130,11 @@ export class EthereumProviderWrapper {
value: Record<string, any> | null;
}[] = [];

const erc725Version = await this.getErc725YVersion(address);

for (let index = 0; index < keys.length; index++) {
// TODO: call getData with array instead of multiple calls with 1 element
const value = await this.getData(address, keys[index]);
const value = await this.getData(address, keys[index], erc725Version);

results.push({
key: keys[index],
Expand Down

0 comments on commit 86c856e

Please sign in to comment.