carbon-js-sdk 0.3.43-dev.1 → 0.3.43-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +1 -1
- package/lib/clients/ZILClient.js +17 -17
- package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/tx/v1beta1/tx.js +2 -2
- package/lib/codec/index.d.ts +2 -2
- package/lib/codec/index.js +10 -6
- package/lib/codec/liquiditypool/event.d.ts +14 -0
- package/lib/codec/liquiditypool/event.js +107 -1
- package/lib/codec/liquiditypool/query.d.ts +71 -34
- package/lib/codec/liquiditypool/query.js +304 -112
- package/lib/codec/liquiditypool/tx.d.ts +0 -1
- package/lib/codec/liquiditypool/tx.js +1 -18
- package/lib/constant/generic.js +1 -1
- package/lib/modules/cdp.js +43 -43
- package/lib/modules/gov.js +12 -12
- package/lib/modules/liquiditypool.d.ts +0 -1
- package/lib/modules/liquiditypool.js +1 -2
- 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 +28 -28
- 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 +22 -22
- package/lib/provider/amino/types/coin.js +4 -4
- package/lib/provider/amino/types/gov.js +4 -12
- 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 -9
- package/lib/provider/amino/types/market.js +1 -1
- 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/o3/O3Wallet.js +2 -2
- package/lib/util/address.js +13 -13
- package/lib/util/api.js +4 -4
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- 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/lib/websocket/models.d.ts +7 -2
- package/package.json +1 -1
|
@@ -29,6 +29,6 @@ const MsgInitiateLiquidation = {
|
|
|
29
29
|
valueMap: {},
|
|
30
30
|
};
|
|
31
31
|
const BrokerAmino = {
|
|
32
|
-
[CarbonTx.Types.MsgInitiateLiquidation]:
|
|
32
|
+
[CarbonTx.Types.MsgInitiateLiquidation]: utils_1.generateAminoType(MsgInitiateLiquidation),
|
|
33
33
|
};
|
|
34
34
|
exports.default = BrokerAmino;
|
|
@@ -145,27 +145,27 @@ const MsgSetCdpPaused = {
|
|
|
145
145
|
valueMap: {},
|
|
146
146
|
};
|
|
147
147
|
const CdpAmino = {
|
|
148
|
-
[CarbonTx.Types.MsgSupplyAsset]:
|
|
149
|
-
[CarbonTx.Types.MsgWithdrawAsset]:
|
|
150
|
-
[CarbonTx.Types.MsgLockCollateral]:
|
|
151
|
-
[CarbonTx.Types.MsgUnlockCollateral]:
|
|
152
|
-
[CarbonTx.Types.MsgBorrowAsset]:
|
|
153
|
-
[CarbonTx.Types.MsgRepayAsset]:
|
|
154
|
-
[CarbonTx.Types.MsgSupplyAssetAndLockCollateral]:
|
|
155
|
-
[CarbonTx.Types.MsgUnlockCollateralAndWithdrawAsset]:
|
|
156
|
-
[CarbonTx.Types.MsgLiquidateCollateral]:
|
|
157
|
-
[CarbonTx.Types.MsgRepayAssetWithCdpTokens]:
|
|
158
|
-
[CarbonTx.Types.MsgRepayAssetWithCollateral]:
|
|
159
|
-
[CarbonTx.Types.MsgMintStablecoin]:
|
|
160
|
-
[CarbonTx.Types.MsgReturnStablecoin]:
|
|
161
|
-
[CarbonTx.Types.MsgLiquidateCollateralWithCdpTokens]:
|
|
162
|
-
[CarbonTx.Types.MsgLiquidateCollateralWithCollateral]:
|
|
163
|
-
[CarbonTx.Types.MsgLiquidateCollateralWithStablecoin]:
|
|
164
|
-
[CarbonTx.Types.MsgCreateRewardScheme]:
|
|
165
|
-
[CarbonTx.Types.MsgUpdateRewardScheme]:
|
|
166
|
-
[CarbonTx.Types.MsgClaimRewards]:
|
|
167
|
-
[CarbonTx.Types.MsgSetStablecoinMintCap]:
|
|
168
|
-
[CarbonTx.Types.MsgSetStalePriceGracePeriod]:
|
|
169
|
-
[CarbonTx.Types.MsgSetCdpPaused]:
|
|
148
|
+
[CarbonTx.Types.MsgSupplyAsset]: utils_1.generateAminoType(MsgSupplyAsset),
|
|
149
|
+
[CarbonTx.Types.MsgWithdrawAsset]: utils_1.generateAminoType(MsgWithdrawAsset),
|
|
150
|
+
[CarbonTx.Types.MsgLockCollateral]: utils_1.generateAminoType(MsgLockCollateral),
|
|
151
|
+
[CarbonTx.Types.MsgUnlockCollateral]: utils_1.generateAminoType(MsgUnlockCollateral),
|
|
152
|
+
[CarbonTx.Types.MsgBorrowAsset]: utils_1.generateAminoType(MsgBorrowAsset),
|
|
153
|
+
[CarbonTx.Types.MsgRepayAsset]: utils_1.generateAminoType(MsgRepayAsset),
|
|
154
|
+
[CarbonTx.Types.MsgSupplyAssetAndLockCollateral]: utils_1.generateAminoType(MsgSupplyAssetAndLockCollateral),
|
|
155
|
+
[CarbonTx.Types.MsgUnlockCollateralAndWithdrawAsset]: utils_1.generateAminoType(MsgUnlockCollateralAndWithdrawAsset),
|
|
156
|
+
[CarbonTx.Types.MsgLiquidateCollateral]: utils_1.generateAminoType(MsgLiquidateCollateral),
|
|
157
|
+
[CarbonTx.Types.MsgRepayAssetWithCdpTokens]: utils_1.generateAminoType(MsgRepayAssetWithCdpTokens),
|
|
158
|
+
[CarbonTx.Types.MsgRepayAssetWithCollateral]: utils_1.generateAminoType(MsgRepayAssetWithCollateral),
|
|
159
|
+
[CarbonTx.Types.MsgMintStablecoin]: utils_1.generateAminoType(MsgMintStablecoin),
|
|
160
|
+
[CarbonTx.Types.MsgReturnStablecoin]: utils_1.generateAminoType(MsgReturnStablecoin),
|
|
161
|
+
[CarbonTx.Types.MsgLiquidateCollateralWithCdpTokens]: utils_1.generateAminoType(MsgLiquidateCollateralWithCdpTokens),
|
|
162
|
+
[CarbonTx.Types.MsgLiquidateCollateralWithCollateral]: utils_1.generateAminoType(MsgLiquidateCollateralWithCollateral),
|
|
163
|
+
[CarbonTx.Types.MsgLiquidateCollateralWithStablecoin]: utils_1.generateAminoType(MsgLiquidateCollateralWithStablecoin),
|
|
164
|
+
[CarbonTx.Types.MsgCreateRewardScheme]: utils_1.generateAminoType(MsgCreateRewardScheme),
|
|
165
|
+
[CarbonTx.Types.MsgUpdateRewardScheme]: utils_1.generateAminoType(MsgUpdateRewardScheme),
|
|
166
|
+
[CarbonTx.Types.MsgClaimRewards]: utils_1.generateAminoType(MsgClaimRewards),
|
|
167
|
+
[CarbonTx.Types.MsgSetStablecoinMintCap]: utils_1.generateAminoType(MsgSetStablecoinMintCap),
|
|
168
|
+
[CarbonTx.Types.MsgSetStalePriceGracePeriod]: utils_1.generateAminoType(MsgSetStalePriceGracePeriod),
|
|
169
|
+
[CarbonTx.Types.MsgSetCdpPaused]: utils_1.generateAminoType(MsgSetCdpPaused),
|
|
170
170
|
};
|
|
171
171
|
exports.default = CdpAmino;
|
|
@@ -44,9 +44,9 @@ const MsgWithdrawFromGroup = {
|
|
|
44
44
|
valueMap: {},
|
|
45
45
|
};
|
|
46
46
|
const CoinAmino = {
|
|
47
|
-
[CarbonTx.Types.MsgWithdraw]:
|
|
48
|
-
[CarbonTx.Types.MsgMintToken]:
|
|
49
|
-
[CarbonTx.Types.MsgDepositToGroup]:
|
|
50
|
-
[CarbonTx.Types.MsgWithdrawFromGroup]:
|
|
47
|
+
[CarbonTx.Types.MsgWithdraw]: utils_1.generateAminoType(MsgWithdraw),
|
|
48
|
+
[CarbonTx.Types.MsgMintToken]: utils_1.generateAminoType(MsgMintToken),
|
|
49
|
+
[CarbonTx.Types.MsgDepositToGroup]: utils_1.generateAminoType(MsgDepositToGroup),
|
|
50
|
+
[CarbonTx.Types.MsgWithdrawFromGroup]: utils_1.generateAminoType(MsgWithdrawFromGroup),
|
|
51
51
|
};
|
|
52
52
|
exports.default = CoinAmino;
|
|
@@ -142,14 +142,6 @@ const UpdateGroupConfig = {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
|
-
const ChangeNumQuotes = {
|
|
146
|
-
value: {
|
|
147
|
-
msg: {
|
|
148
|
-
poolId: utils_1.ConvertEncType.Long,
|
|
149
|
-
numQuotes: utils_1.ConvertEncType.Long,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
145
|
const UpdatePool = {
|
|
154
146
|
value: {
|
|
155
147
|
msg: {
|
|
@@ -225,7 +217,7 @@ const SettlementPrice = {
|
|
|
225
217
|
},
|
|
226
218
|
};
|
|
227
219
|
const preProcessAmino = (value, valueMap) => {
|
|
228
|
-
return
|
|
220
|
+
return utils_1.mapEachIndiv(value, valueMap, false);
|
|
229
221
|
};
|
|
230
222
|
const checkDecodeProposal = (content, amino) => {
|
|
231
223
|
const decodedValue = util_1.GovUtils.decodeContent(content);
|
|
@@ -445,8 +437,8 @@ const proposalAminoProcess = {
|
|
|
445
437
|
},
|
|
446
438
|
};
|
|
447
439
|
const GovAmino = {
|
|
448
|
-
[CarbonTx.Types.MsgSubmitProposal]:
|
|
449
|
-
[CarbonTx.Types.MsgDeposit]:
|
|
450
|
-
[CarbonTx.Types.MsgVote]:
|
|
440
|
+
[CarbonTx.Types.MsgSubmitProposal]: utils_1.generateAminoType(SubmitProposalMsg, proposalAminoProcess),
|
|
441
|
+
[CarbonTx.Types.MsgDeposit]: utils_1.generateAminoType(MsgDeposit),
|
|
442
|
+
[CarbonTx.Types.MsgVote]: utils_1.generateAminoType(MsgVote),
|
|
451
443
|
};
|
|
452
444
|
exports.default = GovAmino;
|
|
@@ -55,6 +55,6 @@ const pruneTransferProcess = {
|
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
57
|
const IbcAmino = {
|
|
58
|
-
[CarbonTx.Types.MsgTransfer]:
|
|
58
|
+
[CarbonTx.Types.MsgTransfer]: utils_1.generateAminoType(MsgTransfer, pruneTransferProcess),
|
|
59
59
|
};
|
|
60
60
|
exports.default = IbcAmino;
|
|
@@ -31,6 +31,6 @@ const MsgSetLeverage = {
|
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
const LeverageAmino = {
|
|
34
|
-
[CarbonTx.Types.MsgSetLeverage]:
|
|
34
|
+
[CarbonTx.Types.MsgSetLeverage]: utils_1.generateAminoType(MsgSetLeverage),
|
|
35
35
|
};
|
|
36
36
|
exports.default = LeverageAmino;
|
|
@@ -33,7 +33,6 @@ const TxTypes = {
|
|
|
33
33
|
const MsgCreatePool = {
|
|
34
34
|
aminoType: TxTypes.CreatePool,
|
|
35
35
|
valueMap: {
|
|
36
|
-
numQuotes: utils_1.ConvertEncType.Long,
|
|
37
36
|
swapFee: utils_1.ConvertEncType.Dec,
|
|
38
37
|
tokenAWeight: utils_1.ConvertEncType.Dec,
|
|
39
38
|
tokenBWeight: utils_1.ConvertEncType.Dec,
|
|
@@ -46,7 +45,6 @@ const MsgCreatePoolWithLiquidity = {
|
|
|
46
45
|
tokenAWeight: utils_1.ConvertEncType.Dec,
|
|
47
46
|
tokenBWeight: utils_1.ConvertEncType.Dec,
|
|
48
47
|
swapFee: utils_1.ConvertEncType.Dec,
|
|
49
|
-
numQuotes: utils_1.ConvertEncType.Long,
|
|
50
48
|
ampBps: utils_1.ConvertEncType.Long,
|
|
51
49
|
},
|
|
52
50
|
};
|
|
@@ -95,12 +93,12 @@ const commitTokensProcess = {
|
|
|
95
93
|
},
|
|
96
94
|
};
|
|
97
95
|
const LiquidityPoolAmino = {
|
|
98
|
-
[CarbonTx.Types.MsgCreatePool]:
|
|
99
|
-
[CarbonTx.Types.MsgCreatePoolWithLiquidity]:
|
|
100
|
-
[CarbonTx.Types.MsgAddLiquidity]:
|
|
101
|
-
[CarbonTx.Types.MsgRemoveLiquidity]:
|
|
102
|
-
[CarbonTx.Types.MsgStakePoolToken]:
|
|
103
|
-
[CarbonTx.Types.MsgUnstakePoolToken]:
|
|
104
|
-
[CarbonTx.Types.MsgClaimPoolRewards]:
|
|
96
|
+
[CarbonTx.Types.MsgCreatePool]: utils_1.generateAminoType(MsgCreatePool),
|
|
97
|
+
[CarbonTx.Types.MsgCreatePoolWithLiquidity]: utils_1.generateAminoType(MsgCreatePoolWithLiquidity),
|
|
98
|
+
[CarbonTx.Types.MsgAddLiquidity]: utils_1.generateAminoType(MsgAddLiquidity),
|
|
99
|
+
[CarbonTx.Types.MsgRemoveLiquidity]: utils_1.generateAminoType(MsgRemoveLiquidity),
|
|
100
|
+
[CarbonTx.Types.MsgStakePoolToken]: utils_1.generateAminoType(MsgStakePoolToken, commitTokensProcess),
|
|
101
|
+
[CarbonTx.Types.MsgUnstakePoolToken]: utils_1.generateAminoType(MsgUnstakePoolToken),
|
|
102
|
+
[CarbonTx.Types.MsgClaimPoolRewards]: utils_1.generateAminoType(MsgClaimPoolRewards),
|
|
105
103
|
};
|
|
106
104
|
exports.default = LiquidityPoolAmino;
|
|
@@ -41,6 +41,6 @@ const MsgUpdateMarket = {
|
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
const MarketAmino = {
|
|
44
|
-
[CarbonTx.Types.MsgUpdateMarket]:
|
|
44
|
+
[CarbonTx.Types.MsgUpdateMarket]: utils_1.generateAminoType(MsgUpdateMarket),
|
|
45
45
|
};
|
|
46
46
|
exports.default = MarketAmino;
|
|
@@ -76,9 +76,9 @@ const createOrderProcess = {
|
|
|
76
76
|
},
|
|
77
77
|
};
|
|
78
78
|
const OrderAmino = {
|
|
79
|
-
[CarbonTx.Types.MsgCreateOrder]:
|
|
80
|
-
[CarbonTx.Types.MsgCancelOrder]:
|
|
81
|
-
[CarbonTx.Types.MsgEditOrder]:
|
|
82
|
-
[CarbonTx.Types.MsgCancelAll]:
|
|
79
|
+
[CarbonTx.Types.MsgCreateOrder]: utils_1.generateAminoType(MsgCreateOrder, createOrderProcess),
|
|
80
|
+
[CarbonTx.Types.MsgCancelOrder]: utils_1.generateAminoType(MsgCancelOrder),
|
|
81
|
+
[CarbonTx.Types.MsgEditOrder]: utils_1.generateAminoType(MsgEditOrder),
|
|
82
|
+
[CarbonTx.Types.MsgCancelAll]: utils_1.generateAminoType(MsgCancelAll),
|
|
83
83
|
};
|
|
84
84
|
exports.default = OrderAmino;
|
|
@@ -29,6 +29,6 @@ const MsgSetMargin = {
|
|
|
29
29
|
valueMap: {},
|
|
30
30
|
};
|
|
31
31
|
const PositionAmino = {
|
|
32
|
-
[CarbonTx.Types.MsgSetMargin]:
|
|
32
|
+
[CarbonTx.Types.MsgSetMargin]: utils_1.generateAminoType(MsgSetMargin),
|
|
33
33
|
};
|
|
34
34
|
exports.default = PositionAmino;
|
|
@@ -45,6 +45,6 @@ const updateProfileProcess = {
|
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
const ProfileAmino = {
|
|
48
|
-
[CarbonTx.Types.MsgUpdateProfile]:
|
|
48
|
+
[CarbonTx.Types.MsgUpdateProfile]: utils_1.generateAminoType(MsgUpdateProfile, updateProfileProcess),
|
|
49
49
|
};
|
|
50
50
|
exports.default = ProfileAmino;
|
|
@@ -44,9 +44,9 @@ const MsgWithdrawDelegatorReward = {
|
|
|
44
44
|
valueMap: {},
|
|
45
45
|
};
|
|
46
46
|
const StakingAmino = {
|
|
47
|
-
[CarbonTx.Types.MsgDelegate]:
|
|
48
|
-
[CarbonTx.Types.MsgUndelegate]:
|
|
49
|
-
[CarbonTx.Types.MsgBeginRedelegate]:
|
|
50
|
-
[CarbonTx.Types.MsgWithdrawDelegatorReward]:
|
|
47
|
+
[CarbonTx.Types.MsgDelegate]: utils_1.generateAminoType(MsgDelegate),
|
|
48
|
+
[CarbonTx.Types.MsgUndelegate]: utils_1.generateAminoType(MsgUndelegate),
|
|
49
|
+
[CarbonTx.Types.MsgBeginRedelegate]: utils_1.generateAminoType(MsgBeginRedelegate),
|
|
50
|
+
[CarbonTx.Types.MsgWithdrawDelegatorReward]: utils_1.generateAminoType(MsgWithdrawDelegatorReward),
|
|
51
51
|
};
|
|
52
52
|
exports.default = StakingAmino;
|
|
@@ -39,8 +39,8 @@ const MsgRemoveSubAccount = {
|
|
|
39
39
|
valueMap: {},
|
|
40
40
|
};
|
|
41
41
|
const SubAccountAmino = {
|
|
42
|
-
[CarbonTx.Types.MsgCreateSubAccount]:
|
|
43
|
-
[CarbonTx.Types.MsgActivateSubAccount]:
|
|
44
|
-
[CarbonTx.Types.MsgRemoveSubAccount]:
|
|
42
|
+
[CarbonTx.Types.MsgCreateSubAccount]: utils_1.generateAminoType(MsgCreateSubAccount),
|
|
43
|
+
[CarbonTx.Types.MsgActivateSubAccount]: utils_1.generateAminoType(MsgActivateSubAccount),
|
|
44
|
+
[CarbonTx.Types.MsgRemoveSubAccount]: utils_1.generateAminoType(MsgRemoveSubAccount),
|
|
45
45
|
};
|
|
46
46
|
exports.default = SubAccountAmino;
|
|
@@ -44,23 +44,23 @@ const mapEachIndiv = (mapItem, valueKey, toAmino = false) => {
|
|
|
44
44
|
if (typeof keyMap !== "object") {
|
|
45
45
|
// Check if this is a Long/BigNumber/Buffer/Date/Duration obj or a non-object/array
|
|
46
46
|
if (typeCheck(mapItem[key]) || typeof mapItem[key] !== "object") {
|
|
47
|
-
directMap[altKey] =
|
|
47
|
+
directMap[altKey] = exports.paramConverter(mapItem[key], keyMap, toAmino);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
if (mapItem[key].length && typeof mapItem[key] === "object") {
|
|
52
52
|
// If value is an array of objects, iterate through objects and call mapToObj function
|
|
53
53
|
directMap[altKey] = mapItem[key].map((newMap) => {
|
|
54
|
-
return
|
|
54
|
+
return exports.mapEachIndiv(newMap, valueKey, toAmino);
|
|
55
55
|
});
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
if (util_1.TypeUtils.isDurationType(mapItem[key])) {
|
|
60
|
-
directMap[altKey] =
|
|
60
|
+
directMap[altKey] = exports.paramConverter(mapItem[key], keyMap, toAmino);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
directMap[altKey] =
|
|
63
|
+
directMap[altKey] = exports.mapEachIndiv(mapItem[key], keyMap, toAmino);
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
return directMap;
|
|
@@ -137,18 +137,18 @@ const generateAminoType = (amino, aminoProcess = {}) => {
|
|
|
137
137
|
if (!newInput[key])
|
|
138
138
|
return;
|
|
139
139
|
if (typeCheck(newInput[key])) {
|
|
140
|
-
aminoObj[snakeKey] =
|
|
140
|
+
aminoObj[snakeKey] = exports.paramConverter(newInput[key], newAminoMap[key], true);
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
if (typeof newInput[key] !== "object" && typeof newAminoMap[key] !== "object") {
|
|
144
|
-
aminoObj[snakeKey] =
|
|
144
|
+
aminoObj[snakeKey] = exports.paramConverter(newInput[key], newAminoMap[key], true);
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
147
|
if (((_a = newInput[key]) === null || _a === void 0 ? void 0 : _a.length) && typeof newInput[key] === "object") {
|
|
148
|
-
aminoObj[snakeKey] = newInput[key].map((newItem) =>
|
|
148
|
+
aminoObj[snakeKey] = newInput[key].map((newItem) => exports.mapEachIndiv(newItem, newAminoMap[key], true));
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
aminoObj[snakeKey] =
|
|
151
|
+
aminoObj[snakeKey] = exports.mapEachIndiv(newInput[key], newAminoMap[key], true);
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
return aminoObj;
|
|
@@ -162,14 +162,14 @@ const generateAminoType = (amino, aminoProcess = {}) => {
|
|
|
162
162
|
var _a;
|
|
163
163
|
const camelKey = util_1.TypeUtils.snakeToCamel(key);
|
|
164
164
|
if (typeof newInput[key] !== "object" && typeof newAminoMap[key] !== "object") {
|
|
165
|
-
aminoObj[camelKey] =
|
|
165
|
+
aminoObj[camelKey] = exports.paramConverter(newInput[key], newAminoMap[camelKey], false);
|
|
166
166
|
}
|
|
167
167
|
else {
|
|
168
168
|
if (((_a = newInput[key]) === null || _a === void 0 ? void 0 : _a.length) && typeof newInput[key] === "object") {
|
|
169
|
-
aminoObj[camelKey] = newInput[key].map((newItem) =>
|
|
169
|
+
aminoObj[camelKey] = newInput[key].map((newItem) => exports.mapEachIndiv(newItem, newAminoMap[camelKey], false));
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
aminoObj[camelKey] =
|
|
172
|
+
aminoObj[camelKey] = exports.mapEachIndiv(newInput[key], newAminoMap[camelKey], false);
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
return aminoObj;
|
|
@@ -147,7 +147,7 @@ class CosmosLedger {
|
|
|
147
147
|
const response = yield this.cosmosApp.getVersion();
|
|
148
148
|
this.checkLedgerErrors(response);
|
|
149
149
|
const { major, minor, patch, test_mode } = response;
|
|
150
|
-
|
|
150
|
+
exports.checkAppMode(this.testModeAllowed, test_mode);
|
|
151
151
|
const version = versionString({ major, minor, patch });
|
|
152
152
|
return version;
|
|
153
153
|
});
|
|
@@ -238,7 +238,7 @@ class CosmosLedger {
|
|
|
238
238
|
const response = yield this.cosmosApp.sign(this.hdPath, signMessage);
|
|
239
239
|
this.checkLedgerErrors(response);
|
|
240
240
|
// we have to parse the signature from Ledger as it's in DER format
|
|
241
|
-
const parsedSignature =
|
|
241
|
+
const parsedSignature = secp256k1_1.signatureImport(response.signature);
|
|
242
242
|
return parsedSignature;
|
|
243
243
|
});
|
|
244
244
|
}
|
|
@@ -210,7 +210,7 @@ class MetaMask {
|
|
|
210
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
211
211
|
const chainIdHex = (yield ((_a = this.getAPI()) === null || _a === void 0 ? void 0 : _a.request({ method: "eth_chainId" })));
|
|
212
212
|
const chainId = !!chainIdHex ? parseInt(chainIdHex, 16) : undefined;
|
|
213
|
-
const blockchain =
|
|
213
|
+
const blockchain = blockchain_1.getBlockchainFromChain(chainId);
|
|
214
214
|
this.blockchain = blockchain;
|
|
215
215
|
return { chainId, blockchain };
|
|
216
216
|
});
|
|
@@ -60,9 +60,9 @@ class O3Wallet {
|
|
|
60
60
|
return {
|
|
61
61
|
type: index_1.CarbonSignerTypes.BrowserInjected,
|
|
62
62
|
signAmino: (_, doc) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const msg = JSON.stringify(
|
|
63
|
+
const msg = JSON.stringify(generic_1.sortObject(doc));
|
|
64
64
|
const signBytes = yield dapi.signMessage(msg);
|
|
65
|
-
const signature =
|
|
65
|
+
const signature = amino_1.encodeSecp256k1Signature(pubKey, signBytes);
|
|
66
66
|
return {
|
|
67
67
|
signed: doc,
|
|
68
68
|
signature,
|
package/lib/util/address.js
CHANGED
|
@@ -94,13 +94,13 @@ const randomMnemonic = () => {
|
|
|
94
94
|
};
|
|
95
95
|
exports.randomMnemonic = randomMnemonic;
|
|
96
96
|
const wifEncodePrivateKey = (privateKey, iter = 128) => {
|
|
97
|
-
const privateKeyBuf =
|
|
97
|
+
const privateKeyBuf = exports.stringOrBufferToBuffer(privateKey);
|
|
98
98
|
return wif.encode(iter, privateKeyBuf, true);
|
|
99
99
|
};
|
|
100
100
|
exports.wifEncodePrivateKey = wifEncodePrivateKey;
|
|
101
101
|
exports.SWTHAddress = {
|
|
102
102
|
newMnemonic: () => {
|
|
103
|
-
return
|
|
103
|
+
return exports.randomMnemonic();
|
|
104
104
|
},
|
|
105
105
|
coinType: () => {
|
|
106
106
|
return SWTH_COIN_TYPE;
|
|
@@ -110,10 +110,10 @@ exports.SWTHAddress = {
|
|
|
110
110
|
return new BIP44Path(BIP44_PURPOSE, coinType).update(index, change, account).toArray();
|
|
111
111
|
},
|
|
112
112
|
publicKeyToScriptHash: (publicKey) => {
|
|
113
|
-
const pubKeyBuffer =
|
|
113
|
+
const pubKeyBuffer = exports.stringOrBufferToBuffer(publicKey);
|
|
114
114
|
const sha256Hash = ethers_1.ethers.utils.sha256(pubKeyBuffer);
|
|
115
115
|
const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
|
|
116
|
-
return
|
|
116
|
+
return generic_1.stripHexPrefix(ripemdHash);
|
|
117
117
|
},
|
|
118
118
|
publicKeyToAddress: (publicKey, opts) => {
|
|
119
119
|
const scriptHash = exports.SWTHAddress.publicKeyToScriptHash(publicKey);
|
|
@@ -135,7 +135,7 @@ exports.SWTHAddress = {
|
|
|
135
135
|
return privateKey;
|
|
136
136
|
},
|
|
137
137
|
privateToPublicKey: (privateKey) => {
|
|
138
|
-
const privateKeyBuff =
|
|
138
|
+
const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
|
|
139
139
|
const publicKeyUint8Array = secp256k1.publicKeyCreate(privateKeyBuff, true);
|
|
140
140
|
const publicKey = Buffer.from(publicKeyUint8Array);
|
|
141
141
|
return publicKey;
|
|
@@ -146,7 +146,7 @@ exports.SWTHAddress = {
|
|
|
146
146
|
return address;
|
|
147
147
|
},
|
|
148
148
|
encode: (hash, opts) => {
|
|
149
|
-
const hashBuff =
|
|
149
|
+
const hashBuff = exports.stringOrBufferToBuffer(hash, "hex");
|
|
150
150
|
const words = bech32.toWords(hashBuff.slice(0, 20));
|
|
151
151
|
const addressPrefix = exports.SWTHAddress.getBech32Prefix(opts === null || opts === void 0 ? void 0 : opts.network, opts === null || opts === void 0 ? void 0 : opts.bech32Prefix, opts === null || opts === void 0 ? void 0 : opts.type);
|
|
152
152
|
const address = bech32.encode(addressPrefix, words);
|
|
@@ -205,7 +205,7 @@ exports.NEOAddress = {
|
|
|
205
205
|
]);
|
|
206
206
|
const sha256Hash = ethers_1.ethers.utils.sha256(addressScript);
|
|
207
207
|
const ripemdHash = ethers_1.ethers.utils.ripemd160(sha256Hash);
|
|
208
|
-
return
|
|
208
|
+
return generic_1.stripHexPrefix(ripemdHash);
|
|
209
209
|
},
|
|
210
210
|
publicKeyToAddress: (publicKey) => {
|
|
211
211
|
const addressScript = exports.NEOAddress.publicKeyToScriptHash(publicKey);
|
|
@@ -213,7 +213,7 @@ exports.NEOAddress = {
|
|
|
213
213
|
return address;
|
|
214
214
|
},
|
|
215
215
|
encodePublicKey: (unencodedPublicKey) => {
|
|
216
|
-
const unencPubKeyBuf =
|
|
216
|
+
const unencPubKeyBuf = exports.stringOrBufferToBuffer(unencodedPublicKey);
|
|
217
217
|
if (unencPubKeyBuf.length <= 33) {
|
|
218
218
|
// length indicates already encoded
|
|
219
219
|
return unencPubKeyBuf;
|
|
@@ -238,7 +238,7 @@ exports.NEOAddress = {
|
|
|
238
238
|
return privateKey;
|
|
239
239
|
},
|
|
240
240
|
privateToPublicKey: (privateKey) => {
|
|
241
|
-
const privateKeyBuff =
|
|
241
|
+
const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
|
|
242
242
|
const publicKeyUint8Array = secp256r1.publicKeyCreate(privateKeyBuff, true);
|
|
243
243
|
return Buffer.from(publicKeyUint8Array);
|
|
244
244
|
},
|
|
@@ -256,7 +256,7 @@ exports.NEOAddress = {
|
|
|
256
256
|
},
|
|
257
257
|
};
|
|
258
258
|
exports.N3Address = Object.assign(Object.assign({}, exports.NEOAddress), { publicKeyToScriptHash: (publicKey) => {
|
|
259
|
-
const publicKeyHex =
|
|
259
|
+
const publicKeyHex = exports.stringOrBufferToBuffer(publicKey).toString("hex");
|
|
260
260
|
return neon_core_next_1.wallet.getScriptHashFromPublicKey(publicKeyHex);
|
|
261
261
|
}, publicKeyToAddress: (publicKey) => {
|
|
262
262
|
const addressScript = exports.N3Address.publicKeyToScriptHash(publicKey);
|
|
@@ -282,11 +282,11 @@ exports.ETHAddress = {
|
|
|
282
282
|
return ethers_1.ethers.utils.keccak256(encodedPublicKey);
|
|
283
283
|
},
|
|
284
284
|
publicKeyToAddress: (publicKey) => {
|
|
285
|
-
const publicKeyBuff =
|
|
285
|
+
const publicKeyBuff = exports.stringOrBufferToBuffer(publicKey);
|
|
286
286
|
return ethers_1.ethers.utils.computeAddress(publicKeyBuff);
|
|
287
287
|
},
|
|
288
288
|
encodePublicKey: (unencodedPublicKey) => {
|
|
289
|
-
const unencodedPublicKeyBuff =
|
|
289
|
+
const unencodedPublicKeyBuff = exports.stringOrBufferToBuffer(unencodedPublicKey);
|
|
290
290
|
const publicKey = ethers_1.ethers.utils.computePublicKey(unencodedPublicKeyBuff, true);
|
|
291
291
|
return Buffer.from(publicKey, "hex");
|
|
292
292
|
},
|
|
@@ -298,7 +298,7 @@ exports.ETHAddress = {
|
|
|
298
298
|
return Buffer.from((_a = wallet.privateKey) === null || _a === void 0 ? void 0 : _a.replace(/^0x/, ""), "hex");
|
|
299
299
|
},
|
|
300
300
|
privateToPublicKey: (privateKey) => {
|
|
301
|
-
const privateKeyBuff =
|
|
301
|
+
const privateKeyBuff = exports.stringOrBufferToBuffer(privateKey);
|
|
302
302
|
return Buffer.from(ethers_1.ethers.utils.computePublicKey(privateKeyBuff).replace(/^0x/, ""), "hex");
|
|
303
303
|
},
|
|
304
304
|
privateKeyToAddress: (privateKey) => {
|
package/lib/util/api.js
CHANGED
|
@@ -84,7 +84,7 @@ class HTTP {
|
|
|
84
84
|
* Executes HTTP GET request with fetch
|
|
85
85
|
*/
|
|
86
86
|
this.get = ({ url, headers }) => {
|
|
87
|
-
return
|
|
87
|
+
return fetch_1.fetch(url, {
|
|
88
88
|
method: "GET",
|
|
89
89
|
headers,
|
|
90
90
|
});
|
|
@@ -93,7 +93,7 @@ class HTTP {
|
|
|
93
93
|
* Executes HTTP POST request with fetch
|
|
94
94
|
*/
|
|
95
95
|
this.post = (options) => {
|
|
96
|
-
return
|
|
96
|
+
return fetch_1.fetch(options.url, {
|
|
97
97
|
method: "POST",
|
|
98
98
|
headers: Object.assign({ "Content-Type": options.content_type || "application/json" }, options.headers),
|
|
99
99
|
body: JSON.stringify(options.body),
|
|
@@ -103,7 +103,7 @@ class HTTP {
|
|
|
103
103
|
* Executes HTTP DELETE request with fetch
|
|
104
104
|
*/
|
|
105
105
|
this.del = (options) => {
|
|
106
|
-
return
|
|
106
|
+
return fetch_1.fetch(options.url, {
|
|
107
107
|
method: "DELETE",
|
|
108
108
|
headers: Object.assign({ "Content-Type": options.content_type || "application/json" }, options.headers),
|
|
109
109
|
body: JSON.stringify(options.body),
|
|
@@ -114,7 +114,7 @@ class HTTP {
|
|
|
114
114
|
*/
|
|
115
115
|
this.raw = (options) => {
|
|
116
116
|
const { url } = options, otherOpts = __rest(options, ["url"]);
|
|
117
|
-
return
|
|
117
|
+
return fetch_1.fetch(url, otherOpts);
|
|
118
118
|
};
|
|
119
119
|
this.apiPrefix = apiPrefix;
|
|
120
120
|
this.apiEndpoints = apiEndpoints;
|
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) => {
|
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,
|