Skip to content

Commit

Permalink
v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ansigroup committed Jul 29, 2020
1 parent 92275d8 commit 7d1bc8f
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 42 deletions.
29 changes: 28 additions & 1 deletion README.md
@@ -1,5 +1,5 @@
# SimpleAssets
*document version 14 July 2020*
*document version 29 July 2020*

## Scope:
1. [Introduction](#introduction)
Expand Down Expand Up @@ -126,6 +126,7 @@ https://github.com/CryptoLions/SimpleAssets/blob/master/include/SimpleAssets.hpp
```bash
authorreg ( name author, string dappinfo, string fieldtypes, string priorityimg )
authorupdate ( name author, string dappinfo, string fieldtypes, string priorityimg )
setarampayer ( name author, name category, bool usearam )


# -- For Non-Fungible Tokens (NFTs)---
Expand Down Expand Up @@ -336,6 +337,25 @@ moredata{
}
```

## Author RAM Payer
```
sarampayer{
uint64_t id;
name author;
name category;
bool usearam;
uint64_t from_id;
auto primary_key() const {
return id;
}
uint64_t by_author() const {
return author.value;
}
};
```

# EXAMPLES: how to use Simple Assets in smart contracts

## Creating Asset and transfer to owner account ownerowner22:
Expand Down Expand Up @@ -641,6 +661,13 @@ to be the main image.
-----------------
# Change Logs

## Change Log v1.6.0
- Added author ram payer option
- Added actions setarampayer, delarampayer
- detach and detachf for author only
- Memo increased to 512
- Code improvement

## Change Log v1.5.2
- Re-enabled event notifications for the following actions:
saeburn, saeclaim, saetransfer, saechauthor, saecreate.
Expand Down
73 changes: 72 additions & 1 deletion build/SimpleAssets/SimpleAssets.abi
Expand Up @@ -515,6 +515,16 @@
}
]
},
{
"name": "delarampayer",
"base": "",
"fields": [
{
"name": "id",
"type": "uint64"
}
]
},
{
"name": "delegate",
"base": "",
Expand Down Expand Up @@ -917,6 +927,32 @@
}
]
},
{
"name": "sarampayer",
"base": "",
"fields": [
{
"name": "id",
"type": "uint64"
},
{
"name": "author",
"type": "name"
},
{
"name": "category",
"type": "name"
},
{
"name": "usearam",
"type": "bool"
},
{
"name": "from_id",
"type": "uint64"
}
]
},
{
"name": "sasset",
"base": "",
Expand Down Expand Up @@ -1011,6 +1047,24 @@
}
]
},
{
"name": "setarampayer",
"base": "",
"fields": [
{
"name": "author",
"type": "name"
},
{
"name": "category",
"type": "name"
},
{
"name": "usearam",
"type": "bool"
}
]
},
{
"name": "smoredata",
"base": "",
Expand Down Expand Up @@ -1393,6 +1447,11 @@
"type": "createnttlog",
"ricardian_contract": "---\nspec_version: 0.0.2\ntitle: createlog (internal)\nsummary: createlog (internal) \nicon: https://cryptolions.io/assets/images/sa-icons-256/claimf.png#80086207646470fa9cbaf4638ba0dedec96ea0e84d5059b567adc9e4b8543c30\n---"
},
{
"name": "delarampayer",
"type": "delarampayer",
"ricardian_contract": "---\nspec_version: 0.0.2\ntitle: Action for deleting a ram payer record;\nsummary: Action for deleting a ram payer record;\nicon: https://cryptolions.io/assets/images/sa-icons-256/claim.png#8c3fdf140ea14a3cb9762a0f6ec0f0d73f8c2eeeec3ea2f109f394a9f35f472d\n---\n\nInput parameters:\n`id` - is id of a ram payer record;\n\nTERM\nThis Contract expires at the conclusion of code execution.\nby CryptoLions [ https://cryptolions.io ]"
},
{
"name": "delegate",
"type": "delegate",
Expand Down Expand Up @@ -1466,7 +1525,7 @@
{
"name": "saeclaim",
"type": "saeclaim",
"ricardian_contract": "---\nspec_version: 0.0.2\ntitle: Internal action used for creating log\nsummary: Internal action used for creating log\nicon: https://cryptolions.io/assets/images/sa-icons-256/claim.png#8c3fdf140ea14a3cb9762a0f6ec0f0d73f8c2eeeec3ea2f109f394a9f35f472d\n---\n\nInput parameters:\n`author` - asset's author, who will able to updated asset's mdata;\n`claimer` - account claiming the asset\n`assetids` - array of assetid's to claim\n\nTERM\nThis Contract expires at the conclusion of code execution.\nby CryptoLions [ https://cryptolions.io ]"
"ricardian_contract": "---\nspec_version: 0.0.2\ntitle: Internal action used for creating log\nsummary: Internal action used for creating log\nicon: https://cryptolions.io/assets/images/sa-icons-256/claim.png#8c3fdf140ea14a3cb9762a0f6ec0f0d73f8c2eeeec3ea2f109f394a9f35f472d\n---\n\nInput parameters:\n`author` - asset's author, who will able to updated asset's mdata;\n`claimer` - account claiming the asset;\n`assetids` - array of assetid's to claim;\n\nTERM\nThis Contract expires at the conclusion of code execution.\nby CryptoLions [ https://cryptolions.io ]"
},
{
"name": "saecreate",
Expand All @@ -1478,6 +1537,11 @@
"type": "saetransfer",
"ricardian_contract": "---\nspec_version: 0.0.2\ntitle: Internal action used for creating log\nsummary: Internal action used for creating log\nicon: https://cryptolions.io/assets/images/sa-icons-256/transfer.png#23227a4901414db5cd0973d1cc5df13f9b82375b21c6315fd3402cb4acd50cbf\n---\n\nThis action is called during transfer in deferred transaction \n\nInput parameters:\n`author` - asset's author;\n`from` - account who sends the asset;\n`to` - account of receiver;\n`assetids` - array of assetid's to transfer;\n`memo` - transfers comment;\n\nTERM\nThis Contract expires at the conclusion of code execution.\nby CryptoLions [ https://cryptolions.io ]"
},
{
"name": "setarampayer",
"type": "setarampayer",
"ricardian_contract": "---\nspec_version: 0.0.2\ntitle: Action for setting a ram payer for author and category.\nsummary: Action for setting a ram payer for author and category.\nicon: https://cryptolions.io/assets/images/sa-icons-256/claim.png#8c3fdf140ea14a3cb9762a0f6ec0f0d73f8c2eeeec3ea2f109f394a9f35f472d\n---\n\nInput parameters:\n`author` - asset's author, who will able to updated asset's mdata;\n`category` - assets category;\n`usearam` - flag for on or off author is a ram payer functionaity;\n\nTERM\nThis Contract expires at the conclusion of code execution.\nby CryptoLions [ https://cryptolions.io ]"
},
{
"name": "transfer",
"type": "transfer",
Expand Down Expand Up @@ -1522,6 +1586,13 @@
"key_names": [],
"key_types": []
},
{
"name": "arampayers",
"type": "sarampayer",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "authors",
"type": "sauthor",
Expand Down
Binary file modified build/SimpleAssets/SimpleAssets.wasm
Binary file not shown.
69 changes: 60 additions & 9 deletions include/SimpleAssets.hpp
@@ -1,7 +1,7 @@
/*
* @file
* @author (C) 2020 by CryptoLions [ https://CryptoLions.io ]
* @version 1.5.2
* @version 1.6.0
*
* @section LICENSE
*
Expand Down Expand Up @@ -809,6 +809,31 @@ CONTRACT SimpleAssets : public contract{
ACTION saeclaim( name author, name claimer, map< uint64_t, name >& assetids );
using saeclaim_action = action_wrapper< "saeclaim"_n, &SimpleAssets::saeclaim >;

/*
* Action for setting a ram payer for author and category.
*
* This action will add new record (only if regre is no same records for author and category)
* and set from_id to last avalable assetsid. It will works only for new created assets.
*
* @param author is account claiming the asset.
* @param category is asset category.
* @param usearam is flag for using ram
* @return no return value.
*/
ACTION setarampayer( name author, name category, bool usearam );
using setarampayer_action = action_wrapper< "setarampayer"_n, &SimpleAssets::setarampayer >;

/*
* Action for deleting a ram payer for author and category.
*
* This action will delete record for arampayer table
*
* @param id is id of arampayer record
* @return no return value.
*/
ACTION delarampayer( uint64_t id );
using delarampayer_action = action_wrapper< "delarampayer"_n, &SimpleAssets::delarampayer >;

public:
enum id_type { asset_id = 0, deferred_id = 1, offer_id = 2, md_id = 3 };

Expand Down Expand Up @@ -863,6 +888,9 @@ CONTRACT SimpleAssets : public contract{
}

private:
const uint16_t MAX_MEMO_SIZE = 512;
const uint64_t IMPOSSIBLE_ID = 1;

/*
* Get new asset id.
*
Expand All @@ -887,7 +915,9 @@ CONTRACT SimpleAssets : public contract{
void sub_balancef( name owner, name author, asset value );
void add_balancef( name owner, name author, asset value, name ram_payer );
void check_empty_vector( vector< uint64_t >& vector_ids, string vector_name = "assetids" );
void check_memo_size( const string & memo );
std::string timeToWait( uint64_t time_in_seconds );
name get_payer( name author, name category, uint64_t id );

template<typename... Args>
void sendEvent( name author, name rampayer, name seaction, const tuple<Args...> &tup );
Expand Down Expand Up @@ -1120,6 +1150,28 @@ CONTRACT SimpleAssets : public contract{
eosio::indexed_by< "author"_n, eosio::const_mem_fun< smoredata, uint64_t, &smoredata::by_author > >
> moredata;

/*
* Ram payer table
*/
TABLE sarampayer{
uint64_t id;
name author;
name category;
bool usearam;
uint64_t from_id;

auto primary_key() const {
return id;
}

uint64_t by_author() const {
return author.value;
}
};
typedef eosio::multi_index< "arampayers"_n, sarampayer,
eosio::indexed_by< "author"_n, eosio::const_mem_fun< sarampayer, uint64_t, &sarampayer::by_author > >
> arampayers;

/*
* global singelton table, used for assetid building. Scope: self
*/
Expand All @@ -1132,7 +1184,6 @@ CONTRACT SimpleAssets : public contract{

EOSLIB_SERIALIZE( global, ( lnftid )( defid )( mdid )( spare2 ) )
};

typedef eosio::singleton< "global"_n, global > conf; /// singleton

/*
Expand All @@ -1149,12 +1200,12 @@ CONTRACT SimpleAssets : public contract{
typedef singleton< "tokenconfigs"_n, tokenconfigs > Configs;

private:
moredata moredatat = { _self, _self.value };
offers offert = { _self, _self.value };
offerfs offerft = { _self, _self.value };
delegates delegatet = { _self, _self.value };
authors authort = { _self, _self.value };
nttoffers nttoffert = { _self, _self.value };

moredata moredatat = { _self, _self.value };
offers offert = { _self, _self.value };
offerfs offerft = { _self, _self.value };
delegates delegatet = { _self, _self.value };
authors authort = { _self, _self.value };
nttoffers nttoffert = { _self, _self.value };
arampayers arampayert = { _self, _self.value };
global _cstate; /// global state
};
38 changes: 36 additions & 2 deletions ricardian/SimpleAssets.contracts.md
Expand Up @@ -855,8 +855,42 @@ icon: https://cryptolions.io/assets/images/sa-icons-256/claim.png#8c3fdf140ea14a

Input parameters:
`author` - asset's author, who will able to updated asset's mdata;
`claimer` - account claiming the asset
`assetids` - array of assetid's to claim
`claimer` - account claiming the asset;
`assetids` - array of assetid's to claim;

TERM
This Contract expires at the conclusion of code execution.
by CryptoLions [ https://cryptolions.io ]

<h1 class="contract"> setarampayer </h1>

---
spec_version: 0.0.2
title: Action for setting a ram payer for author and category.
summary: Action for setting a ram payer for author and category.
icon: https://cryptolions.io/assets/images/sa-icons-256/claim.png#8c3fdf140ea14a3cb9762a0f6ec0f0d73f8c2eeeec3ea2f109f394a9f35f472d
---

Input parameters:
`author` - asset's author, who will able to updated asset's mdata;
`category` - assets category;
`usearam` - flag for on or off author is a ram payer functionaity;

TERM
This Contract expires at the conclusion of code execution.
by CryptoLions [ https://cryptolions.io ]

<h1 class="contract"> delarampayer </h1>

---
spec_version: 0.0.2
title: Action for deleting a ram payer record;
summary: Action for deleting a ram payer record;
icon: https://cryptolions.io/assets/images/sa-icons-256/claim.png#8c3fdf140ea14a3cb9762a0f6ec0f0d73f8c2eeeec3ea2f109f394a9f35f472d
---

Input parameters:
`id` - is id of a ram payer record;

TERM
This Contract expires at the conclusion of code execution.
Expand Down
38 changes: 36 additions & 2 deletions ricardian/SimpleAssets.contracts.md.in
Expand Up @@ -855,8 +855,42 @@ icon: @ICON_BASE_URL@/@CLAIM_ICON_URI@

Input parameters:
`author` - asset's author, who will able to updated asset's mdata;
`claimer` - account claiming the asset
`assetids` - array of assetid's to claim
`claimer` - account claiming the asset;
`assetids` - array of assetid's to claim;

TERM
This Contract expires at the conclusion of code execution.
by CryptoLions [ https://cryptolions.io ]

<h1 class="contract"> setarampayer </h1>

---
spec_version: 0.0.2
title: Action for setting a ram payer for author and category.
summary: Action for setting a ram payer for author and category.
icon: @ICON_BASE_URL@/@CLAIM_ICON_URI@
---

Input parameters:
`author` - asset's author, who will able to updated asset's mdata;
`category` - assets category;
`usearam` - flag for on or off author is a ram payer functionaity;

TERM
This Contract expires at the conclusion of code execution.
by CryptoLions [ https://cryptolions.io ]

<h1 class="contract"> delarampayer </h1>

---
spec_version: 0.0.2
title: Action for deleting a ram payer record;
summary: Action for deleting a ram payer record;
icon: @ICON_BASE_URL@/@CLAIM_ICON_URI@
---

Input parameters:
`id` - is id of a ram payer record;

TERM
This Contract expires at the conclusion of code execution.
Expand Down

0 comments on commit 7d1bc8f

Please sign in to comment.