Skip to content

Commit a95e0a0

Browse files
committed
refactor: Replaced all instances of 0x${string} with Address.
1 parent f0b292d commit a95e0a0

File tree

417 files changed

+2142
-1953
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

417 files changed

+2142
-1953
lines changed

migrations/deprecated/__tests__/00001_accounts.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import { PostgresDatabaseMigrator } from '@/datasources/db/v1/postgres-database.
44
import { faker } from '@faker-js/faker';
55
import type { Sql } from 'postgres';
66
import type postgres from 'postgres';
7+
import type { Address } from 'viem';
78

89
interface AccountRow {
910
id: number;
1011
group_id: number;
1112
created_at: Date;
1213
updated_at: Date;
13-
address: `0x${string}`;
14+
address: Address;
1415
}
1516

1617
describe('Migration 00001_accounts', () => {

migrations/deprecated/__tests__/00003_account-data-settings.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { waitMilliseconds } from '@/__tests__/util/retry';
33
import { PostgresDatabaseMigrator } from '@/datasources/db/v1/postgres-database.migrator';
44
import { faker } from '@faker-js/faker';
55
import type postgres from 'postgres';
6+
import type { Address } from 'viem';
67
import { getAddress } from 'viem';
78

89
interface AccountRow {
910
id: number;
1011
group_id: number;
1112
created_at: Date;
1213
updated_at: Date;
13-
address: `0x${string}`;
14+
address: Address;
1415
}
1516

1617
interface AccountDataTypeRow {

migrations/deprecated/__tests__/00004_counterfactual-safes.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@ import { waitMilliseconds } from '@/__tests__/util/retry';
33
import { PostgresDatabaseMigrator } from '@/datasources/db/v1/postgres-database.migrator';
44
import { faker } from '@faker-js/faker';
55
import type postgres from 'postgres';
6+
import type { Address } from 'viem';
67
import { getAddress } from 'viem';
78

89
interface AccountRow {
910
id: number;
1011
group_id: number;
1112
created_at: Date;
1213
updated_at: Date;
13-
address: `0x${string}`;
14+
address: Address;
1415
}
1516

1617
interface CounterfactualSafesRow {
1718
created_at: Date;
1819
updated_at: Date;
1920
id: number;
2021
chain_id: string;
21-
creator: `0x${string}`;
22-
fallback_handler: `0x${string}`;
23-
owners: Array<`0x${string}`>;
24-
predicted_address: `0x${string}`;
22+
creator: Address;
23+
fallback_handler: Address;
24+
owners: Array<Address>;
25+
predicted_address: Address;
2526
salt_nonce: string;
26-
singleton_address: `0x${string}`;
27+
singleton_address: Address;
2728
threshold: number;
2829
account_id: number;
2930
}

migrations/deprecated/__tests__/00005_notifications.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DeviceType } from '@/domain/notifications/v2/entities/device-type.entit
44
import type { UUID } from 'crypto';
55
import { faker } from '@faker-js/faker';
66
import type postgres from 'postgres';
7+
import type { Address } from 'viem';
78
import { getAddress } from 'viem';
89

910
type PushNotificationDevicesRow = {
@@ -29,10 +30,10 @@ type NotificationTypesRow = {
2930

3031
type NotificationSubscriptionsRow = {
3132
id: number;
32-
signer_address: `0x${string}` | null;
33+
signer_address: Address | null;
3334
push_notification_device_id: PushNotificationDevicesRow['id'];
3435
chain_id: string;
35-
safe_address: `0x${string}`;
36+
safe_address: Address;
3637
created_at: Date;
3738
updated_at: Date;
3839
};

migrations/deprecated/__tests__/00011_address-books.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { waitMilliseconds } from '@/__tests__/util/retry';
33
import { PostgresDatabaseMigrator } from '@/datasources/db/v1/postgres-database.migrator';
44
import { faker } from '@faker-js/faker';
55
import type postgres from 'postgres';
6+
import type { Address } from 'viem';
67
import { getAddress } from 'viem';
78

89
interface AccountDataTypeRow {
@@ -19,7 +20,7 @@ interface AccountRow {
1920
group_id: number;
2021
created_at: Date;
2122
updated_at: Date;
22-
address: `0x${string}`;
23+
address: Address;
2324
}
2425

2526
interface AddressBooksRow {

src/config/entities/blocklist.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import type { Address } from 'viem';
12
import { getAddress } from 'viem';
23

3-
export function getBlocklist(): Array<`0x${string}`> {
4+
export function getBlocklist(): Array<Address> {
45
// Addresses not allowed to interact with the service
56
// List taken from https://www.ic3.gov/PSA/2025/PSA250226
67
return [

src/datasources/accounts/accounts.datasource.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import crypto from 'crypto';
2929
import omit from 'lodash/omit';
3030
import postgres from 'postgres';
31+
import type { Address } from 'viem';
3132

3233
@Injectable()
3334
export class AccountsDatasource implements IAccountsDatasource, OnModuleInit {
@@ -112,7 +113,7 @@ export class AccountsDatasource implements IAccountsDatasource, OnModuleInit {
112113
return omit(await this.decryptAccountData(account), 'name_hash');
113114
}
114115

115-
async getAccount(address: `0x${string}`): Promise<Account> {
116+
async getAccount(address: Address): Promise<Account> {
116117
const cacheDir = CacheRouter.getAccountCacheDir(address);
117118
const [account] = await this.cachedQueryResolver.get<Array<Account>>({
118119
cacheDir,
@@ -127,7 +128,7 @@ export class AccountsDatasource implements IAccountsDatasource, OnModuleInit {
127128
return this.decryptAccountData(account);
128129
}
129130

130-
async deleteAccount(address: `0x${string}`): Promise<void> {
131+
async deleteAccount(address: Address): Promise<void> {
131132
try {
132133
const { count } = await this
133134
.sql`DELETE FROM accounts WHERE address = ${address}`;
@@ -156,7 +157,7 @@ export class AccountsDatasource implements IAccountsDatasource, OnModuleInit {
156157
}
157158

158159
async getAccountDataSettings(
159-
address: `0x${string}`,
160+
address: Address,
160161
): Promise<Array<AccountDataSetting>> {
161162
const account = await this.getAccount(address);
162163
const cacheDir = CacheRouter.getAccountDataSettingsCacheDir(address);
@@ -182,7 +183,7 @@ export class AccountsDatasource implements IAccountsDatasource, OnModuleInit {
182183
* @returns {Array<AccountDataSetting>} inserted account data settings.
183184
*/
184185
async upsertAccountDataSettings(args: {
185-
address: `0x${string}`;
186+
address: Address;
186187
upsertAccountDataSettingsDto: UpsertAccountDataSettingsDto;
187188
}): Promise<Array<AccountDataSetting>> {
188189
const { accountDataSettings } = args.upsertAccountDataSettingsDto;
@@ -270,7 +271,7 @@ export class AccountsDatasource implements IAccountsDatasource, OnModuleInit {
270271

271272
async encryptAccountData(
272273
createAccountDto: CreateAccountDto,
273-
): Promise<{ address: `0x${string}`; name: string; nameHash: string }> {
274+
): Promise<{ address: Address; name: string; nameHash: string }> {
274275
const hash = crypto.createHash('sha256');
275276
hash.update(createAccountDto.name);
276277
const nameHash = hash.digest('hex');

src/datasources/accounts/counterfactual-safes/counterfactual-safes.datasource.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ICounterfactualSafesDatasource } from '@/domain/interfaces/counterfactu
1414
import { ILoggingService, LoggingService } from '@/logging/logging.interface';
1515
import { Inject, Injectable, NotFoundException } from '@nestjs/common';
1616
import postgres from 'postgres';
17+
import type { Address } from 'viem';
1718

1819
@Injectable()
1920
export class CounterfactualSafesDatasource
@@ -67,9 +68,9 @@ export class CounterfactualSafesDatasource
6768
}
6869

6970
async getCounterfactualSafe(args: {
70-
address: `0x${string}`;
71+
address: Address;
7172
chainId: string;
72-
predictedAddress: `0x${string}`;
73+
predictedAddress: Address;
7374
}): Promise<CounterfactualSafe> {
7475
const cacheDir = CacheRouter.getCounterfactualSafeCacheDir(
7576
args.chainId,
@@ -95,7 +96,7 @@ export class CounterfactualSafesDatasource
9596
}
9697

9798
getCounterfactualSafesForAddress(
98-
address: `0x${string}`,
99+
address: Address,
99100
): Promise<Array<CounterfactualSafe>> {
100101
const cacheDir = CacheRouter.getCounterfactualSafesCacheDir(address);
101102
return this.cachedQueryResolver.get<Array<CounterfactualSafe>>({
@@ -110,7 +111,7 @@ export class CounterfactualSafesDatasource
110111
async deleteCounterfactualSafe(args: {
111112
account: Account;
112113
chainId: string;
113-
predictedAddress: `0x${string}`;
114+
predictedAddress: Address;
114115
}): Promise<void> {
115116
try {
116117
const { count } = await this

src/datasources/balances-api/balances-api.manager.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ITransactionApiManager } from '@/domain/interfaces/transaction-api.mana
1717
import { ChainSchema } from '@/domain/chains/entities/schemas/chain.schema';
1818
import { z } from 'zod';
1919
import { type Raw, rawify } from '@/validation/entities/raw.entity';
20+
import type { Address } from 'viem';
2021

2122
@Injectable()
2223
export class BalancesApiManager implements IBalancesApiManager {
@@ -51,10 +52,7 @@ export class BalancesApiManager implements IBalancesApiManager {
5152
this.zerionBalancesApi = zerionBalancesApi;
5253
}
5354

54-
async getApi(
55-
chainId: string,
56-
safeAddress: `0x${string}`,
57-
): Promise<IBalancesApi> {
55+
async getApi(chainId: string, safeAddress: Address): Promise<IBalancesApi> {
5856
if (this.zerionChainIds.includes(chainId)) {
5957
return this.zerionBalancesApi;
6058
}

src/datasources/balances-api/safe-balances-api.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
getAssetPricesSchema,
2121
} from '@/datasources/balances-api/entities/asset-price.entity';
2222
import { ZodError } from 'zod';
23+
import type { Address } from 'viem';
2324

2425
@Injectable()
2526
export class SafeBalancesApi implements IBalancesApi {
@@ -65,7 +66,7 @@ export class SafeBalancesApi implements IBalancesApi {
6566
}
6667

6768
async getBalances(args: {
68-
safeAddress: `0x${string}`;
69+
safeAddress: Address;
6970
fiatCode: string;
7071
chain: Chain;
7172
trusted?: boolean;
@@ -105,7 +106,7 @@ export class SafeBalancesApi implements IBalancesApi {
105106
}
106107
}
107108

108-
async clearBalances(args: { safeAddress: `0x${string}` }): Promise<void> {
109+
async clearBalances(args: { safeAddress: Address }): Promise<void> {
109110
const key = CacheRouter.getBalancesCacheKey({
110111
chainId: this.chainId,
111112
safeAddress: args.safeAddress,
@@ -114,7 +115,7 @@ export class SafeBalancesApi implements IBalancesApi {
114115
}
115116

116117
async getCollectibles(args: {
117-
safeAddress: `0x${string}`;
118+
safeAddress: Address;
118119
limit?: number;
119120
offset?: number;
120121
trusted?: boolean;
@@ -145,7 +146,7 @@ export class SafeBalancesApi implements IBalancesApi {
145146
}
146147
}
147148

148-
async clearCollectibles(args: { safeAddress: `0x${string}` }): Promise<void> {
149+
async clearCollectibles(args: { safeAddress: Address }): Promise<void> {
149150
const key = CacheRouter.getCollectiblesKey({
150151
chainId: this.chainId,
151152
safeAddress: args.safeAddress,
@@ -176,7 +177,7 @@ export class SafeBalancesApi implements IBalancesApi {
176177
}): Promise<Raw<Array<Balance>>> {
177178
const tokenAddresses = args.balances
178179
.map((balance) => balance.tokenAddress)
179-
.filter((address): address is `0x${string}` => address !== null);
180+
.filter((address): address is Address => address !== null);
180181

181182
const lowerCaseFiatCode = args.fiatCode.toLowerCase();
182183
const assetPrices = await this.coingeckoApi

0 commit comments

Comments
 (0)