UNPKG

@test-org122/hypernet-core

Version:

Hypernet Core. Represents the SDK for running the Hypernet Protocol.

82 lines 5.96 kB
import { BigNumber, HypernetConfig, IHypernetOfferDetails, PublicIdentifier, PublicKey, ResultAsync } from "@interfaces/objects"; import { IBrowserNodeProvider, IContextProvider, IVectorUtils, IConfigProvider, IBlockchainProvider, ILogUtils, IPaymentIdUtils, IBrowserNode, IBasicTransferResponse, IBasicChannelResponse, IFullChannelState, IFullTransferState, ITimeUtils } from "@interfaces/utilities"; import { EPaymentType, ETransferState } from "@interfaces/types"; import "reflect-metadata"; import { CoreUninitializedError, InvalidParametersError, RouterChannelUnknownError, RouterUnavailableError, TransferCreationError, TransferResolutionError, VectorError } from "@interfaces/objects/errors"; import { IHypernetPullPaymentDetails } from "../../interfaces/objects/HypernetPullPaymentDetails"; /** * VectorUtils contains methods for interacting directly with the core Vector stuff - * creating transfers, resolving them, & dealing the with router channel. */ export declare class VectorUtils implements IVectorUtils { protected configProvider: IConfigProvider; protected contextProvider: IContextProvider; protected browserNodeProvider: IBrowserNodeProvider; protected blockchainProvider: IBlockchainProvider; protected paymentIdUtils: IPaymentIdUtils; protected logUtils: ILogUtils; protected timeUtils: ITimeUtils; /** * Creates an instance of VectorUtils */ protected getRouterChannelAddressSetup: ResultAsync<string, RouterUnavailableError | CoreUninitializedError> | null; constructor(configProvider: IConfigProvider, contextProvider: IContextProvider, browserNodeProvider: IBrowserNodeProvider, blockchainProvider: IBlockchainProvider, paymentIdUtils: IPaymentIdUtils, logUtils: ILogUtils, timeUtils: ITimeUtils); /** * Resolves a message/offer/null transfer with Vector. * @param transferId the ID of the transfer to resolve */ resolveMessageTransfer(transferId: string): ResultAsync<IBasicTransferResponse, TransferResolutionError>; /** * Resolves a parameterized payment transfer with Vector. * @param transferId the ID of the transfer to resolve */ resolvePaymentTransfer(transferId: string, paymentId: string, amount: string): ResultAsync<IBasicTransferResponse, TransferResolutionError>; /** * Resolves an insurance transfer with Vector. * @param transferId the ID of the tarnsfer to resolve */ resolveInsuranceTransfer(transferId: string, paymentId: string, mediatorSignature?: string, amount?: BigNumber): ResultAsync<IBasicTransferResponse, TransferResolutionError>; /** * Creates a "Message" transfer with Vector, to notify the other party of a pull payment * @param toAddress the public identifier (not eth address!) of the intended recipient * @param message the message to send as IHypernetOfferDetails */ createPullNotificationTransfer(toAddress: string, message: IHypernetPullPaymentDetails): ResultAsync<IBasicTransferResponse, TransferCreationError | InvalidParametersError>; /** * Creates a "Message" transfer with Vector, to notify the other party of a payment creation * @param toAddress the public identifier (not eth address!) of the intended recipient * @param message the message to send as IHypernetOfferDetails */ createOfferTransfer(toAddress: string, message: IHypernetOfferDetails): ResultAsync<IBasicTransferResponse, TransferCreationError | InvalidParametersError>; /** * Creates a "Parameterized" transfer with Vector. * @param type "PUSH" or "PULL" * @param toAddress the public identifier of the intended recipient of this transfer * @param amount the amount of tokens to commit to this transfer * @param assetAddress the address of the ERC20-token to transfer; zero-address for ETH * @param paymentId length-64 hexadecimal string; this becomes the UUID component of the InsuranceState * @param start the start time of this transfer (UNIX timestamp) * @param expiration the expiration time of this transfer (UNIX timestamp) * @param rate the maximum allowed rate of this transfer (deltaAmount/deltaTime) */ createPaymentTransfer(type: EPaymentType, toAddress: PublicIdentifier, amount: BigNumber, assetAddress: string, paymentId: string, start: number, expiration: number, deltaTime?: number, deltaAmount?: string): ResultAsync<IBasicTransferResponse, TransferCreationError | InvalidParametersError>; /** * Creates the actual Insurance transfer with Vector * @param toAddress the publicIdentifier of the person to send the transfer to * @param mediatorAddress the Ethereum address of the mediator * @param amount the amount of the token to commit into the InsuranceTransfer * @param expiration the expiration date of this InsuranceTransfer * @param paymentId a length-64 hexadecimal string; this becomes the UUID component of the InsuranceState */ createInsuranceTransfer(toAddress: PublicIdentifier, mediatorPublicKey: PublicKey, amount: BigNumber, expiration: number, paymentId: string): ResultAsync<IBasicTransferResponse, TransferCreationError | InvalidParametersError>; /** * Returns the address of the channel with the router, if exists. * Otherwise, attempts to create a channel with the router & return the address. */ getRouterChannelAddress(): ResultAsync<string, RouterChannelUnknownError | CoreUninitializedError>; getTimestampFromTransfer(transfer: IFullTransferState): number; getTransferStateFromTransfer(transfer: IFullTransferState): ETransferState; protected _createRouterStateChannel(browserNode: IBrowserNode, config: HypernetConfig): ResultAsync<IBasicChannelResponse, VectorError>; protected _getStateChannel(channelAddress: string, browserNode: IBrowserNode): ResultAsync<IFullChannelState, RouterChannelUnknownError | VectorError>; } //# sourceMappingURL=VectorUtils.d.ts.map