request-wallet-sign 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +20 -1
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -600,6 +600,7 @@ function txDataText() {
|
|
|
600
600
|
out.valueEth = formatEther(REQUEST.value) + ' ' + (meta.symbol || 'ETH');
|
|
601
601
|
if (REQUEST.data) out.data = REQUEST.data;
|
|
602
602
|
if (REQUEST.gas) out.gas = REQUEST.gas;
|
|
603
|
+
if (REQUEST.authorizationList) out.authorizationList = REQUEST.authorizationList;
|
|
603
604
|
} else if (REQUEST._type === 'signTypedData') {
|
|
604
605
|
out.typedData = REQUEST.typedData;
|
|
605
606
|
} else {
|
|
@@ -681,14 +682,19 @@ async function switchChain(account) {
|
|
|
681
682
|
}
|
|
682
683
|
|
|
683
684
|
async function buildTx(account) {
|
|
685
|
+
// An EIP-7702 authorizationList (e.g. relaying someone else's signed
|
|
686
|
+
// authorization) makes this a type-4 transaction; otherwise plain EIP-1559.
|
|
687
|
+
const authList = Array.isArray(REQUEST.authorizationList) && REQUEST.authorizationList.length
|
|
688
|
+
? REQUEST.authorizationList : null;
|
|
684
689
|
const tx = {
|
|
685
|
-
type: '0x2',
|
|
690
|
+
type: authList ? '0x4' : '0x2',
|
|
686
691
|
from: account,
|
|
687
692
|
chainId: hex(REQUEST.chainId),
|
|
688
693
|
value: REQUEST.value || '0x0',
|
|
689
694
|
};
|
|
690
695
|
if (REQUEST.to) tx.to = REQUEST.to;
|
|
691
696
|
if (REQUEST.data) tx.data = REQUEST.data;
|
|
697
|
+
if (authList) tx.authorizationList = authList;
|
|
692
698
|
|
|
693
699
|
// Gas limit
|
|
694
700
|
if (REQUEST.gas) {
|
|
@@ -913,6 +919,19 @@ async function renderWhatThisDoes() {
|
|
|
913
919
|
|
|
914
920
|
const { to, data, value } = REQUEST;
|
|
915
921
|
|
|
922
|
+
// EIP-7702: this tx also installs account delegation(s) — the highest-impact
|
|
923
|
+
// part, so surface each delegate target up front (Details shows the full tx).
|
|
924
|
+
if (Array.isArray(REQUEST.authorizationList) && REQUEST.authorizationList.length) {
|
|
925
|
+
const fields = REQUEST.authorizationList.map((a, i) => ({
|
|
926
|
+
label: 'Delegate #' + (i + 1),
|
|
927
|
+
value: (a && a.address) ? a.address : '(unknown target)',
|
|
928
|
+
danger: true,
|
|
929
|
+
}));
|
|
930
|
+
if (to) fields.push({ label: 'Then calls', value: to });
|
|
931
|
+
showWhat('Authorize account delegation (EIP-7702)', fields);
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
|
|
916
935
|
// Contract deployment
|
|
917
936
|
if (!to && data && data.length > 2) {
|
|
918
937
|
const bytes = Math.floor((data.length - 2) / 2);
|