Skip to content

Commit

Permalink
add forma
Browse files Browse the repository at this point in the history
  • Loading branch information
thal0x committed May 30, 2024
1 parent bd52976 commit 9f5b4cc
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion chain-registry
Submodule chain-registry updated 54 files
+4 −5 .github/workflows/validate.yml
+20 −0 .github/workflows/validate_versionsjson.yml
+31 −0 _IBC/axelar-pryzm.json
+31 −0 _IBC/noble-planq.json
+31 −0 _IBC/onex-onomy.json
+352 −0 _non-cosmos/solana/assetlist.json
+ _non-cosmos/solana/images/bsol.png
+ _non-cosmos/solana/images/edgesol.png
+ _non-cosmos/solana/images/hsol.png
+ _non-cosmos/solana/images/jitosol.png
+ _non-cosmos/solana/images/jupsol.png
+ _non-cosmos/solana/images/lst.png
+ _non-cosmos/solana/images/msol.png
+ _non-cosmos/solana/images/wif.png
+0 −6 canto/chain.json
+3 −3 celestia/chain.json
+369 −16 composable/assetlist.json
+0 −6 crescent/chain.json
+0 −6 emoney/chain.json
+47 −0 injective/assetlist.json
+9 −1 injective/chain.json
+7 −2 juno/assetlist.json
+23 −1 kyve/chain.json
+30 −1 lava/chain.json
+62 −0 mantrachain/assetlist.json
+ mantrachain/images/OM-Darkmatt.png
+10 −0 mantrachain/images/OM-Darkmatt.svg
+ mantrachain/images/OM-Prim-Col.png
+10 −0 mantrachain/images/OM-Prim-Col.svg
+ mantrachain/images/OM-WHT.png
+4 −0 mantrachain/images/OM-WHT.svg
+53 −1 neutron/assetlist.json
+26 −5 neutron/chain.json
+ neutron/images/NBZ.png
+ neutron/images/takumi.png
+ nibiru/images/nibiru.png
+12 −15 nibiru/images/nibiru.svg
+5 −5 osmosis/assetlist.json
+31 −4 persistence/chain.json
+0 −6 regen/chain.json
+28 −9 sei/chain.json
+7 −1 shido/chain.json
+83 −1 stargaze/assetlist.json
+68 −2 terra2/assetlist.json
+32 −0 terra2/images/ura.svg
+31 −0 testnets/_IBC/axelartestnet-mantrachaintestnet.json
+31 −0 testnets/_IBC/coreumtestnet-osmosistestnet.json
+31 −0 testnets/_IBC/mantrachaintestnet-nobletestnet.json
+31 −0 testnets/_IBC/mantrachaintestnet-osmosistestnet.json
+22 −12 testnets/mantrachaintestnet/assetlist.json
+8 −7 testnets/mantrachaintestnet/chain.json
+ testnets/mantrachaintestnet/images/mantra.png
+0 −10 testnets/mantrachaintestnet/images/mantra.svg
+2 −1 versions.schema.json
1 change: 1 addition & 0 deletions src/config/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ exports.WHITELABEL_CHAIN_IDS = {
"dimension_37-1": true,
"coreum-mainnet-1": true,
"haqq_11235-1": true,
"stride-internal-1": true,
};

/**
Expand Down
27 changes: 27 additions & 0 deletions src/constants/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { defineChain } from "viem";
import {
arbitrum,
arbitrumSepolia,
Expand All @@ -24,6 +25,31 @@ import {
sepolia,
} from "wagmi/chains";

export const forma = /*#__PURE__*/ defineChain({
id: 984122,
name: "Forma Mainnet",
nativeCurrency: { name: "TIA", symbol: "TIA", decimals: 18 },
rpcUrls: {
default: {
http: ["https://rpc.forma.art"],
},
},
blockExplorers: {
default: {
name: "Etherscan",
url: "https://lineascan.build",
apiUrl: "https://api.lineascan.build/api",
},
},
contracts: {
multicall3: {
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
blockCreated: 42,
},
},
testnet: false,
});

export const EVM_CHAINS: Chain[] = [
arbitrum,
avalanche,
Expand All @@ -47,4 +73,5 @@ export const EVM_CHAINS: Chain[] = [
arbitrumSepolia,
blast,
blastSepolia,
forma,
];
32 changes: 32 additions & 0 deletions src/hooks/useBalancesByChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,37 @@ export async function getEvmChainBalances(

const chainAssets = assets[chainID];

if (chainID === "984122") {
const balances: bigint[] = [];

for (const asset of chainAssets) {
if (asset.tokenContract) {
const balance = await publicClient.readContract({
address: asset.tokenContract as `0x${string}`,
abi: erc20Abi,
functionName: "balanceOf",
args: [address as `0x${string}`],
});

balances.push(balance);
}

const balance = await publicClient.getBalance({
address: address as `0x${string}`,
});

balances.push(balance);
}

return chainAssets.reduce<Record<string, string>>(
(acc, asset, i) => ({
...acc,
[asset.denom]: balances[i].toString() || "0",
}),
{},
);
}

const balances = await publicClient.multicall({
multicallAddress: "0xcA11bde05977b3631167028862bE2a173976CA11",
contracts: chainAssets.map((asset) => {
Expand All @@ -118,6 +149,7 @@ export async function getEvmChainBalances(
};
}),
});

return chainAssets.reduce<Record<string, string>>(
(acc, asset, i) => ({
...acc,
Expand Down
4 changes: 4 additions & 0 deletions src/lib/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
sepolia,
} from "wagmi/chains";

import { forma } from "@/constants/wagmi";

// Update EVM_CHAINS in src/constants/wagmi.ts as well
export const config = createConfig({
chains: [
Expand All @@ -50,6 +52,7 @@ export const config = createConfig({
arbitrumSepolia,
blast,
blastSepolia,
forma,
],
transports: {
[arbitrum.id]: http(),
Expand All @@ -74,5 +77,6 @@ export const config = createConfig({
[arbitrumSepolia.id]: http(),
[blast.id]: http(),
[blastSepolia.id]: http(),
[forma.id]: http(),
},
});
1 change: 1 addition & 0 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function createProxyHandler(type: "api" | "rpc", fallbackFn?: FallbackEnd
}

const uri = [data.endpoint, ...args].join("/");
console.log(data, args);
return fetch(uri, {
body: req.body,
headers,
Expand Down

0 comments on commit 9f5b4cc

Please sign in to comment.