threefold.models_to_move.finance #
fn Account.new #
fn Account.new() Account
new creates a new Account with default values
fn Asset.new #
fn Asset.new() Asset
new creates a new Asset with default values
fn Bid.new #
fn Bid.new() Bid
new creates a new Bid with default values
fn Listing.new #
fn Listing.new() Listing
new creates a new Listing with default values
enum AssetType #
enum AssetType {
erc20 // ERC-20 token standard
erc721 // ERC-721 NFT standard
erc1155 // ERC-1155 Multi-token standard
native // Native blockchain asset (e.g., ETH, BTC)
}
AssetType defines the type of blockchain asset
enum BidStatus #
enum BidStatus {
active // Bid is active
accepted // Bid was accepted
rejected // Bid was rejected
cancelled // Bid was cancelled by the bidder
}
BidStatus defines the status of a bid on an auction listing
enum ListingStatus #
enum ListingStatus {
active // Listing is active and available
sold // Listing has been sold
cancelled // Listing was cancelled by the seller
expired // Listing has expired
}
ListingStatus defines the status of a marketplace listing
enum ListingType #
enum ListingType {
fixed_price // Fixed price sale
auction // Auction with bids
exchange // Exchange for other assets
}
ListingType defines the type of marketplace listing
struct Account #
struct Account {
pub mut:
id u32 // Unique account ID
name string // Internal name of the account for the user
user_id u32 // User ID of the owner of the account
description string // Optional description of the account
ledger string // Describes the ledger/blockchain where the account is located
address string // Address of the account on the blockchain
pubkey string // Public key
assets []u32 // List of asset IDs in this account
created_at u64 // Creation timestamp
updated_at u64 // Last update timestamp
}
Account represents a financial account owned by a user
fn (Account) name #
fn (mut a Account) name(name string) Account
name sets the name of the account (builder pattern)
fn (Account) user_id #
fn (mut a Account) user_id(user_id u32) Account
user_id sets the user ID of the account owner (builder pattern)
fn (Account) description #
fn (mut a Account) description(description string) Account
description sets the description of the account (builder pattern)
fn (Account) ledger #
fn (mut a Account) ledger(ledger string) Account
ledger sets the ledger/blockchain where the account is located (builder pattern)
fn (Account) address #
fn (mut a Account) address(address string) Account
address sets the address of the account on the blockchain (builder pattern)
fn (Account) pubkey #
fn (mut a Account) pubkey(pubkey string) Account
pubkey sets the public key of the account (builder pattern)
fn (Account) add_asset #
fn (mut a Account) add_asset(asset_id u32) Account
add_asset adds an asset to the account (builder pattern)
fn (Account) total_value #
fn (a Account) total_value() f64
total_value gets the total value of all assets in the account
Todo: implement actual calculation based on asset values
fn (Account) find_asset_by_name #
fn (a Account) find_asset_by_name(name string) ?Asset
find_asset_by_name finds an asset by name
Todo: implement when asset lookup is available
fn (Account) has_asset #
fn (a Account) has_asset(asset_id u32) bool
has_asset checks if the account contains a specific asset
fn (Account) remove_asset #
fn (mut a Account) remove_asset(asset_id u32)
remove_asset removes an asset from the account
struct Asset #
struct Asset {
pub mut:
id u32 // Unique asset ID
name string // Name of the asset
description string // Description of the asset
amount f64 // Amount of the asset
address string // Address of the asset on the blockchain or bank
asset_type AssetType // Type of the asset
decimals u8 // Number of decimals of the asset (default 18)
created_at u64 // Creation timestamp
updated_at u64 // Last update timestamp
}
Asset represents a digital asset or token
fn (Asset) name #
fn (mut a Asset) name(name string) Asset
name sets the name of the asset (builder pattern)
fn (Asset) description #
fn (mut a Asset) description(description string) Asset
description sets the description of the asset (builder pattern)
fn (Asset) amount #
fn (mut a Asset) amount(amount f64) Asset
amount sets the amount of the asset (builder pattern)
fn (Asset) address #
fn (mut a Asset) address(address string) Asset
address sets the address of the asset on the blockchain (builder pattern)
fn (Asset) asset_type #
fn (mut a Asset) asset_type(asset_type AssetType) Asset
asset_type sets the type of the asset (builder pattern)
fn (Asset) decimals #
fn (mut a Asset) decimals(decimals u8) Asset
decimals sets the number of decimals of the asset (builder pattern)
fn (Asset) formatted_amount #
fn (a Asset) formatted_amount() string
formatted_amount returns the formatted amount with proper decimal places
fn (Asset) transfer_to #
fn (mut a Asset) transfer_to(mut target Asset, amount f64) !
transfer_to transfers amount to another asset
struct Bid #
struct Bid {
pub mut:
listing_id string // ID of the listing this bid belongs to
bidder_id u32 // ID of the user who placed the bid
amount f64 // Bid amount
currency string // Currency of the bid
status BidStatus // Status of the bid
created_at u64 // When the bid was created
}
Bid represents a bid on an auction listing
fn (Bid) listing_id #
fn (mut b Bid) listing_id(listing_id string) Bid
listing_id sets the listing ID for the bid (builder pattern)
fn (Bid) bidder_id #
fn (mut b Bid) bidder_id(bidder_id u32) Bid
bidder_id sets the bidder ID for the bid (builder pattern)
fn (Bid) amount #
fn (mut b Bid) amount(amount f64) Bid
amount sets the amount for the bid (builder pattern)
fn (Bid) currency #
fn (mut b Bid) currency(currency string) Bid
currency sets the currency for the bid (builder pattern)
fn (Bid) status #
fn (mut b Bid) status(status BidStatus) Bid
status sets the status of the bid (builder pattern)
struct Listing #
struct Listing {
pub mut:
id u32 // Unique listing ID
title string // Title of the listing
description string // Description of the listing
asset_id string // ID of the asset being listed
asset_type AssetType // Type of the asset
seller_id string // ID of the user selling the asset
price f64 // Initial price for fixed price, or starting price for auction
currency string // Currency of the listing
listing_type ListingType // Type of listing (fixed_price, auction, exchange)
status ListingStatus // Status of the listing
expires_at ?u64 // Optional expiration date
sold_at ?u64 // Optional date when the item was sold
buyer_id ?string // Optional buyer ID
sale_price ?f64 // Optional final sale price
bids []Bid // List of bids for auction type listings
tags []string // Tags for the listing
image_url ?string // Optional image URL
created_at u64 // Creation timestamp
updated_at u64 // Last update timestamp
}
Listing represents a marketplace listing for an asset
fn (Listing) title #
fn (mut l Listing) title(title string) Listing
title sets the title of the listing (builder pattern)
fn (Listing) description #
fn (mut l Listing) description(description string) Listing
description sets the description of the listing (builder pattern)
fn (Listing) asset_id #
fn (mut l Listing) asset_id(asset_id string) Listing
asset_id sets the asset ID of the listing (builder pattern)
fn (Listing) asset_type #
fn (mut l Listing) asset_type(asset_type AssetType) Listing
asset_type sets the asset type of the listing (builder pattern)
fn (Listing) seller_id #
fn (mut l Listing) seller_id(seller_id string) Listing
seller_id sets the seller ID of the listing (builder pattern)
fn (Listing) price #
fn (mut l Listing) price(price f64) Listing
price sets the price of the listing (builder pattern)
fn (Listing) currency #
fn (mut l Listing) currency(currency string) Listing
currency sets the currency of the listing (builder pattern)
fn (Listing) listing_type #
fn (mut l Listing) listing_type(listing_type ListingType) Listing
listing_type sets the listing type (builder pattern)
fn (Listing) status #
fn (mut l Listing) status(status ListingStatus) Listing
status sets the status of the listing (builder pattern)
fn (Listing) expires_at #
fn (mut l Listing) expires_at(expires_at ?u64) Listing
expires_at sets the expiration date of the listing (builder pattern)
fn (Listing) image_url #
fn (mut l Listing) image_url(image_url ?string) Listing
image_url sets the image URL of the listing (builder pattern)
fn (Listing) add_bid #
fn (mut l Listing) add_bid(bid Bid) !
add_bid adds a bid to an auction listing
fn (Listing) highest_bid #
fn (l Listing) highest_bid() ?Bid
highest_bid gets the highest active bid
fn (Listing) buyer_id #
fn (mut l Listing) buyer_id(buyer_id string) Listing
buyer_id sets the buyer ID for completing a sale (builder pattern)
fn (Listing) sale_price #
fn (mut l Listing) sale_price(sale_price f64) Listing
sale_price sets the sale price for completing a sale (builder pattern)
fn (Listing) sold_at #
fn (mut l Listing) sold_at(sold_at ?u64) Listing
sold_at sets the sold date for completing a sale (builder pattern)
fn (Listing) complete_sale #
fn (mut l Listing) complete_sale() !
complete_sale completes a sale (fixed price or auction)
fn (Listing) cancel #
fn (mut l Listing) cancel() !
cancel cancels the listing
fn (Listing) check_expiration #
fn (mut l Listing) check_expiration()
check_expiration checks if the listing has expired and updates status if needed
fn (Listing) add_tag #
fn (mut l Listing) add_tag(tag string) Listing
add_tag adds a single tag to the listing (builder pattern)