@metamask/assets-controllers 43.1.1 → 44.0.1
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/CHANGELOG.md +25 -1
- package/dist/TokenBalancesController.cjs +157 -72
- package/dist/TokenBalancesController.cjs.map +1 -1
- package/dist/TokenBalancesController.d.cts +50 -30
- package/dist/TokenBalancesController.d.cts.map +1 -1
- package/dist/TokenBalancesController.d.mts +50 -30
- package/dist/TokenBalancesController.d.mts.map +1 -1
- package/dist/TokenBalancesController.mjs +159 -73
- package/dist/TokenBalancesController.mjs.map +1 -1
- package/dist/TokenDetectionController.cjs +4 -8
- package/dist/TokenDetectionController.cjs.map +1 -1
- package/dist/TokenDetectionController.d.cts.map +1 -1
- package/dist/TokenDetectionController.d.mts.map +1 -1
- package/dist/TokenDetectionController.mjs +4 -8
- package/dist/TokenDetectionController.mjs.map +1 -1
- package/dist/TokenRatesController.cjs +11 -1
- package/dist/TokenRatesController.cjs.map +1 -1
- package/dist/TokenRatesController.d.cts.map +1 -1
- package/dist/TokenRatesController.d.mts.map +1 -1
- package/dist/TokenRatesController.mjs +11 -1
- package/dist/TokenRatesController.mjs.map +1 -1
- package/dist/TokensController.cjs +20 -6
- package/dist/TokensController.cjs.map +1 -1
- package/dist/TokensController.d.cts +2 -2
- package/dist/TokensController.d.cts.map +1 -1
- package/dist/TokensController.d.mts +2 -2
- package/dist/TokensController.d.mts.map +1 -1
- package/dist/TokensController.mjs +20 -6
- package/dist/TokensController.mjs.map +1 -1
- package/dist/assetsUtil.cjs +2 -2
- package/dist/assetsUtil.cjs.map +1 -1
- package/dist/assetsUtil.d.cts +3 -3
- package/dist/assetsUtil.d.cts.map +1 -1
- package/dist/assetsUtil.d.mts +3 -3
- package/dist/assetsUtil.d.mts.map +1 -1
- package/dist/assetsUtil.mjs +2 -2
- package/dist/assetsUtil.mjs.map +1 -1
- package/dist/multicall.cjs +350 -0
- package/dist/multicall.cjs.map +1 -0
- package/dist/multicall.d.cts +26 -0
- package/dist/multicall.d.cts.map +1 -0
- package/dist/multicall.d.mts +26 -0
- package/dist/multicall.d.mts.map +1 -0
- package/dist/multicall.mjs +346 -0
- package/dist/multicall.mjs.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { Contract } from "@ethersproject/contracts";
|
|
2
|
+
import { reduceInBatchesSerially } from "./assetsUtil.mjs";
|
|
3
|
+
// https://github.com/mds1/multicall/blob/main/deployments.json
|
|
4
|
+
const MULTICALL_CONTRACT_BY_CHAINID = {
|
|
5
|
+
'0x1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
6
|
+
'0x2a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
7
|
+
'0x4': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
8
|
+
'0x5': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
9
|
+
'0x3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
10
|
+
'0xaa36a7': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
11
|
+
'0x4268': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
12
|
+
'0x5e9': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
13
|
+
'0x1b6e6': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
14
|
+
'0x18fc4a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
15
|
+
'0xa': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
16
|
+
'0x45': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
17
|
+
'0x1a4': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
18
|
+
'0xaa37dc': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
19
|
+
'0xa4b1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
20
|
+
'0xa4ba': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
21
|
+
'0x66eed': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
22
|
+
'0x66eee': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
23
|
+
'0x66eeb': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
24
|
+
'0x15f2249': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
25
|
+
'0x89': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
26
|
+
'0x13881': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
27
|
+
'0x13882': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
28
|
+
'0x44d': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
29
|
+
'0x5a2': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
30
|
+
'0x98a': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
31
|
+
'0x64': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
32
|
+
'0x27d8': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
33
|
+
'0xa86a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
34
|
+
'0xa869': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
35
|
+
'0xfa2': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
36
|
+
'0xfa': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
37
|
+
'0xfaf0': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
38
|
+
'0x38': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
39
|
+
'0x61': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
40
|
+
'0x15eb': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
41
|
+
'0xcc': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
42
|
+
'0x504': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
43
|
+
'0x505': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
44
|
+
'0x507': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
45
|
+
'0x2a15c308d': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
46
|
+
'0x2a15c3083': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
47
|
+
'0x63564c40': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
48
|
+
'0x19': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
49
|
+
'0x152': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
50
|
+
'0x5535072': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
51
|
+
'0x6c1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
52
|
+
'0x7a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
53
|
+
'0xe': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
54
|
+
'0x13': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
55
|
+
'0x10': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
56
|
+
'0x72': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
57
|
+
'0x120': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
58
|
+
'0x4e454152': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
59
|
+
'0x250': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
60
|
+
'0x5c2359': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
61
|
+
'0xec0': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
62
|
+
'0x42': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
63
|
+
'0x80': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
64
|
+
'0x440': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
65
|
+
'0x257': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
66
|
+
'0xe9fe': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
67
|
+
'0xd3a0': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
68
|
+
'0x84444': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
69
|
+
'0x1e': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
70
|
+
'0x1f': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
71
|
+
'0x2329': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
72
|
+
'0x2328': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
73
|
+
'0x6c': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
74
|
+
'0x12': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
75
|
+
'0xa516': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
76
|
+
'0x5afe': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
77
|
+
'0xa4ec': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
78
|
+
'0xaef3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
79
|
+
'0x116ea': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
80
|
+
'0x116e9': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
81
|
+
'0x2019': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
82
|
+
'0x3e9': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
83
|
+
'0x7d1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
84
|
+
'0x141': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
85
|
+
'0x6a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
86
|
+
'0x28': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
87
|
+
'0x4d2': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
88
|
+
'0x1e14': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
89
|
+
'0x1e15': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
90
|
+
'0x1251': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
91
|
+
'0x7f08': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
92
|
+
'0x8ae': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
93
|
+
'0x138b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
94
|
+
'0x1389': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
95
|
+
'0x1388': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
96
|
+
'0x1f92': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
97
|
+
'0x14a33': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
98
|
+
'0x14a34': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
99
|
+
'0x2105': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
100
|
+
'0x936': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
101
|
+
'0xff': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
102
|
+
'0x46a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
103
|
+
'0x46b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
104
|
+
'0x8a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
105
|
+
'0x14f': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
106
|
+
'0xd2af': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
107
|
+
'0xe9ac0ce': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
108
|
+
'0xe705': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
109
|
+
'0xe704': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
110
|
+
'0xe708': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
111
|
+
'0x2b6f': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
112
|
+
'0x39': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
113
|
+
'0x23a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
114
|
+
'0x1644': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
115
|
+
'0xdea8': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
116
|
+
'0x3af': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
117
|
+
'0x171': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
118
|
+
'0x3e7': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
119
|
+
'0x76adf1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
120
|
+
'0x3b9ac9ff': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
121
|
+
'0x2c': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
122
|
+
'0x2e': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
123
|
+
'0x15b3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
124
|
+
'0x82751': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
125
|
+
'0x8274f': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
126
|
+
'0x82750': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
127
|
+
'0x96f': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
128
|
+
'0x3cc5': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
129
|
+
'0x4571': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
130
|
+
'0xe99': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
131
|
+
'0x7d0': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
132
|
+
'0x1297': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
133
|
+
'0x1d5e': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
134
|
+
'0x3a14269b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
135
|
+
'0x561bf78b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
136
|
+
'0x235ddd0': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
137
|
+
'0x3cd156dc': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
138
|
+
'0x5d456c62': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
139
|
+
'0x79f99296': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
140
|
+
'0x585eb4b1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
141
|
+
'0x507aaa2a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
142
|
+
'0x1fc3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
143
|
+
'0x32d': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
144
|
+
'0x8a73': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
145
|
+
'0x8a72': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
146
|
+
'0x8a71': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
147
|
+
'0xe9ac0d6': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
148
|
+
'0x1069': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
149
|
+
'0x7e5': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
150
|
+
'0x53': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
151
|
+
'0x52': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
152
|
+
'0xe298': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
153
|
+
'0x1a8': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
154
|
+
'0x94': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
155
|
+
'0x2c6': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
156
|
+
'0x2803': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
157
|
+
'0x2802': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
158
|
+
'0xa9': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
159
|
+
'0x28c5f': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
160
|
+
'0x28c60': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
161
|
+
'0x13a': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
162
|
+
'0x4cb2f': '0xdbfa261cd7d17bb40479a0493ad6c0fee435859e',
|
|
163
|
+
'0x7f93': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
164
|
+
'0xb660': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
165
|
+
'0xb02113d3f': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
166
|
+
'0xdad': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
167
|
+
'0xdae': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
168
|
+
'0x15b38': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
169
|
+
'0x15b32': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
170
|
+
'0x45c': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
171
|
+
'0x45b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
172
|
+
'0x3d': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
173
|
+
'0x41a6ace': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
174
|
+
'0xa729': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
175
|
+
'0x1f47b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
176
|
+
'0x1b59': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
177
|
+
'0x1b58': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
178
|
+
'0xc3': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
179
|
+
'0x16fd8': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
180
|
+
'0xc7': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
181
|
+
'0x405': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
182
|
+
'0x334': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
183
|
+
'0x1ce': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
184
|
+
'0x1cf': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
185
|
+
'0xa70e': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
186
|
+
'0x868b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
187
|
+
'0xa0c71fd': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
188
|
+
'0x13e31': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
189
|
+
'0xa1337': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
190
|
+
'0x1f2b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
191
|
+
'0xf63': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
192
|
+
'0x144': '0xF9cda624FBC7e059355ce98a31693d299FACd963',
|
|
193
|
+
'0x118': '0xF9cda624FBC7e059355ce98a31693d299FACd963',
|
|
194
|
+
'0x12c': '0xF9cda624FBC7e059355ce98a31693d299FACd963',
|
|
195
|
+
'0x18995f': '0xF9cda624FBC7e059355ce98a31693d299FACd963',
|
|
196
|
+
'0x2b74': '0xF9cda624FBC7e059355ce98a31693d299FACd963',
|
|
197
|
+
'0xfc': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
198
|
+
'0x9da': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
199
|
+
'0x137': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
200
|
+
'0x13ed': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
201
|
+
'0x24b1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
202
|
+
'0xba9302': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
203
|
+
'0x7c8': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
204
|
+
'0x138d5': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
205
|
+
'0x6d': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
206
|
+
'0x343b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
207
|
+
'0x34a1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
208
|
+
'0x3109': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
209
|
+
'0x91b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
210
|
+
'0xa96': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
211
|
+
'0x22c3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
212
|
+
'0x2be3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
213
|
+
'0xbf03': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
214
|
+
'0x1b254': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
215
|
+
'0xa7b14': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
216
|
+
'0x2276': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
217
|
+
'0x1b9e': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
218
|
+
'0x6a63bb8': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
219
|
+
'0x15af3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
220
|
+
'0x15af1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
221
|
+
'0xae3f3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
222
|
+
'0x531': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
223
|
+
'0x28c61': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
224
|
+
'0x28c58': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
225
|
+
'0x1d88': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
226
|
+
'0x5b9b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
227
|
+
'0x4c7e1': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
228
|
+
'0xa53b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
229
|
+
'0x1a2b': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
230
|
+
'0x406': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
231
|
+
'0x2cef': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
232
|
+
'0x18b2': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
233
|
+
'0x182a9': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
234
|
+
'0xc4': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
235
|
+
'0xfdd': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
236
|
+
'0xfde': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
237
|
+
'0x99c0a0f': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
238
|
+
'0x22cf': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
239
|
+
'0x310c5': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
240
|
+
'0x46f': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
241
|
+
'0x659': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
242
|
+
'0x139c968f9': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
243
|
+
'0xed88': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
244
|
+
'0xd036': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
245
|
+
'0x1f3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
246
|
+
'0x31bf8c3': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
247
|
+
'0x1cbc67bfdc': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
248
|
+
'0x98967f': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
249
|
+
'0x4f588': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
250
|
+
'0x16db': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
251
|
+
'0x3a': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
252
|
+
'0x59': '0xca11bde05977b3631167028862be2a173976ca11',
|
|
253
|
+
'0x1e0': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
254
|
+
'0x2eb': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
255
|
+
'0x221': '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
256
|
+
};
|
|
257
|
+
const multicallAbi = [
|
|
258
|
+
{
|
|
259
|
+
name: 'tryAggregate',
|
|
260
|
+
type: 'function',
|
|
261
|
+
stateMutability: 'payable',
|
|
262
|
+
inputs: [
|
|
263
|
+
{ name: 'requireSuccess', type: 'bool' },
|
|
264
|
+
{
|
|
265
|
+
name: 'calls',
|
|
266
|
+
type: 'tuple[]',
|
|
267
|
+
components: [
|
|
268
|
+
{ name: 'target', type: 'address' },
|
|
269
|
+
{ name: 'callData', type: 'bytes' },
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
outputs: [
|
|
274
|
+
{
|
|
275
|
+
name: 'returnData',
|
|
276
|
+
type: 'tuple[]',
|
|
277
|
+
components: [
|
|
278
|
+
{ name: 'success', type: 'bool' },
|
|
279
|
+
{ name: 'returnData', type: 'bytes' },
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
];
|
|
285
|
+
const multicall = async (calls, multicallAddress, provider, maxCallsPerMulticall) => {
|
|
286
|
+
const multicallContract = new Contract(multicallAddress, multicallAbi, provider);
|
|
287
|
+
return await reduceInBatchesSerially({
|
|
288
|
+
values: calls,
|
|
289
|
+
batchSize: maxCallsPerMulticall,
|
|
290
|
+
initialResult: [],
|
|
291
|
+
eachBatch: async (workingResult, batch) => {
|
|
292
|
+
const calldata = batch.map((call) => ({
|
|
293
|
+
target: call.contract.address,
|
|
294
|
+
callData: call.contract.interface.encodeFunctionData(call.contract.interface.functions[call.functionSignature], call.arguments),
|
|
295
|
+
}));
|
|
296
|
+
const results = await multicallContract.callStatic.tryAggregate(false, calldata);
|
|
297
|
+
return [
|
|
298
|
+
...workingResult,
|
|
299
|
+
...results.map((r, i) => ({
|
|
300
|
+
success: r.success,
|
|
301
|
+
value: r.success
|
|
302
|
+
? batch[i].contract.interface.decodeFunctionResult(batch[i].functionSignature, r.returnData)[0]
|
|
303
|
+
: undefined,
|
|
304
|
+
})),
|
|
305
|
+
];
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
const fallback = async (calls, maxCallsParallel) => {
|
|
310
|
+
return await reduceInBatchesSerially({
|
|
311
|
+
values: calls,
|
|
312
|
+
batchSize: maxCallsParallel,
|
|
313
|
+
initialResult: [],
|
|
314
|
+
eachBatch: async (workingResult, batch) => {
|
|
315
|
+
const results = await Promise.allSettled(batch.map((call) => call.contract[call.functionSignature](...call.arguments)));
|
|
316
|
+
return [
|
|
317
|
+
...workingResult,
|
|
318
|
+
...results.map((p) => ({
|
|
319
|
+
success: p.status === 'fulfilled',
|
|
320
|
+
value: p.status === 'fulfilled' ? p.value : undefined,
|
|
321
|
+
})),
|
|
322
|
+
];
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Executes an array of contract calls. If the chain supports multicalls,
|
|
328
|
+
* the calls will be executed in single RPC requests (up to maxCallsPerMulticall).
|
|
329
|
+
* Otherwise the calls will be executed separately in parallel (up to maxCallsParallel).
|
|
330
|
+
* @param calls - An array of contract calls to execute.
|
|
331
|
+
* @param chainId - The hexadecimal chain id.
|
|
332
|
+
* @param provider - An ethers rpc provider.
|
|
333
|
+
* @param maxCallsPerMulticall - If multicall is supported, the maximum number of calls to exeute in each multicall.
|
|
334
|
+
* @param maxCallsParallel - If multicall is not supported, the maximum number of calls to execute in parallel.
|
|
335
|
+
* @returns An array of results, with a success boolean and value for each call.
|
|
336
|
+
*/
|
|
337
|
+
export const multicallOrFallback = async (calls, chainId, provider, maxCallsPerMulticall = 300, maxCallsParallel = 20) => {
|
|
338
|
+
if (calls.length === 0) {
|
|
339
|
+
return [];
|
|
340
|
+
}
|
|
341
|
+
const multicallAddress = MULTICALL_CONTRACT_BY_CHAINID[chainId];
|
|
342
|
+
return await (multicallAddress
|
|
343
|
+
? multicall(calls, multicallAddress, provider, maxCallsPerMulticall)
|
|
344
|
+
: fallback(calls, maxCallsParallel));
|
|
345
|
+
};
|
|
346
|
+
//# sourceMappingURL=multicall.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AAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,gBAAgB,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;IAChE,OAAO,MAAM,CAAC,gBAAgB;QAC5B,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,oBAAoB,CAAC;QACpE,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC","sourcesContent":["import { Contract } from '@ethersproject/contracts';\nimport type { Web3Provider } from '@ethersproject/providers';\nimport type { Hex } from '@metamask/utils';\n\nimport { reduceInBatchesSerially } from './assetsUtil';\n\n// https://github.com/mds1/multicall/blob/main/deployments.json\nconst MULTICALL_CONTRACT_BY_CHAINID = {\n '0x1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x4': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x5': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xaa36a7': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x4268': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x5e9': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1b6e6': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x18fc4a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x45': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1a4': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xaa37dc': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa4b1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa4ba': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x66eed': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x66eee': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x66eeb': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x15f2249': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x89': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x13881': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x13882': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x44d': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x5a2': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x98a': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x64': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x27d8': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa86a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa869': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xfa2': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xfa': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xfaf0': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x38': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x61': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x15eb': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xcc': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x504': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x505': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x507': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2a15c308d': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x2a15c3083': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x63564c40': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x19': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x152': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x5535072': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x6c1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x7a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xe': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x13': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x10': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x72': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x120': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x4e454152': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x250': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x5c2359': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xec0': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x42': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x80': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x440': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x257': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xe9fe': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xd3a0': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x84444': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1e': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1f': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2329': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2328': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x6c': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x12': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa516': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x5afe': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa4ec': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xaef3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x116ea': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x116e9': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2019': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3e9': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x7d1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x141': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x6a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x28': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x4d2': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1e14': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1e15': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1251': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x7f08': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x8ae': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x138b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1389': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1388': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1f92': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x14a33': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x14a34': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2105': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x936': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xff': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x46a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x46b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x8a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x14f': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xd2af': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xe9ac0ce': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xe705': '0xca11bde05977b3631167028862be2a173976ca11',\n '0xe704': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xe708': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2b6f': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x39': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x23a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1644': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xdea8': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3af': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x171': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3e7': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x76adf1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3b9ac9ff': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2c': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x2e': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x15b3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x82751': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x8274f': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x82750': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x96f': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3cc5': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x4571': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xe99': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x7d0': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1297': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1d5e': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3a14269b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x561bf78b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x235ddd0': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3cd156dc': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x5d456c62': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x79f99296': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x585eb4b1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x507aaa2a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1fc3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x32d': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x8a73': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x8a72': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x8a71': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xe9ac0d6': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x1069': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x7e5': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x53': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x52': '0xca11bde05977b3631167028862be2a173976ca11',\n '0xe298': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1a8': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x94': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2c6': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2803': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2802': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa9': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x28c5f': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x28c60': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x13a': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x4cb2f': '0xdbfa261cd7d17bb40479a0493ad6c0fee435859e',\n '0x7f93': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xb660': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xb02113d3f': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xdad': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xdae': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x15b38': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x15b32': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x45c': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x45b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3d': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x41a6ace': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa729': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1f47b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1b59': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x1b58': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xc3': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x16fd8': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xc7': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x405': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x334': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1ce': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x1cf': '0xca11bde05977b3631167028862be2a173976ca11',\n '0xa70e': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x868b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa0c71fd': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x13e31': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa1337': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1f2b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xf63': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x144': '0xF9cda624FBC7e059355ce98a31693d299FACd963',\n '0x118': '0xF9cda624FBC7e059355ce98a31693d299FACd963',\n '0x12c': '0xF9cda624FBC7e059355ce98a31693d299FACd963',\n '0x18995f': '0xF9cda624FBC7e059355ce98a31693d299FACd963',\n '0x2b74': '0xF9cda624FBC7e059355ce98a31693d299FACd963',\n '0xfc': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x9da': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x137': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x13ed': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x24b1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xba9302': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x7c8': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x138d5': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x6d': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x343b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x34a1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x3109': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x91b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa96': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x22c3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2be3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xbf03': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1b254': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa7b14': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2276': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1b9e': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x6a63bb8': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x15af3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x15af1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xae3f3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x531': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x28c61': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x28c58': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x1d88': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x5b9b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x4c7e1': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xa53b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1a2b': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x406': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x2cef': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x18b2': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x182a9': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xc4': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xfdd': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xfde': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x99c0a0f': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x22cf': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x310c5': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x46f': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x659': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x139c968f9': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xed88': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0xd036': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1f3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x31bf8c3': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x1cbc67bfdc': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x98967f': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x4f588': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x16db': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x3a': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x59': '0xca11bde05977b3631167028862be2a173976ca11',\n '0x1e0': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x2eb': '0xcA11bde05977b3631167028862bE2a173976CA11',\n '0x221': '0xcA11bde05977b3631167028862bE2a173976CA11',\n} as Record<Hex, Hex>;\n\nconst multicallAbi = [\n {\n name: 'tryAggregate',\n type: 'function',\n stateMutability: 'payable',\n inputs: [\n { name: 'requireSuccess', type: 'bool' },\n {\n name: 'calls',\n type: 'tuple[]',\n components: [\n { name: 'target', type: 'address' },\n { name: 'callData', type: 'bytes' },\n ],\n },\n ],\n outputs: [\n {\n name: 'returnData',\n type: 'tuple[]',\n components: [\n { name: 'success', type: 'bool' },\n { name: 'returnData', type: 'bytes' },\n ],\n },\n ],\n },\n];\n\ntype Call = {\n contract: Contract;\n functionSignature: string;\n arguments: unknown[];\n};\n\nexport type MulticallResult = { success: boolean; value: unknown };\n\nconst multicall = async (\n calls: Call[],\n multicallAddress: Hex,\n provider: Web3Provider,\n maxCallsPerMulticall: number,\n): Promise<MulticallResult[]> => {\n const multicallContract = new Contract(\n multicallAddress,\n multicallAbi,\n provider,\n );\n\n return await reduceInBatchesSerially<Call, MulticallResult[]>({\n values: calls,\n batchSize: maxCallsPerMulticall,\n initialResult: [],\n eachBatch: async (workingResult, batch) => {\n const calldata = batch.map((call) => ({\n target: call.contract.address,\n callData: call.contract.interface.encodeFunctionData(\n call.contract.interface.functions[call.functionSignature],\n call.arguments,\n ),\n }));\n\n const results = await multicallContract.callStatic.tryAggregate(\n false,\n calldata,\n );\n\n return [\n ...workingResult,\n ...results.map(\n (r: { success: boolean; returnData: string }, i: number) => ({\n success: r.success,\n value: r.success\n ? batch[i].contract.interface.decodeFunctionResult(\n batch[i].functionSignature,\n r.returnData,\n )[0]\n : undefined,\n }),\n ),\n ];\n },\n });\n};\n\nconst fallback = async (\n calls: Call[],\n maxCallsParallel: number,\n): Promise<MulticallResult[]> => {\n return await reduceInBatchesSerially<Call, MulticallResult[]>({\n values: calls,\n batchSize: maxCallsParallel,\n initialResult: [],\n eachBatch: async (workingResult, batch) => {\n const results = await Promise.allSettled(\n batch.map((call) =>\n call.contract[call.functionSignature](...call.arguments),\n ),\n );\n return [\n ...workingResult,\n ...results.map((p) => ({\n success: p.status === 'fulfilled',\n value: p.status === 'fulfilled' ? p.value : undefined,\n })),\n ];\n },\n });\n};\n\n/**\n * Executes an array of contract calls. If the chain supports multicalls,\n * the calls will be executed in single RPC requests (up to maxCallsPerMulticall).\n * Otherwise the calls will be executed separately in parallel (up to maxCallsParallel).\n * @param calls - An array of contract calls to execute.\n * @param chainId - The hexadecimal chain id.\n * @param provider - An ethers rpc provider.\n * @param maxCallsPerMulticall - If multicall is supported, the maximum number of calls to exeute in each multicall.\n * @param maxCallsParallel - If multicall is not supported, the maximum number of calls to execute in parallel.\n * @returns An array of results, with a success boolean and value for each call.\n */\nexport const multicallOrFallback = async (\n calls: Call[],\n chainId: Hex,\n provider: Web3Provider,\n maxCallsPerMulticall = 300,\n maxCallsParallel = 20,\n): Promise<MulticallResult[]> => {\n if (calls.length === 0) {\n return [];\n }\n\n const multicallAddress = MULTICALL_CONTRACT_BY_CHAINID[chainId];\n return await (multicallAddress\n ? multicall(calls, multicallAddress, provider, maxCallsPerMulticall)\n : fallback(calls, maxCallsParallel));\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/assets-controllers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "44.0.1",
|
|
4
4
|
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@ethereumjs/util": "^8.1.0",
|
|
51
|
+
"@ethersproject/abi": "^5.7.0",
|
|
51
52
|
"@ethersproject/address": "^5.7.0",
|
|
52
53
|
"@ethersproject/bignumber": "^5.7.0",
|
|
53
54
|
"@ethersproject/contracts": "^5.7.0",
|