@arcadiasystems/morse-sdk 0.3.0 → 0.4.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.
- package/CHANGELOG.md +88 -0
- package/dist/codecs.d.ts +3 -7
- package/dist/codecs.d.ts.map +1 -1
- package/dist/codecs.js +3 -11
- package/dist/codecs.js.map +1 -1
- package/dist/config.d.ts +19 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +13 -10
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.format.js +1 -2
- package/dist/errors.format.js.map +1 -1
- package/dist/errors.js +29 -27
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/ops/index.d.ts +2 -3
- package/dist/ops/index.d.ts.map +1 -1
- package/dist/ops/index.js +2 -3
- package/dist/ops/index.js.map +1 -1
- package/dist/ops/recipient-file-from-bytes.d.ts +123 -0
- package/dist/ops/recipient-file-from-bytes.d.ts.map +1 -0
- package/dist/ops/recipient-file-from-bytes.js +140 -0
- package/dist/ops/recipient-file-from-bytes.js.map +1 -0
- package/dist/ops/recipient-file.d.ts +124 -0
- package/dist/ops/recipient-file.d.ts.map +1 -0
- package/dist/ops/recipient-file.js +160 -0
- package/dist/ops/recipient-file.js.map +1 -0
- package/dist/ptb/recipient-file.d.ts +82 -0
- package/dist/ptb/recipient-file.d.ts.map +1 -0
- package/dist/ptb/recipient-file.js +148 -0
- package/dist/ptb/recipient-file.js.map +1 -0
- package/dist/read/index.d.ts +2 -2
- package/dist/read/index.d.ts.map +1 -1
- package/dist/read/index.js +2 -2
- package/dist/read/index.js.map +1 -1
- package/dist/read/recipient-file-events.d.ts +65 -0
- package/dist/read/recipient-file-events.d.ts.map +1 -0
- package/dist/read/recipient-file-events.js +172 -0
- package/dist/read/recipient-file-events.js.map +1 -0
- package/dist/read/recipient-files-reader.d.ts +27 -0
- package/dist/read/recipient-files-reader.d.ts.map +1 -0
- package/dist/read/recipient-files-reader.js +170 -0
- package/dist/read/recipient-files-reader.js.map +1 -0
- package/dist/seal/adapter.d.ts +20 -19
- package/dist/seal/adapter.d.ts.map +1 -1
- package/dist/seal/adapter.js +9 -3
- package/dist/seal/adapter.js.map +1 -1
- package/dist/seal/default-adapter.d.ts +5 -5
- package/dist/seal/default-adapter.d.ts.map +1 -1
- package/dist/seal/default-adapter.js +13 -22
- package/dist/seal/default-adapter.js.map +1 -1
- package/dist/seal/index.d.ts +2 -2
- package/dist/seal/index.d.ts.map +1 -1
- package/dist/seal/index.js +1 -1
- package/dist/seal/index.js.map +1 -1
- package/dist/seal/recipient-file-identity.d.ts +53 -0
- package/dist/seal/recipient-file-identity.d.ts.map +1 -0
- package/dist/seal/recipient-file-identity.js +87 -0
- package/dist/seal/recipient-file-identity.js.map +1 -0
- package/dist/types.d.ts +43 -59
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wallets/keypair-adapter.d.ts.map +1 -1
- package/dist/wallets/keypair-adapter.js +1 -2
- package/dist/wallets/keypair-adapter.js.map +1 -1
- package/package.json +1 -1
- package/dist/ops/allowlist.d.ts +0 -79
- package/dist/ops/allowlist.d.ts.map +0 -1
- package/dist/ops/allowlist.js +0 -122
- package/dist/ops/allowlist.js.map +0 -1
- package/dist/ops/file-from-bytes.d.ts +0 -84
- package/dist/ops/file-from-bytes.d.ts.map +0 -1
- package/dist/ops/file-from-bytes.js +0 -133
- package/dist/ops/file-from-bytes.js.map +0 -1
- package/dist/ops/file.d.ts +0 -88
- package/dist/ops/file.d.ts.map +0 -1
- package/dist/ops/file.js +0 -142
- package/dist/ops/file.js.map +0 -1
- package/dist/ptb/allowlist.d.ts +0 -65
- package/dist/ptb/allowlist.d.ts.map +0 -1
- package/dist/ptb/allowlist.js +0 -75
- package/dist/ptb/allowlist.js.map +0 -1
- package/dist/ptb/file.d.ts +0 -58
- package/dist/ptb/file.d.ts.map +0 -1
- package/dist/ptb/file.js +0 -108
- package/dist/ptb/file.js.map +0 -1
- package/dist/read/files-events.d.ts +0 -87
- package/dist/read/files-events.d.ts.map +0 -1
- package/dist/read/files-events.js +0 -194
- package/dist/read/files-events.js.map +0 -1
- package/dist/read/files-reader.d.ts +0 -59
- package/dist/read/files-reader.d.ts.map +0 -1
- package/dist/read/files-reader.js +0 -247
- package/dist/read/files-reader.js.map +0 -1
- package/dist/seal/allowlist-identity.d.ts +0 -36
- package/dist/seal/allowlist-identity.d.ts.map +0 -1
- package/dist/seal/allowlist-identity.js +0 -81
- package/dist/seal/allowlist-identity.js.map +0 -1
package/dist/ptb/file.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PTB builders for `file` module Move calls. Internal to the SDK;
|
|
3
|
-
* `ops/file.ts` composes these into single atomic transactions.
|
|
4
|
-
*/
|
|
5
|
-
/** Canonical Sui clock shared object id. The `file::new_*` calls take it as input. */
|
|
6
|
-
const SUI_CLOCK_OBJECT_ID = "0x6";
|
|
7
|
-
/**
|
|
8
|
-
* Add a `file::new_encrypted_file` call. Returns the new EncryptedFile as the
|
|
9
|
-
* first result. The caller must follow with `share_file` to make it accessible
|
|
10
|
-
* from any wallet.
|
|
11
|
-
*/
|
|
12
|
-
export function buildNewEncryptedFile(tx, args) {
|
|
13
|
-
const blobIdBytes = walrusBlobIdToBytes(args.blobId);
|
|
14
|
-
return tx.moveCall({
|
|
15
|
-
target: `${args.packageId}::file::new_encrypted_file`,
|
|
16
|
-
arguments: [
|
|
17
|
-
tx.pure.vector("u8", Array.from(blobIdBytes)),
|
|
18
|
-
optionSomeId(tx, args.blobObjectId),
|
|
19
|
-
tx.pure.string(args.name),
|
|
20
|
-
tx.pure.string(args.contentType),
|
|
21
|
-
tx.pure.u64(args.size),
|
|
22
|
-
tx.pure.address(args.allowlistId),
|
|
23
|
-
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
24
|
-
],
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Add a `file::new_public_file` call. Returns the new EncryptedFile (the
|
|
29
|
-
* `encrypted` flag is false). Follow with `share_file`.
|
|
30
|
-
*/
|
|
31
|
-
export function buildNewPublicFile(tx, args) {
|
|
32
|
-
const blobIdBytes = walrusBlobIdToBytes(args.blobId);
|
|
33
|
-
return tx.moveCall({
|
|
34
|
-
target: `${args.packageId}::file::new_public_file`,
|
|
35
|
-
arguments: [
|
|
36
|
-
tx.pure.vector("u8", Array.from(blobIdBytes)),
|
|
37
|
-
optionSomeId(tx, args.blobObjectId),
|
|
38
|
-
tx.pure.string(args.name),
|
|
39
|
-
tx.pure.string(args.contentType),
|
|
40
|
-
tx.pure.u64(args.size),
|
|
41
|
-
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
42
|
-
],
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
export function buildShareFile(tx, args) {
|
|
46
|
-
return tx.moveCall({
|
|
47
|
-
target: `${args.packageId}::file::share_file`,
|
|
48
|
-
arguments: [args.file],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
export function buildUpdateFileMetadata(tx, args) {
|
|
52
|
-
return tx.moveCall({
|
|
53
|
-
target: `${args.packageId}::file::update_metadata`,
|
|
54
|
-
arguments: [
|
|
55
|
-
tx.object(args.fileId),
|
|
56
|
-
tx.pure.string(args.name),
|
|
57
|
-
tx.pure.string(args.contentType),
|
|
58
|
-
],
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
export function buildTransferFileOwnership(tx, args) {
|
|
62
|
-
return tx.moveCall({
|
|
63
|
-
target: `${args.packageId}::file::transfer_ownership`,
|
|
64
|
-
arguments: [tx.object(args.fileId), tx.pure.address(args.newOwner)],
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
export function buildDeleteFile(tx, args) {
|
|
68
|
-
return tx.moveCall({
|
|
69
|
-
target: `${args.packageId}::file::delete_file`,
|
|
70
|
-
arguments: [tx.object(args.fileId)],
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Walrus blob IDs are 43-char URL-safe base64 strings carrying a 32-byte
|
|
75
|
-
* content digest. The Move layer stores them as `vector<u8>`; we decode the
|
|
76
|
-
* 32 bytes here for the PTB so on-chain reads match what Walrus returns.
|
|
77
|
-
*/
|
|
78
|
-
function walrusBlobIdToBytes(blobId) {
|
|
79
|
-
const base64 = blobId
|
|
80
|
-
.replace(/-/g, "+")
|
|
81
|
-
.replace(/_/g, "/");
|
|
82
|
-
const padded = base64 + "=".repeat((4 - (base64.length % 4)) % 4);
|
|
83
|
-
const binary = atob(padded);
|
|
84
|
-
const out = new Uint8Array(binary.length);
|
|
85
|
-
for (let i = 0; i < binary.length; i += 1) {
|
|
86
|
-
out[i] = binary.charCodeAt(i);
|
|
87
|
-
}
|
|
88
|
-
return out;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Build a Move `Option<ID>` argument. Sui's PTB layer does not have a native
|
|
92
|
-
* Option builder, so we go through the std::option helpers.
|
|
93
|
-
*/
|
|
94
|
-
function optionSomeId(tx, value) {
|
|
95
|
-
if (value === undefined) {
|
|
96
|
-
return tx.moveCall({
|
|
97
|
-
target: "0x1::option::none",
|
|
98
|
-
typeArguments: ["0x2::object::ID"],
|
|
99
|
-
arguments: [],
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return tx.moveCall({
|
|
103
|
-
target: "0x1::option::some",
|
|
104
|
-
typeArguments: ["0x2::object::ID"],
|
|
105
|
-
arguments: [tx.pure.id(value)],
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=file.js.map
|
package/dist/ptb/file.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/ptb/file.ts"],"names":[],"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,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;KAC9B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event type constants and pure reconciliation helpers for the file +
|
|
3
|
-
* allowlist modules. Designed for consumers integrating a Sui indexer of
|
|
4
|
-
* their choice: fetch events from your indexer, pass them here, get back a
|
|
5
|
-
* deduplicated `EncryptedFileSummary[]` that reflects the current state.
|
|
6
|
-
*
|
|
7
|
-
* The SDK intentionally does NOT ship an event-fetching client. Sui v2 gRPC
|
|
8
|
-
* has no historical event query method, and the legacy `suix_queryEvents`
|
|
9
|
-
* JSON-RPC endpoint is on Mysten's deprecation track. Picking an indexer
|
|
10
|
-
* (Mysten public, self-hosted, third-party) is a consumer concern; the SDK
|
|
11
|
-
* owns the parsing + reconciliation logic which is the morse-contract-
|
|
12
|
-
* specific part.
|
|
13
|
-
*
|
|
14
|
-
* Pagination, retention, auth, and CORS are entirely the consumer's
|
|
15
|
-
* responsibility; they live with the indexer client, not here.
|
|
16
|
-
*/
|
|
17
|
-
import type { EncryptedFileSummary, PackageId, SuiAddress } from "../types.js";
|
|
18
|
-
/** Fully-qualified event type strings emitted by the `file` and `allowlist` modules. */
|
|
19
|
-
export interface FilesEventTypes {
|
|
20
|
-
readonly FileCreated: string;
|
|
21
|
-
readonly FileDeleted: string;
|
|
22
|
-
readonly FileMetadataUpdated: string;
|
|
23
|
-
readonly FileOwnershipTransferred: string;
|
|
24
|
-
readonly AllowlistCreated: string;
|
|
25
|
-
readonly AllowlistDeleted: string;
|
|
26
|
-
readonly MemberAdded: string;
|
|
27
|
-
readonly MemberRemoved: string;
|
|
28
|
-
readonly CapTransferred: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Build the fully-qualified event type strings for a given file-events
|
|
32
|
-
* origin package id. The origin id is the package where the event structs
|
|
33
|
-
* were FIRST defined, which is independent of `config.packageId` (the
|
|
34
|
-
* current published-at, which moves on every upgrade).
|
|
35
|
-
*
|
|
36
|
-
* Pass `config.filesEventOriginPackageId` here. The SDK ships the testnet
|
|
37
|
-
* default in `morseConfig`; custom deployments supply their own.
|
|
38
|
-
*
|
|
39
|
-
* @throws {ValidationError} If `packageId` is missing.
|
|
40
|
-
*/
|
|
41
|
-
export declare function buildFilesEventTypes(packageId: PackageId): FilesEventTypes;
|
|
42
|
-
/**
|
|
43
|
-
* Minimal event shape consumed by the reconcile helpers. Compatible with
|
|
44
|
-
* Sui RPC `SuiEvent` and most indexer event payloads. Map your indexer's
|
|
45
|
-
* output to this shape before calling.
|
|
46
|
-
*/
|
|
47
|
-
export interface FilesEventInput {
|
|
48
|
-
/** Fully-qualified event type, e.g. `${pkg}::file::FileCreated`. */
|
|
49
|
-
readonly type: string;
|
|
50
|
-
/** Decoded event payload (the Move struct's fields, snake_case). */
|
|
51
|
-
readonly parsedJson: unknown;
|
|
52
|
-
/**
|
|
53
|
-
* Transaction timestamp in milliseconds, sourced from the event
|
|
54
|
-
* envelope. May be null on pending events (skip those; they do not
|
|
55
|
-
* count as confirmed history).
|
|
56
|
-
*/
|
|
57
|
-
readonly timestampMs?: string | number | null;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Reconcile a stream of Sui events into the current set of files owned by
|
|
61
|
-
* `address`. Caller is responsible for fetching events (typically via an
|
|
62
|
-
* indexer); pass all `FileCreated`, `FileOwnershipTransferred`, and
|
|
63
|
-
* `FileDeleted` events from the event types built via `buildFilesEventTypes`.
|
|
64
|
-
*
|
|
65
|
-
* Order-independence: events are sorted internally by `timestampMs` before
|
|
66
|
-
* reconciliation, so passing them in arbitrary order produces the same
|
|
67
|
-
* result. Events with `timestampMs === null` are skipped (unconfirmed).
|
|
68
|
-
*
|
|
69
|
-
* Best-effort: if `FileOwnershipTransferred` references a `file` whose
|
|
70
|
-
* `FileCreated` is missing from the input (e.g. retention pruning), the
|
|
71
|
-
* incoming transfer is dropped silently; there is no way to recover the
|
|
72
|
-
* metadata without the original event. Increase the indexer's event
|
|
73
|
-
* window if completeness is critical.
|
|
74
|
-
*/
|
|
75
|
-
export declare function reconcileFilesOwnedBy(events: readonly FilesEventInput[], address: SuiAddress, eventTypes: FilesEventTypes): EncryptedFileSummary[];
|
|
76
|
-
/**
|
|
77
|
-
* Reconcile a stream of events into the current set of files where
|
|
78
|
-
* `address` has decrypt access via allowlist membership. Caller passes
|
|
79
|
-
* `MemberAdded`, `MemberRemoved`, `AllowlistDeleted`, `FileCreated`, and
|
|
80
|
-
* `FileDeleted` events.
|
|
81
|
-
*
|
|
82
|
-
* Same best-effort guarantees as `reconcileFilesOwnedBy`. Files referencing
|
|
83
|
-
* an `AllowlistDeleted` allowlist are dropped (the on-chain `seal_approve`
|
|
84
|
-
* dry-run would fail for them anyway).
|
|
85
|
-
*/
|
|
86
|
-
export declare function reconcileFilesAccessibleBy(events: readonly FilesEventInput[], address: SuiAddress, eventTypes: FilesEventTypes): EncryptedFileSummary[];
|
|
87
|
-
//# sourceMappingURL=files-events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files-events.d.ts","sourceRoot":"","sources":["../../src/read/files-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAGX,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,MAAM,aAAa,CAAC;AAErB,wFAAwF;AACxF,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,eAAe,CAkB1E;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC9C;AAmCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,GACzB,oBAAoB,EAAE,CA+BxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,GACzB,oBAAoB,EAAE,CA2CxB"}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event type constants and pure reconciliation helpers for the file +
|
|
3
|
-
* allowlist modules. Designed for consumers integrating a Sui indexer of
|
|
4
|
-
* their choice: fetch events from your indexer, pass them here, get back a
|
|
5
|
-
* deduplicated `EncryptedFileSummary[]` that reflects the current state.
|
|
6
|
-
*
|
|
7
|
-
* The SDK intentionally does NOT ship an event-fetching client. Sui v2 gRPC
|
|
8
|
-
* has no historical event query method, and the legacy `suix_queryEvents`
|
|
9
|
-
* JSON-RPC endpoint is on Mysten's deprecation track. Picking an indexer
|
|
10
|
-
* (Mysten public, self-hosted, third-party) is a consumer concern; the SDK
|
|
11
|
-
* owns the parsing + reconciliation logic which is the morse-contract-
|
|
12
|
-
* specific part.
|
|
13
|
-
*
|
|
14
|
-
* Pagination, retention, auth, and CORS are entirely the consumer's
|
|
15
|
-
* responsibility; they live with the indexer client, not here.
|
|
16
|
-
*/
|
|
17
|
-
import { ValidationError } from "../errors.js";
|
|
18
|
-
/**
|
|
19
|
-
* Build the fully-qualified event type strings for a given file-events
|
|
20
|
-
* origin package id. The origin id is the package where the event structs
|
|
21
|
-
* were FIRST defined, which is independent of `config.packageId` (the
|
|
22
|
-
* current published-at, which moves on every upgrade).
|
|
23
|
-
*
|
|
24
|
-
* Pass `config.filesEventOriginPackageId` here. The SDK ships the testnet
|
|
25
|
-
* default in `morseConfig`; custom deployments supply their own.
|
|
26
|
-
*
|
|
27
|
-
* @throws {ValidationError} If `packageId` is missing.
|
|
28
|
-
*/
|
|
29
|
-
export function buildFilesEventTypes(packageId) {
|
|
30
|
-
if (!packageId) {
|
|
31
|
-
throw new ValidationError("buildFilesEventTypes: packageId is required (pass config.filesEventOriginPackageId)", "packageId");
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
FileCreated: `${packageId}::file::FileCreated`,
|
|
35
|
-
FileDeleted: `${packageId}::file::FileDeleted`,
|
|
36
|
-
FileMetadataUpdated: `${packageId}::file::FileMetadataUpdated`,
|
|
37
|
-
FileOwnershipTransferred: `${packageId}::file::FileOwnershipTransferred`,
|
|
38
|
-
AllowlistCreated: `${packageId}::allowlist::AllowlistCreated`,
|
|
39
|
-
AllowlistDeleted: `${packageId}::allowlist::AllowlistDeleted`,
|
|
40
|
-
MemberAdded: `${packageId}::allowlist::MemberAdded`,
|
|
41
|
-
MemberRemoved: `${packageId}::allowlist::MemberRemoved`,
|
|
42
|
-
CapTransferred: `${packageId}::allowlist::CapTransferred`,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Reconcile a stream of Sui events into the current set of files owned by
|
|
47
|
-
* `address`. Caller is responsible for fetching events (typically via an
|
|
48
|
-
* indexer); pass all `FileCreated`, `FileOwnershipTransferred`, and
|
|
49
|
-
* `FileDeleted` events from the event types built via `buildFilesEventTypes`.
|
|
50
|
-
*
|
|
51
|
-
* Order-independence: events are sorted internally by `timestampMs` before
|
|
52
|
-
* reconciliation, so passing them in arbitrary order produces the same
|
|
53
|
-
* result. Events with `timestampMs === null` are skipped (unconfirmed).
|
|
54
|
-
*
|
|
55
|
-
* Best-effort: if `FileOwnershipTransferred` references a `file` whose
|
|
56
|
-
* `FileCreated` is missing from the input (e.g. retention pruning), the
|
|
57
|
-
* incoming transfer is dropped silently; there is no way to recover the
|
|
58
|
-
* metadata without the original event. Increase the indexer's event
|
|
59
|
-
* window if completeness is critical.
|
|
60
|
-
*/
|
|
61
|
-
export function reconcileFilesOwnedBy(events, address, eventTypes) {
|
|
62
|
-
const known = new Map();
|
|
63
|
-
const owners = new Map();
|
|
64
|
-
const sorted = sortByTimestamp(events);
|
|
65
|
-
for (const event of sorted) {
|
|
66
|
-
const ts = parseTimestampMs(event.timestampMs);
|
|
67
|
-
if (ts === null)
|
|
68
|
-
continue;
|
|
69
|
-
if (event.type === eventTypes.FileCreated) {
|
|
70
|
-
const payload = event.parsedJson;
|
|
71
|
-
const summary = payloadToSummary(payload, ts);
|
|
72
|
-
known.set(summary.id, summary);
|
|
73
|
-
owners.set(summary.id, summary.owner);
|
|
74
|
-
}
|
|
75
|
-
else if (event.type === eventTypes.FileOwnershipTransferred) {
|
|
76
|
-
const payload = event.parsedJson;
|
|
77
|
-
owners.set(payload.file, payload.new_owner);
|
|
78
|
-
}
|
|
79
|
-
else if (event.type === eventTypes.FileDeleted) {
|
|
80
|
-
const payload = event.parsedJson;
|
|
81
|
-
known.delete(payload.file);
|
|
82
|
-
owners.delete(payload.file);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const out = [];
|
|
86
|
-
for (const [fileId, summary] of known) {
|
|
87
|
-
if (owners.get(fileId) === address) {
|
|
88
|
-
out.push(summary);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return out.sort((a, b) => b.createdAtMs - a.createdAtMs);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Reconcile a stream of events into the current set of files where
|
|
95
|
-
* `address` has decrypt access via allowlist membership. Caller passes
|
|
96
|
-
* `MemberAdded`, `MemberRemoved`, `AllowlistDeleted`, `FileCreated`, and
|
|
97
|
-
* `FileDeleted` events.
|
|
98
|
-
*
|
|
99
|
-
* Same best-effort guarantees as `reconcileFilesOwnedBy`. Files referencing
|
|
100
|
-
* an `AllowlistDeleted` allowlist are dropped (the on-chain `seal_approve`
|
|
101
|
-
* dry-run would fail for them anyway).
|
|
102
|
-
*/
|
|
103
|
-
export function reconcileFilesAccessibleBy(events, address, eventTypes) {
|
|
104
|
-
const memberAllowlists = new Set();
|
|
105
|
-
const deletedAllowlists = new Set();
|
|
106
|
-
const knownFiles = new Map();
|
|
107
|
-
const sorted = sortByTimestamp(events);
|
|
108
|
-
for (const event of sorted) {
|
|
109
|
-
const ts = parseTimestampMs(event.timestampMs);
|
|
110
|
-
if (ts === null)
|
|
111
|
-
continue;
|
|
112
|
-
if (event.type === eventTypes.MemberAdded) {
|
|
113
|
-
const payload = event.parsedJson;
|
|
114
|
-
if (payload.member === address) {
|
|
115
|
-
memberAllowlists.add(payload.allowlist);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else if (event.type === eventTypes.MemberRemoved) {
|
|
119
|
-
const payload = event.parsedJson;
|
|
120
|
-
if (payload.member === address) {
|
|
121
|
-
memberAllowlists.delete(payload.allowlist);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else if (event.type === eventTypes.AllowlistDeleted) {
|
|
125
|
-
const payload = event.parsedJson;
|
|
126
|
-
deletedAllowlists.add(payload.allowlist);
|
|
127
|
-
memberAllowlists.delete(payload.allowlist);
|
|
128
|
-
}
|
|
129
|
-
else if (event.type === eventTypes.FileCreated) {
|
|
130
|
-
const payload = event.parsedJson;
|
|
131
|
-
const summary = payloadToSummary(payload, ts);
|
|
132
|
-
knownFiles.set(summary.id, summary);
|
|
133
|
-
}
|
|
134
|
-
else if (event.type === eventTypes.FileDeleted) {
|
|
135
|
-
const payload = event.parsedJson;
|
|
136
|
-
knownFiles.delete(payload.file);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const out = [];
|
|
140
|
-
for (const summary of knownFiles.values()) {
|
|
141
|
-
if (summary.allowlistId === null)
|
|
142
|
-
continue;
|
|
143
|
-
const allowlistKey = summary.allowlistId;
|
|
144
|
-
if (deletedAllowlists.has(allowlistKey))
|
|
145
|
-
continue;
|
|
146
|
-
if (!memberAllowlists.has(allowlistKey))
|
|
147
|
-
continue;
|
|
148
|
-
out.push(summary);
|
|
149
|
-
}
|
|
150
|
-
return out.sort((a, b) => b.createdAtMs - a.createdAtMs);
|
|
151
|
-
}
|
|
152
|
-
// internal
|
|
153
|
-
function sortByTimestamp(events) {
|
|
154
|
-
return [...events].sort((a, b) => {
|
|
155
|
-
const ta = parseTimestampMs(a.timestampMs) ?? Number.POSITIVE_INFINITY;
|
|
156
|
-
const tb = parseTimestampMs(b.timestampMs) ?? Number.POSITIVE_INFINITY;
|
|
157
|
-
return ta - tb;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function parseTimestampMs(value) {
|
|
161
|
-
if (value === null || value === undefined)
|
|
162
|
-
return null;
|
|
163
|
-
const num = typeof value === "string" ? Number(value) : value;
|
|
164
|
-
return Number.isFinite(num) ? num : null;
|
|
165
|
-
}
|
|
166
|
-
function payloadToSummary(payload, createdAtMs) {
|
|
167
|
-
return {
|
|
168
|
-
kind: "summary",
|
|
169
|
-
id: payload.file,
|
|
170
|
-
owner: payload.owner,
|
|
171
|
-
name: payload.name,
|
|
172
|
-
contentType: payload.content_type,
|
|
173
|
-
size: typeof payload.size === "string" ? Number(payload.size) : payload.size,
|
|
174
|
-
encrypted: payload.encrypted,
|
|
175
|
-
allowlistId: extractAllowlistId(payload.allowlist_id),
|
|
176
|
-
createdAtMs,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* `Option<ID>` in Move serializes as either a plain string (the address),
|
|
181
|
-
* `null`, or `{ vec: [address] | [] }` depending on the indexer's decoder.
|
|
182
|
-
* Normalize all three to `AllowlistId | null`.
|
|
183
|
-
*/
|
|
184
|
-
function extractAllowlistId(raw) {
|
|
185
|
-
if (raw === null || raw === undefined)
|
|
186
|
-
return null;
|
|
187
|
-
if (typeof raw === "string")
|
|
188
|
-
return raw;
|
|
189
|
-
if (Array.isArray(raw.vec) && raw.vec.length > 0 && raw.vec[0]) {
|
|
190
|
-
return raw.vec[0];
|
|
191
|
-
}
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
//# sourceMappingURL=files-events.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files-events.js","sourceRoot":"","sources":["../../src/read/files-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAsB/C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAoB;IACxD,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,MAAM,IAAI,eAAe,CACxB,qFAAqF,EACrF,WAAW,CACX,CAAC;IACH,CAAC;IACD,OAAO;QACN,WAAW,EAAE,GAAG,SAAS,qBAAqB;QAC9C,WAAW,EAAE,GAAG,SAAS,qBAAqB;QAC9C,mBAAmB,EAAE,GAAG,SAAS,6BAA6B;QAC9D,wBAAwB,EAAE,GAAG,SAAS,kCAAkC;QACxE,gBAAgB,EAAE,GAAG,SAAS,+BAA+B;QAC7D,gBAAgB,EAAE,GAAG,SAAS,+BAA+B;QAC7D,WAAW,EAAE,GAAG,SAAS,0BAA0B;QACnD,aAAa,EAAE,GAAG,SAAS,4BAA4B;QACvD,cAAc,EAAE,GAAG,SAAS,6BAA6B;KACzD,CAAC;AACH,CAAC;AAqDD;;;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AAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;QACvE,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,WAAW,EAAE,kBAAkB,CAAC,OAAO,CAAC,YAAY,CAAC;QACrD,WAAW;KACX,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAC1B,GAA+C;IAE/C,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACnD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAA6B,CAAC;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAA2B,CAAC;IAC7C,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RPC-backed reader for the allowlist + file modules. EncryptedFile objects
|
|
3
|
-
* are shared (every successful create_*_file flow calls share_file), so
|
|
4
|
-
* "list files owned by an address" is not exposed at the RPC layer — there
|
|
5
|
-
* is no on-chain owner field for `listOwnedObjects` to filter on. Listing
|
|
6
|
-
* accessible files requires event-based indexing; a future indexer-backed
|
|
7
|
-
* implementation will expose it through this same interface.
|
|
8
|
-
*/
|
|
9
|
-
import type { ObjectReader } from "../clients.js";
|
|
10
|
-
import type { Allowlist, AllowlistCap, AllowlistId, EncryptedFile, EncryptedFileId, PackageId, SuiAddress } from "../types.js";
|
|
11
|
-
/** Result of a single page of `listAllowlistCapsOwnedBy`. */
|
|
12
|
-
export interface AllowlistCapListPage {
|
|
13
|
-
readonly results: readonly AllowlistCap[];
|
|
14
|
-
readonly nextCursor: string | null;
|
|
15
|
-
}
|
|
16
|
-
/** Options for paginated list calls in `FilesReader`. */
|
|
17
|
-
export interface FilesListOptions {
|
|
18
|
-
readonly limit?: number;
|
|
19
|
-
readonly cursor?: string;
|
|
20
|
-
readonly signal?: AbortSignal;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Read-only access to the files domain: Allowlist objects, EncryptedFile
|
|
24
|
-
* metadata records, and the AllowlistCaps owned by a given address.
|
|
25
|
-
*
|
|
26
|
-
* Notably absent: there is no `listEncryptedFilesOwnedBy(address)` because
|
|
27
|
-
* EncryptedFile is a shared object with no on-chain owner field; `address`
|
|
28
|
-
* cannot index into anything. List the AllowlistCaps an address holds
|
|
29
|
-
* (admin access), then fetch each cap's `allowlistId` and inspect the
|
|
30
|
-
* allowlist's `members` set, or subscribe to the contract's events.
|
|
31
|
-
*/
|
|
32
|
-
export interface FilesReader {
|
|
33
|
-
getAllowlist(id: AllowlistId, signal?: AbortSignal): Promise<Allowlist>;
|
|
34
|
-
getEncryptedFile(id: EncryptedFileId, signal?: AbortSignal): Promise<EncryptedFile>;
|
|
35
|
-
listAllowlistCapsOwnedBy(address: SuiAddress, options?: FilesListOptions): Promise<AllowlistCapListPage>;
|
|
36
|
-
}
|
|
37
|
-
export declare class RpcFilesReader implements FilesReader {
|
|
38
|
-
private readonly client;
|
|
39
|
-
private readonly typePackageId;
|
|
40
|
-
constructor(client: ObjectReader, typePackageId: PackageId);
|
|
41
|
-
/**
|
|
42
|
-
* Build a reader from a morse package config. Uses `packageId` (the
|
|
43
|
-
* current published-at) for type filters because the allowlist + file
|
|
44
|
-
* modules were introduced in the v2 upgrade — Sui identifies a type by
|
|
45
|
-
* the package id where it was DEFINED, not by the package's genesis
|
|
46
|
-
* original-id. This differs from `RpcPublicationReader`, which uses
|
|
47
|
-
* `originalPackageId` because publication / collection / entry were
|
|
48
|
-
* defined in v1.
|
|
49
|
-
*/
|
|
50
|
-
static fromMorseConfig(config: {
|
|
51
|
-
packageId: PackageId;
|
|
52
|
-
originalPackageId?: PackageId;
|
|
53
|
-
}, client: ObjectReader): RpcFilesReader;
|
|
54
|
-
getAllowlist(id: AllowlistId, signal?: AbortSignal): Promise<Allowlist>;
|
|
55
|
-
getEncryptedFile(id: EncryptedFileId, signal?: AbortSignal): Promise<EncryptedFile>;
|
|
56
|
-
listAllowlistCapsOwnedBy(address: SuiAddress, options?: FilesListOptions): Promise<AllowlistCapListPage>;
|
|
57
|
-
private callClient;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=files-reader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files-reader.d.ts","sourceRoot":"","sources":["../../src/read/files-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAUlD,OAAO,KAAK,EACX,SAAS,EACT,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,EACf,SAAS,EACT,UAAU,EACV,MAAM,aAAa,CAAC;AAIrB,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC3B,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACxE,gBAAgB,CACf,EAAE,EAAE,eAAe,EACnB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,C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