@airgap/tezos 0.13.16-beta.1 → 0.13.16-beta.11
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +5 -5
- package/v0/protocol/TezosProtocol.d.ts +1 -0
- package/v0/protocol/TezosProtocol.js +12 -2
- package/v0/protocol/TezosProtocol.js.map +1 -1
- package/v0/protocol/fa/TezosFAProtocol.js +1 -1
- package/v0/protocol/fa/TezosFAProtocol.js.map +1 -1
- package/v0/protocol/sapling/TezosSaplingProtocol.d.ts +1 -0
- package/v0/protocol/sapling/TezosSaplingProtocol.js +7 -0
- package/v0/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
- package/v0/protocol/sapling/node/TezosSaplingNodeClient.js +1 -1
- package/v0/protocol/sapling/node/TezosSaplingNodeClient.js.map +1 -1
- package/v0/protocol/types/operations/Origination.d.ts +1 -1
- package/v1/block-explorer/factory.d.ts +2 -2
- package/v1/block-explorer/factory.js +4 -4
- package/v1/block-explorer/factory.js.map +1 -1
- package/v1/contract/TezosContract.js +1 -1
- package/v1/contract/TezosContract.js.map +1 -1
- package/v1/domains/TezosDomains.d.ts +20 -0
- package/v1/domains/TezosDomains.js +309 -0
- package/v1/domains/TezosDomains.js.map +1 -0
- package/v1/index.d.ts +23 -4
- package/v1/index.js +23 -1
- package/v1/index.js.map +1 -1
- package/v1/indexer/factory.d.ts +2 -2
- package/v1/indexer/factory.js +4 -4
- package/v1/indexer/factory.js.map +1 -1
- package/v1/module/TezosModule.d.ts +6 -3
- package/v1/module/TezosModule.js +10 -6
- package/v1/module/TezosModule.js.map +1 -1
- package/v1/node/TezosSaplingNodeClient.js +1 -1
- package/v1/node/TezosSaplingNodeClient.js.map +1 -1
- package/v1/protocol/TezosProtocol.d.ts +32 -7
- package/v1/protocol/TezosProtocol.js +351 -20
- package/v1/protocol/TezosProtocol.js.map +1 -1
- package/v1/protocol/fa/TezosFA1Protocol.d.ts +16 -3
- package/v1/protocol/fa/TezosFA1Protocol.js +19 -6
- package/v1/protocol/fa/TezosFA1Protocol.js.map +1 -1
- package/v1/protocol/fa/TezosFA1p2Protocol.d.ts +15 -2
- package/v1/protocol/fa/TezosFA1p2Protocol.js +11 -5
- package/v1/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
- package/v1/protocol/fa/TezosFA2Protocol.d.ts +21 -6
- package/v1/protocol/fa/TezosFA2Protocol.js +34 -6
- package/v1/protocol/fa/TezosFA2Protocol.js.map +1 -1
- package/v1/protocol/fa/TezosFAProtocol.d.ts +10 -7
- package/v1/protocol/fa/TezosFAProtocol.js +22 -8
- package/v1/protocol/fa/TezosFAProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/BTCTezProtocol.js +1 -1
- package/v1/protocol/fa/tokens/BTCTezProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/CTezProtocol.js +1 -1
- package/v1/protocol/fa/tokens/CTezProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/DogamiProtocol.js +1 -1
- package/v1/protocol/fa/tokens/DogamiProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/ETHTezProtocol.js +1 -1
- package/v1/protocol/fa/tokens/ETHTezProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/KolibriUSDProtocol.js +1 -1
- package/v1/protocol/fa/tokens/KolibriUSDProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/PlentyProtocol.js +1 -1
- package/v1/protocol/fa/tokens/PlentyProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/QuipuswapProtocol.js +1 -1
- package/v1/protocol/fa/tokens/QuipuswapProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/SiriusProtocol.js +2 -2
- package/v1/protocol/fa/tokens/SiriusProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/StakerProtocol.js +1 -1
- package/v1/protocol/fa/tokens/StakerProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/TetherUSDProtocol.js +1 -1
- package/v1/protocol/fa/tokens/TetherUSDProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/TzBTCProtocol.js +1 -1
- package/v1/protocol/fa/tokens/TzBTCProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/UBTCProtocol.js +1 -1
- package/v1/protocol/fa/tokens/UBTCProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/UDEFIProtocol.js +1 -1
- package/v1/protocol/fa/tokens/UDEFIProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/USDTezProtocol.js +1 -1
- package/v1/protocol/fa/tokens/USDTezProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/UUSDProtocol.js +1 -1
- package/v1/protocol/fa/tokens/UUSDProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/WrapProtocol.js +1 -1
- package/v1/protocol/fa/tokens/WrapProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/WrappedTezosProtocol.js +1 -1
- package/v1/protocol/fa/tokens/WrappedTezosProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/YouProtocol.js +1 -1
- package/v1/protocol/fa/tokens/YouProtocol.js.map +1 -1
- package/v1/protocol/kt/TezosKtProtocol.js +27 -14
- package/v1/protocol/kt/TezosKtProtocol.js.map +1 -1
- package/v1/protocol/sapling/TezosSaplingProtocol.d.ts +16 -13
- package/v1/protocol/sapling/TezosSaplingProtocol.js +14 -3
- package/v1/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
- package/v1/protocol/sapling/TezosShieldedTezProtocol.js +2 -2
- package/v1/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +42 -146
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/types/block-explorer.d.ts +1 -6
- package/v1/types/domains/TezosDomainsRecord.d.ts +8 -0
- package/v1/types/domains/TezosDomainsRecord.js +3 -0
- package/v1/types/domains/TezosDomainsRecord.js.map +1 -0
- package/v1/types/domains/TezosDomainsReverseRecord.d.ts +5 -0
- package/v1/types/domains/TezosDomainsReverseRecord.js +3 -0
- package/v1/types/domains/TezosDomainsReverseRecord.js.map +1 -0
- package/v1/types/indexer.d.ts +1 -6
- package/v1/types/operations/kinds/Origination.d.ts +1 -1
- package/v1/types/protocol.d.ts +11 -5
- package/v1/types/staking/BakerDetails.d.ts +10 -0
- package/v1/types/staking/BakerDetails.js +3 -0
- package/v1/types/staking/BakerDetails.js.map +1 -0
- package/v1/types/staking/TezosDelegatorAction.d.ts +5 -0
- package/v1/types/staking/TezosDelegatorAction.js +10 -0
- package/v1/types/staking/TezosDelegatorAction.js.map +1 -0
- package/v1/utils/pack.js +3 -4
- package/v1/utils/pack.js.map +1 -1
- package/v1/utils/protocol/instance.d.ts +19 -0
- package/v1/utils/protocol/instance.js +49 -0
- package/v1/utils/protocol/instance.js.map +1 -0
- package/v1/utils/protocol/tezos/TezosAccountant.d.ts +2 -1
- package/v1/utils/protocol/tezos/TezosAccountant.js.map +1 -1
package/v1/module/TezosModule.js
CHANGED
|
@@ -52,6 +52,7 @@ var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
|
52
52
|
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
53
53
|
var module_kit_1 = require("@airgap/module-kit");
|
|
54
54
|
var factory_1 = require("../block-explorer/factory");
|
|
55
|
+
var module_1 = require("../module");
|
|
55
56
|
var BTCTezProtocol_1 = require("../protocol/fa/tokens/BTCTezProtocol");
|
|
56
57
|
var CTezProtocol_1 = require("../protocol/fa/tokens/CTezProtocol");
|
|
57
58
|
var DogamiProtocol_1 = require("../protocol/fa/tokens/DogamiProtocol");
|
|
@@ -114,12 +115,12 @@ var TezosModule = /** @class */ (function () {
|
|
|
114
115
|
});
|
|
115
116
|
});
|
|
116
117
|
};
|
|
117
|
-
TezosModule.prototype.createOnlineProtocol = function (identifier,
|
|
118
|
+
TezosModule.prototype.createOnlineProtocol = function (identifier, networkOrId) {
|
|
118
119
|
var _a;
|
|
119
120
|
return __awaiter(this, void 0, void 0, function () {
|
|
120
121
|
var network;
|
|
121
122
|
return __generator(this, function (_b) {
|
|
122
|
-
network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(
|
|
123
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
123
124
|
if (network === undefined) {
|
|
124
125
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, 'Protocol network type not supported.');
|
|
125
126
|
}
|
|
@@ -127,15 +128,16 @@ var TezosModule = /** @class */ (function () {
|
|
|
127
128
|
});
|
|
128
129
|
});
|
|
129
130
|
};
|
|
130
|
-
TezosModule.prototype.createBlockExplorer = function (identifier,
|
|
131
|
+
TezosModule.prototype.createBlockExplorer = function (identifier, networkOrId) {
|
|
132
|
+
var _a;
|
|
131
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
132
134
|
var network;
|
|
133
|
-
return __generator(this, function (
|
|
134
|
-
network = this.networkRegistries[identifier].findNetwork(
|
|
135
|
+
return __generator(this, function (_b) {
|
|
136
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
135
137
|
if (network === undefined) {
|
|
136
138
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, 'Block Explorer network type not supported.');
|
|
137
139
|
}
|
|
138
|
-
return [2 /*return*/, (0, factory_1.createTezosBlockExplorer)(network.
|
|
140
|
+
return [2 /*return*/, (0, factory_1.createTezosBlockExplorer)(network.blockExplorerType, network.blockExplorerUrl)];
|
|
139
141
|
});
|
|
140
142
|
});
|
|
141
143
|
};
|
|
@@ -162,6 +164,8 @@ var TezosModule = /** @class */ (function () {
|
|
|
162
164
|
return (0, USDTezProtocol_1.createUSDTezProtocol)({ network: network });
|
|
163
165
|
case coinlib_core_1.SubProtocolSymbols.XTZ_KUSD:
|
|
164
166
|
return (0, KolibriUSDProtocol_1.createKolibriUSDProtocol)({ network: network });
|
|
167
|
+
case coinlib_core_1.SubProtocolSymbols.XTZ_USDT:
|
|
168
|
+
return (0, module_1.createTetherUSDProtocol)({ network: network });
|
|
165
169
|
case coinlib_core_1.SubProtocolSymbols.XTZ_STKR:
|
|
166
170
|
return (0, StakerProtocol_1.createStakerProtocol)({ network: network });
|
|
167
171
|
case coinlib_core_1.SubProtocolSymbols.XTZ_ETHTZ:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TezosModule.js","sourceRoot":"","sources":["../../../src/v1/module/TezosModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuG;AACvG,sDAAqE;AACrE,iDAW2B;AAE3B,qDAAoE;AACpE,uEAA2E;AAC3E,mEAAuE;AACvE,uEAA2E;AAC3E,uEAA2E;AAC3E,+EAAmF;AACnF,uEAA2E;AAC3E,6EAAiF;AACjF,uEAA2E;AAC3E,uEAA2E;AAC3E,qEAAyE;AACzE,mEAAuE;AACvE,qEAAyE;AACzE,uEAA2E;AAC3E,mEAAuE;AACvE,mFAAuF;AACvF,mEAAuE;AACvE,iEAAqE;AACrE,kEAAsE;AACtE,yFAA6F;AAC7F,2DAAgI;AAChI,8EAAkF;AAGlF;IAIE;;QACE,IAAM,oBAAoB,GAAsB;YAC9C,iCAAkB,CAAC,OAAO;YAC1B,iCAAkB,CAAC,OAAO;YAC1B,iCAAkB,CAAC,QAAQ;YAC3B,iCAAkB,CAAC,QAAQ;YAC3B,iCAAkB,CAAC,SAAS;YAC5B,iCAAkB,CAAC,QAAQ;YAC3B,iCAAkB,CAAC,OAAO;YAC1B,iCAAkB,CAAC,KAAK;YACxB,iCAAkB,CAAC,SAAS;YAC5B,iCAAkB,CAAC,QAAQ;YAC3B,iCAAkB,CAAC,QAAQ;YAC3B,iCAAkB,CAAC,UAAU;YAC7B,iCAAkB,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AAA;SAC3F;IACH,CAAC;IACH,kBAAC;AAAD,CAAC,AApID,IAoIC;AApIY,kCAAW"}
|
|
@@ -64,7 +64,7 @@ var TezosSaplingNodeClient = /** @class */ (function () {
|
|
|
64
64
|
var response;
|
|
65
65
|
return __generator(this, function (_a) {
|
|
66
66
|
switch (_a.label) {
|
|
67
|
-
case 0: return [4 /*yield*/, axios_0_19_0_1.default.get("".concat(this.rpcUrl, "/chains/main/blocks/head/"))];
|
|
67
|
+
case 0: return [4 /*yield*/, axios_0_19_0_1.default.get("".concat(this.rpcUrl, "/chains/main/blocks/head/header"))];
|
|
68
68
|
case 1:
|
|
69
69
|
response = _a.sent();
|
|
70
70
|
return [2 /*return*/, response.data.chain_id];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TezosSaplingNodeClient.js","sourceRoot":"","sources":["../../../src/v1/node/TezosSaplingNodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oGAAyF;AAIzF;IACE,gCAA6B,MAAc,EAAmB,eAAuB;QAAxD,WAAM,GAAN,MAAM,CAAQ;QAAmB,oBAAe,GAAf,eAAe,CAAQ;IAAG,CAAC;IAE5E,oDAAmB,GAAhC;;;;;4BACyD,qBAAM,sBAAK,CAAC,GAAG,CACpE,UAAG,IAAI,CAAC,MAAM,wDAA8C,IAAI,CAAC,eAAe,6BAA0B,CAC3G,EAAA;;wBAFK,QAAQ,GAAyC,SAEtD;wBAED,sBAAO,QAAQ,CAAC,IAAI,EAAA;;;;KACrB;IAEY,2CAAU,GAAvB;;;;;4BACwD,qBAAM,sBAAK,CAAC,GAAG,CAAC,UAAG,IAAI,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"TezosSaplingNodeClient.js","sourceRoot":"","sources":["../../../src/v1/node/TezosSaplingNodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oGAAyF;AAIzF;IACE,gCAA6B,MAAc,EAAmB,eAAuB;QAAxD,WAAM,GAAN,MAAM,CAAQ;QAAmB,oBAAe,GAAf,eAAe,CAAQ;IAAG,CAAC;IAE5E,oDAAmB,GAAhC;;;;;4BACyD,qBAAM,sBAAK,CAAC,GAAG,CACpE,UAAG,IAAI,CAAC,MAAM,wDAA8C,IAAI,CAAC,eAAe,6BAA0B,CAC3G,EAAA;;wBAFK,QAAQ,GAAyC,SAEtD;wBAED,sBAAO,QAAQ,CAAC,IAAI,EAAA;;;;KACrB;IAEY,2CAAU,GAAvB;;;;;4BACwD,qBAAM,sBAAK,CAAC,GAAG,CAAC,UAAG,IAAI,CAAC,MAAM,oCAAiC,CAAC,EAAA;;wBAAhH,QAAQ,GAAwC,SAAgE;wBAEtH,sBAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAA;;;;KAC9B;IACH,6BAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,wDAAsB"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DelegateeDetails, DelegationDetails, DelegatorDetails } from '@airgap/coinlib-core';
|
|
2
|
+
import { Address, AirGapProtocol, AirGapTransaction, AirGapTransactionsWithCursor, Amount, Balance, CryptoDerivative, FeeDefaults, KeyPair, ProtocolAccountMetadata, ProtocolMetadata, ProtocolUnitsMetadata, PublicKey, RecursivePartial, SecretKey, Signature, TransactionFullConfiguration, TransactionDetails, TransactionSimpleConfiguration } from '@airgap/module-kit';
|
|
3
|
+
import { AirGapDelegateProtocol } from '@airgap/module-kit/internal';
|
|
2
4
|
import { TezosCryptoConfiguration } from '../types/crypto';
|
|
3
5
|
import { TezosOperation } from '../types/operations/kinds/TezosOperation';
|
|
4
6
|
import { TezosWrappedOperation } from '../types/operations/TezosWrappedOperation';
|
|
5
7
|
import { TezosProtocolNetwork, TezosProtocolOptions, TezosUnits } from '../types/protocol';
|
|
8
|
+
import { BakerDetails } from '../types/staking/BakerDetails';
|
|
6
9
|
import { TezosSignedTransaction, TezosTransactionCursor, TezosUnsignedTransaction } from '../types/transaction';
|
|
7
10
|
export interface TezosProtocol extends AirGapProtocol<{
|
|
8
11
|
AddressResult: Address;
|
|
@@ -13,19 +16,24 @@ export interface TezosProtocol extends AirGapProtocol<{
|
|
|
13
16
|
UnsignedTransaction: TezosUnsignedTransaction;
|
|
14
17
|
SignedTransaction: TezosSignedTransaction;
|
|
15
18
|
TransactionCursor: TezosTransactionCursor;
|
|
16
|
-
}, 'Crypto', 'FetchDataForAddress'
|
|
19
|
+
}, 'Crypto', 'FetchDataForAddress'>, AirGapDelegateProtocol {
|
|
20
|
+
isTezosProtocol: true;
|
|
21
|
+
getMinCycleDuration(): Promise<number>;
|
|
22
|
+
getDetailsFromWrappedOperation(wrappedOperation: TezosWrappedOperation): Promise<AirGapTransaction<TezosUnits, TezosUnits>[]>;
|
|
17
23
|
forgeOperation(wrappedOperation: TezosWrappedOperation): Promise<string>;
|
|
18
24
|
unforgeOperation(forged: string, type?: (TezosSignedTransaction | TezosUnsignedTransaction)['type']): Promise<TezosWrappedOperation>;
|
|
19
25
|
getOperationFeeDefaults(publicKey: PublicKey, operations: TezosOperation[]): Promise<FeeDefaults<TezosUnits>>;
|
|
20
26
|
prepareOperations(publicKey: PublicKey, operationRequests: TezosOperation[], overrideParameters?: boolean): Promise<TezosWrappedOperation>;
|
|
21
|
-
prepareTransactionsWithPublicKey(publicKey: PublicKey, details: TransactionDetails<TezosUnits>[], configuration?:
|
|
27
|
+
prepareTransactionsWithPublicKey(publicKey: PublicKey, details: TransactionDetails<TezosUnits>[], configuration?: TransactionFullConfiguration<TezosUnits> & {
|
|
22
28
|
operationsPerGroup?: number;
|
|
23
29
|
}): Promise<TezosUnsignedTransaction[]>;
|
|
30
|
+
bakerDetails(address: string | undefined): Promise<BakerDetails>;
|
|
24
31
|
}
|
|
25
32
|
export declare const TEZOS_UNITS: ProtocolUnitsMetadata<TezosUnits>;
|
|
26
33
|
export declare const TEZOS_DERIVATION_PATH: string;
|
|
27
34
|
export declare const TEZOS_ACCOUNT_METADATA: ProtocolAccountMetadata;
|
|
28
35
|
export declare class TezosProtocolImpl implements TezosProtocol {
|
|
36
|
+
readonly isTezosProtocol: true;
|
|
29
37
|
private readonly options;
|
|
30
38
|
private readonly forger;
|
|
31
39
|
private readonly accountant;
|
|
@@ -53,20 +61,37 @@ export declare class TezosProtocolImpl implements TezosProtocol {
|
|
|
53
61
|
getTransactionsForAddress(address: string, limit: number, cursor?: TezosTransactionCursor): Promise<AirGapTransactionsWithCursor<TezosTransactionCursor, TezosUnits, TezosUnits>>;
|
|
54
62
|
getBalanceOfPublicKey(publicKey: PublicKey): Promise<Balance<TezosUnits>>;
|
|
55
63
|
getBalanceOfAddress(address: string): Promise<Balance<TezosUnits>>;
|
|
56
|
-
getTransactionMaxAmountWithPublicKey(publicKey: PublicKey, to: string[], configuration?:
|
|
64
|
+
getTransactionMaxAmountWithPublicKey(publicKey: PublicKey, to: string[], configuration?: TransactionFullConfiguration<TezosUnits>): Promise<Amount<TezosUnits>>;
|
|
57
65
|
private getTansactionMaxAmountWithBalance;
|
|
58
|
-
getTransactionFeeWithPublicKey(publicKey: PublicKey, details: TransactionDetails<TezosUnits>[]): Promise<FeeDefaults<TezosUnits>>;
|
|
66
|
+
getTransactionFeeWithPublicKey(publicKey: PublicKey, details: TransactionDetails<TezosUnits>[], _configuration?: TransactionSimpleConfiguration): Promise<FeeDefaults<TezosUnits>>;
|
|
59
67
|
getOperationFeeDefaults(publicKey: PublicKey, operations: TezosOperation[]): Promise<FeeDefaults<TezosUnits>>;
|
|
60
|
-
prepareTransactionWithPublicKey(publicKey: PublicKey, details: TransactionDetails<TezosUnits>[], configuration?:
|
|
68
|
+
prepareTransactionWithPublicKey(publicKey: PublicKey, details: TransactionDetails<TezosUnits>[], configuration?: TransactionFullConfiguration<TezosUnits>): Promise<TezosUnsignedTransaction>;
|
|
61
69
|
broadcastTransaction(transaction: TezosSignedTransaction): Promise<string>;
|
|
70
|
+
getDefaultDelegatee(): Promise<string>;
|
|
71
|
+
getCurrentDelegateesForPublicKey(publicKey: PublicKey): Promise<string[]>;
|
|
72
|
+
getCurrentDelegateesForAddress(address: string): Promise<string[]>;
|
|
73
|
+
getDelegateeDetails(address: string): Promise<DelegateeDetails>;
|
|
74
|
+
isPublicKeyDelegating(publicKey: PublicKey): Promise<boolean>;
|
|
75
|
+
isAddressDelegating(address: string): Promise<boolean>;
|
|
76
|
+
getDelegatorDetailsFromPublicKey(publicKey: PublicKey): Promise<DelegatorDetails>;
|
|
77
|
+
getDelegatorDetailsFromAddress(address: string): Promise<DelegatorDetails>;
|
|
78
|
+
getDelegationDetailsFromPublicKey(publicKey: PublicKey, delegatees: string[]): Promise<DelegationDetails>;
|
|
79
|
+
getDelegationDetailsFromAddress(address: string, delegatees: string[]): Promise<DelegationDetails>;
|
|
80
|
+
private getDelegatorDetails;
|
|
81
|
+
prepareDelegatorActionFromPublicKey(publicKey: PublicKey, type: any, data?: any): Promise<any[]>;
|
|
82
|
+
undelegate(publicKey: PublicKey): Promise<TezosUnsignedTransaction>;
|
|
83
|
+
delegate(publicKey: PublicKey, delegate?: string | string[]): Promise<TezosUnsignedTransaction>;
|
|
84
|
+
getMinCycleDuration(): Promise<number>;
|
|
85
|
+
getDetailsFromWrappedOperation(wrappedOperation: TezosWrappedOperation): Promise<AirGapTransaction<TezosUnits, TezosUnits>[]>;
|
|
62
86
|
forgeOperation(wrappedOperation: TezosWrappedOperation): Promise<string>;
|
|
63
87
|
unforgeOperation(forged: string, type?: (TezosSignedTransaction | TezosUnsignedTransaction)['type']): Promise<TezosWrappedOperation>;
|
|
64
|
-
prepareTransactionsWithPublicKey(publicKey: PublicKey, details: TransactionDetails<TezosUnits>[], configuration?:
|
|
88
|
+
prepareTransactionsWithPublicKey(publicKey: PublicKey, details: TransactionDetails<TezosUnits>[], configuration?: TransactionFullConfiguration<TezosUnits> & {
|
|
65
89
|
operationsPerGroup?: number;
|
|
66
90
|
}): Promise<TezosUnsignedTransaction[]>;
|
|
67
91
|
prepareOperations(publicKey: PublicKey, operationRequests: TezosOperation[], overrideParameters?: boolean): Promise<TezosWrappedOperation>;
|
|
68
92
|
private estimateAndReplaceLimitsAndFee;
|
|
69
93
|
private createTransactionOperations;
|
|
94
|
+
bakerDetails(address: string | undefined): Promise<BakerDetails>;
|
|
70
95
|
}
|
|
71
96
|
export declare function createTezosProtocol(options?: RecursivePartial<TezosProtocolOptions>): TezosProtocol;
|
|
72
97
|
export declare const TEZOS_MAINNET_PROTOCOL_NETWORK: TezosProtocolNetwork;
|
|
@@ -61,6 +61,7 @@ var TezosAddress_1 = require("../data/TezosAddress");
|
|
|
61
61
|
var factory_1 = require("../indexer/factory");
|
|
62
62
|
var network_1 = require("../types/network");
|
|
63
63
|
var TezosOperationType_1 = require("../types/operations/TezosOperationType");
|
|
64
|
+
var TezosDelegatorAction_1 = require("../types/staking/TezosDelegatorAction");
|
|
64
65
|
var key_1 = require("../utils/key");
|
|
65
66
|
var operations_1 = require("../utils/operations");
|
|
66
67
|
var TezosAccountant_1 = require("../utils/protocol/tezos/TezosAccountant");
|
|
@@ -69,12 +70,14 @@ var signature_1 = require("../utils/signature");
|
|
|
69
70
|
// Implementation
|
|
70
71
|
var MAX_OPERATIONS_PER_GROUP = 200;
|
|
71
72
|
var MAX_GAS_PER_BLOCK = 5200000;
|
|
73
|
+
var MIN_CYCLE_DURATION = 4096 * 60 * 1000; // ms
|
|
72
74
|
var GAS_LIMIT_PLACEHOLDER = '1040000';
|
|
73
75
|
var STORAGE_LIMIT_PLACEHOLDER = '60000';
|
|
74
76
|
var FEE_PLACEHOLDER = '0';
|
|
75
77
|
var MINIMAL_FEE = 100;
|
|
76
78
|
var MINIMAL_FEE_PER_GAS_UNIT = 0.1;
|
|
77
79
|
var MINIMAL_FEE_PER_BYTE = 1;
|
|
80
|
+
var SELF_BOND_REQUIREMENT = 0.0825; // 8.25%
|
|
78
81
|
exports.TEZOS_UNITS = {
|
|
79
82
|
tez: {
|
|
80
83
|
symbol: { value: 'XTZ', market: 'xtz' },
|
|
@@ -100,6 +103,7 @@ exports.TEZOS_ACCOUNT_METADATA = {
|
|
|
100
103
|
};
|
|
101
104
|
var TezosProtocolImpl = /** @class */ (function () {
|
|
102
105
|
function TezosProtocolImpl(options) {
|
|
106
|
+
this.isTezosProtocol = true;
|
|
103
107
|
// Common
|
|
104
108
|
this.units = exports.TEZOS_UNITS;
|
|
105
109
|
this.feeDefaults = {
|
|
@@ -124,7 +128,7 @@ var TezosProtocolImpl = /** @class */ (function () {
|
|
|
124
128
|
this.options = createTezosProtocolOptions(options.network);
|
|
125
129
|
this.forger = new TezosForger_1.TezosForger();
|
|
126
130
|
this.accountant = new TezosAccountant_1.TezosAccountant(this.forger, this.options.network);
|
|
127
|
-
this.indexerClient = (0, factory_1.createTezosIndexerClient)(this.options.network.
|
|
131
|
+
this.indexerClient = (0, factory_1.createTezosIndexerClient)(this.options.network.indexerType, this.options.network.indexerApi);
|
|
128
132
|
this.cryptoClient = new TezosCryptoClient_1.TezosCryptoClient();
|
|
129
133
|
}
|
|
130
134
|
TezosProtocolImpl.prototype.getMetadata = function () {
|
|
@@ -384,7 +388,7 @@ var TezosProtocolImpl = /** @class */ (function () {
|
|
|
384
388
|
});
|
|
385
389
|
});
|
|
386
390
|
};
|
|
387
|
-
TezosProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details) {
|
|
391
|
+
TezosProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details, _configuration) {
|
|
388
392
|
return __awaiter(this, void 0, void 0, function () {
|
|
389
393
|
var operations, i, recipient, transaction;
|
|
390
394
|
return __generator(this, function (_a) {
|
|
@@ -482,7 +486,298 @@ var TezosProtocolImpl = /** @class */ (function () {
|
|
|
482
486
|
});
|
|
483
487
|
});
|
|
484
488
|
};
|
|
489
|
+
// Staking
|
|
490
|
+
TezosProtocolImpl.prototype.getDefaultDelegatee = function () {
|
|
491
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
492
|
+
var activeBakers;
|
|
493
|
+
return __generator(this, function (_a) {
|
|
494
|
+
switch (_a.label) {
|
|
495
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates?active"))];
|
|
496
|
+
case 1:
|
|
497
|
+
activeBakers = (_a.sent()).data;
|
|
498
|
+
return [2 /*return*/, activeBakers[0] || ''];
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
TezosProtocolImpl.prototype.getCurrentDelegateesForPublicKey = function (publicKey) {
|
|
504
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
505
|
+
var address;
|
|
506
|
+
return __generator(this, function (_a) {
|
|
507
|
+
switch (_a.label) {
|
|
508
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
509
|
+
case 1:
|
|
510
|
+
address = _a.sent();
|
|
511
|
+
return [2 /*return*/, this.getCurrentDelegateesForAddress(address)];
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
};
|
|
516
|
+
TezosProtocolImpl.prototype.getCurrentDelegateesForAddress = function (address) {
|
|
517
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
518
|
+
var data;
|
|
519
|
+
return __generator(this, function (_a) {
|
|
520
|
+
switch (_a.label) {
|
|
521
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address))];
|
|
522
|
+
case 1:
|
|
523
|
+
data = (_a.sent()).data;
|
|
524
|
+
return [2 /*return*/, data.delegate ? [data.delegate] : []];
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
};
|
|
529
|
+
TezosProtocolImpl.prototype.getDelegateeDetails = function (address) {
|
|
530
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
531
|
+
var response, isBakingActive;
|
|
532
|
+
return __generator(this, function (_a) {
|
|
533
|
+
switch (_a.label) {
|
|
534
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/deactivated"))];
|
|
535
|
+
case 1:
|
|
536
|
+
response = _a.sent();
|
|
537
|
+
isBakingActive = !response.data;
|
|
538
|
+
return [2 /*return*/, {
|
|
539
|
+
status: isBakingActive ? 'Active' : 'Inactive',
|
|
540
|
+
address: address
|
|
541
|
+
}];
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
TezosProtocolImpl.prototype.isPublicKeyDelegating = function (publicKey) {
|
|
547
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
548
|
+
var address;
|
|
549
|
+
return __generator(this, function (_a) {
|
|
550
|
+
switch (_a.label) {
|
|
551
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
552
|
+
case 1:
|
|
553
|
+
address = _a.sent();
|
|
554
|
+
return [2 /*return*/, this.isAddressDelegating(address)];
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
};
|
|
559
|
+
TezosProtocolImpl.prototype.isAddressDelegating = function (address) {
|
|
560
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
561
|
+
var data;
|
|
562
|
+
return __generator(this, function (_a) {
|
|
563
|
+
switch (_a.label) {
|
|
564
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address))];
|
|
565
|
+
case 1:
|
|
566
|
+
data = (_a.sent()).data;
|
|
567
|
+
return [2 /*return*/, !!data.delegate];
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
};
|
|
572
|
+
TezosProtocolImpl.prototype.getDelegatorDetailsFromPublicKey = function (publicKey) {
|
|
573
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
574
|
+
var address;
|
|
575
|
+
return __generator(this, function (_a) {
|
|
576
|
+
switch (_a.label) {
|
|
577
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
578
|
+
case 1:
|
|
579
|
+
address = _a.sent();
|
|
580
|
+
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address)];
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
TezosProtocolImpl.prototype.getDelegatorDetailsFromAddress = function (address) {
|
|
586
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
587
|
+
return __generator(this, function (_a) {
|
|
588
|
+
return [2 /*return*/, this.getDelegatorDetails(address)];
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
};
|
|
592
|
+
TezosProtocolImpl.prototype.getDelegationDetailsFromPublicKey = function (publicKey, delegatees) {
|
|
593
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
594
|
+
var address;
|
|
595
|
+
return __generator(this, function (_a) {
|
|
596
|
+
switch (_a.label) {
|
|
597
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
598
|
+
case 1:
|
|
599
|
+
address = _a.sent();
|
|
600
|
+
return [2 /*return*/, this.getDelegationDetailsFromAddress(address, delegatees)];
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
};
|
|
605
|
+
TezosProtocolImpl.prototype.getDelegationDetailsFromAddress = function (address, delegatees) {
|
|
606
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
607
|
+
var bakerAddress, results, delegatorDetails, bakerDetails;
|
|
608
|
+
return __generator(this, function (_a) {
|
|
609
|
+
switch (_a.label) {
|
|
610
|
+
case 0:
|
|
611
|
+
if (delegatees.length > 1) {
|
|
612
|
+
return [2 /*return*/, Promise.reject('Multiple delegation is not supported.')];
|
|
613
|
+
}
|
|
614
|
+
bakerAddress = delegatees[0];
|
|
615
|
+
return [4 /*yield*/, Promise.all([this.getDelegatorDetails(address, bakerAddress), this.getDelegateeDetails(bakerAddress)])];
|
|
616
|
+
case 1:
|
|
617
|
+
results = _a.sent();
|
|
618
|
+
delegatorDetails = results[0];
|
|
619
|
+
bakerDetails = results[1];
|
|
620
|
+
return [2 /*return*/, {
|
|
621
|
+
delegator: delegatorDetails,
|
|
622
|
+
delegatees: [bakerDetails]
|
|
623
|
+
}];
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
};
|
|
628
|
+
TezosProtocolImpl.prototype.getDelegatorDetails = function (address, bakerAddress) {
|
|
629
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
630
|
+
var results, accountDetails, balance, isDelegating, availableActions;
|
|
631
|
+
return __generator(this, function (_a) {
|
|
632
|
+
switch (_a.label) {
|
|
633
|
+
case 0: return [4 /*yield*/, Promise.all([index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address))])];
|
|
634
|
+
case 1:
|
|
635
|
+
results = _a.sent();
|
|
636
|
+
accountDetails = results[0].data;
|
|
637
|
+
balance = accountDetails.balance;
|
|
638
|
+
isDelegating = !!accountDetails.delegate;
|
|
639
|
+
availableActions = [];
|
|
640
|
+
if (!isDelegating) {
|
|
641
|
+
availableActions.push({
|
|
642
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.DELEGATE,
|
|
643
|
+
args: ['delegate']
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
else if (!bakerAddress || accountDetails.delegate === bakerAddress) {
|
|
647
|
+
availableActions.push({
|
|
648
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.UNDELEGATE
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
availableActions.push({
|
|
653
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.CHANGE_BAKER,
|
|
654
|
+
args: ['delegate']
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
return [2 /*return*/, {
|
|
658
|
+
address: address,
|
|
659
|
+
balance: balance,
|
|
660
|
+
delegatees: [accountDetails.delegate],
|
|
661
|
+
availableActions: availableActions
|
|
662
|
+
}];
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
};
|
|
667
|
+
TezosProtocolImpl.prototype.prepareDelegatorActionFromPublicKey = function (publicKey, type, data) {
|
|
668
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
669
|
+
var _a;
|
|
670
|
+
return __generator(this, function (_b) {
|
|
671
|
+
switch (_b.label) {
|
|
672
|
+
case 0:
|
|
673
|
+
_a = type;
|
|
674
|
+
switch (_a) {
|
|
675
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.DELEGATE: return [3 /*break*/, 1];
|
|
676
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.CHANGE_BAKER: return [3 /*break*/, 1];
|
|
677
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.UNDELEGATE: return [3 /*break*/, 3];
|
|
678
|
+
}
|
|
679
|
+
return [3 /*break*/, 5];
|
|
680
|
+
case 1:
|
|
681
|
+
if (!data || !data.delegate) {
|
|
682
|
+
return [2 /*return*/, Promise.reject("Invalid arguments passed for ".concat(type, " action, delegate is missing."))];
|
|
683
|
+
}
|
|
684
|
+
return [4 /*yield*/, this.delegate(publicKey, data.delegate)];
|
|
685
|
+
case 2: return [2 /*return*/, [_b.sent()]];
|
|
686
|
+
case 3: return [4 /*yield*/, this.undelegate(publicKey)];
|
|
687
|
+
case 4: return [2 /*return*/, [_b.sent()]];
|
|
688
|
+
case 5: return [2 /*return*/, Promise.reject('Unsupported delegator action.')];
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
};
|
|
693
|
+
TezosProtocolImpl.prototype.undelegate = function (publicKey) {
|
|
694
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
695
|
+
return __generator(this, function (_a) {
|
|
696
|
+
return [2 /*return*/, this.delegate(publicKey)];
|
|
697
|
+
});
|
|
698
|
+
});
|
|
699
|
+
};
|
|
700
|
+
TezosProtocolImpl.prototype.delegate = function (publicKey, delegate) {
|
|
701
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
702
|
+
var counter, branch, operations, tzAddress, results, accountManager, balance, totalBalance, fee, delegationOperation, tezosWrappedOperation, binary, error_3;
|
|
703
|
+
return __generator(this, function (_a) {
|
|
704
|
+
switch (_a.label) {
|
|
705
|
+
case 0:
|
|
706
|
+
counter = new bignumber_1.default(1);
|
|
707
|
+
branch = '';
|
|
708
|
+
operations = [];
|
|
709
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
710
|
+
case 1:
|
|
711
|
+
tzAddress = _a.sent();
|
|
712
|
+
return [4 /*yield*/, Promise.all([
|
|
713
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(tzAddress, "/counter")),
|
|
714
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head~2/hash")),
|
|
715
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(tzAddress, "/manager_key"))
|
|
716
|
+
]).catch(function (error) {
|
|
717
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error);
|
|
718
|
+
})];
|
|
719
|
+
case 2:
|
|
720
|
+
results = _a.sent();
|
|
721
|
+
counter = new bignumber_1.default(results[0].data).plus(1);
|
|
722
|
+
branch = results[1].data;
|
|
723
|
+
accountManager = results[2].data;
|
|
724
|
+
// check if we have revealed the address already
|
|
725
|
+
if (!accountManager) {
|
|
726
|
+
operations.push((0, operations_1.createRevealOperation)(counter, publicKey, tzAddress));
|
|
727
|
+
counter = counter.plus(1);
|
|
728
|
+
}
|
|
729
|
+
return [4 /*yield*/, this.getBalanceOfAddress(tzAddress)];
|
|
730
|
+
case 3:
|
|
731
|
+
balance = _a.sent();
|
|
732
|
+
totalBalance = new bignumber_1.default((0, module_kit_1.newAmount)(balance.total).blockchain(this.units).value);
|
|
733
|
+
fee = new bignumber_1.default(1420);
|
|
734
|
+
if (totalBalance.isLessThan(fee)) {
|
|
735
|
+
throw new errors_1.BalanceError(coinlib_core_1.Domain.TEZOS, 'not enough balance');
|
|
736
|
+
}
|
|
737
|
+
delegationOperation = {
|
|
738
|
+
kind: TezosOperationType_1.TezosOperationType.DELEGATION,
|
|
739
|
+
source: tzAddress,
|
|
740
|
+
fee: fee.toFixed(),
|
|
741
|
+
counter: counter.toFixed(),
|
|
742
|
+
gas_limit: '10000',
|
|
743
|
+
storage_limit: '0',
|
|
744
|
+
delegate: Array.isArray(delegate) ? delegate[0] : delegate
|
|
745
|
+
};
|
|
746
|
+
operations.push(delegationOperation);
|
|
747
|
+
_a.label = 4;
|
|
748
|
+
case 4:
|
|
749
|
+
_a.trys.push([4, 6, , 7]);
|
|
750
|
+
tezosWrappedOperation = {
|
|
751
|
+
branch: branch,
|
|
752
|
+
contents: operations
|
|
753
|
+
};
|
|
754
|
+
return [4 /*yield*/, this.forgeOperation(tezosWrappedOperation)];
|
|
755
|
+
case 5:
|
|
756
|
+
binary = _a.sent();
|
|
757
|
+
return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ binary: binary })];
|
|
758
|
+
case 6:
|
|
759
|
+
error_3 = _a.sent();
|
|
760
|
+
throw new errors_1.OperationFailedError(coinlib_core_1.Domain.TEZOS, "Forging Tezos TX failed with ".concat(JSON.stringify(error_3.message)));
|
|
761
|
+
case 7: return [2 /*return*/];
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
};
|
|
485
766
|
// Custom
|
|
767
|
+
TezosProtocolImpl.prototype.getMinCycleDuration = function () {
|
|
768
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
769
|
+
return __generator(this, function (_a) {
|
|
770
|
+
return [2 /*return*/, MIN_CYCLE_DURATION];
|
|
771
|
+
});
|
|
772
|
+
});
|
|
773
|
+
};
|
|
774
|
+
TezosProtocolImpl.prototype.getDetailsFromWrappedOperation = function (wrappedOperation) {
|
|
775
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
776
|
+
return __generator(this, function (_a) {
|
|
777
|
+
return [2 /*return*/, this.accountant.getDetailsFromWrappedOperation(wrappedOperation)];
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
};
|
|
486
781
|
TezosProtocolImpl.prototype.forgeOperation = function (wrappedOperation) {
|
|
487
782
|
return __awaiter(this, void 0, void 0, function () {
|
|
488
783
|
return __generator(this, function (_a) {
|
|
@@ -735,7 +1030,7 @@ var TezosProtocolImpl = /** @class */ (function () {
|
|
|
735
1030
|
var counter = startingCounter ? startingCounter.plus(i).toString() : op.counter;
|
|
736
1031
|
return __assign(__assign({}, operation), { gas_limit: gas_limit, counter: counter });
|
|
737
1032
|
});
|
|
738
|
-
return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head"))];
|
|
1033
|
+
return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/header"))];
|
|
739
1034
|
case 1:
|
|
740
1035
|
block = (_a.sent()).data;
|
|
741
1036
|
body = {
|
|
@@ -900,6 +1195,50 @@ var TezosProtocolImpl = /** @class */ (function () {
|
|
|
900
1195
|
});
|
|
901
1196
|
});
|
|
902
1197
|
};
|
|
1198
|
+
TezosProtocolImpl.prototype.bakerDetails = function (address) {
|
|
1199
|
+
var _a, _b, _c, _d;
|
|
1200
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1201
|
+
var results, tzBalance, delegatedBalance, stakingBalance, selfBond, stakingCapacity, bakerDetails;
|
|
1202
|
+
return __generator(this, function (_e) {
|
|
1203
|
+
switch (_e.label) {
|
|
1204
|
+
case 0:
|
|
1205
|
+
if (!address ||
|
|
1206
|
+
!(address.toLowerCase().startsWith('tz1') ||
|
|
1207
|
+
address.toLowerCase().startsWith('tz2') ||
|
|
1208
|
+
address.toLowerCase().startsWith('tz3') ||
|
|
1209
|
+
address.toLowerCase().startsWith('tz4'))) {
|
|
1210
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, 'non tz-address supplied');
|
|
1211
|
+
}
|
|
1212
|
+
return [4 /*yield*/, Promise.all([
|
|
1213
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/balance")).catch(function (_error) { return undefined; }),
|
|
1214
|
+
index_1.default
|
|
1215
|
+
.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/full_balance"))
|
|
1216
|
+
.catch(function (_error) { return undefined; }),
|
|
1217
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/delegated_balance")),
|
|
1218
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/staking_balance"))
|
|
1219
|
+
]).catch(function (error) {
|
|
1220
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error);
|
|
1221
|
+
})];
|
|
1222
|
+
case 1:
|
|
1223
|
+
results = _e.sent();
|
|
1224
|
+
tzBalance = new bignumber_1.default((_b = ((_a = results[0]) !== null && _a !== void 0 ? _a : results[1])) === null || _b === void 0 ? void 0 : _b.data);
|
|
1225
|
+
delegatedBalance = new bignumber_1.default((_c = results[2]) === null || _c === void 0 ? void 0 : _c.data);
|
|
1226
|
+
stakingBalance = new bignumber_1.default((_d = results[3]) === null || _d === void 0 ? void 0 : _d.data);
|
|
1227
|
+
selfBond = stakingBalance.minus(delegatedBalance);
|
|
1228
|
+
stakingCapacity = stakingBalance.div(selfBond.div(SELF_BOND_REQUIREMENT));
|
|
1229
|
+
bakerDetails = {
|
|
1230
|
+
balance: (0, module_kit_1.newAmount)(tzBalance, 'blockchain'),
|
|
1231
|
+
delegatedBalance: (0, module_kit_1.newAmount)(delegatedBalance, 'blockchain'),
|
|
1232
|
+
stakingBalance: (0, module_kit_1.newAmount)(stakingBalance, 'blockchain'),
|
|
1233
|
+
selfBond: (0, module_kit_1.newAmount)(selfBond, 'blockchain'),
|
|
1234
|
+
bakerCapacity: stakingBalance.div(stakingCapacity).toString(),
|
|
1235
|
+
bakerUsage: stakingCapacity.toString()
|
|
1236
|
+
};
|
|
1237
|
+
return [2 /*return*/, bakerDetails];
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
});
|
|
1241
|
+
};
|
|
903
1242
|
return TezosProtocolImpl;
|
|
904
1243
|
}());
|
|
905
1244
|
exports.TezosProtocolImpl = TezosProtocolImpl;
|
|
@@ -914,34 +1253,26 @@ exports.TEZOS_MAINNET_PROTOCOL_NETWORK = {
|
|
|
914
1253
|
type: 'mainnet',
|
|
915
1254
|
rpcUrl: 'https://tezos-node.prod.gke.papers.tech',
|
|
916
1255
|
network: network_1.TezosNetwork.MAINNET,
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
indexer: {
|
|
922
|
-
type: 'tzkt',
|
|
923
|
-
apiUrl: 'https://tezos-mainnet-indexer.prod.gke.papers.tech'
|
|
924
|
-
}
|
|
1256
|
+
blockExplorerUrl: 'https://tzkt.io',
|
|
1257
|
+
blockExplorerType: 'tzkt',
|
|
1258
|
+
indexerApi: 'https://tezos-mainnet-indexer.prod.gke.papers.tech',
|
|
1259
|
+
indexerType: 'tzkt'
|
|
925
1260
|
};
|
|
926
1261
|
exports.TEZOS_GHOSTNET_PROTOCOL_NETWORK = {
|
|
927
1262
|
name: 'Ghostnet',
|
|
928
1263
|
type: 'testnet',
|
|
929
1264
|
rpcUrl: 'https://tezos-ghostnet-node.prod.gke.papers.tech',
|
|
930
1265
|
network: network_1.TezosNetwork.GHOSTNET,
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
indexer: {
|
|
936
|
-
type: 'tzkt',
|
|
937
|
-
apiUrl: 'https://tezos-ghostnet-indexer.prod.gke.papers.tech'
|
|
938
|
-
}
|
|
1266
|
+
blockExplorerUrl: 'https://ghostnet.tzkt.io',
|
|
1267
|
+
blockExplorerType: 'tzkt',
|
|
1268
|
+
indexerApi: 'https://tezos-ghostnet-indexer.prod.gke.papers.tech',
|
|
1269
|
+
indexerType: 'tzkt'
|
|
939
1270
|
};
|
|
940
1271
|
var DEFAULT_TEZOS_PROTOCOL_NETWORK = exports.TEZOS_MAINNET_PROTOCOL_NETWORK;
|
|
941
1272
|
function createTezosProtocolOptions(network) {
|
|
942
1273
|
if (network === void 0) { network = {}; }
|
|
943
1274
|
return {
|
|
944
|
-
network: __assign(__assign(
|
|
1275
|
+
network: __assign(__assign({}, DEFAULT_TEZOS_PROTOCOL_NETWORK), network)
|
|
945
1276
|
};
|
|
946
1277
|
}
|
|
947
1278
|
exports.createTezosProtocolOptions = createTezosProtocolOptions;
|