🇵🇹
DAO Lunes Labs - PT
  • 👋Seja Bem-vindo a DAO Lunes Labs
  • Overview
    • 🚪Introdução
    • 🚀Manifesto DAO Lunes Labs
    • 🍕Tokenomics
    • 👑Proposta de Valor
    • 🧑‍🚀Comunidade e Participação
    • 🗺️Roadmap
    • 💼Compromisso com Ética e Responsabilidade
    • 👾Programa de Bug Bounty: Lunes Security Initiative (LSI)
  • Developers
    • 💽Para Nodes
      • 🥾Instalar Node
        • 🏗️Rust toolchain
        • 🐧Linux
    • 🖥️Para Desenvolvedores
      • 📑Smart Contract Ink! 4.x
        • ✨Configuração
          • 📐Criando um projeto com ink!
          • 🖥️Compile Seu Contrato
          • ⛓️Executar um nó Lunes
          • ⬆️Implante seu contrato
          • 🔛Chame Seu Contrato
          • 🛠️Solução de problemas
        • 🪄Fundamentos
          • 👾Modelo de Contrato
          • 👨‍🚀Armazenando Valores
          • 🔭Lendo Valores do Armazenamento
          • 🦸‍♂️Alterando os Valores de Armazenamento
          • 🎡Eventos
          • 👨‍🔧Seletores
          • 🪶Definições de Trait
          • 🗣️Chamadas entre Contratos (Cross-Contract Calls)
          • 🦸Contratos Atualizáveis
          • 🤺Funções do Ambiente
          • 🏟️Tipos de Ambiente de Cadeia
          • 💠Metadados
          • 🧪Testes de Contrato
          • 🕵️‍♂️Depuração de Contratos
          • 🔬Verificação de Contrato
        • 🎙️Macros e Atributos
          • 📇#[ink::contract]
          • 👽#[ink(anonymous)]
          • 👷#[ink(constructor)]
          • 📏#[ink(default)]
          • 🎢#[ink(event)]
          • 🛩️#[ink(impl)]
          • 📧#[ink(message)]
          • 👨‍💼#[ink(namespace = "…")]
          • 💸#[ink(payable)]
          • ⚡#[ink(selector = S:u32)]
          • 💽#[ink(storage)]
          • 💣#[ink(topic)]
          • ⛓️#[ink::chain_extension]
        • 💽Storege & Data Structires
          • Working with Mapping
          • Storage Layout
          • Custom Data Structures
          • Metadata Format
        • 👾Frontend Development
          • Getting Started
          • Connect Wallet
          • Hooks
            • All Hooks
            • Contracts
              • useCall
              • useCallSubscription
              • useContract
              • useDryRun
              • useEventSubscription
              • useEvents
              • useTx
              • useTxPaymentInfo
            • Wallets
              • useWallet
              • useAllWallets
              • useInstalledWallets
              • useUninstalledWallets
            • API
              • useApi
              • useBalance
              • useBlockHeader
          • Configuration
          • useink / core
            • Contracts
              • Call
              • decodeCallResult
              • decodeError
              • getRegistryError
              • toAbiMessage
          • useink / chains
            • Getting Started
            • Chain Configurations
            • ChainId
          • useink / notifications
            • Getting Started
            • Configuration
            • useNotifications
            • toNotificationLevel
          • useink / utils
            • Getting Started
            • Pick Helpers
            • tx Helpers
            • Types
        • 💡Examples
          • 📔Smart Contracts
          • 📱Dapps
        • 🛠️Tools
          • 🖌️OpenBrush
      • 📒Smart Contract - EVM
        • Create ERC-20 Ink Token!
      • 💰Desenvolvendo uma Wallet Lunes
        • 👾Transações de Tokens PSP22
    • 🎨Para Designers
      • 🖌️Brand Lunes
Powered by GitBook
On this page
  • Notification type Conversion List​
  • Return Type​

Was this helpful?

  1. Developers
  2. Para Desenvolvedores
  3. Smart Contract Ink! 4.x
  4. Frontend Development
  5. useink / notifications

toNotificationLevel

An opinionated utility function to convert nofication type to a simplified severity level. There are four levels: info, warning, success, and error. This function is useful for mapping transaction status to colors in your UI.

Note that for transactions the Finalized status will convert to success, but this does not necessarily mean that the transaction was successful in the user's eyes. It means that the transaction has been processed, gas has been removed from the caller's balance, and the block has been finalized.

import { MyCustomSnackbar } from './MyCustomSnackbar'
import { useNotifications } from 'useink/notifications'

export const MyNotifications = ({ children }) => {
  const { notifications } = useNotifications()

  return (
    <ul>
      {notifications.map((n) => (
        <li key={n.id}>
          <MyCustomSnackbar
            message={n.message}
            type={
              // e.g. `info` might have a blue background, and `error` a red one.
              toNotificationLevel(n.type)
            } 
          /> 
        </li>
      ))}
    </ul>
  )
}
case 'None':
  return 'info';

case 'DryRun':
  return 'info';

case 'PendingSignature':
  return 'info';

case 'Future':
  return 'info';

case 'Ready':
  return 'info';

case 'Broadcast':
  return 'info';

// We optomistically assume that `InBlock` means that the transaction is `success`. 
// This will almost always end up reaching `Finalized` status.
case 'InBlock':
  return 'success';

case 'Retracted':
  return 'warning';

case 'FinalityTimeout':
  return 'error';

case 'Finalized':
  return 'success';

case 'Usurped':
  return 'error';

case 'Dropped':
  return 'error';

case 'Invalid':
  return 'warning';

case 'Errored':
  return 'error';

case 'WalletConnected':
  return 'info';

case 'WalletDisconnected':
  return 'info';

default:
  return 'info';
type NotificationLevel = 'success' | 'error' | 'warning' | 'info';

Last updated 1 year ago

Was this helpful?

Notification type Conversion List

Return Type

🖥️
📑
👾
​
​