Skip to content

Commit

Permalink
Merge pull request #30 from jdogresorg/btns420-indexer
Browse files Browse the repository at this point in the history
v0.11.1 release
  • Loading branch information
jdogresorg authored Feb 14, 2024
2 parents 1017d64 + 16e0731 commit 8326918
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 41 deletions.
36 changes: 24 additions & 12 deletions docs/actions/AIRDROP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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

6 changes: 6 additions & 0 deletions indexer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
41 changes: 34 additions & 7 deletions indexer/includes/actions/issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)';
Expand All @@ -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)';
Expand Down Expand Up @@ -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';

Expand Down
23 changes: 19 additions & 4 deletions indexer/includes/actions/mint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*****************************************************************
Expand Down Expand Up @@ -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';

Expand Down
6 changes: 3 additions & 3 deletions indexer/includes/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
// 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
define("MIN_TICK_LENGTH",1);
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
Expand Down Expand Up @@ -49,7 +49,7 @@

// BTNS Address
define('BURN_ADDRESS', "mvCounterpartyXXXXXXXXXXXXXXW24Hef");
define('GAS_ADDRESS', "mvCounterpartyXXXXXXXXXXXXXXW24Hef");
define('GAS_ADDRESS', "mvThcDEbeqog2aJ7JNj1FefUPaNdYYGqHt");
}

// Database Credentials
Expand Down
Loading

0 comments on commit 8326918

Please sign in to comment.