diff --git a/README.md b/README.md index 4281165..47d7198 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ Git: https://github.com/CryptoLions/SimpleAssets Presentation: https://medium.com/@cryptolions/introducing-simple-assets-b4e17caafaa4 +Events Receiver Example for authors: https://github.com/CryptoLions/SimpleAssets-EventReceiverExample + +--------------------------- + There are two ways to use Simple Assets: 1) As an "ownership authority". When deployed on an EOSIO chain, Simple Assets will be a separate contract which other Dapps can call to manage their digital assets. This serves as an additional guarantee to users of the Dapp that the ownership of assets is managed by a reputable outside authority, and that once created, the Dapp can only manage the asset's mdata. All the ownership-related functionality exists outside the game. @@ -17,6 +21,16 @@ There are two ways to use Simple Assets: 2) Dapps can Deploy their own copy of Simple Assets and make modifications to have greater control of functionality. We consider this an example of a dapp being its own "ownership authority." Before deploying, Simple Assets should be modified to prevent anyone from making assets. --------------------------- +# Change Log v0.3.1 +- Internal action for NFT `createlog` added. Used by create action to log assetid so that third party explorers can easily get new asset ids and other information. +- New singelton table `tokenconfigs` added. It helps external contracts parse actions and tables correctly (Usefull for decentralized exchanges, marketplaces and other contracts that use multiple tokens). + Marketplaces, exchanges and other reliant contracts will be able to view this info using the following code. + ``` + Configs configs("simpl1assets"_n, "simpl1assets"_n.value); + configs.get("simpl1assets"_n); + ``` +- added action `updatever`. It updates version of this SimpleAstes deployment for 3rd party wallets, marketplaces, etc; +- New examples for Event notifications: https://github.com/CryptoLions/SimpleAssets-EventReceiverExample # Change Log v0.3.0 - Added event notifications using deferred transaction. Assets author will receive notification on assets create, transfer, claim or burn. To receive it please add next action to your author contract: @@ -26,7 +40,7 @@ There are two ways to use Simple Assets: ACTION saeclaim ( name account, std::vector& assetids ); ACTION saeburn ( name account, std::vector& assetids, std::string memo ); ``` - - `untildate` parametr changed to `period` (in seconds) for actions `delegate` and table `sdelegates` + - `untildate` parameter changed to `period` (in seconds) for actions `delegate` and table `sdelegates` # Change Log v0.2.0 diff --git a/build/SimpleAssets/SimpleAssets.abi b/build/SimpleAssets/SimpleAssets.abi index f943d9e..3f9c779 100644 --- a/build/SimpleAssets/SimpleAssets.abi +++ b/build/SimpleAssets/SimpleAssets.abi @@ -1,5 +1,5 @@ { - "____comment": "This file was generated with eosio-abigen. DO NOT EDIT Tue Mar 26 14:51:41 2019", + "____comment": "This file was generated with eosio-abigen. DO NOT EDIT Wed Mar 27 13:50:53 2019", "version": "eosio::abi/1.1", "structs": [ { @@ -168,6 +168,36 @@ } ] }, + { + "name": "createlog", + "base": "", + "fields": [ + { + "name": "author", + "type": "name" + }, + { + "name": "category", + "type": "name" + }, + { + "name": "owner", + "type": "name" + }, + { + "name": "idata", + "type": "string" + }, + { + "name": "mdata", + "type": "string" + }, + { + "name": "assetid", + "type": "uint64" + } + ] + }, { "name": "currency_stats", "base": "", @@ -414,6 +444,20 @@ } ] }, + { + "name": "tokenconfigs", + "base": "", + "fields": [ + { + "name": "standard", + "type": "name" + }, + { + "name": "version", + "type": "string" + } + ] + }, { "name": "transfer", "base": "", @@ -501,6 +545,16 @@ "type": "string" } ] + }, + { + "name": "updatever", + "base": "", + "fields": [ + { + "name": "version", + "type": "string" + } + ] } ], "types": [], @@ -545,6 +599,11 @@ "type": "createf", "ricardian_contract": "## ACTION NAME: createf\n\n ### INTENT\n\t\tCreates fungible token with specified maximum supply; You can not change anything after creation.\n\n ### Input parameters:\n\t\t`author` - fungible token author;\n\t\t`maximum_supply` - maximum token supply, example \"10000000.0000 GOLD\", \"10000000 SEED\", \"100000000.00 WOOD\". Precision is also important here;\n\t\t`authorctrl` - if true(1) allow token author (and not just owner) to burnf and transferf. Cannot be changed after creation!\n\t\t\n ### TERM\n This Contract expires at the conclusion of code execution.\n\n by CryptoLions [ https://cryptolions.io ]" }, + { + "name": "createlog", + "type": "createlog", + "ricardian_contract": "" + }, { "name": "delegate", "type": "delegate", @@ -589,6 +648,11 @@ "name": "update", "type": "update", "ricardian_contract": "## ACTION NAME: update\n\n ### INTENT\n\t\tUpdate assets mutable data (mdata) field. Action is available only for authors.\n\n ### Input parameters:\n\t\t`author` - authors account;\n\t\t`owner` - current assets owner;\n\t\t`assetid` - assetid to update;\n\t\t`mdata` - stringified json with mutable assets data. All mdata will be replaced;\n\n ### TERM\n This Contract expires at the conclusion of code execution.\n\n by CryptoLions [ https://cryptolions.io ]" + }, + { + "name": "updatever", + "type": "updatever", + "ricardian_contract": "" } ], "tables": [ @@ -640,6 +704,13 @@ "index_type": "i64", "key_names": [], "key_types": [] + }, + { + "name": "tokenconfigs", + "type": "tokenconfigs", + "index_type": "i64", + "key_names": [], + "key_types": [] } ], "ricardian_clauses": [ diff --git a/build/SimpleAssets/SimpleAssets.wasm b/build/SimpleAssets/SimpleAssets.wasm index 7eb670a..85fde4e 100755 Binary files a/build/SimpleAssets/SimpleAssets.wasm and b/build/SimpleAssets/SimpleAssets.wasm differ diff --git a/include/SimpleAssets.hpp b/include/SimpleAssets.hpp index f9f1197..5121ede 100644 --- a/include/SimpleAssets.hpp +++ b/include/SimpleAssets.hpp @@ -7,6 +7,8 @@ * WebSite: https://simpleassets.io * GitHub: https://github.com/CryptoLions/SimpleAssets * Presentation: https://medium.com/@cryptolions/introducing-simple-assets-b4e17caafaa4 + * + * Event Receiver: https://github.com/CryptoLions/SimpleAssets-EventReceiverExample * */ @@ -25,6 +27,13 @@ CONTRACT SimpleAssets : public contract { public: using contract::contract; + //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + /* + * Update version of this SimpleAstes deployment for 3rd party wallets, marketplaces, etc + */ + ACTION updatever( string version); + using updatever_action = action_wrapper<"updatever"_n, &SimpleAssets::updatever>; + // =============================================================================================== // ============= Non-Fungible Token Actions ====================================================== @@ -80,7 +89,14 @@ CONTRACT SimpleAssets : public contract { ACTION create( name author, name category, name owner, string idata, string mdata, bool requireclaim); using create_action = action_wrapper<"create"_n, &SimpleAssets::create>; - + //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + /* + * Empty action. Used by create action to log assetid so that third party explorers can easily get new asset ids and other information. + * + */ + ACTION createlog( name author, name category, name owner, string idata, string mdata, uint64_t assetid); + using createlog_action = action_wrapper<"createlog"_n, &SimpleAssets::createlog>; + //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- /* * Claim the specified asset (assuming it was offered to claimer by the asset owner). @@ -307,6 +323,7 @@ CONTRACT SimpleAssets : public contract { } + //============================================================================================================================= //============================================================================================================================= private: @@ -488,6 +505,24 @@ CONTRACT SimpleAssets : public contract { }; typedef eosio::multi_index< "stat"_n, currency_stats > stats; + + + //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + /* + * Helps external contracts parse actions and tables correctly (Usefull for decentralized exchanges, + * marketplaces and other contracts that use multiple tokens) + * + * Marketplaces, exchanges and other reliant contracts will be able to view this info using the following code. + * Configs configs("simpl1assets"_n, "simpl1assets"_n.value); + * configs.get("simpl1assets"_n); + + */ + TABLE tokenconfigs { + name standard; + std::string version; + }; + + typedef singleton<"tokenconfigs"_n, tokenconfigs> Configs; }; diff --git a/src/SimpleAssets.cpp b/src/SimpleAssets.cpp index cb76892..64fe760 100644 --- a/src/SimpleAssets.cpp +++ b/src/SimpleAssets.cpp @@ -7,12 +7,21 @@ * WebSite: https://simpleassets.io * GitHub: https://github.com/CryptoLions/SimpleAssets * Presentation: https://medium.com/@cryptolions/introducing-simple-assets-b4e17caafaa4 + * + * Event Receiver: https://github.com/CryptoLions/SimpleAssets-EventReceiverExample * */ - + #include +ACTION SimpleAssets::updatever( string version ) { + require_auth(get_self()); + + Configs configs(_self, _self.value); + configs.set(tokenconfigs{"simpleassets"_n, version}, _self); + +} ACTION SimpleAssets::regauthor( name author, string data, string stemplate) { @@ -94,6 +103,12 @@ ACTION SimpleAssets::create( name author, name category, name owner, string idat //Events sendEvent(author, author, "saecreate"_n, std::make_tuple(owner, newID)); + SEND_INLINE_ACTION( *this, createlog, { {_self, "active"_n} }, { author, category, owner, idata, mdata, newID} ); +} + + +ACTION SimpleAssets::createlog( name author, name category, name owner, string idata, string mdata, uint64_t assetid) { + require_auth(get_self()); } @@ -664,12 +679,13 @@ void SimpleAssets::sendEvent(name author, name rampayer, name seaction, const st //------------------------------------------------------------------------------------------------------------ -EOSIO_DISPATCH( SimpleAssets, (create)(transfer)(burn)(update) +EOSIO_DISPATCH( SimpleAssets, (create)(createlog)(transfer)(burn)(update) (offer)(canceloffer)(claim) (regauthor)(authorupdate) (delegate)(undelegate) (createf)(issuef)(transferf)(burnf) - (openf)(closef) ) + (openf)(closef) + (updatever)) //============================================================================================================ //=======================================- SimpleAssets.io -==================================================