-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2034 from galacticcouncil/feat/solana
Feat/solana
- Loading branch information
Showing
44 changed files
with
1,490 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
diff --git a/node_modules/@galacticcouncil/xcm-sdk/build/types/platforms/substrate/SubstrateService.d.ts b/node_modules/@galacticcouncil/xcm-sdk/build/types/platforms/substrate/SubstrateService.d.ts | ||
index c0e665f..14b6b93 100644 | ||
--- a/node_modules/@galacticcouncil/xcm-sdk/build/types/platforms/substrate/SubstrateService.d.ts | ||
+++ b/node_modules/@galacticcouncil/xcm-sdk/build/types/platforms/substrate/SubstrateService.d.ts | ||
@@ -1,4 +1,4 @@ | ||
-import '@polkadot/api-augment'; | ||
+//import '@polkadot/api-augment'; | ||
import { AnyParachain, Asset, AssetAmount, ExtrinsicConfig } from '@galacticcouncil/xcm-core'; | ||
import { ApiPromise } from '@polkadot/api'; | ||
import { SubmittableExtrinsic } from '@polkadot/api/promise/types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { chainsMap } from "@galacticcouncil/xcm-cfg" | ||
import { EvmChain } from "@galacticcouncil/xcm-core" | ||
import { useQuery, UseQueryOptions } from "@tanstack/react-query" | ||
import { QUERY_KEYS } from "utils/queryKeys" | ||
|
||
export const ethereum = chainsMap.get("ethereum") as EvmChain | ||
export const ethereumNativeToken = ethereum.assetsData.get("eth")! | ||
|
||
type TAccountBalance = Awaited<ReturnType<typeof fetchEthereumAccountBalance>> | ||
|
||
const fetchEthereumAccountBalance = async (address: string) => { | ||
if (!ethereum.client) throw new Error("Ethereum is not connected") | ||
|
||
const provider = ethereum.client.getProvider() | ||
const balance = await provider.getBalance({ | ||
address: address as `0x${string}`, | ||
}) | ||
return { | ||
amount: balance.toString(), | ||
decimals: ethereumNativeToken.decimals, | ||
symbol: ethereumNativeToken.asset.originSymbol, | ||
} | ||
} | ||
|
||
export const useEthereumAccountBalance = ( | ||
address: string, | ||
options: UseQueryOptions<TAccountBalance> = {}, | ||
) => { | ||
return useQuery<TAccountBalance>( | ||
QUERY_KEYS.ethereumAccountBalance(address), | ||
async () => fetchEthereumAccountBalance(address), | ||
{ | ||
enabled: !!address, | ||
...options, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { chainsMap } from "@galacticcouncil/xcm-cfg" | ||
import { SolanaChain } from "@galacticcouncil/xcm-core" | ||
import { PublicKey } from "@solana/web3.js" | ||
import { useQuery, UseQueryOptions } from "@tanstack/react-query" | ||
import { QUERY_KEYS } from "utils/queryKeys" | ||
|
||
export const solana = chainsMap.get("solana") as SolanaChain | ||
export const solanaNativeToken = solana.assetsData.get("sol")! | ||
|
||
type TAccountBalance = Awaited<ReturnType<typeof fetchSolanaAccountBalance>> | ||
|
||
const fetchSolanaAccountBalance = async (address: string) => { | ||
if (!solana.connection) throw new Error("Solana is not connected") | ||
|
||
const balance = await solana.connection.getBalance(new PublicKey(address)) | ||
|
||
return { | ||
amount: balance.toString(), | ||
decimals: solanaNativeToken.decimals, | ||
symbol: solanaNativeToken.asset.originSymbol, | ||
} | ||
} | ||
|
||
export const useSolanaAccountBalance = ( | ||
address: string, | ||
options: UseQueryOptions<TAccountBalance> = {}, | ||
) => { | ||
return useQuery<TAccountBalance>( | ||
QUERY_KEYS.solanaAccountBalance(address), | ||
async () => fetchSolanaAccountBalance(address), | ||
{ | ||
enabled: !!address, | ||
...options, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.