Skip to content

Commit

Permalink
Merge pull request #59 from provenance-io/vmikulis/web-wallet/support…
Browse files Browse the repository at this point in the history
…-new-msgs

feat(message-types.ts): added new provenance exchange message types
  • Loading branch information
VigM-Figure authored Mar 22, 2024
2 parents 4902d88 + 8e5d3bf commit 0345ae9
Show file tree
Hide file tree
Showing 23 changed files with 1,091 additions and 30 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"clean": "rm -rf ./lib ./esm",
"commit": "npx cz",
"postbuild": "npm test && node ./scripts/checkCircularDeps.js",
"pull:protos": "bash ./scripts/pull_protos.sh v1.17.0",
"pull:protos": "bash ./scripts/pull_protos.sh v1.18.0-rc3",
"clean:protos": "rm -rf third_party/proto && rm -rf src/proto",
"prepare": "npm run build && husky install",
"tsc:esm": "tsc --module es2015 --outDir esm",
Expand Down Expand Up @@ -132,4 +132,4 @@
"path": "./node_modules/cz-conventional-changelog"
}
}
}
}
67 changes: 64 additions & 3 deletions src/types/message-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ import {
MsgTransferRequest,
MsgWithdrawRequest,
} from '../proto/provenance/marker/v1/tx_pb';
import {
MsgCommitFundsRequest,
MsgCreatePaymentRequest,
MsgAcceptPaymentRequest,
MsgRejectPaymentRequest,
MsgRejectPaymentsRequest,
MsgCancelPaymentsRequest,
MsgCreateAskRequest,
MsgCreateBidRequest,
MsgCancelOrderRequest,
} from '../proto/provenance/exchange/v1/tx_pb';
import {
MsgSetWithdrawAddress,
MsgWithdrawDelegatorReward,
Expand Down Expand Up @@ -115,7 +126,6 @@ import { PubKey } from '../proto/cosmos/crypto/secp256k1/keys_pb';

import { ExecuteMsg } from './schema/ats-smart-contract/execute_msg';
import { ExecuteMsg as DigitalCurrencyConsortiumExecuteMsg } from './schema/digital-currency-consortium/execute_msg';
import { CoinAsObject } from './layout';

export type SupportedMessageTypeNames =
| 'cosmos.authz.v1beta1.MsgGrant'
Expand Down Expand Up @@ -206,7 +216,17 @@ export type SupportedMessageTypeNames =
| 'provenance.metadata.v1.MsgWriteSessionRequest'
| 'provenance.name.v1.MsgBindNameRequest'
| 'provenance.name.v1.MsgDeleteNameRequest'
| 'tendermint.abci.Evidence';
| 'tendermint.abci.Evidence'
// Provenance Exchange
| 'provenance.exchange.v1.MsgCommitFundsRequest'
| 'provenance.exchange.v1.MsgCreatePaymentRequest'
| 'provenance.exchange.v1.MsgAcceptPaymentRequest'
| 'provenance.exchange.v1.MsgRejectPaymentRequest'
| 'provenance.exchange.v1.MsgRejectPaymentsRequest'
| 'provenance.exchange.v1.MsgCancelPaymentsRequest'
| 'provenance.exchange.v1.MsgCreateAskRequest'
| 'provenance.exchange.v1.MsgCreateBidRequest'
| 'provenance.exchange.v1.MsgCancelOrderRequest';

export type ReadableMessageNames =
| 'MsgGrant'
Expand Down Expand Up @@ -297,7 +317,17 @@ export type ReadableMessageNames =
| 'MsgWriteSessionRequest'
| 'MsgBindNameRequest'
| 'MsgDeleteNameRequest'
| 'Evidence';
| 'Evidence'
// Provenance Exchange
| 'MsgCommitFundsRequest'
| 'MsgCreatePaymentRequest'
| 'MsgAcceptPaymentRequest'
| 'MsgRejectPaymentRequest'
| 'MsgRejectPaymentsRequest'
| 'MsgCancelPaymentsRequest'
| 'MsgCreateAskRequest'
| 'MsgCreateBidRequest'
| 'MsgCancelOrderRequest';

export const TYPE_NAMES_READABLE_MAP: {
[key in ReadableMessageNames]: SupportedMessageTypeNames;
Expand Down Expand Up @@ -406,8 +436,29 @@ export const TYPE_NAMES_READABLE_MAP: {
MsgBindNameRequest: 'provenance.name.v1.MsgBindNameRequest',
MsgDeleteNameRequest: 'provenance.name.v1.MsgDeleteNameRequest',
Evidence: 'tendermint.abci.Evidence',
// Provenance Exchange
MsgCommitFundsRequest: 'provenance.exchange.v1.MsgCommitFundsRequest',
MsgCreatePaymentRequest: 'provenance.exchange.v1.MsgCreatePaymentRequest',
MsgAcceptPaymentRequest: 'provenance.exchange.v1.MsgAcceptPaymentRequest',
MsgRejectPaymentRequest: 'provenance.exchange.v1.MsgRejectPaymentRequest',
MsgRejectPaymentsRequest: 'provenance.exchange.v1.MsgRejectPaymentsRequest',
MsgCancelPaymentsRequest: 'provenance.exchange.v1.MsgCancelPaymentsRequest',
MsgCreateAskRequest: 'provenance.exchange.v1.MsgCreateAskRequest',
MsgCreateBidRequest: 'provenance.exchange.v1.MsgCreateBidRequest',
MsgCancelOrderRequest: 'provenance.exchange.v1.MsgCancelOrderRequest',
};

// Provenance Exchange
export type MsgCommitFundsRequestDisplay = MsgCommitFundsRequest.AsObject;
export type MsgCreatePaymentRequestDisplay = MsgCreatePaymentRequest.AsObject;
export type MsgAcceptPaymentRequestDisplay = MsgAcceptPaymentRequest.AsObject;
export type MsgRejectPaymentRequestDisplay = MsgRejectPaymentRequest.AsObject;
export type MsgRejectPaymentsRequestDisplay = MsgRejectPaymentsRequest.AsObject;
export type MsgCancelPaymentsRequestDisplay = MsgCancelPaymentsRequest.AsObject;
export type MsgCreateAskRequestDisplay = MsgCreateAskRequest.AsObject;
export type MsgCreateBidRequestDisplay = MsgCreateBidRequest.AsObject;
export type MsgCancelOrderRequestDisplay = MsgCancelOrderRequest.AsObject;

export type MsgSendDisplay = MsgSend.AsObject;
export type MsgVerifyInvariantDisplay = MsgVerifyInvariant.AsObject;
export type MsgSetWithdrawAddressDisplay = MsgSetWithdrawAddress.AsObject;
Expand Down Expand Up @@ -594,4 +645,14 @@ export const MESSAGE_PROTOS: { [key in SupportedMessageTypeNames]: typeof Messag
'provenance.name.v1.MsgBindNameRequest': MsgBindNameRequest,
'provenance.name.v1.MsgDeleteNameRequest': MsgDeleteNameRequest,
'tendermint.abci.Evidence': Evidence,
// Provenance Exchange
'provenance.exchange.v1.MsgCommitFundsRequest': MsgCommitFundsRequest,
'provenance.exchange.v1.MsgCreatePaymentRequest': MsgCreatePaymentRequest,
'provenance.exchange.v1.MsgAcceptPaymentRequest': MsgAcceptPaymentRequest,
'provenance.exchange.v1.MsgRejectPaymentRequest': MsgRejectPaymentRequest,
'provenance.exchange.v1.MsgRejectPaymentsRequest': MsgRejectPaymentsRequest,
'provenance.exchange.v1.MsgCancelPaymentsRequest': MsgCancelPaymentsRequest,
'provenance.exchange.v1.MsgCreateAskRequest': MsgCreateAskRequest,
'provenance.exchange.v1.MsgCreateBidRequest': MsgCreateBidRequest,
'provenance.exchange.v1.MsgCancelOrderRequest': MsgCancelOrderRequest,
};
52 changes: 52 additions & 0 deletions third_party/proto/provenance/exchange/v1/commitments.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";
package provenance.exchange.v1;

option go_package = "github.com/provenance-io/provenance/x/exchange";

option java_package = "io.provenance.exchange.v1";
option java_multiple_files = true;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

// Commitment contains information on committed funds.
message Commitment {
// account is the bech32 address string with the committed funds.
string account = 1;
// market_id is the numeric identifier of the market the funds are committed to.
uint32 market_id = 2;
// amount is the funds that have been committed by the account to the market.
repeated cosmos.base.v1beta1.Coin amount = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
}

// AccountAmount associates an account with a coins amount.
message AccountAmount {
option (gogoproto.goproto_stringer) = false;
// account is the bech32 address string of the account associated with the amount.
string account = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount is the funds associated with the address.
repeated cosmos.base.v1beta1.Coin amount = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
}

// MarketAmount associates a market with a coins amount.
message MarketAmount {
option (gogoproto.goproto_stringer) = false;
// market_id is the numeric identifier the amount has been committed to.
uint32 market_id = 1;
// amount is the funds associated with the address.
repeated cosmos.base.v1beta1.Coin amount = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
}

// NetAssetPrice is an association of assets and price used to record the value of things.
// It is related to the NetAssetValue message from the x/marker module, and is therefore often referred to as "a NAV".
message NetAssetPrice {
option (gogoproto.goproto_stringer) = false;
// assets is the volume and denom that has been bought or sold.
cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false];
// price is what was paid for the assets.
cosmos.base.v1beta1.Coin price = 2 [(gogoproto.nullable) = false];
}
135 changes: 134 additions & 1 deletion third_party/proto/provenance/exchange/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ message EventOrderExternalIDUpdated {
string external_id = 3;
}

// EventFundsCommitted is an event emitted when funds are committed to a market.
message EventFundsCommitted {
// account is the bech32 address string of the account.
string account = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// market_id is the numerical identifier of the market.
uint32 market_id = 2;
// amount is the coins string of the newly committed funds.
string amount = 3;
// tag is the string provided in the message causing this event.
string tag = 4;
}

// EventCommitmentReleased is an event emitted when funds are released from their commitment.
message EventCommitmentReleased {
// account is the bech32 address string of the account.
string account = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// market_id is the numerical identifier of the market.
uint32 market_id = 2;
// amount is the coins string of the funds that were released from commitment.
string amount = 3;
// tag is the string provided in the message causing this event.
string tag = 4;
}

// EventMarketWithdraw is an event emitted when a withdrawal of a market's collected fees is made.
message EventMarketWithdraw {
// market_id is the numerical identifier of the market.
Expand All @@ -98,21 +122,41 @@ message EventMarketDetailsUpdated {
}

// EventMarketEnabled is an event emitted when a market is enabled.
// Deprecated: This event is no longer used. It is replaced with EventMarketOrdersEnabled.
message EventMarketEnabled {
option deprecated = true;
// market_id is the numerical identifier of the market.
uint32 market_id = 1;
// updated_by is the account that enabled the market.
string updated_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventMarketDisabled is an event emitted when a market is disabled.
// Deprecated: This event is no longer used. It is replaced with EventMarketOrdersDisabled.
message EventMarketDisabled {
option deprecated = true;
// market_id is the numerical identifier of the market.
uint32 market_id = 1;
// updated_by is the account that disabled the market.
string updated_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventMarketOrdersEnabled is an event emitted when a market enables order creation.
message EventMarketOrdersEnabled {
// market_id is the numerical identifier of the market.
uint32 market_id = 1;
// updated_by is the account that updated the accepting_orders option.
string updated_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventMarketOrdersEnabled is an event emitted when a market disables order creation.
message EventMarketOrdersDisabled {
// market_id is the numerical identifier of the market.
uint32 market_id = 1;
// updated_by is the account that updated the accepting_orders option.
string updated_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventMarketUserSettleEnabled is an event emitted when a market's user_settle option is enabled.
message EventMarketUserSettleEnabled {
// market_id is the numerical identifier of the market.
Expand All @@ -129,6 +173,31 @@ message EventMarketUserSettleDisabled {
string updated_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventMarketCommitmentsEnabled is an event emitted when a market's accepting_commitments option is enabled.
message EventMarketCommitmentsEnabled {
// market_id is the numerical identifier of the market.
uint32 market_id = 1;
// updated_by is the account that updated the accepting_commitments option.
string updated_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventMarketCommitmentsDisabled is an event emitted when a market's accepting_commitments option is disabled.
message EventMarketCommitmentsDisabled {
// market_id is the numerical identifier of the market.
uint32 market_id = 1;
// updated_by is the account that updated the accepting_commitments option.
string updated_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventMarketIntermediaryDenomUpdated is an event emitted when a market updates its
// commitment_settlement_intermediary_denom field.
message EventMarketIntermediaryDenomUpdated {
// market_id is the numerical identifier of the market.
uint32 market_id = 1;
// updated_by is the account that updated the intermediary denom.
string updated_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventMarketPermissionsUpdated is an event emitted when a market's permissions are updated.
message EventMarketPermissionsUpdated {
// market_id is the numerical identifier of the market.
Expand Down Expand Up @@ -158,4 +227,68 @@ message EventMarketFeesUpdated {
}

// EventParamsUpdated is an event emitted when the exchange module's params have been updated.
message EventParamsUpdated {}
message EventParamsUpdated {}

// EventPaymentCreated is an event emitted when a payment is created.
message EventPaymentCreated {
// source is the account that created the Payment.
string source = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// source_amount is the coins amount string of the funds that the source will pay (to the target).
string source_amount = 2;
// target is the account that can accept the Payment.
string target = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// target_amount is the coins amount string of the funds that the target will pay (to the source).
string target_amount = 4;
// external_id is used along with the source to uniquely identify this Payment.
string external_id = 5;
}

// EventPaymentUpdated is an event emitted when a payment is updated.
message EventPaymentUpdated {
// source is the account that updated (and previously created) the Payment.
string source = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// source_amount is the coins amount string of the funds that the source will pay (to the target).
string source_amount = 2;
// old_target is the account that used to be able to accept the Payment (but not any more).
string old_target = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// new_target is the account that is now able to accept the Payment.
string new_target = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// target_amount is the coins amount string of the funds that the target will pay (to the source).
string target_amount = 5;
// external_id is used along with the source to uniquely identify this Payment.
string external_id = 6;
}

// EventPaymentAccepted is an event emitted when a payment is accepted.
message EventPaymentAccepted {
// source is the account that created the Payment.
string source = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// source_amount is the coins amount string of the funds that the source will pay (to the target).
string source_amount = 2;
// target is the account that accepted the Payment.
string target = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// target_amount is the coins amount string of the funds that the target will pay (to the source).
string target_amount = 4;
// external_id is used along with the source to uniquely identify this Payment.
string external_id = 5;
}

// EventPaymentRejected is an event emitted when a payment is rejected (by the target).
message EventPaymentRejected {
// source is the account that created the Payment.
string source = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// target is the account that rejected the Payment.
string target = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// external_id is used along with the source to uniquely identify this Payment.
string external_id = 3;
}

// EventPaymentCancelled is an event emitted when a payment is cancelled (by the source).
message EventPaymentCancelled {
// source is the account that cancelled (and created) the Payment.
string source = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// target is the account that could have accepted the Payment.
string target = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// external_id is used along with the source to uniquely identify this Payment.
string external_id = 3;
}
8 changes: 8 additions & 0 deletions third_party/proto/provenance/exchange/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ option java_package = "io.provenance.exchange.v1";
option java_multiple_files = true;

import "gogoproto/gogo.proto";
import "provenance/exchange/v1/commitments.proto";
import "provenance/exchange/v1/market.proto";
import "provenance/exchange/v1/orders.proto";
import "provenance/exchange/v1/params.proto";
import "provenance/exchange/v1/payments.proto";

// GenesisState is the data that should be loaded into the exchange module during genesis.
message GenesisState {
Expand All @@ -30,4 +32,10 @@ message GenesisState {

// last_order_id is the value of the last order id created.
uint64 last_order_id = 5;

// commitments are all of the commitments to create at genesis.
repeated Commitment commitments = 6 [(gogoproto.nullable) = false];

// payments are all the payments to create at genesis.
repeated Payment payments = 7 [(gogoproto.nullable) = false];
}
Loading

0 comments on commit 0345ae9

Please sign in to comment.