PopCoinWallet.sol

Overview

PopCoinWallet.sol implements the PopCoinWallet smart contract, a core component managing wallet functionality within the PopCoin ecosystem. This contract handles ownership, value tracking, and interactions with related contracts such as PopCoinRoot and PopitGame. It supports minting tokens, managing candidate "popits" (game-related token-like entities), activating these popits, and lifecycle management including contract destruction.

The wallet tracks balances and candidate popits, interacts with the root contract for minting and readiness confirmations, and communicates with the game contract to synchronize state changes. It enforces permissions tied to the owner and root public keys and ensures operational safety by maintaining a minimum contract balance.


Contract: PopCoinWallet

Properties

Property

Type

Description

version

string constant

Contract version identifier ("1.0.0").

_popcoinroot

address

Address of the PopCoinRoot contract managing minting and readiness logic.

_name

string static

Static wallet name set at deployment.

_owner

address static

Static address of the wallet owner.

_root

address

Address of the root contract involved in verification.

_value

uint64

Total token value held by the wallet.

_popits_candidate

mapping(uint256 => uint64)

Mapping of candidate popits IDs to their associated values.

_popits_mbi

mapping(uint256 => uint64)

Mapping of candidate popits IDs to their mbi (possibly a metadata or state identifier).

_popitGame

address

Address of the PopitGame contract associated with this wallet.

_isReady

bool

Flag indicating whether the wallet is activated and ready for operations.

_root_pubkey

uint256

Public key of the root owner for permission control.

_mbiCurBase

uint64

Current base mbi value used for popit minting and validation.

_deployed

uint64

Sequence number of the block when deployed.


Constructor

constructor (
    TvmCell PopitGameCode,
    uint64 value,
    address popcoinroot,
    uint256 root_pubkey,
    uint64 mbiCur
)

Modifiers and Access Control


Public & External Methods

deleteCandidate

function deleteCandidate(uint256 index) public senderIs(_owner) accept;

addValue

function addValue(uint256 id, uint64 value, uint64 mbiCur) public onlyOwnerPubkey(_root_pubkey) accept;

addValuePopitGame

function addValuePopitGame(uint256 id, uint64 value, uint64 mbiCur) public senderIs(_popitGame) accept;

addValueOld

function addValueOld(uint64 value) public onlyOwnerPubkey(_root_pubkey) accept;

activatePopit

function activatePopit(uint256 id, uint16 indexRoot) public view senderIs(_owner) accept;

setReadyPopit

function setReadyPopit(uint256 index) public senderIs(_popcoinroot) accept;

activate

function activate() public view senderIs(_owner) accept;

setReady

function setReady() public senderIs(_popcoinroot) accept;

destroy

function destroy() public senderIs(_owner) accept;

destroyRoot

function destroyRoot() public onlyOwnerPubkey(_root_pubkey) accept;

destroyNode

function destroyNode() public senderIs(address(this)) accept;

Internal Methods

ensureBalance

function ensureBalance() private pure;

Fallback


Getters

getDetails

function getDetails() external view returns(
    address popcoinroot,
    string name,
    address owner,
    uint64 value,
    bool isReady,
    mapping(uint256 => uint64) popits_candidate,
    mapping(uint256 => uint64) popits_mbi,
    uint64 deployed
);

getVersion

function getVersion() external pure returns(string, string);

Important Implementation Details and Algorithms


Interaction with Other Contracts


Visual Diagram: Class Diagram of PopCoinWallet

classDiagram
class PopCoinWallet {
+string version
+address _popcoinroot
+string _name
+address _owner
+address _root
+uint64 _value
+mapping(uint256 => uint64) _popits_candidate
+mapping(uint256 => uint64) _popits_mbi
+address _popitGame
+bool _isReady
+uint256 _root_pubkey
+uint64 _mbiCurBase
+uint64 _deployed
+constructor()
+deleteCandidate()
+addValue()
+addValuePopitGame()
+addValueOld()
+activatePopit()
+setReadyPopit()
+ensureBalance()
+activate()
+setReady()
+destroy()
+destroyRoot()
+destroyNode()
+receive()
+getDetails()
+getVersion()
}