Skip to content

Commit

Permalink
Fix: Add default FeePayer address for sponsored transactions in Scrip…
Browse files Browse the repository at this point in the history
…t Composer
  • Loading branch information
0xAnto committed Dec 21, 2024
1 parent 02da21a commit 9c81faa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/transactionSubmission/build.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 { AccountAddressInput } from "../../core";
import { AccountAddress, AccountAddressInput } from "../../core";
import { generateTransaction } from "../../internal/transactionSubmission";
import {
InputGenerateTransactionPayloadData,
Expand Down Expand Up @@ -171,7 +171,7 @@ export class Build {
payload: TransactionPayloadScript.load(new Deserializer(bytes)),
...args,
});
return new SimpleTransaction(rawTxn);
return new SimpleTransaction(rawTxn, args.withFeePayer === true ? AccountAddress.ZERO : undefined);
}

/**
Expand Down
42 changes: 42 additions & 0 deletions tests/e2e/transaction/transactionSubmission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,48 @@ describe("transaction submission", () => {
});
expect(response.signature?.type).toBe("fee_payer_signature");
});
test("with batch payload", async () => {
const transaction = await aptos.transaction.build.scriptComposer({
sender: singleSignerED25519SenderAccount.accountAddress,
builder: async (builder) => {
const coin = await builder.addBatchedCalls({
function: "0x1::coin::withdraw",
functionArguments: [CallArgument.new_signer(0), 1],
typeArguments: ["0x1::aptos_coin::AptosCoin"],
});

const fungibleAsset = await builder.addBatchedCalls({
function: "0x1::coin::coin_to_fungible_asset",
functionArguments: [coin[0]],
typeArguments: ["0x1::aptos_coin::AptosCoin"],
});

await builder.addBatchedCalls({
function: "0x1::primary_fungible_store::deposit",
functionArguments: [singleSignerED25519SenderAccount.accountAddress, fungibleAsset[0]],
});
return builder;
},
withFeePayer: true,
});

const senderAuthenticator = aptos.transaction.sign({ signer: singleSignerED25519SenderAccount, transaction });
const feePayerSignerAuthenticator = aptos.transaction.signAsFeePayer({
signer: feePayerAccount,
transaction,
});

const response = await aptos.transaction.submit.simple({
transaction,
senderAuthenticator,
feePayerAuthenticator: feePayerSignerAuthenticator,
});

await aptos.waitForTransaction({
transactionHash: response.hash,
});
expect(response.signature?.type).toBe("fee_payer_signature");
});
test("with entry function payload", async () => {
const transaction = await aptos.transaction.build.simple({
sender: singleSignerED25519SenderAccount.accountAddress,
Expand Down

0 comments on commit 9c81faa

Please sign in to comment.