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.
- package/.eslintignore +2 -1
- package/README.md +50 -44
- package/coverage/clover.xml +352 -442
- package/coverage/coverage-final.json +9 -14
- package/coverage/lcov-report/index.html +47 -32
- package/coverage/lcov.info +656 -892
- package/dist/package.json +77 -0
- package/package.json +16 -19
- package/scripts/generate-snapshots.ts +49 -0
- package/dist/CatalystAPI.d.ts +0 -5
- package/dist/CatalystAPI.js +0 -3
- package/dist/CatalystAPI.js.map +0 -1
- package/dist/CatalystClient.d.ts +0 -46
- package/dist/CatalystClient.js +0 -93
- package/dist/CatalystClient.js.map +0 -1
- package/dist/CatalystsList.d.ts +0 -13
- package/dist/CatalystsList.js +0 -78
- package/dist/CatalystsList.js.map +0 -1
- package/dist/ContentAPI.d.ts +0 -30
- package/dist/ContentAPI.js +0 -3
- package/dist/ContentAPI.js.map +0 -1
- package/dist/ContentClient.d.ts +0 -53
- package/dist/ContentClient.js +0 -175
- package/dist/ContentClient.js.map +0 -1
- package/dist/LambdasAPI.d.ts +0 -38
- package/dist/LambdasAPI.js +0 -3
- package/dist/LambdasAPI.js.map +0 -1
- package/dist/LambdasClient.d.ts +0 -25
- package/dist/LambdasClient.js +0 -112
- package/dist/LambdasClient.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/utils/CatalystClientBuilder.d.ts +0 -5
- package/dist/utils/CatalystClientBuilder.js +0 -53
- package/dist/utils/CatalystClientBuilder.js.map +0 -1
- package/dist/utils/DeploymentBuilder.d.ts +0 -48
- package/dist/utils/DeploymentBuilder.js +0 -180
- package/dist/utils/DeploymentBuilder.js.map +0 -1
- package/dist/utils/Environment.d.ts +0 -1
- package/dist/utils/Environment.js +0 -5
- package/dist/utils/Environment.js.map +0 -1
- package/dist/utils/Helper.d.ts +0 -63
- package/dist/utils/Helper.js +0 -276
- package/dist/utils/Helper.js.map +0 -1
- package/dist/utils/catalystList.d.ts +0 -11
- package/dist/utils/catalystList.js +0 -81
- package/dist/utils/catalystList.js.map +0 -1
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.js +0 -12
- package/dist/utils/common.js.map +0 -1
- package/dist/utils/fetcher.d.ts +0 -11
- package/dist/utils/fetcher.js +0 -57
- package/dist/utils/fetcher.js.map +0 -1
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.js +0 -21
- package/dist/utils/index.js.map +0 -1
- package/scripts/generate-catalysts-list.ts +0 -32
package/.eslintignore
CHANGED
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
|
-
|
|
11
|
+
### Implementations
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The examples in this document illustrate the implementation of common workflows using the second version of `catalyst-client`.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
#### Connect to random Catalyst
|
|
16
16
|
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
41
|
-
|
|
56
|
+
return await catalyst.getContentClient()
|
|
57
|
+
}
|
|
42
58
|
|
|
43
|
-
|
|
44
|
-
const deployData = { entityId, files, authChain }
|
|
59
|
+
const identity = { privateKey: 'privatekey', address: '0xfbf2b0392d969db533189b596708ba9ba7f4e3cd' }
|
|
45
60
|
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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`.
|