generated from shuding/nextra-docs-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8694101
commit 7462ff8
Showing
17 changed files
with
363 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{ | ||
"index": "Intro", | ||
"architecture": "Architecture", | ||
"getting-started": "Getting started", | ||
"nostr": "NOSTR Event Anatomy", | ||
"api-gateway": "API Gateway", | ||
"flows": "Flows" | ||
"architecture": "Architecture", | ||
"flows": "Flows", | ||
"ledger": "Ledger", | ||
"extensions": "Extensions" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"index" : "Intro", | ||
"api": "API", | ||
"models": "Models", | ||
"events": "Events" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"inbound-transaction": "Inbound Transaction", | ||
"internal-transaction": "Internal Transaction", | ||
"outbound-transaction": "Outbound Transaction" | ||
} |
68 changes: 68 additions & 0 deletions
68
pages/wallet-provider/ledger/events/inbound-transaction.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Inbound Transaction Handler | ||
|
||
Handles inbound transactions, specifically those initiated by users. | ||
|
||
## Overview | ||
|
||
This module provides the functionality to handle and process inbound transactions on the Nostr platform. | ||
|
||
## Dependencies | ||
|
||
- `@nostr-dev-kit/ndk`: Provides necessary types and filters for Nostr events. | ||
- `@lib/events`: Event-related constants and functions. | ||
- `@lib/transactions`: Transaction-related utilities and handlers. | ||
- `@lib/utils`: General utility functions. | ||
- `@prisma/client`: Prisma ORM client for database interactions. | ||
|
||
## Constants | ||
|
||
- `REPUBLISH_INTERVAL_MS`: Interval for republishing balance events. | ||
- `MAX_RETRIES`: Maximum number of retries for handling a transaction. | ||
|
||
## Filter | ||
|
||
- `filter`: The filter used to select relevant inbound transactions. | ||
|
||
## Functions | ||
|
||
### `getHandler(ctx: Context, ntry: number): (nostrEvent: NostrEvent) => void` | ||
|
||
Returns the inbound transaction handler function. | ||
|
||
#### Parameters | ||
|
||
- `ctx`: The context containing necessary information for transaction handling. | ||
- `ntry`: The number of retries for handling the transaction. | ||
|
||
#### Returns | ||
|
||
A function that handles inbound transactions and initiates the necessary processes. | ||
|
||
### Handler Function | ||
|
||
#### Parameters | ||
|
||
- `nostrEvent`: The inbound transaction Nostr event. | ||
|
||
#### Functionality | ||
|
||
1. Validates the author of the transaction. | ||
2. Initiates the transaction in the database. | ||
3. Manages balances for the receiver's account. | ||
4. Publishes corresponding success or error events. | ||
|
||
#### Retries | ||
|
||
- The handler supports a limited number of retries in case of failures. | ||
|
||
## Usage Example | ||
|
||
```typescript | ||
import { filter, getHandler } from '@path/to/inboundTransaction'; | ||
|
||
// Create a context (ctx) with necessary dependencies | ||
|
||
const inboundTransactionHandler = getHandler(ctx, 0); | ||
|
||
// Subscribe to relevant Nostr events | ||
subscribeToNostrEvents(filter, inboundTransactionHandler); |
68 changes: 68 additions & 0 deletions
68
pages/wallet-provider/ledger/events/internal-transaction.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Internal Transaction Handler | ||
|
||
Handles internal transactions. | ||
|
||
## Overview | ||
|
||
This module provides the functionality to handle and process internal transactions initiated by users. | ||
|
||
## Dependencies | ||
|
||
- `@nostr-dev-kit/ndk`: Provides necessary types and filters for Nostr events. | ||
- `@lib/events`: Event-related constants and functions. | ||
- `@lib/transactions`: Transaction-related utilities and handlers. | ||
- `@lib/utils`: General utility functions. | ||
- `@prisma/client`: Prisma ORM client for database interactions. | ||
|
||
## Constants | ||
|
||
- `REPUBLISH_INTERVAL_MS`: Interval for republishing balance events. | ||
- `MAX_RETRIES`: Maximum number of retries for handling a transaction. | ||
|
||
## Filter | ||
|
||
- `filter`: The filter used to select relevant internal transactions. | ||
|
||
## Functions | ||
|
||
### `getHandler(ctx: Context, ntry: number): (nostrEvent: NostrEvent) => void` | ||
|
||
Returns the internal transaction handler function. | ||
|
||
#### Parameters | ||
|
||
- `ctx`: The context containing necessary information for transaction handling. | ||
- `ntry`: The number of retries for handling the transaction. | ||
|
||
#### Returns | ||
|
||
A function that handles internal transactions and initiates the necessary processes. | ||
|
||
### Handler Function | ||
|
||
#### Parameters | ||
|
||
- `nostrEvent`: The internal transaction Nostr event. | ||
|
||
#### Functionality | ||
|
||
1. Validates the sender's balance for each token. | ||
2. Initiates the transaction in the database. | ||
3. Manages balances for the sender's and receiver's accounts. | ||
4. Publishes corresponding success or error events. | ||
|
||
#### Retries | ||
|
||
- The handler supports a limited number of retries in case of failures. | ||
|
||
## Usage Example | ||
|
||
```typescript | ||
import { filter, getHandler } from '@path/to/internalTransactions'; | ||
|
||
// Create a context (ctx) with necessary dependencies | ||
|
||
const internalTransactionHandler = getHandler(ctx, 0); | ||
|
||
// Subscribe to relevant Nostr events | ||
subscribeToNostrEvents(filter, internalTransactionHandler); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.