@beclab/olaresid 0.1.13 → 0.2.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/CLI-TREE.md +107 -0
- package/CLI.md +122 -1340
- package/README.md +30 -12
- package/SDK-TREE.md +151 -0
- package/TAG.md +95 -41
- package/config.json +6 -4
- package/dist/abi/TerminusDIDQueryABI.d.ts +397 -0
- package/dist/abi/TerminusDIDQueryABI.d.ts.map +1 -0
- package/dist/abi/TerminusDIDQueryABI.js +519 -0
- package/dist/abi/TerminusDIDQueryABI.js.map +1 -0
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business/index.js +9 -23
- package/dist/business/index.js.map +1 -1
- package/dist/business/tag-context.d.ts +1 -0
- package/dist/business/tag-context.d.ts.map +1 -1
- package/dist/business/tag-context.js +13 -7
- package/dist/business/tag-context.js.map +1 -1
- package/dist/cli.js +177 -76
- package/dist/cli.js.map +1 -1
- package/dist/config/index.d.ts +16 -4
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +28 -14
- package/dist/config/index.js.map +1 -1
- package/dist/domain/core.d.ts +65 -0
- package/dist/domain/core.d.ts.map +1 -0
- package/dist/domain/core.js +317 -0
- package/dist/domain/core.js.map +1 -0
- package/dist/domain/index.d.ts +104 -57
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +188 -428
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/types.d.ts +56 -0
- package/dist/domain/types.d.ts.map +1 -0
- package/dist/domain/types.js +3 -0
- package/dist/domain/types.js.map +1 -0
- package/dist/index.d.ts +81 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +158 -143
- package/dist/index.js.map +1 -1
- package/dist/utils/crypto-utils.d.ts +110 -0
- package/dist/utils/crypto-utils.d.ts.map +1 -1
- package/dist/utils/crypto-utils.js +127 -8
- package/dist/utils/crypto-utils.js.map +1 -1
- package/dist/utils/error-parser.d.ts.map +1 -1
- package/dist/utils/error-parser.js +2 -1
- package/dist/utils/error-parser.js.map +1 -1
- package/dist/utils/event-parser.d.ts +161 -0
- package/dist/utils/event-parser.d.ts.map +1 -0
- package/dist/utils/event-parser.js +140 -0
- package/dist/utils/event-parser.js.map +1 -0
- package/dist/utils/tag-type-builder.d.ts +43 -0
- package/dist/utils/tag-type-builder.d.ts.map +1 -1
- package/dist/utils/tag-type-builder.js +122 -0
- package/dist/utils/tag-type-builder.js.map +1 -1
- package/dist/utils/tag-type-parser.d.ts +70 -0
- package/dist/utils/tag-type-parser.d.ts.map +1 -0
- package/dist/utils/tag-type-parser.js +190 -0
- package/dist/utils/tag-type-parser.js.map +1 -0
- package/examples/create-with-rpc-demo.ts +142 -0
- package/examples/fetch-all-flat-demo.ts +159 -0
- package/examples/fetch-by-indices-demo.ts +235 -0
- package/examples/fetch-domain-demo.ts +137 -0
- package/examples/fetch-domains-demo.ts +221 -0
- package/examples/frontend-demo/index.html +2 -2
- package/examples/frontend-demo/package-lock.json +4 -1
- package/examples/index.ts +3 -5
- package/jest.config.js +25 -0
- package/package.json +6 -2
- package/src/abi/TerminusDIDQueryABI.ts +516 -0
- package/src/business/index.ts +9 -33
- package/src/business/tag-context.ts +35 -7
- package/src/cli.ts +253 -90
- package/src/config/index.ts +34 -19
- package/src/domain/core.ts +382 -0
- package/src/domain/index.ts +271 -641
- package/src/domain/types.ts +59 -0
- package/src/index.ts +230 -207
- package/src/utils/crypto-utils.ts +205 -2
- package/src/utils/error-parser.ts +2 -1
- package/src/utils/event-parser.ts +353 -0
- package/src/utils/tag-type-builder.ts +138 -0
- package/src/utils/tag-type-parser.ts +246 -0
- package/tests/unit/crypto-utils.test.ts +338 -0
- package/tests/unit/ed25519-jwk.test.ts +201 -0
- package/tests/unit/event-parser.test.ts +690 -0
- package/tests/unit/generate-mnemonic.test.ts +268 -0
- package/tests/unit/olares-id-format.test.ts +321 -0
- package/tests/unit/tag-type-parser.test.ts +802 -0
- package/tests/unit/tag-types.test.ts +821 -0
- package/tests/unit/version.test.ts +14 -0
- package/tsconfig.json +3 -2
- package/dist/abi/ABITypeABI.d.ts +0 -88
- package/dist/abi/ABITypeABI.d.ts.map +0 -1
- package/dist/abi/ABITypeABI.js +0 -382
- package/dist/abi/ABITypeABI.js.map +0 -1
- package/dist/abi/RegistryABI.d.ts +0 -77
- package/dist/abi/RegistryABI.d.ts.map +0 -1
- package/dist/abi/RegistryABI.js +0 -462
- package/dist/abi/RegistryABI.js.map +0 -1
- package/dist/tag/address.d.ts +0 -11
- package/dist/tag/address.d.ts.map +0 -1
- package/dist/tag/address.js +0 -44
- package/dist/tag/address.js.map +0 -1
- package/dist/tag/array.d.ts +0 -14
- package/dist/tag/array.d.ts.map +0 -1
- package/dist/tag/array.js +0 -72
- package/dist/tag/array.js.map +0 -1
- package/dist/tag/bool.d.ts +0 -11
- package/dist/tag/bool.d.ts.map +0 -1
- package/dist/tag/bool.js +0 -43
- package/dist/tag/bool.js.map +0 -1
- package/dist/tag/bytes.d.ts +0 -11
- package/dist/tag/bytes.d.ts.map +0 -1
- package/dist/tag/bytes.js +0 -37
- package/dist/tag/bytes.js.map +0 -1
- package/dist/tag/flarray.d.ts +0 -15
- package/dist/tag/flarray.d.ts.map +0 -1
- package/dist/tag/flarray.js +0 -81
- package/dist/tag/flarray.js.map +0 -1
- package/dist/tag/flbytes.d.ts +0 -11
- package/dist/tag/flbytes.d.ts.map +0 -1
- package/dist/tag/flbytes.js +0 -47
- package/dist/tag/flbytes.js.map +0 -1
- package/dist/tag/index.d.ts +0 -32
- package/dist/tag/index.d.ts.map +0 -1
- package/dist/tag/index.js +0 -121
- package/dist/tag/index.js.map +0 -1
- package/dist/tag/int.d.ts +0 -12
- package/dist/tag/int.d.ts.map +0 -1
- package/dist/tag/int.js +0 -49
- package/dist/tag/int.js.map +0 -1
- package/dist/tag/string.d.ts +0 -11
- package/dist/tag/string.d.ts.map +0 -1
- package/dist/tag/string.js +0 -37
- package/dist/tag/string.js.map +0 -1
- package/dist/tag/tag.d.ts +0 -67
- package/dist/tag/tag.d.ts.map +0 -1
- package/dist/tag/tag.js +0 -157
- package/dist/tag/tag.js.map +0 -1
- package/dist/tag/tuple.d.ts +0 -17
- package/dist/tag/tuple.d.ts.map +0 -1
- package/dist/tag/tuple.js +0 -162
- package/dist/tag/tuple.js.map +0 -1
- package/dist/tag/uint.d.ts +0 -12
- package/dist/tag/uint.d.ts.map +0 -1
- package/dist/tag/uint.js +0 -49
- package/dist/tag/uint.js.map +0 -1
- package/dist/test/did.d.ts +0 -2
- package/dist/test/did.d.ts.map +0 -1
- package/dist/test/did.js +0 -177
- package/dist/test/did.js.map +0 -1
- package/dist/utils/tag-abi-codec.d.ts +0 -69
- package/dist/utils/tag-abi-codec.d.ts.map +0 -1
- package/dist/utils/tag-abi-codec.js +0 -144
- package/dist/utils/tag-abi-codec.js.map +0 -1
- package/examples/crypto-utilities.ts +0 -140
- package/examples/ed25519-jwk.ts +0 -73
- package/examples/generate-mnemonic.ts +0 -149
- package/examples/legacy.ts +0 -33
- package/examples/olares-id-format.ts +0 -197
- package/examples/tag-builder.ts +0 -235
- package/examples/tag-nested-tuple.ts +0 -190
- package/examples/tag-simple.ts +0 -149
- package/examples/tag-tagger.ts +0 -217
- package/examples/test-nested-tuple-conversion.ts +0 -143
- package/examples/test-type-bytes-parser.ts +0 -70
- package/src/abi/ABITypeABI.ts +0 -379
- package/src/abi/RegistryABI.ts +0 -459
- package/src/tag/address.ts +0 -48
- package/src/tag/array.ts +0 -80
- package/src/tag/bool.ts +0 -43
- package/src/tag/bytes.ts +0 -38
- package/src/tag/flarray.ts +0 -99
- package/src/tag/flbytes.ts +0 -48
- package/src/tag/index.ts +0 -170
- package/src/tag/int.ts +0 -51
- package/src/tag/string.ts +0 -38
- package/src/tag/tag.ts +0 -229
- package/src/tag/tuple.ts +0 -193
- package/src/tag/uint.ts +0 -51
- package/src/test/did.ts +0 -346
- package/src/utils/tag-abi-codec.ts +0 -158
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
`olaresid` is an SDK library and CLI tool
|
|
5
|
+
`olaresid` is an SDK library and CLI tool focused on Olares ID domain metadata and tags. It helps you read core metadata (such as domain, DID, owner, and subdomain settings), and manage typed tag data on-chain for structured profile, auth, and application-specific information.
|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
8
|
|
|
@@ -12,16 +12,17 @@
|
|
|
12
12
|
npm install -g @beclab/olaresid
|
|
13
13
|
|
|
14
14
|
# Query Olares ID information on mainnet (default)
|
|
15
|
-
did-cli
|
|
15
|
+
did-cli fetch olares.com
|
|
16
16
|
|
|
17
17
|
# Query Olares ID information on sepolia testnet
|
|
18
|
-
did-cli
|
|
18
|
+
did-cli fetch olares.com --network sepolia
|
|
19
19
|
|
|
20
20
|
# Support Olares ID Format
|
|
21
|
-
did-cli
|
|
21
|
+
did-cli fetch tw7613781@olares.com
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
- Scenario-based usage guide: [CLI.md](./CLI.md)
|
|
25
|
+
- Full command reference: [CLI-TREE.md](./CLI-TREE.md)
|
|
25
26
|
|
|
26
27
|
### As an SDK
|
|
27
28
|
|
|
@@ -29,11 +30,23 @@ For detailed CLI usage, see [CLI.md](./CLI.md).
|
|
|
29
30
|
npm install @beclab/olaresid
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
In your TypeScript or JavaScript code, import the package:
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
```typescript
|
|
36
|
+
import OlaresID from '@beclab/olaresid';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- Full SDK API reference: [SDK-TREE.md](./SDK-TREE.md)
|
|
40
|
+
- Usage examples: [examples](./examples) directory
|
|
41
|
+
|
|
42
|
+
### Tag System
|
|
43
|
+
|
|
44
|
+
Tag-related usage is documented separately:
|
|
45
|
+
|
|
46
|
+
- SDK and concepts: [TAG.md](./TAG.md)
|
|
47
|
+
- CLI command usage: [TAG.md#cli-usage](./TAG.md#cli-usage)
|
|
35
48
|
|
|
36
|
-
|
|
49
|
+
### Frontend Usage (Browser Environment)
|
|
37
50
|
|
|
38
51
|
When using `@beclab/olaresid` in frontend applications (React, Vue, etc.), you need to configure polyfills and bundler settings due to:
|
|
39
52
|
|
|
@@ -85,8 +98,9 @@ npm run build
|
|
|
85
98
|
# Run examples
|
|
86
99
|
npx ts-node ./examples/index.ts
|
|
87
100
|
|
|
88
|
-
# Or run
|
|
89
|
-
npx ts-node ./examples/
|
|
101
|
+
# Or run domain fetching examples
|
|
102
|
+
npx ts-node ./examples/fetch-domain-demo.ts
|
|
103
|
+
npx ts-node ./examples/fetch-all-flat-demo.ts
|
|
90
104
|
```
|
|
91
105
|
|
|
92
106
|
After testing, feel free to submit a Pull Request!
|
|
@@ -99,14 +113,18 @@ After testing, feel free to submit a Pull Request!
|
|
|
99
113
|
|
|
100
114
|
- **RPC:** https://optimism-rpc.publicnode.com
|
|
101
115
|
- **DID Contract:** 0x5DA4Fa8E567d86e52Ef8Da860de1be8f54cae97D
|
|
102
|
-
- **Root Resolver:**
|
|
116
|
+
- **Root Resolver:** 0x9bA3D0D3d2046aeD57e9897F7F79C58DfAa5325A
|
|
103
117
|
- **Root Resolver2:** 0x7e7961aB771cA942CE4DB6e79579e016a33Dc95B
|
|
104
118
|
- **ABI Type:** 0x9ae3F16bD99294Af1784beB1a0A5C84bf2636365
|
|
119
|
+
- **Query Contract:** 0x8305411EEa5C3F99f9426845Cf2977E77D5a1711
|
|
120
|
+
- **Support Service:** https://api.olares.com/did/support
|
|
105
121
|
|
|
106
122
|
#### Sepolia Testnet
|
|
107
123
|
|
|
108
124
|
- **RPC:** https://sepolia.optimism.io
|
|
109
125
|
- **DID Contract:** 0xe2D7c3a9013960E04d4E9F5F9B63fff37eEd97A8
|
|
110
|
-
- **Root Resolver:**
|
|
126
|
+
- **Root Resolver:** 0xbEE79099eD3eD33c8ce57df9fb79370aAc79f261
|
|
111
127
|
- **Root Resolver2:** 0xcbC02aa08c77a374eC0D5A0403E108b7573d96e8
|
|
112
128
|
- **ABI Type:** 0x7386fCBae6Ad4CCE1499d9153D99bc950B589718
|
|
129
|
+
- **Query Contract:** 0xAf0430AB9f2450c52E7401846C7CA702D53eCFC2
|
|
130
|
+
- **Support Service:** https://api-test.olares.com/did/support
|
package/SDK-TREE.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# OlaresID SDK Reference
|
|
2
|
+
|
|
3
|
+
Package: `@beclab/olaresid`
|
|
4
|
+
Install: `npm install @beclab/olaresid`
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
@beclab/olaresid
|
|
8
|
+
│
|
|
9
|
+
├── OlaresID [Entry factory]
|
|
10
|
+
│ ├── createMainnet() connect to Optimism mainnet
|
|
11
|
+
│ ├── createTestnet() connect to Sepolia testnet
|
|
12
|
+
│ ├── createWithRpc(url, network?) custom RPC, bundled contract addresses
|
|
13
|
+
│ └── createConsole(rpc, did, resolver, abi, resolver2?, svcUrl?, query?)
|
|
14
|
+
│ fully manual configuration
|
|
15
|
+
│
|
|
16
|
+
├── DIDConsole
|
|
17
|
+
│ ├── Signer
|
|
18
|
+
│ │ ├── setSigner(signerOrPrivateKeyOrMnemonic) accepts Signer / hex key / mnemonic
|
|
19
|
+
│ │ ├── getSigner()
|
|
20
|
+
│ │ └── clearSigner()
|
|
21
|
+
│ │
|
|
22
|
+
│ ├── Query [🌐 Public]
|
|
23
|
+
│ │ ├── fetchDomain(nameOrTokenId)
|
|
24
|
+
│ │ ├── fetchDomains(offset, limit)
|
|
25
|
+
│ │ ├── fetchDomainsByIndices(indices[])
|
|
26
|
+
│ │ └── fetchAllFlat({ batchSize?, onProgress? })
|
|
27
|
+
│ │
|
|
28
|
+
│ ├── Contract read-only [🌐 Public]
|
|
29
|
+
│ │ ├── getOwner()
|
|
30
|
+
│ │ ├── getTotalSupply()
|
|
31
|
+
│ │ └── getOperator()
|
|
32
|
+
│ │
|
|
33
|
+
│ ├── Contract ownership [👑 Contract Owner]
|
|
34
|
+
│ │ ├── transferOwnership(newOwner) 2-step: initiates transfer
|
|
35
|
+
│ │ └── acceptOwnership() 2-step: new owner confirms
|
|
36
|
+
│ │
|
|
37
|
+
│ ├── Operator management [👑 Contract Owner]
|
|
38
|
+
│ │ └── setOperator(address)
|
|
39
|
+
│ │
|
|
40
|
+
│ └── domain(name) → DomainContext ↓
|
|
41
|
+
│
|
|
42
|
+
├── DomainContext
|
|
43
|
+
│ ├── Info read-only [🌐 Public]
|
|
44
|
+
│ │ ├── getMetaInfo() id / name / DID / note / allowSubdomain
|
|
45
|
+
│ │ ├── getOwner() NFT owner address
|
|
46
|
+
│ │ └── isOwner() checks connected signer
|
|
47
|
+
│ │
|
|
48
|
+
│ ├── RSA key read-only [🌐 Public]
|
|
49
|
+
│ │ └── getRSAPublicKey() PEM PKCS#8, or null
|
|
50
|
+
│ │
|
|
51
|
+
│ ├── IP read-only [🌐 Public]
|
|
52
|
+
│ │ └── getIP() IPv4 string, or null
|
|
53
|
+
│ │
|
|
54
|
+
│ ├── Wallet read-only [🌐 Public]
|
|
55
|
+
│ │ ├── getEVMWallets()
|
|
56
|
+
│ │ └── getSolanaWallets()
|
|
57
|
+
│ │
|
|
58
|
+
│ ├── RSA key write [🔑 Domain Owner]
|
|
59
|
+
│ │ ├── setRSAPublicKey(pem) accepts PEM or DER hex
|
|
60
|
+
│ │ └── removeRSAPublicKey()
|
|
61
|
+
│ │
|
|
62
|
+
│ ├── IP write [🔑 Domain Owner]
|
|
63
|
+
│ │ ├── setIP(ip) e.g. "192.168.1.1"
|
|
64
|
+
│ │ └── removeIP()
|
|
65
|
+
│ │
|
|
66
|
+
│ ├── Wallet write [🔑 Domain Owner]
|
|
67
|
+
│ │ ├── addEVMWallet(privateKey) dual EIP-712 signature
|
|
68
|
+
│ │ ├── removeEVMWallet(privateKey)
|
|
69
|
+
│ │ ├── addSolanaWallet(privateKey)
|
|
70
|
+
│ │ └── removeSolanaWallet(privateKey)
|
|
71
|
+
│ │
|
|
72
|
+
│ ├── Subdomain registration [🔑 Domain Owner]
|
|
73
|
+
│ │ └── registerSubdomain(label, mnemonic) derives owner + DID from mnemonic
|
|
74
|
+
│ │
|
|
75
|
+
│ ├── Domain transfer [🔑 Domain Owner]
|
|
76
|
+
│ │ └── transfer(newOwnerMnemonic) atomically updates NFT owner + DID
|
|
77
|
+
│ │
|
|
78
|
+
│ └── tag(fromDomain?) → TagContext ↓
|
|
79
|
+
│ (fromDomain defaults to current domain)
|
|
80
|
+
│
|
|
81
|
+
├── TagContext
|
|
82
|
+
│ ├── Read-only [🌐 Public]
|
|
83
|
+
│ │ ├── getTag(toDomain, tagName)
|
|
84
|
+
│ │ ├── getAllTags(toDomain)
|
|
85
|
+
│ │ ├── getDefinedTagNames() tag types defined by fromDomain
|
|
86
|
+
│ │ └── getTagger(tagName)
|
|
87
|
+
│ │
|
|
88
|
+
│ ├── Tag type management [🔑 Domain Owner]
|
|
89
|
+
│ │ ├── defineTag(tagName, TagTypeBuilder)
|
|
90
|
+
│ │ └── setTagger(tagName, address) authorize a tagger
|
|
91
|
+
│ │
|
|
92
|
+
│ └── Tag value write [✏️ Tagger]
|
|
93
|
+
│ ├── setTag(toDomain, tagName, value)
|
|
94
|
+
│ └── removeTag(toDomain, tagName)
|
|
95
|
+
│
|
|
96
|
+
└── Utilities [🌐 No permission required — pure local computation]
|
|
97
|
+
├── Crypto
|
|
98
|
+
│ ├── generateMnemonic(wordCount?) BIP39, 12–24 words
|
|
99
|
+
│ ├── deriveDIDFromMnemonic(mnemonic) → { owner, did }
|
|
100
|
+
│ ├── generateDIDKeyData() generate mnemonic + derive keys
|
|
101
|
+
│ ├── getEVMPrivateKeyFromMnemonic(mnemonic)
|
|
102
|
+
│ ├── getEthereumAddressFromMnemonic(mnemonic)
|
|
103
|
+
│ └── createRsaKeyPair(bits?) → { rsaPublicKey, rsaPrivateKey } PEM
|
|
104
|
+
│
|
|
105
|
+
├── Format
|
|
106
|
+
│ ├── pemToDer(pem) PEM → DER hex
|
|
107
|
+
│ ├── derToPem(hex) DER hex → PEM
|
|
108
|
+
│ ├── ipv4ToBytes4(ip) "1.2.3.4" → bytes4 hex
|
|
109
|
+
│ ├── bytes4ToIpv4(hex) bytes4 hex → "1.2.3.4"
|
|
110
|
+
│ ├── normalizeToDomain(input) alice@olares.com → alice.olares.com
|
|
111
|
+
│ └── normalizeToOlaresId(domain) alice.olares.com → alice@olares.com
|
|
112
|
+
│
|
|
113
|
+
├── Tag
|
|
114
|
+
│ ├── TagTypeBuilder build ABI-encoded type descriptors
|
|
115
|
+
│ │ ├── TagTypeBuilder.string()
|
|
116
|
+
│ │ ├── TagTypeBuilder.uint8() / uint256() / int8() / int256()
|
|
117
|
+
│ │ ├── TagTypeBuilder.bool()
|
|
118
|
+
│ │ ├── TagTypeBuilder.address()
|
|
119
|
+
│ │ ├── TagTypeBuilder.bytes() / bytes32()
|
|
120
|
+
│ │ └── TagTypeBuilder.array(innerType)
|
|
121
|
+
│ └── TagTypeParser decode raw ABI type bytes
|
|
122
|
+
│
|
|
123
|
+
└── Events
|
|
124
|
+
├── parseEvents(rawLogs) parse eth_getLogs into typed events
|
|
125
|
+
└── type guards
|
|
126
|
+
├── isTransferEvent(e)
|
|
127
|
+
├── isMintEvent(e) Transfer from zero address
|
|
128
|
+
├── isTagAddedEvent(e)
|
|
129
|
+
├── isTagRemovedEvent(e)
|
|
130
|
+
├── isTagElemUpdatedEvent(e)
|
|
131
|
+
├── isTagElemPushedEvent(e)
|
|
132
|
+
├── isTagElemPoppedEvent(e)
|
|
133
|
+
└── isNewTagTypeEvent(e)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
Permission legend
|
|
140
|
+
🌐 Public no signing required — read-only on-chain data or local computation
|
|
141
|
+
✏️ Tagger address authorized by Domain Owner via setTagger()
|
|
142
|
+
🔑 Domain Owner holder of the domain NFT
|
|
143
|
+
👑 Contract Owner Ownable2Step super-admin
|
|
144
|
+
|
|
145
|
+
⚠️ Operator role: exists at the contract level for registering root domains;
|
|
146
|
+
not exposed as a method in the SDK.
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
For tag type definitions and examples, see [TAG.md](./TAG.md).
|
package/TAG.md
CHANGED
|
@@ -28,6 +28,22 @@ Tags are key-value pairs associated with a domain. Each tag has:
|
|
|
28
28
|
|
|
29
29
|
## Core Concepts
|
|
30
30
|
|
|
31
|
+
### 0. Get `tagCtx` First
|
|
32
|
+
|
|
33
|
+
Before using any tag APIs in this document, initialize OlaresID, get a domain context, and then get the tag context:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import OlaresID from '@beclab/olaresid';
|
|
37
|
+
|
|
38
|
+
const olaresId = OlaresID.createMainnet(); // or createTestnet()
|
|
39
|
+
await olaresId.setSigner(privateKeyOrMnemonic);
|
|
40
|
+
|
|
41
|
+
const domainCtx = olaresId.domain('example.com');
|
|
42
|
+
const tagCtx = domainCtx.tag();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`tagCtx` is used for tag operations like `defineTag`, `setTag`, `getTag`, and `removeTag`.
|
|
46
|
+
|
|
31
47
|
### 1. Tag Definition
|
|
32
48
|
|
|
33
49
|
Before you can use a tag, you must **define** its type:
|
|
@@ -54,7 +70,7 @@ Each tag has a **tagger** - an Ethereum address authorized to set its value:
|
|
|
54
70
|
|
|
55
71
|
```typescript
|
|
56
72
|
// Set yourself as the tagger
|
|
57
|
-
const signerAddress = await signer.getAddress();
|
|
73
|
+
const signerAddress = await olaresId.signer.getAddress();
|
|
58
74
|
await domainCtx.setTagger('email', signerAddress);
|
|
59
75
|
```
|
|
60
76
|
|
|
@@ -185,8 +201,8 @@ const olaresId = OlaresID.createTestnet(); // or createMainnet()
|
|
|
185
201
|
await olaresId.setSigner(privateKeyOrMnemonic);
|
|
186
202
|
|
|
187
203
|
// Get domain and tag contexts
|
|
188
|
-
const
|
|
189
|
-
const tagCtx =
|
|
204
|
+
const domainCtx = olaresId.domain('example.com');
|
|
205
|
+
const tagCtx = domainCtx.tag();
|
|
190
206
|
```
|
|
191
207
|
|
|
192
208
|
### Complete Workflow
|
|
@@ -198,7 +214,7 @@ await tagCtx.defineTag('bio', bioType);
|
|
|
198
214
|
|
|
199
215
|
// 2. Set tagger (authorize yourself)
|
|
200
216
|
const signerAddress = await olaresId.signer.getAddress();
|
|
201
|
-
await
|
|
217
|
+
await domainCtx.setTagger('bio', signerAddress);
|
|
202
218
|
|
|
203
219
|
// 3. Set tag value
|
|
204
220
|
await tagCtx.setTag('example.com', 'bio', 'Web3 developer');
|
|
@@ -208,11 +224,11 @@ const bio = await tagCtx.getTag('example.com', 'bio');
|
|
|
208
224
|
console.log(bio); // "Web3 developer"
|
|
209
225
|
|
|
210
226
|
// 5. List all tags
|
|
211
|
-
const allTags = await
|
|
227
|
+
const allTags = await domainCtx.getAllTags();
|
|
212
228
|
console.log(allTags); // [{ name: 'bio', value: 'Web3 developer' }, ...]
|
|
213
229
|
|
|
214
230
|
// 6. List defined tag types
|
|
215
|
-
const definedTags = await
|
|
231
|
+
const definedTags = await domainCtx.getDefinedTags();
|
|
216
232
|
console.log(definedTags); // ['bio', 'email', 'age', ...]
|
|
217
233
|
```
|
|
218
234
|
|
|
@@ -221,17 +237,17 @@ console.log(definedTags); // ['bio', 'email', 'age', ...]
|
|
|
221
237
|
For common operations, use the high-level API:
|
|
222
238
|
|
|
223
239
|
```typescript
|
|
224
|
-
const
|
|
240
|
+
const domainCtx = olaresId.domain('example.com');
|
|
225
241
|
|
|
226
242
|
// Define and set in one step (using simplified API)
|
|
227
|
-
await
|
|
228
|
-
await
|
|
243
|
+
await domainCtx.defineSimpleTag('email', 'string');
|
|
244
|
+
await domainCtx.setTag('email', 'user@example.com');
|
|
229
245
|
|
|
230
246
|
// Get value
|
|
231
|
-
const email = await
|
|
247
|
+
const email = await domainCtx.getTag('email');
|
|
232
248
|
|
|
233
249
|
// Remove value
|
|
234
|
-
await
|
|
250
|
+
await domainCtx.removeTag('email');
|
|
235
251
|
```
|
|
236
252
|
|
|
237
253
|
### Array Operations
|
|
@@ -240,7 +256,7 @@ await domain.removeTag('email');
|
|
|
240
256
|
// Define array type
|
|
241
257
|
const linksType = TagTypeBuilder.array(TagTypeBuilder.string());
|
|
242
258
|
await tagCtx.defineTag('socialLinks', linksType);
|
|
243
|
-
await
|
|
259
|
+
await domainCtx.setTagger('socialLinks', signerAddress);
|
|
244
260
|
|
|
245
261
|
// Set array value
|
|
246
262
|
await tagCtx.setTag('example.com', 'socialLinks', [
|
|
@@ -277,60 +293,92 @@ The CLI provides simple commands for basic tag operations. For advanced usage (c
|
|
|
277
293
|
|
|
278
294
|
```bash
|
|
279
295
|
# Simple types
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
296
|
+
did-cli tag define example.com email string
|
|
297
|
+
did-cli tag define example.com age uint8
|
|
298
|
+
did-cli tag define example.com verified bool
|
|
283
299
|
|
|
284
300
|
# Array types (must be quoted!)
|
|
285
|
-
|
|
286
|
-
|
|
301
|
+
did-cli tag define example.com wallets "address[]"
|
|
302
|
+
did-cli tag define example.com links "string[]"
|
|
287
303
|
```
|
|
288
304
|
|
|
289
305
|
### Set Tagger
|
|
290
306
|
|
|
291
307
|
```bash
|
|
292
308
|
# Set tagger address
|
|
293
|
-
|
|
309
|
+
did-cli tag set-tagger example.com email 0xYOUR_ADDRESS
|
|
294
310
|
```
|
|
295
311
|
|
|
296
312
|
### Set Tag Value
|
|
297
313
|
|
|
314
|
+
`tag set` supports separating tag definition domain (`from`) and target object domain (`to`):
|
|
315
|
+
|
|
316
|
+
- `to`: the first `<domain>` argument
|
|
317
|
+
- `from`: optional `--from <domain|root>` (defaults to `to` if omitted)
|
|
318
|
+
|
|
298
319
|
```bash
|
|
299
320
|
# String value
|
|
300
|
-
|
|
321
|
+
did-cli tag set example.com email "user@example.com"
|
|
301
322
|
|
|
302
323
|
# Number value
|
|
303
|
-
|
|
324
|
+
did-cli tag set example.com age 30
|
|
304
325
|
|
|
305
326
|
# Boolean value
|
|
306
|
-
|
|
327
|
+
did-cli tag set example.com verified true
|
|
307
328
|
|
|
308
329
|
# Array value (use JSON, must be quoted!)
|
|
309
|
-
|
|
330
|
+
did-cli tag set example.com links '["https://twitter.com","https://github.com"]'
|
|
331
|
+
|
|
332
|
+
# Cross-domain: tag defined on parent.com, value written to child.parent.com
|
|
333
|
+
did-cli tag set child.parent.com profile "builder" --from parent.com
|
|
334
|
+
|
|
335
|
+
# Root-defined tag
|
|
336
|
+
did-cli tag set child.parent.com latestDID "did:key:..." --from root
|
|
310
337
|
```
|
|
311
338
|
|
|
312
339
|
### Get Tag Value
|
|
313
340
|
|
|
341
|
+
`tag get` uses the same `to` + optional `--from` rule as `tag set`.
|
|
342
|
+
|
|
314
343
|
```bash
|
|
315
344
|
# Read-only, no authentication required
|
|
316
|
-
|
|
345
|
+
did-cli tag get example.com email
|
|
346
|
+
|
|
347
|
+
# Cross-domain read
|
|
348
|
+
did-cli tag get child.parent.com profile --from parent.com
|
|
349
|
+
|
|
350
|
+
# Root-defined tag read
|
|
351
|
+
did-cli tag get child.parent.com latestDID --from root
|
|
317
352
|
```
|
|
318
353
|
|
|
319
354
|
### List Tags
|
|
320
355
|
|
|
356
|
+
`tag list` uses the same `to` + optional `--from` rule as `tag set`/`tag get`.
|
|
357
|
+
|
|
321
358
|
```bash
|
|
322
359
|
# List all tags with values
|
|
323
|
-
|
|
360
|
+
did-cli tag list example.com
|
|
361
|
+
|
|
362
|
+
# Cross-domain list (tag definitions on parent.com)
|
|
363
|
+
did-cli tag list child.parent.com --from parent.com
|
|
364
|
+
|
|
365
|
+
# Root-defined tag list
|
|
366
|
+
did-cli tag list child.parent.com --from root
|
|
324
367
|
|
|
325
368
|
# List all defined tag types
|
|
326
|
-
|
|
369
|
+
did-cli tag list-defined example.com
|
|
327
370
|
```
|
|
328
371
|
|
|
329
372
|
### Remove Tag Value
|
|
330
373
|
|
|
374
|
+
`tag remove` also supports optional `--from <domain|root>` for cross-domain tag definitions.
|
|
375
|
+
|
|
331
376
|
```bash
|
|
332
377
|
# Remove value (definition remains)
|
|
333
|
-
|
|
378
|
+
did-cli tag remove example.com email
|
|
379
|
+
|
|
380
|
+
# Cross-domain remove
|
|
381
|
+
did-cli tag remove child.parent.com profile --from parent.com
|
|
334
382
|
```
|
|
335
383
|
|
|
336
384
|
### Environment Variables
|
|
@@ -343,6 +391,12 @@ export PRIVATE_KEY_OR_MNEMONIC="0xYOUR_PRIVATE_KEY"
|
|
|
343
391
|
export PRIVATE_KEY_OR_MNEMONIC="your twelve word mnemonic phrase here"
|
|
344
392
|
```
|
|
345
393
|
|
|
394
|
+
### Root and Cross-Domain Notes
|
|
395
|
+
|
|
396
|
+
- If `--from` is omitted, CLI uses `from = to` (backward compatible behavior).
|
|
397
|
+
- Use `--from root` when tag type is defined on root domain (`""`).
|
|
398
|
+
- `tag define` and `tag set-tagger` are still executed on their explicit `<domain>` argument.
|
|
399
|
+
|
|
346
400
|
---
|
|
347
401
|
|
|
348
402
|
## Permission Management
|
|
@@ -353,7 +407,7 @@ The **tagger** is the only address authorized to set/modify a tag's value. The d
|
|
|
353
407
|
|
|
354
408
|
```typescript
|
|
355
409
|
// Set tagger (only domain owner can do this)
|
|
356
|
-
await
|
|
410
|
+
await domainCtx.setTagger('email', '0xTAGGER_ADDRESS');
|
|
357
411
|
|
|
358
412
|
// Get current tagger
|
|
359
413
|
const tagger = await tagCtx.getTagger('email');
|
|
@@ -372,8 +426,8 @@ console.log(tagger); // "0xTAGGER_ADDRESS"
|
|
|
372
426
|
**Pattern 1: Owner manages their own tags**
|
|
373
427
|
|
|
374
428
|
```typescript
|
|
375
|
-
const ownerAddress = await signer.getAddress();
|
|
376
|
-
await
|
|
429
|
+
const ownerAddress = await olaresId.signer.getAddress();
|
|
430
|
+
await domainCtx.setTagger('bio', ownerAddress);
|
|
377
431
|
await tagCtx.setTag('example.com', 'bio', 'My biography');
|
|
378
432
|
```
|
|
379
433
|
|
|
@@ -383,7 +437,7 @@ Delegating tagger permissions to a smart contract allows for more complex logic
|
|
|
383
437
|
|
|
384
438
|
```typescript
|
|
385
439
|
const CONTRACT_ADDRESS = '0x1234...'; // Your smart contract address
|
|
386
|
-
await
|
|
440
|
+
await domainCtx.setTagger('reputation', CONTRACT_ADDRESS);
|
|
387
441
|
// Now the contract can update the reputation tag with custom logic
|
|
388
442
|
```
|
|
389
443
|
|
|
@@ -423,7 +477,7 @@ try {
|
|
|
423
477
|
```typescript
|
|
424
478
|
// ✅ Good
|
|
425
479
|
await tagCtx.defineTag('email', emailType);
|
|
426
|
-
await
|
|
480
|
+
await domainCtx.setTagger('email', signerAddress);
|
|
427
481
|
await tagCtx.setTag('example.com', 'email', 'user@example.com');
|
|
428
482
|
|
|
429
483
|
// ❌ Bad - will fail with "Unauthorized"
|
|
@@ -471,10 +525,10 @@ await tagCtx.defineTag(
|
|
|
471
525
|
|
|
472
526
|
// Set tagger
|
|
473
527
|
const signer = await olaresId.signer.getAddress();
|
|
474
|
-
await
|
|
475
|
-
await
|
|
476
|
-
await
|
|
477
|
-
await
|
|
528
|
+
await domainCtx.setTagger('bio', signer);
|
|
529
|
+
await domainCtx.setTagger('followers', signer);
|
|
530
|
+
await domainCtx.setTagger('verified', signer);
|
|
531
|
+
await domainCtx.setTagger('socialLinks', signer);
|
|
478
532
|
|
|
479
533
|
// Set values
|
|
480
534
|
await tagCtx.setTag('alice.com', 'bio', 'Web3 enthusiast');
|
|
@@ -486,7 +540,7 @@ await tagCtx.setTag('alice.com', 'socialLinks', [
|
|
|
486
540
|
]);
|
|
487
541
|
|
|
488
542
|
// Read all tags
|
|
489
|
-
const tags = await
|
|
543
|
+
const tags = await domainCtx.getAllTags();
|
|
490
544
|
console.log(tags);
|
|
491
545
|
```
|
|
492
546
|
|
|
@@ -503,7 +557,7 @@ const nftType = TagTypeBuilder.tuple([
|
|
|
503
557
|
]);
|
|
504
558
|
|
|
505
559
|
await tagCtx.defineTag('nftMetadata', nftType);
|
|
506
|
-
await
|
|
560
|
+
await domainCtx.setTagger('nftMetadata', signerAddress);
|
|
507
561
|
|
|
508
562
|
// Set NFT metadata
|
|
509
563
|
await tagCtx.setTag('nft.com', 'nftMetadata', {
|
|
@@ -529,10 +583,10 @@ await tagCtx.defineTag('enabled', TagTypeBuilder.bool());
|
|
|
529
583
|
|
|
530
584
|
// Delegate tagger to service admin
|
|
531
585
|
const SERVICE_ADMIN = '0x1234...';
|
|
532
|
-
await
|
|
533
|
-
await
|
|
534
|
-
await
|
|
535
|
-
await
|
|
586
|
+
await domainCtx.setTagger('apiEndpoint', SERVICE_ADMIN);
|
|
587
|
+
await domainCtx.setTagger('rpcNodes', SERVICE_ADMIN);
|
|
588
|
+
await domainCtx.setTagger('maxRetries', SERVICE_ADMIN);
|
|
589
|
+
await domainCtx.setTagger('enabled', SERVICE_ADMIN);
|
|
536
590
|
|
|
537
591
|
// Service admin sets config
|
|
538
592
|
await tagCtx.setTag('service.com', 'apiEndpoint', 'https://api.example.com');
|
package/config.json
CHANGED
|
@@ -3,18 +3,20 @@
|
|
|
3
3
|
"sepolia": {
|
|
4
4
|
"rpc": "https://sepolia.optimism.io",
|
|
5
5
|
"contractDid": "0xe2D7c3a9013960E04d4E9F5F9B63fff37eEd97A8",
|
|
6
|
-
"contractRootResolver": "
|
|
6
|
+
"contractRootResolver": "0xbEE79099eD3eD33c8ce57df9fb79370aAc79f261",
|
|
7
7
|
"contractAbiType": "0x7386fCBae6Ad4CCE1499d9153D99bc950B589718",
|
|
8
8
|
"contractRootResolver2": "0xcbC02aa08c77a374eC0D5A0403E108b7573d96e8",
|
|
9
|
-
"supportSvcUrl": "https://api-test.olares.com/did/support"
|
|
9
|
+
"supportSvcUrl": "https://api-test.olares.com/did/support",
|
|
10
|
+
"queryContract": "0xAf0430AB9f2450c52E7401846C7CA702D53eCFC2"
|
|
10
11
|
},
|
|
11
12
|
"mainnet": {
|
|
12
13
|
"rpc": "https://optimism-rpc.publicnode.com",
|
|
13
14
|
"contractDid": "0x5DA4Fa8E567d86e52Ef8Da860de1be8f54cae97D",
|
|
14
|
-
"contractRootResolver": "
|
|
15
|
+
"contractRootResolver": "0x9bA3D0D3d2046aeD57e9897F7F79C58DfAa5325A",
|
|
15
16
|
"contractAbiType": "0x9ae3F16bD99294Af1784beB1a0A5C84bf2636365",
|
|
16
17
|
"contractRootResolver2": "0x7e7961aB771cA942CE4DB6e79579e016a33Dc95B",
|
|
17
|
-
"supportSvcUrl": "https://api.olares.com/did/support"
|
|
18
|
+
"supportSvcUrl": "https://api.olares.com/did/support",
|
|
19
|
+
"queryContract": "0x8305411EEa5C3F99f9426845Cf2977E77D5a1711"
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
}
|