@hypernetlabs/objects
Version:
Objects and types shared by the Hypernet Protocol
93 lines • 5.03 kB
TypeScript
import { ResultAsync, Result } from "neverthrow";
import { Subject } from "rxjs";
import { ActiveStateChannel } from "../ActiveStateChannel";
import { Balances } from "../Balances";
import { ChainId } from "../ChainId";
import { ControlClaim } from "../ControlClaim";
import { BlockchainUnavailableError, InvalidParametersError, ProxyError, GovernanceSignerUnavailableError, CoreInitializationErrors } from "../errors";
import { EthereumAccountAddress } from "../EthereumAccountAddress";
import { GatewayUrl } from "../GatewayUrl";
import { PullPayment } from "../PullPayment";
import { PushPayment } from "../PushPayment";
import { ProviderId } from "../ProviderId";
import { InitializeStatus } from "../InitializeStatus";
import { ChainInformation } from "../ChainInformation";
import { IHypernetPayments } from "../interfaces/IHypernetPayments";
import { IHypernetGovernance } from "../interfaces/IHypernetGovernance";
import { IHypernetRegistries } from "../interfaces/IHypernetRegistries";
/**
* HypernetCore is a single instance of the Hypernet Protocol, representing a single
* user account. The user can be /both/ a consumer and a provider.
*/
export interface IHypernetCore {
initialized(chainId?: ChainId): ResultAsync<boolean, ProxyError>;
waitInitialized(chainId?: ChainId): ResultAsync<void, ProxyError>;
/**
* Probably can be removed, but leaving as a reminder in case we need to solve
* the multiple-instance-of-Hypernet-core issue
*/
inControl(): Result<boolean, never>;
/**
* This returns the linked Ethereum accounts via your installed wallet (ie: Metamask)
*/
getEthereumAccounts(): ResultAsync<EthereumAccountAddress[], BlockchainUnavailableError | ProxyError>;
/**
* This must be called before most other calls; it is used to specify what account addres
* hypernet core will be representing.
* @param account The address that says who this instance of HypernetCore is representing.
*/
initialize(chainId?: ChainId): ResultAsync<InitializeStatus, CoreInitializationErrors>;
getInitializationStatus(): ResultAsync<InitializeStatus, ProxyError>;
providePrivateCredentials(privateKey: string | null, mnemonic: string | null): ResultAsync<void, InvalidParametersError | ProxyError>;
provideProviderId(providerId: ProviderId): ResultAsync<void, InvalidParametersError | ProxyError>;
rejectProviderIdRequest(): ResultAsync<void, ProxyError>;
getBlockNumber(): ResultAsync<number, BlockchainUnavailableError | ProxyError>;
retrieveChainInformationList(): ResultAsync<Map<ChainId, ChainInformation>, ProxyError>;
retrieveGovernanceChainInformation(): ResultAsync<ChainInformation, ProxyError>;
initializeForChainId(chainId: ChainId): ResultAsync<void, CoreInitializationErrors>;
switchProviderNetwork(chainId: ChainId): ResultAsync<void, BlockchainUnavailableError | ProxyError>;
getMainProviderChainId(): ResultAsync<ChainId, BlockchainUnavailableError | ProxyError>;
payments: IHypernetPayments;
governance: IHypernetGovernance;
registries: IHypernetRegistries;
/**
* Observables for seeing what's going on
*/
onControlClaimed: Subject<ControlClaim>;
onControlYielded: Subject<ControlClaim>;
onPushPaymentSent: Subject<PushPayment>;
onPullPaymentSent: Subject<PullPayment>;
onPushPaymentUpdated: Subject<PushPayment>;
onPullPaymentUpdated: Subject<PullPayment>;
onPushPaymentReceived: Subject<PushPayment>;
onPullPaymentReceived: Subject<PullPayment>;
onPushPaymentDelayed: Subject<PushPayment>;
onPullPaymentDelayed: Subject<PullPayment>;
onPushPaymentCanceled: Subject<PushPayment>;
onPullPaymentCanceled: Subject<PullPayment>;
onBalancesChanged: Subject<Balances>;
onCeramicAuthenticationStarted: Subject<void>;
onCeramicAuthenticationSucceeded: Subject<void>;
onCeramicFailed: Subject<Error>;
onGatewayAuthorized: Subject<GatewayUrl>;
onGatewayDeauthorizationStarted: Subject<GatewayUrl>;
onAuthorizedGatewayUpdated: Subject<GatewayUrl>;
onAuthorizedGatewayActivationFailed: Subject<GatewayUrl>;
onGatewayIFrameDisplayRequested: Subject<GatewayUrl>;
onGatewayIFrameCloseRequested: Subject<GatewayUrl>;
onCoreIFrameDisplayRequested: Subject<void>;
onCoreIFrameCloseRequested: Subject<void>;
onInitializationRequired: Subject<void>;
onPrivateCredentialsRequested: Subject<void>;
onWalletConnectOptionsDisplayRequested: Subject<void>;
onStateChannelCreated: Subject<ActiveStateChannel>;
onChainConnected: Subject<ChainId>;
onGovernanceChainConnected: Subject<ChainId>;
onChainChanged: Subject<ChainId>;
onAccountChanged: Subject<EthereumAccountAddress>;
onGovernanceChainChanged: Subject<ChainId>;
onGovernanceAccountChanged: Subject<EthereumAccountAddress>;
onGovernanceSignerUnavailable: Subject<GovernanceSignerUnavailableError>;
}
export declare const IHypernetCoreType: unique symbol;
//# sourceMappingURL=IHypernetCore.d.ts.map