@arcadiasystems/morse-sdk 0.1.4 → 0.3.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 +118 -0
- package/README.md +14 -2
- package/dist/codecs.d.ts +7 -1
- package/dist/codecs.d.ts.map +1 -1
- package/dist/codecs.js +12 -0
- package/dist/codecs.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -1
- 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 +2 -0
- package/dist/errors.format.js.map +1 -1
- package/dist/errors.js +44 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/ops/allowlist.d.ts +79 -0
- package/dist/ops/allowlist.d.ts.map +1 -0
- package/dist/ops/allowlist.js +122 -0
- package/dist/ops/allowlist.js.map +1 -0
- package/dist/ops/file-from-bytes.d.ts +84 -0
- package/dist/ops/file-from-bytes.d.ts.map +1 -0
- package/dist/ops/file-from-bytes.js +133 -0
- package/dist/ops/file-from-bytes.js.map +1 -0
- package/dist/ops/file.d.ts +88 -0
- package/dist/ops/file.d.ts.map +1 -0
- package/dist/ops/file.js +142 -0
- package/dist/ops/file.js.map +1 -0
- package/dist/ops/index.d.ts +3 -0
- package/dist/ops/index.d.ts.map +1 -1
- package/dist/ops/index.js +3 -0
- package/dist/ops/index.js.map +1 -1
- package/dist/ptb/allowlist.d.ts +65 -0
- package/dist/ptb/allowlist.d.ts.map +1 -0
- package/dist/ptb/allowlist.js +75 -0
- package/dist/ptb/allowlist.js.map +1 -0
- package/dist/ptb/file.d.ts +58 -0
- package/dist/ptb/file.d.ts.map +1 -0
- package/dist/ptb/file.js +108 -0
- package/dist/ptb/file.js.map +1 -0
- package/dist/read/files-events.d.ts +87 -0
- package/dist/read/files-events.d.ts.map +1 -0
- package/dist/read/files-events.js +194 -0
- package/dist/read/files-events.js.map +1 -0
- package/dist/read/files-reader.d.ts +59 -0
- package/dist/read/files-reader.d.ts.map +1 -0
- package/dist/read/files-reader.js +247 -0
- package/dist/read/files-reader.js.map +1 -0
- package/dist/read/index.d.ts +2 -0
- package/dist/read/index.d.ts.map +1 -1
- package/dist/read/index.js +2 -0
- package/dist/read/index.js.map +1 -1
- package/dist/seal/adapter.d.ts +22 -1
- package/dist/seal/adapter.d.ts.map +1 -1
- package/dist/seal/allowlist-identity.d.ts +36 -0
- package/dist/seal/allowlist-identity.d.ts.map +1 -0
- package/dist/seal/allowlist-identity.js +81 -0
- package/dist/seal/allowlist-identity.js.map +1 -0
- package/dist/seal/default-adapter.d.ts +16 -1
- package/dist/seal/default-adapter.d.ts.map +1 -1
- package/dist/seal/default-adapter.js +56 -1
- package/dist/seal/default-adapter.js.map +1 -1
- package/dist/seal/index.d.ts +2 -1
- package/dist/seal/index.d.ts.map +1 -1
- package/dist/seal/index.js +1 -0
- package/dist/seal/index.js.map +1 -1
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/dist/wallets/keypair-adapter.d.ts.map +1 -1
- package/dist/wallets/keypair-adapter.js +2 -0
- package/dist/wallets/keypair-adapter.js.map +1 -1
- package/package.json +1 -1
package/dist/ops/file.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level file ops: build a PTB, sign and execute via the wallet adapter,
|
|
3
|
+
* parse the receipt into a typed result.
|
|
4
|
+
*
|
|
5
|
+
* Encrypted-file creation here registers the metadata record assuming the
|
|
6
|
+
* encrypted bytes are already on Walrus. The all-in-one upload+register
|
|
7
|
+
* flow is `uploadEncryptedFileFromBytes` in `file-from-bytes.ts`.
|
|
8
|
+
*/
|
|
9
|
+
import { Transaction, } from "@mysten/sui/transactions";
|
|
10
|
+
import { toEncryptedFileId } from "../codecs.js";
|
|
11
|
+
import { ValidationError } from "../errors.js";
|
|
12
|
+
import { buildDeleteFile, buildNewEncryptedFile, buildNewPublicFile, buildShareFile, buildTransferFileOwnership, buildUpdateFileMetadata, } from "../ptb/file.js";
|
|
13
|
+
import { findCreatedId } from "./internal.js";
|
|
14
|
+
const MAX_FILE_NAME_LENGTH = 256;
|
|
15
|
+
const MAX_CONTENT_TYPE_LENGTH = 255;
|
|
16
|
+
/**
|
|
17
|
+
* Register on-chain metadata for an encrypted file already uploaded to Walrus.
|
|
18
|
+
* The bytes at `blobId` MUST be Seal-encrypted under an identity built from
|
|
19
|
+
* `allowlistId` (see `buildAllowlistSealId`); otherwise consumers will fail
|
|
20
|
+
* to decrypt. The SDK does not verify this binding.
|
|
21
|
+
*
|
|
22
|
+
* @throws {ValidationError} If `name` or `contentType` is empty or exceeds length limits.
|
|
23
|
+
* @throws {ContractAbortError} On Move abort (e.g. empty blob_id).
|
|
24
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
25
|
+
*/
|
|
26
|
+
export async function createEncryptedFile(adapter, config, args) {
|
|
27
|
+
validateFileFields(args.name, args.contentType);
|
|
28
|
+
const tx = new Transaction();
|
|
29
|
+
const created = buildNewEncryptedFile(tx, {
|
|
30
|
+
packageId: config.packageId,
|
|
31
|
+
blobId: args.blobId,
|
|
32
|
+
...(args.blobObjectId === undefined
|
|
33
|
+
? {}
|
|
34
|
+
: { blobObjectId: args.blobObjectId }),
|
|
35
|
+
name: args.name,
|
|
36
|
+
contentType: args.contentType,
|
|
37
|
+
size: args.size,
|
|
38
|
+
allowlistId: args.allowlistId,
|
|
39
|
+
});
|
|
40
|
+
const fileArg = created;
|
|
41
|
+
buildShareFile(tx, { packageId: config.packageId, file: fileArg });
|
|
42
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
43
|
+
// See ops/allowlist.ts: file::EncryptedFile was introduced in v2; type
|
|
44
|
+
// identity is rooted at config.packageId, not originalPackageId.
|
|
45
|
+
const typePrefix = config.packageId;
|
|
46
|
+
return {
|
|
47
|
+
digest: receipt.digest,
|
|
48
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
49
|
+
fileId: toEncryptedFileId(findCreatedId(receipt, `${typePrefix}::file::EncryptedFile`)),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Register on-chain metadata for an unencrypted file. The bytes at `blobId`
|
|
54
|
+
* are publicly readable via the Walrus aggregator.
|
|
55
|
+
*/
|
|
56
|
+
export async function createPublicFile(adapter, config, args) {
|
|
57
|
+
validateFileFields(args.name, args.contentType);
|
|
58
|
+
const tx = new Transaction();
|
|
59
|
+
const created = buildNewPublicFile(tx, {
|
|
60
|
+
packageId: config.packageId,
|
|
61
|
+
blobId: args.blobId,
|
|
62
|
+
...(args.blobObjectId === undefined
|
|
63
|
+
? {}
|
|
64
|
+
: { blobObjectId: args.blobObjectId }),
|
|
65
|
+
name: args.name,
|
|
66
|
+
contentType: args.contentType,
|
|
67
|
+
size: args.size,
|
|
68
|
+
});
|
|
69
|
+
const fileArg = created;
|
|
70
|
+
buildShareFile(tx, { packageId: config.packageId, file: fileArg });
|
|
71
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
72
|
+
// See ops/allowlist.ts: file::EncryptedFile was introduced in v2; type
|
|
73
|
+
// identity is rooted at config.packageId, not originalPackageId.
|
|
74
|
+
const typePrefix = config.packageId;
|
|
75
|
+
return {
|
|
76
|
+
digest: receipt.digest,
|
|
77
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
78
|
+
fileId: toEncryptedFileId(findCreatedId(receipt, `${typePrefix}::file::EncryptedFile`)),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Update the file's `name` and `content_type`. Other fields are immutable
|
|
83
|
+
* post-creation; create a new file record to swap the blob or change the
|
|
84
|
+
* allowlist. Owner only (sender must equal `file.owner` on-chain).
|
|
85
|
+
*/
|
|
86
|
+
export async function updateFileMetadata(adapter, config, args) {
|
|
87
|
+
validateFileFields(args.name, args.contentType);
|
|
88
|
+
const tx = new Transaction();
|
|
89
|
+
buildUpdateFileMetadata(tx, {
|
|
90
|
+
packageId: config.packageId,
|
|
91
|
+
fileId: args.fileId,
|
|
92
|
+
name: args.name,
|
|
93
|
+
contentType: args.contentType,
|
|
94
|
+
});
|
|
95
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
96
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Transfer the metadata-mutation right to a new address. Decryption access
|
|
100
|
+
* is governed separately by the file's allowlist; the new owner must be
|
|
101
|
+
* added to that allowlist (and the previous owner removed, if desired) by
|
|
102
|
+
* the Cap holder. The two operations can be composed in one PTB by the
|
|
103
|
+
* caller if both rights need to move together.
|
|
104
|
+
*/
|
|
105
|
+
export async function transferFileOwnership(adapter, config, args) {
|
|
106
|
+
const tx = new Transaction();
|
|
107
|
+
buildTransferFileOwnership(tx, {
|
|
108
|
+
packageId: config.packageId,
|
|
109
|
+
fileId: args.fileId,
|
|
110
|
+
newOwner: args.newOwner,
|
|
111
|
+
});
|
|
112
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
113
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Delete the on-chain metadata record. Does NOT delete the Walrus blob;
|
|
117
|
+
* that follows the Walrus lease lifecycle independently.
|
|
118
|
+
*/
|
|
119
|
+
export async function deleteFile(adapter, config, args) {
|
|
120
|
+
const tx = new Transaction();
|
|
121
|
+
buildDeleteFile(tx, {
|
|
122
|
+
packageId: config.packageId,
|
|
123
|
+
fileId: args.fileId,
|
|
124
|
+
});
|
|
125
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
126
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
127
|
+
}
|
|
128
|
+
function validateFileFields(name, contentType) {
|
|
129
|
+
if (name.length === 0) {
|
|
130
|
+
throw new ValidationError("File name cannot be empty", "name");
|
|
131
|
+
}
|
|
132
|
+
if (name.length > MAX_FILE_NAME_LENGTH) {
|
|
133
|
+
throw new ValidationError(`File name exceeds ${MAX_FILE_NAME_LENGTH} chars`, "name");
|
|
134
|
+
}
|
|
135
|
+
if (contentType.length === 0) {
|
|
136
|
+
throw new ValidationError("Content type cannot be empty", "contentType");
|
|
137
|
+
}
|
|
138
|
+
if (contentType.length > MAX_CONTENT_TYPE_LENGTH) {
|
|
139
|
+
throw new ValidationError(`Content type exceeds ${MAX_CONTENT_TYPE_LENGTH} chars`, "contentType");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/ops/file.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,WAAW,GAEX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACN,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,0BAA0B,EAC1B,uBAAuB,GACvB,MAAM,gBAAgB,CAAC;AASxB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAkBpC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,OAAsB,EACtB,MAA0B,EAC1B,IAA6B;IAE7B,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAA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E,OAAO,CAAC,WAAW,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY,EAAE,WAAmB;IAC5D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,eAAe,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,GAAG,oBAAoB,EAAE,CAAC;QACxC,MAAM,IAAI,eAAe,CACxB,qBAAqB,oBAAoB,QAAQ,EACjD,MAAM,CACN,CAAC;IACH,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,eAAe,CAAC,8BAA8B,EAAE,aAAa,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,GAAG,uBAAuB,EAAE,CAAC;QAClD,MAAM,IAAI,eAAe,CACxB,wBAAwB,uBAAuB,QAAQ,EACvD,aAAa,CACb,CAAC;IACH,CAAC;AACF,CAAC"}
|
package/dist/ops/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public barrel for the high-level ops layer.
|
|
3
3
|
*/
|
|
4
|
+
export { type AddMemberArgs, type AllowlistOpResult, addMember, type CreateAllowlistArgs, type CreateAllowlistResult, createAllowlist, type DeleteAllowlistArgs, deleteAllowlist, type RemoveMemberArgs, removeMember, type TransferAllowlistCapArgs, transferAllowlistCap, } from "./allowlist.js";
|
|
4
5
|
export { type DestroyPublisherCapArgs, type DestroyPublisherCapResult, destroyPublisherCap, type IssuePublisherCapArgs, type IssuePublisherCapResult, issuePublisherCap, type RevokePublisherCapArgs, type RevokePublisherCapResult, revokePublisherCap, type TransferPublisherCapArgs, type TransferPublisherCapResult, transferPublisherCap, } from "./cap.js";
|
|
5
6
|
export { type CreateCollectionArgs, type CreateCollectionResult, createCollection, type DeleteCollectionArgs, type DeleteCollectionResult, deleteCollection, } from "./collection.js";
|
|
6
7
|
export { type AddEncryptedEntryArgs, type AddEntryArgs, type AddEntryResult, type AppendDraftRevisionArgs, type AppendEncryptedDraftRevisionArgs, addEncryptedEntry, addEntry, appendDraftRevision, appendEncryptedDraftRevision, type DeleteEntryArgs, type DeleteEntryResult, deleteEntry, type PublishDirectArgs, type PublishFromDraftArgs, publishDirect, publishFromDraft, type RevisionAppendResult, } from "./entry.js";
|
|
7
8
|
export { type AddEncryptedEntryFromBytesArgs, type AddEntryFromBytesArgs, type AddEntryFromBytesResult, addEncryptedEntryFromBytes, addEntryFromBytes, type ProgressCallback, type ProgressEvent, } from "./entry-from-bytes.js";
|
|
9
|
+
export { type CreateEncryptedFileArgs, type CreateFileResult, type CreatePublicFileArgs, createEncryptedFile, createPublicFile, type DeleteFileArgs, deleteFile, type FileOpResult, type TransferFileOwnershipArgs, transferFileOwnership, type UpdateFileMetadataArgs, updateFileMetadata, } from "./file.js";
|
|
10
|
+
export { type FileUploadProgressCallback, type FileUploadProgressEvent, type UploadEncryptedFileFromBytesArgs, type UploadFileResult, type UploadPublicFileFromBytesArgs, uploadEncryptedFileFromBytes, uploadPublicFileFromBytes, } from "./file-from-bytes.js";
|
|
8
11
|
export { type CreatePublicationArgs, type CreatePublicationResult, createPublication, type DeletePublicationArgs, type DeletePublicationResult, deletePublication, type PublicationConfig, type TransferOwnershipArgs, type TransferOwnershipResult, transferOwnership, } from "./publication.js";
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ops/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B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ACnB,OAAO,EACN,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,4BAA4B,EAC5B,yBAAyB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,iBAAiB,GACjB,MAAM,kBAAkB,CAAC"}
|
package/dist/ops/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public barrel for the high-level ops layer.
|
|
3
3
|
*/
|
|
4
|
+
export { addMember, createAllowlist, deleteAllowlist, removeMember, transferAllowlistCap, } from "./allowlist.js";
|
|
4
5
|
export { destroyPublisherCap, issuePublisherCap, revokePublisherCap, transferPublisherCap, } from "./cap.js";
|
|
5
6
|
export { createCollection, deleteCollection, } from "./collection.js";
|
|
6
7
|
export { addEncryptedEntry, addEntry, appendDraftRevision, appendEncryptedDraftRevision, deleteEntry, publishDirect, publishFromDraft, } from "./entry.js";
|
|
7
8
|
export { addEncryptedEntryFromBytes, addEntryFromBytes, } from "./entry-from-bytes.js";
|
|
9
|
+
export { createEncryptedFile, createPublicFile, deleteFile, transferFileOwnership, updateFileMetadata, } from "./file.js";
|
|
10
|
+
export { uploadEncryptedFileFromBytes, uploadPublicFileFromBytes, } from "./file-from-bytes.js";
|
|
8
11
|
export { createPublication, deletePublication, transferOwnership, } from "./publication.js";
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
package/dist/ops/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAG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ACjB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTB builders for `allowlist` module Move calls. Internal to the SDK;
|
|
3
|
+
* `ops/allowlist.ts` composes these into single atomic transactions.
|
|
4
|
+
*/
|
|
5
|
+
import type { Transaction, TransactionArgument, TransactionResult } from "@mysten/sui/transactions";
|
|
6
|
+
import type { AllowlistCapId, AllowlistId, PackageId, SuiAddress } from "../types.js";
|
|
7
|
+
export interface BuildNewAllowlistArgs {
|
|
8
|
+
readonly packageId: PackageId;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Add an `allowlist::new_allowlist` call. The result destructures into
|
|
13
|
+
* `[allowlist, cap]` in tuple order.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildNewAllowlist(tx: Transaction, args: BuildNewAllowlistArgs): TransactionResult;
|
|
16
|
+
export interface BuildShareAllowlistArgs {
|
|
17
|
+
readonly packageId: PackageId;
|
|
18
|
+
readonly allowlist: TransactionArgument;
|
|
19
|
+
}
|
|
20
|
+
/** Add an `allowlist::share_allowlist` call. Consumes the allowlist. */
|
|
21
|
+
export declare function buildShareAllowlist(tx: Transaction, args: BuildShareAllowlistArgs): TransactionResult;
|
|
22
|
+
export interface BuildTransferAllowlistCapArgs {
|
|
23
|
+
readonly packageId: PackageId;
|
|
24
|
+
readonly cap: TransactionArgument | AllowlistCapId;
|
|
25
|
+
readonly recipient: SuiAddress;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Add an `allowlist::transfer_cap` call. Use this instead of `tx.transferObjects`
|
|
29
|
+
* because `Cap` is key-only (no `store`); the contract's typed transfer is the
|
|
30
|
+
* only way to move it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildTransferAllowlistCap(tx: Transaction, args: BuildTransferAllowlistCapArgs): TransactionResult;
|
|
33
|
+
export interface BuildAddMemberArgs {
|
|
34
|
+
readonly packageId: PackageId;
|
|
35
|
+
readonly allowlistId: AllowlistId;
|
|
36
|
+
readonly capId: AllowlistCapId;
|
|
37
|
+
readonly member: SuiAddress;
|
|
38
|
+
}
|
|
39
|
+
export declare function buildAddMember(tx: Transaction, args: BuildAddMemberArgs): TransactionResult;
|
|
40
|
+
export interface BuildRemoveMemberArgs {
|
|
41
|
+
readonly packageId: PackageId;
|
|
42
|
+
readonly allowlistId: AllowlistId;
|
|
43
|
+
readonly capId: AllowlistCapId;
|
|
44
|
+
readonly member: SuiAddress;
|
|
45
|
+
}
|
|
46
|
+
export declare function buildRemoveMember(tx: Transaction, args: BuildRemoveMemberArgs): TransactionResult;
|
|
47
|
+
export interface BuildDeleteAllowlistArgs {
|
|
48
|
+
readonly packageId: PackageId;
|
|
49
|
+
readonly allowlistId: AllowlistId;
|
|
50
|
+
readonly capId: AllowlistCapId;
|
|
51
|
+
}
|
|
52
|
+
export declare function buildDeleteAllowlist(tx: Transaction, args: BuildDeleteAllowlistArgs): TransactionResult;
|
|
53
|
+
export interface BuildSealApproveAllowlistArgs {
|
|
54
|
+
readonly packageId: PackageId;
|
|
55
|
+
readonly identity: Uint8Array;
|
|
56
|
+
readonly allowlistId: AllowlistId;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Add a dry-run-only `allowlist::seal_approve` call. Seal key servers execute
|
|
60
|
+
* this against a dry-run of the PTB to decide whether to release decryption
|
|
61
|
+
* key shares; the transaction is not submitted on-chain. The `identity` bytes
|
|
62
|
+
* must be the same `SealId` used to encrypt the content.
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildSealApproveAllowlist(tx: Transaction, args: BuildSealApproveAllowlistArgs): TransactionResult;
|
|
65
|
+
//# sourceMappingURL=allowlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.d.ts","sourceRoot":"","sources":["../../src/ptb/allowlist.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,WAAW,EACX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SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAChC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,qBAAqB,GACzB,iBAAiB,CASnB;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAC/B;AAED,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,wBAAwB,GAC5B,iBAAiB,CAKnB;AAED,MAAM,WAAW,6BAA6B;IAC7C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACxC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,6BAA6B,GACjC,iBAAiB,CAQnB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTB builders for `allowlist` module Move calls. Internal to the SDK;
|
|
3
|
+
* `ops/allowlist.ts` composes these into single atomic transactions.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Add an `allowlist::new_allowlist` call. The result destructures into
|
|
7
|
+
* `[allowlist, cap]` in tuple order.
|
|
8
|
+
*/
|
|
9
|
+
export function buildNewAllowlist(tx, args) {
|
|
10
|
+
return tx.moveCall({
|
|
11
|
+
target: `${args.packageId}::allowlist::new_allowlist`,
|
|
12
|
+
arguments: [tx.pure.string(args.name)],
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Add an `allowlist::share_allowlist` call. Consumes the allowlist. */
|
|
16
|
+
export function buildShareAllowlist(tx, args) {
|
|
17
|
+
return tx.moveCall({
|
|
18
|
+
target: `${args.packageId}::allowlist::share_allowlist`,
|
|
19
|
+
arguments: [args.allowlist],
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Add an `allowlist::transfer_cap` call. Use this instead of `tx.transferObjects`
|
|
24
|
+
* because `Cap` is key-only (no `store`); the contract's typed transfer is the
|
|
25
|
+
* only way to move it.
|
|
26
|
+
*/
|
|
27
|
+
export function buildTransferAllowlistCap(tx, args) {
|
|
28
|
+
const cap = typeof args.cap === "string" ? tx.object(args.cap) : args.cap;
|
|
29
|
+
return tx.moveCall({
|
|
30
|
+
target: `${args.packageId}::allowlist::transfer_cap`,
|
|
31
|
+
arguments: [cap, tx.pure.address(args.recipient)],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function buildAddMember(tx, args) {
|
|
35
|
+
return tx.moveCall({
|
|
36
|
+
target: `${args.packageId}::allowlist::add_member`,
|
|
37
|
+
arguments: [
|
|
38
|
+
tx.object(args.allowlistId),
|
|
39
|
+
tx.object(args.capId),
|
|
40
|
+
tx.pure.address(args.member),
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function buildRemoveMember(tx, args) {
|
|
45
|
+
return tx.moveCall({
|
|
46
|
+
target: `${args.packageId}::allowlist::remove_member`,
|
|
47
|
+
arguments: [
|
|
48
|
+
tx.object(args.allowlistId),
|
|
49
|
+
tx.object(args.capId),
|
|
50
|
+
tx.pure.address(args.member),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function buildDeleteAllowlist(tx, args) {
|
|
55
|
+
return tx.moveCall({
|
|
56
|
+
target: `${args.packageId}::allowlist::delete_allowlist`,
|
|
57
|
+
arguments: [tx.object(args.allowlistId), tx.object(args.capId)],
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Add a dry-run-only `allowlist::seal_approve` call. Seal key servers execute
|
|
62
|
+
* this against a dry-run of the PTB to decide whether to release decryption
|
|
63
|
+
* key shares; the transaction is not submitted on-chain. The `identity` bytes
|
|
64
|
+
* must be the same `SealId` used to encrypt the content.
|
|
65
|
+
*/
|
|
66
|
+
export function buildSealApproveAllowlist(tx, args) {
|
|
67
|
+
return tx.moveCall({
|
|
68
|
+
target: `${args.packageId}::allowlist::seal_approve`,
|
|
69
|
+
arguments: [
|
|
70
|
+
tx.pure.vector("u8", Array.from(args.identity)),
|
|
71
|
+
tx.object(args.allowlistId),
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=allowlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../../src/ptb/allowlist.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAChC,EAAe,EACf,IAA2B;IAE3B,OAAO,EAAE,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,4BAA4B;QACrD,SAAS,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACtC,CAAC,CAAC;AACJ,CAAC;AAOD,wEAAwE;AACxE,MAAM,UAAU,mBAAmB,CAClC,EAAe,EACf,IAA6B;IAE7B,OAAO,EAAE,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,8BAA8B;QACvD,SAAS,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;KAC3B,CAAC,CAAC;AACJ,CAAC;AAQD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACxC,EAAe,EACf,IAAmC;IAEnC,MAAM,GAAG,GAAG,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC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CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC/D,CAAC,CAAC;AACJ,CAAC;AAQD;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACxC,EAAe,EACf,IAAmC;IAEnC,OAAO,EAAE,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,2BAA2B;QACpD,SAAS,EAAE;YACV,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/C,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;SAC3B;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
import type { Transaction, TransactionArgument, TransactionResult } from "@mysten/sui/transactions";
|
|
6
|
+
import type { AllowlistId, BlobObjectId, EncryptedFileId, PackageId, SuiAddress, WalrusBlobId } from "../types.js";
|
|
7
|
+
export interface BuildNewEncryptedFileArgs {
|
|
8
|
+
readonly packageId: PackageId;
|
|
9
|
+
readonly blobId: WalrusBlobId;
|
|
10
|
+
readonly blobObjectId?: BlobObjectId;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly contentType: string;
|
|
13
|
+
readonly size: bigint;
|
|
14
|
+
readonly allowlistId: AllowlistId;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Add a `file::new_encrypted_file` call. Returns the new EncryptedFile as the
|
|
18
|
+
* first result. The caller must follow with `share_file` to make it accessible
|
|
19
|
+
* from any wallet.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildNewEncryptedFile(tx: Transaction, args: BuildNewEncryptedFileArgs): TransactionResult;
|
|
22
|
+
export interface BuildNewPublicFileArgs {
|
|
23
|
+
readonly packageId: PackageId;
|
|
24
|
+
readonly blobId: WalrusBlobId;
|
|
25
|
+
readonly blobObjectId?: BlobObjectId;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly contentType: string;
|
|
28
|
+
readonly size: bigint;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Add a `file::new_public_file` call. Returns the new EncryptedFile (the
|
|
32
|
+
* `encrypted` flag is false). Follow with `share_file`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildNewPublicFile(tx: Transaction, args: BuildNewPublicFileArgs): TransactionResult;
|
|
35
|
+
export interface BuildShareFileArgs {
|
|
36
|
+
readonly packageId: PackageId;
|
|
37
|
+
readonly file: TransactionArgument;
|
|
38
|
+
}
|
|
39
|
+
export declare function buildShareFile(tx: Transaction, args: BuildShareFileArgs): TransactionResult;
|
|
40
|
+
export interface BuildUpdateFileMetadataArgs {
|
|
41
|
+
readonly packageId: PackageId;
|
|
42
|
+
readonly fileId: EncryptedFileId;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly contentType: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function buildUpdateFileMetadata(tx: Transaction, args: BuildUpdateFileMetadataArgs): TransactionResult;
|
|
47
|
+
export interface BuildTransferFileOwnershipArgs {
|
|
48
|
+
readonly packageId: PackageId;
|
|
49
|
+
readonly fileId: EncryptedFileId;
|
|
50
|
+
readonly newOwner: SuiAddress;
|
|
51
|
+
}
|
|
52
|
+
export declare function buildTransferFileOwnership(tx: Transaction, args: BuildTransferFileOwnershipArgs): TransactionResult;
|
|
53
|
+
export interface BuildDeleteFileArgs {
|
|
54
|
+
readonly packageId: PackageId;
|
|
55
|
+
readonly fileId: EncryptedFileId;
|
|
56
|
+
}
|
|
57
|
+
export declare function buildDeleteFile(tx: Transaction, args: BuildDeleteFileArgs): TransactionResult;
|
|
58
|
+
//# sourceMappingURL=file.d.ts.map
|
|
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;IAC9B,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;CACnC;AAED,wBAAgB,cAAc,CAC7B,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,kBAAkB,GACtB,iBAAiB,CAKnB;AAED,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,uBAAuB,CACtC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,2BAA2B,GAC/B,iBAAiB,CASnB;AAED,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;CAC9B;AAED,wBAAgB,0BAA0B,CACzC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,8BAA8B,GAClC,iBAAiB,CAKnB;AAED,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CACjC;AAED,wBAAgB,eAAe,CAC9B,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,mBAAmB,GACvB,iBAAiB,CAKnB"}
|
package/dist/ptb/file.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/ptb/file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,sFAAsF;AACtF,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAYlC;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACpC,EAAe,EACf,IAA+B;IAE/B,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrD,OAAO,EAAE,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,4BAA4B;QACrD,SAAS,EAAE;YACV,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC7C,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC;YACnC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACzB,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;YAChC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACtB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAgC,CAAC;YACtD,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC;SAC9B;KACD,CAAC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AAC,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CACpB,EAAe,EACf,KAA+B;IAE/B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC,QAAQ,CAAC;YAClB,MAAM,EAAE,mBAAmB;YAC3B,aAAa,EAAE,CAAC,iBAAiB,CAAC;YAClC,SAAS,EAAE,EAAE;SACb,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,mBAAmB;QAC3B,aAAa,EAAE,CAAC,iBAAiB,CAAC;QAClC,SAAS,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;KAC9B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-events.d.ts","sourceRoot":"","sources":["../../src/read/files-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAe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