Skip to content

Commit

Permalink
chore: release landing v1.0 (#302)
Browse files Browse the repository at this point in the history
* chore: add @types/uuid

* chore: add @types/uuid

* fix(app-lib): tsconfig pkg extends

* fix: missing encoding dep

* feat: sitemap (#290)

* feat: add sitemap

* fix: error handling

* fix: move common types

* fix: update base url in sitemap

* Update apps/webapp/app/(routes)/[lang]/blog/[category]/sitemap.ts

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Update apps/webapp/app/(routes)/[lang]/wallet/sitemap.ts

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Update apps/webapp/app/(routes)/[lang]/whitepaper/sitemap.ts

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* fix: build error

* fix: remove unnecessary async declarative

* vendor: add @types/uuid

* fix: remove console log for debug

* fix: add 'async' to all sitemaps

* fix: make ProjectPageParams extends CommonPageParams

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* fix(webapp): UI/UX tweaks and upts from final v1 landing designs (#291)

* (webapp)fix:FAQ border radi + muted color

* (webapp)fix:newsletter spacing

* (webapp)fix:participate spacing and font family

* (webapp)fix:header spacing + bitlauncher logo size

* (webapp)fix:blog section 4 per row + purple link + gap

* (webapp)fix:hero-card spacing

* (webapp)fix:auction-card spaces

* (webapp)fix:Upcoming grid gap

* (webapp)fix:article card - text-left

* (webapp)fix:media-card text-start

* (webapp)fix:media-section purple link + space

* (webapp)fix:participate gap + section font and padding

* (webapp)fix:footer links padding + other spacing fix

* (webapp)fix:upcoming background circle

* (webapp)fix:footer margin-10

* (webapp)fix:upcoming bg shape

* (webapp)-andler-changes-request

* (webapp)-debug-toggle navigation icon

* (webapp)-create-mobile-navigation-context

* (webapp)-create-mobile-navigation-context

* (webapp)-fix navigation bug - add key

* (webapp)-Andler-changes

* (webapp)-responsive - upcoming

* (webapp)-fix-responsive-whychooseUs

* (webapp)-fix-responsive-participate

* (webapp)-fix-responsive-media

* (webapp)-fix-responsive-articles

* (webapp)-responsive-project-header+info+sharebtn

* (webapp)-feat-about-base

* (webapp)-feat-about-landing-complete

* (webapp)-feat-security-updated

* (webapp)-fix-steps-padding

* fix typo

* fix bgHeader type

* fix bgHeader type

* impr(webapp): layout tweaks

* impr(webapp): info pages img asset + css class

* fix: bun.lockb

---------

Co-authored-by: Roberto Lucas <[email protected]>

* feat: multichain indexer ( part 1 ) (#293)

* chore: update app-contracts

* feat: multichain indexer

* feat: prod chains

* feat: presale wallet

* feat: blpl token

* feat: blpl token

* chore: update bunlock

* feat: blpl token

* feat: presale evm contribs

* feat: blpl token

* wip: presale indexer

* chore(indexer): fix dockerfile

* feat: presale transaction indexing (#296)

* feat: report transaction id

* feat: save deposits data

* feat: save deposits data

* feat: read presale transactions

* chore: disable view all

* feat: update presale deposits ui

* feat: display amount raised and contributors

* chore: environment chains and tokens

* fix(webapp): desktop padding (#297)

* feat: multichain presale deposits (#298)

* chore: environment chains and tokens

* fix: chain switch

* fix: chain switch

* feat: update nav links (#299)

* chore: environment chains and tokens

* feat: update nav links

* chore: renable swaps service, index token from latest block

* feat(webapp): wallet ui updates (#300)

* fix: wagmi config

* feat(webapp): presale contribution report

* feat: realtime presale data

* feat: realtime presale data

* feat: update dropdown menu

* feat(supabase): update schema and types

* chore: debug presale token issuance

* feat: show issuance trx link on table

---------

Co-authored-by: Gabo Esquivel <[email protected]>
Co-authored-by: Nathanael Liu <[email protected]>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: Brandon Fernández <[email protected]>
  • Loading branch information
5 people authored Aug 6, 2024
1 parent 3294283 commit 032d099
Show file tree
Hide file tree
Showing 141 changed files with 2,273 additions and 1,537 deletions.
1 change: 1 addition & 0 deletions apps/indexer/.env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ SEPOLIA_RPC=https://eth-sepolia.g.alchemy.com/v2/xxx
ISSUER_KEY=xxx
ISSUER_ADDRESS=0x
DFUSE_API_KEY=server_xxx
ALCHEMY_API_KEY=xxx
1 change: 0 additions & 1 deletion apps/indexer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ COPY apps/indexer/package.json ./apps/indexer/package.json
COPY packages/app-env/package.json ./packages/app-env/package.json
COPY packages/app-contracts/package.json ./packages/app-contracts/package.json
COPY packages/app-lib/package.json ./packages/app-lib/package.json
COPY packages/tsconfig/package.json ./packages/tsconfig/package.json
COPY packages/config-typescript/package.json ./packages/config-typescript/package.json
COPY packages/config-eslint/package.json ./packages/config-eslint/package.json

Expand Down
6 changes: 3 additions & 3 deletions apps/indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"@repo/supabase": "workspace:*",
"@sentry/node": "^8.19.0",
"@supabase/supabase-js": "^2.44.4",
"app-contracts": "workspace:*",
"app-env": "workspace:*",
"app-lib": "workspace:*",
"axios": "^1.7.2",
"bn.js": "^5.2.1",
"express": "^4.19.2",
"lodash": "^4.17.21",
"node-fetch": "2.6.4",
"resend": "^3.5.0",
"app-contracts": "workspace:*",
"app-env": "workspace:*",
"app-lib": "workspace:*",
"viem": "latest",
"ws": "^8.18.0"
},
Expand Down
6 changes: 4 additions & 2 deletions apps/indexer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { getErrorMessage } from 'app-lib'
import { startAuctionIndexer } from './modules/auction'
// import { startAuctionIndexer } from './modules/auction'
import { startSwapsService } from './modules/swaps'
import { startExpress } from './routes/healthcheck'
import { startPresaleService } from './modules/presale'

async function main() {
console.log(`Launchpad indexer starting up ...`)
try {
startExpress()
startAuctionIndexer()
startPresaleService()
startSwapsService()
// startAuctionIndexer()
} catch (error) {
console.log('ERROR:' + getErrorMessage(error), JSON.stringify(error))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
import { http, createPublicClient, PublicClient, createWalletClient } from 'viem'
import { sepolia } from 'viem/chains'
import { appenv } from '../config'
import { eosEvmTestnet } from 'app-env'

export const client: PublicClient = createPublicClient({
chain: eosEvmTestnet,
transport: http(),
})

export const walletClient = createWalletClient({
chain: eosEvmTestnet,
transport: http(),
key: appenv.evm.issuerKey,
account: appenv.evm.issuerAccount,
})

export const sepoliaClient: PublicClient = createPublicClient({
chain: {
...sepolia,
rpcUrls: {
default: {
http: [appenv.evm.sepoliaApi],
},
},
},
transport: http(),
})

export async function getCurrentBlockHeight() {
try {
const client = createPublicClient({
chain: eosEvmTestnet,
transport: http(),
})
const blockNumber = await client.getBlockNumber()
return blockNumber
} catch (error) {
Expand Down
14 changes: 14 additions & 0 deletions apps/indexer/src/lib/supabase-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ export async function upsertOrder(data: TablesInsert<'order'>) {

return data
}

export async function upsertTransfers(data: TablesInsert<'transfer'>) {
console.log('upsert transfers', data)
const { data: result, error } = await supabase
.from('transfer')
.upsert(data, { onConflict: 'trx_hash' })
.select()

if (error) console.error('Error:', error)

console.log('Result:', result)

return data
}
8 changes: 6 additions & 2 deletions apps/indexer/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs/promises'
import { erc20Abi } from 'abitype/abis'
import { client } from './evm-client'
import { Abi, Address, parseUnits } from 'viem'
import {Abi, Address, parseUnits, http, createPublicClient} from 'viem';
import {eosEvmTestnet} from 'app-env';

export async function writeToFile(data: string, filePath: string) {
try {
Expand Down Expand Up @@ -38,6 +38,10 @@ export function runPromisesInSeries<T>(
}

export async function getTokenDetails({ address }: { address: Address }) {
const client = createPublicClient({
chain: eosEvmTestnet,
transport: http(),
})
const results = await client.multicall({
contracts: [
{
Expand Down
12 changes: 8 additions & 4 deletions apps/indexer/src/modules/auction/auction-indexer.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { Log, stringify } from 'viem'
import { client } from '~/lib/evm-client'
import {Log, stringify, http, createPublicClient} from 'viem';
import { TestnetEasyAuction } from 'app-contracts'
import {
bigintToPostgresTimestamp,
getEvents,
getTokenDetails,
runPromisesInSeries,
} from '~/lib/utils'
import { NewAuctionEvent, NewSellOrderEvent, NewUserEvent } from '~/modules/auction/auction.type'

import { NewAuctionEvent, NewSellOrderEvent, NewUserEvent } from './auction.type'
import BN from 'bn.js'
import { eosEvmTestnet } from 'app-env'
import { upsertAuctionDetail, upsertOrder } from '~/lib/supabase-client'

export async function startAuctionIndexer() {
console.log('indexing starting')

// TODO: create client for
const client = createPublicClient({
chain: eosEvmTestnet,
transport: http(),
})

// await writeToFile(stringify(TestnetEasyAuction.getEvents(), null, 2), './events.json')
// Get historical event logs
const blockNumber = await client.getBlockNumber()
Expand Down
9 changes: 7 additions & 2 deletions apps/indexer/src/modules/auction/easyauction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { getContract } from 'viem'
import { client } from '../../lib/evm-client'
import {getContract, http, createPublicClient} from 'viem';
import { TestnetEasyAuction } from 'app-contracts'
import {eosEvmTestnet} from 'app-env';

const client = createPublicClient({
chain: eosEvmTestnet,
transport: http(),
})

export const easyAuction = getContract({
...TestnetEasyAuction,
Expand Down
6 changes: 3 additions & 3 deletions apps/indexer/src/modules/presale/eos-contributions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { smartsaleEnv } from 'app-env'
import { stringify } from 'viem/utils'
import { createFirehoseSubscription } from '~/lib/dfuse-client'
import { issueTokens } from './presale-issuer'
import { issuePresaleTokens } from './presale-issuer'

// https://docs.dfuse.eosnation.io/platform/public-apis/search-query-language/
// https://docs.dfuse.eosnation.io/eosio/public-apis/reference/search/terms/
// receiver: means the account with code that has executed the action.
export async function listenToEosContributions(env: 'test' | 'prod' = 'test') {
const usdt = smartsaleEnv[env].usdt.find((t) => (t.chainType = 'antelope'))?.address
const usdt = smartsaleEnv[env].stables.find((t) => (t.chainType = 'antelope'))?.address
const bank = smartsaleEnv[env].bitcash.bank
const launchpad = smartsaleEnv[env].smartsale.bk

Expand All @@ -30,7 +30,7 @@ export async function listenToEosContributions(env: 'test' | 'prod' = 'test') {
async function handleDeposit(data: { trxId: string; from: string; quantity: string }) {
console.log('handle deposit', data)

const response = await issueTokens(
const response = await issuePresaleTokens(
'0x7472312e4e1a373df751f84bd871a4c7a16128fa',
BigInt(data.quantity),
)
Expand Down
74 changes: 32 additions & 42 deletions apps/indexer/src/modules/presale/evm-contributions.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
import { EVMTokenContractData, SepoliaUSDT, TestnetUSDT } from 'app-contracts'
import { EVMTokenContractData, appContracts } from 'app-contracts'
import { runPromisesInSeries } from '~/lib/utils'

import { Address, Log, PublicClient, createPublicClient, http, parseAbiItem, stringify } from 'viem'
import { TransferEvent } from '~/modules/auction/auction.type'
import { sepolia } from 'viem/chains'
import { smartsaleChains } from 'app-env'
import { upsertTransfers } from '~/lib/supabase-client'
import { issuePresaleTokens } from './presale-issuer'

const tokens: EVMTokenContractData[] = [SepoliaUSDT, TestnetUSDT]
const presaleWallet = '0xf7bb6BD787FFbA43539219560E3B8162Ba8EEF09'
const tokens: EVMTokenContractData[] = appContracts.dev.tokens.evm && appContracts.prod.tokens.evm

export async function listenToEvmContributions() {
console.log('subscribing to evm usdt transfers ...')
tokens.map(listenToEvmTransfersFn)
}

async function listenToEvmTransfersFn(token: EVMTokenContractData) {
const chain = smartsaleChains.dev.get(token.chainId)
if (!chain) return
console.log(`listening usdt transfers for token ${token.symbol} on chain ${chain.name}`)
console.log(`listening usdt transfers for token ${token.symbol} on chain ${token.chain.name}`)
const client: PublicClient = createPublicClient({
chain,
chain: token.chain,
transport: http(),
})
try {
const latestBlock = await client.getBlockNumber()
const logs = await client.getLogs({
address: token.address,
event: parseAbiItem(
'event Transfer(address indexed from, address indexed to, uint256 value)',
),
args: {
to: '0x2C9DAAb3F463d6c6D248aCbeaAEe98687936374a',
to: presaleWallet,
},
fromBlock: BigInt(token.indexFromBlock),
fromBlock: latestBlock,
})

// delay prevents idempotent transactions:
processLogs(logs, 3000)
processLogs(logs, token, 3000)

// Watch for new event logs
client.watchEvent({
Expand All @@ -43,11 +42,11 @@ async function listenToEvmTransfersFn(token: EVMTokenContractData) {
'event Transfer(address indexed from, address indexed to, uint256 value)',
),
args: {
to: '0x2C9DAAb3F463d6c6D248aCbeaAEe98687936374a',
to: presaleWallet,
},
onLogs: (logs) => {
console.log('real time transfer', stringify(logs, null, 2))
processLogs(logs)
console.log('real time transfer') // stringify(logs, null, 2)
processLogs(logs, token)
},
})
} catch (error) {
Expand All @@ -57,14 +56,15 @@ async function listenToEvmTransfersFn(token: EVMTokenContractData) {

// takes the generic logs and if the eventName matches one of the eventHandlers keys
// it passes the log to corresponding hanlder function
async function processLogs(logs: Log[], delay = 0) {
async function processLogs(logs: Log[], token: EVMTokenContractData, delay = 0) {
const actions = logs
.map((log) => {
const eventName = (log as any).eventName.toString()

if (!(eventName in eventHandlers)) return null
return async () => {
try {
eventHandlers[eventName] && eventHandlers[eventName](log)
eventHandlers[eventName] && eventHandlers[eventName](log, token)
} catch (error) {
//TODO: sent sentry reports
console.error(error)
Expand All @@ -76,42 +76,32 @@ async function processLogs(logs: Log[], delay = 0) {
runPromisesInSeries(actions, delay)
}

const eventHandlers: { [key: string]: (log: any) => void } = {
const eventHandlers: { [key: string]: (log: any, token: EVMTokenContractData) => void } = {
Transfer: handleTransfer,
}

async function handleTransfer(log: TransferEvent) {
const data = {
async function handleTransfer(log: TransferEvent, token: EVMTokenContractData) {
console.log('handle transfer', log)
const bl_presale_trx = (await issuePresaleTokens(
log.args.from as Address,
log.args.value,
)) as Address

upsertTransfers({
trx_hash: log.transactionHash!,
from: log.args.from as Address,
to: log.args.to as Address,
amount: log.args.value,
amount: Number(log.args.value),
token: log.address,
chain_id: sepolia.id,
type: 'deposit',
}

// const result = await db.transfers.upsert({
// where: {
// trx_hash: log.transactionHash!,
// },
// update: data,
// create: data,
// })
chain_id: token.chainId,
type: 'presale',
bl_presale_trx,
})

// console.log('result', result)
// if (result.usdcred_trx || data.from === '0x0000000000000000000000000000000000000000') return

// const usdcred_trx = (await issueTokens(data.from, data.amount)) as Address

// if (!usdcred_trx) return

// await db.transfers.update({
// where: {
// trx_hash: log.transactionHash!,
// },
// data: { usdcred_trx },
// })
//

// console.log('tokens issued', { usdcred_trx, trx: log.transactionHash })
}
3 changes: 2 additions & 1 deletion apps/indexer/src/modules/presale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { listenToEosContributions } from './eos-contributions'
import { listenToEvmContributions } from './evm-contributions'

export function startPresaleService() {
listenToEosContributions()
console.log('starting presale service')
// listenToEosContributions()
listenToEvmContributions()
}
8 changes: 4 additions & 4 deletions apps/indexer/src/modules/presale/presale-issuer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TestnetUSDCred } from 'app-contracts'
import { TestnetBLPL } from 'app-contracts'
import { eosEvmTestnet } from 'app-env'
import { createWalletClient } from 'viem'
import { appenv } from '~/config'
import { Address, http } from 'viem'

export async function issueTokens(to: Address, amount: bigint) {
export async function issuePresaleTokens(to: Address, amount: bigint) {
console.log('issueTokens', {
args: [to, amount],
})
Expand All @@ -17,8 +17,8 @@ export async function issueTokens(to: Address, amount: bigint) {
account: appenv.evm.issuerAccount,
})
return walletClient.writeContract({
address: TestnetUSDCred.address,
abi: TestnetUSDCred.abi,
address: TestnetBLPL.address,
abi: TestnetBLPL.abi,
functionName: 'issue',
args: [to, amount],
})
Expand Down
2 changes: 1 addition & 1 deletion apps/indexer/src/modules/swaps/eos-transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { issueTokens } from './cred-issuer'
// https://docs.dfuse.eosnation.io/eosio/public-apis/reference/search/terms/
// receiver: means the account with code that has executed the action.
export async function listenToEosTransfers(env: 'test' | 'prod' = 'test') {
const usdt = smartsaleEnv[env].usdt.find((t) => (t.chainType = 'antelope'))?.address
const usdt = smartsaleEnv[env].stables.find((t) => (t.chainType = 'antelope'))?.address
const bank = smartsaleEnv[env].bitcash.bank
const launchpad = smartsaleEnv[env].smartsale.bk

Expand Down
Loading

0 comments on commit 032d099

Please sign in to comment.