0.0.1-alpha.19 • Published 3 days ago

@xlabs-libs/wallet-aggregator-core v0.0.1-alpha.19

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

Wallet Aggregator - Core

Basic Wallet abstractions to interact with blockchains.

In order to implement a wallet for a given chain through the sdk, simply import the Wallet class and extend from it. The abstraction defines a set of generic arguments to define the types the methods it will expect and interact with (e.g. a transaction request type, a message to sign, the result of submitting a tx to network, etc).

The Wallet class implements the EventEmitter interface, letting the client subscribe to the following events:

EventDescription
connectSignals the wallet has succesfully connected
disconnectSignals the wallet has succesfully disconnected
networkChangedSignals whether a change in the network was detected. Useful for working with EVM wallets.

New events can be added by extending the WalletEvents class.

Example:

import { Wallet, WalletEvents } from "@xlabs/wallet-aggregator-core";

// define types
type MyUnsignedTransactionType = // ...
// ...
interface MyEventsType extends WalletEvents {
  // ...
}

class MyBlockchainWallet extends Wallet<
  MyUnsignedTransactionType,
  MySignedTransactionType,
  MySignedTransactionType,
  MySubmitTransactionResultType,
  MyNetworkInfoType,
  MyMessageType,
  MyMessageResultType,
  MyEventsType
> {
  // code...
}

The blockchain IDs follow those of Wormhole. A constants file is provided with said chain ids.

Refer to the Wormhole documentation if you wish to know more about the project.