@t3foundry/tasra-sdk 0.0.0-stage → 0.3.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +148 -0
- package/LICENSE +202 -0
- package/NOTICE +94 -0
- package/README.md +137 -2
- package/SECURITY.md +115 -0
- package/dist/app/approvals.d.ts +50 -0
- package/dist/app/approvals.js +90 -0
- package/dist/app/authorization.d.ts +19 -0
- package/dist/app/authorization.js +20 -0
- package/dist/app/client.d.ts +231 -0
- package/dist/app/client.js +272 -0
- package/dist/app/creation.d.ts +73 -0
- package/dist/app/creation.js +77 -0
- package/dist/app/deployment.d.ts +36 -0
- package/dist/app/deployment.js +18 -0
- package/dist/app/identity.d.ts +211 -0
- package/dist/app/identity.js +287 -0
- package/dist/app/index.d.ts +22 -0
- package/dist/app/index.js +12 -0
- package/dist/app/manifest.d.ts +74 -0
- package/dist/app/manifest.js +120 -0
- package/dist/app/node.d.ts +30 -0
- package/dist/app/node.js +159 -0
- package/dist/app/ready-slot.d.ts +157 -0
- package/dist/app/ready-slot.js +199 -0
- package/dist/app/tasra-client.d.ts +125 -0
- package/dist/app/tasra-client.js +79 -0
- package/dist/app/viem.d.ts +10 -0
- package/dist/app/viem.js +32 -0
- package/dist/app/wallet.d.ts +126 -0
- package/dist/app/wallet.js +137 -0
- package/dist/auth/dpop.d.ts +86 -0
- package/dist/auth/dpop.js +142 -0
- package/dist/auth/holderProof.d.ts +102 -0
- package/dist/auth/holderProof.js +161 -0
- package/dist/auth/identityScope.d.ts +19 -0
- package/dist/auth/identityScope.js +82 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.js +13 -0
- package/dist/auth/oid4vp.d.ts +230 -0
- package/dist/auth/oid4vp.js +780 -0
- package/dist/auth/rego/wasm/PINS.json +11 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm.d.ts +76 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm.js +379 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm_bg.wasm +0 -0
- package/dist/auth/rego.d.ts +192 -0
- package/dist/auth/rego.js +492 -0
- package/dist/auth/verifier.d.ts +166 -0
- package/dist/auth/verifier.js +211 -0
- package/dist/chain/abis/accountantSetRegistry.d.ts +441 -0
- package/dist/chain/abis/accountantSetRegistry.js +574 -0
- package/dist/chain/abis/accountantSlashing.d.ts +2071 -0
- package/dist/chain/abis/accountantSlashing.js +2670 -0
- package/dist/chain/abis/bondingCurve.d.ts +398 -0
- package/dist/chain/abis/bondingCurve.js +521 -0
- package/dist/chain/abis/equivocationSlasher.d.ts +292 -0
- package/dist/chain/abis/equivocationSlasher.js +379 -0
- package/dist/chain/abis/fixedTasraPriceOracle.d.ts +52 -0
- package/dist/chain/abis/fixedTasraPriceOracle.js +72 -0
- package/dist/chain/abis/index.d.ts +12801 -0
- package/dist/chain/abis/index.js +64 -0
- package/dist/chain/abis/keeperShareRegistry.d.ts +519 -0
- package/dist/chain/abis/keeperShareRegistry.js +675 -0
- package/dist/chain/abis/keyRegistry.d.ts +2421 -0
- package/dist/chain/abis/keyRegistry.js +3114 -0
- package/dist/chain/abis/livenessRegistry.d.ts +402 -0
- package/dist/chain/abis/livenessRegistry.js +524 -0
- package/dist/chain/abis/mockEurc.d.ts +210 -0
- package/dist/chain/abis/mockEurc.js +276 -0
- package/dist/chain/abis/nodeRegistry.d.ts +1630 -0
- package/dist/chain/abis/nodeRegistry.js +2113 -0
- package/dist/chain/abis/platformExecutor.d.ts +328 -0
- package/dist/chain/abis/platformExecutor.js +429 -0
- package/dist/chain/abis/prevrandaoSaltBeacon.d.ts +16 -0
- package/dist/chain/abis/prevrandaoSaltBeacon.js +24 -0
- package/dist/chain/abis/serviceRegistry.d.ts +556 -0
- package/dist/chain/abis/serviceRegistry.js +719 -0
- package/dist/chain/abis/settlement.d.ts +1624 -0
- package/dist/chain/abis/settlement.js +2096 -0
- package/dist/chain/abis/tasraSwapRouter.d.ts +92 -0
- package/dist/chain/abis/tasraSwapRouter.js +122 -0
- package/dist/chain/abis/tasraToken.d.ts +455 -0
- package/dist/chain/abis/tasraToken.js +599 -0
- package/dist/chain/abis/tasraVestingVault.d.ts +165 -0
- package/dist/chain/abis/tasraVestingVault.js +215 -0
- package/dist/chain/abis/thresholdRandomBeacon.d.ts +378 -0
- package/dist/chain/abis/thresholdRandomBeacon.js +494 -0
- package/dist/chain/abis/treasury.d.ts +301 -0
- package/dist/chain/abis/treasury.js +390 -0
- package/dist/chain/abis/verifierSetRegistry.d.ts +445 -0
- package/dist/chain/abis/verifierSetRegistry.js +579 -0
- package/dist/chain/client.d.ts +212 -0
- package/dist/chain/client.js +576 -0
- package/dist/chain/commitmentRecovery.d.ts +21 -0
- package/dist/chain/commitmentRecovery.js +44 -0
- package/dist/chain/committeeClient.d.ts +102 -0
- package/dist/chain/committeeClient.js +137 -0
- package/dist/chain/deployments.d.ts +56 -0
- package/dist/chain/deployments.js +269 -0
- package/dist/chain/discovery.d.ts +49 -0
- package/dist/chain/discovery.js +107 -0
- package/dist/chain/events.d.ts +58 -0
- package/dist/chain/events.js +125 -0
- package/dist/chain/format.d.ts +25 -0
- package/dist/chain/format.js +51 -0
- package/dist/chain/index.d.ts +41 -0
- package/dist/chain/index.js +56 -0
- package/dist/chain/manifest.d.ts +165 -0
- package/dist/chain/manifest.js +132 -0
- package/dist/chain/network-profiles.json +75 -0
- package/dist/chain/networks.d.ts +73 -0
- package/dist/chain/networks.js +62 -0
- package/dist/chain/node.d.ts +44 -0
- package/dist/chain/node.js +176 -0
- package/dist/chain/offchain.d.ts +149 -0
- package/dist/chain/offchain.js +73 -0
- package/dist/chain/provisionRule.d.ts +164 -0
- package/dist/chain/provisionRule.js +212 -0
- package/dist/chain/registeredAgent.d.ts +64 -0
- package/dist/chain/registeredAgent.js +140 -0
- package/dist/chain/registeredOperation.d.ts +49 -0
- package/dist/chain/registeredOperation.js +136 -0
- package/dist/chain/registeredRelay.d.ts +206 -0
- package/dist/chain/registeredRelay.js +312 -0
- package/dist/chain/revertReason.d.ts +14 -0
- package/dist/chain/revertReason.js +62 -0
- package/dist/chain/ruleAmendment.d.ts +80 -0
- package/dist/chain/ruleAmendment.js +195 -0
- package/dist/chain/ruleAmendmentCore.d.ts +129 -0
- package/dist/chain/ruleAmendmentCore.js +152 -0
- package/dist/chain/ruleInput.d.ts +10 -0
- package/dist/chain/ruleInput.js +13 -0
- package/dist/chain/serviceIdentity.d.ts +176 -0
- package/dist/chain/serviceIdentity.js +237 -0
- package/dist/chain/serviceProfiles.d.ts +39 -0
- package/dist/chain/serviceProfiles.js +74 -0
- package/dist/chain/services.d.ts +141 -0
- package/dist/chain/services.js +79 -0
- package/dist/chain/slotClient.d.ts +55 -0
- package/dist/chain/slotClient.js +62 -0
- package/dist/chain/slotSeed.d.ts +31 -0
- package/dist/chain/slotSeed.js +98 -0
- package/dist/chain/write.d.ts +431 -0
- package/dist/chain/write.js +958 -0
- package/dist/client/client.d.ts +112 -0
- package/dist/client/client.js +111 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +2 -0
- package/dist/client/session.d.ts +67 -0
- package/dist/client/session.js +238 -0
- package/dist/committee/client.d.ts +284 -0
- package/dist/committee/client.js +351 -0
- package/dist/committee/dual-sign.d.ts +110 -0
- package/dist/committee/dual-sign.js +202 -0
- package/dist/committee/ecdsa.d.ts +36 -0
- package/dist/committee/ecdsa.js +45 -0
- package/dist/committee/extraction.d.ts +82 -0
- package/dist/committee/extraction.js +96 -0
- package/dist/committee/index.d.ts +19 -0
- package/dist/committee/index.js +13 -0
- package/dist/committee/oauth.d.ts +51 -0
- package/dist/committee/oauth.js +90 -0
- package/dist/committee/receipts.d.ts +51 -0
- package/dist/committee/receipts.js +59 -0
- package/dist/committee/request.d.ts +264 -0
- package/dist/committee/request.js +305 -0
- package/dist/committee/token.d.ts +274 -0
- package/dist/committee/token.js +418 -0
- package/dist/crypto/constants.d.ts +10 -0
- package/dist/crypto/constants.js +32 -0
- package/dist/crypto/detect.d.ts +20 -0
- package/dist/crypto/detect.js +44 -0
- package/dist/crypto/envelope.d.ts +60 -0
- package/dist/crypto/envelope.js +243 -0
- package/dist/crypto/frost.d.ts +49 -0
- package/dist/crypto/frost.js +152 -0
- package/dist/crypto/hex.d.ts +7 -0
- package/dist/crypto/hex.js +24 -0
- package/dist/crypto/ibe-blob.d.ts +114 -0
- package/dist/crypto/ibe-blob.js +208 -0
- package/dist/crypto/ibe.d.ts +88 -0
- package/dist/crypto/ibe.js +262 -0
- package/dist/crypto/index.d.ts +12 -0
- package/dist/crypto/index.js +12 -0
- package/dist/crypto/kem.d.ts +55 -0
- package/dist/crypto/kem.js +241 -0
- package/dist/decryption/client.d.ts +64 -0
- package/dist/decryption/client.js +82 -0
- package/dist/decryption/index.d.ts +2 -0
- package/dist/decryption/index.js +2 -0
- package/dist/errors.d.ts +124 -0
- package/dist/errors.js +167 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +98 -0
- package/dist/keys/index.d.ts +1 -0
- package/dist/keys/index.js +4 -0
- package/dist/keys/node-client.d.ts +27 -0
- package/dist/keys/node-client.js +97 -0
- package/dist/oid4vp/binding.d.ts +76 -0
- package/dist/oid4vp/binding.js +118 -0
- package/dist/oid4vp/did-web.d.ts +49 -0
- package/dist/oid4vp/did-web.js +57 -0
- package/dist/oid4vp/index.d.ts +9 -0
- package/dist/oid4vp/index.js +10 -0
- package/dist/oid4vp/jose.d.ts +166 -0
- package/dist/oid4vp/jose.js +242 -0
- package/dist/oid4vp/jwe.d.ts +30 -0
- package/dist/oid4vp/jwe.js +93 -0
- package/dist/oid4vp/oid4vci.d.ts +84 -0
- package/dist/oid4vp/oid4vci.js +85 -0
- package/dist/oid4vp/request-object.d.ts +109 -0
- package/dist/oid4vp/request-object.js +96 -0
- package/dist/oid4vp/sd-jwt.d.ts +177 -0
- package/dist/oid4vp/sd-jwt.js +208 -0
- package/dist/oid4vp/verifier-agent.d.ts +161 -0
- package/dist/oid4vp/verifier-agent.js +132 -0
- package/dist/oid4vp/wallet.d.ts +116 -0
- package/dist/oid4vp/wallet.js +108 -0
- package/dist/recipient/store.d.ts +67 -0
- package/dist/recipient/store.js +98 -0
- package/dist/signing/ecdsa.d.ts +49 -0
- package/dist/signing/ecdsa.js +79 -0
- package/dist/signing/frost.d.ts +88 -0
- package/dist/signing/frost.js +145 -0
- package/dist/signing/index.d.ts +4 -0
- package/dist/signing/index.js +3 -0
- package/dist/slots/faucet.d.ts +23 -0
- package/dist/slots/faucet.js +35 -0
- package/dist/slots/index.d.ts +2 -0
- package/dist/slots/index.js +4 -0
- package/dist/verifier-agent/index.d.ts +241 -0
- package/dist/verifier-agent/index.js +411 -0
- package/docs/DEVELOPER-EXPERIENCE.md +62 -0
- package/docs/README.md +33 -0
- package/docs/access-control.md +76 -0
- package/docs/ai-development.md +292 -0
- package/docs/api.md +338 -0
- package/docs/application-api.md +335 -0
- package/docs/architecture.md +65 -0
- package/docs/basics.md +48 -0
- package/docs/capabilities.md +86 -0
- package/docs/chain.md +153 -0
- package/docs/compatibility.md +36 -0
- package/docs/consumer-migrations.md +80 -0
- package/docs/create-slot.md +104 -0
- package/docs/document-signing.md +243 -0
- package/docs/encrypted-notes.md +129 -0
- package/docs/encryption.md +100 -0
- package/docs/errors.md +76 -0
- package/docs/flows.md +289 -0
- package/docs/fuji.md +127 -0
- package/docs/funding.md +126 -0
- package/docs/getting-started.md +94 -0
- package/docs/glossary.md +44 -0
- package/docs/installation.md +132 -0
- package/docs/manage-slot.md +95 -0
- package/docs/native-approvals.md +124 -0
- package/docs/prerequisites.md +137 -0
- package/docs/read-slot.md +41 -0
- package/docs/reference/README.md +30 -0
- package/docs/reference/app-node.md +102 -0
- package/docs/reference/app.md +1737 -0
- package/docs/reference/chain-node.md +159 -0
- package/docs/reference/chain.md +3609 -0
- package/docs/reference/committee.md +2176 -0
- package/docs/reference/main.md +4068 -0
- package/docs/reference/oid4vp.md +2547 -0
- package/docs/reference/verifier-agent.md +498 -0
- package/docs/shared-account.md +168 -0
- package/docs/signing-and-encryption.md +52 -0
- package/docs/signing.md +172 -0
- package/examples/committee-slot.ts +16 -0
- package/examples/connect-fuji.ts +41 -0
- package/examples/connect-network.ts +14 -0
- package/examples/credential-approvals.ts +46 -0
- package/examples/document-signing/README.md +59 -0
- package/examples/document-signing/backend.ts +132 -0
- package/examples/document-signing/build.mjs +19 -0
- package/examples/document-signing/config.ts +34 -0
- package/examples/document-signing/gitignore.template +9 -0
- package/examples/document-signing/model.ts +140 -0
- package/examples/document-signing/network.ts +58 -0
- package/examples/document-signing/package.json +25 -0
- package/examples/document-signing/public/index.html +27 -0
- package/examples/document-signing/public/sample.pdf +31 -0
- package/examples/document-signing/public/styles.css +531 -0
- package/examples/document-signing/server.ts +358 -0
- package/examples/document-signing/setup.ts +111 -0
- package/examples/document-signing/store.ts +105 -0
- package/examples/document-signing/tsconfig.json +24 -0
- package/examples/document-signing/verify.ts +24 -0
- package/examples/document-signing/web/app.ts +312 -0
- package/examples/document-signing/web/preview.ts +67 -0
- package/examples/document-signing/web/wallet.ts +146 -0
- package/examples/document-signing/workflow.test.ts +228 -0
- package/examples/document-signing/workflow.ts +241 -0
- package/examples/document-signing.ts +96 -0
- package/examples/encrypted-notes.ts +86 -0
- package/examples/ethers-signer.ts +204 -0
- package/examples/fund-slot.ts +73 -0
- package/examples/getting-started.ts +25 -0
- package/examples/learning-authorize.ts +23 -0
- package/examples/learning-cancel-slot.ts +11 -0
- package/examples/learning-context.ts +28 -0
- package/examples/learning-create-slot.ts +25 -0
- package/examples/learning-read-slot.ts +8 -0
- package/examples/learning-renew-slot.ts +12 -0
- package/examples/learning-sign.ts +8 -0
- package/examples/live-config.ts +71 -0
- package/examples/minimal.ts +6 -0
- package/examples/native-approvals.ts +57 -0
- package/examples/network.ts +58 -0
- package/examples/offline.ts +16 -0
- package/examples/personal-vault.ts +20 -0
- package/examples/provision-slot.ts +47 -0
- package/examples/shared-account.ts +46 -0
- package/examples/slot-address.ts +13 -0
- package/examples/slot-creation.ts +9 -0
- package/examples/tutorial-negative.ts +26 -0
- package/examples/tutorial-support.ts +76 -0
- package/examples/viem-account.ts +203 -0
- package/package.json +303 -4
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Slot-driven ON-CHAIN DISCOVERY - turn a bare slot id into everything the
|
|
2
|
+
// committee-authorization flow needs, read straight from the registry:
|
|
3
|
+
//
|
|
4
|
+
// - resolveSlotKeeperUrls - the slot's assigned keeper nodes to their HTTP URLs
|
|
5
|
+
// (KeyRegistry.assignedNodes to NodeRegistry.nodeOf().url)
|
|
6
|
+
// - resolveVerifierDirectory - the active verifier set to {index,url,operator,pubkey}
|
|
7
|
+
// (NodeRegistry operators tagged keccak256("verifier"))
|
|
8
|
+
// - resolveSlotGroupKey - the slot's group public key + epoch, for local encrypt
|
|
9
|
+
// (KeyRegistry.getKeySlot - no node/verifier round-trip)
|
|
10
|
+
//
|
|
11
|
+
// A slot is "equipped with" its keeper committee at creation (drawn on-chain, URLs on
|
|
12
|
+
// chain), but not with a fixed verifier set: it carries only a verifierPolicy(committee,
|
|
13
|
+
// quorum), and the actual committee is drawn per-request from the *global* verifier set
|
|
14
|
+
// by the beacon. So node discovery is per-slot; verifier discovery is network-wide.
|
|
15
|
+
//
|
|
16
|
+
// Lives in the `@t3foundry/tasra-sdk/chain` subpath (viem). The resolved directory feeds the
|
|
17
|
+
// pure committee primitives in ../committee (which take injected chain reads).
|
|
18
|
+
import { keccak256, toHex } from 'viem';
|
|
19
|
+
/**
|
|
20
|
+
* The on-chain role tag verifier operators register under: `keccak256("verifier")`.
|
|
21
|
+
* The same tag the accountants use to build the settlement split, and the CLI to
|
|
22
|
+
* resolve a tagged operator set.
|
|
23
|
+
*/
|
|
24
|
+
export const VERIFIER_TAG = keccak256(toHex('verifier'));
|
|
25
|
+
/**
|
|
26
|
+
* The slot's assigned keeper nodes, resolved to their HTTP base URLs. These are the
|
|
27
|
+
* nodes any `/v1/committee/{sign,decrypt}` request for this slot must target. Order
|
|
28
|
+
* follows `assignedNodes`; url-less operators are skipped.
|
|
29
|
+
* @param chain Reader configured from the approved network manifest.
|
|
30
|
+
* @param slotId Slot whose assigned keeper endpoints are required.
|
|
31
|
+
*/
|
|
32
|
+
export async function resolveSlotKeeperUrls(chain, slotId) {
|
|
33
|
+
const ops = (await chain.readers.keyRegistry.assignedNodes(slotId));
|
|
34
|
+
// `allowFailure: false` - an unreadable operator must fail the call, not silently
|
|
35
|
+
// shrink the committee. A quietly short node list looks like a smaller slot.
|
|
36
|
+
const nodes = (await chain.readMany('NodeRegistry', 'nodeOf', ops.map(op => [op]), { allowFailure: false }));
|
|
37
|
+
return nodes.map(n => n.url).filter((u) => !!u);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read active verifier records in ascending operator-address order. Stable indices must match the anchored verifier snapshot; unreadable records reject discovery rather than silently renumbering the committee.
|
|
41
|
+
* @param chain Reader for the deployment registry.
|
|
42
|
+
* @returns Verifier endpoints, public keys and snapshot indices.
|
|
43
|
+
*/
|
|
44
|
+
export async function resolveVerifierDirectory(chain) {
|
|
45
|
+
const ops = (await chain.readers.nodeRegistry.activeOperators());
|
|
46
|
+
// `allowFailure: false` on both reads below is load-bearing, not caution. `index` is
|
|
47
|
+
// the position in this list, and the anchored snapshot's leaves are built from the same
|
|
48
|
+
// order - so one dropped operator renumbers every operator after it and the committee
|
|
49
|
+
// flow's inclusion proofs are built against the wrong leaves. A short list must be an
|
|
50
|
+
// error, never a different-but-plausible directory.
|
|
51
|
+
const flags = (await chain.readMany('NodeRegistry', 'hasTag', ops.map(op => [op, VERIFIER_TAG]), { allowFailure: false }));
|
|
52
|
+
// Ascending address = numeric order on fixed-width lowercase hex, which is what a
|
|
53
|
+
// byte-wise sort over the 20-byte addresses gives. Plain `<` on lowercased hex, not
|
|
54
|
+
// localeCompare (whose collation could disagree with byte order).
|
|
55
|
+
const lower = (a) => a.toLowerCase();
|
|
56
|
+
const verifierOps = ops
|
|
57
|
+
.filter((_, i) => flags[i])
|
|
58
|
+
.slice()
|
|
59
|
+
.sort((a, b) => (lower(a) < lower(b) ? -1 : lower(a) > lower(b) ? 1 : 0));
|
|
60
|
+
const nodes = (await chain.readMany('NodeRegistry', 'nodeOf', verifierOps.map(op => [op]), { allowFailure: false }));
|
|
61
|
+
return verifierOps.map((operator, index) => ({
|
|
62
|
+
index,
|
|
63
|
+
url: nodes[index].url,
|
|
64
|
+
operator,
|
|
65
|
+
pubkey: nodes[index].pubkey,
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Read the slot's group public key + epoch straight from `KeyRegistry.getKeySlot` - so
|
|
70
|
+
* `encrypt` needs no verifier, no JWT, and no node round-trip (it's local + offline once
|
|
71
|
+
* you hold the key).
|
|
72
|
+
* @param chain Reader for the deployment owning the slot.
|
|
73
|
+
* @param slotId Slot whose anchored public key and epoch are required.
|
|
74
|
+
*/
|
|
75
|
+
export async function resolveSlotGroupKey(chain, slotId) {
|
|
76
|
+
const s = (await chain.readers.keyRegistry.getKeySlot(slotId));
|
|
77
|
+
return { publicKey: s.publicKey, epoch: Number(s.epoch), mode: Number(s.mode) };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The on-chain role tag accountant operators register under: `keccak256("accountant")`.
|
|
81
|
+
* The same tag the accountants themselves resolve their set with.
|
|
82
|
+
*/
|
|
83
|
+
export const ACCOUNTANT_TAG = keccak256(toHex('accountant'));
|
|
84
|
+
/**
|
|
85
|
+
* Read active accountant HTTP endpoints through the registry role index, preserving registry order.
|
|
86
|
+
* @param chain Reader for the registry containing accountant role registrations.
|
|
87
|
+
*/
|
|
88
|
+
export async function resolveAccountantUrls(chain) {
|
|
89
|
+
const PAGE = 256n;
|
|
90
|
+
const urls = [];
|
|
91
|
+
for (let offset = 0n;;) {
|
|
92
|
+
const [page, total] = (await chain.read('NodeRegistry', 'taggedActiveOperatorsPage', [
|
|
93
|
+
ACCOUNTANT_TAG,
|
|
94
|
+
offset,
|
|
95
|
+
PAGE,
|
|
96
|
+
]));
|
|
97
|
+
if (!page.length)
|
|
98
|
+
break;
|
|
99
|
+
offset += BigInt(page.length);
|
|
100
|
+
for (const v of page)
|
|
101
|
+
if (v.url)
|
|
102
|
+
urls.push(v.url);
|
|
103
|
+
if (offset >= total)
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return urls;
|
|
107
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Log } from 'viem';
|
|
2
|
+
import { type ContractName } from './abis/index.js';
|
|
3
|
+
import type { Address } from './deployments.js';
|
|
4
|
+
/**
|
|
5
|
+
* Display category assigned to decoded contract events.
|
|
6
|
+
*/
|
|
7
|
+
export type EventCategory = 'node' | 'slot' | 'slashing' | 'tasra' | 'settlement' | 'beacon' | 'governance';
|
|
8
|
+
/** Default category per contract (the global event feed groups by this). */
|
|
9
|
+
export declare const CONTRACT_CATEGORY: Record<ContractName, EventCategory>;
|
|
10
|
+
/**
|
|
11
|
+
* Choose the event category, including event-specific overrides for a contract.
|
|
12
|
+
* @param contract Contract that emitted the event.
|
|
13
|
+
* @param eventName Decoded event name used for category overrides.
|
|
14
|
+
*/
|
|
15
|
+
export declare function categoryFor(contract: ContractName, eventName: string): EventCategory;
|
|
16
|
+
/**
|
|
17
|
+
* The set of event names declared by a contract's ABI.
|
|
18
|
+
* @param contract Contract whose vendored ABI supplies the event definitions.
|
|
19
|
+
*/
|
|
20
|
+
export declare function eventNamesOf(contract: ContractName): string[];
|
|
21
|
+
/** A normalized, storage-ready decoded log. */
|
|
22
|
+
export interface DecodedEvent {
|
|
23
|
+
/** Display category derived from the contract and event name. */
|
|
24
|
+
category: EventCategory;
|
|
25
|
+
/** Contract ABI used to decode this event. */
|
|
26
|
+
contract: ContractName;
|
|
27
|
+
/** Contract address that emitted the log. */
|
|
28
|
+
address: Address;
|
|
29
|
+
/** Decoded event name from the contract ABI. */
|
|
30
|
+
eventName: string;
|
|
31
|
+
/** Decoded args (bigints preserved; use `jsonSafe` before persisting). */
|
|
32
|
+
args: Record<string, unknown>;
|
|
33
|
+
/** Block containing the log. */
|
|
34
|
+
blockNumber: bigint;
|
|
35
|
+
/** Block hash reported by the RPC, or null when unavailable. */
|
|
36
|
+
blockHash: string | null;
|
|
37
|
+
/** Hash of the transaction that emitted the log. */
|
|
38
|
+
txHash: string;
|
|
39
|
+
/** Transaction position within the block, or null when unavailable. */
|
|
40
|
+
txIndex: number | null;
|
|
41
|
+
/** Log position within the block. */
|
|
42
|
+
logIndex: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Decode raw logs (already filtered to `address`) against `contract`'s ABI.
|
|
46
|
+
* Non-matching / anonymous logs are skipped. `strict:false` tolerates logs
|
|
47
|
+
* whose indexed topics can't be fully decoded.
|
|
48
|
+
* @param contract Contract ABI used to decode each log.
|
|
49
|
+
* @param address Deployed emitting contract address.
|
|
50
|
+
* @param logs Raw logs carrying topics, data and optional block metadata.
|
|
51
|
+
*/
|
|
52
|
+
export declare function decodeContractLogs(contract: ContractName, address: Address, logs: Log[]): DecodedEvent[];
|
|
53
|
+
/**
|
|
54
|
+
* Recursively convert bigints to strings so a decoded event can be JSON
|
|
55
|
+
* serialized / stored. Leaves everything else intact.
|
|
56
|
+
* @param value Value to convert recursively, including bigint and byte arrays.
|
|
57
|
+
*/
|
|
58
|
+
export declare function jsonSafe<T>(value: T): unknown;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Event registry + decoding. The explorer's indexer fetches logs per contract
|
|
2
|
+
// address and decodes them against that contract's ABI into a normalized
|
|
3
|
+
// `DecodedEvent`, tagged with a coarse category for the global feed and the
|
|
4
|
+
// per-domain views.
|
|
5
|
+
import { parseEventLogs } from 'viem';
|
|
6
|
+
import { CONTRACT_ABIS } from './abis/index.js';
|
|
7
|
+
/** Default category per contract (the global event feed groups by this). */
|
|
8
|
+
export const CONTRACT_CATEGORY = {
|
|
9
|
+
NodeRegistry: 'node',
|
|
10
|
+
KeyRegistry: 'slot',
|
|
11
|
+
ServiceRegistry: 'governance',
|
|
12
|
+
Settlement: 'settlement',
|
|
13
|
+
TasraToken: 'tasra',
|
|
14
|
+
BondingCurve: 'tasra',
|
|
15
|
+
Treasury: 'tasra',
|
|
16
|
+
TasraVestingVault: 'tasra',
|
|
17
|
+
ThresholdRandomBeacon: 'beacon',
|
|
18
|
+
PrevrandaoSaltBeacon: 'beacon',
|
|
19
|
+
EquivocationSlasher: 'slashing',
|
|
20
|
+
// The merged slashing hub, which also anchors liveness.
|
|
21
|
+
AccountantSlashing: 'slashing',
|
|
22
|
+
LivenessRegistry: 'node',
|
|
23
|
+
PlatformExecutor: 'governance',
|
|
24
|
+
FixedTasraPriceOracle: 'tasra',
|
|
25
|
+
MockEurc: 'tasra',
|
|
26
|
+
TasraSwapRouter: 'tasra',
|
|
27
|
+
// Per-request verifier-committee set anchoring.
|
|
28
|
+
VerifierSetRegistry: 'governance',
|
|
29
|
+
// Per-(slot,epoch) keeper verifying-share root anchor - feeds
|
|
30
|
+
// participant-weighted settlement (pay proven signers).
|
|
31
|
+
KeeperShareRegistry: 'settlement',
|
|
32
|
+
// Per-epoch snapshot of the accountant set. Structurally a twin of
|
|
33
|
+
// VerifierSetRegistry, but categorised with settlement rather than
|
|
34
|
+
// governance: what it anchors is who held a settle shard at epoch E, which
|
|
35
|
+
// is what the wrong-bundle witness reads before slashing a settlement.
|
|
36
|
+
AccountantSetRegistry: 'settlement',
|
|
37
|
+
};
|
|
38
|
+
// A few events live on a "node" contract but are conceptually slashing - the
|
|
39
|
+
// Slashing Center surfaces them alongside the dedicated oracle verdicts.
|
|
40
|
+
const EVENT_CATEGORY_OVERRIDES = {
|
|
41
|
+
'NodeRegistry.Slashed': 'slashing',
|
|
42
|
+
'NodeRegistry.BountyPaid': 'slashing',
|
|
43
|
+
'NodeRegistry.StakeRestored': 'slashing',
|
|
44
|
+
// Paid only when a slash is proven wrong, so it belongs to the accountability
|
|
45
|
+
// story next to the reversal, not to routine operator lifecycle.
|
|
46
|
+
'NodeRegistry.Compensated': 'slashing',
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Choose the event category, including event-specific overrides for a contract.
|
|
50
|
+
* @param contract Contract that emitted the event.
|
|
51
|
+
* @param eventName Decoded event name used for category overrides.
|
|
52
|
+
*/
|
|
53
|
+
export function categoryFor(contract, eventName) {
|
|
54
|
+
return (EVENT_CATEGORY_OVERRIDES[`${contract}.${eventName}`] ??
|
|
55
|
+
CONTRACT_CATEGORY[contract]);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The set of event names declared by a contract's ABI.
|
|
59
|
+
* @param contract Contract whose vendored ABI supplies the event definitions.
|
|
60
|
+
*/
|
|
61
|
+
export function eventNamesOf(contract) {
|
|
62
|
+
return CONTRACT_ABIS[contract]
|
|
63
|
+
.filter(i => i.type === 'event' && i.name)
|
|
64
|
+
.map(i => i.name);
|
|
65
|
+
}
|
|
66
|
+
function argsToRecord(args) {
|
|
67
|
+
if (args && typeof args === 'object' && !Array.isArray(args)) {
|
|
68
|
+
return args;
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(args)) {
|
|
71
|
+
return Object.fromEntries(args.map((v, i) => [String(i), v]));
|
|
72
|
+
}
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Decode raw logs (already filtered to `address`) against `contract`'s ABI.
|
|
77
|
+
* Non-matching / anonymous logs are skipped. `strict:false` tolerates logs
|
|
78
|
+
* whose indexed topics can't be fully decoded.
|
|
79
|
+
* @param contract Contract ABI used to decode each log.
|
|
80
|
+
* @param address Deployed emitting contract address.
|
|
81
|
+
* @param logs Raw logs carrying topics, data and optional block metadata.
|
|
82
|
+
*/
|
|
83
|
+
export function decodeContractLogs(contract, address, logs) {
|
|
84
|
+
const parsed = parseEventLogs({
|
|
85
|
+
abi: CONTRACT_ABIS[contract],
|
|
86
|
+
logs,
|
|
87
|
+
strict: false,
|
|
88
|
+
});
|
|
89
|
+
const out = [];
|
|
90
|
+
for (const p of parsed) {
|
|
91
|
+
if (!p.eventName)
|
|
92
|
+
continue;
|
|
93
|
+
out.push({
|
|
94
|
+
category: categoryFor(contract, p.eventName),
|
|
95
|
+
contract,
|
|
96
|
+
address,
|
|
97
|
+
eventName: p.eventName,
|
|
98
|
+
args: argsToRecord(p.args),
|
|
99
|
+
blockNumber: p.blockNumber ?? 0n,
|
|
100
|
+
blockHash: p.blockHash ?? null,
|
|
101
|
+
txHash: p.transactionHash ?? '0x',
|
|
102
|
+
txIndex: p.transactionIndex ?? null,
|
|
103
|
+
logIndex: p.logIndex ?? 0,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Recursively convert bigints to strings so a decoded event can be JSON
|
|
110
|
+
* serialized / stored. Leaves everything else intact.
|
|
111
|
+
* @param value Value to convert recursively, including bigint and byte arrays.
|
|
112
|
+
*/
|
|
113
|
+
export function jsonSafe(value) {
|
|
114
|
+
if (typeof value === 'bigint')
|
|
115
|
+
return value.toString();
|
|
116
|
+
if (Array.isArray(value))
|
|
117
|
+
return value.map(jsonSafe);
|
|
118
|
+
if (value && typeof value === 'object') {
|
|
119
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [
|
|
120
|
+
k,
|
|
121
|
+
jsonSafe(v),
|
|
122
|
+
]));
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abbreviate an address or hash by retaining its leading and trailing digits.
|
|
3
|
+
* @param hex Address or hash, with or without a hexadecimal prefix.
|
|
4
|
+
* @param lead Number of leading hexadecimal digits to retain.
|
|
5
|
+
* @param tail Number of trailing hexadecimal digits to retain.
|
|
6
|
+
*/
|
|
7
|
+
export declare function truncateHex(hex: string, lead?: number, tail?: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Format a token amount with thousands separators and truncated fractional digits.
|
|
10
|
+
* @param value Signed integer amount in token base units.
|
|
11
|
+
* @param decimals Number of decimal places used by the token.
|
|
12
|
+
* @param maxFractionDigits Maximum fractional digits retained without rounding.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatUnits(value: bigint, decimals?: number, maxFractionDigits?: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Format a basis-points integer (e.g. 1000) as a percentage string ("10%").
|
|
17
|
+
* @param bps Rate in basis points, where 100 basis points is one percent.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatBps(bps: number | bigint): string;
|
|
20
|
+
/**
|
|
21
|
+
* WAD (1e18 fixed-point) value to a decimal string, e.g. a price.
|
|
22
|
+
* @param wad Signed integer value scaled by 10 to the power of 18.
|
|
23
|
+
* @param maxFractionDigits Maximum fractional digits retained without rounding.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatWad(wad: bigint, maxFractionDigits?: number): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Display/format helpers for on-chain values. Pure, dependency-free.
|
|
2
|
+
/**
|
|
3
|
+
* Abbreviate an address or hash by retaining its leading and trailing digits.
|
|
4
|
+
* @param hex Address or hash, with or without a hexadecimal prefix.
|
|
5
|
+
* @param lead Number of leading hexadecimal digits to retain.
|
|
6
|
+
* @param tail Number of trailing hexadecimal digits to retain.
|
|
7
|
+
*/
|
|
8
|
+
export function truncateHex(hex, lead = 6, tail = 4) {
|
|
9
|
+
if (!hex)
|
|
10
|
+
return '';
|
|
11
|
+
const h = hex.startsWith('0x') ? hex : `0x${hex}`;
|
|
12
|
+
if (h.length <= 2 + lead + tail)
|
|
13
|
+
return h;
|
|
14
|
+
return `${h.slice(0, 2 + lead)}…${h.slice(-tail)}`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Format a token amount with thousands separators and truncated fractional digits.
|
|
18
|
+
* @param value Signed integer amount in token base units.
|
|
19
|
+
* @param decimals Number of decimal places used by the token.
|
|
20
|
+
* @param maxFractionDigits Maximum fractional digits retained without rounding.
|
|
21
|
+
*/
|
|
22
|
+
export function formatUnits(value, decimals = 18, maxFractionDigits = 4) {
|
|
23
|
+
const neg = value < 0n;
|
|
24
|
+
const v = neg ? -value : value;
|
|
25
|
+
const base = 10n ** BigInt(decimals);
|
|
26
|
+
const whole = v / base;
|
|
27
|
+
const frac = v % base;
|
|
28
|
+
const wholeStr = whole.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
29
|
+
if (maxFractionDigits === 0 || frac === 0n) {
|
|
30
|
+
return `${neg ? '-' : ''}${wholeStr}`;
|
|
31
|
+
}
|
|
32
|
+
let fracStr = frac.toString().padStart(decimals, '0').slice(0, maxFractionDigits);
|
|
33
|
+
fracStr = fracStr.replace(/0+$/, '');
|
|
34
|
+
return `${neg ? '-' : ''}${wholeStr}${fracStr ? `.${fracStr}` : ''}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Format a basis-points integer (e.g. 1000) as a percentage string ("10%").
|
|
38
|
+
* @param bps Rate in basis points, where 100 basis points is one percent.
|
|
39
|
+
*/
|
|
40
|
+
export function formatBps(bps) {
|
|
41
|
+
const n = Number(bps) / 100;
|
|
42
|
+
return `${Number.isInteger(n) ? n : n.toFixed(2)}%`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* WAD (1e18 fixed-point) value to a decimal string, e.g. a price.
|
|
46
|
+
* @param wad Signed integer value scaled by 10 to the power of 18.
|
|
47
|
+
* @param maxFractionDigits Maximum fractional digits retained without rounding.
|
|
48
|
+
*/
|
|
49
|
+
export function formatWad(wad, maxFractionDigits = 6) {
|
|
50
|
+
return formatUnits(wad, 18, maxFractionDigits);
|
|
51
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export * from './abis/index.js';
|
|
2
|
+
export { SlotCommitmentExpiredError, assertExpiredSlotCommitment } from './commitmentRecovery.js';
|
|
3
|
+
export { addressBookFromBroadcast, addressBookFromEnv, addressBookFromObject, DEFAULT_CHAIN_ID, requireAddress, requireVaultAddress, vaultKey, VAULT_TRANCHES, } from './deployments.js';
|
|
4
|
+
export type { AddressBook, Address, VaultTranche } from './deployments.js';
|
|
5
|
+
export { NETWORKS, networkNameForChain, resolveNetworkProfile, assertEurcFaucetAllowed } from './networks.js';
|
|
6
|
+
export type { NetworkName, NetworkPreset, ResolvedNetworkProfile } from './networks.js';
|
|
7
|
+
export { CONTRACT_CATEGORY, categoryFor, eventNamesOf, decodeContractLogs, jsonSafe, } from './events.js';
|
|
8
|
+
export type { EventCategory, DecodedEvent } from './events.js';
|
|
9
|
+
export { createTasraChainClient } from './client.js';
|
|
10
|
+
export type { ChainClientConfig, GetLogsWindowedOpts, TasraChainClient, } from './client.js';
|
|
11
|
+
export { nodeApi, verifierApi, parsePrometheus } from './offchain.js';
|
|
12
|
+
export type { FetchOpts, NodeInfo, KeySlotSummary, KeyListReply, SignedHeartbeat, MeteringReply, VerifierInfo, } from './offchain.js';
|
|
13
|
+
export { truncateHex, formatUnits, formatBps, formatWad } from './format.js';
|
|
14
|
+
export { createTasraWriteClient, generateClientKey, ruleCommitment, verifyRuleCommitment } from './write.js';
|
|
15
|
+
export { provisionRule, provisionRuleTypedData, PROVISION_RULE_ACTION } from './provisionRule.js';
|
|
16
|
+
export type { ProvisionRuleArgs, ProvisionRuleResult, KeeperProvisionResult } from './provisionRule.js';
|
|
17
|
+
export type { RuleInput } from './ruleInput.js';
|
|
18
|
+
export { readRuleAmendment, amendSlotRule, RuleAmendmentError } from './ruleAmendment.js';
|
|
19
|
+
export type { RuleAmendmentStatus, RuleAmendmentErrorCode, AmendSlotRuleArgs, AmendSlotRuleResult, AmendmentPhase } from './ruleAmendment.js';
|
|
20
|
+
export type { CreateSlotArgs, CreateSlotFromPolicyArgs, CommitRevealOptions, ProposeRuleArgs, ProposeRuleResult, RelayConfig, RelayReceipt, TasraWriteClient, SlotAuthType, SlotMode, WriteClientConfig, WriteClientKeyConfig, WriteClientWalletConfig, } from './write.js';
|
|
21
|
+
export { VERIFIER_TAG, ACCOUNTANT_TAG, resolveSlotKeeperUrls, resolveVerifierDirectory, resolveSlotGroupKey, resolveAccountantUrls, } from './discovery.js';
|
|
22
|
+
export type { SlotGroupKey } from './discovery.js';
|
|
23
|
+
export { requestSlotSeed } from './slotSeed.js';
|
|
24
|
+
export type { SlotSeed, SlotSeedOptions } from './slotSeed.js';
|
|
25
|
+
export { createCommitteeSlotClient } from './committeeClient.js';
|
|
26
|
+
export type { CommitteeSlotClient, CommitteeSlotClientConfig, SlotCommitteeSignOptions, SlotCommitteeDecryptOptions, CommitteeSignOptions, CommitteeDecryptOptions, } from './committeeClient.js';
|
|
27
|
+
export { createTasraSlotClient } from './slotClient.js';
|
|
28
|
+
export type { TasraSlotClient, TasraSlotClientConfig, ResolvedEndpoints, } from './slotClient.js';
|
|
29
|
+
export { SERVICE_TYPES, SERVICE_STATUSES, deriveServiceId, hashServiceManifest, readApprovedServiceRecord } from './services.js';
|
|
30
|
+
export type { ServiceType, ServiceStatus, ServiceRecord, ServiceApproval } from './services.js';
|
|
31
|
+
export { SERVICE_MANIFEST_PATH, SERVICE_IDENTITY_PATH, SERVICE_MANIFEST_MAX_BYTES, SERVICE_IDENTITY_MAX_BYTES, SERVICE_CHALLENGE_SECONDS, SERVICE_CHALLENGE_LIFETIME_SECONDS, SERVICE_IDENTITY_PROTOCOL, validateServiceEndpoint, encodeServiceManifest, verifyServiceManifest, serviceChallengeTypedData, encodeServiceChallenge, parseServiceChallenge, validateServiceChallenge, verifyServiceIdentity, authenticateApprovedService } from './serviceIdentity.js';
|
|
32
|
+
export type { ServiceManifest, ServiceChallenge, ServiceDiscoveryTransport, AuthenticatedService } from './serviceIdentity.js';
|
|
33
|
+
export { createRegisteredRelaySubmitter, reconcileRelayAttempt, RelayOutcomeUnknownError } from './registeredRelay.js';
|
|
34
|
+
export type { RegisteredRelayConfig, RelayTransport, RelayAttempt, RelayIntent, RelayReconciliation } from './registeredRelay.js';
|
|
35
|
+
export { createRegisteredAgentClient, AgentSessionCreationUnknownError } from './registeredAgent.js';
|
|
36
|
+
export type { AgentTransport, ApprovedAgentProfile, RegisteredAgentSession } from './registeredAgent.js';
|
|
37
|
+
export { parseApplicationServiceProfiles, applicationServiceProfilesDocument } from './serviceProfiles.js';
|
|
38
|
+
export type { ApplicationServiceProfiles, ApprovedServiceProfile } from './serviceProfiles.js';
|
|
39
|
+
export { openRegisteredVerifierAgentSession, awaitRegisteredVerifierAgentResult, assertRegisteredWalletRequest } from './registeredOperation.js';
|
|
40
|
+
export type { RegisteredVerifierAgentSession } from './registeredOperation.js';
|
|
41
|
+
export * from './manifest.js';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// @t3foundry/tasra-sdk/chain - on-chain + network READ capability for building
|
|
2
|
+
// observability tooling (e.g. an explorer) on top of a Tasra Network.
|
|
3
|
+
//
|
|
4
|
+
// This is a separate subpath export (`@t3foundry/tasra-sdk/chain`) so the crypto core
|
|
5
|
+
// entry stays lean and viem is only pulled in when chain features are imported.
|
|
6
|
+
// Contract ABIs (generated from the Foundry artifacts) + nametoabi map.
|
|
7
|
+
export * from './abis/index.js';
|
|
8
|
+
export { SlotCommitmentExpiredError, assertExpiredSlotCommitment } from './commitmentRecovery.js';
|
|
9
|
+
// Deployment address discovery.
|
|
10
|
+
export { addressBookFromBroadcast, addressBookFromEnv, addressBookFromObject, DEFAULT_CHAIN_ID, requireAddress, requireVaultAddress, vaultKey, VAULT_TRANCHES, } from './deployments.js';
|
|
11
|
+
// Network presets: chain id + RPC per known network. Only `local` today.
|
|
12
|
+
export { NETWORKS, networkNameForChain, resolveNetworkProfile, assertEurcFaucetAllowed } from './networks.js';
|
|
13
|
+
// Event registry + decoding.
|
|
14
|
+
export { CONTRACT_CATEGORY, categoryFor, eventNamesOf, decodeContractLogs, jsonSafe, } from './events.js';
|
|
15
|
+
// viem read client (PublicClient + windowed logs + typed readers).
|
|
16
|
+
export { createTasraChainClient } from './client.js';
|
|
17
|
+
// Off-chain network read clients.
|
|
18
|
+
export { nodeApi, verifierApi, parsePrometheus } from './offchain.js';
|
|
19
|
+
// Format helpers.
|
|
20
|
+
export { truncateHex, formatUnits, formatBps, formatWad } from './format.js';
|
|
21
|
+
// Client-side on-chain WRITE path: a sovereign client signs its own slot
|
|
22
|
+
// creation + settlement funding (no relayer). Pairs with the read client above.
|
|
23
|
+
// `ruleCommitment` is exported because a consumer that displays or verifies a
|
|
24
|
+
// slot's policy needs it: the commitment is the only link between an
|
|
25
|
+
// on-chain `KeySlot.ruleCommitment` and a candidate rule, and the plaintext must
|
|
26
|
+
// never go on chain. Without it here the package `exports` map makes it unreachable.
|
|
27
|
+
export { createTasraWriteClient, generateClientKey, ruleCommitment, verifyRuleCommitment } from './write.js';
|
|
28
|
+
// Creator-authorised rule provisioning: the step that makes a created slot USABLE.
|
|
29
|
+
// Without it a caller can create a slot and never deliver its rule, which needs an
|
|
30
|
+
// operator secret on the keeper's admin route.
|
|
31
|
+
export { provisionRule, provisionRuleTypedData, PROVISION_RULE_ACTION } from './provisionRule.js';
|
|
32
|
+
// Rule amendment: the status read and the end-to-end driver (the four writes live on the write client).
|
|
33
|
+
export { readRuleAmendment, amendSlotRule, RuleAmendmentError } from './ruleAmendment.js';
|
|
34
|
+
// Slot-driven on-chain discovery: resolve a slot's keeper URLs, the active verifier
|
|
35
|
+
// directory, and the slot's group key straight from the registry.
|
|
36
|
+
export { VERIFIER_TAG, ACCOUNTANT_TAG, resolveSlotKeeperUrls, resolveVerifierDirectory, resolveSlotGroupKey, resolveAccountantUrls, } from './discovery.js';
|
|
37
|
+
// accountant-seeded creation: the per-commitment draw seed. `createSlotCommitReveal` uses this internally; it is
|
|
38
|
+
// exported for a caller that drives commit and reveal itself (the CLI does) or wants to inspect
|
|
39
|
+
// what the accountant set answered before spending gas.
|
|
40
|
+
export { requestSlotSeed } from './slotSeed.js';
|
|
41
|
+
// The few-lines committee surface, driven by just a slot id: discovers the
|
|
42
|
+
// keeper node + verifier set from chain, then sign / encrypt / decrypt.
|
|
43
|
+
export { createCommitteeSlotClient } from './committeeClient.js';
|
|
44
|
+
// Slot-driven managed JWT client: discovers the slot's keeper nodes and CHOOSES a verifier
|
|
45
|
+
// from chain (that verifier mints the JWT), then opens a managed session - same surface as
|
|
46
|
+
// createTasraClient but endpoints come from the registry, not static config.
|
|
47
|
+
export { createTasraSlotClient } from './slotClient.js';
|
|
48
|
+
// Provider-owned service directory (metadata; endpoint authentication remains separate).
|
|
49
|
+
export { SERVICE_TYPES, SERVICE_STATUSES, deriveServiceId, hashServiceManifest, readApprovedServiceRecord } from './services.js';
|
|
50
|
+
export { SERVICE_MANIFEST_PATH, SERVICE_IDENTITY_PATH, SERVICE_MANIFEST_MAX_BYTES, SERVICE_IDENTITY_MAX_BYTES, SERVICE_CHALLENGE_SECONDS, SERVICE_CHALLENGE_LIFETIME_SECONDS, SERVICE_IDENTITY_PROTOCOL, validateServiceEndpoint, encodeServiceManifest, verifyServiceManifest, serviceChallengeTypedData, encodeServiceChallenge, parseServiceChallenge, validateServiceChallenge, verifyServiceIdentity, authenticateApprovedService } from './serviceIdentity.js';
|
|
51
|
+
export { createRegisteredRelaySubmitter, reconcileRelayAttempt, RelayOutcomeUnknownError } from './registeredRelay.js';
|
|
52
|
+
export { createRegisteredAgentClient, AgentSessionCreationUnknownError } from './registeredAgent.js';
|
|
53
|
+
export { parseApplicationServiceProfiles, applicationServiceProfilesDocument } from './serviceProfiles.js';
|
|
54
|
+
export { openRegisteredVerifierAgentSession, awaitRegisteredVerifierAgentResult, assertRegisteredWalletRequest } from './registeredOperation.js';
|
|
55
|
+
// Versioned, digest-pinned public deployment records.
|
|
56
|
+
export * from './manifest.js';
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { type Hex } from 'viem';
|
|
2
|
+
import type { AddressBook, Address } from './deployments.js';
|
|
3
|
+
import { type NetworkName } from './networks.js';
|
|
4
|
+
/**
|
|
5
|
+
* Manifest record of one deployed contract and its code, transaction and proxy evidence.
|
|
6
|
+
*/
|
|
7
|
+
export interface ContractRecord {
|
|
8
|
+
/**
|
|
9
|
+
* Canonical contract name used as the address-book key.
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Deployed contract address.
|
|
14
|
+
*/
|
|
15
|
+
address: Address;
|
|
16
|
+
/**
|
|
17
|
+
* Relative ABI artifact path in the release repository.
|
|
18
|
+
*/
|
|
19
|
+
abi: string;
|
|
20
|
+
/**
|
|
21
|
+
* Expected runtime-bytecode hash, or null before deployment evidence exists.
|
|
22
|
+
*/
|
|
23
|
+
runtimeCodeHash: Hex | null;
|
|
24
|
+
/**
|
|
25
|
+
* Deployment transaction and decimal block number, or null when unavailable.
|
|
26
|
+
*/
|
|
27
|
+
deployment: {
|
|
28
|
+
transactionHash: Hex;
|
|
29
|
+
blockNumber: string;
|
|
30
|
+
} | null;
|
|
31
|
+
/**
|
|
32
|
+
* Deterministic deployment inputs, or null for other deployment methods.
|
|
33
|
+
*/
|
|
34
|
+
create2: {
|
|
35
|
+
factory: Address;
|
|
36
|
+
salt: Hex;
|
|
37
|
+
initCodeHash: Hex;
|
|
38
|
+
} | null;
|
|
39
|
+
/**
|
|
40
|
+
* Expected implementation, code hash and upgrade authority for a proxy.
|
|
41
|
+
*/
|
|
42
|
+
proxy: {
|
|
43
|
+
implementation: Address;
|
|
44
|
+
runtimeCodeHash: Hex;
|
|
45
|
+
upgradeAuthority: Address | null;
|
|
46
|
+
} | null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Versioned network deployment record published in tasra-releases.
|
|
50
|
+
*/
|
|
51
|
+
export interface NetworkManifest {
|
|
52
|
+
/**
|
|
53
|
+
* Network manifest schema version.
|
|
54
|
+
*/
|
|
55
|
+
schemaVersion: 1;
|
|
56
|
+
/**
|
|
57
|
+
* Network profile associated with this deployment.
|
|
58
|
+
*/
|
|
59
|
+
network: NetworkName;
|
|
60
|
+
/**
|
|
61
|
+
* EVM chain ID matching the selected network profile.
|
|
62
|
+
*/
|
|
63
|
+
chainId: number;
|
|
64
|
+
/**
|
|
65
|
+
* Stable deployment identifier.
|
|
66
|
+
*/
|
|
67
|
+
deploymentId: string;
|
|
68
|
+
/**
|
|
69
|
+
* Positive revision number of this deployment record.
|
|
70
|
+
*/
|
|
71
|
+
revision: number;
|
|
72
|
+
/**
|
|
73
|
+
* Lifecycle state; only active records can configure live clients.
|
|
74
|
+
*/
|
|
75
|
+
status: 'planned' | 'active' | 'retired';
|
|
76
|
+
/**
|
|
77
|
+
* Network protocol compatibility version.
|
|
78
|
+
*/
|
|
79
|
+
protocolVersion: string;
|
|
80
|
+
/**
|
|
81
|
+
* Canonical block and timestamp recorded when deployment evidence was collected.
|
|
82
|
+
*/
|
|
83
|
+
verifiedAt: {
|
|
84
|
+
blockNumber: string;
|
|
85
|
+
blockHash: Hex;
|
|
86
|
+
timestamp: string;
|
|
87
|
+
} | null;
|
|
88
|
+
/**
|
|
89
|
+
* Contract addresses and deployment evidence.
|
|
90
|
+
*/
|
|
91
|
+
contracts: ContractRecord[];
|
|
92
|
+
/**
|
|
93
|
+
* Public service endpoints advertised by this network.
|
|
94
|
+
*/
|
|
95
|
+
services: {
|
|
96
|
+
kind: string;
|
|
97
|
+
url: string;
|
|
98
|
+
}[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Validate data only. Authenticity requires a trusted digest or signature separately.
|
|
102
|
+
* @param value Untrusted parsed JSON to validate against the supported manifest schema.
|
|
103
|
+
*/
|
|
104
|
+
export declare function parseNetworkManifest(value: unknown): NetworkManifest;
|
|
105
|
+
/**
|
|
106
|
+
* The digest must come from a verified release checksum file or application pin.
|
|
107
|
+
* @param text Exact UTF-8 manifest text downloaded from tasra-releases.
|
|
108
|
+
* @param expectedSha256 Independently trusted lowercase SHA-256 digest of that text.
|
|
109
|
+
*/
|
|
110
|
+
export declare function parsePinnedNetworkManifest(text: string, expectedSha256: string): NetworkManifest;
|
|
111
|
+
/**
|
|
112
|
+
* Planned and retired records can be displayed, but cannot configure a live client.
|
|
113
|
+
* @param manifest Network manifest whose lifecycle status must be active.
|
|
114
|
+
*/
|
|
115
|
+
export declare function addressBookFromManifest(manifest: NetworkManifest): AddressBook;
|
|
116
|
+
/**
|
|
117
|
+
* EIP-1967 storage slot containing a proxy implementation address.
|
|
118
|
+
*/
|
|
119
|
+
export declare const IMPLEMENTATION_SLOT: "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
|
|
120
|
+
/**
|
|
121
|
+
* Observed contract code and proxy implementation compared with a manifest record.
|
|
122
|
+
*/
|
|
123
|
+
export interface ContractObservation {
|
|
124
|
+
/**
|
|
125
|
+
* Contract name from the manifest.
|
|
126
|
+
*/
|
|
127
|
+
name: string;
|
|
128
|
+
/**
|
|
129
|
+
* Address read at the finalized block.
|
|
130
|
+
*/
|
|
131
|
+
address: Address;
|
|
132
|
+
/**
|
|
133
|
+
* Runtime hash pinned by the manifest.
|
|
134
|
+
*/
|
|
135
|
+
expectedCodeHash: Hex | null;
|
|
136
|
+
/**
|
|
137
|
+
* Observed runtime hash, or null when no code exists.
|
|
138
|
+
*/
|
|
139
|
+
observedCodeHash: Hex | null;
|
|
140
|
+
/**
|
|
141
|
+
* Observed proxy implementation address, if present.
|
|
142
|
+
*/
|
|
143
|
+
implementation: Address | null;
|
|
144
|
+
/**
|
|
145
|
+
* Observed implementation runtime hash, if present.
|
|
146
|
+
*/
|
|
147
|
+
implementationCodeHash: Hex | null;
|
|
148
|
+
/**
|
|
149
|
+
* Whether deployed code and any proxy implementation match the manifest.
|
|
150
|
+
*/
|
|
151
|
+
matches: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Observe a single finalized block. This verifies code identity, not business wiring or audit quality.
|
|
155
|
+
* @param manifest Manifest containing expected deployment addresses and code hashes.
|
|
156
|
+
* @param rpcUrl RPC endpoint for the same chain as the manifest.
|
|
157
|
+
*/
|
|
158
|
+
export declare function observeNetworkManifest(manifest: NetworkManifest, rpcUrl: string): Promise<{
|
|
159
|
+
chainId: number;
|
|
160
|
+
blockNumber: string;
|
|
161
|
+
blockHash: `0x${string}`;
|
|
162
|
+
observedAt: string;
|
|
163
|
+
contracts: ContractObservation[];
|
|
164
|
+
matches: boolean;
|
|
165
|
+
}>;
|