Skip to content

Commit 857a725

Browse files
committed
chore: left out code from last commit
TICKET: WP-6461
1 parent 18a7800 commit 857a725

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ interface PresignTransactionOptions extends TransactionPrebuild, BasePresignTran
372372
interface EthAddressCoinSpecifics extends AddressCoinSpecific {
373373
forwarderVersion: number;
374374
salt?: string;
375+
feeAddress?: string;
375376
}
376377

377378
export const DEFAULT_SCAN_FACTOR = 20;
@@ -2731,6 +2732,23 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
27312732
return {};
27322733
}
27332734

2735+
getFactoryAndImplContractAddresses(walletVersion: number | undefined): {
2736+
forwarderFactoryAddress: string;
2737+
forwarderImplementationAddress: string;
2738+
} {
2739+
const ethNetwork = this.getNetwork();
2740+
if (walletVersion && (walletVersion === 5 || walletVersion === 4)) {
2741+
return {
2742+
forwarderFactoryAddress: ethNetwork?.walletV4ForwarderFactoryAddress as string,
2743+
forwarderImplementationAddress: ethNetwork?.walletV4ForwarderImplementationAddress as string,
2744+
};
2745+
}
2746+
return {
2747+
forwarderFactoryAddress: ethNetwork?.forwarderFactoryAddress as string,
2748+
forwarderImplementationAddress: ethNetwork?.forwarderImplementationAddress as string,
2749+
};
2750+
}
2751+
27342752
/**
27352753
* Make sure an address is a wallet address and throw an error if it's not.
27362754
* @param {Object} params
@@ -2777,19 +2795,22 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
27772795
);
27782796
}
27792797

2780-
const ethNetwork = this.getNetwork();
2781-
const forwarderFactoryAddress = ethNetwork?.forwarderFactoryAddress as string;
2782-
const forwarderImplementationAddress = ethNetwork?.forwarderImplementationAddress as string;
2783-
2798+
const { forwarderFactoryAddress, forwarderImplementationAddress } = this.getFactoryAndImplContractAddresses(
2799+
params.walletVersion
2800+
);
27842801
const initcode = getProxyInitcode(forwarderImplementationAddress);
27852802
const saltBuffer = ethUtil.setLengthLeft(
27862803
Buffer.from(ethUtil.padToEven(ethUtil.stripHexPrefix(coinSpecific.salt || '')), 'hex'),
27872804
32
27882805
);
27892806

2790-
// Hash the wallet base address with the given salt, so the address directly relies on the base address
2807+
const { createForwarderParams, createForwarderTypes } =
2808+
forwarderVersion === 4
2809+
? getCreateForwarderParamsAndTypes(baseAddress, saltBuffer, coinSpecific.feeAddress)
2810+
: getCreateForwarderParamsAndTypes(baseAddress, saltBuffer);
2811+
27912812
const calculationSalt = optionalDeps.ethUtil.bufferToHex(
2792-
optionalDeps.ethAbi.soliditySHA3(['address', 'bytes32'], [baseAddress, saltBuffer])
2813+
optionalDeps.ethAbi.soliditySHA3(createForwarderTypes, createForwarderParams)
27932814
);
27942815

27952816
expectedAddress = calculateForwarderV1Address(forwarderFactoryAddress, calculationSalt, initcode);

0 commit comments

Comments
 (0)