Skip to content

Commit

Permalink
Merge branch 'feature/#246' into feature/#248
Browse files Browse the repository at this point in the history
  • Loading branch information
urushibata-k committed Dec 21, 2021
2 parents bdca938 + 961f53a commit a61f3b4
Show file tree
Hide file tree
Showing 20 changed files with 3,131 additions and 321 deletions.
119 changes: 109 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,127 @@
* ibet-SmartContract: version 21.12.0


## Starting and Stopping the Server
Install packages
## Setup

### Prerequisites

- Need to set up a Python runtime environment.
- Need to create the DB on PostgreSQL beforehand.
- By default, the following settings are required.
- User: issuerapi
- Password: issuerapipass
- DB: issuerapidb
- DB for test use: issuerapidb_test
- TokenList contract of the ibet-SmartContract must have been deployed beforehand.

### Install packages

Install python packages with:
```bash
$ pip install -r requirements.txt
```

Create database tables
### Setting environment variables

The main environment variables are as follows.

<table style="border-collapse: collapse" id="env-table">
<tr bgcolor="#000000">
<th style="width: 25%">Variable Name</th>
<th style="width: 10%">Required</th>
<th style="width: 30%">Details</th>
<th>Example</th>
</tr>
<tr>
<td>DATABASE_URL</td>
<td>False</td>
<td nowrap>Database URL</td>
<td>postgresql://issuerapi:issuerapipass@localhost:5432/issuerapidb</td>
</tr>
<tr>
<td>TEST_DATABASE_URL</td>
<td>False</td>
<td nowrap>Test database URL</td>
<td>postgresql://issuerapi:issuerapipass@localhost:5432/issuerapidb</td>
</tr>
<tr>
<td>DATABASE_SCHEMA</td>
<td>False</td>
<td nowrap>Database schema</td>
<td></td>
</tr>
<tr>
<td>WEB3_HTTP_PROVIDER</td>
<td>False</td>
<td nowrap>Web3 provider</td>
<td>http://localhost:8545</td>
</tr>
<tr>
<td>CHAIN_ID</td>
<td>False</td>
<td nowrap>Blockchain network ID</td>
<td>1010032</td>
</tr>
<tr>
<td>TOKEN_LIST_CONTRACT_ADDRESS</td>
<td>True</td>
<td nowrap>TokenList contract address</td>
<td>0x0000000000000000000000000000000000000000</td>
</tr>
<tr>
<td>TZ</td>
<td>False</td>
<td nowrap>Timezone</td>
<td>Asia/Tokyo</td>
</tr>
</table>

Other environment variables that can be set can be found in `config.py`.

### DB migrations

See [migrations/README.md](migrations/README.md).


## Starting the Server

You can start the API server with:
```bash
$ ./bin/run_migration.sh init
$ ./run.sh server (Press CTRL+C to quit)
```

You can start (or stop) the API server with:
```bash
$ ./bin/run_server.sh start(stop)
Open your browser at [http://0.0.0.0:5000](http://0.0.0.0:5000).

You will see the JSON response as:
```json
{"server":"ibet-Prime"}
```

### API docs

#### Swagger UI

Now go to [http://0.0.0.0:5000/docs](http://0.0.0.0:5000/docs).

You will see the automatic interactive API documentation provided by Swagger UI:

![swagger](https://user-images.githubusercontent.com/963333/146362141-da0fc0d2-1518-4041-a274-be2b743966a1.png)


#### ReDoc

And now, go to [http://0.0.0.0:5000/redoc](http://0.0.0.0:5000/redoc).

You will see the alternative automatic documentation provided by ReDoc:

![redoc](https://user-images.githubusercontent.com/963333/146362775-c1ec56fa-f0b0-48a4-8926-75c2b7159c90.png)


## Branching model

<p align='center'>
<img alt="ibet" src="https://user-images.githubusercontent.com/963333/128751565-3268b1e3-185b-4f09-870f-b6d96519eb54.png"/>
</p>
This repository is version controlled using the following flow.

![branching_model](https://user-images.githubusercontent.com/963333/128751565-3268b1e3-185b-4f09-870f-b6d96519eb54.png)

## License

Expand Down
9 changes: 6 additions & 3 deletions app/model/db/idx_transfer_approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ class IDXTransferApproval(Base):
application_datetime = Column(DateTime)
# Application Blocktimestamp
application_blocktimestamp = Column(DateTime)
# Approval Datetime
# Approval Datetime(ownership vesting datetime)
approval_datetime = Column(DateTime)
# Approval Blocktimestamp
# Approval Blocktimestamp(ownership vesting block timestamp)
approval_blocktimestamp = Column(DateTime)
# Cancellation Status
cancelled = Column(Boolean)
# Approve Status
transfer_approved = Column(Boolean)

def json(self):
return {
Expand All @@ -68,7 +70,8 @@ def json(self):
"application_blocktimestamp": self.application_blocktimestamp,
"approval_datetime": self.approval_datetime,
"approval_blocktimestamp": self.approval_blocktimestamp,
"cancelled": self.cancelled
"cancelled": self.cancelled,
"transfer_approved": self.transfer_approved
}


Expand Down
1 change: 1 addition & 0 deletions app/model/schema/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class TransferApprovalResponse(BaseModel):
approval_datetime: Optional[str]
approval_blocktimestamp: Optional[str]
cancelled: bool
transfer_approved: bool
is_issuer_cancelable: bool


Expand Down
10 changes: 10 additions & 0 deletions app/routers/bond.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,10 @@ def list_transfer_approval_history(
cancelled = False
else:
cancelled = _transfer_approval.cancelled
if _transfer_approval.transfer_approved is None:
transfer_approved = False
else:
transfer_approved = _transfer_approval.transfer_approved

application_datetime_utc = timezone("UTC").localize(_transfer_approval.application_datetime)
application_datetime = application_datetime_utc.astimezone(local_tz).isoformat()
Expand Down Expand Up @@ -1088,6 +1092,7 @@ def list_transfer_approval_history(
"approval_datetime": approval_datetime,
"approval_blocktimestamp": approval_blocktimestamp,
"cancelled": cancelled,
"transfer_approved": transfer_approved,
"is_issuer_cancelable": is_issuer_cancelable
})

Expand Down Expand Up @@ -1253,6 +1258,10 @@ def retrieve_transfer_approval_history(
cancelled = False
else:
cancelled = _transfer_approval.cancelled
if _transfer_approval.transfer_approved is None:
transfer_approved = False
else:
transfer_approved = _transfer_approval.transfer_approved

application_datetime_utc = timezone("UTC").localize(_transfer_approval.application_datetime)
application_datetime = application_datetime_utc.astimezone(local_tz).isoformat()
Expand Down Expand Up @@ -1290,6 +1299,7 @@ def retrieve_transfer_approval_history(
"approval_datetime": approval_datetime,
"approval_blocktimestamp": approval_blocktimestamp,
"cancelled": cancelled,
"transfer_approved": transfer_approved,
"is_issuer_cancelable": is_issuer_cancelable
}

Expand Down
10 changes: 10 additions & 0 deletions app/routers/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ def list_transfer_approval_history(
cancelled = False
else:
cancelled = _transfer_approval.cancelled
if _transfer_approval.transfer_approved is None:
transfer_approved = False
else:
transfer_approved = _transfer_approval.transfer_approved

application_datetime_utc = timezone("UTC").localize(_transfer_approval.application_datetime)
application_datetime = application_datetime_utc.astimezone(local_tz).isoformat()
Expand Down Expand Up @@ -1074,6 +1078,7 @@ def list_transfer_approval_history(
"approval_datetime": approval_datetime,
"approval_blocktimestamp": approval_blocktimestamp,
"cancelled": cancelled,
"transfer_approved": transfer_approved,
"is_issuer_cancelable": is_issuer_cancelable
})

Expand Down Expand Up @@ -1239,6 +1244,10 @@ def retrieve_transfer_approval_history(
cancelled = False
else:
cancelled = _transfer_approval.cancelled
if _transfer_approval.transfer_approved is None:
transfer_approved = False
else:
transfer_approved = _transfer_approval.transfer_approved

application_datetime_utc = timezone("UTC").localize(_transfer_approval.application_datetime)
application_datetime = application_datetime_utc.astimezone(local_tz).isoformat()
Expand Down Expand Up @@ -1276,6 +1285,7 @@ def retrieve_transfer_approval_history(
"approval_datetime": approval_datetime,
"approval_blocktimestamp": approval_blocktimestamp,
"cancelled": cancelled,
"transfer_approved": transfer_approved,
"is_issuer_cancelable": is_issuer_cancelable
}

Expand Down

0 comments on commit a61f3b4

Please sign in to comment.