@eclesia/indexer-engine 2.14.4 → 2.16.0
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/dist/_virtual/rolldown_runtime.cjs +20 -15
- package/dist/_virtual/rolldown_runtime.mjs +10 -30
- package/dist/constants.cjs +31 -2
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +27 -3
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +27 -3
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +27 -3
- package/dist/constants.mjs.map +1 -1
- package/dist/emitter/index.cjs +25 -7
- package/dist/emitter/index.cjs.map +1 -1
- package/dist/emitter/index.d.cts +8 -1
- package/dist/emitter/index.d.cts.map +1 -1
- package/dist/emitter/index.d.mts +8 -1
- package/dist/emitter/index.d.mts.map +1 -1
- package/dist/emitter/index.mjs +25 -7
- package/dist/emitter/index.mjs.map +1 -1
- package/dist/index.cjs +6 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/indexer/index.cjs +498 -225
- package/dist/indexer/index.cjs.map +1 -1
- package/dist/indexer/index.d.cts +111 -7
- package/dist/indexer/index.d.cts.map +1 -1
- package/dist/indexer/index.d.mts +111 -7
- package/dist/indexer/index.d.mts.map +1 -1
- package/dist/indexer/index.mjs +496 -224
- package/dist/indexer/index.mjs.map +1 -1
- package/dist/metrics/index.cjs +14 -0
- package/dist/metrics/index.cjs.map +1 -1
- package/dist/metrics/index.d.cts +7 -0
- package/dist/metrics/index.d.cts.map +1 -1
- package/dist/metrics/index.d.mts +7 -0
- package/dist/metrics/index.d.mts.map +1 -1
- package/dist/metrics/index.mjs +14 -0
- package/dist/metrics/index.mjs.map +1 -1
- package/dist/mocks/index.cjs +3 -1
- package/dist/mocks/index.cjs.map +1 -1
- package/dist/mocks/index.d.cts +2 -2
- package/dist/mocks/index.d.mts +2 -2
- package/dist/mocks/index.mjs +4 -2
- package/dist/mocks/index.mjs.map +1 -1
- package/dist/mocks/rpc-client.cjs +185 -20
- package/dist/mocks/rpc-client.cjs.map +1 -1
- package/dist/mocks/rpc-client.d.cts +26 -10
- package/dist/mocks/rpc-client.d.cts.map +1 -1
- package/dist/mocks/rpc-client.d.mts +26 -10
- package/dist/mocks/rpc-client.d.mts.map +1 -1
- package/dist/mocks/rpc-client.mjs +184 -22
- package/dist/mocks/rpc-client.mjs.map +1 -1
- package/dist/promise-queue/index.cjs +10 -4
- package/dist/promise-queue/index.cjs.map +1 -1
- package/dist/promise-queue/index.d.cts +1 -4
- package/dist/promise-queue/index.d.cts.map +1 -1
- package/dist/promise-queue/index.d.mts +1 -4
- package/dist/promise-queue/index.d.mts.map +1 -1
- package/dist/promise-queue/index.mjs +10 -4
- package/dist/promise-queue/index.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +28 -5
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +28 -5
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/index.cjs +6 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +3 -2
- package/dist/utils/index.d.mts +3 -2
- package/dist/utils/index.mjs +7 -2
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/text.cjs +31 -0
- package/dist/utils/text.cjs.map +1 -1
- package/dist/utils/text.d.cts +24 -1
- package/dist/utils/text.d.cts.map +1 -1
- package/dist/utils/text.d.mts +24 -1
- package/dist/utils/text.d.mts.map +1 -1
- package/dist/utils/text.mjs +30 -1
- package/dist/utils/text.mjs.map +1 -1
- package/dist/utils/timeout.cjs +32 -0
- package/dist/utils/timeout.cjs.map +1 -0
- package/dist/utils/timeout.d.cts +18 -0
- package/dist/utils/timeout.d.cts.map +1 -0
- package/dist/utils/timeout.d.mts +18 -0
- package/dist/utils/timeout.d.mts.map +1 -0
- package/dist/utils/timeout.mjs +30 -0
- package/dist/utils/timeout.mjs.map +1 -0
- package/package.json +35 -34
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/ascii.cjs +0 -32
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/ascii.cjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/ascii.mjs +0 -29
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/ascii.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/base64.cjs +0 -67
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/base64.cjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/base64.mjs +0 -64
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/base64.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/bech32.cjs +0 -80
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/bech32.cjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/bech32.mjs +0 -77
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/bech32.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/hex.cjs +0 -33
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/hex.cjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/hex.mjs +0 -30
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/hex.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.cjs +0 -106
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.mjs +0 -103
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/rfc3339.cjs +0 -52
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/rfc3339.cjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/rfc3339.mjs +0 -49
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/rfc3339.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/utf8.cjs +0 -31
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/utf8.cjs.map +0 -1
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/utf8.mjs +0 -28
- package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/utf8.mjs.map +0 -1
- package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.cjs +0 -98
- package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.mjs +0 -95
- package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.mjs.map +0 -1
package/dist/mocks/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MockRpcClient, MockRpcConfig, createMockRpcClient } from "./rpc-client.cjs";
|
|
1
|
+
import { MockRpcClient, MockRpcConfig, createMockRpcClient, mockModuleAccounts, syntheticAddress } from "./rpc-client.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mocks/index.d.ts
|
|
4
4
|
declare namespace index_d_exports {
|
|
5
|
-
export { MockRpcClient, MockRpcConfig, createMockRpcClient };
|
|
5
|
+
export { MockRpcClient, MockRpcConfig, createMockRpcClient, mockModuleAccounts, syntheticAddress };
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { index_d_exports };
|
package/dist/mocks/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MockRpcClient, MockRpcConfig, createMockRpcClient } from "./rpc-client.mjs";
|
|
1
|
+
import { MockRpcClient, MockRpcConfig, createMockRpcClient, mockModuleAccounts, syntheticAddress } from "./rpc-client.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mocks/index.d.ts
|
|
4
4
|
declare namespace index_d_exports {
|
|
5
|
-
export { MockRpcClient, MockRpcConfig, createMockRpcClient };
|
|
5
|
+
export { MockRpcClient, MockRpcConfig, createMockRpcClient, mockModuleAccounts, syntheticAddress };
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { index_d_exports };
|
package/dist/mocks/index.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { __export } from "../_virtual/rolldown_runtime.mjs";
|
|
2
|
-
import { MockRpcClient, createMockRpcClient } from "./rpc-client.mjs";
|
|
2
|
+
import { MockRpcClient, createMockRpcClient, mockModuleAccounts, syntheticAddress } from "./rpc-client.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/mocks/index.ts
|
|
5
5
|
var mocks_exports = /* @__PURE__ */ __export({
|
|
6
6
|
MockRpcClient: () => MockRpcClient,
|
|
7
|
-
createMockRpcClient: () => createMockRpcClient
|
|
7
|
+
createMockRpcClient: () => createMockRpcClient,
|
|
8
|
+
mockModuleAccounts: () => mockModuleAccounts,
|
|
9
|
+
syntheticAddress: () => syntheticAddress
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
//#endregion
|
package/dist/mocks/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/mocks/index.ts"],"sourcesContent":["/**\n * Mock implementations for testing and benchmarking\n * Provides RPC client and database mocks to isolate engine performance\n */\n\nexport {\n createMockRpcClient, MockRpcClient, type MockRpcConfig,\n} from \"./rpc-client.js\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/mocks/index.ts"],"sourcesContent":["/**\n * Mock implementations for testing and benchmarking\n * Provides RPC client and database mocks to isolate engine performance\n */\n\nexport {\n createMockRpcClient, mockModuleAccounts, MockRpcClient, type MockRpcConfig, syntheticAddress,\n} from \"./rpc-client.js\";\n"],"mappings":""}
|
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
|
|
2
|
+
let crypto = require("crypto");
|
|
3
3
|
let __cosmjs_tendermint_rpc = require("@cosmjs/tendermint-rpc");
|
|
4
|
+
let cosmjs_types_cosmos_staking_v1beta1_query_js = require("cosmjs-types/cosmos/staking/v1beta1/query.js");
|
|
4
5
|
let cosmjs_types_cosmos_tx_v1beta1_tx_js = require("cosmjs-types/cosmos/tx/v1beta1/tx.js");
|
|
6
|
+
let __cosmjs_encoding = require("@cosmjs/encoding");
|
|
7
|
+
let cosmjs_types_cosmos_auth_v1beta1_auth_js = require("cosmjs-types/cosmos/auth/v1beta1/auth.js");
|
|
8
|
+
let cosmjs_types_cosmos_auth_v1beta1_query_js = require("cosmjs-types/cosmos/auth/v1beta1/query.js");
|
|
9
|
+
let cosmjs_types_cosmos_bank_v1beta1_query_js = require("cosmjs-types/cosmos/bank/v1beta1/query.js");
|
|
10
|
+
let cosmjs_types_cosmos_staking_v1beta1_staking_js = require("cosmjs-types/cosmos/staking/v1beta1/staking.js");
|
|
5
11
|
|
|
6
12
|
//#region src/mocks/rpc-client.ts
|
|
7
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Mock RPC client for benchmarking and testing
|
|
15
|
+
* Generates synthetic blockchain data without requiring an actual RPC node
|
|
16
|
+
*/
|
|
17
|
+
/** Deterministic bech32 address from a small integer, for synthetic accounts and validators */
|
|
18
|
+
function syntheticAddress(prefix, seed) {
|
|
19
|
+
const bytes = new Uint8Array(20);
|
|
20
|
+
bytes[0] = seed & 255;
|
|
21
|
+
bytes[1] = seed >> 8 & 255;
|
|
22
|
+
bytes[19] = 1;
|
|
23
|
+
return (0, __cosmjs_encoding.toBech32)(prefix, bytes);
|
|
24
|
+
}
|
|
25
|
+
/** Module accounts a chain always has, with deterministic addresses (computed on first use) */
|
|
26
|
+
function mockModuleAccounts() {
|
|
27
|
+
return {
|
|
28
|
+
fee_collector: syntheticAddress("cosmos", 1001),
|
|
29
|
+
distribution: syntheticAddress("cosmos", 1002)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
8
32
|
/**
|
|
9
33
|
* Generates a synthetic transaction with realistic structure
|
|
10
34
|
*/
|
|
@@ -68,15 +92,106 @@ var MockRpcClient = class {
|
|
|
68
92
|
startHeight;
|
|
69
93
|
endHeight;
|
|
70
94
|
txPerBlock;
|
|
71
|
-
|
|
95
|
+
cometVersion;
|
|
96
|
+
validatorCount;
|
|
97
|
+
constructor({ chainId, startHeight, endHeight, txPerBlock, cometVersion, validatorCount }) {
|
|
72
98
|
this.chainId = chainId;
|
|
73
99
|
this.startHeight = startHeight;
|
|
74
100
|
this.endHeight = endHeight;
|
|
75
101
|
this.txPerBlock = txPerBlock;
|
|
102
|
+
this.cometVersion = cometVersion ?? "0.37";
|
|
103
|
+
this.validatorCount = validatorCount ?? 3;
|
|
104
|
+
}
|
|
105
|
+
/** The synthetic validator set, identical at every height */
|
|
106
|
+
validators() {
|
|
107
|
+
const set = [];
|
|
108
|
+
for (let i = 0; i < this.validatorCount; i++) set.push(cosmjs_types_cosmos_staking_v1beta1_staking_js.Validator.fromPartial({
|
|
109
|
+
operatorAddress: syntheticAddress("cosmosvaloper", i + 1),
|
|
110
|
+
jailed: false,
|
|
111
|
+
status: 3,
|
|
112
|
+
tokens: String(1e6 * (i + 1)),
|
|
113
|
+
delegatorShares: String(1e6 * (i + 1)) + "000000000000000000",
|
|
114
|
+
description: { moniker: "mock-validator-" + (i + 1) },
|
|
115
|
+
commission: { commissionRates: {
|
|
116
|
+
rate: "100000000000000000",
|
|
117
|
+
maxRate: "200000000000000000",
|
|
118
|
+
maxChangeRate: "10000000000000000"
|
|
119
|
+
} },
|
|
120
|
+
minSelfDelegation: "1"
|
|
121
|
+
}));
|
|
122
|
+
return set;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Answers the ABCI queries the engine and the core modules issue. Unknown paths get a
|
|
126
|
+
* non-zero code, as a real node would answer for a query it does not serve.
|
|
127
|
+
*/
|
|
128
|
+
async abciQuery(params) {
|
|
129
|
+
const reply = (value) => ({
|
|
130
|
+
key: new Uint8Array(),
|
|
131
|
+
value,
|
|
132
|
+
height: params.height,
|
|
133
|
+
index: 0,
|
|
134
|
+
code: 0,
|
|
135
|
+
codespace: "",
|
|
136
|
+
log: "",
|
|
137
|
+
info: ""
|
|
138
|
+
});
|
|
139
|
+
switch (params.path) {
|
|
140
|
+
case "/cosmos.staking.v1beta1.Query/Validators": {
|
|
141
|
+
const request = cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorsRequest.decode(params.data);
|
|
142
|
+
const all = this.validators();
|
|
143
|
+
const limit = Number(request.pagination?.limit ?? 100n) || 100;
|
|
144
|
+
const key = request.pagination?.key;
|
|
145
|
+
const offset = key && key.length > 0 ? key[0] : 0;
|
|
146
|
+
const page = all.slice(offset, offset + limit);
|
|
147
|
+
const next = offset + limit < all.length ? new Uint8Array([offset + limit]) : new Uint8Array();
|
|
148
|
+
return reply(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorsResponse.encode(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorsResponse.fromPartial({
|
|
149
|
+
validators: page,
|
|
150
|
+
pagination: {
|
|
151
|
+
nextKey: next,
|
|
152
|
+
total: BigInt(all.length)
|
|
153
|
+
}
|
|
154
|
+
})).finish());
|
|
155
|
+
}
|
|
156
|
+
case "/cosmos.auth.v1beta1.Query/ModuleAccounts": return reply(cosmjs_types_cosmos_auth_v1beta1_query_js.QueryModuleAccountsResponse.encode(cosmjs_types_cosmos_auth_v1beta1_query_js.QueryModuleAccountsResponse.fromPartial({ accounts: Object.entries(mockModuleAccounts()).map(([name, address]) => ({
|
|
157
|
+
typeUrl: "/cosmos.auth.v1beta1.ModuleAccount",
|
|
158
|
+
value: cosmjs_types_cosmos_auth_v1beta1_auth_js.ModuleAccount.encode(cosmjs_types_cosmos_auth_v1beta1_auth_js.ModuleAccount.fromPartial({
|
|
159
|
+
baseAccount: { address },
|
|
160
|
+
name
|
|
161
|
+
})).finish()
|
|
162
|
+
})) })).finish());
|
|
163
|
+
case "/cosmos.bank.v1beta1.Query/AllBalances": return reply(cosmjs_types_cosmos_bank_v1beta1_query_js.QueryAllBalancesResponse.encode(cosmjs_types_cosmos_bank_v1beta1_query_js.QueryAllBalancesResponse.fromPartial({ balances: [{
|
|
164
|
+
denom: "uatom",
|
|
165
|
+
amount: "1000000"
|
|
166
|
+
}] })).finish());
|
|
167
|
+
case "/cosmos.staking.v1beta1.Query/Pool": return reply(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryPoolResponse.encode(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryPoolResponse.fromPartial({ pool: {
|
|
168
|
+
bondedTokens: String(this.validators().reduce((sum, v) => sum + Number(v.tokens), 0)),
|
|
169
|
+
notBondedTokens: "0"
|
|
170
|
+
} })).finish());
|
|
171
|
+
case "/cosmos.staking.v1beta1.Query/Params": return reply(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryParamsResponse.encode(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryParamsResponse.fromPartial({ params: {
|
|
172
|
+
unbondingTime: {
|
|
173
|
+
seconds: 1814400n,
|
|
174
|
+
nanos: 0
|
|
175
|
+
},
|
|
176
|
+
maxValidators: 100,
|
|
177
|
+
maxEntries: 7,
|
|
178
|
+
historicalEntries: 1e4,
|
|
179
|
+
bondDenom: "uatom",
|
|
180
|
+
minCommissionRate: "0"
|
|
181
|
+
} })).finish());
|
|
182
|
+
case "/cosmos.staking.v1beta1.Query/DelegatorDelegations": return reply(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryDelegatorDelegationsResponse.encode(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryDelegatorDelegationsResponse.fromPartial({})).finish());
|
|
183
|
+
case "/cosmos.staking.v1beta1.Query/ValidatorDelegations": return reply(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorDelegationsResponse.encode(cosmjs_types_cosmos_staking_v1beta1_query_js.QueryValidatorDelegationsResponse.fromPartial({})).finish());
|
|
184
|
+
default: return {
|
|
185
|
+
...reply(new Uint8Array()),
|
|
186
|
+
code: 6,
|
|
187
|
+
log: "unknown request: " + params.path
|
|
188
|
+
};
|
|
189
|
+
}
|
|
76
190
|
}
|
|
77
191
|
async block(height) {
|
|
78
192
|
const txs = [];
|
|
79
193
|
for (let i = 0; i < this.txPerBlock; i++) txs.push(generateMockTx(height, i));
|
|
194
|
+
const hashOf = (h) => new Uint8Array((0, crypto.createHash)("sha256").update(this.chainId + ":" + h).digest());
|
|
80
195
|
return {
|
|
81
196
|
block: {
|
|
82
197
|
header: {
|
|
@@ -112,14 +227,14 @@ var MockRpcClient = class {
|
|
|
112
227
|
},
|
|
113
228
|
signatures: [{
|
|
114
229
|
blockIdFlag: 2,
|
|
115
|
-
validatorAddress: (0,
|
|
230
|
+
validatorAddress: (0, __cosmjs_encoding.fromHex)("D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8"),
|
|
116
231
|
timestamp: (0, __cosmjs_tendermint_rpc.fromRfc3339WithNanoseconds)((/* @__PURE__ */ new Date()).toISOString()),
|
|
117
|
-
signature: (0,
|
|
232
|
+
signature: (0, __cosmjs_encoding.fromBase64)("Z6d2P35dI6qBzfPdyIZvmZi7Imo2FmQ5kNSnpVb2UvCj0aSjRCtS59BauJFB6FDHPluOUYoz0rJ4jiOnNXh9AA==")
|
|
118
233
|
}]
|
|
119
234
|
}
|
|
120
235
|
},
|
|
121
236
|
blockId: {
|
|
122
|
-
hash:
|
|
237
|
+
hash: hashOf(height),
|
|
123
238
|
parts: {
|
|
124
239
|
total: 0,
|
|
125
240
|
hash: new Uint8Array()
|
|
@@ -135,30 +250,30 @@ var MockRpcClient = class {
|
|
|
135
250
|
block: 11,
|
|
136
251
|
app: 0
|
|
137
252
|
},
|
|
138
|
-
id: (0,
|
|
253
|
+
id: (0, __cosmjs_encoding.fromHex)("d2982128df6a29e700980f325b0444e301c604d7"),
|
|
139
254
|
listenAddr: "tcp://0.0.0.0:26656",
|
|
140
|
-
network:
|
|
141
|
-
version: "0.37.15",
|
|
255
|
+
network: this.chainId,
|
|
256
|
+
version: this.cometVersion === "0.38" ? "0.38.17" : "0.37.15",
|
|
142
257
|
channels: "40202122233038606100",
|
|
143
258
|
moniker: "node",
|
|
144
259
|
other: new Map([["txIndex", "on"], ["rpcAddress", "tcp://0.0.0.0:26657"]])
|
|
145
260
|
},
|
|
146
261
|
syncInfo: {
|
|
147
|
-
latestBlockHash: (0,
|
|
148
|
-
latestAppHash: (0,
|
|
262
|
+
latestBlockHash: (0, __cosmjs_encoding.fromHex)("3F3F7A6F11FA91856BE440F8C78262307CAEAB122720D61CB14B118EF89892B5"),
|
|
263
|
+
latestAppHash: (0, __cosmjs_encoding.fromHex)("FF91D618633BDD5395763F34805E6DACF6BBFB642A2E787677BF28B39427F289"),
|
|
149
264
|
latestBlockHeight: this.endHeight,
|
|
150
265
|
latestBlockTime: (0, __cosmjs_tendermint_rpc.fromRfc3339WithNanoseconds)("2025-11-06T12:58:21.271608775Z"),
|
|
151
|
-
earliestBlockHash: (0,
|
|
152
|
-
earliestAppHash: (0,
|
|
266
|
+
earliestBlockHash: (0, __cosmjs_encoding.fromHex)("54473B6F28CAA85F5664F7CA3F2EEE49CD9857BDE41E0BF604B1A1DE93CBFEFF"),
|
|
267
|
+
earliestAppHash: (0, __cosmjs_encoding.fromHex)("24DFB6C312A7FD4B753444F5CD5FAC4D239BAEC09B6A79BB3D04B21B0BC1FC53"),
|
|
153
268
|
earliestBlockHeight: 1,
|
|
154
269
|
earliestBlockTime: (0, __cosmjs_tendermint_rpc.fromRfc3339WithNanoseconds)("2025-05-28T07:58:54.905470438Z"),
|
|
155
270
|
catchingUp: false
|
|
156
271
|
},
|
|
157
272
|
validatorInfo: {
|
|
158
|
-
address: (0,
|
|
273
|
+
address: (0, __cosmjs_encoding.fromHex)("1C7CE0213D96CD5578249740DC31A9D8E4D7A226"),
|
|
159
274
|
pubkey: {
|
|
160
275
|
algorithm: "ed25519",
|
|
161
|
-
data: (0,
|
|
276
|
+
data: (0, __cosmjs_encoding.fromBase64)("+KoTmCU6lo7NCtsfPCYpdNf0fs3aScZ8CtdgHTR/oGs=")
|
|
162
277
|
},
|
|
163
278
|
votingPower: 0n
|
|
164
279
|
}
|
|
@@ -172,24 +287,72 @@ var MockRpcClient = class {
|
|
|
172
287
|
}
|
|
173
288
|
async disconnect() {}
|
|
174
289
|
async blockResults(height) {
|
|
290
|
+
const attribute = (key, value) => ({
|
|
291
|
+
key,
|
|
292
|
+
value
|
|
293
|
+
});
|
|
294
|
+
const feeCollector = mockModuleAccounts().fee_collector;
|
|
295
|
+
const transferEvents = (msgIndex) => [
|
|
296
|
+
{
|
|
297
|
+
type: "message",
|
|
298
|
+
attributes: [attribute("action", "/cosmos.bank.v1beta1.MsgSend"), attribute("msg_index", String(msgIndex))]
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
type: "coin_spent",
|
|
302
|
+
attributes: [
|
|
303
|
+
attribute("spender", syntheticAddress("cosmos", 1)),
|
|
304
|
+
attribute("amount", "10uatom"),
|
|
305
|
+
attribute("msg_index", String(msgIndex))
|
|
306
|
+
]
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
type: "coin_received",
|
|
310
|
+
attributes: [
|
|
311
|
+
attribute("receiver", syntheticAddress("cosmos", 2)),
|
|
312
|
+
attribute("amount", "10uatom"),
|
|
313
|
+
attribute("msg_index", String(msgIndex))
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
];
|
|
175
317
|
const results = [];
|
|
176
318
|
for (let i = 0; i < this.txPerBlock; i++) results.push({
|
|
177
319
|
code: 0,
|
|
178
320
|
data: Buffer.from("success"),
|
|
179
|
-
log: JSON.stringify([{
|
|
321
|
+
log: this.cometVersion === "0.38" ? "" : JSON.stringify([{
|
|
180
322
|
msg_index: 0,
|
|
181
|
-
events:
|
|
323
|
+
events: transferEvents(0)
|
|
182
324
|
}]),
|
|
183
325
|
gasWanted: BigInt(2e5),
|
|
184
326
|
gasUsed: BigInt(15e4),
|
|
185
|
-
events:
|
|
327
|
+
events: transferEvents(0),
|
|
186
328
|
codespace: ""
|
|
187
329
|
});
|
|
330
|
+
const beginBlockEvents = [{
|
|
331
|
+
type: "coin_received",
|
|
332
|
+
attributes: [attribute("receiver", feeCollector), attribute("amount", "50uatom")]
|
|
333
|
+
}];
|
|
334
|
+
const endBlockEvents = [{
|
|
335
|
+
type: "coin_spent",
|
|
336
|
+
attributes: [attribute("spender", feeCollector), attribute("amount", "5uatom")]
|
|
337
|
+
}];
|
|
338
|
+
if (this.cometVersion === "0.38") {
|
|
339
|
+
const tagged = (events, mode) => events.map((event) => ({
|
|
340
|
+
type: event.type,
|
|
341
|
+
attributes: [...event.attributes, attribute("mode", mode)]
|
|
342
|
+
}));
|
|
343
|
+
return {
|
|
344
|
+
height,
|
|
345
|
+
results,
|
|
346
|
+
finalizeBlockEvents: [...tagged(beginBlockEvents, "BeginBlock"), ...tagged(endBlockEvents, "EndBlock")],
|
|
347
|
+
validatorUpdates: [],
|
|
348
|
+
consensusUpdates: void 0
|
|
349
|
+
};
|
|
350
|
+
}
|
|
188
351
|
return {
|
|
189
352
|
height,
|
|
190
353
|
results,
|
|
191
|
-
beginBlockEvents
|
|
192
|
-
endBlockEvents
|
|
354
|
+
beginBlockEvents,
|
|
355
|
+
endBlockEvents,
|
|
193
356
|
validatorUpdates: [],
|
|
194
357
|
consensusUpdates: void 0
|
|
195
358
|
};
|
|
@@ -206,4 +369,6 @@ function createMockRpcClient(config) {
|
|
|
206
369
|
//#endregion
|
|
207
370
|
exports.MockRpcClient = MockRpcClient;
|
|
208
371
|
exports.createMockRpcClient = createMockRpcClient;
|
|
372
|
+
exports.mockModuleAccounts = mockModuleAccounts;
|
|
373
|
+
exports.syntheticAddress = syntheticAddress;
|
|
209
374
|
//# sourceMappingURL=rpc-client.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client.cjs","names":["tx: Tx","Tx","txs: Uint8Array[]","results: TxData[]"],"sources":["../../src/mocks/rpc-client.ts"],"sourcesContent":["/**\n * Mock RPC client for benchmarking and testing\n * Generates synthetic blockchain data without requiring an actual RPC node\n */\nimport {\n fromBase64, fromHex,\n} from \"@cosmjs/encoding\";\nimport {\n BlockResponse,\n BlockResultsResponse,\n CometClient,\n fromRfc3339WithNanoseconds,\n StatusResponse,\n TxData,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n Tx,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx.js\";\n\n/** Configuration for mock data generation */\nexport interface MockRpcConfig {\n /** Chain ID for generated blocks */\n chainId: string\n /** Number of transactions per block */\n txPerBlock: number\n /** Starting block height */\n startHeight: number\n /** Latest block height available */\n endHeight: number\n}\n/**\n * Generates a synthetic transaction with realistic structure\n */\nfunction generateMockTx(height: number, txIndex: number): Uint8Array {\n const tx: Tx = {\n body: {\n messages: [\n {\n typeUrl: \"/cosmos.bank.v1beta1.MsgSend\",\n value: new Uint8Array([10, 45, 99, 111, 115, 109, 111, 115, 49, 18, 45, 99, 111, 115, 109, 111, 115, 50]),\n },\n ],\n memo: `Mock tx ${height}-${txIndex}`,\n timeoutHeight: BigInt(height + 100),\n extensionOptions: [],\n nonCriticalExtensionOptions: [],\n },\n authInfo: {\n signerInfos: [\n {\n publicKey: {\n typeUrl: \"/cosmos.crypto.secp256k1.PubKey\",\n value: new Uint8Array(33),\n },\n modeInfo: {\n single: {\n mode: 1,\n },\n },\n sequence: BigInt(txIndex),\n },\n ],\n fee: {\n amount: [\n {\n denom: \"uatom\",\n amount: \"5000\",\n },\n ],\n gasLimit: BigInt(200000),\n payer: \"\",\n granter: \"\",\n },\n tip: undefined,\n },\n signatures: [new Uint8Array(64)],\n };\n\n return Tx.encode(tx).finish();\n}\n\nexport class MockRpcClient {\n private chainId: string;\n private startHeight: number;\n private endHeight: number;\n private txPerBlock: number;\n\n constructor({\n chainId,\n startHeight,\n endHeight,\n txPerBlock,\n }: {\n chainId: string\n startHeight: number\n endHeight: number\n txPerBlock: number\n }) {\n this.chainId = chainId;\n this.startHeight = startHeight;\n this.endHeight = endHeight;\n this.txPerBlock = txPerBlock;\n }\n\n async block(height: number): Promise<BlockResponse> {\n const txs: Uint8Array[] = [];\n for (let i = 0; i < this.txPerBlock; i++) {\n txs.push(generateMockTx(height, i));\n }\n return {\n block: {\n header: {\n height: height,\n version: {\n block: 11,\n app: 0,\n },\n time: fromRfc3339WithNanoseconds(new Date().toISOString()),\n chainId: this.chainId,\n lastBlockId: null,\n lastCommitHash: new Uint8Array(),\n dataHash: new Uint8Array(),\n validatorsHash: new Uint8Array(),\n nextValidatorsHash: new Uint8Array(),\n consensusHash: new Uint8Array(),\n appHash: new Uint8Array(),\n lastResultsHash: new Uint8Array(),\n evidenceHash: new Uint8Array(),\n proposerAddress: new Uint8Array(),\n },\n txs: txs,\n evidence: [],\n lastCommit: {\n height: height - 1,\n round: 0,\n blockId: {\n hash: new Uint8Array(),\n parts: {\n total: 0,\n hash: new Uint8Array(),\n },\n },\n signatures: [\n {\n blockIdFlag: 2,\n validatorAddress: fromHex(\"D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8\"),\n timestamp: fromRfc3339WithNanoseconds(new Date().toISOString()),\n signature: fromBase64(\"Z6d2P35dI6qBzfPdyIZvmZi7Imo2FmQ5kNSnpVb2UvCj0aSjRCtS59BauJFB6FDHPluOUYoz0rJ4jiOnNXh9AA==\"),\n },\n ],\n },\n },\n blockId: {\n hash: new Uint8Array(),\n parts: {\n total: 0,\n hash: new Uint8Array(),\n },\n },\n };\n }\n\n async status(): Promise<StatusResponse> {\n return {\n nodeInfo: {\n protocolVersion: {\n p2p: 8,\n block: 11,\n app: 0,\n },\n id: fromHex(\"d2982128df6a29e700980f325b0444e301c604d7\"),\n listenAddr: \"tcp://0.0.0.0:26656\",\n network: \"atomone-1\",\n version: \"0.37.15\",\n channels: \"40202122233038606100\",\n moniker: \"node\",\n other: new Map([[\"txIndex\", \"on\"], [\"rpcAddress\", \"tcp://0.0.0.0:26657\"]]),\n },\n syncInfo: {\n latestBlockHash: fromHex(\"3F3F7A6F11FA91856BE440F8C78262307CAEAB122720D61CB14B118EF89892B5\"),\n latestAppHash: fromHex(\"FF91D618633BDD5395763F34805E6DACF6BBFB642A2E787677BF28B39427F289\"),\n latestBlockHeight: this.endHeight,\n latestBlockTime: fromRfc3339WithNanoseconds(\"2025-11-06T12:58:21.271608775Z\"),\n earliestBlockHash: fromHex(\"54473B6F28CAA85F5664F7CA3F2EEE49CD9857BDE41E0BF604B1A1DE93CBFEFF\"),\n earliestAppHash: fromHex(\"24DFB6C312A7FD4B753444F5CD5FAC4D239BAEC09B6A79BB3D04B21B0BC1FC53\"),\n earliestBlockHeight: 1,\n earliestBlockTime: fromRfc3339WithNanoseconds(\"2025-05-28T07:58:54.905470438Z\"),\n catchingUp: false,\n },\n validatorInfo: {\n address: fromHex(\"1C7CE0213D96CD5578249740DC31A9D8E4D7A226\"),\n pubkey: {\n algorithm: \"ed25519\",\n data: fromBase64(\"+KoTmCU6lo7NCtsfPCYpdNf0fs3aScZ8CtdgHTR/oGs=\"),\n },\n votingPower: 0n,\n },\n };\n }\n\n subscribeNewBlock() {\n return {\n addListener: (..._args: unknown[]) => {},\n removeListener: (..._args: unknown[]) => {},\n } as ReturnType<CometClient[\"subscribeNewBlock\"]>;\n }\n\n async disconnect(): Promise<void> {\n // No-op for mock\n }\n\n async blockResults(height: number): Promise<BlockResultsResponse> {\n const results: TxData[] = [];\n for (let i = 0; i < this.txPerBlock; i++) {\n results.push({\n code: 0,\n data: Buffer.from(\"success\"),\n log: JSON.stringify([\n {\n msg_index: 0,\n events: [],\n },\n ]),\n gasWanted: BigInt(200000),\n gasUsed: BigInt(150000),\n events: [],\n codespace: \"\",\n });\n }\n return {\n height: height,\n results: results,\n beginBlockEvents: [],\n endBlockEvents: [],\n validatorUpdates: [],\n consensusUpdates: undefined,\n };\n }\n\n async connect(): Promise<void> {\n }\n}\n\n/**\n * Factory function to create a mock RPC client\n */\nexport function createMockRpcClient(config: MockRpcConfig): CometClient {\n return new MockRpcClient(config) as unknown as CometClient;\n}\n"],"mappings":";;;;;;;;;;AAiCA,SAAS,eAAe,QAAgB,SAA6B;CACnE,MAAMA,KAAS;EACb,MAAM;GACJ,UAAU,CACR;IACE,SAAS;IACT,OAAO,IAAI,WAAW;KAAC;KAAI;KAAI;KAAI;KAAK;KAAK;KAAK;KAAK;KAAK;KAAI;KAAI;KAAI;KAAI;KAAK;KAAK;KAAK;KAAK;KAAK;KAAG,CAAC;IAC1G,CACF;GACD,MAAM,WAAW,OAAO,GAAG;GAC3B,eAAe,OAAO,SAAS,IAAI;GACnC,kBAAkB,EAAE;GACpB,6BAA6B,EAAE;GAChC;EACD,U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;GACV,WAAW;GACZ,CAAC;AAEJ,SAAO;GACG;GACC;GACT,kBAAkB,EAAE;GACpB,gBAAgB,EAAE;GAClB,kBAAkB,EAAE;GACpB,kBAAkB;GACnB;;CAGH,MAAM,UAAyB;;;;;AAOjC,SAAgB,oBAAoB,QAAoC;AACtE,QAAO,IAAI,cAAc,OAAO"}
|
|
1
|
+
{"version":3,"file":"rpc-client.cjs","names":["tx: Tx","Tx","set: Validator[]","Validator","QueryValidatorsRequest","QueryValidatorsResponse","QueryModuleAccountsResponse","ModuleAccount","QueryAllBalancesResponse","QueryPoolResponse","QueryStakingParamsResponse","QueryDelegatorDelegationsResponse","QueryValidatorDelegationsResponse","txs: Uint8Array[]","results: TxData[]","beginBlockEvents: Event38[]","endBlockEvents: Event38[]"],"sources":["../../src/mocks/rpc-client.ts"],"sourcesContent":["/**\n * Mock RPC client for benchmarking and testing\n * Generates synthetic blockchain data without requiring an actual RPC node\n */\nimport {\n createHash,\n} from \"node:crypto\";\n\nimport {\n fromBase64, fromHex, toBech32,\n} from \"@cosmjs/encoding\";\nimport {\n AbciQueryParams,\n AbciQueryResponse,\n BlockResponse,\n BlockResultsResponse,\n CometClient,\n fromRfc3339WithNanoseconds,\n StatusResponse,\n TxData,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event as Event38,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses.js\";\nimport {\n ModuleAccount,\n} from \"cosmjs-types/cosmos/auth/v1beta1/auth.js\";\nimport {\n QueryModuleAccountsResponse,\n} from \"cosmjs-types/cosmos/auth/v1beta1/query.js\";\nimport {\n QueryAllBalancesResponse,\n} from \"cosmjs-types/cosmos/bank/v1beta1/query.js\";\nimport {\n QueryDelegatorDelegationsResponse,\n QueryParamsResponse as QueryStakingParamsResponse,\n QueryPoolResponse,\n QueryValidatorDelegationsResponse,\n QueryValidatorsRequest,\n QueryValidatorsResponse,\n} from \"cosmjs-types/cosmos/staking/v1beta1/query.js\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking.js\";\nimport {\n Tx,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx.js\";\n\n/** Configuration for mock data generation */\nexport interface MockRpcConfig {\n /** Chain ID for generated blocks */\n chainId: string\n /** Number of transactions per block */\n txPerBlock: number\n /** Starting block height */\n startHeight: number\n /** Latest block height available */\n endHeight: number\n /** Which CometBFT response shape to produce (default: 0.37) */\n cometVersion?: \"0.37\" | \"0.38\"\n /** Size of the synthetic validator set answered by the Validators ABCI query (default: 3) */\n validatorCount?: number\n}\n\n/** Deterministic bech32 address from a small integer, for synthetic accounts and validators */\nexport function syntheticAddress(prefix: string, seed: number): string {\n const bytes = new Uint8Array(20);\n bytes[0] = seed & 0xff;\n bytes[1] = (seed >> 8) & 0xff;\n bytes[19] = 0x01;\n return toBech32(prefix, bytes);\n}\n\n/** Module accounts a chain always has, with deterministic addresses (computed on first use) */\nexport function mockModuleAccounts(): Record<string, string> {\n return {\n fee_collector: syntheticAddress(\"cosmos\", 1001),\n distribution: syntheticAddress(\"cosmos\", 1002),\n };\n}\n\n/**\n * Generates a synthetic transaction with realistic structure\n */\nfunction generateMockTx(height: number, txIndex: number): Uint8Array {\n const tx: Tx = {\n body: {\n messages: [\n {\n typeUrl: \"/cosmos.bank.v1beta1.MsgSend\",\n value: new Uint8Array([10, 45, 99, 111, 115, 109, 111, 115, 49, 18, 45, 99, 111, 115, 109, 111, 115, 50]),\n },\n ],\n memo: `Mock tx ${height}-${txIndex}`,\n timeoutHeight: BigInt(height + 100),\n extensionOptions: [],\n nonCriticalExtensionOptions: [],\n },\n authInfo: {\n signerInfos: [\n {\n publicKey: {\n typeUrl: \"/cosmos.crypto.secp256k1.PubKey\",\n value: new Uint8Array(33),\n },\n modeInfo: {\n single: {\n mode: 1,\n },\n },\n sequence: BigInt(txIndex),\n },\n ],\n fee: {\n amount: [\n {\n denom: \"uatom\",\n amount: \"5000\",\n },\n ],\n gasLimit: BigInt(200000),\n payer: \"\",\n granter: \"\",\n },\n tip: undefined,\n },\n signatures: [new Uint8Array(64)],\n };\n\n return Tx.encode(tx).finish();\n}\n\nexport class MockRpcClient {\n private chainId: string;\n private startHeight: number;\n private endHeight: number;\n private txPerBlock: number;\n private cometVersion: \"0.37\" | \"0.38\";\n private validatorCount: number;\n\n constructor({\n chainId,\n startHeight,\n endHeight,\n txPerBlock,\n cometVersion,\n validatorCount,\n }: MockRpcConfig) {\n this.chainId = chainId;\n this.startHeight = startHeight;\n this.endHeight = endHeight;\n this.txPerBlock = txPerBlock;\n this.cometVersion = cometVersion ?? \"0.37\";\n this.validatorCount = validatorCount ?? 3;\n }\n\n /** The synthetic validator set, identical at every height */\n validators(): Validator[] {\n const set: Validator[] = [];\n for (let i = 0; i < this.validatorCount; i++) {\n set.push(Validator.fromPartial({\n operatorAddress: syntheticAddress(\"cosmosvaloper\", i + 1),\n jailed: false,\n status: 3,\n tokens: String(1000000 * (i + 1)),\n delegatorShares: String(1000000 * (i + 1)) + \"000000000000000000\",\n description: {\n moniker: \"mock-validator-\" + (i + 1),\n },\n commission: {\n commissionRates: {\n rate: \"100000000000000000\",\n maxRate: \"200000000000000000\",\n maxChangeRate: \"10000000000000000\",\n },\n },\n minSelfDelegation: \"1\",\n }));\n }\n return set;\n }\n\n /**\n * Answers the ABCI queries the engine and the core modules issue. Unknown paths get a\n * non-zero code, as a real node would answer for a query it does not serve.\n */\n async abciQuery(params: AbciQueryParams): Promise<AbciQueryResponse> {\n const reply = (value: Uint8Array): AbciQueryResponse => ({\n key: new Uint8Array(),\n value,\n height: params.height,\n index: 0,\n code: 0,\n codespace: \"\",\n log: \"\",\n info: \"\",\n });\n switch (params.path) {\n case \"/cosmos.staking.v1beta1.Query/Validators\": {\n const request = QueryValidatorsRequest.decode(params.data);\n const all = this.validators();\n const limit = Number(request.pagination?.limit ?? 100n) || 100;\n const key = request.pagination?.key;\n const offset = key && key.length > 0 ? key[0] : 0;\n const page = all.slice(offset, offset + limit);\n const next = offset + limit < all.length ? new Uint8Array([offset + limit]) : new Uint8Array();\n return reply(QueryValidatorsResponse.encode(QueryValidatorsResponse.fromPartial({\n validators: page,\n pagination: {\n nextKey: next,\n total: BigInt(all.length),\n },\n })).finish());\n }\n case \"/cosmos.auth.v1beta1.Query/ModuleAccounts\":\n return reply(QueryModuleAccountsResponse.encode(QueryModuleAccountsResponse.fromPartial({\n accounts: Object.entries(mockModuleAccounts()).map(([name, address]) => ({\n typeUrl: \"/cosmos.auth.v1beta1.ModuleAccount\",\n value: ModuleAccount.encode(ModuleAccount.fromPartial({\n baseAccount: {\n address,\n },\n name,\n })).finish(),\n })),\n })).finish());\n case \"/cosmos.bank.v1beta1.Query/AllBalances\":\n return reply(QueryAllBalancesResponse.encode(QueryAllBalancesResponse.fromPartial({\n balances: [\n {\n denom: \"uatom\",\n amount: \"1000000\",\n },\n ],\n })).finish());\n case \"/cosmos.staking.v1beta1.Query/Pool\":\n return reply(QueryPoolResponse.encode(QueryPoolResponse.fromPartial({\n pool: {\n bondedTokens: String(this.validators().reduce((sum, v) => sum + Number(v.tokens), 0)),\n notBondedTokens: \"0\",\n },\n })).finish());\n case \"/cosmos.staking.v1beta1.Query/Params\":\n return reply(QueryStakingParamsResponse.encode(QueryStakingParamsResponse.fromPartial({\n params: {\n unbondingTime: {\n seconds: 1814400n,\n nanos: 0,\n },\n maxValidators: 100,\n maxEntries: 7,\n historicalEntries: 10000,\n bondDenom: \"uatom\",\n minCommissionRate: \"0\",\n },\n })).finish());\n case \"/cosmos.staking.v1beta1.Query/DelegatorDelegations\":\n return reply(QueryDelegatorDelegationsResponse.encode(QueryDelegatorDelegationsResponse.fromPartial({\n })).finish());\n case \"/cosmos.staking.v1beta1.Query/ValidatorDelegations\":\n return reply(QueryValidatorDelegationsResponse.encode(QueryValidatorDelegationsResponse.fromPartial({\n })).finish());\n default:\n return {\n ...reply(new Uint8Array()),\n code: 6,\n log: \"unknown request: \" + params.path,\n };\n }\n }\n\n async block(height: number): Promise<BlockResponse> {\n const txs: Uint8Array[] = [];\n for (let i = 0; i < this.txPerBlock; i++) {\n txs.push(generateMockTx(height, i));\n }\n // Deterministic, unique per height: the blocks table has a unique constraint on the hash\n const hashOf = (h: number) => new Uint8Array(createHash(\"sha256\").update(this.chainId + \":\" + h).digest());\n return {\n block: {\n header: {\n height: height,\n version: {\n block: 11,\n app: 0,\n },\n time: fromRfc3339WithNanoseconds(new Date().toISOString()),\n chainId: this.chainId,\n lastBlockId: null,\n lastCommitHash: new Uint8Array(),\n dataHash: new Uint8Array(),\n validatorsHash: new Uint8Array(),\n nextValidatorsHash: new Uint8Array(),\n consensusHash: new Uint8Array(),\n appHash: new Uint8Array(),\n lastResultsHash: new Uint8Array(),\n evidenceHash: new Uint8Array(),\n proposerAddress: new Uint8Array(),\n },\n txs: txs,\n evidence: [],\n lastCommit: {\n height: height - 1,\n round: 0,\n blockId: {\n hash: new Uint8Array(),\n parts: {\n total: 0,\n hash: new Uint8Array(),\n },\n },\n signatures: [\n {\n blockIdFlag: 2,\n validatorAddress: fromHex(\"D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8\"),\n timestamp: fromRfc3339WithNanoseconds(new Date().toISOString()),\n signature: fromBase64(\"Z6d2P35dI6qBzfPdyIZvmZi7Imo2FmQ5kNSnpVb2UvCj0aSjRCtS59BauJFB6FDHPluOUYoz0rJ4jiOnNXh9AA==\"),\n },\n ],\n },\n },\n blockId: {\n hash: hashOf(height),\n parts: {\n total: 0,\n hash: new Uint8Array(),\n },\n },\n };\n }\n\n async status(): Promise<StatusResponse> {\n return {\n nodeInfo: {\n protocolVersion: {\n p2p: 8,\n block: 11,\n app: 0,\n },\n id: fromHex(\"d2982128df6a29e700980f325b0444e301c604d7\"),\n listenAddr: \"tcp://0.0.0.0:26656\",\n network: this.chainId,\n version: this.cometVersion === \"0.38\" ? \"0.38.17\" : \"0.37.15\",\n channels: \"40202122233038606100\",\n moniker: \"node\",\n other: new Map([[\"txIndex\", \"on\"], [\"rpcAddress\", \"tcp://0.0.0.0:26657\"]]),\n },\n syncInfo: {\n latestBlockHash: fromHex(\"3F3F7A6F11FA91856BE440F8C78262307CAEAB122720D61CB14B118EF89892B5\"),\n latestAppHash: fromHex(\"FF91D618633BDD5395763F34805E6DACF6BBFB642A2E787677BF28B39427F289\"),\n latestBlockHeight: this.endHeight,\n latestBlockTime: fromRfc3339WithNanoseconds(\"2025-11-06T12:58:21.271608775Z\"),\n earliestBlockHash: fromHex(\"54473B6F28CAA85F5664F7CA3F2EEE49CD9857BDE41E0BF604B1A1DE93CBFEFF\"),\n earliestAppHash: fromHex(\"24DFB6C312A7FD4B753444F5CD5FAC4D239BAEC09B6A79BB3D04B21B0BC1FC53\"),\n earliestBlockHeight: 1,\n earliestBlockTime: fromRfc3339WithNanoseconds(\"2025-05-28T07:58:54.905470438Z\"),\n catchingUp: false,\n },\n validatorInfo: {\n address: fromHex(\"1C7CE0213D96CD5578249740DC31A9D8E4D7A226\"),\n pubkey: {\n algorithm: \"ed25519\",\n data: fromBase64(\"+KoTmCU6lo7NCtsfPCYpdNf0fs3aScZ8CtdgHTR/oGs=\"),\n },\n votingPower: 0n,\n },\n };\n }\n\n subscribeNewBlock() {\n return {\n addListener: (..._args: unknown[]) => {},\n removeListener: (..._args: unknown[]) => {},\n } as ReturnType<CometClient[\"subscribeNewBlock\"]>;\n }\n\n async disconnect(): Promise<void> {\n // No-op for mock\n }\n\n async blockResults(height: number): Promise<BlockResultsResponse | BlockResultsResponse38> {\n const attribute = (key: string, value: string) => ({\n key,\n value,\n });\n const feeCollector = mockModuleAccounts().fee_collector;\n // Events a real bank module emits for the transfer each mock tx performs\n const transferEvents = (msgIndex: number): Event38[] => [\n {\n type: \"message\",\n attributes: [attribute(\"action\", \"/cosmos.bank.v1beta1.MsgSend\"), attribute(\"msg_index\", String(msgIndex))],\n },\n {\n type: \"coin_spent\",\n attributes: [attribute(\"spender\", syntheticAddress(\"cosmos\", 1)), attribute(\"amount\", \"10uatom\"), attribute(\"msg_index\", String(msgIndex))],\n },\n {\n type: \"coin_received\",\n attributes: [attribute(\"receiver\", syntheticAddress(\"cosmos\", 2)), attribute(\"amount\", \"10uatom\"), attribute(\"msg_index\", String(msgIndex))],\n },\n ];\n const results: TxData[] = [];\n for (let i = 0; i < this.txPerBlock; i++) {\n results.push({\n code: 0,\n data: Buffer.from(\"success\"),\n // CometBFT 0.37 nodes return the structured log; 0.38 nodes return an empty log and\n // events tagged with msg_index instead\n log: this.cometVersion === \"0.38\"\n ? \"\"\n : JSON.stringify([\n {\n msg_index: 0,\n events: transferEvents(0),\n },\n ]),\n gasWanted: BigInt(200000),\n gasUsed: BigInt(150000),\n // The 0.37 and 0.38 event types are structurally identical\n events: transferEvents(0) as unknown as TxData[\"events\"],\n codespace: \"\",\n });\n }\n // Block-level flows: the fee collector receives the mint at the start of the block\n const beginBlockEvents: Event38[] = [\n {\n type: \"coin_received\",\n attributes: [attribute(\"receiver\", feeCollector), attribute(\"amount\", \"50uatom\")],\n },\n ];\n const endBlockEvents: Event38[] = [\n {\n type: \"coin_spent\",\n attributes: [attribute(\"spender\", feeCollector), attribute(\"amount\", \"5uatom\")],\n },\n ];\n if (this.cometVersion === \"0.38\") {\n // Cosmos SDK 0.50+ delivers both phases in one list, tagged with mode=BeginBlock / EndBlock\n const tagged = (events: Event38[], mode: string) => events.map(event => ({\n type: event.type,\n attributes: [...event.attributes, attribute(\"mode\", mode)],\n }));\n return {\n height,\n results,\n finalizeBlockEvents: [...tagged(beginBlockEvents, \"BeginBlock\"), ...tagged(endBlockEvents, \"EndBlock\")],\n validatorUpdates: [],\n consensusUpdates: undefined,\n } as unknown as BlockResultsResponse38;\n }\n return {\n height,\n results,\n beginBlockEvents,\n endBlockEvents,\n validatorUpdates: [],\n consensusUpdates: undefined,\n } as unknown as BlockResultsResponse;\n }\n\n async connect(): Promise<void> {\n }\n}\n\n/**\n * Factory function to create a mock RPC client\n */\nexport function createMockRpcClient(config: MockRpcConfig): CometClient {\n return new MockR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ACX,QAAQ,eAAe,EAAE;IAC1B,CACF,CAAC;GACJ,WAAW,OAAO,IAAO;GACzB,SAAS,OAAO,KAAO;GAEvB,QAAQ,eAAe,EAAE;GACzB,WAAW;GACZ,CAAC;EAGJ,MAAMC,mBAA8B,CAClC;GACE,MAAM;GACN,YAAY,CAAC,UAAU,YAAY,aAAa,EAAE,UAAU,UAAU,UAAU,CAAC;GAClF,CACF;EACD,MAAMC,iBAA4B,CAChC;GACE,MAAM;GACN,YAAY,CAAC,UAAU,WAAW,aAAa,EAAE,UAAU,UAAU,SAAS,CAAC;GAChF,CACF;AACD,MAAI,KAAK,iBAAiB,QAAQ;GAEhC,MAAM,UAAU,QAAmB,SAAiB,OAAO,KAAI,WAAU;IACvE,MAAM,MAAM;IACZ,YAAY,CAAC,GAAG,MAAM,YAAY,UAAU,QAAQ,KAAK,CAAC;IAC3D,EAAE;AACH,UAAO;IACL;IACA;IACA,qBAAqB,CAAC,GAAG,OAAO,kBAAkB,aAAa,EAAE,GAAG,OAAO,gBAAgB,WAAW,CAAC;IACvG,kBAAkB,EAAE;IACpB,kBAAkB;IACnB;;AAEH,SAAO;GACL;GACA;GACA;GACA;GACA,kBAAkB,EAAE;GACpB,kBAAkB;GACnB;;CAGH,MAAM,UAAyB;;;;;AAOjC,SAAgB,oBAAoB,QAAoC;AACtE,QAAO,IAAI,cAAc,OAAO"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { BlockResponse, BlockResultsResponse, CometClient, StatusResponse } from "@cosmjs/tendermint-rpc";
|
|
1
|
+
import { AbciQueryParams, AbciQueryResponse, BlockResponse, BlockResultsResponse, CometClient, StatusResponse } from "@cosmjs/tendermint-rpc";
|
|
2
|
+
import { BlockResultsResponse as BlockResultsResponse$1 } from "@cosmjs/tendermint-rpc/build/comet38/responses.js";
|
|
3
|
+
import { Validator } from "cosmjs-types/cosmos/staking/v1beta1/staking.js";
|
|
2
4
|
|
|
3
5
|
//#region src/mocks/rpc-client.d.ts
|
|
4
6
|
/** Configuration for mock data generation */
|
|
@@ -11,28 +13,42 @@ interface MockRpcConfig {
|
|
|
11
13
|
startHeight: number;
|
|
12
14
|
/** Latest block height available */
|
|
13
15
|
endHeight: number;
|
|
16
|
+
/** Which CometBFT response shape to produce (default: 0.37) */
|
|
17
|
+
cometVersion?: "0.37" | "0.38";
|
|
18
|
+
/** Size of the synthetic validator set answered by the Validators ABCI query (default: 3) */
|
|
19
|
+
validatorCount?: number;
|
|
14
20
|
}
|
|
21
|
+
/** Deterministic bech32 address from a small integer, for synthetic accounts and validators */
|
|
22
|
+
declare function syntheticAddress(prefix: string, seed: number): string;
|
|
23
|
+
/** Module accounts a chain always has, with deterministic addresses (computed on first use) */
|
|
24
|
+
declare function mockModuleAccounts(): Record<string, string>;
|
|
15
25
|
declare class MockRpcClient {
|
|
16
26
|
private chainId;
|
|
17
27
|
private startHeight;
|
|
18
28
|
private endHeight;
|
|
19
29
|
private txPerBlock;
|
|
30
|
+
private cometVersion;
|
|
31
|
+
private validatorCount;
|
|
20
32
|
constructor({
|
|
21
33
|
chainId,
|
|
22
34
|
startHeight,
|
|
23
35
|
endHeight,
|
|
24
|
-
txPerBlock
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
txPerBlock,
|
|
37
|
+
cometVersion,
|
|
38
|
+
validatorCount
|
|
39
|
+
}: MockRpcConfig);
|
|
40
|
+
/** The synthetic validator set, identical at every height */
|
|
41
|
+
validators(): Validator[];
|
|
42
|
+
/**
|
|
43
|
+
* Answers the ABCI queries the engine and the core modules issue. Unknown paths get a
|
|
44
|
+
* non-zero code, as a real node would answer for a query it does not serve.
|
|
45
|
+
*/
|
|
46
|
+
abciQuery(params: AbciQueryParams): Promise<AbciQueryResponse>;
|
|
31
47
|
block(height: number): Promise<BlockResponse>;
|
|
32
48
|
status(): Promise<StatusResponse>;
|
|
33
49
|
subscribeNewBlock(): ReturnType<CometClient["subscribeNewBlock"]>;
|
|
34
50
|
disconnect(): Promise<void>;
|
|
35
|
-
blockResults(height: number): Promise<BlockResultsResponse>;
|
|
51
|
+
blockResults(height: number): Promise<BlockResultsResponse | BlockResultsResponse$1>;
|
|
36
52
|
connect(): Promise<void>;
|
|
37
53
|
}
|
|
38
54
|
/**
|
|
@@ -40,5 +56,5 @@ declare class MockRpcClient {
|
|
|
40
56
|
*/
|
|
41
57
|
declare function createMockRpcClient(config: MockRpcConfig): CometClient;
|
|
42
58
|
//#endregion
|
|
43
|
-
export { MockRpcClient, MockRpcConfig, createMockRpcClient };
|
|
59
|
+
export { MockRpcClient, MockRpcConfig, createMockRpcClient, mockModuleAccounts, syntheticAddress };
|
|
44
60
|
//# sourceMappingURL=rpc-client.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client.d.cts","names":[],"sources":["../../src/mocks/rpc-client.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rpc-client.d.cts","names":[],"sources":["../../src/mocks/rpc-client.ts"],"sourcesContent":[],"mappings":";;;;;;UAiDiB,aAAA;EAAA;EAgBD,OAAA,EAAA,MAAA;EASA;EA0DH,UAAA,EAAA,MAAa;EAStB;EACA,WAAA,EAAA,MAAA;EACA;EACA,SAAA,EAAA,MAAA;EACA;EACA,YAAA,CAAA,EAAA,MAAA,GAAA,MAAA;EACC;EAUW,cAAA,CAAA,EAAA,MAAA;;;AA6B4B,iBAzH5B,gBAAA,CAyH4B,MAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;AAqFb,iBArMf,kBAAA,CAAA,CAqMe,EArMO,MAqMP,CAAA,MAAA,EAAA,MAAA,CAAA;AA4DL,cAvMb,aAAA,CAuMa;EAAR,QAAA,OAAA;EA0CE,QAAA,WAAA;EAAX,QAAA,SAAA;EAGa,QAAA,UAAA;EAIwB,QAAA,YAAA;EAAuB,QAAA,cAAA;EAA/B,WAAA,CAAA;IAAA,OAAA;IAAA,WAAA;IAAA,SAAA;IAAA,UAAA;IAAA,YAAA;IAAA;EAAA,CAAA,EAzOjC,aAyOiC;EAgFnB;EAAO,UAAA,CAAA,CAAA,EA/SV,SA+SU,EAAA;EAOV;;;;oBAzRU,kBAAkB,QAAQ;yBAqFrB,QAAQ;YA4DrB,QAAQ;uBA0CjB,WAAW;gBAGE;gCAIgB,QAAQ,uBAAuB;aAgFlD;;;;;iBAOH,mBAAA,SAA4B,gBAAgB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { BlockResponse, BlockResultsResponse, CometClient, StatusResponse } from "@cosmjs/tendermint-rpc";
|
|
1
|
+
import { AbciQueryParams, AbciQueryResponse, BlockResponse, BlockResultsResponse, CometClient, StatusResponse } from "@cosmjs/tendermint-rpc";
|
|
2
|
+
import { Validator } from "cosmjs-types/cosmos/staking/v1beta1/staking.js";
|
|
3
|
+
import { BlockResultsResponse as BlockResultsResponse$1 } from "@cosmjs/tendermint-rpc/build/comet38/responses.js";
|
|
2
4
|
|
|
3
5
|
//#region src/mocks/rpc-client.d.ts
|
|
4
6
|
/** Configuration for mock data generation */
|
|
@@ -11,28 +13,42 @@ interface MockRpcConfig {
|
|
|
11
13
|
startHeight: number;
|
|
12
14
|
/** Latest block height available */
|
|
13
15
|
endHeight: number;
|
|
16
|
+
/** Which CometBFT response shape to produce (default: 0.37) */
|
|
17
|
+
cometVersion?: "0.37" | "0.38";
|
|
18
|
+
/** Size of the synthetic validator set answered by the Validators ABCI query (default: 3) */
|
|
19
|
+
validatorCount?: number;
|
|
14
20
|
}
|
|
21
|
+
/** Deterministic bech32 address from a small integer, for synthetic accounts and validators */
|
|
22
|
+
declare function syntheticAddress(prefix: string, seed: number): string;
|
|
23
|
+
/** Module accounts a chain always has, with deterministic addresses (computed on first use) */
|
|
24
|
+
declare function mockModuleAccounts(): Record<string, string>;
|
|
15
25
|
declare class MockRpcClient {
|
|
16
26
|
private chainId;
|
|
17
27
|
private startHeight;
|
|
18
28
|
private endHeight;
|
|
19
29
|
private txPerBlock;
|
|
30
|
+
private cometVersion;
|
|
31
|
+
private validatorCount;
|
|
20
32
|
constructor({
|
|
21
33
|
chainId,
|
|
22
34
|
startHeight,
|
|
23
35
|
endHeight,
|
|
24
|
-
txPerBlock
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
txPerBlock,
|
|
37
|
+
cometVersion,
|
|
38
|
+
validatorCount
|
|
39
|
+
}: MockRpcConfig);
|
|
40
|
+
/** The synthetic validator set, identical at every height */
|
|
41
|
+
validators(): Validator[];
|
|
42
|
+
/**
|
|
43
|
+
* Answers the ABCI queries the engine and the core modules issue. Unknown paths get a
|
|
44
|
+
* non-zero code, as a real node would answer for a query it does not serve.
|
|
45
|
+
*/
|
|
46
|
+
abciQuery(params: AbciQueryParams): Promise<AbciQueryResponse>;
|
|
31
47
|
block(height: number): Promise<BlockResponse>;
|
|
32
48
|
status(): Promise<StatusResponse>;
|
|
33
49
|
subscribeNewBlock(): ReturnType<CometClient["subscribeNewBlock"]>;
|
|
34
50
|
disconnect(): Promise<void>;
|
|
35
|
-
blockResults(height: number): Promise<BlockResultsResponse>;
|
|
51
|
+
blockResults(height: number): Promise<BlockResultsResponse | BlockResultsResponse$1>;
|
|
36
52
|
connect(): Promise<void>;
|
|
37
53
|
}
|
|
38
54
|
/**
|
|
@@ -40,5 +56,5 @@ declare class MockRpcClient {
|
|
|
40
56
|
*/
|
|
41
57
|
declare function createMockRpcClient(config: MockRpcConfig): CometClient;
|
|
42
58
|
//#endregion
|
|
43
|
-
export { MockRpcClient, MockRpcConfig, createMockRpcClient };
|
|
59
|
+
export { MockRpcClient, MockRpcConfig, createMockRpcClient, mockModuleAccounts, syntheticAddress };
|
|
44
60
|
//# sourceMappingURL=rpc-client.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client.d.mts","names":[],"sources":["../../src/mocks/rpc-client.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rpc-client.d.mts","names":[],"sources":["../../src/mocks/rpc-client.ts"],"sourcesContent":[],"mappings":";;;;;;UAiDiB,aAAA;EAAA;EAgBD,OAAA,EAAA,MAAA;EASA;EA0DH,UAAA,EAAA,MAAa;EAStB;EACA,WAAA,EAAA,MAAA;EACA;EACA,SAAA,EAAA,MAAA;EACA;EACA,YAAA,CAAA,EAAA,MAAA,GAAA,MAAA;EACC;EAUW,cAAA,CAAA,EAAA,MAAA;;;AA6B4B,iBAzH5B,gBAAA,CAyH4B,MAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;AAqFb,iBArMf,kBAAA,CAAA,CAqMe,EArMO,MAqMP,CAAA,MAAA,EAAA,MAAA,CAAA;AA4DL,cAvMb,aAAA,CAuMa;EAAR,QAAA,OAAA;EA0CE,QAAA,WAAA;EAAX,QAAA,SAAA;EAGa,QAAA,UAAA;EAIwB,QAAA,YAAA;EAAuB,QAAA,cAAA;EAA/B,WAAA,CAAA;IAAA,OAAA;IAAA,WAAA;IAAA,SAAA;IAAA,UAAA;IAAA,YAAA;IAAA;EAAA,CAAA,EAzOjC,aAyOiC;EAgFnB;EAAO,UAAA,CAAA,CAAA,EA/SV,SA+SU,EAAA;EAOV;;;;oBAzRU,kBAAkB,QAAQ;yBAqFrB,QAAQ;YA4DrB,QAAQ;uBA0CjB,WAAW;gBAGE;gCAIgB,QAAQ,uBAAuB;aAgFlD;;;;;iBAOH,mBAAA,SAA4B,gBAAgB"}
|