Skip to content

Commit c7b629a

Browse files
authored
update cosmjs to 0.31.3 (#35)
1 parent 25e619c commit c7b629a

File tree

5 files changed

+40
-51
lines changed

5 files changed

+40
-51
lines changed

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cybercongress/cyber-js",
3-
"version": "0.3.9",
3+
"version": "0.3.91",
44
"description": "Cyber SDK",
55
"license": "",
66
"main": "build/index.js",
@@ -29,13 +29,13 @@
2929
"format-text": "prettier --write \"./*.md\""
3030
},
3131
"dependencies": {
32-
"@cosmjs/cosmwasm-stargate": "^0.30.0",
33-
"@cosmjs/stargate": "^0.30.0",
34-
"@cosmjs/amino": "^0.30.0",
35-
"@cosmjs/crypto": "^0.30.0",
36-
"@cosmjs/math": "^0.30.0",
37-
"@cosmjs/proto-signing": "^0.30.0",
38-
"@cosmjs/utils": "^0.30.0",
32+
"@cosmjs/amino": "0.31.3",
33+
"@cosmjs/cosmwasm-stargate": "0.31.3",
34+
"@cosmjs/crypto": "0.31.3",
35+
"@cosmjs/math": "0.31.3",
36+
"@cosmjs/proto-signing": "0.31.3",
37+
"@cosmjs/stargate": "0.31.3",
38+
"@cosmjs/utils": "0.31.3",
3939
"cosmjs-types": "^0.7",
4040
"fast-deep-equal": "^3.1.3",
4141
"fs-extra": "^10.1.0",

src/cyberclient.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ import {
2323
GovProposalId,
2424
IbcExtension,
2525
IndexedTx,
26-
isSearchByHeightQuery,
27-
isSearchBySentFromOrToQuery,
28-
isSearchByTagsQuery,
2926
QueryClient,
30-
SearchTxFilter,
31-
SearchTxQuery,
3227
SequenceResponse,
3328
setupAuthExtension,
3429
setupBankExtension,
@@ -47,7 +42,6 @@ import {
4742
toRfc3339WithNanoseconds,
4843
} from "@cosmjs/tendermint-rpc";
4944
import { assert } from "@cosmjs/utils";
50-
import { QueryTotalSupplyResponse } from "cosmjs-types/cosmos/bank/v1beta1/query";
5145
import {
5246
QueryCommunityPoolResponse,
5347
QueryDelegationRewardsResponse,
@@ -137,6 +131,7 @@ import {
137131
setupRankExtension,
138132
setupResourcesExtension,
139133
} from "./queries/index";
134+
import { CyberSearchTxFilter, CyberSearchTxQuery } from "./types";
140135

141136
export { Code, CodeDetails, Contract, ContractCodeHistoryEntry };
142137

@@ -318,7 +313,10 @@ export class CyberClient {
318313
return results[0] ?? null;
319314
}
320315

321-
public async searchTx(query: SearchTxQuery, filter: SearchTxFilter = {}): Promise<readonly IndexedTx[]> {
316+
public async searchTx(
317+
query: CyberSearchTxQuery,
318+
filter: CyberSearchTxFilter = {},
319+
): Promise<readonly IndexedTx[]> {
322320
const minHeight = filter.minHeight || 0;
323321
const maxHeight = filter.maxHeight || Number.MAX_SAFE_INTEGER;
324322

@@ -330,12 +328,12 @@ export class CyberClient {
330328

331329
let txs: readonly IndexedTx[];
332330

333-
if (isSearchByHeightQuery(query)) {
331+
if (query?.height !== undefined) {
334332
txs =
335333
query.height >= minHeight && query.height <= maxHeight
336334
? await this.txsQuery(`tx.height=${query.height}`)
337335
: [];
338-
} else if (isSearchBySentFromOrToQuery(query)) {
336+
} else if (query?.sentFromOrTo !== undefined) {
339337
const sentQuery = withFilters(`message.module='bank' AND transfer.sender='${query.sentFromOrTo}'`);
340338
const receivedQuery = withFilters(
341339
`message.module='bank' AND transfer.recipient='${query.sentFromOrTo}'`,
@@ -345,7 +343,7 @@ export class CyberClient {
345343
);
346344
const sentHashes = sent.map((t) => t.hash);
347345
txs = [...sent, ...received.filter((t) => !sentHashes.includes(t.hash))];
348-
} else if (isSearchByTagsQuery(query)) {
346+
} else if (query?.tags !== undefined) {
349347
const rawQuery = withFilters(query.tags.map((t) => `${t.key}='${t.value}'`).join(" AND "));
350348
txs = await this.txsQuery(rawQuery);
351349
} else {
@@ -363,6 +361,7 @@ export class CyberClient {
363361
public async broadcastTx(tx: Uint8Array): Promise<DeliverTxResponse> {
364362
const broadcasted = await this.forceGetTmClient().broadcastTxSync({ tx });
365363
const transactionId = toHex(broadcasted.hash).toUpperCase();
364+
366365
return {
367366
code: broadcasted.code,
368367
height: 0,
@@ -372,6 +371,7 @@ export class CyberClient {
372371
gasWanted: broadcasted.gasWanted,
373372
txIndex: 0,
374373
events: [], // TODO: broadcasted.events,
374+
msgResponses: [],
375375
};
376376
}
377377

@@ -916,6 +916,7 @@ export class CyberClient {
916916
gasWanted: tx.result.gasWanted,
917917
txIndex: tx.index,
918918
events: [], // TODO: tx.result.events || [],
919+
msgResponses: [],
919920
};
920921
});
921922
}

src/renderItems.ts

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { toUtf8 } from "@cosmjs/encoding";
22
import { Uint53 } from "@cosmjs/math";
33
import { longify } from "@cosmjs/stargate/build/queryclient";
4-
import { MsgExec, MsgGrant, MsgRevoke } from "cosmjs-types/cosmos/authz/v1beta1/tx";
4+
// import { MsgExec, MsgGrant, MsgRevoke } from "cosmjs-types/cosmos/authz/v1beta1/tx";
55
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
66
import { MsgWithdrawDelegatorReward } from "cosmjs-types/cosmos/distribution/v1beta1/tx";
77
import { MsgDeposit, MsgSubmitProposal, MsgVote } from "cosmjs-types/cosmos/gov/v1beta1/tx";
@@ -37,40 +37,17 @@ const testAddress2 = "bostrom1frk9k38pvp70vheezhdfd4nvqnlsm9dw3j8hlw";
3737
const testContract = "bostrom1nwnejwsdpqktusvh8qhxe5arsznjd5asdwutmaz9n5qcpl3dcmhsujhemd";
3838
const testValidatorAddress = "bostromvaloper135ca8hdpy9sk0ntwqzpzsvatyl48ptx52tn60p";
3939

40-
const executePlaceholder = {
41-
transfer: {
42-
recipient: "bostrom1p0r7uxstcw8ehrwuj4kn8qzzs0yypsjwxgd445",
43-
amount: "1",
44-
},
45-
};
46-
4740
const depositCoin = { denom: "boot", amount: "1000000" };
4841

4942
const depositCoins = [
5043
{ denom: "boot", amount: "1000000" },
5144
{ denom: "hydrogen", amount: "1000000" },
5245
];
5346

54-
const instantiatePlaceholder = {
55-
name: "Nation coin",
56-
symbol: "NTN",
57-
decimals: 0,
58-
initial_balances: [
59-
{
60-
address: "bostrom1p0r7uxstcw8ehrwuj4kn8qzzs0yypsjwxgd445",
61-
amount: "100000",
62-
},
63-
],
64-
mint: {
65-
minter: "bostrom1p0r7uxstcw8ehrwuj4kn8qzzs0yypsjwxgd445",
66-
cap: "1000000",
67-
},
68-
};
69-
7047
interface RenderItem {
7148
typeUrl: string;
7249
value: Partial<any>;
73-
data: {};
50+
data: any;
7451
}
7552

7653
interface RenderItems extends Array<RenderItem> {}

src/signingcyberclient.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ export function links(from: string, to: string): Link[] {
133133
}
134134

135135
export function chain(particles: string[]): Link[] {
136-
const chain = [];
136+
const chainResult = [];
137137
for (let i = 0; i < particles.length - 1; i++) {
138-
chain.push({
138+
chainResult.push({
139139
from: particles[i],
140140
to: particles[i + 1],
141141
});
142142
}
143-
return chain;
143+
return chainResult;
144144
}
145145

146146
// Experimental for remote dapps with cyb's signer integration
@@ -256,9 +256,9 @@ export class SigningCyberClient extends CyberClient {
256256
}
257257

258258
public render(): string {
259-
const arr: Array<{}> = [];
259+
const arr: Array<Record<string, any>> = [];
260260

261-
renderItems.forEach((i, o) => {
261+
renderItems.forEach((i) => {
262262
arr.push({
263263
[i.typeUrl.toString()]: {
264264
proto: {
@@ -986,11 +986,11 @@ export class SigningCyberClient extends CyberClient {
986986
memo = "",
987987
): Promise<DeliverTxResponse | string[]> {
988988
// Experimental for remote dapps with cyb's signer integration
989-
const msg = messages.map((msg) => this.aminoTypes.fromAmino({ type: msg.type, value: msg.value }));
989+
const msgs = messages.map((msg) => this.aminoTypes.fromAmino({ type: msg.type, value: msg.value }));
990990
if (isOfflineDappSigner(this.signer)) {
991-
return msg.map((m) => toBase64(Buffer.from(JSON.stringify(m), "utf-8")));
991+
return msgs.map((m) => toBase64(Buffer.from(JSON.stringify(m), "utf-8")));
992992
}
993-
const txRaw = await this.sign(signerAddress, msg, fee, memo);
993+
const txRaw = await this.sign(signerAddress, msgs, fee, memo);
994994
const txBytes = TxRaw.encode(txRaw).finish();
995995
return this.broadcastTx(txBytes);
996996
}

src/types.ts

+11
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,14 @@ export interface Link {
3434
from: string;
3535
to: string;
3636
}
37+
38+
export interface CyberSearchTxFilter {
39+
readonly minHeight?: number;
40+
readonly maxHeight?: number;
41+
}
42+
43+
export interface CyberSearchTxQuery {
44+
sentFromOrTo?: string;
45+
height?: number;
46+
tags?: ReadonlyArray<{ readonly key: string; readonly value: string }>;
47+
}

0 commit comments

Comments
 (0)