dash-platform-sdk 1.0.1 → 1.0.3
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/README.md +180 -19
- package/dist/main.js +1 -1
- package/dist/main.js.LICENSE.txt +12 -0
- package/package.json +8 -3
- package/.github/workflows/build.yml +0 -35
- package/.github/workflows/publish.yml +0 -20
- package/babel.config.js +0 -3
- package/index.js +0 -76
- package/proto/platform.proto +0 -1768
- package/src/dapi/getDocuments.js +0 -33
- package/src/dapi/getStatus.js +0 -19
- package/test/unit/index.spec.js +0 -64
- package/webpack.config.js +0 -18
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
9
|
+
|
|
10
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
11
|
+
|
|
12
|
+
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
package/package.json
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dash-platform-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "dist/main.js",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@babel/core": "^7.26.10",
|
|
7
7
|
"@babel/preset-env": "^7.26.9",
|
|
8
8
|
"babel-jest": "^29.7.0",
|
|
9
|
-
"buffer": "^6.0.3",
|
|
10
9
|
"grpc-tools": "^1.13.0",
|
|
11
10
|
"grpc_tools_node_protoc_ts": "^5.3.3",
|
|
12
11
|
"isomorphic-ws": "^5.0.0",
|
|
13
12
|
"jest": "^29.7.0",
|
|
14
13
|
"nice-grpc-web": "^3.3.6",
|
|
14
|
+
"standard": "^17.1.2",
|
|
15
15
|
"stream-browserify": "^3.0.0",
|
|
16
|
+
"terser-webpack-plugin": "^5.3.14",
|
|
16
17
|
"ts-node": "^10.9.2",
|
|
17
18
|
"ts-proto": "^2.6.1",
|
|
18
19
|
"tsc": "^2.0.4",
|
|
19
20
|
"typescript": "^5.8.2",
|
|
20
21
|
"webpack": "^5.98.0",
|
|
21
22
|
"webpack-cli": "^6.0.1",
|
|
23
|
+
"buffer": "^6.0.3",
|
|
22
24
|
"ws": "^8.18.1"
|
|
23
25
|
},
|
|
24
26
|
"scripts": {
|
|
25
27
|
"build": "webpack",
|
|
26
28
|
"build:grpc": "yarn proto:generate && yarn proto:transpile",
|
|
29
|
+
"lint": "standard",
|
|
27
30
|
"test": "jest",
|
|
28
31
|
"test:debug": "node --inspect-brk ./node_modules/.bin/jest",
|
|
29
32
|
"proto:generate": "grpc_tools_node_protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./proto/generated --ts_proto_opt=forceLong=string,env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false --proto_path=./proto ./proto/platform.proto",
|
|
@@ -31,6 +34,8 @@
|
|
|
31
34
|
},
|
|
32
35
|
"dependencies": {
|
|
33
36
|
"@scure/base": "^1.2.4",
|
|
34
|
-
"cbor": "^10.0.3"
|
|
37
|
+
"cbor": "^10.0.3",
|
|
38
|
+
"pshenmic-dpp": "^1.0.3",
|
|
39
|
+
"rfc4648": "^1.5.4"
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
name: Build
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ "master" ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ "master" ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
|
|
13
|
-
strategy:
|
|
14
|
-
matrix:
|
|
15
|
-
node-version: [18.x, 20.x, 22.x]
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
|
|
20
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
-
uses: actions/setup-node@v4
|
|
22
|
-
with:
|
|
23
|
-
node-version: ${{ matrix.node-version }}
|
|
24
|
-
|
|
25
|
-
- name: Install dependencies
|
|
26
|
-
run: |
|
|
27
|
-
yarn
|
|
28
|
-
|
|
29
|
-
- name: Generate GRPC client
|
|
30
|
-
run: |
|
|
31
|
-
yarn build:grpc
|
|
32
|
-
|
|
33
|
-
- name: Build with Webpack
|
|
34
|
-
run: |
|
|
35
|
-
yarn build
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
name: Publish package to NPM
|
|
2
|
-
on:
|
|
3
|
-
release:
|
|
4
|
-
types: [published]
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- uses: actions/checkout@v4
|
|
10
|
-
# Setup .npmrc file to publish to npm
|
|
11
|
-
- uses: actions/setup-node@v4
|
|
12
|
-
with:
|
|
13
|
-
node-version: '20.x'
|
|
14
|
-
registry-url: 'https://registry.npmjs.org'
|
|
15
|
-
- run: yarn
|
|
16
|
-
- run: yarn build:grpc
|
|
17
|
-
- run: yarn build
|
|
18
|
-
- run: yarn publish
|
|
19
|
-
env:
|
|
20
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/babel.config.js
DELETED
package/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PlatformDefinition,
|
|
3
|
-
} from './proto/generated/platform.js';
|
|
4
|
-
import {createChannel, createClient} from 'nice-grpc-web';
|
|
5
|
-
import getStatus from './src/dapi/getStatus'
|
|
6
|
-
import getDocuments from './src/dapi/getDocuments'
|
|
7
|
-
|
|
8
|
-
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
9
|
-
|
|
10
|
-
const DEFAULT_OPTIONS = {
|
|
11
|
-
network: 'testnet',
|
|
12
|
-
dapiUrls: ['https://52.33.28.47:1443'],
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default class DashPlatformSDK {
|
|
16
|
-
|
|
17
|
-
constructor (options = DEFAULT_OPTIONS) {
|
|
18
|
-
this.network = options.network;
|
|
19
|
-
this.dapiUrls = options.dapiUrls
|
|
20
|
-
|
|
21
|
-
const [dapiUrl] = this.dapiUrls
|
|
22
|
-
|
|
23
|
-
const channel = createChannel(dapiUrl);
|
|
24
|
-
|
|
25
|
-
this.client = createClient(
|
|
26
|
-
PlatformDefinition,
|
|
27
|
-
channel,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
this.documents = {
|
|
31
|
-
get: getDocuments.bind(this)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
this.utils = {
|
|
35
|
-
getStatus: getStatus.bind(this),
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
* const options = { network: 'testnet', nodeUrl: 'https://seed-1.pshenmic.dev' }
|
|
40
|
-
* const sdk = new DashPlatformSDK()
|
|
41
|
-
*
|
|
42
|
-
* const identity = await sdk.identities.getByIdentifier('HVfqSPfdmiHsrajx7EmErGnV597uYdH3JGhvwpVDcdAT')
|
|
43
|
-
* const identity = await sdk.identities.getByPublicKeyHash('b381c47c9b164ace0c5a525afab443a9fe636f3c')
|
|
44
|
-
* const identity = await sdk.identities.getByName('pshenmic.dash')
|
|
45
|
-
*
|
|
46
|
-
* const identityContractNonce = await sdk.identities.getIdentityContractNonce(identity, dataContract)
|
|
47
|
-
*
|
|
48
|
-
* const document = await sdk.documents.create(identity, documentType, {key: 'value'}, identityContractNonce)
|
|
49
|
-
* const [document] = await sdk.documents.get(dataContract, query)
|
|
50
|
-
*
|
|
51
|
-
* const stateTransition = await sdk.stateTransition.fromDocument(document)
|
|
52
|
-
*
|
|
53
|
-
* const [identityPublicKey] = sdk.identities.getIdentityPublicKeys()
|
|
54
|
-
*
|
|
55
|
-
* await stateTransition.sign(identityPublicKey)
|
|
56
|
-
*
|
|
57
|
-
* console.log(stateTransition.hash().toString('hex'), stateTransition.toBuffer().toString('hex')
|
|
58
|
-
*
|
|
59
|
-
* await sdk.stateTransition.broadcast(stateTransition)
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* */
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// load identity
|
|
68
|
-
// get identity by identifier
|
|
69
|
-
// getIdentityKeys
|
|
70
|
-
// getIdentityByPublicKeyHash
|
|
71
|
-
// create document (6 STs)
|
|
72
|
-
// getDocuments
|
|
73
|
-
// getIdentityNonce
|
|
74
|
-
// getIdentityContractNonce
|
|
75
|
-
// broadcastStateTransition
|
|
76
|
-
// get data contract
|