Skip to content

Commit

Permalink
refactor: add file extension (.js) to non-index package imports in th…
Browse files Browse the repository at this point in the history
…e packages
  • Loading branch information
ShookLyngs committed Jul 5, 2024
1 parent 4f61ed8 commit 6096395
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions packages/btc/src/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ecc from '@bitcoinerlab/secp256k1';
import * as bitcoin from 'bitcoinjs-lib';
import { ECPairFactory, ECPairInterface } from 'ecpair';
import { isTaprootInput } from 'bitcoinjs-lib/src/psbt/bip371';
import { isP2TR, isP2WPKH, isP2PKH } from 'bitcoinjs-lib/src/psbt/psbtutils';
import { isTaprootInput } from 'bitcoinjs-lib/src/psbt/bip371.js';
import { isP2TR, isP2WPKH, isP2PKH } from 'bitcoinjs-lib/src/psbt/psbtutils.js';

bitcoin.initEccLib(ecc);

Expand Down
2 changes: 1 addition & 1 deletion packages/btc/src/preset/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cloneDeep from 'lodash/cloneDeep';
import cloneDeep from 'lodash/cloneDeep.js';
import { bitcoin } from '../bitcoin';
import { ErrorCodes, TxBuildError } from '../error';
import { NetworkType, RgbppBtcConfig } from './types';
Expand Down
18 changes: 9 additions & 9 deletions packages/btc/src/transaction/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import clone from 'lodash/cloneDeep';
import cloneDeep from 'lodash/cloneDeep.js';
import { bitcoin } from '../bitcoin';
import { DataSource } from '../query/source';
import { ErrorCodes, TxBuildError } from '../error';
Expand Down Expand Up @@ -76,7 +76,7 @@ export class TxBuilder {
throw TxBuildError.withComment(ErrorCodes.DUPLICATED_UTXO, `hash: ${utxo.txid}, index: ${utxo.vout}`);
}

utxo = clone(utxo);
utxo = cloneDeep(utxo);
this.inputs.push(utxoToInput(utxo));
}

Expand Down Expand Up @@ -115,7 +115,7 @@ export class TxBuilder {
};
}
if ('address' in output || 'script' in output) {
result = clone(output);
result = cloneDeep(output);
}
if (!result) {
throw new TxBuildError(ErrorCodes.UNSUPPORTED_OUTPUT);
Expand Down Expand Up @@ -149,8 +149,8 @@ export class TxBuilder {
changeIndex: number;
}> {
const { address, publicKey, feeRate, changeAddress, deductFromOutputs, excludeUtxos } = props;
const originalInputs = clone(this.inputs);
const originalOutputs = clone(this.outputs);
const originalInputs = cloneDeep(this.inputs);
const originalOutputs = cloneDeep(this.outputs);

// Create a cache key to enable the internal caching, prevent querying the Utxo[] too often
// TODO: consider provide an option to disable the cache
Expand All @@ -174,8 +174,8 @@ export class TxBuilder {
while (!isFeeExpected) {
if (isLoopedOnce) {
previousFee = currentFee;
this.inputs = clone(originalInputs);
this.outputs = clone(originalOutputs);
this.inputs = cloneDeep(originalInputs);
this.outputs = cloneDeep(originalOutputs);
}

const { needCollect, needReturn, inputsTotal } = this.summary();
Expand Down Expand Up @@ -527,8 +527,8 @@ export class TxBuilder {
minUtxoSatoshi: this.minUtxoSatoshi,
});

tx.inputs = clone(this.inputs);
tx.outputs = clone(this.outputs);
tx.inputs = cloneDeep(this.inputs);
tx.outputs = cloneDeep(this.outputs);

return tx;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/btc/src/transaction/fee.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ECPairInterface } from 'ecpair';
import { AddressType } from '../address';
import { NetworkType } from '../preset/types';
import { toXOnly, tweakSigner } from '../utils';
import { networkTypeToNetwork } from '../preset/network';
import { isP2trScript, isP2wpkhScript } from '../script';
import { bitcoin, ECPair, isTaprootInput } from '../bitcoin';
import { ECPairInterface, bitcoin, ECPair, isTaprootInput } from '../bitcoin';
import { Utxo } from './utxo';

interface FeeEstimateAccount {
Expand Down
2 changes: 1 addition & 1 deletion packages/btc/src/transaction/utxo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cloneDeep from 'lodash/cloneDeep';
import cloneDeep from 'lodash/cloneDeep.js';
import { ErrorCodes, TxBuildError } from '../error';
import { DataSource } from '../query/source';
import { AddressType, AddressToPubkeyMap } from '../address';
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb/src/rgbpp/btc-time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '../utils';
import { buildSpvClientCellDep } from '../utils';
import { blockchain } from '@ckb-lumos/base';
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses';
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses.js';

export const buildBtcTimeUnlockWitness = (btcTxProof: Hex): Hex => {
const btcTimeUnlock = BTCTimeUnlock.pack({ btcTxProof: blockchain.Bytes.pack(btcTxProof) });
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb/src/rgbpp/btc-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
scriptToHash,
serializeWitnessArgs,
} from '@nervosnetwork/ckb-sdk-utils';
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses';
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses.js';

/**
* Generate the virtual ckb transaction for the btc transfer tx
Expand Down
4 changes: 2 additions & 2 deletions packages/ckb/src/rgbpp/ckb-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
u8ToHex,
} from '../utils';
import { InputsCapacityNotEnoughError } from '../error';
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses';
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses.js';
import { buildSpvClientCellDep } from '../utils';
import { RGBPPUnlock, Uint16 } from '../schemas/generated/rgbpp';
import { Bytes } from '@ckb-lumos/base/lib/blockchain';
import { Bytes } from '@ckb-lumos/base/lib/blockchain.js';

export const buildRgbppUnlockWitness = (
btcTxBytes: Hex,
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb/src/spore/spore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
scriptToHash,
serializeWitnessArgs,
} from '@nervosnetwork/ckb-sdk-utils';
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses';
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses.js';

/**
* Generate the virtual ckb transaction for creating spores
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb/src/utils/ckb-tx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { calculateTransactionFee as calculateTxFee } from '@nervosnetwork/ckb-sdk-utils/lib/calculateTransactionFee';
import { calculateTransactionFee as calculateTxFee } from '@nervosnetwork/ckb-sdk-utils/lib/calculateTransactionFee.js';
import { RawClusterData, packRawClusterData, SporeDataProps, packRawSporeData } from '@spore-sdk/core';
import { remove0x, u64ToLe } from './hex';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb/src/utils/spore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
assembleCreateClusterAction,
assembleCreateSporeAction,
assembleTransferClusterAction,
} from '@spore-sdk/core/lib/cobuild';
} from '@spore-sdk/core/lib/cobuild/index.js';
import { u64ToLe } from './hex';
import { Hex, IndexerCell, SporesCreateCobuildParams } from '../types';
import { NoRgbppLiveCellError, RgbppSporeTypeMismatchError, RgbppUtxoBindMultiTypeAssetsError } from '../error';
Expand Down
2 changes: 1 addition & 1 deletion packages/service/src/service/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pickBy from 'lodash/pickBy';
import pickBy from 'lodash/pickBy.js';
import { isDomain } from '../utils';
import { BtcAssetsApiError, ErrorCodes } from '../error';
import { BaseApis, BaseApiRequestOptions, BtcAssetsApiToken, BtcAssetsApiContext, Json } from '../types';
Expand Down

0 comments on commit 6096395

Please sign in to comment.