@bandprotocol/bandchain.js
Version:
TypeScript library for Cosmos SDK and BandChain
77 lines (76 loc) • 2.51 kB
JavaScript
//@ts-nocheck
import { Coin } from "../../base/v1beta1/coin";
import { BinaryReader, BinaryWriter } from "../../../binary";
function createBaseSendAuthorization() {
return {
$typeUrl: "/cosmos.bank.v1beta1.SendAuthorization",
spendLimit: []
};
}
export const SendAuthorization = {
typeUrl: "/cosmos.bank.v1beta1.SendAuthorization",
encode(message, writer = BinaryWriter.create()) {
for (const v of message.spendLimit) {
Coin.encode(v, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSendAuthorization();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.spendLimit.push(Coin.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseSendAuthorization();
message.spendLimit = object.spendLimit?.map(e => Coin.fromPartial(e)) || [];
return message;
},
fromAmino(object) {
const message = createBaseSendAuthorization();
message.spendLimit = object.spend_limit?.map(e => Coin.fromAmino(e)) || [];
return message;
},
toAmino(message) {
const obj = {};
if (message.spendLimit) {
obj.spend_limit = message.spendLimit.map(e => e ? Coin.toAmino(e) : undefined);
}
else {
obj.spend_limit = message.spendLimit;
}
return obj;
},
fromAminoMsg(object) {
return SendAuthorization.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/SendAuthorization",
value: SendAuthorization.toAmino(message)
};
},
fromProtoMsg(message) {
return SendAuthorization.decode(message.value);
},
toProto(message) {
return SendAuthorization.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.bank.v1beta1.SendAuthorization",
value: SendAuthorization.encode(message).finish()
};
}
};