Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11.5.0
- name: 'Setup Node.js with pnpm cache'
- name: 'Setup Node.js'
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,4 @@ $RECYCLE.BIN/
# End of https://www.gitignore.io/api/node,linux,macos,windows,intellij

dist/
/planning/
26 changes: 13 additions & 13 deletions src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ describe('configuration', () => {
expect(contracts['mainnet']).toBeDefined()
expect(contracts['0x1']).toBeDefined()
expect(contracts['dev']).toBeDefined()
expect(contracts['linea:goerli']).toBeDefined()
expect(contracts['0xe704']).toBeDefined()
expect(contracts['aurora']).toBeDefined()
expect(contracts['0x4e454152']).toBeDefined()
})

it('works with infuraProjectId and overrides', () => {
Expand All @@ -26,19 +26,19 @@ describe('configuration', () => {

it('works with named network', async () => {
const contracts = configureResolverWithNetworks({
networks: [{ name: 'linea:goerli', provider: new JsonRpcProvider('some goerli JSONRPC URL') }],
networks: [{ name: 'aurora', provider: new JsonRpcProvider('some JSONRPC URL') }],
})
expect(contracts['linea:goerli']).toBeDefined()
expect(contracts['0xe704']).toBeDefined()
expect(contracts['aurora']).toBeDefined()
expect(contracts['0x4e454152']).toBeDefined()
})

it('works with single network', async () => {
const contracts = configureResolverWithNetworks({
name: 'linea:goerli',
provider: new JsonRpcProvider('some goerli JSONRPC URL'),
name: 'aurora',
provider: new JsonRpcProvider('some JSONRPC URL'),
})
expect(contracts['linea:goerli']).toBeDefined()
expect(contracts['0xe704']).toBeDefined()
expect(contracts['aurora']).toBeDefined()
expect(contracts['0x4e454152']).toBeDefined()
})

it('works with single provider', async () => {
Expand Down Expand Up @@ -68,24 +68,24 @@ describe('configuration', () => {
it('throws when no configuration is provided', () => {
expect(() => {
configureResolverWithNetworks()
}).toThrowError('invalid_config: Please make sure to have at least one network')
}).toThrow('invalid_config: Please make sure to have at least one network')
})

it('throws when no registry is known for a network', () => {
expect(() => {
configureResolverWithNetworks({ networks: [{ name: 'unknown-net', rpcUrl: 'http://localhost:8545' }] })
}).toThrowError('invalid_config: No registry address known for network unknown-net')
}).toThrow('invalid_config: No registry address known for network unknown-net')
})

it('throws when no relevant configuration is provided for a network', () => {
expect(() => {
configureResolverWithNetworks({ networks: [{ chainId: '0xbad' }] })
}).toThrowError('invalid_config: No web3 provider could be determined for network')
}).toThrow('invalid_config: No web3 provider could be determined for network')
})

it('throws when malformed configuration is provided for a network', () => {
expect(() => {
configureResolverWithNetworks({ networks: [{ web3: '0xbad' }] })
}).toThrowError('invalid_config: No web3 provider could be determined for network')
}).toThrow('invalid_config: No web3 provider could be determined for network')
})
})
8 changes: 4 additions & 4 deletions src/__tests__/resolve.unregistered.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BrowserProvider } from 'ethers'
import { Resolvable } from 'did-resolver'

import { deployRegistry, randomAccount } from './testUtils'
import { compressedSecp256k1ToJwk } from '../helpers'
import { secp256k1ToJwk } from '../helpers'

describe('unregistered DIDs', () => {
let didResolver: Resolvable, provider: BrowserProvider
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('unregistered DIDs', () => {
id: `${longDID}#controllerKey`,
type: 'EcdsaSecp256k1VerificationKey2019',
controller: longDID,
publicKeyJwk: compressedSecp256k1ToJwk(pubKey),
publicKeyJwk: secp256k1ToJwk(pubKey),
},
],
authentication: [`${longDID}#controller`, `${longDID}#controllerKey`],
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('unregistered DIDs', () => {
id: `${pubdid}#controllerKey`,
type: 'EcdsaSecp256k1VerificationKey2019',
controller: pubdid,
publicKeyJwk: compressedSecp256k1ToJwk(pubKey),
publicKeyJwk: secp256k1ToJwk(pubKey),
},
],
authentication: [`${pubdid}#controller`, `${pubdid}#controllerKey`],
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('unregistered DIDs', () => {
id: `${pubdid}#controllerKey`,
type: 'EcdsaSecp256k1VerificationKey2019',
controller: pubdid,
publicKeyJwk: compressedSecp256k1ToJwk(pubKey),
publicKeyJwk: secp256k1ToJwk(pubKey),
},
],
authentication: [`${pubdid}#controller`, `${pubdid}#controllerKey`],
Expand Down
51 changes: 27 additions & 24 deletions src/config/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,38 @@ export const deployments: EthrDidRegistryDeployment[] = [
description: 'energy web testnet',
legacyNonce: false,
},
{
chainId: 246785,
registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B',
name: 'artis:tau1',
legacyNonce: true,
},
{
chainId: 246529,
registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B',
name: 'artis:sigma1',
legacyNonce: true,
},
// // deprecated networks
Comment thread
mirceanis marked this conversation as resolved.
// {
// chainId: 246785,
// registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B',
// name: 'artis:tau1',
// legacyNonce: true,
// },
// {
// chainId: 246529,
// registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B',
// name: 'artis:sigma1',
// legacyNonce: true,
// },
{ chainId: 137, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'polygon', legacyNonce: true },
{
chainId: 80001,
registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b',
name: 'polygon:test',
legacyNonce: true,
},
// // deprecated
Comment thread
mirceanis marked this conversation as resolved.
// {
// chainId: 80001,
// registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b',
// name: 'polygon:test',
// legacyNonce: true,
// },
{
chainId: 1313161554,
registry: '0x63eD58B671EeD12Bc1652845ba5b2CDfBff198e0',
name: 'aurora',
legacyNonce: true,
},
{
chainId: 59140,
registry: '0x03d5003bf0e79C5F5223588F347ebA39AfbC3818',
name: 'linea:goerli',
legacyNonce: false,
},
// deprecated
// {
// chainId: 59140,
// registry: '0x03d5003bf0e79C5F5223588F347ebA39AfbC3818',
// name: 'linea:goerli',
// legacyNonce: false,
// },
]
2 changes: 1 addition & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const infuraNames: Record<string, string> = {
aurora: 'aurora-mainnet',
}

const knownInfuraNames = ['mainnet', 'aurora', 'linea:goerli', 'sepolia']
const knownInfuraNames = ['mainnet', 'aurora', 'sepolia']

/**
* A configuration entry for an ethereum network
Expand Down
32 changes: 25 additions & 7 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,48 @@ export type uint256 = bigint
export type bytes32 = string
export type bytes = string

export interface ERC1056Event {
/**
* Common fields shared by all ERC-1056 events.
*/
type ERC1056Base = {
identity: address
previousChange: uint256
validTo?: bigint
_eventName: string
blockNumber: number
}

export interface DIDOwnerChanged extends ERC1056Event {
/**
* ERC-1056 owner change event — no `validTo`.
*/
export type DIDOwnerChanged = ERC1056Base & {
_eventName: 'DIDOwnerChanged'
owner: address
}

export interface DIDAttributeChanged extends ERC1056Event {
/**
* ERC-1056 attribute change event.
*/
export type DIDAttributeChanged = ERC1056Base & {
_eventName: 'DIDAttributeChanged'
name: bytes32
value: bytes
validTo: uint256
}

export interface DIDDelegateChanged extends ERC1056Event {
/**
* ERC-1056 delegate change event.
*/
export type DIDDelegateChanged = ERC1056Base & {
_eventName: 'DIDDelegateChanged'
delegateType: bytes32
delegate: address
validTo: uint256
}

/**
* Discriminated union of all ERC-1056 event types.
*/
export type ERC1056Event = DIDOwnerChanged | DIDAttributeChanged | DIDDelegateChanged

export const VMTypes = {
EcdsaSecp256k1VerificationKey2019: 'EcdsaSecp256k1VerificationKey2019',
EcdsaSecp256k1RecoveryMethod2020: 'EcdsaSecp256k1RecoveryMethod2020',
Expand Down Expand Up @@ -184,7 +202,7 @@ export function toMultibase(hexValue: string, prefix?: Uint8Array): string {
* Decompresses a 33-byte secp256k1 public key (hex, with or without 0x prefix) and
* returns a JWK object suitable for use as `publicKeyJwk` in a DID document.
*/
Comment thread
mirceanis marked this conversation as resolved.
export function compressedSecp256k1ToJwk(hex: string): JsonWebKey {
export function secp256k1ToJwk(hex: string): JsonWebKey {
const uncompressed = SigningKey.computePublicKey(hex.startsWith('0x') ? hex : `0x${hex}`, false)
// uncompressed is 0x04 || x (32 bytes) || y (32 bytes)
const raw = getBytes(uncompressed)
Expand Down
Loading