Skip to content
Merged
71 changes: 70 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2025-10-22
## 2025-10-30

### Changes

Expand All @@ -15,6 +15,75 @@ Packages with breaking changes:

Packages with other changes:

- [`nekoton_repository` - `v2.1.0-dev.2`](#nekoton_repository---v210-dev2)

---

#### `nekoton_repository` - `v2.1.0-dev.2`

- **FIX**: add apiBaseUrl parameter to getNftList method in NftDataProvider. ([99a6fb99](https://github.com/broxus/nekoton_repository/commit/99a6fb990036cdf283b65b5b77c517409d3cd1aa))

## 2.1.0-dev.2

- **FIX**: add apiBaseUrl parameter to getNftList method in NftDataProvider. ([99a6fb99](https://github.com/broxus/nekoton_repository/commit/99a6fb990036cdf283b65b5b77c517409d3cd1aa))


## 2025-10-30

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`nekoton_repository` - `v2.1.0-dev.1`](#nekoton_repository---v210-dev1)

---

#### `nekoton_repository` - `v2.1.0-dev.1`

- **FIX**: add NftDataProvider as a required parameter in NekotonRepository initialization. ([6d240b8e](https://github.com/broxus/nekoton_repository/commit/6d240b8efaa4f73abb7ec28384dea361ceef3f44))
- **FEAT**(EWM-582): add NFT data provider and update related repository methods. ([8c9c1d30](https://github.com/broxus/nekoton_repository/commit/8c9c1d306c92551733344c498ed4ec839ca75529))
- **FEAT**(EWM-397): add logic of count created names to choose max number. ([c47c067c](https://github.com/broxus/nekoton_repository/commit/c47c067c4ae0bc1ecfa560a2d4c8a0bb1c123ca7))
- **FEAT**(EWM-397): add new logic of default naming seeds and accounts. ([83bd3add](https://github.com/broxus/nekoton_repository/commit/83bd3add139d1914d4a723cab99fa9299c888514))
- **FEAT**(EWM-397): add new logic of account & seed default naming. ([2a9762a0](https://github.com/broxus/nekoton_repository/commit/2a9762a0d155ae283f96ac734638acf23a64c61d))

## 2.1.0-dev.1

- **FIX**: add NftDataProvider as a required parameter in NekotonRepository initialization. ([6d240b8e](https://github.com/broxus/nekoton_repository/commit/6d240b8efaa4f73abb7ec28384dea361ceef3f44))
- **FEAT**(EWM-582): add NFT data provider and update related repository methods. ([8c9c1d30](https://github.com/broxus/nekoton_repository/commit/8c9c1d306c92551733344c498ed4ec839ca75529))
- **FEAT**(EWM-397): add logic of count created names to choose max number. ([c47c067c](https://github.com/broxus/nekoton_repository/commit/c47c067c4ae0bc1ecfa560a2d4c8a0bb1c123ca7))
- **FEAT**(EWM-397): add new logic of default naming seeds and accounts. ([83bd3add](https://github.com/broxus/nekoton_repository/commit/83bd3add139d1914d4a723cab99fa9299c888514))
- **FEAT**(EWM-397): add new logic of account & seed default naming. ([2a9762a0](https://github.com/broxus/nekoton_repository/commit/2a9762a0d155ae283f96ac734638acf23a64c61d))


## 2025-10-30

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`nekoton_repository` - `v2.1.0-dev.0`](#nekoton_repository---v210-dev0)

---

#### `nekoton_repository` - `v2.1.0-dev.0`

- **FEAT**(EWM-582): add NFT data provider and update related repository methods. ([8c9c1d30](https://github.com/broxus/nekoton_repository/commit/8c9c1d306c92551733344c498ed4ec839ca75529))

## 2.1.0-dev.0

- **FEAT**(EWM-582): add NFT data provider and update related repository methods. ([8c9c1d30](https://github.com/broxus/nekoton_repository/commit/8c9c1d306c92551733344c498ed4ec839ca75529))
- [`nekoton_repository` - `v2.0.3-dev.0`](#nekoton_repository---v203-dev0)

---
Expand Down
2 changes: 2 additions & 0 deletions lib/src/models/transport_strategy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ abstract class TransportStrategy {
/// If transport has currency API, then it must return base URL for it.
String? get currencyApiBaseUrl;

String? get nftApiBaseUrl;

PollingConfig get pollingConfig;

/// Create token wallet subscribtion.
Expand Down
7 changes: 7 additions & 0 deletions lib/src/nekoton_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class NekotonRepository
@override
AbiLoader get abiLoader => _abiLoader;

late final NftDataProvider _nftDataProvider;

@override
NftDataProvider get nftDataProvider => _nftDataProvider;

late final fnb.LedgerConnection _ledgerConnection;

/// Setup nekoton bridge logger
Expand All @@ -98,11 +103,13 @@ class NekotonRepository
required TonWalletTransactionsStorage tonWalletStorage,
required TokenWalletTransactionsStorage tokenWalletStorage,
required LedgerConnectionHandler ledgerConnectionHandler,
required NftDataProvider nftDataProvider,
AssetBundle? bundle,
}) async {
_storageRepository = storage;
_tonWalletStorage = tonWalletStorage;
_tokenWalletStorage = tokenWalletStorage;
_nftDataProvider = nftDataProvider;

_nekotonStorage = Storage.create(
get: storage.getStorageData,
Expand Down
12 changes: 12 additions & 0 deletions lib/src/repositories/nft_repository/nft_data_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:nekoton_repository/nekoton_repository.dart';

// ignore: one_member_abstracts
abstract class NftDataProvider {
Future<NftList> getNftList({
required String apiBaseUrl,
required Address collection,
required Address owner,
required int limit,
int? offset,
});
}
1 change: 1 addition & 0 deletions lib/src/repositories/nft_repository/nft_repository.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export 'nft_data_provider.dart';
export 'nft_repository_abstract.dart';
export 'nft_repository_impl.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class NftRepository {

/// Get a list of NFTs owned by [owner] in the [collection].
/// Supports pagination with [limit] and [continuation].
Future<NftList> getNtfList({
Future<NftList> getNftList({
required Address collection,
required Address owner,
required int limit,
Expand Down
28 changes: 27 additions & 1 deletion lib/src/repositories/nft_repository/nft_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const _transferAbiParams = [
mixin NftRepositoryImpl implements NftRepository {
TransportStrategy get currentTransport;
AbiLoader get abiLoader;
NftDataProvider get nftDataProvider;

final _logger = Logger('NftRepositoryImpl');
final _cachedContractStateProvider = CachedContractStateProvider();
Expand Down Expand Up @@ -56,9 +57,23 @@ mixin NftRepositoryImpl implements NftRepository {
required List<Address> collections,
}) {
return currentTransport.transport.use(() async {
final apiBaseUrl = currentTransport.nftApiBaseUrl;
final result = await Future.wait(
collections.map((collection) async {
try {
if (apiBaseUrl != null && apiBaseUrl.isNotEmpty) {
final list = await nftDataProvider.getNftList(
apiBaseUrl: apiBaseUrl,
collection: collection,
owner: owner,
limit: 1,
);

return list.items.isNotEmpty
? getNftCollection(collection)
: null;
}

final [nft, fungible] = await Future.wait([
_getNftIndexes(
type: NftType.nft,
Expand Down Expand Up @@ -116,12 +131,23 @@ mixin NftRepositoryImpl implements NftRepository {
}

@override
Future<NftList> getNtfList({
Future<NftList> getNftList({
required Address collection,
required Address owner,
required int limit,
String? continuation,
}) {
final apiBaseUrl = currentTransport.nftApiBaseUrl;
if (apiBaseUrl != null && apiBaseUrl.isNotEmpty) {
return nftDataProvider.getNftList(
apiBaseUrl: apiBaseUrl,
collection: collection,
owner: owner,
limit: limit,
offset: continuation != null ? int.tryParse(continuation) : null,
);
}

return currentTransport.transport.use(() async {
final isVep1155 = await _supportsInterface(
address: collection,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: nekoton_repository
description: Nekoton repository package
version: 2.0.3-dev.0
version: 2.1.0-dev.2
repository: https://github.com/broxus/nekoton_repository

environment:
Expand Down
19 changes: 16 additions & 3 deletions test/src/nft_repository_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class MockTransportStrategy extends Mock implements TransportStrategy {}

class MockAbiLoader extends Mock implements AbiLoader {}

class MockNftDataProvider extends Mock implements NftDataProvider {}

class MockTonWallet extends Mock implements TonWallet {}

class MockLatestLtTracker extends Mock implements LatestLtTracker {}
Expand All @@ -23,29 +25,40 @@ class MockNftItem extends Mock implements NftItem {}
class MockNftList extends Mock implements NftList {}

class TestNftRepository with NftRepositoryImpl {
TestNftRepository({required this.currentTransport, required this.abiLoader});
TestNftRepository({
required this.currentTransport,
required this.abiLoader,
required this.nftDataProvider,
});

@override
final TransportStrategy currentTransport;

@override
final AbiLoader abiLoader;

@override
final NftDataProvider nftDataProvider;
}

void main() {
group('NftRepositoryImpl', () {
late TestNftRepository repository;
late MockTransportStrategy transport;
late MockAbiLoader abiLoader;
late MockNftDataProvider nftDataProvider;
late MockProtoTransport protoTransport;

setUp(() {
transport = MockTransportStrategy();
abiLoader = MockAbiLoader();
nftDataProvider = MockNftDataProvider();
protoTransport = MockProtoTransport();
when(() => transport.transport).thenReturn(protoTransport);
repository = TestNftRepository(
currentTransport: transport,
abiLoader: abiLoader,
nftDataProvider: nftDataProvider,
);
});

Expand Down Expand Up @@ -88,15 +101,15 @@ void main() {
expect(result, isNull);
});

test('getNtfList returns NftList', () async {
test('getNftList returns NftList', () async {
final collection = makeAddress();
final owner = makeAddress();
final nftList = MockNftList();
when(
() => protoTransport.use<NftList>(any()),
).thenAnswer((_) async => nftList);

final result = await repository.getNtfList(
final result = await repository.getNftList(
collection: collection,
owner: owner,
limit: 1,
Expand Down
Loading