@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,119 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// The single boundary between generated BCS-parse output (snake_case, Move-shaped)
|
|
5
|
+
// and the public camelCase types.
|
|
6
|
+
|
|
7
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
8
|
+
import { fromBase64, toBase64 } from "@mysten/sui/utils";
|
|
9
|
+
import type { Cta, Media, Party, Profile } from "./types.ts";
|
|
10
|
+
|
|
11
|
+
const u256 = bcs.u256();
|
|
12
|
+
|
|
13
|
+
function toBase64Url(bytes: Uint8Array): string {
|
|
14
|
+
return toBase64(bytes).replace(/=*$/, "").replaceAll("+", "-").replaceAll("/", "_");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function fromBase64Url(value: string): Uint8Array {
|
|
18
|
+
let base64 = value.replaceAll("-", "+").replaceAll("_", "/");
|
|
19
|
+
while (base64.length % 4) base64 += "=";
|
|
20
|
+
return fromBase64(base64);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function u256ToB64Url(value: bigint | string): string {
|
|
24
|
+
return toBase64Url(u256.serialize(BigInt(value)).toBytes());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function b64UrlToU256(value: string): string {
|
|
28
|
+
return u256.parse(fromBase64Url(value)).toString();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `CountryCode` / `LanguageCode` are single-field tuple structs → parse to a 1-element array. */
|
|
32
|
+
function unwrapCode(v: unknown): string | undefined {
|
|
33
|
+
if (v == null) return undefined;
|
|
34
|
+
return Array.isArray(v) ? (v[0] as string) : (v as string);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// deno-lint-ignore no-explicit-any -- generated parse output is loosely typed
|
|
38
|
+
export function mapProfile(partyId: string, d: any): Profile {
|
|
39
|
+
return {
|
|
40
|
+
partyId,
|
|
41
|
+
bioShort: d.bio_short,
|
|
42
|
+
bioLong: d.bio_long ?? undefined,
|
|
43
|
+
country: unwrapCode(d.country),
|
|
44
|
+
languages: Array.isArray(d.languages)
|
|
45
|
+
? d.languages.map((l: unknown) => unwrapCode(l)).filter((c: unknown): c is string => Boolean(c))
|
|
46
|
+
: [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// On-chain `Media` holds the quilt blob id as a u256 (decimal string from BCS);
|
|
51
|
+
// expose it in Walrus's base64url form so callers can build aggregator URLs.
|
|
52
|
+
// deno-lint-ignore no-explicit-any -- generated parse output is loosely typed
|
|
53
|
+
export function mapMedia(partyId: string, d: any): Media {
|
|
54
|
+
return { partyId, quiltId: u256ToB64Url(String(d.quilt)) };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// The display name of each canonical `ArtistRole` variant (matches Move's
|
|
58
|
+
// `role_name` — note `Dj` → "DJ"). `Custom` carries its own string.
|
|
59
|
+
const CANONICAL_ROLE_NAMES: Record<string, string> = {
|
|
60
|
+
Artist: "Artist",
|
|
61
|
+
Producer: "Producer",
|
|
62
|
+
Dj: "DJ",
|
|
63
|
+
Composer: "Composer",
|
|
64
|
+
Songwriter: "Songwriter",
|
|
65
|
+
Band: "Band",
|
|
66
|
+
Label: "Label",
|
|
67
|
+
Collective: "Collective",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** One parsed `ArtistRole` enum value → its display name (`Custom` → its string). */
|
|
71
|
+
// deno-lint-ignore no-explicit-any -- generated parse output is loosely typed
|
|
72
|
+
function roleName(r: any): string {
|
|
73
|
+
if (r?.$kind === "Custom") return String(r.Custom ?? r.value ?? "");
|
|
74
|
+
return CANONICAL_ROLE_NAMES[r?.$kind] ?? String(r?.$kind ?? "");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A party's `VecSet<ArtistRole>` → role display names. */
|
|
78
|
+
// deno-lint-ignore no-explicit-any -- generated parse output is loosely typed
|
|
79
|
+
export function mapRoles(d: any): string[] {
|
|
80
|
+
const contents = Array.isArray(d) ? d : d?.contents ?? d?.roles?.contents ?? [];
|
|
81
|
+
return (Array.isArray(contents) ? contents : []).map(roleName);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A party's `VecSet<String>` tag set → tag strings. */
|
|
85
|
+
// deno-lint-ignore no-explicit-any -- generated parse output is loosely typed
|
|
86
|
+
export function mapTags(d: any): string[] {
|
|
87
|
+
const contents = Array.isArray(d) ? d : d?.contents ?? d?.tags?.contents ?? [];
|
|
88
|
+
return (Array.isArray(contents) ? contents : []).map((t: unknown) => String(t));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A party's `VecSet<ID>` genre set → genre object id strings. */
|
|
92
|
+
// deno-lint-ignore no-explicit-any -- generated parse output is loosely typed
|
|
93
|
+
export function mapGenres(d: any): string[] {
|
|
94
|
+
const contents = Array.isArray(d) ? d : d?.contents ?? d?.genres?.contents ?? [];
|
|
95
|
+
return (Array.isArray(contents) ? contents : []).map((g: unknown) => String(g));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A party's `vector<Cta>` → CTA entries, preserving order (position is priority). */
|
|
99
|
+
// deno-lint-ignore no-explicit-any -- generated parse output is loosely typed
|
|
100
|
+
export function mapCtas(d: any): Cta[] {
|
|
101
|
+
return (Array.isArray(d) ? d : []).map((c: any) => ({ label: String(c.label), url: String(c.url) }));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// deno-lint-ignore no-explicit-any -- generated parse output is loosely typed
|
|
105
|
+
export function mapParty(id: string, d: any): Party {
|
|
106
|
+
const kind = d.kind;
|
|
107
|
+
const createdAtMs = Number(d.created_at_ms);
|
|
108
|
+
// PartyKind is `Individual | Group(VecSet<ID>)`. The enum parses to
|
|
109
|
+
// `{ $kind, Individual? , Group? }`; Group's payload is a VecSet `{ contents }`.
|
|
110
|
+
const groupPayload = kind?.Group ?? (kind?.$kind === "Group" ? kind.value : undefined);
|
|
111
|
+
if (groupPayload !== undefined) {
|
|
112
|
+
const contents = groupPayload?.contents ?? groupPayload ?? [];
|
|
113
|
+
const members = (Array.isArray(contents) ? contents : []).map((m: unknown) =>
|
|
114
|
+
typeof m === "string" ? m : (m as { id?: string })?.id ?? String(m),
|
|
115
|
+
);
|
|
116
|
+
return { id, kind: "group", name: d.name, members, createdAtMs };
|
|
117
|
+
}
|
|
118
|
+
return { id, kind: "individual", name: d.name, createdAtMs };
|
|
119
|
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Typed reads: fetch an on-chain object (or dynamic field) via the Core API, BCS-parse
|
|
5
|
+
// it through the generated struct, and map to the public camelCase types.
|
|
6
|
+
|
|
7
|
+
import type { ClientWithCoreApi } from "@mysten/sui/client";
|
|
8
|
+
import { deriveDynamicFieldID, deriveObjectID } from "@mysten/sui/utils";
|
|
9
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
10
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
11
|
+
import {
|
|
12
|
+
MembershipKey as MembershipKeyBcs,
|
|
13
|
+
Party as PartyBcs,
|
|
14
|
+
PendingInviteKey as PendingInviteKeyBcs,
|
|
15
|
+
PendingMembershipKey as PendingMembershipKeyBcs,
|
|
16
|
+
} from "../contracts/miso_party/party.ts";
|
|
17
|
+
import { Profile as ProfileBcs, ProfileKey as ProfileKeyBcs } from "../contracts/party_profile/party_profile.ts";
|
|
18
|
+
import { Media as MediaBcs, MediaKey as MediaKeyBcs } from "../contracts/party_media/party_media.ts";
|
|
19
|
+
import { ArtistRole as ArtistRoleBcs, RolesKey as RolesKeyBcs } from "../contracts/party_roles/party_roles.ts";
|
|
20
|
+
import { TagsKey as TagsKeyBcs } from "../contracts/party_tags/party_tags.ts";
|
|
21
|
+
import { GenresKey as GenresKeyBcs } from "../contracts/party_genre/party_genre.ts";
|
|
22
|
+
import { Cta as CtaBcs, CtasKey as CtasKeyBcs } from "../contracts/party_cta/party_cta.ts";
|
|
23
|
+
import { mapCtas, mapGenres, mapMedia, mapParty, mapProfile, mapRoles, mapTags } from "./internal.ts";
|
|
24
|
+
import { buildLink, platformForDataType } from "./extensions/links.ts";
|
|
25
|
+
import type { Cta, Media, Party, PlatformLink, Profile } from "./types.ts";
|
|
26
|
+
|
|
27
|
+
/** True for the Core API's "object does not exist" error (a missing dynamic field). */
|
|
28
|
+
function isNotFound(e: unknown): boolean {
|
|
29
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
30
|
+
return /not\s*found|does not exist|no object/i.test(msg);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// A missing object (e.g. an unset profile/media dynamic field) surfaces as a
|
|
34
|
+
// thrown "not found" from the Core API, not an empty result — treat it as null
|
|
35
|
+
// so optional extensions read cleanly.
|
|
36
|
+
async function getContent(client: ClientWithCoreApi, objectId: string): Promise<Uint8Array | null> {
|
|
37
|
+
try {
|
|
38
|
+
const { object } = await client.core.getObject({ objectId, include: { content: true } });
|
|
39
|
+
return object?.content ?? null;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (isNotFound(e)) return null;
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Fetches and parses a shared `Party` object. */
|
|
47
|
+
export async function getPartyById(client: ClientWithCoreApi, partyId: string): Promise<Party> {
|
|
48
|
+
const content = await getContent(client, partyId);
|
|
49
|
+
if (!content) throw new Error(`Party not found: ${partyId}`);
|
|
50
|
+
return mapParty(partyId, PartyBcs.parse(content));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Fetches and parses multiple shared `Party` objects in one Core request. */
|
|
54
|
+
export async function getPartiesByIds(
|
|
55
|
+
client: ClientWithCoreApi,
|
|
56
|
+
partyIds: readonly string[],
|
|
57
|
+
): Promise<Partial<Record<string, Party>>> {
|
|
58
|
+
if (partyIds.length === 0) return {};
|
|
59
|
+
const { objects } = await client.core.getObjects({
|
|
60
|
+
objectIds: [...new Set(partyIds)],
|
|
61
|
+
include: { content: true },
|
|
62
|
+
});
|
|
63
|
+
const parties: Partial<Record<string, Party>> = {};
|
|
64
|
+
for (const obj of objects) {
|
|
65
|
+
if (obj instanceof Error) continue;
|
|
66
|
+
parties[obj.objectId] = mapParty(obj.objectId, PartyBcs.parse(obj.content));
|
|
67
|
+
}
|
|
68
|
+
return parties;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Derives a party's `PartyAdminCap` id (it is a `derived_object` off the party UID). */
|
|
72
|
+
export function derivePartyAdminCapId(partyId: string, partyPackageId: string): string {
|
|
73
|
+
return deriveObjectID(
|
|
74
|
+
partyId,
|
|
75
|
+
`${partyPackageId}::party::PartyAdminCapKey`,
|
|
76
|
+
bcs.Address.serialize(partyId).toBytes(),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// The profile is a dynamic field on the party UID under an empty `ProfileKey()`
|
|
81
|
+
// (Move's implicit `dummy_field: bool` → one zero byte).
|
|
82
|
+
const ProfileField = bcs.struct("Field", { id: bcs.Address, name: ProfileKeyBcs, value: ProfileBcs });
|
|
83
|
+
const PROFILE_KEY_BYTES = ProfileKeyBcs.serialize([false]).toBytes();
|
|
84
|
+
|
|
85
|
+
/** Fetches a party's profile, or null if none is set. */
|
|
86
|
+
export async function getProfile(
|
|
87
|
+
client: ClientWithCoreApi,
|
|
88
|
+
partyId: string,
|
|
89
|
+
partyProfilePackageId: string,
|
|
90
|
+
): Promise<Profile | null> {
|
|
91
|
+
const fieldId = deriveDynamicFieldID(
|
|
92
|
+
partyId,
|
|
93
|
+
`${partyProfilePackageId}::party_profile::ProfileKey`,
|
|
94
|
+
PROFILE_KEY_BYTES,
|
|
95
|
+
);
|
|
96
|
+
const content = await getContent(client, fieldId);
|
|
97
|
+
if (!content) return null;
|
|
98
|
+
return mapProfile(partyId, ProfileField.parse(content).value);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Media is a dynamic field on the party UID under an empty `MediaKey()` (same
|
|
102
|
+
// implicit `dummy_field: bool` → one zero byte as the profile key).
|
|
103
|
+
const MediaField = bcs.struct("Field", { id: bcs.Address, name: MediaKeyBcs, value: MediaBcs });
|
|
104
|
+
const MEDIA_KEY_BYTES = MediaKeyBcs.serialize([false]).toBytes();
|
|
105
|
+
|
|
106
|
+
/** Fetches a party's media (avatar + header), or null if none is set. */
|
|
107
|
+
export async function getMedia(
|
|
108
|
+
client: ClientWithCoreApi,
|
|
109
|
+
partyId: string,
|
|
110
|
+
partyMediaPackageId: string,
|
|
111
|
+
): Promise<Media | null> {
|
|
112
|
+
const fieldId = deriveDynamicFieldID(
|
|
113
|
+
partyId,
|
|
114
|
+
`${partyMediaPackageId}::party_media::MediaKey`,
|
|
115
|
+
MEDIA_KEY_BYTES,
|
|
116
|
+
);
|
|
117
|
+
const content = await getContent(client, fieldId);
|
|
118
|
+
if (!content) return null;
|
|
119
|
+
return mapMedia(partyId, MediaField.parse(content).value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// === Collection extension reads (roles / tags / genres / ctas) ===
|
|
123
|
+
//
|
|
124
|
+
// Each is a single dynamic field on the party UID under an empty positional key
|
|
125
|
+
// (Move's implicit `dummy_field: bool` → one zero byte, same as the profile key).
|
|
126
|
+
|
|
127
|
+
const ROLES_KEY_BYTES = RolesKeyBcs.serialize([false]).toBytes();
|
|
128
|
+
const RolesField = bcs.struct("Field", { id: bcs.Address, name: RolesKeyBcs, value: bcs.vector(ArtistRoleBcs) });
|
|
129
|
+
|
|
130
|
+
/** The party's artist-type roles (display names), or `[]` if none are set. */
|
|
131
|
+
export async function getRoles(
|
|
132
|
+
client: ClientWithCoreApi,
|
|
133
|
+
partyId: string,
|
|
134
|
+
partyRolesPackageId: string,
|
|
135
|
+
): Promise<string[]> {
|
|
136
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyRolesPackageId}::party_roles::RolesKey`, ROLES_KEY_BYTES);
|
|
137
|
+
const content = await getContent(client, fieldId);
|
|
138
|
+
if (!content) return [];
|
|
139
|
+
return mapRoles(RolesField.parse(content).value);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const TAGS_KEY_BYTES = TagsKeyBcs.serialize([false]).toBytes();
|
|
143
|
+
const TagsField = bcs.struct("Field", { id: bcs.Address, name: TagsKeyBcs, value: bcs.vector(bcs.string()) });
|
|
144
|
+
|
|
145
|
+
/** The party's free-form tags, or `[]` if none are set. */
|
|
146
|
+
export async function getTags(
|
|
147
|
+
client: ClientWithCoreApi,
|
|
148
|
+
partyId: string,
|
|
149
|
+
partyTagsPackageId: string,
|
|
150
|
+
): Promise<string[]> {
|
|
151
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyTagsPackageId}::party_tags::TagsKey`, TAGS_KEY_BYTES);
|
|
152
|
+
const content = await getContent(client, fieldId);
|
|
153
|
+
if (!content) return [];
|
|
154
|
+
return mapTags(TagsField.parse(content).value);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const GENRES_KEY_BYTES = GenresKeyBcs.serialize([false]).toBytes();
|
|
158
|
+
const GenresField = bcs.struct("Field", { id: bcs.Address, name: GenresKeyBcs, value: bcs.vector(bcs.Address) });
|
|
159
|
+
|
|
160
|
+
/** The party's genre object ids, or `[]` if none are set. */
|
|
161
|
+
export async function getGenres(
|
|
162
|
+
client: ClientWithCoreApi,
|
|
163
|
+
partyId: string,
|
|
164
|
+
partyGenrePackageId: string,
|
|
165
|
+
): Promise<string[]> {
|
|
166
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyGenrePackageId}::party_genre::GenresKey`, GENRES_KEY_BYTES);
|
|
167
|
+
const content = await getContent(client, fieldId);
|
|
168
|
+
if (!content) return [];
|
|
169
|
+
return mapGenres(GenresField.parse(content).value);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const CTAS_KEY_BYTES = CtasKeyBcs.serialize([false]).toBytes();
|
|
173
|
+
// The CTA field's value is a bare `vector<Cta>` (not a wrapper struct).
|
|
174
|
+
const CtasField = bcs.struct("Field", { id: bcs.Address, name: CtasKeyBcs, value: bcs.vector(CtaBcs) });
|
|
175
|
+
|
|
176
|
+
/** The party's ordered CTA list (position is priority), or `[]` if none is set. */
|
|
177
|
+
export async function getCtas(
|
|
178
|
+
client: ClientWithCoreApi,
|
|
179
|
+
partyId: string,
|
|
180
|
+
partyCtaPackageId: string,
|
|
181
|
+
): Promise<Cta[]> {
|
|
182
|
+
const fieldId = deriveDynamicFieldID(partyId, `${partyCtaPackageId}::party_cta::CtasKey`, CTAS_KEY_BYTES);
|
|
183
|
+
const content = await getContent(client, fieldId);
|
|
184
|
+
if (!content) return [];
|
|
185
|
+
return mapCtas(CtasField.parse(content).value);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// === Platform-link reads ===
|
|
189
|
+
//
|
|
190
|
+
// Each platform is an independent `PlatformLink<Data>` dynamic field keyed by
|
|
191
|
+
// `platform_link::PlatformLinkKey<Data>`. There is no single key to derive, so
|
|
192
|
+
// enumerate the party's dynamic fields and pick out the platform-link ones,
|
|
193
|
+
// identifying the platform from the `Data` type argument. Every payload `Data`
|
|
194
|
+
// type is a single-`String` newtype, so `PlatformLink<Data>` serializes exactly
|
|
195
|
+
// as one BCS string — parse the field value as such.
|
|
196
|
+
const PlatformLinkField = bcs.struct("Field", { id: bcs.Address, name: bcs.bool(), value: bcs.string() });
|
|
197
|
+
const PLATFORM_LINK_KEY_RE = /::platform_link::PlatformLinkKey<(.+)>$/;
|
|
198
|
+
|
|
199
|
+
/** All external-platform links attached to a party (social, music, professional). */
|
|
200
|
+
export async function getLinks(client: ClientWithCoreApi, partyId: string): Promise<PlatformLink[]> {
|
|
201
|
+
const links: PlatformLink[] = [];
|
|
202
|
+
let cursor: string | null | undefined;
|
|
203
|
+
do {
|
|
204
|
+
const page = await client.core.listDynamicFields({ parentId: partyId, cursor: cursor ?? undefined });
|
|
205
|
+
for (const f of page.dynamicFields) {
|
|
206
|
+
if (typeof f.name?.type !== "string") continue;
|
|
207
|
+
const match = f.name.type.match(PLATFORM_LINK_KEY_RE);
|
|
208
|
+
const dataType = match?.[1];
|
|
209
|
+
if (!dataType) continue;
|
|
210
|
+
const platform = platformForDataType(dataType);
|
|
211
|
+
if (!platform) continue;
|
|
212
|
+
const content = await getContent(client, f.fieldId);
|
|
213
|
+
if (!content) continue;
|
|
214
|
+
links.push(buildLink(platform, PlatformLinkField.parse(content).value));
|
|
215
|
+
}
|
|
216
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
217
|
+
} while (cursor);
|
|
218
|
+
return links;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// === Group membership reads ===
|
|
222
|
+
|
|
223
|
+
/** Normalizes a dynamic-field key's BCS bytes (Uint8Array or base64 string). */
|
|
224
|
+
function keyBytes(bcs: unknown): Uint8Array {
|
|
225
|
+
return typeof bcs === "string" ? fromBase64(bcs) : (bcs as Uint8Array);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The group ids a party currently belongs to, read from its `MembershipKey`
|
|
230
|
+
* dynamic fields (the member-side record). No indexer required.
|
|
231
|
+
*/
|
|
232
|
+
export async function getMemberships(client: ClientWithCoreApi, partyId: string): Promise<string[]> {
|
|
233
|
+
const groups: string[] = [];
|
|
234
|
+
let cursor: string | null | undefined;
|
|
235
|
+
do {
|
|
236
|
+
const page = await client.core.listDynamicFields({ parentId: partyId, cursor: cursor ?? undefined });
|
|
237
|
+
for (const f of page.dynamicFields) {
|
|
238
|
+
if (typeof f.name?.type === "string" && f.name.type.endsWith("::party::MembershipKey") && f.name.bcs != null) {
|
|
239
|
+
const [groupId] = MembershipKeyBcs.parse(keyBytes(f.name.bcs));
|
|
240
|
+
groups.push(String(groupId));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
244
|
+
} while (cursor);
|
|
245
|
+
return groups;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** The member ids invited to a group but not yet accepted (its `PendingInviteKey` fields). */
|
|
249
|
+
export async function getPendingInvites(client: ClientWithCoreApi, groupId: string): Promise<string[]> {
|
|
250
|
+
const members: string[] = [];
|
|
251
|
+
let cursor: string | null | undefined;
|
|
252
|
+
do {
|
|
253
|
+
const page = await client.core.listDynamicFields({ parentId: groupId, cursor: cursor ?? undefined });
|
|
254
|
+
for (const f of page.dynamicFields) {
|
|
255
|
+
if (typeof f.name?.type === "string" && f.name.type.endsWith("::party::PendingInviteKey") && f.name.bcs != null) {
|
|
256
|
+
const [memberId] = PendingInviteKeyBcs.parse(keyBytes(f.name.bcs));
|
|
257
|
+
members.push(String(memberId));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
261
|
+
} while (cursor);
|
|
262
|
+
return members;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The group ids that have invited a party but are still awaiting its response.
|
|
267
|
+
* This reads the member-side `PendingMembershipKey` inbox index, so it only
|
|
268
|
+
* enumerates the target party's dynamic fields.
|
|
269
|
+
*/
|
|
270
|
+
export async function getPendingMemberships(client: ClientWithCoreApi, partyId: string): Promise<string[]> {
|
|
271
|
+
const groups: string[] = [];
|
|
272
|
+
let cursor: string | null | undefined;
|
|
273
|
+
do {
|
|
274
|
+
const page = await client.core.listDynamicFields({ parentId: partyId, cursor: cursor ?? undefined });
|
|
275
|
+
for (const f of page.dynamicFields) {
|
|
276
|
+
if (
|
|
277
|
+
typeof f.name?.type === "string" &&
|
|
278
|
+
f.name.type.endsWith("::party::PendingMembershipKey") &&
|
|
279
|
+
f.name.bcs != null
|
|
280
|
+
) {
|
|
281
|
+
const [groupId] = PendingMembershipKeyBcs.parse(keyBytes(f.name.bcs));
|
|
282
|
+
groups.push(String(groupId));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
286
|
+
} while (cursor);
|
|
287
|
+
return groups;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** Whether `memberId` currently holds a membership record for `groupId`. */
|
|
291
|
+
export async function isMember(
|
|
292
|
+
client: ClientWithCoreApi,
|
|
293
|
+
memberId: string,
|
|
294
|
+
groupId: string,
|
|
295
|
+
partyPackageId: string,
|
|
296
|
+
): Promise<boolean> {
|
|
297
|
+
const fieldId = deriveDynamicFieldID(
|
|
298
|
+
memberId,
|
|
299
|
+
`${partyPackageId}::party::MembershipKey`,
|
|
300
|
+
MembershipKeyBcs.serialize([groupId]).toBytes(),
|
|
301
|
+
);
|
|
302
|
+
return (await getContent(client, fieldId)) !== null;
|
|
303
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Core PartyOS transaction builders. Every builder returns a thunk that *appends*
|
|
5
|
+
// commands to a caller-owned Transaction, so flows compose. Package ids are taken
|
|
6
|
+
// in params (the client binds them; see ./client.ts). Calls into the party package
|
|
7
|
+
// go through the generated typed call fns (party.*).
|
|
8
|
+
|
|
9
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
10
|
+
import * as party from "../contracts/miso_party/party.ts";
|
|
11
|
+
|
|
12
|
+
export type TxThunk = (tx: Transaction) => void | Promise<void>;
|
|
13
|
+
|
|
14
|
+
export interface CreatePartyParams {
|
|
15
|
+
/** Human-readable party name (not verified; app-layer verifies). */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Address that receives the PartyAdminCap. */
|
|
18
|
+
recipient: string;
|
|
19
|
+
partyPackageId: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Creates an individual party, shares it, and transfers its admin cap to `recipient`. */
|
|
23
|
+
export function createIndividualParty(params: CreatePartyParams): TxThunk {
|
|
24
|
+
return (tx) => {
|
|
25
|
+
const kind = tx.add(party.newIndividualKind({ package: params.partyPackageId }));
|
|
26
|
+
const res = tx.add(party._new({ package: params.partyPackageId, arguments: [kind, params.name] }));
|
|
27
|
+
tx.add(party.share({ package: params.partyPackageId, arguments: [res[0]!, res[1]!] }));
|
|
28
|
+
tx.transferObjects([res[1]!], params.recipient);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Creates a group party (empty member set), shares it, transfers its admin cap. */
|
|
33
|
+
export function createGroupParty(params: CreatePartyParams): TxThunk {
|
|
34
|
+
return (tx) => {
|
|
35
|
+
const kind = tx.add(party.newGroupKind({ package: params.partyPackageId }));
|
|
36
|
+
const res = tx.add(party._new({ package: params.partyPackageId, arguments: [kind, params.name] }));
|
|
37
|
+
tx.add(party.share({ package: params.partyPackageId, arguments: [res[0]!, res[1]!] }));
|
|
38
|
+
tx.transferObjects([res[1]!], params.recipient);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// === Group membership: invite / accept / decline / revoke / leave / evict ===
|
|
43
|
+
// Membership is consent-based: the group admin invites, the member accepts with
|
|
44
|
+
// its OWN admin cap. `member`/`group`/`*Cap` params are all object ids.
|
|
45
|
+
|
|
46
|
+
export interface InvitePartyParams {
|
|
47
|
+
groupId: string;
|
|
48
|
+
groupCapId: string;
|
|
49
|
+
/** The individual party (shared object id) to invite. */
|
|
50
|
+
memberId: string;
|
|
51
|
+
partyPackageId: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Invites an individual party to a group (gated by the group's admin cap). */
|
|
55
|
+
export function inviteParty(params: InvitePartyParams): TxThunk {
|
|
56
|
+
return (tx) => {
|
|
57
|
+
tx.add(party.inviteParty({
|
|
58
|
+
package: params.partyPackageId,
|
|
59
|
+
arguments: [params.groupId, params.memberId, params.groupCapId],
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface AcceptInviteParams {
|
|
65
|
+
groupId: string;
|
|
66
|
+
memberId: string;
|
|
67
|
+
/** The member party's admin cap id (proves consent). */
|
|
68
|
+
memberCapId: string;
|
|
69
|
+
partyPackageId: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Accepts a pending invite, joining the member to the group (member's cap). */
|
|
73
|
+
export function acceptInvite(params: AcceptInviteParams): TxThunk {
|
|
74
|
+
return (tx) => {
|
|
75
|
+
tx.add(party.acceptInvite({
|
|
76
|
+
package: params.partyPackageId,
|
|
77
|
+
arguments: [params.groupId, params.memberId, params.memberCapId],
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface DeclineInviteParams {
|
|
83
|
+
groupId: string;
|
|
84
|
+
/** The invited individual party (shared object id). */
|
|
85
|
+
memberId: string;
|
|
86
|
+
memberCapId: string;
|
|
87
|
+
partyPackageId: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Declines a pending invite (member's cap). */
|
|
91
|
+
export function declineInvite(params: DeclineInviteParams): TxThunk {
|
|
92
|
+
return (tx) => {
|
|
93
|
+
tx.add(party.declineInvite({
|
|
94
|
+
package: params.partyPackageId,
|
|
95
|
+
arguments: [params.groupId, params.memberId, params.memberCapId],
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface RevokeInviteParams {
|
|
101
|
+
groupId: string;
|
|
102
|
+
/** The invited individual party (shared object id). */
|
|
103
|
+
memberId: string;
|
|
104
|
+
groupCapId: string;
|
|
105
|
+
partyPackageId: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Revokes a pending invite (group's admin cap). */
|
|
109
|
+
export function revokeInvite(params: RevokeInviteParams): TxThunk {
|
|
110
|
+
return (tx) => {
|
|
111
|
+
tx.add(party.revokeInvite({
|
|
112
|
+
package: params.partyPackageId,
|
|
113
|
+
arguments: [params.groupId, params.memberId, params.groupCapId],
|
|
114
|
+
}));
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface LeaveGroupParams {
|
|
119
|
+
groupId: string;
|
|
120
|
+
memberId: string;
|
|
121
|
+
memberCapId: string;
|
|
122
|
+
partyPackageId: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Leaves a group, authorized by the member's own admin cap. */
|
|
126
|
+
export function leaveGroup(params: LeaveGroupParams): TxThunk {
|
|
127
|
+
return (tx) => {
|
|
128
|
+
tx.add(party.leave({
|
|
129
|
+
package: params.partyPackageId,
|
|
130
|
+
arguments: [params.groupId, params.memberId, params.memberCapId],
|
|
131
|
+
}));
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface RemoveMemberParams {
|
|
136
|
+
groupId: string;
|
|
137
|
+
groupCapId: string;
|
|
138
|
+
memberId: string;
|
|
139
|
+
partyPackageId: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Evicts a member from a group (group's admin cap); scrubs the member's record too. */
|
|
143
|
+
export function removeMember(params: RemoveMemberParams): TxThunk {
|
|
144
|
+
return (tx) => {
|
|
145
|
+
tx.add(party.removeMember({
|
|
146
|
+
package: params.partyPackageId,
|
|
147
|
+
arguments: [params.groupId, params.groupCapId, params.memberId],
|
|
148
|
+
}));
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface SetNameParams {
|
|
153
|
+
partyId: string;
|
|
154
|
+
capId: string;
|
|
155
|
+
name: string;
|
|
156
|
+
partyPackageId: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Sets the party's human-readable name. */
|
|
160
|
+
export function setName(params: SetNameParams): TxThunk {
|
|
161
|
+
return (tx) => {
|
|
162
|
+
tx.add(party.setName({
|
|
163
|
+
package: params.partyPackageId,
|
|
164
|
+
arguments: [params.partyId, params.capId, params.name],
|
|
165
|
+
}));
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Public, camelCase result types. The mappers in ./internal.ts turn the generated
|
|
5
|
+
// (snake_case, Move-shaped) parse output into these.
|
|
6
|
+
|
|
7
|
+
export type PartyKind = "individual" | "group";
|
|
8
|
+
|
|
9
|
+
export interface Party {
|
|
10
|
+
id: string;
|
|
11
|
+
kind: PartyKind;
|
|
12
|
+
/** Human-readable name (not verified). */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Member party ids — present only when `kind === "group"`. */
|
|
15
|
+
members?: string[];
|
|
16
|
+
/** Unix ms when the party was created. */
|
|
17
|
+
createdAtMs: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Profile {
|
|
21
|
+
partyId: string;
|
|
22
|
+
bioShort: string;
|
|
23
|
+
bioLong?: string;
|
|
24
|
+
/** ISO 3166-1 alpha-2 country code, e.g. "GB". */
|
|
25
|
+
country?: string;
|
|
26
|
+
/** ISO 639-1 language codes, e.g. ["en"]. */
|
|
27
|
+
languages: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A party's imagery, stored on-chain as a single Walrus quilt. Individual images
|
|
32
|
+
* (avatar, header, …) are quilt patches addressed by identifier off-chain — see
|
|
33
|
+
* `mediaUrls` / `MEDIA_IDENTIFIERS` in `extensions/media`.
|
|
34
|
+
*/
|
|
35
|
+
export interface Media {
|
|
36
|
+
partyId: string;
|
|
37
|
+
/** Walrus quilt blob id (base64url) holding the party's images. */
|
|
38
|
+
quiltId: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A single call-to-action on a party: a labeled external link. Position is priority. */
|
|
42
|
+
export interface Cta {
|
|
43
|
+
label: string;
|
|
44
|
+
url: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A platform this SDK knows how to build a link for. One key per external
|
|
49
|
+
* platform, spanning social (`x`, `instagram`, …), music (`spotify`, `bandcamp`,
|
|
50
|
+
* …), and professional/industry (`website`, `patreon`, …) payloads.
|
|
51
|
+
*/
|
|
52
|
+
export type PlatformKey =
|
|
53
|
+
// Social (party_social)
|
|
54
|
+
| "x"
|
|
55
|
+
| "instagram"
|
|
56
|
+
| "threads"
|
|
57
|
+
| "tiktok"
|
|
58
|
+
| "youtube"
|
|
59
|
+
| "discord"
|
|
60
|
+
| "telegram"
|
|
61
|
+
| "reddit"
|
|
62
|
+
| "twitch"
|
|
63
|
+
| "facebook"
|
|
64
|
+
// Music (party_music)
|
|
65
|
+
| "spotify"
|
|
66
|
+
| "bandcamp"
|
|
67
|
+
| "soundcloud"
|
|
68
|
+
| "appleMusic"
|
|
69
|
+
| "deezer"
|
|
70
|
+
| "tidal"
|
|
71
|
+
| "amazonMusic"
|
|
72
|
+
| "audiomack"
|
|
73
|
+
// Professional / industry (party_pro_link)
|
|
74
|
+
| "website"
|
|
75
|
+
| "bookingPage"
|
|
76
|
+
| "managementPage"
|
|
77
|
+
| "publisherPage"
|
|
78
|
+
| "labelPage"
|
|
79
|
+
| "epk"
|
|
80
|
+
| "patreon"
|
|
81
|
+
| "substack"
|
|
82
|
+
| "kofi";
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* One external-platform link attached to a party. Only the native identifier
|
|
86
|
+
* (`value` — a handle, artist id, subdomain, or full URL) is stored on-chain; the
|
|
87
|
+
* public `url` is rebuilt client-side from it.
|
|
88
|
+
*/
|
|
89
|
+
export interface PlatformLink {
|
|
90
|
+
platform: PlatformKey;
|
|
91
|
+
/** The platform-native identifier stored on-chain (handle / id / subdomain / URL). */
|
|
92
|
+
value: string;
|
|
93
|
+
/** The public profile URL, rebuilt from `value`. */
|
|
94
|
+
url: string;
|
|
95
|
+
}
|