0.1.10 • Published 2 years ago

@layerzerolabs/ui-wallet v0.1.10

Weekly downloads
-
License
BUSL-1.1
Repository
-
Last release
2 years ago

Installation

yarn add @layerzerolabs/ui-wallet

pnpm add @layerzerolabs/ui-wallet

npm install @layerzerolabs/ui-wallet

Usage

This package's primary exports are the abstract class AbstractWallet and helper function assertWallet.

AbstractWallet

The abstract class AbstractWallet implements the Wallet interface.

interface Wallet<Signer> {
  isAvailable: boolean;
  isConnected: boolean;
  isConnecting: boolean;
  isSwitchingChain: boolean;
  // eg MetaMask
  type: string;
  address?: string;
  publicKey?: string;
  chainKey?: string | ChainKey;
  readonly chainType: ChainType;
  // native chain id eg: evm chain id
  nativeChainId?: number | string;
  signer?: Signer;
  connect(): Promise<void>;
  disconnect(): Promise<void>;
  autoConnect(): Promise<void>;
  switchChain(endpointId: number): Promise<void>;
  switchChain(chainKey: string): Promise<void>;
  getChainKey(): Promise<ChainKey | string | undefined>;
  getNativeChainId(): Promise<number>;
  getAddress(): Promise<string>;
}

This interface is used throughout our LayerZero application ecosystem to abstract the wallet specific implementation details from application code. See @layerzerolabs/ui-wallet-evm, @layerzerolabs/ui-wallet-aptos, and @layerzerolabs/ui-wallet-solana for already implemented wallet abstractions or for examples on how to add your own.

assertWallet

This helper function is provided to help verify that a connected wallet has matching configuration at a given time. An example might be checking that the wallet still has the same chain and address just before executing a transaction.

const wallet = walletStore.evm;

await assertWallet(wallet, {chainKey: 'ethereum', address: input.srcAddress});
// or
await assertWallet(wallet, {chainId: input.srcChainId, address: input.srcAddress});
0.1.10

2 years ago

1.0.0

2 years ago

0.1.2

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago