0.6.4 • Published 10 months ago

@uqbar/wallet-ui v0.6.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Uqbar Wallet UI Library

Contains the API, components, and store for the uqbar wallet.

This package is meant to be used in a React app.

NOTE: In order to use this library, you must import a global/polyfill for the Buffer dependency. The Ledger library requires a global Buffer to work properly.

Vite example: https://github.com/vitejs/vite/discussions/2785

Please contact ~fabnev-hinmur if you unsure about implementation.

Importing and Using the Wallet Inset

The useWalletStore hook will import the store and the initWallet function will initiate subscriptions and load accounts, assets, transactions, and token metadata.

You can choose to not load all info by passing options { assets: false, transactions: false } to initWallet. The assets option includes the metadata subscription.

The initWallet function can also check if the app is installed and install from the distro ship with initWallet({ prompt: true }).

The AccountSelector component is used to embed the Uqbar wallet in a React app. The onSelectAccount function fires whenever the user changes accounts and receives the selected Account object. Usually you would want to use the rawAddress (Hoon hexadecimal format) or address (just text with dots stripped) property.

Generating and Signing Transactions

New transactions are valided on the ship and saved in unsignedTransactions. The gas price, gas budget, and signature is then added in the signing step. There are thus two steps required to send a transaction.

useWalletStore

Properties

  • loadingText: string | null,
  • accounts: HotWallet[],
  • importedAccounts: HardwareWallet[],
  • metadata: TokenMetadataStore,
  • assets: Assets,
  • selectedTown: number,
  • transactions: Transaction[],
  • unsignedTransactions: Transactions,
  • mostRecentTransaction?: Transaction,

Methods

  • initWallet: (options: InitOptions) => Promise<void>,
  • setLoading: (loadingText: string | null) => void,
  • getAccounts: () => Promise<void>,
  • getTransactions: () => Promise<void>,
  • createAccount: (password: string, nick: string) => Promise<void>,
  • deriveNewAddress: (hdpath: string, nick: string, type?: HardwareWalletType) => Promise<void>,
  • trackAddress: (address: string, nick: string) => Promise<void>,
  • editNickname: (address: string, nick: string) => Promise<void>,
  • restoreAccount: (mnemonic: string, password: string, nick: string) => Promise<void>,
  • importAccount: (type: HardwareWalletType, nick: string) => Promise<void>,
  • deleteAccount: (address: string) => Promise<void>,
  • getSeed: () => Promise<Seed>,
  • setNode: (town: number, ship: string) => Promise<void>,
  • setIndexer: (ship: string) => Promise<void>,
  • sendTokens: (payload: SendTokenPayload) => Promise<void>,
  • sendNft: (payload: SendNftPayload) => Promise<void>,
  • sendCustomTransaction: (payload: SendCustomTransactionPayload) => Promise<void>,
  • getPendingHash: () => Promise<{ hash: string; txn: any; }>
  • deleteUnsignedTransaction: (address: string, hash: string) => Promise<void>
  • getUnsignedTransactions: () => Promise<{ [hash: string]: Transaction }>
  • submitSignedHash: (from: string, hash: string, rate: number, bud: number, ethHash?: string, sig?: { v: number; r: string; s: string; }) => Promise<void>
  • setMostRecentTransaction: (mostRecentTransaction?: Transaction) => void

Development

Clone this repo, run yarn link, then run yarn link "@uqbar/wallet-ui in the downstream repo, run yarn run dev from this repo.

0.4.13

11 months ago

0.4.12

11 months ago

0.6.3

10 months ago

0.6.2

10 months ago

0.6.4

10 months ago

0.5.0

11 months ago

0.6.1

10 months ago

0.6.0

10 months ago

0.4.10

11 months ago

0.4.11

11 months ago

0.2.9-dev

11 months ago

0.4.9

11 months ago

0.4.8

11 months ago

0.3.0

11 months ago

0.4.5

11 months ago

0.4.4

11 months ago

0.4.7

11 months ago

0.4.6

11 months ago

0.4.1

11 months ago

0.3.2

11 months ago

0.4.0

11 months ago

0.3.1

11 months ago

0.4.3

11 months ago

0.4.2

11 months ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.8

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago