wip
This commit is contained in:
113
docs/FREEZONE_IMPLEMENTATION_TODO.md
Normal file
113
docs/FREEZONE_IMPLEMENTATION_TODO.md
Normal file
@@ -0,0 +1,113 @@
|
||||
# Freezone Implementation TODO
|
||||
|
||||
## Summary
|
||||
The freezone.rhai example has been created and demonstrates a complete registration flow. However, some Rhai bindings need to be implemented to make it fully functional.
|
||||
|
||||
## Required Implementations
|
||||
|
||||
### 1. Ethereum Wallet Function
|
||||
**Location:** `src/objects/money/rhai.rs`
|
||||
|
||||
Add a `new_ethereum_wallet()` function that creates an Ethereum wallet:
|
||||
|
||||
```rust
|
||||
#[rhai_fn(name = "new_ethereum_wallet", return_raw)]
|
||||
pub fn new_ethereum_wallet() -> Result<EthereumWallet, Box<EvalAltResult>> {
|
||||
// Generate new Ethereum wallet
|
||||
// Return wallet with address, private key (encrypted), network
|
||||
Ok(EthereumWallet::new())
|
||||
}
|
||||
```
|
||||
|
||||
The wallet should have:
|
||||
- `.owner_id(id)` - set owner
|
||||
- `.network(network)` - set network (mainnet/testnet)
|
||||
- `.get_address()` - get Ethereum address
|
||||
|
||||
### 2. Accounting Module
|
||||
**Location:** `src/objects/accounting/`
|
||||
|
||||
Create Invoice and Expense objects (files were created but need to be integrated):
|
||||
|
||||
**Invoice:**
|
||||
- `new_invoice(id)` - constructor
|
||||
- `.invoice_number(num)`, `.customer_id(id)`, `.amount(amt)`, `.currency(cur)`, `.description(desc)`
|
||||
- `.send()`, `.mark_paid()`, `.mark_overdue()`, `.cancel()`
|
||||
- Getters: `.invoice_number()`, `.customer_id()`, `.amount()`, `.status()`
|
||||
|
||||
**Expense:**
|
||||
- `new_expense(id)` - constructor
|
||||
- `.user_id(id)`, `.amount(amt)`, `.currency(cur)`, `.description(desc)`, `.category(cat)`, `.invoice_id(id)`
|
||||
- `.approve()`, `.mark_paid()`, `.reject()`
|
||||
- Getters: `.user_id()`, `.amount()`, `.status()`, `.category()`
|
||||
|
||||
### 3. Payment Request Enhancements
|
||||
**Location:** `src/objects/money/payments.rs` and `rhai.rs`
|
||||
|
||||
Add `new_payment_request()` function with builder API:
|
||||
- `.amount(amt)`
|
||||
- `.currency(cur)`
|
||||
- `.description(desc)`
|
||||
- `.callback_url(url)`
|
||||
- `.merchant_reference(ref)`
|
||||
|
||||
### 4. KYC Info Enhancements
|
||||
**Location:** `src/objects/kyc/info.rs` and `rhai.rs`
|
||||
|
||||
Add missing builder methods:
|
||||
- `.document_type(type)` - passport, id_card, drivers_license
|
||||
- `.document_number(num)`
|
||||
- `.verified(bool)` - mark as verified
|
||||
|
||||
### 5. Engine Registration
|
||||
**Location:** `src/engine.rs`
|
||||
|
||||
Add to `OsirisPackage`:
|
||||
```rust
|
||||
// Register Accounting modules
|
||||
register_accounting_modules(module);
|
||||
|
||||
// Add save methods for Invoice and Expense
|
||||
FuncRegistration::new("save")
|
||||
.set_into_module(module, |ctx: &mut OsirisContext, invoice: crate::objects::Invoice| ctx.save_object(invoice));
|
||||
FuncRegistration::new("save")
|
||||
.set_into_module(module, |ctx: &mut OsirisContext, expense: crate::objects::Expense| ctx.save_object(expense));
|
||||
```
|
||||
|
||||
### 6. Module Exports
|
||||
**Location:** `src/objects/mod.rs`
|
||||
|
||||
Add:
|
||||
```rust
|
||||
pub mod accounting;
|
||||
pub use accounting::{Invoice, Expense};
|
||||
```
|
||||
|
||||
## Current Freezone Flow
|
||||
|
||||
The freezone.rhai example demonstrates:
|
||||
|
||||
1. **Public Key Registration** - User provides public key
|
||||
2. **Personal Information** - Collect name, email, create KYC info
|
||||
3. **Terms & Conditions** - Create and sign contract
|
||||
4. **Email Verification** - Generate code, send email, verify
|
||||
5. **Crypto Wallet Creation** - Create TFT account + Ethereum wallet
|
||||
6. **Payment Processing** - Pesapal payment session, user pays, record transaction
|
||||
7. **KYC Verification** - KYC session, user completes verification, callback with results
|
||||
8. **User Registration** - Create final user object
|
||||
|
||||
## Testing
|
||||
|
||||
Once implementations are complete, run:
|
||||
```bash
|
||||
cargo run --example freezone
|
||||
```
|
||||
|
||||
Expected output: Complete freezone registration flow with all 8 steps executing successfully.
|
||||
|
||||
## Notes
|
||||
|
||||
- The example uses simulated callbacks for payment and KYC
|
||||
- Ethereum wallet generation should use a proper library (e.g., ethers-rs)
|
||||
- Payment integration with Pesapal is mocked but shows the expected flow
|
||||
- KYC callback demonstrates how verified data would be received and stored
|
||||
Reference in New Issue
Block a user