Skip to content

Commit 6952baa

Browse files
committed
Merge remote-tracking branch 'origin/staging' into julian
2 parents 963c535 + b19dde9 commit 6952baa

File tree

76 files changed

+12104
-757
lines changed

Some content is hidden

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

76 files changed

+12104
-757
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ secp256k1.dll
7070
/lib/app_config.g.dart
7171
/android/app/src/main/app_icon-playstore.png
7272

73-
# Dart generated files (Freezed, Riverpod, GoRouter etc..)
74-
lib/**/*.g.dart
75-
lib/**/*.freezed.dart
76-
7773
## other generated project files
7874

7975
pubspec.yaml

lib/db/isar/main_db.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class MainDB {
5959
AddressSchema,
6060
AddressLabelSchema,
6161
EthContractSchema,
62+
SolContractSchema,
6263
TransactionBlockExplorerSchema,
6364
StackThemeSchema,
6465
ContactEntrySchema,
@@ -69,6 +70,7 @@ class MainDB {
6970
WalletInfoMetaSchema,
7071
TokenWalletInfoSchema,
7172
FrostWalletInfoSchema,
73+
WalletSolanaTokenInfoSchema,
7274
],
7375
directory: (await StackFileSystem.applicationIsarDirectory()).path,
7476
// inspector: kDebugMode,
@@ -621,4 +623,26 @@ class MainDB {
621623
isar.writeTxn(() async {
622624
await isar.ethContracts.putAll(contracts);
623625
});
626+
627+
// ========== Solana =========================================================
628+
629+
// Solana tokens.
630+
631+
QueryBuilder<SolContract, SolContract, QWhere> getSolContracts() =>
632+
isar.solContracts.where();
633+
634+
Future<SolContract?> getSolContract(String tokenMint) =>
635+
isar.solContracts.where().addressEqualTo(tokenMint).findFirst();
636+
637+
SolContract? getSolContractSync(String tokenMint) =>
638+
isar.solContracts.where().addressEqualTo(tokenMint).findFirstSync();
639+
640+
Future<int> putSolContract(SolContract token) => isar.writeTxn(() async {
641+
return await isar.solContracts.put(token);
642+
});
643+
644+
Future<void> putSolContracts(List<SolContract> tokens) =>
645+
isar.writeTxn(() async {
646+
await isar.solContracts.putAll(tokens);
647+
});
624648
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file is part of Stack Wallet.
3+
*
4+
* Copyright (c) 2023 Cypher Stack
5+
* All Rights Reserved.
6+
* The code is distributed under GPLv3 license, see LICENSE file for details.
7+
*
8+
*/
9+
10+
import '../../../wallets/crypto_currency/crypto_currency.dart';
11+
import '../../isar/models/solana/sol_contract.dart';
12+
import '../add_wallet_list_entity.dart';
13+
14+
class SolTokenEntity extends AddWalletListEntity {
15+
SolTokenEntity(this.token);
16+
17+
final SolContract token;
18+
19+
@override
20+
CryptoCurrency get cryptoCurrency => Solana(CryptoCurrencyNetwork.main);
21+
22+
@override
23+
String get name => token.name;
24+
25+
@override
26+
String get ticker => token.symbol;
27+
28+
@override
29+
List<Object?> get props =>
30+
[cryptoCurrency.identifier, name, ticker, token.address];
31+
}

lib/models/isar/models/blockchain_data/transaction.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,5 @@ enum TransactionSubType {
261261
sparkSpend, // firo specific
262262
ordinal,
263263
mweb,
264+
splToken, // Solana token.
264265
}

lib/models/isar/models/blockchain_data/transaction.g.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/isar/models/blockchain_data/v2/transaction_v2.g.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/isar/models/contract.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,15 @@
99
*/
1010

1111
abstract class Contract {
12-
// for possible future use
12+
/// Token/contract address (mint address for Solana, contract address for Ethereum).
13+
String get address;
14+
15+
/// Token name.
16+
String get name;
17+
18+
/// Token symbol.
19+
String get symbol;
20+
21+
/// Token decimals.
22+
int get decimals;
1323
}

lib/models/isar/models/ethereum/eth_contract.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import 'package:isar_community/isar.dart';
12+
1213
import '../contract.dart';
1314

1415
part 'eth_contract.g.dart';
@@ -26,13 +27,17 @@ class EthContract extends Contract {
2627

2728
Id id = Isar.autoIncrement;
2829

30+
@override
2931
@Index(unique: true, replace: true)
3032
late final String address;
3133

34+
@override
3235
late final String name;
3336

37+
@override
3438
late final String symbol;
3539

40+
@override
3641
late final int decimals;
3742

3843
late final String? abi;
@@ -50,21 +55,16 @@ class EthContract extends Contract {
5055
List<String>? walletIds,
5156
String? abi,
5257
String? otherData,
53-
}) =>
54-
EthContract(
55-
address: address ?? this.address,
56-
name: name ?? this.name,
57-
symbol: symbol ?? this.symbol,
58-
decimals: decimals ?? this.decimals,
59-
type: type ?? this.type,
60-
abi: abi ?? this.abi,
61-
)..id = id ?? this.id;
58+
}) => EthContract(
59+
address: address ?? this.address,
60+
name: name ?? this.name,
61+
symbol: symbol ?? this.symbol,
62+
decimals: decimals ?? this.decimals,
63+
type: type ?? this.type,
64+
abi: abi ?? this.abi,
65+
)..id = id ?? this.id;
6266
}
6367

6468
// Used in Isar db and stored there as int indexes so adding/removing values
6569
// in this definition should be done extremely carefully in production
66-
enum EthContractType {
67-
unknown,
68-
erc20,
69-
erc721;
70-
}
70+
enum EthContractType { unknown, erc20, erc721 }

lib/models/isar/models/isar_models.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ export 'blockchain_data/transaction.dart';
1616
export 'blockchain_data/utxo.dart';
1717
export 'ethereum/eth_contract.dart';
1818
export 'log.dart';
19+
export 'solana/sol_contract.dart';
1920
export 'transaction_note.dart';
21+
export '../../../wallets/isar/models/wallet_solana_token_info.dart';
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* This file is part of Stack Wallet.
3+
*
4+
* Copyright (c) 2025 Cypher Stack
5+
* All Rights Reserved.
6+
* The code is distributed under GPLv3 license, see LICENSE file for details.
7+
*
8+
*/
9+
10+
import 'package:isar_community/isar.dart';
11+
12+
import '../contract.dart';
13+
14+
part 'sol_contract.g.dart';
15+
16+
@collection
17+
class SolContract extends Contract {
18+
SolContract({
19+
required this.address,
20+
required this.name,
21+
required this.symbol,
22+
required this.decimals,
23+
this.logoUri,
24+
this.metadataAddress,
25+
});
26+
27+
Id id = Isar.autoIncrement;
28+
29+
@override
30+
@Index(unique: true, replace: true)
31+
late final String address; // Mint address.
32+
33+
@override
34+
late final String name;
35+
36+
@override
37+
late final String symbol;
38+
39+
@override
40+
late final int decimals;
41+
42+
late final String? logoUri;
43+
44+
late final String? metadataAddress;
45+
46+
SolContract copyWith({
47+
Id? id,
48+
String? address,
49+
String? name,
50+
String? symbol,
51+
int? decimals,
52+
String? logoUri,
53+
String? metadataAddress,
54+
}) => SolContract(
55+
address: address ?? this.address,
56+
name: name ?? this.name,
57+
symbol: symbol ?? this.symbol,
58+
decimals: decimals ?? this.decimals,
59+
logoUri: logoUri ?? this.logoUri,
60+
metadataAddress: metadataAddress ?? this.metadataAddress,
61+
)..id = id ?? this.id;
62+
}

0 commit comments

Comments
 (0)