@domino-sdk/relay 0.24.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring.d.ts +52 -10
- package/dist/authoring.js +48 -8
- package/dist/browser.d.ts +431 -27
- package/dist/browser.js +22 -7
- package/dist/chunk-7QICEKC2.js +229 -0
- package/dist/{chunk-ZOL7RYHW.js → chunk-AKB266O5.js} +46 -3
- package/dist/chunk-D6BX627V.js +175 -0
- package/dist/{chunk-UYS522ER.js → chunk-IXLY3A7B.js} +550 -396
- package/dist/chunk-MZFUQQDP.js +355 -0
- package/dist/{chunk-RTBIXGMH.js → chunk-S44XSDW2.js} +779 -46
- package/dist/index.d.ts +1186 -56
- package/dist/index.js +123 -11
- package/dist/portal-proxy.js +10 -5
- package/dist/react/index.d.ts +498 -13
- package/dist/react/index.js +316 -40
- package/dist/schema.d.ts +82 -2
- package/dist/schema.js +1 -1
- package/dist/{submission-input-CK4Dy19H.d.ts → submission-input-Ckpb4sBv.d.ts} +1899 -2
- package/package.json +5 -3
- package/dist/chunk-57TGYC5Y.js +0 -37
- package/dist/chunk-ND3CVNIW.js +0 -61
package/dist/react/index.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createBrowserRelayClient
|
|
3
|
-
|
|
2
|
+
createBrowserRelayClient,
|
|
3
|
+
discoverCosmosWallets,
|
|
4
|
+
discoverEvmWallets,
|
|
5
|
+
discoverSolanaWallets
|
|
6
|
+
} from "../chunk-MZFUQQDP.js";
|
|
4
7
|
import {
|
|
5
|
-
RelayError
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
RelayError,
|
|
9
|
+
avatarSrc,
|
|
10
|
+
defaultAvatar,
|
|
11
|
+
walletAvatarSeed
|
|
12
|
+
} from "../chunk-S44XSDW2.js";
|
|
13
|
+
import "../chunk-AKB266O5.js";
|
|
14
|
+
import "../chunk-7QICEKC2.js";
|
|
15
|
+
import "../chunk-D6BX627V.js";
|
|
16
|
+
import "../chunk-IXLY3A7B.js";
|
|
10
17
|
|
|
11
18
|
// src/react/provider.tsx
|
|
12
19
|
import { useState as useState3 } from "react";
|
|
@@ -531,11 +538,126 @@ function useQuest(observed) {
|
|
|
531
538
|
}
|
|
532
539
|
|
|
533
540
|
// src/react/auth.ts
|
|
534
|
-
import { useEffect as
|
|
535
|
-
|
|
541
|
+
import { useEffect as useEffect5, useState as useState6 } from "react";
|
|
542
|
+
|
|
543
|
+
// src/react/wallets.ts
|
|
544
|
+
import { useCallback as useCallback2, useEffect as useEffect4, useState as useState5 } from "react";
|
|
545
|
+
var WALLETS_CHANGED = "relay-wallets-changed";
|
|
546
|
+
function useWallets() {
|
|
536
547
|
const relay = useRelay();
|
|
537
|
-
const
|
|
548
|
+
const { member } = useExperience();
|
|
549
|
+
const [wallets, setWallets] = useState5(null);
|
|
550
|
+
const [error, setError] = useState5(null);
|
|
551
|
+
const [busy, setBusy] = useState5(false);
|
|
552
|
+
const refresh = useCallback2(async () => {
|
|
553
|
+
try {
|
|
554
|
+
setWallets(await relay.wallets.list());
|
|
555
|
+
setError(null);
|
|
556
|
+
} catch (cause) {
|
|
557
|
+
setError(
|
|
558
|
+
cause instanceof Error && cause.message ? cause.message : "Could not load linked wallets."
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
}, [relay]);
|
|
538
562
|
useEffect4(() => {
|
|
563
|
+
if (!member) {
|
|
564
|
+
setWallets(null);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
const update = () => void refresh();
|
|
568
|
+
update();
|
|
569
|
+
window.addEventListener("focus", update);
|
|
570
|
+
window.addEventListener(WALLETS_CHANGED, update);
|
|
571
|
+
return () => {
|
|
572
|
+
window.removeEventListener("focus", update);
|
|
573
|
+
window.removeEventListener(WALLETS_CHANGED, update);
|
|
574
|
+
};
|
|
575
|
+
}, [member, refresh]);
|
|
576
|
+
async function run(task, fallback) {
|
|
577
|
+
setBusy(true);
|
|
578
|
+
setError(null);
|
|
579
|
+
try {
|
|
580
|
+
await task();
|
|
581
|
+
} catch (cause) {
|
|
582
|
+
setError(
|
|
583
|
+
cause instanceof Error && cause.message ? cause.message : fallback
|
|
584
|
+
);
|
|
585
|
+
} finally {
|
|
586
|
+
setBusy(false);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return {
|
|
590
|
+
/** Null until read, and while nobody is signed in. */
|
|
591
|
+
wallets,
|
|
592
|
+
error,
|
|
593
|
+
busy,
|
|
594
|
+
refresh,
|
|
595
|
+
link: (signer) => run(async () => {
|
|
596
|
+
await relay.wallets.link(signer);
|
|
597
|
+
window.dispatchEvent(new Event(WALLETS_CHANGED));
|
|
598
|
+
}, "Couldn't link this wallet. Try again."),
|
|
599
|
+
unlink: (wallet) => run(async () => {
|
|
600
|
+
await relay.wallets.unlink({
|
|
601
|
+
chain: wallet.chain,
|
|
602
|
+
address: wallet.address
|
|
603
|
+
});
|
|
604
|
+
window.dispatchEvent(new Event(WALLETS_CHANGED));
|
|
605
|
+
}, "Couldn't unlink this wallet. Try again.")
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
function useWalletDiscovery(options = {}) {
|
|
609
|
+
const networks = (options.cosmos ?? ["cosmos:pio-mainnet-1"]).join(" ");
|
|
610
|
+
const [found, setFound] = useState5({ evm: [], solana: [], cosmos: [] });
|
|
611
|
+
useEffect4(() => {
|
|
612
|
+
let active = true;
|
|
613
|
+
const solana = discoverSolanaWallets();
|
|
614
|
+
const cosmos = networks.split(" ").filter(Boolean).flatMap((network) => discoverCosmosWallets(network));
|
|
615
|
+
setFound((current) => ({ ...current, solana, cosmos }));
|
|
616
|
+
void discoverEvmWallets().then((evm) => {
|
|
617
|
+
if (active) {
|
|
618
|
+
setFound((current) => ({ ...current, evm }));
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
return () => {
|
|
622
|
+
active = false;
|
|
623
|
+
};
|
|
624
|
+
}, [networks]);
|
|
625
|
+
return found;
|
|
626
|
+
}
|
|
627
|
+
function useSignInWallets(networks) {
|
|
628
|
+
const key = networks ? networks.join(" ") : null;
|
|
629
|
+
const [found, setFound] = useState5(null);
|
|
630
|
+
useEffect4(() => {
|
|
631
|
+
if (key === null) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
let active = true;
|
|
635
|
+
const enabled = key.split(" ").filter(Boolean);
|
|
636
|
+
const tagged = (network, wallets) => wallets.map((wallet) => ({ ...wallet, network }));
|
|
637
|
+
const immediate = [
|
|
638
|
+
...enabled.includes("solana") ? tagged("solana", discoverSolanaWallets()) : [],
|
|
639
|
+
...enabled.filter(
|
|
640
|
+
(network) => network.startsWith("cosmos:")
|
|
641
|
+
).flatMap((network) => tagged(network, discoverCosmosWallets(network)))
|
|
642
|
+
];
|
|
643
|
+
const evm = enabled.includes("eip155") ? discoverEvmWallets() : Promise.resolve([]);
|
|
644
|
+
void evm.then((wallets) => {
|
|
645
|
+
if (active) {
|
|
646
|
+
setFound({ key, wallets: [...tagged("eip155", wallets), ...immediate] });
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
return () => {
|
|
650
|
+
active = false;
|
|
651
|
+
};
|
|
652
|
+
}, [key]);
|
|
653
|
+
return found && found.key === key ? found.wallets : null;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// src/react/auth.ts
|
|
657
|
+
function useSignInMethods() {
|
|
658
|
+
const relay = useRelay();
|
|
659
|
+
const [methods, setMethods] = useState6(null);
|
|
660
|
+
useEffect5(() => {
|
|
539
661
|
let active = true;
|
|
540
662
|
relay.auth.providers().then((result) => {
|
|
541
663
|
if (!active) {
|
|
@@ -543,20 +665,43 @@ function useSignInMethods() {
|
|
|
543
665
|
}
|
|
544
666
|
setMethods({
|
|
545
667
|
providers: result.providers.filter((p) => p.configured).map((p) => p.provider),
|
|
546
|
-
email: result.email
|
|
668
|
+
email: result.email,
|
|
669
|
+
wallets: result.wallets
|
|
547
670
|
});
|
|
548
|
-
}).catch(
|
|
671
|
+
}).catch(
|
|
672
|
+
() => active && setMethods({ providers: [], email: true, wallets: [] })
|
|
673
|
+
);
|
|
549
674
|
return () => {
|
|
550
675
|
active = false;
|
|
551
676
|
};
|
|
552
677
|
}, [relay]);
|
|
553
678
|
return methods;
|
|
554
679
|
}
|
|
680
|
+
function useMe() {
|
|
681
|
+
const relay = useRelay();
|
|
682
|
+
const { member } = useExperience();
|
|
683
|
+
const [me, setMe] = useState6(null);
|
|
684
|
+
useEffect5(() => {
|
|
685
|
+
if (!member) {
|
|
686
|
+
setMe(null);
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
let active = true;
|
|
690
|
+
const read = () => void relay.me.get().then((value) => active && setMe(value)).catch(() => active && setMe(null));
|
|
691
|
+
read();
|
|
692
|
+
window.addEventListener(WALLETS_CHANGED, read);
|
|
693
|
+
return () => {
|
|
694
|
+
active = false;
|
|
695
|
+
window.removeEventListener(WALLETS_CHANGED, read);
|
|
696
|
+
};
|
|
697
|
+
}, [relay, member]);
|
|
698
|
+
return me;
|
|
699
|
+
}
|
|
555
700
|
function useSignIn() {
|
|
556
701
|
const relay = useRelay();
|
|
557
|
-
const [challenge, setChallenge] =
|
|
558
|
-
const [busy, setBusy] =
|
|
559
|
-
const [error, setError] =
|
|
702
|
+
const [challenge, setChallenge] = useState6(null);
|
|
703
|
+
const [busy, setBusy] = useState6(false);
|
|
704
|
+
const [error, setError] = useState6(null);
|
|
560
705
|
async function run(task, fallback) {
|
|
561
706
|
setBusy(true);
|
|
562
707
|
setError(null);
|
|
@@ -592,12 +737,17 @@ function useSignIn() {
|
|
|
592
737
|
withProvider: (provider) => run(async () => {
|
|
593
738
|
const { url } = await relay.auth.start(provider, "sign-in");
|
|
594
739
|
window.location.assign(url);
|
|
595
|
-
}, "Couldn't start sign-in. Try again.")
|
|
740
|
+
}, "Couldn't start sign-in. Try again."),
|
|
741
|
+
/** Signs in, or signs up, with a wallet; the wallet asks the participant to sign a message. */
|
|
742
|
+
withWallet: (signer) => run(async () => {
|
|
743
|
+
await relay.auth.wallet.signIn(signer);
|
|
744
|
+
setChallenge(null);
|
|
745
|
+
}, "Couldn't sign in with this wallet. Try again.")
|
|
596
746
|
};
|
|
597
747
|
}
|
|
598
748
|
function useSignOut() {
|
|
599
749
|
const relay = useRelay();
|
|
600
|
-
const [busy, setBusy] =
|
|
750
|
+
const [busy, setBusy] = useState6(false);
|
|
601
751
|
return {
|
|
602
752
|
busy,
|
|
603
753
|
signOut: async () => {
|
|
@@ -612,7 +762,7 @@ function useSignOut() {
|
|
|
612
762
|
}
|
|
613
763
|
|
|
614
764
|
// src/react/accounts.ts
|
|
615
|
-
import { useCallback as
|
|
765
|
+
import { useCallback as useCallback3, useEffect as useEffect6, useState as useState7 } from "react";
|
|
616
766
|
var CHANGED = "relay-accounts-changed";
|
|
617
767
|
function isConnected(accounts, provider) {
|
|
618
768
|
return Boolean(
|
|
@@ -624,10 +774,10 @@ function isConnected(accounts, provider) {
|
|
|
624
774
|
function useAccounts() {
|
|
625
775
|
const relay = useRelay();
|
|
626
776
|
const { member } = useExperience();
|
|
627
|
-
const [accounts, setAccounts] =
|
|
628
|
-
const [error, setError] =
|
|
629
|
-
const [busy, setBusy] =
|
|
630
|
-
const refresh =
|
|
777
|
+
const [accounts, setAccounts] = useState7(null);
|
|
778
|
+
const [error, setError] = useState7(null);
|
|
779
|
+
const [busy, setBusy] = useState7(false);
|
|
780
|
+
const refresh = useCallback3(async () => {
|
|
631
781
|
try {
|
|
632
782
|
setAccounts(await relay.auth.accounts());
|
|
633
783
|
setError(null);
|
|
@@ -637,7 +787,7 @@ function useAccounts() {
|
|
|
637
787
|
);
|
|
638
788
|
}
|
|
639
789
|
}, [relay]);
|
|
640
|
-
|
|
790
|
+
useEffect6(() => {
|
|
641
791
|
if (!member) {
|
|
642
792
|
setAccounts(null);
|
|
643
793
|
return;
|
|
@@ -682,8 +832,124 @@ function useAccounts() {
|
|
|
682
832
|
};
|
|
683
833
|
}
|
|
684
834
|
|
|
835
|
+
// src/react/profiles.ts
|
|
836
|
+
import { useCallback as useCallback4, useEffect as useEffect7, useRef as useRef2, useState as useState8 } from "react";
|
|
837
|
+
var PROFILE_CHANGED = "relay-profile-changed";
|
|
838
|
+
function useMyProfile() {
|
|
839
|
+
const relay = useRelay();
|
|
840
|
+
const { member } = useExperience();
|
|
841
|
+
const [profile, setProfile] = useState8(null);
|
|
842
|
+
const [error, setError] = useState8(null);
|
|
843
|
+
const [busy, setBusy] = useState8(false);
|
|
844
|
+
const session = useRef2(null);
|
|
845
|
+
const refresh = useCallback4(async () => {
|
|
846
|
+
try {
|
|
847
|
+
const [current, value] = await Promise.all([
|
|
848
|
+
relay.auth.session(),
|
|
849
|
+
relay.profiles.mine()
|
|
850
|
+
]);
|
|
851
|
+
session.current = current?.id ?? null;
|
|
852
|
+
setProfile(value);
|
|
853
|
+
setError(null);
|
|
854
|
+
} catch (cause) {
|
|
855
|
+
setError(
|
|
856
|
+
cause instanceof Error && cause.message ? cause.message : "Could not load your profile."
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
}, [relay]);
|
|
860
|
+
useEffect7(() => {
|
|
861
|
+
if (!member) {
|
|
862
|
+
setProfile(null);
|
|
863
|
+
session.current = null;
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
const update = () => void refresh();
|
|
867
|
+
update();
|
|
868
|
+
window.addEventListener("focus", update);
|
|
869
|
+
window.addEventListener(PROFILE_CHANGED, update);
|
|
870
|
+
return () => {
|
|
871
|
+
window.removeEventListener("focus", update);
|
|
872
|
+
window.removeEventListener(PROFILE_CHANGED, update);
|
|
873
|
+
};
|
|
874
|
+
}, [member, refresh]);
|
|
875
|
+
async function run(task, fallback) {
|
|
876
|
+
setBusy(true);
|
|
877
|
+
setError(null);
|
|
878
|
+
try {
|
|
879
|
+
const value = await task(session.current ?? void 0);
|
|
880
|
+
setProfile(value);
|
|
881
|
+
window.dispatchEvent(new Event(PROFILE_CHANGED));
|
|
882
|
+
return true;
|
|
883
|
+
} catch (cause) {
|
|
884
|
+
setError(
|
|
885
|
+
cause instanceof Error && cause.message ? cause.message : fallback
|
|
886
|
+
);
|
|
887
|
+
return false;
|
|
888
|
+
} finally {
|
|
889
|
+
setBusy(false);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
return {
|
|
893
|
+
/** Null until read, and while nobody is signed in. */
|
|
894
|
+
profile,
|
|
895
|
+
error,
|
|
896
|
+
busy,
|
|
897
|
+
refresh,
|
|
898
|
+
/** Resolves true once saved; a failure sets `error`. */
|
|
899
|
+
update: (input) => run(
|
|
900
|
+
(value) => relay.profiles.update(input, { session: value }),
|
|
901
|
+
"Couldn't save your profile. Try again."
|
|
902
|
+
),
|
|
903
|
+
/** Uploads a JPEG, PNG or WebP of at most 5 MB as the avatar; resolves true once saved. */
|
|
904
|
+
uploadAvatar: (file) => run(
|
|
905
|
+
(value) => relay.profiles.uploadAvatar(file, {
|
|
906
|
+
uploadId: crypto.randomUUID(),
|
|
907
|
+
session: value
|
|
908
|
+
}),
|
|
909
|
+
"Couldn't upload this picture. Try again."
|
|
910
|
+
)
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function useProfile(id, options = {}) {
|
|
914
|
+
const relay = useRelay();
|
|
915
|
+
const { member } = useExperience();
|
|
916
|
+
const { intervalMs = 6e4 } = options;
|
|
917
|
+
const [state, setState] = useState8({ status: "loading" });
|
|
918
|
+
const refresh = useCallback4(async () => {
|
|
919
|
+
try {
|
|
920
|
+
const profile = await relay.profiles.get(id);
|
|
921
|
+
setState({ status: "ready", profile, stale: null });
|
|
922
|
+
} catch (cause) {
|
|
923
|
+
if (cause instanceof RelayError && cause.status === 404) {
|
|
924
|
+
setState({ status: "missing" });
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
const message = cause instanceof Error && cause.message ? cause.message : "Could not load the profile.";
|
|
928
|
+
setState(
|
|
929
|
+
(previous) => previous.status === "ready" ? { ...previous, stale: message } : { status: "error", message }
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
}, [relay, id]);
|
|
933
|
+
useEffect7(() => {
|
|
934
|
+
setState({ status: "loading" });
|
|
935
|
+
void refresh();
|
|
936
|
+
const timer = setInterval(() => {
|
|
937
|
+
if (document.visibilityState === "visible") {
|
|
938
|
+
void refresh();
|
|
939
|
+
}
|
|
940
|
+
}, intervalMs);
|
|
941
|
+
const changed = () => void refresh();
|
|
942
|
+
window.addEventListener(PROFILE_CHANGED, changed);
|
|
943
|
+
return () => {
|
|
944
|
+
clearInterval(timer);
|
|
945
|
+
window.removeEventListener(PROFILE_CHANGED, changed);
|
|
946
|
+
};
|
|
947
|
+
}, [refresh, member, intervalMs]);
|
|
948
|
+
return { ...state, refresh };
|
|
949
|
+
}
|
|
950
|
+
|
|
685
951
|
// src/react/referrals.ts
|
|
686
|
-
import { useCallback as
|
|
952
|
+
import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef3, useState as useState9 } from "react";
|
|
687
953
|
var PENDING = "domino:pending-referral";
|
|
688
954
|
var CODE = /^[a-zA-Z0-9_-]{1,100}$/;
|
|
689
955
|
function captureReferralCode(param = "ref") {
|
|
@@ -709,12 +975,12 @@ function forgetReferralCode() {
|
|
|
709
975
|
function useInvitation(param = "ref") {
|
|
710
976
|
const relay = useRelay();
|
|
711
977
|
const { member } = useExperience();
|
|
712
|
-
const [state, setState] =
|
|
978
|
+
const [state, setState] = useState9(() => {
|
|
713
979
|
const code = captureReferralCode(param);
|
|
714
980
|
return code ? { status: "pending", code } : { status: "none" };
|
|
715
981
|
});
|
|
716
|
-
const started =
|
|
717
|
-
const accept =
|
|
982
|
+
const started = useRef3(null);
|
|
983
|
+
const accept = useCallback5(
|
|
718
984
|
async (code) => {
|
|
719
985
|
setState({ status: "accepting", code });
|
|
720
986
|
try {
|
|
@@ -735,7 +1001,7 @@ function useInvitation(param = "ref") {
|
|
|
735
1001
|
},
|
|
736
1002
|
[relay]
|
|
737
1003
|
);
|
|
738
|
-
|
|
1004
|
+
useEffect8(() => {
|
|
739
1005
|
if (member && state.status === "pending" && started.current !== `${member}:${state.code}`) {
|
|
740
1006
|
started.current = `${member}:${state.code}`;
|
|
741
1007
|
void accept(state.code);
|
|
@@ -746,9 +1012,9 @@ function useInvitation(param = "ref") {
|
|
|
746
1012
|
function useReferralSummary(options = {}) {
|
|
747
1013
|
const relay = useRelay();
|
|
748
1014
|
const { member } = useExperience();
|
|
749
|
-
const [summary, setSummary] =
|
|
750
|
-
const [error, setError] =
|
|
751
|
-
const refresh =
|
|
1015
|
+
const [summary, setSummary] = useState9(null);
|
|
1016
|
+
const [error, setError] = useState9(null);
|
|
1017
|
+
const refresh = useCallback5(async () => {
|
|
752
1018
|
try {
|
|
753
1019
|
setSummary(await relay.referrals.summary());
|
|
754
1020
|
setError(null);
|
|
@@ -758,7 +1024,7 @@ function useReferralSummary(options = {}) {
|
|
|
758
1024
|
);
|
|
759
1025
|
}
|
|
760
1026
|
}, [relay]);
|
|
761
|
-
|
|
1027
|
+
useEffect8(() => {
|
|
762
1028
|
setSummary(null);
|
|
763
1029
|
if (member) {
|
|
764
1030
|
void refresh();
|
|
@@ -774,13 +1040,13 @@ function useReferralSummary(options = {}) {
|
|
|
774
1040
|
}
|
|
775
1041
|
|
|
776
1042
|
// src/react/leaderboards.ts
|
|
777
|
-
import { useCallback as
|
|
1043
|
+
import { useCallback as useCallback6, useEffect as useEffect9, useState as useState10 } from "react";
|
|
778
1044
|
function useLeaderboard(board, options = {}) {
|
|
779
1045
|
const relay = useRelay();
|
|
780
1046
|
const { member } = useExperience();
|
|
781
1047
|
const { limit = 25, intervalMs = 3e4 } = options;
|
|
782
|
-
const [state, setState] =
|
|
783
|
-
const refresh =
|
|
1048
|
+
const [state, setState] = useState10({ status: "loading" });
|
|
1049
|
+
const refresh = useCallback6(async () => {
|
|
784
1050
|
try {
|
|
785
1051
|
const page = await relay.leaderboards.standings(board, { limit });
|
|
786
1052
|
setState({ status: "ready", page, stale: null });
|
|
@@ -791,7 +1057,7 @@ function useLeaderboard(board, options = {}) {
|
|
|
791
1057
|
);
|
|
792
1058
|
}
|
|
793
1059
|
}, [relay, board, limit]);
|
|
794
|
-
|
|
1060
|
+
useEffect9(() => {
|
|
795
1061
|
void refresh();
|
|
796
1062
|
const timer = setInterval(() => {
|
|
797
1063
|
if (document.visibilityState === "visible") {
|
|
@@ -804,11 +1070,11 @@ function useLeaderboard(board, options = {}) {
|
|
|
804
1070
|
}
|
|
805
1071
|
|
|
806
1072
|
// src/react/references.ts
|
|
807
|
-
import { useCallback as
|
|
1073
|
+
import { useCallback as useCallback7, useEffect as useEffect10, useState as useState11 } from "react";
|
|
808
1074
|
function useReferences(read, failure) {
|
|
809
1075
|
const relay = useRelay();
|
|
810
|
-
const [state, setState] =
|
|
811
|
-
const refresh =
|
|
1076
|
+
const [state, setState] = useState11({ status: "loading" });
|
|
1077
|
+
const refresh = useCallback7(async () => {
|
|
812
1078
|
try {
|
|
813
1079
|
setState({ status: "ready", items: await read(relay) });
|
|
814
1080
|
} catch (cause) {
|
|
@@ -818,7 +1084,7 @@ function useReferences(read, failure) {
|
|
|
818
1084
|
});
|
|
819
1085
|
}
|
|
820
1086
|
}, [relay, read, failure]);
|
|
821
|
-
|
|
1087
|
+
useEffect10(() => {
|
|
822
1088
|
void refresh();
|
|
823
1089
|
}, [refresh]);
|
|
824
1090
|
return { ...state, refresh };
|
|
@@ -833,13 +1099,16 @@ function useTieredRewards() {
|
|
|
833
1099
|
}
|
|
834
1100
|
export {
|
|
835
1101
|
PENDING_POLL_MS,
|
|
1102
|
+
PROFILE_CHANGED,
|
|
836
1103
|
RETRY_DELAYS_MS,
|
|
837
1104
|
RelayProvider,
|
|
1105
|
+
avatarSrc,
|
|
838
1106
|
canRepeat,
|
|
839
1107
|
canSubmit,
|
|
840
1108
|
captureReferralCode,
|
|
841
1109
|
completionCountLabel,
|
|
842
1110
|
completionMark,
|
|
1111
|
+
defaultAvatar,
|
|
843
1112
|
hasPending,
|
|
844
1113
|
isAutomatic,
|
|
845
1114
|
isConnected,
|
|
@@ -854,14 +1123,21 @@ export {
|
|
|
854
1123
|
useExperience,
|
|
855
1124
|
useInvitation,
|
|
856
1125
|
useLeaderboard,
|
|
1126
|
+
useMe,
|
|
1127
|
+
useMyProfile,
|
|
857
1128
|
usePointLedgers,
|
|
1129
|
+
useProfile,
|
|
858
1130
|
useQuest,
|
|
859
1131
|
useReferralSummary,
|
|
860
1132
|
useRelay,
|
|
861
1133
|
useSignIn,
|
|
862
1134
|
useSignInMethods,
|
|
1135
|
+
useSignInWallets,
|
|
863
1136
|
useSignOut,
|
|
864
1137
|
useTieredRewards,
|
|
1138
|
+
useWalletDiscovery,
|
|
1139
|
+
useWallets,
|
|
865
1140
|
visibleQuests,
|
|
1141
|
+
walletAvatarSeed,
|
|
866
1142
|
watchRoleDeliveries
|
|
867
1143
|
};
|
package/dist/schema.d.ts
CHANGED
|
@@ -145,6 +145,17 @@ declare const triggerSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
145
145
|
claim: "claim";
|
|
146
146
|
}>>;
|
|
147
147
|
}, z.core.$strict>>;
|
|
148
|
+
tracker: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
tracker: z.ZodString;
|
|
150
|
+
source: z.ZodEnum<{
|
|
151
|
+
custom: "custom";
|
|
152
|
+
"x-search": "x-search";
|
|
153
|
+
}>;
|
|
154
|
+
beneficiary: z.ZodEnum<{
|
|
155
|
+
author: "author";
|
|
156
|
+
"replied-to": "replied-to";
|
|
157
|
+
}>;
|
|
158
|
+
}, z.core.$strict>>;
|
|
148
159
|
}, z.core.$strict>]>;
|
|
149
160
|
declare const prerequisiteSchema: z.ZodObject<{
|
|
150
161
|
quest: z.ZodString;
|
|
@@ -493,6 +504,17 @@ declare const questDescriptionSchema: z.ZodObject<{
|
|
|
493
504
|
claim: "claim";
|
|
494
505
|
}>>;
|
|
495
506
|
}, z.core.$strict>>;
|
|
507
|
+
tracker: z.ZodOptional<z.ZodObject<{
|
|
508
|
+
tracker: z.ZodString;
|
|
509
|
+
source: z.ZodEnum<{
|
|
510
|
+
custom: "custom";
|
|
511
|
+
"x-search": "x-search";
|
|
512
|
+
}>;
|
|
513
|
+
beneficiary: z.ZodEnum<{
|
|
514
|
+
author: "author";
|
|
515
|
+
"replied-to": "replied-to";
|
|
516
|
+
}>;
|
|
517
|
+
}, z.core.$strict>>;
|
|
496
518
|
}, z.core.$strict>]>;
|
|
497
519
|
performance: z.ZodOptional<z.ZodObject<{
|
|
498
520
|
metrics: z.ZodArray<z.ZodEnum<{
|
|
@@ -531,6 +553,7 @@ declare const questDescriptionSchema: z.ZodObject<{
|
|
|
531
553
|
period: z.ZodEnum<{
|
|
532
554
|
lifetime: "lifetime";
|
|
533
555
|
day: "day";
|
|
556
|
+
week: "week";
|
|
534
557
|
}>;
|
|
535
558
|
limit: z.ZodNumber;
|
|
536
559
|
cost: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
@@ -788,6 +811,17 @@ declare const publishedReleaseSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
788
811
|
claim: "claim";
|
|
789
812
|
}>>;
|
|
790
813
|
}, z.core.$strict>>;
|
|
814
|
+
tracker: z.ZodOptional<z.ZodObject<{
|
|
815
|
+
tracker: z.ZodString;
|
|
816
|
+
source: z.ZodEnum<{
|
|
817
|
+
custom: "custom";
|
|
818
|
+
"x-search": "x-search";
|
|
819
|
+
}>;
|
|
820
|
+
beneficiary: z.ZodEnum<{
|
|
821
|
+
author: "author";
|
|
822
|
+
"replied-to": "replied-to";
|
|
823
|
+
}>;
|
|
824
|
+
}, z.core.$strict>>;
|
|
791
825
|
}, z.core.$strict>]>;
|
|
792
826
|
performance: z.ZodOptional<z.ZodObject<{
|
|
793
827
|
metrics: z.ZodArray<z.ZodEnum<{
|
|
@@ -826,6 +860,7 @@ declare const publishedReleaseSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
826
860
|
period: z.ZodEnum<{
|
|
827
861
|
lifetime: "lifetime";
|
|
828
862
|
day: "day";
|
|
863
|
+
week: "week";
|
|
829
864
|
}>;
|
|
830
865
|
limit: z.ZodNumber;
|
|
831
866
|
cost: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
@@ -1060,6 +1095,11 @@ declare const publishedReleaseSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1060
1095
|
posts: "after-enrollment" | "since-start";
|
|
1061
1096
|
historical: "staff" | "automatic" | "claim";
|
|
1062
1097
|
} | undefined;
|
|
1098
|
+
tracker?: {
|
|
1099
|
+
tracker: string;
|
|
1100
|
+
source: "custom" | "x-search";
|
|
1101
|
+
beneficiary: "author" | "replied-to";
|
|
1102
|
+
} | undefined;
|
|
1063
1103
|
} | {
|
|
1064
1104
|
kind: "manual";
|
|
1065
1105
|
input: "text";
|
|
@@ -1099,7 +1139,7 @@ declare const publishedReleaseSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1099
1139
|
budgets: {
|
|
1100
1140
|
id: string;
|
|
1101
1141
|
scope: "member" | "project";
|
|
1102
|
-
period: "lifetime" | "day";
|
|
1142
|
+
period: "lifetime" | "day" | "week";
|
|
1103
1143
|
limit: number;
|
|
1104
1144
|
cost: number | {
|
|
1105
1145
|
balance: string;
|
|
@@ -1374,6 +1414,17 @@ declare const templateSchema: z.ZodObject<{
|
|
|
1374
1414
|
claim: "claim";
|
|
1375
1415
|
}>>;
|
|
1376
1416
|
}, z.core.$strict>>;
|
|
1417
|
+
tracker: z.ZodOptional<z.ZodObject<{
|
|
1418
|
+
tracker: z.ZodString;
|
|
1419
|
+
source: z.ZodEnum<{
|
|
1420
|
+
custom: "custom";
|
|
1421
|
+
"x-search": "x-search";
|
|
1422
|
+
}>;
|
|
1423
|
+
beneficiary: z.ZodEnum<{
|
|
1424
|
+
author: "author";
|
|
1425
|
+
"replied-to": "replied-to";
|
|
1426
|
+
}>;
|
|
1427
|
+
}, z.core.$strict>>;
|
|
1377
1428
|
}, z.core.$strict>]>;
|
|
1378
1429
|
performance: z.ZodOptional<z.ZodObject<{
|
|
1379
1430
|
metrics: z.ZodArray<z.ZodEnum<{
|
|
@@ -1412,6 +1463,7 @@ declare const templateSchema: z.ZodObject<{
|
|
|
1412
1463
|
period: z.ZodEnum<{
|
|
1413
1464
|
lifetime: "lifetime";
|
|
1414
1465
|
day: "day";
|
|
1466
|
+
week: "week";
|
|
1415
1467
|
}>;
|
|
1416
1468
|
limit: z.ZodNumber;
|
|
1417
1469
|
cost: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
@@ -1840,6 +1892,17 @@ declare const memberProgressSchema: z.ZodObject<{
|
|
|
1840
1892
|
claim: "claim";
|
|
1841
1893
|
}>>;
|
|
1842
1894
|
}, z.core.$strict>>;
|
|
1895
|
+
tracker: z.ZodOptional<z.ZodObject<{
|
|
1896
|
+
tracker: z.ZodString;
|
|
1897
|
+
source: z.ZodEnum<{
|
|
1898
|
+
custom: "custom";
|
|
1899
|
+
"x-search": "x-search";
|
|
1900
|
+
}>;
|
|
1901
|
+
beneficiary: z.ZodEnum<{
|
|
1902
|
+
author: "author";
|
|
1903
|
+
"replied-to": "replied-to";
|
|
1904
|
+
}>;
|
|
1905
|
+
}, z.core.$strict>>;
|
|
1843
1906
|
}, z.core.$strict>]>;
|
|
1844
1907
|
availability: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1845
1908
|
kind: z.ZodLiteral<"available">;
|
|
@@ -2260,6 +2323,17 @@ declare const snapshotSchema: z.ZodObject<{
|
|
|
2260
2323
|
claim: "claim";
|
|
2261
2324
|
}>>;
|
|
2262
2325
|
}, z.core.$strict>>;
|
|
2326
|
+
tracker: z.ZodOptional<z.ZodObject<{
|
|
2327
|
+
tracker: z.ZodString;
|
|
2328
|
+
source: z.ZodEnum<{
|
|
2329
|
+
custom: "custom";
|
|
2330
|
+
"x-search": "x-search";
|
|
2331
|
+
}>;
|
|
2332
|
+
beneficiary: z.ZodEnum<{
|
|
2333
|
+
author: "author";
|
|
2334
|
+
"replied-to": "replied-to";
|
|
2335
|
+
}>;
|
|
2336
|
+
}, z.core.$strict>>;
|
|
2263
2337
|
}, z.core.$strict>]>;
|
|
2264
2338
|
performance: z.ZodOptional<z.ZodObject<{
|
|
2265
2339
|
metrics: z.ZodArray<z.ZodEnum<{
|
|
@@ -2298,6 +2372,7 @@ declare const snapshotSchema: z.ZodObject<{
|
|
|
2298
2372
|
period: z.ZodEnum<{
|
|
2299
2373
|
lifetime: "lifetime";
|
|
2300
2374
|
day: "day";
|
|
2375
|
+
week: "week";
|
|
2301
2376
|
}>;
|
|
2302
2377
|
limit: z.ZodNumber;
|
|
2303
2378
|
cost: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
@@ -2532,6 +2607,11 @@ declare const snapshotSchema: z.ZodObject<{
|
|
|
2532
2607
|
posts: "after-enrollment" | "since-start";
|
|
2533
2608
|
historical: "staff" | "automatic" | "claim";
|
|
2534
2609
|
} | undefined;
|
|
2610
|
+
tracker?: {
|
|
2611
|
+
tracker: string;
|
|
2612
|
+
source: "custom" | "x-search";
|
|
2613
|
+
beneficiary: "author" | "replied-to";
|
|
2614
|
+
} | undefined;
|
|
2535
2615
|
} | {
|
|
2536
2616
|
kind: "manual";
|
|
2537
2617
|
input: "text";
|
|
@@ -2571,7 +2651,7 @@ declare const snapshotSchema: z.ZodObject<{
|
|
|
2571
2651
|
budgets: {
|
|
2572
2652
|
id: string;
|
|
2573
2653
|
scope: "member" | "project";
|
|
2574
|
-
period: "lifetime" | "day";
|
|
2654
|
+
period: "lifetime" | "day" | "week";
|
|
2575
2655
|
limit: number;
|
|
2576
2656
|
cost: number | {
|
|
2577
2657
|
balance: string;
|