decentralcardgame-cardchain-client-ts 0.0.29 → 0.0.30

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.
Files changed (56) hide show
  1. package/DecentralCardGame.cardchain.cardchain/module.js +420 -452
  2. package/DecentralCardGame.cardchain.cardchain/module.ts +1495 -1570
  3. package/DecentralCardGame.cardchain.cardchain/registry.js +78 -70
  4. package/DecentralCardGame.cardchain.cardchain/registry.ts +78 -70
  5. package/DecentralCardGame.cardchain.cardchain/rest.js +71 -0
  6. package/DecentralCardGame.cardchain.cardchain/rest.ts +132 -0
  7. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.js +6 -0
  8. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.ts +6 -0
  9. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/early_access_proposal.js +81 -0
  10. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/early_access_proposal.ts +106 -0
  11. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/encounters.js +295 -0
  12. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/encounters.ts +354 -0
  13. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/genesis.js +16 -0
  14. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/genesis.ts +19 -1
  15. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.js +447 -0
  16. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.ts +570 -0
  17. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.js +504 -0
  18. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.ts +613 -0
  19. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/user.js +50 -0
  20. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/user.ts +48 -0
  21. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/zealy.js +58 -0
  22. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/zealy.ts +82 -0
  23. package/DecentralCardGame.cardchain.cardchain/types.js +5 -1
  24. package/DecentralCardGame.cardchain.cardchain/types.ts +8 -0
  25. package/DecentralCardGame.cardchain.featureflag/module.js +9 -7
  26. package/DecentralCardGame.cardchain.featureflag/module.ts +69 -65
  27. package/client.js +2 -5
  28. package/client.ts +164 -162
  29. package/cosmos.authz.v1beta1/module.js +33 -22
  30. package/cosmos.authz.v1beta1/module.ts +220 -148
  31. package/cosmos.distribution.v1beta1/module.js +65 -35
  32. package/cosmos.distribution.v1beta1/module.ts +354 -200
  33. package/cosmos.evidence.v1beta1/module.js +21 -13
  34. package/cosmos.evidence.v1beta1/module.ts +115 -86
  35. package/cosmos.gov.v1/module.js +48 -29
  36. package/cosmos.gov.v1/module.ts +275 -178
  37. package/cosmos.mint.v1beta1/module.js +9 -7
  38. package/cosmos.mint.v1beta1/module.ts +67 -63
  39. package/cosmos.nft.v1beta1/module.js +9 -7
  40. package/cosmos.nft.v1beta1/module.ts +75 -71
  41. package/cosmos.tx.v1beta1/module.js +9 -7
  42. package/cosmos.tx.v1beta1/module.ts +89 -85
  43. package/cosmos.vesting.v1beta1/module.js +52 -29
  44. package/cosmos.vesting.v1beta1/module.ts +249 -149
  45. package/ibc.applications.interchain_accounts.controller.v1/module.js +9 -7
  46. package/ibc.applications.interchain_accounts.controller.v1/module.ts +65 -61
  47. package/ibc.applications.transfer.v1/module.js +17 -12
  48. package/ibc.applications.transfer.v1/module.ts +114 -88
  49. package/ibc.core.channel.v1/module.js +1 -4
  50. package/ibc.core.channel.v1/module.ts +79 -81
  51. package/ibc.core.client.v1/module.js +1 -4
  52. package/ibc.core.client.v1/module.ts +81 -83
  53. package/ibc.core.connection.v1/module.js +6 -7
  54. package/ibc.core.connection.v1/module.ts +88 -84
  55. package/package.json +1 -1
  56. package/tsconfig.json +1 -1
package/client.ts CHANGED
@@ -1,176 +1,178 @@
1
1
  /// <reference path="./types.d.ts" />
2
2
  import {
3
- GeneratedType,
4
- OfflineSigner,
5
- EncodeObject,
6
- Registry,
3
+ GeneratedType,
4
+ OfflineSigner,
5
+ EncodeObject,
6
+ Registry,
7
7
  } from "@cosmjs/proto-signing";
8
- import {StdFee} from "@cosmjs/amino";
9
- import {SigningStargateClient} from "@cosmjs/stargate";
10
- import {Env} from "./env";
11
- import {UnionToIntersection, Return, Constructor} from "./helpers";
12
- import {Module} from "./modules";
13
- import {EventEmitter} from "events";
14
- import {ChainInfo} from "@keplr-wallet/types";
8
+ import { StdFee } from "@cosmjs/amino";
9
+ import { SigningStargateClient } from "@cosmjs/stargate";
10
+ import { Env } from "./env";
11
+ import { UnionToIntersection, Return, Constructor } from "./helpers";
12
+ import { Module } from "./modules";
13
+ import { EventEmitter } from "events";
14
+ import { ChainInfo } from "@keplr-wallet/types";
15
15
 
16
16
  const defaultFee = {
17
- amount: [],
18
- gas: "200000",
17
+ amount: [],
18
+ gas: "200000",
19
19
  };
20
20
 
21
21
  export class IgniteClient extends EventEmitter {
22
- static plugins: Module[] = [];
23
- env: Env;
24
- signer?: OfflineSigner;
25
- registry: Array<[string, GeneratedType]> = [];
26
-
27
- static plugin<T extends Module | Module[]>(plugin: T) {
28
- const currentPlugins = this.plugins;
29
-
30
- class AugmentedClient extends this {
31
- static plugins = currentPlugins.concat(plugin);
32
- }
33
-
34
- if (Array.isArray(plugin)) {
35
- type Extension = UnionToIntersection<Return<T>['module']>
36
- return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
37
- }
38
-
39
- type Extension = Return<T>['module']
40
- return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
22
+ static plugins: Module[] = [];
23
+ env: Env;
24
+ signer?: OfflineSigner;
25
+ registry: Array<[string, GeneratedType]> = [];
26
+ static plugin<T extends Module | Module[]>(plugin: T) {
27
+ const currentPlugins = this.plugins;
28
+
29
+ class AugmentedClient extends this {
30
+ static plugins = currentPlugins.concat(plugin);
41
31
  }
42
32
 
43
- async signAndBroadcast(msgs: EncodeObject[], fee: StdFee, memo: string) {
44
- if (this.signer) {
45
- const {address} = (await this.signer.getAccounts())[0];
46
- const signingClient = await SigningStargateClient.connectWithSigner(this.env.rpcURL, this.signer, {
47
- registry: new Registry(this.registry),
48
- prefix: this.env.prefix
49
- });
50
- return await signingClient.signAndBroadcast(address, msgs, fee ? fee : defaultFee, memo)
51
- } else {
52
- throw new Error(" Signer is not present.");
53
- }
33
+ if (Array.isArray(plugin)) {
34
+ type Extension = UnionToIntersection<Return<T>["module"]>;
35
+ return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
54
36
  }
55
37
 
56
- constructor(env: Env, signer?: OfflineSigner) {
57
- super();
58
- this.env = env;
59
- this.setMaxListeners(0);
60
- this.signer = signer;
61
- const classConstructor = this.constructor as typeof IgniteClient;
62
- classConstructor.plugins.forEach(plugin => {
63
- const pluginInstance = plugin(this);
64
- Object.assign(this, pluginInstance.module)
65
- if (this.registry) {
66
- this.registry = this.registry.concat(pluginInstance.registry)
67
- }
68
- });
38
+ type Extension = Return<T>["module"];
39
+ return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
40
+ }
41
+
42
+ async signAndBroadcast(msgs: EncodeObject[], fee: StdFee, memo: string) {
43
+ if (this.signer) {
44
+ const { address } = (await this.signer.getAccounts())[0];
45
+ const signingClient = await SigningStargateClient.connectWithSigner(
46
+ this.env.rpcURL,
47
+ this.signer,
48
+ { registry: new Registry(this.registry), prefix: this.env.prefix },
49
+ );
50
+ return await signingClient.signAndBroadcast(
51
+ address,
52
+ msgs,
53
+ fee ? fee : defaultFee,
54
+ memo,
55
+ );
56
+ } else {
57
+ throw new Error(" Signer is not present.");
69
58
  }
70
-
71
- useSigner(signer: OfflineSigner) {
72
- this.signer = signer;
73
- this.emit("signer-changed", this.signer);
74
- }
75
-
76
- removeSigner() {
77
- this.signer = undefined;
78
- this.emit("signer-changed", this.signer);
79
- }
80
-
81
- async useKeplr(keplrChainInfo: Partial<ChainInfo> = {}) {
82
- // Using queryClients directly because BaseClient has no knowledge of the modules at this stage
83
- try {
84
- const queryClient = (
85
- await import("./cosmos.base.tendermint.v1beta1/module")
86
- ).queryClient;
87
- const stakingQueryClient = (
88
- await import("./cosmos.staking.v1beta1/module")
89
- ).queryClient;
90
- const bankQueryClient = (await import("./cosmos.bank.v1beta1/module"))
91
- .queryClient;
92
-
93
- const stakingqc = stakingQueryClient({addr: this.env.apiURL});
94
- const qc = queryClient({addr: this.env.apiURL});
95
- const node_info = await (await qc.serviceGetNodeInfo()).data;
96
- const chainId = node_info.default_node_info?.network ?? "";
97
- const chainName = chainId?.toUpperCase() + " Network";
98
- const staking = await (await stakingqc.queryParams()).data;
99
- const bankqc = bankQueryClient({addr: this.env.apiURL});
100
- const tokens = await (await bankqc.queryTotalSupply()).data;
101
- const addrPrefix = this.env.prefix ?? "cosmos";
102
- const rpc = this.env.rpcURL;
103
- const rest = this.env.apiURL;
104
- let stakeCurrency = {
105
- coinDenom: staking.params?.bond_denom?.toUpperCase() ?? "",
106
- coinMinimalDenom: staking.params?.bond_denom ?? "",
107
- coinDecimals: 0,
108
- };
109
-
110
- let bip44 = {
111
- coinType: 118,
112
- };
113
-
114
- let bech32Config = {
115
- bech32PrefixAccAddr: addrPrefix,
116
- bech32PrefixAccPub: addrPrefix + "pub",
117
- bech32PrefixValAddr: addrPrefix + "valoper",
118
- bech32PrefixValPub: addrPrefix + "valoperpub",
119
- bech32PrefixConsAddr: addrPrefix + "valcons",
120
- bech32PrefixConsPub: addrPrefix + "valconspub",
121
- };
122
-
123
- let currencies =
124
- tokens.supply?.map((x) => {
125
- const y = {
126
- coinDenom: x.denom?.toUpperCase() ?? "",
127
- coinMinimalDenom: x.denom ?? "",
128
- coinDecimals: 0,
129
- };
130
- return y;
131
- }) ?? [];
132
-
133
- let feeCurrencies =
134
- tokens.supply?.map((x) => {
135
- const y = {
136
- coinDenom: x.denom?.toUpperCase() ?? "",
137
- coinMinimalDenom: x.denom ?? "",
138
- coinDecimals: 0,
139
- };
140
- return y;
141
- }) ?? [];
142
-
143
- let coinType = 118;
144
-
145
- if (chainId) {
146
- const suggestOptions: ChainInfo = {
147
- chainId,
148
- chainName,
149
- rpc,
150
- rest,
151
- stakeCurrency,
152
- bip44,
153
- bech32Config,
154
- currencies,
155
- feeCurrencies,
156
- ...keplrChainInfo,
157
- };
158
- await window.keplr.experimentalSuggestChain(suggestOptions);
159
-
160
- window.keplr.defaultOptions = {
161
- sign: {
162
- preferNoSetFee: true,
163
- preferNoSetMemo: true,
164
- },
165
- };
166
- }
167
- await window.keplr.enable(chainId);
168
- this.signer = window.keplr.getOfflineSigner(chainId);
169
- this.emit("signer-changed", this.signer);
170
- } catch (e) {
171
- throw new Error(
172
- "Could not load tendermint, staking and bank modules. Please ensure your client loads them to use useKeplr()"
173
- );
174
- }
59
+ }
60
+
61
+ constructor(env: Env, signer?: OfflineSigner) {
62
+ super();
63
+ this.env = env;
64
+ this.setMaxListeners(0);
65
+ this.signer = signer;
66
+ const classConstructor = this.constructor as typeof IgniteClient;
67
+ classConstructor.plugins.forEach((plugin) => {
68
+ const pluginInstance = plugin(this);
69
+ Object.assign(this, pluginInstance.module);
70
+ if (this.registry) {
71
+ this.registry = this.registry.concat(pluginInstance.registry);
72
+ }
73
+ });
74
+ }
75
+ useSigner(signer: OfflineSigner) {
76
+ this.signer = signer;
77
+ this.emit("signer-changed", this.signer);
78
+ }
79
+ removeSigner() {
80
+ this.signer = undefined;
81
+ this.emit("signer-changed", this.signer);
82
+ }
83
+ async useKeplr(keplrChainInfo: Partial<ChainInfo> = {}) {
84
+ // Using queryClients directly because BaseClient has no knowledge of the modules at this stage
85
+ try {
86
+ const queryClient = (
87
+ await import("./cosmos.base.tendermint.v1beta1/module")
88
+ ).queryClient;
89
+ const stakingQueryClient = (
90
+ await import("./cosmos.staking.v1beta1/module")
91
+ ).queryClient;
92
+ const bankQueryClient = (await import("./cosmos.bank.v1beta1/module"))
93
+ .queryClient;
94
+
95
+ const stakingqc = stakingQueryClient({ addr: this.env.apiURL });
96
+ const qc = queryClient({ addr: this.env.apiURL });
97
+ const node_info = await (await qc.serviceGetNodeInfo()).data;
98
+ const chainId = node_info.default_node_info?.network ?? "";
99
+ const chainName = chainId?.toUpperCase() + " Network";
100
+ const staking = await (await stakingqc.queryParams()).data;
101
+ const bankqc = bankQueryClient({ addr: this.env.apiURL });
102
+ const tokens = await (await bankqc.queryTotalSupply()).data;
103
+ const addrPrefix = this.env.prefix ?? "cosmos";
104
+ const rpc = this.env.rpcURL;
105
+ const rest = this.env.apiURL;
106
+ let stakeCurrency = {
107
+ coinDenom: staking.params?.bond_denom?.toUpperCase() ?? "",
108
+ coinMinimalDenom: staking.params?.bond_denom ?? "",
109
+ coinDecimals: 0,
110
+ };
111
+
112
+ let bip44 = {
113
+ coinType: 118,
114
+ };
115
+
116
+ let bech32Config = {
117
+ bech32PrefixAccAddr: addrPrefix,
118
+ bech32PrefixAccPub: addrPrefix + "pub",
119
+ bech32PrefixValAddr: addrPrefix + "valoper",
120
+ bech32PrefixValPub: addrPrefix + "valoperpub",
121
+ bech32PrefixConsAddr: addrPrefix + "valcons",
122
+ bech32PrefixConsPub: addrPrefix + "valconspub",
123
+ };
124
+
125
+ let currencies =
126
+ tokens.supply?.map((x) => {
127
+ const y = {
128
+ coinDenom: x.denom?.toUpperCase() ?? "",
129
+ coinMinimalDenom: x.denom ?? "",
130
+ coinDecimals: 0,
131
+ };
132
+ return y;
133
+ }) ?? [];
134
+
135
+ let feeCurrencies =
136
+ tokens.supply?.map((x) => {
137
+ const y = {
138
+ coinDenom: x.denom?.toUpperCase() ?? "",
139
+ coinMinimalDenom: x.denom ?? "",
140
+ coinDecimals: 0,
141
+ };
142
+ return y;
143
+ }) ?? [];
144
+
145
+ let coinType = 118;
146
+
147
+ if (chainId) {
148
+ const suggestOptions: ChainInfo = {
149
+ chainId,
150
+ chainName,
151
+ rpc,
152
+ rest,
153
+ stakeCurrency,
154
+ bip44,
155
+ bech32Config,
156
+ currencies,
157
+ feeCurrencies,
158
+ ...keplrChainInfo,
159
+ };
160
+ await window.keplr.experimentalSuggestChain(suggestOptions);
161
+
162
+ window.keplr.defaultOptions = {
163
+ sign: {
164
+ preferNoSetFee: true,
165
+ preferNoSetMemo: true,
166
+ },
167
+ };
168
+ }
169
+ await window.keplr.enable(chainId);
170
+ this.signer = window.keplr.getOfflineSigner(chainId);
171
+ this.emit("signer-changed", this.signer);
172
+ } catch (e) {
173
+ throw new Error(
174
+ "Could not load tendermint, staking and bank modules. Please ensure your client loads them to use useKeplr()",
175
+ );
175
176
  }
176
- }
177
+ }
178
+ }
@@ -1,7 +1,7 @@
1
1
  // Generated by Ignite ignite.com/cli
2
2
  import { SigningStargateClient } from "@cosmjs/stargate";
3
- import { Registry } from "@cosmjs/proto-signing";
4
- import { msgTypes } from './registry';
3
+ import { Registry, } from "@cosmjs/proto-signing";
4
+ import { msgTypes } from "./registry";
5
5
  import { Api } from "./rest";
6
6
  import { MsgRevoke } from "./types/cosmos/authz/v1beta1/tx";
7
7
  import { MsgExec } from "./types/cosmos/authz/v1beta1/tx";
@@ -26,11 +26,14 @@ const defaultFee = {
26
26
  amount: [],
27
27
  gas: "200000",
28
28
  };
29
- export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26657", prefix: "cosmos" }) => {
29
+ export const txClient = ({ signer, prefix, addr } = {
30
+ addr: "http://localhost:26657",
31
+ prefix: "cosmos",
32
+ }) => {
30
33
  return {
31
- async sendMsgRevoke({ value, fee, memo }) {
34
+ async sendMsgRevoke({ value, fee, memo, }) {
32
35
  if (!signer) {
33
- throw new Error('TxClient:sendMsgRevoke: Unable to sign Tx. Signer is not present.');
36
+ throw new Error("TxClient:sendMsgRevoke: Unable to sign Tx. Signer is not present.");
34
37
  }
35
38
  try {
36
39
  const { address } = (await signer.getAccounts())[0];
@@ -39,12 +42,12 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
39
42
  return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
40
43
  }
41
44
  catch (e) {
42
- throw new Error('TxClient:sendMsgRevoke: Could not broadcast Tx: ' + e.message);
45
+ throw new Error("TxClient:sendMsgRevoke: Could not broadcast Tx: " + e.message);
43
46
  }
44
47
  },
45
- async sendMsgExec({ value, fee, memo }) {
48
+ async sendMsgExec({ value, fee, memo, }) {
46
49
  if (!signer) {
47
- throw new Error('TxClient:sendMsgExec: Unable to sign Tx. Signer is not present.');
50
+ throw new Error("TxClient:sendMsgExec: Unable to sign Tx. Signer is not present.");
48
51
  }
49
52
  try {
50
53
  const { address } = (await signer.getAccounts())[0];
@@ -53,12 +56,12 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
53
56
  return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
54
57
  }
55
58
  catch (e) {
56
- throw new Error('TxClient:sendMsgExec: Could not broadcast Tx: ' + e.message);
59
+ throw new Error("TxClient:sendMsgExec: Could not broadcast Tx: " + e.message);
57
60
  }
58
61
  },
59
- async sendMsgGrant({ value, fee, memo }) {
62
+ async sendMsgGrant({ value, fee, memo, }) {
60
63
  if (!signer) {
61
- throw new Error('TxClient:sendMsgGrant: Unable to sign Tx. Signer is not present.');
64
+ throw new Error("TxClient:sendMsgGrant: Unable to sign Tx. Signer is not present.");
62
65
  }
63
66
  try {
64
67
  const { address } = (await signer.getAccounts())[0];
@@ -67,31 +70,40 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
67
70
  return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
68
71
  }
69
72
  catch (e) {
70
- throw new Error('TxClient:sendMsgGrant: Could not broadcast Tx: ' + e.message);
73
+ throw new Error("TxClient:sendMsgGrant: Could not broadcast Tx: " + e.message);
71
74
  }
72
75
  },
73
76
  msgRevoke({ value }) {
74
77
  try {
75
- return { typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", value: MsgRevoke.fromPartial(value) };
78
+ return {
79
+ typeUrl: "/cosmos.authz.v1beta1.MsgRevoke",
80
+ value: MsgRevoke.fromPartial(value),
81
+ };
76
82
  }
77
83
  catch (e) {
78
- throw new Error('TxClient:MsgRevoke: Could not create message: ' + e.message);
84
+ throw new Error("TxClient:MsgRevoke: Could not create message: " + e.message);
79
85
  }
80
86
  },
81
87
  msgExec({ value }) {
82
88
  try {
83
- return { typeUrl: "/cosmos.authz.v1beta1.MsgExec", value: MsgExec.fromPartial(value) };
89
+ return {
90
+ typeUrl: "/cosmos.authz.v1beta1.MsgExec",
91
+ value: MsgExec.fromPartial(value),
92
+ };
84
93
  }
85
94
  catch (e) {
86
- throw new Error('TxClient:MsgExec: Could not create message: ' + e.message);
95
+ throw new Error("TxClient:MsgExec: Could not create message: " + e.message);
87
96
  }
88
97
  },
89
98
  msgGrant({ value }) {
90
99
  try {
91
- return { typeUrl: "/cosmos.authz.v1beta1.MsgGrant", value: MsgGrant.fromPartial(value) };
100
+ return {
101
+ typeUrl: "/cosmos.authz.v1beta1.MsgGrant",
102
+ value: MsgGrant.fromPartial(value),
103
+ };
92
104
  }
93
105
  catch (e) {
94
- throw new Error('TxClient:MsgGrant: Could not create message: ' + e.message);
106
+ throw new Error("TxClient:MsgGrant: Could not create message: " + e.message);
95
107
  }
96
108
  },
97
109
  };
@@ -112,7 +124,7 @@ class SDKModule {
112
124
  EventGrant: getStructure(typeEventGrant.fromPartial({})),
113
125
  EventRevoke: getStructure(typeEventRevoke.fromPartial({})),
114
126
  };
115
- client.on('signer-changed', (signer) => {
127
+ client.on("signer-changed", (signer) => {
116
128
  this.updateTX(client);
117
129
  });
118
130
  }
@@ -128,13 +140,12 @@ class SDKModule {
128
140
  }
129
141
  }
130
142
  }
131
- ;
132
143
  const Module = (test) => {
133
144
  return {
134
145
  module: {
135
- CosmosAuthzV1Beta1: new SDKModule(test)
146
+ CosmosAuthzV1Beta1: new SDKModule(test),
136
147
  },
137
- registry: msgTypes
148
+ registry: msgTypes,
138
149
  };
139
150
  };
140
151
  export default Module;