Skip to content

Commit

Permalink
Merge pull request #712 from BoltzExchange/lazy-loading
Browse files Browse the repository at this point in the history
Lazy loading
  • Loading branch information
michael1011 authored Nov 3, 2024
2 parents daf4c5e + dd15284 commit cd0f73a
Show file tree
Hide file tree
Showing 113 changed files with 2,812 additions and 2,286 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:

- run: npm ci

- run: npm run lint

- run: npm run prettier:check

- run: npm run test
Expand Down
52 changes: 20 additions & 32 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,55 +24,43 @@ const execCommand = async (command: string): Promise<string> => {
}
};

export const getBitcoinAddress = async (): Promise<string> => {
return execCommand("bitcoin-cli-sim-client getnewaddress");
};
export const getBitcoinAddress = (): Promise<string> =>
execCommand("bitcoin-cli-sim-client getnewaddress");

export const getLiquidAddress = async (): Promise<string> => {
return execCommand("elements-cli-sim-client getnewaddress");
};
export const getLiquidAddress = (): Promise<string> =>
execCommand("elements-cli-sim-client getnewaddress");

export const bitcoinSendToAddress = async (
export const bitcoinSendToAddress = (
address: string,
amount: string,
): Promise<string> => {
return execCommand(
`bitcoin-cli-sim-client sendtoaddress "${address}" ${amount}`,
);
};
): Promise<string> =>
execCommand(`bitcoin-cli-sim-client sendtoaddress "${address}" ${amount}`);

export const elementsSendToAddress = async (
export const elementsSendToAddress = (
address: string,
amount: string | number,
): Promise<string> => {
return execCommand(
`elements-cli-sim-client sendtoaddress "${address}" ${amount}`,
);
};
): Promise<string> =>
execCommand(`elements-cli-sim-client sendtoaddress "${address}" ${amount}`);

export const generateBitcoinBlock = async (): Promise<string> => {
return execCommand("bitcoin-cli-sim-client -generate");
};
export const generateBitcoinBlock = (): Promise<string> =>
execCommand("bitcoin-cli-sim-client -generate");

export const generateLiquidBlock = async (): Promise<string> => {
return execCommand("elements-cli-sim-client -generate");
};
export const generateLiquidBlock = (): Promise<string> =>
execCommand("elements-cli-sim-client -generate");

export const getBitcoinWalletTx = async (txId: string): Promise<string> => {
return execCommand(`bitcoin-cli-sim-client gettransaction ${txId}`);
};
export const getBitcoinWalletTx = (txId: string): Promise<string> =>
execCommand(`bitcoin-cli-sim-client gettransaction ${txId}`);

export const payInvoiceLnd = async (invoice: string): Promise<string> => {
return execCommand(`lncli-sim 1 payinvoice -f ${invoice}`);
};
export const payInvoiceLnd = (invoice: string): Promise<string> =>
execCommand(`lncli-sim 1 payinvoice -f ${invoice}`);

export const generateInvoiceLnd = async (amount: number): Promise<string> => {
return JSON.parse(
await execCommand(`lncli-sim 1 addinvoice --amt ${amount}`),
).payment_request;
).payment_request as string;
};

export const getBolt12Offer = async (): Promise<string> => {
return JSON.parse(await execCommand("lightning-cli-sim 1 offer any ''"))
.bolt12;
.bolt12 as string;
};
87 changes: 87 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import pluginJs from "@eslint/js";
import solid from "eslint-plugin-solid";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ files: ["**/*.{js,mjs,cjs,ts,tsx}"] },
{ languageOptions: { globals: globals.browser } },
{
ignores: [
"dist",
"regtest",
"coverage",
"node_modules",
"dnssec-prover",
"jest.config.js",
"babel.config.js",
"vite.config.mjs",
"src/utils/dnssec/dnssec_prover*",
],
},
pluginJs.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
solid.configs["flat/typescript"],
{
languageOptions: {
parserOptions: {
projectService: {
defaultProject: "tsconfig.json",
allowDefaultProject: ["public/*.js", "*.mjs"],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
"no-async-promise-executor": "off",
},
},
{
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
message: "It is a heavy dependency",
group: [
"boltz-bolt12",
"@trezor/connect",
"@trezor/connect-web",
"@ledgerhq/hw-app-eth",
"@ledgerhq/hw-transport",
"@ledgerhq/hw-transport-webhid",
"@vulpemventures/secp256k1-zkp",
],
},
],
},
],
},
},
{
files: ["*/lazy/**"],
rules: {
"no-restricted-imports": "off",
},
},
{
rules: {
"require-await": "error",
"@typescript-eslint/no-floating-promises": "error",

"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/only-throw-error": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/prefer-promise-reject-errors": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
},
},
];
Loading

0 comments on commit cd0f73a

Please sign in to comment.