@arcadiasystems/morse-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/LICENSE +21 -0
- package/README.md +404 -0
- package/dist/clients.d.ts +12 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +6 -0
- package/dist/clients.js.map +1 -0
- package/dist/codecs.d.ts +45 -0
- package/dist/codecs.d.ts.map +1 -0
- package/dist/codecs.js +132 -0
- package/dist/codecs.js.map +1 -0
- package/dist/compatibility.d.ts +22 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +22 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/config.d.ts +92 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +85 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +101 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +214 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/ops/cap.d.ts +79 -0
- package/dist/ops/cap.d.ts.map +1 -0
- package/dist/ops/cap.js +104 -0
- package/dist/ops/cap.js.map +1 -0
- package/dist/ops/collection.d.ts +50 -0
- package/dist/ops/collection.d.ts.map +1 -0
- package/dist/ops/collection.js +55 -0
- package/dist/ops/collection.js.map +1 -0
- package/dist/ops/entry-from-bytes.d.ts +129 -0
- package/dist/ops/entry-from-bytes.d.ts.map +1 -0
- package/dist/ops/entry-from-bytes.js +137 -0
- package/dist/ops/entry-from-bytes.js.map +1 -0
- package/dist/ops/entry.d.ts +173 -0
- package/dist/ops/entry.d.ts.map +1 -0
- package/dist/ops/entry.js +235 -0
- package/dist/ops/entry.js.map +1 -0
- package/dist/ops/index.d.ts +9 -0
- package/dist/ops/index.d.ts.map +1 -0
- package/dist/ops/index.js +9 -0
- package/dist/ops/index.js.map +1 -0
- package/dist/ops/internal.d.ts +21 -0
- package/dist/ops/internal.d.ts.map +1 -0
- package/dist/ops/internal.js +42 -0
- package/dist/ops/internal.js.map +1 -0
- package/dist/ops/publication.d.ts +74 -0
- package/dist/ops/publication.d.ts.map +1 -0
- package/dist/ops/publication.js +123 -0
- package/dist/ops/publication.js.map +1 -0
- package/dist/ptb/cap.d.ts +36 -0
- package/dist/ptb/cap.d.ts.map +1 -0
- package/dist/ptb/cap.js +44 -0
- package/dist/ptb/cap.js.map +1 -0
- package/dist/ptb/collection.d.ts +27 -0
- package/dist/ptb/collection.d.ts.map +1 -0
- package/dist/ptb/collection.js +33 -0
- package/dist/ptb/collection.js.map +1 -0
- package/dist/ptb/entry.d.ts +104 -0
- package/dist/ptb/entry.d.ts.map +1 -0
- package/dist/ptb/entry.js +155 -0
- package/dist/ptb/entry.js.map +1 -0
- package/dist/ptb/index.d.ts +9 -0
- package/dist/ptb/index.d.ts.map +1 -0
- package/dist/ptb/index.js +9 -0
- package/dist/ptb/index.js.map +1 -0
- package/dist/ptb/internal.d.ts +11 -0
- package/dist/ptb/internal.d.ts.map +1 -0
- package/dist/ptb/internal.js +12 -0
- package/dist/ptb/internal.js.map +1 -0
- package/dist/ptb/publication.d.ts +51 -0
- package/dist/ptb/publication.d.ts.map +1 -0
- package/dist/ptb/publication.js +61 -0
- package/dist/ptb/publication.js.map +1 -0
- package/dist/read/entry-bcs.d.ts +47 -0
- package/dist/read/entry-bcs.d.ts.map +1 -0
- package/dist/read/entry-bcs.js +36 -0
- package/dist/read/entry-bcs.js.map +1 -0
- package/dist/read/index.d.ts +5 -0
- package/dist/read/index.d.ts.map +1 -0
- package/dist/read/index.js +5 -0
- package/dist/read/index.js.map +1 -0
- package/dist/read/reader.d.ts +148 -0
- package/dist/read/reader.d.ts.map +1 -0
- package/dist/read/reader.js +403 -0
- package/dist/read/reader.js.map +1 -0
- package/dist/seal/adapter.d.ts +56 -0
- package/dist/seal/adapter.d.ts.map +1 -0
- package/dist/seal/adapter.js +7 -0
- package/dist/seal/adapter.js.map +1 -0
- package/dist/seal/default-adapter.d.ts +90 -0
- package/dist/seal/default-adapter.d.ts.map +1 -0
- package/dist/seal/default-adapter.js +187 -0
- package/dist/seal/default-adapter.js.map +1 -0
- package/dist/seal/identity.d.ts +31 -0
- package/dist/seal/identity.d.ts.map +1 -0
- package/dist/seal/identity.js +79 -0
- package/dist/seal/identity.js.map +1 -0
- package/dist/seal/index.d.ts +8 -0
- package/dist/seal/index.d.ts.map +1 -0
- package/dist/seal/index.js +7 -0
- package/dist/seal/index.js.map +1 -0
- package/dist/types.d.ts +160 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +33 -0
- package/dist/types.js.map +1 -0
- package/dist/wallets/adapter.d.ts +34 -0
- package/dist/wallets/adapter.d.ts.map +1 -0
- package/dist/wallets/adapter.js +6 -0
- package/dist/wallets/adapter.js.map +1 -0
- package/dist/wallets/index.d.ts +7 -0
- package/dist/wallets/index.d.ts.map +1 -0
- package/dist/wallets/index.js +6 -0
- package/dist/wallets/index.js.map +1 -0
- package/dist/wallets/keypair-adapter.d.ts +31 -0
- package/dist/wallets/keypair-adapter.d.ts.map +1 -0
- package/dist/wallets/keypair-adapter.js +210 -0
- package/dist/wallets/keypair-adapter.js.map +1 -0
- package/dist/wallets/wallet-standard-signer.d.ts +118 -0
- package/dist/wallets/wallet-standard-signer.d.ts.map +1 -0
- package/dist/wallets/wallet-standard-signer.js +207 -0
- package/dist/wallets/wallet-standard-signer.js.map +1 -0
- package/dist/walrus/adapter.d.ts +91 -0
- package/dist/walrus/adapter.d.ts.map +1 -0
- package/dist/walrus/adapter.js +11 -0
- package/dist/walrus/adapter.js.map +1 -0
- package/dist/walrus/default-adapter.d.ts +104 -0
- package/dist/walrus/default-adapter.d.ts.map +1 -0
- package/dist/walrus/default-adapter.js +146 -0
- package/dist/walrus/default-adapter.js.map +1 -0
- package/dist/walrus/default-read-adapter.d.ts +89 -0
- package/dist/walrus/default-read-adapter.d.ts.map +1 -0
- package/dist/walrus/default-read-adapter.js +81 -0
- package/dist/walrus/default-read-adapter.js.map +1 -0
- package/dist/walrus/http-aggregator-read-adapter.d.ts +107 -0
- package/dist/walrus/http-aggregator-read-adapter.d.ts.map +1 -0
- package/dist/walrus/http-aggregator-read-adapter.js +174 -0
- package/dist/walrus/http-aggregator-read-adapter.js.map +1 -0
- package/dist/walrus/http-publisher-write-adapter.d.ts +97 -0
- package/dist/walrus/http-publisher-write-adapter.d.ts.map +1 -0
- package/dist/walrus/http-publisher-write-adapter.js +249 -0
- package/dist/walrus/http-publisher-write-adapter.js.map +1 -0
- package/dist/walrus/index.d.ts +11 -0
- package/dist/walrus/index.d.ts.map +1 -0
- package/dist/walrus/index.js +11 -0
- package/dist/walrus/index.js.map +1 -0
- package/dist/walrus/quilt-patch-id.d.ts +34 -0
- package/dist/walrus/quilt-patch-id.d.ts.map +1 -0
- package/dist/walrus/quilt-patch-id.js +103 -0
- package/dist/walrus/quilt-patch-id.js.map +1 -0
- package/package.json +72 -0
package/dist/errors.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error hierarchy. All errors extend `MorseError`; narrow subclasses via `instanceof`.
|
|
3
|
+
*/
|
|
4
|
+
// Base
|
|
5
|
+
/** Abstract base for every error thrown by the SDK. */
|
|
6
|
+
export class MorseError extends Error {
|
|
7
|
+
constructor(message, options) {
|
|
8
|
+
super(message, options);
|
|
9
|
+
this.name = new.target.name;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
// Validation
|
|
13
|
+
/** Client-side precondition failed (malformed ID, invalid enum, etc). */
|
|
14
|
+
export class ValidationError extends MorseError {
|
|
15
|
+
/** Name of the field or parameter that failed validation. */
|
|
16
|
+
field;
|
|
17
|
+
constructor(message, field, options) {
|
|
18
|
+
super(message, options);
|
|
19
|
+
this.field = field;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Resource not found on-chain. */
|
|
23
|
+
export class NotFoundError extends MorseError {
|
|
24
|
+
resource;
|
|
25
|
+
identifier;
|
|
26
|
+
constructor(resource, identifier, options) {
|
|
27
|
+
super(`${resource} not found: ${identifier}`, options);
|
|
28
|
+
this.resource = resource;
|
|
29
|
+
this.identifier = identifier;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Unauthorized
|
|
33
|
+
/** Authorization check failed client-side, before the transaction was submitted. */
|
|
34
|
+
export class UnauthorizedError extends MorseError {
|
|
35
|
+
}
|
|
36
|
+
// Transport
|
|
37
|
+
/** RPC transport, network, or response-parsing failure. Distinct from contract aborts. */
|
|
38
|
+
export class TransportError extends MorseError {
|
|
39
|
+
}
|
|
40
|
+
// Configuration
|
|
41
|
+
/** SDK configuration gap (e.g. asking for a network with no canonical deployment). */
|
|
42
|
+
export class ConfigurationError extends MorseError {
|
|
43
|
+
}
|
|
44
|
+
// Uncertified blob
|
|
45
|
+
/**
|
|
46
|
+
* Thrown by `addEntryFromBytes` / `addEncryptedEntryFromBytes` when the
|
|
47
|
+
* register-and-upload step succeeded (the user already paid for storage and
|
|
48
|
+
* the bytes are on Walrus storage nodes) but the combined `certify_blob +
|
|
49
|
+
* add_entry` transaction failed (rejected popup, contract abort, network
|
|
50
|
+
* blip). The blob exists on Sui as an uncertified `Blob` object that is
|
|
51
|
+
* holding storage until either the consumer certifies it or the storage
|
|
52
|
+
* registration expires.
|
|
53
|
+
*
|
|
54
|
+
* Carries `blobObjectId` and `blobId` so the consumer can surface them to the
|
|
55
|
+
* user (e.g. "your upload was wasted; here is the blob id for support") or
|
|
56
|
+
* retry the flow with fresh bytes. The original failure is preserved as
|
|
57
|
+
* `cause`.
|
|
58
|
+
*/
|
|
59
|
+
export class UncertifiedBlobError extends MorseError {
|
|
60
|
+
blobObjectId;
|
|
61
|
+
blobId;
|
|
62
|
+
constructor(blobObjectId, blobId, options) {
|
|
63
|
+
super(`Walrus blob ${blobObjectId} was registered and uploaded but the certify+addEntry transaction failed; the blob is on storage nodes but uncertified. Retry the full flow with fresh bytes, or wait for the storage registration to expire.`, options);
|
|
64
|
+
this.blobObjectId = blobObjectId;
|
|
65
|
+
this.blobId = blobId;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Seal encryption or decryption failed for a content reason (not transport).
|
|
70
|
+
* Use this to distinguish authorization gaps (`no-access`) from network
|
|
71
|
+
* blips (`TransportError`).
|
|
72
|
+
*/
|
|
73
|
+
export class SealError extends MorseError {
|
|
74
|
+
code;
|
|
75
|
+
constructor(code, message, options) {
|
|
76
|
+
super(message, options);
|
|
77
|
+
this.code = code;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Move abort codes mirrored from `morse-contracts`. Structure: `ABORT_CODES[module][code]`.
|
|
82
|
+
* New abort constants in the Move package must be added here, or they surface as `UnknownAbort`.
|
|
83
|
+
*/
|
|
84
|
+
export const ABORT_CODES = {
|
|
85
|
+
publication: {
|
|
86
|
+
0: {
|
|
87
|
+
name: "ECollectionAlreadyExists",
|
|
88
|
+
description: "A collection with this name already exists in the publication.",
|
|
89
|
+
},
|
|
90
|
+
2: {
|
|
91
|
+
name: "EUnauthorized",
|
|
92
|
+
description: "The capability does not belong to this publication.",
|
|
93
|
+
},
|
|
94
|
+
4: {
|
|
95
|
+
name: "EPublisherCapWrongHolder",
|
|
96
|
+
description: "The sender is not the approved holder for this PublisherCap.",
|
|
97
|
+
},
|
|
98
|
+
5: {
|
|
99
|
+
name: "EPublisherCapRevoked",
|
|
100
|
+
description: "The PublisherCap has been revoked and can no longer be used.",
|
|
101
|
+
},
|
|
102
|
+
6: {
|
|
103
|
+
name: "ESlugAlreadyExists",
|
|
104
|
+
description: "A publication with this slug already exists.",
|
|
105
|
+
},
|
|
106
|
+
7: {
|
|
107
|
+
name: "ESlugEmpty",
|
|
108
|
+
description: "Slug cannot be empty.",
|
|
109
|
+
},
|
|
110
|
+
8: {
|
|
111
|
+
name: "ESlugTooLong",
|
|
112
|
+
description: "Slug exceeds the maximum allowed length.",
|
|
113
|
+
},
|
|
114
|
+
9: {
|
|
115
|
+
name: "ESlugInvalidChar",
|
|
116
|
+
description: "Slug contains characters outside the allowed set (lowercase alphanumeric and hyphen).",
|
|
117
|
+
},
|
|
118
|
+
10: {
|
|
119
|
+
name: "ESlugInvalidEdgeHyphen",
|
|
120
|
+
description: "Slug must not start or end with a hyphen.",
|
|
121
|
+
},
|
|
122
|
+
12: {
|
|
123
|
+
name: "ESealInvalidId",
|
|
124
|
+
description: "Provided Seal identity does not match this publication namespace.",
|
|
125
|
+
},
|
|
126
|
+
13: {
|
|
127
|
+
name: "ESealWrongPolicyTag",
|
|
128
|
+
description: "Provided Seal identity has an unsupported policy tag.",
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
collection: {
|
|
132
|
+
0: {
|
|
133
|
+
name: "EEntryNotFound",
|
|
134
|
+
description: "No entry exists for the requested entry_id.",
|
|
135
|
+
},
|
|
136
|
+
1: {
|
|
137
|
+
name: "EInvalidStorageMode",
|
|
138
|
+
description: "Storage mode must be STORAGE_MODE_BLOB (0) or STORAGE_MODE_QUILT (1).",
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
entry: {
|
|
142
|
+
0: {
|
|
143
|
+
name: "ENameEmpty",
|
|
144
|
+
description: "Entry name cannot be empty.",
|
|
145
|
+
},
|
|
146
|
+
1: {
|
|
147
|
+
name: "EContentTypeEmpty",
|
|
148
|
+
description: "Content type cannot be empty.",
|
|
149
|
+
},
|
|
150
|
+
2: {
|
|
151
|
+
name: "ENameTooLong",
|
|
152
|
+
description: "Entry name exceeds the maximum allowed length.",
|
|
153
|
+
},
|
|
154
|
+
3: {
|
|
155
|
+
name: "EContentTypeTooLong",
|
|
156
|
+
description: "Content type exceeds the maximum allowed length.",
|
|
157
|
+
},
|
|
158
|
+
4: {
|
|
159
|
+
name: "ERevisionNotFound",
|
|
160
|
+
description: "Requested revision does not exist.",
|
|
161
|
+
},
|
|
162
|
+
5: {
|
|
163
|
+
name: "EInvalidAccessPolicy",
|
|
164
|
+
description: "Access policy is not valid for the selected encryption mode.",
|
|
165
|
+
},
|
|
166
|
+
6: {
|
|
167
|
+
name: "ESealIdRequired",
|
|
168
|
+
description: "Encrypted revisions require a Seal identity.",
|
|
169
|
+
},
|
|
170
|
+
7: {
|
|
171
|
+
name: "ESealIdNotAllowed",
|
|
172
|
+
description: "Unencrypted revisions must not include a Seal identity.",
|
|
173
|
+
},
|
|
174
|
+
8: {
|
|
175
|
+
name: "EBlobNotDeletable",
|
|
176
|
+
description: "Blob must be deletable; non-deletable blobs are rejected by platform policy.",
|
|
177
|
+
},
|
|
178
|
+
9: {
|
|
179
|
+
name: "EQuiltPatchIdRequired",
|
|
180
|
+
description: "Quilt-mode collections require a QuiltPatchId on every revision.",
|
|
181
|
+
},
|
|
182
|
+
10: {
|
|
183
|
+
name: "EQuiltPatchIdNotAllowed",
|
|
184
|
+
description: "Blob-mode collections must not include a QuiltPatchId.",
|
|
185
|
+
},
|
|
186
|
+
11: {
|
|
187
|
+
name: "EInvalidQuiltPatchId",
|
|
188
|
+
description: "QuiltPatchId must be exactly 37 bytes (quilt_blob_id || version || start_index || end_index).",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
/** Reason value used when a Move abort code is not in the SDK's table. */
|
|
193
|
+
export const UNKNOWN_ABORT_NAME = "UnknownAbort";
|
|
194
|
+
/** Move VM aborted during transaction execution. Narrow on `reason` (e.g. "EPublisherCapRevoked"). */
|
|
195
|
+
export class ContractAbortError extends MorseError {
|
|
196
|
+
module;
|
|
197
|
+
abortCode;
|
|
198
|
+
reason;
|
|
199
|
+
constructor(module, abortCode, reason, message, options) {
|
|
200
|
+
super(message, options);
|
|
201
|
+
this.module = module;
|
|
202
|
+
this.abortCode = abortCode;
|
|
203
|
+
this.reason = reason;
|
|
204
|
+
}
|
|
205
|
+
/** Build an error by looking up `(module, abortCode)` in the abort-code table. */
|
|
206
|
+
static fromAbortCode(module, abortCode, options) {
|
|
207
|
+
const entry = ABORT_CODES[module][abortCode];
|
|
208
|
+
if (entry === undefined) {
|
|
209
|
+
return new ContractAbortError(module, abortCode, UNKNOWN_ABORT_NAME, `Contract aborted in ${module} with unknown code ${abortCode}. The deployed package may be newer than this SDK.`, options);
|
|
210
|
+
}
|
|
211
|
+
return new ContractAbortError(module, abortCode, entry.name, `Contract aborted: ${module}::${entry.name} (code ${abortCode}). ${entry.description}`, options);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO;AAEP,uDAAuD;AACvD,MAAM,OAAgB,UAAW,SAAQ,KAAK;IAC7C,YAAY,OAAe,EAAE,OAA6B;QACzD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC7B,CAAC;CACD;AAED,aAAa;AAEb,yEAAyE;AACzE,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC9C,6DAA6D;IACpD,KAAK,CAAS;IAEvB,YAAY,OAAe,EAAE,KAAa,EAAE,OAA6B;QACxE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;CACD;AAcD,mCAAmC;AACnC,MAAM,OAAO,aAAc,SAAQ,UAAU;IACnC,QAAQ,CAAmB;IAC3B,UAAU,CAAS;IAE5B,YACC,QAA0B,EAC1B,UAAkB,EAClB,OAA6B;QAE7B,KAAK,CAAC,GAAG,QAAQ,eAAe,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,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,MAAM,KAAK,CAAC,WAAW,EAAE,EACtF,OAAO,CACP,CAAC;IACH,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for morse-sdk.
|
|
3
|
+
*/
|
|
4
|
+
export type { ObjectReader, TransactionExecutor } from "./clients.js";
|
|
5
|
+
export { accessPolicyFromU8, accessPolicyToU8, storageModeFromU8, storageModeToU8, toBlobObjectId, toOwnerCapId, toPackageId, toPublicationId, toPublisherCapId, toQuiltPatchId, toRegistryId, toSuiAddress, toSuiObjectId, toWalrusBlobId, } from "./codecs.js";
|
|
6
|
+
export { TESTED_SUBSTRATE } from "./compatibility.js";
|
|
7
|
+
export { DEFAULT_RPC_URLS, type MorseConfigOptions, type MorsePackageConfig, morseConfig, Network, type NetworkConfig, type WalrusEndpoints, } from "./config.js";
|
|
8
|
+
export { ABORT_CODES, type AbortEntry, type AbortModule, ConfigurationError, ContractAbortError, MorseError, NotFoundError, type NotFoundResource, SealError, type SealErrorCode, TransportError, UNKNOWN_ABORT_NAME, UnauthorizedError, UncertifiedBlobError, ValidationError, } from "./errors.js";
|
|
9
|
+
export { type AddEncryptedEntryArgs, type AddEncryptedEntryFromBytesArgs, type AddEntryArgs, type AddEntryFromBytesArgs, type AddEntryFromBytesResult, type AddEntryResult, type AppendDraftRevisionArgs, type AppendEncryptedDraftRevisionArgs, addEncryptedEntry, addEncryptedEntryFromBytes, addEntry, addEntryFromBytes, appendDraftRevision, appendEncryptedDraftRevision, type CreateCollectionArgs, type CreateCollectionResult, type CreatePublicationArgs, type CreatePublicationResult, createCollection, createPublication, type DeleteCollectionArgs, type DeleteCollectionResult, type DeleteEntryArgs, type DeleteEntryResult, type DeletePublicationArgs, type DeletePublicationResult, type DestroyPublisherCapArgs, type DestroyPublisherCapResult, deleteCollection, deleteEntry, deletePublication, destroyPublisherCap, type IssuePublisherCapArgs, type IssuePublisherCapResult, issuePublisherCap, type ProgressCallback, type ProgressEvent, type PublicationConfig, type PublishDirectArgs, type PublishFromDraftArgs, publishDirect, publishFromDraft, type RevisionAppendResult, type RevokePublisherCapArgs, type RevokePublisherCapResult, revokePublisherCap, type TransferOwnershipArgs, type TransferOwnershipResult, type TransferPublisherCapArgs, type TransferPublisherCapResult, transferOwnership, transferPublisherCap, } from "./ops/index.js";
|
|
10
|
+
export { type EntryListPage, type ListEntriesOptions, type ListPublicationsOptions, type ListPublisherCapsOptions, type OwnedPublication, type PublicationListPage, type PublicationReader, type PublisherCapListPage, RpcPublicationReader, type ScanEntriesOptions, } from "./read/index.js";
|
|
11
|
+
export { buildPublisherSealId, DefaultSealAdapter, decodePublisherSealId, type SealAdapter, type SealAdapterConfig, type SealDecryptOptions, type SealEncryptOptions, type SealEncryptResult, type SealIdParts, } from "./seal/index.js";
|
|
12
|
+
export { AccessPolicy, type BlobObjectId, type BlobRef, type Collection, type Entry, type OwnerCap, type OwnerCapId, type PackageId, type Publication, type PublicationId, type PublisherCap, type PublisherCapId, QUILT_PATCH_ID_LENGTH, type QuiltPatchId, type RegistryId, type Revision, type SealId, SealPolicyTag, StorageMode, type SuiAddress, type SuiObjectId, type TxCreatedObject, type TxDeletedObject, type TxReceipt, type WalrusBlobId, } from "./types.js";
|
|
13
|
+
export { KeypairAdapter, type SimulationReturnValues, type WalletAdapter, type WalletSignPersonalMessage, type WalletSignTransaction, type WalletStandardAccount, WalletStandardSigner, type WalletStandardSignerCallbacks, type WalletStandardSignerOptions, } from "./wallets/index.js";
|
|
14
|
+
export { DefaultWalrusReadAdapter, DefaultWalrusWriteAdapter, type DefaultWalrusWriteAdapterOptions, decodeQuiltPatchId, encodeQuiltPatchId, HttpAggregatorReadAdapter, type HttpAggregatorReadAdapterOptions, HttpPublisherWriteAdapter, type HttpPublisherWriteAdapterOptions, isWalrusFlowCapable, type ParsePublisherResponse, type QuiltPatchIdParts, type QuiltPatchInput, quiltPatchIdFromString, quiltPatchIdToString, type StartBlobUploadResult, type UploadBlobOptions, type UploadBlobResult, type UploadQuiltOptions, type UploadQuiltPatch, type UploadQuiltResult, type WalrusAdapterConfig, type WalrusBlobIntegrityCheck, type WalrusFlowCapable, type WalrusReadAdapter, type WalrusReadAdapterConfig, type WalrusReadOptions, type WalrusUploadCommonOptions, type WalrusWriteAdapter, } from "./walrus/index.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACN,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,WAAW,EACX,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,WAAW,EACX,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,KAAK,gBAAgB,EACrB,SAAS,EACT,KAAK,aAAa,EAClB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,gCA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,KAAK,kBAAkB,GACvB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for morse-sdk.
|
|
3
|
+
*/
|
|
4
|
+
export { accessPolicyFromU8, accessPolicyToU8, storageModeFromU8, storageModeToU8, toBlobObjectId, toOwnerCapId, toPackageId, toPublicationId, toPublisherCapId, toQuiltPatchId, toRegistryId, toSuiAddress, toSuiObjectId, toWalrusBlobId, } from "./codecs.js";
|
|
5
|
+
export { TESTED_SUBSTRATE } from "./compatibility.js";
|
|
6
|
+
export { DEFAULT_RPC_URLS, morseConfig, Network, } from "./config.js";
|
|
7
|
+
export { ABORT_CODES, ConfigurationError, ContractAbortError, MorseError, NotFoundError, SealError, TransportError, UNKNOWN_ABORT_NAME, UnauthorizedError, UncertifiedBlobError, ValidationError, } from "./errors.js";
|
|
8
|
+
export { addEncryptedEntry, addEncryptedEntryFromBytes, addEntry, addEntryFromBytes, appendDraftRevision, appendEncryptedDraftRevision, createCollection, createPublication, deleteCollection, deleteEntry, deletePublication, destroyPublisherCap, issuePublisherCap, publishDirect, publishFromDraft, revokePublisherCap, transferOwnership, transferPublisherCap, } from "./ops/index.js";
|
|
9
|
+
export { RpcPublicationReader, } from "./read/index.js";
|
|
10
|
+
export { buildPublisherSealId, DefaultSealAdapter, decodePublisherSealId, } from "./seal/index.js";
|
|
11
|
+
export { AccessPolicy, QUILT_PATCH_ID_LENGTH, SealPolicyTag, StorageMode, } from "./types.js";
|
|
12
|
+
export { KeypairAdapter, WalletStandardSigner, } from "./wallets/index.js";
|
|
13
|
+
export { DefaultWalrusReadAdapter, DefaultWalrusWriteAdapter, decodeQuiltPatchId, encodeQuiltPatchId, HttpAggregatorReadAdapter, HttpPublisherWriteAdapter, isWalrusFlowCapable, quiltPatchIdFromString, quiltPatchIdToString, } from "./walrus/index.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACN,gBAAgB,EAGhB,WAAW,EACX,OAAO,GAGP,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,WAAW,EAGX,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,aAAa,EAEb,SAAS,EAET,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EASN,iBAAiB,EACjB,0BAA0B,EAC1B,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAK5B,gBAAgB,EAChB,iBAAiB,EASjB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EAGnB,iBAAiB,EAMjB,aAAa,EACb,gBAAgB,EAIhB,kBAAkB,EAKlB,iBAAiB,EACjB,oBAAoB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EASN,oBAAoB,GAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,GAOrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,YAAY,EAYZ,qBAAqB,EAKrB,aAAa,EACb,WAAW,GAOX,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,cAAc,EAMd,oBAAoB,GAGpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EAEzB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EAEzB,yBAAyB,EAEzB,mBAAmB,EAInB,sBAAsB,EACtB,oBAAoB,GAepB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level PublisherCap lifecycle ops: issue, revoke, destroy.
|
|
3
|
+
*/
|
|
4
|
+
import type { MorsePackageConfig } from "../config.js";
|
|
5
|
+
import type { OwnerCapId, PublicationId, PublisherCapId, SuiAddress } from "../types.js";
|
|
6
|
+
import type { WalletAdapter } from "../wallets/adapter.js";
|
|
7
|
+
export interface IssuePublisherCapArgs {
|
|
8
|
+
readonly publicationId: PublicationId;
|
|
9
|
+
readonly ownerCapId: OwnerCapId;
|
|
10
|
+
readonly holder: SuiAddress;
|
|
11
|
+
readonly signal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
export interface IssuePublisherCapResult {
|
|
14
|
+
readonly digest: string;
|
|
15
|
+
readonly gasUsedMist: bigint;
|
|
16
|
+
readonly publisherCapId: PublisherCapId;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Issue a new PublisherCap and atomically transfer it to its bound `holder`
|
|
20
|
+
* inside the same PTB. The cap is bound to `holder` for write-permission
|
|
21
|
+
* checks regardless of where the object lives.
|
|
22
|
+
* @throws {ContractAbortError} On Move abort (e.g. ownerCap mismatch).
|
|
23
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
24
|
+
*/
|
|
25
|
+
export declare function issuePublisherCap(adapter: WalletAdapter, config: MorsePackageConfig, args: IssuePublisherCapArgs): Promise<IssuePublisherCapResult>;
|
|
26
|
+
export interface RevokePublisherCapArgs {
|
|
27
|
+
readonly publicationId: PublicationId;
|
|
28
|
+
readonly ownerCapId: OwnerCapId;
|
|
29
|
+
readonly publisherCapId: PublisherCapId;
|
|
30
|
+
readonly signal?: AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
export interface RevokePublisherCapResult {
|
|
33
|
+
readonly digest: string;
|
|
34
|
+
readonly gasUsedMist: bigint;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Revoke a PublisherCap. Adds the cap ID to the publication's denylist; future
|
|
38
|
+
* write operations using that cap will abort with `EPublisherCapRevoked`.
|
|
39
|
+
* @throws {ContractAbortError} On Move abort (e.g. cap already revoked).
|
|
40
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
41
|
+
*/
|
|
42
|
+
export declare function revokePublisherCap(adapter: WalletAdapter, config: MorsePackageConfig, args: RevokePublisherCapArgs): Promise<RevokePublisherCapResult>;
|
|
43
|
+
export interface DestroyPublisherCapArgs {
|
|
44
|
+
readonly publicationId: PublicationId;
|
|
45
|
+
readonly publisherCapId: PublisherCapId;
|
|
46
|
+
readonly signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
export interface DestroyPublisherCapResult {
|
|
49
|
+
readonly digest: string;
|
|
50
|
+
readonly gasUsedMist: bigint;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Destroy a PublisherCap. Cleans the denylist entry if the cap was previously
|
|
54
|
+
* revoked. The Move layer enforces that `ctx.sender()` matches the cap's
|
|
55
|
+
* bound `holder`; call `reader.getPublisherCap` first if you want to validate
|
|
56
|
+
* before spending gas.
|
|
57
|
+
* @throws {ContractAbortError} On Move abort (e.g. wrong holder).
|
|
58
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
59
|
+
*/
|
|
60
|
+
export declare function destroyPublisherCap(adapter: WalletAdapter, config: MorsePackageConfig, args: DestroyPublisherCapArgs): Promise<DestroyPublisherCapResult>;
|
|
61
|
+
export interface TransferPublisherCapArgs {
|
|
62
|
+
readonly publisherCapId: PublisherCapId;
|
|
63
|
+
readonly recipient: SuiAddress;
|
|
64
|
+
readonly signal?: AbortSignal;
|
|
65
|
+
}
|
|
66
|
+
export interface TransferPublisherCapResult {
|
|
67
|
+
readonly digest: string;
|
|
68
|
+
readonly gasUsedMist: bigint;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Transfer a PublisherCap to a new address. The cap remains bound to its
|
|
72
|
+
* original `holder`; transferring changes object ownership but not write
|
|
73
|
+
* authority. To move write authority, the original holder destroys the cap
|
|
74
|
+
* and the OwnerCap holder issues a new one to the target address.
|
|
75
|
+
* @throws {ContractAbortError} On Move abort.
|
|
76
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
77
|
+
*/
|
|
78
|
+
export declare function transferPublisherCap(adapter: WalletAdapter, config: MorsePackageConfig, args: TransferPublisherCapArgs): Promise<TransferPublisherCapResult>;
|
|
79
|
+
//# sourceMappingURL=cap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cap.d.ts","sourceRoot":"","sources":["../../src/ops/cap.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAOvD,OAAO,KAAK,EACX,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;CACxC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,qBAAqB,GACzB,OAA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E,MAAM,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,wBAAwB,GAC5B,OAAO,CAAC,0BAA0B,CAAC,CAcrC"}
|
package/dist/ops/cap.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level PublisherCap lifecycle ops: issue, revoke, destroy.
|
|
3
|
+
*/
|
|
4
|
+
import { Transaction, } from "@mysten/sui/transactions";
|
|
5
|
+
import { toPublisherCapId } from "../codecs.js";
|
|
6
|
+
import { buildDestroyPublisherCap, buildIssuePublisherCap, buildRevokePublisherCap, } from "../ptb/cap.js";
|
|
7
|
+
import { buildTransferPublisherCap } from "../ptb/publication.js";
|
|
8
|
+
import { findCreatedId } from "./internal.js";
|
|
9
|
+
/**
|
|
10
|
+
* Issue a new PublisherCap and atomically transfer it to its bound `holder`
|
|
11
|
+
* inside the same PTB. The cap is bound to `holder` for write-permission
|
|
12
|
+
* checks regardless of where the object lives.
|
|
13
|
+
* @throws {ContractAbortError} On Move abort (e.g. ownerCap mismatch).
|
|
14
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
15
|
+
*/
|
|
16
|
+
export async function issuePublisherCap(adapter, config, args) {
|
|
17
|
+
const tx = new Transaction();
|
|
18
|
+
const created = buildIssuePublisherCap(tx, {
|
|
19
|
+
packageId: config.packageId,
|
|
20
|
+
publicationId: args.publicationId,
|
|
21
|
+
ownerCap: args.ownerCapId,
|
|
22
|
+
holder: args.holder,
|
|
23
|
+
});
|
|
24
|
+
// issue_publisher_cap returns a single PublisherCap. TransactionResult is
|
|
25
|
+
// typed as the array branch of TransactionArgument intersected with a
|
|
26
|
+
// single Result; the double cast narrows to the object-argument form
|
|
27
|
+
// expected by downstream PTB calls.
|
|
28
|
+
const capArg = created;
|
|
29
|
+
buildTransferPublisherCap(tx, {
|
|
30
|
+
packageId: config.packageId,
|
|
31
|
+
publisherCap: capArg,
|
|
32
|
+
recipient: args.holder,
|
|
33
|
+
});
|
|
34
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
35
|
+
const typePrefix = config.originalPackageId ?? config.packageId;
|
|
36
|
+
return {
|
|
37
|
+
digest: receipt.digest,
|
|
38
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
39
|
+
publisherCapId: toPublisherCapId(findCreatedId(receipt, `${typePrefix}::publication::PublisherCap`)),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Revoke a PublisherCap. Adds the cap ID to the publication's denylist; future
|
|
44
|
+
* write operations using that cap will abort with `EPublisherCapRevoked`.
|
|
45
|
+
* @throws {ContractAbortError} On Move abort (e.g. cap already revoked).
|
|
46
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
47
|
+
*/
|
|
48
|
+
export async function revokePublisherCap(adapter, config, args) {
|
|
49
|
+
const tx = new Transaction();
|
|
50
|
+
buildRevokePublisherCap(tx, {
|
|
51
|
+
packageId: config.packageId,
|
|
52
|
+
publicationId: args.publicationId,
|
|
53
|
+
ownerCap: args.ownerCapId,
|
|
54
|
+
publisherCapId: args.publisherCapId,
|
|
55
|
+
});
|
|
56
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
57
|
+
return {
|
|
58
|
+
digest: receipt.digest,
|
|
59
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Destroy a PublisherCap. Cleans the denylist entry if the cap was previously
|
|
64
|
+
* revoked. The Move layer enforces that `ctx.sender()` matches the cap's
|
|
65
|
+
* bound `holder`; call `reader.getPublisherCap` first if you want to validate
|
|
66
|
+
* before spending gas.
|
|
67
|
+
* @throws {ContractAbortError} On Move abort (e.g. wrong holder).
|
|
68
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
69
|
+
*/
|
|
70
|
+
export async function destroyPublisherCap(adapter, config, args) {
|
|
71
|
+
const tx = new Transaction();
|
|
72
|
+
buildDestroyPublisherCap(tx, {
|
|
73
|
+
packageId: config.packageId,
|
|
74
|
+
publicationId: args.publicationId,
|
|
75
|
+
publisherCap: args.publisherCapId,
|
|
76
|
+
});
|
|
77
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
78
|
+
return {
|
|
79
|
+
digest: receipt.digest,
|
|
80
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Transfer a PublisherCap to a new address. The cap remains bound to its
|
|
85
|
+
* original `holder`; transferring changes object ownership but not write
|
|
86
|
+
* authority. To move write authority, the original holder destroys the cap
|
|
87
|
+
* and the OwnerCap holder issues a new one to the target address.
|
|
88
|
+
* @throws {ContractAbortError} On Move abort.
|
|
89
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
90
|
+
*/
|
|
91
|
+
export async function transferPublisherCap(adapter, config, args) {
|
|
92
|
+
const tx = new Transaction();
|
|
93
|
+
buildTransferPublisherCap(tx, {
|
|
94
|
+
packageId: config.packageId,
|
|
95
|
+
publisherCap: args.publisherCapId,
|
|
96
|
+
recipient: args.recipient,
|
|
97
|
+
});
|
|
98
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
99
|
+
return {
|
|
100
|
+
digest: receipt.digest,
|
|
101
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=cap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cap.js","sourceRoot":"","sources":["../../src/ops/cap.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,WAAW,GAEX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAA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cAAc;QACjC,SAAS,EAAE,IAAI,CAAC,SAAS;KACzB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,yBAAyB,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAEzE,OAAO;QACN,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW,EAAE,OAAO,CAAC,WAAW;KAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level collection ops: create and delete collections within a publication.
|
|
3
|
+
*/
|
|
4
|
+
import type { MorsePackageConfig } from "../config.js";
|
|
5
|
+
import type { PublicationId, PublisherCapId, StorageMode } from "../types.js";
|
|
6
|
+
import type { WalletAdapter } from "../wallets/adapter.js";
|
|
7
|
+
export interface CreateCollectionArgs {
|
|
8
|
+
readonly publicationId: PublicationId;
|
|
9
|
+
readonly publisherCapId: PublisherCapId;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly storageMode: StorageMode;
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateCollectionResult {
|
|
15
|
+
readonly digest: string;
|
|
16
|
+
readonly gasUsedMist: bigint;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Add a new collection to a publication. Collections live inline in the
|
|
20
|
+
* publication's `VecMap`, so no Sui object is created and the receipt
|
|
21
|
+
* carries no created object ID.
|
|
22
|
+
* @throws {ContractAbortError} On Move abort (e.g. duplicate name -> `ECollectionAlreadyExists`).
|
|
23
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createCollection(adapter: WalletAdapter, config: MorsePackageConfig, args: CreateCollectionArgs): Promise<CreateCollectionResult>;
|
|
26
|
+
export interface DeleteCollectionArgs {
|
|
27
|
+
readonly publicationId: PublicationId;
|
|
28
|
+
readonly publisherCapId: PublisherCapId;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly signal?: AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
export interface DeleteCollectionResult {
|
|
33
|
+
readonly digest: string;
|
|
34
|
+
readonly gasUsedMist: bigint;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Remove a collection from a publication. No client-side preflight; the
|
|
38
|
+
* Move layer aborts unnamed (`UnknownAbort`) in two cases:
|
|
39
|
+
*
|
|
40
|
+
* - The collection name is not in the publication's VecMap (`vec_map::remove`).
|
|
41
|
+
* - The collection's entries table is non-empty (`table::destroy_empty`).
|
|
42
|
+
*
|
|
43
|
+
* Consumers wanting certainty before spending gas should fetch the
|
|
44
|
+
* publication via `getPublication` and inspect `collections` first.
|
|
45
|
+
*
|
|
46
|
+
* @throws {ContractAbortError} On Move abort.
|
|
47
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
48
|
+
*/
|
|
49
|
+
export declare function deleteCollection(adapter: WalletAdapter, config: MorsePackageConfig, args: DeleteCollectionArgs): Promise<DeleteCollectionResult>;
|
|
50
|
+
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/ops/collection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAKvD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACrC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,oBAAoB,GACxB,OAAO,CAAC,sBAAsB,CAAC,CAcjC;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACrC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,oBAAoB,GACxB,OAAO,CAAC,sBAAsB,CAAC,CAajC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level collection ops: create and delete collections within a publication.
|
|
3
|
+
*/
|
|
4
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
5
|
+
import { buildCreateCollection, buildDeleteCollection, } from "../ptb/collection.js";
|
|
6
|
+
/**
|
|
7
|
+
* Add a new collection to a publication. Collections live inline in the
|
|
8
|
+
* publication's `VecMap`, so no Sui object is created and the receipt
|
|
9
|
+
* carries no created object ID.
|
|
10
|
+
* @throws {ContractAbortError} On Move abort (e.g. duplicate name -> `ECollectionAlreadyExists`).
|
|
11
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
12
|
+
*/
|
|
13
|
+
export async function createCollection(adapter, config, args) {
|
|
14
|
+
const tx = new Transaction();
|
|
15
|
+
buildCreateCollection(tx, {
|
|
16
|
+
packageId: config.packageId,
|
|
17
|
+
publication: args.publicationId,
|
|
18
|
+
publisherCap: args.publisherCapId,
|
|
19
|
+
name: args.name,
|
|
20
|
+
storageMode: args.storageMode,
|
|
21
|
+
});
|
|
22
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
23
|
+
return {
|
|
24
|
+
digest: receipt.digest,
|
|
25
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Remove a collection from a publication. No client-side preflight; the
|
|
30
|
+
* Move layer aborts unnamed (`UnknownAbort`) in two cases:
|
|
31
|
+
*
|
|
32
|
+
* - The collection name is not in the publication's VecMap (`vec_map::remove`).
|
|
33
|
+
* - The collection's entries table is non-empty (`table::destroy_empty`).
|
|
34
|
+
*
|
|
35
|
+
* Consumers wanting certainty before spending gas should fetch the
|
|
36
|
+
* publication via `getPublication` and inspect `collections` first.
|
|
37
|
+
*
|
|
38
|
+
* @throws {ContractAbortError} On Move abort.
|
|
39
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
40
|
+
*/
|
|
41
|
+
export async function deleteCollection(adapter, config, args) {
|
|
42
|
+
const tx = new Transaction();
|
|
43
|
+
buildDeleteCollection(tx, {
|
|
44
|
+
packageId: config.packageId,
|
|
45
|
+
publication: args.publicationId,
|
|
46
|
+
publisherCap: args.publisherCapId,
|
|
47
|
+
name: args.name,
|
|
48
|
+
});
|
|
49
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
50
|
+
return {
|
|
51
|
+
digest: receipt.digest,
|
|
52
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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