decentralcardgame-cardchain-client-ts 0.0.26-rc1 → 0.0.27
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.
- package/DecentralCardGame.cardchain.cardchain/module.js +504 -352
- package/DecentralCardGame.cardchain.cardchain/module.ts +1505 -1267
- package/DecentralCardGame.cardchain.cardchain/registry.js +64 -62
- package/DecentralCardGame.cardchain.cardchain/registry.ts +64 -62
- package/DecentralCardGame.cardchain.cardchain/rest.js +31 -17
- package/DecentralCardGame.cardchain.cardchain/rest.ts +139 -94
- package/DecentralCardGame.cardchain.cardchain/types/amino/amino.ts +1 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.js +86 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.ts +90 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.js +229 -114
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.ts +276 -120
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/set.js +186 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/set.ts +210 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.js +91 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.ts +113 -0
- package/DecentralCardGame.cardchain.cardchain/types.js +3 -1
- package/DecentralCardGame.cardchain.cardchain/types.ts +4 -0
- package/DecentralCardGame.cardchain.featureflag/module.js +4 -1
- package/DecentralCardGame.cardchain.featureflag/module.ts +71 -69
- package/DecentralCardGame.cardchain.featureflag/rest.ts +6 -6
- package/client.js +3 -9
- package/client.ts +154 -167
- package/cosmos.auth.v1beta1/module.js +4 -1
- package/cosmos.auth.v1beta1/module.ts +71 -69
- package/cosmos.auth.v1beta1/rest.ts +21 -21
- package/cosmos.authz.v1beta1/module.js +17 -17
- package/cosmos.authz.v1beta1/module.ts +25 -25
- package/cosmos.authz.v1beta1/registry.js +4 -4
- package/cosmos.authz.v1beta1/registry.ts +4 -4
- package/cosmos.authz.v1beta1/rest.ts +75 -75
- package/cosmos.bank.v1beta1/rest.ts +9 -9
- package/cosmos.distribution.v1beta1/module.js +27 -27
- package/cosmos.distribution.v1beta1/module.ts +42 -42
- package/cosmos.distribution.v1beta1/registry.js +4 -4
- package/cosmos.distribution.v1beta1/registry.ts +4 -4
- package/cosmos.distribution.v1beta1/rest.ts +20 -20
- package/cosmos.gov.v1/module.js +24 -24
- package/cosmos.gov.v1/module.ts +36 -36
- package/cosmos.gov.v1/registry.js +4 -4
- package/cosmos.gov.v1/registry.ts +4 -4
- package/cosmos.gov.v1/rest.ts +90 -90
- package/cosmos.gov.v1beta1/module.js +27 -27
- package/cosmos.gov.v1beta1/module.ts +42 -42
- package/cosmos.gov.v1beta1/registry.js +4 -4
- package/cosmos.gov.v1beta1/registry.ts +4 -4
- package/cosmos.gov.v1beta1/rest.ts +152 -152
- package/cosmos.group.v1/module.js +108 -108
- package/cosmos.group.v1/module.ts +164 -164
- package/cosmos.group.v1/registry.js +18 -18
- package/cosmos.group.v1/registry.ts +18 -18
- package/cosmos.group.v1/rest.js +5 -5
- package/cosmos.group.v1/rest.ts +214 -214
- package/cosmos.mint.v1beta1/rest.ts +13 -13
- package/cosmos.nft.v1beta1/rest.ts +132 -132
- package/cosmos.slashing.v1beta1/rest.ts +19 -19
- package/cosmos.staking.v1beta1/module.js +39 -39
- package/cosmos.staking.v1beta1/module.ts +59 -59
- package/cosmos.staking.v1beta1/registry.js +6 -6
- package/cosmos.staking.v1beta1/registry.ts +6 -6
- package/cosmos.staking.v1beta1/rest.ts +95 -95
- package/cosmos.upgrade.v1beta1/module.js +16 -16
- package/cosmos.upgrade.v1beta1/module.ts +24 -24
- package/cosmos.upgrade.v1beta1/registry.js +2 -2
- package/cosmos.upgrade.v1beta1/registry.ts +2 -2
- package/ibc.applications.interchain_accounts.controller.v1/rest.ts +10 -10
- package/ibc.applications.interchain_accounts.host.v1/rest.ts +13 -13
- package/ibc.applications.transfer.v1/rest.ts +3 -3
- package/ibc.core.channel.v1/rest.ts +44 -44
- package/package.json +1 -1
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/card.js +0 -651
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/card.ts +0 -735
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/copyright_proposal.js +0 -102
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/copyright_proposal.ts +0 -134
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/council.js +0 -350
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/council.ts +0 -409
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/genesis.js +0 -254
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/genesis.ts +0 -281
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/image.js +0 -88
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/image.ts +0 -115
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/match.js +0 -308
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/match.ts +0 -355
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/match_reporter_proposal.js +0 -67
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/match_reporter_proposal.ts +0 -92
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/num.js +0 -73
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/num.ts +0 -102
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/params.js +0 -314
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/params.ts +0 -367
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/query.js +0 -1984
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/query.ts +0 -2382
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/running_average.js +0 -85
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/running_average.ts +0 -111
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/sell_offer.js +0 -148
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/sell_offer.ts +0 -183
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/server.js +0 -93
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/server.ts +0 -124
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/set.js +0 -365
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/set.ts +0 -416
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/set_proposal.js +0 -93
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/set_proposal.ts +0 -124
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/tx.js +0 -4494
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/tx.ts +0 -5526
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/user.js +0 -522
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/user.ts +0 -583
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/voting.js +0 -346
- package/DecentralCardGame.cardchain.cardchain/types/DecentralCardGame/cardchain/cardchain/voting.ts +0 -417
package/client.ts
CHANGED
|
@@ -1,182 +1,169 @@
|
|
|
1
1
|
/// <reference path="./types.d.ts" />
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
GeneratedType,
|
|
4
|
+
OfflineSigner,
|
|
5
|
+
EncodeObject,
|
|
6
|
+
Registry,
|
|
7
7
|
} from "@cosmjs/proto-signing";
|
|
8
|
-
import {StdFee} from "@cosmjs/amino";
|
|
9
|
-
import {
|
|
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";
|
|
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";
|
|
18
15
|
|
|
19
16
|
const defaultFee = {
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
amount: [],
|
|
18
|
+
gas: "200000",
|
|
22
19
|
};
|
|
23
20
|
|
|
24
21
|
export class IgniteClient extends EventEmitter {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class AugmentedClient extends this {
|
|
35
|
-
static plugins = currentPlugins.concat(plugin);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (Array.isArray(plugin)) {
|
|
39
|
-
type Extension = UnionToIntersection<Return<T>['module']>
|
|
40
|
-
return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type Extension = Return<T>['module']
|
|
44
|
-
return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async signAndBroadcast(msgs: EncodeObject[], fee: StdFee, memo: string) {
|
|
48
|
-
if (this.signer) {
|
|
49
|
-
const {address} = (await this.signer.getAccounts())[0];
|
|
50
|
-
const signingClient = await SigningStargateClient.connectWithSigner(this.env.rpcURL, this.signer, {
|
|
51
|
-
aminoTypes: this.aminoTypes,
|
|
52
|
-
registry: new Registry(this.registry),
|
|
53
|
-
prefix: this.env.prefix
|
|
54
|
-
});
|
|
55
|
-
return await signingClient.signAndBroadcast(address, msgs, fee ? fee : defaultFee, memo)
|
|
56
|
-
} else {
|
|
57
|
-
throw new Error(" Signer is not present.");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
constructor(env: Env, signer?: OfflineSigner) {
|
|
62
|
-
super();
|
|
63
|
-
this.env = env;
|
|
64
|
-
this.setMaxListeners(0);
|
|
65
|
-
this.signer = signer;
|
|
66
|
-
this.aminoTypes = new AminoTypes({additions: createDecentralCardgameAminoConverters(), prefix:"cc"})
|
|
67
|
-
const classConstructor = this.constructor as typeof IgniteClient;
|
|
68
|
-
classConstructor.plugins.forEach(plugin => {
|
|
69
|
-
const pluginInstance = plugin(this);
|
|
70
|
-
Object.assign(this, pluginInstance.module)
|
|
71
|
-
if (this.registry) {
|
|
72
|
-
this.registry = this.registry.concat(pluginInstance.registry)
|
|
73
|
-
}
|
|
74
|
-
});
|
|
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);
|
|
75
31
|
}
|
|
76
32
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
33
|
+
if (Array.isArray(plugin)) {
|
|
34
|
+
type Extension = UnionToIntersection<Return<T>['module']>
|
|
35
|
+
return AugmentedClient as typeof IgniteClient & Constructor<Extension>;
|
|
80
36
|
}
|
|
81
37
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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.");
|
|
85
49
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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 = window.keplr.getOfflineSigner(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
|
+
);
|
|
181
167
|
}
|
|
168
|
+
}
|
|
182
169
|
}
|
|
@@ -18,7 +18,10 @@ const defaultFee = {
|
|
|
18
18
|
amount: [],
|
|
19
19
|
gas: "200000",
|
|
20
20
|
};
|
|
21
|
-
export const txClient = ({ signer, prefix, addr } = {
|
|
21
|
+
export const txClient = ({ signer, prefix, addr } = {
|
|
22
|
+
addr: "http://localhost:26657",
|
|
23
|
+
prefix: "cosmos"
|
|
24
|
+
}) => {
|
|
22
25
|
return {};
|
|
23
26
|
};
|
|
24
27
|
export const queryClient = ({ addr: addr } = { addr: "http://localhost:1317" }) => {
|
|
@@ -1,102 +1,104 @@
|
|
|
1
1
|
// Generated by Ignite ignite.com/cli
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import {StdFee} from "@cosmjs/amino";
|
|
4
|
+
import {SigningStargateClient, DeliverTxResponse} from "@cosmjs/stargate";
|
|
5
|
+
import {EncodeObject, GeneratedType, OfflineSigner, Registry} from "@cosmjs/proto-signing";
|
|
6
|
+
import {msgTypes} from './registry';
|
|
7
|
+
import {IgniteClient} from "../client"
|
|
8
|
+
import {MissingWalletError} from "../helpers"
|
|
9
|
+
import {Api} from "./rest";
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
export { };
|
|
11
|
+
import {BaseAccount as typeBaseAccount} from "./types"
|
|
12
|
+
import {ModuleAccount as typeModuleAccount} from "./types"
|
|
13
|
+
import {Params as typeParams} from "./types"
|
|
16
14
|
|
|
15
|
+
export {};
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
export const registry = new Registry(msgTypes);
|
|
20
19
|
|
|
21
20
|
type Field = {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
name: string;
|
|
22
|
+
type: unknown;
|
|
24
23
|
}
|
|
24
|
+
|
|
25
25
|
function getStructure(template) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const structure: { fields: Field[] } = {fields: []}
|
|
27
|
+
for (let [key, value] of Object.entries(template)) {
|
|
28
|
+
let field = {name: key, type: typeof value}
|
|
29
|
+
structure.fields.push(field)
|
|
30
|
+
}
|
|
31
|
+
return structure
|
|
32
32
|
}
|
|
33
|
+
|
|
33
34
|
const defaultFee = {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
amount: [],
|
|
36
|
+
gas: "200000",
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
interface TxClientOptions {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
addr: string
|
|
41
|
+
prefix: string
|
|
42
|
+
signer?: OfflineSigner
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
export const txClient = ({
|
|
45
|
+
export const txClient = ({signer, prefix, addr}: TxClientOptions = {
|
|
46
|
+
addr: "http://localhost:26657",
|
|
47
|
+
prefix: "cosmos"
|
|
48
|
+
}) => {
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
+
return {}
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
interface QueryClientOptions {
|
|
53
|
-
|
|
54
|
+
addr: string
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
export const queryClient = ({
|
|
57
|
-
|
|
57
|
+
export const queryClient = ({addr: addr}: QueryClientOptions = {addr: "http://localhost:1317"}) => {
|
|
58
|
+
return new Api({baseURL: addr});
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
class SDKModule {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
62
|
+
public query: ReturnType<typeof queryClient>;
|
|
63
|
+
public tx: ReturnType<typeof txClient>;
|
|
64
|
+
public structure: Record<string, unknown>;
|
|
65
|
+
public registry: Array<[string, GeneratedType]> = [];
|
|
66
|
+
|
|
67
|
+
constructor(client: IgniteClient) {
|
|
68
|
+
|
|
69
|
+
this.query = queryClient({addr: client.env.apiURL});
|
|
70
|
+
this.updateTX(client);
|
|
71
|
+
this.structure = {
|
|
72
|
+
BaseAccount: getStructure(typeBaseAccount.fromPartial({})),
|
|
73
|
+
ModuleAccount: getStructure(typeModuleAccount.fromPartial({})),
|
|
74
|
+
Params: getStructure(typeParams.fromPartial({})),
|
|
75
|
+
|
|
76
|
+
};
|
|
77
|
+
client.on('signer-changed', (signer) => {
|
|
78
|
+
this.updateTX(client);
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
updateTX(client: IgniteClient) {
|
|
83
|
+
const methods = txClient({
|
|
84
|
+
signer: client.signer,
|
|
85
|
+
addr: client.env.rpcURL,
|
|
86
|
+
prefix: client.env.prefix ?? "cosmos",
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
this.tx = methods;
|
|
90
|
+
for (let m in methods) {
|
|
91
|
+
this.tx[m] = methods[m].bind(this.tx);
|
|
92
|
+
}
|
|
90
93
|
}
|
|
91
|
-
}
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
const Module = (test: IgniteClient) => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
return {
|
|
98
|
+
module: {
|
|
99
|
+
CosmosAuthV1Beta1: new SDKModule(test)
|
|
100
|
+
},
|
|
101
|
+
registry: msgTypes
|
|
102
|
+
}
|
|
101
103
|
}
|
|
102
104
|
export default Module;
|
|
@@ -9,6 +9,26 @@
|
|
|
9
9
|
* ---------------------------------------------------------------
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Params defines the parameters for the auth module.
|
|
14
|
+
*/
|
|
15
|
+
export interface Authv1Beta1Params {
|
|
16
|
+
/** @format uint64 */
|
|
17
|
+
max_memo_characters?: string;
|
|
18
|
+
|
|
19
|
+
/** @format uint64 */
|
|
20
|
+
tx_sig_limit?: string;
|
|
21
|
+
|
|
22
|
+
/** @format uint64 */
|
|
23
|
+
tx_size_cost_per_byte?: string;
|
|
24
|
+
|
|
25
|
+
/** @format uint64 */
|
|
26
|
+
sig_verify_cost_ed25519?: string;
|
|
27
|
+
|
|
28
|
+
/** @format uint64 */
|
|
29
|
+
sig_verify_cost_secp256k1?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
12
32
|
/**
|
|
13
33
|
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
|
14
34
|
URL that describes the type of the serialized message.
|
|
@@ -230,26 +250,6 @@ export interface V1Beta1PageResponse {
|
|
|
230
250
|
total?: string;
|
|
231
251
|
}
|
|
232
252
|
|
|
233
|
-
/**
|
|
234
|
-
* Params defines the parameters for the auth module.
|
|
235
|
-
*/
|
|
236
|
-
export interface V1Beta1Params {
|
|
237
|
-
/** @format uint64 */
|
|
238
|
-
max_memo_characters?: string;
|
|
239
|
-
|
|
240
|
-
/** @format uint64 */
|
|
241
|
-
tx_sig_limit?: string;
|
|
242
|
-
|
|
243
|
-
/** @format uint64 */
|
|
244
|
-
tx_size_cost_per_byte?: string;
|
|
245
|
-
|
|
246
|
-
/** @format uint64 */
|
|
247
|
-
sig_verify_cost_ed25519?: string;
|
|
248
|
-
|
|
249
|
-
/** @format uint64 */
|
|
250
|
-
sig_verify_cost_secp256k1?: string;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
253
|
/**
|
|
254
254
|
* Since: cosmos-sdk 0.46.2
|
|
255
255
|
*/
|
|
@@ -357,7 +357,7 @@ export interface V1Beta1QueryModuleAccountsResponse {
|
|
|
357
357
|
*/
|
|
358
358
|
export interface V1Beta1QueryParamsResponse {
|
|
359
359
|
/** params defines the parameters of the module. */
|
|
360
|
-
params?:
|
|
360
|
+
params?: Authv1Beta1Params;
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, ResponseType } from "axios";
|