Skip to content
Merged
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
12 changes: 12 additions & 0 deletions modules/abstract-eth/src/abstractEthLikeNewCoins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ export interface TransactionPrebuild extends BaseTransactionPrebuild {
isBatch: boolean;
coin: string;
token?: string;
txInfo?: {
recipients?: TransactionRecipient[];
nextContractSequenceId?: number;
eip1559?: EIP1559;
isBatch?: boolean;
};
}

export interface SignFinalOptions {
Expand All @@ -165,6 +171,12 @@ export interface SignFinalOptions {
isBatch?: boolean;
txHex?: string;
expireTime?: number;
txInfo?: {
recipients?: TransactionRecipient[];
nextContractSequenceId?: number;
eip1559?: EIP1559;
isBatch?: boolean;
};
};
signingKeyNonce?: number;
walletContractAddress?: string;
Expand Down
5 changes: 4 additions & 1 deletion modules/sdk-coin-eth/src/erc7984Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ export class Erc7984Token extends Eth {
throw new Error('verifyConfidentialConsolidation: encryptedHandle is missing or empty in transaction calldata');
}

const expectedForwarder = txPrebuild.recipients?.[0]?.address ?? txParams?.recipients?.[0]?.address;
const expectedForwarder =
txPrebuild.recipients?.[0]?.address ??
txPrebuild.txInfo?.recipients?.[0]?.address ??
txParams?.recipients?.[0]?.address;
if (forwarderAddress && expectedForwarder) {
if (forwarderAddress.toLowerCase() !== expectedForwarder.toLowerCase()) {
throw new Error(
Expand Down
9 changes: 5 additions & 4 deletions modules/sdk-coin-eth/src/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ export class Eth extends AbstractEthLikeNewCoins {
throw new Error('missing prv parameter to sign transaction');
}

params.recipients = txPrebuild.recipients || params.recipients;
params.recipients =
txPrebuild.recipients || (txPrebuild.txInfo?.recipients as Recipient[] | undefined) || params.recipients;

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

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

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

const txParams = {
eip1559: params.txPrebuild.eip1559,
isBatch: params.txPrebuild.isBatch,
eip1559: params.txPrebuild.eip1559 ?? params.txPrebuild.txInfo?.eip1559,
isBatch: params.txPrebuild.isBatch ?? params.txPrebuild.txInfo?.isBatch,
recipients: params.recipients,
expireTime: expireTime,
contractSequenceId: sequenceId,
Expand Down
Loading