@codama/renderers-rust 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,23 +132,25 @@ impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for {{ account.
132
132
  pub fn fetch_{{ account.name | snakeCase }}(
133
133
  rpc: &solana_client::rpc_client::RpcClient,
134
134
  address: &Pubkey,
135
- ) -> Result<super::DecodedAccount<{{ account.name | pascalCase }}>, Error> {
136
- let accounts = fetch_all_{{ account.name | snakeCase }}(rpc, vec![address])?;
135
+ ) -> Result<crate::shared::DecodedAccount<{{ account.name | pascalCase }}>, std::io::Error> {
136
+ let accounts = fetch_all_{{ account.name | snakeCase }}(rpc, &[*address])?;
137
137
  Ok(accounts[0].clone())
138
138
  }
139
139
 
140
140
  #[cfg(feature = "fetch")]
141
141
  pub fn fetch_all_{{ account.name | snakeCase }}(
142
142
  rpc: &solana_client::rpc_client::RpcClient,
143
- addresses: Vec<Pubkey>,
144
- ) -> Result<Vec<super::DecodedAccount<{{ account.name | pascalCase }}>>, Error> {
145
- let accounts = rpc.get_multiple_accounts(&addresses)?;
146
- let mut decoded_accounts: Vec<super::DecodedAccount<{{ account.name | pascalCase }}>> = Vec::new();
143
+ addresses: &[Pubkey],
144
+ ) -> Result<Vec<crate::shared::DecodedAccount<{{ account.name | pascalCase }}>>, std::io::Error> {
145
+ let accounts = rpc.get_multiple_accounts(&addresses)
146
+ .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
147
+ let mut decoded_accounts: Vec<crate::shared::DecodedAccount<{{ account.name | pascalCase }}>> = Vec::new();
147
148
  for i in 0..addresses.len() {
148
149
  let address = addresses[i];
149
- let account = accounts[i].as_ref().ok_or(format!("Account not found: {}", address))?;
150
+ let account = accounts[i].as_ref()
151
+ .ok_or(std::io::Error::new(std::io::ErrorKind::Other, format!("Account not found: {}", address)))?;
150
152
  let data = {{ account.name | pascalCase }}::from_bytes(&account.data)?;
151
- decoded_accounts.push(super::DecodedAccount { address, account: account.clone(), data });
153
+ decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
152
154
  }
153
155
  Ok(decoded_accounts)
154
156
  }
@@ -157,25 +159,26 @@ pub fn fetch_all_{{ account.name | snakeCase }}(
157
159
  pub fn fetch_maybe_{{ account.name | snakeCase }}(
158
160
  rpc: &solana_client::rpc_client::RpcClient,
159
161
  address: &Pubkey,
160
- ) -> Result<super::MaybeAccount<{{ account.name | pascalCase }}>, Error> {
161
- let accounts = fetch_all_maybe_{{ account.name | snakeCase }}(rpc, vec![address])?;
162
+ ) -> Result<crate::shared::MaybeAccount<{{ account.name | pascalCase }}>, std::io::Error> {
163
+ let accounts = fetch_all_maybe_{{ account.name | snakeCase }}(rpc, &[*address])?;
162
164
  Ok(accounts[0].clone())
163
165
  }
164
166
 
165
167
  #[cfg(feature = "fetch")]
166
168
  pub fn fetch_all_maybe_{{ account.name | snakeCase }}(
167
169
  rpc: &solana_client::rpc_client::RpcClient,
168
- addresses: Vec<Pubkey>,
169
- ) -> Result<Vec<super::MaybeAccount<{{ account.name | pascalCase }}>>, Error> {
170
- let accounts = rpc.get_multiple_accounts(&addresses)?;
171
- let mut decoded_accounts: Vec<super::MaybeAccount<{{ account.name | pascalCase }}>> = Vec::new();
170
+ addresses: &[Pubkey],
171
+ ) -> Result<Vec<crate::shared::MaybeAccount<{{ account.name | pascalCase }}>>, std::io::Error> {
172
+ let accounts = rpc.get_multiple_accounts(&addresses)
173
+ .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
174
+ let mut decoded_accounts: Vec<crate::shared::MaybeAccount<{{ account.name | pascalCase }}>> = Vec::new();
172
175
  for i in 0..addresses.len() {
173
176
  let address = addresses[i];
174
177
  if let Some(account) = accounts[i].as_ref() {
175
178
  let data = {{ account.name | pascalCase }}::from_bytes(&account.data)?;
176
- decoded_accounts.push(super::MaybeAccount::Exists(super::DecodedAccount { address, account: account.clone(), data }));
179
+ decoded_accounts.push(crate::shared::MaybeAccount::Exists(crate::shared::DecodedAccount { address, account: account.clone(), data }));
177
180
  } else {
178
- decoded_accounts.push(super::MaybeAccount::NotFound(address));
181
+ decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
179
182
  }
180
183
  }
181
184
  Ok(decoded_accounts)
@@ -6,6 +6,7 @@
6
6
  {{ imports }}
7
7
 
8
8
  /// Accounts.
9
+ #[derive(Debug)]
9
10
  pub struct {{ instruction.name | pascalCase }} {
10
11
  {% for account in instruction.accounts %}
11
12
  {% if account.docs.length > 0 %}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codama/renderers-rust",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Renders Rust clients for your programs",
5
5
  "exports": {
6
6
  "types": "./dist/types/index.d.ts",
@@ -30,13 +30,14 @@
30
30
  "dependencies": {
31
31
  "@solana/codecs-strings": "rc",
32
32
  "nunjucks": "^3.2.4",
33
+ "@codama/errors": "1.2.1",
33
34
  "@codama/nodes": "1.2.1",
34
- "@codama/visitors-core": "1.2.1",
35
35
  "@codama/renderers-core": "1.0.3",
36
- "@codama/errors": "1.2.1"
36
+ "@codama/visitors-core": "1.2.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/nunjucks": "^3.2.6"
39
+ "@types/nunjucks": "^3.2.6",
40
+ "@codama/nodes-from-anchor": "1.1.1"
40
41
  },
41
42
  "license": "MIT",
42
43
  "repository": {