@latticexyz/common 2.2.21-f4db683f90214b03bb8d68635a3825cc9bf58263 → 2.2.22-01a4d064e5fd8e579d54bb3aa8997f225c6960d3
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/chains.d.ts +294 -1
- package/dist/chains.js +41 -0
- package/dist/chains.js.map +1 -1
- package/dist/{chunk-NFWCLD5I.js → chunk-ETXWXV5T.js} +14 -1
- package/dist/chunk-ETXWXV5T.js.map +1 -0
- package/dist/codegen.d.ts +12 -9
- package/dist/codegen.js +84 -46
- package/dist/codegen.js.map +1 -1
- package/dist/internal.d.ts +8 -1
- package/dist/internal.js +429 -2
- package/dist/internal.js.map +1 -1
- package/dist/utils.js +2 -4
- package/package.json +2 -2
- package/dist/chunk-CHXZROA7.js +0 -16
- package/dist/chunk-CHXZROA7.js.map +0 -1
- package/dist/chunk-NFWCLD5I.js.map +0 -1
package/dist/chains.d.ts
CHANGED
|
@@ -970,4 +970,297 @@ declare const rhodolite: {
|
|
|
970
970
|
};
|
|
971
971
|
};
|
|
972
972
|
|
|
973
|
-
|
|
973
|
+
declare const pyrope: {
|
|
974
|
+
readonly name: "Pyrope Testnet";
|
|
975
|
+
readonly testnet: true;
|
|
976
|
+
readonly id: 695569;
|
|
977
|
+
readonly sourceId: 11155111;
|
|
978
|
+
readonly nativeCurrency: {
|
|
979
|
+
readonly name: "Ether";
|
|
980
|
+
readonly symbol: "ETH";
|
|
981
|
+
readonly decimals: 18;
|
|
982
|
+
};
|
|
983
|
+
readonly rpcUrls: {
|
|
984
|
+
readonly default: {
|
|
985
|
+
readonly http: readonly ["https://rpc.pyropechain.com"];
|
|
986
|
+
readonly webSocket: readonly ["wss://rpc.pyropechain.com"];
|
|
987
|
+
};
|
|
988
|
+
readonly bundler: {
|
|
989
|
+
readonly http: readonly ["https://rpc.pyropechain.com"];
|
|
990
|
+
readonly webSocket: readonly ["wss://rpc.pyropechain.com"];
|
|
991
|
+
};
|
|
992
|
+
};
|
|
993
|
+
readonly contracts: {
|
|
994
|
+
readonly l1StandardBridge: {
|
|
995
|
+
readonly 11155111: {
|
|
996
|
+
readonly address: "0xC24932c31D9621aE9e792576152B7ef010cFC2F8";
|
|
997
|
+
};
|
|
998
|
+
};
|
|
999
|
+
readonly gasPriceOracle: {
|
|
1000
|
+
readonly address: "0x420000000000000000000000000000000000000F";
|
|
1001
|
+
};
|
|
1002
|
+
readonly l1Block: {
|
|
1003
|
+
readonly address: "0x4200000000000000000000000000000000000015";
|
|
1004
|
+
};
|
|
1005
|
+
readonly l2CrossDomainMessenger: {
|
|
1006
|
+
readonly address: "0x4200000000000000000000000000000000000007";
|
|
1007
|
+
};
|
|
1008
|
+
readonly l2Erc721Bridge: {
|
|
1009
|
+
readonly address: "0x4200000000000000000000000000000000000014";
|
|
1010
|
+
};
|
|
1011
|
+
readonly l2StandardBridge: {
|
|
1012
|
+
readonly address: "0x4200000000000000000000000000000000000010";
|
|
1013
|
+
};
|
|
1014
|
+
readonly l2ToL1MessagePasser: {
|
|
1015
|
+
readonly address: "0x4200000000000000000000000000000000000016";
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
readonly blockExplorers: {
|
|
1019
|
+
readonly default: {
|
|
1020
|
+
readonly name: "Blockscout";
|
|
1021
|
+
readonly url: "https://explorer.pyropechain.com";
|
|
1022
|
+
};
|
|
1023
|
+
readonly worldsExplorer: {
|
|
1024
|
+
readonly name: "MUD Worlds Explorer";
|
|
1025
|
+
readonly url: "https://explorer.mud.dev/pyrope/worlds";
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
readonly iconUrls: readonly ["https://lattice.xyz/brand/color/pyrope.svg"];
|
|
1029
|
+
readonly indexerUrl: "https://indexer.mud.pyropechain.com";
|
|
1030
|
+
readonly formatters: {
|
|
1031
|
+
readonly block: {
|
|
1032
|
+
exclude: [] | undefined;
|
|
1033
|
+
format: (args: viem_op_stack.OpStackRpcBlock<viem.BlockTag, boolean>) => {
|
|
1034
|
+
baseFeePerGas: bigint | null;
|
|
1035
|
+
blobGasUsed: bigint;
|
|
1036
|
+
difficulty: bigint;
|
|
1037
|
+
excessBlobGas: bigint;
|
|
1038
|
+
extraData: `0x${string}`;
|
|
1039
|
+
gasLimit: bigint;
|
|
1040
|
+
gasUsed: bigint;
|
|
1041
|
+
hash: `0x${string}` | null;
|
|
1042
|
+
logsBloom: `0x${string}` | null;
|
|
1043
|
+
miner: `0x${string}`;
|
|
1044
|
+
mixHash: `0x${string}`;
|
|
1045
|
+
nonce: `0x${string}` | null;
|
|
1046
|
+
number: bigint | null;
|
|
1047
|
+
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
1048
|
+
parentHash: `0x${string}`;
|
|
1049
|
+
receiptsRoot: `0x${string}`;
|
|
1050
|
+
sealFields: `0x${string}`[];
|
|
1051
|
+
sha3Uncles: `0x${string}`;
|
|
1052
|
+
size: bigint;
|
|
1053
|
+
stateRoot: `0x${string}`;
|
|
1054
|
+
timestamp: bigint;
|
|
1055
|
+
totalDifficulty: bigint | null;
|
|
1056
|
+
transactions: `0x${string}`[] | viem_op_stack.OpStackTransaction<boolean>[];
|
|
1057
|
+
transactionsRoot: `0x${string}`;
|
|
1058
|
+
uncles: `0x${string}`[];
|
|
1059
|
+
withdrawals?: viem.Withdrawal[] | undefined;
|
|
1060
|
+
withdrawalsRoot?: `0x${string}` | undefined;
|
|
1061
|
+
};
|
|
1062
|
+
type: "block";
|
|
1063
|
+
};
|
|
1064
|
+
readonly transaction: {
|
|
1065
|
+
exclude: [] | undefined;
|
|
1066
|
+
format: (args: viem_op_stack.OpStackRpcTransaction<boolean>) => {
|
|
1067
|
+
blockHash: `0x${string}` | null;
|
|
1068
|
+
blockNumber: bigint | null;
|
|
1069
|
+
from: `0x${string}`;
|
|
1070
|
+
gas: bigint;
|
|
1071
|
+
hash: `0x${string}`;
|
|
1072
|
+
input: `0x${string}`;
|
|
1073
|
+
nonce: number;
|
|
1074
|
+
r: `0x${string}`;
|
|
1075
|
+
s: `0x${string}`;
|
|
1076
|
+
to: `0x${string}` | null;
|
|
1077
|
+
transactionIndex: number | null;
|
|
1078
|
+
typeHex: `0x${string}` | null;
|
|
1079
|
+
v: bigint;
|
|
1080
|
+
value: bigint;
|
|
1081
|
+
yParity: number;
|
|
1082
|
+
gasPrice?: undefined;
|
|
1083
|
+
maxFeePerBlobGas?: undefined;
|
|
1084
|
+
maxFeePerGas: bigint;
|
|
1085
|
+
maxPriorityFeePerGas: bigint;
|
|
1086
|
+
isSystemTx?: boolean | undefined;
|
|
1087
|
+
mint?: bigint | undefined;
|
|
1088
|
+
sourceHash: `0x${string}`;
|
|
1089
|
+
type: "deposit";
|
|
1090
|
+
} | {
|
|
1091
|
+
r: `0x${string}`;
|
|
1092
|
+
s: `0x${string}`;
|
|
1093
|
+
v: bigint;
|
|
1094
|
+
to: `0x${string}` | null;
|
|
1095
|
+
from: `0x${string}`;
|
|
1096
|
+
gas: bigint;
|
|
1097
|
+
nonce: number;
|
|
1098
|
+
value: bigint;
|
|
1099
|
+
blockHash: `0x${string}` | null;
|
|
1100
|
+
blockNumber: bigint | null;
|
|
1101
|
+
hash: `0x${string}`;
|
|
1102
|
+
input: `0x${string}`;
|
|
1103
|
+
transactionIndex: number | null;
|
|
1104
|
+
typeHex: `0x${string}` | null;
|
|
1105
|
+
accessList?: undefined;
|
|
1106
|
+
authorizationList?: undefined;
|
|
1107
|
+
blobVersionedHashes?: undefined;
|
|
1108
|
+
chainId?: number | undefined;
|
|
1109
|
+
yParity?: undefined;
|
|
1110
|
+
type: "legacy";
|
|
1111
|
+
gasPrice: bigint;
|
|
1112
|
+
maxFeePerBlobGas?: undefined;
|
|
1113
|
+
maxFeePerGas?: undefined;
|
|
1114
|
+
maxPriorityFeePerGas?: undefined;
|
|
1115
|
+
isSystemTx?: undefined;
|
|
1116
|
+
mint?: undefined;
|
|
1117
|
+
sourceHash?: undefined;
|
|
1118
|
+
} | {
|
|
1119
|
+
blockHash: `0x${string}` | null;
|
|
1120
|
+
blockNumber: bigint | null;
|
|
1121
|
+
from: `0x${string}`;
|
|
1122
|
+
gas: bigint;
|
|
1123
|
+
hash: `0x${string}`;
|
|
1124
|
+
input: `0x${string}`;
|
|
1125
|
+
nonce: number;
|
|
1126
|
+
r: `0x${string}`;
|
|
1127
|
+
s: `0x${string}`;
|
|
1128
|
+
to: `0x${string}` | null;
|
|
1129
|
+
transactionIndex: number | null;
|
|
1130
|
+
typeHex: `0x${string}` | null;
|
|
1131
|
+
v: bigint;
|
|
1132
|
+
value: bigint;
|
|
1133
|
+
yParity: number;
|
|
1134
|
+
accessList: viem.AccessList;
|
|
1135
|
+
authorizationList?: undefined;
|
|
1136
|
+
blobVersionedHashes?: undefined;
|
|
1137
|
+
chainId: number;
|
|
1138
|
+
type: "eip2930";
|
|
1139
|
+
gasPrice: bigint;
|
|
1140
|
+
maxFeePerBlobGas?: undefined;
|
|
1141
|
+
maxFeePerGas?: undefined;
|
|
1142
|
+
maxPriorityFeePerGas?: undefined;
|
|
1143
|
+
isSystemTx?: undefined;
|
|
1144
|
+
mint?: undefined;
|
|
1145
|
+
sourceHash?: undefined;
|
|
1146
|
+
} | {
|
|
1147
|
+
blockHash: `0x${string}` | null;
|
|
1148
|
+
blockNumber: bigint | null;
|
|
1149
|
+
from: `0x${string}`;
|
|
1150
|
+
gas: bigint;
|
|
1151
|
+
hash: `0x${string}`;
|
|
1152
|
+
input: `0x${string}`;
|
|
1153
|
+
nonce: number;
|
|
1154
|
+
r: `0x${string}`;
|
|
1155
|
+
s: `0x${string}`;
|
|
1156
|
+
to: `0x${string}` | null;
|
|
1157
|
+
transactionIndex: number | null;
|
|
1158
|
+
typeHex: `0x${string}` | null;
|
|
1159
|
+
v: bigint;
|
|
1160
|
+
value: bigint;
|
|
1161
|
+
yParity: number;
|
|
1162
|
+
accessList: viem.AccessList;
|
|
1163
|
+
authorizationList?: undefined;
|
|
1164
|
+
blobVersionedHashes?: undefined;
|
|
1165
|
+
chainId: number;
|
|
1166
|
+
type: "eip1559";
|
|
1167
|
+
gasPrice?: undefined;
|
|
1168
|
+
maxFeePerBlobGas?: undefined;
|
|
1169
|
+
maxFeePerGas: bigint;
|
|
1170
|
+
maxPriorityFeePerGas: bigint;
|
|
1171
|
+
isSystemTx?: undefined;
|
|
1172
|
+
mint?: undefined;
|
|
1173
|
+
sourceHash?: undefined;
|
|
1174
|
+
} | {
|
|
1175
|
+
blockHash: `0x${string}` | null;
|
|
1176
|
+
blockNumber: bigint | null;
|
|
1177
|
+
from: `0x${string}`;
|
|
1178
|
+
gas: bigint;
|
|
1179
|
+
hash: `0x${string}`;
|
|
1180
|
+
input: `0x${string}`;
|
|
1181
|
+
nonce: number;
|
|
1182
|
+
r: `0x${string}`;
|
|
1183
|
+
s: `0x${string}`;
|
|
1184
|
+
to: `0x${string}` | null;
|
|
1185
|
+
transactionIndex: number | null;
|
|
1186
|
+
typeHex: `0x${string}` | null;
|
|
1187
|
+
v: bigint;
|
|
1188
|
+
value: bigint;
|
|
1189
|
+
yParity: number;
|
|
1190
|
+
accessList: viem.AccessList;
|
|
1191
|
+
authorizationList?: undefined;
|
|
1192
|
+
blobVersionedHashes: readonly `0x${string}`[];
|
|
1193
|
+
chainId: number;
|
|
1194
|
+
type: "eip4844";
|
|
1195
|
+
gasPrice?: undefined;
|
|
1196
|
+
maxFeePerBlobGas: bigint;
|
|
1197
|
+
maxFeePerGas: bigint;
|
|
1198
|
+
maxPriorityFeePerGas: bigint;
|
|
1199
|
+
isSystemTx?: undefined;
|
|
1200
|
+
mint?: undefined;
|
|
1201
|
+
sourceHash?: undefined;
|
|
1202
|
+
} | {
|
|
1203
|
+
blockHash: `0x${string}` | null;
|
|
1204
|
+
blockNumber: bigint | null;
|
|
1205
|
+
from: `0x${string}`;
|
|
1206
|
+
gas: bigint;
|
|
1207
|
+
hash: `0x${string}`;
|
|
1208
|
+
input: `0x${string}`;
|
|
1209
|
+
nonce: number;
|
|
1210
|
+
r: `0x${string}`;
|
|
1211
|
+
s: `0x${string}`;
|
|
1212
|
+
to: `0x${string}` | null;
|
|
1213
|
+
transactionIndex: number | null;
|
|
1214
|
+
typeHex: `0x${string}` | null;
|
|
1215
|
+
v: bigint;
|
|
1216
|
+
value: bigint;
|
|
1217
|
+
yParity: number;
|
|
1218
|
+
accessList: viem.AccessList;
|
|
1219
|
+
authorizationList: viem_experimental.SignedAuthorizationList<number>;
|
|
1220
|
+
blobVersionedHashes?: undefined;
|
|
1221
|
+
chainId: number;
|
|
1222
|
+
type: "eip7702";
|
|
1223
|
+
gasPrice?: undefined;
|
|
1224
|
+
maxFeePerBlobGas?: undefined;
|
|
1225
|
+
maxFeePerGas: bigint;
|
|
1226
|
+
maxPriorityFeePerGas: bigint;
|
|
1227
|
+
isSystemTx?: undefined;
|
|
1228
|
+
mint?: undefined;
|
|
1229
|
+
sourceHash?: undefined;
|
|
1230
|
+
};
|
|
1231
|
+
type: "transaction";
|
|
1232
|
+
};
|
|
1233
|
+
readonly transactionReceipt: {
|
|
1234
|
+
exclude: [] | undefined;
|
|
1235
|
+
format: (args: viem_op_stack.OpStackRpcTransactionReceipt) => {
|
|
1236
|
+
blobGasPrice?: bigint | undefined;
|
|
1237
|
+
blobGasUsed?: bigint | undefined;
|
|
1238
|
+
blockHash: `0x${string}`;
|
|
1239
|
+
blockNumber: bigint;
|
|
1240
|
+
contractAddress: `0x${string}` | null | undefined;
|
|
1241
|
+
cumulativeGasUsed: bigint;
|
|
1242
|
+
effectiveGasPrice: bigint;
|
|
1243
|
+
from: `0x${string}`;
|
|
1244
|
+
gasUsed: bigint;
|
|
1245
|
+
logs: viem.Log<bigint, number, false, undefined, undefined, undefined, undefined>[];
|
|
1246
|
+
logsBloom: `0x${string}`;
|
|
1247
|
+
root?: `0x${string}` | undefined;
|
|
1248
|
+
status: "success" | "reverted";
|
|
1249
|
+
to: `0x${string}` | null;
|
|
1250
|
+
transactionHash: `0x${string}`;
|
|
1251
|
+
transactionIndex: number;
|
|
1252
|
+
type: viem.TransactionType;
|
|
1253
|
+
l1GasPrice: bigint | null;
|
|
1254
|
+
l1GasUsed: bigint | null;
|
|
1255
|
+
l1Fee: bigint | null;
|
|
1256
|
+
l1FeeScalar: number | null;
|
|
1257
|
+
};
|
|
1258
|
+
type: "transactionReceipt";
|
|
1259
|
+
};
|
|
1260
|
+
};
|
|
1261
|
+
readonly serializers: {
|
|
1262
|
+
readonly transaction: typeof viem_op_stack.serializeTransaction;
|
|
1263
|
+
};
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
export { type MUDChain, garnet, mudFoundry, pyrope, redstone, rhodolite };
|
package/dist/chains.js
CHANGED
|
@@ -71,9 +71,50 @@ var rhodolite = {
|
|
|
71
71
|
iconUrls: ["https://redstone.xyz/chain-icons/rhodolite.png"],
|
|
72
72
|
indexerUrl: "https://indexer.mud.rhodolitechain.com"
|
|
73
73
|
};
|
|
74
|
+
|
|
75
|
+
// src/chains/pyrope.ts
|
|
76
|
+
import { chainConfig as chainConfig2 } from "viem/op-stack";
|
|
77
|
+
var sourceId2 = 11155111;
|
|
78
|
+
var defaultRpcUrls2 = {
|
|
79
|
+
http: ["https://rpc.pyropechain.com"],
|
|
80
|
+
webSocket: ["wss://rpc.pyropechain.com"]
|
|
81
|
+
};
|
|
82
|
+
var pyrope = {
|
|
83
|
+
...chainConfig2,
|
|
84
|
+
name: "Pyrope Testnet",
|
|
85
|
+
testnet: true,
|
|
86
|
+
id: 695569,
|
|
87
|
+
sourceId: sourceId2,
|
|
88
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
89
|
+
rpcUrls: {
|
|
90
|
+
default: defaultRpcUrls2,
|
|
91
|
+
bundler: defaultRpcUrls2
|
|
92
|
+
},
|
|
93
|
+
contracts: {
|
|
94
|
+
...chainConfig2.contracts,
|
|
95
|
+
l1StandardBridge: {
|
|
96
|
+
[sourceId2]: {
|
|
97
|
+
address: "0xC24932c31D9621aE9e792576152B7ef010cFC2F8"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
blockExplorers: {
|
|
102
|
+
default: {
|
|
103
|
+
name: "Blockscout",
|
|
104
|
+
url: "https://explorer.pyropechain.com"
|
|
105
|
+
},
|
|
106
|
+
worldsExplorer: {
|
|
107
|
+
name: "MUD Worlds Explorer",
|
|
108
|
+
url: "https://explorer.mud.dev/pyrope/worlds"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
iconUrls: ["https://lattice.xyz/brand/color/pyrope.svg"],
|
|
112
|
+
indexerUrl: "https://indexer.mud.pyropechain.com"
|
|
113
|
+
};
|
|
74
114
|
export {
|
|
75
115
|
garnet,
|
|
76
116
|
mudFoundry,
|
|
117
|
+
pyrope,
|
|
77
118
|
redstone,
|
|
78
119
|
rhodolite
|
|
79
120
|
};
|
package/dist/chains.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chains/mudFoundry.ts","../src/chains/redstone.ts","../src/chains/garnet.ts","../src/chains/rhodolite.ts"],"sourcesContent":["import { foundry } from \"viem/chains\";\nimport { MUDChain } from \"./types\";\n\nexport const mudFoundry = {\n ...foundry,\n fees: {\n defaultPriorityFee: 0n,\n },\n} as const satisfies MUDChain;\n","import { redstone as redstoneConfig } from \"viem/chains\";\nimport type { MUDChain } from \"./types\";\n\nexport const redstone = {\n ...redstoneConfig,\n iconUrls: [\"https://redstone.xyz/chain-icons/redstone.png\"],\n indexerUrl: \"https://indexer.mud.redstonechain.com\",\n} as const satisfies MUDChain;\n","import { garnet as garnetConfig } from \"viem/chains\";\nimport type { MUDChain } from \"./types\";\n\nexport const garnet = {\n ...garnetConfig,\n rpcUrls: {\n ...garnetConfig.rpcUrls,\n bundler: garnetConfig.rpcUrls.default,\n },\n iconUrls: [\"https://redstone.xyz/chain-icons/garnet.png\"],\n indexerUrl: \"https://indexer.mud.garnetchain.com\",\n} as const satisfies MUDChain;\n","import { chainConfig } from \"viem/op-stack\";\nimport { MUDChain } from \"./types\";\nimport { Chain } from \"viem\";\n\nconst sourceId = 17000;\n\nconst defaultRpcUrls = {\n http: [\"https://rpc.rhodolitechain.com\"],\n webSocket: [\"wss://rpc.rhodolitechain.com\"],\n} as const satisfies Chain[\"rpcUrls\"][\"default\"];\n\nexport const rhodolite = {\n ...chainConfig,\n name: \"Rhodolite Devnet\",\n testnet: true,\n id: 17420,\n sourceId,\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: defaultRpcUrls,\n bundler: defaultRpcUrls,\n quarryPassIssuer: defaultRpcUrls,\n wiresaw: defaultRpcUrls,\n },\n contracts: {\n ...chainConfig.contracts,\n l1StandardBridge: {\n [sourceId]: {\n address: \"0x6487446e0B9FAEa90F6a9772A6448cFa780E30F9\",\n },\n },\n quarryPaymaster: {\n address: \"0x7ca1b85aca23fccf2fbac14c02b5e8a6432639b9\",\n },\n },\n blockExplorers: {\n default: {\n name: \"Blockscout\",\n url: \"https://explorer.rhodolitechain.com\",\n },\n worldsExplorer: {\n name: \"MUD Worlds Explorer\",\n url: \"https://explorer.mud.dev/rhodolite/worlds\",\n },\n },\n iconUrls: [\"https://redstone.xyz/chain-icons/rhodolite.png\"],\n indexerUrl: \"https://indexer.mud.rhodolitechain.com\",\n} as const satisfies MUDChain;\n"],"mappings":";AAAA,SAAS,eAAe;AAGjB,IAAM,aAAa;AAAA,EACxB,GAAG;AAAA,EACH,MAAM;AAAA,IACJ,oBAAoB;AAAA,EACtB;AACF;;;ACRA,SAAS,YAAY,sBAAsB;AAGpC,IAAM,WAAW;AAAA,EACtB,GAAG;AAAA,EACH,UAAU,CAAC,+CAA+C;AAAA,EAC1D,YAAY;AACd;;;ACPA,SAAS,UAAU,oBAAoB;AAGhC,IAAM,SAAS;AAAA,EACpB,GAAG;AAAA,EACH,SAAS;AAAA,IACP,GAAG,aAAa;AAAA,IAChB,SAAS,aAAa,QAAQ;AAAA,EAChC;AAAA,EACA,UAAU,CAAC,6CAA6C;AAAA,EACxD,YAAY;AACd;;;ACXA,SAAS,mBAAmB;AAI5B,IAAM,WAAW;AAEjB,IAAM,iBAAiB;AAAA,EACrB,MAAM,CAAC,gCAAgC;AAAA,EACvC,WAAW,CAAC,8BAA8B;AAC5C;AAEO,IAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,MAAM;AAAA,EACN,SAAS;AAAA,EACT,IAAI;AAAA,EACJ;AAAA,EACA,gBAAgB,EAAE,MAAM,SAAS,QAAQ,OAAO,UAAU,GAAG;AAAA,EAC7D,SAAS;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,IACT,kBAAkB;AAAA,IAClB,SAAS;AAAA,EACX;AAAA,EACA,WAAW;AAAA,IACT,GAAG,YAAY;AAAA,IACf,kBAAkB;AAAA,MAChB,CAAC,QAAQ,GAAG;AAAA,QACV,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,MAAM;AAAA,MACN,KAAK;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EACA,UAAU,CAAC,gDAAgD;AAAA,EAC3D,YAAY;AACd;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/chains/mudFoundry.ts","../src/chains/redstone.ts","../src/chains/garnet.ts","../src/chains/rhodolite.ts","../src/chains/pyrope.ts"],"sourcesContent":["import { foundry } from \"viem/chains\";\nimport { MUDChain } from \"./types\";\n\nexport const mudFoundry = {\n ...foundry,\n fees: {\n defaultPriorityFee: 0n,\n },\n} as const satisfies MUDChain;\n","import { redstone as redstoneConfig } from \"viem/chains\";\nimport type { MUDChain } from \"./types\";\n\nexport const redstone = {\n ...redstoneConfig,\n iconUrls: [\"https://redstone.xyz/chain-icons/redstone.png\"],\n indexerUrl: \"https://indexer.mud.redstonechain.com\",\n} as const satisfies MUDChain;\n","import { garnet as garnetConfig } from \"viem/chains\";\nimport type { MUDChain } from \"./types\";\n\nexport const garnet = {\n ...garnetConfig,\n rpcUrls: {\n ...garnetConfig.rpcUrls,\n bundler: garnetConfig.rpcUrls.default,\n },\n iconUrls: [\"https://redstone.xyz/chain-icons/garnet.png\"],\n indexerUrl: \"https://indexer.mud.garnetchain.com\",\n} as const satisfies MUDChain;\n","import { chainConfig } from \"viem/op-stack\";\nimport { MUDChain } from \"./types\";\nimport { Chain } from \"viem\";\n\nconst sourceId = 17000;\n\nconst defaultRpcUrls = {\n http: [\"https://rpc.rhodolitechain.com\"],\n webSocket: [\"wss://rpc.rhodolitechain.com\"],\n} as const satisfies Chain[\"rpcUrls\"][\"default\"];\n\nexport const rhodolite = {\n ...chainConfig,\n name: \"Rhodolite Devnet\",\n testnet: true,\n id: 17420,\n sourceId,\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: defaultRpcUrls,\n bundler: defaultRpcUrls,\n quarryPassIssuer: defaultRpcUrls,\n wiresaw: defaultRpcUrls,\n },\n contracts: {\n ...chainConfig.contracts,\n l1StandardBridge: {\n [sourceId]: {\n address: \"0x6487446e0B9FAEa90F6a9772A6448cFa780E30F9\",\n },\n },\n quarryPaymaster: {\n address: \"0x7ca1b85aca23fccf2fbac14c02b5e8a6432639b9\",\n },\n },\n blockExplorers: {\n default: {\n name: \"Blockscout\",\n url: \"https://explorer.rhodolitechain.com\",\n },\n worldsExplorer: {\n name: \"MUD Worlds Explorer\",\n url: \"https://explorer.mud.dev/rhodolite/worlds\",\n },\n },\n iconUrls: [\"https://redstone.xyz/chain-icons/rhodolite.png\"],\n indexerUrl: \"https://indexer.mud.rhodolitechain.com\",\n} as const satisfies MUDChain;\n","import { chainConfig } from \"viem/op-stack\";\nimport { MUDChain } from \"./types\";\nimport { Chain } from \"viem\";\n\nconst sourceId = 11155111;\n\nconst defaultRpcUrls = {\n http: [\"https://rpc.pyropechain.com\"],\n webSocket: [\"wss://rpc.pyropechain.com\"],\n} as const satisfies Chain[\"rpcUrls\"][\"default\"];\n\nexport const pyrope = {\n ...chainConfig,\n name: \"Pyrope Testnet\",\n testnet: true,\n id: 695569,\n sourceId,\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: defaultRpcUrls,\n bundler: defaultRpcUrls,\n },\n contracts: {\n ...chainConfig.contracts,\n l1StandardBridge: {\n [sourceId]: {\n address: \"0xC24932c31D9621aE9e792576152B7ef010cFC2F8\",\n },\n },\n },\n blockExplorers: {\n default: {\n name: \"Blockscout\",\n url: \"https://explorer.pyropechain.com\",\n },\n worldsExplorer: {\n name: \"MUD Worlds Explorer\",\n url: \"https://explorer.mud.dev/pyrope/worlds\",\n },\n },\n iconUrls: [\"https://lattice.xyz/brand/color/pyrope.svg\"],\n indexerUrl: \"https://indexer.mud.pyropechain.com\",\n} as const satisfies MUDChain;\n"],"mappings":";AAAA,SAAS,eAAe;AAGjB,IAAM,aAAa;AAAA,EACxB,GAAG;AAAA,EACH,MAAM;AAAA,IACJ,oBAAoB;AAAA,EACtB;AACF;;;ACRA,SAAS,YAAY,sBAAsB;AAGpC,IAAM,WAAW;AAAA,EACtB,GAAG;AAAA,EACH,UAAU,CAAC,+CAA+C;AAAA,EAC1D,YAAY;AACd;;;ACPA,SAAS,UAAU,oBAAoB;AAGhC,IAAM,SAAS;AAAA,EACpB,GAAG;AAAA,EACH,SAAS;AAAA,IACP,GAAG,aAAa;AAAA,IAChB,SAAS,aAAa,QAAQ;AAAA,EAChC;AAAA,EACA,UAAU,CAAC,6CAA6C;AAAA,EACxD,YAAY;AACd;;;ACXA,SAAS,mBAAmB;AAI5B,IAAM,WAAW;AAEjB,IAAM,iBAAiB;AAAA,EACrB,MAAM,CAAC,gCAAgC;AAAA,EACvC,WAAW,CAAC,8BAA8B;AAC5C;AAEO,IAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,MAAM;AAAA,EACN,SAAS;AAAA,EACT,IAAI;AAAA,EACJ;AAAA,EACA,gBAAgB,EAAE,MAAM,SAAS,QAAQ,OAAO,UAAU,GAAG;AAAA,EAC7D,SAAS;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,IACT,kBAAkB;AAAA,IAClB,SAAS;AAAA,EACX;AAAA,EACA,WAAW;AAAA,IACT,GAAG,YAAY;AAAA,IACf,kBAAkB;AAAA,MAChB,CAAC,QAAQ,GAAG;AAAA,QACV,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,MAAM;AAAA,MACN,KAAK;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EACA,UAAU,CAAC,gDAAgD;AAAA,EAC3D,YAAY;AACd;;;AC/CA,SAAS,eAAAA,oBAAmB;AAI5B,IAAMC,YAAW;AAEjB,IAAMC,kBAAiB;AAAA,EACrB,MAAM,CAAC,6BAA6B;AAAA,EACpC,WAAW,CAAC,2BAA2B;AACzC;AAEO,IAAM,SAAS;AAAA,EACpB,GAAGF;AAAA,EACH,MAAM;AAAA,EACN,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,UAAAC;AAAA,EACA,gBAAgB,EAAE,MAAM,SAAS,QAAQ,OAAO,UAAU,GAAG;AAAA,EAC7D,SAAS;AAAA,IACP,SAASC;AAAA,IACT,SAASA;AAAA,EACX;AAAA,EACA,WAAW;AAAA,IACT,GAAGF,aAAY;AAAA,IACf,kBAAkB;AAAA,MAChB,CAACC,SAAQ,GAAG;AAAA,QACV,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,MAAM;AAAA,MACN,KAAK;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EACA,UAAU,CAAC,4CAA4C;AAAA,EACvD,YAAY;AACd;","names":["chainConfig","sourceId","defaultRpcUrls"]}
|
|
@@ -82,6 +82,18 @@ function unique(values) {
|
|
|
82
82
|
return Array.from(new Set(values));
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// src/utils/uniqueBy.ts
|
|
86
|
+
function uniqueBy(values, getKey) {
|
|
87
|
+
const map = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const value of values) {
|
|
89
|
+
const key = getKey(value);
|
|
90
|
+
if (!map.has(key)) {
|
|
91
|
+
map.set(key, value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return Array.from(map.values());
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
// src/utils/wait.ts
|
|
86
98
|
function wait(ms) {
|
|
87
99
|
return new Promise((resolve) => setTimeout(() => resolve(), ms));
|
|
@@ -113,7 +125,8 @@ export {
|
|
|
113
125
|
iteratorToArray,
|
|
114
126
|
mapObject,
|
|
115
127
|
unique,
|
|
128
|
+
uniqueBy,
|
|
116
129
|
wait,
|
|
117
130
|
waitForIdle
|
|
118
131
|
};
|
|
119
|
-
//# sourceMappingURL=chunk-
|
|
132
|
+
//# sourceMappingURL=chunk-ETXWXV5T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/assertExhaustive.ts","../src/utils/bigIntMax.ts","../src/utils/bigIntMin.ts","../src/utils/bigIntSort.ts","../src/utils/chunk.ts","../src/utils/groupBy.ts","../src/utils/identity.ts","../src/utils/includes.ts","../src/utils/indent.ts","../src/utils/isDefined.ts","../src/utils/isNotNull.ts","../src/utils/iteratorToArray.ts","../src/utils/mapObject.ts","../src/utils/unique.ts","../src/utils/uniqueBy.ts","../src/utils/wait.ts","../src/utils/waitForIdle.ts"],"sourcesContent":["export function assertExhaustive(value: never, message?: string): never {\n throw new Error(message ?? `Unexpected value: ${value}`);\n}\n","export function bigIntMax(...args: bigint[]): bigint {\n return args.reduce((m, e) => (e > m ? e : m));\n}\n","export function bigIntMin(...args: bigint[]): bigint {\n return args.reduce((m, e) => (e < m ? e : m));\n}\n","export function bigIntSort(a: bigint, b: bigint): -1 | 0 | 1 {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n","export function* chunk<T>(arr: readonly T[], n: number): Generator<readonly T[], void> {\n for (let i = 0; i < arr.length; i += n) {\n yield arr.slice(i, i + n);\n }\n}\n","export function groupBy<value, key>(\n values: readonly value[],\n getKey: (value: value) => key,\n): Map<key, readonly value[]> {\n const map = new Map<key, readonly value[]>();\n for (const value of values) {\n const key = getKey(value);\n if (!map.has(key)) map.set(key, []);\n (map.get(key) as value[]).push(value);\n }\n return map;\n}\n","export function identity<T>(value: T): T {\n return value;\n}\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function includes<item>(items: item[], value: any): value is item {\n return items.includes(value);\n}\n","export function indent(message: string, indentation = \" \"): string {\n return message.replaceAll(/(^|\\n)/g, `$1${indentation}`);\n}\n","export function isDefined<T>(argument: T | undefined): argument is T {\n return argument !== undefined;\n}\n","export function isNotNull<T>(argument: T | null): argument is T {\n return argument !== null;\n}\n","export async function iteratorToArray<T>(iterator: AsyncIterable<T>): Promise<readonly T[]> {\n const items: T[] = [];\n for await (const item of iterator) {\n items.push(item);\n }\n return items;\n}\n","/**\n * Map each key of a source object via a given valueMap function\n */\nexport function mapObject<\n Source extends Record<string | number | symbol, unknown>,\n Target extends { [key in keyof Source]: unknown },\n>(source: Source, valueMap: (value: Source[typeof key], key: keyof Source) => Target[typeof key]): Target {\n return Object.fromEntries(\n Object.entries(source).map(([key, value]) => [key, valueMap(value as Source[keyof Source], key)]),\n ) as Target;\n}\n","export function unique<value>(values: readonly value[]): readonly value[] {\n return Array.from(new Set(values));\n}\n","export function uniqueBy<value, key>(values: readonly value[], getKey: (value: value) => key): readonly value[] {\n const map = new Map<key, value>();\n for (const value of values) {\n const key = getKey(value);\n if (!map.has(key)) {\n map.set(key, value);\n }\n }\n return Array.from(map.values());\n}\n","export function wait(ms: number): Promise<void> {\n return new Promise<void>((resolve) => setTimeout(() => resolve(), ms));\n}\n","export function waitForIdle(): Promise<void> {\n return new Promise<void>((resolve) => {\n if (typeof requestIdleCallback !== \"undefined\") {\n requestIdleCallback(() => resolve());\n } else {\n setTimeout(() => resolve(), 1);\n }\n });\n}\n"],"mappings":";AAAO,SAAS,iBAAiB,OAAc,SAAyB;AACtE,QAAM,IAAI,MAAM,WAAW,qBAAqB,KAAK,EAAE;AACzD;;;ACFO,SAAS,aAAa,MAAwB;AACnD,SAAO,KAAK,OAAO,CAAC,GAAG,MAAO,IAAI,IAAI,IAAI,CAAE;AAC9C;;;ACFO,SAAS,aAAa,MAAwB;AACnD,SAAO,KAAK,OAAO,CAAC,GAAG,MAAO,IAAI,IAAI,IAAI,CAAE;AAC9C;;;ACFO,SAAS,WAAW,GAAW,GAAuB;AAC3D,SAAO,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;AAClC;;;ACFO,UAAU,MAAS,KAAmB,GAA0C;AACrF,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK,GAAG;AACtC,UAAM,IAAI,MAAM,GAAG,IAAI,CAAC;AAAA,EAC1B;AACF;;;ACJO,SAAS,QACd,QACA,QAC4B;AAC5B,QAAM,MAAM,oBAAI,IAA2B;AAC3C,aAAW,SAAS,QAAQ;AAC1B,UAAM,MAAM,OAAO,KAAK;AACxB,QAAI,CAAC,IAAI,IAAI,GAAG,EAAG,KAAI,IAAI,KAAK,CAAC,CAAC;AAClC,IAAC,IAAI,IAAI,GAAG,EAAc,KAAK,KAAK;AAAA,EACtC;AACA,SAAO;AACT;;;ACXO,SAAS,SAAY,OAAa;AACvC,SAAO;AACT;;;ACDO,SAAS,SAAe,OAAe,OAA2B;AACvE,SAAO,MAAM,SAAS,KAAK;AAC7B;;;ACHO,SAAS,OAAO,SAAiB,cAAc,MAAc;AAClE,SAAO,QAAQ,WAAW,WAAW,KAAK,WAAW,EAAE;AACzD;;;ACFO,SAAS,UAAa,UAAwC;AACnE,SAAO,aAAa;AACtB;;;ACFO,SAAS,UAAa,UAAmC;AAC9D,SAAO,aAAa;AACtB;;;ACFA,eAAsB,gBAAmB,UAAmD;AAC1F,QAAM,QAAa,CAAC;AACpB,mBAAiB,QAAQ,UAAU;AACjC,UAAM,KAAK,IAAI;AAAA,EACjB;AACA,SAAO;AACT;;;ACHO,SAAS,UAGd,QAAgB,UAAwF;AACxG,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,SAAS,OAA+B,GAAG,CAAC,CAAC;AAAA,EAClG;AACF;;;ACVO,SAAS,OAAc,QAA4C;AACxE,SAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC;AACnC;;;ACFO,SAAS,SAAqB,QAA0B,QAAiD;AAC9G,QAAM,MAAM,oBAAI,IAAgB;AAChC,aAAW,SAAS,QAAQ;AAC1B,UAAM,MAAM,OAAO,KAAK;AACxB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,KAAK;AAAA,IACpB;AAAA,EACF;AACA,SAAO,MAAM,KAAK,IAAI,OAAO,CAAC;AAChC;;;ACTO,SAAS,KAAK,IAA2B;AAC9C,SAAO,IAAI,QAAc,CAAC,YAAY,WAAW,MAAM,QAAQ,GAAG,EAAE,CAAC;AACvE;;;ACFO,SAAS,cAA6B;AAC3C,SAAO,IAAI,QAAc,CAAC,YAAY;AACpC,QAAI,OAAO,wBAAwB,aAAa;AAC9C,0BAAoB,MAAM,QAAQ,CAAC;AAAA,IACrC,OAAO;AACL,iBAAW,MAAM,QAAQ,GAAG,CAAC;AAAA,IAC/B;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/codegen.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
2
|
import { Abi } from 'abitype';
|
|
3
3
|
import { SchemaType } from '@latticexyz/schema-type/deprecated';
|
|
4
|
-
import { SourceUnit, ContractDefinition } from '@solidity-parser/parser/dist/src/ast-types';
|
|
5
4
|
|
|
6
5
|
declare module "prettier-plugin-solidity" {}
|
|
7
6
|
|
|
@@ -168,6 +167,11 @@ declare function renderTypeHelpers(options: {
|
|
|
168
167
|
|
|
169
168
|
declare const schemaTypesToRecsTypeStrings: Record<SchemaType, string>;
|
|
170
169
|
|
|
170
|
+
interface SymbolImport {
|
|
171
|
+
symbol: string;
|
|
172
|
+
path: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
171
175
|
interface ContractInterfaceFunction {
|
|
172
176
|
name: string;
|
|
173
177
|
parameters: string[];
|
|
@@ -178,10 +182,6 @@ interface ContractInterfaceError {
|
|
|
178
182
|
name: string;
|
|
179
183
|
parameters: string[];
|
|
180
184
|
}
|
|
181
|
-
interface SymbolImport {
|
|
182
|
-
symbol: string;
|
|
183
|
-
path: string;
|
|
184
|
-
}
|
|
185
185
|
/**
|
|
186
186
|
* Parse the contract data to get the functions necessary to generate an interface,
|
|
187
187
|
* and symbols to import from the original contract.
|
|
@@ -194,7 +194,6 @@ declare function contractToInterface(source: string, contractName: string): {
|
|
|
194
194
|
errors: ContractInterfaceError[];
|
|
195
195
|
symbolImports: SymbolImport[];
|
|
196
196
|
};
|
|
197
|
-
declare function findContractNode(ast: SourceUnit, contractName: string): ContractDefinition | undefined;
|
|
198
197
|
|
|
199
198
|
/**
|
|
200
199
|
* Formats solidity code using prettier
|
|
@@ -212,11 +211,11 @@ declare function formatTypescript(content: string): Promise<string>;
|
|
|
212
211
|
|
|
213
212
|
/**
|
|
214
213
|
* Formats solidity code using prettier and write it to a file
|
|
215
|
-
* @param
|
|
214
|
+
* @param content solidity code
|
|
216
215
|
* @param fullOutputPath full path to the output file
|
|
217
216
|
* @param logPrefix prefix for debug logs
|
|
218
217
|
*/
|
|
219
|
-
declare function formatAndWriteSolidity(
|
|
218
|
+
declare function formatAndWriteSolidity(content: string, fullOutputPath: string, logPrefix: string): Promise<void>;
|
|
220
219
|
/**
|
|
221
220
|
* Formats typescript code using prettier and write it to a file
|
|
222
221
|
* @param output typescript code
|
|
@@ -225,4 +224,8 @@ declare function formatAndWriteSolidity(output: string, fullOutputPath: string,
|
|
|
225
224
|
*/
|
|
226
225
|
declare function formatAndWriteTypescript(output: string, fullOutputPath: string, logPrefix: string): Promise<void>;
|
|
227
226
|
|
|
228
|
-
|
|
227
|
+
declare function parseSystem(source: string, contractName: string): undefined | {
|
|
228
|
+
contractType: "contract" | "abstract";
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export { type AbiToInterfaceOptions, type ContractInterfaceError, type ContractInterfaceFunction, type ImportDatum, type RenderDynamicField, type RenderEnum, type RenderField, type RenderFieldTypeWrappingData, type RenderKeyTuple, type RenderStaticField, type RenderType, type StaticResourceData, abiToInterface, contractToInterface, formatAndWriteSolidity, formatAndWriteTypescript, formatSolidity, formatTypescript, getLeftPaddingBits, isLeftAligned, parseSystem, renderArguments, renderCommonData, renderEnums, renderImportPath, renderImports, renderList, renderTableId, renderTypeHelpers, renderValueTypeToBytes32, renderWithFieldSuffix, renderWithStore, renderedSolidityHeader, schemaTypesToRecsTypeStrings };
|
package/dist/codegen.js
CHANGED
|
@@ -10,8 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-GRGLAPN2.js";
|
|
11
11
|
import {
|
|
12
12
|
isDefined
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-CHXZROA7.js";
|
|
13
|
+
} from "./chunk-ETXWXV5T.js";
|
|
15
14
|
|
|
16
15
|
// src/codegen/render-solidity/abiToInterface.ts
|
|
17
16
|
import { formatAbiItem, formatAbiParameter } from "abitype";
|
|
@@ -520,7 +519,47 @@ var schemaTypesToRecsTypeStrings = {
|
|
|
520
519
|
};
|
|
521
520
|
|
|
522
521
|
// src/codegen/utils/contractToInterface.ts
|
|
523
|
-
import { parse, visit } from "@solidity-parser/parser";
|
|
522
|
+
import { parse, visit as visit3 } from "@solidity-parser/parser";
|
|
523
|
+
|
|
524
|
+
// src/codegen/utils/findContractNode.ts
|
|
525
|
+
import { visit } from "@solidity-parser/parser";
|
|
526
|
+
function findContractNode(ast, contractName) {
|
|
527
|
+
let contract = void 0;
|
|
528
|
+
visit(ast, {
|
|
529
|
+
ContractDefinition(node) {
|
|
530
|
+
if (node.name === contractName) {
|
|
531
|
+
contract = node;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
return contract;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/codegen/utils/findSymbolImport.ts
|
|
539
|
+
import { visit as visit2 } from "@solidity-parser/parser";
|
|
540
|
+
function findSymbolImport(ast, symbol) {
|
|
541
|
+
let symbolImport;
|
|
542
|
+
visit2(ast, {
|
|
543
|
+
ImportDirective({ path: path3, symbolAliases }) {
|
|
544
|
+
if (symbolAliases) {
|
|
545
|
+
for (const symbolAndAlias of symbolAliases) {
|
|
546
|
+
const symbolAlias = symbolAndAlias[1] ?? symbolAndAlias[0];
|
|
547
|
+
if (symbol === symbolAlias) {
|
|
548
|
+
symbolImport = {
|
|
549
|
+
// always use the original symbol for interface imports
|
|
550
|
+
symbol: symbolAndAlias[0],
|
|
551
|
+
path: path3
|
|
552
|
+
};
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
return symbolImport;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// src/codegen/utils/contractToInterface.ts
|
|
524
563
|
function contractToInterface(source, contractName) {
|
|
525
564
|
const ast = parse(source);
|
|
526
565
|
const contractNode = findContractNode(ast, contractName);
|
|
@@ -530,7 +569,7 @@ function contractToInterface(source, contractName) {
|
|
|
530
569
|
if (!contractNode) {
|
|
531
570
|
throw new MUDError(`Contract not found: ${contractName}`);
|
|
532
571
|
}
|
|
533
|
-
|
|
572
|
+
visit3(contractNode, {
|
|
534
573
|
FunctionDefinition({
|
|
535
574
|
name,
|
|
536
575
|
visibility,
|
|
@@ -580,17 +619,6 @@ function contractToInterface(source, contractName) {
|
|
|
580
619
|
symbolImports
|
|
581
620
|
};
|
|
582
621
|
}
|
|
583
|
-
function findContractNode(ast, contractName) {
|
|
584
|
-
let contract = void 0;
|
|
585
|
-
visit(ast, {
|
|
586
|
-
ContractDefinition(node) {
|
|
587
|
-
if (node.name === contractName) {
|
|
588
|
-
contract = node;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
return contract;
|
|
593
|
-
}
|
|
594
622
|
function parseParameter({ name, typeName, storageLocation }) {
|
|
595
623
|
let typedNameWithLocation = "";
|
|
596
624
|
const { name: flattenedTypeName, stateMutability } = flattenTypeName(typeName);
|
|
@@ -655,33 +683,11 @@ function typeNameToSymbols(typeName) {
|
|
|
655
683
|
}
|
|
656
684
|
}
|
|
657
685
|
function symbolsToImports(ast, symbols) {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (symbolAliases) {
|
|
664
|
-
for (const symbolAndAlias of symbolAliases) {
|
|
665
|
-
const symbolAlias = symbolAndAlias[1] || symbolAndAlias[0];
|
|
666
|
-
if (symbol === symbolAlias) {
|
|
667
|
-
symbolImport = {
|
|
668
|
-
// always use the original symbol for interface imports
|
|
669
|
-
symbol: symbolAndAlias[0],
|
|
670
|
-
path: path3
|
|
671
|
-
};
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
if (symbolImport) {
|
|
679
|
-
imports.push(symbolImport);
|
|
680
|
-
} else {
|
|
681
|
-
throw new MUDError(`Symbol "${symbol}" has no explicit import`);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
return imports;
|
|
686
|
+
return symbols.map((symbol) => {
|
|
687
|
+
const symbolImport = findSymbolImport(ast, symbol);
|
|
688
|
+
if (!symbolImport) throw new MUDError(`Symbol "${symbol}" has no explicit import`);
|
|
689
|
+
return symbolImport;
|
|
690
|
+
});
|
|
685
691
|
}
|
|
686
692
|
|
|
687
693
|
// src/codegen/utils/format.ts
|
|
@@ -731,10 +737,15 @@ debug2.log = console.debug.bind(console);
|
|
|
731
737
|
error.log = console.error.bind(console);
|
|
732
738
|
|
|
733
739
|
// src/codegen/utils/formatAndWrite.ts
|
|
734
|
-
async function formatAndWriteSolidity(
|
|
735
|
-
|
|
740
|
+
async function formatAndWriteSolidity(content, fullOutputPath, logPrefix) {
|
|
741
|
+
let output = content;
|
|
742
|
+
try {
|
|
743
|
+
output = await formatSolidity(output);
|
|
744
|
+
} catch (e) {
|
|
745
|
+
error(`Error while attempting to format ${fullOutputPath}`, e);
|
|
746
|
+
}
|
|
736
747
|
await fs.mkdir(path2.dirname(fullOutputPath), { recursive: true });
|
|
737
|
-
await fs.writeFile(fullOutputPath,
|
|
748
|
+
await fs.writeFile(fullOutputPath, output);
|
|
738
749
|
debug2(`${logPrefix}: ${fullOutputPath}`);
|
|
739
750
|
}
|
|
740
751
|
async function formatAndWriteTypescript(output, fullOutputPath, logPrefix) {
|
|
@@ -743,16 +754,43 @@ async function formatAndWriteTypescript(output, fullOutputPath, logPrefix) {
|
|
|
743
754
|
await fs.writeFile(fullOutputPath, formattedOutput);
|
|
744
755
|
debug2(`${logPrefix}: ${fullOutputPath}`);
|
|
745
756
|
}
|
|
757
|
+
|
|
758
|
+
// src/codegen/utils/parseSystem.ts
|
|
759
|
+
import { parse as parse2, visit as visit4 } from "@solidity-parser/parser";
|
|
760
|
+
var baseSystemName = "System";
|
|
761
|
+
var baseSystemPath = "@latticexyz/world/src/System.sol";
|
|
762
|
+
function parseSystem(source, contractName) {
|
|
763
|
+
const ast = parse2(source);
|
|
764
|
+
const contractNode = findContractNode(ast, contractName);
|
|
765
|
+
if (!contractNode) return;
|
|
766
|
+
const contractType = contractNode.kind;
|
|
767
|
+
if (contractType !== "contract" && contractType !== "abstract") return;
|
|
768
|
+
const isSystem = (() => {
|
|
769
|
+
if (contractName.endsWith("System") && contractName !== baseSystemName) return true;
|
|
770
|
+
let extendsBaseSystem = false;
|
|
771
|
+
visit4(contractNode, {
|
|
772
|
+
InheritanceSpecifier(node) {
|
|
773
|
+
if (node.baseName.namePath === baseSystemName) {
|
|
774
|
+
extendsBaseSystem = true;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
return extendsBaseSystem && findSymbolImport(ast, baseSystemName)?.path === baseSystemPath;
|
|
779
|
+
})();
|
|
780
|
+
if (isSystem) {
|
|
781
|
+
return { contractType };
|
|
782
|
+
}
|
|
783
|
+
}
|
|
746
784
|
export {
|
|
747
785
|
abiToInterface,
|
|
748
786
|
contractToInterface,
|
|
749
|
-
findContractNode,
|
|
750
787
|
formatAndWriteSolidity,
|
|
751
788
|
formatAndWriteTypescript,
|
|
752
789
|
formatSolidity,
|
|
753
790
|
formatTypescript,
|
|
754
791
|
getLeftPaddingBits,
|
|
755
792
|
isLeftAligned,
|
|
793
|
+
parseSystem,
|
|
756
794
|
renderArguments,
|
|
757
795
|
renderCommonData,
|
|
758
796
|
renderEnums,
|