Skip to content

Commit 8f7d9dc

Browse files
authored
chore: update networks (#783)
* chore: update supported networks * chore: update latest networks services * chore: remove XDC with wrong name * fix: sample links having duplicate params in route * chore: remove analytics category * chore: update Download Schema button to use API Gateway
1 parent 258ef7e commit 8f7d9dc

File tree

219 files changed

+68293
-2934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+68293
-2934
lines changed

.github/scripts/generateApiReference.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const pathsMetadata = require('../../components/ApiReference/paths-metadata.json
99
const txServiceNetworks = require('../../components/ApiReference/tx-service-networks.json')
1010

1111
const curlify = (req: any) =>
12-
`curl -X ${req.method} https://api.safe.global${req.url} \\
12+
`curl -X ${req.method} ${req.baseUrl}${req.url} \\
1313
-H "Accept: application/json" \\
1414
-H "content-type: application/json" \\
1515
-H "Authorization: Bearer YOUR_API_KEY" \\
@@ -328,17 +328,13 @@ const generateMethodContent = (
328328
...data
329329
})
330330
)
331-
const pathParams = path.match(/{[^}]*}/g)
332-
const pathWithParams =
333-
pathParams?.reduce(
334-
(acc, param) =>
335-
acc.replace(param, getSampleValue(param.replace(/{|}/g, '')) as string),
336-
path
337-
) ?? path
338331

339332
// Strip the network prefix from the path to match paths-metadata.json format
340333
const cleanPath = path.replace(/^\/tx-service\/[^/]+/, '')
341334

335+
const pathParams = cleanPath.match(/{[^}]*}/g)
336+
337+
// Clean path with params replaced (for display)
342338
const cleanPathWithParams =
343339
pathParams?.reduce(
344340
(acc, param) =>
@@ -383,7 +379,7 @@ const generateMethodContent = (
383379

384380
// This is commented out, as we omit response generation for now.
385381
// It is planned to move this into a separate script.
386-
// generateSampleApiResponse(path, pathWithParams + query, method, requestBody, network)
382+
// generateSampleApiResponse(path, cleanPathWithParams + query, method, requestBody, network)
387383

388384
const codeBlockWithinDescription = _method.description?.match(
389385
/```[a-z]*\n[\s\S]*?\n```/
@@ -413,7 +409,7 @@ const generateMethodContent = (
413409
)}"} label='Did this API route run successfully?' small />
414410
</Grid>
415411
<Grid item xs={12} md={5.6}>
416-
<Path path="${path}" method="${method}" />
412+
<Path path="${cleanPath}" method="${method}" />
417413
418414
<SampleRequestHeader method="${method}" pathWithParams="${cleanPathWithParams}" />
419415
@@ -430,7 +426,7 @@ ${
430426
}
431427
\`\`\`bash ${hasExample && example !== 'export {}\n' ? 'curl' : ''}
432428
${curlify({
433-
url: pathWithParams,
429+
url: cleanPathWithParams,
434430
method: method.toUpperCase(),
435431
body: requestBody,
436432
baseUrl: network.txServiceUrl
@@ -518,7 +514,7 @@ const generateMainContent = (
518514
network: { txServiceUrl: string; shortName: string; networkName: string }
519515
) => {
520516
const categories = getCategories(swagger).filter(
521-
c => c.title !== 'about' && c.title !== 'notifications'
517+
c => c.title !== 'about' && c.title !== 'notifications' && c.title !== 'analytics'
522518
)
523519
return `import Path from '../Path'
524520
import Hr from '../../Hr'

.github/scripts/generateSupportedNetworks.ts

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -102,50 +102,54 @@ const getDeployedContractsFromGithubRepo = async (
102102
}deployments/`
103103
const repoDestination = module ? 'modules' : 'deployments'
104104

105-
shell.exec(`git clone ${deploymentRepoUrl} ${repoDestination}`)
106-
107-
let paths = walkPath(repoDestination + '/src/assets').map(p =>
108-
p.replace(repoDestination + '/src/assets/', '')
109-
)
110-
111-
const contracts = paths
112-
.map(p => {
113-
const file = fs.readFileSync(repoDestination + `/src/assets/${p}`, 'utf8')
114-
const json = JSON.parse(file)
115-
116-
return Object.entries(json.networkAddresses).map(
117-
([chainId, addressName]) => {
118-
const blockExplorerUrl =
119-
allNetworks.find(n => n.chainId === parseInt(chainId))
120-
?.explorers?.[0]?.url ?? ''
121-
return {
122-
name: p.split('/')[module ? 2 : 1].split('.')[0],
123-
version: p.split('/')[module ? 1 : 0],
124-
address:
125-
typeof addressName === 'string'
126-
? (json.deployments?.[addressName]?.address ??
127-
json.networkAddresses[chainId])
128-
: undefined,
129-
addresses:
130-
typeof addressName === 'string'
131-
? undefined
132-
: (addressName as Array<string>).map(a => [
133-
addressNameLabels[a as 'canonical'],
134-
json.deployments[a]?.address
135-
]),
136-
chainId,
137-
chainName: allNetworks.find(n => n.chainId === parseInt(chainId))
138-
?.name,
139-
blockExplorerUrl,
140-
...(module ? { moduleName: p.split('/')[0] } : {})
105+
try {
106+
shell.exec(`git clone ${deploymentRepoUrl} ${repoDestination}`)
107+
108+
let paths = walkPath(repoDestination + '/src/assets').map(p =>
109+
p.replace(repoDestination + '/src/assets/', '')
110+
)
111+
112+
const contracts = paths
113+
.map(p => {
114+
const file = fs.readFileSync(repoDestination + `/src/assets/${p}`, 'utf8')
115+
const json = JSON.parse(file)
116+
117+
return Object.entries(json.networkAddresses).map(
118+
([chainId, addressName]) => {
119+
const blockExplorerUrl =
120+
allNetworks.find(n => n.chainId === parseInt(chainId))
121+
?.explorers?.[0]?.url ?? ''
122+
return {
123+
name: p.split('/')[module ? 2 : 1].split('.')[0],
124+
version: p.split('/')[module ? 1 : 0],
125+
address:
126+
typeof addressName === 'string'
127+
? (json.deployments?.[addressName]?.address ??
128+
json.networkAddresses[chainId])
129+
: undefined,
130+
addresses:
131+
typeof addressName === 'string'
132+
? undefined
133+
: (addressName as Array<string>).map(a => [
134+
addressNameLabels[a as 'canonical'],
135+
json.deployments[a]?.address
136+
]),
137+
chainId,
138+
chainName: allNetworks.find(n => n.chainId === parseInt(chainId))
139+
?.name,
140+
blockExplorerUrl,
141+
...(module ? { moduleName: p.split('/')[0] } : {})
142+
}
141143
}
142-
}
143-
)
144-
})
145-
.flat()
144+
)
145+
})
146+
.flat()
146147

147-
shell.rm('-rf', repoDestination)
148-
return contracts
148+
shell.rm('-rf', repoDestination)
149+
return contracts
150+
} finally {
151+
shell.rm('-rf', repoDestination)
152+
}
149153
}
150154

151155
const generateSupportedNetworks = async () => {

components/ApiReference/Network.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { capitalize } from 'lodash'
1717
import { CopyToClipboard } from 'nextra/components'
1818

1919
import txServiceNetworks from './tx-service-networks.json'
20-
import { getSwaggerUrl } from './utils'
2120

2221
/**
2322
* Finds the default network for the NetworkContext.
@@ -109,7 +108,7 @@ const NetworkSwitcher: React.FC = () => {
109108
</Grid>
110109
<Grid sx={{ width: '100%' }} item mr={1}>
111110
<Link
112-
href={getSwaggerUrl(network) + '/schema'}
111+
href={network + '/schema'}
113112
target='_blank'
114113
rel='noopener noreferrer'
115114
>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SafeApiKit from '@safe-global/api-kit'
2+
3+
const apiKit = new SafeApiKit({
4+
chainId: 16661n,
5+
apiKey: 'YOUR_API_KEY'
6+
})
7+
8+
const info = await apiKit.getServiceInfo()
9+
10+
console.log(info)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SafeApiKit from '@safe-global/api-kit'
2+
3+
const apiKit = new SafeApiKit({
4+
chainId: 16661n,
5+
apiKey: 'YOUR_API_KEY'
6+
})
7+
8+
const info = await apiKit.getServiceSingletonsInfo()
9+
10+
console.log(info)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import SafeApiKit from '@safe-global/api-kit'
2+
3+
const apiKit = new SafeApiKit({
4+
chainId: 16661n,
5+
apiKey: 'YOUR_API_KEY'
6+
})
7+
8+
const data = await apiKit.decodeData(
9+
'0xa9059cbb0000000000000000000000005298a93734c3d979ef1f23f78ebb871879a21f220000000000000000000000000000000000000000000000008ac7230489e80000'
10+
)
11+
12+
console.log(data)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import SafeApiKit from '@safe-global/api-kit'
2+
3+
const apiKit = new SafeApiKit({
4+
chainId: 16661n,
5+
apiKey: 'YOUR_API_KEY'
6+
})
7+
8+
const messageHash =
9+
'0x950cfe6090e742b709ab5f662c10c8b4e06d403a2f8c4654d86af45d93fa3777'
10+
11+
const message = await apiKit.getMessage(messageHash)
12+
13+
console.log(message)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Safe from '@safe-global/protocol-kit'
2+
import SafeApiKit from '@safe-global/api-kit'
3+
4+
const protocolKit = await Safe.init({
5+
provider: 'https://eth-sepolia.public.blastapi.io',
6+
signer: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
7+
safeAddress: '0x5298a93734c3d979ef1f23f78ebb871879a21f22'
8+
})
9+
10+
const apiKit = new SafeApiKit({
11+
chainId: 16661n,
12+
apiKey: 'YOUR_API_KEY'
13+
})
14+
15+
const messageHash =
16+
'0xdd8c1417bf85842b6181288b1d2da439175c39dcef149097833dd25aef918d79'
17+
const rawMessage = 'string message'
18+
const safeMessage = protocolKit.createMessage(rawMessage)
19+
const signedMessage = await protocolKit.signMessage(safeMessage, 'eth_sign')
20+
21+
const result = await apiKit.addMessageSignature(
22+
messageHash,
23+
signedMessage.encodedSignatures()
24+
)
25+
26+
console.log(result)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import SafeApiKit from '@safe-global/api-kit'
2+
3+
const apiKit = new SafeApiKit({
4+
chainId: 16661n,
5+
apiKey: 'YOUR_API_KEY'
6+
})
7+
8+
const safes = await apiKit.getSafesByModule(
9+
'0xB4F5e59987549a2586976e8957962dBD54a26FD0'
10+
)
11+
12+
console.log(safes)

0 commit comments

Comments
 (0)