-
Notifications
You must be signed in to change notification settings - Fork 12
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
28 changed files
with
1,456 additions
and
18 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,24 @@ | ||
name: Sync | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
sync-branches: | ||
runs-on: ubuntu-latest | ||
name: Syncing branches | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
- name: Opening pull request | ||
id: pull | ||
uses: tretuna/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
FROM_BRANCH: "main" | ||
TO_BRANCH: "develop" |
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
Empty file.
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,19 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "./interfaces/IHelloWorld.sol"; | ||
|
||
address constant HELLO_WORLD_ADDRESS = 0x0300000000000000000000000000000000000000; | ||
|
||
// ExampleHelloWorld shows how the HelloWorld precompile can be used in a smart contract. | ||
contract ExampleHelloWorld { | ||
IHelloWorld helloWorld = IHelloWorld(HELLO_WORLD_ADDRESS); | ||
|
||
function sayHello() public view returns (string memory) { | ||
return helloWorld.sayHello(); | ||
} | ||
|
||
function setGreeting(string calldata greeting) public { | ||
helloWorld.setGreeting(greeting); | ||
} | ||
} |
Empty file.
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; | ||
import "@avalabs/subnet-evm-contracts/contracts/interfaces/IAllowList.sol"; | ||
|
||
interface IHelloWorld is IAllowList { | ||
event GreetingChanged(address indexed sender, string oldGreeting, string newGreeting); | ||
// sayHello returns the stored greeting string | ||
function sayHello() external view returns (string calldata result); | ||
|
||
// setGreeting stores the greeting string | ||
function setGreeting(string calldata response) external; | ||
} |
Empty file.
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,42 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "../ExampleHelloWorld.sol"; | ||
import "../interfaces/IHelloWorld.sol"; | ||
import "@avalabs/subnet-evm-contracts/contracts/test/AllowListTest.sol"; | ||
|
||
contract ExampleHelloWorldTest is AllowListTest { | ||
IHelloWorld helloWorld = IHelloWorld(HELLO_WORLD_ADDRESS); | ||
|
||
function step_getDefaultHelloWorld() public { | ||
ExampleHelloWorld example = new ExampleHelloWorld(); | ||
address exampleAddress = address(example); | ||
|
||
assertRole(helloWorld.readAllowList(exampleAddress), AllowList.Role.None); | ||
assertEq(example.sayHello(), "Hello World!"); | ||
} | ||
|
||
function step_doesNotSetGreetingBeforeEnabled() public { | ||
ExampleHelloWorld example = new ExampleHelloWorld(); | ||
address exampleAddress = address(example); | ||
|
||
assertRole(helloWorld.readAllowList(exampleAddress), AllowList.Role.None); | ||
|
||
try example.setGreeting("testing") { | ||
assertTrue(false, "setGreeting should fail"); | ||
} catch {} // TODO should match on an error to make sure that this is failing in the way that's expected | ||
} | ||
|
||
function step_setAndGetGreeting() public { | ||
ExampleHelloWorld example = new ExampleHelloWorld(); | ||
address exampleAddress = address(example); | ||
|
||
assertRole(helloWorld.readAllowList(exampleAddress), AllowList.Role.None); | ||
helloWorld.setEnabled(exampleAddress); | ||
assertRole(helloWorld.readAllowList(exampleAddress), AllowList.Role.Enabled); | ||
|
||
string memory greeting = "testgreeting"; | ||
example.setGreeting(greeting); | ||
assertEq(example.sayHello(), greeting); | ||
} | ||
} |
Empty file.
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,15 @@ | ||
import { ethers } from "hardhat" | ||
import { ExampleHelloWorld } from "typechain-types" | ||
|
||
const main = async (): Promise<any> => { | ||
const contract: ExampleHelloWorld = await ethers.deployContract("ExampleHelloWorld") | ||
await contract.waitForDeployment() | ||
console.log(`Contract deployed to: ${contract.target}`) | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error) | ||
process.exit(1) | ||
}) |
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
Empty file.
Oops, something went wrong.