UNPKG

@airgap/etherlink

Version:

The @airgap/etherlink package is an implementation of the ICoinProtocol interface from @airgap/coinlib-core.

69 lines (68 loc) 12.8 kB
import { Address, AddressCursor, AddressWithCursor } from '../types/address'; import { AirGapInterface, ApplicableProtocolExtension } from '../types/airgap'; import { Amount } from '../types/amount'; import { Balance } from '../types/balance'; import { CryptoConfiguration, CryptoDerivative } from '../types/crypto'; import { FeeEstimation } from '../types/fee'; import { ExtendedKeyPair, ExtendedPublicKey, ExtendedSecretKey, KeyPair, PublicKey, SecretKey } from '../types/key'; import { Complement } from '../types/meta/utility-types'; import { ProtocolMetadata, ProtocolNetwork } from '../types/protocol'; import { AirGapTransaction, AirGapTransactionsWithCursor, SignedTransaction, TransactionSimpleConfiguration, TransactionCursor, TransactionDetails, UnsignedTransaction, TransactionFullConfiguration } from '../types/transaction'; export interface BaseGeneric<_AddressCursor extends AddressCursor = AddressCursor, _AddressResult extends Address | AddressWithCursor<_AddressCursor> = Address | AddressWithCursor<_AddressCursor>, _Units extends string = string, _FeeUnits extends string = _Units, _SignedTransaction extends SignedTransaction = SignedTransaction, _UnsignedTransaction extends UnsignedTransaction = UnsignedTransaction> { AddressCursor: _AddressCursor; AddressResult: _AddressResult; Units: _Units; FeeUnits: _FeeUnits; SignedTransaction: _SignedTransaction; UnsignedTransaction: _UnsignedTransaction; } export interface OfflineGeneric<_AddressCursor extends AddressCursor = AddressCursor, _AddressResult extends Address | AddressWithCursor<_AddressCursor> = Address | AddressWithCursor<_AddressCursor>, _CryptoConfiguration extends CryptoConfiguration = CryptoConfiguration, _Units extends string = string, _FeeUnits extends string = _Units, _SignedTransaction extends SignedTransaction = SignedTransaction, _UnsignedTransaction extends UnsignedTransaction = UnsignedTransaction> extends BaseGeneric<_AddressCursor, _AddressResult, _Units, _FeeUnits, _SignedTransaction, _UnsignedTransaction> { CryptoConfiguration: _CryptoConfiguration; } export interface OnlineGeneric<_AddressCursor extends AddressCursor = AddressCursor, _AddressResult extends Address | AddressWithCursor<_AddressCursor> = Address | AddressWithCursor<_AddressCursor>, _ProtocolNetwork extends ProtocolNetwork = ProtocolNetwork, _Units extends string = string, _FeeUnits extends string = _Units, _FeeEstimation extends FeeEstimation<_FeeUnits> | undefined = FeeEstimation<_FeeUnits> | undefined, _SignedTransaction extends SignedTransaction = SignedTransaction, _UnsignedTransaction extends UnsignedTransaction = UnsignedTransaction, _TransactionCursor extends TransactionCursor = TransactionCursor> extends BaseGeneric<_AddressCursor, _AddressResult, _Units, _FeeUnits, _SignedTransaction, _UnsignedTransaction> { ProtocolNetwork: _ProtocolNetwork; FeeEstimation: _FeeEstimation; TransactionCursor: _TransactionCursor; } declare type TypedAddressCursor<G extends Partial<BaseGeneric>> = Complement<BaseGeneric, G>['AddressCursor']; declare type TypedAddressResult<G extends Partial<BaseGeneric>> = Complement<BaseGeneric<TypedAddressCursor<G>>, G>['AddressResult']; declare type TypedProtocolNetwork<G extends Partial<OnlineGeneric>> = Complement<OnlineGeneric, G>['ProtocolNetwork']; declare type TypedCryptoConfiguration<G extends Partial<OfflineGeneric>> = Complement<OfflineGeneric, G>['CryptoConfiguration']; declare type TypedUnits<G extends Partial<BaseGeneric>> = Complement<BaseGeneric, G>['Units']; declare type TypedFeeUnits<G extends Partial<BaseGeneric>> = Complement<BaseGeneric<any, any, TypedUnits<G>>, G>['FeeUnits']; declare type TypedFeeEstimation<G extends Partial<OnlineGeneric>> = Complement<OnlineGeneric<any, any, any, any, TypedFeeUnits<G>>, G>['FeeEstimation']; declare type TypedSignedTransaction<G extends Partial<BaseGeneric>> = Complement<BaseGeneric, G>['SignedTransaction']; declare type TypedUnsignedTransaction<G extends Partial<BaseGeneric>> = Complement<BaseGeneric, G>['UnsignedTransaction']; declare type TypedTransactionCursor<G extends Partial<OnlineGeneric>> = Complement<OnlineGeneric, G>['TransactionCursor']; export interface _BaseProtocol<_AddressCursor extends BaseGeneric['AddressCursor'] = any, _AddressResult extends BaseGeneric['AddressResult'] = any, _Units extends BaseGeneric['Units'] = any, _FeeUnits extends BaseGeneric['FeeUnits'] = any, _SignedTransaction extends BaseGeneric['SignedTransaction'] = any, _UnsignedTransaction extends BaseGeneric['UnsignedTransaction'] = any, _PublicKey extends PublicKey | ExtendedPublicKey = any> { getMetadata(): Promise<ProtocolMetadata<_Units, _FeeUnits>>; getAddressFromPublicKey(publicKey: _PublicKey): Promise<_AddressResult>; getDetailsFromTransaction(transaction: _UnsignedTransaction | _SignedTransaction, publicKey: _PublicKey): Promise<AirGapTransaction<_Units, _FeeUnits>[]>; } export declare type BaseProtocol<G extends Partial<BaseGeneric> = {}> = _BaseProtocol<TypedAddressCursor<G>, TypedAddressResult<G>, TypedUnits<G>, TypedFeeUnits<G>, TypedSignedTransaction<G>, TypedUnsignedTransaction<G>, PublicKey>; export interface _OfflineProtocol<_AddressCursor extends OfflineGeneric['AddressCursor'] = any, _AddressResult extends OfflineGeneric['AddressResult'] = any, _CryptoConfiguration extends OfflineGeneric['CryptoConfiguration'] = any, _Units extends BaseGeneric['Units'] = any, _FeeUnits extends BaseGeneric['FeeUnits'] = any, _SignedTransaction extends BaseGeneric['SignedTransaction'] = any, _UnsignedTransaction extends BaseGeneric['UnsignedTransaction'] = any, _PublicKey extends PublicKey | ExtendedPublicKey = any, _SecretKey extends SecretKey | ExtendedSecretKey = any, _KeyPair extends KeyPair | ExtendedKeyPair = any> extends _BaseProtocol<_AddressCursor, _AddressResult, _Units, _FeeUnits, _SignedTransaction, _UnsignedTransaction, _PublicKey> { getCryptoConfiguration(): Promise<_CryptoConfiguration>; getKeyPairFromDerivative(derivative: CryptoDerivative): Promise<KeyPair>; signTransactionWithSecretKey(transaction: _UnsignedTransaction, secretKey: _SecretKey): Promise<_SignedTransaction>; } export declare type OfflineProtocol<G extends Partial<OfflineGeneric> = {}> = _OfflineProtocol<TypedAddressCursor<G>, TypedAddressResult<G>, TypedCryptoConfiguration<G>, TypedUnits<G>, TypedFeeUnits<G>, TypedSignedTransaction<G>, TypedUnsignedTransaction<G>, PublicKey, SecretKey, KeyPair>; export interface _OnlineProtocol<_AddressCursor extends OnlineGeneric['AddressCursor'] = any, _AddressResult extends OnlineGeneric['AddressResult'] = any, _ProtocolNetwork extends OnlineGeneric['ProtocolNetwork'] = any, _Units extends OnlineGeneric['Units'] = any, _FeeUnits extends OnlineGeneric['FeeUnits'] = any, _FeeEstimation extends OnlineGeneric['FeeEstimation'] = any, _SignedTransaction extends OnlineGeneric['SignedTransaction'] = any, _UnsignedTransaction extends OnlineGeneric['UnsignedTransaction'] = any, _TransactionCursor extends OnlineGeneric['TransactionCursor'] = any, _PublicKey extends PublicKey | ExtendedPublicKey = any, _BalanceConfiguration extends Object | undefined = any> extends _BaseProtocol<_AddressCursor, _AddressResult, _Units, _FeeUnits, _SignedTransaction, _UnsignedTransaction, _PublicKey> { getNetwork(): Promise<_ProtocolNetwork>; getTransactionsForPublicKey(publicKey: _PublicKey, limit: number, cursor?: _TransactionCursor): Promise<AirGapTransactionsWithCursor<_TransactionCursor, _Units, _FeeUnits>>; getBalanceOfPublicKey(publicKey: _PublicKey, configuration?: _BalanceConfiguration): Promise<Balance<_Units>>; getTransactionMaxAmountWithPublicKey(publicKey: _PublicKey, to: Address[], configuration?: TransactionFullConfiguration<_FeeUnits>): Promise<Amount<_Units>>; getTransactionFeeWithPublicKey(publicKey: _PublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionSimpleConfiguration): Promise<_FeeEstimation>; prepareTransactionWithPublicKey(publicKey: _PublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionFullConfiguration<_FeeUnits>): Promise<_UnsignedTransaction>; broadcastTransaction(transaction: _SignedTransaction): Promise<string>; } export declare type OnlineProtocol<G extends Partial<OnlineGeneric> = {}> = _OnlineProtocol<TypedAddressCursor<G>, TypedAddressResult<G>, TypedProtocolNetwork<G>, TypedUnits<G>, TypedFeeUnits<G>, TypedFeeEstimation<G>, TypedSignedTransaction<G>, TypedUnsignedTransaction<G>, TypedTransactionCursor<G>, PublicKey, undefined>; export declare type _Protocol = _OfflineProtocol & _OnlineProtocol; export interface Protocol<G extends Partial<OfflineGeneric & OnlineGeneric> = {}> extends OfflineProtocol<G>, OnlineProtocol<G> { } export declare type _AnyProtocol = _OfflineProtocol | _OnlineProtocol; export declare type AnyProtocol<G extends Partial<OfflineGeneric & OnlineGeneric> = {}> = OfflineProtocol<G> | OnlineProtocol<G>; export declare type AirGapOfflineProtocol<G extends Partial<OfflineGeneric> = {}, E0 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E1 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E2 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E3 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E4 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E5 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E6 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E7 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E8 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined, E9 extends ApplicableProtocolExtension<_OfflineProtocol> = undefined> = AirGapInterface<OfflineProtocol<G>, E0, E1, E2, E3, E4, E5, E6, E7, E8, E9>; export declare type AirGapOnlineProtocol<G extends Partial<OnlineGeneric> = {}, E0 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E1 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E2 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E3 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E4 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E5 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E6 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E7 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E8 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined, E9 extends ApplicableProtocolExtension<_OnlineProtocol> = undefined> = AirGapInterface<OnlineProtocol<G>, E0, E1, E2, E3, E4, E5, E6, E7, E8, E9>; export declare type AirGapProtocol<G extends Partial<OfflineGeneric & OnlineGeneric> = {}, E0 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E1 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E2 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E3 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E4 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E5 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E6 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E7 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E8 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined, E9 extends ApplicableProtocolExtension<_OfflineProtocol & _OnlineProtocol> = undefined> = AirGapInterface<Protocol<G>, E0, E1, E2, E3, E4, E5, E6, E7, E8, E9>; export declare type AirGapAnyProtocol<G extends Partial<OfflineGeneric & OnlineGeneric> = {}, E0 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E1 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E2 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E3 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E4 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E5 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E6 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E7 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E8 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined, E9 extends ApplicableProtocolExtension<_OfflineProtocol | _OnlineProtocol> = undefined> = AirGapInterface<AnyProtocol<G>, E0, E1, E2, E3, E4, E5, E6, E7, E8, E9>; export {};