dash-platform-sdk 1.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.
@@ -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/index.js ADDED
@@ -0,0 +1,76 @@
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
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "dash-platform-sdk",
3
+ "version": "1.0.0",
4
+ "main": "dist/main.js",
5
+ "devDependencies": {
6
+ "@babel/core": "^7.26.10",
7
+ "@babel/preset-env": "^7.26.9",
8
+ "babel-jest": "^29.7.0",
9
+ "buffer": "^6.0.3",
10
+ "grpc-tools": "^1.13.0",
11
+ "grpc_tools_node_protoc_ts": "^5.3.3",
12
+ "isomorphic-ws": "^5.0.0",
13
+ "jest": "^29.7.0",
14
+ "nice-grpc-web": "^3.3.6",
15
+ "stream-browserify": "^3.0.0",
16
+ "ts-node": "^10.9.2",
17
+ "ts-proto": "^2.6.1",
18
+ "tsc": "^2.0.4",
19
+ "typescript": "^5.8.2",
20
+ "webpack": "^5.98.0",
21
+ "webpack-cli": "^6.0.1",
22
+ "ws": "^8.18.1"
23
+ },
24
+ "scripts": {
25
+ "build": "webpack",
26
+ "build:grpc": "yarn proto:generate && yarn proto:transpile",
27
+ "test": "jest",
28
+ "test:debug": "node --inspect-brk ./node_modules/.bin/jest",
29
+ "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",
30
+ "proto:transpile": "tsc ./proto/generated/platform.ts"
31
+ },
32
+ "dependencies": {
33
+ "@scure/base": "^1.2.4",
34
+ "cbor": "^10.0.3"
35
+ },
36
+ "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
37
+ }