diff --git a/docs/bridge/docs/02-Bridge/02-REST-API.md b/docs/bridge/docs/02-Bridge/02-REST-API.md index fc9ffbe3ce..85997870b6 100644 --- a/docs/bridge/docs/02-Bridge/02-REST-API.md +++ b/docs/bridge/docs/02-Bridge/02-REST-API.md @@ -26,7 +26,8 @@ The API is available at [`https://api.synapseprotocol.com/`](https://api.synapse | Date | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | 2024‑10‑01 | [https://synapse-rest-api-v2.herokuapp.com/](https://synapse-rest-api-v2.herokuapp.com/) is no longer maintained and has been fully deprecated as of October 2024. | -| 2024‑11‑19 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/) the /bridgeTxInfo endpoint has been consolidated into the /bridge endpoint, which now returns call data | +| 2024‑11‑19 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/) the /bridgeTxInfo endpoint has been consolidated into the /bridge endpoint, which now returns call data | +| 2024‑12‑12 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/bridge) the /bridge endpoint now requires both `originUserAddress` and `destAddress` to generate call data. | ## Support diff --git a/packages/rest-api/src/controllers/bridgeController.ts b/packages/rest-api/src/controllers/bridgeController.ts index 44aabb5ea4..5daf5c478c 100644 --- a/packages/rest-api/src/controllers/bridgeController.ts +++ b/packages/rest-api/src/controllers/bridgeController.ts @@ -53,18 +53,19 @@ export const bridgeController = async (req, res) => { quote.originQuery.tokenOut ) - const callData = destAddress - ? await Synapse.bridge( - destAddress, - quote.routerAddress, - Number(fromChain), - Number(toChain), - fromToken, - amountInWei, - quote.originQuery, - quote.destQuery - ) - : null + const callData = + destAddress && originUserAddress + ? await Synapse.bridge( + destAddress, + quote.routerAddress, + Number(fromChain), + Number(toChain), + fromToken, + amountInWei, + quote.originQuery, + quote.destQuery + ) + : null return { ...quote, diff --git a/packages/rest-api/src/routes/bridgeRoute.ts b/packages/rest-api/src/routes/bridgeRoute.ts index 4d534306fc..f3659ab90a 100644 --- a/packages/rest-api/src/routes/bridgeRoute.ts +++ b/packages/rest-api/src/routes/bridgeRoute.ts @@ -56,13 +56,13 @@ const router: express.Router = express.Router() * required: false * schema: * type: string - * description: The address of the user on the origin chain + * description: The address of the user on the origin chain (required to generate callData) * - in: query * name: destAddress * required: false * schema: * type: string - * description: The destination address for the bridge transaction + * description: The destination address for the bridge transaction (required to generate callData) * responses: * 200: * description: Successful response diff --git a/packages/rest-api/src/tests/bridgeRoute.test.ts b/packages/rest-api/src/tests/bridgeRoute.test.ts index ce6fc247d4..39377b78c2 100644 --- a/packages/rest-api/src/tests/bridgeRoute.test.ts +++ b/packages/rest-api/src/tests/bridgeRoute.test.ts @@ -174,7 +174,7 @@ describe('Bridge Route with Real Synapse Service', () => { expect(response.body.error).toHaveProperty('field', 'amount') }) - it('should return bridge quotes with callData when destAddress is provided', async () => { + it('should return bridge quotes with callData when originUserAddress and destAddress are provided', async () => { const response = await request(app).get('/bridge').query({ fromChain: '1', toChain: '10', @@ -182,6 +182,7 @@ describe('Bridge Route with Real Synapse Service', () => { toToken: USDC.addresses[10], amount: '1000', destAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + originUserAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', }) expect(response.status).toBe(200) @@ -200,6 +201,23 @@ describe('Bridge Route with Real Synapse Service', () => { fromToken: USDC.addresses[1], toToken: USDC.addresses[10], amount: '1000', + originUserAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + }) + + expect(response.status).toBe(200) + expect(Array.isArray(response.body)).toBe(true) + expect(response.body.length).toBeGreaterThan(0) + expect(response.body[0].callData).toBeNull() + }, 15000) + + it('should return bridge quotes without callData when originUserAddress is not provided', async () => { + const response = await request(app).get('/bridge').query({ + fromChain: '1', + toChain: '10', + fromToken: USDC.addresses[1], + toToken: USDC.addresses[10], + amount: '1000', + destAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', }) expect(response.status).toBe(200) diff --git a/packages/rest-api/swagger.json b/packages/rest-api/swagger.json index 2cb16577c3..01039d46c2 100644 --- a/packages/rest-api/swagger.json +++ b/packages/rest-api/swagger.json @@ -201,7 +201,7 @@ { "in": "query", "name": "destAddress", - "required": true, + "required": false, "schema": { "type": "string" },