Context
Context in which the SDK is being used
    Holds the current low level API
    Holds the current keyring pair
    Holds the current Identity

Hierarchy

    Context

Index

Properties

Accessors

Methods

Properties

Optional currentPair

currentPair? : KeyringPair

isArchiveNode

isArchiveNode: boolean = false
Whether the current node is an archive node (contains a full history from genesis onward) or not

polymeshApi

polymeshApi: ApiPromise

ss58Format

ss58Format: number

Accessors

middlewareApi

get middlewareApi(): ApolloClient‹NormalizedCacheObject›
Retrieve the middleware client
throws if the middleware is not enabled
Returns: ApolloClient‹NormalizedCacheObject›

Methods

accountBalance

accountBalance(account?: string | Account): Promise‹AccountBalance
Retrieve the account level POLYX balance
note can be subscribed to
Parameters:
Name
Type
account?
string | Account
Returns: Promise‹AccountBalance
accountBalance(account: string | Account | undefined, callback: SubCallbackAccountBalance›): Promise‹UnsubCallback
Parameters:
Name
Type
account
string | Account | undefined
callback
Returns: Promise‹UnsubCallback

accountSubsidy

accountSubsidy(account?: string | Account): Promise‹Omit‹Subsidy, "beneficiary"› | null›
Retrieve the account level subsidizer relationship. If there is no such relationship, return null
note can be subscribed to
Parameters:
Name
Type
account?
string | Account
Returns: Promise‹Omit‹Subsidy, "beneficiary"› | null›
accountSubsidy(account: string | Account | undefined, callback: SubCallback‹Omit‹Subsidy, "beneficiary"› | null›): Promise‹UnsubCallback
Parameters:
Name
Type
account
string | Account | undefined
callback
SubCallback‹Omit‹Subsidy, "beneficiary"› | null›
Returns: Promise‹UnsubCallback

addPair

addPair(params: AddPairParams): KeyringPair
Add a signing pair to the Keyring
Parameters:
Name
Type
params
Returns: KeyringPair

clone

clone(): Context
Returns a (shallow) clone of this instance. Useful for providing a separate Context to Procedures with different signers
Returns: Context

disconnect

disconnect(): Promise‹void›
Disconnect the Polkadot API, middleware, and render this instance unusable
note after disconnecting, trying to access any property in this objecct will result in an error
Returns: Promise‹void›

getAccounts

getAccounts(): Account[]
Retrieve a list of Accounts that can act as signers. The first Account in the array is the current Account (default signer)
Returns: Account[]

getCurrentAccount

getCurrentAccount(): Account
Retrieve current Account
throws if there is no current account associated to the SDK instance
Returns: Account

getCurrentIdentity

getCurrentIdentity(): Promise‹Identity
Retrieve current Identity
throws if there is no Identity associated to the current Account (or there is no current Account associated to the SDK instance)
Returns: Promise‹Identity

getCurrentPair

getCurrentPair(): KeyringPair
Retrieve current Keyring Pair
throws if there is no Account associated to the SDK instance
Returns: KeyringPair

getInvalidDids

getInvalidDids(identities: (string | Identity‹›)[]): Promise‹string[]›
Check whether Identities exist
Parameters:
Name
Type
identities
(string | Identity‹›)[]
Returns: Promise‹string[]›

getLatestBlock

getLatestBlock(): Promise‹BigNumber›
Retrieve the latest block number
Returns: Promise‹BigNumber›

getNetworkVersion

getNetworkVersion(): Promise‹string›
Retrieve the network version
Returns: Promise‹string›

getSigner

getSigner(): AddressOrPair
Retrieve the signer address (or keyring pair)
Returns: AddressOrPair

getTransactionArguments

getTransactionArguments(args: object): TransactionArgument[]
Retrieve the types of arguments that a certain transaction requires to be run
Parameters:
args: object
Name
Type
Description
tag
TxTag
tag associated with the transaction that will be executed if the proposal passes

getTransactionFees

getTransactionFees(tag: TxTag): Promise‹BigNumber›
Retrieve the protocol fees associated with running a specific transaction
Parameters:
Name
Type
Description
tag
TxTag
transaction tag (i.e. TxTags.asset.CreateAsset or "asset.createAsset")
Returns: Promise‹BigNumber›

isMiddlewareAvailable

isMiddlewareAvailable(): Promise‹boolean›
Return whether the middleware is enabled and online
Returns: Promise‹boolean›

isMiddlewareEnabled

isMiddlewareEnabled(): boolean
Return whether the middleware was enabled at startup
Returns: boolean

issuedClaims

issuedClaims(opts: object): Promise‹ResultSetClaimData››
Retrieve a list of claims. Can be filtered using parameters
note uses the middleware (optional)
Parameters:
Default value opts: object= {}
Name
Type
Description
claimTypes?
types of the claims to fetch. Defaults to any type
includeExpired?
undefined | false | true
whether to include expired claims. Defaults to true
size?
undefined | number
page size
start?
undefined | number
page offset
targets?
(string | Identity‹›)[]
identities (or Identity IDs) for which to fetch claims (targets). Defaults to all targets
trustedClaimIssuers?
(string | Identity‹›)[]
identity IDs of claim issuers. Defaults to all claim issuers
Returns: Promise‹ResultSetClaimData››

queryMiddleware

queryMiddlewareResult›(query: GraphqlQuery‹unknown›): Promise‹ApolloQueryResult‹Result››
Make a query to the middleware server using the apollo client
Type parameters:
Result: Partial‹Query›
Parameters:
Name
Type
query
GraphqlQuery‹unknown›
Returns: Promise‹ApolloQueryResult‹Result››

setPair

setPair(address: string): void
Set a pair as the current Account keyring pair
Parameters:
Name
Type
address
string
Returns: void

Static create

create(params: object): Promise‹Context
Create the Context instance
Parameters:
params: object
Name
Type
accountMnemonic?
undefined | string
accountSeed?
undefined | string
accountUri?
undefined | string
keyring?
middlewareApi
ApolloClient‹NormalizedCacheObject› | null
polymeshApi
ApiPromise
Returns: Promise‹Context
Last modified 26d ago