@tezos-x/octez.js 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -0
- package/dist/lib/batch/constants.js +16 -0
- package/dist/lib/batch/rpc-batch-provider.js +319 -0
- package/dist/lib/constants.js +133 -0
- package/dist/lib/context.js +182 -0
- package/dist/lib/contract/big-map.js +70 -0
- package/dist/lib/contract/compose.js +6 -0
- package/dist/lib/contract/constants.js +4 -0
- package/dist/lib/contract/contract-methods/contract-method-factory.js +18 -0
- package/dist/lib/contract/contract-methods/contract-method-interface.js +2 -0
- package/dist/lib/contract/contract-methods/contract-method-object-param.js +72 -0
- package/dist/lib/contract/contract-methods/contract-on-chain-view.js +124 -0
- package/dist/lib/contract/contract.js +169 -0
- package/dist/lib/contract/errors.js +140 -0
- package/dist/lib/contract/index.js +30 -0
- package/dist/lib/contract/interface.js +2 -0
- package/dist/lib/contract/manager-lambda.js +71 -0
- package/dist/lib/contract/prepare.js +240 -0
- package/dist/lib/contract/rpc-contract-provider.js +724 -0
- package/dist/lib/contract/sapling-state-abstraction.js +35 -0
- package/dist/lib/contract/semantic.js +40 -0
- package/dist/lib/contract/view_lambda.js +27 -0
- package/dist/lib/errors.js +42 -0
- package/dist/lib/estimate/errors.js +16 -0
- package/dist/lib/estimate/estimate-provider-interface.js +2 -0
- package/dist/lib/estimate/estimate.js +130 -0
- package/dist/lib/estimate/index.js +20 -0
- package/dist/lib/estimate/rpc-estimate-provider.js +673 -0
- package/dist/lib/extension/extension.js +2 -0
- package/dist/lib/forger/composite-forger.js +43 -0
- package/dist/lib/forger/errors.js +30 -0
- package/dist/lib/forger/octez.js-local-forger.js +34 -0
- package/dist/lib/forger/rpc-forger.js +12 -0
- package/dist/lib/global-constants/default-global-constants-provider.js +46 -0
- package/dist/lib/global-constants/errors.js +30 -0
- package/dist/lib/global-constants/interface-global-constants-provider.js +2 -0
- package/dist/lib/global-constants/noop-global-constants-provider.js +21 -0
- package/dist/lib/import-key.js +51 -0
- package/dist/lib/injector/helper.js +18 -0
- package/dist/lib/injector/interface.js +2 -0
- package/dist/lib/injector/rpc-injector.js +38 -0
- package/dist/lib/octez.js +404 -0
- package/dist/lib/operations/ballot-operation.js +33 -0
- package/dist/lib/operations/batch-operation.js +66 -0
- package/dist/lib/operations/delegate-operation.js +57 -0
- package/dist/lib/operations/drain-delegate-operation.js +31 -0
- package/dist/lib/operations/errors.js +130 -0
- package/dist/lib/operations/failing-noop-operation.js +2 -0
- package/dist/lib/operations/increase-paid-storage-operation.js +52 -0
- package/dist/lib/operations/index.js +54 -0
- package/dist/lib/operations/operations.js +123 -0
- package/dist/lib/operations/origination-operation.js +89 -0
- package/dist/lib/operations/proposals-operation.js +30 -0
- package/dist/lib/operations/register-global-constant-operation.js +55 -0
- package/dist/lib/operations/reveal-operation.js +74 -0
- package/dist/lib/operations/smart-rollup-add-messages-operation.js +47 -0
- package/dist/lib/operations/smart-rollup-execute-outbox-message-operation.js +56 -0
- package/dist/lib/operations/smart-rollup-originate-operation.js +53 -0
- package/dist/lib/operations/transaction-operation.js +70 -0
- package/dist/lib/operations/transfer-ticket-operation.js +49 -0
- package/dist/lib/operations/types.js +90 -0
- package/dist/lib/operations/update-companion-key-operation.js +58 -0
- package/dist/lib/operations/update-consensus-key-operation.js +58 -0
- package/dist/lib/packer/interface.js +2 -0
- package/dist/lib/packer/michel-codec-packer.js +22 -0
- package/dist/lib/packer/rpc-packer.js +23 -0
- package/dist/lib/parser/interface.js +2 -0
- package/dist/lib/parser/michel-codec-parser.js +135 -0
- package/dist/lib/parser/noop-parser.js +20 -0
- package/dist/lib/prepare/index.js +18 -0
- package/dist/lib/prepare/interface.js +2 -0
- package/dist/lib/prepare/prepare-provider.js +1010 -0
- package/dist/lib/provider.js +169 -0
- package/dist/lib/read-provider/interface.js +2 -0
- package/dist/lib/read-provider/rpc-read-adapter.js +228 -0
- package/dist/lib/signer/errors.js +17 -0
- package/dist/lib/signer/noop.js +40 -0
- package/dist/lib/subscribe/create-observable-from-subscription.js +20 -0
- package/dist/lib/subscribe/errors.js +30 -0
- package/dist/lib/subscribe/filters.js +96 -0
- package/dist/lib/subscribe/interface.js +2 -0
- package/dist/lib/subscribe/observable-subscription.js +79 -0
- package/dist/lib/subscribe/polling-subcribe-provider.js +118 -0
- package/dist/lib/tz/interface.js +2 -0
- package/dist/lib/tz/rpc-tz-provider.js +63 -0
- package/dist/lib/version.js +8 -0
- package/dist/lib/wallet/batch-operation.js +84 -0
- package/dist/lib/wallet/delegation-operation.js +57 -0
- package/dist/lib/wallet/errors.js +28 -0
- package/dist/lib/wallet/increase-paid-storage-operation.js +57 -0
- package/dist/lib/wallet/index.js +25 -0
- package/dist/lib/wallet/interface.js +2 -0
- package/dist/lib/wallet/legacy.js +86 -0
- package/dist/lib/wallet/operation-factory.js +117 -0
- package/dist/lib/wallet/operation.js +157 -0
- package/dist/lib/wallet/origination-operation.js +65 -0
- package/dist/lib/wallet/receipt.js +43 -0
- package/dist/lib/wallet/register-global-constant-operation.js +62 -0
- package/dist/lib/wallet/transaction-operation.js +53 -0
- package/dist/lib/wallet/transfer-ticket-operation.js +53 -0
- package/dist/lib/wallet/wallet.js +442 -0
- package/dist/octez.es6.js +7673 -0
- package/dist/octez.es6.js.map +1 -0
- package/dist/octez.umd.js +7787 -0
- package/dist/octez.umd.js.map +1 -0
- package/dist/types/batch/constants.d.ts +3 -0
- package/dist/types/batch/rpc-batch-provider.d.ts +139 -0
- package/dist/types/constants.d.ts +81 -0
- package/dist/types/context.d.ts +100 -0
- package/dist/types/contract/big-map.d.ts +35 -0
- package/dist/types/contract/compose.d.ts +5 -0
- package/dist/types/contract/constants.d.ts +1 -0
- package/dist/types/contract/contract-methods/contract-method-factory.d.ts +14 -0
- package/dist/types/contract/contract-methods/contract-method-interface.d.ts +28 -0
- package/dist/types/contract/contract-methods/contract-method-object-param.d.ts +39 -0
- package/dist/types/contract/contract-methods/contract-on-chain-view.d.ts +43 -0
- package/dist/types/contract/contract.d.ts +75 -0
- package/dist/types/contract/errors.d.ts +83 -0
- package/dist/types/contract/index.d.ts +11 -0
- package/dist/types/contract/interface.d.ts +254 -0
- package/dist/types/contract/manager-lambda.d.ts +73 -0
- package/dist/types/contract/prepare.d.ts +18 -0
- package/dist/types/contract/rpc-contract-provider.d.ts +269 -0
- package/dist/types/contract/sapling-state-abstraction.d.ts +17 -0
- package/dist/types/contract/semantic.d.ts +7 -0
- package/dist/types/contract/view_lambda.d.ts +34 -0
- package/dist/types/errors.d.ts +26 -0
- package/dist/types/estimate/errors.d.ts +8 -0
- package/dist/types/estimate/estimate-provider-interface.d.ts +156 -0
- package/dist/types/estimate/estimate.d.ts +94 -0
- package/dist/types/estimate/index.d.ts +4 -0
- package/dist/types/estimate/rpc-estimate-provider.d.ts +170 -0
- package/dist/types/extension/extension.d.ts +4 -0
- package/dist/types/forger/composite-forger.d.ts +6 -0
- package/dist/types/forger/errors.d.ts +16 -0
- package/dist/types/forger/octez.js-local-forger.d.ts +8 -0
- package/dist/types/forger/rpc-forger.d.ts +7 -0
- package/dist/types/global-constants/default-global-constants-provider.d.ts +18 -0
- package/dist/types/global-constants/errors.d.ts +16 -0
- package/dist/types/global-constants/interface-global-constants-provider.d.ts +11 -0
- package/dist/types/global-constants/noop-global-constants-provider.d.ts +5 -0
- package/dist/types/import-key.d.ts +13 -0
- package/dist/types/injector/helper.d.ts +2 -0
- package/dist/types/injector/interface.d.ts +5 -0
- package/dist/types/injector/rpc-injector.d.ts +7 -0
- package/dist/types/octez.d.ts +248 -0
- package/dist/types/operations/ballot-operation.d.ts +18 -0
- package/dist/types/operations/batch-operation.d.ts +19 -0
- package/dist/types/operations/delegate-operation.d.ts +24 -0
- package/dist/types/operations/drain-delegate-operation.d.ts +17 -0
- package/dist/types/operations/errors.d.ts +50 -0
- package/dist/types/operations/failing-noop-operation.d.ts +17 -0
- package/dist/types/operations/increase-paid-storage-operation.d.ts +23 -0
- package/dist/types/operations/index.d.ts +18 -0
- package/dist/types/operations/operations.d.ts +35 -0
- package/dist/types/operations/origination-operation.d.ts +35 -0
- package/dist/types/operations/proposals-operation.d.ts +17 -0
- package/dist/types/operations/register-global-constant-operation.d.ts +25 -0
- package/dist/types/operations/reveal-operation.d.ts +25 -0
- package/dist/types/operations/smart-rollup-add-messages-operation.d.ts +20 -0
- package/dist/types/operations/smart-rollup-execute-outbox-message-operation.d.ts +24 -0
- package/dist/types/operations/smart-rollup-originate-operation.d.ts +23 -0
- package/dist/types/operations/transaction-operation.d.ts +28 -0
- package/dist/types/operations/transfer-ticket-operation.d.ts +22 -0
- package/dist/types/operations/types.d.ts +461 -0
- package/dist/types/operations/update-companion-key-operation.d.ts +23 -0
- package/dist/types/operations/update-consensus-key-operation.d.ts +23 -0
- package/dist/types/packer/interface.d.ts +4 -0
- package/dist/types/packer/michel-codec-packer.d.ts +5 -0
- package/dist/types/packer/rpc-packer.d.ts +8 -0
- package/dist/types/parser/interface.d.ts +4 -0
- package/dist/types/parser/michel-codec-parser.d.ts +16 -0
- package/dist/types/parser/noop-parser.d.ts +5 -0
- package/dist/types/prepare/index.d.ts +2 -0
- package/dist/types/prepare/interface.d.ts +153 -0
- package/dist/types/prepare/prepare-provider.d.ts +213 -0
- package/dist/types/provider.d.ts +44 -0
- package/dist/types/read-provider/interface.d.ts +132 -0
- package/dist/types/read-provider/rpc-read-adapter.d.ts +130 -0
- package/dist/types/signer/errors.d.ts +8 -0
- package/dist/types/signer/noop.d.ts +11 -0
- package/dist/types/subscribe/create-observable-from-subscription.d.ts +4 -0
- package/dist/types/subscribe/errors.d.ts +18 -0
- package/dist/types/subscribe/filters.d.ts +6 -0
- package/dist/types/subscribe/interface.d.ts +48 -0
- package/dist/types/subscribe/observable-subscription.d.ts +21 -0
- package/dist/types/subscribe/polling-subcribe-provider.d.ts +23 -0
- package/dist/types/tz/interface.d.ts +20 -0
- package/dist/types/tz/rpc-tz-provider.d.ts +13 -0
- package/dist/types/version.d.ts +4 -0
- package/dist/types/wallet/batch-operation.d.ts +13 -0
- package/dist/types/wallet/delegation-operation.d.ts +12 -0
- package/dist/types/wallet/errors.d.ts +16 -0
- package/dist/types/wallet/increase-paid-storage-operation.d.ts +12 -0
- package/dist/types/wallet/index.d.ts +9 -0
- package/dist/types/wallet/interface.d.ts +66 -0
- package/dist/types/wallet/legacy.d.ts +21 -0
- package/dist/types/wallet/operation-factory.d.ts +32 -0
- package/dist/types/wallet/operation.d.ts +54 -0
- package/dist/types/wallet/origination-operation.d.ts +14 -0
- package/dist/types/wallet/receipt.d.ts +16 -0
- package/dist/types/wallet/register-global-constant-operation.d.ts +13 -0
- package/dist/types/wallet/transaction-operation.d.ts +12 -0
- package/dist/types/wallet/transfer-ticket-operation.d.ts +12 -0
- package/dist/types/wallet/wallet.d.ts +195 -0
- package/package.json +131 -0
- package/patch.js +20 -0
- package/signature.json +866 -0
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# octez.js
|
|
2
|
+
|
|
3
|
+
*TypeDoc style documentation is available on-line [here](https://octez.js.io/typedoc/modules/_octez.js_octez.js.html)*
|
|
4
|
+
|
|
5
|
+
`@tezos-x/octez.js` is the main entry point for interacting with the Tezos blockchain. It provides high-level functionality that builds upon the other packages in the octez.js library suite.
|
|
6
|
+
|
|
7
|
+
**Maintained by [Nomadic Labs](https://www.nomadic-labs.com/).**
|
|
8
|
+
|
|
9
|
+
## CDN Bundle
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<script src="https://unpkg.com/@tezos-x/octez.js@0.9.0/dist/octez.js.min.js"></script>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## General Information
|
|
16
|
+
|
|
17
|
+
The `TezosToolkit` is a facade class that surfaces all of the library's capability and allows its configuration through different providers.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
npm i --save @tezos-x/octez.js
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Minimal configuration
|
|
27
|
+
### TezosToolkit instantiation
|
|
28
|
+
|
|
29
|
+
The `TezosToolkit` constructor takes at least an RPC URL as a parameter. When instantiating the toolkit with a URL, a default instance of `RpcClient` is created. The `RpcClient` class is used to interact with the Tezos network.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { TezosToolkit } from '@tezos-x/octez.js';
|
|
33
|
+
|
|
34
|
+
const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
It is also possible to instantiate the `TezosToolkit` with a class that implements the `RpcClientInterface`. See the `RpcClientCache` from the `@tezos-x/octez.js-rpc` package as an example that provides caching functionality.
|
|
38
|
+
|
|
39
|
+
### Choosing between the contract or the wallet APIs
|
|
40
|
+
|
|
41
|
+
In most cases, you want to use the Wallet API when you give the users of your dapp the freedom to choose the wallet of their choice to interact with. The Contract API is more suited for back-end applications and forging/signing offline (for example, using the inMemorySigner). You would also use the Contract API to build a wallet.
|
|
42
|
+
|
|
43
|
+
**Configure a signer to use the Contract API**
|
|
44
|
+
|
|
45
|
+
Sending operations using the Contract API requires a signer to be configured. octez.js provides different signer implementations (e.g. see the `@tezos-x/octez.js-remote-signer`, `@tezos-x/octez.js-signer` and `@tezos-x/octez.js-ledger-signer`). Here is an example using the `InMemorySigner`:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { InMemorySigner } from '@tezos-x/octez.js-signer';
|
|
49
|
+
import { TezosToolkit } from '@tezos-x/octez.js';
|
|
50
|
+
|
|
51
|
+
const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
|
|
52
|
+
|
|
53
|
+
Tezos.setProvider({ signer: await InMemorySigner.fromSecretKey('edsk...') });
|
|
54
|
+
|
|
55
|
+
// Using the contract API, the following operation is signed using the configured signer:
|
|
56
|
+
await Tezos.contract.transfer({ to: publicKeyHash, amount: 2 });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Configure a wallet to use the Wallet API**
|
|
60
|
+
|
|
61
|
+
Sending operations using the Wallet API requires a wallet to be configured. The wallet API supports different kinds of wallets. For example, the `BeaconWallet` from the `@tezos-x/octez.js-beacon-wallet` (powered by [octez.connect](https://www.npmjs.com/package/@tezos-x/octez.connect)) can be used. Use the `setWalletProvider` method of the `TezosToolkit` to set the wallet:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { TezosToolkit } from '@tezos-x/octez.js';
|
|
65
|
+
import { BeaconWallet } from '@tezos-x/octez.js-beacon-wallet';
|
|
66
|
+
|
|
67
|
+
const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
|
|
68
|
+
const wallet = new BeaconWallet(options);
|
|
69
|
+
|
|
70
|
+
await wallet.requestPermissions(network);
|
|
71
|
+
|
|
72
|
+
Tezos.setWalletProvider(wallet);
|
|
73
|
+
|
|
74
|
+
// Using the wallet API, the configured wallet will prepare the transaction and broadcast it
|
|
75
|
+
await Tezos.wallet.transfer({ to: publicKeyHash, amount: 2 }).send();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## TezosToolkit examples of additional configuration
|
|
79
|
+
|
|
80
|
+
The `TezosToolkit` contains different default providers that are customizable to adapt to users' needs.
|
|
81
|
+
|
|
82
|
+
### Forger
|
|
83
|
+
|
|
84
|
+
Replace the default `RpcForger` with an instance of `LocalForger`:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { localForger } from '@tezos-x/octez.js-local-forging'
|
|
88
|
+
Tezos.setForgerProvider(localForger);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Packer
|
|
92
|
+
|
|
93
|
+
To fetch values of the big map using the local implementation to pack data, replace the default `RpcPacker` with an instance of `MichelCodecPacker`:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { MichelCodecPacker } from '@tezos-x/octez.js';
|
|
97
|
+
// Fetch values of the big map using local implementation to pack data
|
|
98
|
+
Tezos.setPackerProvider(new MichelCodecPacker());
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Poller configuration
|
|
102
|
+
|
|
103
|
+
Polling interval for operation confirmation can be set globally for a octez.js instance.
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
Tezos.setProvider(
|
|
107
|
+
{
|
|
108
|
+
config: {
|
|
109
|
+
confirmationPollingIntervalSecond: 5,
|
|
110
|
+
confirmationPollingTimeoutSecond: 180
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Estimation
|
|
117
|
+
|
|
118
|
+
Use the `estimate` member to estimate fees, gas and storage of operations.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const estimate = await Tezos.estimate.transfer(transferParams);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Stream
|
|
125
|
+
|
|
126
|
+
Use the `stream` member to subscribe to specific operations:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
Tezos.setProvider({
|
|
130
|
+
config: { shouldObservableSubscriptionRetry: true, streamerPollingIntervalMilliseconds: 15000 }
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const bakerAttestationFilter = {
|
|
134
|
+
and: [{ source: 'tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m' }, { kind: 'attestation' }]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const bakerDelegation = {
|
|
138
|
+
and: [{ destination: 'tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m' }, { kind: 'delegation' }]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const sub = tezos.stream.subscribeOperation({
|
|
142
|
+
or: [bakerAttestationFilter, bakerDelegation]
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
sub.on('data', console.log)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Additional info
|
|
149
|
+
|
|
150
|
+
See the top-level [https://github.com/trilitech/octez.js](https://github.com/trilitech/octez.js) file for details on reporting issues, contributing and versioning.
|
|
151
|
+
|
|
152
|
+
## Disclaimer
|
|
153
|
+
|
|
154
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BATCH_KINDS = void 0;
|
|
4
|
+
const octez_js_rpc_1 = require("@tezos-x/octez.js-rpc");
|
|
5
|
+
exports.BATCH_KINDS = [
|
|
6
|
+
octez_js_rpc_1.OpKind.ACTIVATION,
|
|
7
|
+
octez_js_rpc_1.OpKind.ORIGINATION,
|
|
8
|
+
octez_js_rpc_1.OpKind.TRANSACTION,
|
|
9
|
+
octez_js_rpc_1.OpKind.DELEGATION,
|
|
10
|
+
octez_js_rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT,
|
|
11
|
+
octez_js_rpc_1.OpKind.INCREASE_PAID_STORAGE,
|
|
12
|
+
octez_js_rpc_1.OpKind.TRANSFER_TICKET,
|
|
13
|
+
octez_js_rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES,
|
|
14
|
+
octez_js_rpc_1.OpKind.SMART_ROLLUP_ORIGINATE,
|
|
15
|
+
octez_js_rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,
|
|
16
|
+
];
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RPCBatchProvider = exports.OperationBatch = exports.BATCH_KINDS = void 0;
|
|
13
|
+
const prepare_1 = require("../contract/prepare");
|
|
14
|
+
const batch_operation_1 = require("../operations/batch-operation");
|
|
15
|
+
const octez_js_rpc_1 = require("@tezos-x/octez.js-rpc");
|
|
16
|
+
const octez_js_utils_1 = require("@tezos-x/octez.js-utils");
|
|
17
|
+
const octez_js_core_1 = require("@tezos-x/octez.js-core");
|
|
18
|
+
const provider_1 = require("../provider");
|
|
19
|
+
const prepare_2 = require("../prepare");
|
|
20
|
+
var constants_1 = require("./constants");
|
|
21
|
+
Object.defineProperty(exports, "BATCH_KINDS", { enumerable: true, get: function () { return constants_1.BATCH_KINDS; } });
|
|
22
|
+
class OperationBatch extends provider_1.Provider {
|
|
23
|
+
constructor(context, estimator) {
|
|
24
|
+
super(context);
|
|
25
|
+
this.estimator = estimator;
|
|
26
|
+
this.operations = [];
|
|
27
|
+
this.prepare = new prepare_2.PrepareProvider(this.context);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @description Add a transaction operation to the batch
|
|
32
|
+
*
|
|
33
|
+
* @param params Transfer operation parameter
|
|
34
|
+
*/
|
|
35
|
+
withTransfer(params) {
|
|
36
|
+
const toValidation = (0, octez_js_utils_1.validateAddress)(params.to);
|
|
37
|
+
if (params.amount < 0) {
|
|
38
|
+
throw new octez_js_core_1.InvalidAmountError(params.amount.toString());
|
|
39
|
+
}
|
|
40
|
+
if (toValidation !== octez_js_utils_1.ValidationResult.VALID) {
|
|
41
|
+
throw new octez_js_core_1.InvalidAddressError(params.to, toValidation);
|
|
42
|
+
}
|
|
43
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.TRANSACTION }, params));
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @description Transfer tickets from a Tezos address (tz1,tz2 or tz3) to a smart contract address( KT1)
|
|
49
|
+
*
|
|
50
|
+
* @param params Transfer operation parameter
|
|
51
|
+
*/
|
|
52
|
+
withTransferTicket(params) {
|
|
53
|
+
const destinationValidation = (0, octez_js_utils_1.validateAddress)(params.destination);
|
|
54
|
+
if (destinationValidation !== octez_js_utils_1.ValidationResult.VALID) {
|
|
55
|
+
throw new octez_js_core_1.InvalidAddressError(params.destination, destinationValidation);
|
|
56
|
+
}
|
|
57
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.TRANSFER_TICKET }, params));
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @description Add a contract call to the batch
|
|
63
|
+
*
|
|
64
|
+
* @param params Call a contract method
|
|
65
|
+
* @param options Generic operation parameters
|
|
66
|
+
*/
|
|
67
|
+
withContractCall(params, options = {}) {
|
|
68
|
+
return this.withTransfer(params.toTransferParams(options));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @description Add a delegation operation to the batch
|
|
73
|
+
*
|
|
74
|
+
* @param params Delegation operation parameter
|
|
75
|
+
*/
|
|
76
|
+
withDelegation(params) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const sourceValidation = (0, octez_js_utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
79
|
+
if (params.source && sourceValidation !== octez_js_utils_1.ValidationResult.VALID) {
|
|
80
|
+
throw new octez_js_core_1.InvalidAddressError(params.source, sourceValidation);
|
|
81
|
+
}
|
|
82
|
+
const delegateValidation = (0, octez_js_utils_1.validateAddress)((_b = params.delegate) !== null && _b !== void 0 ? _b : '');
|
|
83
|
+
if (params.delegate && delegateValidation !== octez_js_utils_1.ValidationResult.VALID) {
|
|
84
|
+
throw new octez_js_core_1.InvalidAddressError(params.delegate, delegateValidation);
|
|
85
|
+
}
|
|
86
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.DELEGATION }, params));
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @description Add an activation operation to the batch
|
|
92
|
+
*
|
|
93
|
+
* @param params Activation operation parameter
|
|
94
|
+
* @throws {@link InvalidKeyHashError}
|
|
95
|
+
*/
|
|
96
|
+
withActivation({ pkh, secret }) {
|
|
97
|
+
const pkhValidation = (0, octez_js_utils_1.validateKeyHash)(pkh);
|
|
98
|
+
if (pkhValidation !== octez_js_utils_1.ValidationResult.VALID) {
|
|
99
|
+
throw new octez_js_core_1.InvalidKeyHashError(pkh, pkhValidation);
|
|
100
|
+
}
|
|
101
|
+
this.operations.push({ kind: octez_js_rpc_1.OpKind.ACTIVATION, pkh, secret });
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @description Add an origination operation to the batch
|
|
107
|
+
*
|
|
108
|
+
* @param params Origination operation parameter
|
|
109
|
+
*/
|
|
110
|
+
withOrigination(params) {
|
|
111
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.ORIGINATION }, params));
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @description Add a register a global constant operation to the batch
|
|
117
|
+
*
|
|
118
|
+
* @param params RegisterGlobalConstant operation parameter
|
|
119
|
+
*/
|
|
120
|
+
withRegisterGlobalConstant(params) {
|
|
121
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT }, params));
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @description Add an increase paid storage operation to the batch
|
|
127
|
+
*
|
|
128
|
+
* @param params IncreasePaidStorage operation parameter
|
|
129
|
+
*/
|
|
130
|
+
withIncreasePaidStorage(params) {
|
|
131
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.INCREASE_PAID_STORAGE }, params));
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
* @description Add a update consensus key operation to the batch
|
|
137
|
+
*
|
|
138
|
+
* @param params UpdateConsensusKey operation parameter
|
|
139
|
+
*/
|
|
140
|
+
withUpdateConsensusKey(params) {
|
|
141
|
+
const [, pkPrefix] = (0, octez_js_utils_1.b58DecodeAndCheckPrefix)(params.pk, octez_js_utils_1.publicKeyPrefixes);
|
|
142
|
+
if (pkPrefix === octez_js_utils_1.PrefixV2.BLS12_381PublicKey) {
|
|
143
|
+
if (!params.proof) {
|
|
144
|
+
throw new octez_js_core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
if (params.proof) {
|
|
149
|
+
throw new octez_js_core_1.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.UPDATE_CONSENSUS_KEY }, params));
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
* @description Add a update companion key operation to the batch
|
|
158
|
+
*
|
|
159
|
+
* @param params UpdateCompanionKey operation parameter
|
|
160
|
+
*/
|
|
161
|
+
withUpdateCompanionKey(params) {
|
|
162
|
+
const [, pkPrefix] = (0, octez_js_utils_1.b58DecodeAndCheckPrefix)(params.pk, octez_js_utils_1.publicKeyPrefixes);
|
|
163
|
+
if (pkPrefix !== octez_js_utils_1.PrefixV2.BLS12_381PublicKey) {
|
|
164
|
+
throw new octez_js_core_1.ProhibitedActionError('companion key must be a bls account');
|
|
165
|
+
}
|
|
166
|
+
if (!params.proof) {
|
|
167
|
+
throw new octez_js_core_1.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
168
|
+
}
|
|
169
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.UPDATE_COMPANION_KEY }, params));
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
* @description Add a smart rollup add messages operation to the batch
|
|
175
|
+
*
|
|
176
|
+
* @param params Rollup origination operation parameter
|
|
177
|
+
*/
|
|
178
|
+
withSmartRollupAddMessages(params) {
|
|
179
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES }, params));
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
*
|
|
184
|
+
* @description Add a smart rollup originate operation to the batch
|
|
185
|
+
*
|
|
186
|
+
* @param params Smart Rollup Originate operation parameter
|
|
187
|
+
*/
|
|
188
|
+
withSmartRollupOriginate(params) {
|
|
189
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.SMART_ROLLUP_ORIGINATE }, params));
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
*
|
|
194
|
+
* @description Add a smart rollup execute outbox message to the batch
|
|
195
|
+
*
|
|
196
|
+
* @param params Smart Rollup Execute Outbox Message operation parameter
|
|
197
|
+
*/
|
|
198
|
+
withSmartRollupExecuteOutboxMessage(params) {
|
|
199
|
+
this.operations.push(Object.assign({ kind: octez_js_rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE }, params));
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
getRPCOp(param) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
switch (param.kind) {
|
|
205
|
+
case octez_js_rpc_1.OpKind.TRANSACTION:
|
|
206
|
+
return (0, prepare_1.createTransferOperation)(Object.assign({}, param));
|
|
207
|
+
case octez_js_rpc_1.OpKind.ORIGINATION:
|
|
208
|
+
return (0, prepare_1.createOriginationOperation)(yield this.context.parser.prepareCodeOrigination(Object.assign({}, param)));
|
|
209
|
+
case octez_js_rpc_1.OpKind.DELEGATION:
|
|
210
|
+
return (0, prepare_1.createSetDelegateOperation)(Object.assign({}, param));
|
|
211
|
+
case octez_js_rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT:
|
|
212
|
+
return (0, prepare_1.createRegisterGlobalConstantOperation)(Object.assign({}, param));
|
|
213
|
+
case octez_js_rpc_1.OpKind.INCREASE_PAID_STORAGE:
|
|
214
|
+
return (0, prepare_1.createIncreasePaidStorageOperation)(Object.assign({}, param));
|
|
215
|
+
case octez_js_rpc_1.OpKind.UPDATE_CONSENSUS_KEY:
|
|
216
|
+
return (0, prepare_1.createUpdateConsensusKeyOperation)(Object.assign({}, param));
|
|
217
|
+
case octez_js_rpc_1.OpKind.UPDATE_COMPANION_KEY:
|
|
218
|
+
return (0, prepare_1.createUpdateCompanionKeyOperation)(Object.assign({}, param));
|
|
219
|
+
case octez_js_rpc_1.OpKind.TRANSFER_TICKET:
|
|
220
|
+
return (0, prepare_1.createTransferTicketOperation)(Object.assign({}, param));
|
|
221
|
+
case octez_js_rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
222
|
+
return (0, prepare_1.createSmartRollupAddMessagesOperation)(Object.assign({}, param));
|
|
223
|
+
case octez_js_rpc_1.OpKind.SMART_ROLLUP_ORIGINATE:
|
|
224
|
+
return (0, prepare_1.createSmartRollupOriginateOperation)(Object.assign({}, param));
|
|
225
|
+
case octez_js_rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
|
|
226
|
+
return (0, prepare_1.createSmartRollupExecuteOutboxMessageOperation)(Object.assign({}, param));
|
|
227
|
+
default:
|
|
228
|
+
throw new octez_js_core_1.InvalidOperationKindError(JSON.stringify(param.kind));
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* @description Add a group operation to the batch. Operation will be applied in the order they are in the params array
|
|
235
|
+
*
|
|
236
|
+
* @param params Operations parameter
|
|
237
|
+
* @throws {@link InvalidOperationKindError}
|
|
238
|
+
*/
|
|
239
|
+
with(params) {
|
|
240
|
+
for (const param of params) {
|
|
241
|
+
switch (param.kind) {
|
|
242
|
+
case octez_js_rpc_1.OpKind.TRANSACTION:
|
|
243
|
+
this.withTransfer(param);
|
|
244
|
+
break;
|
|
245
|
+
case octez_js_rpc_1.OpKind.ORIGINATION:
|
|
246
|
+
this.withOrigination(param);
|
|
247
|
+
break;
|
|
248
|
+
case octez_js_rpc_1.OpKind.DELEGATION:
|
|
249
|
+
this.withDelegation(param);
|
|
250
|
+
break;
|
|
251
|
+
case octez_js_rpc_1.OpKind.ACTIVATION:
|
|
252
|
+
this.withActivation(param);
|
|
253
|
+
break;
|
|
254
|
+
case octez_js_rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT:
|
|
255
|
+
this.withRegisterGlobalConstant(param);
|
|
256
|
+
break;
|
|
257
|
+
case octez_js_rpc_1.OpKind.INCREASE_PAID_STORAGE:
|
|
258
|
+
this.withIncreasePaidStorage(param);
|
|
259
|
+
break;
|
|
260
|
+
case octez_js_rpc_1.OpKind.TRANSFER_TICKET:
|
|
261
|
+
this.withTransferTicket(param);
|
|
262
|
+
break;
|
|
263
|
+
case octez_js_rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
264
|
+
this.withSmartRollupAddMessages(param);
|
|
265
|
+
break;
|
|
266
|
+
case octez_js_rpc_1.OpKind.SMART_ROLLUP_ORIGINATE:
|
|
267
|
+
this.withSmartRollupOriginate(param);
|
|
268
|
+
break;
|
|
269
|
+
case octez_js_rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
|
|
270
|
+
this.withSmartRollupExecuteOutboxMessage(param);
|
|
271
|
+
break;
|
|
272
|
+
default:
|
|
273
|
+
throw new octez_js_core_1.InvalidOperationKindError(JSON.stringify(param.kind));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
*
|
|
280
|
+
* @description Forge and Inject the operation batch
|
|
281
|
+
*
|
|
282
|
+
* @param params Optionally specify the source of the operation
|
|
283
|
+
*/
|
|
284
|
+
send(params) {
|
|
285
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
287
|
+
const source = (params && params.source) || publicKeyHash;
|
|
288
|
+
const estimates = yield this.estimator.batch(this.operations);
|
|
289
|
+
if (estimates.length !== this.operations.length) {
|
|
290
|
+
estimates.shift();
|
|
291
|
+
}
|
|
292
|
+
const preparedOp = yield this.prepare.batch(this.operations, estimates);
|
|
293
|
+
const opBytes = yield this.forge(preparedOp);
|
|
294
|
+
const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
|
|
295
|
+
return new batch_operation_1.BatchOperation(hash, preparedOp.opOb.contents, source, forgedBytes, opResponse, context);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
exports.OperationBatch = OperationBatch;
|
|
300
|
+
class RPCBatchProvider {
|
|
301
|
+
constructor(context, estimator) {
|
|
302
|
+
this.context = context;
|
|
303
|
+
this.estimator = estimator;
|
|
304
|
+
}
|
|
305
|
+
/***
|
|
306
|
+
*
|
|
307
|
+
* @description Batch a group of operation together. Operations will be applied in the order in which they are added to the batch
|
|
308
|
+
*
|
|
309
|
+
* @param params List of operation to batch together
|
|
310
|
+
*/
|
|
311
|
+
batch(params) {
|
|
312
|
+
const batch = new OperationBatch(this.context, this.estimator);
|
|
313
|
+
if (Array.isArray(params)) {
|
|
314
|
+
batch.with(params);
|
|
315
|
+
}
|
|
316
|
+
return batch;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
exports.RPCBatchProvider = RPCBatchProvider;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRevealFeeInternal = exports.getRevealFee = exports.getRevealGasLimit = exports.ChainIds = exports.protocols = exports.Protocols = exports.COST_PER_BYTE = exports.ORIGINATION_SIZE = exports.REVEAL_STORAGE_LIMIT = void 0;
|
|
4
|
+
// value is based on octez-client reveal operation gasLimit of each address type in Tallinn Protocol
|
|
5
|
+
const REVEAL_GAS_LIMIT = {
|
|
6
|
+
TZ1: 171,
|
|
7
|
+
TZ2: 157,
|
|
8
|
+
TZ3: 447,
|
|
9
|
+
TZ4: 3252,
|
|
10
|
+
};
|
|
11
|
+
// value is based on octez-client reveal operation fee of each address type in Tallinn Protocol
|
|
12
|
+
const REVEAL_FEE = {
|
|
13
|
+
TZ1: 278,
|
|
14
|
+
TZ2: 277,
|
|
15
|
+
TZ3: 306,
|
|
16
|
+
TZ4: 736,
|
|
17
|
+
};
|
|
18
|
+
// value is based on octez-client reveal operation storageLimit of all address type in Tallinn Protocol
|
|
19
|
+
exports.REVEAL_STORAGE_LIMIT = 0;
|
|
20
|
+
// protocol constants in Tallinn Protocol
|
|
21
|
+
exports.ORIGINATION_SIZE = 257;
|
|
22
|
+
// protocol constants in Tallinn Protocol
|
|
23
|
+
exports.COST_PER_BYTE = 250;
|
|
24
|
+
var Protocols;
|
|
25
|
+
(function (Protocols) {
|
|
26
|
+
Protocols["Pt24m4xi"] = "Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd";
|
|
27
|
+
Protocols["PsBABY5H"] = "PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU";
|
|
28
|
+
Protocols["PsBabyM1"] = "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS";
|
|
29
|
+
Protocols["PsCARTHA"] = "PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb";
|
|
30
|
+
Protocols["PsDELPH1"] = "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo";
|
|
31
|
+
Protocols["PtEdo2Zk"] = "PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA";
|
|
32
|
+
Protocols["PsFLorena"] = "PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i";
|
|
33
|
+
Protocols["PtGRANADs"] = "PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV";
|
|
34
|
+
Protocols["PtHangz2"] = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx";
|
|
35
|
+
Protocols["PsiThaCa"] = "PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP";
|
|
36
|
+
Protocols["Psithaca2"] = "Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A";
|
|
37
|
+
Protocols["PtJakart2"] = "PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY";
|
|
38
|
+
Protocols["PtKathman"] = "PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg";
|
|
39
|
+
Protocols["PtLimaPtL"] = "PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW";
|
|
40
|
+
Protocols["PtMumbaii"] = "PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc";
|
|
41
|
+
Protocols["PtMumbai2"] = "PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1";
|
|
42
|
+
Protocols["PtNairobi"] = "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf";
|
|
43
|
+
Protocols["ProxfordY"] = "ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH";
|
|
44
|
+
Protocols["PtParisBx"] = "PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ";
|
|
45
|
+
Protocols["PsParisCZ"] = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi";
|
|
46
|
+
Protocols["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
|
|
47
|
+
Protocols["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
|
|
48
|
+
Protocols["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
|
|
49
|
+
Protocols["PtTALLiNt"] = "PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu";
|
|
50
|
+
Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
|
|
51
|
+
})(Protocols || (exports.Protocols = Protocols = {}));
|
|
52
|
+
exports.protocols = {
|
|
53
|
+
'004': [Protocols.Pt24m4xi],
|
|
54
|
+
'005': [Protocols.PsBABY5H, Protocols.PsBabyM1],
|
|
55
|
+
'006': [Protocols.PsCARTHA],
|
|
56
|
+
'007': [Protocols.PsDELPH1],
|
|
57
|
+
'008': [Protocols.PtEdo2Zk], // edonet v2
|
|
58
|
+
'009': [Protocols.PsFLorena],
|
|
59
|
+
'010': [Protocols.PtGRANADs],
|
|
60
|
+
'011': [Protocols.PtHangz2], // hangzhou v2,
|
|
61
|
+
'012': [Protocols.PsiThaCa, Protocols.Psithaca2],
|
|
62
|
+
'013': [Protocols.PtJakart2],
|
|
63
|
+
'014': [Protocols.PtKathman],
|
|
64
|
+
'015': [Protocols.PtLimaPtL],
|
|
65
|
+
'016': [Protocols.PtMumbai2], // mumbai v2
|
|
66
|
+
'017': [Protocols.PtNairobi],
|
|
67
|
+
'019': [Protocols.ProxfordY],
|
|
68
|
+
'020': [Protocols.PtParisBx, Protocols.PsParisCZ],
|
|
69
|
+
'021': [Protocols.PsQuebecn],
|
|
70
|
+
'022': [Protocols.PsRiotuma],
|
|
71
|
+
'023': [Protocols.PtSeouLou],
|
|
72
|
+
'024': [Protocols.PtTALLiNt],
|
|
73
|
+
'025': [Protocols.ProtoALpha],
|
|
74
|
+
};
|
|
75
|
+
var ChainIds;
|
|
76
|
+
(function (ChainIds) {
|
|
77
|
+
ChainIds["MAINNET"] = "NetXdQprcVkpaWU";
|
|
78
|
+
ChainIds["GHOSTNET"] = "NetXnHfVqm9iesp";
|
|
79
|
+
ChainIds["SHADOWNET"] = "NetXsqzbfFenSTS";
|
|
80
|
+
ChainIds["CARTHAGENET"] = "NetXjD3HPJJjmcd";
|
|
81
|
+
ChainIds["DELPHINET"] = "NetXm8tYqnMWky1";
|
|
82
|
+
ChainIds["EDONET"] = "NetXSgo1ZT2DRUG";
|
|
83
|
+
ChainIds["FLORENCENET"] = "NetXxkAx4woPLyu";
|
|
84
|
+
ChainIds["GRANADANET"] = "NetXz969SFaFn8k";
|
|
85
|
+
ChainIds["HANGZHOUNET"] = "NetXZSsxBpMQeAT";
|
|
86
|
+
ChainIds["ITHACANET"] = "NetXbhmtAbMukLc";
|
|
87
|
+
ChainIds["JAKARTANET2"] = "NetXLH1uAxK7CCh";
|
|
88
|
+
ChainIds["KATHMANDUNET"] = "NetXazhm4yetmff";
|
|
89
|
+
ChainIds["LIMANET"] = "NetXizpkH94bocH";
|
|
90
|
+
ChainIds["MUMBAINET"] = "NetXQw6nWSnrJ5t";
|
|
91
|
+
ChainIds["MUMBAINET2"] = "NetXgbcrNtXD2yA";
|
|
92
|
+
ChainIds["NAIROBINET"] = "NetXyuzvDo2Ugzb";
|
|
93
|
+
ChainIds["OXFORDNET2"] = "NetXxWsskGahzQB";
|
|
94
|
+
ChainIds["PARISBNET"] = "NetXo8SqH1c38SS";
|
|
95
|
+
ChainIds["PARISCNET"] = "NetXXWAHLEvre9b";
|
|
96
|
+
ChainIds["QUEBECNET"] = "NetXuTeGinLEqxp";
|
|
97
|
+
ChainIds["RIONET"] = "NetXPdgaoabtBth";
|
|
98
|
+
ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
|
|
99
|
+
ChainIds["TALLINNNET"] = "NetXe8DbhW9A1eS";
|
|
100
|
+
})(ChainIds || (exports.ChainIds = ChainIds = {}));
|
|
101
|
+
const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
|
|
102
|
+
exports.getRevealGasLimit = getRevealGasLimit;
|
|
103
|
+
const getRevealGasLimitInternal = (address) => {
|
|
104
|
+
switch (address.substring(0, 3)) {
|
|
105
|
+
case 'tz1':
|
|
106
|
+
return REVEAL_GAS_LIMIT.TZ1;
|
|
107
|
+
case 'tz2':
|
|
108
|
+
return REVEAL_GAS_LIMIT.TZ2;
|
|
109
|
+
case 'tz3':
|
|
110
|
+
return REVEAL_GAS_LIMIT.TZ3;
|
|
111
|
+
case 'tz4':
|
|
112
|
+
return REVEAL_GAS_LIMIT.TZ4;
|
|
113
|
+
default:
|
|
114
|
+
throw new Error(`Cannot estimate reveal gas limit for ${address}`);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const getRevealFee = (address) => Math.round(((0, exports.getRevealFeeInternal)(address) * 12) / 10);
|
|
118
|
+
exports.getRevealFee = getRevealFee;
|
|
119
|
+
const getRevealFeeInternal = (address) => {
|
|
120
|
+
switch (address.substring(0, 3)) {
|
|
121
|
+
case 'tz1':
|
|
122
|
+
return REVEAL_FEE.TZ1;
|
|
123
|
+
case 'tz2':
|
|
124
|
+
return REVEAL_FEE.TZ2;
|
|
125
|
+
case 'tz3':
|
|
126
|
+
return REVEAL_FEE.TZ3;
|
|
127
|
+
case 'tz4':
|
|
128
|
+
return REVEAL_FEE.TZ4 * 1.7;
|
|
129
|
+
default:
|
|
130
|
+
throw new Error(`Cannot estimate reveal fee for ${address}`);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
exports.getRevealFeeInternal = getRevealFeeInternal;
|