@pollar/react 0.11.3-rc.1 → 0.11.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/README.md +18 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +25 -26
- package/dist/index.d.ts +25 -26
- package/dist/index.js +17 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { AUTH_ERROR_CODES, WalletType, PollarClient, isInteractiveAuthAdapter, toBaseUnits } from '@pollar/core';
|
|
2
|
+
import { AUTH_ERROR_CODES, WalletType, isPollarClient, PollarClient, isInteractiveAuthAdapter, toBaseUnits } from '@pollar/core';
|
|
3
3
|
import { forwardRef, createContext, useState, useCallback, useEffect, useMemo, useRef, useContext, Component } from 'react';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { startAuthentication, startRegistration } from '@simplewebauthn/browser';
|
|
@@ -1033,7 +1033,7 @@ var PollarModalFooter = () => {
|
|
|
1033
1033
|
/* @__PURE__ */ jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
|
|
1034
1034
|
/* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
|
|
1035
1035
|
"v",
|
|
1036
|
-
"0.11.3
|
|
1036
|
+
"0.11.3"
|
|
1037
1037
|
] })
|
|
1038
1038
|
] })
|
|
1039
1039
|
] });
|
|
@@ -1217,7 +1217,7 @@ var REASON_LABEL = {
|
|
|
1217
1217
|
DISTRIBUTION_RULE_NOT_STARTED: "Not started yet",
|
|
1218
1218
|
DISTRIBUTION_RULE_EXPIRED: "Expired",
|
|
1219
1219
|
DISTRIBUTION_RULE_EXHAUSTED: "Fully claimed",
|
|
1220
|
-
// Per-user, per-window claim limit (resets next period)
|
|
1220
|
+
// Per-user, per-window claim limit (resets next period) - not permanent.
|
|
1221
1221
|
DISTRIBUTION_RATE_LIMIT_EXCEEDED: "Claimed for this period"
|
|
1222
1222
|
};
|
|
1223
1223
|
function reasonLabel(reason) {
|
|
@@ -4067,7 +4067,7 @@ function SendModalTemplate({
|
|
|
4067
4067
|
options: assets.map((a) => ({
|
|
4068
4068
|
key: assetKey3(a),
|
|
4069
4069
|
code: a.code,
|
|
4070
|
-
// Unreadable (null) drops the "
|
|
4070
|
+
// Unreadable (null) drops the "- X available" suffix instead of
|
|
4071
4071
|
// claiming a zero balance.
|
|
4072
4072
|
available: a.available ?? void 0,
|
|
4073
4073
|
enabledInApp: a.enabledInApp
|
|
@@ -6104,7 +6104,7 @@ var browserPasskeyCeremony = async ({ challenge, mode }) => {
|
|
|
6104
6104
|
challenge,
|
|
6105
6105
|
rp: { id: rpId, name: rpId },
|
|
6106
6106
|
user: { id: userId, name: "Smart Wallet", displayName: "Smart Wallet" },
|
|
6107
|
-
// ES256 (secp256r1)
|
|
6107
|
+
// ES256 (secp256r1) - the curve the on-chain WebAuthn verifier expects.
|
|
6108
6108
|
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
|
|
6109
6109
|
authenticatorSelection: { residentKey: "required", userVerification: "required" },
|
|
6110
6110
|
attestation: "none",
|
|
@@ -6139,6 +6139,7 @@ function sessionsEqual(a, b) {
|
|
|
6139
6139
|
return a.clientSessionId === b.clientSessionId && a.userId === b.userId && a.status === b.status && a.token?.accessToken === b.token?.accessToken && a.token?.refreshToken === b.token?.refreshToken && a.token?.expiresAt === b.token?.expiresAt && a.wallet?.address === b.wallet?.address;
|
|
6140
6140
|
}
|
|
6141
6141
|
var PollarContext = createContext(null);
|
|
6142
|
+
var clientByConfig = /* @__PURE__ */ new WeakMap();
|
|
6142
6143
|
function PollarProvider({
|
|
6143
6144
|
client,
|
|
6144
6145
|
appConfig: appConfigProp,
|
|
@@ -6147,20 +6148,29 @@ function PollarProvider({
|
|
|
6147
6148
|
children
|
|
6148
6149
|
}) {
|
|
6149
6150
|
const [pollarClient] = useState(() => {
|
|
6150
|
-
if (client
|
|
6151
|
+
if (isPollarClient(client)) {
|
|
6151
6152
|
client.setPasskeyDefaults({ passkey: browserPasskeyCeremony, passkeySign: browserPasskeySigner });
|
|
6152
6153
|
return client;
|
|
6153
6154
|
}
|
|
6154
|
-
|
|
6155
|
+
const alreadyBuilt = clientByConfig.get(client);
|
|
6156
|
+
if (alreadyBuilt) return alreadyBuilt;
|
|
6157
|
+
const built = new PollarClient({
|
|
6155
6158
|
...client,
|
|
6156
6159
|
passkey: client.passkey ?? browserPasskeyCeremony,
|
|
6157
6160
|
passkeySign: client.passkeySign ?? browserPasskeySigner
|
|
6158
6161
|
});
|
|
6162
|
+
clientByConfig.set(client, built);
|
|
6163
|
+
return built;
|
|
6159
6164
|
});
|
|
6160
|
-
const ownsClientRef = useRef(!(client
|
|
6165
|
+
const ownsClientRef = useRef(!isPollarClient(client));
|
|
6161
6166
|
const destroyTimerRef = useRef(null);
|
|
6167
|
+
const builtFromConfigRef = useRef(isPollarClient(client) ? null : client);
|
|
6162
6168
|
useEffect(() => {
|
|
6163
6169
|
if (!ownsClientRef.current) return;
|
|
6170
|
+
if (builtFromConfigRef.current) {
|
|
6171
|
+
clientByConfig.delete(builtFromConfigRef.current);
|
|
6172
|
+
builtFromConfigRef.current = null;
|
|
6173
|
+
}
|
|
6164
6174
|
if (destroyTimerRef.current) {
|
|
6165
6175
|
clearTimeout(destroyTimerRef.current);
|
|
6166
6176
|
destroyTimerRef.current = null;
|
|
@@ -6804,7 +6814,6 @@ function WalletButton() {
|
|
|
6804
6814
|
} = usePollar();
|
|
6805
6815
|
const { primaryAddress } = useChains();
|
|
6806
6816
|
const walletAddress = primaryAddress || (wallet?.address ?? "");
|
|
6807
|
-
const walletType = wallet?.custody === "external" ? wallet.provider : null;
|
|
6808
6817
|
const [open, setOpen] = useState(false);
|
|
6809
6818
|
const [copied, setCopied] = useState(false);
|
|
6810
6819
|
const [creating, setCreating] = useState(false);
|
|
@@ -6905,7 +6914,6 @@ function WalletButton() {
|
|
|
6905
6914
|
itemColor,
|
|
6906
6915
|
wrapperRef,
|
|
6907
6916
|
isInProgress,
|
|
6908
|
-
walletType,
|
|
6909
6917
|
showCreateAccount: canCreateAccount,
|
|
6910
6918
|
creatingAccount: creating,
|
|
6911
6919
|
onToggleOpen: () => setOpen((v) => !v),
|