@prosopo/scripts 0.1.17 → 0.1.18

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 (133) hide show
  1. package/package.json +54 -54
  2. package/dist/cli/index.d.ts +0 -2
  3. package/dist/cli/index.d.ts.map +0 -1
  4. package/dist/cli/index.js +0 -145
  5. package/dist/cli/index.js.map +0 -1
  6. package/dist/contract/deploy/dapp.d.ts +0 -3
  7. package/dist/contract/deploy/dapp.d.ts.map +0 -1
  8. package/dist/contract/deploy/dapp.js +0 -41
  9. package/dist/contract/deploy/dapp.js.map +0 -1
  10. package/dist/contract/deploy/index.d.ts +0 -3
  11. package/dist/contract/deploy/index.d.ts.map +0 -1
  12. package/dist/contract/deploy/index.js +0 -16
  13. package/dist/contract/deploy/index.js.map +0 -1
  14. package/dist/contract/deploy/protocol.d.ts +0 -3
  15. package/dist/contract/deploy/protocol.d.ts.map +0 -1
  16. package/dist/contract/deploy/protocol.js +0 -53
  17. package/dist/contract/deploy/protocol.js.map +0 -1
  18. package/dist/contract/import.d.ts +0 -4
  19. package/dist/contract/import.d.ts.map +0 -1
  20. package/dist/contract/import.js +0 -21
  21. package/dist/contract/import.js.map +0 -1
  22. package/dist/contract/index.d.ts +0 -3
  23. package/dist/contract/index.d.ts.map +0 -1
  24. package/dist/contract/index.js +0 -16
  25. package/dist/contract/index.js.map +0 -1
  26. package/dist/index.d.ts +0 -5
  27. package/dist/index.d.ts.map +0 -1
  28. package/dist/index.js +0 -18
  29. package/dist/index.js.map +0 -1
  30. package/dist/scripts/addCopyrightNotice.d.ts +0 -2
  31. package/dist/scripts/addCopyrightNotice.d.ts.map +0 -1
  32. package/dist/scripts/addCopyrightNotice.js +0 -103
  33. package/dist/scripts/addCopyrightNotice.js.map +0 -1
  34. package/dist/scripts/bytesToHex.d.ts +0 -2
  35. package/dist/scripts/bytesToHex.d.ts.map +0 -1
  36. package/dist/scripts/bytesToHex.js +0 -22
  37. package/dist/scripts/bytesToHex.js.map +0 -1
  38. package/dist/scripts/convertAccount.d.ts +0 -2
  39. package/dist/scripts/convertAccount.d.ts.map +0 -1
  40. package/dist/scripts/convertAccount.js +0 -37
  41. package/dist/scripts/convertAccount.js.map +0 -1
  42. package/dist/scripts/encodeDecode.d.ts +0 -2
  43. package/dist/scripts/encodeDecode.d.ts.map +0 -1
  44. package/dist/scripts/encodeDecode.js +0 -64
  45. package/dist/scripts/encodeDecode.js.map +0 -1
  46. package/dist/scripts/generateMnemonic.d.ts +0 -2
  47. package/dist/scripts/generateMnemonic.d.ts.map +0 -1
  48. package/dist/scripts/generateMnemonic.js +0 -28
  49. package/dist/scripts/generateMnemonic.js.map +0 -1
  50. package/dist/scripts/getBalance.d.ts +0 -2
  51. package/dist/scripts/getBalance.d.ts.map +0 -1
  52. package/dist/scripts/getBalance.js +0 -15
  53. package/dist/scripts/getBalance.js.map +0 -1
  54. package/dist/scripts/getBlock.d.ts +0 -2
  55. package/dist/scripts/getBlock.d.ts.map +0 -1
  56. package/dist/scripts/getBlock.js +0 -31
  57. package/dist/scripts/getBlock.js.map +0 -1
  58. package/dist/scripts/getContractInfoOf.d.ts +0 -2
  59. package/dist/scripts/getContractInfoOf.d.ts.map +0 -1
  60. package/dist/scripts/getContractInfoOf.js +0 -52
  61. package/dist/scripts/getContractInfoOf.js.map +0 -1
  62. package/dist/scripts/getExistentialDeposit.d.ts +0 -2
  63. package/dist/scripts/getExistentialDeposit.d.ts.map +0 -1
  64. package/dist/scripts/getExistentialDeposit.js +0 -39
  65. package/dist/scripts/getExistentialDeposit.js.map +0 -1
  66. package/dist/scripts/getRandomProvider.d.ts +0 -2
  67. package/dist/scripts/getRandomProvider.d.ts.map +0 -1
  68. package/dist/scripts/getRandomProvider.js +0 -38
  69. package/dist/scripts/getRandomProvider.js.map +0 -1
  70. package/dist/scripts/getStorage.d.ts +0 -2
  71. package/dist/scripts/getStorage.d.ts.map +0 -1
  72. package/dist/scripts/getStorage.js +0 -33
  73. package/dist/scripts/getStorage.js.map +0 -1
  74. package/dist/scripts/getValidators.d.ts +0 -2
  75. package/dist/scripts/getValidators.d.ts.map +0 -1
  76. package/dist/scripts/getValidators.js +0 -31
  77. package/dist/scripts/getValidators.js.map +0 -1
  78. package/dist/scripts/hash.d.ts +0 -2
  79. package/dist/scripts/hash.d.ts.map +0 -1
  80. package/dist/scripts/hash.js +0 -55
  81. package/dist/scripts/hash.js.map +0 -1
  82. package/dist/scripts/hexToBytes.d.ts +0 -2
  83. package/dist/scripts/hexToBytes.d.ts.map +0 -1
  84. package/dist/scripts/hexToBytes.js +0 -18
  85. package/dist/scripts/hexToBytes.js.map +0 -1
  86. package/dist/scripts/mnemonicFromSeed.d.ts +0 -2
  87. package/dist/scripts/mnemonicFromSeed.d.ts.map +0 -1
  88. package/dist/scripts/mnemonicFromSeed.js +0 -30
  89. package/dist/scripts/mnemonicFromSeed.js.map +0 -1
  90. package/dist/scripts/populateTxAndSign.d.ts +0 -2
  91. package/dist/scripts/populateTxAndSign.d.ts.map +0 -1
  92. package/dist/scripts/populateTxAndSign.js +0 -65
  93. package/dist/scripts/populateTxAndSign.js.map +0 -1
  94. package/dist/scripts/sendFunds.d.ts +0 -2
  95. package/dist/scripts/sendFunds.d.ts.map +0 -1
  96. package/dist/scripts/sendFunds.js +0 -32
  97. package/dist/scripts/sendFunds.js.map +0 -1
  98. package/dist/setup/dapp.d.ts +0 -4
  99. package/dist/setup/dapp.d.ts.map +0 -1
  100. package/dist/setup/dapp.js +0 -35
  101. package/dist/setup/dapp.js.map +0 -1
  102. package/dist/setup/funds.d.ts +0 -23
  103. package/dist/setup/funds.d.ts.map +0 -1
  104. package/dist/setup/funds.js +0 -100
  105. package/dist/setup/funds.js.map +0 -1
  106. package/dist/setup/index.d.ts +0 -5
  107. package/dist/setup/index.d.ts.map +0 -1
  108. package/dist/setup/index.js +0 -18
  109. package/dist/setup/index.js.map +0 -1
  110. package/dist/setup/provider.d.ts +0 -5
  111. package/dist/setup/provider.d.ts.map +0 -1
  112. package/dist/setup/provider.js +0 -84
  113. package/dist/setup/provider.js.map +0 -1
  114. package/dist/setup/setup.d.ts +0 -2
  115. package/dist/setup/setup.d.ts.map +0 -1
  116. package/dist/setup/setup.js +0 -150
  117. package/dist/setup/setup.js.map +0 -1
  118. package/dist/util/exec.d.ts +0 -10
  119. package/dist/util/exec.d.ts.map +0 -1
  120. package/dist/util/exec.js +0 -58
  121. package/dist/util/exec.js.map +0 -1
  122. package/dist/util/index.d.ts +0 -4
  123. package/dist/util/index.d.ts.map +0 -1
  124. package/dist/util/index.js +0 -17
  125. package/dist/util/index.js.map +0 -1
  126. package/dist/util/loadContractFiles.d.ts +0 -4
  127. package/dist/util/loadContractFiles.d.ts.map +0 -1
  128. package/dist/util/loadContractFiles.js +0 -54
  129. package/dist/util/loadContractFiles.js.map +0 -1
  130. package/dist/util/updateEnv.d.ts +0 -4
  131. package/dist/util/updateEnv.d.ts.map +0 -1
  132. package/dist/util/updateEnv.js +0 -45
  133. package/dist/util/updateEnv.js.map +0 -1
@@ -1,31 +0,0 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { ApiPromise, WsProvider } from '@polkadot/api';
15
- const providers = {
16
- kusama: { endpoint: 'wss://kusama-rpc.polkadot.io/' },
17
- polkadot: { endpoint: 'wss://rpc.polkadot.io' },
18
- };
19
- async function run() {
20
- // Construct
21
- for (const provider in providers) {
22
- const wsProvider = new WsProvider(providers[provider].endpoint);
23
- const api = await ApiPromise.create({ provider: wsProvider });
24
- // Do something
25
- const validators = await api.query.staking.validators.keys();
26
- console.log(`${validators.length} validators on ${provider}`);
27
- }
28
- process.exit();
29
- }
30
- run();
31
- //# sourceMappingURL=getValidators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getValidators.js","sourceRoot":"","sources":["../../src/scripts/getValidators.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEtD,MAAM,SAAS,GAAG;IACd,MAAM,EAAE,EAAE,QAAQ,EAAE,+BAA+B,EAAE;IACrD,QAAQ,EAAE,EAAE,QAAQ,EAAE,uBAAuB,EAAE;CAClD,CAAA;AAED,KAAK,UAAU,GAAG;IACd,YAAY;IACZ,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAC9B,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC/D,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;QAE7D,eAAe;QACf,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,kBAAkB,QAAQ,EAAE,CAAC,CAAA;KAChE;IACD,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC;AAED,GAAG,EAAE,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hash.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/scripts/hash.ts"],"names":[],"mappings":""}
@@ -1,55 +0,0 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { blake2AsHex, blake2AsU8a, keccakAsHex, keccakAsU8a } from '@polkadot/util-crypto';
15
- import { decodeAddress, encodeAddress } from '@polkadot/keyring';
16
- import { hexToBn, hexToString, hexToU8a, isHex, stringToHex, stringToU8a, u8aToBn, u8aToFloat, u8aToHex, u8aToString, } from '@polkadot/util';
17
- function main() {
18
- const fns = {
19
- arg: (arg) => arg,
20
- isHex,
21
- hexToString,
22
- hexToU8a,
23
- hexToBn,
24
- stringToHex,
25
- stringToU8a,
26
- blake2AsHex,
27
- blake2AsU8a,
28
- keccakAsHex,
29
- keccakAsU8a,
30
- decodeAddress,
31
- encodeAddress,
32
- u8aToHex,
33
- u8aToBn,
34
- u8aToFloat,
35
- u8aToString,
36
- jsonParse: JSON.parse,
37
- jsonStringify: JSON.stringify,
38
- };
39
- const arg = process.argv.slice(2)[0];
40
- const max = Object.keys(fns).reduce((max, key) => Math.max(max, key.length), 0);
41
- for (const fnName in fns) {
42
- const fn = fns[fnName];
43
- let result = '';
44
- try {
45
- result = fn(arg);
46
- }
47
- catch (e) {
48
- // ignore
49
- }
50
- // https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
51
- console.log(`\x1b[40m\x1b[33m${fnName.padEnd(max + 1, ' ')}:\x1b[37m ${result}`);
52
- }
53
- }
54
- main();
55
- //# sourceMappingURL=hash.js.map
@@ -1 +0,0 @@
1
- {"version":3,"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E;QACtB,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;QACtB,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,IAAI;YACA,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;SACnB;QAAC,OAAO,CAAC,EAAE;YACR,SAAS;SACZ;QACD,wFAAwF;QACxF,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,MAAM,EAAE,CAAC,CAAA;KACnF;AACL,CAAC;AAED,IAAI,EAAE,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hexToBytes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hexToBytes.d.ts","sourceRoot":"","sources":["../../src/scripts/hexToBytes.ts"],"names":[],"mappings":""}
@@ -1,18 +0,0 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { hexToU8a } from '@polkadot/util';
15
- const arg = process.argv.slice(2)[0].trim();
16
- console.log(`arg : ${arg}`);
17
- console.log(hexToU8a(arg));
18
- //# sourceMappingURL=hexToBytes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hexToBytes.js","sourceRoot":"","sources":["../../src/scripts/hexToBytes.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAC3C,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAA;AAEpC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=mnemonicFromSeed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mnemonicFromSeed.d.ts","sourceRoot":"","sources":["../../src/scripts/mnemonicFromSeed.ts"],"names":[],"mappings":""}
@@ -1,30 +0,0 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { Keyring } from '@polkadot/keyring';
15
- import { entropyToMnemonic } from '@polkadot/util-crypto/mnemonic/bip39';
16
- import { hexToU8a } from '@polkadot/util';
17
- async function mnemonic() {
18
- const keyring = new Keyring({ type: 'ed25519', ss58Format: 5 });
19
- const u8Entropy = hexToU8a('0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e');
20
- const mnemonic = entropyToMnemonic(u8Entropy);
21
- console.log(`Mnemonic: ${mnemonic}`);
22
- const account = keyring.addFromMnemonic(mnemonic);
23
- console.log(`Address: ${account.address}`);
24
- const account2 = keyring.addFromSeed(hexToU8a('0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e'));
25
- console.log(`Address: ${account2.address}`);
26
- const ss58Format = 5;
27
- }
28
- mnemonic();
29
- //0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e
30
- //# sourceMappingURL=mnemonicFromSeed.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mnemonicFromSeed.js","sourceRoot":"","sources":["../../src/scripts/mnemonicFromSeed.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,KAAK,UAAU,QAAQ;IACnB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;IAC/D,MAAM,SAAS,GAAG,QAAQ,CAAC,oEAAoE,CAAC,CAAA;IAChG,MAAM,QAAQ,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAC7C,OAAO,CAAC,GAAG,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;IACjD,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,oEAAoE,CAAC,CAAC,CAAA;IACpH,OAAO,CAAC,GAAG,CAAC,YAAY,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3C,MAAM,UAAU,GAAG,CAAC,CAAA;AACxB,CAAC;AAED,QAAQ,EAAE,CAAA;AAEV,oEAAoE"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=populateTxAndSign.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"populateTxAndSign.d.ts","sourceRoot":"","sources":["../../src/scripts/populateTxAndSign.ts"],"names":[],"mappings":""}
@@ -1,65 +0,0 @@
1
- // Copyright 2021-2022 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- // #!/usr/bin/env node
15
- // import { hexToString, hexToU8a, u8aToHex } from '@polkadot/util'
16
- // import { Environment } from '../src/env'
17
- // import { blake2AsU8a, encodeAddress } from '@polkadot/util-crypto'
18
- // import { Option, GenericAccountId } from '@polkadot/types'
19
- //
20
- // require('dotenv').config()
21
- export {};
22
- // async function main () {
23
- // const env = new Environment(undefined)
24
- // await env.isReady()
25
- // const contractApi = new ProsopoContractApi(env)
26
- // const serviceOrigin = 'http://localhost:9229'
27
- // const dappContract = '5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y'
28
- // const mnemonic = '//Alice'
29
- //
30
- // if (mnemonic) {
31
- // const signerPair = env.network.keyring.addFromMnemonic(mnemonic)
32
- // const senderAddress = signerPair.address
33
- // const davePair = env.network.keyring.addFromMnemonic('//Dave')
34
- // console.log(davePair.address)
35
- // // let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
36
- // const args = [serviceOrigin, dappContract, new Option(env.network.registry, GenericAccountId)]
37
- // const method = 'dappRegister'
38
- // const encodedArgs = contractApi.encodeArgs(method, args)
39
- // console.log(new Option(env.network.registry, GenericAccountId).toU8a())
40
- // // console.log(u8aToHex(encodedArgs));
41
- // console.log(encodedArgs)
42
- // const populatedTx = await env.contract?.populateTransaction.dappRegister(...encodedArgs, { gasLimit: 8705000000 })
43
- // console.log(encodeAddress(populatedTx!.callParams!.dest))
44
- // console.log(populatedTx!.callParams!.gasLimit.toString())
45
- // console.log(u8aToHex(populatedTx!.callParams!.inputData))
46
- // const payload = u8aToHex(populatedTx!.callParams!.inputData)
47
- // console.log('Payload generated with no signer present in environment\n')
48
- // console.log(`Payload: ${payload}`)
49
- // await env.changeSigner(mnemonic)
50
- // const signature = signerPair.sign(hexToU8a(payload), { withType: true })
51
- // console.log(`Signature: ${u8aToHex(signature)}`)
52
- // console.log(`Decoding 0x42b45efa: ${hexToString('0x42b45efa')}`)
53
- // console.log(`Decoding 0x1501: ${hexToString('0x1501')}`)
54
- // // decodeU8a
55
- // console.log(new Option(env.network.registry, GenericAccountId, null).toU8a())
56
- // process.exit(0)
57
- // }
58
- // }
59
- //
60
- // main()
61
- // .catch((error) => {
62
- // console.error(error)
63
- // process.exit()
64
- // })
65
- //# sourceMappingURL=populateTxAndSign.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"populateTxAndSign.js","sourceRoot":"","sources":["../../src/scripts/populateTxAndSign.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,sBAAsB;AACtB,mEAAmE;AACnE,2CAA2C;AAC3C,qEAAqE;AACrE,6DAA6D;AAC7D,EAAE;AACF,6BAA6B;;AAE7B,2BAA2B;AAC3B,6CAA6C;AAC7C,0BAA0B;AAC1B,sDAAsD;AACtD,oDAAoD;AACpD,8EAA8E;AAC9E,iCAAiC;AACjC,EAAE;AACF,sBAAsB;AACtB,2EAA2E;AAC3E,mDAAmD;AACnD,yEAAyE;AACzE,wCAAwC;AACxC,+FAA+F;AAC/F,yGAAyG;AACzG,wCAAwC;AACxC,mEAAmE;AACnE,kFAAkF;AAClF,iDAAiD;AACjD,mCAAmC;AACnC,6HAA6H;AAC7H,oEAAoE;AACpE,oEAAoE;AACpE,oEAAoE;AACpE,uEAAuE;AACvE,mFAAmF;AACnF,6CAA6C;AAC7C,2CAA2C;AAC3C,mFAAmF;AACnF,2DAA2D;AAC3D,2EAA2E;AAC3E,mEAAmE;AACnE,uBAAuB;AACvB,wFAAwF;AACxF,0BAA0B;AAC1B,QAAQ;AACR,IAAI;AACJ,EAAE;AACF,SAAS;AACT,0BAA0B;AAC1B,+BAA+B;AAC/B,yBAAyB;AACzB,SAAS"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=sendFunds.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendFunds.d.ts","sourceRoot":"","sources":["../../src/scripts/sendFunds.ts"],"names":[],"mappings":""}
@@ -1,32 +0,0 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { BN } from '@polkadot/util';
15
- import { Environment } from '@prosopo/env';
16
- import { config } from 'dotenv';
17
- import { defaultConfig, getPairType, getSs58Format } from '@prosopo/cli';
18
- import { getPair } from '@prosopo/common';
19
- import { sendFunds } from '../setup/index.js';
20
- config();
21
- async function main(account) {
22
- const pair = await getPair(getPairType(), getSs58Format(), '//Alice');
23
- const env = new Environment(pair, defaultConfig());
24
- await env.isReady();
25
- await sendFunds(env, account, 'Provider', new BN(100000000000000000));
26
- process.exit();
27
- }
28
- main(process.argv.slice(2)[0].trim()).catch((error) => {
29
- console.error(error);
30
- process.exit();
31
- });
32
- //# sourceMappingURL=sendFunds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendFunds.js","sourceRoot":"","sources":["../../src/scripts/sendFunds.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,MAAM,EAAE,CAAA;AAER,KAAK,UAAU,IAAI,CAAC,OAAe;IAC/B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,EAAE,aAAa,EAAE,EAAE,SAAS,CAAC,CAAA;IACrE,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAA;IAClD,MAAM,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,MAAM,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAA;IACrE,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAClD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- import { IDappAccount } from '@prosopo/types';
2
- import { ProviderEnvironment } from '@prosopo/types-env';
3
- export declare function setupDapp(env: ProviderEnvironment, dapp: IDappAccount): Promise<void>;
4
- //# sourceMappingURL=dapp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dapp.d.ts","sourceRoot":"","sources":["../../src/setup/dapp.ts"],"names":[],"mappings":"AAaA,OAAO,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAIxD,wBAAsB,SAAS,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB3F"}
@@ -1,35 +0,0 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { DappPayee } from '@prosopo/types';
15
- import { Tasks } from '@prosopo/provider';
16
- import { wrapQuery } from '@prosopo/contract';
17
- export async function setupDapp(env, dapp) {
18
- const logger = env.logger;
19
- if (dapp.pair) {
20
- await env.changeSigner(dapp.pair);
21
- const tasks = new Tasks(env);
22
- try {
23
- const dappResult = await wrapQuery(tasks.contract.query.getDapp, tasks.contract.query)(dapp.contractAccount);
24
- logger.info(' - dapp is already registered');
25
- logger.info('Dapp', dappResult);
26
- }
27
- catch (e) {
28
- logger.info(' - dappRegister');
29
- await tasks.contract.tx.dappRegister(dapp.contractAccount, DappPayee.dapp);
30
- logger.info(' - dappFund');
31
- await tasks.contract.tx.dappFund(dapp.contractAccount, { value: dapp.fundAmount });
32
- }
33
- }
34
- }
35
- //# sourceMappingURL=dapp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dapp.js","sourceRoot":"","sources":["../../src/setup/dapp.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAQ,SAAS,EAAgB,MAAM,gBAAgB,CAAA;AAE9D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAwB,EAAE,IAAkB;IACxE,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;IACzB,IAAI,IAAI,CAAC,IAAI,EAAE;QACX,MAAM,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;QAE5B,IAAI;YACA,MAAM,UAAU,GAAS,MAAM,SAAS,CACpC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAC5B,KAAK,CAAC,QAAQ,CAAC,KAAK,CACvB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;YACvB,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YAC9C,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;SAClC;QAAC,OAAO,CAAC,EAAE;YACR,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;YAChC,MAAM,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;YAC1E,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;YAC5B,MAAM,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;SACrF;KACJ;AACL,CAAC"}
@@ -1,23 +0,0 @@
1
- /// <reference types="bn.js" />
2
- import { AnyNumber } from '@polkadot/types-codec/types';
3
- import { BN } from '@polkadot/util';
4
- import { ProsopoEnvironment } from '@prosopo/types-env';
5
- /** Send funds from one of the development accounts to another account. */
6
- export declare function sendFunds(env: ProsopoEnvironment, address: string, who: string, amount: AnyNumber): Promise<void>;
7
- /**
8
- * Takes the providerStakeDefault and works out if multiplying it by 100 or
9
- * stakeMultiplier is greater than the maxStake. If it is, it returns the maxStake
10
- * If chain decimals = 12, 1 UNIT = 1e12
11
- * @param env
12
- * @param providerStakeDefault
13
- * @param stakeMultiplier
14
- */
15
- export declare function getStakeAmount(env: ProsopoEnvironment, providerStakeDefault: BN, stakeMultiplier?: number): BN;
16
- /**
17
- * Send funds to a test account, adding the max of 2 * stakeAmount or 100 * the
18
- * existential deposit
19
- * @param env
20
- * @param stakeAmount
21
- */
22
- export declare function getSendAmount(env: ProsopoEnvironment, stakeAmount: BN): BN;
23
- //# sourceMappingURL=funds.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"funds.d.ts","sourceRoot":"","sources":["../../src/setup/funds.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AAGnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAevD,0EAA0E;AAC1E,wBAAsB,SAAS,CAC3B,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,GAClB,OAAO,CAAC,IAAI,CAAC,CA+Df;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,EAAE,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,EAAE,CAgB9G;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,kBAAkB,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,CAS1E"}
@@ -1,100 +0,0 @@
1
- import { BN } from '@polkadot/util';
2
- import { ProsopoEnvError } from '@prosopo/common';
3
- import { dispatchErrorHandler, oneUnit } from '@prosopo/contract';
4
- const devMnemonics = ['//Alice', '//Bob', '//Charlie', '//Dave', '//Eve', '//Ferdie'];
5
- let current = -1;
6
- const MAX_ACCOUNT_FUND = 10000; // 10000 UNIT
7
- /** Cycle through the dev mnemonics so as not to deplete the funds too quickly
8
- */
9
- function getNextMnemonic() {
10
- current = (current + 1) % devMnemonics.length;
11
- return devMnemonics[current];
12
- }
13
- /** Send funds from one of the development accounts to another account. */
14
- export async function sendFunds(env, address, who, amount) {
15
- await env.api.isReady;
16
- const mnemonic = getNextMnemonic();
17
- const pair = env.keyring.addFromMnemonic(mnemonic);
18
- const nonce = await env.api.rpc.system.accountNextIndex(pair.address);
19
- const { data: { free: previousFree }, } = await env.contractInterface.api.query.system.account(pair.address);
20
- if (previousFree.lt(new BN(amount.toString()))) {
21
- throw new ProsopoEnvError('DEVELOPER.BALANCE_TOO_LOW', undefined, undefined, {
22
- mnemonic,
23
- previousFree: previousFree.toString(),
24
- amount: amount.toString(),
25
- });
26
- }
27
- const api = env.contractInterface.api;
28
- const unit = oneUnit(env.api);
29
- const unitAmount = new BN(amount.toString()).div(unit).toString();
30
- env.logger.debug('Sending funds from', pair.address, 'to', address, 'Amount:', unitAmount, 'UNIT. Free balance:', previousFree.div(unit).toString(), 'UNIT');
31
- // eslint-disable-next-line no-async-promise-executor
32
- const result = new Promise(async (resolve, reject) => {
33
- const unsub = await api.tx.balances
34
- .transfer(address, amount)
35
- .signAndSend(pair, { nonce }, (result) => {
36
- if (result.status.isInBlock || result.status.isFinalized) {
37
- result.events
38
- .filter(({ event: { section } }) => section === 'system')
39
- .forEach((event) => {
40
- const { event: { method }, } = event;
41
- if (method === 'ExtrinsicFailed') {
42
- unsub();
43
- reject(dispatchErrorHandler(api.registry, event));
44
- }
45
- });
46
- unsub();
47
- resolve(result);
48
- }
49
- else if (result.isError) {
50
- unsub();
51
- reject(result);
52
- }
53
- });
54
- });
55
- await result
56
- .then((result) => {
57
- env.logger.debug(who, 'sent amount', unitAmount, 'UNIT at tx hash ', result.status.asInBlock.toHex());
58
- })
59
- .catch((e) => {
60
- throw new ProsopoEnvError('DEVELOPER.FUNDING_FAILED', undefined, undefined, { e });
61
- });
62
- }
63
- /**
64
- * Takes the providerStakeDefault and works out if multiplying it by 100 or
65
- * stakeMultiplier is greater than the maxStake. If it is, it returns the maxStake
66
- * If chain decimals = 12, 1 UNIT = 1e12
67
- * @param env
68
- * @param providerStakeDefault
69
- * @param stakeMultiplier
70
- */
71
- export function getStakeAmount(env, providerStakeDefault, stakeMultiplier) {
72
- const unit = oneUnit(env.api);
73
- // We want to give each provider 100 * the required stake or 1 UNIT, whichever is greater, so that gas fees can be
74
- // refunded to the Dapp User from within the contract
75
- const stake100 = BN.max(providerStakeDefault.muln(stakeMultiplier || 100), unit);
76
- // We don't want to stake any more than MAX_ACCOUNT_FUND UNIT per provider as the test account funds will be depleted too quickly
77
- const maxStake = unit.muln(MAX_ACCOUNT_FUND);
78
- if (stake100.lt(maxStake)) {
79
- env.logger.debug('Setting stake amount to', stake100.div(unit).toNumber(), 'UNIT');
80
- return stake100;
81
- }
82
- env.logger.debug('Setting stake amount to', maxStake.div(unit).toNumber(), 'UNIT');
83
- return maxStake;
84
- }
85
- /**
86
- * Send funds to a test account, adding the max of 2 * stakeAmount or 100 * the
87
- * existential deposit
88
- * @param env
89
- * @param stakeAmount
90
- */
91
- export function getSendAmount(env, stakeAmount) {
92
- const unit = oneUnit(env.api);
93
- env.logger.debug('Stake amount', stakeAmount.div(unit).toNumber(), 'UNIT');
94
- let sendAmount = new BN(stakeAmount).muln(2);
95
- // Should result in each account receiving a minimum of existentialDeposit
96
- sendAmount = BN.max(sendAmount, env.api.consts.balances.existentialDeposit.muln(100));
97
- env.logger.debug('Setting send amount to', sendAmount.div(unit).toNumber(), 'UNIT');
98
- return sendAmount;
99
- }
100
- //# sourceMappingURL=funds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"funds.js","sourceRoot":"","sources":["../../src/setup/funds.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEjE,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;AACrF,IAAI,OAAO,GAAG,CAAC,CAAC,CAAA;AAChB,MAAM,gBAAgB,GAAG,KAAK,CAAA,CAAC,aAAa;AAE5C;GACG;AACH,SAAS,eAAe;IACpB,OAAO,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,CAAA;IAE7C,OAAO,YAAY,C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AAG,CAAC,CAAA;IAC7B,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAA;IAC1E,IAAI,UAAU,GAAG,IAAI,EAAE,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAE5C,0EAA0E;IAC1E,UAAU,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACrF,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAA;IACnF,OAAO,UAAU,CAAA;AACrB,CAAC"}
@@ -1,5 +0,0 @@
1
- export * from './setup.js';
2
- export * from './provider.js';
3
- export * from './dapp.js';
4
- export * from './funds.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/setup/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
@@ -1,18 +0,0 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- export * from './setup.js';
15
- export * from './provider.js';
16
- export * from './dapp.js';
17
- export * from './funds.js';
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/setup/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
@@ -1,5 +0,0 @@
1
- import { IProviderAccount } from '@prosopo/types';
2
- import { ProviderEnvironment } from '@prosopo/types-env';
3
- export declare function registerProvider(env: ProviderEnvironment, account: IProviderAccount, force?: boolean): Promise<void>;
4
- export declare function setupProvider(env: ProviderEnvironment, provider: IProviderAccount): Promise<void>;
5
- //# sourceMappingURL=provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/setup/provider.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAQxD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,OAAO,iBAgC1G;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmDvG"}
@@ -1,84 +0,0 @@
1
- import { ProsopoEnvError } from '@prosopo/common';
2
- import { Tasks } from '@prosopo/provider';
3
- import { getSendAmount, getStakeAmount, sendFunds } from './funds.js';
4
- import { loadJSONFile } from '@prosopo/cli';
5
- import { stringToU8a } from '@polkadot/util';
6
- import { wrapQuery } from '@prosopo/contract';
7
- export async function registerProvider(env, account, force) {
8
- try {
9
- const provider = (await env.contractInterface.query.getProvider(account.address)).value.unwrap().unwrap();
10
- if (provider.status.toString() === 'Active' && !force) {
11
- env.logger.info('Provider exists and is active, skipping registration.');
12
- return;
13
- }
14
- }
15
- catch {
16
- env.logger.info('Provider does not exist, registering...');
17
- }
18
- if (account.secret) {
19
- const providerKeyringPair = env.keyring.addFromMnemonic(account.secret);
20
- account.address = providerKeyringPair.address;
21
- const result = await wrapQuery(env.contractInterface.query.getProviderStakeThreshold, env.contractInterface.query)();
22
- const stakeAmount = result.rawNumber;
23
- // use the minimum stake amount from the contract to create a reasonable stake amount
24
- account.stake = getStakeAmount(env, stakeAmount);
25
- const sendAmount = getSendAmount(env, account.stake);
26
- // send enough funds to cover the stake amount and more
27
- await sendFunds(env, account.address, 'Provider', sendAmount);
28
- await setupProvider(env, account);
29
- }
30
- else {
31
- throw new ProsopoEnvError('GENERAL.NO_MNEMONIC_OR_SEED');
32
- }
33
- }
34
- export async function setupProvider(env, provider) {
35
- if (!provider.pair) {
36
- throw new ProsopoEnvError('DEVELOPER.MISSING_PROVIDER_PAIR', undefined, undefined, { provider });
37
- }
38
- await env.changeSigner(provider.pair);
39
- const logger = env.logger;
40
- const tasks = new Tasks(env);
41
- logger.info(' - providerRegister');
42
- const providerRegisterArgs = [
43
- Array.from(stringToU8a(provider.url)),
44
- provider.fee,
45
- provider.payee,
46
- {
47
- value: 0,
48
- },
49
- ];
50
- let providerExists = false;
51
- try {
52
- await wrapQuery(tasks.contract.query.providerRegister, tasks.contract.query)(...providerRegisterArgs);
53
- }
54
- catch (e) {
55
- if (e === 'ProviderExists') {
56
- logger.info('Provider already exists');
57
- providerExists = true;
58
- }
59
- else {
60
- throw e;
61
- }
62
- }
63
- if (!providerExists) {
64
- await tasks.contract.tx.providerRegister(...providerRegisterArgs);
65
- }
66
- const registeredProvider = await wrapQuery(tasks.contract.query.getProvider, tasks.contract.query)(provider.address);
67
- logger.info(registeredProvider);
68
- logger.info(' - providerStake');
69
- const providerUpdateArgs = [
70
- Array.from(stringToU8a(provider.url)),
71
- provider.fee,
72
- provider.payee,
73
- {
74
- value: provider.stake,
75
- },
76
- ];
77
- // Do this to catch any errors before running the tx
78
- await wrapQuery(tasks.contract.query.providerUpdate, tasks.contract.query)(...providerUpdateArgs);
79
- await tasks.contract.tx.providerUpdate(...providerUpdateArgs);
80
- logger.info(' - providerSetDataset');
81
- const datasetJSON = loadJSONFile(provider.datasetFile);
82
- await tasks.providerSetDatasetFromFile(datasetJSON);
83
- }
84
- //# sourceMappingURL=provider.js.map