@zing-protocol/zing-sdk 0.0.10 → 0.0.12

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.
@@ -48,6 +48,43 @@ export declare const PublishArticleEvent: MoveStruct<{
48
48
  }, "0x2::vec_map::VecMap<string, @local-pkg/zing_studio::article::File>">;
49
49
  timestamp_ms: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
50
50
  }, "@local-pkg/zing_studio::article::PublishArticleEvent">;
51
+ export declare const PublishArticleEventV1: MoveStruct<{
52
+ article_id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
53
+ owner: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
54
+ subscription_level: import("@mysten/sui/bcs").BcsType<number | null, number | null | undefined, "Option<u8>">;
55
+ blob_ids: import("@mysten/sui/bcs").BcsType<string[], Iterable<string | number | bigint> & {
56
+ length: number;
57
+ }, string>;
58
+ blob_sizes: import("@mysten/sui/bcs").BcsType<string[], Iterable<string | number | bigint> & {
59
+ length: number;
60
+ }, string>;
61
+ blob_storage_sizes: import("@mysten/sui/bcs").BcsType<string[], Iterable<string | number | bigint> & {
62
+ length: number;
63
+ }, string>;
64
+ blob_end_epochs: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
65
+ length: number;
66
+ }, string>;
67
+ files: MoveStruct<{
68
+ contents: import("@mysten/sui/bcs").BcsType<{
69
+ key: string;
70
+ value: {
71
+ blob_index: string;
72
+ mime_type: string;
73
+ size: string;
74
+ };
75
+ }[], Iterable<{
76
+ key: string;
77
+ value: {
78
+ blob_index: string | number | bigint;
79
+ mime_type: string;
80
+ size: string | number | bigint;
81
+ };
82
+ }> & {
83
+ length: number;
84
+ }, string>;
85
+ }, "0x2::vec_map::VecMap<string, @local-pkg/zing_studio::article::File>">;
86
+ timestamp_ms: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
87
+ }, "@local-pkg/zing_studio::article::PublishArticleEventV1">;
51
88
  export declare const BurnArticleEvent: MoveStruct<{
52
89
  article_id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
53
90
  owner: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
@@ -34,6 +34,20 @@ export const PublishArticleEvent = new MoveStruct({
34
34
  timestamp_ms: bcs.u64(),
35
35
  },
36
36
  });
37
+ export const PublishArticleEventV1 = new MoveStruct({
38
+ name: `${$moduleName}::PublishArticleEventV1`,
39
+ fields: {
40
+ article_id: bcs.Address,
41
+ owner: bcs.Address,
42
+ subscription_level: bcs.option(bcs.u8()),
43
+ blob_ids: bcs.vector(bcs.u256()),
44
+ blob_sizes: bcs.vector(bcs.u64()),
45
+ blob_storage_sizes: bcs.vector(bcs.u64()),
46
+ blob_end_epochs: bcs.vector(bcs.u32()),
47
+ files: vec_map.VecMap(bcs.string(), File),
48
+ timestamp_ms: bcs.u64(),
49
+ },
50
+ });
37
51
  export const BurnArticleEvent = new MoveStruct({
38
52
  name: `${$moduleName}::BurnArticleEvent`,
39
53
  fields: {
@@ -23,6 +23,7 @@ export declare class ZingClient {
23
23
  getDerivedStorageID(address: string): string;
24
24
  getDerivedWorksID(address: string): string;
25
25
  getDerivedMembershipID(address: string): string;
26
+ getReferralID(address: string): string;
26
27
  getIdentifierByAddress(platform: PlatformType, address: string): Promise<string | null>;
27
28
  getIdentifierInfoByIdentifier(platform: PlatformType, identifier: string): Promise<{
28
29
  owner: string;
@@ -142,6 +143,11 @@ export declare class ZingClient {
142
143
  nextCursor: string | undefined;
143
144
  hasNextPage: boolean;
144
145
  }>;
146
+ getReferral(owner: string): Promise<{
147
+ referrer_earning: string;
148
+ referrer: string;
149
+ expired_at: string;
150
+ } | null>;
145
151
  getWork(workId: string, workType?: WorkType): Promise<{
146
152
  id: {
147
153
  id: string;
@@ -4,7 +4,7 @@ import { addReferralToStudio } from "../_generated/zing_studio/referral.js";
4
4
  import { shareStorageSpace } from "../_generated/zing_studio/storage.js";
5
5
  import { _new as newStudio, sealApproveStudioOwner, shareStudio, } from "../_generated/zing_studio/studio.js";
6
6
  import { getConfig } from "../config/index.js";
7
- import { getDerivedMembershipID, getDerivedStorageID, getDerivedStudioID, getDerivedWorksID, getIdentifierByAddress, getIdentifierInfoByIdentifier, getMember, getMembers, getStorageSpace, getStorageTreasury, getStudio, getWork, getWorks, getWorksByObjectIds, } from "../getters.js";
7
+ import { getDerivedMembershipID, getDerivedStorageID, getDerivedStudioID, getDerivedWorksID, getIdentifierByAddress, getIdentifierInfoByIdentifier, getMember, getMembers, getReferral, getReferralID, getStorageSpace, getStorageTreasury, getStudio, getWork, getWorks, getWorksByObjectIds, } from "../getters.js";
8
8
  import { importFileKey } from "../mutations/seal.js";
9
9
  import { signPersonalMessage } from "../mutations/signer.js";
10
10
  import { SessionKey } from "@mysten/seal";
@@ -33,6 +33,9 @@ export class ZingClient {
33
33
  getDerivedMembershipID(address) {
34
34
  return getDerivedMembershipID(this.config.zing.ZING_STUDIO_CONFIG_SHARED_OBJECT_REF.objectId, address);
35
35
  }
36
+ getReferralID(address) {
37
+ return getReferralID(this.config.zing.ZING_STUDIO_CONFIG_SHARED_OBJECT_REF.objectId, address);
38
+ }
36
39
  async getIdentifierByAddress(platform, address) {
37
40
  return getIdentifierByAddress(this.suiGrpcClient, this.config.zing.IDENTITY_PLATFORMS[platform]
38
41
  .IDENTITY_MANAGER_ADDRESS_TO_IDENTIFIER_DF_ID, address);
@@ -75,6 +78,9 @@ export class ZingClient {
75
78
  async getMembers(owner, cursor, limit = 20) {
76
79
  return getMembers(this.suiGrpcClient, this.getDerivedMembershipID(owner), cursor, limit);
77
80
  }
81
+ async getReferral(owner) {
82
+ return getReferral(this.suiGrpcClient, this.getReferralID(owner));
83
+ }
78
84
  async getWork(workId, workType) {
79
85
  return getWork(this.suiGrpcClient, workId, workType ? this.config.zing.ZING_WORKS_TYPE[workType] : undefined);
80
86
  }
@@ -1,7 +1,7 @@
1
1
  export const testnetZingConfig = {
2
2
  ZING_FRAMEWORK_PACKAGE_ADDRESS: "0xd851eb5b907b60aa5fd958dd74044d809c49ee60001cad621726f03ea138f943",
3
3
  ZING_IDENTITY_PACKAGE_ADDRESS: "0xaaf27a90890ac1efface4fbb22597e95829cbe6cbb771df02f0d2cc93f067c70",
4
- ZING_STUDIO_PACKAGE_ADDRESS: "0x3502955f106ee334653443005b37ebc6d1ddf7b9c704d39090263ae136ba599d",
4
+ ZING_STUDIO_PACKAGE_ADDRESS: "0x4e497b857da8adcd084fd39a887c36801499a1314bb94e026d9e93d13f8f40e5",
5
5
  ZING_STUDIO_V0_PACKAGE_ADDRESS: "0x3502955f106ee334653443005b37ebc6d1ddf7b9c704d39090263ae136ba599d",
6
6
  ZING_TREASURY_SHARED_OBJECT_REF: {
7
7
  objectId: "0xca56bc3982525decbd4b025d3d4ae4de07259d6efc187577bfc3ab212e20574f",
@@ -47,7 +47,7 @@ export const testnetZingConfig = {
47
47
  article: "0x3502955f106ee334653443005b37ebc6d1ddf7b9c704d39090263ae136ba599d::article::Article",
48
48
  },
49
49
  EVENT_TYPES: {
50
- publishArticleEvent: "0x3502955f106ee334653443005b37ebc6d1ddf7b9c704d39090263ae136ba599d::article::PublishArticleEvent",
50
+ publishArticleEvent: "0x4e497b857da8adcd084fd39a887c36801499a1314bb94e026d9e93d13f8f40e5::article::PublishArticleEventV1",
51
51
  },
52
52
  };
53
53
  export const testnetWalrusConfig = {
package/dist/getters.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare function getDerivedStudioID(studioConfigId: string, address: stri
6
6
  export declare function getDerivedStorageID(studioConfigId: string, address: string): string;
7
7
  export declare function getDerivedWorksID(studioConfigId: string, address: string): string;
8
8
  export declare function getDerivedMembershipID(studioConfigId: string, address: string): string;
9
+ export declare function getReferralID(studioConfigId: string, address: string): string;
9
10
  export declare function getIdentifierByAddress(suiGrpcClient: SuiGrpcClient, addressToIdentifierDynamicFieldId: string, address: string): Promise<string | null>;
10
11
  export declare function getIdentifierInfoByIdentifier(suiGrpcClient: SuiGrpcClient, identifierInfoDynamicFieldId: string, identifier: string): Promise<{
11
12
  owner: string;
@@ -133,6 +134,11 @@ export declare function getMembers(suiGrpcClient: SuiGrpcClient, membershipTable
133
134
  nextCursor: string | undefined;
134
135
  hasNextPage: boolean;
135
136
  }>;
137
+ export declare function getReferral(suiGrpcClient: SuiGrpcClient, referralID: string): Promise<{
138
+ referrer_earning: string;
139
+ referrer: string;
140
+ expired_at: string;
141
+ } | null>;
136
142
  export declare function getWork(suiGrpcClient: SuiGrpcClient, workId: string, workType?: string): Promise<{
137
143
  id: {
138
144
  id: string;
package/dist/getters.js CHANGED
@@ -4,6 +4,7 @@ import { Article, PublishArticleEvent, } from "./_generated/zing_studio/article.
4
4
  import { Field } from "./_generated/zing_studio/deps/sui/dynamic_field.js";
5
5
  import { VecMap } from "./_generated/zing_studio/deps/sui/vec_map.js";
6
6
  import { BlobRegistered } from "./_generated/zing_studio/deps/walrus/events.js";
7
+ import { Referral } from "./_generated/zing_studio/referral.js";
7
8
  import { StorageSpace, StorageTreasury, } from "./_generated/zing_studio/storage.js";
8
9
  import { Member, Studio } from "./_generated/zing_studio/studio.js";
9
10
  import { QuiltPatchId, SuiMoveObject } from "./bcs.js";
@@ -31,6 +32,11 @@ export function getDerivedMembershipID(studioConfigId, address) {
31
32
  const key = new TextEncoder().encode("membership");
32
33
  return deriveObjectID(studioId, "vector<u8>", bcs.vector(bcs.u8()).serialize(key).toBytes());
33
34
  }
35
+ export function getReferralID(studioConfigId, address) {
36
+ const studioId = getDerivedStudioID(studioConfigId, address);
37
+ const key = new TextEncoder().encode("referral");
38
+ return deriveDynamicFieldID(studioId, "vector<u8>", bcs.vector(bcs.u8()).serialize(key).toBytes());
39
+ }
34
40
  export async function getIdentifierByAddress(suiGrpcClient, addressToIdentifierDynamicFieldId, address) {
35
41
  const dfObjectId = deriveDynamicFieldID(addressToIdentifierDynamicFieldId, "address", bcs.Address.serialize(address).toBytes());
36
42
  const res = await suiGrpcClient.ledgerService.getObject({
@@ -171,6 +177,20 @@ export async function getMembers(suiGrpcClient, membershipTableId, cursor, limit
171
177
  hasNextPage: res.response.nextPageToken !== undefined,
172
178
  };
173
179
  }
180
+ export async function getReferral(suiGrpcClient, referralID) {
181
+ const res = await suiGrpcClient.ledgerService.getObject({
182
+ objectId: referralID,
183
+ readMask: {
184
+ paths: ["bcs"],
185
+ },
186
+ });
187
+ if (!res.response.object?.bcs?.value) {
188
+ return null;
189
+ }
190
+ const suiMoveObject = SuiMoveObject.parse(res.response.object.bcs.value);
191
+ const field = Field(bcs.vector(bcs.u8()), Referral).parse(suiMoveObject.data.MoveObject.contents);
192
+ return field.value;
193
+ }
174
194
  export async function getWork(suiGrpcClient, workId, workType) {
175
195
  const res = await suiGrpcClient.ledgerService.getObject({
176
196
  objectId: workId,
@@ -112,6 +112,11 @@ declare const zingQueryMethodMap: (zingClient: ZingClient) => {
112
112
  level: number;
113
113
  expired_at: string;
114
114
  } | null>;
115
+ getReferral: (owner: string) => Promise<{
116
+ referrer_earning: string;
117
+ referrer: string;
118
+ expired_at: string;
119
+ } | null>;
115
120
  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>;
116
121
  getWork: (workId: string, workType?: import("../index.js").WorkType) => Promise<{
117
122
  id: {
@@ -10,6 +10,7 @@ const zingQueryMethodMap = (zingClient) => ({
10
10
  getStorageSpace: zingClient.getStorageSpace.bind(zingClient),
11
11
  getStorageTreasury: zingClient.getStorageTreasury.bind(zingClient),
12
12
  getMember: zingClient.getMember.bind(zingClient),
13
+ getReferral: zingClient.getReferral.bind(zingClient),
13
14
  getBalance: zingClient.getBalance.bind(zingClient),
14
15
  getWork: zingClient.getWork.bind(zingClient),
15
16
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@zing-protocol/zing-sdk",
3
3
  "sideEffects": false,
4
4
  "type": "module",
5
- "version": "0.0.10",
5
+ "version": "0.0.12",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {