-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from hyperledger-labs/upgradeable
Convert to upgradeable and cloneable contracts
- Loading branch information
Showing
56 changed files
with
2,050 additions
and
594 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
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
node_modules | ||
artifacts | ||
cache | ||
typechain-types | ||
typechain-types | ||
ignition/deployments |
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
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,75 @@ | ||
// 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 {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; | ||
import {IZetoFungibleInitializable} from "./lib/interfaces/zeto_fungible_initializable.sol"; | ||
import {IZetoNonFungibleInitializable} from "./lib/interfaces/zeto_nf_initializable.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 initialOwner, | ||
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( | ||
initialOwner, | ||
_depositVerifier, | ||
_withdrawVerifier, | ||
_verifier | ||
); | ||
emit ZetoTokenDeployed(instance); | ||
return instance; | ||
} | ||
|
||
function deployZetoNonFungibleToken( | ||
string memory name, | ||
address initialOwner, | ||
address _verifier | ||
) public returns (address) { | ||
address instance = Clones.clone(implementations[name]); | ||
require( | ||
instance != address(0), | ||
"Factory: failed to find implementation" | ||
); | ||
(IZetoNonFungibleInitializable(instance)).initialize( | ||
initialOwner, | ||
_verifier | ||
); | ||
emit ZetoTokenDeployed(instance); | ||
return instance; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
solidity/contracts/lib/interfaces/zeto_fungible_initializable.sol
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,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 initialOwner, | ||
address _depositVerifier, | ||
address _withdrawVerifier, | ||
address _verifier | ||
) external; | ||
} |
20 changes: 20 additions & 0 deletions
20
solidity/contracts/lib/interfaces/zeto_nf_initializable.sol
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,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 initialOwner, address _verifier) external; | ||
} |
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
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
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
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
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
Oops, something went wrong.