Skip to content
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

generalize asset with metadata #76

Merged
merged 3 commits into from
Jan 10, 2025
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
16 changes: 11 additions & 5 deletions sdk/src/services/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export async function getAtomicAsset(id: string): Promise<AssetDetailType | null
ticker: null,
denomination: null,
balances: null,
transferable: null
transferable: null,
creator: null,
metadata: {},
}

const processState = await aoDryRun({
Expand All @@ -104,10 +106,14 @@ export async function getAtomicAsset(id: string): Promise<AssetDetailType | null
} else {
state.transferable = true;
}

for (const [key, value] of Object.entries(processState)) {
if (!(key in state)) {
state[key] = value;
if (processState.Creator || processState.creator) {
state.creator = processState.Creator || processState.creator;
}
if (processState.AssetMetadata) {
for (const [key, value] of Object.entries(processState.AssetMetadata)) {
if (!(key in state)) {
state.metadata[key] = value;
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions services/src/assets/atomic-asset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Handlers.add('Mint', Handlers.utils.hasMatchingTag('Action', 'Mint'), function(m
Tags = {
Status = 'Error',
Message = string.format('Failed to parse data, received: %s. %s', msg.Data,
'Data must be an object - { Quantity }')
'Data must be an object - { Quantity }')
}
})
end
Expand Down Expand Up @@ -214,15 +214,15 @@ Handlers.add('Balance', Handlers.utils.hasMatchingTag('Action', 'Balance'), func
Tags = {
Status = 'Error',
Message = string.format('Failed to parse data, received: %s. %s', msg.Data,
'Data must be an object - { Target }')
'Data must be an object - { Target }')
}
})
end
end)

-- Read balances
Handlers.add('Balances', Handlers.utils.hasMatchingTag('Action', 'Balances'),
function(msg) msg.reply({ Data = json.encode(Balances) }) end)
function(msg) msg.reply({ Data = json.encode(Balances) }) end)

-- Read total supply of token
Handlers.add('Total-Supply', Handlers.utils.hasMatchingTag('Action', 'Total-Supply'), function(msg)
Expand All @@ -245,4 +245,4 @@ Handlers.once('Add-Upload-To-Zone', 'Add-Upload-To-Zone', function(msg)
AssetType = msg.AssetType,
ContentType = msg.ContentType
})
end)
end)
Loading