77import { TEST_CLIENT } from "../../../test/src/test-clients.js" ;
88import { TEST_ACCOUNT_A } from "../../../test/src/test-wallets.js" ;
99import { simulateTransaction } from "../../transaction/actions/simulate.js" ;
10+ import { computePublishedContractAddress } from "../../utils/any-evm/compute-published-contract-address.js" ;
11+ import { keccakId } from "../../utils/any-evm/keccak-id.js" ;
1012import { ENTRYPOINT_ADDRESS_v0_6 } from "../../wallets/smart/lib/constants.js" ;
1113import { prepareDeterministicDeployTransaction } from "./deploy-deterministic.js" ;
1214
@@ -51,6 +53,16 @@ describe.runIf(process.env.TW_SECRET_KEY)("deployFromMetadata", () => {
5153 salt : "some-salt" ,
5254 } ) ;
5355 const tx2 = prepareDeterministicDeployTransaction ( {
56+ chain : FORKED_ETHEREUM_CHAIN ,
57+ client : TEST_CLIENT ,
58+ contractId : "AccountFactory" ,
59+ constructorParams : {
60+ defaultAdmin : TEST_ACCOUNT_A . address ,
61+ entrypoint : ENTRYPOINT_ADDRESS_v0_6 ,
62+ } ,
63+ salt : keccakId ( "some-salt" ) ,
64+ } ) ;
65+ const tx3 = prepareDeterministicDeployTransaction ( {
5466 chain : FORKED_OPTIMISM_CHAIN ,
5567 client : TEST_CLIENT ,
5668 contractId : "AccountFactory" ,
@@ -59,11 +71,42 @@ describe.runIf(process.env.TW_SECRET_KEY)("deployFromMetadata", () => {
5971 entrypoint : ENTRYPOINT_ADDRESS_v0_6 ,
6072 } ,
6173 } ) ;
62- const [ tx1Result , tx2Result ] = await Promise . all ( [
74+ const [ tx1Result , tx2Result , tx3Result ] = await Promise . all ( [
6375 simulateTransaction ( { transaction : tx1 } ) ,
6476 simulateTransaction ( { transaction : tx2 } ) ,
77+ simulateTransaction ( { transaction : tx3 } ) ,
78+ ] ) ;
79+ expect ( tx1Result === tx2Result ) . toBe ( true ) ;
80+ expect ( tx1Result !== tx3Result ) . toBe ( true ) ;
81+ } ) ;
82+
83+ it ( "computed address and deployed address should match" , async ( ) => {
84+ const computedPromise = computePublishedContractAddress ( {
85+ chain : FORKED_ETHEREUM_CHAIN ,
86+ client : TEST_CLIENT ,
87+ contractId : "AccountFactory" ,
88+ constructorParams : {
89+ defaultAdmin : TEST_ACCOUNT_A . address ,
90+ entrypoint : ENTRYPOINT_ADDRESS_v0_6 ,
91+ } ,
92+ salt : keccakId ( "some-salt" ) ,
93+ } ) ;
94+ const tx = prepareDeterministicDeployTransaction ( {
95+ chain : FORKED_ETHEREUM_CHAIN ,
96+ client : TEST_CLIENT ,
97+ contractId : "AccountFactory" ,
98+ constructorParams : {
99+ defaultAdmin : TEST_ACCOUNT_A . address ,
100+ entrypoint : ENTRYPOINT_ADDRESS_v0_6 ,
101+ } ,
102+ salt : keccakId ( "some-salt" ) ,
103+ } ) ;
104+
105+ const [ computed , txResult ] = await Promise . all ( [
106+ computedPromise ,
107+ simulateTransaction ( { transaction : tx } ) ,
65108 ] ) ;
66- expect ( tx1Result !== tx2Result ) . toBe ( true ) ;
109+ expect ( computed === txResult ) . toBe ( true ) ;
67110 } ) ;
68111 // TODO: Replace these tests' live contracts with mocks
69112 it ( "should deploy a published contract with no constructor" , async ( ) => {
0 commit comments