@airgap/aeternity 0.13.11-beta.1 → 0.13.11-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/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +1 -5
- package/v0/index.d.ts +8 -0
- package/v0/index.js +24 -0
- package/v0/index.js.map +1 -0
- package/v0/protocol/AeternityAddress.d.ts +7 -0
- package/v0/protocol/AeternityAddress.js +42 -0
- package/v0/protocol/AeternityAddress.js.map +1 -0
- package/v0/protocol/AeternityCryptoClient.d.ts +8 -0
- package/v0/protocol/AeternityCryptoClient.js +95 -0
- package/v0/protocol/AeternityCryptoClient.js.map +1 -0
- package/v0/protocol/AeternityProtocol.d.ts +102 -0
- package/v0/protocol/AeternityProtocol.js +725 -0
- package/v0/protocol/AeternityProtocol.js.map +1 -0
- package/v0/protocol/AeternityProtocolOptions.d.ts +17 -0
- package/v0/protocol/AeternityProtocolOptions.js +109 -0
- package/v0/protocol/AeternityProtocolOptions.js.map +1 -0
- package/v0/protocol/AeternityTypes.d.ts +16 -0
- package/v0/protocol/AeternityTypes.js +3 -0
- package/v0/protocol/AeternityTypes.js.map +1 -0
- package/v0/serializer/schemas/v2/transaction-sign-request-aeternity.json +32 -0
- package/v0/serializer/schemas/v2/transaction-sign-response-aeternity.json +19 -0
- package/v0/serializer/schemas/v3/transaction-sign-request-aeternity.json +32 -0
- package/v0/serializer/schemas/v3/transaction-sign-response-aeternity.json +19 -0
- package/v0/serializer/validators/transaction-validator.d.ts +15 -0
- package/v0/serializer/validators/transaction-validator.js +116 -0
- package/v0/serializer/validators/transaction-validator.js.map +1 -0
- package/v0/serializer/validators/validators.d.ts +1 -0
- package/v0/serializer/validators/validators.js +103 -0
- package/v0/serializer/validators/validators.js.map +1 -0
- package/v0/types/signed-transaction-aeternity.d.ts +5 -0
- package/v0/types/signed-transaction-aeternity.js +3 -0
- package/v0/types/signed-transaction-aeternity.js.map +1 -0
- package/v0/types/transaction-aeternity.d.ts +4 -0
- package/v0/types/transaction-aeternity.js +3 -0
- package/v0/types/transaction-aeternity.js.map +1 -0
- package/v0/types/unsigned-transaction-aeternity.d.ts +9 -0
- package/v0/types/unsigned-transaction-aeternity.js +3 -0
- package/v0/types/unsigned-transaction-aeternity.js.map +1 -0
- package/v1/block-explorer/AeternityBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/AeternityBlockExplorer.js +74 -0
- package/v1/block-explorer/AeternityBlockExplorer.js.map +1 -0
- package/v1/data/AeternityAddress.d.ts +8 -0
- package/v1/data/AeternityAddress.js +23 -0
- package/v1/data/AeternityAddress.js.map +1 -0
- package/v1/index.d.ts +13 -0
- package/v1/index.js +11 -0
- package/v1/index.js.map +1 -0
- package/v1/module/AeternityModule.d.ts +15 -0
- package/v1/module/AeternityModule.js +107 -0
- package/v1/module/AeternityModule.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/protocol/AeternityCryptoClient.d.ts +8 -0
- package/v1/protocol/AeternityCryptoClient.js +95 -0
- package/v1/protocol/AeternityCryptoClient.js.map +1 -0
- package/v1/protocol/AeternityProtocol.d.ts +52 -0
- package/v1/protocol/AeternityProtocol.js +584 -0
- package/v1/protocol/AeternityProtocol.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-aeternity.d.ts +4 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-aeternity.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-aeternity.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-aeternity.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-aeternity.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-aeternity.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-aeternity.json +32 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-aeternity.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +14 -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 +91 -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 +106 -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/protocol.d.ts +8 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +11 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/convert.d.ts +3 -0
- package/v1/utils/convert.js +57 -0
- package/v1/utils/convert.js.map +1 -0
- package/v1/utils/key.d.ts +3 -0
- package/v1/utils/key.js +33 -0
- package/v1/utils/key.js.map +1 -0
- package/v1/utils/signature.d.ts +2 -0
- package/v1/utils/signature.js +24 -0
- package/v1/utils/signature.js.map +1 -0
- package/v1/utils/transaction.d.ts +3 -0
- package/v1/utils/transaction.js +56 -0
- package/v1/utils/transaction.js.map +1 -0
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
50
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
51
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
52
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
|
+
function step(op) {
|
|
54
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
+
while (_) try {
|
|
56
|
+
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;
|
|
57
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
|
+
switch (op[0]) {
|
|
59
|
+
case 0: case 1: t = op; break;
|
|
60
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
61
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
62
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
63
|
+
default:
|
|
64
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
65
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
66
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
67
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
68
|
+
if (t[2]) _.ops.pop();
|
|
69
|
+
_.trys.pop(); continue;
|
|
70
|
+
}
|
|
71
|
+
op = body.call(thisArg, _);
|
|
72
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
73
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
77
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
78
|
+
};
|
|
79
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
|
+
exports.AeternityProtocol = void 0;
|
|
81
|
+
var index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index"));
|
|
82
|
+
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
83
|
+
var index_2 = require("@airgap/coinlib-core/dependencies/src/bip39-2.5.0/index");
|
|
84
|
+
var bs58check = __importStar(require("@airgap/coinlib-core/dependencies/src/bs58check-2.1.2/index"));
|
|
85
|
+
var index_3 = require("@airgap/coinlib-core/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/index");
|
|
86
|
+
var rlp = __importStar(require("@airgap/coinlib-core/dependencies/src/rlp-2.2.3/index"));
|
|
87
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
88
|
+
var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
89
|
+
var NonExtendedProtocol_1 = require("@airgap/coinlib-core/protocols/NonExtendedProtocol");
|
|
90
|
+
var base64Check_1 = __importDefault(require("@airgap/coinlib-core/utils/base64Check"));
|
|
91
|
+
var hex_1 = require("@airgap/coinlib-core/utils/hex");
|
|
92
|
+
var ProtocolSymbols_1 = require("@airgap/coinlib-core/utils/ProtocolSymbols");
|
|
93
|
+
var ed25519_1 = require("@stablelib/ed25519");
|
|
94
|
+
var AeternityAddress_1 = require("./AeternityAddress");
|
|
95
|
+
var AeternityCryptoClient_1 = require("./AeternityCryptoClient");
|
|
96
|
+
var AeternityProtocolOptions_1 = require("./AeternityProtocolOptions");
|
|
97
|
+
var AeternityProtocol = /** @class */ (function (_super) {
|
|
98
|
+
__extends(AeternityProtocol, _super);
|
|
99
|
+
function AeternityProtocol(options) {
|
|
100
|
+
if (options === void 0) { options = new AeternityProtocolOptions_1.AeternityProtocolOptions(); }
|
|
101
|
+
var _this = _super.call(this) || this;
|
|
102
|
+
_this.options = options;
|
|
103
|
+
_this.symbol = 'AE';
|
|
104
|
+
_this.name = 'æternity';
|
|
105
|
+
_this.marketSymbol = 'ae';
|
|
106
|
+
_this.feeSymbol = 'ae';
|
|
107
|
+
_this.decimals = 18;
|
|
108
|
+
_this.feeDecimals = 18;
|
|
109
|
+
_this.identifier = ProtocolSymbols_1.MainProtocolSymbols.AE;
|
|
110
|
+
_this.feeDefaults = {
|
|
111
|
+
low: '0.00021',
|
|
112
|
+
medium: '0.000315',
|
|
113
|
+
high: '0.00084'
|
|
114
|
+
};
|
|
115
|
+
_this.units = [
|
|
116
|
+
{
|
|
117
|
+
unitSymbol: 'AE',
|
|
118
|
+
factor: '1'
|
|
119
|
+
}
|
|
120
|
+
];
|
|
121
|
+
_this.supportsHD = false;
|
|
122
|
+
_this.standardDerivationPath = "m/44h/457h/0h/0h/0h";
|
|
123
|
+
_this.addressIsCaseSensitive = true;
|
|
124
|
+
_this.addressValidationPattern = '^ak_+[1-9A-Za-z]{49,50}$';
|
|
125
|
+
_this.addressPlaceholder = 'ak_abc...';
|
|
126
|
+
// ae specifics
|
|
127
|
+
_this.defaultNetworkId = 'ae_mainnet';
|
|
128
|
+
_this.feesURL = 'https://api-airgap.gke.papers.tech/fees';
|
|
129
|
+
_this.cryptoClient = new AeternityCryptoClient_1.AeternityCryptoClient();
|
|
130
|
+
return _this;
|
|
131
|
+
}
|
|
132
|
+
AeternityProtocol.prototype.getSymbol = function () {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
return [2 /*return*/, this.symbol];
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
AeternityProtocol.prototype.getName = function () {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
return [2 /*return*/, this.name];
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
AeternityProtocol.prototype.getMarketSymbol = function () {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
return [2 /*return*/, this.marketSymbol];
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
AeternityProtocol.prototype.getFeeSymbol = function () {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
return [2 /*return*/, this.feeSymbol];
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
AeternityProtocol.prototype.getDecimals = function () {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
+
return __generator(this, function (_a) {
|
|
163
|
+
return [2 /*return*/, this.decimals];
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
AeternityProtocol.prototype.getFeeDecimals = function () {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
return [2 /*return*/, this.feeDecimals];
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
AeternityProtocol.prototype.getIdentifier = function () {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
return __generator(this, function (_a) {
|
|
177
|
+
return [2 /*return*/, this.identifier];
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
AeternityProtocol.prototype.getFeeDefaults = function () {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
+
return __generator(this, function (_a) {
|
|
184
|
+
return [2 /*return*/, this.feeDefaults];
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
AeternityProtocol.prototype.getUnits = function () {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
return [2 /*return*/, this.units];
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
AeternityProtocol.prototype.getSupportsHD = function () {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
+
return __generator(this, function (_a) {
|
|
198
|
+
return [2 /*return*/, this.supportsHD];
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
AeternityProtocol.prototype.getStandardDerivationPath = function () {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
204
|
+
return __generator(this, function (_a) {
|
|
205
|
+
return [2 /*return*/, this.standardDerivationPath];
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
AeternityProtocol.prototype.getAddressIsCaseSensitive = function () {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
+
return __generator(this, function (_a) {
|
|
212
|
+
return [2 /*return*/, this.addressIsCaseSensitive];
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
AeternityProtocol.prototype.getAddressValidationPattern = function () {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
return __generator(this, function (_a) {
|
|
219
|
+
return [2 /*return*/, this.addressValidationPattern];
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
AeternityProtocol.prototype.getAddressPlaceholder = function () {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
return [2 /*return*/, this.addressPlaceholder];
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
AeternityProtocol.prototype.getOptions = function () {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
return [2 /*return*/, this.options];
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
AeternityProtocol.prototype.getBlockExplorerLinkForAddress = function (address) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
+
return __generator(this, function (_a) {
|
|
240
|
+
return [2 /*return*/, this.options.network.blockExplorer.getAddressLink(address)];
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
AeternityProtocol.prototype.getBlockExplorerLinkForTxId = function (txId) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
return __generator(this, function (_a) {
|
|
247
|
+
return [2 /*return*/, this.options.network.blockExplorer.getTransactionLink(txId)];
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
AeternityProtocol.prototype.getPublicKeyFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
var secret;
|
|
254
|
+
return __generator(this, function (_a) {
|
|
255
|
+
secret = (0, index_2.mnemonicToSeed)(mnemonic, password);
|
|
256
|
+
return [2 /*return*/, this.getPublicKeyFromHexSecret(secret, derivationPath)];
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
AeternityProtocol.prototype.getPrivateKeyFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
+
var secret;
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
secret = (0, index_2.mnemonicToSeed)(mnemonic, password);
|
|
265
|
+
return [2 /*return*/, this.getPrivateKeyFromHexSecret(secret, derivationPath)];
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Returns the PublicKey as String, derived from a supplied hex-string
|
|
271
|
+
* @param secret HEX-Secret from BIP39
|
|
272
|
+
* @param derivationPath DerivationPath for Key
|
|
273
|
+
*/
|
|
274
|
+
AeternityProtocol.prototype.getPublicKeyFromHexSecret = function (secret, derivationPath) {
|
|
275
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
276
|
+
var publicKey;
|
|
277
|
+
return __generator(this, function (_a) {
|
|
278
|
+
publicKey = (0, index_3.generateWalletUsingDerivationPath)(Buffer.from(secret, 'hex'), derivationPath).publicKey;
|
|
279
|
+
return [2 /*return*/, Buffer.from(publicKey).toString('hex')];
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Returns the PrivateKey as Buffer, derived from a supplied hex-string
|
|
285
|
+
* @param secret HEX-Secret from BIP39
|
|
286
|
+
* @param derivationPath DerivationPath for Key
|
|
287
|
+
*/
|
|
288
|
+
AeternityProtocol.prototype.getPrivateKeyFromHexSecret = function (secret, derivationPath) {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
+
var secretKey;
|
|
291
|
+
return __generator(this, function (_a) {
|
|
292
|
+
secretKey = (0, index_3.generateWalletUsingDerivationPath)(Buffer.from(secret, 'hex'), derivationPath).secretKey;
|
|
293
|
+
return [2 /*return*/, Buffer.from(secretKey).toString('hex')];
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
AeternityProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
298
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
299
|
+
return __generator(this, function (_a) {
|
|
300
|
+
return [2 /*return*/, {
|
|
301
|
+
address: AeternityAddress_1.AeternityAddress.from(publicKey).asString(),
|
|
302
|
+
cursor: { hasNext: false }
|
|
303
|
+
}];
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
AeternityProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
309
|
+
var address;
|
|
310
|
+
return __generator(this, function (_a) {
|
|
311
|
+
switch (_a.label) {
|
|
312
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
313
|
+
case 1:
|
|
314
|
+
address = _a.sent();
|
|
315
|
+
return [2 /*return*/, [address]];
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
AeternityProtocol.prototype.getTransactionsFromPublicKey = function (publicKey, limit, cursor) {
|
|
321
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
+
var address;
|
|
323
|
+
return __generator(this, function (_a) {
|
|
324
|
+
switch (_a.label) {
|
|
325
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
326
|
+
case 1:
|
|
327
|
+
address = _a.sent();
|
|
328
|
+
return [2 /*return*/, this.getTransactionsFromAddresses([address.address], limit, cursor)];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
AeternityProtocol.prototype.getTransactionsFromAddresses = function (addresses, limit, cursor) {
|
|
334
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
335
|
+
var groupedTransactions, _a, next, allTransactions, transactions;
|
|
336
|
+
var _this = this;
|
|
337
|
+
return __generator(this, function (_b) {
|
|
338
|
+
switch (_b.label) {
|
|
339
|
+
case 0: return [4 /*yield*/, Promise.all(addresses.map(function (address) { return __awaiter(_this, void 0, void 0, function () {
|
|
340
|
+
var endpoint, url, response, _a;
|
|
341
|
+
return __generator(this, function (_b) {
|
|
342
|
+
switch (_b.label) {
|
|
343
|
+
case 0:
|
|
344
|
+
endpoint = cursor === undefined ? "/txs/backward?account=".concat(address, "&limit=").concat(limit) : cursor.next[address];
|
|
345
|
+
url = endpoint !== undefined ? "".concat(this.options.network.rpcUrl, "/mdw/").concat(endpoint.replace(/^\/+/, '')) : undefined;
|
|
346
|
+
if (!(url !== undefined)) return [3 /*break*/, 2];
|
|
347
|
+
return [4 /*yield*/, index_1.default.get(url)];
|
|
348
|
+
case 1:
|
|
349
|
+
_a = _b.sent();
|
|
350
|
+
return [3 /*break*/, 3];
|
|
351
|
+
case 2:
|
|
352
|
+
_a = undefined;
|
|
353
|
+
_b.label = 3;
|
|
354
|
+
case 3:
|
|
355
|
+
response = _a;
|
|
356
|
+
return [2 /*return*/, {
|
|
357
|
+
address: address,
|
|
358
|
+
data: response === null || response === void 0 ? void 0 : response.data
|
|
359
|
+
}];
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}); }))];
|
|
363
|
+
case 1:
|
|
364
|
+
groupedTransactions = _b.sent();
|
|
365
|
+
_a = groupedTransactions.reduce(function (acc, curr) {
|
|
366
|
+
var _a;
|
|
367
|
+
var _b, _c;
|
|
368
|
+
var nextAcc = ((_b = curr.data) === null || _b === void 0 ? void 0 : _b.next) ? Object.assign(acc[0], (_a = {}, _a[curr.address] = curr.data.next, _a)) : acc[0];
|
|
369
|
+
var transactionsAcc = acc[1].concat(((_c = curr.data) === null || _c === void 0 ? void 0 : _c.data) || []);
|
|
370
|
+
return [nextAcc, transactionsAcc];
|
|
371
|
+
}, [{}, []]), next = _a[0], allTransactions = _a[1];
|
|
372
|
+
transactions = allTransactions.map(function (obj) {
|
|
373
|
+
var parsedTimestamp = parseInt(obj.micro_time, 10);
|
|
374
|
+
var airGapTx = {
|
|
375
|
+
amount: new bignumber_1.default(obj.tx.amount).toString(10),
|
|
376
|
+
fee: new bignumber_1.default(obj.tx.fee).toString(10),
|
|
377
|
+
from: [obj.tx.sender_id],
|
|
378
|
+
isInbound: addresses.indexOf(obj.tx.recipient_id) !== -1,
|
|
379
|
+
protocolIdentifier: _this.identifier,
|
|
380
|
+
network: _this.options.network,
|
|
381
|
+
to: [obj.tx.recipient_id],
|
|
382
|
+
hash: obj.hash,
|
|
383
|
+
blockHeight: obj.block_height
|
|
384
|
+
};
|
|
385
|
+
if (obj.tx.payload) {
|
|
386
|
+
airGapTx.data = obj.tx.payload;
|
|
387
|
+
}
|
|
388
|
+
if (!isNaN(parsedTimestamp)) {
|
|
389
|
+
airGapTx.timestamp = Math.round(parsedTimestamp / 1000);
|
|
390
|
+
}
|
|
391
|
+
return airGapTx;
|
|
392
|
+
});
|
|
393
|
+
return [2 /*return*/, { transactions: transactions, cursor: { next: next } }];
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
AeternityProtocol.prototype.getPageNumber = function (limit, offset) {
|
|
399
|
+
if (limit <= 0 || offset < 0) {
|
|
400
|
+
return 1;
|
|
401
|
+
}
|
|
402
|
+
return 1 + Math.floor(offset / limit); // We need +1 here because pages start at 1
|
|
403
|
+
};
|
|
404
|
+
AeternityProtocol.prototype.signWithPrivateKey = function (privateKey, transaction) {
|
|
405
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
406
|
+
var rawTx, signature, txObj, txArray, rlpEncodedTx, signedEncodedTx;
|
|
407
|
+
return __generator(this, function (_a) {
|
|
408
|
+
rawTx = this.decodeTx(transaction.transaction);
|
|
409
|
+
signature = (0, ed25519_1.sign)(Buffer.from(privateKey, 'hex'), Buffer.concat([Buffer.from(transaction.networkId), rawTx]));
|
|
410
|
+
txObj = {
|
|
411
|
+
tag: (0, hex_1.toHexBuffer)(11),
|
|
412
|
+
version: (0, hex_1.toHexBuffer)(1),
|
|
413
|
+
signatures: [Buffer.from(signature)],
|
|
414
|
+
transaction: rawTx
|
|
415
|
+
};
|
|
416
|
+
txArray = Object.keys(txObj).map(function (a) { return txObj[a]; });
|
|
417
|
+
rlpEncodedTx = rlp.encode(txArray);
|
|
418
|
+
signedEncodedTx = "tx_".concat(base64Check_1.default.encode(rlpEncodedTx));
|
|
419
|
+
return [2 /*return*/, signedEncodedTx];
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
};
|
|
423
|
+
AeternityProtocol.prototype.decodeTx = function (transaction) {
|
|
424
|
+
var rawTx;
|
|
425
|
+
try {
|
|
426
|
+
rawTx = base64Check_1.default.decode(transaction.replace('tx_', ''));
|
|
427
|
+
return rawTx;
|
|
428
|
+
}
|
|
429
|
+
catch (error) {
|
|
430
|
+
//
|
|
431
|
+
}
|
|
432
|
+
try {
|
|
433
|
+
rawTx = bs58check.decode(transaction.replace('tx_', ''));
|
|
434
|
+
return rawTx;
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
//
|
|
438
|
+
}
|
|
439
|
+
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.AETERNITY, 'invalid TX-encoding');
|
|
440
|
+
};
|
|
441
|
+
AeternityProtocol.prototype.getTransactionDetails = function (unsignedTx) {
|
|
442
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
443
|
+
var transaction, rlpEncodedTx, rlpDecodedTx, fromAddress, toAddress, airgapTx;
|
|
444
|
+
return __generator(this, function (_a) {
|
|
445
|
+
switch (_a.label) {
|
|
446
|
+
case 0:
|
|
447
|
+
transaction = unsignedTx.transaction.transaction;
|
|
448
|
+
rlpEncodedTx = this.decodeTx(transaction);
|
|
449
|
+
rlpDecodedTx = rlp.decode(rlpEncodedTx, false);
|
|
450
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(rlpDecodedTx[2].slice(1).toString('hex'))];
|
|
451
|
+
case 1:
|
|
452
|
+
fromAddress = _a.sent();
|
|
453
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(rlpDecodedTx[3].slice(1).toString('hex'))];
|
|
454
|
+
case 2:
|
|
455
|
+
toAddress = _a.sent();
|
|
456
|
+
airgapTx = {
|
|
457
|
+
amount: new bignumber_1.default(parseInt(rlpDecodedTx[4].toString('hex'), 16)).toString(10),
|
|
458
|
+
fee: new bignumber_1.default(parseInt(rlpDecodedTx[5].toString('hex'), 16)).toString(10),
|
|
459
|
+
from: [fromAddress.address],
|
|
460
|
+
isInbound: false,
|
|
461
|
+
protocolIdentifier: this.identifier,
|
|
462
|
+
network: this.options.network,
|
|
463
|
+
to: [toAddress.address],
|
|
464
|
+
data: (rlpDecodedTx[8] || '').toString('utf8'),
|
|
465
|
+
transactionDetails: unsignedTx.transaction
|
|
466
|
+
};
|
|
467
|
+
return [2 /*return*/, [airgapTx]];
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
};
|
|
472
|
+
AeternityProtocol.prototype.getTransactionDetailsFromSigned = function (signedTx) {
|
|
473
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
474
|
+
var rlpEncodedTx, rlpDecodedTx, unsignedAeternityTransaction;
|
|
475
|
+
return __generator(this, function (_a) {
|
|
476
|
+
rlpEncodedTx = this.decodeTx(signedTx.transaction);
|
|
477
|
+
rlpDecodedTx = rlp.decode(rlpEncodedTx, false);
|
|
478
|
+
unsignedAeternityTransaction = {
|
|
479
|
+
publicKey: '',
|
|
480
|
+
transaction: {
|
|
481
|
+
networkId: 'ae_mainnet',
|
|
482
|
+
transaction: "tx_".concat(base64Check_1.default.encode(rlpDecodedTx[3]))
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
return [2 /*return*/, this.getTransactionDetails(unsignedAeternityTransaction)];
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
AeternityProtocol.prototype.getBalanceOfAddresses = function (addresses) {
|
|
490
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
491
|
+
var balance, _i, addresses_1, address, data, error_1;
|
|
492
|
+
return __generator(this, function (_a) {
|
|
493
|
+
switch (_a.label) {
|
|
494
|
+
case 0:
|
|
495
|
+
balance = new bignumber_1.default(0);
|
|
496
|
+
_i = 0, addresses_1 = addresses;
|
|
497
|
+
_a.label = 1;
|
|
498
|
+
case 1:
|
|
499
|
+
if (!(_i < addresses_1.length)) return [3 /*break*/, 6];
|
|
500
|
+
address = addresses_1[_i];
|
|
501
|
+
_a.label = 2;
|
|
502
|
+
case 2:
|
|
503
|
+
_a.trys.push([2, 4, , 5]);
|
|
504
|
+
return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/v2/accounts/").concat(address))];
|
|
505
|
+
case 3:
|
|
506
|
+
data = (_a.sent()).data;
|
|
507
|
+
balance = balance.plus(new bignumber_1.default(data.balance));
|
|
508
|
+
return [3 /*break*/, 5];
|
|
509
|
+
case 4:
|
|
510
|
+
error_1 = _a.sent();
|
|
511
|
+
// if node returns 404 (which means 'no account found'), go with 0 balance
|
|
512
|
+
if (error_1.response && error_1.response.status !== 404) {
|
|
513
|
+
throw new errors_1.NetworkError(coinlib_error_1.Domain.AETERNITY, error_1);
|
|
514
|
+
}
|
|
515
|
+
return [3 /*break*/, 5];
|
|
516
|
+
case 5:
|
|
517
|
+
_i++;
|
|
518
|
+
return [3 /*break*/, 1];
|
|
519
|
+
case 6: return [2 /*return*/, balance.toString(10)];
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
AeternityProtocol.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
525
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
526
|
+
var address;
|
|
527
|
+
return __generator(this, function (_a) {
|
|
528
|
+
switch (_a.label) {
|
|
529
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
530
|
+
case 1:
|
|
531
|
+
address = _a.sent();
|
|
532
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
};
|
|
537
|
+
AeternityProtocol.prototype.getBalanceOfPublicKeyForSubProtocols = function (publicKey, subProtocols) {
|
|
538
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
539
|
+
return __generator(this, function (_a) {
|
|
540
|
+
throw Promise.reject('get balance of sub protocols not supported');
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
AeternityProtocol.prototype.getAvailableBalanceOfAddresses = function (addresses) {
|
|
545
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
546
|
+
return __generator(this, function (_a) {
|
|
547
|
+
return [2 /*return*/, this.getBalanceOfAddresses(addresses)];
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
};
|
|
551
|
+
AeternityProtocol.prototype.estimateMaxTransactionValueFromPublicKey = function (publicKey, recipients, fee) {
|
|
552
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
553
|
+
var balance, balanceWrapper, maxFee, estimatedFeeDefaults, amountWithoutFees;
|
|
554
|
+
return __generator(this, function (_a) {
|
|
555
|
+
switch (_a.label) {
|
|
556
|
+
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
557
|
+
case 1:
|
|
558
|
+
balance = _a.sent();
|
|
559
|
+
balanceWrapper = new bignumber_1.default(balance);
|
|
560
|
+
if (!(fee !== undefined)) return [3 /*break*/, 2];
|
|
561
|
+
maxFee = new bignumber_1.default(fee);
|
|
562
|
+
return [3 /*break*/, 4];
|
|
563
|
+
case 2: return [4 /*yield*/, this.estimateFeeDefaultsFromPublicKey(publicKey, recipients, [balance])];
|
|
564
|
+
case 3:
|
|
565
|
+
estimatedFeeDefaults = _a.sent();
|
|
566
|
+
maxFee = new bignumber_1.default(estimatedFeeDefaults.medium).shiftedBy(this.decimals);
|
|
567
|
+
if (maxFee.gte(balanceWrapper)) {
|
|
568
|
+
maxFee = new bignumber_1.default(0);
|
|
569
|
+
}
|
|
570
|
+
_a.label = 4;
|
|
571
|
+
case 4:
|
|
572
|
+
amountWithoutFees = balanceWrapper.minus(maxFee);
|
|
573
|
+
if (amountWithoutFees.isNegative()) {
|
|
574
|
+
amountWithoutFees = new bignumber_1.default(0);
|
|
575
|
+
}
|
|
576
|
+
return [2 /*return*/, amountWithoutFees.toFixed()];
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
AeternityProtocol.prototype.estimateFeeDefaultsFromPublicKey = function (publicKey, recipients, values, data) {
|
|
582
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
583
|
+
return __generator(this, function (_a) {
|
|
584
|
+
switch (_a.label) {
|
|
585
|
+
case 0: return [4 /*yield*/, index_1.default.get(this.feesURL)];
|
|
586
|
+
case 1: return [2 /*return*/, (_a.sent()).data];
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
AeternityProtocol.prototype.prepareTransactionFromPublicKey = function (publicKey, recipients, values, fee, data) {
|
|
592
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
593
|
+
var nonce, address, accountResponse, error_2, balance, _a, sender, recipient, txObj, txArray, rlpEncodedTx, preparedTx;
|
|
594
|
+
return __generator(this, function (_b) {
|
|
595
|
+
switch (_b.label) {
|
|
596
|
+
case 0:
|
|
597
|
+
nonce = 1;
|
|
598
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
599
|
+
case 1:
|
|
600
|
+
address = _b.sent();
|
|
601
|
+
_b.label = 2;
|
|
602
|
+
case 2:
|
|
603
|
+
_b.trys.push([2, 4, , 5]);
|
|
604
|
+
return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/v2/accounts/").concat(address.address))];
|
|
605
|
+
case 3:
|
|
606
|
+
accountResponse = (_b.sent()).data;
|
|
607
|
+
nonce = accountResponse.nonce + 1;
|
|
608
|
+
return [3 /*break*/, 5];
|
|
609
|
+
case 4:
|
|
610
|
+
error_2 = _b.sent();
|
|
611
|
+
// if node returns 404 (which means 'no account found'), go with nonce 0
|
|
612
|
+
if (error_2.response && error_2.response.status !== 404) {
|
|
613
|
+
throw new errors_1.NetworkError(coinlib_error_1.Domain.AETERNITY, error_2);
|
|
614
|
+
}
|
|
615
|
+
return [3 /*break*/, 5];
|
|
616
|
+
case 5:
|
|
617
|
+
_a = bignumber_1.default.bind;
|
|
618
|
+
return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
619
|
+
case 6:
|
|
620
|
+
balance = new (_a.apply(bignumber_1.default, [void 0, _b.sent()]))();
|
|
621
|
+
if (balance.isLessThan(fee)) {
|
|
622
|
+
throw new errors_1.BalanceError(coinlib_error_1.Domain.AETERNITY, 'not enough balance');
|
|
623
|
+
}
|
|
624
|
+
sender = publicKey;
|
|
625
|
+
recipient = bs58check.decode(recipients[0].replace('ak_', ''));
|
|
626
|
+
txObj = {
|
|
627
|
+
tag: (0, hex_1.toHexBuffer)(12),
|
|
628
|
+
version: (0, hex_1.toHexBuffer)(1),
|
|
629
|
+
sender_id: Buffer.concat([(0, hex_1.toHexBuffer)(1), Buffer.from(sender, 'hex')]),
|
|
630
|
+
recipient_id: Buffer.concat([(0, hex_1.toHexBuffer)(1), recipient]),
|
|
631
|
+
amount: (0, hex_1.toHexBuffer)(new bignumber_1.default(values[0])),
|
|
632
|
+
fee: (0, hex_1.toHexBuffer)(new bignumber_1.default(fee)),
|
|
633
|
+
ttl: (0, hex_1.toHexBuffer)(0),
|
|
634
|
+
nonce: (0, hex_1.toHexBuffer)(nonce),
|
|
635
|
+
payload: Buffer.from((data === null || data === void 0 ? void 0 : data.payload) || '')
|
|
636
|
+
};
|
|
637
|
+
txArray = Object.keys(txObj).map(function (a) { return txObj[a]; });
|
|
638
|
+
rlpEncodedTx = rlp.encode(txArray);
|
|
639
|
+
preparedTx = "tx_".concat(base64Check_1.default.encode(rlpEncodedTx));
|
|
640
|
+
return [2 /*return*/, {
|
|
641
|
+
transaction: preparedTx,
|
|
642
|
+
networkId: this.defaultNetworkId
|
|
643
|
+
}];
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
};
|
|
648
|
+
/**
|
|
649
|
+
* This is a function that we only use to fix incompatibilitis with old vault versions that are unable to understand b64 encoded Txs.
|
|
650
|
+
*
|
|
651
|
+
* @deprecated
|
|
652
|
+
* @param preparedTx
|
|
653
|
+
*/
|
|
654
|
+
AeternityProtocol.prototype.convertTxToBase58 = function (preparedTx) {
|
|
655
|
+
return {
|
|
656
|
+
transaction: bs58check.encode(base64Check_1.default.decode(preparedTx.transaction)),
|
|
657
|
+
networkId: preparedTx.networkId
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
AeternityProtocol.prototype.broadcastTransaction = function (rawTransaction) {
|
|
661
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
662
|
+
var data;
|
|
663
|
+
return __generator(this, function (_a) {
|
|
664
|
+
switch (_a.label) {
|
|
665
|
+
case 0: return [4 /*yield*/, index_1.default.post("".concat(this.options.network.rpcUrl, "/v2/transactions"), { tx: rawTransaction }, { headers: { 'Content-Type': 'application/json' } })];
|
|
666
|
+
case 1:
|
|
667
|
+
data = (_a.sent()).data;
|
|
668
|
+
return [2 /*return*/, data.tx_hash];
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
};
|
|
673
|
+
AeternityProtocol.prototype.signMessage = function (message, keypair) {
|
|
674
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
675
|
+
return __generator(this, function (_a) {
|
|
676
|
+
return [2 /*return*/, this.cryptoClient.signMessage(message, keypair)];
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
};
|
|
680
|
+
AeternityProtocol.prototype.verifyMessage = function (message, signature, publicKey) {
|
|
681
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
682
|
+
return __generator(this, function (_a) {
|
|
683
|
+
return [2 /*return*/, this.cryptoClient.verifyMessage(message, signature, publicKey)];
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
};
|
|
687
|
+
AeternityProtocol.prototype.encryptAsymmetric = function (message, publicKey) {
|
|
688
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
689
|
+
return __generator(this, function (_a) {
|
|
690
|
+
return [2 /*return*/, this.cryptoClient.encryptAsymmetric(message, publicKey)];
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
};
|
|
694
|
+
AeternityProtocol.prototype.decryptAsymmetric = function (message, keypair) {
|
|
695
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
696
|
+
return __generator(this, function (_a) {
|
|
697
|
+
return [2 /*return*/, this.cryptoClient.decryptAsymmetric(message, keypair)];
|
|
698
|
+
});
|
|
699
|
+
});
|
|
700
|
+
};
|
|
701
|
+
AeternityProtocol.prototype.encryptAES = function (message, privateKey) {
|
|
702
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
703
|
+
return __generator(this, function (_a) {
|
|
704
|
+
return [2 /*return*/, this.cryptoClient.encryptAES(message, privateKey)];
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
};
|
|
708
|
+
AeternityProtocol.prototype.decryptAES = function (message, privateKey) {
|
|
709
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
710
|
+
return __generator(this, function (_a) {
|
|
711
|
+
return [2 /*return*/, this.cryptoClient.decryptAES(message, privateKey)];
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
AeternityProtocol.prototype.getTransactionStatuses = function (transactionHashes) {
|
|
716
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
717
|
+
return __generator(this, function (_a) {
|
|
718
|
+
return [2 /*return*/, Promise.reject('Transaction status not implemented')];
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
return AeternityProtocol;
|
|
723
|
+
}(NonExtendedProtocol_1.NonExtendedProtocol));
|
|
724
|
+
exports.AeternityProtocol = AeternityProtocol;
|
|
725
|
+
//# sourceMappingURL=AeternityProtocol.js.map
|