Skip to content

Commit

Permalink
v1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ansigroup committed Mar 17, 2021
1 parent 7d1bc8f commit e6a042f
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 96 deletions.
94 changes: 57 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# SimpleAssets
*document version 29 July 2020*
*document version 17 March 2021*

## Scope:
1. [Introduction](#introduction)
- [Resources](#resources)
- [Author RAM Payer](#author-ram-payer)
- [Token Types](#token-types)
2. [Contract actions](#contract-actions)
3. [Data Structures](#data-structures)
Expand Down Expand Up @@ -61,6 +62,12 @@ https://github.com/CryptoLions/SimpleAssets/blob/master/include/SimpleAssets.hpp

Events Receiver Example for authors: https://github.com/CryptoLions/SimpleAssets-EventReceiverExample

---------------------------
## Author RAM Payer

NFT authors can enable Author RAM Payer for some or all of their NFTs, and pay for all the RAM associated with transfers so that users don't have to.

[Read more about Author RAM Payer](https://simpleassets.io/simple-assets-author-ram-payer-solution-post/)

---------------------------
## Token Types
Expand All @@ -78,7 +85,7 @@ Both are stringified JSONs. For example: `{\"key1\":\"some-string\", \"key2\":5

**Category** is an optional field that lets you group your NFTs for convenience. Category names must be less than or equal to 12 characters (a-z, 1-5).

**Offer/Claim** versus **Transfer** - If you transfer an NFT, the sender pays for RAM. As an alternative, you can simply offer the NFT, and the user claiming will pay for their RAM. *(Note: we are working toward a feature that allows NFT authors to reserve a lot of RAM which will spare users for paying for transfers.)*
**Offer/Claim** versus **Transfer** - If you transfer an NFT, the sender pays for RAM. As an alternative, you can simply offer the NFT, and the user claiming will pay for their RAM. *(Note: We've deployed an [Author RAM Payer](https://simpleassets.io/simple-assets-author-ram-payer-solution-post/) feature that allows NFT authors to pay for all the RAM of their NFTs.)*

#### RAM usage

Expand Down Expand Up @@ -216,39 +223,46 @@ offers {

## Authors
```c++
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;
// recommendations: logo, info, url;

string stemplate; // data (json) schema to tell third-party markets how to display each NFT field.
// key: state values, where key is the key from mdata or idata;
// recommended values:
// txt | default type
// url | show as clickable URL
// img | link to img file
// webgl | link to webgl file
// mp3 | link to mp3 file
// video | link to video file
// hide | do not show
// imgb | image as string in binary format
// webglb | webgl binary
// mp3b | mp3 binary
// videob | video binary

string imgpriority; // Specifies primary image field for categories of NFTs.
//
// This is used when you want your NFTs primary image to be something other
// than a URL to an image field specified in the field img. It also allows you to
// create categories of NFTs with different primary image fields.
//
// data is a strigified json.
// key: NFT categories.
// value: a field from idata or mdata to be used as the primary image for
// all NFTs of that category.
authors {
name author; // assets author, who will be able to create and update assets;

string dappinfo; // stringified JSON. Recommendations to include:
// name - name of the application
// company - name of the company
// logo - url to image
// url - url to the game's websites
// info - short description of application
// defaultfee - 100x the % fee you'd like to collect from marketplaces. (for 2%, 200)

string fieldtypes; // data (json) schema to tell third-party markets how to display each NFT field.
// key: state values, where key is the key from mdata or idata;
// recommended values:

// txt | default type
// url | show as clickable URL
// img | link to img file
// webgl | link to webgl file
// mp3 | link to mp3 file
// video | link to video file
// hide | do not show
// imgb | image as string in binary format
// webglb | webgl binary
// mp3b | mp3 binary
// videob | video binary
//

string priorityimg; // Specifies primary image field for categories of NFTs.
//
// This is used when you want your NFTs primary image to be something other
// than a URL to an image field specified in the field img. It also allows you to
// create categories of NFTs with different primary image fields.
//
// data is a strigified json.
// key: NFT categories.
// value: a field from idata or mdata to be used as the primary image for
// all NFTs of that category.

}
}
```

## Delegates
Expand Down Expand Up @@ -319,9 +333,8 @@ snttassets {
```c++
nttoffers {
uint64_t id; // id of the offer for claim (increments automatically)
name author; // ft author
name owner; // ft owner
asset quantity; // quantity
name author; // ntt author
name owner; // ntt owner
name offeredto; // account who can claim the offer
uint64_t cdate; // offer creation date
}
Expand Down Expand Up @@ -661,6 +674,13 @@ to be the main image.
-----------------
# Change Logs

## Change Log v1.6.1
- support for token-back NFT contract
- Changed map structure type to vector in `saeclaim` and `saechautor` log actions
- Code refactoring
- Typo fixed
- Added new developers function: `sa_time_to_wait`

## Change Log v1.6.0
- Added author ram payer option
- Added actions setarampayer, delarampayer
Expand Down
32 changes: 16 additions & 16 deletions build/SimpleAssets/SimpleAssets.abi
Original file line number Diff line number Diff line change
Expand Up @@ -787,20 +787,6 @@
}
]
},
{
"name": "pair_uint64_name",
"base": "",
"fields": [
{
"name": "key",
"type": "uint64"
},
{
"name": "value",
"type": "name"
}
]
},
{
"name": "saeburn",
"base": "",
Expand Down Expand Up @@ -841,7 +827,7 @@
},
{
"name": "assetids",
"type": "pair_uint64_name[]"
"type": "tuple_uint64_name[]"
},
{
"name": "memo",
Expand All @@ -863,7 +849,7 @@
},
{
"name": "assetids",
"type": "pair_uint64_name[]"
"type": "tuple_uint64_name[]"
}
]
},
Expand Down Expand Up @@ -1249,6 +1235,20 @@
}
]
},
{
"name": "tuple_uint64_name",
"base": "",
"fields": [
{
"name": "field_0",
"type": "uint64"
},
{
"name": "field_1",
"type": "name"
}
]
},
{
"name": "undelegate",
"base": "",
Expand Down
Binary file modified build/SimpleAssets/SimpleAssets.wasm
Binary file not shown.
18 changes: 13 additions & 5 deletions include/SimpleAssets.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* @file
* @author (C) 2020 by CryptoLions [ https://CryptoLions.io ]
* @author (C) 2021 by CryptoLions [ https://CryptoLions.io ]
* @version 1.6.0
*
* @section LICENSE
Expand All @@ -23,6 +23,7 @@
* Presentation: https://medium.com/@cryptolions/introducing-simple-assets-b4e17caafaa4
* Event Receiver: https://github.com/CryptoLions/SimpleAssets-EventReceiverExample
*/
#pragma once

#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
Expand Down Expand Up @@ -450,7 +451,7 @@ CONTRACT SimpleAssets : public contract{
* Update the data field of a fungible token.
*
* @param author is fungible token author.
* @param sym is fingible token symbol ("GOLD", "WOOD", etc.).
* @param sym is fungible token symbol ("GOLD", "WOOD", etc.).
* @param data is stringified JSON (recommend including keys `img` and `name` for better displaying by markets).
* @return no return value.
*/
Expand Down Expand Up @@ -772,7 +773,7 @@ CONTRACT SimpleAssets : public contract{
* @param memo is memo for change author action.
* @return no return value.
*/
ACTION saechauthor( name author, name newauthor, name owner, map< uint64_t, name >& assetids, string memo );
ACTION saechauthor( name author, name newauthor, name owner, vector< tuple<uint64_t, name> >& assetids, string memo );
using saechauthor_action = action_wrapper< "saechauthor"_n, &SimpleAssets::saechauthor >;

/*
Expand Down Expand Up @@ -806,7 +807,8 @@ CONTRACT SimpleAssets : public contract{
* @param assetids is array of asset id's to claim.
* @return no return value.
*/
ACTION saeclaim( name author, name claimer, map< uint64_t, name >& assetids );

ACTION saeclaim(name author, name claimer, vector< tuple<uint64_t, name> >& assetids);
using saeclaim_action = action_wrapper< "saeclaim"_n, &SimpleAssets::saeclaim >;

/*
Expand Down Expand Up @@ -887,6 +889,13 @@ CONTRACT SimpleAssets : public contract{
return result;
}

static string sa_time_to_wait(uint64_t time_in_seconds) {
uint64_t s, h, m = 0;
m = time_in_seconds / 60;
h = m / 60;
return "Time to wait " + to_string(int(h)) + " hours " + to_string(int(m % 60)) + " minutes " + to_string(int(time_in_seconds % 60)) + " seconds";
}

private:
const uint16_t MAX_MEMO_SIZE = 512;
const uint64_t IMPOSSIBLE_ID = 1;
Expand Down Expand Up @@ -916,7 +925,6 @@ CONTRACT SimpleAssets : public contract{
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>
Expand Down
Loading

0 comments on commit e6a042f

Please sign in to comment.