diff --git a/docs/actions/AIRDROP.md b/docs/actions/AIRDROP.md index 02decab..068bdef 100644 --- a/docs/actions/AIRDROP.md +++ b/docs/actions/AIRDROP.md @@ -2,20 +2,28 @@ This command airdrops `token` supply to one or more `BTNS` lists. ## PARAMS -| Name | Type | Description | -| --------- | ------ | ----------------------------------- | -| `VERSION` | String | Broadcast Format Version | -| `TICK` | String | 1 to 250 characters in length | -| `AMOUNT` | String | Amount of `tokens` to airdrops | -| `LIST` | String | `TX_HASH` of a BTNS `LIST` commands | +| Name | Type | Description | +| --------- | ------ | ------------------------------| +| `VERSION` | String | Broadcast Format Version | +| `TICK` | String | 1 to 250 characters in length | +| `AMOUNT` | String | Amount of `tokens` to airdrop | +| `LIST` | String | `TX_HASH` of a BTNS `LIST` | +| `MEMO` | String | An optional memo to include | ## Formats -### Version `0` -- `VERSION|TICK|AMOUNT|LIST|LIST` +### Version `0` - Single Airdrop +- `VERSION|TICK|AMOUNT|LIST|MEMO` + +### Version `1` - Multi-Airdrop (brief) +- `VERSION|LIST|TICK|AMOUNT|TICK|AMOUNT|MEMO` + +### Version `2` - Multi-Airdrop (Full) +- `VERSION|TICK|AMOUNT|LIST|TICK|AMOUNT|LIST|MEMO` + +### Version `3` - Multi-Airdrop (Full) with Multiple Memos +- `VERSION|TICK|AMOUNT|LIST|MEMO|TICK|AMOUNT|LIST|MEMO` -### Version `1` -- `VERSION|TICK|AMOUNT|LIST|TICK|AMOUNT|LIST` ## Examples ``` @@ -31,8 +39,12 @@ This example airdops 1 GAS to every holder on a list and 2 BRRR to every holder ## Rules ## Notes -- Use format `0` to send the same `AMOUNT` of `token` to one or more `LIST` -- Use format `1` to send multiple `AMOUNT` of multiple `token` to different `LIST` - `AIRDROP` to `address` `LIST` sends `AMOUNT` of `token` to each address on the list - `AIRDROP` to `token` `LIST` sends `AMOUNT` of `token` to holders of each `token` on the list - `AIRDROP` to `ASSET` `LIST` sends `AMOUNT` of `token` to holders of each `ASSET` on the list +- Format version `0` allows for a single airdrop +- Format version `1` allows for repeating `TICK` and `AMOUNT` params to enable multiple airdrops to a single list +- Format version `2` allows for repeating `TICK`, `AMOUNT` and `LIST` params to enable multiple airdrops to multiple lists +- Format version `3` allows for repeating `TICK`, `AMOUNT`, `LIST`, and `MEMO` params to enable multiple airdrops to multiple lists with multiple memos +- Format version `0`, `1`, and `2` allow for a single optional `MEMO` field to be included as the last PARAM + diff --git a/indexer/CHANGELOG.md b/indexer/CHANGELOG.md index 991b0d7..bcf6990 100644 --- a/indexer/CHANGELOG.md +++ b/indexer/CHANGELOG.md @@ -1,5 +1,11 @@ CHANGELOG --- +0.11.1 +- Added support for `MINT_START_BLOCK` +- Added support for `MINT_STOP_BLOCK` +- Added support for `MINT_ADDRESS_MAX` +- Updates to support `GAS` minting + 0.11.0 - DESTROY support - Added basic sanity checks diff --git a/indexer/includes/actions/issue.php b/indexer/includes/actions/issue.php index 1799ef6..ed062aa 100644 --- a/indexer/includes/actions/issue.php +++ b/indexer/includes/actions/issue.php @@ -23,6 +23,9 @@ * - CALLBACK_AMOUNT - `TICK` `token` amount that users get when `CALLBACK` command is used * - ALLOW_LIST - `TX_HASH` of a BTNS LIST of addresses allowed to interact with this token * - BLOCK_LIST - `TX_HASH` of a BTNS LIST of addresses NOT allowed to interact with this token + * - MINT_ADDRESS_MAX - Maximum amount of supply any address can mint via `MINT` transactions + * - MINT_START_BLOCK - `BLOCK_INDEX` when `MINT` transactions are allowed (begin mint) + * - MINT_STOP_BLOCK` - `BLOCK_INDEX` when `MINT` transactions are NOT allowed (end mint) * * FORMATS : * - 0 = Full @@ -37,16 +40,16 @@ function btnsIssue( $params=null, $data=null, $error=null){ // Define list of known FORMATS $formats = array( - 0 => 'VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK|CALLBACK_AMOUNT|ALLOW_LIST|BLOCK_LIST', + 0 => 'VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK|CALLBACK_AMOUNT|ALLOW_LIST|BLOCK_LIST|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK', 1 => 'VERSION|TICK|DESCRIPTION', - 2 => 'VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY', + 2 => 'VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK', 3 => 'VERSION|TICK|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK', 4 => 'VERSION|TICK|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK' ); // Define list of AMOUNT and LOCK fields (used in validations) $fieldList = array( - 'AMOUNT' => array('MAX_SUPPLY','MAX_MINT','MINT_SUPPLY','CALLBACK_AMOUNT'), + 'AMOUNT' => array('MAX_SUPPLY', 'MAX_MINT', 'MINT_SUPPLY', 'CALLBACK_AMOUNT', 'MINT_ADDRESS_MAX', 'MINT_START_BLOCK', 'MINT_STOP_BLOCK'), 'LOCK' => array('LOCK_SUPPLY', 'LOCK_MINT', 'LOCK_DESCRIPTION', 'LOCK_RUG', 'LOCK_SLEEP', 'LOCK_CALLBACK') ); @@ -87,12 +90,12 @@ function btnsIssue( $params=null, $data=null, $error=null){ $error = 'invalid: TICK (semicolon)'; // Verify TICK is not on RESERVED_TICKS list - if(!$error && in_array($data->TICK,RESERVED_TICKS)) + if(!$error && in_array($data->TICK,RESERVED_TICKS)) $error = 'invalid: TICK (reserved)'; - // Verify TRANSFER_SUPPLY and SOURCE are different - if($data->TRANSFER_SUPPLY == $data->SOURCE) - unset($data->TRANSFER_SUPPLY); + // Verify only GAS_ADDRESS can issue GAS token + if(!$error && strtoupper($data->TICK)=='GAS' && $data->SOURCE!=GAS_ADDRESS) + $error = 'invalid: GAS_ADDRESS'; // Get information on BTNS token $btInfo = getTokenInfo($data->TICK); @@ -184,6 +187,10 @@ function btnsIssue( $params=null, $data=null, $error=null){ if(!$error && isset($data->TRANSFER) && !isCryptoAddress($data->TRANSFER)) $error = 'invalid: TRANSFER (bad address)'; + // Verify TRANSFER_SUPPLY and SOURCE are different + if($data->TRANSFER_SUPPLY == $data->SOURCE) + unset($data->TRANSFER_SUPPLY); + // Verify TRANSFER_SUPPLY addresses if(!$error && isset($data->TRANSFER_SUPPLY) && !isCryptoAddress($data->TRANSFER_SUPPLY)) $error = 'invalid: TRANSFER_SUPPLY (bad address)'; @@ -192,6 +199,14 @@ function btnsIssue( $params=null, $data=null, $error=null){ if(!$error && isset($data->MINT_SUPPLY) && $data->MINT_SUPPLY > $data->MAX_SUPPLY) $error = 'invalid: MINT_SUPPLY > MAX_SUPPLY'; + // Verify MINT_ADDRESS_MAX is less than MAX_SUPPLY + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX > 0 && $data->MINT_ADDRESS_MAX > $data->MAX_SUPPLY) + $error = 'invalid: MINT_ADDRESS_MAX > MAX_SUPPLY'; + + // Verify MINT_ADDRESS_MAX is greater than than MAX_MINT + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX > 0 && $data->MINT_ADDRESS_MAX < $data->MAX_MINT) + $error = 'invalid: MINT_ADDRESS_MAX < MAX_MINT'; + // Verify MAX_SUPPLY can not be changed if LOCK_SUPPLY is enabled if(!$error && $btInfo && $btnInfo->LOCK_SUPPLY && isset($data->MAX_SUPPLY) && $data->MAX_SUPPLY!=$btnInfo->MAX_SUPPLY) $error = 'invalid: MAX_SUPPLY (locked)'; @@ -244,6 +259,18 @@ function btnsIssue( $params=null, $data=null, $error=null){ if(!$error && isset($data->BLOCK_LIST) && !isValidList($data->BLOCK_LIST,3)) $error = 'invalid: BLOCK_LIST (bad list)'; + // Verify MINT_START_BLOCK is greater than or equal to current block + if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK > 0 && $data->MINT_START_BLOCK < $data->BLOCK_INDEX) + $error = 'invalid: MINT_START_BLOCK < BLOCK_INDEX'; + + // Verify MINT_STOP_BLOCK is greater than or equal to current block + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK > 0 && $data->MINT_STOP_BLOCK < $data->BLOCK_INDEX) + $error = 'invalid: MINT_STOP_BLOCK < BLOCK_INDEX'; + + // Verify MINT_STOP_BLOCK is greater than or equal to MINT_START_BLOCK + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_START_BLOCK > 0 && $data->MINT_STOP_BLOCK > 0 && $data->MINT_STOP_BLOCK < $data->MINT_START_BLOCK) + $error = 'invalid: MINT_STOP_BLOCK < MINT_START_BLOCK'; + // Determine final status $data->STATUS = $status = ($error) ? $error : 'valid'; diff --git a/indexer/includes/actions/mint.php b/indexer/includes/actions/mint.php index e5e1320..746fe1f 100644 --- a/indexer/includes/actions/mint.php +++ b/indexer/includes/actions/mint.php @@ -51,10 +51,13 @@ function btnsMint($params=null, $data=null, $error=null){ // Update BTNS transaction object with basic token details if($btInfo){ - $data->SUPPLY = ($btInfo) ? $btInfo->SUPPLY : 0; - $data->DECIMALS = ($btInfo) ? $btInfo->DECIMALS : 0; - $data->MAX_SUPPLY = ($btInfo) ? $btInfo->MAX_SUPPLY : 0; - $data->MAX_MINT = ($btInfo) ? $btInfo->MAX_MINT : 0; + $data->SUPPLY = ($btInfo) ? $btInfo->SUPPLY : 0; + $data->DECIMALS = ($btInfo) ? $btInfo->DECIMALS : 0; + $data->MAX_SUPPLY = ($btInfo) ? $btInfo->MAX_SUPPLY : 0; + $data->MAX_MINT = ($btInfo) ? $btInfo->MAX_MINT : 0; + $data->MINT_ADDRESS_MAX = ($btInfo) ? $btInfo->MINT_ADDRESS_MAX : 0; + $data->MINT_START_BLOCK = ($btInfo) ? $btInfo->MINT_START_BLOCK : 0; + $data->MINT_STOP_BLOCK = ($btInfo) ? $btInfo->MINT_STOP_BLOCK : 0; } /***************************************************************** @@ -89,6 +92,18 @@ function btnsMint($params=null, $data=null, $error=null){ if(!$error && isset($data->DESTINATION) && !isActionAllowed($data->TICK, $data->DESTINATION)) $error = 'invalid: DESTINATION (not authorized)'; + // Verify minting AMOUNT will not exceed MINT_ADDRESS_MAX + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX > 0 && (bcadd(getActionCreditDebitAmount('credits', 'MINT', $data->TICK, $data->SOURCE),$data->AMOUNT,$data->DECIMALS) > $data->MINT_ADDRESS_MAX)) + $error = 'invalid: mint exceeds MINT_ADDRESS_MAX'; + + // Verify minting begins at MINT_START_BLOCK + if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK > 0 && $data->BLOCK_INDEX < $data->MINT_START_BLOCK) + $error = 'invalid: MINT_START_BLOCK'; + + // Verify minting ends at MINT_STOP_BLOCK + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK > 0 && $data->BLOCK_INDEX > $data->MINT_STOP_BLOCK) + $error = 'invalid: MINT_STOP_BLOCK'; + // Determine final status $data->STATUS = $status = ($error) ? $error : 'valid'; diff --git a/indexer/includes/config.php b/indexer/includes/config.php index 95e85a6..0ed44e7 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", 11); -define("VERSION_REVISION",0); +define("VERSION_REVISION",1); define("VERSION_STRING", VERSION_MAJOR . '.' . VERSION_MINOR . '.' . VERSION_REVISION); // TICK constants @@ -18,7 +18,7 @@ define("MAX_TICK_LENGTH",250); // Reserved BTNS TICK names -$reserved = array('BTC','XCP','GAS'); +$reserved = array('BTC','XCP'); define("RESERVED_TICKS",$reserved); // Min/Max MAX_SUPPLY @@ -49,7 +49,7 @@ // BTNS Address define('BURN_ADDRESS', "mvCounterpartyXXXXXXXXXXXXXXW24Hef"); - define('GAS_ADDRESS', "mvCounterpartyXXXXXXXXXXXXXXW24Hef"); + define('GAS_ADDRESS', "mvThcDEbeqog2aJ7JNj1FefUPaNdYYGqHt"); } // Database Credentials diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index 2149941..6d2b135 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -219,20 +219,27 @@ function createIssue( $data=null ){ $max_supply = (isset($data->MAX_SUPPLY) && is_numeric($data->MAX_SUPPLY)) ? $data->MAX_SUPPLY : 0; $max_mint = (isset($data->MAX_MINT) && is_numeric($data->MAX_MINT)) ? $data->MAX_MINT : 0; $mint_supply = (isset($data->MINT_SUPPLY) && is_numeric($data->MINT_SUPPLY)) ? $data->MINT_SUPPLY : 0; + $mint_address_max = (isset($data->MINT_ADDRESS_MAX) && is_numeric($data->MINT_ADDRESS_MAX)) ? $data->MINT_ADDRESS_MAX : 0; + $mint_start_block = (isset($data->MINT_START_BLOCK) && is_numeric($data->MINT_START_BLOCK)) ? $data->MINT_START_BLOCK : 0; + $mint_stop_block = (isset($data->MINT_STOP_BLOCK) && is_numeric($data->MINT_STOP_BLOCK)) ? $data->MINT_STOP_BLOCK : 0; $callback_amount = (isset($data->CALLBACK_AMOUNT) && is_numeric($data->CALLBACK_AMOUNT)) ? $data->CALLBACK_AMOUNT : 0; $decimals = (isset($data->DECIMALS)) ? $data->DECIMALS : 0; // Truncate description to 250 chars $description = substr($data->DESCRIPTION,0,250); // Force any amount values to the correct decimal precision if(is_numeric($decimals) && $decimals>=0 && $decimals<=18){ - $max_supply = bcmul($max_supply,1,$decimals); - $max_mint = bcmul($max_mint,1,$decimals); - $mint_supply = bcmul($mint_supply,1,$decimals); - $callback_amount = bcmul($callback_amount,1,$decimals); + $max_supply = bcmul($max_supply,1,$decimals); + $max_mint = bcmul($max_mint,1,$decimals); + $mint_supply = bcmul($mint_supply,1,$decimals); + $mint_address_max = bcmul($mint_address_max,1,$decimals); + $callback_amount = bcmul($callback_amount,1,$decimals); } $max_supply = $mysqli->real_escape_string($max_supply); $max_mint = $mysqli->real_escape_string($max_mint); $mint_supply = $mysqli->real_escape_string($mint_supply); + $mint_address_max = $mysqli->real_escape_string($mint_address_max); + $mint_start_block = $mysqli->real_escape_string($mint_start_block); + $mint_stop_block = $mysqli->real_escape_string($mint_stop_block); $decimals = $mysqli->real_escape_string($decimals); $description = $mysqli->real_escape_string($description); $block_index = $mysqli->real_escape_string($data->BLOCK_INDEX); @@ -285,6 +292,9 @@ function createIssue( $data=null ){ callback_amount='{$callback_amount}', allow_list_id='{$allow_list_id}', block_list_id='{$block_list_id}', + mint_address_max='{$mint_address_max}', + mint_start_block='{$mint_start_block}', + mint_stop_block='{$mint_stop_block}', source_id='{$source_id}', block_index='{$block_index}', tx_index='{$tx_index}', @@ -293,14 +303,14 @@ function createIssue( $data=null ){ tx_hash_id='{$tx_hash_id}'"; } else { // INSERT record - $sql = "INSERT INTO issues (tick_id, max_supply, max_mint, decimals, description, mint_supply, transfer_id, transfer_supply_id, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, source_id, tx_hash_id, block_index, tx_index, status_id) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$mint_supply}', '{$transfer_id}', '{$transfer_supply_id}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}','{$source_id}', '{$tx_hash_id}', '{$block_index}', '{$tx_index}', '{$status_id}')"; + $sql = "INSERT INTO issues (tick_id, max_supply, max_mint, decimals, description, mint_supply, transfer_id, transfer_supply_id, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, mint_address_max, mint_start_block, mint_stop_block, source_id, tx_hash_id, block_index, tx_index, status_id) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$mint_supply}', '{$transfer_id}', '{$transfer_supply_id}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$mint_address_max}', '{$mint_start_block}', '{$mint_stop_block}', '{$source_id}', '{$tx_hash_id}', '{$block_index}', '{$tx_index}', '{$status_id}')"; } // print $sql; $results = $mysqli->query($sql); if(!$results) - byeLog('Error while trying to create / update a record in the deploys table'); + byeLog('Error while trying to create / update a record in the issues table'); } else { - byeLog('Error while trying to lookup record in deploys table'); + byeLog('Error while trying to lookup record in issues table'); } } @@ -457,18 +467,25 @@ function createToken( $data=null ){ $max_supply = (isset($data->MAX_SUPPLY) && is_numeric($data->MAX_SUPPLY)) ? $data->MAX_SUPPLY : 0; $max_mint = (isset($data->MAX_MINT) && is_numeric($data->MAX_MINT)) ? $data->MAX_MINT : 0; $mint_supply = (isset($data->MINT_SUPPLY) && is_numeric($data->MINT_SUPPLY)) ? $data->MINT_SUPPLY : 0; + $mint_address_max = (isset($data->MINT_ADDRESS_MAX) && is_numeric($data->MINT_ADDRESS_MAX)) ? $data->MINT_ADDRESS_MAX : 0; + $mint_start_block = (isset($data->MINT_START_BLOCK) && is_numeric($data->MINT_START_BLOCK)) ? $data->MINT_START_BLOCK : 0; + $mint_stop_block = (isset($data->MINT_STOP_BLOCK) && is_numeric($data->MINT_STOP_BLOCK)) ? $data->MINT_STOP_BLOCK : 0; $callback_amount = (isset($data->CALLBACK_AMOUNT) && is_numeric($data->CALLBACK_AMOUNT)) ? $data->CALLBACK_AMOUNT : 0; $decimals = (isset($data->DECIMALS)) ? $data->DECIMALS : 0; // Force any amount values to the correct decimal precision if(is_numeric($decimals) && $decimals>=0 && $decimals<=18){ - $max_supply = bcmul($max_supply,1,$decimals); - $max_mint = bcmul($max_mint,1,$decimals); - $mint_supply = bcmul($mint_supply,1,$decimals); - $callback_amount = bcmul($callback_amount,1,$decimals); + $max_supply = bcmul($max_supply,1,$decimals); + $max_mint = bcmul($max_mint,1,$decimals); + $mint_supply = bcmul($mint_supply,1,$decimals); + $mint_address_max = bcmul($mint_address_max,1,$decimals); + $callback_amount = bcmul($callback_amount,1,$decimals); } $supply = $mysqli->real_escape_string($supply); $max_supply = $mysqli->real_escape_string($max_supply); $max_mint = $mysqli->real_escape_string($max_mint); + $mint_address_max = $mysqli->real_escape_string($mint_address_max); + $mint_start_block = $mysqli->real_escape_string($mint_start_block); + $mint_stop_block = $mysqli->real_escape_string($mint_stop_block); $decimals = $mysqli->real_escape_string($decimals); $description = $mysqli->real_escape_string($data->DESCRIPTION); $block_index = $mysqli->real_escape_string($data->BLOCK_INDEX); @@ -510,6 +527,9 @@ function createToken( $data=null ){ callback_amount='{$callback_amount}', allow_list_id='{$allow_list_id}', block_list_id='{$block_list_id}', + mint_address_max='{$mint_address_max}', + mint_start_block='{$mint_start_block}', + mint_stop_block='{$mint_stop_block}', block_index='{$block_index}', supply='{$supply}', owner_id='{$owner_id}' @@ -517,7 +537,7 @@ function createToken( $data=null ){ tick_id='{$tick_id}'"; } else { // INSERT record - $sql = "INSERT INTO tokens (tick_id, max_supply, max_mint, decimals, description, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, owner_id, supply, block_index) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$owner_id}','{$supply}', '{$block_index}')"; + $sql = "INSERT INTO tokens (tick_id, max_supply, max_mint, decimals, description, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, mint_address_max, mint_start_block, mint_stop_block, owner_id, supply, block_index) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$mint_address_max}', '{$mint_start_block}', '{$mint_stop_block}', '{$owner_id}','{$supply}', '{$block_index}')"; } // print $sql; $results = $mysqli->query($sql); @@ -920,6 +940,9 @@ function getTokenInfo($tick=null, $tick_id=null){ t1.callback_amount, t4.hash as allow_list, t5.hash as block_list, + t1.mint_address_max, + t1.mint_start_block, + t1.mint_stop_block, a.address as owner FROM tokens t1 @@ -956,7 +979,10 @@ function getTokenInfo($tick=null, $tick_id=null){ 'CALLBACK_BLOCK' => $row->callback_block, 'CALLBACK_AMOUNT' => $row->callback_amount, 'ALLOW_LIST' => $row->allow_list, - 'BLOCK_LIST' => $row->block_list + 'BLOCK_LIST' => $row->block_list, + 'MINT_ADDRESS_MAX' => $row->mint_address_max, + 'MINT_START_BLOCK' => $row->mint_start_block, + 'MINT_STOP_BLOCK' => $row->mint_stop_block ); } } else { @@ -1056,7 +1082,7 @@ function getTokenDecimalPrecision($tick_id=null){ } // Handle getting credits or debits records for a given address -function getAddressCreditDebit($table=null, $address=null){ +function getAddressCreditDebit($table=null, $address=null, $action=null){ global $mysqli; $data = array(); // Assoc array to store tick/credits $type = gettype($address); @@ -1064,6 +1090,8 @@ function getAddressCreditDebit($table=null, $address=null){ $address_id = $address; if($type==='string' && !is_numeric($address)) $address_id = createAddress($address); + if(isset($action)) + $action_id = createAction($action); if(in_array($table,array('credits','debits'))){ // Get data from the table $sql = "SELECT @@ -1076,6 +1104,8 @@ function getAddressCreditDebit($table=null, $address=null){ WHERE t2.tick_id=t1.tick_id AND t1.address_id='{$address_id}'"; + if(isset($action)) + $sql .= " AND t1.action_id={$action_id}"; $results = $mysqli->query($sql); if($results){ if($results->num_rows){ @@ -1755,4 +1785,16 @@ function consolidateCreditDebitRecords($type=null, $records=null){ } return $data; } + +// Get total amount of credit or debit records for a given address, ticker, and action +function getActionCreditDebitAmount($table=null, $action=null, $tick=null, $address=null){ + global $mysqli; + $total = 0; + $tick_id = createTicker($tick); + $addr_id = createAddress($address); + $data = getAddressCreditDebit($table, $addr_id, $action); + if($data[$tick_id]) + $total = $data[$tick_id]; + return $total; +} ?> \ No newline at end of file diff --git a/indexer/sql/issues.sql b/indexer/sql/issues.sql index ed08ec9..742005c 100644 --- a/indexer/sql/issues.sql +++ b/indexer/sql/issues.sql @@ -20,6 +20,9 @@ CREATE TABLE issues ( callback_amount VARCHAR(250), -- AMOUNT users get if CALLBACK allow_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table block_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table + mint_address_max VARCHAR(250), -- Maximum amount of supply an address can MINT + mint_start_block INTEGER UNSIGNED, -- block_index when MINT transactions are allowed (begin mint) + mint_stop_block INTEGER UNSIGNED, -- BLOCK_INDEX when MINT transactions are NOT allowed (end mint) source_id INTEGER UNSIGNED, -- id of record in index_addresses table (address that did DEPLOY) tx_hash_id INTEGER UNSIGNED, -- id of record in index_transactions block_index INTEGER UNSIGNED, -- block index of DEPLOY transaction diff --git a/indexer/sql/tokens.sql b/indexer/sql/tokens.sql index 1a8b5f0..74fd91e 100644 --- a/indexer/sql/tokens.sql +++ b/indexer/sql/tokens.sql @@ -19,6 +19,9 @@ CREATE TABLE tokens ( callback_amount BIGINT UNSIGNED, -- AMOUNT users get if CALLBACK allow_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table block_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table + mint_address_max VARCHAR(250), -- Maximum amount of supply an address can MINT + mint_start_block INTEGER UNSIGNED, -- block_index when MINT transactions are allowed (begin mint) + mint_stop_block INTEGER UNSIGNED, -- BLOCK_INDEX when MINT transactions are NOT allowed (end mint) owner_id INTEGER UNSIGNED, -- id of record in index_addresses table btc_price VARCHAR(250) NOT NULL default 0 -- last price of BTC purchase of 1 token ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; @@ -33,4 +36,4 @@ CREATE INDEX lock_sleep ON tokens (lock_sleep); CREATE INDEX lock_callback ON tokens (lock_callback); CREATE INDEX callback_tick_id ON tokens (callback_tick_id); CREATE INDEX allow_list_id ON tokens (allow_list_id); -CREATE INDEX block_list_id ON tokens (block_list_id); \ No newline at end of file +CREATE INDEX block_list_id ON tokens (block_list_id);