diff --git a/packages/tokens-to-rent-service/src/index.ts b/packages/tokens-to-rent-service/src/index.ts index 37b79fd23..e288f6887 100644 --- a/packages/tokens-to-rent-service/src/index.ts +++ b/packages/tokens-to-rent-service/src/index.ts @@ -1,19 +1,19 @@ -import cors from '@fastify/cors'; -import { PublicKey } from '@solana/web3.js'; -import Fastify, { FastifyInstance } from 'fastify'; -import * as jup from './jupiter'; -import { HNT_MINT, IOT_MINT, MOBILE_MINT } from '@helium/spl-utils'; +import cors from "@fastify/cors"; +import { PublicKey } from "@solana/web3.js"; +import Fastify, { FastifyInstance } from "fastify"; +import * as jup from "./jupiter"; +import { HNT_MINT, IOT_MINT, MOBILE_MINT } from "@helium/spl-utils"; const server: FastifyInstance = Fastify({ logger: true }); -server.register(cors, { origin: '*' }); +server.register(cors, { origin: "*" }); -server.get('/health', async (req, res) => { +server.get("/health", async (req, res) => { res.send({ ok: true }); }); server.post<{ Body: { wallet: string; mint: string }; -}>('/fees', async (req, res) => { +}>("/fees", async (req, res) => { try { const { wallet, mint } = req.body; const walletPk = new PublicKey(wallet); @@ -32,7 +32,7 @@ server.post<{ server.post<{ Body: { mint: string }; -}>('/estimate', async (req, res) => { +}>("/estimate", async (req, res) => { try { const { mint } = req.body; const mintPk = new PublicKey(mint); @@ -46,7 +46,7 @@ server.post<{ } }); -server.get<{}>('/estimates', async (req, res) => { +server.get<{}>("/estimates", async (req, res) => { try { res.send({ [HNT_MINT.toBase58()]: await jup.estimate({ mint: HNT_MINT }), @@ -63,11 +63,11 @@ const start = async () => { try { await server.listen({ port: Number(process.env.PORT) || 8081, - host: '0.0.0.0', + host: "0.0.0.0", }); const address = server.server.address(); - const port = typeof address === 'string' ? address : address?.port; + const port = typeof address === "string" ? address : address?.port; console.log(`Running on 0.0.0.0:${port}`); } catch (err) { server.log.error(err); diff --git a/packages/tokens-to-rent-service/src/jupiter.ts b/packages/tokens-to-rent-service/src/jupiter.ts index d05a3b1e3..d03953bfa 100644 --- a/packages/tokens-to-rent-service/src/jupiter.ts +++ b/packages/tokens-to-rent-service/src/jupiter.ts @@ -1,11 +1,11 @@ -import { HNT_MINT, IOT_MINT, MOBILE_MINT, toBN } from '@helium/spl-utils'; +import { HNT_MINT, IOT_MINT, MOBILE_MINT, toBN } from "@helium/spl-utils"; import { Configuration, DefaultApi, Instruction, AccountMeta, -} from '@jup-ag/api'; -import { ACCOUNT_SIZE, NATIVE_MINT, getMint } from '@solana/spl-token'; +} from "@jup-ag/api"; +import { ACCOUNT_SIZE, NATIVE_MINT, getMint } from "@solana/spl-token"; import { AddressLookupTableAccount, PublicKey, @@ -13,9 +13,9 @@ import { TransactionInstruction, TransactionMessage, VersionedTransaction, -} from '@solana/web3.js'; -import { JUPITER_FEE_ACCOUNT, JUPITER_FEE_BPS, JUPITER_URL } from './env'; -import { provider } from './solana'; +} from "@solana/web3.js"; +import { JUPITER_FEE_ACCOUNT, JUPITER_FEE_BPS, JUPITER_URL } from "./env"; +import { provider } from "./solana"; export const instructionDataToTransactionInstruction = ( instruction: Instruction | undefined @@ -28,7 +28,7 @@ export const instructionDataToTransactionInstruction = ( isSigner: key.isSigner, isWritable: key.isWritable, })), - data: Buffer.from(instruction.data, 'base64'), + data: Buffer.from(instruction.data, "base64"), }); }; @@ -94,7 +94,7 @@ export const estimate = async ({ platformFeeBps: Number(JUPITER_FEE_BPS) || 0, }); - if (!quote) throw new Error('Unable to quote'); + if (!quote) throw new Error("Unable to quote"); return quote.outAmount; }; @@ -127,6 +127,7 @@ export const fundFees = async ({ outputMint: NATIVE_MINT.toBase58(), slippageBps: 100, // 1% platformFeeBps: Number(JUPITER_FEE_BPS) || 0, + maxAccounts: 20, }); // Tx contains instructions to create/close WSOL token account