Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add default FeePayer address for sponsored transactions in Script Composer #612

Open
wants to merge 1 commit into
base: runtianz/new_script_composer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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