@airgap/coinlib-core 0.13.7-beta.1 → 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/airgap-coinlib-core.min.js +2256 -1609
- package/index.d.ts +1 -2
- package/index.js +1 -4
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/protocols/ICoinBaseProtocol.d.ts +16 -16
- package/protocols/ICoinSubProtocol.d.ts +3 -3
- package/protocols/aeternity/AeternityProtocol.d.ts +31 -20
- package/protocols/aeternity/AeternityProtocol.js +55 -37
- package/protocols/aeternity/AeternityProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinProtocol.d.ts +31 -17
- package/protocols/bitcoin/BitcoinProtocol.js +64 -50
- package/protocols/bitcoin/BitcoinProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinSegwitProtocol.d.ts +4 -4
- package/protocols/bitcoin/BitcoinSegwitProtocol.js +15 -15
- 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/cosmos/CosmosProtocol.d.ts +31 -16
- package/protocols/cosmos/CosmosProtocol.js +46 -31
- 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/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 +31 -17
- package/protocols/ethereum/BaseEthereumProtocol.js +75 -54
- package/protocols/ethereum/BaseEthereumProtocol.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/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 +9 -5
- package/protocols/ethereum/erc20/GenericERC20.js +22 -18
- 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/SubstrateDelegateProtocol.js +32 -32
- package/protocols/substrate/SubstrateDelegateProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateProtocol.d.ts +31 -16
- package/protocols/substrate/SubstrateProtocol.js +40 -34
- package/protocols/substrate/SubstrateProtocol.js.map +1 -1
- 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/data/transaction/SubstrateTransactionPayload.d.ts +1 -1
- 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 +57 -44
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js.map +1 -1
- 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/TezosProtocol.d.ts +31 -17
- package/protocols/tezos/TezosProtocol.js +81 -72
- 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 +2 -2
- package/protocols/tezos/fa/TezosFA1Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFA2Protocol.d.ts +3 -2
- package/protocols/tezos/fa/TezosFA2Protocol.js +8 -7
- package/protocols/tezos/fa/TezosFA2Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFAProtocol.d.ts +9 -5
- package/protocols/tezos/fa/TezosFAProtocol.js +47 -34
- 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 +6 -4
- package/protocols/tezos/kt/TezosKtProtocol.js +7 -5
- package/protocols/tezos/kt/TezosKtProtocol.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingProtocol.d.ts +31 -16
- package/protocols/tezos/sapling/TezosSaplingProtocol.js +55 -40
- package/protocols/tezos/sapling/TezosSaplingProtocol.js.map +1 -1
- 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/protocolsByIdentifier.d.ts +1 -1
- package/utils/protocolsByIdentifier.js +114 -15
- 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 +22 -11
- package/wallet/AirGapWallet.js.map +1 -1
- package/utils/subProtocols.d.ts +0 -8
- package/utils/subProtocols.js +0 -53
- package/utils/subProtocols.js.map +0 -1
|
@@ -19,24 +19,31 @@ var SubstrateDelegateProtocol_1 = require("../SubstrateDelegateProtocol");
|
|
|
19
19
|
var PolkadotProtocolOptions_1 = require("./PolkadotProtocolOptions");
|
|
20
20
|
var PolkadotProtocol = /** @class */ (function (_super) {
|
|
21
21
|
__extends(PolkadotProtocol, _super);
|
|
22
|
-
function PolkadotProtocol(
|
|
23
|
-
if (
|
|
24
|
-
var _this = _super.call(this,
|
|
25
|
-
_this.
|
|
26
|
-
_this.
|
|
27
|
-
_this.
|
|
28
|
-
_this.
|
|
29
|
-
_this.
|
|
30
|
-
_this.
|
|
31
|
-
_this.
|
|
32
|
-
_this.
|
|
33
|
-
_this.
|
|
34
|
-
_this.
|
|
22
|
+
function PolkadotProtocol(_options) {
|
|
23
|
+
if (_options === void 0) { _options = new PolkadotProtocolOptions_1.PolkadotProtocolOptions(); }
|
|
24
|
+
var _this = _super.call(this, _options) || this;
|
|
25
|
+
_this._options = _options;
|
|
26
|
+
_this._symbol = 'DOT';
|
|
27
|
+
_this.symbol = Promise.resolve(_this._symbol);
|
|
28
|
+
_this._name = 'Polkadot';
|
|
29
|
+
_this.name = Promise.resolve(_this._name);
|
|
30
|
+
_this._marketSymbol = 'DOT';
|
|
31
|
+
_this.marketSymbol = Promise.resolve(_this._marketSymbol);
|
|
32
|
+
_this._feeSymbol = 'DOT';
|
|
33
|
+
_this.feeSymbol = Promise.resolve(_this._feeSymbol);
|
|
34
|
+
_this._decimals = 10;
|
|
35
|
+
_this.decimals = Promise.resolve(_this._decimals);
|
|
36
|
+
_this._feeDecimals = 10;
|
|
37
|
+
_this.feeDecimals = Promise.resolve(_this._feeDecimals);
|
|
38
|
+
_this._identifier = ProtocolSymbols_1.MainProtocolSymbols.POLKADOT;
|
|
39
|
+
_this.identifier = Promise.resolve(_this._identifier);
|
|
40
|
+
_this._feeDefaults = {
|
|
35
41
|
low: '0.01',
|
|
36
42
|
medium: '0.01',
|
|
37
43
|
high: '0.01'
|
|
38
44
|
};
|
|
39
|
-
_this.
|
|
45
|
+
_this.feeDefaults = Promise.resolve(_this._feeDefaults);
|
|
46
|
+
_this._units = [
|
|
40
47
|
{
|
|
41
48
|
unitSymbol: 'DOT',
|
|
42
49
|
factor: '1'
|
|
@@ -58,9 +65,15 @@ var PolkadotProtocol = /** @class */ (function (_super) {
|
|
|
58
65
|
factor: '0.0000000001'
|
|
59
66
|
}
|
|
60
67
|
];
|
|
61
|
-
_this.
|
|
62
|
-
_this.
|
|
63
|
-
_this.
|
|
68
|
+
_this.units = Promise.resolve(_this._units);
|
|
69
|
+
_this._standardDerivationPath = "m/44'/354'/0'/0/0";
|
|
70
|
+
_this.standardDerivationPath = Promise.resolve(_this._standardDerivationPath);
|
|
71
|
+
_this._addressIsCaseSensitive = true;
|
|
72
|
+
_this.addressIsCaseSensitive = Promise.resolve(_this._addressIsCaseSensitive);
|
|
73
|
+
_this._addressValidationPattern = '^1[a-km-zA-HJ-NP-Z1-9]+$';
|
|
74
|
+
_this.addressValidationPattern = Promise.resolve(_this._addressValidationPattern);
|
|
75
|
+
_this._addressPlaceholder = "1ABC...";
|
|
76
|
+
_this.addressPlaceholder = Promise.resolve(_this._addressPlaceholder);
|
|
64
77
|
_this.defaultValidator = '12C9U6zSSoZ6pgwR2ksFyBLgQH6v7dkqqPCRyHceoP8MJRo2';
|
|
65
78
|
return _this;
|
|
66
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolkadotProtocol.js","sourceRoot":"","sources":["../../../../src/protocols/substrate/polkadot/PolkadotProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAqF;AAErF,0EAAwE;AAIxE,qEAAmE;AAEnE;IAAsC,oCAAoD;
|
|
1
|
+
{"version":3,"file":"PolkadotProtocol.js","sourceRoot":"","sources":["../../../../src/protocols/substrate/polkadot/PolkadotProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAqF;AAErF,0EAAwE;AAIxE,qEAAmE;AAEnE;IAAsC,oCAAoD;IAmExF,0BAAsC,QAA6F;QAA7F,yBAAA,EAAA,eAAoE,iDAAuB,EAAE;QAAnI,YACE,kBAAM,QAAQ,CAAC,SAChB;QAFqC,cAAQ,GAAR,QAAQ,CAAqF;QAlEzH,aAAO,GAAW,KAAK,CAAA;QAC1B,YAAM,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,OAAO,CAAC,CAAA;QAEpD,WAAK,GAAW,UAAU,CAAA;QAC7B,UAAI,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,KAAK,CAAC,CAAA;QAEhD,mBAAa,GAAW,KAAK,CAAA;QAChC,kBAAY,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,aAAa,CAAC,CAAA;QAEhE,gBAAU,GAAW,KAAK,CAAA;QAC7B,eAAS,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,UAAU,CAAC,CAAA;QAE1D,eAAS,GAAW,EAAE,CAAA;QACzB,cAAQ,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,SAAS,CAAC,CAAA;QAExD,kBAAY,GAAW,EAAE,CAAA;QAC5B,iBAAW,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,YAAY,CAAC,CAAA;QAE9D,iBAAW,GAAoB,qCAAmB,CAAC,QAAQ,CAAA;QAC9D,gBAAU,GAA6B,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,WAAW,CAAC,CAAA;QAErE,kBAAY,GAAgB;YACpC,GAAG,EAAE,MAAM;YACX,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CAAA;QACM,iBAAW,GAAyB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,YAAY,CAAC,CAAA;QAEnE,YAAM,GAAmB;YACjC;gBACE,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,GAAG;aACZ;YACD;gBACE,UAAU,EAAE,MAAM;gBAClB,MAAM,EAAE,OAAO;aAChB;YACD;gBACE,UAAU,EAAE,MAAM;gBAClB,MAAM,EAAE,UAAU;aACnB;YACD;gBACE,UAAU,EAAE,OAAO;gBACnB,MAAM,EAAE,aAAa;aACtB;YACD;gBACE,UAAU,EAAE,QAAQ;gBACpB,MAAM,EAAE,cAAc;aACvB;SACF,CAAA;QACM,WAAK,GAA4B,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,MAAM,CAAC,CAAA;QAE1D,6BAAuB,GAAW,mBAAmB,CAAA;QACxD,4BAAsB,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,uBAAuB,CAAC,CAAA;QAEpF,6BAAuB,GAAY,IAAI,CAAA;QAC1C,4BAAsB,GAAqB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,uBAAuB,CAAC,CAAA;QAErF,+BAAyB,GAAW,0BAA0B,CAAA;QACjE,8BAAwB,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,yBAAyB,CAAC,CAAA;QAExF,yBAAmB,GAAW,SAAS,CAAA;QAC1C,wBAAkB,GAAoB,OAAO,CAAC,OAAO,CAAC,KAAI,CAAC,mBAAmB,CAAC,CAAA;QAE5E,sBAAgB,GAAW,kDAAkD,CAAA;;IAIvF,CAAC;IACH,uBAAC;AAAD,CAAC,AAtED,CAAsC,qDAAyB,GAsE9D;AAtEY,4CAAgB"}
|
|
@@ -103,22 +103,36 @@ export declare enum TezosNetwork {
|
|
|
103
103
|
GHOSTNET = "ghostnet"
|
|
104
104
|
}
|
|
105
105
|
export declare class TezosProtocol extends NonExtendedProtocol implements ICoinDelegateProtocol {
|
|
106
|
-
readonly
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
106
|
+
protected readonly _options: TezosProtocolOptions;
|
|
107
|
+
_symbol: string;
|
|
108
|
+
symbol: Promise<string>;
|
|
109
|
+
_name: string;
|
|
110
|
+
name: Promise<string>;
|
|
111
|
+
_marketSymbol: string;
|
|
112
|
+
marketSymbol: Promise<string>;
|
|
113
|
+
_feeSymbol: string;
|
|
114
|
+
feeSymbol: Promise<string>;
|
|
115
|
+
_decimals: number;
|
|
116
|
+
decimals: Promise<number>;
|
|
117
|
+
_feeDecimals: number;
|
|
118
|
+
feeDecimals: Promise<number>;
|
|
119
|
+
_identifier: ProtocolSymbols;
|
|
120
|
+
identifier: Promise<ProtocolSymbols>;
|
|
121
|
+
_feeDefaults: FeeDefaults;
|
|
122
|
+
feeDefaults: Promise<FeeDefaults>;
|
|
123
|
+
_units: CurrencyUnit[];
|
|
124
|
+
units: Promise<CurrencyUnit[]>;
|
|
125
|
+
_supportsHD: boolean;
|
|
126
|
+
supportsHD: Promise<boolean>;
|
|
127
|
+
_standardDerivationPath: string;
|
|
128
|
+
standardDerivationPath: Promise<string>;
|
|
129
|
+
_addressIsCaseSensitive: boolean;
|
|
130
|
+
addressIsCaseSensitive: Promise<boolean>;
|
|
131
|
+
_addressValidationPattern: string;
|
|
132
|
+
addressValidationPattern: Promise<string>;
|
|
133
|
+
_addressPlaceholder: string;
|
|
134
|
+
addressPlaceholder: Promise<string>;
|
|
135
|
+
readonly options: Promise<TezosProtocolOptions>;
|
|
122
136
|
minCycleDuration: number;
|
|
123
137
|
protected readonly transactionFee: BigNumber;
|
|
124
138
|
protected readonly originationSize: BigNumber;
|
|
@@ -128,7 +142,7 @@ export declare class TezosProtocol extends NonExtendedProtocol implements ICoinD
|
|
|
128
142
|
protected readonly originationBurn: BigNumber;
|
|
129
143
|
readonly cryptoClient: TezosCryptoClient;
|
|
130
144
|
get jsonRPCAPI(): string;
|
|
131
|
-
constructor(
|
|
145
|
+
constructor(_options?: TezosProtocolOptions);
|
|
132
146
|
getBlockExplorerLinkForAddress(address: string): Promise<string>;
|
|
133
147
|
getBlockExplorerLinkForTxId(txId: string): Promise<string>;
|
|
134
148
|
getPublicKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
@@ -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
|
};
|
|
@@ -294,11 +301,11 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
294
301
|
switch (_b.label) {
|
|
295
302
|
case 0:
|
|
296
303
|
address = addresses[0];
|
|
297
|
-
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)];
|
|
298
305
|
case 1:
|
|
299
306
|
results = _b.sent();
|
|
300
307
|
return [2 /*return*/, {
|
|
301
|
-
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 })); }),
|
|
302
309
|
cursor: { offset: ((_a = cursor === null || cursor === void 0 ? void 0 : cursor.offset) !== null && _a !== void 0 ? _a : 0) + results.length }
|
|
303
310
|
}];
|
|
304
311
|
}
|
|
@@ -421,10 +428,11 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
421
428
|
return [3 /*break*/, 8];
|
|
422
429
|
case 6: throw new index_4.UnsupportedError(coinlib_error_1.Domain.TEZOS, 'operation not supported: ' + JSON.stringify(tezosOperation.kind));
|
|
423
430
|
case 7:
|
|
431
|
+
// Exhaustive switch
|
|
424
432
|
assertNever(tezosOperation.kind);
|
|
425
433
|
throw new index_4.NotFoundError(coinlib_error_1.Domain.TEZOS, 'no operation to unforge found');
|
|
426
434
|
case 8: return [2 /*return*/, partialTxs.map(function (partialTx) {
|
|
427
|
-
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);
|
|
428
436
|
})];
|
|
429
437
|
}
|
|
430
438
|
});
|
|
@@ -449,7 +457,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
449
457
|
_a.label = 2;
|
|
450
458
|
case 2:
|
|
451
459
|
_a.trys.push([2, 4, , 5]);
|
|
452
|
-
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")];
|
|
453
461
|
case 3:
|
|
454
462
|
data = (_a.sent()).data;
|
|
455
463
|
balance = balance.plus(new bignumber_1.default(data));
|
|
@@ -526,7 +534,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
526
534
|
return [4 /*yield*/, this.estimateFeeDefaultsFromPublicKey(publicKey, recipients, [balance.toFixed()])];
|
|
527
535
|
case 2:
|
|
528
536
|
estimatedFeeDefaults = _a.sent();
|
|
529
|
-
maxFee = new bignumber_1.default(estimatedFeeDefaults.medium).shiftedBy(this.
|
|
537
|
+
maxFee = new bignumber_1.default(estimatedFeeDefaults.medium).shiftedBy(this._decimals);
|
|
530
538
|
if (maxFee.gte(balance)) {
|
|
531
539
|
maxFee = new bignumber_1.default(0);
|
|
532
540
|
}
|
|
@@ -603,9 +611,9 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
603
611
|
mediumFee = lowFee.plus(lowFee.times(feeStepFactor).integerValue(bignumber_1.default.ROUND_FLOOR));
|
|
604
612
|
highFee = mediumFee.plus(mediumFee.times(feeStepFactor).integerValue(bignumber_1.default.ROUND_FLOOR));
|
|
605
613
|
return [2 /*return*/, {
|
|
606
|
-
low: lowFee.shiftedBy(-this.
|
|
607
|
-
medium: mediumFee.shiftedBy(-this.
|
|
608
|
-
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()
|
|
609
617
|
}];
|
|
610
618
|
}
|
|
611
619
|
});
|
|
@@ -661,9 +669,9 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
661
669
|
}
|
|
662
670
|
address = addresses[addressIndex];
|
|
663
671
|
return [4 /*yield*/, Promise.all([
|
|
664
|
-
index_1.default.get(this.
|
|
665
|
-
index_1.default.get(this.
|
|
666
|
-
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")
|
|
667
675
|
]).catch(function (error) {
|
|
668
676
|
throw new index_4.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
669
677
|
})];
|
|
@@ -817,7 +825,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
817
825
|
var activeBakers;
|
|
818
826
|
return __generator(this, function (_a) {
|
|
819
827
|
switch (_a.label) {
|
|
820
|
-
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")];
|
|
821
829
|
case 1:
|
|
822
830
|
activeBakers = (_a.sent()).data;
|
|
823
831
|
return [2 /*return*/, activeBakers[0] || ''];
|
|
@@ -843,7 +851,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
843
851
|
var data;
|
|
844
852
|
return __generator(this, function (_a) {
|
|
845
853
|
switch (_a.label) {
|
|
846
|
-
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)];
|
|
847
855
|
case 1:
|
|
848
856
|
data = (_a.sent()).data;
|
|
849
857
|
return [2 /*return*/, data.delegate ? [data.delegate] : []];
|
|
@@ -856,7 +864,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
856
864
|
var response, isBakingActive;
|
|
857
865
|
return __generator(this, function (_a) {
|
|
858
866
|
switch (_a.label) {
|
|
859
|
-
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")];
|
|
860
868
|
case 1:
|
|
861
869
|
response = _a.sent();
|
|
862
870
|
isBakingActive = !response.data;
|
|
@@ -886,7 +894,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
886
894
|
var data;
|
|
887
895
|
return __generator(this, function (_a) {
|
|
888
896
|
switch (_a.label) {
|
|
889
|
-
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)];
|
|
890
898
|
case 1:
|
|
891
899
|
data = (_a.sent()).data;
|
|
892
900
|
return [2 /*return*/, !!data.delegate];
|
|
@@ -956,7 +964,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
956
964
|
return __generator(this, function (_a) {
|
|
957
965
|
switch (_a.label) {
|
|
958
966
|
case 0: return [4 /*yield*/, Promise.all([
|
|
959
|
-
index_1.default.get(this.
|
|
967
|
+
index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + address)
|
|
960
968
|
// this.getDelegationRewardsForAddress(address).catch(() => [] as DelegationRewardInfo[])
|
|
961
969
|
])];
|
|
962
970
|
case 1:
|
|
@@ -1041,9 +1049,9 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1041
1049
|
case 1:
|
|
1042
1050
|
address = _f.sent();
|
|
1043
1051
|
return [4 /*yield*/, Promise.all([
|
|
1044
|
-
index_1.default.get(this.
|
|
1045
|
-
index_1.default.get(this.
|
|
1046
|
-
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")
|
|
1047
1055
|
]).catch(function (error) {
|
|
1048
1056
|
throw new index_4.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
1049
1057
|
})];
|
|
@@ -1191,7 +1199,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1191
1199
|
var counter = startingCounter ? startingCounter.plus(i).toString() : op.counter;
|
|
1192
1200
|
return __assign(__assign({}, operation), { gas_limit: gas_limit, counter: counter });
|
|
1193
1201
|
});
|
|
1194
|
-
return [4 /*yield*/, index_1.default.get(this.
|
|
1202
|
+
return [4 /*yield*/, index_1.default.get(this._options.network.rpcUrl + "/chains/main/blocks/head")];
|
|
1195
1203
|
case 1:
|
|
1196
1204
|
block = (_a.sent()).data;
|
|
1197
1205
|
body = {
|
|
@@ -1207,7 +1215,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1207
1215
|
forgedOperation = _a.sent();
|
|
1208
1216
|
gasLimitTotal = 0;
|
|
1209
1217
|
return [4 /*yield*/, index_1.default
|
|
1210
|
-
.post(this.
|
|
1218
|
+
.post(this._options.network.rpcUrl + "/chains/main/blocks/head/helpers/scripts/run_operation", body, {
|
|
1211
1219
|
headers: { 'Content-Type': 'application/json' }
|
|
1212
1220
|
})
|
|
1213
1221
|
.catch(function (runOperationError) {
|
|
@@ -1297,11 +1305,11 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1297
1305
|
var data, delegatedOpLevel, delegatedDate, recentTransactionData;
|
|
1298
1306
|
return __generator(this, function (_a) {
|
|
1299
1307
|
switch (_a.label) {
|
|
1300
|
-
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)];
|
|
1301
1309
|
case 1:
|
|
1302
1310
|
data = (_a.sent()).data;
|
|
1303
1311
|
if (!(data.delegate && fetchExtraInfo)) return [3 /*break*/, 3];
|
|
1304
|
-
return [4 /*yield*/, this.
|
|
1312
|
+
return [4 /*yield*/, this._options.network.extras.indexerClient.getDelegationInfo(delegatedAddress)];
|
|
1305
1313
|
case 2:
|
|
1306
1314
|
recentTransactionData = _a.sent();
|
|
1307
1315
|
if (recentTransactionData) {
|
|
@@ -1332,13 +1340,13 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1332
1340
|
}
|
|
1333
1341
|
return [4 /*yield*/, Promise.all([
|
|
1334
1342
|
index_1.default
|
|
1335
|
-
.get(this.
|
|
1343
|
+
.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/delegates/" + tzAddress + "/balance")
|
|
1336
1344
|
.catch(function (_error) { return undefined; }),
|
|
1337
1345
|
index_1.default
|
|
1338
|
-
.get(this.
|
|
1346
|
+
.get(this._options.network.rpcUrl + "/chains/main/blocks/head/context/delegates/" + tzAddress + "/full_balance")
|
|
1339
1347
|
.catch(function (_error) { return undefined; }),
|
|
1340
|
-
index_1.default.get(this.
|
|
1341
|
-
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")
|
|
1342
1350
|
]).catch(function (error) {
|
|
1343
1351
|
throw new index_4.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
1344
1352
|
})];
|
|
@@ -1384,12 +1392,12 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1384
1392
|
// TODO: use the adapt logic for ithaca upgrade
|
|
1385
1393
|
return [2 /*return*/, []
|
|
1386
1394
|
// const { data: frozenBalance }: AxiosResponse<TezosFrozenBalance[]> = await axios.get(
|
|
1387
|
-
// `${this.
|
|
1395
|
+
// `${this._options.network.rpcUrl}/chains/main/blocks/head/context/delegates/${bakerAddress}/frozen_balance_by_cycle`
|
|
1388
1396
|
// )
|
|
1389
1397
|
// const lastConfirmedCycle: number = frozenBalance[0].cycle - 1
|
|
1390
1398
|
// const mostRecentCycle: number = frozenBalance[frozenBalance.length - 1].cycle
|
|
1391
1399
|
// const { data: mostRecentBlock } = await axios.get(
|
|
1392
|
-
// `${this.
|
|
1400
|
+
// `${this._options.network.rpcUrl}/chains/main/blocks/${this.cycleToBlockLevel(mostRecentCycle)}`
|
|
1393
1401
|
// )
|
|
1394
1402
|
// const timestamp: Date = new Date(mostRecentBlock.header.timestamp)
|
|
1395
1403
|
// const address = delegatorAddress ?? bakerAddress
|
|
@@ -1440,9 +1448,9 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1440
1448
|
case 1:
|
|
1441
1449
|
tzAddress = _d.sent();
|
|
1442
1450
|
return [4 /*yield*/, Promise.all([
|
|
1443
|
-
index_1.default.get(this.
|
|
1444
|
-
index_1.default.get(this.
|
|
1445
|
-
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")
|
|
1446
1454
|
]).catch(function (error) {
|
|
1447
1455
|
throw new index_4.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
1448
1456
|
})];
|
|
@@ -1526,7 +1534,8 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1526
1534
|
case TezosOperationType_1.TezosOperationType.PROPOSALS:
|
|
1527
1535
|
case TezosOperationType_1.TezosOperationType.BALLOT:
|
|
1528
1536
|
break;
|
|
1529
|
-
default:
|
|
1537
|
+
default:
|
|
1538
|
+
// Exhaustive switch
|
|
1530
1539
|
assert_1.assertNever(operation.kind);
|
|
1531
1540
|
throw new index_4.UnsupportedError(coinlib_error_1.Domain.TEZOS, "operation type not supported " + JSON.stringify(operation.kind));
|
|
1532
1541
|
}
|
|
@@ -1541,7 +1550,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1541
1550
|
case 0:
|
|
1542
1551
|
payload = rawTransaction;
|
|
1543
1552
|
return [4 /*yield*/, index_1.default
|
|
1544
|
-
.post(this.
|
|
1553
|
+
.post(this._options.network.rpcUrl + "/injection/operation?chain=main", JSON.stringify(payload), {
|
|
1545
1554
|
headers: { 'content-type': 'application/json' }
|
|
1546
1555
|
})
|
|
1547
1556
|
.catch(function (error) {
|
|
@@ -1614,7 +1623,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1614
1623
|
var response;
|
|
1615
1624
|
return __generator(this, function (_a) {
|
|
1616
1625
|
switch (_a.label) {
|
|
1617
|
-
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")];
|
|
1618
1627
|
case 1:
|
|
1619
1628
|
response = _a.sent();
|
|
1620
1629
|
return [2 /*return*/, response.data];
|
|
@@ -1639,9 +1648,9 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1639
1648
|
TezosProtocol.prototype.timeIntervalBetweenCycles = function (fromCycle, toCycle) {
|
|
1640
1649
|
var cycle1 = Math.min(fromCycle, toCycle);
|
|
1641
1650
|
var cycle2 = Math.max(fromCycle, toCycle);
|
|
1642
|
-
var timeBetweenBlocks = TezosProtocol.TIME_BETWEEN_BLOCKS[this.
|
|
1643
|
-
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this.
|
|
1644
|
-
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) {
|
|
1645
1654
|
if (cycle1 < TezosProtocol.FIRST_010_CYCLE) {
|
|
1646
1655
|
return (((TezosProtocol.FIRST_010_CYCLE - cycle1) * blocksPerCycle[0] * timeBetweenBlocks[0] +
|
|
1647
1656
|
(cycle2 - TezosProtocol.FIRST_010_CYCLE) * blocksPerCycle[1] * timeBetweenBlocks[1]) *
|
|
@@ -1652,15 +1661,15 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1652
1661
|
return (cycle2 - cycle1) * blocksPerCycle[0] * timeBetweenBlocks[0] * 1000;
|
|
1653
1662
|
};
|
|
1654
1663
|
TezosProtocol.prototype.cycleToBlockLevel = function (cycle) {
|
|
1655
|
-
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this.
|
|
1656
|
-
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) {
|
|
1657
1666
|
return TezosProtocol.FIRST_010_CYCLE * blocksPerCycle[0] + (cycle - TezosProtocol.FIRST_010_CYCLE) * blocksPerCycle[1] + 1;
|
|
1658
1667
|
}
|
|
1659
1668
|
return cycle * blocksPerCycle[0] + 1;
|
|
1660
1669
|
};
|
|
1661
1670
|
TezosProtocol.prototype.blockLevelToCycle = function (blockLevel) {
|
|
1662
|
-
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this.
|
|
1663
|
-
if (this.
|
|
1671
|
+
var blocksPerCycle = TezosProtocol.BLOCKS_PER_CYCLE[this._options.network.extras.network];
|
|
1672
|
+
if (this._options.network.extras.network === TezosNetwork.MAINNET) {
|
|
1664
1673
|
var last009BlockLevel = TezosProtocol.FIRST_010_CYCLE * blocksPerCycle[0];
|
|
1665
1674
|
if (blockLevel > last009BlockLevel) {
|
|
1666
1675
|
var deltaLevels = blockLevel - last009BlockLevel;
|
|
@@ -1682,7 +1691,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1682
1691
|
var result;
|
|
1683
1692
|
return __generator(this, function (_a) {
|
|
1684
1693
|
switch (_a.label) {
|
|
1685
|
-
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")];
|
|
1686
1695
|
case 1:
|
|
1687
1696
|
result = _a.sent();
|
|
1688
1697
|
return [2 /*return*/, result.data];
|