@aztec/aztec.js 2.0.0-rc.8 → 2.0.2-rc.2
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/dest/api/utils.d.ts +1 -0
- package/dest/api/utils.d.ts.map +1 -1
- package/dest/api/utils.js +1 -0
- package/dest/contract/batch_call.d.ts +5 -0
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +6 -0
- package/dest/utils/cross_chain.d.ts +24 -0
- package/dest/utils/cross_chain.d.ts.map +1 -0
- package/dest/utils/cross_chain.js +30 -0
- package/package.json +8 -8
- package/src/api/utils.ts +1 -0
- package/src/contract/batch_call.ts +8 -0
- package/src/utils/cross_chain.ts +54 -0
package/dest/api/utils.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export { waitForPXE } from '../utils/pxe.js';
|
|
|
6
6
|
export { waitForNode, createAztecNodeClient, type AztecNode } from '../utils/node.js';
|
|
7
7
|
export { getFeeJuiceBalance } from '../utils/fee_juice.js';
|
|
8
8
|
export { readFieldCompressedString } from '../utils/field_compressed_string.js';
|
|
9
|
+
export { isL1ToL2MessageReady, waitForL1ToL2MessageReady } from '../utils/cross_chain.js';
|
|
9
10
|
//# sourceMappingURL=utils.d.ts.map
|
package/dest/api/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/api/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,gBAAgB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,yBAAyB,EACzB,iCAAiC,EACjC,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/api/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,gBAAgB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,yBAAyB,EACzB,iCAAiC,EACjC,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dest/api/utils.js
CHANGED
|
@@ -5,3 +5,4 @@ export { waitForPXE } from '../utils/pxe.js';
|
|
|
5
5
|
export { waitForNode, createAztecNodeClient } from '../utils/node.js';
|
|
6
6
|
export { getFeeJuiceBalance } from '../utils/fee_juice.js';
|
|
7
7
|
export { readFieldCompressedString } from '../utils/field_compressed_string.js';
|
|
8
|
+
export { isL1ToL2MessageReady, waitForL1ToL2MessageReady } from '../utils/cross_chain.js';
|
|
@@ -14,6 +14,11 @@ export declare class BatchCall extends BaseContractInteraction {
|
|
|
14
14
|
* @returns A Promise that resolves to a transaction instance.
|
|
15
15
|
*/
|
|
16
16
|
create(options?: SendMethodOptions): Promise<TxExecutionRequest>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new instance with no actual calls. Useful for triggering a no-op.
|
|
19
|
+
* @param wallet - The wallet to use for sending the batch call.
|
|
20
|
+
*/
|
|
21
|
+
static empty(wallet: Wallet): BatchCall;
|
|
17
22
|
/**
|
|
18
23
|
* Returns an execution request that represents this operation.
|
|
19
24
|
* @param options - An optional object containing additional configuration for the request generation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch_call.d.ts","sourceRoot":"","sources":["../../src/contract/batch_call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0B,MAAM,4BAA4B,CAAC;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAE/G,qFAAqF;AACrF,qBAAa,SAAU,SAAQ,uBAAuB;IAGlD,SAAS,CAAC,KAAK,EAAE,uBAAuB,EAAE;gBAD1C,MAAM,EAAE,MAAM,EACJ,KAAK,EAAE,uBAAuB,EAAE;IAK5C;;;;;OAKG;IACU,MAAM,CAAC,OAAO,GAAE,iBAAsD,GAAG,OAAO,CAAC,kBAAkB,CAAC;IASjH;;;;OAIG;IACU,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWnF;;;;;;;;OAQG;IACU,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC;YA2ErD,WAAW;CAG1B"}
|
|
1
|
+
{"version":3,"file":"batch_call.d.ts","sourceRoot":"","sources":["../../src/contract/batch_call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0B,MAAM,4BAA4B,CAAC;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAE/G,qFAAqF;AACrF,qBAAa,SAAU,SAAQ,uBAAuB;IAGlD,SAAS,CAAC,KAAK,EAAE,uBAAuB,EAAE;gBAD1C,MAAM,EAAE,MAAM,EACJ,KAAK,EAAE,uBAAuB,EAAE;IAK5C;;;;;OAKG;IACU,MAAM,CAAC,OAAO,GAAE,iBAAsD,GAAG,OAAO,CAAC,kBAAkB,CAAC;IASjH;;;OAGG;WACW,KAAK,CAAC,MAAM,EAAE,MAAM;IAIlC;;;;OAIG;IACU,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWnF;;;;;;;;OAQG;IACU,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC;YA2ErD,WAAW;CAG1B"}
|
|
@@ -26,6 +26,12 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
+
* Creates a new instance with no actual calls. Useful for triggering a no-op.
|
|
30
|
+
* @param wallet - The wallet to use for sending the batch call.
|
|
31
|
+
*/ static empty(wallet) {
|
|
32
|
+
return new BatchCall(wallet, []);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
29
35
|
* Returns an execution request that represents this operation.
|
|
30
36
|
* @param options - An optional object containing additional configuration for the request generation.
|
|
31
37
|
* @returns An execution payload wrapped in promise.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { PXE } from '../api/interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Waits for the L1 to L2 message to be ready to be consumed.
|
|
5
|
+
* @param pxe - PXE instance
|
|
6
|
+
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
7
|
+
* @param opts - Options
|
|
8
|
+
*/
|
|
9
|
+
export declare function waitForL1ToL2MessageReady(pxe: Pick<PXE, 'getBlockNumber' | 'getL1ToL2MessageBlock'>, l1ToL2MessageHash: Fr, opts: {
|
|
10
|
+
/** Timeout for the operation in seconds */ timeoutSeconds: number;
|
|
11
|
+
/** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
|
|
12
|
+
}): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns whether the L1 to L2 message is ready to be consumed.
|
|
15
|
+
* @param pxe - PXE instance
|
|
16
|
+
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
17
|
+
* @param opts - Options
|
|
18
|
+
* @returns True if the message is ready to be consumed, false otherwise
|
|
19
|
+
*/
|
|
20
|
+
export declare function isL1ToL2MessageReady(pxe: Pick<PXE, 'getBlockNumber' | 'getL1ToL2MessageBlock'>, l1ToL2MessageHash: Fr, opts: {
|
|
21
|
+
/** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
|
|
22
|
+
/** Cached synced block number for the message (will be fetched from PXE otherwise) */ messageBlockNumber?: number;
|
|
23
|
+
}): Promise<boolean>;
|
|
24
|
+
//# sourceMappingURL=cross_chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross_chain.d.ts","sourceRoot":"","sources":["../../src/utils/cross_chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAGnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,gBAAgB,GAAG,uBAAuB,CAAC,EAC1D,iBAAiB,EAAE,EAAE,EACrB,IAAI,EAAE;IACJ,2CAA2C,CAAC,cAAc,EAAE,MAAM,CAAC;IACnE,yEAAyE,CAAC,oBAAoB,EAAE,OAAO,CAAC;CACzG,oBASF;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,gBAAgB,GAAG,uBAAuB,CAAC,EAC1D,iBAAiB,EAAE,EAAE,EACrB,IAAI,EAAE;IACJ,yEAAyE,CAAC,oBAAoB,EAAE,OAAO,CAAC;IACxG,sFAAsF,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACpH,GACA,OAAO,CAAC,OAAO,CAAC,CAWlB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
|
+
/**
|
|
3
|
+
* Waits for the L1 to L2 message to be ready to be consumed.
|
|
4
|
+
* @param pxe - PXE instance
|
|
5
|
+
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
6
|
+
* @param opts - Options
|
|
7
|
+
*/ export async function waitForL1ToL2MessageReady(pxe, l1ToL2MessageHash, opts) {
|
|
8
|
+
const messageBlockNumber = await pxe.getL1ToL2MessageBlock(l1ToL2MessageHash);
|
|
9
|
+
return retryUntil(()=>isL1ToL2MessageReady(pxe, l1ToL2MessageHash, {
|
|
10
|
+
...opts,
|
|
11
|
+
messageBlockNumber
|
|
12
|
+
}), `L1 to L2 message ${l1ToL2MessageHash.toString()} ready`, opts.timeoutSeconds, 1);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns whether the L1 to L2 message is ready to be consumed.
|
|
16
|
+
* @param pxe - PXE instance
|
|
17
|
+
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
18
|
+
* @param opts - Options
|
|
19
|
+
* @returns True if the message is ready to be consumed, false otherwise
|
|
20
|
+
*/ export async function isL1ToL2MessageReady(pxe, l1ToL2MessageHash, opts) {
|
|
21
|
+
const blockNumber = await pxe.getBlockNumber();
|
|
22
|
+
const messageBlockNumber = opts.messageBlockNumber ?? await pxe.getL1ToL2MessageBlock(l1ToL2MessageHash);
|
|
23
|
+
if (messageBlockNumber === undefined) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// Note that public messages can be consumed 1 block earlier, since the sequencer will include the messages
|
|
27
|
+
// in the L1 to L2 message tree before executing the txs for the block. In private, however, we need to wait
|
|
28
|
+
// until the message is included so we can make use of the membership witness.
|
|
29
|
+
return opts.forPublicConsumption ? blockNumber + 1 >= messageBlockNumber : blockNumber >= messageBlockNumber;
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2-rc.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dest/index.js",
|
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@aztec/constants": "2.0.
|
|
85
|
-
"@aztec/entrypoints": "2.0.
|
|
86
|
-
"@aztec/ethereum": "2.0.
|
|
87
|
-
"@aztec/foundation": "2.0.
|
|
88
|
-
"@aztec/l1-artifacts": "2.0.
|
|
89
|
-
"@aztec/protocol-contracts": "2.0.
|
|
90
|
-
"@aztec/stdlib": "2.0.
|
|
84
|
+
"@aztec/constants": "2.0.2-rc.2",
|
|
85
|
+
"@aztec/entrypoints": "2.0.2-rc.2",
|
|
86
|
+
"@aztec/ethereum": "2.0.2-rc.2",
|
|
87
|
+
"@aztec/foundation": "2.0.2-rc.2",
|
|
88
|
+
"@aztec/l1-artifacts": "2.0.2-rc.2",
|
|
89
|
+
"@aztec/protocol-contracts": "2.0.2-rc.2",
|
|
90
|
+
"@aztec/stdlib": "2.0.2-rc.2",
|
|
91
91
|
"axios": "^1.8.2",
|
|
92
92
|
"tslib": "^2.4.0",
|
|
93
93
|
"viem": "2.23.7"
|
package/src/api/utils.ts
CHANGED
|
@@ -19,3 +19,4 @@ export { waitForPXE } from '../utils/pxe.js';
|
|
|
19
19
|
export { waitForNode, createAztecNodeClient, type AztecNode } from '../utils/node.js';
|
|
20
20
|
export { getFeeJuiceBalance } from '../utils/fee_juice.js';
|
|
21
21
|
export { readFieldCompressedString } from '../utils/field_compressed_string.js';
|
|
22
|
+
export { isL1ToL2MessageReady, waitForL1ToL2MessageReady } from '../utils/cross_chain.js';
|
|
@@ -30,6 +30,14 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
30
30
|
return await this.wallet.createTxExecutionRequest(requestWithoutFee, fee, { txNonce, cancellable });
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new instance with no actual calls. Useful for triggering a no-op.
|
|
35
|
+
* @param wallet - The wallet to use for sending the batch call.
|
|
36
|
+
*/
|
|
37
|
+
public static empty(wallet: Wallet) {
|
|
38
|
+
return new BatchCall(wallet, []);
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
/**
|
|
34
42
|
* Returns an execution request that represents this operation.
|
|
35
43
|
* @param options - An optional object containing additional configuration for the request generation.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
+
|
|
4
|
+
import type { PXE } from '../api/interfaces.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Waits for the L1 to L2 message to be ready to be consumed.
|
|
8
|
+
* @param pxe - PXE instance
|
|
9
|
+
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
10
|
+
* @param opts - Options
|
|
11
|
+
*/
|
|
12
|
+
export async function waitForL1ToL2MessageReady(
|
|
13
|
+
pxe: Pick<PXE, 'getBlockNumber' | 'getL1ToL2MessageBlock'>,
|
|
14
|
+
l1ToL2MessageHash: Fr,
|
|
15
|
+
opts: {
|
|
16
|
+
/** Timeout for the operation in seconds */ timeoutSeconds: number;
|
|
17
|
+
/** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
|
|
18
|
+
},
|
|
19
|
+
) {
|
|
20
|
+
const messageBlockNumber = await pxe.getL1ToL2MessageBlock(l1ToL2MessageHash);
|
|
21
|
+
return retryUntil(
|
|
22
|
+
() => isL1ToL2MessageReady(pxe, l1ToL2MessageHash, { ...opts, messageBlockNumber }),
|
|
23
|
+
`L1 to L2 message ${l1ToL2MessageHash.toString()} ready`,
|
|
24
|
+
opts.timeoutSeconds,
|
|
25
|
+
1,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether the L1 to L2 message is ready to be consumed.
|
|
31
|
+
* @param pxe - PXE instance
|
|
32
|
+
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
33
|
+
* @param opts - Options
|
|
34
|
+
* @returns True if the message is ready to be consumed, false otherwise
|
|
35
|
+
*/
|
|
36
|
+
export async function isL1ToL2MessageReady(
|
|
37
|
+
pxe: Pick<PXE, 'getBlockNumber' | 'getL1ToL2MessageBlock'>,
|
|
38
|
+
l1ToL2MessageHash: Fr,
|
|
39
|
+
opts: {
|
|
40
|
+
/** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
|
|
41
|
+
/** Cached synced block number for the message (will be fetched from PXE otherwise) */ messageBlockNumber?: number;
|
|
42
|
+
},
|
|
43
|
+
): Promise<boolean> {
|
|
44
|
+
const blockNumber = await pxe.getBlockNumber();
|
|
45
|
+
const messageBlockNumber = opts.messageBlockNumber ?? (await pxe.getL1ToL2MessageBlock(l1ToL2MessageHash));
|
|
46
|
+
if (messageBlockNumber === undefined) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Note that public messages can be consumed 1 block earlier, since the sequencer will include the messages
|
|
51
|
+
// in the L1 to L2 message tree before executing the txs for the block. In private, however, we need to wait
|
|
52
|
+
// until the message is included so we can make use of the membership witness.
|
|
53
|
+
return opts.forPublicConsumption ? blockNumber + 1 >= messageBlockNumber : blockNumber >= messageBlockNumber;
|
|
54
|
+
}
|