Skip to content

Commit

Permalink
Update cip67_strip_label to address #265
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlrt committed Jan 30, 2024
1 parent 3853bba commit 4080a77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions files/grest/cron/jobs/asset-info-cache-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ if [[ $(( $(date +%s) - tip )) -gt 300 ]]; then
echo "$(date +%F_%H:%M:%S) Skipping as database has not received a new block in past 300 seconds!" && exit 1
fi

asset_registry_exists=$(psql ${DB_NAME} -qbt -c "select last_value from grest.control_table where key='asset_registry_commit';" | xargs)

[[ -z "${asset_registry_exists}" ]] && echo "$(date +%F_%H:%M:%S) Skipping as asset registry cache does not seem to be populated!" && exit 1

echo "$(date +%F_%H:%M:%S) Running asset info cache update..."
psql ${DB_NAME} -qbt -c "SELECT grest.asset_info_cache_update();" 1>/dev/null
echo "$(date +%F_%H:%M:%S) Job done!"
6 changes: 3 additions & 3 deletions files/grest/rpc/03_utilities/cip67.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ END;
$$;

CREATE OR REPLACE FUNCTION grest.cip67_strip_label(_asset_name text)
RETURNS asset32type
RETURNS bytea
LANGUAGE plpgsql STABLE
AS $$
BEGIN
IF (grest.cip67_label(_asset_name) != 0) THEN
RETURN SUBSTRING(_asset_name FROM 9);
RETURN DECODE(SUBSTRING(_asset_name FROM 9),'hex');
ELSE
RETURN _asset_name;
RETURN DECODE(_asset_name,'hex');
END IF;
END;
$$;
Expand Down

0 comments on commit 4080a77

Please sign in to comment.