Skip to content

Commit d8f548b

Browse files
committed
test
1 parent 2e2cf41 commit d8f548b

File tree

1 file changed

+126
-130
lines changed

1 file changed

+126
-130
lines changed

cmd/ulxly/ulxly.go

Lines changed: 126 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"encoding/json"
1111
"errors"
1212
"fmt"
13-
"github.com/ethereum/go-ethereum"
1413
"io"
1514
"math/big"
1615
"net/http"
@@ -19,6 +18,8 @@ import (
1918
"strings"
2019
"time"
2120

21+
"github.com/ethereum/go-ethereum"
22+
2223
"github.com/ethereum/go-ethereum/accounts/abi/bind"
2324
"github.com/ethereum/go-ethereum/common"
2425
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -1187,6 +1188,105 @@ var ulxlyClaimCmd = &cobra.Command{
11871188
Args: cobra.NoArgs,
11881189
}
11891190

1191+
var bridgeAssetCmd = &cobra.Command{
1192+
Use: "asset",
1193+
Short: "Move ETH or an ERC20 between to chains",
1194+
Long: bridgeAssetUsage,
1195+
PreRunE: prepInputs,
1196+
RunE: func(cmd *cobra.Command, args []string) error {
1197+
return bridgeAsset(cmd)
1198+
},
1199+
}
1200+
1201+
var bridgeMessageCmd = &cobra.Command{
1202+
Use: "message",
1203+
Short: "Send some ETH along with data from one chain to another chain",
1204+
Long: bridgeMessageUsage,
1205+
PreRunE: prepInputs,
1206+
RunE: func(cmd *cobra.Command, args []string) error {
1207+
return bridgeMessage(cmd)
1208+
},
1209+
}
1210+
1211+
var bridgeMessageWETHCmd = &cobra.Command{
1212+
Use: "weth",
1213+
Short: "For L2's that use a gas token, use this to transfer WETH to another chain",
1214+
Long: bridgeWETHMessageUsage,
1215+
PreRunE: prepInputs,
1216+
RunE: func(cmd *cobra.Command, args []string) error {
1217+
return bridgeWETHMessage(cmd)
1218+
},
1219+
}
1220+
1221+
var claimAssetCmd = &cobra.Command{
1222+
Use: "asset",
1223+
Short: "Claim a deposit",
1224+
Long: claimAssetUsage,
1225+
PreRunE: prepInputs,
1226+
RunE: func(cmd *cobra.Command, args []string) error {
1227+
return claimAsset(cmd)
1228+
},
1229+
}
1230+
1231+
var claimMessageCmd = &cobra.Command{
1232+
Use: "message",
1233+
Short: "Claim a message",
1234+
Long: claimMessageUsage,
1235+
PreRunE: prepInputs,
1236+
RunE: func(cmd *cobra.Command, args []string) error {
1237+
return claimMessage(cmd)
1238+
},
1239+
}
1240+
var claimEverythingCmd = &cobra.Command{
1241+
Use: "claim-everything",
1242+
Short: "Attempt to claim as many deposits and messages as possible",
1243+
PreRunE: prepInputs,
1244+
RunE: func(cmd *cobra.Command, args []string) error {
1245+
return claimEverything(cmd)
1246+
},
1247+
}
1248+
1249+
var emptyproofCmd = &cobra.Command{
1250+
Use: "empty-proof",
1251+
Short: "create an empty proof",
1252+
Long: "Use this command to print an empty proof response that's filled with zero-valued siblings like 0x0000000000000000000000000000000000000000000000000000000000000000. This can be useful when you need to submit a dummy proof.",
1253+
RunE: func(cmd *cobra.Command, args []string) error {
1254+
return emptyProof()
1255+
},
1256+
}
1257+
1258+
var zeroproofCmd = &cobra.Command{
1259+
Use: "zero-proof",
1260+
Short: "create a proof that's filled with zeros",
1261+
Long: `Use this command to print a proof response that's filled with the zero
1262+
hashes. This values are very helpful for debugging because it would
1263+
tell you how populated the tree is and roughly which leaves and
1264+
siblings are empty. It's also helpful for sanity checking a proof
1265+
response to understand if the hashed value is part of the zero hashes
1266+
or if it's actually an intermediate hash.`,
1267+
RunE: func(cmd *cobra.Command, args []string) error {
1268+
return zeroProof()
1269+
},
1270+
}
1271+
1272+
var proofCmd = &cobra.Command{
1273+
Use: "proof",
1274+
Short: "Generate a proof for a given range of deposits",
1275+
Long: proofUsage,
1276+
RunE: func(cmd *cobra.Command, args []string) error {
1277+
return proof(args)
1278+
},
1279+
}
1280+
1281+
var getDepositCmd = &cobra.Command{
1282+
Use: "get-deposits",
1283+
Short: "Generate ndjson for each bridge deposit over a particular range of blocks",
1284+
Long: depositGetUsage,
1285+
RunE: func(cmd *cobra.Command, args []string) error {
1286+
return readDeposit(cmd)
1287+
},
1288+
}
1289+
11901290
type ulxlyArgs struct {
11911291
gasLimit *uint64
11921292
chainID *string
@@ -1220,19 +1320,6 @@ type ulxlyArgs struct {
12201320

12211321
var inputUlxlyArgs = ulxlyArgs{}
12221322

1223-
var (
1224-
bridgeAssetCommand *cobra.Command
1225-
bridgeMessageCommand *cobra.Command
1226-
bridgeMessageWETHCommand *cobra.Command
1227-
claimAssetCommand *cobra.Command
1228-
claimMessageCommand *cobra.Command
1229-
claimEverythingCommand *cobra.Command
1230-
emptyProofCommand *cobra.Command
1231-
zeroProofCommand *cobra.Command
1232-
proofCommand *cobra.Command
1233-
getDepositCommand *cobra.Command
1234-
)
1235-
12361323
const (
12371324
ArgGasLimit = "gas-limit"
12381325
ArgChainID = "chain-id"
@@ -1308,97 +1395,6 @@ func fatalIfError(err error) {
13081395
}
13091396

13101397
func init() {
1311-
bridgeAssetCommand = &cobra.Command{
1312-
Use: "asset",
1313-
Short: "Move ETH or an ERC20 between to chains",
1314-
Long: bridgeAssetUsage,
1315-
PreRunE: prepInputs,
1316-
RunE: func(cmd *cobra.Command, args []string) error {
1317-
return bridgeAsset(cmd)
1318-
},
1319-
}
1320-
bridgeMessageCommand = &cobra.Command{
1321-
Use: "message",
1322-
Short: "Send some ETH along with data from one chain to another chain",
1323-
Long: bridgeMessageUsage,
1324-
PreRunE: prepInputs,
1325-
RunE: func(cmd *cobra.Command, args []string) error {
1326-
return bridgeMessage(cmd)
1327-
},
1328-
}
1329-
bridgeMessageWETHCommand = &cobra.Command{
1330-
Use: "weth",
1331-
Short: "For L2's that use a gas token, use this to transfer WETH to another chain",
1332-
Long: bridgeWETHMessageUsage,
1333-
PreRunE: prepInputs,
1334-
RunE: func(cmd *cobra.Command, args []string) error {
1335-
return bridgeWETHMessage(cmd)
1336-
},
1337-
}
1338-
claimAssetCommand = &cobra.Command{
1339-
Use: "asset",
1340-
Short: "Claim a deposit",
1341-
Long: claimAssetUsage,
1342-
PreRunE: prepInputs,
1343-
RunE: func(cmd *cobra.Command, args []string) error {
1344-
return claimAsset(cmd)
1345-
},
1346-
}
1347-
claimMessageCommand = &cobra.Command{
1348-
Use: "message",
1349-
Short: "Claim a message",
1350-
Long: claimMessageUsage,
1351-
PreRunE: prepInputs,
1352-
RunE: func(cmd *cobra.Command, args []string) error {
1353-
return claimMessage(cmd)
1354-
},
1355-
}
1356-
claimEverythingCommand = &cobra.Command{
1357-
Use: "claim-everything",
1358-
Short: "Attempt to claim as many deposits and messages as possible",
1359-
PreRunE: prepInputs,
1360-
RunE: func(cmd *cobra.Command, args []string) error {
1361-
return claimEverything(cmd)
1362-
},
1363-
}
1364-
emptyProofCommand = &cobra.Command{
1365-
Use: "empty-proof",
1366-
Short: "create an empty proof",
1367-
Long: "Use this command to print an empty proof response that's filled with zero-valued siblings like 0x0000000000000000000000000000000000000000000000000000000000000000. This can be useful when you need to submit a dummy proof.",
1368-
RunE: func(cmd *cobra.Command, args []string) error {
1369-
return emptyProof()
1370-
},
1371-
}
1372-
zeroProofCommand = &cobra.Command{
1373-
Use: "zero-proof",
1374-
Short: "create a proof that's filled with zeros",
1375-
Long: `Use this command to print a proof response that's filled with the zero
1376-
hashes. This values are very helpful for debugging because it would
1377-
tell you how populated the tree is and roughly which leaves and
1378-
siblings are empty. It's also helpful for sanity checking a proof
1379-
response to understand if the hashed value is part of the zero hashes
1380-
or if it's actually an intermediate hash.`,
1381-
RunE: func(cmd *cobra.Command, args []string) error {
1382-
return zeroProof()
1383-
},
1384-
}
1385-
proofCommand = &cobra.Command{
1386-
Use: "proof",
1387-
Short: "Generate a proof for a given range of deposits",
1388-
Long: proofUsage,
1389-
RunE: func(cmd *cobra.Command, args []string) error {
1390-
return proof(args)
1391-
},
1392-
}
1393-
getDepositCommand = &cobra.Command{
1394-
Use: "get-deposits",
1395-
Short: "Generate ndjson for each bridge deposit over a particular range of blocks",
1396-
Long: depositGetUsage,
1397-
RunE: func(cmd *cobra.Command, args []string) error {
1398-
return readDeposit(cmd)
1399-
},
1400-
}
1401-
14021398
// Arguments for both bridge and claim
14031399
inputUlxlyArgs.rpcURL = ulxlyBridgeAndClaimCmd.PersistentFlags().String(ArgRPCURL, "", "the URL of the RPC to send the transaction")
14041400
inputUlxlyArgs.bridgeAddress = ulxlyBridgeAndClaimCmd.PersistentFlags().String(ArgBridgeAddress, "", "the address of the lxly bridge")
@@ -1432,47 +1428,47 @@ or if it's actually an intermediate hash.`,
14321428
fatalIfError(ulxlyClaimCmd.MarkPersistentFlagRequired(ArgBridgeServiceURL))
14331429

14341430
// Claim Everything Helper Command
1435-
inputUlxlyArgs.bridgeServiceURLs = claimEverythingCommand.Flags().StringSlice(ArgBridgeMappings, nil, "Mappings between network ids and bridge service urls. E.g. '1=http://network-1-bridgeurl,7=http://network-2-bridgeurl'")
1436-
inputUlxlyArgs.bridgeLimit = claimEverythingCommand.Flags().Int(ArgBridgeLimit, 25, "Limit the number or responses returned by the bridge service when claiming")
1437-
inputUlxlyArgs.bridgeOffset = claimEverythingCommand.Flags().Int(ArgBridgeOffset, 0, "The offset to specify for pagination of the underlying bridge service deposits")
1438-
fatalIfError(claimEverythingCommand.MarkFlagRequired(ArgBridgeMappings))
1431+
inputUlxlyArgs.bridgeServiceURLs = claimEverythingCmd.Flags().StringSlice(ArgBridgeMappings, nil, "Mappings between network ids and bridge service urls. E.g. '1=http://network-1-bridgeurl,7=http://network-2-bridgeurl'")
1432+
inputUlxlyArgs.bridgeLimit = claimEverythingCmd.Flags().Int(ArgBridgeLimit, 25, "Limit the number or responses returned by the bridge service when claiming")
1433+
inputUlxlyArgs.bridgeOffset = claimEverythingCmd.Flags().Int(ArgBridgeOffset, 0, "The offset to specify for pagination of the underlying bridge service deposits")
1434+
fatalIfError(claimEverythingCmd.MarkFlagRequired(ArgBridgeMappings))
14391435

14401436
// Args that are just for the get deposit command
1441-
inputUlxlyArgs.fromBlock = getDepositCommand.Flags().Uint64(ArgFromBlock, 0, "The start of the range of blocks to retrieve")
1442-
inputUlxlyArgs.toBlock = getDepositCommand.Flags().Uint64(ArgToBlock, 0, "The end of the range of blocks to retrieve")
1443-
inputUlxlyArgs.filterSize = getDepositCommand.Flags().Uint64(ArgFilterSize, 1000, "The batch size for individual filter queries")
1444-
getDepositCommand.Flags().String(ArgRPCURL, "", "The RPC URL to read deposit data")
1445-
getDepositCommand.Flags().String(ArgBridgeAddress, "", "The address of the ulxly bridge")
1446-
fatalIfError(getDepositCommand.MarkFlagRequired(ArgFromBlock))
1447-
fatalIfError(getDepositCommand.MarkFlagRequired(ArgToBlock))
1448-
fatalIfError(getDepositCommand.MarkFlagRequired(ArgRPCURL))
1437+
inputUlxlyArgs.fromBlock = getDepositCmd.Flags().Uint64(ArgFromBlock, 0, "The start of the range of blocks to retrieve")
1438+
inputUlxlyArgs.toBlock = getDepositCmd.Flags().Uint64(ArgToBlock, 0, "The end of the range of blocks to retrieve")
1439+
inputUlxlyArgs.filterSize = getDepositCmd.Flags().Uint64(ArgFilterSize, 1000, "The batch size for individual filter queries")
1440+
getDepositCmd.Flags().String(ArgRPCURL, "", "The RPC URL to read deposit data")
1441+
getDepositCmd.Flags().String(ArgBridgeAddress, "", "The address of the ulxly bridge")
1442+
fatalIfError(getDepositCmd.MarkFlagRequired(ArgFromBlock))
1443+
fatalIfError(getDepositCmd.MarkFlagRequired(ArgToBlock))
1444+
fatalIfError(getDepositCmd.MarkFlagRequired(ArgRPCURL))
14491445

14501446
// Args for the proof command
1451-
inputUlxlyArgs.inputFileName = proofCommand.Flags().String(ArgFileName, "", "An ndjson file with deposit data")
1452-
inputUlxlyArgs.depositNumber = proofCommand.Flags().Uint64(ArgDepositCount, 0, "The deposit number to generate a proof for")
1447+
inputUlxlyArgs.inputFileName = proofCmd.Flags().String(ArgFileName, "", "An ndjson file with deposit data")
1448+
inputUlxlyArgs.depositNumber = proofCmd.Flags().Uint64(ArgDepositCount, 0, "The deposit number to generate a proof for")
14531449

14541450
// Top Level
14551451
ULxLyCmd.AddCommand(ulxlyBridgeAndClaimCmd)
1456-
ULxLyCmd.AddCommand(emptyProofCommand)
1457-
ULxLyCmd.AddCommand(zeroProofCommand)
1458-
ULxLyCmd.AddCommand(proofCommand)
1459-
ULxLyCmd.AddCommand(getDepositCommand)
1452+
ULxLyCmd.AddCommand(emptyproofCmd)
1453+
ULxLyCmd.AddCommand(zeroproofCmd)
1454+
ULxLyCmd.AddCommand(proofCmd)
1455+
ULxLyCmd.AddCommand(getDepositCmd)
14601456

14611457
ULxLyCmd.AddCommand(ulxlyBridgeCmd)
14621458
ULxLyCmd.AddCommand(ulxlyClaimCmd)
1463-
ULxLyCmd.AddCommand(claimEverythingCommand)
1459+
ULxLyCmd.AddCommand(claimEverythingCmd)
14641460

14651461
// Bridge and Claim
14661462
ulxlyBridgeAndClaimCmd.AddCommand(ulxlyBridgeCmd)
14671463
ulxlyBridgeAndClaimCmd.AddCommand(ulxlyClaimCmd)
1468-
ulxlyBridgeAndClaimCmd.AddCommand(claimEverythingCommand)
1464+
ulxlyBridgeAndClaimCmd.AddCommand(claimEverythingCmd)
14691465

14701466
// Bridge
1471-
ulxlyBridgeCmd.AddCommand(bridgeAssetCommand)
1472-
ulxlyBridgeCmd.AddCommand(bridgeMessageCommand)
1473-
ulxlyBridgeCmd.AddCommand(bridgeMessageWETHCommand)
1467+
ulxlyBridgeCmd.AddCommand(bridgeAssetCmd)
1468+
ulxlyBridgeCmd.AddCommand(bridgeMessageCmd)
1469+
ulxlyBridgeCmd.AddCommand(bridgeMessageWETHCmd)
14741470

14751471
// Claim
1476-
ulxlyClaimCmd.AddCommand(claimAssetCommand)
1477-
ulxlyClaimCmd.AddCommand(claimMessageCommand)
1472+
ulxlyClaimCmd.AddCommand(claimAssetCmd)
1473+
ulxlyClaimCmd.AddCommand(claimMessageCmd)
14781474
}

0 commit comments

Comments
 (0)