Skip to content

Commit

Permalink
Merge pull request #12 from Entropy-Foundation/issue-11
Browse files Browse the repository at this point in the history
Added simulate tx using serialized raw transaction
  • Loading branch information
supra-bharoojangid authored Oct 21, 2024
2 parents 127750d + 8590148 commit 9d49dd2
Show file tree
Hide file tree
Showing 30 changed files with 564 additions and 220 deletions.
28 changes: 22 additions & 6 deletions dist/browser/index.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface TransactionDetail {
gasUnitPrice: number;
gasUsed: number | undefined;
transactionCost: number | undefined;
txExpirationTimestamp: number | undefined;
txConfirmationTime: number | undefined;
status: TransactionStatus;
events: any;
Expand Down Expand Up @@ -222,15 +223,18 @@ declare class SupraClient {
private waitForTransactionCompletion;
private sendTx;
private signSupraTransaction;
private getRawTxDataInJson;
private getSendTxPayload;
/**
* Send `entry_function_payload` type tx using serialized raw transaction data
* @param senderAccount Sender KeyPair
* @param serializedRawTransaction Serialized raw transaction data
* @param enableSimulation should enable simulation
* @param waitForTransactionCompletion should wait for transaction completion
* @returns `TransactionResponse`
*/
sendTxUsingSerializedRawTransaction(senderAccount: AptosAccount, serializedRawTransaction: Uint8Array): Promise<TransactionResponse>;
static createRawTxObject(senderAddr: HexString, senderSequenceNumber: bigint, moduleAddr: string, moduleName: string, functionName: string, functionTypeArgs: TxnBuilderTypes.TypeTag[], functionArgs: Uint8Array[], chainId: TxnBuilderTypes.ChainId, maxGas?: bigint, gasUnitPrice?: bigint, txExpiryTime?: bigint | undefined): Promise<TxnBuilderTypes.RawTransaction>;
sendTxUsingSerializedRawTransaction(senderAccount: AptosAccount, serializedRawTransaction: Uint8Array, enableSimulation?: boolean, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
static createRawTxObject(senderAddr: HexString, senderSequenceNumber: bigint, moduleAddr: string, moduleName: string, functionName: string, functionTypeArgs: TxnBuilderTypes.TypeTag[], functionArgs: Uint8Array[], chainId: TxnBuilderTypes.ChainId, maxGas?: bigint | undefined, gasUnitPrice?: bigint | undefined, txExpiryTime?: bigint | undefined): Promise<TxnBuilderTypes.RawTransaction>;
/**
* Create serialized raw transaction object for `entry_function_payload` type tx
* @param senderAddr Sender account address
Expand All @@ -252,31 +256,43 @@ declare class SupraClient {
* @param senderAccount Sender KeyPair
* @param receiverAccountAddr Receiver Supra Account address
* @param amount Amount to transfer
* @param enableSimulation should enable simulation
* @param waitForTransactionCompletion should wait for transaction completion
* @returns `TransactionResponse`
*/
transferSupraCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
transferSupraCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, enableSimulation?: boolean, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
* Transfer coin
* @param senderAccount Sender KeyPair
* @param receiverAccountAddr Receiver Supra Account address
* @param amount Amount to transfer
* @param coinType Type of coin
* @param enableSimulation should enable simulation
* @param waitForTransactionCompletion should wait for transaction completion
* @returns `TransactionResponse`
*/
transferCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, coinType: string, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
transferCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, coinType: string, enableSimulation?: boolean, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
* Publish package or module on supra network
* @param senderAccount Module Publisher KeyPair
* @param packageMetadata Package Metadata
* @param modulesCode module code
* @param enableSimulation should enable simulation
* @param waitForTransactionCompletion should wait for transaction completion
* @returns `TransactionResponse`
*/
publishPackage(senderAccount: AptosAccount, packageMetadata: Uint8Array, modulesCode: Uint8Array[]): Promise<TransactionResponse>;
publishPackage(senderAccount: AptosAccount, packageMetadata: Uint8Array, modulesCode: Uint8Array[], enableSimulation?: boolean, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
* Simulate a transaction using the provided transaction payload
* @param sendTxPayload Transaction payload
*/
simulateTx(sendTxPayload: SendTxPayload): Promise<void>;
simulateTx(sendTxPayload: SendTxPayload): Promise<any>;
/**
* Simulate a transaction using the provided Serialized raw transaction data
* @param senderAccountAddress Tx sender account address
* @param serializedRawTransaction Serialized raw transaction data
*/
simulateTxUsingSerializedRawTransaction(senderAccountAddress: HexString, senderAccountPubKey: HexString, serializedRawTransaction: Uint8Array): Promise<any>;
}

export { type AccountInfo, type AccountResources, type CoinChange, type CoinInfo, type FaucetRequestResponse, type FunctionTypeArgs, type SendTxPayload, SupraClient, type TransactionDetail, type TransactionInsights, type TransactionResponse, TransactionStatus, TxTypeForTransactionInsights };
28 changes: 22 additions & 6 deletions dist/browser/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface TransactionDetail {
gasUnitPrice: number;
gasUsed: number | undefined;
transactionCost: number | undefined;
txExpirationTimestamp: number | undefined;
txConfirmationTime: number | undefined;
status: TransactionStatus;
events: any;
Expand Down Expand Up @@ -222,15 +223,18 @@ declare class SupraClient {
private waitForTransactionCompletion;
private sendTx;
private signSupraTransaction;
private getRawTxDataInJson;
private getSendTxPayload;
/**
* Send `entry_function_payload` type tx using serialized raw transaction data
* @param senderAccount Sender KeyPair
* @param serializedRawTransaction Serialized raw transaction data
* @param enableSimulation should enable simulation
* @param waitForTransactionCompletion should wait for transaction completion
* @returns `TransactionResponse`
*/
sendTxUsingSerializedRawTransaction(senderAccount: AptosAccount, serializedRawTransaction: Uint8Array): Promise<TransactionResponse>;
static createRawTxObject(senderAddr: HexString, senderSequenceNumber: bigint, moduleAddr: string, moduleName: string, functionName: string, functionTypeArgs: TxnBuilderTypes.TypeTag[], functionArgs: Uint8Array[], chainId: TxnBuilderTypes.ChainId, maxGas?: bigint, gasUnitPrice?: bigint, txExpiryTime?: bigint | undefined): Promise<TxnBuilderTypes.RawTransaction>;
sendTxUsingSerializedRawTransaction(senderAccount: AptosAccount, serializedRawTransaction: Uint8Array, enableSimulation?: boolean, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
static createRawTxObject(senderAddr: HexString, senderSequenceNumber: bigint, moduleAddr: string, moduleName: string, functionName: string, functionTypeArgs: TxnBuilderTypes.TypeTag[], functionArgs: Uint8Array[], chainId: TxnBuilderTypes.ChainId, maxGas?: bigint | undefined, gasUnitPrice?: bigint | undefined, txExpiryTime?: bigint | undefined): Promise<TxnBuilderTypes.RawTransaction>;
/**
* Create serialized raw transaction object for `entry_function_payload` type tx
* @param senderAddr Sender account address
Expand All @@ -252,31 +256,43 @@ declare class SupraClient {
* @param senderAccount Sender KeyPair
* @param receiverAccountAddr Receiver Supra Account address
* @param amount Amount to transfer
* @param enableSimulation should enable simulation
* @param waitForTransactionCompletion should wait for transaction completion
* @returns `TransactionResponse`
*/
transferSupraCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
transferSupraCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, enableSimulation?: boolean, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
* Transfer coin
* @param senderAccount Sender KeyPair
* @param receiverAccountAddr Receiver Supra Account address
* @param amount Amount to transfer
* @param coinType Type of coin
* @param enableSimulation should enable simulation
* @param waitForTransactionCompletion should wait for transaction completion
* @returns `TransactionResponse`
*/
transferCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, coinType: string, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
transferCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, coinType: string, enableSimulation?: boolean, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
* Publish package or module on supra network
* @param senderAccount Module Publisher KeyPair
* @param packageMetadata Package Metadata
* @param modulesCode module code
* @param enableSimulation should enable simulation
* @param waitForTransactionCompletion should wait for transaction completion
* @returns `TransactionResponse`
*/
publishPackage(senderAccount: AptosAccount, packageMetadata: Uint8Array, modulesCode: Uint8Array[]): Promise<TransactionResponse>;
publishPackage(senderAccount: AptosAccount, packageMetadata: Uint8Array, modulesCode: Uint8Array[], enableSimulation?: boolean, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
* Simulate a transaction using the provided transaction payload
* @param sendTxPayload Transaction payload
*/
simulateTx(sendTxPayload: SendTxPayload): Promise<void>;
simulateTx(sendTxPayload: SendTxPayload): Promise<any>;
/**
* Simulate a transaction using the provided Serialized raw transaction data
* @param senderAccountAddress Tx sender account address
* @param serializedRawTransaction Serialized raw transaction data
*/
simulateTxUsingSerializedRawTransaction(senderAccountAddress: HexString, senderAccountPubKey: HexString, serializedRawTransaction: Uint8Array): Promise<any>;
}

export { type AccountInfo, type AccountResources, type CoinChange, type CoinInfo, type FaucetRequestResponse, type FunctionTypeArgs, type SendTxPayload, SupraClient, type TransactionDetail, type TransactionInsights, type TransactionResponse, TransactionStatus, TxTypeForTransactionInsights };
Loading

0 comments on commit 9d49dd2

Please sign in to comment.