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
196 changes: 72 additions & 124 deletions bun.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"dependencies": { "@swapkit/cosmos-signer": "0.2.0" },
"devDependencies": {
"@biomejs/biome": "2.4.13",
"@changesets/changelog-github": "0.6.0",
Expand All @@ -21,7 +22,7 @@
"zod": "4.4.3"
},
"name": "swapkit-wallets",
"overrides": { "@swapkit/cosmos-signer": "0.1.0", "nuqs": "2.8.9" },
"overrides": { "nuqs": "2.8.9" },
"packageManager": "bun@1.3.13",
"private": true,
"scripts": {
Expand Down
15 changes: 3 additions & 12 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,12 @@
"types": "./dist/types/wallets.d.ts"
}
},
"files": [
"dist/",
"src/"
],
"files": ["dist/", "src/"],
"homepage": "https://github.com/swapkit/wallets",
"license": "SEE LICENSE IN LICENSE",
"name": "@swapkit/sdk",
"publishConfig": {
"access": "public"
},
"repository": {
"directory": "packages/sdk",
"type": "git",
"url": "git+https://github.com/swapkit/wallets.git"
},
"publishConfig": { "access": "public" },
"repository": { "directory": "packages/sdk", "type": "git", "url": "git+https://github.com/swapkit/wallets.git" },
"scripts": {
"build": "bun run ./build.ts",
"build:clean": "rm -rf dist && bun run ./build.ts",
Expand Down
9 changes: 2 additions & 7 deletions packages/wallet-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,11 @@
"types": "./dist/types/vultisig/index.d.ts"
}
},
"files": [
"dist/",
"src/"
],
"files": ["dist/", "src/"],
"homepage": "https://github.com/swapkit/wallets",
"license": "SEE LICENSE IN LICENSE",
"name": "@swapkit/wallet-extensions",
"publishConfig": {
"access": "public"
},
"publishConfig": { "access": "public" },
"repository": {
"directory": "packages/wallet-extensions",
"type": "git",
Expand Down
14 changes: 13 additions & 1 deletion packages/wallet-extensions/test/evm-extensions.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { beforeEach, describe, expect, mock, test } from "bun:test";
import { afterAll, beforeEach, describe, expect, mock, test } from "bun:test";
import { Chain, WalletOption } from "@swapkit/helpers";
import * as realEvmToolbox from "@swapkit/toolboxes/evm";
import * as realEthers from "ethers";

let balanceAddressCalls: string[] = [];

Expand Down Expand Up @@ -56,6 +58,11 @@ class MockBrowserProvider {
}
}

// mock.module replaces the whole export namespace process-wide; snapshot the real
// modules so afterAll can restore them for test files that run later.
const realEthersSnapshot = { ...realEthers };
const realEvmToolboxSnapshot = { ...realEvmToolbox };

mock.module("ethers", () => ({ BrowserProvider: MockBrowserProvider }));

mock.module("@swapkit/toolboxes/evm", () => ({
Expand Down Expand Up @@ -109,3 +116,8 @@ describe("evm extensions wallet", () => {
expect(provider.listeners.size).toBe(0);
});
});

afterAll(() => {
mock.module("ethers", () => realEthersSnapshot);
mock.module("@swapkit/toolboxes/evm", () => realEvmToolboxSnapshot);
});
12 changes: 11 additions & 1 deletion packages/wallet-extensions/test/phantom.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { beforeEach, describe, expect, mock, test } from "bun:test";
import { afterAll, beforeEach, describe, expect, mock, test } from "bun:test";
import * as realSolanaWeb3 from "@solana/web3.js";
import { AssetValue, Chain } from "@swapkit/helpers";
import * as realSolanaToolbox from "@swapkit/toolboxes/solana";

let createTransactionParams: Record<string, unknown> | undefined;

const realSolanaWeb3Snapshot = { ...realSolanaWeb3 };
const realSolanaToolboxSnapshot = { ...realSolanaToolbox };

mock.module("@solana/web3.js", () => ({
PublicKey: class PublicKey {
constructor(readonly value: string) {}
Expand Down Expand Up @@ -60,3 +65,8 @@ describe("phantom wallet", () => {
expect(createTransactionParams?.memo).toBe("=:ETH.ETH:0xabc");
});
});

afterAll(() => {
mock.module("@solana/web3.js", () => realSolanaWeb3Snapshot);
mock.module("@swapkit/toolboxes/solana", () => realSolanaToolboxSnapshot);
});
9 changes: 2 additions & 7 deletions packages/wallet-hardware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,11 @@
"types": "./dist/types/trezor/index.d.ts"
}
},
"files": [
"dist/",
"src/"
],
"files": ["dist/", "src/"],
"homepage": "https://github.com/swapkit/wallets",
"license": "SEE LICENSE IN LICENSE",
"name": "@swapkit/wallet-hardware",
"publishConfig": {
"access": "public"
},
"publishConfig": { "access": "public" },
"repository": {
"directory": "packages/wallet-hardware",
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { describe, expect, it, mock } from "bun:test";
import { afterAll, describe, expect, it, mock } from "bun:test";
import { hex } from "@scure/base";
import { Chain } from "@swapkit/helpers";
import * as realUtxoToolbox from "@swapkit/toolboxes/utxo";
import { RawTx, Transaction } from "@swapkit/utxo-signer";

const rawTxRequests: Array<{ chain: string; txid: string }> = [];

const realUtxoToolboxSnapshot = { ...realUtxoToolbox };

mock.module("@swapkit/toolboxes/utxo", () => ({
getUtxoApi: (chain: string) => ({
getRawTx: (txid: string) => {
Expand Down Expand Up @@ -89,3 +92,7 @@ describe("ledger legacy UTXO adapter", () => {
expect(signedTxHex).toBe("0200000000");
});
});

afterAll(() => {
mock.module("@swapkit/toolboxes/utxo", () => realUtxoToolboxSnapshot);
});
15 changes: 3 additions & 12 deletions packages/wallet-mobile/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"author": "swapkit",
"dependencies": {
"@swapkit/helpers": "^5.0.0",
"@swapkit/toolboxes": "^5.0.0",
"@swapkit/wallet-core": "^5.0.0"
},
"dependencies": { "@swapkit/helpers": "^5.0.0", "@swapkit/toolboxes": "^5.0.0", "@swapkit/wallet-core": "^5.0.0" },
"description": "SwapKit - Wallet Mobile",
"exports": {
".": {
Expand All @@ -14,16 +10,11 @@
"types": "./dist/types/index.d.ts"
}
},
"files": [
"dist/",
"src/"
],
"files": ["dist/", "src/"],
"homepage": "https://github.com/swapkit/wallets",
"license": "SEE LICENSE IN LICENSE",
"name": "@swapkit/wallet-mobile",
"publishConfig": {
"access": "public"
},
"publishConfig": { "access": "public" },
"repository": {
"directory": "packages/wallet-mobile",
"type": "git",
Expand Down
15 changes: 3 additions & 12 deletions packages/wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,12 @@
"types": "./dist/types/xaman/index.d.ts"
}
},
"files": [
"dist/",
"src/"
],
"files": ["dist/", "src/"],
"homepage": "https://github.com/swapkit/wallets",
"license": "SEE LICENSE IN LICENSE",
"name": "@swapkit/wallets",
"publishConfig": {
"access": "public"
},
"repository": {
"directory": "packages/wallets",
"type": "git",
"url": "git+https://github.com/swapkit/wallets.git"
},
"publishConfig": { "access": "public" },
"repository": { "directory": "packages/wallets", "type": "git", "url": "git+https://github.com/swapkit/wallets.git" },
"scripts": {
"build": "bun run ./build.ts",
"build:clean": "rm -rf dist && bun run ./build.ts",
Expand Down
18 changes: 17 additions & 1 deletion packages/wallets/test/metamask.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { beforeEach, describe, expect, mock, test } from "bun:test";
import { afterAll, beforeEach, describe, expect, mock, test } from "bun:test";
import * as realConnectMultichain from "@metamask/connect-multichain";
import { Chain, SwapKitError, WalletOption } from "@swapkit/helpers";
import * as realSolanaToolbox from "@swapkit/toolboxes/solana";
import * as realEvmExtensions from "@swapkit/wallet-extensions/evm-extensions";
import * as realEthers from "ethers";

const SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
const ETHEREUM_ADDRESS = "0x1111111111111111111111111111111111111111";
Expand Down Expand Up @@ -45,6 +49,11 @@ const mockClient = {
provider: { getSession: async () => sessionData },
};

const realConnectMultichainSnapshot = { ...realConnectMultichain };
const realEthersSnapshot = { ...realEthers };
const realEvmExtensionsSnapshot = { ...realEvmExtensions };
const realSolanaToolboxSnapshot = { ...realSolanaToolbox };

mock.module("@metamask/connect-multichain", () => ({
createMultichainClient: (options: unknown) => {
createClientOptions.push(options);
Expand Down Expand Up @@ -218,3 +227,10 @@ describe("metamask multichain wallet", () => {
).rejects.toThrow("wallet_connection_rejected_by_user");
});
});

afterAll(() => {
mock.module("@metamask/connect-multichain", () => realConnectMultichainSnapshot);
mock.module("ethers", () => realEthersSnapshot);
mock.module("@swapkit/wallet-extensions/evm-extensions", () => realEvmExtensionsSnapshot);
mock.module("@swapkit/toolboxes/solana", () => realSolanaToolboxSnapshot);
});
6 changes: 1 addition & 5 deletions playgrounds/vite-lite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
},
"name": "@internal/playground-vite-lite",
"private": true,
"scripts": {
"build": "vite build",
"dev": "vite",
"preview": "vite preview"
},
"scripts": { "build": "vite build", "dev": "vite", "preview": "vite preview" },
"type": "module",
"version": "0.0.9"
}
Loading