Skip to content

Commit

Permalink
New Feature
Browse files Browse the repository at this point in the history
Added Web3 support for Ton blockchain
Supported Ton W5 wallet contract
  • Loading branch information
mrtnetwork committed Sep 18, 2024
1 parent d804077 commit 535e62c
Show file tree
Hide file tree
Showing 362 changed files with 14,547 additions and 6,383 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion mrt_native_support/lib/io/webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WebViewIoInterface implements PlatformWebView {

Future<void> _methodCallHandler(Map<String, dynamic> args) async {
if (args['type'] == "log") {
print('\x1B[33m${args['data']}\x1B[0m');
print('console: \x1B[33m${args['data']}\x1B[0m');
return;
}
if (args["eventName"] == null) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum WalletEventTypes {
ping,
popup,
windowId,
openExtention;
openExtension;

static WalletEventTypes fromName(String name) {
return values.firstWhere((e) => e.name == name,
Expand Down
1 change: 1 addition & 0 deletions mrt_native_support/lib/platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PlatformInterface {
static AppPlatform get appPlatform => instance.platform;
static bool get isWindows => appPlatform == AppPlatform.windows;
static bool get isWeb => appPlatform == AppPlatform.web;
static bool get isMacos => appPlatform == AppPlatform.macos;
static PlatformWebView get webViewController => instance.webView;
static bool get supportWebView => webViewController.supported;
}
4 changes: 2 additions & 2 deletions mrt_native_support/lib/web/api/chrome/api/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ external Browser get _browser;
@JS("browser")
external Browser? get _browserNullabe;

ChromeAPI get extention {
ChromeAPI get extension {
if (_chromeNullabe != null) {
return _chrome;
}
return _browser;
}

bool get isExtention =>
bool get isExtension =>
_chromeNullabe?.runtimeNullable?.idNullabe != null ||
_browserNullabe?.runtimeNullable?.idNullabe != null;
1 change: 1 addition & 0 deletions mrt_native_support/lib/web/api/core/js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ extension type MRTJsObject(JSObject _) implements JSObject {
external static JSAny keys(JSAny? val);
external static JSAny entries(JSAny? val);
external bool hasOwnProperty(String nameOrSymbol);
external static bool hasOwn(JSAny? obj, String prop);
}
7 changes: 4 additions & 3 deletions mrt_native_support/lib/web/api/window/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,11 @@ extension type CustomEvent._(JSObject _) implements WebEvent {
external factory CustomEvent(String? type, EventInit? options);
factory CustomEvent.create(
{required String? type,
required List<int> data,
required JSAny? eventData,
bool bubbles = true,
bool cancelable = false,
bool clone = false}) {
JSAny? eventData = data.jsify();
if (clone && isExtention && cloneInto != null) {
if (clone && isExtension && cloneInto != null) {
eventData = _cloneInto(eventData, jsWindow.document.defaultView);
}

Expand All @@ -363,4 +362,6 @@ extension type JSConsole._(JSObject _) implements JSObject {
external void debug(String? text);
external void info(String? text);
external void error(String? text);
@JS("error")
external void errorObject(JSAny? obj);
}
5 changes: 0 additions & 5 deletions mrt_native_support/lib/web/mrt_native_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,7 @@ class MrtNativeWeb extends MrtPlatformInterface {

@override
Future<MRTAPPConfig> getConfig() async {
final now = DateTime.now();

storage = await SafeStorage.init();
final end = DateTime.now();
print(
"difference initiale storage ${now.difference(end).inMilliseconds.abs()}");
final barcode = await hasBarcodeScanner().catchError((e) => false);
return MRTAPPConfig(platform: platform, hasBarcodeScanner: barcode);
}
Expand Down
10 changes: 5 additions & 5 deletions mrt_native_support/lib/web/storage/safe_storage/safestorage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class SafestorageUtils {
}

static Future<String?> _key() async {
if (isExtention) {
return await extention.storage.local.getStorage_(StorageConst.key);
if (isExtension) {
return await extension.storage.local.getStorage_(StorageConst.key);
}
return localStorage.getItem(StorageConst.key);
}
Expand All @@ -73,8 +73,8 @@ class SafestorageUtils {
}
final generateKey = _generateKey();
final ChaCha20Poly1305 chacha = generateKey.$2;
if (isExtention) {
await extention.storage.local
if (isExtension) {
await extension.storage.local
.setStorage_(StorageConst.key, generateKey.$1);
return chacha;
}
Expand Down Expand Up @@ -106,7 +106,7 @@ abstract class SafeStorage {
const SafeStorage(this._chacha);
static Future<SafeStorage> init() async {
final key = await SafestorageUtils.migrateLegacy();
if (isExtention) {
if (isExtension) {
return ChromeStorage(key);
}
return WebStorage(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:mrt_native_support/web/storage/constant/constant.dart';

class ChromeStorage extends SafeStorage {
ChromeStorage(super.chacha);
StorageArea get _storage => extention.storage.local;
StorageArea get _storage => extension.storage.local;
@override
Future<void> clear() async {
await _storage.clear_();
Expand Down
14 changes: 7 additions & 7 deletions mrt_native_support/macos/Classes/NativeView/WebKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ class NativeViewFactory: NSObject, FlutterPlatformViewFactory,WKNavigationDelega
self.channel.invokeMethod(WebViewConst.webView, arguments: data.toJson())
}
}

func dispose(){

webView?.stopLoading()

webView?.removeFromSuperview()
webView.reload()
webView.stopLoading()
webView.removeFromSuperview()

}
func openPage(url: String) {
Expand Down Expand Up @@ -170,7 +170,7 @@ class NativeViewFactory: NSObject, FlutterPlatformViewFactory,WKNavigationDelega
window.addEventListener("error", function (e) {
window.webkit.messageHandlers.MRT.postMessage({
type: 'log',
data: "Error occurred: " + e.error.message,
data: "Error occurred: " + e.error.message + e + e.error,
id: '1',
requestId: '0',
});
Expand All @@ -180,7 +180,7 @@ class NativeViewFactory: NSObject, FlutterPlatformViewFactory,WKNavigationDelega
// Send the message to the native side
window.webkit.messageHandlers.MRT.postMessage({
type: 'log',
data: "Error occurred: " + e.reason.message,
data: "Error occurred: " + e.reason.message + e + e.reason,
id: '1',
requestId: '0',
});
Expand All @@ -191,7 +191,7 @@ class NativeViewFactory: NSObject, FlutterPlatformViewFactory,WKNavigationDelega
// Send the message to the native side
window.webkit.messageHandlers.MRT.postMessage({
type: 'log',
data: "Error occurred: " + message,
data: "Error occurred: " + message + source + lineno + colno,
id: '1',
requestId: '0',
});
Expand Down
113 changes: 56 additions & 57 deletions mrt_wallet/assets/wasm/crypto.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ _100: Object.is,
_101: s => s.toUpperCase(),
_102: s => s.toLowerCase(),
_103: (a, i) => a.push(i),
_104: (a, i) => a.splice(i, 1)[0],
_110: (a, s) => a.join(s),
_111: (a, s, e) => a.slice(s, e),
_114: a => a.length,
Expand Down Expand Up @@ -138,68 +137,68 @@ _182: f => finalizeWrapper(f, function(x0) { return dartInstance.exports._182(f,
_183: f => finalizeWrapper(f, function() { return dartInstance.exports._183(f,arguments.length) }),
_201: (c) =>
queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
_577: (s, m) => {
_585: (s, m) => {
try {
return new RegExp(s, m);
} catch (e) {
return String(e);
}
},
_578: (x0,x1) => x0.exec(x1),
_579: (x0,x1) => x0.test(x1),
_580: (x0,x1) => x0.exec(x1),
_588: o => o === undefined,
_589: o => typeof o === 'boolean',
_590: o => typeof o === 'number',
_592: o => typeof o === 'string',
_595: o => o instanceof Int8Array,
_596: o => o instanceof Uint8Array,
_597: o => o instanceof Uint8ClampedArray,
_598: o => o instanceof Int16Array,
_599: o => o instanceof Uint16Array,
_600: o => o instanceof Int32Array,
_601: o => o instanceof Uint32Array,
_602: o => o instanceof Float32Array,
_603: o => o instanceof Float64Array,
_604: o => o instanceof ArrayBuffer,
_605: o => o instanceof DataView,
_606: o => o instanceof Array,
_607: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
_610: o => o instanceof RegExp,
_611: (l, r) => l === r,
_612: o => o,
_613: o => o,
_614: o => o,
_615: b => !!b,
_616: o => o.length,
_619: (o, i) => o[i],
_620: f => f.dartFunction,
_621: l => arrayFromDartList(Int8Array, l),
_622: (data, length) => {
_586: (x0,x1) => x0.exec(x1),
_587: (x0,x1) => x0.test(x1),
_588: (x0,x1) => x0.exec(x1),
_596: o => o === undefined,
_597: o => typeof o === 'boolean',
_598: o => typeof o === 'number',
_600: o => typeof o === 'string',
_603: o => o instanceof Int8Array,
_604: o => o instanceof Uint8Array,
_605: o => o instanceof Uint8ClampedArray,
_606: o => o instanceof Int16Array,
_607: o => o instanceof Uint16Array,
_608: o => o instanceof Int32Array,
_609: o => o instanceof Uint32Array,
_610: o => o instanceof Float32Array,
_611: o => o instanceof Float64Array,
_612: o => o instanceof ArrayBuffer,
_613: o => o instanceof DataView,
_614: o => o instanceof Array,
_615: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
_618: o => o instanceof RegExp,
_619: (l, r) => l === r,
_620: o => o,
_621: o => o,
_622: o => o,
_623: b => !!b,
_624: o => o.length,
_627: (o, i) => o[i],
_628: f => f.dartFunction,
_629: l => arrayFromDartList(Int8Array, l),
_630: (data, length) => {
const jsBytes = new Uint8Array(length);
const getByte = dartInstance.exports.$uint8ListGet;
for (let i = 0; i < length; i++) {
jsBytes[i] = getByte(data, i);
}
return jsBytes;
},
_623: l => arrayFromDartList(Uint8ClampedArray, l),
_624: l => arrayFromDartList(Int16Array, l),
_625: l => arrayFromDartList(Uint16Array, l),
_626: l => arrayFromDartList(Int32Array, l),
_627: l => arrayFromDartList(Uint32Array, l),
_628: l => arrayFromDartList(Float32Array, l),
_629: l => arrayFromDartList(Float64Array, l),
_630: (data, length) => {
_631: l => arrayFromDartList(Uint8ClampedArray, l),
_632: l => arrayFromDartList(Int16Array, l),
_633: l => arrayFromDartList(Uint16Array, l),
_634: l => arrayFromDartList(Int32Array, l),
_635: l => arrayFromDartList(Uint32Array, l),
_636: l => arrayFromDartList(Float32Array, l),
_637: l => arrayFromDartList(Float64Array, l),
_638: (data, length) => {
const read = dartInstance.exports.$byteDataGetUint8;
const view = new DataView(new ArrayBuffer(length));
for (let i = 0; i < length; i++) {
view.setUint8(i, read(data, i));
}
return view;
},
_631: l => arrayFromDartList(Array, l),
_632: (s, length) => {
_639: l => arrayFromDartList(Array, l),
_640: (s, length) => {
if (length == 0) return '';

const read = dartInstance.exports.$stringRead1;
Expand All @@ -220,7 +219,7 @@ _632: (s, length) => {
return result;
}
,
_633: (s, length) => {
_641: (s, length) => {
if (length == 0) return '';

const read = dartInstance.exports.$stringRead2;
Expand All @@ -241,7 +240,7 @@ _633: (s, length) => {
return result;
}
,
_634: (s) => {
_642: (s) => {
let length = s.length;
let range = 0;
for (let i = 0; i < length; i++) {
Expand Down Expand Up @@ -297,18 +296,18 @@ _634: (s) => {
}
}
,
_637: l => new Array(l),
_641: (o, p) => o[p],
_645: o => String(o),
_650: x0 => x0.index,
_652: x0 => x0.length,
_654: (x0,x1) => x0[x1],
_657: x0 => x0.flags,
_658: x0 => x0.multiline,
_659: x0 => x0.ignoreCase,
_660: x0 => x0.unicode,
_661: x0 => x0.dotAll,
_662: (x0,x1) => x0.lastIndex = x1
_645: l => new Array(l),
_649: (o, p) => o[p],
_653: o => String(o),
_658: x0 => x0.index,
_660: x0 => x0.length,
_662: (x0,x1) => x0[x1],
_665: x0 => x0.flags,
_666: x0 => x0.multiline,
_667: x0 => x0.ignoreCase,
_668: x0 => x0.unicode,
_669: x0 => x0.dotAll,
_670: (x0,x1) => x0.lastIndex = x1
};

const baseImports = {
Expand Down
Binary file modified mrt_wallet/assets/wasm/crypto.wasm
Binary file not shown.
Loading

0 comments on commit 535e62c

Please sign in to comment.