UNPKG

@texture-finance/solana-flash-loan-sdk-example

Version:
58 lines (44 loc) 61.6 kB
"use strict"; /* * 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/). */ (self["webpackChunk_texture_finance_solana_flash_loan_sdk_example"] = self["webpackChunk_texture_finance_solana_flash_loan_sdk_example"] || []).push([["vendors-node_modules_solflare-wallet_sdk_lib_esm_index_js"],{ /***/ "./node_modules/@project-serum/sol-wallet-adapter/dist/index.modern.js": /*!*****************************************************************************!*\ !*** ./node_modules/@project-serum/sol-wallet-adapter/dist/index.modern.js ***! \*****************************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.js\");\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(eventemitter3__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _solana_web3_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @solana/web3.js */ \"./node_modules/@solana/web3.js/lib/index.browser.esm.js\");\n/* harmony import */ var bs58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! bs58 */ \"./node_modules/bs58/index.js\");\n/* harmony import */ var bs58__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(bs58__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\n\nclass Wallet extends (eventemitter3__WEBPACK_IMPORTED_MODULE_0___default()) {\n constructor(provider, network) {\n var _this;\n\n super();\n _this = this;\n\n this._handleMessage = e => {\n if (this._injectedProvider && e.source === window || e.origin === this._providerUrl.origin && e.source === this._popup) {\n if (e.data.method === 'connected') {\n const newPublicKey = new _solana_web3_js__WEBPACK_IMPORTED_MODULE_1__.PublicKey(e.data.params.publicKey);\n\n if (!this._publicKey || !this._publicKey.equals(newPublicKey)) {\n if (this._publicKey && !this._publicKey.equals(newPublicKey)) {\n this._handleDisconnect();\n }\n\n this._publicKey = newPublicKey;\n this._autoApprove = !!e.data.params.autoApprove;\n this.emit('connect', this._publicKey);\n }\n } else if (e.data.method === 'disconnected') {\n this._handleDisconnect();\n } else if (e.data.result || e.data.error) {\n if (this._responsePromises.has(e.data.id)) {\n const [resolve, reject] = this._responsePromises.get(e.data.id);\n\n if (e.data.result) {\n resolve(e.data.result);\n } else {\n reject(new Error(e.data.error));\n }\n }\n }\n }\n };\n\n this._handleConnect = () => {\n if (!this._handlerAdded) {\n this._handlerAdded = true;\n window.addEventListener('message', this._handleMessage);\n window.addEventListener('beforeunload', this.disconnect);\n }\n\n if (this._injectedProvider) {\n return new Promise(resolve => {\n this._sendRequest('connect', {});\n\n resolve();\n });\n } else {\n window.name = 'parent';\n this._popup = window.open(this._providerUrl.toString(), '_blank', 'location,resizable,width=460,height=675');\n return new Promise(resolve => {\n this.once('connect', resolve);\n });\n }\n };\n\n this._handleDisconnect = () => {\n if (this._handlerAdded) {\n this._handlerAdded = false;\n window.removeEventListener('message', this._handleMessage);\n window.removeEventListener('beforeunload', this.disconnect);\n }\n\n if (this._publicKey) {\n this._publicKey = null;\n this.emit('disconnect');\n }\n\n this._responsePromises.forEach(([resolve, reject], id) => {\n this._responsePromises.delete(id);\n\n reject('Wallet disconnected');\n });\n };\n\n this._sendRequest = async function (method, params) {\n if (method !== 'connect' && !_this.connected) {\n throw new Error('Wallet not connected');\n }\n\n const requestId = _this._nextRequestId;\n ++_this._nextRequestId;\n return new Promise((resolve, reject) => {\n _this._responsePromises.set(requestId, [resolve, reject]);\n\n if (_this._injectedProvider) {\n _this._injectedProvider.postMessage({\n jsonrpc: '2.0',\n id: requestId,\n method,\n params: {\n network: _this._network,\n ...params\n }\n });\n } else {\n _this._popup.postMessage({\n jsonrpc: '2.0',\n id: requestId,\n method,\n params\n }, _this._providerUrl.origin);\n\n if (!_this.autoApprove) {\n _this._popup.focus();\n }\n }\n });\n };\n\n this.connect = () => {\n if (this._popup) {\n this._popup.close();\n }\n\n return this._handleConnect();\n };\n\n this.disconnect = async function () {\n if (_this._injectedProvider) {\n await _this._sendRequest('disconnect', {});\n }\n\n if (_this._popup) {\n _this._popup.close();\n }\n\n _this._handleDisconnect();\n };\n\n this.sign = async function (data, display) {\n if (!(data instanceof Uint8Array)) {\n throw new Error('Data must be an instance of Uint8Array');\n }\n\n const response = await _this._sendRequest('sign', {\n data,\n display\n });\n const signature = bs58__WEBPACK_IMPORTED_MODULE_2___default().decode(response.signature);\n const publicKey = new _solana_web3_js__WEBPACK_IMPORTED_MODULE_1__.PublicKey(response.publicKey);\n return {\n signature,\n publicKey\n };\n };\n\n this.signTransaction = async function (transaction) {\n const response = await _this._sendRequest('signTransaction', {\n message: bs58__WEBPACK_IMPORTED_MODULE_2___default().encode(transaction.serializeMessage())\n });\n const signature = bs58__WEBPACK_IMPORTED_MODULE_2___default().decode(response.signature);\n const publicKey = new _solana_web3_js__WEBPACK_IMPORTED_MODULE_1__.PublicKey(response.publicKey);\n transaction.addSignature(publicKey, signature);\n return transaction;\n };\n\n this.signAllTransactions = async function (transactions) {\n const response = await _this._sendRequest('signAllTransactions', {\n messages: transactions.map(tx => bs58__WEBPACK_IMPORTED_MODULE_2___default().encode(tx.serializeMessage()))\n });\n const signatures = response.signatures.map(s => bs58__WEBPACK_IMPORTED_MODULE_2___default().decode(s));\n const publicKey = new _solana_web3_js__WEBPACK_IMPORTED_MODULE_1__.PublicKey(response.publicKey);\n transactions = transactions.map((tx, idx) => {\n tx.addSignature(publicKey, signatures[idx]);\n return tx;\n });\n return transactions;\n };\n\n if (isInjectedProvider(provider)) {\n this._injectedProvider = provider;\n } else if (isString(provider)) {\n this._providerUrl = new URL(provider);\n this._providerUrl.hash = new URLSearchParams({\n origin: window.location.origin,\n network\n }).toString();\n } else {\n throw new Error('provider parameter must be an injected provider or a URL string.');\n }\n\n this._network = network;\n this._publicKey = null;\n this._autoApprove = false;\n this._popup = null;\n this._handlerAdded = false;\n this._nextRequestId = 1;\n this._responsePromises = new Map();\n }\n\n get publicKey() {\n return this._publicKey;\n }\n\n get connected() {\n return this._publicKey !== null;\n }\n\n get autoApprove() {\n return this._autoApprove;\n }\n\n}\n\nfunction isString(a) {\n return typeof a === 'string';\n}\n\nfunction isInjectedProvider(a) {\n return isObject(a) && isFunction(a.postMessage);\n}\n\nfunction isObject(a) {\n return typeof a === 'object' && a !== null;\n}\n\nfunction isFunction(a) {\n return typeof a === 'function';\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Wallet);\n//# sourceMappingURL=index.modern.js.map\n\n\n//# sourceURL=webpack://@texture-finance/solana-flash-loan-sdk-example/./node_modules/@project-serum/sol-wallet-adapter/dist/index.modern.js?"); /***/ }), /***/ "./node_modules/@solflare-wallet/sdk/lib/esm/adapters/base.js": /*!********************************************************************!*\ !*** ./node_modules/@solflare-wallet/sdk/lib/esm/adapters/base.js ***! \********************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.js\");\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(eventemitter3__WEBPACK_IMPORTED_MODULE_0__);\nvar __extends = (undefined && undefined.__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})();\n\nvar WalletAdapter = /** @class */ (function (_super) {\n __extends(WalletAdapter, _super);\n function WalletAdapter() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n return WalletAdapter;\n}((eventemitter3__WEBPACK_IMPORTED_MODULE_0___default())));\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (WalletAdapter);\n\n\n//# sourceURL=webpack://@texture-finance/solana-flash-loan-sdk-example/./node_modules/@solflare-wallet/sdk/lib/esm/adapters/base.js?"); /***/ }), /***/ "./node_modules/@solflare-wallet/sdk/lib/esm/adapters/iframe.js": /*!**********************************************************************!*\ !*** ./node_modules/@solflare-wallet/sdk/lib/esm/adapters/iframe.js ***! \**********************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _solana_web3_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @solana/web3.js */ \"./node_modules/@solana/web3.js/lib/index.browser.esm.js\");\n/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./base */ \"./node_modules/@solflare-wallet/sdk/lib/esm/adapters/base.js\");\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n/* harmony import */ var bs58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! bs58 */ \"./node_modules/bs58/index.js\");\n/* harmony import */ var bs58__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(bs58__WEBPACK_IMPORTED_MODULE_2__);\nvar __extends = (undefined && undefined.__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 __assign = (undefined && undefined.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (undefined && undefined.__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 = (undefined && undefined.__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 (_) 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};\n\n\n\n\nvar IframeAdapter = /** @class */ (function (_super) {\n __extends(IframeAdapter, _super);\n function IframeAdapter(iframe, publicKey) {\n var _this = this;\n var _a;\n _this = _super.call(this) || this;\n _this._publicKey = null;\n _this._messageHandlers = {};\n _this.handleMessage = function (data) {\n if (_this._messageHandlers[data.id]) {\n var _a = _this._messageHandlers[data.id], resolve = _a.resolve, reject = _a.reject;\n delete _this._messageHandlers[data.id];\n if (data.error) {\n reject(data.error);\n }\n else {\n resolve(data.result);\n }\n }\n };\n _this._sendMessage = function (data) {\n if (!_this.connected) {\n throw new Error('Wallet not connected');\n }\n return new Promise(function (resolve, reject) {\n var _a, _b;\n var messageId = (0,uuid__WEBPACK_IMPORTED_MODULE_3__[\"default\"])();\n _this._messageHandlers[messageId] = { resolve: resolve, reject: reject };\n (_b = (_a = _this._iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage({\n channel: 'solflareWalletAdapterToIframe',\n data: __assign({ id: messageId }, data)\n }, '*');\n });\n };\n _this._iframe = iframe;\n _this._publicKey = new _solana_web3_js__WEBPACK_IMPORTED_MODULE_0__.PublicKey((_a = publicKey === null || publicKey === void 0 ? void 0 : publicKey.toString) === null || _a === void 0 ? void 0 : _a.call(publicKey));\n return _this;\n }\n Object.defineProperty(IframeAdapter.prototype, \"publicKey\", {\n get: function () {\n return this._publicKey || null;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(IframeAdapter.prototype, \"connected\", {\n get: function () {\n return true;\n },\n enumerable: false,\n configurable: true\n });\n IframeAdapter.prototype.connect = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/];\n });\n });\n };\n IframeAdapter.prototype.disconnect = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this._sendMessage({\n method: 'disconnect'\n })];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n IframeAdapter.prototype.signTransaction = function (message) {\n return __awaiter(this, void 0, void 0, function () {\n var signature, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.connected) {\n throw new Error('Wallet not connected');\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this._sendMessage({\n method: 'signTransaction',\n params: {\n message: bs58__WEBPACK_IMPORTED_MODULE_2___default().encode(message)\n }\n })];\n case 2:\n signature = (_a.sent()).signature;\n return [2 /*return*/, bs58__WEBPACK_IMPORTED_MODULE_2___default().decode(signature)];\n case 3:\n e_1 = _a.sent();\n console.log(e_1);\n throw new Error('Failed to sign transaction');\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n IframeAdapter.prototype.signAllTransactions = function (messages) {\n return __awaiter(this, void 0, void 0, function () {\n var signatures, e_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.connected) {\n throw new Error('Wallet not connected');\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this._sendMessage({\n method: 'signAllTransactions',\n params: {\n messages: messages.map(function (message) { return bs58__WEBPACK_IMPORTED_MODULE_2___default().encode(message); })\n }\n })];\n case 2:\n signatures = (_a.sent()).signatures;\n return [2 /*return*/, signatures.map(function (signature) { return bs58__WEBPACK_IMPORTED_MODULE_2___default().decode(signature); })];\n case 3:\n e_2 = _a.sent();\n console.log(e_2);\n throw new Error('Failed to sign transactions');\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n IframeAdapter.prototype.signMessage = function (data, display) {\n if (display === void 0) { display = 'hex'; }\n return __awaiter(this, void 0, void 0, function () {\n var result, e_3;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.connected) {\n throw new Error('Wallet not connected');\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this._sendMessage({\n method: 'signMessage',\n params: {\n data: data,\n display: display\n }\n })];\n case 2:\n result = _a.sent();\n return [2 /*return*/, Uint8Array.from(bs58__WEBPACK_IMPORTED_MODULE_2___default().decode(result))];\n case 3:\n e_3 = _a.sent();\n console.log(e_3);\n throw new Error('Failed to sign message');\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n return IframeAdapter;\n}(_base__WEBPACK_IMPORTED_MODULE_1__[\"default\"]));\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (IframeAdapter);\n\n\n//# sourceURL=webpack://@texture-finance/solana-flash-loan-sdk-example/./node_modules/@solflare-wallet/sdk/lib/esm/adapters/iframe.js?"); /***/ }), /***/ "./node_modules/@solflare-wallet/sdk/lib/esm/adapters/web.js": /*!*******************************************************************!*\ !*** ./node_modules/@solflare-wallet/sdk/lib/esm/adapters/web.js ***! \*******************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ \"./node_modules/@solflare-wallet/sdk/lib/esm/adapters/base.js\");\n/* harmony import */ var _project_serum_sol_wallet_adapter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @project-serum/sol-wallet-adapter */ \"./node_modules/@project-serum/sol-wallet-adapter/dist/index.modern.js\");\n/* harmony import */ var bs58__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! bs58 */ \"./node_modules/bs58/index.js\");\n/* harmony import */ var bs58__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(bs58__WEBPACK_IMPORTED_MODULE_2__);\nvar __extends = (undefined && undefined.__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 = (undefined && undefined.__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 = (undefined && undefined.__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 (_) 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};\n\n\n\nvar WebAdapter = /** @class */ (function (_super) {\n __extends(WebAdapter, _super);\n // @ts-ignore\n function WebAdapter(iframe, network, provider) {\n var _this = _super.call(this) || this;\n _this._instance = null;\n // @ts-ignore\n _this.handleMessage = function (data) {\n // nothing to do here\n };\n _this._sendRequest = function (method, params) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this._instance.sendRequest) return [3 /*break*/, 2];\n return [4 /*yield*/, this._instance.sendRequest(method, params)];\n case 1: return [2 /*return*/, _a.sent()];\n case 2:\n if (!this._instance._sendRequest) return [3 /*break*/, 4];\n return [4 /*yield*/, this._instance._sendRequest(method, params)];\n case 3: return [2 /*return*/, _a.sent()];\n case 4: throw new Error('Unsupported version of `@project-serum/sol-wallet-adapter`');\n }\n });\n }); };\n _this._handleConnect = function () {\n _this.emit('connect');\n };\n _this._handleDisconnect = function () {\n window.clearInterval(_this._pollTimer);\n _this.emit('disconnect');\n };\n _this._network = network;\n _this._provider = provider;\n return _this;\n }\n Object.defineProperty(WebAdapter.prototype, \"publicKey\", {\n get: function () {\n return this._instance.publicKey || null;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(WebAdapter.prototype, \"connected\", {\n get: function () {\n return this._instance.connected || false;\n },\n enumerable: false,\n configurable: true\n });\n WebAdapter.prototype.connect = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this._instance = new _project_serum_sol_wallet_adapter__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this._provider, this._network);\n this._instance.on('connect', this._handleConnect);\n this._instance.on('disconnect', this._handleDisconnect);\n this._pollTimer = window.setInterval(function () {\n var _a, _b;\n // @ts-ignore\n if (((_b = (_a = _this._instance) === null || _a === void 0 ? void 0 : _a._popup) === null || _b === void 0 ? void 0 : _b.closed) !== false) {\n _this._handleDisconnect();\n }\n }, 200);\n return [4 /*yield*/, this._instance.connect()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n WebAdapter.prototype.disconnect = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.connected) {\n throw new Error('Wallet not connected');\n }\n this._instance.removeAllListeners('connect');\n this._instance.removeAllListeners('disconnect');\n return [4 /*yield*/, this._instance.disconnect()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n WebAdapter.prototype.signTransaction = function (message) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.connected) {\n throw new Error('Wallet not connected');\n }\n return [4 /*yield*/, this._sendRequest('signTransaction', {\n message: bs58__WEBPACK_IMPORTED_MODULE_2___default().encode(message)\n })];\n case 1:\n response = (_a.sent());\n return [2 /*return*/, bs58__WEBPACK_IMPORTED_MODULE_2___default().decode(response.signature)];\n }\n });\n });\n };\n WebAdapter.prototype.signAllTransactions = function (messages) {\n return __awaiter(this, void 0, void 0, function () {\n var response;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.connected) {\n throw new Error('Wallet not connected');\n }\n return [4 /*yield*/, this._sendRequest('signAllTransactions', {\n messages: messages.map(function (message) { return bs58__WEBPACK_IMPORTED_MODULE_2___default().encode(message); })\n })];\n case 1:\n response = (_a.sent());\n return [2 /*return*/, response.signatures.map(function (signature) { return bs58__WEBPACK_IMPORTED_MODULE_2___default().decode(signature); })];\n }\n });\n });\n };\n WebAdapter.prototype.signMessage = function (data, display) {\n if (display === void 0) { display = 'hex'; }\n return __awaiter(this, void 0, void 0, function () {\n var signature;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.connected) {\n throw new Error('Wallet not connected');\n }\n return [4 /*yield*/, this._instance.sign(data, display)];\n case 1:\n signature = (_a.sent()).signature;\n return [2 /*return*/, Uint8Array.from(signature)];\n }\n });\n });\n };\n return WebAdapter;\n}(_base__WEBPACK_IMPORTED_MODULE_0__[\"default\"]));\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (WebAdapter);\n\n\n//# sourceURL=webpack://@texture-finance/solana-flash-loan-sdk-example/./node_modules/@solflare-wallet/sdk/lib/esm/adapters/web.js?"); /***/ }), /***/ "./node_modules/@solflare-wallet/sdk/lib/esm/index.js": /*!************************************************************!*\ !*** ./node_modules/@solflare-wallet/sdk/lib/esm/index.js ***! \************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.js\");\n/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(eventemitter3__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _adapters_web__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./adapters/web */ \"./node_modules/@solflare-wallet/sdk/lib/esm/adapters/web.js\");\n/* harmony import */ var _adapters_iframe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adapters/iframe */ \"./node_modules/@solflare-wallet/sdk/lib/esm/adapters/iframe.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ \"./node_modules/@solflare-wallet/sdk/lib/esm/utils.js\");\n/* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\")[\"Buffer\"];\nvar __extends = (undefined && undefined.__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 = (undefined && undefined.__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 = (undefined && undefined.__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 (_) 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 __values = (undefined && undefined.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\n\n\n\n\nvar Solflare = /** @class */ (function (_super) {\n __extends(Solflare, _super);\n // private static IFRAME_URL = 'http://localhost:3090/';\n function Solflare(config) {\n var _this = _super.call(this) || this;\n _this._network = 'mainnet-beta';\n _this._provider = null;\n _this._adapterInstance = null;\n _this._element = null;\n _this._iframe = null;\n _this._connectHandler = null;\n _this._flutterHandlerInterval = null;\n _this._handleEvent = function (event) {\n var _a, _b, _c;\n switch (event.type) {\n case 'connect_native_web': {\n _this._collapseIframe();\n _this._adapterInstance = new _adapters_web__WEBPACK_IMPORTED_MODULE_1__[\"default\"](_this._iframe, _this._network, ((_a = event.data) === null || _a === void 0 ? void 0 : _a.provider) || _this._provider || 'https://solflare.com/provider');\n _this._adapterInstance.on('connect', _this._webConnected);\n _this._adapterInstance.on('disconnect', _this._webDisconnected);\n _this._adapterInstance.connect();\n _this._setPreferredAdapter('native_web');\n return;\n }\n case 'connect': {\n _this._collapseIframe();\n _this._adapterInstance = new _adapters_iframe__WEBPACK_IMPORTED_MODULE_2__[\"default\"](_this._iframe, ((_b = event.data) === null || _b === void 0 ? void 0 : _b.publicKey) || '');\n _this._adapterInstance.connect();\n _this._setPreferredAdapter((_c = event.data) === null || _c === void 0 ? void 0 : _c.adapter);\n if (_this._connectHandler) {\n _this._connectHandler.resolve();\n _this._connectHandler = null;\n }\n _this.emit('connect', _this.publicKey);\n return;\n }\n case 'disconnect': {\n if (_this._connectHandler) {\n _this._connectHandler.reject();\n _this._connectHandler = null;\n }\n _this._disconnected();\n _this.emit('disconnect');\n return;\n }\n // legacy event, use resize message type instead\n case 'collapse': {\n _this._collapseIframe();\n return;\n }\n default: {\n return;\n }\n }\n };\n _this._handleResize = function (data) {\n if (data.resizeMode === 'full') {\n if (data.params.mode === 'fullscreen') {\n _this._expandIframe();\n }\n else if (data.params.mode === 'hide') {\n _this._collapseIframe();\n }\n }\n else if (data.resizeMode === 'coordinates') {\n if (_this._iframe) {\n _this._iframe.style.top = isFinite(data.params.top) ? \"\".concat(data.params.top, \"px\") : '';\n _this._iframe.style.bottom = isFinite(data.params.bottom) ? \"\".concat(data.params.bottom, \"px\") : '';\n _this._iframe.style.left = isFinite(data.params.left) ? \"\".concat(data.params.left, \"px\") : '';\n _this._iframe.style.right = isFinite(data.params.right) ? \"\".concat(data.params.right, \"px\") : '';\n _this._iframe.style.width = isFinite(data.params.width) ? \"\".concat(data.params.width, \"px\") : data.params.width;\n _this._iframe.style.height = isFinite(data.params.height) ? \"\".concat(data.params.height, \"px\") : data.params.height;\n }\n }\n };\n _this._handleMessage = function (event) {\n var _a;\n if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.channel) !== 'solflareIframeToWalletAdapter') {\n return;\n }\n var data = event.data.data || {};\n if (data.type === 'event') {\n _this._handleEvent(data.event);\n }\n else if (data.type === 'resize') {\n _this._handleResize(data);\n }\n else if (data.type === 'response') {\n if (_this._adapterInstance) {\n _this._adapterInstance.handleMessage(data);\n }\n }\n };\n _this._removeElement = function () {\n if (_this._flutterHandlerInterval !== null) {\n clearInterval(_this._flutterHandlerInterval);\n _this._flutterHandlerInterval = null;\n }\n if (_this._element) {\n _this._element.remove();\n _this._element = null;\n }\n };\n _this._removeDanglingElements = function () {\n var e_1, _a;\n var elements = document.getElementsByClassName('solflare-wallet-adapter-iframe');\n try {\n for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {\n var element = elements_1_1.value;\n if (element.parentElement) {\n element.remove();\n }\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);\n }\n finally { if (e_1) throw e_1.error; }\n }\n };\n _this._injectElement = function () {\n _this._removeElement();\n _this._removeDanglingElements();\n var iframeUrl = \"\".concat(Solflare.IFRAME_URL, \"?cluster=\").concat(encodeURIComponent(_this._network), \"&origin=\").concat(encodeURIComponent(window.location.origin), \"&version=1\");\n var preferredAdapter = _this._getPreferredAdapter();\n if (preferredAdapter) {\n iframeUrl += \"&adapter=\".concat(encodeURIComponent(preferredAdapter));\n }\n _this._element = document.createElement('div');\n _this._element.className = 'solflare-wallet-adapter-iframe';\n _this._element.innerHTML = \"\\n <iframe src='\".concat(iframeUrl, \"' style='position: fixed; top: 0; bottom: 0; left: 0; right: 0; width: 100%; height: 100%; border: none; border-radius: 0; z-index: 99999; color-scheme: auto;' allowtransparency='true'></iframe>\\n \");\n document.body.appendChild(_this._element);\n _this._iframe = _this._element.querySelector('iframe');\n // @ts-ignore\n window.fromFlutter = _this._handleMobileMessage;\n _this._flutterHandlerInterval = setInterval(function () {\n // @ts-ignore\n window.fromFlutter = _this._handleMobileMessage;\n }, 100);\n window.addEventListener('message', _this._handleMessage, false);\n };\n _this._collapseIframe = function () {\n if (_this._iframe) {\n _this._iframe.style.top = '';\n _this._iframe.style.right = '';\n _this._iframe.style.height = '2px';\n _this._iframe.style.width = '2px';\n }\n };\n _this._expandIframe = function () {\n if (_this._iframe) {\n _this._iframe.style.top = '0px';\n _this._iframe.style.bottom = '0px';\n _this._iframe.style.left = '0px';\n _this._iframe.style.right = '0px';\n _this._iframe.style.width = '100%';\n _this._iframe.style.height = '100%';\n }\n };\n _this._getPreferredAdapter = function () {\n if (localStorage) {\n return localStorage.getItem('solflarePreferredWalletAdapter') || null;\n }\n return null;\n };\n _this._setPreferredAdapter = function (adapter) {\n if (localStorage && adapter) {\n localStorage.setItem('solflarePreferredWalletAdapter', adapter);\n }\n };\n _this._clearPreferredAdapter = function () {\n if (localStorage) {\n localStorage.removeItem('solflarePreferredWalle