Skip to content

Commit

Permalink
added support for staking servicer message
Browse files Browse the repository at this point in the history
  • Loading branch information
omerlavanet committed Mar 15, 2022
1 parent e9241a7 commit 49cb8a8
Show file tree
Hide file tree
Showing 16 changed files with 651 additions and 535 deletions.
750 changes: 392 additions & 358 deletions docs/static/openapi.yml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions proto/servicer/stake_storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package lavanet.lava.servicer;

option go_package = "github.com/lavanet/lava/x/servicer/types";
import "servicer/stake_map.proto";
import "gogoproto/gogo.proto";

message StakeStorage {

StakeMap staked = 1;
StakeMap unstaking = 2;
repeated StakeMap staked = 1 [(gogoproto.nullable) = false];
repeated StakeMap unstaking = 2 [(gogoproto.nullable) = false];
}
32 changes: 16 additions & 16 deletions vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,20 @@ export default {
throw new SpVuexError('QueryClient:QueryStakedServicers', 'API Node Unavailable. Could not perform query: ' + e.message);
}
},
async sendMsgStakeServicer({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgProofOfWork({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient = await initTxClient(rootGetters);
const msg = await txClient.msgStakeServicer(value);
const msg = await txClient.msgProofOfWork(value);
const result = await txClient.signAndBroadcast([msg], { fee: { amount: fee,
gas: "200000" }, memo });
return result;
}
catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgStakeServicer:Init', 'Could not initialize signing client. Wallet is required.');
throw new SpVuexError('TxClient:MsgProofOfWork:Init', 'Could not initialize signing client. Wallet is required.');
}
else {
throw new SpVuexError('TxClient:MsgStakeServicer:Send', 'Could not broadcast Tx: ' + e.message);
throw new SpVuexError('TxClient:MsgProofOfWork:Send', 'Could not broadcast Tx: ' + e.message);
}
}
},
Expand All @@ -280,35 +280,35 @@ export default {
}
}
},
async sendMsgProofOfWork({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgStakeServicer({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient = await initTxClient(rootGetters);
const msg = await txClient.msgProofOfWork(value);
const msg = await txClient.msgStakeServicer(value);
const result = await txClient.signAndBroadcast([msg], { fee: { amount: fee,
gas: "200000" }, memo });
return result;
}
catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgProofOfWork:Init', 'Could not initialize signing client. Wallet is required.');
throw new SpVuexError('TxClient:MsgStakeServicer:Init', 'Could not initialize signing client. Wallet is required.');
}
else {
throw new SpVuexError('TxClient:MsgProofOfWork:Send', 'Could not broadcast Tx: ' + e.message);
throw new SpVuexError('TxClient:MsgStakeServicer:Send', 'Could not broadcast Tx: ' + e.message);
}
}
},
async MsgStakeServicer({ rootGetters }, { value }) {
async MsgProofOfWork({ rootGetters }, { value }) {
try {
const txClient = await initTxClient(rootGetters);
const msg = await txClient.msgStakeServicer(value);
const msg = await txClient.msgProofOfWork(value);
return msg;
}
catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgStakeServicer:Init', 'Could not initialize signing client. Wallet is required.');
throw new SpVuexError('TxClient:MsgProofOfWork:Init', 'Could not initialize signing client. Wallet is required.');
}
else {
throw new SpVuexError('TxClient:MsgStakeServicer:Create', 'Could not create message: ' + e.message);
throw new SpVuexError('TxClient:MsgProofOfWork:Create', 'Could not create message: ' + e.message);
}
}
},
Expand All @@ -327,18 +327,18 @@ export default {
}
}
},
async MsgProofOfWork({ rootGetters }, { value }) {
async MsgStakeServicer({ rootGetters }, { value }) {
try {
const txClient = await initTxClient(rootGetters);
const msg = await txClient.msgProofOfWork(value);
const msg = await txClient.msgStakeServicer(value);
return msg;
}
catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgProofOfWork:Init', 'Could not initialize signing client. Wallet is required.');
throw new SpVuexError('TxClient:MsgStakeServicer:Init', 'Could not initialize signing client. Wallet is required.');
}
else {
throw new SpVuexError('TxClient:MsgProofOfWork:Create', 'Could not create message: ' + e.message);
throw new SpVuexError('TxClient:MsgStakeServicer:Create', 'Could not create message: ' + e.message);
}
}
},
Expand Down
32 changes: 16 additions & 16 deletions vue/src/store/generated/lavanet/lava/lavanet.lava.servicer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,18 @@ export default {
},


async sendMsgStakeServicer({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgProofOfWork({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgStakeServicer(value)
const msg = await txClient.msgProofOfWork(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgStakeServicer:Init', 'Could not initialize signing client. Wallet is required.')
throw new SpVuexError('TxClient:MsgProofOfWork:Init', 'Could not initialize signing client. Wallet is required.')
}else{
throw new SpVuexError('TxClient:MsgStakeServicer:Send', 'Could not broadcast Tx: '+ e.message)
throw new SpVuexError('TxClient:MsgProofOfWork:Send', 'Could not broadcast Tx: '+ e.message)
}
}
},
Expand All @@ -336,32 +336,32 @@ export default {
}
}
},
async sendMsgProofOfWork({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgStakeServicer({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgProofOfWork(value)
const msg = await txClient.msgStakeServicer(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgProofOfWork:Init', 'Could not initialize signing client. Wallet is required.')
throw new SpVuexError('TxClient:MsgStakeServicer:Init', 'Could not initialize signing client. Wallet is required.')
}else{
throw new SpVuexError('TxClient:MsgProofOfWork:Send', 'Could not broadcast Tx: '+ e.message)
throw new SpVuexError('TxClient:MsgStakeServicer:Send', 'Could not broadcast Tx: '+ e.message)
}
}
},

async MsgStakeServicer({ rootGetters }, { value }) {
async MsgProofOfWork({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgStakeServicer(value)
const msg = await txClient.msgProofOfWork(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgStakeServicer:Init', 'Could not initialize signing client. Wallet is required.')
throw new SpVuexError('TxClient:MsgProofOfWork:Init', 'Could not initialize signing client. Wallet is required.')
}else{
throw new SpVuexError('TxClient:MsgStakeServicer:Create', 'Could not create message: ' + e.message)
throw new SpVuexError('TxClient:MsgProofOfWork:Create', 'Could not create message: ' + e.message)

}
}
Expand All @@ -380,16 +380,16 @@ export default {
}
}
},
async MsgProofOfWork({ rootGetters }, { value }) {
async MsgStakeServicer({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgProofOfWork(value)
const msg = await txClient.msgStakeServicer(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgProofOfWork:Init', 'Could not initialize signing client. Wallet is required.')
throw new SpVuexError('TxClient:MsgStakeServicer:Init', 'Could not initialize signing client. Wallet is required.')
}else{
throw new SpVuexError('TxClient:MsgProofOfWork:Create', 'Could not create message: ' + e.message)
throw new SpVuexError('TxClient:MsgStakeServicer:Create', 'Could not create message: ' + e.message)

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StdFee } from "@cosmjs/launchpad";
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgStakeServicer } from "./types/servicer/tx";
import { MsgUnstakeServicer } from "./types/servicer/tx";
import { MsgProofOfWork } from "./types/servicer/tx";
import { MsgUnstakeServicer } from "./types/servicer/tx";
import { MsgStakeServicer } from "./types/servicer/tx";
export declare const MissingWalletError: Error;
export declare const registry: Registry;
interface TxClientOptions {
Expand All @@ -15,9 +15,9 @@ interface SignAndBroadcastOptions {
}
declare const txClient: (wallet: OfflineSigner, { addr: addr }?: TxClientOptions) => Promise<{
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }?: SignAndBroadcastOptions) => any;
msgStakeServicer: (data: MsgStakeServicer) => EncodeObject;
msgUnstakeServicer: (data: MsgUnstakeServicer) => EncodeObject;
msgProofOfWork: (data: MsgProofOfWork) => EncodeObject;
msgUnstakeServicer: (data: MsgUnstakeServicer) => EncodeObject;
msgStakeServicer: (data: MsgStakeServicer) => EncodeObject;
}>;
interface QueryClientOptions {
addr: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgStakeServicer } from "./types/servicer/tx";
import { MsgUnstakeServicer } from "./types/servicer/tx";
import { MsgProofOfWork } from "./types/servicer/tx";
import { MsgUnstakeServicer } from "./types/servicer/tx";
import { MsgStakeServicer } from "./types/servicer/tx";
const types = [
["/lavanet.lava.servicer.MsgStakeServicer", MsgStakeServicer],
["/lavanet.lava.servicer.MsgUnstakeServicer", MsgUnstakeServicer],
["/lavanet.lava.servicer.MsgProofOfWork", MsgProofOfWork],
["/lavanet.lava.servicer.MsgUnstakeServicer", MsgUnstakeServicer],
["/lavanet.lava.servicer.MsgStakeServicer", MsgStakeServicer],
];
export const MissingWalletError = new Error("wallet is required");
export const registry = new Registry(types);
Expand All @@ -29,9 +29,9 @@ const txClient = async (wallet, { addr: addr } = { addr: "http://localhost:26657
const { address } = (await wallet.getAccounts())[0];
return {
signAndBroadcast: (msgs, { fee, memo } = { fee: defaultFee, memo: "" }) => client.signAndBroadcast(address, msgs, fee, memo),
msgStakeServicer: (data) => ({ typeUrl: "/lavanet.lava.servicer.MsgStakeServicer", value: MsgStakeServicer.fromPartial(data) }),
msgUnstakeServicer: (data) => ({ typeUrl: "/lavanet.lava.servicer.MsgUnstakeServicer", value: MsgUnstakeServicer.fromPartial(data) }),
msgProofOfWork: (data) => ({ typeUrl: "/lavanet.lava.servicer.MsgProofOfWork", value: MsgProofOfWork.fromPartial(data) }),
msgUnstakeServicer: (data) => ({ typeUrl: "/lavanet.lava.servicer.MsgUnstakeServicer", value: MsgUnstakeServicer.fromPartial(data) }),
msgStakeServicer: (data) => ({ typeUrl: "/lavanet.lava.servicer.MsgStakeServicer", value: MsgStakeServicer.fromPartial(data) }),
};
};
const queryClient = async ({ addr: addr } = { addr: "http://localhost:1317" }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { StdFee } from "@cosmjs/launchpad";
import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgStakeServicer } from "./types/servicer/tx";
import { MsgUnstakeServicer } from "./types/servicer/tx";
import { MsgProofOfWork } from "./types/servicer/tx";
import { MsgUnstakeServicer } from "./types/servicer/tx";
import { MsgStakeServicer } from "./types/servicer/tx";


const types = [
["/lavanet.lava.servicer.MsgStakeServicer", MsgStakeServicer],
["/lavanet.lava.servicer.MsgUnstakeServicer", MsgUnstakeServicer],
["/lavanet.lava.servicer.MsgProofOfWork", MsgProofOfWork],
["/lavanet.lava.servicer.MsgUnstakeServicer", MsgUnstakeServicer],
["/lavanet.lava.servicer.MsgStakeServicer", MsgStakeServicer],

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

return {
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo),
msgStakeServicer: (data: MsgStakeServicer): EncodeObject => ({ typeUrl: "/lavanet.lava.servicer.MsgStakeServicer", value: MsgStakeServicer.fromPartial( data ) }),
msgUnstakeServicer: (data: MsgUnstakeServicer): EncodeObject => ({ typeUrl: "/lavanet.lava.servicer.MsgUnstakeServicer", value: MsgUnstakeServicer.fromPartial( data ) }),
msgProofOfWork: (data: MsgProofOfWork): EncodeObject => ({ typeUrl: "/lavanet.lava.servicer.MsgProofOfWork", value: MsgProofOfWork.fromPartial( data ) }),
msgUnstakeServicer: (data: MsgUnstakeServicer): EncodeObject => ({ typeUrl: "/lavanet.lava.servicer.MsgUnstakeServicer", value: MsgUnstakeServicer.fromPartial( data ) }),
msgStakeServicer: (data: MsgStakeServicer): EncodeObject => ({ typeUrl: "/lavanet.lava.servicer.MsgStakeServicer", value: MsgStakeServicer.fromPartial( data ) }),

};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export interface ServicerStakeMap {
deadline?: ServicerBlockNum;
}
export interface ServicerStakeStorage {
staked?: ServicerStakeMap;
unstaking?: ServicerStakeMap;
staked?: ServicerStakeMap[];
unstaking?: ServicerStakeMap[];
}
export interface ServicerWorkProof {
data?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ export interface ServicerStakeMap {
}

export interface ServicerStakeStorage {
staked?: ServicerStakeMap;
unstaking?: ServicerStakeMap;
staked?: ServicerStakeMap[];
unstaking?: ServicerStakeMap[];
}

export interface ServicerWorkProof {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { StakeMap } from "../servicer/stake_map";
import { Writer, Reader } from "protobufjs/minimal";
export declare const protobufPackage = "lavanet.lava.servicer";
export interface StakeStorage {
staked: StakeMap | undefined;
unstaking: StakeMap | undefined;
staked: StakeMap[];
unstaking: StakeMap[];
}
export declare const StakeStorage: {
encode(message: StakeStorage, writer?: Writer): Writer;
Expand Down
Loading

0 comments on commit 49cb8a8

Please sign in to comment.