decentralcardgame-cardchain-client-ts 0.0.17 → 0.0.19

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 (27) hide show
  1. package/DecentralCardGame.cardchain.cardchain/module.js +304 -310
  2. package/DecentralCardGame.cardchain.cardchain/module.ts +460 -466
  3. package/DecentralCardGame.cardchain.cardchain/registry.js +60 -60
  4. package/DecentralCardGame.cardchain.cardchain/registry.ts +60 -60
  5. package/DecentralCardGame.cardchain.cardchain/rest.js +7 -31
  6. package/DecentralCardGame.cardchain.cardchain/rest.ts +9 -84
  7. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/aminomessages.js +12 -0
  8. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/aminomessages.ts +32 -0
  9. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.js +0 -6
  10. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.ts +0 -6
  11. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/council.js +11 -17
  12. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/council.ts +11 -17
  13. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/params.js +0 -11
  14. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/params.ts +0 -13
  15. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.js +2 -331
  16. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.ts +2 -390
  17. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.js +8 -8
  18. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.ts +9 -9
  19. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/user.js +57 -81
  20. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/user.ts +56 -93
  21. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/voting.js +50 -59
  22. package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/voting.ts +53 -71
  23. package/DecentralCardGame.cardchain.cardchain/types.js +1 -4
  24. package/DecentralCardGame.cardchain.cardchain/types.ts +0 -6
  25. package/client.js +7 -2
  26. package/client.ts +165 -154
  27. package/package.json +1 -1
@@ -4,6 +4,51 @@ import _m0 from "protobufjs/minimal";
4
4
 
5
5
  export const protobufPackage = "DecentralCardGame.cardchain.cardchain";
6
6
 
7
+ export enum VoteType {
8
+ fairEnough = 0,
9
+ inappropriate = 1,
10
+ overpowered = 2,
11
+ underpowered = 3,
12
+ UNRECOGNIZED = -1,
13
+ }
14
+
15
+ export function voteTypeFromJSON(object: any): VoteType {
16
+ switch (object) {
17
+ case 0:
18
+ case "fairEnough":
19
+ return VoteType.fairEnough;
20
+ case 1:
21
+ case "inappropriate":
22
+ return VoteType.inappropriate;
23
+ case 2:
24
+ case "overpowered":
25
+ return VoteType.overpowered;
26
+ case 3:
27
+ case "underpowered":
28
+ return VoteType.underpowered;
29
+ case -1:
30
+ case "UNRECOGNIZED":
31
+ default:
32
+ return VoteType.UNRECOGNIZED;
33
+ }
34
+ }
35
+
36
+ export function voteTypeToJSON(object: VoteType): string {
37
+ switch (object) {
38
+ case VoteType.fairEnough:
39
+ return "fairEnough";
40
+ case VoteType.inappropriate:
41
+ return "inappropriate";
42
+ case VoteType.overpowered:
43
+ return "overpowered";
44
+ case VoteType.underpowered:
45
+ return "underpowered";
46
+ case VoteType.UNRECOGNIZED:
47
+ default:
48
+ return "UNRECOGNIZED";
49
+ }
50
+ }
51
+
7
52
  export interface VotingResults {
8
53
  totalVotes: number;
9
54
  totalFairEnoughVotes: number;
@@ -25,12 +70,7 @@ export interface VotingResult {
25
70
 
26
71
  export interface SingleVote {
27
72
  cardId: number;
28
- voteType: string;
29
- }
30
-
31
- export interface VoteRight {
32
- cardId: number;
33
- expireBlock: number;
73
+ voteType: VoteType;
34
74
  }
35
75
 
36
76
  function createBaseVotingResults(): VotingResults {
@@ -255,7 +295,7 @@ export const VotingResult = {
255
295
  };
256
296
 
257
297
  function createBaseSingleVote(): SingleVote {
258
- return { cardId: 0, voteType: "" };
298
+ return { cardId: 0, voteType: 0 };
259
299
  }
260
300
 
261
301
  export const SingleVote = {
@@ -263,8 +303,8 @@ export const SingleVote = {
263
303
  if (message.cardId !== 0) {
264
304
  writer.uint32(8).uint64(message.cardId);
265
305
  }
266
- if (message.voteType !== "") {
267
- writer.uint32(18).string(message.voteType);
306
+ if (message.voteType !== 0) {
307
+ writer.uint32(16).int32(message.voteType);
268
308
  }
269
309
  return writer;
270
310
  },
@@ -280,7 +320,7 @@ export const SingleVote = {
280
320
  message.cardId = longToNumber(reader.uint64() as Long);
281
321
  break;
282
322
  case 2:
283
- message.voteType = reader.string();
323
+ message.voteType = reader.int32() as any;
284
324
  break;
285
325
  default:
286
326
  reader.skipType(tag & 7);
@@ -293,79 +333,21 @@ export const SingleVote = {
293
333
  fromJSON(object: any): SingleVote {
294
334
  return {
295
335
  cardId: isSet(object.cardId) ? Number(object.cardId) : 0,
296
- voteType: isSet(object.voteType) ? String(object.voteType) : "",
336
+ voteType: isSet(object.voteType) ? voteTypeFromJSON(object.voteType) : 0,
297
337
  };
298
338
  },
299
339
 
300
340
  toJSON(message: SingleVote): unknown {
301
341
  const obj: any = {};
302
342
  message.cardId !== undefined && (obj.cardId = Math.round(message.cardId));
303
- message.voteType !== undefined && (obj.voteType = message.voteType);
343
+ message.voteType !== undefined && (obj.voteType = voteTypeToJSON(message.voteType));
304
344
  return obj;
305
345
  },
306
346
 
307
347
  fromPartial<I extends Exact<DeepPartial<SingleVote>, I>>(object: I): SingleVote {
308
348
  const message = createBaseSingleVote();
309
349
  message.cardId = object.cardId ?? 0;
310
- message.voteType = object.voteType ?? "";
311
- return message;
312
- },
313
- };
314
-
315
- function createBaseVoteRight(): VoteRight {
316
- return { cardId: 0, expireBlock: 0 };
317
- }
318
-
319
- export const VoteRight = {
320
- encode(message: VoteRight, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
321
- if (message.cardId !== 0) {
322
- writer.uint32(8).uint64(message.cardId);
323
- }
324
- if (message.expireBlock !== 0) {
325
- writer.uint32(16).int64(message.expireBlock);
326
- }
327
- return writer;
328
- },
329
-
330
- decode(input: _m0.Reader | Uint8Array, length?: number): VoteRight {
331
- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
332
- let end = length === undefined ? reader.len : reader.pos + length;
333
- const message = createBaseVoteRight();
334
- while (reader.pos < end) {
335
- const tag = reader.uint32();
336
- switch (tag >>> 3) {
337
- case 1:
338
- message.cardId = longToNumber(reader.uint64() as Long);
339
- break;
340
- case 2:
341
- message.expireBlock = longToNumber(reader.int64() as Long);
342
- break;
343
- default:
344
- reader.skipType(tag & 7);
345
- break;
346
- }
347
- }
348
- return message;
349
- },
350
-
351
- fromJSON(object: any): VoteRight {
352
- return {
353
- cardId: isSet(object.cardId) ? Number(object.cardId) : 0,
354
- expireBlock: isSet(object.expireBlock) ? Number(object.expireBlock) : 0,
355
- };
356
- },
357
-
358
- toJSON(message: VoteRight): unknown {
359
- const obj: any = {};
360
- message.cardId !== undefined && (obj.cardId = Math.round(message.cardId));
361
- message.expireBlock !== undefined && (obj.expireBlock = Math.round(message.expireBlock));
362
- return obj;
363
- },
364
-
365
- fromPartial<I extends Exact<DeepPartial<VoteRight>, I>>(object: I): VoteRight {
366
- const message = createBaseVoteRight();
367
- message.cardId = object.cardId ?? 0;
368
- message.expireBlock = object.expireBlock ?? 0;
350
+ message.voteType = object.voteType ?? 0;
369
351
  return message;
370
352
  },
371
353
  };
@@ -11,15 +11,12 @@ import { Params } from "./types/cardchain/cardchain/params";
11
11
  import { IgnoreMatches } from "./types/cardchain/cardchain/query";
12
12
  import { IgnoreSellOffers } from "./types/cardchain/cardchain/query";
13
13
  import { QueryQServerResponse } from "./types/cardchain/cardchain/query";
14
- import { IgnoreCouncils } from "./types/cardchain/cardchain/query";
15
14
  import { RunningAverage } from "./types/cardchain/cardchain/running_average";
16
15
  import { Set } from "./types/cardchain/cardchain/set";
17
16
  import { SetProposal } from "./types/cardchain/cardchain/set_proposal";
18
- import { CouncilParticipation } from "./types/cardchain/cardchain/user";
19
17
  import { BoosterPack } from "./types/cardchain/cardchain/user";
20
18
  import { AirDrops } from "./types/cardchain/cardchain/user";
21
19
  import { VotingResults } from "./types/cardchain/cardchain/voting";
22
20
  import { VotingResult } from "./types/cardchain/cardchain/voting";
23
21
  import { SingleVote } from "./types/cardchain/cardchain/voting";
24
- import { VoteRight } from "./types/cardchain/cardchain/voting";
25
- export { Card, TimeStamp, CopyrightProposal, WrapClearResponse, WrapHashResponse, Image, MatchPlayer, MatchReporterProposal, Num, Params, IgnoreMatches, IgnoreSellOffers, QueryQServerResponse, IgnoreCouncils, RunningAverage, Set, SetProposal, CouncilParticipation, BoosterPack, AirDrops, VotingResults, VotingResult, SingleVote, VoteRight, };
22
+ export { Card, TimeStamp, CopyrightProposal, WrapClearResponse, WrapHashResponse, Image, MatchPlayer, MatchReporterProposal, Num, Params, IgnoreMatches, IgnoreSellOffers, QueryQServerResponse, RunningAverage, Set, SetProposal, BoosterPack, AirDrops, VotingResults, VotingResult, SingleVote, };
@@ -11,17 +11,14 @@ import { Params } from "./types/cardchain/cardchain/params"
11
11
  import { IgnoreMatches } from "./types/cardchain/cardchain/query"
12
12
  import { IgnoreSellOffers } from "./types/cardchain/cardchain/query"
13
13
  import { QueryQServerResponse } from "./types/cardchain/cardchain/query"
14
- import { IgnoreCouncils } from "./types/cardchain/cardchain/query"
15
14
  import { RunningAverage } from "./types/cardchain/cardchain/running_average"
16
15
  import { Set } from "./types/cardchain/cardchain/set"
17
16
  import { SetProposal } from "./types/cardchain/cardchain/set_proposal"
18
- import { CouncilParticipation } from "./types/cardchain/cardchain/user"
19
17
  import { BoosterPack } from "./types/cardchain/cardchain/user"
20
18
  import { AirDrops } from "./types/cardchain/cardchain/user"
21
19
  import { VotingResults } from "./types/cardchain/cardchain/voting"
22
20
  import { VotingResult } from "./types/cardchain/cardchain/voting"
23
21
  import { SingleVote } from "./types/cardchain/cardchain/voting"
24
- import { VoteRight } from "./types/cardchain/cardchain/voting"
25
22
 
26
23
 
27
24
  export {
@@ -38,16 +35,13 @@ export {
38
35
  IgnoreMatches,
39
36
  IgnoreSellOffers,
40
37
  QueryQServerResponse,
41
- IgnoreCouncils,
42
38
  RunningAverage,
43
39
  Set,
44
40
  SetProposal,
45
- CouncilParticipation,
46
41
  BoosterPack,
47
42
  AirDrops,
48
43
  VotingResults,
49
44
  VotingResult,
50
45
  SingleVote,
51
- VoteRight,
52
46
 
53
47
  }
package/client.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /// <reference path="./types.d.ts" />
2
2
  import { Registry, } from "@cosmjs/proto-signing";
3
- import { SigningStargateClient } from "@cosmjs/stargate";
3
+ import { AminoTypes, SigningStargateClient } from "@cosmjs/stargate";
4
4
  import { EventEmitter } from "events";
5
+ import { createDecentralCardgameAminoConverters } from "./DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/aminomessages";
5
6
  const defaultFee = {
6
7
  amount: [],
7
8
  gas: "200000",
@@ -20,7 +21,11 @@ export class IgniteClient extends EventEmitter {
20
21
  async signAndBroadcast(msgs, fee, memo) {
21
22
  if (this.signer) {
22
23
  const { address } = (await this.signer.getAccounts())[0];
23
- const signingClient = await SigningStargateClient.connectWithSigner(this.env.rpcURL, this.signer, { registry: new Registry(this.registry), prefix: this.env.prefix });
24
+ const signingClient = await SigningStargateClient.connectWithSigner(this.env.rpcURL, this.signer, {
25
+ aminoTypes: new AminoTypes({ ...createDecentralCardgameAminoConverters() }),
26
+ registry: new Registry(this.registry),
27
+ prefix: this.env.prefix
28
+ });
24
29
  return await signingClient.signAndBroadcast(address, msgs, fee ? fee : defaultFee, memo);
25
30
  }
26
31
  else {
package/client.ts CHANGED
@@ -1,169 +1,180 @@
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 {AminoTypes, 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
+ import {
16
+ createDecentralCardgameAminoConverters
17
+ } from "./DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/aminomessages";
15
18
 
16
19
  const defaultFee = {
17
- amount: [],
18
- gas: "200000",
20
+ amount: [],
21
+ gas: "200000",
19
22
  };
20
23
 
21
24
  export class IgniteClient extends EventEmitter {
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);
25
+ static plugins: Module[] = [];
26
+ env: Env;
27
+ signer?: OfflineSigner;
28
+ registry: Array<[string, GeneratedType]> = [];
29
+
30
+ static plugin<T extends Module | Module[]>(plugin: T) {
31
+ const currentPlugins = this.plugins;
32
+
33
+ class AugmentedClient extends this {
34
+ static plugins = currentPlugins.concat(plugin);
35
+ }
36
+
37
+ if (Array.isArray(plugin)) {
38
+ type Extension = UnionToIntersection<Return<T>['module']>
39
+ return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
40
+ }
41
+
42
+ type Extension = Return<T>['module']
43
+ return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
44
+ }
45
+
46
+ async signAndBroadcast(msgs: EncodeObject[], fee: StdFee, memo: string) {
47
+ if (this.signer) {
48
+ const {address} = (await this.signer.getAccounts())[0];
49
+ const signingClient = await SigningStargateClient.connectWithSigner(this.env.rpcURL, this.signer, {
50
+ aminoTypes: new AminoTypes({...createDecentralCardgameAminoConverters()}),
51
+ registry: new Registry(this.registry),
52
+ prefix: this.env.prefix
53
+ });
54
+ return await signingClient.signAndBroadcast(address, msgs, fee ? fee : defaultFee, memo)
55
+ } else {
56
+ throw new Error(" Signer is not present.");
57
+ }
58
+ }
59
+
60
+ constructor(env: Env, signer?: OfflineSigner) {
61
+ super();
62
+ this.env = env;
63
+ this.setMaxListeners(0);
64
+ this.signer = signer;
65
+ const classConstructor = this.constructor as typeof IgniteClient;
66
+ classConstructor.plugins.forEach(plugin => {
67
+ const pluginInstance = plugin(this);
68
+ Object.assign(this, pluginInstance.module)
69
+ if (this.registry) {
70
+ this.registry = this.registry.concat(pluginInstance.registry)
71
+ }
72
+ });
31
73
  }
32
74
 
33
- if (Array.isArray(plugin)) {
34
- type Extension = UnionToIntersection<Return<T>['module']>
35
- return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
75
+ useSigner(signer: OfflineSigner) {
76
+ this.signer = signer;
77
+ this.emit("signer-changed", this.signer);
36
78
  }
37
79
 
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(this.env.rpcURL, this.signer, { registry: new Registry(this.registry), prefix: this.env.prefix });
46
- return await signingClient.signAndBroadcast(address, msgs, fee ? fee : defaultFee, memo)
47
- } else {
48
- throw new Error(" Signer is not present.");
80
+ removeSigner() {
81
+ this.signer = undefined;
82
+ this.emit("signer-changed", this.signer);
49
83
  }
50
- }
51
-
52
- constructor(env: Env, signer?: OfflineSigner) {
53
- super();
54
- this.env = env;
55
- this.setMaxListeners(0);
56
- this.signer = signer;
57
- const classConstructor = this.constructor as typeof IgniteClient;
58
- classConstructor.plugins.forEach(plugin => {
59
- const pluginInstance = plugin(this);
60
- Object.assign(this, pluginInstance.module)
61
- if (this.registry) {
62
- this.registry = this.registry.concat(pluginInstance.registry)
63
- }
64
- });
65
- }
66
- useSigner(signer: OfflineSigner) {
67
- this.signer = signer;
68
- this.emit("signer-changed", this.signer);
69
- }
70
- removeSigner() {
71
- this.signer = undefined;
72
- this.emit("signer-changed", this.signer);
73
- }
74
- async useKeplr(keplrChainInfo: Partial<ChainInfo> = {}) {
75
- // Using queryClients directly because BaseClient has no knowledge of the modules at this stage
76
- try {
77
- const queryClient = (
78
- await import("./cosmos.base.tendermint.v1beta1/module")
79
- ).queryClient;
80
- const stakingQueryClient = (
81
- await import("./cosmos.staking.v1beta1/module")
82
- ).queryClient;
83
- const bankQueryClient = (await import("./cosmos.bank.v1beta1/module"))
84
- .queryClient;
85
-
86
- const stakingqc = stakingQueryClient({ addr: this.env.apiURL });
87
- const qc = queryClient({ addr: this.env.apiURL });
88
- const node_info = await (await qc.serviceGetNodeInfo()).data;
89
- const chainId = node_info.default_node_info?.network ?? "";
90
- const chainName = chainId?.toUpperCase() + " Network";
91
- const staking = await (await stakingqc.queryParams()).data;
92
- const bankqc = bankQueryClient({ addr: this.env.apiURL });
93
- const tokens = await (await bankqc.queryTotalSupply()).data;
94
- const addrPrefix = this.env.prefix ?? "cosmos";
95
- const rpc = this.env.rpcURL;
96
- const rest = this.env.apiURL;
97
- let stakeCurrency = {
98
- coinDenom: staking.params?.bond_denom?.toUpperCase() ?? "",
99
- coinMinimalDenom: staking.params?.bond_denom ?? "",
100
- coinDecimals: 0,
101
- };
102
-
103
- let bip44 = {
104
- coinType: 118,
105
- };
106
-
107
- let bech32Config = {
108
- bech32PrefixAccAddr: addrPrefix,
109
- bech32PrefixAccPub: addrPrefix + "pub",
110
- bech32PrefixValAddr: addrPrefix + "valoper",
111
- bech32PrefixValPub: addrPrefix + "valoperpub",
112
- bech32PrefixConsAddr: addrPrefix + "valcons",
113
- bech32PrefixConsPub: addrPrefix + "valconspub",
114
- };
115
-
116
- let currencies =
117
- tokens.supply?.map((x) => {
118
- const y = {
119
- coinDenom: x.denom?.toUpperCase() ?? "",
120
- coinMinimalDenom: x.denom ?? "",
121
- coinDecimals: 0,
122
- };
123
- return y;
124
- }) ?? [];
125
-
126
- let feeCurrencies =
127
- tokens.supply?.map((x) => {
128
- const y = {
129
- coinDenom: x.denom?.toUpperCase() ?? "",
130
- coinMinimalDenom: x.denom ?? "",
131
- coinDecimals: 0,
132
- };
133
- return y;
134
- }) ?? [];
135
-
136
- let coinType = 118;
137
-
138
- if (chainId) {
139
- const suggestOptions: ChainInfo = {
140
- chainId,
141
- chainName,
142
- rpc,
143
- rest,
144
- stakeCurrency,
145
- bip44,
146
- bech32Config,
147
- currencies,
148
- feeCurrencies,
149
- ...keplrChainInfo,
150
- };
151
- await window.keplr.experimentalSuggestChain(suggestOptions);
152
-
153
- window.keplr.defaultOptions = {
154
- sign: {
155
- preferNoSetFee: true,
156
- preferNoSetMemo: true,
157
- },
158
- };
159
- }
160
- await window.keplr.enable(chainId);
161
- this.signer = await window.keplr.getOfflineSignerAuto(chainId);
162
- this.emit("signer-changed", this.signer);
163
- } catch (e) {
164
- throw new Error(
165
- "Could not load tendermint, staking and bank modules. Please ensure your client loads them to use useKeplr()"
166
- );
84
+
85
+ async useKeplr(keplrChainInfo: Partial<ChainInfo> = {}) {
86
+ // Using queryClients directly because BaseClient has no knowledge of the modules at this stage
87
+ try {
88
+ const queryClient = (
89
+ await import("./cosmos.base.tendermint.v1beta1/module")
90
+ ).queryClient;
91
+ const stakingQueryClient = (
92
+ await import("./cosmos.staking.v1beta1/module")
93
+ ).queryClient;
94
+ const bankQueryClient = (await import("./cosmos.bank.v1beta1/module"))
95
+ .queryClient;
96
+
97
+ const stakingqc = stakingQueryClient({addr: this.env.apiURL});
98
+ const qc = queryClient({addr: this.env.apiURL});
99
+ const node_info = await (await qc.serviceGetNodeInfo()).data;
100
+ const chainId = node_info.default_node_info?.network ?? "";
101
+ const chainName = chainId?.toUpperCase() + " Network";
102
+ const staking = await (await stakingqc.queryParams()).data;
103
+ const bankqc = bankQueryClient({addr: this.env.apiURL});
104
+ const tokens = await (await bankqc.queryTotalSupply()).data;
105
+ const addrPrefix = this.env.prefix ?? "cosmos";
106
+ const rpc = this.env.rpcURL;
107
+ const rest = this.env.apiURL;
108
+ let stakeCurrency = {
109
+ coinDenom: staking.params?.bond_denom?.toUpperCase() ?? "",
110
+ coinMinimalDenom: staking.params?.bond_denom ?? "",
111
+ coinDecimals: 0,
112
+ };
113
+
114
+ let bip44 = {
115
+ coinType: 118,
116
+ };
117
+
118
+ let bech32Config = {
119
+ bech32PrefixAccAddr: addrPrefix,
120
+ bech32PrefixAccPub: addrPrefix + "pub",
121
+ bech32PrefixValAddr: addrPrefix + "valoper",
122
+ bech32PrefixValPub: addrPrefix + "valoperpub",
123
+ bech32PrefixConsAddr: addrPrefix + "valcons",
124
+ bech32PrefixConsPub: addrPrefix + "valconspub",
125
+ };
126
+
127
+ let currencies =
128
+ tokens.supply?.map((x) => {
129
+ const y = {
130
+ coinDenom: x.denom?.toUpperCase() ?? "",
131
+ coinMinimalDenom: x.denom ?? "",
132
+ coinDecimals: 0,
133
+ };
134
+ return y;
135
+ }) ?? [];
136
+
137
+ let feeCurrencies =
138
+ tokens.supply?.map((x) => {
139
+ const y = {
140
+ coinDenom: x.denom?.toUpperCase() ?? "",
141
+ coinMinimalDenom: x.denom ?? "",
142
+ coinDecimals: 0,
143
+ };
144
+ return y;
145
+ }) ?? [];
146
+
147
+ let coinType = 118;
148
+
149
+ if (chainId) {
150
+ const suggestOptions: ChainInfo = {
151
+ chainId,
152
+ chainName,
153
+ rpc,
154
+ rest,
155
+ stakeCurrency,
156
+ bip44,
157
+ bech32Config,
158
+ currencies,
159
+ feeCurrencies,
160
+ ...keplrChainInfo,
161
+ };
162
+ await window.keplr.experimentalSuggestChain(suggestOptions);
163
+
164
+ window.keplr.defaultOptions = {
165
+ sign: {
166
+ preferNoSetFee: true,
167
+ preferNoSetMemo: true,
168
+ },
169
+ };
170
+ }
171
+ await window.keplr.enable(chainId);
172
+ this.signer = await window.keplr.getOfflineSignerAuto(chainId);
173
+ this.emit("signer-changed", this.signer);
174
+ } catch (e) {
175
+ throw new Error(
176
+ "Could not load tendermint, staking and bank modules. Please ensure your client loads them to use useKeplr()"
177
+ );
178
+ }
167
179
  }
168
- }
169
180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "decentralcardgame-cardchain-client-ts",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "Autogenerated Typescript Client for crowdcontrol cardchain",
5
5
  "author": "Lxgr <lxgr@protonmail.com>",
6
6
  "license": "GPL-v3",