Skip to content

Commit

Permalink
Merge pull request #253 from ultraio/feature/BLOCK-2560-update-onchai…
Browse files Browse the repository at this point in the history
…n-values-types

[BLOCK-2560] update on chain values types
  • Loading branch information
Adam-Ultra authored Oct 28, 2024
2 parents 963286e + 8b1fa32 commit 47f25c1
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,19 @@ The properties of this type are provided below:

`key_value_store` will be an array with first element is type of the value and second is the value. Here is the support list and example:

| Value Type | Key Def Type string | Example |
| ---------- | ------------------- | -------------------------- |
| int8 | int8 | ["int8", 0] |
| int16 | int16 | ["int16", 0] |
| int32 | int32 | ["int32", 0] |
| int64 | int64 | ["int64", 0] |
| uint8 | uint8 | ["uint8", 0] |
| uint16 | uint16 | ["uint16", 0] |
| uint32 | uint32 | ["uint32", 0] |
| uint64 | uint64 | ["uint64", 0] |
| float | float | ["float", 0.1] |
| double | double | ["double", 0.1] |
| string | string | ["string", "a"] |
| INT8_VEC | int8[] | ["INT8_VEC", [0,1,2]] |
| INT16_VEC | int16[] | ["INT16_VEC", [0,1,2]] |
| INT32_VEC | int32[] | ["INT32_VEC", [0,1,2]] |
| INT64_VEC | int64[] | ["INT64_VEC", [0,1,2]] |
| UINT8_VEC | uint8[] | ["UINT8_VEC", [0,1,2]] |
| UINT16_VEC | uint16[] | ["UINT16_VEC", [0,1,2]] |
| UINT32_VEC | uint32[] | ["UINT32_VEC", [0,1,2]] |
| UINT64_VEC | uint64[] | ["UINT64_VEC", [0,1,2]] |
| FLOAT_VEC | float[] | ["FLOAT_VEC", [0.1,1.2]] |
| DOUBLE_VEC | double[] | ["DOUBLE_VEC", [0.1,1.2]] |
| STRING_VEC | string[] | ["STRING_VEC", ["a", "b"]] |
| Value Type | Key Def Type string | Example |
| ---------- | ------------------- | ---------------- |
| int8 | int8 | ["int8", 0] |
| int16 | int16 | ["int16", 0] |
| int32 | int32 | ["int32", 0] |
| int64 | int64 | ["int64", 0] |
| uint8 | uint8 | ["uint8", 0] |
| uint16 | uint16 | ["uint16", 0] |
| uint32 | uint32 | ["uint32", 0] |
| uint64 | uint64 | ["uint64", 0] |
| float | float32 | ["float32", 0.1] |
| double | float64 | ["float64", 0.1] |
| string | string | ["string", "a"] |

### `edit_rights` bitmask breakdown

Expand All @@ -85,7 +74,7 @@ The properties of this type are provided below:
## CLI - cleos

```bash
cleos push action eosio.nft.ft addkeys.a '{ "factory_id": "10", "key_defs": [ { "name": "id", "type": "uint8[]", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "UINT8_VEC", [0, 1] ] } ], "memo": "new key pairs" }' -p alice@active
cleos push action eosio.nft.ft addkeys.a '{ "factory_id": 10, "key_defs": [ { "name": "id1", "type": "int8", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "int8", -8 ] }, { "name": "id2", "type": "int16", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "int16", 16 ] }, { "name": "id3", "type": "int32", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "int32", -32 ] }, { "name": "id4", "type": "int64", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "int64", 64 ] }, { "name": "id5", "type": "uint8", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "uint8", 8 ] }, { "name": "id6", "type": "uint16", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "uint16", 16 ] }, { "name": "id7", "type": "uint32", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "uint32", 32 ] }, { "name": "id8", "type": "uint64", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "uint64", 64 ] }, { "name": "id9", "type": "float32", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "float32", -1.32 ] }, { "name": "id10", "type": "float64", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "float64", 1.64 ] }, { "name": "id11", "type": "string", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "string", "abc" ] } ], "memo": "add new key pairs" }' -p alice@active
```

## JavaScript - eosjs
Expand All @@ -99,18 +88,85 @@ await transact(
authorization: [{ actor: 'alice', permission: 'active' }],
data: {
factory_id: 10,
key_defs: [{
name: "id",
type: "uint8[]",
edit_rights: 8,
editors: [
"bob"
],
default_value: [
"UINT8_VEC",
[0, 1]
]
}],
key_defs: [
{
name: "id1",
type: "int8",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "int8", -8 ]
},
{
name: "id2",
type: "int16",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "int16", 16 ]
},
{
name: "id3",
type: "int32",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "int32", -32 ]
},
{
name: "id4",
type: "int64",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "int64", 64 ]
},
{
name: "id5",
type: "uint8",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "uint8", 8 ]
},
{
name: "id6",
type: "uint16",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "uint16", 16 ]
},
{
name: "id7",
type: "uint32",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "uint32", 32 ]
},
{
name: "id8",
type: "uint64",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "uint64", 64 ]
},
{
name: "id9",
type: "float32",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "float32", -1.32 ]
},
{
name: "id10",
type: "float64",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "float64", 1.64 ]
},
{
name: "id11",
type: "string",
edit_rights: 8,
editors: [ "bob" ],
default_value: [ "string", "abc" ]
}
],
"memo": "add new key pairs"
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,19 @@ Update supported value type for on chain data

Here is the default table of supported value type and its limit.

| C++ Type | Type string | Limit by element |
| ---------- | ----------- | ---------------- |
| int8 | int8 | 1 |
| int16 | int16 | 1 |
| int32 | int32 | 1 |
| int64 | int64 | 1 |
| uint8 | uint8 | 1 |
| uint16 | uint16 | 1 |
| uint32 | uint32 | 1 |
| uint64 | uint64 | 1 |
| float | float | 1 |
| double | double | 1 |
| string | string | 128 |
| INT8_VEC | int8[] | 128 |
| INT16_VEC | int16[] | 64 |
| INT32_VEC | int32[] | 32 |
| INT64_VEC | int64[] | 16 |
| UINT8_VEC | uint8[] | 128 |
| UINT16_VEC | uint16[] | 64 |
| UINT32_VEC | uint32[] | 32 |
| UINT64_VEC | uint64[] | 16 |
| FLOAT_VEC | float[] | 32 |
| DOUBLE_VEC | double[] | 16 |
| STRING_VEC | string[] | 256 |
| C++ Type | Type string | Limit by element |
| -------- | ----------- | ---------------- |
| int8 | int8 | 1 |
| int16 | int16 | 1 |
| int32 | int32 | 1 |
| int64 | int64 | 1 |
| uint8 | uint8 | 1 |
| uint16 | uint16 | 1 |
| uint32 | uint32 | 1 |
| uint64 | uint64 | 1 |
| float | float32 | 1 |
| double | float64 | 1 |
| string | string | 128 |

**Note**: In case of `string` and `string[]`, it will count the total characters instead.

Expand All @@ -61,7 +50,7 @@ The properties of this type are provided below:
## CLI - cleos

```bash
cleos push action eosio.nft.ft setktypes '{ "key_types": [ {"key_type": "int8", "element_number_limit": 1}, {"key_type": "int16", "element_number_limit": 1}, {"key_type": "int32", "element_number_limit": 1}, {"key_type": "int64", "element_number_limit": 1}, {"key_type": "uint8", "element_number_limit": 1}, {"key_type": "uint16", "element_number_limit": 1}, {"key_type": "uint32", "element_number_limit": 1}, {"key_type": "uint64", "element_number_limit": 1}, {"key_type": "float", "element_number_limit": 1}, {"key_type": "double", "element_number_limit": 1}, {"key_type": "string", "element_number_limit": 128}, {"key_type": "int8[]", "element_number_limit": 128}, {"key_type": "int16[]", "element_number_limit": 64}, {"key_type": "int32[]", "element_number_limit": 32}, {"key_type": "int64[]", "element_number_limit": 16}, {"key_type": "uint8[]", "element_number_limit": 128}, {"key_type": "uint16[]", "element_number_limit": 64}, {"key_type": "uint32[]", "element_number_limit": 32}, {"key_type": "uint64[]", "element_number_limit": 16}, {"key_type": "float[]", "element_number_limit": 32}, {"key_type": "double[]", "element_number_limit": 16}, {"key_type": "string[]", "element_number_limit": 256} ] }' -p ultra.nft.ft@active
cleos push action eosio.nft.ft setktypes '{ "key_types": [ {"key_type": "int8", "element_number_limit": 1}, {"key_type": "int16", "element_number_limit": 1}, {"key_type": "int32", "element_number_limit": 1}, {"key_type": "int64", "element_number_limit": 1}, {"key_type": "uint8", "element_number_limit": 1}, {"key_type": "uint16", "element_number_limit": 1}, {"key_type": "uint32", "element_number_limit": 1}, {"key_type": "uint64", "element_number_limit": 1}, {"key_type": "float32", "element_number_limit": 1}, {"key_type": "float64", "element_number_limit": 1}, {"key_type": "string", "element_number_limit": 128} ] }' -p ultra.nft.ft@active
```

## JavaScript - eosjs
Expand All @@ -83,20 +72,9 @@ await transact(
{key_type: "uint16", element_number_limit: 1},
{key_type: "uint32", element_number_limit: 1},
{key_type: "uint64", element_number_limit: 1},
{key_type: "float", element_number_limit: 1},
{key_type: "double", element_number_limit: 1},
{key_type: "string", element_number_limit: 128},
{key_type: "int8[]", element_number_limit: 128},
{key_type: "int16[]", element_number_limit: 64},
{key_type: "int32[]", element_number_limit: 32},
{key_type: "int64[]", element_number_limit: 16},
{key_type: "uint8[]", element_number_limit: 128},
{key_type: "uint16[]", element_number_limit: 64},
{key_type: "uint32[]", element_number_limit: 32},
{key_type: "uint64[]", element_number_limit: 16},
{key_type: "float[]", element_number_limit: 32},
{key_type: "double[]", element_number_limit: 16},
{key_type: "string[]", element_number_limit: 256}
{key_type: "float32", element_number_limit: 1},
{key_type: "float64", element_number_limit: 1},
{key_type: "string", element_number_limit: 128}
]
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,19 @@ The properties of this type are provided below:

`key_value_store` will be an array with first element is type of the value and second is the value. Here is the support list and example:

| Value Type | Key Def Type string | Example |
| ---------- | ------------------- | -------------------------- |
| int8 | int8 | ["int8", 0] |
| int16 | int16 | ["int16", 0] |
| int32 | int32 | ["int32", 0] |
| int64 | int64 | ["int64", 0] |
| uint8 | uint8 | ["uint8", 0] |
| uint16 | uint16 | ["uint16", 0] |
| uint32 | uint32 | ["uint32", 0] |
| uint64 | uint64 | ["uint64", 0] |
| float | float | ["float", 0.1] |
| double | double | ["double", 0.1] |
| string | string | ["string", "a"] |
| INT8_VEC | int8[] | ["INT8_VEC", [0,1,2]] |
| INT16_VEC | int16[] | ["INT16_VEC", [0,1,2]] |
| INT32_VEC | int32[] | ["INT32_VEC", [0,1,2]] |
| INT64_VEC | int64[] | ["INT64_VEC", [0,1,2]] |
| UINT8_VEC | uint8[] | ["UINT8_VEC", [0,1,2]] |
| UINT16_VEC | uint16[] | ["UINT16_VEC", [0,1,2]] |
| UINT32_VEC | uint32[] | ["UINT32_VEC", [0,1,2]] |
| UINT64_VEC | uint64[] | ["UINT64_VEC", [0,1,2]] |
| FLOAT_VEC | float[] | ["FLOAT_VEC", [0.1,1.2]] |
| DOUBLE_VEC | double[] | ["DOUBLE_VEC", [0.1,1.2]] |
| STRING_VEC | string[] | ["STRING_VEC", ["a", "b"]] |
| Value Type | Key Def Type string | Example |
| ---------- | ------------------- | ---------------- |
| int8 | int8 | ["int8", 0] |
| int16 | int16 | ["int16", 0] |
| int32 | int32 | ["int32", 0] |
| int64 | int64 | ["int64", 0] |
| uint8 | uint8 | ["uint8", 0] |
| uint16 | uint16 | ["uint16", 0] |
| uint32 | uint32 | ["uint32", 0] |
| uint64 | uint64 | ["uint64", 0] |
| float | float32 | ["float32", 0.1] |
| double | float64 | ["float64", 0.1] |
| string | string | ["string", "a"] |

## CLI - cleos

Expand Down

0 comments on commit 47f25c1

Please sign in to comment.