@near-wallet-selector/core
Advanced tools
Comparing version 8.0.1 to 8.0.2
import type { SupportedLanguage } from "./translate/translate"; | ||
export declare type NetworkId = "mainnet" | "testnet"; | ||
export interface Network { | ||
/** | ||
* Network ID (e.g. `testnet`). | ||
*/ | ||
networkId: string; | ||
/** | ||
* URL for RPC requests. | ||
*/ | ||
nodeUrl: string; | ||
/** | ||
* URL for creating accounts. | ||
*/ | ||
helperUrl: string; | ||
/** | ||
* URL for the NEAR explorer. | ||
*/ | ||
explorerUrl: string; | ||
/** | ||
* URL for the NEAR indexer. | ||
*/ | ||
indexerUrl: string; | ||
} | ||
export interface Options { | ||
/** | ||
* ISO 639-1 two-letter language code. | ||
*/ | ||
languageCode: SupportedLanguage | undefined; | ||
/** | ||
* Resolved network configuration. | ||
*/ | ||
network: Network; | ||
/** | ||
* Whether internal logging is enabled. | ||
*/ | ||
debug: boolean; | ||
/** | ||
* Whether wallet order optimization is enabled. | ||
*/ | ||
optimizeWalletOrder: boolean; | ||
/** | ||
* Weather wallet order randomization is enabled. | ||
*/ | ||
randomizeWalletOrder: boolean; | ||
/** | ||
* The URL where DelegateActions are sent by meta transaction enabled wallet modules. | ||
*/ | ||
relayerUrl: string | undefined; | ||
} |
import type { BehaviorSubject, Observable } from "rxjs"; | ||
import type { Wallet, Account } from "./wallet"; | ||
export interface ContractState { | ||
/** | ||
* Account ID of the Smart Contract. | ||
*/ | ||
contractId: string; | ||
/** | ||
* List of methods that can only be invoked on the Smart Contract. Empty list means no restriction. | ||
*/ | ||
methodNames: Array<string>; | ||
} | ||
export declare type ModuleState<Variation extends Wallet = Wallet> = { | ||
/** | ||
* Unique identifier for the wallet. | ||
*/ | ||
id: Variation["id"]; | ||
/** | ||
* Type of the wallet. | ||
*/ | ||
type: Variation["type"]; | ||
/** | ||
* Meta information about the wallet. | ||
*/ | ||
metadata: Variation["metadata"]; | ||
/** | ||
* Access functionality of the wallet. | ||
*/ | ||
wallet(): Promise<Variation>; | ||
}; | ||
export declare type AccountState = Account & { | ||
/** | ||
* Is account set as active. | ||
*/ | ||
active: boolean; | ||
}; | ||
export interface WalletSelectorState { | ||
/** | ||
* Returns the signed in contract. | ||
*/ | ||
contract: ContractState | null; | ||
/** | ||
* Returns the list of available modules. | ||
*/ | ||
modules: Array<ModuleState>; | ||
/** | ||
* Returns the list of signed in accounts. | ||
*/ | ||
accounts: Array<AccountState>; | ||
/** | ||
* Returns the ID of the selected wallet. | ||
*/ | ||
selectedWalletId: string | null; | ||
/** | ||
* Returns ID-s of 5 recently signed in wallets. | ||
*/ | ||
recentlySignedInWallets: Array<string>; | ||
@@ -58,3 +94,9 @@ } | ||
export interface ReadOnlyStore { | ||
/** | ||
* Retrieve the current state. You can find more information on `WalletSelectorState` {@link https://github.com/near/wallet-selector/blob/main/packages/core/docs/api/state.md | here}. | ||
*/ | ||
getState(): WalletSelectorState; | ||
/** | ||
* Subscribe to state changes using the (RxJS) Observable pattern. You can find more information on `WalletSelectorState` {@link https://github.com/near/wallet-selector/blob/main/packages/core/docs/api/state.md | here}. | ||
*/ | ||
observable: Observable<WalletSelectorState>; | ||
@@ -61,0 +103,0 @@ } |
import type { WalletSelector, WalletSelectorParams } from "./wallet-selector.types"; | ||
/** | ||
* Initiates a wallet selector instance | ||
* @param {WalletSelectorParams} params Selector parameters (network, modules...) | ||
* @returns {Promise<WalletSelector>} Returns a WalletSelector object | ||
*/ | ||
export declare const setupWalletSelector: (params: WalletSelectorParams) => Promise<WalletSelector>; |
@@ -42,9 +42,32 @@ import type { Account, Wallet, WalletModuleFactory } from "./wallet/wallet.types"; | ||
export interface WalletSelector { | ||
/** | ||
* Resolved variation of the options passed to `setupWalletSelector`. | ||
*/ | ||
options: Options; | ||
/** | ||
* Wallet selector storage service | ||
*/ | ||
store: WalletSelectorStore; | ||
/** | ||
* Programmatically access wallets and call their methods. | ||
* It's advised to use `state.modules` if you only need access to `id`, `type` or `metadata` as it avoids initialising. | ||
* You can find more information on Wallet {@link https://github.com/near/wallet-selector/blob/main/packages/core/docs/api/wallet.md | here}. | ||
*/ | ||
wallet<Variation extends Wallet = Wallet>(id?: string): Promise<Variation>; | ||
/** | ||
* Determines whether we're signed in to one or more accounts. | ||
*/ | ||
isSignedIn(): boolean; | ||
/** | ||
* Programmatically change active account which will be used to sign and send transactions. | ||
*/ | ||
setActiveAccount(accountId: string): void; | ||
/** | ||
* Attach an event handler to important events. | ||
*/ | ||
on<EventName extends keyof WalletSelectorEvents>(eventName: EventName, callback: (event: WalletSelectorEvents[EventName]) => void): Subscription; | ||
/** | ||
* Removes the event handler attached to the given `event`. | ||
*/ | ||
off<EventName extends keyof WalletSelectorEvents>(eventName: EventName, callback: (event: WalletSelectorEvents[EventName]) => void): void; | ||
} |
@@ -9,19 +9,55 @@ import type { providers, utils } from "near-api-js"; | ||
interface BaseWalletMetadata { | ||
/** | ||
* Wallet name. | ||
*/ | ||
name: string; | ||
/** | ||
* Wallet description. | ||
*/ | ||
description: string | null; | ||
/** | ||
* Wallet icon url. | ||
*/ | ||
iconUrl: string; | ||
/** | ||
* Is wallet deprecated. | ||
*/ | ||
deprecated: boolean; | ||
/** | ||
* Will the wallet be shown in modal. | ||
*/ | ||
available: boolean; | ||
} | ||
export interface Account { | ||
/** | ||
* NEAR account identifier. | ||
*/ | ||
accountId: string; | ||
/** | ||
* Account public key. | ||
*/ | ||
publicKey?: string; | ||
} | ||
export interface SignInParams { | ||
/** | ||
* Account ID of the Smart Contract. | ||
*/ | ||
contractId: string; | ||
/** | ||
* Specify limited access to particular methods on the Smart Contract. | ||
*/ | ||
methodNames?: Array<string>; | ||
} | ||
export interface VerifyOwnerParams { | ||
/** | ||
* The message requested sign. Defaults to `verify owner` string. | ||
*/ | ||
message: string; | ||
/** | ||
* Applicable to browser wallets (e.g. MyNearWallet). This is the callback url once the signing is approved. Defaults to `window.location.href`. | ||
*/ | ||
callbackUrl?: string; | ||
/** | ||
* Applicable to browser wallets (e.g. MyNearWallet) extra data that will be passed to the callback url once the signing is approved. | ||
*/ | ||
meta?: string; | ||
@@ -38,20 +74,63 @@ } | ||
interface SignAndSendTransactionParams { | ||
/** | ||
* Account ID used to sign the transaction. Defaults to the first account. | ||
*/ | ||
signerId?: string; | ||
/** | ||
* Account ID to receive the transaction. Defaults to `contractId` defined in `init`. | ||
*/ | ||
receiverId?: string; | ||
/** | ||
* NEAR Action(s) to sign and send to the network (e.g. `FunctionCall`). You can find more information on `Action` {@link https://github.com/near/wallet-selector/blob/main/packages/core/docs/api/transactions.md | here}. | ||
*/ | ||
actions: Array<Action>; | ||
} | ||
interface SignAndSendTransactionsParams { | ||
/** | ||
* NEAR Transactions(s) to sign and send to the network. You can find more information on `Transaction` {@link https://github.com/near/wallet-selector/blob/main/packages/core/docs/api/transactions.md | here}. | ||
*/ | ||
transactions: Array<Optional<Transaction, "signerId">>; | ||
} | ||
interface BaseWalletBehaviour { | ||
/** | ||
* Programmatically sign in. Hardware wallets (e.g. Ledger) require `derivationPaths` to validate access key permissions. | ||
*/ | ||
signIn(params: SignInParams): Promise<Array<Account>>; | ||
/** | ||
* Sign out from the wallet. | ||
*/ | ||
signOut(): Promise<void>; | ||
/** | ||
* Returns one or more accounts when signed in. | ||
* This method can be useful for wallets that support accounts at once such as WalletConnect. | ||
* In this case, you can use an `accountId` returned as the `signerId` for `signAndSendTransaction`. | ||
*/ | ||
getAccounts(): Promise<Array<Account>>; | ||
/** | ||
* Signs the message and verifies the owner. Message is not sent to blockchain. | ||
*/ | ||
verifyOwner(params: VerifyOwnerParams): Promise<VerifiedOwner | void>; | ||
/** | ||
* Signs one or more NEAR Actions before sending to the network. | ||
* The user must be signed in to call this method as there's at least charges for gas spent. | ||
*/ | ||
signAndSendTransaction(params: SignAndSendTransactionParams): Promise<providers.FinalExecutionOutcome>; | ||
/** | ||
* Signs one or more transactions before sending to the network. | ||
* The user must be signed in to call this method as there's at least charges for gas spent. | ||
*/ | ||
signAndSendTransactions(params: SignAndSendTransactionsParams): Promise<Array<providers.FinalExecutionOutcome>>; | ||
} | ||
declare type BaseWallet<Type extends string, Metadata extends BaseWalletMetadata, Behaviour> = { | ||
/** | ||
* Unique identifier of the wallet. | ||
*/ | ||
id: string; | ||
/** | ||
* Returns the type of wallet. This is particular useful when using functionality that's wallet specific (see hardware wallet example). | ||
*/ | ||
type: Type; | ||
/** | ||
* Returns meta information about the wallet such as `name`, `description`, `iconUrl`, `deprecated` and `available` but can include wallet-specific properties such as `downloadUrl` and `useUrlAccountImport` for injected wallets or `contractId` and `runOnStartup` for instant-link wallets. | ||
*/ | ||
metadata: Metadata; | ||
@@ -77,13 +156,31 @@ } & Behaviour; | ||
export declare type BrowserWalletMetadata = BaseWalletMetadata & { | ||
/** | ||
* Optional for browser wallets (e.g MyNearWallet and HERE Wallet). After successfully signing in where to redirect. | ||
*/ | ||
successUrl?: string; | ||
/** | ||
* Optional for browser wallets (e.g MyNearWallet and HERE Wallet). After failing to sign in where to redirect. | ||
*/ | ||
failureUrl?: string; | ||
}; | ||
interface BrowserWalletSignInParams extends SignInParams { | ||
/** | ||
* Optional for browser wallets (e.g MyNearWallet and HERE Wallet). After successfully signing in where to redirect. | ||
*/ | ||
successUrl?: string; | ||
/** | ||
* Optional for browser wallets (e.g MyNearWallet and HERE Wallet). After failing to sign in where to redirect. | ||
*/ | ||
failureUrl?: string; | ||
} | ||
interface BrowserWalletSignAndSendTransactionParams extends SignAndSendTransactionParams { | ||
/** | ||
* Applicable to browser wallets (e.g. NEAR Wallet). This the callback url once the transaction is approved. | ||
*/ | ||
callbackUrl?: string; | ||
} | ||
interface BrowserWalletSignAndSendTransactionsParams extends SignAndSendTransactionsParams { | ||
/** | ||
* Applicable to browser wallets (e.g. NEAR Wallet). This the callback url once the transaction is approved. | ||
*/ | ||
callbackUrl?: string; | ||
@@ -130,2 +227,5 @@ } | ||
export interface HardwareWalletSignInParams extends SignInParams { | ||
/** | ||
* Required for hardware wallets (e.g. Ledger). This is a list of `accounts` linked to public keys on your device. | ||
*/ | ||
accounts: Array<HardwareWalletAccount>; | ||
@@ -140,2 +240,6 @@ } | ||
interface BridgeWalletSignInParams extends SignInParams { | ||
/** | ||
* Optional for bridge wallets (e.g Wallet Connect). | ||
* This indicates whether to render QR Code in wallet selector modal or use the default vendor modal. | ||
*/ | ||
qrCodeModal?: boolean; | ||
@@ -142,0 +246,0 @@ } |
{ | ||
"name": "@near-wallet-selector/core", | ||
"version": "8.0.1", | ||
"version": "8.0.2", | ||
"description": "This is the core package for NEAR Wallet Selector.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
446541
10997