Skip to content
Merged
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
10 changes: 5 additions & 5 deletions crates/sage-database/src/tables/assets/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct NftOfferInfo {
}

impl Database {
pub async fn owned_nft(&self, hash: Bytes32) -> Result<Option<NftRow>> {
pub async fn wallet_nft(&self, hash: Bytes32) -> Result<Option<NftRow>> {
let hash = hash.as_ref();

query!(
Expand All @@ -69,15 +69,15 @@ impl Database {
asset_hash, asset_name, asset_ticker, asset_precision, asset_icon_url,
asset_description, asset_is_sensitive_content, asset_is_visible,
collections.hash AS 'collection_hash?', collections.name AS collection_name,
owned_nfts.minter_hash, owner_hash, metadata, metadata_updater_puzzle_hash,
wallet_nfts.minter_hash, owner_hash, metadata, metadata_updater_puzzle_hash,
royalty_puzzle_hash, royalty_basis_points, data_hash, metadata_hash, license_hash,
edition_number, edition_total,
parent_coin_hash, puzzle_hash, amount, p2_puzzle_hash, created_height, spent_height,
offer_hash AS 'offer_hash?', created_timestamp, spent_timestamp, clawback_expiration_seconds AS 'clawback_timestamp?',
asset_hidden_puzzle_hash
FROM owned_nfts
LEFT JOIN collections ON collections.id = owned_nfts.collection_id
WHERE owned_nfts.asset_hash = ?
FROM wallet_nfts
LEFT JOIN collections ON collections.id = wallet_nfts.collection_id
WHERE wallet_nfts.asset_hash = ?
",
hash
)
Expand Down
10 changes: 5 additions & 5 deletions crates/sage-database/src/tables/assets/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ impl Database {
.await
}

pub async fn owned_option(&self, launcher_id: Bytes32) -> Result<Option<OptionRow>> {
pub async fn wallet_option(&self, launcher_id: Bytes32) -> Result<Option<OptionRow>> {
let launcher_id_ref = launcher_id.as_ref();

query!(
"
SELECT
asset_hash, asset_name, asset_ticker, asset_precision, asset_icon_url,
asset_description, asset_is_visible, asset_is_sensitive_content,
asset_hidden_puzzle_hash, owned_coins.created_height, owned_coins.spent_height,
owned_coins.parent_coin_hash, owned_coins.puzzle_hash, owned_coins.amount, owned_coins.p2_puzzle_hash,
asset_hidden_puzzle_hash, wallet_coins.created_height, wallet_coins.spent_height,
wallet_coins.parent_coin_hash, wallet_coins.puzzle_hash, wallet_coins.amount, wallet_coins.p2_puzzle_hash,
offer_hash AS 'offer_hash?', created_timestamp, spent_timestamp,
clawback_expiration_seconds AS 'clawback_timestamp?',
p2_options.expiration_seconds AS option_expiration_seconds,
Expand All @@ -97,8 +97,8 @@ impl Database {
strike_amount,
underlying_coin.amount AS underlying_amount,
underlying_coin.hash AS underlying_coin_id
FROM owned_coins
INNER JOIN options ON options.asset_id = owned_coins.asset_id
FROM wallet_coins
INNER JOIN options ON options.asset_id = wallet_coins.asset_id
INNER JOIN p2_options ON p2_options.option_asset_id = options.asset_id
INNER JOIN coins AS underlying_coin ON underlying_coin.id = options.underlying_coin_id
INNER JOIN assets AS strike_asset ON strike_asset.id = options.strike_asset_id
Expand Down
4 changes: 2 additions & 2 deletions crates/sage/src/endpoints/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ impl Sage {

let Some(row) = wallet
.db
.owned_option(parse_option_id(req.option_id)?)
.wallet_option(parse_option_id(req.option_id)?)
.await?
else {
return Ok(GetOptionResponse { option: None });
Expand Down Expand Up @@ -671,7 +671,7 @@ impl Sage {

let nft_id = parse_nft_id(req.nft_id)?;

let Some(row) = wallet.db.owned_nft(nft_id).await? else {
let Some(row) = wallet.db.wallet_nft(nft_id).await? else {
return Ok(GetNftResponse { nft: None });
};

Expand Down
7 changes: 7 additions & 0 deletions migrations/0003_unowned_assets.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE VIEW wallet_nfts AS
SELECT
wallet_coins.*, nfts.minter_hash, owner_hash, metadata, metadata_updater_puzzle_hash,
royalty_puzzle_hash, royalty_basis_points, data_hash, metadata_hash, license_hash,
edition_number, edition_total, nfts.collection_id
FROM wallet_coins
INNER JOIN nfts ON nfts.asset_id = wallet_coins.asset_id;
7 changes: 1 addition & 6 deletions src/components/TransactionColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,12 @@ export const columns: ColumnDef<FlattenedTransaction>[] = [

return (
<div className='flex items-center gap-3'>
<div
className='w-6 h-6 flex-shrink-0'
role='img'
aria-label={`${displayName} icon`}
>
<div className='w-6 h-6 flex-shrink-0' role='img' aria-hidden='true'>
<AssetIcon
asset={{
icon_url: row.original.iconUrl ?? null,
kind: row.original.type,
revocation_address: null,
// TODO: Use Asset here and use the actual revocation address
}}
size='sm'
/>
Expand Down
Loading