@ant-design/web3-ton 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/esm/hooks/useTonConnector.js +7 -8
- package/dist/esm/ton-provider/TonConnectSdk.js +41 -94
- package/dist/esm/ton-provider/TonWeb3ConfigProvider.js +35 -61
- package/dist/esm/ton-provider/config-provider.js +29 -73
- package/dist/esm/wallets/dewallet.js +1 -1
- package/dist/esm/wallets/factory.js +9 -19
- package/dist/esm/wallets/myTonWallet.js +1 -1
- package/dist/esm/wallets/okxTonWallet.js +3 -4
- package/dist/esm/wallets/openmask.js +1 -1
- package/dist/esm/wallets/telegramWallet.js +1 -1
- package/dist/esm/wallets/tonhub.js +1 -1
- package/dist/esm/wallets/tonkeeper.js +1 -1
- package/dist/lib/wallets/okxTonWallet.js +2 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @ant-design/web3-ton
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2e5940c: fix: update okx wallet info in ton provider
|
|
8
|
+
- 3f7d7a6: build: set targets chrome 100
|
|
9
|
+
- Updated dependencies [3f7d7a6]
|
|
10
|
+
- @ant-design/web3-assets@1.10.1
|
|
11
|
+
- @ant-design/web3-common@1.12.1
|
|
12
|
+
|
|
3
13
|
## 1.0.0
|
|
4
14
|
|
|
5
15
|
### Major Changes
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TonConnectorContext } from "../ton-provider/TonWeb3ConfigProvider";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
var provider = React.useContext(TonConnectorContext);
|
|
3
|
+
export const useTonConnector = () => {
|
|
4
|
+
const provider = React.useContext(TonConnectorContext);
|
|
6
5
|
return {
|
|
7
|
-
connector: provider
|
|
8
|
-
account: provider
|
|
9
|
-
tonSelectWallet: provider
|
|
10
|
-
setTonSelectWallet: provider
|
|
11
|
-
connectConfig: provider
|
|
6
|
+
connector: provider?.tonConnectSdk,
|
|
7
|
+
account: provider?.tonConnectSdk?.account,
|
|
8
|
+
tonSelectWallet: provider?.tonSelectWallet,
|
|
9
|
+
setTonSelectWallet: provider?.setTonSelectWallet,
|
|
10
|
+
connectConfig: provider?.connectConfig
|
|
12
11
|
};
|
|
13
12
|
};
|
|
@@ -1,101 +1,48 @@
|
|
|
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
1
|
import TonConnect, { CHAIN } from '@tonconnect/sdk';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_this = _super.call(this, {
|
|
26
|
-
manifestUrl: options === null || options === void 0 ? void 0 : options.manifestUrl
|
|
2
|
+
class TonConnectSdk extends TonConnect {
|
|
3
|
+
_api;
|
|
4
|
+
_network;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super({
|
|
7
|
+
manifestUrl: options?.manifestUrl
|
|
27
8
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_this._network = CHAIN.MAINNET;
|
|
32
|
-
_this._switchNetwork(options.chain || _this._network);
|
|
33
|
-
return _this;
|
|
9
|
+
this._api = '';
|
|
10
|
+
this._network = CHAIN.MAINNET;
|
|
11
|
+
this._switchNetwork(options.chain || this._network);
|
|
34
12
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
13
|
+
get network() {
|
|
14
|
+
return this._network;
|
|
15
|
+
}
|
|
16
|
+
set network(network) {
|
|
17
|
+
this._switchNetwork(network);
|
|
18
|
+
}
|
|
19
|
+
get api() {
|
|
20
|
+
return this._api;
|
|
21
|
+
}
|
|
22
|
+
_switchNetwork(network) {
|
|
23
|
+
if (network === CHAIN.MAINNET) {
|
|
24
|
+
this._api = 'https://toncenter.com/api/v3';
|
|
25
|
+
} else {
|
|
26
|
+
this._api = 'https://testnet.toncenter.com/api/v3';
|
|
47
27
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
28
|
+
this._network = network;
|
|
29
|
+
}
|
|
30
|
+
async getBalance(url) {
|
|
31
|
+
if (!this.account?.address && !url) return Promise.resolve(0n);
|
|
32
|
+
const queryUrl = url || `${this._api}/account?address=${this.account?.address}`;
|
|
33
|
+
return fetch(queryUrl, {
|
|
34
|
+
method: 'GET',
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json'
|
|
55
37
|
}
|
|
56
|
-
|
|
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);
|
|
38
|
+
}).then(res => {
|
|
39
|
+
if (!res.ok) {
|
|
40
|
+
throw new Error('Failed to fetch balance');
|
|
95
41
|
}
|
|
96
|
-
return
|
|
97
|
-
}(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
42
|
+
return res.json();
|
|
43
|
+
}).then(res => {
|
|
44
|
+
return res.balance;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
101
48
|
export default TonConnectSdk;
|
|
@@ -1,87 +1,61 @@
|
|
|
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
1
|
import React, { useEffect } from 'react';
|
|
17
2
|
import { TonWalletFactory } from "../wallets/factory";
|
|
18
3
|
import TonConfigProvider from "./config-provider";
|
|
19
4
|
import TonConnectSdk from "./TonConnectSdk";
|
|
20
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 () {
|
|
6
|
+
export const TonConnectorContext = /*#__PURE__*/React.createContext(null);
|
|
7
|
+
export const TonWeb3ConfigProvider = ({
|
|
8
|
+
children,
|
|
9
|
+
...restProps
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
balance,
|
|
13
|
+
locale,
|
|
14
|
+
wallets,
|
|
15
|
+
chain,
|
|
16
|
+
reconnect = true
|
|
17
|
+
} = restProps;
|
|
18
|
+
const [tonConnectSdk, setTonConnectSdk] = React.useState(null);
|
|
19
|
+
const [tonSelectWallet, setTonSelectWallet] = React.useState(null);
|
|
20
|
+
const [tonWallets, setTonWallets] = React.useState([]);
|
|
21
|
+
useEffect(() => {
|
|
44
22
|
if (!tonConnectSdk) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
const tonSdk = new TonConnectSdk({
|
|
24
|
+
...restProps,
|
|
25
|
+
chain
|
|
26
|
+
});
|
|
48
27
|
if (reconnect) {
|
|
49
28
|
tonSdk.restoreConnection();
|
|
50
29
|
}
|
|
51
|
-
tonSdk.onStatusChange(
|
|
30
|
+
tonSdk.onStatusChange(s => {
|
|
52
31
|
setTonSelectWallet(s);
|
|
53
32
|
});
|
|
54
33
|
setTonConnectSdk(tonSdk);
|
|
55
34
|
}
|
|
56
35
|
}, [tonConnectSdk, restProps, reconnect, chain]);
|
|
57
|
-
React.useEffect(
|
|
58
|
-
if (tonConnectSdk && wallets
|
|
59
|
-
tonConnectSdk.getWallets().then(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return t.appName === w.key;
|
|
68
|
-
});
|
|
69
|
-
return _objectSpread(_objectSpread({}, w), tonBasicWallet);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (tonConnectSdk && wallets?.length) {
|
|
38
|
+
tonConnectSdk.getWallets().then(res => {
|
|
39
|
+
const availableWallets = wallets.filter(w => res.findIndex(t => t.appName === w.key) >= 0);
|
|
40
|
+
setTonWallets(availableWallets.map(w => {
|
|
41
|
+
const tonBasicWallet = res.find(t => t.appName === w.key);
|
|
42
|
+
return {
|
|
43
|
+
...w,
|
|
44
|
+
...tonBasicWallet
|
|
45
|
+
};
|
|
70
46
|
}));
|
|
71
47
|
});
|
|
72
48
|
}
|
|
73
49
|
}, [wallets, tonConnectSdk]);
|
|
74
50
|
return /*#__PURE__*/_jsx(TonConnectorContext.Provider, {
|
|
75
51
|
value: {
|
|
76
|
-
tonConnectSdk
|
|
77
|
-
tonSelectWallet
|
|
78
|
-
setTonSelectWallet
|
|
52
|
+
tonConnectSdk,
|
|
53
|
+
tonSelectWallet,
|
|
54
|
+
setTonSelectWallet,
|
|
79
55
|
connectConfig: restProps
|
|
80
56
|
},
|
|
81
57
|
children: /*#__PURE__*/_jsx(TonConfigProvider, {
|
|
82
|
-
wallets: tonWallets.map(
|
|
83
|
-
return TonWalletFactory(w).create();
|
|
84
|
-
}),
|
|
58
|
+
wallets: tonWallets.map(w => TonWalletFactory(w).create()),
|
|
85
59
|
balance: balance,
|
|
86
60
|
locale: locale,
|
|
87
61
|
children: children
|
|
@@ -1,50 +1,31 @@
|
|
|
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
1
|
import React, { useEffect } from 'react';
|
|
17
2
|
import { Web3ConfigProvider } from '@ant-design/web3-common';
|
|
18
3
|
import { TonCircleColorful } from '@ant-design/web3-icons';
|
|
19
4
|
import { toUserFriendlyAddress } from '@tonconnect/sdk';
|
|
20
5
|
import { useTonConnector } from "../hooks";
|
|
21
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
37
|
-
account = _React$useState4[0],
|
|
38
|
-
setAccount = _React$useState4[1];
|
|
39
|
-
useEffect(function () {
|
|
7
|
+
const TonConfigProvider = ({
|
|
8
|
+
children,
|
|
9
|
+
locale,
|
|
10
|
+
balance: showBalance,
|
|
11
|
+
wallets
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
connector,
|
|
15
|
+
tonSelectWallet,
|
|
16
|
+
setTonSelectWallet
|
|
17
|
+
} = useTonConnector();
|
|
18
|
+
const [balance, setBalance] = React.useState();
|
|
19
|
+
const [account, setAccount] = React.useState();
|
|
20
|
+
useEffect(() => {
|
|
40
21
|
if (!showBalance || !connector) return;
|
|
41
|
-
connector
|
|
22
|
+
connector?.getBalance().then(res => {
|
|
42
23
|
setBalance({
|
|
43
24
|
value: BigInt(res)
|
|
44
25
|
});
|
|
45
26
|
});
|
|
46
27
|
}, [connector, showBalance, tonSelectWallet]);
|
|
47
|
-
useEffect(
|
|
28
|
+
useEffect(() => {
|
|
48
29
|
if (tonSelectWallet) {
|
|
49
30
|
setAccount({
|
|
50
31
|
address: toUserFriendlyAddress(tonSelectWallet.account.address)
|
|
@@ -57,48 +38,23 @@ var TonConfigProvider = function TonConfigProvider(_ref) {
|
|
|
57
38
|
addressPrefix: false,
|
|
58
39
|
locale: locale,
|
|
59
40
|
availableWallets: wallets,
|
|
60
|
-
balance: balance ?
|
|
41
|
+
balance: balance ? {
|
|
42
|
+
...balance,
|
|
61
43
|
decimals: 9,
|
|
62
44
|
icon: /*#__PURE__*/_jsx(TonCircleColorful, {}),
|
|
63
45
|
symbol: 'TON'
|
|
64
|
-
}
|
|
46
|
+
} : undefined,
|
|
65
47
|
account: account,
|
|
66
|
-
connect:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
})),
|
|
48
|
+
connect: async wallet => {
|
|
49
|
+
const walletInfo = wallets?.find(w => w.appName === wallet?.key);
|
|
50
|
+
connector?.connect(walletInfo);
|
|
51
|
+
},
|
|
52
|
+
disconnect: async () => {
|
|
53
|
+
await connector?.disconnect();
|
|
54
|
+
if (!connector?.connected) {
|
|
55
|
+
setTonSelectWallet?.(null);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
102
58
|
children: children
|
|
103
59
|
});
|
|
104
60
|
};
|
|
@@ -1,27 +1,17 @@
|
|
|
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
1
|
import { isWalletInfoCurrentlyInjected } from '@tonconnect/sdk';
|
|
8
|
-
export
|
|
9
|
-
|
|
2
|
+
export const TonWalletFactory = metadata => {
|
|
3
|
+
const isReady = isWalletInfoCurrentlyInjected(metadata);
|
|
10
4
|
return {
|
|
11
|
-
create:
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
create: () => {
|
|
6
|
+
return {
|
|
7
|
+
...metadata,
|
|
14
8
|
name: metadata.name,
|
|
15
9
|
remark: metadata.appName,
|
|
16
10
|
key: metadata.appName,
|
|
17
|
-
icon:
|
|
18
|
-
hasWalletReady:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
hasExtensionInstalled: function hasExtensionInstalled() {
|
|
22
|
-
return Promise.resolve(isReady);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
11
|
+
icon: metadata.icon ?? metadata.imageUrl,
|
|
12
|
+
hasWalletReady: () => Promise.resolve(isReady),
|
|
13
|
+
hasExtensionInstalled: () => Promise.resolve(isReady)
|
|
14
|
+
};
|
|
25
15
|
}
|
|
26
16
|
};
|
|
27
17
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { metadata_OkxWallet } from '@ant-design/web3-assets';
|
|
2
|
+
export const okxTonWallet = {
|
|
3
|
+
...metadata_OkxWallet,
|
|
4
4
|
key: 'okxTonWallet',
|
|
5
|
-
icon: /*#__PURE__*/_jsx(OkxWalletColorful, {}),
|
|
6
5
|
group: 'Popular'
|
|
7
6
|
};
|
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.okxTonWallet = void 0;
|
|
7
|
-
var
|
|
8
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
var _web3Assets = require("@ant-design/web3-assets");
|
|
9
8
|
const okxTonWallet = exports.okxTonWallet = {
|
|
9
|
+
..._web3Assets.metadata_OkxWallet,
|
|
10
10
|
key: 'okxTonWallet',
|
|
11
|
-
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.OkxWalletColorful, {}),
|
|
12
11
|
group: 'Popular'
|
|
13
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ant-design/web3-ton",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"main": "dist/lib/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"typings": "dist/esm/index.d.ts",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"url": "https://github.com/ant-design/ant-design-web3"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ant-design/web3-
|
|
41
|
-
"@ant-design/web3-
|
|
40
|
+
"@ant-design/web3-assets": "1.10.1",
|
|
41
|
+
"@ant-design/web3-common": "1.12.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"father": "^4.4.4",
|
|
45
|
-
"typescript": "^5.5.
|
|
45
|
+
"typescript": "^5.5.4"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"registry": "https://registry.npmjs.org",
|