Skip to content

Commit 8df8935

Browse files
committed
tweaks
1 parent 3369feb commit 8df8935

File tree

1 file changed

+48
-47
lines changed

1 file changed

+48
-47
lines changed

src/components/ppom/transactions.js

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import globalContext from '../..';
22
import { maliciousAddress } from '../../sample-addresses';
3-
import { MALICIOUS_CONTRACT_ADDRESSES } from '../../onchain-sample-contracts';
43
import { isSepoliaNetworkId } from '../../utils';
54
import { getMaliciousTransactions } from './sharedConstants';
65

@@ -48,17 +47,17 @@ export function ppomMaliciousTransactionsAndSignatures(parentContainer) {
4847
</button>
4948
<button
5049
class="btn btn-primary btn-lg btn-block mb-3"
51-
id="maliciousContractInteractionButton"
50+
id="maliciousSetApprovalForAll"
5251
disabled
5352
>
54-
Malicious Contract Interaction
53+
Malicious Set Approval For All
5554
</button>
5655
<button
5756
class="btn btn-primary btn-lg btn-block mb-3"
58-
id="maliciousSetApprovalForAll"
57+
id="maliciousContractInteractionButton"
5958
disabled
6059
>
61-
Malicious Set Approval For All
60+
Malicious Contract Interaction
6261
</button>
6362
<h5>Signatures</h5>
6463
<button
@@ -140,14 +139,15 @@ export function ppomMaliciousTransactionsAndSignatures(parentContainer) {
140139

141140
// Malicious raw ETH transfer
142141
maliciousRawEthButton.onclick = async () => {
143-
const maliciousTransactions = getMaliciousTransactions(globalContext);
142+
const { eth } = getMaliciousTransactions(globalContext);
144143
const result = await globalContext.provider.request({
145144
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+
],
151151
});
152152
console.log(result);
153153
};
@@ -162,76 +162,77 @@ export function ppomMaliciousTransactionsAndSignatures(parentContainer) {
162162
const noPrefixedAddress = from.slice(2);
163163
const result = await globalContext.provider.request({
164164
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+
],
171173
});
172174
console.log(result);
173175
};
174176

175177
// Malicious ERC20 transfer
176178
maliciousERC20TransferButton.onclick = async () => {
177-
const maliciousTransactions = getMaliciousTransactions(globalContext);
179+
const { erc20Transfer } = getMaliciousTransactions(globalContext);
178180
const result = await globalContext.provider.request({
179181
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+
],
186188
});
187189
console.log(result);
188190
};
189191

190192
// Malicious ERC20 Approval
191193
maliciousApprovalButton.onclick = async () => {
192-
const maliciousTransactions = getMaliciousTransactions(globalContext);
194+
const { erc20Approval } = getMaliciousTransactions(globalContext);
193195
const result = await globalContext.provider.request({
194196
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+
],
201203
});
202204
console.log(result);
203205
};
204206

205207
// Malicious Contract interaction
206208
maliciousContractInteractionButton.onclick = async () => {
207-
const contractAddress =
208-
MALICIOUS_CONTRACT_ADDRESSES[globalContext.networkName] ||
209-
MALICIOUS_CONTRACT_ADDRESSES.default;
209+
const { maliciousContractInteraction } =
210+
getMaliciousTransactions(globalContext);
210211

211212
const result = await globalContext.provider.request({
212213
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+
],
219220
});
220221
console.log(result);
221222
};
222223

223224
// Malicious Set Approval For All
224225
maliciousSetApprovalForAll.onclick = async () => {
225-
const maliciousTransactions = getMaliciousTransactions(globalContext);
226+
const { setApprovalForAll } = getMaliciousTransactions(globalContext);
226227

227228
const result = await globalContext.provider.request({
228229
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+
],
235236
});
236237
console.log(result);
237238
};

0 commit comments

Comments
 (0)