proto/wallet/v1/msg.proto
nfel 33dd406f16
v2: balance change added
Signed-off-by: nfel <nfilsaraee@gmail.com>
2025-08-13 14:37:28 +03:30

809 lines
17 KiB
Protocol Buffer

syntax = "proto3";
package wallet.v1;
import "auth/v1/msg.proto";
import "base/v1/msg.proto";
/*
INTERNAL DATA
*/
message InternalTransactionData {
int64 transaction_id = 1;
}
/*
Federation
*/
message Federation {
int64 id = 1;
int64 user_id = 2;
string ed_public = 3;
string ed_public_hash = 4;
int32 status = 5;
string created_at = 6;
string system_wallet_address = 7;
}
message GetFederationReq {
optional int64 federation_id = 1;
optional int64 user_id = 2;
optional string ed_public = 3;
optional string ed_public_hash = 4;
}
/*
Wallet
*/
message UserInitWalletReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
}
message WalletList {
repeated Wallet list = 1;
double available_balance = 3;
double locked_balance = 4;
double total_balance = 5;
uint32 page_no = 6;
uint32 page_size = 7;
uint32 total_count = 8;
}
message Wallet {
int64 id = 1;
int64 user_id = 2;
int64 asset_id = 3;
Asset asset_info = 4;
int64 federation_id = 5;
Federation federation_info = 6;
double balance = 7;
double frozen_balance = 8;
string updated_at = 9;
string created_at = 10;
string wallet_code = 11;
bool accepted_terms = 12;
bool is_locked = 13;
}
message BalanceReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
}
message CheckBalanceReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
double amount = 3; // Checks if user have enough balance
}
message BalanceRes {
double available_balance = 1;
double locked_balance = 2;
double total_balance = 3;
}
/*
Asset
*/
message Asset {
int64 id = 1;
string name = 2;
string code = 3;
string issuer = 4;
string network_code = 5;
int32 decimal = 6;
double max_supply = 7;
string image = 8;
string description = 9;
string url = 10;
// int64 buy_unit_price = 11;
double buy_min_amount = 12;
double buy_max_amount = 13;
bool is_active = 20;
bool can_buy = 21;
bool can_sell = 22;
bool can_deposit = 23;
bool can_withdraw = 24;
bool can_trade = 25;
string updated_at = 29;
string created_at = 30;
repeated string images = 31;
repeated string videos = 32;
AssetStatus status = 33;
AssetMeta meta = 34;
AssetTokenType token_type = 35;
AssetPrice price = 36;
bool is_base_asset = 37;
bool is_locked = 38;
AssetType type = 39;
}
enum AssetTokenType {
ASSET_NETWORK_TYPE_UNKNOWN = 0;
ASSET_NETWORK_TYPE_STELLAR_NATIVE = 1;
ASSET_NETWORK_TYPE_STELLAR_ALPHANUMERIC4 = 2;
ASSET_NETWORK_TYPE_STELLAR_ALPHANUMERIC12 = 3;
ASSET_NETWORK_TYPE_ERC20 = 4;
}
enum AssetStatus {
ASSET_STATUS_UNKNOWN = 0;
ASSET_STATUS_ACTIVE = 1;
ASSET_STATUS_INACTIVE = 2;
ASSET_STATUS_SOON = 3;
ASSET_STATUS_FINISHED = 4;
ASSET_STATUS_EVALUATION = 5;
ASSET_STATUS_SUSPENDED = 6;
}
enum AssetType {
ASSET_TYPE_UNKNOWN = 0;
ASSET_TYPE_PROJECT = 1;
ASSET_TYPE_CURRENCY = 2;
ASSET_TYPE_NETWORK_GAS = 3;
}
message AssetList {
repeated Asset list = 1;
uint32 page_no = 2;
uint32 page_size = 3;
uint32 total_count = 4;
}
message AssetFilter {
repeated int64 ids = 1;
repeated AssetType type = 2; // AssetType
repeated AssetType token_type = 3; // AssetType
repeated AssetStatus status = 4;
repeated string name = 5;
optional bool can_buy = 6;
optional bool can_sell = 7;
optional bool can_deposit = 8;
optional bool can_withdraw = 9;
optional bool can_trade = 10;
optional bool is_active = 11;
optional string search = 12; // Not yet implemented !
}
message AssetDiscountReq {
auth.v1.InternalIAM iam = 1;
string code = 2;
int64 asset_id = 3;
optional double amount = 4; // calculate discount amount
}
message AssetDiscountRes {
uint64 id = 1;
string code = 2;
string expires_at = 3;
double static_amount = 4;
double percentage = 5;
double max_amount = 6;
double effective_amount = 7; // based of asset price and discount amount in req
optional int64 supported_asset = 8;
}
message AssetPrice {
string updated_at = 1;
double market_price = 2;
double ico_price = 3;
}
message GetAssetReq {
optional int64 id = 1;
optional string code = 3;
}
message AssetMeta {
PropertyMeta property = 1;
}
message PropertyMeta {
string description = 1;
string builder_description = 2;
string white_paper_url = 3;
string expert_report_url = 4;
string project_catalog_url = 5;
string ownership_document_url = 6;
double total_area_meters = 7;
int32 total_unit_count = 8;
string usage_type = 9;
string completion_date = 10;
string user_agreement_url = 11;
float lat = 12;
float lng = 13;
string map_link = 14;
PropertyDetail detail = 15;
}
message PropertyDetail {
repeated Content badge = 1; // 2>
repeated Content content = 2; // 4>
}
message Content {
string label = 1;
string value = 2;
string value_type = 3;
}
// Used for both locking and releasing asset :)
message LockAssetReq {
int64 asset_id = 1;
double amount = 2;
auth.v1.InternalIAM iam = 3;
optional auth.v1.TFA tfa = 4; // if request is not internal
}
/*
BNPL - not really but close name
*/
message GetUserBNPLInfoReq {
auth.v1.InternalIAM iam = 1;
base.v1.IdReq id = 2;
}
enum BNPLPaymentsStatus {
PENDING_PAYMENT = 0;
PAID = 1;
OVER_DUE = 2;
NOT_STARTED = 3;
NOT_YET_DUE = 4;
CANCELED = 5;
REJECTED = 6;
}
message BNPLPayments {
uint64 id = 1;
double amount = 2;
double amount_irr = 7;
bool is_paid = 3;
string due_date = 4;
string settlement_date = 5;
BNPLPaymentsStatus status = 6;
}
message UserBNPLResp {
uint64 id = 1;
BNPLInfo bnpl = 2;
int32 current_step = 3;
optional float amount = 4;
optional PaymentPeriodInfo payment_period = 5;
optional bool accepted_terms = 6;
repeated BNPLPayments payments = 7;
optional string employee_id = 8;
optional auth.v1.Company company = 10;
auth.v1.InternalIAM iam = 11;
optional string updated_at = 12;
optional string created_at = 13;
Asset selected_asset = 14;
optional string rejection_reason = 15;
}
message UserBNPLReq {
uint64 id = 1;
int64 bnpl_id = 2;
optional string created_at = 3;
optional string employee_id = 4;
optional int64 company_id = 5;
auth.v1.InternalIAM iam = 6;
optional float amount = 7;
optional PaymentPeriodInfo payment_period = 8;
optional bool has_agreed_contract = 9;
optional int32 current_step = 10; // Can be useful for admin to change the current step
optional int64 asset_id = 11;
}
message PaymentPeriodInfo {
uint64 id = 1;
uint64 period = 2;
bool enabled = 3;
}
message BNPLInfo {
uint64 id = 1;
string description = 3;
repeated Asset supported_assets = 2;
optional bool enabled = 4;
float amount_start = 5;
float amount_end = 6;
float amount_steps = 7;
repeated PaymentPeriodInfo payment_period = 8;
repeated auth.v1.Company possible_companies = 11;
string updated_at = 12;
string created_at = 13;
string expires_at = 14;
}
message BNPLList {
repeated BNPLInfo list = 1;
uint32 page_no = 2;
uint32 page_size = 3;
uint32 total_count = 4;
}
/*
Transaction
*/
message TransactionList {
repeated Transaction list = 1;
uint32 page_no = 2;
uint32 page_size = 3;
uint32 total_count = 4;
}
enum TransactionType {
UNKNOWN = 0;
BUY = 1;
SELL = 2;
INTERNAL_TRANSFER = 3;
EXTERNAL_TRANSFER = 4;
REDEEM = 5;
TRUST_LINE = 6;
WAGE = 7;
EXTERNAL_DEPOSIT = 8;
INTERNAL_DEPOSIT = 9;
MARKETPLACE_BUY = 10;
MARKETPLACE_SELL = 11;
LOCK = 12;
IRT_DEPOSIT = 13;
IRT_WITHDRAWAL = 14;
COMMISSION = 15;
}
enum TransactionStatus {
UNDETERMINED = 0;
FAILED = -10;
SUSPENDED = -9;
CREATED = -1;
PENDING_TRX = 1;
SUCCESSFUL = 2;
PENDING_ADMIN = 3;
}
message Transaction {
int64 id = 1;
int64 asset_id = 2;
string asset_code = 3;
optional int64 from_user_id = 4;
optional auth.v1.UserIdentityBasic from_user_info = 5;
optional int64 from_federation_id = 6;
optional Federation from_federation_info = 7;
optional int64 to_user_id = 8;
optional auth.v1.UserIdentityBasic to_user_info = 9;
optional int64 to_federation_id = 10;
optional Federation to_federation_info = 11;
double amount = 12;
TransactionStatus status = 13;
TransactionType type = 14;
string updated_at = 15;
string created_at = 16;
string tracking_code = 17;
optional string trx_hash = 18;
optional string from_public_key = 19;
optional string to_public_key = 20;
double token_price = 21;
BalanceChange balance_change = 22;
}
enum BalanceChange{
NO_CHANGE = 0;
INCREASE = 1;
DECREASE = 2;
}
message TransactionListFilter {
auth.v1.InternalIAM iam = 1;
optional uint32 page_no = 2;
optional uint32 page_size = 3;
optional int64 id = 4;
optional int64 asset_id = 5;
optional int64 from_user_id = 6;
optional int64 from_federation_id = 7;
optional int64 to_user_id = 8;
optional int64 to_federation_id = 9;
optional double amount_from = 10;
optional double amount_to = 11;
optional string tracking_code = 12;
repeated TransactionType type = 13;
repeated TransactionStatus status = 14;
optional string from_date = 15;
optional string to_date = 16;
}
/*
Transfer
*/
message TransferAssetReq {
auth.v1.InternalIAM iam = 1;
auth.v1.Recipient recipient = 2;
double amount = 3;
optional int64 network_id = 4;
int64 asset_id = 5;
optional bool approval = 6;
optional auth.v1.TFA tfa = 7;
}
message TransferAssetRes {
auth.v1.Recipient recipient = 1;
double amount = 2;
// TODO: Change to Asset
int64 transaction_id = 3;
string transaction_hash = 4;
Asset asset = 5;
}
/*
Redeem Token
*/
message RedeemTokenReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
uint64 bank_info_id = 3;
double amount = 4;
optional string tfa_code = 5;
}
message CalculateRedeemTokenRes {
Asset asset = 1;
double free_balance = 2;
double total_balance = 3;
double request_amount = 4;
double profit_capital = 5;
double user_capital = 6;
optional auth.v1.BankInfo bank_info = 7;
}
message RedeemTokenRes {
uint64 id = 1;
int64 user_id = 2;
Asset asset = 3;
double free_balance = 4;
double total_balance = 5;
double request_amount = 6;
string created_at = 7;
bool is_paid = 8;
// receipt.Receipt receipt = 8;
double calculated_profit = 9;
optional auth.v1.BankInfo bank_info = 10;
optional string receipt = 11;
}
message RedeemTokenResList {
repeated RedeemTokenRes list = 1;
uint32 page_no = 2;
uint32 page_size = 3;
uint32 total_count = 4;
}
/*
Utility: Get Public Key from national id
*/
message NationalIDReq {
auth.v1.InternalIAM iam = 1;
string national_id = 2;
}
message PubKeyRes {
string pub_key = 1;
}
/*
Network Details
*/
enum NetworkType {
UNKNOWN_NETWORK_TYPE = 0;
ETH = 1;
XLM = 2;
BTC = 3;
}
message Network {
int64 id = 1;
string name = 2;
string code = 3;
string explorer = 4;
int64 gas_asset_id = 5;
string description = 6;
NetworkType type = 7;
bool is_active = 8;
string image = 9;
string updated_at = 10;
string created_at = 11;
}
message NetworkList {
repeated Network list = 1;
uint32 page_no = 2;
uint32 page_size = 3;
uint32 total_count = 4;
}
/*
* Commission
* */
enum CommissionType {
COMMISSION_TYPE_ICO = 0;
COMMISSION_TYPE_MARKET_MAKER = 1;
COMMISSION_TYPE_MARKET_TAKER = 2;
COMMISSION_TYPE_BNPL = 3;
COMMISSION_TYPE_REDEEM = 4;
}
message Commission {
uint64 id = 1;
string name = 2;
double service_static = 3;
double service_percentage = 4;
double tax_static = 5;
double tax_percentage = 6;
Asset asset = 7;
CommissionType type = 8;
optional string collector = 9;
optional string description = 10;
string updated_at = 11;
string created_at = 12;
}
message CommissionList {
repeated Commission list = 1;
uint32 page_no = 2;
uint32 page_size = 3;
uint32 total_count = 4;
}
message EffectiveCommission {
double service = 1;
double tax = 2;
double total = 3;
}
message RefundCommissionReq {
auth.v1.UserIdentityBasic user = 3;
uint64 commission_log_id = 1;
}
message CommissionReq {
uint64 commission_id = 1;
double amount = 2;
auth.v1.UserIdentityBasic user = 3;
}
message CommissionRes {
uint64 commission_log_id = 1;
}
/*
* IPG - Internet Payment Gateway
* 1. Get Token
* 2. Confirm
* 3. Cancel
* 4. [optional] check balance
* */
// represent the information regarding the withdraw in bank
// message BalanceReq {
// auth.v1.InternalIAM iam = 1;
// auth.v1.BankInfo bank_info = 2; // BankInfo
// }
enum AccountingType {
ACCOUNTING_TYPE_WITHDRAW = 0;
// Deposits
ACCOUNTING_TYPE_DEPOSIT_IPG = 10;
ACCOUNTING_TYPE_DEPOSIT_BANK_ACCOUNT = 11;
ACCOUNTING_TYPE_DEPOSIT_IBAN = 12;
ACCOUNTING_TYPE_DEPOSIT_CARD = 13;
ACCOUNTING_TYPE_DEPOSIT_DIRECT_DEBIT = 14;
// Withdraw
ACCOUNTING_TYPE_WITHDRAW_IBAN = 20; // User request to receive irt via iban
ACCOUNTING_TYPE_WITHDRAW_CARD = 21; // User request to receive irt via card no
ACCOUNTING_TYPE_WITHDRAW_BANK_ACCOUNT = 22; // User request to receive irt via bank
ACCOUNTING_TYPE_WITHDRAW_IPG_REFUND = 23;
// ???
}
enum AccountingStatus {
ACCOUNTING_STATUS_UNKNOWN = 0;
ACCOUNTING_STATUS_CREATED = 1;
ACCOUNTING_STATUS_PENDING = 2;
ACCOUNTING_STATUS_SUCCESS = 3;
ACCOUNTING_STATUS_FAILED = 4;
ACCOUNTING_STATUS_CANCELLED = 5;
ACCOUNTING_STATUS_REJECTED = 6;
}
enum IPGStatus {
IPG_SUCCESS = 0;
IPG_FAILED = -1;
IPG_PENDING = 1;
}
// represent the information regarding the sale of the token
message IPGGetTokenReq {
auth.v1.InternalIAM iam = 1;
double amount = 2;
repeated string allowed_card_numbers = 3;
}
// represent the information regarding the ipg gateway
message IPGGetTokenRes {
string url = 1;
int64 amount = 2;
}
message IPGConfirmReq {
string redirected_url = 1; // This field includes all of ipg's query params
// string ref_id = 1;
// string res_code = 2;
// string sale_order_id = 3;
// string sale_reference_id = 4;
// string card_holder_info = 5;
// string card_holder_pan = 6;
// string amount = 7;
}
message WithdrawLog {
uint64 id = 1;
Accounting accounting = 2;
string rrn = 3;
int64 amount = 4;
AccountingStatus status = 5;
string created_at = 6;
string updated_at = 7;
optional Transaction transaction = 8;
optional auth.v1.BankInfo bankinfo_id = 10;
optional bool accepted_by_admin = 11;
}
enum PSP {
PSP_UNKNOWN = 0;
PSP_VANDAR_BP_MELLAT = 10;
PSP_VANDAR_SEP = 11;
PSP_VANDAR = 12;
PSP_BP_MELLAT = 20;
}
message Accounting {
uint64 id = 1;
int64 user_id = 2;
int64 balance = 3;
auth.v1.User user = 4;
}
message IPGGenTokenPayload {
int64 amount = 2;
string payer_id = 3;
string mobile = 4;
string national_id = 5;
int64 order_id = 6;
string callback_url = 7;
repeated string bank_cards = 8;
}
message IPGLog {
string ref_id = 1;
Accounting accounting = 2;
int64 amount = 4;
AccountingStatus status = 5;
string created_at = 6;
string updated_at = 7;
string token = 8;
PSP psp = 9;
optional int64 transaction_id = 10;
optional Transaction transaction = 11;
}
message IPGLogReq {
auth.v1.InternalIAM iam = 1;
string ref_id = 2;
}
message IPGConfirmRes {
string ref_id = 1;
optional string error = 2;
}
message SaleManualReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
double amount = 3;
string paid_at = 4;
string rrn = 5;
string national_id = 6;
optional uint64 discount_code = 7;
}
/* IRT
*
* */
message DepositIRTReq {
auth.v1.InternalIAM iam = 1;
double amount = 3;
}
message WithdrawIRTReq {
auth.v1.InternalIAM iam = 1;
double amount = 2;
int64 bank_info_id = 3;
auth.v1.TFA tfa = 4;
}
message WithdrawIRTRes {
uint64 id = 1;
int64 amount = 2;
string transaction_hash = 3;
auth.v1.BankInfo bank_info = 4;
}
message BuyAssetReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
double amount_irt = 3;
double amount_asset = 4;
BuyAssetSide side = 5;
optional string discount_code = 6;
}
message DeclineBuyContractReq {
auth.v1.InternalIAM iam = 1;
uint64 agreement_id = 2;
}
message ConfirmBuyAssetReq {
auth.v1.InternalIAM iam = 1;
uint64 agreement_id = 2; // Only in asset that require agreement contract
optional auth.v1.TFA tfa = 3; // This might be used in the future
}
enum BuyAssetSide {
BUY_ASSET_FROM_BASE = 0;
BUY_ASSET_TO_BASE = 1;
}
message CalcBuyAssetRes {
BuyAssetSide side = 1;
double calculated_irt_amount = 2;
double calculated_asset_amount = 3;
EffectiveCommission commission = 4;
optional AssetDiscountRes discount_detail = 5;
}
message BuyAssetRes {
bool success = 1;
string irt_hash = 2;
string asset_hash = 3;
}
/* Contract */
enum ContractType {
CONTRACT_TYPE_ICO = 0;
CONTRACT_TYPE_MARKET = 1; // FIXME: Please remove this :)
CONTRACT_TYPE_BNPL = 2;
CONTRACT_TYPE_REDEEM = 3;
CONTRACT_TYPE_MARKET_MAKER = 4;
CONTRACT_TYPE_MARKET_TAKER = 5;
}
// agreement_id
message ContractRes {
string link = 1;
uint64 agreement_id = 2;
uint64 transaction_id = 3;
string contract_hash = 4;
string contract_content = 5;
}