@misonetwork/sdk 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +44 -98
  2. package/dist/contracts.d.ts +0 -12
  3. package/dist/contracts.d.ts.map +1 -1
  4. package/dist/contracts.js +3 -16
  5. package/dist/contracts.js.map +1 -1
  6. package/dist/index.d.ts +0 -3
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -3
  9. package/dist/index.js.map +1 -1
  10. package/dist/internal.d.ts +7 -3
  11. package/dist/internal.d.ts.map +1 -1
  12. package/dist/internal.js +22 -4
  13. package/dist/internal.js.map +1 -1
  14. package/dist/queries.d.ts +8 -0
  15. package/dist/queries.d.ts.map +1 -1
  16. package/dist/queries.js +30 -8
  17. package/dist/queries.js.map +1 -1
  18. package/package.json +1 -13
  19. package/src/contracts.ts +3 -19
  20. package/src/index.ts +3 -3
  21. package/src/internal.ts +34 -15
  22. package/src/queries.ts +40 -12
  23. package/dist/contracts/composition_credits/composition_credits.d.ts +0 -181
  24. package/dist/contracts/composition_credits/composition_credits.d.ts.map +0 -1
  25. package/dist/contracts/composition_credits/composition_credits.js +0 -109
  26. package/dist/contracts/composition_credits/composition_credits.js.map +0 -1
  27. package/dist/contracts/composition_credits/composition_party_role.d.ts +0 -119
  28. package/dist/contracts/composition_credits/composition_party_role.d.ts.map +0 -1
  29. package/dist/contracts/composition_credits/composition_party_role.js +0 -139
  30. package/dist/contracts/composition_credits/composition_party_role.js.map +0 -1
  31. package/dist/contracts/composition_credits/deps/miso_credit/credit.d.ts +0 -24
  32. package/dist/contracts/composition_credits/deps/miso_credit/credit.d.ts.map +0 -1
  33. package/dist/contracts/composition_credits/deps/miso_credit/credit.js +0 -23
  34. package/dist/contracts/composition_credits/deps/miso_credit/credit.js.map +0 -1
  35. package/dist/contracts/composition_credits/deps/sui/vec_map.d.ts +0 -37
  36. package/dist/contracts/composition_credits/deps/sui/vec_map.d.ts.map +0 -1
  37. package/dist/contracts/composition_credits/deps/sui/vec_map.js +0 -28
  38. package/dist/contracts/composition_credits/deps/sui/vec_map.js.map +0 -1
  39. package/dist/contracts/composition_royalty_pool/composition_royalty_pool.d.ts +0 -87
  40. package/dist/contracts/composition_royalty_pool/composition_royalty_pool.d.ts.map +0 -1
  41. package/dist/contracts/composition_royalty_pool/composition_royalty_pool.js +0 -80
  42. package/dist/contracts/composition_royalty_pool/composition_royalty_pool.js.map +0 -1
  43. package/dist/contracts/cover_art/cover_art.d.ts +0 -85
  44. package/dist/contracts/cover_art/cover_art.d.ts.map +0 -1
  45. package/dist/contracts/cover_art/cover_art.js +0 -68
  46. package/dist/contracts/cover_art/cover_art.js.map +0 -1
  47. package/dist/contracts/cover_art/deps/ori/walrus_data.d.ts +0 -52
  48. package/dist/contracts/cover_art/deps/ori/walrus_data.d.ts.map +0 -1
  49. package/dist/contracts/cover_art/deps/ori/walrus_data.js +0 -37
  50. package/dist/contracts/cover_art/deps/ori/walrus_data.js.map +0 -1
  51. package/dist/contracts/recording_credits/deps/miso_credit/credit.d.ts +0 -24
  52. package/dist/contracts/recording_credits/deps/miso_credit/credit.d.ts.map +0 -1
  53. package/dist/contracts/recording_credits/deps/miso_credit/credit.js +0 -23
  54. package/dist/contracts/recording_credits/deps/miso_credit/credit.js.map +0 -1
  55. package/dist/contracts/recording_credits/deps/sui/vec_map.d.ts +0 -37
  56. package/dist/contracts/recording_credits/deps/sui/vec_map.d.ts.map +0 -1
  57. package/dist/contracts/recording_credits/deps/sui/vec_map.js +0 -28
  58. package/dist/contracts/recording_credits/deps/sui/vec_map.js.map +0 -1
  59. package/dist/contracts/recording_credits/deps/sui/vec_set.d.ts +0 -21
  60. package/dist/contracts/recording_credits/deps/sui/vec_set.d.ts.map +0 -1
  61. package/dist/contracts/recording_credits/deps/sui/vec_set.js +0 -20
  62. package/dist/contracts/recording_credits/deps/sui/vec_set.js.map +0 -1
  63. package/dist/contracts/recording_credits/recording_credits.d.ts +0 -2313
  64. package/dist/contracts/recording_credits/recording_credits.d.ts.map +0 -1
  65. package/dist/contracts/recording_credits/recording_credits.js +0 -270
  66. package/dist/contracts/recording_credits/recording_credits.js.map +0 -1
  67. package/dist/contracts/recording_credits/recording_party_role.d.ts +0 -1174
  68. package/dist/contracts/recording_credits/recording_party_role.d.ts.map +0 -1
  69. package/dist/contracts/recording_credits/recording_party_role.js +0 -692
  70. package/dist/contracts/recording_credits/recording_party_role.js.map +0 -1
  71. package/dist/contracts/recording_royalty_pool/recording_royalty_pool.d.ts +0 -90
  72. package/dist/contracts/recording_royalty_pool/recording_royalty_pool.d.ts.map +0 -1
  73. package/dist/contracts/recording_royalty_pool/recording_royalty_pool.js +0 -80
  74. package/dist/contracts/recording_royalty_pool/recording_royalty_pool.js.map +0 -1
  75. package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.d.ts +0 -52
  76. package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.d.ts.map +0 -1
  77. package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.js +0 -37
  78. package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.js.map +0 -1
  79. package/dist/contracts/release_cover_art/deps/cover_art/cover_art.d.ts +0 -46
  80. package/dist/contracts/release_cover_art/deps/cover_art/cover_art.d.ts.map +0 -1
  81. package/dist/contracts/release_cover_art/deps/cover_art/cover_art.js +0 -21
  82. package/dist/contracts/release_cover_art/deps/cover_art/cover_art.js.map +0 -1
  83. package/dist/contracts/release_cover_art/deps/per_track/per_track.d.ts +0 -33
  84. package/dist/contracts/release_cover_art/deps/per_track/per_track.d.ts.map +0 -1
  85. package/dist/contracts/release_cover_art/deps/per_track/per_track.js +0 -32
  86. package/dist/contracts/release_cover_art/deps/per_track/per_track.js.map +0 -1
  87. package/dist/contracts/release_cover_art/release_cover_art.d.ts +0 -300
  88. package/dist/contracts/release_cover_art/release_cover_art.d.ts.map +0 -1
  89. package/dist/contracts/release_cover_art/release_cover_art.js +0 -168
  90. package/dist/contracts/release_cover_art/release_cover_art.js.map +0 -1
  91. package/dist/contracts/release_credits/deps/miso_credit/credit.d.ts +0 -24
  92. package/dist/contracts/release_credits/deps/miso_credit/credit.d.ts.map +0 -1
  93. package/dist/contracts/release_credits/deps/miso_credit/credit.js +0 -23
  94. package/dist/contracts/release_credits/deps/miso_credit/credit.js.map +0 -1
  95. package/dist/contracts/release_credits/deps/sui/vec_map.d.ts +0 -37
  96. package/dist/contracts/release_credits/deps/sui/vec_map.d.ts.map +0 -1
  97. package/dist/contracts/release_credits/deps/sui/vec_map.js +0 -28
  98. package/dist/contracts/release_credits/deps/sui/vec_map.js.map +0 -1
  99. package/dist/contracts/release_credits/release_credits.d.ts +0 -142
  100. package/dist/contracts/release_credits/release_credits.d.ts.map +0 -1
  101. package/dist/contracts/release_credits/release_credits.js +0 -108
  102. package/dist/contracts/release_credits/release_credits.js.map +0 -1
  103. package/dist/contracts/release_credits/release_party_role.d.ts +0 -58
  104. package/dist/contracts/release_credits/release_party_role.d.ts.map +0 -1
  105. package/dist/contracts/release_credits/release_party_role.js +0 -66
  106. package/dist/contracts/release_credits/release_party_role.js.map +0 -1
  107. package/dist/contracts/royalty_pool/deps/std/type_name.d.ts +0 -18
  108. package/dist/contracts/royalty_pool/deps/std/type_name.d.ts.map +0 -1
  109. package/dist/contracts/royalty_pool/deps/std/type_name.js +0 -20
  110. package/dist/contracts/royalty_pool/deps/std/type_name.js.map +0 -1
  111. package/dist/contracts/royalty_pool/deps/sui/balance.d.ts +0 -13
  112. package/dist/contracts/royalty_pool/deps/sui/balance.d.ts.map +0 -1
  113. package/dist/contracts/royalty_pool/deps/sui/balance.js +0 -15
  114. package/dist/contracts/royalty_pool/deps/sui/balance.js.map +0 -1
  115. package/dist/contracts/royalty_pool/deps/sui/vec_map.d.ts +0 -37
  116. package/dist/contracts/royalty_pool/deps/sui/vec_map.d.ts.map +0 -1
  117. package/dist/contracts/royalty_pool/deps/sui/vec_map.js +0 -28
  118. package/dist/contracts/royalty_pool/deps/sui/vec_map.js.map +0 -1
  119. package/dist/contracts/royalty_pool/pool.d.ts +0 -358
  120. package/dist/contracts/royalty_pool/pool.d.ts.map +0 -1
  121. package/dist/contracts/royalty_pool/pool.js +0 -352
  122. package/dist/contracts/royalty_pool/pool.js.map +0 -1
  123. package/dist/contracts/royalty_pool/stake.d.ts +0 -202
  124. package/dist/contracts/royalty_pool/stake.d.ts.map +0 -1
  125. package/dist/contracts/royalty_pool/stake.js +0 -197
  126. package/dist/contracts/royalty_pool/stake.js.map +0 -1
  127. package/dist/cover.d.ts +0 -48
  128. package/dist/cover.d.ts.map +0 -1
  129. package/dist/cover.js +0 -68
  130. package/dist/cover.js.map +0 -1
  131. package/dist/credits.d.ts +0 -171
  132. package/dist/credits.d.ts.map +0 -1
  133. package/dist/credits.js +0 -360
  134. package/dist/credits.js.map +0 -1
  135. package/dist/extensions/royalty-pool.d.ts +0 -32
  136. package/dist/extensions/royalty-pool.d.ts.map +0 -1
  137. package/dist/extensions/royalty-pool.js +0 -33
  138. package/dist/extensions/royalty-pool.js.map +0 -1
  139. package/src/contracts/composition_credits/composition_credits.ts +0 -169
  140. package/src/contracts/composition_credits/composition_party_role.ts +0 -189
  141. package/src/contracts/composition_credits/deps/miso_credit/credit.ts +0 -27
  142. package/src/contracts/composition_credits/deps/sui/vec_map.ts +0 -33
  143. package/src/contracts/composition_royalty_pool/composition_royalty_pool.ts +0 -135
  144. package/src/contracts/cover_art/cover_art.ts +0 -99
  145. package/src/contracts/cover_art/deps/ori/walrus_data.ts +0 -36
  146. package/src/contracts/recording_credits/deps/miso_credit/credit.ts +0 -27
  147. package/src/contracts/recording_credits/deps/sui/vec_map.ts +0 -33
  148. package/src/contracts/recording_credits/deps/sui/vec_set.ts +0 -21
  149. package/src/contracts/recording_credits/recording_credits.ts +0 -458
  150. package/src/contracts/recording_credits/recording_party_role.ts +0 -1041
  151. package/src/contracts/recording_royalty_pool/recording_royalty_pool.ts +0 -138
  152. package/src/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.ts +0 -36
  153. package/src/contracts/release_cover_art/deps/cover_art/cover_art.ts +0 -23
  154. package/src/contracts/release_cover_art/deps/per_track/per_track.ts +0 -36
  155. package/src/contracts/release_cover_art/release_cover_art.ts +0 -251
  156. package/src/contracts/release_credits/deps/miso_credit/credit.ts +0 -27
  157. package/src/contracts/release_credits/deps/sui/vec_map.ts +0 -33
  158. package/src/contracts/release_credits/release_credits.ts +0 -156
  159. package/src/contracts/release_credits/release_party_role.ts +0 -87
  160. package/src/contracts/royalty_pool/deps/std/type_name.ts +0 -22
  161. package/src/contracts/royalty_pool/deps/sui/balance.ts +0 -17
  162. package/src/contracts/royalty_pool/deps/sui/vec_map.ts +0 -33
  163. package/src/contracts/royalty_pool/pool.ts +0 -577
  164. package/src/contracts/royalty_pool/stake.ts +0 -317
  165. package/src/cover.ts +0 -136
  166. package/src/credits.ts +0 -645
  167. package/src/extensions/royalty-pool.ts +0 -85
package/dist/credits.js DELETED
@@ -1,360 +0,0 @@
1
- // Copyright (c) Miso Labs, Inc.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { bcs } from "@mysten/sui/bcs";
4
- import { deriveDynamicFieldID } from "@mysten/sui/utils";
5
- import { OPTION_NONE, OPTION_SOME } from "./internal.js";
6
- import { isNotFound } from "./queries.js";
7
- import * as compositionCredits from "./contracts/composition_credits/composition_credits.js";
8
- import * as compositionPartyRole from "./contracts/composition_credits/composition_party_role.js";
9
- import * as recordingCredits from "./contracts/recording_credits/recording_credits.js";
10
- import * as recordingPartyRole from "./contracts/recording_credits/recording_party_role.js";
11
- import * as releaseCredits from "./contracts/release_credits/release_credits.js";
12
- import * as releasePartyRole from "./contracts/release_credits/release_party_role.js";
13
- const COMPOSITION_ROLE_CTOR = {
14
- Adapter: compositionPartyRole.newAdapterRole,
15
- Arranger: compositionPartyRole.newArrangerRole,
16
- Composer: compositionPartyRole.newComposerRole,
17
- Lyricist: compositionPartyRole.newLyricistRole,
18
- Songwriter: compositionPartyRole.newSongwriterRole,
19
- Translator: compositionPartyRole.newTranslatorRole,
20
- };
21
- const RECORDING_LEVEL_CTOR = {
22
- Additional: recordingPartyRole.newAdditionalRoleLevel,
23
- Assistant: recordingPartyRole.newAssistantRoleLevel,
24
- Associate: recordingPartyRole.newAssociateRoleLevel,
25
- Backing: recordingPartyRole.newBackingRoleLevel,
26
- Executive: recordingPartyRole.newExecutiveRoleLevel,
27
- Featured: recordingPartyRole.newFeaturedRoleLevel,
28
- Lead: recordingPartyRole.newLeadRoleLevel,
29
- Primary: recordingPartyRole.newPrimaryRoleLevel,
30
- Principal: recordingPartyRole.newPrincipalRoleLevel,
31
- };
32
- const RECORDING_LEVELED_ROLE_CTOR = {
33
- Actor: recordingPartyRole.newActorRole,
34
- Arranger: recordingPartyRole.newArrangerRole,
35
- BandLeader: recordingPartyRole.newBandLeaderRole,
36
- Choir: recordingPartyRole.newChoirRole,
37
- ChoirMaster: recordingPartyRole.newChoirMasterRole,
38
- ConcertMaster: recordingPartyRole.newConcertMasterRole,
39
- Conductor: recordingPartyRole.newConductorRole,
40
- Contractor: recordingPartyRole.newContractorRole,
41
- DJ: recordingPartyRole.newDjRole,
42
- Editor: recordingPartyRole.newEditorRole,
43
- Engineer: recordingPartyRole.newEngineerRole,
44
- Ensemble: recordingPartyRole.newEnsembleRole,
45
- MasteringEngineer: recordingPartyRole.newMasteringEngineerRole,
46
- MixingEngineer: recordingPartyRole.newMixingEngineerRole,
47
- MusicDirector: recordingPartyRole.newMusicDirectorRole,
48
- MusicSupervisor: recordingPartyRole.newMusicSupervisorRole,
49
- Narrator: recordingPartyRole.newNarratorRole,
50
- Orchestra: recordingPartyRole.newOrchestraRole,
51
- Orchestrator: recordingPartyRole.newOrchestratorRole,
52
- Performer: recordingPartyRole.newPerformerRole,
53
- Producer: recordingPartyRole.newProducerRole,
54
- Programmer: recordingPartyRole.newProgrammerRole,
55
- RecordingEngineer: recordingPartyRole.newRecordingEngineerRole,
56
- RemixingEngineer: recordingPartyRole.newRemixingEngineerRole,
57
- Soloist: recordingPartyRole.newSoloistRole,
58
- SoundDesigner: recordingPartyRole.newSoundDesignerRole,
59
- Speaker: recordingPartyRole.newSpeakerRole,
60
- Vocalist: recordingPartyRole.newVocalistRole,
61
- };
62
- /** Builds an `Option<RecordingPartyRoleLevel>` argument for a role constructor. */
63
- function levelOption(tx, pkg, level) {
64
- const levelType = `${pkg}::recording_party_role::RecordingPartyRoleLevel`;
65
- if (!level)
66
- return tx.moveCall({ target: OPTION_NONE, typeArguments: [levelType] });
67
- const lvl = tx.add(RECORDING_LEVEL_CTOR[level]({ package: pkg }));
68
- return tx.moveCall({ target: OPTION_SOME, typeArguments: [levelType], arguments: [lvl] });
69
- }
70
- /** Builds one `CompositionPartyRole` value in the PTB. */
71
- function buildCompositionRole(tx, pkg, role) {
72
- if (role.type === "Custom") {
73
- return tx.add(compositionPartyRole.newCustomRole({ package: pkg, arguments: [role.name] }));
74
- }
75
- return tx.add(COMPOSITION_ROLE_CTOR[role.type]({ package: pkg }));
76
- }
77
- /** Builds one `RecordingPartyRole` value in the PTB. */
78
- function buildRecordingRole(tx, pkg, role) {
79
- switch (role.type) {
80
- case "ArtistsAndRepertoire":
81
- return tx.add(recordingPartyRole.newArtistsAndRepertoireRole({ package: pkg }));
82
- case "Copyist":
83
- return tx.add(recordingPartyRole.newCopyistRole({ package: pkg }));
84
- case "Instrumentalist":
85
- return tx.add(recordingPartyRole.newInstrumentalistRole({
86
- package: pkg,
87
- arguments: [role.instrument, levelOption(tx, pkg, role.level)],
88
- }));
89
- case "Custom":
90
- return tx.add(recordingPartyRole.newCustomRole({
91
- package: pkg,
92
- arguments: [role.name, levelOption(tx, pkg, role.level)],
93
- }));
94
- default:
95
- return tx.add(RECORDING_LEVELED_ROLE_CTOR[role.type]({
96
- package: pkg,
97
- arguments: [levelOption(tx, pkg, role.level)],
98
- }));
99
- }
100
- }
101
- /** Builds one `ReleasePartyRole` value in the PTB. */
102
- function buildReleaseRole(tx, pkg, role) {
103
- const ctor = role === "Primary" ? releasePartyRole.newPrimaryRole : releasePartyRole.newFeaturedRole;
104
- return tx.add(ctor({ package: pkg }));
105
- }
106
- // ── Client-side validation ────────────────────────────────────────────────────
107
- //
108
- // Mirrors the Move aborts so bad params fail fast (and readably) at the writer
109
- // call site instead of as an on-chain abort code:
110
- // - miso_credit::credit::new — EEmptyString / EMaxDisplayNameLengthExceeded
111
- // (display name non-empty, ≤200 BYTES of UTF-8) and ENoRoles / EDuplicateRoles.
112
- // - composition_credits::add_credit — EMinRolesNotMet / EExceedsMaxRoles (1–5).
113
- // - recording_credits::add_credit — EMinRolesNotMet / EExceedsMaxRoles (1–10).
114
- const MAX_DISPLAY_NAME_BYTES = 200;
115
- const MAX_COMPOSITION_ROLES = 5;
116
- const MAX_RECORDING_ROLES = 10;
117
- function assertDisplayName(fn, displayName) {
118
- if (displayName.length === 0)
119
- throw new Error(`${fn}: displayName must not be empty`);
120
- const byteLength = new TextEncoder().encode(displayName).length;
121
- if (byteLength > MAX_DISPLAY_NAME_BYTES) {
122
- throw new Error(`${fn}: displayName must be at most ${MAX_DISPLAY_NAME_BYTES} bytes of UTF-8 (got ${byteLength})`);
123
- }
124
- }
125
- // Move rejects duplicates by full struct equality, so the duplicate key is the
126
- // role's complete identity: type + instrument + custom name + level.
127
- function roleKey(role) {
128
- return JSON.stringify([
129
- role.type,
130
- "instrument" in role ? role.instrument : null,
131
- "name" in role ? role.name : null,
132
- "level" in role && role.level !== undefined ? role.level : null,
133
- ]);
134
- }
135
- function assertRoles(fn, roles, max) {
136
- if (roles.length < 1)
137
- throw new Error(`${fn}: at least one role is required`);
138
- if (roles.length > max)
139
- throw new Error(`${fn}: at most ${max} roles are allowed (got ${roles.length})`);
140
- const seen = new Set();
141
- for (const role of roles) {
142
- const key = roleKey(role);
143
- if (seen.has(key))
144
- throw new Error(`${fn}: duplicate role ${key}`);
145
- seen.add(key);
146
- }
147
- }
148
- /** Wraps built role values in a `miso_credit::credit::Credit<Role>`. */
149
- function buildCredit(tx, misoCreditPackageId, roleType, displayName, roleArgs) {
150
- const roles = tx.makeMoveVec({ type: roleType, elements: roleArgs });
151
- return tx.moveCall({
152
- target: `${misoCreditPackageId}::credit::new`,
153
- typeArguments: [roleType],
154
- arguments: [tx.pure.string(displayName), roles],
155
- });
156
- }
157
- /**
158
- * Adds a writing credit for a party on a composition. Throws (client-side,
159
- * mirroring the Move aborts) when `displayName` is empty or over 200 UTF-8
160
- * bytes, or `roles` is empty, has more than 5 entries, or contains duplicates.
161
- */
162
- export function attachCompositionCredit(p) {
163
- assertDisplayName("attachCompositionCredit", p.displayName);
164
- assertRoles("attachCompositionCredit", p.roles, MAX_COMPOSITION_ROLES);
165
- return (tx) => {
166
- const roleType = `${p.compositionCreditsPackageId}::composition_party_role::CompositionPartyRole`;
167
- const roleArgs = p.roles.map((r) => buildCompositionRole(tx, p.compositionCreditsPackageId, r));
168
- const credit = buildCredit(tx, p.misoCreditPackageId, roleType, p.displayName, roleArgs);
169
- tx.add(compositionCredits.addCredit({
170
- package: p.compositionCreditsPackageId,
171
- typeArguments: [p.compositionShareType],
172
- arguments: [p.compositionId, p.compositionAdminCapId, p.partyId, credit],
173
- }));
174
- };
175
- }
176
- /**
177
- * Adds a production/performance credit for a party on a recording. Throws
178
- * (client-side, mirroring the Move aborts) when `displayName` is empty or over
179
- * 200 UTF-8 bytes, or `roles` is empty, has more than 10 entries, or contains
180
- * duplicates (same type + instrument + custom name + level).
181
- */
182
- export function attachRecordingCredit(p) {
183
- assertDisplayName("attachRecordingCredit", p.displayName);
184
- assertRoles("attachRecordingCredit", p.roles, MAX_RECORDING_ROLES);
185
- return (tx) => {
186
- const roleType = `${p.recordingCreditsPackageId}::recording_party_role::RecordingPartyRole`;
187
- const roleArgs = p.roles.map((r) => buildRecordingRole(tx, p.recordingCreditsPackageId, r));
188
- const credit = buildCredit(tx, p.misoCreditPackageId, roleType, p.displayName, roleArgs);
189
- tx.add(recordingCredits.addCredit({
190
- package: p.recordingCreditsPackageId,
191
- typeArguments: [p.recordingShareType, p.compositionShareType],
192
- arguments: [p.recordingId, p.recordingAdminCapId, p.partyId, credit],
193
- }));
194
- };
195
- }
196
- /**
197
- * Designates an already-credited party as a primary artist on a recording. The
198
- * party must be credited first (via `attachRecordingCredit`) and not already a
199
- * primary or featured artist.
200
- */
201
- export function addRecordingPrimaryArtist(p) {
202
- return (tx) => {
203
- tx.add(recordingCredits.addPrimaryArtist({
204
- package: p.recordingCreditsPackageId,
205
- typeArguments: [p.recordingShareType, p.compositionShareType],
206
- arguments: [p.recordingId, p.recordingAdminCapId, p.partyId],
207
- }));
208
- };
209
- }
210
- /**
211
- * Designates an already-credited party as a featured artist on a recording. The
212
- * party must be credited first (via `attachRecordingCredit`) and not already a
213
- * primary or featured artist.
214
- */
215
- export function addRecordingFeaturedArtist(p) {
216
- return (tx) => {
217
- tx.add(recordingCredits.addFeaturedArtist({
218
- package: p.recordingCreditsPackageId,
219
- typeArguments: [p.recordingShareType, p.compositionShareType],
220
- arguments: [p.recordingId, p.recordingAdminCapId, p.partyId],
221
- }));
222
- };
223
- }
224
- /**
225
- * Adds a top-line billing credit (a single role) for a party on a release.
226
- * Throws (client-side, mirroring the Move aborts) when `displayName` is empty
227
- * or over 200 UTF-8 bytes. The single role is structural, so no role checks.
228
- */
229
- export function addReleaseCredit(p) {
230
- assertDisplayName("addReleaseCredit", p.displayName);
231
- return (tx) => {
232
- const roleType = `${p.releaseCreditsPackageId}::release_party_role::ReleasePartyRole`;
233
- const roleArg = buildReleaseRole(tx, p.releaseCreditsPackageId, p.role);
234
- const credit = buildCredit(tx, p.misoCreditPackageId, roleType, p.displayName, [roleArg]);
235
- tx.add(releaseCredits.addCredit({
236
- package: p.releaseCreditsPackageId,
237
- arguments: [p.releaseId, p.releaseAdminCapId, p.partyId, credit],
238
- }));
239
- };
240
- }
241
- // Credits are stored as a dynamic field on the work's UID under the extension's
242
- // `ExtensionKey()` — a positional struct with no fields, so Move's implicit
243
- // `dummy_field: bool` serializes to a single `false` byte. The stored object is a
244
- // `Field { id, name: <Key>, value: <Credits> }`.
245
- const CompositionCreditsField = bcs.struct("Field", {
246
- id: bcs.Address,
247
- name: compositionCredits.ExtensionKey,
248
- value: compositionCredits.CompositionCredits,
249
- });
250
- const RecordingCreditsField = bcs.struct("Field", {
251
- id: bcs.Address,
252
- name: recordingCredits.ExtensionKey,
253
- value: recordingCredits.RecordingCredits,
254
- });
255
- const ReleaseCreditsField = bcs.struct("Field", {
256
- id: bcs.Address,
257
- name: releaseCredits.ExtensionKey,
258
- value: releaseCredits.ReleaseCredits,
259
- });
260
- const COMPOSITION_CREDITS_KEY_BYTES = compositionCredits.ExtensionKey.serialize([false]).toBytes();
261
- const RECORDING_CREDITS_KEY_BYTES = recordingCredits.ExtensionKey.serialize([false]).toBytes();
262
- const RELEASE_CREDITS_KEY_BYTES = releaseCredits.ExtensionKey.serialize([false]).toBytes();
263
- /** Fetches the BCS content of a work's credits dynamic field, or `null` if none. */
264
- async function fetchCreditsField(client, workId, keyType, keyBytes) {
265
- const fieldId = deriveDynamicFieldID(workId, keyType, keyBytes);
266
- try {
267
- const { object } = await client.core.getObject({ objectId: fieldId, include: { content: true } });
268
- return object?.content ?? null;
269
- }
270
- catch (e) {
271
- if (isNotFound(e))
272
- return null;
273
- throw e;
274
- }
275
- }
276
- function creditViews(credits, roleLabel) {
277
- return credits.contents.map((entry) => ({
278
- partyId: entry.key,
279
- displayName: entry.value.display_name,
280
- roles: entry.value.roles.map(roleLabel),
281
- }));
282
- }
283
- // `name()` semantics: the `$kind` is the canonical PascalCase token; `Custom`
284
- // carries the user-supplied name in its payload.
285
- function compositionRoleLabel(role) {
286
- return role.$kind === "Custom" ? role.Custom : role.$kind;
287
- }
288
- function releaseRoleLabel(role) {
289
- return role.$kind;
290
- }
291
- // `name()` semantics plus the recording extras: the instrument (for
292
- // `Instrumentalist`) and the optional level, both surfaced into the label.
293
- function recordingRoleLabel(role) {
294
- let base;
295
- let level = null;
296
- switch (role.$kind) {
297
- case "Instrumentalist": {
298
- const [instrument, lvl] = role.Instrumentalist;
299
- base = `Instrumentalist: ${instrument}`;
300
- level = lvl;
301
- break;
302
- }
303
- case "Custom": {
304
- const [name, lvl] = role.Custom;
305
- base = name;
306
- level = lvl;
307
- break;
308
- }
309
- case "ArtistsAndRepertoire":
310
- case "Copyist":
311
- base = role.$kind;
312
- break;
313
- default: {
314
- // A leveled variant's payload is `Option<Level>`: `None` parses to `true`
315
- // (the unit-payload convention), `Some(level)` to the level enum object.
316
- base = role.$kind;
317
- const payload = role[role.$kind];
318
- level =
319
- payload && typeof payload === "object" && "$kind" in payload ? payload : null;
320
- break;
321
- }
322
- }
323
- return level ? `${base} (${level.$kind})` : base;
324
- }
325
- /**
326
- * Reads a composition's writing credits (the `composition_credits` extension), or
327
- * `null` if no credits field is attached.
328
- */
329
- export async function getCompositionCredits(client, compositionId, compositionCreditsPackageId) {
330
- const content = await fetchCreditsField(client, compositionId, `${compositionCreditsPackageId}::composition_credits::ExtensionKey`, COMPOSITION_CREDITS_KEY_BYTES);
331
- if (!content)
332
- return null;
333
- return creditViews(CompositionCreditsField.parse(content).value.credits, compositionRoleLabel);
334
- }
335
- /**
336
- * Reads a recording's credits plus its primary/featured artist party ids (the
337
- * `recording_credits` extension), or `null` if no credits field is attached.
338
- */
339
- export async function getRecordingCredits(client, recordingId, recordingCreditsPackageId) {
340
- const content = await fetchCreditsField(client, recordingId, `${recordingCreditsPackageId}::recording_credits::ExtensionKey`, RECORDING_CREDITS_KEY_BYTES);
341
- if (!content)
342
- return null;
343
- const value = RecordingCreditsField.parse(content).value;
344
- return {
345
- credits: creditViews(value.credits, recordingRoleLabel),
346
- primaryArtistIds: value.primary_artist_ids.contents,
347
- featuredArtistIds: value.featured_artist_ids.contents,
348
- };
349
- }
350
- /**
351
- * Reads a release's top-line billing credits (the `release_credits` extension), or
352
- * `null` if no credits field is attached. Each credit has exactly one role.
353
- */
354
- export async function getReleaseCredits(client, releaseId, releaseCreditsPackageId) {
355
- const content = await fetchCreditsField(client, releaseId, `${releaseCreditsPackageId}::release_credits::ExtensionKey`, RELEASE_CREDITS_KEY_BYTES);
356
- if (!content)
357
- return null;
358
- return creditViews(ReleaseCreditsField.parse(content).value.credits, releaseRoleLabel);
359
- }
360
- //# sourceMappingURL=credits.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credits.js","sourceRoot":"","sources":["../src/credits.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAwBtC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,kBAAkB,MAAM,wDAAwD,CAAC;AAC7F,OAAO,KAAK,oBAAoB,MAAM,2DAA2D,CAAC;AAClG,OAAO,KAAK,gBAAgB,MAAM,oDAAoD,CAAC;AACvF,OAAO,KAAK,kBAAkB,MAAM,uDAAuD,CAAC;AAC5F,OAAO,KAAK,cAAc,MAAM,gDAAgD,CAAC;AACjF,OAAO,KAAK,gBAAgB,MAAM,mDAAmD,CAAC;AA0EtF,MAAM,qBAAqB,GAAkE;IAC3F,OAAO,EAAE,oBAAoB,CAAC,cAAc;IAC5C,QAAQ,EAAE,oBAAoB,CAAC,eAAe;IAC9C,QAAQ,EAAE,oBAAoB,CAAC,eAAe;IAC9C,QAAQ,EAAE,oBAAoB,CAAC,eAAe;IAC9C,UAAU,EAAE,oBAAoB,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OAAO,IAAI,CAAC;IAC1B,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;IACzD,OAAO;QACL,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;QACvD,gBAAgB,EAAE,KAAK,CAAC,kBAAkB,CAAC,QAAQ;QACnD,iBAAiB,EAAE,KAAK,CAAC,mBAAmB,CAAC,QAAQ;KACtD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAyB,EACzB,SAAiB,EACjB,uBAA+B;IAE/B,MAAM,OAAO,GAAG,MAAM,iBAAiB,CACrC,MAAM,EACN,SAAS,EACT,GAAG,uBAAuB,iCAAiC,EAC3D,yBAAyB,CAC1B,CAAC;IACF,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACzF,CAAC"}
@@ -1,32 +0,0 @@
1
- import type { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
- export interface AttachCompositionRoyaltyPoolParams {
3
- /** The Composition — an in-PTB `createComposition` result, borrowed `&mut`. */
4
- composition: TransactionObjectArgument;
5
- /** The CompositionAdminCap, borrowed `&`. */
6
- adminCap: TransactionObjectArgument;
7
- /** The composition's share type (the pool's `Share` phantom = CompositionShare). */
8
- compositionShareType: string;
9
- /** Fully-qualified coin type the pool accumulates (the `Currency` phantom). */
10
- currency: string;
11
- compositionRoyaltyPoolPackageId: string;
12
- royaltyPoolPackageId: string;
13
- }
14
- /** Creates a royalty pool for a composition and shares it, appending to `tx`. */
15
- export declare function attachCompositionRoyaltyPool(tx: Transaction, params: AttachCompositionRoyaltyPoolParams): void;
16
- export interface AttachRecordingRoyaltyPoolParams {
17
- /** The Recording — an in-PTB `createRecording` result, borrowed `&mut`. */
18
- recording: TransactionObjectArgument;
19
- /** The RecordingAdminCap, borrowed `&`. */
20
- adminCap: TransactionObjectArgument;
21
- /** The recording's own share type (the pool's `Share` phantom = RecordingShare). */
22
- recordingShareType: string;
23
- /** The parent composition's share type (the recording's `CompositionShare` phantom). */
24
- compositionShareType: string;
25
- /** Fully-qualified coin type the pool accumulates (the `Currency` phantom). */
26
- currency: string;
27
- recordingRoyaltyPoolPackageId: string;
28
- royaltyPoolPackageId: string;
29
- }
30
- /** Creates a royalty pool for a recording and shares it, appending to `tx`. */
31
- export declare function attachRecordingRoyaltyPool(tx: Transaction, params: AttachRecordingRoyaltyPoolParams): void;
32
- //# sourceMappingURL=royalty-pool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"royalty-pool.d.ts","sourceRoot":"","sources":["../../src/extensions/royalty-pool.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAKvF,MAAM,WAAW,kCAAkC;IACjD,+EAA+E;IAC/E,WAAW,EAAE,yBAAyB,CAAC;IACvC,6CAA6C;IAC7C,QAAQ,EAAE,yBAAyB,CAAC;IACpC,oFAAoF;IACpF,oBAAoB,EAAE,MAAM,CAAC;IAC7B,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B,EAAE,MAAM,CAAC;IACxC,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,iFAAiF;AACjF,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,kCAAkC,GAAG,IAAI,CAe9G;AAED,MAAM,WAAW,gCAAgC;IAC/C,2EAA2E;IAC3E,SAAS,EAAE,yBAAyB,CAAC;IACrC,2CAA2C;IAC3C,QAAQ,EAAE,yBAAyB,CAAC;IACpC,oFAAoF;IACpF,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wFAAwF;IACxF,oBAAoB,EAAE,MAAM,CAAC;IAC7B,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,6BAA6B,EAAE,MAAM,CAAC;IACtC,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,+EAA+E;AAC/E,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,gCAAgC,GAAG,IAAI,CAgB1G"}
@@ -1,33 +0,0 @@
1
- // Copyright (c) Miso Labs, Inc.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import * as compositionRoyaltyPool from "../contracts/composition_royalty_pool/composition_royalty_pool.js";
4
- import * as recordingRoyaltyPool from "../contracts/recording_royalty_pool/recording_royalty_pool.js";
5
- import * as pool from "../contracts/royalty_pool/pool.js";
6
- /** Creates a royalty pool for a composition and shares it, appending to `tx`. */
7
- export function attachCompositionRoyaltyPool(tx, params) {
8
- const created = tx.add(compositionRoyaltyPool.initializePool({
9
- package: params.compositionRoyaltyPoolPackageId,
10
- typeArguments: [params.compositionShareType, params.currency],
11
- arguments: [params.composition, params.adminCap],
12
- }));
13
- tx.add(pool.share({
14
- package: params.royaltyPoolPackageId,
15
- typeArguments: [params.compositionShareType, params.currency],
16
- arguments: [created],
17
- }));
18
- }
19
- /** Creates a royalty pool for a recording and shares it, appending to `tx`. */
20
- export function attachRecordingRoyaltyPool(tx, params) {
21
- const created = tx.add(recordingRoyaltyPool.initializePool({
22
- package: params.recordingRoyaltyPoolPackageId,
23
- typeArguments: [params.recordingShareType, params.compositionShareType, params.currency],
24
- arguments: [params.recording, params.adminCap],
25
- }));
26
- // The pool is RoyaltyPool<RecordingShare, Currency> — Share is the recording's own share type.
27
- tx.add(pool.share({
28
- package: params.royaltyPoolPackageId,
29
- typeArguments: [params.recordingShareType, params.currency],
30
- arguments: [created],
31
- }));
32
- }
33
- //# sourceMappingURL=royalty-pool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"royalty-pool.js","sourceRoot":"","sources":["../../src/extensions/royalty-pool.ts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ACT,OAAO,EAAE,MAAM,CAAC,oBAAoB;QACpC,aAAa,EAAE,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC;QAC3D,SAAS,EAAE,CAAC,OAAO,CAAC;KACrB,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -1,169 +0,0 @@
1
- /**************************************************************
2
- * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
- **************************************************************/
4
-
5
-
6
- /**
7
- * First-party credits extension for compositions.
8
- *
9
- * Attribution (writing credits) is display-oriented and varies across platforms,
10
- * so it lives here as a dynamic field on the composition rather than in immutable
11
- * core. The data is attached under `ExtensionKey()` via the composition's
12
- * cap-gated `uid_mut`, so every mutation is authorized by the composition's admin
13
- * and credits survive into any lifecycle state (they may be attached before or
14
- * after the composition is published).
15
- *
16
- * This is Miso's canonical credits standard; because it is an extension, other
17
- * parties may publish their own composition-credits standard against the same
18
- * `Composition`. Credits are NOT read by the economics — they are attribution.
19
- */
20
-
21
- import { MoveTuple, MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
22
- import { bcs } from '@mysten/sui/bcs';
23
- import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
24
- import * as vec_map from './deps/sui/vec_map.js';
25
- import * as credit from './deps/miso_credit/credit.js';
26
- import * as composition_party_role from './composition_party_role.js';
27
- const $moduleName = '@local-pkg/composition_credits::composition_credits';
28
- export const ExtensionKey = new MoveTuple({ name: `${$moduleName}::ExtensionKey`, fields: [bcs.bool()] });
29
- export const CompositionCredits = new MoveStruct({ name: `${$moduleName}::CompositionCredits`, fields: {
30
- /** Map of party IDs to their credit (display name + roles). */
31
- credits: vec_map.VecMap(bcs.Address, credit.Credit(composition_party_role.CompositionPartyRole))
32
- } });
33
- export const CreditAddedEvent = new MoveStruct({ name: `${$moduleName}::CreditAddedEvent`, fields: {
34
- composition_id: bcs.Address,
35
- party_id: bcs.Address,
36
- credit: credit.Credit(composition_party_role.CompositionPartyRole)
37
- } });
38
- export const CreditRemovedEvent = new MoveStruct({ name: `${$moduleName}::CreditRemovedEvent`, fields: {
39
- composition_id: bcs.Address,
40
- party_id: bcs.Address,
41
- credit: credit.Credit(composition_party_role.CompositionPartyRole)
42
- } });
43
- export interface AddCreditArguments {
44
- self: RawTransactionArgument<string>;
45
- cap: RawTransactionArgument<string>;
46
- party: RawTransactionArgument<string>;
47
- credit: TransactionArgument;
48
- }
49
- export interface AddCreditOptions {
50
- package?: string;
51
- arguments: AddCreditArguments | [
52
- self: RawTransactionArgument<string>,
53
- cap: RawTransactionArgument<string>,
54
- party: RawTransactionArgument<string>,
55
- credit: TransactionArgument
56
- ];
57
- typeArguments: [
58
- string
59
- ];
60
- }
61
- /**
62
- * Adds a credit for a party on the composition, lazily creating the credits record
63
- * on first use. Each credit must have 1-5 roles, and a party may hold at most one
64
- * credit. Requires the composition's admin capability.
65
- */
66
- export function addCredit(options: AddCreditOptions) {
67
- const packageAddress = options.package ?? '@local-pkg/composition_credits';
68
- const argumentsTypes = [
69
- null,
70
- null,
71
- null,
72
- null
73
- ] satisfies (string | null)[];
74
- const parameterNames = ["self", "cap", "party", "credit"];
75
- return (tx: Transaction) => tx.moveCall({
76
- package: packageAddress,
77
- module: 'composition_credits',
78
- function: 'add_credit',
79
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
80
- typeArguments: options.typeArguments
81
- });
82
- }
83
- export interface RemoveCreditArguments {
84
- self: RawTransactionArgument<string>;
85
- cap: RawTransactionArgument<string>;
86
- partyId: RawTransactionArgument<string>;
87
- }
88
- export interface RemoveCreditOptions {
89
- package?: string;
90
- arguments: RemoveCreditArguments | [
91
- self: RawTransactionArgument<string>,
92
- cap: RawTransactionArgument<string>,
93
- partyId: RawTransactionArgument<string>
94
- ];
95
- typeArguments: [
96
- string
97
- ];
98
- }
99
- /** Removes a party's credit. Requires the composition's admin capability. */
100
- export function removeCredit(options: RemoveCreditOptions) {
101
- const packageAddress = options.package ?? '@local-pkg/composition_credits';
102
- const argumentsTypes = [
103
- null,
104
- null,
105
- '0x2::object::ID'
106
- ] satisfies (string | null)[];
107
- const parameterNames = ["self", "cap", "partyId"];
108
- return (tx: Transaction) => tx.moveCall({
109
- package: packageAddress,
110
- module: 'composition_credits',
111
- function: 'remove_credit',
112
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
113
- typeArguments: options.typeArguments
114
- });
115
- }
116
- export interface HasCreditsArguments {
117
- self: RawTransactionArgument<string>;
118
- }
119
- export interface HasCreditsOptions {
120
- package?: string;
121
- arguments: HasCreditsArguments | [
122
- self: RawTransactionArgument<string>
123
- ];
124
- typeArguments: [
125
- string
126
- ];
127
- }
128
- /** Returns whether a credits record has been attached to this composition yet. */
129
- export function hasCredits(options: HasCreditsOptions) {
130
- const packageAddress = options.package ?? '@local-pkg/composition_credits';
131
- const argumentsTypes = [
132
- null
133
- ] satisfies (string | null)[];
134
- const parameterNames = ["self"];
135
- return (tx: Transaction) => tx.moveCall({
136
- package: packageAddress,
137
- module: 'composition_credits',
138
- function: 'has_credits',
139
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
140
- typeArguments: options.typeArguments
141
- });
142
- }
143
- export interface CreditsArguments {
144
- self: RawTransactionArgument<string>;
145
- }
146
- export interface CreditsOptions {
147
- package?: string;
148
- arguments: CreditsArguments | [
149
- self: RawTransactionArgument<string>
150
- ];
151
- typeArguments: [
152
- string
153
- ];
154
- }
155
- /** Returns the party-to-credit map. Aborts if no credits are attached. */
156
- export function credits(options: CreditsOptions) {
157
- const packageAddress = options.package ?? '@local-pkg/composition_credits';
158
- const argumentsTypes = [
159
- null
160
- ] satisfies (string | null)[];
161
- const parameterNames = ["self"];
162
- return (tx: Transaction) => tx.moveCall({
163
- package: packageAddress,
164
- module: 'composition_credits',
165
- function: 'credits',
166
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
167
- typeArguments: options.typeArguments
168
- });
169
- }