Skip to content

refactor(nervous_system): Add a Request trait to simplify interacting with our canisters - #1091

Merged
anchpop merged 2 commits into
masterfrom
@anchpop/request-trait
Aug 27, 2024
Merged

anchpop merged 2 commits into
masterfrom
@anchpop/request-trait

Conversation

@anchpop

@anchpop anchpop commented Aug 23, 2024 •

Copy link
Copy Markdown
Contributor

Problem

Making requests to canisters in rust code is quite tedious because we must get the request type, encode it, send it, check if the canister returned an error, then decode the response. It is also

Solution

Add a Request trait which can be used to contain the information needed to perform a request: its method string, whether it's an update call, and its response type.

Check out interactions/sns_wasm.rs to see how much it cleans up the code.

Notes

In the future I would like to automatically generate Request implementations from our candid files or from the code that causes them to be generated, but for now they are not that bad to implement manually.

Right now, I only actually implement the trait for SNS-W's api, and only use it in the nervous_system/interaction crate. I want to implement this trait for other canisters' types as well, and use them in canister code.

← Previous PR

@anchpop
anchpop marked this pull request as draft August 23, 2024 02:16
@anchpop
anchpop marked this pull request as ready for review August 23, 2024 02:22
@anchpop
anchpop marked this pull request as draft August 23, 2024 02:23
@anchpop
anchpop force-pushed the @anchpop/request-trait branch 2 times, most recently from d15e630 to 8124ed8 Compare August 23, 2024 03:06
@anchpop
anchpop marked this pull request as ready for review August 23, 2024 05:10
@anchpop anchpop changed the title refactor(nervous_system): Add a Request trait to simplify interacting with our canisters #1090 refactor(nervous_system): Add a Request trait to simplify interacting with our canisters Aug 23, 2024
@anchpop
anchpop force-pushed the @anchpop/create-nervous-system-interactions-crate branch from 414c387 to 840ece9 Compare August 23, 2024 21:52
@anchpop
anchpop force-pushed the @anchpop/request-trait branch from 8124ed8 to 6f9c3aa Compare August 23, 2024 21:53
@anchpop
anchpop force-pushed the @anchpop/create-nervous-system-interactions-crate branch from 840ece9 to ce57b01 Compare August 24, 2024 02:05
@anchpop
anchpop force-pushed the @anchpop/request-trait branch from 6f9c3aa to fbddb63 Compare August 24, 2024 02:05
@anchpop
anchpop force-pushed the @anchpop/create-nervous-system-interactions-crate branch from ce57b01 to 8b3eee8 Compare August 24, 2024 02:15
@anchpop
anchpop force-pushed the @anchpop/request-trait branch 2 times, most recently from c5ccac3 to 7e9d9b9 Compare August 24, 2024 02:29
@anchpop
anchpop force-pushed the @anchpop/create-nervous-system-interactions-crate branch from 8b3eee8 to 7263dd2 Compare August 24, 2024 02:37
@anchpop
anchpop force-pushed the @anchpop/request-trait branch from 7e9d9b9 to 09da59c Compare August 24, 2024 02:37
github-merge-queue Bot pushed a commit that referenced this pull request Aug 24, 2024
…teracting with the NNS and SNSes (#1087)

I thought it would make sense to have a crate where we would put various
helper functions for interaction with SNSes and the NNS. Right now, the
only rust helper functions I'm aware of are in some in
`//rs/nervous_system/tools/sync-with-released-nevous-system-wasms` for
interacting with SNS-W, so I moved just those for now. There are also
some that were developed for use in system tests, but they are not
trivial to extract so I haven't yet.

[Next PR →](#1091)
Base automatically changed from @anchpop/create-nervous-system-interactions-crate to master August 24, 2024 03:37
@anchpop
anchpop force-pushed the @anchpop/request-trait branch from 09da59c to 805c376 Compare August 24, 2024 03:55
@anchpop
anchpop force-pushed the @anchpop/request-trait branch from 805c376 to 7d7e84c Compare August 26, 2024 08:17
@anchpop
anchpop force-pushed the @anchpop/request-trait branch from 7d7e84c to 55ba2ad Compare August 27, 2024 12:19
@anchpop
anchpop added this pull request to the merge queue Aug 27, 2024
Merged via the queue into master with commit 5c02bc6 Aug 27, 2024
@anchpop
anchpop deleted the @anchpop/request-trait branch August 27, 2024 17:59
github-merge-queue Bot pushed a commit that referenced this pull request Aug 28, 2024
I accidentally committed this WIP file in a previous PR (#1091). No
other file references it. Let's delete it :)
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