@airgap/mina 0.13.45-beta.1 → 0.13.45-beta.3
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/package.json +5 -5
- package/v1/block-explorer/MinaExplorerBlockExplorer.js +12 -61
- package/v1/block-explorer/MinaExplorerBlockExplorer.js.map +1 -1
- package/v1/index.js +2 -2
- package/v1/index.js.map +1 -1
- package/v1/indexer/MinaExplorerIndexer.js +64 -107
- package/v1/indexer/MinaExplorerIndexer.js.map +1 -1
- package/v1/module/MinaModule.js +38 -96
- package/v1/module/MinaModule.js.map +1 -1
- package/v1/module.js +2 -3
- package/v1/module.js.map +1 -1
- package/v1/node/GraphQLNode.js +70 -107
- package/v1/node/GraphQLNode.js.map +1 -1
- package/v1/protocol/MinaProtocol.js +179 -317
- package/v1/protocol/MinaProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +8 -20
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +69 -148
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +16 -65
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +36 -81
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/protocol.d.ts +2 -2
- package/v1/types/transaction.d.ts +1 -1
- package/v1/utils/key.d.ts +0 -1
- package/v1/utils/key.js +23 -14
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/math.js +7 -11
- package/v1/utils/math.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airgap/mina",
|
|
3
|
-
"version": "0.13.45-beta.
|
|
3
|
+
"version": "0.13.45-beta.3",
|
|
4
4
|
"description": "The @airgap/mina is a Mina implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"airgap",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@airgap/coinlib-core": "^0.13.45-beta.
|
|
34
|
-
"@airgap/crypto": "^0.13.45-beta.
|
|
35
|
-
"@airgap/module-kit": "^0.13.45-beta.
|
|
36
|
-
"@airgap/serializer": "^0.13.45-beta.
|
|
33
|
+
"@airgap/coinlib-core": "^0.13.45-beta.3",
|
|
34
|
+
"@airgap/crypto": "^0.13.45-beta.3",
|
|
35
|
+
"@airgap/module-kit": "^0.13.45-beta.3",
|
|
36
|
+
"@airgap/serializer": "^0.13.45-beta.3",
|
|
37
37
|
"graphql": "^16.7.1",
|
|
38
38
|
"graphql-request": "^6.1.0",
|
|
39
39
|
"mina-signer": "^2.0.3"
|
|
@@ -1,72 +1,23 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.MinaExplorerBlockExplorer = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
class MinaExplorerBlockExplorer {
|
|
5
|
+
constructor(url) {
|
|
42
6
|
this.url = url;
|
|
43
7
|
this.metadata = {
|
|
44
8
|
name: 'Mina Explorer',
|
|
45
9
|
url: this.url
|
|
46
10
|
};
|
|
47
11
|
}
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
}());
|
|
12
|
+
async getMetadata() {
|
|
13
|
+
return this.metadata;
|
|
14
|
+
}
|
|
15
|
+
async createAddressUrl(address) {
|
|
16
|
+
return `${this.url}/wallet/${address}`;
|
|
17
|
+
}
|
|
18
|
+
async createTransactionUrl(transactionId) {
|
|
19
|
+
return `${this.url}/transaction/${transactionId}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
71
22
|
exports.MinaExplorerBlockExplorer = MinaExplorerBlockExplorer;
|
|
72
23
|
//# sourceMappingURL=MinaExplorerBlockExplorer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinaExplorerBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/MinaExplorerBlockExplorer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MinaExplorerBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/MinaExplorerBlockExplorer.ts"],"names":[],"mappings":";;;AAEA,MAAa,yBAAyB;IACpC,YAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAE9B,aAAQ,GAA0B;YACjD,IAAI,EAAE,eAAe;YACrB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IALiD,CAAC;IAM5C,KAAK,CAAC,WAAW;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,OAAe;QAC3C,OAAO,GAAG,IAAI,CAAC,GAAG,WAAW,OAAO,EAAE,CAAA;IACxC,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,aAAqB;QACrD,OAAO,GAAG,IAAI,CAAC,GAAG,gBAAgB,aAAa,EAAE,CAAA;IACnD,CAAC;CACF;AAlBD,8DAkBC"}
|
package/v1/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createMinaProtocol = exports.MinaModule = void 0;
|
|
4
|
-
|
|
4
|
+
const MinaModule_1 = require("./module/MinaModule");
|
|
5
5
|
Object.defineProperty(exports, "MinaModule", { enumerable: true, get: function () { return MinaModule_1.MinaModule; } });
|
|
6
|
-
|
|
6
|
+
const MinaProtocol_1 = require("./protocol/MinaProtocol");
|
|
7
7
|
Object.defineProperty(exports, "createMinaProtocol", { enumerable: true, get: function () { return MinaProtocol_1.createMinaProtocol; } });
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/v1/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAQvC,2FARA,uBAAU,OAQA;AAPnB,0DAA0E;AAWnD,mGAXd,iCAAkB,OAWc"}
|
|
@@ -1,116 +1,73 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
3
|
exports.MinaExplorerIndexer = void 0;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
4
|
+
const graphql_request_1 = require("graphql-request");
|
|
5
|
+
const EMPTY_MEMO = 'E4YM2vTHhWEg66xpj52JErHUBU4pZ1yageL4TVDDpTTSsv8mK6YaH';
|
|
6
|
+
class MinaExplorerIndexer {
|
|
7
|
+
constructor(url) {
|
|
48
8
|
this.url = url;
|
|
49
9
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
});
|
|
10
|
+
async getTransactions(publicKey, limit, dateTimeOffset) {
|
|
11
|
+
const query = (0, graphql_request_1.gql) `
|
|
12
|
+
query GetTransactions($publicKey: String!, $limit: Int!, $dateTimeOffset: DateTime) {
|
|
13
|
+
transactions(
|
|
14
|
+
limit: $limit
|
|
15
|
+
sortBy: DATETIME_DESC
|
|
16
|
+
query: { canonical: true, OR: [{ to: $publicKey }, { from: $publicKey }], dateTime_lt: $dateTimeOffset }
|
|
17
|
+
) {
|
|
18
|
+
to
|
|
19
|
+
from
|
|
20
|
+
amount
|
|
21
|
+
fee
|
|
22
|
+
memo
|
|
23
|
+
hash
|
|
24
|
+
dateTime
|
|
25
|
+
failureReason
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const response = await (0, graphql_request_1.request)(this.url, query, {
|
|
30
|
+
publicKey,
|
|
31
|
+
limit,
|
|
32
|
+
dateTimeOffset: dateTimeOffset ?? null
|
|
81
33
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
34
|
+
return (response.transactions?.map((transaction) => ({
|
|
35
|
+
to: transaction.to ?? '',
|
|
36
|
+
from: transaction.from ?? '',
|
|
37
|
+
amount: transaction.amount ?? 0,
|
|
38
|
+
fee: transaction.fee ?? 0,
|
|
39
|
+
memo: transaction.memo && transaction.memo !== EMPTY_MEMO ? transaction.memo : undefined,
|
|
40
|
+
kind: transaction.kind ?? undefined,
|
|
41
|
+
hash: transaction.hash ?? undefined,
|
|
42
|
+
dateTime: transaction.dateTime ?? '',
|
|
43
|
+
failureReason: transaction.failureReason ?? undefined
|
|
44
|
+
})) ?? []);
|
|
45
|
+
}
|
|
46
|
+
async getLatestFees(blockSpan) {
|
|
47
|
+
const blockQuery = (0, graphql_request_1.gql) `
|
|
48
|
+
query GetLatestBlock {
|
|
49
|
+
blocks(limit: 1, sortBy: DATETIME_DESC, query: { canonical: true }) {
|
|
50
|
+
blockHeight
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
const blocksResponse = await (0, graphql_request_1.request)(this.url, blockQuery);
|
|
55
|
+
const blockHeight = (blocksResponse?.blocks ?? [])[0]?.blockHeight;
|
|
56
|
+
if (!blockHeight) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const feesQuery = (0, graphql_request_1.gql) `
|
|
60
|
+
query GetFees($minBlockHeight: Int) {
|
|
61
|
+
transactions(sortBy: FEE_ASC, query: { canonical: true, blockHeight_gt: $minBlockHeight }) {
|
|
62
|
+
fee
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
const feesResponse = await (0, graphql_request_1.request)(this.url, feesQuery, {
|
|
67
|
+
minBlockHeight: blockHeight - blockSpan
|
|
110
68
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
69
|
+
return feesResponse.transactions?.map(({ fee }) => (fee ?? 0).toString()) ?? [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
114
72
|
exports.MinaExplorerIndexer = MinaExplorerIndexer;
|
|
115
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
116
73
|
//# sourceMappingURL=MinaExplorerIndexer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinaExplorerIndexer.js","sourceRoot":"","sources":["../../../src/v1/indexer/MinaExplorerIndexer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MinaExplorerIndexer.js","sourceRoot":"","sources":["../../../src/v1/indexer/MinaExplorerIndexer.ts"],"names":[],"mappings":";;;AAAA,qDAA8C;AAsB9C,MAAM,UAAU,GAAW,uDAAuD,CAAA;AAElF,MAAa,mBAAmB;IAC9B,YAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAE5C,KAAK,CAAC,eAAe,CAAC,SAAiB,EAAE,KAAa,EAAE,cAAuB;QACpF,MAAM,KAAK,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;KAiBhB,CAAA;QAED,MAAM,QAAQ,GAA4B,MAAM,IAAA,yBAAO,EAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE;YACvE,SAAS;YACT,KAAK;YACL,cAAc,EAAE,cAAc,IAAI,IAAI;SACvC,CAAC,CAAA;QAEF,OAAO,CACL,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,WAAwC,EAAE,EAAE,CAAC,CAAC;YACxE,EAAE,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE;YACxB,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,EAAE;YAC5B,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,CAAC;YAC/B,GAAG,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;YACzB,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YACxF,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,SAAS;YACnC,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,SAAS;YACnC,QAAQ,EAAE,WAAW,CAAC,QAAQ,IAAI,EAAE;YACpC,aAAa,EAAE,WAAW,CAAC,aAAa,IAAI,SAAS;SACtD,CAAC,CAAC,IAAI,EAAE,CACV,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,SAAiB;QAC1C,MAAM,UAAU,GAAG,IAAA,qBAAG,EAAA;;;;;;KAMrB,CAAA;QAED,MAAM,cAAc,GAAsB,MAAM,IAAA,yBAAO,EAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAC7E,MAAM,WAAW,GAAG,CAAC,cAAc,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAA;QAClE,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,EAAE,CAAA;QACX,CAAC;QAED,MAAM,SAAS,GAAG,IAAA,qBAAG,EAAA;;;;;;KAMpB,CAAA;QAED,MAAM,YAAY,GAAoB,MAAM,IAAA,yBAAO,EAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE;YACvE,cAAc,EAAE,WAAW,GAAG,SAAS;SACxC,CAAC,CAAA;QAEF,OAAO,YAAY,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAA;IACjF,CAAC;CACF;AAzED,kDAyEC"}
|
package/v1/module/MinaModule.js
CHANGED
|
@@ -1,109 +1,51 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.MinaModule = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var networkRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
4
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
7
|
+
const MinaExplorerBlockExplorer_1 = require("../block-explorer/MinaExplorerBlockExplorer");
|
|
8
|
+
const module_1 = require("../module");
|
|
9
|
+
const MinaProtocol_1 = require("../protocol/MinaProtocol");
|
|
10
|
+
const serializer_companion_1 = require("../serializer/v3/serializer-companion");
|
|
11
|
+
class MinaModule {
|
|
12
|
+
constructor() {
|
|
13
|
+
const networkRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
51
14
|
supportedNetworks: [MinaProtocol_1.MINA_MAINNET_PROTOCOL_NETWORK]
|
|
52
15
|
});
|
|
53
|
-
this.networkRegistries =
|
|
54
|
-
|
|
55
|
-
|
|
16
|
+
this.networkRegistries = {
|
|
17
|
+
[coinlib_core_1.MainProtocolSymbols.MINA]: networkRegistry
|
|
18
|
+
};
|
|
56
19
|
this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
|
|
57
20
|
}
|
|
58
|
-
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
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) {
|
|
21
|
+
async createOfflineProtocol(identifier) {
|
|
22
|
+
return this.createProtocol(identifier);
|
|
23
|
+
}
|
|
24
|
+
async createOnlineProtocol(identifier, networkOrId) {
|
|
25
|
+
const network = typeof networkOrId === 'object' ? networkOrId : this.networkRegistries[identifier]?.findNetwork(networkOrId);
|
|
26
|
+
if (network === undefined) {
|
|
27
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.MINA, 'Protocol network type not supported.');
|
|
28
|
+
}
|
|
29
|
+
return this.createProtocol(identifier, network);
|
|
30
|
+
}
|
|
31
|
+
async createBlockExplorer(identifier, networkOrId) {
|
|
32
|
+
const network = typeof networkOrId === 'object' ? networkOrId : this.networkRegistries[identifier]?.findNetwork(networkOrId);
|
|
33
|
+
if (network === undefined) {
|
|
34
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.MINA, 'Block Explorer network type not supported.');
|
|
35
|
+
}
|
|
36
|
+
return new MinaExplorerBlockExplorer_1.MinaExplorerBlockExplorer(network.blockExplorerUrl);
|
|
37
|
+
}
|
|
38
|
+
async createV3SerializerCompanion() {
|
|
39
|
+
return new serializer_companion_1.MinaV3SerializerCompanion();
|
|
40
|
+
}
|
|
41
|
+
createProtocol(identifier, network) {
|
|
99
42
|
switch (identifier) {
|
|
100
43
|
case coinlib_core_1.MainProtocolSymbols.MINA:
|
|
101
|
-
return (0, module_1.createMinaProtocol)({ network
|
|
44
|
+
return (0, module_1.createMinaProtocol)({ network });
|
|
102
45
|
default:
|
|
103
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.MINA,
|
|
46
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.MINA, `Protocol ${identifier} not supported.`);
|
|
104
47
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
}());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
108
50
|
exports.MinaModule = MinaModule;
|
|
109
51
|
//# sourceMappingURL=MinaModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinaModule.js","sourceRoot":"","sources":["../../../src/v1/module/MinaModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MinaModule.js","sourceRoot":"","sources":["../../../src/v1/module/MinaModule.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAClE,wDAAqE;AACrE,mDAW2B;AAE3B,2FAAuF;AACvF,sCAA8C;AAC9C,2DAAwE;AACxE,gFAAiF;AAGjF,MAAa,UAAU;IAIrB;QACE,MAAM,eAAe,GAA0B,IAAI,kCAAqB,CAAC;YACvE,iBAAiB,EAAE,CAAC,4CAA6B,CAAC;SACnD,CAAC,CAAA;QAEF,IAAI,CAAC,iBAAiB,GAAG;YACvB,CAAC,kCAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;SAC5C,CAAA;QACD,IAAI,CAAC,kBAAkB,GAAG,IAAA,qCAAwB,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAC5E,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,UAAkB;QACnD,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;IACxC,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAC/B,UAAkB,EAClB,WAA0C;QAE1C,MAAM,OAAO,GACX,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAA;QAE9G,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,IAAI,EAAE,sCAAsC,CAAC,CAAA;QACxF,CAAC;QAED,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAC9B,UAAkB,EAClB,WAA0C;QAE1C,MAAM,OAAO,GACX,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAA;QAE9G,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,IAAI,EAAE,4CAA4C,CAAC,CAAA;QAC9F,CAAC;QAED,OAAO,IAAI,qDAAyB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAChE,CAAC;IAEM,KAAK,CAAC,2BAA2B;QACtC,OAAO,IAAI,gDAAyB,EAAE,CAAA;IACxC,CAAC;IAEO,cAAc,CAAC,UAAkB,EAAE,OAAyB;QAClE,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK,kCAAmB,CAAC,IAAI;gBAC3B,OAAO,IAAA,2BAAkB,EAAC,EAAE,OAAO,EAAE,CAAC,CAAA;YACxC;gBACE,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,IAAI,EAAE,YAAY,UAAU,iBAAiB,CAAC,CAAA;QAC3F,CAAC;IACH,CAAC;CACF;AA3DD,gCA2DC"}
|
package/v1/module.js
CHANGED
|
@@ -14,11 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.create =
|
|
18
|
-
|
|
17
|
+
exports.create = create;
|
|
18
|
+
const MinaModule_1 = require("./module/MinaModule");
|
|
19
19
|
__exportStar(require("./index"), exports);
|
|
20
20
|
function create() {
|
|
21
21
|
return new MinaModule_1.MinaModule();
|
|
22
22
|
}
|
|
23
|
-
exports.create = create;
|
|
24
23
|
//# sourceMappingURL=module.js.map
|
package/v1/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKA,wBAEC;AAND,oDAAgD;AAEhD,0CAAuB;AAEvB,SAAgB,MAAM;IACpB,OAAO,IAAI,uBAAU,EAAE,CAAA;AACzB,CAAC"}
|