APIs

This section elaborates on the transaction message handler methods being exposed by the House module.

Deposit

When a deposit transaction is processed, the following things happen:

  • Validate the incoming deposit message.

  • Call the Deposit method of the keeper.

RPC

The RPC for adding a market is as follows:

// Deposit defines a method for performing a deposit of coins to become part
// of the house corresponding to a market.
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);

Request Message

The request message for Deposit is MsgDeposit. The proto for the request message is as follows:

// MsgDeposit defines a SDK message for performing a deposit of coins to become
// part of the house corresponding to a market.
message MsgDeposit {
  option (gogoproto.equal) = false;
  option (gogoproto.goproto_getters) = false;

  // creator is the account who makes a deposit
  string creator = 1 [ (gogoproto.moretags) = "yaml:\"creator\"" ];
  // market_uid is the uid of market/order book against which deposit is being
  // made.
  string market_uid = 2 [
    (gogoproto.customname) = "MarketUID",
    (gogoproto.jsontag) = "market_uid",
    json_name = "market_uid"
  ];
  // amount is the amount being deposited on an order book to be a house
  string amount = 3 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.nullable) = false
  ];
  // ticket is the jwt ticket data.
  string ticket = 4;
}

Response Message

The response message for Deposit is MsgDepositResponse. The proto for the request message is as follows:

// MsgDepositResponse defines the Msg/Deposit response type.
message MsgDepositResponse {
  string market_uid = 1 [
    (gogoproto.customname) = "MarketUID",
    (gogoproto.jsontag) = "market_uid",
    json_name = "market_uid"
  ];

  uint64 participation_index = 2
      [ (gogoproto.moretags) = "yaml:\"participation_index\"" ];
}

Withdraw

When a withdrawal transaction is processed, the following things happen:

  • Validate the incoming deposit message.

  • Call the Deposit method of the keeper.

RPC

The RPC for adding a market is as follows:

// Withdraw defines a method for performing a withdrawal of coins of unused
// amount corresponding to a deposit.
rpc Withdraw(MsgWithdraw) returns (MsgWithdrawResponse);

Request Message

The request message for Withdraw is MsgWithdraw. The proto for the request message is as follows:

// MsgWithdraw defines a SDK message for performing a withdrawal of coins of
// unused amount corresponding to a deposit.
message MsgWithdraw {
  option (gogoproto.equal) = false;
  option (gogoproto.goproto_getters) = false;

  string creator = 1 [ (gogoproto.moretags) = "yaml:\"creator\"" ];
  string market_uid = 2 [
    (gogoproto.customname) = "MarketUID",
    (gogoproto.jsontag) = "market_uid",
    json_name = "market_uid"
  ];
  // participation_index is the index corresponding to the order book
  // participation
  uint64 participation_index = 3
      [ (gogoproto.moretags) = "yaml:\"participation_index\"" ];
  // mode is the withdrawal mode. It can be full or partial withdraw
  WithdrawalMode mode = 4 [ (gogoproto.moretags) = "yaml:\"mode\"" ];
  // amount is the requested withdrawal amount
  string amount = 5 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
    (gogoproto.nullable) = false
  ];
  // ticket is the jwt ticket data.
  string ticket = 6;
}

Response Message

The response message for Withdraw is MsgWithdrawResponse. The proto for the request message is as follows:

// MsgWithdrawResponse defines the Msg/Withdraw response type.
message MsgWithdrawResponse {
  uint64 id = 1 [
    (gogoproto.customname) = "ID",
    (gogoproto.jsontag) = "id",
    json_name = "id",
    (gogoproto.moretags) = "yaml:\"id\""
  ];

  string market_uid = 2 [
    (gogoproto.customname) = "MarketUID",
    (gogoproto.jsontag) = "market_uid",
    json_name = "market_uid"
  ];

  uint64 participation_index = 3
      [ (gogoproto.moretags) = "yaml:\"participation_index\"" ];
}

Last updated