Skip to content

Commit 59730e2

Browse files
committed
refactor(sdk-coin-apt): check feePayerAddress for signablePayload
TICKET: COIN-2838
1 parent 444b849 commit 59730e2

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

modules/sdk-coin-apt/src/lib/transaction/transaction.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ import {
1616
DEFAULT_MAX_GAS_AMOUNT,
1717
Ed25519PublicKey,
1818
Ed25519Signature,
19+
FeePayerRawTransaction,
20+
generateSigningMessage,
1921
generateUserTransactionHash,
2022
Hex,
2123
Network,
24+
RAW_TRANSACTION_SALT,
25+
RAW_TRANSACTION_WITH_DATA_SALT,
2226
RawTransaction,
2327
SignedTransaction,
2428
SimpleTransaction,
@@ -286,6 +290,23 @@ export abstract class Transaction extends BaseTransaction {
286290
return new BigNumber(this.gasUsed).multipliedBy(this.gasUnitPrice).toString();
287291
}
288292

293+
public get signablePayload(): Buffer {
294+
return this.feePayerAddress ? this.getSignablePayloadWithFeePayer() : this.getSignablePayloadWithoutFeePayer();
295+
}
296+
297+
private getSignablePayloadWithFeePayer(): Buffer {
298+
const feePayerRawTxn = new FeePayerRawTransaction(
299+
this._rawTransaction,
300+
[],
301+
AccountAddress.fromString(this._feePayerAddress)
302+
);
303+
return Buffer.from(generateSigningMessage(feePayerRawTxn.bcsToBytes(), RAW_TRANSACTION_WITH_DATA_SALT));
304+
}
305+
306+
private getSignablePayloadWithoutFeePayer(): Buffer {
307+
return Buffer.from(generateSigningMessage(this._rawTransaction.bcsToBytes(), RAW_TRANSACTION_SALT));
308+
}
309+
289310
private generateTxnId() {
290311
if (
291312
!this._senderSignature ||

modules/sdk-coin-apt/src/lib/transaction/transferTransaction.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
11
import { Transaction } from './transaction';
22
import { AptTransactionExplanation, TransferTxData } from '../iface';
33
import { TransactionRecipient, TransactionType } from '@bitgo/sdk-core';
4-
import {
5-
AccountAddress,
6-
FeePayerRawTransaction,
7-
generateSigningMessage,
8-
RAW_TRANSACTION_WITH_DATA_SALT,
9-
} from '@aptos-labs/ts-sdk';
104

115
export class TransferTransaction extends Transaction {
126
constructor(coinConfig) {
137
super(coinConfig);
148
this._type = TransactionType.Send;
159
}
1610

17-
public get signablePayload(): Buffer {
18-
const feePayerRawTxn = new FeePayerRawTransaction(
19-
this._rawTransaction,
20-
[],
21-
AccountAddress.fromString(this._feePayerAddress)
22-
);
23-
return Buffer.from(generateSigningMessage(feePayerRawTxn.bcsToBytes(), RAW_TRANSACTION_WITH_DATA_SALT));
24-
}
25-
2611
/** @inheritDoc */
2712
explainTransaction(): AptTransactionExplanation {
2813
const displayOrder = [

0 commit comments

Comments
 (0)