184 lines
7.7 KiB
TypeScript

import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, Result } from '@stellar/stellar-sdk/contract';
import type { u64, i128, Option } from '@stellar/stellar-sdk/contract';
export * from '@stellar/stellar-sdk';
export * as contract from '@stellar/stellar-sdk/contract';
export * as rpc from '@stellar/stellar-sdk/rpc';
export declare const networks: {
readonly testnet: {
readonly networkPassphrase: "Test SDF Network ; September 2015";
readonly contractId: "CCDJXQS3DFU2VBFAXMXILXFEQZL5NMHPW3N34F2KAGZQBKBKYLPKTLTF";
};
};
export type EscrowState = {
tag: "Pending";
values: void;
} | {
tag: "Completed";
values: void;
} | {
tag: "Disputed";
values: void;
} | {
tag: "Refunded";
values: void;
};
export type OptionalString = readonly [Option<string>];
export interface EscrowTransaction {
amount: i128;
buyer: string;
created_at: u64;
dispute_reason: OptionalString;
property_id: string;
seller: string;
state: EscrowState;
updated_at: u64;
}
export declare const Errors: {
1: {
message: string;
};
2: {
message: string;
};
3: {
message: string;
};
};
export interface Client {
/**
* Construct and simulate a create_transaction transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
create_transaction: ({ buyer, seller, property_id, amount }: {
buyer: string;
seller: string;
property_id: string;
amount: i128;
}, options?: {
/**
* The fee to pay for the transaction. Default: BASE_FEE
*/
fee?: number;
/**
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
*/
timeoutInSeconds?: number;
/**
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
*/
simulate?: boolean;
}) => Promise<AssembledTransaction<Result<u64>>>;
/**
* Construct and simulate a complete_transaction transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
complete_transaction: ({ seller, transaction_id }: {
seller: string;
transaction_id: u64;
}, options?: {
/**
* The fee to pay for the transaction. Default: BASE_FEE
*/
fee?: number;
/**
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
*/
timeoutInSeconds?: number;
/**
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
*/
simulate?: boolean;
}) => Promise<AssembledTransaction<Result<void>>>;
/**
* Construct and simulate a refund_transaction transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
refund_transaction: ({ buyer, transaction_id }: {
buyer: string;
transaction_id: u64;
}, options?: {
/**
* The fee to pay for the transaction. Default: BASE_FEE
*/
fee?: number;
/**
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
*/
timeoutInSeconds?: number;
/**
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
*/
simulate?: boolean;
}) => Promise<AssembledTransaction<Result<void>>>;
/**
* Construct and simulate a dispute_transaction transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
dispute_transaction: ({ buyer, transaction_id, reason }: {
buyer: string;
transaction_id: u64;
reason: string;
}, options?: {
/**
* The fee to pay for the transaction. Default: BASE_FEE
*/
fee?: number;
/**
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
*/
timeoutInSeconds?: number;
/**
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
*/
simulate?: boolean;
}) => Promise<AssembledTransaction<Result<void>>>;
/**
* Construct and simulate a resolve_dispute transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
resolve_dispute: ({ owner, transaction_id, approve }: {
owner: string;
transaction_id: u64;
approve: boolean;
}, options?: {
/**
* The fee to pay for the transaction. Default: BASE_FEE
*/
fee?: number;
/**
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
*/
timeoutInSeconds?: number;
/**
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
*/
simulate?: boolean;
}) => Promise<AssembledTransaction<Result<void>>>;
/**
* Construct and simulate a get_transaction transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
get_transaction: ({ transaction_id }: {
transaction_id: u64;
}, options?: {
/**
* The fee to pay for the transaction. Default: BASE_FEE
*/
fee?: number;
/**
* The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
*/
timeoutInSeconds?: number;
/**
* Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
*/
simulate?: boolean;
}) => Promise<AssembledTransaction<Result<EscrowTransaction>>>;
}
export declare class Client extends ContractClient {
readonly options: ContractClientOptions;
constructor(options: ContractClientOptions);
readonly fromJSON: {
create_transaction: (json: string) => AssembledTransaction<Result<bigint, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
complete_transaction: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
refund_transaction: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
dispute_transaction: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
resolve_dispute: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
get_transaction: (json: string) => AssembledTransaction<Result<EscrowTransaction, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
};
}