Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-chain-common
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap-chain-common
Commits
646b7138
Commit
646b7138
authored
4 years ago
by
Dmitriy A. Gerasimov
Browse files
Options
Downloads
Patches
Plain Diff
[+] New datum token type
[+] New datum ca
parent
1ee95bad
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/dap_chain_datum.h
+7
-4
7 additions, 4 deletions
include/dap_chain_datum.h
include/dap_chain_datum_token.h
+125
-17
125 additions, 17 deletions
include/dap_chain_datum_token.h
src/dap_chain_datum.c
+2
-1
2 additions, 1 deletion
src/dap_chain_datum.c
with
134 additions
and
22 deletions
include/dap_chain_datum.h
+
7
−
4
View file @
646b7138
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
include/dap_chain_datum_token.h
+
125
−
17
View file @
646b7138
...
...
@@ -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
[];
// Sig
ns if exists
byte_t
data
[];
// Signs or types-size-data sectio
ns 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
[];
This diff is collapsed.
Click to expand it.
src/dap_chain_datum.c
+
2
−
1
View file @
646b7138
...
...
@@ -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"
,
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment