Skip to content

Commit

Permalink
Update operation types. (#477)
Browse files Browse the repository at this point in the history
* Extend OperationResponseType with manageBuyOffer and pathPaymentStrictSend.

* Update types.

* Add interface for strict send payment operation response.
  • Loading branch information
abuiles authored Jan 27, 2020
1 parent 5967fef commit e03e71f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
47 changes: 39 additions & 8 deletions src/horizon_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,18 @@ export namespace Horizon {
export enum OperationResponseType {
createAccount = "create_account",
payment = "payment",
pathPayment = "path_payment",
createPassiveOffer = "create_passive_offer",
manageOffer = "manage_offer",
pathPayment = "path_payment_strict_receive",
createPassiveOffer = "create_passive_sell_offer",
manageOffer = "manage_sell_offer",
setOptions = "set_options",
changeTrust = "change_trust",
allowTrust = "allow_trust",
accountMerge = "account_merge",
inflation = "inflation",
manageData = "manage_data",
bumpSequence = "bump_sequence",
manageBuyOffer = "manage_buy_offer",
pathPaymentStrictSend = "path_payment_strict_send",
}
export enum OperationResponseTypeI {
createAccount = 0,
Expand All @@ -146,6 +148,8 @@ export namespace Horizon {
inflation = 9,
manageData = 10,
bumpSequence = 11,
manageBuyOffer = 12,
pathPaymentStrictSend = 13,
}
export interface BaseOperationResponse<
T extends OperationResponseType = OperationResponseType,
Expand Down Expand Up @@ -185,17 +189,44 @@ export namespace Horizon {
OperationResponseType.pathPayment,
OperationResponseTypeI.pathPayment
> {
from: string;
to: string;
asset_type: AssetType;
amount: string;
asset_code?: string;
asset_issuer?: string;
amount: string;
source_asset_type: AssetType;
asset_type: AssetType;
from: string;
path: Array<{
asset_code: string;
asset_issuer: string;
asset_type: AssetType;
}>;
source_amount: string;
source_asset_code?: string;
source_asset_issuer?: string;
source_asset_type: AssetType;
source_max: string;
to: string;
}
export interface PathPaymentStrictSendOperationResponse
extends BaseOperationResponse<
OperationResponseType.pathPaymentStrictSend,
OperationResponseTypeI.pathPaymentStrictSend
> {
amount: string;
asset_code?: string;
asset_issuer?: string;
asset_type: AssetType;
destination_min: string;
from: string;
path: Array<{
asset_code: string;
asset_issuer: string;
asset_type: AssetType;
}>;
source_amount: string;
source_asset_code?: string;
source_asset_issuer?: string;
source_asset_type: AssetType;
to: string;
}
export interface ManageOfferOperationResponse
extends BaseOperationResponse<
Expand Down
9 changes: 8 additions & 1 deletion src/server_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ export namespace ServerApi {
OperationResponseTypeI.pathPayment
>,
Horizon.PathPaymentOperationResponse {}
export interface PathPaymentStrictSendOperationRecord
extends BaseOperationRecord<
OperationResponseType.pathPaymentStrictSend,
OperationResponseTypeI.pathPaymentStrictSend
>,
Horizon.PathPaymentStrictSendOperationResponse {}
export interface ManageOfferOperationRecord
extends BaseOperationRecord<
OperationResponseType.manageOffer,
Expand Down Expand Up @@ -263,7 +269,8 @@ export namespace ServerApi {
| AccountMergeOperationRecord
| InflationOperationRecord
| ManageDataOperationRecord
| BumpSequenceOperationRecord;
| BumpSequenceOperationRecord
| PathPaymentStrictSendOperationRecord;

export interface TradeRecord extends Horizon.BaseResponse {
id: string;
Expand Down

0 comments on commit e03e71f

Please sign in to comment.