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

Options runtime checks fix. #241

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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: 6 additions & 6 deletions dist/index.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.min.js.map

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions lib/contract-verifier.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/contract-verifier.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/lib/contract-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ export const ContractVerifier = {
codeCellHash: string,
options?: GetSourcesOptions
): Promise<string | null> {
const isTestnet = options?.testnet ?? false; // Mainnet by default
const tc = new TonClient4({
endpoint:
options?.httpApiEndpointV4 ??
(await getHttpV4Endpoint({
network: options.testnet ? "testnet" : "mainnet",
network: isTestnet ? "testnet" : "mainnet",
})),
});
const {
Expand All @@ -94,7 +95,7 @@ export const ContractVerifier = {
args.writeNumber(bigIntFromBuffer(Buffer.from(codeCellHash, "base64")));
const { result: itemAddRes } = await tc.runMethod(
seqno,
options.testnet ? SOURCES_REGISTRY_TESTNET : SOURCES_REGISTRY,
isTestnet ? SOURCES_REGISTRY_TESTNET : SOURCES_REGISTRY,
"get_source_item_address",
args.build()
);
Expand Down Expand Up @@ -128,11 +129,13 @@ export const ContractVerifier = {
testnet?: boolean;
}
): Promise<SourcesData> {
const ipfsConverter = options.ipfsConverter ?? defaultIpfsConverter;
const ipfsHttpLink = ipfsConverter(sourcesJsonUrl, !!options.testnet);

const isTestnet = options?.testnet ?? false; // Mainnet by default
const ipfsConverter = options?.ipfsConverter ?? defaultIpfsConverter;
const ipfsHttpLink = ipfsConverter(sourcesJsonUrl, isTestnet);

const verifiedContract = await (
await fetch(ipfsConverter(sourcesJsonUrl, !!options.testnet))
await fetch(ipfsConverter(sourcesJsonUrl, isTestnet))
).json();

const files = (
Expand All @@ -143,7 +146,7 @@ export const ContractVerifier = {
filename: string;
isEntrypoint?: boolean;
}) => {
const url = ipfsConverter(source.url, !!options.testnet);
const url = ipfsConverter(source.url, isTestnet);
const content = await fetch(url).then((u) => u.text());
return {
name: source.filename,
Expand Down