Skip to content
Permalink
Browse files

v0.3.0

  • Loading branch information
ansigroup committed Mar 26, 2019
1 parent 1bdffea commit 9718651fdde2a34d87ef60cb6f74d8893869aa4a
525 LICENSE

Large diffs are not rendered by default.

@@ -18,6 +18,17 @@ There are two ways to use Simple Assets:

---------------------------

# 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:
```
ACTION saecreate ( name owner, uint64_t assetid );
ACTION saetransfer ( name from, name to, std::vector<uint64_t>& assetids, std::string memo );
ACTION saeclaim ( name account, std::vector<uint64_t>& assetids );
ACTION saeburn ( name account, std::vector<uint64_t>& assetids, std::string memo );
```
- `untildate` parametr changed to `period` (in seconds) for actions `delegate` and table `sdelegates`


# Change Log v0.2.0
## Added Fungible Token tables and logic using eosio.token contract but with some changes
- New actions and logic: `createf`, `issuef`, `transferf`, `burnf`, `openf`, `closef`
@@ -71,7 +82,7 @@ https://github.com/CryptoLions/SimpleAssets/blob/master/include/SimpleAssets.hpp
regauthor (name author, data, stemplate)
authorupdate (author, data, stemplate)
delegate (owner, to, [assetid1,..,assetidn], untildate)
delegate (owner, to, [assetid1,..,assetidn], period)
undelegate (owner, from, [assetid1,..,assetidn])
@@ -118,7 +129,7 @@ authors {
name author; // assets author, who will be able to create and update assets;
string data; // author’s data (json) will be used by markets for better display;
string stemplate; // data (json) schema for markets. key: state values, where key is key from;
// recommendations for non-text fields: hide, url, img, webgl, mp3, video;
// recommendations for non-text fields: hide, url, img, webgl, mp3, video;
}
```

@@ -129,7 +140,8 @@ delegates{
name owner; // asset owner;
name delegatedto; // who can claim this asset;
uint64_t cdate; // offer create date;
uint64_t untildate; // The delegating account will not be able to undelegate before this date;
uint64_t period; // Time in seconds that the asset will be lent. Lender cannot undelegate until
// the period expires, however the receiver can transfer back at any time.
}
```

@@ -196,7 +208,7 @@ createAsset.send();
```

## Search asset and get assets info
1. Please add in your hpp file info about assets structure or include SimpleAssets.hpp
1. Please add in your hpp file info about assets structure
```
TABLE sasset {
uint64_t id;
@@ -1,5 +1,5 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT Mon Mar 18 15:18:32 2019",
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT Tue Mar 26 14:51:41 2019",
"version": "eosio::abi/1.1",
"structs": [
{
@@ -211,7 +211,7 @@
"type": "uint64[]"
},
{
"name": "untildate",
"name": "period",
"type": "uint64"
}
]
@@ -387,7 +387,7 @@
"type": "uint64"
},
{
"name": "untildate",
"name": "period",
"type": "uint64"
}
]
@@ -548,7 +548,7 @@
{
"name": "delegate",
"type": "delegate",
"ricardian_contract": "## ACTION NAME: delegate\n\n ### INTENT\n\t\tDelegates asset to {{to}}. This action changes the asset owner by calling the transfer action.\n\t\tIt also adds a record in the delegates table to record the asset as borrowed. This blocks\n\t\tthe asset from all owner actions (transfers, offers, burning by borrower).\n\n ### Input parameters:\n\t\t`owner` - current asset owner account;\n\t\t`to` - borrower account name;\n\t\t`assetids` - array of assetid's to delegate;\n\t\t`untildate` - untildate - The delegating account will not be able to undelegate before this date. \n\t\t However, the receiver of the lent asset can transfer back any time\n Should be timestamp in future or 0;\n\n ### TERM\n This Contract expires at the conclusion of code execution.\n\n by CryptoLions [ https://cryptolions.io ]"
"ricardian_contract": "## ACTION NAME: delegate\n\n ### INTENT\n\t\tDelegates asset to {{to}}. This action changes the asset owner by calling the transfer action.\n\t\tIt also adds a record in the delegates table to record the asset as borrowed. This blocks\n\t\tthe asset from all owner actions (transfers, offers, burning by borrower).\n\n ### Input parameters:\n\t\t`owner` - current asset owner account;\n\t\t`to` - borrower account name;\n\t\t`assetids` - array of assetid's to delegate;\n\t\t`period` - time in seconds that the asset will be lent. Lender cannot undelegate until \n\t\t the period expires, however the receiver can transfer back at any time.\n\n ### TERM\n This Contract expires at the conclusion of code execution.\n\n by CryptoLions [ https://cryptolions.io ]"
},
{
"name": "issuef",
Binary file not shown.
@@ -10,35 +10,11 @@
*
*/


/**
* MIT License
*
* Copyright (c) 2019 Cryptolions.io
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#include <eosiolib/eosio.hpp>
#include <eosiolib/asset.hpp>
#include <eosiolib/singleton.hpp>
#include <eosiolib/transaction.hpp>

using namespace eosio;
using std::string;
@@ -53,8 +29,7 @@ CONTRACT SimpleAssets : public contract {
// ===============================================================================================
// ============= Non-Fungible Token Actions ======================================================
// ===============================================================================================


//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
/*
* New Author registration. Action is not mandatory. Markets *may* choose to use information here
@@ -105,7 +80,7 @@ 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>;


//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
/*
* Claim the specified asset (assuming it was offered to claimer by the asset owner).
@@ -194,11 +169,10 @@ CONTRACT SimpleAssets : public contract {
* owner - current asset owner account;
* to - borrower account name;
* assetids - array of assetid's to delegate;
* untildate - untildate - The delegating account will not be able to undelegate before this date.
* However, the receiver of the lent asset can transfer back any time
* Should be timestamp in future or 0;
* period - time in seconds that the asset will be lent. Lender cannot undelegate until
* the period expires, however the receiver can transfer back at any time.
*/
ACTION delegate( name owner, name to, std::vector<uint64_t>& assetids, uint64_t untildate );
ACTION delegate( name owner, name to, std::vector<uint64_t>& assetids, uint64_t period );
using delegate_action = action_wrapper<"delegate"_n, &SimpleAssets::delegate>;


@@ -337,13 +311,16 @@ CONTRACT SimpleAssets : public contract {
//=============================================================================================================================
private:

uint64_t getid();
uint64_t getid(bool defer);
uint64_t getFTIndex(name author, symbol symbol);

void sub_balancef( name owner, name author, asset value );
void add_balancef( name owner, name author, asset value, name ram_payer );

template<typename... Args>
void sendEvent(name author, name rampayer, name seaction, const std::tuple<Args...> &tup);


//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
/*
* Authors table. Can be used by asset markets, asset explorers, or wallets for correct asset
@@ -435,7 +412,7 @@ CONTRACT SimpleAssets : public contract {
name owner;
name delegatedto;
uint64_t cdate;
uint64_t untildate;
uint64_t period;

auto primary_key() const {
return assetid;
@@ -447,7 +424,7 @@ CONTRACT SimpleAssets : public contract {
return delegatedto.value;
}

EOSLIB_SERIALIZE( sdelegate, (assetid)(owner)(delegatedto)(cdate)(untildate))
EOSLIB_SERIALIZE( sdelegate, (assetid)(owner)(delegatedto)(cdate)(period))
};

typedef eosio::multi_index< "delegates"_n, sdelegate,
@@ -485,7 +462,7 @@ CONTRACT SimpleAssets : public contract {
asset balance;

uint64_t primary_key()const {
return id;//buildFungibleIndex(author, balance.symbol);// author.value+balance.symbol.code().raw();
return id;
}
};

@@ -191,9 +191,8 @@
`owner` - current asset owner account;
`to` - borrower account name;
`assetids` - array of assetid's to delegate;
`untildate` - untildate - The delegating account will not be able to undelegate before this date.
However, the receiver of the lent asset can transfer back any time
Should be timestamp in future or 0;
`period` - time in seconds that the asset will be lent. Lender cannot undelegate until
the period expires, however the receiver can transfer back at any time.

### TERM
This Contract expires at the conclusion of code execution.

0 comments on commit 9718651

Please sign in to comment.
You can’t perform that action at this time.