@boostxyz/sdk 5.1.1 → 5.2.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/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +108 -108
- package/dist/BoostCore.js.map +1 -1
- package/dist/{Incentive-lNp-ZudZ.cjs → Incentive-BpZePiOD.cjs} +2 -2
- package/dist/Incentive-BpZePiOD.cjs.map +1 -0
- package/dist/{Incentive-DSsxOFKY.js → Incentive-DBZHQ9Np.js} +159 -96
- package/dist/Incentive-DBZHQ9Np.js.map +1 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts +24 -3
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +367 -19
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/BoostCore.ts +11 -1
- package/src/Incentives/ERC20PeggedVariableCriteriaIncentive.test.ts +67 -25
- package/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts +99 -4
- package/dist/Incentive-DSsxOFKY.js.map +0 -1
- package/dist/Incentive-lNp-ZudZ.cjs.map +0 -1
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { waitForTransactionReceipt as u, getChainId as r, getAccount as p, readContract as y } from "@wagmi/core";
|
|
2
|
-
import { slice as x, isHex as c, keccak256 as a, toHex as
|
|
3
|
-
import { NoContractAddressUponReceiptError as
|
|
2
|
+
import { slice as x, isHex as c, keccak256 as a, toHex as f } from "viem";
|
|
3
|
+
import { NoContractAddressUponReceiptError as b, InvalidProtocolChainIdError as o } from "./errors.js";
|
|
4
4
|
const m = {
|
|
5
5
|
abi: {
|
|
6
6
|
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": {
|
|
@@ -837,6 +837,90 @@ const m = {
|
|
|
837
837
|
}
|
|
838
838
|
]
|
|
839
839
|
},
|
|
840
|
+
"0x49c4606c4f7f601127761fb65a512e6bca424f62b165476cf1cfdfa51772a6ab": {
|
|
841
|
+
name: "WowTokenBuy",
|
|
842
|
+
type: "event",
|
|
843
|
+
inputs: [
|
|
844
|
+
{
|
|
845
|
+
type: "address",
|
|
846
|
+
indexed: !0
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
type: "address",
|
|
850
|
+
indexed: !0
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
type: "address",
|
|
854
|
+
indexed: !0
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
type: "uint256"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
type: "uint256"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
type: "uint256"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
type: "uint256"
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
type: "uint256"
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
type: "string"
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
type: "uint256"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
type: "uint8"
|
|
879
|
+
}
|
|
880
|
+
]
|
|
881
|
+
},
|
|
882
|
+
"WowTokenBuy(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)": {
|
|
883
|
+
name: "WowTokenBuy",
|
|
884
|
+
type: "event",
|
|
885
|
+
inputs: [
|
|
886
|
+
{
|
|
887
|
+
type: "address",
|
|
888
|
+
indexed: !0
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
type: "address",
|
|
892
|
+
indexed: !0
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
type: "address",
|
|
896
|
+
indexed: !0
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
type: "uint256"
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
type: "uint256"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
type: "uint256"
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
type: "uint256"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
type: "uint256"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
type: "string"
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
type: "uint256"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
type: "uint8"
|
|
921
|
+
}
|
|
922
|
+
]
|
|
923
|
+
},
|
|
840
924
|
"0xeb3adfe7d8294092cd6b0e7ce95ed01c11d3c5d5d3dc1fecdeb87de43c5e40b2": {
|
|
841
925
|
name: "CoopTokenSell",
|
|
842
926
|
type: "event",
|
|
@@ -921,6 +1005,90 @@ const m = {
|
|
|
921
1005
|
}
|
|
922
1006
|
]
|
|
923
1007
|
},
|
|
1008
|
+
"0x0693c83d190a3d36d2ed6c3ac51b1335d2a3588d96f3f3601c8b1e780d0f952a": {
|
|
1009
|
+
name: "WowTokenSell",
|
|
1010
|
+
type: "event",
|
|
1011
|
+
inputs: [
|
|
1012
|
+
{
|
|
1013
|
+
type: "address",
|
|
1014
|
+
indexed: !0
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
type: "address",
|
|
1018
|
+
indexed: !0
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
type: "address",
|
|
1022
|
+
indexed: !0
|
|
1023
|
+
},
|
|
1024
|
+
{
|
|
1025
|
+
type: "uint256"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
type: "uint256"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
type: "uint256"
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
type: "uint256"
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
type: "uint256"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
type: "string"
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
type: "uint256"
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
type: "uint8"
|
|
1047
|
+
}
|
|
1048
|
+
]
|
|
1049
|
+
},
|
|
1050
|
+
"WowTokenSell(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)": {
|
|
1051
|
+
name: "WowTokenSell",
|
|
1052
|
+
type: "event",
|
|
1053
|
+
inputs: [
|
|
1054
|
+
{
|
|
1055
|
+
type: "address",
|
|
1056
|
+
indexed: !0
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
type: "address",
|
|
1060
|
+
indexed: !0
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
type: "address",
|
|
1064
|
+
indexed: !0
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
type: "uint256"
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
type: "uint256"
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
type: "uint256"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
type: "uint256"
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
type: "uint256"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
type: "string"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
type: "uint256"
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
type: "uint8"
|
|
1089
|
+
}
|
|
1090
|
+
]
|
|
1091
|
+
},
|
|
924
1092
|
"0xd5468362e31bdcdc9884e72dcf3b00f9d46086067621224b7cb759308d597c6c": {
|
|
925
1093
|
name: "CoopTokenFees",
|
|
926
1094
|
type: "event",
|
|
@@ -987,6 +1155,176 @@ const m = {
|
|
|
987
1155
|
}
|
|
988
1156
|
]
|
|
989
1157
|
},
|
|
1158
|
+
"0xf349fe0373a901f0506d5343f4a872f385a7f0c26371d7b9e6bf5584b69d75fc": {
|
|
1159
|
+
name: "WowTokenFees",
|
|
1160
|
+
type: "event",
|
|
1161
|
+
inputs: [
|
|
1162
|
+
{
|
|
1163
|
+
type: "address",
|
|
1164
|
+
indexed: !0
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
type: "address",
|
|
1168
|
+
indexed: !0
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
type: "address",
|
|
1172
|
+
indexed: !0
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
type: "address"
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
type: "uint256"
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
type: "uint256"
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
type: "uint256"
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
type: "uint256"
|
|
1188
|
+
}
|
|
1189
|
+
]
|
|
1190
|
+
},
|
|
1191
|
+
"WowTokenFees(address indexed,address indexed,address indexed,address,uint256,uint256,uint256,uint256)": {
|
|
1192
|
+
name: "WowTokenFees",
|
|
1193
|
+
type: "event",
|
|
1194
|
+
inputs: [
|
|
1195
|
+
{
|
|
1196
|
+
type: "address",
|
|
1197
|
+
indexed: !0
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
type: "address",
|
|
1201
|
+
indexed: !0
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
type: "address",
|
|
1205
|
+
indexed: !0
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
type: "address"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
type: "uint256"
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
type: "uint256"
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
type: "uint256"
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
type: "uint256"
|
|
1221
|
+
}
|
|
1222
|
+
]
|
|
1223
|
+
},
|
|
1224
|
+
"0x3be2a577c218a9e2fca79115ab0381630afc182ee832bcad4011c37d323b4843": {
|
|
1225
|
+
name: "CoopTokenTransfer",
|
|
1226
|
+
type: "event",
|
|
1227
|
+
inputs: [
|
|
1228
|
+
{
|
|
1229
|
+
type: "address",
|
|
1230
|
+
indexed: !0
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
type: "address",
|
|
1234
|
+
indexed: !0
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
type: "uint256"
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
type: "uint256"
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
type: "uint256"
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
type: "uint256"
|
|
1247
|
+
}
|
|
1248
|
+
]
|
|
1249
|
+
},
|
|
1250
|
+
"CoopTokenTransfer(address indexed,address indexed,uint256,uint256,uint256,uint256)": {
|
|
1251
|
+
name: "CoopTokenTransfer",
|
|
1252
|
+
type: "event",
|
|
1253
|
+
inputs: [
|
|
1254
|
+
{
|
|
1255
|
+
type: "address",
|
|
1256
|
+
indexed: !0
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
type: "address",
|
|
1260
|
+
indexed: !0
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
type: "uint256"
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
type: "uint256"
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
type: "uint256"
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
type: "uint256"
|
|
1273
|
+
}
|
|
1274
|
+
]
|
|
1275
|
+
},
|
|
1276
|
+
"0xd19736ba1cd2ffc8c99f90d6c6163e59274d333c89e471cd6668d93849835ac5": {
|
|
1277
|
+
name: "WowTokenTransfer",
|
|
1278
|
+
type: "event",
|
|
1279
|
+
inputs: [
|
|
1280
|
+
{
|
|
1281
|
+
type: "address",
|
|
1282
|
+
indexed: !0
|
|
1283
|
+
},
|
|
1284
|
+
{
|
|
1285
|
+
type: "address",
|
|
1286
|
+
indexed: !0
|
|
1287
|
+
},
|
|
1288
|
+
{
|
|
1289
|
+
type: "uint256"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
type: "uint256"
|
|
1293
|
+
},
|
|
1294
|
+
{
|
|
1295
|
+
type: "uint256"
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
type: "uint256"
|
|
1299
|
+
}
|
|
1300
|
+
]
|
|
1301
|
+
},
|
|
1302
|
+
"WowTokenTransfer(address indexed,address indexed,uint256,uint256,uint256,uint256)": {
|
|
1303
|
+
name: "WowTokenTransfer",
|
|
1304
|
+
type: "event",
|
|
1305
|
+
inputs: [
|
|
1306
|
+
{
|
|
1307
|
+
type: "address",
|
|
1308
|
+
indexed: !0
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
type: "address",
|
|
1312
|
+
indexed: !0
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
type: "uint256"
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
type: "uint256"
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
type: "uint256"
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
type: "uint256"
|
|
1325
|
+
}
|
|
1326
|
+
]
|
|
1327
|
+
},
|
|
990
1328
|
"0x883a883a9ea847654d33471b1e5fb2dea76a2cfc86a6cc7da6c14102800e4d0b": {
|
|
991
1329
|
name: "InfoIndexed",
|
|
992
1330
|
type: "event",
|
|
@@ -1069,38 +1407,48 @@ const m = {
|
|
|
1069
1407
|
"0x72d6b4b5ad0fb12b8a7bb3bcb60edd774c096403d611437859c156ecb3c03a36": "SecondaryBuy(address indexed,address indexed,address indexed,uint256,uint256)",
|
|
1070
1408
|
"CoopTokenBuy(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)": "0x6779abc30cb1bfb05c1170de8e2ef5828c19a2590043d2fd9579d945929fd8a4",
|
|
1071
1409
|
"0x6779abc30cb1bfb05c1170de8e2ef5828c19a2590043d2fd9579d945929fd8a4": "CoopTokenBuy(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)",
|
|
1410
|
+
"WowTokenBuy(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)": "0x49c4606c4f7f601127761fb65a512e6bca424f62b165476cf1cfdfa51772a6ab",
|
|
1411
|
+
"0x49c4606c4f7f601127761fb65a512e6bca424f62b165476cf1cfdfa51772a6ab": "WowTokenBuy(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)",
|
|
1072
1412
|
"CoopTokenSell(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)": "0xeb3adfe7d8294092cd6b0e7ce95ed01c11d3c5d5d3dc1fecdeb87de43c5e40b2",
|
|
1073
1413
|
"0xeb3adfe7d8294092cd6b0e7ce95ed01c11d3c5d5d3dc1fecdeb87de43c5e40b2": "CoopTokenSell(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)",
|
|
1414
|
+
"WowTokenSell(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)": "0x0693c83d190a3d36d2ed6c3ac51b1335d2a3588d96f3f3601c8b1e780d0f952a",
|
|
1415
|
+
"0x0693c83d190a3d36d2ed6c3ac51b1335d2a3588d96f3f3601c8b1e780d0f952a": "WowTokenSell(address indexed,address indexed,address indexed,uint256,uint256,uint256,uint256,uint256,string,uint256,uint8)",
|
|
1074
1416
|
"CoopTokenFees(address indexed,address indexed,address indexed,address,uint256,uint256,uint256,uint256)": "0xd5468362e31bdcdc9884e72dcf3b00f9d46086067621224b7cb759308d597c6c",
|
|
1075
1417
|
"0xd5468362e31bdcdc9884e72dcf3b00f9d46086067621224b7cb759308d597c6c": "CoopTokenFees(address indexed,address indexed,address indexed,address,uint256,uint256,uint256,uint256)",
|
|
1418
|
+
"WowTokenFees(address indexed,address indexed,address indexed,address,uint256,uint256,uint256,uint256)": "0xf349fe0373a901f0506d5343f4a872f385a7f0c26371d7b9e6bf5584b69d75fc",
|
|
1419
|
+
"0xf349fe0373a901f0506d5343f4a872f385a7f0c26371d7b9e6bf5584b69d75fc": "WowTokenFees(address indexed,address indexed,address indexed,address,uint256,uint256,uint256,uint256)",
|
|
1420
|
+
"CoopTokenTransfer(address indexed,address indexed,uint256,uint256,uint256,uint256)": "0x3be2a577c218a9e2fca79115ab0381630afc182ee832bcad4011c37d323b4843",
|
|
1421
|
+
"0x3be2a577c218a9e2fca79115ab0381630afc182ee832bcad4011c37d323b4843": "CoopTokenTransfer(address indexed,address indexed,uint256,uint256,uint256,uint256)",
|
|
1422
|
+
"WowTokenTransfer(address indexed,address indexed,uint256,uint256,uint256,uint256)": "0xd19736ba1cd2ffc8c99f90d6c6163e59274d333c89e471cd6668d93849835ac5",
|
|
1423
|
+
"0xd19736ba1cd2ffc8c99f90d6c6163e59274d333c89e471cd6668d93849835ac5": "WowTokenTransfer(address indexed,address indexed,uint256,uint256,uint256,uint256)",
|
|
1076
1424
|
"InfoIndexed(address indexed,string indexed)": "0x883a883a9ea847654d33471b1e5fb2dea76a2cfc86a6cc7da6c14102800e4d0b",
|
|
1077
1425
|
"0x883a883a9ea847654d33471b1e5fb2dea76a2cfc86a6cc7da6c14102800e4d0b": "InfoIndexed(address indexed,string indexed)",
|
|
1078
1426
|
"Info(address,string)": "0xe46343e36b0721f173bdc76b8f25c08b04f417df09c27e1e83ba1980007fef8c",
|
|
1079
1427
|
"0xe46343e36b0721f173bdc76b8f25c08b04f417df09c27e1e83ba1980007fef8c": "Info(address,string)"
|
|
1080
1428
|
}
|
|
1081
1429
|
};
|
|
1082
|
-
var
|
|
1083
|
-
const
|
|
1084
|
-
function
|
|
1085
|
-
return x(c(e) ? a(e) : a(
|
|
1430
|
+
var T = /* @__PURE__ */ ((e) => (e[e.ACTION = 0] = "ACTION", e[e.ALLOW_LIST = 1] = "ALLOW_LIST", e[e.BUDGET = 2] = "BUDGET", e[e.INCENTIVE = 3] = "INCENTIVE", e[e.VALIDATOR = 4] = "VALIDATOR", e))(T || {}), g = /* @__PURE__ */ ((e) => (e[e.ANY_ACTION_PARAM = 255] = "ANY_ACTION_PARAM", e[e.TX_SENDER_CLAIMANT = 255] = "TX_SENDER_CLAIMANT", e[e.GAS_REBATE_INCENTIVE = 255] = "GAS_REBATE_INCENTIVE", e))(g || {});
|
|
1431
|
+
const k = m.selectors["Transfer(address indexed,address indexed,uint256 indexed)"];
|
|
1432
|
+
function C(e) {
|
|
1433
|
+
return x(c(e) ? a(e) : a(f(e)), 0, 4);
|
|
1086
1434
|
}
|
|
1087
|
-
async function
|
|
1435
|
+
async function S(e, t, n) {
|
|
1088
1436
|
const d = await u(e, {
|
|
1089
1437
|
...n,
|
|
1090
1438
|
hash: await t
|
|
1091
1439
|
});
|
|
1092
1440
|
if (!d.contractAddress)
|
|
1093
|
-
throw new
|
|
1441
|
+
throw new b(d);
|
|
1094
1442
|
return d.contractAddress;
|
|
1095
1443
|
}
|
|
1096
|
-
async function
|
|
1444
|
+
async function I(e, t, n) {
|
|
1097
1445
|
const { hash: d, result: i } = await t;
|
|
1098
1446
|
return await u(e, {
|
|
1099
1447
|
...n,
|
|
1100
1448
|
hash: d
|
|
1101
1449
|
}), i;
|
|
1102
1450
|
}
|
|
1103
|
-
function
|
|
1451
|
+
function N(e, t, n) {
|
|
1104
1452
|
let d;
|
|
1105
1453
|
const i = r(e);
|
|
1106
1454
|
if (i && t[i] && (d = i), n !== void 0 ? t[n] && (d = n) : i !== void 0 && t[i] && (d = i), d === void 0) {
|
|
@@ -1114,7 +1462,7 @@ function w(e, t, n) {
|
|
|
1114
1462
|
);
|
|
1115
1463
|
return { chainId: d, address: t[d] };
|
|
1116
1464
|
}
|
|
1117
|
-
async function
|
|
1465
|
+
async function A(e, t, n, d) {
|
|
1118
1466
|
return await y(e, {
|
|
1119
1467
|
...d,
|
|
1120
1468
|
functionName: "balanceOf",
|
|
@@ -1143,13 +1491,13 @@ async function E(e, t, n, d) {
|
|
|
1143
1491
|
});
|
|
1144
1492
|
}
|
|
1145
1493
|
export {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1494
|
+
g as CheatCodes,
|
|
1495
|
+
T as RegistryType,
|
|
1496
|
+
k as TRANSFER_SIGNATURE,
|
|
1497
|
+
N as assertValidAddressByChainId,
|
|
1498
|
+
I as awaitResult,
|
|
1499
|
+
C as bytes4,
|
|
1500
|
+
S as getDeployedContractAddress,
|
|
1501
|
+
A as getErc20Balance
|
|
1154
1502
|
};
|
|
1155
1503
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { events } from '@boostxyz/signatures';\nimport {\n type Config,\n type ReadContractParameters,\n type SimulateContractParameters,\n type WatchContractEventParameters,\n getAccount,\n getChainId,\n readContract,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n Address,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport {\n InvalidProtocolChainIdError,\n NoContractAddressUponReceiptError,\n} from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n\n/**\n * Enum encapsulating all the different cheat codes for criteria modules.\n * An Event Action action step criteria with a `fieldIndex` set to `CheatCodes.ANY_ACTION_PARAM`, fieldType set to `PrimitiveType.BYTES`, and `filterType` set to `FilterType.EQUAL` will always return true when validating the field, regardless of inputs\n * An Event Action `ActionClaimant` with a `fieldIndex` set to `CheatCodes.TX_SENDER_CLAIMANT`, will always validate with the sender of a given transaction.\n *\n *\n * @export\n * @enum {number}\n */\nexport enum CheatCodes {\n /* An Event Action action step criteria with a `fieldIndex` set to `CheatCodes.ANY_ACTION_PARAM`, fieldType set to `PrimitiveType.BYTES`, and `filterType` set to `FilterType.EQUAL` will always return true when validating the field, regardless of inputs */\n ANY_ACTION_PARAM = 255,\n /* An Event Action `ActionClaimant` with a `fieldIndex` set to `CheatCodes.TX_SENDER_CLAIMANT`, will always validate with the sender of a given transaction. */\n TX_SENDER_CLAIMANT = 255,\n /* For use with `ERC20VariableCriteriaIncentive`, if the criteria's `fieldIndex` is set to `CheatCodes.GAS_REBATE_INCENTIVE`, will claim an incentive amount equal to the transaction's gas used. */\n GAS_REBATE_INCENTIVE = 255,\n}\n\n/**\n * The signature for the Transfer event for both ERC20 and ERC721.\n *\n * @type {Hex}\n */\nexport const TRANSFER_SIGNATURE = events.selectors[\n 'Transfer(address indexed,address indexed,uint256 indexed)'\n] as Hex;\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams = Partial<\n Omit<SimulateContractParameters, 'address' | 'args' | 'functionName' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams = Partial<\n Omit<ReadContractParameters, 'address' | 'args' | 'functionName' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {Promise<Address>}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Given a wagmi config and a map of chain id's to addresses, determine an address/chainId combo that maps to the currently connected chain id, or throw a typed error.\n *\n * @export\n * @param {Config} config\n * @param {Record<string, Address>} addressByChainId\n * @param {number} desiredChainId\n * @returns {{ chainId: number, address: Address }}\n * @throws {@link InvalidProtocolChainIdError}\n */\nexport function assertValidAddressByChainId(\n config: Config,\n addressByChainId: Record<number, Address>,\n desiredChainId?: number,\n): { chainId: number; address: Address } {\n let chainId: number | undefined = undefined;\n\n const wagmiChainId = getChainId(config);\n if (wagmiChainId && addressByChainId[wagmiChainId]) chainId = wagmiChainId;\n // if manually providing a chain id for some contract operation, try to use it\n if (desiredChainId !== undefined) {\n if (addressByChainId[desiredChainId]) chainId = desiredChainId;\n } else if (wagmiChainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiChainId]) chainId = wagmiChainId;\n }\n // chainId is still undefined, try to get chain id off viem client\n if (chainId === undefined) {\n const wagmiAccount = getAccount(config);\n if (wagmiAccount.chainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiAccount.chainId])\n chainId = wagmiAccount.chainId;\n }\n }\n // if chainId is STILL undefined, use our default addresses\n // TODO: update this when on prod network\n if (chainId === undefined) chainId = Number(__DEFAULT_CHAIN_ID__);\n if (!addressByChainId[chainId])\n throw new InvalidProtocolChainIdError(\n chainId,\n Object.keys(addressByChainId).map(Number),\n );\n // biome-ignore lint/style/noNonNullAssertion: this type should be narrowed by the above statement but isn't?\n return { chainId, address: addressByChainId[chainId]! };\n}\n\n/**\n * Check an ERC20's balance for a given asset and\n *\n * @public\n * @async\n * @param {Config} [config]\n * @param {Address} [asset]\n * @param {Address} [owner]\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - The erc20 balance\n */\nexport async function getErc20Balance(\n config: Config,\n asset: Address,\n owner: Address,\n params?: ReadParams,\n) {\n return await readContract(config, {\n ...params,\n functionName: 'balanceOf',\n address: asset,\n args: [owner],\n abi: [\n {\n constant: true,\n inputs: [\n {\n name: '_owner',\n type: 'address',\n },\n ],\n name: 'balanceOf',\n outputs: [\n {\n name: 'balance',\n type: 'uint256',\n },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n ],\n });\n}\n"],"names":["RegistryType","CheatCodes","TRANSFER_SIGNATURE","events","bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","assertValidAddressByChainId","addressByChainId","desiredChainId","chainId","wagmiChainId","getChainId","wagmiAccount","getAccount","InvalidProtocolChainIdError","getErc20Balance","asset","owner","params","readContract"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AK;AAAA,MACH;AAAA,QACE,UAAU;AAAA,QACV,QAAQ;AAAA,UACN;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,UACR;AAAA,QACF;AAAA,QACA,MAAM;AAAA,QACN,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,UACR;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,QACjB,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EAAA,CACD;AACH;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { events } from '@boostxyz/signatures';\nimport {\n type Config,\n type ReadContractParameters,\n type SimulateContractParameters,\n type WatchContractEventParameters,\n getAccount,\n getChainId,\n readContract,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n Address,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport {\n InvalidProtocolChainIdError,\n NoContractAddressUponReceiptError,\n} from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n\n/**\n * Enum encapsulating all the different cheat codes for criteria modules.\n * An Event Action action step criteria with a `fieldIndex` set to `CheatCodes.ANY_ACTION_PARAM`, fieldType set to `PrimitiveType.BYTES`, and `filterType` set to `FilterType.EQUAL` will always return true when validating the field, regardless of inputs\n * An Event Action `ActionClaimant` with a `fieldIndex` set to `CheatCodes.TX_SENDER_CLAIMANT`, will always validate with the sender of a given transaction.\n *\n *\n * @export\n * @enum {number}\n */\nexport enum CheatCodes {\n /* An Event Action action step criteria with a `fieldIndex` set to `CheatCodes.ANY_ACTION_PARAM`, fieldType set to `PrimitiveType.BYTES`, and `filterType` set to `FilterType.EQUAL` will always return true when validating the field, regardless of inputs */\n ANY_ACTION_PARAM = 255,\n /* An Event Action `ActionClaimant` with a `fieldIndex` set to `CheatCodes.TX_SENDER_CLAIMANT`, will always validate with the sender of a given transaction. */\n TX_SENDER_CLAIMANT = 255,\n /* For use with `ERC20VariableCriteriaIncentive`, if the criteria's `fieldIndex` is set to `CheatCodes.GAS_REBATE_INCENTIVE`, will claim an incentive amount equal to the transaction's gas used. */\n GAS_REBATE_INCENTIVE = 255,\n}\n\n/**\n * The signature for the Transfer event for both ERC20 and ERC721.\n *\n * @type {Hex}\n */\nexport const TRANSFER_SIGNATURE = events.selectors[\n 'Transfer(address indexed,address indexed,uint256 indexed)'\n] as Hex;\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams = Partial<\n Omit<SimulateContractParameters, 'address' | 'args' | 'functionName' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams = Partial<\n Omit<ReadContractParameters, 'address' | 'args' | 'functionName' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {Promise<Address>}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Given a wagmi config and a map of chain id's to addresses, determine an address/chainId combo that maps to the currently connected chain id, or throw a typed error.\n *\n * @export\n * @param {Config} config\n * @param {Record<string, Address>} addressByChainId\n * @param {number} desiredChainId\n * @returns {{ chainId: number, address: Address }}\n * @throws {@link InvalidProtocolChainIdError}\n */\nexport function assertValidAddressByChainId(\n config: Config,\n addressByChainId: Record<number, Address>,\n desiredChainId?: number,\n): { chainId: number; address: Address } {\n let chainId: number | undefined = undefined;\n\n const wagmiChainId = getChainId(config);\n if (wagmiChainId && addressByChainId[wagmiChainId]) chainId = wagmiChainId;\n // if manually providing a chain id for some contract operation, try to use it\n if (desiredChainId !== undefined) {\n if (addressByChainId[desiredChainId]) chainId = desiredChainId;\n } else if (wagmiChainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiChainId]) chainId = wagmiChainId;\n }\n // chainId is still undefined, try to get chain id off viem client\n if (chainId === undefined) {\n const wagmiAccount = getAccount(config);\n if (wagmiAccount.chainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiAccount.chainId])\n chainId = wagmiAccount.chainId;\n }\n }\n // if chainId is STILL undefined, use our default addresses\n // TODO: update this when on prod network\n if (chainId === undefined) chainId = Number(__DEFAULT_CHAIN_ID__);\n if (!addressByChainId[chainId])\n throw new InvalidProtocolChainIdError(\n chainId,\n Object.keys(addressByChainId).map(Number),\n );\n // biome-ignore lint/style/noNonNullAssertion: this type should be narrowed by the above statement but isn't?\n return { chainId, address: addressByChainId[chainId]! };\n}\n\n/**\n * Check an ERC20's balance for a given asset and\n *\n * @public\n * @async\n * @param {Config} [config]\n * @param {Address} [asset]\n * @param {Address} [owner]\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - The erc20 balance\n */\nexport async function getErc20Balance(\n config: Config,\n asset: Address,\n owner: Address,\n params?: ReadParams,\n) {\n return await readContract(config, {\n ...params,\n functionName: 'balanceOf',\n address: asset,\n args: [owner],\n abi: [\n {\n constant: true,\n inputs: [\n {\n name: '_owner',\n type: 'address',\n },\n ],\n name: 'balanceOf',\n outputs: [\n {\n name: 'balance',\n type: 'uint256',\n },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n ],\n });\n}\n"],"names":["RegistryType","CheatCodes","TRANSFER_SIGNATURE","events","bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","assertValidAddressByChainId","addressByChainId","desiredChainId","chain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ACR;AAAA,QACF;AAAA,QACA,MAAM;AAAA,QACN,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,UACR;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,QACjB,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EAAA,CACD;AACH;"}
|
package/package.json
CHANGED
package/src/BoostCore.ts
CHANGED
|
@@ -1281,6 +1281,13 @@ export class BoostCore extends Deployable<
|
|
|
1281
1281
|
* @returns {ManagedBudget}
|
|
1282
1282
|
*/
|
|
1283
1283
|
ManagedBudget(options: DeployablePayloadOrAddress<ManagedBudgetPayload>) {
|
|
1284
|
+
if (
|
|
1285
|
+
typeof options !== 'string' &&
|
|
1286
|
+
!options.authorized.includes(this.assertValidAddress())
|
|
1287
|
+
) {
|
|
1288
|
+
options.authorized = [this.assertValidAddress(), ...options.authorized];
|
|
1289
|
+
options.roles = [Roles.MANAGER, ...options.roles];
|
|
1290
|
+
}
|
|
1284
1291
|
return new ManagedBudget(
|
|
1285
1292
|
{ config: this._config, account: this._account },
|
|
1286
1293
|
options,
|
|
@@ -1301,7 +1308,10 @@ export class BoostCore extends Deployable<
|
|
|
1301
1308
|
ManagedBudgetWithFees(
|
|
1302
1309
|
options: DeployablePayloadOrAddress<ManagedBudgetWithFeesPayload>,
|
|
1303
1310
|
) {
|
|
1304
|
-
if (
|
|
1311
|
+
if (
|
|
1312
|
+
typeof options !== 'string' &&
|
|
1313
|
+
!options.authorized.includes(this.assertValidAddress())
|
|
1314
|
+
) {
|
|
1305
1315
|
options.authorized = [this.assertValidAddress(), ...options.authorized];
|
|
1306
1316
|
options.roles = [Roles.MANAGER, ...options.roles];
|
|
1307
1317
|
}
|