Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/blue-suns-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stakekit/widget": patch
---

refactor: chain configuration
5 changes: 5 additions & 0 deletions .changeset/common-corners-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stakekit/widget": patch
---

feat: partial tracking
5 changes: 5 additions & 0 deletions .changeset/stupid-dots-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stakekit/widget": patch
---

feat(transaction): transaction format option
5 changes: 5 additions & 0 deletions .changeset/tall-dingos-throw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stakekit/widget": patch
---

feat(externalProviders): check configured chains
131 changes: 83 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,70 +445,105 @@ const App = () => {
Optionally, you can pass externalProviders property to the widget which will be used to connect to the wallet.

```ts
type SKExternalProviders = {
currentChain?: number;
type SKExternalProviders = {
currentChain?: SupportedSKChainIds;
currentAddress: string;
initToken?: `${TokenDto["network"]}-${TokenDto["address"]}`;
supportedChainIds?: number[];
supportedChainIds?: SupportedSKChainIds[];
type: "generic";
provider: EVMWallet;
provider: SKWallet;
};

type EVMWallet = {
signMessage: (message: string) => Promise<string>;
switchChain: (chainId: string) => Promise<void>;
getTransactionReceipt?(txHash: string): Promise<{
transactionHash?: string;
}>;
sendTransaction(
tx: SKTx,
txMeta: {
txId: TransactionDto["id"];
actionId: ActionDto["id"];
actionType: ActionDto["type"];
txType: TransactionDto["type"];
}): Promise<string>;
};
type SupportedSKChainIds =
| EvmChainIds
| SubstrateChainIds
| MiscChainIds;

enum EvmChainIds {
Ethereum = 1,
Polygon = 137,
Optimism = 10,
Arbitrum = 42_161,
AvalancheC = 43_114,
Celo = 42_220,
Harmony = 1_666_600_000,
Viction = 88,
Binance = 56,
Base = 8453,
Linea = 59_144,
Core = 1116,
Sonic = 146,
EthereumHolesky = 17000,
EthereumGoerli = 5,
}

type Base64String = string;
enum SubstrateChainIds {
Polkadot = 9999,
}

export enum TxType {
Legacy = "0x1",
EIP1559 = "0x2",
enum MiscChainIds {
Near = 397,
Tezos = 1729,
Solana = 501,
Tron = 79,
Ton = 3412,
}

export type EVMTx = {
type EVMTx = {
type: "evm";
tx: {
data: Hex;
from: Hex;
to: Hex;
value: Hex | undefined;
nonce: Hex;
gas: Hex;
chainId: Hex;
type: Hex;
} & (
| {
type: TxType.EIP1559; // EIP-1559
maxFeePerGas: Hex | undefined;
maxPriorityFeePerGas: Hex | undefined;
}
| { type: TxType.Legacy } // Legacy
);
tx: DecodedEVMTransaction;
};

export type SolanaTx = { type: "solana"; tx: Base64String };
type SolanaTx = {
type: "solana";
tx: DecodedSolanaTransaction;
};

export type TonTx = {
type TonTx = {
type: "ton";
tx: {
seqno: bigint;
message: Base64String;
};
tx: DecodedTonTransaction;
};

export type SKTx = EVMTx | SolanaTx | TonTx;
type TronTx = {
type: "tron";
tx: DecodedTronTransaction;
};

type SKTx = EVMTx | SolanaTx | TonTx | TronTx;

type ActionMeta = {
actionId: ActionDto["id"];
actionType: ActionDto["type"];
amount: ActionDto["amount"];
inputToken: ActionDto["inputToken"];
providersDetails: {
name: string;
address: string | undefined;
rewardRate: number | undefined;
rewardType: RewardTypes;
website: string | undefined;
logo: string | undefined;
}[];
};

type SKTxMeta = ActionMeta & {
txId: TransactionDto["id"];
txType: TransactionDto["type"];
};

type SKWallet = {
signMessage: (message: string) => Promise<string>;
switchChain: (chainId: number) => Promise<void>;
getTransactionReceipt?(txHash: string): Promise<{ transactionHash?: string }>;
sendTransaction(
tx: SKTx,
txMeta: SKTxMeta
): Promise<
| string
| { type: "success"; txHash: string }
| { type: "error"; error: string }
>;
};
```

### Tracking
Expand Down
2 changes: 1 addition & 1 deletion packages/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@radix-ui/react-visually-hidden": "^1.1.3",
"@safe-global/safe-apps-provider": "^0.18.6",
"@safe-global/safe-apps-sdk": "^9.1.0",
"@stakekit/api-hooks": "0.0.100",
"@stakekit/api-hooks": "0.0.101",
"@stakekit/common": "^0.0.48",
"@stakekit/rainbowkit": "^2.2.4",
"@tanstack/react-query": "^5.74.0",
Expand Down
54 changes: 54 additions & 0 deletions packages/widget/src/domain/types/chains/cosmos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { CosmosChainsAssets } from "@sk-widget/providers/cosmos/chains/types";
import { CosmosNetworks } from "@stakekit/common";
import type { Chain } from "@stakekit/rainbowkit";

export const supportedCosmosChains = [
CosmosNetworks.Akash,
CosmosNetworks.Cosmos,
CosmosNetworks.Juno,
CosmosNetworks.Kava,
CosmosNetworks.Osmosis,
CosmosNetworks.Stargaze,
CosmosNetworks.Onomy,
CosmosNetworks.Persistence,
CosmosNetworks.Axelar,
CosmosNetworks.Quicksilver,
CosmosNetworks.Agoric,
CosmosNetworks.BandProtocol,
CosmosNetworks.Bitsong,
CosmosNetworks.Chihuahua,
CosmosNetworks.Comdex,
CosmosNetworks.Crescent,
CosmosNetworks.Cronos,
CosmosNetworks.Cudos,
CosmosNetworks.FetchAi,
CosmosNetworks.GravityBridge,
CosmosNetworks.IRISnet,
CosmosNetworks.KiNetwork,
CosmosNetworks.MarsProtocol,
CosmosNetworks.Regen,
CosmosNetworks.Secret,
CosmosNetworks.Sentinel,
CosmosNetworks.Sommelier,
CosmosNetworks.Teritori,
CosmosNetworks.Umee,
CosmosNetworks.Coreum,
CosmosNetworks.Desmos,
CosmosNetworks.Dydx,
CosmosNetworks.Injective,
CosmosNetworks.Sei,
CosmosNetworks.Mantra,
] as const;

export const supportedCosmosChainsSet = new Set(supportedCosmosChains);

export type SupportedCosmosChains = (typeof supportedCosmosChains)[number];

export type CosmosChainsMap = {
[Key in SupportedCosmosChains]: {
type: "cosmos";
skChainName: Key;
wagmiChain: Chain;
chain: CosmosChainsAssets;
};
};
Loading