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

Commit

Permalink
add deposits
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Dec 2, 2023
1 parent 0f65077 commit 9e04bef
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
22 changes: 22 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,27 @@ $ ./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

### example

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

## TABLE `configs`

Expand Down
10 changes: 10 additions & 0 deletions src/notifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ 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();
});

// 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 );
}
33 changes: 33 additions & 0 deletions work.pomelo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,39 @@ 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
*
* ### example
*
* ```json
* {
* "id": 1,
* "from": "1111234.eosn",
* "quantity": "5.0000 USDT",
* "timestamp": "2023-12-01T00:00:00"
* }
* ```
*/
struct [[eosio::table("deposits")]] deposits_row {
uint64_t id;
name from;
asset quantity;
time_point_sec timestamp;

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 9e04bef

Please sign in to comment.