Skip to content

Commit

Permalink
Regenerate reference
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-md committed May 31, 2024
1 parent 183b4b9 commit ac2d9bd
Show file tree
Hide file tree
Showing 2 changed files with 1,355 additions and 220 deletions.
64 changes: 59 additions & 5 deletions .github/scripts/generateApiReference.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const { capitalize } = require('lodash')
const jsonFile = require('../../components/ApiReference/mainnet-swagger.json')
const pathsMetadata = require('../../components/ApiReference/paths-metadata.json')

const baseUrl = 'https://safe-transaction-sepolia.staging.5afe.dev/api'

const curlify = req =>
`curl -X ${req.method} https://safe-transaction-mainnet.safe.global/api${
req.url
Expand All @@ -14,8 +16,13 @@ const curlify = req =>

const sampleSafe = '0xB88F61E6FbdA83fbfffAbE364112137480398018'
const sampleSafe2 = '0xcd2E72aEBe2A203b84f46DEEC948E6465dB51c75'
const sampleSafeWithSafeOp = '0xF72b6C739E7889b89C888403a960a59935564405'
const sampleTargetSafe = '0xb531870897EB944799239FA5485792bA495a7411'
const sampleSafeWithUserOp = '0xFc434a578F935205F459768d8756C000419c6007'
const sampleContract = '0xB88F61E6FbdA83fbfffAbE364112137480398018'
const sampleMessageHash = '0x3b3b57b3'
const sampleSafeOperationHash = '0x597ba36c626a32a4fcc9f23a4b25605ee30b46584918d6b6442387161dc3c51b'
const sampleUserOperationHash = '0xe6dac94a3cdbab8d807dfbe79ec378713403ff60cb1a1fff09696813d2705b8e'
const sampleMessage = '0x1234'
const sampleModuleTransactionId = '0x3b3b57b3'
const sampleSafeTxHash =
Expand All @@ -27,14 +34,29 @@ const sampleValue = '0'
const sampleEOA = '0xBEFA89D90c112A416139F42046Cc2d4A8a308815'
const sampleTransferId = '3b3b57b3'
const sampleLabel = '3b3b57b3'
const sampleSafeAppId = 'safeAppId'
const sampleSafeAppId = 1
const sampleData =
'0x8d80ff0a000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004f6006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d0000000000000000000000000000000000000000000c685fa11e01ec80000000001111111254fb6c44bac0bed2854e76f90643097d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004087c025200000000000000000000000000f2f400c138f9fb900576263af0bc7fcde2b1b8a8000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000f2f400c138f9fb900576263af0bc7fcde2b1b8a80000000000000000000000004f3a120e72c76c22ae802d129f599bfdbc31cb810000000000000000000000000000000000000000000c685fa11e01ec8000000000000000000000000000000000000000000000000000000000000da41c43c100000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001408000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000064eb5625d90000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000089b78cfa322f6c5de0abceecab66aee45393cc5a0000000000000000000000000000000000000000000c685fa11e01ec800000000000000000000000000000000000000000000000000000000000000080000000000000000000000089b78cfa322f6c5de0abceecab66aee45393cc5a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000448d7ef9bb0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d00000000000000000000000000000000000000000000000000000da475abf0000000000000000000000000000000000000000000000000000000000065575cda00000000000000000000'
const sampleSignature =
'0xae31da115daa589fa3cee016c756d191d4140fc0eb30c1565cdddcad35068300669abda9c56e1c5886d72c599e1af29fc70eedd16be72109aa593699661482121c'
const initCode = "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec671688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c7620000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000a97000000000000000000000000000000000000000000000000000000000000001e4b63e800d000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000008ecd4ec46d4d2a6b64fe960b3d64e8b94b2234eb0000000000000000000000000000000000000000000000000000000000000140000000000000000000000000a581c4a4db7175302464ff3c06380bc3270b40370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c6b82ba149cfa113f8f48d5e3b1f78e933e16dfd00000000000000000000000000000000000000000000000000000000000000648d0dc49f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a581c4a4db7175302464ff3c06380bc3270b40370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
const callData = "0x7bb3742800000000000000000000000038869bf66a61cf6bdb996a6ae40d5853fd43b52600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000002c48d80ff0a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000264001c7d4b196cb0c7b01d743fbc6116a902379c723800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000b531870897eb944799239fa5485792ba495a741100000000000000000000000000000000000000000000000000000000000186a0001c7d4b196cb0c7b01d743fbc6116a902379c723800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000b531870897eb944799239fa5485792ba495a741100000000000000000000000000000000000000000000000000000000000186a0001c7d4b196cb0c7b01d743fbc6116a902379c723800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000b531870897eb944799239fa5485792ba495a741100000000000000000000000000000000000000000000000000000000000186a0001c7d4b196cb0c7b01d743fbc6116a902379c723800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000b531870897eb944799239fa5485792ba495a741100000000000000000000000000000000000000000000000000000000000186a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
const callGasLimit = 140240
const verificationGasLimit = 542895
const preVerificationGas = 66374
const maxFeePerGas = 51026511147
const maxPriorityFeePerGas = 1380000000
const paymasterAndData = "0xDFF7FA1077Bce740a6a212b3995990682c0Ba66d000000000000000000000000000000000000000000000000000000006633b1a7000000000000000000000000000000000000000000000000000000000000000066a61c76c14b64bbe67a7c45c5bdc30c890bfde5b9cb66bfdca69d404f9aeb7a0e9a6e6391030f9cce5e64cab2e1f733c63c5a6c88867bde4bbd01be03cf6fa41b"
const signature = "0x0bf06e2de4850291c2ae290ea44bc6f4e47da7c0dbfa0ceea60a04ce333435ca4d44f3124c9f34cbd5b4660d09f98ee34dd71c63bb0ccc4392072acbc4f9e52b1c"
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
const validAfter = "2024-02-23T04:40:36.000Z"
const validUntil = "2024-07-11T02:00:36.000Z"
const moduleAddress = "0xa581c4A4DB7175302464fF3C06380BC3270b4037"

const getSampleValue = param => {
switch (param) {
case 'nonce':
return 10
case 'safe':
return sampleSafe
case 'address':
Expand All @@ -55,6 +77,10 @@ const getSampleValue = param => {
return sampleModuleTransactionId
case 'safe_tx_hash':
return sampleSafeTxHash
case 'safe_operation_hash':
return sampleSafeOperationHash
case 'user_operation_hash':
return sampleUserOperationHash
case 'safeAppId':
return sampleSafeAppId
case 'uuid':
Expand All @@ -71,6 +97,32 @@ const getSampleValue = param => {
return sampleValue
case 'operation':
return sampleOperation
case 'initCode':
return initCode
case 'callData':
return callData
case 'callGasLimit':
return callGasLimit
case 'verificationGasLimit':
return verificationGasLimit
case 'preVerificationGas':
return preVerificationGas
case 'maxFeePerGas':
return maxFeePerGas
case 'maxPriorityFeePerGas':
return maxPriorityFeePerGas
case 'paymasterAndData':
return paymasterAndData
case 'signature':
return signature
case 'entryPoint':
return entryPoint
case 'validAfter':
return validAfter
case 'validUntil':
return validUntil
case 'moduleAddress':
return moduleAddress
default:
return ''
}
Expand All @@ -85,16 +137,17 @@ const generateSampleApiResponse = async (
const fetch = await import('node-fetch')

let response
const url = `https://safe-transaction-mainnet.safe.global/api${pathWithParams}`
const url = baseUrl + pathWithParams
if (method === 'get') {
response = await fetch.default(url).then(async res => {
if (res.status === 200) return await res?.json()
else {
console.error(
'Error generating response for',
pathWithParams,
method,
path,
':',
res.statusText
await res.text()
)
}
})
Expand All @@ -112,9 +165,10 @@ const generateSampleApiResponse = async (
else {
console.error(
'Error generating response for',
method,
path,
':',
res.statusText
await res.text()
)
}
})
Expand Down
Loading

0 comments on commit ac2d9bd

Please sign in to comment.