Skip to content

Commit

Permalink
Re: Removing Odis Identifiers and Hashing Functions (#10708)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmgdr authored Nov 13, 2023
1 parent 68b6bf4 commit 97d5ccf
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 253 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-lies-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/phone-utils': major
---

Remove getPhoneHash, to lookup an odis hash for an identifier use getIdentifierHash from @celo/identity
5 changes: 5 additions & 0 deletions .changeset/nine-ladybugs-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/base': major
---

Remove getIdentifierHash, IdentifierPrefix, getIdentifierPrefix. These have been moved to @celo/odis-identifiers
5 changes: 5 additions & 0 deletions .changeset/small-hats-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/celotool': major
---

Remove lookup command, use `celocli identity:identifier --phoneNumber`
2 changes: 0 additions & 2 deletions dependency-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"@celo/base",
"@celo/connect",
"@celo/cryptographic-utils",
"@celo/phone-utils",
"@celo/typescript",
"@celo/utils",
"@celo/wallet-local"
Expand Down Expand Up @@ -90,7 +89,6 @@
"@celo/base",
"@celo/connect",
"@celo/dev-utils",
"@celo/phone-utils",
"@celo/protocol",
"@celo/utils",
"@celo/wallet-local"
Expand Down
74 changes: 0 additions & 74 deletions packages/celotool/src/cmds/account/lookup.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/cli/src/commands/account/offchain-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default class OffchainRead extends BaseCommand {
args: { address },
flags: { from, privateDEK },
} = this.parse(OffchainRead)

const provider = new BasicDataWrapper(from!, this.kit)

if (privateDEK) {
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/src/commands/releasegold/authorize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flags } from '@oclif/command'
import { flags as oclifFlags } from '@oclif/command'
import { newCheckBuilder } from '../../utils/checks'
import { displaySendTx } from '../../utils/cli'
import { Flags } from '../../utils/command'
Expand All @@ -10,7 +10,7 @@ export default class Authorize extends ReleaseGoldBaseCommand {

static flags = {
...ReleaseGoldBaseCommand.flags,
role: flags.string({ required: true, options: ['vote', 'validator', 'attestation'] }),
role: oclifFlags.string({ required: true, options: ['vote', 'validator', 'attestation'] }),
signer: Flags.address({
required: true,
description: 'The signer key that is to be used for voting through the ReleaseGold instance',
Expand All @@ -29,7 +29,7 @@ export default class Authorize extends ReleaseGoldBaseCommand {
'The BLS public key proof-of-possession, which consists of a signature on the account address. 48 bytes.',
dependsOn: ['blsKey'],
}),
force: flags.boolean({
force: oclifFlags.boolean({
description:
'Allow rotation of validator ECDSA key without rotating the BLS key. Only intended for validators with a special reason to do so.',
default: false,
Expand All @@ -48,6 +48,7 @@ export default class Authorize extends ReleaseGoldBaseCommand {
async run() {
// tslint:disable-next-line
const { flags } = this.parse(Authorize)

const role = flags.role

// Check that the account is registered on-chain.
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/utils/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export async function displaySendTx<A>(
cli.action.start(`Sending Transaction: ${name}`)
try {
const txResult = await txObj.send(tx)

const txHash = await txResult.getHash()

console.log(chalk`SendTransaction: {red.bold ${name}}`)
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/utils/off-chain-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export abstract class OffchainDataCommand extends BaseCommand {
}: ParserOutput<any, any> = this.parse()

const from = privateKeyToAddress(privateKey)

this.offchainDataWrapper = new BasicDataWrapper(from, this.kit)

this.offchainDataWrapper.storageWriter =
Expand Down
16 changes: 12 additions & 4 deletions packages/protocol/lib/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ import { AccountsInstance } from 'types';


import BN = require('bn.js')
import { getIdentifierHash, IdentifierPrefix } from "@celo/odis-identifiers"
export function getOdisHash(
phoneNumber: string,
pepper?: string,
prefix = IdentifierPrefix.PHONE_NUMBER,
) {
return getIdentifierHash(Web3.utils.sha3, phoneNumber, prefix, pepper);
}

const isNumber = (x: any) =>
typeof x === 'number' || (BN as any).isBN(x) || BigNumber.isBigNumber(x)
Expand Down Expand Up @@ -388,10 +396,10 @@ export function assertBNArrayEqual(
assert(Array.isArray(actualArray), `Actual is not an array`)
assert(Array.isArray(expectedArray), `Expected is not an array`)
assert(actualArray.length === expectedArray.length, `Different array sizes; actual: ${actualArray.length} expected: ${expectedArray.length}`)
assert(actualArray.every(actualValue => isNumber(actualValue))
assert(actualArray.every(actualValue => isNumber(actualValue))
&& expectedArray.every(expectedValue => isNumber(expectedValue)),
`Expected all elements to be numbers`)

for (let i = 0; i < actualArray.length; i++) {
assertEqualBN(actualArray[i], expectedArray[i])
}
Expand Down Expand Up @@ -589,11 +597,11 @@ export async function assumeOwnershipWithTruffle(contractsToOwn: string[], to: s
const transferOwnershipData = Buffer.from(stripHexEncoding(registry.contract.methods.transferOwnership(to).encodeABI()), 'hex')
const proposalTransactions = await Promise.all(
contractsToOwn.map(async (contractName: string) => {

const artifactsInstance = ArtifactsSingleton.getInstance(contractPackage, artifacts)

const contractAddress = (await getDeployedProxiedContract(contractName, artifactsInstance)).address

return {
value: 0,
destination: contractAddress,
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
},
"devDependencies": {
"@celo/odis-identifiers": "^1.0.0",
"@celo/phone-utils": "^5.0.5",
"@celo/typechain-target-web3-v1-celo": "^1.0.0",
"@celo/typescript": "0.0.1",
"@types/bn.js": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/identity/attestations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NULL_ADDRESS } from '@celo/base/lib/address'
import { Signature } from '@celo/base/lib/signatureUtils'
import getPhoneHash from '@celo/phone-utils/lib/getPhoneHash'
import { CeloContractName } from '@celo/protocol/lib/registry-utils'
import {
assertEqualBN,
assertLogMatches2,
assertRevert,
assertTransactionRevertWithReason,
getDerivedKey,
getOdisHash as getPhoneHash,
KeyOffsets,
unlockAndAuthorizeKey,
} from '@celo/protocol/lib/test-utils'
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol/test/identity/escrow.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { NULL_ADDRESS } from '@celo/base/lib/address'
import getPhoneHash from '@celo/phone-utils/lib/getPhoneHash'

import { CeloContractName } from '@celo/protocol/lib/registry-utils'
import {
assertEqualBN,
assertLogMatches2,
assertObjectWithBNEqual,
assertTransactionRevertWithReason,
assumeOwnershipWithTruffle,
getOdisHash as getPhoneHash,
timeTravel,
} from '@celo/protocol/lib/test-utils'
import { getDeployedProxiedContract } from '@celo/protocol/lib/web3-utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/identity/federatedattestations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import getPhoneHash from '@celo/phone-utils/lib/getPhoneHash'
import {
getDomainDigest,
getSignatureForAttestation,
Expand All @@ -13,6 +12,7 @@ import {
assertThrowsAsync,
assertTransactionRevertWithReason,
assumeOwnershipWithTruffle,
getOdisHash as getPhoneHash,
} from '@celo/protocol/lib/test-utils'
import { getDeployedProxiedContract } from '@celo/protocol/lib/web3-utils'
import BigNumber from 'bignumber.js'
Expand Down
33 changes: 0 additions & 33 deletions packages/sdk/base/src/identifier.test.ts

This file was deleted.

84 changes: 0 additions & 84 deletions packages/sdk/base/src/identifier.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/sdk/base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export * from './contacts'
export * from './currencies'
export * from './displayFormatting'
export * from './future'
export * from './identifier'
export * from './inputValidation'
export * from './io'
export * from './logger'
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/contractkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"web3-core-helpers": "1.10.0"
},
"devDependencies": {
"@celo/phone-utils": "^5.0.5",
"@celo/odis-identifiers": "^1.0.0",
"@celo/dev-utils": "0.0.1",
"@celo/protocol": "1.0.1",
"@types/debug": "^4.1.5",
Expand Down
Loading

0 comments on commit 97d5ccf

Please sign in to comment.