@wallfree-dev/mina 0.13.42
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/LICENSE.md +7 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +63 -0
- package/readme.md +121 -0
- package/v1/block-explorer/MinaExplorerBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/MinaExplorerBlockExplorer.js +72 -0
- package/v1/block-explorer/MinaExplorerBlockExplorer.js.map +1 -0
- package/v1/index.d.ts +8 -0
- package/v1/index.js +8 -0
- package/v1/index.js.map +1 -0
- package/v1/indexer/MinaExplorerIndexer.d.ts +8 -0
- package/v1/indexer/MinaExplorerIndexer.js +116 -0
- package/v1/indexer/MinaExplorerIndexer.js.map +1 -0
- package/v1/indexer/MinaIndexer.d.ts +5 -0
- package/v1/indexer/MinaIndexer.js +3 -0
- package/v1/indexer/MinaIndexer.js.map +1 -0
- package/v1/module/MinaModule.d.ts +12 -0
- package/v1/module/MinaModule.js +109 -0
- package/v1/module/MinaModule.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/node/GraphQLNode.d.ts +10 -0
- package/v1/node/GraphQLNode.js +115 -0
- package/v1/node/GraphQLNode.js.map +1 -0
- package/v1/node/MinaNode.d.ts +7 -0
- package/v1/node/MinaNode.js +3 -0
- package/v1/node/MinaNode.js.map +1 -0
- package/v1/protocol/MinaProtocol.d.ts +47 -0
- package/v1/protocol/MinaProtocol.js +411 -0
- package/v1/protocol/MinaProtocol.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +37 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-mina.d.ts +4 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-mina.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-mina.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-mina.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-mina.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-mina.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-mina.json +61 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-mina.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +13 -0
- package/v1/serializer/v3/serializer-companion.js +173 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
- package/v1/serializer/v3/validators/transaction-validator.d.ts +7 -0
- package/v1/serializer/v3/validators/transaction-validator.js +90 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/serializer/v3/validators/validators.d.ts +5 -0
- package/v1/serializer/v3/validators/validators.js +118 -0
- package/v1/serializer/v3/validators/validators.js.map +1 -0
- package/v1/types/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.js.map +1 -0
- package/v1/types/indexer.d.ts +12 -0
- package/v1/types/indexer.js +5 -0
- package/v1/types/indexer.js.map +1 -0
- package/v1/types/node.d.ts +4 -0
- package/v1/types/node.js +3 -0
- package/v1/types/node.js.map +1 -0
- package/v1/types/protocol.d.ts +10 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +32 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/key.d.ts +5 -0
- package/v1/utils/key.js +40 -0
- package/v1/utils/key.js.map +1 -0
- package/v1/utils/math.d.ts +5 -0
- package/v1/utils/math.js +24 -0
- package/v1/utils/math.js.map +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2019 Papers AG
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './v1';
|
package/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./v1"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAoB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wallfree-dev/mina",
|
|
3
|
+
"version": "0.13.42",
|
|
4
|
+
"description": "The @wallfree-dev/mina is a Mina implementation of the ICoinProtocol interface from @wallfree-dev/coinlib-core.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"airgap",
|
|
7
|
+
"blockchain",
|
|
8
|
+
"crypto",
|
|
9
|
+
"mina"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://www.airgap.it",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/airgap-it/airgap-coin-lib"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rm -rf ./dist && tsc && node scripts/copy-files-after-build.js",
|
|
22
|
+
"build-scripts": "tsc scripts/copy-files-after-build.ts",
|
|
23
|
+
"lint": "tslint -c ./tslint.json --project ./tsconfig.json --format stylish --fix",
|
|
24
|
+
"lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
25
|
+
"lint-ci": "tslint -t json -o ../../lint-reports/mina.json --project . || true",
|
|
26
|
+
"lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
|
|
27
|
+
"test": "TS_NODE_PROJECT='./test/tsconfig.json' nyc mocha --bail --require ts-node/register --require tsconfig-paths/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
|
|
28
|
+
"test-ci": "nyc --reporter=lcov pnpm test",
|
|
29
|
+
"browserify": "browserify ./dist/index.js -s airgapCoinLibMina > ./dist/airgap-coinlib-mina.min.js"
|
|
30
|
+
},
|
|
31
|
+
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@wallfree-dev/coinlib-core": "^0.13.42",
|
|
34
|
+
"@wallfree-dev/crypto": "^0.13.42",
|
|
35
|
+
"@wallfree-dev/module-kit": "^0.13.42",
|
|
36
|
+
"@wallfree-dev/serializer": "^0.13.42",
|
|
37
|
+
"graphql": "^16.7.1",
|
|
38
|
+
"graphql-request": "^6.1.0",
|
|
39
|
+
"mina-signer": "^2.0.3"
|
|
40
|
+
},
|
|
41
|
+
"nyc": {
|
|
42
|
+
"include": [
|
|
43
|
+
"src/**/*.ts"
|
|
44
|
+
],
|
|
45
|
+
"exclude": [
|
|
46
|
+
"test/**/*.spec.ts"
|
|
47
|
+
],
|
|
48
|
+
"extension": [
|
|
49
|
+
".ts"
|
|
50
|
+
],
|
|
51
|
+
"require": [
|
|
52
|
+
"ts-node/register"
|
|
53
|
+
],
|
|
54
|
+
"reporter": [
|
|
55
|
+
"text",
|
|
56
|
+
"text-summary"
|
|
57
|
+
],
|
|
58
|
+
"report-dir": "../../coverage/mina",
|
|
59
|
+
"sourceMap": true,
|
|
60
|
+
"instrument": true
|
|
61
|
+
},
|
|
62
|
+
"gitHead": "8e8feb6788204501b7173aa825f5456c2a5f185b"
|
|
63
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# AirGap Coin Library
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/airgap-coin-lib)
|
|
4
|
+
[](https://airgap-it.github.io/airgap-coin-lib/)
|
|
5
|
+
[](https://travis-ci.org/airgap-it/airgap-coin-lib/)
|
|
6
|
+
[](https://codecov.io/gh/airgap-it/airgap-coin-lib/)
|
|
7
|
+
|
|
8
|
+
The `airgap-coin-lib` is a protocol-agnostic library that allows easy handling of the most important tasks relating cryptocurrencies and blockchains.
|
|
9
|
+
|
|
10
|
+
It implements operations such as preparing, signing and broadcasting transactions for a range of protocols.
|
|
11
|
+
|
|
12
|
+
The library consists of a shared interface for all implemented protocols. This is especially useful in the context of AirGap because methods are designed to support offline key management and signing. The following core operations are specified:
|
|
13
|
+
|
|
14
|
+
- `prepareTransaction` - This is done on AirGap Wallet (online) side. Either a public key or extended public key is used and will fetch the required information from the network.
|
|
15
|
+
- `signTransaction` - This is done in AirGap Vault (offline) side. The output of "prepareTransaction" is the input for this method (hence the output of "prepareTransaction" is transferred via URL scheme (same-device) or QR code (2-device-setup)).
|
|
16
|
+
- `broadcastTransaction` - This is done in AirGap Wallet (online) side. The output of "signTransaction" is the input for this method (hence the output of "signTransaction" is transferred via URL scheme (same-device) or QR code (2-device-setup)).
|
|
17
|
+
|
|
18
|
+
## Supported Protocols
|
|
19
|
+
|
|
20
|
+
The modular design used in this library allows you to simply add new protocols with special logic. Adding a new Bitcoin-like protocol basically means:
|
|
21
|
+
|
|
22
|
+
1. select the correct network parameters (see `src/networks.ts`)
|
|
23
|
+
2. set the Insight API URL to communicate with the blockchain
|
|
24
|
+
|
|
25
|
+
Adding a new Ethereum-like protocol means:
|
|
26
|
+
|
|
27
|
+
1. set the correct chain id
|
|
28
|
+
2. set the JSON RPC URL
|
|
29
|
+
|
|
30
|
+
Currently supported are:
|
|
31
|
+
|
|
32
|
+
- Bitcoin
|
|
33
|
+
- Ethereum
|
|
34
|
+
- Generic ERC20 Tokens
|
|
35
|
+
- Aeternity
|
|
36
|
+
- Tezos
|
|
37
|
+
- FA1.2 tokens
|
|
38
|
+
- tzBTC
|
|
39
|
+
- USDtz
|
|
40
|
+
- FA2 tokens
|
|
41
|
+
- Groestlcoin
|
|
42
|
+
- Cosmos
|
|
43
|
+
- Polkadot
|
|
44
|
+
- Kusama
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
### Protocols
|
|
49
|
+
|
|
50
|
+
The way the interface was designed is to allow stateless calls. This means the class stores very little state itself.
|
|
51
|
+
All required input comes from the method params (public key, extended public key, etc...)
|
|
52
|
+
|
|
53
|
+
Currently we support for Bitcoin-like (UTXO) protocols:
|
|
54
|
+
|
|
55
|
+
- Single Address Wallets (deprecated)
|
|
56
|
+
- HD Wallets
|
|
57
|
+
|
|
58
|
+
Currently we support for Ethereum-like (Account-based) protocols:
|
|
59
|
+
|
|
60
|
+
- Single Address Wallets
|
|
61
|
+
|
|
62
|
+
### Delegation
|
|
63
|
+
|
|
64
|
+
There is a different interface that can be implemented if the protocol supports delegation. The delegation flow usually requires some changes in the user interface of the AirGap Wallet as well.
|
|
65
|
+
|
|
66
|
+
### Inter App Communication
|
|
67
|
+
|
|
68
|
+
A serializer is included that encodes JSON structures with RLP and base58check. Those strings can then be sent to the other app, either through QR codes or a URL. The serializer can only serialize messages in predefined formats, so new message types have to be added when new protocols are added.
|
|
69
|
+
|
|
70
|
+
### Tezos FA1.2 and FA2 tokens
|
|
71
|
+
|
|
72
|
+
It is possible to interact (fetch balances, create transfers, etc.) with an FA1.2 and FA2 smart contracts using the `TezosFA12Protocol` and `TezosFA2Protocol` classes. An example on how to use them can be found in `examples/custom/protocols/tezos/fa2-smart-contract.ts`.
|
|
73
|
+
|
|
74
|
+
## Synchronising information between wallet and vault
|
|
75
|
+
|
|
76
|
+
Such that the system works we need to be able to synchronise wallets. A wallet can be:
|
|
77
|
+
|
|
78
|
+
- Single Address Wallet
|
|
79
|
+
- HD Wallet
|
|
80
|
+
|
|
81
|
+
For the single address wallet we only need to share the public key. For HD Wallet we need to share the extended public key.
|
|
82
|
+
|
|
83
|
+
## Getting started
|
|
84
|
+
|
|
85
|
+
### Requirements
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
npm >= 6
|
|
89
|
+
NodeJS >= 12
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Build dependencies get installed using `npm install`.
|
|
93
|
+
|
|
94
|
+
### Clone and Run
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
$ git clone https://github.com/airgap-it/airgap-coin-lib.git
|
|
98
|
+
$ cd airgap-coin-lib
|
|
99
|
+
$ npm install
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
To run the tests, you will have to install the test dependencies
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
$ npm run install-test-dependencies
|
|
106
|
+
$ npm test
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
To remove the test dependencies and clean up the `package.json` and `package-lock.json`, execute this command
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
$ npm run install-build-dependencies
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Contributing
|
|
116
|
+
|
|
117
|
+
We welcome contributions from the community. Simple readme updates or bugfixes can be addressed with a PR directly.
|
|
118
|
+
|
|
119
|
+
For larger changes like new protocols, new features or larger refactorings, please contact us first by opening an issue. This project is under constant development and until version `1.x.x` has been reached, there will be frequent breaking changes. So make sure to take a look at the `develop` branch.
|
|
120
|
+
|
|
121
|
+
Regarding new protocols / currencies, we cannot guarantee that they will be merged, but we're more than happy to discuss the details of a specific integration in a github issue.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AirGapBlockExplorer, BlockExplorerMetadata } from '@wallfree-dev/module-kit';
|
|
2
|
+
export declare class MinaExplorerBlockExplorer implements AirGapBlockExplorer {
|
|
3
|
+
private readonly url;
|
|
4
|
+
constructor(url: string);
|
|
5
|
+
private readonly metadata;
|
|
6
|
+
getMetadata(): Promise<BlockExplorerMetadata>;
|
|
7
|
+
createAddressUrl(address: string): Promise<string>;
|
|
8
|
+
createTransactionUrl(transactionId: string): Promise<string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.MinaExplorerBlockExplorer = void 0;
|
|
40
|
+
var MinaExplorerBlockExplorer = /** @class */ (function () {
|
|
41
|
+
function MinaExplorerBlockExplorer(url) {
|
|
42
|
+
this.url = url;
|
|
43
|
+
this.metadata = {
|
|
44
|
+
name: 'Mina Explorer',
|
|
45
|
+
url: this.url
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
MinaExplorerBlockExplorer.prototype.getMetadata = function () {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
return [2 /*return*/, this.metadata];
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
MinaExplorerBlockExplorer.prototype.createAddressUrl = function (address) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
return [2 /*return*/, "".concat(this.url, "/wallet/").concat(address)];
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
MinaExplorerBlockExplorer.prototype.createTransactionUrl = function (transactionId) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
return [2 /*return*/, "".concat(this.url, "/transaction/").concat(transactionId)];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
return MinaExplorerBlockExplorer;
|
|
70
|
+
}());
|
|
71
|
+
exports.MinaExplorerBlockExplorer = MinaExplorerBlockExplorer;
|
|
72
|
+
//# sourceMappingURL=MinaExplorerBlockExplorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinaExplorerBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/MinaExplorerBlockExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IACE,mCAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAE9B,aAAQ,GAA0B;YACjD,IAAI,EAAE,eAAe;YACrB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IALiD,CAAC;IAMtC,+CAAW,GAAxB;;;gBACE,sBAAO,IAAI,CAAC,QAAQ,EAAA;;;KACrB;IAEY,oDAAgB,GAA7B,UAA8B,OAAe;;;gBAC3C,sBAAO,UAAG,IAAI,CAAC,GAAG,qBAAW,OAAO,CAAE,EAAA;;;KACvC;IAEY,wDAAoB,GAAjC,UAAkC,aAAqB;;;gBACrD,sBAAO,UAAG,IAAI,CAAC,GAAG,0BAAgB,aAAa,CAAE,EAAA;;;KAClD;IACH,gCAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,8DAAyB"}
|
package/v1/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MinaModule } from './module/MinaModule';
|
|
2
|
+
import { createMinaProtocol, MinaProtocol } from './protocol/MinaProtocol';
|
|
3
|
+
import { MinaCryptoConfiguration } from './types/crypto';
|
|
4
|
+
import { MinaProtocolNetwork, MinaProtocolOptions, MinaUnits } from './types/protocol';
|
|
5
|
+
import { MinaSignedTransaction, MinaTransactionCursor, MinaUnsignedTransaction } from './types/transaction';
|
|
6
|
+
export { MinaModule };
|
|
7
|
+
export { MinaProtocol, createMinaProtocol };
|
|
8
|
+
export { MinaCryptoConfiguration, MinaUnits, MinaProtocolNetwork, MinaProtocolOptions, MinaUnsignedTransaction, MinaSignedTransaction, MinaTransactionCursor };
|
package/v1/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMinaProtocol = exports.MinaModule = void 0;
|
|
4
|
+
var MinaModule_1 = require("./module/MinaModule");
|
|
5
|
+
Object.defineProperty(exports, "MinaModule", { enumerable: true, get: function () { return MinaModule_1.MinaModule; } });
|
|
6
|
+
var MinaProtocol_1 = require("./protocol/MinaProtocol");
|
|
7
|
+
Object.defineProperty(exports, "createMinaProtocol", { enumerable: true, get: function () { return MinaProtocol_1.createMinaProtocol; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/v1/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,kDAAgD;AAQvC,2FARA,uBAAU,OAQA;AAPnB,wDAA0E;AAWnD,mGAXd,iCAAkB,OAWc"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AccountTransaction } from '../types/indexer';
|
|
2
|
+
import { MinaIndexer } from './MinaIndexer';
|
|
3
|
+
export declare class MinaExplorerIndexer implements MinaIndexer {
|
|
4
|
+
private readonly url;
|
|
5
|
+
constructor(url: string);
|
|
6
|
+
getTransactions(publicKey: string, limit: number, dateTimeOffset?: string): Promise<AccountTransaction[]>;
|
|
7
|
+
getLatestFees(blockSpan: number): Promise<string[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
|
+
function step(op) {
|
|
20
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
+
while (_) try {
|
|
22
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
23
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
+
switch (op[0]) {
|
|
25
|
+
case 0: case 1: t = op; break;
|
|
26
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
+
default:
|
|
30
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
+
if (t[2]) _.ops.pop();
|
|
35
|
+
_.trys.pop(); continue;
|
|
36
|
+
}
|
|
37
|
+
op = body.call(thisArg, _);
|
|
38
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.MinaExplorerIndexer = void 0;
|
|
44
|
+
var graphql_request_1 = require("graphql-request");
|
|
45
|
+
var EMPTY_MEMO = 'E4YM2vTHhWEg66xpj52JErHUBU4pZ1yageL4TVDDpTTSsv8mK6YaH';
|
|
46
|
+
var MinaExplorerIndexer = /** @class */ (function () {
|
|
47
|
+
function MinaExplorerIndexer(url) {
|
|
48
|
+
this.url = url;
|
|
49
|
+
}
|
|
50
|
+
MinaExplorerIndexer.prototype.getTransactions = function (publicKey, limit, dateTimeOffset) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var query, response;
|
|
54
|
+
return __generator(this, function (_c) {
|
|
55
|
+
switch (_c.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
query = (0, graphql_request_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query GetTransactions($publicKey: String!, $limit: Int!, $dateTimeOffset: DateTime) {\n transactions(\n limit: $limit\n sortBy: DATETIME_DESC\n query: { canonical: true, OR: [{ to: $publicKey }, { from: $publicKey }], dateTime_lt: $dateTimeOffset }\n ) {\n to\n from\n amount\n fee\n memo\n hash\n dateTime\n failureReason\n }\n }\n "], ["\n query GetTransactions($publicKey: String!, $limit: Int!, $dateTimeOffset: DateTime) {\n transactions(\n limit: $limit\n sortBy: DATETIME_DESC\n query: { canonical: true, OR: [{ to: $publicKey }, { from: $publicKey }], dateTime_lt: $dateTimeOffset }\n ) {\n to\n from\n amount\n fee\n memo\n hash\n dateTime\n failureReason\n }\n }\n "])));
|
|
58
|
+
return [4 /*yield*/, (0, graphql_request_1.request)(this.url, query, {
|
|
59
|
+
publicKey: publicKey,
|
|
60
|
+
limit: limit,
|
|
61
|
+
dateTimeOffset: dateTimeOffset !== null && dateTimeOffset !== void 0 ? dateTimeOffset : null
|
|
62
|
+
})];
|
|
63
|
+
case 1:
|
|
64
|
+
response = _c.sent();
|
|
65
|
+
return [2 /*return*/, ((_b = (_a = response.transactions) === null || _a === void 0 ? void 0 : _a.map(function (transaction) {
|
|
66
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
67
|
+
return ({
|
|
68
|
+
to: (_a = transaction.to) !== null && _a !== void 0 ? _a : '',
|
|
69
|
+
from: (_b = transaction.from) !== null && _b !== void 0 ? _b : '',
|
|
70
|
+
amount: (_c = transaction.amount) !== null && _c !== void 0 ? _c : 0,
|
|
71
|
+
fee: (_d = transaction.fee) !== null && _d !== void 0 ? _d : 0,
|
|
72
|
+
memo: transaction.memo && transaction.memo !== EMPTY_MEMO ? transaction.memo : undefined,
|
|
73
|
+
kind: (_e = transaction.kind) !== null && _e !== void 0 ? _e : undefined,
|
|
74
|
+
hash: (_f = transaction.hash) !== null && _f !== void 0 ? _f : undefined,
|
|
75
|
+
dateTime: (_g = transaction.dateTime) !== null && _g !== void 0 ? _g : '',
|
|
76
|
+
failureReason: (_h = transaction.failureReason) !== null && _h !== void 0 ? _h : undefined
|
|
77
|
+
});
|
|
78
|
+
})) !== null && _b !== void 0 ? _b : [])];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
MinaExplorerIndexer.prototype.getLatestFees = function (blockSpan) {
|
|
84
|
+
var _a, _b, _c, _d;
|
|
85
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
+
var blockQuery, blocksResponse, blockHeight, feesQuery, feesResponse;
|
|
87
|
+
return __generator(this, function (_e) {
|
|
88
|
+
switch (_e.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
blockQuery = (0, graphql_request_1.gql)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query GetLatestBlock {\n blocks(limit: 1, sortBy: DATETIME_DESC, query: { canonical: true }) {\n blockHeight\n }\n }\n "], ["\n query GetLatestBlock {\n blocks(limit: 1, sortBy: DATETIME_DESC, query: { canonical: true }) {\n blockHeight\n }\n }\n "])));
|
|
91
|
+
return [4 /*yield*/, (0, graphql_request_1.request)(this.url, blockQuery)];
|
|
92
|
+
case 1:
|
|
93
|
+
blocksResponse = _e.sent();
|
|
94
|
+
blockHeight = (_b = ((_a = blocksResponse === null || blocksResponse === void 0 ? void 0 : blocksResponse.blocks) !== null && _a !== void 0 ? _a : [])[0]) === null || _b === void 0 ? void 0 : _b.blockHeight;
|
|
95
|
+
if (!blockHeight) {
|
|
96
|
+
return [2 /*return*/, []];
|
|
97
|
+
}
|
|
98
|
+
feesQuery = (0, graphql_request_1.gql)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n query GetFees($minBlockHeight: Int) {\n transactions(sortBy: FEE_ASC, query: { canonical: true, blockHeight_gt: $minBlockHeight }) {\n fee\n }\n }\n "], ["\n query GetFees($minBlockHeight: Int) {\n transactions(sortBy: FEE_ASC, query: { canonical: true, blockHeight_gt: $minBlockHeight }) {\n fee\n }\n }\n "])));
|
|
99
|
+
return [4 /*yield*/, (0, graphql_request_1.request)(this.url, feesQuery, {
|
|
100
|
+
minBlockHeight: blockHeight - blockSpan
|
|
101
|
+
})];
|
|
102
|
+
case 2:
|
|
103
|
+
feesResponse = _e.sent();
|
|
104
|
+
return [2 /*return*/, (_d = (_c = feesResponse.transactions) === null || _c === void 0 ? void 0 : _c.map(function (_a) {
|
|
105
|
+
var fee = _a.fee;
|
|
106
|
+
return (fee !== null && fee !== void 0 ? fee : 0).toString();
|
|
107
|
+
})) !== null && _d !== void 0 ? _d : []];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
return MinaExplorerIndexer;
|
|
113
|
+
}());
|
|
114
|
+
exports.MinaExplorerIndexer = MinaExplorerIndexer;
|
|
115
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
116
|
+
//# sourceMappingURL=MinaExplorerIndexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinaExplorerIndexer.js","sourceRoot":"","sources":["../../../src/v1/indexer/MinaExplorerIndexer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA8C;AAsB9C,IAAM,UAAU,GAAW,uDAAuD,CAAA;AAElF;IACE,6BAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAEtC,6CAAe,GAA5B,UAA6B,SAAiB,EAAE,KAAa,EAAE,cAAuB;;;;;;;wBAC9E,KAAK,OAAG,qBAAG,2hBAAA,udAiBhB,IAAA,CAAA;wBAEyC,qBAAM,IAAA,yBAAO,EAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE;gCACvE,SAAS,WAAA;gCACT,KAAK,OAAA;gCACL,cAAc,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,IAAI;6BACvC,CAAC,EAAA;;wBAJI,QAAQ,GAA4B,SAIxC;wBAEF,sBAAO,CACL,MAAA,MAAA,QAAQ,CAAC,YAAY,0CAAE,GAAG,CAAC,UAAC,WAAwC;;gCAAK,OAAA,CAAC;oCACxE,EAAE,EAAE,MAAA,WAAW,CAAC,EAAE,mCAAI,EAAE;oCACxB,IAAI,EAAE,MAAA,WAAW,CAAC,IAAI,mCAAI,EAAE;oCAC5B,MAAM,EAAE,MAAA,WAAW,CAAC,MAAM,mCAAI,CAAC;oCAC/B,GAAG,EAAE,MAAA,WAAW,CAAC,GAAG,mCAAI,CAAC;oCACzB,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;oCACxF,IAAI,EAAE,MAAA,WAAW,CAAC,IAAI,mCAAI,SAAS;oCACnC,IAAI,EAAE,MAAA,WAAW,CAAC,IAAI,mCAAI,SAAS;oCACnC,QAAQ,EAAE,MAAA,WAAW,CAAC,QAAQ,mCAAI,EAAE;oCACpC,aAAa,EAAE,MAAA,WAAW,CAAC,aAAa,mCAAI,SAAS;iCACtD,CAAC,CAAA;6BAAA,CAAC,mCAAI,EAAE,CACV,EAAA;;;;KACF;IAEY,2CAAa,GAA1B,UAA2B,SAAiB;;;;;;;wBACpC,UAAU,OAAG,qBAAG,oOAAA,gKAMrB,IAAA,CAAA;wBAEyC,qBAAM,IAAA,yBAAO,EAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,EAAA;;wBAAvE,cAAc,GAAsB,SAAmC;wBACvE,WAAW,GAAG,MAAA,CAAC,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,mCAAI,EAAE,CAAC,CAAC,CAAC,CAAC,0CAAE,WAAW,CAAA;wBAClE,IAAI,CAAC,WAAW,EAAE;4BAChB,sBAAO,EAAE,EAAA;yBACV;wBAEK,SAAS,OAAG,qBAAG,kQAAA,8LAMpB,IAAA,CAAA;wBAEqC,qBAAM,IAAA,yBAAO,EAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE;gCACvE,cAAc,EAAE,WAAW,GAAG,SAAS;6BACxC,CAAC,EAAA;;wBAFI,YAAY,GAAoB,SAEpC;wBAEF,sBAAO,MAAA,MAAA,YAAY,CAAC,YAAY,0CAAE,GAAG,CAAC,UAAC,EAAO;oCAAL,GAAG,SAAA;gCAAO,OAAA,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,CAAC,CAAC,CAAC,QAAQ,EAAE;4BAArB,CAAqB,CAAC,mCAAI,EAAE,EAAA;;;;KAChF;IACH,0BAAC;AAAD,CAAC,AAzED,IAyEC;AAzEY,kDAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinaIndexer.js","sourceRoot":"","sources":["../../../src/v1/indexer/MinaIndexer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, AirGapV3SerializerCompanion, ProtocolConfiguration } from '@wallfree-dev/module-kit';
|
|
2
|
+
import { MinaProtocolNetwork } from '../types/protocol';
|
|
3
|
+
export declare class MinaModule implements AirGapModule {
|
|
4
|
+
private readonly networkRegistries;
|
|
5
|
+
readonly supportedProtocols: Record<string, ProtocolConfiguration>;
|
|
6
|
+
constructor();
|
|
7
|
+
createOfflineProtocol(identifier: string): Promise<AirGapOfflineProtocol | undefined>;
|
|
8
|
+
createOnlineProtocol(identifier: string, networkOrId?: MinaProtocolNetwork | string): Promise<AirGapOnlineProtocol | undefined>;
|
|
9
|
+
createBlockExplorer(identifier: string, networkOrId?: MinaProtocolNetwork | string): Promise<AirGapBlockExplorer | undefined>;
|
|
10
|
+
createV3SerializerCompanion(): Promise<AirGapV3SerializerCompanion>;
|
|
11
|
+
private createProtocol;
|
|
12
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.MinaModule = void 0;
|
|
40
|
+
var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
|
|
41
|
+
var errors_1 = require("@wallfree-dev/coinlib-core/errors");
|
|
42
|
+
var module_kit_1 = require("@wallfree-dev/module-kit");
|
|
43
|
+
var MinaExplorerBlockExplorer_1 = require("../block-explorer/MinaExplorerBlockExplorer");
|
|
44
|
+
var module_1 = require("../module");
|
|
45
|
+
var MinaProtocol_1 = require("../protocol/MinaProtocol");
|
|
46
|
+
var serializer_companion_1 = require("../serializer/v3/serializer-companion");
|
|
47
|
+
var MinaModule = /** @class */ (function () {
|
|
48
|
+
function MinaModule() {
|
|
49
|
+
var _a;
|
|
50
|
+
var networkRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
51
|
+
supportedNetworks: [MinaProtocol_1.MINA_MAINNET_PROTOCOL_NETWORK]
|
|
52
|
+
});
|
|
53
|
+
this.networkRegistries = (_a = {},
|
|
54
|
+
_a[coinlib_core_1.MainProtocolSymbols.MINA] = networkRegistry,
|
|
55
|
+
_a);
|
|
56
|
+
this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
|
|
57
|
+
}
|
|
58
|
+
MinaModule.prototype.createOfflineProtocol = function (identifier) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
return [2 /*return*/, this.createProtocol(identifier)];
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
MinaModule.prototype.createOnlineProtocol = function (identifier, networkOrId) {
|
|
66
|
+
var _a;
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var network;
|
|
69
|
+
return __generator(this, function (_b) {
|
|
70
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
71
|
+
if (network === undefined) {
|
|
72
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.MINA, 'Protocol network type not supported.');
|
|
73
|
+
}
|
|
74
|
+
return [2 /*return*/, this.createProtocol(identifier, network)];
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
MinaModule.prototype.createBlockExplorer = function (identifier, networkOrId) {
|
|
79
|
+
var _a;
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
var network;
|
|
82
|
+
return __generator(this, function (_b) {
|
|
83
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
84
|
+
if (network === undefined) {
|
|
85
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.MINA, 'Block Explorer network type not supported.');
|
|
86
|
+
}
|
|
87
|
+
return [2 /*return*/, new MinaExplorerBlockExplorer_1.MinaExplorerBlockExplorer(network.blockExplorerUrl)];
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
MinaModule.prototype.createV3SerializerCompanion = function () {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
return [2 /*return*/, new serializer_companion_1.MinaV3SerializerCompanion()];
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
MinaModule.prototype.createProtocol = function (identifier, network) {
|
|
99
|
+
switch (identifier) {
|
|
100
|
+
case coinlib_core_1.MainProtocolSymbols.MINA:
|
|
101
|
+
return (0, module_1.createMinaProtocol)({ network: network });
|
|
102
|
+
default:
|
|
103
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.MINA, "Protocol ".concat(identifier, " not supported."));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return MinaModule;
|
|
107
|
+
}());
|
|
108
|
+
exports.MinaModule = MinaModule;
|
|
109
|
+
//# sourceMappingURL=MinaModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinaModule.js","sourceRoot":"","sources":["../../../src/v1/module/MinaModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAwE;AACxE,4DAA2E;AAC3E,uDAWiC;AAEjC,yFAAuF;AACvF,oCAA8C;AAC9C,yDAAwE;AACxE,8EAAiF;AAGjF;IAIE;;QACE,IAAM,eAAe,GAA0B,IAAI,kCAAqB,CAAC;YACvE,iBAAiB,EAAE,CAAC,4CAA6B,CAAC;SACnD,CAAC,CAAA;QAEF,IAAI,CAAC,iBAAiB;YACpB,GAAC,kCAAmB,CAAC,IAAI,IAAG,eAAe;eAC5C,CAAA;QACD,IAAI,CAAC,kBAAkB,GAAG,IAAA,qCAAwB,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAC5E,CAAC;IAEY,0CAAqB,GAAlC,UAAmC,UAAkB;;;gBACnD,sBAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAA;;;KACvC;IAEY,yCAAoB,GAAjC,UACE,UAAkB,EAClB,WAA0C;;;;;gBAEpC,OAAO,GACX,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,0CAAE,WAAW,CAAC,WAAW,CAAC,CAAA;gBAE9G,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,IAAI,EAAE,sCAAsC,CAAC,CAAA;iBACvF;gBAED,sBAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,EAAA;;;KAChD;IAEY,wCAAmB,GAAhC,UACE,UAAkB,EAClB,WAA0C;;;;;gBAEpC,OAAO,GACX,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,0CAAE,WAAW,CAAC,WAAW,CAAC,CAAA;gBAE9G,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,IAAI,EAAE,4CAA4C,CAAC,CAAA;iBAC7F;gBAED,sBAAO,IAAI,qDAAyB,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAA;;;KAC/D;IAEY,gDAA2B,GAAxC;;;gBACE,sBAAO,IAAI,gDAAyB,EAAE,EAAA;;;KACvC;IAEO,mCAAc,GAAtB,UAAuB,UAAkB,EAAE,OAAyB;QAClE,QAAQ,UAAU,EAAE;YAClB,KAAK,kCAAmB,CAAC,IAAI;gBAC3B,OAAO,IAAA,2BAAkB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAA;YACxC;gBACE,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,IAAI,EAAE,mBAAY,UAAU,oBAAiB,CAAC,CAAA;SAC1F;IACH,CAAC;IACH,iBAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DY,gCAAU"}
|
package/v1/module.d.ts
ADDED
package/v1/module.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.create = void 0;
|
|
18
|
+
var MinaModule_1 = require("./module/MinaModule");
|
|
19
|
+
__exportStar(require("./index"), exports);
|
|
20
|
+
function create() {
|
|
21
|
+
return new MinaModule_1.MinaModule();
|
|
22
|
+
}
|
|
23
|
+
exports.create = create;
|
|
24
|
+
//# sourceMappingURL=module.js.map
|