Skip to content

Commit

Permalink
fix: add esm wrapper instead of double transpile
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ESM is only supported through a wrapper
  • Loading branch information
mirceanis committed Oct 13, 2022
1 parent 4cfdb64 commit d2bbeaf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 47 deletions.
3 changes: 3 additions & 0 deletions esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import cjsModule from '../lib/index.js';

export default cjsModule
3 changes: 3 additions & 0 deletions esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
"version": "6.2.4-alpha.1",
"description": "Resolve DID documents for ethereum addresses and public keys",
"type": "module",
"source": "src/index.ts",
"main": "./lib/index.cjs",
"module": "./lib/index.module.js",
"unpkg": "./lib/index.umd.js",
"source": "./src/index.ts",
"main": "./lib/index.js",
"module": "./esm/index.js",
"types": "./lib/index.d.ts",
"umd:main": "./lib/index.umd.js",
"exports": {
".": {
"require": "./lib/index.cjs",
"import": "./lib/index.modern.js"
"types": "./lib/index.d.ts",
"import": "./esm/index.js",
"require": "./lib/index.js"
}
},
"typesVersions": {
Expand All @@ -31,6 +30,7 @@
},
"files": [
"lib",
"esm",
"src",
"LICENSE"
],
Expand Down Expand Up @@ -59,7 +59,8 @@
"scripts": {
"test": "jest",
"test:ci": "jest --coverage",
"build": "microbundle --compress=false",
"build": "tsc",
"clean": "rm -rf ./lib",
"format": "prettier --write \"src/**/*.[jt]s\"",
"lint": "eslint --ignore-pattern \"src/**/*.test.[jt]s\" \"src/**/*.[jt]s\"",
"prepublishOnly": "yarn test:ci && yarn format && yarn lint",
Expand Down
60 changes: 21 additions & 39 deletions src/__tests__/nonce.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,20 @@ describe('nonce tracking', () => {
const hash = await ethrController.createChangeOwnerHash(nextOwner)
const signature = new SigningKey(originalOwnerPrivateKey).signDigest(hash)

await ethrController.changeOwnerSigned(
nextOwner,
{
sigV: signature.v,
sigR: signature.r,
sigS: signature.s,
}
)
await ethrController.changeOwnerSigned(nextOwner, {
sigV: signature.v,
sigR: signature.r,
sigS: signature.s,
})

const hash2 = await ethrController.createChangeOwnerHash(finalOwner)
const signature2 = new SigningKey(nextOwnerPrivateKey).signDigest(hash2)

await ethrController.changeOwnerSigned(
finalOwner,
{
sigV: signature2.v,
sigR: signature2.r,
sigS: signature2.s,
}
)
await ethrController.changeOwnerSigned(finalOwner, {
sigV: signature2.v,
sigR: signature2.r,
sigS: signature2.s,
})

const originalNonce = await registryContract.functions.nonce(originalOwner)
const signerNonce = await registryContract.functions.nonce(nextOwner)
Expand Down Expand Up @@ -143,32 +137,20 @@ describe('nonce tracking', () => {
const hash = await ethrController.createChangeOwnerHash(nextOwner)
const signature = new SigningKey(originalOwnerPrivateKey).signDigest(hash)

await ethrController.changeOwnerSigned(
nextOwner,
{
sigV: signature.v,
sigR: signature.r,
sigS: signature.s,
}
)
await ethrController.changeOwnerSigned(nextOwner, {
sigV: signature.v,
sigR: signature.r,
sigS: signature.s,
})

const hash2 = await ethrController.createSetAttributeHash(
attributeName,
attributeValue,
attributeExpiration
)
const hash2 = await ethrController.createSetAttributeHash(attributeName, attributeValue, attributeExpiration)
const signature2 = new SigningKey(nextOwnerPrivateKey).signDigest(hash2)

await ethrController.setAttributeSigned(
attributeName,
attributeValue,
attributeExpiration,
{
sigV: signature2.v,
sigR: signature2.r,
sigS: signature2.s,
}
)
await ethrController.setAttributeSigned(attributeName, attributeValue, attributeExpiration, {
sigV: signature2.v,
sigR: signature2.r,
sigS: signature2.s,
})

const originalNonce = await registryContract.functions.nonce(originalOwner)
const signerNonce = await registryContract.functions.nonce(nextOwner)
Expand Down

0 comments on commit d2bbeaf

Please sign in to comment.