dcl-catalyst-client 15.0.0 → 17.0.0

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 (59) hide show
  1. package/.eslintignore +2 -1
  2. package/.github/workflows/build-and-publish.yml +13 -74
  3. package/README.md +50 -44
  4. package/coverage/clover.xml +352 -442
  5. package/coverage/coverage-final.json +9 -14
  6. package/coverage/lcov-report/index.html +47 -32
  7. package/coverage/lcov.info +656 -892
  8. package/dist/package.json +77 -0
  9. package/package.json +16 -19
  10. package/scripts/generate-snapshots.ts +49 -0
  11. package/dist/CatalystAPI.d.ts +0 -5
  12. package/dist/CatalystAPI.js +0 -3
  13. package/dist/CatalystAPI.js.map +0 -1
  14. package/dist/CatalystClient.d.ts +0 -46
  15. package/dist/CatalystClient.js +0 -93
  16. package/dist/CatalystClient.js.map +0 -1
  17. package/dist/CatalystsList.d.ts +0 -13
  18. package/dist/CatalystsList.js +0 -78
  19. package/dist/CatalystsList.js.map +0 -1
  20. package/dist/ContentAPI.d.ts +0 -30
  21. package/dist/ContentAPI.js +0 -3
  22. package/dist/ContentAPI.js.map +0 -1
  23. package/dist/ContentClient.d.ts +0 -53
  24. package/dist/ContentClient.js +0 -175
  25. package/dist/ContentClient.js.map +0 -1
  26. package/dist/LambdasAPI.d.ts +0 -38
  27. package/dist/LambdasAPI.js +0 -3
  28. package/dist/LambdasAPI.js.map +0 -1
  29. package/dist/LambdasClient.d.ts +0 -25
  30. package/dist/LambdasClient.js +0 -112
  31. package/dist/LambdasClient.js.map +0 -1
  32. package/dist/index.d.ts +0 -7
  33. package/dist/index.js +0 -24
  34. package/dist/index.js.map +0 -1
  35. package/dist/utils/CatalystClientBuilder.d.ts +0 -5
  36. package/dist/utils/CatalystClientBuilder.js +0 -53
  37. package/dist/utils/CatalystClientBuilder.js.map +0 -1
  38. package/dist/utils/DeploymentBuilder.d.ts +0 -48
  39. package/dist/utils/DeploymentBuilder.js +0 -180
  40. package/dist/utils/DeploymentBuilder.js.map +0 -1
  41. package/dist/utils/Environment.d.ts +0 -1
  42. package/dist/utils/Environment.js +0 -5
  43. package/dist/utils/Environment.js.map +0 -1
  44. package/dist/utils/Helper.d.ts +0 -63
  45. package/dist/utils/Helper.js +0 -276
  46. package/dist/utils/Helper.js.map +0 -1
  47. package/dist/utils/catalystList.d.ts +0 -11
  48. package/dist/utils/catalystList.js +0 -81
  49. package/dist/utils/catalystList.js.map +0 -1
  50. package/dist/utils/common.d.ts +0 -1
  51. package/dist/utils/common.js +0 -12
  52. package/dist/utils/common.js.map +0 -1
  53. package/dist/utils/fetcher.d.ts +0 -11
  54. package/dist/utils/fetcher.js +0 -57
  55. package/dist/utils/fetcher.js.map +0 -1
  56. package/dist/utils/index.d.ts +0 -4
  57. package/dist/utils/index.js +0 -21
  58. package/dist/utils/index.js.map +0 -1
  59. 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
@@ -1,3 +1,5 @@
1
+ name: build and publish
2
+
1
3
  on:
2
4
  push:
3
5
  branches:
@@ -7,78 +9,15 @@ on:
7
9
  types:
8
10
  - created
9
11
 
10
- name: build-deploy
11
- jobs:
12
- check_and_build:
13
- runs-on: ubuntu-latest
14
- outputs:
15
- s3_bucket_key: ${{ steps.publish_package.outputs.s3-bucket-key }}
16
- steps:
17
- - uses: actions/checkout@v2
18
- - name: install
19
- run: yarn install --frozen-lockfile
20
- - name: build
21
- run: yarn build
22
- - name: test
23
- run: yarn test
24
- - name: validate
25
- run: yarn lint:check
26
- - name: publish packages
27
- uses: menduz/oddish-action@master
28
- id: publish_package
29
- with:
30
- registry-url: 'https://registry.npmjs.org'
31
- access: public
32
- ## use action runId instead of current date to generate snapshot numbers
33
- deterministic-snapshot: true
34
-
35
- ## publish every package to s3
36
- s3-bucket: ${{ secrets.SDK_TEAM_S3_BUCKET }}
37
- s3-bucket-key-prefix: '@dcl/${{ github.event.repository_name }}/branch/${{ steps.myref.outputs.branch }}'
38
-
39
- ## inform gitlab after publishing to proceed with CDN propagation
40
- gitlab-token: ${{ secrets.GITLAB_TOKEN }}
41
- gitlab-pipeline-url: ${{ secrets.GITLAB_URL }}
42
- env:
43
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44
- AWS_DEFAULT_REGION: us-east-1
45
- AWS_ACCESS_KEY_ID: ${{ secrets.SDK_TEAM_AWS_ID }}
46
- AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }}
47
12
 
48
- notify_deployment:
49
- needs: [check_and_build]
50
- if: ${{ github.event.pull_request.number }}
51
- runs-on: ubuntu-latest
52
- name: Deployment Notification
53
- steps:
54
- - name: Find Comment
55
- uses: peter-evans/find-comment@v1
56
- id: fc
57
- with:
58
- issue-number: ${{ github.event.pull_request.number }}
59
- comment-author: 'github-actions[bot]'
60
- body-includes: Test this pull request
61
-
62
- - name: Get the current branch name
63
- shell: bash
64
- run: node -e "console.log('::set-output name=branch::' + ('${{github.head_ref}}' || '$GITHUB_REF'.replace('refs/heads/','')) )"
65
- id: myref
66
-
67
- - name: Generate S3 URL
68
- id: url-generator
69
- run: |
70
- body=$(echo ${{ secrets.SDK_TEAM_S3_BASE_URL }})/${{ needs.check_and_build.outputs.s3_bucket_key }}
71
- echo ::set-output name=body::$body
72
-
73
- - name: Create or update comment
74
- uses: peter-evans/create-or-update-comment@v1
75
- with:
76
- comment-id: ${{ steps.fc.outputs.comment-id }}
77
- issue-number: ${{ github.event.pull_request.number }}
78
- body: |
79
- # Test this pull request
80
- - The package can be tested by running
81
- ```bash
82
- yarn upgrade "${{ steps.url-generator.outputs.body }}"
83
- ```
84
- edit-mode: replace
13
+ jobs:
14
+ build-publish:
15
+ uses: decentraland/platform-actions/.github/workflows/libs-build-and-publish.yml@main
16
+ secrets:
17
+ SDK_TEAM_S3_BUCKET: ${{ secrets.SDK_TEAM_S3_BUCKET }}
18
+ GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
19
+ GITLAB_URL: ${{ secrets.GITLAB_URL }}
20
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
21
+ SDK_TEAM_AWS_ID: ${{ secrets.SDK_TEAM_AWS_ID }}
22
+ SDK_TEAM_AWS_SECRET: ${{ secrets.SDK_TEAM_AWS_SECRET }}
23
+ SDK_TEAM_S3_BASE_URL: ${{ secrets.SDK_TEAM_S3_BASE_URL }}
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`.