@injectivelabs/sdk-ts 1.0.209 → 1.0.211
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/accounts/PrivateKey.d.ts +9 -0
- package/dist/core/accounts/PrivateKey.d.ts.map +1 -1
- package/dist/core/accounts/PrivateKey.js +16 -0
- package/dist/core/accounts/PrivateKey.js.map +1 -1
- package/dist/core/transaction/MsgBroadcasterLocal.d.ts +67 -0
- package/dist/core/transaction/MsgBroadcasterLocal.d.ts.map +1 -0
- package/dist/core/transaction/MsgBroadcasterLocal.js +124 -0
- package/dist/core/transaction/MsgBroadcasterLocal.js.map +1 -0
- package/dist/core/transaction/index.d.ts +1 -0
- package/dist/core/transaction/index.d.ts.map +1 -1
- package/dist/core/transaction/index.js +1 -0
- package/dist/core/transaction/index.js.map +1 -1
- package/dist/core/transaction/utils/helpers.d.ts +2 -0
- package/dist/core/transaction/utils/helpers.d.ts.map +1 -1
- package/dist/core/transaction/utils/helpers.js +27 -1
- package/dist/core/transaction/utils/helpers.js.map +1 -1
- package/package.json +2 -2
|
@@ -30,8 +30,17 @@ export declare class PrivateKey {
|
|
|
30
30
|
* If path is not given, default to Band's HD prefix 494 and all other indexes being zeroes.
|
|
31
31
|
* @param {string} privateKey the private key
|
|
32
32
|
* @returns {PrivateKey} Initialized PrivateKey object
|
|
33
|
+
*
|
|
34
|
+
* @deprecated - use fromHex instead
|
|
33
35
|
*/
|
|
34
36
|
static fromPrivateKey(privateKey: string): PrivateKey;
|
|
37
|
+
/**
|
|
38
|
+
* Create a PrivateKey instance from a given private key and a HD derivation path.
|
|
39
|
+
* If path is not given, default to Band's HD prefix 494 and all other indexes being zeroes.
|
|
40
|
+
* @param {string} privateKey the private key
|
|
41
|
+
* @returns {PrivateKey} Initialized PrivateKey object
|
|
42
|
+
*/
|
|
43
|
+
static fromHex(privateKey: string | Uint8Array): PrivateKey;
|
|
35
44
|
/**
|
|
36
45
|
* Return a hex representation of signing key.
|
|
37
46
|
* @returns {string}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC;;;;GAIG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO;IAIP;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAU/D;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CACjB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,MAAM,GAAG,SAAmC,GACjD,UAAU;IAIb;;;;;OAKG;IACH,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC;;;;GAIG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO;IAIP;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAU/D;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CACjB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,MAAM,GAAG,SAAmC,GACjD,UAAU;IAIb;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAIrD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU;IAW3D;;;OAGG;IACH,KAAK,IAAI,MAAM;IAMf;;;QAGI;IACJ,WAAW,IAAI,SAAS;IAIxB;;;QAGI;IACJ,SAAS,IAAI,OAAO;IAIpB;;;QAGI;IACJ,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAYrD;;;;OAIG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAazD;;;;OAIG;IACG,UAAU,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAWjE;;;;OAIG;IACG,cAAc,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAWtE"}
|
|
@@ -80,10 +80,26 @@ class PrivateKey {
|
|
|
80
80
|
* If path is not given, default to Band's HD prefix 494 and all other indexes being zeroes.
|
|
81
81
|
* @param {string} privateKey the private key
|
|
82
82
|
* @returns {PrivateKey} Initialized PrivateKey object
|
|
83
|
+
*
|
|
84
|
+
* @deprecated - use fromHex instead
|
|
83
85
|
*/
|
|
84
86
|
static fromPrivateKey(privateKey) {
|
|
85
87
|
return new PrivateKey(new ethers_1.Wallet(privateKey));
|
|
86
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a PrivateKey instance from a given private key and a HD derivation path.
|
|
91
|
+
* If path is not given, default to Band's HD prefix 494 and all other indexes being zeroes.
|
|
92
|
+
* @param {string} privateKey the private key
|
|
93
|
+
* @returns {PrivateKey} Initialized PrivateKey object
|
|
94
|
+
*/
|
|
95
|
+
static fromHex(privateKey) {
|
|
96
|
+
const isString = typeof privateKey === 'string';
|
|
97
|
+
const privateKeyHex = isString && privateKey.startsWith('0x') ? privateKey.slice(2) : privateKey;
|
|
98
|
+
const privateKeyBuff = isString
|
|
99
|
+
? Buffer.from(privateKeyHex.toString(), 'hex')
|
|
100
|
+
: privateKey;
|
|
101
|
+
return new PrivateKey(new ethers_1.Wallet(privateKeyBuff));
|
|
102
|
+
}
|
|
87
103
|
/**
|
|
88
104
|
* Return a hex representation of signing key.
|
|
89
105
|
* @returns {string}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,mCAA+B;AAC/B,0DAAiC;AACjC,0DAAiC;AACjC,qDAA+D;AAC/D,2CAAuC;AACvC,uCAAmC;AACnC,iEAAkD;AAElD;;;;GAIG;AACH,MAAa,UAAU;IAGrB,YAAoB,MAAc;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ;QACb,MAAM,QAAQ,GAAG,eAAK,CAAC,gBAAgB,EAAE,CAAA;QACzC,MAAM,UAAU,GAAG,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAEpD,OAAO;YACL,UAAU;YACV,QAAQ;SACT,CAAA;IACH,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CACjB,KAAa,EACb,OAA2B,mCAAuB;QAElD,OAAO,IAAI,UAAU,CAAC,eAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;IACzD,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,mCAA+B;AAC/B,0DAAiC;AACjC,0DAAiC;AACjC,qDAA+D;AAC/D,2CAAuC;AACvC,uCAAmC;AACnC,iEAAkD;AAElD;;;;GAIG;AACH,MAAa,UAAU;IAGrB,YAAoB,MAAc;QAChC,IAAI,CAAC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2
|
+
import { Msgs } from '../modules';
|
|
3
|
+
import { ChainId, EthereumChainId } from '@injectivelabs/ts-types';
|
|
4
|
+
interface MsgBroadcasterTxOptions {
|
|
5
|
+
msgs: Msgs | Msgs[];
|
|
6
|
+
injectiveAddress: string;
|
|
7
|
+
ethereumAddress?: string;
|
|
8
|
+
memo?: string;
|
|
9
|
+
feePrice?: string;
|
|
10
|
+
feeDenom?: string;
|
|
11
|
+
gasLimit?: number;
|
|
12
|
+
}
|
|
13
|
+
interface MsgBroadcasterOptionsLocal {
|
|
14
|
+
endpoints: {
|
|
15
|
+
indexerApi: string;
|
|
16
|
+
sentryGrpcApi: string;
|
|
17
|
+
sentryHttpApi: string;
|
|
18
|
+
};
|
|
19
|
+
chainId: ChainId;
|
|
20
|
+
privateKey: string;
|
|
21
|
+
ethereumChainId?: EthereumChainId;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* This class is used to broadcast transactions
|
|
25
|
+
* using a privateKey as a signer
|
|
26
|
+
* for the transactions and broadcasting
|
|
27
|
+
* the transactions directly to the node
|
|
28
|
+
*
|
|
29
|
+
* Mainly used for working in a Node Environment
|
|
30
|
+
*/
|
|
31
|
+
export declare class MsgBroadcasterLocal {
|
|
32
|
+
options: MsgBroadcasterOptionsLocal;
|
|
33
|
+
privateKey: PrivateKey;
|
|
34
|
+
constructor(options: MsgBroadcasterOptionsLocal);
|
|
35
|
+
/**
|
|
36
|
+
* Broadcasting the transaction using the client
|
|
37
|
+
*
|
|
38
|
+
* @param tx
|
|
39
|
+
* @returns {string} transaction hash
|
|
40
|
+
*/
|
|
41
|
+
broadcast(transaction: MsgBroadcasterTxOptions): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Broadcasting the transaction using the client
|
|
44
|
+
*
|
|
45
|
+
* @param tx
|
|
46
|
+
* @returns {string} transaction hash
|
|
47
|
+
*/
|
|
48
|
+
simulate(transaction: MsgBroadcasterTxOptions): Promise<{
|
|
49
|
+
result: {
|
|
50
|
+
data: string;
|
|
51
|
+
log: string;
|
|
52
|
+
eventsList: {
|
|
53
|
+
type: string;
|
|
54
|
+
attributes: {
|
|
55
|
+
key: string;
|
|
56
|
+
value: string;
|
|
57
|
+
}[];
|
|
58
|
+
}[];
|
|
59
|
+
};
|
|
60
|
+
gasInfo: {
|
|
61
|
+
gasWanted: number;
|
|
62
|
+
gasUsed: number;
|
|
63
|
+
};
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=MsgBroadcasterLocal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MsgBroadcasterLocal.d.ts","sourceRoot":"","sources":["../../../src/core/transaction/MsgBroadcasterLocal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAiBjC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAElE,UAAU,uBAAuB;IAC/B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,0BAA0B;IAClC,SAAS,EAAE;QACT,UAAU,EAAE,MAAM,CAAA;QAClB,aAAa,EAAE,MAAM,CAAA;QACrB,aAAa,EAAE,MAAM,CAAA;KACtB,CAAA;IACD,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC;AAED;;;;;;;GAOG;AACH,qBAAa,mBAAmB;IACvB,OAAO,EAAE,0BAA0B,CAAA;IAEnC,UAAU,EAAE,UAAU,CAAA;gBAEjB,OAAO,EAAE,0BAA0B;IAK/C;;;;;OAKG;IACG,SAAS,CAAC,WAAW,EAAE,uBAAuB;IAkEpD;;;;;OAKG;IACG,QAAQ,CAAC,WAAW,EAAE,uBAAuB;;;;;;;;;;;;;;;;;CAyDpD"}
|
|
@@ -0,0 +1,124 @@
|
|
|
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.MsgBroadcasterLocal = void 0;
|
|
13
|
+
const accounts_1 = require("../accounts");
|
|
14
|
+
const tx_1 = require("./tx");
|
|
15
|
+
const TxRestClient_1 = require("./client/TxRestClient");
|
|
16
|
+
const rest_1 = require("./../../client/chain/rest");
|
|
17
|
+
const utils_1 = require("@injectivelabs/utils");
|
|
18
|
+
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
19
|
+
const helpers_1 = require("./utils/helpers");
|
|
20
|
+
/**
|
|
21
|
+
* This class is used to broadcast transactions
|
|
22
|
+
* using a privateKey as a signer
|
|
23
|
+
* for the transactions and broadcasting
|
|
24
|
+
* the transactions directly to the node
|
|
25
|
+
*
|
|
26
|
+
* Mainly used for working in a Node Environment
|
|
27
|
+
*/
|
|
28
|
+
class MsgBroadcasterLocal {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.privateKey = accounts_1.PrivateKey.fromHex(options.privateKey);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Broadcasting the transaction using the client
|
|
35
|
+
*
|
|
36
|
+
* @param tx
|
|
37
|
+
* @returns {string} transaction hash
|
|
38
|
+
*/
|
|
39
|
+
broadcast(transaction) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const { options, privateKey } = this;
|
|
42
|
+
const tx = Object.assign(Object.assign({}, transaction), { msgs: Array.isArray(transaction.msgs)
|
|
43
|
+
? transaction.msgs
|
|
44
|
+
: [transaction.msgs], ethereumAddress: (0, helpers_1.getEthereumSignerAddress)(transaction.injectiveAddress), injectiveAddress: (0, helpers_1.getInjectiveSignerAddress)(transaction.injectiveAddress) });
|
|
45
|
+
/** Account Details * */
|
|
46
|
+
const publicKey = privateKey.toPublicKey();
|
|
47
|
+
const chainRestAuthApi = new rest_1.ChainRestAuthApi(options.endpoints.sentryHttpApi);
|
|
48
|
+
const accountDetailsResponse = yield chainRestAuthApi.fetchAccount(tx.injectiveAddress);
|
|
49
|
+
const baseAccount = accounts_1.BaseAccount.fromRestApi(accountDetailsResponse);
|
|
50
|
+
const accountDetails = baseAccount.toAccountDetails();
|
|
51
|
+
/** Block Details */
|
|
52
|
+
const chainRestTendermintApi = new rest_1.ChainRestTendermintApi(options.endpoints.sentryHttpApi);
|
|
53
|
+
const latestBlock = yield chainRestTendermintApi.fetchLatestBlock();
|
|
54
|
+
const latestHeight = latestBlock.header.height;
|
|
55
|
+
const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(utils_1.DEFAULT_TIMEOUT_HEIGHT);
|
|
56
|
+
/** Prepare the Transaction * */
|
|
57
|
+
const { signBytes, txRaw } = (0, tx_1.createTransaction)({
|
|
58
|
+
memo: '',
|
|
59
|
+
fee: utils_1.DEFAULT_STD_FEE,
|
|
60
|
+
message: tx.msgs.map((m) => m.toDirectSign()),
|
|
61
|
+
timeoutHeight: timeoutHeight.toNumber(),
|
|
62
|
+
pubKey: publicKey.toBase64(),
|
|
63
|
+
sequence: accountDetails.sequence,
|
|
64
|
+
accountNumber: accountDetails.accountNumber,
|
|
65
|
+
chainId: options.chainId,
|
|
66
|
+
});
|
|
67
|
+
/** Sign transaction */
|
|
68
|
+
const signature = yield privateKey.sign(Buffer.from(signBytes));
|
|
69
|
+
/** Append Signatures */
|
|
70
|
+
txRaw.setSignaturesList([signature]);
|
|
71
|
+
/** Broadcast transaction */
|
|
72
|
+
const txResponse = yield new TxRestClient_1.TxRestClient(options.endpoints.sentryHttpApi).broadcast(txRaw);
|
|
73
|
+
if (txResponse.code !== 0) {
|
|
74
|
+
throw new exceptions_1.GeneralException(new Error(`Transaction failed to be broadcasted - ${txResponse.rawLog}`));
|
|
75
|
+
}
|
|
76
|
+
return txResponse.txHash;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Broadcasting the transaction using the client
|
|
81
|
+
*
|
|
82
|
+
* @param tx
|
|
83
|
+
* @returns {string} transaction hash
|
|
84
|
+
*/
|
|
85
|
+
simulate(transaction) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const { options, privateKey } = this;
|
|
88
|
+
const tx = Object.assign(Object.assign({}, transaction), { msgs: Array.isArray(transaction.msgs)
|
|
89
|
+
? transaction.msgs
|
|
90
|
+
: [transaction.msgs], ethereumAddress: (0, helpers_1.getEthereumSignerAddress)(transaction.injectiveAddress), injectiveAddress: (0, helpers_1.getInjectiveSignerAddress)(transaction.injectiveAddress) });
|
|
91
|
+
/** Account Details * */
|
|
92
|
+
const publicKey = privateKey.toPublicKey();
|
|
93
|
+
const chainRestAuthApi = new rest_1.ChainRestAuthApi(options.endpoints.sentryHttpApi);
|
|
94
|
+
const accountDetailsResponse = yield chainRestAuthApi.fetchAccount(tx.injectiveAddress);
|
|
95
|
+
const baseAccount = accounts_1.BaseAccount.fromRestApi(accountDetailsResponse);
|
|
96
|
+
const accountDetails = baseAccount.toAccountDetails();
|
|
97
|
+
/** Block Details */
|
|
98
|
+
const chainRestTendermintApi = new rest_1.ChainRestTendermintApi(options.endpoints.sentryHttpApi);
|
|
99
|
+
const latestBlock = yield chainRestTendermintApi.fetchLatestBlock();
|
|
100
|
+
const latestHeight = latestBlock.header.height;
|
|
101
|
+
const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(utils_1.DEFAULT_TIMEOUT_HEIGHT);
|
|
102
|
+
/** Prepare the Transaction * */
|
|
103
|
+
const { signBytes, txRaw } = (0, tx_1.createTransaction)({
|
|
104
|
+
memo: '',
|
|
105
|
+
fee: utils_1.DEFAULT_STD_FEE,
|
|
106
|
+
message: tx.msgs.map((m) => m.toDirectSign()),
|
|
107
|
+
timeoutHeight: timeoutHeight.toNumber(),
|
|
108
|
+
pubKey: publicKey.toBase64(),
|
|
109
|
+
sequence: accountDetails.sequence,
|
|
110
|
+
accountNumber: accountDetails.accountNumber,
|
|
111
|
+
chainId: options.chainId,
|
|
112
|
+
});
|
|
113
|
+
/** Sign transaction */
|
|
114
|
+
const signature = yield privateKey.sign(Buffer.from(signBytes));
|
|
115
|
+
/** Append Signatures */
|
|
116
|
+
txRaw.setSignaturesList([signature]);
|
|
117
|
+
/** Simulate transaction */
|
|
118
|
+
const simulationResponse = yield new TxRestClient_1.TxRestClient(options.endpoints.sentryHttpApi).simulate(txRaw);
|
|
119
|
+
return simulationResponse;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.MsgBroadcasterLocal = MsgBroadcasterLocal;
|
|
124
|
+
//# sourceMappingURL=MsgBroadcasterLocal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MsgBroadcasterLocal.js","sourceRoot":"","sources":["../../../src/core/transaction/MsgBroadcasterLocal.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAqD;AAErD,6BAAwC;AACx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pB,OAAO,EAAG,EAAE,CAAC,IAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;gBACzD,aAAa,EAAE,aAAa,CAAC,QAAQ,EAAE;gBACvC,MAAM,EAAE,SAAS,CAAC,QAAQ,EAAE;gBAC5B,QAAQ,EAAE,cAAc,CAAC,QAAQ;gBACjC,aAAa,EAAE,cAAc,CAAC,aAAa;gBAC3C,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAA;YAEF,uBAAuB;YACvB,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;YAE/D,wBAAwB;YACxB,KAAK,CAAC,iBAAiB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;YAEpC,2BAA2B;YAC3B,MAAM,kBAAkB,GAAG,MAAM,IAAI,2BAAY,CAC/C,OAAO,CAAC,SAAS,CAAC,aAAa,CAChC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YAEjB,OAAO,kBAAkB,CAAA;QAC3B,CAAC;KAAA;CACF;AAjJD,kDAiJC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/transaction/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAA;AACpB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/transaction/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAA;AACpB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,uBAAuB,CAAA"}
|
|
@@ -18,4 +18,5 @@ __exportStar(require("./tx"), exports);
|
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
19
|
__exportStar(require("./types"), exports);
|
|
20
20
|
__exportStar(require("./client"), exports);
|
|
21
|
+
__exportStar(require("./MsgBroadcasterLocal"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/transaction/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAoB;AACpB,0CAAuB;AACvB,0CAAuB;AACvB,2CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/transaction/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAoB;AACpB,0CAAuB;AACvB,0CAAuB;AACvB,2CAAwB;AACxB,wDAAqC"}
|
|
@@ -79,4 +79,6 @@ export declare const createWeb3Extension: ({ ethereumChainId, feePayer, feePayer
|
|
|
79
79
|
feePayer?: string | undefined;
|
|
80
80
|
feePayerSig?: Uint8Array | undefined;
|
|
81
81
|
}) => ExtensionOptionsWeb3Tx;
|
|
82
|
+
export declare const getInjectiveSignerAddress: (address: string | undefined) => string;
|
|
83
|
+
export declare const getEthereumSignerAddress: (address: string | undefined) => string;
|
|
82
84
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/core/transaction/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,wCAAwC,CAAA;AAC5D,OAAO,EAAU,KAAK,EAAE,MAAM,kDAAkD,CAAA;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,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B5B,CAAA;AAED,eAAO,MAAM,kCAAkC,SAAU;IACvD,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;CACtB,kBAOA,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;;;;;;;;;;EAgBF,CAAA;AAED,eAAO,MAAM,iBAAiB,UACrB,KAAK,aACD,sBAAsB,UAYlC,CAAA;AAED,eAAO,MAAM,mBAAmB;qBAKb,eAAe;;;4BAgBjC,CAAA;AAED,eAAO,MAAM,yBAAyB,YAAa,MAAM,GAAG,SAAS,WAcpE,CAAA;AAED,eAAO,MAAM,wBAAwB,YAAa,MAAM,GAAG,SAAS,WAcnE,CAAA"}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createWeb3Extension = exports.createTxRawEIP712 = exports.createTransactionAndCosmosSignDocForAddressAndMsg = exports.createCosmosSignDocFromTransaction = exports.createTransactionAndCosmosSignDoc = exports.createTransactionForAddressAndMsg = exports.createTxRawFromSigResponse = exports.createTransactionFromMsg = exports.createAny = exports.createAnyMessage = void 0;
|
|
12
|
+
exports.getEthereumSignerAddress = exports.getInjectiveSignerAddress = exports.createWeb3Extension = exports.createTxRawEIP712 = exports.createTransactionAndCosmosSignDocForAddressAndMsg = exports.createCosmosSignDocFromTransaction = exports.createTransactionAndCosmosSignDoc = exports.createTransactionForAddressAndMsg = exports.createTxRawFromSigResponse = exports.createTransactionFromMsg = exports.createAny = exports.createAnyMessage = void 0;
|
|
13
13
|
const any_pb_1 = require("google-protobuf/google/protobuf/any_pb");
|
|
14
14
|
const tx_pb_1 = require("@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb");
|
|
15
15
|
const tx_ext_pb_1 = require("@injectivelabs/chain-api/injective/types/v1beta1/tx_ext_pb");
|
|
@@ -147,4 +147,30 @@ const createWeb3Extension = ({ ethereumChainId, feePayer, feePayerSig, }) => {
|
|
|
147
147
|
return web3Extension;
|
|
148
148
|
};
|
|
149
149
|
exports.createWeb3Extension = createWeb3Extension;
|
|
150
|
+
const getInjectiveSignerAddress = (address) => {
|
|
151
|
+
if (!address) {
|
|
152
|
+
return '';
|
|
153
|
+
}
|
|
154
|
+
if (address.startsWith('inj')) {
|
|
155
|
+
return address;
|
|
156
|
+
}
|
|
157
|
+
if (address.startsWith('0x')) {
|
|
158
|
+
return (0, utils_2.getInjectiveAddress)(address);
|
|
159
|
+
}
|
|
160
|
+
return '';
|
|
161
|
+
};
|
|
162
|
+
exports.getInjectiveSignerAddress = getInjectiveSignerAddress;
|
|
163
|
+
const getEthereumSignerAddress = (address) => {
|
|
164
|
+
if (!address) {
|
|
165
|
+
return '';
|
|
166
|
+
}
|
|
167
|
+
if (address.startsWith('0x')) {
|
|
168
|
+
return address;
|
|
169
|
+
}
|
|
170
|
+
if (address.startsWith('inj')) {
|
|
171
|
+
return (0, utils_2.getAddressFromInjectiveAddress)(address);
|
|
172
|
+
}
|
|
173
|
+
return '';
|
|
174
|
+
};
|
|
175
|
+
exports.getEthereumSignerAddress = getEthereumSignerAddress;
|
|
150
176
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +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,4CAA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;IAED,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC5B,OAAO,OAAO,CAAA;KACf;IAED,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QAC7B,OAAO,IAAA,sCAA8B,EAAC,OAAO,CAAC,CAAA;KAC/C;IAED,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAdY,QAAA,wBAAwB,4BAcpC"}
|
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 browser, node, and react native environment.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.211",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bojan Angjelkoski",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"shx": "^0.3.2",
|
|
67
67
|
"snakecase-keys": "^5.4.1"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "6f16e814a72e55374ac1f17fd513996ff9e7b52e",
|
|
70
70
|
"typedoc": {
|
|
71
71
|
"entryPoint": "./src/index.ts",
|
|
72
72
|
"readmeFile": "./README.md",
|