@gnolang/tm2-js-client 1.3.2 → 2.0.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/README.md +1 -1
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.cjs +12 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.mjs +12 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.cjs +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.mjs +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.cjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.mjs +11 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/index.cjs +92 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +22 -0
- package/dist/index.mjs.map +1 -0
- package/dist/proto/google/protobuf/any.cjs +84 -0
- package/dist/proto/google/protobuf/any.cjs.map +1 -0
- package/dist/proto/google/protobuf/any.d.cts +141 -0
- package/dist/proto/google/protobuf/any.d.cts.map +1 -0
- package/dist/proto/google/protobuf/any.d.mts +141 -0
- package/dist/proto/google/protobuf/any.d.mts.map +1 -0
- package/dist/proto/google/protobuf/any.mjs +83 -0
- package/dist/proto/google/protobuf/any.mjs.map +1 -0
- package/dist/proto/index.cjs +2 -0
- package/dist/proto/index.d.cts +2 -0
- package/dist/proto/index.d.mts +2 -0
- package/dist/proto/index.mjs +3 -0
- package/dist/proto/tm2/abci.cjs +182 -0
- package/dist/proto/tm2/abci.cjs.map +1 -0
- package/dist/proto/tm2/abci.d.cts +33 -0
- package/dist/proto/tm2/abci.d.cts.map +1 -0
- package/dist/proto/tm2/abci.d.mts +33 -0
- package/dist/proto/tm2/abci.d.mts.map +1 -0
- package/dist/proto/tm2/abci.mjs +181 -0
- package/dist/proto/tm2/abci.mjs.map +1 -0
- package/dist/proto/tm2/tx.cjs +263 -0
- package/dist/proto/tm2/tx.cjs.map +1 -0
- package/dist/proto/tm2/tx.d.cts +49 -0
- package/dist/proto/tm2/tx.d.cts.map +1 -0
- package/dist/proto/tm2/tx.d.mts +49 -0
- package/dist/proto/tm2/tx.d.mts.map +1 -0
- package/dist/proto/tm2/tx.mjs +258 -0
- package/dist/proto/tm2/tx.mjs.map +1 -0
- package/dist/provider/endpoints.cjs +43 -0
- package/dist/provider/endpoints.cjs.map +1 -0
- package/dist/provider/endpoints.d.cts +33 -0
- package/dist/provider/endpoints.d.cts.map +1 -0
- package/dist/provider/endpoints.d.mts +33 -0
- package/dist/provider/endpoints.d.mts.map +1 -0
- package/dist/provider/endpoints.mjs +39 -0
- package/dist/provider/endpoints.mjs.map +1 -0
- package/dist/provider/errors/errors.cjs +122 -0
- package/dist/provider/errors/errors.cjs.map +1 -0
- package/dist/provider/errors/errors.d.cts +62 -0
- package/dist/provider/errors/errors.d.cts.map +1 -0
- package/dist/provider/errors/errors.d.mts +62 -0
- package/dist/provider/errors/errors.d.mts.map +1 -0
- package/dist/provider/errors/errors.mjs +104 -0
- package/dist/provider/errors/errors.mjs.map +1 -0
- package/dist/provider/errors/messages.cjs +40 -0
- package/dist/provider/errors/messages.cjs.map +1 -0
- package/dist/provider/errors/messages.mjs +23 -0
- package/dist/provider/errors/messages.mjs.map +1 -0
- package/dist/provider/index.cjs +12 -0
- package/dist/provider/index.d.cts +11 -0
- package/dist/provider/index.d.mts +11 -0
- package/dist/provider/index.mjs +13 -0
- package/dist/provider/jsonrpc/index.cjs +1 -0
- package/dist/provider/jsonrpc/index.d.cts +1 -0
- package/dist/provider/jsonrpc/index.d.mts +1 -0
- package/dist/provider/jsonrpc/index.mjs +2 -0
- package/dist/provider/jsonrpc/jsonrpc.cjs +20 -0
- package/dist/provider/jsonrpc/jsonrpc.cjs.map +1 -0
- package/dist/provider/jsonrpc/jsonrpc.d.cts +16 -0
- package/dist/provider/jsonrpc/jsonrpc.d.cts.map +1 -0
- package/dist/provider/jsonrpc/jsonrpc.d.mts +16 -0
- package/dist/provider/jsonrpc/jsonrpc.d.mts.map +1 -0
- package/dist/provider/jsonrpc/jsonrpc.mjs +19 -0
- package/dist/provider/jsonrpc/jsonrpc.mjs.map +1 -0
- package/dist/provider/provider.cjs +130 -0
- package/dist/provider/provider.cjs.map +1 -0
- package/dist/provider/provider.d.cts +130 -0
- package/dist/provider/provider.d.cts.map +1 -0
- package/dist/provider/provider.d.mts +130 -0
- package/dist/provider/provider.d.mts.map +1 -0
- package/dist/provider/provider.mjs +130 -0
- package/dist/provider/provider.mjs.map +1 -0
- package/dist/provider/types/abci.cjs +6 -0
- package/dist/provider/types/abci.cjs.map +1 -0
- package/dist/provider/types/abci.d.cts +42 -0
- package/dist/provider/types/abci.d.cts.map +1 -0
- package/dist/provider/types/abci.d.mts +42 -0
- package/dist/provider/types/abci.d.mts.map +1 -0
- package/dist/provider/types/abci.mjs +6 -0
- package/dist/provider/types/abci.mjs.map +1 -0
- package/dist/provider/types/common.d.cts +186 -0
- package/dist/provider/types/common.d.cts.map +1 -0
- package/dist/provider/types/common.d.mts +186 -0
- package/dist/provider/types/common.d.mts.map +1 -0
- package/dist/provider/types/jsonrpc.d.cts +30 -0
- package/dist/provider/types/jsonrpc.d.cts.map +1 -0
- package/dist/provider/types/jsonrpc.d.mts +30 -0
- package/dist/provider/types/jsonrpc.d.mts.map +1 -0
- package/dist/provider/utility/adapters.cjs +241 -0
- package/dist/provider/utility/adapters.cjs.map +1 -0
- package/dist/provider/utility/adapters.d.cts +19 -0
- package/dist/provider/utility/adapters.d.cts.map +1 -0
- package/dist/provider/utility/adapters.d.mts +19 -0
- package/dist/provider/utility/adapters.d.mts.map +1 -0
- package/dist/provider/utility/adapters.mjs +231 -0
- package/dist/provider/utility/adapters.mjs.map +1 -0
- package/dist/provider/utility/errors.utility.cjs +38 -0
- package/dist/provider/utility/errors.utility.cjs.map +1 -0
- package/dist/provider/utility/errors.utility.mjs +38 -0
- package/dist/provider/utility/errors.utility.mjs.map +1 -0
- package/dist/provider/utility/index.cjs +3 -0
- package/dist/provider/utility/index.d.cts +3 -0
- package/dist/provider/utility/index.d.mts +3 -0
- package/dist/provider/utility/index.mjs +4 -0
- package/dist/provider/utility/provider.utility.cjs +122 -0
- package/dist/provider/utility/provider.utility.cjs.map +1 -0
- package/{bin/provider/utility/provider.utility.d.ts → dist/provider/utility/provider.utility.d.cts} +15 -10
- package/dist/provider/utility/provider.utility.d.cts.map +1 -0
- package/dist/provider/utility/provider.utility.d.mts +45 -0
- package/dist/provider/utility/provider.utility.d.mts.map +1 -0
- package/dist/provider/utility/provider.utility.mjs +116 -0
- package/dist/provider/utility/provider.utility.mjs.map +1 -0
- package/dist/provider/utility/requests.utility.cjs +75 -0
- package/dist/provider/utility/requests.utility.cjs.map +1 -0
- package/dist/provider/utility/requests.utility.d.cts +40 -0
- package/dist/provider/utility/requests.utility.d.cts.map +1 -0
- package/dist/provider/utility/requests.utility.d.mts +40 -0
- package/dist/provider/utility/requests.utility.d.mts.map +1 -0
- package/dist/provider/utility/requests.utility.mjs +68 -0
- package/dist/provider/utility/requests.utility.mjs.map +1 -0
- package/dist/provider/websocket/index.cjs +1 -0
- package/dist/provider/websocket/index.d.cts +1 -0
- package/dist/provider/websocket/index.d.mts +1 -0
- package/dist/provider/websocket/index.mjs +2 -0
- package/dist/provider/websocket/ws.cjs +27 -0
- package/dist/provider/websocket/ws.cjs.map +1 -0
- package/dist/provider/websocket/ws.d.cts +21 -0
- package/dist/provider/websocket/ws.d.cts.map +1 -0
- package/dist/provider/websocket/ws.d.mts +21 -0
- package/dist/provider/websocket/ws.d.mts.map +1 -0
- package/dist/provider/websocket/ws.mjs +26 -0
- package/dist/provider/websocket/ws.mjs.map +1 -0
- package/dist/services/index.cjs +1 -0
- package/dist/services/index.d.cts +2 -0
- package/dist/services/index.d.mts +2 -0
- package/dist/services/index.mjs +2 -0
- package/dist/services/rest/restService.cjs +16 -0
- package/dist/services/rest/restService.cjs.map +1 -0
- package/dist/services/rest/restService.d.cts +9 -0
- package/dist/services/rest/restService.d.cts.map +1 -0
- package/dist/services/rest/restService.d.mts +9 -0
- package/dist/services/rest/restService.d.mts.map +1 -0
- package/dist/services/rest/restService.mjs +14 -0
- package/dist/services/rest/restService.mjs.map +1 -0
- package/dist/services/rest/restService.types.d.cts +11 -0
- package/dist/services/rest/restService.types.d.cts.map +1 -0
- package/dist/services/rest/restService.types.d.mts +11 -0
- package/dist/services/rest/restService.types.d.mts.map +1 -0
- package/dist/wallet/index.cjs +8 -0
- package/dist/wallet/index.d.cts +7 -0
- package/dist/wallet/index.d.mts +7 -0
- package/dist/wallet/index.mjs +9 -0
- package/dist/wallet/key/index.cjs +1 -0
- package/dist/wallet/key/index.mjs +2 -0
- package/dist/wallet/key/key.cjs +46 -0
- package/dist/wallet/key/key.cjs.map +1 -0
- package/dist/wallet/key/key.d.cts +26 -0
- package/dist/wallet/key/key.d.cts.map +1 -0
- package/dist/wallet/key/key.d.mts +26 -0
- package/dist/wallet/key/key.d.mts.map +1 -0
- package/dist/wallet/key/key.mjs +45 -0
- package/dist/wallet/key/key.mjs.map +1 -0
- package/dist/wallet/ledger/index.cjs +1 -0
- package/dist/wallet/ledger/index.d.cts +1 -0
- package/dist/wallet/ledger/index.d.mts +1 -0
- package/dist/wallet/ledger/index.mjs +2 -0
- package/dist/wallet/ledger/ledger.cjs +49 -0
- package/dist/wallet/ledger/ledger.cjs.map +1 -0
- package/dist/wallet/ledger/ledger.d.cts +27 -0
- package/dist/wallet/ledger/ledger.d.cts.map +1 -0
- package/dist/wallet/ledger/ledger.d.mts +27 -0
- package/dist/wallet/ledger/ledger.d.mts.map +1 -0
- package/dist/wallet/ledger/ledger.mjs +48 -0
- package/dist/wallet/ledger/ledger.mjs.map +1 -0
- package/dist/wallet/signer.d.cts +33 -0
- package/dist/wallet/signer.d.cts.map +1 -0
- package/dist/wallet/signer.d.mts +33 -0
- package/dist/wallet/signer.d.mts.map +1 -0
- package/dist/wallet/types/sign.cjs +6 -0
- package/dist/wallet/types/sign.cjs.map +1 -0
- package/dist/wallet/types/sign.d.cts +20 -0
- package/dist/wallet/types/sign.d.cts.map +1 -0
- package/dist/wallet/types/sign.d.mts +20 -0
- package/dist/wallet/types/sign.d.mts.map +1 -0
- package/dist/wallet/types/sign.mjs +6 -0
- package/dist/wallet/types/sign.mjs.map +1 -0
- package/dist/wallet/types/wallet.d.cts +9 -0
- package/dist/wallet/types/wallet.d.cts.map +1 -0
- package/dist/wallet/types/wallet.d.mts +9 -0
- package/dist/wallet/types/wallet.d.mts.map +1 -0
- package/dist/wallet/utility/index.cjs +1 -0
- package/dist/wallet/utility/index.d.cts +1 -0
- package/dist/wallet/utility/index.d.mts +1 -0
- package/dist/wallet/utility/index.mjs +2 -0
- package/dist/wallet/utility/utility.cjs +83 -0
- package/dist/wallet/utility/utility.cjs.map +1 -0
- package/dist/wallet/utility/utility.d.cts +42 -0
- package/dist/wallet/utility/utility.d.cts.map +1 -0
- package/dist/wallet/utility/utility.d.mts +42 -0
- package/dist/wallet/utility/utility.d.mts.map +1 -0
- package/dist/wallet/utility/utility.mjs +75 -0
- package/dist/wallet/utility/utility.mjs.map +1 -0
- package/dist/wallet/wallet.cjs +223 -0
- package/dist/wallet/wallet.cjs.map +1 -0
- package/dist/wallet/wallet.d.cts +113 -0
- package/dist/wallet/wallet.d.cts.map +1 -0
- package/dist/wallet/wallet.d.mts +113 -0
- package/dist/wallet/wallet.d.mts.map +1 -0
- package/dist/wallet/wallet.mjs +222 -0
- package/dist/wallet/wallet.mjs.map +1 -0
- package/package.json +57 -38
- package/bin/index.d.ts +0 -4
- package/bin/index.js +0 -20
- package/bin/proto/google/protobuf/any.d.ts +0 -145
- package/bin/proto/google/protobuf/any.js +0 -113
- package/bin/proto/index.d.ts +0 -2
- package/bin/proto/index.js +0 -20
- package/bin/proto/tm2/abci.d.ts +0 -37
- package/bin/proto/tm2/abci.js +0 -277
- package/bin/proto/tm2/tx.d.ts +0 -52
- package/bin/proto/tm2/tx.js +0 -360
- package/bin/provider/endpoints.d.ts +0 -29
- package/bin/provider/endpoints.js +0 -37
- package/bin/provider/errors/errors.d.ts +0 -59
- package/bin/provider/errors/errors.js +0 -173
- package/bin/provider/errors/index.d.ts +0 -1
- package/bin/provider/errors/index.js +0 -17
- package/bin/provider/errors/messages.d.ts +0 -19
- package/bin/provider/errors/messages.js +0 -41
- package/bin/provider/index.d.ts +0 -7
- package/bin/provider/index.js +0 -23
- package/bin/provider/jsonrpc/index.d.ts +0 -1
- package/bin/provider/jsonrpc/index.js +0 -17
- package/bin/provider/jsonrpc/jsonrpc.d.ts +0 -31
- package/bin/provider/jsonrpc/jsonrpc.js +0 -327
- package/bin/provider/jsonrpc/jsonrpc.test.d.ts +0 -1
- package/bin/provider/jsonrpc/jsonrpc.test.js +0 -488
- package/bin/provider/provider.d.ts +0 -98
- package/bin/provider/provider.js +0 -2
- package/bin/provider/types/abci.d.ts +0 -39
- package/bin/provider/types/abci.js +0 -4
- package/bin/provider/types/common.d.ts +0 -184
- package/bin/provider/types/common.js +0 -3
- package/bin/provider/types/index.d.ts +0 -3
- package/bin/provider/types/index.js +0 -19
- package/bin/provider/types/jsonrpc.d.ts +0 -26
- package/bin/provider/types/jsonrpc.js +0 -2
- package/bin/provider/utility/errors.utility.d.ts +0 -11
- package/bin/provider/utility/errors.utility.js +0 -56
- package/bin/provider/utility/index.d.ts +0 -2
- package/bin/provider/utility/index.js +0 -18
- package/bin/provider/utility/provider.utility.js +0 -244
- package/bin/provider/utility/requests.utility.d.ts +0 -35
- package/bin/provider/utility/requests.utility.js +0 -80
- package/bin/provider/websocket/index.d.ts +0 -1
- package/bin/provider/websocket/index.js +0 -17
- package/bin/provider/websocket/ws.d.ts +0 -58
- package/bin/provider/websocket/ws.js +0 -415
- package/bin/provider/websocket/ws.test.d.ts +0 -1
- package/bin/provider/websocket/ws.test.js +0 -648
- package/bin/services/index.d.ts +0 -2
- package/bin/services/index.js +0 -18
- package/bin/services/rest/restService.d.ts +0 -4
- package/bin/services/rest/restService.js +0 -72
- package/bin/services/rest/restService.types.d.ts +0 -6
- package/bin/services/rest/restService.types.js +0 -2
- package/bin/wallet/index.d.ts +0 -6
- package/bin/wallet/index.js +0 -22
- package/bin/wallet/key/index.d.ts +0 -1
- package/bin/wallet/key/index.js +0 -17
- package/bin/wallet/key/key.d.ts +0 -21
- package/bin/wallet/key/key.js +0 -102
- package/bin/wallet/key/key.test.d.ts +0 -1
- package/bin/wallet/key/key.test.js +0 -121
- package/bin/wallet/ledger/index.d.ts +0 -1
- package/bin/wallet/ledger/index.js +0 -17
- package/bin/wallet/ledger/ledger.d.ts +0 -22
- package/bin/wallet/ledger/ledger.js +0 -109
- package/bin/wallet/signer.d.ts +0 -29
- package/bin/wallet/signer.js +0 -2
- package/bin/wallet/types/index.d.ts +0 -2
- package/bin/wallet/types/index.js +0 -18
- package/bin/wallet/types/sign.d.ts +0 -16
- package/bin/wallet/types/sign.js +0 -4
- package/bin/wallet/types/wallet.d.ts +0 -5
- package/bin/wallet/types/wallet.js +0 -2
- package/bin/wallet/utility/index.d.ts +0 -1
- package/bin/wallet/utility/index.js +0 -17
- package/bin/wallet/utility/utility.d.ts +0 -36
- package/bin/wallet/utility/utility.js +0 -117
- package/bin/wallet/wallet.d.ts +0 -102
- package/bin/wallet/wallet.js +0 -354
- package/bin/wallet/wallet.test.d.ts +0 -1
- package/bin/wallet/wallet.test.js +0 -352
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./utility"), exports);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { HdPath } from '@cosmjs/crypto';
|
|
2
|
-
/**
|
|
3
|
-
* Generates the HD path, for the specified index, in the form 'm/44'/118'/0'/0/i',
|
|
4
|
-
* where 'i' is the account index
|
|
5
|
-
* @param {number} [index=0] the account index
|
|
6
|
-
*/
|
|
7
|
-
export declare const generateHDPath: (index?: number) => HdPath;
|
|
8
|
-
/**
|
|
9
|
-
* Generates random entropy of the specified size (in B)
|
|
10
|
-
* @param {number} [size=32] the entropy size in bytes
|
|
11
|
-
*/
|
|
12
|
-
export declare const generateEntropy: (size?: number) => Uint8Array;
|
|
13
|
-
interface keyPair {
|
|
14
|
-
privateKey: Uint8Array;
|
|
15
|
-
publicKey: Uint8Array;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Generates a new Secp256k1 key-pair using
|
|
19
|
-
* the provided English mnemonic and account index
|
|
20
|
-
* @param {string} mnemonic the English mnemonic
|
|
21
|
-
* @param {number} [accountIndex=0] the account index
|
|
22
|
-
*/
|
|
23
|
-
export declare const generateKeyPair: (mnemonic: string, accountIndex?: number) => Promise<keyPair>;
|
|
24
|
-
export declare const defaultAddressPrefix = "g";
|
|
25
|
-
/**
|
|
26
|
-
* Encodes a string into a Uint8Array
|
|
27
|
-
* @param {string} str the string to be encoded
|
|
28
|
-
*/
|
|
29
|
-
export declare const stringToUTF8: (str: string) => Uint8Array;
|
|
30
|
-
/**
|
|
31
|
-
* Escapes <,>,& in string.
|
|
32
|
-
* Golang's json marshaller escapes <,>,& by default.
|
|
33
|
-
* https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/encoding/json/encode.go;l=46-53
|
|
34
|
-
*/
|
|
35
|
-
export declare function encodeCharacterSet(data: string): string;
|
|
36
|
-
export {};
|
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.stringToUTF8 = exports.defaultAddressPrefix = exports.generateKeyPair = exports.generateEntropy = exports.generateHDPath = void 0;
|
|
43
|
-
exports.encodeCharacterSet = encodeCharacterSet;
|
|
44
|
-
var crypto_1 = require("@cosmjs/crypto");
|
|
45
|
-
var crypto_2 = __importDefault(require("crypto"));
|
|
46
|
-
/**
|
|
47
|
-
* Generates the HD path, for the specified index, in the form 'm/44'/118'/0'/0/i',
|
|
48
|
-
* where 'i' is the account index
|
|
49
|
-
* @param {number} [index=0] the account index
|
|
50
|
-
*/
|
|
51
|
-
var generateHDPath = function (index) {
|
|
52
|
-
return [
|
|
53
|
-
crypto_1.Slip10RawIndex.hardened(44),
|
|
54
|
-
crypto_1.Slip10RawIndex.hardened(118),
|
|
55
|
-
crypto_1.Slip10RawIndex.hardened(0),
|
|
56
|
-
crypto_1.Slip10RawIndex.normal(0),
|
|
57
|
-
crypto_1.Slip10RawIndex.normal(index ? index : 0),
|
|
58
|
-
];
|
|
59
|
-
};
|
|
60
|
-
exports.generateHDPath = generateHDPath;
|
|
61
|
-
/**
|
|
62
|
-
* Generates random entropy of the specified size (in B)
|
|
63
|
-
* @param {number} [size=32] the entropy size in bytes
|
|
64
|
-
*/
|
|
65
|
-
var generateEntropy = function (size) {
|
|
66
|
-
var array = new Uint8Array(size ? size : 32);
|
|
67
|
-
// Generate random data
|
|
68
|
-
crypto_2.default.randomFillSync(array);
|
|
69
|
-
return array;
|
|
70
|
-
};
|
|
71
|
-
exports.generateEntropy = generateEntropy;
|
|
72
|
-
/**
|
|
73
|
-
* Generates a new Secp256k1 key-pair using
|
|
74
|
-
* the provided English mnemonic and account index
|
|
75
|
-
* @param {string} mnemonic the English mnemonic
|
|
76
|
-
* @param {number} [accountIndex=0] the account index
|
|
77
|
-
*/
|
|
78
|
-
var generateKeyPair = function (mnemonic, accountIndex) { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
-
var seed, privateKey, publicKey;
|
|
80
|
-
return __generator(this, function (_a) {
|
|
81
|
-
switch (_a.label) {
|
|
82
|
-
case 0: return [4 /*yield*/, crypto_1.Bip39.mnemonicToSeed(new crypto_1.EnglishMnemonic(mnemonic))];
|
|
83
|
-
case 1:
|
|
84
|
-
seed = _a.sent();
|
|
85
|
-
privateKey = crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, seed, (0, exports.generateHDPath)(accountIndex)).privkey;
|
|
86
|
-
return [4 /*yield*/, crypto_1.Secp256k1.makeKeypair(privateKey)];
|
|
87
|
-
case 2:
|
|
88
|
-
publicKey = (_a.sent()).pubkey;
|
|
89
|
-
return [2 /*return*/, {
|
|
90
|
-
publicKey: publicKey,
|
|
91
|
-
privateKey: privateKey,
|
|
92
|
-
}];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); };
|
|
96
|
-
exports.generateKeyPair = generateKeyPair;
|
|
97
|
-
// Address prefix for TM2 networks
|
|
98
|
-
exports.defaultAddressPrefix = 'g';
|
|
99
|
-
/**
|
|
100
|
-
* Encodes a string into a Uint8Array
|
|
101
|
-
* @param {string} str the string to be encoded
|
|
102
|
-
*/
|
|
103
|
-
var stringToUTF8 = function (str) {
|
|
104
|
-
return new TextEncoder().encode(str);
|
|
105
|
-
};
|
|
106
|
-
exports.stringToUTF8 = stringToUTF8;
|
|
107
|
-
/**
|
|
108
|
-
* Escapes <,>,& in string.
|
|
109
|
-
* Golang's json marshaller escapes <,>,& by default.
|
|
110
|
-
* https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/encoding/json/encode.go;l=46-53
|
|
111
|
-
*/
|
|
112
|
-
function encodeCharacterSet(data) {
|
|
113
|
-
return data
|
|
114
|
-
.replace(/</g, '\\u003c')
|
|
115
|
-
.replace(/>/g, '\\u003e')
|
|
116
|
-
.replace(/&/g, '\\u0026');
|
|
117
|
-
}
|
package/bin/wallet/wallet.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { BroadcastTransactionMap, Provider } from '../provider';
|
|
2
|
-
import { Signer } from './signer';
|
|
3
|
-
import { LedgerConnector } from '@cosmjs/ledger-amino';
|
|
4
|
-
import { Any, Tx } from '../proto';
|
|
5
|
-
import { AccountWalletOption, CreateWalletOptions } from './types';
|
|
6
|
-
/**
|
|
7
|
-
* Wallet is a single account abstraction
|
|
8
|
-
* that can interact with the blockchain
|
|
9
|
-
*/
|
|
10
|
-
export declare class Wallet {
|
|
11
|
-
protected provider: Provider;
|
|
12
|
-
protected signer: Signer;
|
|
13
|
-
/**
|
|
14
|
-
* Connects the wallet to the specified {@link Provider}
|
|
15
|
-
* @param {Provider} provider the active {@link Provider}, if any
|
|
16
|
-
*/
|
|
17
|
-
connect: (provider: Provider) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Generates a private key-based wallet, using a random seed
|
|
20
|
-
* @param {AccountWalletOption} options the account options
|
|
21
|
-
*/
|
|
22
|
-
static createRandom: (options?: AccountWalletOption) => Promise<Wallet>;
|
|
23
|
-
/**
|
|
24
|
-
* Generates a custom signer-based wallet
|
|
25
|
-
* @param {Signer} signer the custom signer implementing the Signer interface
|
|
26
|
-
* @param {CreateWalletOptions} options the wallet generation options
|
|
27
|
-
*/
|
|
28
|
-
static fromSigner: (signer: Signer) => Promise<Wallet>;
|
|
29
|
-
/**
|
|
30
|
-
* Generates a bip39 mnemonic-based wallet
|
|
31
|
-
* @param {string} mnemonic the bip39 mnemonic
|
|
32
|
-
* @param {CreateWalletOptions} options the wallet generation options
|
|
33
|
-
*/
|
|
34
|
-
static fromMnemonic: (mnemonic: string, options?: CreateWalletOptions) => Promise<Wallet>;
|
|
35
|
-
/**
|
|
36
|
-
* Generates a private key-based wallet
|
|
37
|
-
* @param {string} privateKey the private key
|
|
38
|
-
* @param {AccountWalletOption} options the account options
|
|
39
|
-
*/
|
|
40
|
-
static fromPrivateKey: (privateKey: Uint8Array, options?: AccountWalletOption) => Promise<Wallet>;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a Ledger-based wallet
|
|
43
|
-
* @param {LedgerConnector} connector the Ledger device connector
|
|
44
|
-
* @param {CreateWalletOptions} options the wallet generation options
|
|
45
|
-
*/
|
|
46
|
-
static fromLedger: (connector: LedgerConnector, options?: CreateWalletOptions) => Wallet;
|
|
47
|
-
/**
|
|
48
|
-
* Fetches the address associated with the wallet
|
|
49
|
-
*/
|
|
50
|
-
getAddress: () => Promise<string>;
|
|
51
|
-
/**
|
|
52
|
-
* Fetches the account sequence for the wallet
|
|
53
|
-
* @param {number} [height=latest] the block height
|
|
54
|
-
*/
|
|
55
|
-
getAccountSequence: (height?: number) => Promise<number>;
|
|
56
|
-
/**
|
|
57
|
-
* Fetches the account number for the wallet. Errors out if the
|
|
58
|
-
* account is not initialized
|
|
59
|
-
* @param {number} [height=latest] the block height
|
|
60
|
-
*/
|
|
61
|
-
getAccountNumber: (height?: number) => Promise<number>;
|
|
62
|
-
/**
|
|
63
|
-
* Fetches the account balance for the specific denomination
|
|
64
|
-
* @param {string} [denomination=ugnot] the fund denomination
|
|
65
|
-
*/
|
|
66
|
-
getBalance: (denomination?: string) => Promise<number>;
|
|
67
|
-
/**
|
|
68
|
-
* Fetches the current (recommended) average gas price
|
|
69
|
-
*/
|
|
70
|
-
getGasPrice: () => Promise<number>;
|
|
71
|
-
/**
|
|
72
|
-
* Estimates the gas limit for the transaction
|
|
73
|
-
* @param {Tx} tx the transaction that needs estimating
|
|
74
|
-
*/
|
|
75
|
-
estimateGas: (tx: Tx) => Promise<number>;
|
|
76
|
-
/**
|
|
77
|
-
* Returns the connected provider, if any
|
|
78
|
-
*/
|
|
79
|
-
getProvider: () => Provider;
|
|
80
|
-
/**
|
|
81
|
-
* Generates a transaction signature, and appends it to the transaction
|
|
82
|
-
* @param {Tx} tx the transaction to be signed
|
|
83
|
-
* @param {(messages: Any[]) => any[]} decodeTxMessages tx message decode callback
|
|
84
|
-
* that should expand the concrete message fields into an object. Required because
|
|
85
|
-
* the transaction sign bytes are generated using sorted JSON, which requires
|
|
86
|
-
* encoded message values to be decoded for sorting
|
|
87
|
-
*/
|
|
88
|
-
signTransaction: (tx: Tx, decodeTxMessages: (messages: Any[]) => any[]) => Promise<Tx>;
|
|
89
|
-
/**
|
|
90
|
-
* Encodes and sends the transaction. If the type of endpoint
|
|
91
|
-
* is a broadcast commit, waits for the transaction to be committed to the chain.
|
|
92
|
-
* The transaction needs to be signed beforehand.
|
|
93
|
-
* Returns the transaction hash (base-64)
|
|
94
|
-
* @param {Tx} tx the signed transaction
|
|
95
|
-
* @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)
|
|
96
|
-
*/
|
|
97
|
-
sendTransaction<K extends keyof BroadcastTransactionMap>(tx: Tx, endpoint: K): Promise<BroadcastTransactionMap[K]['result']>;
|
|
98
|
-
/**
|
|
99
|
-
* Returns the associated signer
|
|
100
|
-
*/
|
|
101
|
-
getSigner: () => Signer;
|
|
102
|
-
}
|
package/bin/wallet/wallet.js
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
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);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
-
exports.Wallet = void 0;
|
|
60
|
-
var provider_1 = require("../provider");
|
|
61
|
-
var ledger_1 = require("./ledger");
|
|
62
|
-
var key_1 = require("./key");
|
|
63
|
-
var crypto_1 = require("@cosmjs/crypto");
|
|
64
|
-
var utility_1 = require("./utility");
|
|
65
|
-
var bip39_1 = require("@cosmjs/crypto/build/bip39");
|
|
66
|
-
var proto_1 = require("../proto");
|
|
67
|
-
var types_1 = require("./types");
|
|
68
|
-
var signdoc_1 = require("@cosmjs/amino/build/signdoc");
|
|
69
|
-
/**
|
|
70
|
-
* Wallet is a single account abstraction
|
|
71
|
-
* that can interact with the blockchain
|
|
72
|
-
*/
|
|
73
|
-
var Wallet = /** @class */ (function () {
|
|
74
|
-
function Wallet() {
|
|
75
|
-
var _this = this;
|
|
76
|
-
/**
|
|
77
|
-
* Connects the wallet to the specified {@link Provider}
|
|
78
|
-
* @param {Provider} provider the active {@link Provider}, if any
|
|
79
|
-
*/
|
|
80
|
-
this.connect = function (provider) {
|
|
81
|
-
_this.provider = provider;
|
|
82
|
-
};
|
|
83
|
-
// Account manipulation //
|
|
84
|
-
/**
|
|
85
|
-
* Fetches the address associated with the wallet
|
|
86
|
-
*/
|
|
87
|
-
this.getAddress = function () {
|
|
88
|
-
return _this.signer.getAddress();
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Fetches the account sequence for the wallet
|
|
92
|
-
* @param {number} [height=latest] the block height
|
|
93
|
-
*/
|
|
94
|
-
this.getAccountSequence = function (height) { return __awaiter(_this, void 0, void 0, function () {
|
|
95
|
-
var address;
|
|
96
|
-
return __generator(this, function (_b) {
|
|
97
|
-
switch (_b.label) {
|
|
98
|
-
case 0:
|
|
99
|
-
if (!this.provider) {
|
|
100
|
-
throw new Error('provider not connected');
|
|
101
|
-
}
|
|
102
|
-
return [4 /*yield*/, this.getAddress()];
|
|
103
|
-
case 1:
|
|
104
|
-
address = _b.sent();
|
|
105
|
-
return [2 /*return*/, this.provider.getAccountSequence(address, height)];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}); };
|
|
109
|
-
/**
|
|
110
|
-
* Fetches the account number for the wallet. Errors out if the
|
|
111
|
-
* account is not initialized
|
|
112
|
-
* @param {number} [height=latest] the block height
|
|
113
|
-
*/
|
|
114
|
-
this.getAccountNumber = function (height) { return __awaiter(_this, void 0, void 0, function () {
|
|
115
|
-
var address;
|
|
116
|
-
return __generator(this, function (_b) {
|
|
117
|
-
switch (_b.label) {
|
|
118
|
-
case 0:
|
|
119
|
-
if (!this.provider) {
|
|
120
|
-
throw new Error('provider not connected');
|
|
121
|
-
}
|
|
122
|
-
return [4 /*yield*/, this.getAddress()];
|
|
123
|
-
case 1:
|
|
124
|
-
address = _b.sent();
|
|
125
|
-
return [2 /*return*/, this.provider.getAccountNumber(address, height)];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}); };
|
|
129
|
-
/**
|
|
130
|
-
* Fetches the account balance for the specific denomination
|
|
131
|
-
* @param {string} [denomination=ugnot] the fund denomination
|
|
132
|
-
*/
|
|
133
|
-
this.getBalance = function (denomination) { return __awaiter(_this, void 0, void 0, function () {
|
|
134
|
-
var address;
|
|
135
|
-
return __generator(this, function (_b) {
|
|
136
|
-
switch (_b.label) {
|
|
137
|
-
case 0:
|
|
138
|
-
if (!this.provider) {
|
|
139
|
-
throw new Error('provider not connected');
|
|
140
|
-
}
|
|
141
|
-
return [4 /*yield*/, this.getAddress()];
|
|
142
|
-
case 1:
|
|
143
|
-
address = _b.sent();
|
|
144
|
-
return [2 /*return*/, this.provider.getBalance(address, denomination ? denomination : 'ugnot')];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}); };
|
|
148
|
-
/**
|
|
149
|
-
* Fetches the current (recommended) average gas price
|
|
150
|
-
*/
|
|
151
|
-
this.getGasPrice = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
152
|
-
return __generator(this, function (_b) {
|
|
153
|
-
if (!this.provider) {
|
|
154
|
-
throw new Error('provider not connected');
|
|
155
|
-
}
|
|
156
|
-
return [2 /*return*/, this.provider.getGasPrice()];
|
|
157
|
-
});
|
|
158
|
-
}); };
|
|
159
|
-
/**
|
|
160
|
-
* Estimates the gas limit for the transaction
|
|
161
|
-
* @param {Tx} tx the transaction that needs estimating
|
|
162
|
-
*/
|
|
163
|
-
this.estimateGas = function (tx) { return __awaiter(_this, void 0, void 0, function () {
|
|
164
|
-
return __generator(this, function (_b) {
|
|
165
|
-
if (!this.provider) {
|
|
166
|
-
throw new Error('provider not connected');
|
|
167
|
-
}
|
|
168
|
-
return [2 /*return*/, this.provider.estimateGas(tx)];
|
|
169
|
-
});
|
|
170
|
-
}); };
|
|
171
|
-
/**
|
|
172
|
-
* Returns the connected provider, if any
|
|
173
|
-
*/
|
|
174
|
-
this.getProvider = function () {
|
|
175
|
-
return _this.provider;
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Generates a transaction signature, and appends it to the transaction
|
|
179
|
-
* @param {Tx} tx the transaction to be signed
|
|
180
|
-
* @param {(messages: Any[]) => any[]} decodeTxMessages tx message decode callback
|
|
181
|
-
* that should expand the concrete message fields into an object. Required because
|
|
182
|
-
* the transaction sign bytes are generated using sorted JSON, which requires
|
|
183
|
-
* encoded message values to be decoded for sorting
|
|
184
|
-
*/
|
|
185
|
-
this.signTransaction = function (tx, decodeTxMessages) { return __awaiter(_this, void 0, void 0, function () {
|
|
186
|
-
var status, chainID, address, accountNumber, accountSequence, publicKey, signPayload, signBytes, wrappedKey, txSignature;
|
|
187
|
-
var _b;
|
|
188
|
-
return __generator(this, function (_c) {
|
|
189
|
-
switch (_c.label) {
|
|
190
|
-
case 0:
|
|
191
|
-
if (!this.provider) {
|
|
192
|
-
throw new Error('provider not connected');
|
|
193
|
-
}
|
|
194
|
-
// Make sure the tx fee is initialized
|
|
195
|
-
if (!tx.fee) {
|
|
196
|
-
throw new Error('invalid transaction fee provided');
|
|
197
|
-
}
|
|
198
|
-
return [4 /*yield*/, this.provider.getStatus()];
|
|
199
|
-
case 1:
|
|
200
|
-
status = _c.sent();
|
|
201
|
-
chainID = status.node_info.network;
|
|
202
|
-
return [4 /*yield*/, this.getAddress()];
|
|
203
|
-
case 2:
|
|
204
|
-
address = _c.sent();
|
|
205
|
-
return [4 /*yield*/, this.provider.getAccountNumber(address)];
|
|
206
|
-
case 3:
|
|
207
|
-
accountNumber = _c.sent();
|
|
208
|
-
return [4 /*yield*/, this.provider.getAccountSequence(address)];
|
|
209
|
-
case 4:
|
|
210
|
-
accountSequence = _c.sent();
|
|
211
|
-
return [4 /*yield*/, this.signer.getPublicKey()];
|
|
212
|
-
case 5:
|
|
213
|
-
publicKey = _c.sent();
|
|
214
|
-
signPayload = {
|
|
215
|
-
chain_id: chainID,
|
|
216
|
-
account_number: accountNumber.toString(10),
|
|
217
|
-
sequence: accountSequence.toString(10),
|
|
218
|
-
fee: {
|
|
219
|
-
gas_fee: tx.fee.gas_fee,
|
|
220
|
-
gas_wanted: tx.fee.gas_wanted.toString(10),
|
|
221
|
-
},
|
|
222
|
-
msgs: decodeTxMessages(tx.messages), // unrolled message objects
|
|
223
|
-
memo: tx.memo,
|
|
224
|
-
};
|
|
225
|
-
signBytes = (0, utility_1.stringToUTF8)((0, utility_1.encodeCharacterSet)((0, signdoc_1.sortedJsonStringify)(signPayload)));
|
|
226
|
-
wrappedKey = {
|
|
227
|
-
key: publicKey,
|
|
228
|
-
};
|
|
229
|
-
_b = {
|
|
230
|
-
pub_key: {
|
|
231
|
-
type_url: types_1.Secp256k1PubKeyType,
|
|
232
|
-
value: proto_1.PubKeySecp256k1.encode(wrappedKey).finish(),
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
return [4 /*yield*/, this.getSigner().signData(signBytes)];
|
|
236
|
-
case 6:
|
|
237
|
-
txSignature = (_b.signature = _c.sent(),
|
|
238
|
-
_b);
|
|
239
|
-
// Append the signature
|
|
240
|
-
return [2 /*return*/, __assign(__assign({}, tx), { signatures: __spreadArray(__spreadArray([], tx.signatures, true), [txSignature], false) })];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}); };
|
|
244
|
-
/**
|
|
245
|
-
* Returns the associated signer
|
|
246
|
-
*/
|
|
247
|
-
this.getSigner = function () {
|
|
248
|
-
return _this.signer;
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Encodes and sends the transaction. If the type of endpoint
|
|
253
|
-
* is a broadcast commit, waits for the transaction to be committed to the chain.
|
|
254
|
-
* The transaction needs to be signed beforehand.
|
|
255
|
-
* Returns the transaction hash (base-64)
|
|
256
|
-
* @param {Tx} tx the signed transaction
|
|
257
|
-
* @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)
|
|
258
|
-
*/
|
|
259
|
-
Wallet.prototype.sendTransaction = function (tx, endpoint) {
|
|
260
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
-
var encodedTx;
|
|
262
|
-
return __generator(this, function (_b) {
|
|
263
|
-
if (!this.provider) {
|
|
264
|
-
throw new Error('provider not connected');
|
|
265
|
-
}
|
|
266
|
-
encodedTx = (0, provider_1.uint8ArrayToBase64)(proto_1.Tx.encode(tx).finish());
|
|
267
|
-
// Send the encoded transaction
|
|
268
|
-
return [2 /*return*/, this.provider.sendTransaction(encodedTx, endpoint)];
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
var _a;
|
|
273
|
-
_a = Wallet;
|
|
274
|
-
// Wallet initialization //
|
|
275
|
-
/**
|
|
276
|
-
* Generates a private key-based wallet, using a random seed
|
|
277
|
-
* @param {AccountWalletOption} options the account options
|
|
278
|
-
*/
|
|
279
|
-
Wallet.createRandom = function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
280
|
-
var _b, publicKey, privateKey, wallet;
|
|
281
|
-
return __generator(_a, function (_c) {
|
|
282
|
-
switch (_c.label) {
|
|
283
|
-
case 0: return [4 /*yield*/, (0, utility_1.generateKeyPair)((0, bip39_1.entropyToMnemonic)((0, utility_1.generateEntropy)()), 0)];
|
|
284
|
-
case 1:
|
|
285
|
-
_b = _c.sent(), publicKey = _b.publicKey, privateKey = _b.privateKey;
|
|
286
|
-
wallet = new _a();
|
|
287
|
-
wallet.signer = new key_1.KeySigner(privateKey, crypto_1.Secp256k1.compressPubkey(publicKey), options === null || options === void 0 ? void 0 : options.addressPrefix);
|
|
288
|
-
return [2 /*return*/, wallet];
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}); };
|
|
292
|
-
/**
|
|
293
|
-
* Generates a custom signer-based wallet
|
|
294
|
-
* @param {Signer} signer the custom signer implementing the Signer interface
|
|
295
|
-
* @param {CreateWalletOptions} options the wallet generation options
|
|
296
|
-
*/
|
|
297
|
-
Wallet.fromSigner = function (signer) { return __awaiter(void 0, void 0, void 0, function () {
|
|
298
|
-
var wallet;
|
|
299
|
-
return __generator(_a, function (_b) {
|
|
300
|
-
wallet = new _a();
|
|
301
|
-
wallet.signer = signer;
|
|
302
|
-
return [2 /*return*/, wallet];
|
|
303
|
-
});
|
|
304
|
-
}); };
|
|
305
|
-
/**
|
|
306
|
-
* Generates a bip39 mnemonic-based wallet
|
|
307
|
-
* @param {string} mnemonic the bip39 mnemonic
|
|
308
|
-
* @param {CreateWalletOptions} options the wallet generation options
|
|
309
|
-
*/
|
|
310
|
-
Wallet.fromMnemonic = function (mnemonic, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
311
|
-
var _b, publicKey, privateKey, wallet;
|
|
312
|
-
return __generator(_a, function (_c) {
|
|
313
|
-
switch (_c.label) {
|
|
314
|
-
case 0: return [4 /*yield*/, (0, utility_1.generateKeyPair)(mnemonic, options === null || options === void 0 ? void 0 : options.accountIndex)];
|
|
315
|
-
case 1:
|
|
316
|
-
_b = _c.sent(), publicKey = _b.publicKey, privateKey = _b.privateKey;
|
|
317
|
-
wallet = new _a();
|
|
318
|
-
wallet.signer = new key_1.KeySigner(privateKey, crypto_1.Secp256k1.compressPubkey(publicKey), options === null || options === void 0 ? void 0 : options.addressPrefix);
|
|
319
|
-
return [2 /*return*/, wallet];
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
}); };
|
|
323
|
-
/**
|
|
324
|
-
* Generates a private key-based wallet
|
|
325
|
-
* @param {string} privateKey the private key
|
|
326
|
-
* @param {AccountWalletOption} options the account options
|
|
327
|
-
*/
|
|
328
|
-
Wallet.fromPrivateKey = function (privateKey, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
329
|
-
var publicKey, wallet;
|
|
330
|
-
return __generator(_a, function (_b) {
|
|
331
|
-
switch (_b.label) {
|
|
332
|
-
case 0: return [4 /*yield*/, crypto_1.Secp256k1.makeKeypair(privateKey)];
|
|
333
|
-
case 1:
|
|
334
|
-
publicKey = (_b.sent()).pubkey;
|
|
335
|
-
wallet = new _a();
|
|
336
|
-
wallet.signer = new key_1.KeySigner(privateKey, crypto_1.Secp256k1.compressPubkey(publicKey), options === null || options === void 0 ? void 0 : options.addressPrefix);
|
|
337
|
-
return [2 /*return*/, wallet];
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}); };
|
|
341
|
-
/**
|
|
342
|
-
* Creates a Ledger-based wallet
|
|
343
|
-
* @param {LedgerConnector} connector the Ledger device connector
|
|
344
|
-
* @param {CreateWalletOptions} options the wallet generation options
|
|
345
|
-
*/
|
|
346
|
-
Wallet.fromLedger = function (connector, options) {
|
|
347
|
-
var _b;
|
|
348
|
-
var wallet = new _a();
|
|
349
|
-
wallet.signer = new ledger_1.LedgerSigner(connector, (_b = options === null || options === void 0 ? void 0 : options.accountIndex) !== null && _b !== void 0 ? _b : 0, options === null || options === void 0 ? void 0 : options.addressPrefix);
|
|
350
|
-
return wallet;
|
|
351
|
-
};
|
|
352
|
-
return Wallet;
|
|
353
|
-
}());
|
|
354
|
-
exports.Wallet = Wallet;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|