Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: avichalp <[email protected]>
  • Loading branch information
avichalp committed Jul 14, 2023
1 parent 4a60d24 commit e28a1f2
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions pkg/eventprocessor/impl/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,98 +89,86 @@ type chain struct {
SupportsNFTView bool
}

var chains = map[int64]chain{
var chains = map[tableland.ChainID]chain{
// Ethereum
1: {
ID: 1,
Name: "Ethereum",
ContractAddr: common.HexToAddress("0x012969f7e3439a9B04025b5a049EB9BAD82A8C12"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/ethereum",
BlockExplorerURL: "https://etherscan.io",
SupportsNFTView: true,
},
// Optimism
10: {
ID: 10,
Name: "Optimism",
ContractAddr: common.HexToAddress("0xfad44BF5B843dE943a09D4f3E84949A11d3aa3e6"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/optimism",
BlockExplorerURL: "https://optimistic.etherscan.io",
SupportsNFTView: false,
},
// Polygon
137: {
ID: 137,
Name: "Polygon",
ContractAddr: common.HexToAddress("0x5c4e6A9e5C1e1BF445A062006faF19EA6c49aFeA"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/polygon",
BlockExplorerURL: "https://polygonscan.com",
SupportsNFTView: false,
},
// Arbitrum One
42161: {
ID: 42161,
Name: "Arbitrum",
ContractAddr: common.HexToAddress("0x9aBd75E8640871A5a20d3B4eE6330a04c962aFfd"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/arbitrum",
BlockExplorerURL: "https://arbiscan.io",
SupportsNFTView: false,
},
// Arbitrum Nova
42170: {
ID: 42170,
Name: "Arbitrum Nova",
ContractAddr: common.HexToAddress("0x1a22854c5b1642760a827f20137a67930ae108d2"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/arbitrum",
BlockExplorerURL: "https://nova.arbiscan.io",
SupportsNFTView: false,
},
// Filecoin
314: {
ID: 314,
Name: "Filecoin",
ContractAddr: common.HexToAddress("0x59EF8Bf2d6c102B4c42AEf9189e1a9F0ABfD652d"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/Filecoin",
BlockExplorerURL: "https://filfox.info/en",
SupportsNFTView: false,
},
// Goerli
5: {
ID: 5,
Name: "Ethereum Goerli",
ContractAddr: common.HexToAddress("0xDA8EA22d092307874f30A1F277D1388dca0BA97a"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/ethereum",
BlockExplorerURL: "https://goerli.etherscan.io",
SupportsNFTView: true,
},
// Sepolia
11155111: {
ID: 11155111,
Name: "Ethereum Sepolia",
ContractAddr: common.HexToAddress("0xc50C62498448ACc8dBdE43DA77f8D5D2E2c7597D"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/ethereum",
BlockExplorerURL: "https://sepolia.etherscan.io",
SupportsNFTView: true,
},
// Optimism Goerli
420: {
ID: 420,
Name: "Optimism Goerli",
ContractAddr: common.HexToAddress("0xC72E8a7Be04f2469f8C2dB3F1BdF69A7D516aBbA"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/optimism",
BlockExplorerURL: "https://blockscout.com/optimism/goerli",
SupportsNFTView: false,
},
// Arbitrum Goerli
421613: {
ID: 421613,
Name: "Arbitrum Goerli",
ContractAddr: common.HexToAddress("0x033f69e8d119205089Ab15D340F5b797732f646b"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/arbitrum",
BlockExplorerURL: "https://goerli-rollup-explorer.arbitrum.io",
SupportsNFTView: false,
},
// Filecoin Calibration
314159: {
ID: 314159,
Name: "Filecoin Calibration",
ContractAddr: common.HexToAddress("0x030BCf3D50cad04c2e57391B12740982A9308621"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/Filecoin",
BlockExplorerURL: "https://calibration.filfox.info/en",
SupportsNFTView: false,
},
// Polygon Mumbai
80001: {
ID: 80001,
Name: "Polygon Mumbai",
ContractAddr: common.HexToAddress("0x4b48841d4b32C4650E4ABc117A03FE8B51f38F68"),
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/polygon",
BlockExplorerURL: "https://mumbai.polygonscan.com",
Expand All @@ -202,12 +190,13 @@ type webhookContentData struct {
// getTableNFTViews returns the NFT views for the given table IDs.
func getTableNFTViews(tableIDs tables.TableIDs, chainID tableland.ChainID) string {
var tableNFTURLs []string
ch := chains[chainID]
for _, tableID := range tableIDs {
if !chains[int64(chainID)].SupportsNFTView {
if !ch.SupportsNFTView {
tableNFTURLs = append(tableNFTURLs, tableID.String())
} else {
blockExplorerURL := chains[int64(chainID)].BlockExplorerURL
contractAddr := chains[int64(chainID)].ContractAddr
blockExplorerURL := ch.BlockExplorerURL
contractAddr := ch.ContractAddr
tableNFTURLs = append(tableNFTURLs,
fmt.Sprintf("[%s](%s/nft/%s/%s)", tableID.String(),
blockExplorerURL, contractAddr, tableID.String()))
Expand All @@ -224,8 +213,8 @@ func content(r eventprocessor.Receipt) (string, error) {
return "", fmt.Errorf("failed to parse template: %v", err)
}

txnURL := chains[int64(r.ChainID)].BlockExplorerURL + "/tx/" + r.TxnHash
docsURL := chains[int64(r.ChainID)].TBLDocsURL
txnURL := chains[r.ChainID].BlockExplorerURL + "/tx/" + r.TxnHash
docsURL := chains[r.ChainID].TBLDocsURL
err = tmpl.Execute(&c, webhookContentData{
ChainID: r.ChainID,
TBLDocsURL: docsURL,
Expand Down

0 comments on commit e28a1f2

Please sign in to comment.