pub struct Remapping {
    pub name: String,
    pub path: String,
}
Expand description

The solidity compiler can only reference files that exist locally on your computer. So importing directly from GitHub (as an example) is not possible.

Let’s imagine you want to use OpenZeppelin’s amazing library of smart contracts, @openzeppelin/contracts-ethereum-package:

pragma solidity 0.5.11;

import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";

contract MyContract {
    using SafeMath for uint256;
    ...
}

When using solc, you have to specify the following:

“prefix” = the path that’s used in your smart contract, i.e. “@openzeppelin/contracts-ethereum-package” “target” = the absolute path of OpenZeppelin’s contracts downloaded on your computer

The format looks like this: solc prefix=target ./MyContract.sol

solc –bin @openzeppelin/contracts-ethereum-package=/Your/Absolute/Path/To/@openzeppelin/ contracts-ethereum-package ./MyContract.sol

Source

Fields§

§name: String§path: String

Implementations§

Convenience function for RelativeRemapping::new

Removes the base path from the remapping

Returns all formatted remappings

Attempts to autodetect all remappings given a certain root path.

This will recursively scan all subdirectories of the root path, if a subdirectory contains a solidity file then this a candidate for a remapping. The name of the remapping will be the folder name.

However, there are additional rules/assumptions when it comes to determining if a candidate should in fact be a remapping:

All names and paths end with a trailing “/”

The name of the remapping will be the parent folder of a solidity file, unless the folder is named src, lib or contracts in which case the name of the remapping will be the parent folder’s name of src, lib, contracts: The remapping of repo1/src/contract.sol is name: "repo1/", path: "repo1/src/"

Nested remappings need to be separated by src, lib or contracts, The remapping of repo1/lib/ds-math/src/contract.sol is name: "ds-math/", "repo1/lib/ds-math/src/"

Remapping detection is primarily designed for dapptool’s rules for lib folders, however, we attempt to detect and optimize various folder structures commonly used in node_modules dependencies. For those the same rules apply. In addition, we try to unify all remappings discovered according to the rules mentioned above, so that layouts like,

which would be multiple rededications according to our rules (“governance”, “protocol-v2”), are unified into @aave by looking at their common ancestor, the root of this subdirectory (@aave)

Converts any \\ separators in the path to /

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more