evm-blockchain-tools
Version:
This is a collection of resuseable tools to support development for EVM-powered blockchains
39 lines • 1.72 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContractRegistry = void 0;
class ContractRegistry {
constructor() {
this.registry = new Map();
}
buildHashKey(network, address, signerName) {
return `${network}_${address}_${signerName}`;
}
getContract(network, address, signerName) {
const hashKey = this.buildHashKey(network, address, signerName);
if (this.registry.has(hashKey)) {
return this.registry.get(hashKey);
}
return null;
}
registerContract(contract, network, signerName) {
return __awaiter(this, void 0, void 0, function* () {
const address = contract.address;
const hashKey = this.buildHashKey(network, address, signerName);
if (this.registry.has(hashKey)) {
return;
}
this.registry.set(hashKey, contract);
});
}
}
exports.ContractRegistry = ContractRegistry;
//# sourceMappingURL=contract-registry.js.map