carbon-js-sdk 0.4.20 → 0.4.21
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/lib/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.js +3 -3
- package/lib/clients/ZILClient.js +17 -17
- package/lib/codec/cosmos/gov/v1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1/tx.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/group/v1/events.js +2 -2
- package/lib/codec/cosmos/group/v1/tx.js +4 -4
- package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.d.ts +1 -0
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.js +6 -0
- package/lib/codec/ethermint/evm/v1/export.d.ts +5 -0
- package/lib/codec/ethermint/evm/v1/export.js +53 -0
- package/lib/codec/ethermint/feemarket/v1/export.d.ts +4 -0
- package/lib/codec/ethermint/feemarket/v1/export.js +18 -0
- package/lib/codec/ethermint/types/v1/export.d.ts +4 -0
- package/lib/codec/ethermint/types/v1/export.js +11 -0
- package/lib/codec/ethermint-models.d.ts +4 -0
- package/lib/codec/ethermint-models.js +26 -0
- package/lib/codec/market/fee.d.ts +123 -0
- package/lib/codec/market/fee.js +334 -0
- package/lib/codec/perpsliquidity/event.d.ts +102 -0
- package/lib/codec/perpsliquidity/event.js +581 -0
- package/lib/codec/perpsliquidity/genesis.d.ts +35 -0
- package/lib/codec/perpsliquidity/genesis.js +162 -0
- package/lib/codec/perpsliquidity/params.d.ts +24 -0
- package/lib/codec/perpsliquidity/params.js +103 -0
- package/lib/codec/perpsliquidity/pool.d.ts +137 -0
- package/lib/codec/perpsliquidity/pool.js +747 -0
- package/lib/codec/perpsliquidity/query.d.ts +167 -0
- package/lib/codec/perpsliquidity/query.js +719 -0
- package/lib/codec/perpsliquidity/tx.d.ts +199 -0
- package/lib/codec/perpsliquidity/tx.js +940 -0
- package/lib/constant/eip712.d.ts +46 -0
- package/lib/constant/eip712.js +106 -0
- package/lib/constant/generic.js +1 -1
- package/lib/constant/network.js +2 -2
- package/lib/modules/cdp.js +43 -43
- package/lib/modules/cosmwasm.js +1 -1
- package/lib/modules/evm.d.ts +46 -0
- package/lib/modules/evm.js +127 -0
- package/lib/modules/evmmerge.d.ts +12 -0
- package/lib/modules/evmmerge.js +35 -0
- package/lib/modules/feemarket.d.ts +20 -0
- package/lib/modules/feemarket.js +45 -0
- package/lib/modules/gov.js +12 -12
- package/lib/modules/liquiditypool.js +1 -1
- package/lib/modules/vault.d.ts +44 -0
- package/lib/modules/vault.js +95 -0
- package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
- package/lib/provider/amino/types/admin.js +27 -27
- package/lib/provider/amino/types/bank.js +1 -1
- package/lib/provider/amino/types/broker.js +1 -1
- package/lib/provider/amino/types/cdp.js +25 -25
- package/lib/provider/amino/types/coin.js +4 -4
- package/lib/provider/amino/types/evm.d.ts +4 -0
- package/lib/provider/amino/types/evm.js +40 -0
- package/lib/provider/amino/types/evmmerge.d.ts +4 -0
- package/lib/provider/amino/types/evmmerge.js +34 -0
- package/lib/provider/amino/types/feemarket.d.ts +4 -0
- package/lib/provider/amino/types/feemarket.js +34 -0
- package/lib/provider/amino/types/gov.js +4 -4
- package/lib/provider/amino/types/ibc.js +1 -1
- package/lib/provider/amino/types/leverage.js +1 -1
- package/lib/provider/amino/types/liquidityPool.js +7 -7
- package/lib/provider/amino/types/market.js +2 -2
- package/lib/provider/amino/types/oracle.js +1 -1
- package/lib/provider/amino/types/order.js +4 -4
- package/lib/provider/amino/types/position.js +1 -1
- package/lib/provider/amino/types/profile.js +1 -1
- package/lib/provider/amino/types/staking.js +4 -4
- package/lib/provider/amino/types/subaccount.js +3 -3
- package/lib/provider/amino/utils.js +11 -11
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.js +1 -1
- package/lib/provider/metamask/legacy-accounts.d.ts +6 -0
- package/lib/provider/metamask/legacy-accounts.js +44 -0
- package/lib/provider/o3/O3Wallet.js +2 -2
- package/lib/util/address.js +13 -13
- package/lib/util/api.js +4 -4
- package/lib/util/eip712.d.ts +10 -0
- package/lib/util/eip712.js +195 -0
- package/lib/util/ethermint.d.ts +8 -0
- package/lib/util/ethermint.js +68 -0
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/legacyEIP712.d.ts +20 -0
- package/lib/util/legacyEIP712.js +98 -0
- package/lib/util/number.js +5 -5
- package/lib/wallet/CarbonSigner.js +2 -2
- package/lib/wallet/CarbonSigningClient.js +8 -8
- package/lib/wallet/CarbonWallet.js +6 -6
- package/lib/websocket/connector.js +3 -3
- package/package.json +1 -1
- package/lib/clients/EvmIbcClient.d.ts +0 -86
- package/lib/clients/EvmIbcClient.js +0 -90
- package/lib/codec/broker/incoming_pool_swap.d.ts +0 -23
- package/lib/codec/broker/incoming_pool_swap.js +0 -136
- package/lib/util/ethermint/evm-ibc.d.ts +0 -97
- package/lib/util/ethermint/evm-ibc.js +0 -134
- package/lib/util/ethermint/index.d.ts +0 -3
- package/lib/util/ethermint/index.js +0 -12
- package/lib/util/ethermint/keys.d.ts +0 -39
- package/lib/util/ethermint/keys.js +0 -138
- package/lib/util/ethermint/web3.d.ts +0 -36
- package/lib/util/ethermint/web3.js +0 -124
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.constructEIP712Tx = void 0;
|
|
7
|
+
const eip712_1 = require("../constant/eip712");
|
|
8
|
+
const ethermint_1 = require("../util/ethermint");
|
|
9
|
+
const codec_1 = require("../codec");
|
|
10
|
+
const AminoTypesMap_1 = __importDefault(require("../provider/amino/AminoTypesMap"));
|
|
11
|
+
const lodash_1 = require("lodash");
|
|
12
|
+
function getTypes(msgs) {
|
|
13
|
+
let types = Object.assign({}, eip712_1.DEFAULT_EIP712_TYPES);
|
|
14
|
+
const includedTypes = [];
|
|
15
|
+
let valueIndex = 0;
|
|
16
|
+
msgs.forEach((msg, index) => {
|
|
17
|
+
const typeUrl = AminoTypesMap_1.default.fromAmino(msg).typeUrl;
|
|
18
|
+
const msgType = msg.type.split('/')[1];
|
|
19
|
+
const msgTypeIndex = getLatestMsgTypeIndex(`Type${msgType}`, types);
|
|
20
|
+
//cosmos-sdk/MsgSend => TypeMsgSend1
|
|
21
|
+
const typeKey = `Type${msgType}${msgTypeIndex}`;
|
|
22
|
+
if (!includedTypes.includes(msg.type)) {
|
|
23
|
+
types['Tx'] = [...types['Tx'], { name: `msg${index}`, type: typeKey }];
|
|
24
|
+
types[typeKey] = [{ name: 'value', type: `TypeValue${valueIndex}` }, { name: 'type', type: 'string' }];
|
|
25
|
+
//cosmos-sdk/MsgSend => Msg_Send
|
|
26
|
+
types = Object.assign(Object.assign({}, types), sortByNameDescending(getMsgValueType(typeUrl, msg.value, `TypeValue${valueIndex}`, valueIndex, types)));
|
|
27
|
+
includedTypes.push(msg.type);
|
|
28
|
+
valueIndex++;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const typeFound = matchingType(msg, types);
|
|
32
|
+
if (typeFound) {
|
|
33
|
+
types['Tx'] = [...types['Tx'], { name: `msg${index}`, type: typeFound }];
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
//same type, but different fields populated, so new type defnition is required
|
|
37
|
+
types['Tx'] = [...types['Tx'], { name: `msg${index}`, type: typeKey }];
|
|
38
|
+
types[typeKey] = [{ name: 'value', type: `TypeValue${valueIndex}` }, { name: 'type', type: 'string' }];
|
|
39
|
+
types = Object.assign(Object.assign({}, types), sortByNameDescending(getMsgValueType(typeUrl, msg.value, `TypeValue${valueIndex}`, valueIndex, types)));
|
|
40
|
+
valueIndex++;
|
|
41
|
+
});
|
|
42
|
+
return types;
|
|
43
|
+
}
|
|
44
|
+
function getLatestMsgTypeIndex(typeName, types) {
|
|
45
|
+
let index = 0;
|
|
46
|
+
Object.entries(types).forEach(([key, _]) => {
|
|
47
|
+
if (key.includes(typeName)) {
|
|
48
|
+
index++;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return index;
|
|
52
|
+
}
|
|
53
|
+
function sortByNameDescending(types) {
|
|
54
|
+
Object.entries(types).forEach(([key, _]) => {
|
|
55
|
+
types[key].sort((a, b) => b.name.localeCompare(a.name));
|
|
56
|
+
});
|
|
57
|
+
return types;
|
|
58
|
+
}
|
|
59
|
+
// Checks if there is a need to create new type for the same message type because of different populated fields
|
|
60
|
+
function matchingType(msg, eipTypes) {
|
|
61
|
+
const msgType = msg.type.split('/')[1];
|
|
62
|
+
let match = false;
|
|
63
|
+
for (const key in eipTypes) {
|
|
64
|
+
if (key.includes(msgType)) {
|
|
65
|
+
match = compareValues(msg, key, eipTypes);
|
|
66
|
+
}
|
|
67
|
+
if (match) {
|
|
68
|
+
return key;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
function compareValues(msg, key, eipTypes) {
|
|
74
|
+
let match = true;
|
|
75
|
+
for (let { name, type } of eipTypes[key]) {
|
|
76
|
+
if (Object.keys(msg).length > eipTypes[key].length) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
let value = msg[name];
|
|
80
|
+
if (!isNonZeroField(value)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const typeIsArray = type.includes('[]');
|
|
84
|
+
if (typeIsArray) {
|
|
85
|
+
type = type.split('[]')[0];
|
|
86
|
+
//Assumption: Take first value in array to determine which fields are populated
|
|
87
|
+
value = value[0];
|
|
88
|
+
}
|
|
89
|
+
if (eipTypes[type]) {
|
|
90
|
+
match = compareValues(value, type, eipTypes);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return match;
|
|
94
|
+
}
|
|
95
|
+
function getMsgValueType(msgTypeUrl, msgValue, msgTypeName, msgTypeIndex, types, objectName, nestedType = false, msgTypeDefinitions = {}) {
|
|
96
|
+
const packageName = msgTypeUrl.split(".").slice(0, -1).join(".");
|
|
97
|
+
const msgFieldType = msgTypeUrl.split(".").pop();
|
|
98
|
+
const typeName = getTypeName(msgTypeName, msgTypeIndex, objectName, nestedType, false);
|
|
99
|
+
const fieldsDefinition = codec_1.EIP712Types[packageName][msgFieldType];
|
|
100
|
+
if (isNonZeroField(msgValue)) {
|
|
101
|
+
if (!msgTypeDefinitions[typeName]) {
|
|
102
|
+
msgTypeDefinitions[typeName] = [];
|
|
103
|
+
}
|
|
104
|
+
fieldsDefinition.forEach(({ packageName, name, type }) => {
|
|
105
|
+
if (Array.isArray(msgValue) && msgValue.length === 0) {
|
|
106
|
+
msgTypeDefinitions[typeName] = [...msgTypeDefinitions[typeName], { name, type: 'string[]' }];
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
//Assumption: Take first value in array to determine which fields are populated
|
|
110
|
+
const fieldValue = Array.isArray(msgValue) && msgValue.length > 0 ? msgValue[0][name] : msgValue[name];
|
|
111
|
+
if (isNonZeroField(fieldValue)) {
|
|
112
|
+
//For nested structs
|
|
113
|
+
if (packageName) {
|
|
114
|
+
const isArray = type.includes('[]') ? true : false;
|
|
115
|
+
// TypeValue0 --> Value
|
|
116
|
+
const objectName = typeName.split('Type')[1].split(`${msgTypeIndex}`)[0];
|
|
117
|
+
const nestedTypeName = `Type${objectName ? objectName : ''}${name.split('_').map((subName) => lodash_1.capitalize(subName)).join('')}`;
|
|
118
|
+
const nestedMsgTypeIndex = getLatestMsgTypeIndex(nestedTypeName, types);
|
|
119
|
+
const nestedType = getTypeName(name, nestedMsgTypeIndex, objectName, true, isArray);
|
|
120
|
+
msgTypeDefinitions[typeName] = [...msgTypeDefinitions[typeName], { name, type: nestedType }];
|
|
121
|
+
//Special logic if nested struct is google protobuf's Any type
|
|
122
|
+
if (isGoogleProtobufAnyPackage(packageName, type)) {
|
|
123
|
+
const nestedAnyTypeName = isArray ? nestedType.split('[]')[0].split(`${msgTypeIndex}`)[0] : nestedType.split(`${msgTypeIndex}`)[0];
|
|
124
|
+
const nestedMsgTypeIndex = getLatestMsgTypeIndex(`${nestedAnyTypeName}Value`, types);
|
|
125
|
+
const nestedAnyValueType = `${nestedAnyTypeName}Value${nestedMsgTypeIndex}`;
|
|
126
|
+
msgTypeDefinitions[`${nestedAnyTypeName}${msgTypeIndex}`] = [{ name: "type", type: "string" }, { name: "value", type: nestedAnyValueType }];
|
|
127
|
+
const anyObjectTypeNameSplit = nestedAnyTypeName.split('Type')[1].split(`${msgTypeIndex}`)[0];
|
|
128
|
+
const messageTypeUrl = AminoTypesMap_1.default.fromAmino(fieldValue).typeUrl;
|
|
129
|
+
getMsgValueType(messageTypeUrl, fieldValue.value, "value", nestedMsgTypeIndex, types, anyObjectTypeNameSplit, true, msgTypeDefinitions);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const typeStructName = type.includes('[]') ? type.split('[]')[0].split(`${nestedMsgTypeIndex}`)[0] : type.split(`${nestedMsgTypeIndex}`)[0];
|
|
133
|
+
const messageTypeUrl = `${packageName}.${typeStructName}`;
|
|
134
|
+
getMsgValueType(messageTypeUrl, fieldValue, name, nestedMsgTypeIndex, types, objectName, true, msgTypeDefinitions);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
msgTypeDefinitions[typeName] = [...msgTypeDefinitions[typeName], { name, type: getGjsonPrimitiveType(fieldValue) }];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return msgTypeDefinitions;
|
|
144
|
+
}
|
|
145
|
+
function getGjsonPrimitiveType(value) {
|
|
146
|
+
if (typeof value === 'number') {
|
|
147
|
+
return 'int64';
|
|
148
|
+
}
|
|
149
|
+
if (typeof value === 'boolean') {
|
|
150
|
+
return 'bool';
|
|
151
|
+
}
|
|
152
|
+
return 'string';
|
|
153
|
+
}
|
|
154
|
+
function getTypeName(name, index, objectName, nestedType = false, isArray = false) {
|
|
155
|
+
if (nestedType) {
|
|
156
|
+
return `Type${objectName ? objectName : ''}${name.split('_').map(subName => lodash_1.capitalize(subName)).join('')}${index}${isArray ? '[]' : ''}`;
|
|
157
|
+
}
|
|
158
|
+
return name;
|
|
159
|
+
}
|
|
160
|
+
function isGoogleProtobufAnyPackage(packageName, type) {
|
|
161
|
+
return packageName === '/google.protobuf' && type == 'Any';
|
|
162
|
+
}
|
|
163
|
+
function isNonZeroField(fieldValue) {
|
|
164
|
+
// zero fields are considered falsey,except if it is string "0"
|
|
165
|
+
if (fieldValue == "0" && typeof fieldValue !== "string") {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
// empty arrays are considered truthy
|
|
169
|
+
if (Array.isArray(fieldValue)) {
|
|
170
|
+
return fieldValue.length !== 0;
|
|
171
|
+
}
|
|
172
|
+
// empty objects are considered truthy
|
|
173
|
+
if (fieldValue && typeof fieldValue === 'object' && Object.keys(fieldValue).length === 0) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return fieldValue;
|
|
177
|
+
}
|
|
178
|
+
function constructEIP712Tx(doc) {
|
|
179
|
+
const { account_number, chain_id, fee, memo, sequence } = doc;
|
|
180
|
+
const eip712Tx = {
|
|
181
|
+
types: getTypes(doc.msgs),
|
|
182
|
+
primaryType: "Tx",
|
|
183
|
+
domain: Object.assign(Object.assign({}, eip712_1.DEFAULT_CARBON_DOMAIN_FIELDS), { chainId: ethermint_1.parseChainId(doc.chain_id) }),
|
|
184
|
+
message: Object.assign({ account_number, chain_id, fee, memo, sequence }, convertMsgs(doc.msgs))
|
|
185
|
+
};
|
|
186
|
+
return eip712Tx;
|
|
187
|
+
}
|
|
188
|
+
exports.constructEIP712Tx = constructEIP712Tx;
|
|
189
|
+
function convertMsgs(msgs) {
|
|
190
|
+
const convertedMsgs = {};
|
|
191
|
+
msgs.forEach((msg, index) => {
|
|
192
|
+
convertedMsgs[`msg${index}`] = msg;
|
|
193
|
+
});
|
|
194
|
+
return convertedMsgs;
|
|
195
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import CarbonSDK from "../CarbonSDK";
|
|
2
|
+
import { Any } from "../codec";
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
|
+
export declare const ETH_SECP256K1_TYPE = "/ethermint.crypto.v1.ethsecp256k1.PubKey";
|
|
5
|
+
export declare const PUBLIC_KEY_SIGNING_TEXT = "Sign your public key to merge your Carbon account: ";
|
|
6
|
+
export declare function encodeAnyEthSecp256k1PubKey(pubkey: Uint8Array): Any;
|
|
7
|
+
export declare function parseChainId(evmChainId: string): string;
|
|
8
|
+
export declare function populateEvmTransactionDetails(api: CarbonSDK, req: ethers.providers.TransactionRequest): Promise<ethers.providers.TransactionRequest>;
|
|
@@ -0,0 +1,68 @@
|
|
|
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.populateEvmTransactionDetails = exports.parseChainId = exports.encodeAnyEthSecp256k1PubKey = exports.PUBLIC_KEY_SIGNING_TEXT = exports.ETH_SECP256K1_TYPE = void 0;
|
|
13
|
+
const codec_1 = require("../codec");
|
|
14
|
+
const keys_1 = require("../codec/ethermint/crypto/v1/ethsecp256k1/keys");
|
|
15
|
+
exports.ETH_SECP256K1_TYPE = '/ethermint.crypto.v1.ethsecp256k1.PubKey';
|
|
16
|
+
exports.PUBLIC_KEY_SIGNING_TEXT = 'Sign your public key to merge your Carbon account: ';
|
|
17
|
+
function encodeAnyEthSecp256k1PubKey(pubkey) {
|
|
18
|
+
const ethPubKey = keys_1.PubKey.fromPartial({
|
|
19
|
+
key: pubkey,
|
|
20
|
+
});
|
|
21
|
+
return codec_1.Any.fromPartial({
|
|
22
|
+
typeUrl: exports.ETH_SECP256K1_TYPE,
|
|
23
|
+
value: keys_1.PubKey.encode(ethPubKey).finish(),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.encodeAnyEthSecp256k1PubKey = encodeAnyEthSecp256k1PubKey;
|
|
27
|
+
function parseChainId(evmChainId) {
|
|
28
|
+
const chainId = evmChainId.trim();
|
|
29
|
+
if (chainId.length > 48) {
|
|
30
|
+
throw new Error(`chain-id '${chainId}' cannot exceed 48 chars`);
|
|
31
|
+
}
|
|
32
|
+
if (!chainId.match(/^[a-z]+_\d+-\d+$/)) {
|
|
33
|
+
throw new Error(`chain-id '${chainId}' does not conform to the required format`);
|
|
34
|
+
}
|
|
35
|
+
return chainId.split("_")[1].split("-")[0];
|
|
36
|
+
}
|
|
37
|
+
exports.parseChainId = parseChainId;
|
|
38
|
+
function populateEvmTransactionDetails(api, req) {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const provider = api.evmJsonRpc;
|
|
42
|
+
const evmHexAddress = (_b = (_a = api.wallet) === null || _a === void 0 ? void 0 : _a.evmHexAddress) !== null && _b !== void 0 ? _b : '';
|
|
43
|
+
let request = {
|
|
44
|
+
to: (_c = req.to) !== null && _c !== void 0 ? _c : '',
|
|
45
|
+
from: (_d = req.from) !== null && _d !== void 0 ? _d : (_e = api.wallet) === null || _e === void 0 ? void 0 : _e.evmHexAddress,
|
|
46
|
+
nonce: (_f = req.nonce) !== null && _f !== void 0 ? _f : (yield provider.getTransactionCount(evmHexAddress)),
|
|
47
|
+
data: req.data,
|
|
48
|
+
value: `0x${Number(req.value).toString(16)}`,
|
|
49
|
+
chainId: (_g = req.chainId) !== null && _g !== void 0 ? _g : Number(parseChainId(yield ((_h = api.wallet) === null || _h === void 0 ? void 0 : _h.getEvmChainId()))),
|
|
50
|
+
// type = 0, 1 or 2 where 0 = legacyTx, 1 = AccessListTx, 2 = DynamicTx. Defaults to DynamicTx
|
|
51
|
+
type: (_j = req.type) !== null && _j !== void 0 ? _j : 2,
|
|
52
|
+
accessList: req.accessList,
|
|
53
|
+
};
|
|
54
|
+
const gasLimit = (yield provider.estimateGas(request)).toHexString();
|
|
55
|
+
const gasFee = yield provider.getFeeData();
|
|
56
|
+
if (!req.gasPrice) {
|
|
57
|
+
// Dynamic Tx
|
|
58
|
+
return Object.assign(Object.assign({}, request), { maxPriorityFeePerGas: (_k = req.maxPriorityFeePerGas) !== null && _k !== void 0 ? _k : (_l = gasFee.maxPriorityFeePerGas) === null || _l === void 0 ? void 0 : _l.toHexString(), maxFeePerGas: (_m = req.maxFeePerGas) !== null && _m !== void 0 ? _m : (_o = gasFee.maxFeePerGas) === null || _o === void 0 ? void 0 : _o.toHexString(), gasLimit, type: 2 });
|
|
59
|
+
}
|
|
60
|
+
if (req.accessList) {
|
|
61
|
+
// AccessList Tx
|
|
62
|
+
return Object.assign(Object.assign({}, request), { gasLimit, type: 1 });
|
|
63
|
+
}
|
|
64
|
+
// LegacyTx
|
|
65
|
+
return Object.assign(Object.assign({}, request), { gasLimit, type: 0 });
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports.populateEvmTransactionDetails = populateEvmTransactionDetails;
|
package/lib/util/fetch.js
CHANGED
package/lib/util/generic.js
CHANGED
|
@@ -22,7 +22,7 @@ const overrideConfig = (defaults, override) => {
|
|
|
22
22
|
continue;
|
|
23
23
|
if (typeof member === "object") {
|
|
24
24
|
// @ts-ignore
|
|
25
|
-
result[key] =
|
|
25
|
+
result[key] = exports.overrideConfig(result[key], member);
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
// @ts-ignore
|
|
@@ -41,7 +41,7 @@ const sortObject = (input) => {
|
|
|
41
41
|
Object.keys(input)
|
|
42
42
|
.sort()
|
|
43
43
|
// @ts-ignore noImplicitAny
|
|
44
|
-
.forEach((key) => (output[key] =
|
|
44
|
+
.forEach((key) => (output[key] = exports.sortObject(input[key])));
|
|
45
45
|
return output;
|
|
46
46
|
};
|
|
47
47
|
exports.sortObject = sortObject;
|
|
@@ -56,7 +56,7 @@ exports.appendHexPrefix = appendHexPrefix;
|
|
|
56
56
|
const computeTxHash = (bytes) => {
|
|
57
57
|
if (!bytes)
|
|
58
58
|
return bytes;
|
|
59
|
-
return
|
|
59
|
+
return exports.toTxHash(crypto_1.sha256(bytes));
|
|
60
60
|
};
|
|
61
61
|
exports.computeTxHash = computeTxHash;
|
|
62
62
|
const toTxHash = (bytes) => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StdSignDoc } from "@cosmjs/amino/build";
|
|
2
|
+
import { TypedDataDomain, TypedDataField } from "@ethersproject/abstract-signer";
|
|
3
|
+
import { TypeUtils } from ".";
|
|
4
|
+
import { Coin } from "@cosmjs/proto-signing";
|
|
5
|
+
export interface LegacyEIP712Tx {
|
|
6
|
+
readonly types: TypeUtils.SimpleMap<TypedDataField[]>;
|
|
7
|
+
readonly primaryType: string;
|
|
8
|
+
readonly domain: TypedDataDomain;
|
|
9
|
+
readonly message: LegacyEIP712StdSignDoc;
|
|
10
|
+
}
|
|
11
|
+
export declare type EIP712Fee = {
|
|
12
|
+
readonly amount: readonly Coin[];
|
|
13
|
+
readonly gas: string;
|
|
14
|
+
readonly feePayer: string;
|
|
15
|
+
};
|
|
16
|
+
declare type LegacyEIP712StdSignDoc = StdSignDoc & {
|
|
17
|
+
fee: EIP712Fee;
|
|
18
|
+
};
|
|
19
|
+
export declare function legacyConstructEIP712Tx(doc: LegacyEIP712StdSignDoc): LegacyEIP712Tx;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.legacyConstructEIP712Tx = void 0;
|
|
7
|
+
const eip712_1 = require("../constant/eip712");
|
|
8
|
+
const ethermint_1 = require("../util/ethermint");
|
|
9
|
+
const codec_1 = require("../codec");
|
|
10
|
+
const AminoTypesMap_1 = __importDefault(require("../provider/amino/AminoTypesMap"));
|
|
11
|
+
const lodash_1 = require("lodash");
|
|
12
|
+
function getTypes(msgTypeUrl, aminoMsgValue) {
|
|
13
|
+
return Object.assign(Object.assign({}, eip712_1.LEGACY_DEFAULT_EIP712_TYPES), getMsgValueType(msgTypeUrl, aminoMsgValue, "MsgValue"));
|
|
14
|
+
}
|
|
15
|
+
function getMsgValueType(msgTypeUrl, msgValue, msgTypeName, objectName, nestedType = false, msgTypeDefinitions = {}) {
|
|
16
|
+
const packageName = msgTypeUrl.split(".").slice(0, -1).join(".");
|
|
17
|
+
const msgFieldType = msgTypeUrl.split(".").pop();
|
|
18
|
+
const typeName = getTypeName(msgTypeName, objectName, nestedType, false);
|
|
19
|
+
const fieldsDefinition = codec_1.EIP712Types[packageName][msgFieldType];
|
|
20
|
+
if (isNonZeroField(msgValue)) {
|
|
21
|
+
if (!msgTypeDefinitions[typeName]) {
|
|
22
|
+
msgTypeDefinitions[typeName] = [];
|
|
23
|
+
}
|
|
24
|
+
fieldsDefinition.forEach(({ packageName, name, type }) => {
|
|
25
|
+
let fieldValue;
|
|
26
|
+
if (Array.isArray(msgValue)) {
|
|
27
|
+
//Assumption: Take first value in array to determine which fields are populated
|
|
28
|
+
fieldValue = msgValue.length > 0 ? msgValue[0][name] : [];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
fieldValue = msgValue[name];
|
|
32
|
+
}
|
|
33
|
+
if (isNonZeroField(fieldValue)) {
|
|
34
|
+
//For nested structs
|
|
35
|
+
if (packageName) {
|
|
36
|
+
const isArray = type.includes('[]') ? true : false;
|
|
37
|
+
const objectName = typeName === 'MsgValue' ? 'MsgValue' : typeName.split('Type')[1];
|
|
38
|
+
const nestedType = getTypeName(name, objectName, true, isArray);
|
|
39
|
+
msgTypeDefinitions[typeName] = [...msgTypeDefinitions[typeName], { name, type: nestedType }];
|
|
40
|
+
//Special logic if nested struct is google protobuf's Any type
|
|
41
|
+
if (isGoogleProtobufAnyPackage(packageName, type)) {
|
|
42
|
+
const nestedAnyTypeName = isArray ? nestedType.split('[]')[0] : nestedType;
|
|
43
|
+
const nestedAnyValueType = `${nestedAnyTypeName}Value`;
|
|
44
|
+
msgTypeDefinitions[nestedAnyTypeName] = [{ name: "type", type: "string" }, { name: "value", type: nestedAnyValueType }];
|
|
45
|
+
const anyObjectTypeNameSplit = nestedAnyTypeName.split('Type')[1];
|
|
46
|
+
const messageTypeUrl = AminoTypesMap_1.default.fromAmino(fieldValue).typeUrl;
|
|
47
|
+
getMsgValueType(messageTypeUrl, fieldValue.value, "value", anyObjectTypeNameSplit, true, msgTypeDefinitions);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const typeStructName = type.includes('[]') ? type.split('[]')[0] : type;
|
|
51
|
+
const messageTypeUrl = `${packageName}.${typeStructName}`;
|
|
52
|
+
getMsgValueType(messageTypeUrl, fieldValue, name, objectName, true, msgTypeDefinitions);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
msgTypeDefinitions[typeName] = [...msgTypeDefinitions[typeName], { name, type }];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return msgTypeDefinitions;
|
|
62
|
+
}
|
|
63
|
+
function getTypeName(name, objectName, nestedType = false, isArray = false) {
|
|
64
|
+
if (nestedType) {
|
|
65
|
+
return `Type${objectName === 'MsgValue' ? '' : objectName}${name.split('_').map(subName => lodash_1.capitalize(subName)).join('')}${isArray ? '[]' : ''}`;
|
|
66
|
+
}
|
|
67
|
+
return name;
|
|
68
|
+
}
|
|
69
|
+
function isGoogleProtobufAnyPackage(packageName, type) {
|
|
70
|
+
return packageName === '/google.protobuf' && type == 'Any';
|
|
71
|
+
}
|
|
72
|
+
function isNonZeroField(fieldValue) {
|
|
73
|
+
// zero fields are considered falsey
|
|
74
|
+
if (fieldValue == "0") {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
// empty arrays are considered truthy
|
|
78
|
+
if (Array.isArray(fieldValue)) {
|
|
79
|
+
return fieldValue.length !== 0;
|
|
80
|
+
}
|
|
81
|
+
// empty objects are considered truthy
|
|
82
|
+
if (fieldValue && typeof fieldValue === 'object' && Object.keys(fieldValue).length === 0) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return fieldValue;
|
|
86
|
+
}
|
|
87
|
+
function legacyConstructEIP712Tx(doc) {
|
|
88
|
+
// Legacy EIP-712 can only accept batch msgs of the same type
|
|
89
|
+
const msg = doc.msgs[0];
|
|
90
|
+
const eip712Tx = {
|
|
91
|
+
types: getTypes(AminoTypesMap_1.default.fromAmino(msg).typeUrl, msg.value),
|
|
92
|
+
primaryType: "Tx",
|
|
93
|
+
domain: Object.assign(Object.assign({}, eip712_1.DEFAULT_CARBON_DOMAIN_FIELDS), { chainId: ethermint_1.parseChainId(doc.chain_id) }),
|
|
94
|
+
message: doc
|
|
95
|
+
};
|
|
96
|
+
return eip712Tx;
|
|
97
|
+
}
|
|
98
|
+
exports.legacyConstructEIP712Tx = legacyConstructEIP712Tx;
|
package/lib/util/number.js
CHANGED
|
@@ -18,26 +18,26 @@ const parseBN = (input, defaultValue) => {
|
|
|
18
18
|
};
|
|
19
19
|
exports.parseBN = parseBN;
|
|
20
20
|
const bnOrZero = (input, defaultValue = exports.BN_ZERO) => {
|
|
21
|
-
return
|
|
21
|
+
return exports.parseBN(input, defaultValue);
|
|
22
22
|
};
|
|
23
23
|
exports.bnOrZero = bnOrZero;
|
|
24
24
|
const toHuman = (value, decimals) => {
|
|
25
25
|
if (value === undefined || value === null)
|
|
26
26
|
return undefined;
|
|
27
|
-
const valueBN =
|
|
27
|
+
const valueBN = exports.bnOrZero(value);
|
|
28
28
|
if (!decimals)
|
|
29
29
|
return valueBN; // decimals = 0 or nullish
|
|
30
|
-
const decimalsBN =
|
|
30
|
+
const decimalsBN = exports.bnOrZero(decimals);
|
|
31
31
|
return valueBN.shiftedBy(decimalsBN.negated().toNumber());
|
|
32
32
|
};
|
|
33
33
|
exports.toHuman = toHuman;
|
|
34
34
|
const toUnitless = (value, decimals) => {
|
|
35
35
|
if (value === undefined || value === null)
|
|
36
36
|
return undefined;
|
|
37
|
-
const valueBN =
|
|
37
|
+
const valueBN = exports.bnOrZero(value);
|
|
38
38
|
if (!decimals)
|
|
39
39
|
return valueBN; // decimals = 0 or nullish
|
|
40
|
-
const decimalsBN =
|
|
40
|
+
const decimalsBN = exports.bnOrZero(decimals);
|
|
41
41
|
return valueBN.shiftedBy(decimalsBN.toNumber());
|
|
42
42
|
};
|
|
43
43
|
exports.toUnitless = toUnitless;
|
|
@@ -106,9 +106,9 @@ class CarbonLedgerSigner {
|
|
|
106
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
107
|
const account = yield this.retrieveAccount();
|
|
108
108
|
const { pubkey } = account;
|
|
109
|
-
const msg = JSON.stringify(
|
|
109
|
+
const msg = JSON.stringify(generic_1.sortObject(doc));
|
|
110
110
|
const signBytes = yield this.ledger.sign(msg);
|
|
111
|
-
const signature =
|
|
111
|
+
const signature = amino_1.encodeSecp256k1Signature(pubkey, signBytes);
|
|
112
112
|
return {
|
|
113
113
|
signed: doc,
|
|
114
114
|
signature,
|
|
@@ -87,7 +87,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
87
87
|
*/
|
|
88
88
|
sign(signerAddress, messages, fee, memo, signerData) {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
return
|
|
90
|
+
return proto_signing_1.isOfflineDirectSigner(this.signer)
|
|
91
91
|
? this.signDirect(signerAddress, messages, fee, memo, signerData)
|
|
92
92
|
: this.signAmino(signerAddress, messages, fee, memo, signerData);
|
|
93
93
|
});
|
|
@@ -99,7 +99,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
99
99
|
if (!accountFromSigner) {
|
|
100
100
|
throw new Error("Failed to retrieve account from signer");
|
|
101
101
|
}
|
|
102
|
-
const pubkey =
|
|
102
|
+
const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
|
103
103
|
const txBodyEncodeObject = {
|
|
104
104
|
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
105
105
|
value: Object.assign({ messages: messages, memo: memo }, (timeoutHeight && {
|
|
@@ -108,13 +108,13 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
108
108
|
};
|
|
109
109
|
const txBodyBytes = this.registry.encode(txBodyEncodeObject);
|
|
110
110
|
const gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
|
|
111
|
-
const authInfoBytes =
|
|
112
|
-
const signDoc =
|
|
111
|
+
const authInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit);
|
|
112
|
+
const signDoc = proto_signing_1.makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
|
113
113
|
const { signature, signed } = yield signer.signDirect(signerAddress, signDoc);
|
|
114
114
|
return tx_1.TxRaw.fromPartial({
|
|
115
115
|
bodyBytes: signed.bodyBytes,
|
|
116
116
|
authInfoBytes: signed.authInfoBytes,
|
|
117
|
-
signatures: [
|
|
117
|
+
signatures: [encoding_1.fromBase64(signature.signature)],
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -125,7 +125,7 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
125
125
|
if (!accountFromSigner) {
|
|
126
126
|
throw new Error("Failed to retrieve account from signer");
|
|
127
127
|
}
|
|
128
|
-
const pubkey =
|
|
128
|
+
const pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
|
129
129
|
const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
130
130
|
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
|
|
131
131
|
const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight !== null && timeoutHeight !== void 0 ? timeoutHeight : 0);
|
|
@@ -140,11 +140,11 @@ class CarbonSigningClient extends stargate_1.StargateClient {
|
|
|
140
140
|
const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
|
|
141
141
|
const signedGasLimit = math_1.Int53.fromString(signed.fee.gas).toNumber();
|
|
142
142
|
const signedSequence = math_1.Int53.fromString(signed.sequence).toNumber();
|
|
143
|
-
const signedAuthInfoBytes =
|
|
143
|
+
const signedAuthInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, signMode);
|
|
144
144
|
return tx_1.TxRaw.fromPartial({
|
|
145
145
|
bodyBytes: signedTxBodyBytes,
|
|
146
146
|
authInfoBytes: signedAuthInfoBytes,
|
|
147
|
-
signatures: [
|
|
147
|
+
signatures: [encoding_1.fromBase64(signature.signature)],
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
150
|
}
|
|
@@ -150,7 +150,7 @@ class CarbonWallet {
|
|
|
150
150
|
const signerData = Object.assign({ accountNumber: this.accountInfo.accountNumber, chainId: this.getChainId(), sequence }, explicitSignerData);
|
|
151
151
|
const fee = (_a = opts === null || opts === void 0 ? void 0 : opts.fee) !== null && _a !== void 0 ? _a : this.estimateTxFee(messages, feeDenom);
|
|
152
152
|
const txRaw = yield signingClient.sign(signerAddress, messages, fee, memo, signerData);
|
|
153
|
-
signature =
|
|
153
|
+
signature = amino_1.encodeSecp256k1Signature(account.pubkey, txRaw.signatures[0]);
|
|
154
154
|
return txRaw;
|
|
155
155
|
}
|
|
156
156
|
finally {
|
|
@@ -168,7 +168,7 @@ class CarbonWallet {
|
|
|
168
168
|
const tx = CarbonWallet.TxRaw.encode(txRaw).finish();
|
|
169
169
|
const carbonClient = this.getSigningClient();
|
|
170
170
|
const response = yield carbonClient.broadcastTx(tx, timeoutMs, pollIntervalMs);
|
|
171
|
-
if (
|
|
171
|
+
if (stargate_1.isDeliverTxFailure(response)) {
|
|
172
172
|
// tx failed
|
|
173
173
|
throw new tx_1.CarbonTxError(`[${response.code}] ${response.rawLog}`, response);
|
|
174
174
|
}
|
|
@@ -207,9 +207,9 @@ class CarbonWallet {
|
|
|
207
207
|
try {
|
|
208
208
|
if (!this.accountInfo || this.sequenceInvalidated)
|
|
209
209
|
yield this.reloadAccountSequence();
|
|
210
|
-
const heightResponse = yield
|
|
210
|
+
const heightResponse = yield fetch_1.fetch(`${this.networkConfig.tmRpcUrl}/blockchain?cache=${new Date().getTime()}`);
|
|
211
211
|
const heightRes = yield heightResponse.json();
|
|
212
|
-
const height =
|
|
212
|
+
const height = number_1.bnOrZero((_a = heightRes.result) === null || _a === void 0 ? void 0 : _a.last_height);
|
|
213
213
|
const timeoutHeight = height.isZero() ? undefined : height.toNumber() + this.defaultTimeoutBlocks;
|
|
214
214
|
const sequence = this.accountInfo.sequence;
|
|
215
215
|
this.accountInfo = Object.assign(Object.assign({}, this.accountInfo), { sequence: sequence + 1 });
|
|
@@ -343,12 +343,12 @@ class CarbonWallet {
|
|
|
343
343
|
const queryClient = this.getQueryClient();
|
|
344
344
|
const { msgGasCosts } = yield queryClient.fee.MsgGasCostAll({});
|
|
345
345
|
this.txGasCosts = msgGasCosts.reduce((result, item) => {
|
|
346
|
-
result[item.msgType] =
|
|
346
|
+
result[item.msgType] = number_1.bnOrZero(item.gasCost);
|
|
347
347
|
return result;
|
|
348
348
|
}, {});
|
|
349
349
|
const { minGasPrices } = yield queryClient.fee.MinGasPriceAll({});
|
|
350
350
|
this.txGasPrices = minGasPrices.reduce((result, item) => {
|
|
351
|
-
result[item.denom] =
|
|
351
|
+
result[item.denom] = number_1.bnOrZero(item.gasPrice).shiftedBy(-18); // sdk.Dec shifting
|
|
352
352
|
return result;
|
|
353
353
|
}, {});
|
|
354
354
|
if (!this.txGasPrices[this.defaultFeeDenom]) {
|
|
@@ -171,7 +171,7 @@ class WSConnector {
|
|
|
171
171
|
params = [params]; // eslint-disable-line no-param-reassign
|
|
172
172
|
}
|
|
173
173
|
for (const param of params) {
|
|
174
|
-
const channelId =
|
|
174
|
+
const channelId = channel_1.generateChannelId(param);
|
|
175
175
|
const shouldSubscribe = this.channelHandlers[channelId] === undefined;
|
|
176
176
|
this.channelHandlers[channelId] = handler;
|
|
177
177
|
if (shouldSubscribe) {
|
|
@@ -193,7 +193,7 @@ class WSConnector {
|
|
|
193
193
|
}
|
|
194
194
|
const channelIds = [];
|
|
195
195
|
for (const param of params) {
|
|
196
|
-
const channelId =
|
|
196
|
+
const channelId = channel_1.generateChannelId(param);
|
|
197
197
|
const shouldUnsubscribe = this.channelHandlers[channelId] !== undefined;
|
|
198
198
|
delete this.channelHandlers[channelId];
|
|
199
199
|
if (shouldUnsubscribe) {
|
|
@@ -281,7 +281,7 @@ class WSConnector {
|
|
|
281
281
|
if (!channelHandler) {
|
|
282
282
|
this.debugLog(`handler not found for channel: ${message.channel}`);
|
|
283
283
|
try {
|
|
284
|
-
const params =
|
|
284
|
+
const params = channel_1.parseChannelId(message.channel);
|
|
285
285
|
this.unsubscribe({ channel: params.channel });
|
|
286
286
|
}
|
|
287
287
|
catch (error) {
|