-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e705577
commit e27fb5c
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import fs from 'fs'; | ||
|
||
const BALANCE_TRACKER_FILENAME : string = 'contracts/BalanceTracker.flattened.sol'; | ||
|
||
export function readTokenAddressFromSource() : string { | ||
let file = fs.readFileSync(BALANCE_TRACKER_FILENAME).toString(); | ||
const regex = /address public constant TOKEN = address\((0x[0-9a-fA-F]{40})\);/ | ||
const matches = file.match(regex) as RegExpMatchArray; | ||
const tokenAddress = matches[1]; | ||
return tokenAddress; | ||
} | ||
|
||
export function replaceTokenAddress(oldAddress: string, newAddress: string) { | ||
let file = fs.readFileSync(BALANCE_TRACKER_FILENAME).toString(); | ||
if (oldAddress === newAddress) { | ||
// nothing to do | ||
return; | ||
} | ||
fs.writeFileSync(BALANCE_TRACKER_FILENAME, file.replace(oldAddress, newAddress), {flag: 'w'}); | ||
} | ||
|
||
export function recompile() { | ||
const execSync = require('child_process').execSync; | ||
execSync('npx hardhat compile'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters