Module: @shareledgerjs/client
Namespaces
Classes
- BaseClient
- BroadcastTxError
- Client
- GasPrice
- QueryClient
- Registry
- Secp256k1HdWallet
- Secp256k1Wallet
- ShareledgerClient
- ShareledgerSigningClient
- SigningClient
- TimeoutError
Interfaces
- Account
- AminoConverter
- AminoMsg
- Attribute
- Block
- BlockHeader
- ClientOptions
- Coin
- DecCoin
- DeliverTxResponse
- Event
- HttpEndpoint
- IndexedTx
- ProtobufRpcClient
- QueryAbciResponse
- QueryStoreResponse
- SearchByHeightQuery
- SearchBySentFromOrToQuery
- SearchByTagsQuery
- SearchTxFilter
- Secp256k1HdWalletOptions
- SequenceResponse
- SignerData
- SigningOptions
- StdFee
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
Name | Type |
---|---|
any | Any |
Returns
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
Name | Type |
---|---|
decode | (input : Uint8Array | Reader , length? : number ) => Coin |
encode | (message : Coin , writer : Writer ) => Writer |
fromPartial | <I>(object : I ) => Coin |
DecCoin
• DecCoin: Object
Type declaration
Name | Type |
---|---|
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
Name | Type |
---|---|
input | Any |
Returns
assertIsDeliverTxFailure
▸ assertIsDeliverTxFailure(result
): void
Ensures the given result is a failure. Throws a detailed error message otherwise.
Parameters
Name | Type |
---|---|
result | DeliverTxResponse |
Returns
void
assertIsDeliverTxSuccess
▸ assertIsDeliverTxSuccess(result
): void
Ensures the given result is a success. Throws a detailed error message otherwise.
Parameters
Name | Type |
---|---|
result | DeliverTxResponse |
Returns
void
calculateFee
▸ calculateFee(gasLimit
, gasPrice
): StdFee
Parameters
Name | Type |
---|---|
gasLimit | number |
gasPrice | string | GasPrice |
Returns
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
Name | Type |
---|---|
amount | string | number |
denom | string |
Returns
Coin
coins
▸ coins(amount
, denom
): Coin
[]
Creates a list of coins with one element.
Parameters
Name | Type |
---|---|
amount | string | number |
denom | string |
Returns
Coin
[]
createDefaultAminoTypes
▸ createDefaultAminoTypes(prefix
): AminoConverters
Parameters
Name | Type |
---|---|
prefix | string |
Returns
createPagination
▸ createPagination(paginationKey?
): PageRequest
| undefined
Parameters
Name | Type |
---|---|
paginationKey? | Uint8Array |
Returns
PageRequest
| undefined
createProtobufRpcClient
▸ createProtobufRpcClient(base
): ProtobufRpcClient
Parameters
Name | Type |
---|---|
base | QueryClient |
Returns
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
Name | Type |
---|---|
input | string | Uint8Array |
Returns
Decimal
decodePubkey
▸ decodePubkey(pubkey?
): Pubkey
| null
Parameters
Name | Type |
---|---|
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
Name | Type |
---|---|
tx | Uint8Array |
Returns
DecodedTxRaw
encodePubkey
▸ encodePubkey(pubkey
): Any
Parameters
Name | Type |
---|---|
pubkey | Pubkey |
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
Name | Type |
---|---|
logs | readonly Log [] |
eventType | string |
attrKey | string |
Returns
fromBech32
▸ fromBech32(address
, limit?
): Object
Parameters
Name | Type |
---|---|
address | string |
limit? | number |
Returns
Object
Name | Type |
---|---|
data | Uint8Array |
prefix | string |
fromCent
▸ fromCent(number
): DecCoin
Parameters
Name | Type |
---|---|
number | string | number | BigNumber |
Returns
fromNshr
▸ fromNshr(number
): DecCoin
Parameters
Name | Type |
---|---|
number | string | number | BigNumber |
Returns
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
Name | Type |
---|---|
event | Event |
Returns
isDeliverTxFailure
▸ isDeliverTxFailure(result
): boolean
Parameters
Name | Type |
---|---|
result | DeliverTxResponse |
Returns
boolean
isDeliverTxSuccess
▸ isDeliverTxSuccess(result
): boolean
Parameters
Name | Type |
---|---|
result | DeliverTxResponse |
Returns
boolean
isSearchByHeightQuery
▸ isSearchByHeightQuery(query
): query is SearchByHeightQuery
Parameters
Name | Type |
---|---|
query | SearchTxQuery |
Returns
query is SearchByHeightQuery
isSearchBySentFromOrToQuery
▸ isSearchBySentFromOrToQuery(query
): query is SearchBySentFromOrToQuery
Parameters
Name | Type |
---|---|
query | SearchTxQuery |
Returns
query is SearchBySentFromOrToQuery
isSearchByTagsQuery
▸ isSearchByTagsQuery(query
): query is SearchByTagsQuery
Parameters
Name | Type |
---|---|
query | SearchTxQuery |
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
Name | Type |
---|---|
value | string | 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
Name | Type |
---|---|
multisigPubkey | MultisigThresholdPubkey |
sequence | number |
fee | StdFee |
bodyBytes | Uint8Array |
signatures | Map <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
Name | Type |
---|---|
multisigPubkey | MultisigThresholdPubkey |
sequence | number |
fee | StdFee |
bodyBytes | Uint8Array |
signatures | Map <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
Name | Type |
---|---|
a | number |
Returns
HdPath
parseAttribute
▸ parseAttribute(input
): Attribute
Parameters
Name | Type |
---|---|
input | unknown |
Returns
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
Name | Type |
---|---|
input | string |
Returns
Coin
[]
parseDecCoins
▸ parseDecCoins(input
, fractionalDigits?
): DecCoin
[]
Parameters
Name | Type |
---|---|
input | string |
fractionalDigits? | number |
Returns
DecCoin
[]
parseEvent
▸ parseEvent(input
): Event
Parameters
Name | Type |
---|---|
input | unknown |
Returns
parseLog
▸ parseLog(input
): Log
Parameters
Name | Type |
---|---|
input | unknown |
Returns
Log
parseLogs
▸ parseLogs(input
): readonly Log
[]
Parameters
Name | Type |
---|---|
input | unknown |
Returns
readonly Log
[]
parseRawLog
▸ parseRawLog(input?
): readonly Log
[]
Parameters
Name | Type | Default value |
---|---|---|
input | string | "[]" |
Returns
readonly Log
[]
pubkeyToAddress
▸ pubkeyToAddress(pubkey
, prefix
): string
Parameters
Name | Type |
---|---|
pubkey | Pubkey |
prefix | string |
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
Name | Type |
---|---|
address | string |
Returns
Uint8Array
toBech32
▸ toBech32(prefix
, data
, limit?
): string
Parameters
Name | Type |
---|---|
prefix | string |
data | Uint8Array |
limit? | number |
Returns
string
toBech32Address
▸ toBech32Address(pubkey
, prefix?
): string
Parameters
Name | Type | Default value |
---|---|---|
pubkey | Uint8Array | undefined |
prefix | string | "shareledger" |
Returns
string
toBech32ConsAddress
▸ toBech32ConsAddress(pubkey
, prefix?
): string
Parameters
Name | Type | Default value |
---|---|---|
pubkey | Uint8Array | undefined |
prefix | string | "shareledgervalcons" |
Returns
string
toBech32ValAddress
▸ toBech32ValAddress(pubkey
, prefix?
): string
Parameters
Name | Type | Default value |
---|---|---|
pubkey | Uint8Array | undefined |
prefix | string | "shareledgervaloper" |
Returns
string
toCent
▸ toCent(number
): Coin
Parameters
Name | Type |
---|---|
number | string | number | BigNumber |
Returns
toNshr
▸ toNshr(number
): Coin
Parameters
Name | Type |
---|---|
number | string | number | BigNumber |