-
Notifications
You must be signed in to change notification settings - Fork 283
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
refactor(abstract-eth): move methods to abstract-eth #4039
Conversation
signingKeyNonce?: number; | ||
walletContractAddress?: string; | ||
prv: string; | ||
recipients?: Recipient[]; |
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.
Here I had to make all the fields optional because I was getting an error that the params passed to signTransaction are not compatible as we also have signTransaction in AbstractEthLikeCoin class and the interface used there is not having all these fields.
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.
Moving from required to optional isnt a breaking change right?
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.
Correct, will remove this from breaking change
gasLimit?: number; | ||
gasPrice?: number; | ||
custodianTransactionId?: string; | ||
} |
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.
Had to make all fields optional because of the same issue mentioned above with signTransaction method
txInfo: TxInfo; | ||
feeInfo: EthTransactionFee; | ||
source: string; | ||
dataToSign: string; | ||
nextContractSequenceId?: string; | ||
nextContractSequenceId?: number; |
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.
BREAKING CHANGE: Type of nextContractSequenceId is changed to number to avoid typescript error of incompatible function params for signTransaction method in AbstractEthLikeNewCoins and AbstractEthLikeCoin
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.
Have created a ticket WIN-1098 to address the change required in OVC because of this
export interface TransactionPrebuild extends BaseTransactionPrebuild { | ||
hopTransaction?: HopPrebuild; | ||
buildParams: { | ||
recipients: Recipient[]; | ||
}; | ||
recipients: TransactionRecipient[]; | ||
nextContractSequenceId: string; | ||
nextContractSequenceId: number; |
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.
BREAKING CHANGE: Type of nextContractSequenceId is changed to number to avoid typescript error of incompatible function params for signTransaction method in AbstractEthLikeNewCoins and AbstractEthLikeCoin
09bb52f
to
00ac185
Compare
* @param params.prv | ||
* @returns {{txHex: string}} | ||
*/ | ||
async signFinalPolygon(params: SignFinalOptions): Promise<FullySignedTransaction> { |
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.
BREAKING CHANGE: signFinalPolygon method name is updated to signFinalEthLike so that it can be used for other EthLike coins
return 'PolygonMumbai'; | ||
} | ||
return 'PolygonMainnet'; | ||
} |
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.
BREAKING CHANGE: getCustomChainName method is removed and getCustomChainCommon method is added in the AbstractEthLikeNewCoins class to return ethlike common object
const defaultHardfork = !!params.eip1559 ? 'london' : optionalDeps.EthCommon.Hardfork.TangerineWhistle; | ||
let customChainCommon; | ||
// if replay protection options are set, override the default common setting | ||
if (params.replayProtectionOptions) { |
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.
BREAKING CHANGE: replayProtectionOptions is not optional in buildTransaction method for EthLike coins and needs to be passed to derive the Eth common object from the chainId
edb0910
to
9a2ec21
Compare
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.
Will reserve a final review until @BitGo/ethalt-team reviews.
Also for breaking change commits please ensure that its the last grouping with no spaced lines.
Example:
refactor(abstract-eth): move methods to abstract-eth
<description>
BREAKING CHANGE: something changed
TICKET: WIN-1012
@@ -0,0 +1,16 @@ | |||
// Mapping of all supported coins with their chainIds | |||
export const EthLikeCoinNameFromChainId = { |
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.
can we create this map using statics?
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.
added
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.
Nice Work!!!. Some small NITs
throw new Error('Invalid address: ' + recipient.address); | ||
} | ||
|
||
let amount; |
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.
let amount; | |
let amount: BigNumber; |
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.
addressed
* @param address | ||
* @returns {*} |
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.
* @returns {*} | |
* @returns {Promise<number>} |
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.
addressed
* @param txInfo | ||
* @param ethTx | ||
* @param userKey | ||
* @param backupKey | ||
* @param gasPrice | ||
* @param gasLimit | ||
* @param eip1559 | ||
* @param replayProtectionOptions | ||
* @returns {Promise<OfflineVaultTxInfo>} |
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.
Lets add JSDOC consistently with all other functions in the file
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.
added
285d428
to
3b72cb5
Compare
removed blank spaces from BREAKING CHANGE description |
b7eaec3
to
42c2a6c
Compare
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.
Awesome!! 👍
42c2a6c
to
1921f62
Compare
Squashed the commits |
a25ee6a
WIN-1012 BREAKING CHANGE: Type of nextContractSequenceId field in TransactionPrebuild interface is changed from string to number in AbstractEthLikeCoin and AbstractEthLikeNewCoins classes. getCustomChainName method is removed from Polygon class because a common method getCustomChainCommon has been added to AbstractEthLikeNewCoins class for all EthLike coins. replayProtectionOptions is not optional in buildTransaction method in AbstractEthLikeNewCoins and needs to be passed to derive the Eth common object from the chainId. signFinalPolygon method name from Polygon class is updated to signFinalEthLike so that it can be used for other EthLike coins. getBaseFactor method in Eth and Polygon class returns number instead of string just to align with AbstractEthLikeCoin Ticket: WIN-1012
a25ee6a
to
af8bd10
Compare
This PR moves the common EthLike methods to AbstractEthLikeNewCoins class. EthLikeToken also inherits from this new class. ETH and Polygon classes have been modified to inherit from this new class. All the tokens like BscToken, PolygonToken are inheriting EthLikeToken class, but Erc20Token is still inheriting Eth class because ERC20 tokens use some of the methods defined in the Eth class like signing methods
WIN-1012
TICKET: WIN-1012