v2: refactored proto

- Sale -> IPG
- Withdraw/Deposit IRT
- Buy Asset Added
- Removed redundant messages
- Cleanup docs

Signed-off-by: nfel <nfilsaraee@gmail.com>
This commit is contained in:
nfel 2025-04-29 12:52:24 +03:30
parent a5370200b5
commit c8f69b9310
Signed by: nfel
GPG Key ID: DCC0BF3F92B0D45F
2 changed files with 181 additions and 148 deletions

View File

@ -9,7 +9,9 @@ import "base/v1/msg.proto";
INTERNAL DATA INTERNAL DATA
*/ */
message InternalTransactionData { int64 transaction_id = 1; } message InternalTransactionData {
int64 transaction_id = 1;
}
/* /*
Federation Federation
@ -32,11 +34,46 @@ message GetFederationReq {
optional string ed_public_hash = 4; optional string ed_public_hash = 4;
} }
/*
Wallet
*/
message UserInitWalletReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
}
message WalletList {
repeated Wallet list = 1;
// optional base.v1.Pagination pagination = 2;
double available_balance = 3;
double locked_balance = 4;
double total_balance = 5;
}
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;
}
/* /*
Asset Asset
*/ */
message AssetList { repeated Asset list = 1; } message AssetList {
repeated Asset list = 1;
}
message Asset { message Asset {
int64 id = 1; int64 id = 1;
@ -77,6 +114,24 @@ message Asset {
bool is_locked = 36; bool is_locked = 36;
} }
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;
optional int64 supported_asset = 7;
optional double discount_amount = 8; // based of asset price and discount amount in req
}
message AssetPrice { message AssetPrice {
string updated_at = 1; string updated_at = 1;
double market_price = 2; double market_price = 2;
@ -88,7 +143,9 @@ message GetAssetReq {
optional string code = 3; optional string code = 3;
} }
message AssetMeta { PropertyMeta property = 1; } message AssetMeta {
PropertyMeta property = 1;
}
message PropertyMeta { message PropertyMeta {
string description = 1; string description = 1;
@ -104,6 +161,14 @@ message PropertyMeta {
string user_agreement_url = 11; string user_agreement_url = 11;
} }
// 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 BNPL - not really but close name
*/ */
@ -163,8 +228,7 @@ message UserBNPLReq {
optional float amount = 7; optional float amount = 7;
optional PaymentPeriodInfo payment_period = 8; optional PaymentPeriodInfo payment_period = 8;
optional bool has_agreed_contract = 9; optional bool has_agreed_contract = 9;
optional int32 current_step = optional int32 current_step = 10; // Can be useful for admin to change the current step
10; // Can be useful for admin to change the current step
optional int64 asset_id = 11; optional int64 asset_id = 11;
} }
@ -188,50 +252,8 @@ message BNPLInfo {
string expires_at = 14; string expires_at = 14;
} }
message BNPLList { repeated BNPLInfo list = 1; } message BNPLList {
repeated BNPLInfo list = 1;
/*
Wallet
*/
message WalletList {
repeated Wallet list = 1;
// optional base.v1.Pagination pagination = 2;
double available_balance = 3;
double locked_balance = 4;
double total_balance = 5;
}
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;
}
// Frozen Asset is asset locked due to reservation
message FrozenAsset {
uint64 id = 1;
int64 asset_id = 2;
int64 wallet_id = 4;
double amount = 5;
string created_at = 6;
string updated_at = 7;
optional string expires_at = 8;
}
message UserInitWalletReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
} }
/* /*
@ -314,20 +336,6 @@ message UserGetTransactionListReq {
optional string to_date = 16; optional string to_date = 16;
} }
/*
Buy
*/
message UserBuyAssetReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
double amount = 3;
}
/*
Sell
*/
/* /*
Transfer Transfer
*/ */
@ -348,59 +356,7 @@ message TransferAssetRes {
// TODO: Change to Asset // TODO: Change to Asset
int64 transaction_id = 3; int64 transaction_id = 3;
string transaction_hash = 4; string transaction_hash = 4;
} Asset asset = 5;
// represent the information regarding the withdraw in bank
message BalanceReq {
auth.v1.InternalIAM iam = 1;
auth.v1.BankInfo bank_info = 2; //BankInfo
}
message WithdrawReceipt { string code = 1; }
message DepositReq{
auth.v1.BankInfo bank_info = 1; //BankInfo
double amount = 2;
}
// represent the information regarding the sale of the token
message SaleGetTokenReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
double amount = 3;
optional uint64 discount_code = 4;
}
// represent the information regarding the ipg gateway
message SaleGetTokenRes {
string url = 1;
int64 unit_price = 2;
int64 total_price = 3;
double amount = 4;
string asset = 5;
optional uint64 discount_code = 6;
}
message SaleConfirmReq {
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 final_amount = 7;
optional uint64 discount_code = 8;
}
message SaleConfirmRes { string receipt_link = 1; }
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;
} }
/* /*
@ -438,14 +394,22 @@ message RedeemTokenRes {
optional auth.v1.BankInfo bank_info = 10; optional auth.v1.BankInfo bank_info = 10;
optional string receipt = 11; optional string receipt = 11;
} }
message RedeemTokenResList { repeated RedeemTokenRes list = 1; } message RedeemTokenResList {
repeated RedeemTokenRes list = 1;
}
message GetPublicKeyByNationalIDReq { /*
Utility: Get Public Key from national id
*/
message NationalIDReq {
auth.v1.InternalIAM iam = 1; auth.v1.InternalIAM iam = 1;
string national_id = 2; string national_id = 2;
} }
message GetPublicKeyByNationalIDRes { string pub_key = 1; } message PubKeyRes {
string pub_key = 1;
}
/* /*
Network Details Network Details
@ -471,8 +435,13 @@ message Network {
string created_at = 11; string created_at = 11;
} }
message NetworkList { repeated Network list = 1; } message NetworkList {
repeated Network list = 1;
}
/*
* Commission
* */
message Commission { message Commission {
uint64 id = 1; uint64 id = 1;
string name = 2; string name = 2;
@ -485,33 +454,91 @@ message Commission {
string created_at = 11; string created_at = 11;
} }
message LockAssetReq { /*
int64 asset_id = 1; * IPG - Internet Payment Gateway
double amount = 2; * 1. Get Token
auth.v1.InternalIAM iam = 3; * 2. Confirm
optional auth.v1.TFA tfa = 4; // if request is not internal * 3. Cancel
} * 4. [optional] check balance
* */
message AssetDiscountReq { // represent the information regarding the withdraw in bank
// message BalanceReq {
// auth.v1.InternalIAM iam = 1;
// auth.v1.BankInfo bank_info = 2; // BankInfo
// }
// represent the information regarding the sale of the token
message IPGGetTokenReq {
auth.v1.InternalIAM iam = 1; auth.v1.InternalIAM iam = 1;
string code = 2; int64 asset_id = 2;
int64 asset_id = 3; double amount = 3;
optional double amount = 4; // calculate discount amount optional uint64 discount_code = 4;
} }
message AssetDiscountRes { // represent the information regarding the ipg gateway
uint64 id = 1; message IPGGetTokenRes {
string code = 2; string url = 1;
string expires_at = 3; int64 unit_price = 2;
double static_amount = 4; int64 total_price = 3;
double percentage = 5; double amount = 4;
double max_amount = 6; string asset = 5;
optional int64 supported_asset = 7; optional uint64 discount_code = 6;
optional double discount_amount =
8; // based of asset price and discount amount in req
} }
message IRTReq { message IPGConfirmReq {
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 final_amount = 7;
}
message IPGConfirmRes {
string receipt_link = 1;
}
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; auth.v1.InternalIAM iam = 1;
double amount = 3; double amount = 3;
} }
message WithdrawIRTReq {
auth.v1.InternalIAM iam = 1;
double amount = 2;
int64 bank_info_id = 3;
}
message WithdrawIRTRes {
int64 transaction_id = 1;
int64 amount = 2;
string transaction_hash = 3;
}
message BuyAssetReq {
auth.v1.InternalIAM iam = 1;
int64 asset_id = 2;
double amount = 3;
optional uint64 discount_code = 4;
optional auth.v1.TFA tfa = 5; // This might be used in the future
}
message BuyAssetRes {
int64 id = 1;
}

View File

@ -15,7 +15,8 @@ service WalletService {
rpc GetNetworkList(base.v1.Empty) returns (NetworkList); rpc GetNetworkList(base.v1.Empty) returns (NetworkList);
rpc UserGetAssetList(base.v1.Empty) returns (AssetList); rpc GetAssetList(base.v1.Empty) returns (AssetList);
rpc UserGetAssetList(auth.v1.InternalIAM) returns (AssetList);
rpc AdminGetAssetList(base.v1.Empty) returns (AssetList); rpc AdminGetAssetList(base.v1.Empty) returns (AssetList);
rpc GetAsset(GetAssetReq) returns (Asset); rpc GetAsset(GetAssetReq) returns (Asset);
rpc GetAssetPrice(base.v1.IdReq) returns (AssetPrice); rpc GetAssetPrice(base.v1.IdReq) returns (AssetPrice);
@ -25,8 +26,11 @@ service WalletService {
rpc UserGetTransactionList(UserGetTransactionListReq) returns (TransactionList); rpc UserGetTransactionList(UserGetTransactionListReq) returns (TransactionList);
rpc SaleGetToken(SaleGetTokenReq) returns (SaleGetTokenRes); // Get Token from IPG is and internal api
rpc SaleConfirm(SaleConfirmReq) returns (SaleConfirmRes); rpc IPGGetToken(IPGGetTokenReq) returns (IPGGetTokenRes);
// IPG Confirm is a public api
rpc IPGConfirm(IPGConfirmReq) returns (IPGConfirmRes);
// Admin can increase user's balance as wish
rpc AdminManualSaleDeposit(SaleManualReq) returns (base.v1.StatusRes); rpc AdminManualSaleDeposit(SaleManualReq) returns (base.v1.StatusRes);
// BNPL // BNPL
@ -42,7 +46,7 @@ service WalletService {
rpc RedeemToken(RedeemTokenReq) returns (base.v1.StatusRes); rpc RedeemToken(RedeemTokenReq) returns (base.v1.StatusRes);
rpc RedeemTokenList(auth.v1.ReqWithIAMAndParams) returns (RedeemTokenResList); rpc RedeemTokenList(auth.v1.ReqWithIAMAndParams) returns (RedeemTokenResList);
rpc GetPublicKeyByNationalID(GetPublicKeyByNationalIDReq) returns (GetPublicKeyByNationalIDRes); rpc GetPublicKeyByNationalID(NationalIDReq) returns (PubKeyRes);
// Assets routing // Assets routing
rpc InternalTransferAsset(TransferAssetReq) returns (TransferAssetRes); rpc InternalTransferAsset(TransferAssetReq) returns (TransferAssetRes);
@ -53,7 +57,9 @@ service WalletService {
rpc AssetDiscount(AssetDiscountReq) returns (AssetDiscountRes); rpc AssetDiscount(AssetDiscountReq) returns (AssetDiscountRes);
// --- IRT --- // --- IRT ---
rpc WithdrawIRT(IRTReq) returns (base.v1.StatusRes); rpc WithdrawIRT(WithdrawIRTReq) returns (WithdrawIRTRes);
rpc DepositIRT(IRTReq) returns (base.v1.StatusRes); rpc DepositIRT(DepositIRTReq) returns (IPGGetTokenRes);
rpc BuyAsset(BuyAssetReq) returns (BuyAssetRes);
} }