@keplr-wallet/cosmos 0.9.5 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("./index");
4
+ describe("Test account parse", () => {
5
+ test("Test fromAminoJSON", () => {
6
+ // Base account
7
+ let account = index_1.BaseAccount.fromAminoJSON({
8
+ height: "8409557",
9
+ result: {
10
+ type: "cosmos-sdk/BaseAccount",
11
+ value: {
12
+ address: "cosmos1vv6hruquzpty4xpks9znkw8gys5x4nsnqw9f4k",
13
+ public_key: {
14
+ type: "tendermint/PubKeySecp256k1",
15
+ value: "Avn3xBbmE0+MEyWMuxhmjjiX1GtCUVyv/Mavg8OcRIm4",
16
+ },
17
+ account_number: "9736",
18
+ sequence: "971",
19
+ },
20
+ },
21
+ });
22
+ expect(account.getAddress()).toBe("cosmos1vv6hruquzpty4xpks9znkw8gys5x4nsnqw9f4k");
23
+ expect(account.getSequence().toString()).toBe("971");
24
+ expect(account.getAccountNumber().toString()).toBe("9736");
25
+ expect(account.getType()).toBe("cosmos-sdk/BaseAccount");
26
+ // Vesting account
27
+ account = index_1.BaseAccount.fromAminoJSON({
28
+ height: "8409738",
29
+ result: {
30
+ type: "cosmos-sdk/DelayedVestingAccount",
31
+ value: {
32
+ base_vesting_account: {
33
+ base_account: {
34
+ address: "cosmos1x3rhderemr703f4lxktk2da99vl5crs28ur3xl",
35
+ public_key: {
36
+ type: "tendermint/PubKeySecp256k1",
37
+ value: "A+Zzm/8QhyL00ISXgiAgeW6zeqZHezVFi2w3iQkJeKyP",
38
+ },
39
+ account_number: "367245",
40
+ sequence: "7",
41
+ },
42
+ original_vesting: [{ denom: "uatom", amount: "16666660000" }],
43
+ delegated_free: [],
44
+ delegated_vesting: [],
45
+ end_time: "1719752607",
46
+ },
47
+ },
48
+ },
49
+ });
50
+ expect(account.getAddress()).toBe("cosmos1x3rhderemr703f4lxktk2da99vl5crs28ur3xl");
51
+ expect(account.getSequence().toString()).toBe("7");
52
+ expect(account.getAccountNumber().toString()).toBe("367245");
53
+ expect(account.getType()).toBe("cosmos-sdk/DelayedVestingAccount");
54
+ // Custom account that embeds the base account (ethermint)
55
+ account = index_1.BaseAccount.fromAminoJSON({
56
+ height: "449",
57
+ result: {
58
+ base_account: {
59
+ address: "evmos1w3ygakvq5snf30pca5g8pnyvvfr7x28djnj34m",
60
+ public_key: {
61
+ type: "tendermint/PubKeySecp256k1",
62
+ value: "AulWtcPTIZWd/CnkFkQOMqDOwU7e+U/Iq8Tli1nhBq6j",
63
+ },
64
+ account_number: "11",
65
+ sequence: "1",
66
+ },
67
+ code_hash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
68
+ },
69
+ });
70
+ expect(account.getAddress()).toBe("evmos1w3ygakvq5snf30pca5g8pnyvvfr7x28djnj34m");
71
+ expect(account.getSequence().toString()).toBe("1");
72
+ expect(account.getAccountNumber().toString()).toBe("11");
73
+ expect(account.getType()).toBe("");
74
+ });
75
+ });
76
+ //# sourceMappingURL=account.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.spec.js","sourceRoot":"","sources":["../../src/account/account.spec.ts"],"names":[],"mappings":";;AAAA,mCAAsC;AAEtC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC9B,eAAe;QACf,IAAI,OAAO,GAAG,mBAAW,CAAC,aAAa,CAAC;YACtC,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE;gBACN,IAAI,EAAE,wBAAwB;gBAC9B,KAAK,EAAE;oBACL,OAAO,EAAE,+CAA+C;oBACxD,UAAU,EAAE;wBACV,IAAI,EAAE,4BAA4B;wBAClC,KAAK,EAAE,8CAA8C;qBACtD;oBACD,cAAc,EAAE,MAAM;oBAC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AAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7D,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QAEnE,0DAA0D;QAC1D,OAAO,GAAG,mBAAW,CAAC,aAAa,CAAC;YAClC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE;gBACN,YAAY,EAAE;oBACZ,OAAO,EAAE,8CAA8C;oBACvD,UAAU,EAAE;wBACV,IAAI,EAAE,4BAA4B;wBAClC,KAAK,EAAE,8CAA8C;qBACtD;oBACD,cAAc,EAAE,IAAI;oBACpB,QAAQ,EAAE,GAAG;iBACd;gBACD,SAAS,EACP,oEAAoE;aACvE;SAGK,CAAC,CAAC;QAEV,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAC/B,8CAA8C,CAC/C,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -36,6 +36,12 @@ class BaseAccount {
36
36
  }
37
37
  const type = obj.type || "";
38
38
  let value = "value" in obj ? obj.value : obj;
39
+ // If the chain modifies the account type, handle the case where the account type embeds the base account.
40
+ // (Actually, the only existent case is ethermint, and this is the line for handling ethermint)
41
+ const baseAccount = value.BaseAccount || value.baseAccount || value.base_account;
42
+ if (baseAccount) {
43
+ value = baseAccount;
44
+ }
39
45
  // If the account is the vesting account that embeds the base vesting account,
40
46
  // the actual base account exists under the base vesting account.
41
47
  // But, this can be different according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OAAO,EAAE;YACZ,IAAI,CAAC,oBAAoB,EAAE;gBACzB,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aACzE;YACD,OAAO,GAAG,oBAAoB,CAAC;SAChC;QAED,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC;QAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEhC,OAAO,IAAI,WAAW,CACpB,IAAI,EACJ,OAAO,EACP,IAAI,UAAG,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,GAAG,CAAC,EAC7B,IAAI,UAAG,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,GAAG,CAAC,CACzB,CAAC;IACJ,CAAC;IASD,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAtGD,kCAsGC"}
@@ -1,10 +1,26 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
4
20
  };
5
21
  Object.defineProperty(exports, "__esModule", { value: true });
6
22
  exports.Bech32Address = void 0;
7
- const bech32_1 = __importDefault(require("bech32"));
23
+ const bech32_1 = __importStar(require("bech32"));
8
24
  class Bech32Address {
9
25
  constructor(address) {
10
26
  this.address = address;
@@ -40,7 +56,7 @@ class Bech32Address {
40
56
  if (prefix && decoded.prefix !== prefix) {
41
57
  throw new Error("Unmatched prefix");
42
58
  }
43
- return new Bech32Address(new Uint8Array(decoded.words));
59
+ return new Bech32Address(new Uint8Array(bech32_1.fromWords(decoded.words)));
44
60
  }
45
61
  static validate(bech32Address, prefix) {
46
62
  const { prefix: decodedPrefix } = bech32_1.default.decode(bech32Address);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bech32/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAG5B,MAAa,aAAa;IAsExB,YAA4B,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;IAAG,CAAC;IArEnD,MAAM,CAAC,cAAc,CAAC,MAAc,EAAE,aAAqB;QACzD,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE;YAClC,OAAO,MAAM,CAAC;SACf;QAED,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAEpC,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC;QAC/B,aAAa,IAAI,CAAC,CAAC,CAAC,YAAY;QAChC,aAAa,IAAI,CAAC,CAAC,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K,CAAC,kBAAkB,CAAC,CAAC;SACrC;QAED,OAAO,IAAI,aAAa,CAAC,IAAI,UAAU,CAAC,kBAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,aAAqB,EAAE,MAAe;QACpD,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,gBAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC/D,IAAI,MAAM,IAAI,MAAM,KAAK,aAAa,EAAE;YACtC,MAAM,IAAI,KAAK,CACb,gCAAgC,MAAM,aAAa,aAAa,GAAG,CACpE,CAAC;SACH;IACH,CAAC;IAED,MAAM,CAAC,mBAAmB,CACxB,UAAkB,EAClB,kBAA0B,KAAK,EAC/B,kBAA0B,MAAM,EAChC,eAAuB,KAAK,EAC5B,iBAAyB,MAAM;QAE/B,OAAO;YACL,mBAAmB,EAAE,UAAU;YAC/B,kBAAkB,EAAE,UAAU,GAAG,YAAY;YAC7C,mBAAmB,EAAE,UAAU,GAAG,eAAe,GAAG,cAAc;YAClE,kBAAkB,EAChB,UAAU,GAAG,eAAe,GAAG,cAAc,GAAG,YAAY;YAC9D,oBAAoB,EAAE,UAAU,GAAG,eAAe,GAAG,eAAe;YACpE,mBAAmB,EACjB,UAAU,GAAG,eAAe,GAAG,eAAe,GAAG,YAAY;SAChE,CAAC;IACJ,CAAC;IAID,QAAQ,CAAC,MAAc;QACrB,MAAM,KAAK,GAAG,gBAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3C,OAAO,gBAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;CACF;AA5ED,sCA4EC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("./index");
4
+ describe("Test bech32", () => {
5
+ it("bech32 address should be parsed properly", () => {
6
+ const address = index_1.Bech32Address.fromBech32("cosmos1vv6hruquzpty4xpks9znkw8gys5x4nsnqw9f4k");
7
+ expect(address.address).toStrictEqual(new Uint8Array([
8
+ 99,
9
+ 53,
10
+ 113,
11
+ 240,
12
+ 28,
13
+ 16,
14
+ 86,
15
+ 74,
16
+ 152,
17
+ 54,
18
+ 129,
19
+ 69,
20
+ 59,
21
+ 56,
22
+ 232,
23
+ 36,
24
+ 40,
25
+ 106,
26
+ 206,
27
+ 19,
28
+ ]));
29
+ expect(address.address.length).toBe(20);
30
+ expect(address.toBech32("cosmos")).toBe("cosmos1vv6hruquzpty4xpks9znkw8gys5x4nsnqw9f4k");
31
+ });
32
+ });
33
+ //# sourceMappingURL=test.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.spec.js","sourceRoot":"","sources":["../../src/bech32/test.spec.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,OAAO,GAAG,qBAAa,CAAC,UAAU,CACtC,+CAA+C,CAChD,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,aAAa,CACnC,IAAI,UAAU,CAAC;YACb,EAAE;YACF,EAAE;YACF,GAAG;YACH,GAAG;YACH,EAAE;YACF,EAAE;YACF,EAAE;YACF,EAAE;YACF,GAAG;YACH,EAAE;YACF,GAAG;YACH,EAAE;YACF,EAAE;YACF,EAAE;YACF,GAAG;YACH,EAAE;YACF,EAAE;YACF,GAAG;YACH,GAAG;YACH,EAAE;SACH,CAAC,CACH,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CACrC,+CAA+C,CAChD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -2227,6 +2227,152 @@ export namespace cosmos {
2227
2227
  public toJSON(): { [k: string]: any };
2228
2228
  }
2229
2229
  }
2230
+
2231
+ /** Namespace abci. */
2232
+ namespace abci {
2233
+
2234
+ /** Namespace v1beta1. */
2235
+ namespace v1beta1 {
2236
+
2237
+ /** Properties of a MsgData. */
2238
+ interface IMsgData {
2239
+
2240
+ /** MsgData msgType */
2241
+ msgType?: (string|null);
2242
+
2243
+ /** MsgData data */
2244
+ data?: (Uint8Array|null);
2245
+ }
2246
+
2247
+ /** Represents a MsgData. */
2248
+ class MsgData implements IMsgData {
2249
+
2250
+ /**
2251
+ * Constructs a new MsgData.
2252
+ * @param [p] Properties to set
2253
+ */
2254
+ constructor(p?: cosmos.base.abci.v1beta1.IMsgData);
2255
+
2256
+ /** MsgData msgType. */
2257
+ public msgType: string;
2258
+
2259
+ /** MsgData data. */
2260
+ public data: Uint8Array;
2261
+
2262
+ /**
2263
+ * Creates a new MsgData instance using the specified properties.
2264
+ * @param [properties] Properties to set
2265
+ * @returns MsgData instance
2266
+ */
2267
+ public static create(properties?: cosmos.base.abci.v1beta1.IMsgData): cosmos.base.abci.v1beta1.MsgData;
2268
+
2269
+ /**
2270
+ * Encodes the specified MsgData message. Does not implicitly {@link cosmos.base.abci.v1beta1.MsgData.verify|verify} messages.
2271
+ * @param m MsgData message or plain object to encode
2272
+ * @param [w] Writer to encode to
2273
+ * @returns Writer
2274
+ */
2275
+ public static encode(m: cosmos.base.abci.v1beta1.IMsgData, w?: $protobuf.Writer): $protobuf.Writer;
2276
+
2277
+ /**
2278
+ * Decodes a MsgData message from the specified reader or buffer.
2279
+ * @param r Reader or buffer to decode from
2280
+ * @param [l] Message length if known beforehand
2281
+ * @returns MsgData
2282
+ * @throws {Error} If the payload is not a reader or valid buffer
2283
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
2284
+ */
2285
+ public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): cosmos.base.abci.v1beta1.MsgData;
2286
+
2287
+ /**
2288
+ * Creates a MsgData message from a plain object. Also converts values to their respective internal types.
2289
+ * @param d Plain object
2290
+ * @returns MsgData
2291
+ */
2292
+ public static fromObject(d: { [k: string]: any }): cosmos.base.abci.v1beta1.MsgData;
2293
+
2294
+ /**
2295
+ * Creates a plain object from a MsgData message. Also converts values to other types if specified.
2296
+ * @param m MsgData
2297
+ * @param [o] Conversion options
2298
+ * @returns Plain object
2299
+ */
2300
+ public static toObject(m: cosmos.base.abci.v1beta1.MsgData, o?: $protobuf.IConversionOptions): { [k: string]: any };
2301
+
2302
+ /**
2303
+ * Converts this MsgData to JSON.
2304
+ * @returns JSON object
2305
+ */
2306
+ public toJSON(): { [k: string]: any };
2307
+ }
2308
+
2309
+ /** Properties of a TxMsgData. */
2310
+ interface ITxMsgData {
2311
+
2312
+ /** TxMsgData data */
2313
+ data?: (cosmos.base.abci.v1beta1.IMsgData[]|null);
2314
+ }
2315
+
2316
+ /** Represents a TxMsgData. */
2317
+ class TxMsgData implements ITxMsgData {
2318
+
2319
+ /**
2320
+ * Constructs a new TxMsgData.
2321
+ * @param [p] Properties to set
2322
+ */
2323
+ constructor(p?: cosmos.base.abci.v1beta1.ITxMsgData);
2324
+
2325
+ /** TxMsgData data. */
2326
+ public data: cosmos.base.abci.v1beta1.IMsgData[];
2327
+
2328
+ /**
2329
+ * Creates a new TxMsgData instance using the specified properties.
2330
+ * @param [properties] Properties to set
2331
+ * @returns TxMsgData instance
2332
+ */
2333
+ public static create(properties?: cosmos.base.abci.v1beta1.ITxMsgData): cosmos.base.abci.v1beta1.TxMsgData;
2334
+
2335
+ /**
2336
+ * Encodes the specified TxMsgData message. Does not implicitly {@link cosmos.base.abci.v1beta1.TxMsgData.verify|verify} messages.
2337
+ * @param m TxMsgData message or plain object to encode
2338
+ * @param [w] Writer to encode to
2339
+ * @returns Writer
2340
+ */
2341
+ public static encode(m: cosmos.base.abci.v1beta1.ITxMsgData, w?: $protobuf.Writer): $protobuf.Writer;
2342
+
2343
+ /**
2344
+ * Decodes a TxMsgData message from the specified reader or buffer.
2345
+ * @param r Reader or buffer to decode from
2346
+ * @param [l] Message length if known beforehand
2347
+ * @returns TxMsgData
2348
+ * @throws {Error} If the payload is not a reader or valid buffer
2349
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
2350
+ */
2351
+ public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): cosmos.base.abci.v1beta1.TxMsgData;
2352
+
2353
+ /**
2354
+ * Creates a TxMsgData message from a plain object. Also converts values to their respective internal types.
2355
+ * @param d Plain object
2356
+ * @returns TxMsgData
2357
+ */
2358
+ public static fromObject(d: { [k: string]: any }): cosmos.base.abci.v1beta1.TxMsgData;
2359
+
2360
+ /**
2361
+ * Creates a plain object from a TxMsgData message. Also converts values to other types if specified.
2362
+ * @param m TxMsgData
2363
+ * @param [o] Conversion options
2364
+ * @returns Plain object
2365
+ */
2366
+ public static toObject(m: cosmos.base.abci.v1beta1.TxMsgData, o?: $protobuf.IConversionOptions): { [k: string]: any };
2367
+
2368
+ /**
2369
+ * Converts this TxMsgData to JSON.
2370
+ * @returns JSON object
2371
+ */
2372
+ public toJSON(): { [k: string]: any };
2373
+ }
2374
+ }
2375
+ }
2230
2376
  }
2231
2377
 
2232
2378
  /** Namespace crypto. */
@@ -4148,6 +4294,168 @@ export namespace ibc {
4148
4294
  }
4149
4295
  }
4150
4296
 
4297
+ /** Namespace cosmwasm. */
4298
+ export namespace cosmwasm {
4299
+
4300
+ /** Namespace wasm. */
4301
+ namespace wasm {
4302
+
4303
+ /** Namespace v1. */
4304
+ namespace v1 {
4305
+
4306
+ /** Properties of a MsgExecuteContract. */
4307
+ interface IMsgExecuteContract {
4308
+
4309
+ /** MsgExecuteContract sender */
4310
+ sender?: (string|null);
4311
+
4312
+ /** MsgExecuteContract contract */
4313
+ contract?: (string|null);
4314
+
4315
+ /** MsgExecuteContract msg */
4316
+ msg?: (Uint8Array|null);
4317
+
4318
+ /** MsgExecuteContract funds */
4319
+ funds?: (cosmos.base.v1beta1.ICoin[]|null);
4320
+ }
4321
+
4322
+ /** Represents a MsgExecuteContract. */
4323
+ class MsgExecuteContract implements IMsgExecuteContract {
4324
+
4325
+ /**
4326
+ * Constructs a new MsgExecuteContract.
4327
+ * @param [p] Properties to set
4328
+ */
4329
+ constructor(p?: cosmwasm.wasm.v1.IMsgExecuteContract);
4330
+
4331
+ /** MsgExecuteContract sender. */
4332
+ public sender: string;
4333
+
4334
+ /** MsgExecuteContract contract. */
4335
+ public contract: string;
4336
+
4337
+ /** MsgExecuteContract msg. */
4338
+ public msg: Uint8Array;
4339
+
4340
+ /** MsgExecuteContract funds. */
4341
+ public funds: cosmos.base.v1beta1.ICoin[];
4342
+
4343
+ /**
4344
+ * Creates a new MsgExecuteContract instance using the specified properties.
4345
+ * @param [properties] Properties to set
4346
+ * @returns MsgExecuteContract instance
4347
+ */
4348
+ public static create(properties?: cosmwasm.wasm.v1.IMsgExecuteContract): cosmwasm.wasm.v1.MsgExecuteContract;
4349
+
4350
+ /**
4351
+ * Encodes the specified MsgExecuteContract message. Does not implicitly {@link cosmwasm.wasm.v1.MsgExecuteContract.verify|verify} messages.
4352
+ * @param m MsgExecuteContract message or plain object to encode
4353
+ * @param [w] Writer to encode to
4354
+ * @returns Writer
4355
+ */
4356
+ public static encode(m: cosmwasm.wasm.v1.IMsgExecuteContract, w?: $protobuf.Writer): $protobuf.Writer;
4357
+
4358
+ /**
4359
+ * Decodes a MsgExecuteContract message from the specified reader or buffer.
4360
+ * @param r Reader or buffer to decode from
4361
+ * @param [l] Message length if known beforehand
4362
+ * @returns MsgExecuteContract
4363
+ * @throws {Error} If the payload is not a reader or valid buffer
4364
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
4365
+ */
4366
+ public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): cosmwasm.wasm.v1.MsgExecuteContract;
4367
+
4368
+ /**
4369
+ * Creates a MsgExecuteContract message from a plain object. Also converts values to their respective internal types.
4370
+ * @param d Plain object
4371
+ * @returns MsgExecuteContract
4372
+ */
4373
+ public static fromObject(d: { [k: string]: any }): cosmwasm.wasm.v1.MsgExecuteContract;
4374
+
4375
+ /**
4376
+ * Creates a plain object from a MsgExecuteContract message. Also converts values to other types if specified.
4377
+ * @param m MsgExecuteContract
4378
+ * @param [o] Conversion options
4379
+ * @returns Plain object
4380
+ */
4381
+ public static toObject(m: cosmwasm.wasm.v1.MsgExecuteContract, o?: $protobuf.IConversionOptions): { [k: string]: any };
4382
+
4383
+ /**
4384
+ * Converts this MsgExecuteContract to JSON.
4385
+ * @returns JSON object
4386
+ */
4387
+ public toJSON(): { [k: string]: any };
4388
+ }
4389
+
4390
+ /** Properties of a MsgExecuteContractResponse. */
4391
+ interface IMsgExecuteContractResponse {
4392
+
4393
+ /** MsgExecuteContractResponse data */
4394
+ data?: (Uint8Array|null);
4395
+ }
4396
+
4397
+ /** Represents a MsgExecuteContractResponse. */
4398
+ class MsgExecuteContractResponse implements IMsgExecuteContractResponse {
4399
+
4400
+ /**
4401
+ * Constructs a new MsgExecuteContractResponse.
4402
+ * @param [p] Properties to set
4403
+ */
4404
+ constructor(p?: cosmwasm.wasm.v1.IMsgExecuteContractResponse);
4405
+
4406
+ /** MsgExecuteContractResponse data. */
4407
+ public data: Uint8Array;
4408
+
4409
+ /**
4410
+ * Creates a new MsgExecuteContractResponse instance using the specified properties.
4411
+ * @param [properties] Properties to set
4412
+ * @returns MsgExecuteContractResponse instance
4413
+ */
4414
+ public static create(properties?: cosmwasm.wasm.v1.IMsgExecuteContractResponse): cosmwasm.wasm.v1.MsgExecuteContractResponse;
4415
+
4416
+ /**
4417
+ * Encodes the specified MsgExecuteContractResponse message. Does not implicitly {@link cosmwasm.wasm.v1.MsgExecuteContractResponse.verify|verify} messages.
4418
+ * @param m MsgExecuteContractResponse message or plain object to encode
4419
+ * @param [w] Writer to encode to
4420
+ * @returns Writer
4421
+ */
4422
+ public static encode(m: cosmwasm.wasm.v1.IMsgExecuteContractResponse, w?: $protobuf.Writer): $protobuf.Writer;
4423
+
4424
+ /**
4425
+ * Decodes a MsgExecuteContractResponse message from the specified reader or buffer.
4426
+ * @param r Reader or buffer to decode from
4427
+ * @param [l] Message length if known beforehand
4428
+ * @returns MsgExecuteContractResponse
4429
+ * @throws {Error} If the payload is not a reader or valid buffer
4430
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
4431
+ */
4432
+ public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): cosmwasm.wasm.v1.MsgExecuteContractResponse;
4433
+
4434
+ /**
4435
+ * Creates a MsgExecuteContractResponse message from a plain object. Also converts values to their respective internal types.
4436
+ * @param d Plain object
4437
+ * @returns MsgExecuteContractResponse
4438
+ */
4439
+ public static fromObject(d: { [k: string]: any }): cosmwasm.wasm.v1.MsgExecuteContractResponse;
4440
+
4441
+ /**
4442
+ * Creates a plain object from a MsgExecuteContractResponse message. Also converts values to other types if specified.
4443
+ * @param m MsgExecuteContractResponse
4444
+ * @param [o] Conversion options
4445
+ * @returns Plain object
4446
+ */
4447
+ public static toObject(m: cosmwasm.wasm.v1.MsgExecuteContractResponse, o?: $protobuf.IConversionOptions): { [k: string]: any };
4448
+
4449
+ /**
4450
+ * Converts this MsgExecuteContractResponse to JSON.
4451
+ * @returns JSON object
4452
+ */
4453
+ public toJSON(): { [k: string]: any };
4454
+ }
4455
+ }
4456
+ }
4457
+ }
4458
+
4151
4459
  /** Namespace tendermint. */
4152
4460
  export namespace tendermint {
4153
4461