Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan committed Aug 3, 2023
1 parent 1c0236e commit 0bb4ae2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
22 changes: 9 additions & 13 deletions ecosystem/typescript/sdk/src/providers/aptos_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,27 +322,23 @@ export class AptosClient {
* @param sender the sender's account address
* @param payload the transaction payload
* @param fee_payer the fee payer account
* @param secondary_signer_accounts an optional array of the secondary signers accounts
* @param secondarySignerAccounts an optional array of the secondary signers accounts
* @returns a fee payer raw transaction that can be signed and submitted to chain
*/
async generateFeePayerTransaction(
sender: MaybeHexString,
payload: Gen.EntryFunctionPayload,
fee_payer: AptosAccount,
secondary_signer_accounts: Array<AptosAccount> = [],
feePayer: MaybeHexString,
secondarySignerAccounts: Array<MaybeHexString> = [],
options?: Partial<Gen.SubmitTransactionRequest>,
): Promise<TxnBuilderTypes.FeePayerRawTransaction> {
const rawTxn = await this.generateTransaction(sender, payload, options);

const signers: Array<AccountAddress> = secondary_signer_accounts.map((account) =>
AccountAddress.fromHex(account.address()),
);
const signers: Array<AccountAddress> = secondarySignerAccounts.map((signer) => {
return AccountAddress.fromHex(signer);
});

const feePayerTxn = new TxnBuilderTypes.FeePayerRawTransaction(
rawTxn,
signers,
AccountAddress.fromHex(fee_payer.address()),
);
const feePayerTxn = new TxnBuilderTypes.FeePayerRawTransaction(rawTxn, signers, AccountAddress.fromHex(feePayer));
return feePayerTxn;
}

Expand All @@ -359,12 +355,12 @@ export class AptosClient {
feePayerTransaction: TxnBuilderTypes.FeePayerRawTransaction,
senderAuthenticator: TxnBuilderTypes.AccountAuthenticatorEd25519,
feePayerAuthenticator: TxnBuilderTypes.AccountAuthenticatorEd25519,
signersAuthenticators: Array<TxnBuilderTypes.AccountAuthenticatorEd25519> = [],
additionalSignersAuthenticators: Array<TxnBuilderTypes.AccountAuthenticatorEd25519> = [],
): Promise<Gen.PendingTransaction> {
const txAuthenticatorFeePayer = new TxnBuilderTypes.TransactionAuthenticatorFeePayer(
senderAuthenticator,
feePayerTransaction.secondary_signer_addresses,
signersAuthenticators,
additionalSignersAuthenticators,
{ address: feePayerTransaction.fee_payer_address, authenticator: feePayerAuthenticator },
);

Expand Down
8 changes: 5 additions & 3 deletions ecosystem/typescript/sdk/src/tests/e2e/aptos_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ test(
};

// Create a fee payer transaction with the sender, transaction payload, and fee payer account
const feePayerTxn = await client.generateFeePayerTransaction(alice.address().hex(), payload, feePayer);
const feePayerTxn = await client.generateFeePayerTransaction(alice.address().hex(), payload, feePayer.address());

// sender and fee payer need to sign the transaction
const senderAuthenticator = await client.signMultiTransaction(alice, feePayerTxn);
Expand Down Expand Up @@ -622,8 +622,10 @@ test(
arguments: [alice.address(), collectionName, tokenName, propertyVersion, 1],
};

// Create a fee payer transaction with the sender, transaction payload, and fee payer account
const feePayerTxn = await client.generateFeePayerTransaction(alice.address().hex(), payload, feePayer, [bob]);
// Create a fee payer transaction with the sender, transaction payload, fee payer account and secondary signers
const feePayerTxn = await client.generateFeePayerTransaction(alice.address().hex(), payload, feePayer.address(), [
bob.address(),
]);

// sender and fee payer need to sign the transaction
const senderAuthenticator = await client.signMultiTransaction(alice, feePayerTxn);
Expand Down

0 comments on commit 0bb4ae2

Please sign in to comment.