1
1
import globalContext from '../..' ;
2
2
import { maliciousAddress } from '../../sample-addresses' ;
3
- import { MALICIOUS_CONTRACT_ADDRESSES } from '../../onchain-sample-contracts' ;
4
3
import { isSepoliaNetworkId } from '../../utils' ;
5
4
import { getMaliciousTransactions } from './sharedConstants' ;
6
5
@@ -48,17 +47,17 @@ export function ppomMaliciousTransactionsAndSignatures(parentContainer) {
48
47
</button>
49
48
<button
50
49
class="btn btn-primary btn-lg btn-block mb-3"
51
- id="maliciousContractInteractionButton "
50
+ id="maliciousSetApprovalForAll "
52
51
disabled
53
52
>
54
- Malicious Contract Interaction
53
+ Malicious Set Approval For All
55
54
</button>
56
55
<button
57
56
class="btn btn-primary btn-lg btn-block mb-3"
58
- id="maliciousSetApprovalForAll "
57
+ id="maliciousContractInteractionButton "
59
58
disabled
60
59
>
61
- Malicious Set Approval For All
60
+ Malicious Contract Interaction
62
61
</button>
63
62
<h5>Signatures</h5>
64
63
<button
@@ -140,14 +139,15 @@ export function ppomMaliciousTransactionsAndSignatures(parentContainer) {
140
139
141
140
// Malicious raw ETH transfer
142
141
maliciousRawEthButton . onclick = async ( ) => {
143
- const maliciousTransactions = getMaliciousTransactions ( globalContext ) ;
142
+ const { eth } = getMaliciousTransactions ( globalContext ) ;
144
143
const result = await globalContext . provider . request ( {
145
144
method : 'eth_sendTransaction' ,
146
- params : {
147
- from : globalContext . accounts [ 0 ] ,
148
- to : maliciousTransactions . eth . to ,
149
- value : maliciousTransactions . eth . value ,
150
- } ,
145
+ params : [
146
+ {
147
+ from : globalContext . accounts [ 0 ] ,
148
+ ...eth ,
149
+ } ,
150
+ ] ,
151
151
} ) ;
152
152
console . log ( result ) ;
153
153
} ;
@@ -162,76 +162,77 @@ export function ppomMaliciousTransactionsAndSignatures(parentContainer) {
162
162
const noPrefixedAddress = from . slice ( 2 ) ;
163
163
const result = await globalContext . provider . request ( {
164
164
method : 'eth_sendTransaction' ,
165
- params : {
166
- from,
167
- to : '0x27A56df30bC838BCA36141E517e7b5376dea68eE' ,
168
- value : '0x0' ,
169
- data : `0x40c10f19000000000000000000000000${ noPrefixedAddress } 000000000000000000000000000000000000000000000000000000001dcd6500` ,
170
- } ,
165
+ params : [
166
+ {
167
+ from,
168
+ to : '0x27A56df30bC838BCA36141E517e7b5376dea68eE' ,
169
+ value : '0x0' ,
170
+ data : `0x40c10f19000000000000000000000000${ noPrefixedAddress } 000000000000000000000000000000000000000000000000000000001dcd6500` ,
171
+ } ,
172
+ ] ,
171
173
} ) ;
172
174
console . log ( result ) ;
173
175
} ;
174
176
175
177
// Malicious ERC20 transfer
176
178
maliciousERC20TransferButton . onclick = async ( ) => {
177
- const maliciousTransactions = getMaliciousTransactions ( globalContext ) ;
179
+ const { erc20Transfer } = getMaliciousTransactions ( globalContext ) ;
178
180
const result = await globalContext . provider . request ( {
179
181
method : 'eth_sendTransaction' ,
180
- params : {
181
- from : globalContext . accounts [ 0 ] ,
182
- to : maliciousTransactions . erc20Transfer . to ,
183
- data : maliciousTransactions . erc20Transfer . data ,
184
- value : maliciousTransactions . erc20Transfer . value ,
185
- } ,
182
+ params : [
183
+ {
184
+ from : globalContext . accounts [ 0 ] ,
185
+ ... erc20Transfer ,
186
+ } ,
187
+ ] ,
186
188
} ) ;
187
189
console . log ( result ) ;
188
190
} ;
189
191
190
192
// Malicious ERC20 Approval
191
193
maliciousApprovalButton . onclick = async ( ) => {
192
- const maliciousTransactions = getMaliciousTransactions ( globalContext ) ;
194
+ const { erc20Approval } = getMaliciousTransactions ( globalContext ) ;
193
195
const result = await globalContext . provider . request ( {
194
196
method : 'eth_sendTransaction' ,
195
- params : {
196
- from : globalContext . accounts [ 0 ] ,
197
- to : maliciousTransactions . erc20Approval . to ,
198
- data : maliciousTransactions . erc20Approval . data ,
199
- value : maliciousTransactions . erc20Approval . value ,
200
- } ,
197
+ params : [
198
+ {
199
+ from : globalContext . accounts [ 0 ] ,
200
+ ... erc20Approval ,
201
+ } ,
202
+ ] ,
201
203
} ) ;
202
204
console . log ( result ) ;
203
205
} ;
204
206
205
207
// Malicious Contract interaction
206
208
maliciousContractInteractionButton . onclick = async ( ) => {
207
- const contractAddress =
208
- MALICIOUS_CONTRACT_ADDRESSES [ globalContext . networkName ] ||
209
- MALICIOUS_CONTRACT_ADDRESSES . default ;
209
+ const { maliciousContractInteraction } =
210
+ getMaliciousTransactions ( globalContext ) ;
210
211
211
212
const result = await globalContext . provider . request ( {
212
213
method : 'eth_sendTransaction' ,
213
- params : {
214
- from : globalContext . accounts [ 0 ] ,
215
- to : contractAddress ,
216
- data : '0xef5cfb8c0000000000000000000000000b3e87a076ac4b0d1975f0f232444af6deb96c59' ,
217
- value : '0x0' ,
218
- } ,
214
+ params : [
215
+ {
216
+ from : globalContext . accounts [ 0 ] ,
217
+ ... maliciousContractInteraction ,
218
+ } ,
219
+ ] ,
219
220
} ) ;
220
221
console . log ( result ) ;
221
222
} ;
222
223
223
224
// Malicious Set Approval For All
224
225
maliciousSetApprovalForAll . onclick = async ( ) => {
225
- const maliciousTransactions = getMaliciousTransactions ( globalContext ) ;
226
+ const { setApprovalForAll } = getMaliciousTransactions ( globalContext ) ;
226
227
227
228
const result = await globalContext . provider . request ( {
228
229
method : 'eth_sendTransaction' ,
229
- params : {
230
- from : globalContext . accounts [ 0 ] ,
231
- to : maliciousTransactions . setApprovalForAll . to ,
232
- data : maliciousTransactions . setApprovalForAll . data ,
233
- value : maliciousTransactions . setApprovalForAll . value ,
234
- } ,
230
+ params : [
231
+ {
232
+ from : globalContext . accounts [ 0 ] ,
233
+ ... setApprovalForAll ,
234
+ } ,
235
+ ] ,
235
236
} ) ;
236
237
console . log ( result ) ;
237
238
} ;
0 commit comments