@@ -15,6 +15,47 @@ export const DEFAULT_CALLS = [
15
15
} ,
16
16
] ;
17
17
18
+ const ERC20_USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' ;
19
+ const ERC20_USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7' ;
20
+ const ERC721_BORED_APE = '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d' ;
21
+ const ERC1155_OPENSTORE = '0x495f947276749ce646f68ac8c248420045cb7b5e' ;
22
+ const PERMIT2 = '0x000000000022D473030F116dDEE9F6B43aC78BA3' ;
23
+
24
+ const CALL_APPROVAL_ERC20_LEGACY = {
25
+ data : '0x095ea7b30000000000000000000000000c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb0000000000000000000000000000000000000000000000000000000000459480' ,
26
+ to : ERC20_USDC ,
27
+ } ;
28
+
29
+ const CALL_APPROVAL_ERC20_PERMIT_2 = {
30
+ data : '0x87517c45000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb000000000000000000000000000000000000000000000000000000000012C4B00000000000000000000000000000000000000000000000000000000068437af0' ,
31
+ to : PERMIT2 ,
32
+ } ;
33
+
34
+ const CALL_APPROVAL_ERC20_INCREASE_ALLOWANCE = {
35
+ data : '0x395093510000000000000000000000000c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb0000000000000000000000000000000000000000000000000000000000786450' ,
36
+ to : ERC20_USDC ,
37
+ } ;
38
+
39
+ const CALL_APPROVAL_ERC20_LEGACY_UNLIMITED = {
40
+ data : '0x095ea7b30000000000000000000000000c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb0000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFF' ,
41
+ to : ERC20_USDT ,
42
+ } ;
43
+
44
+ const CALL_APPROVAL_ERC721_APPROVE = {
45
+ data : '0x095ea7b30000000000000000000000000c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb00000000000000000000000000000000000000000000000000000000000020F0' ,
46
+ to : ERC721_BORED_APE ,
47
+ } ;
48
+
49
+ const CALL_APPROVAL_ERC721_APPROVE_ALL = {
50
+ data : '0xa22cb4650000000000000000000000000c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb0000000000000000000000000000000000000000000000000000000000000001' ,
51
+ to : ERC721_BORED_APE ,
52
+ } ;
53
+
54
+ const CALL_APPROVAL_ERC1155_APPROVE_ALL = {
55
+ data : '0xa22cb4650000000000000000000000000c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb0000000000000000000000000000000000000000000000000000000000000001' ,
56
+ to : ERC1155_OPENSTORE ,
57
+ } ;
58
+
18
59
export function sendCallsComponent ( parentContainer ) {
19
60
parentContainer . insertAdjacentHTML (
20
61
'beforeend' ,
@@ -63,6 +104,14 @@ export function sendCallsComponent(parentContainer) {
63
104
Send Calls
64
105
</button>
65
106
107
+ <button
108
+ class="btn btn-primary btn-lg btn-block mb-3"
109
+ id="eip5792SendCallsApprovalButton"
110
+ disabled
111
+ >
112
+ Send Calls - Multiple Approvals
113
+ </button>
114
+
66
115
<p class="info-text alert alert-warning" id="eip5792SendCallsErrorContainer" hidden>
67
116
<span class="wrap" id="eip5792SendCallsError"></span>
68
117
</p>` ,
@@ -76,6 +125,9 @@ export function sendCallsComponent(parentContainer) {
76
125
const callsContainer = document . getElementById ( 'eip5792Calls' ) ;
77
126
const addCallButton = document . getElementById ( 'eip5792AddCall' ) ;
78
127
const sendCallsButton = document . getElementById ( 'eip5792SendCallsButton' ) ;
128
+ const sendCallsApprovalButton = document . getElementById (
129
+ 'eip5792SendCallsApprovalButton' ,
130
+ ) ;
79
131
const errorContainer = document . getElementById (
80
132
'eip5792SendCallsErrorContainer' ,
81
133
) ;
@@ -86,13 +138,15 @@ export function sendCallsComponent(parentContainer) {
86
138
editButton . disabled = false ;
87
139
addCallButton . disabled = false ;
88
140
sendCallsButton . disabled = false ;
141
+ sendCallsApprovalButton . disabled = false ;
89
142
}
90
143
} ) ;
91
144
92
145
document . addEventListener ( 'disableAndClear' , function ( ) {
93
146
editButton . disabled = true ;
94
147
addCallButton . disabled = true ;
95
148
sendCallsButton . disabled = true ;
149
+ sendCallsApprovalButton . disabled = true ;
96
150
} ) ;
97
151
98
152
editButton . onclick = async ( ) => {
@@ -122,10 +176,31 @@ export function sendCallsComponent(parentContainer) {
122
176
} ;
123
177
124
178
sendCallsButton . onclick = async ( ) => {
179
+ submitRequest ( ) ;
180
+ } ;
181
+
182
+ sendCallsApprovalButton . onclick = ( ) => {
183
+ submitRequest ( [
184
+ CALL_APPROVAL_ERC20_LEGACY ,
185
+ CALL_APPROVAL_ERC20_PERMIT_2 ,
186
+ CALL_APPROVAL_ERC20_INCREASE_ALLOWANCE ,
187
+ CALL_APPROVAL_ERC20_LEGACY_UNLIMITED ,
188
+ CALL_APPROVAL_ERC721_APPROVE ,
189
+ CALL_APPROVAL_ERC721_APPROVE_ALL ,
190
+ CALL_APPROVAL_ERC1155_APPROVE_ALL ,
191
+ ] ) ;
192
+ } ;
193
+
194
+ async function submitRequest ( calls ) {
125
195
try {
126
196
const result = await globalContext . provider . request ( {
127
197
method : 'wallet_sendCalls' ,
128
- params : [ getParams ( ) ] ,
198
+ params : [
199
+ {
200
+ ...getParams ( ) ,
201
+ ...( calls ? { calls } : { } ) ,
202
+ } ,
203
+ ] ,
129
204
} ) ;
130
205
131
206
document . getElementById ( 'eip5792RequestIdInput' ) . value = result . id ;
@@ -136,7 +211,7 @@ export function sendCallsComponent(parentContainer) {
136
211
errorContainer . hidden = false ;
137
212
errorOutput . innerHTML = `Error: ${ error . message } ` ;
138
213
}
139
- } ;
214
+ }
140
215
141
216
function getParams ( ) {
142
217
const useInputs = isCustom ( ) ;
0 commit comments