UNPKG

@firmachain/firma-js

Version:

The Official FirmaChain Javascript SDK written in Typescript

356 lines (355 loc) 14.3 kB
"use strict"; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SendAuthorization = exports.StakeAuthorization_Validators = exports.StakeAuthorization = exports.authorizationTypeToJSON = exports.authorizationTypeFromJSON = exports.AuthorizationType = exports.GenericAuthorization = exports.Grant = exports.MsgRevokeResponse = exports.MsgRevoke = exports.MsgGrantResponse = exports.MsgExec = exports.MsgExecResponse = exports.MsgGrant = void 0; var coin_1 = require("cosmjs-types/cosmos/base/v1beta1/coin"); var any_1 = require("../google/protobuf/any"); var binary_1 = require("cosmjs-types/binary"); var timestamp_1 = require("cosmjs-types/google/protobuf/timestamp"); function createBaseMsgGrant() { return { granter: "", grantee: "", grant: undefined }; } exports.MsgGrant = { encode: function (message, writer) { if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } if (message.granter !== "") { writer.uint32(10).string(message.granter); } if (message.grantee !== "") { writer.uint32(18).string(message.grantee); } if (message.grant !== undefined) { exports.Grant.encode(message.grant, writer.uint32(26).fork()).ldelim(); } return writer; }, fromPartial: function (object) { var _a, _b; var message = createBaseMsgGrant(); message.granter = (_a = object.granter) !== null && _a !== void 0 ? _a : ""; message.grantee = (_b = object.grantee) !== null && _b !== void 0 ? _b : ""; message.grant = object.grant !== undefined && object.grant !== null ? exports.Grant.fromPartial(object.grant) : undefined; return message; }, }; function createBaseMsgExecResponse() { return { results: [] }; } exports.MsgExecResponse = { encode: function (message, writer) { var e_1, _a; if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } try { for (var _b = __values(message.results), _c = _b.next(); !_c.done; _c = _b.next()) { var v = _c.value; writer.uint32(10).bytes(v); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return writer; }, fromPartial: function (object) { var _a; var message = createBaseMsgExecResponse(); message.results = ((_a = object.results) === null || _a === void 0 ? void 0 : _a.map(function (e) { return e; })) || []; return message; }, }; function createBaseMsgExec() { return { grantee: "", msgs: [] }; } exports.MsgExec = { encode: function (message, writer) { var e_2, _a; if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } if (message.grantee !== "") { writer.uint32(10).string(message.grantee); } try { for (var _b = __values(message.msgs), _c = _b.next(); !_c.done; _c = _b.next()) { var v = _c.value; any_1.Any.encode(v, writer.uint32(18).fork()).ldelim(); } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } return writer; }, // fromPartial(object: DeepPartial<MsgGrantAllowance>): MsgGrantAllowance { fromPartial: function (object) { var _a, _b; var message = createBaseMsgExec(); message.grantee = (_a = object.grantee) !== null && _a !== void 0 ? _a : ""; message.msgs = ((_b = object.msgs) === null || _b === void 0 ? void 0 : _b.map(function (e) { return any_1.Any.fromPartial(e); })) || []; return message; }, }; function createBaseMsgGrantResponse() { return {}; } exports.MsgGrantResponse = { encode: function (_, writer) { if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } return writer; }, fromPartial: function (object) { var message = createBaseMsgGrantResponse(); return message; }, }; function createBaseMsgRevoke() { return { granter: "", grantee: "", msgTypeUrl: "" }; } exports.MsgRevoke = { encode: function (message, writer) { if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } if (message.granter !== "") { writer.uint32(10).string(message.granter); } if (message.grantee !== "") { writer.uint32(18).string(message.grantee); } if (message.msgTypeUrl !== "") { writer.uint32(26).string(message.msgTypeUrl); } return writer; }, fromPartial: function (object) { var _a, _b, _c; var message = createBaseMsgRevoke(); message.granter = (_a = object.granter) !== null && _a !== void 0 ? _a : ""; message.grantee = (_b = object.grantee) !== null && _b !== void 0 ? _b : ""; message.msgTypeUrl = (_c = object.msgTypeUrl) !== null && _c !== void 0 ? _c : ""; return message; }, }; function createBaseMsgRevokeResponse() { return {}; } exports.MsgRevokeResponse = { encode: function (_, writer) { if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } return writer; }, fromPartial: function (object) { var message = createBaseMsgRevokeResponse(); return message; }, }; function createBaseGrant() { return { authorization: undefined, expiration: undefined }; } exports.Grant = { encode: function (message, writer) { if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } if (message.authorization !== undefined) { any_1.Any.encode(message.authorization, writer.uint32(10).fork()).ldelim(); } if (message.expiration !== undefined) { timestamp_1.Timestamp.encode(message.expiration, writer.uint32(18).fork()).ldelim(); } return writer; }, fromPartial: function (object) { var message = createBaseGrant(); message.authorization = object.authorization !== undefined && object.authorization !== null ? any_1.Any.fromPartial(object.authorization) : undefined; message.expiration = object.expiration !== undefined && object.expiration !== null ? timestamp_1.Timestamp.fromPartial(object.expiration) : undefined; return message; }, }; function createBaseGenericAuthorization() { return { msg: "" }; } exports.GenericAuthorization = { encode: function (message, writer) { if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } if (message.msg !== "") { writer.uint32(10).string(message.msg); } return writer; }, fromPartial: function (object) { var _a; var message = createBaseGenericAuthorization(); message.msg = (_a = object.msg) !== null && _a !== void 0 ? _a : ""; return message; }, }; /** * AuthorizationType defines the type of staking module authorization type * * Since: cosmos-sdk 0.43 */ var AuthorizationType; (function (AuthorizationType) { /** AUTHORIZATION_TYPE_UNSPECIFIED - AUTHORIZATION_TYPE_UNSPECIFIED specifies an unknown authorization type */ AuthorizationType[AuthorizationType["AUTHORIZATION_TYPE_UNSPECIFIED"] = 0] = "AUTHORIZATION_TYPE_UNSPECIFIED"; /** AUTHORIZATION_TYPE_DELEGATE - AUTHORIZATION_TYPE_DELEGATE defines an authorization type for Msg/Delegate */ AuthorizationType[AuthorizationType["AUTHORIZATION_TYPE_DELEGATE"] = 1] = "AUTHORIZATION_TYPE_DELEGATE"; /** AUTHORIZATION_TYPE_UNDELEGATE - AUTHORIZATION_TYPE_UNDELEGATE defines an authorization type for Msg/Undelegate */ AuthorizationType[AuthorizationType["AUTHORIZATION_TYPE_UNDELEGATE"] = 2] = "AUTHORIZATION_TYPE_UNDELEGATE"; /** AUTHORIZATION_TYPE_REDELEGATE - AUTHORIZATION_TYPE_REDELEGATE defines an authorization type for Msg/BeginRedelegate */ AuthorizationType[AuthorizationType["AUTHORIZATION_TYPE_REDELEGATE"] = 3] = "AUTHORIZATION_TYPE_REDELEGATE"; AuthorizationType[AuthorizationType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(AuthorizationType = exports.AuthorizationType || (exports.AuthorizationType = {})); function authorizationTypeFromJSON(object) { switch (object) { case 0: case "AUTHORIZATION_TYPE_UNSPECIFIED": return AuthorizationType.AUTHORIZATION_TYPE_UNSPECIFIED; case 1: case "AUTHORIZATION_TYPE_DELEGATE": return AuthorizationType.AUTHORIZATION_TYPE_DELEGATE; case 2: case "AUTHORIZATION_TYPE_UNDELEGATE": return AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE; case 3: case "AUTHORIZATION_TYPE_REDELEGATE": return AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE; case -1: case "UNRECOGNIZED": default: return AuthorizationType.UNRECOGNIZED; } } exports.authorizationTypeFromJSON = authorizationTypeFromJSON; function authorizationTypeToJSON(object) { switch (object) { case AuthorizationType.AUTHORIZATION_TYPE_UNSPECIFIED: return "AUTHORIZATION_TYPE_UNSPECIFIED"; case AuthorizationType.AUTHORIZATION_TYPE_DELEGATE: return "AUTHORIZATION_TYPE_DELEGATE"; case AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE: return "AUTHORIZATION_TYPE_UNDELEGATE"; case AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE: return "AUTHORIZATION_TYPE_REDELEGATE"; default: return "UNKNOWN"; } } exports.authorizationTypeToJSON = authorizationTypeToJSON; function createBaseStakeAuthorization() { return { maxTokens: undefined, allowList: undefined, denyList: undefined, authorizationType: 0 }; } exports.StakeAuthorization = { encode: function (message, writer) { if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } if (message.maxTokens !== undefined) { coin_1.Coin.encode(message.maxTokens, writer.uint32(10).fork()).ldelim(); } if (message.allowList !== undefined) { exports.StakeAuthorization_Validators.encode(message.allowList, writer.uint32(18).fork()).ldelim(); } if (message.denyList !== undefined) { exports.StakeAuthorization_Validators.encode(message.denyList, writer.uint32(26).fork()).ldelim(); } if (message.authorizationType !== 0) { writer.uint32(32).int32(message.authorizationType); } return writer; }, fromPartial: function (object) { var _a; var message = createBaseStakeAuthorization(); message.maxTokens = object.maxTokens !== undefined && object.maxTokens !== null ? coin_1.Coin.fromPartial(object.maxTokens) : undefined; message.allowList = object.allowList !== undefined && object.allowList !== null ? exports.StakeAuthorization_Validators.fromPartial(object.allowList) : undefined; message.denyList = object.denyList !== undefined && object.denyList !== null ? exports.StakeAuthorization_Validators.fromPartial(object.denyList) : undefined; message.authorizationType = (_a = object.authorizationType) !== null && _a !== void 0 ? _a : 0; return message; }, }; function createBaseStakeAuthorization_Validators() { return { address: [] }; } exports.StakeAuthorization_Validators = { encode: function (message, writer) { var e_3, _a; if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } try { for (var _b = __values(message.address), _c = _b.next(); !_c.done; _c = _b.next()) { var v = _c.value; writer.uint32(10).string(v); } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_3) throw e_3.error; } } return writer; }, fromPartial: function (object) { var _a; var message = createBaseStakeAuthorization_Validators(); message.address = ((_a = object.address) === null || _a === void 0 ? void 0 : _a.map(function (e) { return e; })) || []; return message; }, }; function createBaseSendAuthorization() { return { spendLimit: [] }; } exports.SendAuthorization = { encode: function (message, writer) { var e_4, _a; if (writer === void 0) { writer = binary_1.BinaryWriter.create(); } try { for (var _b = __values(message.spendLimit), _c = _b.next(); !_c.done; _c = _b.next()) { var v = _c.value; coin_1.Coin.encode(v, writer.uint32(10).fork()).ldelim(); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_4) throw e_4.error; } } return writer; }, fromPartial: function (object) { var _a; var message = createBaseSendAuthorization(); message.spendLimit = ((_a = object.spendLimit) === null || _a === void 0 ? void 0 : _a.map(function (e) { return coin_1.Coin.fromPartial(e); })) || []; return message; }, };