From 902b00c44459ab670e154167cacb219b1ad9f79f Mon Sep 17 00:00:00 2001 From: Kenji Koshikawa Date: Wed, 6 Jul 2022 02:05:11 +0900 Subject: [PATCH 1/2] feat(GoerliAndSepolia): add Ethereum testnets definitions, goerli and sepolia --- src/constants/blockchains.ts | 20 ++++++++++++++ .../did/deriveIssuingAddressFromPublicKey.ts | 2 ++ .../certificates/useCases/getChain.test.ts | 26 +++++++++++++++++++ .../deriveIssuingAddressFromPublicKey.test.ts | 14 ++++++++++ 4 files changed, 62 insertions(+) diff --git a/src/constants/blockchains.ts b/src/constants/blockchains.ts index 39dccd5fa..4087fec5f 100644 --- a/src/constants/blockchains.ts +++ b/src/constants/blockchains.ts @@ -5,6 +5,8 @@ export enum SupportedChains { Ethmain = 'ethmain', Ethropst = 'ethropst', Ethrinkeby = 'ethrinkeby', + Ethgoerli = 'ethgoerli', + Ethsepolia = 'ethsepolia', Mocknet = 'mocknet', Regtest = 'regtest', Testnet = 'testnet' @@ -61,6 +63,24 @@ const BLOCKCHAINS: {[chain in SupportedChains]: IBlockchainObject} = { raw: `https://rinkeby.etherscan.io/getRawTx?tx=${TRANSACTION_ID_PLACEHOLDER}` } }, + [SupportedChains.Ethgoerli]: { + code: SupportedChains.Ethgoerli, + name: 'Ethereum Testnet', + signatureValue: 'ethereumGoerli', + transactionTemplates: { + full: `https://goerli.etherscan.io/tx/${TRANSACTION_ID_PLACEHOLDER}`, + raw: `https://goerli.etherscan.io/getRawTx?tx=${TRANSACTION_ID_PLACEHOLDER}` + } + }, + [SupportedChains.Ethsepolia]: { + code: SupportedChains.Ethsepolia, + name: 'Ethereum Testnet', + signatureValue: 'ethereumSepolia', + transactionTemplates: { + full: `https://sepolia.etherscan.io/tx/${TRANSACTION_ID_PLACEHOLDER}`, + raw: `https://sepolia.etherscan.io/getRawTx?tx=${TRANSACTION_ID_PLACEHOLDER}` + } + }, [SupportedChains.Mocknet]: { code: SupportedChains.Mocknet, name: 'Mocknet', diff --git a/src/inspectors/did/deriveIssuingAddressFromPublicKey.ts b/src/inspectors/did/deriveIssuingAddressFromPublicKey.ts index 8f048c088..ddefa95b0 100644 --- a/src/inspectors/did/deriveIssuingAddressFromPublicKey.ts +++ b/src/inspectors/did/deriveIssuingAddressFromPublicKey.ts @@ -21,6 +21,8 @@ export default function deriveIssuingAddressFromPublicKey (verificationMethodPub case SupportedChains.Ethmain: case SupportedChains.Ethropst: case SupportedChains.Ethrinkeby: + case SupportedChains.Ethgoerli: + case SupportedChains.Ethsepolia: address = computeEthereumAddressFromPublicKey(publicKey, chain); break; diff --git a/test/application/domain/certificates/useCases/getChain.test.ts b/test/application/domain/certificates/useCases/getChain.test.ts index bd5079cb1..4b703ad23 100644 --- a/test/application/domain/certificates/useCases/getChain.test.ts +++ b/test/application/domain/certificates/useCases/getChain.test.ts @@ -117,6 +117,32 @@ describe('domain certificates get chain use case test suite', function () { expect(result).toEqual(chainAssertion); }); }); + + describe('and the network is goerli', function () { + it('should return ethereum goerli value', function () { + const fixtureSignature = { + anchors: [ + 'blink:eth:goerli:0xfaea9061b06ff532d96ad91bab89fdfab900ae7d4524161431dc88318216435a' + ] + }; + const result = domain.certificates.getChain(fixtureAddress, fixtureSignature); + const chainAssertion = BLOCKCHAINS.ethgoerli; + expect(result).toEqual(chainAssertion); + }); + }); + + describe('and the network is sepolia', function () { + it('should return ethereum sepolia value', function () { + const fixtureSignature = { + anchors: [ + 'blink:eth:sepolia:0xfaea9061b06ff532d96ad91bab89fdfab900ae7d4524161431dc88318216435a' + ] + }; + const result = domain.certificates.getChain(fixtureAddress, fixtureSignature); + const chainAssertion = BLOCKCHAINS.ethsepolia; + expect(result).toEqual(chainAssertion); + }); + }); }); }); diff --git a/test/application/inspectors/did/deriveIssuingAddressFromPublicKey.test.ts b/test/application/inspectors/did/deriveIssuingAddressFromPublicKey.test.ts index 8d1e8e7d7..f98617ca5 100644 --- a/test/application/inspectors/did/deriveIssuingAddressFromPublicKey.test.ts +++ b/test/application/inspectors/did/deriveIssuingAddressFromPublicKey.test.ts @@ -52,6 +52,20 @@ describe('deriveIssuingAddressFromPublicKey test suite', function () { }); }); + describe('given the argument chain was Ethgoerli', function () { + it('should return the address of Ethereum', function () { + const address = deriveIssuingAddressFromPublicKey(publicKey, BLOCKCHAINS.ethgoerli); + expect(address).toBe('0x40cf9b7db6fcc742ad0a76b8588c7f8de2b54a60'); + }); + }); + + describe('given the argument chain was Ethsepolia', function () { + it('should return the address of Ethereum', function () { + const address = deriveIssuingAddressFromPublicKey(publicKey, BLOCKCHAINS.ethsepolia); + expect(address).toBe('0x40cf9b7db6fcc742ad0a76b8588c7f8de2b54a60'); + }); + }); + describe('given the argument chain was Regtest (Unsupported)', function () { it('should throw', function () { expect(() => { From 9874ce69e32093d57ffdc02293f5f90bc8091ae2 Mon Sep 17 00:00:00 2001 From: Kenji Koshikawa Date: Wed, 24 Aug 2022 23:05:46 +0900 Subject: [PATCH 2/2] feat(GoerliAndSepolia): specify the dependencies which @blockcerts/explorer-lookup is larger than 1.3.0 and @vaultie/lds-merkle-proof-2019 is pointed to the commit e4b7197 --- package-lock.json | 29 +++++++++++++++-------------- package.json | 4 ++-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index c19b6b76b..d4aaee7a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "dependencies": { "@babel/runtime": "^7.11.2", "@babel/runtime-corejs3": "^7.8.7", - "@blockcerts/explorer-lookup": "^1.2.1", + "@blockcerts/explorer-lookup": "^1.3.0", "@blockcerts/hashlink-verifier": "^1.3.0", "@blockcerts/schemas": "^3.2.1", "@bloomprotocol/ecdsa-secp256k1-signature-2019": "^0.1.3", @@ -24,7 +24,7 @@ "@transmute/did-key-secp256k1": "^0.3.0-unstable.8", "@transmute/ed25519-key-pair": "^0.7.0-unstable.63", "@trust/keyto": "^1.0.1", - "@vaultie/lds-merkle-proof-2019": "0.0.8", + "@vaultie/lds-merkle-proof-2019": "github:vaultie/lds-merkle-proof-2019#e4b7197d6759d1ef882e8a06f61ba07ccc20d819", "base58-universal": "github:lemoustachiste/base58-universal#fix/hoisting-error-alphabet", "bigi": "^1.4.2", "bitcoinjs-lib": "^5.2.0", @@ -1839,9 +1839,9 @@ } }, "node_modules/@blockcerts/explorer-lookup": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@blockcerts/explorer-lookup/-/explorer-lookup-1.2.1.tgz", - "integrity": "sha512-JASXJhMIExXgdLurJHkntskjpSQNPkY6dvxaV0t3ZrXhKYlBI7rZ2g4+UIodlbFeZKH4ueS5phdy2xviJPJJqg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@blockcerts/explorer-lookup/-/explorer-lookup-1.3.0.tgz", + "integrity": "sha512-V4nYyxHdrWieaB4zxYbzF7wZJvU869hCl1rzpkchA24QgF3ccFORlhT9+fo7dDTXgr/uHX1i4AX+yGldEOsQow==", "dependencies": { "xmlhttprequest": "^1.8.0" } @@ -5314,9 +5314,10 @@ } }, "node_modules/@vaultie/lds-merkle-proof-2019": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@vaultie/lds-merkle-proof-2019/-/lds-merkle-proof-2019-0.0.8.tgz", - "integrity": "sha512-Tn+M9Vbj7Ie0ab4jqjWWBXZ4RDWn+cHWf+drSgbQgwtEs4h0hGvaNTEzSNcChOndC/XxzetmfK+XqVryfv2f7w==", + "version": "0.0.7", + "resolved": "git+ssh://git@github.com/vaultie/lds-merkle-proof-2019.git#e4b7197d6759d1ef882e8a06f61ba07ccc20d819", + "integrity": "sha512-Blo+hk5TKLcL2u+bZAava/sEMxrE/1n86SVxTnS6f1okW1rZCmNoTf8VxvQ3zPdN0Y/sIqxhhBVMbbKqzShsZw==", + "license": "MIT", "dependencies": { "ajv": "^6.10.2", "cbor": "^5.0.1", @@ -26587,9 +26588,9 @@ "integrity": "sha512-R524tD5VwOt3QRHr7N518nqTVR/HKgfWL4LypekcGuNQN8R4PWScvuRcRzrY39A28kLztMv+TJdiKuMNbkU1ug==" }, "@blockcerts/explorer-lookup": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@blockcerts/explorer-lookup/-/explorer-lookup-1.2.1.tgz", - "integrity": "sha512-JASXJhMIExXgdLurJHkntskjpSQNPkY6dvxaV0t3ZrXhKYlBI7rZ2g4+UIodlbFeZKH4ueS5phdy2xviJPJJqg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@blockcerts/explorer-lookup/-/explorer-lookup-1.3.0.tgz", + "integrity": "sha512-V4nYyxHdrWieaB4zxYbzF7wZJvU869hCl1rzpkchA24QgF3ccFORlhT9+fo7dDTXgr/uHX1i4AX+yGldEOsQow==", "requires": { "xmlhttprequest": "^1.8.0" } @@ -29351,9 +29352,9 @@ } }, "@vaultie/lds-merkle-proof-2019": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@vaultie/lds-merkle-proof-2019/-/lds-merkle-proof-2019-0.0.8.tgz", - "integrity": "sha512-Tn+M9Vbj7Ie0ab4jqjWWBXZ4RDWn+cHWf+drSgbQgwtEs4h0hGvaNTEzSNcChOndC/XxzetmfK+XqVryfv2f7w==", + "version": "git+ssh://git@github.com/vaultie/lds-merkle-proof-2019.git#e4b7197d6759d1ef882e8a06f61ba07ccc20d819", + "integrity": "sha512-Blo+hk5TKLcL2u+bZAava/sEMxrE/1n86SVxTnS6f1okW1rZCmNoTf8VxvQ3zPdN0Y/sIqxhhBVMbbKqzShsZw==", + "from": "@vaultie/lds-merkle-proof-2019@github:vaultie/lds-merkle-proof-2019#e4b7197d6759d1ef882e8a06f61ba07ccc20d819", "requires": { "ajv": "^6.10.2", "cbor": "^5.0.1", diff --git a/package.json b/package.json index d4fbe2253..4ec482d28 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "dependencies": { "@babel/runtime": "^7.11.2", "@babel/runtime-corejs3": "^7.8.7", - "@blockcerts/explorer-lookup": "^1.2.1", + "@blockcerts/explorer-lookup": "^1.3.0", "@blockcerts/hashlink-verifier": "^1.3.0", "@blockcerts/schemas": "^3.2.1", "@bloomprotocol/ecdsa-secp256k1-signature-2019": "^0.1.3", @@ -68,7 +68,7 @@ "@transmute/did-key-secp256k1": "^0.3.0-unstable.8", "@transmute/ed25519-key-pair": "^0.7.0-unstable.63", "@trust/keyto": "^1.0.1", - "@vaultie/lds-merkle-proof-2019": "0.0.8", + "@vaultie/lds-merkle-proof-2019": "github:vaultie/lds-merkle-proof-2019#e4b7197d6759d1ef882e8a06f61ba07ccc20d819", "base58-universal": "github:lemoustachiste/base58-universal#fix/hoisting-error-alphabet", "bigi": "^1.4.2", "bitcoinjs-lib": "^5.2.0",