Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove wizard, remove re-exports and adjust todos #1198

Merged
merged 2 commits into from
Feb 19, 2025
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
1 change: 0 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"@swapkit/sdk": "2.2.17",
"@swapkit/toolboxes": "0.1.0",
"@swapkit/wallets": "2.0.20",
"@swapkit/wizard": "2.1.0",
"@internal/playground-nextjs": "0.0.0",
"@internal/playground-node": "0.0.0",
"@internal/playground-vite": "0.0.0",
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/check-token-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,3 @@ jobs:
title: "[Bot] Update Token List"
label: token-list
get_diff: true

# TODO: figure out how to create changeset from cli
# - name: Publish Token List
# if: ${{ steps.commit.outputs.numberOfChangedFiles > 0 }}
# run: |
# git config --global user.email "[email protected]"
# git config --global user.name "swapkit-bot"
# cp .npmrc.prod ./packages/swapkit/tokens/.npmrc
# bun changeset version --snapshot nightly
# cd packages/swapkit/tokens
# npm config list --no-workspaces
# npm publish --no-workspaces
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
# NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

201 changes: 149 additions & 52 deletions bun.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"test": "bun --filter '*' --elide-lines=1000 test",
"test:coverage": "bun --filter '*' test:coverage",
"type-check": "bun --filter '*' --elide-lines=100 type-check",
"version-bump": "bun changeset version",
"wizard": "bun --cwd ./packages/swapkit/wizard"
"version-bump": "bun changeset version"
},
"trustedDependencies": [
"@biomejs/biome",
Expand Down
7 changes: 2 additions & 5 deletions packages/helpers/fetchTokenLists.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Chain, ChainId, ProviderName } from "./src";
import { Chain, ProviderName } from "./src";
import { SwapKitApi } from "./src/api";

const providers = (await SwapKitApi.getTokenListProviders()).filter(
Expand All @@ -17,8 +17,6 @@ console.info(
.join("\n-")}`,
);

const thorchainChainId = ChainId.THORChain;

for (const { provider } of providers) {
try {
const tokenList = await SwapKitApi.getTokenList(provider);
Expand All @@ -30,8 +28,7 @@ for (const { provider } of providers) {
.map((token) => ({
address: token.address,
chain: parseChain(token.chain),
// TODO remove after fork
chainId: token.chainId === "thorchain-mainnet-v1" ? thorchainChainId : token.chainId,
chainId: token.chainId,
decimals: token.decimals,
identifier: parseIdentifier(token.identifier),
logoURI: token.logoURI,
Expand Down
2 changes: 0 additions & 2 deletions packages/helpers/src/api/swapkitApi/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function getApiUrl(path?: `/${string}`) {
return `${isDev ? devApiUrl : apiUrl}${path}`;
}

// TODO: refactor to use apiKey
function getAuthHeaders(hash?: string) {
const { swapKit } = SKConfig.get("apiKeys");
const { referer } = SKConfig.get("envs");
Expand Down Expand Up @@ -58,7 +57,6 @@ export const computeHash = (
return crypto.createHash("sha256").update(data, "utf8").digest("hex");
};

// TODO: refactor to use apiKey
export function getTrackerDetails(payload: TrackerParams) {
return RequestClient.post<TrackerResponse>(getApiUrl("/track"), {
json: payload,
Expand Down
1 change: 0 additions & 1 deletion packages/toolboxes/src/evm/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,5 @@ export const estimateTransactionFee = async (
);
}

// TODO:
throw new Error("No gas price found");
};
13 changes: 0 additions & 13 deletions packages/toolboxes/src/evm/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
// TODO remove with next major
export {
AbstractSigner,
BrowserProvider,
HDNodeWallet,
JsonRpcProvider,
Signature,
Transaction,
type Eip1193Provider,
type Provider,
type TransactionRequest,
} from "ethers";

/**
* Package
*/
Expand Down
13 changes: 7 additions & 6 deletions packages/toolboxes/src/evm/toolbox/EVMToolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,13 @@ export const getChecksumAddressFromAsset = (asset: Asset, chain: EVMChain) => {

export const getTokenAddress = ({ chain, symbol, ticker }: Asset, baseAssetChain: EVMChain) => {
try {
if (
// TODO: refactor this to use simplify the logic
(chain === baseAssetChain && symbol === baseAssetChain && ticker === baseAssetChain) ||
(chain === Chain.BinanceSmartChain && symbol === "BNB" && ticker === "BNB") ||
([Chain.Arbitrum, Chain.Base].includes(chain) && symbol === "ETH" && ticker === "ETH")
) {
const isBSCBNB = chain === Chain.BinanceSmartChain && symbol === "BNB" && ticker === "BNB";
const isBaseAsset =
chain === baseAssetChain && symbol === baseAssetChain && ticker === baseAssetChain;
const isEVMAsset =
[Chain.Arbitrum, Chain.Base].includes(chain) && symbol === "ETH" && ticker === "ETH";

if (isBaseAsset || isBSCBNB || isEVMAsset) {
return baseAssetAddress[baseAssetChain];
}

Expand Down
4 changes: 1 addition & 3 deletions packages/toolboxes/src/radix/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
// // tip_percentage: intent.header.tipPercentage,
// // nonce: intent.header.nonce,
// // signer_public_keys: [retPublicKeyToGatewayPublicKey(intent.header.notaryPublicKey)],
// // // TODO: Add message

// // flags: {
// // assume_all_signature_proofs: false,
// // skip_epoch_check: false,
Expand Down Expand Up @@ -680,7 +680,6 @@
// // return function signMessage(_message: string) {
// // throw new SwapKitError("not_implemented", { method: "signMessage", toolbox: "radix" });

// // // TODO: convert message to Uint8Array
// // // return signer.signToSignatureWithPublicKey(message);
// // };
// // }
Expand All @@ -689,7 +688,6 @@
// // return function validateSignature(_signature: SignatureWithPublicKey) {
// // throw new SwapKitError("not_implemented", { method: "validateSignature", toolbox: "radix" });

// // // TODO: validate signature
// // // return
// // };
// // }
18 changes: 0 additions & 18 deletions packages/wallets/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Eip1193Provider } from "@swapkit/toolboxes/evm";
import { bitgetWallet } from "./bitget";
import { coinbaseWallet } from "./coinbase";
import { ctrlWallet } from "./ctrl";
Expand Down Expand Up @@ -36,20 +35,3 @@ export const wallets = {
...trezorWallet,
...walletconnectWallet,
};

declare global {
interface Window {
keepkey?: {
binance: Eip1193Provider;
bitcoin: Eip1193Provider;
bitcoincash: Eip1193Provider;
dogecoin: Eip1193Provider;
ethereum: Eip1193Provider;
cosmos: Eip1193Provider;
dash: Eip1193Provider;
litecoin: Eip1193Provider;
thorchain: Eip1193Provider;
mayachain: Eip1193Provider;
};
}
}
15 changes: 15 additions & 0 deletions packages/wallets/src/keepkey-bex/walletHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ export const getProviderNameFromChain = (chain: Chain): string => {
}
};

declare const window: {
keepkey?: {
binance: Eip1193Provider;
bitcoin: Eip1193Provider;
bitcoincash: Eip1193Provider;
dogecoin: Eip1193Provider;
ethereum: Eip1193Provider;
cosmos: Eip1193Provider;
dash: Eip1193Provider;
litecoin: Eip1193Provider;
thorchain: Eip1193Provider;
mayachain: Eip1193Provider;
};
} & Window;

export function getKEEPKEYProvider<T extends Chain>(chain: T) {
if (!window.keepkey) throw new SwapKitError("wallet_keepkey_not_found");

Expand Down
1 change: 0 additions & 1 deletion packages/wallets/src/ledger/clients/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class CosmosLedger extends CosmosLedgerInterface {
];
};

// TODO: Fix type inference
signAmino = async (signerAddress: string, signDoc: any): Promise<any> => {
await this.checkOrCreateTransportAndLedger(true);

Expand Down
1 change: 0 additions & 1 deletion packages/wallets/src/ledger/clients/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class EVMLedgerInterface extends AbstractSigner {
return Signature.from(sig).serialized;
};

// TODO: fix typing infer from ethers
sendTransaction = async (tx: TransactionRequest): Promise<any> => {
if (!this.provider) throw new Error("No provider set");

Expand Down
6 changes: 2 additions & 4 deletions packages/wallets/src/walletconnect/evmSigner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type EVMChain, SwapKitError, WalletOption } from "@swapkit/helpers";
import type { JsonRpcProvider, Provider, TransactionRequest } from "ethers";
import type { JsonRpcProvider, Provider, TransactionRequest, TransactionResponse } from "ethers";
import { AbstractSigner } from "ethers";

import { DEFAULT_EIP155_METHODS } from "./constants";
Expand Down Expand Up @@ -100,7 +100,6 @@ class WalletconnectSigner extends AbstractSigner {
// return txHash.startsWith('0x') ? txHash : `0x${txHash}`;
};

// @ts-expect-error TODO: fix this
sendTransaction = async ({ from, to, value, data }: TransactionRequest) => {
const { toHexString } = await import("@swapkit/toolboxes/evm");

Expand All @@ -119,10 +118,9 @@ class WalletconnectSigner extends AbstractSigner {
},
});

return response;
return response as TransactionResponse;
};

// @ts-expect-error TODO: fix this
connect = (provider: Provider | null) => {
if (!provider) {
throw new SwapKitError({
Expand Down
1 change: 0 additions & 1 deletion packages/wallets/src/walletconnect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ async function getToolbox({
const signer = await getEVMSigner({ walletconnect, chain, provider });
const toolbox = getToolboxByChain(chain);

// @ts-expect-error TODO: fix this signer issue
return toolbox({ provider, signer });
}

Expand Down
Loading