Closed dawid-kruk closed 2 weeks ago
@dawid-kruk Did you find a solution to this?
@ppoliani Yes I did :) Below is code example:
export interface MsgExample {
duration: Duration | undefined;
}
export interface AminoMsgExample extends AminoMsg {
readonly type: "correct/Type";
readonly value: {
readonly duration: string,
};
}
"/abcd.abcd.abcd.MsgExample": {
aminoType: "correct/Type",
toAmino: ({
duration,
}: MsgExample): AminoMsgExample["value"] => ({
duration: duration?(duration.seconds * 1000000000 + duration.nanos).toString():"0",
}),
fromAmino: ({
duration,
}: AminoMsgExample["value"]): MsgExample => {
const durationInNanoseconds = parseInt(duration, 10);
const seconds = Math.floor(durationInNanoseconds / 1_000_000_000);
const nanos = durationInNanoseconds % 1_000_000_000;
return {
duration: {
seconds,
nanos,
},
}
},
}
Thanks @dawid-kruk I fell I'm having a similar issue https://github.com/cosmos/cosmjs/issues/1596 but can't get my head around it.
Hello, I have a big problem with amino converter for Duration type. Here is my proto definition of a message:
Here is my typescript type for protobuf signing:
Duration is of this type:
And here is my AminoMsgCreateVestingPool
Here i have my amino converter:
Here is error from the chain:
I know that i'm hardcoding duration conversion for now but i don't know how to do it correctly. I was trying passing objects, numbers and other formats to AminoMsgCreateVestingPool type. I don't know what I can do more. Thank's in advance!