Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ lib/ethereum/ethereum.dart
lib/bitcoin_cash/bitcoin_cash.dart
lib/nano/nano.dart
lib/polygon/polygon.dart
lib/gnosis/gnosis.dart
lib/solana/solana.dart
lib/tron/tron.dart
lib/wownero/wownero.dart
Expand Down
4 changes: 4 additions & 0 deletions assets/gnosis_node_list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-
uri: gnosis-rpc.publicnode.com
useSSL: true
isDefault: true
Binary file added assets/images/gno.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/gnosis_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/xdai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cakewallet.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
set cw_win_app_config=--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron
set cw_win_app_config=--monero --bitcoin --ethereum --polygon --gnosis --nano --bitcoinCash --solana --tron
set cw_root=%cd%
set cw_archive_name=Cake Wallet.zip
set cw_archive_path=%cw_root%\%cw_archive_name%
Expand Down
4 changes: 4 additions & 0 deletions cw_core/lib/crypto_currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
CryptoCurrency.flip,
CryptoCurrency.deuro,
CryptoCurrency.usdtbsc,
CryptoCurrency.xdai,
CryptoCurrency.gno,
];

static const havenCurrencies = [
Expand Down Expand Up @@ -235,6 +237,8 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
static const flip = CryptoCurrency(title: 'FLIP', tag: 'ETH', fullName: 'Chainflip', raw: 97, name: 'flip', iconPath: 'assets/images/flip_icon.png', decimals: 18);
static const deuro = CryptoCurrency(title: 'DEURO', tag: 'ETH', fullName: 'Decentralized Euro', raw: 98, name: 'deuro', iconPath: 'assets/images/deuro_icon.png', decimals: 18);
static const usdtbsc = CryptoCurrency(title: 'USDT', tag: 'BSC', fullName: 'USDT Binance coin', raw: 99, name: 'usdtbsc', iconPath: 'assets/images/usdtbsc_icon.png', decimals: 18);
static const xdai = CryptoCurrency(title: 'XDAI', tag: 'XDAI', fullName: 'xDAI', raw: 100, name: 'xDAI', iconPath: 'assets/images/xdai.png', decimals: 18);
static const gno = CryptoCurrency(title: 'GNO', tag: 'XDAI', fullName: 'Gnosis', raw: 101, name: 'gnoxdai', iconPath: 'assets/images/gno.png', decimals: 18);

static final Map<int, CryptoCurrency> _rawCurrencyMap =
[...all, ...havenCurrencies].fold<Map<int, CryptoCurrency>>(<int, CryptoCurrency>{}, (acc, item) {
Expand Down
4 changes: 4 additions & 0 deletions cw_core/lib/currency_for_wallet_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ CryptoCurrency currencyForWalletType(WalletType type, {bool? isTestnet}) {
return CryptoCurrency.zano;
case WalletType.decred:
return CryptoCurrency.dcr;
case WalletType.gnosis:
return CryptoCurrency.xdai;
case WalletType.none:
throw Exception(
'Unexpected wallet type: ${type.toString()} for CryptoCurrency currencyForWalletType');
Expand All @@ -60,6 +62,8 @@ WalletType? walletTypeForCurrency(CryptoCurrency currency) {
return WalletType.banano;
case CryptoCurrency.maticpoly:
return WalletType.polygon;
case CryptoCurrency.xdai:
return WalletType.gnosis;
case CryptoCurrency.sol:
return WalletType.solana;
case CryptoCurrency.trx:
Expand Down
1 change: 1 addition & 0 deletions cw_core/lib/erc20_token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Erc20Token extends CryptoCurrency with HiveObjectMixin {
static const boxName = 'Erc20Tokens';
static const ethereumBoxName = 'EthereumErc20Tokens';
static const polygonBoxName = 'PolygonErc20Tokens';
static const gnosisBoxName = 'GnosisErc20Tokens';

@override
bool operator ==(other) =>
Expand Down
2 changes: 2 additions & 0 deletions cw_core/lib/node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Node extends HiveObject with Keyable {
case WalletType.banano:
case WalletType.ethereum:
case WalletType.polygon:
case WalletType.gnosis:
case WalletType.solana:
case WalletType.tron:
case WalletType.zano:
Expand Down Expand Up @@ -163,6 +164,7 @@ class Node extends HiveObject with Keyable {
case WalletType.bitcoinCash:
case WalletType.ethereum:
case WalletType.polygon:
case WalletType.gnosis:
case WalletType.solana:
case WalletType.tron:
return requestElectrumServer();
Expand Down
18 changes: 17 additions & 1 deletion cw_core/lib/wallet_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const walletTypes = [
WalletType.litecoin,
WalletType.haven,
WalletType.ethereum,
WalletType.gnosis,
WalletType.bitcoinCash,
WalletType.nano,
WalletType.banano,
Expand Down Expand Up @@ -65,7 +66,10 @@ enum WalletType {
zano,

@HiveField(14)
decred
decred,

@HiveField(15)
gnosis
}

int serializeToInt(WalletType type) {
Expand Down Expand Up @@ -98,6 +102,8 @@ int serializeToInt(WalletType type) {
return 12;
case WalletType.decred:
return 13;
case WalletType.gnosis:
return 14;
case WalletType.none:
return -1;
}
Expand Down Expand Up @@ -133,6 +139,8 @@ WalletType deserializeFromInt(int raw) {
return WalletType.zano;
case 13:
return WalletType.decred;
case 14:
return WalletType.gnosis;
default:
throw Exception(
'Unexpected token: $raw for WalletType deserializeFromInt');
Expand Down Expand Up @@ -169,6 +177,8 @@ String walletTypeToString(WalletType type) {
return 'Zano';
case WalletType.decred:
return 'Decred';
case WalletType.gnosis:
return 'Gnosis';
case WalletType.none:
return '';
}
Expand Down Expand Up @@ -204,6 +214,8 @@ String walletTypeToDisplayName(WalletType type) {
return 'Zano (ZANO)';
case WalletType.decred:
return 'Decred (DCR)';
case WalletType.gnosis:
return 'Gnosis (xDAI)';
case WalletType.none:
return '';
}
Expand Down Expand Up @@ -242,6 +254,8 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type, {bool isTestnet = fal
return CryptoCurrency.zano;
case WalletType.decred:
return CryptoCurrency.dcr;
case WalletType.gnosis:
return CryptoCurrency.xdai;
case WalletType.none:
throw Exception(
'Unexpected wallet type: ${type.toString()} for CryptoCurrency walletTypeToCryptoCurrency');
Expand Down Expand Up @@ -278,6 +292,8 @@ WalletType? cryptoCurrencyToWalletType(CryptoCurrency type) {
return WalletType.zano;
case CryptoCurrency.dcr:
return WalletType.decred;
case CryptoCurrency.xdai:
return WalletType.gnosis;
default:
return null;
}
Expand Down
30 changes: 30 additions & 0 deletions cw_gnosis/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
1 change: 1 addition & 0 deletions cw_gnosis/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
4 changes: 4 additions & 0 deletions cw_gnosis/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
3 changes: 3 additions & 0 deletions cw_gnosis/devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:
54 changes: 54 additions & 0 deletions cw_gnosis/lib/default_gnosis_erc20_tokens.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/erc20_token.dart';

class DefaultGnosisErc20Tokens {
final List<Erc20Token> _defaultTokens = [
Erc20Token(
name: "Wrapped Ether",
symbol: "WETH",
contractAddress: "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1",
decimal: 18,
enabled: false,
),
Erc20Token(
name: "Tether USD on xDai",
symbol: "USDT",
contractAddress: "0x4ECaBa5870353805a9F068101A40E0f32ed605C6",
decimal: 6,
enabled: true,
),
Erc20Token(
name: "USD Coin",
symbol: "USDC.e",
contractAddress: "0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0",
decimal: 6,
enabled: true,
),
Erc20Token(
name: "Gnosis",
symbol: "GNO",
contractAddress: "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb",
decimal: 18,
enabled: true,
),
Erc20Token(
name: "Decentralized Euro",
symbol: "DEURO",
contractAddress: "0xac90f343820D8299Ac72a06A7674491b07d45f03",
decimal: 18,
enabled: true,
),
];

List<Erc20Token> get initialGnosisErc20Tokens => _defaultTokens.map((token) {
String? iconPath;
try {
iconPath = CryptoCurrency.all
.firstWhere((element) =>
element.title.toUpperCase() == token.symbol.split(".").first.toUpperCase())
.iconPath;
} catch (_) {}

return Erc20Token.copyWith(token, iconPath, 'XDAI');
}).toList();
}
92 changes: 92 additions & 0 deletions cw_gnosis/lib/gnosis_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import 'dart:convert';

import 'package:cw_evm/evm_chain_client.dart';
import 'package:cw_evm/.secrets.g.dart' as secrets;
import 'package:cw_evm/evm_chain_transaction_model.dart';
import 'package:flutter/foundation.dart';
import 'package:web3dart/web3dart.dart';

class GnosisClient extends EVMChainClient {
@override
Transaction createTransaction({
required EthereumAddress from,
required EthereumAddress to,
required EtherAmount amount,
EtherAmount? maxPriorityFeePerGas,
Uint8List? data,
int? maxGas,
EtherAmount? gasPrice,
EtherAmount? maxFeePerGas,
}) {
return Transaction(
from: from,
to: to,
value: amount,
// data: data,
maxGas: maxGas,
// gasPrice: gasPrice,
// maxFeePerGas: maxFeePerGas,
// maxPriorityFeePerGas: maxPriorityFeePerGas,
);
}

@override
Uint8List prepareSignedTransactionForSending(Uint8List signedTransaction) => signedTransaction;

@override
int get chainId => 137;

@override
Future<List<EVMChainTransactionModel>> fetchTransactions(String address,
{String? contractAddress}) async {
try {
final response = await client.get(Uri.https("api.gnosisscan.io", "/v2/api", {
"chainid": "$chainId",
"module": "account",
"action": contractAddress != null ? "tokentx" : "txlist",
if (contractAddress != null) "contractaddress": contractAddress,
"address": address,
"apikey": secrets.etherScanApiKey,
}));

final jsonResponse = json.decode(response.body) as Map<String, dynamic>;

if (response.statusCode >= 200 && response.statusCode < 300 && jsonResponse['status'] != 0) {
return (jsonResponse['result'] as List)
.map(
(e) => EVMChainTransactionModel.fromJson(e as Map<String, dynamic>, 'XDAI'),
)
.toList();
}

return [];
} catch (e) {
return [];
}
}

@override
Future<List<EVMChainTransactionModel>> fetchInternalTransactions(String address) async {
try {
final response = await client.get(Uri.https("api.gnosisscan.io", "/v2/api", {
"chainid": "$chainId",
"module": "account",
"action": "txlistinternal",
"address": address,
"apikey": secrets.etherScanApiKey,
}));

final jsonResponse = json.decode(response.body) as Map<String, dynamic>;

if (response.statusCode >= 200 && response.statusCode < 300 && jsonResponse['status'] != 0) {
return (jsonResponse['result'] as List)
.map((e) => EVMChainTransactionModel.fromJson(e as Map<String, dynamic>, 'XDAI'))
.toList();
}

return [];
} catch (_) {
return [];
}
}
}
5 changes: 5 additions & 0 deletions cw_gnosis/lib/gnosis_mnemonics_exception.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class GnosisMnemonicIsIncorrectException implements Exception {
@override
String toString() =>
'Polygon mnemonic has incorrect format. Mnemonic should contain 12 or 24 words separated by space.';
}
20 changes: 20 additions & 0 deletions cw_gnosis/lib/gnosis_transaction_history.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'dart:core';

import 'package:cw_evm/evm_chain_transaction_history.dart';
import 'package:cw_evm/evm_chain_transaction_info.dart';
import 'package:cw_gnosis/gnosis_transaction_info.dart';

class GnosisTransactionHistory extends EVMChainTransactionHistory {
GnosisTransactionHistory({
required super.walletInfo,
required super.password,
required super.encryptionFileUtils,
});

@override
String getTransactionHistoryFileName() => 'gnosis_transactions.json';

@override
EVMChainTransactionInfo getTransactionInfo(Map<String, dynamic> val) =>
GnosisTransactionInfo.fromJson(val);
}
Loading
Loading