@airgap/mina 0.13.45-beta.3 → 0.13.45-beta.4
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 +61 -12
- 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 +107 -64
- package/v1/indexer/MinaExplorerIndexer.js.map +1 -1
- package/v1/module/MinaModule.js +96 -38
- package/v1/module/MinaModule.js.map +1 -1
- package/v1/module.js +3 -2
- package/v1/module.js.map +1 -1
- package/v1/node/GraphQLNode.js +107 -70
- package/v1/node/GraphQLNode.js.map +1 -1
- package/v1/protocol/MinaProtocol.js +317 -179
- package/v1/protocol/MinaProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +20 -8
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +148 -69
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +65 -16
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +81 -36
- 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 +1 -0
- package/v1/utils/key.js +14 -23
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/math.js +11 -7
- package/v1/utils/math.js.map +1 -1
package/v1/node/GraphQLNode.js
CHANGED
|
@@ -1,78 +1,115 @@
|
|
|
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
|
+
};
|
|
2
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
43
|
exports.GraphQLNode = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
44
|
+
var graphql_request_1 = require("graphql-request");
|
|
45
|
+
var GraphQLNode = /** @class */ (function () {
|
|
46
|
+
function GraphQLNode(url) {
|
|
7
47
|
this.url = url;
|
|
8
48
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
query AccountBalance($publicKey: PublicKey!) {
|
|
24
|
-
account(publicKey: $publicKey) {
|
|
25
|
-
balance {
|
|
26
|
-
total
|
|
27
|
-
liquid
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
const response = await (0, graphql_request_1.request)(this.url, query, { publicKey });
|
|
33
|
-
return {
|
|
34
|
-
total: response.account?.balance?.total ?? '0',
|
|
35
|
-
liquid: response.account?.balance?.liquid ?? '0'
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
async sendTransaction(payment, signature) {
|
|
39
|
-
const mutation = (0, graphql_request_1.gql) `
|
|
40
|
-
mutation SendTransaction(
|
|
41
|
-
$to: PublicKey!
|
|
42
|
-
$from: PublicKey!
|
|
43
|
-
$amount: UInt64!
|
|
44
|
-
$fee: UInt64!
|
|
45
|
-
$nonce: UInt32!
|
|
46
|
-
$memo: String
|
|
47
|
-
$validUntil: UInt32
|
|
48
|
-
$rawSignature: String
|
|
49
|
-
$field: String
|
|
50
|
-
$scalar: String
|
|
51
|
-
) {
|
|
52
|
-
sendPayment(
|
|
53
|
-
input: { to: $to, from: $from, amount: $amount, fee: $fee, nonce: $nonce, memo: $memo, validUntil: $validUntil }
|
|
54
|
-
signature: { rawSignature: $rawSignature, field: $field, scalar: $scalar }
|
|
55
|
-
) {
|
|
56
|
-
payment {
|
|
57
|
-
hash
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
62
|
-
const response = await (0, graphql_request_1.request)(this.url, mutation, {
|
|
63
|
-
to: payment.to,
|
|
64
|
-
from: payment.from,
|
|
65
|
-
amount: payment.amount,
|
|
66
|
-
fee: payment.fee,
|
|
67
|
-
nonce: payment.nonce,
|
|
68
|
-
memo: payment.memo ?? null,
|
|
69
|
-
validUntil: payment.validUntil ?? null,
|
|
70
|
-
rawSignature: signature.type === 'raw' ? signature.value : null,
|
|
71
|
-
field: signature.type === 'legacy' ? signature.field : null,
|
|
72
|
-
scalar: signature.type === 'legacy' ? signature.scalar : null
|
|
49
|
+
GraphQLNode.prototype.getNonce = function (publicKey) {
|
|
50
|
+
var _a, _b, _c, _d;
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
var query, response;
|
|
53
|
+
return __generator(this, function (_e) {
|
|
54
|
+
switch (_e.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
query = (0, graphql_request_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query AccountNonce($publicKey: PublicKey!) {\n account(publicKey: $publicKey) {\n nonce\n inferredNonce\n }\n }\n "], ["\n query AccountNonce($publicKey: PublicKey!) {\n account(publicKey: $publicKey) {\n nonce\n inferredNonce\n }\n }\n "])));
|
|
57
|
+
return [4 /*yield*/, (0, graphql_request_1.request)(this.url, query, { publicKey: publicKey })];
|
|
58
|
+
case 1:
|
|
59
|
+
response = _e.sent();
|
|
60
|
+
return [2 /*return*/, (_d = (_b = (_a = response.account) === null || _a === void 0 ? void 0 : _a.inferredNonce) !== null && _b !== void 0 ? _b : (_c = response.account) === null || _c === void 0 ? void 0 : _c.nonce) !== null && _d !== void 0 ? _d : '0'];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
73
63
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
};
|
|
65
|
+
GraphQLNode.prototype.getBalance = function (publicKey) {
|
|
66
|
+
var _a, _b, _c, _d, _e, _f;
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var query, response;
|
|
69
|
+
return __generator(this, function (_g) {
|
|
70
|
+
switch (_g.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
query = (0, graphql_request_1.gql)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query AccountBalance($publicKey: PublicKey!) {\n account(publicKey: $publicKey) {\n balance {\n total\n liquid\n }\n }\n }\n "], ["\n query AccountBalance($publicKey: PublicKey!) {\n account(publicKey: $publicKey) {\n balance {\n total\n liquid\n }\n }\n }\n "])));
|
|
73
|
+
return [4 /*yield*/, (0, graphql_request_1.request)(this.url, query, { publicKey: publicKey })];
|
|
74
|
+
case 1:
|
|
75
|
+
response = _g.sent();
|
|
76
|
+
return [2 /*return*/, {
|
|
77
|
+
total: (_c = (_b = (_a = response.account) === null || _a === void 0 ? void 0 : _a.balance) === null || _b === void 0 ? void 0 : _b.total) !== null && _c !== void 0 ? _c : '0',
|
|
78
|
+
liquid: (_f = (_e = (_d = response.account) === null || _d === void 0 ? void 0 : _d.balance) === null || _e === void 0 ? void 0 : _e.liquid) !== null && _f !== void 0 ? _f : '0'
|
|
79
|
+
}];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
GraphQLNode.prototype.sendTransaction = function (payment, signature) {
|
|
85
|
+
var _a, _b, _c, _d, _e;
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var mutation, response;
|
|
88
|
+
return __generator(this, function (_f) {
|
|
89
|
+
switch (_f.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
mutation = (0, graphql_request_1.gql)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n mutation SendTransaction(\n $to: PublicKey!\n $from: PublicKey!\n $amount: UInt64!\n $fee: UInt64!\n $nonce: UInt32!\n $memo: String\n $validUntil: UInt32\n $rawSignature: String\n $field: String\n $scalar: String\n ) {\n sendPayment(\n input: { to: $to, from: $from, amount: $amount, fee: $fee, nonce: $nonce, memo: $memo, validUntil: $validUntil }\n signature: { rawSignature: $rawSignature, field: $field, scalar: $scalar }\n ) {\n payment {\n hash\n }\n }\n }\n "], ["\n mutation SendTransaction(\n $to: PublicKey!\n $from: PublicKey!\n $amount: UInt64!\n $fee: UInt64!\n $nonce: UInt32!\n $memo: String\n $validUntil: UInt32\n $rawSignature: String\n $field: String\n $scalar: String\n ) {\n sendPayment(\n input: { to: $to, from: $from, amount: $amount, fee: $fee, nonce: $nonce, memo: $memo, validUntil: $validUntil }\n signature: { rawSignature: $rawSignature, field: $field, scalar: $scalar }\n ) {\n payment {\n hash\n }\n }\n }\n "])));
|
|
92
|
+
return [4 /*yield*/, (0, graphql_request_1.request)(this.url, mutation, {
|
|
93
|
+
to: payment.to,
|
|
94
|
+
from: payment.from,
|
|
95
|
+
amount: payment.amount,
|
|
96
|
+
fee: payment.fee,
|
|
97
|
+
nonce: payment.nonce,
|
|
98
|
+
memo: (_a = payment.memo) !== null && _a !== void 0 ? _a : null,
|
|
99
|
+
validUntil: (_b = payment.validUntil) !== null && _b !== void 0 ? _b : null,
|
|
100
|
+
rawSignature: signature.type === 'raw' ? signature.value : null,
|
|
101
|
+
field: signature.type === 'legacy' ? signature.field : null,
|
|
102
|
+
scalar: signature.type === 'legacy' ? signature.scalar : null
|
|
103
|
+
})];
|
|
104
|
+
case 1:
|
|
105
|
+
response = _f.sent();
|
|
106
|
+
return [2 /*return*/, (_e = (_d = (_c = response.sendPayment) === null || _c === void 0 ? void 0 : _c.payment) === null || _d === void 0 ? void 0 : _d.hash) !== null && _e !== void 0 ? _e : ''];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return GraphQLNode;
|
|
112
|
+
}());
|
|
77
113
|
exports.GraphQLNode = GraphQLNode;
|
|
114
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
78
115
|
//# sourceMappingURL=GraphQLNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQLNode.js","sourceRoot":"","sources":["../../../src/v1/node/GraphQLNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GraphQLNode.js","sourceRoot":"","sources":["../../../src/v1/node/GraphQLNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA8C;AA4B9C;IACE,qBAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAEtC,8BAAQ,GAArB,UAAsB,SAAiB;;;;;;;wBAC/B,KAAK,OAAG,qBAAG,wOAAA,oKAOhB,IAAA,CAAA;wBAEsC,qBAAM,IAAA,yBAAO,EAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,SAAS,WAAA,EAAE,CAAC,EAAA;;wBAA9E,QAAQ,GAAyB,SAA6C;wBAEpF,sBAAO,MAAA,MAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,aAAa,mCAAI,MAAA,QAAQ,CAAC,OAAO,0CAAE,KAAK,mCAAI,GAAG,EAAA;;;;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