-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
232 additions
and
211 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
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
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
import { Fr } from '@aztec/circuits.js'; | ||
import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; | ||
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; | ||
|
||
export class InboxLeaf { | ||
constructor( | ||
/** L2 block number in which the message will be included. */ | ||
public readonly blockNumber: bigint, | ||
/** Index of the leaf in L2 block message subtree. */ | ||
public readonly index: bigint, | ||
/** Leaf of the subtree. */ | ||
public readonly leaf: Fr, | ||
) {} | ||
|
||
toBuffer(): Buffer { | ||
return serializeToBuffer([this.blockNumber, this.index, this.leaf]); | ||
} | ||
|
||
fromBuffer(buffer: Buffer | BufferReader): InboxLeaf { | ||
const reader = BufferReader.asReader(buffer); | ||
const blockNumber = toBigIntBE(reader.readBytes(32)); | ||
const index = toBigIntBE(reader.readBytes(32)); | ||
const leaf = reader.readObject(Fr); | ||
return new InboxLeaf(blockNumber, index, leaf); | ||
} | ||
} |
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,5 @@ | ||
export * from './inbox_leaf.js'; | ||
export * from './l1_to_l2_message.js'; | ||
export * from './l1_to_l2_message_source.js'; | ||
export * from './l1_actor.js'; | ||
export * from './l2_actor.js'; |
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,43 @@ | ||
import { randomInt } from '@aztec/foundation/crypto'; | ||
import { EthAddress } from '@aztec/foundation/eth-address'; | ||
import { Fr } from '@aztec/foundation/fields'; | ||
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; | ||
|
||
/** | ||
* The sender of an L1 to L2 message. | ||
*/ | ||
export class L1Actor { | ||
constructor( | ||
/** | ||
* The sender of the message. | ||
*/ | ||
public readonly sender: EthAddress, | ||
/** | ||
* The chain id on which the message was sent. | ||
*/ | ||
public readonly chainId: number, | ||
) {} | ||
|
||
static empty() { | ||
return new L1Actor(EthAddress.ZERO, 0); | ||
} | ||
|
||
toFields(): Fr[] { | ||
return [this.sender.toField(), new Fr(BigInt(this.chainId))]; | ||
} | ||
|
||
toBuffer(): Buffer { | ||
return serializeToBuffer(this.sender, this.chainId); | ||
} | ||
|
||
static fromBuffer(buffer: Buffer | BufferReader): L1Actor { | ||
const reader = BufferReader.asReader(buffer); | ||
const ethAddr = reader.readObject(EthAddress); | ||
const chainId = reader.readNumber(); | ||
return new L1Actor(ethAddr, chainId); | ||
} | ||
|
||
static random(): L1Actor { | ||
return new L1Actor(EthAddress.random(), randomInt(1000)); | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.