Skip to content

Commit

Permalink
Added README for Subscription Fee SC
Browse files Browse the repository at this point in the history
  • Loading branch information
psorinionut committed Feb 7, 2024
1 parent 28f93c7 commit 14e2856
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
31 changes: 31 additions & 0 deletions subscription-fee/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Subscription Fee Smart Contract

The Smart Contract provides a comprehensive set of functionalities for managing subscription services and fees on the MultiversX blockchain. It allows users to register services, subscribe to services, deposit funds, withdraw funds, and perform various other actions related to managing subscription services and fees.

The code consists of multiple modules and endpoints that handle various operations related to subscription services, fees, pair actions, among others.

Let's break down the key components and functionalities of the Smart Contract:

## Initialization

Defines the initialization function for setting up the SC with the mandatory variables.

## Service Module

Manages the registration, approval, and subscription of services. It also defines the structure of a service, including payment information and subscription epochs. The module allows the service provider to register or add extra services, unregister services, and the users to subscribe/unsubscribe to/from those said services.

## Fees Module

Handles the addition of accepted fee tokens, setting minimum deposit values, user deposits, and fund withdrawals.

## Common Storage Module

Contains storage mappers and views for various data storage and retrieval operations used by other modules.

## Pair Actions Module

Deals with pair related operations and price queries. Provides functions for adding/removing pair addresses and retrieving token prices.

## Subtract Payments Module

Handles the subtraction of payments for subscribed services. Uses a custom result type for successful or failed price queries, to have a more flexible code output.
3 changes: 3 additions & 0 deletions subscription-fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ pub trait SubscriptionFee:
.set_if_empty(min_stable_token_deposit_value);
self.add_accepted_fees_tokens(accepted_tokens);
}

#[upgrade]
fn upgrade(&self) {}
}
5 changes: 3 additions & 2 deletions subscription-fee/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
////////////////////////////////////////////////////

// Init: 1
// Endpoints: 20
// Endpoints: 21
// Async Callback (empty): 1
// Total number of exported functions: 22
// Total number of exported functions: 23

#![no_std]

Expand All @@ -22,6 +22,7 @@ multiversx_sc_wasm_adapter::endpoints! {
subscription_fee
(
init => init
upgrade => upgrade
addAcceptedFeesTokens => add_accepted_fees_tokens
setMinDepositValue => set_min_deposit_value
deposit => deposit
Expand Down

0 comments on commit 14e2856

Please sign in to comment.