Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Add support for remote contracts data pre-loading #231

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/gasData.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ class GasData {
}
}

if (contract.artifact.bytecodeHash) {
this.trackNameByPreloadedAddress(
contract.name,
contract.artifact.address,
contract.artifact.bytecodeHash
);
}

// Decode, getMethodIDs
const methodIDs = {};

Expand Down Expand Up @@ -120,6 +128,17 @@ class GasData {
this.addressCache[address] = name;
}

/**
* Map a contract name to pre-generated hash of the code stored at an address
* @param {String} name contract name
* @param {String} address contract address
*/
trackNameByPreloadedAddress(name, address, hash) {
if (this.addressIsCached(address)) return;
this.codeHashMap[hash] = name;
this.addressCache[address] = name;
}

/**
* Get the name of the contract stored at contract address
* @param {String} address contract address
Expand Down