Skip to content

Commit

Permalink
Feat/bitget wallet (#1109)
Browse files Browse the repository at this point in the history
* Bitget wallet

* bitget fixes

* Changeset

* remove redundant code

* Revert "Changeset"

This reverts commit 2ac894e.

* Type fixes

* Fix types

* feat: cleans code and fixes typing

---------

Co-authored-by: Marek Epicode <m.sadura@outlook.com>
Co-authored-by: towan <95243956+towanTG@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Dec 10, 2024
1 parent 20e5fd3 commit cc61490
Show file tree
Hide file tree
Showing 20 changed files with 429 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-bees-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@swapkit/helpers": patch
---

ChainApi type
6 changes: 6 additions & 0 deletions .changeset/khaki-monkeys-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@swapkit/helpers": minor
"@swapkit/wallet-bitget": minor
---

Removes Kuji reference and adds new SwapKitError codes
5 changes: 5 additions & 0 deletions .changeset/khaki-suits-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@swapkit/plugin-kado": patch
---

Fixes plugin typing
7 changes: 7 additions & 0 deletions .changeset/nasty-cherries-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@swapkit/wallet-bitget": major
"@swapkit/helpers": patch
"@swapkit/wallets": patch
---

Bitget wallet
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/plugins/kado/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function mapKadoQuoteToQuoteResponse({

function plugin({
config: { kadoApiKey },
}: Exclude<SwapKitPluginParams<{ kadoApiKey: string }>, SwapKitPluginParams["getWallet"]>) {
}: Omit<SwapKitPluginParams<{ kadoApiKey: string }>, "getWallet">) {
async function fetchProviderQuote({
sellAsset,
buyAsset,
Expand Down
1 change: 1 addition & 0 deletions packages/swapkit/helpers/src/modules/swapKitError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const errorCodes = {
wallet_keepkey_asset_not_defined: 20901,
wallet_keepkey_contract_address_not_provided: 20902,
wallet_keepkey_send_transaction_no_address: 20903,
wallet_bitkeep_not_found: 21001,
/**
* Chainflip
*/
Expand Down
2 changes: 2 additions & 0 deletions packages/swapkit/helpers/src/types/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type ChainApis = { [key in CovalentChains]?: CovalentApiType } & {
[key in Chain.Fiat]?: undefined;
};

export type ChainApi = EthplorerApiType | CovalentApiType | BlockchairApiType | string;

export type GenericSwapParams<T = unknown> = {
buyAsset?: AssetValue;
sellAsset?: AssetValue;
Expand Down
1 change: 1 addition & 0 deletions packages/swapkit/helpers/src/types/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type {
};

export enum WalletOption {
BITGET = "BITGET",
BRAVE = "BRAVE",
COINBASE_MOBILE = "COINBASE_MOBILE",
COINBASE_WEB = "COINBASE_WEB",
Expand Down
1 change: 1 addition & 0 deletions packages/swapkit/wallets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "SwapKit - Wallets",
"dependencies": {
"@swapkit/wallet-bitget": "workspace:*",
"@swapkit/wallet-coinbase": "workspace:*",
"@swapkit/wallet-ctrl": "workspace:*",
"@swapkit/wallet-evm-extensions": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/swapkit/wallets/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { bitgetWallet } from "@swapkit/wallet-bitget";
import { coinbaseWallet } from "@swapkit/wallet-coinbase";
import { ctrlWallet } from "@swapkit/wallet-ctrl";
import { evmWallet } from "@swapkit/wallet-evm-extensions";
import { exodusWallet } from "@swapkit/wallet-exodus";
import { keepkeyWallet } from "@swapkit/wallet-keepkey";
import { keepkeyBexWallet } from "@swapkit/wallet-keepkey-bex";
import { keplrWallet } from "@swapkit/wallet-keplr";
Expand All @@ -16,9 +16,9 @@ import { trezorWallet } from "@swapkit/wallet-trezor";
import { walletconnectWallet } from "@swapkit/wallet-wc";

export const wallets = {
...bitgetWallet,
...coinbaseWallet,
...evmWallet,
...exodusWallet,
...keepkeyBexWallet,
...keepkeyWallet,
...keplrWallet,
Expand Down
1 change: 1 addition & 0 deletions packages/wallets/bitget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @swapkit/wallet-bitget
4 changes: 4 additions & 0 deletions packages/wallets/bitget/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { buildPackage } from "../../../tools/builder";
import { dependencies } from "./package.json";

buildPackage({ dependencies });
32 changes: 32 additions & 0 deletions packages/wallets/bitget/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"description": "SwapKit Wallet - Bitget",
"dependencies": {
"@swapkit/helpers": "workspace:*",
"@swapkit/toolbox-cosmos": "workspace:*",
"@swapkit/toolbox-evm": "workspace:*",
"@swapkit/toolbox-utxo": "workspace:*"
},
"files": [
"src/",
"dist/"
],
"homepage": "https://github.com/thorswap/SwapKit",
"license": "Apache-2.0",
"main": "./dist/index.js",
"name": "@swapkit/wallet-bitget",
"repository": {
"type": "git",
"url": "git+https://github.com/thorswap/SwapKit.git"
},
"scripts": {
"build": "bun run ./build.ts",
"clean": "rm -rf dist node_modules *.tsbuildinfo",
"lint": "biome check --diagnostic-level=error --write ./src",
"test": "echo 'bun test'",
"test:coverage": "bun test --coverage",
"type-check": "tsc --noEmit"
},
"type": "module",
"types": "./src/index.ts",
"version": "0.0.0"
}
47 changes: 47 additions & 0 deletions packages/wallets/bitget/src/bitgetWallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {
Chain,
type ConnectWalletParams,
EVMChains,
WalletOption,
setRequestClientConfig,
} from "@swapkit/helpers";

import { getWalletForChain } from "./helpers";

export const BITGET_SUPPORTED_CHAINS = [
...EVMChains,
Chain.Cosmos,
Chain.Bitcoin,
Chain.Solana,
] as const;

function connectBitget({
addChain,
config: { thorswapApiKey, covalentApiKey, ethplorerApiKey, blockchairApiKey },
}: ConnectWalletParams) {
return async function connectBitget(chains: (typeof BITGET_SUPPORTED_CHAINS)[number][]) {
setRequestClientConfig({ apiKey: thorswapApiKey });

const promises = chains.map(async (chain) => {
const walletMethods = await getWalletForChain({
chain,
covalentApiKey,
ethplorerApiKey,
blockchairApiKey,
});

addChain({
...walletMethods,
chain,
balance: [],
walletType: WalletOption.BITGET,
});
});

await Promise.all(promises);

return true;
};
}

export const bitgetWallet = { connectBitget } as const;
Loading

0 comments on commit cc61490

Please sign in to comment.