-
Notifications
You must be signed in to change notification settings - Fork 40
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
Index Token Extensions and Fungible Tokens #214
Open
Nagaprasadvr
wants to merge
12
commits into
metaplex-foundation:main
Choose a base branch
from
rpcpool:das-38-rebase-stale-te-branch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2524c1b
Token extensions Indexing support
niks3089 0b5a545
fix: register token extensions parser with program transform. add int…
kespinola d1855e0
WIP : token extensions
Nagaprasadvr db11fd6
chore: cleanup
Nagaprasadvr c22c4c2
fix: token extensions integration tests
Nagaprasadvr 08a7ba1
change is_non_fungible condition checks
Nagaprasadvr 76cd8a7
chore: cleanup
Nagaprasadvr 6d708a6
resolve comments
Nagaprasadvr 6aa175d
fix tests and snapshots
Nagaprasadvr bb2f67e
add more scenarios
Nagaprasadvr 8d592c7
resolve comments and fix fixtures
Nagaprasadvr 2c483c5
chore : resolve comments
Nagaprasadvr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
use crate::dao::sea_orm_active_enums::SpecificationVersions; | ||
use crate::dao::FullAsset; | ||
use crate::dao::PageOptions; | ||
use crate::dao::Pagination; | ||
|
@@ -278,14 +277,8 @@ pub fn v1_content_from_json(asset_data: &asset_data::Model) -> Result<Content, D | |
}) | ||
} | ||
|
||
pub fn get_content(asset: &asset::Model, data: &asset_data::Model) -> Result<Content, DbErr> { | ||
match asset.specification_version { | ||
Some(SpecificationVersions::V1) | Some(SpecificationVersions::V0) => { | ||
v1_content_from_json(data) | ||
} | ||
Some(_) => Err(DbErr::Custom("Version Not Implemented".to_string())), | ||
None => Err(DbErr::Custom("Specification version not found".to_string())), | ||
} | ||
pub fn get_content(data: &asset_data::Model) -> Option<Content> { | ||
v1_content_from_json(data).ok() | ||
} | ||
|
||
pub fn to_authority(authority: Vec<asset_authority::Model>) -> Vec<Authority> { | ||
|
@@ -334,10 +327,7 @@ pub fn to_grouping( | |
|
||
pub fn get_interface(asset: &asset::Model) -> Result<Interface, DbErr> { | ||
Ok(Interface::from(( | ||
asset | ||
.specification_version | ||
.as_ref() | ||
.ok_or(DbErr::Custom("Specification version not found".to_string()))?, | ||
asset.specification_version.as_ref(), | ||
asset | ||
.specification_asset_class | ||
.as_ref() | ||
|
@@ -360,14 +350,32 @@ pub fn asset_to_rpc(asset: FullAsset, options: &Options) -> Result<RpcAsset, DbE | |
let rpc_creators = to_creators(creators); | ||
let rpc_groups = to_grouping(groups, options)?; | ||
let interface = get_interface(&asset)?; | ||
let content = get_content(&asset, &data)?; | ||
let mut chain_data_selector_fn = jsonpath_lib::selector(&data.chain_data); | ||
let chain_data_selector = &mut chain_data_selector_fn; | ||
let basis_points = safe_select(chain_data_selector, "$.primary_sale_happened") | ||
.and_then(|v| v.as_bool()) | ||
.unwrap_or(false); | ||
let edition_nonce = | ||
safe_select(chain_data_selector, "$.edition_nonce").and_then(|v| v.as_u64()); | ||
|
||
let (content, edition_nonce, basis_points, mutable, uses) = if let Some(data) = &data { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this cleanup putting it all together |
||
let mut chain_data_selector_fn = jsonpath_lib::selector(&data.chain_data); | ||
let chain_data_selector = &mut chain_data_selector_fn; | ||
( | ||
get_content(data), | ||
safe_select(chain_data_selector, "$.edition_nonce").and_then(|v| v.as_u64()), | ||
safe_select(chain_data_selector, "$.primary_sale_happened") | ||
.and_then(|v| v.as_bool()) | ||
.unwrap_or(false), | ||
data.chain_data_mutability.clone().into(), | ||
data.chain_data.get("uses").map(|u| Uses { | ||
use_method: u | ||
.get("use_method") | ||
.and_then(|s| s.as_str()) | ||
.unwrap_or("Single") | ||
.to_string() | ||
.into(), | ||
total: u.get("total").and_then(|t| t.as_u64()).unwrap_or(0), | ||
remaining: u.get("remaining").and_then(|t| t.as_u64()).unwrap_or(0), | ||
}), | ||
) | ||
} else { | ||
(None, None, false, false, None) | ||
}; | ||
|
||
let mpl_core_info = match interface { | ||
Interface::MplCoreAsset | Interface::MplCoreCollection => Some(MplCoreInfo { | ||
num_minted: asset.mpl_core_collection_num_minted, | ||
|
@@ -380,9 +388,9 @@ pub fn asset_to_rpc(asset: FullAsset, options: &Options) -> Result<RpcAsset, DbE | |
Ok(RpcAsset { | ||
interface: interface.clone(), | ||
id: bs58::encode(asset.id).into_string(), | ||
content: Some(content), | ||
content, | ||
authorities: Some(rpc_authorities), | ||
mutable: data.chain_data_mutability.into(), | ||
mutable, | ||
compression: Some(Compression { | ||
eligible: asset.compressible, | ||
compressed: asset.compressed, | ||
|
@@ -415,7 +423,7 @@ pub fn asset_to_rpc(asset: FullAsset, options: &Options) -> Result<RpcAsset, DbE | |
locked: false, | ||
}), | ||
creators: Some(rpc_creators), | ||
ownership: Ownership { | ||
ownership: Some(Ownership { | ||
frozen: asset.frozen, | ||
delegated: asset.delegate.is_some(), | ||
delegate: asset.delegate.map(|s| bs58::encode(s).into_string()), | ||
|
@@ -424,7 +432,7 @@ pub fn asset_to_rpc(asset: FullAsset, options: &Options) -> Result<RpcAsset, DbE | |
.owner | ||
.map(|o| bs58::encode(o).into_string()) | ||
.unwrap_or("".to_string()), | ||
}, | ||
}), | ||
supply: match interface { | ||
Interface::V1NFT => Some(Supply { | ||
edition_nonce, | ||
|
@@ -433,17 +441,9 @@ pub fn asset_to_rpc(asset: FullAsset, options: &Options) -> Result<RpcAsset, DbE | |
}), | ||
_ => None, | ||
}, | ||
uses: data.chain_data.get("uses").map(|u| Uses { | ||
use_method: u | ||
.get("use_method") | ||
.and_then(|s| s.as_str()) | ||
.unwrap_or("Single") | ||
.to_string() | ||
.into(), | ||
total: u.get("total").and_then(|t| t.as_u64()).unwrap_or(0), | ||
remaining: u.get("remaining").and_then(|t| t.as_u64()).unwrap_or(0), | ||
}), | ||
uses, | ||
burnt: asset.burnt, | ||
mint_extensions: asset.mint_extensions, | ||
plugins: asset.mpl_core_plugins, | ||
unknown_plugins: asset.mpl_core_unknown_plugins, | ||
mpl_core_info, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange that there's a V2 that was never used. Maybe we should delete that but doesn't have to be part of this PR.