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

refactor: make patch state key Vec<u8> instead of String #79

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion examples/src/spooning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async fn main() -> anyhow::Result<()> {
worker
.patch_state(
sandbox_contract.id(),
"STATE".to_string(),
"STATE".into(),
status_msg.try_to_vec()?,
)
.await?;
Expand Down
6 changes: 3 additions & 3 deletions workspaces/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub trait StatePatcher {
async fn patch_state(
&self,
contract_id: &AccountId,
key: String,
key: Vec<u8>,
value: Vec<u8>,
) -> anyhow::Result<()>;

Expand All @@ -120,12 +120,12 @@ where
async fn patch_state(
&self,
contract_id: &AccountId,
key: String,
key: Vec<u8>,
value: Vec<u8>,
Comment on lines +123 to 124
Copy link
Contributor

Choose a reason for hiding this comment

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

these should probably be slices to be consistent with the rest of the API, or is there a reason they are not @ChaoticTempest ?

Copy link
Member

Choose a reason for hiding this comment

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

ahh, yeah best to keep them as slices. My bad, prematurely merged this one since it looked simple

Copy link
Contributor Author

@itegulov itegulov Mar 1, 2022

Choose a reason for hiding this comment

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

no worries, I can fix this real quick, I just went by the issue description

you want me to change both key and value to be &[u8], right?

Copy link
Member

Choose a reason for hiding this comment

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

yup both should be slices

Copy link
Contributor

Choose a reason for hiding this comment

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

was unrelated to this PR, just wanted to point out before opening an issue :)

) -> anyhow::Result<()> {
let state = StateRecord::Data {
account_id: contract_id.to_owned(),
data_key: key.into(),
data_key: key,
value,
};
let records = vec![state];
Expand Down
2 changes: 1 addition & 1 deletion workspaces/src/worker/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ where
async fn patch_state(
&self,
contract_id: &AccountId,
key: String,
key: Vec<u8>,
value: Vec<u8>,
) -> anyhow::Result<()> {
self.workspace.patch_state(contract_id, key, value).await
Expand Down
2 changes: 1 addition & 1 deletion workspaces/tests/patch_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async fn test_patch_state() -> anyhow::Result<()> {
});

worker
.patch_state(&contract_id, "STATE".to_string(), status_msg.try_to_vec()?)
.patch_state(&contract_id, "STATE".into(), status_msg.try_to_vec()?)
.await?;

let status: String = worker
Expand Down