Skip to content

Commit

Permalink
New versions (cake-tech#1312)
Browse files Browse the repository at this point in the history
* New versions
Fix issues with Monero.com

* Add sending for Solana tokens exchanges

* Add default keyword for P2WPKH [skip ci]

* chore: Switch solana commitment to confirmed to reduced blockhash expiration (cake-tech#1313)

* Modify test workflow to send arm64-v8a build only

* Fix workflow build path

* Remove unnecessary reverse of txId

* Show case sensitive evm wallet address

* Revert default Cake Theme
add custom package id for test builds

* Fix workflow script

* Fix workflow

* hash branch name

* hash branch name

* Update versions

* Add user image to Nostr
Add fetching address from text for tokens

* Fix test app package id

* fix: Solana message improvement (cake-tech#1316)

---------

Co-authored-by: Adegoke David <64401859+Blazebrain@users.noreply.github.com>
  • Loading branch information
OmarHatem28 and Blazebrain committed Mar 4, 2024
1 parent 10fd32f commit c7deeae
Show file tree
Hide file tree
Showing 28 changed files with 186 additions and 138 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/pr_test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,7 @@ jobs:
- name: Build generated code
run: |
cd /opt/android/cake_wallet
cd cw_core && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_evm && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_monero && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_bitcoin && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_haven && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_bitcoin_cash && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_nano && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_solana && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_ethereum && flutter pub get && cd ..
cd cw_polygon && flutter pub get && cd ..
flutter packages pub run build_runner build --delete-conflicting-outputs
./model_generator.sh
- name: Add secrets
run: |
Expand Down Expand Up @@ -159,12 +149,16 @@ jobs:
echo "const ankrApiKey = '${{ secrets.ANKR_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart
- name: Rename app
run: echo -e "id=com.cakewallet.test\nname=${{ env.BRANCH_NAME }}" > /opt/android/cake_wallet/android/app.properties
run: |
hash=`sha512sum <<<"${{ env.BRANCH_NAME }}"`
substring=${hash:0:15}
echo substring
echo -e "id=com.cakewallet.test_$(substring)\nname=${{ env.BRANCH_NAME }}" > /opt/android/cake_wallet/android/app.properties
- name: Build
run: |
cd /opt/android/cake_wallet
flutter build apk --release
flutter build apk --release --split-per-abi
# - name: Push to App Center
# run: |
Expand All @@ -181,21 +175,21 @@ jobs:

- name: Rename apk file
run: |
cd /opt/android/cake_wallet/build/app/outputs/apk/release
cd /opt/android/cake_wallet/build/app/outputs/flutter-apk
mkdir test-apk
cp app-release.apk test-apk/${{env.BRANCH_NAME}}.apk
cp app-arm64-v8a-release.apk test-apk/${{env.BRANCH_NAME}}.apk
- name: Upload Artifact
uses: kittaakos/upload-artifact-as-is@v0
with:
path: /opt/android/cake_wallet/build/app/outputs/apk/release/test-apk/
path: /opt/android/cake_wallet/build/app/outputs/flutter-apk/test-apk/

- name: Send Test APK
continue-on-error: true
uses: adrey/slack-file-upload-action@1.0.5
with:
token: ${{ secrets.SLACK_APP_TOKEN }}
path: /opt/android/cake_wallet/build/app/outputs/apk/release/app-release.apk
path: /opt/android/cake_wallet/build/app/outputs/flutter-apk/test-apk/${{env.BRANCH_NAME}}.apk
channel: ${{ secrets.SLACK_APK_CHANNEL }}
title: "${{ env.BRANCH_NAME }}.apk"
filename: ${{ env.BRANCH_NAME }}.apk
Expand Down
5 changes: 2 additions & 3 deletions assets/text/Monerocom_Release_Notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Improve wallet recovery and error tolerance
Enhance Background sync for Monero wallets
Bug fixes
New themes
Bug fixes and enhancements
5 changes: 4 additions & 1 deletion assets/text/Release_Notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Add Solana wallet
Support ALL Bitcoin address types (Legacy, Segwit (both variants), Taproot)
Enhance Sending/Receiving flow for Bitcoin
Improve fee calculations in Bitcoin
Improve fee calculations in Bitcoin
New themes
Bug fixes and enhancements
4 changes: 2 additions & 2 deletions cw_bitcoin/lib/bitcoin_receive_page_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:cw_core/receive_page_option.dart';

class BitcoinReceivePageOption implements ReceivePageOption {
static const p2wpkh = BitcoinReceivePageOption._('Segwit (P2WPKH)');
static const p2wpkh = BitcoinReceivePageOption._('Segwit (P2WPKH) (Default)');
static const p2sh = BitcoinReceivePageOption._('Segwit-Compatible (P2SH)');
static const p2tr = BitcoinReceivePageOption._('Taproot (P2TR)');
static const p2wsh = BitcoinReceivePageOption._('Segwit (P2WSH)');
Expand All @@ -18,9 +18,9 @@ class BitcoinReceivePageOption implements ReceivePageOption {

static const all = [
BitcoinReceivePageOption.p2wpkh,
BitcoinReceivePageOption.p2sh,
BitcoinReceivePageOption.p2tr,
BitcoinReceivePageOption.p2wsh,
BitcoinReceivePageOption.p2sh,
BitcoinReceivePageOption.p2pkh
];

Expand Down
14 changes: 3 additions & 11 deletions cw_bitcoin/lib/electrum_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import 'package:cw_core/utils/file.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:flutter/foundation.dart';
import 'package:hex/hex.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:rxdart/subjects.dart';
Expand Down Expand Up @@ -623,16 +622,9 @@ abstract class ElectrumWalletBase
final ins = <bitcoin_base.BtcTransaction>[];

for (final vin in original.inputs) {
try {
final id = HEX.encode(HEX.decode(vin.txId).reversed.toList());
final txHex = await electrumClient.getTransactionHex(hash: id);
final tx = bitcoin_base.BtcTransaction.fromRaw(txHex);
ins.add(tx);
} catch (_) {
ins.add(bitcoin_base.BtcTransaction.fromRaw(
await electrumClient.getTransactionHex(hash: vin.txId),
));
}
final txHex = await electrumClient.getTransactionHex(hash: vin.txId);
final tx = bitcoin_base.BtcTransaction.fromRaw(txHex);
ins.add(tx);
}

return ElectrumTransactionBundle(original,
Expand Down
12 changes: 11 additions & 1 deletion cw_core/lib/crypto_currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
CryptoCurrency.usdcEPoly,
CryptoCurrency.kaspa,
CryptoCurrency.digibyte,
CryptoCurrency.usdtSol,
];

static const havenCurrencies = [
Expand Down Expand Up @@ -246,7 +247,16 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
return CryptoCurrency._rawCurrencyMap[raw]!;
}

static CryptoCurrency fromString(String name) {
// TODO: refactor this
static CryptoCurrency fromString(String name, {CryptoCurrency? walletCurrency}) {
try {
return CryptoCurrency.all.firstWhere((element) =>
element.title.toLowerCase() == name &&
(element.tag == null ||
element.tag == walletCurrency?.title ||
element.tag == walletCurrency?.tag));
} catch (_) {}

if (CryptoCurrency._nameCurrencyMap[name.toLowerCase()] == null) {
final s = 'Unexpected token: $name for CryptoCurrency fromString';
throw ArgumentError.value(name, 'name', s);
Expand Down
2 changes: 1 addition & 1 deletion cw_evm/lib/evm_chain_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ abstract class EVMChainWalletBase
privateKey: _hexPrivateKey,
password: _password,
);
walletAddresses.address = _evmChainPrivateKey.address.toString();
walletAddresses.address = _evmChainPrivateKey.address.hexEip55;
await save();
}

Expand Down
11 changes: 6 additions & 5 deletions cw_solana/lib/solana_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class SolanaWalletClient {
required Ed25519HDKeyPair ownerKeypair,
List<String> references = const [],
}) async {
const commitment = Commitment.finalized;
const commitment = Commitment.confirmed;

final latestBlockhash =
await _client!.rpcClient.getLatestBlockhash(commitment: commitment).value;
Expand Down Expand Up @@ -394,9 +394,7 @@ class SolanaWalletClient {
funder: ownerKeypair,
);
} catch (e) {
throw Exception(
'Error while creating an associated token account for the recipient: ${e.toString()}',
);
throw Exception('Insufficient lamports balance to complete this transaction');
}

// Input by the user
Expand Down Expand Up @@ -468,7 +466,10 @@ class SolanaWalletClient {
required SignedTx signedTransaction,
required Commitment commitment,
}) async {
final signature = await _client!.rpcClient.sendTransaction(signedTransaction.encode());
final signature = await _client!.rpcClient.sendTransaction(
signedTransaction.encode(),
preflightCommitment: commitment,
);

_client!.waitForSignatureStatus(signature, status: commitment);

Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
platform :ios, '12.0'
source 'https://github.com/CocoaPods/Specs.git'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
Expand Down Expand Up @@ -44,7 +44,7 @@ post_install do |installer|
flutter_additional_ios_build_settings(target)

target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

Expand Down
24 changes: 12 additions & 12 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PODS:
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
- CryptoSwift (1.7.1)
- CryptoSwift (1.8.1)
- cw_haven (0.0.1):
- cw_haven/Boost (= 0.0.1)
- cw_haven/Haven (= 0.0.1)
Expand Down Expand Up @@ -132,19 +132,19 @@ PODS:
- permission_handler_apple (9.1.1):
- Flutter
- ReachabilitySwift (5.0.0)
- SDWebImage (5.16.0):
- SDWebImage/Core (= 5.16.0)
- SDWebImage/Core (5.16.0)
- SDWebImage (5.18.11):
- SDWebImage/Core (= 5.18.11)
- SDWebImage/Core (5.18.11)
- sensitive_clipboard (0.0.1):
- Flutter
- share_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- SwiftProtobuf (1.22.0)
- SwiftProtobuf (1.25.2)
- SwiftyGif (5.4.4)
- Toast (4.0.0)
- Toast (4.1.0)
- uni_links (0.0.1):
- Flutter
- UnstoppableDomainsResolution (4.0.0):
Expand Down Expand Up @@ -262,8 +262,8 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
barcode_scan2: 0af2bb63c81b4565aab6cd78278e4c0fa136dbb0
BigInt: f668a80089607f521586bbe29513d708491ef2f7
connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e
CryptoSwift: d3d18dc357932f7e6d580689e065cf1f176007c1
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
CryptoSwift: b9c701d6f5011df23794dbf7f2e480a77835d83d
cw_haven: b3e54e1fbe7b8e6fda57a93206bc38f8e89b898a
cw_monero: 4cf3b96f2da8e95e2ef7d6703dd4d2c509127b7d
cw_shared_external: 2972d872b8917603478117c9957dfca611845a92
Expand All @@ -287,19 +287,19 @@ SPEC CHECKSUMS:
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
SDWebImage: 2aea163b50bfcb569a2726b6a754c54a4506fcf6
SDWebImage: a3ba0b8faac7228c3c8eadd1a55c9c9fe5e16457
sensitive_clipboard: d4866e5d176581536c27bb1618642ee83adca986
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
SwiftProtobuf: 40bd808372cb8706108f22d28f8ab4a6b9bc6989
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
Toast: ec33c32b8688982cecc6348adeae667c1b9938da
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
UnstoppableDomainsResolution: c3c67f4d0a5e2437cb00d4bd50c2e00d6e743841
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47
workmanager: 0afdcf5628bbde6924c21af7836fed07b42e30e6

PODFILE CHECKSUM: 09df1114e7c360f55770d35a79356bf5446e0100
PODFILE CHECKSUM: fcb1b8418441a35b438585c9dd8374e722e6c6ca

COCOAPODS: 1.12.1
11 changes: 3 additions & 8 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -523,7 +523,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -561,7 +561,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -607,9 +607,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
};
};
}
21 changes: 19 additions & 2 deletions lib/bitcoin/cw_bitcoin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,28 @@ class CWBitcoin extends Bitcoin {
}

@override
BitcoinReceivePageOption getSelectedAddressType(Object wallet) {
ReceivePageOption getSelectedAddressType(Object wallet) {
final bitcoinWallet = wallet as ElectrumWallet;
return BitcoinReceivePageOption.fromType(bitcoinWallet.walletAddresses.addressPageType);
}

@override
List<BitcoinReceivePageOption> getBitcoinReceivePageOptions() => BitcoinReceivePageOption.all;
List<ReceivePageOption> getBitcoinReceivePageOptions() => BitcoinReceivePageOption.all;

@override
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option) {
switch (option) {
case BitcoinReceivePageOption.p2pkh:
return P2pkhAddressType.p2pkh;
case BitcoinReceivePageOption.p2sh:
return P2shAddressType.p2wpkhInP2sh;
case BitcoinReceivePageOption.p2tr:
return SegwitAddresType.p2tr;
case BitcoinReceivePageOption.p2wsh:
return SegwitAddresType.p2wsh;
case BitcoinReceivePageOption.p2wpkh:
default:
return SegwitAddresType.p2wpkh;
}
}
}
10 changes: 10 additions & 0 deletions lib/core/address_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ class AddressValidator extends TextValidator {
case CryptoCurrency.sol:
return '([^0-9a-zA-Z]|^)[1-9A-HJ-NP-Za-km-z]{43,44}([^0-9a-zA-Z]|\$)';
default:
if (type.tag == CryptoCurrency.eth.title) {
return '0x[0-9a-zA-Z]{42}';
}
if (type.tag == CryptoCurrency.maticpoly.tag) {
return '0x[0-9a-zA-Z]{42}';
}
if (type.tag == CryptoCurrency.sol.title) {
return '([^0-9a-zA-Z]|^)[1-9A-HJ-NP-Za-km-z]{43,44}([^0-9a-zA-Z]|\$)';
}

return null;
}
}
Expand Down
Loading

0 comments on commit c7deeae

Please sign in to comment.