-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add barebones FederatedAttestations contract, proxy, and interface * Make TODOs ASv2 specific * Add FA usages to existing files * Add skeleton migration file * Add test scaffolding * Add CK wrapper and test
- Loading branch information
1 parent
8ca8614
commit 92f7d91
Showing
18 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
packages/protocol/contracts/identity/FederatedAttestations.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,60 @@ | ||
pragma solidity ^0.5.13; | ||
|
||
import "openzeppelin-solidity/contracts/math/SafeMath.sol"; | ||
import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; | ||
import "openzeppelin-solidity/contracts/utils/SafeCast.sol"; | ||
|
||
import "./interfaces/IFederatedAttestations.sol"; | ||
import "../common/interfaces/IAccounts.sol"; | ||
import "../common/interfaces/ICeloVersionedContract.sol"; | ||
|
||
import "../common/Initializable.sol"; | ||
import "../common/UsingRegistry.sol"; | ||
import "../common/Signatures.sol"; | ||
import "../common/UsingPrecompiles.sol"; | ||
import "../common/libraries/ReentrancyGuard.sol"; | ||
|
||
/** | ||
* @title Contract mapping identifiers to accounts | ||
*/ | ||
contract FederatedAttestations is | ||
IFederatedAttestations, | ||
ICeloVersionedContract, | ||
Ownable, | ||
Initializable, | ||
UsingRegistry, | ||
ReentrancyGuard, | ||
UsingPrecompiles | ||
{ | ||
using SafeMath for uint256; | ||
using SafeCast for uint256; | ||
|
||
// TODO ASv2 State var declarations | ||
|
||
// TODO ASv2 Event declarations | ||
|
||
/** | ||
* @notice Sets initialized == true on implementation contracts | ||
* @param test Set to true to skip implementation initialization | ||
*/ | ||
constructor(bool test) public Initializable(test) {} | ||
|
||
/** | ||
* @notice Used in place of the constructor to allow the contract to be upgradable via proxy. | ||
* @param registryAddress The address of the registry core smart contract. | ||
*/ | ||
function initialize(address registryAddress) external initializer { | ||
_transferOwnership(msg.sender); | ||
setRegistry(registryAddress); | ||
// TODO ASv2 initialize any other variables here | ||
} | ||
|
||
/** | ||
* @notice Returns the storage, major, minor, and patch version of the contract. | ||
* @return The storage, major, minor, and patch version of the contract. | ||
*/ | ||
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) { | ||
return (1, 1, 0, 0); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/protocol/contracts/identity/interfaces/IFederatedAttestations.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,5 @@ | ||
pragma solidity ^0.5.13; | ||
|
||
// TODO ASv2 add external, view, and only owner function sigs | ||
// separated into these three groups for clarity | ||
interface IFederatedAttestations {} |
6 changes: 6 additions & 0 deletions
6
packages/protocol/contracts/identity/proxies/FederatedAttestationsProxy.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,6 @@ | ||
pragma solidity ^0.5.13; | ||
|
||
import "../../common/Proxy.sol"; | ||
|
||
/* solhint-disable no-empty-blocks */ | ||
contract FederatedAttestationsProxy is Proxy {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { CeloContractName } from '@celo/protocol/lib/registry-utils' | ||
import { deploymentForCoreContract } from '@celo/protocol/lib/web3-utils' | ||
import { config } from '@celo/protocol/migrationsConfig' | ||
import { FederatedAttestationsInstance } from 'types' | ||
|
||
const initializeArgs = async (): Promise<[string]> => { | ||
return [config.registry.predeployedProxyAddress] | ||
} | ||
|
||
module.exports = deploymentForCoreContract<FederatedAttestationsInstance>( | ||
web3, | ||
artifacts, | ||
CeloContractName.FederatedAttestations, | ||
initializeArgs | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { CeloContractName } from '@celo/protocol/lib/registry-utils' | ||
// import { getPhoneHash } from '@celo/utils/lib/phoneNumbers' | ||
import { | ||
AccountsContract, | ||
AccountsInstance, | ||
FederatedAttestationsContract, | ||
FederatedAttestationsInstance, | ||
RegistryContract, | ||
RegistryInstance, | ||
} from 'types' | ||
|
||
const Accounts: AccountsContract = artifacts.require('Accounts') | ||
const FederatedAttestations: FederatedAttestationsContract = artifacts.require( | ||
'FederatedAttestations' | ||
) | ||
const Registry: RegistryContract = artifacts.require('Registry') | ||
|
||
contract('Attestations', (accounts: string[]) => { | ||
let accountsInstance: AccountsInstance | ||
let federatedAttestations: FederatedAttestationsInstance | ||
let registry: RegistryInstance | ||
|
||
const caller: string = accounts[0] | ||
// const phoneNumber: string = '+18005551212' | ||
// const phoneHash: string = getPhoneHash(phoneNumber) | ||
|
||
beforeEach('FederatedAttestations setup', async () => { | ||
accountsInstance = await Accounts.new(true) | ||
federatedAttestations = await FederatedAttestations.new(true) | ||
registry = await Registry.new(true) | ||
await accountsInstance.initialize(registry.address) | ||
await registry.setAddressFor(CeloContractName.Accounts, accountsInstance.address) | ||
await federatedAttestations.initialize(registry.address) | ||
}) | ||
|
||
describe('#initialize()', () => { | ||
it('TODO ASv2', async () => { | ||
// TODO ASv2 | ||
assert(caller) | ||
assert(federatedAttestations) | ||
}) | ||
}) | ||
}) |
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
26 changes: 26 additions & 0 deletions
26
packages/sdk/contractkit/src/wrappers/FederatedAttestations.test.ts
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,26 @@ | ||
import { testWithGanache } from '@celo/dev-utils/lib/ganache-test' | ||
// import { PhoneNumberUtils } from '@celo/utils' | ||
import { newKitFromWeb3 } from '../kit' | ||
import { FederatedAttestationsWrapper } from './FederatedAttestations' | ||
|
||
testWithGanache('FederatedAttestations Wrapper', (web3) => { | ||
// const PHONE_NUMBER = '+15555555555' | ||
// const IDENTIFIER = PhoneNumberUtils.getPhoneHash(PHONE_NUMBER) | ||
|
||
const kit = newKitFromWeb3(web3) | ||
let accounts: string[] = [] | ||
let federatedAttestations: FederatedAttestationsWrapper | ||
|
||
beforeAll(async () => { | ||
accounts = await web3.eth.getAccounts() | ||
kit.defaultAccount = accounts[0] | ||
}) | ||
|
||
describe('TODO ASv2', () => { | ||
it('TODO ASv2', async () => { | ||
expect(accounts) | ||
federatedAttestations = await kit.contracts.getFederatedAttestations() | ||
expect(federatedAttestations) | ||
}) | ||
}) | ||
}) |
8 changes: 8 additions & 0 deletions
8
packages/sdk/contractkit/src/wrappers/FederatedAttestations.ts
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 @@ | ||
import { FederatedAttestations } from '../generated/FederatedAttestations' | ||
import { BaseWrapper } from './BaseWrapper' | ||
|
||
export interface FederatedAttestationsConfig { | ||
// TODO ASv2 | ||
} | ||
|
||
export class FederatedAttestationsWrapper extends BaseWrapper<FederatedAttestations> {} |