Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from pomelo-io/feature/deposits
Browse files Browse the repository at this point in the history
Feature/deposits
  • Loading branch information
DenisCarriere authored Dec 2, 2023
2 parents 0f65077 + 563eec6 commit 0a3e48e
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ $ ./test.sh
## Table of Content

### Tables
- [TABLE `deposits`](#table-deposits)
- [TABLE `configs`](#table-configs)
- [TABLE `bounties`](#table-bounties)
- [TABLE `transfers`](#table-transfers)
Expand Down Expand Up @@ -159,6 +160,29 @@ $ ./test.sh
### Action Notifications
- [TRANSFER NOTIFY HANDLER `on_transfer`](#transfer-notify-handler-on_transfer)

## TABLE `deposits`

*scope*: `{name} bount_id`

### params

- `{uint64_t} id` - (primary key) deposit ID
- `{name} from` - sender account (EOSN Login ID or EOS account)
- `{asset} quantity` - token quantity
- `{time_point_sec} timestamp` - timestamp
- `{checksum256} trx_id` - transaction ID

### example

```json
{
"id": 1,
"from": "1111234.eosn",
"quantity": "5.0000 USDT",
"timestamp": "2023-12-01T00:00:00",
"trx_id": "33916e02c5fdc40c7c7d08598a606e51bcd93fc0003316fd85a335eedf58d26b"
}
```

## TABLE `configs`

Expand Down
2 changes: 2 additions & 0 deletions src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ void pomelo::cleartable( const name table_name, const optional<name> scope, cons
pomelo::bounties_table _bounties( get_self(), value );
pomelo::tokens_table _tokens( get_self(), value );
pomelo::configs_table _configs( get_self(), value );
pomelo::deposits_table _deposits( get_self(), value );

if (table_name == "bounties"_n) clear_table( _bounties, rows_to_clear );
else if (table_name == "tokens"_n) clear_table( _tokens, rows_to_clear );
else if (table_name == "deposits"_n) clear_table( _deposits, rows_to_clear );
else if (table_name == "configs"_n) _configs.remove();
else check(false, "pomelo::cleartable: [table_name] unknown table to clear" );
}
11 changes: 11 additions & 0 deletions src/notifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ void pomelo::deposit_bounty( const name bounty_id, const name user_id, const nam
check( total <= max_amount, "pomelo::deposit_bounty: [quantity=" + ext_quantity.quantity.to_string() + "] is greater than [tokens.max_amount=" + to_string( max_amount ) + "]");
});

// track unique deposits
pomelo::deposits_table _deposits( get_self(), bounty_id.value );
_deposits.emplace( get_self(), [&]( auto & row ) {
row.id = _deposits.available_primary_key();
row.from = from;
row.quantity = quantity;
row.timestamp = current_time_point();
row.trx_id = get_trx_id();
});

// deposit log
pomelo::depositlog_action depositlog( get_self(), { get_self(), "active"_n });
depositlog.send( bounty_id, funder_user_id, from, amount, fee.quantity, value, memo );
}
36 changes: 36 additions & 0 deletions work.pomelo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,42 @@ class [[eosio::contract("work.pomelo")]] pomelo : public eosio::contract {
};
typedef eosio::multi_index< "tokens"_n, tokens_row> tokens_table;

/**
* ## TABLE `deposits`
*
* *scope*: `{name} bount_id`
*
* ### params
*
* - `{uint64_t} id` - (primary key) deposit ID
* - `{name} from` - sender account (EOSN Login ID or EOS account)
* - `{asset} quantity` - token quantity
* - `{time_point_sec} timestamp` - timestamp
* - `{checksum256} trx_id` - transaction ID
*
* ### example
*
* ```json
* {
* "id": 1,
* "from": "1111234.eosn",
* "quantity": "5.0000 USDT",
* "timestamp": "2023-12-01T00:00:00",
* "trx_id": "33916e02c5fdc40c7c7d08598a606e51bcd93fc0003316fd85a335eedf58d26b"
* }
* ```
*/
struct [[eosio::table("deposits")]] deposits_row {
uint64_t id;
name from;
asset quantity;
time_point_sec timestamp;
checksum256 trx_id;

uint64_t primary_key() const { return id; }
};
typedef eosio::multi_index< "deposits"_n, deposits_row> deposits_table;

/**
* ## TABLE `bounties`
*
Expand Down

0 comments on commit 0a3e48e

Please sign in to comment.