Skip to content

Commit 9787e99

Browse files
authored
Merge pull request #95 from scryptonight/main
Added web front-end for the identity portion of the project
2 parents 290f9a1 + f246c1f commit 9787e99

File tree

371 files changed

+11730
-7136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

371 files changed

+11730
-7136
lines changed

3-lending/demifi/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*~

3-lending/demifi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "demifi"
3-
version = "1.0.0"
3+
version = "2.0.0"
44
edition = "2021"
55

66
[dependencies]

3-lending/demifi/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
![](./web/public/DeMiFi%20logo.png)
2+
3+
# DeMiFi - Decentralized Micro-Finance
4+
This project provides a set of blueprints which when used together
5+
will allow you to offer micro-finance services on the ledger.
6+
7+
It consists of three different blueprints working together, with one
8+
blueprint offering identity services for the participants and the two
9+
other handling loan requests and loan management.
10+
11+
## How to build and test the web front-end
12+
You need to have npm installed on your system. You do not need to
13+
build the blueprints themselves to build and run the front-end.
14+
- From the command line, in the `demifi/web` directory, run `npm
15+
install && npm run dev`
16+
- Connect your web browser to the URL it shows you
17+
18+
## How to build the blueprints
19+
Make sure you have the necessary toolchain installed, including the
20+
resim tool, see
21+
[here](https://docs.radixdlt.com/main/scrypto/getting-started/install-scrypto.html)
22+
for details.
23+
- From the command line, in the `demifi` directory, run `cargo build`
24+
25+
### How to run the test suite
26+
- Make sure you have the resim tool installed, see above.
27+
- From the command line, in the `demifi` directory, run `cargo test --
28+
--test-threads=1`
29+
30+
### How to generate the documentation
31+
- From the command line, in the `demifi` directory, run `cargo doc`
32+
33+
The generated web pages contain detailed documentation on how the
34+
blueprints work.

3-lending/demifi/src/loanrequestor.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,11 @@
194194
//! Participants catalog should get the job done --- but I don't know
195195
//! your business.)
196196
//!
197-
//! Each LoanRequestor instance needs to paired with one LoanAcceptor
198-
//! instance (see [crate::loanacceptor]). The requestor manages the
199-
//! loan request negotiation, and the acceptor converts the request
200-
//! into an actual loan and manages the repayment etc. of that loan.
197+
//! Each LoanRequestor instance needs to be paired with one
198+
//! LoanAcceptor instance (see [crate::loanacceptor]). The requestor
199+
//! manages the loan request negotiation, and the acceptor converts
200+
//! the request into an actual loan and manages the repayment etc. of
201+
//! that loan.
201202
//!
202203
//! # Load balancing
203204
//!

3-lending/demifi/src/participants.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ blueprint! {
123123
/// The NFT resource address of this Participant catalog.
124124
nft_address: ResourceAddress,
125125

126+
/// NonFungibleIds are allocated from this counter.
127+
nft_serial: u64,
128+
126129
/// Our admin badge, used to manage the Participent NFTs.
127130
admin_badge: Vault,
128131

@@ -181,6 +184,7 @@ blueprint! {
181184
let (nft, nfid) = Participants::create_participant(
182185
&badge,
183186
nft_address,
187+
0,
184188
root_participant_name.unwrap_or(
185189
"Loan market creator".to_string()),
186190
"".to_string(),
@@ -190,6 +194,7 @@ blueprint! {
190194
let participants =
191195
Self {
192196
nft_address,
197+
nft_serial: 0,
193198
admin_badge: badge,
194199
catalog_creator: nfid.clone(),
195200
}
@@ -217,14 +222,16 @@ blueprint! {
217222
/// ```text
218223
#[doc = include_str!("../rtm/participants/new_participant.rtm")]
219224
/// ```
220-
pub fn new_participant(&self,
225+
pub fn new_participant(&mut self,
221226
name: String,
222227
url: String,
223228
id_ref: String,
224229
expect_sponsor: Option<NonFungibleId>) -> (Bucket, NonFungibleId)
225230
{
231+
self.nft_serial += 1;
226232
Participants::create_participant(&self.admin_badge,
227233
self.nft_address,
234+
self.nft_serial,
228235
name,
229236
url,
230237
id_ref,
@@ -525,6 +532,18 @@ blueprint! {
525532
self.nft_address
526533
}
527534

535+
/// Retrieves the last serial number used to create a
536+
/// Participant NFT.
537+
///
538+
/// ---
539+
///
540+
/// **Access control:** Read only, allows anyone.
541+
///
542+
/// **Transaction manifest:** TODO
543+
pub fn read_participants_nft_serial(&self) -> u64 {
544+
self.nft_serial
545+
}
546+
528547
/// Retrieves address of the catalog creator's Participant
529548
/// NFT.
530549
///
@@ -548,12 +567,13 @@ blueprint! {
548567
/// Helper function to create a new Participant.
549568
fn create_participant(admin_badge: &Vault,
550569
nft_address: ResourceAddress,
570+
nft_serial: u64,
551571
name: String,
552572
url: String,
553573
id_ref: String,
554574
expect_sponsor: Option<NonFungibleId>) -> (Bucket, NonFungibleId)
555575
{
556-
let nfid: NonFungibleId = NonFungibleId::random();
576+
let nfid: NonFungibleId = NonFungibleId::from_u64(nft_serial);
557577
let nft: Bucket = admin_badge.authorize(||
558578
borrow_resource_manager!(nft_address)
559579
.mint_non_fungible(

3-lending/demifi/web/.gitignore

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1-
.snowpack
2-
build
3-
node_modules
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
*~

3-lending/demifi/web/.prettierrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

3-lending/demifi/web/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

3-lending/demifi/web/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
6+
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
7+
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
8+
<link rel="manifest" href="site.webmanifest">
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
10+
<title>DeMiFi</title>
11+
</head>
12+
<body>
13+
<div id="app"></div>
14+
<script type="module" src="/src/main.ts"></script>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)