-
Notifications
You must be signed in to change notification settings - Fork 274
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
chore(avaxc) : wrw support for evm ccr #4944
Conversation
773895f
to
c116a8e
Compare
tests are failing |
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 defeats the purpose of inheritance and code reusability.
return userGasPrice; | ||
} | ||
|
||
async recoveryBlockchainExplorerQuery(query: Record<string, any>): Promise<any> { |
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 JSdocs
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.
ok
setGasLimit(userGasLimit?: number): number { | ||
if (!userGasLimit) { | ||
return ethGasConfigs.defaultGasLimit; | ||
} | ||
const gasLimitMax = ethGasConfigs.maximumGasLimit; | ||
const gasLimitMin = ethGasConfigs.minimumGasLimit; | ||
if (userGasLimit < gasLimitMin || userGasLimit > gasLimitMax) { | ||
throw new Error(`Gas limit must be between ${gasLimitMin} and ${gasLimitMax}`); | ||
} | ||
return userGasLimit; | ||
} |
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 is this required?
the implementation of setGasLimit in AbstractEthLikeNewCoins is the same.
setGasPrice(userGasPrice?: number): number { | ||
if (!userGasPrice) { | ||
return ethGasConfigs.defaultGasPrice; | ||
} | ||
|
||
const gasPriceMax = ethGasConfigs.maximumGasPrice; | ||
const gasPriceMin = ethGasConfigs.minimumGasPrice; | ||
if (userGasPrice < gasPriceMin || userGasPrice > gasPriceMax) { | ||
throw new Error(`Gas price must be between ${gasPriceMin} and ${gasPriceMax}`); | ||
} | ||
return userGasPrice; | ||
} |
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 is this required?
the implementation of setGasPrice in AbstractEthLikeNewCoins is the same.
async recoveryBlockchainExplorerQuery(query: Record<string, any>): Promise<any> { | ||
const env = this.bitgo.getEnv(); | ||
const response = await request.post(common.Environments[env].avaxcNetworkBaseUrl + '/ext/bc/C/rpc').send(query); | ||
if (!response.ok) { | ||
throw new Error('could not reach avax.network'); | ||
} | ||
|
||
if (response.body.status === '0' && response.body.message === 'NOTOK') { | ||
throw new Error('avax.network rate limit reached'); | ||
} | ||
return response.body; | ||
} |
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 is this required?
the implementation of recoveryBlockchainExplorerQuery in AbstractEthLikeNewCoins is the same.
async getAddressNonce(address: string): Promise<number> { | ||
// Get nonce for backup key (should be 0) | ||
const result = await this.recoveryBlockchainExplorerQuery({ | ||
jsonrpc: '2.0', | ||
method: 'eth_getTransactionCount', | ||
params: [address, 'latest'], | ||
id: 1, | ||
}); | ||
if (!result || isNaN(result.result)) { | ||
throw new Error('Unable to find next nonce from avax.network, got: ' + JSON.stringify(result)); | ||
} | ||
const nonceHex = result.result; | ||
return new optionalDeps.ethUtil.BN(nonceHex.slice(2), 16).toNumber(); | ||
} |
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.
same
async queryAddressBalance(address: string): Promise<BN> { | ||
const result = await this.recoveryBlockchainExplorerQuery({ | ||
jsonrpc: '2.0', | ||
method: 'eth_getBalance', | ||
params: [address, 'latest'], | ||
id: 1, | ||
}); | ||
// throw if the result does not exist or the result is not a valid number | ||
if (!result || !result.result || isNaN(result.result)) { | ||
throw new Error(`Could not obtain address balance for ${address} from avax.network, got: ${result.result}`); | ||
} | ||
const nativeBalanceHex = result.result; | ||
return new optionalDeps.ethUtil.BN(nativeBalanceHex.slice(2), 16); | ||
} |
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.
same
async querySequenceId(address: string): Promise<number> { | ||
// Get sequence ID using contract call | ||
const sequenceIdMethodSignature = optionalDeps.ethAbi.methodID('getNextSequenceId', []); | ||
const sequenceIdArgs = optionalDeps.ethAbi.rawEncode([], []); | ||
const sequenceIdData = Buffer.concat([sequenceIdMethodSignature, sequenceIdArgs]).toString('hex'); | ||
const sequenceIdDataHex = optionalDeps.ethUtil.addHexPrefix(sequenceIdData); | ||
const result = await this.recoveryBlockchainExplorerQuery({ | ||
jsonrpc: '2.0', | ||
method: 'eth_call', | ||
params: [{ to: address, data: sequenceIdDataHex }, 'latest'], | ||
id: 1, | ||
}); | ||
if (!result || !result.result) { | ||
throw new Error('Could not obtain sequence ID from avax.network, got: ' + result.result); | ||
} | ||
const sequenceIdHex = result.result; | ||
return new optionalDeps.ethUtil.BN(sequenceIdHex.slice(2), 16).toNumber(); | ||
} |
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.
same
async getGasPriceFromExternalAPI(): Promise<BN> { | ||
try { | ||
// COIN -1708 : hardcoded for half signing | ||
const gasPrice = new BN(250000); | ||
console.log(` Got hardcoded gas price: ${gasPrice}`); | ||
return gasPrice; | ||
} catch (e) { | ||
throw new Error('Failed to get gas price'); | ||
} | ||
} |
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.
same
@kamleshmugdiya |
Also, the gas price and limit from the explorer were not required here for the half sign. |
on it |
69b11e7
to
bf631db
Compare
I don't understand this, if the function has the same impl in AbstractEthLikeNewCoins, what is the need to override with the same code in the new class? |
bf631db
to
28a78e4
Compare
This was based on testing, for each of the issues, the method has been copied. Example: A -> B -> C is the method flow and A has to be changed, now i we need to change the method A over here, we will need to override all its parents, the sub method will not be able to be called. |
28a78e4
to
c48ecda
Compare
what testing? |
c48ecda
to
6818a6d
Compare
pipeline failing again |
chore(avaxc) : wrw support for evm ccr
TICKET: COIN-1708