@webb-tools/tangle-substrate-types 0.5.12 → 0.9.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 (36) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +15 -17
  3. package/build/index.cjs +2 -0
  4. package/build/index.d.ts +20826 -0
  5. package/build/index.mjs +1 -0
  6. package/package.json +57 -1
  7. package/examples/job_and_result_submission.d.ts +0 -1
  8. package/examples/job_and_result_submission.js +0 -230
  9. package/index.d.ts +0 -3
  10. package/index.js +0 -5
  11. package/interfaces/augment-api-consts.d.ts +0 -1045
  12. package/interfaces/augment-api-consts.js +0 -3
  13. package/interfaces/augment-api-errors.d.ts +0 -2001
  14. package/interfaces/augment-api-errors.js +0 -3
  15. package/interfaces/augment-api-events.d.ts +0 -3268
  16. package/interfaces/augment-api-events.js +0 -3
  17. package/interfaces/augment-api-query.d.ts +0 -2117
  18. package/interfaces/augment-api-query.js +0 -3
  19. package/interfaces/augment-api-rpc.d.ts +0 -679
  20. package/interfaces/augment-api-rpc.js +0 -3
  21. package/interfaces/augment-api-runtime.d.ts +0 -363
  22. package/interfaces/augment-api-runtime.js +0 -3
  23. package/interfaces/augment-api-tx.d.ts +0 -4118
  24. package/interfaces/augment-api-tx.js +0 -3
  25. package/interfaces/augment-api.d.ts +0 -7
  26. package/interfaces/augment-api.js +0 -9
  27. package/interfaces/augment-types.d.ts +0 -1249
  28. package/interfaces/augment-types.js +0 -3
  29. package/interfaces/lookup.d.ts +0 -6240
  30. package/interfaces/lookup.js +0 -6248
  31. package/interfaces/registry.d.ts +0 -413
  32. package/interfaces/registry.js +0 -3
  33. package/interfaces/types-lookup.d.ts +0 -6157
  34. package/interfaces/types-lookup.js +0 -3
  35. package/metadata/static-latest.d.ts +0 -2
  36. package/metadata/static-latest.js +0 -7
@@ -0,0 +1 @@
1
+ import '@polkadot/types/types/registry';
package/package.json CHANGED
@@ -1 +1,57 @@
1
- {"name":"@webb-tools/tangle-substrate-types","version":"0.5.12","description":"Polkadot.js type definitions required for interacting with Webb's tangle network","main":"./index.js","types":"./index.d.ts","typings":"./index.d.ts","author":"Webb Developers <drew@webb.tools>","license":"Apache-2.0","type":"commonjs","publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"repository":"https://github.com/webb-tools/tangle.git","bugs":{"url":"https://github.com/webb-tools/tangle/issues"},"homepage":"https://github.com/webb-tools/tangle","dependencies":{"@babel/cli":"^7.23.9","@babel/core":"^7.24.0","@babel/plugin-proposal-nullish-coalescing-operator":"^7.18.6","@babel/plugin-proposal-numeric-separator":"^7.18.6","@babel/plugin-proposal-optional-chaining":"^7.20.7","@babel/plugin-syntax-bigint":"^7.8.3","@babel/plugin-syntax-dynamic-import":"^7.8.3","@babel/plugin-syntax-import-assertions":"^7.23.3","@babel/plugin-syntax-import-meta":"^7.10.4","@babel/plugin-syntax-top-level-await":"^7.14.5","@babel/plugin-transform-regenerator":"^7.23.3","@babel/plugin-transform-runtime":"^7.24.0","@babel/preset-env":"^7.24.0","@babel/preset-react":"^7.23.3","@babel/preset-typescript":"^7.23.3","@babel/register":"^7.23.7","@babel/runtime":"^7.24.0","@open-web3/orml-types":"^2.0.1","@polkadot/api":"^11.0.2","@polkadot/dev":"^0.78.11","@polkadot/typegen":"^11.0.2","@polkadot/types":"^11.0.2","babel-jest":"^29.7.0","babel-plugin-module-extension-resolver":"^1.0.0","babel-plugin-module-resolver":"^5.0.0","babel-plugin-styled-components":"^2.1.4","ecpair":"^2.1.0","elliptic":"^6.5.5","fs-extra":"^11.2.0","glob2base":"^0.0.12","minimatch":"^9.0.3","mkdirp":"^3.0.1","tiny-secp256k1":"^2.2.3"},"devDependencies":{"@types/websocket":"^1.0.10","prettier":"3.2.5","rimraf":"5.0.5","ts-node":"10.9.2","tsconfig-paths":"^4.2.0","typescript":"5.4.2","websocket":"^1.0.34"},"scripts":{"build":"node ./scripts/build.js","build:interfaces":"yarn build:interfaces:defs && yarn build:interfaces:chain && rm ./src/interfaces/index.ts && rm ./src/interfaces/types.ts","build:interfaces:defs":"npx ts-node node_modules/.bin/polkadot-types-from-defs --input ./src/interfaces --package @webb-tools/tangle-substrate-types --endpoint ./src/metadata/metadata.json","build:interfaces:chain":"npx ts-node node_modules/.bin/polkadot-types-from-chain --endpoint ./src/metadata/metadata.json --output ./src/interfaces","clean":"rm -rf build && rm -rf ts-types","publish-types":"node ./scripts/publish-types.js","update:metadata":"npx ts-node ./scripts/updateMetadata.ts"},"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"}
1
+ {
2
+ "name": "@webb-tools/tangle-substrate-types",
3
+ "version": "0.9.0",
4
+ "description": "Polkadot.js type definitions required for interacting with Webb's tangle network",
5
+ "author": "Webb Developers <drew@webb.tools>",
6
+ "license": "Apache-2.0",
7
+ "repository": "https://github.com/webb-tools/tangle.git",
8
+ "homepage": "https://github.com/webb-tools/tangle",
9
+ "files": [
10
+ "build"
11
+ ],
12
+ "main": "./build/index.cjs",
13
+ "module": "./build/index.mjs",
14
+ "types": "./build/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./build/index.d.ts",
18
+ "require": "./build/index.cjs",
19
+ "import": "./build/index.mjs",
20
+ "module": "./build/index.mjs"
21
+ }
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/webb-tools/tangle/issues"
29
+ },
30
+ "scripts": {
31
+ "build": "bunchee",
32
+ "build:interfaces": "yarn build:interfaces:defs && yarn build:interfaces:chain",
33
+ "build:interfaces:defs": "tsx node_modules/.bin/polkadot-types-from-defs --input ./src/interfaces --package @webb-tools/tangle-substrate-types --endpoint ws://127.0.0.1:9944",
34
+ "build:interfaces:chain": "tsx node_modules/.bin/polkadot-types-from-chain --output ./src/interfaces --package @webb-tools/tangle-substrate-types --endpoint ws://127.0.0.1:9944",
35
+ "clean": "rm -rf build",
36
+ "publish-types": "release-it patch",
37
+ "update:metadata": "tsx ./scripts/updateMetadata.ts"
38
+ },
39
+ "dependencies": {
40
+ "@polkadot/api": "^13.2.1",
41
+ "@polkadot/typegen": "^13.2.1",
42
+ "@polkadot/types": "^13.2.1",
43
+ "ecpair": "^2.1.0",
44
+ "tiny-secp256k1": "^2.2.3"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^22.6.1",
48
+ "@types/ws": "^8.5.12",
49
+ "bunchee": "^5.4.0",
50
+ "prettier": "3.2.5",
51
+ "release-it": "^17.6.0",
52
+ "tsx": "^4.19.1",
53
+ "typescript": "5.4.2",
54
+ "ws": "^8.18.0"
55
+ },
56
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
57
+ }
@@ -1 +0,0 @@
1
- export {};
@@ -1,230 +0,0 @@
1
- "use strict";
2
-
3
- var _api = require("@polkadot/api");
4
- var _keyring = require("@polkadot/keyring");
5
- var _util = require("@polkadot/util");
6
- var _utilCrypto = require("@polkadot/util-crypto");
7
- var _ecpair = require("ecpair");
8
- /**
9
- * @fileoverview
10
- * Example script to submit jobs/job results to Tangle chain, to test this script
11
- *
12
- * 1. Build the tangle node and start the local network using `./scripts/run-standalone-local.sh --clean`
13
- *
14
- * 2. Make sure you have the necessary dependencies installed. You can install them using npm:
15
- * ```
16
- * npm i
17
- * ```
18
- *
19
- * 3. Run the script using `cd types && npx ts-node src/playground.ts`
20
- *
21
- * 4. The script will connect to the tangle chain, create roles for alice & bob, then submit a job and job result.
22
- *
23
- */
24
-
25
- const tinysecp = require('tiny-secp256k1');
26
- const ECPair = (0, _ecpair.ECPairFactory)(tinysecp);
27
- (async () => {
28
- // Establish connection to the Polkadot node
29
- const provider = new _api.WsProvider('ws://127.0.0.1:9944');
30
- const api = await _api.ApiPromise.create({
31
- provider
32
- });
33
-
34
- // Wait for the API to be ready
35
- await api.isReady;
36
-
37
- // Initialize keyring for sr25519 type
38
- const sr25519Keyring = new _keyring.Keyring({
39
- type: 'sr25519'
40
- });
41
-
42
- // Define Alice and Bob's identities and role seeds
43
- const ALICE = sr25519Keyring.addFromUri('//Alice');
44
- const BOB = sr25519Keyring.addFromUri('//Bob');
45
-
46
- // Generated by subkey inspect //Alice --scheme Ecdsa
47
- const ALICE_ROLE_SEED = new Uint8Array(Buffer.from("cb6df9de1efca7a3998a8ead4e02159d5fa99c3e0d4fd6432667390bb4726854", "hex"));
48
- // Generated by subkey inspect //Bob --scheme Ecdsa
49
- const BOB_ROLE_SEED = new Uint8Array(Buffer.from("79c3b7fc0b7697b9414cb87adcb37317d1cab32818ae18c0e97ad76395d1fdcf", "hex"));
50
-
51
- // Print role seeds for reference
52
- console.log('ALICE_ROLE_SEED:', (0, _util.u8aToHex)(ALICE_ROLE_SEED));
53
- console.log('BOB_ROLE_SEED:', (0, _util.u8aToHex)(BOB_ROLE_SEED));
54
-
55
- // Generate role key pairs for Alice and Bob
56
- const ALICE_ROLE = ECPair.fromPrivateKey(Buffer.from(ALICE_ROLE_SEED));
57
- const BOB_ROLE = ECPair.fromPrivateKey(Buffer.from(BOB_ROLE_SEED));
58
- console.log('ALICE_ROLE:', (0, _util.u8aToHex)(ALICE_ROLE.publicKey));
59
- console.log('BOB_ROLE:', (0, _util.u8aToHex)(BOB_ROLE.publicKey));
60
-
61
- // Obtain the next available job ID from the chain
62
- const nextJobId = await api.query.jobs.nextJobId();
63
- const jobId = nextJobId;
64
-
65
- // Transaction to create a profile for Alice
66
- const creatingProfileTx = api.tx.roles.createProfile({
67
- Shared: {
68
- records: [{
69
- role: {
70
- Tss: {
71
- DfnsCGGMP21Secp256k1: {}
72
- }
73
- }
74
- }],
75
- amount: "10000000000000000000"
76
- }
77
- }, 10);
78
-
79
- // Sign and send the transaction for creating Alice's profile
80
- await new Promise(async resolve => {
81
- const unsub = await creatingProfileTx.signAndSend(ALICE, async ({
82
- events = [],
83
- status
84
- }) => {
85
- if (status.isInBlock) {
86
- console.log('[creatingProfileTx] Included at block hash', status.asInBlock.toHex());
87
- console.log('[creatingProfileTx] Events:');
88
- events.forEach(({
89
- event: {
90
- data,
91
- method,
92
- section
93
- }
94
- }) => {
95
- console.log(`\t${section}.${method}:: ${data}`);
96
- });
97
- unsub();
98
- resolve(void 0);
99
- }
100
- });
101
- });
102
-
103
- // Sign and send the transaction for creating Bob's profile
104
- await new Promise(async resolve => {
105
- const unsub = await creatingProfileTx.signAndSend(BOB, async ({
106
- events = [],
107
- status
108
- }) => {
109
- if (status.isInBlock) {
110
- console.log('[creatingProfileTx] Included at block hash', status.asInBlock.toHex());
111
- console.log('[creatingProfileTx] Events:');
112
- events.forEach(({
113
- event: {
114
- data,
115
- method,
116
- section
117
- }
118
- }) => {
119
- console.log(`\t${section}.${method}:: ${data}`);
120
- });
121
- unsub();
122
- resolve(void 0);
123
- }
124
- });
125
- });
126
-
127
- // Transaction to submit a job
128
- const submittingJobTx = api.tx.jobs.submitJob({
129
- expiry: 100,
130
- ttl: 100,
131
- jobType: {
132
- DkgtssPhaseOne: {
133
- participants: [ALICE.address, BOB.address],
134
- threshold: 1,
135
- permittedCaller: null,
136
- roleType: {
137
- DfnsCGGMP21Secp256k1: {}
138
- }
139
- }
140
- }
141
- });
142
-
143
- // Sign and send the transaction for submitting the job
144
- await new Promise(async resolve => {
145
- const unsub = await submittingJobTx.signAndSend(ALICE, async ({
146
- events = [],
147
- status
148
- }) => {
149
- if (status.isInBlock) {
150
- console.log('[submittingJobTx] Included at block hash', status.asInBlock.toHex());
151
- console.log('[submittingJobTx] Events:');
152
- events.forEach(({
153
- event: {
154
- data,
155
- method,
156
- section
157
- }
158
- }) => {
159
- console.log(`\t${section}.${method}:: ${data}`);
160
- });
161
- unsub();
162
- resolve(void 0);
163
- }
164
- });
165
- });
166
-
167
- // Generate a new ECDSA KeyPair for DKG
168
- const dkgKeyPair = ECPair.fromPrivateKey(Buffer.from("eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619", "hex"), {
169
- compressed: false
170
- });
171
-
172
- // Sign the compressed public key of the ECDSA KeyPair with the role keys of Alice and Bob
173
- const dkgPublicKey = dkgKeyPair.publicKey;
174
- const dkgPublicKeyHash = (0, _utilCrypto.keccak256AsU8a)(dkgPublicKey);
175
- const lowR = false;
176
- const signature1 = ALICE_ROLE.sign(Buffer.from(dkgPublicKeyHash), lowR);
177
- const signature2 = BOB_ROLE.sign(Buffer.from(dkgPublicKeyHash), lowR);
178
- const v = lowR ? 27 : 28;
179
-
180
- // Extend the signatures with recovery id
181
- const signature1Array = Array.from(signature1);
182
- const signature2Array = Array.from(signature2);
183
- signature1Array[64] = v;
184
- signature2Array[64] = v;
185
- console.assert(signature1Array.length == 65, 'Signature 1 length is invalid');
186
- console.assert(signature2Array.length == 65, 'Signature 2 length is invalid');
187
-
188
- // Transaction to submit job result
189
- const submittingJobResultTx = api.tx.jobs.submitJobResult({
190
- Tss: {
191
- DfnsCGGMP21Secp256k1: {}
192
- }
193
- }, jobId, {
194
- DKGPhaseOne: {
195
- key: (0, _util.u8aToHex)(dkgPublicKey),
196
- signatures: [(0, _util.u8aToHex)(Uint8Array.from(signature1Array)), (0, _util.u8aToHex)(Uint8Array.from(signature2Array))],
197
- threshold: 1,
198
- signatureScheme: {
199
- Ecdsa: {}
200
- }
201
- }
202
- });
203
-
204
- // Sign and send the transaction for submitting the job result
205
- await new Promise(async resolve => {
206
- const unsub = await submittingJobResultTx.signAndSend(ALICE, async ({
207
- events = [],
208
- status
209
- }) => {
210
- if (status.isInBlock) {
211
- console.log('[submittingJobResultTx] Included at block hash', status.asInBlock.toHex());
212
- console.log('[submittingJobResultTx] Events:');
213
- events.forEach(({
214
- event: {
215
- data,
216
- method,
217
- section
218
- }
219
- }) => {
220
- console.log(`\t${section}.${method}:: ${data}`);
221
- });
222
- unsub();
223
- resolve(void 0);
224
- }
225
- });
226
- });
227
-
228
- // Exit process after completing all transactions
229
- process.exit(0);
230
- })();
package/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import './interfaces/augment-api.js';
2
- import './interfaces/augment-types.js';
3
- import './interfaces/types-lookup.js';
package/index.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- require("./interfaces/augment-api.js");
4
- require("./interfaces/augment-types.js");
5
- require("./interfaces/types-lookup.js");