@ownables/core 0.14.0 → 0.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ownables/core",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,13 +0,0 @@
1
- import type { RecordStore, BridgedOwnableRecord, NftRef } from '../types/Authority.js';
2
- import type { StateStore } from '../interfaces/core.js';
3
- export default class StateStoreRecordStore implements RecordStore {
4
- private readonly state;
5
- constructor(state: StateStore);
6
- put(record: BridgedOwnableRecord): Promise<void>;
7
- getByCid(cid: string): Promise<BridgedOwnableRecord | undefined>;
8
- hasCid(cid: string): Promise<boolean>;
9
- getCidByNft(nft: NftRef): Promise<string | undefined>;
10
- getByNft(nft: NftRef): Promise<BridgedOwnableRecord | undefined>;
11
- listByPrevOwner(prevOwner: string): Promise<BridgedOwnableRecord[]>;
12
- }
13
- //# sourceMappingURL=StateStoreRecordStore.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StateStoreRecordStore.service.d.ts","sourceRoot":"","sources":["../../src/services/StateStoreRecordStore.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA4BxD,MAAM,CAAC,OAAO,OAAO,qBAAsB,YAAW,WAAW;IACnD,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,UAAU;IAExC,GAAG,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkChD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAKhE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKrC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKrD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAMhE,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;CAQ1E"}
@@ -1,76 +0,0 @@
1
- const STORE_BY_CID = 'records:by-cid';
2
- const STORE_BY_NFT = 'records:index:nft';
3
- const STORE_BY_OWNER = 'records:index:owner';
4
- function normalizeAddress(address) {
5
- return address.toLowerCase();
6
- }
7
- function ownerKey(owner) {
8
- return normalizeAddress(owner);
9
- }
10
- function nftKey(nft) {
11
- return `${nft.network.toLowerCase()}|${normalizeAddress(nft.address)}|${nft.id}`;
12
- }
13
- async function ensureStores(state) {
14
- const stores = [STORE_BY_CID, STORE_BY_NFT, STORE_BY_OWNER];
15
- const missing = await Promise.all(stores.map((store) => state.hasStore(store)));
16
- const toCreate = stores.filter((_store, idx) => !missing[idx]);
17
- if (toCreate.length > 0) {
18
- await state.createStore(...toCreate);
19
- }
20
- }
21
- export default class StateStoreRecordStore {
22
- state;
23
- constructor(state) {
24
- this.state = state;
25
- }
26
- async put(record) {
27
- await ensureStores(this.state);
28
- const existing = await this.getByCid(record.cid);
29
- const owner = ownerKey(record.prevOwner);
30
- const nft = nftKey(record.nft);
31
- await this.state.set(STORE_BY_CID, record.cid, record);
32
- await this.state.set(STORE_BY_NFT, nft, record.cid);
33
- const ownerCids = (await this.state.get(STORE_BY_OWNER, owner)) ?? [];
34
- if (!ownerCids.includes(record.cid)) {
35
- await this.state.set(STORE_BY_OWNER, owner, [...ownerCids, record.cid]);
36
- }
37
- if (!existing) {
38
- return;
39
- }
40
- const oldOwner = ownerKey(existing.prevOwner);
41
- const oldNft = nftKey(existing.nft);
42
- if (oldNft !== nft) {
43
- await this.state.delete(STORE_BY_NFT, oldNft);
44
- }
45
- if (oldOwner !== owner) {
46
- const oldOwnerCids = (await this.state.get(STORE_BY_OWNER, oldOwner)) ?? [];
47
- const next = oldOwnerCids.filter((cid) => cid !== record.cid);
48
- await this.state.set(STORE_BY_OWNER, oldOwner, next);
49
- }
50
- }
51
- async getByCid(cid) {
52
- await ensureStores(this.state);
53
- return (await this.state.get(STORE_BY_CID, cid));
54
- }
55
- async hasCid(cid) {
56
- const record = await this.getByCid(cid);
57
- return Boolean(record);
58
- }
59
- async getCidByNft(nft) {
60
- await ensureStores(this.state);
61
- return (await this.state.get(STORE_BY_NFT, nftKey(nft)));
62
- }
63
- async getByNft(nft) {
64
- const cid = await this.getCidByNft(nft);
65
- if (!cid)
66
- return undefined;
67
- return this.getByCid(cid);
68
- }
69
- async listByPrevOwner(prevOwner) {
70
- await ensureStores(this.state);
71
- const cids = (await this.state.get(STORE_BY_OWNER, ownerKey(prevOwner))) ?? [];
72
- const records = await Promise.all(cids.map((cid) => this.getByCid(cid)));
73
- return records.filter((record) => Boolean(record));
74
- }
75
- }
76
- //# sourceMappingURL=StateStoreRecordStore.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StateStoreRecordStore.service.js","sourceRoot":"","sources":["../../src/services/StateStoreRecordStore.service.ts"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAG,gBAAgB,CAAC;AACtC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AACzC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,gBAAgB,CAAC,GAA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string;
4
- id: string;
5
- }
6
- export interface BridgedOwnableRecord {
7
- cid: string;
8
- prevOwner: string;
9
- nft: NftRef;
10
- createdAt: string;
11
- }
12
- export interface ImportedArchive {
13
- cid: string;
14
- chainJson: Record<string, unknown>;
15
- chainFileName: 'eventChain.json' | 'chain.json';
16
- packageFiles: string[];
17
- }
18
- export interface RecordStore {
19
- put(record: BridgedOwnableRecord): Promise<void>;
20
- getByCid(cid: string): Promise<BridgedOwnableRecord | undefined>;
21
- hasCid(cid: string): Promise<boolean>;
22
- getCidByNft(nft: NftRef): Promise<string | undefined>;
23
- getByNft(nft: NftRef): Promise<BridgedOwnableRecord | undefined>;
24
- listByPrevOwner(prevOwner: string): Promise<BridgedOwnableRecord[]>;
25
- }
26
- export interface ArchiveService {
27
- importArchive(data: Uint8Array): Promise<ImportedArchive>;
28
- hasPackage(cid: string): Promise<boolean>;
29
- hasChain(cid: string): Promise<boolean>;
30
- readChain(cid: string): Promise<Record<string, unknown>>;
31
- readPackageZip(cid: string): Promise<Uint8Array>;
32
- }
33
- export interface LockableGateway {
34
- getOwner(contractAddress: string, tokenId: string): Promise<string>;
35
- isLocked(contractAddress: string, tokenId: string): Promise<boolean>;
36
- getUnlockChallenge(contractAddress: string, tokenId: string): Promise<string>;
37
- signUnlockChallenge(challenge: string): Promise<string>;
38
- isUnlockProofValid(contractAddress: string, tokenId: string, proof: string): Promise<boolean>;
39
- }
40
- //# sourceMappingURL=Authority.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Authority.d.ts","sourceRoot":"","sources":["../../src/types/Authority.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ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