From bca05c5b78e9c5996b0d146bff398958d9d1c16b Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj <38898766+apskhem@users.noreply.github.com> Date: Fri, 17 May 2024 11:18:20 +0700 Subject: [PATCH 1/2] fix(wallet-tester): missing configurable aux hash and network ID (#500) * fix: aux hash * fix: filter pollution * chore: fmt * feat: enable network ID * fix: note typo * fix: typo --- .../src/common/components/TxBuilder.tsx | 7 ++++--- .../src/common/helpers/buildUnsignedTx.ts | 19 ++++++++++++------- .../src/common/helpers/getCardano.ts | 7 ++++++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/utilities/wallet-tester/src/common/components/TxBuilder.tsx b/utilities/wallet-tester/src/common/components/TxBuilder.tsx index 3f06a0d9f7..fe29b8f31b 100644 --- a/utilities/wallet-tester/src/common/components/TxBuilder.tsx +++ b/utilities/wallet-tester/src/common/components/TxBuilder.tsx @@ -354,9 +354,10 @@ function TxBuilder({ utxos, addresses, onSubmit: onPropSubmit = noop }: Props) { onRemoveClick={() => resetField("networkId")} render={() => ( diff --git a/utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts b/utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts index 4c12ef8e3d..59f981467b 100644 --- a/utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts +++ b/utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts @@ -11,6 +11,7 @@ import { GeneralTransactionMetadata, Int, LinearFee, + NetworkId, RewardAddress, StakeCredential, StakeDelegation, @@ -148,7 +149,7 @@ export default async function buildUnsignedTx( // #7 add auxiliary data hash if (builder.auxiliaryDataHash) { - // auto generated + // note: the hash will be set after building auxillary data } // #8 add validity interval start @@ -171,11 +172,6 @@ export default async function buildUnsignedTx( txBuilder.add_required_signer(Ed25519KeyHash.from_hex(stakeCred)); } - // #15 add network id - if (builder.networkId) { - // auto generated - } - // aux data const auxMetadata = AuxiliaryData.new(); const txMetadata = GeneralTransactionMetadata.new(); @@ -212,6 +208,7 @@ export default async function buildUnsignedTx( if (txMetadata.len()) { auxMetadata.set_metadata(txMetadata); + txBuilder.set_auxiliary_data(auxMetadata); } // generate fee incase too much ADA provided for fee @@ -221,7 +218,15 @@ export default async function buildUnsignedTx( } // build a full transaction, passing in empty witness set - const unsignedTx = Transaction.new(txBuilder.build(), TransactionWitnessSet.new(), auxMetadata); + const txBody = txBuilder.build(); + + // #15 add network id + if (builder.networkId && [0, 1].includes(Number(builder.networkId))) { + const networkId = Number(builder.networkId) === 0 ? NetworkId.testnet() : NetworkId.mainnet() + txBody.set_network_id(networkId); + } + + const unsignedTx = Transaction.new(txBody, TransactionWitnessSet.new(), auxMetadata); return unsignedTx; } diff --git a/utilities/wallet-tester/src/common/helpers/getCardano.ts b/utilities/wallet-tester/src/common/helpers/getCardano.ts index 68f491b6b4..b6e326b551 100644 --- a/utilities/wallet-tester/src/common/helpers/getCardano.ts +++ b/utilities/wallet-tester/src/common/helpers/getCardano.ts @@ -1,9 +1,14 @@ +import { pickBy } from "lodash-es"; import type { WalletCollections } from "types/cardano"; export default function getCardano( walletName?: T ): T extends string ? WalletCollections[string] : WalletCollections { - return (walletName ? globalThis.cardano[walletName] : globalThis.cardano) as T extends string + return (walletName ? globalThis.cardano[walletName] : filterPolluteObjects(globalThis.cardano)) as T extends string ? WalletCollections[string] : WalletCollections; } + +function filterPolluteObjects(cardano: any): WalletCollections { + return pickBy(cardano, (v) => typeof v === "object" && "enable" in v) +} From b73fbe60fec6f8cbca0d4c6d4d4c83076f002d0b Mon Sep 17 00:00:00 2001 From: Lucio Baglione Date: Fri, 17 May 2024 13:06:30 +0200 Subject: [PATCH 2/2] feat: Add svg support to flutter (#498) * feat: Add svg support for flutter_gen and add `CatalystSvgPicture` wrapper. * feat: Add Catalyst SVG logo version. --- .../lib/pages/coming_soon/logo.dart | 5 +- .../assets/images/catalyst_logo.svg | 75 ++++++++++++++++++ .../assets/images/logo.webp | Bin 3694 -> 0 bytes .../lib/generated/assets.gen.dart | 65 ++++++++++++++- .../lib/src/catalyst_image.dart | 64 ++++++++------- .../lib/src/catalyst_svg_picture.dart | 43 ++++++++++ .../lib/src/catalyst_voices_assets.dart | 1 + .../catalyst_voices_assets/pubspec.yaml | 5 +- 8 files changed, 218 insertions(+), 40 deletions(-) create mode 100644 catalyst_voices/packages/catalyst_voices_assets/assets/images/catalyst_logo.svg delete mode 100644 catalyst_voices/packages/catalyst_voices_assets/assets/images/logo.webp create mode 100644 catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart diff --git a/catalyst_voices/lib/pages/coming_soon/logo.dart b/catalyst_voices/lib/pages/coming_soon/logo.dart index d3854da508..c5a54104c0 100644 --- a/catalyst_voices/lib/pages/coming_soon/logo.dart +++ b/catalyst_voices/lib/pages/coming_soon/logo.dart @@ -12,8 +12,9 @@ class ComingSoonLogo extends StatelessWidget { return Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - CatalystImage.asset( - VoicesAssets.images.logo.path, + CatalystSvgPicture.asset( + VoicesAssets.images.catalystLogo.path, + width: 202, ), Container( margin: const EdgeInsets.only(left: 13, bottom: 6), diff --git a/catalyst_voices/packages/catalyst_voices_assets/assets/images/catalyst_logo.svg b/catalyst_voices/packages/catalyst_voices_assets/assets/images/catalyst_logo.svg new file mode 100644 index 0000000000..a45832d93d --- /dev/null +++ b/catalyst_voices/packages/catalyst_voices_assets/assets/images/catalyst_logo.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/catalyst_voices/packages/catalyst_voices_assets/assets/images/logo.webp b/catalyst_voices/packages/catalyst_voices_assets/assets/images/logo.webp deleted file mode 100644 index e0e9688c742c7231e603873474d245b69d2f7368..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3694 zcmV-!4w3OvNk&Fy4gdgGMM6+kP&il$0000G0002V0021v06|PpNMHv500FR7ZJQ8R z)+eDHq#O(m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*5ac7;3OQL?{Y+#hAo9ijvSD$d-~x9)J*yN#4OZ zgc1TEAN@(QE2HN)KmXS8 z&YgIdkz=SqtZDGu?hpgul8H(*xmcpoTs0?ru>=3P)JUKZhM>%Ao?L1P+ZBf82M8-vb@HRE1yIM~UbQ#~ z4$q76Vs!kiPxmyrBsg`U#o2xSTgv9*R@z)V4&3&>Yj$0oFjJeQu-=J_`%Sg7m6?B7H232`bVJ(`X7;Z zP;`^Rifj8#{Uh#4wp;=Lzzd)a!Wb-{pRW*i>#XwT=8t9X-FgSc_#Lpt--p5*1M#Fp M8`|&)0m=XX05+gB8UO$Q diff --git a/catalyst_voices/packages/catalyst_voices_assets/lib/generated/assets.gen.dart b/catalyst_voices/packages/catalyst_voices_assets/lib/generated/assets.gen.dart index 467a659fa9..e2079b0e71 100644 --- a/catalyst_voices/packages/catalyst_voices_assets/lib/generated/assets.gen.dart +++ b/catalyst_voices/packages/catalyst_voices_assets/lib/generated/assets.gen.dart @@ -8,10 +8,16 @@ // ignore_for_file: directives_ordering,unnecessary_import,implicit_dynamic_list_literal,deprecated_member_use import 'package:flutter/widgets.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:flutter/services.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); + /// File path: assets/images/catalyst_logo.svg + SvgGenImage get catalystLogo => + const SvgGenImage('assets/images/catalyst_logo.svg'); + /// File path: assets/images/coming_soon_bkg.webp AssetGenImage get comingSoonBkg => const AssetGenImage('assets/images/coming_soon_bkg.webp'); @@ -20,11 +26,9 @@ class $AssetsImagesGen { AssetGenImage get dummyCatalystVoices => const AssetGenImage('assets/images/dummy_catalyst_voices.webp'); - /// File path: assets/images/logo.webp - AssetGenImage get logo => const AssetGenImage('assets/images/logo.webp'); - /// List of all assets - List get values => [comingSoonBkg, dummyCatalystVoices, logo]; + List get values => + [catalystLogo, comingSoonBkg, dummyCatalystVoices]; } class VoicesAssets { @@ -106,3 +110,56 @@ class AssetGenImage { String get keyName => _assetName; } + +class SvgGenImage { + const SvgGenImage(this._assetName); + + final String _assetName; + + SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + SvgTheme theme = const SvgTheme(), + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + return SvgPicture.asset( + _assetName, + key: key, + matchTextDirection: matchTextDirection, + bundle: bundle, + package: package, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + theme: theme, + colorFilter: colorFilter, + color: color, + colorBlendMode: colorBlendMode, + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } + + String get path => _assetName; + + String get keyName => _assetName; +} diff --git a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_image.dart b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_image.dart index cd96c3bf60..3584574450 100644 --- a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_image.dart +++ b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_image.dart @@ -1,12 +1,12 @@ import 'package:flutter/widgets.dart'; -/// [CatalystImage] is a wrapper around [Image.asset] that sets the package -/// property to `catalyst_voices_assets` by default. -/// This allows the package to be used without having to specify -/// the package name every time. +/// [CatalystImage] extends [Image] to have an asset constructor +/// tat sets the package property to `catalyst_voices_assets` by default. +/// This allows to use the asset without having to specify the package name +/// every time. /// For more information, see [Image.asset]. -final class CatalystImage { - static Image asset( +final class CatalystImage extends Image { + CatalystImage.asset( String name, { AssetBundle? bundle, ImageFrameBuilder? frameBuilder, @@ -30,31 +30,29 @@ final class CatalystImage { FilterQuality filterQuality = FilterQuality.low, int? cacheWidth, int? cacheHeight, - }) { - return Image.asset( - name, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - package: package, - ); - } + }) : super.asset( + name, + bundle: bundle, + frameBuilder: frameBuilder, + errorBuilder: errorBuilder, + semanticLabel: semanticLabel, + excludeFromSemantics: excludeFromSemantics, + scale: scale, + width: width, + height: height, + color: color, + opacity: opacity, + colorBlendMode: colorBlendMode, + fit: fit, + alignment: alignment, + repeat: repeat, + centerSlice: centerSlice, + matchTextDirection: matchTextDirection, + gaplessPlayback: gaplessPlayback, + isAntiAlias: isAntiAlias, + filterQuality: filterQuality, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + package: package, + ); } diff --git a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart new file mode 100644 index 0000000000..ff37a53415 --- /dev/null +++ b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart @@ -0,0 +1,43 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +/// [CatalystSvgPicture] extends [SvgPicture] to have an asset constructor +/// tat sets the package property to `catalyst_voices_assets` by default. +/// This allows to use the asset without having to specify the package name +/// every time. +/// For more information, see [SvgPicture.asset]. +final class CatalystSvgPicture extends SvgPicture { + CatalystSvgPicture.asset( + String name, { + AssetBundle? bundle, + String? semanticsLabel, + bool excludeFromSemantics = false, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + Alignment alignment = Alignment.center, + bool matchTextDirection = false, + String package = 'catalyst_voices_assets', + bool allowDrawingOutsideViewBox = false, + Widget Function(BuildContext)? placeholderBuilder, + Clip clipBehavior = Clip.hardEdge, + SvgTheme? theme, + ColorFilter? colorFilter, + }) : super.asset( + name, + bundle: bundle, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + width: width, + height: height, + fit: fit, + alignment: alignment, + matchTextDirection: matchTextDirection, + package: package, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + clipBehavior: clipBehavior, + theme: theme, + colorFilter: colorFilter, + ); +} diff --git a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_voices_assets.dart b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_voices_assets.dart index 8da60065f7..8530754a64 100644 --- a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_voices_assets.dart +++ b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_voices_assets.dart @@ -2,3 +2,4 @@ export 'package:catalyst_voices_assets/generated/assets.gen.dart'; export 'package:catalyst_voices_assets/generated/colors.gen.dart'; export 'package:catalyst_voices_assets/generated/fonts.gen.dart'; export 'package:catalyst_voices_assets/src/catalyst_image.dart'; +export 'package:catalyst_voices_assets/src/catalyst_svg_picture.dart'; diff --git a/catalyst_voices/packages/catalyst_voices_assets/pubspec.yaml b/catalyst_voices/packages/catalyst_voices_assets/pubspec.yaml index e7fa13292e..6743ad0b9d 100644 --- a/catalyst_voices/packages/catalyst_voices_assets/pubspec.yaml +++ b/catalyst_voices/packages/catalyst_voices_assets/pubspec.yaml @@ -10,6 +10,7 @@ environment: dependencies: flutter: sdk: flutter + flutter_svg: ^2.0.10+1 dev_dependencies: build_runner: ^2.3.3 @@ -43,4 +44,6 @@ flutter_gen: outputs: class_name: VoicesColors inputs: - - assets/colors/colors.xml \ No newline at end of file + - assets/colors/colors.xml + integrations: + flutter_svg: true \ No newline at end of file