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

Add other confidential tx methods to seid #1933

Merged
merged 9 commits into from
Nov 19, 2024
Merged

Add other confidential tx methods to seid #1933

merged 9 commits into from
Nov 19, 2024

Conversation

mj850
Copy link
Contributor

@mj850 mj850 commented Nov 14, 2024

Describe your changes and provide context

Adds the remaining 4 commands

Testing performed to validate your change

Manual testing with the seid cli

@@ -358,6 +358,10 @@ func (m msgServer) Transfer(goCtx context.Context, req *types.MsgTransfer) (*typ
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid msg")
}

if instruction.FromAddress == instruction.ToAddress {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I agree, but In bank module though, I think it's a valid case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Disabled this because the way we write this is
senderState = getAccount(sender)
recipientState = getAccount(recipient)

senderState.Balance += Amount
recipientState.Balance -= Amount

keeper.Store(senderState, sender)
keeper.Store(recipientState, recipient).

If sender and recipient are same address, the updated 'recipientState' overrides the updated 'senderState' for the key 'sender' and funds are not deducted. If we want to enable this we need to write a special case.

cmd := &cobra.Command{
Use: "transfer [denom] [to_address] [amount] [flags]",
Short: "Make a confidential transfer to another address",
Long: `Transfer command create a confidential transfer of the specified amount of the specified denomination to the specified address.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could also add some example commands in long description. I think i rushed my piece in without it though


fromAddress := clientCtx.GetFromAddress().String()
denom := args[0]
toAddress := args[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

we may want to validate inputs. I think I skipped those checks in commands I implemented, and we may need to revisit here and other places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the commands with denom and address validation

@dssei
Copy link
Contributor

dssei commented Nov 14, 2024

Code LGTM in general. Let's fix lint errors and add unit tests where possible.

@mj850 mj850 changed the title Mj/ct cli Add other confidential tx methods to seid Nov 14, 2024
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 30.98592% with 49 lines in your changes missing coverage. Please review.

Project coverage is 60.13%. Comparing base (81c0d5f) to head (be00e41).
Report is 39 commits behind head on feature/ct_types.

Files with missing lines Patch % Lines
x/confidentialtransfers/types/msgs.go 0.00% 42 Missing ⚠️
x/confidentialtransfers/types/transfer.go 0.00% 4 Missing ⚠️
x/confidentialtransfers/keeper/msg_server.go 81.25% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           feature/ct_types    #1933      +/-   ##
====================================================
- Coverage             61.57%   60.13%   -1.45%     
====================================================
  Files                   263      281      +18     
  Lines                 23306    25369    +2063     
====================================================
+ Hits                  14351    15255     +904     
- Misses                 7948     8982    +1034     
- Partials               1007     1132     +125     
Files with missing lines Coverage Δ
x/confidentialtransfers/utils/utils.go 100.00% <100.00%> (ø)
x/confidentialtransfers/keeper/msg_server.go 74.41% <81.25%> (ø)
x/confidentialtransfers/types/transfer.go 0.00% <0.00%> (ø)
x/confidentialtransfers/types/msgs.go 40.53% <0.00%> (ø)

... and 6 files with indirect coverage changes

---- 🚨 Try these New Features:

@@ -17,3 +17,11 @@ func SplitTransferBalance(amount uint64) (uint16, uint32, error) {

return bottom16, next32, nil
}

// Combines the bottom 32 bits and the next 48 bits into a single 64-bit number.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: godoc usually stars with method name e.g

// CombineTransferAmount Combines the bottom 32 bits and the next 48 bits into a single 64-bit number.

@@ -17,3 +17,11 @@ func SplitTransferBalance(amount uint64) (uint16, uint32, error) {

return bottom16, next32, nil
}

// Combines the bottom 32 bits and the next 48 bits into a single 64-bit number.
func CombineTransferAmount(bottom16 uint16, hi uint32) (uint64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably deserves it's own unit test

@mj850 mj850 merged commit 08c7505 into feature/ct_types Nov 19, 2024
27 of 28 checks passed
@mj850 mj850 deleted the mj/ctCli branch November 19, 2024 17:29
mj850 added a commit that referenced this pull request Dec 7, 2024
* add other tx commands

* small fixes

* add param validation

* fix apply pending balance method

* check denom for initialize

* add util tests

* bug

* fix initialize tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants