diff --git a/dependency-graph.json b/dependency-graph.json index 1b7659699b4..01b86beebd7 100644 --- a/dependency-graph.json +++ b/dependency-graph.json @@ -8,6 +8,7 @@ "dependencies": [ "@celo/contractkit", "@celo/keystores", + "@celo/phone-utils", "@celo/utils" ] }, @@ -66,6 +67,7 @@ "dependencies": [ "@celo/connect", "@celo/contractkit", + "@celo/phone-utils", "@celo/utils" ] }, @@ -197,6 +199,7 @@ "@celo/contractkit", "@celo/dev-utils", "@celo/flake-tracker", + "@celo/phone-utils", "@celo/utils", "@celo/wallet-local" ] diff --git a/package.json b/package.json index 5a80adaf313..c4a940c2668 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "celotool": "yarn --cwd packages/celotool run --silent cli", "celocli": "yarn --cwd packages/cli run --silent celocli", "update-dependency-graph": "ts-node ./scripts/update_dependency_graph.ts", - "deploy-sdks": "ts-node ./scripts/deploy-sdks.ts" + "deploy-sdks": "ts-node ./scripts/deploy-sdks.ts", + "deprecate-sdks": "ts-node ./scripts/unpublish-sdks.ts" }, "husky": { "hooks": { diff --git a/packages/attestation-service/package.json b/packages/attestation-service/package.json index 12292de8705..3ffd9cb3626 100644 --- a/packages/attestation-service/package.json +++ b/packages/attestation-service/package.json @@ -29,9 +29,10 @@ "test-send-sms-twilio": "TS_NODE_FILES=true CONFIG=config/.env.development ts-node scripts/test-send-sms-twilio.ts" }, "dependencies": { - "@celo/contractkit": "1.3.3-dev", - "@celo/keystores": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", + "@celo/contractkit": "1.5.1-dev", + "@celo/keystores": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/phone-utils": "1.5.1-dev", "bignumber.js": "^9.0.0", "body-parser": "1.19.0", "bunyan": "1.8.12", diff --git a/packages/attestation-service/src/index.ts b/packages/attestation-service/src/index.ts index 3a2fc08667e..f4eae0d3580 100644 --- a/packages/attestation-service/src/index.ts +++ b/packages/attestation-service/src/index.ts @@ -2,7 +2,7 @@ import { AttestationRequestType, AttestationServiceTestRequestType, GetAttestationRequestType, -} from '@celo/utils/lib/io' +} from '@celo/phone-utils/lib/io' import express from 'express' import rateLimit from 'express-rate-limit' import requestIdMiddleware from 'express-request-id' diff --git a/packages/attestation-service/src/models/attestation.ts b/packages/attestation-service/src/models/attestation.ts index 300cb86193e..91881229259 100644 --- a/packages/attestation-service/src/models/attestation.ts +++ b/packages/attestation-service/src/models/attestation.ts @@ -1,4 +1,4 @@ -import { E164Number } from '@celo/utils/lib/io' +import { E164Number } from '@celo/phone-utils/lib/io' import { BuildOptions, DataTypes, Model, Sequelize } from 'sequelize' // Split out SmsFields from the underlying data model; diff --git a/packages/attestation-service/src/request.ts b/packages/attestation-service/src/request.ts index a3278ebd263..5fa6960747c 100644 --- a/packages/attestation-service/src/request.ts +++ b/packages/attestation-service/src/request.ts @@ -1,4 +1,4 @@ -import { AttestationResponseType } from '@celo/utils/lib/io' +import { AttestationResponseType } from '@celo/phone-utils/lib/io' import Logger from 'bunyan' import express from 'express' import { isLeft } from 'fp-ts/lib/Either' diff --git a/packages/attestation-service/src/requestHandlers/attestation.ts b/packages/attestation-service/src/requestHandlers/attestation.ts index 6727b01a47c..26bcd50f468 100644 --- a/packages/attestation-service/src/requestHandlers/attestation.ts +++ b/packages/attestation-service/src/requestHandlers/attestation.ts @@ -1,8 +1,9 @@ import { AttestationState } from '@celo/contractkit/lib/wrappers/Attestations' -import { AttestationUtils, PhoneNumberUtils } from '@celo/utils' +import { PhoneNumberUtils } from '@celo/phone-utils' +import { AttestationRequest } from '@celo/phone-utils/lib/io' +import { AttestationUtils } from '@celo/utils' import { eqAddress } from '@celo/utils/lib/address' import { sleep } from '@celo/utils/lib/async' -import { AttestationRequest } from '@celo/utils/lib/io' import Logger from 'bunyan' import { randomBytes } from 'crypto' import express from 'express' diff --git a/packages/attestation-service/src/requestHandlers/get_attestation.ts b/packages/attestation-service/src/requestHandlers/get_attestation.ts index 595a8d7c7ff..866d15799dc 100644 --- a/packages/attestation-service/src/requestHandlers/get_attestation.ts +++ b/packages/attestation-service/src/requestHandlers/get_attestation.ts @@ -1,6 +1,6 @@ -import { PhoneNumberUtils } from '@celo/utils' +import { PhoneNumberUtils } from '@celo/phone-utils' +import { GetAttestationRequest } from '@celo/phone-utils/lib/io' import { isValidAddress, publicKeyToAddress } from '@celo/utils/lib/address' -import { GetAttestationRequest } from '@celo/utils/lib/io' import { verifyEIP712TypedDataSigner } from '@celo/utils/lib/signatureUtils' import { attestationSecurityCode as buildSecurityCodeTypedData } from '@celo/utils/lib/typed-data-constructors' import Logger from 'bunyan' diff --git a/packages/attestation-service/src/requestHandlers/status.ts b/packages/attestation-service/src/requestHandlers/status.ts index 8a906ad24f2..1c3cb98526b 100644 --- a/packages/attestation-service/src/requestHandlers/status.ts +++ b/packages/attestation-service/src/requestHandlers/status.ts @@ -1,4 +1,5 @@ -import { AttestationServiceStatusResponseType, SignatureType } from '@celo/utils/lib/io' +import { AttestationServiceStatusResponseType } from '@celo/phone-utils/lib/io' +import { SignatureType } from '@celo/utils/lib/io' import express from 'express' import * as t from 'io-ts' import { getAgeOfLatestBlock, isNodeSyncing, useKit } from '../db' diff --git a/packages/attestation-service/src/requestHandlers/test_attestation.ts b/packages/attestation-service/src/requestHandlers/test_attestation.ts index 2d4644ec11a..e9dea64a21e 100644 --- a/packages/attestation-service/src/requestHandlers/test_attestation.ts +++ b/packages/attestation-service/src/requestHandlers/test_attestation.ts @@ -1,5 +1,5 @@ -import { PhoneNumberUtils } from '@celo/utils' -import { AttestationServiceTestRequest } from '@celo/utils/lib/io' +import { PhoneNumberUtils } from '@celo/phone-utils' +import { AttestationServiceTestRequest } from '@celo/phone-utils/lib/io' import { verifySignature } from '@celo/utils/lib/signatureUtils' import { randomBytes } from 'crypto' import express from 'express' diff --git a/packages/attestation-service/src/sms/base.ts b/packages/attestation-service/src/sms/base.ts index f65300e27ec..d7545b6ac17 100644 --- a/packages/attestation-service/src/sms/base.ts +++ b/packages/attestation-service/src/sms/base.ts @@ -1,4 +1,4 @@ -import { E164Number } from '@celo/utils/lib/io' +import { E164Number } from '@celo/phone-utils/lib/io' import Logger from 'bunyan' import express from 'express' import { fetchEnvOrDefault } from '../env' diff --git a/packages/attestation-service/src/sms/index.ts b/packages/attestation-service/src/sms/index.ts index 2a7910b57df..c2e37ecb201 100644 --- a/packages/attestation-service/src/sms/index.ts +++ b/packages/attestation-service/src/sms/index.ts @@ -1,6 +1,6 @@ +import { E164Number } from '@celo/phone-utils/lib/io' import { sleep } from '@celo/utils/lib/async' import { intersection } from '@celo/utils/lib/collections' -import { E164Number } from '@celo/utils/lib/io' import Logger from 'bunyan' import { PhoneNumberType, PhoneNumberUtil } from 'google-libphonenumber' import { shuffle } from 'lodash' diff --git a/packages/celotool/package.json b/packages/celotool/package.json index e5a9ba64938..4446cec3ea8 100644 --- a/packages/celotool/package.json +++ b/packages/celotool/package.json @@ -6,16 +6,16 @@ "author": "Celo", "license": "Apache-2.0", "dependencies": { - "@celo/base": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", - "@celo/contractkit": "1.3.3-dev", + "@celo/base": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", + "@celo/contractkit": "1.5.1-dev", "@celo/env-tests": "1.0.0", "@types/ethereumjs-util": "^5.2.0", - "@celo/explorer": "1.3.3-dev", - "@celo/governance": "1.3.3-dev", - "@celo/identity": "1.3.3-dev", - "@celo/network-utils": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", + "@celo/explorer": "1.5.1-dev", + "@celo/governance": "1.5.1-dev", + "@celo/identity": "1.5.1-dev", + "@celo/network-utils": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", "@google-cloud/monitoring": "0.7.1", "@google-cloud/pubsub": "^0.28.1", "@google-cloud/secret-manager": "3.0.0", diff --git a/packages/celotool/src/cmds/account/lookup.ts b/packages/celotool/src/cmds/account/lookup.ts index 825235af615..75bc5973dfb 100644 --- a/packages/celotool/src/cmds/account/lookup.ts +++ b/packages/celotool/src/cmds/account/lookup.ts @@ -1,7 +1,7 @@ /* tslint:disable no-console */ import { newKitFromWeb3 } from '@celo/contractkit' -import { PhoneNumberUtils } from '@celo/utils' +import { PhoneNumberUtils } from '@celo/phone-utils' import { switchToClusterFromEnv } from 'src/lib/cluster' import { portForwardAnd } from 'src/lib/port_forward' import Web3 from 'web3' diff --git a/packages/celotool/src/lib/attestation.ts b/packages/celotool/src/lib/attestation.ts index 39c8fec2a95..2bd15a2fc5e 100644 --- a/packages/celotool/src/lib/attestation.ts +++ b/packages/celotool/src/lib/attestation.ts @@ -1,6 +1,6 @@ import { AttestationsWrapper } from '@celo/contractkit/lib/wrappers/Attestations' import { RequestAttestationError } from '@celo/env-tests/lib/shared/attestation' -import { PhoneNumberUtils } from '@celo/utils' +import { PhoneNumberUtils } from '@celo/phone-utils' import { sample } from 'lodash' import { Twilio } from 'twilio' diff --git a/packages/cli/npm-shrinkwrap.json b/packages/cli/npm-shrinkwrap.json index b90f11509c6..e789e96076b 100644 --- a/packages/cli/npm-shrinkwrap.json +++ b/packages/cli/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "@celo/celocli", - "version": "1.3.0", + "version": "1.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -41,9 +41,9 @@ } }, "@azure/core-client": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.3.0.tgz", - "integrity": "sha512-4ricu3aM1TQP2vglBcvFX8KgbWVe+7hl1jVAw6BzIGG4CTAvO3ygDS6th3O+zFwGN9xkgXFHa7Tp3u9za8ciIA==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.3.3.tgz", + "integrity": "sha512-yrg4fn1S1mF1+dazfDzIGJE4gQeX1ToGgv78E08GLAL6kDLPf40VEKd2V98NO4IXcwcT1I52KZy3xS3787qcXA==", "requires": { "@azure/abort-controller": "^1.0.0", "@azure/core-asynciterator-polyfill": "^1.0.0", @@ -70,9 +70,9 @@ } }, "@azure/core-http": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.0.tgz", - "integrity": "sha512-DCXm8OTNhPxErNvwuNgd9r/W+LjMrHHNc9/q4QgIOpCaoBvpJd1O5Nl2gbAhrwfiwmEBNWHMeGoe5+g3Lx2H/A==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.2.tgz", + "integrity": "sha512-V1DdoO9V/sFimKpdWoNBgsE+QUjQgpXYnxrTdUp5RyhsTJjvEVn/HKmTQXIHuLUUo6IyIWj+B+Dg4VaXse9dIA==", "requires": { "@azure/abort-controller": "^1.0.0", "@azure/core-asynciterator-polyfill": "^1.0.0", @@ -133,9 +133,9 @@ } }, "@azure/core-lro": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.2.0.tgz", - "integrity": "sha512-TJo95eNT1dwYOPCb0m1C2zyxVlHuRRkKGeg9TKu8XMF2qh4v6c1weD63r9RVIrLdHdnSqS0n6PTXBpWoB8NqMw==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.2.2.tgz", + "integrity": "sha512-pn30b+HyJHg0+G4ZRgpL3BJa6LQnKdKl1X4JDMpuVsX+kPxs2FNoweNqD3Li199ROroIvFbi6pE29y0J2vvyIg==", "requires": { "@azure/abort-controller": "^1.0.0", "@azure/core-tracing": "1.0.0-preview.13", @@ -176,9 +176,9 @@ } }, "@azure/core-rest-pipeline": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.3.0.tgz", - "integrity": "sha512-XdGCm4sVfLvFbd3x17Aw6XNA8SK+sWFvVlOnNSSL2OJGJ4g10LspCpGnIqB+V6OZAaVwOx/eQQN2rOfZzf4Q5w==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.3.2.tgz", + "integrity": "sha512-kymICKESeHBpVLgQiAxllgWdSTopkqtmfPac8ITwMCxNEC6hzbSpqApYbjzxbBNkBMgoD4GESo6LLhR/sPh6kA==", "requires": { "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.3.0", @@ -335,11 +335,11 @@ } }, "@azure/logger": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.2.tgz", - "integrity": "sha512-YZNjNV0vL3nN2nedmcjQBcpCTo3oqceXmgiQtEm6fLpucjRZyQKAQruhCmCpRlB1iykqKJJ/Y8CDmT5rIE6IJw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.3.tgz", + "integrity": "sha512-aK4s3Xxjrx3daZr3VylxejK3vG5ExXck5WOHDJ8in/k9AqlfIyFMMT1uG7u8mNjX+QRILTIn0/Xgschfh/dQ9g==", "requires": { - "tslib": "^2.0.0" + "tslib": "^2.2.0" }, "dependencies": { "tslib": { @@ -376,16 +376,16 @@ } }, "@celo/base": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/base/-/base-1.2.5.tgz", - "integrity": "sha512-59bBpcdlg3Y1Ak7gtusTJn91jcRk92IaOBq+uzvCWnvYbRedPUvJkbgqnLdqMlpf0QvY/F9HO8rdpBLPW/QjLg==" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/base/-/base-1.5.0.tgz", + "integrity": "sha512-RPRhwrKLyKdGAuaJ8vdslwEI/wVVQQiVGitzoBtUdFIMuf5XGPRp8GFNbYJdGcpooJnkQy1u8DYmZpaCLtRPDQ==" }, "@celo/connect": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/connect/-/connect-1.2.5.tgz", - "integrity": "sha512-Mg4Ul5mocMA39Zdw5ZzUk7PdyapuRN6WN7/i611sZgNs23TO8SbW7Hfal+oZAyZR/4weOSwejZoUQ/yR1cXF3w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/connect/-/connect-1.5.0.tgz", + "integrity": "sha512-LIG/GlBKuJLd8WgJYtCGut6fvn4GJ6HAqwXAumVCqiRkQIBZ0TZQQ39wWGTwfvKSzNzWpQsLx9oY96sTLGEOiQ==", "requires": { - "@celo/utils": "1.2.5", + "@celo/utils": "1.5.0", "@types/debug": "^4.1.5", "@types/utf8": "^2.1.6", "bignumber.js": "^9.0.0", @@ -394,17 +394,17 @@ } }, "@celo/contractkit": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/contractkit/-/contractkit-1.2.5.tgz", - "integrity": "sha512-TaCMP2MigmkV/+ysSYgp0Xy8zmxJoZrIQn2gZdBtmszaBmmp3c+up8FbmLj4fkkvK8W+ZtvMiMJJKH1e3hStOw==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/contractkit/-/contractkit-1.5.0.tgz", + "integrity": "sha512-JX5ZcpPyWO6loAF2aFcNG64ElFhyBmPPBE2L2KwjLOPkKmGpjb8TqlgQEg76u/NysEzfylpd9i7HuK0NSg3H9Q==", "requires": { - "@celo/base": "1.2.5", - "@celo/connect": "1.2.5", - "@celo/utils": "1.2.5", - "@celo/wallet-local": "1.2.5", + "@celo/base": "1.5.0", + "@celo/connect": "1.5.0", + "@celo/utils": "1.5.0", + "@celo/wallet-local": "1.5.0", "@types/debug": "^4.1.5", "bignumber.js": "^9.0.0", - "cross-fetch": "3.0.4", + "cross-fetch": "^3.0.6", "debug": "^4.1.1", "fp-ts": "2.1.1", "io-ts": "2.0.1", @@ -423,27 +423,28 @@ } }, "@celo/explorer": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/explorer/-/explorer-1.2.5.tgz", - "integrity": "sha512-RYod5Ml699xKJWCggEnsENvnG6zu5Je+9zWgtBN9Td8S+S4DepaMsDlcZYGUnZ1IQaLs1zUDpEdAyr9h4lq11w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/explorer/-/explorer-1.5.0.tgz", + "integrity": "sha512-77SVSFGJNGFca/2JoQR/dkRLNYdY7a+b7uEdqXe6MTLjnm0E3qCrrZJerCFaqh6cqtF2HzoF1uKXhiZ0zX/PcA==", "requires": { - "@celo/base": "1.2.5", - "@celo/connect": "1.2.5", - "@celo/contractkit": "1.2.5", + "@celo/base": "1.5.0", + "@celo/connect": "1.5.0", + "@celo/contractkit": "1.5.0", + "@celo/utils": "1.5.0", "@types/debug": "^4.1.5", "debug": "^4.1.1" } }, "@celo/governance": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/governance/-/governance-1.2.5.tgz", - "integrity": "sha512-YGNfPhdQ7aW7JqAdvpnD25XxR7Nc3Vj5mmv+p5uvO9bv9WOhuDL5teda5wZVRNg4GFzdhdpusyITx7FBzxzl1w==", - "requires": { - "@celo/base": "1.2.5", - "@celo/connect": "1.2.5", - "@celo/contractkit": "1.2.5", - "@celo/explorer": "1.2.5", - "@celo/utils": "1.2.5", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/governance/-/governance-1.5.0.tgz", + "integrity": "sha512-9KpCv48kYCnh3an49LOdOYnYK9Bd4wJ4wTIGkfo3HdUVAErW+jKxAKfVlJrHCbr7Pbvzapo58GkCTKoCpejccA==", + "requires": { + "@celo/base": "1.5.0", + "@celo/connect": "1.5.0", + "@celo/contractkit": "1.5.0", + "@celo/explorer": "1.5.0", + "@celo/utils": "1.5.0", "@types/debug": "^4.1.5", "@types/ethereumjs-util": "^5.2.0", "@types/inquirer": "^6.5.0", @@ -453,16 +454,16 @@ } }, "@celo/identity": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/identity/-/identity-1.2.5.tgz", - "integrity": "sha512-UX8OEUl98KA8RCDZYX/O/fk4ZkkXEDVsOdhsQL1ZWqexZoMlSEYHNWFK7g1bEm4VhkgTE3YuPTlRSuM9UqxoKg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/identity/-/identity-1.5.0.tgz", + "integrity": "sha512-CSlYxXilsiNIWCnrzE5SjCmySBYvQ6PcuzzRtIJ1K+62dffIfmTGc1nLeu8n2I7Bf7g1mupd5BF0PkAe5XB6FQ==", "requires": { - "@celo/base": "1.2.5", - "@celo/contractkit": "1.2.5", - "@celo/utils": "1.2.5", + "@celo/base": "1.5.0", + "@celo/contractkit": "1.5.0", + "@celo/utils": "1.5.0", "@types/debug": "^4.1.5", "bignumber.js": "^9.0.0", - "blind-threshold-bls": "git+https://github.com/celo-org/blind-threshold-bls-wasm.git#e1e2f8a1ab5154c2f0b1c55cb0d61fbb1d907208", + "blind-threshold-bls": "git+https://github.com/celo-org/blind-threshold-bls-wasm.git#e1e2f8a", "cross-fetch": "3.0.4", "debug": "^4.1.1", "elliptic": "^6.5.4", @@ -475,6 +476,15 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, + "cross-fetch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.4.tgz", + "integrity": "sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw==", + "requires": { + "node-fetch": "2.6.0", + "whatwg-fetch": "3.0.0" + } + }, "elliptic": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", @@ -492,11 +502,11 @@ } }, "@celo/utils": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/utils/-/utils-1.2.5.tgz", - "integrity": "sha512-21Ays/8sqJNblU6gowsNmSnSxitNgx7nHe37dYWgtFXoUHFWQLF1J+SRVBjM55+4oVl6QpaH9cQjbEbLcCdD3Q==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/utils/-/utils-1.5.0.tgz", + "integrity": "sha512-D/g+DFiqTdE4GP+gyNWpwbcz6MUDuncW/fh+3eU6253Lfiu75ca2UArn8/XX+kSz9qz1KHNh+KVmvXfipJXJiw==", "requires": { - "@celo/base": "1.2.5", + "@celo/base": "1.5.0", "@types/country-data": "^0.0.0", "@types/elliptic": "^6.4.9", "@types/ethereumjs-util": "^5.2.0", @@ -549,13 +559,13 @@ } }, "@celo/wallet-base": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/wallet-base/-/wallet-base-1.2.5.tgz", - "integrity": "sha512-6I7OdV2EbIkajgZNNDGm/R7SQBfIXrDJJyLQ37V0aV4SwVmYTx7GcP+9StuSccqSyAfdw0oy7fMolN+V70x0QA==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/wallet-base/-/wallet-base-1.5.0.tgz", + "integrity": "sha512-1MOCSyH9q0LWuQMHEXljzgfBWVLrMPWzt9LFqTwtdn5zePP+SxUDceGEXBgFKKI2PrqrbkTcczQGfA1EK8J33w==", "requires": { - "@celo/base": "1.2.5", - "@celo/connect": "1.2.5", - "@celo/utils": "1.2.5", + "@celo/base": "1.5.0", + "@celo/connect": "1.5.0", + "@celo/utils": "1.5.0", "@types/debug": "^4.1.5", "@types/ethereumjs-util": "^5.2.0", "bignumber.js": "^9.0.0", @@ -565,11 +575,11 @@ } }, "@celo/wallet-hsm": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/wallet-hsm/-/wallet-hsm-1.2.5.tgz", - "integrity": "sha512-ZRaV31Vr9qxjv5j74sNZFrvtgIsW7zR2CQRFrhwxnHyBUWbN+kc0DHjS5pSCaAxEE4vsV6Vm9K56W880CDOP4w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/wallet-hsm/-/wallet-hsm-1.5.0.tgz", + "integrity": "sha512-tseOC8LhrLRq7bqq+Yx9qItwPEUkdc+rjtEPM4vEFUxjFIZariTxSq9QYqwlbtt2sDnK5COIAZzuhlRKR+a9lg==", "requires": { - "@celo/base": "1.2.5", + "@celo/base": "1.5.0", "@types/asn1js": "^0.0.2", "@types/debug": "^4.1.5", "@types/secp256k1": "^4.0.0", @@ -602,18 +612,18 @@ } }, "@celo/wallet-hsm-azure": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/wallet-hsm-azure/-/wallet-hsm-azure-1.2.5.tgz", - "integrity": "sha512-kfCKzR5zU49UryMtanNpoG1oedyV16aRQS8uvylkTsJ2MRNG6tUaUq/0RNkLzyzOcL7E3HlI2dXa0EQiLXO+Eg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/wallet-hsm-azure/-/wallet-hsm-azure-1.5.0.tgz", + "integrity": "sha512-RPpDyGco8pX8nxcsUrdg3kCmA7glpXuInQ2VlzJ24sjLxRvvwJm/S36IdzeOY3iUtOotkc+cNOYzzXehkTC7UA==", "requires": { "@azure/identity": "^1.1.0", "@azure/keyvault-keys": "^4.1.0", "@azure/keyvault-secrets": "^4.1.0", - "@celo/connect": "1.2.5", - "@celo/utils": "1.2.5", - "@celo/wallet-base": "1.2.5", - "@celo/wallet-hsm": "1.2.5", - "@celo/wallet-remote": "1.2.5", + "@celo/connect": "1.5.0", + "@celo/utils": "1.5.0", + "@celo/wallet-base": "1.5.0", + "@celo/wallet-hsm": "1.5.0", + "@celo/wallet-remote": "1.5.0", "@types/secp256k1": "^4.0.0", "bignumber.js": "^9.0.0", "debug": "^4.1.1", @@ -623,14 +633,14 @@ } }, "@celo/wallet-ledger": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/wallet-ledger/-/wallet-ledger-1.2.5.tgz", - "integrity": "sha512-XYo1LKhL1bgaOoyF5EUHXOf2ug8Q6ksRq2TY48/w2XgyoOuniv1QaYw2sA8eKpDESDn9bswc1+sQ/siNacTQ5A==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/wallet-ledger/-/wallet-ledger-1.5.0.tgz", + "integrity": "sha512-WyKuxLpV9XQHxdrvr+vSy7BBEq+40Y5ikrpZbWZjoSIEhISgjeTbiv0spMTFLywNhzlxiNFi8T8eCMuiTvxguQ==", "requires": { - "@celo/connect": "1.2.5", - "@celo/utils": "1.2.5", - "@celo/wallet-base": "1.2.5", - "@celo/wallet-remote": "1.2.5", + "@celo/connect": "1.5.0", + "@celo/utils": "1.5.0", + "@celo/wallet-base": "1.5.0", + "@celo/wallet-remote": "1.5.0", "@ledgerhq/hw-app-eth": "~5.11.0", "@ledgerhq/hw-transport": "~5.11.0", "@types/ethereumjs-util": "^5.2.0", @@ -640,26 +650,26 @@ } }, "@celo/wallet-local": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/wallet-local/-/wallet-local-1.2.5.tgz", - "integrity": "sha512-u2AJo7U3wc15Ym4q+4Ir6NJg2MLq6qFoeFfNdrQifY6Cni6YAWJYQHGmnJV7xOXvNcog9kQeJIMO3ioWQf3LlA==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/wallet-local/-/wallet-local-1.5.0.tgz", + "integrity": "sha512-JwFvnmKrk5Qr1bNkrp6NsMYtWd9WJECUIesGIB1QhApHDU6nmW2GxsQbnMZrElPoaFSGcbaPvUCnOTv1uHn5UA==", "requires": { - "@celo/connect": "1.2.5", - "@celo/utils": "1.2.5", - "@celo/wallet-base": "1.2.5", + "@celo/connect": "1.5.0", + "@celo/utils": "1.5.0", + "@celo/wallet-base": "1.5.0", "@types/ethereumjs-util": "^5.2.0", "eth-lib": "^0.2.8", "ethereumjs-util": "^5.2.0" } }, "@celo/wallet-remote": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@celo/wallet-remote/-/wallet-remote-1.2.5.tgz", - "integrity": "sha512-8jeGYEAg/dkq4dzdMLfWb6EKoUIbYOKSx+a5/IJUaQEnzbyqLInrnuree2L5VPN+TlI+y2SJ0fGL4i0VBWe9Hw==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@celo/wallet-remote/-/wallet-remote-1.5.0.tgz", + "integrity": "sha512-5AoCn9w4yogViO7dT7f19/2nKRnz+QzhVbeBma410XO3Jy8hnrS+yXEbtDJjUYhHFthYaVZ/XPvf3+fAZHjmhg==", "requires": { - "@celo/connect": "1.2.5", - "@celo/utils": "1.2.5", - "@celo/wallet-base": "1.2.5", + "@celo/connect": "1.5.0", + "@celo/utils": "1.5.0", + "@celo/wallet-base": "1.5.0", "@types/debug": "^4.1.5", "@types/ethereumjs-util": "^5.2.0", "eth-lib": "^0.2.8", @@ -2239,9 +2249,9 @@ "integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==" }, "@types/elliptic": { - "version": "6.4.13", - "resolved": "https://registry.npmjs.org/@types/elliptic/-/elliptic-6.4.13.tgz", - "integrity": "sha512-e8iyLJ8vMLpWxXpVWrIt0ujqsfHWgVe5XAz9IMhBYoDirK6th7J+mHjzp797OLc62ZX419nrlwwzsNAA0a0mKg==", + "version": "6.4.14", + "resolved": "https://registry.npmjs.org/@types/elliptic/-/elliptic-6.4.14.tgz", + "integrity": "sha512-z4OBcDAU0GVwDTuwJzQCiL6188QvZMkvoERgcVjq0/mPM8jCfdwZ3x5zQEVoL9WCAru3aG5wl3Z5Ww5wBWn7ZQ==", "requires": { "@types/bn.js": "*" } @@ -2256,9 +2266,9 @@ } }, "@types/google-libphonenumber": { - "version": "7.4.21", - "resolved": "https://registry.npmjs.org/@types/google-libphonenumber/-/google-libphonenumber-7.4.21.tgz", - "integrity": "sha512-AkZh/KMuvHpjpMeV1Wx1BJl5gMUVc2gKJhzhbQlpUzIg5s/vjcw8tZeH7nLsCwddCxqf93YVpdJcjUNRkW7gvQ==" + "version": "7.4.23", + "resolved": "https://registry.npmjs.org/@types/google-libphonenumber/-/google-libphonenumber-7.4.23.tgz", + "integrity": "sha512-C3ydakLTQa8HxtYf9ge4q6uT9krDX8smSIxmmW3oACFi5g5vv6T068PRExF7UyWbWpuYiDG8Nm24q2X5XhcZWw==" }, "@types/inquirer": { "version": "6.5.0", @@ -2270,9 +2280,9 @@ } }, "@types/lodash": { - "version": "4.14.173", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.173.tgz", - "integrity": "sha512-vv0CAYoaEjCw/mLy96GBTnRoZrSxkGE0BKzKimdR8P3OzrNYNvBgtW7p055A+E8C31vXNUhWKoFCbhq7gbyhFg==" + "version": "4.14.178", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz", + "integrity": "sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==" }, "@types/long": { "version": "4.0.1", @@ -2525,7 +2535,7 @@ "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-2.1.1.tgz", "integrity": "sha512-t9u0dU0rJN4ML+uxgN6VM2Z4H5jWIYm0w8LsZLzMJaQsgL3IJNbxHgmbWDvJAwspyHpDFuzUaUFh4c05UB4+6g==", "requires": { - "pvutils": "latest" + "pvutils": "^1.0.17" }, "dependencies": { "pvutils": { @@ -2714,6 +2724,11 @@ "version": "12.19.15", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.15.tgz", "integrity": "sha512-lowukE3GUI+VSYSu6VcBXl14d61Rp5hA1D+61r16qnwC0lYNSqdxcvRh0pswejorHfS+HgwBasM8jLXz0/aOsw==" + }, + "typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==" } } }, @@ -3542,12 +3557,18 @@ } }, "cross-fetch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.4.tgz", - "integrity": "sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz", + "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", "requires": { - "node-fetch": "2.6.0", - "whatwg-fetch": "3.0.0" + "node-fetch": "2.6.1" + }, + "dependencies": { + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + } } }, "cross-spawn": { @@ -4300,9 +4321,9 @@ } }, "follow-redirects": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz", - "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==" + "version": "1.14.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz", + "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==" }, "foreach": { "version": "2.0.5", @@ -4562,9 +4583,9 @@ } }, "google-libphonenumber": { - "version": "3.2.23", - "resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.23.tgz", - "integrity": "sha512-bcrAEAF68R5p3ooGytNTPEJ4eSOg5QJ9wiBoENRrqIiSPvllIenQq/e7+H5GleOIDSJvrLZZPF8oicPUEFi5Rg==" + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.25.tgz", + "integrity": "sha512-M/b5mij5o2aGnbe+Id9O3847jBtP0baW61foFkevxBxbuV4LH9AcujjYLd2UVkUPKVdMpKyBZxfeNwdxqobQFQ==" }, "google-p12-pem": { "version": "3.0.3", @@ -4945,21 +4966,21 @@ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" + "strip-ansi": "^6.0.1" } }, "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "requires": { - "ansi-regex": "^5.0.0" + "ansi-regex": "^5.0.1" } }, "supports-color": { @@ -5432,12 +5453,39 @@ } }, "keccak256": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/keccak256/-/keccak256-1.0.3.tgz", - "integrity": "sha512-EkF/4twuPm1V/gn75nejOUrKfDUJn87RMLzDWosXF3pXuOvesiSgX35GcmbqzdImCASEkE/WaklWGWSa+Ha5bQ==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/keccak256/-/keccak256-1.0.6.tgz", + "integrity": "sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw==", "requires": { - "bn.js": "^4.11.8", - "keccak": "^3.0.1" + "bn.js": "^5.2.0", + "buffer": "^6.0.3", + "keccak": "^3.0.2" + }, + "dependencies": { + "bn.js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", + "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==" + }, + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "keccak": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.2.tgz", + "integrity": "sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ==", + "requires": { + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0", + "readable-stream": "^3.6.0" + } + } } }, "keytar": { @@ -5881,9 +5929,9 @@ "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "msal": { - "version": "1.4.12", - "resolved": "https://registry.npmjs.org/msal/-/msal-1.4.12.tgz", - "integrity": "sha512-gjupwQ6nvNL6mZkl5NIXyUmZhTiEMRu5giNdgHMh8l5EPOnV2Xj6nukY1NIxFacSTkEYUSDB47Pej9GxDYf+1w==", + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/msal/-/msal-1.4.15.tgz", + "integrity": "sha512-H/CxkeZJ4laEK6GZ/cDKQoYjBTvDNFK3hDC8mfU8IkuZvKFfFdo9KM89r8spXY7xnBK9SQBAjIuQgwUogeUw7g==", "requires": { "tslib": "^1.9.3" } @@ -7312,11 +7360,6 @@ "resolved": "https://registry.npmjs.org/typeforce/-/typeforce-1.18.0.tgz", "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" }, - "typescript": { - "version": "3.9.7", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", - "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==" - }, "ultron": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", diff --git a/packages/cli/package.json b/packages/cli/package.json index c4bb746b31c..a865f023997 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@celo/celocli", "description": "CLI Tool for transacting with the Celo protocol", - "version": "1.3.0", + "version": "1.5.1-dev", "author": "Celo", "license": "Apache-2.0", "repository": "celo-org/celo-monorepo", @@ -25,22 +25,22 @@ "build": "tsc -b .", "docs": "./generate_docs.sh", "lint": "tslint -c tslint.json --project tsconfig.json", - "generate:shrinkwrap": "yarn run npm install --production && yarn run npm shrinkwrap", - "check:shrinkwrap": "yarn run npm install --production && yarn run npm shrinkwrap && ./scripts/check_shrinkwrap_dirty.sh", + "generate:shrinkwrap": "npm install --production && npm shrinkwrap", + "check:shrinkwrap": "npm install --production && npm shrinkwrap && ./scripts/check_shrinkwrap_dirty.sh", "prepack": "yarn run build && oclif-dev manifest && oclif-dev readme && yarn run check:shrinkwrap", "test:reset": "yarn --cwd ../protocol devchain generate-tar .tmp/devchain.tar.gz --migration_override ../dev-utils/src/migration-override.json --upto 25 --release_gold_contracts scripts/truffle/releaseGoldExampleConfigs.json", "test:livechain": "yarn --cwd ../protocol devchain run-tar .tmp/devchain.tar.gz", "test": "TZ=UTC jest --runInBand" }, "dependencies": { - "@celo/contractkit": "1.3.3-dev", - "@celo/explorer": "1.3.3-dev", - "@celo/governance": "1.3.3-dev", - "@celo/identity": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/wallet-hsm-azure": "1.3.3-dev", - "@celo/wallet-ledger": "1.3.3-dev", - "@celo/wallet-local": "1.3.3-dev", + "@celo/contractkit": "1.5.1-dev", + "@celo/explorer": "1.5.1-dev", + "@celo/governance": "1.5.1-dev", + "@celo/identity": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-hsm-azure": "1.5.1-dev", + "@celo/wallet-ledger": "1.5.1-dev", + "@celo/wallet-local": "1.5.1-dev", "@ledgerhq/hw-transport-node-hid": "~5.11.0", "@oclif/command": "^1.6.0", "@oclif/config": "^1.6.0", @@ -162,4 +162,4 @@ "prerun": "./lib/hooks/prerun/plugin-warning" } } -} \ No newline at end of file +} diff --git a/packages/cli/src/utils/command.ts b/packages/cli/src/utils/command.ts index 16909e09ed4..4ddff792d39 100644 --- a/packages/cli/src/utils/command.ts +++ b/packages/cli/src/utils/command.ts @@ -1,8 +1,8 @@ +import { URL_REGEX } from '@celo/base/lib/io' import { CeloContract, RegisteredContracts } from '@celo/contractkit' +import { isE164NumberStrict } from '@celo/phone-utils/lib/phoneNumbers' import { ensureLeading0x, trimLeading0x } from '@celo/utils/lib/address' import { BLS_POP_SIZE, BLS_PUBLIC_KEY_SIZE } from '@celo/utils/lib/bls' -import { URL_REGEX } from '@celo/utils/lib/io' -import { isE164NumberStrict } from '@celo/utils/lib/phoneNumbers' import { POP_SIZE } from '@celo/utils/lib/signatureUtils' import { flags } from '@oclif/command' import { CLIError } from '@oclif/errors' diff --git a/packages/docs/developer-resources/utils/reference/README.md b/packages/docs/developer-resources/utils/reference/README.md new file mode 100644 index 00000000000..a90cd0f5701 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/README.md @@ -0,0 +1,162 @@ +# @celo/phone-utils + +

+ + celo logo + +

+ +**Celo Monorepo - Official repository for core projects comprising the Celo platform** + +This repository contains the source code for the Celo core projects including the [smart contracts](https://github.com/celo-org/celo-monorepo/tree/master/packages/protocol), [contractKit](https://github.com/celo-org/celo-monorepo/tree/master/packages/sdk/contractkit), +and other packages. The source code for the Celo Blockchain which operates a node on the Celo Network is kept in a separate repo [here](https://github.com/celo-org/celo-blockchain). + + + +[![CircleCI](https://img.shields.io/circleci/build/github/celo-org/celo-monorepo/master)](https://circleci.com/gh/celo-org/celo-monorepo/tree/master) +[![Codecov](https://img.shields.io/codecov/c/github/celo-org/celo-monorepo)](https://codecov.io/gh/celo-org/celo-monorepo) +[![GitHub contributors](https://img.shields.io/github/contributors/celo-org/celo-monorepo)](https://github.com/celo-org/celo-monorepo/graphs/contributors) +[![GitHub commit activity](https://img.shields.io/github/commit-activity/w/celo-org/celo-monorepo)](https://github.com/celo-org/celo-monorepo/graphs/contributors) +[![GitHub Stars](https://img.shields.io/github/stars/celo-org/celo-monorepo.svg)](https://github.com/celo-org/celo-monorepo/stargazers) +![GitHub repo size](https://img.shields.io/github/repo-size/celo-org/celo-monorepo) +[![GitHub](https://img.shields.io/github/license/celo-org/celo-monorepo?color=blue)](https://github.com/celo-org/celo-monorepo/blob/master/LICENSE) + + + +[![Website celo.org](https://img.shields.io/website-up-down-green-red/https/celo.org.svg)](https://celo.org) +[![Blog](https://img.shields.io/badge/blog-up-green)](https://medium.com/celoorg) +[![docs](https://img.shields.io/badge/docs-up-green)](https://docs.celo.org/) +[![Youtube](https://img.shields.io/badge/YouTube%20channel-up-green)](https://www.youtube.com/channel/UCCZgos_YAJSXm5QX5D5Wkcw/videos?view=0&sort=p&flow=grid) +[![forum](https://img.shields.io/badge/forum-up-green)](https://forum.celo.org) +[![Discord](https://img.shields.io/discord/600834479145353243.svg)](https://discord.gg/RfHQKtY) +[![Twitter CeloDevs](https://img.shields.io/twitter/follow/celodevs?style=social)](https://twitter.com/celodevs) +[![Twitter CeloOrg](https://img.shields.io/twitter/follow/celoorg?style=social)](https://twitter.com/CeloOrg) +[![Subreddit subscribers](https://img.shields.io/reddit/subreddit-subscribers/CeloHQ?style=social)](https://www.reddit.com/r/CeloHQ/) + + + +[![GitHub pull requests by-label](https://img.shields.io/github/issues-pr-raw/celo-org/celo-monorepo)](https://github.com/celo-org/celo-monorepo/pulls) +[![GitHub Issues](https://img.shields.io/github/issues-raw/celo-org/celo-monorepo.svg)](https://github.com/celo-org/celo-monorepo/issues) +[![GitHub issues by-label](https://img.shields.io/github/issues/celo-org/celo-monorepo/1%20hour%20tasks)](https://github.com/celo-org/celo-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A%221+hour+tasks%22) +[![GitHub issues by-label](https://img.shields.io/github/issues/celo-org/celo-monorepo/betanet-phase-2)](https://github.com/celo-org/celo-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3Abetanet-phase-2) +[![GitHub issues by-label](https://img.shields.io/github/issues/celo-org/celo-monorepo/betanet-phase-3)](https://github.com/celo-org/celo-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3Abetanet-phase-3) + +Contents: + + + +- [Celo's Mission - Prosperity for All](#mission) +- [The Celo Stack](#stack) +- [Documentation](#docs) +- [Issues](#issues) +- [Repo Structure](#repo) +- [Contributing](#contributing) +- [Ask Questions, Find Answers, Get in Touch](#ask) +- [License](#license) + + +## 🥅 Celo's Mission - Prosperity for All + +Celo, pronounced /ˈtselo/, means ‘purpose’ in Esperanto. In a similar spirit, we are aiming to create a new platform to connect people globally and bring financial stability to those who need it most. We believe blockchain technology is one of the most exciting innovations in recent history and as a community we look to push the boundaries of what is possible with it today. More importantly, we are driven by purpose -- to solve real-world problems such as lack of access to sound currency, or friction for cash-transfer programs aimed to alleviate poverty. Our mission is to build a monetary system that creates the conditions for prosperity for all. + + +

+ + Play on Youtube - What if money were beautiful + +
+ What if money were beautiful? +

+ +## 🧱 The Celo Stack + +Celo is oriented around providing the simplest possible experience for end users, who may have no familiarity with cryptocurrencies, and may be using low cost devices with limited connectivity. To achieve this, the project takes a full-stack approach, where each layer of the stack is designed with the end user in mind whilst considering other stakeholders \(e.g. operators of nodes in the network\) involved in enabling the end user experience. + +The Celo stack is structured into the following logical layers: + + +

+ Celo protocol +
+ The Celo Blockchain and Celo Core Contracts together comprise the Celo Protocol +

+ +- **Celo Blockchain**: An open cryptographic protocol that allows applications to make transactions with and run smart contracts in a secure and decentralized fashion. The Celo Blockchain has shared ancestry with [Ethereum](https://www.ethereum.org), and maintains full EVM compatibility for smart contracts. However it uses a [Byzantine Fault Tolerant](http://pmg.csail.mit.edu/papers/osdi99.pdf) \(BFT\) consensus mechanism rather than Proof of Work, and has different block format, transaction format, client synchronization protocols, and gas payment and pricing mechanisms. The network’s native asset is Celo Gold, exposed via an ERC-20 interface. + +- **Celo Core Contracts**: A set of smart contracts running on the Celo Blockchain that comprise much of the logic of the platform features including ERC-20 stable currencies, identity attestations, Proof of Stake and governance. These smart contracts are upgradeable and managed by the decentralized governance process. + + +

+ Celo network +
+ Topology of a Celo Network +

+ +- **Applications:** Applications for end users built on the Celo platform. The Celo Wallet app, the first of an ecosystem of applications, allows end users to manage accounts and make payments securely and simply by taking advantage of the innovations in the Celo protocol. Applications take the form of external mobile or backend software: they interact with the Celo Blockchain to issue transactions and invoke code that forms the Celo Core Contracts’ API. Third parties can also deploy custom smart contracts that their own applications can invoke, which in turn can leverage Celo Core Contracts. Applications may use centralized cloud services to provide some of their functionality: in the case of the Celo Wallet, push notifications and a transaction activity feed. + +## 📚 Documentation + +Follow the instructions in [SETUP.md](SETUP.md) to get a development environment set up. + +See [Developer's Guide](https://docs.celo.org/) for full details about the design of the Celo protocol and other information about running these projects. + +## 🙋 Issues + +See the [issue backlog](https://github.com/celo-org/celo-monorepo/issues) for a list of active or proposed tasks. Feel free to create new issues to report bugs and/or request features. + +## 📂 Repo Structure + +The repository has the following packages (sub projects): + +- [attestation-service](packages/attestation-service) - service run by validators on the Celo network to send SMS messages, enabling attestations of user phone numbers and their accounts on the Celo network +- [blockchain-api](packages/blockchain-api) - service that uses Blockscout to present view of transactions by account for Celo Wallet activity feed +- [celotool](packages/celotool) - scripts for deploying and managing testnets +- [cli](packages/cli) - tool that uses ContractKit to interact with the Celo protocol ([docs](https://docs.celo.org/command-line-interface/introduction)) +- [contractkit](packages/contractkit) - library to help developers and validators interact with the protocol and it's smart contracts ([docs](https://docs.celo.org/celo-sdk/contractkit)) +- [dappkit](packages/dappkit) - set of functions for mobile DApps to work with the wallet app (ex. sign transactions and access the user's account) ([docs](https://docs.celo.org/celo-sdk/dappkit)) +- [dev-utils](packages/dev-utils) - a utils package for use as a dev dependency +- [docs](packages/docs) - technical documentation for the Celo project ([live](https://docs.celo.org/)) +- [faucet](packages/faucet) - faucet deployment configuration ([live](https://celo.org/build/faucet)) +- [helm-charts](packages/helm-charts) - templatized deployments of entire environments to Kubernetes clusters +- [mobile](packages/mobile) - Android wallet app for the Celo platform ([docs](https://docs.celo.org/getting-started/using-the-mobile-wallet), [live](https://play.google.com/store/apps/details?id=org.celo.mobile.alfajores)) +- [notification-service](packages/notification-service) - service for managing push notifications for Celo Wallet +- [protocol](packages/protocol) - identity, stability and other smart contracts for the Celo protocol ([docs](https://docs.celo.org/celo-codebase/protocol)) +- [react-components](packages/react-components) - generalized react native components +- [reserve-site](packages/reserve-site) - website for ([Celo Reserve.org](https://celoreserve.org/)) +- [terraform-modules](packages/terraform-modules) - templatized deployments of entire VM-based testnets for Google Cloud Platform +- [typescript](packages/typescript) - no README available (improve?) +- [utils](packages/utils) - no README available (improve?) + +Code owners for each package can be found in [.github/CODEOWNERS](.github/CODEOWNERS). + +## ✍️ Contributing + +Feel free to jump on the Celo 🚂🚋🚋🚋. Improvements and contributions are highly encouraged! 🙏👊 + +See the [contributing guide](https://docs.celo.org/community/contributing) for details on how to participate. +[![GitHub issues by-label](https://img.shields.io/github/issues/celo-org/celo-monorepo/1%20hour%20tasks)](https://github.com/celo-org/celo-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A%221+hour+tasks%22) + +All communication and contributions to the Celo project are subject to the [Celo Code of Conduct](https://celo.org/code-of-conduct). + +Not yet ready to contribute but do like the project? Support Celo with a ⭐ or share the love in a [![Twitter URL](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fcelo.org%2F)](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DkKggE5OvyhE&via=celohq&text=Checkout%20celo%21%20Love%20what%20they%20are%20building.&hashtags=celo) + + + +## 💬 Ask Questions, Find Answers, Get in Touch + +- [Website](https://celo.org/) +- [Docs](https://docs.celo.org/) +- [Blog](https://medium.com/celohq) +- [YouTube](https://www.youtube.com/channel/UCCZgos_YAJSXm5QX5D5Wkcw/videos?view=0&sort=p&flow=grid) +- [Forum](https://forum.celo.org) +- [Discord](https://discord.gg/vRbExjv) +- [Twitter](https://twitter.com/CeloDevs) +- [Reddit](https://www.reddit.com/r/CeloHQ/) +- [Community Events](https://celo.org/community) + +## 📜 License + +All packages are licensed under the terms of the [Apache 2.0 License](LICENSE) unless otherwise specified in the LICENSE file at package's root. diff --git a/packages/docs/developer-resources/utils/reference/SUMMARY.md b/packages/docs/developer-resources/utils/reference/SUMMARY.md new file mode 100644 index 00000000000..1884115503b --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/SUMMARY.md @@ -0,0 +1,13 @@ +* [Globals](globals.md) +* [Modules]() + * [countries](modules/_countries_.md) + * [Countries](classes/_countries_.countries.md) + * [LocalizedCountry](interfaces/_countries_.localizedcountry.md) + * [data/countries/es/country](modules/_data_countries_es_country_.md) + * [inputValidation](modules/_inputvalidation_.md) + * [io](modules/_io_.md) + * [phoneNumbers](modules/_phonenumbers_.md) +* [Classes]() + * [Countries](classes/_countries_.countries.md) +* [Interfaces]() + * [LocalizedCountry](interfaces/_countries_.localizedcountry.md) \ No newline at end of file diff --git a/packages/docs/developer-resources/utils/reference/classes/_countries_.countries.md b/packages/docs/developer-resources/utils/reference/classes/_countries_.countries.md new file mode 100644 index 00000000000..e436fc9b6f7 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/classes/_countries_.countries.md @@ -0,0 +1,111 @@ +# Class: Countries + +## Hierarchy + +* **Countries** + +## Index + +### Constructors + +* [constructor](_countries_.countries.md#constructor) + +### Properties + +* [countryMap](_countries_.countries.md#countrymap) +* [language](_countries_.countries.md#language) +* [localizedCountries](_countries_.countries.md#localizedcountries) + +### Methods + +* [getCountry](_countries_.countries.md#getcountry) +* [getCountryByCodeAlpha2](_countries_.countries.md#getcountrybycodealpha2) +* [getFilteredCountries](_countries_.countries.md#getfilteredcountries) + +## Constructors + +### constructor + +\+ **new Countries**(`language?`: undefined | string): *[Countries](_countries_.countries.md)* + +*Defined in [countries.ts:40](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L40)* + +**Parameters:** + +Name | Type | +------ | ------ | +`language?` | undefined | string | + +**Returns:** *[Countries](_countries_.countries.md)* + +## Properties + +### countryMap + +• **countryMap**: *Map‹string, [LocalizedCountry](../interfaces/_countries_.localizedcountry.md)›* + +*Defined in [countries.ts:39](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L39)* + +___ + +### language + +• **language**: *string* + +*Defined in [countries.ts:38](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L38)* + +___ + +### localizedCountries + +• **localizedCountries**: *[LocalizedCountry](../interfaces/_countries_.localizedcountry.md)[]* + +*Defined in [countries.ts:40](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L40)* + +## Methods + +### getCountry + +▸ **getCountry**(`countryName?`: string | null): *[LocalizedCountry](../interfaces/_countries_.localizedcountry.md) | undefined* + +*Defined in [countries.ts:50](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L50)* + +**Parameters:** + +Name | Type | +------ | ------ | +`countryName?` | string | null | + +**Returns:** *[LocalizedCountry](../interfaces/_countries_.localizedcountry.md) | undefined* + +___ + +### getCountryByCodeAlpha2 + +▸ **getCountryByCodeAlpha2**(`countryCode`: string): *[LocalizedCountry](../interfaces/_countries_.localizedcountry.md) | undefined* + +*Defined in [countries.ts:60](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L60)* + +**Parameters:** + +Name | Type | +------ | ------ | +`countryCode` | string | + +**Returns:** *[LocalizedCountry](../interfaces/_countries_.localizedcountry.md) | undefined* + +___ + +### getFilteredCountries + +▸ **getFilteredCountries**(`query`: string): *[LocalizedCountry](../interfaces/_countries_.localizedcountry.md)[]* + +*Defined in [countries.ts:64](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L64)* + +**Parameters:** + +Name | Type | +------ | ------ | +`query` | string | + +**Returns:** *[LocalizedCountry](../interfaces/_countries_.localizedcountry.md)[]* diff --git a/packages/docs/developer-resources/utils/reference/globals.md b/packages/docs/developer-resources/utils/reference/globals.md new file mode 100644 index 00000000000..e2070222e31 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/globals.md @@ -0,0 +1,11 @@ +# @celo/phone-utils + +## Index + +### Modules + +* ["countries"](modules/_countries_.md) +* ["data/countries/es/country"](modules/_data_countries_es_country_.md) +* ["inputValidation"](modules/_inputvalidation_.md) +* ["io"](modules/_io_.md) +* ["phoneNumbers"](modules/_phonenumbers_.md) diff --git a/packages/docs/developer-resources/utils/reference/interfaces/_countries_.localizedcountry.md b/packages/docs/developer-resources/utils/reference/interfaces/_countries_.localizedcountry.md new file mode 100644 index 00000000000..c7747a0fcc2 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/interfaces/_countries_.localizedcountry.md @@ -0,0 +1,63 @@ +# Interface: LocalizedCountry + +## Hierarchy + +* object + + ↳ **LocalizedCountry** + +## Index + +### Properties + +* [countryCallingCode](_countries_.localizedcountry.md#countrycallingcode) +* [countryPhonePlaceholder](_countries_.localizedcountry.md#countryphoneplaceholder) +* [displayName](_countries_.localizedcountry.md#displayname) +* [displayNameNoDiacritics](_countries_.localizedcountry.md#displaynamenodiacritics) +* [names](_countries_.localizedcountry.md#names) + +## Properties + +### countryCallingCode + +• **countryCallingCode**: *string* + +*Defined in [countries.ts:18](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L18)* + +___ + +### countryPhonePlaceholder + +• **countryPhonePlaceholder**: *object* + +*Defined in [countries.ts:14](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L14)* + +#### Type declaration: + +* **international**? : *string | undefined* + +* **national**? : *string | undefined* + +___ + +### displayName + +• **displayName**: *string* + +*Defined in [countries.ts:11](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L11)* + +___ + +### displayNameNoDiacritics + +• **displayNameNoDiacritics**: *string* + +*Defined in [countries.ts:12](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L12)* + +___ + +### names + +• **names**: *CountryNames* + +*Defined in [countries.ts:13](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/countries.ts#L13)* diff --git a/packages/docs/developer-resources/utils/reference/modules/_countries_.md b/packages/docs/developer-resources/utils/reference/modules/_countries_.md new file mode 100644 index 00000000000..8de832cfac6 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/modules/_countries_.md @@ -0,0 +1,11 @@ +# Module: "countries" + +## Index + +### Classes + +* [Countries](../classes/_countries_.countries.md) + +### Interfaces + +* [LocalizedCountry](../interfaces/_countries_.localizedcountry.md) diff --git a/packages/docs/developer-resources/utils/reference/modules/_data_countries_es_country_.md b/packages/docs/developer-resources/utils/reference/modules/_data_countries_es_country_.md new file mode 100644 index 00000000000..5ffe13dfaf0 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/modules/_data_countries_es_country_.md @@ -0,0 +1,3 @@ +# Module: "data/countries/es/country" + + diff --git a/packages/docs/developer-resources/utils/reference/modules/_inputvalidation_.md b/packages/docs/developer-resources/utils/reference/modules/_inputvalidation_.md new file mode 100644 index 00000000000..754e49767b6 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/modules/_inputvalidation_.md @@ -0,0 +1,42 @@ +# Module: "inputValidation" + +## Index + +### Functions + +* [validateInput](_inputvalidation_.md#validateinput) +* [validatePhone](_inputvalidation_.md#validatephone) + +## Functions + +### validateInput + +▸ **validateInput**(`input`: string, `props`: BaseProps): *string* + +*Defined in [inputValidation.ts:20](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/inputValidation.ts#L20)* + +**Parameters:** + +Name | Type | +------ | ------ | +`input` | string | +`props` | BaseProps | + +**Returns:** *string* + +___ + +### validatePhone + +▸ **validatePhone**(`input`: string, `countryCallingCode?`: undefined | string): *string* + +*Defined in [inputValidation.ts:4](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/inputValidation.ts#L4)* + +**Parameters:** + +Name | Type | +------ | ------ | +`input` | string | +`countryCallingCode?` | undefined | string | + +**Returns:** *string* diff --git a/packages/docs/developer-resources/utils/reference/modules/_io_.md b/packages/docs/developer-resources/utils/reference/modules/_io_.md new file mode 100644 index 00000000000..95c8a900d42 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/modules/_io_.md @@ -0,0 +1,318 @@ +# Module: "io" + +## Index + +### References + +* [URL_REGEX](_io_.md#url_regex) +* [isValidUrl](_io_.md#isvalidurl) + +### Type aliases + +* [Address](_io_.md#address) +* [AttestationRequest](_io_.md#attestationrequest) +* [AttestationResponse](_io_.md#attestationresponse) +* [AttestationServiceTestRequest](_io_.md#attestationservicetestrequest) +* [E164Number](_io_.md#e164number) +* [GetAttestationRequest](_io_.md#getattestationrequest) +* [Signature](_io_.md#signature) + +### Variables + +* [AddressType](_io_.md#const-addresstype) +* [AttestationRequestType](_io_.md#const-attestationrequesttype) +* [AttestationResponseType](_io_.md#const-attestationresponsetype) +* [AttestationServiceStatusResponseType](_io_.md#const-attestationservicestatusresponsetype) +* [AttestationServiceTestRequestType](_io_.md#const-attestationservicetestrequesttype) +* [E164PhoneNumberType](_io_.md#const-e164phonenumbertype) +* [GetAttestationRequestType](_io_.md#const-getattestationrequesttype) +* [JSONStringType](_io_.md#const-jsonstringtype) +* [PublicKeyType](_io_.md#const-publickeytype) +* [SaltType](_io_.md#const-salttype) +* [SignatureType](_io_.md#const-signaturetype) +* [UrlType](_io_.md#const-urltype) + +## References + +### URL_REGEX + +• **URL_REGEX**: + +___ + +### isValidUrl + +• **isValidUrl**: + +## Type aliases + +### Address + +Ƭ **Address**: *t.TypeOf‹typeof AddressType›* + +*Defined in [io.ts:105](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L105)* + +___ + +### AttestationRequest + +Ƭ **AttestationRequest**: *t.TypeOf‹typeof AttestationRequestType›* + +*Defined in [io.ts:120](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L120)* + +___ + +### AttestationResponse + +Ƭ **AttestationResponse**: *t.TypeOf‹typeof AttestationResponseType›* + +*Defined in [io.ts:166](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L166)* + +___ + +### AttestationServiceTestRequest + +Ƭ **AttestationServiceTestRequest**: *t.TypeOf‹typeof AttestationServiceTestRequestType›* + +*Defined in [io.ts:102](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L102)* + +___ + +### E164Number + +Ƭ **E164Number**: *t.TypeOf‹typeof E164PhoneNumberType›* + +*Defined in [io.ts:106](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L106)* + +___ + +### GetAttestationRequest + +Ƭ **GetAttestationRequest**: *t.TypeOf‹typeof GetAttestationRequestType›* + +*Defined in [io.ts:132](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L132)* + +___ + +### Signature + +Ƭ **Signature**: *t.TypeOf‹typeof SignatureType›* + +*Defined in [io.ts:104](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L104)* + +## Variables + +### `Const` AddressType + +• **AddressType**: *Type‹string, string, unknown›* = new t.Type( + 'Address', + t.string.is, + (input, context) => + either.chain(t.string.validate(input, context), (stringValue) => + isValidAddress(stringValue) + ? t.success(toChecksumAddress(stringValue)) + : t.failure(stringValue, context, 'is not a valid address') + ), + String +) + +*Defined in [io.ts:51](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L51)* + +___ + +### `Const` AttestationRequestType + +• **AttestationRequestType**: *TypeC‹object›* = t.type({ + phoneNumber: E164PhoneNumberType, + account: AddressType, + issuer: AddressType, + // io-ts way of defining optional key-value pair + salt: t.union([t.undefined, SaltType]), + smsRetrieverAppSig: t.union([t.undefined, t.string]), + // if specified, the message sent will be short random number prefixed by this string + securityCodePrefix: t.union([t.undefined, t.string]), + language: t.union([t.undefined, t.string]), +}) + +*Defined in [io.ts:108](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L108)* + +___ + +### `Const` AttestationResponseType + +• **AttestationResponseType**: *TypeC‹object›* = t.type({ + // Always returned in 1.0.x + success: t.boolean, + + // Returned for errors in 1.0.x + error: t.union([t.undefined, t.string]), + + // Stringifyed JSON dict of dicts, mapping attempt to error info. + errors: t.union([t.undefined, t.string]), + + // Returned for successful send in 1.0.x + provider: t.union([t.undefined, t.string]), + + // New fields + identifier: t.union([t.undefined, t.string]), + account: t.union([t.undefined, AddressType]), + issuer: t.union([t.undefined, AddressType]), + status: t.union([t.undefined, t.string]), + attempt: t.union([t.undefined, t.number]), + countryCode: t.union([t.undefined, t.string]), + + // Time to receive eventual delivery/failure (inc retries) + duration: t.union([t.undefined, t.number]), + + // Only used by test endpoint to return randomly generated salt. + // Never return a user-supplied salt. + salt: t.union([t.undefined, t.string]), + + // only returned if the request supplied the correct security code + attestationCode: t.union([t.undefined, t.string]), +}) + +*Defined in [io.ts:134](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L134)* + +___ + +### `Const` AttestationServiceStatusResponseType + +• **AttestationServiceStatusResponseType**: *TypeC‹object›* = t.type({ + status: t.literal('ok'), + smsProviders: t.array(t.string), + blacklistedRegionCodes: t.union([t.array(t.string), t.undefined]), + accountAddress: AddressType, + signature: t.union([SignatureType, t.undefined]), + version: t.string, + latestBlock: t.number, + ageOfLatestBlock: t.number, + isNodeSyncing: t.boolean, + appSignature: t.string, + smsProvidersRandomized: t.boolean, + maxDeliveryAttempts: t.number, + maxRerequestMins: t.number, + twilioVerifySidProvided: t.boolean, +}) + +*Defined in [io.ts:79](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L79)* + +___ + +### `Const` AttestationServiceTestRequestType + +• **AttestationServiceTestRequestType**: *TypeC‹object›* = t.type({ + phoneNumber: E164PhoneNumberType, + message: t.string, + signature: SignatureType, + provider: t.union([t.string, t.undefined]), +}) + +*Defined in [io.ts:96](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L96)* + +___ + +### `Const` E164PhoneNumberType + +• **E164PhoneNumberType**: *Type‹string, string, unknown›* = new t.Type( + 'E164Number', + t.string.is, + (input, context) => + either.chain(t.string.validate(input, context), (stringValue) => + isE164NumberStrict(stringValue) + ? t.success(stringValue) + : t.failure(stringValue, context, 'is not a valid e164 number') + ), + String +) + +*Defined in [io.ts:39](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L39)* + +___ + +### `Const` GetAttestationRequestType + +• **GetAttestationRequestType**: *TypeC‹object›* = t.type({ + phoneNumber: E164PhoneNumberType, + account: AddressType, + issuer: AddressType, + // io-ts way of defining optional key-value pair + salt: t.union([t.undefined, SaltType]), + // if the value supplied matches the stored security code, the response will include the complete message + securityCode: t.union([t.undefined, t.string]), +}) + +*Defined in [io.ts:122](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L122)* + +___ + +### `Const` JSONStringType + +• **JSONStringType**: *Type‹string, string, unknown›* = new t.Type( + 'JSONString', + t.string.is, + (input, context) => + either.chain(t.string.validate(input, context), (stringValue) => { + try { + JSON.parse(stringValue) + return t.success(stringValue) + } catch (error) { + return t.failure(stringValue, context, 'can not be parsed as JSON') + } + }), + String +) + +*Defined in [io.ts:24](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L24)* + +___ + +### `Const` PublicKeyType + +• **PublicKeyType**: *Type‹string, string, unknown›* = new t.Type( + 'Public Key', + t.string.is, + (input, context) => + either.chain(t.string.validate(input, context), (stringValue) => + stringValue.startsWith('0x') && isValidPublic(Buffer.from(stringValue.slice(2), 'hex'), true) + ? t.success(toChecksumAddress(stringValue)) + : t.failure(stringValue, context, 'is not a valid public key') + ), + String +) + +*Defined in [io.ts:63](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L63)* + +___ + +### `Const` SaltType + +• **SaltType**: *StringC‹›* = t.string + +*Defined in [io.ts:77](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L77)* + +___ + +### `Const` SignatureType + +• **SignatureType**: *StringC‹›* = t.string + +*Defined in [io.ts:75](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L75)* + +___ + +### `Const` UrlType + +• **UrlType**: *Type‹string, string, unknown›* = new t.Type( + 'Url', + t.string.is, + (input, context) => + either.chain(t.string.validate(input, context), (stringValue) => + URL_REGEX.test(stringValue) + ? t.success(stringValue) + : t.failure(stringValue, context, 'is not a valid url') + ), + String +) + +*Defined in [io.ts:12](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/io.ts#L12)* diff --git a/packages/docs/developer-resources/utils/reference/modules/_phonenumbers_.md b/packages/docs/developer-resources/utils/reference/modules/_phonenumbers_.md new file mode 100644 index 00000000000..74cf4748f63 --- /dev/null +++ b/packages/docs/developer-resources/utils/reference/modules/_phonenumbers_.md @@ -0,0 +1,296 @@ +# Module: "phoneNumbers" + +## Index + +### References + +* [ParsedPhoneNumber](_phonenumbers_.md#parsedphonenumber) +* [anonymizedPhone](_phonenumbers_.md#anonymizedphone) +* [isE164Number](_phonenumbers_.md#ise164number) + +### Functions + +* [getCountryCode](_phonenumbers_.md#getcountrycode) +* [getCountryEmoji](_phonenumbers_.md#getcountryemoji) +* [getDisplayNumberInternational](_phonenumbers_.md#getdisplaynumberinternational) +* [getDisplayPhoneNumber](_phonenumbers_.md#getdisplayphonenumber) +* [getE164DisplayNumber](_phonenumbers_.md#gete164displaynumber) +* [getE164Number](_phonenumbers_.md#gete164number) +* [getExampleNumber](_phonenumbers_.md#getexamplenumber) +* [getPhoneHash](_phonenumbers_.md#const-getphonehash) +* [getRegionCode](_phonenumbers_.md#getregioncode) +* [getRegionCodeFromCountryCode](_phonenumbers_.md#getregioncodefromcountrycode) +* [isE164NumberStrict](_phonenumbers_.md#ise164numberstrict) +* [parsePhoneNumber](_phonenumbers_.md#parsephonenumber) + +### Object literals + +* [PhoneNumberUtils](_phonenumbers_.md#const-phonenumberutils) + +## References + +### ParsedPhoneNumber + +• **ParsedPhoneNumber**: + +___ + +### anonymizedPhone + +• **anonymizedPhone**: + +___ + +### isE164Number + +• **isE164Number**: + +## Functions + +### getCountryCode + +▸ **getCountryCode**(`e164PhoneNumber`: string): *undefined | null | number* + +*Defined in [phoneNumbers.ts:48](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L48)* + +**Parameters:** + +Name | Type | +------ | ------ | +`e164PhoneNumber` | string | + +**Returns:** *undefined | null | number* + +___ + +### getCountryEmoji + +▸ **getCountryEmoji**(`e164PhoneNumber`: string, `countryCodePossible?`: undefined | number, `regionCodePossible?`: undefined | string): *string* + +*Defined in [phoneNumbers.ts:27](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L27)* + +**Parameters:** + +Name | Type | +------ | ------ | +`e164PhoneNumber` | string | +`countryCodePossible?` | undefined | number | +`regionCodePossible?` | undefined | string | + +**Returns:** *string* + +___ + +### getDisplayNumberInternational + +▸ **getDisplayNumberInternational**(`e164PhoneNumber`: string): *string* + +*Defined in [phoneNumbers.ts:94](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L94)* + +**Parameters:** + +Name | Type | +------ | ------ | +`e164PhoneNumber` | string | + +**Returns:** *string* + +___ + +### getDisplayPhoneNumber + +▸ **getDisplayPhoneNumber**(`phoneNumber`: string, `defaultCountryCode`: string): *string* + +*Defined in [phoneNumbers.ts:84](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L84)* + +**Parameters:** + +Name | Type | +------ | ------ | +`phoneNumber` | string | +`defaultCountryCode` | string | + +**Returns:** *string* + +___ + +### getE164DisplayNumber + +▸ **getE164DisplayNumber**(`e164PhoneNumber`: string): *string* + +*Defined in [phoneNumbers.ts:105](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L105)* + +**Parameters:** + +Name | Type | +------ | ------ | +`e164PhoneNumber` | string | + +**Returns:** *string* + +___ + +### getE164Number + +▸ **getE164Number**(`phoneNumber`: string, `defaultCountryCode`: string): *null | string* + +*Defined in [phoneNumbers.ts:110](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L110)* + +**Parameters:** + +Name | Type | +------ | ------ | +`phoneNumber` | string | +`defaultCountryCode` | string | + +**Returns:** *null | string* + +___ + +### getExampleNumber + +▸ **getExampleNumber**(`regionCode`: string, `useOnlyZeroes`: boolean, `isInternational`: boolean): *undefined | string* + +*Defined in [phoneNumbers.ts:247](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L247)* + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`regionCode` | string | - | +`useOnlyZeroes` | boolean | true | +`isInternational` | boolean | false | + +**Returns:** *undefined | string* + +___ + +### `Const` getPhoneHash + +▸ **getPhoneHash**(`phoneNumber`: string, `salt?`: undefined | string): *string* + +*Defined in [phoneNumbers.ts:20](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L20)* + +**Parameters:** + +Name | Type | +------ | ------ | +`phoneNumber` | string | +`salt?` | undefined | string | + +**Returns:** *string* + +___ + +### getRegionCode + +▸ **getRegionCode**(`e164PhoneNumber`: string): *undefined | null | string* + +*Defined in [phoneNumbers.ts:60](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L60)* + +**Parameters:** + +Name | Type | +------ | ------ | +`e164PhoneNumber` | string | + +**Returns:** *undefined | null | string* + +___ + +### getRegionCodeFromCountryCode + +▸ **getRegionCodeFromCountryCode**(`countryCode`: string): *null | string* + +*Defined in [phoneNumbers.ts:72](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L72)* + +**Parameters:** + +Name | Type | +------ | ------ | +`countryCode` | string | + +**Returns:** *null | string* + +___ + +### isE164NumberStrict + +▸ **isE164NumberStrict**(`phoneNumber`: string): *boolean* + +*Defined in [phoneNumbers.ts:120](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L120)* + +**Parameters:** + +Name | Type | +------ | ------ | +`phoneNumber` | string | + +**Returns:** *boolean* + +___ + +### parsePhoneNumber + +▸ **parsePhoneNumber**(`phoneNumberRaw`: string, `defaultCountryCode?`: undefined | string): *ParsedPhoneNumber | null* + +*Defined in [phoneNumbers.ts:132](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L132)* + +**Parameters:** + +Name | Type | +------ | ------ | +`phoneNumberRaw` | string | +`defaultCountryCode?` | undefined | string | + +**Returns:** *ParsedPhoneNumber | null* + +## Object literals + +### `Const` PhoneNumberUtils + +### ▪ **PhoneNumberUtils**: *object* + +*Defined in [phoneNumbers.ts:275](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L275)* + +### getCountryCode + +• **getCountryCode**: *[getCountryCode](_phonenumbers_.md#getcountrycode)* + +*Defined in [phoneNumbers.ts:277](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L277)* + +### getDisplayPhoneNumber + +• **getDisplayPhoneNumber**: *[getDisplayPhoneNumber](_phonenumbers_.md#getdisplayphonenumber)* + +*Defined in [phoneNumbers.ts:279](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L279)* + +### getE164Number + +• **getE164Number**: *[getE164Number](_phonenumbers_.md#gete164number)* + +*Defined in [phoneNumbers.ts:280](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L280)* + +### getPhoneHash + +• **getPhoneHash**: *getPhoneHash* + +*Defined in [phoneNumbers.ts:276](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L276)* + +### getRegionCode + +• **getRegionCode**: *[getRegionCode](_phonenumbers_.md#getregioncode)* + +*Defined in [phoneNumbers.ts:278](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L278)* + +### isE164Number + +• **isE164Number**: *isE164Number* + +*Defined in [phoneNumbers.ts:281](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L281)* + +### parsePhoneNumber + +• **parsePhoneNumber**: *[parsePhoneNumber](_phonenumbers_.md#parsephonenumber)* + +*Defined in [phoneNumbers.ts:282](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/phone-utils/src/phoneNumbers.ts#L282)* diff --git a/packages/env-tests/package.json b/packages/env-tests/package.json index 146594009f5..f3c741413c3 100644 --- a/packages/env-tests/package.json +++ b/packages/env-tests/package.json @@ -5,11 +5,11 @@ "main": "index.js", "license": "MIT", "dependencies": { - "@celo/contractkit": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/base": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", - "@celo/identity": "1.3.3-dev", + "@celo/contractkit": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/base": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", + "@celo/identity": "1.5.1-dev", "bunyan": "1.8.12", "bunyan-gke-stackdriver": "0.1.2", "bunyan-debug-stream": "2.0.0", diff --git a/packages/env-tests/src/shared/attestation.ts b/packages/env-tests/src/shared/attestation.ts index f48092ab8e5..624b140dff4 100644 --- a/packages/env-tests/src/shared/attestation.ts +++ b/packages/env-tests/src/shared/attestation.ts @@ -8,9 +8,9 @@ import { } from '@celo/contractkit/lib/wrappers/Attestations' import { OdisUtils } from '@celo/identity' import { AuthSigner } from '@celo/identity/lib/odis/query' -import { AttestationUtils, PhoneNumberUtils } from '@celo/utils' +import { AttestationRequest, PhoneNumberUtils } from '@celo/phone-utils' +import { AttestationUtils } from '@celo/utils' import { concurrentMap, sleep } from '@celo/utils/lib/async' -import { AttestationRequest } from '@celo/utils/lib/io' import Logger from 'bunyan' import { sample } from 'lodash' import moment from 'moment' diff --git a/packages/faucet/package.json b/packages/faucet/package.json index 7b9c730d22b..993a7f5fd89 100644 --- a/packages/faucet/package.json +++ b/packages/faucet/package.json @@ -18,9 +18,10 @@ "build:rules": "firebase-bolt database-rules.bolt" }, "dependencies": { - "@celo/connect": "1.3.3", - "@celo/contractkit": "1.3.3", - "@celo/utils": "1.3.3", + "@celo/connect": "1.5.0", + "@celo/contractkit": "1.5.0", + "@celo/utils": "1.5.0", + "@celo/phone-utils": "1.5.0", "@firebase/app": "^0.5.3", "@google-cloud/logging": "^7.1.0", "debug": "^4.1.1", diff --git a/packages/faucet/src/database-helper.ts b/packages/faucet/src/database-helper.ts index 0f860747253..2c8980e7cfd 100644 --- a/packages/faucet/src/database-helper.ts +++ b/packages/faucet/src/database-helper.ts @@ -1,6 +1,6 @@ /* tslint:disable max-classes-per-file */ import { CeloTransactionObject } from '@celo/connect' -import { PhoneNumberUtils } from '@celo/utils' +import { PhoneNumberUtils } from '@celo/phone-utils' import { retryAsync, sleep } from '@celo/utils/lib/async' import { database } from 'firebase-admin' import { DataSnapshot } from 'firebase-functions/lib/providers/database' diff --git a/packages/metadata-crawler/package.json b/packages/metadata-crawler/package.json index f0d3f05e7ef..95ad2cbf067 100644 --- a/packages/metadata-crawler/package.json +++ b/packages/metadata-crawler/package.json @@ -9,9 +9,9 @@ "homepage": "https://github.com/celo-org/celo-monorepo/tree/master/packages/metadata-crawler", "repository": "https://github.com/celo-org/celo-monorepo/tree/master/packages/metadata-crawler", "dependencies": { - "@celo/connect": "1.3.3-dev", - "@celo/contractkit": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", + "@celo/connect": "1.5.1-dev", + "@celo/contractkit": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", "@types/pg": "^7.14.3", "bunyan": "1.8.12", "bunyan-gke-stackdriver": "0.1.2", diff --git a/packages/phone-number-privacy/combiner/package.json b/packages/phone-number-privacy/combiner/package.json index 8f67c6d1caa..02ea4828e65 100644 --- a/packages/phone-number-privacy/combiner/package.json +++ b/packages/phone-number-privacy/combiner/package.json @@ -30,10 +30,10 @@ "db:migrate:make": "knex --migrations-directory ./migrations migrate:make -x ts" }, "dependencies": { - "@celo/contractkit": "1.3.3", - "@celo/identity": "1.3.3", + "@celo/contractkit": "1.5.0", + "@celo/identity": "1.5.0", "@celo/phone-number-privacy-common": "1.0.36-dev", - "@celo/utils": "1.3.3", + "@celo/utils": "1.5.0", "blind-threshold-bls": "https://github.com/celo-org/blind-threshold-bls-wasm#e1e2f8a", "elliptic": "^6.5.4", "firebase-admin": "^9.12.0", diff --git a/packages/phone-number-privacy/combiner/test/end-to-end/resources.ts b/packages/phone-number-privacy/combiner/test/end-to-end/resources.ts index c4c059489e9..b8bd2662deb 100644 --- a/packages/phone-number-privacy/combiner/test/end-to-end/resources.ts +++ b/packages/phone-number-privacy/combiner/test/end-to-end/resources.ts @@ -5,7 +5,7 @@ import { ServiceContext, WalletKeySigner, } from '@celo/identity/lib/odis/query' -import { PhoneNumberUtils } from '@celo/utils' +import { PhoneNumberUtils } from '@celo/phone-utils' import { ensureLeading0x, normalizeAddressWith0x, diff --git a/packages/phone-number-privacy/common/package.json b/packages/phone-number-privacy/common/package.json index df82116b1b3..eae4d5d5d88 100644 --- a/packages/phone-number-privacy/common/package.json +++ b/packages/phone-number-privacy/common/package.json @@ -18,10 +18,10 @@ "lib/**/*" ], "dependencies": { - "@celo/base": "1.3.3", - "@celo/contractkit": "1.3.3", - "@celo/identity": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", + "@celo/base": "1.5.0", + "@celo/contractkit": "1.5.0", + "@celo/identity": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", "bignumber.js": "^9.0.0", "blind-threshold-bls": "https://github.com/celo-org/blind-threshold-bls-wasm#e1e2f8a", "btoa": "1.2.1", @@ -34,7 +34,7 @@ "libphonenumber-js": "^1.9.11" }, "devDependencies": { - "@celo/wallet-local": "1.3.3-dev", + "@celo/wallet-local": "1.5.1-dev", "@types/btoa": "^1.2.3", "@types/bunyan": "1.8.4", "@types/elliptic": "^6.4.12", diff --git a/packages/phone-number-privacy/common/src/test/values.ts b/packages/phone-number-privacy/common/src/test/values.ts index 61e6e9e463f..dc51da2b34f 100644 --- a/packages/phone-number-privacy/common/src/test/values.ts +++ b/packages/phone-number-privacy/common/src/test/values.ts @@ -1,4 +1,4 @@ -import { PhoneNumberUtils } from '@celo/utils' +import { PhoneNumberUtils } from '@celo/phone-utils' import { normalizeAddressWith0x, privateKeyToAddress } from '@celo/utils/lib/address' import { getBlindedPhoneNumber } from './utils' diff --git a/packages/phone-number-privacy/monitor/package.json b/packages/phone-number-privacy/monitor/package.json index 9077f873701..9803a514315 100644 --- a/packages/phone-number-privacy/monitor/package.json +++ b/packages/phone-number-privacy/monitor/package.json @@ -21,11 +21,11 @@ "loadTest": "ts-node src/scripts/runLoadTest.ts" }, "dependencies": { - "@celo/contractkit": "1.3.3", - "@celo/identity": "1.3.3", - "@celo/wallet-local": "1.3.3", + "@celo/contractkit": "1.5.0", + "@celo/identity": "1.5.0", + "@celo/wallet-local": "1.5.0", "@celo/phone-number-privacy-common": "1.0.36-dev", - "@celo/utils": "1.3.3", + "@celo/utils": "1.5.0", "firebase-admin": "^8.10.0", "firebase-functions": "^3.6.0" }, diff --git a/packages/phone-number-privacy/signer/package.json b/packages/phone-number-privacy/signer/package.json index e00ea1eeda6..5ff36a102b2 100644 --- a/packages/phone-number-privacy/signer/package.json +++ b/packages/phone-number-privacy/signer/package.json @@ -19,12 +19,12 @@ "ssl:keygen": "./scripts/create-ssl-cert.sh" }, "dependencies": { - "@celo/base": "1.3.3", - "@celo/contractkit": "1.3.3", + "@celo/base": "1.5.0", + "@celo/contractkit": "1.5.0", "@celo/phone-number-privacy-common": "1.0.36-dev", - "@celo/identity": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/wallet-hsm-azure": "1.3.3", + "@celo/identity": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-hsm-azure": "1.5.0", "@google-cloud/secret-manager": "3.0.0", "@types/bunyan": "^1.8.6", "@types/elliptic": "^6.4.12", diff --git a/packages/protocol/package.json b/packages/protocol/package.json index 33dc0496cf3..e6d204a8a70 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -50,10 +50,10 @@ "@0x/sol-profiler": "^3.0.0", "@0x/sol-trace": "^2.0.16", "@0x/subproviders": "^5.0.0", - "@celo/base": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", + "@celo/base": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", "@celo/ganache-cli": "git+https://github.com/celo-org/ganache-cli.git#e933297", - "@celo/utils": "1.3.3-dev", + "@celo/utils": "1.5.1-dev", "@openzeppelin/upgrades": "^2.8.0", "bip39": "https://github.com/bitcoinjs/bip39#d8ea080a18b40f301d4e2219a2991cd2417e83c2", "bls12377js": "https://github.com/celo-org/bls12377js#cb38a4cfb643c778619d79b20ca3e5283a2122a6", diff --git a/packages/protocol/test/identity/attestations.ts b/packages/protocol/test/identity/attestations.ts index 158242e36d1..d10ebf5eedd 100644 --- a/packages/protocol/test/identity/attestations.ts +++ b/packages/protocol/test/identity/attestations.ts @@ -1,4 +1,5 @@ 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, @@ -13,7 +14,6 @@ import { } from '@celo/protocol/lib/test-utils' import { privateKeyToAddress } from '@celo/utils/lib/address' import { parseSolidityStringArray } from '@celo/utils/lib/parsing' -import { getPhoneHash } from '@celo/utils/lib/phoneNumbers' import BigNumber from 'bignumber.js' import { range, uniq } from 'lodash' import { diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 921e815390a..0a40af7adcd 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,11 +1,15 @@ # Changelog -All notable changes to the [Celo SDK](https://docs.celo.org/developer-guide/sdk-code-reference) will be documented in this file. +All notable changes to the [Celo SDK](https://docs.celo.org/developer-guide/sdk-code-reference) will be documented in this file. This package will follow the release process outlined [here](https://docs.celo.org/community/release-process). - ## Development (not published yet) -### **[1.2.3--dev]** + +### **[2.0.0-dev]** +Features + - Extract out heavy phone-utils into new package [#](https://github.com/celo-org/celo-monorepo/pull/8987) + +### **[1.5.1-dev]** Features - one-line summary - [#](link PR) @@ -15,9 +19,17 @@ Bug Fixes Other Changes - one-line summary - [#](link PR) - ## Published +### **[1.5.0]** +Features +- Adds cREAL support to contract kit [#9040](https://github.com/celo-org/celo-monorepo/pull/9040) + +### **[1.4.2]** +Bug Fixes +- Fixes wallet connect issue in @celo/wallet-walletconnect + + ### **[1.2.2]** -- 2021-07-08 Features - new package: JS keystore support [#8096](https://github.com/celo-org/celo-monorepo/pull/8096) diff --git a/packages/sdk/base/package.json b/packages/sdk/base/package.json index 201c96cfdd2..8414075a90a 100644 --- a/packages/sdk/base/package.json +++ b/packages/sdk/base/package.json @@ -1,6 +1,6 @@ { "name": "@celo/base", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Celo base common utils, no dependencies", "author": "Celo", "license": "Apache-2.0", diff --git a/packages/sdk/connect/package.json b/packages/sdk/connect/package.json index 9338d9a5e8b..8c2d463e91b 100644 --- a/packages/sdk/connect/package.json +++ b/packages/sdk/connect/package.json @@ -1,6 +1,6 @@ { "name": "@celo/connect", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Toolkit for connecting with the Celo network", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -23,7 +23,7 @@ "dependencies": { "@types/debug": "^4.1.5", "@types/utf8": "^2.1.6", - "@celo/utils": "1.3.3-dev", + "@celo/utils": "1.5.1-dev", "bignumber.js": "^9.0.0", "debug": "^4.1.1", "utf8": "3.0.0" diff --git a/packages/sdk/contractkit/package.json b/packages/sdk/contractkit/package.json index 515c5ce00b4..3b3e6cd2591 100644 --- a/packages/sdk/contractkit/package.json +++ b/packages/sdk/contractkit/package.json @@ -1,6 +1,6 @@ { "name": "@celo/contractkit", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Celo's ContractKit to interact with Celo network", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -27,10 +27,10 @@ "lint": "tslint -c tslint.json --project ." }, "dependencies": { - "@celo/base": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/wallet-local": "1.3.3-dev", + "@celo/base": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-local": "1.5.1-dev", "@types/debug": "^4.1.5", "bignumber.js": "^9.0.0", "cross-fetch": "^3.0.6", @@ -41,6 +41,7 @@ "web3": "1.3.6" }, "devDependencies": { + "@celo/phone-utils": "1.5.1-dev", "@celo/dev-utils": "0.0.1-dev", "@celo/flake-tracker": "0.0.1-dev", "@celo/ganache-cli": "git+https://github.com/celo-org/ganache-cli.git#21652da", diff --git a/packages/sdk/contractkit/src/identity/claims/attestation-service-url.ts b/packages/sdk/contractkit/src/identity/claims/attestation-service-url.ts index c8b14074cee..baed6a88f52 100644 --- a/packages/sdk/contractkit/src/identity/claims/attestation-service-url.ts +++ b/packages/sdk/contractkit/src/identity/claims/attestation-service-url.ts @@ -1,6 +1,7 @@ import { ensureLeading0x, eqAddress } from '@celo/base/lib/address' import { Address } from '@celo/connect' -import { AttestationServiceStatusResponseType, UrlType } from '@celo/utils/lib/io' +import { AttestationServiceStatusResponseType } from '@celo/phone-utils/lib/io' +import { UrlType } from '@celo/utils/lib/io' import { verifySignature } from '@celo/utils/lib/signatureUtils' import fetch from 'cross-fetch' import { randomBytes } from 'crypto' diff --git a/packages/sdk/contractkit/src/wrappers/Attestations.test.ts b/packages/sdk/contractkit/src/wrappers/Attestations.test.ts index d943409f349..fa0ba2d1b99 100644 --- a/packages/sdk/contractkit/src/wrappers/Attestations.test.ts +++ b/packages/sdk/contractkit/src/wrappers/Attestations.test.ts @@ -1,5 +1,5 @@ import { testWithGanache } from '@celo/dev-utils/lib/ganache-test' -import { PhoneNumberUtils } from '@celo/utils' +import { PhoneNumberUtils } from '@celo/phone-utils' import { newKitFromWeb3 } from '../kit' import { AttestationsWrapper, getSecurityCodePrefix } from './Attestations' diff --git a/packages/sdk/contractkit/src/wrappers/Attestations.ts b/packages/sdk/contractkit/src/wrappers/Attestations.ts index dd4fe4a60cb..eadfd1f38e6 100644 --- a/packages/sdk/contractkit/src/wrappers/Attestations.ts +++ b/packages/sdk/contractkit/src/wrappers/Attestations.ts @@ -4,8 +4,8 @@ import { notEmpty, zip3 } from '@celo/base/lib/collections' import { parseSolidityStringArray } from '@celo/base/lib/parsing' import { appendPath } from '@celo/base/lib/string' import { Address, toTransactionObject } from '@celo/connect' +import { AttestationRequest, GetAttestationRequest } from '@celo/phone-utils/lib/io' import { AttestationUtils, SignatureUtils } from '@celo/utils/lib' -import { AttestationRequest, GetAttestationRequest } from '@celo/utils/lib/io' import { attestationSecurityCode as buildSecurityCodeTypedData } from '@celo/utils/lib/typed-data-constructors' import BigNumber from 'bignumber.js' import fetch from 'cross-fetch' diff --git a/packages/sdk/dappkit/package.json b/packages/sdk/dappkit/package.json index 0d1f4fcb3aa..bd7653983d3 100644 --- a/packages/sdk/dappkit/package.json +++ b/packages/sdk/dappkit/package.json @@ -1,15 +1,15 @@ { "name": "@celo/dappkit", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "scripts": { "build": "tsc", "clean": "tsc -b . --clean", "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/connect": "1.3.3-dev", - "@celo/contractkit": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", + "@celo/connect": "1.5.1-dev", + "@celo/contractkit": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", "react-native": "^0.63.4" }, "devDependencies": { diff --git a/packages/sdk/explorer/package.json b/packages/sdk/explorer/package.json index c69167eb7c7..2e0a9330bc2 100644 --- a/packages/sdk/explorer/package.json +++ b/packages/sdk/explorer/package.json @@ -1,6 +1,6 @@ { "name": "@celo/explorer", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Celo's block explorer consumer", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -23,10 +23,10 @@ }, "dependencies": { "@types/debug": "^4.1.5", - "@celo/base": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", - "@celo/contractkit": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", + "@celo/base": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", + "@celo/contractkit": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", "debug": "^4.1.1" }, "devDependencies": { diff --git a/packages/sdk/governance/package.json b/packages/sdk/governance/package.json index 5043abbe7ca..cbd92f2d083 100644 --- a/packages/sdk/governance/package.json +++ b/packages/sdk/governance/package.json @@ -1,6 +1,6 @@ { "name": "@celo/governance", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Celo's governance proposals", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -21,11 +21,11 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/base": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", - "@celo/contractkit": "1.3.3-dev", - "@celo/explorer": "1.3.3-dev", + "@celo/base": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", + "@celo/contractkit": "1.5.1-dev", + "@celo/explorer": "1.5.1-dev", "@types/debug": "^4.1.5", "@types/inquirer": "^6.5.0", "@types/ethereumjs-util": "^5.2.0", diff --git a/packages/sdk/identity/package.json b/packages/sdk/identity/package.json index dd2bbd153a7..8cd5a6784fc 100644 --- a/packages/sdk/identity/package.json +++ b/packages/sdk/identity/package.json @@ -1,6 +1,6 @@ { "name": "@celo/identity", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Utilities for interacting with Celo's identity protocol", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -25,9 +25,10 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/base": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/contractkit": "1.3.3-dev", + "@celo/base": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/phone-utils": "1.5.1-dev", + "@celo/contractkit": "1.5.1-dev", "@types/debug": "^4.1.5", "bignumber.js": "^9.0.0", "blind-threshold-bls": "https://github.com/celo-org/blind-threshold-bls-wasm#e1e2f8a", @@ -39,7 +40,7 @@ }, "devDependencies": { "@celo/dev-utils": "0.0.1-dev", - "@celo/wallet-local": "1.3.3-dev", + "@celo/wallet-local": "1.5.1-dev", "fetch-mock": "9.10.4", "@types/elliptic": "^6.4.12", "@celo/flake-tracker": "0.0.1-dev", diff --git a/packages/sdk/identity/src/odis/matchmaking.ts b/packages/sdk/identity/src/odis/matchmaking.ts index 1bafd90dc25..8013f0f0f33 100644 --- a/packages/sdk/identity/src/odis/matchmaking.ts +++ b/packages/sdk/identity/src/odis/matchmaking.ts @@ -1,4 +1,4 @@ -import { E164Number } from '@celo/utils/lib/io' +import { E164Number } from '@celo/phone-utils/lib/io' import crypto from 'crypto' import debugFactory from 'debug' import { diff --git a/packages/sdk/keystores/package.json b/packages/sdk/keystores/package.json index 42284a2e8c3..3a7cd4ba5e3 100644 --- a/packages/sdk/keystores/package.json +++ b/packages/sdk/keystores/package.json @@ -1,6 +1,6 @@ { "name": "@celo/keystores", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "keystore implementation", "author": "Celo", "license": "Apache-2.0", @@ -20,8 +20,8 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/utils": "1.3.3-dev", - "@celo/wallet-local": "1.3.3-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-local": "1.5.1-dev", "@types/ethereumjs-util": "^5.2.0", "ethereumjs-wallet": "^1.0.1" }, diff --git a/packages/sdk/network-utils/package.json b/packages/sdk/network-utils/package.json index b7f86ff44ff..40548f6ad05 100644 --- a/packages/sdk/network-utils/package.json +++ b/packages/sdk/network-utils/package.json @@ -1,6 +1,6 @@ { "name": "@celo/network-utils", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Utilities for fetching static information about the Celo network", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/sdk/phone-utils/package.json b/packages/sdk/phone-utils/package.json index 96f11b716af..80c055f1521 100644 --- a/packages/sdk/phone-utils/package.json +++ b/packages/sdk/phone-utils/package.json @@ -1,6 +1,6 @@ { "name": "@celo/phone-utils", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Celo phone utils", "author": "Celo", "license": "Apache-2.0", @@ -20,8 +20,8 @@ "lib/**/*" ], "dependencies": { - "@celo/base": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", + "@celo/base": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", "@types/country-data": "^0.0.0", "@types/ethereumjs-util": "^5.2.0", "@types/google-libphonenumber": "^7.4.17", diff --git a/packages/sdk/phone-utils/scripts/linkdocs.ts b/packages/sdk/phone-utils/scripts/linkdocs.ts new file mode 100644 index 00000000000..961bf59b73a --- /dev/null +++ b/packages/sdk/phone-utils/scripts/linkdocs.ts @@ -0,0 +1,39 @@ +import { readFileSync, writeFileSync } from 'fs' +import { TypeDocOptionMap } from 'typedoc' + +const pkgName = process.argv.slice(2)[0] +if (!pkgName) { + console.error('No package name given.') + process.exit(1) +} +const indent = ' ' + +const config: Partial = JSON.parse(readFileSync('./typedoc.json').toString()) +const localSummaryPath = `${config.out!}/SUMMARY.md` +const localSummary = readFileSync(localSummaryPath).toString() + +const filePathPrefix = pkgName.indexOf('wallet') >= 0 ? '../../../docs/' : '../../docs/' +const localPathPrefix = config.out!.replace(filePathPrefix, '') + +const pathRegex = /\(.*.md\)/g +const modifiedLocalSummary = localSummary + .replace(pathRegex, (match) => `(${localPathPrefix}/${match.slice(1, -1)})`) + .replace(/\*/g, indent + '-') + +const globalSummaryPath = filePathPrefix + 'SUMMARY.md' +const globalSummary = readFileSync(globalSummaryPath).toString() + +// Adding the indent to the tag, otherwise the markdows has poor preview +const startTag = `${indent}` +const endTag = `${indent}` + +const modifiedGlobalSummary = + globalSummary.slice(0, globalSummary.search(startTag) + startTag.length) + + '\n' + + modifiedLocalSummary + + '\n' + + globalSummary.slice(globalSummary.search(endTag)) + +writeFileSync(globalSummaryPath, modifiedGlobalSummary) + +console.log(`${globalSummaryPath} updated with links to generated docs`) diff --git a/packages/sdk/phone-utils/typedoc.json b/packages/sdk/phone-utils/typedoc.json new file mode 100644 index 00000000000..9154db2bf8e --- /dev/null +++ b/packages/sdk/phone-utils/typedoc.json @@ -0,0 +1,13 @@ +{ + "mode": "modules", + "exclude": ["**/*+(index|.test).ts"], + "excludeNotExported": true, + "excludePrivate": true, + "excludeProtected": true, + "includeDeclarations": false, + "ignoreCompilerErrors": true, + "hideGenerator": "true", + "theme": "gitbook", + "out": "../../docs/developer-resources/utils/reference", + "gitRevision": "master" + } \ No newline at end of file diff --git a/packages/sdk/transactions-uri/package.json b/packages/sdk/transactions-uri/package.json index ddf91e0a4b8..25fb1be115d 100644 --- a/packages/sdk/transactions-uri/package.json +++ b/packages/sdk/transactions-uri/package.json @@ -1,6 +1,6 @@ { "name": "@celo/transactions-uri", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Celo's transactions uri generation", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -26,15 +26,15 @@ "dependencies": { "@types/debug": "^4.1.5", "@types/qrcode": "^1.3.4", - "@celo/base": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", + "@celo/base": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", "bn.js": "4.11.8", "qrcode": "^1.4.4", "web3-eth-abi": "1.3.6" }, "devDependencies": { "@celo/dev-utils": "0.0.1-dev", - "@celo/contractkit": "1.3.3-dev", + "@celo/contractkit": "1.5.1-dev", "dotenv": "^8.2.0", "@celo/flake-tracker": "0.0.1-dev" }, diff --git a/packages/sdk/utils/package.json b/packages/sdk/utils/package.json index 5133c7002b3..3f9f21ed01b 100644 --- a/packages/sdk/utils/package.json +++ b/packages/sdk/utils/package.json @@ -1,6 +1,6 @@ { "name": "@celo/utils", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Celo common utils", "author": "Celo", "license": "Apache-2.0", @@ -19,12 +19,9 @@ "lib/**/*" ], "dependencies": { - "@celo/base": "1.3.3-dev", - "@types/country-data": "^0.0.0", + "@celo/base": "1.5.1-dev", "@types/elliptic": "^6.4.9", "@types/ethereumjs-util": "^5.2.0", - "@types/google-libphonenumber": "^7.4.17", - "@types/lodash": "^4.14.170", "@types/node": "^10.12.18", "@types/randombytes": "^2.0.0", "bigi": "^1.1.0", @@ -34,15 +31,11 @@ "bls12377js": "https://github.com/celo-org/bls12377js#cb38a4cfb643c778619d79b20ca3e5283a2122a6", "bn.js": "4.11.8", "buffer-reverse": "^1.0.1", - "country-data": "^0.0.31", "crypto-js": "^3.1.9-1", "elliptic": "^6.5.4", "ethereumjs-util": "^5.2.0", - "fp-ts": "2.1.1", - "google-libphonenumber": "^3.2.15", "io-ts": "2.0.1", "keccak256": "^1.0.0", - "lodash": "^4.17.21", "numeral": "^2.0.6", "web3-eth-abi": "1.3.6", "web3-utils": "1.3.6" @@ -55,4 +48,4 @@ "elliptic/bn.js": "4.11.8", "web3-utils/bn.js": "4.11.8" } -} \ No newline at end of file +} diff --git a/packages/sdk/utils/src/countries.test.ts b/packages/sdk/utils/src/countries.test.ts deleted file mode 100644 index 4ccecf71660..00000000000 --- a/packages/sdk/utils/src/countries.test.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { Countries } from './countries' - -const countries = new Countries('en-us') - -describe('countries', () => { - describe('getCountryMap', () => { - test('Valid Country', () => { - const country = countries.getCountryByCodeAlpha2('US') - - expect(country).toBeDefined() - - // check these to make tsc happy - if (country && country.names) { - expect(country.names['en-us']).toEqual('United States') - } - }) - - test('Invalid Country', () => { - // canary islands, no calling code - const invalidCountry = countries.getCountryByCodeAlpha2('IC') - - expect(invalidCountry).toBeUndefined() - }) - }) - describe('getCountry', () => { - test('has all country data', () => { - const country = countries.getCountry('taiwan') - - expect(country).toMatchInlineSnapshot(` - Object { - "alpha2": "TW", - "alpha3": "TWN", - "countryCallingCode": "+886", - "countryCallingCodes": Array [ - "+886", - ], - "countryPhonePlaceholder": Object { - "national": "00 0000 0000", - }, - "currencies": Array [ - "TWD", - ], - "displayName": "Taiwan", - "displayNameNoDiacritics": "taiwan", - "emoji": "🇹🇼", - "ioc": "TPE", - "languages": Array [ - "zho", - ], - "name": "Taiwan", - "names": Object { - "en-us": "Taiwan", - "es-419": "Taiwán", - }, - "status": "assigned", - } - `) - }) - }) - - describe('Country Search', () => { - test('finds an exact match', () => { - const results = countries.getFilteredCountries('taiwan') - - expect(results).toMatchInlineSnapshot(` - Array [ - Object { - "alpha2": "TW", - "alpha3": "TWN", - "countryCallingCode": "+886", - "countryCallingCodes": Array [ - "+886", - ], - "countryPhonePlaceholder": Object { - "national": "00 0000 0000", - }, - "currencies": Array [ - "TWD", - ], - "displayName": "Taiwan", - "displayNameNoDiacritics": "taiwan", - "emoji": "🇹🇼", - "ioc": "TPE", - "languages": Array [ - "zho", - ], - "name": "Taiwan", - "names": Object { - "en-us": "Taiwan", - "es-419": "Taiwán", - }, - "status": "assigned", - }, - ] - `) - }) - - test('finds countries by calling code', () => { - const results = countries.getFilteredCountries('49') - - expect(results).toMatchInlineSnapshot(` - Array [ - Object { - "alpha2": "DE", - "alpha3": "DEU", - "countryCallingCode": "+49", - "countryCallingCodes": Array [ - "+49", - ], - "countryPhonePlaceholder": Object { - "national": "000 000000", - }, - "currencies": Array [ - "EUR", - ], - "displayName": "Germany", - "displayNameNoDiacritics": "germany", - "emoji": "🇩🇪", - "ioc": "GER", - "languages": Array [ - "deu", - ], - "name": "Germany", - "names": Object { - "en-us": "Germany", - "es-419": "Alemania", - }, - "status": "assigned", - }, - ] - `) - }) - - test('finds countries by ISO code', () => { - const results = countries.getFilteredCountries('gb') - - expect(results).toMatchInlineSnapshot(` - Array [ - Object { - "alpha2": "GB", - "alpha3": "GBR", - "countryCallingCode": "+44", - "countryCallingCodes": Array [ - "+44", - ], - "countryPhonePlaceholder": Object { - "national": "0000 000 0000", - }, - "currencies": Array [ - "GBP", - ], - "displayName": "United Kingdom", - "displayNameNoDiacritics": "united kingdom", - "emoji": "🇬🇧", - "ioc": "GBR", - "languages": Array [ - "eng", - "cor", - "gle", - "gla", - "cym", - ], - "name": "United Kingdom", - "names": Object { - "en-us": "United Kingdom", - "es-419": "Reino Unido", - }, - "status": "assigned", - }, - ] - `) - }) - }) -}) diff --git a/packages/sdk/utils/src/countries.ts b/packages/sdk/utils/src/countries.ts deleted file mode 100644 index 98d88b361ef..00000000000 --- a/packages/sdk/utils/src/countries.ts +++ /dev/null @@ -1,122 +0,0 @@ -import countryData from 'country-data' -// more countries @ https://github.com/umpirsky/country-list -import esData from './data/countries/es/country.json' -import { getExampleNumber } from './phoneNumbers' - -interface CountryNames { - [name: string]: string -} - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export interface LocalizedCountry extends Omit { - displayName: string - displayNameNoDiacritics: string - names: CountryNames - countryPhonePlaceholder: { - national?: string | undefined - international?: string | undefined - } - countryCallingCode: string -} - -const removeDiacritics = (word: string) => - word && - word - .normalize('NFD') - .replace(/[\u0300-\u036f]/g, '') - .toLowerCase() - .trim() - -const matchCountry = (country: LocalizedCountry, query: string) => { - return ( - country.displayNameNoDiacritics.startsWith(query) || - country.countryCallingCode.startsWith('+' + query) || - country.alpha3.startsWith(query.toUpperCase()) - ) -} - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export class Countries { - language: string - countryMap: Map - localizedCountries: LocalizedCountry[] - - constructor(language?: string) { - // fallback to 'en-us' - this.language = language ? language.toLocaleLowerCase() : 'en-us' - this.countryMap = new Map() - this.localizedCountries = Array() - this.assignCountries() - } - - getCountry(countryName?: string | null): LocalizedCountry | undefined { - if (!countryName) { - return undefined - } - - const query = removeDiacritics(countryName) - - return this.localizedCountries.find((country) => country.displayNameNoDiacritics === query) - } - - getCountryByCodeAlpha2(countryCode: string): LocalizedCountry | undefined { - return this.countryMap.get(countryCode) - } - - getFilteredCountries(query: string): LocalizedCountry[] { - query = removeDiacritics(query) - // Return full list if the query is empty - if (!query || !query.length) { - return this.localizedCountries - } - - return this.localizedCountries.filter((country) => matchCountry(country, query)) - } - - private assignCountries() { - // add other languages to country data - this.localizedCountries = countryData.callingCountries.all - .map((country: countryData.Country) => { - // this is assuming these two are the only cases, in i18n.ts seems like there - // are fallback languages 'es-US' and 'es-LA' that are not covered - const names: CountryNames = { - 'en-us': country.name, - // @ts-ignore - 'es-419': esData[country.alpha2], - } - - const displayName = names[this.language] || country.name - - // We only use the first calling code, others are irrelevant in the current dataset. - // Also some of them have a non standard calling code - // for instance: 'Antigua And Barbuda' has '+1 268', where only '+1' is expected - // so we fix this here - const countryCallingCode = country.countryCallingCodes[0].split(' ')[0] - - const localizedCountry = { - names, - displayName, - displayNameNoDiacritics: removeDiacritics(displayName), - countryPhonePlaceholder: { - national: getExampleNumber(countryCallingCode), - // Not needed right now - // international: getExampleNumber(countryCallingCode, true, true), - }, - countryCallingCode, - ...country, - // Use default emoji when flag emoji is missing - emoji: country.emoji || '🏳', - } - - // use ISO 3166-1 alpha2 code as country id - this.countryMap.set(country.alpha2.toUpperCase(), localizedCountry) - - return localizedCountry - }) - .sort((a, b) => a.displayName.localeCompare(b.displayName)) - } -} diff --git a/packages/sdk/utils/src/data/countries/es/country.json b/packages/sdk/utils/src/data/countries/es/country.json deleted file mode 100644 index ee1e3cecc0c..00000000000 --- a/packages/sdk/utils/src/data/countries/es/country.json +++ /dev/null @@ -1 +0,0 @@ -{"AF":"Afganist\u00e1n","AL":"Albania","DE":"Alemania","AD":"Andorra","AO":"Angola","AI":"Anguila","AQ":"Ant\u00e1rtida","AG":"Antigua y Barbuda","SA":"Arabia Saud\u00ed","DZ":"Argelia","AR":"Argentina","AM":"Armenia","AW":"Aruba","AU":"Australia","AT":"Austria","AZ":"Azerbaiy\u00e1n","BS":"Bahamas","BD":"Banglad\u00e9s","BB":"Barbados","BH":"Bar\u00e9in","BE":"B\u00e9lgica","BZ":"Belice","BJ":"Ben\u00edn","BM":"Bermudas","BY":"Bielorrusia","BO":"Bolivia","BA":"Bosnia y Herzegovina","BW":"Botsuana","BR":"Brasil","BN":"Brun\u00e9i","BG":"Bulgaria","BF":"Burkina Faso","BI":"Burundi","BT":"But\u00e1n","CV":"Cabo Verde","KH":"Camboya","CM":"Camer\u00fan","CA":"Canad\u00e1","IC":"Canarias","BQ":"Caribe neerland\u00e9s","QA":"Catar","EA":"Ceuta y Melilla","TD":"Chad","CZ":"Chequia","CL":"Chile","CN":"China","CY":"Chipre","VA":"Ciudad del Vaticano","CO":"Colombia","KM":"Comoras","CG":"Congo","KP":"Corea del Norte","KR":"Corea del Sur","CR":"Costa Rica","CI":"C\u00f4te d\u2019Ivoire","HR":"Croacia","CU":"Cuba","CW":"Curazao","DG":"Diego Garc\u00eda","DK":"Dinamarca","DM":"Dominica","EC":"Ecuador","EG":"Egipto","SV":"El Salvador","AE":"Emiratos \u00c1rabes Unidos","ER":"Eritrea","SK":"Eslovaquia","SI":"Eslovenia","ES":"Espa\u00f1a","US":"Estados Unidos","EE":"Estonia","SZ":"Esuatini","ET":"Etiop\u00eda","PH":"Filipinas","FI":"Finlandia","FJ":"Fiyi","FR":"Francia","GA":"Gab\u00f3n","GM":"Gambia","GE":"Georgia","GH":"Ghana","GI":"Gibraltar","GD":"Granada","GR":"Grecia","GL":"Groenlandia","GP":"Guadalupe","GU":"Guam","GT":"Guatemala","GF":"Guayana Francesa","GG":"Guernsey","GN":"Guinea","GQ":"Guinea Ecuatorial","GW":"Guinea-Bis\u00e1u","GY":"Guyana","HT":"Hait\u00ed","HN":"Honduras","HU":"Hungr\u00eda","IN":"India","ID":"Indonesia","IQ":"Irak","IR":"Ir\u00e1n","IE":"Irlanda","AC":"Isla de la Ascensi\u00f3n","IM":"Isla de Man","CX":"Isla de Navidad","NF":"Isla Norfolk","IS":"Islandia","AX":"Islas \u00c5land","KY":"Islas Caim\u00e1n","CC":"Islas Cocos","CK":"Islas Cook","FO":"Islas Feroe","GS":"Islas Georgia del Sur y Sandwich del Sur","FK":"Islas Malvinas","MP":"Islas Marianas del Norte","MH":"Islas Marshall","UM":"Islas menores alejadas de EE. UU.","PN":"Islas Pitcairn","SB":"Islas Salom\u00f3n","TC":"Islas Turcas y Caicos","VG":"Islas V\u00edrgenes Brit\u00e1nicas","VI":"Islas V\u00edrgenes de EE. UU.","IL":"Israel","IT":"Italia","JM":"Jamaica","JP":"Jap\u00f3n","JE":"Jersey","JO":"Jordania","KZ":"Kazajist\u00e1n","KE":"Kenia","KG":"Kirguist\u00e1n","KI":"Kiribati","XK":"Kosovo","KW":"Kuwait","LA":"Laos","LS":"Lesoto","LV":"Letonia","LB":"L\u00edbano","LR":"Liberia","LY":"Libia","LI":"Liechtenstein","LT":"Lituania","LU":"Luxemburgo","MK":"Macedonia","MG":"Madagascar","MY":"Malasia","MW":"Malaui","MV":"Maldivas","ML":"Mali","MT":"Malta","MA":"Marruecos","MQ":"Martinica","MU":"Mauricio","MR":"Mauritania","YT":"Mayotte","MX":"M\u00e9xico","FM":"Micronesia","MD":"Moldavia","MC":"M\u00f3naco","MN":"Mongolia","ME":"Montenegro","MS":"Montserrat","MZ":"Mozambique","MM":"Myanmar (Birmania)","NA":"Namibia","NR":"Nauru","NP":"Nepal","NI":"Nicaragua","NE":"N\u00edger","NG":"Nigeria","NU":"Niue","NO":"Noruega","NC":"Nueva Caledonia","NZ":"Nueva Zelanda","OM":"Om\u00e1n","NL":"Pa\u00edses Bajos","PK":"Pakist\u00e1n","PW":"Palaos","PA":"Panam\u00e1","PG":"Pap\u00faa Nueva Guinea","PY":"Paraguay","PE":"Per\u00fa","PF":"Polinesia Francesa","PL":"Polonia","PT":"Portugal","XA":"Pseudo-Accents","XB":"Pseudo-Bidi","PR":"Puerto Rico","HK":"RAE de Hong Kong (China)","MO":"RAE de Macao (China)","GB":"Reino Unido","CF":"Rep\u00fablica Centroafricana","CD":"Rep\u00fablica Democr\u00e1tica del Congo","DO":"Rep\u00fablica Dominicana","RE":"Reuni\u00f3n","RW":"Ruanda","RO":"Ruman\u00eda","RU":"Rusia","EH":"S\u00e1hara Occidental","WS":"Samoa","AS":"Samoa Americana","BL":"San Bartolom\u00e9","KN":"San Crist\u00f3bal y Nieves","SM":"San Marino","MF":"San Mart\u00edn","PM":"San Pedro y Miquel\u00f3n","VC":"San Vicente y las Granadinas","SH":"Santa Elena","LC":"Santa Luc\u00eda","ST":"Santo Tom\u00e9 y Pr\u00edncipe","SN":"Senegal","RS":"Serbia","SC":"Seychelles","SL":"Sierra Leona","SG":"Singapur","SX":"Sint Maarten","SY":"Siria","SO":"Somalia","LK":"Sri Lanka","ZA":"Sud\u00e1frica","SD":"Sud\u00e1n","SS":"Sud\u00e1n del Sur","SE":"Suecia","CH":"Suiza","SR":"Surinam","SJ":"Svalbard y Jan Mayen","TH":"Tailandia","TW":"Taiw\u00e1n","TZ":"Tanzania","TJ":"Tayikist\u00e1n","IO":"Territorio Brit\u00e1nico del Oc\u00e9ano \u00cdndico","TF":"Territorios Australes Franceses","PS":"Territorios Palestinos","TL":"Timor-Leste","TG":"Togo","TK":"Tokelau","TO":"Tonga","TT":"Trinidad y Tobago","TA":"Trist\u00e1n de Acu\u00f1a","TN":"T\u00fanez","TM":"Turkmenist\u00e1n","TR":"Turqu\u00eda","TV":"Tuvalu","UA":"Ucrania","UG":"Uganda","UY":"Uruguay","UZ":"Uzbekist\u00e1n","VU":"Vanuatu","VE":"Venezuela","VN":"Vietnam","WF":"Wallis y Futuna","YE":"Yemen","DJ":"Yibuti","ZM":"Zambia","ZW":"Zimbabue"} \ No newline at end of file diff --git a/packages/sdk/utils/src/index.ts b/packages/sdk/utils/src/index.ts index 2b08d0cb14b..5446a8555ca 100644 --- a/packages/sdk/utils/src/index.ts +++ b/packages/sdk/utils/src/index.ts @@ -4,13 +4,11 @@ export { AccountUtils } from './account' export { AttestationUtils } from './attestations' export { CommentEncryptionUtils } from './commentEncryption' export * from './contacts' -export * from './countries' export * from './currencies' export * from './dappkit' export { DataEncryptionKeyUtils } from './dataEncryptionKey' export { ECIES } from './ecies' export { IstanbulUtils } from './istanbul' -export { PhoneNumberUtils } from './phoneNumbers' export { SignatureUtils } from './signatureUtils' export { StringUtils } from './string' export { AddressUtils } diff --git a/packages/sdk/utils/src/inputValidation.test.ts b/packages/sdk/utils/src/inputValidation.test.ts deleted file mode 100644 index e73afc428ae..00000000000 --- a/packages/sdk/utils/src/inputValidation.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { BaseProps, validateInput, ValidatorKind } from './inputValidation' - -describe('inputValidation', () => { - function validateFunction( - itStr: string, - inputs: string[], - validator: ValidatorKind, - expected: string, - props?: BaseProps - ) { - it(itStr, () => - inputs.forEach((input) => { - const result = validateInput(input, { validator, countryCallingCode: '1', ...props }) - expect(result).toEqual(expected) - }) - ) - } - - const numbers = ['bu1.23n', '1.2.3', '1.23', '1.2.-_[`/,zx3.....', '1.b.23'] - - validateFunction('validates integers', numbers, ValidatorKind.Integer, '123') - - validateFunction('validates decimals', numbers, ValidatorKind.Decimal, '1.23') - - validateFunction( - 'allows comma decimals', - numbers.map((val) => val.replace('.', ',')), - ValidatorKind.Decimal, - '1,23', - { decimalSeparator: ',' } - ) - - validateFunction( - 'validates phone numbers', - [ - '4023939889', - '(402)3939889', - '(402)393-9889', - '402bun393._=988-9', - '402 393 9889', - '(4023) 9-39-88-9', - '4-0-2-3-9-3-9-8-8-9', // phone-kebab - ], - ValidatorKind.Phone, - '(402) 393-9889' - ) -}) diff --git a/packages/sdk/utils/src/inputValidation.ts b/packages/sdk/utils/src/inputValidation.ts index 45440b79014..1eaaca746f3 100644 --- a/packages/sdk/utils/src/inputValidation.ts +++ b/packages/sdk/utils/src/inputValidation.ts @@ -1,6 +1,3 @@ -import { BaseProps, validateDecimal, validateInteger } from '@celo/base/lib/inputValidation' -import { getDisplayPhoneNumber } from './phoneNumbers' - // Exports moved to @celo/base, forwarding them // here for backwards compatibility export { @@ -9,41 +6,3 @@ export { validateInteger, ValidatorKind, } from '@celo/base/lib/inputValidation' - -export function validatePhone(input: string, countryCallingCode?: string): string { - input = input.replace(/[^0-9()\- ]/g, '') - - if (!countryCallingCode) { - return input - } - - const displayNumber = getDisplayPhoneNumber(input, countryCallingCode) - - if (!displayNumber) { - return input - } - - return displayNumber -} - -export function validateInput(input: string, props: BaseProps): string { - if (!props.validator && !props.customValidator) { - return input - } - - switch (props.validator) { - case 'decimal': - return validateDecimal(input, props.decimalSeparator) - case 'integer': - return validateInteger(input) - case 'phone': - return validatePhone(input, props.countryCallingCode) - case 'custom': { - if (props.customValidator) { - return props.customValidator(input) - } - } - } - - throw new Error('Unhandled input validator') -} diff --git a/packages/sdk/utils/src/io.ts b/packages/sdk/utils/src/io.ts index f8c18f3f988..128ffb8bad6 100644 --- a/packages/sdk/utils/src/io.ts +++ b/packages/sdk/utils/src/io.ts @@ -3,7 +3,6 @@ import { isValidPublic, toChecksumAddress } from 'ethereumjs-util' import { either } from 'fp-ts/lib/Either' import * as t from 'io-ts' import { isValidAddress } from './address' -import { isE164NumberStrict } from './phoneNumbers' // Exports moved to @celo/base, forwarding them // here for backwards compatibility @@ -36,21 +35,6 @@ export const JSONStringType = new t.Type( String ) -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export const E164PhoneNumberType = new t.Type( - 'E164Number', - t.string.is, - (input, context) => - either.chain(t.string.validate(input, context), (stringValue) => - isE164NumberStrict(stringValue) - ? t.success(stringValue) - : t.failure(stringValue, context, 'is not a valid e164 number') - ), - String -) - export const AddressType = new t.Type( 'Address', t.string.is, @@ -76,120 +60,7 @@ export const PublicKeyType = new t.Type( ) export const SignatureType = t.string - export const SaltType = t.string -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export const AttestationServiceStatusResponseType = t.type({ - status: t.literal('ok'), - smsProviders: t.array(t.string), - blacklistedRegionCodes: t.union([t.array(t.string), t.undefined]), - accountAddress: AddressType, - signature: t.union([SignatureType, t.undefined]), - version: t.string, - latestBlock: t.number, - ageOfLatestBlock: t.number, - isNodeSyncing: t.boolean, - appSignature: t.string, - smsProvidersRandomized: t.boolean, - maxDeliveryAttempts: t.number, - maxRerequestMins: t.number, - twilioVerifySidProvided: t.boolean, -}) - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export const AttestationServiceTestRequestType = t.type({ - phoneNumber: E164PhoneNumberType, - message: t.string, - signature: SignatureType, - provider: t.union([t.string, t.undefined]), -}) - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export type AttestationServiceTestRequest = t.TypeOf - export type Signature = t.TypeOf export type Address = t.TypeOf - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export type E164Number = t.TypeOf - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export const AttestationRequestType = t.type({ - phoneNumber: E164PhoneNumberType, - account: AddressType, - issuer: AddressType, - // io-ts way of defining optional key-value pair - salt: t.union([t.undefined, SaltType]), - smsRetrieverAppSig: t.union([t.undefined, t.string]), - // if specified, the message sent will be short random number prefixed by this string - securityCodePrefix: t.union([t.undefined, t.string]), - language: t.union([t.undefined, t.string]), -}) - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export type AttestationRequest = t.TypeOf - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export const GetAttestationRequestType = t.type({ - phoneNumber: E164PhoneNumberType, - account: AddressType, - issuer: AddressType, - // io-ts way of defining optional key-value pair - salt: t.union([t.undefined, SaltType]), - // if the value supplied matches the stored security code, the response will include the complete message - securityCode: t.union([t.undefined, t.string]), -}) - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export type GetAttestationRequest = t.TypeOf - -export const AttestationResponseType = t.type({ - // Always returned in 1.0.x - success: t.boolean, - - // Returned for errors in 1.0.x - error: t.union([t.undefined, t.string]), - - // Stringifyed JSON dict of dicts, mapping attempt to error info. - errors: t.union([t.undefined, t.string]), - - // Returned for successful send in 1.0.x - provider: t.union([t.undefined, t.string]), - - // New fields - identifier: t.union([t.undefined, t.string]), - account: t.union([t.undefined, AddressType]), - issuer: t.union([t.undefined, AddressType]), - status: t.union([t.undefined, t.string]), - attempt: t.union([t.undefined, t.number]), - countryCode: t.union([t.undefined, t.string]), - - // Time to receive eventual delivery/failure (inc retries) - duration: t.union([t.undefined, t.number]), - - // Only used by test endpoint to return randomly generated salt. - // Never return a user-supplied salt. - salt: t.union([t.undefined, t.string]), - - // only returned if the request supplied the correct security code - attestationCode: t.union([t.undefined, t.string]), -}) - -export type AttestationResponse = t.TypeOf diff --git a/packages/sdk/utils/src/phoneNumbers.test.ts b/packages/sdk/utils/src/phoneNumbers.test.ts deleted file mode 100644 index bc69d8e4273..00000000000 --- a/packages/sdk/utils/src/phoneNumbers.test.ts +++ /dev/null @@ -1,306 +0,0 @@ -import { - getCountryCode, - getDisplayPhoneNumber, - getE164Number, - getExampleNumber, - getPhoneHash, - getRegionCode, - getRegionCodeFromCountryCode, - isE164Number, - parsePhoneNumber, -} from './phoneNumbers' - -const COUNTRY_CODES = { - US: '+1', - DE: '+49', - AR: '+54', - MX: '+52', - LR: '+231', -} - -const TEST_PHONE_NUMBERS = { - VALID_US_1: '6282287826', - VALID_US_2: '(628) 228-7826', - VALID_US_3: '+16282287826', - VALID_US_4: '16282287826', - VALID_DE_1: '015229355106', - VALID_DE_2: '01522 (935)-5106', - VALID_DE_3: '+49 01522 935 5106', - VALID_AR_1: '091126431111', - VALID_AR_2: '(911) 2643-1111', - VALID_AR_3: '+5411 2643-1111', - VALID_AR_4: '9 11 2643 1111', - VALID_MX_1: '33 1234-5678', - VALID_MX_2: '1 33 1234-5678', - VALID_MX_3: '+52 1 33 1234-5678', - VALID_LR: '881551952', - FORMATTED_AR: '+5491126431111', - FORMATTED_MX: '+523312345678', - FORMATTED_LR: '+231881551952', - DISPLAY_AR: '9 11 2643-1111', - DISPLAY_MX: '33 1234 5678', - DISPLAY_LR: '88 155 1952', - INVALID_EMPTY: '', - TOO_SHORT: '123', - VALID_E164: '+141555544444', -} - -describe('Phone number formatting and utilities', () => { - describe('Phone hashing', () => { - it('Hashes an valid number without a salt', () => { - expect(getPhoneHash(TEST_PHONE_NUMBERS.VALID_E164)).toBe( - '0x483128504c69591aed5751690805ba9aad6c390644421dc189f6dbb6e085aadf' - ) - }) - it('Hashes an valid number with a salt', () => { - expect(getPhoneHash(TEST_PHONE_NUMBERS.VALID_E164, 'abcdefg')).toBe( - '0xf08257f6b126597dbd090fecf4f5106cfb59c98ef997644cef16f9349464810c' - ) - }) - it('Throws for an invalid number', () => { - try { - getPhoneHash(TEST_PHONE_NUMBERS.VALID_US_1) - fail('expected an error') - } catch (error) { - // Error expected - } - }) - }) - - describe('E164 formatting', () => { - it('Invalid empty', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.INVALID_EMPTY, COUNTRY_CODES.US)).toBe(null) - }) - it('Format US phone simple, no country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_US_1, COUNTRY_CODES.US)).toBe('+16282287826') - }) - it('Format US phone messy, no country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_US_2, COUNTRY_CODES.US)).toBe('+16282287826') - }) - it('Format US phone simple, with country code and wrong region', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_US_3, COUNTRY_CODES.AR)).toBe('+16282287826') - }) - it('Format US phone simple, with country code no plus', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_US_4, COUNTRY_CODES.US)).toBe('+16282287826') - }) - it('Format DE phone simple, no country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_DE_1, COUNTRY_CODES.DE)).toBe('+4915229355106') - }) - it('Format DE phone messy, no country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_DE_2, COUNTRY_CODES.DE)).toBe('+4915229355106') - }) - it('Format DE phone messy, wrong country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_DE_2, COUNTRY_CODES.US)).toBe(null) - }) - it('Format DE phone with country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_DE_3, COUNTRY_CODES.DE)).toBe('+4915229355106') - }) - it('Format AR phone simple, no country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_AR_1, COUNTRY_CODES.AR)).toBe( - TEST_PHONE_NUMBERS.FORMATTED_AR - ) - }) - it('Format AR phone messy, no country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_AR_2, COUNTRY_CODES.AR)).toBe( - TEST_PHONE_NUMBERS.FORMATTED_AR - ) - }) - it('Format AR phone with country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_AR_3, COUNTRY_CODES.AR)).toBe( - TEST_PHONE_NUMBERS.FORMATTED_AR - ) - }) - - it('Format MX phone simple, no country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_MX_1, COUNTRY_CODES.MX)).toBe( - TEST_PHONE_NUMBERS.FORMATTED_MX - ) - }) - it('Format MX phone simple with 1, no country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_MX_2, COUNTRY_CODES.MX)).toBe( - TEST_PHONE_NUMBERS.FORMATTED_MX - ) - }) - it('Format MX phone with country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_MX_3, COUNTRY_CODES.MX)).toBe( - TEST_PHONE_NUMBERS.FORMATTED_MX - ) - }) - - it('Format LR phone with country code', () => { - expect(getE164Number(TEST_PHONE_NUMBERS.VALID_LR, COUNTRY_CODES.LR)).toBe( - TEST_PHONE_NUMBERS.FORMATTED_LR - ) - }) - }) - - describe('Display formatting', () => { - it('Invalid empty', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.INVALID_EMPTY, COUNTRY_CODES.US)).toBe('') - }) - it('Format US phone simple, no country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_US_1, COUNTRY_CODES.US)).toBe( - '(628) 228-7826' - ) - }) - it('Format US phone messy, no country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_US_2, COUNTRY_CODES.US)).toBe( - '(628) 228-7826' - ) - }) - it('Format US phone simple, with country code and wrong region', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_US_3, COUNTRY_CODES.AR)).toBe( - '(628) 228-7826' - ) - }) - it('Format US phone simple, with country code but no param', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_US_3, COUNTRY_CODES.US)).toBe( - '(628) 228-7826' - ) - }) - it('Format US phone simple, with country code no plus', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_US_4, COUNTRY_CODES.US)).toBe( - '(628) 228-7826' - ) - }) - it('Format DE phone simple, no country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_DE_1, COUNTRY_CODES.DE)).toBe( - '01522 9355106' - ) - }) - it('Format DE phone messy, no country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_DE_2, COUNTRY_CODES.DE)).toBe( - '01522 9355106' - ) - }) - it('Format DE phone messy, wrong country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_DE_2, COUNTRY_CODES.US)).toBe( - TEST_PHONE_NUMBERS.VALID_DE_2 - ) - }) - it('Format DE phone with country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_DE_3, COUNTRY_CODES.DE)).toBe( - '01522 9355106' - ) - }) - it('Format AR phone simple, no country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_AR_1, COUNTRY_CODES.AR)).toBe( - TEST_PHONE_NUMBERS.DISPLAY_AR - ) - }) - it('Format AR phone messy, no country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_AR_2, COUNTRY_CODES.AR)).toBe( - TEST_PHONE_NUMBERS.DISPLAY_AR - ) - }) - it('Format AR phone with country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_AR_3, COUNTRY_CODES.AR)).toBe( - TEST_PHONE_NUMBERS.DISPLAY_AR - ) - }) - - it('Format MX phone with country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_MX_3, COUNTRY_CODES.MX)).toBe( - TEST_PHONE_NUMBERS.DISPLAY_MX - ) - }) - - it('Format LR phone with no country code', () => { - expect(getDisplayPhoneNumber(TEST_PHONE_NUMBERS.VALID_LR, COUNTRY_CODES.LR)).toBe( - TEST_PHONE_NUMBERS.DISPLAY_LR - ) - }) - }) - - describe('Number Parsing', () => { - it('Invalid empty', () => { - expect(parsePhoneNumber(TEST_PHONE_NUMBERS.INVALID_EMPTY, COUNTRY_CODES.US)).toBe(null) - }) - it('Too short', () => { - expect(parsePhoneNumber(TEST_PHONE_NUMBERS.TOO_SHORT, COUNTRY_CODES.US)).toBe(null) - }) - it('Format US messy phone #', () => { - expect(parsePhoneNumber(TEST_PHONE_NUMBERS.VALID_US_2, COUNTRY_CODES.US)).toMatchObject({ - e164Number: '+16282287826', - displayNumber: '(628) 228-7826', - countryCode: 1, - regionCode: 'US', - }) - }) - it('Format DE messy phone #', () => { - expect(parsePhoneNumber(TEST_PHONE_NUMBERS.VALID_DE_2, COUNTRY_CODES.DE)).toMatchObject({ - e164Number: '+4915229355106', - displayNumber: '01522 9355106', - countryCode: 49, - regionCode: 'DE', - }) - }) - it('Format AR messy phone # 1', () => { - expect(parsePhoneNumber(TEST_PHONE_NUMBERS.VALID_AR_4, COUNTRY_CODES.AR)).toMatchObject({ - e164Number: TEST_PHONE_NUMBERS.FORMATTED_AR, - displayNumber: TEST_PHONE_NUMBERS.DISPLAY_AR, - countryCode: 54, - regionCode: 'AR', - }) - }) - - it('Format MX phone # 1', () => { - expect(parsePhoneNumber(TEST_PHONE_NUMBERS.VALID_MX_1, COUNTRY_CODES.MX)).toMatchObject({ - e164Number: TEST_PHONE_NUMBERS.FORMATTED_MX, - displayNumber: TEST_PHONE_NUMBERS.DISPLAY_MX, - countryCode: 52, - regionCode: 'MX', - }) - }) - }) - - describe('Other phone helper methods', () => { - it('gets country code', () => { - expect(getCountryCode(TEST_PHONE_NUMBERS.VALID_US_3)).toBe(1) - expect(getCountryCode(TEST_PHONE_NUMBERS.VALID_DE_3)).toBe(49) - expect(getCountryCode(TEST_PHONE_NUMBERS.VALID_AR_3)).toBe(54) - }) - - it('gets region code', () => { - expect(getRegionCode(TEST_PHONE_NUMBERS.VALID_US_3)).toBe('US') - expect(getRegionCode(TEST_PHONE_NUMBERS.VALID_DE_3)).toBe('DE') - expect(getRegionCode(TEST_PHONE_NUMBERS.VALID_AR_3)).toBe('AR') - }) - - it('gets region code from country code', () => { - expect(getRegionCodeFromCountryCode(COUNTRY_CODES.US)).toBe('US') - expect(getRegionCodeFromCountryCode(COUNTRY_CODES.DE)).toBe('DE') - expect(getRegionCodeFromCountryCode(COUNTRY_CODES.AR)).toBe('AR') - }) - - it('checks if number is e164', () => { - // @ts-ignore - expect(isE164Number(null)).toBe(false) - expect(isE164Number('')).toBe(false) - expect(isE164Number(TEST_PHONE_NUMBERS.VALID_US_1)).toBe(false) - expect(isE164Number(TEST_PHONE_NUMBERS.VALID_US_2)).toBe(false) - expect(isE164Number(TEST_PHONE_NUMBERS.VALID_US_3)).toBe(true) - expect(isE164Number(TEST_PHONE_NUMBERS.VALID_US_4)).toBe(false) - }) - }) - - describe('Example phones', () => { - it('gets example by country showing zeros', () => { - expect(getExampleNumber(COUNTRY_CODES.AR)).toBe('000 0000-0000') - expect(getExampleNumber(COUNTRY_CODES.DE)).toBe('000 000000') - expect(getExampleNumber(COUNTRY_CODES.US)).toBe('(000) 000-0000') - }) - - it('gets example by country', () => { - expect(getExampleNumber(COUNTRY_CODES.AR, false)).toBe('011 2345-6789') - expect(getExampleNumber(COUNTRY_CODES.DE, false)).toBe('030 123456') - expect(getExampleNumber(COUNTRY_CODES.US, false)).toBe('(201) 555-0123') - }) - - it('gets example by country showing zeros in international way', () => { - expect(getExampleNumber(COUNTRY_CODES.AR, true, true)).toBe('+54 00 0000-0000') - expect(getExampleNumber(COUNTRY_CODES.DE, true, true)).toBe('+49 00 000000') - expect(getExampleNumber(COUNTRY_CODES.US, true, true)).toBe('+1 000-000-0000') - }) - }) -}) diff --git a/packages/sdk/utils/src/phoneNumbers.ts b/packages/sdk/utils/src/phoneNumbers.ts deleted file mode 100644 index 866876ff419..00000000000 --- a/packages/sdk/utils/src/phoneNumbers.ts +++ /dev/null @@ -1,319 +0,0 @@ -import { - getPhoneHash as baseGetPhoneHash, - isE164Number, - ParsedPhoneNumber, -} from '@celo/base/lib/phoneNumbers' -import CountryData from 'country-data' -import { - PhoneNumber, - PhoneNumberFormat, - PhoneNumberType, - PhoneNumberUtil, -} from 'google-libphonenumber' -import { soliditySha3 } from 'web3-utils' - -// Exports moved to @celo/base, forwarding them -// here for backwards compatibility - -export { anonymizedPhone, isE164Number, ParsedPhoneNumber } from '@celo/base/lib/phoneNumbers' - -const sha3 = (v: string): string | null => soliditySha3({ type: 'string', value: v }) -export const getPhoneHash = (phoneNumber: string, salt?: string): string => { - return baseGetPhoneHash(sha3, phoneNumber, salt) -} - -const phoneUtil = PhoneNumberUtil.getInstance() -const MIN_PHONE_LENGTH = 4 - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getCountryEmoji( - e164PhoneNumber: string, - countryCodePossible?: number, - regionCodePossible?: string -) { - // The country code and region code can both be passed in, or it can be inferred from the e164PhoneNumber - let countryCode: any - let regionCode: any - countryCode = countryCodePossible - regionCode = regionCodePossible - if (!countryCode || !regionCode) { - countryCode = getCountryCode(e164PhoneNumber) - regionCode = getRegionCode(e164PhoneNumber) - } - const countries = CountryData.lookup.countries({ countryCallingCodes: `+${countryCode}` }) - const userCountryArray = countries.filter((c: any) => c.alpha2 === regionCode) - const country = userCountryArray.length > 0 ? userCountryArray[0] : undefined - - return country ? country.emoji : '' -} -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getCountryCode(e164PhoneNumber: string) { - if (!e164PhoneNumber) { - return null - } - try { - return phoneUtil.parse(e164PhoneNumber).getCountryCode() - } catch (error) { - console.debug(`getCountryCode, number: ${e164PhoneNumber}, error: ${error}`) - return null - } -} -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getRegionCode(e164PhoneNumber: string) { - if (!e164PhoneNumber) { - return null - } - try { - return phoneUtil.getRegionCodeForNumber(phoneUtil.parse(e164PhoneNumber)) - } catch (error) { - console.debug(`getRegionCodeForNumber, number: ${e164PhoneNumber}, error: ${error}`) - return null - } -} -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getRegionCodeFromCountryCode(countryCode: string) { - if (!countryCode) { - return null - } - try { - return phoneUtil.getRegionCodeForCountryCode(parseInt(countryCode, 10)) - } catch (error) { - console.debug(`getRegionCodeFromCountryCode, countrycode: ${countryCode}, error: ${error}`) - return null - } -} - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getDisplayPhoneNumber(phoneNumber: string, defaultCountryCode: string) { - const phoneDetails = parsePhoneNumber(phoneNumber, defaultCountryCode) - if (phoneDetails) { - return phoneDetails.displayNumber - } else { - // Fallback to input instead of showing nothing for invalid numbers - return phoneNumber - } -} - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getDisplayNumberInternational(e164PhoneNumber: string) { - const countryCode = getCountryCode(e164PhoneNumber) - const phoneDetails = parsePhoneNumber(e164PhoneNumber, (countryCode || '').toString()) - if (phoneDetails) { - return phoneDetails.displayNumberInternational - } else { - // Fallback to input instead of showing nothing for invalid numbers - return e164PhoneNumber - } -} - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getE164DisplayNumber(e164PhoneNumber: string) { - const countryCode = getCountryCode(e164PhoneNumber) - return getDisplayPhoneNumber(e164PhoneNumber, (countryCode || '').toString()) -} - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getE164Number(phoneNumber: string, defaultCountryCode: string) { - const phoneDetails = parsePhoneNumber(phoneNumber, defaultCountryCode) - if (phoneDetails && isE164Number(phoneDetails.e164Number)) { - return phoneDetails.e164Number - } else { - return null - } -} - -// Actually runs through the parsing instead of using a regex -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function isE164NumberStrict(phoneNumber: string) { - try { - const parsedPhoneNumber = phoneUtil.parse(phoneNumber) - if (!phoneUtil.isValidNumber(parsedPhoneNumber)) { - return false - } - return phoneUtil.format(parsedPhoneNumber, PhoneNumberFormat.E164) === phoneNumber - } catch { - return false - } -} - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function parsePhoneNumber( - phoneNumberRaw: string, - defaultCountryCode?: string -): ParsedPhoneNumber | null { - try { - if (!phoneNumberRaw || phoneNumberRaw.length < MIN_PHONE_LENGTH) { - return null - } - - const defaultRegionCode = defaultCountryCode - ? getRegionCodeFromCountryCode(defaultCountryCode) - : null - const parsedNumberUnfixed = phoneUtil.parse(phoneNumberRaw, defaultRegionCode || undefined) - const parsedCountryCode = parsedNumberUnfixed.getCountryCode() - const parsedRegionCode = phoneUtil.getRegionCodeForNumber(parsedNumberUnfixed) - const parsedNumber = handleSpecialCasesForParsing( - parsedNumberUnfixed, - parsedCountryCode, - parsedRegionCode - ) - - if (!parsedNumber) { - return null - } - - const isValid = phoneUtil.isValidNumberForRegion(parsedNumber, parsedRegionCode) - - return isValid - ? { - e164Number: phoneUtil.format(parsedNumber, PhoneNumberFormat.E164), - displayNumber: handleSpecialCasesForDisplay(parsedNumber, parsedCountryCode), - displayNumberInternational: phoneUtil.format( - parsedNumber, - PhoneNumberFormat.INTERNATIONAL - ), - countryCode: parsedCountryCode, - regionCode: parsedRegionCode, - } - : null - } catch (error) { - console.debug(`phoneNumbers/parsePhoneNumber/Failed to parse phone number, error: ${error}`) - return null - } -} - -function handleSpecialCasesForParsing( - parsedNumber: PhoneNumber, - countryCode?: number, - regionCode?: string -) { - if (!countryCode || !regionCode) { - return parsedNumber - } - - switch (countryCode) { - // Argentina - // https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#why-is-this-number-from-argentina-ar-or-mexico-mx-not-identified-as-the-right-number-type - // https://en.wikipedia.org/wiki/Telephone_numbers_in_Argentina - case 54: - return prependToFormMobilePhoneNumber(parsedNumber, regionCode, '9') - - default: - return parsedNumber - } -} - -// TODO(Rossy) Given the inconsistencies of numbers around the world, we should -// display e164 everywhere to ensure users knows exactly who their sending money to -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -function handleSpecialCasesForDisplay(parsedNumber: PhoneNumber, countryCode?: number) { - switch (countryCode) { - // Argentina - // The Google lib formatter incorretly adds '15' to the nationally formatted number for Argentina - // However '15' is only needed when calling a mobile from a landline - case 54: - return phoneUtil - .format(parsedNumber, PhoneNumberFormat.INTERNATIONAL) - .replace(/\+54(\s)?/, '') - - case 231: - const formatted = phoneUtil.format(parsedNumber, PhoneNumberFormat.NATIONAL) - return formatted && formatted[0] === '0' ? formatted.slice(1) : formatted - - default: - return phoneUtil.format(parsedNumber, PhoneNumberFormat.NATIONAL) - } -} - -/** - * Some countries require a prefix before the area code depending on if the number is - * mobile vs landline and international vs national - */ -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -function prependToFormMobilePhoneNumber( - parsedNumber: PhoneNumber, - regionCode: string, - prefix: string -) { - if (phoneUtil.getNumberType(parsedNumber) === PhoneNumberType.MOBILE) { - return parsedNumber - } - - let nationalNumber = phoneUtil.format(parsedNumber, PhoneNumberFormat.NATIONAL) - // Nationally formatted numbers sometimes contain leading 0 - if (nationalNumber.charAt(0) === '0') { - nationalNumber = nationalNumber.slice(1) - } - // If the number already starts with prefix, don't prepend it again - if (nationalNumber.startsWith(prefix)) { - return null - } - - const adjustedNumber = phoneUtil.parse(prefix + nationalNumber, regionCode) - return phoneUtil.getNumberType(adjustedNumber) === PhoneNumberType.MOBILE ? adjustedNumber : null -} - -/** - * @deprecated moved to @celo/phone-utils will be removed in next major version - */ -export function getExampleNumber( - regionCode: string, - useOnlyZeroes: boolean = true, - isInternational: boolean = false -) { - const examplePhone = phoneUtil.getExampleNumber( - getRegionCodeFromCountryCode(regionCode) as string - ) - - if (!examplePhone) { - return - } - - const formatedExample = phoneUtil.format( - examplePhone, - isInternational ? PhoneNumberFormat.INTERNATIONAL : PhoneNumberFormat.NATIONAL - ) - - if (useOnlyZeroes) { - if (isInternational) { - return formatedExample.replace(/(^\+[0-9]{1,3} |[0-9])/g, (value, _, i) => (i ? '0' : value)) - } - return formatedExample.replace(/[0-9]/g, '0') - } - - return formatedExample -} - -export const PhoneNumberUtils = { - getPhoneHash, - getCountryCode, - getRegionCode, - getDisplayPhoneNumber, - getE164Number, - isE164Number, - parsePhoneNumber, -} diff --git a/packages/sdk/utils/tsconfig.json b/packages/sdk/utils/tsconfig.json index f83a3096a22..410feb9ee75 100644 --- a/packages/sdk/utils/tsconfig.json +++ b/packages/sdk/utils/tsconfig.json @@ -6,5 +6,6 @@ "downlevelIteration": true, "resolveJsonModule": true }, - "include": ["src/", "src/**/*.json"] + "include": ["src/", "src/**/*.json"], + "exclude": ["**/*.test.ts"] } diff --git a/packages/sdk/wallets/wallet-base/package.json b/packages/sdk/wallets/wallet-base/package.json index 1f4601a9aa6..70c65b8ce65 100644 --- a/packages/sdk/wallets/wallet-base/package.json +++ b/packages/sdk/wallets/wallet-base/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-base", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Wallet base implementation", "author": "Celo", "license": "Apache-2.0", @@ -20,9 +20,9 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/connect": "1.3.3-dev", - "@celo/base": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", + "@celo/connect": "1.5.1-dev", + "@celo/base": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", "@types/ethereumjs-util": "^5.2.0", "@types/debug": "^4.1.5", "bignumber.js": "^9.0.0", diff --git a/packages/sdk/wallets/wallet-hsm-aws/package.json b/packages/sdk/wallets/wallet-hsm-aws/package.json index 7b116f95223..b8f4469bee3 100644 --- a/packages/sdk/wallets/wallet-hsm-aws/package.json +++ b/packages/sdk/wallets/wallet-hsm-aws/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-hsm-aws", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "AWS HSM wallet implementation", "author": "Celo", "license": "Apache-2.0", @@ -20,10 +20,10 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/utils": "1.3.3-dev", - "@celo/wallet-base": "1.3.3-dev", - "@celo/wallet-remote": "1.3.3-dev", - "@celo/wallet-hsm": "1.3.3-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-base": "1.5.1-dev", + "@celo/wallet-remote": "1.5.1-dev", + "@celo/wallet-hsm": "1.5.1-dev", "@types/debug": "^4.1.5", "@types/secp256k1": "^4.0.0", "aws-sdk": "^2.705.0", @@ -34,7 +34,7 @@ "secp256k1": "^4.0.0" }, "devDependencies": { - "@celo/connect": "1.3.3-dev", + "@celo/connect": "1.5.1-dev", "elliptic": "^6.5.4", "web3": "1.3.6" }, diff --git a/packages/sdk/wallets/wallet-hsm-azure/package.json b/packages/sdk/wallets/wallet-hsm-azure/package.json index 57810e178ee..311f1f58f2b 100644 --- a/packages/sdk/wallets/wallet-hsm-azure/package.json +++ b/packages/sdk/wallets/wallet-hsm-azure/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-hsm-azure", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Azure HSM wallet implementation", "author": "Celo", "license": "Apache-2.0", @@ -23,11 +23,11 @@ "@azure/identity": "^1.1.0", "@azure/keyvault-keys": "^4.1.0", "@azure/keyvault-secrets": "^4.1.0", - "@celo/utils": "1.3.3-dev", - "@celo/wallet-base": "1.3.3-dev", - "@celo/wallet-remote": "1.3.3-dev", - "@celo/wallet-hsm": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-base": "1.5.1-dev", + "@celo/wallet-remote": "1.5.1-dev", + "@celo/wallet-hsm": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", "@types/secp256k1": "^4.0.0", "eth-lib": "^0.2.8", "ethereumjs-util": "^5.2.0", diff --git a/packages/sdk/wallets/wallet-hsm/package.json b/packages/sdk/wallets/wallet-hsm/package.json index 5ed3940e79c..9d460a28501 100644 --- a/packages/sdk/wallets/wallet-hsm/package.json +++ b/packages/sdk/wallets/wallet-hsm/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-hsm", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "HSM wallet implementation utils", "author": "Celo", "license": "Apache-2.0", @@ -20,7 +20,7 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/base": "1.3.3-dev", + "@celo/base": "1.5.1-dev", "@types/asn1js": "^0.0.2", "@types/secp256k1": "^4.0.0", "@types/debug": "^4.1.5", diff --git a/packages/sdk/wallets/wallet-ledger/package.json b/packages/sdk/wallets/wallet-ledger/package.json index abe1dbca9f3..9744cee2da9 100644 --- a/packages/sdk/wallets/wallet-ledger/package.json +++ b/packages/sdk/wallets/wallet-ledger/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-ledger", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Ledger wallet implementation", "author": "Celo", "license": "Apache-2.0", @@ -20,10 +20,10 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/utils": "1.3.3-dev", - "@celo/wallet-base": "1.3.3-dev", - "@celo/wallet-remote": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-base": "1.5.1-dev", + "@celo/wallet-remote": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", "@types/ethereumjs-util": "^5.2.0", "eth-lib": "^0.2.8", "ethereumjs-util": "^5.2.0", diff --git a/packages/sdk/wallets/wallet-local/package.json b/packages/sdk/wallets/wallet-local/package.json index 7780ea02e5f..850dcb68328 100644 --- a/packages/sdk/wallets/wallet-local/package.json +++ b/packages/sdk/wallets/wallet-local/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-local", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Local wallet implementation", "author": "Celo", "license": "Apache-2.0", @@ -20,9 +20,9 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/utils": "1.3.3-dev", - "@celo/connect": "1.3.3-dev", - "@celo/wallet-base": "1.3.3-dev", + "@celo/utils": "1.5.1-dev", + "@celo/connect": "1.5.1-dev", + "@celo/wallet-base": "1.5.1-dev", "@types/ethereumjs-util": "^5.2.0", "eth-lib": "^0.2.8", "ethereumjs-util": "^5.2.0" diff --git a/packages/sdk/wallets/wallet-remote/package.json b/packages/sdk/wallets/wallet-remote/package.json index be3ad068c9c..7dd09e0a5ab 100644 --- a/packages/sdk/wallets/wallet-remote/package.json +++ b/packages/sdk/wallets/wallet-remote/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-remote", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Remote wallet implementation", "author": "Celo", "license": "Apache-2.0", @@ -20,9 +20,9 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/connect": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/wallet-base": "1.3.3-dev", + "@celo/connect": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-base": "1.5.1-dev", "@types/ethereumjs-util": "^5.2.0", "@types/debug": "^4.1.5", "eth-lib": "^0.2.8", diff --git a/packages/sdk/wallets/wallet-rpc/package.json b/packages/sdk/wallets/wallet-rpc/package.json index dd94d85d316..a25fd6ce1ab 100644 --- a/packages/sdk/wallets/wallet-rpc/package.json +++ b/packages/sdk/wallets/wallet-rpc/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-rpc", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "Geth RPC wallet implementation", "author": "Celo", "license": "Apache-2.0", @@ -20,16 +20,16 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/connect": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/wallet-base": "1.3.3-dev", - "@celo/wallet-remote": "1.3.3-dev", + "@celo/connect": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-base": "1.5.1-dev", + "@celo/wallet-remote": "1.5.1-dev", "bignumber.js": "^9.0.0", "debug": "^4.1.1" }, "devDependencies": { "@celo/dev-utils": "0.0.1-dev", - "@celo/contractkit": "1.3.3-dev" + "@celo/contractkit": "1.5.1-dev" }, "engines": { "node": ">=8.13.0" diff --git a/packages/sdk/wallets/wallet-walletconnect/package.json b/packages/sdk/wallets/wallet-walletconnect/package.json index f0998bb5888..10eb27d4560 100644 --- a/packages/sdk/wallets/wallet-walletconnect/package.json +++ b/packages/sdk/wallets/wallet-walletconnect/package.json @@ -1,6 +1,6 @@ { "name": "@celo/wallet-walletconnect", - "version": "1.3.3-dev", + "version": "1.5.1-dev", "description": "WalletConnect wallet implementation", "author": "Celo", "license": "Apache-2.0", @@ -24,21 +24,21 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@celo/connect": "1.3.3-dev", - "@celo/utils": "1.3.3-dev", - "@celo/wallet-base": "1.3.3-dev", - "@celo/wallet-remote": "1.3.3-dev", - "@walletconnect/client": "2.0.0-beta.20.2", - "@walletconnect/types": "2.0.0-beta.20.2", - "@walletconnect/utils": "2.0.0-beta.20.2", + "@celo/connect": "1.5.1-dev", + "@celo/utils": "1.5.1-dev", + "@celo/wallet-base": "1.5.1-dev", + "@celo/wallet-remote": "1.5.1-dev", + "@walletconnect/client": "2.0.0-beta.20.3", + "@walletconnect/types": "2.0.0-beta.20.3", + "@walletconnect/utils": "2.0.0-beta.20.3", "debug": "^4.1.1", "ethereumjs-util": "^7.0.8" }, "devDependencies": { - "@celo/contractkit": "1.3.3-dev", + "@celo/contractkit": "1.5.1-dev", "@celo/dev-utils": "0.0.1-dev" }, "engines": { "node": ">=10" } -} +} \ No newline at end of file diff --git a/scripts/deploy-sdks.ts b/scripts/deploy-sdks.ts index 5b3e7c4d7e1..e9ef10b837c 100644 --- a/scripts/deploy-sdks.ts +++ b/scripts/deploy-sdks.ts @@ -3,7 +3,7 @@ /* * deploy-sdks script * THIS SCRIPT MUST BE RUN WITH NPM TO PUBLISH - `npm run deploy-sdks` - * From the monorepo root run `yarn deploy-sdks` + * From the monorepo root run `npm run deploy-sdks` * You'll first be asked which version to update the sdks to. * You can pick major, minor, patch, a semantic version, * or nothing if you don't want to update the versions. @@ -68,14 +68,14 @@ type Answers = { 'Invalid version given. Version must be major, minor, patch, or a semantic version.' ) ) - process.exit() + process.exit(1) } const shouldPublish = publish === 'Y' || publish === 'dry-run' if (!shouldPublish && !version) { console.error(colors.red('Either a version or --publish must be given')) - process.exit() + process.exit(1) } const sdkPackagePaths = findPackagePaths(path.join(__dirname, '..', 'packages', 'sdk')) @@ -121,12 +121,13 @@ type Answers = { const otpPrompt = [ { - name: 'otp', + name: 'newOtp', description: colors.green(`Enter 2FA code`), }, ] let successfulPackages = [] + let otp = '' if (shouldPublish) { // Here we build and publish all the sdk packages for (let index = 0; index < sdkPackagePaths.length; index++) { @@ -144,11 +145,16 @@ type Answers = { console.log(`Publishing ${packageJson.name}@${packageJson.version}`) // Here you enter the 2FA code for npm - const { otp } = await prompt.get(otpPrompt) + let { newOtp } = (await prompt.get(otpPrompt)) as { newOtp: string } + if (newOtp) { + otp = newOtp + } else { + newOtp = otp + } // Here is the actual publishing child_process.execSync( - `npm publish --access public --otp ${otp} ${publish === 'dry-run' ? '--dry-run' : ''}`, + `npm publish --access public --otp ${newOtp} ${publish === 'dry-run' ? '--dry-run' : ''}`, { cwd: packageFolderPath, stdio: 'ignore' } ) successfulPackages.push(packageJson.name) @@ -183,7 +189,7 @@ type Answers = { JSON.stringify({ packages: failedPackages, version: newVersion, publish }) ) console.error(colors.red(`Fix failed packages and try again.`)) - process.exit() + process.exit(1) } const failedJsonPath = path.join(__dirname, 'failedSDKs.json') @@ -193,6 +199,7 @@ type Answers = { const allPackagePaths = findPackagePaths(path.join(__dirname, '..', 'packages')) + const newDevVersion = getNewDevVersion(newVersion) // Finally we update all the packages across the monorepo // to use the most recent sdk packages. allPackagePaths.forEach((path) => { @@ -201,21 +208,25 @@ type Answers = { const isSdk = sdkNames.includes(json.name) if (isSdk) { - json.version = `${newVersion}-dev` + json.version = `${newDevVersion}-dev` packageChanged = true } for (const depName in json.dependencies) { if (sdkNames.includes(depName)) { - const suffix = json.dependencies[depName].includes('-dev') || isSdk ? '-dev' : '' - json.dependencies[depName] = `${newVersion}${suffix}` + const versionUpdate = + json.dependencies[depName].includes('-dev') || isSdk ? `${newDevVersion}-dev` : newVersion + json.dependencies[depName] = versionUpdate packageChanged = true } } for (const depName in json.devDependencies) { if (sdkNames.includes(depName)) { - const suffix = json.devDependencies[depName].includes('-dev') || isSdk ? '-dev' : '' - json.devDependencies[depName] = `${newVersion}${suffix}` + const versionUpdate = + json.devDependencies[depName].includes('-dev') || isSdk + ? `${newDevVersion}-dev` + : newVersion + json.devDependencies[depName] = versionUpdate packageChanged = true } } @@ -276,7 +287,7 @@ function incrementVersion(version: string, command: string) { } function removeDevSuffix(version: string) { - return version.endsWith('-dev') ? version.slice(0, 5) : version + return version.endsWith('-dev') ? version.slice(0, -4) : version } function readPackageJson(filePath: string): PackageJson { @@ -297,3 +308,11 @@ function writePackageJson(filePath: string, properties: Partial) { ) ) } + +function getNewDevVersion(version: string) { + const versionArray = version.split('.') + const bump = Number(versionArray[2]) + 1 + if (isNaN(bump)) return version + versionArray[2] = `${bump}` + return versionArray.join('.') +} diff --git a/scripts/deprecate-sdks.ts b/scripts/deprecate-sdks.ts new file mode 100644 index 00000000000..094b6ec2f65 --- /dev/null +++ b/scripts/deprecate-sdks.ts @@ -0,0 +1,81 @@ +import * as fs from 'fs' +import * as path from 'path' +import * as prompt from 'prompt' +import * as colors from 'colors' +import * as child_process from 'child_process' +import * as semver from 'semver' + +type PackageJson = { + name: string + version: string + dependencies: { [key: string]: string } + devDependencies: { [key: string]: string } +} + +const dontOpen = ['node_modules', 'src', 'lib'] + +;(async function () { + prompt.start() + const prompts = [ + { + name: 'version', + description: colors.green('Which sdk version do you want to deprecate?'), + }, + { + name: 'message', + description: colors.green('Reason for deprecation:'), + }, + ] + const { version, message } = (await prompt.get(prompts)) as { version: string; message: string } + if (!semver.valid(version)) { + console.error(colors.red('Invalid version')) + process.exit(1) + } + const sdkPackagePaths = findPackagePaths(path.join(__dirname, '..', 'packages', 'sdk')) + const sdkJsons: PackageJson[] = sdkPackagePaths.map((path) => + JSON.parse(fs.readFileSync(path).toString()) + ) + const otpPrompt = [ + { + name: 'newOtp', + description: colors.green(`Enter 2FA code`), + }, + ] + + let otp = '' + for (const sdkJson of sdkJsons) { + let { newOtp } = (await prompt.get(otpPrompt)) as { newOtp: string } + if (!newOtp) { + newOtp = otp + } else { + otp = newOtp + } + const buffer = child_process.execSync(`npm info ${sdkJson.name} versions --json`) + const versions = JSON.parse(buffer.toString()) as string[] + if (!versions.includes(version)) { + console.log(colors.yellow(`Version ${version} does not exist for ${sdkJson.name}.`)) + } else { + try { + child_process.execSync( + `npm deprecate ${sdkJson.name}@${version} '${message}' --otp ${newOtp}` + ) + console.log(colors.green(`${sdkJson.name}@${version} deprecated with message ${message}`)) + } catch (e) { + console.error(colors.red(`${sdkJson.name} failed to deprecate version ${version}.`)) + console.error(e) + } + } + } +})() + +function findPackagePaths(dir: string): string[] { + return fs.readdirSync(dir, { withFileTypes: true }).reduce((packageJsons, dirent) => { + if (dirent.isDirectory() && !dontOpen.includes(dirent.name)) { + return [...packageJsons, ...findPackagePaths(`${dir}/${dirent.name}`)] + } + if (dirent.name === 'package.json') { + return [...packageJsons, path.join(dir, dirent.name)] + } + return packageJsons + }, []) +} diff --git a/yarn.lock b/yarn.lock index 36b4c9499fe..eb833d5e6db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1319,17 +1319,17 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@celo/base@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/base/-/base-1.3.3.tgz#a74ef1b9a63afd831d5f3ec6399bb98cc2fc733a" - integrity sha512-FA7C212AMCRVbWCBFNmmh0AKEStztwxkmMNYGLOSpBNu6QIMvTw/ZZKMqJeXJ0KcZvH0/xK9K3vjVEq2J9Z1HQ== +"@celo/base@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/base/-/base-1.5.0.tgz#8bbcde0b2c7ed61e07c8f8084acf673d19e0a651" + integrity sha512-RPRhwrKLyKdGAuaJ8vdslwEI/wVVQQiVGitzoBtUdFIMuf5XGPRp8GFNbYJdGcpooJnkQy1u8DYmZpaCLtRPDQ== -"@celo/connect@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/connect/-/connect-1.3.3.tgz#b9f9b4a634f454c1e72bda751f1bb3108f727ece" - integrity sha512-owgLDd3S4vYWR+yjYqx5OXGm9b0YIsOOpgCahyzlQLLEi/XgDhdk9EVdVIFeKv2bgmrZtPE80FqN+9iqNLi+hw== +"@celo/connect@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/connect/-/connect-1.5.0.tgz#2716b2f9b363f104ca7c50390a7c0c7c66df7980" + integrity sha512-LIG/GlBKuJLd8WgJYtCGut6fvn4GJ6HAqwXAumVCqiRkQIBZ0TZQQ39wWGTwfvKSzNzWpQsLx9oY96sTLGEOiQ== dependencies: - "@celo/utils" "1.3.3" + "@celo/utils" "1.5.0" "@types/debug" "^4.1.5" "@types/utf8" "^2.1.6" bignumber.js "^9.0.0" @@ -1357,15 +1357,15 @@ web3-eth-contract "1.2.4" web3-utils "1.2.4" -"@celo/contractkit@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/contractkit/-/contractkit-1.3.3.tgz#89d573dd5c354a5b66434e2d77d5ccf77962c3be" - integrity sha512-8SIrgwkLddG35gyktLwjyyPJLYeDYTarFt70T/kvn852enEjjickRy7q5BvXzO8sVajuS1f6YgWMO6wk6Emh2Q== +"@celo/contractkit@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/contractkit/-/contractkit-1.5.0.tgz#1715e6c2553a8fabcb84b961f32e57e25afb5233" + integrity sha512-JX5ZcpPyWO6loAF2aFcNG64ElFhyBmPPBE2L2KwjLOPkKmGpjb8TqlgQEg76u/NysEzfylpd9i7HuK0NSg3H9Q== dependencies: - "@celo/base" "1.3.3" - "@celo/connect" "1.3.3" - "@celo/utils" "1.3.3" - "@celo/wallet-local" "1.3.3" + "@celo/base" "1.5.0" + "@celo/connect" "1.5.0" + "@celo/utils" "1.5.0" + "@celo/wallet-local" "1.5.0" "@types/debug" "^4.1.5" bignumber.js "^9.0.0" cross-fetch "^3.0.6" @@ -1425,14 +1425,14 @@ ethereumjs-wallet "0.6.4" web3 "1.2.4" -"@celo/identity@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/identity/-/identity-1.3.3.tgz#596930b9808cce13b0434a57923ecc081d25f53e" - integrity sha512-fUWxbcXNy1gYtye9pWyjYoNcssbhTZ04T6VXWD5CzbADpsV8tq5A4UHZ95apKaQHtiDC5xmePAGXujcDIj3IKQ== +"@celo/identity@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/identity/-/identity-1.5.0.tgz#b3824bfc486fb45df53bd15d9973725852dadcfa" + integrity sha512-CSlYxXilsiNIWCnrzE5SjCmySBYvQ6PcuzzRtIJ1K+62dffIfmTGc1nLeu8n2I7Bf7g1mupd5BF0PkAe5XB6FQ== dependencies: - "@celo/base" "1.3.3" - "@celo/contractkit" "1.3.3" - "@celo/utils" "1.3.3" + "@celo/base" "1.5.0" + "@celo/contractkit" "1.5.0" + "@celo/utils" "1.5.0" "@types/debug" "^4.1.5" bignumber.js "^9.0.0" blind-threshold-bls "https://github.com/celo-org/blind-threshold-bls-wasm#e1e2f8a" @@ -1442,6 +1442,22 @@ fp-ts "2.1.1" io-ts "2.0.1" +"@celo/phone-utils@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/phone-utils/-/phone-utils-1.5.0.tgz#dda171fbbe0804494a37eb88d4a412a59e7514a0" + integrity sha512-QOO0fCiXy4VTFYt2rpXuW50NZ1eNlZU1/pBvBZnpVP6yl/LeOoaFybezAjPRBelqXfG80fP0XdTod3Hlwqwh3A== + dependencies: + "@celo/base" "1.5.0" + "@celo/utils" "1.5.0" + "@types/country-data" "^0.0.0" + "@types/ethereumjs-util" "^5.2.0" + "@types/google-libphonenumber" "^7.4.17" + "@types/node" "^10.12.18" + country-data "^0.0.31" + fp-ts "2.1.1" + google-libphonenumber "^3.2.15" + io-ts "2.0.1" + "@celo/typechain-target-web3-v1-celo@0.2.0": version "0.2.0" resolved "https://registry.yarnpkg.com/@celo/typechain-target-web3-v1-celo/-/typechain-target-web3-v1-celo-0.2.0.tgz#2560b470e348d2628debe899885724ce5b218bc3" @@ -1495,12 +1511,12 @@ numeral "^2.0.6" web3-utils "1.2.4" -"@celo/utils@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/utils/-/utils-1.3.3.tgz#f39f3d22f3c6277ff87ec4eb14074885b81cfea8" - integrity sha512-O7AqQIO7+uIb8bSreb75gXyxSY4lt9oKxYP5KYaTOgjcTiH0OqSkxn87mFuuAn0FWAPVUp3CNP0ZINWTHXpGVg== +"@celo/utils@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/utils/-/utils-1.5.0.tgz#ea99189cc9dd115f54a6321de9cebd9c45e12932" + integrity sha512-D/g+DFiqTdE4GP+gyNWpwbcz6MUDuncW/fh+3eU6253Lfiu75ca2UArn8/XX+kSz9qz1KHNh+KVmvXfipJXJiw== dependencies: - "@celo/base" "1.3.3" + "@celo/base" "1.5.0" "@types/country-data" "^0.0.0" "@types/elliptic" "^6.4.9" "@types/ethereumjs-util" "^5.2.0" @@ -1528,14 +1544,14 @@ web3-eth-abi "1.3.6" web3-utils "1.3.6" -"@celo/wallet-base@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/wallet-base/-/wallet-base-1.3.3.tgz#31397c6a84ff827fb131d738357c4db489b1f790" - integrity sha512-huP36Djm86CCj7LvVcxVCIWDvlCRAMzTOiQrmMchfDPy+IOk7eh7SUaPMpxbZb/UY0RQjnjLAF/1XT1h8IJVYg== +"@celo/wallet-base@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/wallet-base/-/wallet-base-1.5.0.tgz#843eb2b62eb02d2f87e51bfdced1e87db091572c" + integrity sha512-1MOCSyH9q0LWuQMHEXljzgfBWVLrMPWzt9LFqTwtdn5zePP+SxUDceGEXBgFKKI2PrqrbkTcczQGfA1EK8J33w== dependencies: - "@celo/base" "1.3.3" - "@celo/connect" "1.3.3" - "@celo/utils" "1.3.3" + "@celo/base" "1.5.0" + "@celo/connect" "1.5.0" + "@celo/utils" "1.5.0" "@types/debug" "^4.1.5" "@types/ethereumjs-util" "^5.2.0" bignumber.js "^9.0.0" @@ -1543,19 +1559,19 @@ eth-lib "^0.2.8" ethereumjs-util "^5.2.0" -"@celo/wallet-hsm-azure@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/wallet-hsm-azure/-/wallet-hsm-azure-1.3.3.tgz#0c60d6ae892a2a91b495b62e90c168027a10ea8d" - integrity sha512-IyVKlK/bMVo/9bS+Dx3QZFugxggZgY4IhkDqchpwrDeWEL5dTFqugw2mWhbfpDdBUsglV645yP1VliNtO6/Hqw== +"@celo/wallet-hsm-azure@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/wallet-hsm-azure/-/wallet-hsm-azure-1.5.0.tgz#332308e367b6b89bc20a944d6e09c4b6615aa9f7" + integrity sha512-RPpDyGco8pX8nxcsUrdg3kCmA7glpXuInQ2VlzJ24sjLxRvvwJm/S36IdzeOY3iUtOotkc+cNOYzzXehkTC7UA== dependencies: "@azure/identity" "^1.1.0" "@azure/keyvault-keys" "^4.1.0" "@azure/keyvault-secrets" "^4.1.0" - "@celo/connect" "1.3.3" - "@celo/utils" "1.3.3" - "@celo/wallet-base" "1.3.3" - "@celo/wallet-hsm" "1.3.3" - "@celo/wallet-remote" "1.3.3" + "@celo/connect" "1.5.0" + "@celo/utils" "1.5.0" + "@celo/wallet-base" "1.5.0" + "@celo/wallet-hsm" "1.5.0" + "@celo/wallet-remote" "1.5.0" "@types/secp256k1" "^4.0.0" bignumber.js "^9.0.0" debug "^4.1.1" @@ -1563,12 +1579,12 @@ ethereumjs-util "^5.2.0" secp256k1 "^4.0.0" -"@celo/wallet-hsm@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/wallet-hsm/-/wallet-hsm-1.3.3.tgz#19fbded8ac58b19d4322f14cdb2c591e06b8113d" - integrity sha512-S8hlaPDzW8CvIeL0AKEfafJ+F5K1r9PyFNwblkVz7by/SvAMYCH1nRjWN8OzCf9ezjd+YYYlDJsHz9w5zizxVg== +"@celo/wallet-hsm@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/wallet-hsm/-/wallet-hsm-1.5.0.tgz#714f9a2f802836c43ba28748f0f9d0c783f3b1c8" + integrity sha512-tseOC8LhrLRq7bqq+Yx9qItwPEUkdc+rjtEPM4vEFUxjFIZariTxSq9QYqwlbtt2sDnK5COIAZzuhlRKR+a9lg== dependencies: - "@celo/base" "1.3.3" + "@celo/base" "1.5.0" "@types/asn1js" "^0.0.2" "@types/debug" "^4.1.5" "@types/secp256k1" "^4.0.0" @@ -1578,26 +1594,26 @@ ethereumjs-util "^5.2.0" secp256k1 "^4.0.0" -"@celo/wallet-local@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/wallet-local/-/wallet-local-1.3.3.tgz#5dffbe8a6270aedfb3da5584a1ab1522bac876f7" - integrity sha512-QOkVl0Onei31+DKN123GuebtrWyGBzvma/iYgG15UlLavNuiXqjUQ2eemP/Zn5vigUPmnOOxT1wwuNr5tja4jA== +"@celo/wallet-local@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/wallet-local/-/wallet-local-1.5.0.tgz#51edee58a1d60a2c5197876031a977ec4eb29089" + integrity sha512-JwFvnmKrk5Qr1bNkrp6NsMYtWd9WJECUIesGIB1QhApHDU6nmW2GxsQbnMZrElPoaFSGcbaPvUCnOTv1uHn5UA== dependencies: - "@celo/connect" "1.3.3" - "@celo/utils" "1.3.3" - "@celo/wallet-base" "1.3.3" + "@celo/connect" "1.5.0" + "@celo/utils" "1.5.0" + "@celo/wallet-base" "1.5.0" "@types/ethereumjs-util" "^5.2.0" eth-lib "^0.2.8" ethereumjs-util "^5.2.0" -"@celo/wallet-remote@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@celo/wallet-remote/-/wallet-remote-1.3.3.tgz#d45b8649ce695a40b99ba351bc70dfc90e0205cd" - integrity sha512-hPIqVusMx0OtuUNFs5qvrPKH9L5XW67N6f1QbS6zYfwwNH+zFyrvXv9SyB+mi1zAXEzsg2deUoOcUFFHYNc2iw== +"@celo/wallet-remote@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@celo/wallet-remote/-/wallet-remote-1.5.0.tgz#0205a5497e59c79ae9d6d1616cb8b1c891c311c9" + integrity sha512-5AoCn9w4yogViO7dT7f19/2nKRnz+QzhVbeBma410XO3Jy8hnrS+yXEbtDJjUYhHFthYaVZ/XPvf3+fAZHjmhg== dependencies: - "@celo/connect" "1.3.3" - "@celo/utils" "1.3.3" - "@celo/wallet-base" "1.3.3" + "@celo/connect" "1.5.0" + "@celo/utils" "1.5.0" + "@celo/wallet-base" "1.5.0" "@types/debug" "^4.1.5" "@types/ethereumjs-util" "^5.2.0" eth-lib "^0.2.8" @@ -5627,10 +5643,10 @@ version "1.0.0" resolved "git://github.com/umpirsky/country-list#05fda51cd97b3294e8175ffed06104c44b3c71d7" -"@walletconnect/client@2.0.0-beta.20.2": - version "2.0.0-beta.20.2" - resolved "https://registry.yarnpkg.com/@walletconnect/client/-/client-2.0.0-beta.20.2.tgz#6b78793d939858e8dd9adb4961ac882b372af475" - integrity sha512-BjAIDUfKExJJdHx3pTs4ZEOVgFX0XDQaLbTCfUvNubf4DQm48ijUaXS5815XzD67VrMgXdgDOheSKuqgKJx3Mw== +"@walletconnect/client@2.0.0-beta.20.3": + version "2.0.0-beta.20.3" + resolved "https://registry.yarnpkg.com/@walletconnect/client/-/client-2.0.0-beta.20.3.tgz#1c116f2e9afbc244b98e39685d380065aeb83dc0" + integrity sha512-TDs3VeYb7e3da5iwopSFDOEUwSuniyW3SMsn+nUdpB2/+Ks0eNBAmV4P3S6n/z7xZd4/pGvdDPKTlqMivjTIxg== dependencies: "@walletconnect/encoding" "^1.0.0" "@walletconnect/jsonrpc-provider" "^1.0.0" @@ -5639,8 +5655,8 @@ "@walletconnect/logger" "^1.0.0" "@walletconnect/relay-api" "^1.0.0" "@walletconnect/safe-json" "^1.0.0" - "@walletconnect/types" "^2.0.0-beta.20.2" - "@walletconnect/utils" "^2.0.0-beta.20.2" + "@walletconnect/types" "^2.0.0-beta.20.3" + "@walletconnect/utils" "^2.0.0-beta.20.3" ws "^8.3.0" "@walletconnect/crypto@^1.0.1": @@ -5736,27 +5752,27 @@ resolved "https://registry.yarnpkg.com/@walletconnect/safe-json/-/safe-json-1.0.0.tgz#12eeb11d43795199c045fafde97e3c91646683b2" integrity sha512-QJzp/S/86sUAgWY6eh5MKYmSfZaRpIlmCJdi5uG4DJlKkZrHEF7ye7gA+VtbVzvTtpM/gRwO2plQuiooIeXjfg== -"@walletconnect/types@2.0.0-beta.20.2", "@walletconnect/types@^2.0.0-beta.20.2": - version "2.0.0-beta.20.2" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.0.0-beta.20.2.tgz#2a9bb511bd88bbe20593dbae410b7d99b9ac8890" - integrity sha512-pUIS+1vOo30Ph25p15GkMiMBklG3CxVotiUtQM/qPz88mkVAEIx9l+BPgvFSRu60R8LX/HvMwZ/mbUm4IcphYw== +"@walletconnect/types@2.0.0-beta.20.3", "@walletconnect/types@^2.0.0-beta.20.3": + version "2.0.0-beta.20.3" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.0.0-beta.20.3.tgz#c2206467262661744f8202856a0e0423f941bb0b" + integrity sha512-Z5DUcEDF6ZDvuNE+z/msgRLuUsQgY8hywRhmx8ia+/YXmC/iId7lt3GLxr3my1eOyhlGkCbhQAO5kyqZ8EPhPw== dependencies: "@walletconnect/jsonrpc-types" "^1.0.0" keyvaluestorage "^0.7.1" pino "^6.7.0" pino-pretty "^4.3.0" -"@walletconnect/utils@2.0.0-beta.20.2", "@walletconnect/utils@^2.0.0-beta.20.2": - version "2.0.0-beta.20.2" - resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.0.0-beta.20.2.tgz#1c33be62fc62d94d6076b413915fc32eac2da66c" - integrity sha512-XKn0lzfWWcX1ojQi0SiBh5wZ4m3d+h4FPWs5Xslo4ECTNXjEsysE/lmGO6saUS011dEoHOcZRm9d0WD4cd/RYA== +"@walletconnect/utils@2.0.0-beta.20.3", "@walletconnect/utils@^2.0.0-beta.20.3": + version "2.0.0-beta.20.3" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.0.0-beta.20.3.tgz#50e75fccce20f8f50e8df552f89a59b9ace6c6e2" + integrity sha512-qHEVBAzIegNFzzpeFoCF3p3QdxmyFaC6rNz2wFnjT+da5AvQ+tv/7Afvxr2Oa9N+7UDsEHzFgXgoqiBYDFa6sA== dependencies: "@walletconnect/ecies-25519" "^1.0.1" "@walletconnect/encoding" "^1.0.0" "@walletconnect/jsonrpc-utils" "^1.0.0" "@walletconnect/logger" "^1.0.0" "@walletconnect/safe-json" "^1.0.0" - "@walletconnect/types" "^2.0.0-beta.20.2" + "@walletconnect/types" "^2.0.0-beta.20.3" "@walletconnect/window-getters" "^1.0.0" "@walletconnect/window-metadata" "^1.0.0" lodash.union "^4.6.0"