@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/codecs.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime codecs: branded-ID constructors and enum converters between
|
|
3
|
+
* TypeScript values and on-chain Move representations.
|
|
4
|
+
*/
|
|
5
|
+
import { ValidationError } from "./errors.js";
|
|
6
|
+
import { AccessPolicy, QUILT_PATCH_ID_LENGTH, StorageMode, } from "./types.js";
|
|
7
|
+
// ID validation
|
|
8
|
+
/** `0x` + 1 to 64 lowercase hex chars. */
|
|
9
|
+
const OBJECT_ID_PATTERN = /^0x[0-9a-f]{1,64}$/;
|
|
10
|
+
const OBJECT_ID_HEX_LENGTH = 64;
|
|
11
|
+
/**
|
|
12
|
+
* Validate the input shape and return its zero-padded canonical form.
|
|
13
|
+
* Sui represents object IDs as 32-byte values rendered `0x`+64 hex chars.
|
|
14
|
+
* Short forms (e.g. `"0x1"`) are accepted as input — they're convenient in
|
|
15
|
+
* Move source — but the brand always carries the canonical 64-char form so
|
|
16
|
+
* downstream string equality works against RPC responses (which are always
|
|
17
|
+
* canonical).
|
|
18
|
+
*/
|
|
19
|
+
function normalizeObjectId(value, field) {
|
|
20
|
+
if (!OBJECT_ID_PATTERN.test(value)) {
|
|
21
|
+
throw new ValidationError(`Invalid ${field}: expected lowercase hex prefixed with "0x" and up to 64 hex characters, got ${JSON.stringify(value)}`, field);
|
|
22
|
+
}
|
|
23
|
+
const hex = value.slice(2);
|
|
24
|
+
if (hex.length === OBJECT_ID_HEX_LENGTH) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return `0x${hex.padStart(OBJECT_ID_HEX_LENGTH, "0")}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Construct a `PackageId`. Input may be `0x` + 1-64 lowercase hex chars;
|
|
31
|
+
* the result is always zero-padded to 64 hex chars (Sui canonical form).
|
|
32
|
+
* @throws {ValidationError} On invalid shape.
|
|
33
|
+
*/
|
|
34
|
+
export function toPackageId(value) {
|
|
35
|
+
return normalizeObjectId(value, "PackageId");
|
|
36
|
+
}
|
|
37
|
+
/** Construct a `RegistryId`. Input is normalized to canonical 64-char form. @throws {ValidationError} On invalid shape. */
|
|
38
|
+
export function toRegistryId(value) {
|
|
39
|
+
return normalizeObjectId(value, "RegistryId");
|
|
40
|
+
}
|
|
41
|
+
/** Construct a `PublicationId`. Input is normalized to canonical 64-char form. @throws {ValidationError} On invalid shape. */
|
|
42
|
+
export function toPublicationId(value) {
|
|
43
|
+
return normalizeObjectId(value, "PublicationId");
|
|
44
|
+
}
|
|
45
|
+
/** Construct an `OwnerCapId`. Input is normalized to canonical 64-char form. @throws {ValidationError} On invalid shape. */
|
|
46
|
+
export function toOwnerCapId(value) {
|
|
47
|
+
return normalizeObjectId(value, "OwnerCapId");
|
|
48
|
+
}
|
|
49
|
+
/** Construct a `PublisherCapId`. Input is normalized to canonical 64-char form. @throws {ValidationError} On invalid shape. */
|
|
50
|
+
export function toPublisherCapId(value) {
|
|
51
|
+
return normalizeObjectId(value, "PublisherCapId");
|
|
52
|
+
}
|
|
53
|
+
/** Construct a `BlobObjectId`. Input is normalized to canonical 64-char form. @throws {ValidationError} On invalid shape. */
|
|
54
|
+
export function toBlobObjectId(value) {
|
|
55
|
+
return normalizeObjectId(value, "BlobObjectId");
|
|
56
|
+
}
|
|
57
|
+
/** Construct a `SuiAddress`. Input is normalized to canonical 64-char form. @throws {ValidationError} On invalid shape. */
|
|
58
|
+
export function toSuiAddress(value) {
|
|
59
|
+
return normalizeObjectId(value, "SuiAddress");
|
|
60
|
+
}
|
|
61
|
+
/** Construct a `SuiObjectId`. Input is normalized to canonical 64-char form. @throws {ValidationError} On invalid shape. */
|
|
62
|
+
export function toSuiObjectId(value) {
|
|
63
|
+
return normalizeObjectId(value, "SuiObjectId");
|
|
64
|
+
}
|
|
65
|
+
// Walrus blob id
|
|
66
|
+
/** URL-safe base64 alphabet, no padding. 43 chars carries 32 bytes. */
|
|
67
|
+
const WALRUS_BLOB_ID_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
68
|
+
/**
|
|
69
|
+
* Construct a `WalrusBlobId` from a URL-safe base64 string (43 chars,
|
|
70
|
+
* unpadded). @throws {ValidationError} On invalid shape.
|
|
71
|
+
*/
|
|
72
|
+
export function toWalrusBlobId(value) {
|
|
73
|
+
if (!WALRUS_BLOB_ID_PATTERN.test(value)) {
|
|
74
|
+
throw new ValidationError(`Invalid WalrusBlobId: expected 43 URL-safe base64 chars (unpadded), got ${JSON.stringify(value)}`, "WalrusBlobId");
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
// Quilt patch id
|
|
79
|
+
/**
|
|
80
|
+
* Construct a `QuiltPatchId` by validating length only. Use the structural
|
|
81
|
+
* codec in `walrus/quilt-patch-id.ts` for `{quiltId, version, startIndex,
|
|
82
|
+
* endIndex}` round-trips. @throws {ValidationError} On wrong length.
|
|
83
|
+
*/
|
|
84
|
+
export function toQuiltPatchId(bytes) {
|
|
85
|
+
if (bytes.length !== QUILT_PATCH_ID_LENGTH) {
|
|
86
|
+
throw new ValidationError(`Invalid QuiltPatchId: expected ${QUILT_PATCH_ID_LENGTH} bytes, got ${bytes.length}`, "QuiltPatchId");
|
|
87
|
+
}
|
|
88
|
+
return bytes;
|
|
89
|
+
}
|
|
90
|
+
// Storage mode
|
|
91
|
+
/** Convert `StorageMode` to Move `u8`. */
|
|
92
|
+
export function storageModeToU8(mode) {
|
|
93
|
+
if (mode === StorageMode.Blob) {
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
/** Convert Move `u8` to `StorageMode`. @throws {ValidationError} On unknown values. */
|
|
99
|
+
export function storageModeFromU8(value) {
|
|
100
|
+
if (value === 0) {
|
|
101
|
+
return StorageMode.Blob;
|
|
102
|
+
}
|
|
103
|
+
if (value === 1) {
|
|
104
|
+
return StorageMode.Quilt;
|
|
105
|
+
}
|
|
106
|
+
throw new ValidationError(`Invalid storage_mode: expected 0 (blob) or 1 (quilt), got ${value}`, "storage_mode");
|
|
107
|
+
}
|
|
108
|
+
// Access policy
|
|
109
|
+
/** Convert `AccessPolicy` to Move `u8`. */
|
|
110
|
+
export function accessPolicyToU8(policy) {
|
|
111
|
+
if (policy === AccessPolicy.Public) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
if (policy === AccessPolicy.Publisher) {
|
|
115
|
+
return 1;
|
|
116
|
+
}
|
|
117
|
+
return 2;
|
|
118
|
+
}
|
|
119
|
+
/** Convert Move `u8` to `AccessPolicy`. @throws {ValidationError} On unknown values. */
|
|
120
|
+
export function accessPolicyFromU8(value) {
|
|
121
|
+
if (value === 0) {
|
|
122
|
+
return AccessPolicy.Public;
|
|
123
|
+
}
|
|
124
|
+
if (value === 1) {
|
|
125
|
+
return AccessPolicy.Publisher;
|
|
126
|
+
}
|
|
127
|
+
if (value === 2) {
|
|
128
|
+
return AccessPolicy.Subscription;
|
|
129
|
+
}
|
|
130
|
+
throw new ValidationError(`Invalid access_policy: expected 0, 1, or 2, got ${value}`, "access_policy");
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACN,YAAY,EAMZ,qBAAqB,EAGrB,WAAW,GAIX,MAAM,YAAY,CAAC;AAEpB,gBAAgB;AAEhB,0CAA0C;AAC1C,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC/C,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC;;;;;;;GAOG;AACH,SAAS,iBAAiB,CAAC,KAAa,EAAE,KAAa;IACtD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,eAAe,CACxB,WAAW,KAAK,gFAAgF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EACvH,KAAK,CACL,CAAC;IACH,CAAC;IACD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,GAAG,CAAC,MAAM,KAAK,oBAAoB,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,KAAK,GAAG,CAAC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,EAAE,CAAC;AACvD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACxC,OAAO,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAc,CAAC;AAC3D,CAAC;AAED,2HAA2H;AAC3H,MAAM,UAAU,YAAY,CAAC,KAAa;IACzC,OAAO,iBAAiB,CAAC,KAAK,EAAE,YAAY,CAAe,CAAC;AAC7D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D,MAAM,IAAI,eAAe,CACxB,mDAAmD,KAAK,EAAE,EAC1D,eAAe,CACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Mysten substrate versions morse-sdk has been tested end-to-end
|
|
3
|
+
* against. Compatibility is enforced at install time via peer-dependency
|
|
4
|
+
* ranges in `package.json` (`bun install` warns if mismatched). Runtime
|
|
5
|
+
* version checks are not provided because the Mysten libraries do not
|
|
6
|
+
* expose their `package.json` `version` through their `exports` maps; a
|
|
7
|
+
* hand-rolled "open the package.json from disk" check would be fragile in
|
|
8
|
+
* browser bundlers and silent on misconfiguration.
|
|
9
|
+
*
|
|
10
|
+
* This constant is exported so consumers can display the tested matrix in
|
|
11
|
+
* their own diagnostics, log it during initialization, or compare it
|
|
12
|
+
* against bundler-resolved versions in CI.
|
|
13
|
+
*/
|
|
14
|
+
/** Mysten substrate library versions verified end-to-end on testnet. */
|
|
15
|
+
export declare const TESTED_SUBSTRATE: {
|
|
16
|
+
readonly "@mysten/sui": string;
|
|
17
|
+
readonly "@mysten/seal": string;
|
|
18
|
+
readonly "@mysten/walrus": string;
|
|
19
|
+
readonly verifiedOn: string;
|
|
20
|
+
readonly suiNetwork: "testnet";
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=compatibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../src/compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,EAAE;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;CAO/B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Mysten substrate versions morse-sdk has been tested end-to-end
|
|
3
|
+
* against. Compatibility is enforced at install time via peer-dependency
|
|
4
|
+
* ranges in `package.json` (`bun install` warns if mismatched). Runtime
|
|
5
|
+
* version checks are not provided because the Mysten libraries do not
|
|
6
|
+
* expose their `package.json` `version` through their `exports` maps; a
|
|
7
|
+
* hand-rolled "open the package.json from disk" check would be fragile in
|
|
8
|
+
* browser bundlers and silent on misconfiguration.
|
|
9
|
+
*
|
|
10
|
+
* This constant is exported so consumers can display the tested matrix in
|
|
11
|
+
* their own diagnostics, log it during initialization, or compare it
|
|
12
|
+
* against bundler-resolved versions in CI.
|
|
13
|
+
*/
|
|
14
|
+
/** Mysten substrate library versions verified end-to-end on testnet. */
|
|
15
|
+
export const TESTED_SUBSTRATE = {
|
|
16
|
+
"@mysten/sui": "2.16.2",
|
|
17
|
+
"@mysten/seal": "1.1.3",
|
|
18
|
+
"@mysten/walrus": "1.1.6",
|
|
19
|
+
verifiedOn: "2026-05-10",
|
|
20
|
+
suiNetwork: "testnet",
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=compatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../src/compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAMzB;IACH,aAAa,EAAE,QAAQ;IACvB,cAAc,EAAE,OAAO;IACvB,gBAAgB,EAAE,OAAO;IACzB,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,SAAS;CACrB,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network configuration types, defaults, and the `morseConfig` factory that
|
|
3
|
+
* hides deployed package addresses from consumers using known networks.
|
|
4
|
+
*/
|
|
5
|
+
import type { KeyServerConfig } from "@mysten/seal";
|
|
6
|
+
import type { PackageId, RegistryId } from "./types.js";
|
|
7
|
+
/** Supported Sui networks. */
|
|
8
|
+
export declare const Network: {
|
|
9
|
+
readonly Mainnet: "mainnet";
|
|
10
|
+
readonly Testnet: "testnet";
|
|
11
|
+
readonly Localnet: "localnet";
|
|
12
|
+
};
|
|
13
|
+
export type Network = (typeof Network)[keyof typeof Network];
|
|
14
|
+
/** Public Sui RPC endpoints per network. Override via `NetworkConfig.rpcUrl` if needed. */
|
|
15
|
+
export declare const DEFAULT_RPC_URLS: Readonly<Record<Network, string>>;
|
|
16
|
+
/**
|
|
17
|
+
* Points the SDK at a Morse deployment. Values come from the deployment's
|
|
18
|
+
* `Published.toml`.
|
|
19
|
+
*
|
|
20
|
+
* `packageId` is the `published-at` address (current upgrade) used as the
|
|
21
|
+
* target of Move calls. `originalPackageId` is the `original-id` (genesis
|
|
22
|
+
* publish address) used as the canonical type identity that Sui surfaces in
|
|
23
|
+
* `objectType` strings and type filters; defaults to `packageId` when
|
|
24
|
+
* omitted (correct for a fresh deploy with no upgrades). Swapping the two
|
|
25
|
+
* values causes type-filter reads (e.g. `listPublicationsOwnedBy`) to return
|
|
26
|
+
* empty.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Walrus aggregator / publisher HTTP endpoints. The aggregator URL is the
|
|
30
|
+
* canonical Mysten-run service for the network; the publisher URL is left
|
|
31
|
+
* undefined by default because publishers are operator-specific (paid
|
|
32
|
+
* tiers, region pinning) and picking one for everyone is a trust decision
|
|
33
|
+
* the SDK should not make. Consumers using a specific publisher supply
|
|
34
|
+
* the URL explicitly via `morseConfig({ walrusEndpoints: { ... } })` or
|
|
35
|
+
* pass it directly to `HttpPublisherWriteAdapter.fromConfig`.
|
|
36
|
+
*/
|
|
37
|
+
export interface WalrusEndpoints {
|
|
38
|
+
/** Aggregator base URL for HTTP reads. No trailing slash. */
|
|
39
|
+
readonly aggregator: string;
|
|
40
|
+
/** Optional publisher base URL for HTTP writes. No trailing slash. */
|
|
41
|
+
readonly publisher?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface NetworkConfig {
|
|
44
|
+
readonly network: Network;
|
|
45
|
+
readonly rpcUrl: string;
|
|
46
|
+
readonly packageId: PackageId;
|
|
47
|
+
readonly originalPackageId?: PackageId;
|
|
48
|
+
readonly registryId: RegistryId;
|
|
49
|
+
/**
|
|
50
|
+
* Canonical Seal threshold-encryption key servers for the network. Used by
|
|
51
|
+
* `DefaultSealAdapter.fromMorseConfig` when the consumer omits an explicit
|
|
52
|
+
* `serverConfigs`. Empty for networks where the allowlist isn't pinned yet
|
|
53
|
+
* (e.g. mainnet pre-freeze).
|
|
54
|
+
*/
|
|
55
|
+
readonly sealKeyServers: readonly KeyServerConfig[];
|
|
56
|
+
/**
|
|
57
|
+
* Canonical Walrus HTTP endpoints for the network. Used by
|
|
58
|
+
* `HttpAggregatorReadAdapter.fromMorseConfig` (and the future publisher
|
|
59
|
+
* equivalent when a "canonical" publisher exists). Aggregator is pinned
|
|
60
|
+
* to Mysten's testnet service; publisher is intentionally left
|
|
61
|
+
* undefined — pass `walrusEndpoints.publisher` to override.
|
|
62
|
+
*/
|
|
63
|
+
readonly walrusEndpoints: WalrusEndpoints;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Subset of `NetworkConfig` used by ops that touch only the package (cap and
|
|
67
|
+
* collection ops). Excludes `registryId`, which only registry-aware ops
|
|
68
|
+
* (publication creation/deletion) need.
|
|
69
|
+
*/
|
|
70
|
+
export type MorsePackageConfig = Pick<NetworkConfig, "packageId" | "originalPackageId">;
|
|
71
|
+
/**
|
|
72
|
+
* Options for `morseConfig`. `network` is required; address fields are
|
|
73
|
+
* optional and override the canonical deployment when supplied. Use them
|
|
74
|
+
* for forks or local deployments.
|
|
75
|
+
*/
|
|
76
|
+
export interface MorseConfigOptions {
|
|
77
|
+
readonly network: Network;
|
|
78
|
+
readonly rpcUrl?: string;
|
|
79
|
+
readonly packageId?: PackageId;
|
|
80
|
+
readonly originalPackageId?: PackageId;
|
|
81
|
+
readonly registryId?: RegistryId;
|
|
82
|
+
readonly sealKeyServers?: readonly KeyServerConfig[];
|
|
83
|
+
readonly walrusEndpoints?: WalrusEndpoints;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build a `NetworkConfig` pointing at the canonical Morse deployment for the
|
|
87
|
+
* chosen network, with optional per-field overrides for forks and local nodes.
|
|
88
|
+
* @throws {ConfigurationError} If the chosen network has no canonical deployment
|
|
89
|
+
* and `packageId` and `registryId` are not supplied as overrides.
|
|
90
|
+
*/
|
|
91
|
+
export declare function morseConfig(options: MorseConfigOptions): NetworkConfig;
|
|
92
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxD,8BAA8B;AAC9B,eAAO,MAAM,OAAO;;;;CAIV,CAAC;AACX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAI7D,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAI9D,CAAC;AAIF;;;;;;;;;;;GAWG;AACH;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,EAAE,SAAS,eAAe,EAAE,CAAC;IACpD;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;CAC1C;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACpC,aAAa,EACb,WAAW,GAAG,mBAAmB,CACjC,CAAC;AA2DF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACrD,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;CAC3C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,aAAa,CA4BtE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network configuration types, defaults, and the `morseConfig` factory that
|
|
3
|
+
* hides deployed package addresses from consumers using known networks.
|
|
4
|
+
*/
|
|
5
|
+
import { toPackageId, toRegistryId } from "./codecs.js";
|
|
6
|
+
import { ConfigurationError } from "./errors.js";
|
|
7
|
+
// Network
|
|
8
|
+
/** Supported Sui networks. */
|
|
9
|
+
export const Network = {
|
|
10
|
+
Mainnet: "mainnet",
|
|
11
|
+
Testnet: "testnet",
|
|
12
|
+
Localnet: "localnet",
|
|
13
|
+
};
|
|
14
|
+
// Default RPC endpoints
|
|
15
|
+
/** Public Sui RPC endpoints per network. Override via `NetworkConfig.rpcUrl` if needed. */
|
|
16
|
+
export const DEFAULT_RPC_URLS = {
|
|
17
|
+
mainnet: "https://fullnode.mainnet.sui.io:443",
|
|
18
|
+
testnet: "https://fullnode.testnet.sui.io:443",
|
|
19
|
+
localnet: "http://127.0.0.1:9000",
|
|
20
|
+
};
|
|
21
|
+
// morseConfig factory
|
|
22
|
+
/**
|
|
23
|
+
* Canonical Morse deployment addresses per network. Updated on every contract
|
|
24
|
+
* redeploy during active development; expected to stabilize after Phase 7
|
|
25
|
+
* when the contracts are frozen for v0.1.0.
|
|
26
|
+
*/
|
|
27
|
+
const KNOWN_DEPLOYMENTS = {
|
|
28
|
+
testnet: {
|
|
29
|
+
packageId: toPackageId("0x191946c5dc1ea1b978e664d85455e81ef9bdd1d3dbb221fd48cf9008d46a00f0"),
|
|
30
|
+
originalPackageId: toPackageId("0x191946c5dc1ea1b978e664d85455e81ef9bdd1d3dbb221fd48cf9008d46a00f0"),
|
|
31
|
+
registryId: toRegistryId("0xb25e4849d720ad5058c1945a819aa1dc01ff899006e3f0fe7cb9c62668d307e2"),
|
|
32
|
+
// Canonical Seal testnet allowlist; mirrors the values used in Mysten's
|
|
33
|
+
// own integration tests at
|
|
34
|
+
// https://github.com/MystenLabs/ts-sdks/blob/main/packages/seal/test/unit/integration.test.ts
|
|
35
|
+
// Pulled 2026-05-08. Public, stable; not a secret.
|
|
36
|
+
sealKeyServers: [
|
|
37
|
+
{
|
|
38
|
+
objectId: "0x73d05d62c18d9374e3ea529e8e0ed6161da1a141a94d3f76ae3fe4e99356db75",
|
|
39
|
+
weight: 1,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
objectId: "0xf5d14a81a982144ae441cd7d64b09027f116a468bd36e7eca494f750591623c8",
|
|
43
|
+
weight: 1,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
// Canonical Mysten-run Walrus testnet aggregator. Used by
|
|
47
|
+
// `HttpAggregatorReadAdapter.fromMorseConfig` for browser dapps that
|
|
48
|
+
// need a single CORS-friendly endpoint instead of the direct-protocol
|
|
49
|
+
// shard fanout (which has incomplete CORS coverage on testnet).
|
|
50
|
+
// Publisher is intentionally undefined — there is no single canonical
|
|
51
|
+
// testnet publisher; consumers wire their own (Nami, self-hosted, etc).
|
|
52
|
+
walrusEndpoints: {
|
|
53
|
+
aggregator: "https://aggregator.walrus-testnet.walrus.space",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Build a `NetworkConfig` pointing at the canonical Morse deployment for the
|
|
59
|
+
* chosen network, with optional per-field overrides for forks and local nodes.
|
|
60
|
+
* @throws {ConfigurationError} If the chosen network has no canonical deployment
|
|
61
|
+
* and `packageId` and `registryId` are not supplied as overrides.
|
|
62
|
+
*/
|
|
63
|
+
export function morseConfig(options) {
|
|
64
|
+
const deployment = KNOWN_DEPLOYMENTS[options.network];
|
|
65
|
+
const packageId = options.packageId ?? deployment?.packageId;
|
|
66
|
+
const originalPackageId = options.originalPackageId ?? deployment?.originalPackageId;
|
|
67
|
+
const registryId = options.registryId ?? deployment?.registryId;
|
|
68
|
+
if (!packageId || !registryId) {
|
|
69
|
+
if (options.network === "mainnet") {
|
|
70
|
+
throw new ConfigurationError("Morse is not yet deployed on mainnet. Use { network: 'testnet' } or supply packageId, originalPackageId, and registryId for a custom deployment.");
|
|
71
|
+
}
|
|
72
|
+
throw new ConfigurationError(`No canonical Morse deployment for network "${options.network}". Supply packageId, originalPackageId, and registryId for a custom deployment.`);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
network: options.network,
|
|
76
|
+
rpcUrl: options.rpcUrl ?? DEFAULT_RPC_URLS[options.network],
|
|
77
|
+
packageId,
|
|
78
|
+
registryId,
|
|
79
|
+
...(originalPackageId === undefined ? {} : { originalPackageId }),
|
|
80
|
+
sealKeyServers: options.sealKeyServers ?? deployment?.sealKeyServers ?? [],
|
|
81
|
+
walrusEndpoints: options.walrusEndpoints ??
|
|
82
|
+
deployment?.walrusEndpoints ?? { aggregator: "" },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,UAAU;AAEV,8BAA8B;AAC9B,MAAM,CAAC,MAAM,OAAO,GAAG;IACtB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACX,CAAC;AAGX,wBAAwB;AAExB,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IAClE,OAAO,EAAE,qCAAqC;IAC9C,OAAO,EAAE,qCAAqC;IAC9C,QAAQ,EAAE,uBAAuB;CACjC,CAAC;AAiEF,sBAAsB;AAEtB;;;;GAIG;AACH,MAAM,iBAAiB,GAWnB;IACH,OAAO,EAAE;QACR,SAAS,EAAE,WAAW,CACrB,oEAAoE,CACpE;QACD,iBAAiB,EAAE,WAAW,CAC7B,oEAAoE,CACpE;QACD,UAAU,EAAE,YAAY,CACvB,oEAAoE,CACpE;QACD,wEAAwE;QACxE,2BAA2B;QAC3B,8FAA8F;QAC9F,mDAAmD;QACnD,cAAc,EAAE;YACf;gBACC,QAAQ,EACP,oEAAoE;gBACrE,MAAM,EAAE,CAAC;aACT;YACD;gBACC,QAAQ,EACP,oEAAoE;gBACrE,MAAM,EAAE,CAAC;aACT;SACD;QACD,0DAA0D;QAC1D,qEAAqE;QACrE,sEAAsE;Q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1
|
+
/**
|
|
2
|
+
* Error hierarchy. All errors extend `MorseError`; narrow subclasses via `instanceof`.
|
|
3
|
+
*/
|
|
4
|
+
/** Abstract base for every error thrown by the SDK. */
|
|
5
|
+
export declare abstract class MorseError extends Error {
|
|
6
|
+
constructor(message: string, options?: {
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/** Client-side precondition failed (malformed ID, invalid enum, etc). */
|
|
11
|
+
export declare class ValidationError extends MorseError {
|
|
12
|
+
/** Name of the field or parameter that failed validation. */
|
|
13
|
+
readonly field: string;
|
|
14
|
+
constructor(message: string, field: string, options?: {
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export type NotFoundResource = "publication" | "collection" | "entry" | "revision" | "publisher-cap" | "owner-cap" | "registry" | "blob";
|
|
19
|
+
/** Resource not found on-chain. */
|
|
20
|
+
export declare class NotFoundError extends MorseError {
|
|
21
|
+
readonly resource: NotFoundResource;
|
|
22
|
+
readonly identifier: string;
|
|
23
|
+
constructor(resource: NotFoundResource, identifier: string, options?: {
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Authorization check failed client-side, before the transaction was submitted. */
|
|
28
|
+
export declare class UnauthorizedError extends MorseError {
|
|
29
|
+
}
|
|
30
|
+
/** RPC transport, network, or response-parsing failure. Distinct from contract aborts. */
|
|
31
|
+
export declare class TransportError extends MorseError {
|
|
32
|
+
}
|
|
33
|
+
/** SDK configuration gap (e.g. asking for a network with no canonical deployment). */
|
|
34
|
+
export declare class ConfigurationError extends MorseError {
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Thrown by `addEntryFromBytes` / `addEncryptedEntryFromBytes` when the
|
|
38
|
+
* register-and-upload step succeeded (the user already paid for storage and
|
|
39
|
+
* the bytes are on Walrus storage nodes) but the combined `certify_blob +
|
|
40
|
+
* add_entry` transaction failed (rejected popup, contract abort, network
|
|
41
|
+
* blip). The blob exists on Sui as an uncertified `Blob` object that is
|
|
42
|
+
* holding storage until either the consumer certifies it or the storage
|
|
43
|
+
* registration expires.
|
|
44
|
+
*
|
|
45
|
+
* Carries `blobObjectId` and `blobId` so the consumer can surface them to the
|
|
46
|
+
* user (e.g. "your upload was wasted; here is the blob id for support") or
|
|
47
|
+
* retry the flow with fresh bytes. The original failure is preserved as
|
|
48
|
+
* `cause`.
|
|
49
|
+
*/
|
|
50
|
+
export declare class UncertifiedBlobError extends MorseError {
|
|
51
|
+
readonly blobObjectId: string;
|
|
52
|
+
readonly blobId: string;
|
|
53
|
+
constructor(blobObjectId: string, blobId: string, options?: {
|
|
54
|
+
cause?: unknown;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Distinct failure modes Seal exposes to consumers. Narrow on `code`. */
|
|
58
|
+
export type SealErrorCode = "no-access" | "decrypt-failed" | "session-expired" | "rate-limited";
|
|
59
|
+
/**
|
|
60
|
+
* Seal encryption or decryption failed for a content reason (not transport).
|
|
61
|
+
* Use this to distinguish authorization gaps (`no-access`) from network
|
|
62
|
+
* blips (`TransportError`).
|
|
63
|
+
*/
|
|
64
|
+
export declare class SealError extends MorseError {
|
|
65
|
+
readonly code: SealErrorCode;
|
|
66
|
+
constructor(code: SealErrorCode, message: string, options?: {
|
|
67
|
+
cause?: unknown;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/** Move module whose abort codes the SDK knows about. */
|
|
71
|
+
export type AbortModule = "publication" | "collection" | "entry";
|
|
72
|
+
/** One row of the abort-code table. */
|
|
73
|
+
export interface AbortEntry {
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly description: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Move abort codes mirrored from `morse-contracts`. Structure: `ABORT_CODES[module][code]`.
|
|
79
|
+
* New abort constants in the Move package must be added here, or they surface as `UnknownAbort`.
|
|
80
|
+
*/
|
|
81
|
+
export declare const ABORT_CODES: {
|
|
82
|
+
readonly [M in AbortModule]: {
|
|
83
|
+
readonly [code: number]: AbortEntry;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** Reason value used when a Move abort code is not in the SDK's table. */
|
|
87
|
+
export declare const UNKNOWN_ABORT_NAME = "UnknownAbort";
|
|
88
|
+
/** Move VM aborted during transaction execution. Narrow on `reason` (e.g. "EPublisherCapRevoked"). */
|
|
89
|
+
export declare class ContractAbortError extends MorseError {
|
|
90
|
+
readonly module: AbortModule;
|
|
91
|
+
readonly abortCode: number;
|
|
92
|
+
readonly reason: string;
|
|
93
|
+
constructor(module: AbortModule, abortCode: number, reason: string, message: string, options?: {
|
|
94
|
+
cause?: unknown;
|
|
95
|
+
});
|
|
96
|
+
/** Build an error by looking up `(module, abortCode)` in the abort-code table. */
|
|
97
|
+
static fromAbortCode(module: AbortModule, abortCode: number, options?: {
|
|
98
|
+
cause?: unknown;
|
|
99
|
+
}): ContractAbortError;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,uDAAuD;AACvD,8BAAsB,UAAW,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI1D;AAID,yEAAyE;AACzE,qBAAa,eAAgB,SAAQ,UAAU;IAC9C,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAIzE;AAID,MAAM,MAAM,gBAAgB,GACzB,aAAa,GACb,YAAY,GACZ,OAAO,GACP,UAAU,GACV,eAAe,GACf,WAAW,G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