Skip to content

Commit 04132eb

Browse files
fix(sdk-coin-eth): use txInfo to fetch recipients
TICKET: CHALO-726
1 parent 765fa34 commit 04132eb

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ export interface TransactionPrebuild extends BaseTransactionPrebuild {
143143
isBatch: boolean;
144144
coin: string;
145145
token?: string;
146+
txInfo?: {
147+
recipients?: TransactionRecipient[];
148+
nextContractSequenceId?: number;
149+
eip1559?: EIP1559;
150+
isBatch?: boolean;
151+
};
146152
}
147153

148154
export interface SignFinalOptions {
@@ -165,6 +171,12 @@ export interface SignFinalOptions {
165171
isBatch?: boolean;
166172
txHex?: string;
167173
expireTime?: number;
174+
txInfo?: {
175+
recipients?: TransactionRecipient[];
176+
nextContractSequenceId?: number;
177+
eip1559?: EIP1559;
178+
isBatch?: boolean;
179+
};
168180
};
169181
signingKeyNonce?: number;
170182
walletContractAddress?: string;

modules/sdk-coin-eth/src/erc7984Token.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ export class Erc7984Token extends Eth {
234234
throw new Error('verifyConfidentialConsolidation: encryptedHandle is missing or empty in transaction calldata');
235235
}
236236

237-
const expectedForwarder = txPrebuild.recipients?.[0]?.address ?? txParams?.recipients?.[0]?.address;
237+
const expectedForwarder =
238+
txPrebuild.recipients?.[0]?.address ??
239+
txPrebuild.txInfo?.recipients?.[0]?.address ??
240+
txParams?.recipients?.[0]?.address;
238241
if (forwarderAddress && expectedForwarder) {
239242
if (forwarderAddress.toLowerCase() !== expectedForwarder.toLowerCase()) {
240243
throw new Error(

modules/sdk-coin-eth/src/eth.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ export class Eth extends AbstractEthLikeNewCoins {
475475
throw new Error('missing prv parameter to sign transaction');
476476
}
477477

478-
params.recipients = txPrebuild.recipients || params.recipients;
478+
params.recipients =
479+
txPrebuild.recipients || (txPrebuild.txInfo?.recipients as Recipient[] | undefined) || params.recipients;
479480

480481
// if no recipients in either params or txPrebuild, then throw an error
481482
if (!params.recipients || !Array.isArray(params.recipients)) {
@@ -494,7 +495,7 @@ export class Eth extends AbstractEthLikeNewCoins {
494495

495496
const secondsSinceEpoch = Math.floor(new Date().getTime() / 1000);
496497
const expireTime = params.expireTime || secondsSinceEpoch + EXPIRETIME_DEFAULT;
497-
const sequenceId = txPrebuild.nextContractSequenceId;
498+
const sequenceId = txPrebuild.nextContractSequenceId ?? txPrebuild.txInfo?.nextContractSequenceId;
498499

499500
if (_.isUndefined(sequenceId)) {
500501
throw new Error('transaction prebuild missing required property nextContractSequenceId');
@@ -504,8 +505,8 @@ export class Eth extends AbstractEthLikeNewCoins {
504505
const signature = Util.ethSignMsgHash(operationHash, Util.xprvToEthPrivateKey(userPrv));
505506

506507
const txParams = {
507-
eip1559: params.txPrebuild.eip1559,
508-
isBatch: params.txPrebuild.isBatch,
508+
eip1559: params.txPrebuild.eip1559 ?? params.txPrebuild.txInfo?.eip1559,
509+
isBatch: params.txPrebuild.isBatch ?? params.txPrebuild.txInfo?.isBatch,
509510
recipients: params.recipients,
510511
expireTime: expireTime,
511512
contractSequenceId: sequenceId,

0 commit comments

Comments
 (0)