Skip to content

Commit

Permalink
Merge pull request #28 from vlmoon99/webassembly-beta
Browse files Browse the repository at this point in the history
Webassembly on web support
  • Loading branch information
vlmoon99 authored Nov 12, 2024
2 parents 497acc1 + fb9c8f4 commit e9137b9
Show file tree
Hide file tree
Showing 69 changed files with 2,030 additions and 607 deletions.
4 changes: 2 additions & 2 deletions assets/crypto-lib/dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/crypto-lib/dist/dop_bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -170382,7 +170382,7 @@ var BitcoinBlockchain = exports.BitcoinBlockchain = /*#__PURE__*/function () {
});
var input = TW.Bitcoin.Proto.SigningInput.create({
hashType: BitcoinScript.hashTypeForCoin(CoinType.bitcoin),
amount: transferAmount,
amount: BigInt(transferAmount),
byteFee: feeBayte,
toAddress: toAddress,
changeAddress: accountID,
Expand Down
2 changes: 1 addition & 1 deletion assets/crypto-lib/src/chains/btc_blockhain.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ bitcoinTransferAction(toAddress, accountID, transferAmount, privateKeyHex, publi

const input = TW.Bitcoin.Proto.SigningInput.create({
hashType: BitcoinScript.hashTypeForCoin(CoinType.bitcoin),
amount: transferAmount,
amount: BigInt(transferAmount),
byteFee: feeBayte,
toAddress: toAddress,
changeAddress: accountID,
Expand Down
2 changes: 1 addition & 1 deletion assets/crypto-lib/src/utils/kdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function uncompressedHexPointToXRPAddress(childPublicKey) {
return {address, childPublicKey};
}

export async function generateAddressForNearMPC(accountId, path, chain, publicMPCKey = MPC_PUBLIC_KEY, network = "testnet") {
export async function generateAddressForNearMPC(accountId, path, chain, network = "testnet", publicMPCKey = MPC_PUBLIC_KEY) {
let childPublicKey = await deriveChildPublicKey(
najPublicKeyStrToUncompressedHexPoint(publicMPCKey),
accountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutterchain/flutterchain_lib/constants/chains/near_blockchain_network_urls.dart';
import 'package:flutterchain/flutterchain_lib/models/chains/near/near_network_environment_settings.dart';
import 'package:flutterchain/flutterchain_lib/models/core/wallet.dart';
import 'package:flutterchain/flutterchain_lib/services/chains/bitcoin_blockchain_service.dart';
import 'package:flutterchain/flutterchain_lib/services/chains/near_blockchain_service.dart';
import 'package:flutterchain/flutterchain_lib/services/core/crypto_service.dart';
import 'package:flutterchain/flutterchain_lib/services/core/js_engines/core/js_engine_stub.dart'
if (dart.library.io) 'package:flutterchain/flutterchain_lib/services/core/js_engines/platforms_implementations/webview_js_engine.dart'
if (dart.library.js) 'package:flutterchain/flutterchain_lib/services/core/js_engines/platforms_implementations/web_js_engine.dart';

class NearAccountCreationActionDialog extends StatefulWidget {
const NearAccountCreationActionDialog({
Expand Down Expand Up @@ -57,7 +53,7 @@ class _NearAccountCreationActionDialogState
);

final flutterChainService = FlutterChainService(
jsVMService: getJsVM(),
// jsVMService: getJsVM(),
nearBlockchainService: nearBlockChainService,
);

Expand Down
91 changes: 50 additions & 41 deletions chain_signatures_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,18 @@ packages:
dependency: transitive
description:
name: flutter_inappwebview
sha256: "3e9a443a18ecef966fb930c3a76ca5ab6a7aafc0c7b5e14a4a850cf107b09959"
sha256: "80092d13d3e29b6227e25b67973c67c7210bd5e35c4b747ca908e31eb71a46d5"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
version: "6.1.5"
flutter_inappwebview_android:
dependency: transitive
description:
name: flutter_inappwebview_android
sha256: d247f6ed417f1f8c364612fa05a2ecba7f775c8d0c044c1d3b9ee33a6515c421
sha256: "62557c15a5c2db5d195cb3892aab74fcaec266d7b86d59a6f0027abd672cddba"
url: "https://pub.dev"
source: hosted
version: "1.0.13"
version: "1.1.3"
flutter_inappwebview_internal_annotations:
dependency: transitive
description:
Expand All @@ -306,34 +306,42 @@ packages:
dependency: transitive
description:
name: flutter_inappwebview_ios
sha256: f363577208b97b10b319cd0c428555cd8493e88b468019a8c5635a0e4312bd0f
sha256: "5818cf9b26cf0cbb0f62ff50772217d41ea8d3d9cc00279c45f8aabaa1b4025d"
url: "https://pub.dev"
source: hosted
version: "1.0.13"
version: "1.1.2"
flutter_inappwebview_macos:
dependency: transitive
description:
name: flutter_inappwebview_macos
sha256: b55b9e506c549ce88e26580351d2c71d54f4825901666bd6cfa4be9415bb2636
sha256: c1fbb86af1a3738e3541364d7d1866315ffb0468a1a77e34198c9be571287da1
url: "https://pub.dev"
source: hosted
version: "1.0.11"
version: "1.1.2"
flutter_inappwebview_platform_interface:
dependency: transitive
description:
name: flutter_inappwebview_platform_interface
sha256: "545fd4c25a07d2775f7d5af05a979b2cac4fbf79393b0a7f5d33ba39ba4f6187"
sha256: cf5323e194096b6ede7a1ca808c3e0a078e4b33cc3f6338977d75b4024ba2500
url: "https://pub.dev"
source: hosted
version: "1.0.10"
version: "1.3.0+1"
flutter_inappwebview_web:
dependency: transitive
description:
name: flutter_inappwebview_web
sha256: d8c680abfb6fec71609a700199635d38a744df0febd5544c5a020bd73de8ee07
sha256: "55f89c83b0a0d3b7893306b3bb545ba4770a4df018204917148ebb42dc14a598"
url: "https://pub.dev"
source: hosted
version: "1.1.2"
flutter_inappwebview_windows:
dependency: transitive
description:
name: flutter_inappwebview_windows
sha256: "8b4d3a46078a2cdc636c4a3d10d10f2a16882f6be607962dbfff8874d1642055"
url: "https://pub.dev"
source: hosted
version: "1.0.8"
version: "0.6.0"
flutter_launcher_icons:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -482,11 +490,12 @@ packages:
grpc:
dependency: transitive
description:
name: grpc
sha256: "5b99b7a420937d4361ece68b798c9af8e04b5bc128a7859f2a4be87427694813"
url: "https://pub.dev"
source: hosted
version: "4.0.1"
path: "."
ref: HEAD
resolved-ref: "3d9ee25fee6d398489816927ffe219408d778ae4"
url: "https://github.com/minoic/grpc-dart.git"
source: git
version: "4.0.2-wip"
hex:
dependency: transitive
description:
Expand All @@ -499,10 +508,10 @@ packages:
dependency: transitive
description:
name: http
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.2.2"
http2:
dependency: transitive
description:
Expand Down Expand Up @@ -579,18 +588,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.4"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -627,18 +636,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.15.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -904,10 +913,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.7.2"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -976,10 +985,10 @@ packages:
dependency: transitive
description:
name: url_launcher_web
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a"
sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.3"
url_launcher_windows:
dependency: transitive
description:
Expand Down Expand Up @@ -1032,10 +1041,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.1"
version: "14.2.5"
watcher:
dependency: transitive
description:
Expand All @@ -1048,26 +1057,26 @@ packages:
dependency: transitive
description:
name: web
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "1.1.0"
web_socket:
dependency: transitive
description:
name: web_socket
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83"
url: "https://pub.dev"
source: hosted
version: "0.1.5"
version: "0.1.6"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.0.1"
win32:
dependency: transitive
description:
Expand Down Expand Up @@ -1101,5 +1110,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
11 changes: 3 additions & 8 deletions chain_signatures_example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,10 @@
window.addEventListener("load", async function (ev) {
{{flutter_js}}
{{flutter_build_config}}

_flutter.loader.load({
serviceWorker: {
serviceWorkerVersion: '{{flutter_service_worker_version}}',
},
onEntrypointLoaded: function (engineInitializer) {
engineInitializer.initializeEngine().then(function (appRunner) {
appRunner.runApp();
});
serviceWorkerSettings: {
serviceWorkerVersion: {{flutter_service_worker_version}},
},
});
});
Expand Down
11 changes: 0 additions & 11 deletions example/lib/modules/app_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import 'package:flutterchain_example/modules/home/services/helper_service.dart';
import 'package:flutterchain_example/network/helper_network_client.dart';
import 'package:flutterchain_example/routes/routes.dart';
import 'package:flutterchain_example/theme/app_theme.dart';
import 'package:flutterchain/flutterchain_lib/services/core/js_engines/core/js_engine_stub.dart'
if (dart.library.io) 'package:flutterchain/flutterchain_lib/services/core/js_engines/platforms_implementations/webview_js_engine.dart'
if (dart.library.js) 'package:flutterchain/flutterchain_lib/services/core/js_engines/platforms_implementations/web_js_engine.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';

class AppModule extends Module {
Expand All @@ -33,10 +30,6 @@ class AppModule extends Module {
(i) => const FlutterSecureStorage(),
),

//Inject JS Engine
Bind.singleton(
(i) => getJsVM(),
),
//Inject Blockchain Code

//1. Near Blockchain
Expand All @@ -53,7 +46,6 @@ class AppModule extends Module {
),
Bind.singleton(
(i) => NearBlockChainService(
jsVMService: i(),
nearRpcClient: i(),
),
),
Expand Down Expand Up @@ -83,21 +75,18 @@ class AppModule extends Module {
),
Bind.singleton(
(i) => BitcoinBlockChainService(
jsVMService: i(),
bitcoinRpcClient: i(),
),
),
Bind.singleton(
(i) => ConcordiumBlockChainService(
jsVMService: i(),
concordiumRpcClient: ConcordiumRpcClient.defaultInstance(),
),
),

//Inject Main Services for Main File of Crypto Library
Bind.singleton(
(i) => FlutterChainService(
jsVMService: i(),
nearBlockchainService: i(),
bitcoinBlockchainService: i(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class _ExportKeyInNearApiJsFormatState
(element) => element.derivationPath == currentDerivationPath);
final secretKey = await NearBlockChainService.defaultInstance()
.exportPrivateKeyToTheNearApiJsFormat(
currentBlockchainData: currentBlockchainData,
currentBlockchainData: currentBlockchainData!,
);
nearVM.nearState.add(
currentState.copyWith(exportSecretKeyToTheNearApiJsFormat: secretKey),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
Expand Down
7 changes: 7 additions & 0 deletions example/lib/modules/home/pages/core/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:developer';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:flutterchain/flutterchain_lib/models/core/wallet.dart';
Expand Down Expand Up @@ -74,6 +75,12 @@ class _CryptoListPageState extends State<CryptoListPage> {
SizedBox(
height: 10.h,
),
if (kIsWeb) ...[
const Text("wasm: $kIsWasm"),
SizedBox(
height: 10.h,
),
],
Text(
'Total Amount: \$" Not yet implemented"',
style: nearTextStyles.headline!.copyWith(
Expand Down
Loading

0 comments on commit e9137b9

Please sign in to comment.