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

The internal tuples in the Storage structure generated by codegen are private #403

Closed
DaviRain-Su opened this issue Jan 21, 2022 · 2 comments · Fixed by #404
Closed

The internal tuples in the Storage structure generated by codegen are private #403

DaviRain-Su opened this issue Jan 21, 2022 · 2 comments · Fixed by #404

Comments

@DaviRain-Su
Copy link

I found a problem, when the defined storage is using StrorageMap the tuples in the generated structure are pub, but when using StorageDoubleMap the tuples in the generated structure are private. Wondering if there is any way to solve this problem. Here is the generated code.

          pub struct Connections(pub ::std::vec::Vec<::core::primitive::u8>);
          impl ::subxt::StorageEntry for Connections {
              const PALLET: &'static str = "Ibc";
              const STORAGE: &'static str = "Connections";
              type Value = ::std::vec::Vec<::core::primitive::u8>;
              fn key(&self) -> ::subxt::StorageEntryKey {
                  ::subxt::StorageEntryKey::Map(vec![::subxt::StorageMapKey::new(
                      &self.0,
                      ::subxt::StorageHasher::Blake2_128Concat,
                  )])
              }
          } 
         

           pub struct Channels(
                ::std::vec::Vec<::core::primitive::u8>,
                ::std::vec::Vec<::core::primitive::u8>,
            );
            impl ::subxt::StorageEntry for Channels {
                const PALLET: &'static str = "Ibc";
                const STORAGE: &'static str = "Channels";
                type Value = ::std::vec::Vec<::core::primitive::u8>;
                fn key(&self) -> ::subxt::StorageEntryKey {
                    ::subxt::StorageEntryKey::Map(vec![
                        ::subxt::StorageMapKey::new(
                            &self.0,
                            ::subxt::StorageHasher::Blake2_128Concat,
                        ),
                        ::subxt::StorageMapKey::new(
                            &self.1,
                            ::subxt::StorageHasher::Blake2_128Concat,
                        ),
                    ])
                }
            }

What you can see is that the tuples inside the generated connections structure are pub, while the tuples inside the channels structure are private.

there is code link: https://github.com/octopus-network/octopusxt/blob/d6b2589a18c57257495bae70b3e008e420b538a2/src/codegen/generate.rs#L4986 for connections

https://github.com/octopus-network/octopusxt/blob/d6b2589a18c57257495bae70b3e008e420b538a2/src/codegen/generate.rs#L5007 for channels

@jsdw
Copy link
Collaborator

jsdw commented Jan 21, 2022

Thanks for raising this! A nice simple fix by the looks of things which the PR attached above makes :)

@DaviRain-Su
Copy link
Author

Thanks for raising this! A nice simple fix by the looks of things which the PR attached above makes :)

thx

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 a pull request may close this issue.

2 participants