diff --git a/docs/actions/MINT.md b/docs/actions/MINT.md index 1962124..f723a33 100644 --- a/docs/actions/MINT.md +++ b/docs/actions/MINT.md @@ -8,11 +8,12 @@ This command mints `BTNS` `token` supply | `TICK` | String | 1 to 250 characters in length | | `AMOUNT` | String | Amount of `tokens` to mint | | `DESTINATION` | String | Address to transfer minted `tokens` to | +| `MEMO` | String | An optional memo to include | ## Formats ### Version `0` -- `VERSION|TICK|AMOUNT|DESTINATION` +- `VERSION|TICK|AMOUNT|DESTINATION|MEMO` ## Examples ``` diff --git a/indexer/includes/actions/mint.php b/indexer/includes/actions/mint.php index 106d865..6bfc807 100644 --- a/indexer/includes/actions/mint.php +++ b/indexer/includes/actions/mint.php @@ -17,7 +17,7 @@ function btnsMint($params=null, $data=null, $error=null){ // Define list of known FORMATS $formats = array( - 0 => 'VERSION|TICK|AMOUNT|DESTINATION' + 0 => 'VERSION|TICK|AMOUNT|DESTINATION|MEMO' ); /***************************************************************** @@ -91,6 +91,14 @@ function btnsMint($params=null, $data=null, $error=null){ * General Validations ****************************************************************/ + // Verify no pipe in MEMO (BTNS uses pipe as field delimiter) + if(!$error && isset($data->MEMO) && strpos($data->MEMO,'|')!==false) + $error = 'invalid: MEMO (pipe)'; + + // Verify no semicolon in MEMO (BTNS uses semicolon as action delimiter) + if(!$error && isset($data->MEMO) && strpos($data->MEMO,';')!==false) + $error = 'invalid: MEMO (semicolon)'; + // Verify AMOUNT is less than MAX_MINT if(!$error && isset($data->AMOUNT) && $data->AMOUNT > $data->MAX_MINT) $error = 'invalid: AMOUNT > MAX_MINT'; diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index d99a952..85cceea 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -321,6 +321,7 @@ function createMint( $data=null ){ $source_id = createAddress($data->SOURCE); $destination_id = createAddress($data->DESTINATION); $tx_hash_id = createTransaction($data->TX_HASH); + $memo_id = createMemo($data->MEMO); $status_id = createStatus($data->STATUS); $tx_index = $mysqli->real_escape_string($data->TX_INDEX); $amount = $mysqli->real_escape_string($data->AMOUNT); @@ -340,12 +341,13 @@ function createMint( $data=null ){ source_id='{$source_id}', block_index='{$block_index}', tx_index='{$tx_index}', + memo_id='{$memo_id}', status_id='{$status_id}' WHERE tx_hash_id='{$tx_hash_id}'"; } else { // INSERT record - $sql = "INSERT INTO mints (tx_index, tick_id, amount, source_id, destination_id, tx_hash_id, block_index, status_id) values ('{$tx_index}','{$tick_id}', '{$amount}', '{$source_id}', '{$destination_id}', '{$tx_hash_id}', '{$block_index}', '{$status_id}')"; + $sql = "INSERT INTO mints (tx_index, tick_id, amount, source_id, destination_id, tx_hash_id, block_index, memo_id, status_id) values ('{$tx_index}','{$tick_id}', '{$amount}', '{$source_id}', '{$destination_id}', '{$tx_hash_id}', '{$block_index}', '{$memo_id}', '{$status_id}')"; } $results = $mysqli->query($sql); if(!$results) diff --git a/indexer/sql/mints.sql b/indexer/sql/mints.sql index 8a3ce76..65880e0 100644 --- a/indexer/sql/mints.sql +++ b/indexer/sql/mints.sql @@ -7,6 +7,7 @@ CREATE TABLE mints ( destination_id INTEGER UNSIGNED, -- id of record in index_addresses table (optional, mint and transfer) tx_hash_id INTEGER UNSIGNED, -- id of record in index_transactions block_index INTEGER UNSIGNED, -- block index of MINT transaction + memo_id INTEGER UNSIGNED, -- id of record in index_memos table status_id INTEGER UNSIGNED -- id of record in index_statuses table ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -15,4 +16,5 @@ CREATE INDEX tick_id ON mints (tick_id); CREATE INDEX tx_hash_id ON mints (tx_hash_id); CREATE INDEX source_id ON mints (source_id); CREATE INDEX destination_id ON mints (destination_id); +CREATE INDEX memo_id ON mints (memo_id); CREATE INDEX status_id ON mints (status_id);