@misonetwork/sdk 0.8.0 → 0.9.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/README.md +39 -7
- package/dist/client.d.ts +3 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -0
- package/dist/client.js.map +1 -1
- package/dist/contracts/miso/composition.d.ts +0 -14
- package/dist/contracts/miso/composition.d.ts.map +1 -1
- package/dist/contracts/miso/composition.js +0 -15
- package/dist/contracts/miso/composition.js.map +1 -1
- package/dist/contracts/miso/recording.d.ts +0 -15
- package/dist/contracts/miso/recording.d.ts.map +1 -1
- package/dist/contracts/miso/recording.js +0 -15
- package/dist/contracts/miso/recording.js.map +1 -1
- package/dist/contracts/miso/release.d.ts +0 -11
- package/dist/contracts/miso/release.d.ts.map +1 -1
- package/dist/contracts/miso/release.js +0 -14
- package/dist/contracts/miso/release.js.map +1 -1
- package/dist/contracts/miso_party/deps/sui/vec_set.d.ts +21 -0
- package/dist/contracts/miso_party/deps/sui/vec_set.d.ts.map +1 -0
- package/dist/contracts/miso_party/deps/sui/vec_set.js +20 -0
- package/dist/contracts/miso_party/deps/sui/vec_set.js.map +1 -0
- package/dist/contracts/miso_party/party.d.ts +481 -0
- package/dist/contracts/miso_party/party.d.ts.map +1 -0
- package/dist/contracts/miso_party/party.js +527 -0
- package/dist/contracts/miso_party/party.js.map +1 -0
- package/dist/contracts/party_cta/party_cta.d.ts +120 -0
- package/dist/contracts/party_cta/party_cta.d.ts.map +1 -0
- package/dist/contracts/party_cta/party_cta.js +139 -0
- package/dist/contracts/party_cta/party_cta.js.map +1 -0
- package/dist/contracts/party_genre/party_genre.d.ts +117 -0
- package/dist/contracts/party_genre/party_genre.d.ts.map +1 -0
- package/dist/contracts/party_genre/party_genre.js +131 -0
- package/dist/contracts/party_genre/party_genre.js.map +1 -0
- package/dist/contracts/party_media/party_media.d.ts +86 -0
- package/dist/contracts/party_media/party_media.d.ts.map +1 -0
- package/dist/contracts/party_media/party_media.js +97 -0
- package/dist/contracts/party_media/party_media.js.map +1 -0
- package/dist/contracts/party_music/party_music.d.ts +209 -0
- package/dist/contracts/party_music/party_music.d.ts.map +1 -0
- package/dist/contracts/party_music/party_music.js +259 -0
- package/dist/contracts/party_music/party_music.js.map +1 -0
- package/dist/contracts/party_platform_link/party_platform_link.d.ts +89 -0
- package/dist/contracts/party_platform_link/party_platform_link.d.ts.map +1 -0
- package/dist/contracts/party_platform_link/party_platform_link.js +92 -0
- package/dist/contracts/party_platform_link/party_platform_link.js.map +1 -0
- package/dist/contracts/party_pro_link/party_pro_link.d.ts +233 -0
- package/dist/contracts/party_pro_link/party_pro_link.d.ts.map +1 -0
- package/dist/contracts/party_pro_link/party_pro_link.js +289 -0
- package/dist/contracts/party_pro_link/party_pro_link.js.map +1 -0
- package/dist/contracts/party_profile/deps/country_code/country_code.d.ts +15 -0
- package/dist/contracts/party_profile/deps/country_code/country_code.d.ts.map +1 -0
- package/dist/contracts/party_profile/deps/country_code/country_code.js +17 -0
- package/dist/contracts/party_profile/deps/country_code/country_code.js.map +1 -0
- package/dist/contracts/party_profile/deps/language_code/language_code.d.ts +6 -0
- package/dist/contracts/party_profile/deps/language_code/language_code.d.ts.map +1 -0
- package/dist/contracts/party_profile/deps/language_code/language_code.js +8 -0
- package/dist/contracts/party_profile/deps/language_code/language_code.js.map +1 -0
- package/dist/contracts/party_profile/party_profile.d.ts +133 -0
- package/dist/contracts/party_profile/party_profile.d.ts.map +1 -0
- package/dist/contracts/party_profile/party_profile.js +153 -0
- package/dist/contracts/party_profile/party_profile.js.map +1 -0
- package/dist/contracts/party_roles/party_roles.d.ts +201 -0
- package/dist/contracts/party_roles/party_roles.d.ts.map +1 -0
- package/dist/contracts/party_roles/party_roles.js +237 -0
- package/dist/contracts/party_roles/party_roles.js.map +1 -0
- package/dist/contracts/party_social/party_social.d.ts +258 -0
- package/dist/contracts/party_social/party_social.d.ts.map +1 -0
- package/dist/contracts/party_social/party_social.js +320 -0
- package/dist/contracts/party_social/party_social.js.map +1 -0
- package/dist/contracts/party_tags/party_tags.d.ts +116 -0
- package/dist/contracts/party_tags/party_tags.d.ts.map +1 -0
- package/dist/contracts/party_tags/party_tags.js +130 -0
- package/dist/contracts/party_tags/party_tags.js.map +1 -0
- package/dist/contracts/routed_stake/routed_stake.d.ts +0 -14
- package/dist/contracts/routed_stake/routed_stake.d.ts.map +1 -1
- package/dist/contracts/routed_stake/routed_stake.js +0 -14
- package/dist/contracts/routed_stake/routed_stake.js.map +1 -1
- package/dist/contracts/royalty_pool/pool.d.ts +0 -14
- package/dist/contracts/royalty_pool/pool.d.ts.map +1 -1
- package/dist/contracts/royalty_pool/pool.js +0 -14
- package/dist/contracts/royalty_pool/pool.js.map +1 -1
- package/dist/contracts/royalty_pool/stake.d.ts +0 -13
- package/dist/contracts/royalty_pool/stake.d.ts.map +1 -1
- package/dist/contracts/royalty_pool/stake.js +0 -14
- package/dist/contracts/royalty_pool/stake.js.map +1 -1
- package/dist/contracts.d.ts +13 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +14 -2
- package/dist/contracts.js.map +1 -1
- package/dist/deployments.d.ts +2 -2
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +16 -3
- package/dist/deployments.js.map +1 -1
- package/dist/events.d.ts +0 -14
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +0 -4
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/packages.d.ts +39 -4
- package/dist/packages.d.ts.map +1 -1
- package/dist/packages.js +39 -4
- package/dist/packages.js.map +1 -1
- package/dist/party/client.d.ts +233 -0
- package/dist/party/client.d.ts.map +1 -0
- package/dist/party/client.js +222 -0
- package/dist/party/client.js.map +1 -0
- package/dist/party/extensions/ctas.d.ts +19 -0
- package/dist/party/extensions/ctas.d.ts.map +1 -0
- package/dist/party/extensions/ctas.js +25 -0
- package/dist/party/extensions/ctas.js.map +1 -0
- package/dist/party/extensions/genres.d.ts +27 -0
- package/dist/party/extensions/genres.d.ts.map +1 -0
- package/dist/party/extensions/genres.js +31 -0
- package/dist/party/extensions/genres.js.map +1 -0
- package/dist/party/extensions/links.d.ts +65 -0
- package/dist/party/extensions/links.d.ts.map +1 -0
- package/dist/party/extensions/links.js +117 -0
- package/dist/party/extensions/links.js.map +1 -0
- package/dist/party/extensions/media.d.ts +36 -0
- package/dist/party/extensions/media.d.ts.map +1 -0
- package/dist/party/extensions/media.js +45 -0
- package/dist/party/extensions/media.js.map +1 -0
- package/dist/party/extensions/profile.d.ts +24 -0
- package/dist/party/extensions/profile.d.ts.map +1 -0
- package/dist/party/extensions/profile.js +48 -0
- package/dist/party/extensions/profile.js.map +1 -0
- package/dist/party/extensions/roles.d.ts +37 -0
- package/dist/party/extensions/roles.d.ts.map +1 -0
- package/dist/party/extensions/roles.js +46 -0
- package/dist/party/extensions/roles.js.map +1 -0
- package/dist/party/extensions/tags.d.ts +25 -0
- package/dist/party/extensions/tags.d.ts.map +1 -0
- package/dist/party/extensions/tags.js +25 -0
- package/dist/party/extensions/tags.js.map +1 -0
- package/dist/party/index.d.ts +12 -0
- package/dist/party/index.d.ts.map +1 -0
- package/dist/party/index.js +14 -0
- package/dist/party/index.js.map +1 -0
- package/dist/party/internal.d.ts +15 -0
- package/dist/party/internal.d.ts.map +1 -0
- package/dist/party/internal.js +103 -0
- package/dist/party/internal.js.map +1 -0
- package/dist/party/queries.d.ts +38 -0
- package/dist/party/queries.d.ts.map +1 -0
- package/dist/party/queries.js +232 -0
- package/dist/party/queries.js.map +1 -0
- package/dist/party/transactions.d.ts +74 -0
- package/dist/party/transactions.d.ts.map +1 -0
- package/dist/party/transactions.js +85 -0
- package/dist/party/transactions.js.map +1 -0
- package/dist/party/types.d.ts +54 -0
- package/dist/party/types.d.ts.map +1 -0
- package/dist/party/types.js +4 -0
- package/dist/party/types.js.map +1 -0
- package/package.json +6 -2
- package/src/client.ts +16 -0
- package/src/contracts/miso/composition.ts +0 -27
- package/src/contracts/miso/recording.ts +0 -28
- package/src/contracts/miso/release.ts +0 -23
- package/src/contracts/miso_party/deps/sui/vec_set.ts +21 -0
- package/src/contracts/miso_party/party.ts +797 -0
- package/src/contracts/party_cta/party_cta.ts +212 -0
- package/src/contracts/party_genre/party_genre.ts +199 -0
- package/src/contracts/party_media/party_media.ts +141 -0
- package/src/contracts/party_music/party_music.ts +405 -0
- package/src/contracts/party_platform_link/party_platform_link.ts +148 -0
- package/src/contracts/party_pro_link/party_pro_link.ts +453 -0
- package/src/contracts/party_profile/deps/country_code/country_code.ts +19 -0
- package/src/contracts/party_profile/deps/language_code/language_code.ts +7 -0
- package/src/contracts/party_profile/party_profile.ts +239 -0
- package/src/contracts/party_roles/party_roles.ts +363 -0
- package/src/contracts/party_social/party_social.ts +502 -0
- package/src/contracts/party_tags/party_tags.ts +198 -0
- package/src/contracts/routed_stake/routed_stake.ts +0 -27
- package/src/contracts/royalty_pool/pool.ts +0 -27
- package/src/contracts/royalty_pool/stake.ts +0 -26
- package/src/contracts.ts +15 -2
- package/src/deployments.ts +18 -3
- package/src/events.ts +0 -4
- package/src/index.ts +2 -0
- package/src/packages.ts +40 -8
- package/src/party/client.ts +283 -0
- package/src/party/extensions/ctas.ts +46 -0
- package/src/party/extensions/genres.ts +62 -0
- package/src/party/extensions/links.ts +185 -0
- package/src/party/extensions/media.ts +72 -0
- package/src/party/extensions/profile.ts +81 -0
- package/src/party/extensions/roles.ts +94 -0
- package/src/party/extensions/tags.ts +54 -0
- package/src/party/index.ts +14 -0
- package/src/party/internal.ts +119 -0
- package/src/party/queries.ts +303 -0
- package/src/party/transactions.ts +167 -0
- package/src/party/types.ts +95 -0
- package/dist/contracts/release_snapshot_bundle/deps/ori/walrus_data.d.ts +0 -52
- package/dist/contracts/release_snapshot_bundle/deps/ori/walrus_data.d.ts.map +0 -1
- package/dist/contracts/release_snapshot_bundle/deps/ori/walrus_data.js +0 -37
- package/dist/contracts/release_snapshot_bundle/deps/ori/walrus_data.js.map +0 -1
- package/dist/contracts/release_snapshot_bundle/release_snapshot_bundle.d.ts +0 -91
- package/dist/contracts/release_snapshot_bundle/release_snapshot_bundle.d.ts.map +0 -1
- package/dist/contracts/release_snapshot_bundle/release_snapshot_bundle.js +0 -91
- package/dist/contracts/release_snapshot_bundle/release_snapshot_bundle.js.map +0 -1
- package/src/contracts/release_snapshot_bundle/deps/ori/walrus_data.ts +0 -36
- package/src/contracts/release_snapshot_bundle/release_snapshot_bundle.ts +0 -124
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { deriveDynamicFieldID, deriveObjectID } from "@mysten/sui/utils";
|
|
4
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
5
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
6
|
+
import { MembershipKey as MembershipKeyBcs, Party as PartyBcs, PendingInviteKey as PendingInviteKeyBcs, PendingMembershipKey as PendingMembershipKeyBcs, } from "../contracts/miso_party/party.js";
|
|
7
|
+
import { Profile as ProfileBcs, ProfileKey as ProfileKeyBcs } from "../contracts/party_profile/party_profile.js";
|
|
8
|
+
import { Media as MediaBcs, MediaKey as MediaKeyBcs } from "../contracts/party_media/party_media.js";
|
|
9
|
+
import { ArtistRole as ArtistRoleBcs, RolesKey as RolesKeyBcs } from "../contracts/party_roles/party_roles.js";
|
|
10
|
+
import { TagsKey as TagsKeyBcs } from "../contracts/party_tags/party_tags.js";
|
|
11
|
+
import { GenresKey as GenresKeyBcs } from "../contracts/party_genre/party_genre.js";
|
|
12
|
+
import { Cta as CtaBcs, CtasKey as CtasKeyBcs } from "../contracts/party_cta/party_cta.js";
|
|
13
|
+
import { mapCtas, mapGenres, mapMedia, mapParty, mapProfile, mapRoles, mapTags } from "./internal.js";
|
|
14
|
+
import { buildLink, platformForDataType } from "./extensions/links.js";
|
|
15
|
+
/** True for the Core API's "object does not exist" error (a missing dynamic field). */
|
|
16
|
+
function isNotFound(e) {
|
|
17
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
18
|
+
return /not\s*found|does not exist|no object/i.test(msg);
|
|
19
|
+
}
|
|
20
|
+
// A missing object (e.g. an unset profile/media dynamic field) surfaces as a
|
|
21
|
+
// thrown "not found" from the Core API, not an empty result — treat it as null
|
|
22
|
+
// so optional extensions read cleanly.
|
|
23
|
+
async function getContent(client, objectId) {
|
|
24
|
+
try {
|
|
25
|
+
const { object } = await client.core.getObject({ objectId, include: { content: true } });
|
|
26
|
+
return object?.content ?? null;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
if (isNotFound(e))
|
|
30
|
+
return null;
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Fetches and parses a shared `Party` object. */
|
|
35
|
+
export async function getPartyById(client, partyId) {
|
|
36
|
+
const content = await getContent(client, partyId);
|
|
37
|
+
if (!content)
|
|
38
|
+
throw new Error(`Party not found: ${partyId}`);
|
|
39
|
+
return mapParty(partyId, PartyBcs.parse(content));
|
|
40
|
+
}
|
|
41
|
+
/** Fetches and parses multiple shared `Party` objects in one Core request. */
|
|
42
|
+
export async function getPartiesByIds(client, partyIds) {
|
|
43
|
+
if (partyIds.length === 0)
|
|
44
|
+
return {};
|
|
45
|
+
const { objects } = await client.core.getObjects({
|
|
46
|
+
objectIds: [...new Set(partyIds)],
|
|
47
|
+
include: { content: true },
|
|
48
|
+
});
|
|
49
|
+
const parties = {};
|
|
50
|
+
for (const obj of objects) {
|
|
51
|
+
if (obj instanceof Error)
|
|
52
|
+
continue;
|
|
53
|
+
parties[obj.objectId] = mapParty(obj.objectId, PartyBcs.parse(obj.content));
|
|
54
|
+
}
|
|
55
|
+
return parties;
|
|
56
|
+
}
|
|
57
|
+
/** Derives a party's `PartyAdminCap` id (it is a `derived_object` off the party UID). */
|
|
58
|
+
export function derivePartyAdminCapId(partyId, partyPackageId) {
|
|
59
|
+
return deriveObjectID(partyId, `${partyPackageId}::party::PartyAdminCapKey`, bcs.Address.serialize(partyId).toBytes());
|
|
60
|
+
}
|
|
61
|
+
// The profile is a dynamic field on the party UID under an empty `ProfileKey()`
|
|
62
|
+
// (Move's implicit `dummy_field: bool` → one zero byte).
|
|
63
|
+
const ProfileField = bcs.struct("Field", { id: bcs.Address, name: ProfileKeyBcs, value: ProfileBcs });
|
|
64
|
+
const PROFILE_KEY_BYTES = ProfileKeyBcs.serialize([false]).toBytes();
|
|
65
|
+
/** Fetches a party's profile, or null if none is set. */
|
|
66
|
+
export async function getProfile(client, partyId, partyProfilePackageId) {
|
|
67
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyProfilePackageId}::party_profile::ProfileKey`, PROFILE_KEY_BYTES);
|
|
68
|
+
const content = await getContent(client, fieldId);
|
|
69
|
+
if (!content)
|
|
70
|
+
return null;
|
|
71
|
+
return mapProfile(partyId, ProfileField.parse(content).value);
|
|
72
|
+
}
|
|
73
|
+
// Media is a dynamic field on the party UID under an empty `MediaKey()` (same
|
|
74
|
+
// implicit `dummy_field: bool` → one zero byte as the profile key).
|
|
75
|
+
const MediaField = bcs.struct("Field", { id: bcs.Address, name: MediaKeyBcs, value: MediaBcs });
|
|
76
|
+
const MEDIA_KEY_BYTES = MediaKeyBcs.serialize([false]).toBytes();
|
|
77
|
+
/** Fetches a party's media (avatar + header), or null if none is set. */
|
|
78
|
+
export async function getMedia(client, partyId, partyMediaPackageId) {
|
|
79
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyMediaPackageId}::party_media::MediaKey`, MEDIA_KEY_BYTES);
|
|
80
|
+
const content = await getContent(client, fieldId);
|
|
81
|
+
if (!content)
|
|
82
|
+
return null;
|
|
83
|
+
return mapMedia(partyId, MediaField.parse(content).value);
|
|
84
|
+
}
|
|
85
|
+
// === Collection extension reads (roles / tags / genres / ctas) ===
|
|
86
|
+
//
|
|
87
|
+
// Each is a single dynamic field on the party UID under an empty positional key
|
|
88
|
+
// (Move's implicit `dummy_field: bool` → one zero byte, same as the profile key).
|
|
89
|
+
const ROLES_KEY_BYTES = RolesKeyBcs.serialize([false]).toBytes();
|
|
90
|
+
const RolesField = bcs.struct("Field", { id: bcs.Address, name: RolesKeyBcs, value: bcs.vector(ArtistRoleBcs) });
|
|
91
|
+
/** The party's artist-type roles (display names), or `[]` if none are set. */
|
|
92
|
+
export async function getRoles(client, partyId, partyRolesPackageId) {
|
|
93
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyRolesPackageId}::party_roles::RolesKey`, ROLES_KEY_BYTES);
|
|
94
|
+
const content = await getContent(client, fieldId);
|
|
95
|
+
if (!content)
|
|
96
|
+
return [];
|
|
97
|
+
return mapRoles(RolesField.parse(content).value);
|
|
98
|
+
}
|
|
99
|
+
const TAGS_KEY_BYTES = TagsKeyBcs.serialize([false]).toBytes();
|
|
100
|
+
const TagsField = bcs.struct("Field", { id: bcs.Address, name: TagsKeyBcs, value: bcs.vector(bcs.string()) });
|
|
101
|
+
/** The party's free-form tags, or `[]` if none are set. */
|
|
102
|
+
export async function getTags(client, partyId, partyTagsPackageId) {
|
|
103
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyTagsPackageId}::party_tags::TagsKey`, TAGS_KEY_BYTES);
|
|
104
|
+
const content = await getContent(client, fieldId);
|
|
105
|
+
if (!content)
|
|
106
|
+
return [];
|
|
107
|
+
return mapTags(TagsField.parse(content).value);
|
|
108
|
+
}
|
|
109
|
+
const GENRES_KEY_BYTES = GenresKeyBcs.serialize([false]).toBytes();
|
|
110
|
+
const GenresField = bcs.struct("Field", { id: bcs.Address, name: GenresKeyBcs, value: bcs.vector(bcs.Address) });
|
|
111
|
+
/** The party's genre object ids, or `[]` if none are set. */
|
|
112
|
+
export async function getGenres(client, partyId, partyGenrePackageId) {
|
|
113
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyGenrePackageId}::party_genre::GenresKey`, GENRES_KEY_BYTES);
|
|
114
|
+
const content = await getContent(client, fieldId);
|
|
115
|
+
if (!content)
|
|
116
|
+
return [];
|
|
117
|
+
return mapGenres(GenresField.parse(content).value);
|
|
118
|
+
}
|
|
119
|
+
const CTAS_KEY_BYTES = CtasKeyBcs.serialize([false]).toBytes();
|
|
120
|
+
// The CTA field's value is a bare `vector<Cta>` (not a wrapper struct).
|
|
121
|
+
const CtasField = bcs.struct("Field", { id: bcs.Address, name: CtasKeyBcs, value: bcs.vector(CtaBcs) });
|
|
122
|
+
/** The party's ordered CTA list (position is priority), or `[]` if none is set. */
|
|
123
|
+
export async function getCtas(client, partyId, partyCtaPackageId) {
|
|
124
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyCtaPackageId}::party_cta::CtasKey`, CTAS_KEY_BYTES);
|
|
125
|
+
const content = await getContent(client, fieldId);
|
|
126
|
+
if (!content)
|
|
127
|
+
return [];
|
|
128
|
+
return mapCtas(CtasField.parse(content).value);
|
|
129
|
+
}
|
|
130
|
+
// === Platform-link reads ===
|
|
131
|
+
//
|
|
132
|
+
// Each platform is an independent `PlatformLink<Data>` dynamic field keyed by
|
|
133
|
+
// `platform_link::PlatformLinkKey<Data>`. There is no single key to derive, so
|
|
134
|
+
// enumerate the party's dynamic fields and pick out the platform-link ones,
|
|
135
|
+
// identifying the platform from the `Data` type argument. Every payload `Data`
|
|
136
|
+
// type is a single-`String` newtype, so `PlatformLink<Data>` serializes exactly
|
|
137
|
+
// as one BCS string — parse the field value as such.
|
|
138
|
+
const PlatformLinkField = bcs.struct("Field", { id: bcs.Address, name: bcs.bool(), value: bcs.string() });
|
|
139
|
+
const PLATFORM_LINK_KEY_RE = /::platform_link::PlatformLinkKey<(.+)>$/;
|
|
140
|
+
/** All external-platform links attached to a party (social, music, professional). */
|
|
141
|
+
export async function getLinks(client, partyId) {
|
|
142
|
+
const links = [];
|
|
143
|
+
let cursor;
|
|
144
|
+
do {
|
|
145
|
+
const page = await client.core.listDynamicFields({ parentId: partyId, cursor: cursor ?? undefined });
|
|
146
|
+
for (const f of page.dynamicFields) {
|
|
147
|
+
if (typeof f.name?.type !== "string")
|
|
148
|
+
continue;
|
|
149
|
+
const match = f.name.type.match(PLATFORM_LINK_KEY_RE);
|
|
150
|
+
const dataType = match?.[1];
|
|
151
|
+
if (!dataType)
|
|
152
|
+
continue;
|
|
153
|
+
const platform = platformForDataType(dataType);
|
|
154
|
+
if (!platform)
|
|
155
|
+
continue;
|
|
156
|
+
const content = await getContent(client, f.fieldId);
|
|
157
|
+
if (!content)
|
|
158
|
+
continue;
|
|
159
|
+
links.push(buildLink(platform, PlatformLinkField.parse(content).value));
|
|
160
|
+
}
|
|
161
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
162
|
+
} while (cursor);
|
|
163
|
+
return links;
|
|
164
|
+
}
|
|
165
|
+
// === Group membership reads ===
|
|
166
|
+
/** Normalizes a dynamic-field key's BCS bytes (Uint8Array or base64 string). */
|
|
167
|
+
function keyBytes(bcs) {
|
|
168
|
+
return typeof bcs === "string" ? fromBase64(bcs) : bcs;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The group ids a party currently belongs to, read from its `MembershipKey`
|
|
172
|
+
* dynamic fields (the member-side record). No indexer required.
|
|
173
|
+
*/
|
|
174
|
+
export async function getMemberships(client, partyId) {
|
|
175
|
+
const groups = [];
|
|
176
|
+
let cursor;
|
|
177
|
+
do {
|
|
178
|
+
const page = await client.core.listDynamicFields({ parentId: partyId, cursor: cursor ?? undefined });
|
|
179
|
+
for (const f of page.dynamicFields) {
|
|
180
|
+
if (typeof f.name?.type === "string" && f.name.type.endsWith("::party::MembershipKey") && f.name.bcs != null) {
|
|
181
|
+
const [groupId] = MembershipKeyBcs.parse(keyBytes(f.name.bcs));
|
|
182
|
+
groups.push(String(groupId));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
186
|
+
} while (cursor);
|
|
187
|
+
return groups;
|
|
188
|
+
}
|
|
189
|
+
/** The member ids invited to a group but not yet accepted (its `PendingInviteKey` fields). */
|
|
190
|
+
export async function getPendingInvites(client, groupId) {
|
|
191
|
+
const members = [];
|
|
192
|
+
let cursor;
|
|
193
|
+
do {
|
|
194
|
+
const page = await client.core.listDynamicFields({ parentId: groupId, cursor: cursor ?? undefined });
|
|
195
|
+
for (const f of page.dynamicFields) {
|
|
196
|
+
if (typeof f.name?.type === "string" && f.name.type.endsWith("::party::PendingInviteKey") && f.name.bcs != null) {
|
|
197
|
+
const [memberId] = PendingInviteKeyBcs.parse(keyBytes(f.name.bcs));
|
|
198
|
+
members.push(String(memberId));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
202
|
+
} while (cursor);
|
|
203
|
+
return members;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The group ids that have invited a party but are still awaiting its response.
|
|
207
|
+
* This reads the member-side `PendingMembershipKey` inbox index, so it only
|
|
208
|
+
* enumerates the target party's dynamic fields.
|
|
209
|
+
*/
|
|
210
|
+
export async function getPendingMemberships(client, partyId) {
|
|
211
|
+
const groups = [];
|
|
212
|
+
let cursor;
|
|
213
|
+
do {
|
|
214
|
+
const page = await client.core.listDynamicFields({ parentId: partyId, cursor: cursor ?? undefined });
|
|
215
|
+
for (const f of page.dynamicFields) {
|
|
216
|
+
if (typeof f.name?.type === "string" &&
|
|
217
|
+
f.name.type.endsWith("::party::PendingMembershipKey") &&
|
|
218
|
+
f.name.bcs != null) {
|
|
219
|
+
const [groupId] = PendingMembershipKeyBcs.parse(keyBytes(f.name.bcs));
|
|
220
|
+
groups.push(String(groupId));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
224
|
+
} while (cursor);
|
|
225
|
+
return groups;
|
|
226
|
+
}
|
|
227
|
+
/** Whether `memberId` currently holds a membership record for `groupId`. */
|
|
228
|
+
export async function isMember(client, memberId, groupId, partyPackageId) {
|
|
229
|
+
const fieldId = deriveDynamicFieldID(memberId, `${partyPackageId}::party::MembershipKey`, MembershipKeyBcs.serialize([groupId]).toBytes());
|
|
230
|
+
return (await getContent(client, fieldId)) !== null;
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/party/queries.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAMtC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,aAAa,IAAI,gBAAgB,EACjC,KAAK,IAAI,QAAQ,EACjB,gBAAgB,IAAI,mBAAmB,EACvC,oBAAoB,IAAI,uBAAuB,GAChD,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjH,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACrG,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC/G,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,O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AC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAChD,CAAC;IACF,OAAO,CAAC,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
export type TxThunk = (tx: Transaction) => void | Promise<void>;
|
|
3
|
+
export interface CreatePartyParams {
|
|
4
|
+
/** Human-readable party name (not verified; app-layer verifies). */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Address that receives the PartyAdminCap. */
|
|
7
|
+
recipient: string;
|
|
8
|
+
partyPackageId: string;
|
|
9
|
+
}
|
|
10
|
+
/** Creates an individual party, shares it, and transfers its admin cap to `recipient`. */
|
|
11
|
+
export declare function createIndividualParty(params: CreatePartyParams): TxThunk;
|
|
12
|
+
/** Creates a group party (empty member set), shares it, transfers its admin cap. */
|
|
13
|
+
export declare function createGroupParty(params: CreatePartyParams): TxThunk;
|
|
14
|
+
export interface InvitePartyParams {
|
|
15
|
+
groupId: string;
|
|
16
|
+
groupCapId: string;
|
|
17
|
+
/** The individual party (shared object id) to invite. */
|
|
18
|
+
memberId: string;
|
|
19
|
+
partyPackageId: string;
|
|
20
|
+
}
|
|
21
|
+
/** Invites an individual party to a group (gated by the group's admin cap). */
|
|
22
|
+
export declare function inviteParty(params: InvitePartyParams): TxThunk;
|
|
23
|
+
export interface AcceptInviteParams {
|
|
24
|
+
groupId: string;
|
|
25
|
+
memberId: string;
|
|
26
|
+
/** The member party's admin cap id (proves consent). */
|
|
27
|
+
memberCapId: string;
|
|
28
|
+
partyPackageId: string;
|
|
29
|
+
}
|
|
30
|
+
/** Accepts a pending invite, joining the member to the group (member's cap). */
|
|
31
|
+
export declare function acceptInvite(params: AcceptInviteParams): TxThunk;
|
|
32
|
+
export interface DeclineInviteParams {
|
|
33
|
+
groupId: string;
|
|
34
|
+
/** The invited individual party (shared object id). */
|
|
35
|
+
memberId: string;
|
|
36
|
+
memberCapId: string;
|
|
37
|
+
partyPackageId: string;
|
|
38
|
+
}
|
|
39
|
+
/** Declines a pending invite (member's cap). */
|
|
40
|
+
export declare function declineInvite(params: DeclineInviteParams): TxThunk;
|
|
41
|
+
export interface RevokeInviteParams {
|
|
42
|
+
groupId: string;
|
|
43
|
+
/** The invited individual party (shared object id). */
|
|
44
|
+
memberId: string;
|
|
45
|
+
groupCapId: string;
|
|
46
|
+
partyPackageId: string;
|
|
47
|
+
}
|
|
48
|
+
/** Revokes a pending invite (group's admin cap). */
|
|
49
|
+
export declare function revokeInvite(params: RevokeInviteParams): TxThunk;
|
|
50
|
+
export interface LeaveGroupParams {
|
|
51
|
+
groupId: string;
|
|
52
|
+
memberId: string;
|
|
53
|
+
memberCapId: string;
|
|
54
|
+
partyPackageId: string;
|
|
55
|
+
}
|
|
56
|
+
/** Leaves a group, authorized by the member's own admin cap. */
|
|
57
|
+
export declare function leaveGroup(params: LeaveGroupParams): TxThunk;
|
|
58
|
+
export interface RemoveMemberParams {
|
|
59
|
+
groupId: string;
|
|
60
|
+
groupCapId: string;
|
|
61
|
+
memberId: string;
|
|
62
|
+
partyPackageId: string;
|
|
63
|
+
}
|
|
64
|
+
/** Evicts a member from a group (group's admin cap); scrubs the member's record too. */
|
|
65
|
+
export declare function removeMember(params: RemoveMemberParams): TxThunk;
|
|
66
|
+
export interface SetNameParams {
|
|
67
|
+
partyId: string;
|
|
68
|
+
capId: string;
|
|
69
|
+
name: string;
|
|
70
|
+
partyPackageId: string;
|
|
71
|
+
}
|
|
72
|
+
/** Sets the party's human-readable name. */
|
|
73
|
+
export declare function setName(params: SetNameParams): TxThunk;
|
|
74
|
+
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/party/transactions.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BA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ChB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAOhE;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,gEAAgE;AAChE,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAO5D;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAOhE;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,4CAA4C;AAC5C,wBAAgB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAOtD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import * as party from "../contracts/miso_party/party.js";
|
|
4
|
+
/** Creates an individual party, shares it, and transfers its admin cap to `recipient`. */
|
|
5
|
+
export function createIndividualParty(params) {
|
|
6
|
+
return (tx) => {
|
|
7
|
+
const kind = tx.add(party.newIndividualKind({ package: params.partyPackageId }));
|
|
8
|
+
const res = tx.add(party._new({ package: params.partyPackageId, arguments: [kind, params.name] }));
|
|
9
|
+
tx.add(party.share({ package: params.partyPackageId, arguments: [res[0], res[1]] }));
|
|
10
|
+
tx.transferObjects([res[1]], params.recipient);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Creates a group party (empty member set), shares it, transfers its admin cap. */
|
|
14
|
+
export function createGroupParty(params) {
|
|
15
|
+
return (tx) => {
|
|
16
|
+
const kind = tx.add(party.newGroupKind({ package: params.partyPackageId }));
|
|
17
|
+
const res = tx.add(party._new({ package: params.partyPackageId, arguments: [kind, params.name] }));
|
|
18
|
+
tx.add(party.share({ package: params.partyPackageId, arguments: [res[0], res[1]] }));
|
|
19
|
+
tx.transferObjects([res[1]], params.recipient);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Invites an individual party to a group (gated by the group's admin cap). */
|
|
23
|
+
export function inviteParty(params) {
|
|
24
|
+
return (tx) => {
|
|
25
|
+
tx.add(party.inviteParty({
|
|
26
|
+
package: params.partyPackageId,
|
|
27
|
+
arguments: [params.groupId, params.memberId, params.groupCapId],
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Accepts a pending invite, joining the member to the group (member's cap). */
|
|
32
|
+
export function acceptInvite(params) {
|
|
33
|
+
return (tx) => {
|
|
34
|
+
tx.add(party.acceptInvite({
|
|
35
|
+
package: params.partyPackageId,
|
|
36
|
+
arguments: [params.groupId, params.memberId, params.memberCapId],
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Declines a pending invite (member's cap). */
|
|
41
|
+
export function declineInvite(params) {
|
|
42
|
+
return (tx) => {
|
|
43
|
+
tx.add(party.declineInvite({
|
|
44
|
+
package: params.partyPackageId,
|
|
45
|
+
arguments: [params.groupId, params.memberId, params.memberCapId],
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Revokes a pending invite (group's admin cap). */
|
|
50
|
+
export function revokeInvite(params) {
|
|
51
|
+
return (tx) => {
|
|
52
|
+
tx.add(party.revokeInvite({
|
|
53
|
+
package: params.partyPackageId,
|
|
54
|
+
arguments: [params.groupId, params.memberId, params.groupCapId],
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Leaves a group, authorized by the member's own admin cap. */
|
|
59
|
+
export function leaveGroup(params) {
|
|
60
|
+
return (tx) => {
|
|
61
|
+
tx.add(party.leave({
|
|
62
|
+
package: params.partyPackageId,
|
|
63
|
+
arguments: [params.groupId, params.memberId, params.memberCapId],
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Evicts a member from a group (group's admin cap); scrubs the member's record too. */
|
|
68
|
+
export function removeMember(params) {
|
|
69
|
+
return (tx) => {
|
|
70
|
+
tx.add(party.removeMember({
|
|
71
|
+
package: params.partyPackageId,
|
|
72
|
+
arguments: [params.groupId, params.groupCapId, params.memberId],
|
|
73
|
+
}));
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Sets the party's human-readable name. */
|
|
77
|
+
export function setName(params) {
|
|
78
|
+
return (tx) => {
|
|
79
|
+
tx.add(party.setName({
|
|
80
|
+
package: params.partyPackageId,
|
|
81
|
+
arguments: [params.partyId, params.capId, params.name],
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../src/party/transactions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAQtC,OAAO,KAAK,KAAK,MAAM,kCAAkC,CAAC;AAY1D,0FAA0F;AAC1F,MAAM,UAAU,qBAAqB,CAAC,MAAyB;IAC7D,OAAO,CAAC,EAAE,EAAE,EAAE;QACZ,MAAM,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,MAAM,C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
3
|
+
id: string;
|
|
4
|
+
kind: PartyKind;
|
|
5
|
+
/** Human-readable name (not verified). */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Member party ids — present only when `kind === "group"`. */
|
|
8
|
+
members?: string[];
|
|
9
|
+
/** Unix ms when the party was created. */
|
|
10
|
+
createdAtMs: number;
|
|
11
|
+
}
|
|
12
|
+
export interface Profile {
|
|
13
|
+
partyId: string;
|
|
14
|
+
bioShort: string;
|
|
15
|
+
bioLong?: string;
|
|
16
|
+
/** ISO 3166-1 alpha-2 country code, e.g. "GB". */
|
|
17
|
+
country?: string;
|
|
18
|
+
/** ISO 639-1 language codes, e.g. ["en"]. */
|
|
19
|
+
languages: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A party's imagery, stored on-chain as a single Walrus quilt. Individual images
|
|
23
|
+
* (avatar, header, …) are quilt patches addressed by identifier off-chain — see
|
|
24
|
+
* `mediaUrls` / `MEDIA_IDENTIFIERS` in `extensions/media`.
|
|
25
|
+
*/
|
|
26
|
+
export interface Media {
|
|
27
|
+
partyId: string;
|
|
28
|
+
/** Walrus quilt blob id (base64url) holding the party's images. */
|
|
29
|
+
quiltId: string;
|
|
30
|
+
}
|
|
31
|
+
/** A single call-to-action on a party: a labeled external link. Position is priority. */
|
|
32
|
+
export interface Cta {
|
|
33
|
+
label: string;
|
|
34
|
+
url: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A platform this SDK knows how to build a link for. One key per external
|
|
38
|
+
* platform, spanning social (`x`, `instagram`, …), music (`spotify`, `bandcamp`,
|
|
39
|
+
* …), and professional/industry (`website`, `patreon`, …) payloads.
|
|
40
|
+
*/
|
|
41
|
+
export type PlatformKey = "x" | "instagram" | "threads" | "tiktok" | "youtube" | "discord" | "telegram" | "reddit" | "twitch" | "facebook" | "spotify" | "bandcamp" | "soundcloud" | "appleMusic" | "deezer" | "tidal" | "amazonMusic" | "audiomack" | "website" | "bookingPage" | "managementPage" | "publisherPage" | "labelPage" | "epk" | "patreon" | "substack" | "kofi";
|
|
42
|
+
/**
|
|
43
|
+
* One external-platform link attached to a party. Only the native identifier
|
|
44
|
+
* (`value` — a handle, artist id, subdomain, or full URL) is stored on-chain; the
|
|
45
|
+
* public `url` is rebuilt client-side from it.
|
|
46
|
+
*/
|
|
47
|
+
export interface PlatformLink {
|
|
48
|
+
platform: PlatformKey;
|
|
49
|
+
/** The platform-native identifier stored on-chain (handle / id / subdomain / URL). */
|
|
50
|
+
value: string;
|
|
51
|
+
/** The public profile URL, rebuilt from `value`. */
|
|
52
|
+
url: string;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/party/types.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,yFAAyF;AACzF,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAEnB,GAAG,GACH,WAAW,GACX,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,UAAU,GAEV,SAAS,GACT,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,OAAO,GACP,aAAa,GACb,WAAW,GAEX,SAAS,GACT,aAAa,GACb,gBAAgB,GAChB,eAAe,GACf,WAAW,GACX,KAAK,GACL,SAAS,GACT,UAAU,GACV,MAAM,CAAC;AAEX;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,WAAW,CAAC;IACtB,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/party/types.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@misonetwork/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"packageManager": "bun@1.4.0",
|
|
5
|
-
"description": "Typed bindings, queries, event decoders, and PTB builders for the Miso protocol package set on Sui.",
|
|
5
|
+
"description": "Typed bindings, queries, event decoders, and PTB builders for the Miso protocol and Party package set on Sui.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -82,6 +82,10 @@
|
|
|
82
82
|
"types": "./dist/packages.d.ts",
|
|
83
83
|
"default": "./dist/packages.js"
|
|
84
84
|
},
|
|
85
|
+
"./party": {
|
|
86
|
+
"types": "./dist/party/index.d.ts",
|
|
87
|
+
"default": "./dist/party/index.js"
|
|
88
|
+
},
|
|
85
89
|
"./package.json": "./package.json"
|
|
86
90
|
},
|
|
87
91
|
"files": [
|
package/src/client.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { bindModulePackage, MisoPackageBindings, REF_RETURNING_CALLS } from "./packages.ts";
|
|
18
18
|
import * as parsers from "./parsers.ts";
|
|
19
19
|
import { eventParsers } from "./events.ts";
|
|
20
|
+
import { PartyProtocolClient } from "./party/client.ts";
|
|
20
21
|
import * as queries from "./queries.ts";
|
|
21
22
|
import * as view from "./view.ts";
|
|
22
23
|
import type {
|
|
@@ -108,6 +109,7 @@ export class MisoProtocolClient {
|
|
|
108
109
|
#graphqlClient?: SuiGraphQLClient;
|
|
109
110
|
#deployment: MisoProtocolDeployment;
|
|
110
111
|
#packageDeployment?: MisoDeployment;
|
|
112
|
+
#partyClient?: PartyProtocolClient;
|
|
111
113
|
|
|
112
114
|
constructor(client: ClientWithCoreApi, options: MisoProtocolClientOptions) {
|
|
113
115
|
this.#client = client;
|
|
@@ -116,6 +118,9 @@ export class MisoProtocolClient {
|
|
|
116
118
|
this.#packageDeployment = options.packageDeployment
|
|
117
119
|
? normalizeMisoDeployment(options.packageDeployment)
|
|
118
120
|
: undefined;
|
|
121
|
+
this.#partyClient = this.#packageDeployment
|
|
122
|
+
? new PartyProtocolClient(client, this.#packageDeployment)
|
|
123
|
+
: undefined;
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
/** The exact deployment selected for this client. */
|
|
@@ -137,6 +142,17 @@ export class MisoProtocolClient {
|
|
|
137
142
|
return new MisoPackageBindings(this.#packageDeployment);
|
|
138
143
|
}
|
|
139
144
|
|
|
145
|
+
/** Party identity, profile, membership, and extension APIs. */
|
|
146
|
+
get party(): PartyProtocolClient {
|
|
147
|
+
if (!this.#partyClient) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
"@misonetwork/sdk: Party APIs require a complete MisoDeployment. " +
|
|
150
|
+
"Pass the verified post-publish manifest to miso({ deployment }).",
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return this.#partyClient;
|
|
154
|
+
}
|
|
155
|
+
|
|
140
156
|
get #misoPackageId(): string {
|
|
141
157
|
return this.#deployment.packageId;
|
|
142
158
|
}
|
|
@@ -156,33 +156,6 @@ export function publish(options: PublishOptions) {
|
|
|
156
156
|
typeArguments: options.typeArguments
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
export interface IdArguments {
|
|
160
|
-
self: RawTransactionArgument<string>;
|
|
161
|
-
}
|
|
162
|
-
export interface IdOptions {
|
|
163
|
-
package?: string;
|
|
164
|
-
arguments: IdArguments | [
|
|
165
|
-
self: RawTransactionArgument<string>
|
|
166
|
-
];
|
|
167
|
-
typeArguments: [
|
|
168
|
-
string
|
|
169
|
-
];
|
|
170
|
-
}
|
|
171
|
-
/** Returns the composition's object ID. */
|
|
172
|
-
export function id(options: IdOptions) {
|
|
173
|
-
const packageAddress = options.package ?? '@local-pkg/miso';
|
|
174
|
-
const argumentsTypes = [
|
|
175
|
-
null
|
|
176
|
-
] satisfies (string | null)[];
|
|
177
|
-
const parameterNames = ["self"];
|
|
178
|
-
return (tx: Transaction) => tx.moveCall({
|
|
179
|
-
package: packageAddress,
|
|
180
|
-
module: 'composition',
|
|
181
|
-
function: 'id',
|
|
182
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
183
|
-
typeArguments: options.typeArguments
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
159
|
export interface TitleArguments {
|
|
187
160
|
self: RawTransactionArgument<string>;
|
|
188
161
|
}
|
|
@@ -240,34 +240,6 @@ export function compositionId(options: CompositionIdOptions) {
|
|
|
240
240
|
typeArguments: options.typeArguments
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
|
-
export interface IdArguments {
|
|
244
|
-
self: RawTransactionArgument<string>;
|
|
245
|
-
}
|
|
246
|
-
export interface IdOptions {
|
|
247
|
-
package?: string;
|
|
248
|
-
arguments: IdArguments | [
|
|
249
|
-
self: RawTransactionArgument<string>
|
|
250
|
-
];
|
|
251
|
-
typeArguments: [
|
|
252
|
-
string,
|
|
253
|
-
string
|
|
254
|
-
];
|
|
255
|
-
}
|
|
256
|
-
/** Returns the recording's object ID. */
|
|
257
|
-
export function id(options: IdOptions) {
|
|
258
|
-
const packageAddress = options.package ?? '@local-pkg/miso';
|
|
259
|
-
const argumentsTypes = [
|
|
260
|
-
null
|
|
261
|
-
] satisfies (string | null)[];
|
|
262
|
-
const parameterNames = ["self"];
|
|
263
|
-
return (tx: Transaction) => tx.moveCall({
|
|
264
|
-
package: packageAddress,
|
|
265
|
-
module: 'recording',
|
|
266
|
-
function: 'id',
|
|
267
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
268
|
-
typeArguments: options.typeArguments
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
243
|
export interface UidArguments {
|
|
272
244
|
self: RawTransactionArgument<string>;
|
|
273
245
|
}
|