vault icon indicating copy to clipboard operation
vault copied to clipboard

Implement /get_whitelisted_contracts Endpoint

Open 0xLucqs opened this issue 10 months ago • 2 comments

Description

We need to implement the /get_whitelisted_contracts endpoint in the Vault backend. This endpoint is responsible for retrieving the whitelisted contracts associated with a specific account.

Details

  • Method: GET
  • Path: /get_whitelisted_contracts
  • Summary: Get whitelisted contracts.

Request Parameters:

  • address: The Starknet address for which the whitelisted contracts are to be retrieved.

Response:

  • Status Code: 200
  • Description: Successful retrieval of whitelisted contracts
  • Content Type: application/json
  • Body:
{
  "page_count": 5,
  "contracts": [
    "0x0123456789abcdefABCDEF0123456789abcdefABCDEF0123456789abcdefABCD",
    "0x1234567890abcdefABCDEF0123456789abcdefABCDEF0123456789abcdefABC",
    ...
  ]
}

Notes:

The whitelisted contracts are represented as an array of Starknet addresses in hexadecimal format.

Example

// Import necessary modules
import fastify from 'fastify';

// Create Fastify instance
const app = fastify({ logger: true });

// Define the get_whitelisted_contracts endpoint
app.get('/get_whitelisted_contracts', async (request, reply) => {
    try {
        // Logic to retrieve the whitelisted contracts goes here

        // Return the whitelisted contracts
        return {
            page_count: 5,
            contracts: [
                "0x0123456789abcdefABCDEF0123456789abcdefABCDEF0123456789abcdefABCD",
                "0x1234567890abcdefABCDEF0123456789abcdefABCDEF0123456789abcdefABC",
                ...
            ]
        };
    } catch (error) {
        // Handle errors
        console.error('Error while retrieving whitelisted contracts:', error);
        return reply.status(500).send({ error: 'Internal Server Error' });
    }
});

Tasks:

  • [ ] Implement the /get_whitelisted_contracts endpoint.

0xLucqs avatar Apr 02 '24 14:04 0xLucqs