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

update to handle empty asset info responses #16

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
update to handle empty asset info responses
- for existing asset, just return existing asset id
- for new asset, throw error and stop processing
  • Loading branch information
jdogresorg committed Dec 11, 2024
commit 7d5e8c89f4e68f195b15e220cd0572da283bb8df
6 changes: 6 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ function createAsset( $asset=null, $block_index=null ){
// Update asset information
$row = $results->fetch_assoc();
$id = $row['id'];
// If we don't have any asset data, skip update and just return asset id
if(count($data)==0)
return $id;
$sql = "UPDATE assets SET
asset_id = '{$data->asset_id}',
asset_longname = '{$data->asset_longname}',
Expand All @@ -232,6 +235,9 @@ function createAsset( $asset=null, $block_index=null ){
byeLog('Error while trying to update asset record for ' . $asset . ' : ' . $sql);
}
} else {
// If we don't have any asset data, skip update and just return asset id
if(count($data)==0)
byeLog('Error while trying to create asset record for ' . $asset . ': no asset data found!');
// Create asset information
$sql = "INSERT INTO assets (asset_id, asset, asset_longname, block_index, type, divisible, description, issuer_id, locked, owner_id, supply) values (
'{$data->asset_id}',
Expand Down