@the_library/web3-registry-addresses 1.0.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/LICENCE ADDED
@@ -0,0 +1,104 @@
1
+ # D-CODE SOVEREIGN LICENCE (v1.2)
2
+
3
+ ### PROPRIETARY PUBLIC SOURCE | D-SAFE COMPLIANT
4
+
5
+ **COPYRIGHT:** © 2026 DATAPOND PUBLIC LIBRARY TRUST - Australia
6
+ **TECHNICAL GUARDIAN:** POND ENTERPRISE PTY LTD - Australia
7
+
8
+ ---
9
+
10
+ ## 1. PREAMBLE & DEFINITIONS
11
+
12
+ This software is a fundamental component of the DataPond Ecosystem, designed to build a decentralized, indestructible public library. Unlike standard open-source licenses, this **D-Open Sovereign Licence** is a conditional grant of rights tied strictly to the ethical and technical preservation of the Public Domain.
13
+
14
+ **Definitions:**
15
+ * **"The Software"**: The source code, data models (ORM generated), and Web3 utilities contained in this package.
16
+ * **"D-Licence Compliance"**: Usage that is strictly Non-Commercial, Free of Paywalls, Free of User Account Requirements (Login Walls), Free of Advertising, Free of Political Campaigning or Agendas, and Free of Social Media mechanisms.
17
+ * **"The Canonical Config"**: The dynamic blockchain configuration hosted at `https://datapond.earth/web3-config`.
18
+ * **"The Guardian"**: Pond Enterprise Pty Ltd, the mandated commercial entity responsible for technical certification and liability management.
19
+
20
+ ---
21
+
22
+ ## 2. GRANT OF RIGHTS (CONDITIONAL)
23
+
24
+ The Trust hereby grants you a worldwide, royalty-free, non-exclusive license to use, copy, modify, and distribute The Software, SUBJECT TO the following strict conditions:
25
+
26
+ 1. **Public Access (Anti-Enclosure):** You may not use this Software in any application that restricts access to the underlying public data via payment (Paywalls), mandatory registration (Login Walls), or requires viewing advertisements.
27
+ 2. **Strict Neutrality:** The Software cannot be integrated into platforms driven by political agendas or social media algorithms designed for engagement framing.
28
+ 3. **D-SAFE Integrity:** Any content served, managed, or trained upon by this Software must strictly adhere to the **D-SAFE Specification** (detailed in Section 8).
29
+ 4. **Viral AI Training (The "Copyleft" AI Clause):** Usage of this data for Artificial Intelligence training is conditionally permitted. The resulting AI model must itself be published strictly under this **D-CODE SOVEREIGN LICENCE**. Because this license enforces D-SAFE Integrity, the AI model cannot be legally trained if its broader dataset includes non-DSAFE materials (e.g., hate speech, explicit content). Any AI model that trains on this data but fails to release under this license and adhere to D-SAFE standards is operating illegally and is in material breach of this license.
30
+
31
+ ---
32
+
33
+ ## 3. TECHNICAL ANCHORS & HARD-FORK RESILIENCE
34
+
35
+ To ensure the permanence and provenance of the library:
36
+
37
+ 1. **Immutable Addresses:** You are prohibited from manually modifying the hard-coded Smart Contract addresses or D-SAFE Source URLs embedded in this package to point to non-certified ledgers.
38
+ 2. **Dynamic Synchronization:** Your implementation must utilize the **Canonical Config** API endpoint to resolve the current, active Smart Contract addresses. This ensures resilience against blockchain hard-forks or contract migrations initiated by The Guardian.
39
+ 3. **Prohibited Forking:** You may not "fork" this package to redirect the DataPond models to a private, centralized database. Doing so constitutes a material breach of this license.
40
+
41
+ ---
42
+
43
+ ## 4. OFFLINE & SNAPSHOT RESILIENCE
44
+
45
+ Acknowledging the goal of "Indestructible" access:
46
+
47
+ 1. **Snapshot Rights:** You are permitted to download, cache, and deploy The Software in **100% Offline Environments** (e.g., air-gapped schools, bunkers, remote field operations) where a connection to the Canonical Config or Blockchain is impossible.
48
+ 2. **Static Validity:** In such offline cases, the hard-coded addresses at the time of the "Snapshot" shall be deemed valid, provided the snapshot was originally sourced from a D-SAFE certified release.
49
+
50
+ ---
51
+
52
+ ## 5. THE "KUKRI" LIABILITY SHIELD
53
+
54
+ **WARNING:** BY USING THIS SOFTWARE, YOU AGREE TO THE FOLLOWING LIABILITY STRUCTURE:
55
+
56
+ 1. **The Sanctuary (Trust) Disclaimer:** The DataPond Public Library Trust is a non-profit entity holding the assets. It provides this Software "AS IS" and holds **ZERO LIABILITY** for any damages, gas fees, or data loss arising from its use.
57
+ 2. **The Shield (Guardian) Direction:** Any and all claims regarding technical performance, patent infringement, or professional indemnity related to the core architecture of The Software must be directed exclusively to **Pond Enterprise Pty Ltd**.
58
+ 3. **User Indemnity:** You agree to indemnify and hold harmless The Trust and The Guardian against any claims arising specifically from **your specific implementation**, modification, or misuse of The Software (e.g., if you build an illegal interface using our models).
59
+
60
+ ---
61
+
62
+ ## 6. BREACH & CURE PERIOD
63
+
64
+ 1. **Automatic Termination:** If you violate any term of this license (specifically Section 2 or 3), your rights under this license terminate automatically.
65
+ 2. **30-Day Cure Period:** Before commencing legal action for Intellectual Property infringement, The Trust or The Guardian will provide public or private notice of the breach. You have **thirty (30) days** from the date of such notice to correct the breach (e.g., remove the paywall or restore the correct Smart Contract addresses).
66
+ 3. **Permanent Revocation:** Failure to cure the breach within 30 days results in permanent revocation of rights and potential legal action.
67
+
68
+ ---
69
+
70
+ ## 7. SOVEREIGN OVERRIDE & NON-SEVERABILITY
71
+
72
+ This license is an indivisible whole. There is no severability clause. This license is **VOID** and usage of The Software is unconditionally **PROHIBITED** in any jurisdiction where:
73
+ 1. Decentralized data storage or blockchain technology is illegal.
74
+ 2. The usage of uncensored public domain data is prohibited by law.
75
+ 3. Any clause within this license is deemed legally unenforceable by that state.
76
+
77
+ The Trust will not conduct business or facilitate infrastructure in such restrictive jurisdictions. It is up to the restrictive state to block the DNS or network routing of DataPond.
78
+
79
+ ---
80
+
81
+ ## 8. D-SAFE SPECIFICATION
82
+
83
+ To qualify for D-Licence Compliance, the data and its surrounding implementation must maintain **D-SAFE Integrity**. A prerequisite for the D-SAFE designation is that all associated content must adhere to the four pillars of the D-Licence:
84
+
85
+ * **Decentralized:** The content must live on permanent, distributed infrastructure (such as the Arweave Permaweb), ensuring guaranteed access free from corporate kill-switches.
86
+ * **Integral:** There must be zero money flow attached to the data—no ads, no sponsorships, and no paywalls. It is a pure exchange of ideas.
87
+ * **Common:** Rooted in CC BY-NC-ND 4.0; the content demands attribution, must strictly be Non-Commercial, and permits no derivatives.
88
+
89
+ Building upon that foundation, the network and the application utilizing The Software must adhere to strict zero-tolerance policies and be entirely free from the following:
90
+
91
+ 1. **No Ecological Harm:** Strictly prohibits content that advocates for, or condones, environmental degradation, including but not limited to deforestation, pollution, and the endangerment of species.
92
+ 2. **No AI Generation:** Restricted exclusively to human-authored content; materials generated by artificial intelligence are expressly prohibited.
93
+ 3. **No Explicit/Violence:** Content must be universally suitable for all ages and compliant with all applicable laws, strictly prohibiting explicit material and depictions of violence.
94
+ 4. **No Stolen Content:** Mandates original authorship; all content must be free of plagiarism and must not infringe upon the intellectual property rights or copyrights of third parties.
95
+ 5. **No Politics:** Expressly prohibits materials related to political campaigning, partisan debate, or the promotion of political affiliations.
96
+ 6. **No Spirituality:** Excludes the dissemination of spiritual doctrines, religious proselytization, and non-empirical theological claims.
97
+ 7. **No History:** Prohibits the inclusion of historical claims, historiographical disputes, or speculative historical narratives.
98
+ 8. **No Medicine:** Strictly forbids the provision of medical advice, clinical diagnoses, treatment recommendations, or suggested remedies.
99
+ 9. **No Fiction:** Restricted entirely to factual, real-world information; all works of fiction or fabricated narratives are excluded.
100
+ 10. **No Psychological Profiling:** Prohibits studies or materials that engage in psychological profiling or the broad generalization of human behavior based on demographic factors such as race, culture, or identity.
101
+
102
+ ---
103
+
104
+ **GOVERNING LAW:** This Licence is governed by the laws of **South Australia**.
@@ -0,0 +1,27 @@
1
+ import { Tech, AddressRegistryReadAPI } from '@the_library/web3-core';
2
+
3
+ interface CacheEntry {
4
+ address: string;
5
+ abi: any;
6
+ txId: string;
7
+ originalName: string;
8
+ }
9
+ interface RegistryCache {
10
+ timestamp: number;
11
+ entries: {
12
+ [contractName: string]: CacheEntry;
13
+ };
14
+ }
15
+ declare class RegistryAddressLoader {
16
+ private memoryCache;
17
+ private getCacheKey;
18
+ private getFromLocalStorage;
19
+ private saveToLocalStorage;
20
+ private fetchAbiFromArweave;
21
+ Initialize(tech: Tech, chainId: number | string, registry: AddressRegistryReadAPI): Promise<Record<string, string>>;
22
+ getAddress(tech: string, chainId: string | number, name: string): string | undefined;
23
+ getAbi(tech: string, chainId: string | number, name: string): any;
24
+ }
25
+ declare const registryAddressLoader: RegistryAddressLoader;
26
+
27
+ export { type CacheEntry, RegistryAddressLoader, type RegistryCache, registryAddressLoader };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ var u="dcode_registry_cache_v2_",R=1440*60*1e3,d=class{constructor(){this.memoryCache=new Map;}getCacheKey(t,e){return `${u}${t}_${e}`}getFromLocalStorage(t){let e=localStorage.getItem(t);if(!e)return null;try{return JSON.parse(e)}catch(s){return console.error(`[RegistryLoader] Failed to parse cache for ${t}`,s),null}}saveToLocalStorage(t,e){localStorage.setItem(t,JSON.stringify(e));}async fetchAbiFromArweave(t){if(!t)return null;try{let e=await fetch(`https://arweave.net/${t}`);if(e.ok){let s=await e.json();return `${t}`,s}console.error(`[RegistryLoader] Arweave fetch failed for ${t}: ${e.status} ${e.statusText}`);}catch(e){console.warn(`[RegistryLoader] Failed to fetch ABI from Arweave (${t}):`,e);}return null}async Initialize(t,e,s){let a=this.getCacheKey(t,e),c=Date.now(),o=this.memoryCache.get(a)||this.getFromLocalStorage(a);if(o&&c-o.timestamp<R){this.memoryCache.set(a,o);let r={};return Object.values(o.entries).forEach(n=>{let i=n.originalName.charAt(0).toLowerCase()+n.originalName.slice(1);r[i]=n.address;}),r}let l=await s.getAllContractNames();`${l.length}${t}${e}`;let h={},y={};for(let r of l)try{let[n,i]=await s.getLatestContract(r),g=r.toLowerCase(),C=r.charAt(0).toLowerCase()+r.slice(1),m=null;o&&o.entries[g]&&o.entries[g].txId===i?m=o.entries[g].abi:i?(`${r}${i}`,m=await this.fetchAbiFromArweave(i)):console.warn(`[RegistryLoader] No ABI URL found for ${r} on ${t}:${e}`),h[g]={address:n,abi:m,txId:i,originalName:r},y[C]=n;}catch(n){console.warn(`[RegistryLoader] Failed to load contract ${r} for ${t}:${e}:`,n);}let f={timestamp:c,entries:h};return this.memoryCache.set(a,f),this.saveToLocalStorage(a,f),y}getAddress(t,e,s){let a=this.getCacheKey(t,e);return this.memoryCache.get(a)?.entries[s.toLowerCase()]?.address}getAbi(t,e,s){let a=this.getCacheKey(t,e);return this.memoryCache.get(a)?.entries[s.toLowerCase()]?.abi}},$=new d;
2
+ export{d as RegistryAddressLoader,$ as registryAddressLoader};//# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/loader.ts"],"names":["CACHE_KEY_PREFIX","CACHE_DURATION_MS","RegistryAddressLoader","tech","chainId","key","data","e","cache","abiUrl","res","abi","registry","cacheKey","now","addresses","entry","camelCaseName","contractNames","newEntries","name","address","normalizedName","newCache","registryAddressLoader"],"mappings":"AAEA,IAAMA,CAAAA,CAAmB,2BACnBC,CAAAA,CAAoB,IAAA,CAAU,GAAK,GAAA,CAgB5BC,CAAAA,CAAN,KAA4B,CAA5B,WAAA,EAAA,CACH,IAAA,CAAQ,YAA0C,IAAI,IAAA,CAE9C,YAAYC,CAAAA,CAAcC,CAAAA,CAAkC,CAChE,OAAO,CAAA,EAAGJ,CAAgB,CAAA,EAAGG,CAAI,CAAA,CAAA,EAAIC,CAAO,CAAA,CAChD,CAEQ,oBAAoBC,CAAAA,CAAmC,CAC3D,IAAMC,CAAAA,CAAO,YAAA,CAAa,OAAA,CAAQD,CAAG,CAAA,CACrC,GAAI,CAACC,CAAAA,CAAM,OAAO,KAClB,GAAI,CACA,OAAO,IAAA,CAAK,KAAA,CAAMA,CAAI,CAC1B,CAAA,MAASC,CAAAA,CAAG,CACR,OAAA,OAAA,CAAQ,KAAA,CAAM,8CAA8CF,CAAG,CAAA,CAAA,CAAIE,CAAC,CAAA,CAC7D,IACX,CACJ,CAEQ,kBAAA,CAAmBF,CAAAA,CAAaG,EAA4B,CAChE,YAAA,CAAa,QAAQH,CAAAA,CAAK,IAAA,CAAK,UAAUG,CAAK,CAAC,EACnD,CAEA,MAAc,mBAAA,CAAoBC,EAA8B,CAC5D,GAAI,CAACA,CAAAA,CAAQ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AI,CAAA,KAAA,EAAQjB,CAAI,CAAA,CAAA,EAAIC,CAAO,CAAA,CAAA,CAAA,CAAKG,CAAC,EAC9F,CAGJ,IAAMgB,EAA0B,CAC5B,SAAA,CAAWT,CAAAA,CACX,OAAA,CAASK,CACb,CAAA,CAEA,YAAK,WAAA,CAAY,GAAA,CAAIN,CAAAA,CAAUU,CAAQ,CAAA,CACvC,IAAA,CAAK,mBAAmBV,CAAAA,CAAUU,CAAQ,CAAA,CACnCR,CACX,CAEO,UAAA,CAAWZ,EAAcC,CAAAA,CAA0BgB,CAAAA,CAAkC,CACxF,IAAMP,CAAAA,CAAW,KAAK,WAAA,CAAYV,CAAAA,CAAMC,CAAO,CAAA,CAE/C,OADc,IAAA,CAAK,YAAY,GAAA,CAAIS,CAAQ,GAC7B,OAAA,CAAQO,CAAAA,CAAK,aAAa,CAAA,EAAG,OAC/C,CAEO,MAAA,CAAOjB,CAAAA,CAAcC,EAA0BgB,CAAAA,CAAmB,CACrE,IAAMP,CAAAA,CAAW,IAAA,CAAK,YAAYV,CAAAA,CAAMC,CAAO,CAAA,CAE/C,OADc,IAAA,CAAK,WAAA,CAAY,IAAIS,CAAQ,CAAA,EAC7B,OAAA,CAAQO,CAAAA,CAAK,WAAA,EAAa,GAAG,GAC/C,CACJ,CAAA,CAEaI,CAAAA,CAAwB,IAAItB","file":"index.js","sourcesContent":["import { ReadOnlyDomainAPI, Tech, AddressRegistryReadAPI } from '@the_library/web3-core';\n\nconst CACHE_KEY_PREFIX = 'dcode_registry_cache_v2_';\nconst CACHE_DURATION_MS = 24 * 60 * 60 * 1000; // 24 hours\n\nexport interface CacheEntry {\n address: string;\n abi: any;\n txId: string;\n originalName: string;\n}\n\nexport interface RegistryCache {\n timestamp: number;\n entries: {\n [contractName: string]: CacheEntry;\n };\n}\n\nexport class RegistryAddressLoader {\n private memoryCache: Map<string, RegistryCache> = new Map();\n\n private getCacheKey(tech: string, chainId: string | number): string {\n return `${CACHE_KEY_PREFIX}${tech}_${chainId}`;\n }\n\n private getFromLocalStorage(key: string): RegistryCache | null {\n const data = localStorage.getItem(key);\n if (!data) return null;\n try {\n return JSON.parse(data);\n } catch (e) {\n console.error(`[RegistryLoader] Failed to parse cache for ${key}`, e);\n return null;\n }\n }\n\n private saveToLocalStorage(key: string, cache: RegistryCache): void {\n localStorage.setItem(key, JSON.stringify(cache));\n }\n\n private async fetchAbiFromArweave(abiUrl: string): Promise<any> {\n if (!abiUrl) return null;\n try {\n const res = await fetch(`https://arweave.net/${abiUrl}`);\n if (res.ok) {\n const abi = await res.json();\n console.log(`[RegistryLoader] Successfully fetched ABI for ${abiUrl}`);\n return abi;\n }\n console.error(`[RegistryLoader] Arweave fetch failed for ${abiUrl}: ${res.status} ${res.statusText}`);\n } catch (e) {\n console.warn(`[RegistryLoader] Failed to fetch ABI from Arweave (${abiUrl}):`, e);\n }\n return null;\n }\n\n public async Initialize(tech: Tech, chainId: number | string, registry: AddressRegistryReadAPI): Promise<Record<string, string>> {\n const cacheKey = this.getCacheKey(tech, chainId);\n const now = Date.now();\n\n let cache = this.memoryCache.get(cacheKey) || this.getFromLocalStorage(cacheKey);\n\n // Time Check: Has it been less than 24 hours?\n if (cache && (now - cache.timestamp < CACHE_DURATION_MS)) {\n console.log(`[RegistryLoader] Cache valid for ${tech}:${chainId}`);\n this.memoryCache.set(cacheKey, cache);\n const addresses: Record<string, string> = {};\n Object.values(cache.entries).forEach(entry => {\n const camelCaseName = entry.originalName.charAt(0).toLowerCase() + entry.originalName.slice(1);\n addresses[camelCaseName] = entry.address;\n });\n return addresses;\n }\n\n console.log(`[RegistryLoader] Cache expired or missing for ${tech}:${chainId}. Performing Full Sync...`);\n\n const contractNames = await registry.getAllContractNames();\n console.log(`[RegistryLoader] Retrieved ${contractNames.length} contract names for ${tech}:${chainId}:`, contractNames);\n const newEntries: { [name: string]: CacheEntry } = {};\n const addresses: Record<string, string> = {};\n\n for (const name of contractNames) {\n try {\n const [address, abiUrl] = await registry.getLatestContract(name);\n const normalizedName = name.toLowerCase();\n const camelCaseName = name.charAt(0).toLowerCase() + name.slice(1);\n\n let abi = null;\n // Try to reuse ABI from old cache if txId matches\n if (cache && cache.entries[normalizedName] && cache.entries[normalizedName].txId === abiUrl) {\n abi = cache.entries[normalizedName].abi;\n } else if (abiUrl) {\n console.log(`[RegistryLoader] Fetching new ABI for ${name} (${abiUrl})...`);\n abi = await this.fetchAbiFromArweave(abiUrl);\n } else {\n console.warn(`[RegistryLoader] No ABI URL found for ${name} on ${tech}:${chainId}`);\n }\n\n newEntries[normalizedName] = {\n address,\n abi,\n txId: abiUrl,\n originalName: name\n };\n addresses[camelCaseName] = address;\n } catch (e) {\n console.warn(`[RegistryLoader] Failed to load contract ${name} for ${tech}:${chainId}:`, e);\n }\n }\n\n const newCache: RegistryCache = {\n timestamp: now,\n entries: newEntries\n };\n\n this.memoryCache.set(cacheKey, newCache);\n this.saveToLocalStorage(cacheKey, newCache);\n return addresses;\n }\n\n public getAddress(tech: string, chainId: string | number, name: string): string | undefined {\n const cacheKey = this.getCacheKey(tech, chainId);\n const cache = this.memoryCache.get(cacheKey);\n return cache?.entries[name.toLowerCase()]?.address;\n }\n\n public getAbi(tech: string, chainId: string | number, name: string): any {\n const cacheKey = this.getCacheKey(tech, chainId);\n const cache = this.memoryCache.get(cacheKey);\n return cache?.entries[name.toLowerCase()]?.abi;\n }\n}\n\nexport const registryAddressLoader = new RegistryAddressLoader();\n"]}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@the_library/web3-registry-addresses",
3
+ "version": "1.0.0",
4
+ "description": "Common package for handling Web3 AddressRegistry sessions and caching",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "dev": "tsup --watch",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "keywords": [
24
+ "web3",
25
+ "registry",
26
+ "address",
27
+ "session",
28
+ "cache"
29
+ ],
30
+ "sideEffects": false,
31
+ "author": "Med Pond",
32
+ "license": "SEE LICENSE IN LICENCE",
33
+ "devDependencies": {
34
+ "@types/node": "^22.10.0",
35
+ "tsup": "^8.0.1",
36
+ "typescript": "^5.3.3"
37
+ },
38
+ "dependencies": {
39
+ "@the_library/web3-contracts": "workspace:*",
40
+ "@the_library/web3-core": "workspace:*"
41
+ }
42
+ }