Skip to content

Commit

Permalink
Relative artifacts (#118) [skip ci]
Browse files Browse the repository at this point in the history
Co-authored-by: edwin <edwinswatpako@gmail.com>
Co-authored-by: FabijanC <fabijan.corak@gmail.com>
  • Loading branch information
3 people committed Jun 20, 2022
1 parent cad8ec0 commit 1f8ff25
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/type-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
StringMap
} from "./types";
import { StarknetWrapper } from "./starknet-wrappers";
import { FlushResponse, IncreaseTimeResponse, LoadL1MessagingContractResponse, SetTimeResponse } from "./devnet-utils";
import {
FlushResponse,
IncreaseTimeResponse,
LoadL1MessagingContractResponse,
SetTimeResponse
} from "./devnet-utils";
import { Account, ArgentAccount, OpenZeppelinAccount } from "./account";
import { Transaction, TransactionReceipt, Block } from "./starknet-types";
import { HardhatNetworkConfig, NetworkConfig } from "hardhat/types/config";
Expand Down
10 changes: 8 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,15 @@ export function isStarknetDevnet(networkName: string): boolean {
return networkName === INTEGRATED_DEVNET || networkName === INTEGRATED_DEVNET_INTERNALLY;
}

export async function findPath(traversable: string, name: string) {
export async function findPath(traversable: string, pathSegment: string) {
// Relative path to artifacts can be resolved now
const resolvedPath = path.resolve(path.join(traversable, pathSegment));
if (fs.existsSync(resolvedPath) && fs.lstatSync(resolvedPath).isFile()) {
return resolvedPath;
}

let files = await traverseFiles(traversable);
files = files.filter((f) => f.endsWith(name));
files = files.filter((f) => f.endsWith(pathSegment));
if (files.length == 0) {
return null;
} else if (files.length == 1) {
Expand Down
8 changes: 8 additions & 0 deletions test/general-tests/relative-artifact-test/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

npx hardhat starknet-compile contracts/contract.cairo contracts/util.cairo

cp -a starknet-artifacts/contracts test/test-artifacts

npx hardhat test --no-compile test/relative-artifacts.test.ts
12 changes: 12 additions & 0 deletions test/general-tests/relative-artifact-test/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "../dist/src/index.js";

module.exports = {
starknet: {
network: process.env.NETWORK
},
networks: {
devnet: {
url: "http://127.0.0.1:5050"
}
}
};
4 changes: 4 additions & 0 deletions test/general-tests/relative-artifact-test/network.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "../../network.schema",
"devnet": true
}

0 comments on commit 1f8ff25

Please sign in to comment.