-
Notifications
You must be signed in to change notification settings - Fork 12
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
Convert to upgradeable and cloneable contracts #43
Changes from 2 commits
9d40e02
87b0404
516267b
d7c4ffe
be9e994
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
node_modules | ||
artifacts | ||
cache | ||
typechain-types | ||
typechain-types | ||
ignition/deployments |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright © 2024 Kaleido, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
pragma solidity ^0.8.20; | ||
|
||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; | ||
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
import {IZetoFungible} from "./lib/interfaces/zeto_fungible.sol"; | ||
import {IZetoFungibleInitializable} from "./lib/interfaces/zeto_fungible_initializable.sol"; | ||
import {IZetoNonFungibleInitializable} from "./lib/interfaces/zeto_nf_initializable.sol"; | ||
import {SampleERC20} from "./erc20.sol"; | ||
|
||
contract ZetoTokenFactory { | ||
event ZetoTokenDeployed(address indexed zetoToken); | ||
|
||
mapping(string => address) internal implementations; | ||
|
||
constructor() {} | ||
|
||
function registerImplementation( | ||
string memory name, | ||
address implementation | ||
) public { | ||
implementations[name] = implementation; | ||
} | ||
|
||
function deployZetoFungibleToken( | ||
string memory name, | ||
address authority, | ||
address _depositVerifier, | ||
address _withdrawVerifier, | ||
address _verifier | ||
) public returns (address) { | ||
address instance = Clones.clone(implementations[name]); | ||
require( | ||
instance != address(0), | ||
"Factory: failed to find implementation" | ||
); | ||
(IZetoFungibleInitializable(instance)).initialize( | ||
authority, | ||
_depositVerifier, | ||
_withdrawVerifier, | ||
_verifier | ||
); | ||
emit ZetoTokenDeployed(instance); | ||
return instance; | ||
} | ||
|
||
function deployZetoNonFungibleToken( | ||
string memory name, | ||
address authority, | ||
address _verifier | ||
) public returns (address) { | ||
address instance = Clones.clone(implementations[name]); | ||
require( | ||
instance != address(0), | ||
"Factory: failed to find implementation" | ||
); | ||
(IZetoNonFungibleInitializable(instance)).initialize( | ||
authority, | ||
_verifier | ||
); | ||
emit ZetoTokenDeployed(instance); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels there are other information that could be useful to emit. But they can be added based on the use case in the future. |
||
return instance; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright © 2024 Kaleido, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
pragma solidity ^0.8.20; | ||
|
||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
interface IZetoFungible { | ||
function setERC20(IERC20 _erc20) external; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the name of this file doesn't reflect it's mainly for supporting ERC20 contract anchoring, also, the interface is not used by multiple files as the existing abstract contract |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright © 2024 Kaleido, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
pragma solidity ^0.8.20; | ||
|
||
interface IZetoFungibleInitializable { | ||
function initialize( | ||
address authority, | ||
address _depositVerifier, | ||
address _withdrawVerifier, | ||
address _verifier | ||
) external; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright © 2024 Kaleido, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
pragma solidity ^0.8.20; | ||
|
||
interface IZetoNonFungibleInitializable { | ||
function initialize(address authority, address _verifier) external; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not being used