-
Notifications
You must be signed in to change notification settings - Fork 296
feat(abstract-eth): add recover consolidation for eth #6550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
960e8af
to
3b58e6a
Compare
dfef449
to
d50d402
Compare
@claude review this PR as Grug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds consolidation recovery functionality for Ethereum-based coins (ETH and HTETH) to support unsigned consolidation operations in WRW. The implementation includes methods to generate forwarder addresses, derive addresses from public keys, and recover funds from multiple consolidation addresses.
Key changes:
- Added network configuration properties for wallet V4 forwarder addresses
- Implemented consolidation recovery methods in the abstract Ethereum class
- Added comprehensive address generation and scanning functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
modules/statics/src/networks.ts | Added wallet V4 forwarder factory and implementation addresses to Ethereum and Holesky network configurations |
modules/statics/test/unit/resources/amsTokenConfig.ts | Updated test configuration with new forwarder addresses |
modules/abstract-eth/src/abstractEthLikeNewCoins.ts | Implemented core consolidation recovery functionality including address generation, derivation, and transaction building |
Comments suppressed due to low confidence (1)
modules/abstract-eth/src/abstractEthLikeNewCoins.ts:1318
- Using 'any' type reduces type safety. Consider defining a proper interface or union type for consolidation transactions.
const consolidationTransactions: any[] = [];
); | ||
possibleConsolidationAddresses.push(forwarderAddress); | ||
} catch (e) { | ||
console.log(`Failed to generate forwarder address: ${e.message}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using console.log for error logging is not appropriate for production code. Consider using a proper logging framework or throwing/handling the error appropriately.
console.log(`Failed to generate forwarder address: ${e.message}`); | |
debug(`Failed to generate forwarder address: ${e instanceof Error ? e.message : e}`); |
Copilot uses AI. Check for mistakes.
const derivedAddress = this.deriveAddressFromPublicKey(params.userKey, index); | ||
possibleConsolidationAddresses.push(derivedAddress); | ||
} catch (e) { | ||
console.log(`Failed to generate derived address: ${e}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using console.log for error logging is not appropriate for production code. Consider using a proper logging framework or throwing/handling the error appropriately.
console.log(`Failed to generate derived address: ${e}`); | |
debug(`Failed to generate derived address: ${e}`); |
Copilot uses AI. Check for mistakes.
} | ||
} | ||
|
||
// lastScanIndex = i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commented out code should be removed or properly implemented if needed.
// lastScanIndex = i; |
Copilot uses AI. Check for mistakes.
chain: params.replayProtectionOptions?.chain || 0, | ||
hardfork: params.replayProtectionOptions?.hardfork || 'london', | ||
}, | ||
bitgoKey: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting bitgoKey to an empty string may be problematic. Consider using a proper default value or making this parameter optional if it's not required.
bitgoKey: '', | |
...(params.bitgoKey !== undefined ? { bitgoKey: params.bitgoKey } : {}), |
Copilot uses AI. Check for mistakes.
|
||
if (params.userKey) { | ||
try { | ||
const derivedAddress = this.deriveAddressFromPublicKey(params.userKey, index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
derivedAddress is returned for every getConsolidationAddress
call, why is that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have any means to differentiate between v6 and v5 wallet thus we try to derive address every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case this would execute for v6 wallet as well right ?
const forwarderAddress = this.generateForwarderAddress( params.walletContractAddress, params.bitgoFeeAddress, forwarderFactoryAddress, forwarderImplementationAddress, index ); possibleConsolidationAddresses.push(forwarderAddress);
const salt = addHexPrefix(index.toString(16)); | ||
const saltBuffer = setLengthLeft(toBuffer(salt), 32); | ||
|
||
const { createForwarderParams, createForwarderTypes } = getCreateForwarderParamsAndTypes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is specific for v4 wallet, can you not make it generic ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are not sure which version is being used, we have kept this in a try statement in order to handle the failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also please add test cases
ce56893
to
b0e63e4
Compare
|
||
if (params.userKey) { | ||
try { | ||
const derivedAddress = this.deriveAddressFromPublicKey(params.userKey, index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case this would execute for v6 wallet as well right ?
const forwarderAddress = this.generateForwarderAddress( params.walletContractAddress, params.bitgoFeeAddress, forwarderFactoryAddress, forwarderImplementationAddress, index ); possibleConsolidationAddresses.push(forwarderAddress);
basecoin = bitgo.coin('hteth') as Hteth; | ||
}); | ||
|
||
it('should generate an unsigned consolidation', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a test case for v5 and v6 separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to write separate test cases since all the values are provided and based on the which wallet version we are assuming, we are using the relevant values and generating address for consolidation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case this would execute for v6 wallet as well right ?
const forwarderAddress = this.generateForwarderAddress( params.walletContractAddress, params.bitgoFeeAddress, forwarderFactoryAddress, forwarderImplementationAddress, index ); possibleConsolidationAddresses.push(forwarderAddress);
yes, this will run in both the cases since we have no means of verifying which wallet version is this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you sure whether this would throw an error for V6 wallet?
better to add a testcase to verify
383997d
to
aabf004
Compare
aabf004
to
596e192
Compare
Adding the recover consolidation functionality for
eth
andhteth
which would be used for unsigned consolidation in WRWticket: WIN-5700