0.12.1 • Published 3 years ago
@horizonx/aptos-wallet-connector v0.12.1
aptos-wallet-connector
Detail
Provides a common interface for aptos wallets in a minimal package.
| Function | Description | Arguments |
|---|---|---|
| connect | connect wallet | - |
| account | returns current account | - |
| network | returns current network name | - |
| chainId | returns current chainId | - |
| isConnected | returns connected or not | - |
| disconnect | disconnect wallet | - |
| signAndSubmitTransaction | call connected wallet to sign and submit transction | payload: Transaction Payload (optional) options: TransactionOptions |
| onAccountChanged | add listener callback on account changed | listener: (address: string | undefined) => VoidFunction (removeListener) |
| onNetworkChanged | add listener callback on network changed | listener: (payload: { network: string, chainId?: number}) => VoidFunction (removeListener) |
Installation
yarn add @horizonx/aptos-wallet-connectoror
npm install @horizonx/aptos-wallet-connectorBlocto
Dependencies:
@blocto/sdkExample:
import BloctoSDK from '@blocto/sdk' import { connect, WalletInterface, WalletType } from '@horizonx/aptos-wallet-connector' const walletClient: WalletInterface = await connect('blocto', new BloctoSDK({ aptos: { chainId: 1 } }).aptos!)
How to Use
import { connect, connectWalletWithProvider, WalletInterface, WalletType } from '@horizonx/aptos-wallet-connector'
const type: WalletType = 'aptos' // 'aptos'(petra) | 'fewcha' | 'martian' | 'pontem'
const walletClient: WalletInterface = await connect(type)
// If an external provider is required, it must be passed as the second argument.
const type: WalletType = 'blocto' // 'blocto'
const walletClient: WalletInterface = await connect(type, provider)See code example.
Features
| Function | Description | Arguments |
|---|---|---|
| connect | connect a wallet | type: Wallet Typeprovider?: External Provider |
| isSupportedWalletType | returns passed arg is supported wallet type or not | arg: any |
| lastConnectedWalletType | returns last connected wallet type | - |
| Constant | Description | type |
|---|---|---|
| SUPPORTED_WALLETS | array of supported wallet type strs | WalletType[] |
| ERRORS | dictionary of errors | Record<ErrorType, string> |
Errors
| ErrorType | Description |
|---|---|
| NOT_INSTALLED | wallet not installed |
| NOT_CONNECTED | wallet not connected |
| CANCELLED | request cancelled by user |
Supported Wallets
| Petra | Fewcha | Martian | Pontem | Blocto | |
|---|---|---|---|---|---|
| version | 1.0.5 | 0.4.8 | 1.1.4 | 2.1.1 | 0.3.9-beta |
| connect | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| account | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| network | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| chainId | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| isConnected | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| disconnect | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| signAndSubmitTransaction | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| onAccountChanged | :white_check_mark: | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :heavy_minus_sign: |
| onNetworkChanged | :white_check_mark: | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :heavy_minus_sign: |
0.10.0
3 years ago
0.11.0
3 years ago
0.10.1
3 years ago
0.9.0
3 years ago
0.12.0
3 years ago
0.8.0
3 years ago
0.12.1
3 years ago
0.9.2
3 years ago
0.9.1
3 years ago
0.7.1
3 years ago
0.7.0
3 years ago
0.6.0
3 years ago
0.5.1
3 years ago
0.5.0
3 years ago
0.4.0
3 years ago
0.3.1
3 years ago
0.3.0
3 years ago
0.2.0
3 years ago
0.1.0
3 years ago
0.0.1
3 years ago