@test-org122/hypernet-core
Version:
Hypernet Core. Represents the SDK for running the Hypernet Protocol.
70 lines • 4.7 kB
TypeScript
import { IPaymentRepository } from "@interfaces/data/IPaymentRepository";
import { EthereumAddress, Payment, PublicIdentifier, PublicKey, ResultAsync } from "@interfaces/objects";
import { CoreUninitializedError, LogicalError, PaymentStakeError, RouterChannelUnknownError, TransferResolutionError, VectorError } from "@interfaces/objects/errors";
import { IBrowserNodeProvider, IConfigProvider, IContextProvider, IFullTransferState, ILogUtils, IPaymentUtils, ITimeUtils, IVectorUtils } from "@interfaces/utilities";
/**
* Contains methods for creating push, pull, etc payments,
* as well as retrieving them, and finalizing them.
*/
export declare class PaymentRepository implements IPaymentRepository {
protected browserNodeProvider: IBrowserNodeProvider;
protected vectorUtils: IVectorUtils;
protected configProvider: IConfigProvider;
protected contextProvider: IContextProvider;
protected paymentUtils: IPaymentUtils;
protected logUtils: ILogUtils;
protected timeUtils: ITimeUtils;
/**
* Returns an instance of PaymentRepository
*/
constructor(browserNodeProvider: IBrowserNodeProvider, vectorUtils: IVectorUtils, configProvider: IConfigProvider, contextProvider: IContextProvider, paymentUtils: IPaymentUtils, logUtils: ILogUtils, timeUtils: ITimeUtils);
createPullRecord(paymentId: string, amount: string): ResultAsync<Payment, RouterChannelUnknownError | CoreUninitializedError | VectorError | Error>;
createPullPayment(counterPartyAccount: PublicIdentifier, maximumAmount: string, // TODO: amounts should be consistently use BigNumber
deltaTime: number, deltaAmount: string, // TODO: amounts should be consistently use BigNumber
expirationDate: number, requiredStake: string, // TODO: amounts should be consistently use BigNumber
paymentToken: EthereumAddress, merchantUrl: string): ResultAsync<Payment, RouterChannelUnknownError | CoreUninitializedError | VectorError | Error>;
/**
* Creates a push payment and returns it. Nothing moves until
* the payment is accepted; the payment will return with the
* "PROPOSED" status. This function just creates an OfferTransfer.
* @param counterPartyAccount the public identifier of the account to pay
* @param amount the amount to pay the counterparty
* @param expirationDate the date (in unix time) at which point the payment will expire & revert
* @param requiredStake the amount of insurance the counterparty must put up for this payment
* @param paymentToken the (Ethereum) address of the payment token
* @param merchantUrl the registered URL for the merchant that will resolve any disputes.
*/
createPushPayment(counterPartyAccount: PublicIdentifier, amount: string, expirationDate: number, requiredStake: string, paymentToken: EthereumAddress, merchantUrl: string): ResultAsync<Payment, RouterChannelUnknownError | CoreUninitializedError | VectorError | Error>;
/**
* Given a paymentId, return the component transfers.
* @param paymentId the payment to get transfers for
*/
protected _getTransfersByPaymentId(paymentId: string): ResultAsync<IFullTransferState[], Error>;
/**
* Given a list of payment Ids, return the associated payments.
* @param paymentIds the list of payments to get
*/
getPaymentsByIds(paymentIds: string[]): ResultAsync<Map<string, Payment>, Error>;
/**
* Finalizes/confirms a payment
* Internally, this is what actually calls resolve() on the Vector transfer -
* be it a insurancePayments or parameterizedPayments.
* @param paymentId the payment to finalize
* @param amount the amount of the payment to finalize for
*/
finalizePayment(paymentId: string, amount: string): ResultAsync<Payment, RouterChannelUnknownError | CoreUninitializedError | VectorError | Error>;
/**
* Provides stake for a given payment id
* Internally, this is what actually creates the InsurancePayments with Vector.
* @param paymentId the payment for which to provide stake for
*/
provideStake(paymentId: string, merchantPublicKey: PublicKey): ResultAsync<Payment, PaymentStakeError | TransferResolutionError | RouterChannelUnknownError | CoreUninitializedError | VectorError | Error>;
/**
* Singular version of provideAssets
* Internally, creates a parameterizedPayment with Vector,
* and returns a payment of state 'Approved'
* @param paymentId the payment for which to provide an asset for
*/
provideAsset(paymentId: string): ResultAsync<Payment, RouterChannelUnknownError | CoreUninitializedError | VectorError | LogicalError>;
}
//# sourceMappingURL=PaymentRepository.d.ts.map