Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding API routes & services #18

Merged
merged 5 commits into from
Jun 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
updated README's
AmarildoGrembi committed Feb 17, 2023
commit 70b89b2cfa3e7a9f18a4074a90f229015bb39299
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -23,6 +23,18 @@ We also hope to help you understand the main concepts and best practices of Cade

`AssetHandover` is a dapp where account `holders` can grant a `recipient` the ability to `withdraw` specific `tokens` that they own (both `FungibleToken` and `NonFungibleToken`), at a future release date. Each account can only declare one recipient, as this removes the complexity of handling race conditions upon withdrawals. However, an account can be the recipient of multiple handovers. The account holder can specify which fungible tokens will be handed over and a maximum amount for each token. It is also possible to specify which non-fungible tokens will be handed over and a specific list of NFT IDs from each `NFT` Collection. The above tokens are not locked for the account holder, meaning that they can still be utilized/transferred. The recipient (or any other account) can attempt to withdraw them, at any given time, however, this will only be successful after the release date has passed, and only for the authorized recipient. One real-world scenario would be to create a digital `"will"` for one's account, or to simply add another account as a backup, in case the account holder loses access to his/her account or is no longer able to interact with it.

## Project Overview

Below is a description of the Dapp's components.

### 1. Web Server | [asset-handover/api](https://github.com/Build-Squad/asset-handover/tree/master/api)

The API demonstrates how to send transactions and queries to the Flow blockchain. By using the API you would be able to interact with the 3 main smart contracts of [Asset-Handover](https://github.com/Build-Squad/asset-handover/blob/master/cadence/contracts/AssetHandover.cdc), [BlpToken](https://github.com/Build-Squad/asset-handover/blob/master/cadence/contracts/tokens/BlpToken.cdc) and [Domains](https://github.com/Build-Squad/asset-handover/blob/master/cadence/contracts/nfts/Domains.cdc).

### 2. Cadence Code | [asset-handover/cadence](https://github.com/onflow/asset-handover/tree/master/cadence)

[Cadence](https://docs.onflow.org/cadence) This folder contains all of the blockchain logic for the application, meaning, smart contracts, smart contract implementations, as well as the scripts and transactions that interact with them.

## ✨ Getting Started

### 1. Install Dependencies
16 changes: 8 additions & 8 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Asset-handover API
The Asset-handover API is a RESTful API built with [express](https://expressjs.com/) that sends transactions to Flow using the [Flow JS SDK](https://github.com/onflow/fcl-js/tree/master/packages/sdk). It contains endpoints for the [Asset-handover](src/services/assetHandover.js), the [BLP token](src/services/blpToken.ts) and [Domains token](src/services/domainsToken.ts) services to read & write data to the Flow blockchain.
The Asset-handover API is a RESTful API built with [express](https://expressjs.com/) that sends transactions to Flow using the [Flow JS SDK](https://github.com/onflow/fcl-js/tree/master/packages/sdk). It contains endpoints for the [Asset-handover](src/services/assetHandover.js), the [BLP token](src/services/blpToken.js) and [Domains token](src/services/domainsToken.js) services to read & write data to the Flow blockchain.

## Services
The Asset-handover API contains four main services. These services synchronize data between the blockchain, and also provide API endpoints that could be consumed by the asset-handover client-side application.

### [Asset-Handover Service](src/services/block-cursor.ts)
### [Asset-Handover Service](src/services/assetHandover.js)
This service contains functions that utilize the Flow Service to send Cadence transactions and scripts that fetch and update Asset-handover data.

You can also run the [transactions and scripts](../cadence) manually using the [Flow CLI](https://docs.onflow.org/flow-cli/).
@@ -14,15 +14,15 @@ You can also run the [transactions and scripts](../cadence) manually using the [

- **POST `/v1/asset-handover/lockUp/updateWithdrawFees`**: Allows the admin (deployer) of the Asset-Handover smart contract to update the fees charged for withdrawing from a lock-up. Uses [updateWithdrawFees.cdc](/cadence/transactions/lockUps/updateWithdrawFees.cdc)

- **GET `/v1/asset-handover/accountLockUp/:address`**: Fetches the lock-up by holder account. Calls [getAccountLockUp.cdc](/cadence/scripts/lockups/getAccountLockUp.cdc)
- **GET `/v1/asset-handover/accountLockUp/:address`**: Fetches the lock-up by holder account. Calls [getAccountLockUp.cdc](/cadence/scripts/lockUps/getAccountLockUp.cdc)

- **GET `/v1/asset-handover/LockUpsByRecipient/:address`**: Fetches the lock-up by recipient account. Calls [getLockUpsByRecipient.cdc](/cadence/scripts/lockups/getLockUpsByRecipient.cdc)
- **GET `/v1/asset-handover/LockUpsByRecipient/:address`**: Fetches the lock-up by recipient account. Calls [getLockUpsByRecipient.cdc](/cadence/scripts/lockUps/getLockUpsByRecipient.cdc)

- **GET `/v1/asset-handover/fungibleTokenInfoMapping`**: Fetches the fungible tokens of the Asset-handover registry. Calls [getFungibleTokenInfoMapping.cdc](/cadence/scripts/lockups/getFungibleTokenInfoMapping.cdc)
- **GET `/v1/asset-handover/fungibleTokenInfoMapping`**: Fetches the fungible tokens of the Asset-handover registry. Calls [getFungibleTokenInfoMapping.cdc](/cadence/scripts/lockUps/getFungibleTokenInfoMapping.cdc)

- **GET `/v1/asset-handover/nonFungibleTokenInfoMapping`**: Fetches the non fungible tokens of the Asset-handover registry. Calls [getNonFungibleTokenInfoMapping.cdc](/cadence/scripts/lockups/getNonFungibleTokenInfoMapping.cdc)
- **GET `/v1/asset-handover/nonFungibleTokenInfoMapping`**: Fetches the non fungible tokens of the Asset-handover registry. Calls [getNonFungibleTokenInfoMapping.cdc](/cadence/scripts/lockUps/getNonFungibleTokenInfoMapping.cdc)

### [BLP Token Service](src/services/kitty-items.ts)
### [BLP Token Service](src/services/blpToken.js)
This service contains functions that utilize the Flow Service to send Cadence transactions and scripts that fetch and update BLP token data.

You can also run the [transactions and scripts](../cadence) manually using the [Flow CLI](https://docs.onflow.org/flow-cli/).
@@ -42,7 +42,7 @@ You can also run the [transactions and scripts](../cadence) manually using the [

- **POST `/v1/asset-handover/domains/mint`**: Mint Domains token for an account. Calls [registerDomain.cdc](/cadence/transactions/domains/registerDomain.cdc)

### [Flow Service](src/services/flow.ts)
### [Flow Service](src/services/flow.js)
This service contains functions that interact with the Flow blockchain using the [FCL JS](https://docs.onflow.org/fcl/) library. While it has no exposed endpoints, its methods used to read, write and authorize data on the chain are used extensively by its sister services.

Notable functions: