@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.
Files changed (76) hide show
  1. package/dist/cjs/contracts/index.d.ts +8 -8
  2. package/dist/cjs/functions/burnFuses.d.ts +31 -4
  3. package/dist/cjs/functions/burnFuses.js +36 -6
  4. package/dist/cjs/functions/commitName.d.ts +26 -0
  5. package/dist/cjs/functions/commitName.js +24 -0
  6. package/dist/cjs/functions/getFuses.d.ts +2 -1
  7. package/dist/cjs/functions/getFuses.js +9 -18
  8. package/dist/cjs/functions/getHistory.d.ts +0 -30
  9. package/dist/cjs/functions/getHistory.js +3 -99
  10. package/dist/cjs/functions/getName.d.ts +2 -2
  11. package/dist/cjs/functions/getName.js +1 -1
  12. package/dist/cjs/functions/getProfile.js +1 -1
  13. package/dist/cjs/functions/getSpecificRecord.d.ts +4 -4
  14. package/dist/cjs/functions/registerName.d.ts +11 -0
  15. package/dist/cjs/functions/registerName.js +19 -0
  16. package/dist/cjs/functions/renewName.d.ts +6 -0
  17. package/dist/cjs/functions/renewName.js +10 -0
  18. package/dist/cjs/index.d.ts +24 -35
  19. package/dist/cjs/index.js +8 -3
  20. package/dist/cjs/utils/fuses.d.ts +18 -17
  21. package/dist/cjs/utils/fuses.js +10 -4
  22. package/dist/cjs/utils/registerHelpers.d.ts +44 -16
  23. package/dist/cjs/utils/registerHelpers.js +43 -15
  24. package/dist/cjs/utils/wrapperExpiry.d.ts +1 -1
  25. package/dist/cjs/utils/writeTx.d.ts +18 -1
  26. package/dist/cjs/utils/writeTx.js +4 -1
  27. package/dist/esm/contracts/index.d.ts +8 -8
  28. package/dist/esm/functions/burnFuses.d.ts +31 -4
  29. package/dist/esm/functions/burnFuses.js +36 -3
  30. package/dist/esm/functions/commitName.d.ts +26 -0
  31. package/dist/esm/functions/commitName.js +21 -0
  32. package/dist/esm/functions/getFuses.d.ts +2 -1
  33. package/dist/esm/functions/getFuses.js +10 -19
  34. package/dist/esm/functions/getHistory.d.ts +0 -30
  35. package/dist/esm/functions/getHistory.js +2 -96
  36. package/dist/esm/functions/getName.d.ts +2 -2
  37. package/dist/esm/functions/getName.js +1 -1
  38. package/dist/esm/functions/getProfile.js +1 -1
  39. package/dist/esm/functions/getSpecificRecord.d.ts +4 -4
  40. package/dist/esm/functions/registerName.d.ts +11 -0
  41. package/dist/esm/functions/registerName.js +16 -0
  42. package/dist/esm/functions/renewName.d.ts +6 -0
  43. package/dist/esm/functions/renewName.js +7 -0
  44. package/dist/esm/index.d.ts +24 -35
  45. package/dist/esm/index.js +8 -3
  46. package/dist/esm/utils/fuses.d.ts +18 -17
  47. package/dist/esm/utils/fuses.js +9 -3
  48. package/dist/esm/utils/registerHelpers.d.ts +44 -16
  49. package/dist/esm/utils/registerHelpers.js +40 -14
  50. package/dist/esm/utils/wrapperExpiry.d.ts +1 -1
  51. package/dist/esm/utils/writeTx.d.ts +18 -1
  52. package/dist/esm/utils/writeTx.js +4 -1
  53. package/package.json +19 -22
  54. package/src/functions/burnFuses.test.ts +123 -15
  55. package/src/functions/burnFuses.ts +101 -10
  56. package/src/functions/commitName.test.ts +61 -0
  57. package/src/functions/commitName.ts +36 -0
  58. package/src/functions/getFuses.test.ts +33 -15
  59. package/src/functions/getFuses.ts +13 -25
  60. package/src/functions/getHistory.test.ts +0 -84
  61. package/src/functions/getHistory.ts +2 -127
  62. package/src/functions/getName.test.ts +1 -1
  63. package/src/functions/getName.ts +1 -1
  64. package/src/functions/getProfile.ts +1 -1
  65. package/src/functions/registerName.test.ts +59 -0
  66. package/src/functions/registerName.ts +38 -0
  67. package/src/functions/renewName.test.ts +44 -0
  68. package/src/functions/renewName.ts +22 -0
  69. package/src/index.ts +28 -25
  70. package/src/utils/fuses.ts +12 -4
  71. package/src/utils/registerHelpers.ts +107 -49
  72. package/src/utils/writeTx.ts +12 -2
  73. package/src/tests/populateTransaction.test.ts +0 -40
  74. package/src/tests/setup.ts +0 -58
  75. package/src/tests/signerInjection.test.ts +0 -46
  76. package/src/tests/withProvider.test.ts +0 -28
@@ -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 ? tx : signer.sendTransaction(tx)
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
- })
@@ -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
- })