Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

[WIP] 2.0 #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## UNRELEASED

### Breaking

- removed unnecessary newtype `AccountDataRef` for `ReadonlyAccountData` impl for `solana_sdk::account::Account`

## [1.1.0]

### Changed
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "solana-readonly-account"
description = "Readonly solana account field getter traits that work for both on-chain AccountInfos and off-chain Accounts"
version = "1.1.0"
version = "2.0.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/igneous-labs/solana-readonly-account.git"
Expand All @@ -17,10 +17,9 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
default = []
solana-sdk = ["dep:solana-sdk", "dep:derive_more"]
solana-sdk = ["dep:solana-sdk"]

[dependencies]
derive_more = { version = ">=0.99", optional = true, default-features = false, features = ["deref", "deref_mut", "as_ref", "as_mut", "from", "into"] }
solana-program ="^1"
solana-sdk = { version = "^1", optional = true }

Expand Down
11 changes: 3 additions & 8 deletions src/sdk.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use derive_more::{AsMut, AsRef, Deref, DerefMut, From, Into};
use solana_program::{pubkey::Pubkey, stake_history::Epoch};
use solana_sdk::account::Account;

Expand All @@ -7,10 +6,6 @@ use crate::{
ReadonlyAccountOwner, ReadonlyAccountRentEpoch,
};

/// Newtype owning reference to account.data in order to work with trait
#[derive(Clone, Copy, Debug, Deref, DerefMut, AsRef, AsMut, From, Into)]
pub struct AccountDataRef<'a>(pub &'a [u8]);

pub type KeyedAccount = Keyed<Account>;

impl ReadonlyAccountLamports for Account {
Expand All @@ -20,11 +15,11 @@ impl ReadonlyAccountLamports for Account {
}

impl ReadonlyAccountData for Account {
type SliceDeref<'s> = &'s [u8] where Self: 's;
type DataDeref<'d> = AccountDataRef<'d> where Self: 'd;
type SliceDeref<'s> = Vec<u8>;
type DataDeref<'d> = &'d Vec<u8>;

fn data(&self) -> Self::DataDeref<'_> {
AccountDataRef(&self.data)
&self.data
}
}

Expand Down