Skip to content
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

Support create vesting account msg #126

Merged
merged 19 commits into from
Jun 12, 2023
Merged

Conversation

abefernan
Copy link
Contributor

@abefernan abefernan commented May 31, 2023

Part of #99.
Closes #49.
Closes #54.

@abefernan abefernan self-assigned this May 31, 2023
@vercel
Copy link

vercel bot commented May 31, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cosmos-multisig-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 8, 2023 10:36am

endTime: timestampFromDatetimeLocal(endTime),
delayed,
},
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This msg looks alright here. You can add type-dafety if you store the value: MsgCreateVestingAccount in an extra line.

But how does the object look like when it was written to Fauna and read from Fauna as part of the signing process? I'd assume this breaks the Long.

      const {
        data: { transactionID },
      } = await axios.post("/api/transaction", {
        dataJSON: JSON.stringify(tx),
      });

writed the whole tx including the messages to JSON. There it looks like this:

> const Long = require("long")
undefined
> Long.fromNumber(123)
Long { low: 123, high: 0, unsigned: false }
> let a = { endTime: Long.fromNumber(123) }
undefined
> JSON.stringify(a)
'{"endTime":{"low":123,"high":0,"unsigned":false}}'

Then in const txInfo: DbTransaction = transactionJSON ? JSON.parse(transactionJSON) : null; this becomes something like

JSON.parse('{"endTime":{"low":123,"high":0,"unsigned":false}}')
{ endTime: { low: 123, high: 0, unsigned: false } }.

I'm a bit surprised the proto encoding does not fail entirely.

How does props.tx.msgs look like in this code block?

      const { bodyBytes, signatures } = await signingClient.sign(
        signerAddress,
        props.tx.msgs,
        props.tx.fee,
        props.tx.memo,
        signerData,
      );

Copy link
Contributor Author

@abefernan abefernan Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

props.tx.msgs looks like this:

image

I checked that only the methods go away in serialization, so when reading the tx from db I re-build the Long obj with Long.fromValue to be able to use longObj.multiply(1000)

Comment on lines +100 to +104
fromAddress,
toAddress,
amount: [{ amount: amountInAtomics, denom: state.chain.denom }],
endTime: timestampFromDatetimeLocal(endTime),
delayed,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you pull this out into a const createMsgValue: MsgCreateVestingAccount = { ... to ensure we have type-safety for that part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you have that in TxMsgCreateVestingAccount. Never mind then.

@abefernan abefernan marked this pull request as ready for review June 8, 2023 13:55
@abefernan abefernan requested a review from webmaster128 June 8, 2023 13:55
Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!! Glad it works now :)

@abefernan abefernan merged commit 9253c96 into master Jun 12, 2023
@abefernan abefernan deleted the feat/support-create-vesting branch June 12, 2023 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for create-vesting-account
2 participants