@@ -2,6 +2,7 @@ import { Address, Bytes, Provider, Hex, RpcTransport, Secp256k1, AbiFunction } f
22import { Context , Payload } from '@0xsequence/wallet-primitives'
33import { LocalRelayer } from '../src/relayer/local'
44import { describe , it , expect , vi } from 'vitest'
5+ import { isAddressEqual } from 'viem'
56import {
67 NativeBalancePrecondition ,
78 Erc20BalancePrecondition ,
@@ -632,7 +633,7 @@ describe('Intent Configuration Address', () => {
632633 const address = calculateIntentConfigurationAddress ( mainSigner , [ payload ] , context )
633634
634635 // Verify the address matches Go test
635- expect ( address . toString ( ) ) . toBe ( '0x8577dfb93fe58cc8ee90dea522555fdf01fd7429' )
636+ expect ( isAddressEqual ( address , '0x8577dFb93fE58cc8EE90DEA522555Fdf01Fd7429' ) ) . toBe ( true )
636637 } )
637638
638639 it ( 'should calculate address for multiple operations' , ( ) => {
@@ -689,6 +690,70 @@ describe('Intent Configuration Address', () => {
689690 const address = calculateIntentConfigurationAddress ( mainSigner , [ payload1 , payload2 ] , context )
690691
691692 // Verify the address matches Go test
692- expect ( address . toString ( ) ) . toBe ( '0xbd820ed5b1e969ed6509e8ede687dfc4c714438f' )
693+ expect ( isAddressEqual ( address , '0xBd820eD5b1E969eD6509E8EdE687DfC4c714438F' ) ) . toBe ( true )
694+ } )
695+
696+ it ( 'should calculate address for multi-chain intent operations' , ( ) => {
697+ // Create context
698+ const context : Context . Context = {
699+ factory : '0xBd0F8abD58B4449B39C57Ac9D5C67433239aC447' as `0x${string } `,
700+ stage1 : '0x2440595Ead70Ba5874572153910362DcA2dde417' as `0x${string } `,
701+ stage2 : '0xa3F27508a1Dac8A11C0791f7EBEA5fc95dC1e131' as `0x${string } `,
702+ creationCode :
703+ '0x603e600e3d39601e805130553df33d3d34601c57363d3d373d363d30545af43d82803e903d91601c57fd5bf3' as `0x${string } `,
704+ }
705+
706+ // Main signer
707+ const mainSigner = Address . from ( '0x1111111111111111111111111111111111111111' )
708+
709+ // Create multi-chain operations
710+ const arbitrumPayload : IntentCallsPayload = {
711+ chainId : 42161n ,
712+ type : 'call' ,
713+ space : 0n ,
714+ nonce : 0n ,
715+ calls : [
716+ {
717+ to : Address . from ( '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae' ) ,
718+ value : 16960774n ,
719+ data : '0xa6010a66000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000be0548f317223fcd2c44d34d7e8ec9fc78482cd1d61cd3d3f206ad07ed50d043c02000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e58310000000000000000000000008456195dd0793c621c7f9245edf0fef85b1b879c00000000000000000000000000000000000000000000000000000000000072c0000000000000000000000000000000000000000000000000000000000000210500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d737461726761746556324275730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000f2388207e4600000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000086490411a32000000000000000000000000f851d3d46237ec552a4c6e383a973115e781b1a5000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000f851d3d46237ec552a4c6e383a973115e781b1a50000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000f2388207e46000000000000000000000000000000000000000000000000000000000000753200000000000000000000000000000000000000000000000000000000000078d20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000042000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f2388207e4600000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000004d0e30db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000001276ca67566283cce1cffe830e0bb873c80551be000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000f2388207e46000000000000000000000000f851d3d46237ec552a4c6e383a973115e781b1a500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e82af49447d8a07e3bd95bd0d56f35241523fbab1000bb8af88d065e77c8cc2239327c5edb3a432268e583100001f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e85000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000922164bbbd36acf9e854acbbf32facc949fcaeef00000000000000000000000000000000000000000000000000000000000078d200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e58310000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e58310000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000077368def90800000000000000000000000000000000000000000000000000000000000000000000000000000000000000008456195dd0793c621c7f9245edf0fef85b1b879c00000000000000000000000000000000000000000000000000000000000075e80000000000000000000000008456195dd0793c621c7f9245edf0fef85b1b879c0000000000000000000000000000000000000000000000000000000000007532000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000' as Hex . Hex ,
720+ gasLimit : 0n ,
721+ delegateCall : false ,
722+ onlyFallback : false ,
723+ behaviorOnError : 'ignore' ,
724+ } ,
725+ ] ,
726+ }
727+
728+ const basePayload : IntentCallsPayload = {
729+ chainId : 8453n ,
730+ type : 'call' ,
731+ space : 0n ,
732+ nonce : 0n ,
733+ calls : [
734+ {
735+ to : Address . from ( '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' ) ,
736+ value : 0n ,
737+ data : '0xa9059cbb000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000007530' as Hex . Hex ,
738+ gasLimit : 0n ,
739+ delegateCall : false ,
740+ onlyFallback : false ,
741+ behaviorOnError : 'ignore' ,
742+ } ,
743+ ] ,
744+ }
745+
746+ // Calculate intent configuration address
747+ const address = calculateIntentConfigurationAddress ( mainSigner , [ arbitrumPayload , basePayload ] , context )
748+
749+ // The address should be deterministic based on the inputs
750+ expect ( address ) . toBeDefined ( )
751+ expect ( address . startsWith ( '0x' ) ) . toBe ( true )
752+ expect ( address . length ) . toBe ( 42 )
753+
754+ console . log ( 'address' , address )
755+
756+ // Calculated address should match Go test
757+ expect ( isAddressEqual ( address , '0xB2621385fae972FEF53985ed7B9673EacD5a32Ff' ) ) . toBe ( true )
693758 } )
694759} )
0 commit comments