MCPcopy Create free account
hub / github.com/SmarDex-Dev/smart-contracts / updateHashV1

Function updateHashV1

deploy/utils.ts:492–525  ·  view source on GitHub ↗
(hre: HardhatRuntimeEnvironment)

Source from the content-addressed store, hash-verified

490
491// check and update pair v1 hash
492export async function updateHashV1(hre: HardhatRuntimeEnvironment): Promise<boolean> {
493 return new Promise(function (resolve, reject) {
494 try {
495 const content = readFileSync(__dirname + smardexLibFile, "utf8");
496 const currentHash = content?.match(/hex"((?!(ff)).+)"/g)?.[0];
497
498 hre.ethers
499 .getContractFactory("SmardexPairV1")
500 .then(function (contractFactory) {
501 const currentLocalHash = 'hex"' + keccak256(contractFactory.bytecode).slice(2) + '"';
502 if ((!isV1Pair && currentLocalHash !== currentHash) || (isV1Pair && currentHash !== hashForPairL1)) {
503 // run changehashforv1 script
504 hre
505 .run("changehashforv1", {
506 deployment: isV1Pair.toString(),
507 })
508 .then(function () {
509 resolve(isV1Pair);
510 })
511 .catch(function (e: any) {
512 reject(e.message);
513 });
514 } else {
515 resolve(isV1Pair);
516 }
517 })
518 .catch(function (e: any) {
519 reject(e.message);
520 });
521 } catch (e: any) {
522 reject(e.message);
523 }
524 });
525}
526
527const pathPrefix = "../artifacts/contracts/";
528export const abiPaths = {

Callers 1

funcFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected