diff --git a/README.md b/README.md index 37b5210..085d741 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ Use `ZgFile` to create a file object, then call `merkleTree` method to get the m ```js import { Indexer, ZgFile } from '@0glabs/0g-ts-sdk'; -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers, BrowserProvider } = pkg; import { exit } from 'process'; const file = await ZgFile.fromFilePath(); diff --git a/lib.commonjs/file/AbstractFile.d.ts b/lib.commonjs/file/AbstractFile.d.ts index 71eee6e..87f3f46 100644 --- a/lib.commonjs/file/AbstractFile.d.ts +++ b/lib.commonjs/file/AbstractFile.d.ts @@ -1,4 +1,5 @@ -import { BytesLike } from 'ethers'; +import pkg from 'ethers'; +const { BytesLike } = pkg; import { MerkleTree } from './MerkleTree.js'; import { SubmissionNodeStruct, SubmissionStruct } from '../contracts/flow/FixedPriceFlow.js'; import { Iterator } from './Iterator/index.js'; @@ -16,4 +17,4 @@ export declare abstract class AbstractFile { createNode(offset: number, chunks: number): Promise<[SubmissionNodeStruct | null, Error | null]>; createSegmentNode(offset: number, batch: number, size: number): Promise<[SubmissionNodeStruct | null, Error | null]>; } -//# sourceMappingURL=AbstractFile.d.ts.map \ No newline at end of file +//# sourceMappingURL=AbstractFile.d.ts.map diff --git a/lib.commonjs/indexer/Indexer.d.ts b/lib.commonjs/indexer/Indexer.d.ts index 62a8d1c..2064690 100644 --- a/lib.commonjs/indexer/Indexer.d.ts +++ b/lib.commonjs/indexer/Indexer.d.ts @@ -5,7 +5,8 @@ import { UploadOption, Uploader } from '../transfer/index.js'; import { StorageNode } from '../node/index.js'; import { RetryOpts } from '../types.js'; import { AbstractFile } from '../file/AbstractFile.js'; -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; export declare class Indexer extends HttpProvider { constructor(url: string); getShardedNodes(): Promise; @@ -16,4 +17,4 @@ export declare class Indexer extends HttpProvider { upload(file: AbstractFile, blockchain_rpc: string, signer: ethers.Wallet, opts?: UploadOption, retryOpts?: RetryOpts): Promise<[string, Error | null]>; download(rootHash: string, filePath: string, proof: boolean): Promise; } -//# sourceMappingURL=Indexer.d.ts.map \ No newline at end of file +//# sourceMappingURL=Indexer.d.ts.map diff --git a/lib.commonjs/transfer/Uploader.d.ts b/lib.commonjs/transfer/Uploader.d.ts index ba93f59..5072321 100644 --- a/lib.commonjs/transfer/Uploader.d.ts +++ b/lib.commonjs/transfer/Uploader.d.ts @@ -2,7 +2,8 @@ import { StorageNode, SegmentWithProof, FileInfo } from '../node/index.js'; import { FixedPriceFlow } from '../contracts/flow/FixedPriceFlow.js'; import { RetryOpts } from '../types.js'; import { MerkleTree } from '../file/index.js'; -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; import { UploadOption, UploadTask } from './types.js'; import { AbstractFile } from '../file/AbstractFile.js'; export declare class Uploader { @@ -21,4 +22,4 @@ export declare class Uploader { getSegment(file: AbstractFile, tree: MerkleTree, segIndex: number): Promise<[boolean, SegmentWithProof | null, Error | null]>; uploadTask(file: AbstractFile, tree: MerkleTree, uploadTask: UploadTask): Promise; } -//# sourceMappingURL=Uploader.d.ts.map \ No newline at end of file +//# sourceMappingURL=Uploader.d.ts.map diff --git a/lib.commonjs/transfer/types.d.ts b/lib.commonjs/transfer/types.d.ts index 7afa393..5d69bc6 100644 --- a/lib.commonjs/transfer/types.d.ts +++ b/lib.commonjs/transfer/types.d.ts @@ -1,4 +1,5 @@ -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; export interface UploadTask { clientIndex: number; taskSize: number; @@ -15,4 +16,4 @@ export interface UploadOption { fee: bigint; } export declare var defaultUploadOption: UploadOption; -//# sourceMappingURL=types.d.ts.map \ No newline at end of file +//# sourceMappingURL=types.d.ts.map diff --git a/lib.commonjs/utils.d.ts b/lib.commonjs/utils.d.ts index 1e8a841..18edb85 100644 --- a/lib.commonjs/utils.d.ts +++ b/lib.commonjs/utils.d.ts @@ -1,8 +1,8 @@ -import { Signer } from 'ethers'; -import { ContractRunner } from 'ethers'; +import pkg from 'ethers'; +const { Signer, ContractRunner } = pkg; export declare function getFlowContract(address: string, signer: Signer): import("./contracts/flow/FixedPriceFlow.js").FixedPriceFlow; export declare function getMarketContract(address: string, runner: ContractRunner): import("./contracts/market/FixedPrice.js").FixedPrice; export declare function checkExist(inputPath: string): boolean; export declare function GetSplitNum(total: number, unit: number): number; export declare const delay: (ms: number) => Promise; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file +//# sourceMappingURL=utils.d.ts.map diff --git a/lib.esm/file/AbstractFile.d.ts b/lib.esm/file/AbstractFile.d.ts index 71eee6e..87f3f46 100644 --- a/lib.esm/file/AbstractFile.d.ts +++ b/lib.esm/file/AbstractFile.d.ts @@ -1,4 +1,5 @@ -import { BytesLike } from 'ethers'; +import pkg from 'ethers'; +const { BytesLike } = pkg; import { MerkleTree } from './MerkleTree.js'; import { SubmissionNodeStruct, SubmissionStruct } from '../contracts/flow/FixedPriceFlow.js'; import { Iterator } from './Iterator/index.js'; @@ -16,4 +17,4 @@ export declare abstract class AbstractFile { createNode(offset: number, chunks: number): Promise<[SubmissionNodeStruct | null, Error | null]>; createSegmentNode(offset: number, batch: number, size: number): Promise<[SubmissionNodeStruct | null, Error | null]>; } -//# sourceMappingURL=AbstractFile.d.ts.map \ No newline at end of file +//# sourceMappingURL=AbstractFile.d.ts.map diff --git a/lib.esm/indexer/Indexer.d.ts b/lib.esm/indexer/Indexer.d.ts index 62a8d1c..2064690 100644 --- a/lib.esm/indexer/Indexer.d.ts +++ b/lib.esm/indexer/Indexer.d.ts @@ -5,7 +5,8 @@ import { UploadOption, Uploader } from '../transfer/index.js'; import { StorageNode } from '../node/index.js'; import { RetryOpts } from '../types.js'; import { AbstractFile } from '../file/AbstractFile.js'; -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; export declare class Indexer extends HttpProvider { constructor(url: string); getShardedNodes(): Promise; @@ -16,4 +17,4 @@ export declare class Indexer extends HttpProvider { upload(file: AbstractFile, blockchain_rpc: string, signer: ethers.Wallet, opts?: UploadOption, retryOpts?: RetryOpts): Promise<[string, Error | null]>; download(rootHash: string, filePath: string, proof: boolean): Promise; } -//# sourceMappingURL=Indexer.d.ts.map \ No newline at end of file +//# sourceMappingURL=Indexer.d.ts.map diff --git a/lib.esm/kv/builder.js b/lib.esm/kv/builder.js index efddf08..af9c309 100644 --- a/lib.esm/kv/builder.js +++ b/lib.esm/kv/builder.js @@ -1,4 +1,5 @@ -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; import { MAX_KEY_SIZE, MAX_SET_SIZE, STREAM_DOMAIN } from './constants.js'; import { StreamData } from './types.js'; export class StreamDataBuilder { @@ -128,4 +129,4 @@ export class StreamDataBuilder { return this.controls; } } -//# sourceMappingURL=builder.js.map \ No newline at end of file +//# sourceMappingURL=builder.js.map diff --git a/lib.esm/kv/types.js b/lib.esm/kv/types.js index 4dc6e94..04d9d3e 100644 --- a/lib.esm/kv/types.js +++ b/lib.esm/kv/types.js @@ -1,4 +1,5 @@ -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; var AccessControlType; (function (AccessControlType) { AccessControlType[AccessControlType["GrantAdminRole"] = 0] = "GrantAdminRole"; @@ -131,4 +132,4 @@ export class StreamData { return encoded; } } -//# sourceMappingURL=types.js.map \ No newline at end of file +//# sourceMappingURL=types.js.map diff --git a/lib.esm/transfer/Downloader.js b/lib.esm/transfer/Downloader.js index ec35a33..267a082 100644 --- a/lib.esm/transfer/Downloader.js +++ b/lib.esm/transfer/Downloader.js @@ -1,7 +1,8 @@ import fs from 'fs'; import { DEFAULT_SEGMENT_MAX_CHUNKS, DEFAULT_CHUNK_SIZE } from '../constant.js'; import { GetSplitNum, checkExist } from '../utils.js'; -import { decodeBase64 } from 'ethers'; +import pkg from 'ethers'; +const { decodeBase64 } = pkg; import { getShardConfigs } from './utils.js'; export class Downloader { nodes; @@ -106,4 +107,4 @@ export class Downloader { return null; } } -//# sourceMappingURL=Downloader.js.map \ No newline at end of file +//# sourceMappingURL=Downloader.js.map diff --git a/lib.esm/transfer/Uploader.d.ts b/lib.esm/transfer/Uploader.d.ts index ba93f59..5072321 100644 --- a/lib.esm/transfer/Uploader.d.ts +++ b/lib.esm/transfer/Uploader.d.ts @@ -2,7 +2,8 @@ import { StorageNode, SegmentWithProof, FileInfo } from '../node/index.js'; import { FixedPriceFlow } from '../contracts/flow/FixedPriceFlow.js'; import { RetryOpts } from '../types.js'; import { MerkleTree } from '../file/index.js'; -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; import { UploadOption, UploadTask } from './types.js'; import { AbstractFile } from '../file/AbstractFile.js'; export declare class Uploader { @@ -21,4 +22,4 @@ export declare class Uploader { getSegment(file: AbstractFile, tree: MerkleTree, segIndex: number): Promise<[boolean, SegmentWithProof | null, Error | null]>; uploadTask(file: AbstractFile, tree: MerkleTree, uploadTask: UploadTask): Promise; } -//# sourceMappingURL=Uploader.d.ts.map \ No newline at end of file +//# sourceMappingURL=Uploader.d.ts.map diff --git a/lib.esm/transfer/Uploader.js b/lib.esm/transfer/Uploader.js index ba96879..fc9ec93 100644 --- a/lib.esm/transfer/Uploader.js +++ b/lib.esm/transfer/Uploader.js @@ -1,7 +1,8 @@ import { DEFAULT_SEGMENT_SIZE, DEFAULT_SEGMENT_MAX_CHUNKS, DEFAULT_CHUNK_SIZE, } from '../constant.js'; import { delay, getMarketContract } from '../utils.js'; import { numSplits } from '../file/index.js'; -import { encodeBase64, ethers } from 'ethers'; +import pkg from 'ethers'; +const { encodeBase64, ethers } = pkg; import { calculatePrice, getShardConfigs } from './utils.js'; import { checkReplica } from '../common/index.js'; export class Uploader { @@ -248,4 +249,4 @@ export class Uploader { return res; } } -//# sourceMappingURL=Uploader.js.map \ No newline at end of file +//# sourceMappingURL=Uploader.js.map diff --git a/lib.esm/transfer/types.d.ts b/lib.esm/transfer/types.d.ts index 7afa393..5d69bc6 100644 --- a/lib.esm/transfer/types.d.ts +++ b/lib.esm/transfer/types.d.ts @@ -1,4 +1,5 @@ -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; export interface UploadTask { clientIndex: number; taskSize: number; @@ -15,4 +16,4 @@ export interface UploadOption { fee: bigint; } export declare var defaultUploadOption: UploadOption; -//# sourceMappingURL=types.d.ts.map \ No newline at end of file +//# sourceMappingURL=types.d.ts.map diff --git a/lib.esm/utils.d.ts b/lib.esm/utils.d.ts index 1e8a841..18edb85 100644 --- a/lib.esm/utils.d.ts +++ b/lib.esm/utils.d.ts @@ -1,8 +1,8 @@ -import { Signer } from 'ethers'; -import { ContractRunner } from 'ethers'; +import pkg from 'ethers'; +const { Signer, ContractRunner } = pkg; export declare function getFlowContract(address: string, signer: Signer): import("./contracts/flow/FixedPriceFlow.js").FixedPriceFlow; export declare function getMarketContract(address: string, runner: ContractRunner): import("./contracts/market/FixedPrice.js").FixedPrice; export declare function checkExist(inputPath: string): boolean; export declare function GetSplitNum(total: number, unit: number): number; export declare const delay: (ms: number) => Promise; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file +//# sourceMappingURL=utils.d.ts.map diff --git a/src.ts/file/AbstractFile.ts b/src.ts/file/AbstractFile.ts index b31d387..e73f23e 100644 --- a/src.ts/file/AbstractFile.ts +++ b/src.ts/file/AbstractFile.ts @@ -1,4 +1,5 @@ -import { BytesLike } from 'ethers' +import pkg from 'ethers'; +const { BytesLike } = pkg; import { MerkleTree } from './MerkleTree.js' import { SubmissionNodeStruct, diff --git a/src.ts/indexer/Indexer.ts b/src.ts/indexer/Indexer.ts index 5190bff..9c465ef 100644 --- a/src.ts/indexer/Indexer.ts +++ b/src.ts/indexer/Indexer.ts @@ -5,7 +5,8 @@ import { UploadOption, Uploader, Downloader } from '../transfer/index.js' import { StorageNode } from '../node/index.js' import { RetryOpts } from '../types.js' import { AbstractFile } from '../file/AbstractFile.js' -import { ethers } from 'ethers' +import pkg from 'ethers'; +const { ethers } = pkg; import { getFlowContract } from '../utils.js' export class Indexer extends HttpProvider { diff --git a/src.ts/kv/builder.ts b/src.ts/kv/builder.ts index cba7368..0dc8bbb 100644 --- a/src.ts/kv/builder.ts +++ b/src.ts/kv/builder.ts @@ -1,4 +1,5 @@ -import { ethers } from 'ethers' +import pkg from 'ethers'; +const { ethers } = pkg; import { MAX_KEY_SIZE, MAX_SET_SIZE, STREAM_DOMAIN } from './constants.js' import { AccessControl, StreamData } from './types.js' import { Bytes } from '@ethersproject/bytes' diff --git a/src.ts/kv/types.ts b/src.ts/kv/types.ts index 686e88a..e9c975f 100644 --- a/src.ts/kv/types.ts +++ b/src.ts/kv/types.ts @@ -1,5 +1,5 @@ -import { ethers } from 'ethers' - +import pkg from 'ethers'; +const { ethers } = pkg; // Assuming common.Hash and common.Address are hex strings type Hash = string type Address = string diff --git a/src.ts/transfer/Downloader.ts b/src.ts/transfer/Downloader.ts index e9d5be1..62fe7bb 100644 --- a/src.ts/transfer/Downloader.ts +++ b/src.ts/transfer/Downloader.ts @@ -2,7 +2,8 @@ import fs from 'fs' import { DEFAULT_SEGMENT_MAX_CHUNKS, DEFAULT_CHUNK_SIZE } from '../constant.js' import { GetSplitNum, checkExist } from '../utils.js' import { StorageNode, Segment, FileInfo } from '../node/index.js' -import { decodeBase64 } from 'ethers' +import pkg from 'ethers'; +const { decodeBase64 } = pkg; import { Hash } from '../types.js' import { getShardConfigs } from './utils.js' import { ShardConfig } from '../common/index.js' diff --git a/src.ts/transfer/Uploader.ts b/src.ts/transfer/Uploader.ts index 40101d4..a492373 100644 --- a/src.ts/transfer/Uploader.ts +++ b/src.ts/transfer/Uploader.ts @@ -8,7 +8,8 @@ import { FixedPriceFlow } from '../contracts/flow/FixedPriceFlow.js' import { delay, getMarketContract } from '../utils.js' import { RetryOpts } from '../types.js' import { MerkleTree, numSplits } from '../file/index.js' -import { encodeBase64, ethers } from 'ethers' +import pkg from 'ethers'; +const { encodeBase64, ethers } = pkg; import { calculatePrice, getShardConfigs } from './utils.js' import { UploadOption, UploadTask } from './types.js' import { AbstractFile } from '../file/AbstractFile.js' diff --git a/src.ts/transfer/types.ts b/src.ts/transfer/types.ts index 52ed857..8341b24 100644 --- a/src.ts/transfer/types.ts +++ b/src.ts/transfer/types.ts @@ -1,4 +1,5 @@ -import { ethers } from 'ethers' +import pkg from 'ethers'; +const { ethers } = pkg; export interface UploadTask { clientIndex: number diff --git a/src.ts/utils.ts b/src.ts/utils.ts index d6b65ee..a8de865 100644 --- a/src.ts/utils.ts +++ b/src.ts/utils.ts @@ -1,9 +1,9 @@ -import { Signer } from 'ethers' import { FixedPriceFlow__factory } from './contracts/flow/index.js' import { FixedPrice__factory } from './contracts/market/index.js' import fs from 'fs' import path from 'path' -import { ContractRunner } from 'ethers' +import pkg from 'ethers'; +const { Signer, ContractRunner } = pkg; export function getFlowContract(address: string, signer: Signer) { return FixedPriceFlow__factory.connect(address, signer) diff --git a/types/file/AbstractFile.d.ts b/types/file/AbstractFile.d.ts index 71eee6e..87f3f46 100644 --- a/types/file/AbstractFile.d.ts +++ b/types/file/AbstractFile.d.ts @@ -1,4 +1,5 @@ -import { BytesLike } from 'ethers'; +import pkg from 'ethers'; +const { BytesLike } = pkg; import { MerkleTree } from './MerkleTree.js'; import { SubmissionNodeStruct, SubmissionStruct } from '../contracts/flow/FixedPriceFlow.js'; import { Iterator } from './Iterator/index.js'; @@ -16,4 +17,4 @@ export declare abstract class AbstractFile { createNode(offset: number, chunks: number): Promise<[SubmissionNodeStruct | null, Error | null]>; createSegmentNode(offset: number, batch: number, size: number): Promise<[SubmissionNodeStruct | null, Error | null]>; } -//# sourceMappingURL=AbstractFile.d.ts.map \ No newline at end of file +//# sourceMappingURL=AbstractFile.d.ts.map diff --git a/types/indexer/Indexer.d.ts b/types/indexer/Indexer.d.ts index 62a8d1c..2064690 100644 --- a/types/indexer/Indexer.d.ts +++ b/types/indexer/Indexer.d.ts @@ -5,7 +5,8 @@ import { UploadOption, Uploader } from '../transfer/index.js'; import { StorageNode } from '../node/index.js'; import { RetryOpts } from '../types.js'; import { AbstractFile } from '../file/AbstractFile.js'; -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; export declare class Indexer extends HttpProvider { constructor(url: string); getShardedNodes(): Promise; @@ -16,4 +17,4 @@ export declare class Indexer extends HttpProvider { upload(file: AbstractFile, blockchain_rpc: string, signer: ethers.Wallet, opts?: UploadOption, retryOpts?: RetryOpts): Promise<[string, Error | null]>; download(rootHash: string, filePath: string, proof: boolean): Promise; } -//# sourceMappingURL=Indexer.d.ts.map \ No newline at end of file +//# sourceMappingURL=Indexer.d.ts.map diff --git a/types/transfer/Uploader.d.ts b/types/transfer/Uploader.d.ts index ba93f59..5072321 100644 --- a/types/transfer/Uploader.d.ts +++ b/types/transfer/Uploader.d.ts @@ -2,7 +2,8 @@ import { StorageNode, SegmentWithProof, FileInfo } from '../node/index.js'; import { FixedPriceFlow } from '../contracts/flow/FixedPriceFlow.js'; import { RetryOpts } from '../types.js'; import { MerkleTree } from '../file/index.js'; -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; import { UploadOption, UploadTask } from './types.js'; import { AbstractFile } from '../file/AbstractFile.js'; export declare class Uploader { @@ -21,4 +22,4 @@ export declare class Uploader { getSegment(file: AbstractFile, tree: MerkleTree, segIndex: number): Promise<[boolean, SegmentWithProof | null, Error | null]>; uploadTask(file: AbstractFile, tree: MerkleTree, uploadTask: UploadTask): Promise; } -//# sourceMappingURL=Uploader.d.ts.map \ No newline at end of file +//# sourceMappingURL=Uploader.d.ts.map diff --git a/types/transfer/types.d.ts b/types/transfer/types.d.ts index 7afa393..5d69bc6 100644 --- a/types/transfer/types.d.ts +++ b/types/transfer/types.d.ts @@ -1,4 +1,5 @@ -import { ethers } from 'ethers'; +import pkg from 'ethers'; +const { ethers } = pkg; export interface UploadTask { clientIndex: number; taskSize: number; @@ -15,4 +16,4 @@ export interface UploadOption { fee: bigint; } export declare var defaultUploadOption: UploadOption; -//# sourceMappingURL=types.d.ts.map \ No newline at end of file +//# sourceMappingURL=types.d.ts.map diff --git a/types/utils.d.ts b/types/utils.d.ts index 1e8a841..18edb85 100644 --- a/types/utils.d.ts +++ b/types/utils.d.ts @@ -1,8 +1,8 @@ -import { Signer } from 'ethers'; -import { ContractRunner } from 'ethers'; +import pkg from 'ethers'; +const { Signer, ContractRunner } = pkg; export declare function getFlowContract(address: string, signer: Signer): import("./contracts/flow/FixedPriceFlow.js").FixedPriceFlow; export declare function getMarketContract(address: string, runner: ContractRunner): import("./contracts/market/FixedPrice.js").FixedPrice; export declare function checkExist(inputPath: string): boolean; export declare function GetSplitNum(total: number, unit: number): number; export declare const delay: (ms: number) => Promise; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file +//# sourceMappingURL=utils.d.ts.map