diff --git a/docs/actions/ISSUE.md b/docs/actions/ISSUE.md index 8bbc661..fd239ac 100644 --- a/docs/actions/ISSUE.md +++ b/docs/actions/ISSUE.md @@ -103,7 +103,8 @@ This example issues a TEST token with a max supply of 100, and a maximum mint of - Additional `TICK` `ISSUE` transactions after first valid `TICK` `ISSUE`, will be considered invalid and ignored, unless broadcast from `token` owners address - `DECIMALS` can not be changed after `token` supply is issued and/or minted - `MAX_SUPPLY` max value is 1,000,000,000,000,000,000,000 (1 Sextillion) -- `LOCK_SUPPLY` can not be set to `1` and permanently locked unless `MAX_SUPPLY` is set to a non-zero number. +- `MAX_SUPPLY` can not be set below existing supply +- `LOCK_SUPPLY` can not be set to `1` and permanently locked until `MIN_TOKEN_SUPPLY` supply exists. ## Notes - `ISSUE` `TICK` with `MAX_SUPPLY` and `MINT_SUPPLY` set to any non `0` value, to mint supply until `MAX_SUPPLY` is reached (owner can mint beyond `MAX_MINT`) diff --git a/indexer/CHANGELOG.md b/indexer/CHANGELOG.md index ca09e2c..d3aaf6a 100644 --- a/indexer/CHANGELOG.md +++ b/indexer/CHANGELOG.md @@ -1,5 +1,12 @@ CHANGELOG --- +0.10.1 +- set MIN_TOKEN_SUPPLY to 0.000000000000000001 +- Prevent LOCK_SUPPLY if no supply is issued +- Prevent setting MAX_SUPPLY below current SUPPLY +- Updated getTokenSupply() to use CAST in sql queries +- Updated getAssetInfo() to only lookup assets using name + 0.10.0 - Initial Release - ISSUE support - LIST support diff --git a/indexer/includes/actions/issue.php b/indexer/includes/actions/issue.php index d1a2395..c54e914 100644 --- a/indexer/includes/actions/issue.php +++ b/indexer/includes/actions/issue.php @@ -153,6 +153,14 @@ function btnsIssue( $params=null, $data=null, $error=null){ if(!$error && isset($data->MAX_SUPPLY) && ($data->MAX_SUPPLY < MIN_TOKEN_SUPPLY || $data->MAX_SUPPLY > MAX_TOKEN_SUPPLY)) $error = 'invalid: MAX_SUPPLY (min/max)'; + // Verify MAX_SUPPLY is not set below current SUPPLY + if(!$error && isset($data->MAX_SUPPLY) && $data->MAX_SUPPLY < $data->SUPPLY) + $error = 'invalid: MAX_SUPPLY < SUPPLY'; + + // Verify SUPPLY is at least MIN_TOKEN_SUPPLY before allowing LOCK_SUPPLY + if(!$error && $data->LOCK_SUPPLY && (($btInfo && $btInfo->SUPPLY < MIN_TOKEN_SUPPLY) || (!$btInfo && $data->MINT_SUPPLY < MIN_TOKEN_SUPPLY))) + $error = 'invalid: LOCK_SUPPLY (no supply)'; + // Verify DECIMAL min/max if(!$error && isset($data->DECIMALS) && ($data->DECIMALS < MIN_TOKEN_DECIMALS || $data->DECIMALS > MAX_TOKEN_DECIMALS)) $error = 'invalid: DECIMALS (min/max)'; diff --git a/indexer/includes/config.php b/indexer/includes/config.php index 34de998..7bcc77a 100644 --- a/indexer/includes/config.php +++ b/indexer/includes/config.php @@ -10,7 +10,7 @@ // BTNS Indexer Version define("VERSION_MAJOR", 0); define("VERSION_MINOR", 10); -define("VERSION_REVISION",0); +define("VERSION_REVISION",1); define("VERSION_STRING", VERSION_MAJOR . '.' . VERSION_MINOR . '.' . VERSION_REVISION); // TICK constants @@ -22,7 +22,7 @@ define("RESERVED_TICKS",$reserved); // Min/Max MAX_SUPPLY -define('MIN_TOKEN_SUPPLY',0); +define('MIN_TOKEN_SUPPLY',0.000000000000000001); define('MAX_TOKEN_SUPPLY',1000000000000000000000); // Min/Max DECIMALS diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index a9dbceb..42ddf0d 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -930,13 +930,11 @@ function getAssetId($asset=null){ // Handle getting asset information for an asset function getAssetInfo($asset=null){ global $mysqli, $dbase; - $type = gettype($tick); + $type = gettype($asset); $data = false; - if($type==='integer' || is_numeric($asset)){ - $asset_id = $asset; - } else { + // Only do lookup on strings, since all CP assets are strings + if($type=='string') $asset_id = getAssetId($asset); - } if($asset_id){ // Get data from assets table $sql = "SELECT @@ -1228,8 +1226,10 @@ function getTokenSupply( $tick=null ){ $tick_id = $tick; if($type==='string' && !is_numeric($tick)) $tick_id = createTicker($tick); - // Get Credits - $sql = "SELECT SUM(amount) as credits FROM credits WHERE tick_id='{$tick_id}'"; + // Get info on decimal precision + $decimals = getTokenDecimalPrecision($tick_id); + // Get Credits + $sql = "SELECT CAST(SUM(amount) AS DECIMAL(60,$decimals)) as credits FROM credits WHERE tick_id='{$tick_id}'"; $results = $mysqli->query($sql); if($results){ if($results->num_rows){ @@ -1240,7 +1240,7 @@ function getTokenSupply( $tick=null ){ byeLog('Error while trying to get list of credits'); } // Get Debits - $sql = "SELECT SUM(amount) as debits FROM debits WHERE tick_id='{$tick_id}'"; + $sql = "SELECT CAST(SUM(amount) AS DECIMAL(60,$decimals)) as debits FROM debits WHERE tick_id='{$tick_id}'"; $results = $mysqli->query($sql); if($results){ if($results->num_rows){ @@ -1250,12 +1250,10 @@ function getTokenSupply( $tick=null ){ } else { byeLog('Error while trying to get list of debits'); } - $decimals = getTokenDecimalPrecision($tick_id); - $supply = bcsub($credits, $debits, $decimals); + $supply = bcsub($credits, $debits, $decimals); return $supply; } - // Handle doing VERY lose validation on an address function isCryptoAddress( $address=null ){ $len = strlen($address);