@@ -93,9 +93,9 @@ describe("ERC20 to CW20 Pointer", function () {
93
93
expect ( await pointer . balanceOf ( sender . evmAddress ) ) . to . equal ( balances . account0 ) ;
94
94
expect ( await pointer . balanceOf ( recipient . evmAddress ) ) . to . equal ( balances . account1 ) ;
95
95
96
- const blockNumber = await ethers . provider . getBlockNumber ( ) ;
97
96
const tx = await pointer . transfer ( recipient . evmAddress , 1 ) ;
98
- await tx . wait ( ) ;
97
+ const receipt = await tx . wait ( ) ;
98
+ const blockNumber = receipt . blockNumber ;
99
99
100
100
expect ( await pointer . balanceOf ( sender . evmAddress ) ) . to . equal ( balances . account0 - 1 ) ;
101
101
expect ( await pointer . balanceOf ( recipient . evmAddress ) ) . to . equal ( balances . account1 + 1 ) ;
@@ -107,18 +107,38 @@ describe("ERC20 to CW20 Pointer", function () {
107
107
address : await pointer . getAddress ( ) ,
108
108
topics : [ ethers . id ( "Transfer(address,address,uint256)" ) ]
109
109
} ;
110
- // send via eth_ endpoint - synthetic event doesn't show up
110
+ // send via eth_ endpoint - synthetic event should show up because we are using the
111
+ // synthetic event in place of a real EVM event
111
112
const ethlogs = await ethers . provider . send ( 'eth_getLogs' , [ filter ] ) ;
112
- expect ( ethlogs . length ) . to . equal ( 0 ) ;
113
+ expect ( ethlogs . length ) . to . equal ( 1 ) ;
113
114
114
115
// send via sei_ endpoint - synthetic event shows up
115
116
const seilogs = await ethers . provider . send ( 'sei_getLogs' , [ filter ] ) ;
116
117
expect ( seilogs . length ) . to . equal ( 1 ) ;
117
- expect ( seilogs . length ) . to . equal ( 1 ) ;
118
- expect ( seilogs [ 0 ] [ "address" ] . toLowerCase ( ) ) . to . equal ( ( await pointer . getAddress ( ) ) . toLowerCase ( ) ) ;
119
- expect ( seilogs [ 0 ] [ "topics" ] [ 0 ] ) . to . equal ( ethers . id ( "Transfer(address,address,uint256)" ) ) ;
120
- expect ( seilogs [ 0 ] [ "topics" ] [ 1 ] . substring ( 26 ) ) . to . equal ( sender . evmAddress . substring ( 2 ) . toLowerCase ( ) ) ;
121
- expect ( seilogs [ 0 ] [ "topics" ] [ 2 ] . substring ( 26 ) ) . to . equal ( recipient . evmAddress . substring ( 2 ) . toLowerCase ( ) ) ;
118
+
119
+ const logs = [ ...ethlogs , ...seilogs ] ;
120
+ logs . forEach ( async ( log ) => {
121
+ expect ( log [ "address" ] . toLowerCase ( ) ) . to . equal ( ( await pointer . getAddress ( ) ) . toLowerCase ( ) ) ;
122
+ expect ( log [ "topics" ] [ 0 ] ) . to . equal ( ethers . id ( "Transfer(address,address,uint256)" ) ) ;
123
+ expect ( log [ "topics" ] [ 1 ] . substring ( 26 ) ) . to . equal ( sender . evmAddress . substring ( 2 ) . toLowerCase ( ) ) ;
124
+ expect ( log [ "topics" ] [ 2 ] . substring ( 26 ) ) . to . equal ( recipient . evmAddress . substring ( 2 ) . toLowerCase ( ) ) ;
125
+ } ) ;
126
+
127
+ const ethBlock = await ethers . provider . send ( 'eth_getBlockByNumber' , [ '0x' + blockNumber . toString ( 16 ) , false ] ) ;
128
+ const seiBlock = await ethers . provider . send ( 'sei_getBlockByNumber' , [ '0x' + blockNumber . toString ( 16 ) , false ] ) ;
129
+ expect ( ethBlock . transactions . length ) . to . equal ( 1 ) ;
130
+ expect ( seiBlock . transactions . length ) . to . equal ( 1 ) ;
131
+
132
+ const ethReceipts = await ethers . provider . send ( 'eth_getBlockReceipts' , [ '0x' + blockNumber . toString ( 16 ) ] ) ;
133
+ const seiReceipts = await ethers . provider . send ( 'sei_getBlockReceipts' , [ '0x' + blockNumber . toString ( 16 ) ] ) ;
134
+ expect ( ethReceipts . length ) . to . equal ( 1 ) ;
135
+ expect ( seiReceipts . length ) . to . equal ( 1 ) ;
136
+ expect ( ethReceipts [ 0 ] . transactionHash ) . to . equal ( seiReceipts [ 0 ] . transactionHash ) ;
137
+
138
+ const ethTx = await ethers . provider . send ( 'eth_getTransactionReceipt' , [ receipt . hash ] ) ;
139
+ expect ( ethTx . logs . length ) . to . equal ( 1 ) ; // check for transfer event
140
+ const ethTxByHash = await ethers . provider . send ( 'eth_getTransactionByHash' , [ tx . hash ] ) ;
141
+ expect ( ethTxByHash ) . to . not . be . null ;
122
142
123
143
const cleanupTx = await pointer . connect ( recipient . signer ) . transfer ( sender . evmAddress , 1 ) ;
124
144
await cleanupTx . wait ( ) ;
@@ -147,7 +167,7 @@ describe("ERC20 to CW20 Pointer", function () {
147
167
const spender = accounts [ 1 ] . evmAddress ;
148
168
const blockNumber = await ethers . provider . getBlockNumber ( ) ;
149
169
const tx = await pointer . approve ( spender , 1000000 ) ;
150
- await tx . wait ( ) ;
170
+ const receipt = await tx . wait ( ) ;
151
171
const allowance = await pointer . allowance ( owner , spender ) ;
152
172
expect ( Number ( allowance ) ) . to . equal ( 1000000 ) ;
153
173
@@ -160,15 +180,15 @@ describe("ERC20 to CW20 Pointer", function () {
160
180
} ;
161
181
// send via eth_ endpoint - synthetic event doesn't show up
162
182
const ethlogs = await ethers . provider . send ( 'eth_getLogs' , [ filter ] ) ;
163
- expect ( ethlogs . length ) . to . equal ( 0 ) ;
183
+ expect ( ethlogs . length ) . to . equal ( 1 ) ;
184
+ expect ( ethlogs [ 0 ] [ "address" ] . toLowerCase ( ) ) . to . equal ( ( await pointer . getAddress ( ) ) . toLowerCase ( ) ) ;
185
+ expect ( ethlogs [ 0 ] [ "topics" ] [ 0 ] ) . to . equal ( ethers . id ( "Approval(address,address,uint256)" ) ) ;
186
+ expect ( ethlogs [ 0 ] [ "topics" ] [ 1 ] . substring ( 26 ) ) . to . equal ( owner . substring ( 2 ) . toLowerCase ( ) ) ;
187
+ expect ( ethlogs [ 0 ] [ "topics" ] [ 2 ] . substring ( 26 ) ) . to . equal ( spender . substring ( 2 ) . toLowerCase ( ) ) ;
164
188
165
189
// send via sei_ endpoint - synthetic event shows up
166
190
const seilogs = await ethers . provider . send ( 'sei_getLogs' , [ filter ] ) ;
167
191
expect ( seilogs . length ) . to . equal ( 1 ) ;
168
- expect ( seilogs [ 0 ] [ "address" ] . toLowerCase ( ) ) . to . equal ( ( await pointer . getAddress ( ) ) . toLowerCase ( ) ) ;
169
- expect ( seilogs [ 0 ] [ "topics" ] [ 0 ] ) . to . equal ( ethers . id ( "Approval(address,address,uint256)" ) ) ;
170
- expect ( seilogs [ 0 ] [ "topics" ] [ 1 ] . substring ( 26 ) ) . to . equal ( owner . substring ( 2 ) . toLowerCase ( ) ) ;
171
- expect ( seilogs [ 0 ] [ "topics" ] [ 2 ] . substring ( 26 ) ) . to . equal ( spender . substring ( 2 ) . toLowerCase ( ) ) ;
172
192
} ) ;
173
193
174
194
it ( "should lower approval" , async function ( ) {
0 commit comments