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-20 18:56:27 +00:00
|
|
|
console.log('Making request with input:', input);
|
2023-09-13 11:49:56 +00:00
|
|
|
|
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-20 18:56:27 +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),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|