@0x/contracts-zero-ex: Use (scaled) enums for storage IDs
This commit is contained in:
@@ -5,9 +5,10 @@ import { promisify } from 'util';
|
||||
|
||||
describe('Storage ID uniqueness test', () => {
|
||||
const STORAGE_SOURCES_DIR = resolve(__dirname, '../../contracts/src/storage');
|
||||
|
||||
async function findStorageIdFromSourceFileAsync(path: string): Promise<string | void> {
|
||||
const contents = await promisify(readFile)(path, { encoding: 'utf-8' });
|
||||
const m = /STORAGE_ID\s*=\s*(0x[a-fA-F0-9]{64})/m.exec(contents);
|
||||
const m = /LibStorage\.\s*getStorageOffset\(\s*LibStorage\.\s*StorageId\.\s*(\w+)\s*\)/m.exec(contents);
|
||||
if (m) {
|
||||
return m[1];
|
||||
}
|
||||
@@ -17,7 +18,9 @@ describe('Storage ID uniqueness test', () => {
|
||||
const sourcePaths = (await promisify(readdir)(STORAGE_SOURCES_DIR))
|
||||
.filter(p => p.endsWith('.sol'))
|
||||
.map(p => resolve(STORAGE_SOURCES_DIR, p));
|
||||
const storageIds = await Promise.all(sourcePaths.map(async p => findStorageIdFromSourceFileAsync(p)));
|
||||
const storageIds = (await Promise.all(sourcePaths.map(async p => findStorageIdFromSourceFileAsync(p)))).filter(
|
||||
id => !!id,
|
||||
);
|
||||
for (let i = 0; i < storageIds.length; ++i) {
|
||||
const storageId = storageIds[i];
|
||||
for (let j = 0; j < storageIds.length; ++j) {
|
||||
|
||||
Reference in New Issue
Block a user