Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using contract address from config instead of contract address from ETHSTORAGE_MAPPING. #9

Merged
merged 5 commits into from
Jul 24, 2024
Merged
Changes from 2 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
12 changes: 8 additions & 4 deletions src/ethstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export class EthStorage {
#blobUploader;

static async create(config) {
const {rpc} = config;
const {rpc, contractAddr} = config;
ping-ke marked this conversation as resolved.
Show resolved Hide resolved
const ethStorage = new EthStorage(config);
await ethStorage.init(rpc);
await ethStorage.init(rpc, contractAddr);
return ethStorage;
}

Expand All @@ -36,9 +36,13 @@ export class EthStorage {
this.#blobUploader = new BlobUploader(rpc, privateKey);
}

async init(rpc) {
async init(rpc, contractAddr) {
const chainId = await getChainId(rpc);
ping-ke marked this conversation as resolved.
Show resolved Hide resolved
this.#contractAddr = ETHSTORAGE_MAPPING[chainId];
if (contractAddr != null) {
this.#contractAddr = contractAddr;
} else {
this.#contractAddr = ETHSTORAGE_MAPPING[chainId];
}
if (!this.#contractAddr) {
throw new Error("EthStorage: Network not supported yet.");
}
Expand Down