diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..f2872cf 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 0000000..4c70286 --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,22 @@ +PODS: + - Flutter (1.0.0) + - flutter_sodium (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - flutter_sodium (from `.symlinks/plugins/flutter_sodium/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + flutter_sodium: + :path: ".symlinks/plugins/flutter_sodium/ios" + +SPEC CHECKSUMS: + Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a + flutter_sodium: c84426b4de738514b5b66cfdeb8a06634e72fe0b + +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c + +COCOAPODS: 1.10.1 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index d59cc08..6976c4c 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 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 */; }; + E912E6A76ADEDE241BCDB735 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B45E7A4745AF4B8EE477D69 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -31,7 +32,10 @@ /* 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 = ""; }; + 1B45E7A4745AF4B8EE477D69 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 1E50678272CB049C5F39A78C /* 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 = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 6BFB775485EAB3650B8CB319 /* 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 = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -42,6 +46,7 @@ 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 = ""; }; + BD336D74DB5A87C0740ADDFE /* 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 = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -49,6 +54,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + E912E6A76ADEDE241BCDB735 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -72,6 +78,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + BD826F3CE00D16E2532AF5CC /* Pods */, + D06F5E3A6439218479EA2FC5 /* Frameworks */, ); sourceTree = ""; }; @@ -106,6 +114,25 @@ name = "Supporting Files"; sourceTree = ""; }; + BD826F3CE00D16E2532AF5CC /* Pods */ = { + isa = PBXGroup; + children = ( + 6BFB775485EAB3650B8CB319 /* Pods-Runner.debug.xcconfig */, + BD336D74DB5A87C0740ADDFE /* Pods-Runner.release.xcconfig */, + 1E50678272CB049C5F39A78C /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + D06F5E3A6439218479EA2FC5 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1B45E7A4745AF4B8EE477D69 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -113,12 +140,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 6A8D1B8E0412D0033A7D127B /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 8628E441B6D41CA9126B84D0 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -191,6 +220,45 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 6A8D1B8E0412D0033A7D127B /* [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; + }; + 8628E441B6D41CA9126B84D0 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + 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; @@ -280,7 +348,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -362,7 +430,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -411,7 +479,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/example/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/example/lib/main.dart b/example/lib/main.dart index 71e321f..3ae1200 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -44,7 +44,7 @@ class _MyAppState extends State { // Accessing: private key ===> identity[0] | public key ===> identity[1] | public Key Hash ===> identity[2] all of type string. //Restore account from secret key - List restoredKeys = TezsterDart.getKeysFromSecretKey( + List restoredKeys = TezsterDart.getKeysFromSecretKey( "edskRrDH2TF4DwKU1ETsUjyhxPC8aCTD6ko5YDguNkJjRb3PiBm8Upe4FGFmCrQqzSVMDLfFN22XrQXATcA3v41hWnAhymgQwc"); print("Restored account keys ===> $restoredKeys"); // restoredKeys ===> [privateKey, publicKey, publicKeyHash] @@ -233,8 +233,8 @@ class _MyAppState extends State { ); var faucetKeys = await TezsterDart.unlockFundraiserIdentity( - email: faucetKeyStore.email, - passphrase: faucetKeyStore.password, + email: faucetKeyStore.email!, + passphrase: faucetKeyStore.password!, mnemonic: faucetKeyStore.seed.join(' ')); faucetKeyStore ..publicKey = faucetKeys[1] @@ -244,7 +244,7 @@ class _MyAppState extends State { TezsterDart.writeKeyWithHint(faucetKeyStore.secretKey, 'edsk')); var activationOperationResult = await TezsterDart.sendIdentityActivationOperation(server, - activationOperationSigner, faucetKeyStore, faucetKeyStore.secret); + activationOperationSigner, faucetKeyStore, faucetKeyStore.secret!); print('${activationOperationResult['operationGroupID']}'); //Reveal an account @@ -266,7 +266,16 @@ class _MyAppState extends State { @override void initState() { super.initState(); - tezosWalletUtil(); + // tezosWalletUtil(); + readContract(); + } + + void readContract() async { + // var contractAddress = 'KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton'; + // var contract = await TezsterDart.getContractStorage( + // "https://edonet.smartpy.io", "KT1CoQ5cd6hkPCxeCj3N5uPWztKfjn4kqXVm"); + // print(contract); + TezsterDart.exp("KT1CoQ5cd6hkPCxeCj3N5uPWztKfjn4kqXVm"); } @override @@ -277,9 +286,14 @@ class _MyAppState extends State { body: Padding( padding: EdgeInsets.all(8.0), child: Center( - child: Text( - "Welcome to Tezster_dart package.\n Please check the debug console for the outputs", - textAlign: TextAlign.center, + child: InkWell( + onTap: () { + readContract(); + }, + child: Text( + "Welcome to Tezster_dart package.\n Please check the debug console for the outputs", + textAlign: TextAlign.center, + ), ), ), ), diff --git a/example/pubspec.lock b/example/pubspec.lock index dbfafda..faae489 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,21 +7,21 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.7.0" bip39: dependency: transitive description: name: bip39 url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.6" blake2b: dependency: transitive description: name: blake2b url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.1" boolean_selector: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: bs58check url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" characters: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -64,27 +64,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" + conduit_password_hash: + dependency: transitive + description: + name: conduit_password_hash + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.11" convert: dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "3.0.1" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" cryptography: dependency: transitive description: name: cryptography url: "https://pub.dartlang.org" source: hosted - version: "1.4.1" + version: "2.0.2" cupertino_icons: dependency: "direct main" description: @@ -98,7 +105,7 @@ packages: name: ed25519_hd_key url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.1.0" fake_async: dependency: transitive description: @@ -112,14 +119,14 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.1.2" fixnum: dependency: transitive description: name: fixnum url: "https://pub.dartlang.org" source: hosted - version: "0.10.11" + version: "1.0.0" flutter: dependency: "direct main" description: flutter @@ -131,26 +138,31 @@ packages: name: flutter_sodium url: "https://pub.dartlang.org" source: hosted - version: "0.1.11" + version: "0.2.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" hex: dependency: transitive description: name: hex url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.2" + version: "0.6.3" matcher: dependency: transitive description: @@ -164,14 +176,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" - password_hash: - dependency: transitive - description: - name: password_hash - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" + version: "1.7.0" path: dependency: transitive description: @@ -185,19 +190,26 @@ packages: name: pointycastle url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "3.2.0" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + sodium_web: + dependency: transitive + description: + name: sodium_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -232,7 +244,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.2" tezster_dart: dependency: "direct main" description: @@ -253,7 +265,7 @@ packages: name: unorm_dart url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" vector_math: dependency: transitive description: @@ -262,5 +274,5 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" - flutter: ">=1.10.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index a77bc68..f577ad8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: diff --git a/lib/chain/tezos/tezos_language_util.dart b/lib/chain/tezos/tezos_language_util.dart index ccda09f..1947fc7 100644 --- a/lib/chain/tezos/tezos_language_util.dart +++ b/lib/chain/tezos/tezos_language_util.dart @@ -2,12 +2,12 @@ import 'package:tezster_dart/michelson_parser/michelson_parser.dart'; class TezosLanguageUtil { - static String translateMichelsonToMicheline(String code) { + static String? translateMichelsonToMicheline(String code) { var result = MichelsonParser.parseMichelson(code); return result; } - static String translateMichelineToHex(p) { + static String? translateMichelineToHex(p) { return MichelsonParser.translateMichelineToHex(p); } } diff --git a/lib/chain/tezos/tezos_message_codec.dart b/lib/chain/tezos/tezos_message_codec.dart index 48fbbc4..c9478ef 100644 --- a/lib/chain/tezos/tezos_message_codec.dart +++ b/lib/chain/tezos/tezos_message_codec.dart @@ -24,15 +24,15 @@ class TezosMessageCodec { static String encodeTransaction(OperationModel message) { String hex = TezosMessageUtils.writeInt(108); - hex += TezosMessageUtils.writeAddress(message.source).substring(2); - hex += TezosMessageUtils.writeInt(int.parse(message.fee)); - hex += TezosMessageUtils.writeInt(message.counter); - hex += TezosMessageUtils.writeInt(message.gasLimit); + hex += TezosMessageUtils.writeAddress(message.source!).substring(2); + hex += TezosMessageUtils.writeInt(int.parse(message.fee!)); + hex += TezosMessageUtils.writeInt(message.counter!); + hex += TezosMessageUtils.writeInt(message.gasLimit!); hex += TezosMessageUtils.writeInt(message.storageLimit); - hex += TezosMessageUtils.writeInt(int.parse(message.amount)); - hex += TezosMessageUtils.writeAddress(message.destination); + hex += TezosMessageUtils.writeInt(int.parse(message.amount!)); + hex += TezosMessageUtils.writeAddress(message.destination!); if (message.parameters != null) { - var composite = message.parameters; + var composite = message.parameters!; var result = TezosLanguageUtil.translateMichelineToHex( jsonEncode(composite['value'])); if ((composite['entrypoint'] == 'default' || @@ -61,7 +61,7 @@ class TezosMessageCodec { .map((String c) => c.codeUnitAt(0).toRadixString(16)) .join(''); } - var resRad = '0000000' + (result.length ~/ 2).toRadixString(16); + var resRad = '0000000' + (result!.length ~/ 2).toRadixString(16); hex += resRad.substring(resRad.length - 8) + result; } } else { @@ -72,25 +72,25 @@ class TezosMessageCodec { static String encodeReveal(OperationModel message) { var hex = TezosMessageUtils.writeInt(107); - hex += TezosMessageUtils.writeAddress(message.source).substring(2); - hex += TezosMessageUtils.writeInt(int.parse(message.fee)); - hex += TezosMessageUtils.writeInt(message.counter); - hex += TezosMessageUtils.writeInt(message.gasLimit); + hex += TezosMessageUtils.writeAddress(message.source!).substring(2); + hex += TezosMessageUtils.writeInt(int.parse(message.fee!)); + hex += TezosMessageUtils.writeInt(message.counter!); + hex += TezosMessageUtils.writeInt(message.gasLimit!); hex += TezosMessageUtils.writeInt(message.storageLimit); - hex += TezosMessageUtils.writePublicKey(message.publicKey); + hex += TezosMessageUtils.writePublicKey(message.publicKey!); return hex; } static String encodeDelegation(OperationModel delegation) { var hex = TezosMessageUtils.writeInt(110); - hex += TezosMessageUtils.writeAddress(delegation.source).substring(2); - hex += TezosMessageUtils.writeInt(int.parse(delegation.fee)); - hex += TezosMessageUtils.writeInt(delegation.counter); - hex += TezosMessageUtils.writeInt(delegation.gasLimit); + hex += TezosMessageUtils.writeAddress(delegation.source!).substring(2); + hex += TezosMessageUtils.writeInt(int.parse(delegation.fee!)); + hex += TezosMessageUtils.writeInt(delegation.counter!); + hex += TezosMessageUtils.writeInt(delegation.gasLimit!); hex += TezosMessageUtils.writeInt(delegation.storageLimit); - if (delegation.delegate != null && delegation.delegate.isNotEmpty) { + if (delegation.delegate != null && delegation.delegate!.isNotEmpty) { hex += TezosMessageUtils.writeBoolean(true); - hex += TezosMessageUtils.writeAddress(delegation.delegate).substring(2); + hex += TezosMessageUtils.writeAddress(delegation.delegate!).substring(2); } else { hex += TezosMessageUtils.writeBoolean(false); } @@ -99,28 +99,28 @@ class TezosMessageCodec { static String encodeOrigination(OperationModel origination) { var hex = TezosMessageUtils.writeInt(109); - hex += TezosMessageUtils.writeAddress(origination.source).substring(2); - hex += TezosMessageUtils.writeInt(int.parse(origination.fee)); - hex += TezosMessageUtils.writeInt(origination.counter); - hex += TezosMessageUtils.writeInt(origination.gasLimit); + hex += TezosMessageUtils.writeAddress(origination.source!).substring(2); + hex += TezosMessageUtils.writeInt(int.parse(origination.fee!)); + hex += TezosMessageUtils.writeInt(origination.counter!); + hex += TezosMessageUtils.writeInt(origination.gasLimit!); hex += TezosMessageUtils.writeInt(origination.storageLimit); - hex += TezosMessageUtils.writeInt(int.parse(origination.amount)); + hex += TezosMessageUtils.writeInt(int.parse(origination.amount!)); if (origination.delegate != null) { hex += TezosMessageUtils.writeBoolean(true); - hex += TezosMessageUtils.writeAddress(origination.delegate).substring(2); + hex += TezosMessageUtils.writeAddress(origination.delegate!).substring(2); } else { hex += TezosMessageUtils.writeBoolean(false); } if (origination.script != null) { var parts = []; - parts.add(origination.script['code']); - parts.add(origination.script['storage']); + parts.add(origination.script!['code']); + parts.add(origination.script!['storage']); hex += parts .map((p) => jsonEncode(p)) .map((p) => TezosLanguageUtil.translateMichelineToHex(p)) .fold('', (m, p) { - var result = ('0000000' + (p.length ~/ 2).toRadixString(16)); + var result = ('0000000' + (p!.length ~/ 2).toRadixString(16)); result = result.substring(result.length - 8) + p; return m + result; }); diff --git a/lib/chain/tezos/tezos_message_utils.dart b/lib/chain/tezos/tezos_message_utils.dart index 4a4ca3f..ac6dfcf 100644 --- a/lib/chain/tezos/tezos_message_utils.dart +++ b/lib/chain/tezos/tezos_message_utils.dart @@ -188,7 +188,7 @@ class TezosMessageUtils { .join(''); } - static String writeString(value) { + static String? writeString(value) { var len = dataLength(value.length); var text = value .split('') @@ -247,7 +247,7 @@ class TezosMessageUtils { case 'nat': return '0500' + writeInt(int.parse(value)); case 'string': - return '0501' + writeString(value); + return '0501' + writeString(value)!; case 'key_hash': var address = writeAddress(value).substring(2); return '050a${dataLength(address.length / 2)}$address'; @@ -263,7 +263,7 @@ class TezosMessageUtils { return '05${TezosLanguageUtil.translateMichelineToHex(value)}'; } else if (format == TezosParameterFormat.Michelson) { var micheline = - TezosLanguageUtil.translateMichelsonToMicheline(value); + TezosLanguageUtil.translateMichelsonToMicheline(value)!; return '05${TezosLanguageUtil.translateMichelineToHex(micheline)}'; } else { throw new Exception('Unsupported format $format provided'); diff --git a/lib/chain/tezos/tezos_node_reader.dart b/lib/chain/tezos/tezos_node_reader.dart index 3e630a2..1e638f8 100644 --- a/lib/chain/tezos/tezos_node_reader.dart +++ b/lib/chain/tezos/tezos_node_reader.dart @@ -1,4 +1,6 @@ import 'package:tezster_dart/helper/http_helper.dart'; +import 'package:tezster_dart/michelson_parser/michelson_parser.dart'; +import 'package:tezster_dart/michelson_parser/parser/michelson_grammar.dart'; class TezosNodeReader { static Future getCounterForAccount(String server, String publicKeyHash, @@ -23,34 +25,48 @@ class TezosNodeReader { return response != null ? response.toString() : ''; } - static Future> getBlockAtOffset( + static Future?> getBlockAtOffset( String server, int offset, {String chainid = 'main'}) async { if (offset <= 0) { return await getBlock(server); } - var head = await getBlock(server); + var head = await (getBlock(server)); var response = await HttpHelper.performGetRequest( - server, 'chains/$chainid/blocks/${head['header']['level'] - offset}'); + server, 'chains/$chainid/blocks/${head!['header']['level'] - offset}'); return response; } - static Future> getBlock(String server, + static Future?> getBlock(String server, {String hash = 'head', String chainid = 'main'}) async { var response = await HttpHelper.performGetRequest( server, 'chains/$chainid/blocks/$hash'); return response; } - static Future> getContractStorage(server, accountHash, + static Future getContractStorage(server, accountHash, {block = 'head', chainid = 'main'}) async { - return await HttpHelper.performGetRequest(server, - 'chains/$chainid/blocks/$block/context/contracts/$accountHash/storage'); + var res = await (HttpHelper.performGetRequest(server, + 'chains/$chainid/blocks/$block/context/contracts/$accountHash/script', + returnString: true)); + print(res); + return MichelsonParser.parseMichelson(res); } static getValueForBigMapKey(String server, String index, String key, - {String block, String chainid}) async { - return await HttpHelper.performGetRequest(server, - 'chains/$chainid/blocks/$block/context/big_maps/$index/$key'); + {String? block, String? chainid}) async { + return await HttpHelper.performGetRequest( + server, 'chains/$chainid/blocks/$block/context/big_maps/$index/$key'); + } + + + static Future?> getTokenMetaData( + String server, String accountHash, + {block = 'head', chainid = 'main'}) async { + var storage = await getContractStorage(server, accountHash); + if (storage == null) { + throw Exception( + '$accountHash does not point to a valid contract on $server'); + } } } diff --git a/lib/chain/tezos/tezos_node_writer.dart b/lib/chain/tezos/tezos_node_writer.dart index bd2c2c9..8ffe253 100644 --- a/lib/chain/tezos/tezos_node_writer.dart +++ b/lib/chain/tezos/tezos_node_writer.dart @@ -15,7 +15,7 @@ import 'package:tezster_dart/types/tezos/tezos_chain_types.dart'; import 'package:tezster_dart/utils/gas_fee_calculator.dart'; class TezosNodeWriter { - static Future> sendTransactionOperation(String server, + static Future> sendTransactionOperation(String server, SoftSigner signer, KeyStoreModel keyStore, String to, int amount, int fee, {int offset = 54}) async { var counter = await TezosNodeReader.getCounterForAccount( @@ -69,7 +69,7 @@ class TezosNodeWriter { SoftSigner signer, KeyStoreModel keyStore, int amount, - String delegate, + String? delegate, int fee, int storageLimit, int gasLimit, @@ -185,7 +185,7 @@ class TezosNodeWriter { if (parameters != null) { if (parameterFormat == TezosParameterFormat.Michelson) { var michelineParams = - TezosLanguageUtil.translateMichelsonToMicheline(parameters); + TezosLanguageUtil.translateMichelsonToMicheline(parameters)!; transaction.parameters = { 'entrypoint': entrypoint.isEmpty ? 'default' : entrypoint, 'value': jsonDecode(michelineParams) @@ -197,7 +197,7 @@ class TezosNodeWriter { }; } else if (parameterFormat == TezosParameterFormat.MichelsonLambda) { var michelineLambda = - TezosLanguageUtil.translateMichelsonToMicheline('code $parameters'); + TezosLanguageUtil.translateMichelsonToMicheline('code $parameters')!; transaction.parameters = { 'entrypoint': entrypoint.isEmpty ? 'default' : entrypoint, 'value': jsonDecode(michelineLambda) @@ -212,7 +212,7 @@ class TezosNodeWriter { static Future> appendRevealOperation( String server, - String publicKey, + String? publicKey, String publicKeyHash, int accountOperationIndex, List operations) async { @@ -238,10 +238,10 @@ class TezosNodeWriter { return operations; } - static Future> sendOperation(String server, + static Future> sendOperation(String server, List operations, SoftSigner signer, int offset) async { var blockHead = await TezosNodeReader.getBlockAtOffset(server, offset); - var blockHash = blockHead['hash'].toString().substring(0, 51); + var blockHash = blockHead!['hash'].toString().substring(0, 51); var forgedOperationGroup = forgeOperations(blockHash, operations); var opSignature = signer.signOperation(Uint8List.fromList(hex.decode( TezosConstants.OperationGroupWatermark + forgedOperationGroup))); @@ -326,7 +326,7 @@ class TezosNodeWriter { } } - static String parseRPCOperationResult(result) { + static String? parseRPCOperationResult(result) { if (result.status == 'failed') { return "${result.status}: ${result.errors.map((e) => '(${e.kind}: ${e.id})').join(', ')}"; } else if (result.status == 'applied') { @@ -339,7 +339,7 @@ class TezosNodeWriter { static injectOperation(String server, Map opPair, {chainid = 'main'}) async { var response = await HttpHelper.performPostRequest(server, - 'injection/operation?chain=$chainid', hex.encode(opPair['bytes'])); + 'injection/operation?chain=$chainid', hex.encode(opPair['bytes'] as List)); response = response.toString().replaceAll('"', ''); return response; } @@ -347,7 +347,7 @@ class TezosNodeWriter { static OperationModel constructContractOriginationOperation( KeyStoreModel keyStore, int amount, - String delegate, + String? delegate, int fee, int storageLimit, int gasLimit, @@ -359,9 +359,9 @@ class TezosNodeWriter { var parsedStorage; if (codeFormat == TezosParameterFormat.Michelson) { parsedCode = - jsonDecode(TezosLanguageUtil.translateMichelsonToMicheline(code)); + jsonDecode(TezosLanguageUtil.translateMichelsonToMicheline(code)!); parsedStorage = - jsonDecode(TezosLanguageUtil.translateMichelsonToMicheline(storage)); + jsonDecode(TezosLanguageUtil.translateMichelsonToMicheline(storage)!); } else if (codeFormat == TezosParameterFormat.Micheline) { parsedCode = jsonDecode(code); parsedStorage = jsonDecode(storage); diff --git a/lib/helper/generateKeys.dart b/lib/helper/generateKeys.dart index 64e83cb..4348dab 100644 --- a/lib/helper/generateKeys.dart +++ b/lib/helper/generateKeys.dart @@ -12,7 +12,7 @@ class GenerateKeys { String stringToHexString = hex.encode(uintToString.codeUnits); String finalStringToDecode = "06a19f" + stringToHexString; List listOfHexDecodedInt = hex.decode(finalStringToDecode); - String publicKeyHash = bs58check.encode(listOfHexDecodedInt); + String publicKeyHash = bs58check.encode(listOfHexDecodedInt as Uint8List); return publicKeyHash; } @@ -25,12 +25,12 @@ class GenerateKeys { String concatinatingHexStringWithHint = hint + stringToHexString; List convertingHexStringToListOfInt = hex.decode(concatinatingHexStringWithHint); - String base58String = bs58check.encode(convertingHexStringToListOfInt); + String base58String = bs58check.encode(convertingHexStringToListOfInt as Uint8List); return base58String; } static Uint8List writeKeyWithHint( - String key, + String? key, String hint, ) { if (hint == 'edsk' || @@ -39,7 +39,7 @@ class GenerateKeys { hint == 'p2pk' || hint == '2bf64e07' || hint == '0d0f25d9') { - return bs58check.decode(key).sublist(4); + return bs58check.decode(key!).sublist(4); } else throw Exception("Unrecognized key hint, '$hint'"); } diff --git a/lib/helper/http_helper.dart b/lib/helper/http_helper.dart index 81779c0..f55f381 100644 --- a/lib/helper/http_helper.dart +++ b/lib/helper/http_helper.dart @@ -3,7 +3,7 @@ import 'dart:io'; class HttpHelper { static Future performPostRequest(server, command, payload, - {Map headers}) async { + {Map? headers}) async { HttpClient httpClient = new HttpClient(); HttpClientRequest request = await httpClient.postUrl( command.isEmpty ? Uri.parse(server) : Uri.parse('$server/$command')); @@ -12,7 +12,7 @@ class HttpHelper { request.add(utf8.encode(json.encode(payload))); } else { headers.entries.forEach( - (header) => request.headers.add(header.key, header.value), + (header) => request.headers.add(header.key, header.value!), ); request.headers.add('body', json.encode(payload)); request.add(utf8.encode(json.encode(payload))); @@ -23,13 +23,17 @@ class HttpHelper { return reply; } - static Future performGetRequest(server, command) async { + static Future performGetRequest(server, command,{bool returnString=false}) async { HttpClient httpClient = new HttpClient(); HttpClientRequest request = await httpClient.getUrl(Uri.parse('$server/$command')); HttpClientResponse response = await request.close(); String reply = await response.transform(utf8.decoder).join(); httpClient.close(); + + if(returnString){ + return reply; + } return jsonDecode(reply); } } diff --git a/lib/helper/password_generater.dart b/lib/helper/password_generater.dart index d18db72..255e8e9 100644 --- a/lib/helper/password_generater.dart +++ b/lib/helper/password_generater.dart @@ -5,11 +5,11 @@ import 'package:flutter/cupertino.dart'; class PasswordGenerator { static String generatePassword( - {@required double length, - bool isWithLetters, - bool isWithUppercase, - bool isWithNumbers, - bool isWithSpecial}) { + {required double length, + required bool isWithLetters, + required bool isWithUppercase, + required bool isWithNumbers, + required bool isWithSpecial}) { String _lowerCaseLetters = "abcdefghijklmnopqrstuvwxyz"; String _upperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String _numbers = "0123456789"; diff --git a/lib/michelson_parser/grammar/michelin_grammar_tokenizer.dart b/lib/michelson_parser/grammar/michelin_grammar_tokenizer.dart index 97c2b1a..8a8f13b 100644 --- a/lib/michelson_parser/grammar/michelin_grammar_tokenizer.dart +++ b/lib/michelson_parser/grammar/michelin_grammar_tokenizer.dart @@ -4,8 +4,8 @@ import 'michelson_grammar_tokenizer.dart'; class MichelinGrammarTokenizer { Map delimiters; List tokens = []; - var buffer; - int index; + late var buffer; + late int index; var line; var lastLineBreak; diff --git a/lib/michelson_parser/grammar/michelson_grammar_tokenizer.dart b/lib/michelson_parser/grammar/michelson_grammar_tokenizer.dart index f41878a..1c2b63e 100644 --- a/lib/michelson_parser/grammar/michelson_grammar_tokenizer.dart +++ b/lib/michelson_parser/grammar/michelson_grammar_tokenizer.dart @@ -3,8 +3,8 @@ import 'dart:math'; class MichelsonGrammarTokenizer { Map delimiters; List tokens = []; - var buffer; - int index; + late var buffer; + late int index; var line; var lastLineBreak; @@ -223,9 +223,9 @@ class MichelsonGrammarTokenizer { } class GrammarResultModel { - String type; + String? type; String value; - int columnNumber; + int? columnNumber; GrammarResultModel(this.type, this.value); diff --git a/lib/michelson_parser/michelson_parser.dart b/lib/michelson_parser/michelson_parser.dart index a519b2a..c727740 100644 --- a/lib/michelson_parser/michelson_parser.dart +++ b/lib/michelson_parser/michelson_parser.dart @@ -3,7 +3,7 @@ import 'package:tezster_dart/michelson_parser/parser/michelson_grammar.dart'; import 'package:tezster_dart/michelson_parser/parser/nearley.dart'; class MichelsonParser { - static String parseMichelson(String code) { + static String? parseMichelson(String code) { var parser = Nearley(); parser.parser(Nearley.fromCompiled(MichelsonGrammar().grammar)); var cleanCode = preProcessMichelsonScript(code); diff --git a/lib/michelson_parser/parser/micheline_grammar.dart b/lib/michelson_parser/parser/micheline_grammar.dart index b592395..a0be606 100644 --- a/lib/michelson_parser/parser/micheline_grammar.dart +++ b/lib/michelson_parser/parser/micheline_grammar.dart @@ -1,7 +1,7 @@ import 'package:tezster_dart/michelson_parser/grammar/michelin_grammar_tokenizer.dart'; class MichelineGrammar { - MichelinGrammarTokenizer lexer; + MichelinGrammarTokenizer? lexer; var lbrace, _, colon, quotedValue, rbrace, comma, lbracket, rbracket; final List defaultMichelsonKeywords = [ '"parameter"', @@ -123,7 +123,7 @@ class MichelineGrammar { '"chain_id"', '"CHAIN_ID"' ]; - List languageKeywords; + late List languageKeywords; MichelineGrammar() { languageKeywords = defaultMichelsonKeywords; @@ -147,11 +147,11 @@ class MichelineGrammar { languageKeywords = list; } - int getCodeForKeyword(String word) { + int getCodeForKeyword(String? word) { return languageKeywords.indexOf(word); } - String getKeywordForWord(int index) { + String? getKeywordForWord(int index) { return languageKeywords[index]; } @@ -252,15 +252,15 @@ class MichelineGrammar { } } final String prim = encodePrimitive(getMapValue(d[6])); - String args = d[15].map((e) => e[0]).join(''); - String newArgs = ''; + String? args = d[15].map((e) => e[0]).join(''); + String? newArgs = ''; if (prefix == '09') { newArgs = '0000000' + - int.parse((args.length ~/ 2).toString()).toRadixString(16).toString(); + int.parse((args!.length ~/ 2).toString()).toRadixString(16).toString(); newArgs = newArgs.substring(newArgs.length - 8); newArgs = newArgs + args + '00000000'; } - newArgs = newArgs == '' ? args : newArgs; + newArgs = newArgs == '' ? args! : newArgs; return prefix + prim + newArgs; } @@ -279,7 +279,7 @@ class MichelineGrammar { prefix = '09'; } String prim = encodePrimitive(getMapValue(d[6])); - String args = d[15].map((v) => v[0]).join(''); + String? args = d[15].map((v) => v[0]).join(''); String ann = d[26].map((v) { String t = getMapValue(v[0]); t = t.substring(1, t.length - 1); @@ -290,18 +290,18 @@ class MichelineGrammar { return d; }).join(''); ann = encodeLength(int.parse((ann.length ~/ 2).toString())) + ann; - String newArgs = ''; + String? newArgs = ''; if (prefix == '09') { newArgs = '0000000' + - int.parse((args.length ~/ 2).toString()).toRadixString(16).toString(); + int.parse((args!.length ~/ 2).toString()).toRadixString(16).toString(); newArgs = newArgs.substring(newArgs.length - 8); newArgs = newArgs + args; } - newArgs = newArgs == '' ? args : newArgs; + newArgs = newArgs == '' ? args! : newArgs; return prefix + prim + newArgs + ann; } - String encodePrimitive(String p) { + String encodePrimitive(String? p) { String result = '00' + getCodeForKeyword(p).toRadixString(16).toString(); result = result.substring(result.length - 2); return result; @@ -397,24 +397,24 @@ class MichelineGrammar { "name": r"staticInt$ebnf$1", "symbols": [ r"staticInt$ebnf$1", - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": (d) => d[0]..addAll([d[1]]) }, { "name": "staticInt", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"int\""}, r"staticInt$ebnf$1", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("quotedValue") + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": staticIntToHex }, @@ -423,24 +423,24 @@ class MichelineGrammar { "name": r"staticString$ebnf$1", "symbols": [ r"staticString$ebnf$1", - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": (d) => d[0]..addAll([d[1]]) }, { "name": "staticString", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"string\""}, r"staticString$ebnf$1", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("quotedValue") + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": staticStringToHex }, @@ -449,24 +449,24 @@ class MichelineGrammar { "name": r"staticBytes$ebnf$1", "symbols": [ r"staticBytes$ebnf$1", - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": (d) => d[0]..addAll([d[1]]) }, { "name": "staticBytes", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"bytes\""}, r"staticBytes$ebnf$1", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("quotedValue") + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": staticBytesToHex }, @@ -490,31 +490,31 @@ class MichelineGrammar { "name": r"primBare$ebnf$1", "symbols": [ r"primBare$ebnf$1", - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": (d) => d[0]..addAll([d[1]]) }, { "name": "primBare", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"prim\""}, r"primBare$ebnf$1", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("quotedValue") + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": primBareToHex }, { "name": r"primArg$ebnf$1", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -526,7 +526,7 @@ class MichelineGrammar { { "name": r"primArg$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -538,7 +538,7 @@ class MichelineGrammar { { "name": r"primArg$ebnf$3$subexpression$1$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -550,7 +550,7 @@ class MichelineGrammar { { "name": r"primArg$ebnf$3$subexpression$1$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -574,7 +574,7 @@ class MichelineGrammar { { "name": r"primArg$ebnf$3$subexpression$2$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -586,7 +586,7 @@ class MichelineGrammar { { "name": r"primArg$ebnf$3$subexpression$2$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -611,35 +611,35 @@ class MichelineGrammar { { "name": "primArg", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"prim\""}, r"primArg$ebnf$1", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("quotedValue") + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), - (lexer.has("comma") ? {'type': "comma"} : comma), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("comma") ? {'type': "comma"} : comma), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"args\""}, r"primArg$ebnf$2", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("lbracket") ? {'type': "lbracket"} : lbracket), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("lbracket") ? {'type': "lbracket"} : lbracket), + (lexer!.has("_") ? {'type': "_"} : _), r"primArg$ebnf$3", - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbracket") ? {'type': "rbracket"} : rbracket), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbracket") ? {'type': "rbracket"} : rbracket), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": primArgToHex }, { "name": r"primAnn$ebnf$1", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -651,7 +651,7 @@ class MichelineGrammar { { "name": r"primAnn$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -663,7 +663,7 @@ class MichelineGrammar { { "name": r"primAnn$ebnf$3$subexpression$1$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -675,7 +675,7 @@ class MichelineGrammar { { "name": r"primAnn$ebnf$3$subexpression$1$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -687,7 +687,7 @@ class MichelineGrammar { { "name": r"primAnn$ebnf$3$subexpression$1", "symbols": [ - (lexer.has("quotedValue") + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), r"primAnn$ebnf$3$subexpression$1$ebnf$1", @@ -701,7 +701,7 @@ class MichelineGrammar { { "name": r"primAnn$ebnf$3$subexpression$2$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -713,7 +713,7 @@ class MichelineGrammar { { "name": r"primAnn$ebnf$3$subexpression$2$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -725,7 +725,7 @@ class MichelineGrammar { { "name": r"primAnn$ebnf$3$subexpression$2", "symbols": [ - (lexer.has("quotedValue") + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), r"primAnn$ebnf$3$subexpression$2$ebnf$1", @@ -740,35 +740,35 @@ class MichelineGrammar { { "name": "primAnn", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"prim\""}, r"primAnn$ebnf$1", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("quotedValue") + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), - (lexer.has("comma") ? {'type': "comma"} : comma), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("comma") ? {'type': "comma"} : comma), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"annots\""}, r"primAnn$ebnf$2", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("lbracket") ? {'type': "lbracket"} : lbracket), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("lbracket") ? {'type': "lbracket"} : lbracket), + (lexer!.has("_") ? {'type': "_"} : _), r"primAnn$ebnf$3", - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbracket") ? {'type': "rbracket"} : rbracket), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbracket") ? {'type': "rbracket"} : rbracket), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": primAnnToHex }, { "name": r"primArgAnn$ebnf$1", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -780,7 +780,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -792,7 +792,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$3$subexpression$1$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -804,7 +804,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$3$subexpression$1$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -828,7 +828,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$3$subexpression$2$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -840,7 +840,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$3$subexpression$2$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -868,7 +868,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$4", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -880,7 +880,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$5$subexpression$1$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -892,7 +892,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$5$subexpression$1$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -904,7 +904,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$5$subexpression$1", "symbols": [ - (lexer.has("quotedValue") + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), r"primArgAnn$ebnf$5$subexpression$1$ebnf$1", @@ -918,7 +918,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$5$subexpression$2$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -930,7 +930,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$5$subexpression$2$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -942,7 +942,7 @@ class MichelineGrammar { { "name": r"primArgAnn$ebnf$5$subexpression$2", "symbols": [ - (lexer.has("quotedValue") + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), r"primArgAnn$ebnf$5$subexpression$2$ebnf$1", @@ -960,39 +960,39 @@ class MichelineGrammar { { "name": "primArgAnn", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"prim\""}, r"primArgAnn$ebnf$1", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("quotedValue") + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("quotedValue") ? {'type': "quotedValue"} : quotedValue), - (lexer.has("comma") ? {'type': "comma"} : comma), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("comma") ? {'type': "comma"} : comma), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"args\""}, r"primArgAnn$ebnf$2", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("lbracket") ? {'type': "lbracket"} : lbracket), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("lbracket") ? {'type': "lbracket"} : lbracket), + (lexer!.has("_") ? {'type': "_"} : _), r"primArgAnn$ebnf$3", - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbracket") ? {'type': "rbracket"} : rbracket), - (lexer.has("comma") ? {'type': "comma"} : comma), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbracket") ? {'type': "rbracket"} : rbracket), + (lexer!.has("comma") ? {'type': "comma"} : comma), + (lexer!.has("_") ? {'type': "_"} : _), {"literal": "\"annots\""}, r"primArgAnn$ebnf$4", - (lexer.has("colon") ? {'type': "colon"} : colon), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("lbracket") ? {'type': "lbracket"} : lbracket), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("colon") ? {'type': "colon"} : colon), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("lbracket") ? {'type': "lbracket"} : lbracket), + (lexer!.has("_") ? {'type': "_"} : _), r"primArgAnn$ebnf$5", - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbracket") ? {'type': "rbracket"} : rbracket), - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbracket") ? {'type': "rbracket"} : rbracket), + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": primArgAnnToHex }, @@ -1034,15 +1034,15 @@ class MichelineGrammar { { "name": "anyArray", "symbols": [ - (lexer.has("lbracket") ? {'type': "lbracket"} : lbracket), - (lexer.has("rbracket") ? {'type': "rbracket"} : rbracket) + (lexer!.has("lbracket") ? {'type': "lbracket"} : lbracket), + (lexer!.has("rbracket") ? {'type': "rbracket"} : rbracket) ], "postprocess": (d) => '0200000000' }, { "name": r"anyArray$ebnf$1$subexpression$1$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -1054,7 +1054,7 @@ class MichelineGrammar { { "name": r"anyArray$ebnf$1$subexpression$1$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -1078,7 +1078,7 @@ class MichelineGrammar { { "name": r"anyArray$ebnf$1$subexpression$2$ebnf$1", "symbols": [ - (lexer.has("comma") ? {'type': "comma"} : comma) + (lexer!.has("comma") ? {'type': "comma"} : comma) ], "postprocess": id }, @@ -1090,7 +1090,7 @@ class MichelineGrammar { { "name": r"anyArray$ebnf$1$subexpression$2$ebnf$2", "symbols": [ - (lexer.has("_") ? {'type': "_"} : _) + (lexer!.has("_") ? {'type': "_"} : _) ], "postprocess": id }, @@ -1115,11 +1115,11 @@ class MichelineGrammar { { "name": "anyArray", "symbols": [ - (lexer.has("lbracket") ? {'type': "lbracket"} : lbracket), - (lexer.has("_") ? {'type': "_"} : _), + (lexer!.has("lbracket") ? {'type': "lbracket"} : lbracket), + (lexer!.has("_") ? {'type': "_"} : _), r"anyArray$ebnf$1", - (lexer.has("_") ? {'type': "_"} : _), - (lexer.has("rbracket") ? {'type': "rbracket"} : rbracket) + (lexer!.has("_") ? {'type': "_"} : _), + (lexer!.has("rbracket") ? {'type': "rbracket"} : rbracket) ], "postprocess": staticArrayToHex } diff --git a/lib/michelson_parser/parser/michelson_grammar.dart b/lib/michelson_parser/parser/michelson_grammar.dart index 8c23af1..4302b92 100644 --- a/lib/michelson_parser/parser/michelson_grammar.dart +++ b/lib/michelson_parser/parser/michelson_grammar.dart @@ -1,7 +1,7 @@ import 'package:tezster_dart/michelson_parser/grammar/michelson_grammar_tokenizer.dart'; class MichelsonGrammar { - MichelsonGrammarTokenizer lexer; + MichelsonGrammarTokenizer? lexer; var macroCADRconst = 'C[AD]+R'; var macroSETCADRconst = 'SET_C[AD]+R'; @@ -669,7 +669,7 @@ class MichelsonGrammar { { "name": "parameterValue", "symbols": [ - (lexer.has("parameter") ? {'type': "parameter"} : parameter), + (lexer!.has("parameter") ? {'type': "parameter"} : parameter), "_", "typeData", "_", @@ -680,7 +680,7 @@ class MichelsonGrammar { { "name": "storageValue", "symbols": [ - (lexer.has("storage") ? {'type': "storage"} : storage), + (lexer!.has("storage") ? {'type': "storage"} : storage), "_", "typeData", "_", @@ -691,7 +691,7 @@ class MichelsonGrammar { { "name": "parameter", "symbols": [ - (lexer.has("parameter") ? {'type': "parameter"} : parameter), + (lexer!.has("parameter") ? {'type': "parameter"} : parameter), "_", "type", "_", @@ -702,7 +702,7 @@ class MichelsonGrammar { { "name": "storage", "symbols": [ - (lexer.has("storage") ? {'type': "storage"} : storage), + (lexer!.has("storage") ? {'type': "storage"} : storage), "_", "type", "_", @@ -713,7 +713,7 @@ class MichelsonGrammar { { "name": "code", "symbols": [ - (lexer.has("code") ? {'type': "code"} : code), + (lexer!.has("code") ? {'type': "code"} : code), "_", "subInstruction", "_", @@ -725,7 +725,7 @@ class MichelsonGrammar { { "name": "code", "symbols": [ - (lexer.has("code") ? {'type': "code"} : code), + (lexer!.has("code") ? {'type': "code"} : code), "_", {"literal": "{};"} ], @@ -734,7 +734,7 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("comparableType") + (lexer!.has("comparableType") ? {'type': "comparableType"} : comparableType) ], @@ -743,7 +743,7 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("constantType") + (lexer!.has("constantType") ? {'type': "constantType"} : constantType) ], @@ -752,7 +752,7 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("singleArgType") + (lexer!.has("singleArgType") ? {'type': "singleArgType"} : singleArgType), "_", @@ -763,41 +763,41 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("singleArgType") + (lexer!.has("singleArgType") ? {'type': "singleArgType"} : singleArgType), "_", "type", "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": singleArgKeywordWithParenToJson }, { "name": "type", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("singleArgType") + (lexer!.has("singleArgType") ? {'type': "singleArgType"} : singleArgType), "_", - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", "type", "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen), + (lexer!.has("rparen") ? {'type': "rparen"} : rparen), "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": singleArgKeywordWithParenToJson }, { "name": "type", "symbols": [ - (lexer.has("doubleArgType") + (lexer!.has("doubleArgType") ? {'type': "doubleArgType"} : doubleArgType), "_", @@ -810,9 +810,9 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("doubleArgType") + (lexer!.has("doubleArgType") ? {'type': "doubleArgType"} : doubleArgType), "_", @@ -820,7 +820,7 @@ class MichelsonGrammar { "_", "type", "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": doubleArgKeywordWithParenToJson }, @@ -828,7 +828,7 @@ class MichelsonGrammar { "name": r"type$ebnf$1$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -839,7 +839,7 @@ class MichelsonGrammar { "name": r"type$ebnf$1$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -850,7 +850,7 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("comparableType") + (lexer!.has("comparableType") ? {'type': "comparableType"} : comparableType), r"type$ebnf$1" @@ -861,7 +861,7 @@ class MichelsonGrammar { "name": r"type$ebnf$2$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -872,7 +872,7 @@ class MichelsonGrammar { "name": r"type$ebnf$2$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -883,7 +883,7 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("constantType") + (lexer!.has("constantType") ? {'type': "constantType"} : constantType), r"type$ebnf$2" @@ -894,7 +894,7 @@ class MichelsonGrammar { "name": r"type$ebnf$3$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -905,7 +905,7 @@ class MichelsonGrammar { "name": r"type$ebnf$3$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -916,14 +916,14 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("comparableType") + (lexer!.has("comparableType") ? {'type': "comparableType"} : comparableType), r"type$ebnf$3", "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": comparableTypeToJson }, @@ -931,7 +931,7 @@ class MichelsonGrammar { "name": r"type$ebnf$4$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -942,7 +942,7 @@ class MichelsonGrammar { "name": r"type$ebnf$4$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -953,14 +953,14 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("constantType") + (lexer!.has("constantType") ? {'type': "constantType"} : constantType), r"type$ebnf$4", "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": comparableTypeToJson }, @@ -968,7 +968,7 @@ class MichelsonGrammar { "name": r"type$ebnf$5$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -979,7 +979,7 @@ class MichelsonGrammar { "name": r"type$ebnf$5$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -990,15 +990,15 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("singleArgType") + (lexer!.has("singleArgType") ? {'type': "singleArgType"} : singleArgType), r"type$ebnf$5", "_", "type", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": singleArgTypeKeywordWithParenToJson }, @@ -1006,7 +1006,7 @@ class MichelsonGrammar { "name": r"type$ebnf$6$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1017,7 +1017,7 @@ class MichelsonGrammar { "name": r"type$ebnf$6$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1028,9 +1028,9 @@ class MichelsonGrammar { { "name": "type", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("doubleArgType") + (lexer!.has("doubleArgType") ? {'type': "doubleArgType"} : doubleArgType), r"type$ebnf$6", @@ -1038,14 +1038,14 @@ class MichelsonGrammar { "type", "_", "type", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": doubleArgTypeKeywordWithParenToJson }, { "name": "typeData", "symbols": [ - (lexer.has("singleArgType") + (lexer!.has("singleArgType") ? {'type': "singleArgType"} : singleArgType), "_", @@ -1056,22 +1056,22 @@ class MichelsonGrammar { { "name": "typeData", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("singleArgType") + (lexer!.has("singleArgType") ? {'type': "singleArgType"} : singleArgType), "_", "typeData", "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": singleArgKeywordWithParenToJson }, { "name": "typeData", "symbols": [ - (lexer.has("doubleArgType") + (lexer!.has("doubleArgType") ? {'type': "doubleArgType"} : doubleArgType), "_", @@ -1084,9 +1084,9 @@ class MichelsonGrammar { { "name": "typeData", "symbols": [ - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", - (lexer.has("doubleArgType") + (lexer!.has("doubleArgType") ? {'type': "doubleArgType"} : doubleArgType), "_", @@ -1094,7 +1094,7 @@ class MichelsonGrammar { "_", "typeData", "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen) + (lexer!.has("rparen") ? {'type': "rparen"} : rparen) ], "postprocess": doubleArgKeywordWithParenToJson }, @@ -1111,30 +1111,30 @@ class MichelsonGrammar { { "name": "typeData", "symbols": [ - (lexer.has("number") ? {'type': "number"} : number) + (lexer!.has("number") ? {'type': "number"} : number) ], "postprocess": intToJson }, { "name": "typeData", "symbols": [ - (lexer.has("string") ? {'type': "string"} : string) + (lexer!.has("string") ? {'type': "string"} : string) ], "postprocess": stringToJson }, { "name": "typeData", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": (d) => [] }, { "name": "data", "symbols": [ - (lexer.has("constantData") + (lexer!.has("constantData") ? {'type': "constantData"} : constantData) ], @@ -1143,7 +1143,7 @@ class MichelsonGrammar { { "name": "data", "symbols": [ - (lexer.has("singleArgData") + (lexer!.has("singleArgData") ? {'type': "singleArgData"} : singleArgData), "_", @@ -1154,7 +1154,7 @@ class MichelsonGrammar { { "name": "data", "symbols": [ - (lexer.has("doubleArgData") + (lexer!.has("doubleArgData") ? {'type': "doubleArgData"} : doubleArgData), "_", @@ -1177,30 +1177,30 @@ class MichelsonGrammar { { "name": "data", "symbols": [ - (lexer.has("string") ? {'type': "string"} : string) + (lexer!.has("string") ? {'type': "string"} : string) ], "postprocess": stringToJson }, { "name": "data", "symbols": [ - (lexer.has("bytes") ? {'type': "bytes"} : bytes) + (lexer!.has("bytes") ? {'type': "bytes"} : bytes) ], "postprocess": bytesToJson }, { "name": "data", "symbols": [ - (lexer.has("number") ? {'type': "number"} : number) + (lexer!.has("number") ? {'type': "number"} : number) ], "postprocess": intToJson }, { "name": "subData", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": (d) => "[]" }, @@ -1295,9 +1295,9 @@ class MichelsonGrammar { { "name": "subElt", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": (d) => "[]" }, @@ -1355,7 +1355,7 @@ class MichelsonGrammar { { "name": "elt", "symbols": [ - (lexer.has("elt") ? {'type': "elt"} : elt), + (lexer!.has("elt") ? {'type': "elt"} : elt), "_", "data", "_", @@ -1366,9 +1366,9 @@ class MichelsonGrammar { { "name": "subTypeData", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": (d) => "[]" }, @@ -1499,9 +1499,9 @@ class MichelsonGrammar { { "name": "subTypeElt", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": (d) => "[]" }, @@ -1634,7 +1634,7 @@ class MichelsonGrammar { { "name": "typeElt", "symbols": [ - (lexer.has("elt") ? {'type': "elt"} : elt), + (lexer!.has("elt") ? {'type': "elt"} : elt), "_", "typeData", "_", @@ -1645,20 +1645,20 @@ class MichelsonGrammar { { "name": "subInstruction", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": (d) => "" }, { "name": "subInstruction", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", "instruction", "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": (d) => d[2] }, @@ -1667,7 +1667,7 @@ class MichelsonGrammar { "symbols": [ "instruction", "_", - (lexer.has("semicolon") ? {'type': "semicolon"} : semicolon), + (lexer!.has("semicolon") ? {'type': "semicolon"} : semicolon), "_" ] }, @@ -1680,7 +1680,7 @@ class MichelsonGrammar { "symbols": [ "instruction", "_", - (lexer.has("semicolon") ? {'type': "semicolon"} : semicolon), + (lexer!.has("semicolon") ? {'type': "semicolon"} : semicolon), "_" ] }, @@ -1695,12 +1695,12 @@ class MichelsonGrammar { { "name": "subInstruction", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", r"subInstruction$ebnf$1", "instruction", "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": instructionSetToJsonNoSemi }, @@ -1709,7 +1709,7 @@ class MichelsonGrammar { "symbols": [ "instruction", "_", - (lexer.has("semicolon") ? {'type': "semicolon"} : semicolon), + (lexer!.has("semicolon") ? {'type': "semicolon"} : semicolon), "_" ] }, @@ -1722,7 +1722,7 @@ class MichelsonGrammar { "symbols": [ "instruction", "_", - (lexer.has("semicolon") ? {'type': "semicolon"} : semicolon), + (lexer!.has("semicolon") ? {'type': "semicolon"} : semicolon), "_" ] }, @@ -1737,17 +1737,17 @@ class MichelsonGrammar { { "name": "subInstruction", "symbols": [ - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", r"subInstruction$ebnf$2", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": instructionSetToJsonSemi }, { "name": "instructions", "symbols": [ - (lexer.has("baseInstruction") + (lexer!.has("baseInstruction") ? {'type': "baseInstruction"} : baseInstruction) ] @@ -1755,25 +1755,25 @@ class MichelsonGrammar { { "name": "instructions", "symbols": [ - (lexer.has("macroCADR") ? {'type': "macroCADR"} : macroCADR) + (lexer!.has("macroCADR") ? {'type': "macroCADR"} : macroCADR) ] }, { "name": "instructions", "symbols": [ - (lexer.has("macroDIP") ? {'type': "macroDIP"} : macroDIP) + (lexer!.has("macroDIP") ? {'type': "macroDIP"} : macroDIP) ] }, { "name": "instructions", "symbols": [ - (lexer.has("macroDUP") ? {'type': "macroDUP"} : macroDUP) + (lexer!.has("macroDUP") ? {'type': "macroDUP"} : macroDUP) ] }, { "name": "instructions", "symbols": [ - (lexer.has("macroSETCADR") + (lexer!.has("macroSETCADR") ? {'type': "macroSETCADR"} : macroSETCADR) ] @@ -1781,7 +1781,7 @@ class MichelsonGrammar { { "name": "instructions", "symbols": [ - (lexer.has("macroASSERTlist") + (lexer!.has("macroASSERTlist") ? {'type': "macroASSERTlist"} : macroASSERTlist) ] @@ -1800,7 +1800,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$1$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1811,7 +1811,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$1$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1836,7 +1836,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$2$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1847,7 +1847,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$2$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1877,7 +1877,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$3$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1888,7 +1888,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$3$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1913,7 +1913,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$4$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1924,7 +1924,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$4$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1957,7 +1957,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$5$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -1968,7 +1968,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$5$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2008,7 +2008,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$6$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2019,7 +2019,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$6$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2051,7 +2051,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$7$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2062,7 +2062,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$7$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2103,8 +2103,8 @@ class MichelsonGrammar { "_", "type", "_", - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": pushToJson }, @@ -2112,7 +2112,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$8$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2123,7 +2123,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$8$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2195,7 +2195,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$11$subexpression$1", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2206,7 +2206,7 @@ class MichelsonGrammar { "name": r"instruction$ebnf$11$subexpression$2", "symbols": [ "_", - (lexer.has("annot") ? {'type': "annot"} : annot) + (lexer!.has("annot") ? {'type': "annot"} : annot) ] }, { @@ -2292,7 +2292,7 @@ class MichelsonGrammar { "symbols": [ {"literal": "CREATE_CONTRACT"}, "_", - (lexer.has("lbrace") ? {'type': "lbrace"} : lbrace), + (lexer!.has("lbrace") ? {'type': "lbrace"} : lbrace), "_", "parameter", "_", @@ -2300,7 +2300,7 @@ class MichelsonGrammar { "_", "code", "_", - (lexer.has("rbrace") ? {'type': "rbrace"} : rbrace) + (lexer!.has("rbrace") ? {'type': "rbrace"} : rbrace) ], "postprocess": subContractToJson }, @@ -2320,11 +2320,11 @@ class MichelsonGrammar { "symbols": [ {"literal": "EMPTY_MAP"}, "_", - (lexer.has("lparen") ? {'type': "lparen"} : lparen), + (lexer!.has("lparen") ? {'type': "lparen"} : lparen), "_", "type", "_", - (lexer.has("rparen") ? {'type': "rparen"} : rparen), + (lexer!.has("rparen") ? {'type': "rparen"} : rparen), "_", "type" ], diff --git a/lib/michelson_parser/parser/nearley.dart b/lib/michelson_parser/parser/nearley.dart index 760b48e..9e82794 100644 --- a/lib/michelson_parser/parser/nearley.dart +++ b/lib/michelson_parser/parser/nearley.dart @@ -6,15 +6,15 @@ import 'package:tezster_dart/michelson_parser/grammar/michelson_grammar_tokenize var fail = {}; class Nearley { - NearleyGrammar grammar; + NearleyGrammar? grammar; var options; var lexer; var lexerState; - var table; + late var table; - int current; - var results; + late int current; + late var results; static NearleyGrammar fromCompiled(Map rules, {start}) { var lexer = rules['Lexer']; @@ -33,15 +33,15 @@ class Nearley { options = { 'keepHistory': false, - 'lexer': grammar.lexer ?? new StreamLexer(), + 'lexer': grammar!.lexer ?? new StreamLexer(), }; lexer = options['lexer']; lexerState = null; var column = new Column(grammar, 0); - column.wants[grammar.start] = []; - column.predict(grammar.start); + column.wants![grammar!.start] = []; + column.predict(grammar!.start); column.process(); table = [column]; current = 0; @@ -109,7 +109,7 @@ class Nearley { finish() { var considerations = []; - var start = this.grammar.start; + var start = this.grammar!.start; var column = this.table[this.table.length - 1]; column.states.forEach((t) { if (t.rule.name == start && @@ -271,13 +271,13 @@ class Nearley { } class Column { - NearleyGrammar grammar; + NearleyGrammar? grammar; int index; - List states; - Map wants; - List scannable; - Map completed; + late List states; + Map? wants; + late List scannable; + Map? completed; Column(this.grammar, this.index) { states = []; @@ -287,10 +287,10 @@ class Column { } void predict(exp) { - var rules = grammar.byName[exp] ?? []; + var rules = grammar!.byName[exp] ?? []; for (var i = 0; i < rules.length; i++) { var r = rules[i]; - var wantBy = wants[exp]; + var wantBy = wants![exp]; var s = new ColumnState(r, 0, index, wantBy); states.add(s); } @@ -302,7 +302,7 @@ class Column { var _completed = this.completed; for (var w = 0; w < _states.length; w++) { - var state = _states[w]; + var state = _states[w]!; if (state.isComplete) { state.finish(); if (state.data != fail) { @@ -315,8 +315,8 @@ class Column { if (state.reference == index) { var exp = state.rule.name; - this.completed[exp] = this.completed[exp] ?? []; - this.completed[exp].add(state); + this.completed![exp] = this.completed![exp] ?? []; + this.completed![exp].add(state); } } } else { @@ -325,9 +325,9 @@ class Column { this.scannable.add(state); } - if (_wants[exp] != null) { + if (_wants![exp] != null) { _wants[exp].add(state); - if (_completed.containsKey(exp)) { + if (_completed!.containsKey(exp)) { var nulls = _completed[exp]; for (var i = 0; i < nulls.length; i++) { var right = nulls[i]; @@ -354,10 +354,10 @@ class ColumnState { var reference; var data; var wantedBy; - var isComplete; + late var isComplete; - ColumnState left; - var right; + ColumnState? left; + late var right; ColumnState(this.rule, this.dot, this.reference, this.wantedBy) { data = []; @@ -386,11 +386,11 @@ class ColumnState { List build() { var children = []; - var node = this; + ColumnState node = this; do { children.add( node.right is ColumnState ? node.right.data : node.right['data']); - node = node.left; + node = node.left!; } while (node.left != null); children = children.reversed.toList(); return children; @@ -399,23 +399,23 @@ class ColumnState { class NearleyError { var error; - int offset; + int? offset; var token; NearleyError(this.error); } class NearleyGrammar { - List rules; + List? rules; var start; var lexer; - var byName; + late var byName; NearleyGrammar(this.rules, this.start) { this.rules = rules; - this.start = start ?? this.rules[0].name; + this.start = start ?? this.rules![0].name; var byName = this.byName = {}; - this.rules.forEach((rule) { + this.rules!.forEach((rule) { if (!byName.containsKey(rule.name)) { byName[rule.name] = []; } @@ -458,7 +458,7 @@ class Rule { class StreamLexer { var buffer; - int index; + late int index; var line; var lastLineBreak; @@ -503,7 +503,7 @@ class StreamLexer { " col " + col.toString() + ":\n\n"; - var msg = List(); + var msg = []; for (var i = 0; i < lines.length; i++) { var line = lines[i]; msg.add( diff --git a/lib/models/key_store_model.dart b/lib/models/key_store_model.dart index 8dc8aad..2a5d61d 100644 --- a/lib/models/key_store_model.dart +++ b/lib/models/key_store_model.dart @@ -1,18 +1,18 @@ import 'package:flutter/cupertino.dart'; class KeyStoreModel { - String publicKey; - String secretKey; + String? publicKey; + String? secretKey; String publicKeyHash; var seed; - String email; - String password; - String secret; + String? email; + String? password; + String? secret; KeyStoreModel({ this.publicKey, this.secretKey, - @required this.publicKeyHash, + required this.publicKeyHash, this.seed, this.secret, this.email, diff --git a/lib/models/operation_model.dart b/lib/models/operation_model.dart index 29b8b95..6a2797c 100644 --- a/lib/models/operation_model.dart +++ b/lib/models/operation_model.dart @@ -1,22 +1,22 @@ import 'package:tezster_dart/helper/constants.dart'; class OperationModel { - String destination; - String amount; + String? destination; + String? amount; int storageLimit; - int gasLimit; - int counter; - String fee; - String source; + int? gasLimit; + int? counter; + String? fee; + String? source; String kind; - String publicKey; - String delegate; - Map script; + String? publicKey; + String? delegate; + Map? script; - Map parameters; + Map? parameters; - String pkh; - String secret; + String? pkh; + String? secret; OperationModel({ this.destination, diff --git a/lib/reporting/conseil_query_builder.dart b/lib/reporting/conseil_query_builder.dart index f33b0ef..0e5b3c2 100644 --- a/lib/reporting/conseil_query_builder.dart +++ b/lib/reporting/conseil_query_builder.dart @@ -3,10 +3,10 @@ import 'package:tezster_dart/types/tezos/query_types.dart'; class ConseilQueryBuilder { static blankQuery() { return { - 'fields': new List(), - 'predicates': new List(), - 'orderBy': new List(), - 'aggregation': new List(), + 'fields': [], + 'predicates': [], + 'orderBy': [], + 'aggregation': [], 'limit': 100 }; } diff --git a/lib/src/soft-signer/soft_signer.dart b/lib/src/soft-signer/soft_signer.dart index b848bb0..0ac74bd 100644 --- a/lib/src/soft-signer/soft_signer.dart +++ b/lib/src/soft-signer/soft_signer.dart @@ -9,16 +9,16 @@ enum SignerCurve { ED25519, SECP256K1, SECP256R1 } class SoftSigner { var _secretKey; var _lockTimout; - var _passphrase; - var _salt; - var _unlocked; + late var _passphrase; + late var _salt; + late var _unlocked; var _key; SoftSigner( - {Uint8List secretKey, + {Uint8List? secretKey, int validity = -1, String passphrase = '', - Uint8List salt}) { + Uint8List? salt}) { this._secretKey = secretKey; this._lockTimout = validity; this._passphrase = passphrase; @@ -51,7 +51,7 @@ class SoftSigner { return new SoftSigner(secretKey: secretKey); } - Uint8List getKey() { + Uint8List? getKey() { if (!_unlocked) { var k = CryptoUtils.decryptMessage(_secretKey, _passphrase, _salt); if (_lockTimout == 0) { @@ -72,7 +72,7 @@ class SoftSigner { Uint8List signOperation(Uint8List uint8list) { return CryptoUtils.signDetached(TezosMessageUtils.simpleHash(uint8list, 32), - Uint8List.fromList(getKey())); + Uint8List.fromList(getKey()!)); } SignerCurve getSignerCurve() { diff --git a/lib/src/tezster_dart.dart b/lib/src/tezster_dart.dart index ba546c9..061190e 100644 --- a/lib/src/tezster_dart.dart +++ b/lib/src/tezster_dart.dart @@ -1,14 +1,14 @@ -library tezster_dart; +library readcontr; import 'dart:async'; import 'dart:convert'; import 'dart:typed_data'; import 'dart:core'; +import 'package:conduit_password_hash/conduit_password_hash.dart'; import 'package:convert/convert.dart'; import 'package:blake2b/blake2b_hash.dart'; import 'package:crypto/crypto.dart'; import 'package:ed25519_hd_key/ed25519_hd_key.dart'; -import 'package:password_hash/password_hash.dart'; import 'package:bip39/bip39.dart' as bip39; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:tezster_dart/chain/tezos/tezos_message_utils.dart'; @@ -16,6 +16,8 @@ import 'package:tezster_dart/chain/tezos/tezos_node_reader.dart'; import 'package:tezster_dart/chain/tezos/tezos_node_writer.dart'; import 'package:tezster_dart/helper/constants.dart'; import 'package:tezster_dart/helper/http_helper.dart'; +import 'package:tezster_dart/michelson_parser/michelson_parser.dart'; +import 'package:tezster_dart/michelson_parser/parser/michelson_grammar.dart'; import 'package:tezster_dart/reporting/tezos/tezos_conseil_client.dart'; import 'package:tezster_dart/src/soft-signer/soft_signer.dart'; import 'package:tezster_dart/tezster_dart.dart'; @@ -32,7 +34,7 @@ class TezsterDart { } static Future> getKeysFromMnemonic({ - String mnemonic, + required String mnemonic, }) async { assert(mnemonic != null); Uint8List seed = bip39.mnemonicToSeed(mnemonic); @@ -45,8 +47,8 @@ class TezsterDart { } static Future> getKeysFromMnemonicAndPassphrase({ - String mnemonic, - String passphrase, + required String mnemonic, + required String passphrase, }) async { assert(mnemonic != null); assert(passphrase != null); @@ -58,7 +60,7 @@ class TezsterDart { static Future> restoreIdentityFromDerivationPath( String derivationPath, String mnemonic, - {String password = '', String pkh, bool validate = true}) async { + {String password = '', String? pkh, bool validate = true}) async { if (validate) { if (![12, 15, 18, 21, 24].contains(mnemonic.split(' ').length)) { throw new Exception("Invalid mnemonic length."); @@ -72,7 +74,7 @@ class TezsterDart { Uint8List seed = bip39.mnemonicToSeed(mnemonic); if (derivationPath != null && derivationPath.length > 0) { - KeyData keysource = ED25519_HD_KEY.derivePath(derivationPath, seed); + KeyData keysource = await ED25519_HD_KEY.derivePath(derivationPath, seed); var combinedKey = Uint8List.fromList(keysource.key + keysource.chainCode); keys = SodiumUtils.publicKey(combinedKey); } else { @@ -90,7 +92,7 @@ class TezsterDart { return [secretKey, publicKey, publicKeyHash]; } - static List getKeysFromSecretKey(String skKey) { + static List getKeysFromSecretKey(String? skKey) { Uint8List secretKeyBytes = GenerateKeys.writeKeyWithHint(skKey, 'edsk'); KeyPair keys = SodiumUtils.publicKey(secretKeyBytes); String pkKey = TezosMessageUtils.readKeyWithHint(keys.pk, 'edpk'); @@ -99,8 +101,8 @@ class TezsterDart { } static Future> unlockFundraiserIdentity({ - String mnemonic, - String email, + required String mnemonic, + required String email, String passphrase = "", }) async { assert(mnemonic != null); @@ -113,8 +115,8 @@ class TezsterDart { } static Future> signOperationGroup({ - String privateKey, - String forgedOperation, + required String privateKey, + required String forgedOperation, }) async { assert(privateKey != null); assert(forgedOperation != null); @@ -122,7 +124,7 @@ class TezsterDart { List hexStringToListOfInt = hex.decode(watermarkedForgedOperationBytesHex); Uint8List hashedWatermarkedOpBytes = - Blake2bHash.hashWithDigestSize(256, hexStringToListOfInt); + Blake2bHash.hashWithDigestSize(256, hexStringToListOfInt as Uint8List); Uint8List privateKeyBytes = bs58check.decode(privateKey); List pkB = List.from(privateKeyBytes); pkB.removeRange(0, 4); @@ -133,14 +135,14 @@ class TezsterDart { ); String opSignatureHex = hex.encode(value); String hexStringToEncode = '09f5cd8612' + opSignatureHex; - Uint8List hexDeco = hex.decode(hexStringToEncode); + Uint8List hexDeco = hex.decode(hexStringToEncode) as Uint8List; String hexSignature = bs58check.encode(hexDeco); String signedOpBytes = forgedOperation + opSignatureHex; return [hexSignature, signedOpBytes]; } static Future> _unlockKeys({ - String mnemonic, + required String mnemonic, String passphrase = "", String email = "", }) async { @@ -158,7 +160,8 @@ class TezsterDart { List normalizedPassphrase = stringNormalize("$email" + "$passphrase"); String normString = String.fromCharCodes(normalizedPassphrase); String p = "mnemonic" + normString; - Uint8List seed = PBKDF2(hashAlgorithm: sha512).generateKey(m, p, 2048, 32); + Uint8List seed = + PBKDF2(hashAlgorithm: sha512).generateKey(m, p, 2048, 32) as Uint8List; KeyPair keyPair = Sodium.cryptoSignSeedKeypair(seed); String skKey = GenerateKeys.readKeysWithHint(keyPair.sk, '2bf64e07'); String pkKey = GenerateKeys.readKeysWithHint(keyPair.pk, '0d0f25d9'); @@ -228,7 +231,7 @@ class TezsterDart { SoftSigner signer, KeyStoreModel keyStore, int amount, - String delegate, + String? delegate, int fee, int storageLimit, int gasLimit, @@ -315,7 +318,7 @@ class TezsterDart { gasLimit, entrypoint, parameters, - parameterFormat: codeFormat ?? TezosParameterFormat.Micheline, + parameterFormat: codeFormat, offset: offset ?? 54); } @@ -369,4 +372,14 @@ class TezsterDart { return await TezosNodeReader.getValueForBigMapKey(server, index, key, block: 'head', chainid: 'main'); } + + static void exp(String contract) async { + var block = 'head'; + var chainid = 'main'; + var server = "https://edonet.smartpy.io"; + var res =await HttpHelper.performGetRequest(server, + 'chains/$chainid/blocks/$block/context/contracts/$contract/script',returnString: true); + var script =MichelsonParser.preProcessMichelsonScript(res); + print(script); + } } diff --git a/pubspec.lock b/pubspec.lock index 4f77ad6..98af72a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,21 +7,21 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.7.0" bip39: dependency: "direct main" description: name: bip39 url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.6" blake2b: dependency: "direct main" description: name: blake2b url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.1" boolean_selector: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: bs58check url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" characters: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -64,34 +64,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" + conduit_password_hash: + dependency: "direct main" + description: + name: conduit_password_hash + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.11" convert: dependency: "direct main" description: name: convert url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "3.0.1" crypto: dependency: "direct main" description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" cryptography: dependency: transitive description: name: cryptography url: "https://pub.dartlang.org" source: hosted - version: "1.4.1" + version: "2.0.2" ed25519_hd_key: dependency: "direct main" description: name: ed25519_hd_key url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.1.0" fake_async: dependency: transitive description: @@ -105,14 +112,14 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.1.2" fixnum: dependency: transitive description: name: fixnum url: "https://pub.dartlang.org" source: hosted - version: "0.10.11" + version: "1.0.0" flutter: dependency: "direct main" description: flutter @@ -124,26 +131,31 @@ packages: name: flutter_sodium url: "https://pub.dartlang.org" source: hosted - version: "0.1.11" + version: "0.2.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" hex: dependency: transitive description: name: hex url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.2" + version: "0.6.3" matcher: dependency: transitive description: @@ -157,14 +169,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" - password_hash: - dependency: "direct main" - description: - name: password_hash - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" + version: "1.7.0" path: dependency: transitive description: @@ -178,19 +183,26 @@ packages: name: pointycastle url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "3.2.0" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + sodium_web: + dependency: transitive + description: + name: sodium_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -225,7 +237,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.2" typed_data: dependency: transitive description: @@ -239,7 +251,7 @@ packages: name: unorm_dart url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" vector_math: dependency: transitive description: @@ -248,5 +260,5 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" - flutter: ">=1.10.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6934a90..77035e1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,20 +7,20 @@ repository: https://github.com/Tezsure/tezster_dart issue_tracker: https://github.com/Tezsure/tezster_dart/issues environment: - sdk: ">=2.3.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: sdk: flutter - bip39: ^1.0.3 - blake2b: ^0.1.2 - bs58check: ^1.0.1 - convert: ^2.1.1 - crypto: ^2.1.5 - flutter_sodium: ^0.1.9 - password_hash: ^2.0.0 - unorm_dart: ^0.1.2 - ed25519_hd_key: ^1.1.0 + bip39: ^1.0.6 + blake2b: ^0.2.1 + bs58check: ^1.0.2 + convert: ^3.0.1 + crypto: ^3.0.1 + flutter_sodium: ^0.2.0 + conduit_password_hash: ^3.0.11 + unorm_dart: ^0.2.0 + ed25519_hd_key: ^2.1.0 dev_dependencies: flutter_test: diff --git a/test/tezos_test.dart b/test/tezos_test.dart index 74562e3..736c00f 100644 --- a/test/tezos_test.dart +++ b/test/tezos_test.dart @@ -26,7 +26,7 @@ void main() { }); test('Restore account from secret key', () { - List keys = + List keys = TezsterDart.getKeysFromSecretKey(_keyStoreModel.secretKey); expect(keys[0], _keyStoreModel.secretKey); expect(keys[1], _keyStoreModel.publicKey);