Skip to main content

bn.initUniversalWeb3Provider

initUniversalWeb3Provider(options?): Promise<{ result: UniversalProvider }>

Parameters

NameType
options?Pick<UniversalProviderOptions, "topicId" | "metaData">

Returns

Promise<{ result: UniversalProvider }>

Interface: UniversalProviderOptions

NameTypeDescription
rpcHooksRPCHooks
topicId?TopicId
metaData?ClientMetadata

Class: UniversalProvider

NameTypeDescription
topicIdTopicId
metaData?ClientMetadata
eventsSimpleEventEmitter
namespacesNamespaceRecord = {}
rpcAdaptorsRpcAdaptorMap = {}
rpcHooksRPCHooks
isConnectingboolean = false
on<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
once<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
removeListener<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
off<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
emit<E>(event: E, payload: EventArguments[E]) => boolean
isConnectedboolean
request(args, chain?): Promise<T>
sendAsync(args, callback, chain?): void
enable(__namedParameters?): Promise<string[]>
connect(__namedParameters?): Promise<void>
disconnect(): Promise<void>
setDefaultChain(chain): void
onAccountsChanged(accountsMap): void
initialize(): Promise<void>
createAdaptors(): void
registerEventListeners(): void
getAdaptor(namespace): IAdaptor
setNamespaces(accountsMap): void
validateChain(chain?): [Namespace, string]
requestAccounts(chain?): Promise<string[]>
onConnect(): void
onChainChanged(chain): void
init(options): Promise<UniversalProvider>

request

request<T>(args, chain?): Promise<T>

Type parameters

NameType
Tunknown

Parameters

NameType
argsRequestArgs
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

Promise<T>

Implementation of

IUniversalProvider.request


sendAsync

sendAsync<T>(args, callback, chain?): void

Type parameters

NameType
Tunknown

Parameters

NameType
argsRequestArgs
callback(error: null | Error, response: undefined | T) => void
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

void

Implementation of

IUniversalProvider.sendAsync


enable

enable(__namedParameters?): Promise<string[]>

Parameters

NameType
__namedParametersEnableArgs

Returns

Promise<string[]>

Implementation of

IUniversalProvider.enable


connect

connect(__namedParameters?): Promise<void>

Parameters

NameType
__namedParametersConnectArgs

Returns

Promise<void>

Implementation of

IUniversalProvider.connect


disconnect

disconnect(): Promise<void>

Returns

Promise<void>

Implementation of

IUniversalProvider.disconnect


setDefaultChain

setDefaultChain(chain): void

Parameters

NameType
chain`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

void


onAccountsChanged

onAccountsChanged(accountsMap): void

Parameters

NameType
accountsMapAccountsMap

Returns

void


initialize

Private initialize(): Promise<void>

Returns

Promise<void>


createAdaptors

Private createAdaptors(): void

Returns

void


registerEventListeners

Private registerEventListeners(): void

Returns

void


getAdaptor

Private getAdaptor(namespace): IAdaptor

Parameters

NameType
namespaceNamespace

Returns

IAdaptor


setNamespaces

Private setNamespaces(accountsMap): void

Parameters

NameType
accountsMapAccountsMap

Returns

void


validateChain

Private validateChain(chain?): [Namespace, string]

Parameters

NameType
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

[Namespace, string]


requestAccounts

Private requestAccounts(chain?): Promise<string[]>

Parameters

NameType
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

Promise<string[]>


onConnect

Private onConnect(): void

Returns

void


onChainChanged

Private onChainChanged(chain): void

Parameters

NameType
chain`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

void


init

Static init(options): Promise<UniversalProvider>

Parameters

NameType
optionsUniversalProviderOptions

Returns

Promise<UniversalProvider>

Interface: RequestArgs

NameTypeDescription
methodstring
params?unknown[] | Record<string, unknown>
metadata?ClientMetadata

Interface: IUniversalProvider

NameTypeDescription
topicIdTopicId
metaData?ClientMetadata
eventsSimpleEventEmitter
namespaces?NamespaceRecord
rpcAdaptorsRpcAdaptorMap
on<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
once<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
off<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
removeListener<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
emit<E>(event: E, payload: EventArguments[E]) => boolean
request(args, chain?): Promise<T>
sendAsync(args, callback, chain?): void
enable(args?): Promise<string[]>
connect(args?): Promise<void>
disconnect(): void

request

request<T>(args, chain?): Promise<T>

Type parameters

NameType
Tunknown

Parameters

NameType
argsRequestArgs
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

Promise<T>

Overrides

EIP1193Provider.request


sendAsync

sendAsync<T>(args, callback, chain?): void

Type parameters

NameType
Tunknown

Parameters

NameType
argsRequestArgs
callback(error: null | Error, response: undefined | T) => void
chain?string

Returns

void


enable

enable(args?): Promise<string[]>

Parameters

NameType
args?EnableArgs

Returns

Promise<string[]>

Overrides

EIP1193Provider.enable


connect

connect(args?): Promise<void>

Parameters

NameType
args?ConnectArgs

Returns

Promise<void>


disconnect

disconnect(): void

Returns

void

Interface: RequestArgs

NameTypeDescription
methodstring
params?unknown[] | Record<string, unknown>
metadata?ClientMetadata

Interface: EIP1193Provider

NameTypeDescription
request(args): Promise<unknown>
enable(): Promise<ProviderAccounts>
on(event, listener): void
once(event, listener): void
removeListener(event, listener): void
off(event, listener): void
emit(event, ...args): boolean

request

request(args): Promise<unknown>

Parameters

NameType
argsRequestArgs

Returns

Promise<unknown>


enable

enable(): Promise<ProviderAccounts>

Returns

Promise<ProviderAccounts>


on

on(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void

Inherited from

SimpleEventEmitter.on


once

once(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void

Inherited from

SimpleEventEmitter.once


removeListener

removeListener(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void

Inherited from

SimpleEventEmitter.removeListener


off

off(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void

Inherited from

SimpleEventEmitter.off


emit

emit(event, ...args): boolean

Parameters

NameType
eventstring
...argsunknown[]

Returns

boolean

Inherited from

SimpleEventEmitter.emit

ProviderAccounts

Ƭ ProviderAccounts: Account[]


Account

Ƭ Account: string


Listener

Ƭ Listener: (...args: unknown[]) => void

Type declaration

▸ (...args): void

Parameters

NameType
...argsunknown[]

Returns

void


Interface: SimpleEventEmitter

NameTypeDescription
on(event, listener): void
once(event, listener): void
removeListener(event, listener): void
off(event, listener): void
emit(event, ...args): boolean

on

on(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void


once

once(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void


removeListener

removeListener(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void


off

off(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void


emit

emit(event, ...args): boolean

Parameters

NameType
eventstring
...argsunknown[]

Returns

boolean

on

on(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void


once

once(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void


removeListener

removeListener(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void


off

off(event, listener): void

Parameters

NameType
eventstring
listenerListener

Returns

void


emit

emit(event, ...args): boolean

Parameters

NameType
eventstring
...argsunknown[]

Returns

boolean

request

request(args): Promise<unknown>

Parameters

NameType
argsRequestArgs

Returns

Promise<unknown>


Interface: EnableArgs

NameTypeDescription
chain?`eip155:${string}eip155:${string}` | `cosmos:${string}cosmos:${string}` | `trust:${string}trust:${string}` | `w3w:${string}w3w:${string}`
topicId?TopicId
metaData?ClientMetadata

enable

enable(): Promise<ProviderAccounts>

Returns

Promise<ProviderAccounts>


Interface: ConnectArgs

NameTypeDescription
topicId?TopicId
metaData?ClientMetadata

request

request<T>(args, chain?): Promise<T>

Type parameters

NameType
Tunknown

Parameters

NameType
argsRequestArgs
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

Promise<T>

Overrides

EIP1193Provider.request


sendAsync

sendAsync<T>(args, callback, chain?): void

Type parameters

NameType
Tunknown

Parameters

NameType
argsRequestArgs
callback(error: null | Error, response: undefined | T) => void
chain?string

Returns

void


Interface: EnableArgs

NameTypeDescription
chain?`eip155:${string}eip155:${string}` | `cosmos:${string}cosmos:${string}` | `trust:${string}trust:${string}` | `w3w:${string}w3w:${string}`
topicId?TopicId
metaData?ClientMetadata

enable

enable(args?): Promise<string[]>

Parameters

NameType
args?EnableArgs

Returns

Promise<string[]>

Overrides

EIP1193Provider.enable


Interface: ConnectArgs

NameTypeDescription
topicId?TopicId
metaData?ClientMetadata

connect

connect(args?): Promise<void>

Parameters

NameType
args?ConnectArgs

Returns

Promise<void>


disconnect

disconnect(): void

Returns

void

AccountsMap

Ƭ AccountsMap: Object

Type declaration

NameType
eip155undefined | Record<`eip155:${string}`, string[]>
cosmosundefined | Record<`cosmos:${string}`, string[]>
trustundefined | Record<`trust:${string}`, string[]>
w3wundefined | Record<`w3w:${string}`, string[]>

Interface: IAdaptor

NameTypeDescription
namestring
chainIdstring
eventsSimpleEventEmitter
namespaceNamespaceConfig<Namespace>
request(args): Promise<T>
updateNamespace(namespace): void
getDefaultChainId(): string
setDefaultChainId(chainId): void
requestAccounts(chainId?): string[]

request

request<T>(args): Promise<T>

Type parameters

NameType
Tunknown

Parameters

NameType
argsAdaptorRequestArgs

Returns

Promise<T>


updateNamespace

updateNamespace(namespace): void

Parameters

NameType
namespaceNamespaceConfig<Namespace>

Returns

void


getDefaultChainId

getDefaultChainId(): string

Returns

string


setDefaultChainId

setDefaultChainId(chainId): void

Parameters

NameType
chainIdstring

Returns

void


requestAccounts

requestAccounts(chainId?): string[]

Parameters

NameType
chainId?string

Returns

string[]

Interface: AdaptorRequestArgs

NameTypeDescription
chainIdstring
topicIdTopicId
methodstring
params?unknown[] | Record<string, unknown>
metadata?ClientMetadata

NamespaceConfig

Ƭ NamespaceConfig<NS>: Object

Type parameters

NameType
NSextends Namespace

Type declaration

NameType
chainsChain<NS>[]
accounts`${Chain<NS>}:${Account}`[]

Namespace

Ƭ Namespace: "eip155" | "cosmos" | "trust" | "w3w"


Chain

Ƭ Chain<NS>: `${NS}:${ChainId}`

Type parameters

NameType
NSextends Namespace = Namespace

Namespace

Ƭ Namespace: "eip155" | "cosmos" | "trust" | "w3w"


Class: UniversalProvider

NameTypeDescription
topicIdTopicId
metaData?ClientMetadata
eventsSimpleEventEmitter
namespacesNamespaceRecord = {}
rpcAdaptorsRpcAdaptorMap = {}
rpcHooksRPCHooks
isConnectingboolean = false
on<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
once<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
removeListener<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
off<E>(event: E, listener: ((args: EventArguments[E]) => void) => void
emit<E>(event: E, payload: EventArguments[E]) => boolean
isConnectedboolean
request(args, chain?): Promise<T>
sendAsync(args, callback, chain?): void
enable(__namedParameters?): Promise<string[]>
connect(__namedParameters?): Promise<void>
disconnect(): Promise<void>
setDefaultChain(chain): void
onAccountsChanged(accountsMap): void
initialize(): Promise<void>
createAdaptors(): void
registerEventListeners(): void
getAdaptor(namespace): IAdaptor
setNamespaces(accountsMap): void
validateChain(chain?): [Namespace, string]
requestAccounts(chain?): Promise<string[]>
onConnect(): void
onChainChanged(chain): void
init(options): Promise<UniversalProvider>

request

request<T>(args, chain?): Promise<T>

Type parameters

NameType
Tunknown

Parameters

NameType
argsRequestArgs
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

Promise<T>

Implementation of

IUniversalProvider.request


sendAsync

sendAsync<T>(args, callback, chain?): void

Type parameters

NameType
Tunknown

Parameters

NameType
argsRequestArgs
callback(error: null | Error, response: undefined | T) => void
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

void

Implementation of

IUniversalProvider.sendAsync


enable

enable(__namedParameters?): Promise<string[]>

Parameters

NameType
__namedParametersEnableArgs

Returns

Promise<string[]>

Implementation of

IUniversalProvider.enable


connect

connect(__namedParameters?): Promise<void>

Parameters

NameType
__namedParametersConnectArgs

Returns

Promise<void>

Implementation of

IUniversalProvider.connect


disconnect

disconnect(): Promise<void>

Returns

Promise<void>

Implementation of

IUniversalProvider.disconnect


setDefaultChain

setDefaultChain(chain): void

Parameters

NameType
chain`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

void


onAccountsChanged

onAccountsChanged(accountsMap): void

Parameters

NameType
accountsMapAccountsMap

Returns

void


initialize

Private initialize(): Promise<void>

Returns

Promise<void>


createAdaptors

Private createAdaptors(): void

Returns

void


registerEventListeners

Private registerEventListeners(): void

Returns

void


getAdaptor

Private getAdaptor(namespace): IAdaptor

Parameters

NameType
namespaceNamespace

Returns

IAdaptor


setNamespaces

Private setNamespaces(accountsMap): void

Parameters

NameType
accountsMapAccountsMap

Returns

void


validateChain

Private validateChain(chain?): [Namespace, string]

Parameters

NameType
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

[Namespace, string]


requestAccounts

Private requestAccounts(chain?): Promise<string[]>

Parameters

NameType
chain?`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

Promise<string[]>


onConnect

Private onConnect(): void

Returns

void


onChainChanged

Private onChainChanged(chain): void

Parameters

NameType
chain`eip155:${string}` | `cosmos:${string}` | `trust:${string}` | `w3w:${string}`

Returns

void


init

Static init(options): Promise<UniversalProvider>

Parameters

NameType
optionsUniversalProviderOptions

Returns

Promise<UniversalProvider>

Interface: UniversalProviderOptions

NameTypeDescription
rpcHooksRPCHooks
topicId?TopicId
metaData?ClientMetadata