-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathconfig.ts
76 lines (69 loc) · 2.46 KB
/
config.ts
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
import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
import {
type L1ReaderConfig,
type L1TxUtilsConfig,
NULL_KEY,
l1ReaderConfigMappings,
l1TxUtilsConfigMappings,
} from '@aztec/ethereum';
import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
import { EthAddress } from '@aztec/foundation/eth-address';
/**
* The configuration of the rollup transaction publisher.
*/
export type TxSenderConfig = L1ReaderConfig & {
/**
* The private key to be used by the publisher.
*/
publisherPrivateKey: `0x${string}`;
/**
* The address of the custom forwarder contract.
*/
customForwarderContractAddress: EthAddress;
};
/**
* Configuration of the L1Publisher.
*/
export type PublisherConfig = L1TxUtilsConfig &
BlobSinkConfig & {
/**
* The interval to wait between publish retries.
*/
l1PublishRetryIntervalMS: number;
};
export const getTxSenderConfigMappings: (
scope: 'PROVER' | 'SEQ',
) => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>> = (scope: 'PROVER' | 'SEQ') => ({
...l1ReaderConfigMappings,
customForwarderContractAddress: {
env: `CUSTOM_FORWARDER_CONTRACT_ADDRESS`,
parseEnv: (val: string) => EthAddress.fromString(val),
description: 'The address of the custom forwarder contract.',
defaultValue: EthAddress.ZERO,
},
publisherPrivateKey: {
env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`,
description: 'The private key to be used by the publisher.',
parseEnv: (val: string) => (val ? `0x${val.replace('0x', '')}` : NULL_KEY),
defaultValue: NULL_KEY,
fallback: ['VALIDATOR_PRIVATE_KEY'],
},
});
export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSenderConfig, 'l1Contracts'> {
return getConfigFromMappings(getTxSenderConfigMappings(scope));
}
export const getPublisherConfigMappings: (
scope: 'PROVER' | 'SEQ',
) => ConfigMappingsType<PublisherConfig & L1TxUtilsConfig> = scope => ({
l1PublishRetryIntervalMS: {
env: scope === `PROVER` ? `PROVER_PUBLISH_RETRY_INTERVAL_MS` : `SEQ_PUBLISH_RETRY_INTERVAL_MS`,
parseEnv: (val: string) => +val,
defaultValue: 1000,
description: 'The interval to wait between publish retries.',
},
...l1TxUtilsConfigMappings,
...blobSinkConfigMapping,
});
export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
return getConfigFromMappings(getPublisherConfigMappings(scope));
}