Skip to content

Commit 82cbd1d

Browse files
authored
fix(1939): Fix build, replace missing implmentation with new solution (#1940)
Signed-off-by: matevszm <mateusz.marcinkowski@blockydevs.com>
1 parent 4e11cd1 commit 82cbd1d

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

src/plugins/token/commands/allowance-ft-list/handler.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { CommandHandlerArgs, CommandResult } from '@/core';
22
import type { Command } from '@/core/commands/command.interface';
3-
import type { CoreApi } from '@/core/core-api/core-api.interface';
43
import type { AccountReference } from '@/core/schemas/common-schemas';
54
import type { IdentityResolutionService } from '@/core/services/identity-resolution/identity-resolution-service.interface';
65
import type { HederaMirrornodeService } from '@/core/services/mirrornode/hedera-mirrornode-service.interface';
@@ -9,13 +8,14 @@ import type {
98
TokenInfo,
109
} from '@/core/services/mirrornode/types';
1110
import type { SupportedNetwork } from '@/core/types/shared.types';
11+
import type { TokenReferenceService } from '@/plugins/token/services/token-reference.service.interface';
1212
import type { FtTokenMetadata } from '@/plugins/token/types';
1313
import type { TokenAllowanceFtListOutput } from './output';
1414

1515
import BigNumber from 'bignumber.js';
1616

1717
import { normalizeBalance } from '@/core/utils/normalize-balance';
18-
import { resolveTokenParameter } from '@/plugins/token/resolver-helper';
18+
import { TokenReferenceServiceImpl } from '@/plugins/token/services/token-reference.service';
1919

2020
import { TokenAllowanceFtListInputSchema } from './input';
2121

@@ -27,6 +27,8 @@ type TokenAllowanceFtFetchResult = {
2727
};
2828

2929
export class TokenAllowanceFtListCommand implements Command {
30+
constructor(private readonly tokenReferenceService: TokenReferenceService) {}
31+
3032
async execute(args: CommandHandlerArgs): Promise<CommandResult> {
3133
const { api } = args;
3234
const validArgs = TokenAllowanceFtListInputSchema.parse(args.args);
@@ -41,7 +43,7 @@ export class TokenAllowanceFtListCommand implements Command {
4143
network,
4244
validArgs.spender,
4345
);
44-
const tokenId = this.resolveOptionalToken(validArgs.token, api, network);
46+
const tokenId = this.resolveOptionalToken(validArgs.token, network);
4547

4648
const response = await this.fetchAllowances(
4749
api.mirror,
@@ -97,11 +99,10 @@ export class TokenAllowanceFtListCommand implements Command {
9799

98100
private resolveOptionalToken(
99101
token: string | undefined,
100-
api: CoreApi,
101102
network: SupportedNetwork,
102103
): string | undefined {
103104
if (token === undefined) return undefined;
104-
const resolved = resolveTokenParameter(token, api, network);
105+
const resolved = this.tokenReferenceService.resolveToken(token, network);
105106
if (!resolved) return undefined;
106107
return resolved.tokenId;
107108
}
@@ -188,5 +189,8 @@ export class TokenAllowanceFtListCommand implements Command {
188189
export async function tokenAllowanceFtList(
189190
args: CommandHandlerArgs,
190191
): Promise<CommandResult> {
191-
return new TokenAllowanceFtListCommand().execute(args);
192+
const { api } = args;
193+
return new TokenAllowanceFtListCommand(
194+
new TokenReferenceServiceImpl(api.identityResolution),
195+
).execute(args);
192196
}

src/plugins/token/commands/allowance-nft-list/handler.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { CommandHandlerArgs, CommandResult } from '@/core';
22
import type { Command } from '@/core/commands/command.interface';
3-
import type { CoreApi } from '@/core/core-api/core-api.interface';
43
import type { AccountReference } from '@/core/schemas/common-schemas';
54
import type { IdentityResolutionService } from '@/core/services/identity-resolution/identity-resolution-service.interface';
65
import type { HederaMirrornodeService } from '@/core/services/mirrornode/hedera-mirrornode-service.interface';
@@ -9,10 +8,11 @@ import type {
98
TokenInfo,
109
} from '@/core/services/mirrornode/types';
1110
import type { SupportedNetwork } from '@/core/types/shared.types';
11+
import type { TokenReferenceService } from '@/plugins/token/services/token-reference.service.interface';
1212
import type { NftTokenMetadata } from '@/plugins/token/types';
1313
import type { TokenAllowanceNftListOutput } from './output';
1414

15-
import { resolveTokenParameter } from '@/plugins/token/resolver-helper';
15+
import { TokenReferenceServiceImpl } from '@/plugins/token/services/token-reference.service';
1616

1717
import { TokenAllowanceNftListInputSchema } from './input';
1818

@@ -31,6 +31,8 @@ type TokenAllowanceNftFetchResult = {
3131
};
3232

3333
export class TokenAllowanceNftListCommand implements Command {
34+
constructor(private readonly tokenReferenceService: TokenReferenceService) {}
35+
3436
async execute(args: CommandHandlerArgs): Promise<CommandResult> {
3537
const { api } = args;
3638
const validArgs = TokenAllowanceNftListInputSchema.parse(args.args);
@@ -45,7 +47,7 @@ export class TokenAllowanceNftListCommand implements Command {
4547
network,
4648
validArgs.spender,
4749
);
48-
const tokenId = this.resolveOptionalToken(validArgs.token, api, network);
50+
const tokenId = this.resolveOptionalToken(validArgs.token, network);
4951

5052
const response = await this.fetchAllowances(
5153
api.mirror,
@@ -101,11 +103,10 @@ export class TokenAllowanceNftListCommand implements Command {
101103

102104
private resolveOptionalToken(
103105
token: string | undefined,
104-
api: CoreApi,
105106
network: SupportedNetwork,
106107
): string | undefined {
107108
if (token === undefined) return undefined;
108-
const resolved = resolveTokenParameter(token, api, network);
109+
const resolved = this.tokenReferenceService.resolveToken(token, network);
109110
if (!resolved) return undefined;
110111
return resolved.tokenId;
111112
}
@@ -216,5 +217,8 @@ export class TokenAllowanceNftListCommand implements Command {
216217
export async function tokenAllowanceNftList(
217218
args: CommandHandlerArgs,
218219
): Promise<CommandResult> {
219-
return new TokenAllowanceNftListCommand().execute(args);
220+
const { api } = args;
221+
return new TokenAllowanceNftListCommand(
222+
new TokenReferenceServiceImpl(api.identityResolution),
223+
).execute(args);
220224
}

0 commit comments

Comments
 (0)