-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add moduleAddress to operators table, Registry__factory
- Loading branch information
Showing
18 changed files
with
142 additions
and
52 deletions.
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
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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { Registry, REGISTRY_CONTRACT_TOKEN } from '@lido-nestjs/contracts'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { Registry__factory } from '@lido-nestjs/contracts'; | ||
import { CallOverrides } from './interfaces/overrides.interface'; | ||
import { ExecutionProvider } from 'common/execution-provider'; | ||
|
||
@Injectable() | ||
export class RegistryMetaFetchService { | ||
constructor(@Inject(REGISTRY_CONTRACT_TOKEN) private registryContract: Registry) {} | ||
constructor(protected readonly provider: ExecutionProvider) {} | ||
|
||
private getContract(moduleAddress: string) { | ||
return Registry__factory.connect(moduleAddress, this.provider); | ||
} | ||
|
||
/** fetches keys operation index */ | ||
public async fetchKeysOpIndex(overrides: CallOverrides = {}, moduleAddress: string): Promise<number> { | ||
public async fetchKeysOpIndex(moduleAddress: string, overrides: CallOverrides = {}): Promise<number> { | ||
// TODO: read data from all contract that implement curated-v1-onchain type | ||
const bigNumber = await this.registryContract.getKeysOpIndex(overrides as any); | ||
const bigNumber = await this.getContract(moduleAddress).getKeysOpIndex(overrides as any); | ||
return bigNumber.toNumber(); | ||
} | ||
} |
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
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
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,11 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20230724202500 extends Migration { | ||
async up(): Promise<void> { | ||
this.addSql('alter table "registry_operator" add column "module_address" varchar(42) null;'); | ||
} | ||
|
||
async down(): Promise<void> { | ||
this.addSql('alter table "registry_operator" drop column "module_address";'); | ||
} | ||
} |
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,31 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20230724204141 extends Migration { | ||
public async up(): Promise<void> { | ||
if (process.env.CHAIN_ID == '1') { | ||
this.addSql("UPDATE registry_operator SET module_address = '0x55032650b14df07b85bF18A3a3eC8E0Af2e028d5'"); | ||
return; | ||
} | ||
|
||
if (process.env.CHAIN_ID == '5') { | ||
this.addSql("UPDATE registry_operator SET module_address = '0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320'"); | ||
return; | ||
} | ||
|
||
//TODO: will have problem on new testnet for example | ||
// maybe better instead of this migration truncate values in db but than update will take more time for holders | ||
// I prefer second way | ||
|
||
throw new Error('CHAIN_ID is wrong, it should be 1 or 5'); | ||
} | ||
|
||
public async down(): Promise<void> { | ||
if (process.env.CHAIN_ID === '1') { | ||
this.addSql('UPDATE registry_operator SET module_address = NULL'); | ||
} else if (process.env.CHAIN_ID === '5') { | ||
this.addSql('UPDATE registry_operator SET module_address = NULL'); | ||
} else { | ||
throw new Error('CHAIN_ID is wrong, it should be 1 or 5'); | ||
} | ||
} | ||
} |
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,17 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20230724205529 extends Migration { | ||
async up(): Promise<void> { | ||
this.addSql( | ||
'alter table "registry_operator" alter column "module_address" type varchar(42) using ("module_address"::varchar(42));', | ||
); | ||
this.addSql('alter table "registry_operator" alter column "module_address" set not null;'); | ||
} | ||
|
||
async down(): Promise<void> { | ||
this.addSql( | ||
'alter table "registry_operator" alter column "module_address" type varchar using ("module_address"::varchar);', | ||
); | ||
this.addSql('alter table "registry_operator" alter column "module_address" drop not null;'); | ||
} | ||
} |
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,11 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20230724210022 extends Migration { | ||
public async up(): Promise<void> { | ||
this.addSql('ALTER TABLE "srmodule_entity" RENAME TO "sr_module_entity"'); | ||
} | ||
|
||
public async down(): Promise<void> { | ||
this.addSql('ALTER TABLE "sr_module_entity" RENAME TO "srmodule_entity"'); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { EntityRepository } from '@mikro-orm/knex'; | ||
import { SRModuleEntity } from './sr-module.entity'; | ||
import { SrModuleEntity } from './sr-module.entity'; | ||
|
||
export class SRModuleRepository extends EntityRepository<SRModuleEntity> {} | ||
export class SRModuleRepository extends EntityRepository<SrModuleEntity> {} |
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
Oops, something went wrong.