@zing-protocol/zing-sdk 0.0.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/README.md +12 -0
- package/package.json +37 -0
- package/src/_generated/index.js +6 -0
- package/src/_generated/utils/index.ts +181 -0
- package/src/_generated/zing_framework/coin_utils.ts +41 -0
- package/src/_generated/zing_framework/deps/sui/object.ts +16 -0
- package/src/_generated/zing_framework/derived_object_bag.ts +400 -0
- package/src/_generated/zing_framework/derived_table.ts +366 -0
- package/src/_generated/zing_governance/admin.ts +47 -0
- package/src/_generated/zing_governance/deps/sui/object.ts +16 -0
- package/src/_generated/zing_governance/treasury.ts +134 -0
- package/src/_generated/zing_identity/config.ts +191 -0
- package/src/_generated/zing_identity/deps/std/type_name.ts +25 -0
- package/src/_generated/zing_identity/deps/sui/object.ts +16 -0
- package/src/_generated/zing_identity/deps/sui/object_table.ts +26 -0
- package/src/_generated/zing_identity/deps/sui/table.ts +38 -0
- package/src/_generated/zing_identity/deps/sui/vec_set.ts +28 -0
- package/src/_generated/zing_identity/ecdsa.ts +166 -0
- package/src/_generated/zing_identity/identity.ts +661 -0
- package/src/_generated/zing_identity/reclaim.ts +803 -0
- package/src/_generated/zing_studio/app.ts +855 -0
- package/src/_generated/zing_studio/article.ts +598 -0
- package/src/_generated/zing_studio/config.ts +475 -0
- package/src/_generated/zing_studio/deps/std/type_name.ts +25 -0
- package/src/_generated/zing_studio/deps/sui/bag.ts +43 -0
- package/src/_generated/zing_studio/deps/sui/balance.ts +20 -0
- package/src/_generated/zing_studio/deps/sui/coin.ts +21 -0
- package/src/_generated/zing_studio/deps/sui/dynamic_field.ts +272 -0
- package/src/_generated/zing_studio/deps/sui/object.ts +16 -0
- package/src/_generated/zing_studio/deps/sui/table.ts +38 -0
- package/src/_generated/zing_studio/deps/sui/vec_map.ts +39 -0
- package/src/_generated/zing_studio/deps/sui/vec_set.ts +28 -0
- package/src/_generated/zing_studio/deps/walrus/blob.ts +22 -0
- package/src/_generated/zing_studio/deps/walrus/events.ts +124 -0
- package/src/_generated/zing_studio/deps/walrus/metadata.ts +137 -0
- package/src/_generated/zing_studio/deps/walrus/storage_resource.ts +17 -0
- package/src/_generated/zing_studio/deps/zing_framework/derived_object_bag.ts +17 -0
- package/src/_generated/zing_studio/deps/zing_framework/derived_table.ts +17 -0
- package/src/_generated/zing_studio/donation.ts +18 -0
- package/src/_generated/zing_studio/enclave.ts +466 -0
- package/src/_generated/zing_studio/nitro_attestation.ts +308 -0
- package/src/_generated/zing_studio/referral.ts +447 -0
- package/src/_generated/zing_studio/storage.ts +664 -0
- package/src/_generated/zing_studio/studio.ts +682 -0
- package/src/bcs.ts +139 -0
- package/src/client/index.ts +557 -0
- package/src/client/types.ts +28 -0
- package/src/components/index.ts +3 -0
- package/src/components/wallet-provider.tsx +53 -0
- package/src/components/walrus-provider.tsx +212 -0
- package/src/components/zing-provider.tsx +54 -0
- package/src/config/common.ts +82 -0
- package/src/config/index.ts +45 -0
- package/src/config/mainnet.ts +109 -0
- package/src/config/testnet.ts +111 -0
- package/src/config/types.ts +69 -0
- package/src/const.ts +32 -0
- package/src/getters.ts +523 -0
- package/src/hooks/index.ts +14 -0
- package/src/hooks/useGetStudio.ts +22 -0
- package/src/hooks/useGetTierPlan.ts +115 -0
- package/src/hooks/useReclaim.ts +165 -0
- package/src/hooks/useSignAndExecuteTransaction.ts +57 -0
- package/src/hooks/useSignPersonalMessage.ts +28 -0
- package/src/hooks/useZingInfiniteQueries.ts +92 -0
- package/src/hooks/useZingMutation.ts +66 -0
- package/src/hooks/useZingQueries.ts +107 -0
- package/src/hooks/useZingQuery.ts +88 -0
- package/src/index.ts +15 -0
- package/src/lib/utils/colorful-logger.ts +27 -0
- package/src/lib/utils/const.ts +25 -0
- package/src/lib/utils/helpers.ts +78 -0
- package/src/lib/utils/index.ts +5 -0
- package/src/lib/utils/init-app-with-shadow.ts +42 -0
- package/src/lib/utils/quilt.ts +317 -0
- package/src/lib/utils/reclaim.ts +148 -0
- package/src/lib/utils/types.ts +14 -0
- package/src/mutations/index.ts +3 -0
- package/src/mutations/seal.ts +78 -0
- package/src/mutations/signer.ts +241 -0
- package/src/mutations/walrus.ts +862 -0
- package/src/stores/index.ts +3 -0
- package/src/stores/walletStore.ts +360 -0
- package/src/stores/walrusStore.ts +118 -0
- package/src/stores/zkloginStore.ts +53 -0
- package/src/types.ts +120 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// WalletProvider.tsx
|
|
2
|
+
import { createWalletStore } from "../stores/walletStore.js";
|
|
3
|
+
import { createContext, useContext, useRef, useEffect } from "react";
|
|
4
|
+
import { useStore } from "zustand";
|
|
5
|
+
import type { WalletStore, WalletStoreConfig } from "../stores/walletStore.js";
|
|
6
|
+
import type { PropsWithChildren } from "react";
|
|
7
|
+
import type { StoreApi } from "zustand";
|
|
8
|
+
|
|
9
|
+
const WalletContext = createContext<StoreApi<WalletStore> | null>(null);
|
|
10
|
+
|
|
11
|
+
export function WalletProvider({
|
|
12
|
+
suiClient,
|
|
13
|
+
oAuthClientId,
|
|
14
|
+
network,
|
|
15
|
+
autoInit = true,
|
|
16
|
+
children,
|
|
17
|
+
}: PropsWithChildren<
|
|
18
|
+
WalletStoreConfig & { network?: string; autoInit?: boolean }
|
|
19
|
+
>) {
|
|
20
|
+
const storeRef = useRef<StoreApi<WalletStore> | null>(null);
|
|
21
|
+
|
|
22
|
+
if (!storeRef.current) {
|
|
23
|
+
storeRef.current = createWalletStore({
|
|
24
|
+
suiClient,
|
|
25
|
+
oAuthClientId,
|
|
26
|
+
network,
|
|
27
|
+
autoInit,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Optionally run initFromStorage when suiClient changes or on mount
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const s = storeRef.current!;
|
|
34
|
+
if (autoInit) {
|
|
35
|
+
s.getState()
|
|
36
|
+
.initFromStorage()
|
|
37
|
+
.catch(() => {});
|
|
38
|
+
}
|
|
39
|
+
}, [autoInit, suiClient]);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<WalletContext.Provider value={storeRef.current}>
|
|
43
|
+
{children}
|
|
44
|
+
</WalletContext.Provider>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function useWalletStore<T>(selector: (s: WalletStore) => T): T {
|
|
49
|
+
const store = useContext(WalletContext);
|
|
50
|
+
if (!store)
|
|
51
|
+
throw new Error("useWalletStore must be used inside WalletProvider");
|
|
52
|
+
return useStore(store, selector);
|
|
53
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { calculateEncryptedQuiltSize } from "../lib/utils/quilt.js";
|
|
2
|
+
import { uploadFileToWalrus } from "../mutations/walrus.js";
|
|
3
|
+
import { createWalrusStore } from "../stores/walrusStore.js";
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useMemo,
|
|
7
|
+
useEffect,
|
|
8
|
+
useContext,
|
|
9
|
+
useCallback,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { useStore } from "zustand";
|
|
12
|
+
import type { PublishArticleEvent } from "../_generated/zing_studio/article.js";
|
|
13
|
+
import type { ZingClient } from "../client/index.js";
|
|
14
|
+
import type { WalrusUploadFlowStage } from "../config/common.js";
|
|
15
|
+
import type { WalrusSystemState } from "../config/types.js";
|
|
16
|
+
import type { QuiltSizeResult } from "../lib/utils/quilt.js";
|
|
17
|
+
import type { WalrusStore } from "../stores/walrusStore.js";
|
|
18
|
+
import type { ZKLoginSignerState } from "../types.js";
|
|
19
|
+
import type { SealClient } from "@mysten/seal";
|
|
20
|
+
import type { WalrusClient, WalrusFile } from "@mysten/walrus";
|
|
21
|
+
import type { ReactNode } from "react";
|
|
22
|
+
import type { StoreApi } from "zustand";
|
|
23
|
+
|
|
24
|
+
type WalrusContextType = StoreApi<WalrusStore> & {
|
|
25
|
+
uploadFile: (
|
|
26
|
+
zingClient: ZingClient,
|
|
27
|
+
fileKey: CryptoKey,
|
|
28
|
+
walrusSystem: WalrusSystemState,
|
|
29
|
+
walTreasury: string,
|
|
30
|
+
storageByEpoch: Record<number, number>,
|
|
31
|
+
// params
|
|
32
|
+
walrusFiles: WalrusFile[],
|
|
33
|
+
subscriptionLevel: null | number,
|
|
34
|
+
metadata: {
|
|
35
|
+
identifier: string;
|
|
36
|
+
tags: {
|
|
37
|
+
"content-type": string;
|
|
38
|
+
};
|
|
39
|
+
size: number;
|
|
40
|
+
}[],
|
|
41
|
+
signer: ZKLoginSignerState,
|
|
42
|
+
gasPoolBearerToken: string,
|
|
43
|
+
onProgress?: (stage: WalrusUploadFlowStage) => void,
|
|
44
|
+
) => Promise<typeof PublishArticleEvent.$inferType>;
|
|
45
|
+
calculateQuiltSize: (
|
|
46
|
+
walrusSystem: WalrusSystemState,
|
|
47
|
+
files: Array<{
|
|
48
|
+
size: number;
|
|
49
|
+
identifier: string;
|
|
50
|
+
tags?: Record<string, string>;
|
|
51
|
+
}>,
|
|
52
|
+
ivSize?: number,
|
|
53
|
+
) => QuiltSizeResult;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const WalrusContext = createContext<WalrusContextType | undefined>(undefined);
|
|
57
|
+
|
|
58
|
+
interface WalrusProviderProps {
|
|
59
|
+
walrusClient: WalrusClient;
|
|
60
|
+
sealClient: SealClient;
|
|
61
|
+
children: ReactNode;
|
|
62
|
+
// optional persistence
|
|
63
|
+
autoInit?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const WalrusProvider: React.FC<WalrusProviderProps> = ({
|
|
67
|
+
walrusClient,
|
|
68
|
+
sealClient,
|
|
69
|
+
children,
|
|
70
|
+
autoInit = true,
|
|
71
|
+
}) => {
|
|
72
|
+
// create store instance once per provider
|
|
73
|
+
const store = useMemo(
|
|
74
|
+
() =>
|
|
75
|
+
createWalrusStore({
|
|
76
|
+
walrusClient,
|
|
77
|
+
sealClient,
|
|
78
|
+
autoInit,
|
|
79
|
+
}),
|
|
80
|
+
[walrusClient, sealClient, autoInit],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// optionally auto-init on mount
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (autoInit) {
|
|
86
|
+
// call init and ignore errors � store handles them
|
|
87
|
+
store
|
|
88
|
+
.getState()
|
|
89
|
+
.init()
|
|
90
|
+
.catch((e: any) => {
|
|
91
|
+
console.error(e);
|
|
92
|
+
// optionally log
|
|
93
|
+
// console.error('Walrus store init failed', e);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
+
}, [store]);
|
|
99
|
+
|
|
100
|
+
const uploadFile = useCallback(
|
|
101
|
+
async (
|
|
102
|
+
zingClient: ZingClient,
|
|
103
|
+
fileKey: CryptoKey,
|
|
104
|
+
walrusSystem: WalrusSystemState,
|
|
105
|
+
walTreasury: string,
|
|
106
|
+
storageByEpoch: Record<number, number>,
|
|
107
|
+
walrusFiles: WalrusFile[],
|
|
108
|
+
subscriptionLevel: null | number,
|
|
109
|
+
metadata: {
|
|
110
|
+
identifier: string;
|
|
111
|
+
tags: {
|
|
112
|
+
"content-type": string;
|
|
113
|
+
};
|
|
114
|
+
size: number;
|
|
115
|
+
}[],
|
|
116
|
+
signer: ZKLoginSignerState,
|
|
117
|
+
gasPoolBearerToken: string,
|
|
118
|
+
onProgress?: (stage: WalrusUploadFlowStage) => void,
|
|
119
|
+
) => {
|
|
120
|
+
const config = zingClient.config;
|
|
121
|
+
return uploadFileToWalrus(
|
|
122
|
+
{
|
|
123
|
+
zingStudioPackageId: config.zing.ZING_STUDIO_PACKAGE_ADDRESS,
|
|
124
|
+
zingStudioV0PackageId: config.zing.ZING_STUDIO_V0_PACKAGE_ADDRESS,
|
|
125
|
+
walrusPackageId: config.walrus.WALRUS_PACKAGE,
|
|
126
|
+
zingStudioConfigSharedObjectRef:
|
|
127
|
+
config.zing.ZING_STUDIO_CONFIG_SHARED_OBJECT_REF,
|
|
128
|
+
walrusSystemSharedObjectRef:
|
|
129
|
+
config.walrus.WALRUS_SYSTEM_SHARED_OBJECT_REF,
|
|
130
|
+
zingStorageTreasurySharedObjectRef:
|
|
131
|
+
config.zing.ZING_STORAGE_TREASURY_SHARED_OBJECT_REF,
|
|
132
|
+
blobRegisteredEventType: config.walrus.EVENT_TYPES.blobRegistered,
|
|
133
|
+
publishArticleEventType: config.zing.EVENT_TYPES.publishArticleEvent,
|
|
134
|
+
},
|
|
135
|
+
zingClient.suiGrpcClient,
|
|
136
|
+
zingClient.suiJsonRpcClient,
|
|
137
|
+
walrusClient,
|
|
138
|
+
walrusSystem,
|
|
139
|
+
walTreasury,
|
|
140
|
+
storageByEpoch,
|
|
141
|
+
fileKey,
|
|
142
|
+
walrusFiles,
|
|
143
|
+
subscriptionLevel,
|
|
144
|
+
metadata,
|
|
145
|
+
signer,
|
|
146
|
+
gasPoolBearerToken,
|
|
147
|
+
onProgress,
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
[walrusClient],
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const calculateQuiltSize = useCallback(
|
|
154
|
+
(
|
|
155
|
+
walrusSystem: WalrusSystemState,
|
|
156
|
+
files: Array<{
|
|
157
|
+
size: number;
|
|
158
|
+
identifier: string;
|
|
159
|
+
tags?: Record<string, string>;
|
|
160
|
+
}>,
|
|
161
|
+
ivSize: number = 12,
|
|
162
|
+
): QuiltSizeResult => {
|
|
163
|
+
const numShards = walrusSystem.committee.n_shards;
|
|
164
|
+
|
|
165
|
+
return calculateEncryptedQuiltSize(
|
|
166
|
+
files,
|
|
167
|
+
numShards,
|
|
168
|
+
ivSize,
|
|
169
|
+
"RS2", // default encoding type
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
[],
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
// Memoize context value with uploadFile and calculateQuiltSize included
|
|
176
|
+
const contextValue = useMemo(
|
|
177
|
+
() =>
|
|
178
|
+
Object.assign(store, {
|
|
179
|
+
uploadFile,
|
|
180
|
+
calculateQuiltSize,
|
|
181
|
+
}) as WalrusContextType,
|
|
182
|
+
[store, uploadFile, calculateQuiltSize],
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<WalrusContext.Provider value={contextValue}>
|
|
187
|
+
{children}
|
|
188
|
+
</WalrusContext.Provider>
|
|
189
|
+
);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export function useWalrusStore<T>(selector: (s: WalrusStore) => T): T {
|
|
193
|
+
const store = useContext(WalrusContext);
|
|
194
|
+
if (!store) throw new Error("useWalrus must be used inside WalrusProvider");
|
|
195
|
+
return useStore(store, selector);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function useWalrusUpload() {
|
|
199
|
+
const context = useContext(WalrusContext);
|
|
200
|
+
if (!context)
|
|
201
|
+
throw new Error("useWalrusUpload must be used inside WalrusProvider");
|
|
202
|
+
|
|
203
|
+
return context.uploadFile;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function useWalrusQuiltSize() {
|
|
207
|
+
const context = useContext(WalrusContext);
|
|
208
|
+
if (!context)
|
|
209
|
+
throw new Error("useWalrusQuiltSize must be used inside WalrusProvider");
|
|
210
|
+
|
|
211
|
+
return context.calculateQuiltSize;
|
|
212
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ZingClient } from "../client/index.js";
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import type { SuiNetwork } from "../types.js";
|
|
4
|
+
import type { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
5
|
+
import type { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
|
|
8
|
+
interface ZingClientContextProps {
|
|
9
|
+
client: ZingClient | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ZingClientContext = createContext<ZingClientContextProps>({
|
|
13
|
+
client: null,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
interface ZingClientProviderProps {
|
|
17
|
+
network: SuiNetwork;
|
|
18
|
+
suiGrpcClient: SuiGrpcClient;
|
|
19
|
+
suiJsonRpcClient: SuiJsonRpcClient;
|
|
20
|
+
gasPoolBearerToken: string;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const ZingClientProvider: React.FC<ZingClientProviderProps> = ({
|
|
25
|
+
network,
|
|
26
|
+
suiGrpcClient,
|
|
27
|
+
suiJsonRpcClient,
|
|
28
|
+
children,
|
|
29
|
+
gasPoolBearerToken,
|
|
30
|
+
}) => {
|
|
31
|
+
const client = useMemo(
|
|
32
|
+
() =>
|
|
33
|
+
new ZingClient({
|
|
34
|
+
network,
|
|
35
|
+
suiGrpcClient,
|
|
36
|
+
suiJsonRpcClient,
|
|
37
|
+
gasPoolBearerToken,
|
|
38
|
+
}),
|
|
39
|
+
[network, suiGrpcClient, suiJsonRpcClient, gasPoolBearerToken],
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<ZingClientContext.Provider value={{ client }}>
|
|
44
|
+
{children}
|
|
45
|
+
</ZingClientContext.Provider>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
export const useZingClient = (): ZingClient => {
|
|
49
|
+
const context = useContext(ZingClientContext);
|
|
50
|
+
if (!context.client) {
|
|
51
|
+
throw new Error("useZingClient must be used within a ZingClientProvider");
|
|
52
|
+
}
|
|
53
|
+
return context.client;
|
|
54
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export const AUTH_PROVIDDERS = ["Google"] as const;
|
|
2
|
+
export type AuthProvider = (typeof AUTH_PROVIDDERS)[number];
|
|
3
|
+
|
|
4
|
+
export const PLATFORMS = ["twitter"] as const;
|
|
5
|
+
export type PlatformType = (typeof PLATFORMS)[number];
|
|
6
|
+
|
|
7
|
+
export const WORKS = ["article"] as const;
|
|
8
|
+
export type WorkType = (typeof WORKS)[number];
|
|
9
|
+
|
|
10
|
+
export const COIN_SYMBOLS = ["USDC"] as const;
|
|
11
|
+
export type CoinSymbol = (typeof COIN_SYMBOLS)[number];
|
|
12
|
+
|
|
13
|
+
export const AUTH_PROVIDER_ICON_PATH: Record<AuthProvider, string> = {
|
|
14
|
+
Google: "icons/google.svg",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const WALRUS_UPLOAD_FLOW_STAGES = [
|
|
18
|
+
"encode",
|
|
19
|
+
"register_blob",
|
|
20
|
+
"upload",
|
|
21
|
+
"certify_blob",
|
|
22
|
+
"publish",
|
|
23
|
+
] as const;
|
|
24
|
+
export type WalrusUploadFlowStage = (typeof WALRUS_UPLOAD_FLOW_STAGES)[number];
|
|
25
|
+
|
|
26
|
+
export const COIN_DECIMALS: Record<CoinSymbol, number> = {
|
|
27
|
+
USDC: 6,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ProviderInfo = {
|
|
31
|
+
providerHash: string;
|
|
32
|
+
name: string;
|
|
33
|
+
icon: string;
|
|
34
|
+
};
|
|
35
|
+
export const PLATFORM_PROVIDER_INFO: Record<PlatformType, ProviderInfo> = {
|
|
36
|
+
twitter: {
|
|
37
|
+
name: "Twitter",
|
|
38
|
+
icon: "/icons/twitter.svg",
|
|
39
|
+
providerHash:
|
|
40
|
+
"0x168c2d4c2c7fd8c0eb21d4cd9aa634a716b61186b1f61e7ab78cd0dbff34fb04",
|
|
41
|
+
},
|
|
42
|
+
// instagram: {
|
|
43
|
+
// name: 'Instagram',
|
|
44
|
+
// icon: 'popup/icons/instagram.svg',
|
|
45
|
+
// providerHash: '',
|
|
46
|
+
// },
|
|
47
|
+
// medium: {
|
|
48
|
+
// name: 'Medium',
|
|
49
|
+
// icon: 'popup/icons/medium.svg',
|
|
50
|
+
// providerHash: '',
|
|
51
|
+
// },
|
|
52
|
+
// substack: {
|
|
53
|
+
// name: 'Substack',
|
|
54
|
+
// icon: 'popup/icons/substack.svg',
|
|
55
|
+
// providerHash: '',
|
|
56
|
+
// },
|
|
57
|
+
};
|
|
58
|
+
export const PLATFORMS_HOSTNAME: Record<PlatformType, string> = {
|
|
59
|
+
twitter: "https://x.com",
|
|
60
|
+
// medium: 'https://medium.com',
|
|
61
|
+
// substack: 'https://substack.com',
|
|
62
|
+
// instagram: 'https://www.instagram.com',
|
|
63
|
+
};
|
|
64
|
+
export const LEVEL_FEATURES: Record<
|
|
65
|
+
number,
|
|
66
|
+
{ name: string; features: string[] }
|
|
67
|
+
> = {
|
|
68
|
+
0: { name: "Supporter", features: ["Basic Support", "Standard Features"] },
|
|
69
|
+
1: {
|
|
70
|
+
name: "Premium",
|
|
71
|
+
features: ["Priority Support", "Advanced Features", "Analytics"],
|
|
72
|
+
},
|
|
73
|
+
2: {
|
|
74
|
+
name: "VIP",
|
|
75
|
+
features: [
|
|
76
|
+
"24/7 Support",
|
|
77
|
+
"All Features",
|
|
78
|
+
"Custom Integration",
|
|
79
|
+
"White Label",
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mainnetZingConfig,
|
|
3
|
+
mainnetWalrusConfig,
|
|
4
|
+
mainnetSealConfig,
|
|
5
|
+
mainnetCoinConfig,
|
|
6
|
+
} from "./mainnet.js";
|
|
7
|
+
import {
|
|
8
|
+
testnetZingConfig,
|
|
9
|
+
testnetWalrusConfig,
|
|
10
|
+
testnetSealConfig,
|
|
11
|
+
testnetCoinConfig,
|
|
12
|
+
} from "./testnet.js";
|
|
13
|
+
import type { Config } from "./types.js";
|
|
14
|
+
import type { SuiNetwork } from "../types.js";
|
|
15
|
+
|
|
16
|
+
const configs: Record<string, Config> = {
|
|
17
|
+
mainnet: {
|
|
18
|
+
zing: mainnetZingConfig,
|
|
19
|
+
walrus: mainnetWalrusConfig,
|
|
20
|
+
seal: mainnetSealConfig,
|
|
21
|
+
coins: mainnetCoinConfig,
|
|
22
|
+
},
|
|
23
|
+
testnet: {
|
|
24
|
+
zing: testnetZingConfig,
|
|
25
|
+
walrus: testnetWalrusConfig,
|
|
26
|
+
seal: testnetSealConfig,
|
|
27
|
+
coins: testnetCoinConfig,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// TBD: removeed
|
|
32
|
+
export const PROJECT_URL_OBJECT = {
|
|
33
|
+
url: "https://x.com/ZingonSui",
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
export function getConfig(network: SuiNetwork = "testnet"): Config {
|
|
37
|
+
const cfg = configs[network];
|
|
38
|
+
if (!cfg) {
|
|
39
|
+
throw new Error(`Unknown Zing network config: ${network}`);
|
|
40
|
+
}
|
|
41
|
+
return cfg;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type * from "./types.js";
|
|
45
|
+
export * from "./common.js";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { CoinSymbol } from "./common.js";
|
|
2
|
+
import type { SealConfig, WalrusConfig, ZingConfig } from "./types.js";
|
|
3
|
+
|
|
4
|
+
// zing
|
|
5
|
+
export const mainnetZingConfig: ZingConfig = {
|
|
6
|
+
ZING_FRAMEWORK_PACKAGE_ADDRESS:
|
|
7
|
+
"0x58c2589e21157bac347513cb4c392ffa34af0e1a630f5a77c0ee92f141057d01",
|
|
8
|
+
ZING_IDENTITY_PACKAGE_ADDRESS:
|
|
9
|
+
"0x4a22da297adc51ec5ed6e1f4fc884a45a50d8299b8c3deb9d056392210ce951d",
|
|
10
|
+
ZING_STUDIO_PACKAGE_ADDRESS:
|
|
11
|
+
"0x3db3853f032b5b403e35a7d863fb630359c5bec238990f52a8c33c6ac1f5222f",
|
|
12
|
+
ZING_STUDIO_V0_PACKAGE_ADDRESS:
|
|
13
|
+
"0xf245105e9896942a02614e4dbbb6c6636452879d58b1e12db1e0364c0d1532a7",
|
|
14
|
+
ZING_TREASURY_SHARED_OBJECT_REF: {
|
|
15
|
+
objectId:
|
|
16
|
+
"0x30f0dc6c1ad6bdf944ed303e9c966af60a3bbbef1b5b9ae3f23de1d44b02f5b6",
|
|
17
|
+
initialSharedVersion: 661729837,
|
|
18
|
+
mutable: true,
|
|
19
|
+
},
|
|
20
|
+
ZING_IDENTITY_CONFIG_SHARED_OBJECT_REF: {
|
|
21
|
+
objectId:
|
|
22
|
+
"0xd511beaa68a5647cdc193b753f3658e8e33bc87ec603857c3d6d315562f0e470",
|
|
23
|
+
initialSharedVersion: 661729843,
|
|
24
|
+
mutable: true,
|
|
25
|
+
},
|
|
26
|
+
PROOF_COMMITMENT_TYPE:
|
|
27
|
+
"0xd666d3234eb46551273014f5616ed2575e709a861dd3812613d59104a4cb7344::reclaim::ProofCommitment",
|
|
28
|
+
IDENTITY_PLATFORMS: {
|
|
29
|
+
twitter: {
|
|
30
|
+
PLATFORM_UPDATE_PROOF_TARGET:
|
|
31
|
+
"0x910fd7e88647ea9369ab269fa5629f0efd815dfa5a7b7ef2355ffee13852413b::twitter::update_with_twitter_proof",
|
|
32
|
+
PLATFORM_TYPE:
|
|
33
|
+
"0x910fd7e88647ea9369ab269fa5629f0efd815dfa5a7b7ef2355ffee13852413b::twitter::Twitter",
|
|
34
|
+
RECLAIM_MANAGER_SHARED_OBJECT_REF: {
|
|
35
|
+
objectId:
|
|
36
|
+
"0xe8849f48412d3b7220902fd56b7f128f324ffb27615bf57e83c638f523aa10e6",
|
|
37
|
+
initialSharedVersion: 662715429,
|
|
38
|
+
mutable: true,
|
|
39
|
+
},
|
|
40
|
+
IDENTITY_MANAGER_SHARED_OBJECT_REF: {
|
|
41
|
+
objectId:
|
|
42
|
+
"0xff54f2a3bfc4daedbbc7ecbb1b0985e8311c95fd847f070825882e7e083af5f1",
|
|
43
|
+
initialSharedVersion: 662715429,
|
|
44
|
+
mutable: true,
|
|
45
|
+
},
|
|
46
|
+
IDENTITY_MANAGER_IDENTIFIER_INFO_DF_ID:
|
|
47
|
+
"0xcbe996d13835c0fcc9a0a015098546997ae9ff58dd075389bfe764d43bb46c2e",
|
|
48
|
+
IDENTITY_MANAGER_ADDRESS_TO_IDENTIFIER_DF_ID:
|
|
49
|
+
"0x20ba08956972f73a956b288dde1659f9ad6059256205beb20bc3fa2cc0377ac2",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
ZING_STUDIO_CONFIG_SHARED_OBJECT_REF: {
|
|
53
|
+
objectId:
|
|
54
|
+
"0x9fe332fc68cb2a736a9643dc4f06089c7c4894396db0fb47895d216599ee5c00",
|
|
55
|
+
initialSharedVersion: 663114127,
|
|
56
|
+
mutable: true,
|
|
57
|
+
},
|
|
58
|
+
ZING_STORAGE_TREASURY_SHARED_OBJECT_REF: {
|
|
59
|
+
objectId:
|
|
60
|
+
"0xd80e520d304a43b21c3d2dba2c89463819c2ef9b779c89d15e19b425b385fe74",
|
|
61
|
+
initialSharedVersion: 663114127,
|
|
62
|
+
mutable: true,
|
|
63
|
+
},
|
|
64
|
+
ZING_WORKS_TYPE: {
|
|
65
|
+
article:
|
|
66
|
+
"0xf245105e9896942a02614e4dbbb6c6636452879d58b1e12db1e0364c0d1532a7::article::Article",
|
|
67
|
+
},
|
|
68
|
+
EVENT_TYPES: {
|
|
69
|
+
publishArticleEvent:
|
|
70
|
+
"0xf245105e9896942a02614e4dbbb6c6636452879d58b1e12db1e0364c0d1532a7::article::PublishArticle",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// walrus
|
|
75
|
+
export const mainnetWalrusConfig: WalrusConfig = {
|
|
76
|
+
WALRUS_PACKAGE:
|
|
77
|
+
"0xfa65cb2d62f4d39e60346fb7d501c12538ca2bbc646eaa37ece2aec5f897814e",
|
|
78
|
+
WAL_STAKING_INNER_FIELD:
|
|
79
|
+
"0x16f1f9fcdf5a746da423d1ad055d88f88b24a9272ca8afb4c0dcf074ae6c730a",
|
|
80
|
+
WALRUS_SYSTEM_SHARED_OBJECT_REF: {
|
|
81
|
+
objectId:
|
|
82
|
+
"0x2134d52768ea07e8c43570ef975eb3e4c27a39fa6396bef985b5abc58d03ddd2",
|
|
83
|
+
initialSharedVersion: 317862159,
|
|
84
|
+
mutable: true, // mutable when register_blob
|
|
85
|
+
},
|
|
86
|
+
WALRUS_AGGREGATORS: ["https://aggregator.suicore.com"],
|
|
87
|
+
WALRUS_UPLOAD_RELAY_BASE_URL:
|
|
88
|
+
"https://walrus-upload-relay-production-73a4.up.railway.app",
|
|
89
|
+
EVENT_TYPES: {
|
|
90
|
+
blobRegistered:
|
|
91
|
+
"0xfdc88f7d7cf30afab2f82e8380d11ee8f70efb90e863d1de8616fae1bb09ea77::events::BlobRegistered",
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// coins
|
|
96
|
+
export const mainnetCoinConfig: Record<CoinSymbol, string> = {
|
|
97
|
+
USDC: "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC",
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// seal
|
|
101
|
+
export const mainnetSealConfig: SealConfig = {
|
|
102
|
+
serverConfigs: [
|
|
103
|
+
{
|
|
104
|
+
objectId:
|
|
105
|
+
"0xe0eb52eba9261b96e895bbb4deca10dcd64fbc626a1133017adcd5131353fd10",
|
|
106
|
+
weight: 1,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { CoinSymbol } from "./common.js";
|
|
2
|
+
import type { SealConfig, WalrusConfig, ZingConfig } from "./types.js";
|
|
3
|
+
|
|
4
|
+
export const testnetZingConfig: ZingConfig = {
|
|
5
|
+
ZING_FRAMEWORK_PACKAGE_ADDRESS:
|
|
6
|
+
"0xd851eb5b907b60aa5fd958dd74044d809c49ee60001cad621726f03ea138f943",
|
|
7
|
+
ZING_IDENTITY_PACKAGE_ADDRESS:
|
|
8
|
+
"0xaaf27a90890ac1efface4fbb22597e95829cbe6cbb771df02f0d2cc93f067c70",
|
|
9
|
+
ZING_STUDIO_PACKAGE_ADDRESS:
|
|
10
|
+
"0x455bd1ba1afe47158c9155001f33b4069c9f008d091eef28f61c47c857bf60aa",
|
|
11
|
+
ZING_STUDIO_V0_PACKAGE_ADDRESS:
|
|
12
|
+
"0x455bd1ba1afe47158c9155001f33b4069c9f008d091eef28f61c47c857bf60aa",
|
|
13
|
+
ZING_TREASURY_SHARED_OBJECT_REF: {
|
|
14
|
+
objectId:
|
|
15
|
+
"0xca56bc3982525decbd4b025d3d4ae4de07259d6efc187577bfc3ab212e20574f",
|
|
16
|
+
initialSharedVersion: 645292716,
|
|
17
|
+
mutable: true,
|
|
18
|
+
},
|
|
19
|
+
ZING_IDENTITY_CONFIG_SHARED_OBJECT_REF: {
|
|
20
|
+
objectId:
|
|
21
|
+
"0xde2eb80aa01db47e65b705c80af931ccb1d56a8a6a06403e205fa8fb1ad4a02e",
|
|
22
|
+
initialSharedVersion: 645292717,
|
|
23
|
+
mutable: false,
|
|
24
|
+
},
|
|
25
|
+
PROOF_COMMITMENT_TYPE:
|
|
26
|
+
"0xaaf27a90890ac1efface4fbb22597e95829cbe6cbb771df02f0d2cc93f067c70::reclaim::ProofCommitment",
|
|
27
|
+
IDENTITY_PLATFORMS: {
|
|
28
|
+
twitter: {
|
|
29
|
+
PLATFORM_UPDATE_PROOF_TARGET:
|
|
30
|
+
"0xa0d84dc088ba37e3108e69458c4dc0d0f836479f384fbe1fe98c737d27945c3e::twitter::update_with_twitter_proof",
|
|
31
|
+
PLATFORM_TYPE:
|
|
32
|
+
"0xa0d84dc088ba37e3108e69458c4dc0d0f836479f384fbe1fe98c737d27945c3e::twitter::Twitter",
|
|
33
|
+
RECLAIM_MANAGER_SHARED_OBJECT_REF: {
|
|
34
|
+
objectId:
|
|
35
|
+
"0x3d3c56359728f12f8b54e9e2f5d5861a168f7d75675b83afc7f8b9cce289bfc1",
|
|
36
|
+
initialSharedVersion: 663897156,
|
|
37
|
+
mutable: true,
|
|
38
|
+
},
|
|
39
|
+
IDENTITY_MANAGER_SHARED_OBJECT_REF: {
|
|
40
|
+
objectId:
|
|
41
|
+
"0x44e9171b465f9bbad19864c06cec7ad24d3e830198fe10d9acc84f4e31ad59f6",
|
|
42
|
+
initialSharedVersion: 663897156,
|
|
43
|
+
mutable: true,
|
|
44
|
+
},
|
|
45
|
+
IDENTITY_MANAGER_IDENTIFIER_INFO_DF_ID:
|
|
46
|
+
"0x69ff6f5d7e4a64d177c24ae9882e732402065eb9668f41f9337b56fea39bd46d",
|
|
47
|
+
IDENTITY_MANAGER_ADDRESS_TO_IDENTIFIER_DF_ID:
|
|
48
|
+
"0x1073c13dfed532938cd978adfcb0b14a165350762392e0bb3137f493112d0520",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
ZING_STUDIO_CONFIG_SHARED_OBJECT_REF: {
|
|
52
|
+
objectId:
|
|
53
|
+
"0x4257dc4f3a3fe73e5f8d8c86c2233210876c35dc9b369f72d6aab0521733e57e",
|
|
54
|
+
initialSharedVersion: 723767900,
|
|
55
|
+
mutable: false,
|
|
56
|
+
},
|
|
57
|
+
ZING_STORAGE_TREASURY_SHARED_OBJECT_REF: {
|
|
58
|
+
objectId:
|
|
59
|
+
"0xde26730698493f851a7d9cd4d49b5b56f6781d902d3a63e24aa1f25820924cc8",
|
|
60
|
+
initialSharedVersion: 723767900,
|
|
61
|
+
mutable: true,
|
|
62
|
+
},
|
|
63
|
+
ZING_WORKS_TYPE: {
|
|
64
|
+
article:
|
|
65
|
+
"0x455bd1ba1afe47158c9155001f33b4069c9f008d091eef28f61c47c857bf60aa::article::Article",
|
|
66
|
+
},
|
|
67
|
+
EVENT_TYPES: {
|
|
68
|
+
publishArticleEvent:
|
|
69
|
+
"0x455bd1ba1afe47158c9155001f33b4069c9f008d091eef28f61c47c857bf60aa::article::PublishArticleEvent",
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const testnetWalrusConfig: WalrusConfig = {
|
|
74
|
+
WALRUS_PACKAGE:
|
|
75
|
+
"0xa998b8719ca1c0a6dc4e24a859bbb39f5477417f71885fbf2967a6510f699144",
|
|
76
|
+
WAL_STAKING_INNER_FIELD:
|
|
77
|
+
"0x93429364cd0447556847e7e96f15c20411e9cc9769c0877e5b6e99732a73a006",
|
|
78
|
+
WALRUS_SYSTEM_SHARED_OBJECT_REF: {
|
|
79
|
+
objectId:
|
|
80
|
+
"0x6c2547cbbc38025cf3adac45f63cb0a8d12ecf777cdc75a4971612bf97fdf6af",
|
|
81
|
+
initialSharedVersion: 400185623,
|
|
82
|
+
mutable: true, // mutable when register_blob
|
|
83
|
+
},
|
|
84
|
+
WALRUS_AGGREGATORS: ["https://aggregator.suicore.com"],
|
|
85
|
+
WALRUS_UPLOAD_RELAY_BASE_URL:
|
|
86
|
+
"https://walrus-upload-relay-production-73a4.up.railway.app",
|
|
87
|
+
EVENT_TYPES: {
|
|
88
|
+
blobRegistered:
|
|
89
|
+
"0xd84704c17fc870b8764832c535aa6b11f21a95cd6f5bb38a9b07d2cf42220c66::events::BlobRegistered",
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// coins
|
|
94
|
+
export const testnetCoinConfig: Record<CoinSymbol, string> = {
|
|
95
|
+
USDC: "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC",
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const testnetSealConfig: SealConfig = {
|
|
99
|
+
serverConfigs: [
|
|
100
|
+
{
|
|
101
|
+
objectId:
|
|
102
|
+
"0x73d05d62c18d9374e3ea529e8e0ed6161da1a141a94d3f76ae3fe4e99356db75",
|
|
103
|
+
weight: 1,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
objectId:
|
|
107
|
+
"0xf5d14a81a982144ae441cd7d64b09027f116a468bd36e7eca494f750591623c8",
|
|
108
|
+
weight: 1,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
};
|