DappConfig.sol

Overview

DappConfig.sol defines the DappConfig contract, which serves as the configuration manager for an individual decentralized application (DApp). Its primary role is to store and manage credit configuration parameters, including balances and limits related to token usage within the DApp. The contract ensures secure updates to these configurations and handles incoming token transfers, adjusting balances accordingly. It enforces access control to sensitive operations, allowing only authorized entities to modify the configuration data.

Contract: DappConfig

Purpose

The DappConfig contract maintains the credit configuration state for a single DApp instance. It provides mechanisms for initializing the configuration, updating credit balances, managing authorized public keys, and processing incoming token transfers. This contract is designed to interact primarily with the DappRoot entity (as the deployer and owner) and internal system messages for secure updates.

State Variables

Variable

Type

Visibility

Description

version

string constant

internal

Contract version identifier ("1.0.0").

_data

CreditConfig

internal

Stores credit configuration data including balances and limits.

_owner

address

internal

Owner address, set to a fixed address expected to be DappRoot.

_dapp_id

uint256

internal

Unique identifier for the DApp instance.

_authorityAddress

optional(address)

public

Optional address authorized to append new public keys.

_keys

uint256[]

public

Dynamic array storing authorized public keys.

Constructor

constructor (
    uint256 dapp_id,
    CreditConfig data,
    optional(address) authorityAddress
)

Methods

appendPubkey

function appendPubkey(uint256 pubkey) public senderIs(_authorityAddress.get()) accept

setNewConfig

function setNewConfig(int128 value) public internalMsg senderIs(address(this)) functionID(5)

setNewUnlimit

function setNewUnlimit(bool is_unlimit) public internalMsg senderIs(address(this))

receive (Fallback function)

receive() external

getDetails

function getDetails() external view returns(uint256 dapp_id, CreditConfig data)

Important Implementation Details

Interactions with Other System Components

Visual Diagram

classDiagram
class DappConfig {
-string version
-CreditConfig _data
-address _owner
-uint256 _dapp_id
-optional(address) _authorityAddress
-uint256[] _keys
+constructor(dapp_id, data, authorityAddress)
+appendPubkey()
+setNewConfig()
+setNewUnlimit()
+receive()
+getDetails()
}
DappConfig ..|> Modifiers

This class diagram highlights the main attributes and methods of the DappConfig contract, illustrating its role as a specialized configuration manager with secure update capabilities and token handling logic.