-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add support for Polygon (POL) network #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f339346
feat: add support for Polygon (POL) network
manishdex25 b83869e
feat: add W3C Transferable Record fixture for Polygon mainnet
manishdex25 aaf1665
test: update Polygon network tests to conditionally skip live-network…
manishdex25 74088e1
refactor: update Polygon network references
manishdex25 7079568
test: enhance Polygon network tests with new fixtures and error handling
manishdex25 bfc06d6
chore: update dependencies and enhance CI configuration
manishdex25 c07749f
Update src/__tests__/fixtures/pol-w3c-verifiable-document.json
manishdex25 9e5c411
test: enhance Polygon network tests for credential status handling
manishdex25 c953a4f
test: update Polygon network tests to conditionally skip based on min…
manishdex25 64a9655
test: refine Polygon network tests for improved validation and error …
manishdex25 19b1f1b
test: update transfer tests to use dynamic gas transaction options an…
manishdex25 3e01b32
fix: refactor Polygon network tests to utilize helper functions for i…
manishdex25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { verifyDocument } from '../../core/verify'; | ||
| import { W3C_TRANSFERABLE_RECORD_POL } from '../fixtures/fixtures'; | ||
| import { CHAIN_ID, SUPPORTED_CHAINS } from '../../utils/supportedChains'; | ||
|
|
||
| // Public Polygon mainnet RPC — no API key required for read-only calls. | ||
| const POL_RPC_URL = process.env.POL_RPC || 'https://polygon-rpc.com'; | ||
|
|
||
| describe('Polygon (POL) network support', () => { | ||
| describe('CHAIN_ID and SUPPORTED_CHAINS', () => { | ||
| it('CHAIN_ID.pol should equal chain ID 137', () => { | ||
| expect(CHAIN_ID.pol).toBe('137'); | ||
| }); | ||
|
|
||
| it('CHAIN_ID.matic (backward-compat alias) should also equal 137', () => { | ||
| expect(CHAIN_ID.matic).toBe('137'); | ||
| }); | ||
|
|
||
| it('SUPPORTED_CHAINS[CHAIN_ID.pol] should have currency POL', () => { | ||
| expect(SUPPORTED_CHAINS[CHAIN_ID.pol].currency).toBe('POL'); | ||
| }); | ||
|
|
||
| it('SUPPORTED_CHAINS[CHAIN_ID.pol] and SUPPORTED_CHAINS[CHAIN_ID.matic] should be the same object', () => { | ||
| expect(SUPPORTED_CHAINS[CHAIN_ID.pol]).toBe(SUPPORTED_CHAINS[CHAIN_ID.matic]); | ||
| }); | ||
| }); | ||
|
|
||
| describe('W3C_TRANSFERABLE_RECORD_POL fixture structure', () => { | ||
| it('should have chain POL and chainId 137 in credentialStatus', () => { | ||
| expect(W3C_TRANSFERABLE_RECORD_POL.credentialStatus.tokenNetwork.chain).toBe('POL'); | ||
| expect(W3C_TRANSFERABLE_RECORD_POL.credentialStatus.tokenNetwork.chainId).toBe(137); | ||
| }); | ||
|
|
||
| it('should have a DataIntegrityProof with ecdsa-sd-2023 cryptosuite', () => { | ||
| expect(W3C_TRANSFERABLE_RECORD_POL.proof.type).toBe('DataIntegrityProof'); | ||
| expect(W3C_TRANSFERABLE_RECORD_POL.proof.cryptosuite).toBe('ecdsa-sd-2023'); | ||
| }); | ||
|
|
||
| it('issuer should be did:web:didhost.vercel.app', () => { | ||
| expect(W3C_TRANSFERABLE_RECORD_POL.issuer).toBe('did:web:didhost.vercel.app'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('W3C_TRANSFERABLE_RECORD_POL — POL network routing', () => { | ||
| it( | ||
| 'verifyDocument should return fragments for a POL credential (all verifiers run)', | ||
| { timeout: 30000 }, | ||
| async () => { | ||
| const fragments = await verifyDocument(W3C_TRANSFERABLE_RECORD_POL as any); | ||
|
|
||
| // All three verifier types should produce fragments — proves the document | ||
| // is recognised as a W3C VC with POL credentialStatus. | ||
| const names = fragments.map((f) => f.name); | ||
| expect(names).toContain('EcdsaW3CSignatureIntegrity'); | ||
| expect(names).toContain('W3CCredentialStatus'); | ||
| expect(names).toContain('W3CIssuerIdentity'); | ||
| }, | ||
| ); | ||
|
|
||
| it( | ||
| 'should reach Polygon mainnet (chain 137) for DOCUMENT_STATUS check', | ||
| { timeout: 300000 }, | ||
| async () => { | ||
| const fragments = await verifyDocument(W3C_TRANSFERABLE_RECORD_POL as any, { | ||
| rpcProviderUrl: POL_RPC_URL, | ||
| }); | ||
|
|
||
| // W3CCredentialStatus fragment must be present — its presence proves the verifier | ||
| // attempted to check the token on Polygon mainnet (chain 137). | ||
| // INVALID = token not minted on-chain (expected for this test fixture). | ||
| // ERROR = RPC connection failed, meaning POL routing is broken. | ||
| const statusFragment = fragments.find((f) => f.name === 'W3CCredentialStatus'); | ||
| expect(statusFragment).toBeDefined(); | ||
| expect(statusFragment?.status).not.toBe('ERROR'); | ||
| }, | ||
| ); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.