Skip to content

Instantly share code, notes, and snippets.

@StEvUgnIn
Last active February 5, 2023 01:12
Show Gist options
  • Save StEvUgnIn/5f5a14b724b18ca06fe61342abd747c4 to your computer and use it in GitHub Desktop.
Save StEvUgnIn/5f5a14b724b18ca06fe61342abd747c4 to your computer and use it in GitHub Desktop.
classDiagram

Profile ..|> AccessControl
Library --* Presentation
Presentation ..|> IERC165
Presentation ..|> File
File ..|> Ownable
File ..|> Initializable
DataCap ..|> IDataCap
DataCap -- DataCapAPI

left to right direction

class Profile {
  +Public: constant bytes32 = keccak256("Public")
  +Host: constant bytes32 = keccak256("Host")
  +Speaker: constant bytes32 = keccak256("Speaker")

  #owner: address
  #names: mapping address => string memory
  #emails: mapping address => bytes memory
  #pictures: mapping address => bytes memory
  +roles: mapping address => Role
  +constructor(owner: address, bytes32 role)
  +setName(name: string calldata)
  +setEmail(email: bytes calldata)
  +setPicture(picture: bytes calldata)
}

class Library {
  #owner: address
  #contributors: mapping address => address[]
  #presentationsByAccount: mapping address => mapping uint256 => address
  #presentations: mapping uint256 => mapping uint256 => address
  #numPresentationsbyEpoch: mapping(uint256 => uint256)
  #epochs: uint256[]
  +constructor(owner: address)
  +setContributors(presentation: address, contributors: address[])
  +addContributor(presentation: address, contributor: address)
  +getEpochs(): uint256[]
  +get(epoch: uint256, num: uint256): address
  +getAll(): address[]
  +getAllByAccount(owner: address): address[]
  +range(startEpoch: uint256, endEpoch: uint256): address[]
  +add(piece_cid: bytes calldata, dealId: uint64, metadata: string calldata): address
  +update(presentation: address, piece_cid: bytes calldata, dealId: uint64)
  +remove(epoch: uint256, num: uint256)
  +numberOfPresentationsInEpoch(epoch: uint256): uint256
}

class DealProposal {
  piece_cid: bytes
  piece_size: uint64
  verified_deal: bool
  client: bytes
  provider: bytes
  label: string
  start_epoch: int64
  end_epoch: int64
  storage_price_per_epoch: BigInt
  provider_collateral: BigInt
  client_collateral: BigInt
}

class Presentation {
  #piece_cid: bytes
  #owner: address
  #metadata: string
  #ranking: uint256
  #votes: mapping address => uint8
  -length: uint256
  +VOTE_MIN: const uint8 = 1
  +VOTE_MAX: const uint8 = 10
  +constructor(owner: address, metadata: string calldata)
  +tokenURI(): string memory
  +updateRanking(grade: uint16)
  +getVote(voter: address): uint16
}

class File {
  +constructor()
  +initialize(...)
}

class Ownable
class Initializable

class DataCap {
    ...
}

class IDataCap {
    +name(): string memory

    +symbol(): string memory

    +totalSupply(): BigInt memory

    +balance(bytes memory addr): BigInt memory

    +allowance(DataCapTypes.GetAllowanceParams memory params): BigInt memory

    +transfer(DataCapTypes.TransferParams memory params): DataCapTypes.TransferReturn memory

    +transferFrom(DataCapTypes.TransferFromParams memory params): DataCapTypes.TransferFromReturn memory

    +increaseAllowance(DataCapTypes.IncreaseAllowanceParams memory params): BigInt memory

    +decreaseAllowance(DataCapTypes.DecreaseAllowanceParams memory params): BigInt memory

    +revokeAllowance(DataCapTypes.RevokeAllowanceParams memory params): BigInt memory

    +burn(DataCapTypes.BurnParams memory params): DataCapTypes.BurnReturn memory

    +burnFrom(DataCapTypes.BurnFromParams memory params): DataCapTypes.BurnFromReturn memory
}

class DataCapAPI {
    +name(): string memory

    +symbol(): string memory

    +totalSupply(): BigInt memory

    +balance(bytes memory addr): BigInt memory

    +allowance(DataCapTypes.GetAllowanceParams memory params): BigInt memory

    +transfer(DataCapTypes.TransferParams memory params): DataCapTypes.TransferReturn memory

    +transferFrom(DataCapTypes.TransferFromParams memory params): DataCapTypes.TransferFromReturn memory

    +increaseAllowance(DataCapTypes.IncreaseAllowanceParams memory params): BigInt memory

    +decreaseAllowance(DataCapTypes.DecreaseAllowanceParams memory params): BigInt memory

    +revokeAllowance(DataCapTypes.RevokeAllowanceParams memory params): BigInt memory

    +burn(DataCapTypes.BurnParams memory params): DataCapTypes.BurnReturn memory

    +burnFrom(DataCapTypes.BurnFromParams memory params): DataCapTypes.BurnFromReturn memory
}

class IERC165 {
  +supportsInterface(interfaceId: bytes4): bool
}

class DealRewarder {
  +cidSet: mapping bytes => bool
  +cidSizes: mapping bytes => uint
  +cidProviders: mapping bytes => mapping =>: uint64 bool

  +owner: address
  +CALL_ACTOR_ID: constant address  = 0xfe00000000000000000000000000000000000005
  +DEFAULT_FLAG: constant uint64 = 0x00000000
  +METHOD_SEND: constant uint64  = 0

  +constructor()
  +fund(unused: uint64) payable
  +addCID(cidraw: bytes calldata, size: uint)
  #policyOK(cidraw: bytes memory, provider: uint64): bool
  +authorizeData(cidraw: bytes memory, provider: uint64, size: uint)
  +claim_bounty(deal_id: uint64)
  +call_actor_id(method: uint64, value: uint256, flags: uint64, codec: uint64, params: bytes memory, id: uint64): (bool, int256, uint64, bytes memory)
  #send(actorID: uint64)
}

class FilecoinMarketConsumer {
  +dealLabel: string
  +dealClientActorId: uint64
  +dealProviderActorId: uint64
  +isDealActivated: bool
  +dealCommitment: MarketTypes.GetDealDataCommitmentReturn
  +dealTerm: MarketTypes.GetDealTermReturn
  +dealPricePerEpoch: MarketTypes.GetDealEpochPriceReturn
  +clientCollateral: MarketTypes.GetDealClientCollateralReturn
  +providerCollateral: MarketTypes.GetDealProviderCollateralReturn
  +activationStatus: MarketTypes.GetDealActivationReturn

  +storeAll(dealId: uint64)

  +storeDealLabel(dealId: uint64)
  +storeDealClient(dealId: uint64)
  +storeDealClientProvider(dealId: uint64)
  +storeDealCommitment(dealId: uint64)
  +storeDealTerm(dealId: uint64)
  +storeDealTotalPrice(dealId: uint64)
  +storeClientCollateral(dealId: uint64)
  +storeProviderCollateral(dealId: uint64)
  +storeDealVerificaton(dealId: uint64)
  +storeDealActivationStatus(dealId: uint64)
}
Loading
@StEvUgnIn
Copy link
Author

updated

@StEvUgnIn
Copy link
Author

StEvUgnIn commented Feb 4, 2023

Please refer to oop.md.

Thanks @WillDera.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment