npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@requestnetwork/create-invoice-form

v0.12.0

Published

[![npm version](https://badge.fury.io/js/%40requestnetwork%2Fcreate-invoice-form.svg)](https://badge.fury.io/js/%40requestnetwork%2Fcreate-invoice-form)

Downloads

2,187

Readme

Request Network Create Invoice Form Web Component

npm version

A web component for integrating the Request Network's Create Invoice Form into a web application.

Introduction

The Create Invoice Form component allows users to create a request using the Request Network. It is built using Svelte but compiled to a Web Component, making it usable in any web environment, regardless of the framework.

Installation

To install the component, use npm:

npm install @requestnetwork/create-invoice-form

Usage

Usage in React

create-invoice.tsx

You can directly pass props into the create-invoice-form web component without needing to create references or use workarounds.

import Head from "next/head";
import { config } from "@/utils/config";
import { useAppContext } from "@/utils/context";
import { currencies } from "@/utils/currencies";
import { rainbowKitConfig as wagmiConfig } from "@/utils/wagmiConfig";
import CreateInvoiceForm from "@requestnetwork/create-invoice-form/react";

export default function CreateInvoice() {
  const { requestNetwork } = useAppContext();

  return (
    <>
      <Head>
        <title>Request Invoicing - Create an Invoice</title>
      </Head>
      <div className="container m-auto  w-[100%]">
        <CreateInvoiceForm
          config={config}
          currencies={currencies}
          wagmiConfig={wagmiConfig}
          requestNetwork={requestNetwork}
        />
      </div>
    </>
  );
}

Important Note on Currencies Prop

  • The currencies prop is now optional.
  • If you include the currencies prop and follow the proper format, it will override the default currencies.
  • To use the default currencies list, simply omit the currencies prop.

Example Override for Currencies

If you need to customize the currencies list, ensure you follow the correct format:

export const currencies: CurrencyTypes.CurrencyInput[] = [
  {
    symbol: "FAU",
    address: "0x370DE27fdb7D1Ff1e1BaA7D11c5820a324Cf623C",
    network: "sepolia",
    decimals: 18,
    type: RequestLogicTypes.CURRENCY.ERC20,
  },
  {
    symbol: "ETH",
    network: "sepolia",
    decimals: 18,
    type: RequestLogicTypes.CURRENCY.ETH,
  },
];

When added, this will replace the default currencies list. To retain the defaults, do not include the currencies prop.

initializeRN.ts

Initialize the RequestNetwork object using an Ethers Signer or Viem WalletClient.

import { RequestNetwork } from "@requestnetwork/request-client.js";
import { Web3SignatureProvider } from "@requestnetwork/web3-signature";

export const initializeRequestNetwork = (setter: any, walletClient: any) => {
  try {
    const web3SignatureProvider = new Web3SignatureProvider(walletClient);

    const requestNetwork = new RequestNetwork({
      nodeConnectionConfig: {
        baseURL: "https://gnosis.gateway.request.network/",
      },
      signatureProvider: web3SignatureProvider,
    });

    setter(requestNetwork);
  } catch (error) {
    console.error("Failed to initialize the Request Network:", error);
    setter(null);
  }
};

wagmiConfig.ts

The wagmiConfig file configures wallet connections for the InvoiceDashboard component, using RainbowKit and supporting various wallets and blockchains.

For more details see Wagmi Docs

config.ts

Use the config object to pass additional configuration options to the create invoice form component.

Please replace the builderId with your own, arbitrarily chosen ID. This is used to track how many invoices are created by your application.

import { IConfig } from "@requestnetwork/shared";

export const config: IConfig = {
  builderId: "request-network", // Replace with your builder ID, arbitrarily chosen, used for metrics
  dashboardLink: "/",
  logo: "/assets/logo-sm.svg",
  colors: {
    main: "#0BB489",
    secondary: "#58E1A5",
  },
};

Supporting files

  • context.tsx - Use a context provider to reinitialize the Request Network instance when the wallet changes.
  • types.d.ts - Specify types to avoid TypeScript errors.

Features

| Feature | Status | | ------------------------------------ | ------ | | ERC20 Request | ✅ | | rnf_invoice format 0.3.0 | ✅ | | Configure Logo and Colors | ✅ | | Minimal Chains and Currencies | ✅ | | Compatible with all Wagmi connectors | ✅ | | Native Request | ❌ | | Conversion Request | ❌ | | Swap-to-Pay Request | ❌ | | Swap-to-Conversion Request | ❌ | | Escrow Request | ❌ | | Improved UI and UX | ❌ | | Auto-increment Invoice Number | ❌ | | Client Address List | ❌ | | Payment Recipient Address List | ❌ | | More Chains and Currencies | ❌ | | More Configuration Options | ❌ | | Attachments | ❌ |

Chains and Currencies

| Chain | Currencies | | -------- | ---------------------- | | Ethereum | USDC, USDT, DAI | | Polygon | USDC, USDT, DAI, USDCe | | Sepolia | USDC, FAU |

Additional Information

For more information, see the Request Network documentation.