Skip to content

Commit

Permalink
Update drop proto to include accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Jun 9, 2024
1 parent d5c22ea commit 52f40ca
Show file tree
Hide file tree
Showing 12 changed files with 2,387 additions and 172 deletions.
292 changes: 274 additions & 18 deletions docs/static/openapi.yml

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions proto/market/drop.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,37 @@ message Drop {
uint64 uid = 1;
string owner = 2;
string pair = 3;
string drops = 4 [
bool active = 4;
string drops = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string product = 5 [
int64 time_beg = 6;
string coin1_beg = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin",
(gogoproto.nullable) = false
];
string coin2_beg = 8 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin",
(gogoproto.nullable) = false
];
string product_beg = 9 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
int64 time_end = 10;
string coin1_end = 11 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin",
(gogoproto.nullable) = false
];
string coin2_end = 12 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin",
(gogoproto.nullable) = false
];
bool active = 6;
string product_end = 13 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

message Drops {
Expand Down
22 changes: 22 additions & 0 deletions proto/market/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ message MsgCreatePool {
}

message MsgCreatePoolResponse {
string creator = 1;
uint64 drop_uid = 2;
string pair = 3;
string drops = 4;
string coin1 = 5;
string coin2 = 6;
}

message MsgCreateDrop {
Expand All @@ -32,6 +38,12 @@ message MsgCreateDrop {
}

message MsgCreateDropResponse {
string creator = 1;
uint64 uid = 2;
string pair = 3;
string drops = 4;
string coin1 = 5;
string coin2 = 6;
}

message MsgRedeemDrop {
Expand All @@ -40,6 +52,16 @@ message MsgRedeemDrop {
}

message MsgRedeemDropResponse {
string creator = 1;
uint64 uid = 2;
string pair = 3;
string drops = 4;
string time_beg = 5;
string coin1_beg = 6;
string coin2_beg = 7;
string time_end = 8;
string coin1_end = 9;
string coin2_end = 10;
}

message MsgCreateOrder {
Expand Down
4 changes: 2 additions & 2 deletions testutil/keeper/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ func MaxSupportedCoin(denom string) string {
return fmt.Sprintf("5192296858534827628530496329220095%s", denom)
}

// Equal to `MaxSupportedCoin` squared
// Equal to `MaxSupportedCoin`
func MaxSupportedDrop(denom string) string {
return fmt.Sprintf("26959946667150639794667015087019620289043427352885315420110951809025%s", denom)
return fmt.Sprintf("5192296858534827628530496329220095%s", denom)
}

// This is for funding an account capable of `MaxSupportedCoin`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,48 +915,48 @@ export default {
},


async sendMsgMarketOrder({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgCreateDrop({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgMarketOrder(value)
const msg = await txClient.msgCreateDrop(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgMarketOrder:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateDrop:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgMarketOrder:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgCreateDrop:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgCreatePool({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgMarketOrder({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreatePool(value)
const msg = await txClient.msgMarketOrder(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreatePool:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgMarketOrder:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgCreatePool:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgMarketOrder:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgRedeemDrop({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgCreateOrder({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgRedeemDrop(value)
const msg = await txClient.msgCreateOrder(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgRedeemDrop:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgRedeemDrop:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgCreateOrder:Send Could not broadcast Tx: '+ e.message)
}
}
},
Expand All @@ -975,73 +975,73 @@ export default {
}
}
},
async sendMsgCreateDrop({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgCreatePool({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateDrop(value)
const msg = await txClient.msgCreatePool(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateDrop:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreatePool:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgCreateDrop:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgCreatePool:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgCreateOrder({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgRedeemDrop({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateOrder(value)
const msg = await txClient.msgRedeemDrop(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgRedeemDrop:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgCreateOrder:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgRedeemDrop:Send Could not broadcast Tx: '+ e.message)
}
}
},

async MsgMarketOrder({ rootGetters }, { value }) {
async MsgCreateDrop({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgMarketOrder(value)
const msg = await txClient.msgCreateDrop(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgMarketOrder:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateDrop:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgMarketOrder:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreateDrop:Create Could not create message: ' + e.message)
}
}
},
async MsgCreatePool({ rootGetters }, { value }) {
async MsgMarketOrder({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreatePool(value)
const msg = await txClient.msgMarketOrder(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreatePool:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgMarketOrder:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgCreatePool:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgMarketOrder:Create Could not create message: ' + e.message)
}
}
},
async MsgRedeemDrop({ rootGetters }, { value }) {
async MsgCreateOrder({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgRedeemDrop(value)
const msg = await txClient.msgCreateOrder(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgRedeemDrop:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgRedeemDrop:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreateOrder:Create Could not create message: ' + e.message)
}
}
},
Expand All @@ -1058,29 +1058,29 @@ export default {
}
}
},
async MsgCreateDrop({ rootGetters }, { value }) {
async MsgCreatePool({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateDrop(value)
const msg = await txClient.msgCreatePool(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateDrop:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreatePool:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgCreateDrop:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreatePool:Create Could not create message: ' + e.message)
}
}
},
async MsgCreateOrder({ rootGetters }, { value }) {
async MsgRedeemDrop({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateOrder(value)
const msg = await txClient.msgRedeemDrop(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgRedeemDrop:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgCreateOrder:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgRedeemDrop:Create Could not create message: ' + e.message)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { StdFee } from "@cosmjs/launchpad";
import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgCreateDrop } from "./types/market/tx";
import { MsgMarketOrder } from "./types/market/tx";
import { MsgCreateOrder } from "./types/market/tx";
import { MsgCancelOrder } from "./types/market/tx";
import { MsgCreatePool } from "./types/market/tx";
import { MsgRedeemDrop } from "./types/market/tx";
import { MsgCancelOrder } from "./types/market/tx";
import { MsgCreateDrop } from "./types/market/tx";
import { MsgCreateOrder } from "./types/market/tx";


const types = [
["/pendulumlabs.market.market.MsgCreateDrop", MsgCreateDrop],
["/pendulumlabs.market.market.MsgMarketOrder", MsgMarketOrder],
["/pendulumlabs.market.market.MsgCreateOrder", MsgCreateOrder],
["/pendulumlabs.market.market.MsgCancelOrder", MsgCancelOrder],
["/pendulumlabs.market.market.MsgCreatePool", MsgCreatePool],
["/pendulumlabs.market.market.MsgRedeemDrop", MsgRedeemDrop],
["/pendulumlabs.market.market.MsgCancelOrder", MsgCancelOrder],
["/pendulumlabs.market.market.MsgCreateDrop", MsgCreateDrop],
["/pendulumlabs.market.market.MsgCreateOrder", MsgCreateOrder],

];
export const MissingWalletError = new Error("wallet is required");
Expand Down Expand Up @@ -51,12 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions =

return {
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo),
msgCreateDrop: (data: MsgCreateDrop): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreateDrop", value: MsgCreateDrop.fromPartial( data ) }),
msgMarketOrder: (data: MsgMarketOrder): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgMarketOrder", value: MsgMarketOrder.fromPartial( data ) }),
msgCreateOrder: (data: MsgCreateOrder): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreateOrder", value: MsgCreateOrder.fromPartial( data ) }),
msgCancelOrder: (data: MsgCancelOrder): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCancelOrder", value: MsgCancelOrder.fromPartial( data ) }),
msgCreatePool: (data: MsgCreatePool): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreatePool", value: MsgCreatePool.fromPartial( data ) }),
msgRedeemDrop: (data: MsgRedeemDrop): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgRedeemDrop", value: MsgRedeemDrop.fromPartial( data ) }),
msgCancelOrder: (data: MsgCancelOrder): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCancelOrder", value: MsgCancelOrder.fromPartial( data ) }),
msgCreateDrop: (data: MsgCreateDrop): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreateDrop", value: MsgCreateDrop.fromPartial( data ) }),
msgCreateOrder: (data: MsgCreateOrder): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreateOrder", value: MsgCreateOrder.fromPartial( data ) }),

};
};
Expand Down
Loading

0 comments on commit 52f40ca

Please sign in to comment.