Skip to content
Snippets Groups Projects
Commit 646b7138 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[+] New datum token type

[+] New datum ca
parent 1ee95bad
No related branches found
No related tags found
No related merge requests found
......@@ -52,14 +52,17 @@
/// Smart contract: EVM data section
#define DAP_CHAIN_DATUM_EVM_DATA 0x0911
/// Pub key section, with sign and address
#define DAP_CHAIN_DATUM_PKEY 0x0c00
/// CA with public key and self signed metadata
#define DAP_CHAIN_DATUM_CA 0x0c00
/// Token
#define DAP_CHAIN_DATUM_TOKEN_DECL 0xf000
/// Simple token decl
#define DAP_CHAIN_DATUM_TOKEN_DECL 0xf000
#define DAP_CHAIN_DATUM_TOKEN_EMISSION 0xf100
#define DAP_CHAIN_DATUM_CUSTOM 0xffff
extern const char * c_datum_type_str[];
#define DAP_CHAIN_DATUM_ID_SIZE 4
......
......@@ -27,38 +27,139 @@
#include "dap_sign.h"
#define DAP_CHAIN_DATUM_TOKEN_TYPE_AUTH 0x0001
#define DAP_CHAIN_DATUM_TOKEN_TYPE_OPEN 0x0002
// Token declaration
typedef struct dap_chain_datum_token{
uint16_t type;
char ticker[DAP_CHAIN_TICKER_SIZE_MAX];
union {
// Simple private token declaration. Useful for 100% premined emission without any plays with token and owners after that
struct {
uint16_t type;
char ticker[DAP_CHAIN_TICKER_SIZE_MAX];
uint64_t total_supply;
uint64_t total_supply; // Could be zero if unlimited
uint16_t signs_valid; // Emission auth signs
uint16_t signs_total; // Emission auth signs
} DAP_ALIGN_PACKED header_auth;
} DAP_ALIGN_PACKED header_private;
// Private token declarations, with flags, manipulations and updates
struct {
uint16_t flags; // Token declaration flags
size_t tsd_data_size; // Data size section with values in key-length-value list trailing the signs section
} DAP_ALIGN_PACKED header_private_decl;
// Private token update
struct {
uint16_t flags; // Update flag - clear all before, add or etc
size_t klv_data_size; // Data size section with extended values in key-length-value list.
} DAP_ALIGN_PACKED header_private_update;
// Public token declaration
struct {
uint16_t type;
char ticker[DAP_CHAIN_TICKER_SIZE_MAX];
uint128_t total_supply;
uint128_t premine_supply;
dap_chain_addr_t premine_address;
uint32_t flags;
} DAP_ALIGN_PACKED header_open;
} DAP_ALIGN_PACKED header_public;
};
uint8_t signs[]; // Signs if exists
byte_t data[]; // Signs or types-size-data sections if exists
} DAP_ALIGN_PACKED dap_chain_datum_token_t;
// Token declaration type
// Simple private token decl
#define DAP_CHAIN_DATUM_TOKEN_PRIVATE 0x0001
// Extended declaration of privatetoken with in-time control
#define DAP_CHAIN_DATUM_TOKEN_PRIVATE_DECL 0x0002
// Token update
#define DAP_CHAIN_DATUM_TOKEN_PRIVATE_UPDATE 0x0003
// Open token with now ownership
#define DAP_CHAIN_DATUM_TOKEN_PUBLIC 0x0004
// Macros for token flags
/// ------- Global section flags --------
// Blocked all permissions, usefull issue it by default and then allow what you want to allow
#define DAP_CHAIN_DATUM_TOKEN_FLAG_ALL_BLOCKED 0x0001
// Allowed all permissions if not blocked them. Be careful with this mode
#define DAP_CHAIN_DATUM_TOKEN_FLAG_ALL_ALLOWED 0x0002
// All permissions are temprorary frozen
#define DAP_CHAIN_DATUM_TOKEN_FLAG_ALL_FROZEN 0x0003
// Unfrozen permissions
#define DAP_CHAIN_DATUM_TOKEN_FLAG_ALL_UNFROZEN 0x0004
/// ------ Static configured flags
// No token manipulations after declarations at all. Token declares staticly and can't variabed after
#define DAP_CHAIN_DATUM_TOKEN_FLAG_STATIC_ALL 0x0010
// No token manipulations after declarations with flags.
#define DAP_CHAIN_DATUM_TOKEN_FLAG_STATIC_FLAGS 0x0011
// No all permissions lists manipulations after declarations
#define DAP_CHAIN_DATUM_TOKEN_FLAG_STATIC_PERMISSIONS_ALL 0x0012
// No datum type permissions lists manipulations after declarations
#define DAP_CHAIN_DATUM_TOKEN_FLAG_STATIC_PERMISSIONS_DATUM_TYPE 0x0013
// No tx sender permissions lists manipulations after declarations
#define DAP_CHAIN_DATUM_TOKEN_FLAG_STATIC_PERMISSIONS_TX_SENDER 0x0014
// No tx receiver permissions lists manipulations after declarations
#define DAP_CHAIN_DATUM_TOKEN_FLAG_STATIC_PERMISSIONS_TX_RECEIVER 0x0015
// TSD section - Type-Size-Data
typedef struct dap_chain_datum_token_tsd{
uint16_t type; /// Section type
size_t size; /// Data size trailing the section
byte_t data[]; /// Section's data
} DAP_ALIGN_PACKED dap_chain_datum_token_klv_t;
/// -------- General tsd types ----
// Flags set/unsed
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_SET_FLAGS 0x0001
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_UNSET_FLAGS 0x0002
// Total supply limits
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TOTAL_SUPPLY 0x0003
// Set total signs count value to set to be valid
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TOTAL_SIGNS_VALID 0x0004
// Add owner signature's pkey fingerprint
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TOTAL_SIGNS_ADD 0x0006
// Remove owner signature by pkey fingerprint
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TOTAL_SIGNS_REMOVE 0x0007
/// ------- Permissions list flags, grouped by update-remove-clear operations --------
// Allowed datum types list add, remove or clear
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DATUM_TYPE_ALLOWED_ADD 0x0010
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DATUM_TYPE_ALLOWED_REMOVE 0x0011
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DATUM_TYPE_ALLOWED_CLEAR 0x0012
// Blocked datum types list add, remove or clear
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DATUM_TYPE_BLOCKED_ADD 0x0013
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DATUM_TYPE_BLOCKED_REMOVE 0x0014
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_DATUM_TYPE_BLOCKED_CLEAR 0x0015
//Allowed tx receiver addres list add, remove or clear
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_RECEIVER_ALLOWED_ADD 0x0014
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_RECEIVER_ALLOWED_REMOVE 0x0015
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_RECEIVER_ALLOWED_CLEAR 0x0016
//Blocked tx receiver addres list add, remove or clear
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_RECEIVER_BLOCKED_ADD 0x0017
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_RECEIVER_BLOCKED_REMOVE 0x0018
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_RECEIVER_BLOCKED_CLEAR 0x0019
//Allowed tx sender addres list add, remove or clear
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_SENDER_ALLOWED_ADD 0x0020
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_SENDER_ALLOWED_REMOVE 0x0021
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_SENDER_ALLOWED_CLEAR 0x0022
//Blocked tx sender addres list add, remove or clear
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_SENDER_BLOCKED_ADD 0x0023
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_SENDER_BLOCKED_REMOVE 0x0024
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_SENDER_BLOCKED_CLEAR 0x0025
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_UNDEFINED 0x00
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_AUTH 0x01
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_ALGO 0x02
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_ATOM_OWNER 0x03
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_SMART_CONTRACT 0x04
extern const char *c_dap_chain_datum_token_emission_type_str[];
// Token emission
typedef struct dap_chain_datum_token_emission{
......@@ -84,8 +185,15 @@ typedef struct dap_chain_datum_token_emission{
} DAP_ALIGN_PACKED type_algo;
struct {
uint16_t signs_count;
uint8_t signs[];
byte_t signs[];
} DAP_ALIGN_PACKED type_auth;// Signs if exists
} data;
} DAP_ALIGN_PACKED dap_chain_datum_token_emission_t;
// Different emissions type
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_UNDEFINED 0x00
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_AUTH 0x01
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_ALGO 0x02
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_ATOM_OWNER 0x03
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_SMART_CONTRACT 0x04
extern const char *c_dap_chain_datum_token_emission_type_str[];
......@@ -38,7 +38,8 @@ const char * c_datum_type_str[]={
[DAP_CHAIN_DATUM_WASM_DATA]="DATUM_WASM_DATA",
[DAP_CHAIN_DATUM_EVM_CODE]="DATUM_EVM_CODE",
[DAP_CHAIN_DATUM_EVM_DATA]="DATUM_EVM_DATA",
[DAP_CHAIN_DATUM_PKEY]="DATUM_PKEY",
[DAP_CHAIN_DATUM_CA]="DATUM_CA",
[DAP_CHAIN_DATUM_CUSTOM]="DATUM_CUSTOM",
[DAP_CHAIN_DATUM_TOKEN_DECL]="DATUM_TOKEN_DECL",
[DAP_CHAIN_DATUM_TOKEN_EMISSION]="DATUM_TOKEN_EMISSION",
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment