Skip to content

Commit

Permalink
added distribute staking reward message
Browse files Browse the repository at this point in the history
  • Loading branch information
faneaatiku committed Apr 18, 2024
1 parent f11f7a3 commit d199ac8
Show file tree
Hide file tree
Showing 16 changed files with 981 additions and 83 deletions.
2 changes: 2 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34743,6 +34743,8 @@ definitions:
properties:
reward_id:
type: string
bze.v1.rewards.MsgDistributeStakingRewardsResponse:
type: object
bze.v1.rewards.MsgExitStakingResponse:
type: object
bze.v1.rewards.MsgJoinStakingResponse:
Expand Down
10 changes: 10 additions & 0 deletions proto/rewards/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ service Msg {
rpc JoinStaking(MsgJoinStaking) returns (MsgJoinStakingResponse);
rpc ExitStaking(MsgExitStaking) returns (MsgExitStakingResponse);
rpc ClaimStakingRewards(MsgClaimStakingRewards) returns (MsgClaimStakingRewardsResponse);
rpc DistributeStakingRewards(MsgDistributeStakingRewards) returns (MsgDistributeStakingRewardsResponse);
// this line is used by starport scaffolding # proto/tx/rpc
}

Expand Down Expand Up @@ -75,4 +76,13 @@ message MsgClaimStakingRewardsResponse {
string amount = 1;
}

message MsgDistributeStakingRewards {
string creator = 1;
string rewardId = 2;
string amount = 3;
}

message MsgDistributeStakingRewardsResponse {
}

// this line is used by starport scaffolding # proto/tx/message
108 changes: 68 additions & 40 deletions vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,33 +407,48 @@ export default {
},


async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgClaimStakingRewards(value)
const msg = await txClient.msgCreateTradingReward(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateTradingReward(value)
const msg = await txClient.msgCreateStakingReward(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgUpdateStakingReward(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message)
}
}
},
Expand All @@ -452,75 +467,88 @@ export default {
}
}
},
async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateStakingReward(value)
const msg = await txClient.msgExitStaking(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgUpdateStakingReward(value)
const msg = await txClient.msgClaimStakingRewards(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgDistributeStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgExitStaking(value)
const msg = await txClient.msgDistributeStakingRewards(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgDistributeStakingRewards:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgDistributeStakingRewards:Send Could not broadcast Tx: '+ e.message)
}
}
},

async MsgClaimStakingRewards({ rootGetters }, { value }) {
async MsgCreateTradingReward({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgClaimStakingRewards(value)
const msg = await txClient.msgCreateTradingReward(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message)
}
}
},
async MsgCreateTradingReward({ rootGetters }, { value }) {
async MsgCreateStakingReward({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateTradingReward(value)
const msg = await txClient.msgCreateStakingReward(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message)
}
}
},
async MsgUpdateStakingReward({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgUpdateStakingReward(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message)
}
}
},
Expand All @@ -537,42 +565,42 @@ export default {
}
}
},
async MsgCreateStakingReward({ rootGetters }, { value }) {
async MsgExitStaking({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreateStakingReward(value)
const msg = await txClient.msgExitStaking(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message)
}
}
},
async MsgUpdateStakingReward({ rootGetters }, { value }) {
async MsgClaimStakingRewards({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgUpdateStakingReward(value)
const msg = await txClient.msgClaimStakingRewards(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message)
}
}
},
async MsgExitStaking({ rootGetters }, { value }) {
async MsgDistributeStakingRewards({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgExitStaking(value)
const msg = await txClient.msgDistributeStakingRewards(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgDistributeStakingRewards:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgDistributeStakingRewards:Create Could not create message: ' + e.message)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ import { StdFee } from "@cosmjs/launchpad";
import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgClaimStakingRewards } from "./types/rewards/tx";
import { MsgCreateTradingReward } from "./types/rewards/tx";
import { MsgJoinStaking } from "./types/rewards/tx";
import { MsgCreateStakingReward } from "./types/rewards/tx";
import { MsgUpdateStakingReward } from "./types/rewards/tx";
import { MsgJoinStaking } from "./types/rewards/tx";
import { MsgExitStaking } from "./types/rewards/tx";
import { MsgClaimStakingRewards } from "./types/rewards/tx";
import { MsgDistributeStakingRewards } from "./types/rewards/tx";


const types = [
["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards],
["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward],
["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking],
["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward],
["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward],
["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking],
["/bze.v1.rewards.MsgExitStaking", MsgExitStaking],
["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards],
["/bze.v1.rewards.MsgDistributeStakingRewards", MsgDistributeStakingRewards],

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

return {
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo),
msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }),
msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }),
msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }),
msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }),
msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }),
msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }),
msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }),
msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }),
msgDistributeStakingRewards: (data: MsgDistributeStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgDistributeStakingRewards", value: MsgDistributeStakingRewards.fromPartial( data ) }),

};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface RewardsMsgCreateTradingRewardResponse {
reward_id?: string;
}

export type RewardsMsgDistributeStakingRewardsResponse = object;

export type RewardsMsgExitStakingResponse = object;

export type RewardsMsgJoinStakingResponse = object;
Expand Down

0 comments on commit d199ac8

Please sign in to comment.