Skip to content

Latest commit

 

History

History
2001 lines (1144 loc) · 48.5 KB

README.md

File metadata and controls

2001 lines (1144 loc) · 48.5 KB

Tezos Wallet

Client side library written in Typescript for building application utilizing Tezos crypto currency and Trezor hardware wallet.

Tezos wallet simplifies communication with Tezos nodes and significantly reduces burden of working with Tezos network.

Installation

Add NPM package to the list of dependencies

npm install tezos-wallet

Project is based on RxJS and relies on it as peer dependency, therefore add supported version as dependency of you project.

npm install rxjs@~6.3.2

Development

Import the libary methods as import { initializeWallet, getWallet } from 'tezos-wallet';

Library is tested with Typescript versions 3.2.2.

Code

Code is well described and documentation generated using Typedoc can be viewed in docs folder.

Examples

Code samples describing usage can be found in example folder.

Index

Interfaces

Type aliases

Functions

Object literals


Type aliases

ActivatedWallet

Ƭ ActivatedWallet: object

Defined in common/state.ts:31

Type declaration

secret: string


BalanceUpdate

Ƭ BalanceUpdate: * ContractBalanceUpdate | FeeBalanceUpdate *

Defined in common/operations.ts:64


ConfirmOperation

Ƭ ConfirmOperation: object

Defined in common/state.ts:35

Type declaration

injectionOperation: InjectionOperation


ContractBalanceUpdate

Ƭ ContractBalanceUpdate: object

Defined in common/operations.ts:50

Type declaration

change: string

contract: string

kind: "contract"


ErrorKind

Ƭ ErrorKind: * "temporary" | "permanent" *

Defined in common/errors.ts:4


FeeBalanceUpdate

Ƭ FeeBalanceUpdate: object

Defined in common/operations.ts:56

Type declaration

category: "fees"

change: string

delegate: string

kind: "freezer"

level: number


Head

Ƭ Head: object

Defined in common/state.ts:67

Type declaration

chain_id: string

hash: string

header: object

context: string

fitness: [string, string]

level: number

operations_hash: string

predecessor: string

priority: number

proof_of_work_nonce: string

proto: number

signature: string

timestamp: string

validation_pass: number

metadata: object

baker: string

balance_updates: any[]

consumed_gas: string

deactivated: any[]

level: any

max_block_header_length: number

max_operation_data_length: number

max_operation_list_length: object[]

max_operations_ttl: number

next_protocol: string

nonce_hash: string | null

protocol: string

test_chain_status: object

status: "running" | "not_running"

voting_period_kind: "proposal"

operations: object[]

protocol: string


HeadConstants

Ƭ HeadConstants: object

Defined in common/state.ts:39

Type declaration

block_reward: string

block_security_deposit: string

blocks_per_commitment: number

blocks_per_cycle: number

blocks_per_roll_snapshot: number

blocks_per_voting_period: number

cost_per_byte: string

endorsement_reward: string

endorsement_security_deposit: string

endorsers_per_block: number

hard_gas_limit_per_block: string

hard_gas_limit_per_operation: string

hard_storage_limit_per_operation: string

max_operation_data_length: number

max_proposals_per_delegate: number

max_revelations_per_block: number

michelson_maximum_type_size: number

nonce_length: number

origination_size: number

preserved_cycles: number

proof_of_work_nonce_size: number

proof_of_work_threshold: string

seed_nonce_revelation_tip: string

time_between_blocks: string[]

tokens_per_roll: string


InjectionError

Ƭ InjectionError: object

Defined in common/errors.ts:24

Type declaration

response: object[]

state: S


InjectionOperation

Ƭ InjectionOperation: object

Defined in common/state.ts:119

Type declaration


LowFeeError

Ƭ LowFeeError: object

Defined in common/errors.ts:33

Type declaration

response: object[]

state: S


ManagerKey

Ƭ ManagerKey: object

Defined in common/state.ts:138

Type declaration

key: string

manager: string


Mempool

Ƭ Mempool: object

Defined in common/state.ts:130

Type declaration

applied: MempoolOperation[]

branch_delayed: MempoolOperation[]

branch_refused: MempoolOperation[]

refused: MempoolOperation[]

unprocessed: MempoolOperation[]


MempoolOperation

Ƭ MempoolOperation: object

Defined in common/state.ts:123

Type declaration

branch: string

contents: any

hash: string

signature: string


OperationApplicationResult

Ƭ OperationApplicationResult: * OperationValidationResult & object *

Defined in common/operations.ts:80


OperationMetadata

Ƭ OperationMetadata: * BaseOperationMetadata & RevealOperationMetadata | TransactionOperationMetadata | OriginationOperationMetadata | DelegationOperationMetadata | ActivateWalletOperationMetadata

Defined in common/operations.ts:41


OperationValidationResult

Ƭ OperationValidationResult: * OperationMetadata & object *

Defined in common/operations.ts:66


OriginatedContract

Ƭ OriginatedContract: object

Defined in common/state.ts:143

Type declaration

amount: string

fee: string

Optional testRun: undefined | false | true

to: string


PackOperationParameters

Ƭ PackOperationParameters: object

Defined in common/state.ts:150

Type declaration


PendingOperation

Ƭ PendingOperation: object

Defined in common/state.ts:154

Type declaration

publicKeyHash: string


PreapplyOperation

Ƭ PreapplyOperation: object

Defined in common/state.ts:158

Type declaration

contents: OperationValidationResult[]

signature: string


RpcError

Ƭ RpcError: object

Defined in common/errors.ts:6

Type declaration

response: object[]

state: S


SetDelegate

Ƭ SetDelegate: object

Defined in common/state.ts:163

Type declaration

fee: string

Optional testRun: undefined | false | true

to: string


SignOperation

Ƭ SignOperation: object

Defined in common/state.ts:169

Type declaration

operationHash: string

signature: string

signedOperationContents: string


StateActivateWallet

Ƭ StateActivateWallet: object

Defined in wallet/activateWallet.ts:9

Type declaration

activateWallet: ActivatedWallet


StateConfirmOperation

Ƭ StateConfirmOperation: object

Defined in operation/confirmOperation.ts:8

Type declaration

confirmOperation: object

injectionOperation: InjectionOperation


StateConstants

Ƭ StateConstants: object

Defined in head/getConstants.ts:6

Type declaration

constants: HeadConstants


StateCounter

Ƭ StateCounter: object

Defined in contract/getContractCounter.ts:6

Type declaration

counter: number


StateHead

Ƭ StateHead: object

Defined in head/getHead.ts:6

Type declaration

head: Head


StateInjectionOperation

Ƭ StateInjectionOperation: object

Defined in operation/applyInjectOperation.ts:16

Type declaration

injectionOperation: InjectionOperation


StateManagerKey

Ƭ StateManagerKey: object

Defined in contract/getContractManagerKey.ts:6

Type declaration

manager_key: ManagerKey


StateMempool

Ƭ StateMempool: object

Defined in operation/pendingOperation.ts:6

Type declaration

mempool: Mempool


StateOperation

Ƭ StateOperation: object

Defined in operation/forgeOperation.ts:16

Type declaration

operation: string


StateOperations

Ƭ StateOperations: object

Defined in operation/operation.ts:9

Type declaration

operations: OperationMetadata[]


StateOriginateContract

Ƭ StateOriginateContract: object

Defined in contract/originateContract.ts:14

Type declaration

originateContract: OriginatedContract


StatePackOperationParameters

Ƭ StatePackOperationParameters: object

Defined in operation/packOperationData.ts:7

Type declaration

packOperationParameters: PackOperationParameters


StatePendingOperation

Ƭ StatePendingOperation: object

Defined in operation/pendingOperation.ts:10

Type declaration

pendingOperation: PendingOperation


StatePreapplyOperation

Ƭ StatePreapplyOperation: object

Defined in operation/applyInjectOperation.ts:12

Type declaration

preapply: PreapplyOperation


StateSetDelegate

Ƭ StateSetDelegate: object

Defined in delegate/setDelegate.ts:11

Type declaration

setDelegate: SetDelegate


StateSignOperation

Ƭ StateSignOperation: object

Defined in operation/signOperation.ts:35

Type declaration

signOperation: SignOperation


StateTransaction

Ƭ StateTransaction: object

Defined in transaction/createTransaction.ts:11

Type declaration

transaction: Transaction


StateValidatedOperations

Ƭ StateValidatedOperations: object

Defined in operation/validateOperation.ts:10

Type declaration

validatedOperations: ValidationResult


StateWallet

Ƭ StateWallet: object

Defined in wallet/initializeWallet.ts:8

Type declaration

wallet: Wallet


StateWalletDetail

Ƭ StateWalletDetail: object

Defined in wallet/getWallet.ts:5

Type declaration

getWallet: WalletDetail


Transaction

Ƭ Transaction: object

Defined in common/state.ts:175

Type declaration

amount: string

fee: string

Optional parameters: Record<string, any>

Optional testRun: undefined | false | true

to: string


TrezorDelegationOperation

Ƭ TrezorDelegationOperation: object

Defined in common/operations.ts:122

Type declaration

counter: number

delegate: string

fee: number

gas_limit: number

source: string

storage_limit: number


TrezorOperationTarget

Ƭ TrezorOperationTarget: object

Defined in common/operations.ts:85

Type declaration

hash: Uint8Array | null

tag: number


TrezorOriginationOperation

Ƭ TrezorOriginationOperation: object

Defined in common/operations.ts:109

Type declaration

balance: number

counter: number

delegatable: boolean

delegate: string

fee: number

gas_limit: number

manager_pubkey: string

source: string

spendable: boolean

storage_limit: number


TrezorRevealOperation

Ƭ TrezorRevealOperation: object

Defined in common/operations.ts:90

Type declaration

counter: number

fee: number

gas_limit: number

public_key: string

source: string

storage_limit: number


TrezorTransactionOperation

Ƭ TrezorTransactionOperation: object

Defined in common/operations.ts:99

Type declaration

amount: number

counter: number

destination: string

fee: number

gas_limit: number

source: string

storage_limit: number


ValidationError

Ƭ ValidationError: object

Defined in common/errors.ts:15

Type declaration

response: object[]

state: S


ValidationResult

Ƭ ValidationResult: object

Defined in common/state.ts:183

Type declaration

contents: OperationValidationResult[]


Wallet

Ƭ Wallet: object

Defined in common/state.ts:187

Type declaration

Optional mnemonic: undefined | string

node: TezosNode

Optional path: undefined | string

Optional publicKey: undefined | string

publicKeyHash: string

Optional secret: undefined | string

Optional secretKey: undefined | string

Optional type: "web" | "TREZOR_T" | "TREZOR_P"


WalletDetail

Ƭ WalletDetail: object

Defined in common/state.ts:199

Type declaration

balance: number


Functions

<Const> activateWallet

activateWallet<T>(selector: function): (Anonymous function)

Defined in wallet/activateWallet.ts:20

Activate generated wallet address

Type parameters:

T : State

Parameters:

Name Type
selector function

Returns: (Anonymous function) Observable


<Const> applyAndInjectOperation

applyAndInjectOperation<T>(): (Anonymous function)

Defined in operation/applyInjectOperation.ts:26

Validates and inject operation into tezos blockain Can be applied to any prepared operation

Type parameters:

Returns: (Anonymous function)


base58CheckDecode

base58CheckDecode(this: void, prefix: Uint8Array, encoded: string): Buffer

Defined in common/crypto.ts:52

Decodes base58 encoded string into byte array and removes defined prefix

Parameters:

Name Type Description
this void
prefix Uint8Array -
encoded string

Returns: Buffer


bs58checkEncode

bs58checkEncode(this: void, prefix: Uint8Array, payload: Uint8Array): string

Defined in common/crypto.ts:38

Encode byte array into base58check format using defined prefix

Parameters:

Name Type Description
this void
prefix Uint8Array -
payload Uint8Array

Returns: string


checkPropertyWithError

checkPropertyWithError(o: Object, propName: string, methodName: string): void

Defined in common/validation.ts:41

Ensure that defined property exists in object and throw syntax error if not

Parameters:

Name Type Description
o Object object to check
propName string prop name
methodName string user friendly method name for better error tracking

Returns: void


concatKeys

concatKeys(this: void, privateKey: Uint8Array, publicKey: Uint8Array): Uint8Array

Defined in common/crypto.ts:62

Concat together private and public key

Parameters:

Name Type Description
this void
privateKey Uint8Array -
publicKey Uint8Array

Returns: Uint8Array


<Const> confirmOperation

confirmOperation<T>(selector: function): (Anonymous function)

Defined in operation/confirmOperation.ts:21

Wait until operation is confirmed & moved from mempool to head

Polls mempool to check when operation is confirmed and moved to head

Type parameters:

T : State

Parameters:

Name Type Description
selector function method returning operation hash to check in mempool

Returns: (Anonymous function)


<Const> constants

constants<T>(): (Anonymous function)

Defined in head/getConstants.ts:15

Get constants used in block

Type parameters:

T : State

Returns: (Anonymous function)


<Const> counter

counter<T>(): (Anonymous function)

Defined in contract/getContractCounter.ts:16

Get contract counter

Type parameters:

T : State

Returns: (Anonymous function)


<Const> forgeOperation

forgeOperation<T>(): (Anonymous function)

Defined in operation/forgeOperation.ts:27

Forge operation in blocchain. Converts operation into binary format and signs operation using script or Trezor

Type parameters:

Returns: (Anonymous function)


<Const> forgeOperationAtomic

forgeOperationAtomic<T>(): (Anonymous function)

Defined in operation/forgeOperation.ts:69

Converts operation to binary format on node

Type parameters:

Returns: (Anonymous function)


<Const> getWallet

getWallet<T>(): (Anonymous function)

Defined in wallet/getWallet.ts:14

Get wallet details as balance

Type parameters:

T : State

Returns: (Anonymous function)


hasAppliedOperationInMempool

hasAppliedOperationInMempool(this: StateConfirmOperation, operation: MempoolOperation): boolean

Defined in operation/confirmOperation.ts:68

Check if mempool contains operation among applied this: state with operation to confirm

Parameters:

Name Type
this StateConfirmOperation
operation MempoolOperation

Returns: boolean


hasRefusedOperationInMempool

hasRefusedOperationInMempool(this: StateConfirmOperation, operation: MempoolOperation): boolean

Defined in operation/confirmOperation.ts:59

Check if mempool contains operation among refused this: state with operation to confirm

Parameters:

Name Type Description
this StateConfirmOperation
operation MempoolOperation mempool operation

Returns: boolean


<Const> head

head<T>(): (Anonymous function)

Defined in head/getHead.ts:13

Get head for operation

Type parameters:

T : State

Returns: (Anonymous function)


<Const> initializeWallet

initializeWallet<T>(selector: function): (Anonymous function)

Defined in wallet/initializeWallet.ts:17

Waits for sodium to initialize and prepares wallet for working with it Should be the first step of every workflow

Type parameters:

T : Wallet

Parameters:

Name Type
selector function

Returns: (Anonymous function)


<Const> injectOperations

injectOperations<T>(): (Anonymous function)

Defined in operation/applyInjectOperation.ts:81

Inbjects prevalidated operation to Tezos blockchain

Type parameters:

Returns: (Anonymous function)


keys

keys(): WalletBase

keys(mnemonic: string, password: string): WalletBase

Defined in common/crypto.ts:86

Generates wallet new wallet or uses provided mnemonic and password

Returns: WalletBase

Defined in common/crypto.ts:87

Parameters:

Name Type
mnemonic string
password string

Returns: WalletBase


<Const> managerKey

managerKey<T>(): (Anonymous function)

Defined in contract/getContractManagerKey.ts:13

Get manager key for contract

Type parameters:

T : State

Returns: (Anonymous function)


<Const> newWallet

newWallet(): (Anonymous function)

Defined in wallet/newWallet.ts:9

Generate new menomonic, private, public key & tezos wallet address

Returns: (Anonymous function)


<Const> operation

operation(): (Anonymous function)

Defined in operation/operation.ts:17

Create operation in blockchain. Fully forge operation, validates it and inject into blockchain

Returns: (Anonymous function)


operationIsValid

operationIsValid(operation: OperationValidationResult): boolean

Defined in operation/validateOperation.ts:108

Parameters:

Name Type
operation OperationValidationResult

Returns: boolean


<Const> originateContract

originateContract<T>(selector: function): (Anonymous function)

Defined in contract/originateContract.ts:37

Originate smart contract from implicit wallet. Contract will be used for delegation. Complete operations stack

Type parameters:

T : State

Parameters:

Name Type Description
selector function derives origination data from state

Returns: (Anonymous function)


<Const> packOperationParameters

packOperationParameters<T>(): (Anonymous function)

Defined in operation/packOperationData.ts:14

Serialize operation parameters into binary format

Type parameters:

Returns: (Anonymous function)


<Const> packOperationParametersAtomic

packOperationParametersAtomic<T>(): (Anonymous function)

Defined in operation/packOperationData.ts:30

Serialize operation parameters on node

Type parameters:

Returns: (Anonymous function)


parseAmount

parseAmount(this: void, amount: string): number

Defined in common/crypto.ts:76

Convert string amount notation into number in milions

Parameters:

Name Type Description
this void
amount string text amount (3.50 tez)

Returns: number


<Const> pendingOperation

pendingOperation<T>(selector: function): (Anonymous function)

Defined in operation/pendingOperation.ts:19

Gets list of applied and refused operations in mempool for specific wallet

Type parameters:

T : State

Parameters:

Name Type Description
selector function method returning operation object with public key used as filter

Returns: (Anonymous function)


<Const> pendingOperationsAtomic

pendingOperationsAtomic<T>(): (Anonymous function)

Defined in operation/pendingOperation.ts:51

Gets mempool operations

Type parameters:

T : State

Returns: (Anonymous function)


<Const> preapplyOperations

preapplyOperations<T>(): (Anonymous function)

Defined in operation/applyInjectOperation.ts:61

Prevalidates (preapply) operation on tezos node

Type parameters:

Returns: (Anonymous function)


<Const> ready

ready(): Promise<void>

Defined in common/crypto.ts:114

Get sodium ready state

Returns: Promise<void>


<Const> rpc

rpc<T>(selector: function): (Anonymous function)

Defined in common/rpc.ts:20

Remote procedure call (RPC) on tezos node Returns state object with rpc result under property defined in rpc parameters

Type parameters:

T : State

Parameters:

Name Type Description
selector function method returning rpc parameters

Returns: (Anonymous function)


<Const> setDelegation

setDelegation<T>(selector: function): (Anonymous function)

Defined in delegate/setDelegate.ts:33

Set delegation rights to tezos address

Type parameters:

T : State

Parameters:

Name Type Description
selector function provides data for delegation operation

Returns: (Anonymous function)


signOperation

signOperation<T>(state: T): Observable< T & State & object & object & object>

Defined in operation/signOperation.ts:45

Sign operation in state. Software signing is used. throws: TypeError when operation is not available in state

Type parameters:

Parameters:

Name Type Description
state T transaction state

Returns: Observable< T & State & object & object & object>


signOperationTrezor

signOperationTrezor<T>(state: T): Observable< T & State & object & object & object>

Defined in operation/signOperation.ts:109

Sign operation using hardware Trezor wallet throws: Typerror when operation is not available

Type parameters:

Parameters:

Name Type Description
state T transaction state

Returns: Observable< T & State & object & object & object>


<Const> transaction

transaction<T>(selector: function): (Anonymous function)

Defined in transaction/createTransaction.ts:39

Send amount to another wallet

Fully covers send useace and get transaction to blockchain

Type parameters:

T : State

Parameters:

Name Type Description
selector function method returning transaction obejct

Returns: (Anonymous function)


<Const> updateFeesForOperation

updateFeesForOperation<T>(): (Anonymous function)

Defined in operation/forgeOperation.ts:89

Estimates minimal fee for the operation and compares provided defined fees with minimal If provided fee is insuficient its overriden

When fee is modified operation has to be re-forged so signature is matching operation content

Type parameters:

Returns: (Anonymous function)


<Const> validateOperation

validateOperation<T>(): (Anonymous function)

Defined in operation/validateOperation.ts:20

Validates operation on node to ensure, that operation can be executed and prefills gas consumption and storage size data

Type parameters:

Returns: (Anonymous function)


<Const> validateOperationAtomic

validateOperationAtomic<T>(): (Anonymous function)

Defined in operation/validateOperation.ts:92

Serialize operation parameters on node

Type parameters:

Returns: (Anonymous function)


validateOriginationOperation

validateOriginationOperation(operation: OperationMetadata): void

Defined in common/validation.ts:27

Check origination operation metadata in runtime to prevent hidden failues

Parameters:

Name Type
operation OperationMetadata

Returns: void


validateRevealOperation

validateRevealOperation(operation: OperationMetadata): void

Defined in common/validation.ts:6

Check reveal operation metadata in runtime to prevent hidden failues

Parameters:

Name Type
operation OperationMetadata

Returns: void


validateTransactionOperation

validateTransactionOperation(operation: OperationMetadata): void

Defined in common/validation.ts:16

Check transaction operation metadata in runtime to prevent hidden failues

Parameters:

Name Type
operation OperationMetadata

Returns: void


Object literals

<Const> prefix

prefix: object

Defined in common/crypto.ts:18

Prefix table

B

● B: Uint8Array = new Uint8Array([1, 52])

Defined in common/crypto.ts:23


KT1

● KT1: Uint8Array = new Uint8Array([2, 90, 121])

Defined in common/crypto.ts:22


edpk

● edpk: Uint8Array = new Uint8Array([13, 15, 37, 217])

Defined in common/crypto.ts:24


edsig

● edsig: Uint8Array = new Uint8Array([9, 245, 205, 134, 18])

Defined in common/crypto.ts:29


edsk32

● edsk32: Uint8Array = new Uint8Array([13, 15, 58, 7])

Defined in common/crypto.ts:28


edsk64

● edsk64: Uint8Array = new Uint8Array([43, 246, 78, 7])

Defined in common/crypto.ts:27


operation

● operation: Uint8Array = new Uint8Array([5, 116])

Defined in common/crypto.ts:30


p2pk

● p2pk: Uint8Array = new Uint8Array([3, 178, 139, 127])

Defined in common/crypto.ts:26


sppk

● sppk: Uint8Array = new Uint8Array([3, 254, 226, 86])

Defined in common/crypto.ts:25


tz1

● tz1: Uint8Array = new Uint8Array([6, 161, 159])

Defined in common/crypto.ts:19


tz2

● tz2: Uint8Array = new Uint8Array([6, 161, 161])

Defined in common/crypto.ts:20


tz3

● tz3: Uint8Array = new Uint8Array([6, 161, 164])

Defined in common/crypto.ts:21