-
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
feat(cosmos): Add support for contract call transaction #3691
Conversation
a67fd14
to
9f5715a
Compare
private registry; | ||
constructor() { | ||
this.registry = new Registry([...defaultRegistryTypes]); | ||
this.registry.register('/cosmwasm.wasm.v1.MsgExecuteContract', MsgExecuteContract); |
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.
nit: could be a constant
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.
It should already be there in constants, let me use that here
export const accountAddressRegex = /^(cosmos)1(['qpzry9x8gf2tvdw0s3jn54khce6mua7l']{38})$/; | ||
export const validatorAddressRegex = /^(cosmosvaloper)1(['qpzry9x8gf2tvdw0s3jn54khce6mua7l']{38})$/; |
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.
What changed here ?
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.
length, for account address it would always be 38 character long(excluding prefix)
isValidContractAddress(address: string): boolean { | ||
return constants.contractAddressRegex.test(address); | ||
} |
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 and few other methods - seems like we could put it together in a parent class after abstracting the regex pattern; not too concerned though
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.
I was also thinking to do that, but it seemed more clean to me, let me check it again
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.
I think it can be done but I don't want to delay this PR, will create a separate PR for it after completing wallet platform changes
@@ -129,7 +129,7 @@ export class CosmosCoin extends BaseCoin { | |||
throw new Error('Tx outputs does not match with expected txParams recipients'); | |||
} | |||
// WithdrawDelegatorRewards transaction doesn't have amount | |||
if (transaction.type !== TransactionType.StakingWithdraw) { | |||
if (transaction.type !== TransactionType.StakingWithdraw && transaction.type !== TransactionType.ContractCall) { |
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.
Contract interaction support the amount, anyway that will not require in our case but let's keep in mind.
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.
yeah, it is under funds and didn't want to update current amount validation for it
* @returns {boolean} - the validation result | ||
*/ | ||
isValidContractAddress(address: string): boolean { | ||
throw new NotImplementedError('isValidContractAddress not implemented'); |
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's implement using the length comparison and add ToDo to implement with Regex. Else it will be blocker in the platform side.
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.
it is there in extended classes
9f5715a
to
9b7dd54
Compare
|
||
import * as crypto from 'crypto'; | ||
import * as constants from './constants'; | ||
import { | ||
CosmosLikeTransaction, | ||
DelegateOrUndelegeteMessage, | ||
ExecuteContractMessage, |
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 use CosmosTransactionMessage here.
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 can't, schema is different
@@ -473,19 +501,23 @@ export class CosmosUtils implements BaseUtils { | |||
switch (type) { | |||
case TransactionType.Send: { | |||
const value = messageData.value as SendMessage; | |||
this.isObjPropertyNull(value, ['toAddress', 'fromAddress']); |
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 we removing this null check ??
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.
it is being done in this.validateSendMessage
, I wanted to keep validation code common
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 you check this function's path - enrichTransactionDetailsFromRawTransaction()
I think we wont be making this null check here. As this is not calling this.validateSendMessage
.
break; | ||
} | ||
case TransactionType.StakingWithdraw: { | ||
const value = messageData.value as WithdrawDelegatorRewardsMessage; | ||
this.isObjPropertyNull(value, ['validatorAddress', 'delegatorAddress']); |
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 as above.
Ticket: WIN-20