@zing-protocol/zing-sdk 0.0.1 → 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/dist/_generated/index.js +6 -0
- package/dist/_generated/utils/index.d.ts +12 -0
- package/dist/_generated/utils/index.js +135 -0
- package/dist/_generated/zing_framework/coin_utils.d.ts +15 -0
- package/dist/_generated/zing_framework/coin_utils.js +19 -0
- package/dist/_generated/zing_framework/deps/sui/object.d.ts +8 -0
- package/{src/_generated/zing_governance/deps/sui/object.ts → dist/_generated/zing_framework/deps/sui/object.js} +4 -7
- package/dist/_generated/zing_framework/derived_object_bag.d.ts +166 -0
- package/dist/_generated/zing_framework/derived_object_bag.js +221 -0
- package/dist/_generated/zing_framework/derived_table.d.ts +153 -0
- package/dist/_generated/zing_framework/derived_table.js +200 -0
- package/dist/_generated/zing_governance/admin.d.ts +20 -0
- package/dist/_generated/zing_governance/admin.js +26 -0
- package/dist/_generated/zing_governance/deps/sui/object.d.ts +8 -0
- package/{src/_generated/zing_identity/deps/sui/object.ts → dist/_generated/zing_governance/deps/sui/object.js} +4 -7
- package/dist/_generated/zing_governance/treasury.d.ts +56 -0
- package/dist/_generated/zing_governance/treasury.js +78 -0
- package/dist/_generated/zing_identity/config.d.ts +87 -0
- package/dist/_generated/zing_identity/config.js +98 -0
- package/{src/_generated/zing_studio/deps/std/type_name.ts → dist/_generated/zing_identity/deps/std/type_name.d.ts} +3 -11
- package/dist/_generated/zing_identity/deps/std/type_name.js +22 -0
- package/dist/_generated/zing_identity/deps/sui/object.d.ts +8 -0
- package/{src/_generated/zing_studio/deps/sui/object.ts → dist/_generated/zing_identity/deps/sui/object.js} +4 -7
- package/dist/_generated/zing_identity/deps/sui/object_table.d.ts +12 -0
- package/{src/_generated/zing_identity/deps/sui/object_table.ts → dist/_generated/zing_identity/deps/sui/object_table.js} +7 -10
- package/dist/_generated/zing_identity/deps/sui/table.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/sui/table.ts → dist/_generated/zing_identity/deps/sui/table.js} +7 -10
- package/{src/_generated/zing_identity/deps/sui/vec_set.ts → dist/_generated/zing_identity/deps/sui/vec_set.d.ts} +3 -14
- package/dist/_generated/zing_identity/deps/sui/vec_set.js +22 -0
- package/dist/_generated/zing_identity/ecdsa.d.ts +81 -0
- package/dist/_generated/zing_identity/ecdsa.js +87 -0
- package/dist/_generated/zing_identity/identity.d.ts +262 -0
- package/dist/_generated/zing_identity/identity.js +294 -0
- package/dist/_generated/zing_identity/reclaim.d.ts +356 -0
- package/dist/_generated/zing_identity/reclaim.js +414 -0
- package/dist/_generated/zing_studio/app.d.ts +351 -0
- package/dist/_generated/zing_studio/app.js +451 -0
- package/dist/_generated/zing_studio/article.d.ts +331 -0
- package/dist/_generated/zing_studio/article.js +331 -0
- package/dist/_generated/zing_studio/config.d.ts +203 -0
- package/dist/_generated/zing_studio/config.js +233 -0
- package/{src/_generated/zing_identity/deps/std/type_name.ts → dist/_generated/zing_studio/deps/std/type_name.d.ts} +3 -11
- package/dist/_generated/zing_studio/deps/std/type_name.js +22 -0
- package/dist/_generated/zing_studio/deps/sui/bag.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/sui/bag.ts → dist/_generated/zing_studio/deps/sui/bag.js} +7 -10
- package/dist/_generated/zing_studio/deps/sui/balance.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/sui/balance.ts → dist/_generated/zing_studio/deps/sui/balance.js} +4 -7
- package/dist/_generated/zing_studio/deps/sui/coin.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/sui/coin.ts → dist/_generated/zing_studio/deps/sui/coin.js} +5 -8
- package/dist/_generated/zing_studio/deps/sui/dynamic_field.d.ts +126 -0
- package/dist/_generated/zing_studio/deps/sui/dynamic_field.js +140 -0
- package/dist/_generated/zing_studio/deps/sui/object.d.ts +8 -0
- package/{src/_generated/zing_framework/deps/sui/object.ts → dist/_generated/zing_studio/deps/sui/object.js} +4 -7
- package/dist/_generated/zing_studio/deps/sui/table.d.ts +12 -0
- package/{src/_generated/zing_identity/deps/sui/table.ts → dist/_generated/zing_studio/deps/sui/table.js} +7 -10
- package/dist/_generated/zing_studio/deps/sui/vec_map.d.ts +30 -0
- package/{src/_generated/zing_studio/deps/sui/vec_map.ts → dist/_generated/zing_studio/deps/sui/vec_map.js} +15 -21
- package/{src/_generated/zing_studio/deps/sui/vec_set.ts → dist/_generated/zing_studio/deps/sui/vec_set.d.ts} +3 -14
- package/dist/_generated/zing_studio/deps/sui/vec_set.js +22 -0
- package/dist/_generated/zing_studio/deps/walrus/blob.d.ts +20 -0
- package/{src/_generated/zing_studio/deps/walrus/blob.ts → dist/_generated/zing_studio/deps/walrus/blob.js} +11 -12
- package/dist/_generated/zing_studio/deps/walrus/events.d.ts +83 -0
- package/dist/_generated/zing_studio/deps/walrus/events.js +122 -0
- package/dist/_generated/zing_studio/deps/walrus/metadata.d.ts +71 -0
- package/dist/_generated/zing_studio/deps/walrus/metadata.js +73 -0
- package/dist/_generated/zing_studio/deps/walrus/storage_resource.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/walrus/storage_resource.ts → dist/_generated/zing_studio/deps/walrus/storage_resource.js} +7 -8
- package/dist/_generated/zing_studio/deps/zing_framework/derived_object_bag.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/zing_framework/derived_object_bag.ts → dist/_generated/zing_studio/deps/zing_framework/derived_object_bag.js} +7 -8
- package/dist/_generated/zing_studio/deps/zing_framework/derived_table.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/zing_framework/derived_table.ts → dist/_generated/zing_studio/deps/zing_framework/derived_table.js} +7 -8
- package/dist/_generated/zing_studio/donation.d.ts +24 -0
- package/{src/_generated/zing_studio/donation.ts → dist/_generated/zing_studio/donation.js} +7 -8
- package/dist/_generated/zing_studio/enclave.d.ts +187 -0
- package/dist/_generated/zing_studio/enclave.js +231 -0
- package/dist/_generated/zing_studio/nitro_attestation.d.ts +148 -0
- package/dist/_generated/zing_studio/nitro_attestation.js +183 -0
- package/dist/_generated/zing_studio/referral.d.ts +166 -0
- package/dist/_generated/zing_studio/referral.js +224 -0
- package/dist/_generated/zing_studio/storage.d.ts +327 -0
- package/dist/_generated/zing_studio/storage.js +365 -0
- package/dist/_generated/zing_studio/studio.d.ts +282 -0
- package/dist/_generated/zing_studio/studio.js +360 -0
- package/dist/bcs.d.ts +61 -0
- package/dist/bcs.js +109 -0
- package/dist/client/index.d.ts +228 -0
- package/dist/client/index.js +296 -0
- package/dist/client/types.d.ts +23 -0
- package/dist/client/types.js +1 -0
- package/dist/components/index.js +3 -0
- package/dist/components/wallet-provider.d.ts +7 -0
- package/dist/components/wallet-provider.js +33 -0
- package/dist/components/walrus-provider.d.ts +31 -0
- package/dist/components/walrus-provider.js +71 -0
- package/dist/components/zing-provider.d.ts +15 -0
- package/dist/components/zing-provider.js +22 -0
- package/dist/config/common.d.ts +23 -0
- package/dist/config/common.js +61 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +28 -0
- package/dist/config/mainnet.d.ts +6 -0
- package/dist/config/mainnet.js +80 -0
- package/dist/config/testnet.d.ts +6 -0
- package/dist/config/testnet.js +81 -0
- package/dist/config/types.d.ts +49 -0
- package/dist/config/types.js +1 -0
- package/dist/const.d.ts +4 -0
- package/dist/const.js +25 -0
- package/dist/getters.d.ts +228 -0
- package/dist/getters.js +317 -0
- package/{src/hooks/index.ts → dist/hooks/index.d.ts} +2 -3
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/useGetStudio.d.ts +26 -0
- package/dist/hooks/useGetStudio.js +17 -0
- package/dist/hooks/useGetTierPlan.d.ts +7 -0
- package/dist/hooks/useGetTierPlan.js +85 -0
- package/dist/hooks/useReclaim.d.ts +12 -0
- package/dist/hooks/useReclaim.js +87 -0
- package/dist/hooks/useSignAndExecuteTransaction.d.ts +6 -0
- package/dist/hooks/useSignAndExecuteTransaction.js +40 -0
- package/dist/hooks/useSignPersonalMessage.d.ts +8 -0
- package/dist/hooks/useSignPersonalMessage.js +21 -0
- package/dist/hooks/useZingInfiniteQueries.d.ts +75 -0
- package/dist/hooks/useZingInfiniteQueries.js +28 -0
- package/dist/hooks/useZingMutation.d.ts +35 -0
- package/dist/hooks/useZingMutation.js +37 -0
- package/dist/hooks/useZingQueries.d.ts +127 -0
- package/dist/hooks/useZingQueries.js +37 -0
- package/dist/hooks/useZingQuery.d.ts +147 -0
- package/dist/hooks/useZingQuery.js +34 -0
- package/{src/index.ts → dist/index.d.ts} +2 -3
- package/dist/index.js +9 -0
- package/dist/lib/utils/colorful-logger.d.ts +2 -0
- package/dist/lib/utils/colorful-logger.js +23 -0
- package/dist/lib/utils/const.d.ts +25 -0
- package/dist/lib/utils/const.js +25 -0
- package/dist/lib/utils/helpers.d.ts +10 -0
- package/dist/lib/utils/helpers.js +49 -0
- package/dist/lib/utils/index.js +4 -0
- package/dist/lib/utils/init-app-with-shadow.d.ts +6 -0
- package/dist/lib/utils/init-app-with-shadow.js +28 -0
- package/dist/lib/utils/quilt.d.ts +61 -0
- package/dist/lib/utils/quilt.js +194 -0
- package/dist/lib/utils/reclaim.d.ts +29 -0
- package/dist/lib/utils/reclaim.js +88 -0
- package/dist/lib/utils/types.d.ts +5 -0
- package/dist/lib/utils/types.js +1 -0
- package/dist/mutations/index.js +3 -0
- package/dist/mutations/seal.d.ts +12 -0
- package/dist/mutations/seal.js +41 -0
- package/dist/mutations/signer.d.ts +10 -0
- package/dist/mutations/signer.js +176 -0
- package/dist/mutations/walrus.d.ts +98 -0
- package/dist/mutations/walrus.js +488 -0
- package/dist/stores/index.js +3 -0
- package/dist/stores/walletStore.d.ts +48 -0
- package/dist/stores/walletStore.js +232 -0
- package/dist/stores/walrusStore.d.ts +28 -0
- package/dist/stores/walrusStore.js +61 -0
- package/dist/stores/zkloginStore.d.ts +28 -0
- package/dist/stores/zkloginStore.js +27 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.js +1 -0
- package/package.json +18 -10
- package/src/_generated/utils/index.ts +0 -181
- package/src/_generated/zing_framework/coin_utils.ts +0 -41
- package/src/_generated/zing_framework/derived_object_bag.ts +0 -400
- package/src/_generated/zing_framework/derived_table.ts +0 -366
- package/src/_generated/zing_governance/admin.ts +0 -47
- package/src/_generated/zing_governance/treasury.ts +0 -134
- package/src/_generated/zing_identity/config.ts +0 -191
- package/src/_generated/zing_identity/ecdsa.ts +0 -166
- package/src/_generated/zing_identity/identity.ts +0 -661
- package/src/_generated/zing_identity/reclaim.ts +0 -803
- package/src/_generated/zing_studio/app.ts +0 -855
- package/src/_generated/zing_studio/article.ts +0 -598
- package/src/_generated/zing_studio/config.ts +0 -475
- package/src/_generated/zing_studio/deps/sui/dynamic_field.ts +0 -272
- package/src/_generated/zing_studio/deps/walrus/events.ts +0 -124
- package/src/_generated/zing_studio/deps/walrus/metadata.ts +0 -137
- package/src/_generated/zing_studio/enclave.ts +0 -466
- package/src/_generated/zing_studio/nitro_attestation.ts +0 -308
- package/src/_generated/zing_studio/referral.ts +0 -447
- package/src/_generated/zing_studio/storage.ts +0 -664
- package/src/_generated/zing_studio/studio.ts +0 -682
- package/src/bcs.ts +0 -139
- package/src/client/index.ts +0 -557
- package/src/client/types.ts +0 -28
- package/src/components/wallet-provider.tsx +0 -53
- package/src/components/walrus-provider.tsx +0 -212
- package/src/components/zing-provider.tsx +0 -54
- package/src/config/common.ts +0 -82
- package/src/config/index.ts +0 -45
- package/src/config/mainnet.ts +0 -109
- package/src/config/testnet.ts +0 -111
- package/src/config/types.ts +0 -69
- package/src/const.ts +0 -32
- package/src/getters.ts +0 -523
- package/src/hooks/useGetStudio.ts +0 -22
- package/src/hooks/useGetTierPlan.ts +0 -115
- package/src/hooks/useReclaim.ts +0 -165
- package/src/hooks/useSignAndExecuteTransaction.ts +0 -57
- package/src/hooks/useSignPersonalMessage.ts +0 -28
- package/src/hooks/useZingInfiniteQueries.ts +0 -92
- package/src/hooks/useZingMutation.ts +0 -66
- package/src/hooks/useZingQueries.ts +0 -107
- package/src/hooks/useZingQuery.ts +0 -88
- package/src/lib/utils/colorful-logger.ts +0 -27
- package/src/lib/utils/const.ts +0 -25
- package/src/lib/utils/helpers.ts +0 -78
- package/src/lib/utils/init-app-with-shadow.ts +0 -42
- package/src/lib/utils/quilt.ts +0 -317
- package/src/lib/utils/reclaim.ts +0 -148
- package/src/lib/utils/types.ts +0 -14
- package/src/mutations/seal.ts +0 -78
- package/src/mutations/signer.ts +0 -241
- package/src/mutations/walrus.ts +0 -862
- package/src/stores/walletStore.ts +0 -360
- package/src/stores/walrusStore.ts +0 -118
- package/src/stores/zkloginStore.ts +0 -53
- package/src/types.ts +0 -120
- package/tsconfig.json +0 -12
- /package/{src/_generated/index.js → dist/_generated/index.d.ts} +0 -0
- /package/{src/components/index.ts → dist/components/index.d.ts} +0 -0
- /package/{src/lib/utils/index.ts → dist/lib/utils/index.d.ts} +0 -0
- /package/{src/mutations/index.ts → dist/mutations/index.d.ts} +0 -0
- /package/{src/stores/index.ts → dist/stores/index.d.ts} +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ZingClient } from "../client/index.js";
|
|
2
|
+
import type { SuiNetwork } from "../types.js";
|
|
3
|
+
import type { UseInfiniteQueryOptions, InfiniteData } from "@tanstack/react-query";
|
|
4
|
+
declare const zingInfiniteQueryMethodMap: (zingClient: ZingClient) => {
|
|
5
|
+
getMembers: (owner: string, cursor?: string, limit?: number) => Promise<{
|
|
6
|
+
data: {
|
|
7
|
+
member: string;
|
|
8
|
+
level: number;
|
|
9
|
+
expiredAt: string;
|
|
10
|
+
}[];
|
|
11
|
+
nextCursor: string | undefined;
|
|
12
|
+
hasNextPage: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
getWorks: (walrusSystem: import("../index.js").WalrusSystemState, owner: string, workType?: import("../index.js").WorkType, cursor?: string, limit?: number) => Promise<{
|
|
15
|
+
data: {
|
|
16
|
+
id: {
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
owner: string;
|
|
20
|
+
deleted: boolean;
|
|
21
|
+
created_at: string;
|
|
22
|
+
subscription_level: number | null;
|
|
23
|
+
blobs: {
|
|
24
|
+
id: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
registered_epoch: number;
|
|
28
|
+
blob_id: string;
|
|
29
|
+
size: string;
|
|
30
|
+
encoding_type: number;
|
|
31
|
+
certified_epoch: number | null;
|
|
32
|
+
storage: {
|
|
33
|
+
id: {
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
36
|
+
start_epoch: number;
|
|
37
|
+
end_epoch: number;
|
|
38
|
+
storage_size: string;
|
|
39
|
+
};
|
|
40
|
+
deletable: boolean;
|
|
41
|
+
}[];
|
|
42
|
+
files: {
|
|
43
|
+
contents: {
|
|
44
|
+
key: string;
|
|
45
|
+
value: {
|
|
46
|
+
blob_index: string;
|
|
47
|
+
mime_type: string;
|
|
48
|
+
size: string;
|
|
49
|
+
};
|
|
50
|
+
}[];
|
|
51
|
+
};
|
|
52
|
+
}[];
|
|
53
|
+
nextCursor: string | undefined;
|
|
54
|
+
hasNextPage: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
};
|
|
57
|
+
type ZingInfiniteQueryMethods = ReturnType<typeof zingInfiniteQueryMethodMap>;
|
|
58
|
+
type ExtractParams<T> = T extends (...args: infer P) => any ? P : never;
|
|
59
|
+
type InfiniteMethodParamsMap = {
|
|
60
|
+
[K in keyof ZingInfiniteQueryMethods]: ExtractParams<ZingInfiniteQueryMethods[K]>;
|
|
61
|
+
};
|
|
62
|
+
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
63
|
+
type ExtractReturnType<T> = T extends (...args: any[]) => infer R ? R : never;
|
|
64
|
+
type UseZingInfiniteQueryParams<K extends keyof InfiniteMethodParamsMap> = {
|
|
65
|
+
method: K;
|
|
66
|
+
params: InfiniteMethodParamsMap[K];
|
|
67
|
+
limit?: number;
|
|
68
|
+
};
|
|
69
|
+
type ExtraInfiniteQueryOptions<TData = unknown> = Partial<Pick<UseInfiniteQueryOptions<TData, Error, InfiniteData<TData>, readonly unknown[], string | undefined>, "enabled" | "gcTime" | "staleTime" | "retry">>;
|
|
70
|
+
export type InfiniteMethodReturnMap = {
|
|
71
|
+
[K in keyof ZingInfiniteQueryMethods]: UnwrapPromise<ExtractReturnType<ZingInfiniteQueryMethods[K]>>;
|
|
72
|
+
};
|
|
73
|
+
export declare function getZingInfiniteQueryKey<K extends keyof ZingInfiniteQueryMethods>(network: SuiNetwork, method: K, memo: string[]): readonly [string, K, string[]];
|
|
74
|
+
export declare function useZingInfiniteQuery<K extends keyof InfiniteMethodParamsMap>(input: UseZingInfiniteQueryParams<K>, options?: ExtraInfiniteQueryOptions<InfiniteMethodReturnMap[K]>, memo?: string[]): import("@tanstack/react-query").UseInfiniteQueryResult<InfiniteData<InfiniteMethodReturnMap[K], unknown>, Error>;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useZingClient } from "../components/zing-provider.js";
|
|
2
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
3
|
+
const zingInfiniteQueryMethodMap = (zingClient) => ({
|
|
4
|
+
getMembers: zingClient.getMembers.bind(zingClient),
|
|
5
|
+
getWorks: zingClient.getWorks.bind(zingClient),
|
|
6
|
+
});
|
|
7
|
+
export function getZingInfiniteQueryKey(network, method, memo) {
|
|
8
|
+
return [network, method, memo];
|
|
9
|
+
}
|
|
10
|
+
export function useZingInfiniteQuery(input, options = {}, memo = []) {
|
|
11
|
+
const zingClient = useZingClient();
|
|
12
|
+
const methodMap = zingInfiniteQueryMethodMap(zingClient);
|
|
13
|
+
const { method, params, limit = 20 } = input;
|
|
14
|
+
return useInfiniteQuery({
|
|
15
|
+
queryKey: [zingClient.network, method, memo],
|
|
16
|
+
queryFn: async ({ pageParam }) => {
|
|
17
|
+
const fn = methodMap[method];
|
|
18
|
+
// Call the function with spread params, cursor, and limit
|
|
19
|
+
return fn(...params, pageParam, limit);
|
|
20
|
+
},
|
|
21
|
+
initialPageParam: undefined,
|
|
22
|
+
getNextPageParam: (lastPage) => {
|
|
23
|
+
const nextCursor = lastPage?.nextCursor;
|
|
24
|
+
return nextCursor ?? undefined; // Convert null to undefined
|
|
25
|
+
},
|
|
26
|
+
...options,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import type { ZingClient } from "../client/index.js";
|
|
3
|
+
import type { TransactionEffects } from "@mysten/sui/client";
|
|
4
|
+
declare const zingMutationMethodMap: (zingClient: ZingClient) => {
|
|
5
|
+
subscribeToStudioTransaction: ({ sender, creatorAddress, subscriptionAmount, level, }: import("../client/types.js").SubscribeParams) => (tx: Transaction) => void;
|
|
6
|
+
purchaseStorageTierTransaction: ({ sender, objs, newTierIdx, balance, referrer, }: import("../client/types.js").PurchaseStorageTierParams) => (tx: Transaction) => void;
|
|
7
|
+
setMonthlySubscriptionFeeTransaction: ({ sender, monthlyFee, level, }: import("../client/types.js").SetMonthlySubscriptionFeeParams) => (tx: Transaction) => void;
|
|
8
|
+
updateArticleSubscriptionLevelTransaction: ({ sender, articleId, subscriptionLevel, }: {
|
|
9
|
+
sender: string;
|
|
10
|
+
articleId: string;
|
|
11
|
+
subscriptionLevel: null | number;
|
|
12
|
+
}) => (tx: Transaction) => void;
|
|
13
|
+
deleteArticleTransaction: ({ sender, articleId, }: {
|
|
14
|
+
sender: string;
|
|
15
|
+
articleId: string;
|
|
16
|
+
}) => (tx: Transaction) => void;
|
|
17
|
+
donateTransaction: ({ recipient, message, value, }: {
|
|
18
|
+
recipient: string;
|
|
19
|
+
message: string;
|
|
20
|
+
value: number;
|
|
21
|
+
}) => (tx: Transaction) => void;
|
|
22
|
+
};
|
|
23
|
+
type ZingMutationMethods = ReturnType<typeof zingMutationMethodMap>;
|
|
24
|
+
type ExtractParams<T> = T extends (arg: infer P) => any ? P : never;
|
|
25
|
+
type MethodParamsMap = {
|
|
26
|
+
[K in keyof ZingMutationMethods]: ExtractParams<ZingMutationMethods[K]>;
|
|
27
|
+
};
|
|
28
|
+
type UseZingMutationParams = {
|
|
29
|
+
[K in keyof ZingMutationMethods]: {
|
|
30
|
+
method: K;
|
|
31
|
+
params: MethodParamsMap[K];
|
|
32
|
+
};
|
|
33
|
+
}[keyof ZingMutationMethods];
|
|
34
|
+
export declare function useZingMutation(): import("@tanstack/react-query").UseMutationResult<TransactionEffects | null, Error, UseZingMutationParams, unknown>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useSignAndExecuteTransaction } from "./useSignAndExecuteTransaction.js";
|
|
2
|
+
import { useZingClient } from "../components/zing-provider.js";
|
|
3
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
4
|
+
import { useMutation } from "@tanstack/react-query";
|
|
5
|
+
// Only allows Transaction methods
|
|
6
|
+
const zingMutationMethodMap = (zingClient) => ({
|
|
7
|
+
subscribeToStudioTransaction: zingClient.subscribeToStudioTransaction.bind(zingClient),
|
|
8
|
+
purchaseStorageTierTransaction: zingClient.purchaseStorageTierTransaction.bind(zingClient),
|
|
9
|
+
setMonthlySubscriptionFeeTransaction: zingClient.setMonthlySubscriptionFeeTransaction.bind(zingClient),
|
|
10
|
+
updateArticleSubscriptionLevelTransaction: zingClient.updateArticleSubscriptionLevelTransaction.bind(zingClient),
|
|
11
|
+
deleteArticleTransaction: zingClient.deleteArticleTransaction.bind(zingClient),
|
|
12
|
+
donateTransaction: zingClient.donateTransaction.bind(zingClient),
|
|
13
|
+
});
|
|
14
|
+
export function useZingMutation() {
|
|
15
|
+
const zingClient = useZingClient();
|
|
16
|
+
const methodMap = zingMutationMethodMap(zingClient);
|
|
17
|
+
const { mutateAsync: signAndExecute } = useSignAndExecuteTransaction();
|
|
18
|
+
return useMutation({
|
|
19
|
+
mutationFn: async ({ method, params }) => {
|
|
20
|
+
const tx = new Transaction();
|
|
21
|
+
const builderFn = methodMap[method];
|
|
22
|
+
// builderFn receives a structured params object, not an array
|
|
23
|
+
const buildTx = builderFn(params);
|
|
24
|
+
buildTx(tx);
|
|
25
|
+
return signAndExecute({
|
|
26
|
+
transaction: tx,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
onSuccess: async (effects) => {
|
|
30
|
+
if (effects?.transactionDigest) {
|
|
31
|
+
await zingClient.suiJsonRpcClient.waitForTransaction({
|
|
32
|
+
digest: effects.transactionDigest,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ZingClient } from "../client/index.js";
|
|
2
|
+
import type { UseQueryOptions } from "@tanstack/react-query";
|
|
3
|
+
declare const zingQueryMethodMap: (zingClient: ZingClient) => {
|
|
4
|
+
getIdentifierByAddress: (platform: import("../index.js").PlatformType, address: string) => Promise<string | null>;
|
|
5
|
+
getIdentifierInfoByIdentifier: (platform: import("../index.js").PlatformType, identifier: string) => Promise<{
|
|
6
|
+
owner: string;
|
|
7
|
+
updated_at: string;
|
|
8
|
+
} | null>;
|
|
9
|
+
getStudio: (owner: string) => Promise<{
|
|
10
|
+
id: {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
owner: string;
|
|
14
|
+
period: string[];
|
|
15
|
+
monthly_subscription_fee: {
|
|
16
|
+
contents: {
|
|
17
|
+
key: number;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
membership: {
|
|
22
|
+
id: {
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
size: string;
|
|
26
|
+
};
|
|
27
|
+
works: {
|
|
28
|
+
id: {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
size: string;
|
|
32
|
+
};
|
|
33
|
+
encrypted_file_key: number[] | null;
|
|
34
|
+
} | null>;
|
|
35
|
+
getStorageSpace: (owner: string) => Promise<{
|
|
36
|
+
id: {
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
owner: string;
|
|
40
|
+
tier: number | null;
|
|
41
|
+
storage_used: {
|
|
42
|
+
contents: {
|
|
43
|
+
key: number;
|
|
44
|
+
value: string;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
credits: string;
|
|
48
|
+
} | null>;
|
|
49
|
+
getStorageTreasury: () => Promise<{
|
|
50
|
+
id: {
|
|
51
|
+
id: string;
|
|
52
|
+
};
|
|
53
|
+
tier_plan: {
|
|
54
|
+
contents: {
|
|
55
|
+
key: number;
|
|
56
|
+
value: {
|
|
57
|
+
price: string;
|
|
58
|
+
duration_days: number;
|
|
59
|
+
storage_limit: string;
|
|
60
|
+
};
|
|
61
|
+
}[];
|
|
62
|
+
};
|
|
63
|
+
storages_by_epoch: {
|
|
64
|
+
contents: {
|
|
65
|
+
key: number;
|
|
66
|
+
value: {
|
|
67
|
+
id: {
|
|
68
|
+
id: string;
|
|
69
|
+
};
|
|
70
|
+
start_epoch: number;
|
|
71
|
+
end_epoch: number;
|
|
72
|
+
storage_size: string;
|
|
73
|
+
};
|
|
74
|
+
}[];
|
|
75
|
+
};
|
|
76
|
+
wal_treasury: {
|
|
77
|
+
id: {
|
|
78
|
+
id: string;
|
|
79
|
+
};
|
|
80
|
+
balance: {
|
|
81
|
+
value: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
} | null>;
|
|
85
|
+
getMember: (owner: string, member: string) => Promise<{
|
|
86
|
+
level: number;
|
|
87
|
+
expired_at: string;
|
|
88
|
+
} | null>;
|
|
89
|
+
getBalance: (owner: string, coinSymbol: import("../index.js").CoinSymbol) => Promise<import("node_modules/@mysten/sui/dist/esm/grpc/proto/sui/rpc/v2/state_service.js").GetBalanceResponse>;
|
|
90
|
+
};
|
|
91
|
+
type ZingQueryMethods = ReturnType<typeof zingQueryMethodMap>;
|
|
92
|
+
type ExtractParams<T> = T extends (...args: infer P) => any ? P : never;
|
|
93
|
+
type MethodParamsMap = {
|
|
94
|
+
[K in keyof ZingQueryMethods]: ExtractParams<ZingQueryMethods[K]>;
|
|
95
|
+
};
|
|
96
|
+
type ExtractReturnType<T> = T extends (...args: any[]) => infer R ? R : never;
|
|
97
|
+
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
98
|
+
type MethodReturnMap = {
|
|
99
|
+
[K in keyof ZingQueryMethods]: UnwrapPromise<ExtractReturnType<ZingQueryMethods[K]>>;
|
|
100
|
+
};
|
|
101
|
+
type ZingQueryConfig = {
|
|
102
|
+
[K in keyof ZingQueryMethods]: {
|
|
103
|
+
method: K;
|
|
104
|
+
params: MethodParamsMap[K];
|
|
105
|
+
} & Omit<UseQueryOptions<MethodReturnMap[K], Error, MethodReturnMap[K], readonly unknown[]>, "queryKey" | "queryFn">;
|
|
106
|
+
}[keyof ZingQueryMethods];
|
|
107
|
+
type UseZingQueriesOptions<T extends readonly ZingQueryConfig[], TCombinedResult = QueriesResults<T>> = {
|
|
108
|
+
queries: readonly [...T];
|
|
109
|
+
combine?: (results: QueriesResults<T>) => TCombinedResult;
|
|
110
|
+
};
|
|
111
|
+
type QueryResult<T> = T extends {
|
|
112
|
+
method: infer K;
|
|
113
|
+
params: any;
|
|
114
|
+
} ? K extends keyof ZingQueryMethods ? {
|
|
115
|
+
data: MethodReturnMap[K] | undefined;
|
|
116
|
+
error: Error | null;
|
|
117
|
+
isLoading: boolean;
|
|
118
|
+
isError: boolean;
|
|
119
|
+
isSuccess: boolean;
|
|
120
|
+
status: "pending" | "error" | "success";
|
|
121
|
+
fetchStatus: "fetching" | "paused" | "idle";
|
|
122
|
+
} : never : never;
|
|
123
|
+
type QueriesResults<T extends readonly ZingQueryConfig[]> = {
|
|
124
|
+
[K in keyof T]: QueryResult<T[K]>;
|
|
125
|
+
};
|
|
126
|
+
export declare function useZingQueries<T extends readonly ZingQueryConfig[], TCombinedResult = QueriesResults<T>>(options: UseZingQueriesOptions<T, TCombinedResult>): TCombinedResult;
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useZingClient } from "../components/zing-provider.js";
|
|
2
|
+
import { useQueries } from "@tanstack/react-query";
|
|
3
|
+
// ---------------------------------------------
|
|
4
|
+
// Method map (shared with useZingQuery)
|
|
5
|
+
// ---------------------------------------------
|
|
6
|
+
const zingQueryMethodMap = (zingClient) => ({
|
|
7
|
+
getIdentifierByAddress: zingClient.getIdentifierByAddress.bind(zingClient),
|
|
8
|
+
getIdentifierInfoByIdentifier: zingClient.getIdentifierInfoByIdentifier.bind(zingClient),
|
|
9
|
+
getStudio: zingClient.getStudio.bind(zingClient),
|
|
10
|
+
getStorageSpace: zingClient.getStorageSpace.bind(zingClient),
|
|
11
|
+
getStorageTreasury: zingClient.getStorageTreasury.bind(zingClient),
|
|
12
|
+
getMember: zingClient.getMember.bind(zingClient),
|
|
13
|
+
getBalance: zingClient.getBalance.bind(zingClient),
|
|
14
|
+
});
|
|
15
|
+
// ---------------------------------------------
|
|
16
|
+
// Hook
|
|
17
|
+
// ---------------------------------------------
|
|
18
|
+
export function useZingQueries(options) {
|
|
19
|
+
const zingClient = useZingClient();
|
|
20
|
+
const methodMap = zingQueryMethodMap(zingClient);
|
|
21
|
+
const queryConfigs = options.queries.map((queryConfig) => {
|
|
22
|
+
const { method, params, ...queryOptions } = queryConfig;
|
|
23
|
+
return {
|
|
24
|
+
queryKey: [zingClient.network, method, params],
|
|
25
|
+
queryFn: async () => {
|
|
26
|
+
const fn = methodMap[method];
|
|
27
|
+
return fn(...params);
|
|
28
|
+
},
|
|
29
|
+
...queryOptions,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
const results = useQueries({
|
|
33
|
+
queries: queryConfigs,
|
|
34
|
+
combine: options.combine,
|
|
35
|
+
});
|
|
36
|
+
return results;
|
|
37
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { ZingClient } from "../client/index.js";
|
|
2
|
+
import type { SuiNetwork } from "../types.js";
|
|
3
|
+
import type { UseQueryOptions } from "@tanstack/react-query";
|
|
4
|
+
declare const zingQueryMethodMap: (zingClient: ZingClient) => {
|
|
5
|
+
getIdentifierByAddress: (platform: import("../index.js").PlatformType, address: string) => Promise<string | null>;
|
|
6
|
+
getIdentifierInfoByIdentifier: (platform: import("../index.js").PlatformType, identifier: string) => Promise<{
|
|
7
|
+
owner: string;
|
|
8
|
+
updated_at: string;
|
|
9
|
+
} | null>;
|
|
10
|
+
getStudio: (owner: string) => Promise<{
|
|
11
|
+
id: {
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
owner: string;
|
|
15
|
+
period: string[];
|
|
16
|
+
monthly_subscription_fee: {
|
|
17
|
+
contents: {
|
|
18
|
+
key: number;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
membership: {
|
|
23
|
+
id: {
|
|
24
|
+
id: string;
|
|
25
|
+
};
|
|
26
|
+
size: string;
|
|
27
|
+
};
|
|
28
|
+
works: {
|
|
29
|
+
id: {
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
32
|
+
size: string;
|
|
33
|
+
};
|
|
34
|
+
encrypted_file_key: number[] | null;
|
|
35
|
+
} | null>;
|
|
36
|
+
getStorageSpace: (owner: string) => Promise<{
|
|
37
|
+
id: {
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
owner: string;
|
|
41
|
+
tier: number | null;
|
|
42
|
+
storage_used: {
|
|
43
|
+
contents: {
|
|
44
|
+
key: number;
|
|
45
|
+
value: string;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
credits: string;
|
|
49
|
+
} | null>;
|
|
50
|
+
getStorageTreasury: () => Promise<{
|
|
51
|
+
id: {
|
|
52
|
+
id: string;
|
|
53
|
+
};
|
|
54
|
+
tier_plan: {
|
|
55
|
+
contents: {
|
|
56
|
+
key: number;
|
|
57
|
+
value: {
|
|
58
|
+
price: string;
|
|
59
|
+
duration_days: number;
|
|
60
|
+
storage_limit: string;
|
|
61
|
+
};
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
64
|
+
storages_by_epoch: {
|
|
65
|
+
contents: {
|
|
66
|
+
key: number;
|
|
67
|
+
value: {
|
|
68
|
+
id: {
|
|
69
|
+
id: string;
|
|
70
|
+
};
|
|
71
|
+
start_epoch: number;
|
|
72
|
+
end_epoch: number;
|
|
73
|
+
storage_size: string;
|
|
74
|
+
};
|
|
75
|
+
}[];
|
|
76
|
+
};
|
|
77
|
+
wal_treasury: {
|
|
78
|
+
id: {
|
|
79
|
+
id: string;
|
|
80
|
+
};
|
|
81
|
+
balance: {
|
|
82
|
+
value: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
} | null>;
|
|
86
|
+
getMember: (owner: string, member: string) => Promise<{
|
|
87
|
+
level: number;
|
|
88
|
+
expired_at: string;
|
|
89
|
+
} | null>;
|
|
90
|
+
getBalance: (owner: string, coinSymbol: import("../index.js").CoinSymbol) => Promise<import("node_modules/@mysten/sui/dist/esm/grpc/proto/sui/rpc/v2/state_service.js").GetBalanceResponse>;
|
|
91
|
+
getWork: (walrusSystem: import("../index.js").WalrusSystemState, workId: string, workType?: import("../index.js").WorkType) => Promise<{
|
|
92
|
+
id: {
|
|
93
|
+
id: string;
|
|
94
|
+
};
|
|
95
|
+
owner: string;
|
|
96
|
+
deleted: boolean;
|
|
97
|
+
created_at: string;
|
|
98
|
+
subscription_level: number | null;
|
|
99
|
+
blobs: {
|
|
100
|
+
id: {
|
|
101
|
+
id: string;
|
|
102
|
+
};
|
|
103
|
+
registered_epoch: number;
|
|
104
|
+
blob_id: string;
|
|
105
|
+
size: string;
|
|
106
|
+
encoding_type: number;
|
|
107
|
+
certified_epoch: number | null;
|
|
108
|
+
storage: {
|
|
109
|
+
id: {
|
|
110
|
+
id: string;
|
|
111
|
+
};
|
|
112
|
+
start_epoch: number;
|
|
113
|
+
end_epoch: number;
|
|
114
|
+
storage_size: string;
|
|
115
|
+
};
|
|
116
|
+
deletable: boolean;
|
|
117
|
+
}[];
|
|
118
|
+
files: {
|
|
119
|
+
contents: {
|
|
120
|
+
key: string;
|
|
121
|
+
value: {
|
|
122
|
+
blob_index: string;
|
|
123
|
+
mime_type: string;
|
|
124
|
+
size: string;
|
|
125
|
+
};
|
|
126
|
+
}[];
|
|
127
|
+
};
|
|
128
|
+
} | null>;
|
|
129
|
+
};
|
|
130
|
+
type ZingQueryMethods = ReturnType<typeof zingQueryMethodMap>;
|
|
131
|
+
type ExtractParams<T> = T extends (...args: infer P) => any ? P : never;
|
|
132
|
+
type MethodParamsMap = {
|
|
133
|
+
[K in keyof ZingQueryMethods]: ExtractParams<ZingQueryMethods[K]>;
|
|
134
|
+
};
|
|
135
|
+
type ExtractReturnType<T> = T extends (...args: any[]) => infer R ? R : never;
|
|
136
|
+
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
137
|
+
type MethodReturnMap = {
|
|
138
|
+
[K in keyof ZingQueryMethods]: UnwrapPromise<ExtractReturnType<ZingQueryMethods[K]>>;
|
|
139
|
+
};
|
|
140
|
+
type UseZingQueryParams<K extends keyof ZingQueryMethods = keyof ZingQueryMethods> = {
|
|
141
|
+
method: K;
|
|
142
|
+
params: MethodParamsMap[K];
|
|
143
|
+
};
|
|
144
|
+
type ExtraQueryOptions<TData> = Omit<UseQueryOptions<TData, Error, TData, readonly unknown[]>, "queryKey" | "queryFn">;
|
|
145
|
+
export declare function getZingQueryKey<K extends keyof ZingQueryMethods>(network: SuiNetwork, method: K, memo: string[]): readonly [string, K, string[]];
|
|
146
|
+
export declare function useZingQuery<K extends keyof ZingQueryMethods>(input: UseZingQueryParams<K>, options?: ExtraQueryOptions<MethodReturnMap[K]>, memo?: string[]): import("@tanstack/react-query").UseQueryResult<import("@tanstack/react-query").NoInfer<MethodReturnMap[K]>, Error>;
|
|
147
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useZingClient } from "../components/zing-provider.js";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
// ---------------------------------------------
|
|
4
|
+
// Method map
|
|
5
|
+
// ---------------------------------------------
|
|
6
|
+
const zingQueryMethodMap = (zingClient) => ({
|
|
7
|
+
getIdentifierByAddress: zingClient.getIdentifierByAddress.bind(zingClient),
|
|
8
|
+
getIdentifierInfoByIdentifier: zingClient.getIdentifierInfoByIdentifier.bind(zingClient),
|
|
9
|
+
getStudio: zingClient.getStudio.bind(zingClient),
|
|
10
|
+
getStorageSpace: zingClient.getStorageSpace.bind(zingClient),
|
|
11
|
+
getStorageTreasury: zingClient.getStorageTreasury.bind(zingClient),
|
|
12
|
+
getMember: zingClient.getMember.bind(zingClient),
|
|
13
|
+
getBalance: zingClient.getBalance.bind(zingClient),
|
|
14
|
+
getWork: zingClient.getWork.bind(zingClient),
|
|
15
|
+
});
|
|
16
|
+
export function getZingQueryKey(network, method, memo) {
|
|
17
|
+
return [network, method, memo];
|
|
18
|
+
}
|
|
19
|
+
export function useZingQuery(input, options = {}, memo = []) {
|
|
20
|
+
const zingClient = useZingClient();
|
|
21
|
+
const methodMap = zingQueryMethodMap(zingClient);
|
|
22
|
+
const { method, params } = input;
|
|
23
|
+
return useQuery({
|
|
24
|
+
queryKey: [zingClient.network, method, memo],
|
|
25
|
+
gcTime: options.gcTime,
|
|
26
|
+
staleTime: options.staleTime,
|
|
27
|
+
enabled: options.enabled,
|
|
28
|
+
retry: options.retry,
|
|
29
|
+
queryFn: async () => {
|
|
30
|
+
const fn = methodMap[method];
|
|
31
|
+
return fn(...params);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -8,8 +8,7 @@ export * from "./bcs.js";
|
|
|
8
8
|
export * from "./_generated/index.js";
|
|
9
9
|
export * from "./components/index.js";
|
|
10
10
|
export type * from "./types.js";
|
|
11
|
-
|
|
12
11
|
export type InfiniteQueryResult<TData> = {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
pages: TData[];
|
|
13
|
+
pageParams: number[];
|
|
15
14
|
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./const.js";
|
|
2
|
+
export * from "./lib/utils/index.js";
|
|
3
|
+
export * from "./config/index.js";
|
|
4
|
+
export * from "./getters.js";
|
|
5
|
+
export * from "./mutations/index.js";
|
|
6
|
+
export * from "./hooks/index.js";
|
|
7
|
+
export * from "./bcs.js";
|
|
8
|
+
export * from "./_generated/index.js";
|
|
9
|
+
export * from "./components/index.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { COLORS } from "./const.js";
|
|
2
|
+
export const colorfulLog = (message, type) => {
|
|
3
|
+
let color;
|
|
4
|
+
switch (type) {
|
|
5
|
+
case "success":
|
|
6
|
+
color = COLORS.FgGreen;
|
|
7
|
+
break;
|
|
8
|
+
case "info":
|
|
9
|
+
color = COLORS.FgBlue;
|
|
10
|
+
break;
|
|
11
|
+
case "error":
|
|
12
|
+
color = COLORS.FgRed;
|
|
13
|
+
break;
|
|
14
|
+
case "warning":
|
|
15
|
+
color = COLORS.FgYellow;
|
|
16
|
+
break;
|
|
17
|
+
default:
|
|
18
|
+
color = COLORS[type];
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
console.info(color, message);
|
|
22
|
+
console.info(COLORS["Reset"]);
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const COLORS: {
|
|
2
|
+
readonly Reset: "\u001B[0m";
|
|
3
|
+
readonly Bright: "\u001B[1m";
|
|
4
|
+
readonly Dim: "\u001B[2m";
|
|
5
|
+
readonly Underscore: "\u001B[4m";
|
|
6
|
+
readonly Blink: "\u001B[5m";
|
|
7
|
+
readonly Reverse: "\u001B[7m";
|
|
8
|
+
readonly Hidden: "\u001B[8m";
|
|
9
|
+
readonly FgBlack: "\u001B[30m";
|
|
10
|
+
readonly FgRed: "\u001B[31m";
|
|
11
|
+
readonly FgGreen: "\u001B[32m";
|
|
12
|
+
readonly FgYellow: "\u001B[33m";
|
|
13
|
+
readonly FgBlue: "\u001B[34m";
|
|
14
|
+
readonly FgMagenta: "\u001B[35m";
|
|
15
|
+
readonly FgCyan: "\u001B[36m";
|
|
16
|
+
readonly FgWhite: "\u001B[37m";
|
|
17
|
+
readonly BgBlack: "\u001B[40m";
|
|
18
|
+
readonly BgRed: "\u001B[41m";
|
|
19
|
+
readonly BgGreen: "\u001B[42m";
|
|
20
|
+
readonly BgYellow: "\u001B[43m";
|
|
21
|
+
readonly BgBlue: "\u001B[44m";
|
|
22
|
+
readonly BgMagenta: "\u001B[45m";
|
|
23
|
+
readonly BgCyan: "\u001B[46m";
|
|
24
|
+
readonly BgWhite: "\u001B[47m";
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const COLORS = {
|
|
2
|
+
Reset: "\x1b[0m",
|
|
3
|
+
Bright: "\x1b[1m",
|
|
4
|
+
Dim: "\x1b[2m",
|
|
5
|
+
Underscore: "\x1b[4m",
|
|
6
|
+
Blink: "\x1b[5m",
|
|
7
|
+
Reverse: "\x1b[7m",
|
|
8
|
+
Hidden: "\x1b[8m",
|
|
9
|
+
FgBlack: "\x1b[30m",
|
|
10
|
+
FgRed: "\x1b[31m",
|
|
11
|
+
FgGreen: "\x1b[32m",
|
|
12
|
+
FgYellow: "\x1b[33m",
|
|
13
|
+
FgBlue: "\x1b[34m",
|
|
14
|
+
FgMagenta: "\x1b[35m",
|
|
15
|
+
FgCyan: "\x1b[36m",
|
|
16
|
+
FgWhite: "\x1b[37m",
|
|
17
|
+
BgBlack: "\x1b[40m",
|
|
18
|
+
BgRed: "\x1b[41m",
|
|
19
|
+
BgGreen: "\x1b[42m",
|
|
20
|
+
BgYellow: "\x1b[43m",
|
|
21
|
+
BgBlue: "\x1b[44m",
|
|
22
|
+
BgMagenta: "\x1b[45m",
|
|
23
|
+
BgCyan: "\x1b[46m",
|
|
24
|
+
BgWhite: "\x1b[47m",
|
|
25
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExcludeValuesFromBaseArrayType } from "./types.js";
|
|
2
|
+
export declare const excludeValuesFromBaseArray: <B extends string[], E extends (string | number)[]>(baseArray: B, excludeArray: E) => ExcludeValuesFromBaseArrayType<B, E>;
|
|
3
|
+
export declare const sleep: (time: number) => Promise<unknown>;
|
|
4
|
+
export declare const formatDate: (date: Date) => string;
|
|
5
|
+
export declare const formatBalance: (balance: string | number | bigint, decimal: number, digits?: number) => string;
|
|
6
|
+
export declare const formatTimeAgo: (date: Date) => string;
|
|
7
|
+
export declare function formatDaysAuto(days: number): string;
|
|
8
|
+
export declare const formatBytes: (bytes: number) => string;
|
|
9
|
+
export declare const getDaysRemaining: (comp: number) => number;
|
|
10
|
+
export declare const bytesToGB: (bytes: number) => number;
|