generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helpers for compress/decompress, fix spl-noop wrap and compressed…
… transfer
- Loading branch information
Showing
11 changed files
with
248 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use borsh::{BorshDeserialize, BorshSerialize}; | ||
use solana_program::pubkey::Pubkey; | ||
|
||
use crate::state::{Asset, HashablePluginSchema, UpdateAuthority, Wrappable}; | ||
|
||
/// A simple struct to store the compression proof of an asset. | ||
#[repr(C)] | ||
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] | ||
pub struct CompressionProof { | ||
/// The owner of the asset. | ||
pub owner: Pubkey, //32 | ||
/// The update authority of the asset. | ||
pub update_authority: UpdateAuthority, //33 | ||
/// The name of the asset. | ||
pub name: String, //4 | ||
/// The URI of the asset that points to the off-chain data. | ||
pub uri: String, //4 | ||
/// The plugins for the asset. | ||
pub plugins: Vec<HashablePluginSchema>, //4 | ||
} | ||
|
||
impl CompressionProof { | ||
pub fn new(asset: Asset, plugins: Vec<HashablePluginSchema>) -> Self { | ||
Self { | ||
owner: asset.owner, | ||
update_authority: asset.update_authority, | ||
name: asset.name, | ||
uri: asset.uri, | ||
plugins, | ||
} | ||
} | ||
} | ||
|
||
impl Wrappable for CompressionProof {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use borsh::{BorshDeserialize, BorshSerialize}; | ||
use std::cmp::Ordering; | ||
|
||
use crate::{ | ||
plugins::Plugin, | ||
state::{Authority, Compressible}, | ||
}; | ||
|
||
/// A type that stores a plugin's authorities and deserialized data into a | ||
/// schema that will be later hashed into a hashed asset. Also used in | ||
/// `CompressionProof`. | ||
#[derive(Clone, BorshSerialize, BorshDeserialize, Debug, PartialEq, Eq)] | ||
pub struct HashablePluginSchema { | ||
/// This is the order the plugins are stored in the account, allowing us | ||
/// to keep track of their order in the hashing. | ||
pub index: usize, | ||
/// The authorities who have permission to utilize a plugin. | ||
pub authority: Authority, | ||
/// The deserialized plugin. | ||
pub plugin: Plugin, | ||
} | ||
|
||
impl HashablePluginSchema { | ||
/// Associated function for sorting `RegistryRecords` by offset. | ||
pub fn compare_indeces(a: &HashablePluginSchema, b: &HashablePluginSchema) -> Ordering { | ||
a.index.cmp(&b.index) | ||
} | ||
} | ||
|
||
impl Compressible for HashablePluginSchema {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.