import { HistoryTransaction, PendingTransaction, TransactionIntention } from '@msafe/sui3-model/core'; import { DryRunTransactionBlockResponse, GasCostSummary } from '@mysten/sui.js/client'; import { SerializedSignature } from '@mysten/sui.js/cryptography'; import { CoinTransferIntention, ObjectTransferIntention, PlainPayloadIntention, SuiAddress, TransactionType, TxIntention, } from '@/types'; import { IMSafeInfoResp } from './msafe'; import { IPagedResult } from './page'; export enum TransactionStatus { SUCCESS = 'SUCCESS', FAILED = 'FAILED', REJECTED = 'REJECTED', } export enum TransactionIntentionStatus { NEW = 'NEW', SUCCESS = 'SUCCESS', FAILED = 'FAILED', } export interface IMSafeAddressRequest { msafeAddress: string; } export interface IGetSequenceNumberRequest extends IMSafeAddressRequest {} export interface IGetPendingTransactionRequest extends IMSafeAddressRequest {} export interface IGetHistoryTransactionsRequest extends IMSafeAddressRequest { page?: string; limit?: string; } export interface IGetIntentionsRequest extends IGetHistoryTransactionsRequest {} export interface GetPendingTransactionResponse { pending?: PendingTransactionItem; reject?: PendingTransactionItem; } export interface GetHistoryTransactionsResponse extends IPagedResult {} export interface GetTransactionIntentionsResponse extends IPagedResult {} export interface IProposeIntentionRequest { application: string; txType: TransactionType; txSubType: string; intention: TxIntention; sequenceNumber: number; msafeAddress: string; signature: SerializedSignature; } export interface IProposeIntentionAndBuildAndVoteRequest extends IGasOption { application: string; txType: TransactionType; txSubType: string; intention: TxIntention; sequenceNumber: number; msafeAddress: string; signature: SerializedSignature; forceBuild: boolean; payload: string; digest: string; } export interface ISimulateIntentionRequest { application: string; txType: TransactionType; txSubType: string; intention: TxIntention; } export interface SimulateIntentionResponse { success: boolean; message: string; gasPrice: bigint; gasUsed: GasCostSummary; result: DryRunTransactionBlockResponse; } export interface ISkipIntentionRequest extends IMSafeAddressRequest {} export type IBuildTransactionRequest = IMSafeAddressRequest & IGasOption & { forceBuild: boolean }; export interface IVoteTransactionRequest { msafeAddress: string; digest: string; signature: string; } export type IRejectTransactionRequest = IVoteTransactionRequest & IGasOption & { forceBuild: boolean }; export type PendingTransactionItem = Omit & { application: string; txType: TransactionType; txSubType: string; intention?: TxIntention; votes: PendingVote[]; }; export type HistoryTransactionItem = HistoryTransactionSendItem | HistoryTransactionReceiveItem; export type HistoryTransactionSendItem = Omit & { application: string; txType: TransactionType; txSubType: string; isSendTx: true; approveVotes: HistoryVote[]; rejectVotes: HistoryVote[]; intention: CoinTransferIntentionItem | ObjectTransferIntentionItem | PlainPayloadIntentionItem | OtherIntentionItem; }; export type HistoryTransactionReceiveItem = { application: string; txType: TransactionType; txSubType: string; isSendTx: false; type: 'ReceiveCoin' | 'ReceiveObject' | 'CreateAccount'; digest: string; sender: string; executedAt: Date; data: CoinReceiveType | ObjectReceiveType | CreateAccountType; }; export type CoinTransferIntentionItem = { txType: TransactionType.Assets; txSubType: 'SendCoin'; } & CoinTransferIntention; export type ObjectTransferIntentionItem = { txType: TransactionType.Assets; txSubType: 'SendObject'; } & ObjectTransferIntention; export type PlainPayloadIntentionItem = { txType: TransactionType.Other; txSubType: 'PlainPayload'; } & PlainPayloadIntention; export type OtherIntentionItem = { txType: TransactionType; txSubType: string; } & TxIntention; export type CoinReceiveType = { sender: string; receiver: string; coinType: string; amount: string; }; export type ObjectReceiveType = { sender: string; receiver: string; objectType: string; objectId: string; }; export type CreateAccountType = IMSafeInfoResp; export type TransactionIntentionItem = Omit & { intentionId: string; intention: TxIntention; }; export type PendingVote = HistoryVote & { signature: string; }; export interface HistoryVote { userAddress: SuiAddress; timestamp: Date; } export interface IGasOption { gasPrice: bigint; gasBudget: bigint; }