Skip to content

Commit

Permalink
[api] Cleaned up transaction interface
Browse files Browse the repository at this point in the history
  • Loading branch information
hardsetting committed Feb 16, 2024
1 parent 7451d73 commit f8c3caf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/api/transactionSubmission/simulate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

import { PublicKey } from "../../core";
import type { PublicKeyInput } from "../../core";
import { simulateTransaction } from "../../internal/transactionSubmission";
import { AnyRawTransaction, InputSimulateTransactionOptions } from "../../transactions";
import { UserTransactionResponse } from "../../types";
Expand Down Expand Up @@ -30,9 +30,9 @@ export class Simulate {
*/
@ValidateFeePayerDataOnSimulation
async simple(args: {
signerPublicKey: PublicKey;
signerPublicKey: PublicKeyInput;
transaction: AnyRawTransaction;
feePayerPublicKey?: PublicKey;
feePayerPublicKey?: PublicKeyInput;
options?: InputSimulateTransactionOptions;
}): Promise<Array<UserTransactionResponse>> {
return simulateTransaction({ aptosConfig: this.config, ...args });
Expand All @@ -51,10 +51,10 @@ export class Simulate {
*/
@ValidateFeePayerDataOnSimulation
async multiAgent(args: {
signerPublicKey: PublicKey;
signerPublicKey: PublicKeyInput;
transaction: AnyRawTransaction;
secondarySignersPublicKeys: Array<PublicKey>;
feePayerPublicKey?: PublicKey;
secondarySignersPublicKeys: PublicKeyInput[];
feePayerPublicKey?: PublicKeyInput;
options?: InputSimulateTransactionOptions;
}): Promise<Array<UserTransactionResponse>> {
return simulateTransaction({ aptosConfig: this.config, ...args });
Expand Down
6 changes: 3 additions & 3 deletions src/api/transactionSubmission/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { submitTransaction } from "../../internal/transactionSubmission";
import { AccountAuthenticator, AnyRawTransaction } from "../../transactions";
import { AccountAuthenticator, MultiAgentTransaction, SimpleTransaction } from "../../transactions";
import { PendingTransactionResponse } from "../../types";
import { AptosConfig } from "../aptosConfig";
import { ValidateFeePayerDataOnSubmission } from "./helpers";
Expand All @@ -28,7 +28,7 @@ export class Submit {
*/
@ValidateFeePayerDataOnSubmission
async simple(args: {
transaction: AnyRawTransaction;
transaction: SimpleTransaction;
senderAuthenticator: AccountAuthenticator;
feePayerAuthenticator?: AccountAuthenticator;
}): Promise<PendingTransactionResponse> {
Expand All @@ -47,7 +47,7 @@ export class Submit {
*/
@ValidateFeePayerDataOnSubmission
async multiAgent(args: {
transaction: AnyRawTransaction;
transaction: MultiAgentTransaction;
senderAuthenticator: AccountAuthenticator;
additionalSignersAuthenticators: Array<AccountAuthenticator>;
feePayerAuthenticator?: AccountAuthenticator;
Expand Down
21 changes: 15 additions & 6 deletions src/transactions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,21 @@ export type InputGenerateTransactionData =
| InputGenerateSingleSignerRawTransactionData
| InputGenerateMultiAgentRawTransactionData;

/**
* Interface that holds the user data input when submitting a transaction
*/
export interface InputSubmitTransactionData {
transaction: AnyRawTransaction;
export interface SubmitSimpleTransactionArgs {
transaction: SimpleTransaction;
senderAuthenticator: AccountAuthenticator;
additionalSignersAuthenticators?: undefined;
feePayerAuthenticator?: AccountAuthenticator;
}

export interface SubmitMultiSignerTransactionArgs {
transaction: MultiAgentTransaction;
senderAuthenticator: AccountAuthenticator;
additionalSignersAuthenticators: AccountAuthenticator[];
feePayerAuthenticator?: AccountAuthenticator;
additionalSignersAuthenticators?: Array<AccountAuthenticator>;
}

/**
* Interface that holds the user data input when submitting a transaction
*/
export type InputSubmitTransactionData = SubmitSimpleTransactionArgs | SubmitMultiSignerTransactionArgs;

0 comments on commit f8c3caf

Please sign in to comment.