@airgap/aeternity 0.13.45-beta.2 → 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 +4 -4
- package/v0/index.js +7 -7
- package/v0/index.js.map +1 -1
- package/v0/protocol/AeternityAddress.js +27 -18
- package/v0/protocol/AeternityAddress.js.map +1 -1
- package/v0/protocol/AeternityCryptoClient.js +21 -84
- package/v0/protocol/AeternityCryptoClient.js.map +1 -1
- package/v0/protocol/AeternityProtocol.js +341 -657
- package/v0/protocol/AeternityProtocol.js.map +1 -1
- package/v0/protocol/AeternityProtocolOptions.js +22 -93
- package/v0/protocol/AeternityProtocolOptions.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +30 -83
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +19 -67
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v1/block-explorer/AeternityBlockExplorer.js +12 -61
- package/v1/block-explorer/AeternityBlockExplorer.js.map +1 -1
- package/v1/data/AeternityAddress.js +12 -13
- package/v1/data/AeternityAddress.js.map +1 -1
- package/v1/index.js +3 -3
- package/v1/index.js.map +1 -1
- package/v1/module/AeternityModule.d.ts +1 -1
- package/v1/module/AeternityModule.js +37 -95
- package/v1/module/AeternityModule.js.map +1 -1
- package/v1/module.js +2 -3
- package/v1/module.js.map +1 -1
- package/v1/protocol/AeternityCryptoClient.js +21 -84
- package/v1/protocol/AeternityCryptoClient.js.map +1 -1
- package/v1/protocol/AeternityProtocol.js +282 -497
- package/v1/protocol/AeternityProtocol.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 +15 -63
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +19 -67
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/protocol.d.ts +1 -1
- package/v1/utils/convert.js +26 -17
- package/v1/utils/convert.js.map +1 -1
- package/v1/utils/key.js +9 -10
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/signature.js +6 -7
- package/v1/utils/signature.js.map +1 -1
- package/v1/utils/transaction.d.ts +0 -1
- package/v1/utils/transaction.js +26 -17
- package/v1/utils/transaction.js.map +1 -1
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -26,73 +15,48 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
26
15
|
}) : function(o, v) {
|
|
27
16
|
o["default"] = v;
|
|
28
17
|
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (_) try {
|
|
52
|
-
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;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
72
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
37
|
};
|
|
75
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
-
exports.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
39
|
+
exports.AETERNITY_MAINNET_PROTOCOL_NETWORK = exports.AeternityProtocolImpl = void 0;
|
|
40
|
+
exports.createAeternityProtocol = createAeternityProtocol;
|
|
41
|
+
exports.createAeternityProtocolOptions = createAeternityProtocolOptions;
|
|
42
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
43
|
+
const index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index"));
|
|
44
|
+
const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
45
|
+
const bs58check = __importStar(require("@airgap/coinlib-core/dependencies/src/bs58check-2.1.2/index"));
|
|
46
|
+
const rlp = __importStar(require("@airgap/coinlib-core/dependencies/src/rlp-2.2.3/index"));
|
|
47
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
48
|
+
const base64Check_1 = __importDefault(require("@airgap/coinlib-core/utils/base64Check"));
|
|
49
|
+
const hex_1 = require("@airgap/coinlib-core/utils/hex");
|
|
50
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
51
|
+
const ed25519_1 = require("@stablelib/ed25519");
|
|
52
|
+
const AeternityAddress_1 = require("../data/AeternityAddress");
|
|
53
|
+
const key_1 = require("../utils/key");
|
|
54
|
+
const signature_1 = require("../utils/signature");
|
|
55
|
+
const transaction_1 = require("../utils/transaction");
|
|
56
|
+
const AeternityCryptoClient_1 = require("./AeternityCryptoClient");
|
|
92
57
|
// Implementation
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (options === void 0) { options = {}; }
|
|
58
|
+
class AeternityProtocolImpl {
|
|
59
|
+
constructor(options = {}) {
|
|
96
60
|
// Common
|
|
97
61
|
this.units = {
|
|
98
62
|
AE: {
|
|
@@ -114,7 +78,7 @@ var AeternityProtocolImpl = /** @class */ (function () {
|
|
|
114
78
|
defaults: this.feeDefaults
|
|
115
79
|
},
|
|
116
80
|
account: {
|
|
117
|
-
standardDerivationPath:
|
|
81
|
+
standardDerivationPath: `m/44h/457h/0h/0h/0h`,
|
|
118
82
|
address: {
|
|
119
83
|
isCaseSensitive: true,
|
|
120
84
|
placeholder: 'ak_abc...',
|
|
@@ -134,439 +98,262 @@ var AeternityProtocolImpl = /** @class */ (function () {
|
|
|
134
98
|
this.options = createAeternityProtocolOptions(options.network);
|
|
135
99
|
this.cryptoClient = new AeternityCryptoClient_1.AeternityCryptoClient();
|
|
136
100
|
}
|
|
137
|
-
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
AeternityProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
235
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
236
|
-
var rawTx, signature, txObj, txArray, rlpEncodedTx, signedEncodedTx;
|
|
237
|
-
return __generator(this, function (_a) {
|
|
238
|
-
if (secretKey.format !== 'hex') {
|
|
239
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
240
|
-
}
|
|
241
|
-
rawTx = (0, transaction_1.decodeTx)(transaction.transaction);
|
|
242
|
-
signature = (0, ed25519_1.sign)(Buffer.from(secretKey.value, 'hex'), Buffer.concat([Buffer.from(transaction.networkId), rawTx]));
|
|
243
|
-
txObj = {
|
|
244
|
-
tag: (0, hex_1.toHexBuffer)(11),
|
|
245
|
-
version: (0, hex_1.toHexBuffer)(1),
|
|
246
|
-
signatures: [Buffer.from(signature)],
|
|
247
|
-
transaction: rawTx
|
|
248
|
-
};
|
|
249
|
-
txArray = Object.keys(txObj).map(function (a) { return txObj[a]; });
|
|
250
|
-
rlpEncodedTx = rlp.encode(txArray);
|
|
251
|
-
signedEncodedTx = "tx_".concat(base64Check_1.default.encode(rlpEncodedTx));
|
|
252
|
-
return [2 /*return*/, (0, module_kit_1.newSignedTransaction)({ transaction: signedEncodedTx })];
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
AeternityProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) {
|
|
257
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
258
|
-
var _a;
|
|
259
|
-
return __generator(this, function (_b) {
|
|
260
|
-
switch (_b.label) {
|
|
261
|
-
case 0:
|
|
262
|
-
if (keyPair.secretKey.format !== 'hex') {
|
|
263
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
264
|
-
}
|
|
265
|
-
_a = module_kit_1.newSignature;
|
|
266
|
-
return [4 /*yield*/, this.cryptoClient.signMessage(message, { privateKey: keyPair.secretKey.value })];
|
|
267
|
-
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), 'hex'])];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
AeternityProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) {
|
|
273
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
274
|
-
var hexPublicKey;
|
|
275
|
-
return __generator(this, function (_a) {
|
|
276
|
-
if (keyPair.secretKey.format !== 'hex') {
|
|
277
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
278
|
-
}
|
|
279
|
-
hexPublicKey = (0, key_1.convertPublicKey)(keyPair.publicKey, 'hex');
|
|
280
|
-
return [2 /*return*/, this.cryptoClient.decryptAsymmetric(payload, { publicKey: hexPublicKey.value, privateKey: keyPair.secretKey.value })];
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
AeternityProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) {
|
|
285
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
286
|
-
return __generator(this, function (_a) {
|
|
287
|
-
if (secretKey.format !== 'hex') {
|
|
288
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
289
|
-
}
|
|
290
|
-
return [2 /*return*/, this.cryptoClient.encryptAES(payload, secretKey.value)];
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
};
|
|
294
|
-
AeternityProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) {
|
|
295
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
-
return __generator(this, function (_a) {
|
|
297
|
-
if (secretKey.format !== 'hex') {
|
|
298
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
299
|
-
}
|
|
300
|
-
return [2 /*return*/, this.cryptoClient.decryptAES(payload, secretKey.value)];
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
101
|
+
async getMetadata() {
|
|
102
|
+
return this.metadata;
|
|
103
|
+
}
|
|
104
|
+
async getAddressFromPublicKey(publicKey) {
|
|
105
|
+
return AeternityAddress_1.AeternityAddress.from(publicKey).asString();
|
|
106
|
+
}
|
|
107
|
+
async getDetailsFromTransaction(transaction, _publicKey) {
|
|
108
|
+
switch (transaction.type) {
|
|
109
|
+
case 'signed':
|
|
110
|
+
const rlpEncodedTx = (0, transaction_1.decodeTx)(transaction.transaction);
|
|
111
|
+
const rlpDecodedTx = rlp.decode(rlpEncodedTx, false);
|
|
112
|
+
return this.getDetailsFromEncodedTransaction(`tx_${base64Check_1.default.encode(rlpDecodedTx[3])}`);
|
|
113
|
+
case 'unsigned':
|
|
114
|
+
return this.getDetailsFromEncodedTransaction(transaction.transaction);
|
|
115
|
+
default:
|
|
116
|
+
(0, coinlib_core_1.assertNever)(transaction);
|
|
117
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, 'Unsupported transaction type.');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async getDetailsFromEncodedTransaction(tx) {
|
|
121
|
+
const rlpEncodedTx = (0, transaction_1.decodeTx)(tx);
|
|
122
|
+
const rlpDecodedTx = rlp.decode(rlpEncodedTx, false);
|
|
123
|
+
const from = await this.getAddressFromPublicKey((0, module_kit_1.newPublicKey)(rlpDecodedTx[2].slice(1).toString('hex'), 'hex'));
|
|
124
|
+
const to = await this.getAddressFromPublicKey((0, module_kit_1.newPublicKey)(rlpDecodedTx[3].slice(1).toString('hex'), 'hex'));
|
|
125
|
+
const airgapTx = {
|
|
126
|
+
from: [from],
|
|
127
|
+
to: [to],
|
|
128
|
+
isInbound: false,
|
|
129
|
+
amount: (0, module_kit_1.newAmount)(parseInt(rlpDecodedTx[4].toString('hex'), 16), 'blockchain'),
|
|
130
|
+
fee: (0, module_kit_1.newAmount)(parseInt(rlpDecodedTx[5].toString('hex'), 16), 'blockchain'),
|
|
131
|
+
network: this.options.network,
|
|
132
|
+
arbitraryData: (rlpDecodedTx[8] || '').toString('utf8')
|
|
133
|
+
};
|
|
134
|
+
return [airgapTx];
|
|
135
|
+
}
|
|
136
|
+
async verifyMessageWithPublicKey(message, signature, publicKey) {
|
|
137
|
+
const hexSignature = (0, signature_1.convertSignature)(signature, 'hex');
|
|
138
|
+
const hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex');
|
|
139
|
+
return this.cryptoClient.verifyMessage(message, hexSignature.value, hexPublicKey.value);
|
|
140
|
+
}
|
|
141
|
+
async encryptAsymmetricWithPublicKey(payload, publicKey) {
|
|
142
|
+
const hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex');
|
|
143
|
+
return this.cryptoClient.encryptAsymmetric(payload, hexPublicKey.value);
|
|
144
|
+
}
|
|
145
|
+
async getCryptoConfiguration() {
|
|
146
|
+
return this.cryptoConfiguration;
|
|
147
|
+
}
|
|
148
|
+
async getKeyPairFromDerivative(derivative) {
|
|
149
|
+
return {
|
|
150
|
+
secretKey: (0, module_kit_1.newSecretKey)(Buffer.concat([Buffer.from(derivative.secretKey, 'hex'), Buffer.from(derivative.publicKey, 'hex')]).toString('hex'), 'hex'),
|
|
151
|
+
publicKey: (0, module_kit_1.newPublicKey)(derivative.publicKey, 'hex')
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async signTransactionWithSecretKey(transaction, secretKey) {
|
|
155
|
+
if (secretKey.format !== 'hex') {
|
|
156
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
157
|
+
}
|
|
158
|
+
const rawTx = (0, transaction_1.decodeTx)(transaction.transaction);
|
|
159
|
+
const signature = (0, ed25519_1.sign)(Buffer.from(secretKey.value, 'hex'), Buffer.concat([Buffer.from(transaction.networkId), rawTx]));
|
|
160
|
+
const txObj = {
|
|
161
|
+
tag: (0, hex_1.toHexBuffer)(11),
|
|
162
|
+
version: (0, hex_1.toHexBuffer)(1),
|
|
163
|
+
signatures: [Buffer.from(signature)],
|
|
164
|
+
transaction: rawTx
|
|
165
|
+
};
|
|
166
|
+
const txArray = Object.keys(txObj).map((a) => txObj[a]);
|
|
167
|
+
const rlpEncodedTx = rlp.encode(txArray);
|
|
168
|
+
const signedEncodedTx = `tx_${base64Check_1.default.encode(rlpEncodedTx)}`;
|
|
169
|
+
return (0, module_kit_1.newSignedTransaction)({ transaction: signedEncodedTx });
|
|
170
|
+
}
|
|
171
|
+
async signMessageWithKeyPair(message, keyPair) {
|
|
172
|
+
if (keyPair.secretKey.format !== 'hex') {
|
|
173
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
174
|
+
}
|
|
175
|
+
return (0, module_kit_1.newSignature)(await this.cryptoClient.signMessage(message, { privateKey: keyPair.secretKey.value }), 'hex');
|
|
176
|
+
}
|
|
177
|
+
async decryptAsymmetricWithKeyPair(payload, keyPair) {
|
|
178
|
+
if (keyPair.secretKey.format !== 'hex') {
|
|
179
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
180
|
+
}
|
|
181
|
+
const hexPublicKey = (0, key_1.convertPublicKey)(keyPair.publicKey, 'hex');
|
|
182
|
+
return this.cryptoClient.decryptAsymmetric(payload, { publicKey: hexPublicKey.value, privateKey: keyPair.secretKey.value });
|
|
183
|
+
}
|
|
184
|
+
async encryptAESWithSecretKey(payload, secretKey) {
|
|
185
|
+
if (secretKey.format !== 'hex') {
|
|
186
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
187
|
+
}
|
|
188
|
+
return this.cryptoClient.encryptAES(payload, secretKey.value);
|
|
189
|
+
}
|
|
190
|
+
async decryptAESWithSecretKey(payload, secretKey) {
|
|
191
|
+
if (secretKey.format !== 'hex') {
|
|
192
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.');
|
|
193
|
+
}
|
|
194
|
+
return this.cryptoClient.decryptAES(payload, secretKey.value);
|
|
195
|
+
}
|
|
304
196
|
// Online
|
|
305
|
-
|
|
306
|
-
return
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (!(url !== undefined)) return [3 /*break*/, 2];
|
|
336
|
-
return [4 /*yield*/, index_1.default.get(url)];
|
|
337
|
-
case 1:
|
|
338
|
-
_c = _d.sent();
|
|
339
|
-
return [3 /*break*/, 3];
|
|
340
|
-
case 2:
|
|
341
|
-
_c = undefined;
|
|
342
|
-
_d.label = 3;
|
|
343
|
-
case 3:
|
|
344
|
-
response = _c;
|
|
345
|
-
nodeTransactions = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.data) || [];
|
|
346
|
-
next = (0, module_kit_1.normalizeToUndefined)((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.next);
|
|
347
|
-
transactions = nodeTransactions.map(function (obj) {
|
|
348
|
-
var parsedTimestamp = parseInt(obj.micro_time, 10);
|
|
349
|
-
return {
|
|
350
|
-
from: [obj.tx.sender_id],
|
|
351
|
-
to: [obj.tx.recipient_id],
|
|
352
|
-
isInbound: address === obj.tx.recipient_id,
|
|
353
|
-
amount: (0, module_kit_1.newAmount)(obj.tx.amount, 'blockchain'),
|
|
354
|
-
fee: (0, module_kit_1.newAmount)(obj.tx.fee, 'blockchain'),
|
|
355
|
-
network: _this.options.network,
|
|
356
|
-
timestamp: !isNaN(parsedTimestamp) ? Math.round(parsedTimestamp / 1000) : undefined,
|
|
357
|
-
status: {
|
|
358
|
-
type: 'unknown',
|
|
359
|
-
hash: obj.hash,
|
|
360
|
-
block: obj.block_height
|
|
361
|
-
},
|
|
362
|
-
details: obj.tx.payload ? [(0, module_kit_1.newPlainUIText)('Payload'), obj.tx.payload] : undefined
|
|
363
|
-
};
|
|
364
|
-
});
|
|
365
|
-
return [2 /*return*/, {
|
|
366
|
-
transactions: transactions,
|
|
367
|
-
cursor: {
|
|
368
|
-
hasNext: next !== undefined,
|
|
369
|
-
next: next
|
|
370
|
-
}
|
|
371
|
-
}];
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
};
|
|
376
|
-
AeternityProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
377
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
378
|
-
var address;
|
|
379
|
-
return __generator(this, function (_a) {
|
|
380
|
-
switch (_a.label) {
|
|
381
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
382
|
-
case 1:
|
|
383
|
-
address = _a.sent();
|
|
384
|
-
return [2 /*return*/, this.getBalanceOfAddress(address)];
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
};
|
|
389
|
-
AeternityProtocolImpl.prototype.getBalanceOfAddress = function (address) {
|
|
390
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
391
|
-
var balance, data, error_1;
|
|
392
|
-
return __generator(this, function (_a) {
|
|
393
|
-
switch (_a.label) {
|
|
394
|
-
case 0:
|
|
395
|
-
_a.trys.push([0, 2, , 3]);
|
|
396
|
-
return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/v2/accounts/").concat(address))];
|
|
397
|
-
case 1:
|
|
398
|
-
data = (_a.sent()).data;
|
|
399
|
-
balance = new bignumber_1.default(data.balance);
|
|
400
|
-
return [3 /*break*/, 3];
|
|
401
|
-
case 2:
|
|
402
|
-
error_1 = _a.sent();
|
|
403
|
-
// if node returns 404 (which means 'no account found'), go with 0 balance
|
|
404
|
-
if (error_1.response && error_1.response.status !== 404) {
|
|
405
|
-
throw new errors_1.NetworkError(coinlib_core_1.Domain.AETERNITY, error_1);
|
|
406
|
-
}
|
|
407
|
-
balance = new bignumber_1.default(0);
|
|
408
|
-
return [3 /*break*/, 3];
|
|
409
|
-
case 3: return [2 /*return*/, { total: (0, module_kit_1.newAmount)(balance.toString(10), 'blockchain') }];
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
};
|
|
414
|
-
AeternityProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
|
|
415
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
416
|
-
var balance, balanceBn, fee, transactionDetails, feeEstimation, amountWithoutFees;
|
|
417
|
-
return __generator(this, function (_a) {
|
|
418
|
-
switch (_a.label) {
|
|
419
|
-
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
420
|
-
case 1:
|
|
421
|
-
balance = _a.sent();
|
|
422
|
-
balanceBn = new bignumber_1.default((0, module_kit_1.newAmount)(balance.total).blockchain(this.units).value);
|
|
423
|
-
if (!((configuration === null || configuration === void 0 ? void 0 : configuration.fee) !== undefined)) return [3 /*break*/, 2];
|
|
424
|
-
fee = new bignumber_1.default((0, module_kit_1.newAmount)(configuration.fee).blockchain(this.units).value);
|
|
425
|
-
return [3 /*break*/, 4];
|
|
426
|
-
case 2:
|
|
427
|
-
transactionDetails = to.map(function (address) { return ({
|
|
428
|
-
to: address,
|
|
429
|
-
amount: (0, module_kit_1.newAmount)(balanceBn.div(to.length).toString(), 'blockchain')
|
|
430
|
-
}); });
|
|
431
|
-
return [4 /*yield*/, this.getTransactionFeeWithPublicKey(publicKey, transactionDetails)];
|
|
432
|
-
case 3:
|
|
433
|
-
feeEstimation = _a.sent();
|
|
434
|
-
fee = new bignumber_1.default((0, module_kit_1.newAmount)(feeEstimation.medium).blockchain(this.units).value);
|
|
435
|
-
if (fee.gte(balanceBn)) {
|
|
436
|
-
fee = new bignumber_1.default(0);
|
|
437
|
-
}
|
|
438
|
-
_a.label = 4;
|
|
439
|
-
case 4:
|
|
440
|
-
amountWithoutFees = balanceBn.minus(fee);
|
|
441
|
-
if (amountWithoutFees.isNegative()) {
|
|
442
|
-
amountWithoutFees = new bignumber_1.default(0);
|
|
443
|
-
}
|
|
444
|
-
return [2 /*return*/, (0, module_kit_1.newAmount)(amountWithoutFees.toFixed(), 'blockchain')];
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
};
|
|
449
|
-
AeternityProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (_publicKey, _details, _configuration) {
|
|
450
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
451
|
-
var feeDetaults;
|
|
452
|
-
return __generator(this, function (_a) {
|
|
453
|
-
switch (_a.label) {
|
|
454
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.options.network.feesUrl)];
|
|
455
|
-
case 1:
|
|
456
|
-
feeDetaults = (_a.sent()).data;
|
|
457
|
-
return [2 /*return*/, {
|
|
458
|
-
low: (0, module_kit_1.newAmount)(feeDetaults.low, 'AE').blockchain(this.units),
|
|
459
|
-
medium: (0, module_kit_1.newAmount)(feeDetaults.medium, 'AE').blockchain(this.units),
|
|
460
|
-
high: (0, module_kit_1.newAmount)(feeDetaults.high, 'AE').blockchain(this.units)
|
|
461
|
-
}];
|
|
462
|
-
}
|
|
463
|
-
});
|
|
197
|
+
async getNetwork() {
|
|
198
|
+
return this.options.network;
|
|
199
|
+
}
|
|
200
|
+
async getTransactionsForPublicKey(publicKey, limit, cursor) {
|
|
201
|
+
const address = await this.getAddressFromPublicKey(publicKey);
|
|
202
|
+
return this.getTransactionsForAddress(address, limit, cursor);
|
|
203
|
+
}
|
|
204
|
+
async getTransactionsForAddress(address, limit, cursor) {
|
|
205
|
+
const endpoint = cursor === undefined ? `/txs/backward?account=${address}&limit=${limit}` : cursor.next;
|
|
206
|
+
const url = endpoint !== undefined ? `${this.options.network.rpcUrl}/mdw/${endpoint.replace(/^\/+/, '')}` : undefined;
|
|
207
|
+
const response = url !== undefined ? await index_1.default.get(url) : undefined;
|
|
208
|
+
const nodeTransactions = response?.data?.data || [];
|
|
209
|
+
const next = (0, module_kit_1.normalizeToUndefined)(response?.data?.next);
|
|
210
|
+
const transactions = nodeTransactions.map((obj) => {
|
|
211
|
+
const parsedTimestamp = parseInt(obj.micro_time, 10);
|
|
212
|
+
return {
|
|
213
|
+
from: [obj.tx.sender_id],
|
|
214
|
+
to: [obj.tx.recipient_id],
|
|
215
|
+
isInbound: address === obj.tx.recipient_id,
|
|
216
|
+
amount: (0, module_kit_1.newAmount)(obj.tx.amount, 'blockchain'),
|
|
217
|
+
fee: (0, module_kit_1.newAmount)(obj.tx.fee, 'blockchain'),
|
|
218
|
+
network: this.options.network,
|
|
219
|
+
timestamp: !isNaN(parsedTimestamp) ? Math.round(parsedTimestamp / 1000) : undefined,
|
|
220
|
+
status: {
|
|
221
|
+
type: 'unknown',
|
|
222
|
+
hash: obj.hash,
|
|
223
|
+
block: obj.block_height
|
|
224
|
+
},
|
|
225
|
+
details: obj.tx.payload ? [(0, module_kit_1.newPlainUIText)('Payload'), obj.tx.payload] : undefined
|
|
226
|
+
};
|
|
464
227
|
});
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
228
|
+
return {
|
|
229
|
+
transactions,
|
|
230
|
+
cursor: {
|
|
231
|
+
hasNext: next !== undefined,
|
|
232
|
+
next
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
async getBalanceOfPublicKey(publicKey) {
|
|
237
|
+
const address = await this.getAddressFromPublicKey(publicKey);
|
|
238
|
+
return this.getBalanceOfAddress(address);
|
|
239
|
+
}
|
|
240
|
+
async getBalanceOfAddress(address) {
|
|
241
|
+
let balance;
|
|
242
|
+
try {
|
|
243
|
+
const { data } = await index_1.default.get(`${this.options.network.rpcUrl}/v2/accounts/${address}`);
|
|
244
|
+
balance = new bignumber_1.default(data.balance);
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
// if node returns 404 (which means 'no account found'), go with 0 balance
|
|
248
|
+
if (error.response && error.response.status !== 404) {
|
|
249
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.AETERNITY, error);
|
|
250
|
+
}
|
|
251
|
+
balance = new bignumber_1.default(0);
|
|
252
|
+
}
|
|
253
|
+
return { total: (0, module_kit_1.newAmount)(balance.toString(10), 'blockchain') };
|
|
254
|
+
}
|
|
255
|
+
async getTransactionMaxAmountWithPublicKey(publicKey, to, configuration) {
|
|
256
|
+
const balance = await this.getBalanceOfPublicKey(publicKey);
|
|
257
|
+
const balanceBn = new bignumber_1.default((0, module_kit_1.newAmount)(balance.total).blockchain(this.units).value);
|
|
258
|
+
let fee;
|
|
259
|
+
if (configuration?.fee !== undefined) {
|
|
260
|
+
fee = new bignumber_1.default((0, module_kit_1.newAmount)(configuration.fee).blockchain(this.units).value);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const transactionDetails = to.map((address) => ({
|
|
264
|
+
to: address,
|
|
265
|
+
amount: (0, module_kit_1.newAmount)(balanceBn.div(to.length).toString(), 'blockchain')
|
|
266
|
+
}));
|
|
267
|
+
const feeEstimation = await this.getTransactionFeeWithPublicKey(publicKey, transactionDetails);
|
|
268
|
+
fee = new bignumber_1.default((0, module_kit_1.newAmount)(feeEstimation.medium).blockchain(this.units).value);
|
|
269
|
+
if (fee.gte(balanceBn)) {
|
|
270
|
+
fee = new bignumber_1.default(0);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
let amountWithoutFees = balanceBn.minus(fee);
|
|
274
|
+
if (amountWithoutFees.isNegative()) {
|
|
275
|
+
amountWithoutFees = new bignumber_1.default(0);
|
|
276
|
+
}
|
|
277
|
+
return (0, module_kit_1.newAmount)(amountWithoutFees.toFixed(), 'blockchain');
|
|
278
|
+
}
|
|
279
|
+
async getTransactionFeeWithPublicKey(_publicKey, _details, _configuration) {
|
|
280
|
+
const feeDetaults = (await index_1.default.get(this.options.network.feesUrl)).data;
|
|
281
|
+
return {
|
|
282
|
+
low: (0, module_kit_1.newAmount)(feeDetaults.low, 'AE').blockchain(this.units),
|
|
283
|
+
medium: (0, module_kit_1.newAmount)(feeDetaults.medium, 'AE').blockchain(this.units),
|
|
284
|
+
high: (0, module_kit_1.newAmount)(feeDetaults.high, 'AE').blockchain(this.units)
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
async prepareTransactionWithPublicKey(publicKey, details, configuration) {
|
|
288
|
+
// should we support multiple transactions here?
|
|
289
|
+
let nonce = 1;
|
|
290
|
+
const address = await this.getAddressFromPublicKey(publicKey);
|
|
291
|
+
try {
|
|
292
|
+
const { data: accountResponse } = await index_1.default.get(`${this.options.network.rpcUrl}/v2/accounts/${address}`);
|
|
293
|
+
nonce = accountResponse.nonce + 1;
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
// if node returns 404 (which means 'no account found'), go with nonce 0
|
|
297
|
+
if (error.response && error.response.status !== 404) {
|
|
298
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.AETERNITY, error);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const balance = (0, module_kit_1.newAmount)((await this.getBalanceOfPublicKey(publicKey)).total).blockchain(this.units);
|
|
302
|
+
const balanceBn = new bignumber_1.default(balance.value);
|
|
303
|
+
const feeBn = configuration?.fee !== undefined
|
|
304
|
+
? new bignumber_1.default((0, module_kit_1.newAmount)(configuration.fee).blockchain(this.units).value)
|
|
305
|
+
: new bignumber_1.default((0, module_kit_1.newAmount)(this.feeDefaults.medium).blockchain(this.units).value);
|
|
306
|
+
if (balanceBn.isLessThan(feeBn)) {
|
|
307
|
+
throw new errors_1.BalanceError(coinlib_core_1.Domain.AETERNITY, 'not enough balance');
|
|
308
|
+
}
|
|
309
|
+
const sender = (0, key_1.convertPublicKey)(publicKey, 'hex').value;
|
|
310
|
+
const recipient = (0, key_1.convertPublicKey)(AeternityAddress_1.AeternityAddress.from(details[0].to).toPublicKey(), 'hex').value;
|
|
311
|
+
const value = new bignumber_1.default((0, module_kit_1.newAmount)(details[0].amount).blockchain(this.units).value);
|
|
312
|
+
const payload = details[0].arbitraryData || '';
|
|
313
|
+
const txObj = {
|
|
314
|
+
tag: (0, hex_1.toHexBuffer)(12),
|
|
315
|
+
version: (0, hex_1.toHexBuffer)(1),
|
|
316
|
+
sender_id: Buffer.concat([(0, hex_1.toHexBuffer)(1), Buffer.from(sender, 'hex')]),
|
|
317
|
+
recipient_id: Buffer.concat([(0, hex_1.toHexBuffer)(1), Buffer.from(recipient, 'hex')]),
|
|
318
|
+
amount: (0, hex_1.toHexBuffer)(value),
|
|
319
|
+
fee: (0, hex_1.toHexBuffer)(feeBn),
|
|
320
|
+
ttl: (0, hex_1.toHexBuffer)(0),
|
|
321
|
+
nonce: (0, hex_1.toHexBuffer)(nonce),
|
|
322
|
+
payload: Buffer.from(payload)
|
|
323
|
+
};
|
|
324
|
+
const txArray = Object.keys(txObj).map((a) => txObj[a]);
|
|
325
|
+
const rlpEncodedTx = rlp.encode(txArray);
|
|
326
|
+
const preparedTx = (0, transaction_1.encodeTx)(rlpEncodedTx);
|
|
327
|
+
return (0, module_kit_1.newUnsignedTransaction)({
|
|
328
|
+
transaction: preparedTx,
|
|
329
|
+
networkId: this.networkId()
|
|
527
330
|
});
|
|
528
|
-
}
|
|
529
|
-
|
|
331
|
+
}
|
|
332
|
+
networkId() {
|
|
530
333
|
switch (this.options.network.type) {
|
|
531
334
|
case 'mainnet':
|
|
532
335
|
return 'ae_mainnet';
|
|
533
336
|
default:
|
|
534
337
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Network type not supported.');
|
|
535
338
|
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
switch (_a.label) {
|
|
542
|
-
case 0: return [4 /*yield*/, index_1.default.post("".concat(this.options.network.rpcUrl, "/v2/transactions"), { tx: transaction.transaction }, { headers: { 'Content-Type': 'application/json' } })];
|
|
543
|
-
case 1:
|
|
544
|
-
data = (_a.sent()).data;
|
|
545
|
-
return [2 /*return*/, data.tx_hash];
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
});
|
|
549
|
-
};
|
|
339
|
+
}
|
|
340
|
+
async broadcastTransaction(transaction) {
|
|
341
|
+
const { data } = await index_1.default.post(`${this.options.network.rpcUrl}/v2/transactions`, { tx: transaction.transaction }, { headers: { 'Content-Type': 'application/json' } });
|
|
342
|
+
return data.tx_hash;
|
|
343
|
+
}
|
|
550
344
|
// Custom
|
|
551
|
-
|
|
552
|
-
return
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
transaction: bs58check.encode(base64Check_1.default.decode(preparedTx.transaction)),
|
|
556
|
-
networkId: preparedTx.networkId
|
|
557
|
-
})];
|
|
558
|
-
});
|
|
345
|
+
async convertTransactionToBase58(preparedTx) {
|
|
346
|
+
return (0, module_kit_1.newUnsignedTransaction)({
|
|
347
|
+
transaction: bs58check.encode(base64Check_1.default.decode(preparedTx.transaction)),
|
|
348
|
+
networkId: preparedTx.networkId
|
|
559
349
|
});
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
}());
|
|
350
|
+
}
|
|
351
|
+
}
|
|
563
352
|
exports.AeternityProtocolImpl = AeternityProtocolImpl;
|
|
564
353
|
// Factory
|
|
565
|
-
function createAeternityProtocol(options) {
|
|
566
|
-
if (options === void 0) { options = {}; }
|
|
354
|
+
function createAeternityProtocol(options = {}) {
|
|
567
355
|
return new AeternityProtocolImpl(options);
|
|
568
356
|
}
|
|
569
|
-
exports.createAeternityProtocol = createAeternityProtocol;
|
|
570
357
|
exports.AETERNITY_MAINNET_PROTOCOL_NETWORK = {
|
|
571
358
|
name: 'Mainnet',
|
|
572
359
|
type: 'mainnet',
|
|
@@ -574,12 +361,10 @@ exports.AETERNITY_MAINNET_PROTOCOL_NETWORK = {
|
|
|
574
361
|
blockExplorerUrl: 'https://explorer.aeternity.io',
|
|
575
362
|
feesUrl: 'https://api-airgap.gke.papers.tech/fees'
|
|
576
363
|
};
|
|
577
|
-
|
|
578
|
-
function createAeternityProtocolOptions(network) {
|
|
579
|
-
if (network === void 0) { network = {}; }
|
|
364
|
+
const DEFAULT_AETERNITY_PROTOCOL_NETWORK = exports.AETERNITY_MAINNET_PROTOCOL_NETWORK;
|
|
365
|
+
function createAeternityProtocolOptions(network = {}) {
|
|
580
366
|
return {
|
|
581
|
-
network:
|
|
367
|
+
network: { ...DEFAULT_AETERNITY_PROTOCOL_NETWORK, ...network }
|
|
582
368
|
};
|
|
583
369
|
}
|
|
584
|
-
exports.createAeternityProtocolOptions = createAeternityProtocolOptions;
|
|
585
370
|
//# sourceMappingURL=AeternityProtocol.js.map
|