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

Bfe 252 hub add support for renamed contract functions #214

Merged
merged 19 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.bartio
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ NEXT_PUBLIC_MULTICALL_CREATION_BLOCK="6983"
NEXT_PUBLIC_DYNAMIC_API_KEY="b8a5104d-47e0-4965-b56a-0bcc31cf56f4"

# Honey Addresses ===================================================================
NEXT_PUBLIC_HONEY_ROUTER_ADDRESS="0xAd1782b2a7020631249031618fB1Bd09CD926b31"
# this was actually deployed as honey router on bartio
NEXT_PUBLIC_HONEY_FACTORY_ADDRESS="0xAd1782b2a7020631249031618fB1Bd09CD926b31"
# Honey Tokens ======================================================================
NEXT_PUBLIC_HONEY_ADDRESS="0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03"
NEXT_PUBLIC_WBERA_ADDRESS="0x7507c1dc16935B82698e4C63f2746A2fCf994dF8"
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/ipfs-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Deploy on Fleek

on:
push:
branches: [ "v2" ]
# push:
# branches: [ "v2" ]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -32,14 +32,11 @@ jobs:
node-version: 18.18.2
cache: 'pnpm'

- name: Install dependencies
run: pnpm install
- name: Install
run: bash ./.scripts/vercel-install.sh ${{ secrets.ENV_NAME }}

- name: Install Fleek CLI
run: pnpm i -g @fleek-platform/[email protected]

- name: Set environment variables
run: pnpm setenv:bartio

- name: Build all projects
env:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/ipfs-static-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ jobs:
with:
node-version: 18.18.2
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Set environment variables
run: pnpm setenv:bartio
- name: Install
run: bash ./.scripts/vercel-install.sh ${{ secrets.ENV_NAME }}

- name: Build all projects
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { type BeraConfig } from "@bera/berajs";
export const beraConfig: BeraConfig = {
contracts: {
multicallAddress: "0x...",
honeyRouterAddress: "0x...",
honeyFactoryAddress: "0x...",
},
};
```
Expand All @@ -47,7 +47,7 @@ const publicClient = createPublicClient({
export const beraConfig: BeraConfig = {
contracts: {
multicallAddress: "0x...",
honeyRouterAddress: "0x...",
honeyFactoryAddress: "0x...",
},
};

Expand Down
4 changes: 2 additions & 2 deletions apps/berajs-docs/docs/pages/actions/honey/getHoneyPreview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { type BeraConfig } from "@bera/berajs";

export const beraConfig: BeraConfig = {
contracts: {
honeyRouterAddress: "0x...",
honeyFactoryAddress: "0x...",
},
};
```
Expand All @@ -45,7 +45,7 @@ const publicClient = createPublicClient({
// required configs for getHoneyPreview
export const beraConfig: BeraConfig = {
contracts: {
honeyRouterAddress: "0x...",
honeyFactoryAddress: "0x...",
},
};

Expand Down
18 changes: 9 additions & 9 deletions apps/honey/src/components/honey-machine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import { useEffect, useState } from "react";
import {
honeyRouterAbi,
honeyFactoryAbi,
TransactionActionType,
truncateHash,
} from "@bera/berajs";
import { honeyRouterAddress } from "@bera/config";
import { honeyFactoryAddress } from "@bera/config";
import {
ConnectButton,
SSRSpinner,
Expand Down Expand Up @@ -199,7 +199,7 @@ export function HoneyMachine() {
abi: erc20Abi as unknown as (typeof erc20Abi)[],
functionName: "approve",
params: [
honeyRouterAddress,
honeyFactoryAddress,
parseUnits(
`${fromAmount ?? "0"}` as `${number}`,
selectedFrom?.decimals ?? 18,
Expand All @@ -210,18 +210,18 @@ export function HoneyMachine() {

const performMinting = () =>
write({
address: honeyRouterAddress,
abi: honeyRouterAbi,
address: honeyFactoryAddress,
abi: honeyFactoryAbi,
functionName: "mint",
params: payload,
params: payload!,
});

const performRedeeming = () =>
write({
address: honeyRouterAddress,
abi: honeyRouterAbi,
address: honeyFactoryAddress,
abi: honeyFactoryAbi,
functionName: "redeem",
params: payload,
params: payload!,
});

return (
Expand Down
15 changes: 8 additions & 7 deletions apps/honey/src/components/swap-card.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import React, { useState } from "react";
import { honeyRouterAbi } from "@bera/berajs";
import { honeyRouterAddress } from "@bera/config";
import { honeyFactoryAbi } from "@bera/berajs";
import { honeyFactoryAddress } from "@bera/config";
import {
ApproveButton,
ConnectButton,
Expand Down Expand Up @@ -134,7 +134,7 @@ export function SwapCard() {
) : needsApproval && !exceedBalance ? (
<ApproveButton
token={selectedFrom}
spender={honeyRouterAddress}
spender={honeyFactoryAddress}
amount={parseUnits(
fromAmount ?? "0",
selectedFrom?.decimals ?? 18,
Expand All @@ -147,14 +147,15 @@ export function SwapCard() {
!fromAmount ||
!toAmount ||
exceedBalance ||
isTyping
isTyping ||
!payload
}
onClick={() => {
write({
address: honeyRouterAddress,
abi: honeyRouterAbi,
address: honeyFactoryAddress,
abi: honeyFactoryAbi,
functionName: isMint ? "mint" : "redeem",
params: payload,
params: payload!,
});
}}
>
Expand Down
23 changes: 13 additions & 10 deletions apps/honey/src/hooks/usePsm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useTokens,
type Token,
} from "@bera/berajs";
import { honeyRouterAddress, honeyTokenAddress } from "@bera/config";
import { honeyFactoryAddress, honeyTokenAddress } from "@bera/config";
import { useAnalytics, useTxn } from "@bera/shared-ui";
import BigNumber from "bignumber.js";
import { getAddress, parseUnits, type Address } from "viem";
Expand Down Expand Up @@ -68,7 +68,7 @@ export const usePsm = () => {
const { isReady, account } = useBeraJs();

const { data: allowance } = usePollAllowance({
spender: honeyRouterAddress,
spender: honeyFactoryAddress,
token: selectedFrom,
});

Expand Down Expand Up @@ -136,14 +136,17 @@ export const usePsm = () => {
setGivenIn(!givenIn);
};

const payload = [
collateral?.address,
parseUnits(
fromAmount ?? "0",
(isMint ? collateral?.decimals : honey?.decimals) ?? 18,
),
account ?? "",
];
const payload =
collateral && account
? ([
collateral?.address,
parseUnits(
fromAmount ?? "0",
(isMint ? collateral?.decimals : honey?.decimals) ?? 18,
),
account ?? "",
] as const)
: undefined;

const needsApproval = BigNumber(fromAmount ?? "0").gt(
allowance?.formattedAllowance ?? "0",
Expand Down
132 changes: 0 additions & 132 deletions apps/hub/src/app/components/reward-btn.tsx

This file was deleted.

1 change: 1 addition & 0 deletions apps/hub/src/app/governance/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export type SafeProposalAction = {
type: ProposalTypeEnum.UPDATE_REWARDS_GAUGE;
vault: Address;
isFriend: boolean;
metadata?: string | undefined;
}
| {
type: ProposalTypeEnum.ERC20_TRANSFER;
Expand Down
18 changes: 9 additions & 9 deletions apps/hub/src/app/pools/[poolId]/details/PoolPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ export default function PoolPageContent({
)}
</CardContent>
</Card>
{didUserDeposit ? (
rewardVault && rewardVault.address !== ADDRESS_ZERO ? (
{rewardVault && rewardVault.address !== ADDRESS_ZERO ? (
didUserDeposit ? (
<>
<Card>
<CardContent className="p-4">
Expand Down Expand Up @@ -480,13 +480,13 @@ export default function PoolPageContent({
</CardContent>
</Card>
</>
) : (
<PoolCreateRewardVault
onSuccess={() => refreshRewardVault()}
address={pool?.address as Address}
/>
)
) : null}
) : null
) : (
<PoolCreateRewardVault
onSuccess={() => refreshRewardVault()}
address={pool?.address as Address}
/>
)}
</div>
)}
<div className="grid grid-cols-1 lg:col-span-7 lg:col-start-1 auto-rows-auto gap-4">
Expand Down
Loading