Skip to content

Commit

Permalink
Merge pull request #1393 from koshilife/support-goerli-and-sepolia
Browse files Browse the repository at this point in the history
Support verifying VCs on the Goerli and the Sepolia
  • Loading branch information
lemoustachiste authored Aug 24, 2022
2 parents 5d85d58 + 9874ce6 commit e7da49b
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 16 deletions.
29 changes: 15 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
20 changes: 20 additions & 0 deletions src/constants/blockchains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export enum SupportedChains {
Ethmain = 'ethmain',
Ethropst = 'ethropst',
Ethrinkeby = 'ethrinkeby',
Ethgoerli = 'ethgoerli',
Ethsepolia = 'ethsepolia',
Mocknet = 'mocknet',
Regtest = 'regtest',
Testnet = 'testnet'
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/inspectors/did/deriveIssuingAddressFromPublicKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
26 changes: 26 additions & 0 deletions test/application/domain/certificates/useCases/getChain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit e7da49b

Please sign in to comment.