Skip to content

Commit

Permalink
chore: use prettier import sort
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Jan 6, 2024
1 parent a8e007f commit 7cad601
Show file tree
Hide file tree
Showing 57 changed files with 363 additions and 298 deletions.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrder": ["<THIRD_PARTY_MODULES>", "^[../]", "^[./]"],
"importOrderSeparation": false,
"importOrderSortSpecifiers": true,
"importOrderParserPlugins": ["typescript"],
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
Expand Down
48 changes: 24 additions & 24 deletions lib/Boltz.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { init } from './init';
import Musig from './musig/Musig';
import * as Types from './consts/Types';
import ERC20ABI from '../out/ERC20.sol/ERC20.json';
import ERC20SwapABI from '../out/ERC20Swap.sol/ERC20Swap.json';
import EtherSwapABI from '../out/EtherSwap.sol/EtherSwap.json';
import { targetFee } from './TargetFee';
import Networks from './consts/Networks';
import * as Scripts from './swap/Scripts';
import swapScript from './swap/SwapScript';
import { OutputType } from './consts/Enums';
import * as SwapUtils from './swap/SwapUtils';
import { detectSwap } from './swap/SwapDetector';
import * as TaprootUtils from './swap/TaprootUtils';
import reverseSwapScript from './swap/ReverseSwapScript';
import Networks from './consts/Networks';
import * as Types from './consts/Types';
import {
ClaimDetails,
RefundDetails,
ScriptElement,
TransactionOutput,
} from './consts/Types';
import { init } from './init';
import Musig from './musig/Musig';
import { constructClaimTransaction } from './swap/Claim';
import { detectPreimage } from './swap/PreimageDetector';
import { constructRefundTransaction } from './swap/Refund';
import * as SwapTreeSerializer from './swap/SwapTreeSerializer';
import swapTree, {
extractClaimPublicKeyFromSwapTree,
extractRefundPublicKeyFromSwapTree,
} from './swap/SwapTree';
import reverseSwapScript from './swap/ReverseSwapScript';
import reverseSwapTree, {
extractClaimPublicKeyFromReverseSwapTree,
extractRefundPublicKeyFromReverseSwapTree,
} from './swap/ReverseSwapTree';
import {
ClaimDetails,
RefundDetails,
ScriptElement,
TransactionOutput,
} from './consts/Types';
import ERC20ABI from '../out/ERC20.sol/ERC20.json';
import EtherSwapABI from '../out/EtherSwap.sol/EtherSwap.json';
import ERC20SwapABI from '../out/ERC20Swap.sol/ERC20Swap.json';
import * as Scripts from './swap/Scripts';
import { detectSwap } from './swap/SwapDetector';
import swapScript from './swap/SwapScript';
import swapTree, {
extractClaimPublicKeyFromSwapTree,
extractRefundPublicKeyFromSwapTree,
} from './swap/SwapTree';
import * as SwapTreeSerializer from './swap/SwapTreeSerializer';
import * as SwapUtils from './swap/SwapUtils';
import * as TaprootUtils from './swap/TaprootUtils';

const ContractABIs = {
ERC20: ERC20ABI.abi,
Expand Down
2 changes: 1 addition & 1 deletion lib/consts/Types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BIP32Interface } from 'bip32';
import { ECPairInterface } from 'ecpair';
import { TxOutput } from 'bitcoinjs-lib';
import { Taptree } from 'bitcoinjs-lib/src/types';
import { ECPairInterface } from 'ecpair';
import { OutputType } from './Enums';

export type Error = {
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { confidential, TxOutput } from 'liquidjs-lib';
import { TxOutput, confidential } from 'liquidjs-lib';
import { confidentialLiquid } from './init';

export const getOutputValue = (
Expand Down
8 changes: 4 additions & 4 deletions lib/liquid/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { init } from './init';
import Networks from './consts/Networks';
import { getOutputValue } from './Utils';
import * as TaprootUtils from './swap/TaprooUtils';
import Networks from './consts/Networks';
import { LiquidClaimDetails, LiquidRefundDetails } from './consts/Types';
import { init } from './init';
import { constructClaimTransaction } from './swap/Claim';
import { constructRefundTransaction } from './swap/Refund';
import { LiquidClaimDetails, LiquidRefundDetails } from './consts/Types';
import * as TaprootUtils from './swap/TaprooUtils';

export {
Networks,
Expand Down
4 changes: 2 additions & 2 deletions lib/liquid/init.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { confidential } from 'liquidjs-lib';
import { ECPairAPI, ECPairFactory } from 'ecpair';
import { Secp256k1ZKP } from '@vulpemventures/secp256k1-zkp';
import { ECPairAPI, ECPairFactory } from 'ecpair';
import { confidential } from 'liquidjs-lib';

export let secp: Secp256k1ZKP;
export let ecpair: ECPairAPI;
Expand Down
18 changes: 9 additions & 9 deletions lib/liquid/swap/Claim.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import ops from '@boltz/bitcoin-ops';
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371';
import {
Blinder,
Creator,
CreatorInput,
CreatorOutput,
crypto,
Extractor,
Finalizer,
Pset,
script,
Signer,
Transaction,
Updater,
witnessStackToScriptWitness,
ZKPGenerator,
ZKPValidator,
crypto,
script,
witnessStackToScriptWitness,
} from 'liquidjs-lib';
import { Network } from 'liquidjs-lib/src/networks';
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371';
import { reverseBuffer, varuint } from 'liquidjs-lib/src/bufferutils';
import { ecpair, secp } from '../init';
import Networks from '../consts/Networks';
import { getOutputValue } from '../Utils';
import { Network } from 'liquidjs-lib/src/networks';
import { getHexString } from '../../Utils';
import { OutputType } from '../../consts/Enums';
import { validateInputs } from '../../swap/Claim';
import { LiquidClaimDetails } from '../consts/Types';
import { scriptBuffersToScript } from '../../swap/SwapUtils';
import { getOutputValue } from '../Utils';
import Networks from '../consts/Networks';
import { LiquidClaimDetails } from '../consts/Types';
import { ecpair, secp } from '../init';
import { createControlBlock, tapLeafHash, toHashTree } from './TaprooUtils';

const dummyTaprootSignature = Buffer.alloc(64);
Expand Down
6 changes: 3 additions & 3 deletions lib/liquid/swap/Refund.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Transaction } from 'liquidjs-lib';
import { getHexBuffer } from '../../Utils';
import { constructClaimTransaction } from './Claim';
import { LiquidClaimDetails, LiquidRefundDetails } from '../consts/Types';
import { Network } from 'liquidjs-lib/src/networks';
import { getHexBuffer } from '../../Utils';
import Networks from '../consts/Networks';
import { LiquidClaimDetails, LiquidRefundDetails } from '../consts/Types';
import { constructClaimTransaction } from './Claim';

const dummyPreimage = getHexBuffer('0x00');

Expand Down
16 changes: 8 additions & 8 deletions lib/liquid/swap/TaprooUtils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Transaction } from 'liquidjs-lib';
import { Network } from 'liquidjs-lib/src/networks';
import { taggedHash } from 'liquidjs-lib/src/crypto';
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371';
import { isTapleaf, Taptree } from 'bitcoinjs-lib/src/types';
import { Taptree, isTapleaf } from 'bitcoinjs-lib/src/types';
import { Transaction } from 'liquidjs-lib';
import {
HashTree,
TaprootLeaf,
toHashTree as liquidToHashTree,
tapLeafHash as liquidTapLeafHash,
findScriptPath as liquidFindScriptPath,
tapLeafHash as liquidTapLeafHash,
toHashTree as liquidToHashTree,
} from 'liquidjs-lib/src/bip341';
import { secp } from '../init';
import Musig from '../../musig/Musig';
import { taggedHash } from 'liquidjs-lib/src/crypto';
import { Network } from 'liquidjs-lib/src/networks';
import { getHexString } from '../../Utils';
import { Tapleaf } from '../../consts/Types';
import Musig from '../../musig/Musig';
import { LiquidRefundDetails } from '../consts/Types';
import { secp } from '../init';

const convertLeaf = (leaf: Tapleaf) => ({
version: leaf.version,
Expand Down
2 changes: 1 addition & 1 deletion lib/musig/Musig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ECPairInterface } from 'ecpair';
import { Secp256k1ZKP } from '@vulpemventures/secp256k1-zkp';
import { ECPairInterface } from 'ecpair';
import { getHexString } from '../Utils';

class Musig {
Expand Down
7 changes: 3 additions & 4 deletions lib/swap/Claim.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* This file is based on the repository github.com/submarineswaps/swaps-service created by Alex Bosworth
*/

import * as bip65 from 'bip65';
import ops from '@boltz/bitcoin-ops';
import * as varuint from 'varuint-bitcoin';
import { crypto, script, Transaction } from 'bitcoinjs-lib';
import * as bip65 from 'bip65';
import { Transaction, crypto, script } from 'bitcoinjs-lib';
import { tapleafHash, toHashTree } from 'bitcoinjs-lib/src/payments/bip341';
import * as varuint from 'varuint-bitcoin';
import { getHexString } from '../Utils';
import { OutputType } from '../consts/Enums';
import { ClaimDetails } from '../consts/Types';
Expand Down
3 changes: 1 addition & 2 deletions lib/swap/Refund.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* This file is based on the repository github.com/submarineswaps/swaps-service created by Alex Bosworth
*/

import { Transaction } from 'bitcoinjs-lib';
import { getHexBuffer } from '../Utils';
import { ClaimDetails, RefundDetails } from '../consts/Types';
import { constructClaimTransaction } from './Claim';
import { RefundDetails, ClaimDetails } from '../consts/Types';

const dummyPreimage = getHexBuffer('0x00');

Expand Down
5 changes: 2 additions & 3 deletions lib/swap/ReverseSwapScript.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/**
* This file is based on the repository github.com/submarineswaps/swaps-service created by Alex Bosworth
*/

import ops from '@boltz/bitcoin-ops';
import { script, crypto } from 'bitcoinjs-lib';
import { toPushdataScript, encodeCltv } from './SwapUtils';
import { crypto, script } from 'bitcoinjs-lib';
import { encodeCltv, toPushdataScript } from './SwapUtils';

/**
* Generate a reverse swap redeem script
Expand Down
2 changes: 1 addition & 1 deletion lib/swap/ReverseSwapTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import ops from '@boltz/bitcoin-ops';
import { crypto, script } from 'bitcoinjs-lib';
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371';
import { SwapTree } from '../consts/Types';
import { createLeaf, swapLeafsToTree } from './TaprootUtils';
import {
createRefundLeaf,
extractRefundPublicKeyFromSwapTree,
} from './SwapTree';
import { createLeaf, swapLeafsToTree } from './TaprootUtils';

export const extractClaimPublicKeyFromReverseSwapTree = (
swapTree: SwapTree,
Expand Down
1 change: 0 additions & 1 deletion lib/swap/Scripts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* This file is based on the repository github.com/submarineswaps/swaps-service created by Alex Bosworth
*/

import ops from '@boltz/bitcoin-ops';
import { crypto, script } from 'bitcoinjs-lib';
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371';
Expand Down
1 change: 0 additions & 1 deletion lib/swap/SwapDetector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* This file is based on the repository github.com/submarineswaps/swaps-service created by Alex Bosworth
*/

import { Transaction, TxOutput } from 'bitcoinjs-lib';
import { OutputType } from '../consts/Enums';
import {
Expand Down
3 changes: 1 addition & 2 deletions lib/swap/SwapScript.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/**
* This file is based on the repository github.com/submarineswaps/swaps-service created by Alex Bosworth
*/

import ops from '@boltz/bitcoin-ops';
import { crypto } from 'bitcoinjs-lib';
import { toPushdataScript, encodeCltv } from './SwapUtils';
import { encodeCltv, toPushdataScript } from './SwapUtils';

/**
* Generate a swap redeem script
Expand Down
2 changes: 1 addition & 1 deletion lib/swap/SwapTree.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ops from '@boltz/bitcoin-ops';
import { crypto, script } from 'bitcoinjs-lib';
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371';
import { encodeCltv } from './SwapUtils';
import { SwapTree } from '../consts/Types';
import { encodeCltv } from './SwapUtils';
import { createLeaf, swapLeafsToTree } from './TaprootUtils';

export const createRefundLeaf = (
Expand Down
4 changes: 2 additions & 2 deletions lib/swap/SwapTreeSerializer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { swapLeafsToTree } from './TaprootUtils';
import { SwapTree, Tapleaf } from '../consts/Types';
import { getHexBuffer, getHexString } from '../Utils';
import { SwapTree, Tapleaf } from '../consts/Types';
import { swapLeafsToTree } from './TaprootUtils';

type SerializedLeaf = {
version: number;
Expand Down
11 changes: 5 additions & 6 deletions lib/swap/SwapUtils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/**
* This file is based on the repository github.com/submarineswaps/swaps-service created by Alex Bosworth
*/

import Bn from 'bn.js';
import bip66 from 'bip66';
import * as bip65 from 'bip65';
import ops from '@boltz/bitcoin-ops';
import * as bip65 from 'bip65';
import bip66 from 'bip66';
import { script } from 'bitcoinjs-lib';
import Bn from 'bn.js';
import * as varuint from 'varuint-bitcoin';
import { ScriptElement } from '../consts/Types';
import { Output, OutputType } from '../consts/Enums';
import { getHexBuffer, getHexString } from '../Utils';
import { Output, OutputType } from '../consts/Enums';
import { ScriptElement } from '../consts/Types';

const zeroHexBuffer = getHexBuffer('00');

Expand Down
10 changes: 5 additions & 5 deletions lib/swap/TaprootUtils.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Transaction } from 'bitcoinjs-lib';
import {
findScriptPath,
HashTree,
LEAF_VERSION_TAPSCRIPT,
tapleafHash,
findScriptPath,
tapTweakHash,
tapleafHash,
toHashTree,
tweakKey,
} from 'bitcoinjs-lib/src/payments/bip341';
import { Transaction } from 'bitcoinjs-lib';
import { Taptree } from 'bitcoinjs-lib/src/types';
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371';
import { Taptree } from 'bitcoinjs-lib/src/types';
import { RefundDetails, ScriptElement, Tapleaf } from '../consts/Types';
import Musig from '../musig/Musig';
import { toPushdataScript } from './SwapUtils';
import { RefundDetails, ScriptElement, Tapleaf } from '../consts/Types';

export const leafVersionLiquid = 196;

Expand Down
Loading

0 comments on commit 7cad601

Please sign in to comment.