@airgap/coinlib-core 0.12.5-beta.9 → 0.12.7-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/airgap-coinlib-core.min.js +43778 -15484
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/codec.js +4 -1
- package/dependencies/src/@taquito/local-forging-8.0.1-beta.1/packages/taquito-local-forging/src/codec.js.map +1 -1
- package/dependencies/src/cosmjs/index.d.ts +376 -0
- package/dependencies/src/cosmjs/index.js +1291 -0
- package/dependencies/src/cosmjs/index.js.map +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.d.ts +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js +28 -9
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.d.ts +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js +24 -8
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/index.js +5 -2
- package/dependencies/src/eciesjs-0.3.9/src/keys/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/utils.js +20 -1
- package/dependencies/src/eciesjs-0.3.9/src/utils.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js +21 -2
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js.map +1 -1
- package/dependencies/src/sha.js-2.4.11/index.js +3 -2
- package/index.d.ts +4 -2
- package/index.js +4 -2
- package/index.js.map +1 -1
- package/package.json +7 -2
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinProtocol.d.ts +1 -1
- package/protocols/NonExtendedProtocol.d.ts +1 -1
- package/protocols/NonExtendedProtocol.js +1 -1
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/aeternity/AeternityAddress.js +20 -1
- package/protocols/aeternity/AeternityAddress.js.map +1 -1
- package/protocols/aeternity/AeternityCryptoClient.js.map +1 -1
- package/protocols/aeternity/AeternityProtocol.js +27 -5
- package/protocols/aeternity/AeternityProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinProtocol.js +25 -3
- package/protocols/bitcoin/BitcoinProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinProtocolOptions.js +20 -1
- package/protocols/bitcoin/BitcoinProtocolOptions.js.map +1 -1
- package/protocols/bitcoin/BitcoinSegwitProtocol.js +26 -4
- package/protocols/bitcoin/BitcoinSegwitProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinTestnetProtocol.js +20 -1
- package/protocols/bitcoin/BitcoinTestnetProtocol.js.map +1 -1
- package/protocols/cosmos/CosmosAddress.js.map +1 -1
- package/protocols/cosmos/CosmosCryptoClient.js.map +1 -1
- package/protocols/cosmos/CosmosNodeClient.d.ts +16 -3
- package/protocols/cosmos/CosmosNodeClient.js +12 -7
- package/protocols/cosmos/CosmosNodeClient.js.map +1 -1
- package/protocols/cosmos/CosmosProtocol.js +70 -63
- package/protocols/cosmos/CosmosProtocol.js.map +1 -1
- package/protocols/cosmos/CosmosTransaction.d.ts +6 -1
- package/protocols/cosmos/CosmosTransaction.js +13 -1
- package/protocols/cosmos/CosmosTransaction.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.d.ts +3 -0
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.js +15 -0
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosMessage.d.ts +2 -2
- package/protocols/cosmos/cosmos-message/CosmosMessage.js +4 -4
- package/protocols/cosmos/cosmos-message/CosmosMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.d.ts +3 -0
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.js +24 -1
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +3 -0
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +12 -0
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -1
- package/protocols/ethereum/BaseEthereumProtocol.d.ts +8 -4
- package/protocols/ethereum/BaseEthereumProtocol.js +277 -52
- package/protocols/ethereum/BaseEthereumProtocol.js.map +1 -1
- package/protocols/ethereum/EthereumAddress.js +20 -1
- package/protocols/ethereum/EthereumAddress.js.map +1 -1
- package/protocols/ethereum/EthereumCryptoClient.js +44 -5
- package/protocols/ethereum/EthereumCryptoClient.js.map +1 -1
- package/protocols/ethereum/EthereumProtocol.d.ts +2 -0
- package/protocols/ethereum/EthereumProtocol.js +2 -0
- package/protocols/ethereum/EthereumProtocol.js.map +1 -1
- package/protocols/ethereum/clients/info-clients/EtherscanInfoClient.js +4 -1
- package/protocols/ethereum/clients/info-clients/EtherscanInfoClient.js.map +1 -1
- package/protocols/ethereum/clients/node-clients/AirGapNodeClient.js +4 -1
- package/protocols/ethereum/clients/node-clients/AirGapNodeClient.js.map +1 -1
- package/protocols/ethereum/erc20/GenericERC20.js +24 -2
- package/protocols/ethereum/erc20/GenericERC20.js.map +1 -1
- package/protocols/groestlcoin/GroestlcoinProtocol.js +20 -1
- package/protocols/groestlcoin/GroestlcoinProtocol.js.map +1 -1
- package/protocols/groestlcoin/GroestlcoinProtocolOptions.js +20 -1
- package/protocols/groestlcoin/GroestlcoinProtocolOptions.js.map +1 -1
- package/protocols/groestlcoin/GroestlcoinTestnetProtocol.js +20 -1
- package/protocols/groestlcoin/GroestlcoinTestnetProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateDelegateProtocol.js +4 -1
- package/protocols/substrate/SubstrateDelegateProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateProtocol.js +4 -1
- package/protocols/substrate/SubstrateProtocol.js.map +1 -1
- package/protocols/substrate/common/SubstrateAccountController.js +4 -1
- package/protocols/substrate/common/SubstrateAccountController.js.map +1 -1
- package/protocols/substrate/common/SubstrateTransactionController.js +24 -2
- package/protocols/substrate/common/SubstrateTransactionController.js.map +1 -1
- package/protocols/substrate/common/blockexplorer/SubstrateBlockExplorerClient.js +5 -2
- package/protocols/substrate/common/blockexplorer/SubstrateBlockExplorerClient.js.map +1 -1
- package/protocols/substrate/common/data/scale/type/SCALECompactInt.js +4 -1
- package/protocols/substrate/common/data/scale/type/SCALECompactInt.js.map +1 -1
- package/protocols/substrate/common/data/scale/type/SCALEEra.js +4 -1
- package/protocols/substrate/common/data/scale/type/SCALEEra.js.map +1 -1
- package/protocols/substrate/common/data/scale/type/SCALEInt.js +4 -1
- package/protocols/substrate/common/data/scale/type/SCALEInt.js.map +1 -1
- package/protocols/substrate/common/data/scale/type/SCALEMultiAddress.js +4 -1
- package/protocols/substrate/common/data/scale/type/SCALEMultiAddress.js.map +1 -1
- package/protocols/substrate/common/data/transaction/method/SubstrateTransactionMethodArgs.js +4 -1
- package/protocols/substrate/common/data/transaction/method/SubstrateTransactionMethodArgs.js.map +1 -1
- package/protocols/substrate/common/node/SubstrateNodeClient.js +5 -2
- package/protocols/substrate/common/node/SubstrateNodeClient.js.map +1 -1
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js +3 -3
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js.map +1 -1
- package/protocols/substrate/moonbeam/controllers/MoonbeamAccountController.js +24 -2
- package/protocols/substrate/moonbeam/controllers/MoonbeamAccountController.js.map +1 -1
- package/protocols/substrate/moonbeam/data/account/MoonbeamAddress.js +20 -1
- package/protocols/substrate/moonbeam/data/account/MoonbeamAddress.js.map +1 -1
- package/protocols/tezos/TezosAddress.js +20 -1
- package/protocols/tezos/TezosAddress.js.map +1 -1
- package/protocols/tezos/TezosCryptoClient.js +21 -2
- package/protocols/tezos/TezosCryptoClient.js.map +1 -1
- package/protocols/tezos/TezosProtocol.js +25 -3
- package/protocols/tezos/TezosProtocol.js.map +1 -1
- package/protocols/tezos/TezosUtils.js +25 -3
- package/protocols/tezos/TezosUtils.js.map +1 -1
- package/protocols/tezos/contract/TezosContract.js +4 -1
- package/protocols/tezos/contract/TezosContract.js.map +1 -1
- package/protocols/tezos/fa/TezosBTC.js +4 -1
- package/protocols/tezos/fa/TezosBTC.js.map +1 -1
- package/protocols/tezos/fa/TezosFA1Protocol.js +4 -1
- package/protocols/tezos/fa/TezosFA1Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFA1p2Protocol.js +4 -1
- package/protocols/tezos/fa/TezosFA1p2Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFA2Protocol.js +4 -1
- package/protocols/tezos/fa/TezosFA2Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFAProtocol.js +5 -2
- package/protocols/tezos/fa/TezosFAProtocol.js.map +1 -1
- package/protocols/tezos/kt/TezosKtProtocol.js +5 -2
- package/protocols/tezos/kt/TezosKtProtocol.js.map +1 -1
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation005.js +4 -1
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation005.js.map +1 -1
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation006.js +4 -1
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation006.js.map +1 -1
- package/protocols/tezos/rewardcalculation/TezosRewardCalculationDefault.js +5 -2
- package/protocols/tezos/rewardcalculation/TezosRewardCalculationDefault.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingAddress.js +20 -1
- package/protocols/tezos/sapling/TezosSaplingAddress.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingCryptoClient.js +24 -2
- package/protocols/tezos/sapling/TezosSaplingCryptoClient.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingProtocol.d.ts +9 -4
- package/protocols/tezos/sapling/TezosSaplingProtocol.js +156 -94
- package/protocols/tezos/sapling/TezosSaplingProtocol.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingProtocolOptions.d.ts +10 -7
- package/protocols/tezos/sapling/TezosSaplingProtocolOptions.js +39 -9
- package/protocols/tezos/sapling/TezosSaplingProtocolOptions.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingTokenProtocol.d.ts +23 -0
- package/protocols/tezos/sapling/TezosSaplingTokenProtocol.js +234 -0
- package/protocols/tezos/sapling/TezosSaplingTokenProtocol.js.map +1 -0
- package/protocols/tezos/sapling/TezosShieldedTezProtocol.js +4 -1
- package/protocols/tezos/sapling/TezosShieldedTezProtocol.js.map +1 -1
- package/protocols/tezos/sapling/node/TezosSaplingNodeClient.js +4 -1
- package/protocols/tezos/sapling/node/TezosSaplingNodeClient.js.map +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingBookkeeper.js +47 -18
- package/protocols/tezos/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingEncoder.js +4 -1
- package/protocols/tezos/sapling/utils/TezosSaplingEncoder.js.map +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingForger.js +24 -2
- package/protocols/tezos/sapling/utils/TezosSaplingForger.js.map +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingState.js +24 -2
- package/protocols/tezos/sapling/utils/TezosSaplingState.js.map +1 -1
- package/protocols/tezos/types/michelson/MichelsonTypeUtils.js +1 -1
- package/protocols/tezos/types/michelson/MichelsonTypeUtils.js.map +1 -1
- package/protocols/tezos/types/michelson/primitives/MichelsonInt.js +4 -1
- package/protocols/tezos/types/michelson/primitives/MichelsonInt.js.map +1 -1
- package/serializer/inter-app-communication-protocol.js +21 -2
- package/serializer/inter-app-communication-protocol.js.map +1 -1
- package/serializer/payloads/full-payload.js +21 -2
- package/serializer/payloads/full-payload.js.map +1 -1
- package/serializer/schemas/definitions/unsigned-transaction-tezos-sapling.d.ts +1 -1
- package/serializer/serializer.js +4 -0
- package/serializer/serializer.js.map +1 -1
- package/serializer/types.d.ts +6 -1
- package/serializer/unsigned-transactions/xtz-btc-transactions.validator.js +4 -1
- package/serializer/unsigned-transactions/xtz-btc-transactions.validator.js.map +1 -1
- package/serializer/utils/toBuffer.js +4 -1
- package/serializer/utils/toBuffer.js.map +1 -1
- package/serializer/validators/validators.js +5 -2
- package/serializer/validators/validators.js.map +1 -1
- package/serializer-v3/iac-message-wrapper.js +20 -1
- package/serializer-v3/iac-message-wrapper.js.map +1 -1
- package/serializer-v3/message.d.ts +2 -2
- package/serializer-v3/message.js +31 -11
- package/serializer-v3/message.js.map +1 -1
- package/serializer-v3/schemas/definitions/unsigned-transaction-ethereum-typed.d.ts +11 -0
- package/serializer-v3/schemas/definitions/unsigned-transaction-ethereum-typed.js +3 -0
- package/serializer-v3/schemas/definitions/unsigned-transaction-ethereum-typed.js.map +1 -0
- package/serializer-v3/schemas/definitions/unsigned-transaction-tezos-sapling.d.ts +1 -1
- package/serializer-v3/schemas/generated/account-share-request.json +1 -3
- package/serializer-v3/schemas/generated/account-share-response.json +1 -9
- package/serializer-v3/schemas/generated/message-sign-request.json +1 -4
- package/serializer-v3/schemas/generated/message-sign-response.json +1 -5
- package/serializer-v3/schemas/generated/transaction-sign-request-aeternity.json +2 -8
- package/serializer-v3/schemas/generated/transaction-sign-request-bitcoin.json +4 -19
- package/serializer-v3/schemas/generated/transaction-sign-request-cosmos.json +7 -36
- package/serializer-v3/schemas/generated/transaction-sign-request-ethereum-typed.json +38 -0
- package/serializer-v3/schemas/generated/transaction-sign-request-ethereum.json +2 -13
- package/serializer-v3/schemas/generated/transaction-sign-request-substrate.json +2 -7
- package/serializer-v3/schemas/generated/transaction-sign-request-tezos-sapling.json +6 -35
- package/serializer-v3/schemas/generated/transaction-sign-request-tezos.json +2 -7
- package/serializer-v3/schemas/generated/transaction-sign-response-aeternity.json +1 -4
- package/serializer-v3/schemas/generated/transaction-sign-response-bitcoin-segwit.json +1 -4
- package/serializer-v3/schemas/generated/transaction-sign-response-bitcoin.json +1 -8
- package/serializer-v3/schemas/generated/transaction-sign-response-ethereum.json +1 -4
- package/serializer-v3/schemas/generated/transaction-sign-response-substrate.json +1 -4
- package/serializer-v3/schemas/generated/transaction-sign-response-tezos-sapling.json +1 -4
- package/serializer-v3/schemas/generated/transaction-sign-response-tezos.json +1 -4
- package/serializer-v3/serializer.d.ts +1 -1
- package/serializer-v3/serializer.js +19 -10
- package/serializer-v3/serializer.js.map +1 -1
- package/serializer-v3/types.d.ts +1 -1
- package/serializer-v3/unsigned-transactions/xtz-btc-transactions.validator.js +4 -1
- package/serializer-v3/unsigned-transactions/xtz-btc-transactions.validator.js.map +1 -1
- package/serializer-v3/validators/validators.js +5 -2
- package/serializer-v3/validators/validators.js.map +1 -1
- package/utils/AES.js +20 -1
- package/utils/AES.js.map +1 -1
- package/utils/ProtocolNetwork.js.map +1 -1
- package/utils/ProtocolSymbols.d.ts +1 -0
- package/utils/ProtocolSymbols.js +1 -0
- package/utils/ProtocolSymbols.js.map +1 -1
- package/utils/base64Check.js.map +1 -1
- package/utils/coinlibReady.js.map +1 -1
- package/utils/hex.js +4 -1
- package/utils/hex.js.map +1 -1
- package/utils/protocolOptionsByIdentifier.js +4 -0
- package/utils/protocolOptionsByIdentifier.js.map +1 -1
- package/utils/remote-data/HttpRemoteData.js +4 -1
- package/utils/remote-data/HttpRemoteData.js.map +1 -1
- package/utils/remote-data/IpfsRemoteData.js +4 -1
- package/utils/remote-data/IpfsRemoteData.js.map +1 -1
- package/utils/remote-data/Sha256RemoteData.js +4 -1
- package/utils/remote-data/Sha256RemoteData.js.map +1 -1
- package/utils/type.js +4 -1
- package/utils/type.js.map +1 -1
- package/wallet/AirGapCoinWallet.js +4 -1
- package/wallet/AirGapCoinWallet.js.map +1 -1
- package/wallet/AirGapMarketWallet.js +4 -1
- package/wallet/AirGapMarketWallet.js.map +1 -1
- package/wallet/AirGapNFTWallet.js +4 -1
- package/wallet/AirGapNFTWallet.js.map +1 -1
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
+
r[k] = a[j];
|
|
7
|
+
return r;
|
|
8
|
+
};
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
2
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
13
|
exports.CosmosSendMessage = void 0;
|
|
4
|
-
var bignumber_1 = require("../../../dependencies/src/bignumber.js-9.0.0/bignumber");
|
|
14
|
+
var bignumber_1 = __importDefault(require("../../../dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
5
15
|
var IAirGapTransaction_1 = require("../../../interfaces/IAirGapTransaction");
|
|
6
16
|
var CosmosCoin_1 = require("../CosmosCoin");
|
|
7
17
|
var CosmosMessage_1 = require("./CosmosMessage");
|
|
@@ -12,6 +22,19 @@ var CosmosSendMessage = /** @class */ (function () {
|
|
|
12
22
|
this.toAddress = toAddress;
|
|
13
23
|
this.amount = amount;
|
|
14
24
|
}
|
|
25
|
+
CosmosSendMessage.prototype.toEncodeObject = function () {
|
|
26
|
+
return {
|
|
27
|
+
typeUrl: this.type.value,
|
|
28
|
+
value: {
|
|
29
|
+
fromAddress: this.fromAddress,
|
|
30
|
+
toAddress: this.toAddress,
|
|
31
|
+
amount: __spreadArrays(this.amount)
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
CosmosSendMessage.fromEncodeObject = function (encodeObject) {
|
|
36
|
+
return new CosmosSendMessage(encodeObject.value.fromAddress, encodeObject.value.toAddress, encodeObject.value.amount.map(function (amount) { return new CosmosCoin_1.CosmosCoin(amount.denom, amount.amount); }));
|
|
37
|
+
};
|
|
15
38
|
CosmosSendMessage.prototype.toJSON = function () {
|
|
16
39
|
return {
|
|
17
40
|
type: this.type.index,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosSendMessage.js","sourceRoot":"","sources":["../../../../src/protocols/cosmos/cosmos-message/CosmosSendMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CosmosSendMessage.js","sourceRoot":"","sources":["../../../../src/protocols/cosmos/cosmos-message/CosmosSendMessage.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EncodeObject } from '../../../dependencies/src/cosmjs';
|
|
1
2
|
import { IAirGapTransaction } from '../../../interfaces/IAirGapTransaction';
|
|
2
3
|
import { CosmosProtocol } from '../CosmosProtocol';
|
|
3
4
|
import { CosmosMessage, CosmosMessageJSON, CosmosMessageType } from './CosmosMessage';
|
|
@@ -6,6 +7,8 @@ export declare class CosmosWithdrawDelegationRewardMessage implements CosmosMess
|
|
|
6
7
|
readonly validatorAddress: string;
|
|
7
8
|
readonly type: CosmosMessageType;
|
|
8
9
|
constructor(delegatorAddress: string, validatorAddress: string);
|
|
10
|
+
toEncodeObject(): EncodeObject;
|
|
11
|
+
static fromEncodeObject(encodeObject: EncodeObject): CosmosWithdrawDelegationRewardMessage;
|
|
9
12
|
toAirGapTransaction(protocol: CosmosProtocol, fee: string): IAirGapTransaction;
|
|
10
13
|
toJSON(): CosmosMessageJSON;
|
|
11
14
|
static fromJSON(json: CosmosMessageJSON): CosmosWithdrawDelegationRewardMessage;
|
|
@@ -8,6 +8,18 @@ var CosmosWithdrawDelegationRewardMessage = /** @class */ (function () {
|
|
|
8
8
|
this.delegatorAddress = delegatorAddress;
|
|
9
9
|
this.validatorAddress = validatorAddress;
|
|
10
10
|
}
|
|
11
|
+
CosmosWithdrawDelegationRewardMessage.prototype.toEncodeObject = function () {
|
|
12
|
+
return {
|
|
13
|
+
typeUrl: this.type.value,
|
|
14
|
+
value: {
|
|
15
|
+
delegatorAddress: this.delegatorAddress,
|
|
16
|
+
validatorAddress: this.validatorAddress
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
CosmosWithdrawDelegationRewardMessage.fromEncodeObject = function (encodeObject) {
|
|
21
|
+
return new CosmosWithdrawDelegationRewardMessage(encodeObject.value.delegatorAddress, encodeObject.value.validatorAddress);
|
|
22
|
+
};
|
|
11
23
|
CosmosWithdrawDelegationRewardMessage.prototype.toAirGapTransaction = function (protocol, fee) {
|
|
12
24
|
return {
|
|
13
25
|
from: [this.delegatorAddress],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosWithdrawDelegationRewardMessage.js","sourceRoot":"","sources":["../../../../src/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CosmosWithdrawDelegationRewardMessage.js","sourceRoot":"","sources":["../../../../src/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.ts"],"names":[],"mappings":";;;AAIA,iDAAqF;AAErF;IAKE,+CAAY,gBAAwB,EAAE,gBAAwB;QAF9C,SAAI,GAAsB,iCAAiB,CAAC,wBAAwB,CAAA;QAGlF,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;IAC1C,CAAC;IAEM,8DAAc,GAArB;QACE,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACxB,KAAK,EAAE;gBACL,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;aACxC;SACF,CAAA;IACH,CAAC;IAEa,sDAAgB,GAA9B,UAA+B,YAA0B;QACvD,OAAO,IAAI,qCAAqC,CAAC,YAAY,CAAC,KAAK,CAAC,gBAAgB,EAAE,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAC5H,CAAC;IAEM,mEAAmB,GAA1B,UAA2B,QAAwB,EAAE,GAAW;QAC9D,OAAO;YACL,IAAI,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC7B,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC3B,MAAM,EAAE,GAAG;YACX,SAAS,EAAE,KAAK;YAChB,GAAG,KAAA;YACH,kBAAkB,EAAE,QAAQ,CAAC,UAAU;YACvC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO;YACjC,kBAAkB,EAAE,IAAI,CAAC,SAAS,EAAE;SACrC,CAAA;IACH,CAAC;IAEM,sDAAM,GAAb;QACE,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACrB,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;YACnC,WAAW,EAAE,IAAI,CAAC,gBAAgB;YAClC,SAAS,EAAE,IAAI,CAAC,gBAAgB;SACjC,CAAA;IACH,CAAC;IAEa,8CAAQ,GAAtB,UAAuB,IAAuB;QAC5C,OAAO,IAAI,qCAAqC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IACpF,CAAC;IAEM,yDAAS,GAAhB;QACE,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACrB,KAAK,EAAE;gBACL,iBAAiB,EAAE,IAAI,CAAC,gBAAgB;gBACxC,iBAAiB,EAAE,IAAI,CAAC,gBAAgB;aACzC;SACF,CAAA;IACH,CAAC;IAEa,iDAAW,GAAzB,UAA0B,IAAS;QACjC,OAAO,IAAI,qCAAqC,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAC9G,CAAC;IACH,4CAAC;AAAD,CAAC,AA/DD,IA+DC;AA/DY,sFAAqC"}
|
|
@@ -4,7 +4,7 @@ import { AirGapTransactionStatus, IAirGapTransaction } from '../../interfaces/IA
|
|
|
4
4
|
import { Network } from '../../networks';
|
|
5
5
|
import { SignedEthereumTransaction } from '../../serializer/schemas/definitions/signed-transaction-ethereum';
|
|
6
6
|
import { UnsignedTransaction } from '../../serializer/schemas/definitions/unsigned-transaction';
|
|
7
|
-
import { RawEthereumTransaction } from '../../serializer/types';
|
|
7
|
+
import { RawEthereumTransaction, RawTypedEthereumTransaction } from '../../serializer/types';
|
|
8
8
|
import { ProtocolSymbols } from '../../utils/ProtocolSymbols';
|
|
9
9
|
import { CurrencyUnit, FeeDefaults, ICoinProtocol } from '../ICoinProtocol';
|
|
10
10
|
import { ICoinSubProtocol } from '../ICoinSubProtocol';
|
|
@@ -40,15 +40,19 @@ export declare abstract class BaseEthereumProtocol<NodeClient extends EthereumNo
|
|
|
40
40
|
getPublicKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
41
41
|
getPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<Buffer>;
|
|
42
42
|
getExtendedPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
43
|
+
getExtendedPublicKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
43
44
|
getPublicKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
45
|
+
getExtendedPublicKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
44
46
|
getPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<Buffer>;
|
|
45
47
|
getExtendedPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
46
48
|
getAddressFromPublicKey(publicKey: string | Buffer): Promise<EthereumAddress>;
|
|
47
49
|
getAddressesFromPublicKey(publicKey: string | Buffer): Promise<EthereumAddress[]>;
|
|
50
|
+
private getPublicKeyFromExtendedPublicKey;
|
|
48
51
|
getAddressFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressDerivationIndex: number): Promise<EthereumAddress>;
|
|
49
52
|
getAddressesFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressCount: number, offset: number): Promise<EthereumAddress[]>;
|
|
50
53
|
getNextAddressFromPublicKey(publicKey: string, current: EthereumAddress): Promise<EthereumAddress>;
|
|
51
|
-
|
|
54
|
+
private getPrivateKeyFromExtendedPrivateKey;
|
|
55
|
+
signWithExtendedPrivateKey(extendedPrivateKey: string, untypedTransaction: RawTypedEthereumTransaction | RawEthereumTransaction, childDerivationPath?: string): Promise<IAirGapSignedTransaction>;
|
|
52
56
|
signWithPrivateKey(privateKey: Buffer, transaction: RawEthereumTransaction): Promise<IAirGapSignedTransaction>;
|
|
53
57
|
getTransactionDetails(unsignedTx: UnsignedTransaction): Promise<IAirGapTransaction[]>;
|
|
54
58
|
getTransactionDetailsFromSigned(transaction: SignedEthereumTransaction): Promise<IAirGapTransaction[]>;
|
|
@@ -58,8 +62,8 @@ export declare abstract class BaseEthereumProtocol<NodeClient extends EthereumNo
|
|
|
58
62
|
getBalanceOfExtendedPublicKey(extendedPublicKey: string, offset?: number): Promise<string>;
|
|
59
63
|
getAvailableBalanceOfAddresses(addresses: string[]): Promise<string>;
|
|
60
64
|
estimateMaxTransactionValueFromExtendedPublicKey(extendedPublicKey: string, recipients: string[], fee?: string): Promise<string>;
|
|
61
|
-
estimateFeeDefaultsFromExtendedPublicKey(
|
|
62
|
-
prepareTransactionFromExtendedPublicKey(extendedPublicKey: string,
|
|
65
|
+
estimateFeeDefaultsFromExtendedPublicKey(extendedPublicKey: string, recipients: string[], values: string[], data?: any): Promise<FeeDefaults>;
|
|
66
|
+
prepareTransactionFromExtendedPublicKey(extendedPublicKey: string, _offset: number, recipients: string[], values: string[], fee: string, data?: any): Promise<RawEthereumTransaction>;
|
|
63
67
|
estimateMaxTransactionValueFromPublicKey(publicKey: string, recipients: string[], fee?: string): Promise<string>;
|
|
64
68
|
estimateFeeDefaultsFromPublicKey(publicKey: string, recipients: string[], values: string[], data?: any): Promise<FeeDefaults>;
|
|
65
69
|
prepareTransactionFromPublicKey(publicKey: string, recipients: string[], values: string[], fee: string, data?: any): Promise<RawEthereumTransaction>;
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,12 +54,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
54
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
55
|
}
|
|
37
56
|
};
|
|
57
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
|
+
};
|
|
38
60
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
61
|
exports.BaseEthereumProtocol = void 0;
|
|
40
62
|
var bignumber_1 = require("../../dependencies/src/bignumber.js-9.0.0/bignumber");
|
|
41
63
|
var index_1 = require("../../dependencies/src/bip39-2.5.0/index");
|
|
42
|
-
var bitcoinJS = require("../../dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/index");
|
|
43
|
-
var ethUtil = require("../../dependencies/src/ethereumjs-util-5.2.0/index");
|
|
64
|
+
var bitcoinJS = __importStar(require("../../dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/index"));
|
|
44
65
|
var errors_1 = require("../../errors");
|
|
45
66
|
var coinlib_error_1 = require("../../errors/coinlib-error");
|
|
46
67
|
var ProtocolSymbols_1 = require("../../utils/ProtocolSymbols");
|
|
@@ -50,7 +71,9 @@ var EthereumAddress_1 = require("./EthereumAddress");
|
|
|
50
71
|
var EthereumCryptoClient_1 = require("./EthereumCryptoClient");
|
|
51
72
|
var EthereumProtocolOptions_1 = require("./EthereumProtocolOptions");
|
|
52
73
|
var utils_1 = require("./utils/utils");
|
|
53
|
-
var
|
|
74
|
+
var common_1 = __importDefault(require("@ethereumjs/common"));
|
|
75
|
+
// TODO: ETH TX and ethereumjs-util-5.2.0 removed
|
|
76
|
+
var tx_1 = require("@ethereumjs/tx");
|
|
54
77
|
var BaseEthereumProtocol = /** @class */ (function () {
|
|
55
78
|
function BaseEthereumProtocol(options) {
|
|
56
79
|
if (options === void 0) { options = new EthereumProtocolOptions_1.EthereumProtocolOptions(); }
|
|
@@ -131,8 +154,19 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
131
154
|
};
|
|
132
155
|
BaseEthereumProtocol.prototype.getExtendedPrivateKeyFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
133
156
|
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
+
var secret;
|
|
134
158
|
return __generator(this, function (_a) {
|
|
135
|
-
|
|
159
|
+
secret = index_1.mnemonicToSeed(mnemonic, password);
|
|
160
|
+
return [2 /*return*/, this.getExtendedPrivateKeyFromHexSecret(secret, derivationPath)];
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
BaseEthereumProtocol.prototype.getExtendedPublicKeyFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
+
var secret;
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
secret = index_1.mnemonicToSeed(mnemonic, password);
|
|
169
|
+
return [2 /*return*/, this.getExtendedPublicKeyFromHexSecret(secret, derivationPath)];
|
|
136
170
|
});
|
|
137
171
|
});
|
|
138
172
|
};
|
|
@@ -145,6 +179,15 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
145
179
|
});
|
|
146
180
|
});
|
|
147
181
|
};
|
|
182
|
+
BaseEthereumProtocol.prototype.getExtendedPublicKeyFromHexSecret = function (secret, derivationPath) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
var ethereumNode;
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
ethereumNode = bitcoinJS.HDNode.fromSeedHex(secret, this.network);
|
|
187
|
+
return [2 /*return*/, ethereumNode.derivePath(derivationPath).neutered().toBase58()];
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
};
|
|
148
191
|
BaseEthereumProtocol.prototype.getPrivateKeyFromHexSecret = function (secret, derivationPath) {
|
|
149
192
|
return __awaiter(this, void 0, void 0, function () {
|
|
150
193
|
var ethereumNode;
|
|
@@ -156,8 +199,10 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
156
199
|
};
|
|
157
200
|
BaseEthereumProtocol.prototype.getExtendedPrivateKeyFromHexSecret = function (secret, derivationPath) {
|
|
158
201
|
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
+
var ethereumNode;
|
|
159
203
|
return __generator(this, function (_a) {
|
|
160
|
-
|
|
204
|
+
ethereumNode = bitcoinJS.HDNode.fromSeedHex(secret, this.network);
|
|
205
|
+
return [2 /*return*/, ethereumNode.derivePath(derivationPath).toBase58()];
|
|
161
206
|
});
|
|
162
207
|
});
|
|
163
208
|
};
|
|
@@ -181,14 +226,27 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
181
226
|
});
|
|
182
227
|
});
|
|
183
228
|
};
|
|
184
|
-
BaseEthereumProtocol.prototype.
|
|
229
|
+
BaseEthereumProtocol.prototype.getPublicKeyFromExtendedPublicKey = function (extendedPublicKey, visibilityDerivationIndex, addressDerivationIndex) {
|
|
185
230
|
return __awaiter(this, void 0, void 0, function () {
|
|
186
231
|
return __generator(this, function (_a) {
|
|
187
|
-
return [2 /*return*/,
|
|
232
|
+
return [2 /*return*/, bitcoinJS.HDNode.fromBase58(extendedPublicKey, this.network)
|
|
188
233
|
.derive(visibilityDerivationIndex)
|
|
189
234
|
.derive(addressDerivationIndex)
|
|
190
235
|
.getPublicKeyBuffer()
|
|
191
|
-
.toString('hex')
|
|
236
|
+
.toString('hex')];
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
BaseEthereumProtocol.prototype.getAddressFromExtendedPublicKey = function (extendedPublicKey, visibilityDerivationIndex, addressDerivationIndex) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
+
var _a;
|
|
243
|
+
return __generator(this, function (_b) {
|
|
244
|
+
switch (_b.label) {
|
|
245
|
+
case 0:
|
|
246
|
+
_a = this.getAddressFromPublicKey;
|
|
247
|
+
return [4 /*yield*/, this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, visibilityDerivationIndex, addressDerivationIndex)];
|
|
248
|
+
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
|
|
249
|
+
}
|
|
192
250
|
});
|
|
193
251
|
});
|
|
194
252
|
};
|
|
@@ -207,35 +265,122 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
207
265
|
});
|
|
208
266
|
});
|
|
209
267
|
};
|
|
210
|
-
BaseEthereumProtocol.prototype.
|
|
211
|
-
return
|
|
268
|
+
BaseEthereumProtocol.prototype.getPrivateKeyFromExtendedPrivateKey = function (extendedPrivateKey, childDerivationPath) {
|
|
269
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
270
|
+
var dp;
|
|
271
|
+
return __generator(this, function (_a) {
|
|
272
|
+
dp = childDerivationPath !== null && childDerivationPath !== void 0 ? childDerivationPath : '0/0' // This is the default
|
|
273
|
+
;
|
|
274
|
+
if (dp.startsWith('m')) {
|
|
275
|
+
throw new Error('Received full derivation path, expected child derivation path');
|
|
276
|
+
}
|
|
277
|
+
if (dp.toLowerCase().includes('h') || dp.includes("'")) {
|
|
278
|
+
throw new Error('Child derivation path cannot include hardened children');
|
|
279
|
+
}
|
|
280
|
+
return [2 /*return*/, dp
|
|
281
|
+
.split('/')
|
|
282
|
+
.reduce(function (pv, cv) { return pv.derive(Number(cv)); }, bitcoinJS.HDNode.fromBase58(extendedPrivateKey, this.network))
|
|
283
|
+
.keyPair.d.toBuffer(32)];
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
BaseEthereumProtocol.prototype.signWithExtendedPrivateKey = function (extendedPrivateKey, untypedTransaction, childDerivationPath) {
|
|
288
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
289
|
+
var privateKey, transaction, tx;
|
|
290
|
+
return __generator(this, function (_a) {
|
|
291
|
+
switch (_a.label) {
|
|
292
|
+
case 0: return [4 /*yield*/, this.getPrivateKeyFromExtendedPrivateKey(extendedPrivateKey, childDerivationPath)];
|
|
293
|
+
case 1:
|
|
294
|
+
privateKey = _a.sent();
|
|
295
|
+
if (untypedTransaction.serialized &&
|
|
296
|
+
untypedTransaction.derivationPath) {
|
|
297
|
+
transaction = untypedTransaction;
|
|
298
|
+
tx = tx_1.TransactionFactory.fromSerializedData(Buffer.from(transaction.serialized, 'hex'));
|
|
299
|
+
tx = tx.sign(privateKey);
|
|
300
|
+
return [2 /*return*/, tx.serialize().toString('hex')];
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
return [2 /*return*/, this.signWithPrivateKey(privateKey, untypedTransaction)];
|
|
304
|
+
}
|
|
305
|
+
return [2 /*return*/];
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
});
|
|
212
309
|
};
|
|
213
310
|
BaseEthereumProtocol.prototype.signWithPrivateKey = function (privateKey, transaction) {
|
|
214
311
|
return __awaiter(this, void 0, void 0, function () {
|
|
215
|
-
var tx;
|
|
312
|
+
var common, tx;
|
|
216
313
|
return __generator(this, function (_a) {
|
|
217
314
|
if (!transaction.value.startsWith('0x')) {
|
|
218
315
|
transaction.value = utils_1.EthereumUtils.toHex(parseInt(transaction.value, 10));
|
|
219
316
|
}
|
|
220
|
-
|
|
221
|
-
|
|
317
|
+
try {
|
|
318
|
+
common = new common_1.default({ chain: transaction.chainId });
|
|
319
|
+
}
|
|
320
|
+
catch (_b) {
|
|
321
|
+
common = common_1.default.custom({ chainId: transaction.chainId });
|
|
322
|
+
}
|
|
323
|
+
tx = tx_1.TransactionFactory.fromTxData(transaction, { common: common });
|
|
324
|
+
tx = tx.sign(privateKey);
|
|
222
325
|
return [2 /*return*/, tx.serialize().toString('hex')];
|
|
223
326
|
});
|
|
224
327
|
});
|
|
225
328
|
};
|
|
226
329
|
BaseEthereumProtocol.prototype.getTransactionDetails = function (unsignedTx) {
|
|
330
|
+
var _a, _b;
|
|
227
331
|
return __awaiter(this, void 0, void 0, function () {
|
|
228
|
-
var transaction,
|
|
229
|
-
return __generator(this, function (
|
|
230
|
-
switch (
|
|
332
|
+
var typedTransaction, transaction, dps, ownAddress, _c, transaction, ownAddress, _d;
|
|
333
|
+
return __generator(this, function (_e) {
|
|
334
|
+
switch (_e.label) {
|
|
231
335
|
case 0:
|
|
232
|
-
|
|
233
|
-
|
|
336
|
+
if (!unsignedTx.transaction.serialized) return [3 /*break*/, 5];
|
|
337
|
+
typedTransaction = unsignedTx.transaction;
|
|
338
|
+
transaction = tx_1.TransactionFactory.fromSerializedData(Buffer.from(typedTransaction.serialized, 'hex'));
|
|
339
|
+
dps = typedTransaction.derivationPath.split('/');
|
|
340
|
+
if (!unsignedTx.publicKey.startsWith('x') // xPub
|
|
341
|
+
) return [3 /*break*/, 2]; // xPub
|
|
342
|
+
return [4 /*yield*/, this.getAddressFromExtendedPublicKey(unsignedTx.publicKey, Number(dps[dps.length - 2]), Number(dps[dps.length - 1]))];
|
|
234
343
|
case 1:
|
|
235
|
-
|
|
344
|
+
_c = _e.sent();
|
|
345
|
+
return [3 /*break*/, 4];
|
|
346
|
+
case 2: return [4 /*yield*/, this.getAddressFromPublicKey(unsignedTx.publicKey)];
|
|
347
|
+
case 3:
|
|
348
|
+
_c = _e.sent();
|
|
349
|
+
_e.label = 4;
|
|
350
|
+
case 4:
|
|
351
|
+
ownAddress = _c;
|
|
236
352
|
return [2 /*return*/, [
|
|
237
353
|
{
|
|
238
|
-
from: [
|
|
354
|
+
from: [ownAddress.getValue()],
|
|
355
|
+
to: [(_b = (_a = transaction.to) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''],
|
|
356
|
+
amount: new bignumber_1.BigNumber(transaction.value.toString(10)).toString(10),
|
|
357
|
+
fee: new bignumber_1.BigNumber(transaction.gasLimit.toString(10))
|
|
358
|
+
.multipliedBy(new bignumber_1.BigNumber(transaction.maxFeePerGas.toString(10)))
|
|
359
|
+
.toString(10),
|
|
360
|
+
protocolIdentifier: this.identifier,
|
|
361
|
+
network: this.options.network,
|
|
362
|
+
isInbound: false,
|
|
363
|
+
data: transaction.data.toString('hex'),
|
|
364
|
+
transactionDetails: unsignedTx
|
|
365
|
+
}
|
|
366
|
+
]];
|
|
367
|
+
case 5:
|
|
368
|
+
transaction = unsignedTx.transaction;
|
|
369
|
+
if (!unsignedTx.publicKey.startsWith('x') // xPub
|
|
370
|
+
) return [3 /*break*/, 7]; // xPub
|
|
371
|
+
return [4 /*yield*/, this.getAddressFromExtendedPublicKey(unsignedTx.publicKey, 0, 0)];
|
|
372
|
+
case 6:
|
|
373
|
+
_d = _e.sent();
|
|
374
|
+
return [3 /*break*/, 9];
|
|
375
|
+
case 7: return [4 /*yield*/, this.getAddressFromPublicKey(unsignedTx.publicKey)];
|
|
376
|
+
case 8:
|
|
377
|
+
_d = _e.sent();
|
|
378
|
+
_e.label = 9;
|
|
379
|
+
case 9:
|
|
380
|
+
ownAddress = _d;
|
|
381
|
+
return [2 /*return*/, [
|
|
382
|
+
{
|
|
383
|
+
from: [ownAddress.getValue()],
|
|
239
384
|
to: [transaction.to],
|
|
240
385
|
amount: new bignumber_1.BigNumber(transaction.value).toString(10),
|
|
241
386
|
fee: new bignumber_1.BigNumber(transaction.gasLimit).multipliedBy(new bignumber_1.BigNumber(transaction.gasPrice)).toString(10),
|
|
@@ -251,31 +396,65 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
251
396
|
});
|
|
252
397
|
};
|
|
253
398
|
BaseEthereumProtocol.prototype.getTransactionDetailsFromSigned = function (transaction) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
399
|
+
var _a, _b;
|
|
400
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
401
|
+
var ethTx, tx, hexValue, hexGasPrice, hexGasLimit, hexNonce, chainId, to, feeTx;
|
|
402
|
+
return __generator(this, function (_c) {
|
|
403
|
+
ethTx = tx_1.TransactionFactory.fromSerializedData(Buffer.from(transaction.transaction, 'hex'));
|
|
404
|
+
if (ethTx.type === 0) {
|
|
405
|
+
tx = ethTx;
|
|
406
|
+
hexValue = tx.value.toString('hex') || '0x0';
|
|
407
|
+
hexGasPrice = tx.gasPrice.toString('hex') || '0x0';
|
|
408
|
+
hexGasLimit = tx.gasLimit.toString('hex') || '0x0';
|
|
409
|
+
hexNonce = tx.nonce.toString('hex') || '0x0';
|
|
410
|
+
chainId = tx.common.chainIdBN().toString(10);
|
|
411
|
+
to = tx.to;
|
|
412
|
+
if (!to) {
|
|
413
|
+
throw new Error('No "TO" address');
|
|
414
|
+
}
|
|
415
|
+
return [2 /*return*/, [
|
|
416
|
+
{
|
|
417
|
+
from: [tx.getSenderAddress().toString()],
|
|
418
|
+
to: [to.toString()],
|
|
419
|
+
amount: new bignumber_1.BigNumber(parseInt(hexValue, 16)).toString(10),
|
|
420
|
+
fee: new bignumber_1.BigNumber(parseInt(hexGasLimit, 16)).multipliedBy(new bignumber_1.BigNumber(parseInt(hexGasPrice, 16))).toString(10),
|
|
421
|
+
protocolIdentifier: this.identifier,
|
|
422
|
+
network: this.options.network,
|
|
423
|
+
isInbound: tx.toCreationAddress(),
|
|
424
|
+
hash: "0x" + tx.hash().toString('hex'),
|
|
425
|
+
data: "0x" + tx.data.toString('hex'),
|
|
426
|
+
extra: {
|
|
427
|
+
chainId: chainId,
|
|
428
|
+
nonce: parseInt(hexNonce, 16)
|
|
429
|
+
},
|
|
430
|
+
transactionDetails: { raw: transaction.transaction }
|
|
431
|
+
}
|
|
432
|
+
]];
|
|
433
|
+
}
|
|
434
|
+
try {
|
|
435
|
+
feeTx = ethTx;
|
|
436
|
+
return [2 /*return*/, [
|
|
437
|
+
{
|
|
438
|
+
from: [feeTx.getSenderAddress().toString()],
|
|
439
|
+
to: [(_b = (_a = feeTx.to) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''],
|
|
440
|
+
amount: new bignumber_1.BigNumber(feeTx.value.toString(10)).toString(10),
|
|
441
|
+
fee: new bignumber_1.BigNumber(feeTx.gasLimit.toString(10)).multipliedBy(new bignumber_1.BigNumber(feeTx.maxFeePerGas.toString(10))).toString(10),
|
|
442
|
+
protocolIdentifier: this.identifier,
|
|
443
|
+
network: this.options.network,
|
|
444
|
+
isInbound: false,
|
|
445
|
+
data: feeTx.data.toString('hex'),
|
|
446
|
+
extra: {
|
|
447
|
+
chainId: feeTx.chainId.toString(10),
|
|
448
|
+
nonce: feeTx.nonce.toString(10)
|
|
449
|
+
},
|
|
450
|
+
transactionDetails: { raw: transaction.transaction }
|
|
451
|
+
}
|
|
452
|
+
]];
|
|
453
|
+
}
|
|
454
|
+
catch (e) {
|
|
455
|
+
throw new Error("Transaction type \"" + ethTx.type + "\" not supported");
|
|
456
|
+
}
|
|
457
|
+
return [2 /*return*/];
|
|
279
458
|
});
|
|
280
459
|
});
|
|
281
460
|
};
|
|
@@ -334,7 +513,17 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
334
513
|
};
|
|
335
514
|
BaseEthereumProtocol.prototype.getBalanceOfExtendedPublicKey = function (extendedPublicKey, offset) {
|
|
336
515
|
if (offset === void 0) { offset = 0; }
|
|
337
|
-
return
|
|
516
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
517
|
+
var publicKey;
|
|
518
|
+
return __generator(this, function (_a) {
|
|
519
|
+
switch (_a.label) {
|
|
520
|
+
case 0: return [4 /*yield*/, this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, 0, 0)];
|
|
521
|
+
case 1:
|
|
522
|
+
publicKey = _a.sent();
|
|
523
|
+
return [2 /*return*/, this.getBalanceOfPublicKey(publicKey)];
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
});
|
|
338
527
|
};
|
|
339
528
|
BaseEthereumProtocol.prototype.getAvailableBalanceOfAddresses = function (addresses) {
|
|
340
529
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -344,17 +533,43 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
344
533
|
});
|
|
345
534
|
};
|
|
346
535
|
BaseEthereumProtocol.prototype.estimateMaxTransactionValueFromExtendedPublicKey = function (extendedPublicKey, recipients, fee) {
|
|
347
|
-
return
|
|
536
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
537
|
+
var publicKey;
|
|
538
|
+
return __generator(this, function (_a) {
|
|
539
|
+
switch (_a.label) {
|
|
540
|
+
case 0: return [4 /*yield*/, this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, 0, 0)];
|
|
541
|
+
case 1:
|
|
542
|
+
publicKey = _a.sent();
|
|
543
|
+
return [2 /*return*/, this.estimateMaxTransactionValueFromPublicKey(publicKey, recipients, fee)];
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
});
|
|
348
547
|
};
|
|
349
|
-
BaseEthereumProtocol.prototype.estimateFeeDefaultsFromExtendedPublicKey = function (
|
|
548
|
+
BaseEthereumProtocol.prototype.estimateFeeDefaultsFromExtendedPublicKey = function (extendedPublicKey, recipients, values, data) {
|
|
350
549
|
return __awaiter(this, void 0, void 0, function () {
|
|
550
|
+
var publicKey;
|
|
351
551
|
return __generator(this, function (_a) {
|
|
352
|
-
|
|
552
|
+
switch (_a.label) {
|
|
553
|
+
case 0: return [4 /*yield*/, this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, 0, 0)];
|
|
554
|
+
case 1:
|
|
555
|
+
publicKey = _a.sent();
|
|
556
|
+
return [2 /*return*/, this.estimateFeeDefaultsFromPublicKey(publicKey, recipients, values, data)];
|
|
557
|
+
}
|
|
353
558
|
});
|
|
354
559
|
});
|
|
355
560
|
};
|
|
356
|
-
BaseEthereumProtocol.prototype.prepareTransactionFromExtendedPublicKey = function (extendedPublicKey,
|
|
357
|
-
return
|
|
561
|
+
BaseEthereumProtocol.prototype.prepareTransactionFromExtendedPublicKey = function (extendedPublicKey, _offset, recipients, values, fee, data) {
|
|
562
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
563
|
+
var publicKey;
|
|
564
|
+
return __generator(this, function (_a) {
|
|
565
|
+
switch (_a.label) {
|
|
566
|
+
case 0: return [4 /*yield*/, this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, 0, 0)];
|
|
567
|
+
case 1:
|
|
568
|
+
publicKey = _a.sent();
|
|
569
|
+
return [2 /*return*/, this.prepareTransactionFromPublicKey(publicKey, recipients, values, fee, data)];
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
});
|
|
358
573
|
};
|
|
359
574
|
BaseEthereumProtocol.prototype.estimateMaxTransactionValueFromPublicKey = function (publicKey, recipients, fee) {
|
|
360
575
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -473,7 +688,17 @@ var BaseEthereumProtocol = /** @class */ (function () {
|
|
|
473
688
|
});
|
|
474
689
|
};
|
|
475
690
|
BaseEthereumProtocol.prototype.getTransactionsFromExtendedPublicKey = function (extendedPublicKey, limit, cursor) {
|
|
476
|
-
return
|
|
691
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
692
|
+
var publicKey;
|
|
693
|
+
return __generator(this, function (_a) {
|
|
694
|
+
switch (_a.label) {
|
|
695
|
+
case 0: return [4 /*yield*/, this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, 0, 0)];
|
|
696
|
+
case 1:
|
|
697
|
+
publicKey = _a.sent();
|
|
698
|
+
return [2 /*return*/, this.getTransactionsFromPublicKey(publicKey, limit, cursor)];
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
});
|
|
477
702
|
};
|
|
478
703
|
BaseEthereumProtocol.prototype.getTransactionsFromPublicKey = function (publicKey, limit, cursor) {
|
|
479
704
|
if (limit === void 0) { limit = 50; }
|