-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
88 lines (78 loc) · 2.23 KB
/
Copy pathtypes.ts
File metadata and controls
88 lines (78 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* Typed Stellar deployment manifest (v1).
* Canonical source: deployments/v1/<network>.json
*/
export type DeploymentNetwork = "testnet" | "mainnet";
export type DeploymentStatus = "template" | "deployed" | "not_deployed";
export type ContractKey =
| "stealthRegistry"
| "stealthAnnouncer"
| "groth16Verifier"
| "reputationVerifier"
| "schemaRegistry"
| "attestationEngineV2";
export type ContractRecord = {
id: string;
wasmHash: string;
package?: string;
};
export type DeploymentManifestV1 = {
schemaVersion: "1.0.0";
release: string;
network: DeploymentNetwork;
networkPassphrase: string;
rpcUrl?: string;
horizonUrl?: string;
deploymentLedger: number | null;
deployedAt: string | null;
deployer: string | null;
admin: string | null;
multisig: string | null;
deploymentStatus: DeploymentStatus;
contracts: Record<ContractKey, ContractRecord>;
artifacts: {
frontend: {
buildCommit: string | null;
repository?: string;
};
circuits: {
v2: {
r1csHash: string | null;
verificationKeyHash: string | null;
};
};
};
verification: {
command: string;
output: string | null;
};
};
export const CONTRACT_KEYS: readonly ContractKey[] = [
"stealthRegistry",
"stealthAnnouncer",
"groth16Verifier",
"reputationVerifier",
"schemaRegistry",
"attestationEngineV2",
] as const;
export const CONTRACT_ENV_SUFFIX: Record<ContractKey, string> = {
stealthRegistry: "STEALTH_REGISTRY_CONTRACT",
stealthAnnouncer: "STEALTH_ANNOUNCER_CONTRACT",
groth16Verifier: "GROTH16_VERIFIER_CONTRACT",
reputationVerifier: "REPUTATION_VERIFIER_CONTRACT",
schemaRegistry: "SCHEMA_REGISTRY_CONTRACT",
attestationEngineV2: "ATTESTATION_ENGINE_CONTRACT",
};
export function contractEnvKey(network: DeploymentNetwork, key: ContractKey): string {
return `VITE_${network.toUpperCase()}_${CONTRACT_ENV_SUFFIX[key]}`;
}
export function isValidStellarContractId(value: string): boolean {
return /^C[A-Z2-7]{55}$/.test(value);
}
export function manifestContractIds(
manifest: DeploymentManifestV1,
): Record<ContractKey, string> {
return Object.fromEntries(
CONTRACT_KEYS.map((key) => [key, manifest.contracts[key].id]),
) as Record<ContractKey, string>;
}