@ant-design/web3-ton 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/dist/esm/chains/index.d.ts +1 -0
  4. package/dist/esm/chains/index.js +1 -0
  5. package/dist/esm/hooks/index.d.ts +1 -0
  6. package/dist/esm/hooks/index.js +1 -0
  7. package/dist/esm/hooks/useTonConnector.d.ts +7 -0
  8. package/dist/esm/hooks/useTonConnector.js +13 -0
  9. package/dist/esm/index.d.ts +4 -0
  10. package/dist/esm/index.js +4 -0
  11. package/dist/esm/ton-provider/TonConnectSdk.d.ts +15 -0
  12. package/dist/esm/ton-provider/TonConnectSdk.js +101 -0
  13. package/dist/esm/ton-provider/TonWeb3ConfigProvider.d.ts +21 -0
  14. package/dist/esm/ton-provider/TonWeb3ConfigProvider.js +90 -0
  15. package/dist/esm/ton-provider/config-provider.d.ts +8 -0
  16. package/dist/esm/ton-provider/config-provider.js +105 -0
  17. package/dist/esm/ton-provider/index.d.ts +1 -0
  18. package/dist/esm/ton-provider/index.js +1 -0
  19. package/dist/esm/wallets/dewallet.d.ts +2 -0
  20. package/dist/esm/wallets/dewallet.js +6 -0
  21. package/dist/esm/wallets/factory.d.ts +2 -0
  22. package/dist/esm/wallets/factory.js +27 -0
  23. package/dist/esm/wallets/index.d.ts +7 -0
  24. package/dist/esm/wallets/index.js +7 -0
  25. package/dist/esm/wallets/myTonWallet.d.ts +2 -0
  26. package/dist/esm/wallets/myTonWallet.js +6 -0
  27. package/dist/esm/wallets/okxTonWallet.d.ts +2 -0
  28. package/dist/esm/wallets/okxTonWallet.js +7 -0
  29. package/dist/esm/wallets/openmask.d.ts +2 -0
  30. package/dist/esm/wallets/openmask.js +6 -0
  31. package/dist/esm/wallets/telegramWallet.d.ts +2 -0
  32. package/dist/esm/wallets/telegramWallet.js +6 -0
  33. package/dist/esm/wallets/tonhub.d.ts +2 -0
  34. package/dist/esm/wallets/tonhub.js +6 -0
  35. package/dist/esm/wallets/tonkeeper.d.ts +2 -0
  36. package/dist/esm/wallets/tonkeeper.js +7 -0
  37. package/dist/esm/wallets/type.d.ts +10 -0
  38. package/dist/esm/wallets/type.js +1 -0
  39. package/dist/lib/chains/index.d.ts +1 -0
  40. package/dist/lib/chains/index.js +12 -0
  41. package/dist/lib/hooks/index.d.ts +1 -0
  42. package/dist/lib/hooks/index.js +16 -0
  43. package/dist/lib/hooks/useTonConnector.d.ts +7 -0
  44. package/dist/lib/hooks/useTonConnector.js +20 -0
  45. package/dist/lib/index.d.ts +4 -0
  46. package/dist/lib/index.js +49 -0
  47. package/dist/lib/ton-provider/TonConnectSdk.d.ts +15 -0
  48. package/dist/lib/ton-provider/TonConnectSdk.js +56 -0
  49. package/dist/lib/ton-provider/TonWeb3ConfigProvider.d.ts +21 -0
  50. package/dist/lib/ton-provider/TonWeb3ConfigProvider.js +74 -0
  51. package/dist/lib/ton-provider/config-provider.d.ts +8 -0
  52. package/dist/lib/ton-provider/config-provider.js +69 -0
  53. package/dist/lib/ton-provider/index.d.ts +1 -0
  54. package/dist/lib/ton-provider/index.js +16 -0
  55. package/dist/lib/wallets/dewallet.d.ts +2 -0
  56. package/dist/lib/wallets/dewallet.js +12 -0
  57. package/dist/lib/wallets/factory.d.ts +2 -0
  58. package/dist/lib/wallets/factory.js +24 -0
  59. package/dist/lib/wallets/index.d.ts +7 -0
  60. package/dist/lib/wallets/index.js +82 -0
  61. package/dist/lib/wallets/myTonWallet.d.ts +2 -0
  62. package/dist/lib/wallets/myTonWallet.js +12 -0
  63. package/dist/lib/wallets/okxTonWallet.d.ts +2 -0
  64. package/dist/lib/wallets/okxTonWallet.js +13 -0
  65. package/dist/lib/wallets/openmask.d.ts +2 -0
  66. package/dist/lib/wallets/openmask.js +12 -0
  67. package/dist/lib/wallets/telegramWallet.d.ts +2 -0
  68. package/dist/lib/wallets/telegramWallet.js +12 -0
  69. package/dist/lib/wallets/tonhub.d.ts +2 -0
  70. package/dist/lib/wallets/tonhub.js +12 -0
  71. package/dist/lib/wallets/tonkeeper.d.ts +2 -0
  72. package/dist/lib/wallets/tonkeeper.js +13 -0
  73. package/dist/lib/wallets/type.d.ts +10 -0
  74. package/dist/lib/wallets/type.js +5 -0
  75. package/package.json +64 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @ant-design/web3-ton
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - d49a4b8: feat: add ton chain
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [8f3430b]
12
+ - Updated dependencies [d663c3b]
13
+ - @ant-design/web3-assets@1.10.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ant Design Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ export { CHAIN } from '@tonconnect/sdk';
@@ -0,0 +1 @@
1
+ export { CHAIN } from '@tonconnect/sdk';
@@ -0,0 +1 @@
1
+ export * from './useTonConnector';
@@ -0,0 +1 @@
1
+ export * from "./useTonConnector";
@@ -0,0 +1,7 @@
1
+ export declare const useTonConnector: () => {
2
+ connector: import("../ton-provider/TonConnectSdk").default | null | undefined;
3
+ account: import("@tonconnect/sdk").Account | null | undefined;
4
+ tonSelectWallet: import("@tonconnect/sdk").Wallet | null | undefined;
5
+ setTonSelectWallet: ((sdk: import("@tonconnect/sdk").Wallet | null) => void) | undefined;
6
+ connectConfig: import("../ton-provider/TonConnectSdk").TonConnectSdkConfigType | undefined;
7
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { TonConnectorContext } from "../ton-provider/TonWeb3ConfigProvider";
3
+ export var useTonConnector = function useTonConnector() {
4
+ var _provider$tonConnectS;
5
+ var provider = React.useContext(TonConnectorContext);
6
+ return {
7
+ connector: provider === null || provider === void 0 ? void 0 : provider.tonConnectSdk,
8
+ account: provider === null || provider === void 0 || (_provider$tonConnectS = provider.tonConnectSdk) === null || _provider$tonConnectS === void 0 ? void 0 : _provider$tonConnectS.account,
9
+ tonSelectWallet: provider === null || provider === void 0 ? void 0 : provider.tonSelectWallet,
10
+ setTonSelectWallet: provider === null || provider === void 0 ? void 0 : provider.setTonSelectWallet,
11
+ connectConfig: provider === null || provider === void 0 ? void 0 : provider.connectConfig
12
+ };
13
+ };
@@ -0,0 +1,4 @@
1
+ export * from './ton-provider';
2
+ export * from './wallets';
3
+ export * from './chains';
4
+ export * from './hooks';
@@ -0,0 +1,4 @@
1
+ export * from "./ton-provider";
2
+ export * from "./wallets";
3
+ export * from "./chains";
4
+ export * from "./hooks";
@@ -0,0 +1,15 @@
1
+ import TonConnect, { CHAIN, type TonConnectOptions } from '@tonconnect/sdk';
2
+ export interface TonConnectSdkConfigType extends TonConnectOptions {
3
+ chain?: CHAIN;
4
+ }
5
+ declare class TonConnectSdk extends TonConnect {
6
+ private _api;
7
+ private _network;
8
+ constructor(options: TonConnectSdkConfigType);
9
+ get network(): CHAIN;
10
+ set network(network: CHAIN);
11
+ get api(): string;
12
+ private _switchNetwork;
13
+ getBalance(url?: string): Promise<bigint>;
14
+ }
15
+ export default TonConnectSdk;
@@ -0,0 +1,101 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
9
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
12
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ import TonConnect, { CHAIN } from '@tonconnect/sdk';
19
+ var TonConnectSdk = /*#__PURE__*/function (_TonConnect) {
20
+ _inherits(TonConnectSdk, _TonConnect);
21
+ var _super = _createSuper(TonConnectSdk);
22
+ function TonConnectSdk(options) {
23
+ var _this;
24
+ _classCallCheck(this, TonConnectSdk);
25
+ _this = _super.call(this, {
26
+ manifestUrl: options === null || options === void 0 ? void 0 : options.manifestUrl
27
+ });
28
+ _defineProperty(_assertThisInitialized(_this), "_api", void 0);
29
+ _defineProperty(_assertThisInitialized(_this), "_network", void 0);
30
+ _this._api = '';
31
+ _this._network = CHAIN.MAINNET;
32
+ _this._switchNetwork(options.chain || _this._network);
33
+ return _this;
34
+ }
35
+ _createClass(TonConnectSdk, [{
36
+ key: "network",
37
+ get: function get() {
38
+ return this._network;
39
+ },
40
+ set: function set(network) {
41
+ this._switchNetwork(network);
42
+ }
43
+ }, {
44
+ key: "api",
45
+ get: function get() {
46
+ return this._api;
47
+ }
48
+ }, {
49
+ key: "_switchNetwork",
50
+ value: function _switchNetwork(network) {
51
+ if (network === CHAIN.MAINNET) {
52
+ this._api = 'https://toncenter.com/api/v3';
53
+ } else {
54
+ this._api = 'https://testnet.toncenter.com/api/v3';
55
+ }
56
+ this._network = network;
57
+ }
58
+ }, {
59
+ key: "getBalance",
60
+ value: function () {
61
+ var _getBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
62
+ var _this$account, _this$account2;
63
+ var queryUrl;
64
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
65
+ while (1) switch (_context.prev = _context.next) {
66
+ case 0:
67
+ if (!(!((_this$account = this.account) !== null && _this$account !== void 0 && _this$account.address) && !url)) {
68
+ _context.next = 2;
69
+ break;
70
+ }
71
+ return _context.abrupt("return", Promise.resolve(0n));
72
+ case 2:
73
+ queryUrl = url || "".concat(this._api, "/account?address=").concat((_this$account2 = this.account) === null || _this$account2 === void 0 ? void 0 : _this$account2.address);
74
+ return _context.abrupt("return", fetch(queryUrl, {
75
+ method: 'GET',
76
+ headers: {
77
+ 'Content-Type': 'application/json'
78
+ }
79
+ }).then(function (res) {
80
+ if (!res.ok) {
81
+ throw new Error('Failed to fetch balance');
82
+ }
83
+ return res.json();
84
+ }).then(function (res) {
85
+ return res.balance;
86
+ }));
87
+ case 4:
88
+ case "end":
89
+ return _context.stop();
90
+ }
91
+ }, _callee, this);
92
+ }));
93
+ function getBalance(_x) {
94
+ return _getBalance.apply(this, arguments);
95
+ }
96
+ return getBalance;
97
+ }()
98
+ }]);
99
+ return TonConnectSdk;
100
+ }(TonConnect);
101
+ export default TonConnectSdk;
@@ -0,0 +1,21 @@
1
+ import React, { type PropsWithChildren } from 'react';
2
+ import type { Locale } from '@ant-design/web3-common';
3
+ import type { CHAIN, TonConnectOptions, Wallet } from '@tonconnect/sdk';
4
+ import type { TonWalletMetadata } from '../wallets/type';
5
+ import TonConnectSdk, { type TonConnectSdkConfigType } from './TonConnectSdk';
6
+ interface TonConnectorContextProps {
7
+ tonConnectSdk: TonConnectSdk | null;
8
+ tonSelectWallet: Wallet | null;
9
+ setTonSelectWallet: (sdk: Wallet | null) => void;
10
+ connectConfig: TonConnectSdkConfigType;
11
+ }
12
+ export declare const TonConnectorContext: React.Context<TonConnectorContextProps | null>;
13
+ export interface TonWeb3ConfigProviderProps extends TonConnectOptions {
14
+ locale?: Locale;
15
+ balance?: boolean;
16
+ wallets: TonWalletMetadata[];
17
+ chain?: CHAIN;
18
+ reconnect?: boolean;
19
+ }
20
+ export declare const TonWeb3ConfigProvider: React.FC<PropsWithChildren<TonWeb3ConfigProviderProps>>;
21
+ export {};
@@ -0,0 +1,90 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["children"];
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
+ import React, { useEffect } from 'react';
17
+ import { TonWalletFactory } from "../wallets/factory";
18
+ import TonConfigProvider from "./config-provider";
19
+ import TonConnectSdk from "./TonConnectSdk";
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ export var TonConnectorContext = /*#__PURE__*/React.createContext(null);
22
+ export var TonWeb3ConfigProvider = function TonWeb3ConfigProvider(_ref) {
23
+ var children = _ref.children,
24
+ restProps = _objectWithoutProperties(_ref, _excluded);
25
+ var balance = restProps.balance,
26
+ locale = restProps.locale,
27
+ wallets = restProps.wallets,
28
+ chain = restProps.chain,
29
+ _restProps$reconnect = restProps.reconnect,
30
+ reconnect = _restProps$reconnect === void 0 ? true : _restProps$reconnect;
31
+ var _React$useState = React.useState(null),
32
+ _React$useState2 = _slicedToArray(_React$useState, 2),
33
+ tonConnectSdk = _React$useState2[0],
34
+ setTonConnectSdk = _React$useState2[1];
35
+ var _React$useState3 = React.useState(null),
36
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
37
+ tonSelectWallet = _React$useState4[0],
38
+ setTonSelectWallet = _React$useState4[1];
39
+ var _React$useState5 = React.useState([]),
40
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
41
+ tonWallets = _React$useState6[0],
42
+ setTonWallets = _React$useState6[1];
43
+ useEffect(function () {
44
+ if (!tonConnectSdk) {
45
+ var tonSdk = new TonConnectSdk(_objectSpread(_objectSpread({}, restProps), {}, {
46
+ chain: chain
47
+ }));
48
+ if (reconnect) {
49
+ tonSdk.restoreConnection();
50
+ }
51
+ tonSdk.onStatusChange(function (s) {
52
+ setTonSelectWallet(s);
53
+ });
54
+ setTonConnectSdk(tonSdk);
55
+ }
56
+ }, [tonConnectSdk, restProps, reconnect, chain]);
57
+ React.useEffect(function () {
58
+ if (tonConnectSdk && wallets !== null && wallets !== void 0 && wallets.length) {
59
+ tonConnectSdk.getWallets().then(function (res) {
60
+ var availableWallets = wallets.filter(function (w) {
61
+ return res.findIndex(function (t) {
62
+ return t.appName === w.key;
63
+ }) >= 0;
64
+ });
65
+ setTonWallets(availableWallets.map(function (w) {
66
+ var tonBasicWallet = res.find(function (t) {
67
+ return t.appName === w.key;
68
+ });
69
+ return _objectSpread(_objectSpread({}, w), tonBasicWallet);
70
+ }));
71
+ });
72
+ }
73
+ }, [wallets, tonConnectSdk]);
74
+ return /*#__PURE__*/_jsx(TonConnectorContext.Provider, {
75
+ value: {
76
+ tonConnectSdk: tonConnectSdk,
77
+ tonSelectWallet: tonSelectWallet,
78
+ setTonSelectWallet: setTonSelectWallet,
79
+ connectConfig: restProps
80
+ },
81
+ children: /*#__PURE__*/_jsx(TonConfigProvider, {
82
+ wallets: tonWallets.map(function (w) {
83
+ return TonWalletFactory(w).create();
84
+ }),
85
+ balance: balance,
86
+ locale: locale,
87
+ children: children
88
+ })
89
+ });
90
+ };
@@ -0,0 +1,8 @@
1
+ import React, { type PropsWithChildren } from 'react';
2
+ import type { TonWallet } from '../wallets/type';
3
+ import type { TonWeb3ConfigProviderProps } from './TonWeb3ConfigProvider';
4
+ interface TonConfigProviderProps extends Omit<TonWeb3ConfigProviderProps, 'wallets' | 'connectConfig'> {
5
+ wallets?: TonWallet[];
6
+ }
7
+ declare const TonConfigProvider: React.FC<PropsWithChildren<TonConfigProviderProps>>;
8
+ export default TonConfigProvider;
@@ -0,0 +1,105 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ import React, { useEffect } from 'react';
17
+ import { Web3ConfigProvider } from '@ant-design/web3-common';
18
+ import { TonCircleColorful } from '@ant-design/web3-icons';
19
+ import { toUserFriendlyAddress } from '@tonconnect/sdk';
20
+ import { useTonConnector } from "../hooks";
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ var TonConfigProvider = function TonConfigProvider(_ref) {
23
+ var children = _ref.children,
24
+ locale = _ref.locale,
25
+ showBalance = _ref.balance,
26
+ wallets = _ref.wallets;
27
+ var _useTonConnector = useTonConnector(),
28
+ connector = _useTonConnector.connector,
29
+ tonSelectWallet = _useTonConnector.tonSelectWallet,
30
+ setTonSelectWallet = _useTonConnector.setTonSelectWallet;
31
+ var _React$useState = React.useState(),
32
+ _React$useState2 = _slicedToArray(_React$useState, 2),
33
+ balance = _React$useState2[0],
34
+ setBalance = _React$useState2[1];
35
+ var _React$useState3 = React.useState(),
36
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
37
+ account = _React$useState4[0],
38
+ setAccount = _React$useState4[1];
39
+ useEffect(function () {
40
+ if (!showBalance || !connector) return;
41
+ connector === null || connector === void 0 || connector.getBalance().then(function (res) {
42
+ setBalance({
43
+ value: BigInt(res)
44
+ });
45
+ });
46
+ }, [connector, showBalance, tonSelectWallet]);
47
+ useEffect(function () {
48
+ if (tonSelectWallet) {
49
+ setAccount({
50
+ address: toUserFriendlyAddress(tonSelectWallet.account.address)
51
+ });
52
+ } else {
53
+ setAccount(undefined);
54
+ }
55
+ }, [tonSelectWallet]);
56
+ return /*#__PURE__*/_jsx(Web3ConfigProvider, {
57
+ addressPrefix: false,
58
+ locale: locale,
59
+ availableWallets: wallets,
60
+ balance: balance ? _objectSpread(_objectSpread({}, balance), {}, {
61
+ decimals: 9,
62
+ icon: /*#__PURE__*/_jsx(TonCircleColorful, {}),
63
+ symbol: 'TON'
64
+ }) : undefined,
65
+ account: account,
66
+ connect: ( /*#__PURE__*/function () {
67
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(wallet) {
68
+ var walletInfo;
69
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
70
+ while (1) switch (_context.prev = _context.next) {
71
+ case 0:
72
+ walletInfo = wallets === null || wallets === void 0 ? void 0 : wallets.find(function (w) {
73
+ return w.appName === (wallet === null || wallet === void 0 ? void 0 : wallet.key);
74
+ });
75
+ connector === null || connector === void 0 || connector.connect(walletInfo);
76
+ case 2:
77
+ case "end":
78
+ return _context.stop();
79
+ }
80
+ }, _callee);
81
+ }));
82
+ return function (_x) {
83
+ return _ref2.apply(this, arguments);
84
+ };
85
+ }()),
86
+ disconnect: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
87
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
88
+ while (1) switch (_context2.prev = _context2.next) {
89
+ case 0:
90
+ _context2.next = 2;
91
+ return connector === null || connector === void 0 ? void 0 : connector.disconnect();
92
+ case 2:
93
+ if (!(connector !== null && connector !== void 0 && connector.connected)) {
94
+ setTonSelectWallet === null || setTonSelectWallet === void 0 || setTonSelectWallet(null);
95
+ }
96
+ case 3:
97
+ case "end":
98
+ return _context2.stop();
99
+ }
100
+ }, _callee2);
101
+ })),
102
+ children: children
103
+ });
104
+ };
105
+ export default TonConfigProvider;
@@ -0,0 +1 @@
1
+ export * from './TonWeb3ConfigProvider';
@@ -0,0 +1 @@
1
+ export * from "./TonWeb3ConfigProvider";
@@ -0,0 +1,2 @@
1
+ import type { TonWalletMetadata } from './type';
2
+ export declare const dewallet: TonWalletMetadata;
@@ -0,0 +1,6 @@
1
+ import { DeWalletCircleColorful } from '@ant-design/web3-icons';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export var dewallet = {
4
+ key: 'dewallet',
5
+ icon: /*#__PURE__*/_jsx(DeWalletCircleColorful, {})
6
+ };
@@ -0,0 +1,2 @@
1
+ import type { TonBasicWallet, WalletFactory } from './type';
2
+ export declare const TonWalletFactory: (metadata: TonBasicWallet) => WalletFactory;
@@ -0,0 +1,27 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { isWalletInfoCurrentlyInjected } from '@tonconnect/sdk';
8
+ export var TonWalletFactory = function TonWalletFactory(metadata) {
9
+ var isReady = isWalletInfoCurrentlyInjected(metadata);
10
+ return {
11
+ create: function create() {
12
+ var _metadata$icon;
13
+ return _objectSpread(_objectSpread({}, metadata), {}, {
14
+ name: metadata.name,
15
+ remark: metadata.appName,
16
+ key: metadata.appName,
17
+ icon: (_metadata$icon = metadata.icon) !== null && _metadata$icon !== void 0 ? _metadata$icon : metadata.imageUrl,
18
+ hasWalletReady: function hasWalletReady() {
19
+ return Promise.resolve(isReady);
20
+ },
21
+ hasExtensionInstalled: function hasExtensionInstalled() {
22
+ return Promise.resolve(isReady);
23
+ }
24
+ });
25
+ }
26
+ };
27
+ };
@@ -0,0 +1,7 @@
1
+ export * from './tonkeeper';
2
+ export * from './telegramWallet';
3
+ export * from './myTonWallet';
4
+ export * from './openmask';
5
+ export * from './tonhub';
6
+ export * from './dewallet';
7
+ export * from './okxTonWallet';
@@ -0,0 +1,7 @@
1
+ export * from "./tonkeeper";
2
+ export * from "./telegramWallet";
3
+ export * from "./myTonWallet";
4
+ export * from "./openmask";
5
+ export * from "./tonhub";
6
+ export * from "./dewallet";
7
+ export * from "./okxTonWallet";
@@ -0,0 +1,2 @@
1
+ import type { TonWalletMetadata } from './type';
2
+ export declare const myTonWallet: TonWalletMetadata;
@@ -0,0 +1,6 @@
1
+ import { MytonWalletCircleColorful } from '@ant-design/web3-icons';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export var myTonWallet = {
4
+ key: 'mytonwallet',
5
+ icon: /*#__PURE__*/_jsx(MytonWalletCircleColorful, {})
6
+ };
@@ -0,0 +1,2 @@
1
+ import type { TonWalletMetadata } from './type';
2
+ export declare const okxTonWallet: TonWalletMetadata;
@@ -0,0 +1,7 @@
1
+ import { OkxWalletColorful } from '@ant-design/web3-icons';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export var okxTonWallet = {
4
+ key: 'okxTonWallet',
5
+ icon: /*#__PURE__*/_jsx(OkxWalletColorful, {}),
6
+ group: 'Popular'
7
+ };
@@ -0,0 +1,2 @@
1
+ import type { TonWalletMetadata } from './type';
2
+ export declare const openmask: TonWalletMetadata;
@@ -0,0 +1,6 @@
1
+ import { OpenmaskCircleColorful } from '@ant-design/web3-icons';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export var openmask = {
4
+ key: 'openmask',
5
+ icon: /*#__PURE__*/_jsx(OpenmaskCircleColorful, {})
6
+ };
@@ -0,0 +1,2 @@
1
+ import type { TonWalletMetadata } from './type';
2
+ export declare const telegramWallet: TonWalletMetadata;
@@ -0,0 +1,6 @@
1
+ import { TgWalletCircleColorful } from '@ant-design/web3-icons';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export var telegramWallet = {
4
+ key: 'telegram-wallet',
5
+ icon: /*#__PURE__*/_jsx(TgWalletCircleColorful, {})
6
+ };
@@ -0,0 +1,2 @@
1
+ import type { TonWalletMetadata } from './type';
2
+ export declare const tonhub: TonWalletMetadata;
@@ -0,0 +1,6 @@
1
+ import { TonhubCircleColorful } from '@ant-design/web3-icons';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export var tonhub = {
4
+ key: 'tonhub',
5
+ icon: /*#__PURE__*/_jsx(TonhubCircleColorful, {})
6
+ };
@@ -0,0 +1,2 @@
1
+ import type { TonWalletMetadata } from './type';
2
+ export declare const tonkeeper: TonWalletMetadata;