@airgap/mina 0.13.19-beta.10
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 +410 -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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.minaTransactionSignResponseToSigned = exports.minaTransactionSignRequestToUnsigned = exports.minaSignedTransactionToResponse = exports.minaUnsignedTransactionToRequest = void 0;
|
|
15
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
16
|
+
function minaUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
17
|
+
var _ = unsigned.type, rest = __rest(unsigned, ["type"]);
|
|
18
|
+
return {
|
|
19
|
+
transaction: rest,
|
|
20
|
+
publicKey: publicKey,
|
|
21
|
+
callbackURL: callbackUrl
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.minaUnsignedTransactionToRequest = minaUnsignedTransactionToRequest;
|
|
25
|
+
function minaSignedTransactionToResponse(signed, accountIdentifier) {
|
|
26
|
+
return { transaction: JSON.stringify(signed), accountIdentifier: accountIdentifier };
|
|
27
|
+
}
|
|
28
|
+
exports.minaSignedTransactionToResponse = minaSignedTransactionToResponse;
|
|
29
|
+
function minaTransactionSignRequestToUnsigned(request) {
|
|
30
|
+
return (0, module_kit_1.newUnsignedTransaction)(request.transaction);
|
|
31
|
+
}
|
|
32
|
+
exports.minaTransactionSignRequestToUnsigned = minaTransactionSignRequestToUnsigned;
|
|
33
|
+
function minaTransactionSignResponseToSigned(response) {
|
|
34
|
+
return (0, module_kit_1.newSignedTransaction)(JSON.parse(response.transaction));
|
|
35
|
+
}
|
|
36
|
+
exports.minaTransactionSignResponseToSigned = minaTransactionSignResponseToSigned;
|
|
37
|
+
//# sourceMappingURL=transaction-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iDAAiF;AAMjF,SAAgB,gCAAgC,CAC9C,QAAiC,EACjC,SAAiB,EACjB,WAAoB;IAEZ,IAAM,CAAC,GAAc,QAAQ,KAAtB,EAAK,IAAI,UAAK,QAAQ,EAA/B,QAAoB,CAAF,CAAa;IAErC,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,SAAS,WAAA;QACT,WAAW,EAAE,WAAW;KACzB,CAAA;AACH,CAAC;AAZD,4EAYC;AAED,SAAgB,+BAA+B,CAAC,MAA6B,EAAE,iBAAyB;IACtG,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,iBAAiB,mBAAA,EAAE,CAAA;AACnE,CAAC;AAFD,0EAEC;AAED,SAAgB,oCAAoC,CAAC,OAAmC;IACtF,OAAO,IAAA,mCAAsB,EAA0B,OAAO,CAAC,WAAW,CAAC,CAAA;AAC7E,CAAC;AAFD,oFAEC;AAED,SAAgB,mCAAmC,CAAC,QAAqC;IACvF,OAAO,IAAA,iCAAoB,EAAwB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAA;AACtF,CAAC;AAFD,kFAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-sign-request-mina.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/definitions/transaction-sign-request-mina.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-sign-response-mina.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/definitions/transaction-sign-response-mina.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/MinaTransactionSignRequest",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"MinaNetworkType": {
|
|
6
|
+
"enum": ["mainnet", "testnet"],
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"MinaTransactionSignRequest": {
|
|
10
|
+
"additionalProperties": false,
|
|
11
|
+
"properties": {
|
|
12
|
+
"callbackURL": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
},
|
|
15
|
+
"publicKey": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"transaction": {
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"properties": {
|
|
21
|
+
"data": {
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"properties": {
|
|
24
|
+
"amount": {
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"fee": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
},
|
|
30
|
+
"from": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
},
|
|
33
|
+
"memo": {
|
|
34
|
+
"type": "string"
|
|
35
|
+
},
|
|
36
|
+
"nonce": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"to": {
|
|
40
|
+
"type": "string"
|
|
41
|
+
},
|
|
42
|
+
"validUntil": {
|
|
43
|
+
"type": "string"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": ["to", "from", "amount", "fee", "nonce"],
|
|
47
|
+
"type": "object"
|
|
48
|
+
},
|
|
49
|
+
"networkType": {
|
|
50
|
+
"$ref": "#/definitions/MinaNetworkType"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": ["networkType", "data"],
|
|
54
|
+
"type": "object"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": ["publicKey", "transaction"],
|
|
58
|
+
"type": "object"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/MinaTransactionSignResponse",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"MinaTransactionSignResponse": {
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"accountIdentifier": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"transaction": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": ["accountIdentifier", "transaction"],
|
|
16
|
+
"type": "object"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AirGapV3SerializerCompanion, SignedTransaction, UnsignedTransaction, V3SchemaConfiguration } from '@airgap/module-kit';
|
|
2
|
+
import { TransactionSignRequest, TransactionSignResponse } from '@airgap/serializer';
|
|
3
|
+
export declare class MinaV3SerializerCompanion implements AirGapV3SerializerCompanion {
|
|
4
|
+
readonly schemas: V3SchemaConfiguration[];
|
|
5
|
+
private readonly minaTransactionValidator;
|
|
6
|
+
constructor();
|
|
7
|
+
toTransactionSignRequest(identifier: string, unsignedTransaction: UnsignedTransaction, publicKey: string, callbackUrl?: string): Promise<TransactionSignRequest>;
|
|
8
|
+
fromTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<UnsignedTransaction>;
|
|
9
|
+
validateTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<boolean>;
|
|
10
|
+
toTransactionSignResponse(identifier: string, signedTransaction: SignedTransaction, accountIdentifier: string): Promise<TransactionSignResponse>;
|
|
11
|
+
fromTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<SignedTransaction>;
|
|
12
|
+
validateTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<boolean>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
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.MinaV3SerializerCompanion = void 0;
|
|
40
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
41
|
+
var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
42
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
43
|
+
var serializer_1 = require("@airgap/serializer");
|
|
44
|
+
var transaction_converter_1 = require("./schemas/converter/transaction-converter");
|
|
45
|
+
var transaction_validator_1 = require("./validators/transaction-validator");
|
|
46
|
+
var validators_1 = require("./validators/validators");
|
|
47
|
+
var minaTransactionSignRequest = require('./schemas/generated/transaction-sign-request-mina.json');
|
|
48
|
+
var minaTransactionSignResponse = require('./schemas/generated/transaction-sign-response-mina.json');
|
|
49
|
+
var MinaV3SerializerCompanion = /** @class */ (function () {
|
|
50
|
+
function MinaV3SerializerCompanion() {
|
|
51
|
+
this.schemas = [
|
|
52
|
+
{
|
|
53
|
+
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
54
|
+
schema: { schema: minaTransactionSignRequest },
|
|
55
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.MINA
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: serializer_1.IACMessageType.TransactionSignResponse,
|
|
59
|
+
schema: { schema: minaTransactionSignResponse },
|
|
60
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.MINA
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
this.minaTransactionValidator = new transaction_validator_1.MinaTransactionValidator();
|
|
64
|
+
Object.keys(validators_1.minaValidators).forEach(function (key) {
|
|
65
|
+
validate_1.validators[key] = validators_1.minaValidators[key];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
MinaV3SerializerCompanion.prototype.toTransactionSignRequest = function (identifier, unsignedTransaction, publicKey, callbackUrl) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (identifier) {
|
|
72
|
+
case coinlib_core_1.MainProtocolSymbols.MINA:
|
|
73
|
+
return [2 /*return*/, (0, transaction_converter_1.minaUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
74
|
+
default:
|
|
75
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.MINA, "Protocol ".concat(identifier, " not supported"));
|
|
76
|
+
}
|
|
77
|
+
return [2 /*return*/];
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
MinaV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
switch (identifier) {
|
|
85
|
+
case coinlib_core_1.MainProtocolSymbols.MINA:
|
|
86
|
+
return [2 /*return*/, (0, transaction_converter_1.minaTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
87
|
+
default:
|
|
88
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.MINA, "Protocol ".concat(identifier, " not supported"));
|
|
89
|
+
}
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
MinaV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
return __generator(this, function (_c) {
|
|
98
|
+
switch (_c.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
_a = identifier;
|
|
101
|
+
switch (_a) {
|
|
102
|
+
case coinlib_core_1.MainProtocolSymbols.MINA: return [3 /*break*/, 1];
|
|
103
|
+
}
|
|
104
|
+
return [3 /*break*/, 4];
|
|
105
|
+
case 1:
|
|
106
|
+
_c.trys.push([1, 3, , 4]);
|
|
107
|
+
return [4 /*yield*/, this.minaTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
|
|
108
|
+
case 2:
|
|
109
|
+
_c.sent();
|
|
110
|
+
return [2 /*return*/, true];
|
|
111
|
+
case 3:
|
|
112
|
+
_b = _c.sent();
|
|
113
|
+
return [2 /*return*/, false];
|
|
114
|
+
case 4: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.MINA, "Protocol ".concat(identifier, " not supported"));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
MinaV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (identifier) {
|
|
123
|
+
case coinlib_core_1.MainProtocolSymbols.MINA:
|
|
124
|
+
return [2 /*return*/, (0, transaction_converter_1.minaSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
125
|
+
default:
|
|
126
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.MINA, "Protocol ".concat(identifier, " not supported"));
|
|
127
|
+
}
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
MinaV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
switch (identifier) {
|
|
136
|
+
case coinlib_core_1.MainProtocolSymbols.MINA:
|
|
137
|
+
return [2 /*return*/, (0, transaction_converter_1.minaTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
138
|
+
default:
|
|
139
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.MINA, "Protocol ".concat(identifier, " not supported"));
|
|
140
|
+
}
|
|
141
|
+
return [2 /*return*/];
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
MinaV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
return __generator(this, function (_c) {
|
|
149
|
+
switch (_c.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
_a = identifier;
|
|
152
|
+
switch (_a) {
|
|
153
|
+
case coinlib_core_1.MainProtocolSymbols.MINA: return [3 /*break*/, 1];
|
|
154
|
+
}
|
|
155
|
+
return [3 /*break*/, 4];
|
|
156
|
+
case 1:
|
|
157
|
+
_c.trys.push([1, 3, , 4]);
|
|
158
|
+
return [4 /*yield*/, this.minaTransactionValidator.validateSignedTransaction(transactionSignResponse)];
|
|
159
|
+
case 2:
|
|
160
|
+
_c.sent();
|
|
161
|
+
return [2 /*return*/, true];
|
|
162
|
+
case 3:
|
|
163
|
+
_b = _c.sent();
|
|
164
|
+
return [2 /*return*/, false];
|
|
165
|
+
case 4: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.MINA, "Protocol ".concat(identifier, " not supported"));
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
return MinaV3SerializerCompanion;
|
|
171
|
+
}());
|
|
172
|
+
exports.MinaV3SerializerCompanion = MinaV3SerializerCompanion;
|
|
173
|
+
//# sourceMappingURL=serializer-companion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer-companion.js","sourceRoot":"","sources":["../../../../src/v1/serializer/v3/serializer-companion.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TransactionValidator } from '@airgap/serializer';
|
|
2
|
+
import { MinaTransactionSignRequest } from '../schemas/definitions/transaction-sign-request-mina';
|
|
3
|
+
import { MinaTransactionSignResponse } from '../schemas/definitions/transaction-sign-response-mina';
|
|
4
|
+
export declare class MinaTransactionValidator implements TransactionValidator {
|
|
5
|
+
validateUnsignedTransaction(request: MinaTransactionSignRequest): Promise<boolean>;
|
|
6
|
+
validateSignedTransaction(response: MinaTransactionSignResponse): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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.MinaTransactionValidator = void 0;
|
|
40
|
+
var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
41
|
+
var serializer_1 = require("@airgap/serializer");
|
|
42
|
+
var unsignedTransactionConstraints = {
|
|
43
|
+
networkType: {
|
|
44
|
+
presence: { allowEmpty: false },
|
|
45
|
+
type: 'String',
|
|
46
|
+
isValidMinaNetworkType: true
|
|
47
|
+
},
|
|
48
|
+
data: {
|
|
49
|
+
presence: { allowEmpty: false },
|
|
50
|
+
isValidMinaPayment: true
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var signedTransactionConstraints = {
|
|
54
|
+
data: {
|
|
55
|
+
presence: { allowEmpty: false },
|
|
56
|
+
isValidMinaPayment: true
|
|
57
|
+
},
|
|
58
|
+
signature: {
|
|
59
|
+
presence: { allowEmpty: false },
|
|
60
|
+
isValidMinaSignature: true
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var success = function () { return undefined; };
|
|
64
|
+
var error = function (errors) { return errors; };
|
|
65
|
+
var MinaTransactionValidator = /** @class */ (function () {
|
|
66
|
+
function MinaTransactionValidator() {
|
|
67
|
+
}
|
|
68
|
+
MinaTransactionValidator.prototype.validateUnsignedTransaction = function (request) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var transaction;
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
transaction = request.transaction;
|
|
73
|
+
(0, serializer_1.validateSyncScheme)({});
|
|
74
|
+
return [2 /*return*/, (0, validate_1.async)(transaction, unsignedTransactionConstraints).then(success, error)];
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
MinaTransactionValidator.prototype.validateSignedTransaction = function (response) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var transaction;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
transaction = JSON.parse(response.transaction);
|
|
83
|
+
return [2 /*return*/, (0, validate_1.async)(transaction, signedTransactionConstraints).then(success, error)];
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
return MinaTransactionValidator;
|
|
88
|
+
}());
|
|
89
|
+
exports.MinaTransactionValidator = MinaTransactionValidator;
|
|
90
|
+
//# sourceMappingURL=transaction-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAAyF;AACzF,iDAA6E;AAK7E,IAAM,8BAA8B,GAAG;IACrC,WAAW,EAAE;QACX,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,sBAAsB,EAAE,IAAI;KAC7B;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,kBAAkB,EAAE,IAAI;KACzB;CACF,CAAA;AACD,IAAM,4BAA4B,GAAG;IACnC,IAAI,EAAE;QACJ,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,kBAAkB,EAAE,IAAI;KACzB;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,oBAAoB,EAAE,IAAI;KAC3B;CACF,CAAA;AAED,IAAM,OAAO,GAAG,cAAM,OAAA,SAAS,EAAT,CAAS,CAAA;AAC/B,IAAM,KAAK,GAAG,UAAC,MAAM,IAAK,OAAA,MAAM,EAAN,CAAM,CAAA;AAEhC;IAAA;IAYA,CAAC;IAXc,8DAA2B,GAAxC,UAAyC,OAAmC;;;;gBACpE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;gBACvC,IAAA,+BAAkB,EAAC,EAAE,CAAC,CAAA;gBAEtB,sBAAO,IAAA,gBAAK,EAAC,WAAW,EAAE,8BAA8B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAA;;;KAC/E;IAEY,4DAAyB,GAAtC,UAAuC,QAAqC;;;;gBACpE,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;gBACpD,sBAAO,IAAA,gBAAK,EAAC,WAAW,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAA;;;KAC7E;IACH,+BAAC;AAAD,CAAC,AAZD,IAYC;AAZY,4DAAwB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const minaValidators: {
|
|
2
|
+
isValidMinaPayment: (value: unknown) => Promise<"not an object" | "not a valid Mina `to` address" | "not a valid Mina `from` address" | "not a valid amount" | "not a valid fee" | "not a valid nonce" | "not a valid memo" | "not a valid timestamp" | null>;
|
|
3
|
+
isValidMinaSignature: (value: unknown) => "not an object" | "not a valid Mina raw signature" | "not a valid Mina legacy signature" | "not a valid Mina signature type" | null;
|
|
4
|
+
isValidMinaNetworkType: (value: unknown) => "not a string" | "not a valid Mina network type" | null;
|
|
5
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
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.minaValidators = void 0;
|
|
40
|
+
var MinaProtocol_1 = require("../../../protocol/MinaProtocol");
|
|
41
|
+
exports.minaValidators = {
|
|
42
|
+
isValidMinaPayment: function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
+
var protocol, metadata, addressPattern, amountPattern, payment;
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
return __generator(this, function (_d) {
|
|
46
|
+
switch (_d.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
if (typeof value !== 'object') {
|
|
49
|
+
return [2 /*return*/, 'not an object'];
|
|
50
|
+
}
|
|
51
|
+
protocol = (0, MinaProtocol_1.createMinaProtocol)();
|
|
52
|
+
return [4 /*yield*/, protocol.getMetadata()];
|
|
53
|
+
case 1:
|
|
54
|
+
metadata = _d.sent();
|
|
55
|
+
addressPattern = RegExp((_c = (_b = (_a = metadata.account) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.regex) !== null && _c !== void 0 ? _c : '.*');
|
|
56
|
+
amountPattern = RegExp('d+');
|
|
57
|
+
payment = value;
|
|
58
|
+
if (typeof payment.to !== 'string' || !addressPattern.test(payment.to)) {
|
|
59
|
+
return [2 /*return*/, 'not a valid Mina `to` address'];
|
|
60
|
+
}
|
|
61
|
+
if (typeof payment.from !== 'string' || !addressPattern.test(payment.from)) {
|
|
62
|
+
return [2 /*return*/, 'not a valid Mina `from` address'];
|
|
63
|
+
}
|
|
64
|
+
if (typeof payment.amount !== 'string' || !amountPattern.test(payment.amount)) {
|
|
65
|
+
return [2 /*return*/, 'not a valid amount'];
|
|
66
|
+
}
|
|
67
|
+
if (typeof payment.fee !== 'string' || !amountPattern.test(payment.fee)) {
|
|
68
|
+
return [2 /*return*/, 'not a valid fee'];
|
|
69
|
+
}
|
|
70
|
+
if (typeof payment.nonce !== 'string' || !amountPattern.test(payment.nonce) || parseInt(payment.nonce, 10) < 0) {
|
|
71
|
+
return [2 /*return*/, 'not a valid nonce'];
|
|
72
|
+
}
|
|
73
|
+
if (typeof payment.memo !== 'undefined' && typeof payment.memo !== 'string') {
|
|
74
|
+
return [2 /*return*/, 'not a valid memo'];
|
|
75
|
+
}
|
|
76
|
+
if (typeof payment.validUntil !== 'undefined' && (typeof payment.validUntil !== 'string' || !amountPattern.test(payment.validUntil))) {
|
|
77
|
+
return [2 /*return*/, 'not a valid timestamp'];
|
|
78
|
+
}
|
|
79
|
+
return [2 /*return*/, null];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}); },
|
|
83
|
+
isValidMinaSignature: function (value) {
|
|
84
|
+
if (typeof value !== 'object') {
|
|
85
|
+
return 'not an object';
|
|
86
|
+
}
|
|
87
|
+
var signature = value;
|
|
88
|
+
if (signature.type === 'raw') {
|
|
89
|
+
if (typeof signature.value !== 'string') {
|
|
90
|
+
return 'not a valid Mina raw signature';
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
if (signature.type === 'legacy') {
|
|
95
|
+
if (typeof signature.field !== 'string') {
|
|
96
|
+
return 'not a valid Mina legacy signature';
|
|
97
|
+
}
|
|
98
|
+
if (typeof signature.scalar !== 'string') {
|
|
99
|
+
return 'not a valid Mina legacy signature';
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return 'not a valid Mina signature type';
|
|
104
|
+
},
|
|
105
|
+
isValidMinaNetworkType: function (value) {
|
|
106
|
+
if (!value) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (typeof value !== 'string') {
|
|
110
|
+
return 'not a string';
|
|
111
|
+
}
|
|
112
|
+
if (value !== 'mainnet' && value !== 'testnet') {
|
|
113
|
+
return 'not a valid Mina network type';
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/validators.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/v1/types/crypto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const ACCOUNT_TRANSFER_KIND: string;
|
|
2
|
+
export interface AccountTransaction {
|
|
3
|
+
to: string;
|
|
4
|
+
from: string;
|
|
5
|
+
amount: string | number;
|
|
6
|
+
fee: string | number;
|
|
7
|
+
memo?: string;
|
|
8
|
+
kind?: string;
|
|
9
|
+
hash?: string;
|
|
10
|
+
dateTime: string;
|
|
11
|
+
failureReason?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../../src/v1/types/indexer.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAW,SAAS,CAAA"}
|
package/v1/types/node.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/v1/types/node.ts"],"names":[],"mappings":""}
|