Skip to content

Commit

Permalink
refactor: Make AccountData return an empty vec by default
Browse files Browse the repository at this point in the history
  • Loading branch information
conr2d committed Jan 2, 2025
1 parent 673aa41 commit 5dfc94f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 7 additions & 2 deletions frame/solana/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,13 @@ pub mod pallet {

#[pallet::storage]
#[pallet::getter(fn account_data)]
pub type AccountData<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, BoundedVec<u8, T::MaxPermittedDataLength>>;
pub type AccountData<T: Config> = StorageMap<
_,
Twox64Concat,
T::AccountId,
BoundedVec<u8, T::MaxPermittedDataLength>,
ValueQuery,
>;

#[pallet::genesis_config]
#[derive_where(Default)]
Expand Down
7 changes: 2 additions & 5 deletions frame/solana/src/runtime/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,10 @@ impl<T: Config> TransactionProcessingCallback for Bank<T> {
let account = <AccountMeta<T>>::get(&pubkey)?;
let lamports =
<Lamports<T>>::new(T::Currency::reducible_balance(&pubkey, Preserve, Polite));
let data = <AccountData<T>>::get(&pubkey);
let data = <AccountData<T>>::get(&pubkey).into();
Some(AccountSharedData::from(Account {
lamports: lamports.get(),
data: match data {
Some(data) => data.into(),
None => vec![],
},
data,
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
Expand Down

0 comments on commit 5dfc94f

Please sign in to comment.