dcl-catalyst-client 15.0.1 → 17.0.1

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 (58) hide show
  1. package/.eslintignore +2 -1
  2. package/README.md +50 -44
  3. package/coverage/clover.xml +352 -442
  4. package/coverage/coverage-final.json +9 -14
  5. package/coverage/lcov-report/index.html +47 -32
  6. package/coverage/lcov.info +656 -892
  7. package/dist/package.json +77 -0
  8. package/package.json +16 -19
  9. package/scripts/generate-snapshots.ts +49 -0
  10. package/dist/CatalystAPI.d.ts +0 -5
  11. package/dist/CatalystAPI.js +0 -3
  12. package/dist/CatalystAPI.js.map +0 -1
  13. package/dist/CatalystClient.d.ts +0 -46
  14. package/dist/CatalystClient.js +0 -93
  15. package/dist/CatalystClient.js.map +0 -1
  16. package/dist/CatalystsList.d.ts +0 -13
  17. package/dist/CatalystsList.js +0 -78
  18. package/dist/CatalystsList.js.map +0 -1
  19. package/dist/ContentAPI.d.ts +0 -30
  20. package/dist/ContentAPI.js +0 -3
  21. package/dist/ContentAPI.js.map +0 -1
  22. package/dist/ContentClient.d.ts +0 -53
  23. package/dist/ContentClient.js +0 -175
  24. package/dist/ContentClient.js.map +0 -1
  25. package/dist/LambdasAPI.d.ts +0 -38
  26. package/dist/LambdasAPI.js +0 -3
  27. package/dist/LambdasAPI.js.map +0 -1
  28. package/dist/LambdasClient.d.ts +0 -25
  29. package/dist/LambdasClient.js +0 -112
  30. package/dist/LambdasClient.js.map +0 -1
  31. package/dist/index.d.ts +0 -7
  32. package/dist/index.js +0 -24
  33. package/dist/index.js.map +0 -1
  34. package/dist/utils/CatalystClientBuilder.d.ts +0 -5
  35. package/dist/utils/CatalystClientBuilder.js +0 -53
  36. package/dist/utils/CatalystClientBuilder.js.map +0 -1
  37. package/dist/utils/DeploymentBuilder.d.ts +0 -48
  38. package/dist/utils/DeploymentBuilder.js +0 -180
  39. package/dist/utils/DeploymentBuilder.js.map +0 -1
  40. package/dist/utils/Environment.d.ts +0 -1
  41. package/dist/utils/Environment.js +0 -5
  42. package/dist/utils/Environment.js.map +0 -1
  43. package/dist/utils/Helper.d.ts +0 -63
  44. package/dist/utils/Helper.js +0 -276
  45. package/dist/utils/Helper.js.map +0 -1
  46. package/dist/utils/catalystList.d.ts +0 -11
  47. package/dist/utils/catalystList.js +0 -81
  48. package/dist/utils/catalystList.js.map +0 -1
  49. package/dist/utils/common.d.ts +0 -1
  50. package/dist/utils/common.js +0 -12
  51. package/dist/utils/common.js.map +0 -1
  52. package/dist/utils/fetcher.d.ts +0 -11
  53. package/dist/utils/fetcher.js +0 -57
  54. package/dist/utils/fetcher.js.map +0 -1
  55. package/dist/utils/index.d.ts +0 -4
  56. package/dist/utils/index.js +0 -21
  57. package/dist/utils/index.js.map +0 -1
  58. package/scripts/generate-catalysts-list.ts +0 -32
package/.eslintignore CHANGED
@@ -2,4 +2,5 @@ dist
2
2
  jest.config.js
3
3
  scripts
4
4
  coverage
5
- src/CatalystsList.ts
5
+ src/contracts-snapshots/data.ts
6
+ docs
package/README.md CHANGED
@@ -8,66 +8,72 @@ Welcome to the Catalyst Client library. This client can be used to interact with
8
8
  npm install dcl-catalyst-client
9
9
  ```
10
10
 
11
- ## Usage
11
+ ### Implementations
12
12
 
13
- You can check the entire API [here](src/CatalystAPI.ts).
13
+ The examples in this document illustrate the implementation of common workflows using the second version of `catalyst-client`.
14
14
 
15
- This library depends on two other Decentraland libraries:
15
+ #### Connect to random Catalyst
16
16
 
17
- - [Decentraland Crypto](https://github.com/decentraland/decentraland-crypto/)
18
- - [Catalyst Commons](https://github.com/decentraland/catalyst-commons/)
17
+ The following section outlines the steps to successfully connect to a random catalyst when there is no need to communicate with any particular node.
19
18
 
20
- ### Deploying
19
+ ```javascript
20
+ import { connectedToRandomCatalyst } from 'dcl-catalyst-client'
21
+ import { getCatalystServersFromCache } from './../dist/contracts-snapshots'
22
+ import { createFetchComponent } from './../dist/client/utils/fetcher'
21
23
 
22
- One of the most important aspects, is the ability to deploy new entities. Here is an example of how to do it:
24
+ // Connect to a catalyst randomly choosen from the catalyst-client snapshot
25
+ const fetcher = createFetchComponent()
26
+ const nodes = getCatalystServersFromCache('mainnet')
27
+ const catalyst = await connectedToRandomCatalyst(nodes, { fetcher })
23
28
 
29
+ if (!catalyst) {
30
+ console.log('No catalyst node is available right now')
31
+ return
32
+ }
33
+
34
+ const catalystInfo = await catalyst.fetchAbout()
35
+ const contentClient = await catalyst.getContentClient()
36
+ const lambdasClient = await catalyst.getLambdasClient()
24
37
  ```
25
- import { CatalystClient, DeploymentBuilder } from 'dcl-catalyst-client'
26
- import { EntityType } from '@dcl/schemas'
27
- import { Authenticator } from '@dcl/crypto'
28
38
 
39
+ #### Deploy an entity
29
40
 
30
- // This is up to you. You will need to figure out how to make the owner of the pointer sign the entity id
31
- const { signature, address } = await sign(entityId)
41
+ The following section outlines the steps to deploy an entity to the Decentraland network.
32
42
 
33
- // You can then create a simple auth chain like this, or a more complex one.
34
- const authChain = Authenticator.createSimpleAuthChain(entityId, address, signature)
43
+ ```javascript
44
+ import { Authenticator } from '@dcl/crypto'
45
+ import { createCatalystClient } from 'dcl-catalyst-client'
46
+ import { createFetchComponent } from 'dcl-catalyst-client/dist/client/utils/fetcher'
47
+ import * as EthCrypto from 'eth-crypto'
48
+ import { EntityType } from '@dcl/schemas'
49
+ import { PROFILE_METADATA, PROFILE_POINTERS } from './data/inputs'
35
50
 
36
- // Build the client
37
- const catalyst = await CatalystClient.connectedToCatalystIn('mainnet')
38
- // Note: this operation is expensive, so try to store the created catalyst client somewhere, instead of re-building for each every request
51
+ async function resolveClient() {
52
+ // Build the client, Node is harcoded for simplicity
53
+ const fetcher = createFetchComponent()
54
+ const catalyst = await createCatalystClient({ url: 'https://peer-ec2.decentraland.org', fetcher })
39
55
 
40
- // Build entity and group all files
41
- const { entityId, files } = await catalyst.buildEntity({type: EntityType.*, pointers, files: contentFiles, metadata })
56
+ return await catalyst.getContentClient()
57
+ }
42
58
 
43
- // Build the deploy data
44
- const deployData = { entityId, files, authChain }
59
+ const identity = { privateKey: 'privatekey', address: '0xfbf2b0392d969db533189b596708ba9ba7f4e3cd' }
45
60
 
46
- // Deploy the actual entity
47
- await catalyst.deployEntity(deployData)
61
+ const content = await resolveClient()
48
62
 
49
- ```
63
+ const { entityId, files } = await content.buildEntity({
64
+ type: EntityType.PROFILE,
65
+ pointers: PROFILE_POINTERS,
66
+ metadata: PROFILE_METADATA
67
+ })
50
68
 
51
- ## Contributing
69
+ // This is up to you. You will need to figure out how to make the owner of the pointer sign the entity id
70
+ const messageHash = Authenticator.createEthereumMessageHash(entityId)
71
+ const signature = EthCrypto.sign(identity.privateKey, Buffer.from(messageHash).toString('hex'))
52
72
 
53
- ### Build and test
73
+ // You can then create a simple auth chain like this, or a more complex one.
74
+ const authChain = Authenticator.createSimpleAuthChain(entityId, identity.address, signature)
75
+ const deployData = { entityId, files, authChain }
54
76
 
77
+ // Deploy the actual entity
78
+ await content.deploy(deployData)
55
79
  ```
56
- npm install
57
- npm run build
58
- npm run test
59
- ```
60
-
61
- ### [Releases](https://registry.npmjs.org/dcl-catalyst-client)
62
-
63
- #### Stable Releases
64
-
65
- To publish a new release, a tag following [SemVer](https://semver.org/) must be done in `master` branch following the format: `MAJOR.MINOR.PATCH` and that will trigger a Github Workflow that publishes the new version of the library, tagging it as `latest`.
66
-
67
- #### Master Releases
68
-
69
- Every commit to `master` branch triggers a NPM Publish with the beta version following the convention `NEXT_MAJOR.NEXT_MINOR.NEXT_PATCH-TIMESTAMP.commit-COMMIT_SHA`, tagging it as `next`.
70
-
71
- #### Tag Releases
72
-
73
- If you need to publish a NPM package in a work in progress commit, then you can create a git tag, and that will trigger an automatically NPM publish following the convention `NEXT_MAJOR.NEXT_MINOR.NEXT_PATCH-TIMESTAMP.commit-COMMIT_SHA` and tagging it on NPM with your custom tag: `tag-CUSTOM_TAG`.