From d9c2be765799f65172fcbdb7b6fbace5e8314618 Mon Sep 17 00:00:00 2001 From: nfel Date: Sun, 18 May 2025 11:06:28 +0330 Subject: [PATCH] v2: changed gen contract flow Signed-off-by: nfel --- wallet/v1/msg.proto | 64 ++++++++++++++++----------------------------- wallet/v1/srv.proto | 6 +++-- 2 files changed, 27 insertions(+), 43 deletions(-) diff --git a/wallet/v1/msg.proto b/wallet/v1/msg.proto index 44cacc8..f5aa814 100644 --- a/wallet/v1/msg.proto +++ b/wallet/v1/msg.proto @@ -9,9 +9,7 @@ import "base/v1/msg.proto"; INTERNAL DATA */ -message InternalTransactionData { - int64 transaction_id = 1; -} +message InternalTransactionData { int64 transaction_id = 1; } /* Federation @@ -138,9 +136,7 @@ enum AssetType { ASSET_TYPE_NETWORK_GAS = 3; } -message AssetList { - repeated Asset list = 1; -} +message AssetList { repeated Asset list = 1; } message AssetFilter { repeated int64 ids = 1; @@ -153,7 +149,7 @@ message AssetFilter { optional bool can_deposit = 8; optional bool can_withdraw = 9; optional bool is_active = 10; - optional string search = 11; // Not yet implemented ! + optional string search = 11; // Not yet implemented ! } message AssetDiscountReq { @@ -185,9 +181,7 @@ message GetAssetReq { optional string code = 3; } -message AssetMeta { - PropertyMeta property = 1; -} +message AssetMeta { PropertyMeta property = 1; } message PropertyMeta { string description = 1; @@ -271,7 +265,8 @@ message UserBNPLReq { 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 int32 current_step = + 10; // Can be useful for admin to change the current step optional int64 asset_id = 11; } @@ -295,9 +290,7 @@ message BNPLInfo { string expires_at = 14; } -message BNPLList { - repeated BNPLInfo list = 1; -} +message BNPLList { repeated BNPLInfo list = 1; } /* Transaction @@ -437,9 +430,7 @@ message RedeemTokenRes { optional auth.v1.BankInfo bank_info = 10; optional string receipt = 11; } -message RedeemTokenResList { - repeated RedeemTokenRes list = 1; -} +message RedeemTokenResList { repeated RedeemTokenRes list = 1; } /* Utility: Get Public Key from national id @@ -450,9 +441,7 @@ message NationalIDReq { string national_id = 2; } -message PubKeyRes { - string pub_key = 1; -} +message PubKeyRes { string pub_key = 1; } /* Network Details @@ -478,9 +467,7 @@ message Network { string created_at = 11; } -message NetworkList { - repeated Network list = 1; -} +message NetworkList { repeated Network list = 1; } /* * Commission @@ -552,9 +539,7 @@ message IPGConfirmReq { string final_amount = 7; } -message IPGConfirmRes { - string receipt_link = 1; -} +message IPGConfirmRes { string receipt_link = 1; } message SaleManualReq { auth.v1.InternalIAM iam = 1; @@ -593,9 +578,18 @@ message BuyAssetReq { double amount_irt = 3; double amount_asset = 4; BuyAssetSide side = 5; - optional uint64 aggreement_id = 6; // Only in asset that require agreement contract - optional string discount_code = 7; - optional auth.v1.TFA tfa = 8; // This might be used in the future + optional string discount_code = 6; +} + +message DeclineBuyContractReq{ + auth.v1.InternalIAM iam = 1; + uint64 aggreement_id = 2; +} + +message ConfirmBuyAssetReq { + auth.v1.InternalIAM iam = 1; + uint64 aggreement_id = 2; // Only in asset that require agreement contract + optional auth.v1.TFA tfa = 3; // This might be used in the future } enum BuyAssetSide { @@ -604,16 +598,11 @@ enum BuyAssetSide { } message CalcBuyAssetRes { - // int64 id = 1; - // Wallet wallet = 1; - // Asset asset = 2; - // double amount = 4; BuyAssetSide side = 1; double calculated_irt_amount = 2; double calculated_asset_amount = 3; EffectiveCommission commission = 4; optional AssetDiscountRes discount_detail = 5; - // double buy_min_amount = 7; } message BuyAssetRes { @@ -631,13 +620,6 @@ enum ContractType { CONTRACT_TYPE_REDEEM = 3; } -message GenerateContractReq { - auth.v1.InternalIAM iam = 1; - int64 asset_id = 2; - int64 amount = 3; - ContractType contract_type = 4; - map metadata = 5; -} message ContractRes { string link = 1; diff --git a/wallet/v1/srv.proto b/wallet/v1/srv.proto index c7096f3..54b19e9 100644 --- a/wallet/v1/srv.proto +++ b/wallet/v1/srv.proto @@ -65,8 +65,10 @@ service WalletService { // --- Buy Asset --- rpc CalcBuyAsset(BuyAssetReq) returns (CalcBuyAssetRes); - rpc BuyAsset(BuyAssetReq) returns (BuyAssetRes); + rpc BuyAsset(ConfirmBuyAssetReq) returns (BuyAssetRes); // -- Contract -- - rpc GenerateContract(GenerateContractReq) returns (ContractRes); + rpc GenerateBuyContract(BuyAssetReq) returns (ContractRes); + rpc DeclineBuyContract(DeclineBuyContractReq) returns (base.v1.StatusRes); + // rpc GenerateMarketContract(MarketContractReq) returns (ContractRes); }