restructure api types

This commit is contained in:
Florian Dold 2022-10-04 13:12:15 +02:00
parent bbde2a9bb9
commit 37d27ba437
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 303 additions and 193 deletions

View File

@ -423,11 +423,17 @@ export const codecForPreparePayResult = (): Codec<PreparePayResult> =>
) )
.build("PreparePayResult"); .build("PreparePayResult");
/**
* Result of a prepare pay operation.
*/
export type PreparePayResult = export type PreparePayResult =
| PreparePayResultInsufficientBalance | PreparePayResultInsufficientBalance
| PreparePayResultAlreadyConfirmed | PreparePayResultAlreadyConfirmed
| PreparePayResultPaymentPossible; | PreparePayResultPaymentPossible;
/**
* Payment is possible.
*/
export interface PreparePayResultPaymentPossible { export interface PreparePayResultPaymentPossible {
status: PreparePayResultType.PaymentPossible; status: PreparePayResultType.PaymentPossible;
proposalId: string; proposalId: string;
@ -604,7 +610,7 @@ export interface KnownBankAccountsInfo {
uri: PaytoUri; uri: PaytoUri;
kyc_completed: boolean; kyc_completed: boolean;
currency: string; currency: string;
alias: string, alias: string;
} }
export interface KnownBankAccounts { export interface KnownBankAccounts {
@ -1092,9 +1098,9 @@ export interface AddKnownBankAccountsRequest {
export const codecForAddKnownBankAccounts = export const codecForAddKnownBankAccounts =
(): Codec<AddKnownBankAccountsRequest> => (): Codec<AddKnownBankAccountsRequest> =>
buildCodecForObject<AddKnownBankAccountsRequest>() buildCodecForObject<AddKnownBankAccountsRequest>()
.property("payto", (codecForString())) .property("payto", codecForString())
.property("alias", (codecForString())) .property("alias", codecForString())
.property("currency", (codecForString())) .property("currency", codecForString())
.build("AddKnownBankAccountsRequest"); .build("AddKnownBankAccountsRequest");
export interface ForgetKnownBankAccountsRequest { export interface ForgetKnownBankAccountsRequest {
@ -1104,7 +1110,7 @@ export interface ForgetKnownBankAccountsRequest {
export const codecForForgetKnownBankAccounts = export const codecForForgetKnownBankAccounts =
(): Codec<ForgetKnownBankAccountsRequest> => (): Codec<ForgetKnownBankAccountsRequest> =>
buildCodecForObject<ForgetKnownBankAccountsRequest>() buildCodecForObject<ForgetKnownBankAccountsRequest>()
.property("payto", (codecForString())) .property("payto", codecForString())
.build("ForgetKnownBankAccountsRequest"); .build("ForgetKnownBankAccountsRequest");
export interface GetExchangeWithdrawalInfo { export interface GetExchangeWithdrawalInfo {

View File

@ -138,195 +138,299 @@ export enum WalletApiOperation {
Recycle = "recycle", Recycle = "recycle",
} }
/**
* Initialize wallet-core.
*
* Must be the first message sent before any other operations.
*/
export type InitWalletOp = {
op: WalletApiOperation.InitWallet;
request: {};
response: {};
};
export type WithdrawFakebankOp = {
op: WalletApiOperation.WithdrawFakebank;
request: WithdrawFakebankRequest;
response: {};
};
export type PreparePayForUriOp = {
op: WalletApiOperation.PreparePayForUri;
request: PreparePayRequest;
response: PreparePayResult;
};
export type WithdrawTestkudosOp = {
op: WalletApiOperation.WithdrawTestkudos;
request: {};
response: {};
};
export type ConfirmPayOp = {
op: WalletApiOperation.ConfirmPay;
request: ConfirmPayRequest;
response: ConfirmPayResult;
};
export type AbortPayWithRefundOp = {
request: AbortPayWithRefundRequest;
response: {};
};
export type GetBalancesOp = {
request: {};
response: BalancesResponse;
};
export type GetTransactionsOp = {
request: TransactionsRequest;
response: TransactionsResponse;
};
export type GetPendingOperationsOp = {
request: {};
response: PendingOperationsResponse;
};
export type DumpCoinsOp = {
request: {};
response: CoinDumpJson;
};
export type SetCoinSuspendedOp = {
request: SetCoinSuspendedRequest;
response: {};
};
export type ForceRefreshOp = {
request: ForceRefreshRequest;
response: {};
};
export type DeleteTransactionOp = {
request: DeleteTransactionRequest;
response: {};
};
export type RetryTransactionOp = {
request: RetryTransactionRequest;
response: {};
};
export type PrepareTipOp = {
request: PrepareTipRequest;
response: PrepareTipResult;
};
export type AcceptTipOp = {
request: AcceptTipRequest;
response: {};
};
export type ApplyRefundOp = {
request: ApplyRefundRequest;
response: ApplyRefundResponse;
};
export type ListCurrenciesOp = {
request: {};
response: WalletCurrencyInfo;
};
export type GetWithdrawalDetailsForAmountOp = {
request: GetWithdrawalDetailsForAmountRequest;
response: ManualWithdrawalDetails;
};
export type GetWithdrawalDetailsForUriOp = {
request: GetWithdrawalDetailsForUriRequest;
response: WithdrawUriInfoResponse;
};
export type AcceptBankIntegratedWithdrawalOp = {
request: AcceptBankIntegratedWithdrawalRequest;
response: AcceptWithdrawalResponse;
};
export type AcceptManualWithdrawalOp = {
request: AcceptManualWithdrawalRequest;
response: AcceptManualWithdrawalResult;
};
export type ListExchangesOp = {
request: {};
response: ExchangesListResponse;
};
export type AddExchangeOp = {
request: AddExchangeRequest;
response: {};
};
export type SetExchangeTosAcceptedOp = {
request: AcceptExchangeTosRequest;
response: {};
};
export type GetExchangeTosOp = {
request: GetExchangeTosRequest;
response: GetExchangeTosResult;
};
export type TrackDepositGroupOp = {
request: TrackDepositGroupRequest;
response: TrackDepositGroupResponse;
};
export type CreateDepositGroupOp = {
request: CreateDepositGroupRequest;
response: CreateDepositGroupResponse;
};
export type SetWalletDeviceIdOp = {
request: SetWalletDeviceIdRequest;
response: {};
};
export type ExportBackupPlainOp = {
request: {};
response: WalletBackupContentV1;
};
export type ExportBackupRecoveryOp = {
request: {};
response: BackupRecovery;
};
export type ImportBackupRecoveryOp = {
request: RecoveryLoadRequest;
response: {};
};
export type RunBackupCycleOp = {
request: {};
response: {};
};
export type AddBackupProviderOp = {
request: AddBackupProviderRequest;
response: {};
};
export type GetBackupInfoOp = {
request: {};
response: BackupInfo;
};
export type RunIntegrationTestOp = {
request: IntegrationTestArgs;
response: {};
};
export type WithdrawTestBalanceOp = {
request: WithdrawTestBalanceRequest;
response: {};
};
export type TestPayOp = {
request: TestPayArgs;
response: TestPayResult;
};
export type ExportDbOp = {
request: {};
response: any;
};
export type InitiatePeerPushPaymentOp = {
request: InitiatePeerPushPaymentRequest;
response: InitiatePeerPushPaymentResponse;
};
export type CheckPeerPushPaymentOp = {
request: CheckPeerPushPaymentRequest;
response: CheckPeerPushPaymentResponse;
};
export type AcceptPeerPushPaymentOp = {
request: AcceptPeerPushPaymentRequest;
response: {};
};
export type InitiatePeerPullPaymentOp = {
request: InitiatePeerPullPaymentRequest;
response: InitiatePeerPullPaymentResponse;
};
export type CheckPeerPullPaymentOp = {
request: CheckPeerPullPaymentRequest;
response: CheckPeerPullPaymentResponse;
};
export type AcceptPeerPullPaymentOp = {
request: AcceptPeerPullPaymentRequest;
response: {};
};
export type ClearDbOp = {
request: {};
response: {};
};
export type RecycleOp = {
request: {};
response: {};
};
export type WalletOperations = { export type WalletOperations = {
[WalletApiOperation.InitWallet]: { [WalletApiOperation.InitWallet]: InitWalletOp;
request: {}; [WalletApiOperation.WithdrawFakebank]: WithdrawFakebankOp;
response: {}; [WalletApiOperation.PreparePayForUri]: PreparePayForUriOp;
}; [WalletApiOperation.WithdrawTestkudos]: WithdrawTestkudosOp;
[WalletApiOperation.WithdrawFakebank]: { [WalletApiOperation.ConfirmPay]: ConfirmPayOp;
request: WithdrawFakebankRequest; [WalletApiOperation.AbortFailedPayWithRefund]: AbortPayWithRefundOp;
response: {}; [WalletApiOperation.GetBalances]: GetBalancesOp;
}; [WalletApiOperation.GetTransactions]: GetTransactionsOp;
[WalletApiOperation.PreparePayForUri]: { [WalletApiOperation.GetPendingOperations]: GetPendingOperationsOp;
request: PreparePayRequest; [WalletApiOperation.DumpCoins]: DumpCoinsOp;
response: PreparePayResult; [WalletApiOperation.SetCoinSuspended]: SetCoinSuspendedOp;
}; [WalletApiOperation.ForceRefresh]: ForceRefreshOp;
[WalletApiOperation.WithdrawTestkudos]: { [WalletApiOperation.DeleteTransaction]: DeleteTransactionOp;
request: {}; [WalletApiOperation.RetryTransaction]: RetryTransactionOp;
response: {}; [WalletApiOperation.PrepareTip]: PrepareTipOp;
}; [WalletApiOperation.AcceptTip]: AcceptTipOp;
[WalletApiOperation.ConfirmPay]: { [WalletApiOperation.ApplyRefund]: ApplyRefundOp;
request: ConfirmPayRequest; [WalletApiOperation.ListCurrencies]: ListCurrenciesOp;
response: ConfirmPayResult; [WalletApiOperation.GetWithdrawalDetailsForAmount]: GetWithdrawalDetailsForAmountOp;
}; [WalletApiOperation.GetWithdrawalDetailsForUri]: GetWithdrawalDetailsForUriOp;
[WalletApiOperation.AbortFailedPayWithRefund]: { [WalletApiOperation.AcceptBankIntegratedWithdrawal]: AcceptBankIntegratedWithdrawalOp;
request: AbortPayWithRefundRequest; [WalletApiOperation.AcceptManualWithdrawal]: AcceptManualWithdrawalOp;
response: {}; [WalletApiOperation.ListExchanges]: ListExchangesOp;
}; [WalletApiOperation.AddExchange]: AddExchangeOp;
[WalletApiOperation.GetBalances]: { [WalletApiOperation.SetExchangeTosAccepted]: SetExchangeTosAcceptedOp;
request: {}; [WalletApiOperation.GetExchangeTos]: GetExchangeTosOp;
response: BalancesResponse; [WalletApiOperation.TrackDepositGroup]: TrackDepositGroupOp;
}; [WalletApiOperation.CreateDepositGroup]: CreateDepositGroupOp;
[WalletApiOperation.GetTransactions]: { [WalletApiOperation.SetWalletDeviceId]: SetWalletDeviceIdOp;
request: TransactionsRequest; [WalletApiOperation.ExportBackupPlain]: ExportBackupPlainOp;
response: TransactionsResponse; [WalletApiOperation.ExportBackupRecovery]: ExportBackupRecoveryOp;
}; [WalletApiOperation.ImportBackupRecovery]: ImportBackupRecoveryOp;
[WalletApiOperation.GetPendingOperations]: { [WalletApiOperation.RunBackupCycle]: RunBackupCycleOp;
request: {}; [WalletApiOperation.AddBackupProvider]: AddBackupProviderOp;
response: PendingOperationsResponse; [WalletApiOperation.GetBackupInfo]: GetBackupInfoOp;
}; [WalletApiOperation.RunIntegrationTest]: RunIntegrationTestOp;
[WalletApiOperation.DumpCoins]: { [WalletApiOperation.WithdrawTestBalance]: WithdrawTestBalanceOp;
request: {}; [WalletApiOperation.TestPay]: TestPayOp;
response: CoinDumpJson; [WalletApiOperation.ExportDb]: ExportDbOp;
}; [WalletApiOperation.InitiatePeerPushPayment]: InitiatePeerPushPaymentOp;
[WalletApiOperation.SetCoinSuspended]: { [WalletApiOperation.CheckPeerPushPayment]: CheckPeerPushPaymentOp;
request: SetCoinSuspendedRequest; [WalletApiOperation.AcceptPeerPushPayment]: AcceptPeerPushPaymentOp;
response: {}; [WalletApiOperation.InitiatePeerPullPayment]: InitiatePeerPullPaymentOp;
}; [WalletApiOperation.CheckPeerPullPayment]: CheckPeerPullPaymentOp;
[WalletApiOperation.ForceRefresh]: { [WalletApiOperation.AcceptPeerPullPayment]: AcceptPeerPullPaymentOp;
request: ForceRefreshRequest; [WalletApiOperation.ClearDb]: ClearDbOp;
response: {}; [WalletApiOperation.Recycle]: RecycleOp;
};
[WalletApiOperation.DeleteTransaction]: {
request: DeleteTransactionRequest;
response: {};
};
[WalletApiOperation.RetryTransaction]: {
request: RetryTransactionRequest;
response: {};
};
[WalletApiOperation.PrepareTip]: {
request: PrepareTipRequest;
response: PrepareTipResult;
};
[WalletApiOperation.AcceptTip]: {
request: AcceptTipRequest;
response: {};
};
[WalletApiOperation.ApplyRefund]: {
request: ApplyRefundRequest;
response: ApplyRefundResponse;
};
[WalletApiOperation.ListCurrencies]: {
request: {};
response: WalletCurrencyInfo;
};
[WalletApiOperation.GetWithdrawalDetailsForAmount]: {
request: GetWithdrawalDetailsForAmountRequest;
response: ManualWithdrawalDetails;
};
[WalletApiOperation.GetWithdrawalDetailsForUri]: {
request: GetWithdrawalDetailsForUriRequest;
response: WithdrawUriInfoResponse;
};
[WalletApiOperation.AcceptBankIntegratedWithdrawal]: {
request: AcceptBankIntegratedWithdrawalRequest;
response: AcceptWithdrawalResponse;
};
[WalletApiOperation.AcceptManualWithdrawal]: {
request: AcceptManualWithdrawalRequest;
response: AcceptManualWithdrawalResult;
};
[WalletApiOperation.ListExchanges]: {
request: {};
response: ExchangesListResponse;
};
[WalletApiOperation.AddExchange]: {
request: AddExchangeRequest;
response: {};
};
[WalletApiOperation.SetExchangeTosAccepted]: {
request: AcceptExchangeTosRequest;
response: {};
};
[WalletApiOperation.GetExchangeTos]: {
request: GetExchangeTosRequest;
response: GetExchangeTosResult;
};
[WalletApiOperation.TrackDepositGroup]: {
request: TrackDepositGroupRequest;
response: TrackDepositGroupResponse;
};
[WalletApiOperation.CreateDepositGroup]: {
request: CreateDepositGroupRequest;
response: CreateDepositGroupResponse;
};
[WalletApiOperation.SetWalletDeviceId]: {
request: SetWalletDeviceIdRequest;
response: {};
};
[WalletApiOperation.ExportBackupPlain]: {
request: {};
response: WalletBackupContentV1;
};
[WalletApiOperation.ExportBackupRecovery]: {
request: {};
response: BackupRecovery;
};
[WalletApiOperation.ImportBackupRecovery]: {
request: RecoveryLoadRequest;
response: {};
};
[WalletApiOperation.RunBackupCycle]: {
request: {};
response: {};
};
[WalletApiOperation.AddBackupProvider]: {
request: AddBackupProviderRequest;
response: {};
};
[WalletApiOperation.GetBackupInfo]: {
request: {};
response: BackupInfo;
};
[WalletApiOperation.RunIntegrationTest]: {
request: IntegrationTestArgs;
response: {};
};
[WalletApiOperation.WithdrawTestBalance]: {
request: WithdrawTestBalanceRequest;
response: {};
};
[WalletApiOperation.TestPay]: {
request: TestPayArgs;
response: TestPayResult;
};
[WalletApiOperation.ExportDb]: {
request: {};
response: any;
};
[WalletApiOperation.InitiatePeerPushPayment]: {
request: InitiatePeerPushPaymentRequest;
response: InitiatePeerPushPaymentResponse;
};
[WalletApiOperation.CheckPeerPushPayment]: {
request: CheckPeerPushPaymentRequest;
response: CheckPeerPushPaymentResponse;
};
[WalletApiOperation.AcceptPeerPushPayment]: {
request: AcceptPeerPushPaymentRequest;
response: {};
};
[WalletApiOperation.InitiatePeerPullPayment]: {
request: InitiatePeerPullPaymentRequest;
response: InitiatePeerPullPaymentResponse;
};
[WalletApiOperation.CheckPeerPullPayment]: {
request: CheckPeerPullPaymentRequest;
response: CheckPeerPullPaymentResponse;
};
[WalletApiOperation.AcceptPeerPullPayment]: {
request: AcceptPeerPullPaymentRequest;
response: {};
};
[WalletApiOperation.ClearDb]: {
request: {};
response: {};
};
[WalletApiOperation.Recycle]: {
request: {};
response: {};
};
}; };
export type RequestType< export type RequestType<