@injectivelabs/sdk-ts 1.0.139 → 1.0.140
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/core/transaction/client/TxClient.js +1 -1
- package/dist/core/transaction/client/TxClient.js.map +1 -1
- package/dist/core/transaction/tx.d.ts +0 -53
- package/dist/core/transaction/tx.d.ts.map +1 -1
- package/dist/core/transaction/tx.js +1 -103
- package/dist/core/transaction/tx.js.map +1 -1
- package/dist/core/transaction/types/index.d.ts +5 -0
- package/dist/core/transaction/types/index.d.ts.map +1 -1
- package/dist/core/transaction/types/index.js.map +1 -1
- package/dist/core/transaction/utils/helpers.d.ts +75 -0
- package/dist/core/transaction/utils/helpers.d.ts.map +1 -0
- package/dist/core/transaction/utils/helpers.js +134 -0
- package/dist/core/transaction/utils/helpers.js.map +1 -0
- package/dist/core/transaction/utils/index.d.ts +1 -8
- package/dist/core/transaction/utils/index.d.ts.map +1 -1
- package/dist/core/transaction/utils/index.js +15 -16
- package/dist/core/transaction/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/core/transaction/utils/crypto.d.ts +0 -4
- package/dist/core/transaction/utils/crypto.d.ts.map +0 -1
- package/dist/core/transaction/utils/crypto.js +0 -20
- package/dist/core/transaction/utils/crypto.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TxClient = void 0;
|
|
4
4
|
const tx_pb_1 = require("@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb");
|
|
5
|
-
const crypto_1 = require("
|
|
5
|
+
const crypto_1 = require("../../../utils/crypto");
|
|
6
6
|
class TxClient {
|
|
7
7
|
/**
|
|
8
8
|
* Encode a transaction to base64-encoded protobuf
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxClient.js","sourceRoot":"","sources":["../../../../src/core/transaction/client/TxClient.ts"],"names":[],"mappings":";;;AAAA,4EAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"TxClient.js","sourceRoot":"","sources":["../../../../src/core/transaction/client/TxClient.ts"],"names":[],"mappings":";;;AAAA,4EAAwE;AACxE,kDAAiD;AAEjD,MAAa,QAAQ;IACnB;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,EAAS;QAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC7D,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,SAAiB;QACpC,OAAO,aAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAA;IAClE,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAI,CAAC,EAAS;QAC1B,OAAO,IAAA,kBAAS,EAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IACvC,CAAC;CACF;AAxBD,4BAwBC"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { StdFee } from '@cosmjs/amino';
|
|
2
2
|
import { TxBody, SignDoc, SignerInfo, AuthInfo, Fee, TxRaw } from '@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb';
|
|
3
3
|
import { SignModeMap } from '@injectivelabs/chain-api/cosmos/tx/signing/v1beta1/signing_pb';
|
|
4
|
-
import { ExtensionOptionsWeb3Tx } from '@injectivelabs/chain-api/injective/types/v1beta1/tx_ext_pb';
|
|
5
|
-
import { DirectSignResponse } from '@cosmjs/proto-signing';
|
|
6
|
-
import { EthereumChainId } from '@injectivelabs/ts-types';
|
|
7
|
-
import { Msgs } from '../modules';
|
|
8
|
-
import { SignDoc as CosmosSignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
|
|
9
4
|
export declare type MsgArg = {
|
|
10
5
|
type: string;
|
|
11
6
|
message: any;
|
|
@@ -88,52 +83,4 @@ export declare const createSigDoc: ({ bodyBytes, authInfoBytes, chainId, account
|
|
|
88
83
|
* @returns {CreateTransactionResult} result
|
|
89
84
|
*/
|
|
90
85
|
export declare const createTransaction: ({ memo, pubKey, chainId, message, sequence, fee, signMode, accountNumber, timeoutHeight, }: CreateTransactionArgs) => CreateTransactionResult;
|
|
91
|
-
/**
|
|
92
|
-
* Used when we want to pass a Msg class instead of the {type, message}
|
|
93
|
-
* object of the Message (using the toDirectSign() method)
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
export declare const createTransactionFromMsg: (params: Omit<CreateTransactionArgs, 'message'> & {
|
|
97
|
-
message: Msgs | Msgs[];
|
|
98
|
-
}) => CreateTransactionResult;
|
|
99
|
-
/**
|
|
100
|
-
* Used when we get a DirectSignResponse from
|
|
101
|
-
* Cosmos native wallets like Keplr, Leap, etc after
|
|
102
|
-
* the TxRaw has been signed.
|
|
103
|
-
*
|
|
104
|
-
* The reason why we need to create a new TxRaw and
|
|
105
|
-
* not use the one that we passed to signing is that the users
|
|
106
|
-
* can change the gas fees and that will alter the original
|
|
107
|
-
* TxRaw which will cause signature miss match if we broadcast
|
|
108
|
-
* that transaction on chain
|
|
109
|
-
* @returns
|
|
110
|
-
*/
|
|
111
|
-
export declare const createTxRawFromSigResponse: (signatureResponse: DirectSignResponse) => TxRaw;
|
|
112
|
-
/**
|
|
113
|
-
* Used when we don't have account details and block details
|
|
114
|
-
* and we pass the message and the user's address only
|
|
115
|
-
* @returns
|
|
116
|
-
*/
|
|
117
|
-
export declare const createTransactionForAddressAndMsg: (params: Omit<CreateTransactionArgs, 'message' | 'sequence' | 'pubKey' | 'accountNumber'> & {
|
|
118
|
-
message: Msgs | Msgs[];
|
|
119
|
-
address: string;
|
|
120
|
-
pubKey?: string;
|
|
121
|
-
endpoint: string;
|
|
122
|
-
}) => Promise<CreateTransactionResult>;
|
|
123
|
-
export declare const createCosmosSignDocFromTransaction: (args: CreateTransactionArgs) => {
|
|
124
|
-
cosmosSignDoc: CosmosSignDoc;
|
|
125
|
-
txRaw: TxRaw;
|
|
126
|
-
signDoc: SignDoc;
|
|
127
|
-
accountNumber: number;
|
|
128
|
-
bodyBytes: Uint8Array;
|
|
129
|
-
authInfoBytes: Uint8Array;
|
|
130
|
-
signBytes: Uint8Array;
|
|
131
|
-
signHashedBytes: Uint8Array;
|
|
132
|
-
};
|
|
133
|
-
export declare const createTxRawEIP712: (txRaw: TxRaw, extension: ExtensionOptionsWeb3Tx) => TxRaw;
|
|
134
|
-
export declare const createWeb3Extension: ({ ethereumChainId, feePayer, feePayerSig, }: {
|
|
135
|
-
ethereumChainId: EthereumChainId;
|
|
136
|
-
feePayer?: string | undefined;
|
|
137
|
-
feePayerSig?: Uint8Array | undefined;
|
|
138
|
-
}) => ExtensionOptionsWeb3Tx;
|
|
139
86
|
//# sourceMappingURL=tx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../src/core/transaction/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,EACL,MAAM,EACN,OAAO,EACP,UAAU,EACV,QAAQ,EAER,GAAG,EACH,KAAK,EACN,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAEL,WAAW,EACZ,MAAM,+DAA+D,CAAA;
|
|
1
|
+
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../src/core/transaction/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,EACL,MAAM,EACN,OAAO,EACP,UAAU,EACV,QAAQ,EAER,GAAG,EACH,KAAK,EACN,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAEL,WAAW,EACZ,MAAM,+DAA+D,CAAA;AAOtE,oBAAY,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,GAAG,CAAA;CACb,CAAA;AAED,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;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,+FAU3B,qBAAqB,KAAG,uBA0C1B,CAAA"}
|
|
@@ -1,30 +1,17 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
6
|
+
exports.createTransaction = exports.createSigDoc = exports.createAuthInfo = exports.createSignerInfo = exports.createFee = exports.createBody = exports.getPublicKey = exports.SIGN_AMINO = exports.SIGN_DIRECT = void 0;
|
|
16
7
|
const keccak256_1 = __importDefault(require("keccak256"));
|
|
17
8
|
const tx_pb_1 = require("@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb");
|
|
18
9
|
const signing_pb_1 = require("@injectivelabs/chain-api/cosmos/tx/signing/v1beta1/signing_pb");
|
|
19
10
|
const coin_pb_1 = require("@injectivelabs/chain-api/cosmos/base/v1beta1/coin_pb");
|
|
20
11
|
const keys_pb_1 = require("@injectivelabs/chain-api/cosmos/crypto/secp256k1/keys_pb");
|
|
21
12
|
const keys_pb_2 = require("@injectivelabs/chain-api/injective/crypto/v1beta1/ethsecp256k1/keys_pb");
|
|
22
|
-
const tx_ext_pb_1 = require("@injectivelabs/chain-api/injective/types/v1beta1/tx_ext_pb");
|
|
23
13
|
const utils_1 = require("@injectivelabs/utils");
|
|
24
14
|
const utils_2 = require("./utils");
|
|
25
|
-
const client_1 = require("../../client");
|
|
26
|
-
const utils_3 = require("../../utils");
|
|
27
|
-
const tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
|
|
28
15
|
exports.SIGN_DIRECT = signing_pb_1.SignMode.SIGN_MODE_DIRECT;
|
|
29
16
|
exports.SIGN_AMINO = signing_pb_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
30
17
|
const getPublicKey = ({ chainId, key, }) => {
|
|
@@ -158,93 +145,4 @@ const createTransaction = ({ memo, pubKey, chainId, message, sequence, fee = uti
|
|
|
158
145
|
};
|
|
159
146
|
};
|
|
160
147
|
exports.createTransaction = createTransaction;
|
|
161
|
-
/**
|
|
162
|
-
* Used when we want to pass a Msg class instead of the {type, message}
|
|
163
|
-
* object of the Message (using the toDirectSign() method)
|
|
164
|
-
* @returns
|
|
165
|
-
*/
|
|
166
|
-
const createTransactionFromMsg = (params) => {
|
|
167
|
-
const messages = Array.isArray(params.message)
|
|
168
|
-
? params.message
|
|
169
|
-
: [params.message];
|
|
170
|
-
return (0, exports.createTransaction)(Object.assign(Object.assign({}, params), { message: messages.map((m) => m.toDirectSign()) }));
|
|
171
|
-
};
|
|
172
|
-
exports.createTransactionFromMsg = createTransactionFromMsg;
|
|
173
|
-
/**
|
|
174
|
-
* Used when we get a DirectSignResponse from
|
|
175
|
-
* Cosmos native wallets like Keplr, Leap, etc after
|
|
176
|
-
* the TxRaw has been signed.
|
|
177
|
-
*
|
|
178
|
-
* The reason why we need to create a new TxRaw and
|
|
179
|
-
* not use the one that we passed to signing is that the users
|
|
180
|
-
* can change the gas fees and that will alter the original
|
|
181
|
-
* TxRaw which will cause signature miss match if we broadcast
|
|
182
|
-
* that transaction on chain
|
|
183
|
-
* @returns
|
|
184
|
-
*/
|
|
185
|
-
const createTxRawFromSigResponse = (signatureResponse) => {
|
|
186
|
-
const txRaw = new tx_pb_1.TxRaw();
|
|
187
|
-
txRaw.setAuthInfoBytes(signatureResponse.signed.authInfoBytes);
|
|
188
|
-
txRaw.setBodyBytes(signatureResponse.signed.bodyBytes);
|
|
189
|
-
txRaw.setSignaturesList([signatureResponse.signature.signature]);
|
|
190
|
-
return txRaw;
|
|
191
|
-
};
|
|
192
|
-
exports.createTxRawFromSigResponse = createTxRawFromSigResponse;
|
|
193
|
-
/**
|
|
194
|
-
* Used when we don't have account details and block details
|
|
195
|
-
* and we pass the message and the user's address only
|
|
196
|
-
* @returns
|
|
197
|
-
*/
|
|
198
|
-
const createTransactionForAddressAndMsg = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
199
|
-
var _a;
|
|
200
|
-
const messages = Array.isArray(params.message)
|
|
201
|
-
? params.message
|
|
202
|
-
: [params.message];
|
|
203
|
-
// Clients
|
|
204
|
-
const chainRestApi = new client_1.ChainRestAuthApi(params.endpoint);
|
|
205
|
-
const tendermintRestApi = new client_1.ChainRestTendermintApi(params.endpoint);
|
|
206
|
-
/** Account Details * */
|
|
207
|
-
const accountDetails = yield chainRestApi.fetchAccount(params.address);
|
|
208
|
-
/** Block Details */
|
|
209
|
-
const latestBlock = yield tendermintRestApi.fetchLatestBlock();
|
|
210
|
-
const latestHeight = latestBlock.header.height;
|
|
211
|
-
const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(utils_3.DEFAULT_TIMEOUT_HEIGHT);
|
|
212
|
-
const pubKey = params.pubKey || ((_a = accountDetails.account.base_account) === null || _a === void 0 ? void 0 : _a.pub_key.key);
|
|
213
|
-
if (pubKey) {
|
|
214
|
-
throw new Error(`The pubKey for ${params.address} is missing.`);
|
|
215
|
-
}
|
|
216
|
-
return (0, exports.createTransaction)(Object.assign(Object.assign({}, params), { pubKey: params.pubKey ||
|
|
217
|
-
Buffer.from(accountDetails.account.base_account.pub_key.key).toString('base64'), sequence: Number(accountDetails.account.base_account.sequence), timeoutHeight: timeoutHeight.toNumber(), accountNumber: Number(accountDetails.account.base_account.account_number), message: messages.map((m) => m.toDirectSign()) }));
|
|
218
|
-
});
|
|
219
|
-
exports.createTransactionForAddressAndMsg = createTransactionForAddressAndMsg;
|
|
220
|
-
const createCosmosSignDocFromTransaction = (args) => {
|
|
221
|
-
const result = (0, exports.createTransaction)(args);
|
|
222
|
-
return Object.assign(Object.assign({}, result), { cosmosSignDoc: tx_1.SignDoc.fromPartial({
|
|
223
|
-
bodyBytes: result.bodyBytes,
|
|
224
|
-
authInfoBytes: result.authInfoBytes,
|
|
225
|
-
accountNumber: result.accountNumber,
|
|
226
|
-
chainId: args.chainId,
|
|
227
|
-
}) });
|
|
228
|
-
};
|
|
229
|
-
exports.createCosmosSignDocFromTransaction = createCosmosSignDocFromTransaction;
|
|
230
|
-
const createTxRawEIP712 = (txRaw, extension) => {
|
|
231
|
-
const body = tx_pb_1.TxBody.deserializeBinary(txRaw.getBodyBytes_asU8());
|
|
232
|
-
const extensionAny = (0, utils_2.createAny)(extension.serializeBinary(), '/injective.types.v1beta1.ExtensionOptionsWeb3Tx');
|
|
233
|
-
body.addExtensionOptions(extensionAny);
|
|
234
|
-
txRaw.setBodyBytes(body.serializeBinary());
|
|
235
|
-
return txRaw;
|
|
236
|
-
};
|
|
237
|
-
exports.createTxRawEIP712 = createTxRawEIP712;
|
|
238
|
-
const createWeb3Extension = ({ ethereumChainId, feePayer, feePayerSig, }) => {
|
|
239
|
-
const web3Extension = new tx_ext_pb_1.ExtensionOptionsWeb3Tx();
|
|
240
|
-
web3Extension.setTypeddatachainid(ethereumChainId);
|
|
241
|
-
if (feePayer) {
|
|
242
|
-
web3Extension.setFeepayer(feePayer);
|
|
243
|
-
}
|
|
244
|
-
if (feePayerSig) {
|
|
245
|
-
web3Extension.setFeepayersig(feePayerSig);
|
|
246
|
-
}
|
|
247
|
-
return web3Extension;
|
|
248
|
-
};
|
|
249
|
-
exports.createWeb3Extension = createWeb3Extension;
|
|
250
148
|
//# sourceMappingURL=tx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.js","sourceRoot":"","sources":["../../../src/core/transaction/tx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tx.js","sourceRoot":"","sources":["../../../src/core/transaction/tx.ts"],"names":[],"mappings":";;;;;;AACA,0DAAiC;AACjC,4EAQyD;AACzD,8FAGsE;AACtE,kFAA2E;AAC3E,sFAAiG;AACjG,oGAA+F;AAC/F,gDAAsD;AACtD,mCAAqD;AA+BxC,QAAA,WAAW,GAAG,qBAAQ,CAAC,gBAAgB,CAAA;AACvC,QAAA,UAAU,GAAG,qBAAQ,CAAC,2BAA2B,CAAA;AAEvD,MAAM,YAAY,GAAG,CAAC,EAC3B,OAAO,EACP,GAAG,GAIJ,EAAE,EAAE;IACH,IAAI,KAAK,CAAA;IACT,IAAI,IAAI,CAAA;IAER,IAAI,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QACnC,KAAK,GAAG,IAAI,gBAAM,EAAE,CAAA;QACpB,IAAI,GAAG,+CAA+C,CAAA;KACvD;SAAM,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QACtC,KAAK,GAAG,IAAI,gBAAM,EAAE,CAAA;QACpB,IAAI,GAAG,0CAA0C,CAAA;KAClD;SAAM;QACL,KAAK,GAAG,IAAI,gBAAY,EAAE,CAAA;QAC1B,IAAI,GAAG,iCAAiC,CAAA;KACzC;IAED,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA;IAExC,OAAO,IAAA,iBAAS,EAAC,KAAK,CAAC,eAAe,EAAE,EAAE,IAAI,CAAC,CAAA;AACjD,CAAC,CAAA;AAxBY,QAAA,YAAY,gBAwBxB;AAEM,MAAM,UAAU,GAAG,CAAC,EACzB,OAAO,EACP,IAAI,EACJ,aAAa,GAK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C,CAAA;IAClD,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAA;IAE1C,OAAO;QACL,KAAK;QACL,OAAO;QACP,aAAa;QACb,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE;QACjC,aAAa,EAAE,QAAQ,CAAC,eAAe,EAAE;QACzC,SAAS,EAAE,WAAW;QACtB,eAAe,EAAE,UAAU;KAC5B,CAAA;AACH,CAAC,CAAA;AApDY,QAAA,iBAAiB,qBAoD7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/transaction/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAA;AACpB,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/transaction/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,cAAc,MAAM,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAEhC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/transaction/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/transaction/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,uCAAoB;AACpB,mDAAgC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Any } from 'google-protobuf/google/protobuf/any_pb';
|
|
2
|
+
import { TxRaw } from '@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb';
|
|
3
|
+
import { ExtensionOptionsWeb3Tx } from '@injectivelabs/chain-api/injective/types/v1beta1/tx_ext_pb';
|
|
4
|
+
import { DirectSignResponse } from '@cosmjs/proto-signing';
|
|
5
|
+
import { EthereumChainId } from '@injectivelabs/ts-types';
|
|
6
|
+
import { Msgs } from '../../modules';
|
|
7
|
+
import { SignDoc as CosmosSignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
|
|
8
|
+
import { CreateTransactionArgs } from '../tx';
|
|
9
|
+
import { MessageGenerated } from '../types';
|
|
10
|
+
export declare const createAnyMessage: (msg: MessageGenerated) => Any;
|
|
11
|
+
export declare const createAny: (value: any, type: string) => Any;
|
|
12
|
+
/**
|
|
13
|
+
* Used when we want to pass a Msg class instead of the {type, message}
|
|
14
|
+
* object of the Message (using the toDirectSign() method)
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare const createTransactionFromMsg: (params: Omit<CreateTransactionArgs, 'message'> & {
|
|
18
|
+
message: Msgs | Msgs[];
|
|
19
|
+
}) => import("../tx").CreateTransactionResult;
|
|
20
|
+
/**
|
|
21
|
+
* Used when we get a DirectSignResponse from
|
|
22
|
+
* Cosmos native wallets like Keplr, Leap, etc after
|
|
23
|
+
* the TxRaw has been signed.
|
|
24
|
+
*
|
|
25
|
+
* The reason why we need to create a new TxRaw and
|
|
26
|
+
* not use the one that we passed to signing is that the users
|
|
27
|
+
* can change the gas fees and that will alter the original
|
|
28
|
+
* TxRaw which will cause signature miss match if we broadcast
|
|
29
|
+
* that transaction on chain
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare const createTxRawFromSigResponse: (signatureResponse: DirectSignResponse) => TxRaw;
|
|
33
|
+
/**
|
|
34
|
+
* Used when we don't have account details and block details
|
|
35
|
+
* and we pass the message and the user's address only
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
export declare const createTransactionForAddressAndMsg: (params: Omit<CreateTransactionArgs, 'message' | 'sequence' | 'pubKey' | 'accountNumber'> & {
|
|
39
|
+
message: Msgs | Msgs[];
|
|
40
|
+
address: string;
|
|
41
|
+
pubKey?: string;
|
|
42
|
+
endpoint: string;
|
|
43
|
+
}) => Promise<import("../tx").CreateTransactionResult>;
|
|
44
|
+
export declare const createTransactionAndCosmosSignDoc: (args: CreateTransactionArgs) => {
|
|
45
|
+
cosmosSignDoc: CosmosSignDoc;
|
|
46
|
+
txRaw: TxRaw;
|
|
47
|
+
signDoc: import("@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb").SignDoc;
|
|
48
|
+
accountNumber: number;
|
|
49
|
+
bodyBytes: Uint8Array;
|
|
50
|
+
authInfoBytes: Uint8Array;
|
|
51
|
+
signBytes: Uint8Array;
|
|
52
|
+
signHashedBytes: Uint8Array;
|
|
53
|
+
};
|
|
54
|
+
export declare const createTransactionAndCosmosSignDocForAddressAndMsg: (params: Omit<CreateTransactionArgs, 'message' | 'sequence' | 'pubKey' | 'accountNumber'> & {
|
|
55
|
+
message: Msgs | Msgs[];
|
|
56
|
+
address: string;
|
|
57
|
+
pubKey?: string;
|
|
58
|
+
endpoint: string;
|
|
59
|
+
}) => Promise<{
|
|
60
|
+
cosmosSignDoc: CosmosSignDoc;
|
|
61
|
+
txRaw: TxRaw;
|
|
62
|
+
signDoc: import("@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb").SignDoc;
|
|
63
|
+
accountNumber: number;
|
|
64
|
+
bodyBytes: Uint8Array;
|
|
65
|
+
authInfoBytes: Uint8Array;
|
|
66
|
+
signBytes: Uint8Array;
|
|
67
|
+
signHashedBytes: Uint8Array;
|
|
68
|
+
}>;
|
|
69
|
+
export declare const createTxRawEIP712: (txRaw: TxRaw, extension: ExtensionOptionsWeb3Tx) => TxRaw;
|
|
70
|
+
export declare const createWeb3Extension: ({ ethereumChainId, feePayer, feePayerSig, }: {
|
|
71
|
+
ethereumChainId: EthereumChainId;
|
|
72
|
+
feePayer?: string | undefined;
|
|
73
|
+
feePayerSig?: Uint8Array | undefined;
|
|
74
|
+
}) => ExtensionOptionsWeb3Tx;
|
|
75
|
+
//# source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CF,CAAA;AAED,eAAO,MAAM,iCAAiC,SACtC,qBAAqB;;;;;;;;;CAa5B,CAAA;AAED,eAAO,MAAM,iDAAiD,WACpD,KACN,qBAAqB,EACrB,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,eAAe,CACpD,GAAG;IACF,OAAO,EAAE,IAAI,GAAG,IAAI,EAAE,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB;;;;;;;;;EAaF,CAAA;AAED,eAAO,MAAM,iBAAiB,UACrB,KAAK,aACD,sBAAsB,UAYlC,CAAA;AAED,eAAO,MAAM,mBAAmB;qBAKb,eAAe;;;4BAgBjC,CAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createWeb3Extension = exports.createTxRawEIP712 = exports.createTransactionAndCosmosSignDocForAddressAndMsg = exports.createTransactionAndCosmosSignDoc = exports.createTransactionForAddressAndMsg = exports.createTxRawFromSigResponse = exports.createTransactionFromMsg = exports.createAny = exports.createAnyMessage = void 0;
|
|
13
|
+
const any_pb_1 = require("google-protobuf/google/protobuf/any_pb");
|
|
14
|
+
const tx_pb_1 = require("@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb");
|
|
15
|
+
const tx_ext_pb_1 = require("@injectivelabs/chain-api/injective/types/v1beta1/tx_ext_pb");
|
|
16
|
+
const utils_1 = require("@injectivelabs/utils");
|
|
17
|
+
const client_1 = require("../../../client");
|
|
18
|
+
const utils_2 = require("../../../utils");
|
|
19
|
+
const tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
|
|
20
|
+
const tx_2 = require("../tx");
|
|
21
|
+
const createAnyMessage = (msg) => {
|
|
22
|
+
const message = new any_pb_1.Any();
|
|
23
|
+
message.setTypeUrl(`${msg.type.startsWith('/') ? '' : '/'}${msg.type}`);
|
|
24
|
+
message.setValue(msg.value.serializeBinary());
|
|
25
|
+
return message;
|
|
26
|
+
};
|
|
27
|
+
exports.createAnyMessage = createAnyMessage;
|
|
28
|
+
const createAny = (value, type) => {
|
|
29
|
+
const message = new any_pb_1.Any();
|
|
30
|
+
message.setTypeUrl(type);
|
|
31
|
+
message.setValue(value);
|
|
32
|
+
return message;
|
|
33
|
+
};
|
|
34
|
+
exports.createAny = createAny;
|
|
35
|
+
/**
|
|
36
|
+
* Used when we want to pass a Msg class instead of the {type, message}
|
|
37
|
+
* object of the Message (using the toDirectSign() method)
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
const createTransactionFromMsg = (params) => {
|
|
41
|
+
const messages = Array.isArray(params.message)
|
|
42
|
+
? params.message
|
|
43
|
+
: [params.message];
|
|
44
|
+
return (0, tx_2.createTransaction)(Object.assign(Object.assign({}, params), { message: messages.map((m) => m.toDirectSign()) }));
|
|
45
|
+
};
|
|
46
|
+
exports.createTransactionFromMsg = createTransactionFromMsg;
|
|
47
|
+
/**
|
|
48
|
+
* Used when we get a DirectSignResponse from
|
|
49
|
+
* Cosmos native wallets like Keplr, Leap, etc after
|
|
50
|
+
* the TxRaw has been signed.
|
|
51
|
+
*
|
|
52
|
+
* The reason why we need to create a new TxRaw and
|
|
53
|
+
* not use the one that we passed to signing is that the users
|
|
54
|
+
* can change the gas fees and that will alter the original
|
|
55
|
+
* TxRaw which will cause signature miss match if we broadcast
|
|
56
|
+
* that transaction on chain
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
const createTxRawFromSigResponse = (signatureResponse) => {
|
|
60
|
+
const txRaw = new tx_pb_1.TxRaw();
|
|
61
|
+
txRaw.setAuthInfoBytes(signatureResponse.signed.authInfoBytes);
|
|
62
|
+
txRaw.setBodyBytes(signatureResponse.signed.bodyBytes);
|
|
63
|
+
txRaw.setSignaturesList([signatureResponse.signature.signature]);
|
|
64
|
+
return txRaw;
|
|
65
|
+
};
|
|
66
|
+
exports.createTxRawFromSigResponse = createTxRawFromSigResponse;
|
|
67
|
+
/**
|
|
68
|
+
* Used when we don't have account details and block details
|
|
69
|
+
* and we pass the message and the user's address only
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
const createTransactionForAddressAndMsg = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
var _a;
|
|
74
|
+
const messages = Array.isArray(params.message)
|
|
75
|
+
? params.message
|
|
76
|
+
: [params.message];
|
|
77
|
+
// Clients
|
|
78
|
+
const chainRestApi = new client_1.ChainRestAuthApi(params.endpoint);
|
|
79
|
+
const tendermintRestApi = new client_1.ChainRestTendermintApi(params.endpoint);
|
|
80
|
+
/** Account Details * */
|
|
81
|
+
const accountDetails = yield chainRestApi.fetchAccount(params.address);
|
|
82
|
+
/** Block Details */
|
|
83
|
+
const latestBlock = yield tendermintRestApi.fetchLatestBlock();
|
|
84
|
+
const latestHeight = latestBlock.header.height;
|
|
85
|
+
const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(utils_2.DEFAULT_TIMEOUT_HEIGHT);
|
|
86
|
+
const pubKey = params.pubKey || ((_a = accountDetails.account.base_account) === null || _a === void 0 ? void 0 : _a.pub_key.key);
|
|
87
|
+
if (pubKey) {
|
|
88
|
+
throw new Error(`The pubKey for ${params.address} is missing.`);
|
|
89
|
+
}
|
|
90
|
+
return (0, tx_2.createTransaction)(Object.assign(Object.assign({}, params), { pubKey: params.pubKey ||
|
|
91
|
+
Buffer.from(accountDetails.account.base_account.pub_key.key).toString('base64'), sequence: Number(accountDetails.account.base_account.sequence), timeoutHeight: timeoutHeight.toNumber(), accountNumber: Number(accountDetails.account.base_account.account_number), message: messages.map((m) => m.toDirectSign()) }));
|
|
92
|
+
});
|
|
93
|
+
exports.createTransactionForAddressAndMsg = createTransactionForAddressAndMsg;
|
|
94
|
+
const createTransactionAndCosmosSignDoc = (args) => {
|
|
95
|
+
const result = (0, tx_2.createTransaction)(args);
|
|
96
|
+
return Object.assign(Object.assign({}, result), { cosmosSignDoc: tx_1.SignDoc.fromPartial({
|
|
97
|
+
bodyBytes: result.bodyBytes,
|
|
98
|
+
authInfoBytes: result.authInfoBytes,
|
|
99
|
+
accountNumber: result.accountNumber,
|
|
100
|
+
chainId: args.chainId,
|
|
101
|
+
}) });
|
|
102
|
+
};
|
|
103
|
+
exports.createTransactionAndCosmosSignDoc = createTransactionAndCosmosSignDoc;
|
|
104
|
+
const createTransactionAndCosmosSignDocForAddressAndMsg = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
const result = yield (0, exports.createTransactionForAddressAndMsg)(params);
|
|
106
|
+
return Object.assign(Object.assign({}, result), { cosmosSignDoc: tx_1.SignDoc.fromPartial({
|
|
107
|
+
bodyBytes: result.bodyBytes,
|
|
108
|
+
authInfoBytes: result.authInfoBytes,
|
|
109
|
+
accountNumber: result.accountNumber,
|
|
110
|
+
chainId: params.chainId,
|
|
111
|
+
}) });
|
|
112
|
+
});
|
|
113
|
+
exports.createTransactionAndCosmosSignDocForAddressAndMsg = createTransactionAndCosmosSignDocForAddressAndMsg;
|
|
114
|
+
const createTxRawEIP712 = (txRaw, extension) => {
|
|
115
|
+
const body = tx_pb_1.TxBody.deserializeBinary(txRaw.getBodyBytes_asU8());
|
|
116
|
+
const extensionAny = (0, exports.createAny)(extension.serializeBinary(), '/injective.types.v1beta1.ExtensionOptionsWeb3Tx');
|
|
117
|
+
body.addExtensionOptions(extensionAny);
|
|
118
|
+
txRaw.setBodyBytes(body.serializeBinary());
|
|
119
|
+
return txRaw;
|
|
120
|
+
};
|
|
121
|
+
exports.createTxRawEIP712 = createTxRawEIP712;
|
|
122
|
+
const createWeb3Extension = ({ ethereumChainId, feePayer, feePayerSig, }) => {
|
|
123
|
+
const web3Extension = new tx_ext_pb_1.ExtensionOptionsWeb3Tx();
|
|
124
|
+
web3Extension.setTypeddatachainid(ethereumChainId);
|
|
125
|
+
if (feePayer) {
|
|
126
|
+
web3Extension.setFeepayer(feePayer);
|
|
127
|
+
}
|
|
128
|
+
if (feePayerSig) {
|
|
129
|
+
web3Extension.setFeepayersig(feePayerSig);
|
|
130
|
+
}
|
|
131
|
+
return web3Extension;
|
|
132
|
+
};
|
|
133
|
+
exports.createWeb3Extension = createWeb3Extension;
|
|
134
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/core/transaction/utils/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAA4D;AAC5D,4EAAgF;AAChF,0FAAmG;AAEnG,gDAAsD;AAGtD,4CAA0E;AAC1E,0CAAuD;AACvD,0DAA4E;AAC5E,8BAAgE;AAGzD,MAAM,gBAAgB,GAAG,CAAC,GAAqB,EAAE,EAAE;IACxD,MAAM,OAAO,GAAG,IAAI,YAAG,EAAE,CAAA;IACzB,OAAO,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IACvE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAA;IAE7C,OAAO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,SAAS,CAAC,eAAe,EAAE,EAC3B,iDAAiD,CAClD,CAAA;IACD,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAEtC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAA;IAE1C,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAdY,QAAA,iBAAiB,qBAc7B;AAEM,MAAM,mBAAmB,GAAG,CAAC,EAClC,eAAe,EACf,QAAQ,EACR,WAAW,GAKZ,EAAE,EAAE;IACH,MAAM,aAAa,GAAG,IAAI,kCAAsB,EAAE,CAAA;IAClD,aAAa,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAA;IAElD,IAAI,QAAQ,EAAE;QACZ,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;KACpC;IAED,IAAI,WAAW,EAAE;QACf,aAAa,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;KAC1C;IAED,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AArBY,QAAA,mBAAmB,uBAqB/B"}
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Any } from 'google-protobuf/google/protobuf/any_pb';
|
|
3
|
-
export interface MessageGenerated {
|
|
4
|
-
value: Message;
|
|
5
|
-
type: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const createAnyMessage: (msg: MessageGenerated) => Any;
|
|
8
|
-
export declare const createAny: (value: any, type: string) => Any;
|
|
1
|
+
export * from './helpers';
|
|
9
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/transaction/utils/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/transaction/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
message.setValue(value);
|
|
16
|
-
return message;
|
|
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);
|
|
17
15
|
};
|
|
18
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./helpers"), exports);
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/transaction/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/transaction/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/sdk-ts",
|
|
3
3
|
"description": "SDK in TypeScript for building Injective applications in a Node environment.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.140",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bojan Angjelkoski",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"shx": "^0.3.2",
|
|
64
64
|
"snakecase-keys": "^5.4.1"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "e48bf3c4fcc3cff36a8417283451a63621957029",
|
|
67
67
|
"typedoc": {
|
|
68
68
|
"entryPoint": "./src/index.ts",
|
|
69
69
|
"readmeFile": "./README.md",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../../src/core/transaction/utils/crypto.ts"],"names":[],"mappings":"AAKA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEnD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEtD"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ripemd160 = exports.sha256 = exports.hashToHex = void 0;
|
|
4
|
-
const SHA256_1 = require("jscrypto/SHA256");
|
|
5
|
-
const RIPEMD160_1 = require("jscrypto/RIPEMD160");
|
|
6
|
-
const Base64_1 = require("jscrypto/Base64");
|
|
7
|
-
const jscrypto_1 = require("jscrypto");
|
|
8
|
-
function hashToHex(data) {
|
|
9
|
-
return SHA256_1.SHA256.hash(Base64_1.Base64.parse(data)).toString().toUpperCase();
|
|
10
|
-
}
|
|
11
|
-
exports.hashToHex = hashToHex;
|
|
12
|
-
function sha256(data) {
|
|
13
|
-
return SHA256_1.SHA256.hash(new jscrypto_1.Word32Array(data)).toUint8Array();
|
|
14
|
-
}
|
|
15
|
-
exports.sha256 = sha256;
|
|
16
|
-
function ripemd160(data) {
|
|
17
|
-
return RIPEMD160_1.RIPEMD160.hash(new jscrypto_1.Word32Array(data)).toUint8Array();
|
|
18
|
-
}
|
|
19
|
-
exports.ripemd160 = ripemd160;
|
|
20
|
-
//# sourceMappingURL=crypto.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../../src/core/transaction/utils/crypto.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AACxC,kDAA8C;AAC9C,4CAAwC;AACxC,uCAAsC;AAEtC,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,eAAM,CAAC,IAAI,CAAC,eAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAA;AACjE,CAAC;AAFD,8BAEC;AAED,SAAgB,MAAM,CAAC,IAAgB;IACrC,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,sBAAW,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAA;AAC1D,CAAC;AAFD,wBAEC;AAED,SAAgB,SAAS,CAAC,IAAgB;IACxC,OAAO,qBAAS,CAAC,IAAI,CAAC,IAAI,sBAAW,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAA;AAC7D,CAAC;AAFD,8BAEC"}
|