Skip to content

Commit e28a1f2

Browse files
committed
Address comments
Signed-off-by: avichalp <[email protected]>
1 parent 4a60d24 commit e28a1f2

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

pkg/eventprocessor/impl/webhook.go

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,98 +89,86 @@ type chain struct {
8989
SupportsNFTView bool
9090
}
9191

92-
var chains = map[int64]chain{
92+
var chains = map[tableland.ChainID]chain{
93+
// Ethereum
9394
1: {
94-
ID: 1,
95-
Name: "Ethereum",
9695
ContractAddr: common.HexToAddress("0x012969f7e3439a9B04025b5a049EB9BAD82A8C12"),
9796
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/ethereum",
9897
BlockExplorerURL: "https://etherscan.io",
9998
SupportsNFTView: true,
10099
},
100+
// Optimism
101101
10: {
102-
ID: 10,
103-
Name: "Optimism",
104102
ContractAddr: common.HexToAddress("0xfad44BF5B843dE943a09D4f3E84949A11d3aa3e6"),
105103
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/optimism",
106104
BlockExplorerURL: "https://optimistic.etherscan.io",
107105
SupportsNFTView: false,
108106
},
107+
// Polygon
109108
137: {
110-
ID: 137,
111-
Name: "Polygon",
112109
ContractAddr: common.HexToAddress("0x5c4e6A9e5C1e1BF445A062006faF19EA6c49aFeA"),
113110
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/polygon",
114111
BlockExplorerURL: "https://polygonscan.com",
115112
SupportsNFTView: false,
116113
},
114+
// Arbitrum One
117115
42161: {
118-
ID: 42161,
119-
Name: "Arbitrum",
120116
ContractAddr: common.HexToAddress("0x9aBd75E8640871A5a20d3B4eE6330a04c962aFfd"),
121117
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/arbitrum",
122118
BlockExplorerURL: "https://arbiscan.io",
123119
SupportsNFTView: false,
124120
},
121+
// Arbitrum Nova
125122
42170: {
126-
ID: 42170,
127-
Name: "Arbitrum Nova",
128123
ContractAddr: common.HexToAddress("0x1a22854c5b1642760a827f20137a67930ae108d2"),
129124
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/arbitrum",
130125
BlockExplorerURL: "https://nova.arbiscan.io",
131126
SupportsNFTView: false,
132127
},
128+
// Filecoin
133129
314: {
134-
ID: 314,
135-
Name: "Filecoin",
136130
ContractAddr: common.HexToAddress("0x59EF8Bf2d6c102B4c42AEf9189e1a9F0ABfD652d"),
137131
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/Filecoin",
138132
BlockExplorerURL: "https://filfox.info/en",
139133
SupportsNFTView: false,
140134
},
135+
// Goerli
141136
5: {
142-
ID: 5,
143-
Name: "Ethereum Goerli",
144137
ContractAddr: common.HexToAddress("0xDA8EA22d092307874f30A1F277D1388dca0BA97a"),
145138
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/ethereum",
146139
BlockExplorerURL: "https://goerli.etherscan.io",
147140
SupportsNFTView: true,
148141
},
142+
// Sepolia
149143
11155111: {
150-
ID: 11155111,
151-
Name: "Ethereum Sepolia",
152144
ContractAddr: common.HexToAddress("0xc50C62498448ACc8dBdE43DA77f8D5D2E2c7597D"),
153145
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/ethereum",
154146
BlockExplorerURL: "https://sepolia.etherscan.io",
155147
SupportsNFTView: true,
156148
},
149+
// Optimism Goerli
157150
420: {
158-
ID: 420,
159-
Name: "Optimism Goerli",
160151
ContractAddr: common.HexToAddress("0xC72E8a7Be04f2469f8C2dB3F1BdF69A7D516aBbA"),
161152
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/optimism",
162153
BlockExplorerURL: "https://blockscout.com/optimism/goerli",
163154
SupportsNFTView: false,
164155
},
156+
// Arbitrum Goerli
165157
421613: {
166-
ID: 421613,
167-
Name: "Arbitrum Goerli",
168158
ContractAddr: common.HexToAddress("0x033f69e8d119205089Ab15D340F5b797732f646b"),
169159
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/arbitrum",
170160
BlockExplorerURL: "https://goerli-rollup-explorer.arbitrum.io",
171161
SupportsNFTView: false,
172162
},
163+
// Filecoin Calibration
173164
314159: {
174-
ID: 314159,
175-
Name: "Filecoin Calibration",
176165
ContractAddr: common.HexToAddress("0x030BCf3D50cad04c2e57391B12740982A9308621"),
177166
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/Filecoin",
178167
BlockExplorerURL: "https://calibration.filfox.info/en",
179168
SupportsNFTView: false,
180169
},
170+
// Polygon Mumbai
181171
80001: {
182-
ID: 80001,
183-
Name: "Polygon Mumbai",
184172
ContractAddr: common.HexToAddress("0x4b48841d4b32C4650E4ABc117A03FE8B51f38F68"),
185173
TBLDocsURL: "https://docs.tableland.xyz/fundamentals/chains/polygon",
186174
BlockExplorerURL: "https://mumbai.polygonscan.com",
@@ -202,12 +190,13 @@ type webhookContentData struct {
202190
// getTableNFTViews returns the NFT views for the given table IDs.
203191
func getTableNFTViews(tableIDs tables.TableIDs, chainID tableland.ChainID) string {
204192
var tableNFTURLs []string
193+
ch := chains[chainID]
205194
for _, tableID := range tableIDs {
206-
if !chains[int64(chainID)].SupportsNFTView {
195+
if !ch.SupportsNFTView {
207196
tableNFTURLs = append(tableNFTURLs, tableID.String())
208197
} else {
209-
blockExplorerURL := chains[int64(chainID)].BlockExplorerURL
210-
contractAddr := chains[int64(chainID)].ContractAddr
198+
blockExplorerURL := ch.BlockExplorerURL
199+
contractAddr := ch.ContractAddr
211200
tableNFTURLs = append(tableNFTURLs,
212201
fmt.Sprintf("[%s](%s/nft/%s/%s)", tableID.String(),
213202
blockExplorerURL, contractAddr, tableID.String()))
@@ -224,8 +213,8 @@ func content(r eventprocessor.Receipt) (string, error) {
224213
return "", fmt.Errorf("failed to parse template: %v", err)
225214
}
226215

227-
txnURL := chains[int64(r.ChainID)].BlockExplorerURL + "/tx/" + r.TxnHash
228-
docsURL := chains[int64(r.ChainID)].TBLDocsURL
216+
txnURL := chains[r.ChainID].BlockExplorerURL + "/tx/" + r.TxnHash
217+
docsURL := chains[r.ChainID].TBLDocsURL
229218
err = tmpl.Execute(&c, webhookContentData{
230219
ChainID: r.ChainID,
231220
TBLDocsURL: docsURL,

0 commit comments

Comments
 (0)