-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add messages related to staking/delegation
- Loading branch information
1 parent
a48fa72
commit 4da00ba
Showing
6 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { PlainMessage } from "@bufbuild/protobuf"; | ||
import { CosmosStakingV1beta1MsgBeginRedelegate as ProtoMsgBeginRedelegate } from "cosmes/protobufs"; | ||
|
||
import { DeepPrettify } from "../../typeutils/prettify"; | ||
import { Adapter } from "./Adapter"; | ||
|
||
type Data = DeepPrettify<PlainMessage<ProtoMsgBeginRedelegate>>; | ||
|
||
export class MsgBeginRedelegate implements Adapter { | ||
private readonly data: Data; | ||
|
||
constructor(data: Data) { | ||
this.data = data; | ||
} | ||
|
||
public toProto() { | ||
return new ProtoMsgBeginRedelegate(this.data); | ||
} | ||
|
||
public toAmino() { | ||
return { | ||
type: "cosmos-sdk/MsgBeginRedelegate", | ||
value: { | ||
delegator_address: this.data.delegatorAddress, | ||
validator_src_address: this.data.validatorSrcAddress, | ||
validator_dst_address: this.data.validatorDstAddress, | ||
amount: this.data.amount, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { PlainMessage } from "@bufbuild/protobuf"; | ||
import { CosmosStakingV1beta1MsgDelegate as ProtoMsgDelegate } from "cosmes/protobufs"; | ||
|
||
import { DeepPrettify } from "../../typeutils/prettify"; | ||
import { Adapter } from "./Adapter"; | ||
|
||
type Data = DeepPrettify<PlainMessage<ProtoMsgDelegate>>; | ||
|
||
export class MsgDelegate implements Adapter { | ||
private readonly data: Data; | ||
|
||
constructor(data: Data) { | ||
this.data = data; | ||
} | ||
|
||
public toProto() { | ||
return new ProtoMsgDelegate(this.data); | ||
} | ||
|
||
public toAmino() { | ||
return { | ||
type: "cosmos-sdk/MsgDelegate", | ||
value: { | ||
delegator_address: this.data.delegatorAddress, | ||
validator_address: this.data.validatorAddress, | ||
amount: this.data.amount, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { PlainMessage } from "@bufbuild/protobuf"; | ||
import { CosmosStakingV1beta1MsgUndelegate as ProtoMsgUndelegate } from "cosmes/protobufs"; | ||
|
||
import { DeepPrettify } from "../../typeutils/prettify"; | ||
import { Adapter } from "./Adapter"; | ||
|
||
type Data = DeepPrettify<PlainMessage<ProtoMsgUndelegate>>; | ||
|
||
export class MsgUndelegate implements Adapter { | ||
private readonly data: Data; | ||
|
||
constructor(data: Data) { | ||
this.data = data; | ||
} | ||
|
||
public toProto() { | ||
return new ProtoMsgUndelegate(this.data); | ||
} | ||
|
||
public toAmino() { | ||
return { | ||
type: "cosmos-sdk/MsgUndelegate", | ||
value: { | ||
delegator_address: this.data.delegatorAddress, | ||
validator_address: this.data.validatorAddress, | ||
amount: this.data.amount, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { PlainMessage } from "@bufbuild/protobuf"; | ||
import { CosmosDistributionV1beta1MsgWithdrawDelegatorReward as ProtoMsgWithdrawDelegatorRewards } from "cosmes/protobufs"; | ||
|
||
import { DeepPrettify } from "../../typeutils/prettify"; | ||
import { Adapter } from "./Adapter"; | ||
|
||
type Data = DeepPrettify<PlainMessage<ProtoMsgWithdrawDelegatorRewards>>; | ||
|
||
export class MsgWithdrawDelegatorRewards implements Adapter { | ||
private readonly data: Data; | ||
private readonly isLegacy: boolean; | ||
|
||
constructor(data: Data, isLegacy = false) { | ||
this.data = data; | ||
this.isLegacy = isLegacy; | ||
} | ||
|
||
public toProto() { | ||
return new ProtoMsgWithdrawDelegatorRewards(this.data); | ||
} | ||
|
||
public toAmino() { | ||
return { | ||
type: this.isLegacy ? "distribution/MsgWithdrawDelegationReward" : "cosmos-sdk/MsgWithdrawDelegationReward", | ||
value: { | ||
validator_address: this.data.validatorAddress, | ||
delegator_address: this.data.delegatorAddress, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { PlainMessage } from "@bufbuild/protobuf"; | ||
import { CosmosDistributionV1beta1MsgWithdrawValidatorCommission as ProtoMsgWithdrawValidatorCommission } from "cosmes/protobufs"; | ||
|
||
import { DeepPrettify } from "../../typeutils/prettify"; | ||
import { Adapter } from "./Adapter"; | ||
|
||
type Data = DeepPrettify<PlainMessage<ProtoMsgWithdrawValidatorCommission>>; | ||
|
||
export class MsgWithdrawValidatorCommission implements Adapter { | ||
private readonly data: Data; | ||
|
||
constructor(data: Data) { | ||
this.data = data; | ||
} | ||
|
||
public toProto() { | ||
return new ProtoMsgWithdrawValidatorCommission(this.data); | ||
} | ||
|
||
public toAmino() { | ||
return { | ||
type: "cosmos-sdk/MsgWithdrawValidatorCommission", | ||
value: { | ||
validator_address: this.data.validatorAddress, | ||
}, | ||
}; | ||
} | ||
} |