@reown/appkit-cdn 0.0.3
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/LICENSE +190 -0
- package/dist/W3MFrameProviderSingleton-BpWUndnw.cjs +11014 -0
- package/dist/W3MFrameProviderSingleton-CuVI_88U.js +65026 -0
- package/dist/ethers.cjs +1 -0
- package/dist/ethers.js +17800 -0
- package/dist/hooks.module-BmccViTi.cjs +1 -0
- package/dist/hooks.module-C2zxEs4Z.js +764 -0
- package/dist/index--u0BBJui.js +128 -0
- package/dist/index-B5dlb2GK.cjs +1 -0
- package/dist/index-BGcCLdgU.js +3175 -0
- package/dist/index-BgSdiVHK.cjs +64 -0
- package/dist/index-BzzLy8QO.js +2055 -0
- package/dist/index-CEbNT_sk.cjs +41 -0
- package/dist/index-Cbfs_-YJ.js +254 -0
- package/dist/index-CjczsdX0.js +9034 -0
- package/dist/index-CytFwM4F.cjs +1 -0
- package/dist/index-DIBheNE_.js +250 -0
- package/dist/index-DTZ3zFoi.js +931 -0
- package/dist/index-DoNvH4sY.cjs +1 -0
- package/dist/index-DxKsnlAL.cjs +7 -0
- package/dist/index-_fb0kPJf.js +161 -0
- package/dist/index-e2XnZub2.cjs +1 -0
- package/dist/index-qHZ88Aei.cjs +47 -0
- package/dist/index.es-Dzy36BN7.js +11685 -0
- package/dist/index.es-wptiKBWB.cjs +43 -0
- package/dist/metamask-sdk-CH4ak2WC.cjs +217 -0
- package/dist/metamask-sdk-vSsaK2qA.js +40484 -0
- package/dist/native-DUnMHCku.cjs +1 -0
- package/dist/native-DZv9b0EL.js +16 -0
- package/dist/w3m-modal-Cb8iN1Y9.js +290 -0
- package/dist/w3m-modal-pgEnMCmq.cjs +149 -0
- package/dist/wagmi-Cz2I9r-O.cjs +47 -0
- package/dist/wagmi-Dnkdlm7T.js +26712 -0
- package/dist/wagmi.cjs +1 -0
- package/dist/wagmi.js +9 -0
- package/package.json +38 -0
|
@@ -0,0 +1,3175 @@
|
|
|
1
|
+
import { B as f, s as rn, k as L, l as sn, b7 as an } from "./W3MFrameProviderSingleton-CuVI_88U.js";
|
|
2
|
+
import { j as on, r as _t, a as Et, b as cn } from "./hooks.module-C2zxEs4Z.js";
|
|
3
|
+
var St = {}, ne = {}, be = {};
|
|
4
|
+
Object.defineProperty(be, "__esModule", { value: !0 });
|
|
5
|
+
be.walletLogo = void 0;
|
|
6
|
+
const dn = (n, e) => {
|
|
7
|
+
let t;
|
|
8
|
+
switch (n) {
|
|
9
|
+
case "standard":
|
|
10
|
+
return t = e, `data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
|
|
11
|
+
case "circle":
|
|
12
|
+
return t = e, `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${t}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;
|
|
13
|
+
case "text":
|
|
14
|
+
return t = (0.1 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
|
|
15
|
+
case "textWithLogo":
|
|
16
|
+
return t = (0.25 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
|
|
17
|
+
case "textLight":
|
|
18
|
+
return t = (0.1 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
|
|
19
|
+
case "textWithLogoLight":
|
|
20
|
+
return t = (0.25 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
|
|
21
|
+
default:
|
|
22
|
+
return t = e, `data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
be.walletLogo = dn;
|
|
26
|
+
var ye = {}, O = {}, B = {};
|
|
27
|
+
Object.defineProperty(B, "__esModule", { value: !0 });
|
|
28
|
+
B.errorValues = B.standardErrorCodes = void 0;
|
|
29
|
+
B.standardErrorCodes = {
|
|
30
|
+
rpc: {
|
|
31
|
+
invalidInput: -32e3,
|
|
32
|
+
resourceNotFound: -32001,
|
|
33
|
+
resourceUnavailable: -32002,
|
|
34
|
+
transactionRejected: -32003,
|
|
35
|
+
methodNotSupported: -32004,
|
|
36
|
+
limitExceeded: -32005,
|
|
37
|
+
parse: -32700,
|
|
38
|
+
invalidRequest: -32600,
|
|
39
|
+
methodNotFound: -32601,
|
|
40
|
+
invalidParams: -32602,
|
|
41
|
+
internal: -32603
|
|
42
|
+
},
|
|
43
|
+
provider: {
|
|
44
|
+
userRejectedRequest: 4001,
|
|
45
|
+
unauthorized: 4100,
|
|
46
|
+
unsupportedMethod: 4200,
|
|
47
|
+
disconnected: 4900,
|
|
48
|
+
chainDisconnected: 4901,
|
|
49
|
+
unsupportedChain: 4902
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
B.errorValues = {
|
|
53
|
+
"-32700": {
|
|
54
|
+
standard: "JSON RPC 2.0",
|
|
55
|
+
message: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
|
56
|
+
},
|
|
57
|
+
"-32600": {
|
|
58
|
+
standard: "JSON RPC 2.0",
|
|
59
|
+
message: "The JSON sent is not a valid Request object."
|
|
60
|
+
},
|
|
61
|
+
"-32601": {
|
|
62
|
+
standard: "JSON RPC 2.0",
|
|
63
|
+
message: "The method does not exist / is not available."
|
|
64
|
+
},
|
|
65
|
+
"-32602": {
|
|
66
|
+
standard: "JSON RPC 2.0",
|
|
67
|
+
message: "Invalid method parameter(s)."
|
|
68
|
+
},
|
|
69
|
+
"-32603": {
|
|
70
|
+
standard: "JSON RPC 2.0",
|
|
71
|
+
message: "Internal JSON-RPC error."
|
|
72
|
+
},
|
|
73
|
+
"-32000": {
|
|
74
|
+
standard: "EIP-1474",
|
|
75
|
+
message: "Invalid input."
|
|
76
|
+
},
|
|
77
|
+
"-32001": {
|
|
78
|
+
standard: "EIP-1474",
|
|
79
|
+
message: "Resource not found."
|
|
80
|
+
},
|
|
81
|
+
"-32002": {
|
|
82
|
+
standard: "EIP-1474",
|
|
83
|
+
message: "Resource unavailable."
|
|
84
|
+
},
|
|
85
|
+
"-32003": {
|
|
86
|
+
standard: "EIP-1474",
|
|
87
|
+
message: "Transaction rejected."
|
|
88
|
+
},
|
|
89
|
+
"-32004": {
|
|
90
|
+
standard: "EIP-1474",
|
|
91
|
+
message: "Method not supported."
|
|
92
|
+
},
|
|
93
|
+
"-32005": {
|
|
94
|
+
standard: "EIP-1474",
|
|
95
|
+
message: "Request limit exceeded."
|
|
96
|
+
},
|
|
97
|
+
4001: {
|
|
98
|
+
standard: "EIP-1193",
|
|
99
|
+
message: "User rejected the request."
|
|
100
|
+
},
|
|
101
|
+
4100: {
|
|
102
|
+
standard: "EIP-1193",
|
|
103
|
+
message: "The requested account and/or method has not been authorized by the user."
|
|
104
|
+
},
|
|
105
|
+
4200: {
|
|
106
|
+
standard: "EIP-1193",
|
|
107
|
+
message: "The requested method is not supported by this Ethereum provider."
|
|
108
|
+
},
|
|
109
|
+
4900: {
|
|
110
|
+
standard: "EIP-1193",
|
|
111
|
+
message: "The provider is disconnected from all chains."
|
|
112
|
+
},
|
|
113
|
+
4901: {
|
|
114
|
+
standard: "EIP-1193",
|
|
115
|
+
message: "The provider is disconnected from the specified chain."
|
|
116
|
+
},
|
|
117
|
+
4902: {
|
|
118
|
+
standard: "EIP-3085",
|
|
119
|
+
message: "Unrecognized chain ID."
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var we = {}, Fe = {};
|
|
123
|
+
(function(n) {
|
|
124
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), n.serialize = n.getErrorCode = n.isValidCode = n.getMessageFromCode = n.JSON_RPC_SERVER_ERROR_MESSAGE = void 0;
|
|
125
|
+
const e = B, t = "Unspecified error message.";
|
|
126
|
+
n.JSON_RPC_SERVER_ERROR_MESSAGE = "Unspecified server error.";
|
|
127
|
+
function r(d, p = t) {
|
|
128
|
+
if (d && Number.isInteger(d)) {
|
|
129
|
+
const b = d.toString();
|
|
130
|
+
if (h(e.errorValues, b))
|
|
131
|
+
return e.errorValues[b].message;
|
|
132
|
+
if (c(d))
|
|
133
|
+
return n.JSON_RPC_SERVER_ERROR_MESSAGE;
|
|
134
|
+
}
|
|
135
|
+
return p;
|
|
136
|
+
}
|
|
137
|
+
n.getMessageFromCode = r;
|
|
138
|
+
function s(d) {
|
|
139
|
+
if (!Number.isInteger(d))
|
|
140
|
+
return !1;
|
|
141
|
+
const p = d.toString();
|
|
142
|
+
return !!(e.errorValues[p] || c(d));
|
|
143
|
+
}
|
|
144
|
+
n.isValidCode = s;
|
|
145
|
+
function i(d) {
|
|
146
|
+
var p;
|
|
147
|
+
if (typeof d == "number")
|
|
148
|
+
return d;
|
|
149
|
+
if (a(d))
|
|
150
|
+
return (p = d.code) !== null && p !== void 0 ? p : d.errorCode;
|
|
151
|
+
}
|
|
152
|
+
n.getErrorCode = i;
|
|
153
|
+
function a(d) {
|
|
154
|
+
return typeof d == "object" && d !== null && (typeof d.code == "number" || typeof d.errorCode == "number");
|
|
155
|
+
}
|
|
156
|
+
function o(d, { shouldIncludeStack: p = !1 } = {}) {
|
|
157
|
+
const b = {};
|
|
158
|
+
if (d && typeof d == "object" && !Array.isArray(d) && h(d, "code") && s(d.code)) {
|
|
159
|
+
const H = d;
|
|
160
|
+
b.code = H.code, H.message && typeof H.message == "string" ? (b.message = H.message, h(H, "data") && (b.data = H.data)) : (b.message = r(b.code), b.data = { originalError: l(d) });
|
|
161
|
+
} else
|
|
162
|
+
b.code = e.standardErrorCodes.rpc.internal, b.message = m(d, "message") ? d.message : t, b.data = { originalError: l(d) };
|
|
163
|
+
return p && (b.stack = m(d, "stack") ? d.stack : void 0), b;
|
|
164
|
+
}
|
|
165
|
+
n.serialize = o;
|
|
166
|
+
function c(d) {
|
|
167
|
+
return d >= -32099 && d <= -32e3;
|
|
168
|
+
}
|
|
169
|
+
function l(d) {
|
|
170
|
+
return d && typeof d == "object" && !Array.isArray(d) ? Object.assign({}, d) : d;
|
|
171
|
+
}
|
|
172
|
+
function h(d, p) {
|
|
173
|
+
return Object.prototype.hasOwnProperty.call(d, p);
|
|
174
|
+
}
|
|
175
|
+
function m(d, p) {
|
|
176
|
+
return typeof d == "object" && d !== null && p in d && typeof d[p] == "string";
|
|
177
|
+
}
|
|
178
|
+
})(Fe);
|
|
179
|
+
Object.defineProperty(we, "__esModule", { value: !0 });
|
|
180
|
+
we.standardErrors = void 0;
|
|
181
|
+
const _ = B, Ct = Fe;
|
|
182
|
+
we.standardErrors = {
|
|
183
|
+
rpc: {
|
|
184
|
+
parse: (n) => k(_.standardErrorCodes.rpc.parse, n),
|
|
185
|
+
invalidRequest: (n) => k(_.standardErrorCodes.rpc.invalidRequest, n),
|
|
186
|
+
invalidParams: (n) => k(_.standardErrorCodes.rpc.invalidParams, n),
|
|
187
|
+
methodNotFound: (n) => k(_.standardErrorCodes.rpc.methodNotFound, n),
|
|
188
|
+
internal: (n) => k(_.standardErrorCodes.rpc.internal, n),
|
|
189
|
+
server: (n) => {
|
|
190
|
+
if (!n || typeof n != "object" || Array.isArray(n))
|
|
191
|
+
throw new Error("Ethereum RPC Server errors must provide single object argument.");
|
|
192
|
+
const { code: e } = n;
|
|
193
|
+
if (!Number.isInteger(e) || e > -32005 || e < -32099)
|
|
194
|
+
throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');
|
|
195
|
+
return k(e, n);
|
|
196
|
+
},
|
|
197
|
+
invalidInput: (n) => k(_.standardErrorCodes.rpc.invalidInput, n),
|
|
198
|
+
resourceNotFound: (n) => k(_.standardErrorCodes.rpc.resourceNotFound, n),
|
|
199
|
+
resourceUnavailable: (n) => k(_.standardErrorCodes.rpc.resourceUnavailable, n),
|
|
200
|
+
transactionRejected: (n) => k(_.standardErrorCodes.rpc.transactionRejected, n),
|
|
201
|
+
methodNotSupported: (n) => k(_.standardErrorCodes.rpc.methodNotSupported, n),
|
|
202
|
+
limitExceeded: (n) => k(_.standardErrorCodes.rpc.limitExceeded, n)
|
|
203
|
+
},
|
|
204
|
+
provider: {
|
|
205
|
+
userRejectedRequest: (n) => F(_.standardErrorCodes.provider.userRejectedRequest, n),
|
|
206
|
+
unauthorized: (n) => F(_.standardErrorCodes.provider.unauthorized, n),
|
|
207
|
+
unsupportedMethod: (n) => F(_.standardErrorCodes.provider.unsupportedMethod, n),
|
|
208
|
+
disconnected: (n) => F(_.standardErrorCodes.provider.disconnected, n),
|
|
209
|
+
chainDisconnected: (n) => F(_.standardErrorCodes.provider.chainDisconnected, n),
|
|
210
|
+
unsupportedChain: (n) => F(_.standardErrorCodes.provider.unsupportedChain, n),
|
|
211
|
+
custom: (n) => {
|
|
212
|
+
if (!n || typeof n != "object" || Array.isArray(n))
|
|
213
|
+
throw new Error("Ethereum Provider custom errors must provide single object argument.");
|
|
214
|
+
const { code: e, message: t, data: r } = n;
|
|
215
|
+
if (!t || typeof t != "string")
|
|
216
|
+
throw new Error('"message" must be a nonempty string');
|
|
217
|
+
return new Mt(e, t, r);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
function k(n, e) {
|
|
222
|
+
const [t, r] = kt(e);
|
|
223
|
+
return new It(n, t || (0, Ct.getMessageFromCode)(n), r);
|
|
224
|
+
}
|
|
225
|
+
function F(n, e) {
|
|
226
|
+
const [t, r] = kt(e);
|
|
227
|
+
return new Mt(n, t || (0, Ct.getMessageFromCode)(n), r);
|
|
228
|
+
}
|
|
229
|
+
function kt(n) {
|
|
230
|
+
if (n) {
|
|
231
|
+
if (typeof n == "string")
|
|
232
|
+
return [n];
|
|
233
|
+
if (typeof n == "object" && !Array.isArray(n)) {
|
|
234
|
+
const { message: e, data: t } = n;
|
|
235
|
+
if (e && typeof e != "string")
|
|
236
|
+
throw new Error("Must specify string message.");
|
|
237
|
+
return [e || void 0, t];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
242
|
+
class It extends Error {
|
|
243
|
+
constructor(e, t, r) {
|
|
244
|
+
if (!Number.isInteger(e))
|
|
245
|
+
throw new Error('"code" must be an integer.');
|
|
246
|
+
if (!t || typeof t != "string")
|
|
247
|
+
throw new Error('"message" must be a nonempty string.');
|
|
248
|
+
super(t), this.code = e, r !== void 0 && (this.data = r);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
class Mt extends It {
|
|
252
|
+
/**
|
|
253
|
+
* Create an Ethereum Provider JSON-RPC error.
|
|
254
|
+
* `code` must be an integer in the 1000 <= 4999 range.
|
|
255
|
+
*/
|
|
256
|
+
constructor(e, t, r) {
|
|
257
|
+
if (!ln(e))
|
|
258
|
+
throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
|
|
259
|
+
super(e, t, r);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function ln(n) {
|
|
263
|
+
return Number.isInteger(n) && n >= 1e3 && n <= 4999;
|
|
264
|
+
}
|
|
265
|
+
(function(n) {
|
|
266
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), n.standardErrors = n.standardErrorCodes = void 0;
|
|
267
|
+
var e = B;
|
|
268
|
+
Object.defineProperty(n, "standardErrorCodes", { enumerable: !0, get: function() {
|
|
269
|
+
return e.standardErrorCodes;
|
|
270
|
+
} });
|
|
271
|
+
var t = we;
|
|
272
|
+
Object.defineProperty(n, "standardErrors", { enumerable: !0, get: function() {
|
|
273
|
+
return t.standardErrors;
|
|
274
|
+
} });
|
|
275
|
+
})(O);
|
|
276
|
+
var ve = {}, X = {};
|
|
277
|
+
Object.defineProperty(X, "__esModule", { value: !0 });
|
|
278
|
+
X.isErrorResponse = void 0;
|
|
279
|
+
function un(n) {
|
|
280
|
+
return n.errorMessage !== void 0;
|
|
281
|
+
}
|
|
282
|
+
X.isErrorResponse = un;
|
|
283
|
+
var q = {};
|
|
284
|
+
Object.defineProperty(q, "__esModule", { value: !0 });
|
|
285
|
+
q.LIB_VERSION = void 0;
|
|
286
|
+
q.LIB_VERSION = "4.0.4";
|
|
287
|
+
Object.defineProperty(ve, "__esModule", { value: !0 });
|
|
288
|
+
ve.serializeError = void 0;
|
|
289
|
+
const hn = X, gn = q, pn = B, fn = Fe;
|
|
290
|
+
function mn(n, e) {
|
|
291
|
+
const t = (0, fn.serialize)(bn(n), {
|
|
292
|
+
shouldIncludeStack: !0
|
|
293
|
+
}), r = new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");
|
|
294
|
+
r.searchParams.set("version", gn.LIB_VERSION), r.searchParams.set("code", t.code.toString());
|
|
295
|
+
const s = yn(t.data, e);
|
|
296
|
+
return s && r.searchParams.set("method", s), r.searchParams.set("message", t.message), Object.assign(Object.assign({}, t), { docUrl: r.href });
|
|
297
|
+
}
|
|
298
|
+
ve.serializeError = mn;
|
|
299
|
+
function bn(n) {
|
|
300
|
+
return typeof n == "string" ? {
|
|
301
|
+
message: n,
|
|
302
|
+
code: pn.standardErrorCodes.rpc.internal
|
|
303
|
+
} : (0, hn.isErrorResponse)(n) ? Object.assign(Object.assign({}, n), { message: n.errorMessage, code: n.errorCode, data: { method: n.method } }) : n;
|
|
304
|
+
}
|
|
305
|
+
function yn(n, e) {
|
|
306
|
+
const t = n == null ? void 0 : n.method;
|
|
307
|
+
if (t)
|
|
308
|
+
return t;
|
|
309
|
+
if (e !== void 0) {
|
|
310
|
+
if (typeof e == "string")
|
|
311
|
+
return e;
|
|
312
|
+
if (Array.isArray(e)) {
|
|
313
|
+
if (e.length > 0)
|
|
314
|
+
return e[0].method;
|
|
315
|
+
} else
|
|
316
|
+
return e.method;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
var E = {};
|
|
320
|
+
Object.defineProperty(E, "__esModule", { value: !0 });
|
|
321
|
+
E.RegExpString = E.IntNumber = E.BigIntString = E.AddressString = E.HexString = E.OpaqueType = void 0;
|
|
322
|
+
function re() {
|
|
323
|
+
return (n) => n;
|
|
324
|
+
}
|
|
325
|
+
E.OpaqueType = re;
|
|
326
|
+
E.HexString = re();
|
|
327
|
+
E.AddressString = re();
|
|
328
|
+
E.BigIntString = re();
|
|
329
|
+
function wn(n) {
|
|
330
|
+
return Math.floor(n);
|
|
331
|
+
}
|
|
332
|
+
E.IntNumber = wn;
|
|
333
|
+
E.RegExpString = re();
|
|
334
|
+
var u = {};
|
|
335
|
+
Object.defineProperty(u, "__esModule", { value: !0 });
|
|
336
|
+
u.areAddressArraysEqual = u.getFavicon = u.range = u.isBigNumber = u.ensureParsedJSONObject = u.ensureBigInt = u.ensureRegExpString = u.ensureIntNumber = u.ensureBuffer = u.ensureAddressString = u.ensureEvenLengthHexString = u.ensureHexString = u.isHexString = u.prepend0x = u.strip0x = u.has0xPrefix = u.hexStringFromIntNumber = u.intNumberFromHexString = u.bigIntStringFromBigInt = u.hexStringFromBuffer = u.hexStringToUint8Array = u.uint8ArrayToHex = u.randomBytesHex = void 0;
|
|
337
|
+
const $ = O, M = E, Lt = /^[0-9]*$/, At = /^[a-f0-9]*$/;
|
|
338
|
+
function vn(n) {
|
|
339
|
+
return Rt(crypto.getRandomValues(new Uint8Array(n)));
|
|
340
|
+
}
|
|
341
|
+
u.randomBytesHex = vn;
|
|
342
|
+
function Rt(n) {
|
|
343
|
+
return [...n].map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
344
|
+
}
|
|
345
|
+
u.uint8ArrayToHex = Rt;
|
|
346
|
+
function _n(n) {
|
|
347
|
+
return new Uint8Array(n.match(/.{1,2}/g).map((e) => parseInt(e, 16)));
|
|
348
|
+
}
|
|
349
|
+
u.hexStringToUint8Array = _n;
|
|
350
|
+
function En(n, e = !1) {
|
|
351
|
+
const t = n.toString("hex");
|
|
352
|
+
return (0, M.HexString)(e ? `0x${t}` : t);
|
|
353
|
+
}
|
|
354
|
+
u.hexStringFromBuffer = En;
|
|
355
|
+
function Sn(n) {
|
|
356
|
+
return (0, M.BigIntString)(n.toString(10));
|
|
357
|
+
}
|
|
358
|
+
u.bigIntStringFromBigInt = Sn;
|
|
359
|
+
function Cn(n) {
|
|
360
|
+
return (0, M.IntNumber)(Number(BigInt(ie(n, !0))));
|
|
361
|
+
}
|
|
362
|
+
u.intNumberFromHexString = Cn;
|
|
363
|
+
function kn(n) {
|
|
364
|
+
return (0, M.HexString)(`0x${BigInt(n).toString(16)}`);
|
|
365
|
+
}
|
|
366
|
+
u.hexStringFromIntNumber = kn;
|
|
367
|
+
function Ve(n) {
|
|
368
|
+
return n.startsWith("0x") || n.startsWith("0X");
|
|
369
|
+
}
|
|
370
|
+
u.has0xPrefix = Ve;
|
|
371
|
+
function _e(n) {
|
|
372
|
+
return Ve(n) ? n.slice(2) : n;
|
|
373
|
+
}
|
|
374
|
+
u.strip0x = _e;
|
|
375
|
+
function xt(n) {
|
|
376
|
+
return Ve(n) ? `0x${n.slice(2)}` : `0x${n}`;
|
|
377
|
+
}
|
|
378
|
+
u.prepend0x = xt;
|
|
379
|
+
function se(n) {
|
|
380
|
+
if (typeof n != "string")
|
|
381
|
+
return !1;
|
|
382
|
+
const e = _e(n).toLowerCase();
|
|
383
|
+
return At.test(e);
|
|
384
|
+
}
|
|
385
|
+
u.isHexString = se;
|
|
386
|
+
function Pt(n, e = !1) {
|
|
387
|
+
if (typeof n == "string") {
|
|
388
|
+
const t = _e(n).toLowerCase();
|
|
389
|
+
if (At.test(t))
|
|
390
|
+
return (0, M.HexString)(e ? `0x${t}` : t);
|
|
391
|
+
}
|
|
392
|
+
throw $.standardErrors.rpc.invalidParams(`"${String(n)}" is not a hexadecimal string`);
|
|
393
|
+
}
|
|
394
|
+
u.ensureHexString = Pt;
|
|
395
|
+
function ie(n, e = !1) {
|
|
396
|
+
let t = Pt(n, !1);
|
|
397
|
+
return t.length % 2 === 1 && (t = (0, M.HexString)(`0${t}`)), e ? (0, M.HexString)(`0x${t}`) : t;
|
|
398
|
+
}
|
|
399
|
+
u.ensureEvenLengthHexString = ie;
|
|
400
|
+
function In(n) {
|
|
401
|
+
if (typeof n == "string") {
|
|
402
|
+
const e = _e(n).toLowerCase();
|
|
403
|
+
if (se(e) && e.length === 40)
|
|
404
|
+
return (0, M.AddressString)(xt(e));
|
|
405
|
+
}
|
|
406
|
+
throw $.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(n)}`);
|
|
407
|
+
}
|
|
408
|
+
u.ensureAddressString = In;
|
|
409
|
+
function Mn(n) {
|
|
410
|
+
if (f.isBuffer(n))
|
|
411
|
+
return n;
|
|
412
|
+
if (typeof n == "string") {
|
|
413
|
+
if (se(n)) {
|
|
414
|
+
const e = ie(n, !1);
|
|
415
|
+
return f.from(e, "hex");
|
|
416
|
+
}
|
|
417
|
+
return f.from(n, "utf8");
|
|
418
|
+
}
|
|
419
|
+
throw $.standardErrors.rpc.invalidParams(`Not binary data: ${String(n)}`);
|
|
420
|
+
}
|
|
421
|
+
u.ensureBuffer = Mn;
|
|
422
|
+
function Nt(n) {
|
|
423
|
+
if (typeof n == "number" && Number.isInteger(n))
|
|
424
|
+
return (0, M.IntNumber)(n);
|
|
425
|
+
if (typeof n == "string") {
|
|
426
|
+
if (Lt.test(n))
|
|
427
|
+
return (0, M.IntNumber)(Number(n));
|
|
428
|
+
if (se(n))
|
|
429
|
+
return (0, M.IntNumber)(Number(BigInt(ie(n, !0))));
|
|
430
|
+
}
|
|
431
|
+
throw $.standardErrors.rpc.invalidParams(`Not an integer: ${String(n)}`);
|
|
432
|
+
}
|
|
433
|
+
u.ensureIntNumber = Nt;
|
|
434
|
+
function Ln(n) {
|
|
435
|
+
if (n instanceof RegExp)
|
|
436
|
+
return (0, M.RegExpString)(n.toString());
|
|
437
|
+
throw $.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(n)}`);
|
|
438
|
+
}
|
|
439
|
+
u.ensureRegExpString = Ln;
|
|
440
|
+
function An(n) {
|
|
441
|
+
if (n !== null && (typeof n == "bigint" || Tt(n)))
|
|
442
|
+
return BigInt(n.toString(10));
|
|
443
|
+
if (typeof n == "number")
|
|
444
|
+
return BigInt(Nt(n));
|
|
445
|
+
if (typeof n == "string") {
|
|
446
|
+
if (Lt.test(n))
|
|
447
|
+
return BigInt(n);
|
|
448
|
+
if (se(n))
|
|
449
|
+
return BigInt(ie(n, !0));
|
|
450
|
+
}
|
|
451
|
+
throw $.standardErrors.rpc.invalidParams(`Not an integer: ${String(n)}`);
|
|
452
|
+
}
|
|
453
|
+
u.ensureBigInt = An;
|
|
454
|
+
function Rn(n) {
|
|
455
|
+
if (typeof n == "string")
|
|
456
|
+
return JSON.parse(n);
|
|
457
|
+
if (typeof n == "object")
|
|
458
|
+
return n;
|
|
459
|
+
throw $.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(n)}`);
|
|
460
|
+
}
|
|
461
|
+
u.ensureParsedJSONObject = Rn;
|
|
462
|
+
function Tt(n) {
|
|
463
|
+
if (n == null || typeof n.constructor != "function")
|
|
464
|
+
return !1;
|
|
465
|
+
const { constructor: e } = n;
|
|
466
|
+
return typeof e.config == "function" && typeof e.EUCLID == "number";
|
|
467
|
+
}
|
|
468
|
+
u.isBigNumber = Tt;
|
|
469
|
+
function xn(n, e) {
|
|
470
|
+
return Array.from({ length: e - n }, (t, r) => n + r);
|
|
471
|
+
}
|
|
472
|
+
u.range = xn;
|
|
473
|
+
function Pn() {
|
|
474
|
+
const n = document.querySelector('link[sizes="192x192"]') || document.querySelector('link[sizes="180x180"]') || document.querySelector('link[rel="icon"]') || document.querySelector('link[rel="shortcut icon"]'), { protocol: e, host: t } = document.location, r = n ? n.getAttribute("href") : null;
|
|
475
|
+
return !r || r.startsWith("javascript:") || r.startsWith("vbscript:") ? null : r.startsWith("http://") || r.startsWith("https://") || r.startsWith("data:") ? r : r.startsWith("//") ? e + r : `${e}//${t}${r}`;
|
|
476
|
+
}
|
|
477
|
+
u.getFavicon = Pn;
|
|
478
|
+
function Nn(n, e) {
|
|
479
|
+
return n.length === e.length && n.every((t, r) => t === e[r]);
|
|
480
|
+
}
|
|
481
|
+
u.areAddressArraysEqual = Nn;
|
|
482
|
+
var N = {}, Ee = {}, Se = {}, w = {};
|
|
483
|
+
Object.defineProperty(w, "__esModule", { value: !0 });
|
|
484
|
+
w.decryptContent = w.encryptContent = w.importKeyFromHexString = w.exportKeyToHexString = w.decrypt = w.encrypt = w.deriveSharedSecret = w.generateKeyPair = void 0;
|
|
485
|
+
const jt = u;
|
|
486
|
+
async function Tn() {
|
|
487
|
+
return crypto.subtle.generateKey({
|
|
488
|
+
name: "ECDH",
|
|
489
|
+
namedCurve: "P-256"
|
|
490
|
+
}, !0, ["deriveKey"]);
|
|
491
|
+
}
|
|
492
|
+
w.generateKeyPair = Tn;
|
|
493
|
+
async function jn(n, e) {
|
|
494
|
+
return crypto.subtle.deriveKey({
|
|
495
|
+
name: "ECDH",
|
|
496
|
+
public: e
|
|
497
|
+
}, n, {
|
|
498
|
+
name: "AES-GCM",
|
|
499
|
+
length: 256
|
|
500
|
+
}, !1, ["encrypt", "decrypt"]);
|
|
501
|
+
}
|
|
502
|
+
w.deriveSharedSecret = jn;
|
|
503
|
+
async function Ot(n, e) {
|
|
504
|
+
const t = crypto.getRandomValues(new Uint8Array(12)), r = await crypto.subtle.encrypt({
|
|
505
|
+
name: "AES-GCM",
|
|
506
|
+
iv: t
|
|
507
|
+
}, n, new TextEncoder().encode(e));
|
|
508
|
+
return { iv: t, cipherText: r };
|
|
509
|
+
}
|
|
510
|
+
w.encrypt = Ot;
|
|
511
|
+
async function Dt(n, { iv: e, cipherText: t }) {
|
|
512
|
+
const r = await crypto.subtle.decrypt({
|
|
513
|
+
name: "AES-GCM",
|
|
514
|
+
iv: e
|
|
515
|
+
}, n, t);
|
|
516
|
+
return new TextDecoder().decode(r);
|
|
517
|
+
}
|
|
518
|
+
w.decrypt = Dt;
|
|
519
|
+
function Wt(n) {
|
|
520
|
+
switch (n) {
|
|
521
|
+
case "public":
|
|
522
|
+
return "spki";
|
|
523
|
+
case "private":
|
|
524
|
+
return "pkcs8";
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
async function On(n, e) {
|
|
528
|
+
const t = Wt(n), r = await crypto.subtle.exportKey(t, e);
|
|
529
|
+
return (0, jt.uint8ArrayToHex)(new Uint8Array(r));
|
|
530
|
+
}
|
|
531
|
+
w.exportKeyToHexString = On;
|
|
532
|
+
async function Dn(n, e) {
|
|
533
|
+
const t = Wt(n), r = (0, jt.hexStringToUint8Array)(e).buffer;
|
|
534
|
+
return await crypto.subtle.importKey(t, r, {
|
|
535
|
+
name: "ECDH",
|
|
536
|
+
namedCurve: "P-256"
|
|
537
|
+
}, !0, n === "private" ? ["deriveKey"] : []);
|
|
538
|
+
}
|
|
539
|
+
w.importKeyFromHexString = Dn;
|
|
540
|
+
async function Wn(n, e) {
|
|
541
|
+
const t = JSON.stringify(n, (r, s) => {
|
|
542
|
+
if (!(s instanceof Error))
|
|
543
|
+
return s;
|
|
544
|
+
const i = s;
|
|
545
|
+
return Object.assign(Object.assign({}, i.code ? { code: i.code } : {}), { message: i.message });
|
|
546
|
+
});
|
|
547
|
+
return Ot(e, t);
|
|
548
|
+
}
|
|
549
|
+
w.encryptContent = Wn;
|
|
550
|
+
async function Un(n, e) {
|
|
551
|
+
return JSON.parse(await Dt(e, n));
|
|
552
|
+
}
|
|
553
|
+
w.decryptContent = Un;
|
|
554
|
+
var D = {};
|
|
555
|
+
Object.defineProperty(D, "__esModule", { value: !0 });
|
|
556
|
+
D.ScopedLocalStorage = void 0;
|
|
557
|
+
class me {
|
|
558
|
+
constructor(e, t) {
|
|
559
|
+
this.scope = e, this.module = t;
|
|
560
|
+
}
|
|
561
|
+
setItem(e, t) {
|
|
562
|
+
localStorage.setItem(this.scopedKey(e), t);
|
|
563
|
+
}
|
|
564
|
+
getItem(e) {
|
|
565
|
+
return localStorage.getItem(this.scopedKey(e));
|
|
566
|
+
}
|
|
567
|
+
removeItem(e) {
|
|
568
|
+
localStorage.removeItem(this.scopedKey(e));
|
|
569
|
+
}
|
|
570
|
+
clear() {
|
|
571
|
+
const e = this.scopedKey(""), t = [];
|
|
572
|
+
for (let r = 0; r < localStorage.length; r++) {
|
|
573
|
+
const s = localStorage.key(r);
|
|
574
|
+
typeof s == "string" && s.startsWith(e) && t.push(s);
|
|
575
|
+
}
|
|
576
|
+
t.forEach((r) => localStorage.removeItem(r));
|
|
577
|
+
}
|
|
578
|
+
scopedKey(e) {
|
|
579
|
+
return `-${this.scope}${this.module ? `:${this.module}` : ""}:${e}`;
|
|
580
|
+
}
|
|
581
|
+
static clearAll() {
|
|
582
|
+
new me("CBWSDK").clear(), new me("walletlink").clear();
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
D.ScopedLocalStorage = me;
|
|
586
|
+
Object.defineProperty(Se, "__esModule", { value: !0 });
|
|
587
|
+
Se.SCWKeyManager = void 0;
|
|
588
|
+
const ce = w, Bn = D, We = {
|
|
589
|
+
storageKey: "ownPrivateKey",
|
|
590
|
+
keyType: "private"
|
|
591
|
+
}, Ue = {
|
|
592
|
+
storageKey: "ownPublicKey",
|
|
593
|
+
keyType: "public"
|
|
594
|
+
}, Be = {
|
|
595
|
+
storageKey: "peerPublicKey",
|
|
596
|
+
keyType: "public"
|
|
597
|
+
};
|
|
598
|
+
class Hn {
|
|
599
|
+
constructor() {
|
|
600
|
+
this.storage = new Bn.ScopedLocalStorage("CBWSDK", "SCWKeyManager"), this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null;
|
|
601
|
+
}
|
|
602
|
+
async getOwnPublicKey() {
|
|
603
|
+
return await this.loadKeysIfNeeded(), this.ownPublicKey;
|
|
604
|
+
}
|
|
605
|
+
// returns null if the shared secret is not yet derived
|
|
606
|
+
async getSharedSecret() {
|
|
607
|
+
return await this.loadKeysIfNeeded(), this.sharedSecret;
|
|
608
|
+
}
|
|
609
|
+
async setPeerPublicKey(e) {
|
|
610
|
+
this.sharedSecret = null, this.peerPublicKey = e, await this.storeKey(Be, e), await this.loadKeysIfNeeded();
|
|
611
|
+
}
|
|
612
|
+
async clear() {
|
|
613
|
+
this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null, this.storage.removeItem(Ue.storageKey), this.storage.removeItem(We.storageKey), this.storage.removeItem(Be.storageKey);
|
|
614
|
+
}
|
|
615
|
+
async generateKeyPair() {
|
|
616
|
+
const e = await (0, ce.generateKeyPair)();
|
|
617
|
+
this.ownPrivateKey = e.privateKey, this.ownPublicKey = e.publicKey, await this.storeKey(We, e.privateKey), await this.storeKey(Ue, e.publicKey);
|
|
618
|
+
}
|
|
619
|
+
async loadKeysIfNeeded() {
|
|
620
|
+
if (this.ownPrivateKey === null && (this.ownPrivateKey = await this.loadKey(We)), this.ownPublicKey === null && (this.ownPublicKey = await this.loadKey(Ue)), (this.ownPrivateKey === null || this.ownPublicKey === null) && await this.generateKeyPair(), this.peerPublicKey === null && (this.peerPublicKey = await this.loadKey(Be)), this.sharedSecret === null) {
|
|
621
|
+
if (this.ownPrivateKey === null || this.peerPublicKey === null)
|
|
622
|
+
return;
|
|
623
|
+
this.sharedSecret = await (0, ce.deriveSharedSecret)(this.ownPrivateKey, this.peerPublicKey);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
// storage methods
|
|
627
|
+
async loadKey(e) {
|
|
628
|
+
const t = this.storage.getItem(e.storageKey);
|
|
629
|
+
return t ? (0, ce.importKeyFromHexString)(e.keyType, t) : null;
|
|
630
|
+
}
|
|
631
|
+
async storeKey(e, t) {
|
|
632
|
+
const r = await (0, ce.exportKeyToHexString)(e.keyType, t);
|
|
633
|
+
this.storage.setItem(e.storageKey, r);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
Se.SCWKeyManager = Hn;
|
|
637
|
+
var Ce = {};
|
|
638
|
+
Object.defineProperty(Ce, "__esModule", { value: !0 });
|
|
639
|
+
Ce.SCWStateManager = void 0;
|
|
640
|
+
const Kn = D, Xe = "accounts", et = "activeChain", tt = "availableChains", nt = "walletCapabilities";
|
|
641
|
+
class qn {
|
|
642
|
+
get accounts() {
|
|
643
|
+
return this._accounts;
|
|
644
|
+
}
|
|
645
|
+
get activeChain() {
|
|
646
|
+
return this._activeChain;
|
|
647
|
+
}
|
|
648
|
+
get walletCapabilities() {
|
|
649
|
+
return this._walletCapabilities;
|
|
650
|
+
}
|
|
651
|
+
constructor(e) {
|
|
652
|
+
var t, r;
|
|
653
|
+
this.storage = new Kn.ScopedLocalStorage("CBWSDK", "SCWStateManager"), this.updateListener = e.updateListener, this.availableChains = this.loadItemFromStorage(tt), this._walletCapabilities = this.loadItemFromStorage(nt);
|
|
654
|
+
const s = this.loadItemFromStorage(Xe), i = this.loadItemFromStorage(et);
|
|
655
|
+
s && this.updateListener.onAccountsUpdate({
|
|
656
|
+
accounts: s,
|
|
657
|
+
source: "storage"
|
|
658
|
+
}), i && this.updateListener.onChainUpdate({
|
|
659
|
+
chain: i,
|
|
660
|
+
source: "storage"
|
|
661
|
+
}), this._accounts = s || [], this._activeChain = i || { id: (r = (t = e.appChainIds) === null || t === void 0 ? void 0 : t[0]) !== null && r !== void 0 ? r : 1 };
|
|
662
|
+
}
|
|
663
|
+
updateAccounts(e) {
|
|
664
|
+
this._accounts = e, this.storeItemToStorage(Xe, e), this.updateListener.onAccountsUpdate({
|
|
665
|
+
accounts: e,
|
|
666
|
+
source: "wallet"
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
switchChain(e) {
|
|
670
|
+
var t;
|
|
671
|
+
const r = (t = this.availableChains) === null || t === void 0 ? void 0 : t.find((s) => s.id === e);
|
|
672
|
+
return r ? (r === this._activeChain || (this._activeChain = r, this.storeItemToStorage(et, r), this.updateListener.onChainUpdate({
|
|
673
|
+
chain: r,
|
|
674
|
+
source: "wallet"
|
|
675
|
+
})), !0) : !1;
|
|
676
|
+
}
|
|
677
|
+
updateAvailableChains(e) {
|
|
678
|
+
if (!e || Object.keys(e).length === 0)
|
|
679
|
+
return;
|
|
680
|
+
const t = Object.entries(e).map(([r, s]) => ({ id: Number(r), rpcUrl: s }));
|
|
681
|
+
this.availableChains = t, this.storeItemToStorage(tt, t), this.switchChain(this._activeChain.id);
|
|
682
|
+
}
|
|
683
|
+
updateWalletCapabilities(e) {
|
|
684
|
+
this._walletCapabilities = e, this.storeItemToStorage(nt, e);
|
|
685
|
+
}
|
|
686
|
+
storeItemToStorage(e, t) {
|
|
687
|
+
this.storage.setItem(e, JSON.stringify(t));
|
|
688
|
+
}
|
|
689
|
+
loadItemFromStorage(e) {
|
|
690
|
+
const t = this.storage.getItem(e);
|
|
691
|
+
return t ? JSON.parse(t) : void 0;
|
|
692
|
+
}
|
|
693
|
+
clear() {
|
|
694
|
+
this.storage.clear();
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
Ce.SCWStateManager = qn;
|
|
698
|
+
Object.defineProperty(Ee, "__esModule", { value: !0 });
|
|
699
|
+
Ee.SCWSigner = void 0;
|
|
700
|
+
const $n = Se, Fn = Ce, de = O, rt = u, le = w;
|
|
701
|
+
class Vn {
|
|
702
|
+
constructor(e) {
|
|
703
|
+
this.metadata = e.metadata, this.communicator = e.communicator, this.keyManager = new $n.SCWKeyManager(), this.stateManager = new Fn.SCWStateManager({
|
|
704
|
+
appChainIds: this.metadata.appChainIds,
|
|
705
|
+
updateListener: e.updateListener
|
|
706
|
+
}), this.handshake = this.handshake.bind(this), this.request = this.request.bind(this), this.createRequestMessage = this.createRequestMessage.bind(this), this.decryptResponseMessage = this.decryptResponseMessage.bind(this);
|
|
707
|
+
}
|
|
708
|
+
async handshake() {
|
|
709
|
+
const e = await this.createRequestMessage({
|
|
710
|
+
handshake: {
|
|
711
|
+
method: "eth_requestAccounts",
|
|
712
|
+
params: this.metadata
|
|
713
|
+
}
|
|
714
|
+
}), t = await this.communicator.postRequestAndWaitForResponse(e);
|
|
715
|
+
if ("failure" in t.content)
|
|
716
|
+
throw t.content.failure;
|
|
717
|
+
const r = await (0, le.importKeyFromHexString)("public", t.sender);
|
|
718
|
+
await this.keyManager.setPeerPublicKey(r);
|
|
719
|
+
const s = await this.decryptResponseMessage(t);
|
|
720
|
+
this.updateInternalState({ method: "eth_requestAccounts" }, s);
|
|
721
|
+
const i = s.result;
|
|
722
|
+
if ("error" in i)
|
|
723
|
+
throw i.error;
|
|
724
|
+
return this.stateManager.accounts;
|
|
725
|
+
}
|
|
726
|
+
async request(e) {
|
|
727
|
+
const t = this.tryLocalHandling(e);
|
|
728
|
+
if (t !== void 0) {
|
|
729
|
+
if (t instanceof Error)
|
|
730
|
+
throw t;
|
|
731
|
+
return t;
|
|
732
|
+
}
|
|
733
|
+
await this.communicator.waitForPopupLoaded();
|
|
734
|
+
const r = await this.sendEncryptedRequest(e), s = await this.decryptResponseMessage(r);
|
|
735
|
+
this.updateInternalState(e, s);
|
|
736
|
+
const i = s.result;
|
|
737
|
+
if ("error" in i)
|
|
738
|
+
throw i.error;
|
|
739
|
+
return i.value;
|
|
740
|
+
}
|
|
741
|
+
async disconnect() {
|
|
742
|
+
this.stateManager.clear(), await this.keyManager.clear();
|
|
743
|
+
}
|
|
744
|
+
tryLocalHandling(e) {
|
|
745
|
+
var t;
|
|
746
|
+
switch (e.method) {
|
|
747
|
+
case "wallet_switchEthereumChain": {
|
|
748
|
+
const r = e.params;
|
|
749
|
+
if (!r || !(!((t = r[0]) === null || t === void 0) && t.chainId))
|
|
750
|
+
throw de.standardErrors.rpc.invalidParams();
|
|
751
|
+
const s = (0, rt.ensureIntNumber)(r[0].chainId);
|
|
752
|
+
return this.stateManager.switchChain(s) ? null : void 0;
|
|
753
|
+
}
|
|
754
|
+
case "wallet_getCapabilities": {
|
|
755
|
+
const r = this.stateManager.walletCapabilities;
|
|
756
|
+
if (!r)
|
|
757
|
+
throw de.standardErrors.provider.unauthorized("No wallet capabilities found, please disconnect and reconnect");
|
|
758
|
+
return r;
|
|
759
|
+
}
|
|
760
|
+
default:
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
async sendEncryptedRequest(e) {
|
|
765
|
+
const t = await this.keyManager.getSharedSecret();
|
|
766
|
+
if (!t)
|
|
767
|
+
throw de.standardErrors.provider.unauthorized("No valid session found, try requestAccounts before other methods");
|
|
768
|
+
const r = await (0, le.encryptContent)({
|
|
769
|
+
action: e,
|
|
770
|
+
chainId: this.stateManager.activeChain.id
|
|
771
|
+
}, t), s = await this.createRequestMessage({ encrypted: r });
|
|
772
|
+
return this.communicator.postRequestAndWaitForResponse(s);
|
|
773
|
+
}
|
|
774
|
+
async createRequestMessage(e) {
|
|
775
|
+
const t = await (0, le.exportKeyToHexString)("public", await this.keyManager.getOwnPublicKey());
|
|
776
|
+
return {
|
|
777
|
+
id: crypto.randomUUID(),
|
|
778
|
+
sender: t,
|
|
779
|
+
content: e,
|
|
780
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
async decryptResponseMessage(e) {
|
|
784
|
+
const t = e.content;
|
|
785
|
+
if ("failure" in t)
|
|
786
|
+
throw t.failure;
|
|
787
|
+
const r = await this.keyManager.getSharedSecret();
|
|
788
|
+
if (!r)
|
|
789
|
+
throw de.standardErrors.provider.unauthorized("Invalid session");
|
|
790
|
+
return (0, le.decryptContent)(t.encrypted, r);
|
|
791
|
+
}
|
|
792
|
+
updateInternalState(e, t) {
|
|
793
|
+
var r, s;
|
|
794
|
+
const i = (r = t.data) === null || r === void 0 ? void 0 : r.chains;
|
|
795
|
+
i && this.stateManager.updateAvailableChains(i);
|
|
796
|
+
const a = (s = t.data) === null || s === void 0 ? void 0 : s.capabilities;
|
|
797
|
+
a && this.stateManager.updateWalletCapabilities(a);
|
|
798
|
+
const o = t.result;
|
|
799
|
+
if (!("error" in o))
|
|
800
|
+
switch (e.method) {
|
|
801
|
+
case "eth_requestAccounts": {
|
|
802
|
+
const c = o.value;
|
|
803
|
+
this.stateManager.updateAccounts(c);
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
case "wallet_switchEthereumChain": {
|
|
807
|
+
if (o.value !== null)
|
|
808
|
+
return;
|
|
809
|
+
const c = e.params, l = (0, rt.ensureIntNumber)(c[0].chainId);
|
|
810
|
+
this.stateManager.switchChain(l);
|
|
811
|
+
break;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
Ee.SCWSigner = Vn;
|
|
817
|
+
var ke = {};
|
|
818
|
+
const zn = on;
|
|
819
|
+
function Ut(n) {
|
|
820
|
+
return f.allocUnsafe(n).fill(0);
|
|
821
|
+
}
|
|
822
|
+
function Zn(n) {
|
|
823
|
+
return n.toString(2).length;
|
|
824
|
+
}
|
|
825
|
+
function Bt(n, e) {
|
|
826
|
+
let t = n.toString(16);
|
|
827
|
+
t.length % 2 !== 0 && (t = "0" + t);
|
|
828
|
+
const r = t.match(/.{1,2}/g).map((s) => parseInt(s, 16));
|
|
829
|
+
for (; r.length < e; )
|
|
830
|
+
r.unshift(0);
|
|
831
|
+
return f.from(r);
|
|
832
|
+
}
|
|
833
|
+
function Gn(n, e) {
|
|
834
|
+
const t = n < 0n;
|
|
835
|
+
let r;
|
|
836
|
+
if (t) {
|
|
837
|
+
const s = (1n << BigInt(e)) - 1n;
|
|
838
|
+
r = (~n & s) + 1n;
|
|
839
|
+
} else
|
|
840
|
+
r = n;
|
|
841
|
+
return r &= (1n << BigInt(e)) - 1n, r;
|
|
842
|
+
}
|
|
843
|
+
function Ht(n, e, t) {
|
|
844
|
+
const r = Ut(e);
|
|
845
|
+
return n = Ie(n), t ? n.length < e ? (n.copy(r), r) : n.slice(0, e) : n.length < e ? (n.copy(r, e - n.length), r) : n.slice(-e);
|
|
846
|
+
}
|
|
847
|
+
function Yn(n, e) {
|
|
848
|
+
return Ht(n, e, !0);
|
|
849
|
+
}
|
|
850
|
+
function Ie(n) {
|
|
851
|
+
if (!f.isBuffer(n))
|
|
852
|
+
if (Array.isArray(n))
|
|
853
|
+
n = f.from(n);
|
|
854
|
+
else if (typeof n == "string")
|
|
855
|
+
Kt(n) ? n = f.from(Xn(qt(n)), "hex") : n = f.from(n);
|
|
856
|
+
else if (typeof n == "number")
|
|
857
|
+
n = intToBuffer(n);
|
|
858
|
+
else if (n == null)
|
|
859
|
+
n = f.allocUnsafe(0);
|
|
860
|
+
else if (typeof n == "bigint")
|
|
861
|
+
n = Bt(n);
|
|
862
|
+
else if (n.toArray)
|
|
863
|
+
n = f.from(n.toArray());
|
|
864
|
+
else
|
|
865
|
+
throw new Error("invalid type");
|
|
866
|
+
return n;
|
|
867
|
+
}
|
|
868
|
+
function Jn(n) {
|
|
869
|
+
return n = Ie(n), "0x" + n.toString("hex");
|
|
870
|
+
}
|
|
871
|
+
function Qn(n, e) {
|
|
872
|
+
return n = Ie(n), e || (e = 256), zn("keccak" + e).update(n).digest();
|
|
873
|
+
}
|
|
874
|
+
function Xn(n) {
|
|
875
|
+
return n.length % 2 ? "0" + n : n;
|
|
876
|
+
}
|
|
877
|
+
function Kt(n) {
|
|
878
|
+
return typeof n == "string" && n.match(/^0x[0-9A-Fa-f]*$/);
|
|
879
|
+
}
|
|
880
|
+
function qt(n) {
|
|
881
|
+
return typeof n == "string" && n.startsWith("0x") ? n.slice(2) : n;
|
|
882
|
+
}
|
|
883
|
+
var $t = {
|
|
884
|
+
zeros: Ut,
|
|
885
|
+
setLength: Ht,
|
|
886
|
+
setLengthRight: Yn,
|
|
887
|
+
isHexString: Kt,
|
|
888
|
+
stripHexPrefix: qt,
|
|
889
|
+
toBuffer: Ie,
|
|
890
|
+
bufferToHex: Jn,
|
|
891
|
+
keccak: Qn,
|
|
892
|
+
bitLengthFromBigInt: Zn,
|
|
893
|
+
bufferBEFromBigInt: Bt,
|
|
894
|
+
twosFromBigInt: Gn
|
|
895
|
+
};
|
|
896
|
+
const S = $t;
|
|
897
|
+
function Ft(n) {
|
|
898
|
+
return n.startsWith("int[") ? "int256" + n.slice(3) : n === "int" ? "int256" : n.startsWith("uint[") ? "uint256" + n.slice(4) : n === "uint" ? "uint256" : n.startsWith("fixed[") ? "fixed128x128" + n.slice(5) : n === "fixed" ? "fixed128x128" : n.startsWith("ufixed[") ? "ufixed128x128" + n.slice(6) : n === "ufixed" ? "ufixed128x128" : n;
|
|
899
|
+
}
|
|
900
|
+
function Y(n) {
|
|
901
|
+
return parseInt(/^\D+(\d+)$/.exec(n)[1], 10);
|
|
902
|
+
}
|
|
903
|
+
function st(n) {
|
|
904
|
+
var e = /^\D+(\d+)x(\d+)$/.exec(n);
|
|
905
|
+
return [parseInt(e[1], 10), parseInt(e[2], 10)];
|
|
906
|
+
}
|
|
907
|
+
function Vt(n) {
|
|
908
|
+
var e = n.match(/(.*)\[(.*?)\]$/);
|
|
909
|
+
return e ? e[2] === "" ? "dynamic" : parseInt(e[2], 10) : null;
|
|
910
|
+
}
|
|
911
|
+
function K(n) {
|
|
912
|
+
var e = typeof n;
|
|
913
|
+
if (e === "string" || e === "number")
|
|
914
|
+
return BigInt(n);
|
|
915
|
+
if (e === "bigint")
|
|
916
|
+
return n;
|
|
917
|
+
throw new Error("Argument is not a number");
|
|
918
|
+
}
|
|
919
|
+
function x(n, e) {
|
|
920
|
+
var t, r, s, i;
|
|
921
|
+
if (n === "address")
|
|
922
|
+
return x("uint160", K(e));
|
|
923
|
+
if (n === "bool")
|
|
924
|
+
return x("uint8", e ? 1 : 0);
|
|
925
|
+
if (n === "string")
|
|
926
|
+
return x("bytes", new f(e, "utf8"));
|
|
927
|
+
if (tr(n)) {
|
|
928
|
+
if (typeof e.length > "u")
|
|
929
|
+
throw new Error("Not an array?");
|
|
930
|
+
if (t = Vt(n), t !== "dynamic" && t !== 0 && e.length > t)
|
|
931
|
+
throw new Error("Elements exceed array size: " + t);
|
|
932
|
+
s = [], n = n.slice(0, n.lastIndexOf("[")), typeof e == "string" && (e = JSON.parse(e));
|
|
933
|
+
for (i in e)
|
|
934
|
+
s.push(x(n, e[i]));
|
|
935
|
+
if (t === "dynamic") {
|
|
936
|
+
var a = x("uint256", e.length);
|
|
937
|
+
s.unshift(a);
|
|
938
|
+
}
|
|
939
|
+
return f.concat(s);
|
|
940
|
+
} else {
|
|
941
|
+
if (n === "bytes")
|
|
942
|
+
return e = new f(e), s = f.concat([x("uint256", e.length), e]), e.length % 32 !== 0 && (s = f.concat([s, S.zeros(32 - e.length % 32)])), s;
|
|
943
|
+
if (n.startsWith("bytes")) {
|
|
944
|
+
if (t = Y(n), t < 1 || t > 32)
|
|
945
|
+
throw new Error("Invalid bytes<N> width: " + t);
|
|
946
|
+
return S.setLengthRight(e, 32);
|
|
947
|
+
} else if (n.startsWith("uint")) {
|
|
948
|
+
if (t = Y(n), t % 8 || t < 8 || t > 256)
|
|
949
|
+
throw new Error("Invalid uint<N> width: " + t);
|
|
950
|
+
r = K(e);
|
|
951
|
+
const o = S.bitLengthFromBigInt(r);
|
|
952
|
+
if (o > t)
|
|
953
|
+
throw new Error("Supplied uint exceeds width: " + t + " vs " + o);
|
|
954
|
+
if (r < 0)
|
|
955
|
+
throw new Error("Supplied uint is negative");
|
|
956
|
+
return S.bufferBEFromBigInt(r, 32);
|
|
957
|
+
} else if (n.startsWith("int")) {
|
|
958
|
+
if (t = Y(n), t % 8 || t < 8 || t > 256)
|
|
959
|
+
throw new Error("Invalid int<N> width: " + t);
|
|
960
|
+
r = K(e);
|
|
961
|
+
const o = S.bitLengthFromBigInt(r);
|
|
962
|
+
if (o > t)
|
|
963
|
+
throw new Error("Supplied int exceeds width: " + t + " vs " + o);
|
|
964
|
+
const c = S.twosFromBigInt(r, 256);
|
|
965
|
+
return S.bufferBEFromBigInt(c, 32);
|
|
966
|
+
} else if (n.startsWith("ufixed")) {
|
|
967
|
+
if (t = st(n), r = K(e), r < 0)
|
|
968
|
+
throw new Error("Supplied ufixed is negative");
|
|
969
|
+
return x("uint256", r * BigInt(2) ** BigInt(t[1]));
|
|
970
|
+
} else if (n.startsWith("fixed"))
|
|
971
|
+
return t = st(n), x("int256", K(e) * BigInt(2) ** BigInt(t[1]));
|
|
972
|
+
}
|
|
973
|
+
throw new Error("Unsupported or invalid type: " + n);
|
|
974
|
+
}
|
|
975
|
+
function er(n) {
|
|
976
|
+
return n === "string" || n === "bytes" || Vt(n) === "dynamic";
|
|
977
|
+
}
|
|
978
|
+
function tr(n) {
|
|
979
|
+
return n.lastIndexOf("]") === n.length - 1;
|
|
980
|
+
}
|
|
981
|
+
function nr(n, e) {
|
|
982
|
+
var t = [], r = [], s = 32 * n.length;
|
|
983
|
+
for (var i in n) {
|
|
984
|
+
var a = Ft(n[i]), o = e[i], c = x(a, o);
|
|
985
|
+
er(a) ? (t.push(x("uint256", s)), r.push(c), s += c.length) : t.push(c);
|
|
986
|
+
}
|
|
987
|
+
return f.concat(t.concat(r));
|
|
988
|
+
}
|
|
989
|
+
function zt(n, e) {
|
|
990
|
+
if (n.length !== e.length)
|
|
991
|
+
throw new Error("Number of types are not matching the values");
|
|
992
|
+
for (var t, r, s = [], i = 0; i < n.length; i++) {
|
|
993
|
+
var a = Ft(n[i]), o = e[i];
|
|
994
|
+
if (a === "bytes")
|
|
995
|
+
s.push(o);
|
|
996
|
+
else if (a === "string")
|
|
997
|
+
s.push(new f(o, "utf8"));
|
|
998
|
+
else if (a === "bool")
|
|
999
|
+
s.push(new f(o ? "01" : "00", "hex"));
|
|
1000
|
+
else if (a === "address")
|
|
1001
|
+
s.push(S.setLength(o, 20));
|
|
1002
|
+
else if (a.startsWith("bytes")) {
|
|
1003
|
+
if (t = Y(a), t < 1 || t > 32)
|
|
1004
|
+
throw new Error("Invalid bytes<N> width: " + t);
|
|
1005
|
+
s.push(S.setLengthRight(o, t));
|
|
1006
|
+
} else if (a.startsWith("uint")) {
|
|
1007
|
+
if (t = Y(a), t % 8 || t < 8 || t > 256)
|
|
1008
|
+
throw new Error("Invalid uint<N> width: " + t);
|
|
1009
|
+
r = K(o);
|
|
1010
|
+
const c = S.bitLengthFromBigInt(r);
|
|
1011
|
+
if (c > t)
|
|
1012
|
+
throw new Error("Supplied uint exceeds width: " + t + " vs " + c);
|
|
1013
|
+
s.push(S.bufferBEFromBigInt(r, t / 8));
|
|
1014
|
+
} else if (a.startsWith("int")) {
|
|
1015
|
+
if (t = Y(a), t % 8 || t < 8 || t > 256)
|
|
1016
|
+
throw new Error("Invalid int<N> width: " + t);
|
|
1017
|
+
r = K(o);
|
|
1018
|
+
const c = S.bitLengthFromBigInt(r);
|
|
1019
|
+
if (c > t)
|
|
1020
|
+
throw new Error("Supplied int exceeds width: " + t + " vs " + c);
|
|
1021
|
+
const l = S.twosFromBigInt(r, t);
|
|
1022
|
+
s.push(S.bufferBEFromBigInt(l, t / 8));
|
|
1023
|
+
} else
|
|
1024
|
+
throw new Error("Unsupported or invalid type: " + a);
|
|
1025
|
+
}
|
|
1026
|
+
return f.concat(s);
|
|
1027
|
+
}
|
|
1028
|
+
function rr(n, e) {
|
|
1029
|
+
return S.keccak(zt(n, e));
|
|
1030
|
+
}
|
|
1031
|
+
var sr = {
|
|
1032
|
+
rawEncode: nr,
|
|
1033
|
+
solidityPack: zt,
|
|
1034
|
+
soliditySHA3: rr
|
|
1035
|
+
};
|
|
1036
|
+
const R = $t, te = sr, Zt = {
|
|
1037
|
+
type: "object",
|
|
1038
|
+
properties: {
|
|
1039
|
+
types: {
|
|
1040
|
+
type: "object",
|
|
1041
|
+
additionalProperties: {
|
|
1042
|
+
type: "array",
|
|
1043
|
+
items: {
|
|
1044
|
+
type: "object",
|
|
1045
|
+
properties: {
|
|
1046
|
+
name: { type: "string" },
|
|
1047
|
+
type: { type: "string" }
|
|
1048
|
+
},
|
|
1049
|
+
required: ["name", "type"]
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
primaryType: { type: "string" },
|
|
1054
|
+
domain: { type: "object" },
|
|
1055
|
+
message: { type: "object" }
|
|
1056
|
+
},
|
|
1057
|
+
required: ["types", "primaryType", "domain", "message"]
|
|
1058
|
+
}, He = {
|
|
1059
|
+
/**
|
|
1060
|
+
* Encodes an object by encoding and concatenating each of its members
|
|
1061
|
+
*
|
|
1062
|
+
* @param {string} primaryType - Root type
|
|
1063
|
+
* @param {Object} data - Object to encode
|
|
1064
|
+
* @param {Object} types - Type definitions
|
|
1065
|
+
* @returns {string} - Encoded representation of an object
|
|
1066
|
+
*/
|
|
1067
|
+
encodeData(n, e, t, r = !0) {
|
|
1068
|
+
const s = ["bytes32"], i = [this.hashType(n, t)];
|
|
1069
|
+
if (r) {
|
|
1070
|
+
const a = (o, c, l) => {
|
|
1071
|
+
if (t[c] !== void 0)
|
|
1072
|
+
return ["bytes32", l == null ? "0x0000000000000000000000000000000000000000000000000000000000000000" : R.keccak(this.encodeData(c, l, t, r))];
|
|
1073
|
+
if (l === void 0)
|
|
1074
|
+
throw new Error(`missing value for field ${o} of type ${c}`);
|
|
1075
|
+
if (c === "bytes")
|
|
1076
|
+
return ["bytes32", R.keccak(l)];
|
|
1077
|
+
if (c === "string")
|
|
1078
|
+
return typeof l == "string" && (l = f.from(l, "utf8")), ["bytes32", R.keccak(l)];
|
|
1079
|
+
if (c.lastIndexOf("]") === c.length - 1) {
|
|
1080
|
+
const h = c.slice(0, c.lastIndexOf("[")), m = l.map((d) => a(o, h, d));
|
|
1081
|
+
return ["bytes32", R.keccak(te.rawEncode(
|
|
1082
|
+
m.map(([d]) => d),
|
|
1083
|
+
m.map(([, d]) => d)
|
|
1084
|
+
))];
|
|
1085
|
+
}
|
|
1086
|
+
return [c, l];
|
|
1087
|
+
};
|
|
1088
|
+
for (const o of t[n]) {
|
|
1089
|
+
const [c, l] = a(o.name, o.type, e[o.name]);
|
|
1090
|
+
s.push(c), i.push(l);
|
|
1091
|
+
}
|
|
1092
|
+
} else
|
|
1093
|
+
for (const a of t[n]) {
|
|
1094
|
+
let o = e[a.name];
|
|
1095
|
+
if (o !== void 0)
|
|
1096
|
+
if (a.type === "bytes")
|
|
1097
|
+
s.push("bytes32"), o = R.keccak(o), i.push(o);
|
|
1098
|
+
else if (a.type === "string")
|
|
1099
|
+
s.push("bytes32"), typeof o == "string" && (o = f.from(o, "utf8")), o = R.keccak(o), i.push(o);
|
|
1100
|
+
else if (t[a.type] !== void 0)
|
|
1101
|
+
s.push("bytes32"), o = R.keccak(this.encodeData(a.type, o, t, r)), i.push(o);
|
|
1102
|
+
else {
|
|
1103
|
+
if (a.type.lastIndexOf("]") === a.type.length - 1)
|
|
1104
|
+
throw new Error("Arrays currently unimplemented in encodeData");
|
|
1105
|
+
s.push(a.type), i.push(o);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return te.rawEncode(s, i);
|
|
1109
|
+
},
|
|
1110
|
+
/**
|
|
1111
|
+
* Encodes the type of an object by encoding a comma delimited list of its members
|
|
1112
|
+
*
|
|
1113
|
+
* @param {string} primaryType - Root type to encode
|
|
1114
|
+
* @param {Object} types - Type definitions
|
|
1115
|
+
* @returns {string} - Encoded representation of the type of an object
|
|
1116
|
+
*/
|
|
1117
|
+
encodeType(n, e) {
|
|
1118
|
+
let t = "", r = this.findTypeDependencies(n, e).filter((s) => s !== n);
|
|
1119
|
+
r = [n].concat(r.sort());
|
|
1120
|
+
for (const s of r) {
|
|
1121
|
+
if (!e[s])
|
|
1122
|
+
throw new Error("No type definition specified: " + s);
|
|
1123
|
+
t += s + "(" + e[s].map(({ name: a, type: o }) => o + " " + a).join(",") + ")";
|
|
1124
|
+
}
|
|
1125
|
+
return t;
|
|
1126
|
+
},
|
|
1127
|
+
/**
|
|
1128
|
+
* Finds all types within a type definition object
|
|
1129
|
+
*
|
|
1130
|
+
* @param {string} primaryType - Root type
|
|
1131
|
+
* @param {Object} types - Type definitions
|
|
1132
|
+
* @param {Array} results - current set of accumulated types
|
|
1133
|
+
* @returns {Array} - Set of all types found in the type definition
|
|
1134
|
+
*/
|
|
1135
|
+
findTypeDependencies(n, e, t = []) {
|
|
1136
|
+
if (n = n.match(/^\w*/)[0], t.includes(n) || e[n] === void 0)
|
|
1137
|
+
return t;
|
|
1138
|
+
t.push(n);
|
|
1139
|
+
for (const r of e[n])
|
|
1140
|
+
for (const s of this.findTypeDependencies(r.type, e, t))
|
|
1141
|
+
!t.includes(s) && t.push(s);
|
|
1142
|
+
return t;
|
|
1143
|
+
},
|
|
1144
|
+
/**
|
|
1145
|
+
* Hashes an object
|
|
1146
|
+
*
|
|
1147
|
+
* @param {string} primaryType - Root type
|
|
1148
|
+
* @param {Object} data - Object to hash
|
|
1149
|
+
* @param {Object} types - Type definitions
|
|
1150
|
+
* @returns {Buffer} - Hash of an object
|
|
1151
|
+
*/
|
|
1152
|
+
hashStruct(n, e, t, r = !0) {
|
|
1153
|
+
return R.keccak(this.encodeData(n, e, t, r));
|
|
1154
|
+
},
|
|
1155
|
+
/**
|
|
1156
|
+
* Hashes the type of an object
|
|
1157
|
+
*
|
|
1158
|
+
* @param {string} primaryType - Root type to hash
|
|
1159
|
+
* @param {Object} types - Type definitions
|
|
1160
|
+
* @returns {string} - Hash of an object
|
|
1161
|
+
*/
|
|
1162
|
+
hashType(n, e) {
|
|
1163
|
+
return R.keccak(this.encodeType(n, e));
|
|
1164
|
+
},
|
|
1165
|
+
/**
|
|
1166
|
+
* Removes properties from a message object that are not defined per EIP-712
|
|
1167
|
+
*
|
|
1168
|
+
* @param {Object} data - typed message object
|
|
1169
|
+
* @returns {Object} - typed message object with only allowed fields
|
|
1170
|
+
*/
|
|
1171
|
+
sanitizeData(n) {
|
|
1172
|
+
const e = {};
|
|
1173
|
+
for (const t in Zt.properties)
|
|
1174
|
+
n[t] && (e[t] = n[t]);
|
|
1175
|
+
return e.types && (e.types = Object.assign({ EIP712Domain: [] }, e.types)), e;
|
|
1176
|
+
},
|
|
1177
|
+
/**
|
|
1178
|
+
* Returns the hash of a typed message as per EIP-712 for signing
|
|
1179
|
+
*
|
|
1180
|
+
* @param {Object} typedData - Types message data to sign
|
|
1181
|
+
* @returns {string} - sha3 hash for signing
|
|
1182
|
+
*/
|
|
1183
|
+
hash(n, e = !0) {
|
|
1184
|
+
const t = this.sanitizeData(n), r = [f.from("1901", "hex")];
|
|
1185
|
+
return r.push(this.hashStruct("EIP712Domain", t.domain, t.types, e)), t.primaryType !== "EIP712Domain" && r.push(this.hashStruct(t.primaryType, t.message, t.types, e)), R.keccak(f.concat(r));
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
var ir = {
|
|
1189
|
+
TYPED_MESSAGE_SCHEMA: Zt,
|
|
1190
|
+
TypedDataUtils: He,
|
|
1191
|
+
hashForSignTypedDataLegacy: function(n) {
|
|
1192
|
+
return ar(n.data);
|
|
1193
|
+
},
|
|
1194
|
+
hashForSignTypedData_v3: function(n) {
|
|
1195
|
+
return He.hash(n.data, !1);
|
|
1196
|
+
},
|
|
1197
|
+
hashForSignTypedData_v4: function(n) {
|
|
1198
|
+
return He.hash(n.data);
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
function ar(n) {
|
|
1202
|
+
const e = new Error("Expect argument to be non-empty array");
|
|
1203
|
+
if (typeof n != "object" || !n.length)
|
|
1204
|
+
throw e;
|
|
1205
|
+
const t = n.map(function(i) {
|
|
1206
|
+
return i.type === "bytes" ? R.toBuffer(i.value) : i.value;
|
|
1207
|
+
}), r = n.map(function(i) {
|
|
1208
|
+
return i.type;
|
|
1209
|
+
}), s = n.map(function(i) {
|
|
1210
|
+
if (!i.name)
|
|
1211
|
+
throw e;
|
|
1212
|
+
return i.type + " " + i.name;
|
|
1213
|
+
});
|
|
1214
|
+
return te.soliditySHA3(
|
|
1215
|
+
["bytes32", "bytes32"],
|
|
1216
|
+
[
|
|
1217
|
+
te.soliditySHA3(new Array(n.length).fill("string"), s),
|
|
1218
|
+
te.soliditySHA3(r, t)
|
|
1219
|
+
]
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
var T = {};
|
|
1223
|
+
Object.defineProperty(T, "__esModule", { value: !0 });
|
|
1224
|
+
T.APP_VERSION_KEY = T.LOCAL_STORAGE_ADDRESSES_KEY = T.WALLET_USER_NAME_KEY = void 0;
|
|
1225
|
+
T.WALLET_USER_NAME_KEY = "walletUsername";
|
|
1226
|
+
T.LOCAL_STORAGE_ADDRESSES_KEY = "Addresses";
|
|
1227
|
+
T.APP_VERSION_KEY = "AppVersion";
|
|
1228
|
+
var ae = {};
|
|
1229
|
+
Object.defineProperty(ae, "__esModule", { value: !0 });
|
|
1230
|
+
ae.RelayEventManager = void 0;
|
|
1231
|
+
const or = u;
|
|
1232
|
+
class cr {
|
|
1233
|
+
constructor() {
|
|
1234
|
+
this._nextRequestId = 0, this.callbacks = /* @__PURE__ */ new Map();
|
|
1235
|
+
}
|
|
1236
|
+
makeRequestId() {
|
|
1237
|
+
this._nextRequestId = (this._nextRequestId + 1) % 2147483647;
|
|
1238
|
+
const e = this._nextRequestId, t = (0, or.prepend0x)(e.toString(16));
|
|
1239
|
+
return this.callbacks.get(t) && this.callbacks.delete(t), e;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
ae.RelayEventManager = cr;
|
|
1243
|
+
var Me = {}, Le = {}, Ae = {};
|
|
1244
|
+
Object.defineProperty(Ae, "__esModule", { value: !0 });
|
|
1245
|
+
Ae.WalletLinkCipher = void 0;
|
|
1246
|
+
const ue = u;
|
|
1247
|
+
class dr {
|
|
1248
|
+
// @param secret hex representation of 32-byte secret
|
|
1249
|
+
constructor(e) {
|
|
1250
|
+
this.secret = e;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
*
|
|
1254
|
+
* @param plainText string to be encrypted
|
|
1255
|
+
* returns hex string representation of bytes in the order: initialization vector (iv),
|
|
1256
|
+
* auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes. Remaining bytes are the
|
|
1257
|
+
* encrypted plainText.
|
|
1258
|
+
*/
|
|
1259
|
+
async encrypt(e) {
|
|
1260
|
+
const t = this.secret;
|
|
1261
|
+
if (t.length !== 64)
|
|
1262
|
+
throw Error("secret must be 256 bits");
|
|
1263
|
+
const r = crypto.getRandomValues(new Uint8Array(12)), s = await crypto.subtle.importKey("raw", (0, ue.hexStringToUint8Array)(t), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), i = new TextEncoder(), a = await window.crypto.subtle.encrypt({
|
|
1264
|
+
name: "AES-GCM",
|
|
1265
|
+
iv: r
|
|
1266
|
+
}, s, i.encode(e)), o = 16, c = a.slice(a.byteLength - o), l = a.slice(0, a.byteLength - o), h = new Uint8Array(c), m = new Uint8Array(l), d = new Uint8Array([...r, ...h, ...m]);
|
|
1267
|
+
return (0, ue.uint8ArrayToHex)(d);
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
*
|
|
1271
|
+
* @param cipherText hex string representation of bytes in the order: initialization vector (iv),
|
|
1272
|
+
* auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes.
|
|
1273
|
+
*/
|
|
1274
|
+
async decrypt(e) {
|
|
1275
|
+
const t = this.secret;
|
|
1276
|
+
if (t.length !== 64)
|
|
1277
|
+
throw Error("secret must be 256 bits");
|
|
1278
|
+
return new Promise((r, s) => {
|
|
1279
|
+
(async function() {
|
|
1280
|
+
const i = await crypto.subtle.importKey("raw", (0, ue.hexStringToUint8Array)(t), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), a = (0, ue.hexStringToUint8Array)(e), o = a.slice(0, 12), c = a.slice(12, 28), l = a.slice(28), h = new Uint8Array([...l, ...c]), m = {
|
|
1281
|
+
name: "AES-GCM",
|
|
1282
|
+
iv: new Uint8Array(o)
|
|
1283
|
+
};
|
|
1284
|
+
try {
|
|
1285
|
+
const d = await window.crypto.subtle.decrypt(m, i, h), p = new TextDecoder();
|
|
1286
|
+
r(p.decode(d));
|
|
1287
|
+
} catch (d) {
|
|
1288
|
+
s(d);
|
|
1289
|
+
}
|
|
1290
|
+
})();
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
Ae.WalletLinkCipher = dr;
|
|
1295
|
+
var Re = {};
|
|
1296
|
+
Object.defineProperty(Re, "__esModule", { value: !0 });
|
|
1297
|
+
Re.WalletLinkHTTP = void 0;
|
|
1298
|
+
class lr {
|
|
1299
|
+
constructor(e, t, r) {
|
|
1300
|
+
this.linkAPIUrl = e, this.sessionId = t;
|
|
1301
|
+
const s = `${t}:${r}`;
|
|
1302
|
+
this.auth = `Basic ${btoa(s)}`;
|
|
1303
|
+
}
|
|
1304
|
+
// mark unseen events as seen
|
|
1305
|
+
async markUnseenEventsAsSeen(e) {
|
|
1306
|
+
return Promise.all(e.map((t) => fetch(`${this.linkAPIUrl}/events/${t.eventId}/seen`, {
|
|
1307
|
+
method: "POST",
|
|
1308
|
+
headers: {
|
|
1309
|
+
Authorization: this.auth
|
|
1310
|
+
}
|
|
1311
|
+
}))).catch((t) => console.error("Unabled to mark event as failed:", t));
|
|
1312
|
+
}
|
|
1313
|
+
async fetchUnseenEvents() {
|
|
1314
|
+
var e;
|
|
1315
|
+
const t = await fetch(`${this.linkAPIUrl}/events?unseen=true`, {
|
|
1316
|
+
headers: {
|
|
1317
|
+
Authorization: this.auth
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
if (t.ok) {
|
|
1321
|
+
const { events: r, error: s } = await t.json();
|
|
1322
|
+
if (s)
|
|
1323
|
+
throw new Error(`Check unseen events failed: ${s}`);
|
|
1324
|
+
const i = (e = r == null ? void 0 : r.filter((a) => a.event === "Web3Response").map((a) => ({
|
|
1325
|
+
type: "Event",
|
|
1326
|
+
sessionId: this.sessionId,
|
|
1327
|
+
eventId: a.id,
|
|
1328
|
+
event: a.event,
|
|
1329
|
+
data: a.data
|
|
1330
|
+
}))) !== null && e !== void 0 ? e : [];
|
|
1331
|
+
return this.markUnseenEventsAsSeen(i), i;
|
|
1332
|
+
}
|
|
1333
|
+
throw new Error(`Check unseen events failed: ${t.status}`);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
Re.WalletLinkHTTP = lr;
|
|
1337
|
+
var J = {};
|
|
1338
|
+
Object.defineProperty(J, "__esModule", { value: !0 });
|
|
1339
|
+
J.WalletLinkWebSocket = J.ConnectionState = void 0;
|
|
1340
|
+
var G;
|
|
1341
|
+
(function(n) {
|
|
1342
|
+
n[n.DISCONNECTED = 0] = "DISCONNECTED", n[n.CONNECTING = 1] = "CONNECTING", n[n.CONNECTED = 2] = "CONNECTED";
|
|
1343
|
+
})(G || (J.ConnectionState = G = {}));
|
|
1344
|
+
class ur {
|
|
1345
|
+
setConnectionStateListener(e) {
|
|
1346
|
+
this.connectionStateListener = e;
|
|
1347
|
+
}
|
|
1348
|
+
setIncomingDataListener(e) {
|
|
1349
|
+
this.incomingDataListener = e;
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Constructor
|
|
1353
|
+
* @param url WebSocket server URL
|
|
1354
|
+
* @param [WebSocketClass] Custom WebSocket implementation
|
|
1355
|
+
*/
|
|
1356
|
+
constructor(e, t = WebSocket) {
|
|
1357
|
+
this.WebSocketClass = t, this.webSocket = null, this.pendingData = [], this.url = e.replace(/^http/, "ws");
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Make a websocket connection
|
|
1361
|
+
* @returns a Promise that resolves when connected
|
|
1362
|
+
*/
|
|
1363
|
+
async connect() {
|
|
1364
|
+
if (this.webSocket)
|
|
1365
|
+
throw new Error("webSocket object is not null");
|
|
1366
|
+
return new Promise((e, t) => {
|
|
1367
|
+
var r;
|
|
1368
|
+
let s;
|
|
1369
|
+
try {
|
|
1370
|
+
this.webSocket = s = new this.WebSocketClass(this.url);
|
|
1371
|
+
} catch (i) {
|
|
1372
|
+
t(i);
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
(r = this.connectionStateListener) === null || r === void 0 || r.call(this, G.CONNECTING), s.onclose = (i) => {
|
|
1376
|
+
var a;
|
|
1377
|
+
this.clearWebSocket(), t(new Error(`websocket error ${i.code}: ${i.reason}`)), (a = this.connectionStateListener) === null || a === void 0 || a.call(this, G.DISCONNECTED);
|
|
1378
|
+
}, s.onopen = (i) => {
|
|
1379
|
+
var a;
|
|
1380
|
+
e(), (a = this.connectionStateListener) === null || a === void 0 || a.call(this, G.CONNECTED), this.pendingData.length > 0 && ([...this.pendingData].forEach((c) => this.sendData(c)), this.pendingData = []);
|
|
1381
|
+
}, s.onmessage = (i) => {
|
|
1382
|
+
var a, o;
|
|
1383
|
+
if (i.data === "h")
|
|
1384
|
+
(a = this.incomingDataListener) === null || a === void 0 || a.call(this, {
|
|
1385
|
+
type: "Heartbeat"
|
|
1386
|
+
});
|
|
1387
|
+
else
|
|
1388
|
+
try {
|
|
1389
|
+
const c = JSON.parse(i.data);
|
|
1390
|
+
(o = this.incomingDataListener) === null || o === void 0 || o.call(this, c);
|
|
1391
|
+
} catch {
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Disconnect from server
|
|
1398
|
+
*/
|
|
1399
|
+
disconnect() {
|
|
1400
|
+
var e;
|
|
1401
|
+
const { webSocket: t } = this;
|
|
1402
|
+
if (t) {
|
|
1403
|
+
this.clearWebSocket(), (e = this.connectionStateListener) === null || e === void 0 || e.call(this, G.DISCONNECTED), this.connectionStateListener = void 0, this.incomingDataListener = void 0;
|
|
1404
|
+
try {
|
|
1405
|
+
t.close();
|
|
1406
|
+
} catch {
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Send data to server
|
|
1412
|
+
* @param data text to send
|
|
1413
|
+
*/
|
|
1414
|
+
sendData(e) {
|
|
1415
|
+
const { webSocket: t } = this;
|
|
1416
|
+
if (!t) {
|
|
1417
|
+
this.pendingData.push(e), this.connect();
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
t.send(e);
|
|
1421
|
+
}
|
|
1422
|
+
clearWebSocket() {
|
|
1423
|
+
const { webSocket: e } = this;
|
|
1424
|
+
e && (this.webSocket = null, e.onclose = null, e.onerror = null, e.onmessage = null, e.onopen = null);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
J.WalletLinkWebSocket = ur;
|
|
1428
|
+
Object.defineProperty(Le, "__esModule", { value: !0 });
|
|
1429
|
+
Le.WalletLinkConnection = void 0;
|
|
1430
|
+
const it = T, hr = Ae, gr = Re, he = J, V = E, at = 1e4, pr = 6e4;
|
|
1431
|
+
class fr {
|
|
1432
|
+
/**
|
|
1433
|
+
* Constructor
|
|
1434
|
+
* @param session Session
|
|
1435
|
+
* @param linkAPIUrl Coinbase Wallet link server URL
|
|
1436
|
+
* @param listener WalletLinkConnectionUpdateListener
|
|
1437
|
+
* @param [WebSocketClass] Custom WebSocket implementation
|
|
1438
|
+
*/
|
|
1439
|
+
constructor({ session: e, linkAPIUrl: t, listener: r, WebSocketClass: s = WebSocket }) {
|
|
1440
|
+
this.destroyed = !1, this.lastHeartbeatResponse = 0, this.nextReqId = (0, V.IntNumber)(1), this._connected = !1, this._linked = !1, this.shouldFetchUnseenEventsOnConnect = !1, this.requestResolutions = /* @__PURE__ */ new Map(), this.handleSessionMetadataUpdated = (a) => {
|
|
1441
|
+
if (!a)
|
|
1442
|
+
return;
|
|
1443
|
+
(/* @__PURE__ */ new Map([
|
|
1444
|
+
["__destroyed", this.handleDestroyed],
|
|
1445
|
+
["EthereumAddress", this.handleAccountUpdated],
|
|
1446
|
+
["WalletUsername", this.handleWalletUsernameUpdated],
|
|
1447
|
+
["AppVersion", this.handleAppVersionUpdated],
|
|
1448
|
+
[
|
|
1449
|
+
"ChainId",
|
|
1450
|
+
(c) => a.JsonRpcUrl && this.handleChainUpdated(c, a.JsonRpcUrl)
|
|
1451
|
+
]
|
|
1452
|
+
])).forEach((c, l) => {
|
|
1453
|
+
const h = a[l];
|
|
1454
|
+
h !== void 0 && c(h);
|
|
1455
|
+
});
|
|
1456
|
+
}, this.handleDestroyed = (a) => {
|
|
1457
|
+
var o;
|
|
1458
|
+
a === "1" && ((o = this.listener) === null || o === void 0 || o.resetAndReload());
|
|
1459
|
+
}, this.handleAccountUpdated = async (a) => {
|
|
1460
|
+
var o;
|
|
1461
|
+
{
|
|
1462
|
+
const c = await this.cipher.decrypt(a);
|
|
1463
|
+
(o = this.listener) === null || o === void 0 || o.accountUpdated(c);
|
|
1464
|
+
}
|
|
1465
|
+
}, this.handleMetadataUpdated = async (a, o) => {
|
|
1466
|
+
var c;
|
|
1467
|
+
{
|
|
1468
|
+
const l = await this.cipher.decrypt(o);
|
|
1469
|
+
(c = this.listener) === null || c === void 0 || c.metadataUpdated(a, l);
|
|
1470
|
+
}
|
|
1471
|
+
}, this.handleWalletUsernameUpdated = async (a) => {
|
|
1472
|
+
this.handleMetadataUpdated(it.WALLET_USER_NAME_KEY, a);
|
|
1473
|
+
}, this.handleAppVersionUpdated = async (a) => {
|
|
1474
|
+
this.handleMetadataUpdated(it.APP_VERSION_KEY, a);
|
|
1475
|
+
}, this.handleChainUpdated = async (a, o) => {
|
|
1476
|
+
var c;
|
|
1477
|
+
{
|
|
1478
|
+
const l = await this.cipher.decrypt(a), h = await this.cipher.decrypt(o);
|
|
1479
|
+
(c = this.listener) === null || c === void 0 || c.chainUpdated(l, h);
|
|
1480
|
+
}
|
|
1481
|
+
}, this.session = e, this.cipher = new hr.WalletLinkCipher(e.secret), this.listener = r;
|
|
1482
|
+
const i = new he.WalletLinkWebSocket(`${t}/rpc`, s);
|
|
1483
|
+
i.setConnectionStateListener(async (a) => {
|
|
1484
|
+
let o = !1;
|
|
1485
|
+
switch (a) {
|
|
1486
|
+
case he.ConnectionState.DISCONNECTED:
|
|
1487
|
+
if (!this.destroyed) {
|
|
1488
|
+
const c = async () => {
|
|
1489
|
+
await new Promise((l) => setTimeout(l, 5e3)), this.destroyed || i.connect().catch(() => {
|
|
1490
|
+
c();
|
|
1491
|
+
});
|
|
1492
|
+
};
|
|
1493
|
+
c();
|
|
1494
|
+
}
|
|
1495
|
+
break;
|
|
1496
|
+
case he.ConnectionState.CONNECTED:
|
|
1497
|
+
try {
|
|
1498
|
+
await this.authenticate(), this.sendIsLinked(), this.sendGetSessionConfig(), o = !0;
|
|
1499
|
+
} catch {
|
|
1500
|
+
}
|
|
1501
|
+
this.updateLastHeartbeat(), setInterval(() => {
|
|
1502
|
+
this.heartbeat();
|
|
1503
|
+
}, at), this.shouldFetchUnseenEventsOnConnect && this.fetchUnseenEventsAPI();
|
|
1504
|
+
break;
|
|
1505
|
+
case he.ConnectionState.CONNECTING:
|
|
1506
|
+
break;
|
|
1507
|
+
}
|
|
1508
|
+
this.connected !== o && (this.connected = o);
|
|
1509
|
+
}), i.setIncomingDataListener((a) => {
|
|
1510
|
+
var o;
|
|
1511
|
+
switch (a.type) {
|
|
1512
|
+
case "Heartbeat":
|
|
1513
|
+
this.updateLastHeartbeat();
|
|
1514
|
+
return;
|
|
1515
|
+
case "IsLinkedOK":
|
|
1516
|
+
case "Linked": {
|
|
1517
|
+
const c = a.type === "IsLinkedOK" ? a.linked : void 0;
|
|
1518
|
+
this.linked = c || a.onlineGuests > 0;
|
|
1519
|
+
break;
|
|
1520
|
+
}
|
|
1521
|
+
case "GetSessionConfigOK":
|
|
1522
|
+
case "SessionConfigUpdated": {
|
|
1523
|
+
this.handleSessionMetadataUpdated(a.metadata);
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
case "Event": {
|
|
1527
|
+
this.handleIncomingEvent(a);
|
|
1528
|
+
break;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
a.id !== void 0 && ((o = this.requestResolutions.get(a.id)) === null || o === void 0 || o(a));
|
|
1532
|
+
}), this.ws = i, this.http = new gr.WalletLinkHTTP(t, e.id, e.key);
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Make a connection to the server
|
|
1536
|
+
*/
|
|
1537
|
+
connect() {
|
|
1538
|
+
if (this.destroyed)
|
|
1539
|
+
throw new Error("instance is destroyed");
|
|
1540
|
+
this.ws.connect();
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Terminate connection, and mark as destroyed. To reconnect, create a new
|
|
1544
|
+
* instance of WalletSDKConnection
|
|
1545
|
+
*/
|
|
1546
|
+
destroy() {
|
|
1547
|
+
this.destroyed = !0, this.ws.disconnect(), this.listener = void 0;
|
|
1548
|
+
}
|
|
1549
|
+
get isDestroyed() {
|
|
1550
|
+
return this.destroyed;
|
|
1551
|
+
}
|
|
1552
|
+
get connected() {
|
|
1553
|
+
return this._connected;
|
|
1554
|
+
}
|
|
1555
|
+
set connected(e) {
|
|
1556
|
+
var t;
|
|
1557
|
+
this._connected = e, e && ((t = this.onceConnected) === null || t === void 0 || t.call(this));
|
|
1558
|
+
}
|
|
1559
|
+
setOnceConnected(e) {
|
|
1560
|
+
return new Promise((t) => {
|
|
1561
|
+
this.connected ? e().then(t) : this.onceConnected = () => {
|
|
1562
|
+
e().then(t), this.onceConnected = void 0;
|
|
1563
|
+
};
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
get linked() {
|
|
1567
|
+
return this._linked;
|
|
1568
|
+
}
|
|
1569
|
+
set linked(e) {
|
|
1570
|
+
var t, r;
|
|
1571
|
+
this._linked = e, e && ((t = this.onceLinked) === null || t === void 0 || t.call(this)), (r = this.listener) === null || r === void 0 || r.linkedUpdated(e);
|
|
1572
|
+
}
|
|
1573
|
+
setOnceLinked(e) {
|
|
1574
|
+
return new Promise((t) => {
|
|
1575
|
+
this.linked ? e().then(t) : this.onceLinked = () => {
|
|
1576
|
+
e().then(t), this.onceLinked = void 0;
|
|
1577
|
+
};
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
async handleIncomingEvent(e) {
|
|
1581
|
+
var t;
|
|
1582
|
+
if (!(e.type !== "Event" || e.event !== "Web3Response")) {
|
|
1583
|
+
const r = await this.cipher.decrypt(e.data), s = JSON.parse(r);
|
|
1584
|
+
if (s.type !== "WEB3_RESPONSE")
|
|
1585
|
+
return;
|
|
1586
|
+
(t = this.listener) === null || t === void 0 || t.handleWeb3ResponseMessage(s);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
async checkUnseenEvents() {
|
|
1590
|
+
if (!this.connected) {
|
|
1591
|
+
this.shouldFetchUnseenEventsOnConnect = !0;
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
await new Promise((e) => setTimeout(e, 250));
|
|
1595
|
+
try {
|
|
1596
|
+
await this.fetchUnseenEventsAPI();
|
|
1597
|
+
} catch (e) {
|
|
1598
|
+
console.error("Unable to check for unseen events", e);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
async fetchUnseenEventsAPI() {
|
|
1602
|
+
this.shouldFetchUnseenEventsOnConnect = !1, (await this.http.fetchUnseenEvents()).forEach((t) => this.handleIncomingEvent(t));
|
|
1603
|
+
}
|
|
1604
|
+
/**
|
|
1605
|
+
* Set session metadata in SessionConfig object
|
|
1606
|
+
* @param key
|
|
1607
|
+
* @param value
|
|
1608
|
+
* @returns a Promise that completes when successful
|
|
1609
|
+
*/
|
|
1610
|
+
async setSessionMetadata(e, t) {
|
|
1611
|
+
const r = {
|
|
1612
|
+
type: "SetSessionConfig",
|
|
1613
|
+
id: (0, V.IntNumber)(this.nextReqId++),
|
|
1614
|
+
sessionId: this.session.id,
|
|
1615
|
+
metadata: { [e]: t }
|
|
1616
|
+
};
|
|
1617
|
+
return this.setOnceConnected(async () => {
|
|
1618
|
+
const s = await this.makeRequest(r);
|
|
1619
|
+
if (s.type === "Fail")
|
|
1620
|
+
throw new Error(s.error || "failed to set session metadata");
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Publish an event and emit event ID when successful
|
|
1625
|
+
* @param event event name
|
|
1626
|
+
* @param unencryptedData unencrypted event data
|
|
1627
|
+
* @param callWebhook whether the webhook should be invoked
|
|
1628
|
+
* @returns a Promise that emits event ID when successful
|
|
1629
|
+
*/
|
|
1630
|
+
async publishEvent(e, t, r = !1) {
|
|
1631
|
+
const s = await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({}, t), { origin: location.origin, relaySource: "coinbaseWalletExtension" in window && window.coinbaseWalletExtension ? "injected_sdk" : "sdk" }))), i = {
|
|
1632
|
+
type: "PublishEvent",
|
|
1633
|
+
id: (0, V.IntNumber)(this.nextReqId++),
|
|
1634
|
+
sessionId: this.session.id,
|
|
1635
|
+
event: e,
|
|
1636
|
+
data: s,
|
|
1637
|
+
callWebhook: r
|
|
1638
|
+
};
|
|
1639
|
+
return this.setOnceLinked(async () => {
|
|
1640
|
+
const a = await this.makeRequest(i);
|
|
1641
|
+
if (a.type === "Fail")
|
|
1642
|
+
throw new Error(a.error || "failed to publish event");
|
|
1643
|
+
return a.eventId;
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
sendData(e) {
|
|
1647
|
+
this.ws.sendData(JSON.stringify(e));
|
|
1648
|
+
}
|
|
1649
|
+
updateLastHeartbeat() {
|
|
1650
|
+
this.lastHeartbeatResponse = Date.now();
|
|
1651
|
+
}
|
|
1652
|
+
heartbeat() {
|
|
1653
|
+
if (Date.now() - this.lastHeartbeatResponse > at * 2) {
|
|
1654
|
+
this.ws.disconnect();
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
try {
|
|
1658
|
+
this.ws.sendData("h");
|
|
1659
|
+
} catch {
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
async makeRequest(e, t = pr) {
|
|
1663
|
+
const r = e.id;
|
|
1664
|
+
this.sendData(e);
|
|
1665
|
+
let s;
|
|
1666
|
+
return Promise.race([
|
|
1667
|
+
new Promise((i, a) => {
|
|
1668
|
+
s = window.setTimeout(() => {
|
|
1669
|
+
a(new Error(`request ${r} timed out`));
|
|
1670
|
+
}, t);
|
|
1671
|
+
}),
|
|
1672
|
+
new Promise((i) => {
|
|
1673
|
+
this.requestResolutions.set(r, (a) => {
|
|
1674
|
+
clearTimeout(s), i(a), this.requestResolutions.delete(r);
|
|
1675
|
+
});
|
|
1676
|
+
})
|
|
1677
|
+
]);
|
|
1678
|
+
}
|
|
1679
|
+
async authenticate() {
|
|
1680
|
+
const e = {
|
|
1681
|
+
type: "HostSession",
|
|
1682
|
+
id: (0, V.IntNumber)(this.nextReqId++),
|
|
1683
|
+
sessionId: this.session.id,
|
|
1684
|
+
sessionKey: this.session.key
|
|
1685
|
+
}, t = await this.makeRequest(e);
|
|
1686
|
+
if (t.type === "Fail")
|
|
1687
|
+
throw new Error(t.error || "failed to authenticate");
|
|
1688
|
+
}
|
|
1689
|
+
sendIsLinked() {
|
|
1690
|
+
const e = {
|
|
1691
|
+
type: "IsLinked",
|
|
1692
|
+
id: (0, V.IntNumber)(this.nextReqId++),
|
|
1693
|
+
sessionId: this.session.id
|
|
1694
|
+
};
|
|
1695
|
+
this.sendData(e);
|
|
1696
|
+
}
|
|
1697
|
+
sendGetSessionConfig() {
|
|
1698
|
+
const e = {
|
|
1699
|
+
type: "GetSessionConfig",
|
|
1700
|
+
id: (0, V.IntNumber)(this.nextReqId++),
|
|
1701
|
+
sessionId: this.session.id
|
|
1702
|
+
};
|
|
1703
|
+
this.sendData(e);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
Le.WalletLinkConnection = fr;
|
|
1707
|
+
var xe = {};
|
|
1708
|
+
Object.defineProperty(xe, "__esModule", { value: !0 });
|
|
1709
|
+
xe.WalletLinkSession = void 0;
|
|
1710
|
+
const mr = rn, ot = u, ct = "session:id", dt = "session:secret", lt = "session:linked";
|
|
1711
|
+
class ze {
|
|
1712
|
+
constructor(e, t, r, s) {
|
|
1713
|
+
this._storage = e, this._id = t || (0, ot.randomBytesHex)(16), this._secret = r || (0, ot.randomBytesHex)(32), this._key = new mr.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"), this._linked = !!s;
|
|
1714
|
+
}
|
|
1715
|
+
static load(e) {
|
|
1716
|
+
const t = e.getItem(ct), r = e.getItem(lt), s = e.getItem(dt);
|
|
1717
|
+
return t && s ? new ze(e, t, s, r === "1") : null;
|
|
1718
|
+
}
|
|
1719
|
+
get id() {
|
|
1720
|
+
return this._id;
|
|
1721
|
+
}
|
|
1722
|
+
get secret() {
|
|
1723
|
+
return this._secret;
|
|
1724
|
+
}
|
|
1725
|
+
get key() {
|
|
1726
|
+
return this._key;
|
|
1727
|
+
}
|
|
1728
|
+
get linked() {
|
|
1729
|
+
return this._linked;
|
|
1730
|
+
}
|
|
1731
|
+
set linked(e) {
|
|
1732
|
+
this._linked = e, this.persistLinked();
|
|
1733
|
+
}
|
|
1734
|
+
save() {
|
|
1735
|
+
return this._storage.setItem(ct, this._id), this._storage.setItem(dt, this._secret), this.persistLinked(), this;
|
|
1736
|
+
}
|
|
1737
|
+
persistLinked() {
|
|
1738
|
+
this._storage.setItem(lt, this._linked ? "1" : "0");
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
xe.WalletLinkSession = ze;
|
|
1742
|
+
var C = {};
|
|
1743
|
+
Object.defineProperty(C, "__esModule", { value: !0 });
|
|
1744
|
+
C.isDarkMode = C.isMobileWeb = C.getLocation = C.createQrUrl = void 0;
|
|
1745
|
+
function br(n, e, t, r, s, i) {
|
|
1746
|
+
const a = r ? "parent-id" : "id", o = new URLSearchParams({
|
|
1747
|
+
[a]: n,
|
|
1748
|
+
secret: e,
|
|
1749
|
+
server: t,
|
|
1750
|
+
v: s,
|
|
1751
|
+
chainId: i.toString()
|
|
1752
|
+
}).toString();
|
|
1753
|
+
return `${t}/#/link?${o}`;
|
|
1754
|
+
}
|
|
1755
|
+
C.createQrUrl = br;
|
|
1756
|
+
function yr() {
|
|
1757
|
+
try {
|
|
1758
|
+
return window.frameElement !== null;
|
|
1759
|
+
} catch {
|
|
1760
|
+
return !1;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
function wr() {
|
|
1764
|
+
try {
|
|
1765
|
+
return yr() && window.top ? window.top.location : window.location;
|
|
1766
|
+
} catch {
|
|
1767
|
+
return window.location;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
C.getLocation = wr;
|
|
1771
|
+
function vr() {
|
|
1772
|
+
var n;
|
|
1773
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((n = window == null ? void 0 : window.navigator) === null || n === void 0 ? void 0 : n.userAgent);
|
|
1774
|
+
}
|
|
1775
|
+
C.isMobileWeb = vr;
|
|
1776
|
+
function _r() {
|
|
1777
|
+
var n, e;
|
|
1778
|
+
return (e = (n = window == null ? void 0 : window.matchMedia) === null || n === void 0 ? void 0 : n.call(window, "(prefers-color-scheme: dark)").matches) !== null && e !== void 0 ? e : !1;
|
|
1779
|
+
}
|
|
1780
|
+
C.isDarkMode = _r;
|
|
1781
|
+
var Pe = {}, oe = {}, Ze = {};
|
|
1782
|
+
Object.defineProperty(Ze, "__esModule", { value: !0 });
|
|
1783
|
+
Ze.default = '@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';
|
|
1784
|
+
var Er = L && L.__importDefault || function(n) {
|
|
1785
|
+
return n && n.__esModule ? n : { default: n };
|
|
1786
|
+
};
|
|
1787
|
+
Object.defineProperty(oe, "__esModule", { value: !0 });
|
|
1788
|
+
oe.injectCssReset = void 0;
|
|
1789
|
+
const Sr = Er(Ze);
|
|
1790
|
+
function Cr() {
|
|
1791
|
+
const n = document.createElement("style");
|
|
1792
|
+
n.type = "text/css", n.appendChild(document.createTextNode(Sr.default)), document.documentElement.appendChild(n);
|
|
1793
|
+
}
|
|
1794
|
+
oe.injectCssReset = Cr;
|
|
1795
|
+
var Ge = {}, Ye = {};
|
|
1796
|
+
Object.defineProperty(Ye, "__esModule", { value: !0 });
|
|
1797
|
+
Ye.default = ".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}";
|
|
1798
|
+
(function(n) {
|
|
1799
|
+
var e = L && L.__importDefault || function(d) {
|
|
1800
|
+
return d && d.__esModule ? d : { default: d };
|
|
1801
|
+
};
|
|
1802
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), n.SnackbarInstance = n.SnackbarContainer = n.Snackbar = void 0;
|
|
1803
|
+
const t = e(_t), r = Et, s = cn, i = C, a = e(Ye), o = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+", c = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";
|
|
1804
|
+
class l {
|
|
1805
|
+
constructor() {
|
|
1806
|
+
this.items = /* @__PURE__ */ new Map(), this.nextItemKey = 0, this.root = null, this.darkMode = (0, i.isDarkMode)();
|
|
1807
|
+
}
|
|
1808
|
+
attach(p) {
|
|
1809
|
+
this.root = document.createElement("div"), this.root.className = "-cbwsdk-snackbar-root", p.appendChild(this.root), this.render();
|
|
1810
|
+
}
|
|
1811
|
+
presentItem(p) {
|
|
1812
|
+
const b = this.nextItemKey++;
|
|
1813
|
+
return this.items.set(b, p), this.render(), () => {
|
|
1814
|
+
this.items.delete(b), this.render();
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
clear() {
|
|
1818
|
+
this.items.clear(), this.render();
|
|
1819
|
+
}
|
|
1820
|
+
render() {
|
|
1821
|
+
this.root && (0, r.render)((0, r.h)(
|
|
1822
|
+
"div",
|
|
1823
|
+
null,
|
|
1824
|
+
(0, r.h)(n.SnackbarContainer, { darkMode: this.darkMode }, Array.from(this.items.entries()).map(([p, b]) => (0, r.h)(n.SnackbarInstance, Object.assign({}, b, { key: p }))))
|
|
1825
|
+
), this.root);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
n.Snackbar = l;
|
|
1829
|
+
const h = (d) => (0, r.h)(
|
|
1830
|
+
"div",
|
|
1831
|
+
{ class: (0, t.default)("-cbwsdk-snackbar-container") },
|
|
1832
|
+
(0, r.h)("style", null, a.default),
|
|
1833
|
+
(0, r.h)("div", { class: "-cbwsdk-snackbar" }, d.children)
|
|
1834
|
+
);
|
|
1835
|
+
n.SnackbarContainer = h;
|
|
1836
|
+
const m = ({ autoExpand: d, message: p, menuItems: b }) => {
|
|
1837
|
+
const [H, en] = (0, s.useState)(!0), [De, Qe] = (0, s.useState)(d ?? !1);
|
|
1838
|
+
(0, s.useEffect)(() => {
|
|
1839
|
+
const A = [
|
|
1840
|
+
window.setTimeout(() => {
|
|
1841
|
+
en(!1);
|
|
1842
|
+
}, 1),
|
|
1843
|
+
window.setTimeout(() => {
|
|
1844
|
+
Qe(!0);
|
|
1845
|
+
}, 1e4)
|
|
1846
|
+
];
|
|
1847
|
+
return () => {
|
|
1848
|
+
A.forEach(window.clearTimeout);
|
|
1849
|
+
};
|
|
1850
|
+
});
|
|
1851
|
+
const tn = () => {
|
|
1852
|
+
Qe(!De);
|
|
1853
|
+
};
|
|
1854
|
+
return (0, r.h)(
|
|
1855
|
+
"div",
|
|
1856
|
+
{ class: (0, t.default)("-cbwsdk-snackbar-instance", H && "-cbwsdk-snackbar-instance-hidden", De && "-cbwsdk-snackbar-instance-expanded") },
|
|
1857
|
+
(0, r.h)(
|
|
1858
|
+
"div",
|
|
1859
|
+
{ class: "-cbwsdk-snackbar-instance-header", onClick: tn },
|
|
1860
|
+
(0, r.h)("img", { src: o, class: "-cbwsdk-snackbar-instance-header-cblogo" }),
|
|
1861
|
+
" ",
|
|
1862
|
+
(0, r.h)("div", { class: "-cbwsdk-snackbar-instance-header-message" }, p),
|
|
1863
|
+
(0, r.h)(
|
|
1864
|
+
"div",
|
|
1865
|
+
{ class: "-gear-container" },
|
|
1866
|
+
!De && (0, r.h)(
|
|
1867
|
+
"svg",
|
|
1868
|
+
{ width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
1869
|
+
(0, r.h)("circle", { cx: "12", cy: "12", r: "12", fill: "#F5F7F8" })
|
|
1870
|
+
),
|
|
1871
|
+
(0, r.h)("img", { src: c, class: "-gear-icon", title: "Expand" })
|
|
1872
|
+
)
|
|
1873
|
+
),
|
|
1874
|
+
b && b.length > 0 && (0, r.h)("div", { class: "-cbwsdk-snackbar-instance-menu" }, b.map((A, nn) => (0, r.h)(
|
|
1875
|
+
"div",
|
|
1876
|
+
{ class: (0, t.default)("-cbwsdk-snackbar-instance-menu-item", A.isRed && "-cbwsdk-snackbar-instance-menu-item-is-red"), onClick: A.onClick, key: nn },
|
|
1877
|
+
(0, r.h)(
|
|
1878
|
+
"svg",
|
|
1879
|
+
{ width: A.svgWidth, height: A.svgHeight, viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
1880
|
+
(0, r.h)("path", { "fill-rule": A.defaultFillRule, "clip-rule": A.defaultClipRule, d: A.path, fill: "#AAAAAA" })
|
|
1881
|
+
),
|
|
1882
|
+
(0, r.h)("span", { class: (0, t.default)("-cbwsdk-snackbar-instance-menu-item-info", A.isRed && "-cbwsdk-snackbar-instance-menu-item-info-is-red") }, A.info)
|
|
1883
|
+
)))
|
|
1884
|
+
);
|
|
1885
|
+
};
|
|
1886
|
+
n.SnackbarInstance = m;
|
|
1887
|
+
})(Ge);
|
|
1888
|
+
Object.defineProperty(Pe, "__esModule", { value: !0 });
|
|
1889
|
+
Pe.WalletLinkRelayUI = void 0;
|
|
1890
|
+
const kr = oe, Ir = Ge;
|
|
1891
|
+
class Mr {
|
|
1892
|
+
constructor() {
|
|
1893
|
+
this.attached = !1, this.snackbar = new Ir.Snackbar();
|
|
1894
|
+
}
|
|
1895
|
+
attach() {
|
|
1896
|
+
if (this.attached)
|
|
1897
|
+
throw new Error("Coinbase Wallet SDK UI is already attached");
|
|
1898
|
+
const e = document.documentElement, t = document.createElement("div");
|
|
1899
|
+
t.className = "-cbwsdk-css-reset", e.appendChild(t), this.snackbar.attach(t), this.attached = !0, (0, kr.injectCssReset)();
|
|
1900
|
+
}
|
|
1901
|
+
showConnecting(e) {
|
|
1902
|
+
let t;
|
|
1903
|
+
return e.isUnlinkedErrorState ? t = {
|
|
1904
|
+
autoExpand: !0,
|
|
1905
|
+
message: "Connection lost",
|
|
1906
|
+
menuItems: [
|
|
1907
|
+
{
|
|
1908
|
+
isRed: !1,
|
|
1909
|
+
info: "Reset connection",
|
|
1910
|
+
svgWidth: "10",
|
|
1911
|
+
svgHeight: "11",
|
|
1912
|
+
path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",
|
|
1913
|
+
defaultFillRule: "evenodd",
|
|
1914
|
+
defaultClipRule: "evenodd",
|
|
1915
|
+
onClick: e.onResetConnection
|
|
1916
|
+
}
|
|
1917
|
+
]
|
|
1918
|
+
} : t = {
|
|
1919
|
+
message: "Confirm on phone",
|
|
1920
|
+
menuItems: [
|
|
1921
|
+
{
|
|
1922
|
+
isRed: !0,
|
|
1923
|
+
info: "Cancel transaction",
|
|
1924
|
+
svgWidth: "11",
|
|
1925
|
+
svgHeight: "11",
|
|
1926
|
+
path: "M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",
|
|
1927
|
+
defaultFillRule: "inherit",
|
|
1928
|
+
defaultClipRule: "inherit",
|
|
1929
|
+
onClick: e.onCancel
|
|
1930
|
+
},
|
|
1931
|
+
{
|
|
1932
|
+
isRed: !1,
|
|
1933
|
+
info: "Reset connection",
|
|
1934
|
+
svgWidth: "10",
|
|
1935
|
+
svgHeight: "11",
|
|
1936
|
+
path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",
|
|
1937
|
+
defaultFillRule: "evenodd",
|
|
1938
|
+
defaultClipRule: "evenodd",
|
|
1939
|
+
onClick: e.onResetConnection
|
|
1940
|
+
}
|
|
1941
|
+
]
|
|
1942
|
+
}, this.snackbar.presentItem(t);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
Pe.WalletLinkRelayUI = Mr;
|
|
1946
|
+
var Ne = {}, Te = {}, Je = {};
|
|
1947
|
+
Object.defineProperty(Je, "__esModule", { value: !0 });
|
|
1948
|
+
Je.default = ".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";
|
|
1949
|
+
var Gt = L && L.__importDefault || function(n) {
|
|
1950
|
+
return n && n.__esModule ? n : { default: n };
|
|
1951
|
+
};
|
|
1952
|
+
Object.defineProperty(Te, "__esModule", { value: !0 });
|
|
1953
|
+
Te.RedirectDialog = void 0;
|
|
1954
|
+
const Lr = Gt(_t), P = Et, Ar = oe, Rr = Ge, xr = C, Pr = Gt(Je);
|
|
1955
|
+
class Nr {
|
|
1956
|
+
constructor() {
|
|
1957
|
+
this.root = null, this.darkMode = (0, xr.isDarkMode)();
|
|
1958
|
+
}
|
|
1959
|
+
attach() {
|
|
1960
|
+
const e = document.documentElement;
|
|
1961
|
+
this.root = document.createElement("div"), this.root.className = "-cbwsdk-css-reset", e.appendChild(this.root), (0, Ar.injectCssReset)();
|
|
1962
|
+
}
|
|
1963
|
+
present(e) {
|
|
1964
|
+
this.render(e);
|
|
1965
|
+
}
|
|
1966
|
+
clear() {
|
|
1967
|
+
this.render(null);
|
|
1968
|
+
}
|
|
1969
|
+
render(e) {
|
|
1970
|
+
this.root && ((0, P.render)(null, this.root), e && (0, P.render)((0, P.h)(Tr, Object.assign({}, e, { onDismiss: () => {
|
|
1971
|
+
this.clear();
|
|
1972
|
+
}, darkMode: this.darkMode })), this.root));
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
Te.RedirectDialog = Nr;
|
|
1976
|
+
const Tr = ({ title: n, buttonText: e, darkMode: t, onButtonClick: r, onDismiss: s }) => {
|
|
1977
|
+
const i = t ? "dark" : "light";
|
|
1978
|
+
return (0, P.h)(
|
|
1979
|
+
Rr.SnackbarContainer,
|
|
1980
|
+
{ darkMode: t },
|
|
1981
|
+
(0, P.h)(
|
|
1982
|
+
"div",
|
|
1983
|
+
{ class: "-cbwsdk-redirect-dialog" },
|
|
1984
|
+
(0, P.h)("style", null, Pr.default),
|
|
1985
|
+
(0, P.h)("div", { class: "-cbwsdk-redirect-dialog-backdrop", onClick: s }),
|
|
1986
|
+
(0, P.h)(
|
|
1987
|
+
"div",
|
|
1988
|
+
{ class: (0, Lr.default)("-cbwsdk-redirect-dialog-box", i) },
|
|
1989
|
+
(0, P.h)("p", null, n),
|
|
1990
|
+
(0, P.h)("button", { onClick: r }, e)
|
|
1991
|
+
)
|
|
1992
|
+
)
|
|
1993
|
+
);
|
|
1994
|
+
};
|
|
1995
|
+
var j = {};
|
|
1996
|
+
Object.defineProperty(j, "__esModule", { value: !0 });
|
|
1997
|
+
j.CBW_MOBILE_DEEPLINK_URL = j.WALLETLINK_URL = j.CB_KEYS_URL = void 0;
|
|
1998
|
+
j.CB_KEYS_URL = "https://keys.coinbase.com/connect";
|
|
1999
|
+
j.WALLETLINK_URL = "https://www.walletlink.org";
|
|
2000
|
+
j.CBW_MOBILE_DEEPLINK_URL = "https://go.cb-w.com/walletlink";
|
|
2001
|
+
Object.defineProperty(Ne, "__esModule", { value: !0 });
|
|
2002
|
+
Ne.WLMobileRelayUI = void 0;
|
|
2003
|
+
const jr = Te, Or = C, Dr = j;
|
|
2004
|
+
class Wr {
|
|
2005
|
+
constructor() {
|
|
2006
|
+
this.attached = !1, this.redirectDialog = new jr.RedirectDialog();
|
|
2007
|
+
}
|
|
2008
|
+
attach() {
|
|
2009
|
+
if (this.attached)
|
|
2010
|
+
throw new Error("Coinbase Wallet SDK UI is already attached");
|
|
2011
|
+
this.redirectDialog.attach(), this.attached = !0;
|
|
2012
|
+
}
|
|
2013
|
+
redirectToCoinbaseWallet(e) {
|
|
2014
|
+
const t = new URL(Dr.CBW_MOBILE_DEEPLINK_URL);
|
|
2015
|
+
t.searchParams.append("redirect_url", (0, Or.getLocation)().href), e && t.searchParams.append("wl_url", e);
|
|
2016
|
+
const r = document.createElement("a");
|
|
2017
|
+
r.target = "cbw-opener", r.href = t.href, r.rel = "noreferrer noopener", r.click();
|
|
2018
|
+
}
|
|
2019
|
+
openCoinbaseWalletDeeplink(e) {
|
|
2020
|
+
this.redirectDialog.present({
|
|
2021
|
+
title: "Redirecting to Coinbase Wallet...",
|
|
2022
|
+
buttonText: "Open",
|
|
2023
|
+
onButtonClick: () => {
|
|
2024
|
+
this.redirectToCoinbaseWallet(e);
|
|
2025
|
+
}
|
|
2026
|
+
}), setTimeout(() => {
|
|
2027
|
+
this.redirectToCoinbaseWallet(e);
|
|
2028
|
+
}, 99);
|
|
2029
|
+
}
|
|
2030
|
+
showConnecting(e) {
|
|
2031
|
+
return () => {
|
|
2032
|
+
this.redirectDialog.clear();
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
Ne.WLMobileRelayUI = Wr;
|
|
2037
|
+
Object.defineProperty(Me, "__esModule", { value: !0 });
|
|
2038
|
+
Me.WalletLinkRelay = void 0;
|
|
2039
|
+
const Ur = Le, Br = T, Hr = ae, Ke = xe, z = X, Kr = C, qr = Pe, ut = Ne, $r = O, y = u, Fr = D;
|
|
2040
|
+
class U {
|
|
2041
|
+
constructor(e) {
|
|
2042
|
+
this.accountsCallback = null, this.chainCallbackParams = { chainId: "", jsonRpcUrl: "" }, this.chainCallback = null, this.dappDefaultChain = 1, this.isMobileWeb = (0, Kr.isMobileWeb)(), this.appName = "", this.appLogoUrl = null, this.linkedUpdated = (i) => {
|
|
2043
|
+
this.isLinked = i;
|
|
2044
|
+
const a = this.storage.getItem(Br.LOCAL_STORAGE_ADDRESSES_KEY);
|
|
2045
|
+
if (i && (this._session.linked = i), this.isUnlinkedErrorState = !1, a) {
|
|
2046
|
+
const o = a.split(" "), c = this.storage.getItem("IsStandaloneSigning") === "true";
|
|
2047
|
+
o[0] !== "" && !i && this._session.linked && !c && (this.isUnlinkedErrorState = !0);
|
|
2048
|
+
}
|
|
2049
|
+
}, this.metadataUpdated = (i, a) => {
|
|
2050
|
+
this.storage.setItem(i, a);
|
|
2051
|
+
}, this.chainUpdated = (i, a) => {
|
|
2052
|
+
this.chainCallbackParams.chainId === i && this.chainCallbackParams.jsonRpcUrl === a || (this.chainCallbackParams = {
|
|
2053
|
+
chainId: i,
|
|
2054
|
+
jsonRpcUrl: a
|
|
2055
|
+
}, this.chainCallback && this.chainCallback(i, a));
|
|
2056
|
+
}, this.accountUpdated = (i) => {
|
|
2057
|
+
this.accountsCallback && this.accountsCallback([i]), U.accountRequestCallbackIds.size > 0 && (Array.from(U.accountRequestCallbackIds.values()).forEach((a) => {
|
|
2058
|
+
const o = {
|
|
2059
|
+
type: "WEB3_RESPONSE",
|
|
2060
|
+
id: a,
|
|
2061
|
+
response: {
|
|
2062
|
+
method: "requestEthereumAccounts",
|
|
2063
|
+
result: [i]
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
this.invokeCallback(Object.assign(Object.assign({}, o), { id: a }));
|
|
2067
|
+
}), U.accountRequestCallbackIds.clear());
|
|
2068
|
+
}, this.resetAndReload = this.resetAndReload.bind(this), this.linkAPIUrl = e.linkAPIUrl, this.storage = e.storage;
|
|
2069
|
+
const { session: t, ui: r, connection: s } = this.subscribe();
|
|
2070
|
+
this._session = t, this.connection = s, this.relayEventManager = new Hr.RelayEventManager(), this.ui = r;
|
|
2071
|
+
}
|
|
2072
|
+
subscribe() {
|
|
2073
|
+
const e = Ke.WalletLinkSession.load(this.storage) || new Ke.WalletLinkSession(this.storage).save(), { linkAPIUrl: t } = this, r = new Ur.WalletLinkConnection({
|
|
2074
|
+
session: e,
|
|
2075
|
+
linkAPIUrl: t,
|
|
2076
|
+
listener: this
|
|
2077
|
+
}), s = this.isMobileWeb ? new ut.WLMobileRelayUI() : new qr.WalletLinkRelayUI();
|
|
2078
|
+
return r.connect(), { session: e, ui: s, connection: r };
|
|
2079
|
+
}
|
|
2080
|
+
attachUI() {
|
|
2081
|
+
this.ui.attach();
|
|
2082
|
+
}
|
|
2083
|
+
resetAndReload() {
|
|
2084
|
+
Promise.race([
|
|
2085
|
+
this.connection.setSessionMetadata("__destroyed", "1"),
|
|
2086
|
+
new Promise((e) => setTimeout(() => e(null), 1e3))
|
|
2087
|
+
]).then(() => {
|
|
2088
|
+
this.connection.destroy();
|
|
2089
|
+
const e = Ke.WalletLinkSession.load(this.storage);
|
|
2090
|
+
(e == null ? void 0 : e.id) === this._session.id && Fr.ScopedLocalStorage.clearAll(), document.location.reload();
|
|
2091
|
+
}).catch((e) => {
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
setAppInfo(e, t) {
|
|
2095
|
+
this.appName = e, this.appLogoUrl = t;
|
|
2096
|
+
}
|
|
2097
|
+
getStorageItem(e) {
|
|
2098
|
+
return this.storage.getItem(e);
|
|
2099
|
+
}
|
|
2100
|
+
setStorageItem(e, t) {
|
|
2101
|
+
this.storage.setItem(e, t);
|
|
2102
|
+
}
|
|
2103
|
+
signEthereumMessage(e, t, r, s) {
|
|
2104
|
+
return this.sendRequest({
|
|
2105
|
+
method: "signEthereumMessage",
|
|
2106
|
+
params: {
|
|
2107
|
+
message: (0, y.hexStringFromBuffer)(e, !0),
|
|
2108
|
+
address: t,
|
|
2109
|
+
addPrefix: r,
|
|
2110
|
+
typedDataJson: s || null
|
|
2111
|
+
}
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
ethereumAddressFromSignedMessage(e, t, r) {
|
|
2115
|
+
return this.sendRequest({
|
|
2116
|
+
method: "ethereumAddressFromSignedMessage",
|
|
2117
|
+
params: {
|
|
2118
|
+
message: (0, y.hexStringFromBuffer)(e, !0),
|
|
2119
|
+
signature: (0, y.hexStringFromBuffer)(t, !0),
|
|
2120
|
+
addPrefix: r
|
|
2121
|
+
}
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
signEthereumTransaction(e) {
|
|
2125
|
+
return this.sendRequest({
|
|
2126
|
+
method: "signEthereumTransaction",
|
|
2127
|
+
params: {
|
|
2128
|
+
fromAddress: e.fromAddress,
|
|
2129
|
+
toAddress: e.toAddress,
|
|
2130
|
+
weiValue: (0, y.bigIntStringFromBigInt)(e.weiValue),
|
|
2131
|
+
data: (0, y.hexStringFromBuffer)(e.data, !0),
|
|
2132
|
+
nonce: e.nonce,
|
|
2133
|
+
gasPriceInWei: e.gasPriceInWei ? (0, y.bigIntStringFromBigInt)(e.gasPriceInWei) : null,
|
|
2134
|
+
maxFeePerGas: e.gasPriceInWei ? (0, y.bigIntStringFromBigInt)(e.gasPriceInWei) : null,
|
|
2135
|
+
maxPriorityFeePerGas: e.gasPriceInWei ? (0, y.bigIntStringFromBigInt)(e.gasPriceInWei) : null,
|
|
2136
|
+
gasLimit: e.gasLimit ? (0, y.bigIntStringFromBigInt)(e.gasLimit) : null,
|
|
2137
|
+
chainId: e.chainId,
|
|
2138
|
+
shouldSubmit: !1
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
signAndSubmitEthereumTransaction(e) {
|
|
2143
|
+
return this.sendRequest({
|
|
2144
|
+
method: "signEthereumTransaction",
|
|
2145
|
+
params: {
|
|
2146
|
+
fromAddress: e.fromAddress,
|
|
2147
|
+
toAddress: e.toAddress,
|
|
2148
|
+
weiValue: (0, y.bigIntStringFromBigInt)(e.weiValue),
|
|
2149
|
+
data: (0, y.hexStringFromBuffer)(e.data, !0),
|
|
2150
|
+
nonce: e.nonce,
|
|
2151
|
+
gasPriceInWei: e.gasPriceInWei ? (0, y.bigIntStringFromBigInt)(e.gasPriceInWei) : null,
|
|
2152
|
+
maxFeePerGas: e.maxFeePerGas ? (0, y.bigIntStringFromBigInt)(e.maxFeePerGas) : null,
|
|
2153
|
+
maxPriorityFeePerGas: e.maxPriorityFeePerGas ? (0, y.bigIntStringFromBigInt)(e.maxPriorityFeePerGas) : null,
|
|
2154
|
+
gasLimit: e.gasLimit ? (0, y.bigIntStringFromBigInt)(e.gasLimit) : null,
|
|
2155
|
+
chainId: e.chainId,
|
|
2156
|
+
shouldSubmit: !0
|
|
2157
|
+
}
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
submitEthereumTransaction(e, t) {
|
|
2161
|
+
return this.sendRequest({
|
|
2162
|
+
method: "submitEthereumTransaction",
|
|
2163
|
+
params: {
|
|
2164
|
+
signedTransaction: (0, y.hexStringFromBuffer)(e, !0),
|
|
2165
|
+
chainId: t
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
scanQRCode(e) {
|
|
2170
|
+
return this.sendRequest({
|
|
2171
|
+
method: "scanQRCode",
|
|
2172
|
+
params: {
|
|
2173
|
+
regExp: e
|
|
2174
|
+
}
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
getWalletLinkSession() {
|
|
2178
|
+
return this._session;
|
|
2179
|
+
}
|
|
2180
|
+
genericRequest(e, t) {
|
|
2181
|
+
return this.sendRequest({
|
|
2182
|
+
method: "generic",
|
|
2183
|
+
params: {
|
|
2184
|
+
action: t,
|
|
2185
|
+
data: e
|
|
2186
|
+
}
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
sendGenericMessage(e) {
|
|
2190
|
+
return this.sendRequest(e);
|
|
2191
|
+
}
|
|
2192
|
+
sendRequest(e) {
|
|
2193
|
+
let t = null;
|
|
2194
|
+
const r = (0, y.randomBytesHex)(8), s = (i) => {
|
|
2195
|
+
this.publishWeb3RequestCanceledEvent(r), this.handleErrorResponse(r, e.method, i), t == null || t();
|
|
2196
|
+
};
|
|
2197
|
+
return new Promise((i, a) => {
|
|
2198
|
+
t = this.ui.showConnecting({
|
|
2199
|
+
isUnlinkedErrorState: this.isUnlinkedErrorState,
|
|
2200
|
+
onCancel: s,
|
|
2201
|
+
onResetConnection: this.resetAndReload
|
|
2202
|
+
// eslint-disable-line @typescript-eslint/unbound-method
|
|
2203
|
+
}), this.relayEventManager.callbacks.set(r, (o) => {
|
|
2204
|
+
if (t == null || t(), (0, z.isErrorResponse)(o))
|
|
2205
|
+
return a(new Error(o.errorMessage));
|
|
2206
|
+
i(o);
|
|
2207
|
+
}), this.publishWeb3RequestEvent(r, e);
|
|
2208
|
+
});
|
|
2209
|
+
}
|
|
2210
|
+
setAccountsCallback(e) {
|
|
2211
|
+
this.accountsCallback = e;
|
|
2212
|
+
}
|
|
2213
|
+
setChainCallback(e) {
|
|
2214
|
+
this.chainCallback = e;
|
|
2215
|
+
}
|
|
2216
|
+
setDappDefaultChainCallback(e) {
|
|
2217
|
+
this.dappDefaultChain = e;
|
|
2218
|
+
}
|
|
2219
|
+
publishWeb3RequestEvent(e, t) {
|
|
2220
|
+
const r = { type: "WEB3_REQUEST", id: e, request: t };
|
|
2221
|
+
this.publishEvent("Web3Request", r, !0).then((s) => {
|
|
2222
|
+
}).catch((s) => {
|
|
2223
|
+
this.handleWeb3ResponseMessage({
|
|
2224
|
+
type: "WEB3_RESPONSE",
|
|
2225
|
+
id: r.id,
|
|
2226
|
+
response: {
|
|
2227
|
+
method: t.method,
|
|
2228
|
+
errorMessage: s.message
|
|
2229
|
+
}
|
|
2230
|
+
});
|
|
2231
|
+
}), this.isMobileWeb && this.openCoinbaseWalletDeeplink(t.method);
|
|
2232
|
+
}
|
|
2233
|
+
// copied from MobileRelay
|
|
2234
|
+
openCoinbaseWalletDeeplink(e) {
|
|
2235
|
+
if (this.ui instanceof ut.WLMobileRelayUI)
|
|
2236
|
+
switch (e) {
|
|
2237
|
+
case "requestEthereumAccounts":
|
|
2238
|
+
case "switchEthereumChain":
|
|
2239
|
+
return;
|
|
2240
|
+
default:
|
|
2241
|
+
window.addEventListener("blur", () => {
|
|
2242
|
+
window.addEventListener("focus", () => {
|
|
2243
|
+
this.connection.checkUnseenEvents();
|
|
2244
|
+
}, { once: !0 });
|
|
2245
|
+
}, { once: !0 }), this.ui.openCoinbaseWalletDeeplink();
|
|
2246
|
+
break;
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
publishWeb3RequestCanceledEvent(e) {
|
|
2250
|
+
const t = {
|
|
2251
|
+
type: "WEB3_REQUEST_CANCELED",
|
|
2252
|
+
id: e
|
|
2253
|
+
};
|
|
2254
|
+
this.publishEvent("Web3RequestCanceled", t, !1).then();
|
|
2255
|
+
}
|
|
2256
|
+
publishEvent(e, t, r) {
|
|
2257
|
+
return this.connection.publishEvent(e, t, r);
|
|
2258
|
+
}
|
|
2259
|
+
handleWeb3ResponseMessage(e) {
|
|
2260
|
+
const { response: t } = e;
|
|
2261
|
+
if (t.method === "requestEthereumAccounts") {
|
|
2262
|
+
U.accountRequestCallbackIds.forEach((r) => this.invokeCallback(Object.assign(Object.assign({}, e), { id: r }))), U.accountRequestCallbackIds.clear();
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
this.invokeCallback(e);
|
|
2266
|
+
}
|
|
2267
|
+
handleErrorResponse(e, t, r) {
|
|
2268
|
+
var s;
|
|
2269
|
+
const i = (s = r == null ? void 0 : r.message) !== null && s !== void 0 ? s : "Unspecified error message.";
|
|
2270
|
+
this.handleWeb3ResponseMessage({
|
|
2271
|
+
type: "WEB3_RESPONSE",
|
|
2272
|
+
id: e,
|
|
2273
|
+
response: {
|
|
2274
|
+
method: t,
|
|
2275
|
+
errorMessage: i
|
|
2276
|
+
}
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
invokeCallback(e) {
|
|
2280
|
+
const t = this.relayEventManager.callbacks.get(e.id);
|
|
2281
|
+
t && (t(e.response), this.relayEventManager.callbacks.delete(e.id));
|
|
2282
|
+
}
|
|
2283
|
+
requestEthereumAccounts() {
|
|
2284
|
+
const e = {
|
|
2285
|
+
method: "requestEthereumAccounts",
|
|
2286
|
+
params: {
|
|
2287
|
+
appName: this.appName,
|
|
2288
|
+
appLogoUrl: this.appLogoUrl || null
|
|
2289
|
+
}
|
|
2290
|
+
}, t = (0, y.randomBytesHex)(8);
|
|
2291
|
+
return new Promise((r, s) => {
|
|
2292
|
+
this.relayEventManager.callbacks.set(t, (i) => {
|
|
2293
|
+
if ((0, z.isErrorResponse)(i))
|
|
2294
|
+
return s(new Error(i.errorMessage));
|
|
2295
|
+
r(i);
|
|
2296
|
+
}), U.accountRequestCallbackIds.add(t), this.publishWeb3RequestEvent(t, e);
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
watchAsset(e, t, r, s, i, a) {
|
|
2300
|
+
const o = {
|
|
2301
|
+
method: "watchAsset",
|
|
2302
|
+
params: {
|
|
2303
|
+
type: e,
|
|
2304
|
+
options: {
|
|
2305
|
+
address: t,
|
|
2306
|
+
symbol: r,
|
|
2307
|
+
decimals: s,
|
|
2308
|
+
image: i
|
|
2309
|
+
},
|
|
2310
|
+
chainId: a
|
|
2311
|
+
}
|
|
2312
|
+
};
|
|
2313
|
+
let c = null;
|
|
2314
|
+
const l = (0, y.randomBytesHex)(8), h = (m) => {
|
|
2315
|
+
this.publishWeb3RequestCanceledEvent(l), this.handleErrorResponse(l, o.method, m), c == null || c();
|
|
2316
|
+
};
|
|
2317
|
+
return c = this.ui.showConnecting({
|
|
2318
|
+
isUnlinkedErrorState: this.isUnlinkedErrorState,
|
|
2319
|
+
onCancel: h,
|
|
2320
|
+
onResetConnection: this.resetAndReload
|
|
2321
|
+
// eslint-disable-line @typescript-eslint/unbound-method
|
|
2322
|
+
}), new Promise((m, d) => {
|
|
2323
|
+
this.relayEventManager.callbacks.set(l, (p) => {
|
|
2324
|
+
if (c == null || c(), (0, z.isErrorResponse)(p))
|
|
2325
|
+
return d(new Error(p.errorMessage));
|
|
2326
|
+
m(p);
|
|
2327
|
+
}), this.publishWeb3RequestEvent(l, o);
|
|
2328
|
+
});
|
|
2329
|
+
}
|
|
2330
|
+
addEthereumChain(e, t, r, s, i, a) {
|
|
2331
|
+
const o = {
|
|
2332
|
+
method: "addEthereumChain",
|
|
2333
|
+
params: {
|
|
2334
|
+
chainId: e,
|
|
2335
|
+
rpcUrls: t,
|
|
2336
|
+
blockExplorerUrls: s,
|
|
2337
|
+
chainName: i,
|
|
2338
|
+
iconUrls: r,
|
|
2339
|
+
nativeCurrency: a
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2342
|
+
let c = null;
|
|
2343
|
+
const l = (0, y.randomBytesHex)(8), h = (m) => {
|
|
2344
|
+
this.publishWeb3RequestCanceledEvent(l), this.handleErrorResponse(l, o.method, m), c == null || c();
|
|
2345
|
+
};
|
|
2346
|
+
return c = this.ui.showConnecting({
|
|
2347
|
+
isUnlinkedErrorState: this.isUnlinkedErrorState,
|
|
2348
|
+
onCancel: h,
|
|
2349
|
+
onResetConnection: this.resetAndReload
|
|
2350
|
+
// eslint-disable-line @typescript-eslint/unbound-method
|
|
2351
|
+
}), new Promise((m, d) => {
|
|
2352
|
+
this.relayEventManager.callbacks.set(l, (p) => {
|
|
2353
|
+
if (c == null || c(), (0, z.isErrorResponse)(p))
|
|
2354
|
+
return d(new Error(p.errorMessage));
|
|
2355
|
+
m(p);
|
|
2356
|
+
}), this.publishWeb3RequestEvent(l, o);
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
switchEthereumChain(e, t) {
|
|
2360
|
+
const r = {
|
|
2361
|
+
method: "switchEthereumChain",
|
|
2362
|
+
params: Object.assign({ chainId: e }, { address: t })
|
|
2363
|
+
}, s = (0, y.randomBytesHex)(8);
|
|
2364
|
+
return new Promise((i, a) => {
|
|
2365
|
+
this.relayEventManager.callbacks.set(s, (o) => {
|
|
2366
|
+
if ((0, z.isErrorResponse)(o) && o.errorCode)
|
|
2367
|
+
return a($r.standardErrors.provider.custom({
|
|
2368
|
+
code: o.errorCode,
|
|
2369
|
+
message: "Unrecognized chain ID. Try adding the chain using addEthereumChain first."
|
|
2370
|
+
}));
|
|
2371
|
+
if ((0, z.isErrorResponse)(o))
|
|
2372
|
+
return a(new Error(o.errorMessage));
|
|
2373
|
+
i(o);
|
|
2374
|
+
}), this.publishWeb3RequestEvent(s, r);
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
Me.WalletLinkRelay = U;
|
|
2379
|
+
U.accountRequestCallbackIds = /* @__PURE__ */ new Set();
|
|
2380
|
+
var Vr = L && L.__importDefault || function(n) {
|
|
2381
|
+
return n && n.__esModule ? n : { default: n };
|
|
2382
|
+
};
|
|
2383
|
+
Object.defineProperty(ke, "__esModule", { value: !0 });
|
|
2384
|
+
ke.WalletLinkSigner = void 0;
|
|
2385
|
+
const qe = Vr(ir), ht = T, zr = ae, W = X, Zr = Me, gt = j, v = O, g = u, Gr = D, $e = "DefaultChainId", pt = "DefaultJsonRpcUrl";
|
|
2386
|
+
class Yr {
|
|
2387
|
+
constructor(e) {
|
|
2388
|
+
var t, r;
|
|
2389
|
+
this._relay = null, this._addresses = [], this.hasMadeFirstChainChangedEmission = !1;
|
|
2390
|
+
const { appName: s, appLogoUrl: i } = e.metadata;
|
|
2391
|
+
this._appName = s, this._appLogoUrl = i, this._storage = new Gr.ScopedLocalStorage("walletlink", gt.WALLETLINK_URL), this.updateListener = e.updateListener, this._relayEventManager = new zr.RelayEventManager(), this._jsonRpcUrlFromOpts = "";
|
|
2392
|
+
const a = this._storage.getItem(ht.LOCAL_STORAGE_ADDRESSES_KEY);
|
|
2393
|
+
if (a) {
|
|
2394
|
+
const c = a.split(" ");
|
|
2395
|
+
c[0] !== "" && (this._addresses = c.map((l) => (0, g.ensureAddressString)(l)), (t = this.updateListener) === null || t === void 0 || t.onAccountsUpdate({
|
|
2396
|
+
accounts: this._addresses,
|
|
2397
|
+
source: "storage"
|
|
2398
|
+
}));
|
|
2399
|
+
}
|
|
2400
|
+
this._storage.getItem($e) && ((r = this.updateListener) === null || r === void 0 || r.onChainUpdate({
|
|
2401
|
+
chain: {
|
|
2402
|
+
id: this.getChainId(),
|
|
2403
|
+
rpcUrl: this.jsonRpcUrl
|
|
2404
|
+
},
|
|
2405
|
+
source: "storage"
|
|
2406
|
+
}), this.hasMadeFirstChainChangedEmission = !0), this.initializeRelay();
|
|
2407
|
+
}
|
|
2408
|
+
getSession() {
|
|
2409
|
+
const e = this.initializeRelay(), { id: t, secret: r } = e.getWalletLinkSession();
|
|
2410
|
+
return { id: t, secret: r };
|
|
2411
|
+
}
|
|
2412
|
+
async handshake() {
|
|
2413
|
+
return await this.request({ method: "eth_requestAccounts" });
|
|
2414
|
+
}
|
|
2415
|
+
get selectedAddress() {
|
|
2416
|
+
return this._addresses[0] || void 0;
|
|
2417
|
+
}
|
|
2418
|
+
get jsonRpcUrl() {
|
|
2419
|
+
var e;
|
|
2420
|
+
return (e = this._storage.getItem(pt)) !== null && e !== void 0 ? e : this._jsonRpcUrlFromOpts;
|
|
2421
|
+
}
|
|
2422
|
+
set jsonRpcUrl(e) {
|
|
2423
|
+
this._storage.setItem(pt, e);
|
|
2424
|
+
}
|
|
2425
|
+
updateProviderInfo(e, t) {
|
|
2426
|
+
var r;
|
|
2427
|
+
this.jsonRpcUrl = e;
|
|
2428
|
+
const s = this.getChainId();
|
|
2429
|
+
this._storage.setItem($e, t.toString(10)), ((0, g.ensureIntNumber)(t) !== s || !this.hasMadeFirstChainChangedEmission) && ((r = this.updateListener) === null || r === void 0 || r.onChainUpdate({
|
|
2430
|
+
chain: { id: t, rpcUrl: e },
|
|
2431
|
+
source: "wallet"
|
|
2432
|
+
}), this.hasMadeFirstChainChangedEmission = !0);
|
|
2433
|
+
}
|
|
2434
|
+
async watchAsset(e, t, r, s, i, a) {
|
|
2435
|
+
const c = await this.initializeRelay().watchAsset(e, t, r, s, i, a == null ? void 0 : a.toString());
|
|
2436
|
+
return (0, W.isErrorResponse)(c) ? !1 : !!c.result;
|
|
2437
|
+
}
|
|
2438
|
+
async addEthereumChain(e, t, r, s, i, a) {
|
|
2439
|
+
var o, c;
|
|
2440
|
+
if ((0, g.ensureIntNumber)(e) === this.getChainId())
|
|
2441
|
+
return !1;
|
|
2442
|
+
const l = this.initializeRelay();
|
|
2443
|
+
this._isAuthorized() || await l.requestEthereumAccounts();
|
|
2444
|
+
const h = await l.addEthereumChain(e.toString(), t, i, r, s, a);
|
|
2445
|
+
return (0, W.isErrorResponse)(h) ? !1 : (((o = h.result) === null || o === void 0 ? void 0 : o.isApproved) === !0 && this.updateProviderInfo(t[0], e), ((c = h.result) === null || c === void 0 ? void 0 : c.isApproved) === !0);
|
|
2446
|
+
}
|
|
2447
|
+
async switchEthereumChain(e) {
|
|
2448
|
+
const r = await this.initializeRelay().switchEthereumChain(e.toString(10), this.selectedAddress || void 0);
|
|
2449
|
+
if ((0, W.isErrorResponse)(r)) {
|
|
2450
|
+
if (!r.errorCode)
|
|
2451
|
+
return;
|
|
2452
|
+
throw r.errorCode === v.standardErrorCodes.provider.unsupportedChain ? v.standardErrors.provider.unsupportedChain() : v.standardErrors.provider.custom({
|
|
2453
|
+
message: r.errorMessage,
|
|
2454
|
+
code: r.errorCode
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
const s = r.result;
|
|
2458
|
+
s.isApproved && s.rpcUrl.length > 0 && this.updateProviderInfo(s.rpcUrl, e);
|
|
2459
|
+
}
|
|
2460
|
+
async disconnect() {
|
|
2461
|
+
this._relay && this._relay.resetAndReload(), this._storage.clear();
|
|
2462
|
+
}
|
|
2463
|
+
async request(e) {
|
|
2464
|
+
try {
|
|
2465
|
+
return this._request(e).catch((t) => {
|
|
2466
|
+
throw t;
|
|
2467
|
+
});
|
|
2468
|
+
} catch (t) {
|
|
2469
|
+
return Promise.reject(t);
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
async _request(e) {
|
|
2473
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
2474
|
+
throw v.standardErrors.rpc.invalidRequest({
|
|
2475
|
+
message: "Expected a single, non-array, object argument.",
|
|
2476
|
+
data: e
|
|
2477
|
+
});
|
|
2478
|
+
const { method: t, params: r } = e;
|
|
2479
|
+
if (typeof t != "string" || t.length === 0)
|
|
2480
|
+
throw v.standardErrors.rpc.invalidRequest({
|
|
2481
|
+
message: "'args.method' must be a non-empty string.",
|
|
2482
|
+
data: e
|
|
2483
|
+
});
|
|
2484
|
+
if (r !== void 0 && !Array.isArray(r) && (typeof r != "object" || r === null))
|
|
2485
|
+
throw v.standardErrors.rpc.invalidRequest({
|
|
2486
|
+
message: "'args.params' must be an object or array if provided.",
|
|
2487
|
+
data: e
|
|
2488
|
+
});
|
|
2489
|
+
const s = r === void 0 ? [] : r, i = this._relayEventManager.makeRequestId();
|
|
2490
|
+
return (await this._sendRequestAsync({
|
|
2491
|
+
method: t,
|
|
2492
|
+
params: s,
|
|
2493
|
+
jsonrpc: "2.0",
|
|
2494
|
+
id: i
|
|
2495
|
+
})).result;
|
|
2496
|
+
}
|
|
2497
|
+
_setAddresses(e, t) {
|
|
2498
|
+
var r;
|
|
2499
|
+
if (!Array.isArray(e))
|
|
2500
|
+
throw new Error("addresses is not an array");
|
|
2501
|
+
const s = e.map((i) => (0, g.ensureAddressString)(i));
|
|
2502
|
+
JSON.stringify(s) !== JSON.stringify(this._addresses) && (this._addresses = s, (r = this.updateListener) === null || r === void 0 || r.onAccountsUpdate({
|
|
2503
|
+
accounts: s,
|
|
2504
|
+
source: "wallet"
|
|
2505
|
+
}), this._storage.setItem(ht.LOCAL_STORAGE_ADDRESSES_KEY, s.join(" ")));
|
|
2506
|
+
}
|
|
2507
|
+
_sendRequestAsync(e) {
|
|
2508
|
+
return new Promise((t, r) => {
|
|
2509
|
+
try {
|
|
2510
|
+
const s = this._handleSynchronousMethods(e);
|
|
2511
|
+
if (s !== void 0)
|
|
2512
|
+
return t({
|
|
2513
|
+
jsonrpc: "2.0",
|
|
2514
|
+
id: e.id,
|
|
2515
|
+
result: s
|
|
2516
|
+
});
|
|
2517
|
+
} catch (s) {
|
|
2518
|
+
return r(s);
|
|
2519
|
+
}
|
|
2520
|
+
this._handleAsynchronousMethods(e).then((s) => s && t(Object.assign(Object.assign({}, s), { id: e.id }))).catch((s) => r(s));
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
_handleSynchronousMethods(e) {
|
|
2524
|
+
const { method: t } = e;
|
|
2525
|
+
switch (t) {
|
|
2526
|
+
case "eth_accounts":
|
|
2527
|
+
return this._eth_accounts();
|
|
2528
|
+
case "eth_coinbase":
|
|
2529
|
+
return this._eth_coinbase();
|
|
2530
|
+
case "net_version":
|
|
2531
|
+
return this._net_version();
|
|
2532
|
+
case "eth_chainId":
|
|
2533
|
+
return this._eth_chainId();
|
|
2534
|
+
default:
|
|
2535
|
+
return;
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
async _handleAsynchronousMethods(e) {
|
|
2539
|
+
const { method: t } = e, r = e.params || [];
|
|
2540
|
+
switch (t) {
|
|
2541
|
+
case "eth_requestAccounts":
|
|
2542
|
+
return this._eth_requestAccounts();
|
|
2543
|
+
case "eth_sign":
|
|
2544
|
+
return this._eth_sign(r);
|
|
2545
|
+
case "eth_ecRecover":
|
|
2546
|
+
return this._eth_ecRecover(r);
|
|
2547
|
+
case "personal_sign":
|
|
2548
|
+
return this._personal_sign(r);
|
|
2549
|
+
case "personal_ecRecover":
|
|
2550
|
+
return this._personal_ecRecover(r);
|
|
2551
|
+
case "eth_signTransaction":
|
|
2552
|
+
return this._eth_signTransaction(r);
|
|
2553
|
+
case "eth_sendRawTransaction":
|
|
2554
|
+
return this._eth_sendRawTransaction(r);
|
|
2555
|
+
case "eth_sendTransaction":
|
|
2556
|
+
return this._eth_sendTransaction(r);
|
|
2557
|
+
case "eth_signTypedData_v1":
|
|
2558
|
+
return this._eth_signTypedData_v1(r);
|
|
2559
|
+
case "eth_signTypedData_v2":
|
|
2560
|
+
return this._throwUnsupportedMethodError();
|
|
2561
|
+
case "eth_signTypedData_v3":
|
|
2562
|
+
return this._eth_signTypedData_v3(r);
|
|
2563
|
+
case "eth_signTypedData_v4":
|
|
2564
|
+
case "eth_signTypedData":
|
|
2565
|
+
return this._eth_signTypedData_v4(r);
|
|
2566
|
+
case "wallet_addEthereumChain":
|
|
2567
|
+
return this._wallet_addEthereumChain(r);
|
|
2568
|
+
case "wallet_switchEthereumChain":
|
|
2569
|
+
return this._wallet_switchEthereumChain(r);
|
|
2570
|
+
case "wallet_watchAsset":
|
|
2571
|
+
return this._wallet_watchAsset(r);
|
|
2572
|
+
default:
|
|
2573
|
+
return this._throwUnsupportedMethodError();
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
_isKnownAddress(e) {
|
|
2577
|
+
try {
|
|
2578
|
+
const t = (0, g.ensureAddressString)(e);
|
|
2579
|
+
return this._addresses.map((s) => (0, g.ensureAddressString)(s)).includes(t);
|
|
2580
|
+
} catch {
|
|
2581
|
+
}
|
|
2582
|
+
return !1;
|
|
2583
|
+
}
|
|
2584
|
+
_ensureKnownAddress(e) {
|
|
2585
|
+
if (!this._isKnownAddress(e))
|
|
2586
|
+
throw new Error("Unknown Ethereum address");
|
|
2587
|
+
}
|
|
2588
|
+
_prepareTransactionParams(e) {
|
|
2589
|
+
const t = e.from ? (0, g.ensureAddressString)(e.from) : this.selectedAddress;
|
|
2590
|
+
if (!t)
|
|
2591
|
+
throw new Error("Ethereum address is unavailable");
|
|
2592
|
+
this._ensureKnownAddress(t);
|
|
2593
|
+
const r = e.to ? (0, g.ensureAddressString)(e.to) : null, s = e.value != null ? (0, g.ensureBigInt)(e.value) : BigInt(0), i = e.data ? (0, g.ensureBuffer)(e.data) : f.alloc(0), a = e.nonce != null ? (0, g.ensureIntNumber)(e.nonce) : null, o = e.gasPrice != null ? (0, g.ensureBigInt)(e.gasPrice) : null, c = e.maxFeePerGas != null ? (0, g.ensureBigInt)(e.maxFeePerGas) : null, l = e.maxPriorityFeePerGas != null ? (0, g.ensureBigInt)(e.maxPriorityFeePerGas) : null, h = e.gas != null ? (0, g.ensureBigInt)(e.gas) : null, m = e.chainId ? (0, g.ensureIntNumber)(e.chainId) : this.getChainId();
|
|
2594
|
+
return {
|
|
2595
|
+
fromAddress: t,
|
|
2596
|
+
toAddress: r,
|
|
2597
|
+
weiValue: s,
|
|
2598
|
+
data: i,
|
|
2599
|
+
nonce: a,
|
|
2600
|
+
gasPriceInWei: o,
|
|
2601
|
+
maxFeePerGas: c,
|
|
2602
|
+
maxPriorityFeePerGas: l,
|
|
2603
|
+
gasLimit: h,
|
|
2604
|
+
chainId: m
|
|
2605
|
+
};
|
|
2606
|
+
}
|
|
2607
|
+
_isAuthorized() {
|
|
2608
|
+
return this._addresses.length > 0;
|
|
2609
|
+
}
|
|
2610
|
+
_requireAuthorization() {
|
|
2611
|
+
if (!this._isAuthorized())
|
|
2612
|
+
throw v.standardErrors.provider.unauthorized({});
|
|
2613
|
+
}
|
|
2614
|
+
_throwUnsupportedMethodError() {
|
|
2615
|
+
throw v.standardErrors.provider.unsupportedMethod({});
|
|
2616
|
+
}
|
|
2617
|
+
async _signEthereumMessage(e, t, r, s) {
|
|
2618
|
+
this._ensureKnownAddress(t);
|
|
2619
|
+
try {
|
|
2620
|
+
const a = await this.initializeRelay().signEthereumMessage(e, t, r, s);
|
|
2621
|
+
if ((0, W.isErrorResponse)(a))
|
|
2622
|
+
throw new Error(a.errorMessage);
|
|
2623
|
+
return { jsonrpc: "2.0", id: 0, result: a.result };
|
|
2624
|
+
} catch (i) {
|
|
2625
|
+
throw typeof i.message == "string" && i.message.match(/(denied|rejected)/i) ? v.standardErrors.provider.userRejectedRequest("User denied message signature") : i;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
async _ethereumAddressFromSignedMessage(e, t, r) {
|
|
2629
|
+
const i = await this.initializeRelay().ethereumAddressFromSignedMessage(e, t, r);
|
|
2630
|
+
if ((0, W.isErrorResponse)(i))
|
|
2631
|
+
throw new Error(i.errorMessage);
|
|
2632
|
+
return { jsonrpc: "2.0", id: 0, result: i.result };
|
|
2633
|
+
}
|
|
2634
|
+
_eth_accounts() {
|
|
2635
|
+
return [...this._addresses];
|
|
2636
|
+
}
|
|
2637
|
+
_eth_coinbase() {
|
|
2638
|
+
return this.selectedAddress || null;
|
|
2639
|
+
}
|
|
2640
|
+
_net_version() {
|
|
2641
|
+
return this.getChainId().toString(10);
|
|
2642
|
+
}
|
|
2643
|
+
_eth_chainId() {
|
|
2644
|
+
return (0, g.hexStringFromIntNumber)(this.getChainId());
|
|
2645
|
+
}
|
|
2646
|
+
getChainId() {
|
|
2647
|
+
const e = this._storage.getItem($e);
|
|
2648
|
+
if (!e)
|
|
2649
|
+
return (0, g.ensureIntNumber)(1);
|
|
2650
|
+
const t = parseInt(e, 10);
|
|
2651
|
+
return (0, g.ensureIntNumber)(t);
|
|
2652
|
+
}
|
|
2653
|
+
async _eth_requestAccounts() {
|
|
2654
|
+
if (this._isAuthorized())
|
|
2655
|
+
return Promise.resolve({
|
|
2656
|
+
jsonrpc: "2.0",
|
|
2657
|
+
id: 0,
|
|
2658
|
+
result: this._addresses
|
|
2659
|
+
});
|
|
2660
|
+
let e;
|
|
2661
|
+
try {
|
|
2662
|
+
if (e = await this.initializeRelay().requestEthereumAccounts(), (0, W.isErrorResponse)(e))
|
|
2663
|
+
throw new Error(e.errorMessage);
|
|
2664
|
+
} catch (t) {
|
|
2665
|
+
throw typeof t.message == "string" && t.message.match(/(denied|rejected)/i) ? v.standardErrors.provider.userRejectedRequest("User denied account authorization") : t;
|
|
2666
|
+
}
|
|
2667
|
+
if (!e.result)
|
|
2668
|
+
throw new Error("accounts received is empty");
|
|
2669
|
+
return this._setAddresses(e.result), { jsonrpc: "2.0", id: 0, result: this._addresses };
|
|
2670
|
+
}
|
|
2671
|
+
_eth_sign(e) {
|
|
2672
|
+
this._requireAuthorization();
|
|
2673
|
+
const t = (0, g.ensureAddressString)(e[0]), r = (0, g.ensureBuffer)(e[1]);
|
|
2674
|
+
return this._signEthereumMessage(r, t, !1);
|
|
2675
|
+
}
|
|
2676
|
+
_eth_ecRecover(e) {
|
|
2677
|
+
const t = (0, g.ensureBuffer)(e[0]), r = (0, g.ensureBuffer)(e[1]);
|
|
2678
|
+
return this._ethereumAddressFromSignedMessage(t, r, !1);
|
|
2679
|
+
}
|
|
2680
|
+
_personal_sign(e) {
|
|
2681
|
+
this._requireAuthorization();
|
|
2682
|
+
const t = (0, g.ensureBuffer)(e[0]), r = (0, g.ensureAddressString)(e[1]);
|
|
2683
|
+
return this._signEthereumMessage(t, r, !0);
|
|
2684
|
+
}
|
|
2685
|
+
_personal_ecRecover(e) {
|
|
2686
|
+
const t = (0, g.ensureBuffer)(e[0]), r = (0, g.ensureBuffer)(e[1]);
|
|
2687
|
+
return this._ethereumAddressFromSignedMessage(t, r, !0);
|
|
2688
|
+
}
|
|
2689
|
+
async _eth_signTransaction(e) {
|
|
2690
|
+
this._requireAuthorization();
|
|
2691
|
+
const t = this._prepareTransactionParams(e[0] || {});
|
|
2692
|
+
try {
|
|
2693
|
+
const s = await this.initializeRelay().signEthereumTransaction(t);
|
|
2694
|
+
if ((0, W.isErrorResponse)(s))
|
|
2695
|
+
throw new Error(s.errorMessage);
|
|
2696
|
+
return { jsonrpc: "2.0", id: 0, result: s.result };
|
|
2697
|
+
} catch (r) {
|
|
2698
|
+
throw typeof r.message == "string" && r.message.match(/(denied|rejected)/i) ? v.standardErrors.provider.userRejectedRequest("User denied transaction signature") : r;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
async _eth_sendRawTransaction(e) {
|
|
2702
|
+
const t = (0, g.ensureBuffer)(e[0]), s = await this.initializeRelay().submitEthereumTransaction(t, this.getChainId());
|
|
2703
|
+
if ((0, W.isErrorResponse)(s))
|
|
2704
|
+
throw new Error(s.errorMessage);
|
|
2705
|
+
return { jsonrpc: "2.0", id: 0, result: s.result };
|
|
2706
|
+
}
|
|
2707
|
+
async _eth_sendTransaction(e) {
|
|
2708
|
+
this._requireAuthorization();
|
|
2709
|
+
const t = this._prepareTransactionParams(e[0] || {});
|
|
2710
|
+
try {
|
|
2711
|
+
const s = await this.initializeRelay().signAndSubmitEthereumTransaction(t);
|
|
2712
|
+
if ((0, W.isErrorResponse)(s))
|
|
2713
|
+
throw new Error(s.errorMessage);
|
|
2714
|
+
return { jsonrpc: "2.0", id: 0, result: s.result };
|
|
2715
|
+
} catch (r) {
|
|
2716
|
+
throw typeof r.message == "string" && r.message.match(/(denied|rejected)/i) ? v.standardErrors.provider.userRejectedRequest("User denied transaction signature") : r;
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
async _eth_signTypedData_v1(e) {
|
|
2720
|
+
this._requireAuthorization();
|
|
2721
|
+
const t = (0, g.ensureParsedJSONObject)(e[0]), r = (0, g.ensureAddressString)(e[1]);
|
|
2722
|
+
this._ensureKnownAddress(r);
|
|
2723
|
+
const s = qe.default.hashForSignTypedDataLegacy({ data: t }), i = JSON.stringify(t, null, 2);
|
|
2724
|
+
return this._signEthereumMessage(s, r, !1, i);
|
|
2725
|
+
}
|
|
2726
|
+
async _eth_signTypedData_v3(e) {
|
|
2727
|
+
this._requireAuthorization();
|
|
2728
|
+
const t = (0, g.ensureAddressString)(e[0]), r = (0, g.ensureParsedJSONObject)(e[1]);
|
|
2729
|
+
this._ensureKnownAddress(t);
|
|
2730
|
+
const s = qe.default.hashForSignTypedData_v3({ data: r }), i = JSON.stringify(r, null, 2);
|
|
2731
|
+
return this._signEthereumMessage(s, t, !1, i);
|
|
2732
|
+
}
|
|
2733
|
+
async _eth_signTypedData_v4(e) {
|
|
2734
|
+
this._requireAuthorization();
|
|
2735
|
+
const t = (0, g.ensureAddressString)(e[0]), r = (0, g.ensureParsedJSONObject)(e[1]);
|
|
2736
|
+
this._ensureKnownAddress(t);
|
|
2737
|
+
const s = qe.default.hashForSignTypedData_v4({ data: r }), i = JSON.stringify(r, null, 2);
|
|
2738
|
+
return this._signEthereumMessage(s, t, !1, i);
|
|
2739
|
+
}
|
|
2740
|
+
async _wallet_addEthereumChain(e) {
|
|
2741
|
+
var t, r, s, i;
|
|
2742
|
+
const a = e[0];
|
|
2743
|
+
if (((t = a.rpcUrls) === null || t === void 0 ? void 0 : t.length) === 0)
|
|
2744
|
+
return {
|
|
2745
|
+
jsonrpc: "2.0",
|
|
2746
|
+
id: 0,
|
|
2747
|
+
error: { code: 2, message: "please pass in at least 1 rpcUrl" }
|
|
2748
|
+
};
|
|
2749
|
+
if (!a.chainName || a.chainName.trim() === "")
|
|
2750
|
+
throw v.standardErrors.rpc.invalidParams("chainName is a required field");
|
|
2751
|
+
if (!a.nativeCurrency)
|
|
2752
|
+
throw v.standardErrors.rpc.invalidParams("nativeCurrency is a required field");
|
|
2753
|
+
const o = parseInt(a.chainId, 16);
|
|
2754
|
+
return await this.addEthereumChain(o, (r = a.rpcUrls) !== null && r !== void 0 ? r : [], (s = a.blockExplorerUrls) !== null && s !== void 0 ? s : [], a.chainName, (i = a.iconUrls) !== null && i !== void 0 ? i : [], a.nativeCurrency) ? { jsonrpc: "2.0", id: 0, result: null } : {
|
|
2755
|
+
jsonrpc: "2.0",
|
|
2756
|
+
id: 0,
|
|
2757
|
+
error: { code: 2, message: "unable to add ethereum chain" }
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2760
|
+
async _wallet_switchEthereumChain(e) {
|
|
2761
|
+
const t = e[0];
|
|
2762
|
+
return await this.switchEthereumChain(parseInt(t.chainId, 16)), { jsonrpc: "2.0", id: 0, result: null };
|
|
2763
|
+
}
|
|
2764
|
+
async _wallet_watchAsset(e) {
|
|
2765
|
+
const t = Array.isArray(e) ? e[0] : e;
|
|
2766
|
+
if (!t.type)
|
|
2767
|
+
throw v.standardErrors.rpc.invalidParams("Type is required");
|
|
2768
|
+
if ((t == null ? void 0 : t.type) !== "ERC20")
|
|
2769
|
+
throw v.standardErrors.rpc.invalidParams(`Asset of type '${t.type}' is not supported`);
|
|
2770
|
+
if (!(t != null && t.options))
|
|
2771
|
+
throw v.standardErrors.rpc.invalidParams("Options are required");
|
|
2772
|
+
if (!(t != null && t.options.address))
|
|
2773
|
+
throw v.standardErrors.rpc.invalidParams("Address is required");
|
|
2774
|
+
const r = this.getChainId(), { address: s, symbol: i, image: a, decimals: o } = t.options;
|
|
2775
|
+
return { jsonrpc: "2.0", id: 0, result: await this.watchAsset(t.type, s, i, o, a, r) };
|
|
2776
|
+
}
|
|
2777
|
+
initializeRelay() {
|
|
2778
|
+
if (!this._relay) {
|
|
2779
|
+
const e = new Zr.WalletLinkRelay({
|
|
2780
|
+
linkAPIUrl: gt.WALLETLINK_URL,
|
|
2781
|
+
storage: this._storage
|
|
2782
|
+
});
|
|
2783
|
+
e.setAppInfo(this._appName, this._appLogoUrl), e.attachUI(), e.setAccountsCallback((t, r) => this._setAddresses(t, r)), e.setChainCallback((t, r) => {
|
|
2784
|
+
this.updateProviderInfo(r, parseInt(t, 10));
|
|
2785
|
+
}), this._relay = e;
|
|
2786
|
+
}
|
|
2787
|
+
return this._relay;
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
ke.WalletLinkSigner = Yr;
|
|
2791
|
+
var I = {};
|
|
2792
|
+
Object.defineProperty(I, "__esModule", { value: !0 });
|
|
2793
|
+
I.checkErrorForInvalidRequestArgs = I.getCoinbaseInjectedProvider = I.getCoinbaseInjectedSigner = I.fetchRPCRequest = void 0;
|
|
2794
|
+
const Jr = q, fe = O;
|
|
2795
|
+
async function Qr(n, e) {
|
|
2796
|
+
if (!e.rpcUrl)
|
|
2797
|
+
throw fe.standardErrors.rpc.internal("No RPC URL set for chain");
|
|
2798
|
+
const t = Object.assign(Object.assign({}, n), { jsonrpc: "2.0", id: crypto.randomUUID() });
|
|
2799
|
+
return (await (await window.fetch(e.rpcUrl, {
|
|
2800
|
+
method: "POST",
|
|
2801
|
+
body: JSON.stringify(t),
|
|
2802
|
+
mode: "cors",
|
|
2803
|
+
headers: { "Content-Type": "application/json", "X-Cbw-Sdk-Version": Jr.LIB_VERSION }
|
|
2804
|
+
})).json()).result;
|
|
2805
|
+
}
|
|
2806
|
+
I.fetchRPCRequest = Qr;
|
|
2807
|
+
function Yt() {
|
|
2808
|
+
return globalThis.coinbaseWalletSigner;
|
|
2809
|
+
}
|
|
2810
|
+
I.getCoinbaseInjectedSigner = Yt;
|
|
2811
|
+
function Xr() {
|
|
2812
|
+
return globalThis.coinbaseWalletExtension;
|
|
2813
|
+
}
|
|
2814
|
+
function es() {
|
|
2815
|
+
var n, e;
|
|
2816
|
+
try {
|
|
2817
|
+
const t = globalThis;
|
|
2818
|
+
return (n = t.ethereum) !== null && n !== void 0 ? n : (e = t.top) === null || e === void 0 ? void 0 : e.ethereum;
|
|
2819
|
+
} catch {
|
|
2820
|
+
return;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
function ts({ metadata: n, preference: e }) {
|
|
2824
|
+
var t;
|
|
2825
|
+
if (e.options !== "smartWalletOnly") {
|
|
2826
|
+
if (Yt())
|
|
2827
|
+
return;
|
|
2828
|
+
const i = Xr();
|
|
2829
|
+
if (i) {
|
|
2830
|
+
const { appName: a, appLogoUrl: o, appChainIds: c } = n;
|
|
2831
|
+
return (t = i.setAppInfo) === null || t === void 0 || t.call(i, a, o, c), i;
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
const r = es();
|
|
2835
|
+
if (r != null && r.isCoinbaseBrowser)
|
|
2836
|
+
return r;
|
|
2837
|
+
}
|
|
2838
|
+
I.getCoinbaseInjectedProvider = ts;
|
|
2839
|
+
function ns(n) {
|
|
2840
|
+
if (!n || typeof n != "object" || Array.isArray(n))
|
|
2841
|
+
return fe.standardErrors.rpc.invalidParams({
|
|
2842
|
+
message: "Expected a single, non-array, object argument.",
|
|
2843
|
+
data: n
|
|
2844
|
+
});
|
|
2845
|
+
const { method: e, params: t } = n;
|
|
2846
|
+
if (typeof e != "string" || e.length === 0)
|
|
2847
|
+
return fe.standardErrors.rpc.invalidParams({
|
|
2848
|
+
message: "'args.method' must be a non-empty string.",
|
|
2849
|
+
data: n
|
|
2850
|
+
});
|
|
2851
|
+
if (t !== void 0 && !Array.isArray(t) && (typeof t != "object" || t === null))
|
|
2852
|
+
return fe.standardErrors.rpc.invalidParams({
|
|
2853
|
+
message: "'args.params' must be an object or array if provided.",
|
|
2854
|
+
data: n
|
|
2855
|
+
});
|
|
2856
|
+
}
|
|
2857
|
+
I.checkErrorForInvalidRequestArgs = ns;
|
|
2858
|
+
Object.defineProperty(N, "__esModule", { value: !0 });
|
|
2859
|
+
N.createSigner = N.fetchSignerType = N.storeSignerType = N.loadSignerType = void 0;
|
|
2860
|
+
const rs = Ee, Jt = ke, ss = O, is = I, as = D, Qt = "SignerType", Xt = new as.ScopedLocalStorage("CBWSDK", "SignerConfigurator");
|
|
2861
|
+
function os() {
|
|
2862
|
+
return Xt.getItem(Qt);
|
|
2863
|
+
}
|
|
2864
|
+
N.loadSignerType = os;
|
|
2865
|
+
function cs(n) {
|
|
2866
|
+
Xt.setItem(Qt, n);
|
|
2867
|
+
}
|
|
2868
|
+
N.storeSignerType = cs;
|
|
2869
|
+
async function ds(n) {
|
|
2870
|
+
const { communicator: e, metadata: t } = n;
|
|
2871
|
+
us(e, t).catch(() => {
|
|
2872
|
+
});
|
|
2873
|
+
const r = {
|
|
2874
|
+
id: crypto.randomUUID(),
|
|
2875
|
+
event: "selectSignerType",
|
|
2876
|
+
data: n.preference
|
|
2877
|
+
}, { data: s } = await e.postRequestAndWaitForResponse(r);
|
|
2878
|
+
return s;
|
|
2879
|
+
}
|
|
2880
|
+
N.fetchSignerType = ds;
|
|
2881
|
+
function ls(n) {
|
|
2882
|
+
const { signerType: e, metadata: t, communicator: r, updateListener: s } = n;
|
|
2883
|
+
switch (e) {
|
|
2884
|
+
case "scw":
|
|
2885
|
+
return new rs.SCWSigner({
|
|
2886
|
+
metadata: t,
|
|
2887
|
+
updateListener: s,
|
|
2888
|
+
communicator: r
|
|
2889
|
+
});
|
|
2890
|
+
case "walletlink":
|
|
2891
|
+
return new Jt.WalletLinkSigner({
|
|
2892
|
+
metadata: t,
|
|
2893
|
+
updateListener: s
|
|
2894
|
+
});
|
|
2895
|
+
case "extension": {
|
|
2896
|
+
const i = (0, is.getCoinbaseInjectedSigner)();
|
|
2897
|
+
if (!i)
|
|
2898
|
+
throw ss.standardErrors.rpc.internal("injected signer not found");
|
|
2899
|
+
return i;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
N.createSigner = ls;
|
|
2904
|
+
async function us(n, e) {
|
|
2905
|
+
await n.onMessage(({ event: r }) => r === "WalletLinkSessionRequest");
|
|
2906
|
+
const t = new Jt.WalletLinkSigner({
|
|
2907
|
+
metadata: e
|
|
2908
|
+
});
|
|
2909
|
+
n.postMessage({
|
|
2910
|
+
event: "WalletLinkUpdate",
|
|
2911
|
+
data: { session: t.getSession() }
|
|
2912
|
+
}), await t.handshake(), n.postMessage({
|
|
2913
|
+
event: "WalletLinkUpdate",
|
|
2914
|
+
data: { connected: !0 }
|
|
2915
|
+
});
|
|
2916
|
+
}
|
|
2917
|
+
var je = {}, Q = {};
|
|
2918
|
+
Object.defineProperty(Q, "__esModule", { value: !0 });
|
|
2919
|
+
Q.closePopup = Q.openPopup = void 0;
|
|
2920
|
+
const hs = O, ft = 420, mt = 540;
|
|
2921
|
+
function gs(n) {
|
|
2922
|
+
const e = (window.innerWidth - ft) / 2 + window.screenX, t = (window.innerHeight - mt) / 2 + window.screenY, r = window.open(n, "Smart Wallet", `width=${ft}, height=${mt}, left=${e}, top=${t}`);
|
|
2923
|
+
if (r == null || r.focus(), !r)
|
|
2924
|
+
throw hs.standardErrors.rpc.internal("Pop up window failed to open");
|
|
2925
|
+
return r;
|
|
2926
|
+
}
|
|
2927
|
+
Q.openPopup = gs;
|
|
2928
|
+
function ps(n) {
|
|
2929
|
+
n && !n.closed && n.close();
|
|
2930
|
+
}
|
|
2931
|
+
Q.closePopup = ps;
|
|
2932
|
+
Object.defineProperty(je, "__esModule", { value: !0 });
|
|
2933
|
+
je.Communicator = void 0;
|
|
2934
|
+
const fs = q, bt = Q, ms = j, yt = O;
|
|
2935
|
+
class bs {
|
|
2936
|
+
constructor(e = ms.CB_KEYS_URL) {
|
|
2937
|
+
this.popup = null, this.listeners = /* @__PURE__ */ new Map(), this.postMessage = async (t) => {
|
|
2938
|
+
(await this.waitForPopupLoaded()).postMessage(t, this.url.origin);
|
|
2939
|
+
}, this.postRequestAndWaitForResponse = async (t) => {
|
|
2940
|
+
const r = this.onMessage(({ requestId: s }) => s === t.id);
|
|
2941
|
+
return this.postMessage(t), await r;
|
|
2942
|
+
}, this.onMessage = async (t) => new Promise((r, s) => {
|
|
2943
|
+
const i = (a) => {
|
|
2944
|
+
if (a.origin !== this.url.origin)
|
|
2945
|
+
return;
|
|
2946
|
+
const o = a.data;
|
|
2947
|
+
t(o) && (r(o), window.removeEventListener("message", i), this.listeners.delete(i));
|
|
2948
|
+
};
|
|
2949
|
+
window.addEventListener("message", i), this.listeners.set(i, { reject: s });
|
|
2950
|
+
}), this.disconnect = () => {
|
|
2951
|
+
(0, bt.closePopup)(this.popup), this.popup = null, this.listeners.forEach(({ reject: t }, r) => {
|
|
2952
|
+
t(yt.standardErrors.provider.userRejectedRequest("Request rejected")), window.removeEventListener("message", r);
|
|
2953
|
+
}), this.listeners.clear();
|
|
2954
|
+
}, this.waitForPopupLoaded = async () => this.popup && !this.popup.closed ? (this.popup.focus(), this.popup) : (this.popup = (0, bt.openPopup)(this.url), this.onMessage(({ event: t }) => t === "PopupUnload").then(this.disconnect).catch(() => {
|
|
2955
|
+
}), this.onMessage(({ event: t }) => t === "PopupLoaded").then((t) => {
|
|
2956
|
+
this.postMessage({
|
|
2957
|
+
requestId: t.id,
|
|
2958
|
+
data: { version: fs.LIB_VERSION }
|
|
2959
|
+
});
|
|
2960
|
+
}).then(() => {
|
|
2961
|
+
if (!this.popup)
|
|
2962
|
+
throw yt.standardErrors.rpc.internal();
|
|
2963
|
+
return this.popup;
|
|
2964
|
+
})), this.url = new URL(e);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
je.Communicator = bs;
|
|
2968
|
+
var Oe = {};
|
|
2969
|
+
Object.defineProperty(Oe, "__esModule", { value: !0 });
|
|
2970
|
+
Oe.determineMethodCategory = void 0;
|
|
2971
|
+
const wt = {
|
|
2972
|
+
handshake: ["eth_requestAccounts"],
|
|
2973
|
+
sign: [
|
|
2974
|
+
"eth_ecRecover",
|
|
2975
|
+
"personal_sign",
|
|
2976
|
+
"personal_ecRecover",
|
|
2977
|
+
"eth_signTransaction",
|
|
2978
|
+
"eth_sendTransaction",
|
|
2979
|
+
"eth_signTypedData_v1",
|
|
2980
|
+
"eth_signTypedData_v3",
|
|
2981
|
+
"eth_signTypedData_v4",
|
|
2982
|
+
"eth_signTypedData",
|
|
2983
|
+
"wallet_addEthereumChain",
|
|
2984
|
+
"wallet_switchEthereumChain",
|
|
2985
|
+
"wallet_watchAsset",
|
|
2986
|
+
"wallet_getCapabilities",
|
|
2987
|
+
"wallet_sendCalls",
|
|
2988
|
+
"wallet_showCallsStatus"
|
|
2989
|
+
],
|
|
2990
|
+
state: [
|
|
2991
|
+
// internal state
|
|
2992
|
+
"eth_chainId",
|
|
2993
|
+
"eth_accounts",
|
|
2994
|
+
"eth_coinbase",
|
|
2995
|
+
"net_version"
|
|
2996
|
+
],
|
|
2997
|
+
deprecated: ["eth_sign", "eth_signTypedData_v2"],
|
|
2998
|
+
unsupported: ["eth_subscribe", "eth_unsubscribe"],
|
|
2999
|
+
fetch: []
|
|
3000
|
+
};
|
|
3001
|
+
function ys(n) {
|
|
3002
|
+
for (const e in wt) {
|
|
3003
|
+
const t = e;
|
|
3004
|
+
if (wt[t].includes(n))
|
|
3005
|
+
return t;
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
Oe.determineMethodCategory = ys;
|
|
3009
|
+
var ws = L && L.__rest || function(n, e) {
|
|
3010
|
+
var t = {};
|
|
3011
|
+
for (var r in n)
|
|
3012
|
+
Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
|
|
3013
|
+
if (n != null && typeof Object.getOwnPropertySymbols == "function")
|
|
3014
|
+
for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++)
|
|
3015
|
+
e.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (t[r[s]] = n[r[s]]);
|
|
3016
|
+
return t;
|
|
3017
|
+
}, vs = L && L.__importDefault || function(n) {
|
|
3018
|
+
return n && n.__esModule ? n : { default: n };
|
|
3019
|
+
};
|
|
3020
|
+
Object.defineProperty(ye, "__esModule", { value: !0 });
|
|
3021
|
+
ye.CoinbaseWalletProvider = void 0;
|
|
3022
|
+
const _s = vs(sn), Z = O, Es = ve, ge = E, ee = u, pe = N, vt = I, Ss = je, Cs = Oe, ks = D;
|
|
3023
|
+
class Is extends _s.default {
|
|
3024
|
+
constructor(e) {
|
|
3025
|
+
var t, r, { metadata: s } = e, i = e.preference, { keysUrl: a } = i, o = ws(i, ["keysUrl"]);
|
|
3026
|
+
super(), this.accounts = [], this.handlers = {
|
|
3027
|
+
// eth_requestAccounts
|
|
3028
|
+
handshake: async (l) => {
|
|
3029
|
+
try {
|
|
3030
|
+
if (this.connected)
|
|
3031
|
+
return this.emit("connect", { chainId: (0, ee.hexStringFromIntNumber)((0, ge.IntNumber)(this.chain.id)) }), this.accounts;
|
|
3032
|
+
const h = await this.requestSignerSelection(), m = this.initSigner(h), d = await m.handshake();
|
|
3033
|
+
return this.signer = m, (0, pe.storeSignerType)(h), this.emit("connect", { chainId: (0, ee.hexStringFromIntNumber)((0, ge.IntNumber)(this.chain.id)) }), d;
|
|
3034
|
+
} catch (h) {
|
|
3035
|
+
throw this.handleUnauthorizedError(h), h;
|
|
3036
|
+
}
|
|
3037
|
+
},
|
|
3038
|
+
sign: async (l) => {
|
|
3039
|
+
if (!this.connected || !this.signer)
|
|
3040
|
+
throw Z.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");
|
|
3041
|
+
try {
|
|
3042
|
+
return await this.signer.request(l);
|
|
3043
|
+
} catch (h) {
|
|
3044
|
+
throw this.handleUnauthorizedError(h), h;
|
|
3045
|
+
}
|
|
3046
|
+
},
|
|
3047
|
+
fetch: (l) => (0, vt.fetchRPCRequest)(l, this.chain),
|
|
3048
|
+
state: (l) => {
|
|
3049
|
+
const h = () => {
|
|
3050
|
+
if (this.connected)
|
|
3051
|
+
return this.accounts;
|
|
3052
|
+
throw Z.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");
|
|
3053
|
+
};
|
|
3054
|
+
switch (l.method) {
|
|
3055
|
+
case "eth_chainId":
|
|
3056
|
+
return (0, ee.hexStringFromIntNumber)((0, ge.IntNumber)(this.chain.id));
|
|
3057
|
+
case "net_version":
|
|
3058
|
+
return this.chain.id;
|
|
3059
|
+
case "eth_accounts":
|
|
3060
|
+
return h();
|
|
3061
|
+
case "eth_coinbase":
|
|
3062
|
+
return h()[0];
|
|
3063
|
+
default:
|
|
3064
|
+
return this.handlers.unsupported(l);
|
|
3065
|
+
}
|
|
3066
|
+
},
|
|
3067
|
+
deprecated: ({ method: l }) => {
|
|
3068
|
+
throw Z.standardErrors.rpc.methodNotSupported(`Method ${l} is deprecated.`);
|
|
3069
|
+
},
|
|
3070
|
+
unsupported: ({ method: l }) => {
|
|
3071
|
+
throw Z.standardErrors.rpc.methodNotSupported(`Method ${l} is not supported.`);
|
|
3072
|
+
}
|
|
3073
|
+
}, this.isCoinbaseWallet = !0, this.updateListener = {
|
|
3074
|
+
onAccountsUpdate: ({ accounts: l, source: h }) => {
|
|
3075
|
+
(0, ee.areAddressArraysEqual)(this.accounts, l) || (this.accounts = l, h !== "storage" && this.emit("accountsChanged", this.accounts));
|
|
3076
|
+
},
|
|
3077
|
+
onChainUpdate: ({ chain: l, source: h }) => {
|
|
3078
|
+
l.id === this.chain.id && l.rpcUrl === this.chain.rpcUrl || (this.chain = l, h !== "storage" && this.emit("chainChanged", (0, ee.hexStringFromIntNumber)((0, ge.IntNumber)(l.id))));
|
|
3079
|
+
}
|
|
3080
|
+
}, this.metadata = s, this.preference = o, this.communicator = new Ss.Communicator(a), this.chain = {
|
|
3081
|
+
id: (r = (t = s.appChainIds) === null || t === void 0 ? void 0 : t[0]) !== null && r !== void 0 ? r : 1
|
|
3082
|
+
};
|
|
3083
|
+
const c = (0, pe.loadSignerType)();
|
|
3084
|
+
this.signer = c ? this.initSigner(c) : null;
|
|
3085
|
+
}
|
|
3086
|
+
get connected() {
|
|
3087
|
+
return this.accounts.length > 0;
|
|
3088
|
+
}
|
|
3089
|
+
async request(e) {
|
|
3090
|
+
var t;
|
|
3091
|
+
try {
|
|
3092
|
+
const r = (0, vt.checkErrorForInvalidRequestArgs)(e);
|
|
3093
|
+
if (r)
|
|
3094
|
+
throw r;
|
|
3095
|
+
const s = (t = (0, Cs.determineMethodCategory)(e.method)) !== null && t !== void 0 ? t : "fetch";
|
|
3096
|
+
return this.handlers[s](e);
|
|
3097
|
+
} catch (r) {
|
|
3098
|
+
return Promise.reject((0, Es.serializeError)(r, e.method));
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
handleUnauthorizedError(e) {
|
|
3102
|
+
e.code === Z.standardErrorCodes.provider.unauthorized && this.disconnect();
|
|
3103
|
+
}
|
|
3104
|
+
/** @deprecated Use `.request({ method: 'eth_requestAccounts' })` instead. */
|
|
3105
|
+
async enable() {
|
|
3106
|
+
return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'), await this.request({
|
|
3107
|
+
method: "eth_requestAccounts"
|
|
3108
|
+
});
|
|
3109
|
+
}
|
|
3110
|
+
async disconnect() {
|
|
3111
|
+
this.accounts = [], this.chain = { id: 1 }, ks.ScopedLocalStorage.clearAll(), this.emit("disconnect", Z.standardErrors.provider.disconnected("User initiated disconnection"));
|
|
3112
|
+
}
|
|
3113
|
+
requestSignerSelection() {
|
|
3114
|
+
return (0, pe.fetchSignerType)({
|
|
3115
|
+
communicator: this.communicator,
|
|
3116
|
+
preference: this.preference,
|
|
3117
|
+
metadata: this.metadata
|
|
3118
|
+
});
|
|
3119
|
+
}
|
|
3120
|
+
initSigner(e) {
|
|
3121
|
+
return (0, pe.createSigner)({
|
|
3122
|
+
signerType: e,
|
|
3123
|
+
metadata: this.metadata,
|
|
3124
|
+
communicator: this.communicator,
|
|
3125
|
+
updateListener: this.updateListener
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
ye.CoinbaseWalletProvider = Is;
|
|
3130
|
+
Object.defineProperty(ne, "__esModule", { value: !0 });
|
|
3131
|
+
ne.CoinbaseWalletSDK = void 0;
|
|
3132
|
+
const Ms = be, Ls = ye, As = D, Rs = q, xs = u, Ps = I;
|
|
3133
|
+
class Ns {
|
|
3134
|
+
constructor(e) {
|
|
3135
|
+
this.metadata = {
|
|
3136
|
+
appName: e.appName || "Dapp",
|
|
3137
|
+
appLogoUrl: e.appLogoUrl || (0, xs.getFavicon)(),
|
|
3138
|
+
appChainIds: e.appChainIds || []
|
|
3139
|
+
}, this.storeLatestVersion();
|
|
3140
|
+
}
|
|
3141
|
+
makeWeb3Provider(e = { options: "all" }) {
|
|
3142
|
+
var t;
|
|
3143
|
+
const r = { metadata: this.metadata, preference: e };
|
|
3144
|
+
return (t = (0, Ps.getCoinbaseInjectedProvider)(r)) !== null && t !== void 0 ? t : new Ls.CoinbaseWalletProvider(r);
|
|
3145
|
+
}
|
|
3146
|
+
/**
|
|
3147
|
+
* Official Coinbase Wallet logo for developers to use on their frontend
|
|
3148
|
+
* @param type Type of wallet logo: "standard" | "circle" | "text" | "textWithLogo" | "textLight" | "textWithLogoLight"
|
|
3149
|
+
* @param width Width of the logo (Optional)
|
|
3150
|
+
* @returns SVG Data URI
|
|
3151
|
+
*/
|
|
3152
|
+
getCoinbaseWalletLogo(e, t = 240) {
|
|
3153
|
+
return (0, Ms.walletLogo)(e, t);
|
|
3154
|
+
}
|
|
3155
|
+
storeLatestVersion() {
|
|
3156
|
+
new As.ScopedLocalStorage("CBWSDK").setItem("VERSION", Rs.LIB_VERSION);
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
ne.CoinbaseWalletSDK = Ns;
|
|
3160
|
+
(function(n) {
|
|
3161
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), n.CoinbaseWalletSDK = void 0;
|
|
3162
|
+
const e = ne;
|
|
3163
|
+
n.default = e.CoinbaseWalletSDK;
|
|
3164
|
+
var t = ne;
|
|
3165
|
+
Object.defineProperty(n, "CoinbaseWalletSDK", { enumerable: !0, get: function() {
|
|
3166
|
+
return t.CoinbaseWalletSDK;
|
|
3167
|
+
} });
|
|
3168
|
+
})(St);
|
|
3169
|
+
const Ts = /* @__PURE__ */ an(St), Ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3170
|
+
__proto__: null,
|
|
3171
|
+
default: Ts
|
|
3172
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
3173
|
+
export {
|
|
3174
|
+
Ds as i
|
|
3175
|
+
};
|