@zing-protocol/zing-sdk 0.0.16 → 0.1.0
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.d.ts +0 -2
- package/dist/_generated/index.js +0 -2
- package/dist/_generated/utils/index.d.ts +21 -2
- package/dist/_generated/utils/index.js +35 -11
- package/dist/_generated/zing_framework/coin_utils.js +1 -4
- package/dist/_generated/zing_framework/derived_object_bag.d.ts +4 -3
- package/dist/_generated/zing_framework/derived_object_bag.js +12 -37
- package/dist/_generated/zing_framework/derived_table.d.ts +5 -4
- package/dist/_generated/zing_framework/derived_table.js +12 -33
- package/dist/_generated/zing_governance/admin.d.ts +4 -17
- package/dist/_generated/zing_governance/admin.js +3 -17
- package/dist/_generated/zing_governance/treasury.d.ts +5 -4
- package/dist/_generated/zing_governance/treasury.js +5 -15
- package/dist/_generated/zing_studio/app.d.ts +70 -2
- package/dist/_generated/zing_studio/app.js +154 -100
- package/dist/_generated/zing_studio/article.d.ts +6 -52
- package/dist/_generated/zing_studio/article.js +23 -74
- package/dist/_generated/zing_studio/config.d.ts +34 -3
- package/dist/_generated/zing_studio/config.js +47 -50
- package/dist/_generated/zing_studio/deps/sui/bag.d.ts +25 -3
- package/dist/_generated/zing_studio/deps/sui/bag.js +1 -2
- package/dist/_generated/zing_studio/deps/sui/balance.d.ts +1 -1
- package/dist/_generated/zing_studio/deps/sui/balance.js +1 -1
- package/dist/_generated/zing_studio/deps/sui/coin.d.ts +3 -5
- package/dist/_generated/zing_studio/deps/sui/coin.js +3 -3
- package/dist/_generated/zing_studio/deps/sui/table.d.ts +21 -4
- package/dist/_generated/zing_studio/deps/sui/table.js +2 -3
- package/dist/_generated/zing_studio/deps/walrus/blob.d.ts +2 -6
- package/dist/_generated/zing_studio/deps/walrus/blob.js +1 -2
- package/dist/_generated/zing_studio/deps/walrus/storage_resource.d.ts +1 -3
- package/dist/_generated/zing_studio/deps/walrus/storage_resource.js +1 -2
- package/dist/_generated/zing_studio/deps/zing_framework/derived_object_bag.d.ts +1 -3
- package/dist/_generated/zing_studio/deps/zing_framework/derived_object_bag.js +1 -2
- package/dist/_generated/zing_studio/deps/zing_framework/derived_table.d.ts +2 -4
- package/dist/_generated/zing_studio/deps/zing_framework/derived_table.js +2 -3
- package/dist/_generated/zing_studio/donation.d.ts +6 -14
- package/dist/_generated/zing_studio/donation.js +2 -2
- package/dist/_generated/zing_studio/enclave.d.ts +17 -10
- package/dist/_generated/zing_studio/enclave.js +16 -41
- package/dist/_generated/zing_studio/referral.js +15 -46
- package/dist/_generated/zing_studio/storage.d.ts +13 -17
- package/dist/_generated/zing_studio/storage.js +46 -100
- package/dist/_generated/zing_studio/studio.d.ts +6 -28
- package/dist/_generated/zing_studio/studio.js +23 -96
- package/dist/client/index.d.ts +22 -56
- package/dist/client/index.js +4 -30
- package/dist/components/zing-provider.d.ts +2 -0
- package/dist/components/zing-provider.js +3 -2
- package/dist/getters.d.ts +17 -62
- package/dist/getters.js +62 -56
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useGetStudio.d.ts +4 -10
- package/dist/hooks/useReclaim.d.ts +0 -10
- package/dist/hooks/useReclaim.js +169 -92
- package/dist/hooks/useSignAndExecuteTransaction.js +4 -1
- package/dist/hooks/useZingInfiniteQueries.d.ts +3 -9
- package/dist/hooks/useZingInfiniteQueries.js +1 -0
- package/dist/hooks/useZingQueries.d.ts +8 -27
- package/dist/hooks/useZingQueries.js +1 -2
- package/dist/hooks/useZingQuery.d.ts +11 -36
- package/dist/hooks/useZingQuery.js +1 -2
- package/dist/lib/utils/index.d.ts +0 -1
- package/dist/lib/utils/index.js +0 -1
- package/dist/lib/utils/reclaim.d.ts +1 -29
- package/dist/lib/utils/reclaim.js +148 -87
- package/dist/mutations/signer.js +1 -1
- package/dist/mutations/walrus.js +1 -1
- package/package.json +1 -1
- package/dist/_generated/zing_framework/deps/sui/object.d.ts +0 -8
- package/dist/_generated/zing_framework/deps/sui/object.js +0 -13
- package/dist/_generated/zing_governance/deps/sui/object.d.ts +0 -8
- package/dist/_generated/zing_governance/deps/sui/object.js +0 -13
- package/dist/_generated/zing_identity/config.d.ts +0 -87
- package/dist/_generated/zing_identity/config.js +0 -98
- package/dist/_generated/zing_identity/deps/std/type_name.d.ts +0 -17
- package/dist/_generated/zing_identity/deps/std/type_name.js +0 -22
- package/dist/_generated/zing_identity/deps/sui/object.d.ts +0 -8
- package/dist/_generated/zing_identity/deps/sui/object.js +0 -13
- package/dist/_generated/zing_identity/deps/sui/object_table.d.ts +0 -12
- package/dist/_generated/zing_identity/deps/sui/object_table.js +0 -23
- package/dist/_generated/zing_identity/deps/sui/table.d.ts +0 -12
- package/dist/_generated/zing_identity/deps/sui/table.js +0 -35
- package/dist/_generated/zing_identity/deps/sui/vec_set.d.ts +0 -17
- package/dist/_generated/zing_identity/deps/sui/vec_set.js +0 -22
- package/dist/_generated/zing_identity/ecdsa.d.ts +0 -81
- package/dist/_generated/zing_identity/ecdsa.js +0 -87
- package/dist/_generated/zing_identity/identity.d.ts +0 -262
- package/dist/_generated/zing_identity/identity.js +0 -294
- package/dist/_generated/zing_identity/reclaim.d.ts +0 -356
- package/dist/_generated/zing_identity/reclaim.js +0 -414
- package/dist/_generated/zing_studio/nitro_attestation.d.ts +0 -148
- package/dist/_generated/zing_studio/nitro_attestation.js +0 -183
package/dist/getters.d.ts
CHANGED
|
@@ -6,25 +6,10 @@ export declare function getDerivedStorageID(studioConfigId: string, address: str
|
|
|
6
6
|
export declare function getDerivedWorksID(studioConfigId: string, address: string): string;
|
|
7
7
|
export declare function getDerivedMembershipID(studioConfigId: string, address: string): string;
|
|
8
8
|
export declare function getReferralID(studioConfigId: string, address: string): string;
|
|
9
|
-
export declare function getIdentifierByAddress(suiGrpcClient: SuiGrpcClient, addressToIdentifierDynamicFieldId: string, address: string): Promise<string | null>;
|
|
10
|
-
export declare function getIdentifierInfoByIdentifier(suiGrpcClient: SuiGrpcClient, identifierInfoDynamicFieldId: string, identifier: string): Promise<{
|
|
11
|
-
owner: string;
|
|
12
|
-
updated_at: string;
|
|
13
|
-
} | null>;
|
|
14
|
-
export declare function getDonationByIdentifier(suiGrpcClient: SuiGrpcClient, donationTableId: string, identifier: string): Promise<{
|
|
15
|
-
contents: {
|
|
16
|
-
key: {
|
|
17
|
-
name: string;
|
|
18
|
-
};
|
|
19
|
-
value: string;
|
|
20
|
-
}[];
|
|
21
|
-
} | null>;
|
|
22
9
|
export declare function getStudio(suiGrpcClient: SuiGrpcClient, studioId: string): Promise<{
|
|
23
|
-
id:
|
|
24
|
-
id: string;
|
|
25
|
-
};
|
|
10
|
+
id: string;
|
|
26
11
|
owner: string;
|
|
27
|
-
period: string
|
|
12
|
+
period: [string, string];
|
|
28
13
|
monthly_subscription_fee: {
|
|
29
14
|
contents: {
|
|
30
15
|
key: number;
|
|
@@ -32,15 +17,11 @@ export declare function getStudio(suiGrpcClient: SuiGrpcClient, studioId: string
|
|
|
32
17
|
}[];
|
|
33
18
|
};
|
|
34
19
|
membership: {
|
|
35
|
-
id:
|
|
36
|
-
id: string;
|
|
37
|
-
};
|
|
20
|
+
id: string;
|
|
38
21
|
size: string;
|
|
39
22
|
};
|
|
40
23
|
works: {
|
|
41
|
-
id:
|
|
42
|
-
id: string;
|
|
43
|
-
};
|
|
24
|
+
id: string;
|
|
44
25
|
size: string;
|
|
45
26
|
};
|
|
46
27
|
encrypted_file_key: number[] | null;
|
|
@@ -52,9 +33,7 @@ export declare function getStudio(suiGrpcClient: SuiGrpcClient, studioId: string
|
|
|
52
33
|
};
|
|
53
34
|
} | null>;
|
|
54
35
|
export declare function getStorageSpace(suiGrpcClient: SuiGrpcClient, storageSpaceId: string): Promise<{
|
|
55
|
-
id:
|
|
56
|
-
id: string;
|
|
57
|
-
};
|
|
36
|
+
id: string;
|
|
58
37
|
owner: string;
|
|
59
38
|
tier: number | null;
|
|
60
39
|
storage_used: {
|
|
@@ -70,9 +49,7 @@ export declare function getStorageSpace(suiGrpcClient: SuiGrpcClient, storageSpa
|
|
|
70
49
|
};
|
|
71
50
|
} | null>;
|
|
72
51
|
export declare function getStorageTreasury(suiGrpcClient: SuiGrpcClient, storageTreasuryId: string): Promise<{
|
|
73
|
-
id:
|
|
74
|
-
id: string;
|
|
75
|
-
};
|
|
52
|
+
id: string;
|
|
76
53
|
tier_plan: {
|
|
77
54
|
contents: {
|
|
78
55
|
key: number;
|
|
@@ -87,9 +64,7 @@ export declare function getStorageTreasury(suiGrpcClient: SuiGrpcClient, storage
|
|
|
87
64
|
contents: {
|
|
88
65
|
key: number;
|
|
89
66
|
value: {
|
|
90
|
-
id:
|
|
91
|
-
id: string;
|
|
92
|
-
};
|
|
67
|
+
id: string;
|
|
93
68
|
start_epoch: number;
|
|
94
69
|
end_epoch: number;
|
|
95
70
|
storage_size: string;
|
|
@@ -103,9 +78,7 @@ export declare function getStorageTreasury(suiGrpcClient: SuiGrpcClient, storage
|
|
|
103
78
|
}[];
|
|
104
79
|
};
|
|
105
80
|
wal_treasury: {
|
|
106
|
-
id:
|
|
107
|
-
id: string;
|
|
108
|
-
};
|
|
81
|
+
id: string;
|
|
109
82
|
balance: {
|
|
110
83
|
value: string;
|
|
111
84
|
};
|
|
@@ -139,26 +112,20 @@ export declare function getReferral(suiGrpcClient: SuiGrpcClient, referralID: st
|
|
|
139
112
|
expired_at: string;
|
|
140
113
|
} | null>;
|
|
141
114
|
export declare function getWork(suiGrpcClient: SuiGrpcClient, workId: string, workType?: string): Promise<{
|
|
142
|
-
id:
|
|
143
|
-
id: string;
|
|
144
|
-
};
|
|
115
|
+
id: string;
|
|
145
116
|
owner: string;
|
|
146
117
|
deleted: boolean;
|
|
147
118
|
created_at: string;
|
|
148
119
|
subscription_level: number | null;
|
|
149
120
|
blobs: {
|
|
150
|
-
id:
|
|
151
|
-
id: string;
|
|
152
|
-
};
|
|
121
|
+
id: string;
|
|
153
122
|
registered_epoch: number;
|
|
154
123
|
blob_id: string;
|
|
155
124
|
size: string;
|
|
156
125
|
encoding_type: number;
|
|
157
126
|
certified_epoch: number | null;
|
|
158
127
|
storage: {
|
|
159
|
-
id:
|
|
160
|
-
id: string;
|
|
161
|
-
};
|
|
128
|
+
id: string;
|
|
162
129
|
start_epoch: number;
|
|
163
130
|
end_epoch: number;
|
|
164
131
|
storage_size: string;
|
|
@@ -178,26 +145,20 @@ export declare function getWork(suiGrpcClient: SuiGrpcClient, workId: string, wo
|
|
|
178
145
|
} | null>;
|
|
179
146
|
export declare function getWorks(suiGrpcClient: SuiGrpcClient, workTableId: string, workType?: string, cursor?: string, limit?: number): Promise<{
|
|
180
147
|
data: {
|
|
181
|
-
id:
|
|
182
|
-
id: string;
|
|
183
|
-
};
|
|
148
|
+
id: string;
|
|
184
149
|
owner: string;
|
|
185
150
|
deleted: boolean;
|
|
186
151
|
created_at: string;
|
|
187
152
|
subscription_level: number | null;
|
|
188
153
|
blobs: {
|
|
189
|
-
id:
|
|
190
|
-
id: string;
|
|
191
|
-
};
|
|
154
|
+
id: string;
|
|
192
155
|
registered_epoch: number;
|
|
193
156
|
blob_id: string;
|
|
194
157
|
size: string;
|
|
195
158
|
encoding_type: number;
|
|
196
159
|
certified_epoch: number | null;
|
|
197
160
|
storage: {
|
|
198
|
-
id:
|
|
199
|
-
id: string;
|
|
200
|
-
};
|
|
161
|
+
id: string;
|
|
201
162
|
start_epoch: number;
|
|
202
163
|
end_epoch: number;
|
|
203
164
|
storage_size: string;
|
|
@@ -219,26 +180,20 @@ export declare function getWorks(suiGrpcClient: SuiGrpcClient, workTableId: stri
|
|
|
219
180
|
hasNextPage: boolean;
|
|
220
181
|
}>;
|
|
221
182
|
export declare function getWorksByObjectIds(suiGrpcClient: SuiGrpcClient, workObjectIds: string[], workType?: string): Promise<{
|
|
222
|
-
id:
|
|
223
|
-
id: string;
|
|
224
|
-
};
|
|
183
|
+
id: string;
|
|
225
184
|
owner: string;
|
|
226
185
|
deleted: boolean;
|
|
227
186
|
created_at: string;
|
|
228
187
|
subscription_level: number | null;
|
|
229
188
|
blobs: {
|
|
230
|
-
id:
|
|
231
|
-
id: string;
|
|
232
|
-
};
|
|
189
|
+
id: string;
|
|
233
190
|
registered_epoch: number;
|
|
234
191
|
blob_id: string;
|
|
235
192
|
size: string;
|
|
236
193
|
encoding_type: number;
|
|
237
194
|
certified_epoch: number | null;
|
|
238
195
|
storage: {
|
|
239
|
-
id:
|
|
240
|
-
id: string;
|
|
241
|
-
};
|
|
196
|
+
id: string;
|
|
242
197
|
start_epoch: number;
|
|
243
198
|
end_epoch: number;
|
|
244
199
|
storage_size: string;
|
package/dist/getters.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IdentifierInfo } from "./_generated/zing_identity/identity.js";
|
|
3
|
-
import { Article, PublishArticleEventV1, } from "./_generated/zing_studio/article.js";
|
|
1
|
+
import { Article, PublishArticleEvent, } from "./_generated/zing_studio/article.js";
|
|
4
2
|
import { Field } from "./_generated/zing_studio/deps/sui/dynamic_field.js";
|
|
5
|
-
import { VecMap } from "./_generated/zing_studio/deps/sui/vec_map.js";
|
|
6
3
|
import { BlobRegistered } from "./_generated/zing_studio/deps/walrus/events.js";
|
|
7
4
|
import { Referral } from "./_generated/zing_studio/referral.js";
|
|
8
5
|
import { StorageSpace, StorageTreasury, } from "./_generated/zing_studio/storage.js";
|
|
@@ -37,57 +34,66 @@ export function getReferralID(studioConfigId, address) {
|
|
|
37
34
|
const key = new TextEncoder().encode("referral");
|
|
38
35
|
return deriveDynamicFieldID(studioId, "vector<u8>", bcs.vector(bcs.u8()).serialize(key).toBytes());
|
|
39
36
|
}
|
|
40
|
-
export async function getIdentifierByAddress(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
37
|
+
// export async function getIdentifierByAddress(
|
|
38
|
+
// suiGrpcClient: SuiGrpcClient,
|
|
39
|
+
// addressToIdentifierDynamicFieldId: string,
|
|
40
|
+
// address: string,
|
|
41
|
+
// ) {
|
|
42
|
+
// const dfObjectId = deriveDynamicFieldID(
|
|
43
|
+
// addressToIdentifierDynamicFieldId,
|
|
44
|
+
// "address",
|
|
45
|
+
// bcs.Address.serialize(address).toBytes(),
|
|
46
|
+
// );
|
|
47
|
+
// const res = await suiGrpcClient.ledgerService.getObject({
|
|
48
|
+
// objectId: dfObjectId,
|
|
49
|
+
// readMask: {
|
|
50
|
+
// paths: ["bcs"],
|
|
51
|
+
// },
|
|
52
|
+
// });
|
|
53
|
+
// if (!res.response.object?.bcs?.value) {
|
|
54
|
+
// return null;
|
|
55
|
+
// }
|
|
56
|
+
//
|
|
57
|
+
// const suiMoveObject = bcs.Object.parse(res.response.object.bcs.value);
|
|
58
|
+
// if (suiMoveObject.data.$kind === "Package")
|
|
59
|
+
// throw new Error("Move Object is Package");
|
|
60
|
+
//
|
|
61
|
+
// const field = Field(bcs.Address, bcs.String).parse(
|
|
62
|
+
// suiMoveObject.data.Move.contents,
|
|
63
|
+
// );
|
|
64
|
+
//
|
|
65
|
+
// return field.value;
|
|
66
|
+
// }
|
|
67
|
+
// export async function getIdentifierInfoByIdentifier(
|
|
68
|
+
// suiGrpcClient: SuiGrpcClient,
|
|
69
|
+
// identifierInfoDynamicFieldId: string,
|
|
70
|
+
// identifier: string,
|
|
71
|
+
// ) {
|
|
72
|
+
// const dfObjectId = deriveDynamicFieldID(
|
|
73
|
+
// identifierInfoDynamicFieldId,
|
|
74
|
+
// "0x1::ascii::String",
|
|
75
|
+
// bcs.Address.serialize(identifier).toBytes(),
|
|
76
|
+
// );
|
|
77
|
+
// const res = await suiGrpcClient.ledgerService.getObject({
|
|
78
|
+
// objectId: dfObjectId,
|
|
79
|
+
// readMask: {
|
|
80
|
+
// paths: ["bcs"],
|
|
81
|
+
// },
|
|
82
|
+
// });
|
|
83
|
+
// if (!res.response.object?.bcs?.value) {
|
|
84
|
+
// return null;
|
|
85
|
+
// }
|
|
86
|
+
//
|
|
87
|
+
// const suiMoveObject = bcs.Object.parse(res.response.object.bcs.value);
|
|
88
|
+
// if (suiMoveObject.data.$kind === "Package")
|
|
89
|
+
// throw new Error("Move Object is Package");
|
|
90
|
+
//
|
|
91
|
+
// const field = Field(bcs.String, IdentifierInfo).parse(
|
|
92
|
+
// suiMoveObject.data.Move.contents,
|
|
93
|
+
// );
|
|
94
|
+
//
|
|
95
|
+
// return field.value;
|
|
96
|
+
// }
|
|
91
97
|
export async function getStudio(suiGrpcClient, studioId) {
|
|
92
98
|
try {
|
|
93
99
|
const res = await suiGrpcClient.ledgerService.getObject({
|
|
@@ -304,7 +310,7 @@ export async function getPublishedArticleAndBlobId(suiGrpcClient, walrusClient,
|
|
|
304
310
|
throw new Error("fail to get publishArticleEvent");
|
|
305
311
|
}
|
|
306
312
|
const blobObjectId = BlobRegistered.parse(blobRegisteredEvent.contents?.value).object_id;
|
|
307
|
-
const parsedPublishArticleEvent =
|
|
313
|
+
const parsedPublishArticleEvent = PublishArticleEvent.parse(publishArticleEvent.contents.value);
|
|
308
314
|
return { parsedPublishArticleEvent, blobObjectId };
|
|
309
315
|
}
|
|
310
316
|
export function encodeQuiltPatchId(id) {
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export declare function useGetStudio(suiAddress?: string): import("@tanstack/react-query").UseQueryResult<{
|
|
2
|
-
id:
|
|
3
|
-
id: string;
|
|
4
|
-
};
|
|
2
|
+
id: string;
|
|
5
3
|
owner: string;
|
|
6
|
-
period: string
|
|
4
|
+
period: [string, string];
|
|
7
5
|
monthly_subscription_fee: {
|
|
8
6
|
contents: {
|
|
9
7
|
key: number;
|
|
@@ -11,15 +9,11 @@ export declare function useGetStudio(suiAddress?: string): import("@tanstack/rea
|
|
|
11
9
|
}[];
|
|
12
10
|
};
|
|
13
11
|
membership: {
|
|
14
|
-
id:
|
|
15
|
-
id: string;
|
|
16
|
-
};
|
|
12
|
+
id: string;
|
|
17
13
|
size: string;
|
|
18
14
|
};
|
|
19
15
|
works: {
|
|
20
|
-
id:
|
|
21
|
-
id: string;
|
|
22
|
-
};
|
|
16
|
+
id: string;
|
|
23
17
|
size: string;
|
|
24
18
|
};
|
|
25
19
|
encrypted_file_key: number[] | null;
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import type { PlatformType } from "../config/common.js";
|
|
2
|
-
import type { ReclaimProof } from "../lib/utils/reclaim.js";
|
|
3
|
-
import type { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
4
|
-
interface CommitProofParams {
|
|
5
|
-
suiClient: SuiGrpcClient;
|
|
6
|
-
walletAddress: string;
|
|
7
|
-
platform: PlatformType;
|
|
8
|
-
proof: ReclaimProof;
|
|
9
|
-
}
|
|
10
|
-
export declare function useCommitProof(): import("@tanstack/react-query").UseMutationResult<import("@mysten/sui/jsonRpc").TransactionEffects | null, Error, CommitProofParams, unknown>;
|
|
11
1
|
export {};
|
package/dist/hooks/useReclaim.js
CHANGED
|
@@ -1,92 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
export {};
|
|
2
|
+
// import { useSignAndExecuteTransaction } from "./useSignAndExecuteTransaction.js";
|
|
3
|
+
// import {
|
|
4
|
+
// commitProof,
|
|
5
|
+
// revealAndVerifyProof,
|
|
6
|
+
// } from "../_generated/zing_identity/reclaim.js";
|
|
7
|
+
// import { useZingClient } from "../components/zing-provider.js";
|
|
8
|
+
// import {
|
|
9
|
+
// hexToBytes,
|
|
10
|
+
// textToBytes,
|
|
11
|
+
// generateCommitmentHash,
|
|
12
|
+
// generateCommitNonce,
|
|
13
|
+
// } from "../lib/utils/reclaim.js";
|
|
14
|
+
// import { bcs } from "@mysten/sui/bcs";
|
|
15
|
+
// import { Transaction } from "@mysten/sui/transactions";
|
|
16
|
+
// import { useMutation } from "@tanstack/react-query";
|
|
17
|
+
// import sha3 from "js-sha3";
|
|
18
|
+
// import type { PlatformType } from "../config/common.js";
|
|
19
|
+
// import type { ReclaimProof } from "../lib/utils/reclaim.js";
|
|
20
|
+
// import type { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
21
|
+
//
|
|
22
|
+
// interface CommitProofParams {
|
|
23
|
+
// suiClient: SuiGrpcClient;
|
|
24
|
+
// walletAddress: string;
|
|
25
|
+
// platform: PlatformType;
|
|
26
|
+
// proof: ReclaimProof;
|
|
27
|
+
// }
|
|
28
|
+
//
|
|
29
|
+
// export function useCommitProof() {
|
|
30
|
+
// const { mutateAsync: signAndExecuteTransaction } =
|
|
31
|
+
// useSignAndExecuteTransaction();
|
|
32
|
+
// const zingClient = useZingClient();
|
|
33
|
+
// const config = zingClient.config;
|
|
34
|
+
//
|
|
35
|
+
// return useMutation({
|
|
36
|
+
// mutationFn: async ({
|
|
37
|
+
// suiClient,
|
|
38
|
+
// walletAddress,
|
|
39
|
+
// platform,
|
|
40
|
+
// proof,
|
|
41
|
+
// }: CommitProofParams) => {
|
|
42
|
+
// const nonce = generateCommitNonce(walletAddress, proof.identifier);
|
|
43
|
+
// const commitmentHash = generateCommitmentHash(proof, nonce);
|
|
44
|
+
// const identifierHash = hexToBytes(
|
|
45
|
+
// sha3.keccak256(textToBytes(proof.identifier)),
|
|
46
|
+
// );
|
|
47
|
+
//
|
|
48
|
+
// const identityPlatform = config.zing.IDENTITY_PLATFORMS[platform];
|
|
49
|
+
// const commitProofTransaction = new Transaction();
|
|
50
|
+
//
|
|
51
|
+
// commitProofTransaction.add(
|
|
52
|
+
// commitProof({
|
|
53
|
+
// package: config.zing.ZING_IDENTITY_PACKAGE_ADDRESS,
|
|
54
|
+
// typeArguments: [identityPlatform.PLATFORM_TYPE],
|
|
55
|
+
// arguments: {
|
|
56
|
+
// self: commitProofTransaction.sharedObjectRef(
|
|
57
|
+
// identityPlatform.RECLAIM_MANAGER_SHARED_OBJECT_REF,
|
|
58
|
+
// ),
|
|
59
|
+
// config: commitProofTransaction.sharedObjectRef(
|
|
60
|
+
// config.zing.ZING_IDENTITY_CONFIG_SHARED_OBJECT_REF,
|
|
61
|
+
// ),
|
|
62
|
+
// commitmentHash: commitProofTransaction.pure(
|
|
63
|
+
// bcs.vector(bcs.u8()).serialize(commitmentHash),
|
|
64
|
+
// ),
|
|
65
|
+
// identifierHash: commitProofTransaction.pure(
|
|
66
|
+
// bcs.vector(bcs.u8()).serialize(identifierHash),
|
|
67
|
+
// ),
|
|
68
|
+
// },
|
|
69
|
+
// }),
|
|
70
|
+
// );
|
|
71
|
+
//
|
|
72
|
+
// const commitTransactionResponse = await signAndExecuteTransaction({
|
|
73
|
+
// transaction: commitProofTransaction,
|
|
74
|
+
// });
|
|
75
|
+
// if (!commitTransactionResponse) throw new Error("fail to commit proof");
|
|
76
|
+
//
|
|
77
|
+
// const settledCommitTransactionResult = await suiClient.waitForTransaction(
|
|
78
|
+
// {
|
|
79
|
+
// digest: commitTransactionResponse.transactionDigest,
|
|
80
|
+
// include: {
|
|
81
|
+
// effects: true,
|
|
82
|
+
// objectTypes: true,
|
|
83
|
+
// },
|
|
84
|
+
// },
|
|
85
|
+
// );
|
|
86
|
+
//
|
|
87
|
+
// const commitTransactionObjectChanges =
|
|
88
|
+
// settledCommitTransactionResult.Transaction?.effects.changedObjects ||
|
|
89
|
+
// [];
|
|
90
|
+
//
|
|
91
|
+
// if (!commitTransactionObjectChanges)
|
|
92
|
+
// throw new Error("fail to commit proof");
|
|
93
|
+
//
|
|
94
|
+
// const commitment = commitTransactionObjectChanges.find((objChange) => {
|
|
95
|
+
// if (objChange.idOperation !== "Created") return false;
|
|
96
|
+
// const type =
|
|
97
|
+
// settledCommitTransactionResult.Transaction?.objectTypes![
|
|
98
|
+
// objChange.objectId
|
|
99
|
+
// ];
|
|
100
|
+
// return type === config.zing.PROOF_COMMITMENT_TYPE;
|
|
101
|
+
// });
|
|
102
|
+
//
|
|
103
|
+
// if (!commitment || commitment.idOperation !== "Created")
|
|
104
|
+
// throw new Error("fail to commit proof");
|
|
105
|
+
//
|
|
106
|
+
// const revealTransaction = new Transaction();
|
|
107
|
+
//
|
|
108
|
+
// const [, proofObj] = revealTransaction.add(
|
|
109
|
+
// revealAndVerifyProof({
|
|
110
|
+
// package: config.zing.ZING_IDENTITY_PACKAGE_ADDRESS,
|
|
111
|
+
// typeArguments: [identityPlatform.PLATFORM_TYPE],
|
|
112
|
+
// arguments: {
|
|
113
|
+
// self: revealTransaction.sharedObjectRef(
|
|
114
|
+
// identityPlatform.RECLAIM_MANAGER_SHARED_OBJECT_REF,
|
|
115
|
+
// ),
|
|
116
|
+
// config: revealTransaction.sharedObjectRef(
|
|
117
|
+
// config.zing.ZING_IDENTITY_CONFIG_SHARED_OBJECT_REF,
|
|
118
|
+
// ),
|
|
119
|
+
// commitmentId: revealTransaction.pure.id(commitment.objectId),
|
|
120
|
+
// provider: revealTransaction.pure.string(proof.claimData.provider),
|
|
121
|
+
// parameters: revealTransaction.pure.string(
|
|
122
|
+
// proof.claimData.parameters,
|
|
123
|
+
// ),
|
|
124
|
+
// context: revealTransaction.pure.string(proof.claimData.context),
|
|
125
|
+
// identifier: revealTransaction.pure.string(
|
|
126
|
+
// proof.claimData.identifier,
|
|
127
|
+
// ),
|
|
128
|
+
// owner: revealTransaction.pure.string(proof.claimData.owner),
|
|
129
|
+
// epoch: revealTransaction.pure.string(
|
|
130
|
+
// proof.claimData.epoch.toString(),
|
|
131
|
+
// ),
|
|
132
|
+
// timestampS: revealTransaction.pure.u64(proof.claimData.timestampS),
|
|
133
|
+
// signatures: revealTransaction.pure(
|
|
134
|
+
// bcs
|
|
135
|
+
// .vector(bcs.vector(bcs.u8()))
|
|
136
|
+
// .serialize(
|
|
137
|
+
// proof.signatures.map((sig) => hexToBytes(sig.substring(2))),
|
|
138
|
+
// ),
|
|
139
|
+
// ),
|
|
140
|
+
// nonce: revealTransaction.pure(
|
|
141
|
+
// bcs.vector(bcs.u8()).serialize(nonce),
|
|
142
|
+
// ),
|
|
143
|
+
// },
|
|
144
|
+
// }),
|
|
145
|
+
// );
|
|
146
|
+
//
|
|
147
|
+
// // Call extract parameters customizaed functions; this interface should identical for different platforms
|
|
148
|
+
// revealTransaction.moveCall({
|
|
149
|
+
// target: identityPlatform.PLATFORM_UPDATE_PROOF_TARGET,
|
|
150
|
+
// arguments: [
|
|
151
|
+
// // IdentityManager
|
|
152
|
+
// revealTransaction.sharedObjectRef(
|
|
153
|
+
// identityPlatform.IDENTITY_MANAGER_SHARED_OBJECT_REF,
|
|
154
|
+
// ),
|
|
155
|
+
// // IdentityConfig
|
|
156
|
+
// revealTransaction.sharedObjectRef(
|
|
157
|
+
// config.zing.ZING_IDENTITY_CONFIG_SHARED_OBJECT_REF,
|
|
158
|
+
// ),
|
|
159
|
+
// proofObj,
|
|
160
|
+
// ],
|
|
161
|
+
// });
|
|
162
|
+
//
|
|
163
|
+
// const transactionResponse = await signAndExecuteTransaction({
|
|
164
|
+
// transaction: revealTransaction,
|
|
165
|
+
// });
|
|
166
|
+
// return transactionResponse;
|
|
167
|
+
// },
|
|
168
|
+
// });
|
|
169
|
+
// }
|