tronsave-sdk
Version:
TypeScript SDK for Tronsave API to manage TRON blockchain resources
72 lines (71 loc) • 2.5 kB
TypeScript
import { ResourceType, UnitPriceType } from "./common";
/**
* TronWeb signature standards
* - Docs: https://tronweb.network/docu/docs/API%20List/trx/sign
*/
export type SignedTransaction = {
visible: boolean;
txID: string;
raw_data: {
contract: [
{
parameter: {
value: {
amount: number;
owner_address: string;
to_address: string;
};
type_url: string;
};
type: string;
}
];
ref_block_bytes: string;
ref_block_hash: string;
expiration: number;
timestamp: number;
};
raw_data_hex: string;
signature: string[];
};
/**
* @param receiver Receiver resource address
* @param resourceAmount Amount of resource to buy
* @param resourceType Optional: "ENERGY" | "BANDWIDTH". Default is ENERGY - {@link ResourceType}
* @param unitPrice Optional: number | "FAST" | "MEDIUM" | "SLOW". Default is MEDIUM - {@link UnitPriceType}
* @param durationSec Optional: Duration in seconds. Default is 259_200
* @param sponsor Optional: Ref code
* @param signedTx Optional: Signed transaction data - {@link SignedTransaction}
* @param requester Optional: Requester address. Default is empty
*/
export type OrderInfoParams = {
receiver: string;
resourceAmount: number;
resourceType?: ResourceType;
unitPrice?: UnitPriceType;
durationSec?: number;
sponsor?: string;
requester?: string;
signedTx?: SignedTransaction;
};
/**
* Buy Resource Options type
* @param allowPartialFill Optional: Whether to allow partial filling. Default is "true"
* @param maxPriceAccepted Optional: Maximum price to accept. Default is empty
* @param minResourceDelegateRequiredAmount Optional: Minimum resource delegate required amount. Default is 100000 for ENERGY or 1000 for BANDWIDTH
* @param onlyCreateWhenFulfilled Optional: Only create when fully fulfilled. Default is false
* @param preventDuplicateIncompleteOrders Optional: Prevent duplicate incomplete orders. Default is false
*/
export type OrderOptionParams = {
allowPartialFill?: boolean;
maxPriceAccepted?: number;
minResourceDelegateRequiredAmount?: number;
onlyCreateWhenFulfilled?: boolean;
preventDuplicateIncompleteOrders?: boolean;
};
/**
* Buy Resource Response type
*/
export type BuyResourceResponse = {
orderId: string;
};