Skip to content

Commit

Permalink
use config correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
steezeburger committed Sep 30, 2024
1 parent 7dc566f commit 932f362
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion web/src/components/DepositCard/DepositCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useConfig } from "config/hooks/useConfig";
export default function DepositCard(): React.ReactElement {
const { addNotification } = useContext(NotificationsContext);
const { userAccount } = useEthWallet();
const { ibcChains } = useConfig();
const { ibcChains, sequencerBridgeAccount } = useConfig();

const {
selectIbcChain,
Expand Down Expand Up @@ -106,6 +106,7 @@ export default function DepositCard(): React.ReactElement {
recipientAddress,
DecUtils.getTenExponentN(6).mul(new Dec(amount)).truncate().toString(),
selectedIbcCurrency,
sequencerBridgeAccount,
);
} catch (e) {
if (e instanceof Error) {
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/WithdrawCard/WithdrawCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useConfig } from "config/hooks/useConfig";
export default function WithdrawCard(): React.ReactElement {
const { addNotification } = useContext(NotificationsContext);
const { userAccount, selectedWallet } = useEthWallet();
const { ibcChains, sequencerBridgeAccount } = useConfig();
const { ibcChains, sequencerBridgeAccount, evmWithdrawerContractAddress } = useConfig();

const {
selectIbcChain,
Expand Down Expand Up @@ -46,6 +46,7 @@ export default function WithdrawCard(): React.ReactElement {
const [isAnimating, setIsAnimating] = useState<boolean>(false);

useEffect(() => {
console.log(userAccount);
if (userAccount?.address) {
setFromAddress(userAccount.address);
}
Expand Down Expand Up @@ -165,7 +166,7 @@ export default function WithdrawCard(): React.ReactElement {
try {
const withdrawerSvc = getAstriaWithdrawerService(
selectedWallet.provider,
sequencerBridgeAccount,
evmWithdrawerContractAddress,
);
await withdrawerSvc.withdrawToIbcChain(
fromAddress,
Expand Down
5 changes: 4 additions & 1 deletion web/src/config/contexts/ConfigContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ export const ConfigContextProvider: React.FC<ConfigContextProps> = ({
const sequencerBridgeAccount = getEnvVariable(
"REACT_APP_SEQUENCER_BRIDGE_ACCOUNT",
);
const evmWithdrawerContractAddress = getEnvVariable(
"REACT_APP_EVM_WITHDRAWER_CONTRACT_ADDRESS",
);

return (
<ConfigContext.Provider value={{ ibcChains, sequencerBridgeAccount }}>
<ConfigContext.Provider value={{ evmWithdrawerContractAddress, ibcChains, sequencerBridgeAccount }}>
{children}
</ConfigContext.Provider>
);
Expand Down
1 change: 1 addition & 0 deletions web/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ import type { IbcChains } from "./chainConfigs";
export type AppConfig = {
ibcChains: IbcChains;
sequencerBridgeAccount: string;
evmWithdrawerContractAddress: string;
};
8 changes: 4 additions & 4 deletions web/src/services/ibc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import { getEnvVariable } from "config/env";
* @param recipient
* @param amount
* @param currency
* @param sequencerBridgeAccount
*/
export const sendIbcTransfer = async (
selectedIbcChain: IbcChainInfo,
sender: string,
recipient: string,
amount: string,
currency: IbcCurrency,
sequencerBridgeAccount: string,
) => {
const keplr = window.keplr;
if (!keplr) {
Expand All @@ -37,9 +39,7 @@ export const sendIbcTransfer = async (
if (!account) {
throw new Error("Failed to get account from Keplr wallet.");
}
const sequencer_bridge_account = getEnvVariable(
"REACT_APP_SEQUENCER_BRIDGE_ACCOUNT",
);

// TODO - does this need to be configurable in the ui?
const feeDenom = selectedIbcChain.feeCurrencies[0].coinMinimalDenom;
const memo = JSON.stringify({ rollupDepositAddress: recipient });
Expand All @@ -64,7 +64,7 @@ export const sendIbcTransfer = async (
},
sender: sender,
memo: memo,
receiver: sequencer_bridge_account,
receiver: sequencerBridgeAccount,
// Timeout is in nanoseconds. Use Long.UZERO for default timeout
timeoutTimestamp: Long.fromNumber(Date.now() + 600_000).multiply(
1_000_000,
Expand Down
9 changes: 5 additions & 4 deletions web/src/styles/dropdown-customizations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@

.dropdown-trigger {
width: 100%;

.button {
width: 100%;
min-width: 0;
display: flex;
align-items: center;
justify-content: space-between;
background-color: transparent;
color: $dropdown-item-color;

.dropdown-label {
//
}

span {
color: $dropdown-placeholder-color;

Expand All @@ -27,12 +30,10 @@

&.icon-left {
height: 20px;
flex-shrink: 0;
}

&.icon-right {
margin-left: auto;
flex-shrink: 0;
}
}
}
Expand Down

0 comments on commit 932f362

Please sign in to comment.