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

Problem: encryption-key cmd is not supported #1409

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

* (rpc) [#1397](https://github.com/crypto-org-chain/cronos/pull/1397) Avoid panic on invalid elasticity_multiplier.

### Features

- [#1406](https://github.com/crypto-org-chain/cronos/pull/1406) Add set-encryption-key for encryption module.
mmsqe marked this conversation as resolved.
Show resolved Hide resolved

*April 8, 2024*

## v1.2.0-rc1
Expand Down
31 changes: 31 additions & 0 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1840,3 +1840,34 @@ def query_bank_send(self, *denoms):
output="json",
)
).get("send_enabled", [])

def query_e2ee_key(self, address):
return json.loads(
self.raw(
"q",
"e2ee",
"key",
address,
home=self.data_dir,
output="json",
)
)

def set_e2ee_key(self, key, **kwargs):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
kwargs.setdefault("gas", DEFAULT_GAS)
rsp = json.loads(
self.raw(
"tx",
"e2ee",
"set-encryption-key",
key,
"-y",
home=self.data_dir,
stderr=subprocess.DEVNULL,
**kwargs,
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions integration_tests/test_e2ee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import base64


def test_set_key(cronos):
cli = cronos.cosmos_cli()
key = base64.b64encode(b"new_key").decode("utf-8")
cli.set_e2ee_key(key, _from="community")
adr = cli.address("community")
p = cli.query_e2ee_key(adr)
assert p["key"] == key
13 changes: 13 additions & 0 deletions x/e2ee/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,18 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: "e2ee.Msg",
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "RegisterEncryptionKey",
Use: "set-encryption-key [key]",
Short: "Set encryption key is stored associated with the user address.",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "key"},
},
},
},
},
}
}
Loading