Skip to content

Commit

Permalink
Add isTestnet flag from config service (safe-global#1093)
Browse files Browse the repository at this point in the history
Adds a new `isTestnet` flag to `Chain` as per [the config service integration](safe-global/safe-config-service#1036).
  • Loading branch information
iamacook authored Jan 31, 2024
1 parent 11bb359 commit 194c500
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/domain/chains/entities/__tests__/chain.builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function chainBuilder(): IBuilder<Chain> {
.with('chainName', faker.company.name())
.with('description', faker.word.words())
.with('l2', faker.datatype.boolean())
.with('isTestnet', faker.datatype.boolean())
.with('shortName', faker.company.name())
.with('rpcUri', rpcUriBuilder().build())
.with('safeAppsRpcUri', rpcUriBuilder().build())
Expand Down
2 changes: 2 additions & 0 deletions src/domain/chains/entities/chain.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface Chain {
chainName: string;
description: string;
l2: boolean;
// TODO: Make required when deemed stable on config service
isTestnet?: boolean;
shortName: string;
rpcUri: RpcUri;
safeAppsRpcUri: RpcUri;
Expand Down
3 changes: 3 additions & 0 deletions src/domain/chains/entities/schemas/chain.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export const chainSchema: JSONSchemaType<Chain> = {
chainName: { type: 'string' },
description: { type: 'string' },
l2: { type: 'boolean' },
// TODO: Make required when deemed stable on config service
isTestnet: { type: 'boolean', nullable: true },
shortName: { type: 'string' },
rpcUri: { $ref: 'rpc-uri.json' },
safeAppsRpcUri: { $ref: 'rpc-uri.json' },
Expand All @@ -144,6 +146,7 @@ export const chainSchema: JSONSchemaType<Chain> = {
'chainName',
'description',
'l2',
// isTestnet,
'shortName',
'rpcUri',
'safeAppsRpcUri',
Expand Down
3 changes: 3 additions & 0 deletions src/routes/chains/chains.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('Chains Controller (Unit)', () => {
chainName: chainsResponse.results[0].chainName,
description: chainsResponse.results[0].description,
l2: chainsResponse.results[0].l2,
isTestnet: chainsResponse.results[0].isTestnet,
shortName: chainsResponse.results[0].shortName,
rpcUri: chainsResponse.results[0].rpcUri,
safeAppsRpcUri: chainsResponse.results[0].safeAppsRpcUri,
Expand All @@ -114,6 +115,7 @@ describe('Chains Controller (Unit)', () => {
chainName: chainsResponse.results[1].chainName,
description: chainsResponse.results[1].description,
l2: chainsResponse.results[1].l2,
isTestnet: chainsResponse.results[1].isTestnet,
shortName: chainsResponse.results[1].shortName,
rpcUri: chainsResponse.results[1].rpcUri,
safeAppsRpcUri: chainsResponse.results[1].safeAppsRpcUri,
Expand Down Expand Up @@ -206,6 +208,7 @@ describe('Chains Controller (Unit)', () => {
chainName: chainDomain.chainName,
description: chainDomain.description,
l2: chainDomain.l2,
isTestnet: chainDomain.isTestnet,
nativeCurrency: chainDomain.nativeCurrency,
transactionService: chainDomain.transactionService,
blockExplorerUriTemplate: chainDomain.blockExplorerUriTemplate,
Expand Down
2 changes: 2 additions & 0 deletions src/routes/chains/chains.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class ChainsService {
chain.shortName,
chain.theme,
chain.ensRegistryAddress,
chain.isTestnet,
),
);

Expand Down Expand Up @@ -84,6 +85,7 @@ export class ChainsService {
result.shortName,
result.theme,
result.ensRegistryAddress,
result.isTestnet,
);
}

Expand Down
6 changes: 6 additions & 0 deletions src/routes/chains/entities/chain.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export class Chain {
description: string;
@ApiProperty()
l2: boolean;
// TODO: Make required when implemented on config service and deemed stable
@ApiPropertyOptional()
isTestnet?: boolean;
@ApiProperty()
nativeCurrency: ApiNativeCurrency;
@ApiProperty()
Expand Down Expand Up @@ -96,11 +99,14 @@ export class Chain {
shortName: string,
theme: Theme,
ensRegistryAddress: string | null,
// TODO: Make required when deemed stable on config service
isTestnet?: boolean,
) {
this.chainId = chainId;
this.chainName = chainName;
this.description = description;
this.l2 = l2;
this.isTestnet = isTestnet;
this.nativeCurrency = nativeCurrency;
this.transactionService = transactionService;
this.blockExplorerUriTemplate = blockExplorerUriTemplate;
Expand Down

0 comments on commit 194c500

Please sign in to comment.