@airgap/coinlib-core 0.13.7-beta.0 → 0.13.7-beta.2
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/actions/GetKtAccountsAction.js +1 -1
- package/actions/GetKtAccountsAction.js.map +1 -1
- package/airgap-coinlib-core.min.js +2914 -2332
- package/index.d.ts +1 -3
- package/index.js +1 -6
- package/index.js.map +1 -1
- package/interfaces/IAirGapAddress.d.ts +19 -0
- package/interfaces/IAirGapAddress.js +3 -0
- package/interfaces/IAirGapAddress.js.map +1 -0
- package/package.json +1 -1
- package/protocols/CryptoClient.d.ts +4 -5
- package/protocols/Ed25519CryptoClient.d.ts +1 -2
- package/protocols/Ed25519CryptoClient.js +1 -1
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinBaseProtocol.d.ts +47 -0
- package/protocols/ICoinBaseProtocol.js +3 -0
- package/protocols/ICoinBaseProtocol.js.map +1 -0
- package/protocols/ICoinOfflineProtocol.d.ts +22 -0
- package/protocols/ICoinOfflineProtocol.js +3 -0
- package/protocols/ICoinOfflineProtocol.js.map +1 -0
- package/protocols/ICoinOnlineProtocol.d.ts +46 -0
- package/protocols/ICoinOnlineProtocol.js +3 -0
- package/protocols/ICoinOnlineProtocol.js.map +1 -0
- package/protocols/ICoinProtocol.d.ts +4 -110
- package/protocols/ICoinSubProtocol.d.ts +3 -3
- package/protocols/NonExtendedProtocol.d.ts +4 -3
- package/protocols/NonExtendedProtocol.js +4 -1
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/Secp256k1CryptoClient.d.ts +1 -2
- package/protocols/Secp256k1CryptoClient.js +1 -1
- package/protocols/Secp256k1CryptoClient.js.map +1 -1
- package/protocols/Sr25519CryptoClient.d.ts +1 -2
- package/protocols/aeternity/AeternityAddress.d.ts +1 -1
- package/protocols/aeternity/AeternityAddress.js +1 -1
- package/protocols/aeternity/AeternityCryptoClient.d.ts +1 -2
- package/protocols/aeternity/AeternityCryptoClient.js +1 -1
- package/protocols/aeternity/AeternityCryptoClient.js.map +1 -1
- package/protocols/aeternity/AeternityProtocol.d.ts +41 -33
- package/protocols/aeternity/AeternityProtocol.js +70 -56
- package/protocols/aeternity/AeternityProtocol.js.map +1 -1
- package/protocols/aeternity/AeternityTypes.d.ts +6 -0
- package/protocols/bitcoin/BitcoinAddress.d.ts +1 -1
- package/protocols/bitcoin/BitcoinAddress.js +1 -1
- package/protocols/bitcoin/BitcoinCryptoClient.d.ts +1 -2
- package/protocols/bitcoin/BitcoinCryptoClient.js +2 -2
- package/protocols/bitcoin/BitcoinCryptoClient.js.map +1 -1
- package/protocols/bitcoin/BitcoinProtocol.d.ts +43 -32
- package/protocols/bitcoin/BitcoinProtocol.js +98 -79
- package/protocols/bitcoin/BitcoinProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinSegwitAddress.d.ts +1 -1
- package/protocols/bitcoin/BitcoinSegwitAddress.js +1 -1
- package/protocols/bitcoin/BitcoinSegwitProtocol.d.ts +10 -11
- package/protocols/bitcoin/BitcoinSegwitProtocol.js +42 -29
- package/protocols/bitcoin/BitcoinSegwitProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinTestnetProtocol.d.ts +6 -3
- package/protocols/bitcoin/BitcoinTestnetProtocol.js +6 -3
- package/protocols/bitcoin/BitcoinTestnetProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinTypes.d.ts +6 -0
- package/protocols/cosmos/CosmosAddress.d.ts +1 -1
- package/protocols/cosmos/CosmosAddress.js +1 -1
- package/protocols/cosmos/CosmosCryptoClient.d.ts +1 -2
- package/protocols/cosmos/CosmosCryptoClient.js +1 -1
- package/protocols/cosmos/CosmosCryptoClient.js.map +1 -1
- package/protocols/cosmos/CosmosProtocol.d.ts +41 -29
- package/protocols/cosmos/CosmosProtocol.js +72 -58
- package/protocols/cosmos/CosmosProtocol.js.map +1 -1
- package/protocols/cosmos/CosmosTransaction.d.ts +3 -2
- package/protocols/cosmos/CosmosTransaction.js +2 -2
- package/protocols/cosmos/CosmosTransaction.js.map +1 -1
- package/protocols/cosmos/CosmosTypes.d.ts +6 -0
- package/protocols/cosmos/CosmosTypes.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.d.ts +3 -2
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.js +3 -3
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosMessage.d.ts +3 -2
- package/protocols/cosmos/cosmos-message/CosmosMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.d.ts +2 -2
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.js +3 -3
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +3 -2
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +3 -3
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -1
- package/protocols/ethereum/BaseEthereumProtocol.d.ts +43 -31
- package/protocols/ethereum/BaseEthereumProtocol.js +95 -76
- package/protocols/ethereum/BaseEthereumProtocol.js.map +1 -1
- package/protocols/ethereum/EthereumAddress.d.ts +1 -1
- package/protocols/ethereum/EthereumAddress.js +1 -1
- package/protocols/ethereum/EthereumCryptoClient.d.ts +1 -2
- package/protocols/ethereum/EthereumCryptoClient.js +8 -7
- package/protocols/ethereum/EthereumCryptoClient.js.map +1 -1
- package/protocols/ethereum/EthereumProtocol.d.ts +6 -4
- package/protocols/ethereum/EthereumProtocol.js +8 -6
- package/protocols/ethereum/EthereumProtocol.js.map +1 -1
- package/protocols/ethereum/EthereumTypes.d.ts +6 -0
- package/protocols/ethereum/clients/info-clients/EtherscanInfoClient.js +82 -58
- package/protocols/ethereum/clients/info-clients/EtherscanInfoClient.js.map +1 -1
- package/protocols/ethereum/clients/info-clients/InfoClient.d.ts +3 -3
- package/protocols/ethereum/erc20/GenericERC20.d.ts +10 -7
- package/protocols/ethereum/erc20/GenericERC20.js +27 -23
- package/protocols/ethereum/erc20/GenericERC20.js.map +1 -1
- package/protocols/groestlcoin/GroestlcoinProtocol.d.ts +29 -15
- package/protocols/groestlcoin/GroestlcoinProtocol.js +31 -17
- package/protocols/groestlcoin/GroestlcoinProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateCryptoClient.d.ts +1 -2
- package/protocols/substrate/SubstrateCryptoClient.js +7 -7
- package/protocols/substrate/SubstrateCryptoClient.js.map +1 -1
- package/protocols/substrate/SubstrateDelegateProtocol.js +35 -35
- package/protocols/substrate/SubstrateDelegateProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateProtocol.d.ts +43 -29
- package/protocols/substrate/SubstrateProtocol.js +60 -52
- package/protocols/substrate/SubstrateProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateTypes.d.ts +6 -0
- package/protocols/substrate/astar/AstarProtocol.d.ts +28 -15
- package/protocols/substrate/astar/AstarProtocol.js +30 -17
- package/protocols/substrate/astar/AstarProtocol.js.map +1 -1
- package/protocols/substrate/astar/shiden/ShidenProtocol.d.ts +22 -11
- package/protocols/substrate/astar/shiden/ShidenProtocol.js +24 -13
- package/protocols/substrate/astar/shiden/ShidenProtocol.js.map +1 -1
- package/protocols/substrate/common/SubstrateAccountController.js +4 -4
- package/protocols/substrate/common/data/account/SubstrateAddress.d.ts +1 -1
- package/protocols/substrate/common/data/account/SubstrateAddress.js +2 -2
- package/protocols/substrate/common/data/scale/type/SCALEAccountId.js +1 -1
- package/protocols/substrate/common/data/transaction/SubstrateTransactionPayload.d.ts +1 -1
- package/protocols/substrate/common/data/transaction/method/SubstrateTransactionMethodArgs.js +12 -12
- package/protocols/substrate/kusama/KusamaProtocol.d.ts +28 -15
- package/protocols/substrate/kusama/KusamaProtocol.js +30 -17
- package/protocols/substrate/kusama/KusamaProtocol.js.map +1 -1
- package/protocols/substrate/moonbeam/MoonbeamProtocol.d.ts +28 -15
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js +61 -48
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js.map +1 -1
- package/protocols/substrate/moonbeam/controllers/MoonbeamAccountController.js +3 -3
- package/protocols/substrate/moonbeam/data/account/MoonbeamAddress.d.ts +1 -1
- package/protocols/substrate/moonbeam/data/account/MoonbeamAddress.js +3 -3
- package/protocols/substrate/moonbeam/moonbase/MoonbaseProtocol.d.ts +20 -12
- package/protocols/substrate/moonbeam/moonbase/MoonbaseProtocol.js +22 -14
- package/protocols/substrate/moonbeam/moonbase/MoonbaseProtocol.js.map +1 -1
- package/protocols/substrate/moonbeam/moonriver/MoonriverProtocol.d.ts +20 -12
- package/protocols/substrate/moonbeam/moonriver/MoonriverProtocol.js +22 -14
- package/protocols/substrate/moonbeam/moonriver/MoonriverProtocol.js.map +1 -1
- package/protocols/substrate/polkadot/PolkadotProtocol.d.ts +28 -15
- package/protocols/substrate/polkadot/PolkadotProtocol.js +30 -17
- package/protocols/substrate/polkadot/PolkadotProtocol.js.map +1 -1
- package/protocols/tezos/TezosAddress.d.ts +1 -1
- package/protocols/tezos/TezosAddress.js +1 -1
- package/protocols/tezos/TezosCryptoClient.d.ts +1 -1
- package/protocols/tezos/TezosCryptoClient.js +1 -1
- package/protocols/tezos/TezosCryptoClient.js.map +1 -1
- package/protocols/tezos/TezosProtocol.d.ts +42 -29
- package/protocols/tezos/TezosProtocol.js +105 -94
- package/protocols/tezos/TezosProtocol.js.map +1 -1
- package/protocols/tezos/contract/TezosContract.js +1 -0
- package/protocols/tezos/contract/TezosContract.js.map +1 -1
- package/protocols/tezos/fa/TezosBTC.d.ts +0 -1
- package/protocols/tezos/fa/TezosBTC.js +1 -3
- package/protocols/tezos/fa/TezosBTC.js.map +1 -1
- package/protocols/tezos/fa/TezosBTCtez.d.ts +0 -1
- package/protocols/tezos/fa/TezosBTCtez.js +1 -3
- package/protocols/tezos/fa/TezosBTCtez.js.map +1 -1
- package/protocols/tezos/fa/TezosCTez.d.ts +0 -1
- package/protocols/tezos/fa/TezosCTez.js +1 -3
- package/protocols/tezos/fa/TezosCTez.js.map +1 -1
- package/protocols/tezos/fa/TezosDOGA.d.ts +0 -1
- package/protocols/tezos/fa/TezosDOGA.js +1 -3
- package/protocols/tezos/fa/TezosDOGA.js.map +1 -1
- package/protocols/tezos/fa/TezosETHtz.d.ts +0 -1
- package/protocols/tezos/fa/TezosETHtz.js +1 -3
- package/protocols/tezos/fa/TezosETHtz.js.map +1 -1
- package/protocols/tezos/fa/TezosFA1Protocol.js +6 -6
- package/protocols/tezos/fa/TezosFA1Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFA2Protocol.d.ts +3 -2
- package/protocols/tezos/fa/TezosFA2Protocol.js +10 -9
- package/protocols/tezos/fa/TezosFA2Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFAProtocol.d.ts +9 -5
- package/protocols/tezos/fa/TezosFAProtocol.js +48 -35
- package/protocols/tezos/fa/TezosFAProtocol.js.map +1 -1
- package/protocols/tezos/fa/TezosKolibriUSD.d.ts +0 -1
- package/protocols/tezos/fa/TezosKolibriUSD.js +1 -3
- package/protocols/tezos/fa/TezosKolibriUSD.js.map +1 -1
- package/protocols/tezos/fa/TezosPlanty.d.ts +0 -1
- package/protocols/tezos/fa/TezosPlanty.js +1 -3
- package/protocols/tezos/fa/TezosPlanty.js.map +1 -1
- package/protocols/tezos/fa/TezosQUIPU.d.ts +0 -1
- package/protocols/tezos/fa/TezosQUIPU.js +1 -3
- package/protocols/tezos/fa/TezosQUIPU.js.map +1 -1
- package/protocols/tezos/fa/TezosSIRS.d.ts +0 -1
- package/protocols/tezos/fa/TezosSIRS.js +1 -3
- package/protocols/tezos/fa/TezosSIRS.js.map +1 -1
- package/protocols/tezos/fa/TezosStaker.d.ts +0 -1
- package/protocols/tezos/fa/TezosStaker.js +1 -3
- package/protocols/tezos/fa/TezosStaker.js.map +1 -1
- package/protocols/tezos/fa/TezosUBTC.d.ts +0 -1
- package/protocols/tezos/fa/TezosUBTC.js +1 -3
- package/protocols/tezos/fa/TezosUBTC.js.map +1 -1
- package/protocols/tezos/fa/TezosUDEFI.d.ts +0 -1
- package/protocols/tezos/fa/TezosUDEFI.js +1 -3
- package/protocols/tezos/fa/TezosUDEFI.js.map +1 -1
- package/protocols/tezos/fa/TezosUSD.d.ts +0 -1
- package/protocols/tezos/fa/TezosUSD.js +1 -3
- package/protocols/tezos/fa/TezosUSD.js.map +1 -1
- package/protocols/tezos/fa/TezosUSDT.d.ts +0 -1
- package/protocols/tezos/fa/TezosUSDT.js +1 -3
- package/protocols/tezos/fa/TezosUSDT.js.map +1 -1
- package/protocols/tezos/fa/TezosUUSD.d.ts +0 -1
- package/protocols/tezos/fa/TezosUUSD.js +1 -3
- package/protocols/tezos/fa/TezosUUSD.js.map +1 -1
- package/protocols/tezos/fa/TezosWRAP.d.ts +0 -1
- package/protocols/tezos/fa/TezosWRAP.js +1 -3
- package/protocols/tezos/fa/TezosWRAP.js.map +1 -1
- package/protocols/tezos/fa/TezosWrapped.d.ts +0 -1
- package/protocols/tezos/fa/TezosWrapped.js +1 -3
- package/protocols/tezos/fa/TezosWrapped.js.map +1 -1
- package/protocols/tezos/fa/TezosYOU.d.ts +0 -1
- package/protocols/tezos/fa/TezosYOU.js +1 -3
- package/protocols/tezos/fa/TezosYOU.js.map +1 -1
- package/protocols/tezos/kt/TezosKtProtocol.d.ts +10 -7
- package/protocols/tezos/kt/TezosKtProtocol.js +50 -20
- package/protocols/tezos/kt/TezosKtProtocol.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingCryptoClient.d.ts +1 -1
- package/protocols/tezos/sapling/TezosSaplingProtocol.d.ts +43 -28
- package/protocols/tezos/sapling/TezosSaplingProtocol.js +129 -69
- package/protocols/tezos/sapling/TezosSaplingProtocol.js.map +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingBookkeeper.js +7 -7
- package/protocols/tezos/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
- package/protocols/tezos/types/TezosAddressCursor.d.ts +3 -0
- package/protocols/tezos/types/TezosAddressCursor.js +3 -0
- package/protocols/tezos/types/TezosAddressCursor.js.map +1 -0
- package/protocols/tezos/types/TezosAddressResult.d.ts +4 -0
- package/protocols/tezos/types/TezosAddressResult.js +3 -0
- package/protocols/tezos/types/TezosAddressResult.js.map +1 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.d.ts +4 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.js +3 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.js.map +1 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.d.ts +5 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.js +3 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.js.map +1 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.d.ts +4 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.js +3 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.js.map +1 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.d.ts +4 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.js +3 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.js.map +1 -0
- package/serializer/unsigned-transactions/xtz-btc-transactions.validator.js +23 -10
- package/serializer/unsigned-transactions/xtz-btc-transactions.validator.js.map +1 -1
- package/serializer/validators/validators.js +246 -140
- package/serializer/validators/validators.js.map +1 -1
- package/serializer-v3/unsigned-transactions/xtz-btc-transactions.validator.js +23 -10
- package/serializer-v3/unsigned-transactions/xtz-btc-transactions.validator.js.map +1 -1
- package/serializer-v3/validators/validators.js +246 -140
- package/serializer-v3/validators/validators.js.map +1 -1
- package/utils/AES.d.ts +2 -3
- package/utils/AES.js +3 -1
- package/utils/AES.js.map +1 -1
- package/utils/protocolsByIdentifier.d.ts +1 -1
- package/utils/protocolsByIdentifier.js +114 -24
- package/utils/protocolsByIdentifier.js.map +1 -1
- package/utils/supportedProtocols.d.ts +2 -2
- package/utils/supportedProtocols.js +114 -12
- package/utils/supportedProtocols.js.map +1 -1
- package/wallet/AirGapCoinWallet.d.ts +1 -1
- package/wallet/AirGapCoinWallet.js +45 -27
- package/wallet/AirGapCoinWallet.js.map +1 -1
- package/wallet/AirGapMarketWallet.js +28 -24
- package/wallet/AirGapMarketWallet.js.map +1 -1
- package/wallet/AirGapNFTWallet.d.ts +1 -1
- package/wallet/AirGapNFTWallet.js +26 -5
- package/wallet/AirGapNFTWallet.js.map +1 -1
- package/wallet/AirGapWallet.d.ts +1 -1
- package/wallet/AirGapWallet.js +23 -12
- package/wallet/AirGapWallet.js.map +1 -1
- package/utils/createProtocol.d.ts +0 -3
- package/utils/createProtocol.js +0 -143
- package/utils/createProtocol.js.map +0 -1
- package/utils/subProtocols.d.ts +0 -8
- package/utils/subProtocols.js +0 -53
- package/utils/subProtocols.js.map +0 -1
|
@@ -91,7 +91,6 @@ var index_2 = require("../../dependencies/src/bip39-2.5.0/index");
|
|
|
91
91
|
var bs58check = __importStar(require("../../dependencies/src/bs58check-2.1.2/index"));
|
|
92
92
|
var index_3 = require("../../dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/index");
|
|
93
93
|
var ProtocolSymbols_1 = require("../../utils/ProtocolSymbols");
|
|
94
|
-
var subProtocols_1 = require("../../utils/subProtocols");
|
|
95
94
|
var NonExtendedProtocol_1 = require("../NonExtendedProtocol");
|
|
96
95
|
var TezosAddress_1 = require("./TezosAddress");
|
|
97
96
|
var TezosCryptoClient_1 = require("./TezosCryptoClient");
|
|
@@ -124,34 +123,49 @@ var TezosNetwork;
|
|
|
124
123
|
})(TezosNetwork = exports.TezosNetwork || (exports.TezosNetwork = {}));
|
|
125
124
|
var TezosProtocol = /** @class */ (function (_super) {
|
|
126
125
|
__extends(TezosProtocol, _super);
|
|
127
|
-
function TezosProtocol(
|
|
128
|
-
if (
|
|
126
|
+
function TezosProtocol(_options) {
|
|
127
|
+
if (_options === void 0) { _options = new TezosProtocolOptions_1.TezosProtocolOptions(); }
|
|
129
128
|
var _this = _super.call(this) || this;
|
|
130
|
-
_this.
|
|
131
|
-
_this.
|
|
132
|
-
_this.
|
|
133
|
-
_this.
|
|
134
|
-
_this.
|
|
135
|
-
_this.
|
|
136
|
-
_this.
|
|
137
|
-
_this.
|
|
129
|
+
_this._options = _options;
|
|
130
|
+
_this._symbol = 'XTZ';
|
|
131
|
+
_this.symbol = Promise.resolve(_this._symbol);
|
|
132
|
+
_this._name = 'Tezos';
|
|
133
|
+
_this.name = Promise.resolve(_this._name);
|
|
134
|
+
_this._marketSymbol = 'xtz';
|
|
135
|
+
_this.marketSymbol = Promise.resolve(_this._marketSymbol);
|
|
136
|
+
_this._feeSymbol = 'xtz';
|
|
137
|
+
_this.feeSymbol = Promise.resolve(_this._feeSymbol);
|
|
138
|
+
_this._decimals = 6;
|
|
139
|
+
_this.decimals = Promise.resolve(_this._decimals);
|
|
140
|
+
_this._feeDecimals = 6; // micro tez is the smallest, 1000000 microtez is 1 tez
|
|
141
|
+
_this.feeDecimals = Promise.resolve(_this._feeDecimals);
|
|
142
|
+
_this._identifier = ProtocolSymbols_1.MainProtocolSymbols.XTZ;
|
|
143
|
+
_this.identifier = Promise.resolve(_this._identifier);
|
|
138
144
|
// tezbox default
|
|
139
|
-
_this.
|
|
145
|
+
_this._feeDefaults = {
|
|
140
146
|
low: '0.001420',
|
|
141
147
|
medium: '0.001520',
|
|
142
148
|
high: '0.003000'
|
|
143
149
|
};
|
|
144
|
-
_this.
|
|
150
|
+
_this.feeDefaults = Promise.resolve(_this._feeDefaults);
|
|
151
|
+
_this._units = [
|
|
145
152
|
{
|
|
146
153
|
unitSymbol: 'XTZ',
|
|
147
154
|
factor: '1'
|
|
148
155
|
}
|
|
149
156
|
];
|
|
150
|
-
_this.
|
|
151
|
-
_this.
|
|
152
|
-
_this.
|
|
153
|
-
_this.
|
|
154
|
-
_this.
|
|
157
|
+
_this.units = Promise.resolve(_this._units);
|
|
158
|
+
_this._supportsHD = false;
|
|
159
|
+
_this.supportsHD = Promise.resolve(_this._supportsHD);
|
|
160
|
+
_this._standardDerivationPath = "m/44h/1729h/0h/0h";
|
|
161
|
+
_this.standardDerivationPath = Promise.resolve(_this._standardDerivationPath);
|
|
162
|
+
_this._addressIsCaseSensitive = true;
|
|
163
|
+
_this.addressIsCaseSensitive = Promise.resolve(_this._addressIsCaseSensitive);
|
|
164
|
+
_this._addressValidationPattern = '^((tz1|tz2|tz3|KT1)[1-9A-Za-z]{33}|zet1[1-9A-Za-z]{65})$';
|
|
165
|
+
_this.addressValidationPattern = Promise.resolve(_this._addressValidationPattern);
|
|
166
|
+
_this._addressPlaceholder = 'tz1...';
|
|
167
|
+
_this.addressPlaceholder = Promise.resolve(_this._addressPlaceholder);
|
|
168
|
+
_this.options = Promise.resolve(_this._options);
|
|
155
169
|
// https://gitlab.com/tezos/tezos/-/blob/master/docs/whitedoc/proof_of_stake.rst
|
|
156
170
|
// cycle has 4096 blocks, which are at least one minute apart
|
|
157
171
|
_this.minCycleDuration = 4096 * 60 * 1000; // ms
|
|
@@ -164,17 +178,10 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
164
178
|
_this.cryptoClient = new TezosCryptoClient_1.TezosCryptoClient(TezosUtils_1.TezosUtils.tezosPrefixes.edsig);
|
|
165
179
|
return _this;
|
|
166
180
|
}
|
|
167
|
-
Object.defineProperty(TezosProtocol.prototype, "subProtocols", {
|
|
168
|
-
get: function () {
|
|
169
|
-
return subProtocols_1.getSubProtocolsByIdentifier(this.identifier, this.options.network);
|
|
170
|
-
},
|
|
171
|
-
enumerable: false,
|
|
172
|
-
configurable: true
|
|
173
|
-
});
|
|
174
181
|
Object.defineProperty(TezosProtocol.prototype, "jsonRPCAPI", {
|
|
175
|
-
// TODO: Should we remove these getters and replace the calls to `this.
|
|
182
|
+
// TODO: Should we remove these getters and replace the calls to `this._options.network...`?
|
|
176
183
|
get: function () {
|
|
177
|
-
return this.
|
|
184
|
+
return this._options.network.rpcUrl;
|
|
178
185
|
},
|
|
179
186
|
enumerable: false,
|
|
180
187
|
configurable: true
|
|
@@ -182,14 +189,14 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
182
189
|
TezosProtocol.prototype.getBlockExplorerLinkForAddress = function (address) {
|
|
183
190
|
return __awaiter(this, void 0, void 0, function () {
|
|
184
191
|
return __generator(this, function (_a) {
|
|
185
|
-
return [2 /*return*/, this.
|
|
192
|
+
return [2 /*return*/, this._options.network.blockExplorer.getAddressLink(address)];
|
|
186
193
|
});
|
|
187
194
|
});
|
|
188
195
|
};
|
|
189
196
|
TezosProtocol.prototype.getBlockExplorerLinkForTxId = function (txId) {
|
|
190
197
|
return __awaiter(this, void 0, void 0, function () {
|
|
191
198
|
return __generator(this, function (_a) {
|
|
192
|
-
return [2 /*return*/, this.
|
|
199
|
+
return [2 /*return*/, this._options.network.blockExplorer.getTransactionLink(txId)];
|
|
193
200
|
});
|
|
194
201
|
});
|
|
195
202
|
};
|
|
@@ -237,23 +244,32 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
237
244
|
return __generator(this, function (_a) {
|
|
238
245
|
secretKey = index_3.generateWalletUsingDerivationPath(Buffer.from(secret, 'hex'), derivationPath) // TODO: Look into typings
|
|
239
246
|
.secretKey;
|
|
240
|
-
return [2 /*return*/, Buffer.from(secretKey)];
|
|
247
|
+
return [2 /*return*/, Buffer.from(secretKey).toString('hex')];
|
|
241
248
|
});
|
|
242
249
|
});
|
|
243
250
|
};
|
|
244
|
-
TezosProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
251
|
+
TezosProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
245
252
|
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
var address;
|
|
246
254
|
return __generator(this, function (_a) {
|
|
247
|
-
|
|
255
|
+
switch (_a.label) {
|
|
256
|
+
case 0: return [4 /*yield*/, TezosAddress_1.TezosAddress.fromPublicKey(publicKey)];
|
|
257
|
+
case 1:
|
|
258
|
+
address = _a.sent();
|
|
259
|
+
return [2 /*return*/, {
|
|
260
|
+
address: address.asString(),
|
|
261
|
+
cursor: { hasNext: false }
|
|
262
|
+
}];
|
|
263
|
+
}
|
|
248
264
|
});
|
|
249
265
|
});
|
|
250
266
|
};
|
|
251
|
-
TezosProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
267
|
+
TezosProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
252
268
|
return __awaiter(this, void 0, void 0, function () {
|
|
253
269
|
var address;
|
|
254
270
|
return __generator(this, function (_a) {
|
|
255
271
|
switch (_a.label) {
|
|
256
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
272
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
257
273
|
case 1:
|
|
258
274
|
address = _a.sent();
|
|
259
275
|
return [2 /*return*/, [address]];
|
|
@@ -261,20 +277,13 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
261
277
|
});
|
|
262
278
|
});
|
|
263
279
|
};
|
|
264
|
-
TezosProtocol.prototype.getNextAddressFromPublicKey = function (publicKey, current) {
|
|
265
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
266
|
-
return __generator(this, function (_a) {
|
|
267
|
-
return [2 /*return*/, current];
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
};
|
|
271
280
|
TezosProtocol.prototype.getTransactionsFromPublicKey = function (publicKey, limit, cursor) {
|
|
272
281
|
return __awaiter(this, void 0, void 0, function () {
|
|
273
282
|
var addresses;
|
|
274
283
|
return __generator(this, function (_a) {
|
|
275
284
|
switch (_a.label) {
|
|
276
285
|
case 0: return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey).then(function (addresses) {
|
|
277
|
-
return addresses.map(function (address) { return address.
|
|
286
|
+
return addresses.map(function (address) { return address.address; });
|
|
278
287
|
})];
|
|
279
288
|
case 1:
|
|
280
289
|
addresses = _a.sent();
|
|
@@ -292,11 +301,11 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
292
301
|
switch (_b.label) {
|
|
293
302
|
case 0:
|
|
294
303
|
address = addresses[0];
|
|
295
|
-
return [4 /*yield*/, this.
|
|
304
|
+
return [4 /*yield*/, this._options.network.extras.indexerClient.getTransactions(address, limit, cursor === null || cursor === void 0 ? void 0 : cursor.offset)];
|
|
296
305
|
case 1:
|
|
297
306
|
results = _b.sent();
|
|
298
307
|
return [2 /*return*/, {
|
|
299
|
-
transactions: results.map(function (transaction) { return (__assign(__assign({}, transaction), { protocolIdentifier: _this.
|
|
308
|
+
transactions: results.map(function (transaction) { return (__assign(__assign({}, transaction), { protocolIdentifier: _this._identifier, network: _this._options.network })); }),
|
|
300
309
|
cursor: { offset: ((_a = cursor === null || cursor === void 0 ? void 0 : cursor.offset) !== null && _a !== void 0 ? _a : 0) + results.length }
|
|
301
310
|
}];
|
|
302
311
|
}
|
|
@@ -308,7 +317,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
308
317
|
var opSignature, signedOpBytes;
|
|
309
318
|
return __generator(this, function (_a) {
|
|
310
319
|
switch (_a.label) {
|
|
311
|
-
case 0: return [4 /*yield*/, this.cryptoClient.operationSignature(privateKey, transaction)];
|
|
320
|
+
case 0: return [4 /*yield*/, this.cryptoClient.operationSignature(Buffer.from(privateKey, 'hex'), transaction)];
|
|
312
321
|
case 1:
|
|
313
322
|
opSignature = _a.sent();
|
|
314
323
|
signedOpBytes = Buffer.concat([Buffer.from(transaction.binaryTransaction, 'hex'), Buffer.from(opSignature)]);
|
|
@@ -419,10 +428,11 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
419
428
|
return [3 /*break*/, 8];
|
|
420
429
|
case 6: throw new index_4.UnsupportedError(coinlib_error_1.Domain.TEZOS, 'operation not supported: ' + JSON.stringify(tezosOperation.kind));
|
|
421
430
|
case 7:
|
|
431
|
+
// Exhaustive switch
|
|
422
432
|
assertNever(tezosOperation.kind);
|
|
423
433
|
throw new index_4.NotFoundError(coinlib_error_1.Domain.TEZOS, 'no operation to unforge found');
|
|
424
434
|
case 8: return [2 /*return*/, partialTxs.map(function (partialTx) {
|
|
425
|
-
return __assign({ amount: '0', fee: operation !== undefined ? new bignumber_1.default(operation.fee).toString(10) : '0', from: [], isInbound: false, protocolIdentifier: _this.
|
|
435
|
+
return __assign({ amount: '0', fee: operation !== undefined ? new bignumber_1.default(operation.fee).toString(10) : '0', from: [], isInbound: false, protocolIdentifier: _this._identifier, network: _this._options.network, to: [], transactionDetails: tezosOperation }, partialTx);
|
|
426
436
|
})];
|
|
427
437
|
}
|
|
428
438
|
});
|
|
@@ -447,7 +457,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
447
457
|
_a.label = 2;
|
|
448
458
|
case 2:
|
|
449
459
|
_a.trys.push([2, 4, , 5]);
|
|
450
|
-
return [4 /*yield*/, index_1.default.get(this.
|
|
460
|
+
return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address + "/balance")];
|
|
451
461
|
case 3:
|
|
452
462
|
data = (_a.sent()).data;
|
|
453
463
|
balance = balance.plus(new bignumber_1.default(data));
|
|
@@ -475,7 +485,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
475
485
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
476
486
|
case 1:
|
|
477
487
|
address = _a.sent();
|
|
478
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
488
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address], data)];
|
|
479
489
|
}
|
|
480
490
|
});
|
|
481
491
|
});
|
|
@@ -524,7 +534,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
524
534
|
return [4 /*yield*/, this.estimateFeeDefaultsFromPublicKey(publicKey, recipients, [balance.toFixed()])];
|
|
525
535
|
case 2:
|
|
526
536
|
estimatedFeeDefaults = _a.sent();
|
|
527
|
-
maxFee = new bignumber_1.default(estimatedFeeDefaults.medium).shiftedBy(this.
|
|
537
|
+
maxFee = new bignumber_1.default(estimatedFeeDefaults.medium).shiftedBy(this._decimals);
|
|
528
538
|
if (maxFee.gte(balance)) {
|
|
529
539
|
maxFee = new bignumber_1.default(0);
|
|
530
540
|
}
|
|
@@ -601,9 +611,9 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
601
611
|
mediumFee = lowFee.plus(lowFee.times(feeStepFactor).integerValue(bignumber_1.default.ROUND_FLOOR));
|
|
602
612
|
highFee = mediumFee.plus(mediumFee.times(feeStepFactor).integerValue(bignumber_1.default.ROUND_FLOOR));
|
|
603
613
|
return [2 /*return*/, {
|
|
604
|
-
low: lowFee.shiftedBy(-this.
|
|
605
|
-
medium: mediumFee.shiftedBy(-this.
|
|
606
|
-
high: highFee.shiftedBy(-this.
|
|
614
|
+
low: lowFee.shiftedBy(-this._feeDecimals).toFixed(),
|
|
615
|
+
medium: mediumFee.shiftedBy(-this._feeDecimals).toFixed(),
|
|
616
|
+
high: highFee.shiftedBy(-this._feeDecimals).toFixed()
|
|
607
617
|
}];
|
|
608
618
|
}
|
|
609
619
|
});
|
|
@@ -650,7 +660,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
650
660
|
operations = [];
|
|
651
661
|
addressIndex = data && data.addressIndex ? data.addressIndex : 0;
|
|
652
662
|
return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey).then(function (addresses) {
|
|
653
|
-
return addresses.map(function (address) { return address.
|
|
663
|
+
return addresses.map(function (address) { return address.address; });
|
|
654
664
|
})];
|
|
655
665
|
case 1:
|
|
656
666
|
addresses = _f.sent();
|
|
@@ -659,9 +669,9 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
659
669
|
}
|
|
660
670
|
address = addresses[addressIndex];
|
|
661
671
|
return [4 /*yield*/, Promise.all([
|
|
662
|
-
index_1.default.get(this.
|
|
663
|
-
index_1.default.get(this.
|
|
664
|
-
index_1.default.get(this.
|
|
672
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address + "/counter"),
|
|
673
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head~2/hash"),
|
|
674
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address + "/manager_key")
|
|
665
675
|
]).catch(function (error) {
|
|
666
676
|
throw new index_4.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
667
677
|
})];
|
|
@@ -815,7 +825,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
815
825
|
var activeBakers;
|
|
816
826
|
return __generator(this, function (_a) {
|
|
817
827
|
switch (_a.label) {
|
|
818
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
828
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/delegates?active")];
|
|
819
829
|
case 1:
|
|
820
830
|
activeBakers = (_a.sent()).data;
|
|
821
831
|
return [2 /*return*/, activeBakers[0] || ''];
|
|
@@ -831,7 +841,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
831
841
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
832
842
|
case 1:
|
|
833
843
|
address = _a.sent();
|
|
834
|
-
return [2 /*return*/, this.getCurrentDelegateesForAddress(address.
|
|
844
|
+
return [2 /*return*/, this.getCurrentDelegateesForAddress(address.address)];
|
|
835
845
|
}
|
|
836
846
|
});
|
|
837
847
|
});
|
|
@@ -841,7 +851,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
841
851
|
var data;
|
|
842
852
|
return __generator(this, function (_a) {
|
|
843
853
|
switch (_a.label) {
|
|
844
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
854
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address)];
|
|
845
855
|
case 1:
|
|
846
856
|
data = (_a.sent()).data;
|
|
847
857
|
return [2 /*return*/, data.delegate ? [data.delegate] : []];
|
|
@@ -854,7 +864,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
854
864
|
var response, isBakingActive;
|
|
855
865
|
return __generator(this, function (_a) {
|
|
856
866
|
switch (_a.label) {
|
|
857
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
867
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/delegates/" + address + "/deactivated")];
|
|
858
868
|
case 1:
|
|
859
869
|
response = _a.sent();
|
|
860
870
|
isBakingActive = !response.data;
|
|
@@ -874,7 +884,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
874
884
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
875
885
|
case 1:
|
|
876
886
|
address = _a.sent();
|
|
877
|
-
return [2 /*return*/, this.isAddressDelegating(address.
|
|
887
|
+
return [2 /*return*/, this.isAddressDelegating(address.address)];
|
|
878
888
|
}
|
|
879
889
|
});
|
|
880
890
|
});
|
|
@@ -884,7 +894,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
884
894
|
var data;
|
|
885
895
|
return __generator(this, function (_a) {
|
|
886
896
|
switch (_a.label) {
|
|
887
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
897
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address)];
|
|
888
898
|
case 1:
|
|
889
899
|
data = (_a.sent()).data;
|
|
890
900
|
return [2 /*return*/, !!data.delegate];
|
|
@@ -900,7 +910,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
900
910
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
901
911
|
case 1:
|
|
902
912
|
address = _a.sent();
|
|
903
|
-
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address.
|
|
913
|
+
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address.address)];
|
|
904
914
|
}
|
|
905
915
|
});
|
|
906
916
|
});
|
|
@@ -920,7 +930,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
920
930
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
921
931
|
case 1:
|
|
922
932
|
address = _a.sent();
|
|
923
|
-
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.
|
|
933
|
+
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.address, delegatees)];
|
|
924
934
|
}
|
|
925
935
|
});
|
|
926
936
|
});
|
|
@@ -954,7 +964,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
954
964
|
return __generator(this, function (_a) {
|
|
955
965
|
switch (_a.label) {
|
|
956
966
|
case 0: return [4 /*yield*/, Promise.all([
|
|
957
|
-
index_1.default.get(this.
|
|
967
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address)
|
|
958
968
|
// this.getDelegationRewardsForAddress(address).catch(() => [] as DelegationRewardInfo[])
|
|
959
969
|
])];
|
|
960
970
|
case 1:
|
|
@@ -1035,13 +1045,13 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1035
1045
|
case 0:
|
|
1036
1046
|
counter = new bignumber_1.default(1);
|
|
1037
1047
|
operations = [];
|
|
1038
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.
|
|
1048
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.address; })];
|
|
1039
1049
|
case 1:
|
|
1040
1050
|
address = _f.sent();
|
|
1041
1051
|
return [4 /*yield*/, Promise.all([
|
|
1042
|
-
index_1.default.get(this.
|
|
1043
|
-
index_1.default.get(this.
|
|
1044
|
-
index_1.default.get(this.
|
|
1052
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address + "/counter"),
|
|
1053
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head~2/hash"),
|
|
1054
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address + "/manager_key")
|
|
1045
1055
|
]).catch(function (error) {
|
|
1046
1056
|
throw new index_4.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
1047
1057
|
})];
|
|
@@ -1189,7 +1199,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1189
1199
|
var counter = startingCounter ? startingCounter.plus(i).toString() : op.counter;
|
|
1190
1200
|
return __assign(__assign({}, operation), { gas_limit: gas_limit, counter: counter });
|
|
1191
1201
|
});
|
|
1192
|
-
return [4 /*yield*/, index_1.default.get(this.
|
|
1202
|
+
return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head")];
|
|
1193
1203
|
case 1:
|
|
1194
1204
|
block = (_a.sent()).data;
|
|
1195
1205
|
body = {
|
|
@@ -1205,7 +1215,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1205
1215
|
forgedOperation = _a.sent();
|
|
1206
1216
|
gasLimitTotal = 0;
|
|
1207
1217
|
return [4 /*yield*/, index_1.default
|
|
1208
|
-
.post(this.
|
|
1218
|
+
.post(this._options.network.rpcUrl + "/chains/main/blocks/head/helpers/scripts/run_operation", body, {
|
|
1209
1219
|
headers: { 'Content-Type': 'application/json' }
|
|
1210
1220
|
})
|
|
1211
1221
|
.catch(function (runOperationError) {
|
|
@@ -1295,11 +1305,11 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1295
1305
|
var data, delegatedOpLevel, delegatedDate, recentTransactionData;
|
|
1296
1306
|
return __generator(this, function (_a) {
|
|
1297
1307
|
switch (_a.label) {
|
|
1298
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
1308
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + delegatedAddress)];
|
|
1299
1309
|
case 1:
|
|
1300
1310
|
data = (_a.sent()).data;
|
|
1301
1311
|
if (!(data.delegate && fetchExtraInfo)) return [3 /*break*/, 3];
|
|
1302
|
-
return [4 /*yield*/, this.
|
|
1312
|
+
return [4 /*yield*/, this._options.network.extras.indexerClient.getDelegationInfo(delegatedAddress)];
|
|
1303
1313
|
case 2:
|
|
1304
1314
|
recentTransactionData = _a.sent();
|
|
1305
1315
|
if (recentTransactionData) {
|
|
@@ -1330,13 +1340,13 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1330
1340
|
}
|
|
1331
1341
|
return [4 /*yield*/, Promise.all([
|
|
1332
1342
|
index_1.default
|
|
1333
|
-
.get(this.
|
|
1343
|
+
.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/delegates/" + tzAddress + "/balance")
|
|
1334
1344
|
.catch(function (_error) { return undefined; }),
|
|
1335
1345
|
index_1.default
|
|
1336
|
-
.get(this.
|
|
1346
|
+
.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/delegates/" + tzAddress + "/full_balance")
|
|
1337
1347
|
.catch(function (_error) { return undefined; }),
|
|
1338
|
-
index_1.default.get(this.
|
|
1339
|
-
index_1.default.get(this.
|
|
1348
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/delegates/" + tzAddress + "/delegated_balance"),
|
|
1349
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/delegates/" + tzAddress + "/staking_balance")
|
|
1340
1350
|
]).catch(function (error) {
|
|
1341
1351
|
throw new index_4.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
1342
1352
|
})];
|
|
@@ -1382,12 +1392,12 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1382
1392
|
// TODO: use the adapt logic for ithaca upgrade
|
|
1383
1393
|
return [2 /*return*/, []
|
|
1384
1394
|
// const { data: frozenBalance }: AxiosResponse<TezosFrozenBalance[]> = await axios.get(
|
|
1385
|
-
// `${this.
|
|
1395
|
+
// `${this._options.network.rpcUrl}/chains/main/blocks/head/context/delegates/${bakerAddress}/frozen_balance_by_cycle`
|
|
1386
1396
|
// )
|
|
1387
1397
|
// const lastConfirmedCycle: number = frozenBalance[0].cycle - 1
|
|
1388
1398
|
// const mostRecentCycle: number = frozenBalance[frozenBalance.length - 1].cycle
|
|
1389
1399
|
// const { data: mostRecentBlock } = await axios.get(
|
|
1390
|
-
// `${this.
|
|
1400
|
+
// `${this._options.network.rpcUrl}/chains/main/blocks/${this.cycleToBlockLevel(mostRecentCycle)}`
|
|
1391
1401
|
// )
|
|
1392
1402
|
// const timestamp: Date = new Date(mostRecentBlock.header.timestamp)
|
|
1393
1403
|
// const address = delegatorAddress ?? bakerAddress
|
|
@@ -1434,13 +1444,13 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1434
1444
|
counter = new bignumber_1.default(1);
|
|
1435
1445
|
branch = '';
|
|
1436
1446
|
operations = [];
|
|
1437
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.
|
|
1447
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey).then(function (address) { return address.address; })];
|
|
1438
1448
|
case 1:
|
|
1439
1449
|
tzAddress = _d.sent();
|
|
1440
1450
|
return [4 /*yield*/, Promise.all([
|
|
1441
|
-
index_1.default.get(this.
|
|
1442
|
-
index_1.default.get(this.
|
|
1443
|
-
index_1.default.get(this.
|
|
1451
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + tzAddress + "/counter"),
|
|
1452
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head~2/hash"),
|
|
1453
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + tzAddress + "/manager_key")
|
|
1444
1454
|
]).catch(function (error) {
|
|
1445
1455
|
throw new index_4.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
1446
1456
|
})];
|
|
@@ -1524,7 +1534,8 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1524
1534
|
case TezosOperationType_1.TezosOperationType.PROPOSALS:
|
|
1525
1535
|
case TezosOperationType_1.TezosOperationType.BALLOT:
|
|
1526
1536
|
break;
|
|
1527
|
-
default:
|
|
1537
|
+
default:
|
|
1538
|
+
// Exhaustive switch
|
|
1528
1539
|
assert_1.assertNever(operation.kind);
|
|
1529
1540
|
throw new index_4.UnsupportedError(coinlib_error_1.Domain.TEZOS, "operation type not supported " + JSON.stringify(operation.kind));
|
|
1530
1541
|
}
|
|
@@ -1539,7 +1550,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1539
1550
|
case 0:
|
|
1540
1551
|
payload = rawTransaction;
|
|
1541
1552
|
return [4 /*yield*/, index_1.default
|
|
1542
|
-
.post(this.
|
|
1553
|
+
.post(this._options.network.rpcUrl + "/injection/operation?chain=main", JSON.stringify(payload), {
|
|
1543
1554
|
headers: { 'content-type': 'application/json' }
|
|
1544
1555
|
})
|
|
1545
1556
|
.catch(function (error) {
|
|
@@ -1612,7 +1623,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1612
1623
|
var response;
|
|
1613
1624
|
return __generator(this, function (_a) {
|
|
1614
1625
|
switch (_a.label) {
|
|
1615
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
1626
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/" + blockHash + "/votes/listings")];
|
|
1616
1627
|
case 1:
|
|
1617
1628
|
response = _a.sent();
|
|
1618
1629
|
return [2 /*return*/, response.data];
|
|
@@ -1637,9 +1648,9 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1637
1648
|
TezosProtocol.prototype.timeIntervalBetweenCycles = function (fromCycle, toCycle) {
|
|
1638
1649
|
var cycle1 = Math.min(fromCycle, toCycle);
|
|
1639
1650
|
var cycle2 = Math.max(fromCycle, toCycle);
|
|
1640
|
-
var timeBetweenBlocks = TezosProtocol.TIME_BETWEEN_BLOCKS[this.
|
|
1641
|
-
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this.
|
|
1642
|
-
if (this.
|
|
1651
|
+
var timeBetweenBlocks = TezosProtocol.TIME_BETWEEN_BLOCKS[this._options.network.extras.network];
|
|
1652
|
+
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this._options.network.extras.network];
|
|
1653
|
+
if (this._options.network.extras.network === TezosNetwork.MAINNET && cycle2 > TezosProtocol.FIRST_010_CYCLE) {
|
|
1643
1654
|
if (cycle1 < TezosProtocol.FIRST_010_CYCLE) {
|
|
1644
1655
|
return (((TezosProtocol.FIRST_010_CYCLE - cycle1) * blocksPerCycle[0] * timeBetweenBlocks[0] +
|
|
1645
1656
|
(cycle2 - TezosProtocol.FIRST_010_CYCLE) * blocksPerCycle[1] * timeBetweenBlocks[1]) *
|
|
@@ -1650,15 +1661,15 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1650
1661
|
return (cycle2 - cycle1) * blocksPerCycle[0] * timeBetweenBlocks[0] * 1000;
|
|
1651
1662
|
};
|
|
1652
1663
|
TezosProtocol.prototype.cycleToBlockLevel = function (cycle) {
|
|
1653
|
-
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this.
|
|
1654
|
-
if (this.
|
|
1664
|
+
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this._options.network.extras.network];
|
|
1665
|
+
if (this._options.network.extras.network === TezosNetwork.MAINNET && cycle > TezosProtocol.FIRST_010_CYCLE) {
|
|
1655
1666
|
return TezosProtocol.FIRST_010_CYCLE * blocksPerCycle[0] + (cycle - TezosProtocol.FIRST_010_CYCLE) * blocksPerCycle[1] + 1;
|
|
1656
1667
|
}
|
|
1657
1668
|
return cycle * blocksPerCycle[0] + 1;
|
|
1658
1669
|
};
|
|
1659
1670
|
TezosProtocol.prototype.blockLevelToCycle = function (blockLevel) {
|
|
1660
|
-
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this.
|
|
1661
|
-
if (this.
|
|
1671
|
+
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this._options.network.extras.network];
|
|
1672
|
+
if (this._options.network.extras.network === TezosNetwork.MAINNET) {
|
|
1662
1673
|
var last009BlockLevel = TezosProtocol.FIRST_010_CYCLE * blocksPerCycle[0];
|
|
1663
1674
|
if (blockLevel > last009BlockLevel) {
|
|
1664
1675
|
var deltaLevels = blockLevel - last009BlockLevel;
|
|
@@ -1680,7 +1691,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1680
1691
|
var result;
|
|
1681
1692
|
return __generator(this, function (_a) {
|
|
1682
1693
|
switch (_a.label) {
|
|
1683
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
1694
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/" + block + "/metadata")];
|
|
1684
1695
|
case 1:
|
|
1685
1696
|
result = _a.sent();
|
|
1686
1697
|
return [2 /*return*/, result.data];
|