Skip to content

Commit

Permalink
Merge pull request #19 from alienc0der/bigint-support
Browse files Browse the repository at this point in the history
BigInt support & WalletConnect implementation
  • Loading branch information
interstellartraveler77 authored Jul 20, 2023
2 parents c996cc4 + cbac36f commit 2a86d3b
Show file tree
Hide file tree
Showing 145 changed files with 3,573 additions and 1,299 deletions.
31 changes: 24 additions & 7 deletions .github/workflows/syrius_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:

jobs:
build-macos:
environment: wallet-connect
env:
WALLET_CONNECT_PROJECT_ID: ${{ secrets.WC_PROJECT_ID }}
runs-on: macos-12
steps:
- name: Checkout
Expand All @@ -23,15 +26,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
uses: subosito/flutter-action@v2.10.0
with:
channel: "stable"
flutter-version: "3.10.2"
- name: Check flutter version
run: flutter --version
- name: Build syrius desktop
run: |
flutter config --enable-macos-desktop
flutter build macos --release
flutter build macos --dart-define=WC_PROJECT_ID=$WALLET_CONNECT_PROJECT_ID --release
- name: Package into DMG
run: |
create-dmg --volname syrius \
Expand All @@ -53,20 +57,24 @@ jobs:
name: macos-artifacts
path: syrius-alphanet-macos-universal.dmg
build-windows:
environment: wallet-connect
env:
WALLET_CONNECT_PROJECT_ID: ${{ secrets.WC_PROJECT_ID }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
uses: subosito/flutter-action@v2.10.0
with:
channel: "stable"
flutter-version: "3.10.2"
- name: Check flutter version
run: flutter --version
- name: Build syrius desktop
run: |
flutter config --enable-windows-desktop
flutter build windows --release
flutter build windows --dart-define=WC_PROJECT_ID=$env:WALLET_CONNECT_PROJECT_ID --release
- name: Package into zip
run: |
Compress-Archive -Path build\windows\runner\Release\* -DestinationPath .\syrius-alphanet-windows-amd64.zip
Expand All @@ -76,6 +84,9 @@ jobs:
name: windows-artifacts
path: syrius-alphanet-windows-amd64.zip
build-linux:
environment: wallet-connect
env:
WALLET_CONNECT_PROJECT_ID: ${{ secrets.WC_PROJECT_ID }}
runs-on: ubuntu-20.04
steps:
- name: Checkout
Expand All @@ -85,15 +96,21 @@ jobs:
sudo apt update
sudo apt install -y curl clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev unzip xz-utils zip libnotify-dev libayatana-appindicator3-dev
- name: Setup Flutter
uses: subosito/flutter-action@v2
uses: subosito/flutter-action@v2.10.0
with:
channel: "stable"
flutter-version: "3.10.2"
- name: Set permissions
run: |
sudo chmod -R 777 linux/
- name: Check flutter version
run: flutter --version
run: |
which flutter
flutter --version
- name: Build syrius desktop
run: |
flutter config --enable-linux-desktop
flutter build linux --release
flutter build linux --dart-define=WC_PROJECT_ID=$WALLET_CONNECT_PROJECT_ID --release -v
- name: Package zip
run: |
cd build/linux/x64/release/bundle
Expand Down
69 changes: 14 additions & 55 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.classpath
.project
.settings/
.vscode/
.vscode/*

# Flutter repo-specific
/bin/cache/
Expand Down Expand Up @@ -51,17 +51,14 @@ analysis_benchmark.json
.flutter-plugins-dependencies
**/generated_plugin_registrant.dart
.packages
.pub-cache/
.pub-preload-cache/
.pub/
build/
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds

# Web related
lib/generated_plugin_registrant.dart

# Android related
**/android/**/gradle-wrapper.jar
.gradle/
Expand Down Expand Up @@ -104,71 +101,33 @@ lib/generated_plugin_registrant.dart
**/ios/Runner/GeneratedPluginRegistrant.*

# macOS
**/Flutter/ephemeral/
**/Pods/
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/ephemeral
**/xcuserdata/

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Windows
**/windows/flutter/generated_plugin_registrant.cc
**/windows/flutter/generated_plugin_registrant.h
**/windows/flutter/generated_plugins.cmake

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk
# Linux
**/linux/flutter/generated_plugin_registrant.cc
**/linux/flutter/generated_plugin_registrant.h
**/linux/flutter/generated_plugins.cmake

# Coverage
coverage/

# Symbols
app.*.symbols

# Obfuscation related
app.*.map.json

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
!pubspec.lock
!.vscode/settings.json
30 changes: 30 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.

version:
revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
- platform: windows
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ Dependencies:

Currently supported `<os>`: `windows`, `macos`, `linux`

The [WalletConnect](https://github.com/WalletConnect) integration requires setting the `WC_PROJECT_ID` environmental variable.

```bash
git clone https://github.com/zenon-network/syrius.git
flutter pub get
flutter build <os>
flutter build <os> --release
flutter run --release
flutter run --dart-define=WC_PROJECT_ID=walletconnect_project_id -d <os>
flutter build --dart-define=WC_PROJECT_ID=walletconnect_project_id <os>
```

## Contributing

Please check CONTRIBUTING for more details.
Please check [CONTRIBUTING](./CONTRIBUTING.md) for more details.

## License

The MIT License (MIT). Please check LICENSE for more information.
The MIT License (MIT). Please check [LICENSE](./LICENSE) for more information.
12 changes: 12 additions & 0 deletions assets/svg/walletconnect-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion lib/blocs/accelerator/accelerator_balance_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class AcceleratorBalanceBloc extends BaseBloc<AccountInfo?> {
AccountInfo accountInfo = await zenon!.ledger.getAccountInfoByAddress(
acceleratorAddress,
);
if (accountInfo.qsr()! > 0 || accountInfo.znn()! > 0) {
if (accountInfo.qsr()! > BigInt.zero ||
accountInfo.znn()! > BigInt.zero) {
addEvent(accountInfo);
} else {
throw 'Accelerator fund empty';
Expand Down
4 changes: 2 additions & 2 deletions lib/blocs/accelerator/create_phase_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class CreatePhaseBloc extends BaseBloc<AccountBlockTemplate?> {
String name,
String description,
String url,
int znnFundsNeeded,
int qsrFundsNeeded,
BigInt znnFundsNeeded,
BigInt qsrFundsNeeded,
) async {
try {
addEvent(null);
Expand Down
6 changes: 3 additions & 3 deletions lib/blocs/accelerator/create_project_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class CreateProjectBloc extends BaseBloc<AccountBlockTemplate?> {
String name,
String description,
String url,
int znnFundsNeeded,
int qsrFundsNeeded,
BigInt znnFundsNeeded,
BigInt qsrFundsNeeded,
) {
try {
addEvent(null);
Expand All @@ -26,7 +26,7 @@ class CreateProjectBloc extends BaseBloc<AccountBlockTemplate?> {
'creating project',
).then(
(block) {
AddressUtils.refreshBalance();
ZenonAddressUtils.refreshBalance();
addEvent(block);
},
).onError(
Expand Down
11 changes: 5 additions & 6 deletions lib/blocs/accelerator/submit_donation_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart';
import 'package:zenon_syrius_wallet_flutter/main.dart';
import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart';
import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart';
import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart';
import 'package:znn_sdk_dart/znn_sdk_dart.dart';

class SubmitDonationBloc extends BaseBloc<AccountBlockTemplate?> {
Future<void> submitDonation(num znnAmount, num qsrAmount) async {
Future<void> submitDonation(BigInt znnAmount, BigInt qsrAmount) async {
try {
addEvent(null);
if (znnAmount > 0) {
if (znnAmount > BigInt.zero) {
await _sendDonationBlock(zenon!.embedded.accelerator.donate(
znnAmount.extractDecimals(znnDecimals),
znnAmount,
kZnnCoin.tokenStandard,
));
}
if (qsrAmount > 0) {
if (qsrAmount > BigInt.zero) {
await _sendDonationBlock(zenon!.embedded.accelerator.donate(
qsrAmount.extractDecimals(qsrDecimals),
qsrAmount,
kQsrCoin.tokenStandard,
));
}
Expand Down
14 changes: 4 additions & 10 deletions lib/blocs/accelerator/update_phase_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart';
import 'package:zenon_syrius_wallet_flutter/main.dart';
import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart';
import 'package:zenon_syrius_wallet_flutter/utils/utils.dart';
import 'package:znn_sdk_dart/znn_sdk_dart.dart';

class UpdatePhaseBloc extends BaseBloc<AccountBlockTemplate?> {
void updatePhase(Hash id, String name, String description, String url,
double znnFundsNeeded, double qsrFundsNeeded) {
BigInt znnFundsNeeded, BigInt qsrFundsNeeded) {
try {
addEvent(null);
AccountBlockTemplate transactionParams =
Expand All @@ -14,14 +14,8 @@ class UpdatePhaseBloc extends BaseBloc<AccountBlockTemplate?> {
name,
description,
url,
AmountUtils.extractDecimals(
znnFundsNeeded,
znnDecimals,
),
AmountUtils.extractDecimals(
qsrFundsNeeded,
qsrDecimals,
),
znnFundsNeeded,
qsrFundsNeeded,
);
AccountBlockUtils.createAccountBlock(transactionParams, 'update phase')
.then(
Expand Down
4 changes: 3 additions & 1 deletion lib/blocs/auto_receive_tx_worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AutoReceiveTxWorker extends BaseBloc<WalletNotification> {
);
_sendSuccessNotification(response, toAddress);
} on RpcException catch (e, stackTrace) {
_sendErrorNotification(e.toString());
Logger('AutoReceiveTxWorker')
.log(Level.WARNING, 'autoReceive', e, stackTrace);
if (e.message.compareTo('account-block from-block already received') !=
Expand Down Expand Up @@ -74,7 +75,8 @@ class AutoReceiveTxWorker extends BaseBloc<WalletNotification> {
void _sendSuccessNotification(AccountBlockTemplate block, String toAddress) {
addEvent(
WalletNotification(
title: 'Transaction received on ${AddressUtils.getLabel(toAddress)}',
title:
'Transaction received on ${ZenonAddressUtils.getLabel(toAddress)}',
timestamp: DateTime.now().millisecondsSinceEpoch,
details: 'Transaction hash: ${block.hash}',
type: NotificationType.paymentReceived,
Expand Down
Loading

0 comments on commit 2a86d3b

Please sign in to comment.