-
Notifications
You must be signed in to change notification settings - Fork 837
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
268 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
contract A { | ||
function foo() public pure virtual returns (string memory) { | ||
return "A"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "./A.sol"; | ||
|
||
// Contracts inherit other contracts by using the keyword 'is'. | ||
contract B is A { | ||
// Override A.foo() | ||
function foo() public pure virtual override returns (string memory) { | ||
return "B"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "./A.sol"; | ||
|
||
contract C is A { | ||
// Override A.foo() | ||
function foo() public pure virtual override returns (string memory) { | ||
return "C"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "./B.sol"; | ||
import "./C.sol"; | ||
|
||
// Contracts can inherit from multiple parent contracts. | ||
// When a function is called that is defined multiple times in | ||
// different contracts, parent contracts are searched from | ||
// right to left, and in depth-first manner. | ||
|
||
contract D is B, C { | ||
// D.foo() returns "C" | ||
// since C is the right most parent contract with function foo() | ||
function foo() public pure override(B, C) returns (string memory) { | ||
return super.foo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "./B.sol"; | ||
import "./C.sol"; | ||
|
||
contract E is C, B { | ||
// E.foo() returns "B" | ||
// since B is the right most parent contract with function foo() | ||
function foo() public pure override(C, B) returns (string memory) { | ||
return super.foo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "./A.sol"; | ||
import "./B.sol"; | ||
|
||
// Inheritance must be ordered from “most base-like” to “most derived”. | ||
// Swapping the order of A and B will throw a compilation error. | ||
contract F is A, B { | ||
function foo() public pure override(A, B) returns (string memory) { | ||
return super.foo(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,143 @@ | ||
const deployedContracts = null; | ||
const contracts = { | ||
31337: [ | ||
{ | ||
chainId: "31337", | ||
name: "localhost", | ||
contracts: { | ||
A: { | ||
address: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", | ||
abi: [ | ||
{ | ||
inputs: [], | ||
name: "foo", | ||
outputs: [ | ||
{ | ||
internalType: "string", | ||
name: "", | ||
type: "string", | ||
}, | ||
], | ||
stateMutability: "pure", | ||
type: "function", | ||
}, | ||
], | ||
inheritedFunctions: {}, | ||
}, | ||
B: { | ||
address: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", | ||
abi: [ | ||
{ | ||
inputs: [], | ||
name: "foo", | ||
outputs: [ | ||
{ | ||
internalType: "string", | ||
name: "", | ||
type: "string", | ||
}, | ||
], | ||
stateMutability: "pure", | ||
type: "function", | ||
}, | ||
], | ||
inheritedFunctions: { | ||
foo: "contracts/A.sol", | ||
}, | ||
}, | ||
C: { | ||
address: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", | ||
abi: [ | ||
{ | ||
inputs: [], | ||
name: "foo", | ||
outputs: [ | ||
{ | ||
internalType: "string", | ||
name: "", | ||
type: "string", | ||
}, | ||
], | ||
stateMutability: "pure", | ||
type: "function", | ||
}, | ||
], | ||
inheritedFunctions: { | ||
foo: "contracts/A.sol", | ||
}, | ||
}, | ||
D: { | ||
address: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", | ||
abi: [ | ||
{ | ||
inputs: [], | ||
name: "foo", | ||
outputs: [ | ||
{ | ||
internalType: "string", | ||
name: "", | ||
type: "string", | ||
}, | ||
], | ||
stateMutability: "pure", | ||
type: "function", | ||
}, | ||
], | ||
inheritedFunctions: { | ||
foo: "contracts/C.sol", | ||
}, | ||
}, | ||
E: { | ||
address: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", | ||
abi: [ | ||
{ | ||
inputs: [], | ||
name: "foo", | ||
outputs: [ | ||
{ | ||
internalType: "string", | ||
name: "", | ||
type: "string", | ||
}, | ||
], | ||
stateMutability: "pure", | ||
type: "function", | ||
}, | ||
], | ||
inheritedFunctions: { | ||
foo: "contracts/C.sol", | ||
}, | ||
}, | ||
F: { | ||
address: "0x0165878A594ca255338adfa4d48449f69242Eb8F", | ||
abi: [ | ||
{ | ||
inputs: [], | ||
name: "foo", | ||
outputs: [ | ||
{ | ||
internalType: "string", | ||
name: "", | ||
type: "string", | ||
}, | ||
], | ||
stateMutability: "pure", | ||
type: "function", | ||
}, | ||
], | ||
inheritedFunctions: { | ||
foo: "contracts/B.sol", | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
11155111: [ | ||
{ | ||
chainId: "11155111", | ||
name: "sepolia", | ||
contracts: {}, | ||
}, | ||
], | ||
} as const; | ||
|
||
export default deployedContracts; | ||
export default contracts; |