@ark-us/wasmx-stargate 0.0.1
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/.DS_Store +0 -0
- package/.eslintignore +5 -0
- package/.eslintrc.js +108 -0
- package/.gitignore +5 -0
- package/README.md +22 -0
- package/build/encoding.d.ts +12 -0
- package/build/encoding.js +25 -0
- package/build/encoding.js.map +1 -0
- package/build/encoding.spec.d.ts +1 -0
- package/build/encoding.spec.js +78 -0
- package/build/encoding.spec.js.map +1 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +18 -0
- package/build/index.js.map +1 -0
- package/build/modules/index.d.ts +3 -0
- package/build/modules/index.js +14 -0
- package/build/modules/index.js.map +1 -0
- package/build/modules/wasmx/aminomessages.d.ts +49 -0
- package/build/modules/wasmx/aminomessages.js +63 -0
- package/build/modules/wasmx/aminomessages.js.map +1 -0
- package/build/modules/wasmx/aminomessages.spec.d.ts +1 -0
- package/build/modules/wasmx/aminomessages.spec.js +209 -0
- package/build/modules/wasmx/aminomessages.spec.js.map +1 -0
- package/build/modules/wasmx/messages.d.ts +18 -0
- package/build/modules/wasmx/messages.js +22 -0
- package/build/modules/wasmx/messages.js.map +1 -0
- package/build/modules/wasmx/queries.d.ts +42 -0
- package/build/modules/wasmx/queries.js +81 -0
- package/build/modules/wasmx/queries.js.map +1 -0
- package/build/signingwasmxclient.d.ts +160 -0
- package/build/signingwasmxclient.js +303 -0
- package/build/signingwasmxclient.js.map +1 -0
- package/build/tendermintclient.d.ts +3 -0
- package/build/tendermintclient.js +9 -0
- package/build/tendermintclient.js.map +1 -0
- package/build/wasmxclient.d.ts +114 -0
- package/build/wasmxclient.js +344 -0
- package/build/wasmxclient.js.map +1 -0
- package/jasmine-testrunner.js +38 -0
- package/karma.conf.js +54 -0
- package/package.json +93 -0
- package/src/encoding.spec.ts +99 -0
- package/src/encoding.ts +21 -0
- package/src/index.ts +30 -0
- package/src/modules/index.ts +17 -0
- package/src/modules/wasmx/aminomessages.spec.ts +222 -0
- package/src/modules/wasmx/aminomessages.ts +129 -0
- package/src/modules/wasmx/messages.ts +43 -0
- package/src/modules/wasmx/queries.ts +134 -0
- package/src/signingwasmxclient.ts +577 -0
- package/src/tendermintclient.ts +7 -0
- package/src/wasmxclient.ts +477 -0
- package/tsconfig.eslint.json +9 -0
- package/tsconfig.json +12 -0
- package/typedoc.js +11 -0
- package/webpack.web.config.js +37 -0
- package/yarn-error.log +4205 -0
- package/yarn.lock +4145 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WasmXClient = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
5
|
+
const encoding_1 = require("@cosmjs/encoding");
|
|
6
|
+
const math_1 = require("@cosmjs/math");
|
|
7
|
+
const stargate_1 = require("@cosmjs/stargate");
|
|
8
|
+
const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
9
|
+
const utils_1 = require("@cosmjs/utils");
|
|
10
|
+
const modules_1 = require("./modules");
|
|
11
|
+
class WasmXClient {
|
|
12
|
+
constructor(tmClient) {
|
|
13
|
+
this.codesCache = new Map();
|
|
14
|
+
this.chainId = "";
|
|
15
|
+
if (tmClient) {
|
|
16
|
+
this.tmClient = tmClient;
|
|
17
|
+
this.queryClient = stargate_1.QueryClient.withExtensions(tmClient, stargate_1.setupAuthExtension, stargate_1.setupBankExtension, modules_1.setupWasmExtension, stargate_1.setupTxExtension);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance by connecting to the given Tendermint RPC endpoint.
|
|
22
|
+
*
|
|
23
|
+
* For now this uses the Tendermint 0.34 client. If you need Tendermint 0.37
|
|
24
|
+
* support, see `create`.
|
|
25
|
+
*/
|
|
26
|
+
static async connect(endpoint) {
|
|
27
|
+
const tmClient = await tendermint_rpc_1.Tendermint34Client.connect(endpoint);
|
|
28
|
+
return WasmXClient.create(tmClient);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates an instance from a manually created Tendermint client.
|
|
32
|
+
* Use this to use `Tendermint37Client` instead of `Tendermint34Client`.
|
|
33
|
+
*/
|
|
34
|
+
static async create(tmClient) {
|
|
35
|
+
return new WasmXClient(tmClient);
|
|
36
|
+
}
|
|
37
|
+
getTmClient() {
|
|
38
|
+
return this.tmClient;
|
|
39
|
+
}
|
|
40
|
+
forceGetTmClient() {
|
|
41
|
+
if (!this.tmClient) {
|
|
42
|
+
throw new Error("Tendermint client not available. You cannot use online functionality in offline mode.");
|
|
43
|
+
}
|
|
44
|
+
return this.tmClient;
|
|
45
|
+
}
|
|
46
|
+
getQueryClient() {
|
|
47
|
+
return this.queryClient;
|
|
48
|
+
}
|
|
49
|
+
forceGetQueryClient() {
|
|
50
|
+
if (!this.queryClient) {
|
|
51
|
+
throw new Error("Query client not available. You cannot use online functionality in offline mode.");
|
|
52
|
+
}
|
|
53
|
+
return this.queryClient;
|
|
54
|
+
}
|
|
55
|
+
async getChainId() {
|
|
56
|
+
if (!this.chainId) {
|
|
57
|
+
const response = await this.forceGetTmClient().status();
|
|
58
|
+
const chainId = response.nodeInfo.network;
|
|
59
|
+
if (!chainId)
|
|
60
|
+
throw new Error("Chain ID must not be empty");
|
|
61
|
+
this.chainId = chainId;
|
|
62
|
+
}
|
|
63
|
+
return this.chainId;
|
|
64
|
+
}
|
|
65
|
+
async getHeight() {
|
|
66
|
+
const status = await this.forceGetTmClient().status();
|
|
67
|
+
return status.syncInfo.latestBlockHeight;
|
|
68
|
+
}
|
|
69
|
+
async getAccount(searchAddress) {
|
|
70
|
+
try {
|
|
71
|
+
const account = await this.forceGetQueryClient().auth.account(searchAddress);
|
|
72
|
+
return account ? (0, stargate_1.accountFromAny)(account) : null;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (/rpc error: code = NotFound/i.test(error.toString())) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async getSequence(address) {
|
|
82
|
+
const account = await this.getAccount(address);
|
|
83
|
+
if (!account) {
|
|
84
|
+
throw new Error(`Account '${address}' does not exist on chain. Send some tokens there before trying to query sequence.`);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
accountNumber: account.accountNumber,
|
|
88
|
+
sequence: account.sequence,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async getBlock(height) {
|
|
92
|
+
const response = await this.forceGetTmClient().block(height);
|
|
93
|
+
return {
|
|
94
|
+
id: (0, encoding_1.toHex)(response.blockId.hash).toUpperCase(),
|
|
95
|
+
header: {
|
|
96
|
+
version: {
|
|
97
|
+
block: new math_1.Uint53(response.block.header.version.block).toString(),
|
|
98
|
+
app: new math_1.Uint53(response.block.header.version.app).toString(),
|
|
99
|
+
},
|
|
100
|
+
height: response.block.header.height,
|
|
101
|
+
chainId: response.block.header.chainId,
|
|
102
|
+
time: (0, tendermint_rpc_1.toRfc3339WithNanoseconds)(response.block.header.time),
|
|
103
|
+
},
|
|
104
|
+
txs: response.block.txs,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async getBalance(address, searchDenom) {
|
|
108
|
+
return this.forceGetQueryClient().bank.balance(address, searchDenom);
|
|
109
|
+
}
|
|
110
|
+
async getTx(id) {
|
|
111
|
+
const results = await this.txsQuery(`tx.hash='${id}'`);
|
|
112
|
+
return results[0] ?? null;
|
|
113
|
+
}
|
|
114
|
+
async searchTx(query, filter = {}) {
|
|
115
|
+
const minHeight = filter.minHeight || 0;
|
|
116
|
+
const maxHeight = filter.maxHeight || Number.MAX_SAFE_INTEGER;
|
|
117
|
+
if (maxHeight < minHeight)
|
|
118
|
+
return []; // optional optimization
|
|
119
|
+
function withFilters(originalQuery) {
|
|
120
|
+
return `${originalQuery} AND tx.height>=${minHeight} AND tx.height<=${maxHeight}`;
|
|
121
|
+
}
|
|
122
|
+
let txs;
|
|
123
|
+
if ((0, stargate_1.isSearchByHeightQuery)(query)) {
|
|
124
|
+
txs =
|
|
125
|
+
query.height >= minHeight && query.height <= maxHeight
|
|
126
|
+
? await this.txsQuery(`tx.height=${query.height}`)
|
|
127
|
+
: [];
|
|
128
|
+
}
|
|
129
|
+
else if ((0, stargate_1.isSearchBySentFromOrToQuery)(query)) {
|
|
130
|
+
const sentQuery = withFilters(`message.module='bank' AND transfer.sender='${query.sentFromOrTo}'`);
|
|
131
|
+
const receivedQuery = withFilters(`message.module='bank' AND transfer.recipient='${query.sentFromOrTo}'`);
|
|
132
|
+
const [sent, received] = await Promise.all([sentQuery, receivedQuery].map((rawQuery) => this.txsQuery(rawQuery)));
|
|
133
|
+
const sentHashes = sent.map((t) => t.hash);
|
|
134
|
+
txs = [...sent, ...received.filter((t) => !sentHashes.includes(t.hash))];
|
|
135
|
+
}
|
|
136
|
+
else if ((0, stargate_1.isSearchByTagsQuery)(query)) {
|
|
137
|
+
const rawQuery = withFilters(query.tags.map((t) => `${t.key}='${t.value}'`).join(" AND "));
|
|
138
|
+
txs = await this.txsQuery(rawQuery);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
throw new Error("Unknown query type");
|
|
142
|
+
}
|
|
143
|
+
const filtered = txs.filter((tx) => tx.height >= minHeight && tx.height <= maxHeight);
|
|
144
|
+
return filtered;
|
|
145
|
+
}
|
|
146
|
+
disconnect() {
|
|
147
|
+
if (this.tmClient)
|
|
148
|
+
this.tmClient.disconnect();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Broadcasts a signed transaction to the network and monitors its inclusion in a block.
|
|
152
|
+
*
|
|
153
|
+
* If broadcasting is rejected by the node for some reason (e.g. because of a CheckTx failure),
|
|
154
|
+
* an error is thrown.
|
|
155
|
+
*
|
|
156
|
+
* If the transaction is not included in a block before the provided timeout, this errors with a `TimeoutError`.
|
|
157
|
+
*
|
|
158
|
+
* If the transaction is included in a block, a `DeliverTxResponse` is returned. The caller then
|
|
159
|
+
* usually needs to check for execution success or failure.
|
|
160
|
+
*/
|
|
161
|
+
// NOTE: This method is tested against slow chains and timeouts in the @cosmjs/stargate package.
|
|
162
|
+
// Make sure it is kept in sync!
|
|
163
|
+
async broadcastTx(tx, timeoutMs = 60000, pollIntervalMs = 3000) {
|
|
164
|
+
let timedOut = false;
|
|
165
|
+
const txPollTimeout = setTimeout(() => {
|
|
166
|
+
timedOut = true;
|
|
167
|
+
}, timeoutMs);
|
|
168
|
+
const pollForTx = async (txId) => {
|
|
169
|
+
if (timedOut) {
|
|
170
|
+
throw new stargate_1.TimeoutError(`Transaction with ID ${txId} was submitted but was not yet found on the chain. You might want to check later. There was a wait of ${timeoutMs / 1000} seconds.`, txId);
|
|
171
|
+
}
|
|
172
|
+
await (0, utils_1.sleep)(pollIntervalMs);
|
|
173
|
+
const result = await this.getTx(txId);
|
|
174
|
+
return result
|
|
175
|
+
? {
|
|
176
|
+
code: result.code,
|
|
177
|
+
height: result.height,
|
|
178
|
+
rawLog: result.rawLog,
|
|
179
|
+
transactionHash: txId,
|
|
180
|
+
events: result.events,
|
|
181
|
+
gasUsed: result.gasUsed,
|
|
182
|
+
gasWanted: result.gasWanted,
|
|
183
|
+
}
|
|
184
|
+
: pollForTx(txId);
|
|
185
|
+
};
|
|
186
|
+
const broadcasted = await this.forceGetTmClient().broadcastTxSync({ tx });
|
|
187
|
+
if (broadcasted.code) {
|
|
188
|
+
return Promise.reject(new stargate_1.BroadcastTxError(broadcasted.code, broadcasted.codespace ?? "", broadcasted.log));
|
|
189
|
+
}
|
|
190
|
+
const transactionId = (0, encoding_1.toHex)(broadcasted.hash).toUpperCase();
|
|
191
|
+
return new Promise((resolve, reject) => pollForTx(transactionId).then((value) => {
|
|
192
|
+
clearTimeout(txPollTimeout);
|
|
193
|
+
resolve(value);
|
|
194
|
+
}, (error) => {
|
|
195
|
+
clearTimeout(txPollTimeout);
|
|
196
|
+
reject(error);
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* getCodes() returns all codes and is just looping through all pagination pages.
|
|
201
|
+
*
|
|
202
|
+
* This is potentially inefficient and advanced apps should consider creating
|
|
203
|
+
* their own query client to handle pagination together with the app's screens.
|
|
204
|
+
*/
|
|
205
|
+
async getCodes() {
|
|
206
|
+
const allCodes = [];
|
|
207
|
+
let startAtKey = undefined;
|
|
208
|
+
do {
|
|
209
|
+
const { codeInfos, pagination } = await this.forceGetQueryClient().wasm.listCodeInfo(startAtKey);
|
|
210
|
+
const loadedCodes = codeInfos || [];
|
|
211
|
+
allCodes.push(...loadedCodes);
|
|
212
|
+
startAtKey = pagination?.nextKey;
|
|
213
|
+
} while (startAtKey?.length !== 0);
|
|
214
|
+
return allCodes.map((entry) => {
|
|
215
|
+
(0, utils_1.assert)(entry.creator && entry.codeId && entry.dataHash, "entry incomplete");
|
|
216
|
+
return {
|
|
217
|
+
id: entry.codeId.toNumber(),
|
|
218
|
+
creator: entry.creator,
|
|
219
|
+
checksum: (0, encoding_1.toHex)(entry.dataHash),
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async getCodeDetails(codeId) {
|
|
224
|
+
const cached = this.codesCache.get(codeId);
|
|
225
|
+
if (cached)
|
|
226
|
+
return cached;
|
|
227
|
+
const { codeInfo, data } = await this.forceGetQueryClient().wasm.getCode(codeId);
|
|
228
|
+
(0, utils_1.assert)(codeInfo && codeInfo.codeId && codeInfo.creator && codeInfo.dataHash && data, "codeInfo missing or incomplete");
|
|
229
|
+
const codeDetails = {
|
|
230
|
+
id: codeInfo.codeId.toNumber(),
|
|
231
|
+
creator: codeInfo.creator,
|
|
232
|
+
checksum: (0, encoding_1.toHex)(codeInfo.dataHash),
|
|
233
|
+
data: data,
|
|
234
|
+
};
|
|
235
|
+
this.codesCache.set(codeId, codeDetails);
|
|
236
|
+
return codeDetails;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* getContracts() returns all contract instances for one code and is just looping through all pagination pages.
|
|
240
|
+
*
|
|
241
|
+
* This is potentially inefficient and advanced apps should consider creating
|
|
242
|
+
* their own query client to handle pagination together with the app's screens.
|
|
243
|
+
*/
|
|
244
|
+
async getContracts(codeId) {
|
|
245
|
+
const allContracts = [];
|
|
246
|
+
let startAtKey = undefined;
|
|
247
|
+
do {
|
|
248
|
+
const { contracts, pagination } = await this.forceGetQueryClient().wasm.listContractsByCodeId(codeId, startAtKey);
|
|
249
|
+
const loadedContracts = contracts || [];
|
|
250
|
+
allContracts.push(...loadedContracts);
|
|
251
|
+
startAtKey = pagination?.nextKey;
|
|
252
|
+
} while (startAtKey?.length !== 0 && startAtKey !== undefined);
|
|
253
|
+
return allContracts;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Throws an error if no contract was found at the address
|
|
257
|
+
*/
|
|
258
|
+
async getContract(address) {
|
|
259
|
+
const { address: retrievedAddress, contractInfo } = await this.forceGetQueryClient().wasm.getContractInfo(address);
|
|
260
|
+
if (!contractInfo)
|
|
261
|
+
throw new Error(`No contract found at address "${address}"`);
|
|
262
|
+
(0, utils_1.assert)(retrievedAddress, "address missing");
|
|
263
|
+
(0, utils_1.assert)(contractInfo.codeId && contractInfo.creator && contractInfo.label, "contractInfo incomplete");
|
|
264
|
+
return {
|
|
265
|
+
address: retrievedAddress,
|
|
266
|
+
codeId: contractInfo.codeId.toNumber(),
|
|
267
|
+
creator: contractInfo.creator,
|
|
268
|
+
label: contractInfo.label,
|
|
269
|
+
ibcPortId: contractInfo.ibcPortId || undefined,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Returns the data at the key if present (raw contract dependent storage data)
|
|
274
|
+
* or null if no data at this key.
|
|
275
|
+
*
|
|
276
|
+
* Promise is rejected when contract does not exist.
|
|
277
|
+
*/
|
|
278
|
+
async queryContractRaw(address, key) {
|
|
279
|
+
// just test contract existence
|
|
280
|
+
await this.getContract(address);
|
|
281
|
+
const { data } = await this.forceGetQueryClient().wasm.queryContractRaw(address, key);
|
|
282
|
+
return data ?? null;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Makes a smart query on the contract, returns the parsed JSON document.
|
|
286
|
+
*
|
|
287
|
+
* Promise is rejected when contract does not exist.
|
|
288
|
+
* Promise is rejected for invalid query format.
|
|
289
|
+
* Promise is rejected for invalid response format.
|
|
290
|
+
*/
|
|
291
|
+
async queryContractSmart(address, queryMsg) {
|
|
292
|
+
try {
|
|
293
|
+
return await this.forceGetQueryClient().wasm.queryContractSmart(address, queryMsg);
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
if (error instanceof Error) {
|
|
297
|
+
if (error.message.startsWith("not found: contract")) {
|
|
298
|
+
throw new Error(`No contract found at address "${address}"`);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
async queryContractFull(sender, address, queryMsg, funds, dependencies) {
|
|
310
|
+
try {
|
|
311
|
+
return await this.forceGetQueryClient().wasm.queryContractFull(sender, address, queryMsg, funds, dependencies);
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
if (error instanceof Error) {
|
|
315
|
+
if (error.message.startsWith("not found: contract")) {
|
|
316
|
+
throw new Error(`No contract found at address "${address}"`);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
async txsQuery(query) {
|
|
328
|
+
const results = await this.forceGetTmClient().txSearchAll({ query: query });
|
|
329
|
+
return results.txs.map((tx) => {
|
|
330
|
+
return {
|
|
331
|
+
height: tx.height,
|
|
332
|
+
hash: (0, encoding_1.toHex)(tx.hash).toUpperCase(),
|
|
333
|
+
code: tx.result.code,
|
|
334
|
+
events: tx.result.events.map(stargate_1.fromTendermint34Event),
|
|
335
|
+
rawLog: tx.result.log || "",
|
|
336
|
+
tx: tx.tx,
|
|
337
|
+
gasUsed: tx.result.gasUsed,
|
|
338
|
+
gasWanted: tx.result.gasWanted,
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
exports.WasmXClient = WasmXClient;
|
|
344
|
+
//# sourceMappingURL=wasmxclient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasmxclient.js","sourceRoot":"","sources":["../src/wasmxclient.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,+CAAmD;AACnD,uCAAsC;AACtC,+CAuB0B;AAC1B,2DAIgC;AAEhC,yCAA8C;AAO9C,uCAA0E;AAuC1E,MAAa,WAAW;IA2BtB,YAAsB,QAAsC;QAtB3C,eAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;QACrD,YAAO,GAAW,EAAE,CAAC;QAsB3B,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC,cAAc,CAC3C,QAAQ,EACR,6BAAkB,EAClB,6BAAkB,EAClB,4BAAkB,EAClB,2BAAgB,CACjB,CAAC;SACH;IACH,CAAC;IA9BD;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAA+B;QACzD,MAAM,QAAQ,GAAG,MAAM,mCAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAA0B;QACnD,OAAO,IAAI,WAAW,CAAC,QAAQ,CAAC,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C,EAAO,EAAE,EAAE;YACjC,OAAO;gBACL,MAAM,EAAE,EAAE,CAAC,MAAM;gBACjB,IAAI,EAAE,IAAA,gBAAK,EAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;gBAClC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI;gBACpB,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,gCAAqB,CAAC;gBACnD,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE;gBAC3B,EAAE,EAAE,EAAE,CAAC,EAAE;gBACT,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO;gBAC1B,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS;aAC/B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7YD,kCA6YC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
|
|
3
|
+
if (process.env.SES_ENABLED) {
|
|
4
|
+
require("ses/lockdown");
|
|
5
|
+
// eslint-disable-next-line no-undef
|
|
6
|
+
lockdown();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
require("source-map-support").install();
|
|
10
|
+
const defaultSpecReporterConfig = require("../../jasmine-spec-reporter.config.json");
|
|
11
|
+
|
|
12
|
+
// setup Jasmine
|
|
13
|
+
const Jasmine = require("jasmine");
|
|
14
|
+
const jasmine = new Jasmine();
|
|
15
|
+
jasmine.loadConfig({
|
|
16
|
+
spec_dir: "build",
|
|
17
|
+
spec_files: ["**/*.spec.js"],
|
|
18
|
+
helpers: [],
|
|
19
|
+
random: false,
|
|
20
|
+
seed: null,
|
|
21
|
+
stopSpecOnExpectationFailure: false,
|
|
22
|
+
});
|
|
23
|
+
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 15 * 1000;
|
|
24
|
+
|
|
25
|
+
// setup reporter
|
|
26
|
+
const { SpecReporter } = require("jasmine-spec-reporter");
|
|
27
|
+
const reporter = new SpecReporter({
|
|
28
|
+
...defaultSpecReporterConfig,
|
|
29
|
+
spec: {
|
|
30
|
+
...defaultSpecReporterConfig.spec,
|
|
31
|
+
displaySuccessful: !process.argv.includes("--quiet"),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// initialize and execute
|
|
36
|
+
jasmine.env.clearReporters();
|
|
37
|
+
jasmine.addReporter(reporter);
|
|
38
|
+
void jasmine.execute();
|
package/karma.conf.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const chrome = require("karma-chrome-launcher");
|
|
2
|
+
const firefox = require("karma-firefox-launcher");
|
|
3
|
+
const jasmine = require("karma-jasmine");
|
|
4
|
+
const kjhtml = require("karma-jasmine-html-reporter");
|
|
5
|
+
|
|
6
|
+
module.exports = function (config) {
|
|
7
|
+
config.set({
|
|
8
|
+
// base path that will be used to resolve all patterns (eg. files, exclude)
|
|
9
|
+
basePath: ".",
|
|
10
|
+
// registers plugins but does not activate them
|
|
11
|
+
plugins: [jasmine, kjhtml, chrome, firefox],
|
|
12
|
+
|
|
13
|
+
// frameworks to use
|
|
14
|
+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
|
15
|
+
frameworks: ["jasmine"],
|
|
16
|
+
|
|
17
|
+
// list of files / patterns to load in the browser
|
|
18
|
+
files: ["dist/web/tests.js"],
|
|
19
|
+
|
|
20
|
+
client: {
|
|
21
|
+
jasmine: {
|
|
22
|
+
random: false,
|
|
23
|
+
timeoutInterval: 15000,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
// test results reporter to use
|
|
28
|
+
// possible values: 'dots', 'progress'
|
|
29
|
+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
30
|
+
reporters: ["progress", "kjhtml"],
|
|
31
|
+
|
|
32
|
+
// web server port
|
|
33
|
+
port: 9876,
|
|
34
|
+
|
|
35
|
+
// enable / disable colors in the output (reporters and logs)
|
|
36
|
+
colors: true,
|
|
37
|
+
|
|
38
|
+
// level of logging
|
|
39
|
+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
40
|
+
logLevel: config.LOG_INFO,
|
|
41
|
+
|
|
42
|
+
// enable / disable watching file and executing tests whenever any file changes
|
|
43
|
+
autoWatch: false,
|
|
44
|
+
|
|
45
|
+
// start these browsers
|
|
46
|
+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
|
47
|
+
browsers: ["Firefox"],
|
|
48
|
+
|
|
49
|
+
browserNoActivityTimeout: 90000,
|
|
50
|
+
|
|
51
|
+
// Keep brower open for debugging. This is overridden by yarn scripts
|
|
52
|
+
singleRun: false,
|
|
53
|
+
});
|
|
54
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ark-us/wasmx-stargate",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "WasmX SDK",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"Loredana Cirstea"
|
|
7
|
+
],
|
|
8
|
+
"license": "GLPv3",
|
|
9
|
+
"main": "build/index.js",
|
|
10
|
+
"types": "build/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"build/",
|
|
13
|
+
"*.md",
|
|
14
|
+
"!*.spec.*",
|
|
15
|
+
"!**/testdata/"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/ark-us/mythosjs/tree/main/packages/wasmx-stargate"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"docs": "typedoc --options typedoc.js",
|
|
27
|
+
"format": "prettier --write --loglevel warn \"./src/**/*.ts\"",
|
|
28
|
+
"format-text": "prettier --write \"./*.md\"",
|
|
29
|
+
"lint": "eslint --max-warnings 0 \"./**/*.ts\" \"./*.js\"",
|
|
30
|
+
"lint-fix": "eslint --fix --max-warnings 0 \"./**/*.ts\" \"./*.js\"",
|
|
31
|
+
"build": "rm -rf ./build && tsc",
|
|
32
|
+
"build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build",
|
|
33
|
+
"test-node": "yarn node jasmine-testrunner.js",
|
|
34
|
+
"test-firefox": "yarn pack-web && karma start --single-run --browsers Firefox",
|
|
35
|
+
"test-chrome": "yarn pack-web && karma start --single-run --browsers ChromeHeadless",
|
|
36
|
+
"test": "yarn build-or-skip && yarn test-node",
|
|
37
|
+
"coverage": "nyc --reporter=text --reporter=lcov yarn test --quiet",
|
|
38
|
+
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@ark-us/wasmxjs": "^0.0.1",
|
|
42
|
+
"@cosmjs/amino": "^0.29.5",
|
|
43
|
+
"@cosmjs/crypto": "^0.29.5",
|
|
44
|
+
"@cosmjs/encoding": "^0.29.5",
|
|
45
|
+
"@cosmjs/math": "^0.29.5",
|
|
46
|
+
"@cosmjs/proto-signing": "^0.29.5",
|
|
47
|
+
"@cosmjs/stargate": "^0.29.5",
|
|
48
|
+
"@cosmjs/tendermint-rpc": "^0.29.5",
|
|
49
|
+
"@cosmjs/utils": "^0.29.5",
|
|
50
|
+
"cosmjs-types": "^0.6.0",
|
|
51
|
+
"long": "^4.0.0",
|
|
52
|
+
"pako": "^2.0.2"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
|
56
|
+
"@types/eslint-plugin-prettier": "^3",
|
|
57
|
+
"@types/jasmine": "^4",
|
|
58
|
+
"@types/karma-firefox-launcher": "^2",
|
|
59
|
+
"@types/karma-jasmine": "^4",
|
|
60
|
+
"@types/karma-jasmine-html-reporter": "^1",
|
|
61
|
+
"@types/long": "^4.0.1",
|
|
62
|
+
"@types/node": "^15.0.1",
|
|
63
|
+
"@types/pako": "^1.0.1",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
|
65
|
+
"@typescript-eslint/parser": "^5.54.0",
|
|
66
|
+
"eslint": "^7.5",
|
|
67
|
+
"eslint-config-prettier": "^8.3.0",
|
|
68
|
+
"eslint-import-resolver-node": "^0.3.4",
|
|
69
|
+
"eslint-plugin-import": "^2.22.1",
|
|
70
|
+
"eslint-plugin-prettier": "^3.4.0",
|
|
71
|
+
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
72
|
+
"esm": "^3.2.25",
|
|
73
|
+
"glob": "^7.1.6",
|
|
74
|
+
"jasmine": "^4",
|
|
75
|
+
"jasmine-spec-reporter": "^6",
|
|
76
|
+
"karma": "^6.3.14",
|
|
77
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
78
|
+
"karma-firefox-launcher": "^2.1.0",
|
|
79
|
+
"karma-jasmine": "^5",
|
|
80
|
+
"karma-jasmine-html-reporter": "^1.5.4",
|
|
81
|
+
"nyc": "^15.1.0",
|
|
82
|
+
"prettier": "^2.8.1",
|
|
83
|
+
"protobufjs": "~6.11.3",
|
|
84
|
+
"readonly-date": "^1.0.0",
|
|
85
|
+
"ses": "^0.11.0",
|
|
86
|
+
"source-map-support": "^0.5.19",
|
|
87
|
+
"ts-node": "^8",
|
|
88
|
+
"typedoc": "^0.22",
|
|
89
|
+
"typescript": "~4.6",
|
|
90
|
+
"webpack": "^5.32.0",
|
|
91
|
+
"webpack-cli": "^4.6.0"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { fromBinary, toBinary } from "./encoding";
|
|
2
|
+
|
|
3
|
+
describe("encoding", () => {
|
|
4
|
+
describe("toBinary", () => {
|
|
5
|
+
it("works for objects", () => {
|
|
6
|
+
// echo -n "{}" | base64
|
|
7
|
+
expect(toBinary({})).toEqual("e30=");
|
|
8
|
+
|
|
9
|
+
// echo -n '{"swap":{"max_spread":"0.25"}}' | base64
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11
|
+
expect(toBinary({ swap: { max_spread: "0.25" } })).toEqual("eyJzd2FwIjp7Im1heF9zcHJlYWQiOiIwLjI1In19");
|
|
12
|
+
|
|
13
|
+
// echo -n '{"num":3.45,"null":null,"bool":true,"obj":{"str":"bar"}}' | base64
|
|
14
|
+
expect(
|
|
15
|
+
toBinary({ num: 3.45, null: null, bool: true, obj: { str: "bar" }, omitted: undefined }),
|
|
16
|
+
).toEqual("eyJudW0iOjMuNDUsIm51bGwiOm51bGwsImJvb2wiOnRydWUsIm9iaiI6eyJzdHIiOiJiYXIifX0=");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("works for strings", () => {
|
|
20
|
+
// echo -n '""' | base64
|
|
21
|
+
expect(toBinary("")).toEqual("IiI=");
|
|
22
|
+
|
|
23
|
+
// echo -n '"hi"' | base64
|
|
24
|
+
expect(toBinary("hi")).toEqual("ImhpIg==");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("works for arrays", () => {
|
|
28
|
+
// echo -n '[]' | base64
|
|
29
|
+
expect(toBinary([])).toEqual("W10=");
|
|
30
|
+
|
|
31
|
+
// echo -n '[1,2,3]' | base64
|
|
32
|
+
expect(toBinary([1, 2, 3])).toEqual("WzEsMiwzXQ==");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("works for booleans", () => {
|
|
36
|
+
// echo -n 'true' | base64
|
|
37
|
+
expect(toBinary(true)).toEqual("dHJ1ZQ==");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("works for numbers", () => {
|
|
41
|
+
// echo -n '12.21' | base64
|
|
42
|
+
expect(toBinary(12.21)).toEqual("MTIuMjE=");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("works for null", () => {
|
|
46
|
+
// echo -n 'null' | base64
|
|
47
|
+
expect(toBinary(null)).toEqual("bnVsbA==");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("fromBinary", () => {
|
|
52
|
+
it("works for objects", () => {
|
|
53
|
+
// echo -n "{}" | base64
|
|
54
|
+
expect(fromBinary("e30=")).toEqual({});
|
|
55
|
+
|
|
56
|
+
// echo -n '{"swap":{"max_spread":"0.25"}}' | base64
|
|
57
|
+
expect(fromBinary("eyJzd2FwIjp7Im1heF9zcHJlYWQiOiIwLjI1In19")).toEqual({
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
59
|
+
swap: { max_spread: "0.25" },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// echo -n '{"num":3.45,"null":null,"bool":true,"obj":{"str":"bar"}}' | base64
|
|
63
|
+
expect(
|
|
64
|
+
fromBinary("eyJudW0iOjMuNDUsIm51bGwiOm51bGwsImJvb2wiOnRydWUsIm9iaiI6eyJzdHIiOiJiYXIifX0="),
|
|
65
|
+
).toEqual({ num: 3.45, null: null, bool: true, obj: { str: "bar" } });
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("works for strings", () => {
|
|
69
|
+
// echo -n '""' | base64
|
|
70
|
+
expect(fromBinary("IiI=")).toEqual("");
|
|
71
|
+
|
|
72
|
+
// echo -n '"hi"' | base64
|
|
73
|
+
expect(fromBinary("ImhpIg==")).toEqual("hi");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("works for arrays", () => {
|
|
77
|
+
// echo -n '[]' | base64
|
|
78
|
+
expect(fromBinary("W10=")).toEqual([]);
|
|
79
|
+
|
|
80
|
+
// echo -n '[1,2,3]' | base64
|
|
81
|
+
expect(fromBinary("WzEsMiwzXQ==")).toEqual([1, 2, 3]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("works for booleans", () => {
|
|
85
|
+
// echo -n 'true' | base64
|
|
86
|
+
expect(fromBinary("dHJ1ZQ==")).toEqual(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("works for numbers", () => {
|
|
90
|
+
// echo -n '12.21' | base64
|
|
91
|
+
expect(fromBinary("MTIuMjE=")).toEqual(12.21);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("works for null", () => {
|
|
95
|
+
// echo -n 'null' | base64
|
|
96
|
+
expect(fromBinary("bnVsbA==")).toEqual(null);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
package/src/encoding.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { fromBase64, fromUtf8, toBase64, toUtf8 } from "@cosmjs/encoding";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Takes a value, serializes it to JSON and encodes it as base64.
|
|
5
|
+
*
|
|
6
|
+
* This can be used for creating values of fields that have the WasmX Binary type.
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
9
|
+
export function toBinary(obj: any): string {
|
|
10
|
+
return toBase64(toUtf8(JSON.stringify(obj)));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Takes a base64 string, decodes it and parses the content from JSON to an object.
|
|
15
|
+
*
|
|
16
|
+
* This can be used for parsing the values of a WasmX Binary field.
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
19
|
+
export function fromBinary(base64: string): any {
|
|
20
|
+
return JSON.parse(fromUtf8(fromBase64(base64)));
|
|
21
|
+
}
|