@gnolang/tm2-js-client 1.3.2 → 1.3.3
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/bin/proto/google/protobuf/any.js +1 -1
- package/bin/proto/tm2/abci.js +1 -1
- package/bin/proto/tm2/multisig.d.ts +43 -0
- package/bin/proto/tm2/multisig.js +322 -0
- package/bin/proto/tm2/multisig.test.d.ts +1 -0
- package/bin/proto/tm2/multisig.test.js +63 -0
- package/bin/proto/tm2/tx.js +1 -1
- package/bin/provider/jsonrpc/jsonrpc.js +1 -1
- package/bin/provider/websocket/ws.js +1 -1
- package/bin/wallet/wallet.d.ts +5 -1
- package/bin/wallet/wallet.js +17 -10
- package/bin/wallet/wallet.test.js +76 -5
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.7.
|
|
4
|
+
// protoc-gen-ts_proto v2.7.7
|
|
5
5
|
// protoc v5.29.3
|
|
6
6
|
// source: google/protobuf/any.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/bin/proto/tm2/abci.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.7.
|
|
4
|
+
// protoc-gen-ts_proto v2.7.7
|
|
5
5
|
// protoc v5.29.3
|
|
6
6
|
// source: tm2/abci.proto
|
|
7
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
|
+
import Long from 'long';
|
|
3
|
+
import { Any } from '../google/protobuf/any';
|
|
4
|
+
export declare const protobufPackage = "tm";
|
|
5
|
+
/** messages */
|
|
6
|
+
export interface PubKeyMultisig {
|
|
7
|
+
k: Long;
|
|
8
|
+
pub_keys: Any[];
|
|
9
|
+
}
|
|
10
|
+
export interface Multisignature {
|
|
11
|
+
bit_array?: CompactBitArray | undefined;
|
|
12
|
+
sigs: Uint8Array[];
|
|
13
|
+
}
|
|
14
|
+
export interface CompactBitArray {
|
|
15
|
+
/** The number of extra bits in elems. */
|
|
16
|
+
extra_bits_stored: number;
|
|
17
|
+
elems: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
export declare const PubKeyMultisig: MessageFns<PubKeyMultisig>;
|
|
20
|
+
export declare const Multisignature: MessageFns<Multisignature>;
|
|
21
|
+
export declare const CompactBitArray: MessageFns<CompactBitArray>;
|
|
22
|
+
export declare function createCompactBitArray(bits: number): CompactBitArray;
|
|
23
|
+
export declare function compactBitArraySize(bA: CompactBitArray): number;
|
|
24
|
+
export declare function compactBitArraySetIndex(bA: CompactBitArray, i: number, v: boolean): boolean;
|
|
25
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
26
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
27
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
28
|
+
} : Partial<T>;
|
|
29
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
30
|
+
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
31
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
32
|
+
} & {
|
|
33
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
34
|
+
};
|
|
35
|
+
export interface MessageFns<T> {
|
|
36
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
37
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
38
|
+
fromJSON(object: any): T;
|
|
39
|
+
toJSON(message: T): unknown;
|
|
40
|
+
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
41
|
+
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
|
+
// versions:
|
|
4
|
+
// protoc-gen-ts_proto v2.7.7
|
|
5
|
+
// protoc v5.29.3
|
|
6
|
+
// source: tm2/multisig.proto
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.CompactBitArray = exports.Multisignature = exports.PubKeyMultisig = exports.protobufPackage = void 0;
|
|
12
|
+
exports.createCompactBitArray = createCompactBitArray;
|
|
13
|
+
exports.compactBitArraySize = compactBitArraySize;
|
|
14
|
+
exports.compactBitArraySetIndex = compactBitArraySetIndex;
|
|
15
|
+
/* eslint-disable */
|
|
16
|
+
var wire_1 = require("@bufbuild/protobuf/wire");
|
|
17
|
+
var long_1 = __importDefault(require("long"));
|
|
18
|
+
var any_1 = require("../google/protobuf/any");
|
|
19
|
+
exports.protobufPackage = 'tm';
|
|
20
|
+
function createBasePubKeyMultisig() {
|
|
21
|
+
return { k: long_1.default.UZERO, pub_keys: [] };
|
|
22
|
+
}
|
|
23
|
+
exports.PubKeyMultisig = {
|
|
24
|
+
encode: function (message, writer) {
|
|
25
|
+
if (writer === void 0) { writer = new wire_1.BinaryWriter(); }
|
|
26
|
+
if (!message.k.equals(long_1.default.UZERO)) {
|
|
27
|
+
writer.uint32(8).uint64(message.k.toString());
|
|
28
|
+
}
|
|
29
|
+
for (var _i = 0, _a = message.pub_keys; _i < _a.length; _i++) {
|
|
30
|
+
var v = _a[_i];
|
|
31
|
+
any_1.Any.encode(v, writer.uint32(18).fork()).join();
|
|
32
|
+
}
|
|
33
|
+
return writer;
|
|
34
|
+
},
|
|
35
|
+
decode: function (input, length) {
|
|
36
|
+
var reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
37
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
38
|
+
var message = createBasePubKeyMultisig();
|
|
39
|
+
while (reader.pos < end) {
|
|
40
|
+
var tag = reader.uint32();
|
|
41
|
+
switch (tag >>> 3) {
|
|
42
|
+
case 1: {
|
|
43
|
+
if (tag !== 8) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
message.k = long_1.default.fromString(reader.uint64().toString(), true);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
case 2: {
|
|
50
|
+
if (tag !== 18) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
message.pub_keys.push(any_1.Any.decode(reader, reader.uint32()));
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
reader.skip(tag & 7);
|
|
61
|
+
}
|
|
62
|
+
return message;
|
|
63
|
+
},
|
|
64
|
+
fromJSON: function (object) {
|
|
65
|
+
return {
|
|
66
|
+
k: isSet(object.threshold)
|
|
67
|
+
? long_1.default.fromValue(object.threshold)
|
|
68
|
+
: long_1.default.UZERO,
|
|
69
|
+
pub_keys: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.pubkeys)
|
|
70
|
+
? object.pubkeys.map(function (e) { return any_1.Any.fromJSON(e); })
|
|
71
|
+
: [],
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
toJSON: function (message) {
|
|
75
|
+
var _a;
|
|
76
|
+
var obj = {};
|
|
77
|
+
if (message.k !== undefined) {
|
|
78
|
+
obj.threshold = (message.k || long_1.default.UZERO).toString();
|
|
79
|
+
}
|
|
80
|
+
if ((_a = message.pub_keys) === null || _a === void 0 ? void 0 : _a.length) {
|
|
81
|
+
obj.pubkeys = message.pub_keys.map(function (e) { return any_1.Any.toJSON(e); });
|
|
82
|
+
}
|
|
83
|
+
return obj;
|
|
84
|
+
},
|
|
85
|
+
create: function (base) {
|
|
86
|
+
return exports.PubKeyMultisig.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
87
|
+
},
|
|
88
|
+
fromPartial: function (object) {
|
|
89
|
+
var _a;
|
|
90
|
+
var message = createBasePubKeyMultisig();
|
|
91
|
+
message.k =
|
|
92
|
+
object.k !== undefined && object.k !== null
|
|
93
|
+
? long_1.default.fromValue(object.k)
|
|
94
|
+
: long_1.default.UZERO;
|
|
95
|
+
message.pub_keys = ((_a = object.pub_keys) === null || _a === void 0 ? void 0 : _a.map(function (e) { return any_1.Any.fromPartial(e); })) || [];
|
|
96
|
+
return message;
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
function createBaseMultisignature() {
|
|
100
|
+
return { bit_array: undefined, sigs: [] };
|
|
101
|
+
}
|
|
102
|
+
exports.Multisignature = {
|
|
103
|
+
encode: function (message, writer) {
|
|
104
|
+
if (writer === void 0) { writer = new wire_1.BinaryWriter(); }
|
|
105
|
+
if (message.bit_array !== undefined) {
|
|
106
|
+
exports.CompactBitArray.encode(message.bit_array, writer.uint32(10).fork()).join();
|
|
107
|
+
}
|
|
108
|
+
for (var _i = 0, _a = message.sigs; _i < _a.length; _i++) {
|
|
109
|
+
var v = _a[_i];
|
|
110
|
+
writer.uint32(18).bytes(v);
|
|
111
|
+
}
|
|
112
|
+
return writer;
|
|
113
|
+
},
|
|
114
|
+
decode: function (input, length) {
|
|
115
|
+
var reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
116
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
117
|
+
var message = createBaseMultisignature();
|
|
118
|
+
while (reader.pos < end) {
|
|
119
|
+
var tag = reader.uint32();
|
|
120
|
+
switch (tag >>> 3) {
|
|
121
|
+
case 1: {
|
|
122
|
+
if (tag !== 10) {
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
message.bit_array = exports.CompactBitArray.decode(reader, reader.uint32());
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
case 2: {
|
|
129
|
+
if (tag !== 18) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
message.sigs.push(reader.bytes());
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
reader.skip(tag & 7);
|
|
140
|
+
}
|
|
141
|
+
return message;
|
|
142
|
+
},
|
|
143
|
+
fromJSON: function (object) {
|
|
144
|
+
return {
|
|
145
|
+
bit_array: isSet(object.bit_array)
|
|
146
|
+
? exports.CompactBitArray.fromJSON(object.bit_array)
|
|
147
|
+
: undefined,
|
|
148
|
+
sigs: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.sigs)
|
|
149
|
+
? object.sigs.map(function (e) { return bytesFromBase64(e); })
|
|
150
|
+
: [],
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
toJSON: function (message) {
|
|
154
|
+
var _a;
|
|
155
|
+
var obj = {};
|
|
156
|
+
if (message.bit_array !== undefined) {
|
|
157
|
+
obj.bit_array = exports.CompactBitArray.toJSON(message.bit_array);
|
|
158
|
+
}
|
|
159
|
+
if ((_a = message.sigs) === null || _a === void 0 ? void 0 : _a.length) {
|
|
160
|
+
obj.sigs = message.sigs.map(function (e) { return base64FromBytes(e); });
|
|
161
|
+
}
|
|
162
|
+
return obj;
|
|
163
|
+
},
|
|
164
|
+
create: function (base) {
|
|
165
|
+
return exports.Multisignature.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
166
|
+
},
|
|
167
|
+
fromPartial: function (object) {
|
|
168
|
+
var _a;
|
|
169
|
+
var message = createBaseMultisignature();
|
|
170
|
+
message.bit_array =
|
|
171
|
+
object.bit_array !== undefined && object.bit_array !== null
|
|
172
|
+
? exports.CompactBitArray.fromPartial(object.bit_array)
|
|
173
|
+
: undefined;
|
|
174
|
+
message.sigs = ((_a = object.sigs) === null || _a === void 0 ? void 0 : _a.map(function (e) { return e; })) || [];
|
|
175
|
+
return message;
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
function createBaseCompactBitArray() {
|
|
179
|
+
return { extra_bits_stored: 0, elems: new Uint8Array(0) };
|
|
180
|
+
}
|
|
181
|
+
exports.CompactBitArray = {
|
|
182
|
+
encode: function (message, writer) {
|
|
183
|
+
if (writer === void 0) { writer = new wire_1.BinaryWriter(); }
|
|
184
|
+
if (message.extra_bits_stored !== 0) {
|
|
185
|
+
writer.uint32(8).uint32(message.extra_bits_stored);
|
|
186
|
+
}
|
|
187
|
+
if (message.elems.length !== 0) {
|
|
188
|
+
writer.uint32(18).bytes(message.elems);
|
|
189
|
+
}
|
|
190
|
+
return writer;
|
|
191
|
+
},
|
|
192
|
+
decode: function (input, length) {
|
|
193
|
+
var reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
194
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
195
|
+
var message = createBaseCompactBitArray();
|
|
196
|
+
while (reader.pos < end) {
|
|
197
|
+
var tag = reader.uint32();
|
|
198
|
+
switch (tag >>> 3) {
|
|
199
|
+
case 1: {
|
|
200
|
+
if (tag !== 8) {
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
message.extra_bits_stored = reader.uint32();
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
case 2: {
|
|
207
|
+
if (tag !== 18) {
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
message.elems = reader.bytes();
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
reader.skip(tag & 7);
|
|
218
|
+
}
|
|
219
|
+
return message;
|
|
220
|
+
},
|
|
221
|
+
fromJSON: function (json) {
|
|
222
|
+
if (json === null) {
|
|
223
|
+
// Handle null case
|
|
224
|
+
return createBaseCompactBitArray();
|
|
225
|
+
}
|
|
226
|
+
if (typeof json !== 'string') {
|
|
227
|
+
throw new Error("CompactBitArray in JSON should be a string or null but got ".concat(typeof json));
|
|
228
|
+
}
|
|
229
|
+
var bits = json;
|
|
230
|
+
var numBits = bits.length;
|
|
231
|
+
// Create a new CompactBitArray
|
|
232
|
+
var numBytes = Math.ceil(numBits / 8);
|
|
233
|
+
var elems = new Uint8Array(numBytes);
|
|
234
|
+
var extraBitsStored = numBits % 8;
|
|
235
|
+
var bitArray = { extra_bits_stored: extraBitsStored, elems: elems };
|
|
236
|
+
// Set bits based on the string representation
|
|
237
|
+
for (var i = 0; i < numBits; i++) {
|
|
238
|
+
if (bits[i] === 'x') {
|
|
239
|
+
compactBitArraySetIndex(bitArray, i, true);
|
|
240
|
+
}
|
|
241
|
+
// For '_', we don't need to do anything as bits are initialized to 0
|
|
242
|
+
}
|
|
243
|
+
return bitArray;
|
|
244
|
+
},
|
|
245
|
+
toJSON: function (message) {
|
|
246
|
+
throw new Error('not implemented');
|
|
247
|
+
},
|
|
248
|
+
create: function (base) {
|
|
249
|
+
return exports.CompactBitArray.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
250
|
+
},
|
|
251
|
+
fromPartial: function (object) {
|
|
252
|
+
var _a, _b;
|
|
253
|
+
var message = createBaseCompactBitArray();
|
|
254
|
+
message.extra_bits_stored = (_a = object.extra_bits_stored) !== null && _a !== void 0 ? _a : 0;
|
|
255
|
+
message.elems = (_b = object.elems) !== null && _b !== void 0 ? _b : new Uint8Array(0);
|
|
256
|
+
return message;
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
function createCompactBitArray(bits) {
|
|
260
|
+
if (bits <= 0) {
|
|
261
|
+
throw new Error('empty');
|
|
262
|
+
}
|
|
263
|
+
var extraBitsStored = bits % 8;
|
|
264
|
+
var elems = new Uint8Array(Math.ceil(bits / 8));
|
|
265
|
+
return { extra_bits_stored: extraBitsStored, elems: elems };
|
|
266
|
+
}
|
|
267
|
+
function compactBitArraySize(bA) {
|
|
268
|
+
if (bA.elems === null) {
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
271
|
+
else if (bA.extra_bits_stored === 0) {
|
|
272
|
+
return bA.elems.length * 8;
|
|
273
|
+
}
|
|
274
|
+
return (bA.elems.length - 1) * 8 + bA.extra_bits_stored;
|
|
275
|
+
}
|
|
276
|
+
// SetIndex sets the bit at index i within the bit array
|
|
277
|
+
// Returns true if successful, false if out of bounds or array is null
|
|
278
|
+
function compactBitArraySetIndex(bA, i, v) {
|
|
279
|
+
if (bA.elems === null) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
if (i >= compactBitArraySize(bA)) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
if (v) {
|
|
286
|
+
// Set the bit (most significant bit first)
|
|
287
|
+
bA.elems[i >> 3] |= 1 << (7 - (i % 8));
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
// Clear the bit
|
|
291
|
+
bA.elems[i >> 3] &= ~(1 << (7 - (i % 8)));
|
|
292
|
+
}
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
function bytesFromBase64(b64) {
|
|
296
|
+
if (globalThis.Buffer) {
|
|
297
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, 'base64'));
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
var bin = globalThis.atob(b64);
|
|
301
|
+
var arr = new Uint8Array(bin.length);
|
|
302
|
+
for (var i = 0; i < bin.length; ++i) {
|
|
303
|
+
arr[i] = bin.charCodeAt(i);
|
|
304
|
+
}
|
|
305
|
+
return arr;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function base64FromBytes(arr) {
|
|
309
|
+
if (globalThis.Buffer) {
|
|
310
|
+
return globalThis.Buffer.from(arr).toString('base64');
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
var bin_1 = [];
|
|
314
|
+
arr.forEach(function (byte) {
|
|
315
|
+
bin_1.push(globalThis.String.fromCharCode(byte));
|
|
316
|
+
});
|
|
317
|
+
return globalThis.btoa(bin_1.join(''));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function isSet(value) {
|
|
321
|
+
return value !== null && value !== undefined;
|
|
322
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var utils_1 = require("@noble/hashes/utils");
|
|
40
|
+
var multisig_1 = require("./multisig");
|
|
41
|
+
describe('TestMarshalCompactBitArrayAmino', function () {
|
|
42
|
+
var testCases = [
|
|
43
|
+
{ marshalledBA: "null", hexOutput: '' },
|
|
44
|
+
{ marshalledBA: "null", hexOutput: '' },
|
|
45
|
+
{ marshalledBA: "\"_\"", hexOutput: '0801120100' },
|
|
46
|
+
{ marshalledBA: "\"x\"", hexOutput: '0801120180' },
|
|
47
|
+
{ marshalledBA: "\"xx___\"", hexOutput: '08051201c0' },
|
|
48
|
+
{ marshalledBA: "\"xx______x\"", hexOutput: '08011202c080' },
|
|
49
|
+
{ marshalledBA: "\"xx_____________x\"", hexOutput: '1202c001' },
|
|
50
|
+
];
|
|
51
|
+
test.each(testCases)('$marshalledBA', function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
52
|
+
var jsonData, bA, bz, actualHex;
|
|
53
|
+
var marshalledBA = _b.marshalledBA, hexOutput = _b.hexOutput;
|
|
54
|
+
return __generator(this, function (_c) {
|
|
55
|
+
jsonData = JSON.parse(marshalledBA);
|
|
56
|
+
bA = multisig_1.CompactBitArray.fromJSON(jsonData);
|
|
57
|
+
bz = multisig_1.CompactBitArray.encode(bA).finish();
|
|
58
|
+
actualHex = (0, utils_1.bytesToHex)(bz);
|
|
59
|
+
expect(actualHex).toBe(hexOutput);
|
|
60
|
+
return [2 /*return*/];
|
|
61
|
+
});
|
|
62
|
+
}); });
|
|
63
|
+
});
|
package/bin/proto/tm2/tx.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.7.
|
|
4
|
+
// protoc-gen-ts_proto v2.7.7
|
|
5
5
|
// protoc v5.29.3
|
|
6
6
|
// source: tm2/tx.proto
|
|
7
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
@@ -228,7 +228,7 @@ var JSONRPCProvider = /** @class */ (function () {
|
|
|
228
228
|
return __generator(this, function (_a) {
|
|
229
229
|
switch (_a.label) {
|
|
230
230
|
case 0: return [4 /*yield*/, services_1.RestService.post(this.baseURL, {
|
|
231
|
-
request: (0, utility_1.newRequest)(endpoints_1.CommonEndpoint.STATUS),
|
|
231
|
+
request: (0, utility_1.newRequest)(endpoints_1.CommonEndpoint.STATUS, [null]),
|
|
232
232
|
})];
|
|
233
233
|
case 1: return [2 /*return*/, _a.sent()];
|
|
234
234
|
}
|
|
@@ -320,7 +320,7 @@ var WSProvider = /** @class */ (function () {
|
|
|
320
320
|
var response;
|
|
321
321
|
return __generator(this, function (_a) {
|
|
322
322
|
switch (_a.label) {
|
|
323
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.CommonEndpoint.STATUS))];
|
|
323
|
+
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.CommonEndpoint.STATUS, [null]))];
|
|
324
324
|
case 1:
|
|
325
325
|
response = _a.sent();
|
|
326
326
|
return [2 /*return*/, this.parseResponse(response)];
|
package/bin/wallet/wallet.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { Signer } from './signer';
|
|
|
3
3
|
import { LedgerConnector } from '@cosmjs/ledger-amino';
|
|
4
4
|
import { Any, Tx } from '../proto';
|
|
5
5
|
import { AccountWalletOption, CreateWalletOptions } from './types';
|
|
6
|
+
export interface SignTransactionOptions {
|
|
7
|
+
accountNumber?: string;
|
|
8
|
+
sequence?: string;
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
11
|
* Wallet is a single account abstraction
|
|
8
12
|
* that can interact with the blockchain
|
|
@@ -85,7 +89,7 @@ export declare class Wallet {
|
|
|
85
89
|
* the transaction sign bytes are generated using sorted JSON, which requires
|
|
86
90
|
* encoded message values to be decoded for sorting
|
|
87
91
|
*/
|
|
88
|
-
signTransaction: (tx: Tx, decodeTxMessages: (messages: Any[]) => any[]) => Promise<Tx>;
|
|
92
|
+
signTransaction: (tx: Tx, decodeTxMessages: (messages: Any[]) => any[], opts?: SignTransactionOptions) => Promise<Tx>;
|
|
89
93
|
/**
|
|
90
94
|
* Encodes and sends the transaction. If the type of endpoint
|
|
91
95
|
* is a broadcast commit, waits for the transaction to be committed to the chain.
|
package/bin/wallet/wallet.js
CHANGED
|
@@ -182,8 +182,8 @@ var Wallet = /** @class */ (function () {
|
|
|
182
182
|
* the transaction sign bytes are generated using sorted JSON, which requires
|
|
183
183
|
* encoded message values to be decoded for sorting
|
|
184
184
|
*/
|
|
185
|
-
this.signTransaction = function (tx, decodeTxMessages) { return __awaiter(_this, void 0, void 0, function () {
|
|
186
|
-
var status, chainID,
|
|
185
|
+
this.signTransaction = function (tx, decodeTxMessages, opts) { return __awaiter(_this, void 0, void 0, function () {
|
|
186
|
+
var status, chainID, accountNumber, accountSequence, address, account, publicKey, signPayload, signBytes, wrappedKey, txSignature;
|
|
187
187
|
var _b;
|
|
188
188
|
return __generator(this, function (_c) {
|
|
189
189
|
switch (_c.label) {
|
|
@@ -199,22 +199,29 @@ var Wallet = /** @class */ (function () {
|
|
|
199
199
|
case 1:
|
|
200
200
|
status = _c.sent();
|
|
201
201
|
chainID = status.node_info.network;
|
|
202
|
+
accountNumber = opts === null || opts === void 0 ? void 0 : opts.accountNumber;
|
|
203
|
+
accountSequence = opts === null || opts === void 0 ? void 0 : opts.sequence;
|
|
204
|
+
if (!(accountNumber === undefined || accountSequence === undefined)) return [3 /*break*/, 4];
|
|
202
205
|
return [4 /*yield*/, this.getAddress()];
|
|
203
206
|
case 2:
|
|
204
207
|
address = _c.sent();
|
|
205
|
-
return [4 /*yield*/, this.provider.
|
|
208
|
+
return [4 /*yield*/, this.provider.getAccount(address)];
|
|
206
209
|
case 3:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
account = _c.sent();
|
|
211
|
+
if (accountNumber === undefined) {
|
|
212
|
+
accountNumber = account.BaseAccount.account_number;
|
|
213
|
+
}
|
|
214
|
+
if (accountSequence === undefined) {
|
|
215
|
+
accountSequence = account.BaseAccount.sequence;
|
|
216
|
+
}
|
|
217
|
+
_c.label = 4;
|
|
218
|
+
case 4: return [4 /*yield*/, this.signer.getPublicKey()];
|
|
212
219
|
case 5:
|
|
213
220
|
publicKey = _c.sent();
|
|
214
221
|
signPayload = {
|
|
215
222
|
chain_id: chainID,
|
|
216
|
-
account_number: accountNumber
|
|
217
|
-
sequence: accountSequence
|
|
223
|
+
account_number: accountNumber,
|
|
224
|
+
sequence: accountSequence,
|
|
218
225
|
fee: {
|
|
219
226
|
gas_fee: tx.fee.gas_fee,
|
|
220
227
|
gas_wanted: tx.fee.gas_wanted.toString(10),
|
|
@@ -246,7 +246,7 @@ describe('Wallet', function () {
|
|
|
246
246
|
});
|
|
247
247
|
}); });
|
|
248
248
|
test('signTransaction', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
249
|
-
var mockTx, mockStatus, mockProvider, wallet, emptyDecodeCallback, signedTx, sig;
|
|
249
|
+
var mockTx, mockStatus, mockProvider, mockAccount, wallet, emptyDecodeCallback, signedTx, sig;
|
|
250
250
|
var _a, _b;
|
|
251
251
|
return __generator(this, function (_c) {
|
|
252
252
|
switch (_c.label) {
|
|
@@ -274,8 +274,16 @@ describe('Wallet', function () {
|
|
|
274
274
|
};
|
|
275
275
|
mockProvider = (0, jest_mock_extended_1.mock)();
|
|
276
276
|
mockProvider.getStatus.mockResolvedValue(mockStatus);
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
mockAccount = {
|
|
278
|
+
BaseAccount: {
|
|
279
|
+
address: '',
|
|
280
|
+
coins: '',
|
|
281
|
+
public_key: null,
|
|
282
|
+
account_number: '',
|
|
283
|
+
sequence: '',
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
mockProvider.getAccount.mockResolvedValue(mockAccount);
|
|
279
287
|
return [4 /*yield*/, wallet_1.Wallet.createRandom()];
|
|
280
288
|
case 1:
|
|
281
289
|
wallet = _c.sent();
|
|
@@ -287,8 +295,71 @@ describe('Wallet', function () {
|
|
|
287
295
|
case 2:
|
|
288
296
|
signedTx = _c.sent();
|
|
289
297
|
expect(mockProvider.getStatus).toHaveBeenCalled();
|
|
290
|
-
expect(mockProvider.
|
|
291
|
-
expect(
|
|
298
|
+
expect(mockProvider.getAccount).toHaveBeenCalled();
|
|
299
|
+
expect(signedTx.signatures).toHaveLength(1);
|
|
300
|
+
sig = signedTx.signatures[0];
|
|
301
|
+
expect((_a = sig.pub_key) === null || _a === void 0 ? void 0 : _a.type_url).toBe(types_1.Secp256k1PubKeyType);
|
|
302
|
+
expect((_b = sig.pub_key) === null || _b === void 0 ? void 0 : _b.value).not.toBeNull();
|
|
303
|
+
expect(sig.signature).not.toBeNull();
|
|
304
|
+
return [2 /*return*/];
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}); });
|
|
308
|
+
test('signTransactionWithAllOpts', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
309
|
+
var mockTx, opts, mockStatus, mockProvider, mockAccount, wallet, emptyDecodeCallback, signedTx, sig;
|
|
310
|
+
var _a, _b;
|
|
311
|
+
return __generator(this, function (_c) {
|
|
312
|
+
switch (_c.label) {
|
|
313
|
+
case 0:
|
|
314
|
+
mockTx = (0, jest_mock_extended_1.mock)();
|
|
315
|
+
mockTx.signatures = [];
|
|
316
|
+
mockTx.fee = {
|
|
317
|
+
gas_fee: '10',
|
|
318
|
+
gas_wanted: new long_1.default(10),
|
|
319
|
+
};
|
|
320
|
+
mockTx.messages = [];
|
|
321
|
+
opts = {
|
|
322
|
+
accountNumber: '42',
|
|
323
|
+
sequence: '42',
|
|
324
|
+
};
|
|
325
|
+
mockStatus = (0, jest_mock_extended_1.mock)();
|
|
326
|
+
mockStatus.node_info = {
|
|
327
|
+
version_set: [],
|
|
328
|
+
version: '',
|
|
329
|
+
net_address: '',
|
|
330
|
+
software: '',
|
|
331
|
+
channels: '',
|
|
332
|
+
monkier: '',
|
|
333
|
+
other: {
|
|
334
|
+
tx_index: '',
|
|
335
|
+
rpc_address: '',
|
|
336
|
+
},
|
|
337
|
+
network: 'testchain',
|
|
338
|
+
};
|
|
339
|
+
mockProvider = (0, jest_mock_extended_1.mock)();
|
|
340
|
+
mockProvider.getStatus.mockResolvedValue(mockStatus);
|
|
341
|
+
mockAccount = {
|
|
342
|
+
BaseAccount: {
|
|
343
|
+
address: '',
|
|
344
|
+
coins: '',
|
|
345
|
+
public_key: null,
|
|
346
|
+
account_number: '',
|
|
347
|
+
sequence: '',
|
|
348
|
+
},
|
|
349
|
+
};
|
|
350
|
+
mockProvider.getAccount.mockResolvedValue(mockAccount);
|
|
351
|
+
return [4 /*yield*/, wallet_1.Wallet.createRandom()];
|
|
352
|
+
case 1:
|
|
353
|
+
wallet = _c.sent();
|
|
354
|
+
wallet.connect(mockProvider);
|
|
355
|
+
emptyDecodeCallback = function (_) {
|
|
356
|
+
return [];
|
|
357
|
+
};
|
|
358
|
+
return [4 /*yield*/, wallet.signTransaction(mockTx, emptyDecodeCallback, opts)];
|
|
359
|
+
case 2:
|
|
360
|
+
signedTx = _c.sent();
|
|
361
|
+
expect(mockProvider.getStatus).toHaveBeenCalled();
|
|
362
|
+
expect(mockProvider.getAccount).not.toHaveBeenCalled();
|
|
292
363
|
expect(signedTx.signatures).toHaveLength(1);
|
|
293
364
|
sig = signedTx.signatures[0];
|
|
294
365
|
expect((_a = sig.pub_key) === null || _a === void 0 ? void 0 : _a.type_url).toBe(types_1.Secp256k1PubKeyType);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnolang/tm2-js-client",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Tendermint2 JS / TS Client",
|
|
5
5
|
"main": "./bin/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@types/long": "^5.0.0",
|
|
31
31
|
"@types/node": "^24.3.0",
|
|
32
32
|
"@types/ws": "^8.5.11",
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
34
|
-
"@typescript-eslint/parser": "^8.
|
|
35
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
36
|
-
"eslint": "^9.
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
|
34
|
+
"@typescript-eslint/parser": "^8.42.0",
|
|
35
|
+
"@typescript-eslint/typescript-estree": "^8.42.0",
|
|
36
|
+
"eslint": "^9.35.0",
|
|
37
37
|
"eslint-config-prettier": "^10.1.5",
|
|
38
38
|
"eslint-plugin-prettier": "5.5.1",
|
|
39
39
|
"globals": "^16.3.0",
|