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 e0e9688c74..0000000000 Binary files a/catalyst_voices/packages/catalyst_voices_assets/assets/images/logo.webp and /dev/null differ 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 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) +}