Skip to content

Commit

Permalink
Merge branch 'main' into feat/cip36-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy authored May 17, 2024
2 parents 10551bc + b73fbe6 commit f7aef41
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 51 deletions.
5 changes: 3 additions & 2 deletions catalyst_voices/lib/pages/coming_soon/logo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
);
}
Original file line number Diff line number Diff line change
@@ -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,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
5 changes: 4 additions & 1 deletion catalyst_voices/packages/catalyst_voices_assets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_svg: ^2.0.10+1

dev_dependencies:
build_runner: ^2.3.3
Expand Down Expand Up @@ -43,4 +44,6 @@ flutter_gen:
outputs:
class_name: VoicesColors
inputs:
- assets/colors/colors.xml
- assets/colors/colors.xml
integrations:
flutter_svg: true
7 changes: 4 additions & 3 deletions utilities/wallet-tester/src/common/components/TxBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,10 @@ function TxBuilder({ utxos, addresses, onSubmit: onPropSubmit = noop }: Props) {
onRemoveClick={() => resetField("networkId")}
render={() => (
<Input
type="text"
disabled={true}
placeholder="Auto generated"
type="number"
min={0}
max={1}
placeholder="0: testnet, 1: mainnet"
label="Network ID"
formRegister={register("networkId")}
/>
Expand Down
19 changes: 12 additions & 7 deletions utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
GeneralTransactionMetadata,
Int,
LinearFee,
NetworkId,
RewardAddress,
StakeCredential,
StakeDelegation,
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
7 changes: 6 additions & 1 deletion utilities/wallet-tester/src/common/helpers/getCardano.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { pickBy } from "lodash-es";
import type { WalletCollections } from "types/cardano";

export default function getCardano<T extends string | undefined>(
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)
}

0 comments on commit f7aef41

Please sign in to comment.