@webb-tools/tangle-substrate-types 0.5.8 → 0.5.12

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 (84) hide show
  1. package/README.md +11 -2
  2. package/{build/interfaces → interfaces}/augment-api-consts.d.ts +119 -24
  3. package/{ts-types/src/interfaces → interfaces}/augment-api-errors.d.ts +199 -342
  4. package/{build/interfaces → interfaces}/augment-api-events.d.ts +1365 -378
  5. package/{build/interfaces → interfaces}/augment-api-query.d.ts +718 -261
  6. package/{ts-types/src/interfaces → interfaces}/augment-api-tx.d.ts +1684 -442
  7. package/{ts-types/src/interfaces → interfaces}/lookup.d.ts +1425 -1093
  8. package/{build/interfaces → interfaces}/lookup.js +1443 -1111
  9. package/{build/interfaces → interfaces}/registry.d.ts +62 -75
  10. package/{ts-types/src/interfaces → interfaces}/types-lookup.d.ts +1233 -1128
  11. package/metadata/static-latest.d.ts +2 -0
  12. package/metadata/static-latest.js +7 -0
  13. package/package.json +1 -72
  14. package/.envrc +0 -5
  15. package/babel-config-cjs.cjs +0 -10
  16. package/build/interfaces/augment-api-errors.d.ts +0 -2144
  17. package/build/interfaces/augment-api-tx.d.ts +0 -2876
  18. package/build/interfaces/lookup.d.ts +0 -5908
  19. package/build/interfaces/types-lookup.d.ts +0 -6052
  20. package/build/metadata/static-latest.d.ts +0 -2
  21. package/build/metadata/static-latest.js +0 -7
  22. package/build/metadata/static-type.d.ts +0 -2
  23. package/build/metadata/static-type.js +0 -1
  24. package/build/package.json +0 -1
  25. package/playground.ts +0 -86
  26. package/polkadot-dev-configs/babel-config-cjs.cjs +0 -12
  27. package/polkadot-dev-configs/babel-general.cjs +0 -15
  28. package/polkadot-dev-configs/babel-plugins.cjs +0 -21
  29. package/polkadot-dev-configs/babel-presets.cjs +0 -33
  30. package/polkadot-dev-configs/babel-resolver.cjs +0 -14
  31. package/scripts/build.js +0 -134
  32. package/scripts/publish-types.js +0 -95
  33. package/scripts/updateMetadata.ts +0 -44
  34. package/src/examples/job_and_result_submission.ts +0 -203
  35. package/src/index.ts +0 -7
  36. package/src/interfaces/augment-api-consts.ts +0 -958
  37. package/src/interfaces/augment-api-errors.ts +0 -2152
  38. package/src/interfaces/augment-api-events.ts +0 -1465
  39. package/src/interfaces/augment-api-query.ts +0 -1629
  40. package/src/interfaces/augment-api-rpc.ts +0 -617
  41. package/src/interfaces/augment-api-runtime.ts +0 -308
  42. package/src/interfaces/augment-api-tx.ts +0 -1550
  43. package/src/interfaces/augment-api.ts +0 -10
  44. package/src/interfaces/augment-types.ts +0 -1256
  45. package/src/interfaces/lookup.ts +0 -5912
  46. package/src/interfaces/registry.ts +0 -433
  47. package/src/interfaces/types-lookup.ts +0 -6455
  48. package/src/metadata/metadata.json +0 -5
  49. package/src/metadata/static-latest.ts +0 -1
  50. package/src/metadata/static-type.ts +0 -3
  51. package/ts-types/playground.d.ts +0 -1
  52. package/ts-types/src/examples/job_and_result_submission.d.ts +0 -1
  53. package/ts-types/src/index.d.ts +0 -3
  54. package/ts-types/src/interfaces/augment-api-consts.d.ts +0 -950
  55. package/ts-types/src/interfaces/augment-api-events.d.ts +0 -2281
  56. package/ts-types/src/interfaces/augment-api-query.d.ts +0 -1660
  57. package/ts-types/src/interfaces/augment-api-rpc.d.ts +0 -679
  58. package/ts-types/src/interfaces/augment-api-runtime.d.ts +0 -363
  59. package/ts-types/src/interfaces/augment-api.d.ts +0 -7
  60. package/ts-types/src/interfaces/augment-types.d.ts +0 -1249
  61. package/ts-types/src/interfaces/registry.d.ts +0 -426
  62. package/ts-types/src/metadata/static-latest.d.ts +0 -2
  63. package/ts-types/src/metadata/static-type.d.ts +0 -2
  64. package/ts-types/tsconfig.tsbuildinfo +0 -1
  65. package/tsconfig.json +0 -36
  66. /package/{build/examples → examples}/job_and_result_submission.d.ts +0 -0
  67. /package/{build/examples → examples}/job_and_result_submission.js +0 -0
  68. /package/{build/index.d.ts → index.d.ts} +0 -0
  69. /package/{build/index.js → index.js} +0 -0
  70. /package/{build/interfaces → interfaces}/augment-api-consts.js +0 -0
  71. /package/{build/interfaces → interfaces}/augment-api-errors.js +0 -0
  72. /package/{build/interfaces → interfaces}/augment-api-events.js +0 -0
  73. /package/{build/interfaces → interfaces}/augment-api-query.js +0 -0
  74. /package/{build/interfaces → interfaces}/augment-api-rpc.d.ts +0 -0
  75. /package/{build/interfaces → interfaces}/augment-api-rpc.js +0 -0
  76. /package/{build/interfaces → interfaces}/augment-api-runtime.d.ts +0 -0
  77. /package/{build/interfaces → interfaces}/augment-api-runtime.js +0 -0
  78. /package/{build/interfaces → interfaces}/augment-api-tx.js +0 -0
  79. /package/{build/interfaces → interfaces}/augment-api.d.ts +0 -0
  80. /package/{build/interfaces → interfaces}/augment-api.js +0 -0
  81. /package/{build/interfaces → interfaces}/augment-types.d.ts +0 -0
  82. /package/{build/interfaces → interfaces}/augment-types.js +0 -0
  83. /package/{build/interfaces → interfaces}/registry.js +0 -0
  84. /package/{build/interfaces → interfaces}/types-lookup.js +0 -0
@@ -1 +0,0 @@
1
- {"name":"@webb-tools/tangle-substrate-types","version":"0.5.8","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","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"}}
package/playground.ts DELETED
@@ -1,86 +0,0 @@
1
- import { ApiPromise, WsProvider } from "@polkadot/api";
2
- import { Keyring } from "@polkadot/keyring";
3
- import { u128 } from "@polkadot/types";
4
- (async () => {
5
- const provider = new WsProvider('ws://127.0.0.1:9944');
6
- const api = await ApiPromise.create({ provider });
7
-
8
- await api.isReady;
9
- const registry = api.registry;
10
-
11
- const sr25519Keyring = new Keyring({ type: 'sr25519' });
12
-
13
- const ALICE = sr25519Keyring.addFromUri('//Alice');
14
- const BOB = sr25519Keyring.addFromUri('//Bob');
15
- const CHARLIE = sr25519Keyring.addFromUri('//Charlie');
16
- const creatingProfileTx = api.tx.roles.createProfile({
17
- Shared: {
18
- records: [
19
- {
20
- role: {
21
- Tss: {
22
- DfnsCGGMP21Secp256k1: {},
23
- },
24
- },
25
- },
26
- ],
27
- amount: new u128(registry, 100_000_000_000_000),
28
- },
29
- //@ts-ignore
30
- }, null);
31
-
32
- for (const signer of [ALICE, BOB, CHARLIE]) {
33
- await new Promise(async (resolve) => {
34
- console.log('Creating profile for:', signer.address);
35
- const unsub = await creatingProfileTx.signAndSend(signer, async ({ events = [], status }) => {
36
- if (status.isInBlock) {
37
- console.log(
38
- '[creatingProfileTx] Included at block hash',
39
- status.asInBlock.toHex()
40
- );
41
- console.log('[creatingProfileTx] Events:');
42
- events.forEach(({ event: { data, method, section } }) => {
43
- console.log(`\t${section}.${method}:: ${data}`);
44
- });
45
- unsub();
46
- resolve(void 0);
47
- }
48
- });
49
- });
50
- }
51
-
52
- const submittingJobTx = api.tx.jobs.submitJob({
53
- expiry: 100_000_000,
54
- ttl: 100_000_000,
55
- jobType: {
56
- DkgtssPhaseOne: {
57
- participants: [ALICE.address, BOB.address, CHARLIE.address],
58
- threshold: 2,
59
- permittedCaller: null,
60
- roleType: {
61
- DfnsCGGMP21Secp256k1: {},
62
- },
63
- },
64
- },
65
- });
66
-
67
- // Sign and send the transaction and wait for it to be included.
68
- await new Promise(async (resolve) => {
69
- const unsub = await submittingJobTx.signAndSend(ALICE, async ({ events = [], status }) => {
70
- if (status.isFinalized) {
71
- console.log(
72
- '[submittingJobTx] Included at block hash',
73
- status.asFinalized.toHex()
74
- );
75
- console.log('[submittingJobTx] Events:');
76
- events.forEach(({ event: { data, method, section } }) => {
77
- console.log(`\t${section}.${method}:: ${data}`);
78
- });
79
- unsub();
80
- resolve(void 0);
81
- }
82
- });
83
- });
84
-
85
- process.exit(0);
86
- })();
@@ -1,12 +0,0 @@
1
- // Copyright 2017-2023 @polkadot/dev authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- const general = require('./babel-general.cjs');
5
- const plugins = require('./babel-plugins.cjs');
6
- const presets = require('./babel-presets.cjs');
7
-
8
- module.exports = {
9
- ...general,
10
- plugins: plugins(false),
11
- presets: presets(false)
12
- };
@@ -1,15 +0,0 @@
1
- // Copyright 2017-2023 @polkadot/dev authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- module.exports = {
5
- assumptions: {
6
- // ensure that ?. & ?? uses !=/== null checks (not also undefined)
7
- noDocumentAll: true,
8
- // no extra defineProperty for private class fields
9
- privateFieldsAsProperties: true,
10
- // no extra defineProperty for public class fields
11
- setPublicClassFields: true
12
- }
13
- // Really want to switch this on, but not as of yet...
14
- // comments: false
15
- };
@@ -1,21 +0,0 @@
1
- // Copyright 2017-2023 @polkadot/dev authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- const resolver = require('./babel-resolver.cjs');
5
-
6
- module.exports = function (isEsm) {
7
- return resolver([
8
- '@babel/plugin-proposal-nullish-coalescing-operator',
9
- '@babel/plugin-proposal-numeric-separator',
10
- '@babel/plugin-proposal-optional-chaining',
11
- ['@babel/plugin-transform-runtime', {
12
- useESModules: isEsm
13
- }],
14
- '@babel/plugin-syntax-bigint',
15
- '@babel/plugin-syntax-dynamic-import',
16
- '@babel/plugin-syntax-import-assertions',
17
- '@babel/plugin-syntax-import-meta',
18
- '@babel/plugin-syntax-top-level-await',
19
- 'babel-plugin-styled-components'
20
- ]);
21
- };
@@ -1,33 +0,0 @@
1
- // Copyright 2017-2023 @polkadot/dev authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- const resolver = require('./babel-resolver.cjs');
5
-
6
- module.exports = function (isEsm) {
7
- return resolver([
8
- '@babel/preset-typescript',
9
- ['@babel/preset-react', {
10
- development: false,
11
- runtime: 'automatic'
12
- }],
13
- ['@babel/preset-env', {
14
- exclude: [
15
- // we don't want 2n ** 128n to Math.pow(2n, 128n)
16
- '@babel/plugin-transform-exponentiation-operator',
17
- // we don't want await import(...) to Promise.resolve(require(...))
18
- 'proposal-dynamic-import'
19
- ],
20
- modules: isEsm
21
- ? false
22
- : 'commonjs',
23
- targets: isEsm
24
- ? {
25
- node: '14'
26
- }
27
- : {
28
- browsers: '>0.25% and last 2 versions and not ie 11 and not OperaMini all',
29
- node: '14'
30
- }
31
- }]
32
- ]);
33
- };
@@ -1,14 +0,0 @@
1
- // Copyright 2017-2023 @polkadot/dev authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- module.exports = function resolver (input) {
5
- return Array.isArray(input)
6
- ? input
7
- .filter((plugin) => !!plugin)
8
- .map((plugin) =>
9
- Array.isArray(plugin)
10
- ? [require.resolve(plugin[0]), plugin[1]]
11
- : require.resolve(plugin)
12
- )
13
- : require.resolve(input);
14
- };
package/scripts/build.js DELETED
@@ -1,134 +0,0 @@
1
- #!/usr/bin/env node
2
- // Copyright 2017-2020 @polkadot/dev authors & contributors
3
- // SPDX-License-Identifier: Apache-2.0
4
-
5
- const babel = require('@babel/cli/lib/babel/dir').default;
6
- const path = require('path');
7
- const mkdirp = require('mkdirp');
8
- const { execSync } = require('child_process');
9
- const fs = require('fs-extra');
10
- const glob = require('glob');
11
- const glob2base = require('glob2base');
12
- const { Minimatch } = require('minimatch');
13
-
14
- function normalizePath(originalPath) {
15
- const normalizedPath = path.relative(process.cwd(), path.resolve(originalPath)).replace(/\\/g, '/');
16
-
17
- return /\/$/.test(normalizedPath) ? normalizedPath.slice(0, -1) : normalizedPath || '.';
18
- }
19
-
20
- const copySync = (src, dst) => {
21
- const normalizedSource = normalizePath(src);
22
- const normalizedOutputDir = normalizePath(dst);
23
- const baseDir = normalizePath(glob2base({ minimatch: new Minimatch(normalizedSource) }));
24
-
25
- glob
26
- .sync(normalizedSource, {
27
- follow: false,
28
- nodir: true,
29
- silent: true
30
- })
31
- .forEach((src) => {
32
- const dst = baseDir === '.' ? path.join(normalizedOutputDir, src) : src.replace(baseDir, normalizedOutputDir);
33
-
34
- if (dst !== src) {
35
- const stat = fs.statSync(src);
36
-
37
- if (stat.isDirectory()) {
38
- fs.ensureDirSync(dst);
39
- } else {
40
- fs.ensureDirSync(path.dirname(dst));
41
- fs.copySync(src, dst);
42
- }
43
-
44
- fs.chmodSync(dst, stat.mode);
45
- }
46
- });
47
- }
48
- const executeSync = (cmd) => {
49
- try {
50
- execSync(cmd, { stdio: 'inherit' });
51
- } catch (error) {
52
- process.exit(-1);
53
- }
54
- }
55
-
56
- const CPX = ['css', 'gif', 'hbs', 'jpg', 'js', 'png', 'svg', 'd.ts']
57
- .map((ext) => `src/**/*.${ext}`)
58
-
59
- function copyMiscFiles(dir) {
60
- // take the package.json defined in the module and strip out the '/build/'
61
- // in the export paths before copying to the output 'build' folder for publishing.
62
- // The 'build/' in the path exists for packages to resolve properly in builds.
63
- // e.g. the '@webb-tools/test-utils' package needs this to properly resolve
64
- // methods in '@webb-tools/sdk-core' because it imports '@webb-tools/utils'
65
- // which uses '@webb-tools/sdk-core' in its dependencies.
66
- const raw = fs.readFileSync('./package.json');
67
- const pkg = JSON.parse(raw);
68
- const pkgString = JSON.stringify(pkg);
69
- const newPkgString = pkgString.replaceAll('/build/', '/');
70
-
71
- // Extra logic for copying over other files (package.json for cjs modules)
72
- [...CPX]
73
- .concat(`./ts-types/src/**/*.d.ts`)
74
- .forEach((src) => copySync(src, 'build'));
75
-
76
- fs.writeFileSync('./build/package.json', newPkgString);
77
- }
78
-
79
- // @param module - the module system to use cjs or esm.
80
- async function buildBabel(dir, module = 'esm') {
81
- console.log('build babel for: ', module);
82
-
83
- // babel configuratiom
84
- const configFileName = `babel-config-cjs.cjs`;
85
-
86
- // Prefer to use local config over the root one.
87
- const conf = path.join(process.cwd(), configFileName);
88
-
89
- // Commonjs builds will exist in a '/cjs' directory for the package.
90
- await babel({
91
- babelOptions: {
92
- configFile: conf
93
- },
94
- cliOptions: {
95
- extensions: ['.ts'],
96
- filenames: ['src'],
97
- ignore: '**/*.d.ts',
98
- outDir: path.join(process.cwd(), 'build'),
99
- outFileExtension: '.js'
100
- }
101
- });
102
-
103
- copyMiscFiles(dir, module);
104
- }
105
-
106
-
107
- async function buildJs(dir) {
108
- if (!fs.existsSync(path.join(process.cwd(), '.skip-build'))) {
109
- const { name, version } = require(path.join(process.cwd(), './package.json'));
110
-
111
- console.log(`*** ${name} ${version}`);
112
-
113
- mkdirp.sync('build');
114
-
115
- await buildBabel(dir, 'cjs');
116
-
117
- // copyMiscFiles();
118
- }
119
- }
120
-
121
- async function buildMonorepo() {
122
- executeSync('yarn clean');
123
- executeSync('tsc --emitDeclarationOnly --outdir ./ts-types');
124
- await buildJs('types');
125
- }
126
-
127
- async function main() {
128
- buildMonorepo();
129
- }
130
-
131
- main().catch((error) => {
132
- console.error(error);
133
- process.exit(-1);
134
- });
@@ -1,95 +0,0 @@
1
-
2
- const path = require('path');
3
-
4
- const rimraf = require('rimraf');
5
- const { execSync: _execSync } = require('child_process');
6
-
7
- const fs = require('fs-extra');
8
- const glob = require('glob');
9
- const glob2base = require('glob2base');
10
- const { Minimatch } = require('minimatch');
11
-
12
- function normalizePath(originalPath) {
13
- const normalizedPath = path.relative(process.cwd(), path.resolve(originalPath)).replace(/\\/g, '/');
14
-
15
- return /\/$/.test(normalizedPath) ? normalizedPath.slice(0, -1) : normalizedPath || '.';
16
- }
17
-
18
- const copySync = (src, dst) => {
19
- const normalizedSource = normalizePath(src);
20
- const normalizedOutputDir = normalizePath(dst);
21
- const baseDir = normalizePath(glob2base({ minimatch: new Minimatch(normalizedSource) }));
22
-
23
- glob
24
- .sync(normalizedSource, {
25
- follow: false,
26
- nodir: true,
27
- silent: true
28
- })
29
- .forEach((src) => {
30
- const dst = baseDir === '.' ? path.join(normalizedOutputDir, src) : src.replace(baseDir, normalizedOutputDir);
31
-
32
- if (dst !== src) {
33
- const stat = fs.statSync(src);
34
-
35
- if (stat.isDirectory()) {
36
- fs.ensureDirSync(dst);
37
- } else {
38
- fs.ensureDirSync(path.dirname(dst));
39
- fs.copySync(src, dst);
40
- }
41
-
42
- fs.chmodSync(dst, stat.mode);
43
- }
44
- });
45
- }
46
-
47
- const execSync = (cmd) => _execSync(cmd, { stdio: 'inherit' });
48
-
49
- function npmGetVersion() {
50
- return JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf8')).version;
51
- }
52
-
53
- function npmPublish() {
54
- rimraf.sync('build/package.json');
55
-
56
- // take the package.json defined in the module and strip out the '/build/'
57
- // in the export paths before copying to the output 'build' folder for publishing.
58
- // The 'build/' in the path exists for packages to resolve properly while using
59
- // webb.js locally.
60
- // e.g. the '@webb-tools/test-utils' package needs this to properly resolve
61
- // methods in '@webb-tools/sdk-core' because it imports '@webb-tools/utils'
62
- // which uses '@webb-tools/sdk-core' in its dependencies.
63
- const raw = fs.readFileSync('./package.json');
64
- const pkg = JSON.parse(raw);
65
- const pkgString = JSON.stringify(pkg);
66
- const newPkgString = pkgString.replaceAll('/build/', '/');
67
-
68
- ['LICENSE', 'README.md'].forEach((file) => copySync(file, 'build'));
69
- fs.writeFileSync('./build/package.json', newPkgString);
70
- process.chdir('build');
71
- const tag = npmGetVersion().includes('-') ? '--tag beta' : '';
72
- let count = 1;
73
-
74
- while (true) {
75
- try {
76
- execSync(`npm publish --access public ${tag}`);
77
-
78
- break;
79
- } catch (error) {
80
- console.error(error);
81
- if (count < 5) {
82
- const end = Date.now() + 15000;
83
-
84
- console.error(`Publish failed on attempt ${count}/5. Retrying in 15s`);
85
- count++;
86
-
87
- while (Date.now() < end) {
88
- // just spin our wheels
89
- }
90
- }
91
- }
92
- }
93
- }
94
-
95
- npmPublish();
@@ -1,44 +0,0 @@
1
- // Copyright (C) 2020-2022 Acala Foundation.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // This file is part of Tangle.
5
- // Copyright (C) 2022-2024 Webb Technologies Inc.
6
- // SPDX-License-Identifier: Apache-2.0
7
- // This file has been modified by Webb Technologies Inc.
8
-
9
- /* eslint-disable @typescript-eslint/no-explicit-any */
10
-
11
- const pkg = require('websocket');
12
-
13
- const fs = require('fs');
14
-
15
- const { w3cwebsocket: WS } = pkg;
16
-
17
- const main = (): void => {
18
- const endpoint = 'ws://127.0.0.1:9944';
19
-
20
- console.log('Connecting to ', endpoint);
21
- const ws = new WS(endpoint);
22
-
23
- ws.onerror = (error: any) => {
24
- console.error('WebSocket error:', error);
25
- };
26
-
27
- ws.onopen = (): void => {
28
- ws.send('{"id":"1","jsonrpc":"2.0","method":"state_getMetadata","params":[]}');
29
- console.log("data send");
30
- };
31
-
32
- ws.onmessage = (msg: any): void => {
33
- const fullData = JSON.parse(msg.data);
34
- const metadata = fullData.result;
35
-
36
- fs.writeFileSync('./src/metadata/static-latest.ts', `export default '${metadata}'`);
37
- fs.writeFileSync('./src/metadata/metadata.json', JSON.stringify(fullData, null, 2));
38
-
39
- console.log('Done');
40
- process.exit(0);
41
- };
42
- };
43
-
44
- main();
@@ -1,203 +0,0 @@
1
- /**
2
- * @fileoverview
3
- * Example script to submit jobs/job results to Tangle chain, to test this script
4
- *
5
- * 1. Build the tangle node and start the local network using `./scripts/run-standalone-local.sh --clean`
6
- *
7
- * 2. Make sure you have the necessary dependencies installed. You can install them using npm:
8
- * ```
9
- * npm i
10
- * ```
11
- *
12
- * 3. Run the script using `cd types && npx ts-node src/playground.ts`
13
- *
14
- * 4. The script will connect to the tangle chain, create roles for alice & bob, then submit a job and job result.
15
- *
16
- */
17
- import { ApiPromise, WsProvider } from "@polkadot/api";
18
- import { Keyring } from "@polkadot/keyring";
19
- import { u8aToHex } from '@polkadot/util';
20
- import { keccak256AsU8a } from "@polkadot/util-crypto";
21
- import { ECPairFactory, ECPairAPI, TinySecp256k1Interface } from 'ecpair';
22
- const tinysecp: TinySecp256k1Interface = require('tiny-secp256k1');
23
- const ECPair: ECPairAPI = ECPairFactory(tinysecp);
24
-
25
- (async () => {
26
- // Establish connection to the Polkadot node
27
- const provider = new WsProvider('ws://127.0.0.1:9944');
28
- const api = await ApiPromise.create({ provider });
29
-
30
- // Wait for the API to be ready
31
- await api.isReady;
32
-
33
- // Initialize keyring for sr25519 type
34
- const sr25519Keyring = new Keyring({ type: 'sr25519' });
35
-
36
- // Define Alice and Bob's identities and role seeds
37
- const ALICE = sr25519Keyring.addFromUri('//Alice');
38
- const BOB = sr25519Keyring.addFromUri('//Bob');
39
-
40
- // Generated by subkey inspect //Alice --scheme Ecdsa
41
- const ALICE_ROLE_SEED = new Uint8Array(Buffer.from("cb6df9de1efca7a3998a8ead4e02159d5fa99c3e0d4fd6432667390bb4726854", "hex"));
42
- // Generated by subkey inspect //Bob --scheme Ecdsa
43
- const BOB_ROLE_SEED = new Uint8Array(Buffer.from("79c3b7fc0b7697b9414cb87adcb37317d1cab32818ae18c0e97ad76395d1fdcf", "hex"));
44
-
45
- // Print role seeds for reference
46
- console.log('ALICE_ROLE_SEED:', u8aToHex(ALICE_ROLE_SEED))
47
- console.log('BOB_ROLE_SEED:', u8aToHex(BOB_ROLE_SEED))
48
-
49
- // Generate role key pairs for Alice and Bob
50
- const ALICE_ROLE = ECPair.fromPrivateKey(Buffer.from(ALICE_ROLE_SEED));
51
- const BOB_ROLE = ECPair.fromPrivateKey(Buffer.from(BOB_ROLE_SEED));
52
- console.log('ALICE_ROLE:', u8aToHex(ALICE_ROLE.publicKey));
53
- console.log('BOB_ROLE:', u8aToHex(BOB_ROLE.publicKey));
54
-
55
- // Obtain the next available job ID from the chain
56
- const nextJobId = await api.query.jobs.nextJobId();
57
- const jobId = nextJobId;
58
-
59
- // Transaction to create a profile for Alice
60
- const creatingProfileTx = api.tx.roles.createProfile({
61
- Shared: {
62
- records: [
63
- {
64
- role: {
65
- Tss: {
66
- DfnsCGGMP21Secp256k1: {},
67
- },
68
- },
69
- },
70
- ],
71
- amount: "10000000000000000000",
72
- },
73
- }, 10);
74
-
75
- // Sign and send the transaction for creating Alice's profile
76
- await new Promise(async (resolve) => {
77
- const unsub = await creatingProfileTx.signAndSend(ALICE, async ({ events = [], status }) => {
78
- if (status.isInBlock) {
79
- console.log(
80
- '[creatingProfileTx] Included at block hash',
81
- status.asInBlock.toHex()
82
- );
83
- console.log('[creatingProfileTx] Events:');
84
- events.forEach(({ event: { data, method, section } }) => {
85
- console.log(`\t${section}.${method}:: ${data}`);
86
- });
87
- unsub();
88
- resolve(void 0);
89
- }
90
- });
91
- });
92
-
93
- // Sign and send the transaction for creating Bob's profile
94
- await new Promise(async (resolve) => {
95
- const unsub = await creatingProfileTx.signAndSend(BOB, async ({ events = [], status }) => {
96
- if (status.isInBlock) {
97
- console.log(
98
- '[creatingProfileTx] Included at block hash',
99
- status.asInBlock.toHex()
100
- );
101
- console.log('[creatingProfileTx] Events:');
102
- events.forEach(({ event: { data, method, section } }) => {
103
- console.log(`\t${section}.${method}:: ${data}`);
104
- });
105
- unsub();
106
- resolve(void 0);
107
- }
108
- });
109
- });
110
-
111
- // Transaction to submit a job
112
- const submittingJobTx = api.tx.jobs.submitJob({
113
- expiry: 100,
114
- ttl: 100,
115
- jobType: {
116
- DkgtssPhaseOne: {
117
- participants: [ALICE.address, BOB.address],
118
- threshold: 1,
119
- permittedCaller: null,
120
- roleType: {
121
- DfnsCGGMP21Secp256k1: {},
122
- },
123
- },
124
- },
125
- });
126
-
127
- // Sign and send the transaction for submitting the job
128
- await new Promise(async (resolve) => {
129
- const unsub = await submittingJobTx.signAndSend(ALICE, async ({ events = [], status }) => {
130
- if (status.isInBlock) {
131
- console.log(
132
- '[submittingJobTx] Included at block hash',
133
- status.asInBlock.toHex()
134
- );
135
- console.log('[submittingJobTx] Events:');
136
- events.forEach(({ event: { data, method, section } }) => {
137
- console.log(`\t${section}.${method}:: ${data}`);
138
- });
139
- unsub();
140
- resolve(void 0);
141
- }
142
- });
143
- });
144
-
145
- // Generate a new ECDSA KeyPair for DKG
146
- const dkgKeyPair = ECPair.fromPrivateKey(
147
- Buffer.from("eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619", "hex"),
148
- { compressed: false }
149
- );
150
-
151
- // Sign the compressed public key of the ECDSA KeyPair with the role keys of Alice and Bob
152
- const dkgPublicKey = dkgKeyPair.publicKey;
153
- const dkgPublicKeyHash = keccak256AsU8a(dkgPublicKey);
154
- const lowR = false;
155
- const signature1 = ALICE_ROLE.sign(Buffer.from(dkgPublicKeyHash), lowR);
156
- const signature2 = BOB_ROLE.sign(Buffer.from(dkgPublicKeyHash), lowR);
157
- const v = lowR ? 27 : 28;
158
-
159
- // Extend the signatures with recovery id
160
- const signature1Array = Array.from(signature1);
161
- const signature2Array = Array.from(signature2);
162
- signature1Array[64] = v;
163
- signature2Array[64] = v;
164
- console.assert(signature1Array.length == 65, 'Signature 1 length is invalid');
165
- console.assert(signature2Array.length == 65, 'Signature 2 length is invalid');
166
-
167
- // Transaction to submit job result
168
- const submittingJobResultTx = api.tx.jobs.submitJobResult({
169
- Tss: {
170
- DfnsCGGMP21Secp256k1: {},
171
- },
172
- }, jobId, {
173
- DKGPhaseOne: {
174
- key: u8aToHex(dkgPublicKey),
175
- signatures: [u8aToHex(Uint8Array.from(signature1Array)), u8aToHex(Uint8Array.from(signature2Array))],
176
- threshold: 1,
177
- signatureScheme: {
178
- Ecdsa: {},
179
- }
180
- }
181
- });
182
-
183
- // Sign and send the transaction for submitting the job result
184
- await new Promise(async (resolve) => {
185
- const unsub = await submittingJobResultTx.signAndSend(ALICE, async ({ events = [], status }) => {
186
- if (status.isInBlock) {
187
- console.log(
188
- '[submittingJobResultTx] Included at block hash',
189
- status.asInBlock.toHex()
190
- );
191
- console.log('[submittingJobResultTx] Events:');
192
- events.forEach(({ event: { data, method, section } }) => {
193
- console.log(`\t${section}.${method}:: ${data}`);
194
- });
195
- unsub();
196
- resolve(void 0);
197
- }
198
- });
199
- });
200
-
201
- // Exit process after completing all transactions
202
- process.exit(0);
203
- })();
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
1
- // This file is part of Tangle.
2
- // Copyright (C) 2022-2024 Webb Technologies Inc.
3
- // SPDX-License-Identifier: Apache-2.0
4
-
5
- import './interfaces/augment-api.js';
6
- import './interfaces/augment-types.js';
7
- import './interfaces/types-lookup.js';