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

feat: wc utxo chains #965

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions .changeset/slow-crabs-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@swapkit/toolbox-solana": minor
"@swapkit/wallet-phantom": minor
"@swapkit/toolbox-evm": minor
"@swapkit/api": minor
---

Support new chains (BTC, ETH) on Phantom
Binary file modified bun.lockb
Binary file not shown.
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.7",
"@changesets/cli": "2.27.8",
"@size-limit/file": "11.1.4",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"@types/node": "22.5.3",
"@types/react": "18.3.5",
"@types/react-dom": "18.3.0",
"bun-types": "1.1.18",
"lefthook": "1.7.2",
"npm-check-updates": "16.14.20",
"react": "18.2.0",
"bun-types": "1.1.26",
"lefthook": "1.7.15",
"npm-check-updates": "17.1.1",
"size-limit": "11.1.4",
"typescript": "5.5.4"
},
"name": "swapkit-monorepo",
"packageManager": "^bun@1.1.17",
"packageManager": "bun@^1.1.26",
"private": true,
"scripts": {
"bootstrap": "bun clean; bun install --force; bun run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/chainflip/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "swapkit-oss",
"dependencies": {
"@chainflip/sdk": "1.4.2",
"@chainflip/sdk": "1.5.1",
"@polkadot/keyring": "12.6.2",
"@polkadot/util": "12.6.2",
"@swapkit/api": "workspace:*",
Expand Down
3 changes: 0 additions & 3 deletions packages/swapkit/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"@swapkit/helpers": "workspace:*",
"zod": "3.23.8"
},
"devDependencies": {
"ky": "1.4.0"
},
"description": "SwapKit - API",
"files": [
"src/",
Expand Down
2 changes: 1 addition & 1 deletion packages/swapkit/helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"@swapkit/contracts": "workspace:*",
"@swapkit/tokens": "workspace:*",
"picocolors": "1.0.1"
"picocolors": "1.1.0"
},
"devDependencies": {
"@swapkit/toolbox-cosmos": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/swapkit/helpers/src/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum RPCUrl {
Radix = "https://radix-mainnet.rpc.grove.city/v1/326002fc/core",
THORChain = "https://rpc.thorswap.net",
THORChainStagenet = "https://stagenet-rpc.ninerealms.com",
Solana = "https://mainnet.helius-rpc.com/?api-key=2cbe3ae6-cfc5-4141-a093-0055d0fa3d80",
Solana = "https://mainnet.helius-rpc.com",
}

export enum ExplorerUrl {
Expand Down
2 changes: 1 addition & 1 deletion packages/swapkit/wizard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"@clack/prompts": "0.7.0",
"ejs": "3.1.10",
"picocolors": "1.0.1",
"picocolors": "1.1.0",
"zod": "3.23.8"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/toolboxes/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"@cosmjs/encoding": "0.32.4",
"@cosmjs/proto-signing": "0.32.4",
"@cosmjs/stargate": "0.32.4",
"@scure/base": "1.1.7",
"@scure/base": "1.1.8",
"@swapkit/api": "workspace:*",
"@swapkit/helpers": "workspace:*",
"base64-js": "1.5.1",
"cosmjs-types": "0.9.0",
"protobufjs": "7.3.2"
"protobufjs": "7.4.0"
},
"description": "SwapKit - Toolbox cosmos",
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/toolboxes/cosmos/src/cosmosClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export class CosmosClient {
if (!address.startsWith(this.prefix)) return false;

try {
const { prefix, words } = bech32.decode(address);
const normalized = bech32.encode(prefix, words);
const { prefix, words } = bech32.decode(address as `${string}1${string}`);
const normalized = bech32.encode(prefix, words, false);

return normalized === address.toLocaleLowerCase();
} catch (_error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { base64, bech32 } from "@scure/base";
import { fromByteArray, toByteArray } from "base64-js";

export function bech32ToBase64(address: string) {
return base64.encode(Uint8Array.from(bech32.fromWords(bech32.decode(address).words)));
return base64.encode(
Uint8Array.from(bech32.fromWords(bech32.decode(address as `${string}1${string}`).words)),
);
}

export function base64ToBech32(address: string, prefix = "thor") {
Expand Down
6 changes: 3 additions & 3 deletions packages/toolboxes/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"author": "swapkit-oss",
"dependencies": {
"@swapkit/helpers": "workspace:*",
"ethers": "6.11.1"
"ethers": "6.13.2"
},
"description": "SwapKit - Toolbox evm",
"devDependencies": {
"@nomicfoundation/hardhat-ethers": "3.0.6",
"@nomicfoundation/hardhat-ethers": "3.0.8",
"@nomicfoundation/hardhat-toolbox": "5.0.0",
"hardhat": "2.22.6"
"hardhat": "2.22.10"
},
"files": [
"src/",
Expand Down
4 changes: 2 additions & 2 deletions packages/toolboxes/radix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"author": "swapkit-oss",
"dependencies": {
"@radixdlt/babylon-core-api-sdk": "1.2.0",
"@radixdlt/radix-engine-toolkit": "1.0.4",
"@radixdlt/radix-engine-toolkit": "1.0.5",
"@radixdlt/wallet-sdk": "1.0.1",
"@scure/bip39": "1.3.0",
"@scure/bip39": "1.4.0",
"@swapkit/helpers": "workspace:*"
},
"description": "SwapKit - Toolbox radix",
Expand Down
4 changes: 2 additions & 2 deletions packages/toolboxes/solana/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"author": "swapkit-oss",
"dependencies": {
"@scure/bip39": "1.3.0",
"@scure/bip39": "1.4.0",
"@solana/spl-token": "0.4.8",
"@solana/web3.js": "1.95.0",
"@solana/web3.js": "1.95.3",
"@swapkit/helpers": "workspace:*"
},
"description": "SwapKit - Toolbox solana",
Expand Down
10 changes: 8 additions & 2 deletions packages/toolboxes/solana/src/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ function validateAddress(address: string) {
function createKeysForPath({
phrase,
derivationPath = DerivationPath.SOL,
}: { phrase: string; derivationPath?: string }) {
}: {
phrase: string;
derivationPath?: string;
}) {
const seed = mnemonicToSeedSync(phrase);
const hdKey = HDKey.fromMasterSeed(seed);

Expand All @@ -53,7 +56,10 @@ function getAddressFromKeys(keypair: Keypair) {
async function getTokenBalances({
connection,
address,
}: { connection: Connection; address: string }) {
}: {
connection: Connection;
address: string;
}) {
const tokenAccounts = await connection.getTokenAccountsByOwner(new PublicKey(address), {
programId: TOKEN_PROGRAM_ID,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/toolboxes/utxo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"dependencies": {
"@bitcoinerlab/secp256k1": "1.1.1",
"@psf/bitcoincashjs-lib": "4.0.3",
"@scure/bip32": "1.4.0",
"@scure/bip39": "1.3.0",
"@scure/bip32": "1.5.0",
"@scure/bip39": "1.4.0",
"@swapkit/helpers": "workspace:*",
"bitcoinjs-lib": "6.1.6",
"bs58check": "4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/keplr/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "SwapKit Wallet - Keplr",
"dependencies": {
"@keplr-wallet/types": "0.12.110",
"@keplr-wallet/types": "0.12.125",
"@swapkit/helpers": "workspace:*",
"@swapkit/toolbox-cosmos": "workspace:*"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/keystore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@scure/bip39": "1.3.0",
"@scure/bip39": "1.4.0",
"@swapkit/helpers": "workspace:*",
"@swapkit/toolbox-cosmos": "workspace:*",
"@swapkit/toolbox-evm": "workspace:*",
Expand Down
21 changes: 9 additions & 12 deletions packages/wallets/ledger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"@cosmjs/amino": "0.32.4",
"@cosmjs/crypto": "0.32.4",
"@cosmjs/proto-signing": "0.32.4",
"@ledgerhq/devices": "8.4.0",
"@ledgerhq/errors": "6.17.0",
"@ledgerhq/hw-app-btc": "10.3.0",
"@ledgerhq/hw-app-cosmos": "6.30.0",
"@ledgerhq/hw-app-eth": "6.37.1",
"@ledgerhq/hw-transport": "6.31.0",
"@ledgerhq/hw-transport-webusb": "6.29.0",
"@ledgerhq/devices": "8.4.2",
"@ledgerhq/errors": "6.18.0",
"@ledgerhq/hw-app-btc": "10.4.1",
"@ledgerhq/hw-app-cosmos": "6.30.2",
"@ledgerhq/hw-app-eth": "6.38.0",
"@ledgerhq/hw-transport": "6.31.2",
"@ledgerhq/hw-transport-webusb": "6.29.2",
"@ledgerhq/wallet-api-client": "1.5.10",
"@scure/base": "1.1.7",
"@scure/base": "1.1.8",
"@swapkit/helpers": "workspace:*",
"@swapkit/toolbox-cosmos": "workspace:*",
"@swapkit/toolbox-evm": "workspace:*",
Expand All @@ -21,10 +21,7 @@
"ripemd160": "2.0.2"
},
"description": "SwapKit Wallet - Ledger",
"files": [
"src/",
"dist/"
],
"files": ["src/", "dist/"],
"homepage": "https://github.com/thorswap/SwapKit",
"license": "Apache-2.0",
"main": "./dist/index.js",
Expand Down
9 changes: 2 additions & 7 deletions packages/wallets/ledger/src/clients/thorchain/lib.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import crypto from "crypto";
/** ******************************************************************************
* (c) 2019 ZondaX GmbH
* (c) 2016-2017 Ledger
Expand All @@ -15,6 +14,7 @@ import crypto from "crypto";
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************* */
import crypto from "crypto";
import { bech32 } from "@scure/base";
import { LedgerErrorCode } from "@swapkit/helpers";
import Ripemd160 from "ripemd160";
Expand Down Expand Up @@ -65,12 +65,7 @@ export class THORChainApp {

const hashSha256 = crypto.createHash("sha256").update(pk).digest();
const hashRip = new Ripemd160().update(hashSha256).digest();
// @ts-ignore
const encode = bech32.encode || bech32.bech32.encode;
// @ts-ignore
const toWords = bech32.toWords || bech32.bech32.toWords;

return encode(hrp, toWords(hashRip));
return bech32.encode(hrp, bech32.toWords(hashRip), false);
}

async serializePath(path: string) {
Expand Down
Loading
Loading