fix(operations): review props and options

This commit is contained in:
Kalvis Kalniņš
2019-01-03 11:43:26 +02:00
parent 3d0c5d3f77
commit b058eee449
+61 -78
View File
@@ -1,4 +1,4 @@
// Type definitions for stellar-sdk 0.10
// Type definitions for stellar-sdk 0.11
// Project: https://github.com/stellar/js-stellar-sdk
// Definitions by: Carl Foster <https://github.com/carl-foster>
// Triston Jones <https://github.com/tristonj>
@@ -154,98 +154,89 @@ export namespace StellarBase {
}
namespace Operation {
interface Operation {
type: OperationType;
source: string | null;
}
interface AccountMerge extends Operation {
type: OperationType.accountMerge;
destination: string;
}
interface AccountMergeOptions {
destination: string;
interface Operation<T extends OperationType = OperationType> {
type: T;
source?: string;
}
interface OperationOptions {
source?: string;
}
interface AccountMerge extends Operation<OperationType.accountMerge> {
destination: string;
}
interface AccountMergeOptions extends OperationOptions {
destination: string;
}
function accountMerge(options: AccountMergeOptions): xdr.Operation<AccountMerge>;
interface AllowTrust extends Operation {
type: OperationType.allowTrust;
interface AllowTrust extends Operation<OperationType.allowTrust> {
trustor: string;
assetCode: string;
authorize: boolean;
authorize: boolean | undefined;
}
interface AllowTrustOptions {
interface AllowTrustOptions extends OperationOptions {
trustor: string;
assetCode: string;
authorize: boolean;
source?: string;
authorize?: boolean;
}
function allowTrust(options: AllowTrustOptions): xdr.Operation<AllowTrust>;
interface ChangeTrust extends Operation {
type: OperationType.changeTrust;
interface ChangeTrust extends Operation<OperationType.changeTrust> {
line: Asset;
limit: string | number;
limit: string;
}
interface ChangeTrustOptions {
interface ChangeTrustOptions extends OperationOptions {
asset: Asset;
limit?: string;
source?: string;
}
function changeTrust(options: ChangeTrustOptions): xdr.Operation<ChangeTrust>;
interface CreateAccount extends Operation {
type: OperationType.createAccount;
source: string;
interface CreateAccount extends Operation<OperationType.createAccount> {
destination: string;
startingBalance: string | number;
startingBalance: string;
}
interface CreateAccountOptions {
interface CreateAccountOptions extends OperationOptions {
destination: string;
startingBalance: string;
source?: string;
}
function createAccount(options: CreateAccountOptions): xdr.Operation<CreateAccount>;
interface CreatePassiveOffer extends Operation {
type: OperationType.createPassiveOffer;
selling: Asset;
buying: Asset;
amount: string | number;
price: string | number;
}
interface CreatePassiveOfferOptions {
interface CreatePassiveOffer extends Operation<OperationType.createPassiveOffer> {
selling: Asset;
buying: Asset;
amount: string;
price: number | string | object;
source?: string;
price: string;
}
interface CreatePassiveOfferOptions extends OperationOptions {
selling: Asset;
buying: Asset;
amount: string;
price: number | string | object /* bignumber.js */;
}
function createPassiveOffer(options: CreatePassiveOfferOptions): xdr.Operation<CreatePassiveOffer>;
interface Inflation extends Operation {
type: OperationType.inflation;
interface Inflation extends Operation<OperationType.inflation> {
}
function inflation(options: { source?: string }): xdr.Operation<Inflation>;
interface InflationOptions extends OperationOptions { // tslint:disable-line
}
function inflation(options: InflationOptions): xdr.Operation<Inflation>;
interface ManageData extends Operation {
type: OperationType.manageData;
interface ManageData extends Operation<OperationType.manageData> {
name: string;
value: Buffer;
}
interface ManageDataOptions {
interface ManageDataOptions extends OperationOptions {
name: string;
value: string | Buffer;
source?: string;
}
function manageData(options: ManageDataOptions): xdr.Operation<ManageData>;
interface ManageOffer extends Operation {
type: OperationType.manageOffer;
interface ManageOffer extends Operation<OperationType.manageOffer> {
selling: Asset;
buying: Asset;
amount: string | number;
price: string | number;
amount: string;
price: string;
offerId: string;
}
interface ManageOfferOptions extends CreatePassiveOfferOptions {
@@ -253,37 +244,33 @@ export namespace StellarBase {
}
function manageOffer(options: ManageOfferOptions): xdr.Operation<ManageOffer>;
interface PathPayment extends Operation {
type: OperationType.pathPayment;
sendAsset: Asset;
sendMax: string | number;
destination: string;
destAsset: Asset;
destAmount: string | number;
path: Asset[];
}
interface PathPaymentOptions {
interface PathPayment extends Operation<OperationType.pathPayment> {
sendAsset: Asset;
sendMax: string;
destination: string;
destAsset: Asset;
destAmount: string;
path: Asset[];
source?: string;
}
interface PathPaymentOptions extends OperationOptions {
sendAsset: Asset;
sendMax: string;
destination: string;
destAsset: Asset;
destAmount: string;
path?: Asset[];
}
function pathPayment(options: PathPaymentOptions): xdr.Operation<PathPayment>;
interface Payment extends Operation {
type: OperationType.payment;
destination: string;
asset: Asset;
amount: string | number;
}
interface PaymentOptions {
destination: string;
asset: Asset;
interface Payment extends Operation<OperationType.payment> {
amount: string;
source?: string;
asset: Asset;
destination: string;
}
interface PaymentOptions extends OperationOptions {
amount: string;
asset: Asset;
destination: string;
}
function payment(options: PaymentOptions): xdr.Operation<Payment>;
@@ -303,8 +290,7 @@ export namespace StellarBase {
preAuthTx?: Buffer | string;
weight?: number | string;
}
interface SetOptions extends Operation {
type: OperationType.setOptions;
interface SetOptions extends Operation<OperationType.setOptions> {
inflationDest?: string;
clearFlags?: AuthFlags;
setFlags?: AuthFlags;
@@ -315,7 +301,7 @@ export namespace StellarBase {
homeDomain?: string;
signer?: Signer;
}
interface SetOptionsOptions {
interface SetOptionsOptions extends OperationOptions {
inflationDest?: string;
clearFlags?: AuthFlags;
setFlags?: AuthFlags;
@@ -325,17 +311,14 @@ export namespace StellarBase {
highThreshold?: number | string;
signer?: Signer;
homeDomain?: string;
source?: string;
}
function setOptions(options: SetOptionsOptions): xdr.Operation<SetOptions>;
interface BumpSequence extends Operation {
type: OperationType.bumpSequence;
interface BumpSequence extends Operation<OperationType.bumpSequence> {
bumpTo: string;
}
interface BumpSequenceOptions {
interface BumpSequenceOptions extends OperationOptions {
bumpTo: string;
source?: string;
}
function bumpSequence(options: BumpSequenceOptions): xdr.Operation<BumpSequence>;