Skip to content

Commit

Permalink
Feat/talisman cf support (#1179)
Browse files Browse the repository at this point in the history
* Support CF with talisman

* changeset

---------

Co-authored-by: Marek Epicode <[email protected]>
  • Loading branch information
0xepicode and msadura authored Feb 10, 2025
1 parent 23abbd7 commit e6005d5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/giant-ants-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@swapkit/toolbox-substrate": patch
"@swapkit/wallet-talisman": patch
---

Support chainflip with talisman
5 changes: 3 additions & 2 deletions packages/toolboxes/substrate/src/toolbox/toolboxFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export const PolkadotToolbox = ({ providerUrl, signer, generic = false }: Toolbo
};

export const ChainflipToolbox = async ({ providerUrl, signer, generic = false }: ToolboxParams) => {
const provider = new WsProvider(providerUrl);
const providerUrlWithFallback = providerUrl || getRPCUrl(Chain.Chainflip);
const provider = new WsProvider(providerUrlWithFallback);
const api = await ApiPromise.create({ provider });
const gasAsset = AssetValue.from({ chain: Chain.Chainflip });

Expand All @@ -60,7 +61,7 @@ export const ChainflipToolbox = async ({ providerUrl, signer, generic = false }:
const evmToolbox = await ToolboxFactory({
chain: Chain.Chainflip,
signer,
providerUrl,
providerUrl: providerUrlWithFallback,
generic,
});

Expand Down
7 changes: 4 additions & 3 deletions packages/wallets/talisman/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
switchEVMWalletNetwork,
} from "@swapkit/helpers";
import type { NonETHToolbox } from "@swapkit/toolbox-evm";
import type { InjectedWindow } from "@swapkit/toolbox-substrate";
import { type InjectedWindow, Network } from "@swapkit/toolbox-substrate";
import type { Eip1193Provider } from "ethers";

declare const window: {
Expand Down Expand Up @@ -111,7 +111,8 @@ export const getWalletForChain = async ({
return { walletMethods: { ...evmWallet, getBalance }, address };
}

case Chain.Polkadot: {
case Chain.Polkadot:
case Chain.Chainflip: {
const { getToolboxByChain } = await import("@swapkit/toolbox-substrate");

const injectedWindow = window as Window & InjectedWindow;
Expand All @@ -136,7 +137,7 @@ export const getWalletForChain = async ({
}
const [{ address }] = accounts;

return { walletMethods: toolbox, address: convertAddress(address, 0) };
return { walletMethods: toolbox, address: convertAddress(address, Network[chain].prefix) };
}

default:
Expand Down
1 change: 1 addition & 0 deletions packages/wallets/talisman/src/talisman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const TALISMAN_SUPPORTED_CHAINS = [
Chain.BinanceSmartChain,
Chain.Optimism,
Chain.Polkadot,
Chain.Chainflip,
] as const;

function connectTalisman({
Expand Down
1 change: 1 addition & 0 deletions playgrounds/nextjs/src/components/WalletConnectDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export const availableChainsByWallet = {
Chain.BinanceSmartChain,
Chain.Optimism,
Chain.Polkadot,
Chain.Chainflip,
],
[WalletOption.EXODUS]: [Chain.Ethereum, Chain.BinanceSmartChain, Chain.Polygon, Chain.Bitcoin],
[WalletOption.LEDGER_LIVE]: [],
Expand Down

0 comments on commit e6005d5

Please sign in to comment.