@directcryptopay/sdk 0.1.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.
- package/README.md +357 -0
- package/dist/ConstantsUtil-B-_-u8aQ.js +6 -0
- package/dist/add-KF4m4jFK.js +19 -0
- package/dist/all-wallets-D6NAjQgX.js +10 -0
- package/dist/app-store-D7TTn-EO.js +21 -0
- package/dist/apple-DjX2E2hE.js +22 -0
- package/dist/arrow-bottom-C0YrNJYB.js +12 -0
- package/dist/arrow-bottom-circle-Dlxvx_XG.js +15 -0
- package/dist/arrow-left-x8_-lUyK.js +12 -0
- package/dist/arrow-right-BTZybj80.js +12 -0
- package/dist/arrow-top-LzH7iLCp.js +12 -0
- package/dist/bank-23jp-IV_.js +18 -0
- package/dist/browser-EjoorDid.js +18 -0
- package/dist/card-DGgWwtwC.js +18 -0
- package/dist/ccip-BMANewTU.js +150 -0
- package/dist/checkmark-B1qcQhBo.js +15 -0
- package/dist/checkmark-bold-Cyc4IEEJ.js +12 -0
- package/dist/chevron-bottom-ClHs08rB.js +12 -0
- package/dist/chevron-left-O8h_551_.js +12 -0
- package/dist/chevron-right-DP3xpyIA.js +12 -0
- package/dist/chevron-top-CuwkBUs9.js +12 -0
- package/dist/chrome-store-zfT_aJ3R.js +65 -0
- package/dist/clock-DHZqivIS.js +12 -0
- package/dist/close-Cp9rNAw4.js +12 -0
- package/dist/coinPlaceholder-U7-T1KKQ.js +12 -0
- package/dist/compass-Ds5-PRSR.js +12 -0
- package/dist/copy-Jg4HdIMf.js +19 -0
- package/dist/core/api.d.ts +30 -0
- package/dist/core/config.d.ts +59 -0
- package/dist/core/logic.d.ts +2 -0
- package/dist/core/wallet.d.ts +34 -0
- package/dist/cursor-DmMevduB.js +7 -0
- package/dist/cursor-transparent-Dn9-1SV8.js +16 -0
- package/dist/dcp-sdk.umd.js +12000 -0
- package/dist/dcp.d.ts +10 -0
- package/dist/desktop-C4udXXlZ.js +13 -0
- package/dist/disconnect-wd1BYLxt.js +12 -0
- package/dist/discord-DthxuCAP.js +21 -0
- package/dist/email-B3jSnUFE.js +696 -0
- package/dist/embedded-wallet-CJHmoBI2.js +468 -0
- package/dist/etherscan-Cjp4xfMW.js +10 -0
- package/dist/exclamation-triangle-CRNR5WOy.js +8 -0
- package/dist/extension-Cydk0mZt.js +12 -0
- package/dist/external-link-CuPTAoq9.js +12 -0
- package/dist/facebook-CghqXmdf.js +30 -0
- package/dist/farcaster-BREqMX4y.js +16 -0
- package/dist/filters-Dn_Ys7ew.js +12 -0
- package/dist/github-C-A7JmIY.js +22 -0
- package/dist/google-CCdM_naE.js +22 -0
- package/dist/hashTypedData-D2Qmzscs.js +197 -0
- package/dist/help-circle-DIH4vyj3.js +16 -0
- package/dist/id-DkJ0gBuy.js +16 -0
- package/dist/if-defined-BciplFKz.js +744 -0
- package/dist/image-qMjyiXM0.js +8 -0
- package/dist/index--3Zp0jAb.js +45 -0
- package/dist/index-1adX-Fit.js +65 -0
- package/dist/index-AvC0IGDl.js +7864 -0
- package/dist/index-B2-vKLd8.js +276 -0
- package/dist/index-B2iDt0TJ.js +146 -0
- package/dist/index-B5zkXsLJ.js +320 -0
- package/dist/index-B7K86vWu.js +1742 -0
- package/dist/index-BBkcvSiY.js +511 -0
- package/dist/index-BdjxQs66.js +181 -0
- package/dist/index-Bijd4_Ns.js +294 -0
- package/dist/index-BpXOsxzU.js +387 -0
- package/dist/index-C1QEJL-2.js +572 -0
- package/dist/index-C27dwOyE.js +243 -0
- package/dist/index-C4BX3QW8.js +58 -0
- package/dist/index-CMPIqsB1.js +170 -0
- package/dist/index-CTYngdl0.js +21991 -0
- package/dist/index-CUdQyyFn.js +51 -0
- package/dist/index-CX60z_g2.js +573 -0
- package/dist/index-CppCc1n8.js +65 -0
- package/dist/index-CqVegmN4.js +559 -0
- package/dist/index-CuiyMA8F.js +78 -0
- package/dist/index-CwB_qRfM.js +305 -0
- package/dist/index-CxOF7GqE.js +265 -0
- package/dist/index-D-IzHD_8.js +54 -0
- package/dist/index-DRNiFv9I.js +218 -0
- package/dist/index-Da8oZh8H.js +838 -0
- package/dist/index-DiHImG4L.js +44236 -0
- package/dist/index-DmOMXRG1.js +181 -0
- package/dist/index-DoSYqTQg.js +199 -0
- package/dist/index-DpHXq5_E.js +603 -0
- package/dist/index-DtCsAVBg.js +78 -0
- package/dist/index-Ij6XA6_4.js +77 -0
- package/dist/index-SzyBYfzA.js +8490 -0
- package/dist/index-eW8y-mXH.js +257 -0
- package/dist/index-fxzIDZsb.js +75 -0
- package/dist/index-lbhz9evJ.js +97 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/info-DMIGgjkL.js +7 -0
- package/dist/info-circle-CJuIKZSx.js +16 -0
- package/dist/lightbulb-qFT6WEWV.js +7 -0
- package/dist/localBatchGatewayRequest-CsMVMFBc.js +91 -0
- package/dist/mail-DoYgQvOt.js +12 -0
- package/dist/mobile-URtsh7o-.js +13 -0
- package/dist/more-DoQd10TF.js +15 -0
- package/dist/network-placeholder-BBA2Ue6C.js +18 -0
- package/dist/nftPlaceholder-C9RXWz9k.js +12 -0
- package/dist/off-YcuDQczT.js +12 -0
- package/dist/onramp-BfqDIx4o.js +1279 -0
- package/dist/parseSignature-280HB24T.js +3560 -0
- package/dist/play-store-sFaloG_r.js +36 -0
- package/dist/plus-l0wekSht.js +17 -0
- package/dist/qr-code-CihrUU4G.js +10 -0
- package/dist/receive-dfY1Cu-g.js +186 -0
- package/dist/recycle-horizontal-nXu6YaPw.js +13 -0
- package/dist/ref-huAzXCX0.js +41 -0
- package/dist/refresh-D2ZbVeNC.js +12 -0
- package/dist/reown-logo-BMaTMJmc.js +16 -0
- package/dist/search-YVM9q3J-.js +12 -0
- package/dist/secp256k1-BrysY3Sv.js +1302 -0
- package/dist/secp256k1-DPQgTBwQ.js +1510 -0
- package/dist/send-BwQZPKxI.js +19 -0
- package/dist/send-GyetMVu1.js +1038 -0
- package/dist/socials-B0W91J9k.js +574 -0
- package/dist/swapHorizontal-Dy_oQEkp.js +12 -0
- package/dist/swapHorizontalBold-C4JpaMpc.js +12 -0
- package/dist/swapHorizontalMedium-D5NuVZFh.js +20 -0
- package/dist/swapHorizontalRoundedBold-Bq4P2MCj.js +12 -0
- package/dist/swapVertical-CVQ8Mg03.js +12 -0
- package/dist/swaps-CA04SSdK.js +1637 -0
- package/dist/telegram-BP4SgW_L.js +20 -0
- package/dist/three-dots-BJYGJ-dQ.js +9 -0
- package/dist/transactions-Bq-98Tsg.js +37 -0
- package/dist/twitch-DTATWo9M.js +22 -0
- package/dist/twitterIcon-D5UWPInb.js +10 -0
- package/dist/types.d.ts +128 -0
- package/dist/ui/Modal.d.ts +9 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/verify-Byvj8Wi1.js +12 -0
- package/dist/verify-filled-B40taNm0.js +12 -0
- package/dist/w3m-modal-HV6SE74G.js +1037 -0
- package/dist/wallet-Cp-6Kk88.js +12 -0
- package/dist/wallet-placeholder-C3juwA9o.js +18 -0
- package/dist/walletconnect-CRkIiLCx.js +36 -0
- package/dist/warning-circle-DtvCLwG4.js +16 -0
- package/dist/x-Cqyx5eCt.js +16 -0
- package/package.json +70 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cz as d, cC as u, cG as p, cA as m, cB as f } from "./index-DiHImG4L.js";
|
|
2
|
+
import { n as h, c as g } from "./if-defined-BciplFKz.js";
|
|
3
|
+
const v = d`
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
width: var(--local-width);
|
|
7
|
+
height: var(--local-height);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
img {
|
|
11
|
+
display: block;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
object-fit: cover;
|
|
15
|
+
object-position: center center;
|
|
16
|
+
border-radius: inherit;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
var a = function(s, t, r, o) {
|
|
20
|
+
var c = arguments.length, e = c < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, r) : o, n;
|
|
21
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") e = Reflect.decorate(s, t, r, o);
|
|
22
|
+
else for (var l = s.length - 1; l >= 0; l--) (n = s[l]) && (e = (c < 3 ? n(e) : c > 3 ? n(t, r, e) : n(t, r)) || e);
|
|
23
|
+
return c > 3 && e && Object.defineProperty(t, r, e), e;
|
|
24
|
+
};
|
|
25
|
+
let i = class extends m {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments), this.src = "./path/to/image.jpg", this.alt = "Image", this.size = void 0;
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return this.style.cssText = `
|
|
31
|
+
--local-width: ${this.size ? `var(--wui-icon-size-${this.size});` : "100%"};
|
|
32
|
+
--local-height: ${this.size ? `var(--wui-icon-size-${this.size});` : "100%"};
|
|
33
|
+
`, f`<img src=${this.src} alt=${this.alt} @error=${this.handleImageError} />`;
|
|
34
|
+
}
|
|
35
|
+
handleImageError() {
|
|
36
|
+
this.dispatchEvent(new CustomEvent("onLoadError", { bubbles: !0, composed: !0 }));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
i.styles = [u, p, v];
|
|
40
|
+
a([
|
|
41
|
+
h()
|
|
42
|
+
], i.prototype, "src", void 0);
|
|
43
|
+
a([
|
|
44
|
+
h()
|
|
45
|
+
], i.prototype, "alt", void 0);
|
|
46
|
+
a([
|
|
47
|
+
h()
|
|
48
|
+
], i.prototype, "size", void 0);
|
|
49
|
+
i = a([
|
|
50
|
+
g("wui-image")
|
|
51
|
+
], i);
|
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import { cT as g, cS as v, d0 as A, d1 as N, d2 as l, cO as Q, cP as j, cE as S, cU as f, d3 as D, cX as x, cY as F, d4 as V, d5 as R, d6 as $, d7 as Y, d8 as H, cQ as K, cR as X, cz as J, cC as Z, cD as ee, cA as te, cB as M } from "./index-DiHImG4L.js";
|
|
2
|
+
import { n as q, c as ne } from "./if-defined-BciplFKz.js";
|
|
3
|
+
import "./index-CUdQyyFn.js";
|
|
4
|
+
import "./index-fxzIDZsb.js";
|
|
5
|
+
const _ = {
|
|
6
|
+
async getTokenList() {
|
|
7
|
+
var a;
|
|
8
|
+
const t = g.state.activeCaipNetwork, n = await A.fetchSwapTokens({
|
|
9
|
+
chainId: t == null ? void 0 : t.caipNetworkId
|
|
10
|
+
});
|
|
11
|
+
return ((a = n == null ? void 0 : n.tokens) == null ? void 0 : a.map((s) => ({
|
|
12
|
+
...s,
|
|
13
|
+
eip2612: !1,
|
|
14
|
+
quantity: {
|
|
15
|
+
decimals: "0",
|
|
16
|
+
numeric: "0"
|
|
17
|
+
},
|
|
18
|
+
price: 0,
|
|
19
|
+
value: 0
|
|
20
|
+
}))) || [];
|
|
21
|
+
},
|
|
22
|
+
async fetchGasPrice() {
|
|
23
|
+
var n, o;
|
|
24
|
+
const t = g.state.activeCaipNetwork;
|
|
25
|
+
if (!t)
|
|
26
|
+
return null;
|
|
27
|
+
try {
|
|
28
|
+
switch (t.chainNamespace) {
|
|
29
|
+
case "solana":
|
|
30
|
+
const a = (o = await ((n = N) == null ? void 0 : n.estimateGas({ chainNamespace: "solana" }))) == null ? void 0 : o.toString();
|
|
31
|
+
return {
|
|
32
|
+
standard: a,
|
|
33
|
+
fast: a,
|
|
34
|
+
instant: a
|
|
35
|
+
};
|
|
36
|
+
case "eip155":
|
|
37
|
+
default:
|
|
38
|
+
return await A.fetchGasPrice({
|
|
39
|
+
chainId: t.caipNetworkId
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
async fetchSwapAllowance({ tokenAddress: t, userAddress: n, sourceTokenAmount: o, sourceTokenDecimals: a }) {
|
|
47
|
+
const s = await A.fetchSwapAllowance({
|
|
48
|
+
tokenAddress: t,
|
|
49
|
+
userAddress: n
|
|
50
|
+
});
|
|
51
|
+
if (s != null && s.allowance && o && a) {
|
|
52
|
+
const i = N.parseUnits(o, a) || 0;
|
|
53
|
+
return BigInt(s.allowance) >= i;
|
|
54
|
+
}
|
|
55
|
+
return !1;
|
|
56
|
+
},
|
|
57
|
+
async getMyTokensWithBalance(t) {
|
|
58
|
+
const n = v.state.address, o = g.state.activeCaipNetwork;
|
|
59
|
+
if (!n || !o)
|
|
60
|
+
return [];
|
|
61
|
+
const s = (await A.getBalance(n, o.caipNetworkId, t)).balances.filter((i) => i.quantity.decimals !== "0");
|
|
62
|
+
return v.setTokenBalance(s, g.state.activeChain), this.mapBalancesToSwapTokens(s);
|
|
63
|
+
},
|
|
64
|
+
mapBalancesToSwapTokens(t) {
|
|
65
|
+
return (t == null ? void 0 : t.map((n) => ({
|
|
66
|
+
...n,
|
|
67
|
+
address: n != null && n.address ? n.address : g.getActiveNetworkTokenAddress(),
|
|
68
|
+
decimals: parseInt(n.quantity.decimals, 10),
|
|
69
|
+
logoUri: n.iconUrl,
|
|
70
|
+
eip2612: !1
|
|
71
|
+
}))) || [];
|
|
72
|
+
}
|
|
73
|
+
}, P = {
|
|
74
|
+
getGasPriceInEther(t, n) {
|
|
75
|
+
const o = n * t;
|
|
76
|
+
return Number(o) / 1e18;
|
|
77
|
+
},
|
|
78
|
+
getGasPriceInUSD(t, n, o) {
|
|
79
|
+
const a = P.getGasPriceInEther(n, o);
|
|
80
|
+
return l.bigNumber(t).times(a).toNumber();
|
|
81
|
+
},
|
|
82
|
+
getPriceImpact({ sourceTokenAmount: t, sourceTokenPriceInUSD: n, toTokenPriceInUSD: o, toTokenAmount: a }) {
|
|
83
|
+
const s = l.bigNumber(t).times(n), i = l.bigNumber(a).times(o);
|
|
84
|
+
return s.minus(i).div(s).times(100).toNumber();
|
|
85
|
+
},
|
|
86
|
+
getMaxSlippage(t, n) {
|
|
87
|
+
const o = l.bigNumber(t).div(100);
|
|
88
|
+
return l.multiply(n, o).toNumber();
|
|
89
|
+
},
|
|
90
|
+
getProviderFee(t, n = 85e-4) {
|
|
91
|
+
return l.bigNumber(t).times(n).toString();
|
|
92
|
+
},
|
|
93
|
+
isInsufficientNetworkTokenForGas(t, n) {
|
|
94
|
+
const o = n || "0";
|
|
95
|
+
return l.bigNumber(t).eq(0) ? !0 : l.bigNumber(l.bigNumber(o)).gt(t);
|
|
96
|
+
},
|
|
97
|
+
isInsufficientSourceTokenForSwap(t, n, o) {
|
|
98
|
+
var i, u;
|
|
99
|
+
const a = (u = (i = o == null ? void 0 : o.find((c) => c.address === n)) == null ? void 0 : i.quantity) == null ? void 0 : u.numeric;
|
|
100
|
+
return l.bigNumber(a || "0").lt(t);
|
|
101
|
+
},
|
|
102
|
+
getToTokenAmount({ sourceToken: t, toToken: n, sourceTokenPrice: o, toTokenPrice: a, sourceTokenAmount: s }) {
|
|
103
|
+
if (s === "0" || !t || !n)
|
|
104
|
+
return "0";
|
|
105
|
+
const i = t.decimals, u = o, c = n.decimals, T = a;
|
|
106
|
+
if (T <= 0)
|
|
107
|
+
return "0";
|
|
108
|
+
const d = l.bigNumber(s).times(85e-4), w = l.bigNumber(s).minus(d).times(l.bigNumber(10).pow(i)), h = l.bigNumber(u).div(T), b = i - c;
|
|
109
|
+
return w.times(h).div(l.bigNumber(10).pow(b)).div(l.bigNumber(10).pow(c)).toFixed(c).toString();
|
|
110
|
+
}
|
|
111
|
+
}, z = 15e4, oe = 6, k = {
|
|
112
|
+
// Loading states
|
|
113
|
+
initializing: !1,
|
|
114
|
+
initialized: !1,
|
|
115
|
+
loadingPrices: !1,
|
|
116
|
+
loadingQuote: !1,
|
|
117
|
+
loadingApprovalTransaction: !1,
|
|
118
|
+
loadingBuildTransaction: !1,
|
|
119
|
+
loadingTransaction: !1,
|
|
120
|
+
// Error states
|
|
121
|
+
fetchError: !1,
|
|
122
|
+
// Approval & Swap transaction states
|
|
123
|
+
approvalTransaction: void 0,
|
|
124
|
+
swapTransaction: void 0,
|
|
125
|
+
transactionError: void 0,
|
|
126
|
+
// Input values
|
|
127
|
+
sourceToken: void 0,
|
|
128
|
+
sourceTokenAmount: "",
|
|
129
|
+
sourceTokenPriceInUSD: 0,
|
|
130
|
+
toToken: void 0,
|
|
131
|
+
toTokenAmount: "",
|
|
132
|
+
toTokenPriceInUSD: 0,
|
|
133
|
+
networkPrice: "0",
|
|
134
|
+
networkBalanceInUSD: "0",
|
|
135
|
+
networkTokenSymbol: "",
|
|
136
|
+
inputError: void 0,
|
|
137
|
+
// Request values
|
|
138
|
+
slippage: $.CONVERT_SLIPPAGE_TOLERANCE,
|
|
139
|
+
// Tokens
|
|
140
|
+
tokens: void 0,
|
|
141
|
+
popularTokens: void 0,
|
|
142
|
+
suggestedTokens: void 0,
|
|
143
|
+
foundTokens: void 0,
|
|
144
|
+
myTokensWithBalance: void 0,
|
|
145
|
+
tokensPriceMap: {},
|
|
146
|
+
// Calculations
|
|
147
|
+
gasFee: "0",
|
|
148
|
+
gasPriceInUSD: 0,
|
|
149
|
+
priceImpact: void 0,
|
|
150
|
+
maxSlippage: void 0,
|
|
151
|
+
providerFee: void 0
|
|
152
|
+
}, e = j(k), U = {
|
|
153
|
+
state: e,
|
|
154
|
+
subscribe(t) {
|
|
155
|
+
return X(e, () => t(e));
|
|
156
|
+
},
|
|
157
|
+
subscribeKey(t, n) {
|
|
158
|
+
return K(e, t, n);
|
|
159
|
+
},
|
|
160
|
+
getParams() {
|
|
161
|
+
var T, d, p, w, h, b, I, y;
|
|
162
|
+
const t = g.state.activeCaipAddress, n = g.state.activeChain, o = F.getPlainAddress(t), a = g.getActiveNetworkTokenAddress(), s = Y.getConnectorId(n);
|
|
163
|
+
if (!o)
|
|
164
|
+
throw new Error("No address found to swap the tokens from.");
|
|
165
|
+
const i = !((T = e.toToken) != null && T.address) || !((d = e.toToken) != null && d.decimals), u = !((p = e.sourceToken) != null && p.address) || !((w = e.sourceToken) != null && w.decimals) || !l.bigNumber(e.sourceTokenAmount).gt(0), c = !e.sourceTokenAmount;
|
|
166
|
+
return {
|
|
167
|
+
networkAddress: a,
|
|
168
|
+
fromAddress: o,
|
|
169
|
+
fromCaipAddress: t,
|
|
170
|
+
sourceTokenAddress: (h = e.sourceToken) == null ? void 0 : h.address,
|
|
171
|
+
toTokenAddress: (b = e.toToken) == null ? void 0 : b.address,
|
|
172
|
+
toTokenAmount: e.toTokenAmount,
|
|
173
|
+
toTokenDecimals: (I = e.toToken) == null ? void 0 : I.decimals,
|
|
174
|
+
sourceTokenAmount: e.sourceTokenAmount,
|
|
175
|
+
sourceTokenDecimals: (y = e.sourceToken) == null ? void 0 : y.decimals,
|
|
176
|
+
invalidToToken: i,
|
|
177
|
+
invalidSourceToken: u,
|
|
178
|
+
invalidSourceTokenAmount: c,
|
|
179
|
+
availableToSwap: t && !i && !u && !c,
|
|
180
|
+
isAuthConnector: s === H.CONNECTOR_ID.AUTH
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
setSourceToken(t) {
|
|
184
|
+
if (!t) {
|
|
185
|
+
e.sourceToken = t, e.sourceTokenAmount = "", e.sourceTokenPriceInUSD = 0;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
e.sourceToken = t, r.setTokenPrice(t.address, "sourceToken");
|
|
189
|
+
},
|
|
190
|
+
setSourceTokenAmount(t) {
|
|
191
|
+
e.sourceTokenAmount = t;
|
|
192
|
+
},
|
|
193
|
+
setToToken(t) {
|
|
194
|
+
if (!t) {
|
|
195
|
+
e.toToken = t, e.toTokenAmount = "", e.toTokenPriceInUSD = 0;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
e.toToken = t, r.setTokenPrice(t.address, "toToken");
|
|
199
|
+
},
|
|
200
|
+
setToTokenAmount(t) {
|
|
201
|
+
e.toTokenAmount = t ? l.formatNumberToLocalString(t, oe) : "";
|
|
202
|
+
},
|
|
203
|
+
async setTokenPrice(t, n) {
|
|
204
|
+
let o = e.tokensPriceMap[t] || 0;
|
|
205
|
+
o || (e.loadingPrices = !0, o = await r.getAddressPrice(t)), n === "sourceToken" ? e.sourceTokenPriceInUSD = o : n === "toToken" && (e.toTokenPriceInUSD = o), e.loadingPrices && (e.loadingPrices = !1), r.getParams().availableToSwap && r.swapTokens();
|
|
206
|
+
},
|
|
207
|
+
switchTokens() {
|
|
208
|
+
if (e.initializing || !e.initialized)
|
|
209
|
+
return;
|
|
210
|
+
const t = e.toToken ? { ...e.toToken } : void 0, n = e.sourceToken ? { ...e.sourceToken } : void 0, o = t && e.toTokenAmount === "" ? "1" : e.toTokenAmount;
|
|
211
|
+
r.setSourceToken(t), r.setToToken(n), r.setSourceTokenAmount(o), r.setToTokenAmount(""), r.swapTokens();
|
|
212
|
+
},
|
|
213
|
+
resetState() {
|
|
214
|
+
e.myTokensWithBalance = k.myTokensWithBalance, e.tokensPriceMap = k.tokensPriceMap, e.initialized = k.initialized, e.sourceToken = k.sourceToken, e.sourceTokenAmount = k.sourceTokenAmount, e.sourceTokenPriceInUSD = k.sourceTokenPriceInUSD, e.toToken = k.toToken, e.toTokenAmount = k.toTokenAmount, e.toTokenPriceInUSD = k.toTokenPriceInUSD, e.networkPrice = k.networkPrice, e.networkTokenSymbol = k.networkTokenSymbol, e.networkBalanceInUSD = k.networkBalanceInUSD, e.inputError = k.inputError, e.myTokensWithBalance = k.myTokensWithBalance;
|
|
215
|
+
},
|
|
216
|
+
resetValues() {
|
|
217
|
+
var o;
|
|
218
|
+
const { networkAddress: t } = r.getParams(), n = (o = e.tokens) == null ? void 0 : o.find((a) => a.address === t);
|
|
219
|
+
r.setSourceToken(n), r.setToToken(void 0);
|
|
220
|
+
},
|
|
221
|
+
getApprovalLoadingState() {
|
|
222
|
+
return e.loadingApprovalTransaction;
|
|
223
|
+
},
|
|
224
|
+
clearError() {
|
|
225
|
+
e.transactionError = void 0;
|
|
226
|
+
},
|
|
227
|
+
async initializeState() {
|
|
228
|
+
if (!e.initializing) {
|
|
229
|
+
if (e.initializing = !0, !e.initialized)
|
|
230
|
+
try {
|
|
231
|
+
await r.fetchTokens(), e.initialized = !0;
|
|
232
|
+
} catch {
|
|
233
|
+
e.initialized = !1, f.showError("Failed to initialize swap"), S.goBack();
|
|
234
|
+
}
|
|
235
|
+
e.initializing = !1;
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
async fetchTokens() {
|
|
239
|
+
var o;
|
|
240
|
+
const { networkAddress: t } = r.getParams();
|
|
241
|
+
await r.getTokenList(), await r.getNetworkTokenPrice(), await r.getMyTokensWithBalance();
|
|
242
|
+
const n = (o = e.tokens) == null ? void 0 : o.find((a) => a.address === t);
|
|
243
|
+
n && (e.networkTokenSymbol = n.symbol, r.setSourceToken(n), r.setSourceTokenAmount("1"));
|
|
244
|
+
},
|
|
245
|
+
async getTokenList() {
|
|
246
|
+
const t = await _.getTokenList();
|
|
247
|
+
e.tokens = t, e.popularTokens = t.sort((n, o) => n.symbol < o.symbol ? -1 : n.symbol > o.symbol ? 1 : 0), e.suggestedTokens = t.filter((n) => !!$.SWAP_SUGGESTED_TOKENS.includes(n.symbol), {});
|
|
248
|
+
},
|
|
249
|
+
async getAddressPrice(t) {
|
|
250
|
+
var T, d;
|
|
251
|
+
const n = e.tokensPriceMap[t];
|
|
252
|
+
if (n)
|
|
253
|
+
return n;
|
|
254
|
+
const o = await A.fetchTokenPrice({
|
|
255
|
+
addresses: [t]
|
|
256
|
+
}), a = (o == null ? void 0 : o.fungibles) || [], s = [...e.tokens || [], ...e.myTokensWithBalance || []], i = (T = s == null ? void 0 : s.find((p) => p.address === t)) == null ? void 0 : T.symbol, u = ((d = a.find((p) => p.symbol.toLowerCase() === (i == null ? void 0 : i.toLowerCase()))) == null ? void 0 : d.price) || 0, c = parseFloat(u.toString());
|
|
257
|
+
return e.tokensPriceMap[t] = c, c;
|
|
258
|
+
},
|
|
259
|
+
async getNetworkTokenPrice() {
|
|
260
|
+
var s;
|
|
261
|
+
const { networkAddress: t } = r.getParams(), o = (s = (await A.fetchTokenPrice({
|
|
262
|
+
addresses: [t]
|
|
263
|
+
}).catch(() => (f.showError("Failed to fetch network token price"), { fungibles: [] }))).fungibles) == null ? void 0 : s[0], a = (o == null ? void 0 : o.price.toString()) || "0";
|
|
264
|
+
e.tokensPriceMap[t] = parseFloat(a), e.networkTokenSymbol = (o == null ? void 0 : o.symbol) || "", e.networkPrice = a;
|
|
265
|
+
},
|
|
266
|
+
async getMyTokensWithBalance(t) {
|
|
267
|
+
const n = await R.getMyTokensWithBalance(t), o = R.mapBalancesToSwapTokens(n);
|
|
268
|
+
o && (await r.getInitialGasPrice(), r.setBalances(o));
|
|
269
|
+
},
|
|
270
|
+
setBalances(t) {
|
|
271
|
+
const { networkAddress: n } = r.getParams(), o = g.state.activeCaipNetwork;
|
|
272
|
+
if (!o)
|
|
273
|
+
return;
|
|
274
|
+
const a = t.find((s) => s.address === n);
|
|
275
|
+
t.forEach((s) => {
|
|
276
|
+
e.tokensPriceMap[s.address] = s.price || 0;
|
|
277
|
+
}), e.myTokensWithBalance = t.filter((s) => s.address.startsWith(o.caipNetworkId)), e.networkBalanceInUSD = a ? l.multiply(a.quantity.numeric, a.price).toString() : "0";
|
|
278
|
+
},
|
|
279
|
+
async getInitialGasPrice() {
|
|
280
|
+
var n, o;
|
|
281
|
+
const t = await _.fetchGasPrice();
|
|
282
|
+
if (!t)
|
|
283
|
+
return { gasPrice: null, gasPriceInUSD: null };
|
|
284
|
+
switch ((o = (n = g.state) == null ? void 0 : n.activeCaipNetwork) == null ? void 0 : o.chainNamespace) {
|
|
285
|
+
case "solana":
|
|
286
|
+
return e.gasFee = t.standard ?? "0", e.gasPriceInUSD = l.multiply(t.standard, e.networkPrice).div(1e9).toNumber(), {
|
|
287
|
+
gasPrice: BigInt(e.gasFee),
|
|
288
|
+
gasPriceInUSD: Number(e.gasPriceInUSD)
|
|
289
|
+
};
|
|
290
|
+
case "eip155":
|
|
291
|
+
default:
|
|
292
|
+
const a = t.standard ?? "0", s = BigInt(a), i = BigInt(z), u = P.getGasPriceInUSD(e.networkPrice, i, s);
|
|
293
|
+
return e.gasFee = a, e.gasPriceInUSD = u, { gasPrice: s, gasPriceInUSD: u };
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
// -- Swap -------------------------------------- //
|
|
297
|
+
async swapTokens() {
|
|
298
|
+
var i, u;
|
|
299
|
+
const t = v.state.address, n = e.sourceToken, o = e.toToken, a = l.bigNumber(e.sourceTokenAmount).gt(0);
|
|
300
|
+
if (a || r.setToTokenAmount(""), !o || !n || e.loadingPrices || !a)
|
|
301
|
+
return;
|
|
302
|
+
e.loadingQuote = !0;
|
|
303
|
+
const s = l.bigNumber(e.sourceTokenAmount).times(10 ** n.decimals).round(0);
|
|
304
|
+
try {
|
|
305
|
+
const c = await A.fetchSwapQuote({
|
|
306
|
+
userAddress: t,
|
|
307
|
+
from: n.address,
|
|
308
|
+
to: o.address,
|
|
309
|
+
gasPrice: e.gasFee,
|
|
310
|
+
amount: s.toString()
|
|
311
|
+
});
|
|
312
|
+
e.loadingQuote = !1;
|
|
313
|
+
const T = (u = (i = c == null ? void 0 : c.quotes) == null ? void 0 : i[0]) == null ? void 0 : u.toAmount;
|
|
314
|
+
if (!T) {
|
|
315
|
+
V.open({
|
|
316
|
+
shortMessage: "Incorrect amount",
|
|
317
|
+
longMessage: "Please enter a valid amount"
|
|
318
|
+
}, "error");
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const d = l.bigNumber(T).div(10 ** o.decimals).toString();
|
|
322
|
+
r.setToTokenAmount(d), r.hasInsufficientToken(e.sourceTokenAmount, n.address) ? e.inputError = "Insufficient balance" : (e.inputError = void 0, r.setTransactionDetails());
|
|
323
|
+
} catch {
|
|
324
|
+
e.loadingQuote = !1, e.inputError = "Insufficient balance";
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
// -- Create Transactions -------------------------------------- //
|
|
328
|
+
async getTransaction() {
|
|
329
|
+
const { fromCaipAddress: t, availableToSwap: n } = r.getParams(), o = e.sourceToken, a = e.toToken;
|
|
330
|
+
if (!(!t || !n || !o || !a || e.loadingQuote))
|
|
331
|
+
try {
|
|
332
|
+
e.loadingBuildTransaction = !0;
|
|
333
|
+
const s = await _.fetchSwapAllowance({
|
|
334
|
+
userAddress: t,
|
|
335
|
+
tokenAddress: o.address,
|
|
336
|
+
sourceTokenAmount: e.sourceTokenAmount,
|
|
337
|
+
sourceTokenDecimals: o.decimals
|
|
338
|
+
});
|
|
339
|
+
let i;
|
|
340
|
+
return s ? i = await r.createSwapTransaction() : i = await r.createAllowanceTransaction(), e.loadingBuildTransaction = !1, e.fetchError = !1, i;
|
|
341
|
+
} catch {
|
|
342
|
+
S.goBack(), f.showError("Failed to check allowance"), e.loadingBuildTransaction = !1, e.approvalTransaction = void 0, e.swapTransaction = void 0, e.fetchError = !0;
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
async createAllowanceTransaction() {
|
|
347
|
+
const { fromCaipAddress: t, sourceTokenAddress: n, toTokenAddress: o } = r.getParams();
|
|
348
|
+
if (!(!t || !o)) {
|
|
349
|
+
if (!n)
|
|
350
|
+
throw new Error("createAllowanceTransaction - No source token address found.");
|
|
351
|
+
try {
|
|
352
|
+
const a = await A.generateApproveCalldata({
|
|
353
|
+
from: n,
|
|
354
|
+
to: o,
|
|
355
|
+
userAddress: t
|
|
356
|
+
}), s = {
|
|
357
|
+
data: a.tx.data,
|
|
358
|
+
to: F.getPlainAddress(a.tx.from),
|
|
359
|
+
gasPrice: BigInt(a.tx.eip155.gasPrice),
|
|
360
|
+
value: BigInt(a.tx.value),
|
|
361
|
+
toAmount: e.toTokenAmount
|
|
362
|
+
};
|
|
363
|
+
return e.swapTransaction = void 0, e.approvalTransaction = {
|
|
364
|
+
data: s.data,
|
|
365
|
+
to: s.to,
|
|
366
|
+
gasPrice: s.gasPrice,
|
|
367
|
+
value: s.value,
|
|
368
|
+
toAmount: s.toAmount
|
|
369
|
+
}, {
|
|
370
|
+
data: s.data,
|
|
371
|
+
to: s.to,
|
|
372
|
+
gasPrice: s.gasPrice,
|
|
373
|
+
value: s.value,
|
|
374
|
+
toAmount: s.toAmount
|
|
375
|
+
};
|
|
376
|
+
} catch {
|
|
377
|
+
S.goBack(), f.showError("Failed to create approval transaction"), e.approvalTransaction = void 0, e.swapTransaction = void 0, e.fetchError = !0;
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
async createSwapTransaction() {
|
|
383
|
+
var u;
|
|
384
|
+
const { networkAddress: t, fromCaipAddress: n, sourceTokenAmount: o } = r.getParams(), a = e.sourceToken, s = e.toToken;
|
|
385
|
+
if (!n || !o || !a || !s)
|
|
386
|
+
return;
|
|
387
|
+
const i = (u = N.parseUnits(o, a.decimals)) == null ? void 0 : u.toString();
|
|
388
|
+
try {
|
|
389
|
+
const c = await A.generateSwapCalldata({
|
|
390
|
+
userAddress: n,
|
|
391
|
+
from: a.address,
|
|
392
|
+
to: s.address,
|
|
393
|
+
amount: i,
|
|
394
|
+
disableEstimate: !0
|
|
395
|
+
}), T = a.address === t, d = BigInt(c.tx.eip155.gas), p = BigInt(c.tx.eip155.gasPrice), w = {
|
|
396
|
+
data: c.tx.data,
|
|
397
|
+
to: F.getPlainAddress(c.tx.to),
|
|
398
|
+
gas: d,
|
|
399
|
+
gasPrice: p,
|
|
400
|
+
value: BigInt(T ? i ?? "0" : "0"),
|
|
401
|
+
toAmount: e.toTokenAmount
|
|
402
|
+
};
|
|
403
|
+
return e.gasPriceInUSD = P.getGasPriceInUSD(e.networkPrice, d, p), e.approvalTransaction = void 0, e.swapTransaction = w, w;
|
|
404
|
+
} catch {
|
|
405
|
+
S.goBack(), f.showError("Failed to create transaction"), e.approvalTransaction = void 0, e.swapTransaction = void 0, e.fetchError = !0;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
// -- Send Transactions --------------------------------- //
|
|
410
|
+
async sendTransactionForApproval(t) {
|
|
411
|
+
var s, i, u, c;
|
|
412
|
+
const { fromAddress: n, isAuthConnector: o } = r.getParams();
|
|
413
|
+
e.loadingApprovalTransaction = !0;
|
|
414
|
+
const a = "Approve limit increase in your wallet";
|
|
415
|
+
o ? S.pushTransactionStack({
|
|
416
|
+
onSuccess() {
|
|
417
|
+
f.showLoading(a);
|
|
418
|
+
}
|
|
419
|
+
}) : f.showLoading(a);
|
|
420
|
+
try {
|
|
421
|
+
await N.sendTransaction({
|
|
422
|
+
address: n,
|
|
423
|
+
to: t.to,
|
|
424
|
+
data: t.data,
|
|
425
|
+
value: t.value,
|
|
426
|
+
chainNamespace: "eip155"
|
|
427
|
+
}), await r.swapTokens(), await r.getTransaction(), e.approvalTransaction = void 0, e.loadingApprovalTransaction = !1;
|
|
428
|
+
} catch (T) {
|
|
429
|
+
const d = T;
|
|
430
|
+
e.transactionError = d == null ? void 0 : d.shortMessage, e.loadingApprovalTransaction = !1, f.showError((d == null ? void 0 : d.shortMessage) || "Transaction error"), D.sendEvent({
|
|
431
|
+
type: "track",
|
|
432
|
+
event: "SWAP_APPROVAL_ERROR",
|
|
433
|
+
properties: {
|
|
434
|
+
message: (d == null ? void 0 : d.shortMessage) || (d == null ? void 0 : d.message) || "Unknown",
|
|
435
|
+
network: ((s = g.state.activeCaipNetwork) == null ? void 0 : s.caipNetworkId) || "",
|
|
436
|
+
swapFromToken: ((i = r.state.sourceToken) == null ? void 0 : i.symbol) || "",
|
|
437
|
+
swapToToken: ((u = r.state.toToken) == null ? void 0 : u.symbol) || "",
|
|
438
|
+
swapFromAmount: r.state.sourceTokenAmount || "",
|
|
439
|
+
swapToAmount: r.state.toTokenAmount || "",
|
|
440
|
+
isSmartAccount: ((c = v.state.preferredAccountTypes) == null ? void 0 : c.eip155) === x.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
async sendTransactionForSwap(t) {
|
|
446
|
+
var u, c, T, d, p, w, h, b, I, y, E, W, G, O;
|
|
447
|
+
if (!t)
|
|
448
|
+
return;
|
|
449
|
+
const { fromAddress: n, toTokenAmount: o, isAuthConnector: a } = r.getParams();
|
|
450
|
+
e.loadingTransaction = !0;
|
|
451
|
+
const s = `Swapping ${(u = e.sourceToken) == null ? void 0 : u.symbol} to ${l.formatNumberToLocalString(o, 3)} ${(c = e.toToken) == null ? void 0 : c.symbol}`, i = `Swapped ${(T = e.sourceToken) == null ? void 0 : T.symbol} to ${l.formatNumberToLocalString(o, 3)} ${(d = e.toToken) == null ? void 0 : d.symbol}`;
|
|
452
|
+
a ? S.pushTransactionStack({
|
|
453
|
+
onSuccess() {
|
|
454
|
+
S.replace("Account"), f.showLoading(s), U.resetState();
|
|
455
|
+
}
|
|
456
|
+
}) : f.showLoading("Confirm transaction in your wallet");
|
|
457
|
+
try {
|
|
458
|
+
const B = [(p = e.sourceToken) == null ? void 0 : p.address, (w = e.toToken) == null ? void 0 : w.address].join(","), m = await N.sendTransaction({
|
|
459
|
+
address: n,
|
|
460
|
+
to: t.to,
|
|
461
|
+
data: t.data,
|
|
462
|
+
value: t.value,
|
|
463
|
+
chainNamespace: "eip155"
|
|
464
|
+
});
|
|
465
|
+
return e.loadingTransaction = !1, f.showSuccess(i), D.sendEvent({
|
|
466
|
+
type: "track",
|
|
467
|
+
event: "SWAP_SUCCESS",
|
|
468
|
+
properties: {
|
|
469
|
+
network: ((h = g.state.activeCaipNetwork) == null ? void 0 : h.caipNetworkId) || "",
|
|
470
|
+
swapFromToken: ((b = r.state.sourceToken) == null ? void 0 : b.symbol) || "",
|
|
471
|
+
swapToToken: ((I = r.state.toToken) == null ? void 0 : I.symbol) || "",
|
|
472
|
+
swapFromAmount: r.state.sourceTokenAmount || "",
|
|
473
|
+
swapToAmount: r.state.toTokenAmount || "",
|
|
474
|
+
isSmartAccount: ((y = v.state.preferredAccountTypes) == null ? void 0 : y.eip155) === x.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
475
|
+
}
|
|
476
|
+
}), U.resetState(), a || S.replace("Account"), U.getMyTokensWithBalance(B), m;
|
|
477
|
+
} catch (B) {
|
|
478
|
+
const m = B;
|
|
479
|
+
e.transactionError = m == null ? void 0 : m.shortMessage, e.loadingTransaction = !1, f.showError((m == null ? void 0 : m.shortMessage) || "Transaction error"), D.sendEvent({
|
|
480
|
+
type: "track",
|
|
481
|
+
event: "SWAP_ERROR",
|
|
482
|
+
properties: {
|
|
483
|
+
message: (m == null ? void 0 : m.shortMessage) || (m == null ? void 0 : m.message) || "Unknown",
|
|
484
|
+
network: ((E = g.state.activeCaipNetwork) == null ? void 0 : E.caipNetworkId) || "",
|
|
485
|
+
swapFromToken: ((W = r.state.sourceToken) == null ? void 0 : W.symbol) || "",
|
|
486
|
+
swapToToken: ((G = r.state.toToken) == null ? void 0 : G.symbol) || "",
|
|
487
|
+
swapFromAmount: r.state.sourceTokenAmount || "",
|
|
488
|
+
swapToAmount: r.state.toTokenAmount || "",
|
|
489
|
+
isSmartAccount: ((O = v.state.preferredAccountTypes) == null ? void 0 : O.eip155) === x.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
// -- Checks -------------------------------------------- //
|
|
496
|
+
hasInsufficientToken(t, n) {
|
|
497
|
+
return P.isInsufficientSourceTokenForSwap(t, n, e.myTokensWithBalance);
|
|
498
|
+
},
|
|
499
|
+
// -- Calculations -------------------------------------- //
|
|
500
|
+
setTransactionDetails() {
|
|
501
|
+
const { toTokenAddress: t, toTokenDecimals: n } = r.getParams();
|
|
502
|
+
!t || !n || (e.gasPriceInUSD = P.getGasPriceInUSD(e.networkPrice, BigInt(e.gasFee), BigInt(z)), e.priceImpact = P.getPriceImpact({
|
|
503
|
+
sourceTokenAmount: e.sourceTokenAmount,
|
|
504
|
+
sourceTokenPriceInUSD: e.sourceTokenPriceInUSD,
|
|
505
|
+
toTokenPriceInUSD: e.toTokenPriceInUSD,
|
|
506
|
+
toTokenAmount: e.toTokenAmount
|
|
507
|
+
}), e.maxSlippage = P.getMaxSlippage(e.slippage, e.toTokenAmount), e.providerFee = P.getProviderFee(e.sourceTokenAmount));
|
|
508
|
+
}
|
|
509
|
+
}, r = Q(U), se = J`
|
|
510
|
+
:host {
|
|
511
|
+
display: block;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
:host > button {
|
|
515
|
+
gap: var(--wui-spacing-xxs);
|
|
516
|
+
padding: var(--wui-spacing-xs);
|
|
517
|
+
padding-right: var(--wui-spacing-1xs);
|
|
518
|
+
height: 40px;
|
|
519
|
+
border-radius: var(--wui-border-radius-l);
|
|
520
|
+
background: var(--wui-color-gray-glass-002);
|
|
521
|
+
border-width: 0px;
|
|
522
|
+
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
:host > button wui-image {
|
|
526
|
+
width: 24px;
|
|
527
|
+
height: 24px;
|
|
528
|
+
border-radius: var(--wui-border-radius-s);
|
|
529
|
+
box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
|
|
530
|
+
}
|
|
531
|
+
`;
|
|
532
|
+
var L = function(t, n, o, a) {
|
|
533
|
+
var s = arguments.length, i = s < 3 ? n : a === null ? a = Object.getOwnPropertyDescriptor(n, o) : a, u;
|
|
534
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(t, n, o, a);
|
|
535
|
+
else for (var c = t.length - 1; c >= 0; c--) (u = t[c]) && (i = (s < 3 ? u(i) : s > 3 ? u(n, o, i) : u(n, o)) || i);
|
|
536
|
+
return s > 3 && i && Object.defineProperty(n, o, i), i;
|
|
537
|
+
};
|
|
538
|
+
let C = class extends te {
|
|
539
|
+
constructor() {
|
|
540
|
+
super(...arguments), this.text = "";
|
|
541
|
+
}
|
|
542
|
+
render() {
|
|
543
|
+
return M`
|
|
544
|
+
<button>
|
|
545
|
+
${this.tokenTemplate()}
|
|
546
|
+
<wui-text variant="paragraph-600" color="fg-100">${this.text}</wui-text>
|
|
547
|
+
</button>
|
|
548
|
+
`;
|
|
549
|
+
}
|
|
550
|
+
tokenTemplate() {
|
|
551
|
+
return this.imageSrc ? M`<wui-image src=${this.imageSrc}></wui-image>` : M`
|
|
552
|
+
<wui-icon-box
|
|
553
|
+
size="sm"
|
|
554
|
+
iconColor="fg-200"
|
|
555
|
+
backgroundColor="fg-300"
|
|
556
|
+
icon="networkPlaceholder"
|
|
557
|
+
></wui-icon-box>
|
|
558
|
+
`;
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
C.styles = [Z, ee, se];
|
|
562
|
+
L([
|
|
563
|
+
q()
|
|
564
|
+
], C.prototype, "imageSrc", void 0);
|
|
565
|
+
L([
|
|
566
|
+
q()
|
|
567
|
+
], C.prototype, "text", void 0);
|
|
568
|
+
C = L([
|
|
569
|
+
ne("wui-token-button")
|
|
570
|
+
], C);
|
|
571
|
+
export {
|
|
572
|
+
r as S
|
|
573
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { cz as c, cC as h, cA as l, cB as f } from "./index-DiHImG4L.js";
|
|
2
|
+
import { n as m, c as p } from "./if-defined-BciplFKz.js";
|
|
3
|
+
const v = c`
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
width: var(--wui-box-size-md);
|
|
7
|
+
height: var(--wui-box-size-md);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
svg {
|
|
11
|
+
width: var(--wui-box-size-md);
|
|
12
|
+
height: var(--wui-box-size-md);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
rect {
|
|
16
|
+
fill: none;
|
|
17
|
+
stroke: var(--wui-color-accent-100);
|
|
18
|
+
stroke-width: 4px;
|
|
19
|
+
stroke-linecap: round;
|
|
20
|
+
animation: dash 1s linear infinite;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@keyframes dash {
|
|
24
|
+
to {
|
|
25
|
+
stroke-dashoffset: 0px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
var u = function(o, t, r, s) {
|
|
30
|
+
var i = arguments.length, e = i < 3 ? t : s === null ? s = Object.getOwnPropertyDescriptor(t, r) : s, a;
|
|
31
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") e = Reflect.decorate(o, t, r, s);
|
|
32
|
+
else for (var d = o.length - 1; d >= 0; d--) (a = o[d]) && (e = (i < 3 ? a(e) : i > 3 ? a(t, r, e) : a(t, r)) || e);
|
|
33
|
+
return i > 3 && e && Object.defineProperty(t, r, e), e;
|
|
34
|
+
};
|
|
35
|
+
let n = class extends l {
|
|
36
|
+
constructor() {
|
|
37
|
+
super(...arguments), this.radius = 36;
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
return this.svgLoaderTemplate();
|
|
41
|
+
}
|
|
42
|
+
svgLoaderTemplate() {
|
|
43
|
+
const t = this.radius > 50 ? 50 : this.radius, s = 36 - t, i = 116 + s, e = 245 + s, a = 360 + s * 1.75;
|
|
44
|
+
return f`
|
|
45
|
+
<svg viewBox="0 0 110 110" width="110" height="110">
|
|
46
|
+
<rect
|
|
47
|
+
x="2"
|
|
48
|
+
y="2"
|
|
49
|
+
width="106"
|
|
50
|
+
height="106"
|
|
51
|
+
rx=${t}
|
|
52
|
+
stroke-dasharray="${i} ${e}"
|
|
53
|
+
stroke-dashoffset=${a}
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
n.styles = [h, v];
|
|
60
|
+
u([
|
|
61
|
+
m({ type: Number })
|
|
62
|
+
], n.prototype, "radius", void 0);
|
|
63
|
+
n = u([
|
|
64
|
+
p("wui-loading-thumbnail")
|
|
65
|
+
], n);
|