"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransferAuthorization = exports.Allocation = void 0;
//@ts-nocheck
const coin_1 = require("../../../../cosmos/base/v1beta1/coin");
const binary_1 = require("../../../../binary");
const registry_1 = require("../../../../registry");
function createBaseAllocation() {
return {
sourcePort: "",
sourceChannel: "",
spendLimit: [],
allowList: [],
allowedPacketData: []
};
}
exports.Allocation = {
typeUrl: "/ibc.applications.transfer.v1.Allocation",
aminoType: "cosmos-sdk/Allocation",
is(o) {
return o && (o.$typeUrl === exports.Allocation.typeUrl || typeof o.sourcePort === "string" && typeof o.sourceChannel === "string" && Array.isArray(o.spendLimit) && (!o.spendLimit.length || coin_1.Coin.is(o.spendLimit[0])) && Array.isArray(o.allowList) && (!o.allowList.length || typeof o.allowList[0] === "string") && Array.isArray(o.allowedPacketData) && (!o.allowedPacketData.length || typeof o.allowedPacketData[0] === "string"));
},
isSDK(o) {
return o && (o.$typeUrl === exports.Allocation.typeUrl || typeof o.source_port === "string" && typeof o.source_channel === "string" && Array.isArray(o.spend_limit) && (!o.spend_limit.length || coin_1.Coin.isSDK(o.spend_limit[0])) && Array.isArray(o.allow_list) && (!o.allow_list.length || typeof o.allow_list[0] === "string") && Array.isArray(o.allowed_packet_data) && (!o.allowed_packet_data.length || typeof o.allowed_packet_data[0] === "string"));
},
isAmino(o) {
return o && (o.$typeUrl === exports.Allocation.typeUrl || typeof o.source_port === "string" && typeof o.source_channel === "string" && Array.isArray(o.spend_limit) && (!o.spend_limit.length || coin_1.Coin.isAmino(o.spend_limit[0])) && Array.isArray(o.allow_list) && (!o.allow_list.length || typeof o.allow_list[0] === "string") && Array.isArray(o.allowed_packet_data) && (!o.allowed_packet_data.length || typeof o.allowed_packet_data[0] === "string"));
},
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.sourcePort !== "") {
writer.uint32(10).string(message.sourcePort);
}
if (message.sourceChannel !== "") {
writer.uint32(18).string(message.sourceChannel);
}
for (const v of message.spendLimit) {
coin_1.Coin.encode(v, writer.uint32(26).fork()).ldelim();
}
for (const v of message.allowList) {
writer.uint32(34).string(v);
}
for (const v of message.allowedPacketData) {
writer.uint32(42).string(v);
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAllocation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.sourcePort = reader.string();
break;
case 2:
message.sourceChannel = reader.string();
break;
case 3:
message.spendLimit.push(coin_1.Coin.decode(reader, reader.uint32()));
break;
case 4:
message.allowList.push(reader.string());
break;
case 5:
message.allowedPacketData.push(reader.string());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseAllocation();
message.sourcePort = object.sourcePort ?? "";
message.sourceChannel = object.sourceChannel ?? "";
message.spendLimit = object.spendLimit?.map(e => coin_1.Coin.fromPartial(e)) || [];
message.allowList = object.allowList?.map(e => e) || [];
message.allowedPacketData = object.allowedPacketData?.map(e => e) || [];
return message;
},
fromAmino(object) {
const message = createBaseAllocation();
if (object.source_port !== undefined && object.source_port !== null) {
message.sourcePort = object.source_port;
}
if (object.source_channel !== undefined && object.source_channel !== null) {
message.sourceChannel = object.source_channel;
}
message.spendLimit = object.spend_limit?.map(e => coin_1.Coin.fromAmino(e)) || [];
message.allowList = object.allow_list?.map(e => e) || [];
message.allowedPacketData = object.allowed_packet_data?.map(e => e) || [];
return message;
},
toAmino(message) {
const obj = {};
obj.source_port = message.sourcePort === "" ? undefined : message.sourcePort;
obj.source_channel = message.sourceChannel === "" ? undefined : message.sourceChannel;
if (message.spendLimit) {
obj.spend_limit = message.spendLimit.map(e => e ? coin_1.Coin.toAmino(e) : undefined);
}
else {
obj.spend_limit = message.spendLimit;
}
if (message.allowList) {
obj.allow_list = message.allowList.map(e => e);
}
else {
obj.allow_list = message.allowList;
}
if (message.allowedPacketData) {
obj.allowed_packet_data = message.allowedPacketData.map(e => e);
}
else {
obj.allowed_packet_data = message.allowedPacketData;
}
return obj;
},
fromAminoMsg(object) {
return exports.Allocation.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Allocation",
value: exports.Allocation.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.Allocation.decode(message.value);
},
toProto(message) {
return exports.Allocation.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/ibc.applications.transfer.v1.Allocation",
value: exports.Allocation.encode(message).finish()
};
}
};
registry_1.GlobalDecoderRegistry.register(exports.Allocation.typeUrl, exports.Allocation);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.Allocation.aminoType, exports.Allocation.typeUrl);
function createBaseTransferAuthorization() {
return {
$typeUrl: "/ibc.applications.transfer.v1.TransferAuthorization",
allocations: []
};
}
exports.TransferAuthorization = {
typeUrl: "/ibc.applications.transfer.v1.TransferAuthorization",
aminoType: "cosmos-sdk/TransferAuthorization",
is(o) {
return o && (o.$typeUrl === exports.TransferAuthorization.typeUrl || Array.isArray(o.allocations) && (!o.allocations.length || exports.Allocation.is(o.allocations[0])));
},
isSDK(o) {
return o && (o.$typeUrl === exports.TransferAuthorization.typeUrl || Array.isArray(o.allocations) && (!o.allocations.length || exports.Allocation.isSDK(o.allocations[0])));
},
isAmino(o) {
return o && (o.$typeUrl === exports.TransferAuthorization.typeUrl || Array.isArray(o.allocations) && (!o.allocations.length || exports.Allocation.isAmino(o.allocations[0])));
},
encode(message, writer = binary_1.BinaryWriter.create()) {
for (const v of message.allocations) {
exports.Allocation.encode(v, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseTransferAuthorization();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.allocations.push(exports.Allocation.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseTransferAuthorization();
message.allocations = object.allocations?.map(e => exports.Allocation.fromPartial(e)) || [];
return message;
},
fromAmino(object) {
const message = createBaseTransferAuthorization();
message.allocations = object.allocations?.map(e => exports.Allocation.fromAmino(e)) || [];
return message;
},
toAmino(message) {
const obj = {};
if (message.allocations) {
obj.allocations = message.allocations.map(e => e ? exports.Allocation.toAmino(e) : undefined);
}
else {
obj.allocations = message.allocations;
}
return obj;
},
fromAminoMsg(object) {
return exports.TransferAuthorization.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/TransferAuthorization",
value: exports.TransferAuthorization.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.TransferAuthorization.decode(message.value);
},
toProto(message) {
return exports.TransferAuthorization.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/ibc.applications.transfer.v1.TransferAuthorization",
value: exports.TransferAuthorization.encode(message).finish()
};
}
};
registry_1.GlobalDecoderRegistry.register(exports.TransferAuthorization.typeUrl, exports.TransferAuthorization);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.TransferAuthorization.aminoType, exports.TransferAuthorization.typeUrl);