UNPKG

@dojima-wallet/transfer

Version:

Transfer assets from account to account

59 lines (45 loc) 73.4 kB
/* * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). * This devtool is neither made for production nor for readable output files. * It uses "eval()" calls to create a separate source file in the browser devtools. * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) * or disable the default devtool with "devtool: false". * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). */ /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./lib/chains/arweave.ts": /*!*******************************!*\ !*** ./lib/chains/arweave.ts ***! \*******************************/ /***/ (function(__unused_webpack_module, exports, __webpack_require__) { eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar connection_1 = __webpack_require__(/*! @dojima-wallet/connection */ \"@dojima-wallet/connection\");\nvar utils_1 = __webpack_require__(/*! ./utils */ \"./lib/chains/utils.ts\");\nvar ArweaveChain = /** @class */ (function (_super) {\n __extends(ArweaveChain, _super);\n function ArweaveChain(mnemonic, network) {\n return _super.call(this, mnemonic, network) || this;\n }\n ArweaveChain.prototype.getGasFee = function (recipient, amount) {\n return __awaiter(this, void 0, void 0, function () {\n var rawTx, arw_gasFee, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.arConnect.createTransaction(recipient, amount)];\n case 1:\n rawTx = _a.sent();\n return [4 /*yield*/, this.arConnect.getFees(rawTx)];\n case 2:\n arw_gasFee = _a.sent();\n return [4 /*yield*/, (0, utils_1.getUsdtTokenPriceResult)(arw_gasFee, \"ar\")];\n case 3:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n ArweaveChain.prototype.transfer = function (recipient, amount) {\n return __awaiter(this, void 0, void 0, function () {\n var hash;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.arConnect.transfer({ recipient: recipient, amount: amount })];\n case 1:\n hash = _a.sent();\n return [2 /*return*/, hash];\n }\n });\n });\n };\n ArweaveChain.prototype.getSwapOutput = function (amount, pool, toDoj) {\n return this.arConnect.getSwapOutput(amount, pool, toDoj);\n };\n ArweaveChain.prototype.getDoubleSwapOutput = function (amount, pool1, pool2) {\n return this.arConnect.getDoubleSwapOutput(amount, pool1, pool2);\n };\n ArweaveChain.prototype.getSwapSlippage = function (amount, pool, toDoj) {\n return this.arConnect.getSwapSlip(amount, pool, toDoj) * 100;\n };\n ArweaveChain.prototype.getDoubleSwapSlippage = function (amount, pool1, pool2) {\n return this.arConnect.getDoubleSwapSlip(amount, pool1, pool2) * 100;\n };\n ArweaveChain.prototype.getDefaultLiquidityPoolGasFee = function (hermesApiUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var LPDefaultGasFee, arw_LPgasfee, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.arConnect.getDefaultLiquidityPoolGasFee(hermesApiUrl)];\n case 1:\n LPDefaultGasFee = _a.sent();\n arw_LPgasfee = {\n slow: LPDefaultGasFee,\n average: LPDefaultGasFee,\n fast: LPDefaultGasFee,\n };\n return [4 /*yield*/, (0, utils_1.getUsdtTokenPriceResult)(arw_LPgasfee, \"ar\")];\n case 2:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n ArweaveChain.prototype.addLiquidityPool = function (amount, hermesApiUrl, hermesAddress) {\n return __awaiter(this, void 0, void 0, function () {\n var inboundAddress, liquidityPoolHash, error_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3, , 4]);\n return [4 /*yield*/, this.arConnect.getArweaveInboundAddress(hermesApiUrl)];\n case 1:\n inboundAddress = _a.sent();\n return [4 /*yield*/, this.arConnect.addLiquidityPool(amount, inboundAddress, hermesAddress)];\n case 2:\n liquidityPoolHash = _a.sent();\n return [2 /*return*/, liquidityPoolHash];\n case 3:\n error_1 = _a.sent();\n return [2 /*return*/, Promise.reject(error_1)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n ArweaveChain.prototype.swap = function (amount, recipient, token, hermesApiUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var inboundAddress, swapHash, error_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3, , 4]);\n return [4 /*yield*/, this.arConnect.getArweaveInboundAddress(hermesApiUrl)];\n case 1:\n inboundAddress = _a.sent();\n return [4 /*yield*/, this.arConnect.swap(amount, token, inboundAddress, recipient)];\n case 2:\n swapHash = _a.sent();\n return [2 /*return*/, swapHash];\n case 3:\n error_2 = _a.sent();\n return [2 /*return*/, Promise.reject(error_2)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return ArweaveChain;\n}(connection_1.ArweaveInit));\nexports[\"default\"] = ArweaveChain;\n\n\n//# sourceURL=webpack://@dojima-wallet/transfer/./lib/chains/arweave.ts?"); /***/ }), /***/ "./lib/chains/dojima.ts": /*!******************************!*\ !*** ./lib/chains/dojima.ts ***! \******************************/ /***/ (function(__unused_webpack_module, exports, __webpack_require__) { eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar connection_1 = __webpack_require__(/*! @dojima-wallet/connection */ \"@dojima-wallet/connection\");\nvar utils_1 = __webpack_require__(/*! ./utils */ \"./lib/chains/utils.ts\");\nvar DojimaChain = /** @class */ (function (_super) {\n __extends(DojimaChain, _super);\n function DojimaChain(mnemonic, privateKey, network, rpcUrl) {\n return _super.call(this, mnemonic, privateKey, network, rpcUrl) || this;\n }\n DojimaChain.prototype.getGasFee = function (amount, memo) {\n return __awaiter(this, void 0, void 0, function () {\n var gasFee, gasFeeResult, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.dojConnect.calculateGasFee(this.dojConnect.getAddress(), amount, memo ? memo : undefined)];\n case 1:\n gasFee = _a.sent();\n gasFeeResult = {\n slow: parseFloat(gasFee),\n average: parseFloat(gasFee),\n fast: parseFloat(gasFee),\n };\n return [4 /*yield*/, (0, utils_1.getUsdtTokenPriceResult)(gasFeeResult, \"doj\")];\n case 2:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n DojimaChain.prototype.transfer = function (recipient, amount, gasPrice, memo) {\n return __awaiter(this, void 0, void 0, function () {\n var hash;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.dojConnect.transfer({\n recipient: recipient,\n amount: amount,\n fee: gasPrice ? gasPrice : undefined,\n memo: memo ? memo : undefined,\n })];\n case 1:\n hash = _a.sent();\n return [2 /*return*/, hash];\n }\n });\n });\n };\n DojimaChain.prototype.getSwapOutput = function (amount, pool, toDoj) {\n return this.dojConnect.getSwapOutput(amount, pool, toDoj);\n };\n DojimaChain.prototype.getDoubleSwapOutput = function (amount, pool1, pool2) {\n return this.dojConnect.getDoubleSwapOutput(amount, pool1, pool2);\n };\n DojimaChain.prototype.getSwapSlippage = function (amount, pool, toDoj) {\n return this.dojConnect.getSwapSlip(amount, pool, toDoj) * 100;\n };\n DojimaChain.prototype.getDoubleSwapSlippage = function (amount, pool1, pool2) {\n return this.dojConnect.getDoubleSwapSlip(amount, pool1, pool2) * 100;\n };\n DojimaChain.prototype.getDefaultLiquidityPoolGasFee = function (hermesApiUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var LPDefaultGasFee, eth_LPgasfee, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.dojConnect.getDefaultLiquidityPoolGasFee(hermesApiUrl)];\n case 1:\n LPDefaultGasFee = _a.sent();\n eth_LPgasfee = {\n slow: LPDefaultGasFee,\n average: LPDefaultGasFee,\n fast: LPDefaultGasFee,\n };\n return [4 /*yield*/, (0, utils_1.getUsdtTokenPriceResult)(eth_LPgasfee, \"doj\")];\n case 2:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n DojimaChain.prototype.addLiquidityPool = function (amount, hermesApiUrl, hermesAddress) {\n return __awaiter(this, void 0, void 0, function () {\n var inboundAddress, liquidityPoolHash, error_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3, , 4]);\n return [4 /*yield*/, this.dojConnect.getDojimaInboundAddress(hermesApiUrl)];\n case 1:\n inboundAddress = _a.sent();\n return [4 /*yield*/, this.dojConnect.addLiquidityPool(amount, inboundAddress, hermesAddress)];\n case 2:\n liquidityPoolHash = _a.sent();\n return [2 /*return*/, liquidityPoolHash];\n case 3:\n error_1 = _a.sent();\n return [2 /*return*/, Promise.reject(error_1)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n DojimaChain.prototype.swap = function (amount, recipient, token, hermesApiUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var inboundAddress, swapHash, error_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3, , 4]);\n return [4 /*yield*/, this.dojConnect.getDojimaInboundAddress(hermesApiUrl)];\n case 1:\n inboundAddress = _a.sent();\n return [4 /*yield*/, this.dojConnect.swap(amount, token, inboundAddress, recipient)];\n case 2:\n swapHash = _a.sent();\n return [2 /*return*/, swapHash];\n case 3:\n error_2 = _a.sent();\n return [2 /*return*/, Promise.reject(error_2)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return DojimaChain;\n}(connection_1.DojimaInit));\nexports[\"default\"] = DojimaChain;\n\n\n//# sourceURL=webpack://@dojima-wallet/transfer/./lib/chains/dojima.ts?"); /***/ }), /***/ "./lib/chains/ethereum.ts": /*!********************************!*\ !*** ./lib/chains/ethereum.ts ***! \********************************/ /***/ (function(__unused_webpack_module, exports, __webpack_require__) { eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar connection_1 = __webpack_require__(/*! @dojima-wallet/connection */ \"@dojima-wallet/connection\");\nvar utils_1 = __webpack_require__(/*! ./utils */ \"./lib/chains/utils.ts\");\n// import { assetAmount, assetToBase } from \"@dojima-wallet/utils\";\nvar EthereumChain = /** @class */ (function (_super) {\n __extends(EthereumChain, _super);\n function EthereumChain(mnemonic, privateKey, network, rpcUrl) {\n return _super.call(this, mnemonic, privateKey, network, rpcUrl) || this;\n }\n EthereumChain.prototype.getGasFee = function (amount, memo) {\n return __awaiter(this, void 0, void 0, function () {\n var gasFee, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ethConnect.getFees(amount, memo ? memo : undefined)];\n case 1:\n gasFee = _a.sent();\n return [4 /*yield*/, (0, utils_1.getUsdtTokenPriceResult)(gasFee, \"eth\")];\n case 2:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n EthereumChain.prototype.transfer = function (recipient, amount, gasPrice, memo) {\n return __awaiter(this, void 0, void 0, function () {\n var hash;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ethConnect.transfer({\n recipient: recipient,\n amount: amount,\n fee: gasPrice ? gasPrice : undefined,\n memo: memo ? memo : undefined,\n })];\n case 1:\n hash = _a.sent();\n return [2 /*return*/, hash];\n }\n });\n });\n };\n EthereumChain.prototype.getSwapOutput = function (amount, pool, toDoj) {\n return this.ethConnect.getSwapOutput(amount, pool, toDoj);\n };\n EthereumChain.prototype.getDoubleSwapOutput = function (amount, pool1, pool2) {\n return this.ethConnect.getDoubleSwapOutput(amount, pool1, pool2);\n };\n EthereumChain.prototype.getSwapSlippage = function (amount, pool, toDoj) {\n return this.ethConnect.getSwapSlip(amount, pool, toDoj) * 100;\n };\n EthereumChain.prototype.getDoubleSwapSlippage = function (amount, pool1, pool2) {\n return this.ethConnect.getDoubleSwapSlip(amount, pool1, pool2) * 100;\n };\n EthereumChain.prototype.getDefaultLiquidityPoolGasFee = function (hermesApiUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var LPDefaultGasFee, eth_LPgasfee, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ethConnect.getDefaultLiquidityPoolGasFee(hermesApiUrl)];\n case 1:\n LPDefaultGasFee = _a.sent();\n eth_LPgasfee = {\n slow: LPDefaultGasFee,\n average: LPDefaultGasFee,\n fast: LPDefaultGasFee,\n };\n return [4 /*yield*/, (0, utils_1.getUsdtTokenPriceResult)(eth_LPgasfee, \"eth\")];\n case 2:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n EthereumChain.prototype.addLiquidityPool = function (amount, hermesApiUrl, hermesAddress) {\n return __awaiter(this, void 0, void 0, function () {\n var inboundAddress, liquidityPoolHash, error_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3, , 4]);\n return [4 /*yield*/, this.ethConnect.getEthereumInboundAddress(hermesApiUrl)];\n case 1:\n inboundAddress = _a.sent();\n return [4 /*yield*/, this.ethConnect.addLiquidityPool(amount, inboundAddress, hermesAddress)];\n case 2:\n liquidityPoolHash = _a.sent();\n return [2 /*return*/, liquidityPoolHash];\n case 3:\n error_1 = _a.sent();\n return [2 /*return*/, Promise.reject(error_1)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n EthereumChain.prototype.swap = function (amount, recipient, token, hermesApiUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var inboundAddress, swapHash, error_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3, , 4]);\n return [4 /*yield*/, this.ethConnect.getEthereumInboundAddress(hermesApiUrl)];\n case 1:\n inboundAddress = _a.sent();\n return [4 /*yield*/, this.ethConnect.swap(amount, token, inboundAddress, recipient)];\n case 2:\n swapHash = _a.sent();\n return [2 /*return*/, swapHash];\n case 3:\n error_2 = _a.sent();\n return [2 /*return*/, Promise.reject(error_2)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return EthereumChain;\n}(connection_1.EthereumInit));\nexports[\"default\"] = EthereumChain;\n\n\n//# sourceURL=webpack://@dojima-wallet/transfer/./lib/chains/ethereum.ts?"); /***/ }), /***/ "./lib/chains/hermes.ts": /*!******************************!*\ !*** ./lib/chains/hermes.ts ***! \******************************/ /***/ (function(__unused_webpack_module, exports, __webpack_require__) { eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar connection_1 = __webpack_require__(/*! @dojima-wallet/connection */ \"@dojima-wallet/connection\");\nvar utils_1 = __webpack_require__(/*! ./utils */ \"./lib/chains/utils.ts\");\nvar utils_2 = __webpack_require__(/*! @dojima-wallet/utils */ \"@dojima-wallet/utils\");\nvar bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ \"bignumber.js\"));\nvar HermesChain = /** @class */ (function (_super) {\n __extends(HermesChain, _super);\n function HermesChain(mnemonic, network, apiUrl, rpcUrl) {\n return _super.call(this, mnemonic, network, apiUrl, rpcUrl) || this;\n }\n HermesChain.prototype.getGasFee = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gasFee, h4s_gasFee, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.h4sConnect.getFees()];\n case 1:\n gasFee = _a.sent();\n h4s_gasFee = {\n slow: Number((0, utils_2.baseToAsset)((0, utils_2.baseAmount)(gasFee.average.amount())).amount()),\n average: Number((0, utils_2.baseToAsset)((0, utils_2.baseAmount)(gasFee.fast.amount())).amount()),\n fast: Number((0, utils_2.baseToAsset)((0, utils_2.baseAmount)(gasFee.fastest.amount())).amount()),\n };\n return [4 /*yield*/, (0, utils_1.getUsdtTokenPriceResult)(h4s_gasFee, \"h4s\")];\n case 2:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n HermesChain.prototype.transfer = function (recipient, amount, gasPrice, memo) {\n return __awaiter(this, void 0, void 0, function () {\n var baseAmt, hash;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n baseAmt = (0, utils_2.assetToBase)((0, utils_2.assetAmount)(amount, connection_1.DOJ_DECIMAL));\n return [4 /*yield*/, this.h4sConnect.transfer({\n recipient: recipient,\n amount: baseAmt,\n gasLimit: gasPrice\n ? new bignumber_js_1.default(gasPrice * Math.pow(10, connection_1.DOJ_DECIMAL))\n : undefined,\n memo: memo ? memo : undefined,\n })];\n case 1:\n hash = _a.sent();\n return [2 /*return*/, hash];\n }\n });\n });\n };\n HermesChain.prototype.getSwapOutput = function (amount, pool, toDoj) {\n return this.h4sConnect.getSwapOutput(amount, pool, toDoj);\n };\n HermesChain.prototype.getDoubleSwapOutput = function (amount, pool1, pool2) {\n return this.h4sConnect.getDoubleSwapOutput(amount, pool1, pool2);\n };\n HermesChain.prototype.getSwapSlippage = function (amount, pool, toDoj) {\n return this.h4sConnect.getSwapSlip(amount, pool, toDoj) * 100;\n };\n HermesChain.prototype.getDoubleSwapSlippage = function (amount, pool1, pool2) {\n return this.h4sConnect.getDoubleSwapSlip(amount, pool1, pool2) * 100;\n };\n HermesChain.prototype.addLiquidityPool = function (amount, recipient, token) {\n return __awaiter(this, void 0, void 0, function () {\n var baseAmt, memo, liquidityPoolHash, error_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n baseAmt = (0, utils_2.assetToBase)((0, utils_2.assetAmount)(amount, connection_1.DOJ_DECIMAL));\n memo = \"ADD:\".concat(token, \":\").concat(recipient);\n return [4 /*yield*/, this.h4sConnect.deposit({\n amount: baseAmt,\n memo: memo,\n })];\n case 1:\n liquidityPoolHash = _a.sent();\n return [2 /*return*/, liquidityPoolHash];\n case 2:\n error_1 = _a.sent();\n return [2 /*return*/, Promise.reject(error_1)];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n HermesChain.prototype.swap = function (amount, recipient, token) {\n return __awaiter(this, void 0, void 0, function () {\n var baseAmt, memo, swapHash, error_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n baseAmt = (0, utils_2.assetToBase)((0, utils_2.assetAmount)(amount, connection_1.DOJ_DECIMAL));\n memo = \"SWAP:\".concat(token, \":\").concat(recipient);\n return [4 /*yield*/, this.h4sConnect.deposit({\n amount: baseAmt,\n memo: memo,\n })];\n case 1:\n swapHash = _a.sent();\n return [2 /*return*/, swapHash];\n case 2:\n error_2 = _a.sent();\n return [2 /*return*/, Promise.reject(error_2)];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n HermesChain.prototype.bondAddress = function (amount, recipient) {\n return __awaiter(this, void 0, void 0, function () {\n var baseAmt, memo, bondAddresslHash, error_3;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n baseAmt = (0, utils_2.assetToBase)((0, utils_2.assetAmount)(amount, connection_1.DOJ_DECIMAL));\n memo = \"BOND:\".concat(recipient);\n return [4 /*yield*/, this.h4sConnect.deposit({\n amount: baseAmt,\n memo: memo,\n })];\n case 1:\n bondAddresslHash = _a.sent();\n return [2 /*return*/, bondAddresslHash];\n case 2:\n error_3 = _a.sent();\n return [2 /*return*/, Promise.reject(error_3)];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n HermesChain.prototype.setVersion = function (version) {\n return __awaiter(this, void 0, void 0, function () {\n var setVersionHash, error_4;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n return [4 /*yield*/, this.h4sConnect.setVersion({ version: version })];\n case 1:\n setVersionHash = _a.sent();\n return [2 /*return*/, setVersionHash];\n case 2:\n error_4 = _a.sent();\n return [2 /*return*/, Promise.reject(error_4)];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n HermesChain.prototype.setIpAddress = function (ipAddress) {\n return __awaiter(this, void 0, void 0, function () {\n var setIpAddressHash, error_5;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n return [4 /*yield*/, this.h4sConnect.setIpAddress({\n ipAddress: ipAddress,\n })];\n case 1:\n setIpAddressHash = _a.sent();\n return [2 /*return*/, setIpAddressHash];\n case 2:\n error_5 = _a.sent();\n return [2 /*return*/, Promise.reject(error_5)];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n HermesChain.prototype.setPubkeys = function (secp256k1Pubkey, ed25519Pubkey, validatorConsPubkey) {\n return __awaiter(this, void 0, void 0, function () {\n var setPubKeysHash, error_6;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n return [4 /*yield*/, this.h4sConnect.setPubkeys({\n secp256k1Pubkey: secp256k1Pubkey,\n ed25519Pubkey: ed25519Pubkey,\n validatorConsPubkey: validatorConsPubkey,\n })];\n case 1:\n setPubKeysHash = _a.sent();\n return [2 /*return*/, setPubKeysHash];\n case 2:\n error_6 = _a.sent();\n return [2 /*return*/, Promise.reject(error_6)];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n return HermesChain;\n}(connection_1.HermesInit));\nexports[\"default\"] = HermesChain;\n\n\n//# sourceURL=webpack://@dojima-wallet/transfer/./lib/chains/hermes.ts?"); /***/ }), /***/ "./lib/chains/polkadot.ts": /*!********************************!*\ !*** ./lib/chains/polkadot.ts ***! \********************************/ /***/ (function(__unused_webpack_module, exports, __webpack_require__) { eval("\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar connection_1 = __webpack_require__(/*! @dojima-wallet/connection */ \"@dojima-wallet/connection\");\nvar utils_1 = __webpack_require__(/*! ./utils */ \"./lib/chains/utils.ts\");\nvar PolkadotChain = /** @class */ (function (_super) {\n __extends(PolkadotChain, _super);\n function PolkadotChain(mnemonic, network) {\n return _super.call(this, mnemonic, network) || this;\n }\n PolkadotChain.prototype.getGasFee = function (recipient, amount) {\n return __awaiter(this, void 0, void 0, function () {\n var dot_gasFee, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.dotConnect.getFees({\n recipient: recipient,\n amount: amount,\n })];\n case 1:\n dot_gasFee = _a.sent();\n return [4 /*yield*/, (0, utils_1.getUsdtTokenPriceResult)(dot_gasFee, \"dot\")];\n case 2:\n result = _a.sent();\n return [2 /*return*/, result];\n }\n });\n });\n };\n PolkadotChain.prototype.transfer = function (recipient, amount) {\n return __awaiter(this, void 0, void 0, function () {\n var hash;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.dotConnect.transfer({ recipient: recipient, amount: amount })];\n case 1:\n hash = _a.sent();\n return [2 /*return*/, hash];\n }\n });\n });\n };\n PolkadotChain.prototype.getSwapOutput = function (amount, pool, toDoj) {\n return this.dotConnect.getSwapOutput(amount, pool, toDoj);\n };\n PolkadotChain.prototype.getDoubleSwapOutput = function (amount, pool1, pool2) {\n return this.dotConnect.getDoubleSwapOutput(amount, pool1, pool2);\n };\n PolkadotChain.prototype.getSwapSlippage = function (amount, pool, toDoj) {\n return this.dotConnect.getSwapSlip(amount, pool, toDoj) * 100;\n };\n PolkadotChain.prototype.getDoubleSwapSlippage = function (amount, pool1, pool2) {\n return this.dotConnect.getDoubleSwapSlip(amount, pool1, pool2) * 100;\n };\n PolkadotChain.prototype.getDefaultLiquidityPoolGasFee = function (hermesApiUrl) {\n return __awaiter(this, void 0, void 0, function () {\n var LPDefaultGasFee, dot_LPgasfee, result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.dotConnect.getDefaultLiquidityPoolGasFee(hermesApiUrl)];\n case 1:\n