@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,62 @@
|
|
|
1
|
+
// Slot-driven managed JWT client. Same ergonomics as `createTasraClient`, but you
|
|
2
|
+
// bring a slot id + a chain client instead of hardcoding `{nodes, verifier}`:
|
|
3
|
+
//
|
|
4
|
+
// - the keeper NODES come from the slot's on-chain committee (assignedNodes to nodeOf().url)
|
|
5
|
+
// - the VERIFIER is CHOSEN from the on-chain verifier set (NodeRegistry operators tagged
|
|
6
|
+
// keccak256("verifier")) at random - that verifier validates your VP and issues the JWT
|
|
7
|
+
// - the JWT then authorizes the operation at a keeper node
|
|
8
|
+
//
|
|
9
|
+
// So the verifier is part of every session: `openSession` picks one from chain,
|
|
10
|
+
// and the returned session's JWT was minted by it. This composes the existing verifier-auth
|
|
11
|
+
// + session machinery (src/client) with chain discovery (src/chain/discovery) - no new
|
|
12
|
+
// crypto, just endpoint resolution moved from static config to the registry.
|
|
13
|
+
import { resolveSlotKeeperUrls, resolveVerifierDirectory } from './discovery.js';
|
|
14
|
+
import { createTasraClient, } from '../client/index.js';
|
|
15
|
+
/**
|
|
16
|
+
* Create managed JWT sessions using keeper endpoints and a randomly selected verifier discovered from the chain. The verifier authenticates the holder and issues the session token. Session key operations may reconstruct private key material in the client; use threshold committee operations when that custody model is unsuitable.
|
|
17
|
+
* @param cfg Chain reader, holder identity and optional endpoint routing or discovery callback.
|
|
18
|
+
* @returns Client that opens and tracks managed slot sessions.
|
|
19
|
+
*/
|
|
20
|
+
export function createTasraSlotClient(cfg) {
|
|
21
|
+
const rewrite = cfg.rewriteUrl ?? ((u) => u);
|
|
22
|
+
const open = new Set();
|
|
23
|
+
// The verifier set is network-wide (not per-slot), so discover it once and cache.
|
|
24
|
+
let verifiersPromise;
|
|
25
|
+
const verifierDirectory = () => (verifiersPromise ??= resolveVerifierDirectory(cfg.chain));
|
|
26
|
+
async function resolveEndpoints(slotId) {
|
|
27
|
+
const [nodesRaw, dir] = await Promise.all([
|
|
28
|
+
resolveSlotKeeperUrls(cfg.chain, slotId),
|
|
29
|
+
verifierDirectory(),
|
|
30
|
+
]);
|
|
31
|
+
const nodes = nodesRaw.map(rewrite).filter(Boolean);
|
|
32
|
+
if (nodes.length === 0)
|
|
33
|
+
throw new Error(`slot ${slotId.slice(0, 10)}… has no on-chain assigned keeper node with a URL`);
|
|
34
|
+
const verifiers = dir.map(v => rewrite(v.url)).filter(Boolean);
|
|
35
|
+
if (verifiers.length === 0)
|
|
36
|
+
throw new Error('no verifiers discovered on chain (NodeRegistry has no active keccak256("verifier")-tagged node with a URL)');
|
|
37
|
+
// Choose the verifier at random - the SDK "queries the chain and picks the verifier".
|
|
38
|
+
const verifier = verifiers[Math.floor(Math.random() * verifiers.length)];
|
|
39
|
+
return { slotId, nodes, verifier, verifierCount: verifiers.length };
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
resolveEndpoints,
|
|
43
|
+
verifierDirectory,
|
|
44
|
+
async openSession(slotId, auth, opts) {
|
|
45
|
+
const resolved = await resolveEndpoints(slotId);
|
|
46
|
+
cfg.onResolve?.(resolved);
|
|
47
|
+
// Compose the existing managed JWT client with the chain-resolved endpoints. The
|
|
48
|
+
// chosen verifier mints the JWT (openSession to resolveAuth to verify against it).
|
|
49
|
+
const inner = createTasraClient({ nodes: resolved.nodes, verifier: resolved.verifier, identity: cfg.identity });
|
|
50
|
+
const session = await inner.openSession(slotId, auth, { skewMs: cfg.skewMs, ...opts });
|
|
51
|
+
open.add(session);
|
|
52
|
+
return session;
|
|
53
|
+
},
|
|
54
|
+
sessions() {
|
|
55
|
+
return [...open];
|
|
56
|
+
},
|
|
57
|
+
async closeAll() {
|
|
58
|
+
await Promise.all([...open].map(s => s.close()));
|
|
59
|
+
open.clear();
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import type { TasraChainClient } from './client.js';
|
|
3
|
+
/** What an accountant returns from `POST /v1/slot-seed`. */
|
|
4
|
+
export interface SlotSeed {
|
|
5
|
+
/**
|
|
6
|
+
* Creation commitment for which the seed was requested.
|
|
7
|
+
*/
|
|
8
|
+
commitment: Hex;
|
|
9
|
+
/** `KeyRegistry.commitSeedDigest(commitment)` - what the signature is over. */
|
|
10
|
+
digest: Hex;
|
|
11
|
+
/** The 64-byte BN254 G1 threshold signature; pass as `seedSig` to `revealKeySlotWithSeed`. */
|
|
12
|
+
signature: Hex;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Accountant endpoint overrides and per-request timeout for committee seed discovery.
|
|
16
|
+
*/
|
|
17
|
+
export interface SlotSeedOptions {
|
|
18
|
+
/** Accountant base URLs. Resolved from `NodeRegistry` when omitted. */
|
|
19
|
+
urls?: string[];
|
|
20
|
+
/** Per-accountant HTTP timeout. The round itself is bounded server-side. */
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Request a committee draw seed and compare its digest with the registry. Checks signature encoding and rejects the point at infinity; signature cryptography is verified during the on-chain reveal.
|
|
25
|
+
* @param chain Reader for the deployment owning the commitment.
|
|
26
|
+
* @param keyRegistry Registry that will receive the reveal transaction.
|
|
27
|
+
* @param commitment Previously submitted creation commitment.
|
|
28
|
+
* @param opts Accountant endpoints and request timeout.
|
|
29
|
+
* @returns A seed response, or null when no accountant returns an acceptable response.
|
|
30
|
+
*/
|
|
31
|
+
export declare function requestSlotSeed(chain: TasraChainClient, keyRegistry: `0x${string}`, commitment: Hex, opts?: SlotSeedOptions): Promise<SlotSeed | null>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// accountant-seeded creation: the per-commitment draw seed.
|
|
2
|
+
//
|
|
3
|
+
// Under beacon-epoch creation a slot is committed, then revealed once the beacon has advanced past the
|
|
4
|
+
// commit's target epoch. The wait is what makes the committee draw ungrindable - the seed must
|
|
5
|
+
// post-date the commitment - and it costs one BEACON EPOCH, which at the production cadence is up
|
|
6
|
+
// to an hour.
|
|
7
|
+
//
|
|
8
|
+
// accountant-seeded creation keeps the property and drops the wait: the accountant set threshold-signs
|
|
9
|
+
// `KeyRegistry.commitSeedDigest(commitment)` on demand, and the reveal derives the draw seed from
|
|
10
|
+
// that signature. It post-dates the commitment because it is OVER the commitment.
|
|
11
|
+
//
|
|
12
|
+
// This module is the client half. It is deliberately best-effort: when no accountant answers, the
|
|
13
|
+
// caller falls back to the epoch wait, which still works and is what every existing deployment
|
|
14
|
+
// does. A seed that cannot be fetched is slower, never wrong.
|
|
15
|
+
import { keyRegistryAbi } from './abis/index.js';
|
|
16
|
+
import { resolveAccountantUrls } from './discovery.js';
|
|
17
|
+
/** A 64-byte BN254 G1 point, hex-encoded: the wire size of a threshold signature. */
|
|
18
|
+
const SIG_HEX_LEN = 2 + 64 * 2;
|
|
19
|
+
function parseSeed(body, commitment) {
|
|
20
|
+
if (!body || typeof body !== 'object')
|
|
21
|
+
return null;
|
|
22
|
+
const { digest, signature } = body;
|
|
23
|
+
if (typeof digest !== 'string' || typeof signature !== 'string')
|
|
24
|
+
return null;
|
|
25
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(digest))
|
|
26
|
+
return null;
|
|
27
|
+
// Pin the LENGTH, not just the alphabet. An accountant that answered with a short or
|
|
28
|
+
// over-long signature would otherwise be discovered by a reverting reveal, which costs gas and
|
|
29
|
+
// names `BadSeedSignature` - a message that points at the signature's validity, not its shape.
|
|
30
|
+
if (signature.length !== SIG_HEX_LEN || !/^0x[0-9a-fA-F]+$/.test(signature))
|
|
31
|
+
return null;
|
|
32
|
+
// An all-zero signature is the point at infinity. The contract rejects it (it would otherwise
|
|
33
|
+
// verify against an all-zero key from anyone), but rejecting it here means a misbehaving
|
|
34
|
+
// accountant cannot make a caller pay for the discovery.
|
|
35
|
+
if (BigInt(signature) === 0n)
|
|
36
|
+
return null;
|
|
37
|
+
return { commitment, digest: digest.toLowerCase(), signature: signature.toLowerCase() };
|
|
38
|
+
}
|
|
39
|
+
async function askOne(url, commitment, timeoutMs) {
|
|
40
|
+
let end = url.length;
|
|
41
|
+
while (end > 0 && url[end - 1] === '/')
|
|
42
|
+
end--;
|
|
43
|
+
const base = url.slice(0, end);
|
|
44
|
+
const res = await fetch(`${base}/v1/slot-seed`, {
|
|
45
|
+
method: 'POST',
|
|
46
|
+
headers: { 'content-type': 'application/json' },
|
|
47
|
+
body: JSON.stringify({ commitment }),
|
|
48
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
49
|
+
});
|
|
50
|
+
// 503 is the expected answer from an accountant whose threshold set is not up, and 404 from one
|
|
51
|
+
// whose chain view has not yet seen the commit. Both mean "ask someone else / try again",
|
|
52
|
+
// neither is an error worth surfacing - the caller's fallback is the epoch wait.
|
|
53
|
+
if (!res.ok)
|
|
54
|
+
return null;
|
|
55
|
+
return parseSeed(await res.json(), commitment);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Request a committee draw seed and compare its digest with the registry. Checks signature encoding and rejects the point at infinity; signature cryptography is verified during the on-chain reveal.
|
|
59
|
+
* @param chain Reader for the deployment owning the commitment.
|
|
60
|
+
* @param keyRegistry Registry that will receive the reveal transaction.
|
|
61
|
+
* @param commitment Previously submitted creation commitment.
|
|
62
|
+
* @param opts Accountant endpoints and request timeout.
|
|
63
|
+
* @returns A seed response, or null when no accountant returns an acceptable response.
|
|
64
|
+
*/
|
|
65
|
+
export async function requestSlotSeed(chain, keyRegistry, commitment, opts = {}) {
|
|
66
|
+
const timeoutMs = opts.timeoutMs ?? 20_000;
|
|
67
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 120_000) {
|
|
68
|
+
throw new Error('Invalid slot-seed timeout');
|
|
69
|
+
}
|
|
70
|
+
const urls = opts.urls ?? (await resolveAccountantUrls(chain).catch(() => []));
|
|
71
|
+
if (!urls.length)
|
|
72
|
+
return null;
|
|
73
|
+
const expected = (await chain.client.readContract({
|
|
74
|
+
address: keyRegistry,
|
|
75
|
+
abi: keyRegistryAbi,
|
|
76
|
+
functionName: 'commitSeedDigest',
|
|
77
|
+
args: [commitment],
|
|
78
|
+
}));
|
|
79
|
+
for (const url of urls) {
|
|
80
|
+
let seed;
|
|
81
|
+
try {
|
|
82
|
+
seed = await askOne(url, commitment, timeoutMs);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// One unreachable accountant is not a failure of the set. Move on.
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!seed)
|
|
89
|
+
continue;
|
|
90
|
+
// A digest that is not the registry's own means this accountant is bound to a DIFFERENT
|
|
91
|
+
// registry or chain - its signature could never satisfy the reveal. Skip it rather than
|
|
92
|
+
// spending gas to be told so.
|
|
93
|
+
if (seed.digest !== expected.toLowerCase())
|
|
94
|
+
continue;
|
|
95
|
+
return seed;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { type RuleInput } from './ruleInput.js';
|
|
2
|
+
import { type SlotSeed } from './slotSeed.js';
|
|
3
|
+
import { type Account, type Address, type Chain, type Hex, type PublicClient, type Transport, type WalletClient } from 'viem';
|
|
4
|
+
import { type RegisteredRelayConfig, type RelayReceipt, type RelayAttempt } from './registeredRelay.js';
|
|
5
|
+
export type { RelayReceipt } from './registeredRelay.js';
|
|
6
|
+
import { type OauthPolicyInput } from '../auth/rego.js';
|
|
7
|
+
import { type AmendmentOnChain } from './ruleAmendmentCore.js';
|
|
8
|
+
/**
|
|
9
|
+
* Return whether active operators include both tagged keepers and other roles, making an unfiltered draw include non-keepers.
|
|
10
|
+
* @param active Total active operator count.
|
|
11
|
+
* @param tagged Active operator count carrying the keeper tag.
|
|
12
|
+
*/
|
|
13
|
+
export declare function untaggedDrawSeatsNonKeepers(active: bigint, tagged: bigint): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Return whether a FILTERED draw cannot be seated: fewer tagged-ACTIVE candidates than the
|
|
16
|
+
* committee size the slot asks for. This is the shortfall `KeyRegistry` reverts
|
|
17
|
+
* `InsufficientFilteredPool(have, need)` on, judged on the tag filter alone.
|
|
18
|
+
* @param candidates Active operators carrying EVERY required tag (KeyRegistry takes the smallest
|
|
19
|
+
* tagged count when a slot requires several).
|
|
20
|
+
* @param n Committee size the slot asks for.
|
|
21
|
+
*/
|
|
22
|
+
export declare function filteredDrawCannotSeat(candidates: bigint, n: number): boolean;
|
|
23
|
+
import { type AddressBook, type VaultTranche } from './deployments.js';
|
|
24
|
+
/**
|
|
25
|
+
* The slot's key type, mirroring `KeyRegistry.Mode` on-chain:
|
|
26
|
+
* `frost` Ed25519 threshold signatures, `bls` BLS12-381 encryption/decryption,
|
|
27
|
+
* `tecdsa` secp256k1 threshold ECDSA (an EVM account - what `signEoaDigest` needs),
|
|
28
|
+
* `bls-bn254`, and `tecdsa-p256` (ES256). A deployment need not run keepers for
|
|
29
|
+
* every mode; creating a slot the network cannot key leaves it without a group key.
|
|
30
|
+
*/
|
|
31
|
+
export type SlotMode = 'frost' | 'bls' | 'tecdsa' | 'bls-bn254' | 'tecdsa-p256';
|
|
32
|
+
/**
|
|
33
|
+
* Authorization family recorded at creation. The default unspecified value declares no family. This label is not included in the committee-selection commitment.
|
|
34
|
+
*/
|
|
35
|
+
export type SlotAuthType = 'unspecified' | 'oid4vp' | 'oauth';
|
|
36
|
+
/**
|
|
37
|
+
* Map a `KeyRegistry.AuthType` ordinal read from chain back to its label.
|
|
38
|
+
* @param ordinal The `auth` field of `KeyRegistry.getKeySlot`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function slotAuthTypeOf(ordinal: number): SlotAuthType;
|
|
41
|
+
/**
|
|
42
|
+
* Approved relay configuration for gas-sponsored sender-bound contract calls. The creator signs the forward request; the relayer pays gas. ERC-20 approvals still require direct transactions.
|
|
43
|
+
*/
|
|
44
|
+
export type RelayConfig = RegisteredRelayConfig;
|
|
45
|
+
interface WriteClientConfigBase {
|
|
46
|
+
/** JSON-RPC endpoint for the deployment selected from the network manifest. */
|
|
47
|
+
rpcUrl: string;
|
|
48
|
+
/** Deployed contract address book from the selected network manifest. */
|
|
49
|
+
addresses: AddressBook;
|
|
50
|
+
/** When set, sender-bound calls are gas-sponsored through the platform relayer. */
|
|
51
|
+
relay?: RelayConfig;
|
|
52
|
+
/**
|
|
53
|
+
* EVM chain ID from the network manifest. Defaults to the bound wallet chain, or DEFAULT_CHAIN_ID for a loopback RPC when no chain is supplied.
|
|
54
|
+
*/
|
|
55
|
+
chainId?: number;
|
|
56
|
+
}
|
|
57
|
+
/** Sovereign-key variant: the SDK owns the account and signs with `privateKey`. */
|
|
58
|
+
export interface WriteClientKeyConfig extends WriteClientConfigBase {
|
|
59
|
+
/** The client's own 0x-prefixed 32-byte private key (it signs + pays gas). */
|
|
60
|
+
privateKey: Hex;
|
|
61
|
+
/** Must be omitted when supplying a raw private key. */
|
|
62
|
+
wallet?: undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Account-bound and chain-bound viem wallet used for signing without exposing its private key. Reads and receipt polling use the separately configured RPC.
|
|
66
|
+
*/
|
|
67
|
+
export interface WriteClientWalletConfig extends WriteClientConfigBase {
|
|
68
|
+
/** Account-bound and chain-bound wallet used for writes; mutually exclusive with a raw private key. */
|
|
69
|
+
wallet: WalletClient<Transport, Chain, Account>;
|
|
70
|
+
/** Must be omitted when supplying a wallet signer. */
|
|
71
|
+
privateKey?: undefined;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Either a private-key signer or an account-bound wallet with network write configuration.
|
|
75
|
+
*/
|
|
76
|
+
export type WriteClientConfig = WriteClientKeyConfig | WriteClientWalletConfig;
|
|
77
|
+
/**
|
|
78
|
+
* Recovery and timing controls for commit-reveal creation. Accountant seed discovery is attempted first; unavailable seeds fall back to a beacon epoch wait.
|
|
79
|
+
*/
|
|
80
|
+
export interface CommitRevealOptions {
|
|
81
|
+
/** Durable creation flow. Awaited before submission and after receiving each hash.
|
|
82
|
+
* Enabling recovery disables automatic transaction resubmission and chain-time nudges.
|
|
83
|
+
* Only supply hashes from the same persisted intent; never reconstruct lost salts.
|
|
84
|
+
*/
|
|
85
|
+
recovery?: {
|
|
86
|
+
commitTx?: Hex;
|
|
87
|
+
revealTx?: Hex;
|
|
88
|
+
seeded?: boolean;
|
|
89
|
+
onTransaction: (event: {
|
|
90
|
+
step: 'commit' | 'reveal';
|
|
91
|
+
phase: 'submitting' | 'submitted' | 'confirmed';
|
|
92
|
+
hash?: Hex;
|
|
93
|
+
seeded?: boolean;
|
|
94
|
+
}) => Promise<void>;
|
|
95
|
+
};
|
|
96
|
+
/** Cancel cooperative creation waits; already submitted transactions remain on chain. */
|
|
97
|
+
signal?: AbortSignal;
|
|
98
|
+
/**
|
|
99
|
+
* Maximum beacon-epoch wait in milliseconds when no accountant seed is available.
|
|
100
|
+
*/
|
|
101
|
+
maxWaitMs?: number;
|
|
102
|
+
/** Progress during that wait. Not called on the seeded path - there is no wait to report. */
|
|
103
|
+
onEpoch?: (cur: number, target: number) => void;
|
|
104
|
+
/**
|
|
105
|
+
* Attempt accountant seed discovery by default. Set false to wait for the beacon epoch instead; both paths bind the draw to the committed creation intent.
|
|
106
|
+
*/
|
|
107
|
+
slotSeed?: boolean;
|
|
108
|
+
/** Accountant base URLs for the seed request. Resolved from `NodeRegistry` when omitted. */
|
|
109
|
+
accountantUrls?: string[];
|
|
110
|
+
/** Per-accountant HTTP timeout for the seed request. */
|
|
111
|
+
slotSeedTimeoutMs?: number;
|
|
112
|
+
/** The seed that was obtained, or `null` when the epoch wait is being used instead. */
|
|
113
|
+
onSeed?: (seed: SlotSeed | null) => void;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Slot key mode, keeper threshold, private authorization rule and creation policies.
|
|
117
|
+
*/
|
|
118
|
+
export interface CreateSlotArgs extends RuleInput {
|
|
119
|
+
/**
|
|
120
|
+
* Private 32-byte authorization-rule salt, generated when omitted. Distinct from the committee-selection salt.
|
|
121
|
+
*/
|
|
122
|
+
ruleSalt?: Hex;
|
|
123
|
+
/**
|
|
124
|
+
* Minimum participating keeper shares required for an operation.
|
|
125
|
+
*/
|
|
126
|
+
k: number;
|
|
127
|
+
/**
|
|
128
|
+
* Total keeper shares assigned to the slot.
|
|
129
|
+
*/
|
|
130
|
+
n: number;
|
|
131
|
+
/**
|
|
132
|
+
* Key algorithm and threshold operation family.
|
|
133
|
+
*/
|
|
134
|
+
mode: SlotMode;
|
|
135
|
+
/**
|
|
136
|
+
* `KeyRegistry.AuthType` for this slot - how a holder authorises against the rule.
|
|
137
|
+
* Defaults to `'unspecified'` (ordinal 0), which declares nothing and is what every
|
|
138
|
+
* slot predating the field reads as. Set it when the rule is an OID4VP-DCQL query
|
|
139
|
+
* (`'oid4vp'`) or an OAuth/OIDC token rule (`'oauth'`).
|
|
140
|
+
*/
|
|
141
|
+
authType?: SlotAuthType;
|
|
142
|
+
/** Committee-draw filter tags; default `["keykeeper"]`. */
|
|
143
|
+
tags?: string[];
|
|
144
|
+
/**
|
|
145
|
+
* Explicit 32-byte slot identifier, generated when omitted.
|
|
146
|
+
*/
|
|
147
|
+
slotId?: Hex;
|
|
148
|
+
/**
|
|
149
|
+
* 32-byte committee-selection salt, generated when omitted.
|
|
150
|
+
*/
|
|
151
|
+
salt?: Hex;
|
|
152
|
+
/**
|
|
153
|
+
* Install amendment authority in the creation transaction. Omission makes the rule immutable. A later policy transaction can lose the race with key generation.
|
|
154
|
+
*/
|
|
155
|
+
rulePolicy?: RulePolicyArgs;
|
|
156
|
+
/**
|
|
157
|
+
* Allow raw share export, permitting a holder with enough shares to retain the reconstructed key permanently. Revocation cannot remove an exported key. Disabled by default and incompatible with rulePolicy.
|
|
158
|
+
*/
|
|
159
|
+
exportable?: boolean;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Slot creation from an authored Rego policy instead of a rule string. The SDK packs
|
|
163
|
+
* `oauthPolicy` into the canonical `kk_oauth` envelope with the network's own engine, refuses
|
|
164
|
+
* it when a keeper would not store it, and commits the envelope. Requires `authType: 'oauth'`.
|
|
165
|
+
* The packed envelope is returned as `rule`: provision exactly that string.
|
|
166
|
+
*/
|
|
167
|
+
export type CreateSlotFromPolicyArgs = Omit<CreateSlotArgs, 'rule'> & {
|
|
168
|
+
/** Must be omitted: the rule is the packed envelope. */
|
|
169
|
+
rule?: undefined;
|
|
170
|
+
/** Rego policy source, token specifications and optional entrypoint. */
|
|
171
|
+
oauthPolicy: OauthPolicyInput;
|
|
172
|
+
};
|
|
173
|
+
/** Who may amend a slot's authorization rule, and how slowly. */
|
|
174
|
+
export interface RulePolicyArgs {
|
|
175
|
+
/**
|
|
176
|
+
* Account authorized to propose rule amendments.
|
|
177
|
+
*/
|
|
178
|
+
admin: Address;
|
|
179
|
+
/** May veto or endorse. Omitted means none - which then requires a real timelock. */
|
|
180
|
+
guardian?: Address;
|
|
181
|
+
/**
|
|
182
|
+
* Required amendment delay in seconds. Without a guardian, the contract minimum delay applies.
|
|
183
|
+
*/
|
|
184
|
+
timelockSecs: number;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* A rule amendment: the new rule (a clear rule string, or an authored Rego policy the SDK packs
|
|
188
|
+
* into a `kk_oauth` envelope) for an existing slot, committed with the slot's saved rule salt.
|
|
189
|
+
*/
|
|
190
|
+
export type ProposeRuleArgs = ({
|
|
191
|
+
rule: string;
|
|
192
|
+
} | {
|
|
193
|
+
oauthPolicy: OauthPolicyInput;
|
|
194
|
+
}) & {
|
|
195
|
+
/** 32-byte identifier of the slot whose rule changes. */
|
|
196
|
+
slotId: Hex;
|
|
197
|
+
/** The slot's rule salt (from creation). Amendments reuse it; it is never minted here. */
|
|
198
|
+
ruleSalt: Hex;
|
|
199
|
+
};
|
|
200
|
+
/** A confirmed `proposeRuleUpdate`, decoded from its `RuleUpdateProposed` event. */
|
|
201
|
+
export interface ProposeRuleResult {
|
|
202
|
+
/** Slot whose rule amendment was proposed. */
|
|
203
|
+
slotId: Hex;
|
|
204
|
+
/** Transaction that carried the proposal. */
|
|
205
|
+
txHash: Hex;
|
|
206
|
+
/** Amendment version the contract assigned. */
|
|
207
|
+
version: number;
|
|
208
|
+
/** Chain time (Unix seconds) from which the amendment may activate. */
|
|
209
|
+
notBefore: number;
|
|
210
|
+
/** Salted commitment of the proposed rule. */
|
|
211
|
+
ruleCommitment: Hex;
|
|
212
|
+
/** Rule salt the commitment was computed with. */
|
|
213
|
+
ruleSalt: Hex;
|
|
214
|
+
/** Exact rule string committed; deliver exactly this to the keepers. */
|
|
215
|
+
rule: string;
|
|
216
|
+
/** Relay receipt, when the proposal was gas-sponsored. */
|
|
217
|
+
relay?: RelayReceipt;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Resolve the rule string an amendment commits to: an `oauthPolicy` is packed into the canonical
|
|
221
|
+
* `kk_oauth` envelope, a `rule` is taken as given. No chain call; the auth-type check needs the
|
|
222
|
+
* slot and runs in {@link amendmentPreflight}.
|
|
223
|
+
* @param a Amendment arguments carrying exactly one of `rule` and `oauthPolicy`.
|
|
224
|
+
* @param what Caller name used in error messages.
|
|
225
|
+
*/
|
|
226
|
+
export declare function resolveAmendmentRule(a: ProposeRuleArgs, what: string): Promise<string>;
|
|
227
|
+
/**
|
|
228
|
+
* Refuse, before signing, an amendment rule the slot's keepers would never store: a `kk_oauth`
|
|
229
|
+
* envelope on a slot not created with `authType: 'oauth'` (`wrong-auth-type`), or an envelope
|
|
230
|
+
* that fails the network's gate (`not-admissible`). An OID4VP rule on an `oauth` slot stays allowed.
|
|
231
|
+
* @param rule Resolved amendment rule.
|
|
232
|
+
* @param state The slot's amendment state read from chain.
|
|
233
|
+
* @param slotId Slot being amended.
|
|
234
|
+
* @param what Caller name used in error messages.
|
|
235
|
+
*/
|
|
236
|
+
export declare function amendmentPreflight(rule: string, state: AmendmentOnChain, slotId: Hex, what: string): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Compute the salted rule commitment. OID4VP queries and `kk_oauth` policy envelopes use canonical JSON; other rule formats retain their exact bytes.
|
|
239
|
+
* @param ruleSalt Private 32-byte salt saved with the slot creation intent.
|
|
240
|
+
* @param rule Clear authorization rule; OID4VP queries and policy envelopes are canonicalized before hashing.
|
|
241
|
+
*/
|
|
242
|
+
export declare function ruleCommitment(ruleSalt: Hex, rule: string): Hex;
|
|
243
|
+
/**
|
|
244
|
+
* Return whether the disclosed rule and salt reproduce the on-chain commitment. Invalid inputs and mismatches return false.
|
|
245
|
+
* @param rule Clear rule received for the slot.
|
|
246
|
+
* @param ruleSalt Private salt associated with that rule commitment.
|
|
247
|
+
* @param onChainRuleCommitment Commitment read from the on-chain slot.
|
|
248
|
+
*/
|
|
249
|
+
export declare function verifyRuleCommitment(rule: string, ruleSalt: Hex, onChainRuleCommitment: Hex): boolean;
|
|
250
|
+
/** Fresh 0x-prefixed 32-byte private key for a new sovereign client account. */
|
|
251
|
+
export declare function generateClientKey(): Hex;
|
|
252
|
+
/**
|
|
253
|
+
* Create an account-bound client for slot lifecycle, settlement and token transactions. Use deployed addresses and the chain ID from a tasra-releases network manifest.
|
|
254
|
+
* @param cfg RPC, manifest contract addresses, chain ID and an explicit signing account.
|
|
255
|
+
*/
|
|
256
|
+
export declare function createTasraWriteClient(cfg: WriteClientConfig): TasraWriteClient;
|
|
257
|
+
/**
|
|
258
|
+
* Account-bound operations for slot creation, lifecycle management, settlement funding and token transactions.
|
|
259
|
+
*/
|
|
260
|
+
export interface TasraWriteClient {
|
|
261
|
+
/** The account every write is signed with. */
|
|
262
|
+
account: Account;
|
|
263
|
+
/** Convenience alias for `account.address`. */
|
|
264
|
+
address: Address;
|
|
265
|
+
/** The underlying wallet client. */
|
|
266
|
+
wallet: WalletClient<Transport, Chain, Account>;
|
|
267
|
+
/** A read client on the same RPC, used for receipts and balance reads. */
|
|
268
|
+
pub: PublicClient;
|
|
269
|
+
/**
|
|
270
|
+
* Create a slot directly. Persist the generated slot ID and rule salt; provisioning requires the saved salt. Use prepared creation to persist the intent before submission.
|
|
271
|
+
* A `kk_oauth` policy envelope (as `rule`, or authored as `oauthPolicy`) requires `authType: 'oauth'` and must pass the network's gate; both are checked before any chain call. `rule` in the result is the exact string committed.
|
|
272
|
+
*/
|
|
273
|
+
createSlot(args: CreateSlotArgs | CreateSlotFromPolicyArgs): Promise<{
|
|
274
|
+
slotId: Hex;
|
|
275
|
+
txHash: Hex;
|
|
276
|
+
ruleSalt: Hex;
|
|
277
|
+
rule: string;
|
|
278
|
+
relay?: RelayReceipt;
|
|
279
|
+
}>;
|
|
280
|
+
/**
|
|
281
|
+
* Create a slot using commit-reveal, trying an accountant seed before waiting for a beacon epoch. Persist the slot ID and rule salt; prepared creation preserves them before submission.
|
|
282
|
+
* Policy envelopes are checked as for `createSlot`; `rule` in the result is the exact string committed.
|
|
283
|
+
*/
|
|
284
|
+
createSlotCommitReveal(args: (CreateSlotArgs | CreateSlotFromPolicyArgs) & CommitRevealOptions): Promise<{
|
|
285
|
+
slotId: Hex;
|
|
286
|
+
commitTx: Hex;
|
|
287
|
+
revealTx: Hex;
|
|
288
|
+
targetEpoch: number;
|
|
289
|
+
ruleSalt: Hex;
|
|
290
|
+
rule: string;
|
|
291
|
+
seeded: boolean;
|
|
292
|
+
}>;
|
|
293
|
+
/**
|
|
294
|
+
* Approve TSRA and fund the slot settlement balance in token base units.
|
|
295
|
+
*/
|
|
296
|
+
fundSlot(slotId: Hex, amount: bigint): Promise<{
|
|
297
|
+
approveTx: Hex;
|
|
298
|
+
fundTx: Hex;
|
|
299
|
+
relay?: RelayReceipt;
|
|
300
|
+
}>;
|
|
301
|
+
/**
|
|
302
|
+
* Send native currency in base units and wait for a successful receipt.
|
|
303
|
+
*/
|
|
304
|
+
sendEth(to: Address, wei: bigint): Promise<Hex>;
|
|
305
|
+
/**
|
|
306
|
+
* Transfer TSRA in token base units and wait for confirmation.
|
|
307
|
+
*/
|
|
308
|
+
transferTsra(to: Address, amount: bigint): Promise<Hex>;
|
|
309
|
+
/**
|
|
310
|
+
* Request a new distributed key generation epoch for the slot.
|
|
311
|
+
*/
|
|
312
|
+
rotateKey(slotId: Hex, reason?: string): Promise<Hex>;
|
|
313
|
+
/**
|
|
314
|
+
* Redistribute the slot key among the supplied operators using the new threshold.
|
|
315
|
+
*/
|
|
316
|
+
reshareKey(slotId: Hex, newOperators: Address[], k: number, n: number, reason?: string): Promise<Hex>;
|
|
317
|
+
/**
|
|
318
|
+
* Cancel the slot using the configured account authority.
|
|
319
|
+
*/
|
|
320
|
+
cancelSlot(slotId: Hex): Promise<Hex>;
|
|
321
|
+
/**
|
|
322
|
+
* Renew the slot lease; the configured account must be its creator.
|
|
323
|
+
*/
|
|
324
|
+
renewSlot(slotId: Hex): Promise<Hex>;
|
|
325
|
+
/**
|
|
326
|
+
* Set the verifier committee size and quorum, optionally persisting transaction progress.
|
|
327
|
+
*/
|
|
328
|
+
setVerifierPolicy(slotId: Hex, committee: number, quorum: number, onTransaction?: (event: {
|
|
329
|
+
phase: 'submitting' | 'submitted' | 'confirmed';
|
|
330
|
+
hash?: Hex;
|
|
331
|
+
}) => Promise<void>): Promise<Hex>;
|
|
332
|
+
/**
|
|
333
|
+
* Pin amendment authority while the slot is fresh. Prefer passing rulePolicy at creation so key generation cannot win the race. The guardian must differ from the administrator, and omitting a guardian requires the contract minimum timelock.
|
|
334
|
+
*/
|
|
335
|
+
setRulePolicy(slotId: Hex, policy: RulePolicyArgs): Promise<Hex>;
|
|
336
|
+
/**
|
|
337
|
+
* Propose a new rule for the slot, signed by its rule admin (relayed calls are still signed by this account). The slot's saved `ruleSalt` is reused.
|
|
338
|
+
* Refused before signing, as a `RuleAmendmentError`: a missing slot, an immutable slot, a signer that is not the rule admin, an amendment already pending, a policy envelope on a slot not created with `authType: 'oauth'`, an envelope keepers would not store, and the current rule.
|
|
339
|
+
* An amendable rule means whoever holds the admin key can change who may sign with this key, without changing the key: keep the admin key as safe as the slot itself. The guardian can veto during the delay; without a guardian nobody can. A slot created without a rule admin can never become amendable.
|
|
340
|
+
* Deliver the returned `rule` with `provisionRule({expect: 'pending'})`; the amendment activates only once enough keepers hold it.
|
|
341
|
+
*/
|
|
342
|
+
proposeRuleUpdate(a: ProposeRuleArgs): Promise<ProposeRuleResult>;
|
|
343
|
+
/**
|
|
344
|
+
* Waive the remaining delay of the pending amendment, signed by the slot's guardian. Refuses `not-guardian` and `no-pending` before signing.
|
|
345
|
+
*/
|
|
346
|
+
endorseRuleUpdate(slotId: Hex): Promise<Hex>;
|
|
347
|
+
/**
|
|
348
|
+
* Discard the pending amendment, signed by the slot's guardian. Refuses `not-guardian` and `no-pending` before signing.
|
|
349
|
+
*/
|
|
350
|
+
vetoRuleUpdate(slotId: Hex): Promise<Hex>;
|
|
351
|
+
/**
|
|
352
|
+
* Activate the pending amendment; anyone may send it. Refuses `no-pending`, `timelock` (judged on the latest block timestamp, not the local clock) and `below-threshold` before signing.
|
|
353
|
+
*/
|
|
354
|
+
activateRuleUpdate(slotId: Hex): Promise<Hex>;
|
|
355
|
+
/**
|
|
356
|
+
* Buy TSRA with approved EURC while enforcing the minimum output amount.
|
|
357
|
+
*/
|
|
358
|
+
buyTsra(eurcAmount: bigint, minTsraOut: bigint): Promise<Hex>;
|
|
359
|
+
/**
|
|
360
|
+
* Approve the bonding curve to spend the specified EURC base units.
|
|
361
|
+
*/
|
|
362
|
+
approveEurcForCurve(amount: bigint): Promise<Hex>;
|
|
363
|
+
/**
|
|
364
|
+
* Mint test EURC only after verifying the network and mock-token faucet policy.
|
|
365
|
+
*/
|
|
366
|
+
mintMockEurc(to: Address, amount: bigint): Promise<Hex>;
|
|
367
|
+
/**
|
|
368
|
+
* Read an account EURC balance in base units.
|
|
369
|
+
*/
|
|
370
|
+
eurcBalance(a: Address): Promise<bigint>;
|
|
371
|
+
/**
|
|
372
|
+
* Approve and redeem TSRA for EURC, enforcing any minimum output.
|
|
373
|
+
*/
|
|
374
|
+
redeemTsra(tsraAmount: bigint, minEurcOut?: bigint): Promise<{
|
|
375
|
+
approveTx: Hex;
|
|
376
|
+
redeemTx: Hex;
|
|
377
|
+
}>;
|
|
378
|
+
/**
|
|
379
|
+
* Permanently burn TSRA from the configured account.
|
|
380
|
+
*/
|
|
381
|
+
burnTsra(amount: bigint): Promise<Hex>;
|
|
382
|
+
/**
|
|
383
|
+
* Read the current bonding-curve spot price.
|
|
384
|
+
*/
|
|
385
|
+
spotPrice(): Promise<bigint>;
|
|
386
|
+
/**
|
|
387
|
+
* Read the bonding-curve price at the supplied sold-token amount.
|
|
388
|
+
*/
|
|
389
|
+
priceAt(sold: bigint): Promise<bigint>;
|
|
390
|
+
/**
|
|
391
|
+
* Request an authorized treasury withdrawal to the recipient.
|
|
392
|
+
*/
|
|
393
|
+
treasuryWithdraw(to: Address, amount: bigint): Promise<Hex>;
|
|
394
|
+
/**
|
|
395
|
+
* Request an authorized treasury refund to the recipient.
|
|
396
|
+
*/
|
|
397
|
+
treasuryRefund(to: Address, amount: bigint): Promise<Hex>;
|
|
398
|
+
/**
|
|
399
|
+
* Release currently vested tokens for the named allocation.
|
|
400
|
+
*/
|
|
401
|
+
vaultRelease(tranche: VaultTranche): Promise<Hex>;
|
|
402
|
+
/**
|
|
403
|
+
* Read TSRA base units for the supplied account or the configured signer.
|
|
404
|
+
*/
|
|
405
|
+
tsraBalance(of?: Address): Promise<bigint>;
|
|
406
|
+
/**
|
|
407
|
+
* Read native-token base units for the supplied account or configured signer.
|
|
408
|
+
*/
|
|
409
|
+
ethBalance(of?: Address): Promise<bigint>;
|
|
410
|
+
/**
|
|
411
|
+
* Read the prepaid TSRA settlement balance of a slot.
|
|
412
|
+
*/
|
|
413
|
+
settlementBalance(slotId: Hex): Promise<bigint>;
|
|
414
|
+
/** Whether writes are submitted through a registered relay rather than directly. */
|
|
415
|
+
relayEnabled: boolean;
|
|
416
|
+
/**
|
|
417
|
+
* Return the last verified relay receipt, if any.
|
|
418
|
+
*/
|
|
419
|
+
lastRelay(): RelayReceipt | undefined;
|
|
420
|
+
/**
|
|
421
|
+
* Return the signed relay attempt awaiting reconciliation, if any.
|
|
422
|
+
*/
|
|
423
|
+
pendingRelayAttempt(): RelayAttempt | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* Inspect the pending attempt against the chain without signing a replacement.
|
|
426
|
+
*/
|
|
427
|
+
reconcileRelay(): Promise<{
|
|
428
|
+
receipt?: RelayReceipt;
|
|
429
|
+
expired: boolean;
|
|
430
|
+
} | undefined>;
|
|
431
|
+
}
|