Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/components/transactions/transaction-batch/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { transactionBatchButtonsComponent } from "./transactionBatchButtonsComponent";

Check failure on line 1 in src/components/transactions/transaction-batch/index.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `"./transactionBatchButtonsComponent"` with `'./transactionBatchButtonsComponent'`

export function transactionBatchComponent(parentContainer) {
parentContainer.insertAdjacentHTML(
'beforeend',
`<div class="col-xl-4 col-lg-6 col-md-12 col-sm-12 col-12 d-flex align-items-stretch">
<div class="card full-width">
<div class="card-body eip5792">
<h4 class="card-title">
Transaction Batch
</h4>
<div id="transactionBatchButtons"></div>
</div>
</div>
</div`,
);

transactionBatchButtonsComponent(document.getElementById('transactionBatchButtons'));

Check failure on line 18 in src/components/transactions/transaction-batch/index.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `document.getElementById('transactionBatchButtons')` with `⏎····document.getElementById('transactionBatchButtons'),⏎··`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import globalContext from '../../..';

export const VERSION = '2.0.0';

export function transactionBatchButtonsComponent(parentContainer) {
parentContainer.insertAdjacentHTML(
'beforeend',
`<button
class="btn btn-primary btn-lg btn-block mb-3"
id="transactionBatchSendRequest"
disabled
>
Send Transaction Batch Request
</button>
`,
);

const sendRequestButton = document.getElementById('transactionBatchSendRequest');

Check failure on line 18 in src/components/transactions/transaction-batch/transactionBatchButtonsComponent.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `'transactionBatchSendRequest'` with `⏎····'transactionBatchSendRequest',⏎··`

document.addEventListener('globalConnectionChange', function (e) {
if (e.detail.connected) {
sendRequestButton.disabled = false;
}
});

document.addEventListener('disableAndClear', function () {
sendRequestButton.disabled = true;
});

const calls = [
{
// Transfer DAI
data: "0xa9059cbb000000000000000000000000dc47789de4ceff0e8fe9d15d728af7f17550c164000000000000000000000000000000000000000000000001158e460913d00000",

Check failure on line 33 in src/components/transactions/transaction-batch/transactionBatchButtonsComponent.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `"0xa9059cbb000000000000000000000000dc47789de4ceff0e8fe9d15d728af7f17550c164000000000000000000000000000000000000000000000001158e460913d00000"` with `'0xa9059cbb000000000000000000000000dc47789de4ceff0e8fe9d15d728af7f17550c164000000000000000000000000000000000000000000000001158e460913d00000'`
to: "0x6b175474e89094c44da98b954eedeac495271d0f",

Check failure on line 34 in src/components/transactions/transaction-batch/transactionBatchButtonsComponent.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `"0x6b175474e89094c44da98b954eedeac495271d0f"` with `'0x6b175474e89094c44da98b954eedeac495271d0f'`
value: "0x0",

Check failure on line 35 in src/components/transactions/transaction-batch/transactionBatchButtonsComponent.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `"0x0"` with `'0x0'`
},
{
// Transfer DAI
data: "0xa9059cbb000000000000000000000000dc47789de4ceff0e8fe9d15d728af7f17550c164000000000000000000000000000000000000000000000001158e460913d00000",

Check failure on line 39 in src/components/transactions/transaction-batch/transactionBatchButtonsComponent.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `"0xa9059cbb000000000000000000000000dc47789de4ceff0e8fe9d15d728af7f17550c164000000000000000000000000000000000000000000000001158e460913d00000"` with `'0xa9059cbb000000000000000000000000dc47789de4ceff0e8fe9d15d728af7f17550c164000000000000000000000000000000000000000000000001158e460913d00000'`
to: "0x6b175474e89094c44da98b954eedeac495271d0f",

Check failure on line 40 in src/components/transactions/transaction-batch/transactionBatchButtonsComponent.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `"0x6b175474e89094c44da98b954eedeac495271d0f"` with `'0x6b175474e89094c44da98b954eedeac495271d0f'`
value: "0x0",

Check failure on line 41 in src/components/transactions/transaction-batch/transactionBatchButtonsComponent.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Replace `"0x0"` with `'0x0'`
},
];

function getDefaultChainId() {
return `0x${globalContext.chainIdInt.toString(16)}`;
}

function getDefaultFrom() {
return globalContext.accounts[0];
}

function getParams() {
const from = getDefaultFrom();
const chainId = getDefaultChainId();;

Check failure on line 55 in src/components/transactions/transaction-batch/transactionBatchButtonsComponent.js

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test (20.x)

Delete `;`

return {
version: VERSION,
from,
chainId,
atomicRequired: true,
calls,
};
}

sendRequestButton.onclick = async () => {
try {
await globalContext.provider.request({
method: 'wallet_sendCalls',
params: [getParams()],
});
} catch (error) {
console.error(error.message);
}
};
}
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
} from './components/interactions';
import { sendFormComponent } from './components/forms/send-form';
import { eip5792Component } from './components/transactions/eip5792';
import { transactionBatchComponent } from './components/transactions/transaction-batch';

const {
hstBytecode,
Expand Down Expand Up @@ -178,6 +179,7 @@ erc721Component(transactionsRow);
erc1155Component(transactionsRow);
eip747Component(transactionsRow);
eip5792Component(transactionsRow);
transactionBatchComponent(transactionsRow);

const ppomSection = document.createElement('section');
mainContainer.appendChild(ppomSection);
Expand Down
Loading