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
Optional
currentPair• currentPair? : KeyringPair
Defined in src/base/Context.ts:111
isArchiveNode
• isArchiveNode: boolean = false
Defined in src/base/Context.ts:116
Whether the current node is an archive node (contains a full history from genesis onward) or not
polymeshApi
• polymeshApi: ApiPromise
Defined in src/base/Context.ts:109
ss58Format
• ss58Format: number
Defined in src/base/Context.ts:118
Accessors
middlewareApi
• get middlewareApi(): ApolloClient‹NormalizedCacheObject›
Defined in src/base/Context.ts:1005
Retrieve the middleware client
throws
if the middleware is not enabled
Returns: ApolloClient‹NormalizedCacheObject›
Methods
accountBalance
▸ accountBalance(account?
: string | Account): Promise‹AccountBalance›
Defined in src/base/Context.ts:328
Retrieve the account level POLYX balance
note
can be subscribed to
Parameters:
Name | Type |
---|---|
| string | Account |
Returns: Promise‹AccountBalance›
▸ accountBalance(account
: string | Account | undefined, callback
: SubCallback‹AccountBalance›): Promise‹UnsubCallback›
Defined in src/base/Context.ts:329
Parameters:
Name | Type |
---|---|
| string | Account | undefined |
|
Returns: Promise‹UnsubCallback›
accountSubsidy
▸ accountSubsidy(account?
: string | Account): Promise‹Omit‹Subsidy, "beneficiary"› | null›
Defined in src/base/Context.ts:386
Retrieve the account level subsidizer relationship. If there is no such relationship, return null
note
can be subscribed to
Parameters:
Name | Type |
---|---|
| string | Account |
Returns: Promise‹Omit‹Subsidy, "beneficiary"› | null›
▸ accountSubsidy(account
: string | Account | undefined, callback
: SubCallback‹Omit‹Subsidy, "beneficiary"› | null›): Promise‹UnsubCallback›
Defined in src/base/Context.ts:387
Parameters:
Name | Type |
---|---|
| string | Account | undefined |
| SubCallback‹Omit‹Subsidy, "beneficiary"› | null› |
Returns: Promise‹UnsubCallback›
addPair
▸ addPair(params
: AddPairParams): KeyringPair
Defined in src/base/Context.ts:263
Add a signing pair to the Keyring
Parameters:
Name | Type |
---|---|
|
Returns: KeyringPair
clone
▸ clone(): Context
Defined in src/base/Context.ts:1102
Returns a (shallow) clone of this instance. Useful for providing a separate Context to Procedures with different signers
Returns: Context
disconnect
▸ disconnect(): Promise‹void›
Defined in src/base/Context.ts:1084
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[]
Defined in src/base/Context.ts:240
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
Defined in src/base/Context.ts:442
Retrieve current Account
throws
if there is no current account associated to the SDK instance
Returns: Account
getCurrentIdentity
▸ getCurrentIdentity(): Promise‹Identity›
Defined in src/base/Context.ts:453
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
Defined in src/base/Context.ts:473
Retrieve current Keyring Pair
throws
if there is no Account associated to the SDK instance
Returns: KeyringPair
getInvalidDids
▸ getInvalidDids(identities
: (string | Identity‹›)[]): Promise‹string[]›
Defined in src/base/Context.ts:502
Check whether Identities exist
Parameters:
Name | Type |
---|---|
| (string | Identity‹›)[] |
Returns: Promise‹string[]›
getLatestBlock
▸ getLatestBlock(): Promise‹BigNumber›
Defined in src/base/Context.ts:1063
Retrieve the latest block number
Returns: Promise‹BigNumber›
getNetworkVersion
▸ getNetworkVersion(): Promise‹string›
Defined in src/base/Context.ts:1072
Retrieve the network version
Returns: Promise‹string›
getSigner
▸ getSigner(): AddressOrPair
Defined in src/base/Context.ts:489
Retrieve the signer address (or keyring pair)
Returns: AddressOrPair
getTransactionArguments
▸ getTransactionArguments(args
: object): TransactionArgument[]
Defined in src/base/Context.ts:558
Retrieve the types of arguments that a certain transaction requires to be run
Parameters:
▪ args: object
Name | Type | Description |
---|---|---|
| TxTag | tag associated with the transaction that will be executed if the proposal passes |
Returns: TransactionArgument[]
getTransactionFees
▸ getTransactionFees(tag
: TxTag): Promise‹BigNumber›
Defined in src/base/Context.ts:531
Retrieve the protocol fees associated with running a specific transaction
Parameters:
Name | Type | Description |
---|---|---|
| TxTag | transaction tag (i.e. TxTags.asset.CreateAsset or "asset.createAsset") |
Returns: Promise‹BigNumber›
isMiddlewareAvailable
▸ isMiddlewareAvailable(): Promise‹boolean›
Defined in src/base/Context.ts:1050
Return whether the middleware is enabled and online
Returns: Promise‹boolean›
isMiddlewareEnabled
▸ isMiddlewareEnabled(): boolean
Defined in src/base/Context.ts:1043
Return whether the middleware was enabled at startup
Returns: boolean
issuedClaims
▸ issuedClaims(opts
: object): Promise‹ResultSet‹ClaimData››
Defined in src/base/Context.ts:954
Retrieve a list of claims. Can be filtered using parameters
note
uses the middleware (optional)
Parameters:
▪Default value
opts: object= {}
Name | Type | Description |
---|---|---|
| types of the claims to fetch. Defaults to any type | |
| undefined | false | true | whether to include expired claims. Defaults to true |
| undefined | number | page size |
| undefined | number | page offset |
| (string | Identity‹›)[] | identities (or Identity IDs) for which to fetch claims (targets). Defaults to all targets |
| (string | Identity‹›)[] | identity IDs of claim issuers. Defaults to all claim issuers |
Returns: Promise‹ResultSet‹ClaimData››
queryMiddleware
▸ queryMiddleware‹Result›(query
: GraphqlQuery‹unknown›): Promise‹ApolloQueryResult‹Result››
Defined in src/base/Context.ts:1021
Make a query to the middleware server using the apollo client
Type parameters:
▪ Result: Partial‹Query›
Parameters:
Name | Type |
---|---|
| GraphqlQuery‹unknown› |
Returns: Promise‹ApolloQueryResult‹Result››
setPair
▸ setPair(address
: string): void
Defined in src/base/Context.ts:305
Set a pair as the current Account keyring pair
Parameters:
Name | Type |
---|---|
| string |
Returns: void
Static
create
Static
create▸ create(params
: object): Promise‹Context›
Defined in src/base/Context.ts:165
Create the Context instance
Parameters:
▪ params: object
Name | Type |
---|---|
| undefined | string |
| undefined | string |
| undefined | string |
| |
| ApolloClient‹NormalizedCacheObject› | null |
| ApiPromise |
Returns: Promise‹Context›
Last updated