-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add batched signerless contract calls
- Loading branch information
Showing
14 changed files
with
190 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
noir-projects/noir-contracts/contracts/signerless_entrypoint_contract/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "signerless_entrypoint_contract" | ||
authors = [""] | ||
compiler_version = ">=0.18.0" | ||
type = "contract" | ||
|
||
[dependencies] | ||
aztec = { path = "../../../aztec-nr/aztec" } | ||
authwit = { path = "../../../aztec-nr/authwit" } |
13 changes: 13 additions & 0 deletions
13
noir-projects/noir-contracts/contracts/signerless_entrypoint_contract/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// An entrypoint contract that allows everything to go through. Only used for testing | ||
// Pair this with SignerlessWallet to perform multiple actions before any account contracts are deployed (and without authentication) | ||
contract SignerlessEntrypoint { | ||
use dep::std; | ||
|
||
use dep::aztec::prelude::AztecAddress; | ||
use dep::authwit::entrypoint::app::AppPayload; | ||
|
||
#[aztec(private)] | ||
fn entrypoint(app_payload: pub AppPayload) { | ||
app_payload.execute_calls(&mut context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
yarn-project/protocol-contracts/src/signerless-entrypoint/__snapshots__/index.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`GasToken returns canonical protocol contract 1`] = ` | ||
{ | ||
"address": AztecAddress<0x27970e5b54a9263933858c6450179726ee51346a6cb61893a6ca667e0d6906f3>, | ||
"instance": { | ||
"address": AztecAddress<0x27970e5b54a9263933858c6450179726ee51346a6cb61893a6ca667e0d6906f3>, | ||
"contractClassId": Fr<0x03ebe4598137a75cba2503a8d8286ee8500473a821877b1f4a1950590d00364c>, | ||
"deployer": AztecAddress<0x0000000000000000000000000000000000000000000000000000000000000000>, | ||
"initializationHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, | ||
"portalContractAddress": EthAddress<0x0000000000000000000000000000000000000000>, | ||
"publicKeysHash": Fr<0x27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed>, | ||
"salt": Fr<0x0000000000000000000000000000000000000000000000000000000000000001>, | ||
"version": 1, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`GasToken returns canonical protocol contract 2`] = ` | ||
{ | ||
"artifactHash": Fr<0x0a52d996440db1be04a93b2bc3d827c729e76abf6703374008e1d5163cd2b934>, | ||
"id": Fr<0x03ebe4598137a75cba2503a8d8286ee8500473a821877b1f4a1950590d00364c>, | ||
"privateFunctions": [ | ||
{ | ||
"isInternal": false, | ||
"selector": Selector<0x37889ba1>, | ||
"vkHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, | ||
}, | ||
], | ||
"privateFunctionsRoot": Fr<0x2b9863e7fc2300212371e9b566c072dc000aaa9f5025eb761d6af73ce6f8b7a4>, | ||
"publicBytecodeCommitment": Fr<0x1dae27cc7fe2af345f160253be3875d449a7e9ba6bd68747d87d4e7054b81115>, | ||
"version": 1, | ||
} | ||
`; | ||
|
||
exports[`GasToken returns canonical protocol contract 3`] = `[]`; |
6 changes: 6 additions & 0 deletions
6
yarn-project/protocol-contracts/src/signerless-entrypoint/artifact.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { loadContractArtifact } from '@aztec/types/abi'; | ||
import { NoirCompiledContract } from '@aztec/types/noir'; | ||
|
||
import SignerlessEntrypoint from '../artifacts/SignerlessEntrypoint.json' assert { type: 'json' }; | ||
|
||
export const SignerlessEntrypointArtifact = loadContractArtifact(SignerlessEntrypoint as NoirCompiledContract); |
20 changes: 20 additions & 0 deletions
20
yarn-project/protocol-contracts/src/signerless-entrypoint/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { setupCustomSnapshotSerializers } from '@aztec/foundation/testing'; | ||
|
||
import omit from 'lodash.omit'; | ||
|
||
import { getCanonicalSignerlessEntrypointContract } from './index.js'; | ||
|
||
describe('GasToken', () => { | ||
setupCustomSnapshotSerializers(expect); | ||
it('returns canonical protocol contract', () => { | ||
const contract = getCanonicalSignerlessEntrypointContract(); | ||
expect(omit(contract, ['artifact', 'contractClass'])).toMatchSnapshot(); | ||
|
||
// bytecode is very large | ||
expect(omit(contract.contractClass, ['packedBytecode', 'publicFunctions'])).toMatchSnapshot(); | ||
|
||
// this contract has public bytecode | ||
expect(contract.contractClass.publicFunctions.map(x => omit(x, 'bytecode'))).toMatchSnapshot(); | ||
expect(contract.contractClass.packedBytecode.length).toBeGreaterThan(0); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
yarn-project/protocol-contracts/src/signerless-entrypoint/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { AztecAddress, EthAddress, Point } from '@aztec/circuits.js'; | ||
|
||
import { ProtocolContract, getCanonicalProtocolContract } from '../protocol_contract.js'; | ||
import { SignerlessEntrypointArtifact } from './artifact.js'; | ||
|
||
export function getCanonicalSignerlessEntrypointContract(): ProtocolContract { | ||
return getCanonicalProtocolContract(SignerlessEntrypointArtifact, 1, [], Point.ZERO, EthAddress.ZERO); | ||
} | ||
|
||
export function getCanonicalSignerlessEntrypointAddress(): AztecAddress { | ||
return getCanonicalSignerlessEntrypointContract().address; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters