Skip to content

Commit

Permalink
Merge pull request #37 from jdogresorg/btns420-indexer
Browse files Browse the repository at this point in the history
v0.12.0 Release
  • Loading branch information
jdogresorg authored Mar 23, 2024
2 parents 742b13f + 357b350 commit b2903f5
Show file tree
Hide file tree
Showing 37 changed files with 1,837 additions and 512 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Name | Title | Aut

| ACTION | Description |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------- |
| [`ADDRESS`](./docs/actions/ADDRESS.md) | Configure address specific options |
| [`AIRDROP`](./docs/actions/AIRDROP.md) | Transfer/Distribute `token` supply to a `LIST` |
| [`BATCH`](./docs/actions/BATCH.md) | Execute multiple BTNS `ACTION` commands in a single transaction |
| [`BET`](./docs/actions/BET.md) | Bet `token` on `broadcast` oracle feed outcomes |
| [`CALLBACK`](./docs/actions/CALLBACK.md) | Return all `token` supply to owner address after a set block, in exchange for a different `token` |
| [`DESTROY`](./docs/actions/DESTROY.md) | Destroy `token` supply forever |
| [`DISPENSER`](./docs/actions/DISPENSER.md) | Create a dispenser (vending machine) to dispense a `token` when triggered |
Expand Down
2 changes: 1 addition & 1 deletion docs/BTNS-420.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Below is a list of the defined BTNS `ACTION` commands and the function of each:

| ACTION | Description |
| ------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [`ADDRESS`](./actions/ADDRESS.md) | Configures address specific options |
| [`AIRDROP`](./actions/AIRDROP.md) | Transfer/Distribute `token` supply to a `LIST` |
| [`BATCH`](./actions/BATCH.md) | Execute multiple BTNS `ACTION` commands in a single transaction |
| [`BET`](./actions/BET.md) | Bet `token` on `broadcast` oracle feed outcomes |
| [`CALLBACK`](./actions/CALLBACK.md) | Return all `token` supply to owner address after a set block, in exchange for a different `token` |
| [`DESTROY`](./actions/DESTROY.md) | Destroy `token` supply forever |
| [`DISPENSER`](./actions/DISPENSER.md) | Create a dispenser (vending machine) to dispense a `token` when triggered |
Expand Down
39 changes: 39 additions & 0 deletions docs/actions/ADDRESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ADDRESS command
This command configures address specific options.

## PARAMS
| Name | Type | Description |
| ---------------- | ------ | ----------------------------------------|
| `VERSION` | String | Broadcast Format Version |
| `FEE_PREFERENCE` | String | Set preference for how `FEE` is used |
| `REQUIRE_MEMO` | String | Require a `MEMO` on any received `SEND` |

## Formats

### Version `0`
- `VERSION|FEE_PREFERENCE|REQUIRE_MEMO`

## Examples
```
bt:ADDRESS|0|1|0
This example sets the address to DESTROY fees
```

```
bt:ADDRESS|0|2|0
This example sets the address to DONATE fees
```

```
bt:ADDRESS|0|0|1
This example sets the address to require a `MEMO` on any received `SEND`
```

## `FEE_PREFERENCE` Options
- `1` = Destroy `FEE`, provably lowering supply
- `2` = Donate `FEE` to protocol development (default)
- `3` = Donate `FEE` to community development

## Notes
- `ADDR` `ACTION` can be used for shorter reference to `ADDRESS` `ACTION`

1 change: 1 addition & 0 deletions docs/actions/AIRDROP.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This example airdops 1 GAS to every holder on a list and 2 BRRR to every holder
## Rules

## Notes
- `DROP` `ACTION` can be used for shorter reference to `AIRDROP` `ACTION`
- `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
Expand Down
7 changes: 5 additions & 2 deletions docs/actions/BATCH.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ This command batch executes multiple `BTNS` `ACTION` commands in a single transa

## Examples
```
bt:BATCH|0|MINT|0|GAS|1000;ISSUE|0|JDOG
This example mints 1000 GAS tokens and reserves the JDOG token
bt:BATCH|0|MINT|0|GAS|60;ISSUE|0|JDOG
This example mints 60 GAS tokens and reserves the JDOG token
```

## Rules
- Can only use one `MINT` command in a `BATCH` command
- Can only use one `ISSUE` command in a `BATCH` command
- Can only use one `LIST` command in a `BATCH` command
- Can not use `BATCH` as a command in a `BATCH` command

## Notes
- `COMMANDS` are separated by a semi-colon `;`
22 changes: 12 additions & 10 deletions docs/actions/ISSUE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ This command creates or issues a `BTNS` `token`
| `MINT_SUPPLY` | String | Amount of token supply to mint in immediately (default:0) |
| `TRANSFER` | String | Address to transfer ownership of the `token` to (owner can perform future actions on token) |
| `TRANSFER_SUPPLY` | String | Address to transfer `MINT_SUPPLY` to (mint initial supply and transfer to address) |
| `LOCK_SUPPLY` | String | Lock `MAX_SUPPLY` permanently (cannot increase `MAX_SUPPLY`) |
| `LOCK_MINT` | String | Lock `MAX_MINT` permanently (cannot edit `MAX_MINT`) |
| `LOCK_MAX_SUPPLY` | String | Lock `MAX_SUPPLY` permanently (cannot increase `MAX_SUPPLY`) |
| `LOCK_MAX_MINT` | String | Lock `MAX_MINT` permanently (cannot edit `MAX_MINT`) |
| `LOCK_MINT` | String | Lock `token` against `MINT` command |
| `LOCK_MINT_SUPPLY` | String | Lock `token` against issuing additional supply via `MINT_SUPPLY` |
| `LOCK_DESCRIPTION` | String | Lock `token` against `DESCRIPTION` changes |
| `LOCK_RUG` | String | Lock `token` against `RUG` command |
| `LOCK_SLEEP` | String | Lock `token` against `SLEEP` command |
Expand All @@ -32,7 +34,7 @@ This command creates or issues a `BTNS` `token`
## Formats

### Version `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`
- `VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_MAX_SUPPLY|LOCK_MAX_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|LOCK_MINT|LOCK_MINT_SUPPLY`

### Version `1` - Edit `DESCRIPTION`
- `VERSION|TICK|DESCRIPTION`
Expand All @@ -41,7 +43,7 @@ This command creates or issues a `BTNS` `token`
- `VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK`

### Version `3` - Edit `LOCK` `PARAMS`
- `VERSION|TICK|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK`
- `VERSION|TICK|LOCK_MAX_SUPPLY|LOCK_MAX_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|LOCK_MINT|LOCK_MINT_SUPPLY`

### Version `4` - Edit `CALLBACK` `PARAMS`
- `VERSION|TICK|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK`
Expand All @@ -57,7 +59,7 @@ This example issues a JDOG token

```
bt:ISSUE|0|JDOG|1||||1|||1
This example issues a JDOG token with MAX_SUPPLY set to 1, Mints 1 token via MINT_SUPPLY, and has LOCK_SUPPLY set to 1 to permanently lock the MAX_SUPPLY
This example issues a JDOG token with MAX_SUPPLY set to 1, Mints 1 token via MINT_SUPPLY, and has LOCK_MAX_SUPPLY set to 1 to permanently lock the MAX_SUPPLY
```

```
Expand Down Expand Up @@ -107,13 +109,14 @@ This example issues a TEST token with a max supply of 100, and a maximum mint of
- `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)
- `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.
- `LOCK_MAX_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`)
- `ISSUE` `TICK` with `MAX_SUPPLY` and `MAX_MINT` set to any non `0` value, to enable user minting (fair minting)
- `ISSUE` `TICK` with `LOCK_SUPPLY` set to `1` to permanently lock `MAX_SUPPLY`
- `ISSUE` `TICK` with `LOCK_MINT` set to `1` to permanently lock `MAX_MINT`
- `ISSUE` `TICK` with `LOCK_MAX_SUPPLY` set to `1` to permanently lock `MAX_SUPPLY`
- `ISSUE` `TICK` with `LOCK_MAX_MINT` set to `1` to permanently lock `MAX_MINT`
- `ISSUE` `TICK` with `LOCK_MINT` set to `1` to permanently prevent use of the `MINT` command
- `ISSUE` `TICK` with `LOCK_RUG` set to `1` to permanently prevent use of the `RUG` command
- `ISSUE` `TICK` with `LOCK_SLEEP` set to `1` to permanently prevent use of the `SLEEP` command
- `ISSUE` `TICK` with `LOCK_CALLBACK` set to `1` to permanently lock `CALLBACK_BLOCK`, `CALLBACK_TICK`, and `CALLBACK_AMOUNT`
Expand All @@ -126,5 +129,4 @@ This example issues a TEST token with a max supply of 100, and a maximum mint of
- If `TICK` contains any unicode characters, then `TICK` should be `base64` encoded
- `counterparty` `ASSET` and `SUBASSET` names are reserved within the BTNS for use by the `counterparty` owner
- `MINT_ADDRESS_MAX` can be used to limit the maximum `TICK` `AMOUNT` that a single address can `MINT`
- `MINT_START_BLOCK` and `MINT_STOP_BLOCK` can be used to determine period(s) when `MINT` transactions are allowed

- `MINT_START_BLOCK` and `MINT_STOP_BLOCK` can be used to determine period(s) when `MINT` transactions are allowed
8 changes: 4 additions & 4 deletions docs/actions/SEND.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ This command sends/transfers one or more `token`s between addresses

## Formats

### Version `0`
### Version `0` - Single Send
- `VERSION|TICK|AMOUNT|DESTINATION|MEMO`

### Version `1`
### Version `1` - Multi-Send (Brief)
- `VERSION|TICK|AMOUNT|DESTINATION|AMOUNT|DESTINATION|MEMO`

### Version `2`
### Version `2` - Multi-Send (Full)
- `VERSION|TICK|AMOUNT|DESTINATION|TICK|AMOUNT|DESTINATION|MEMO`

### Version `3`
### Version `3` - Multi-Send (Full) with Multiple Memos
- `VERSION|TICK|AMOUNT|DESTINATION|MEMO|TICK|AMOUNT|DESTINATION|MEMO`


Expand Down
11 changes: 11 additions & 0 deletions indexer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
CHANGELOG
---
0.12.0
- Added support for `--reparse`
- Optimized ledger hashing
- `ADDRESS` support
- Renamed `LOCK_MINT` param to `LOCK_MAX_MINT`
- Renamed `LOCK_SUPPLY` param to `LOCK_MAX_SUPPLY`
- Added `LOCK_MINT` param to lock against `MINT` command
- Added `LOCK_MINT_SUPPLY` param
- `BATCH` support
- `AIRDROP` support

0.11.1
- Added support for `MINT_START_BLOCK`
- Added support for `MINT_STOP_BLOCK`
Expand Down
72 changes: 72 additions & 0 deletions indexer/includes/actions/address.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*********************************************************************
* address.php - ADDRESS command
*
* PARAMS:
* - VERSION - Broadcast Format Version
* - FEE_PREFERENCE - Set preference for how `FEE` is used
* - REQUIRE_MEMO - Require a `MEMO` on any received `SEND`
*
* FORMATS:
* - 0 = Full
*
********************************************************************/
function btnsAddress($params=null, $data=null, $error=null){
global $mysqli, $reparse;

// Define list of known FORMATS
$formats = array(
0 => 'VERSION|FEE_PREFERENCE|REQUIRE_MEMO'
);

/*****************************************************************
* DEBUGGING - Force params
****************************************************************/
// $str = "0|1|1";
// $params = explode('|',$str);

// Validate that broadcast format is known
$format = getFormatVersion($params[0]);
if(!$error && ($format===NULL || !in_array($format,array_keys($formats))))
$error = 'invalid: VERSION (unknown)';

// Parse PARAMS using given VERSION format and update BTNS transaction data object
if(!$error)
$data = setActionParams($data, $params, $formats[$format]);

/*****************************************************************
* FORMAT Validations
****************************************************************/

// Verify FEE_PREFERENCE is numeric
if(!$error && isset($data->FEE_PREFERENCE) && !is_numeric($data->FEE_PREFERENCE))
$error = "invalid: FEE_PREFERENCE (format)";

// Verify REQUIRE_MEMO is numeric
if(!$error && isset($data->REQUIRE_MEMO) && !is_numeric($data->REQUIRE_MEMO))
$error = "invalid: REQUIRE_MEMO (format)";

/*****************************************************************
* General Validations
****************************************************************/

// Verify FEE_PREFERENCE value is valid
if(!$error && isset($data->FEE_PREFERENCE) && !in_array($data->FEE_PREFERENCE,array(0,1,2)))
$error = 'invalid: FEE_PREFERENCE';

// Verify REQUIRE_MEMO value is valid
if(!$error && isset($data->REQUIRE_MEMO) && !in_array($data->REQUIRE_MEMO,array(0,1)))
$error = 'invalid: REQUIRE_MEMO';

// Determine final status
$data->STATUS = $status = ($error) ? $error : 'valid';

// Print status message
print "\n\t ADDRESS : {$data->SOURCE} : {$data->STATUS}";

// Create record in addresses table
createAddressOption($data);

}

?>
Loading

0 comments on commit b2903f5

Please sign in to comment.