Skip to main content

Module: @shareledgerjs/client

Namespaces

Classes

Interfaces

Type Aliases

AccountParser

Ƭ AccountParser: (any: Any) => Account

Type declaration

▸ (any): Account

Represents a generic function that takes an Any encoded account from the chain and extracts some common Account information from it.

Parameters
NameType
anyAny
Returns

Account


AminoConverters

Ƭ AminoConverters: Record<string, AminoConverter | "not_supported_by_chain">

A map from protobuf type URL to the AminoConverter implementation if supported on chain


SearchTxQuery

Ƭ SearchTxQuery: SearchByHeightQuery | SearchBySentFromOrToQuery | SearchByTagsQuery

Variables

Coin

Coin: Object

Type declaration

NameType
decode(input: Uint8Array | Reader, length?: number) => Coin
encode(message: Coin, writer: Writer) => Writer
fromPartial<I>(object: I) => Coin

DecCoin

DecCoin: Object

Type declaration

NameType
decode(input: Uint8Array | Reader, length?: number) => DecCoin
encode(message: DecCoin, writer: Writer) => Writer
fromPartial<I>(object: I) => DecCoin

defaultRegistryTypes

Const defaultRegistryTypes: ReadonlyArray<[string, GeneratedType]>

Functions

accountFromAny

accountFromAny(input): Account

Basic implementation of AccountParser. This is supposed to support the most relevant common Cosmos SDK account types. If you need support for exotic account types, you'll need to write your own account decoder.

Parameters

NameType
inputAny

Returns

Account


assertIsDeliverTxFailure

assertIsDeliverTxFailure(result): void

Ensures the given result is a failure. Throws a detailed error message otherwise.

Parameters

NameType
resultDeliverTxResponse

Returns

void


assertIsDeliverTxSuccess

assertIsDeliverTxSuccess(result): void

Ensures the given result is a success. Throws a detailed error message otherwise.

Parameters

NameType
resultDeliverTxResponse

Returns

void


calculateFee

calculateFee(gasLimit, gasPrice): StdFee

Parameters

NameType
gasLimitnumber
gasPricestring | GasPrice

Returns

StdFee


coin

coin(amount, denom): Coin

Creates a coin.

If your values do not exceed the safe integer range of JS numbers (53 bit), you can use the number type here. This is the case for all typical Cosmos SDK chains that use the default 6 decimals.

In case you need to supportr larger values, use unsigned integer strings instead.

Parameters

NameType
amountstring | number
denomstring

Returns

Coin


coins

coins(amount, denom): Coin[]

Creates a list of coins with one element.

Parameters

NameType
amountstring | number
denomstring

Returns

Coin[]


createDefaultAminoTypes

createDefaultAminoTypes(prefix): AminoConverters

Parameters

NameType
prefixstring

Returns

AminoConverters


createPagination

createPagination(paginationKey?): PageRequest | undefined

Parameters

NameType
paginationKey?Uint8Array

Returns

PageRequest | undefined


createProtobufRpcClient

createProtobufRpcClient(base): ProtobufRpcClient

Parameters

NameType
baseQueryClient

Returns

ProtobufRpcClient


decodeCosmosSdkDecFromProto

decodeCosmosSdkDecFromProto(input): Decimal

Takes a string or binary encoded github.com/cosmos/cosmos-sdk/types.Dec from the protobuf API and converts it into a Decimal with 18 fractional digits.

See https://github.com/cosmos/cosmos-sdk/issues/10863 for more context why this is needed.

Parameters

NameType
inputstring | Uint8Array

Returns

Decimal


decodePubkey

decodePubkey(pubkey?): Pubkey | null

Parameters

NameType
pubkey?null | Any

Returns

Pubkey | null


decodeTxRaw

decodeTxRaw(tx): DecodedTxRaw

Takes a serialized TxRaw (the bytes stored in Tendermint) and decodes it into something usable.

Parameters

NameType
txUint8Array

Returns

DecodedTxRaw


encodePubkey

encodePubkey(pubkey): Any

Parameters

NameType
pubkeyPubkey

Returns

Any


findAttribute

findAttribute(logs, eventType, attrKey): Attribute

Searches in logs for the first event of the given event type and in that event for the first first attribute with the given attribute key.

Throws if the attribute was not found.

Parameters

NameType
logsreadonly Log[]
eventTypestring
attrKeystring

Returns

Attribute


fromBech32

fromBech32(address, limit?): Object

Parameters

NameType
addressstring
limit?number

Returns

Object

NameType
dataUint8Array
prefixstring

fromCent

fromCent(number): DecCoin

Parameters

NameType
numberstring | number | BigNumber

Returns

DecCoin


fromNshr

fromNshr(number): DecCoin

Parameters

NameType
numberstring | number | BigNumber

Returns

DecCoin


fromTendermint34Event

fromTendermint34Event(event): Event

Takes a Tendemrint 0.34 event with binary encoded key and value and converts it into an Event with string attributes.

Parameters

NameType
eventEvent

Returns

Event


isDeliverTxFailure

isDeliverTxFailure(result): boolean

Parameters

NameType
resultDeliverTxResponse

Returns

boolean


isDeliverTxSuccess

isDeliverTxSuccess(result): boolean

Parameters

NameType
resultDeliverTxResponse

Returns

boolean


isSearchByHeightQuery

isSearchByHeightQuery(query): query is SearchByHeightQuery

Parameters

NameType
querySearchTxQuery

Returns

query is SearchByHeightQuery


isSearchBySentFromOrToQuery

isSearchBySentFromOrToQuery(query): query is SearchBySentFromOrToQuery

Parameters

NameType
querySearchTxQuery

Returns

query is SearchBySentFromOrToQuery


isSearchByTagsQuery

isSearchByTagsQuery(query): query is SearchByTagsQuery

Parameters

NameType
querySearchTxQuery

Returns

query is SearchByTagsQuery


longify

longify(value): Long

Takes a uint64 value as string, number, Long or Uint64 and returns an unsigned Long instance of it.

Parameters

NameType
valuestring | number | Long | Uint64

Returns

Long


makeMultisignedTx

makeMultisignedTx(multisigPubkey, sequence, fee, bodyBytes, signatures): TxRaw

Creates a signed transaction from signer info, transaction body and signatures. The result can be broadcasted after serialization.

Consider using makeMultisignedTxBytes instead if you want to broadcast the transaction immediately.

Parameters

NameType
multisigPubkeyMultisigThresholdPubkey
sequencenumber
feeStdFee
bodyBytesUint8Array
signaturesMap<string, Uint8Array>

Returns

TxRaw


makeMultisignedTxBytes

makeMultisignedTxBytes(multisigPubkey, sequence, fee, bodyBytes, signatures): Uint8Array

Creates a signed transaction from signer info, transaction body and signatures. The result can be broadcasted.

This is a wrapper around makeMultisignedTx that encodes the transaction for broadcasting.

Parameters

NameType
multisigPubkeyMultisigThresholdPubkey
sequencenumber
feeStdFee
bodyBytesUint8Array
signaturesMap<string, Uint8Array>

Returns

Uint8Array


makeShareledgerPath

makeShareledgerPath(a): HdPath

The derivation path in the form m/44'/118'/0'/0/a with 0-based account index a.

Parameters

NameType
anumber

Returns

HdPath


parseAttribute

parseAttribute(input): Attribute

Parameters

NameType
inputunknown

Returns

Attribute


parseCoins

parseCoins(input): Coin[]

Takes a coins list like "819966000ucosm,700000000ustake" and parses it.

This is a Stargate ready version of parseCoins from @cosmjs/amino and @cosmjs/launchpad. It supports more denoms.

Parameters

NameType
inputstring

Returns

Coin[]


parseDecCoins

parseDecCoins(input, fractionalDigits?): DecCoin[]

Parameters

NameType
inputstring
fractionalDigits?number

Returns

DecCoin[]


parseEvent

parseEvent(input): Event

Parameters

NameType
inputunknown

Returns

Event


parseLog

parseLog(input): Log

Parameters

NameType
inputunknown

Returns

Log


parseLogs

parseLogs(input): readonly Log[]

Parameters

NameType
inputunknown

Returns

readonly Log[]


parseRawLog

parseRawLog(input?): readonly Log[]

Parameters

NameTypeDefault value
inputstring"[]"

Returns

readonly Log[]


pubkeyToAddress

pubkeyToAddress(pubkey, prefix): string

Parameters

NameType
pubkeyPubkey
prefixstring

Returns

string


toAccAddress

toAccAddress(address): Uint8Array

Takes a bech32 encoded address and returns the data part. The prefix is ignored and discarded. This is called AccAddress in Cosmos SDK, which is basically an alias for raw binary data. The result is typically 20 bytes long but not restricted to that.

Parameters

NameType
addressstring

Returns

Uint8Array


toBech32

toBech32(prefix, data, limit?): string

Parameters

NameType
prefixstring
dataUint8Array
limit?number

Returns

string


toBech32Address

toBech32Address(pubkey, prefix?): string

Parameters

NameTypeDefault value
pubkeyUint8Arrayundefined
prefixstring"shareledger"

Returns

string


toBech32ConsAddress

toBech32ConsAddress(pubkey, prefix?): string

Parameters

NameTypeDefault value
pubkeyUint8Arrayundefined
prefixstring"shareledgervalcons"

Returns

string


toBech32ValAddress

toBech32ValAddress(pubkey, prefix?): string

Parameters

NameTypeDefault value
pubkeyUint8Arrayundefined
prefixstring"shareledgervaloper"

Returns

string


toCent

toCent(number): Coin

Parameters

NameType
numberstring | number | BigNumber

Returns

Coin


toNshr

toNshr(number): Coin

Parameters

NameType
numberstring | number | BigNumber

Returns

Coin