@aztec/ethereum 0.16.4 → 0.16.5
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/package.json +2 -2
- package/src/constants.ts +0 -3
- package/src/deploy_l1_contracts.ts +0 -226
- package/src/ethereum_chain.ts +0 -16
- package/src/index.ts +0 -27
- package/src/l1_contract_addresses.ts +0 -31
- package/src/testnet.ts +0 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"typedocOptions": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"../package.common.json"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@aztec/foundation": "0.16.
|
|
27
|
+
"@aztec/foundation": "0.16.5",
|
|
28
28
|
"dotenv": "^16.0.3",
|
|
29
29
|
"tslib": "^2.4.0",
|
|
30
30
|
"viem": "^1.2.5"
|
package/src/constants.ts
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { DebugLogger } from '@aztec/foundation/log';
|
|
3
|
-
|
|
4
|
-
import type { Abi, Narrow } from 'abitype';
|
|
5
|
-
import {
|
|
6
|
-
Account,
|
|
7
|
-
Chain,
|
|
8
|
-
Hex,
|
|
9
|
-
HttpTransport,
|
|
10
|
-
PublicClient,
|
|
11
|
-
WalletClient,
|
|
12
|
-
createPublicClient,
|
|
13
|
-
createWalletClient,
|
|
14
|
-
getAddress,
|
|
15
|
-
getContract,
|
|
16
|
-
http,
|
|
17
|
-
} from 'viem';
|
|
18
|
-
import { HDAccount, PrivateKeyAccount } from 'viem/accounts';
|
|
19
|
-
|
|
20
|
-
import { L1ContractAddresses } from './l1_contract_addresses.js';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Return type of the deployL1Contract function.
|
|
24
|
-
*/
|
|
25
|
-
export type DeployL1Contracts = {
|
|
26
|
-
/**
|
|
27
|
-
* Wallet Client Type.
|
|
28
|
-
*/
|
|
29
|
-
walletClient: WalletClient<HttpTransport, Chain, Account>;
|
|
30
|
-
/**
|
|
31
|
-
* Public Client Type.
|
|
32
|
-
*/
|
|
33
|
-
publicClient: PublicClient<HttpTransport, Chain>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The currently deployed l1 contract addresses
|
|
37
|
-
*/
|
|
38
|
-
l1ContractAddresses: L1ContractAddresses;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Contract artifacts
|
|
43
|
-
*/
|
|
44
|
-
export interface ContractArtifacts {
|
|
45
|
-
/**
|
|
46
|
-
* The contract abi.
|
|
47
|
-
*/
|
|
48
|
-
contractAbi: Narrow<Abi | readonly unknown[]>;
|
|
49
|
-
/**
|
|
50
|
-
* The contract bytecode
|
|
51
|
-
*/
|
|
52
|
-
contractBytecode: Hex;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* All L1 Contract Artifacts for deployment
|
|
57
|
-
*/
|
|
58
|
-
export interface L1ContractArtifactsForDeployment {
|
|
59
|
-
/**
|
|
60
|
-
* Contract deployment emitter artifacts
|
|
61
|
-
*/
|
|
62
|
-
contractDeploymentEmitter: ContractArtifacts;
|
|
63
|
-
/**
|
|
64
|
-
* Decoder contract artifacts
|
|
65
|
-
*/
|
|
66
|
-
decoderHelper?: ContractArtifacts;
|
|
67
|
-
/**
|
|
68
|
-
* Inbox contract artifacts
|
|
69
|
-
*/
|
|
70
|
-
inbox: ContractArtifacts;
|
|
71
|
-
/**
|
|
72
|
-
* Outbox contract artifacts
|
|
73
|
-
*/
|
|
74
|
-
outbox: ContractArtifacts;
|
|
75
|
-
/**
|
|
76
|
-
* Registry contract artifacts
|
|
77
|
-
*/
|
|
78
|
-
registry: ContractArtifacts;
|
|
79
|
-
/**
|
|
80
|
-
* Rollup contract artifacts
|
|
81
|
-
*/
|
|
82
|
-
rollup: ContractArtifacts;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Deploys the aztec L1 contracts; Rollup, Contract Deployment Emitter & (optionally) Decoder Helper.
|
|
87
|
-
* @param rpcUrl - URL of the ETH RPC to use for deployment.
|
|
88
|
-
* @param account - Private Key or HD Account that will deploy the contracts.
|
|
89
|
-
* @param chain - The chain instance to deploy to.
|
|
90
|
-
* @param logger - A logger object.
|
|
91
|
-
* @param contractsToDeploy - The set of L1 artifacts to be deployed
|
|
92
|
-
* @returns A list of ETH addresses of the deployed contracts.
|
|
93
|
-
*/
|
|
94
|
-
export const deployL1Contracts = async (
|
|
95
|
-
rpcUrl: string,
|
|
96
|
-
account: HDAccount | PrivateKeyAccount,
|
|
97
|
-
chain: Chain,
|
|
98
|
-
logger: DebugLogger,
|
|
99
|
-
contractsToDeploy: L1ContractArtifactsForDeployment,
|
|
100
|
-
): Promise<DeployL1Contracts> => {
|
|
101
|
-
logger('Deploying contracts...');
|
|
102
|
-
|
|
103
|
-
const walletClient = createWalletClient({
|
|
104
|
-
account,
|
|
105
|
-
chain,
|
|
106
|
-
transport: http(rpcUrl),
|
|
107
|
-
});
|
|
108
|
-
const publicClient = createPublicClient({
|
|
109
|
-
chain,
|
|
110
|
-
transport: http(rpcUrl),
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const registryAddress = await deployL1Contract(
|
|
114
|
-
walletClient,
|
|
115
|
-
publicClient,
|
|
116
|
-
contractsToDeploy.registry.contractAbi,
|
|
117
|
-
contractsToDeploy.registry.contractBytecode,
|
|
118
|
-
);
|
|
119
|
-
logger(`Deployed Registry at ${registryAddress}`);
|
|
120
|
-
|
|
121
|
-
const inboxAddress = await deployL1Contract(
|
|
122
|
-
walletClient,
|
|
123
|
-
publicClient,
|
|
124
|
-
contractsToDeploy.inbox.contractAbi,
|
|
125
|
-
contractsToDeploy.inbox.contractBytecode,
|
|
126
|
-
[getAddress(registryAddress.toString())],
|
|
127
|
-
);
|
|
128
|
-
logger(`Deployed Inbox at ${inboxAddress}`);
|
|
129
|
-
|
|
130
|
-
const outboxAddress = await deployL1Contract(
|
|
131
|
-
walletClient,
|
|
132
|
-
publicClient,
|
|
133
|
-
contractsToDeploy.outbox.contractAbi,
|
|
134
|
-
contractsToDeploy.outbox.contractBytecode,
|
|
135
|
-
[getAddress(registryAddress.toString())],
|
|
136
|
-
);
|
|
137
|
-
logger(`Deployed Outbox at ${outboxAddress}`);
|
|
138
|
-
|
|
139
|
-
const rollupAddress = await deployL1Contract(
|
|
140
|
-
walletClient,
|
|
141
|
-
publicClient,
|
|
142
|
-
contractsToDeploy.rollup.contractAbi,
|
|
143
|
-
contractsToDeploy.rollup.contractBytecode,
|
|
144
|
-
[getAddress(registryAddress.toString())],
|
|
145
|
-
);
|
|
146
|
-
logger(`Deployed Rollup at ${rollupAddress}`);
|
|
147
|
-
|
|
148
|
-
// We need to call a function on the registry to set the various contract addresses.
|
|
149
|
-
const registryContract = getContract({
|
|
150
|
-
address: getAddress(registryAddress.toString()),
|
|
151
|
-
abi: contractsToDeploy.registry.contractAbi,
|
|
152
|
-
publicClient,
|
|
153
|
-
walletClient,
|
|
154
|
-
});
|
|
155
|
-
await registryContract.write.upgrade(
|
|
156
|
-
[getAddress(rollupAddress.toString()), getAddress(inboxAddress.toString()), getAddress(outboxAddress.toString())],
|
|
157
|
-
{ account },
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
const contractDeploymentEmitterAddress = await deployL1Contract(
|
|
161
|
-
walletClient,
|
|
162
|
-
publicClient,
|
|
163
|
-
contractsToDeploy.contractDeploymentEmitter.contractAbi,
|
|
164
|
-
contractsToDeploy.contractDeploymentEmitter.contractBytecode,
|
|
165
|
-
);
|
|
166
|
-
logger(`Deployed contract deployment emitter at ${contractDeploymentEmitterAddress}`);
|
|
167
|
-
|
|
168
|
-
let decoderHelperAddress: EthAddress | undefined;
|
|
169
|
-
if (contractsToDeploy.decoderHelper) {
|
|
170
|
-
decoderHelperAddress = await deployL1Contract(
|
|
171
|
-
walletClient,
|
|
172
|
-
publicClient,
|
|
173
|
-
contractsToDeploy.decoderHelper.contractAbi,
|
|
174
|
-
contractsToDeploy.decoderHelper.contractBytecode,
|
|
175
|
-
);
|
|
176
|
-
logger(`Deployed DecoderHelper at ${decoderHelperAddress}`);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const l1Contracts: L1ContractAddresses = {
|
|
180
|
-
rollupAddress,
|
|
181
|
-
registryAddress,
|
|
182
|
-
inboxAddress,
|
|
183
|
-
outboxAddress,
|
|
184
|
-
contractDeploymentEmitterAddress,
|
|
185
|
-
decoderHelperAddress: decoderHelperAddress ?? EthAddress.ZERO,
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
walletClient,
|
|
190
|
-
publicClient,
|
|
191
|
-
l1ContractAddresses: l1Contracts,
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
// docs:start:deployL1Contract
|
|
196
|
-
/**
|
|
197
|
-
* Helper function to deploy ETH contracts.
|
|
198
|
-
* @param walletClient - A viem WalletClient.
|
|
199
|
-
* @param publicClient - A viem PublicClient.
|
|
200
|
-
* @param abi - The ETH contract's ABI (as abitype's Abi).
|
|
201
|
-
* @param bytecode - The ETH contract's bytecode.
|
|
202
|
-
* @param args - Constructor arguments for the contract.
|
|
203
|
-
* @returns The ETH address the contract was deployed to.
|
|
204
|
-
*/
|
|
205
|
-
export async function deployL1Contract(
|
|
206
|
-
walletClient: WalletClient<HttpTransport, Chain, Account>,
|
|
207
|
-
publicClient: PublicClient<HttpTransport, Chain>,
|
|
208
|
-
abi: Narrow<Abi | readonly unknown[]>,
|
|
209
|
-
bytecode: Hex,
|
|
210
|
-
args: readonly unknown[] = [],
|
|
211
|
-
): Promise<EthAddress> {
|
|
212
|
-
const hash = await walletClient.deployContract({
|
|
213
|
-
abi,
|
|
214
|
-
bytecode,
|
|
215
|
-
args,
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
219
|
-
const contractAddress = receipt.contractAddress;
|
|
220
|
-
if (!contractAddress) {
|
|
221
|
-
throw new Error(`No contract address found in receipt: ${JSON.stringify(receipt)}`);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return EthAddress.fromString(receipt.contractAddress!);
|
|
225
|
-
}
|
|
226
|
-
// docs:end:deployL1Contract
|
package/src/ethereum_chain.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Chain } from 'viem';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interface containing the connection and chain properties to interact with a blockchain.
|
|
5
|
-
*/
|
|
6
|
-
export interface EthereumChain {
|
|
7
|
-
/**
|
|
8
|
-
* An instance of the viem chain data.
|
|
9
|
-
*/
|
|
10
|
-
chainInfo: Chain;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The actual url to be used.
|
|
14
|
-
*/
|
|
15
|
-
rpcUrl: string;
|
|
16
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { foundry } from 'viem/chains';
|
|
2
|
-
|
|
3
|
-
import { EthereumChain } from './ethereum_chain.js';
|
|
4
|
-
import { createTestnetChain } from './testnet.js';
|
|
5
|
-
|
|
6
|
-
export * from './testnet.js';
|
|
7
|
-
export * from './deploy_l1_contracts.js';
|
|
8
|
-
export * from './l1_contract_addresses.js';
|
|
9
|
-
export * from './constants.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Helper function to create an instance of Aztec Chain from an rpc url and api key.
|
|
13
|
-
* @param rpcUrl - The rpc url of the chain or a chain identifier (e.g. 'testnet')
|
|
14
|
-
* @param apiKey - An optional API key for the chain client.
|
|
15
|
-
*/
|
|
16
|
-
export function createEthereumChain(rpcUrl: string, apiKey?: string) {
|
|
17
|
-
if (rpcUrl === 'testnet') {
|
|
18
|
-
if (apiKey === undefined || apiKey === '') {
|
|
19
|
-
throw new Error('API Key must be provided for aztec testnet');
|
|
20
|
-
}
|
|
21
|
-
return createTestnetChain(apiKey!);
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
chainInfo: foundry,
|
|
25
|
-
rpcUrl,
|
|
26
|
-
} as EthereumChain;
|
|
27
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Provides the directory of current L1 contract addresses
|
|
5
|
-
*/
|
|
6
|
-
export interface L1ContractAddresses {
|
|
7
|
-
/**
|
|
8
|
-
* Rollup Address.
|
|
9
|
-
*/
|
|
10
|
-
rollupAddress: EthAddress;
|
|
11
|
-
/**
|
|
12
|
-
* Registry Address.
|
|
13
|
-
*/
|
|
14
|
-
registryAddress: EthAddress;
|
|
15
|
-
/**
|
|
16
|
-
* Inbox Address.
|
|
17
|
-
*/
|
|
18
|
-
inboxAddress: EthAddress;
|
|
19
|
-
/**
|
|
20
|
-
* Outbox Address.
|
|
21
|
-
*/
|
|
22
|
-
outboxAddress: EthAddress;
|
|
23
|
-
/**
|
|
24
|
-
* Data Emitter Address.
|
|
25
|
-
*/
|
|
26
|
-
contractDeploymentEmitterAddress: EthAddress;
|
|
27
|
-
/**
|
|
28
|
-
* Decoder Helper Address.
|
|
29
|
-
*/
|
|
30
|
-
decoderHelperAddress: EthAddress;
|
|
31
|
-
}
|
package/src/testnet.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Chain } from 'viem';
|
|
2
|
-
|
|
3
|
-
import { EthereumChain } from './ethereum_chain.js';
|
|
4
|
-
|
|
5
|
-
const { DEPLOY_TAG = 'aztec-dev', CHAIN_ID = 31337 } = process.env;
|
|
6
|
-
|
|
7
|
-
export const createTestnetChain = (apiKey: string) => {
|
|
8
|
-
const chain: Chain = {
|
|
9
|
-
id: +CHAIN_ID,
|
|
10
|
-
name: 'testnet',
|
|
11
|
-
network: 'aztec',
|
|
12
|
-
nativeCurrency: {
|
|
13
|
-
name: 'Ether',
|
|
14
|
-
symbol: 'ETH',
|
|
15
|
-
decimals: 18,
|
|
16
|
-
},
|
|
17
|
-
rpcUrls: {
|
|
18
|
-
default: {
|
|
19
|
-
http: [`https://${DEPLOY_TAG}-mainnet-fork.aztec.network:8545/${apiKey}`],
|
|
20
|
-
},
|
|
21
|
-
public: {
|
|
22
|
-
http: [`https://${DEPLOY_TAG}-mainnet-fork.aztec.network:8545/${apiKey}`],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
chainInfo: chain,
|
|
28
|
-
rpcUrl: chain.rpcUrls.default.http[0],
|
|
29
|
-
} as EthereumChain;
|
|
30
|
-
};
|