Skip to content

Commit

Permalink
one more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
shazarre committed Dec 6, 2024
1 parent 717d67d commit 076c280
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
29 changes: 28 additions & 1 deletion packages/sdk/metadata-claims/src/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ testWithAnvilL1('Metadata', (web3) => {
}
})

it('throws an error while trying to add a ATTESTAION_SERVICE_URL claim ', async () => {
it('throws an error while trying to add a ATTESTATION_SERVICE_URL claim ', async () => {
const metadata = IdentityMetadataWrapper.fromEmpty(address)

const claim = {
Expand All @@ -104,4 +104,31 @@ testWithAnvilL1('Metadata', (web3) => {
metadata.addClaim(claim as Claim, NativeSigner(kit.connection.sign, address))
).rejects.toThrow('ATTESTATION_SERVICE_URL claims are not supported')
})

it('allows to add a new valid claim and hashes it even if the existing claims contains deprecated ATTESTATION_SERVICE_URL', async () => {
const metadata = await IdentityMetadataWrapper.fromRawString(
await kit.contracts.getAccounts(),
`{
"claims": [
{
"url": "https://example.com/attestations",
"timestamp": 1733488714,
"type": "ATTESTATION_SERVICE_URL"
}
],
"meta": {
"address": "0x5409ED021D9299bf6814279A6A1411A7e866A631",
"signature": "0x48b156db90446fcc0587575ad4913c40184cae119ef40e17652c66641f6fef4611d4be7b7940d36b46ac8803ba26ea608e6009c12bf9361e2e149fee33ecbbf11c"
}
}`
)

await expect(
metadata.addClaim(createNameClaim('Test name'), NativeSigner(kit.connection.sign, address))
).resolves.toMatchObject({
// Not checking timestamp here on purpose
name: 'Test name',
type: 'NAME',
})
})
})
1 change: 1 addition & 0 deletions packages/sdk/metadata-claims/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class IdentityMetadataWrapper {
if (existingClaims.length > 0) {
return existingClaims[0]
}
break

Check warning on line 202 in packages/sdk/metadata-claims/src/metadata.ts

View check run for this annotation

Codecov / codecov/patch

packages/sdk/metadata-claims/src/metadata.ts#L202

Added line #L202 was not covered by tests
}
case ClaimTypes.ATTESTATION_SERVICE_URL: {
throw new Error('ATTESTATION_SERVICE_URL claims are not supported')
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/metadata-claims/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export enum ClaimTypes {
}

export const VERIFIABLE_CLAIM_TYPES = [ClaimTypes.KEYBASE, ClaimTypes.ACCOUNT, ClaimTypes.DOMAIN]
export const SINGULAR_CLAIM_TYPES = [ClaimTypes.NAME, ClaimTypes.ATTESTATION_SERVICE_URL]
export const SINGULAR_CLAIM_TYPES = [ClaimTypes.NAME]

export type AccountSignerGetters = {
isAccount: (address: Address) => Promise<boolean>
Expand Down

0 comments on commit 076c280

Please sign in to comment.