@ensdomains/ensjs 3.0.0-alpha.11 → 3.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/contracts/index.d.ts +8 -8
- package/dist/cjs/functions/burnFuses.d.ts +31 -4
- package/dist/cjs/functions/burnFuses.js +36 -6
- package/dist/cjs/functions/commitName.d.ts +26 -0
- package/dist/cjs/functions/commitName.js +24 -0
- package/dist/cjs/functions/getFuses.d.ts +2 -1
- package/dist/cjs/functions/getFuses.js +9 -18
- package/dist/cjs/functions/getHistory.d.ts +0 -30
- package/dist/cjs/functions/getHistory.js +3 -99
- package/dist/cjs/functions/getName.d.ts +2 -2
- package/dist/cjs/functions/getName.js +1 -1
- package/dist/cjs/functions/getProfile.js +1 -1
- package/dist/cjs/functions/getSpecificRecord.d.ts +4 -4
- package/dist/cjs/functions/registerName.d.ts +11 -0
- package/dist/cjs/functions/registerName.js +19 -0
- package/dist/cjs/functions/renewName.d.ts +6 -0
- package/dist/cjs/functions/renewName.js +10 -0
- package/dist/cjs/index.d.ts +24 -35
- package/dist/cjs/index.js +8 -3
- package/dist/cjs/utils/fuses.d.ts +18 -17
- package/dist/cjs/utils/fuses.js +10 -4
- package/dist/cjs/utils/registerHelpers.d.ts +44 -16
- package/dist/cjs/utils/registerHelpers.js +43 -15
- package/dist/cjs/utils/wrapperExpiry.d.ts +1 -1
- package/dist/cjs/utils/writeTx.d.ts +18 -1
- package/dist/cjs/utils/writeTx.js +4 -1
- package/dist/esm/contracts/index.d.ts +8 -8
- package/dist/esm/functions/burnFuses.d.ts +31 -4
- package/dist/esm/functions/burnFuses.js +36 -3
- package/dist/esm/functions/commitName.d.ts +26 -0
- package/dist/esm/functions/commitName.js +21 -0
- package/dist/esm/functions/getFuses.d.ts +2 -1
- package/dist/esm/functions/getFuses.js +10 -19
- package/dist/esm/functions/getHistory.d.ts +0 -30
- package/dist/esm/functions/getHistory.js +2 -96
- package/dist/esm/functions/getName.d.ts +2 -2
- package/dist/esm/functions/getName.js +1 -1
- package/dist/esm/functions/getProfile.js +1 -1
- package/dist/esm/functions/getSpecificRecord.d.ts +4 -4
- package/dist/esm/functions/registerName.d.ts +11 -0
- package/dist/esm/functions/registerName.js +16 -0
- package/dist/esm/functions/renewName.d.ts +6 -0
- package/dist/esm/functions/renewName.js +7 -0
- package/dist/esm/index.d.ts +24 -35
- package/dist/esm/index.js +8 -3
- package/dist/esm/utils/fuses.d.ts +18 -17
- package/dist/esm/utils/fuses.js +9 -3
- package/dist/esm/utils/registerHelpers.d.ts +44 -16
- package/dist/esm/utils/registerHelpers.js +40 -14
- package/dist/esm/utils/wrapperExpiry.d.ts +1 -1
- package/dist/esm/utils/writeTx.d.ts +18 -1
- package/dist/esm/utils/writeTx.js +4 -1
- package/package.json +19 -22
- package/src/functions/burnFuses.test.ts +123 -15
- package/src/functions/burnFuses.ts +101 -10
- package/src/functions/commitName.test.ts +61 -0
- package/src/functions/commitName.ts +36 -0
- package/src/functions/getFuses.test.ts +33 -15
- package/src/functions/getFuses.ts +13 -25
- package/src/functions/getHistory.test.ts +0 -84
- package/src/functions/getHistory.ts +2 -127
- package/src/functions/getName.test.ts +1 -1
- package/src/functions/getName.ts +1 -1
- package/src/functions/getProfile.ts +1 -1
- package/src/functions/registerName.test.ts +59 -0
- package/src/functions/registerName.ts +38 -0
- package/src/functions/renewName.test.ts +44 -0
- package/src/functions/renewName.ts +22 -0
- package/src/index.ts +28 -25
- package/src/utils/fuses.ts +12 -4
- package/src/utils/registerHelpers.ts +107 -49
- package/src/utils/writeTx.ts +12 -2
- package/src/tests/populateTransaction.test.ts +0 -40
- package/src/tests/setup.ts +0 -58
- package/src/tests/signerInjection.test.ts +0 -46
- package/src/tests/withProvider.test.ts +0 -28
package/src/utils/writeTx.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { JsonRpcSigner } from '@ethersproject/providers'
|
|
2
2
|
import type { PopulatedTransaction } from 'ethers'
|
|
3
3
|
|
|
4
|
+
type CustomData = Record<string, any>
|
|
5
|
+
|
|
6
|
+
const withCustomData = <T extends object>(
|
|
7
|
+
tx: T,
|
|
8
|
+
customData: CustomData | undefined,
|
|
9
|
+
): (T & { customData: CustomData }) | T =>
|
|
10
|
+
customData ? { ...tx, customData } : tx
|
|
11
|
+
|
|
4
12
|
export default (signer: JsonRpcSigner, populate: boolean) =>
|
|
5
|
-
(tx: PopulatedTransaction) =>
|
|
6
|
-
populate
|
|
13
|
+
({ customData, ...tx }: PopulatedTransaction) =>
|
|
14
|
+
populate
|
|
15
|
+
? withCustomData(tx, customData)
|
|
16
|
+
: signer.sendTransaction(tx).then((r) => withCustomData(r, customData))
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ethers } from 'ethers'
|
|
2
|
-
import { ENS } from '..'
|
|
3
|
-
import setup from '../tests/setup'
|
|
4
|
-
|
|
5
|
-
let ENSInstance: ENS
|
|
6
|
-
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
7
|
-
let provider: ethers.providers.JsonRpcProvider
|
|
8
|
-
let accounts: string[]
|
|
9
|
-
|
|
10
|
-
beforeAll(async () => {
|
|
11
|
-
;({ ENSInstance, revert, provider } = await setup())
|
|
12
|
-
accounts = await provider.listAccounts()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
afterAll(async () => {
|
|
16
|
-
await revert()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
jest.setTimeout(20000)
|
|
20
|
-
|
|
21
|
-
describe('populateTransaction', () => {
|
|
22
|
-
beforeEach(async () => {
|
|
23
|
-
await revert()
|
|
24
|
-
})
|
|
25
|
-
it('should return a transaction successfully', async () => {
|
|
26
|
-
const tx = await ENSInstance.setName('fleek.eth')
|
|
27
|
-
expect(tx).toBeTruthy()
|
|
28
|
-
if (tx) {
|
|
29
|
-
await tx.wait()
|
|
30
|
-
expect(tx.hash).toBeTruthy()
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
it('should return a populated transaction successfully', async () => {
|
|
34
|
-
const tx = await ENSInstance.setName.populateTransaction('fleek.eth')
|
|
35
|
-
expect(tx).toBeTruthy()
|
|
36
|
-
if (tx) {
|
|
37
|
-
expect(tx).not.toHaveProperty('hash')
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
})
|
package/src/tests/setup.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { config } from 'dotenv'
|
|
2
|
-
import { ethers } from 'ethers'
|
|
3
|
-
import { resolve } from 'path'
|
|
4
|
-
import { ENS } from '../'
|
|
5
|
-
import { ContractName, SupportedNetworkId } from '../contracts/types'
|
|
6
|
-
|
|
7
|
-
config({
|
|
8
|
-
path: resolve(__dirname, '../../.env.local'),
|
|
9
|
-
override: true,
|
|
10
|
-
debug: true,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
const deploymentAddresses = JSON.parse(
|
|
14
|
-
process.env.DEPLOYMENT_ADDRESSES!,
|
|
15
|
-
) as Record<ContractName | 'ENSRegistry', string>
|
|
16
|
-
|
|
17
|
-
const createENS = (graphURI: string) =>
|
|
18
|
-
new ENS({
|
|
19
|
-
graphURI,
|
|
20
|
-
getContractAddress: (_: SupportedNetworkId) => (contractName) =>
|
|
21
|
-
deploymentAddresses[
|
|
22
|
-
contractName === 'ENSRegistryWithFallback'
|
|
23
|
-
? 'ENSRegistry'
|
|
24
|
-
: contractName
|
|
25
|
-
],
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
export default async (useReal?: boolean) => {
|
|
29
|
-
const graphURI = useReal
|
|
30
|
-
? 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten'
|
|
31
|
-
: 'http://localhost:8000/subgraphs/name/graphprotocol/ens'
|
|
32
|
-
|
|
33
|
-
const provider = new ethers.providers.JsonRpcProvider(
|
|
34
|
-
'http://localhost:8545',
|
|
35
|
-
1337,
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
let ENSInstance = createENS(graphURI)
|
|
39
|
-
await ENSInstance.setProvider(provider)
|
|
40
|
-
|
|
41
|
-
let snapshot = await provider.send('evm_snapshot', [])
|
|
42
|
-
|
|
43
|
-
const revert = async (customSnapshot?: any) => {
|
|
44
|
-
const snapshotToUse = customSnapshot || snapshot
|
|
45
|
-
await provider.send('evm_revert', [snapshotToUse])
|
|
46
|
-
if (parseInt(snapshot, 16) >= parseInt(snapshotToUse, 16)) {
|
|
47
|
-
snapshot = await provider.send('evm_snapshot', [])
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
ENSInstance = createENS(graphURI)
|
|
51
|
-
await ENSInstance.setProvider(provider)
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const createSnapshot = async () => await provider.send('evm_snapshot', [])
|
|
56
|
-
|
|
57
|
-
return { ENSInstance, revert, createSnapshot, provider }
|
|
58
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ContractTransaction, ethers } from 'ethers'
|
|
2
|
-
import { ENS } from '..'
|
|
3
|
-
import setup from '../tests/setup'
|
|
4
|
-
|
|
5
|
-
let ENSInstance: ENS
|
|
6
|
-
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
7
|
-
let provider: ethers.providers.JsonRpcProvider
|
|
8
|
-
let accounts: string[]
|
|
9
|
-
|
|
10
|
-
beforeAll(async () => {
|
|
11
|
-
;({ ENSInstance, revert, provider } = await setup())
|
|
12
|
-
accounts = await provider.listAccounts()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
afterAll(async () => {
|
|
16
|
-
await revert()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
jest.setTimeout(20000)
|
|
20
|
-
|
|
21
|
-
describe('Signer Injection', () => {
|
|
22
|
-
beforeEach(async () => {
|
|
23
|
-
await revert()
|
|
24
|
-
})
|
|
25
|
-
it('should return a transaction successfully for a custom signer', async () => {
|
|
26
|
-
const signer = provider.getSigner(accounts[3])
|
|
27
|
-
const tx = await ENSInstance.setName('fleek.eth', {
|
|
28
|
-
signer,
|
|
29
|
-
})
|
|
30
|
-
expect(tx).toBeTruthy()
|
|
31
|
-
if (tx) {
|
|
32
|
-
await tx.wait()
|
|
33
|
-
expect(tx.from).toBe(accounts[3])
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
it('should return a transaction succesfully for a custom signer index', async () => {
|
|
37
|
-
const tx = (await ENSInstance.setName('fleek.eth', {
|
|
38
|
-
addressOrIndex: 3,
|
|
39
|
-
})) as ContractTransaction
|
|
40
|
-
expect(tx).toBeTruthy()
|
|
41
|
-
if (tx) {
|
|
42
|
-
await tx.wait()
|
|
43
|
-
expect(tx.from).toBe(accounts[3])
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
})
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ethers } from 'ethers'
|
|
2
|
-
import { ENS } from '..'
|
|
3
|
-
import setup from '../tests/setup'
|
|
4
|
-
|
|
5
|
-
let ENSInstance: ENS
|
|
6
|
-
let providerFake: ethers.providers.JsonRpcProvider
|
|
7
|
-
|
|
8
|
-
beforeAll(async () => {
|
|
9
|
-
;({ ENSInstance } = await setup())
|
|
10
|
-
providerFake = new ethers.providers.JsonRpcProvider(
|
|
11
|
-
'http://localhost:34023',
|
|
12
|
-
'ropsten',
|
|
13
|
-
)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
describe('withProvider', () => {
|
|
17
|
-
it('should be able to use a new provider', async () => {
|
|
18
|
-
const addr = await ENSInstance.getAddr('with-profile.eth')
|
|
19
|
-
expect(addr).toBeTruthy()
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
await ENSInstance.withProvider(providerFake).getOwner('with-profile.eth')
|
|
23
|
-
expect(false).toBeTruthy()
|
|
24
|
-
} catch {
|
|
25
|
-
expect(true).toBeTruthy()
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
})
|