UNPKG

@airgap/aeternity

Version:

The @airgap/aeternity is an Aeternity implementation of the ICoinProtocol interface from @airgap/coinlib-core.

585 lines 31.9 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { 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; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createAeternityProtocolOptions = exports.AETERNITY_MAINNET_PROTOCOL_NETWORK = exports.createAeternityProtocol = exports.AeternityProtocolImpl = void 0; var coinlib_core_1 = require("@airgap/coinlib-core"); var index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index")); var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber")); var bs58check = __importStar(require("@airgap/coinlib-core/dependencies/src/bs58check-2.1.2/index")); var rlp = __importStar(require("@airgap/coinlib-core/dependencies/src/rlp-2.2.3/index")); var errors_1 = require("@airgap/coinlib-core/errors"); var base64Check_1 = __importDefault(require("@airgap/coinlib-core/utils/base64Check")); var hex_1 = require("@airgap/coinlib-core/utils/hex"); var module_kit_1 = require("@airgap/module-kit"); var ed25519_1 = require("@stablelib/ed25519"); var AeternityAddress_1 = require("../data/AeternityAddress"); var key_1 = require("../utils/key"); var signature_1 = require("../utils/signature"); var transaction_1 = require("../utils/transaction"); var AeternityCryptoClient_1 = require("./AeternityCryptoClient"); // Implementation var AeternityProtocolImpl = /** @class */ (function () { function AeternityProtocolImpl(options) { if (options === void 0) { options = {}; } // Common this.units = { AE: { symbol: { value: 'AE', market: 'ae' }, decimals: 18 } }; this.feeDefaults = { low: (0, module_kit_1.newAmount)(0.00021, 'AE').blockchain(this.units), medium: (0, module_kit_1.newAmount)(0.000315, 'AE').blockchain(this.units), high: (0, module_kit_1.newAmount)(0.00084, 'AE').blockchain(this.units) }; this.metadata = { identifier: coinlib_core_1.MainProtocolSymbols.AE, name: 'æternity', units: this.units, mainUnit: 'AE', fee: { defaults: this.feeDefaults }, account: { standardDerivationPath: "m/44h/457h/0h/0h/0h", address: { isCaseSensitive: true, placeholder: 'ak_abc...', regex: '^ak_+[1-9A-Za-z]{38,50}$' } }, transaction: { arbitraryData: { inner: { name: 'payload' } } } }; // Offline this.cryptoConfiguration = { algorithm: 'ed25519' }; this.options = createAeternityProtocolOptions(options.network); this.cryptoClient = new AeternityCryptoClient_1.AeternityCryptoClient(); } AeternityProtocolImpl.prototype.getMetadata = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, this.metadata]; }); }); }; AeternityProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, AeternityAddress_1.AeternityAddress.from(publicKey).asString()]; }); }); }; AeternityProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, _publicKey) { return __awaiter(this, void 0, void 0, function () { var rlpEncodedTx, rlpDecodedTx; return __generator(this, function (_a) { switch (transaction.type) { case 'signed': rlpEncodedTx = (0, transaction_1.decodeTx)(transaction.transaction); rlpDecodedTx = rlp.decode(rlpEncodedTx, false); return [2 /*return*/, this.getDetailsFromEncodedTransaction("tx_".concat(base64Check_1.default.encode(rlpDecodedTx[3])))]; case 'unsigned': return [2 /*return*/, this.getDetailsFromEncodedTransaction(transaction.transaction)]; default: (0, coinlib_core_1.assertNever)(transaction); throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, 'Unsupported transaction type.'); } return [2 /*return*/]; }); }); }; AeternityProtocolImpl.prototype.getDetailsFromEncodedTransaction = function (tx) { return __awaiter(this, void 0, void 0, function () { var rlpEncodedTx, rlpDecodedTx, from, to, airgapTx; return __generator(this, function (_a) { switch (_a.label) { case 0: rlpEncodedTx = (0, transaction_1.decodeTx)(tx); rlpDecodedTx = rlp.decode(rlpEncodedTx, false); return [4 /*yield*/, this.getAddressFromPublicKey((0, module_kit_1.newPublicKey)(rlpDecodedTx[2].slice(1).toString('hex'), 'hex'))]; case 1: from = _a.sent(); return [4 /*yield*/, this.getAddressFromPublicKey((0, module_kit_1.newPublicKey)(rlpDecodedTx[3].slice(1).toString('hex'), 'hex'))]; case 2: to = _a.sent(); airgapTx = { from: [from], to: [to], isInbound: false, amount: (0, module_kit_1.newAmount)(parseInt(rlpDecodedTx[4].toString('hex'), 16), 'blockchain'), fee: (0, module_kit_1.newAmount)(parseInt(rlpDecodedTx[5].toString('hex'), 16), 'blockchain'), network: this.options.network, arbitraryData: (rlpDecodedTx[8] || '').toString('utf8') }; return [2 /*return*/, [airgapTx]]; } }); }); }; AeternityProtocolImpl.prototype.verifyMessageWithPublicKey = function (message, signature, publicKey) { return __awaiter(this, void 0, void 0, function () { var hexSignature, hexPublicKey; return __generator(this, function (_a) { hexSignature = (0, signature_1.convertSignature)(signature, 'hex'); hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex'); return [2 /*return*/, this.cryptoClient.verifyMessage(message, hexSignature.value, hexPublicKey.value)]; }); }); }; AeternityProtocolImpl.prototype.encryptAsymmetricWithPublicKey = function (payload, publicKey) { return __awaiter(this, void 0, void 0, function () { var hexPublicKey; return __generator(this, function (_a) { hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex'); return [2 /*return*/, this.cryptoClient.encryptAsymmetric(payload, hexPublicKey.value)]; }); }); }; AeternityProtocolImpl.prototype.getCryptoConfiguration = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, this.cryptoConfiguration]; }); }); }; AeternityProtocolImpl.prototype.getKeyPairFromDerivative = function (derivative) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, { secretKey: (0, module_kit_1.newSecretKey)(Buffer.concat([Buffer.from(derivative.secretKey, 'hex'), Buffer.from(derivative.publicKey, 'hex')]).toString('hex'), 'hex'), publicKey: (0, module_kit_1.newPublicKey)(derivative.publicKey, 'hex') }]; }); }); }; AeternityProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) { return __awaiter(this, void 0, void 0, function () { var rawTx, signature, txObj, txArray, rlpEncodedTx, signedEncodedTx; return __generator(this, function (_a) { if (secretKey.format !== 'hex') { throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.'); } rawTx = (0, transaction_1.decodeTx)(transaction.transaction); signature = (0, ed25519_1.sign)(Buffer.from(secretKey.value, 'hex'), Buffer.concat([Buffer.from(transaction.networkId), rawTx])); txObj = { tag: (0, hex_1.toHexBuffer)(11), version: (0, hex_1.toHexBuffer)(1), signatures: [Buffer.from(signature)], transaction: rawTx }; txArray = Object.keys(txObj).map(function (a) { return txObj[a]; }); rlpEncodedTx = rlp.encode(txArray); signedEncodedTx = "tx_".concat(base64Check_1.default.encode(rlpEncodedTx)); return [2 /*return*/, (0, module_kit_1.newSignedTransaction)({ transaction: signedEncodedTx })]; }); }); }; AeternityProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) { return __awaiter(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) { switch (_b.label) { case 0: if (keyPair.secretKey.format !== 'hex') { throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.'); } _a = module_kit_1.newSignature; return [4 /*yield*/, this.cryptoClient.signMessage(message, { privateKey: keyPair.secretKey.value })]; case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), 'hex'])]; } }); }); }; AeternityProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) { return __awaiter(this, void 0, void 0, function () { var hexPublicKey; return __generator(this, function (_a) { if (keyPair.secretKey.format !== 'hex') { throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.'); } hexPublicKey = (0, key_1.convertPublicKey)(keyPair.publicKey, 'hex'); return [2 /*return*/, this.cryptoClient.decryptAsymmetric(payload, { publicKey: hexPublicKey.value, privateKey: keyPair.secretKey.value })]; }); }); }; AeternityProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { if (secretKey.format !== 'hex') { throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.'); } return [2 /*return*/, this.cryptoClient.encryptAES(payload, secretKey.value)]; }); }); }; AeternityProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { if (secretKey.format !== 'hex') { throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Secret key is of an unexpected format.'); } return [2 /*return*/, this.cryptoClient.decryptAES(payload, secretKey.value)]; }); }); }; // Online AeternityProtocolImpl.prototype.getNetwork = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, this.options.network]; }); }); }; AeternityProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) { return __awaiter(this, void 0, void 0, function () { var address; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)]; case 1: address = _a.sent(); return [2 /*return*/, this.getTransactionsForAddress(address, limit, cursor)]; } }); }); }; AeternityProtocolImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) { var _a, _b; return __awaiter(this, void 0, void 0, function () { var endpoint, url, response, _c, nodeTransactions, next, transactions; var _this = this; return __generator(this, function (_d) { switch (_d.label) { case 0: endpoint = cursor === undefined ? "/txs/backward?account=".concat(address, "&limit=").concat(limit) : cursor.next; url = endpoint !== undefined ? "".concat(this.options.network.rpcUrl, "/mdw/").concat(endpoint.replace(/^\/+/, '')) : undefined; if (!(url !== undefined)) return [3 /*break*/, 2]; return [4 /*yield*/, index_1.default.get(url)]; case 1: _c = _d.sent(); return [3 /*break*/, 3]; case 2: _c = undefined; _d.label = 3; case 3: response = _c; nodeTransactions = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.data) || []; next = (0, module_kit_1.normalizeToUndefined)((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.next); transactions = nodeTransactions.map(function (obj) { var parsedTimestamp = parseInt(obj.micro_time, 10); return { from: [obj.tx.sender_id], to: [obj.tx.recipient_id], isInbound: address === obj.tx.recipient_id, amount: (0, module_kit_1.newAmount)(obj.tx.amount, 'blockchain'), fee: (0, module_kit_1.newAmount)(obj.tx.fee, 'blockchain'), network: _this.options.network, timestamp: !isNaN(parsedTimestamp) ? Math.round(parsedTimestamp / 1000) : undefined, status: { type: 'unknown', hash: obj.hash, block: obj.block_height }, details: obj.tx.payload ? [(0, module_kit_1.newPlainUIText)('Payload'), obj.tx.payload] : undefined }; }); return [2 /*return*/, { transactions: transactions, cursor: { hasNext: next !== undefined, next: next } }]; } }); }); }; AeternityProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) { return __awaiter(this, void 0, void 0, function () { var address; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)]; case 1: address = _a.sent(); return [2 /*return*/, this.getBalanceOfAddress(address)]; } }); }); }; AeternityProtocolImpl.prototype.getBalanceOfAddress = function (address) { return __awaiter(this, void 0, void 0, function () { var balance, data, error_1; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/v2/accounts/").concat(address))]; case 1: data = (_a.sent()).data; balance = new bignumber_1.default(data.balance); return [3 /*break*/, 3]; case 2: error_1 = _a.sent(); // if node returns 404 (which means 'no account found'), go with 0 balance if (error_1.response && error_1.response.status !== 404) { throw new errors_1.NetworkError(coinlib_core_1.Domain.AETERNITY, error_1); } balance = new bignumber_1.default(0); return [3 /*break*/, 3]; case 3: return [2 /*return*/, { total: (0, module_kit_1.newAmount)(balance.toString(10), 'blockchain') }]; } }); }); }; AeternityProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) { return __awaiter(this, void 0, void 0, function () { var balance, balanceBn, fee, transactionDetails, feeEstimation, amountWithoutFees; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)]; case 1: balance = _a.sent(); balanceBn = new bignumber_1.default((0, module_kit_1.newAmount)(balance.total).blockchain(this.units).value); if (!((configuration === null || configuration === void 0 ? void 0 : configuration.fee) !== undefined)) return [3 /*break*/, 2]; fee = new bignumber_1.default((0, module_kit_1.newAmount)(configuration.fee).blockchain(this.units).value); return [3 /*break*/, 4]; case 2: transactionDetails = to.map(function (address) { return ({ to: address, amount: (0, module_kit_1.newAmount)(balanceBn.div(to.length).toString(), 'blockchain') }); }); return [4 /*yield*/, this.getTransactionFeeWithPublicKey(publicKey, transactionDetails)]; case 3: feeEstimation = _a.sent(); fee = new bignumber_1.default((0, module_kit_1.newAmount)(feeEstimation.medium).blockchain(this.units).value); if (fee.gte(balanceBn)) { fee = new bignumber_1.default(0); } _a.label = 4; case 4: amountWithoutFees = balanceBn.minus(fee); if (amountWithoutFees.isNegative()) { amountWithoutFees = new bignumber_1.default(0); } return [2 /*return*/, (0, module_kit_1.newAmount)(amountWithoutFees.toFixed(), 'blockchain')]; } }); }); }; AeternityProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (_publicKey, _details, _configuration) { return __awaiter(this, void 0, void 0, function () { var feeDetaults; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, index_1.default.get(this.options.network.feesUrl)]; case 1: feeDetaults = (_a.sent()).data; return [2 /*return*/, { low: (0, module_kit_1.newAmount)(feeDetaults.low, 'AE').blockchain(this.units), medium: (0, module_kit_1.newAmount)(feeDetaults.medium, 'AE').blockchain(this.units), high: (0, module_kit_1.newAmount)(feeDetaults.high, 'AE').blockchain(this.units) }]; } }); }); }; AeternityProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) { return __awaiter(this, void 0, void 0, function () { var nonce, address, accountResponse, error_2, balance, _a, balanceBn, feeBn, sender, recipient, value, payload, txObj, txArray, rlpEncodedTx, preparedTx; return __generator(this, function (_b) { switch (_b.label) { case 0: nonce = 1; return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)]; case 1: address = _b.sent(); _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/v2/accounts/").concat(address))]; case 3: accountResponse = (_b.sent()).data; nonce = accountResponse.nonce + 1; return [3 /*break*/, 5]; case 4: error_2 = _b.sent(); // if node returns 404 (which means 'no account found'), go with nonce 0 if (error_2.response && error_2.response.status !== 404) { throw new errors_1.NetworkError(coinlib_core_1.Domain.AETERNITY, error_2); } return [3 /*break*/, 5]; case 5: _a = module_kit_1.newAmount; return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)]; case 6: balance = _a.apply(void 0, [(_b.sent()).total]).blockchain(this.units); balanceBn = new bignumber_1.default(balance.value); feeBn = (configuration === null || configuration === void 0 ? void 0 : configuration.fee) !== undefined ? new bignumber_1.default((0, module_kit_1.newAmount)(configuration.fee).blockchain(this.units).value) : new bignumber_1.default((0, module_kit_1.newAmount)(this.feeDefaults.medium).blockchain(this.units).value); if (balanceBn.isLessThan(feeBn)) { throw new errors_1.BalanceError(coinlib_core_1.Domain.AETERNITY, 'not enough balance'); } sender = (0, key_1.convertPublicKey)(publicKey, 'hex').value; recipient = (0, key_1.convertPublicKey)(AeternityAddress_1.AeternityAddress.from(details[0].to).toPublicKey(), 'hex').value; value = new bignumber_1.default((0, module_kit_1.newAmount)(details[0].amount).blockchain(this.units).value); payload = details[0].arbitraryData || ''; txObj = { tag: (0, hex_1.toHexBuffer)(12), version: (0, hex_1.toHexBuffer)(1), sender_id: Buffer.concat([(0, hex_1.toHexBuffer)(1), Buffer.from(sender, 'hex')]), recipient_id: Buffer.concat([(0, hex_1.toHexBuffer)(1), Buffer.from(recipient, 'hex')]), amount: (0, hex_1.toHexBuffer)(value), fee: (0, hex_1.toHexBuffer)(feeBn), ttl: (0, hex_1.toHexBuffer)(0), nonce: (0, hex_1.toHexBuffer)(nonce), payload: Buffer.from(payload) }; txArray = Object.keys(txObj).map(function (a) { return txObj[a]; }); rlpEncodedTx = rlp.encode(txArray); preparedTx = (0, transaction_1.encodeTx)(rlpEncodedTx); return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ transaction: preparedTx, networkId: this.networkId() })]; } }); }); }; AeternityProtocolImpl.prototype.networkId = function () { switch (this.options.network.type) { case 'mainnet': return 'ae_mainnet'; default: throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Network type not supported.'); } }; AeternityProtocolImpl.prototype.broadcastTransaction = function (transaction) { return __awaiter(this, void 0, void 0, function () { var data; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, index_1.default.post("".concat(this.options.network.rpcUrl, "/v2/transactions"), { tx: transaction.transaction }, { headers: { 'Content-Type': 'application/json' } })]; case 1: data = (_a.sent()).data; return [2 /*return*/, data.tx_hash]; } }); }); }; // Custom AeternityProtocolImpl.prototype.convertTransactionToBase58 = function (preparedTx) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ transaction: bs58check.encode(base64Check_1.default.decode(preparedTx.transaction)), networkId: preparedTx.networkId })]; }); }); }; return AeternityProtocolImpl; }()); exports.AeternityProtocolImpl = AeternityProtocolImpl; // Factory function createAeternityProtocol(options) { if (options === void 0) { options = {}; } return new AeternityProtocolImpl(options); } exports.createAeternityProtocol = createAeternityProtocol; exports.AETERNITY_MAINNET_PROTOCOL_NETWORK = { name: 'Mainnet', type: 'mainnet', rpcUrl: 'https://mainnet.aeternity.io', blockExplorerUrl: 'https://explorer.aeternity.io', feesUrl: 'https://api-airgap.gke.papers.tech/fees' }; var DEFAULT_AETERNITY_PROTOCOL_NETWORK = exports.AETERNITY_MAINNET_PROTOCOL_NETWORK; function createAeternityProtocolOptions(network) { if (network === void 0) { network = {}; } return { network: __assign(__assign({}, DEFAULT_AETERNITY_PROTOCOL_NETWORK), network) }; } exports.createAeternityProtocolOptions = createAeternityProtocolOptions; //# sourceMappingURL=AeternityProtocol.js.map