astra-modal-test 1.0.5 → 1.0.7
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/.github/workflows/code-quality.yml +43 -0
- package/.github/workflows/publish.yml +64 -0
- package/README.md +204 -0
- package/dist/SwapController-CsNqEWIM.js +447 -0
- package/dist/add-Dm_oSEbv.js +19 -0
- package/dist/all-wallets-DfLlzQJ3.js +10 -0
- package/dist/app-store-BMdJkp6P.js +21 -0
- package/dist/apple-BetlVMKw.js +22 -0
- package/dist/arrow-bottom-BddPptxy.js +12 -0
- package/dist/arrow-bottom-circle-CvdJJniv.js +15 -0
- package/dist/arrow-left-Bbq-z1nQ.js +12 -0
- package/dist/arrow-right-Bu4_SVLC.js +12 -0
- package/dist/arrow-top-CynlXB-M.js +12 -0
- package/dist/astra-sdk.es.js +4 -4
- package/dist/bank-B9QscNnS.js +18 -0
- package/dist/bin-v-tshf8_.js +8 -0
- package/dist/bitcoin-C01gkYyN.js +17 -0
- package/dist/browser-9uNaCY31.js +18 -0
- package/dist/card-hKR9lRzU.js +18 -0
- package/dist/{ccip-oZOrZYR9.js → ccip-CUCziAPw.js} +52 -49
- package/dist/checkmark-D1M40aM5.js +15 -0
- package/dist/checkmark-bold-1_UGl24m.js +12 -0
- package/dist/chevron-bottom-BleoRNRL.js +12 -0
- package/dist/chevron-left-C9JMU-3B.js +12 -0
- package/dist/chevron-right-Daue4WBx.js +12 -0
- package/dist/chevron-top-yuXekbUC.js +12 -0
- package/dist/chrome-store-BsUFRR7F.js +65 -0
- package/dist/circle-BCxdhM5X.js +8 -0
- package/dist/clock-7a-DWZQa.js +12 -0
- package/dist/close-DMQYuJ0z.js +12 -0
- package/dist/clsx.m-DCYaa4RU.js +20 -0
- package/dist/coinPlaceholder-DjQ-HnSH.js +12 -0
- package/dist/compass-AMecXNVm.js +12 -0
- package/dist/copy-CgIPGYbU.js +19 -0
- package/dist/cursor-DpYbTNcO.js +7 -0
- package/dist/cursor-transparent-C8iPJkn8.js +16 -0
- package/dist/desktop-BWVQVGng.js +13 -0
- package/dist/disconnect-C6IQRrtF.js +12 -0
- package/dist/discord-gH3i-QsC.js +21 -0
- package/dist/email-BxYwJC5T.js +10 -0
- package/dist/embedded-wallet-DCcVNgkc.js +464 -0
- package/dist/ethereum-CGWsmZaC.js +14 -0
- package/dist/etherscan-D4EFsAJ4.js +10 -0
- package/dist/exclamation-triangle-DNwQ1Xq6.js +8 -0
- package/dist/extension-DxQPsN2z.js +12 -0
- package/dist/external-link-BeEzrdgR.js +12 -0
- package/dist/facebook-B2Ix8_d3.js +30 -0
- package/dist/farcaster-BB83p8dC.js +16 -0
- package/dist/filters-PzdIomB1.js +12 -0
- package/dist/github-gcp1rxX0.js +22 -0
- package/dist/google-Qv9lTZcz.js +22 -0
- package/dist/help-circle-BLXTMjzX.js +16 -0
- package/dist/id-BHg2CRhj.js +16 -0
- package/dist/image-DWi1V30x.js +8 -0
- package/dist/index-4lbsZ6RQ.js +33 -0
- package/dist/index-64U3D9_n.js +21034 -0
- package/dist/index-CRU49I0g.js +15911 -0
- package/dist/index-ChxXyuZj.js +572 -0
- package/dist/index-ClS956E1.js +74511 -0
- package/dist/index-Cs4fWw01.js +386 -0
- package/dist/index-DfWqgW4h.js +709 -0
- package/dist/index-VYNI76FM.js +315 -0
- package/dist/index-qfkTLN90.js +10785 -0
- package/dist/index-r2ztgVN2.js +1060 -0
- package/dist/index-wvh7Yd5J.js +70 -0
- package/dist/info-Bl5tmiBJ.js +7 -0
- package/dist/info-circle-D2uYywg-.js +16 -0
- package/dist/lightbulb-HvXH2AVF.js +7 -0
- package/dist/mail-DXOPfnog.js +12 -0
- package/dist/mobile-Dd0Gj4vZ.js +13 -0
- package/dist/more-DYcnClbB.js +15 -0
- package/dist/network-placeholder-CfRZGQfi.js +18 -0
- package/dist/nftPlaceholder-DHmFkY55.js +12 -0
- package/dist/off-CG2Y30qN.js +8 -0
- package/dist/onramp-DoAMTeNm.js +917 -0
- package/dist/play-store-B5EYBQto.js +36 -0
- package/dist/plus-DPo25_zL.js +17 -0
- package/dist/qr-code-BRTO19PL.js +10 -0
- package/dist/receive-BvclNdV_.js +179 -0
- package/dist/recycle-horizontal-ng_b2eJV.js +13 -0
- package/dist/refresh-3kiwRV0w.js +12 -0
- package/dist/reown-logo-_9cuIfJD.js +16 -0
- package/dist/search-CoJvIxpi.js +12 -0
- package/dist/secp256k1-wZyK2iIX.js +1257 -0
- package/dist/send-BVKGSR-Z.js +19 -0
- package/dist/send-Bkj5YtHe.js +1039 -0
- package/dist/socials-DL42HlL5.js +589 -0
- package/dist/solana-BjP-_Ioa.js +17 -0
- package/dist/swapHorizontal-Do3uBbum.js +12 -0
- package/dist/swapHorizontalBold-D7N75BE-.js +12 -0
- package/dist/swapHorizontalMedium-BahEVO2x.js +20 -0
- package/dist/swapHorizontalRoundedBold-D6Hoi132.js +12 -0
- package/dist/swapVertical-P-fnrADh.js +12 -0
- package/dist/swaps-DZgbVJZ2.js +1713 -0
- package/dist/telegram-DmaL2iB8.js +20 -0
- package/dist/three-dots-oXyAsUA6.js +9 -0
- package/dist/transactions-BjB5yZN7.js +35 -0
- package/dist/twitch-0UGrMr2K.js +22 -0
- package/dist/twitterIcon-B97KAbaJ.js +10 -0
- package/dist/ui-r6nnVhBA.js +812 -0
- package/dist/user-BG1yp56Q.js +7 -0
- package/dist/verify-CgzkMSuV.js +12 -0
- package/dist/verify-filled-D-TRpWtN.js +12 -0
- package/dist/w3m-modal-Drsibcs0.js +1041 -0
- package/dist/wallet-CAHsZdfj.js +12 -0
- package/dist/wallet-placeholder-agbbreqw.js +18 -0
- package/dist/walletconnect-Yd8iXqY9.js +36 -0
- package/dist/warning-circle-C0hqC6h_.js +16 -0
- package/dist/x-mark-D9_ai2sI.js +7 -0
- package/dist/x-z6v1Jegg.js +16 -0
- package/eslint.config.mjs +1 -1
- package/package.json +14 -13
- package/src/apis/lspApi.js +47 -24
- package/src/assets/ln.png +0 -0
- package/src/assets/network/Arbitrum.png +0 -0
- package/src/assets/network/Polygon.png +0 -0
- package/src/assets/network/Solana.png +0 -0
- package/src/assets/network/botanix.png +0 -0
- package/src/assets/network/bsc.svg +13 -0
- package/src/assets/pay.png +0 -0
- package/src/assets/tokens/usdc.png +0 -0
- package/src/assets/tokens/usdt.png +0 -0
- package/src/comps/AstraImage.jsx +17 -3
- package/src/comps/AstraModal.jsx +22 -16
- package/src/comps/AstraModalLogo.jsx +9 -9
- package/src/comps/AstraNetwork.jsx +174 -45
- package/src/comps/CheckErc20Button.jsx +1 -1
- package/src/comps/CommonStyle.jsx +4 -0
- package/src/comps/ConnectButton.jsx +16 -33
- package/src/comps/ResultModal.jsx +45 -39
- package/src/comps/ToLightning.jsx +207 -80
- package/src/comps/ToToken.jsx +278 -217
- package/src/constants/index.js +20 -4
- package/src/hooks/useContract.js +164 -125
- package/src/hooks/useGetMinAndMax.js +48 -0
- package/src/hooks/useLspApi.js +56 -39
- package/src/hooks/useParseInvoice.js +82 -72
- package/src/index.jsx +43 -10
- package/src/main.jsx +36 -5
- package/src/utils/index.js +136 -24
- package/vite.config.js +7 -1
- package/dist/astra-sdk.umd.js +0 -12578
- package/dist/hooks.module-BBZfodGH.js +0 -506
- package/dist/index-BKKAfRrw.js +0 -87520
- package/dist/index-C2MAIRET.js +0 -2929
- package/dist/index-CsRxokSv.js +0 -445
- package/dist/index-DQ6iiHxJ.js +0 -13720
- package/dist/index-SJhlkSif.js +0 -133
- package/dist/w3m-modal-CYJpmgnf.js +0 -267
- package/src/constants/contracts/abi/bridge.js +0 -1281
- package/src/constants/contracts/abi/index.js +0 -3
- package/src/constants/contracts/abi/usdt.js +0 -130
- package/src/constants/contracts/abi/watcher.js +0 -437
- package/src/constants/contracts/index.js +0 -37
package/dist/index-CsRxokSv.js
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
import { p as T, s as M, a as W, r as R, S as I, Q as U, J as k, i as $, b as _, O as N, A as g, x as v, c as b, E as f, C as l, W as h, d as y, e as D, M as P, R as j, f as O, N as w, g as K } from "./index-BKKAfRrw.js";
|
|
2
|
-
import { h as ne, V as se, Y as ie } from "./index-BKKAfRrw.js";
|
|
3
|
-
const c = T({
|
|
4
|
-
status: "uninitialized"
|
|
5
|
-
}), p = {
|
|
6
|
-
state: c,
|
|
7
|
-
subscribeKey(t, e) {
|
|
8
|
-
return M(c, t, e);
|
|
9
|
-
},
|
|
10
|
-
subscribe(t) {
|
|
11
|
-
return W(c, () => t(c));
|
|
12
|
-
},
|
|
13
|
-
_getClient() {
|
|
14
|
-
if (!c._client)
|
|
15
|
-
throw new Error("SIWEController client not set");
|
|
16
|
-
return c._client;
|
|
17
|
-
},
|
|
18
|
-
async getNonce(t) {
|
|
19
|
-
const s = await this._getClient().getNonce(t);
|
|
20
|
-
return this.setNonce(s), s;
|
|
21
|
-
},
|
|
22
|
-
async getSession() {
|
|
23
|
-
try {
|
|
24
|
-
const e = await this._getClient().getSession();
|
|
25
|
-
return e && (this.setSession(e), this.setStatus("success")), e || void 0;
|
|
26
|
-
} catch {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
createMessage(t) {
|
|
31
|
-
const s = this._getClient().createMessage(t);
|
|
32
|
-
return this.setMessage(s), s;
|
|
33
|
-
},
|
|
34
|
-
async verifyMessage(t) {
|
|
35
|
-
return await this._getClient().verifyMessage(t);
|
|
36
|
-
},
|
|
37
|
-
async signIn() {
|
|
38
|
-
return await this._getClient().signIn();
|
|
39
|
-
},
|
|
40
|
-
async signOut() {
|
|
41
|
-
var e;
|
|
42
|
-
const t = this._getClient();
|
|
43
|
-
await t.signOut(), this.setStatus("ready"), this.setSession(void 0), (e = t.onSignOut) == null || e.call(t);
|
|
44
|
-
},
|
|
45
|
-
onSignIn(t) {
|
|
46
|
-
var s;
|
|
47
|
-
const e = this._getClient();
|
|
48
|
-
(s = e.onSignIn) == null || s.call(e, t);
|
|
49
|
-
},
|
|
50
|
-
onSignOut() {
|
|
51
|
-
var e;
|
|
52
|
-
const t = this._getClient();
|
|
53
|
-
(e = t.onSignOut) == null || e.call(t);
|
|
54
|
-
},
|
|
55
|
-
async setSIWEClient(t) {
|
|
56
|
-
c._client = R(t), c.session = await this.getSession(), c.status = c.session ? "success" : "ready";
|
|
57
|
-
},
|
|
58
|
-
setNonce(t) {
|
|
59
|
-
c.nonce = t;
|
|
60
|
-
},
|
|
61
|
-
setStatus(t) {
|
|
62
|
-
c.status = t;
|
|
63
|
-
},
|
|
64
|
-
setMessage(t) {
|
|
65
|
-
c.message = t;
|
|
66
|
-
},
|
|
67
|
-
setSession(t) {
|
|
68
|
-
c.session = t, c.status = t ? "success" : "ready";
|
|
69
|
-
}
|
|
70
|
-
}, A = {
|
|
71
|
-
FIVE_MINUTES_IN_MS: 3e5
|
|
72
|
-
};
|
|
73
|
-
class V {
|
|
74
|
-
constructor(e) {
|
|
75
|
-
const { enabled: s = !0, nonceRefetchIntervalMs: n = A.FIVE_MINUTES_IN_MS, sessionRefetchIntervalMs: i = A.FIVE_MINUTES_IN_MS, signOutOnAccountChange: r = !0, signOutOnDisconnect: a = !0, signOutOnNetworkChange: o = !0, ...u } = e;
|
|
76
|
-
this.options = {
|
|
77
|
-
enabled: s,
|
|
78
|
-
nonceRefetchIntervalMs: n,
|
|
79
|
-
sessionRefetchIntervalMs: i,
|
|
80
|
-
signOutOnDisconnect: a,
|
|
81
|
-
signOutOnAccountChange: r,
|
|
82
|
-
signOutOnNetworkChange: o
|
|
83
|
-
}, this.methods = u;
|
|
84
|
-
}
|
|
85
|
-
async getNonce(e) {
|
|
86
|
-
const s = await this.methods.getNonce(e);
|
|
87
|
-
if (!s)
|
|
88
|
-
throw new Error("siweControllerClient:getNonce - nonce is undefined");
|
|
89
|
-
return s;
|
|
90
|
-
}
|
|
91
|
-
async getMessageParams() {
|
|
92
|
-
var e, s;
|
|
93
|
-
return await ((s = (e = this.methods).getMessageParams) == null ? void 0 : s.call(e)) || {};
|
|
94
|
-
}
|
|
95
|
-
createMessage(e) {
|
|
96
|
-
const s = this.methods.createMessage(e);
|
|
97
|
-
if (!s)
|
|
98
|
-
throw new Error("siweControllerClient:createMessage - message is undefined");
|
|
99
|
-
return s;
|
|
100
|
-
}
|
|
101
|
-
async verifyMessage(e) {
|
|
102
|
-
return await this.methods.verifyMessage(e);
|
|
103
|
-
}
|
|
104
|
-
async getSession() {
|
|
105
|
-
const e = await this.methods.getSession();
|
|
106
|
-
if (!e)
|
|
107
|
-
throw new Error("siweControllerClient:getSession - session is undefined");
|
|
108
|
-
return e;
|
|
109
|
-
}
|
|
110
|
-
async signIn() {
|
|
111
|
-
await I.requestSignMessage();
|
|
112
|
-
const e = await this.methods.getSession();
|
|
113
|
-
if (!e)
|
|
114
|
-
throw new Error("Error verifying SIWE signature");
|
|
115
|
-
return e;
|
|
116
|
-
}
|
|
117
|
-
async signOut() {
|
|
118
|
-
const e = I.getSIWX();
|
|
119
|
-
return e ? (await e.setSessions([]), !0) : !1;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const F = /0x[a-fA-F0-9]{40}/u, X = /Chain ID: (?<temp1>\d+)/u;
|
|
123
|
-
function Y(t) {
|
|
124
|
-
var e;
|
|
125
|
-
return ((e = t.match(F)) == null ? void 0 : e[0]) || "";
|
|
126
|
-
}
|
|
127
|
-
function q(t) {
|
|
128
|
-
var e;
|
|
129
|
-
return `eip155:${((e = t.match(X)) == null ? void 0 : e[1]) || 1}`;
|
|
130
|
-
}
|
|
131
|
-
async function G({ address: t, message: e, signature: s, chainId: n, projectId: i }) {
|
|
132
|
-
let r = U(t, e, s);
|
|
133
|
-
return r || (r = await k(t, e, s, n, i)), r;
|
|
134
|
-
}
|
|
135
|
-
const L = $`
|
|
136
|
-
:host {
|
|
137
|
-
display: flex;
|
|
138
|
-
justify-content: center;
|
|
139
|
-
gap: var(--wui-spacing-2xl);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
wui-visual-thumbnail:nth-child(1) {
|
|
143
|
-
z-index: 1;
|
|
144
|
-
}
|
|
145
|
-
`;
|
|
146
|
-
var H = function(t, e, s, n) {
|
|
147
|
-
var i = arguments.length, r = i < 3 ? e : n === null ? n = Object.getOwnPropertyDescriptor(e, s) : n, a;
|
|
148
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, s, n);
|
|
149
|
-
else for (var o = t.length - 1; o >= 0; o--) (a = t[o]) && (r = (i < 3 ? a(r) : i > 3 ? a(e, s, r) : a(e, s)) || r);
|
|
150
|
-
return i > 3 && r && Object.defineProperty(e, s, r), r;
|
|
151
|
-
};
|
|
152
|
-
let m = class extends _ {
|
|
153
|
-
constructor() {
|
|
154
|
-
var e, s;
|
|
155
|
-
super(...arguments), this.dappImageUrl = (e = N.state.metadata) == null ? void 0 : e.icons, this.walletImageUrl = (s = g.state.connectedWalletInfo) == null ? void 0 : s.icon;
|
|
156
|
-
}
|
|
157
|
-
firstUpdated() {
|
|
158
|
-
var s;
|
|
159
|
-
const e = (s = this.shadowRoot) == null ? void 0 : s.querySelectorAll("wui-visual-thumbnail");
|
|
160
|
-
e != null && e[0] && this.createAnimation(e[0], "translate(18px)"), e != null && e[1] && this.createAnimation(e[1], "translate(-18px)");
|
|
161
|
-
}
|
|
162
|
-
render() {
|
|
163
|
-
var e;
|
|
164
|
-
return v`
|
|
165
|
-
<wui-visual-thumbnail
|
|
166
|
-
?borderRadiusFull=${!0}
|
|
167
|
-
.imageSrc=${(e = this.dappImageUrl) == null ? void 0 : e[0]}
|
|
168
|
-
></wui-visual-thumbnail>
|
|
169
|
-
<wui-visual-thumbnail .imageSrc=${this.walletImageUrl}></wui-visual-thumbnail>
|
|
170
|
-
`;
|
|
171
|
-
}
|
|
172
|
-
createAnimation(e, s) {
|
|
173
|
-
e.animate([{ transform: "translateX(0px)" }, { transform: s }], {
|
|
174
|
-
duration: 1600,
|
|
175
|
-
easing: "cubic-bezier(0.56, 0, 0.48, 1)",
|
|
176
|
-
direction: "alternate",
|
|
177
|
-
iterations: 1 / 0
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
m.styles = L;
|
|
182
|
-
m = H([
|
|
183
|
-
b("w3m-connecting-siwe")
|
|
184
|
-
], m);
|
|
185
|
-
var C = function(t, e, s, n) {
|
|
186
|
-
var i = arguments.length, r = i < 3 ? e : n === null ? n = Object.getOwnPropertyDescriptor(e, s) : n, a;
|
|
187
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, s, n);
|
|
188
|
-
else for (var o = t.length - 1; o >= 0; o--) (a = t[o]) && (r = (i < 3 ? a(r) : i > 3 ? a(e, s, r) : a(e, s)) || r);
|
|
189
|
-
return i > 3 && r && Object.defineProperty(e, s, r), r;
|
|
190
|
-
};
|
|
191
|
-
let S = class extends _ {
|
|
192
|
-
constructor() {
|
|
193
|
-
var e;
|
|
194
|
-
super(...arguments), this.dappName = (e = N.state.metadata) == null ? void 0 : e.name, this.isSigning = !1, this.isCancelling = !1;
|
|
195
|
-
}
|
|
196
|
-
render() {
|
|
197
|
-
return v`
|
|
198
|
-
<wui-flex justifyContent="center" .padding=${["2xl", "0", "xxl", "0"]}>
|
|
199
|
-
<w3m-connecting-siwe></w3m-connecting-siwe>
|
|
200
|
-
</wui-flex>
|
|
201
|
-
<wui-flex
|
|
202
|
-
.padding=${["0", "4xl", "l", "4xl"]}
|
|
203
|
-
gap="s"
|
|
204
|
-
justifyContent="space-between"
|
|
205
|
-
>
|
|
206
|
-
<wui-text variant="paragraph-500" align="center" color="fg-100"
|
|
207
|
-
>${this.dappName ?? "Dapp"} needs to connect to your wallet</wui-text
|
|
208
|
-
>
|
|
209
|
-
</wui-flex>
|
|
210
|
-
<wui-flex
|
|
211
|
-
.padding=${["0", "3xl", "l", "3xl"]}
|
|
212
|
-
gap="s"
|
|
213
|
-
justifyContent="space-between"
|
|
214
|
-
>
|
|
215
|
-
<wui-text variant="small-400" align="center" color="fg-200"
|
|
216
|
-
>Sign this message to prove you own this wallet and proceed. Canceling will disconnect
|
|
217
|
-
you.</wui-text
|
|
218
|
-
>
|
|
219
|
-
</wui-flex>
|
|
220
|
-
<wui-flex .padding=${["l", "xl", "xl", "xl"]} gap="s" justifyContent="space-between">
|
|
221
|
-
<wui-button
|
|
222
|
-
size="lg"
|
|
223
|
-
borderRadius="xs"
|
|
224
|
-
fullWidth
|
|
225
|
-
variant="neutral"
|
|
226
|
-
?loading=${this.isCancelling}
|
|
227
|
-
@click=${this.onCancel.bind(this)}
|
|
228
|
-
data-testid="w3m-connecting-siwe-cancel"
|
|
229
|
-
>
|
|
230
|
-
Cancel
|
|
231
|
-
</wui-button>
|
|
232
|
-
<wui-button
|
|
233
|
-
size="lg"
|
|
234
|
-
borderRadius="xs"
|
|
235
|
-
fullWidth
|
|
236
|
-
variant="main"
|
|
237
|
-
@click=${this.onSign.bind(this)}
|
|
238
|
-
?loading=${this.isSigning}
|
|
239
|
-
data-testid="w3m-connecting-siwe-sign"
|
|
240
|
-
>
|
|
241
|
-
${this.isSigning ? "Signing..." : "Sign"}
|
|
242
|
-
</wui-button>
|
|
243
|
-
</wui-flex>
|
|
244
|
-
`;
|
|
245
|
-
}
|
|
246
|
-
async onSign() {
|
|
247
|
-
var e, s, n;
|
|
248
|
-
this.isSigning = !0, f.sendEvent({
|
|
249
|
-
event: "CLICK_SIGN_SIWX_MESSAGE",
|
|
250
|
-
type: "track",
|
|
251
|
-
properties: {
|
|
252
|
-
network: ((e = l.state.activeCaipNetwork) == null ? void 0 : e.caipNetworkId) || "",
|
|
253
|
-
isSmartAccount: g.state.preferredAccountType === h.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
try {
|
|
257
|
-
p.setStatus("loading");
|
|
258
|
-
const i = await p.signIn();
|
|
259
|
-
return p.setStatus("success"), f.sendEvent({
|
|
260
|
-
event: "SIWX_AUTH_SUCCESS",
|
|
261
|
-
type: "track",
|
|
262
|
-
properties: {
|
|
263
|
-
network: ((s = l.state.activeCaipNetwork) == null ? void 0 : s.caipNetworkId) || "",
|
|
264
|
-
isSmartAccount: g.state.preferredAccountType === h.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
265
|
-
}
|
|
266
|
-
}), i;
|
|
267
|
-
} catch {
|
|
268
|
-
const a = g.state.preferredAccountType === h.ACCOUNT_TYPES.SMART_ACCOUNT;
|
|
269
|
-
return a ? y.showError("This application might not support Smart Accounts") : y.showError("Signature declined"), p.setStatus("error"), f.sendEvent({
|
|
270
|
-
event: "SIWX_AUTH_ERROR",
|
|
271
|
-
type: "track",
|
|
272
|
-
properties: {
|
|
273
|
-
network: ((n = l.state.activeCaipNetwork) == null ? void 0 : n.caipNetworkId) || "",
|
|
274
|
-
isSmartAccount: a
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
} finally {
|
|
278
|
-
this.isSigning = !1;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
async onCancel() {
|
|
282
|
-
var s;
|
|
283
|
-
this.isCancelling = !0, l.state.activeCaipAddress ? (await D.disconnect(), P.close()) : j.push("Connect"), this.isCancelling = !1, f.sendEvent({
|
|
284
|
-
event: "CLICK_CANCEL_SIWX",
|
|
285
|
-
type: "track",
|
|
286
|
-
properties: {
|
|
287
|
-
network: ((s = l.state.activeCaipNetwork) == null ? void 0 : s.caipNetworkId) || "",
|
|
288
|
-
isSmartAccount: g.state.preferredAccountType === h.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
C([
|
|
294
|
-
O()
|
|
295
|
-
], S.prototype, "isSigning", void 0);
|
|
296
|
-
C([
|
|
297
|
-
O()
|
|
298
|
-
], S.prototype, "isCancelling", void 0);
|
|
299
|
-
S = C([
|
|
300
|
-
b("w3m-connecting-siwe-view")
|
|
301
|
-
], S);
|
|
302
|
-
const E = [];
|
|
303
|
-
function B(t) {
|
|
304
|
-
async function e() {
|
|
305
|
-
try {
|
|
306
|
-
const n = await t.methods.getSession();
|
|
307
|
-
if (!n)
|
|
308
|
-
return;
|
|
309
|
-
if (!(n != null && n.address))
|
|
310
|
-
throw new Error("SIWE session is missing address");
|
|
311
|
-
if (!(n != null && n.chainId))
|
|
312
|
-
throw new Error("SIWE session is missing chainId");
|
|
313
|
-
return n;
|
|
314
|
-
} catch (n) {
|
|
315
|
-
console.warn("AppKit:SIWE:getSession - error:", n);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
async function s() {
|
|
320
|
-
var n, i;
|
|
321
|
-
await t.methods.signOut(), (i = (n = t.methods).onSignOut) == null || i.call(n);
|
|
322
|
-
}
|
|
323
|
-
return E.forEach((n) => n()), E.push(l.subscribeKey("activeCaipNetwork", async (n) => {
|
|
324
|
-
if (!t.options.signOutOnNetworkChange)
|
|
325
|
-
return;
|
|
326
|
-
const i = await e();
|
|
327
|
-
i && i.chainId !== w.caipNetworkIdToNumber(n == null ? void 0 : n.caipNetworkId) && await s();
|
|
328
|
-
}), l.subscribeKey("activeCaipAddress", async (n) => {
|
|
329
|
-
var i, r, a;
|
|
330
|
-
if (t.options.signOutOnDisconnect && !n) {
|
|
331
|
-
await e() && await s();
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
if (t.options.signOutOnAccountChange) {
|
|
335
|
-
const o = await e(), u = (i = o == null ? void 0 : o.address) == null ? void 0 : i.toLowerCase(), d = (a = (r = K) == null ? void 0 : r.getPlainAddress(n)) == null ? void 0 : a.toLowerCase();
|
|
336
|
-
o && u !== d && await s();
|
|
337
|
-
}
|
|
338
|
-
})), {
|
|
339
|
-
async createMessage(n) {
|
|
340
|
-
var u, d;
|
|
341
|
-
const i = await ((d = (u = t.methods).getMessageParams) == null ? void 0 : d.call(u));
|
|
342
|
-
if (!i)
|
|
343
|
-
throw new Error("Failed to get message params!");
|
|
344
|
-
const r = await t.getNonce(n.accountAddress), a = i.iat || (/* @__PURE__ */ new Date()).toISOString(), o = "1";
|
|
345
|
-
return {
|
|
346
|
-
nonce: r,
|
|
347
|
-
version: o,
|
|
348
|
-
requestId: i.requestId,
|
|
349
|
-
accountAddress: n.accountAddress,
|
|
350
|
-
chainId: n.chainId,
|
|
351
|
-
domain: i.domain,
|
|
352
|
-
uri: i.uri,
|
|
353
|
-
notBefore: i.nbf,
|
|
354
|
-
resources: i.resources,
|
|
355
|
-
statement: i.statement,
|
|
356
|
-
expirationTime: i.exp,
|
|
357
|
-
issuedAt: a,
|
|
358
|
-
toString: () => t.createMessage({
|
|
359
|
-
...i,
|
|
360
|
-
chainId: w.caipNetworkIdToNumber(n.chainId) || 1,
|
|
361
|
-
address: `did:pkh:${n.chainId}:${n.accountAddress}`,
|
|
362
|
-
nonce: r,
|
|
363
|
-
version: o,
|
|
364
|
-
iat: a
|
|
365
|
-
})
|
|
366
|
-
};
|
|
367
|
-
},
|
|
368
|
-
async addSession(n) {
|
|
369
|
-
var r, a;
|
|
370
|
-
if (!w.parseEvmChainId(n.data.chainId))
|
|
371
|
-
return Promise.resolve();
|
|
372
|
-
if (await t.methods.verifyMessage(n))
|
|
373
|
-
return (a = (r = t.methods).onSignIn) == null || a.call(r, {
|
|
374
|
-
address: n.data.accountAddress,
|
|
375
|
-
chainId: w.parseEvmChainId(n.data.chainId)
|
|
376
|
-
}), Promise.resolve();
|
|
377
|
-
throw new Error("Failed to verify message");
|
|
378
|
-
},
|
|
379
|
-
async revokeSession(n, i) {
|
|
380
|
-
try {
|
|
381
|
-
await s();
|
|
382
|
-
} catch (r) {
|
|
383
|
-
console.warn("AppKit:SIWE:revokeSession - signOut error", r);
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
async setSessions(n) {
|
|
387
|
-
if (n.length === 0)
|
|
388
|
-
try {
|
|
389
|
-
await s();
|
|
390
|
-
} catch (i) {
|
|
391
|
-
console.warn("AppKit:SIWE:setSessions - signOut error", i);
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
const i = n.find((r) => {
|
|
395
|
-
var a;
|
|
396
|
-
return r.data.chainId === ((a = l.getActiveCaipNetwork()) == null ? void 0 : a.caipNetworkId);
|
|
397
|
-
}) || n[0];
|
|
398
|
-
await this.addSession(i);
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
async getSessions(n, i) {
|
|
402
|
-
var r;
|
|
403
|
-
try {
|
|
404
|
-
if (!n.startsWith("eip155:"))
|
|
405
|
-
return [
|
|
406
|
-
{
|
|
407
|
-
data: {
|
|
408
|
-
accountAddress: i,
|
|
409
|
-
chainId: n
|
|
410
|
-
},
|
|
411
|
-
message: "",
|
|
412
|
-
signature: ""
|
|
413
|
-
}
|
|
414
|
-
];
|
|
415
|
-
const a = await e(), o = `eip155:${a == null ? void 0 : a.chainId}`, u = (r = a == null ? void 0 : a.address) == null ? void 0 : r.toLowerCase(), d = i == null ? void 0 : i.toLowerCase();
|
|
416
|
-
return !a || u !== d || o !== n ? [] : [{
|
|
417
|
-
data: {
|
|
418
|
-
accountAddress: a.address,
|
|
419
|
-
chainId: o
|
|
420
|
-
},
|
|
421
|
-
message: "",
|
|
422
|
-
signature: ""
|
|
423
|
-
}];
|
|
424
|
-
} catch (a) {
|
|
425
|
-
return console.warn("AppKit:SIWE:getSessions - error:", a), [];
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
function Z(t) {
|
|
431
|
-
return new V(t);
|
|
432
|
-
}
|
|
433
|
-
export {
|
|
434
|
-
p as SIWEController,
|
|
435
|
-
m as W3mConnectingSiwe,
|
|
436
|
-
S as W3mConnectingSiweView,
|
|
437
|
-
Z as createSIWEConfig,
|
|
438
|
-
ne as formatMessage,
|
|
439
|
-
Y as getAddressFromMessage,
|
|
440
|
-
q as getChainIdFromMessage,
|
|
441
|
-
se as getDidAddress,
|
|
442
|
-
ie as getDidChainId,
|
|
443
|
-
B as mapToSIWX,
|
|
444
|
-
G as verifySignature
|
|
445
|
-
};
|