Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new release #423

Closed
wants to merge 11 commits into from
173 changes: 173 additions & 0 deletions apps/axelarscan-amplifier-apis/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
\*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
\*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

\*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

\*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.cache
.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

.cache/

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp
.cache

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*

# wrangler project

.dev.vars

.wrangler
21 changes: 21 additions & 0 deletions apps/axelarscan-amplifier-apis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Gas price API

This project is a thin API that exposes gas prices and costs for Amplifier chains.

## To run the project locally

1. Sign up for [Cloudflare Workers](https://workers.dev). The free tier is more than enough for most use cases.
2. Clone this project and install dependencies with `npm install`
3. Run `wrangler login` to login to your Cloudflare account in wrangler
4. Run `wrangler deploy` to publish the API to Cloudflare Workers

## Project structure

1. Your main router is defined in `src/index.ts`.
2. Each endpoint has its own file in `src/endpoints/`.

## Development

1. Run `wrangler dev` to start a local instance of the API.
2. Open `http://localhost:PORT/` in your browser to see the Swagger interface where you can try the endpoints.
3. Changes made in the `src/` folder will automatically trigger the server to reload, you only need to refresh the Swagger interface.
20 changes: 20 additions & 0 deletions apps/axelarscan-amplifier-apis/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "axelarscan-amplifier-apis",
"version": "0.0.1",
"private": true,
"scripts": {
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev",
"cf-typegen": "wrangler types"
},
"dependencies": {
"@cloudflare/itty-router-openapi": "^1.0.1"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240524.0",
"@types/node": "^20.5.7",
"@types/service-worker-mock": "^2.0.1",
"wrangler": "^3.0.0"
}
}
92 changes: 92 additions & 0 deletions apps/axelarscan-amplifier-apis/src/configs/feesAndPrices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
const feesAndPrices = {
testnet: [],
stagenet: [
{
name: "test-avalanche",
amplifierChainId: "test-avalanche",
description: null,
gasPriceGwei: 25,
approvalCost: 425000,
updated: "2024-08-05",
},
{
name: "test-sepolia",
amplifierChainId: "test-sepolia",
description: null,
gasPriceGwei: 5.02,
approvalCost: 1300000,
updated: "2024-08-05",
},
],
"devnet-verifiers": [
{
name: "Avalanche",
amplifierChainId: "avalanche",
description: null,
gasPriceGwei: 25,
approvalCost: 425000,
updated: "2024-08-05",
},
{
name: "fantom",
amplifierChainId: "fantom",
description: null,
gasPriceGwei: 1.03,
approvalCost: 1300000,
updated: "2024-08-05",
},
{
name: "ethereum-sepolia",
amplifierChainId: "ethereum-sepolia",
description: null,
gasPriceGwei: 11.5,
approvalCost: 200000,
updated: "2024-08-05",
},
{
name: "op-sepolia",
amplifierChainId: "op-sepolia",
description: null,
gasPriceGwei: 0.001,
approvalCost: 300000,
updated: "2024-08-05",
},
],
"devnet-amplifier": [
{
name: "Avalanche",
amplifierChainId: "avalanche",
description: null,
gasPriceGwei: 25,
approvalCost: 425000,
updated: "2024-08-05",
},
{
name: "fantom",
amplifierChainId: "fantom",
description: null,
gasPriceGwei: 1.03,
approvalCost: 1300000,
updated: "2024-08-05",
},
{
name: "ethereum-sepolia",
amplifierChainId: "ethereum-sepolia",
description: null,
gasPriceGwei: 6.4,
approvalCost: 200000,
updated: "2024-08-05",
},
{
name: "op-sepolia",
amplifierChainId: "op-sepolia",
description: null,
gasPriceGwei: 0.001,
approvalCost: 300000,
updated: "2024-08-05",
},
],
mainnet: [],
};

export default feesAndPrices;
49 changes: 49 additions & 0 deletions apps/axelarscan-amplifier-apis/src/endpoints/gasPricesAllChains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {
OpenAPIRoute,
OpenAPIRouteSchema,
Query,
} from "@cloudflare/itty-router-openapi";
import feesAndPrices from "configs/feesAndPrices";
import getEnvironmentFromUrl from "utils";

import { Chain } from "../types";

export class ChainList extends OpenAPIRoute {
static schema: OpenAPIRouteSchema = {
tags: ["Chains"],
summary:
"All supported Amplifier chains with approval cost and gas price constants",
parameters: {
page: Query(Number, {
description: "Page number",
default: 0,
required: false,
}),
},
responses: {
"200": {
description: "Returns a list of chains and their gas prices",
schema: {
success: Boolean,
result: {
chains: [Chain],
},
},
},
},
};

handle(
request: Request,
env: unknown,
context: unknown,
data: Record<string, any>
) {
const environment = getEnvironmentFromUrl(request.url) as string;
const chains = feesAndPrices[environment] as (typeof Chain)[];
return {
success: true,
chains: chains,
};
}
}
Loading