Reference Source
import {TupeloClient} from 'tupelo-client'
public class | source

TupeloClient

Represents a connection to a specific Tupelo wallet managed by a remote Tupelo RPC server

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

rpc: WalletRPCService

Back end Tupelo Wallet RPC service connection

public

The name and passphrase of the wallet to connect to

public

The URL ("host:port") of the RPC wallet server to connect to

Method Summary

Public Methods
public

Create a new chain tree owned by the key at keyAddr.

public

establishToken(chainId: string, keyAddr: string, tokenName: string, maximum: number): Promise<EstablishTokenResponse, RpcError>

Establish a new token type associated with a chain tree.

public

Get a Base58 serialized chain tree Export

public

Generate a new chain tree ownership key pair.

public

Get the latest tip (as known by the Tupelo network signers) of the chain tree with id chainId

public

importChainTree(chainTree: SerializedChaintree, storageAdapter: StorageAdapterConfig): *

Import a serialized chain tree and save it to the wallet.

public

List the IDs of the chain trees associated with the connected wallet.

public

List the addresses of the keys associated with the connected wallet.

public

mintToken(chainId: string, keyAddr: string, tokenName: string, amount: number): Promise<MintTokenResponse, RpcError>

Mint new tokens of an already established token type associated with a chain tree.

public

Apply a sequence of transactions to a chain tree

public

receiveToken(chainId: string, keyAddr: string, tokenPayload: string): *

Receive a send token payload from another chain tree.

public

Register a new wallet with the client credentials.

public

Resolve data from the root of the chain tree.

public

async resolveAt(chainId: string, path: string, tip: string): Promise<ResolveResponse, RpcError>

Resolve data from a tip of a chain tree given a certain path.

public

Resolve data from the user portion ("/tree/data") of the chain tree.

public

sendToken(chainId: string, keyAddr: string, tokenName: string, destinationChainId: string, amount: number): *

Send an amount of minted tokens to another chain tree.

public

setData(chainId: string, keyAddr: string, path: string, value: string | number | boolean | Array | Object): Promise<SetDataResponse, RpcError>

Store data on a chain tree with a transaction validated by the network's notary group.

public

setOwner(chainId: string, keyAddr: string, newOwnerKeys: string[]): Promise<SetOwnerResponse, RpcError>

Define the set of owners of the chain tree with ID chainId as the set of keys in newOwnerKeys in a transaction, and register that transaction with the notary group.

Public Constructors

public constructor() source

Public Members

public rpc: WalletRPCService source

Back end Tupelo Wallet RPC service connection

public walletCreds: WalletCredentials source

The name and passphrase of the wallet to connect to

public walletServer: string source

The URL ("host:port") of the RPC wallet server to connect to

Public Methods

public createChainTree(keyAddr: string, storageAdapter: StorageAdapterConfig): Promise<CreateChainResponse, RpcError> source

Create a new chain tree owned by the key at keyAddr.

Params:

NameTypeAttributeDescription
keyAddr string

Address of the key that owns the new chain tree.

storageAdapter StorageAdapterConfig
  • optional

Storage configuration for the chain tree

public establishToken(chainId: string, keyAddr: string, tokenName: string, maximum: number): Promise<EstablishTokenResponse, RpcError> source

Establish a new token type associated with a chain tree.

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree.

keyAddr string

Address of a key that currently owns the chain tree.

tokenName string

Name of the new token

maximum number

Maximum number of tokens of this type that can exist

public exportChainTree(chainId: string): Promise<ExportChainTreeResponse, RpcError> source

Get a Base58 serialized chain tree Export

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree to be exported

public generateKey(): Promise<GenerateKeyResponse, RpcError> source

Generate a new chain tree ownership key pair.

public getTip(chainId: string): Promise<GetTipResponse, RpcError> source

Get the latest tip (as known by the Tupelo network signers) of the chain tree with id chainId

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree.

public importChainTree(chainTree: SerializedChaintree, storageAdapter: StorageAdapterConfig): * source

Import a serialized chain tree and save it to the wallet.

Params:

NameTypeAttributeDescription
chainTree SerializedChaintree

Serialized chain tree to import

storageAdapter StorageAdapterConfig
  • optional

Storage configuration for the chain tree

StorageAdapterConfig

Return:

*

public listChainIds(): Promise<ListChainIdsResponse, RpcError> source

List the IDs of the chain trees associated with the connected wallet.

public listKeys(): Promise<ListKeysResponse, RpcError> source

List the addresses of the keys associated with the connected wallet.

public mintToken(chainId: string, keyAddr: string, tokenName: string, amount: number): Promise<MintTokenResponse, RpcError> source

Mint new tokens of an already established token type associated with a chain tree.

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree.

keyAddr string

Address of a key that currently owns the chain tree.

tokenName string

Name of the token type

amount number

Number of tokens to mint.

public playTransactions(chainId: string, keyAddr: string, transactions: Object[]): Promise<PlayTransactionsResponse, RpcError> source

Apply a sequence of transactions to a chain tree

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree to store the data on.

keyAddr string

Address of the key that owns the chain tree.

transactions Object[]

List of transactions to apply

public receiveToken(chainId: string, keyAddr: string, tokenPayload: string): * source

Receive a send token payload from another chain tree.

Params:

NameTypeAttributeDescription
chainId string

The ID of the sending chain tree.

keyAddr string

Address of a key that currently owns the chain tree.

tokenPayload string

The base64-encoded token send payload.

Return:

*

public register(): Promise<RegisterResponse, RpcError> source

Register a new wallet with the client credentials.

public resolve(chainId: string, path: string): Promise<ResolveResponse, RpcError> source

Resolve data from the root of the chain tree.

The data will be resolved in the tree according to the path until we reach the end of the path or a leaf node. If we reach a leaf node before the end of the path, the data at the leaf node is returned and the remaining unresolved part of the path is set as the response's remainingPath property.

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree to retrieve the data from.

path string

'/' delimited path into the chain tree where the data is stored.

public async resolveAt(chainId: string, path: string, tip: string): Promise<ResolveResponse, RpcError> source

Resolve data from a tip of a chain tree given a certain path.

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree to retrieve the data from.

path string

'/' delimited path into the chain tree where the data is stored

tip string

The tip in question.

public resolveData(chainId: string, path: string): Promise<ResolveResponse, RpcError> source

Resolve data from the user portion ("/tree/data") of the chain tree.

The data will be resolved in the tree according to the path until we reach the end of the path or a leaf node. If we reach a leaf node before the end of the path, the data at the leaf node is returned and the remaining unresolved part of the path is set as the response's remainingPath property.

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree to retrieve the data from.

path string

'/' delimited path inside of tree/data where the data is stored.

public sendToken(chainId: string, keyAddr: string, tokenName: string, destinationChainId: string, amount: number): * source

Send an amount of minted tokens to another chain tree.

Params:

NameTypeAttributeDescription
chainId string

The ID of the sending chain tree.

keyAddr string

Address of a key that currently owns the chain tree.

tokenName string

Name of the token type.

destinationChainId string

The ID of the recipient chain tree.

amount number

Number of tokens to send.

Return:

*

public setData(chainId: string, keyAddr: string, path: string, value: string | number | boolean | Array | Object): Promise<SetDataResponse, RpcError> source

Store data on a chain tree with a transaction validated by the network's notary group.

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree to store the data on.

keyAddr string

Address of the key that owns the chain tree.

path string

'/' delimited path into the chain tree to store the data

value string | number | boolean | Array | Object

The data to store.

public setOwner(chainId: string, keyAddr: string, newOwnerKeys: string[]): Promise<SetOwnerResponse, RpcError> source

Define the set of owners of the chain tree with ID chainId as the set of keys in newOwnerKeys in a transaction, and register that transaction with the notary group.

Params:

NameTypeAttributeDescription
chainId string

The ID of the chain tree.

keyAddr string

Address of a key that currently owns the chain tree.

newOwnerKeys string[]

List of key addresses for the new owners.