diff --git a/.github/scripts/generateApiReference.js b/.github/scripts/generateApiReference.js index fa700187..ba0843e6 100644 --- a/.github/scripts/generateApiReference.js +++ b/.github/scripts/generateApiReference.js @@ -276,7 +276,7 @@ const generateMethodContent = (path, method) => { - #### Sample Request + @@ -298,6 +298,14 @@ ${curlify({ \`\`\` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + ${ hasResponse && sampleResponse !== '{}' @@ -369,12 +377,15 @@ const generateMainContent = () => { return `import Path from './Path' import Hr from '../Hr' +import SampleRequestHeader from './SampleRequestHeader' import Parameters from './Parameter' import NetworkSwitcher from './Network' import Responses from './Response' import Feedback from '../Feedback' import Grid from '@mui/material/Grid' import Box from '@mui/material/Box' +import NextLink from 'next/link' +import Link from '@mui/material/Link' # Safe Transaction Service API Reference diff --git a/components/ApiReference/SampleRequestHeader.tsx b/components/ApiReference/SampleRequestHeader.tsx new file mode 100644 index 00000000..5271f40c --- /dev/null +++ b/components/ApiReference/SampleRequestHeader.tsx @@ -0,0 +1,29 @@ +import Button from '@mui/material/Button' +import Grid from '@mui/material/Grid' +import { useContext } from 'react' +import { NetworkContext } from './Network' +import { MdxHeading } from '../../lib/mdx' + +const SampleRequestHeader: React.FC<{ + method: string + pathWithParams: string +}> = ({ method, pathWithParams }) => { + const [network] = useContext(NetworkContext) + + return ( + + Sample Request + + + ) +} + +export default SampleRequestHeader diff --git a/components/ApiReference/generated-reference.mdx b/components/ApiReference/generated-reference.mdx index 90a400f5..c43eb4ee 100644 --- a/components/ApiReference/generated-reference.mdx +++ b/components/ApiReference/generated-reference.mdx @@ -1,11 +1,14 @@ import Path from './Path' import Hr from '../Hr' +import SampleRequestHeader from './SampleRequestHeader' import Parameters from './Parameter' import NetworkSwitcher from './Network' import Responses from './Response' import Feedback from '../Feedback' import Grid from '@mui/material/Grid' import Box from '@mui/material/Box' +import NextLink from 'next/link' +import Link from '@mui/material/Link' # Safe Transaction Service API Reference @@ -39,7 +42,7 @@ This service is available on [multiple networks](../../core-api/transaction-serv - #### Sample Request + @@ -52,12 +55,20 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/contracts/ \ ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response ```json { - "count": 138990, + "count": 143215, "next": "https://safe-transaction-mainnet.safe.global/api/v1/contracts/?limit=2&offset=2", "previous": null, "results": [ @@ -105,7 +116,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/contracts/ \ - #### Sample Request + @@ -118,6 +129,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/contracts/0xcd2E ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -186,7 +205,7 @@ as in case of ABI collision service will know which ABI to use. - #### Sample Request + @@ -202,6 +221,14 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/data-decoder/ \ ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -306,7 +333,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/data-decoder/ \ - #### Sample Request + @@ -319,6 +346,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/delegates/ \ ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -363,7 +398,7 @@ For example: - #### Sample Request + @@ -382,6 +417,14 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/delegates/ \ ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -411,7 +454,7 @@ Check `POST /delegates/` - #### Sample Request + @@ -428,6 +471,14 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/delegates/0x5 ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -465,7 +516,7 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/delegates/0x5 - #### Sample Request + @@ -478,6 +529,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/messages/0x3b3b5 ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -505,7 +564,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/messages/0x3b3b5 - #### Sample Request + @@ -520,6 +579,14 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/messages/0x3b3b ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -553,7 +620,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/messages/0x3b3b - #### Sample Request + @@ -566,6 +633,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/module-transacti ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -599,7 +674,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/module-transacti - #### Sample Request + @@ -612,6 +687,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/modules/0xcd2E72 ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -651,7 +734,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/modules/0xcd2E72 - #### Sample Request + @@ -664,6 +747,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/multisig-transac ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -725,7 +816,7 @@ Unix UTC epoch time (no milliseconds) and dividing by 3600 (natural division, no - #### Sample Request + @@ -741,6 +832,14 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/multisig-tran ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -772,7 +871,7 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/multisig-tran - #### Sample Request + @@ -785,6 +884,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/multisig-transac ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -822,7 +929,7 @@ the use of delegates to make a transaction trusted. - #### Sample Request + @@ -837,6 +944,14 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/multisig-transa ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -870,7 +985,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/multisig-transa - #### Sample Request + @@ -883,6 +998,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/owners/0xcd2E72a ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -922,7 +1045,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/owners/0xcd2E72a - #### Sample Request + @@ -935,6 +1058,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -979,7 +1110,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - #### Sample Request + @@ -992,6 +1123,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1192,7 +1331,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - #### Sample Request + @@ -1205,6 +1344,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1286,7 +1433,7 @@ Check `POST /delegates/` - #### Sample Request + @@ -1303,6 +1450,14 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E7 ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1334,7 +1489,7 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E7 - #### Sample Request + @@ -1347,6 +1502,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1426,7 +1589,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - #### Sample Request + @@ -1439,6 +1602,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1480,7 +1651,7 @@ service needs to derive it itself. - #### Sample Request + @@ -1497,6 +1668,14 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -1524,7 +1703,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a - #### Sample Request + @@ -1537,6 +1716,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1574,7 +1761,7 @@ By default only ``trusted`` multisig transactions are returned. - #### Sample Request + @@ -1587,6 +1774,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1762,7 +1957,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - #### Sample Request + @@ -1791,6 +1986,14 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -1818,7 +2021,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a - #### Sample Request + @@ -1836,6 +2039,14 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1870,7 +2081,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a - #### Sample Request + @@ -1883,6 +2094,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response @@ -1968,7 +2187,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - #### Sample Request + @@ -1981,12 +2200,20 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/tokens/ \ ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + #### Sample Response ```json { - "count": 39649, + "count": 40188, "next": "https://safe-transaction-mainnet.safe.global/api/v1/tokens/?limit=2&offset=2", "previous": null, "results": [ @@ -2036,7 +2263,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/tokens/ \ - #### Sample Request + @@ -2049,6 +2276,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/tokens/0xcd2E72a ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. + @@ -2082,7 +2317,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/tokens/0xcd2E72a - #### Sample Request + @@ -2095,6 +2330,14 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/transfer/3b3b57b ``` + + This snippet shows a sample request on mainnet. For other networks you should use + the corresponding base URL. +