diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d126702 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# aar 18M,放在在主目录,拷贝到libs下 +**/android/app/libs/WalletCore.aar \ No newline at end of file diff --git a/SimpleMultiSig.sol b/SimpleMultiSig.sol new file mode 100644 index 0000000..34ba7f2 --- /dev/null +++ b/SimpleMultiSig.sol @@ -0,0 +1,100 @@ +pragma solidity ^0.5.0; + +contract SimpleMultiSig { + +// EIP712 Precomputed hashes: +// keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)") +bytes32 constant EIP712DOMAINTYPE_HASH = 0xd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac56472; + +// keccak256("Simple MultiSig") +bytes32 constant NAME_HASH = 0xb7a0bfa1b79f2443f4d73ebb9259cddbcd510b18be6fc4da7d1aa7b1786e73e6; + +// keccak256("1") +bytes32 constant VERSION_HASH = 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6; + +// keccak256("MultiSigTransaction(address destination,uint256 value,bytes data,uint256 nonce,address executor,uint256 gasLimit)") +bytes32 constant TXTYPE_HASH = 0x3ee892349ae4bbe61dce18f95115b5dc02daf49204cc602458cd4c1f540d56d7; + +bytes32 constant SALT = 0x251543af6a222378665a76fe38dbceae4871a070b7fdaf5c6c30cf758dc33cc0; + + event Execute(address[] _confirmAddrs, address _destination, uint _value, bytes data); + event Deposit(address indexed _from,uint _value); + + // debug events + // event DbgExecuteParam(bytes32 sperator, bytes32 txInputHash, bytes32 totalHash, bytes txInput); + // event DbgRecover(address _recovered); + + uint public nonce; // (only) mutable state + uint public threshold; // immutable state + mapping (address => bool) isOwner; // immutable state + address[] public ownersArr; // immutable state + + bytes32 DOMAIN_SEPARATOR; // hash for EIP712, computed from contract address + + // Note that owners_ must be strictly increasing, in order to prevent duplicates + constructor(uint threshold_, address[] memory owners_, uint chainId) public { + require(owners_.length <= 10 && threshold_ <= owners_.length && threshold_ > 0, "0 lastAdd, "repeated owner or not sorted"); + isOwner[owners_[i]] = true; + lastAdd = owners_[i]; + } + ownersArr = owners_; + threshold = threshold_; + + DOMAIN_SEPARATOR = keccak256(abi.encode(EIP712DOMAINTYPE_HASH, + NAME_HASH, + VERSION_HASH, + chainId, + this, + SALT)); + } + + // Note that address recovered from signatures must be strictly increasing, in order to prevent duplicates + function execute(uint8[] memory sigV, bytes32[] memory sigR, bytes32[] memory sigS, + address destination, uint value, bytes memory data, address executor, uint gasLimit) public { + + require(sigR.length == threshold, "R len not equal to threshold"); + require(sigR.length == sigS.length && sigR.length == sigV.length, "length of r/s/v not match"); + require(executor == msg.sender || executor == address(0), "wrong executor"); + + // EIP712 scheme: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md + bytes32 txInputHash = keccak256(abi.encode(TXTYPE_HASH, destination, value, keccak256(data), nonce, executor, gasLimit)); + bytes32 totalHash = keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, txInputHash)); + + // emit DbgExecuteParam(DOMAIN_SEPARATOR, txInputHash, totalHash, abi.encode(TXTYPE_HASH, destination, value, keccak256(data), nonce, executor, gasLimit)); + + address lastAdd = address(0); // cannot have address(0) as an owner + address[] memory confirmAddrs = new address[](threshold); + for (uint i = 0; i < threshold; i++) { + address recovered = ecrecover(totalHash, sigV[i], sigR[i], sigS[i]); + require(recovered > lastAdd && isOwner[recovered], "Verify sig failed"); + // emit DbgRecover(recovered); + confirmAddrs[i] = recovered; + lastAdd = recovered; + } + + // If we make it here all signatures are accounted for. + // The address.call() syntax is no longer recommended, see: + // https://github.com/ethereum/solidity/issues/2884 + nonce = nonce + 1; + bool success = false; + assembly { success := call(gasLimit, destination, value, add(data, 0x20), mload(data), 0, 0) } + require(success, "not_success"); + emit Execute(confirmAddrs, destination, value, data); + } + + function getVersion() external pure returns (string memory) { + return "2.33"; // 版本号随便写的,无意义, + } + + function getOwersLength() external view returns (uint8) { + return uint8(ownersArr.length); //owners.length <= 10 (see constructor), so type convert is ok + } + + function () external payable { + emit Deposit(msg.sender, msg.value); + } +} diff --git a/WalletCore.aar b/WalletCore.aar new file mode 100644 index 0000000..100d396 Binary files /dev/null and b/WalletCore.aar differ diff --git a/demo_cold/.gitignore b/demo_cold/.gitignore new file mode 100644 index 0000000..ea33626 --- /dev/null +++ b/demo_cold/.gitignore @@ -0,0 +1,83 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# 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 +**/doc/api/ +.dart_tool/ +.flutter-plugins +.packages +.pub-cache/ +.pub/ +/build/ + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# 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 + + +# +**/android/**/.project +**/android/**/.classpath +**/android/**/.settings/ + + +# local files +local_* + diff --git a/demo_cold/.metadata b/demo_cold/.metadata new file mode 100644 index 0000000..e023651 --- /dev/null +++ b/demo_cold/.metadata @@ -0,0 +1,10 @@ +# 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 and should not be manually edited. + +version: + revision: 20e59316b8b8474554b38493b8ca888794b0234a + channel: stable + +project_type: app diff --git a/demo_cold/.vscode/settings.json b/demo_cold/.vscode/settings.json new file mode 100644 index 0000000..2421e38 --- /dev/null +++ b/demo_cold/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.exclude": { + "**/.classpath": true, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true + } +} \ No newline at end of file diff --git a/demo_cold/Makefile b/demo_cold/Makefile new file mode 100644 index 0000000..d229765 --- /dev/null +++ b/demo_cold/Makefile @@ -0,0 +1,8 @@ +fmt: + flutter format lib/* -l 120 +buildApk: + flutter build apk --target-platform android-arm --split-per-abi + +macCleanGradleCache: + rm -rf ~/.gradle/caches + cd android && gradle cleanBuildCache \ No newline at end of file diff --git a/demo_cold/README.md b/demo_cold/README.md new file mode 100644 index 0000000..b770092 --- /dev/null +++ b/demo_cold/README.md @@ -0,0 +1,16 @@ +# demo_cold + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/demo_cold/android/app/build.gradle b/demo_cold/android/app/build.gradle new file mode 100644 index 0000000..68a83a1 --- /dev/null +++ b/demo_cold/android/app/build.gradle @@ -0,0 +1,66 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +repositories{ + flatDir{ + dirs 'libs' + } +} +android { + compileSdkVersion 28 + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "io.dabank.sdkdemo.cold.demo_cold" + minSdkVersion 16 + targetSdkVersion 28 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation (name:'WalletCore',ext:'aar') + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' +} diff --git a/demo_cold/android/app/src/debug/AndroidManifest.xml b/demo_cold/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..67d5372 --- /dev/null +++ b/demo_cold/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/demo_cold/android/app/src/main/AndroidManifest.xml b/demo_cold/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5d26557 --- /dev/null +++ b/demo_cold/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + diff --git a/demo_cold/android/app/src/main/java/io/dabank/sdkdemo/cold/demo_cold/MainActivity.java b/demo_cold/android/app/src/main/java/io/dabank/sdkdemo/cold/demo_cold/MainActivity.java new file mode 100644 index 0000000..c004c03 --- /dev/null +++ b/demo_cold/android/app/src/main/java/io/dabank/sdkdemo/cold/demo_cold/MainActivity.java @@ -0,0 +1,144 @@ +package io.dabank.sdkdemo.cold.demo_cold; + +import android.os.Bundle; + +import java.util.List; + +import io.flutter.app.FlutterActivity; +import io.flutter.plugins.GeneratedPluginRegistrant; + +import mobile.Mobile; +import geth.Geth; + +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.MethodChannel.MethodCallHandler; +import io.flutter.plugin.common.MethodChannel.Result; + +public class MainActivity extends FlutterActivity { + private static final String CHANNEL = "walletcore/eth"; + + private static Long argument2long(Object argument) { + if (argument == null) { + throw new RuntimeException("argument is null"); + + } + if (argument instanceof Integer) { + return ((Integer) argument).longValue(); + } else if (argument instanceof Long) { + return (Long) argument; + } else { + throw new RuntimeException("argument is not integer or long," + argument.toString()); + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + GeneratedPluginRegistrant.registerWith(this); + + new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(new MethodCallHandler() { + @Override + public void onMethodCall(MethodCall call, Result result) { + System.out.println(CHANNEL + ":" + call.method + ",arguments:" + call.arguments); + + try { + + switch (call.method) { + case "genEthKey": { + String prvk = (String) call.arguments; + String key = geth.Geth.utilGenKey(prvk); + result.success(key); + break; + } + case "buildTime": { + String bt = mobile.Mobile.getBuildTime(); + result.success(bt); + break; + } + case "packedDeploySimpleMultiSig": { + Integer sigRequired = call.argument("sigRequired"); + Long chainId = argument2long(call.argument("chainId")); + List addrs = call.argument("addrs"); + geth.AddressesWrap wrapAddrs = new geth.AddressesWrap(); + for (String addr : addrs) { + wrapAddrs.addOne(new geth.ETHAddress(addr)); + } + + byte[] data = Geth.packedDeploySimpleMultiSig(new geth.BigInt(new Long(sigRequired)), wrapAddrs, new geth.BigInt(chainId)); + result.success(data); + break; + } + case "newETHTransactionForContractCreationAndSign": { + System.out.println("newETHTransactionForContractCreationAndSign invoked"); + + Integer nonce = call.argument("nonce"); + Long gasLimit = argument2long(call.argument("gasLimit")); + Long gasPrice = argument2long(call.argument("gasPrice")); + byte[] data = call.argument("data"); + String prvkey = call.argument("prvkey"); + + geth.ETHTransaction tx = new geth.ETHTransaction(nonce.longValue(), gasLimit, new geth.BigInt(gasPrice), data); + String encodedRlp = tx.encodeRLP(); + + geth.Signer signer = new geth.Signer(); + String signed = signer.sign(encodedRlp, prvkey); + result.success(signed); + break; + } + case "newTransactionAndSign": { + System.out.println("newTransactionAndSign invoked"); + + Integer nonce = call.argument("nonce"); + Long gasLimit = argument2long(call.argument("gasLimit")); + Long gasPrice = argument2long(call.argument("gasPrice")); + byte[] data = call.argument("data"); + String prvkey = call.argument("prvkey"); + Double amount = call.argument("amount"); + String toAddress = call.argument("toAddress"); + + geth.ETHTransaction tx = new geth.ETHTransaction(nonce.longValue(), new geth.ETHAddress(toAddress), new geth.BigInt(amount.longValue()), gasLimit, new geth.BigInt(gasPrice), data); + String encodedRlp = tx.encodeRLP(); + + geth.Signer signer = new geth.Signer(); + String signed = signer.sign(encodedRlp, prvkey); + result.success(signed); + break; + } + case "signMultisigExecute": { +// 'prvkey': prvk, +// 'multisigContractAddress': call.multisigContractAddress, +// 'toAddress': call.toAddress, +// 'internalNonce': call.internalNonce, +// 'amount': call.amount, +// 'gasLimit': call.gasLimit, +// 'data': call.data + + String prvkey = call.argument("prvkey"); + String multisigContractAddress = call.argument("multisigContractAddress"); + String toAddress = call.argument("toAddress"); + Long internalNonce = argument2long(call.argument("internalNonce")); + Double amount = call.argument("amount"); + Long gasLimit = argument2long(call.argument("gasLimit")); + String executorAddress = call.argument("executor"); + byte[] data = call.argument("data"); + Long chainId = argument2long(call.argument("chainId")); + + geth.SimpleMultiSigExecuteSignResult ret = geth.Geth.utilSimpleMultiSigExecuteSign(chainId, prvkey, multisigContractAddress, toAddress, executorAddress, internalNonce, new geth.BigInt(amount.longValue()), new geth.BigInt(gasLimit), data); + result.success(ret.toHex()); + break; + } + default: + result.success("unknown method"); + } + + } catch (Exception e) { + System.err.println(e); + e.printStackTrace(); +// e.printStackTrace(new PrintStream(System.out)); + } + } + }); + + } +} diff --git a/demo_cold/android/app/src/main/res/drawable/launch_background.xml b/demo_cold/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/demo_cold/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/demo_cold/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/demo_cold/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/demo_cold/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/demo_cold/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/demo_cold/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/demo_cold/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/demo_cold/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/demo_cold/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/demo_cold/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/demo_cold/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/demo_cold/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/demo_cold/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/demo_cold/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/demo_cold/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/demo_cold/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/demo_cold/android/app/src/main/res/values/styles.xml b/demo_cold/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..00fa441 --- /dev/null +++ b/demo_cold/android/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + diff --git a/demo_cold/android/app/src/profile/AndroidManifest.xml b/demo_cold/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..67d5372 --- /dev/null +++ b/demo_cold/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/demo_cold/android/build.gradle b/demo_cold/android/build.gradle new file mode 100644 index 0000000..bb8a303 --- /dev/null +++ b/demo_cold/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/demo_cold/android/gradle.properties b/demo_cold/android/gradle.properties new file mode 100644 index 0000000..2bd6f4f --- /dev/null +++ b/demo_cold/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx1536M + diff --git a/demo_cold/android/gradle/wrapper/gradle-wrapper.properties b/demo_cold/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2819f02 --- /dev/null +++ b/demo_cold/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/demo_cold/android/settings.gradle b/demo_cold/android/settings.gradle new file mode 100644 index 0000000..5a2f14f --- /dev/null +++ b/demo_cold/android/settings.gradle @@ -0,0 +1,15 @@ +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +} diff --git a/demo_cold/assets/qr_code.png b/demo_cold/assets/qr_code.png new file mode 100644 index 0000000..d4a8491 Binary files /dev/null and b/demo_cold/assets/qr_code.png differ diff --git a/demo_cold/assets/scan_qr.png b/demo_cold/assets/scan_qr.png new file mode 100644 index 0000000..e7ee839 Binary files /dev/null and b/demo_cold/assets/scan_qr.png differ diff --git a/demo_cold/ios/Flutter/AppFrameworkInfo.plist b/demo_cold/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..6b4c0f7 --- /dev/null +++ b/demo_cold/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 8.0 + + diff --git a/demo_cold/ios/Flutter/Debug.xcconfig b/demo_cold/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..e8efba1 --- /dev/null +++ b/demo_cold/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/demo_cold/ios/Flutter/Release.xcconfig b/demo_cold/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..399e934 --- /dev/null +++ b/demo_cold/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/demo_cold/ios/Podfile b/demo_cold/ios/Podfile new file mode 100644 index 0000000..64ba749 --- /dev/null +++ b/demo_cold/ios/Podfile @@ -0,0 +1,72 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def parse_KV_file(file, separator='=') + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return []; + end + pods_ary = [] + skip_line_start_symbols = ["#", "/"] + File.foreach(file_abs_path) { |line| + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } + plugin = line.split(pattern=separator) + if plugin.length == 2 + podname = plugin[0].strip() + path = plugin[1].strip() + podpath = File.expand_path("#{path}", file_abs_path) + pods_ary.push({:name => podname, :path => podpath}); + else + puts "Invalid plugin specification: #{line}" + end + } + return pods_ary +end + +target 'Runner' do + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock + # referring to absolute paths on developers' machines. + system('rm -rf .symlinks') + system('mkdir -p .symlinks/plugins') + + # Flutter Pods + generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') + if generated_xcode_build_settings.empty? + puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first." + end + generated_xcode_build_settings.map { |p| + if p[:name] == 'FLUTTER_FRAMEWORK_DIR' + symlink = File.join('.symlinks', 'flutter') + File.symlink(File.dirname(p[:path]), symlink) + pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) + end + } + + # Plugin Pods + plugin_pods = parse_KV_file('../.flutter-plugins') + plugin_pods.map { |p| + symlink = File.join('.symlinks', 'plugins', p[:name]) + File.symlink(p[:path], symlink) + pod p[:name], :path => File.join(symlink, 'ios') + } +end + +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['ENABLE_BITCODE'] = 'NO' + end + end +end diff --git a/demo_cold/ios/Podfile.lock b/demo_cold/ios/Podfile.lock new file mode 100644 index 0000000..3e70092 --- /dev/null +++ b/demo_cold/ios/Podfile.lock @@ -0,0 +1,28 @@ +PODS: + - Flutter (1.0.0) + - qrcode_reader (0.0.1): + - Flutter + - shared_preferences (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `.symlinks/flutter/ios`) + - qrcode_reader (from `.symlinks/plugins/qrcode_reader/ios`) + - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: ".symlinks/flutter/ios" + qrcode_reader: + :path: ".symlinks/plugins/qrcode_reader/ios" + shared_preferences: + :path: ".symlinks/plugins/shared_preferences/ios" + +SPEC CHECKSUMS: + Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a + qrcode_reader: 09b34d43b4c08fe5b63a6e56c96789bcea7b9148 + shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523 + +PODFILE CHECKSUM: 7fb83752f59ead6285236625b82473f90b1cb932 + +COCOAPODS: 1.7.5 diff --git a/demo_cold/ios/Runner.xcodeproj/project.pbxproj b/demo_cold/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..ff80ed3 --- /dev/null +++ b/demo_cold/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,577 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 8A255C655A538835E8F3CD5F /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C40664ECF694283188E8BBE /* libPods-Runner.a */; }; + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; + 48D51927445CCE3C4206D693 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 6C40664ECF694283188E8BBE /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 8F19F13B6B69F2ABADD53E04 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C94FF2C9A317895B6A6A122B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, + 8A255C655A538835E8F3CD5F /* libPods-Runner.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B80C3931E831B6300D905FE /* App.framework */, + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEBA1CF902C7004384FC /* Flutter.framework */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + C21AE643477CA6973F606388 /* Pods */, + CF96F68438CE58BE13494DC0 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + C21AE643477CA6973F606388 /* Pods */ = { + isa = PBXGroup; + children = ( + 8F19F13B6B69F2ABADD53E04 /* Pods-Runner.debug.xcconfig */, + 48D51927445CCE3C4206D693 /* Pods-Runner.release.xcconfig */, + C94FF2C9A317895B6A6A122B /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + CF96F68438CE58BE13494DC0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6C40664ECF694283188E8BBE /* libPods-Runner.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 6966C8552797EFF85A7DF569 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + F1282C2C335ECAF0B6097B9E /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = "The Chromium Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + }; + 6966C8552797EFF85A7DF569 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + F1282C2C335ECAF0B6097B9E /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = S8QB4VV633; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = io.dabank.sdkdemo.cold.demoCold; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = io.dabank.sdkdemo.cold.demoCold; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = io.dabank.sdkdemo.cold.demoCold; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/demo_cold/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/demo_cold/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/demo_cold/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/demo_cold/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/demo_cold/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..a28140c --- /dev/null +++ b/demo_cold/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo_cold/ios/Runner.xcworkspace/contents.xcworkspacedata b/demo_cold/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..21a3cc1 --- /dev/null +++ b/demo_cold/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/demo_cold/ios/Runner/AppDelegate.h b/demo_cold/ios/Runner/AppDelegate.h new file mode 100644 index 0000000..36e21bb --- /dev/null +++ b/demo_cold/ios/Runner/AppDelegate.h @@ -0,0 +1,6 @@ +#import +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/demo_cold/ios/Runner/AppDelegate.m b/demo_cold/ios/Runner/AppDelegate.m new file mode 100644 index 0000000..59a72e9 --- /dev/null +++ b/demo_cold/ios/Runner/AppDelegate.m @@ -0,0 +1,13 @@ +#include "AppDelegate.h" +#include "GeneratedPluginRegistrant.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + // Override point for customization after application launch. + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +@end diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..3d43d11 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..28c6bf0 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..f091b6b Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cde121 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..d0ef06e Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..dcdc230 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..c8f9ed8 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..75b2d16 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..c4df70d Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..6a84f41 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..d0e1f58 Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/demo_cold/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/demo_cold/ios/Runner/Base.lproj/LaunchScreen.storyboard b/demo_cold/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/demo_cold/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo_cold/ios/Runner/Base.lproj/Main.storyboard b/demo_cold/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/demo_cold/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo_cold/ios/Runner/Info.plist b/demo_cold/ios/Runner/Info.plist new file mode 100644 index 0000000..b0a0d80 --- /dev/null +++ b/demo_cold/ios/Runner/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + demo_cold + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/demo_cold/ios/Runner/main.m b/demo_cold/ios/Runner/main.m new file mode 100644 index 0000000..dff6597 --- /dev/null +++ b/demo_cold/ios/Runner/main.m @@ -0,0 +1,9 @@ +#import +#import +#import "AppDelegate.h" + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/demo_cold/lib/main.dart b/demo_cold/lib/main.dart new file mode 100644 index 0000000..ee8c12a --- /dev/null +++ b/demo_cold/lib/main.dart @@ -0,0 +1,132 @@ +import 'dart:async'; + +import 'package:demo_cold/ui/key_list.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:oktoast/oktoast.dart'; + +void main() { + // This captures errors reported by the Flutter framework. + FlutterError.onError = (FlutterErrorDetails details) async { + if (isInDebugMode) { + // In development mode simply print to console. + FlutterError.dumpErrorToConsole(details); + } else { + // In production mode report to the application zone to report to + // Sentry. + Zone.current.handleUncaughtError(details.exception, details.stack); + } + }; + + // This creates a [Zone] that contains the Flutter application and stablishes + // an error handler that captures errors and reports them. + // + // Using a zone makes sure that as many errors as possible are captured, + // including those thrown from [Timer]s, microtasks, I/O, and those forwarded + // from the `FlutterError` handler. + // + // More about zones: + // + // - https://api.dartlang.org/stable/1.24.2/dart-async/Zone-class.html + // - https://www.dartlang.org/articles/libraries/zones + runZoned>(() async { + runApp(new MyApp()); + }, onError: (error, stackTrace) async { + await _reportError(error, stackTrace); + }); +} + +class MyApp extends StatelessWidget { + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + // This is the theme of your application. + // + // Try running your application with "flutter run". You'll see the + // application has a blue toolbar. Then, without quitting the app, try + // changing the primarySwatch below to Colors.green and then invoke + // "hot reload" (press "r" in the console where you ran "flutter run", + // or simply save your changes to "hot reload" in a Flutter IDE). + // Notice that the counter didn't reset back to zero; the application + // is not restarted. + primarySwatch: Colors.blue, + ), + home: MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + MyHomePage({Key key, this.title}) : super(key: key); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + + final String title; + + @override + _MyHomePageState createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + @override + Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. + return OKToast( + child: MaterialApp( + debugShowCheckedModeBanner: false, + localizationsDelegates: [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: [ + const Locale('zh', 'CN'), // Hebrew + ], + title: '冷钱包', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: KeyListPage(), + ), + ); + } +} + +/// Reports [error] along with its [stackTrace] to Sentry.io. +Future _reportError(dynamic error, dynamic stackTrace) async { + print('Caught error: $error'); + + var atLine = stackTrace.toString().split('\n')[0]; + showToast( + error.toString() + '\n$atLine', + duration: Duration(seconds: 6), + textStyle: TextStyle(color: Colors.redAccent), + ); + print(error.toString()); +} + +bool get isInDebugMode { + // Assume we're in production mode + bool _inDebugMode = false; + + // Assert expressions are only evaluated during development. They are ignored + // in production. Therefore, this code will only turn `inDebugMode` to true + // in our development environments! + assert(_inDebugMode = true); + + return _inDebugMode; +} diff --git a/demo_cold/lib/models/addr.dart b/demo_cold/lib/models/addr.dart new file mode 100644 index 0000000..e79661f --- /dev/null +++ b/demo_cold/lib/models/addr.dart @@ -0,0 +1,17 @@ +class Addr { + String privateKey; //私钥 + String publicKey; //公钥 + String address; //地址 + + static Addr decode(String prvPubAddr) { + var l = prvPubAddr.split(','); + return Addr() + ..privateKey = l[0] + ..publicKey = l[1] + ..address = l[2]; + } + + String encode() { + return '$privateKey,$publicKey,$address'; + } +} diff --git a/demo_cold/lib/sdk/sdk_wrapper.dart b/demo_cold/lib/sdk/sdk_wrapper.dart new file mode 100644 index 0000000..b6356b1 --- /dev/null +++ b/demo_cold/lib/sdk/sdk_wrapper.dart @@ -0,0 +1,85 @@ +import 'dart:typed_data'; + +import 'package:demo_cold/shared/const.dart'; +import 'package:demo_cold/shared/req_sign_content.dart'; +import 'package:flutter/services.dart'; + +class SdkWrapper { + static const platform = const MethodChannel('walletcore/eth'); + + /// private,public,addr + static Future> genKey(String prvk) async { + String ret = await platform.invokeMethod('genEthKey', prvk ?? ""); + return ret.split(','); + } + + static Future packedDeploySimpleMultiSig(int sigRequired, List addrs, int chainId) async { + Uint8List ret = await platform.invokeMethod('packedDeploySimpleMultiSig', { + 'sigRequired': sigRequired, + 'addrs': addrs, + 'chainId': chainId, + }); + return ret; + } + + /// 构造一个多签合约创建交易,并使用私钥对其签名 + static Future newETHTransactionForContractCreationAndSign( + int nonce, + int gasLimit, + int gasPrice, + Uint8List data, + String prvkey, + ) async { + String ret = await platform.invokeMethod('newETHTransactionForContractCreationAndSign', { + 'nonce': nonce, + 'gasLimit': gasLimit, + 'gasPrice': gasPrice, + 'data': data, + 'prvkey': prvkey, + // "toAddress": toAddress, + }); + return ret; + } + + static Future newTransactionAndSign( + int nonce, + int gasLimit, + int gasPrice, + String toAddress, + String prvkey, + double amount, + Uint8List data, + ) async { + String ret = await platform.invokeMethod('newTransactionAndSign', { + 'nonce': nonce, + 'gasLimit': gasLimit, + 'gasPrice': gasPrice, + 'toAddress': toAddress, + 'prvkey': prvkey, + 'amount': amount, + 'data': data, + }); + return ret; + } + + static Future signMultisigExecute(ReqSignContentMultisigExecute call, String prvk, int chainId) async { + double amountInWei = call.amount * ETH18; + String ret = await platform.invokeMethod('signMultisigExecute', { + 'prvkey': prvk, + 'multisigContractAddress': call.multisigContractAddress, + 'toAddress': call.toAddress, + 'internalNonce': call.internalNonce, + 'amount': amountInWei, + 'gasLimit': call.gasLimit, + 'executor': call.exectorAddress, + 'data': call.data, + 'chainId': chainId, + }); + return ret; + } + + static Future sign(String data, String prvk) async { + String ret = await platform.invokeMethod('sign', {}); + return ret; + } +} diff --git a/demo_cold/lib/shared/assets.dart b/demo_cold/lib/shared/assets.dart new file mode 100644 index 0000000..06e3137 --- /dev/null +++ b/demo_cold/lib/shared/assets.dart @@ -0,0 +1,2 @@ +const ASSETS_QR_CODE = 'assets/qr_code.png'; +const ASSETS_SCAN_QR = 'assets/scan_qr.png'; diff --git a/demo_cold/lib/shared/const.dart b/demo_cold/lib/shared/const.dart new file mode 100644 index 0000000..b2efda2 --- /dev/null +++ b/demo_cold/lib/shared/const.dart @@ -0,0 +1,31 @@ +const CHAIN_ID = 3; +const ETH18 = 1000000000000000000; +const APP_URL_SCHEMA = 'demoapp://'; + +const PATH_REQ_SIGN_CONTENT = 'reqsign/'; +const PATH_REQ_SIGN_CONTENT_CREATEMULTISIGCONTRACT = 'createmultisig/'; +const PATH_REQ_SIGN_CONTENT_ETHTRANSFER = 'ethtransfer/'; +const PATH_REQ_SIGN_CONTENT_MULTISIGEXECUTE = 'multisigexecute/'; + +const PATH_SIGNED_DATA = ''; + +const PATH_PRIVATEKEY = 'prvkey/'; +const PATH_ADDR = 'addr/'; +const PATH_PUBKEY = 'pubkey/'; +const PATH_RAWTX = 'rawtx/'; +const PATH_PART = 'part/'; //eg, part:1/3:rawtx:... +const PATH_SIGNED = 'signed/'; + +String trimLeftUrlSchema(String url) { + if (url == null) { + return url; + } + if (!url.startsWith(APP_URL_SCHEMA)) { + return url; + } + return url.substring(APP_URL_SCHEMA.length); +} + +String urlWithAppSchema(String path) { + return APP_URL_SCHEMA + path; +} diff --git a/demo_cold/lib/shared/req_sign_content.dart b/demo_cold/lib/shared/req_sign_content.dart new file mode 100644 index 0000000..e1df3e2 --- /dev/null +++ b/demo_cold/lib/shared/req_sign_content.dart @@ -0,0 +1,195 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'const.dart'; + +ReqSignContent parseReqSignContent(String encodedContentWithPrefix) { + encodedContentWithPrefix = trimLeftUrlSchema(encodedContentWithPrefix); + if (!encodedContentWithPrefix.startsWith(PATH_REQ_SIGN_CONTENT)) { + throw 'not start with $PATH_REQ_SIGN_CONTENT'; + } + + String content = encodedContentWithPrefix.substring(PATH_REQ_SIGN_CONTENT.length); + + if (content.startsWith(PATH_REQ_SIGN_CONTENT_CREATEMULTISIGCONTRACT)) { + var req = ReqSignContentCreateMultisigContract(); + req.decode(content); + return req; + } else if (content.startsWith(PATH_REQ_SIGN_CONTENT_ETHTRANSFER)) { + var req = ReqSignContentETHTransfer(); + req.decode(content); + return req; + } else if (content.startsWith(PATH_REQ_SIGN_CONTENT_MULTISIGEXECUTE)) { + var req = ReqSignContentMultisigExecute(); + req.decode(content); + return req; + } else { + throw 'unknown req sign content'; + } +} + +abstract class ReqSignContent { + String title(); + String encode(); //用于展示二维码 + void decode(String content); //扫码 + String info(); //详细描述 +} + +/// 创建多签合约 +class ReqSignContentCreateMultisigContract implements ReqSignContent { + int nonce; + int sigRequired; + int gasPrice; + int gasLimit; + List addrs; + + @override + void decode(String content) { + var items = content.substring(PATH_REQ_SIGN_CONTENT_CREATEMULTISIGCONTRACT.length).split(","); + nonce = int.parse(items[0]); + sigRequired = int.parse(items[1]); + gasPrice = int.parse(items[2]); + gasLimit = int.parse(items[3]); + addrs = items.sublist(4); + } + + @override + String encode() { + List list = [ + nonce.toString(), + sigRequired.toString(), + gasPrice.toString(), + gasLimit.toString(), + ...addrs, + ]; + return PATH_REQ_SIGN_CONTENT_CREATEMULTISIGCONTRACT + list.join(","); + } + + @override + String info() { + return ''' +nonce: $nonce +签名人数 - 总人数:$sigRequired - 2 +gasPrice: $gasPrice +gasLimit: $gasLimit +地址1: ${addrs[0]} +地址2: ${addrs[1]} + '''; + } + + @override + String title() { + return '创建 $sigRequired - 2 多签合约'; + } +} + +/// 转账或合约调用 +class ReqSignContentETHTransfer implements ReqSignContent { + int nonce; + String toAddress; + double amount; + int gasLimit; + int gasPrice; + Uint8List data; + + @override + void decode(String content) { + var items = content.substring(PATH_REQ_SIGN_CONTENT_ETHTRANSFER.length).split(','); + nonce = int.parse(items[0]); + toAddress = items[1]; + amount = double.parse(items[2]); + gasLimit = int.parse(items[3]); + gasPrice = int.parse(items[4]); + if (items.length >= 6) { + data = base64Decode(items[5]); + } + } + + @override + String encode() { + List items = [ + nonce.toString(), + toAddress, + amount.toString(), + gasLimit.toString(), + gasPrice.toString(), + if (data != null) base64Encode(data) + ]; + return PATH_REQ_SIGN_CONTENT_ETHTRANSFER + items.join(','); + } + + @override + String info() { + return ''' +nonce: $nonce, +地址: $toAddress, +金额: $amount, +gasLimit: $gasLimit, +gasPrice: $gasPrice, +data.length: ${data?.length ?? 0} + '''; + } + + @override + String title() { + return 'ETH 转账 或 合约调用'; + } +} + +/// 多签转账签名(不是后续的交易签名 +class ReqSignContentMultisigExecute implements ReqSignContent { + String multisigContractAddress; + String toAddress; + int internalNonce; + double amount; //value + int gasLimit; + String exectorAddress; //最终发起交易的人,这里由创建人发起 + // int gasPrice; + Uint8List data; + + @override + void decode(String content) { + var items = content.substring(PATH_REQ_SIGN_CONTENT_MULTISIGEXECUTE.length).split(','); + multisigContractAddress = items[0]; + toAddress = items[1]; + internalNonce = int.parse(items[2]); + amount = double.parse(items[3]); + gasLimit = int.parse(items[4]); + exectorAddress = items[5]; + if (items.length >= 7) { + data = base64Decode(items[6]); + } + } + + @override + String encode() { + List items = [ + multisigContractAddress, + toAddress, + internalNonce.toString(), + amount.toString(), + gasLimit.toString(), + exectorAddress, + if (data != null) base64Encode(data) + ]; + return PATH_REQ_SIGN_CONTENT_MULTISIGEXECUTE + items.join(','); + } + + @override + String info() { + return ''' +多签合约地址: $multisigContractAddress +目标地址: $toAddress +内部nonce: $internalNonce +amount: $amount +gasLimit: $gasLimit +执行/地址: $exectorAddress +data.length: ${data?.length ?? 0} + '''; + } + + @override + String title() { + return '多签转账原始数据签名'; + } +} diff --git a/demo_cold/lib/shared/utl.dart b/demo_cold/lib/shared/utl.dart new file mode 100644 index 0000000..992bd45 --- /dev/null +++ b/demo_cold/lib/shared/utl.dart @@ -0,0 +1,6 @@ +String utlTrimLeft(String content, String trim) { + if (content == null) { + return null; + } + return content.startsWith(trim) ? content.substring(trim.length) : content; +} diff --git a/demo_cold/lib/shared/widgets/action_import_data.dart b/demo_cold/lib/shared/widgets/action_import_data.dart new file mode 100644 index 0000000..a7306c4 --- /dev/null +++ b/demo_cold/lib/shared/widgets/action_import_data.dart @@ -0,0 +1,109 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:oktoast/oktoast.dart'; +import 'package:qrcode_reader/qrcode_reader.dart'; + +import '../const.dart'; + +const int FromClipboard = 1; +const int FromCamera = 2; +const int CancelAction = 0; + +/// 读取导入数据从二维码或者剪切板 +Future readImportData(BuildContext ctx, {int source}) async { + int fromSource; + + if (source != null) { + fromSource = source; + } else { + fromSource = await showModalBottomSheet( + context: ctx, + builder: (c) => ButtonBar( + alignment: MainAxisAlignment.center, + children: [ + FlatButton( + child: Text('读取剪贴板'), + onPressed: () => Navigator.of(c).pop(FromClipboard), + ), + FlatButton( + child: Text('扫码'), + onPressed: () => Navigator.of(c).pop(FromCamera), + ), + FlatButton( + child: Text('取消'), + onPressed: () => Navigator.of(c).pop(CancelAction), + ) + ], + ), + ); + } + + if (fromSource == null || fromSource == CancelAction) { + return null; + } + + String readAddr; + if (fromSource == FromClipboard) { + readAddr = (await Clipboard.getData("text/plain")).text; + return readAddr; + } + + if (fromSource == FromCamera) { + String ret = await scanQRCode(); + + if (ret == null || !ret.startsWith(PATH_PART)) { + return ret; + } + + // 如果包含多页,则以第一页的总共页数为依据,一直读取,直到全部扫码完成 + int totalPage = -1; + List pages = []; + // part/1-3/${data} + while (pages.length == 0 || pages.contains(null)) { + var partPageData = ret.split('/'); + String data = partPageData.sublist(2).join('/'); + var indexTotalString = partPageData[1].split('-'); + + if (totalPage == -1) { + totalPage = int.parse(indexTotalString[1]); + pages = List.generate(totalPage, (_) => null); + } + + int currentIndex = int.parse(indexTotalString[0]); + print('currentindex $currentIndex, pages length:${pages.length}'); + if (pages[currentIndex] == null) { + pages[currentIndex] = data; + print('readed:$ret'); + } + + List scanedPages = []; + List notScanedPages = []; + for (int i = 0; i < totalPage; i++) { + if (pages[i] != null) { + scanedPages.add(i + 1); + } else { + notScanedPages.add(i + 1); + } + } + showToast('已获取第$scanedPages 页\n剩余第 $notScanedPages 页'); + if (notScanedPages.length == 0) { + break; + } + await Future.delayed(const Duration(seconds: 2), () => null); //睡眠1s + ret = await scanQRCode(); + } + return pages.join(''); + } + return null; +} + +Future scanQRCode() { + return QRCodeReader() + .setAutoFocusIntervalInMs(500) // default 5000 + .setForceAutoFocus(true) // default false + .setTorchEnabled(true) // default false + .setHandlePermissions(true) // default true + .setExecuteAfterPermissionGranted(true) // default true + .scan(); +} diff --git a/demo_cold/lib/shared/widgets/copy_btn.dart b/demo_cold/lib/shared/widgets/copy_btn.dart new file mode 100644 index 0000000..7560e98 --- /dev/null +++ b/demo_cold/lib/shared/widgets/copy_btn.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import 'snack_info_copied.dart'; + +class CopyBtn extends StatelessWidget { + final String content; + + const CopyBtn({Key key, this.content}) : super(key: key); + + @override + Widget build(BuildContext context) { + return IconButton( + tooltip: '复制', + icon: Icon(Icons.content_copy), + onPressed: () { + Clipboard.setData(ClipboardData(text: content)); + Scaffold.of(context).showSnackBar(SnackBar(content: SnackInfoCopied(content))); + print('copied:\n$content\n'); + }, + ); + } +} diff --git a/demo_cold/lib/shared/widgets/copy_qrcode_btn.dart b/demo_cold/lib/shared/widgets/copy_qrcode_btn.dart new file mode 100644 index 0000000..9882c80 --- /dev/null +++ b/demo_cold/lib/shared/widgets/copy_qrcode_btn.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:qr_flutter/qr_flutter.dart'; + +import '../assets.dart'; + +class CopyOrShowQRCode extends StatelessWidget { + final String text; + + const CopyOrShowQRCode({Key key, this.text}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + width: 100, + child: Row( + children: [ + IconButton( + tooltip: '复制', + icon: Icon(Icons.content_copy), + onPressed: () { + Clipboard.setData(ClipboardData(text: text)); + Scaffold.of(context).showSnackBar(SnackBar( + content: Row( + children: [ + Text('copied:', style: TextStyle(color: Colors.lightBlue)), + Expanded(child: Text(text)), + ], + ), + )); + }, + ), + IconButton( + icon: ImageIcon(AssetImage(ASSETS_QR_CODE)), + tooltip: '显示二维码', + onPressed: () => actionShowQRCode(text, context), + ), + ], + ), + ); + } + + void actionShowQRCode(String content, BuildContext ctx) { + showDialog( + context: ctx, + builder: (ctx) => Scaffold( + body: SingleChildScrollView( + child: Center( + child: Column( + children: [ + SizedBox(height: 24), + Text(content), + QrImage(data: content, size: 360.0), + SizedBox(height: 36), + IconButton( + icon: Icon(Icons.close), + onPressed: () => Navigator.pop(ctx), + ) + ], + ), + ), + ), + ), + ); + } +} diff --git a/demo_cold/lib/shared/widgets/paged_qr_image.dart b/demo_cold/lib/shared/widgets/paged_qr_image.dart new file mode 100644 index 0000000..ad905ba --- /dev/null +++ b/demo_cold/lib/shared/widgets/paged_qr_image.dart @@ -0,0 +1,99 @@ +import 'package:flutter/material.dart'; +import 'package:qr_flutter/qr_flutter.dart'; + +import '../const.dart'; + +class PagedQrImage extends StatefulWidget { + final String data; + + const PagedQrImage({Key key, this.data}) : super(key: key); + + @override + _PagedQrImageState createState() => _PagedQrImageState(); +} + +class _PagedQrImageState extends State { + int currentIndex = 0; + int p; + List parts = []; + + @override + void initState() { + super.initState(); + if (widget.data.length < 850) { + return; + } + const perPart = 845; + p = (widget.data.length / perPart).ceil(); + parts = []; + for (int i = 0; i < p; i++) { + int end = (i + 1) * perPart; + if (end > widget.data.length) { + end = widget.data.length; + } + // part/1-2/... + parts.add('$PATH_PART$i-$p/' + widget.data.substring(i * perPart, end)); + } + } + + void actionChangeIndex(int idx) { + setState(() { + currentIndex = idx; + }); + } + + @override + Widget build(BuildContext context) { + if (widget.data.length < 100) { + return QrImage(version: 5, data: widget.data); + } + + if (widget.data.length < 200) { + return QrImage(version: 9, data: widget.data); + } + + if (widget.data.length < 500) { + return QrImage(version: 9, data: widget.data); + } + + if (widget.data.length < 850) { + return QrImage(version: 20, data: widget.data); + } + + // 858 + + return Container( + // color: Colors.grey, + child: ConstrainedBox( + constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.width + 72), + child: Column( + children: [ + QrImage(version: 20, data: parts[currentIndex]), + Text('part: ${currentIndex + 1} - $p (len:${parts[currentIndex].length})', style: TextStyle(fontSize: 20)), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RaisedButton( + child: Text('上一页'), + onPressed: currentIndex == 0 + ? null + : () { + actionChangeIndex(currentIndex - 1); + }), + Text('当前第 ${currentIndex + 1} - ${parts.length} 页'), + RaisedButton( + child: Text('下一页'), + onPressed: (currentIndex == parts.length - 1) + ? null + : () { + actionChangeIndex(currentIndex + 1); + }, + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/demo_cold/lib/shared/widgets/paste_btn.dart b/demo_cold/lib/shared/widgets/paste_btn.dart new file mode 100644 index 0000000..0c7dffa --- /dev/null +++ b/demo_cold/lib/shared/widgets/paste_btn.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class PasteBtn extends StatelessWidget { + final Function(String) callback; + + const PasteBtn({Key key, @required this.callback}) : super(key: key); + @override + Widget build(BuildContext context) { + return IconButton( + icon: Icon(Icons.content_copy), + onPressed: () async { + String ret = (await Clipboard.getData('text/plain')).text; + callback(ret); + }, + ); + } +} diff --git a/demo_cold/lib/shared/widgets/paste_or_scan.dart b/demo_cold/lib/shared/widgets/paste_or_scan.dart new file mode 100644 index 0000000..cf73a34 --- /dev/null +++ b/demo_cold/lib/shared/widgets/paste_or_scan.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import '../assets.dart'; +import 'action_import_data.dart'; + +class PasteOrScan extends StatelessWidget { + final Function(String) callback; + + const PasteOrScan({Key key, this.callback}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + width: 120, + child: Row( + children: [ + IconButton( + icon: Icon(Icons.content_copy), + onPressed: () async { + String ret = (await Clipboard.getData('text/plain')).text; + callback(ret); + }, + ), + IconButton( + icon: ImageIcon(AssetImage(ASSETS_SCAN_QR)), + onPressed: () async { + String ret = await scanQRCode(); + callback(ret); + }, + ) + ], + ), + ); + } +} diff --git a/demo_cold/lib/shared/widgets/snack_info_copied.dart b/demo_cold/lib/shared/widgets/snack_info_copied.dart new file mode 100644 index 0000000..9478cea --- /dev/null +++ b/demo_cold/lib/shared/widgets/snack_info_copied.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class SnackInfoCopied extends StatelessWidget { + final String text; + + SnackInfoCopied(this.text); + @override + Widget build(BuildContext context) { + String txt = text; + if (txt.length > 200) { + txt = text.substring(0, 200) + "..."; + } + return Row( + children: [ + Text('copied:', style: TextStyle(color: Colors.lightBlue)), + Expanded(child: Text(txt)), + ], + ); + } +} diff --git a/demo_cold/lib/shared/widgets/split_line_text.dart b/demo_cold/lib/shared/widgets/split_line_text.dart new file mode 100644 index 0000000..1c82034 --- /dev/null +++ b/demo_cold/lib/shared/widgets/split_line_text.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +/// 多行文本 +class SplitLineText extends StatelessWidget { + final String text; + + SplitLineText(this.text); + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: text.split('\n').map((txt) => Text(txt)).toList(growable: false), + ); + } +} diff --git a/demo_cold/lib/ui/key_detail.dart b/demo_cold/lib/ui/key_detail.dart new file mode 100644 index 0000000..a5579b5 --- /dev/null +++ b/demo_cold/lib/ui/key_detail.dart @@ -0,0 +1,126 @@ +import 'package:demo_cold/models/addr.dart'; +import 'package:demo_cold/shared/const.dart'; +import 'package:demo_cold/shared/req_sign_content.dart'; +import 'package:demo_cold/shared/widgets/action_import_data.dart'; +import 'package:demo_cold/shared/widgets/copy_qrcode_btn.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'package:qr_flutter/qr_flutter.dart'; + +import 'key_list.dart'; +import 'sign.dart'; + +class KeyDetailPage extends StatefulWidget { + static final String routeName = "/key"; + + final Addr addr; + + const KeyDetailPage({Key key, @required this.addr}) : super(key: key); + + @override + _KeyDetailPageState createState() => _KeyDetailPageState(); +} + +class _KeyDetailPageState extends State { + final GlobalKey _scaffoldKey = GlobalKey(); + + void actionShowQRCode(String content) { + showDialog( + context: _scaffoldKey.currentContext, + builder: (ctx) => Scaffold( + body: ListView( + children: [ + Text(content), + QrImage(data: content, size: 250.0), + IconButton(icon: Icon(Icons.close), onPressed: () => Navigator.pop(ctx)) + ], + ), + ), + ); + } + + void actionDelKey(BuildContext context) { + var dialogBuilder = (BuildContext ctx) => AlertDialog( + title: Text('确定删除?'), + content: Text('私钥一旦删除将不可找回,同时也会删除地址,公钥'), + actions: [ + FlatButton( + child: Text('删除'), + onPressed: () async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + List l = prefs.getStringList(storeKey); + l.removeWhere((encoded) => encoded.contains(widget.addr.privateKey)); + prefs.setStringList(storeKey, l); + Navigator.pop(ctx); + Navigator.pop(_scaffoldKey.currentContext); + }), + FlatButton(child: Text('取消'), onPressed: () => Navigator.pop(ctx)), + ], + ); + showDialog(context: context, builder: dialogBuilder); + } + + void parseReqSignDataThenShowSign(String reqSignData) { + try { + ReqSignContent content = parseReqSignContent(reqSignData); + Navigator.of(_scaffoldKey.currentContext).push(MaterialPageRoute( + builder: (_) => SignPage( + content: content, + privateKey: widget.addr.privateKey, + addr: widget.addr.address, + ))); + } catch (err) { + _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('无法解析待签名数据,$reqSignData, $err'))); + throw err; + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + appBar: AppBar(title: Text("地址详情")), + body: ListView( + children: [ + Center(child: Text('⚠️生成的私钥/地址仅用于测试演示', style: TextStyle(fontSize: 20, color: Colors.redAccent))), + Row(children: [ + Expanded(child: Text('地址:${widget.addr.address}')), + CopyOrShowQRCode(text: PATH_ADDR + widget.addr.address), + ]), + Row(children: [ + Expanded(child: Text('公钥:${widget.addr.publicKey}')), + CopyOrShowQRCode(text: PATH_PUBKEY + widget.addr.publicKey), + ]), + Row(children: [ + Expanded(child: Text('私钥:${widget.addr.privateKey}')), + CopyOrShowQRCode(text: PATH_PRIVATEKEY + widget.addr.privateKey), + ]), + SizedBox(height: 36), + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + RaisedButton( + child: Text('扫码签名'), + onPressed: () async { + String futureString = await readImportData(context, source: FromCamera); + parseReqSignDataThenShowSign(futureString); + }), + RaisedButton( + child: Text('从剪切板读取待签名数据'), + onPressed: () async { + var data = (await Clipboard.getData(null)).text; + parseReqSignDataThenShowSign(data); + }), + ]), + SizedBox(height: 36), + Center( + child: RaisedButton( + child: Text('删除私钥', style: TextStyle(color: Colors.redAccent)), + onPressed: () => actionDelKey(context), + ), + ), + ], + ), + ); + } +} diff --git a/demo_cold/lib/ui/key_list.dart b/demo_cold/lib/ui/key_list.dart new file mode 100644 index 0000000..8806da4 --- /dev/null +++ b/demo_cold/lib/ui/key_list.dart @@ -0,0 +1,107 @@ +import 'dart:async'; + +import 'package:demo_cold/models/addr.dart'; +import 'package:demo_cold/sdk/sdk_wrapper.dart'; +import 'package:demo_cold/shared/const.dart'; +import 'package:demo_cold/shared/utl.dart'; +import 'package:demo_cold/shared/widgets/action_import_data.dart'; +import 'package:demo_cold/ui/key_detail.dart'; +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +const String storeKey = "encoded_keys"; + +class KeyListPage extends StatefulWidget { + static final String routeName = "/addrlist"; + + @override + _KeyListPageState createState() => _KeyListPageState(); +} + +class _KeyListPageState extends State { + final GlobalKey _scaffoldKey = GlobalKey(); + List keys = []; + + @override + void initState() { + super.initState(); + scheduleMicrotask(loadKey); + } + + void loadKey() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + List l = prefs.getStringList(storeKey) ?? []; + if (l.length == keys.length) { + return; + } + setState(() { + keys = l.map((encoded) => Addr.decode(encoded)).toList(growable: false); + }); + } + + Future addKey(Addr addr) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + List l = prefs.getStringList(storeKey) ?? []; + l.add(addr.encode()); + prefs.setStringList(storeKey, l); + loadKey(); + } + + void actionImportPrivateKey() async { + var data = await readImportData(_scaffoldKey.currentContext); + if (data == null) { + return; + } + data = trimLeftUrlSchema(data); + data = utlTrimLeft(data, PATH_PRIVATEKEY); + var ret = await SdkWrapper.genKey(data); + Addr addr = Addr() + ..privateKey = ret[0] + ..publicKey = ret[1] + ..address = ret[2]; + await addKey(addr); + } + + void actionGenerateKeyAndSave() async { + var ret = await SdkWrapper.genKey(null); + Addr addr = Addr() + ..privateKey = ret[0] + ..publicKey = ret[1] + ..address = ret[2]; + await addKey(addr); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + appBar: AppBar(title: Text('地址列表')), + body: Scrollbar( + child: ListView( + children: [ + Center(child: Text('⚠️生成的私钥/地址仅用于测试演示', style: TextStyle(fontSize: 20, color: Colors.redAccent))), + SizedBox(height: 16), + for (Addr ad in keys) + ListTile( + title: Text(ad.address), + trailing: Icon(Icons.arrow_forward), + onTap: () async { + await Navigator.of(context).push(MaterialPageRoute(builder: (_) => KeyDetailPage(addr: ad))); + loadKey(); + }, + ), + SizedBox(height: 24), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + RaisedButton(child: Text("生成私钥"), onPressed: actionGenerateKeyAndSave), + RaisedButton(child: Text("导入私钥"), onPressed: actionImportPrivateKey) + ], + ), + SizedBox(height: 24), + ], + ), + ), + ); + } +} diff --git a/demo_cold/lib/ui/sign.dart b/demo_cold/lib/ui/sign.dart new file mode 100644 index 0000000..dffec14 --- /dev/null +++ b/demo_cold/lib/ui/sign.dart @@ -0,0 +1,64 @@ +import 'dart:typed_data'; + +import 'package:demo_cold/sdk/sdk_wrapper.dart'; +import 'package:demo_cold/shared/const.dart'; +import 'package:demo_cold/shared/req_sign_content.dart'; +import 'package:demo_cold/shared/widgets/split_line_text.dart'; +import 'package:flutter/material.dart'; + +import 'sign_result.dart'; + +class SignPage extends StatefulWidget { + final ReqSignContent content; + final String privateKey; + final String addr; + + const SignPage({Key key, this.content, this.privateKey, this.addr}) : super(key: key); + + @override + _SignPageState createState() => _SignPageState(); +} + +class _SignPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('签名')), + body: ListView( + children: [ + Center(child: Text(widget.content.title(), style: TextStyle(fontSize: 22))), + SplitLineText(widget.content.info()), + SizedBox(height: 48), + Center( + child: RaisedButton( + child: Text('使用私钥签名'), + onPressed: () async { + String signedData = await signContentUsingPrivateKey(widget.content, widget.privateKey, widget.addr); + Navigator.push(context, MaterialPageRoute(builder: (_) => SignResult(signedData: signedData))); + }, + ), + ) + ], + ), + ); + } +} + +Future signContentUsingPrivateKey(ReqSignContent content, String privateKey, String addr) async { + if (content is ReqSignContentCreateMultisigContract) { + var addrs = content.addrs; + addrs.sort(); + Uint8List data = await SdkWrapper.packedDeploySimpleMultiSig(content.sigRequired, addrs, CHAIN_ID); + return SdkWrapper.newETHTransactionForContractCreationAndSign( + content.nonce, content.gasLimit, content.gasPrice, data, privateKey); + } else if (content is ReqSignContentETHTransfer) { + double amountInWei = content.amount * ETH18; + return SdkWrapper.newTransactionAndSign( + content.nonce, content.gasLimit, content.gasPrice, content.toAddress, privateKey, amountInWei, content.data); + } else if (content is ReqSignContentMultisigExecute) { + String res = await SdkWrapper.signMultisigExecute(content, privateKey, CHAIN_ID); + return addr + ',' + res; + } else { + throw '尚未实现'; + } +} diff --git a/demo_cold/lib/ui/sign_result.dart b/demo_cold/lib/ui/sign_result.dart new file mode 100644 index 0000000..61ee976 --- /dev/null +++ b/demo_cold/lib/ui/sign_result.dart @@ -0,0 +1,42 @@ +import 'package:demo_cold/shared/const.dart'; +import 'package:demo_cold/shared/widgets/paged_qr_image.dart'; +import 'package:demo_cold/shared/widgets/snack_info_copied.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class SignResult extends StatefulWidget { + final String signedData; + + SignResult({Key key, this.signedData}) : super(key: key); + + @override + _SignResultState createState() => _SignResultState(); +} + +class _SignResultState extends State { + GlobalKey _scaffoldKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + appBar: AppBar(title: Text('签名结果')), + body: ListView( + children: [ + Text('签名结果(length:${widget.signedData.length})'), + Text('Hexed:${widget.signedData}', softWrap: false), + PagedQrImage(data: PATH_SIGNED + widget.signedData), + SizedBox(height: 16), + RaisedButton( + child: Text('复制签名结果'), + onPressed: () { + String copy = PATH_SIGNED + widget.signedData; + Clipboard.setData(ClipboardData(text: copy)); + _scaffoldKey.currentState.showSnackBar(SnackBar(content: SnackInfoCopied(copy))); + }, + ), + ], + ), + ); + } +} diff --git a/demo_cold/pubspec.lock b/demo_cold/pubspec.lock new file mode 100644 index 0000000..f9807fe --- /dev/null +++ b/demo_cold/pubspec.lock @@ -0,0 +1,194 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.14.11" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.8" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.5" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.6" + oktoast: + dependency: "direct main" + description: + name: oktoast + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.2" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + qr: + dependency: transitive + description: + name: qr + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + qr_flutter: + dependency: "direct main" + description: + name: qr_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0+55" + qrcode_reader: + dependency: "direct main" + description: + name: qrcode_reader + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.4" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.3+4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.5" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.3" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.5" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.6" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" +sdks: + dart: ">=2.3.0 <3.0.0" + flutter: ">=1.5.0 <2.0.0" diff --git a/demo_cold/pubspec.yaml b/demo_cold/pubspec.yaml new file mode 100644 index 0000000..9f9ea48 --- /dev/null +++ b/demo_cold/pubspec.yaml @@ -0,0 +1,79 @@ +name: demo_cold +description: SDK demo app cold wallet. + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.3.0 <3.0.0" + +dependencies: + flutter: + sdk: flutter + flutter_localizations: + sdk: flutter + shared_preferences: ^0.5.3+4 + qr_flutter: ^2.1.0+55 + qrcode_reader: ^0.4.4 + oktoast: ^2.2.0 + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^0.1.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + assets: + - assets/qr_code.png + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/demo_cold/test/widget_test.dart b/demo_cold/test/widget_test.dart new file mode 100644 index 0000000..9aeefc5 --- /dev/null +++ b/demo_cold/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:demo_cold/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/demo_watch/.gitignore b/demo_watch/.gitignore new file mode 100644 index 0000000..8a3c699 --- /dev/null +++ b/demo_watch/.gitignore @@ -0,0 +1,75 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# 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 +**/doc/api/ +.dart_tool/ +.flutter-plugins +.packages +.pub-cache/ +.pub/ +/build/ + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# 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 + +# local files +local_* \ No newline at end of file diff --git a/demo_watch/.metadata b/demo_watch/.metadata new file mode 100644 index 0000000..e023651 --- /dev/null +++ b/demo_watch/.metadata @@ -0,0 +1,10 @@ +# 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 and should not be manually edited. + +version: + revision: 20e59316b8b8474554b38493b8ca888794b0234a + channel: stable + +project_type: app diff --git a/demo_watch/.vscode/settings.json b/demo_watch/.vscode/settings.json new file mode 100644 index 0000000..2421e38 --- /dev/null +++ b/demo_watch/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.exclude": { + "**/.classpath": true, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true + } +} \ No newline at end of file diff --git a/demo_watch/Makefile b/demo_watch/Makefile new file mode 100644 index 0000000..98f2a7d --- /dev/null +++ b/demo_watch/Makefile @@ -0,0 +1,7 @@ +fmt: + flutter format lib/* -l 120 +buildApk: + flutter build apk --target-platform android-arm --split-per-abi + +jsonGen: + flutter pub run build_runner build --delete-conflicting-outputs \ No newline at end of file diff --git a/demo_watch/README.md b/demo_watch/README.md new file mode 100644 index 0000000..aa0f340 --- /dev/null +++ b/demo_watch/README.md @@ -0,0 +1,16 @@ +# demo_watch + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/demo_watch/android/.project b/demo_watch/android/.project new file mode 100644 index 0000000..3964dd3 --- /dev/null +++ b/demo_watch/android/.project @@ -0,0 +1,17 @@ + + + android + Project android created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/demo_watch/android/.settings/org.eclipse.buildship.core.prefs b/demo_watch/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/demo_watch/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/demo_watch/android/app/.classpath b/demo_watch/android/app/.classpath new file mode 100644 index 0000000..4a04201 --- /dev/null +++ b/demo_watch/android/app/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/demo_watch/android/app/.project b/demo_watch/android/app/.project new file mode 100644 index 0000000..ac485d7 --- /dev/null +++ b/demo_watch/android/app/.project @@ -0,0 +1,23 @@ + + + app + Project app created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/demo_watch/android/app/.settings/org.eclipse.buildship.core.prefs b/demo_watch/android/app/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..b1886ad --- /dev/null +++ b/demo_watch/android/app/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir=.. +eclipse.preferences.version=1 diff --git a/demo_watch/android/app/build.gradle b/demo_watch/android/app/build.gradle new file mode 100644 index 0000000..3053d9c --- /dev/null +++ b/demo_watch/android/app/build.gradle @@ -0,0 +1,68 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +repositories{ + flatDir{ + dirs 'libs' + } +} + +android { + compileSdkVersion 28 + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "io.dabank.sdkdemo.demo_watch" + minSdkVersion 16 + targetSdkVersion 28 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation (name:'WalletCore',ext:'aar') + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' +} diff --git a/demo_watch/android/app/src/debug/AndroidManifest.xml b/demo_watch/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..4d5dc1c --- /dev/null +++ b/demo_watch/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/demo_watch/android/app/src/main/AndroidManifest.xml b/demo_watch/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4c8df0f --- /dev/null +++ b/demo_watch/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + diff --git a/demo_watch/android/app/src/main/java/io/dabank/sdkdemo/demo_watch/MainActivity.java b/demo_watch/android/app/src/main/java/io/dabank/sdkdemo/demo_watch/MainActivity.java new file mode 100644 index 0000000..05b2f95 --- /dev/null +++ b/demo_watch/android/app/src/main/java/io/dabank/sdkdemo/demo_watch/MainActivity.java @@ -0,0 +1,101 @@ +package io.dabank.sdkdemo.demo_watch; + +import java.util.List; + +import android.os.Bundle; +import io.flutter.app.FlutterActivity; +import io.flutter.plugins.GeneratedPluginRegistrant; + +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.MethodChannel.MethodCallHandler; +import io.flutter.plugin.common.MethodChannel.Result; + +import geth.SimpleMultiSigABIHelper; +import geth.SimpleMultiSigExecuteSignResult; +import geth.Uint8ArrayWrap; +import geth.Byte32ArrayWrap; +import geth.SizedByteArray; +import geth.ETHAddress; + +public class MainActivity extends FlutterActivity { + private static final String CHANNEL = "walletcore/eth"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + GeneratedPluginRegistrant.registerWith(this); + + new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(new MethodCallHandler() { + @Override + public void onMethodCall(MethodCall call, Result result) { + System.out.println(CHANNEL + ":" + call.method + ",arguments:" + call.arguments); + + try { + + switch (call.method) { + case "genEthKey": { + String prvk = (String) call.arguments; + String key = geth.Geth.utilGenKey(prvk); + result.success(key); + break; + } + case "buildTime": { + String bt = mobile.Mobile.getBuildTime(); + result.success(bt); + break; + } + case "simpleMultisigAbiPackedNonce": { + SimpleMultiSigABIHelper helper = new SimpleMultiSigABIHelper(); + byte[] ret = helper.packedNonce(); + result.success(ret); + break; + } + case "simpleMultisigAbiUnpackedNonce": { + byte[] resp = call.arguments(); + SimpleMultiSigABIHelper helper = new SimpleMultiSigABIHelper(); + geth.BigInt bigInt = helper.unpackNonce(resp); + Long nonce = bigInt.getInt64(); + result.success(nonce); + break; + } + case "simpleMultisigPackedExecute": { + String toAddress = call.argument("toAddress"); + Double amount = call.argument("amount"); + byte[] data = call.argument("data"); + Integer gasLimit = call.argument("gasLimit"); + List sigs = call.argument("sigs"); //需要根据address按照升序排好 + String executorAddr = call.argument("executor"); + ETHAddress executor = new ETHAddress(executorAddr); //此处为空地址 + + Uint8ArrayWrap sigVs = new Uint8ArrayWrap(); + Byte32ArrayWrap sigRs = new Byte32ArrayWrap(); + Byte32ArrayWrap sigSs = new Byte32ArrayWrap(); + + for (int i = 0; i< sigs.size(); i++) { + String sig = sigs.get(i); + SimpleMultiSigExecuteSignResult re = new SimpleMultiSigExecuteSignResult(sig); + SizedByteArray r = re.getR(); + SizedByteArray s = re.getS(); + sigVs.addOne(re.getV()); + sigRs.addOne(re.getR().get()); + sigSs.addOne(re.getS().get()); + } + SimpleMultiSigABIHelper helper = new SimpleMultiSigABIHelper(); + byte[] packedExecuteData = helper.packedExecute(sigVs, sigRs, sigSs, new ETHAddress(toAddress), new geth.BigInt(amount.longValue()), data, executor, new geth.BigInt(gasLimit.longValue())); + result.success(packedExecuteData); + // System.out.println(packedExecuteData); + break; + } + default: + throw new RuntimeException("unknown channel method"); + } + + } catch (Exception e) { + System.err.println(e); + e.printStackTrace(); + } + } + }); + } +} diff --git a/demo_watch/android/app/src/main/res/drawable/launch_background.xml b/demo_watch/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/demo_watch/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/demo_watch/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/demo_watch/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/demo_watch/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/demo_watch/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/demo_watch/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/demo_watch/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/demo_watch/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/demo_watch/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/demo_watch/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/demo_watch/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/demo_watch/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/demo_watch/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/demo_watch/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/demo_watch/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/demo_watch/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/demo_watch/android/app/src/main/res/values/styles.xml b/demo_watch/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..00fa441 --- /dev/null +++ b/demo_watch/android/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + diff --git a/demo_watch/android/app/src/profile/AndroidManifest.xml b/demo_watch/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..c45d2b7 --- /dev/null +++ b/demo_watch/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/demo_watch/android/build.gradle b/demo_watch/android/build.gradle new file mode 100644 index 0000000..bb8a303 --- /dev/null +++ b/demo_watch/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/demo_watch/android/gradle.properties b/demo_watch/android/gradle.properties new file mode 100644 index 0000000..2bd6f4f --- /dev/null +++ b/demo_watch/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx1536M + diff --git a/demo_watch/android/gradle/wrapper/gradle-wrapper.properties b/demo_watch/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2819f02 --- /dev/null +++ b/demo_watch/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/demo_watch/android/settings.gradle b/demo_watch/android/settings.gradle new file mode 100644 index 0000000..5a2f14f --- /dev/null +++ b/demo_watch/android/settings.gradle @@ -0,0 +1,15 @@ +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +} diff --git a/demo_watch/assets/qr_code.png b/demo_watch/assets/qr_code.png new file mode 100644 index 0000000..d4a8491 Binary files /dev/null and b/demo_watch/assets/qr_code.png differ diff --git a/demo_watch/assets/scan_qr.png b/demo_watch/assets/scan_qr.png new file mode 100644 index 0000000..e7ee839 Binary files /dev/null and b/demo_watch/assets/scan_qr.png differ diff --git a/demo_watch/doc/design.md b/demo_watch/doc/design.md new file mode 100644 index 0000000..47936d2 --- /dev/null +++ b/demo_watch/doc/design.md @@ -0,0 +1,15 @@ +# code design + +## route +TBD + +## url +demoapp://addr/ +demoapp://pubkey/ +demoapp://prvkey/ +demoapp://rawtx/ +demoapp://signed/part/1-3/ +demoapp://signed/part/2-3/ +demoapp://reqsign/createmultisig/ +demoapp://reqsign/ethtransafer/ +demoapp://reqsign/multisigexecute/ \ No newline at end of file diff --git a/demo_watch/ios/Flutter/AppFrameworkInfo.plist b/demo_watch/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..6b4c0f7 --- /dev/null +++ b/demo_watch/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 8.0 + + diff --git a/demo_watch/ios/Flutter/Debug.xcconfig b/demo_watch/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..e8efba1 --- /dev/null +++ b/demo_watch/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/demo_watch/ios/Flutter/Release.xcconfig b/demo_watch/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..399e934 --- /dev/null +++ b/demo_watch/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/demo_watch/ios/Podfile b/demo_watch/ios/Podfile new file mode 100644 index 0000000..64ba749 --- /dev/null +++ b/demo_watch/ios/Podfile @@ -0,0 +1,72 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def parse_KV_file(file, separator='=') + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return []; + end + pods_ary = [] + skip_line_start_symbols = ["#", "/"] + File.foreach(file_abs_path) { |line| + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } + plugin = line.split(pattern=separator) + if plugin.length == 2 + podname = plugin[0].strip() + path = plugin[1].strip() + podpath = File.expand_path("#{path}", file_abs_path) + pods_ary.push({:name => podname, :path => podpath}); + else + puts "Invalid plugin specification: #{line}" + end + } + return pods_ary +end + +target 'Runner' do + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock + # referring to absolute paths on developers' machines. + system('rm -rf .symlinks') + system('mkdir -p .symlinks/plugins') + + # Flutter Pods + generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') + if generated_xcode_build_settings.empty? + puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first." + end + generated_xcode_build_settings.map { |p| + if p[:name] == 'FLUTTER_FRAMEWORK_DIR' + symlink = File.join('.symlinks', 'flutter') + File.symlink(File.dirname(p[:path]), symlink) + pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) + end + } + + # Plugin Pods + plugin_pods = parse_KV_file('../.flutter-plugins') + plugin_pods.map { |p| + symlink = File.join('.symlinks', 'plugins', p[:name]) + File.symlink(p[:path], symlink) + pod p[:name], :path => File.join(symlink, 'ios') + } +end + +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['ENABLE_BITCODE'] = 'NO' + end + end +end diff --git a/demo_watch/ios/Podfile.lock b/demo_watch/ios/Podfile.lock new file mode 100644 index 0000000..cdd0b14 --- /dev/null +++ b/demo_watch/ios/Podfile.lock @@ -0,0 +1,34 @@ +PODS: + - Flutter (1.0.0) + - flutter_webview_plugin (0.0.1): + - Flutter + - qrcode_reader (0.0.1): + - Flutter + - shared_preferences (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `.symlinks/flutter/ios`) + - flutter_webview_plugin (from `.symlinks/plugins/flutter_webview_plugin/ios`) + - qrcode_reader (from `.symlinks/plugins/qrcode_reader/ios`) + - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: ".symlinks/flutter/ios" + flutter_webview_plugin: + :path: ".symlinks/plugins/flutter_webview_plugin/ios" + qrcode_reader: + :path: ".symlinks/plugins/qrcode_reader/ios" + shared_preferences: + :path: ".symlinks/plugins/shared_preferences/ios" + +SPEC CHECKSUMS: + Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a + flutter_webview_plugin: ed9e8a6a96baf0c867e90e1bce2673913eeac694 + qrcode_reader: 09b34d43b4c08fe5b63a6e56c96789bcea7b9148 + shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523 + +PODFILE CHECKSUM: 7fb83752f59ead6285236625b82473f90b1cb932 + +COCOAPODS: 1.7.5 diff --git a/demo_watch/ios/Runner.xcodeproj/project.pbxproj b/demo_watch/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2d26356 --- /dev/null +++ b/demo_watch/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,594 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 4D878D8397CFC736E43DB507 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C1C259A1F76529AB7AC3670 /* libPods-Runner.a */; }; + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + CB7DDD78230650FE00A376A6 /* Wallet.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB7DDD77230650FE00A376A6 /* Wallet.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 0FDA8AAC1DFF069463621C33 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 1C1C259A1F76529AB7AC3670 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 8D7F6BDE09A7FDE7BB758D57 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CB7DDD77230650FE00A376A6 /* Wallet.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Wallet.framework; sourceTree = ""; }; + CD06D24B93150EE1061A91F9 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + CB7DDD78230650FE00A376A6 /* Wallet.framework in Frameworks */, + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, + 4D878D8397CFC736E43DB507 /* libPods-Runner.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B80C3931E831B6300D905FE /* App.framework */, + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEBA1CF902C7004384FC /* Flutter.framework */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + F0A8CD0BC5726B80442C76E4 /* Pods */, + CC457842CA68040B3737FA19 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + CC457842CA68040B3737FA19 /* Frameworks */ = { + isa = PBXGroup; + children = ( + CB7DDD77230650FE00A376A6 /* Wallet.framework */, + 1C1C259A1F76529AB7AC3670 /* libPods-Runner.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + F0A8CD0BC5726B80442C76E4 /* Pods */ = { + isa = PBXGroup; + children = ( + CD06D24B93150EE1061A91F9 /* Pods-Runner.debug.xcconfig */, + 8D7F6BDE09A7FDE7BB758D57 /* Pods-Runner.release.xcconfig */, + 0FDA8AAC1DFF069463621C33 /* Pods-Runner.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + DED1ECC9FBE9FDF50F22448C /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 908D45AF8F5A7F88B07DB80F /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = "The Chromium Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = SYACGFGV53; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + }; + 908D45AF8F5A7F88B07DB80F /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + DED1ECC9FBE9FDF50F22448C /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = SYACGFGV53; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + "$(PROJECT_DIR)", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = io.dabank.sdkdemo.demoWatch; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = SYACGFGV53; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + "$(PROJECT_DIR)", + ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"${PODS_ROOT}/Headers/Public\"", + "\"${PODS_ROOT}/Headers/Public/flutter_webview_plugin\"", + "\"${PODS_ROOT}/Headers/Public/qrcode_reader\"", + "\"${PODS_ROOT}/Headers/Public/shared_preferences\"", + "\"$(SRCROOT)/Wallet.framework/Headers\"", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = io.dabank.sdkdemo.demoWatch; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = SYACGFGV53; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + "$(PROJECT_DIR)", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = io.dabank.sdkdemo.demoWatch; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/demo_watch/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/demo_watch/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/demo_watch/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/demo_watch/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/demo_watch/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..a28140c --- /dev/null +++ b/demo_watch/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo_watch/ios/Runner.xcworkspace/contents.xcworkspacedata b/demo_watch/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..21a3cc1 --- /dev/null +++ b/demo_watch/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/demo_watch/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/demo_watch/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/demo_watch/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/demo_watch/ios/Runner/AppDelegate.h b/demo_watch/ios/Runner/AppDelegate.h new file mode 100644 index 0000000..36e21bb --- /dev/null +++ b/demo_watch/ios/Runner/AppDelegate.h @@ -0,0 +1,6 @@ +#import +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/demo_watch/ios/Runner/AppDelegate.m b/demo_watch/ios/Runner/AppDelegate.m new file mode 100644 index 0000000..86a53b8 --- /dev/null +++ b/demo_watch/ios/Runner/AppDelegate.m @@ -0,0 +1,43 @@ +#include "AppDelegate.h" +#include "GeneratedPluginRegistrant.h" + +#include "Wallet/Mobile.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + //sdk binding + FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController; + FlutterMethodChannel* walletChannel = [FlutterMethodChannel + methodChannelWithName:@"walletcore/eth" + binaryMessenger:controller]; + + [walletChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { + // Note: this method is invoked on the UI thread. + // TODO + + if ([@"buildTime" isEqualToString:call.method]) { + NSString* t = MobileGetBuildTime(); + + result(t); + +// if (batteryLevel == -1) { +// result([FlutterError errorWithCode:@"UNAVAILABLE" +// message:@"Battery info unavailable" +// details:nil]); +// } else { +// result(@(batteryLevel)); +// } + } else { + result(FlutterMethodNotImplemented); + } + }]; + + [GeneratedPluginRegistrant registerWithRegistry:self]; + // Override point for customization after application launch. + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +@end diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..3d43d11 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..28c6bf0 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..f091b6b Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cde121 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..d0ef06e Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..dcdc230 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..c8f9ed8 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..75b2d16 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..c4df70d Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..6a84f41 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..d0e1f58 Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/demo_watch/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/demo_watch/ios/Runner/Base.lproj/LaunchScreen.storyboard b/demo_watch/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/demo_watch/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo_watch/ios/Runner/Base.lproj/Main.storyboard b/demo_watch/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/demo_watch/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo_watch/ios/Runner/Info.plist b/demo_watch/ios/Runner/Info.plist new file mode 100644 index 0000000..a1f9153 --- /dev/null +++ b/demo_watch/ios/Runner/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + demo_watch + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/demo_watch/ios/Runner/main.m b/demo_watch/ios/Runner/main.m new file mode 100644 index 0000000..dff6597 --- /dev/null +++ b/demo_watch/ios/Runner/main.m @@ -0,0 +1,9 @@ +#import +#import +#import "AppDelegate.h" + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/demo_watch/lib/main.dart b/demo_watch/lib/main.dart new file mode 100644 index 0000000..896de61 --- /dev/null +++ b/demo_watch/lib/main.dart @@ -0,0 +1,91 @@ +import 'dart:async'; + +import 'package:demo_watch/ui/index.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:oktoast/oktoast.dart'; +import 'package:demo_watch/ui/addr_list.dart'; + +void main() { + // This captures errors reported by the Flutter framework. + FlutterError.onError = (FlutterErrorDetails details) async { + if (isInDebugMode) { + // In development mode simply print to console. + FlutterError.dumpErrorToConsole(details); + } else { + // In production mode report to the application zone to report to + // Sentry. + Zone.current.handleUncaughtError(details.exception, details.stack); + } + }; + + // This creates a [Zone] that contains the Flutter application and stablishes + // an error handler that captures errors and reports them. + // + // Using a zone makes sure that as many errors as possible are captured, + // including those thrown from [Timer]s, microtasks, I/O, and those forwarded + // from the `FlutterError` handler. + // + // More about zones: + // + // - https://api.dartlang.org/stable/1.24.2/dart-async/Zone-class.html + // - https://www.dartlang.org/articles/libraries/zones + runZoned>(() async { + runApp(new MyApp()); + }, onError: (error, stackTrace) async { + await _reportError(error, stackTrace); + }); +} + +class MyApp extends StatelessWidget { + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return OKToast( + child: MaterialApp( + debugShowCheckedModeBanner: false, + localizationsDelegates: [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: [ + const Locale('zh', 'CN'), // Hebrew + ], + title: '观察钱包', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + initialRoute: '/', + routes: { + IndexPage.routeName: (_) => IndexPage(), + AddrList.routeName: (_) => AddrList(), + }, + ), + ); + } +} + +/// Reports [error] along with its [stackTrace] to Sentry.io. +Future _reportError(dynamic error, dynamic stackTrace) async { + print('Caught error: $error'); + + var atLine = stackTrace.toString().split('\n')[0]; + showToast( + error.toString() + '\n$atLine', + duration: Duration(seconds: 10), + textStyle: TextStyle(color: Colors.redAccent), + ); + print(error.toString()); +} + +bool get isInDebugMode { + // Assume we're in production mode + bool _inDebugMode = false; + + // Assert expressions are only evaluated during development. They are ignored + // in production. Therefore, this code will only turn `inDebugMode` to true + // in our development environments! + assert(_inDebugMode = true); + + return _inDebugMode; +} diff --git a/demo_watch/lib/models/addr.dart b/demo_watch/lib/models/addr.dart new file mode 100644 index 0000000..291b1a4 --- /dev/null +++ b/demo_watch/lib/models/addr.dart @@ -0,0 +1,19 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'addr.g.dart'; + +@JsonSerializable() +class AddrInfo { + String addr; + bool isMultisig; + + //多签用 + int sigRequired; + List memberAddrs; + String pendingTxid; //创建多签交易时的pending txid,不为空时表示还没打包不能获取合约地址 + + AddrInfo(); + + factory AddrInfo.fromJson(Map json) => _$AddrInfoFromJson(json); + Map toJson() => _$AddrInfoToJson(this); +} diff --git a/demo_watch/lib/models/addr.g.dart b/demo_watch/lib/models/addr.g.dart new file mode 100644 index 0000000..6715a5e --- /dev/null +++ b/demo_watch/lib/models/addr.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'addr.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +AddrInfo _$AddrInfoFromJson(Map json) { + return AddrInfo() + ..addr = json['addr'] as String + ..isMultisig = json['isMultisig'] as bool + ..sigRequired = json['sigRequired'] as int + ..memberAddrs = (json['memberAddrs'] as List)?.map((e) => e as String)?.toList() + ..pendingTxid = json['pendingTxid'] as String; +} + +Map _$AddrInfoToJson(AddrInfo instance) => { + 'addr': instance.addr, + 'isMultisig': instance.isMultisig, + 'sigRequired': instance.sigRequired, + 'memberAddrs': instance.memberAddrs, + 'pendingTxid': instance.pendingTxid + }; diff --git a/demo_watch/lib/models/doc.md b/demo_watch/lib/models/doc.md new file mode 100644 index 0000000..939242c --- /dev/null +++ b/demo_watch/lib/models/doc.md @@ -0,0 +1,11 @@ +## add json support +``` +part 'addr.g.dart'; + +@JsonSerializable() + +#add default constructor + +factory AddrInfo.fromJson(Map json) => _$AddrInfoFromJson(json); +Map toJson() => _$AddrInfoToJson(this); +``` \ No newline at end of file diff --git a/demo_watch/lib/repo/addrs.dart b/demo_watch/lib/repo/addrs.dart new file mode 100644 index 0000000..48ba111 --- /dev/null +++ b/demo_watch/lib/repo/addrs.dart @@ -0,0 +1,60 @@ +import 'dart:convert'; + +import 'package:demo_watch/models/addr.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +const KEY_MULTISIG_ADDRS = 'multisig_addrs'; +const String STORE_KEY_ADDRS = "k:addrs"; + +class AddrRepo { + static Future> loadAll() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + String json = prefs.getString(STORE_KEY_ADDRS); + + List addrs = []; + if (json != null) { + Iterable l = jsonDecode(json); + if (l != null) { + addrs = l.map((json) => AddrInfo.fromJson(json)).toList(); + } + } + return addrs; + } + + static Future replace(List addrs) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.remove(STORE_KEY_ADDRS); + prefs.setString(STORE_KEY_ADDRS, jsonEncode(addrs)); + } + + /// 1.增加地址(无txid) 2.增加多签地址(有txid) 3.增加pending中的多签地址(有txid,无addr) + static Future> add(AddrInfo newOne) async { + var list = await loadAll(); + //重复地址不再存储 + if (newOne.addr != null) { + if (list.any((ad) => ad.addr == newOne.addr)) { + return list; + } + } else { + //没有地址以txid识别 + if (newOne.pendingTxid != null && list.any((v) => v.pendingTxid == newOne.pendingTxid)) { + return list; + } + } + + //保存多签地址(有txid)时,把旧的移除掉(因为旧的可能pending时暂存还没有地址) + if (newOne.addr != null && newOne.pendingTxid != null) { + list.removeWhere((x) => x.pendingTxid == newOne.pendingTxid); + } + + list.add(newOne); + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString(STORE_KEY_ADDRS, jsonEncode(list)); + return list; + } + + static Future clear() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.remove(STORE_KEY_ADDRS); + } +} diff --git a/demo_watch/lib/repo/repo.dart b/demo_watch/lib/repo/repo.dart new file mode 100644 index 0000000..d0c2a27 --- /dev/null +++ b/demo_watch/lib/repo/repo.dart @@ -0,0 +1,15 @@ +import 'package:demo_watch/rpc/eth_rpc.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class Repo { + static const String KEY_RPC_URL = 'key/rpcurl'; + static Future getRPCUrl() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + return prefs.getString(KEY_RPC_URL) ?? EthRpc.defaultRpcUrl; + } + + static Future setRPCUrl(String url) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString(KEY_RPC_URL, url); + } +} diff --git a/demo_watch/lib/rpc/eth_rpc.dart b/demo_watch/lib/rpc/eth_rpc.dart new file mode 100644 index 0000000..6742147 --- /dev/null +++ b/demo_watch/lib/rpc/eth_rpc.dart @@ -0,0 +1,120 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:convert/convert.dart'; +import 'package:http/http.dart' as http; + +class EthRpc { + static const defaultRpcUrl = "https://ropsten.infura.io/v3/69f29be376784f37b36a146ce7581efc"; + static String rpcUrl = defaultRpcUrl; + + static Map invoke(String method, dynamic args) { + Map m = {"jsonrpc": "2.0", "method": method, "params": args, "id": 1}; + print('rpc: ' + jsonEncode(m)); + return m; + } + + static Future getBalance(String address, String block) async { + var resp = await http.post( + rpcUrl, + body: jsonEncode(invoke("eth_getBalance", [address, block ?? "latest"])), + ); + if (resp.statusCode != 200) { + print(resp.body); + return "<${resp.statusCode}>"; + } + Map m = jsonDecode(resp.body); + return m['result']; + } + + static Future getTransactionCount(String address, String block) async { + var resp = + await http.post(rpcUrl, body: jsonEncode(invoke('eth_getTransactionCount', [address, block ?? 'latest']))); + if (resp.statusCode != 200) { + print(resp.body); + return -1; + } + Map m = jsonDecode(resp.body); + return int.parse(m['result'].substring(2), radix: 16); + } + + static Future getSuggestedGasPrice() async { + var resp = await http.post(rpcUrl, body: jsonEncode(invoke('eth_gasPrice', []))); + if (resp.statusCode != 200) { + print(resp.body); + return -1; + } + Map m = jsonDecode(resp.body); + return int.parse(m['result'].substring(2), radix: 16); + } + + static Future> getBlockByNumber(int id, bool txDetail) async { + var resp = + await http.post(rpcUrl, body: jsonEncode(invoke('eth_getBlockByNumber', [id ?? 'latest', txDetail ?? false]))); + if (resp.statusCode != 200) { + throw resp; + } + Map m = jsonDecode(resp.body); + if (m['result'] == null) { + throw resp.body; + } + print(resp.body); + return m['result']; + } + + static Future sendRawTransaction(String tx) async { + var resp = await http.post(rpcUrl, body: jsonEncode(invoke('eth_sendRawTransaction', [tx]))); + if (resp.statusCode != 200) { + print(resp.body); + return 'http_err_code: ${resp.statusCode}'; + } + print(resp.body); + Map m = jsonDecode(resp.body); + var ret = m['result']; + if (ret == null) { + throw resp.body; + } + return ret; + } + + static Future> getTransactionReceipt(String txid) async { + var resp = await http.post(rpcUrl, body: jsonEncode(invoke('eth_getTransactionReceipt', [txid]))); + if (resp.statusCode != 200) { + print(resp.body); + throw 'http_err_code: ${resp.statusCode}\n${resp.body}'; + } + Map m = jsonDecode(resp.body); + var ret = m['result']; + // if (ret == null) { + // throw resp.body; + // } + return ret; + } + + static Future> getNonceGaspriceGaslimit(String addr) async { + var nonce = await getTransactionCount(addr, null); + var gasPrice = await getSuggestedGasPrice(); + gasPrice = (gasPrice * 3).ceil(); //加倍 + var block = await getBlockByNumber(null, null); + var gasLimit = int.parse(block['gasLimit'].substring(2), radix: 16) - 1000; + return [nonce, gasPrice, gasLimit]; + } + + static Future call(String to, Uint8List data) async { + Map m = { + 'to': to, + 'data': '0x' + hex.encode(data), //0xaffed0e0 + }; + var resp = await http.post(rpcUrl, body: jsonEncode(invoke('eth_call', [m, 'latest']))); + if (resp.statusCode != 200) { + throw resp; + } + print(resp.body); + Map rm = jsonDecode(resp.body); + var ret = rm['result']; + if (ret == null) { + throw resp.body; + } + return ret; + } +} diff --git a/demo_watch/lib/sdk/sdk_wrapper.dart b/demo_watch/lib/sdk/sdk_wrapper.dart new file mode 100644 index 0000000..5ad3a1c --- /dev/null +++ b/demo_watch/lib/sdk/sdk_wrapper.dart @@ -0,0 +1,41 @@ +import 'dart:typed_data'; + +import 'package:flutter/services.dart'; + +class SdkWrapper { + static const platform = const MethodChannel('walletcore/eth'); + + static Future buildTime() async { + String ret = await platform.invokeMethod('buildTime'); + return ret; + } + + static Future simpleMultisigAbiPackedNonce() async { + Uint8List ret = await platform.invokeMethod('simpleMultisigAbiPackedNonce'); + return ret; + } + + static Future simpleMultisigAbiUnpackedNonce(List result) async { + int ret = await platform.invokeMethod('simpleMultisigAbiUnpackedNonce', result); + return ret; + } + + static Future simpleMultisigPackedExecute({ + String toAddress, + double amount, + Uint8List data, + int gasLimit, + String executor, + List sortedSigs, //按照签名地址升序排序 + }) async { + Uint8List ret = await platform.invokeMethod('simpleMultisigPackedExecute', { + 'toAddress': toAddress, + 'amount': amount, + 'data': data, + 'gasLimit': gasLimit, + 'sigs': sortedSigs, + 'executor': executor, + }); + return ret; + } +} diff --git a/demo_watch/lib/shared/assets.dart b/demo_watch/lib/shared/assets.dart new file mode 100644 index 0000000..06e3137 --- /dev/null +++ b/demo_watch/lib/shared/assets.dart @@ -0,0 +1,2 @@ +const ASSETS_QR_CODE = 'assets/qr_code.png'; +const ASSETS_SCAN_QR = 'assets/scan_qr.png'; diff --git a/demo_watch/lib/shared/const.dart b/demo_watch/lib/shared/const.dart new file mode 100644 index 0000000..b2efda2 --- /dev/null +++ b/demo_watch/lib/shared/const.dart @@ -0,0 +1,31 @@ +const CHAIN_ID = 3; +const ETH18 = 1000000000000000000; +const APP_URL_SCHEMA = 'demoapp://'; + +const PATH_REQ_SIGN_CONTENT = 'reqsign/'; +const PATH_REQ_SIGN_CONTENT_CREATEMULTISIGCONTRACT = 'createmultisig/'; +const PATH_REQ_SIGN_CONTENT_ETHTRANSFER = 'ethtransfer/'; +const PATH_REQ_SIGN_CONTENT_MULTISIGEXECUTE = 'multisigexecute/'; + +const PATH_SIGNED_DATA = ''; + +const PATH_PRIVATEKEY = 'prvkey/'; +const PATH_ADDR = 'addr/'; +const PATH_PUBKEY = 'pubkey/'; +const PATH_RAWTX = 'rawtx/'; +const PATH_PART = 'part/'; //eg, part:1/3:rawtx:... +const PATH_SIGNED = 'signed/'; + +String trimLeftUrlSchema(String url) { + if (url == null) { + return url; + } + if (!url.startsWith(APP_URL_SCHEMA)) { + return url; + } + return url.substring(APP_URL_SCHEMA.length); +} + +String urlWithAppSchema(String path) { + return APP_URL_SCHEMA + path; +} diff --git a/demo_watch/lib/shared/req_sign_content.dart b/demo_watch/lib/shared/req_sign_content.dart new file mode 100644 index 0000000..e1df3e2 --- /dev/null +++ b/demo_watch/lib/shared/req_sign_content.dart @@ -0,0 +1,195 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'const.dart'; + +ReqSignContent parseReqSignContent(String encodedContentWithPrefix) { + encodedContentWithPrefix = trimLeftUrlSchema(encodedContentWithPrefix); + if (!encodedContentWithPrefix.startsWith(PATH_REQ_SIGN_CONTENT)) { + throw 'not start with $PATH_REQ_SIGN_CONTENT'; + } + + String content = encodedContentWithPrefix.substring(PATH_REQ_SIGN_CONTENT.length); + + if (content.startsWith(PATH_REQ_SIGN_CONTENT_CREATEMULTISIGCONTRACT)) { + var req = ReqSignContentCreateMultisigContract(); + req.decode(content); + return req; + } else if (content.startsWith(PATH_REQ_SIGN_CONTENT_ETHTRANSFER)) { + var req = ReqSignContentETHTransfer(); + req.decode(content); + return req; + } else if (content.startsWith(PATH_REQ_SIGN_CONTENT_MULTISIGEXECUTE)) { + var req = ReqSignContentMultisigExecute(); + req.decode(content); + return req; + } else { + throw 'unknown req sign content'; + } +} + +abstract class ReqSignContent { + String title(); + String encode(); //用于展示二维码 + void decode(String content); //扫码 + String info(); //详细描述 +} + +/// 创建多签合约 +class ReqSignContentCreateMultisigContract implements ReqSignContent { + int nonce; + int sigRequired; + int gasPrice; + int gasLimit; + List addrs; + + @override + void decode(String content) { + var items = content.substring(PATH_REQ_SIGN_CONTENT_CREATEMULTISIGCONTRACT.length).split(","); + nonce = int.parse(items[0]); + sigRequired = int.parse(items[1]); + gasPrice = int.parse(items[2]); + gasLimit = int.parse(items[3]); + addrs = items.sublist(4); + } + + @override + String encode() { + List list = [ + nonce.toString(), + sigRequired.toString(), + gasPrice.toString(), + gasLimit.toString(), + ...addrs, + ]; + return PATH_REQ_SIGN_CONTENT_CREATEMULTISIGCONTRACT + list.join(","); + } + + @override + String info() { + return ''' +nonce: $nonce +签名人数 - 总人数:$sigRequired - 2 +gasPrice: $gasPrice +gasLimit: $gasLimit +地址1: ${addrs[0]} +地址2: ${addrs[1]} + '''; + } + + @override + String title() { + return '创建 $sigRequired - 2 多签合约'; + } +} + +/// 转账或合约调用 +class ReqSignContentETHTransfer implements ReqSignContent { + int nonce; + String toAddress; + double amount; + int gasLimit; + int gasPrice; + Uint8List data; + + @override + void decode(String content) { + var items = content.substring(PATH_REQ_SIGN_CONTENT_ETHTRANSFER.length).split(','); + nonce = int.parse(items[0]); + toAddress = items[1]; + amount = double.parse(items[2]); + gasLimit = int.parse(items[3]); + gasPrice = int.parse(items[4]); + if (items.length >= 6) { + data = base64Decode(items[5]); + } + } + + @override + String encode() { + List items = [ + nonce.toString(), + toAddress, + amount.toString(), + gasLimit.toString(), + gasPrice.toString(), + if (data != null) base64Encode(data) + ]; + return PATH_REQ_SIGN_CONTENT_ETHTRANSFER + items.join(','); + } + + @override + String info() { + return ''' +nonce: $nonce, +地址: $toAddress, +金额: $amount, +gasLimit: $gasLimit, +gasPrice: $gasPrice, +data.length: ${data?.length ?? 0} + '''; + } + + @override + String title() { + return 'ETH 转账 或 合约调用'; + } +} + +/// 多签转账签名(不是后续的交易签名 +class ReqSignContentMultisigExecute implements ReqSignContent { + String multisigContractAddress; + String toAddress; + int internalNonce; + double amount; //value + int gasLimit; + String exectorAddress; //最终发起交易的人,这里由创建人发起 + // int gasPrice; + Uint8List data; + + @override + void decode(String content) { + var items = content.substring(PATH_REQ_SIGN_CONTENT_MULTISIGEXECUTE.length).split(','); + multisigContractAddress = items[0]; + toAddress = items[1]; + internalNonce = int.parse(items[2]); + amount = double.parse(items[3]); + gasLimit = int.parse(items[4]); + exectorAddress = items[5]; + if (items.length >= 7) { + data = base64Decode(items[6]); + } + } + + @override + String encode() { + List items = [ + multisigContractAddress, + toAddress, + internalNonce.toString(), + amount.toString(), + gasLimit.toString(), + exectorAddress, + if (data != null) base64Encode(data) + ]; + return PATH_REQ_SIGN_CONTENT_MULTISIGEXECUTE + items.join(','); + } + + @override + String info() { + return ''' +多签合约地址: $multisigContractAddress +目标地址: $toAddress +内部nonce: $internalNonce +amount: $amount +gasLimit: $gasLimit +执行/地址: $exectorAddress +data.length: ${data?.length ?? 0} + '''; + } + + @override + String title() { + return '多签转账原始数据签名'; + } +} diff --git a/demo_watch/lib/shared/utl.dart b/demo_watch/lib/shared/utl.dart new file mode 100644 index 0000000..992bd45 --- /dev/null +++ b/demo_watch/lib/shared/utl.dart @@ -0,0 +1,6 @@ +String utlTrimLeft(String content, String trim) { + if (content == null) { + return null; + } + return content.startsWith(trim) ? content.substring(trim.length) : content; +} diff --git a/demo_watch/lib/shared/widgets/action_import_data.dart b/demo_watch/lib/shared/widgets/action_import_data.dart new file mode 100644 index 0000000..a7306c4 --- /dev/null +++ b/demo_watch/lib/shared/widgets/action_import_data.dart @@ -0,0 +1,109 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:oktoast/oktoast.dart'; +import 'package:qrcode_reader/qrcode_reader.dart'; + +import '../const.dart'; + +const int FromClipboard = 1; +const int FromCamera = 2; +const int CancelAction = 0; + +/// 读取导入数据从二维码或者剪切板 +Future readImportData(BuildContext ctx, {int source}) async { + int fromSource; + + if (source != null) { + fromSource = source; + } else { + fromSource = await showModalBottomSheet( + context: ctx, + builder: (c) => ButtonBar( + alignment: MainAxisAlignment.center, + children: [ + FlatButton( + child: Text('读取剪贴板'), + onPressed: () => Navigator.of(c).pop(FromClipboard), + ), + FlatButton( + child: Text('扫码'), + onPressed: () => Navigator.of(c).pop(FromCamera), + ), + FlatButton( + child: Text('取消'), + onPressed: () => Navigator.of(c).pop(CancelAction), + ) + ], + ), + ); + } + + if (fromSource == null || fromSource == CancelAction) { + return null; + } + + String readAddr; + if (fromSource == FromClipboard) { + readAddr = (await Clipboard.getData("text/plain")).text; + return readAddr; + } + + if (fromSource == FromCamera) { + String ret = await scanQRCode(); + + if (ret == null || !ret.startsWith(PATH_PART)) { + return ret; + } + + // 如果包含多页,则以第一页的总共页数为依据,一直读取,直到全部扫码完成 + int totalPage = -1; + List pages = []; + // part/1-3/${data} + while (pages.length == 0 || pages.contains(null)) { + var partPageData = ret.split('/'); + String data = partPageData.sublist(2).join('/'); + var indexTotalString = partPageData[1].split('-'); + + if (totalPage == -1) { + totalPage = int.parse(indexTotalString[1]); + pages = List.generate(totalPage, (_) => null); + } + + int currentIndex = int.parse(indexTotalString[0]); + print('currentindex $currentIndex, pages length:${pages.length}'); + if (pages[currentIndex] == null) { + pages[currentIndex] = data; + print('readed:$ret'); + } + + List scanedPages = []; + List notScanedPages = []; + for (int i = 0; i < totalPage; i++) { + if (pages[i] != null) { + scanedPages.add(i + 1); + } else { + notScanedPages.add(i + 1); + } + } + showToast('已获取第$scanedPages 页\n剩余第 $notScanedPages 页'); + if (notScanedPages.length == 0) { + break; + } + await Future.delayed(const Duration(seconds: 2), () => null); //睡眠1s + ret = await scanQRCode(); + } + return pages.join(''); + } + return null; +} + +Future scanQRCode() { + return QRCodeReader() + .setAutoFocusIntervalInMs(500) // default 5000 + .setForceAutoFocus(true) // default false + .setTorchEnabled(true) // default false + .setHandlePermissions(true) // default true + .setExecuteAfterPermissionGranted(true) // default true + .scan(); +} diff --git a/demo_watch/lib/shared/widgets/copy_btn.dart b/demo_watch/lib/shared/widgets/copy_btn.dart new file mode 100644 index 0000000..7560e98 --- /dev/null +++ b/demo_watch/lib/shared/widgets/copy_btn.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import 'snack_info_copied.dart'; + +class CopyBtn extends StatelessWidget { + final String content; + + const CopyBtn({Key key, this.content}) : super(key: key); + + @override + Widget build(BuildContext context) { + return IconButton( + tooltip: '复制', + icon: Icon(Icons.content_copy), + onPressed: () { + Clipboard.setData(ClipboardData(text: content)); + Scaffold.of(context).showSnackBar(SnackBar(content: SnackInfoCopied(content))); + print('copied:\n$content\n'); + }, + ); + } +} diff --git a/demo_watch/lib/shared/widgets/copy_qrcode_btn.dart b/demo_watch/lib/shared/widgets/copy_qrcode_btn.dart new file mode 100644 index 0000000..9882c80 --- /dev/null +++ b/demo_watch/lib/shared/widgets/copy_qrcode_btn.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:qr_flutter/qr_flutter.dart'; + +import '../assets.dart'; + +class CopyOrShowQRCode extends StatelessWidget { + final String text; + + const CopyOrShowQRCode({Key key, this.text}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + width: 100, + child: Row( + children: [ + IconButton( + tooltip: '复制', + icon: Icon(Icons.content_copy), + onPressed: () { + Clipboard.setData(ClipboardData(text: text)); + Scaffold.of(context).showSnackBar(SnackBar( + content: Row( + children: [ + Text('copied:', style: TextStyle(color: Colors.lightBlue)), + Expanded(child: Text(text)), + ], + ), + )); + }, + ), + IconButton( + icon: ImageIcon(AssetImage(ASSETS_QR_CODE)), + tooltip: '显示二维码', + onPressed: () => actionShowQRCode(text, context), + ), + ], + ), + ); + } + + void actionShowQRCode(String content, BuildContext ctx) { + showDialog( + context: ctx, + builder: (ctx) => Scaffold( + body: SingleChildScrollView( + child: Center( + child: Column( + children: [ + SizedBox(height: 24), + Text(content), + QrImage(data: content, size: 360.0), + SizedBox(height: 36), + IconButton( + icon: Icon(Icons.close), + onPressed: () => Navigator.pop(ctx), + ) + ], + ), + ), + ), + ), + ); + } +} diff --git a/demo_watch/lib/shared/widgets/paged_qr_image.dart b/demo_watch/lib/shared/widgets/paged_qr_image.dart new file mode 100644 index 0000000..ad905ba --- /dev/null +++ b/demo_watch/lib/shared/widgets/paged_qr_image.dart @@ -0,0 +1,99 @@ +import 'package:flutter/material.dart'; +import 'package:qr_flutter/qr_flutter.dart'; + +import '../const.dart'; + +class PagedQrImage extends StatefulWidget { + final String data; + + const PagedQrImage({Key key, this.data}) : super(key: key); + + @override + _PagedQrImageState createState() => _PagedQrImageState(); +} + +class _PagedQrImageState extends State { + int currentIndex = 0; + int p; + List parts = []; + + @override + void initState() { + super.initState(); + if (widget.data.length < 850) { + return; + } + const perPart = 845; + p = (widget.data.length / perPart).ceil(); + parts = []; + for (int i = 0; i < p; i++) { + int end = (i + 1) * perPart; + if (end > widget.data.length) { + end = widget.data.length; + } + // part/1-2/... + parts.add('$PATH_PART$i-$p/' + widget.data.substring(i * perPart, end)); + } + } + + void actionChangeIndex(int idx) { + setState(() { + currentIndex = idx; + }); + } + + @override + Widget build(BuildContext context) { + if (widget.data.length < 100) { + return QrImage(version: 5, data: widget.data); + } + + if (widget.data.length < 200) { + return QrImage(version: 9, data: widget.data); + } + + if (widget.data.length < 500) { + return QrImage(version: 9, data: widget.data); + } + + if (widget.data.length < 850) { + return QrImage(version: 20, data: widget.data); + } + + // 858 + + return Container( + // color: Colors.grey, + child: ConstrainedBox( + constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.width + 72), + child: Column( + children: [ + QrImage(version: 20, data: parts[currentIndex]), + Text('part: ${currentIndex + 1} - $p (len:${parts[currentIndex].length})', style: TextStyle(fontSize: 20)), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RaisedButton( + child: Text('上一页'), + onPressed: currentIndex == 0 + ? null + : () { + actionChangeIndex(currentIndex - 1); + }), + Text('当前第 ${currentIndex + 1} - ${parts.length} 页'), + RaisedButton( + child: Text('下一页'), + onPressed: (currentIndex == parts.length - 1) + ? null + : () { + actionChangeIndex(currentIndex + 1); + }, + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/demo_watch/lib/shared/widgets/paste_btn.dart b/demo_watch/lib/shared/widgets/paste_btn.dart new file mode 100644 index 0000000..0c7dffa --- /dev/null +++ b/demo_watch/lib/shared/widgets/paste_btn.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class PasteBtn extends StatelessWidget { + final Function(String) callback; + + const PasteBtn({Key key, @required this.callback}) : super(key: key); + @override + Widget build(BuildContext context) { + return IconButton( + icon: Icon(Icons.content_copy), + onPressed: () async { + String ret = (await Clipboard.getData('text/plain')).text; + callback(ret); + }, + ); + } +} diff --git a/demo_watch/lib/shared/widgets/paste_or_scan.dart b/demo_watch/lib/shared/widgets/paste_or_scan.dart new file mode 100644 index 0000000..cf73a34 --- /dev/null +++ b/demo_watch/lib/shared/widgets/paste_or_scan.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import '../assets.dart'; +import 'action_import_data.dart'; + +class PasteOrScan extends StatelessWidget { + final Function(String) callback; + + const PasteOrScan({Key key, this.callback}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + width: 120, + child: Row( + children: [ + IconButton( + icon: Icon(Icons.content_copy), + onPressed: () async { + String ret = (await Clipboard.getData('text/plain')).text; + callback(ret); + }, + ), + IconButton( + icon: ImageIcon(AssetImage(ASSETS_SCAN_QR)), + onPressed: () async { + String ret = await scanQRCode(); + callback(ret); + }, + ) + ], + ), + ); + } +} diff --git a/demo_watch/lib/shared/widgets/snack_info_copied.dart b/demo_watch/lib/shared/widgets/snack_info_copied.dart new file mode 100644 index 0000000..9478cea --- /dev/null +++ b/demo_watch/lib/shared/widgets/snack_info_copied.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class SnackInfoCopied extends StatelessWidget { + final String text; + + SnackInfoCopied(this.text); + @override + Widget build(BuildContext context) { + String txt = text; + if (txt.length > 200) { + txt = text.substring(0, 200) + "..."; + } + return Row( + children: [ + Text('copied:', style: TextStyle(color: Colors.lightBlue)), + Expanded(child: Text(txt)), + ], + ); + } +} diff --git a/demo_watch/lib/shared/widgets/split_line_text.dart b/demo_watch/lib/shared/widgets/split_line_text.dart new file mode 100644 index 0000000..1c82034 --- /dev/null +++ b/demo_watch/lib/shared/widgets/split_line_text.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +/// 多行文本 +class SplitLineText extends StatelessWidget { + final String text; + + SplitLineText(this.text); + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: text.split('\n').map((txt) => Text(txt)).toList(growable: false), + ); + } +} diff --git a/demo_watch/lib/store_keys.dart b/demo_watch/lib/store_keys.dart new file mode 100644 index 0000000..af4874f --- /dev/null +++ b/demo_watch/lib/store_keys.dart @@ -0,0 +1 @@ +const KEY_MULTISIG_ADDRS = 'multisig_addrs'; diff --git a/demo_watch/lib/ui/addr_detail.dart b/demo_watch/lib/ui/addr_detail.dart new file mode 100644 index 0000000..d0c614e --- /dev/null +++ b/demo_watch/lib/ui/addr_detail.dart @@ -0,0 +1,133 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; +import 'package:demo_watch/models/addr.dart'; +import 'package:demo_watch/rpc/eth_rpc.dart'; +import 'package:demo_watch/shared/widgets/copy_btn.dart'; + +import 'request_create_multisig.dart'; +import 'request_transfer.dart'; + +class AddrDetail extends StatefulWidget { + static const routeName = "addrs/detail"; + final AddrInfo addrInfo; + + const AddrDetail({Key key, this.addrInfo}) : super(key: key); + + @override + _AddrDetailState createState() => _AddrDetailState(); +} + +class _AddrDetailState extends State { + final GlobalKey _scaffoldKey = GlobalKey(); + int balance = -1; + double balanceETH = -1; + bool balanceInited = false; + + String message; + + void fetchBalance() async { + setState(() { + message = '读取余额'; + }); + String ret = await EthRpc.getBalance(widget.addrInfo.addr, null); + message = null; + if (!mounted) { + return; + } + setState(() { + balance = int.parse(ret.substring(2), radix: 16); + balanceETH = balance / 1000000000000000000; + balanceInited = true; + }); + } + + @override + void initState() { + super.initState(); + scheduleMicrotask(fetchBalance); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + appBar: AppBar(title: Text('地址详情')), + body: ListView( + children: [ + if (message != null) Column(children: [LinearProgressIndicator(), Text(message)]), + Row(children: [ + Expanded(child: Text('地址:${widget.addrInfo.addr}')), + CopyBtn(content: widget.addrInfo.addr), + ]), + if (widget.addrInfo.isMultisig) Text('多签合约地址', style: TextStyle(color: Colors.blueAccent)), + Text('余额:$balance(wei)'), + Text('余额:$balanceETH(ETH)'), + SizedBox(height: 20), + RaisedButton( + child: Text(widget.addrInfo.isMultisig ?? false ? '发起多签转账' : '发起转账'), + onPressed: !balanceInited + ? null + : () { + Navigator.of(context).push(MaterialPageRoute( + builder: (ctx) => RequestTransfer( + currentBalanceETH: balanceETH, + addr: widget.addrInfo, + ))); + }), + if (!widget.addrInfo.isMultisig) + RaisedButton( + child: Text('创建多签合约'), + onPressed: () { + Navigator.of(context) + .push(MaterialPageRoute(builder: (_) => CreqteMultisigContract(addr0: widget.addrInfo.addr))); + }), + SizedBox(height: 80), + RaisedButton( + child: Text('链接:ETH ropsten 水龙头'), + onPressed: () { + Clipboard.setData(ClipboardData(text: widget.addrInfo.addr)); + _scaffoldKey.currentState + .showSnackBar(SnackBar(content: Text('地址已复制,该通知关闭时打开浏览器,下扫可快速关闭通知'))) + .closed + .then((_) { + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => WebviewScaffold( + url: "https://faucet.ropsten.be/", + appBar: new AppBar(title: new Text("ETH ropsten水龙头")), + )), + ); + }); + }), + RaisedButton( + child: Text('链接:ETH ropsten 浏览器上查看地址'), + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => WebviewScaffold( + url: "https://ropsten.etherscan.io/address/${widget.addrInfo.addr}", + appBar: new AppBar(title: new Text("ETH ropsten区块浏览器,addr:${widget.addrInfo.addr}")), + )), + ); + }, + ), + Text('测试完成后,请把不用的测试ETH返还给水龙头,可发起一笔交易向下述地址转账'), + RaisedButton( + child: Text('复制水龙头地址'), + onPressed: () { + Clipboard.setData(ClipboardData(text: '0x687422eea2cb73b5d3e242ba5456b782919afc85')); + _scaffoldKey.currentState + .showSnackBar(SnackBar(content: Text('已复制(0x687422eea2cb73b5d3e242ba5456b782919afc85)'))); + }), + ], + ), + floatingActionButton: FloatingActionButton( + child: Icon(Icons.refresh), + onPressed: fetchBalance, + ), + ); + } +} diff --git a/demo_watch/lib/ui/addr_list.dart b/demo_watch/lib/ui/addr_list.dart new file mode 100644 index 0000000..8ab0492 --- /dev/null +++ b/demo_watch/lib/ui/addr_list.dart @@ -0,0 +1,137 @@ +import 'dart:async'; + +import 'package:demo_watch/shared/req_sign_content.dart'; +import 'package:demo_watch/ui/broadcast_result.dart'; +import 'package:flutter/material.dart'; +import 'package:oktoast/oktoast.dart'; +import 'package:demo_watch/repo/addrs.dart'; +import 'package:demo_watch/shared/const.dart'; +import 'package:demo_watch/models/addr.dart'; +import 'package:demo_watch/shared/widgets/action_import_data.dart'; +import 'addr_detail.dart'; + +class AddrList extends StatefulWidget { + static const routeName = "/addrlist"; + + @override + _AddrListState createState() => _AddrListState(); +} + +class _AddrListState extends State { + final GlobalKey _scaffoldKey = GlobalKey(); + + List addrs = []; + + void loadAddrs() async { + var ret = await AddrRepo.loadAll(); + setState(() { + addrs = ret; + }); + } + + void actionImportAddr() async { + String addr = await readImportData(_scaffoldKey.currentContext); + if (addr == null) { + return; + } + if (!addr.startsWith(PATH_ADDR)) { + _scaffoldKey.currentState.showSnackBar(SnackBar( + content: Text('Err:地址没有以$PATH_ADDR 开头 -> $addr'), + )); + return; + } + + String a = addr.substring(PATH_ADDR.length); + if (addrs.any((ad) => ad.addr == a)) { + showToast('已经导入的地址'); + return; + } + var ret = await AddrRepo.add(AddrInfo() + ..addr = a + ..isMultisig = false); + setState(() { + addrs = ret; + }); + } + + @override + void initState() { + super.initState(); + scheduleMicrotask(loadAddrs); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + appBar: AppBar(title: Text('地址列表')), + body: ListView( + children: [ + for (var addr in addrs.where((add) => add.addr != null)) //已有地址的 + ListTile( + title: Text(addr.addr), + subtitle: addr.isMultisig ? Text('多签', style: TextStyle(color: Colors.blue)) : Text('地址'), + trailing: Icon(Icons.arrow_forward), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + settings: RouteSettings(name: AddrDetail.routeName), + builder: (context) => AddrDetail(addrInfo: addr)), + ).then((_) { + loadAddrs(); + }); + // _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('to detail'))); + }, + ), + for (var addr in addrs.where((add) => add.addr == null && add.pendingTxid != null)) + ListTile( + title: Text('pending 的创建多签地址交易,尚无地址', style: TextStyle(color: Colors.deepOrangeAccent)), + subtitle: Text('txid:' + addr.pendingTxid), + trailing: Icon(Icons.arrow_forward), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => BroadcastResult( + reqSign: ReqSignContentCreateMultisigContract() + ..sigRequired = addr.sigRequired + ..addrs = addr.memberAddrs, + txid: addr.pendingTxid, + )), + ).then((_) { + loadAddrs(); + }); + }, + ), + RaisedButton(child: Text('导入观察地址'), onPressed: actionImportAddr), + RaisedButton( + child: Text('全部清除'), + onPressed: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('确定清除?'), + content: Text('注意多签地址清除后不可恢复,虽然是测试环境,还是把币转出后再清除!'), + actions: [ + FlatButton( + child: Text('清除'), + onPressed: () async { + await AddrRepo.clear(); + Navigator.pop(ctx); + loadAddrs(); + }), + FlatButton(child: Text('不清除'), onPressed: () => Navigator.pop(ctx)), + ], + )); + }, + ), + ], + ), + floatingActionButton: FloatingActionButton( + child: Icon(Icons.refresh), + onPressed: loadAddrs, + ), + ); + } +} diff --git a/demo_watch/lib/ui/broadcast_result.dart b/demo_watch/lib/ui/broadcast_result.dart new file mode 100644 index 0000000..aac5816 --- /dev/null +++ b/demo_watch/lib/ui/broadcast_result.dart @@ -0,0 +1,129 @@ +import 'dart:convert'; + +import 'package:demo_watch/models/addr.dart'; +import 'package:demo_watch/repo/addrs.dart'; +import 'package:demo_watch/rpc/eth_rpc.dart'; +import 'package:demo_watch/shared/req_sign_content.dart'; +import 'package:demo_watch/shared/widgets/copy_btn.dart'; +import 'package:demo_watch/shared/widgets/split_line_text.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; +import 'package:oktoast/oktoast.dart'; + +import 'addr_list.dart'; + +class BroadcastResult extends StatefulWidget { + final ReqSignContent reqSign; + final String txid; + + const BroadcastResult({Key key, @required this.reqSign, this.txid}) : super(key: key); + @override + _BroadcastResultState createState() => _BroadcastResultState(); +} + +class _BroadcastResultState extends State { + String loadingMessage; + String contractAddress; + + void actionFetchCreatedContractAddress() async { + setState(() { + loadingMessage = '读取交易'; + }); + var m = await EthRpc.getTransactionReceipt(widget.txid); + setState(() { + loadingMessage = null; + }); + if (m == null) { + showToast('没有读取到交易数据,可能还在pending中,去浏览器看看吧', duration: Duration(seconds: 8)); + return; + } + var addr = m['contractAddress']; + if (addr == null) { + throw '空的合约地址:' + jsonEncode(m); + } + print('----contact addr:$addr'); + setState(() { + contractAddress = addr; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('交易已广播')), + body: ListView( + children: [ + if (loadingMessage != null) Column(children: [LinearProgressIndicator(), Text(loadingMessage)]), + Center(child: Text(widget.reqSign.title())), + SplitLineText(widget.reqSign.info()), + Row(children: [ + Expanded(child: Text('txid:${widget.txid}')), + CopyBtn(content: widget.txid), + RaisedButton( + child: Text('浏览交易'), + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => WebviewScaffold( + url: "https://ropsten.etherscan.io/tx/${widget.txid}", + appBar: new AppBar(title: new Text("浏览交易")), + ), + ), + ); + }, + ) + ]), + if (widget.reqSign is ReqSignContentCreateMultisigContract && contractAddress == null) ...[ + Row(children: [ + RaisedButton(child: Text('读取合约地址'), onPressed: actionFetchCreatedContractAddress), + Text('(确保交易成功后读取,读取后存下来:-)'), + ]), + RaisedButton( + child: Text('暂存交易id,稍后从地址列表页读取'), + onPressed: () async { + ReqSignContentCreateMultisigContract reqCreate = widget.reqSign; + await AddrRepo.add(AddrInfo() + ..isMultisig = true + ..pendingTxid = widget.txid + ..sigRequired = reqCreate.sigRequired + ..memberAddrs = reqCreate.addrs); + showToast('保存成功,可以在列表页找到', backgroundColor: Colors.lightBlue); + Navigator.of(context).popUntil((r) => r.settings.name == AddrList.routeName); + }, + ) + ], + if (contractAddress != null && widget.reqSign is ReqSignContentCreateMultisigContract) + Row(children: [ + Expanded(child: Text('合约地址:$contractAddress')), + RaisedButton( + child: Text('浏览地址'), + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => WebviewScaffold( + url: "https://ropsten.etherscan.io/address/$contractAddress", + appBar: new AppBar(title: new Text("浏览地址")), + ), + ), + ); + }, + ), + RaisedButton( + child: Text('保存地址'), + onPressed: () async { + ReqSignContentCreateMultisigContract reqCreate = widget.reqSign; + AddrRepo.add(AddrInfo() + ..pendingTxid = widget.txid + ..addr = contractAddress + ..isMultisig = true + ..sigRequired = reqCreate.sigRequired + ..memberAddrs = reqCreate.addrs); + showToast('保存成功', backgroundColor: Colors.lightBlue); + }, + ) + ]) + ], + ), + ); + } +} diff --git a/demo_watch/lib/ui/gather_multisig.dart b/demo_watch/lib/ui/gather_multisig.dart new file mode 100644 index 0000000..ea93fcd --- /dev/null +++ b/demo_watch/lib/ui/gather_multisig.dart @@ -0,0 +1,134 @@ +// 收集多签签名页面 + +import 'dart:typed_data'; + +import 'package:demo_watch/shared/const.dart'; +import 'package:demo_watch/shared/widgets/copy_btn.dart'; +import 'package:demo_watch/shared/widgets/paste_or_scan.dart'; +import 'package:flutter/material.dart'; +import 'package:oktoast/oktoast.dart'; +import 'package:demo_watch/models/addr.dart'; +import 'package:demo_watch/rpc/eth_rpc.dart'; +import 'package:demo_watch/sdk/sdk_wrapper.dart'; +import 'package:demo_watch/shared/req_sign_content.dart'; +import 'package:demo_watch/shared/widgets/split_line_text.dart'; +import 'package:demo_watch/ui/request_sign.dart'; + +class GatherMultisigSigPage extends StatefulWidget { + final ReqSignContent content; + final AddrInfo addr; + + const GatherMultisigSigPage({Key key, this.content, this.addr}) : super(key: key); + + @override + _GatherMultisigSigPageState createState() => _GatherMultisigSigPageState(); +} + +class _GatherMultisigSigPageState extends State { + // List sigs; + List ctrls; + String loadingMessage; + + @override + void initState() { + super.initState(); + // sigs = List.generate(widget.addr.sigRequired, (_) => null); + ctrls = List.generate(widget.addr.sigRequired, (_) => TextEditingController()); + } + + void actionBuildData2sign() async { + List sigs = ctrls.map((c) => c.text).toList(); + if (sigs.any((v) => v == null)) { + showToast('收集签名数尚未达成', backgroundColor: Colors.redAccent); + return; + } + + setState(() { + loadingMessage = '获取nonce,gasPrice,gasLimit'; + }); + ReqSignContentMultisigExecute exec = widget.content; + var nonceGaspriceGaslimit = await EthRpc.getNonceGaspriceGaslimit(exec.exectorAddress); + if (!mounted) { + return; + } + setState(() { + loadingMessage = null; + }); + var nonce = nonceGaspriceGaslimit[0]; + var gasPrice = nonceGaspriceGaslimit[1]; + var gasLimit = nonceGaspriceGaslimit[2]; + sigs.sort(); + + double amountInWei = exec.amount * ETH18; + Uint8List packedExecuteData = await SdkWrapper.simpleMultisigPackedExecute( + toAddress: exec.toAddress, + amount: amountInWei, + data: null, + gasLimit: gasLimit, + executor: exec.exectorAddress, + sortedSigs: sigs.map((addrSig) => addrSig.split(',')[1]).toList(growable: false), + ); + + var reqSign = ReqSignContentETHTransfer() + ..nonce = nonce + ..toAddress = widget.addr.addr //合约地址 + ..amount = 0 + ..gasLimit = gasLimit + ..gasPrice = gasPrice + ..data = packedExecuteData; + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => RequestSignPage( + content: reqSign, + addr: widget.addr, + ))); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('收集签名')), + body: ListView( + children: [ + if (loadingMessage != null) Column(children: [LinearProgressIndicator(), Text(loadingMessage)]), + Text(widget.content.title()), + SplitLineText(widget.content.info()), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('原始数据:'), + Expanded( + child: ConstrainedBox( + constraints: BoxConstraints(maxHeight: 160), + child: Scrollbar( + child: SingleChildScrollView( + child: Text(widget.content.encode()), + ), + ), + ), + ), + CopyBtn(content: urlWithAppSchema(PATH_REQ_SIGN_CONTENT + widget.content.encode())), + ], + ), + Text('需要的签名数:${widget.addr.sigRequired}'), + ...List.generate( + widget.addr.sigRequired, + (int idx) => Row( + children: [ + Expanded( + child: TextField( + maxLines: 3, + controller: ctrls[idx], + decoration: InputDecoration(labelText: '签名${idx + 1}'), + ), + ), + PasteOrScan(callback: (v) => ctrls[idx].text = v), + ], + ), + ), + SizedBox(height: 24), + RaisedButton(child: Text('构造将要广播的待签名交易'), onPressed: actionBuildData2sign), + ], + ), + ); + } +} diff --git a/demo_watch/lib/ui/index.dart b/demo_watch/lib/ui/index.dart new file mode 100644 index 0000000..3123d5a --- /dev/null +++ b/demo_watch/lib/ui/index.dart @@ -0,0 +1,69 @@ +import 'package:demo_watch/repo/repo.dart'; +import 'package:demo_watch/rpc/eth_rpc.dart'; +import 'package:demo_watch/sdk/sdk_wrapper.dart'; +import 'package:demo_watch/shared/widgets/paste_btn.dart'; +import 'package:flutter/material.dart'; +import 'package:oktoast/oktoast.dart'; + +import 'addr_list.dart'; + +class IndexPage extends StatefulWidget { + static const String routeName = "/"; + @override + _IndexPageState createState() => _IndexPageState(); +} + +class _IndexPageState extends State { + final TextEditingController rpcCtl = TextEditingController(); + + String sdkBuildTime = ''; + + @override + void initState() { + super.initState(); + Repo.getRPCUrl().then((url) { + rpcCtl.text = url; + EthRpc.rpcUrl = url; + }); + SdkWrapper.buildTime().then((v) { + setState(() { + sdkBuildTime = v ?? ''; + }); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row(children: [ + Expanded( + child: TextField( + decoration: InputDecoration(labelText: 'rpcUrl'), + controller: rpcCtl, + ), + ), + PasteBtn(callback: (v) => rpcCtl.text = v), + ]), + SizedBox(height: 12), + RaisedButton( + child: Text('设置rpcurl'), + onPressed: () async { + await Repo.setRPCUrl(rpcCtl.text); + EthRpc.rpcUrl = rpcCtl.text; + showToast('done'); + }, + ), + SizedBox(height: 24), + RaisedButton( + child: Text('进入地址列表页'), + onPressed: () => Navigator.of(context).pushReplacementNamed(AddrList.routeName), + ), + Text('SDK build at:' + sdkBuildTime ?? ''), + ], + ), + ); + } +} diff --git a/demo_watch/lib/ui/request_broadcast.dart b/demo_watch/lib/ui/request_broadcast.dart new file mode 100644 index 0000000..f596861 --- /dev/null +++ b/demo_watch/lib/ui/request_broadcast.dart @@ -0,0 +1,57 @@ +// 请求广播交易页面 +import 'package:demo_watch/ui/broadcast_result.dart'; +import 'package:flutter/material.dart'; +import 'package:oktoast/oktoast.dart'; +import 'package:demo_watch/rpc/eth_rpc.dart'; +import 'package:demo_watch/shared/req_sign_content.dart'; +import 'package:demo_watch/shared/widgets/split_line_text.dart'; + +class RequestBroadcastPage extends StatefulWidget { + final String rawSignedData; + final ReqSignContent reqSign; + + const RequestBroadcastPage({Key key, this.rawSignedData, this.reqSign}) : super(key: key); + @override + _RequestBroadcastPageState createState() => _RequestBroadcastPageState(); +} + +class _RequestBroadcastPageState extends State { + String loadingMessage; + + void actionBroadcastTx(BuildContext ctx) async { + setState(() { + loadingMessage = '广播交易中'; + }); + String txid = await EthRpc.sendRawTransaction(widget.rawSignedData); + setState(() { + loadingMessage = null; + }); + showToast('交易已广播'); + Navigator.of(ctx).push(MaterialPageRoute( + builder: (c) => BroadcastResult(reqSign: widget.reqSign, txid: txid), + )); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('已签名交易')), + body: ListView(children: [ + if (loadingMessage != null) Column(children: [LinearProgressIndicator(), Text(loadingMessage)]), + Center(child: Text(widget.reqSign.title())), + SplitLineText(widget.reqSign.info()), + Text('已签名的原始交易(Length:${widget.rawSignedData.length}):'), + ConstrainedBox( + constraints: BoxConstraints(maxHeight: 180), + child: Scrollbar(child: SingleChildScrollView(child: Text(widget.rawSignedData))), + ), + SizedBox(height: 24), + RaisedButton( + child: Text('广播交易'), + onPressed: () => actionBroadcastTx(context), + ), + SizedBox(height: 36), + ]), + ); + } +} diff --git a/demo_watch/lib/ui/request_create_multisig.dart b/demo_watch/lib/ui/request_create_multisig.dart new file mode 100644 index 0000000..8629441 --- /dev/null +++ b/demo_watch/lib/ui/request_create_multisig.dart @@ -0,0 +1,139 @@ +// 创建多签合约页面 +import 'package:demo_watch/shared/utl.dart'; +import 'package:demo_watch/shared/widgets/paste_or_scan.dart'; +import 'package:flutter/material.dart'; +import 'package:demo_watch/rpc/eth_rpc.dart'; +import 'package:demo_watch/shared/const.dart'; +import 'package:demo_watch/shared/req_sign_content.dart'; +import 'package:oktoast/oktoast.dart'; + +import 'request_sign.dart'; + +class CreqteMultisigContract extends StatefulWidget { + final String addr0; + + const CreqteMultisigContract({Key key, this.addr0}) : super(key: key); + + @override + _CreqteMultisigContractState createState() => _CreqteMultisigContractState(); +} + +class _CreqteMultisigContractState extends State { + final GlobalKey _scaffoldKey = GlobalKey(); + final TextEditingController addr0Ctrl = TextEditingController(); + final TextEditingController addr1Ctrl = TextEditingController(); + + int sigNumber = 1; + String addr1; + + String message; + + @override + void initState() { + super.initState(); + addr0Ctrl.text = widget.addr0; + } + + void setAnotherAddr(String addr) { + print(addr); + if (addr?.isEmpty ?? true) { + showToast('空地址', duration: Duration(seconds: 3)); + return; + } + trimLeftUrlSchema(addr); + setState(() { + addr1 = utlTrimLeft(addr, PATH_ADDR); + addr1Ctrl.text = addr1; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + appBar: AppBar(title: Text('创建简单多签合约')), + body: ListView(children: [ + if (message != null) Column(children: [LinearProgressIndicator(), Text(message)]), + Text('签名人数', style: TextStyle(fontSize: 24)), + Row(children: [ + Text('1'), + Radio( + value: 1, + groupValue: sigNumber, + onChanged: (i) { + setState(() { + sigNumber = 1; + }); + }, + ), + Text('2'), + Radio( + value: 2, + groupValue: sigNumber, + onChanged: (i) { + setState(() { + print(i); + sigNumber = 2; + }); + }, + ), + ]), + TextField( + controller: addr0Ctrl, + readOnly: true, + decoration: InputDecoration( + labelText: '地址1', + ), + ), + Row(children: [ + Expanded( + child: TextField( + controller: addr1Ctrl, + decoration: InputDecoration( + labelText: '地址2', + ), + onChanged: (v) { + setState(() { + addr1 = v; + }); + }, + ), + ), + PasteOrScan(callback: (v) => setAnotherAddr(v)), + ]), + SizedBox(height: 16), + RaisedButton( + child: Text('生成创建合约交易待签名数据'), + onPressed: () async { + if (addr1 == null || addr1.isEmpty) { + _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('地址2为空'))); + return; + } + setState(() { + message = '读取nonce,gasPrice,gasLimit'; + }); + var nonceGaspriceGaslimit = await EthRpc.getNonceGaspriceGaslimit(widget.addr0); + var nonce = nonceGaspriceGaslimit[0]; + var gasPrice = nonceGaspriceGaslimit[1]; + var gasLimit = nonceGaspriceGaslimit[2]; + if (!mounted) { + return; + } + setState(() { + message = null; + }); + + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => RequestSignPage( + content: ReqSignContentCreateMultisigContract() + ..nonce = nonce + ..gasPrice = gasPrice + ..gasLimit = gasLimit + ..sigRequired = sigNumber + ..addrs = [widget.addr0, addr1]))); + }, + ) + ]), + ); + } +} diff --git a/demo_watch/lib/ui/request_sign.dart b/demo_watch/lib/ui/request_sign.dart new file mode 100644 index 0000000..4b1aac6 --- /dev/null +++ b/demo_watch/lib/ui/request_sign.dart @@ -0,0 +1,117 @@ +// 请求签名页面 + +import 'package:demo_watch/shared/widgets/action_import_data.dart'; +import 'package:demo_watch/shared/widgets/paged_qr_image.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:demo_watch/models/addr.dart'; +import 'package:demo_watch/shared/const.dart'; +import 'package:demo_watch/shared/req_sign_content.dart'; +import 'package:demo_watch/shared/widgets/copy_btn.dart'; +import 'package:demo_watch/shared/widgets/split_line_text.dart'; + +import 'gather_multisig.dart'; +import 'request_broadcast.dart'; + +class RequestSignPage extends StatefulWidget { + final ReqSignContent content; + final AddrInfo addr; + + const RequestSignPage({Key key, this.content, this.addr}) : super(key: key); + + @override + _RequestSignPageState createState() => _RequestSignPageState(); +} + +class _RequestSignPageState extends State { + final GlobalKey _scaffoldKey = GlobalKey(); + + void parseSignedData(String data) { + data = trimLeftUrlSchema(data); + if (!data.startsWith(PATH_SIGNED)) { + _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('err:无法识别的签名数据'))); + return; + } + String rawSigned = data.substring(PATH_SIGNED.length); + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => RequestBroadcastPage( + rawSignedData: rawSigned, + reqSign: widget.content, + ))); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + appBar: AppBar(title: Text('待签名数据')), + body: ListView( + children: [ + Center(child: Text(widget.content.title(), style: TextStyle(fontSize: 22))), + SplitLineText(widget.content.info()), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('原始数据:'), + Expanded( + child: ConstrainedBox( + constraints: BoxConstraints(maxHeight: 160), + child: Scrollbar( + child: SingleChildScrollView( + child: Text(widget.content.encode()), + ), + ), + ), + ), + CopyBtn(content: urlWithAppSchema(PATH_REQ_SIGN_CONTENT + widget.content.encode())), + ], + ), + SizedBox(height: 24), + Text('请用持有私钥的钱包签名'), + PagedQrImage(data: urlWithAppSchema(PATH_REQ_SIGN_CONTENT + widget.content.encode())), + SizedBox(height: 70), + ], + ), + bottomNavigationBar: BottomAppBar( + elevation: 12, + child: Container( + height: 48, + decoration: BoxDecoration(border: Border(top: BorderSide(width: 1, color: Colors.grey))), + padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 8.0), + child: (widget.content is ReqSignContentMultisigExecute) + ? RaisedButton( + child: Text('收集成员签名'), + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => GatherMultisigSigPage( + content: widget.content, + addr: widget.addr, + ), + )); + }, + ) + : Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + RaisedButton( + child: Text('扫码签名结果'), + onPressed: () async { + String data = await readImportData(context, source: FromCamera); + parseSignedData(data); + }, + ), + // Expanded(child: SizedBox(width: 1)), + RaisedButton( + child: Text('从剪切板读取签名结果'), + onPressed: () async { + String data = (await Clipboard.getData('text/plain')).text; + parseSignedData(data); + }, + ), + ], + ), + ), + ), + ); + } +} diff --git a/demo_watch/lib/ui/request_transfer.dart b/demo_watch/lib/ui/request_transfer.dart new file mode 100644 index 0000000..4ecd993 --- /dev/null +++ b/demo_watch/lib/ui/request_transfer.dart @@ -0,0 +1,155 @@ +import 'package:convert/convert.dart'; +import 'package:demo_watch/shared/const.dart'; +import 'package:demo_watch/shared/utl.dart'; +import 'package:demo_watch/shared/widgets/paste_or_scan.dart'; +import 'package:flutter/material.dart'; +import 'package:oktoast/oktoast.dart'; +import 'package:demo_watch/models/addr.dart'; +import 'package:demo_watch/rpc/eth_rpc.dart'; +import 'package:demo_watch/sdk/sdk_wrapper.dart'; +import 'package:demo_watch/shared/req_sign_content.dart'; + +import 'request_sign.dart'; + +class RequestTransfer extends StatefulWidget { + final double currentBalanceETH; + final AddrInfo addr; + + const RequestTransfer({Key key, this.currentBalanceETH, this.addr}) : super(key: key); + @override + _RequestTransferState createState() => _RequestTransferState(); +} + +class _RequestTransferState extends State { + final TextEditingController toAddrCtrl = TextEditingController(); + final TextEditingController amountCtrl = TextEditingController(); + String message; + + String broadcastAddress; //广播交易的地址,多签用 + + void actionChangeBroadcaster() { + for (int i = 0; i < widget.addr.memberAddrs.length * 2; i++) { + int idx = i % widget.addr.memberAddrs.length; + if (widget.addr.memberAddrs[idx] == broadcastAddress) { + int nextIdx = ((i + 1) % widget.addr.memberAddrs.length); + setState(() { + broadcastAddress = widget.addr.memberAddrs[nextIdx]; + }); + break; + } + } + } + + void setToAddr(String v) { + if (v == null) { + return; + } + v = trimLeftUrlSchema(v); + v = utlTrimLeft(v, PATH_ADDR); + setState(() { + toAddrCtrl.text = v; + }); + } + + void actionGenerateToSignData(BuildContext ctx) async { + String toAddress = toAddrCtrl.text; + double amount = double.tryParse(amountCtrl.text); + if (toAddress == null || amount == null) { + showToast('似乎转出地址或金额没有正确设置', backgroundColor: Colors.redAccent); + return; + } + if (toAddress.length < 40 || toAddress.length > 42) { + showToast('似乎不是合法地址', backgroundColor: Colors.redAccent); + return; + } + if (amount > widget.currentBalanceETH) { + showToast('转出金额超过了余额', backgroundColor: Colors.redAccent); + return; + } + setState(() { + message = '获取nonce,gasPrice,gasLimit'; + }); + var nonceGaspriceGaslimit = await EthRpc.getNonceGaspriceGaslimit(widget.addr.addr); + if (!mounted) { + return; + } + setState(() { + message = null; + }); + var nonce = nonceGaspriceGaslimit[0]; + var gasPrice = nonceGaspriceGaslimit[1]; + var gasLimit = nonceGaspriceGaslimit[2]; + ReqSignContent reqSign; + + if (!widget.addr.isMultisig) { + reqSign = ReqSignContentETHTransfer() + ..amount = amount + ..toAddress = toAddress + ..gasLimit = gasLimit + ..gasPrice = gasPrice + ..nonce = nonce; + } else { + setState(() { + message = '读取合约内部nonce'; + }); + var packedNonce = await SdkWrapper.simpleMultisigAbiPackedNonce(); + var internalNonceData = await EthRpc.call(widget.addr.addr, packedNonce); + var internalNonce = await SdkWrapper.simpleMultisigAbiUnpackedNonce(hex.decode(internalNonceData.substring(2))); + reqSign = ReqSignContentMultisigExecute() + ..multisigContractAddress = widget.addr.addr + ..toAddress = toAddress + ..internalNonce = internalNonce + ..amount = amount + ..exectorAddress = broadcastAddress + ..gasLimit = gasLimit; + setState(() { + message = null; + }); + } + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => RequestSignPage( + content: reqSign, + addr: widget.addr, + ))); + } + + @override + void initState() { + super.initState(); + if (widget.addr.isMultisig) { + broadcastAddress = widget.addr.memberAddrs[0]; + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('发起转账')), + body: ListView(children: [ + if (message != null) Column(children: [LinearProgressIndicator(), Text(message)]), + Center(child: Text('当前余额(ETH):${widget.currentBalanceETH}')), + SizedBox(height: 16), + Row(children: [ + Expanded(child: TextField(controller: toAddrCtrl, decoration: InputDecoration(labelText: '转出地址'))), + PasteOrScan(callback: setToAddr), + ]), + TextField( + controller: amountCtrl, + keyboardType: TextInputType.number, + decoration: InputDecoration(labelText: '转出金额(ETH)'), + ), + if (widget.addr.isMultisig) + Row(children: [ + Text('广播者:'), + Expanded(child: Text(broadcastAddress)), + RaisedButton(child: Text('更换'), onPressed: actionChangeBroadcaster), + ]), + SizedBox(height: 16), + RaisedButton( + child: Text('生成待签名数据'), + onPressed: () => actionGenerateToSignData(context), + ), + ]), + ); + } +} diff --git a/demo_watch/pubspec.lock b/demo_watch/pubspec.lock new file mode 100644 index 0000000..9f2facd --- /dev/null +++ b/demo_watch/pubspec.lock @@ -0,0 +1,579 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "0.36.4" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.2" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.5" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.6" + build_runner: + dependency: "direct dev" + description: + name: build_runner + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.5" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.7" + built_collection: + dependency: transitive + description: + name: built_collection + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.2" + built_value: + dependency: transitive + description: + name: built_value + url: "https://pub.dartlang.org" + source: hosted + version: "6.7.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + code_builder: + dependency: transitive + description: + name: code_builder + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.14.11" + convert: + dependency: "direct main" + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.6" + csslib: + dependency: transitive + description: + name: csslib + url: "https://pub.dartlang.org" + source: hosted + version: "0.16.1" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.9" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.9" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_webview_plugin: + dependency: "direct main" + description: + name: flutter_webview_plugin + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" + front_end: + dependency: transitive + description: + name: front_end + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.19" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.7" + graphs: + dependency: transitive + description: + name: graphs + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" + html: + dependency: transitive + description: + name: html + url: "https://pub.dartlang.org" + source: hosted + version: "0.14.0+2" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.0+2" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.3" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.8" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.3" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.1+1" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + json_rpc_2: + dependency: transitive + description: + name: json_rpc_2 + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + kernel: + dependency: transitive + description: + name: kernel + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.19" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "0.11.3+2" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.5" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.6" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.6+3" + multi_server_socket: + dependency: transitive + description: + name: multi_server_socket + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + node_preamble: + dependency: transitive + description: + name: node_preamble + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.6" + oktoast: + dependency: "direct main" + description: + name: oktoast + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + package_resolver: + dependency: transitive + description: + name: package_resolver + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.10" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.2" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.2" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" + qr: + dependency: transitive + description: + name: qr + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + qr_flutter: + dependency: "direct main" + description: + name: qr_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0+55" + qrcode_reader: + dependency: "direct main" + description: + name: qrcode_reader + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.4" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.3+4" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.5" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + shelf_static: + dependency: transitive + description: + name: shelf_static + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.8" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.3" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.4+3" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.5" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.8" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.5" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.3" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.19" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + test: + dependency: "direct dev" + description: + name: test + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.3" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.5" + test_core: + dependency: transitive + description: + name: test_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.5" + timing: + dependency: transitive + description: + name: timing + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.1+1" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.6" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" + vm_service_client: + dependency: transitive + description: + name: vm_service_client + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.6+3" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.7+12" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.14" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.16" +sdks: + dart: ">=2.3.0 <3.0.0" + flutter: ">=1.5.0 <2.0.0" diff --git a/demo_watch/pubspec.yaml b/demo_watch/pubspec.yaml new file mode 100644 index 0000000..a078a1f --- /dev/null +++ b/demo_watch/pubspec.yaml @@ -0,0 +1,85 @@ +name: demo_watch +description: A new Flutter project. + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.3.0 <3.0.0" + +dependencies: + flutter: + sdk: flutter + flutter_localizations: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^0.1.2 + json_annotation: ^2.0.0 + shared_preferences: ^0.5.3+4 + qr_flutter: ^2.1.0+55 + qrcode_reader: ^0.4.4 + flutter_webview_plugin: ^0.3.5 + oktoast: ^2.2.0 + convert: ^2.1.1 + +dev_dependencies: + test: ^1.5.3 + flutter_test: + sdk: flutter + build_runner: ^1.0.0 + json_serializable: ^2.0.0 + + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + assets: + - assets/qr_code.png + - assets/scan_qr.png + + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/demo_watch/test/lang_test.dart b/demo_watch/test/lang_test.dart new file mode 100644 index 0000000..03a77c1 --- /dev/null +++ b/demo_watch/test/lang_test.dart @@ -0,0 +1,33 @@ +import 'package:convert/convert.dart'; +import 'dart:typed_data'; +import 'dart:convert'; + +import 'package:test/test.dart'; + +void main() { + test('hex to int', () { + String s = "0x1d2296e2ff6a3c00"; + print(s.substring(2)); + int i = int.parse(s.substring(2), radix: 16); + print(i); + // expect(actual, matcher) + }); + + test('unint8list', () { + Uint8List list = Uint8List.fromList([1,2,3]); + var str = list.toString(); + print(str); + + + print('-----'); + String s = '0000000000000000000000000000000000000000000000000000000000000000'; + print(hex.decode(s)); + }); + + test('sort', () { + var l = ["cd", "6xx", "bcd"]; + print(l.sublist(2)); + }); + + +} \ No newline at end of file diff --git a/demo_watch/test/widget_test.dart b/demo_watch/test/widget_test.dart new file mode 100644 index 0000000..7cf9a1e --- /dev/null +++ b/demo_watch/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:demo_watch/main.dart'; + + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/prototype_draft/arch.png b/prototype_draft/arch.png new file mode 100644 index 0000000..614859b Binary files /dev/null and b/prototype_draft/arch.png differ diff --git "a/prototype_draft/demo_cold/1\345\234\260\345\235\200\345\210\227\350\241\250\351\241\265.png" "b/prototype_draft/demo_cold/1\345\234\260\345\235\200\345\210\227\350\241\250\351\241\265.png" new file mode 100644 index 0000000..48ab733 Binary files /dev/null and "b/prototype_draft/demo_cold/1\345\234\260\345\235\200\345\210\227\350\241\250\351\241\265.png" differ diff --git "a/prototype_draft/demo_cold/2\347\247\201\351\222\245\350\257\246\346\203\205.png" "b/prototype_draft/demo_cold/2\347\247\201\351\222\245\350\257\246\346\203\205.png" new file mode 100644 index 0000000..df9cd95 Binary files /dev/null and "b/prototype_draft/demo_cold/2\347\247\201\351\222\245\350\257\246\346\203\205.png" differ diff --git "a/prototype_draft/demo_cold/3\346\211\253\347\240\201\347\255\276\345\220\215.png" "b/prototype_draft/demo_cold/3\346\211\253\347\240\201\347\255\276\345\220\215.png" new file mode 100644 index 0000000..4445c39 Binary files /dev/null and "b/prototype_draft/demo_cold/3\346\211\253\347\240\201\347\255\276\345\220\215.png" differ diff --git "a/prototype_draft/demo_cold/4\347\255\276\345\220\215\347\273\223\346\236\234.png" "b/prototype_draft/demo_cold/4\347\255\276\345\220\215\347\273\223\346\236\234.png" new file mode 100644 index 0000000..cdacbfd Binary files /dev/null and "b/prototype_draft/demo_cold/4\347\255\276\345\220\215\347\273\223\346\236\234.png" differ diff --git "a/prototype_draft/demo_watch/1\350\247\202\345\257\237\345\234\260\345\235\200\345\210\227\350\241\250.png" "b/prototype_draft/demo_watch/1\350\247\202\345\257\237\345\234\260\345\235\200\345\210\227\350\241\250.png" new file mode 100644 index 0000000..e65226b Binary files /dev/null and "b/prototype_draft/demo_watch/1\350\247\202\345\257\237\345\234\260\345\235\200\345\210\227\350\241\250.png" differ diff --git "a/prototype_draft/demo_watch/2\345\234\260\345\235\200\350\257\246\346\203\205.png" "b/prototype_draft/demo_watch/2\345\234\260\345\235\200\350\257\246\346\203\205.png" new file mode 100644 index 0000000..2b7e674 Binary files /dev/null and "b/prototype_draft/demo_watch/2\345\234\260\345\235\200\350\257\246\346\203\205.png" differ diff --git "a/prototype_draft/demo_watch/2\350\247\202\345\257\237\345\234\260\345\235\200\345\267\262\345\257\274\345\205\245 copy.png" "b/prototype_draft/demo_watch/2\350\247\202\345\257\237\345\234\260\345\235\200\345\267\262\345\257\274\345\205\245 copy.png" new file mode 100644 index 0000000..eed85b2 Binary files /dev/null and "b/prototype_draft/demo_watch/2\350\247\202\345\257\237\345\234\260\345\235\200\345\267\262\345\257\274\345\205\245 copy.png" differ diff --git "a/prototype_draft/demo_watch/3\345\210\233\345\273\272\345\244\232\347\255\276\345\220\210\347\272\246.png" "b/prototype_draft/demo_watch/3\345\210\233\345\273\272\345\244\232\347\255\276\345\220\210\347\272\246.png" new file mode 100644 index 0000000..0cf0156 Binary files /dev/null and "b/prototype_draft/demo_watch/3\345\210\233\345\273\272\345\244\232\347\255\276\345\220\210\347\272\246.png" differ diff --git "a/prototype_draft/demo_watch/3\345\217\221\350\265\267\350\275\254\350\264\246.png" "b/prototype_draft/demo_watch/3\345\217\221\350\265\267\350\275\254\350\264\246.png" new file mode 100644 index 0000000..e31adab Binary files /dev/null and "b/prototype_draft/demo_watch/3\345\217\221\350\265\267\350\275\254\350\264\246.png" differ diff --git "a/prototype_draft/demo_watch/4.5\346\224\266\351\233\206\345\244\232\347\255\276\347\255\276\345\220\215\346\225\260\346\215\256.png" "b/prototype_draft/demo_watch/4.5\346\224\266\351\233\206\345\244\232\347\255\276\347\255\276\345\220\215\346\225\260\346\215\256.png" new file mode 100644 index 0000000..6707cd6 Binary files /dev/null and "b/prototype_draft/demo_watch/4.5\346\224\266\351\233\206\345\244\232\347\255\276\347\255\276\345\220\215\346\225\260\346\215\256.png" differ diff --git "a/prototype_draft/demo_watch/4\345\276\205\347\255\276\345\220\215\346\225\260\346\215\256.png" "b/prototype_draft/demo_watch/4\345\276\205\347\255\276\345\220\215\346\225\260\346\215\256.png" new file mode 100644 index 0000000..2664c57 Binary files /dev/null and "b/prototype_draft/demo_watch/4\345\276\205\347\255\276\345\220\215\346\225\260\346\215\256.png" differ diff --git "a/prototype_draft/demo_watch/5\347\255\276\345\220\215\347\273\223\346\236\234\345\261\225\347\244\272.png" "b/prototype_draft/demo_watch/5\347\255\276\345\220\215\347\273\223\346\236\234\345\261\225\347\244\272.png" new file mode 100644 index 0000000..0f24ecf Binary files /dev/null and "b/prototype_draft/demo_watch/5\347\255\276\345\220\215\347\273\223\346\236\234\345\261\225\347\244\272.png" differ diff --git "a/prototype_draft/demo_watch/6\344\272\244\346\230\223\345\267\262\345\271\277\346\222\255.png" "b/prototype_draft/demo_watch/6\344\272\244\346\230\223\345\267\262\345\271\277\346\222\255.png" new file mode 100644 index 0000000..2b61cb7 Binary files /dev/null and "b/prototype_draft/demo_watch/6\344\272\244\346\230\223\345\267\262\345\271\277\346\222\255.png" differ diff --git "a/prototype_draft/demo_watch/6\345\210\233\345\273\272\345\244\232\347\255\276:\344\272\244\346\230\223\345\267\262\345\271\277\346\222\255.png" "b/prototype_draft/demo_watch/6\345\210\233\345\273\272\345\244\232\347\255\276:\344\272\244\346\230\223\345\267\262\345\271\277\346\222\255.png" new file mode 100644 index 0000000..83ed01d Binary files /dev/null and "b/prototype_draft/demo_watch/6\345\210\233\345\273\272\345\244\232\347\255\276:\344\272\244\346\230\223\345\267\262\345\271\277\346\222\255.png" differ diff --git a/prototype_draft/multisig_flow.png b/prototype_draft/multisig_flow.png new file mode 100644 index 0000000..df83cd7 Binary files /dev/null and b/prototype_draft/multisig_flow.png differ diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..23e9f45 --- /dev/null +++ b/readme.md @@ -0,0 +1,91 @@ +# ETH 多签 + 冷钱包 demo + +基于Flutter + WalletCore.aar (后续开源源码)开发 + +暂时没有支持iOS,如果有需要的话可以提issue,我这边有空机会加上去。 + +## 目录说明 +- images 一些图片 +- prototype_draft 两个app的设计稿 +- demo_watch 观察钱包源代码 +- demo_cold 冷钱包源代码 + +## 演示录屏 +(上传中) + +## 试用 + +在release中下载apk,可以运行在一台安卓设备上(主要通过复制通信),也可以安装在2台设备上(通过扫码通信),体验完整功能流程如下: + +1. 生成2个私钥,对应地址为 A1,A2 +2. 将地址导入观察钱包,并查询余额 +3. 从水龙头请求一些资金到地址A1,等待水龙头到账 +4. A1有资金后可以创建多签合约 + - 收集地址(A1+A2),构造交易 + - 签名交易,(用A1签名广播,A2没有支付手续费的资金) + - 广播交易 + - 等待打包 + - 交易打包成功,读取多签合约地址,保存合约地址 + - 查询余额 + + +5. 从A1转出资金到多签地址 + - 创建交易 + - 冷钱包签名 + - 广播交易 + - 等待打包 + - 查询余额,验证交易成功 + +6. 从多签地址转出全部资金到A2 + - 构造需要签名的转账信息(指定A1来广播交易,A2没有支付手续费的资金) + - A1,A2 分别对转账信息进行签名 + - 收集成员签名(A1,A2),并构造需要广播的原始交易 + - A1 用冷钱包对原始交易进行签名 + - 观察钱包将交易进行广播 + - 等待打包 + - 打包成功,验证各地址余额 + +## 基本结构 +基于 `ropsten.infura.io` api,一个冷钱包,一个观察钱包 +![结构图](prototype_draft/arch.png) + +多签流程: + +![多签流程](prototype_draft/multisig_flow.png) + +## 开发人员运行app + +如果可以,最好替换掉 infura.io 的 api url,有每日限额。 + +首先将 `WalletCore.aar` 拷贝到 `demo_code/android/app/libs/` 和 `demo_watch/android/app/libs/`目录下 + +```bash +cp WalletCore.aar demo_cold/android/app/libs/ +cp WalletCore.aar demo_watch/android/app/libs/ + +#你需要确保本地flutter环境已安装 https://flutter.dev/docs/get-started/install + +cd demo_cold && flutter run +cd demo_watch && flutter run + +``` + +## app 打包 + +参见`demo_cold`和`demo_watch`的`Makefile` ==> `make buildApk` + +## ETH 多签合约 + +本demo中使用的多签合约 [`SimpleMultiSig.sol`](SimpleMultiSig.sol), 修改自 https://github.com/christianlundkvist/simple-multisig/blob/master/contracts/SimpleMultiSig.sol + +## 其他 + +由于开发人员的一些设备坏了,扫码没有充分测试,有问题请提issue + +有些私人数据,求忽略,求包含 + +## LICENCE + +引用的资源基于引用资源本身协议 + +该工程基于 [WTFPL](http://www.wtfpl.net) 协议,大概就是,爱干嘛干嘛