Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

feat: utils - toStatusName. #36

Closed
wants to merge 1 commit into from
Closed

feat: utils - toStatusName. #36

wants to merge 1 commit into from

Conversation

nicolad
Copy link

@nicolad nicolad commented Apr 5, 2023

Resolves #30

  • There is an associated issue (required)
  • The change is described in detail
  • There are new or updated tests validating the change (if applicable)

Description

This PR adds a new helper function called toStatusName to easily display customized messages for a contract transaction. The function accepts a transaction object and an optional i18n object to allow for customizable messages and 18n support.

@nicolad nicolad requested a review from DoubleOTheven as a code owner April 5, 2023 06:38
Comment on lines +1 to +6
export * from "./call.ts";
export * from "./decodeContractExecResult.ts";
export * from "./decodeError.ts";
export * from "./toContractAbiMessage.ts";
export * from "./toRegistryErrorDecoded.ts";
export * from "./toStatusName.ts";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we need a .prettierrc to avoid inconsistent auto-save?
cc @DoubleOTheven

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolad You can set Deno as the formatter. It can format on save too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the denoland vscode plugin works well

@nicolad nicolad changed the title Feature: utils - toStatusName. feat: utils - toStatusName. Apr 5, 2023

export const toStatusName = (
status: ExtrinsicStatus | SubmittableResult | undefined,
i18n: I18n = defaultI18n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good exploration. I created that issue because this is a common task that could be made easier, or we could come up with better patterns to DRY up code.

  1. We want to be able to use string interpolation too.
  2. We also do not want to introduce a brand new system for handling translations. i18n-next, react-intl, etc already exist. Is there a way we can make them easier to use with useink? ( I don't know the answer to that yet).

Copy link
Contributor

@DoubleOTheven DoubleOTheven Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a Dapp using translations. I don't think there are examples of interpolation in there, but maybe those libraries are enough and we should not worry about it for useink. I'm curious to hear your thoughts

SubmittableResult,
} from "@polkadot/types/interfaces";

type I18n = { [key: string]: string };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key: should be typed to NotificationType instead of any string.

@DoubleOTheven
Copy link
Contributor

I'm closing this PR for now. A lot has changed for V 1.0.0. We should re-evaluate what features we want here

@nicolad nicolad deleted the toStatusName branch May 19, 2023 04:23
@nicolad
Copy link
Author

nicolad commented May 19, 2023

Thanks for explanations, @DoubleOTheven

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add helper functions to easily display customized messages for a contract transaction
2 participants