wallet.andert.me/.wundergraph/operations/getBalance.ts

27 lines
672 B
TypeScript
Raw Normal View History

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);
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,
},
timeout: 10000,
});
console.log('Received response:', data);
return {
balance: parseFloat(data.result),
};
},
});