@t3foundry/tasra-sdk 0.0.0-stage → 0.3.0-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,102 @@
|
|
|
1
|
+
import type { TasraChainClient } from './client.js';
|
|
2
|
+
import { type ClientSigner, type CommitteeVerifier, type HolderProofPerVerifier } from '../committee/index.js';
|
|
3
|
+
import type { FrostSignResult } from '../signing/frost.js';
|
|
4
|
+
import type { Ciphertext } from '../crypto/kem.js';
|
|
5
|
+
import type { BlsPeer } from '../decryption/client.js';
|
|
6
|
+
/**
|
|
7
|
+
* Chain discovery and holder-proof configuration for threshold signing and identity decryption.
|
|
8
|
+
*/
|
|
9
|
+
export interface CommitteeSlotClientConfig {
|
|
10
|
+
/** Read client for the deployment (RPC + address book). */
|
|
11
|
+
chain: TasraChainClient;
|
|
12
|
+
/**
|
|
13
|
+
* Holder DID (the credentials' subject).
|
|
14
|
+
*
|
|
15
|
+
* Required for {@link CommitteeSlotClient.sign} and
|
|
16
|
+
* {@link CommitteeSlotClient.decrypt}, which must present credentials to the
|
|
17
|
+
* verifier committee. Not needed for {@link CommitteeSlotClient.encrypt},
|
|
18
|
+
* which only reads the slot's public group key from chain.
|
|
19
|
+
*/
|
|
20
|
+
holder?: string;
|
|
21
|
+
/** Compact-JWS verifiable credentials presented to the committee. Required for sign/decrypt. */
|
|
22
|
+
credentials?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Ignored compatibility field. Verifiers fetch the committed rule from a keeper; supplying this field does not change authorization.
|
|
25
|
+
*/
|
|
26
|
+
dcqlRule?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Holder proof-of-possession for the holder DID authentication key. Required for sign/decrypt.
|
|
29
|
+
*
|
|
30
|
+
* One string serves one verifier: the proof names its audience and burns a nonce that lives in
|
|
31
|
+
* that verifier, so on any deployment whose policy draws a committee the others answer 401 ("aud
|
|
32
|
+
* does not include this verifier"). Pass `holderProofPerVerifier({signer, audience, credentials,
|
|
33
|
+
* slotId})` there - it mints a fresh proof per drawn verifier, on every request.
|
|
34
|
+
*/
|
|
35
|
+
holderProof?: string | HolderProofPerVerifier;
|
|
36
|
+
/** sign the request bundle so keeper + audit can verify you authorized it. */
|
|
37
|
+
clientSigner?: ClientSigner;
|
|
38
|
+
/** Compound-token TTL in seconds (default 300). */
|
|
39
|
+
ttlSecs?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Per-call overrides for a committee-authorized FROST signature. */
|
|
42
|
+
export interface SlotCommitteeSignOptions {
|
|
43
|
+
/** Optional FROST participant identifiers selected for signing. */
|
|
44
|
+
signingSet?: number[];
|
|
45
|
+
/** Optional Ed25519 slot-owner approval signature for the signing request. */
|
|
46
|
+
userSignature?: Uint8Array;
|
|
47
|
+
/** Pin the keeper this request targets (anti-Sybil). Must be one of the slot's
|
|
48
|
+
* on-chain assigned operators; there is no way to point at an off-chain node. */
|
|
49
|
+
targetKeykeeper?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Everything a committee-authorized threshold decrypt needs beyond the slot id. */
|
|
52
|
+
export interface SlotCommitteeDecryptOptions {
|
|
53
|
+
/** Group ciphertext to decrypt through committee authorization. */
|
|
54
|
+
ciphertext: Ciphertext;
|
|
55
|
+
/** Original associated data used when encrypting the group ciphertext. */
|
|
56
|
+
identity: Uint8Array;
|
|
57
|
+
/** BLS identifiers (k..n, distinct) to run the ceremony with. */
|
|
58
|
+
decryptingSet: number[];
|
|
59
|
+
/** The libp2p peers for those identifiers. */
|
|
60
|
+
blsPeers: BlsPeer[];
|
|
61
|
+
/** Optional Ed25519 slot-owner signature required by the keeper policy. */
|
|
62
|
+
userSignature?: Uint8Array;
|
|
63
|
+
/** Expected slot key epoch for detecting ciphertext-key rotation. */
|
|
64
|
+
ciphertextEpoch?: number;
|
|
65
|
+
/** Pin the keeper this request targets (anti-Sybil); an on-chain assigned operator. */
|
|
66
|
+
targetKeykeeper?: string;
|
|
67
|
+
}
|
|
68
|
+
/** Signing options for a registry-discovered committee slot.
|
|
69
|
+
* @deprecated Use SlotCommitteeSignOptions.
|
|
70
|
+
*/
|
|
71
|
+
export type CommitteeSignOptions = SlotCommitteeSignOptions;
|
|
72
|
+
/** Decryption options for a registry-discovered committee slot.
|
|
73
|
+
* @deprecated Use SlotCommitteeDecryptOptions.
|
|
74
|
+
*/
|
|
75
|
+
export type CommitteeDecryptOptions = SlotCommitteeDecryptOptions;
|
|
76
|
+
/**
|
|
77
|
+
* Slot-based committee operations that discover keepers and verifiers from the chain.
|
|
78
|
+
*/
|
|
79
|
+
export interface CommitteeSlotClient {
|
|
80
|
+
/** Committee-authorized threshold FROST signature over `message`. */
|
|
81
|
+
sign(slotId: string, message: Uint8Array, opts?: SlotCommitteeSignOptions): Promise<FrostSignResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Encrypt to the slot's group key. Local - reads the public key from chain, then
|
|
84
|
+
* does the crypto in-process: no verifier, no JWT, no keeper node, and **no
|
|
85
|
+
* credentials** (a client built with only `{chain}` can call this). BLS
|
|
86
|
+
* (encryption) slots only.
|
|
87
|
+
*/
|
|
88
|
+
encrypt(slotId: string, plaintext: Uint8Array, opts?: {
|
|
89
|
+
identity?: Uint8Array;
|
|
90
|
+
epoch?: bigint | null;
|
|
91
|
+
}): Promise<Uint8Array>;
|
|
92
|
+
/** Committee-authorized threshold decrypt. */
|
|
93
|
+
decrypt(slotId: string, opts: SlotCommitteeDecryptOptions): Promise<Uint8Array>;
|
|
94
|
+
/** The resolved active verifier directory (discovered once, then cached). */
|
|
95
|
+
verifierDirectory(): Promise<CommitteeVerifier[]>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Create registry-discovered threshold signing, encryption and decryption operations. Signing and decryption require holder credentials and proofs against an anchored verifier snapshot. Encryption needs only the public group key read from the chain. The master key is not reconstructed by these threshold operations.
|
|
99
|
+
* @param cfg Chain reader and optional holder credentials and proof callbacks.
|
|
100
|
+
* @returns Committee client whose operations each take a slot ID.
|
|
101
|
+
*/
|
|
102
|
+
export declare function createCommitteeSlotClient(cfg: CommitteeSlotClientConfig): CommitteeSlotClient;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// The committee path, driven by a slot id and nothing else. See the JSDoc on
|
|
2
|
+
// createCommitteeSlotClient below for what it guarantees.
|
|
3
|
+
//
|
|
4
|
+
// const kk = createCommitteeSlotClient({chain, holder, credentials, holderProof})
|
|
5
|
+
// const sig = await kk.sign(slotId, message) // committee-authorized FROST
|
|
6
|
+
// const env = await kk.encrypt(slotId, plaintext) // local (key read from chain)
|
|
7
|
+
// const text = await kk.decrypt(slotId, {ciphertext, identity, decryptingSet, blsPeers})
|
|
8
|
+
import { resolveSlotKeeperUrls, resolveVerifierDirectory, resolveSlotGroupKey, } from './discovery.js';
|
|
9
|
+
import { requestCommitteeToken, committeeSign, committeeDecrypt, committeeChainReadsFromClient, } from '../committee/index.js';
|
|
10
|
+
import { encryptEnvelope, toBytes } from '../crypto/envelope.js';
|
|
11
|
+
import { hexToBytes } from '../crypto/hex.js';
|
|
12
|
+
/**
|
|
13
|
+
* Create registry-discovered threshold signing, encryption and decryption operations. Signing and decryption require holder credentials and proofs against an anchored verifier snapshot. Encryption needs only the public group key read from the chain. The master key is not reconstructed by these threshold operations.
|
|
14
|
+
* @param cfg Chain reader and optional holder credentials and proof callbacks.
|
|
15
|
+
* @returns Committee client whose operations each take a slot ID.
|
|
16
|
+
*/
|
|
17
|
+
export function createCommitteeSlotClient(cfg) {
|
|
18
|
+
const reads = committeeChainReadsFromClient(cfg.chain.readers);
|
|
19
|
+
// The credential fields are validated HERE rather than in the constructor: only
|
|
20
|
+
// sign/decrypt present credentials to the committee, while encrypt is a local
|
|
21
|
+
// operation over a public key read from chain. Checking them up front made it
|
|
22
|
+
// impossible to get an encrypt-only handle without credentials - which the
|
|
23
|
+
// crypto never needed.
|
|
24
|
+
function requireCredentials(op) {
|
|
25
|
+
const missing = [];
|
|
26
|
+
if (!cfg.holder)
|
|
27
|
+
missing.push('holder');
|
|
28
|
+
if (!cfg.credentials?.length)
|
|
29
|
+
missing.push('credentials');
|
|
30
|
+
// `dcqlRule` is not required, and demanding it was wrong:
|
|
31
|
+
// it refused to authorize unless the caller supplied a rule the verifier
|
|
32
|
+
// then ignored. A required input that decides nothing is worse than an
|
|
33
|
+
// unused one - it turns a working call into an error.
|
|
34
|
+
if (!cfg.holderProof)
|
|
35
|
+
missing.push('holderProof');
|
|
36
|
+
if (missing.length) {
|
|
37
|
+
throw new Error(`createCommitteeSlotClient: ${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} ` +
|
|
38
|
+
`required to authorize ${op} (they prove control of the holder DID to the verifier ` +
|
|
39
|
+
`committee). encrypt() does not need them — it reads the slot's public group key from chain.`);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
holder: cfg.holder,
|
|
43
|
+
credentials: cfg.credentials,
|
|
44
|
+
holderProof: cfg.holderProof,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// The verifier set is network-wide (not per-slot), so discover it once and cache.
|
|
48
|
+
let verifiersPromise;
|
|
49
|
+
function verifierDirectory() {
|
|
50
|
+
return (verifiersPromise ??= resolveVerifierDirectory(cfg.chain));
|
|
51
|
+
}
|
|
52
|
+
async function keeperUrl(slotId) {
|
|
53
|
+
const urls = await resolveSlotKeeperUrls(cfg.chain, slotId);
|
|
54
|
+
const url = urls[0];
|
|
55
|
+
if (!url)
|
|
56
|
+
throw new Error(`no assigned keeper node with a URL for slot ${slotId.slice(0, 10)}…`);
|
|
57
|
+
return url;
|
|
58
|
+
}
|
|
59
|
+
// Resolve keeper + verifiers from chain, gather the committee token, and REQUIRE the
|
|
60
|
+
// trustless verifier-set proofs (+ an anchored snapshot) so the keeper never validates
|
|
61
|
+
// against a statically-configured set. Shared by sign + decrypt.
|
|
62
|
+
async function tokenFor(slotId, op) {
|
|
63
|
+
const creds = requireCredentials(op);
|
|
64
|
+
const [verifiers, nodeUrl] = await Promise.all([verifierDirectory(), keeperUrl(slotId)]);
|
|
65
|
+
const res = await requestCommitteeToken({
|
|
66
|
+
chain: reads,
|
|
67
|
+
verifiers,
|
|
68
|
+
slotId,
|
|
69
|
+
// The rule is no longer sent - the verifier fetches the slot's
|
|
70
|
+
// confidential rule from a keeper and hash-verifies it on chain.
|
|
71
|
+
holder: creds.holder,
|
|
72
|
+
credentials: creds.credentials,
|
|
73
|
+
holderProof: creds.holderProof,
|
|
74
|
+
clientSigner: cfg.clientSigner,
|
|
75
|
+
ttlSecs: cfg.ttlSecs,
|
|
76
|
+
});
|
|
77
|
+
// `reads.snapshot` throws when VerifierSetRegistry isn't in the address book, and
|
|
78
|
+
// returns null when no snapshot is anchored (zero root / size 0) - both mean "no
|
|
79
|
+
// trustless source of truth", so treat them the same.
|
|
80
|
+
const snap = reads.snapshot
|
|
81
|
+
? await reads.snapshot(BigInt(res.epoch)).catch(() => null)
|
|
82
|
+
: null;
|
|
83
|
+
if (!snap) {
|
|
84
|
+
throw new Error(`no anchored VerifierSetRegistry snapshot at epoch ${res.epoch} — cannot run trustless ` +
|
|
85
|
+
`(the deployment must deploy + anchor the verifier set, and VerifierSetRegistry must be in ` +
|
|
86
|
+
`the address book); refusing to fall back to the keeper's configured set`);
|
|
87
|
+
}
|
|
88
|
+
if (!res.verifierProofs || res.verifierProofs.length !== res.token.signatures.length) {
|
|
89
|
+
throw new Error(`trustless verifier-set inclusion proofs are not derivable for every signer ` +
|
|
90
|
+
`(built ${res.verifierProofs?.length ?? 0}/${res.token.signatures.length}); refusing to fall back ` +
|
|
91
|
+
`to the keeper's configured verifier set`);
|
|
92
|
+
}
|
|
93
|
+
return { res, nodeUrl };
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
verifierDirectory,
|
|
97
|
+
async sign(slotId, message, opts) {
|
|
98
|
+
const { res, nodeUrl } = await tokenFor(slotId, 'sign()');
|
|
99
|
+
return committeeSign({
|
|
100
|
+
nodeUrl,
|
|
101
|
+
committeeToken: res.token,
|
|
102
|
+
message,
|
|
103
|
+
signingSet: opts?.signingSet,
|
|
104
|
+
userSignature: opts?.userSignature,
|
|
105
|
+
targetKeykeeper: opts?.targetKeykeeper,
|
|
106
|
+
verifierProofs: res.verifierProofs,
|
|
107
|
+
clientPubkey: res.clientPubkey,
|
|
108
|
+
clientSignature: res.clientSignature,
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
async encrypt(slotId, plaintext, opts) {
|
|
112
|
+
const id = slotId;
|
|
113
|
+
const { publicKey, epoch } = await resolveSlotGroupKey(cfg.chain, id);
|
|
114
|
+
const slotIdBytes = hexToBytes(id);
|
|
115
|
+
const identity = opts?.identity ?? slotIdBytes;
|
|
116
|
+
const ep = opts?.epoch !== undefined ? opts.epoch : BigInt(epoch);
|
|
117
|
+
return toBytes(encryptEnvelope(slotIdBytes, hexToBytes(publicKey), identity, plaintext, ep));
|
|
118
|
+
},
|
|
119
|
+
async decrypt(slotId, opts) {
|
|
120
|
+
const { res, nodeUrl } = await tokenFor(slotId, 'decrypt()');
|
|
121
|
+
return committeeDecrypt({
|
|
122
|
+
nodeUrl,
|
|
123
|
+
committeeToken: res.token,
|
|
124
|
+
ciphertext: opts.ciphertext,
|
|
125
|
+
identity: opts.identity,
|
|
126
|
+
decryptingSet: opts.decryptingSet,
|
|
127
|
+
blsPeers: opts.blsPeers,
|
|
128
|
+
userSignature: opts.userSignature,
|
|
129
|
+
ciphertextEpoch: opts.ciphertextEpoch,
|
|
130
|
+
targetKeykeeper: opts.targetKeykeeper,
|
|
131
|
+
verifierProofs: res.verifierProofs,
|
|
132
|
+
clientPubkey: res.clientPubkey,
|
|
133
|
+
clientSignature: res.clientSignature,
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ContractName } from './abis/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Hex-encoded EVM contract or account address.
|
|
4
|
+
*/
|
|
5
|
+
export type Address = `0x${string}`;
|
|
6
|
+
/** Canonical contract name to deployed address (lowercased keys allowed too). */
|
|
7
|
+
export type AddressBook = Partial<Record<ContractName, Address>> & {
|
|
8
|
+
[k: string]: Address | undefined;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Fallback chain ID retained for explicitly configured loopback connections. Set the chain ID from the downloaded tasra-releases network manifest for deployment access.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_CHAIN_ID = 1337;
|
|
14
|
+
/** The vesting tranches Deploy.s.sol creates, in the order it creates them. */
|
|
15
|
+
export declare const VAULT_TRANCHES: readonly ["investor", "team", "community"];
|
|
16
|
+
/**
|
|
17
|
+
* Named vesting allocation used to resolve its deployed vault.
|
|
18
|
+
*/
|
|
19
|
+
export type VaultTranche = (typeof VAULT_TRANCHES)[number];
|
|
20
|
+
/**
|
|
21
|
+
* Address-book key for one vesting tranche, e.g. TasraVestingVault_team.
|
|
22
|
+
* @param tranche Vesting allocation name.
|
|
23
|
+
*/
|
|
24
|
+
export declare function vaultKey(tranche: VaultTranche): string;
|
|
25
|
+
/**
|
|
26
|
+
* Build an AddressBook from a parsed Foundry broadcast run JSON. The last
|
|
27
|
+
* deployment of a given contract name wins (re-deploys later in the run
|
|
28
|
+
* override). Proxied contracts resolve to the proxy, which is the address
|
|
29
|
+
* callers must actually talk to.
|
|
30
|
+
* @param json Parsed Foundry broadcast artifact containing deployment transactions.
|
|
31
|
+
*/
|
|
32
|
+
export declare function addressBookFromBroadcast(json: unknown): AddressBook;
|
|
33
|
+
/**
|
|
34
|
+
* Parse supported deployment environment keys or a KEY=VALUE text blob into contract addresses. Empty values and entries that are not valid addresses are ignored. Prefer deployment addresses from a tasra-releases network manifest.
|
|
35
|
+
* @param src Environment key-value object or serialized environment text.
|
|
36
|
+
* @returns Address book keyed by canonical contract names.
|
|
37
|
+
*/
|
|
38
|
+
export declare function addressBookFromEnv(src: string | Record<string, string | undefined>): AddressBook;
|
|
39
|
+
/**
|
|
40
|
+
* Normalise an explicit object into an AddressBook (validates addresses).
|
|
41
|
+
* @param obj Object containing canonical contract names or supported environment aliases.
|
|
42
|
+
*/
|
|
43
|
+
export declare function addressBookFromObject(obj: Record<string, string>): AddressBook;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the named vesting allocation. The unqualified vault address is accepted as a fallback; callers aggregating allocations must deduplicate resolved addresses.
|
|
46
|
+
* @param book Deployment contract addresses.
|
|
47
|
+
* @param tranche Vesting allocation to resolve.
|
|
48
|
+
* @returns Address of the allocation vault; throws when missing.
|
|
49
|
+
*/
|
|
50
|
+
export declare function requireVaultAddress(book: AddressBook, tranche: VaultTranche): Address;
|
|
51
|
+
/**
|
|
52
|
+
* Resolve a contract address, throwing a clear error if missing.
|
|
53
|
+
* @param book Resolved deployment addresses.
|
|
54
|
+
* @param name Canonical contract name or supported address-book key.
|
|
55
|
+
*/
|
|
56
|
+
export declare function requireAddress(book: AddressBook, name: ContractName): Address;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// Deployment address discovery. An explorer needs to know where each contract
|
|
2
|
+
// lives on a given chain. Three interchangeable sources are supported:
|
|
3
|
+
//
|
|
4
|
+
// 1. A Foundry broadcast run JSON (contracts/broadcast/Deploy.s.sol/<id>/run-*.json):
|
|
5
|
+
// we map contractName to contractAddress across both deploy shapes the
|
|
6
|
+
// network's Deploy.s.sol emits - a plain CREATE, and (DETERMINISTIC=true /
|
|
7
|
+
// PRODUCTION) a CREATE2 through the DeterministicDeployer factory,
|
|
8
|
+
// which surfaces as `additionalContracts[]` on the factory CALL. UUPS
|
|
9
|
+
// contracts resolve to their ERC1967Proxy, never the
|
|
10
|
+
// implementation - see resolveProxies() below.
|
|
11
|
+
// 2. A `chain.env` style KEY=VALUE blob (mirrors the network's credentials file),
|
|
12
|
+
// e.g. NODE_REGISTRY=0x... KEY_REGISTRY=0x...
|
|
13
|
+
// 3. An explicit { ContractName: address } object.
|
|
14
|
+
//
|
|
15
|
+
// All loaders normalise to an AddressBook keyed by canonical contract names
|
|
16
|
+
// (matching the ABI / CONTRACT_ABIS keys).
|
|
17
|
+
/** The proxy the network deploys UUPS implementations behind. */
|
|
18
|
+
const PROXY_CONTRACT = 'ERC1967Proxy';
|
|
19
|
+
/**
|
|
20
|
+
* Fallback chain ID retained for explicitly configured loopback connections. Set the chain ID from the downloaded tasra-releases network manifest for deployment access.
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_CHAIN_ID = 1337;
|
|
23
|
+
/** The vesting tranches Deploy.s.sol creates, in the order it creates them. */
|
|
24
|
+
export const VAULT_TRANCHES = ['investor', 'team', 'community'];
|
|
25
|
+
/**
|
|
26
|
+
* Address-book key for one vesting tranche, e.g. TasraVestingVault_team.
|
|
27
|
+
* @param tranche Vesting allocation name.
|
|
28
|
+
*/
|
|
29
|
+
export function vaultKey(tranche) {
|
|
30
|
+
return `TasraVestingVault_${tranche}`;
|
|
31
|
+
}
|
|
32
|
+
function asAddress(s) {
|
|
33
|
+
if (!s)
|
|
34
|
+
return undefined;
|
|
35
|
+
const v = s.trim().toLowerCase();
|
|
36
|
+
return /^0x[0-9a-f]{40}$/.test(v) ? v : undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Collect every contract creation in the run, in order. Two shapes:
|
|
40
|
+
* - plain CREATE to a top-level transaction carrying contractName
|
|
41
|
+
* - CREATE2 (factory) to a CALL to DeterministicDeployer whose created
|
|
42
|
+
* contracts are listed in `additionalContracts[]`
|
|
43
|
+
*/
|
|
44
|
+
function collectDeployments(file) {
|
|
45
|
+
const out = [];
|
|
46
|
+
for (const tx of file.transactions ?? []) {
|
|
47
|
+
if (tx.transactionType === 'CREATE') {
|
|
48
|
+
const addr = asAddress(tx.contractAddress);
|
|
49
|
+
if (tx.contractName && addr)
|
|
50
|
+
out.push({
|
|
51
|
+
name: tx.contractName,
|
|
52
|
+
address: addr,
|
|
53
|
+
args: tx.arguments ?? undefined,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
for (const sub of tx.additionalContracts ?? []) {
|
|
57
|
+
if (sub.transactionType !== 'CREATE' && sub.transactionType !== 'CREATE2')
|
|
58
|
+
continue;
|
|
59
|
+
const addr = asAddress(sub.address);
|
|
60
|
+
if (sub.contractName && addr)
|
|
61
|
+
out.push({ name: sub.contractName, address: addr, initCode: sub.initCode });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Point each proxied contract name at its ERC1967Proxy rather than its
|
|
68
|
+
* implementation. Reads against an implementation address hit uninitialized
|
|
69
|
+
* storage and return zeros instead of reverting, so getting this wrong is
|
|
70
|
+
* silent - hence resolving the link explicitly rather than by position.
|
|
71
|
+
*
|
|
72
|
+
* The implementation is `ERC1967Proxy(implementation, initData)`'s first
|
|
73
|
+
* constructor argument. A plain-CREATE run gives it decoded in `arguments[0]`;
|
|
74
|
+
* a CREATE2 run gives only the init code, so we match on how `(address, bytes)`
|
|
75
|
+
* ABI-encodes: the padded implementation word followed by the `bytes` offset
|
|
76
|
+
* word (0x40). Matching the bare address is not enough - `initData` is an
|
|
77
|
+
* `initialize(...)` call that embeds further addresses (owner, treasury, …)
|
|
78
|
+
* after the implementation.
|
|
79
|
+
*/
|
|
80
|
+
function resolveProxies(deployments, book) {
|
|
81
|
+
const implName = new Map();
|
|
82
|
+
for (const d of deployments) {
|
|
83
|
+
if (d.name !== PROXY_CONTRACT)
|
|
84
|
+
implName.set(d.address, d.name);
|
|
85
|
+
}
|
|
86
|
+
for (const d of deployments) {
|
|
87
|
+
if (d.name !== PROXY_CONTRACT)
|
|
88
|
+
continue;
|
|
89
|
+
let impl = asAddress(d.args?.[0]);
|
|
90
|
+
if (!impl || !implName.has(impl)) {
|
|
91
|
+
const code = (d.initCode ?? '').toLowerCase();
|
|
92
|
+
const offsetWord = '0'.repeat(62) + '40'; // abi offset of the `bytes` arg
|
|
93
|
+
const matches = [...implName.keys()].filter(a => code.includes('0'.repeat(24) + a.slice(2) + offsetWord));
|
|
94
|
+
// Only accept an unambiguous hit; a guess here is worse than a miss,
|
|
95
|
+
// because requireAddress() surfaces a miss and a wrong proxy reads zeros.
|
|
96
|
+
impl = matches.length === 1 ? matches[0] : undefined;
|
|
97
|
+
}
|
|
98
|
+
const name = impl ? implName.get(impl) : undefined;
|
|
99
|
+
if (name)
|
|
100
|
+
book[name] = d.address;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Build an AddressBook from a parsed Foundry broadcast run JSON. The last
|
|
105
|
+
* deployment of a given contract name wins (re-deploys later in the run
|
|
106
|
+
* override). Proxied contracts resolve to the proxy, which is the address
|
|
107
|
+
* callers must actually talk to.
|
|
108
|
+
* @param json Parsed Foundry broadcast artifact containing deployment transactions.
|
|
109
|
+
*/
|
|
110
|
+
export function addressBookFromBroadcast(json) {
|
|
111
|
+
const file = json;
|
|
112
|
+
const deployments = collectDeployments(file);
|
|
113
|
+
const book = {};
|
|
114
|
+
for (const d of deployments)
|
|
115
|
+
book[d.name] = d.address;
|
|
116
|
+
resolveProxies(deployments, book);
|
|
117
|
+
resolveVaultTranches(deployments, book);
|
|
118
|
+
return book;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Split the vesting vaults into their tranches. Deploy.s.sol creates three
|
|
122
|
+
* instances from one artifact - `TasraVestingVault_investor`, `_team`,
|
|
123
|
+
* `_community` - but the run JSON labels all three `TasraVestingVault`, so a
|
|
124
|
+
* name-keyed book keeps only the last and silently reports the wrong tranche.
|
|
125
|
+
*
|
|
126
|
+
* Deployment order is the only discriminator available: with default env the
|
|
127
|
+
* investor and team constructor args are identical, so the addresses cannot be
|
|
128
|
+
* told apart by content. That order is fixed by the deploy script; if it ever
|
|
129
|
+
* grows a fourth vault or reorders, the extra entries stay unlabelled rather
|
|
130
|
+
* than being mislabelled.
|
|
131
|
+
*/
|
|
132
|
+
function resolveVaultTranches(deployments, book) {
|
|
133
|
+
const vaults = deployments.filter(d => d.name === 'TasraVestingVault');
|
|
134
|
+
if (vaults.length < 2)
|
|
135
|
+
return; // single vault - the plain name is unambiguous
|
|
136
|
+
vaults.forEach((v, i) => {
|
|
137
|
+
const tranche = VAULT_TRANCHES[i];
|
|
138
|
+
if (tranche)
|
|
139
|
+
book[vaultKey(tranche)] = v.address;
|
|
140
|
+
});
|
|
141
|
+
// The bare name would otherwise be whichever vault was deployed last, which
|
|
142
|
+
// reads like "the vault" but is only the community tranche.
|
|
143
|
+
delete book.TasraVestingVault;
|
|
144
|
+
}
|
|
145
|
+
// Map common env keys to canonical contract names, so a chain.env using
|
|
146
|
+
// snake/upper-case names still resolves.
|
|
147
|
+
const ENV_ALIASES = {
|
|
148
|
+
NODE_REGISTRY: 'NodeRegistry',
|
|
149
|
+
KEY_REGISTRY: 'KeyRegistry',
|
|
150
|
+
SERVICE_REGISTRY: 'ServiceRegistry',
|
|
151
|
+
SETTLEMENT: 'Settlement',
|
|
152
|
+
TSRA_TOKEN: 'TasraToken',
|
|
153
|
+
TASRA_TOKEN: 'TasraToken',
|
|
154
|
+
KEYK_TOKEN: 'TasraToken',
|
|
155
|
+
TOKEN: 'TasraToken',
|
|
156
|
+
BONDING_CURVE: 'BondingCurve',
|
|
157
|
+
SWAP_ROUTER: 'TasraSwapRouter',
|
|
158
|
+
TASRA_SWAP_ROUTER: 'TasraSwapRouter',
|
|
159
|
+
TREASURY: 'Treasury',
|
|
160
|
+
VAULT: 'TasraVestingVault',
|
|
161
|
+
TASRA_VAULT: 'TasraVestingVault',
|
|
162
|
+
TASRA_VESTING_VAULT: 'TasraVestingVault',
|
|
163
|
+
THRESHOLD_RANDOM_BEACON: 'ThresholdRandomBeacon',
|
|
164
|
+
THRESHOLD_BEACON: 'ThresholdRandomBeacon',
|
|
165
|
+
RANDOM_BEACON: 'ThresholdRandomBeacon',
|
|
166
|
+
BEACON: 'ThresholdRandomBeacon',
|
|
167
|
+
PREVRANDAO_BEACON: 'PrevrandaoSaltBeacon',
|
|
168
|
+
EQUIVOCATION_SLASHER: 'EquivocationSlasher',
|
|
169
|
+
// The four legacy oracle env keys are aliases for the merged AccountantSlashing
|
|
170
|
+
// hub, so resolve them straight to it.
|
|
171
|
+
ACCOUNTANT_SLASHING: 'AccountantSlashing',
|
|
172
|
+
SLASHING_ORACLE: 'AccountantSlashing',
|
|
173
|
+
FAULT_ORACLE: 'AccountantSlashing',
|
|
174
|
+
FALSE_SLASH_ORACLE: 'AccountantSlashing',
|
|
175
|
+
SETTLEMENT_FAULT_ORACLE: 'AccountantSlashing',
|
|
176
|
+
LIVENESS_REGISTRY: 'LivenessRegistry',
|
|
177
|
+
VERIFIER_SET_REGISTRY: 'VerifierSetRegistry',
|
|
178
|
+
ACCOUNTANT_SET_REGISTRY: 'AccountantSetRegistry',
|
|
179
|
+
KEEPER_SHARE_REGISTRY: 'KeeperShareRegistry',
|
|
180
|
+
PLATFORM_EXECUTOR: 'PlatformExecutor',
|
|
181
|
+
PRICE_ORACLE: 'FixedTasraPriceOracle',
|
|
182
|
+
EURC: 'MockEurc',
|
|
183
|
+
};
|
|
184
|
+
// Vesting tranches are not distinct contracts, so they key off vaultKey()
|
|
185
|
+
// rather than a ContractName.
|
|
186
|
+
const VAULT_ENV_ALIASES = Object.fromEntries(VAULT_TRANCHES.flatMap(t => [
|
|
187
|
+
[`TASRA_VAULT_${t.toUpperCase()}`, vaultKey(t)],
|
|
188
|
+
[`VAULT_${t.toUpperCase()}`, vaultKey(t)],
|
|
189
|
+
]));
|
|
190
|
+
/**
|
|
191
|
+
* Record one KEY=VALUE pair into `book`, resolving env aliases to their
|
|
192
|
+
* canonical contract name. Non-address values are skipped.
|
|
193
|
+
*/
|
|
194
|
+
function putEnvEntry(book, rawKey, rawVal) {
|
|
195
|
+
const key = rawKey.trim().toUpperCase().replace(/^EXPORT\s+/, '');
|
|
196
|
+
const val = rawVal.trim().replace(/^['"]|['"]$/g, '');
|
|
197
|
+
const addr = asAddress(val);
|
|
198
|
+
if (!addr)
|
|
199
|
+
return;
|
|
200
|
+
const canonical = ENV_ALIASES[key];
|
|
201
|
+
if (canonical)
|
|
202
|
+
book[canonical] = addr;
|
|
203
|
+
else if (VAULT_ENV_ALIASES[key])
|
|
204
|
+
book[VAULT_ENV_ALIASES[key]] = addr;
|
|
205
|
+
book[key] = addr; // keep the raw key too
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Parse supported deployment environment keys or a KEY=VALUE text blob into contract addresses. Empty values and entries that are not valid addresses are ignored. Prefer deployment addresses from a tasra-releases network manifest.
|
|
209
|
+
* @param src Environment key-value object or serialized environment text.
|
|
210
|
+
* @returns Address book keyed by canonical contract names.
|
|
211
|
+
*/
|
|
212
|
+
export function addressBookFromEnv(src) {
|
|
213
|
+
const book = {};
|
|
214
|
+
if (typeof src !== 'string') {
|
|
215
|
+
for (const [k, v] of Object.entries(src)) {
|
|
216
|
+
if (typeof v === 'string')
|
|
217
|
+
putEnvEntry(book, k, v);
|
|
218
|
+
}
|
|
219
|
+
return book;
|
|
220
|
+
}
|
|
221
|
+
for (const raw of src.split(/\r?\n/)) {
|
|
222
|
+
const line = raw.trim();
|
|
223
|
+
if (!line || line.startsWith('#'))
|
|
224
|
+
continue;
|
|
225
|
+
const eq = line.indexOf('=');
|
|
226
|
+
if (eq < 0)
|
|
227
|
+
continue;
|
|
228
|
+
putEnvEntry(book, line.slice(0, eq), line.slice(eq + 1));
|
|
229
|
+
}
|
|
230
|
+
return book;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Normalise an explicit object into an AddressBook (validates addresses).
|
|
234
|
+
* @param obj Object containing canonical contract names or supported environment aliases.
|
|
235
|
+
*/
|
|
236
|
+
export function addressBookFromObject(obj) {
|
|
237
|
+
const book = {};
|
|
238
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
239
|
+
const addr = asAddress(v);
|
|
240
|
+
if (addr)
|
|
241
|
+
book[k] = addr;
|
|
242
|
+
}
|
|
243
|
+
return book;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Resolve the named vesting allocation. The unqualified vault address is accepted as a fallback; callers aggregating allocations must deduplicate resolved addresses.
|
|
247
|
+
* @param book Deployment contract addresses.
|
|
248
|
+
* @param tranche Vesting allocation to resolve.
|
|
249
|
+
* @returns Address of the allocation vault; throws when missing.
|
|
250
|
+
*/
|
|
251
|
+
export function requireVaultAddress(book, tranche) {
|
|
252
|
+
const addr = book[vaultKey(tranche)] ?? book.TasraVestingVault;
|
|
253
|
+
if (!addr) {
|
|
254
|
+
throw new Error(`AddressBook is missing ${vaultKey(tranche)}. Known: ${Object.keys(book).join(', ') || '(none)'}`);
|
|
255
|
+
}
|
|
256
|
+
return addr;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Resolve a contract address, throwing a clear error if missing.
|
|
260
|
+
* @param book Resolved deployment addresses.
|
|
261
|
+
* @param name Canonical contract name or supported address-book key.
|
|
262
|
+
*/
|
|
263
|
+
export function requireAddress(book, name) {
|
|
264
|
+
const addr = book[name];
|
|
265
|
+
if (!addr) {
|
|
266
|
+
throw new Error(`AddressBook is missing ${name}. Known: ${Object.keys(book).join(', ') || '(none)'}`);
|
|
267
|
+
}
|
|
268
|
+
return addr;
|
|
269
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { TasraChainClient } from './client.js';
|
|
2
|
+
import type { CommitteeVerifier } from '../committee/request.js';
|
|
3
|
+
/**
|
|
4
|
+
* The on-chain role tag verifier operators register under: `keccak256("verifier")`.
|
|
5
|
+
* The same tag the accountants use to build the settlement split, and the CLI to
|
|
6
|
+
* resolve a tagged operator set.
|
|
7
|
+
*/
|
|
8
|
+
export declare const VERIFIER_TAG: `0x${string}`;
|
|
9
|
+
/**
|
|
10
|
+
* The slot's assigned keeper nodes, resolved to their HTTP base URLs. These are the
|
|
11
|
+
* nodes any `/v1/committee/{sign,decrypt}` request for this slot must target. Order
|
|
12
|
+
* follows `assignedNodes`; url-less operators are skipped.
|
|
13
|
+
* @param chain Reader configured from the approved network manifest.
|
|
14
|
+
* @param slotId Slot whose assigned keeper endpoints are required.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveSlotKeeperUrls(chain: TasraChainClient, slotId: `0x${string}`): Promise<string[]>;
|
|
17
|
+
/**
|
|
18
|
+
* 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.
|
|
19
|
+
* @param chain Reader for the deployment registry.
|
|
20
|
+
* @returns Verifier endpoints, public keys and snapshot indices.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveVerifierDirectory(chain: TasraChainClient): Promise<CommitteeVerifier[]>;
|
|
23
|
+
/** The slot's on-chain group public key + epoch (and mode), for local envelope encrypt. */
|
|
24
|
+
export interface SlotGroupKey {
|
|
25
|
+
/** 0x-prefixed group public key (96-byte compressed G2 for a BLS slot). */
|
|
26
|
+
publicKey: `0x${string}`;
|
|
27
|
+
/** Slot key epoch associated with the returned group public key. */
|
|
28
|
+
epoch: number;
|
|
29
|
+
/** 0 = frost, 1 = bls (KeyRegistry.Mode). Encrypt applies to BLS slots. */
|
|
30
|
+
mode: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read the slot's group public key + epoch straight from `KeyRegistry.getKeySlot` - so
|
|
34
|
+
* `encrypt` needs no verifier, no JWT, and no node round-trip (it's local + offline once
|
|
35
|
+
* you hold the key).
|
|
36
|
+
* @param chain Reader for the deployment owning the slot.
|
|
37
|
+
* @param slotId Slot whose anchored public key and epoch are required.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveSlotGroupKey(chain: TasraChainClient, slotId: `0x${string}`): Promise<SlotGroupKey>;
|
|
40
|
+
/**
|
|
41
|
+
* The on-chain role tag accountant operators register under: `keccak256("accountant")`.
|
|
42
|
+
* The same tag the accountants themselves resolve their set with.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ACCOUNTANT_TAG: `0x${string}`;
|
|
45
|
+
/**
|
|
46
|
+
* Read active accountant HTTP endpoints through the registry role index, preserving registry order.
|
|
47
|
+
* @param chain Reader for the registry containing accountant role registrations.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveAccountantUrls(chain: TasraChainClient): Promise<string[]>;
|