2023-09-06 17:10:41 +00:00
|
|
|
import { createOperation, z } from '../generated/wundergraph.factory';
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
|
|
export default createOperation.query({
|
|
|
|
input: z.object({
|
|
|
|
address: z.string(),
|
|
|
|
}),
|
|
|
|
handler: async ({ input }) => {
|
2023-09-13 11:49:56 +00:00
|
|
|
console.log('Making request with input:', input); // Log the input
|
|
|
|
|
2023-09-06 17:10:41 +00:00
|
|
|
const { data } = await axios.get('https://api.gnosisscan.io/api', {
|
|
|
|
params: {
|
|
|
|
module: 'account',
|
|
|
|
action: 'balance',
|
|
|
|
address: input.address,
|
2023-09-13 11:49:56 +00:00
|
|
|
// tag: 'latest',
|
|
|
|
// apikey: process.env.GNOSISSCAN_API,
|
2023-09-06 17:10:41 +00:00
|
|
|
},
|
2023-09-13 11:49:56 +00:00
|
|
|
timeout: 10000,
|
2023-09-06 17:10:41 +00:00
|
|
|
});
|
2023-09-13 11:49:56 +00:00
|
|
|
|
|
|
|
console.log('Received response:', data);
|
2023-09-06 17:10:41 +00:00
|
|
|
return {
|
|
|
|
balance: parseFloat(data.result),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|