@aztec/protocol-contracts 0.23.0 → 0.26.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/README.md +1 -1
- package/dest/artifacts/ContractClassRegisterer.json +1 -2605
- package/dest/artifacts/ContractInstanceDeployer.json +1 -1303
- package/dest/artifacts/GasToken.json +1 -0
- package/dest/class-registerer/index.js +1 -1
- package/dest/gas-token/artifact.d.ts +2 -0
- package/dest/gas-token/artifact.d.ts.map +1 -0
- package/dest/gas-token/artifact.js +4 -0
- package/dest/gas-token/index.d.ts +5 -0
- package/dest/gas-token/index.d.ts.map +1 -0
- package/dest/gas-token/index.js +8 -0
- package/dest/instance-deployer/index.d.ts.map +1 -1
- package/dest/instance-deployer/index.js +3 -3
- package/dest/protocol_contract.d.ts +2 -2
- package/dest/protocol_contract.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/artifacts/ContractClassRegisterer.json +1 -0
- package/src/artifacts/ContractInstanceDeployer.json +1 -0
- package/src/artifacts/GasToken.json +1 -0
- package/src/class-registerer/artifact.ts +8 -0
- package/src/class-registerer/index.ts +17 -0
- package/src/gas-token/artifact.ts +6 -0
- package/src/gas-token/index.ts +9 -0
- package/src/index.ts +1 -0
- package/src/instance-deployer/artifact.ts +8 -0
- package/src/instance-deployer/index.ts +11 -0
- package/src/protocol_contract.ts +33 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/types/abi';
|
|
2
|
+
import { NoirCompiledContract } from '@aztec/types/noir';
|
|
3
|
+
|
|
4
|
+
import ContractClassRegistererJson from '../artifacts/ContractClassRegisterer.json' assert { type: 'json' };
|
|
5
|
+
|
|
6
|
+
export const ContractClassRegistererArtifact = loadContractArtifact(
|
|
7
|
+
ContractClassRegistererJson as NoirCompiledContract,
|
|
8
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AztecAddress } from '@aztec/circuits.js';
|
|
2
|
+
|
|
3
|
+
import { ProtocolContract, getCanonicalProtocolContract } from '../protocol_contract.js';
|
|
4
|
+
import { ContractClassRegistererArtifact } from './artifact.js';
|
|
5
|
+
|
|
6
|
+
/** Returns the canonical deployment of the class registerer contract. */
|
|
7
|
+
export function getCanonicalClassRegisterer(): ProtocolContract {
|
|
8
|
+
return getCanonicalProtocolContract(ContractClassRegistererArtifact, 1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Address of the canonical class registerer.
|
|
13
|
+
* @remarks This should not change often, hence we hardcode it to save from having to recompute it every time.
|
|
14
|
+
*/
|
|
15
|
+
export const ClassRegistererAddress = AztecAddress.fromString(
|
|
16
|
+
'0x251ab40f36a148a5ac88fe3c2398ec1968d5676b0066299278610b870d738a9e',
|
|
17
|
+
);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/types/abi';
|
|
2
|
+
import { NoirCompiledContract } from '@aztec/types/noir';
|
|
3
|
+
|
|
4
|
+
import GasTokenJson from '../artifacts/GasToken.json' assert { type: 'json' };
|
|
5
|
+
|
|
6
|
+
export const GasTokenArtifact = loadContractArtifact(GasTokenJson as NoirCompiledContract);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProtocolContract, getCanonicalProtocolContract } from '../protocol_contract.js';
|
|
2
|
+
import { GasTokenArtifact } from './artifact.js';
|
|
3
|
+
|
|
4
|
+
/** Returns the canonical deployment of the gas token. */
|
|
5
|
+
export function getCanonicalGasToken(): ProtocolContract {
|
|
6
|
+
return getCanonicalProtocolContract(GasTokenArtifact, 1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const GasTokenAddress = getCanonicalGasToken().address;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProtocolContract } from './protocol_contract.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/types/abi';
|
|
2
|
+
import { NoirCompiledContract } from '@aztec/types/noir';
|
|
3
|
+
|
|
4
|
+
import ContractInstanceDeployerJson from '../artifacts/ContractInstanceDeployer.json' assert { type: 'json' };
|
|
5
|
+
|
|
6
|
+
export const ContractInstanceDeployerArtifact = loadContractArtifact(
|
|
7
|
+
ContractInstanceDeployerJson as NoirCompiledContract,
|
|
8
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AztecAddress, DEPLOYER_CONTRACT_ADDRESS } from '@aztec/circuits.js';
|
|
2
|
+
|
|
3
|
+
import { ProtocolContract, getCanonicalProtocolContract } from '../protocol_contract.js';
|
|
4
|
+
import { ContractInstanceDeployerArtifact } from './artifact.js';
|
|
5
|
+
|
|
6
|
+
/** Returns the canonical deployment of the instance deployer contract. */
|
|
7
|
+
export function getCanonicalInstanceDeployer(): ProtocolContract {
|
|
8
|
+
return getCanonicalProtocolContract(ContractInstanceDeployerArtifact, 1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const InstanceDeployerAddress = AztecAddress.fromBigInt(DEPLOYER_CONTRACT_ADDRESS);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AztecAddress, getContractClassFromArtifact, getContractInstanceFromDeployParams } from '@aztec/circuits.js';
|
|
2
|
+
import { ContractArtifact } from '@aztec/foundation/abi';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { ContractClassWithId, ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
5
|
+
|
|
6
|
+
/** Represents a canonical contract in the protocol. */
|
|
7
|
+
export interface ProtocolContract {
|
|
8
|
+
/** Canonical deployed instance. */
|
|
9
|
+
instance: ContractInstanceWithAddress;
|
|
10
|
+
/** Contract class of this contract. */
|
|
11
|
+
contractClass: ContractClassWithId;
|
|
12
|
+
/** Complete contract artifact. */
|
|
13
|
+
artifact: ContractArtifact;
|
|
14
|
+
/** Deployment address for the canonical instance. */
|
|
15
|
+
address: AztecAddress;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Returns the canonical deployment a given artifact. */
|
|
19
|
+
export function getCanonicalProtocolContract(
|
|
20
|
+
artifact: ContractArtifact,
|
|
21
|
+
salt: Fr | number | bigint,
|
|
22
|
+
initArgs: any[] = [],
|
|
23
|
+
): ProtocolContract {
|
|
24
|
+
// TODO(@spalladino): This computes the contract class from the artifact twice.
|
|
25
|
+
const contractClass = getContractClassFromArtifact(artifact);
|
|
26
|
+
const instance = getContractInstanceFromDeployParams(artifact, initArgs, new Fr(salt));
|
|
27
|
+
return {
|
|
28
|
+
instance,
|
|
29
|
+
contractClass,
|
|
30
|
+
artifact,
|
|
31
|
+
address: instance.address,
|
|
32
|
+
};
|
|
33
|
+
}
|