polkamarkets-js 1.0.2 → 3.1.1

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 (164) hide show
  1. package/.openzeppelin/unknown-1337.json +2056 -0
  2. package/CONTRIBUTING.md +36 -0
  3. package/README.md +24 -25
  4. package/_book/README.md +590 -0
  5. package/_book/core.md +50 -0
  6. package/_book/gitbook/fonts/fontawesome/FontAwesome.otf +0 -0
  7. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot +0 -0
  8. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.svg +685 -0
  9. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf +0 -0
  10. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff +0 -0
  11. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff2 +0 -0
  12. package/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js +240 -0
  13. package/_book/gitbook/gitbook-plugin-fontsettings/website.css +291 -0
  14. package/_book/gitbook/gitbook-plugin-highlight/ebook.css +135 -0
  15. package/_book/gitbook/gitbook-plugin-highlight/website.css +434 -0
  16. package/_book/gitbook/gitbook-plugin-lunr/lunr.min.js +7 -0
  17. package/_book/gitbook/gitbook-plugin-lunr/search-lunr.js +59 -0
  18. package/_book/gitbook/gitbook-plugin-search/lunr.min.js +7 -0
  19. package/_book/gitbook/gitbook-plugin-search/search-engine.js +50 -0
  20. package/_book/gitbook/gitbook-plugin-search/search.css +35 -0
  21. package/_book/gitbook/gitbook-plugin-search/search.js +213 -0
  22. package/_book/gitbook/gitbook-plugin-sharing/buttons.js +90 -0
  23. package/_book/gitbook/gitbook.js +4 -0
  24. package/_book/gitbook/images/apple-touch-icon-precomposed-152.png +0 -0
  25. package/_book/gitbook/images/favicon.ico +0 -0
  26. package/_book/gitbook/style.css +9 -0
  27. package/_book/gitbook/theme.js +4 -0
  28. package/_book/index.html +705 -0
  29. package/_book/intro.md +32 -0
  30. package/_book/search_index.json +1 -0
  31. package/book.json +8 -0
  32. package/build/contracts/AccessControl.json +1 -0
  33. package/build/contracts/AccessControlEnumerable.json +1 -0
  34. package/build/contracts/Achievements.json +1 -0
  35. package/build/contracts/Address.json +1 -0
  36. package/build/contracts/BalanceHolder.json +1 -0
  37. package/build/contracts/BalanceHolder_ERC20.json +1 -0
  38. package/build/contracts/CeilDiv.json +1 -0
  39. package/build/contracts/Clones.json +1 -0
  40. package/build/contracts/Context.json +1 -0
  41. package/build/contracts/Counters.json +1 -0
  42. package/build/contracts/ERC165.json +1 -0
  43. package/build/contracts/ERC20.json +1 -0
  44. package/build/contracts/ERC20Burnable.json +1 -0
  45. package/build/contracts/ERC20Pausable.json +1 -0
  46. package/build/contracts/ERC20PresetMinterPauser.json +1 -0
  47. package/build/contracts/ERC721.json +1 -0
  48. package/build/contracts/EnumerableMap.json +1 -0
  49. package/build/contracts/EnumerableSet.json +1 -0
  50. package/build/contracts/FantasyERC20.json +1 -0
  51. package/build/contracts/IAccessControl.json +1 -0
  52. package/build/contracts/IAccessControlEnumerable.json +1 -0
  53. package/build/contracts/IBalanceHolder_ERC20.json +1 -0
  54. package/build/contracts/IERC165.json +1 -0
  55. package/build/contracts/IERC20.json +1 -0
  56. package/build/contracts/IERC20Metadata.json +1 -0
  57. package/build/contracts/IERC20Permit.json +1 -0
  58. package/build/contracts/IERC721.json +1 -0
  59. package/build/contracts/IERC721Enumerable.json +1 -0
  60. package/build/contracts/IERC721Metadata.json +1 -0
  61. package/build/contracts/IERC721Receiver.json +1 -0
  62. package/build/contracts/IFantasyERC20.json +1 -0
  63. package/build/contracts/IPredictionMarketV3.json +1 -0
  64. package/build/contracts/IPredictionMarketV3Factory.json +1 -0
  65. package/build/contracts/IPredictionMarketV3Manager.json +1 -0
  66. package/build/contracts/IRealityETH_ERC20.json +1 -0
  67. package/build/contracts/IRealityETH_IERC20.json +1 -0
  68. package/build/contracts/IWETH.json +1 -0
  69. package/build/contracts/LandFactory.json +1 -0
  70. package/build/contracts/Math.json +1 -0
  71. package/build/contracts/Migrations.json +1 -0
  72. package/build/contracts/Ownable.json +1 -0
  73. package/build/contracts/Pausable.json +1 -0
  74. package/build/contracts/PredictionMarket.json +1 -0
  75. package/build/contracts/PredictionMarketV2.json +1 -0
  76. package/build/contracts/PredictionMarketV3.json +1 -0
  77. package/build/contracts/PredictionMarketV3Controller.json +1 -0
  78. package/build/contracts/PredictionMarketV3Factory.json +1 -0
  79. package/build/contracts/PredictionMarketV3Manager.json +1 -0
  80. package/build/contracts/PredictionMarketV3Querier.json +1 -0
  81. package/build/contracts/RealitioERC20.json +1 -0
  82. package/build/contracts/RealitioForeignArbitrationProxyWithAppeals.json +1 -0
  83. package/build/contracts/RealitioHomeArbitrationProxy.json +1 -0
  84. package/build/contracts/RealitioSafeMath256.json +1 -0
  85. package/build/contracts/RealitioSafeMath32.json +1 -0
  86. package/build/contracts/RealityETH_ERC20_Factory.json +1 -0
  87. package/build/contracts/RealityETH_ERC20_v3_0.json +1 -0
  88. package/build/contracts/ReentrancyGuard.json +1 -0
  89. package/build/contracts/SafeERC20.json +1 -0
  90. package/build/contracts/SafeMath.json +1 -0
  91. package/build/contracts/Strings.json +1 -0
  92. package/build/contracts/Voting.json +1 -0
  93. package/build/contracts/WETH9.json +1 -0
  94. package/build/contracts/test.json +1 -0
  95. package/cleanContracts.js +22 -0
  96. package/contracts/FantasyERC20.sol +81 -0
  97. package/contracts/IFantasyERC20.sol +20 -0
  98. package/contracts/IPredictionMarketV3.sol +207 -0
  99. package/contracts/IPredictionMarketV3Factory.sol +10 -0
  100. package/contracts/IPredictionMarketV3Manager.sol +12 -0
  101. package/contracts/IRealityETH_ERC20.sol +64 -0
  102. package/contracts/LandFactory.sol +248 -0
  103. package/contracts/Migrations.sol +24 -0
  104. package/contracts/PredictionMarketV3.sol +1332 -0
  105. package/contracts/PredictionMarketV3Controller.sol +87 -0
  106. package/contracts/PredictionMarketV3Factory.sol +205 -0
  107. package/contracts/PredictionMarketV3Manager.sol +45 -0
  108. package/contracts/PredictionMarketV3Querier.sol +79 -0
  109. package/contracts/RealityETH_ERC20_Factory.sol +54 -0
  110. package/contracts/Voting.sol +153 -0
  111. package/contracts/WETH9.sol +62 -0
  112. package/hardhat.config.js +4 -0
  113. package/help.txt +8 -0
  114. package/index.js +3 -0
  115. package/migrations/10_deploy_weth.js +5 -0
  116. package/migrations/11_deploy_full_flow.js +99 -0
  117. package/migrations/12_deploy_pm_v3_querier.js +7 -0
  118. package/migrations/13_deploy_pm_v3_factory.js +14 -0
  119. package/migrations/1_initial_migration.js +5 -0
  120. package/migrations/2_deploy_erc20.js +10 -0
  121. package/migrations/3_deploy_realitio.js +11 -0
  122. package/migrations/4_deploy_pm.js +20 -0
  123. package/migrations/5_seed_markets.js +51 -0
  124. package/migrations/6_deploy_achievements.js +5 -0
  125. package/migrations/7_deploy_voting.js +14 -0
  126. package/migrations/8_deploy_pm_v2.js +20 -0
  127. package/migrations/9_seed_markets_v2.js +68 -0
  128. package/package.json +106 -13
  129. package/src/Application.js +421 -0
  130. package/src/interfaces/index.js +19 -0
  131. package/src/models/AchievementsContract.js +217 -0
  132. package/src/models/ArbitrationContract.js +69 -0
  133. package/src/models/ArbitrationProxyContract.js +32 -0
  134. package/src/models/ERC20Contract.js +156 -0
  135. package/src/models/FantasyERC20Contract.js +92 -0
  136. package/src/models/IContract.js +1002 -0
  137. package/src/models/PolkamarketsSmartAccount.js +100 -0
  138. package/src/models/PredictionMarketContract.js +562 -0
  139. package/src/models/PredictionMarketV2Contract.js +830 -0
  140. package/src/models/PredictionMarketV3Contract.js +256 -0
  141. package/src/models/PredictionMarketV3ControllerContract.js +102 -0
  142. package/src/models/PredictionMarketV3FactoryContract.js +96 -0
  143. package/src/models/PredictionMarketV3ManagerContract.js +111 -0
  144. package/src/models/PredictionMarketV3QuerierContract.js +24 -0
  145. package/src/models/RealitioERC20Contract.js +286 -0
  146. package/src/models/VotingContract.js +182 -0
  147. package/src/models/WETH9Contract.js +92 -0
  148. package/src/models/index.js +33 -0
  149. package/src/utils/Account.js +40 -0
  150. package/src/utils/Contract.js +120 -0
  151. package/src/utils/Numbers.js +94 -0
  152. package/tests/fantasyERC20Contract.js +225 -0
  153. package/tests/index.js +10 -0
  154. package/tests/predictionMarketContract.js +466 -0
  155. package/tests/predictionMarketV2Contract.js +1042 -0
  156. package/tests/predictionMarketV3Contract.js +1079 -0
  157. package/tests/predictionMarketV3ControllerContract.js +613 -0
  158. package/tests/predictionMarketV3FactoryContract.js +469 -0
  159. package/tests/predictionMarketV3ManagerContract.js +610 -0
  160. package/tests/utils.js +16 -0
  161. package/tests/votingContract.js +490 -0
  162. package/tooling/docs/jsdoc.json +6 -0
  163. package/truffle-config.js +134 -0
  164. package/polkamarkets.js +0 -436
@@ -0,0 +1,36 @@
1
+ # Contributor's Guide
2
+
3
+ Welcome; we appreciate you and would like to thank you for contributing to our project. This document aims to facilitate the process and share with you some structure that hopefully will remove any roadblock.
4
+
5
+ ### Guidelines:
6
+
7
+ 1. Each reported issue shall have a name and description.
8
+ 2. It should also have a detailed description of the requested feature.
9
+ 3. It should also contain a label with the bounty price
10
+ 4. It should include the expected solution.
11
+ 5. It should also contain who is requesting the feature.
12
+ 6. The issue shall be reviewed and approved by one of the collaborators in the projects before any contributor starts working on it.
13
+ 7. Once the issue is approved, it shall be assigned to the contributor.
14
+
15
+ ---
16
+
17
+ ### Discussion
18
+ 1. The issue discussion shall include the basics principles of communication.
19
+ 2. It should be clear, and if a solution is proposed, it should include pros and cons.
20
+ 3. If a question is asked, it should tag at least one of the project collaborators who will provide some guidance around the issue and/or the solution
21
+
22
+ ---
23
+
24
+ ### Solution
25
+ 1. Each PR shall include the [**Ethereum Address**][1] for the bounty payment.
26
+ 2. The PR shall include a clear description of the proposed solution
27
+ 3. If there is any additional information or link, it shall be included in the description.
28
+ 4. The PR shall be cleaned up with [Prettier][2]
29
+ 5. (Optional) The contributor has the option to include the Twitter handle.
30
+
31
+ ---
32
+
33
+ If you have any comment or ideas in terms of making this process better, please let us know or submit a PR.
34
+
35
+ [1]: [https://prettier.io/]
36
+ [2]: [https://coinmarketcap.com/currencies/polkamarkets/]
package/README.md CHANGED
@@ -1,48 +1,44 @@
1
- ![alt tag](https://uploads-ssl.webflow.com/6001b8a9fb88852f468bf865/600f55bddbe2354c1e36e200_Dark.svg)
1
+ # ![alt tag](https://uploads-ssl.webflow.com/6001b8a9fb88852f468bf865/600f55bddbe2354c1e36e200_Dark.svg)
2
2
 
3
3
  ## Introductions
4
4
 
5
- `polkamarkets-js` is the Polkamarkets Javascript SDK to integrate Prediction Markets into any dapp.
5
+ `polkamarkets-js` is the Polkamarkets' Javascript SDK to integrate Prediction Markets into any dapp.
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Using [npm](https://www.npmjs.com/):
10
10
 
11
11
  ```bash
12
- npm install "polkamarkets-js" --save
12
+ npm install "https://github.com/Polkamarkets/polkamarkets-js" --save
13
13
  ```
14
14
 
15
15
  Using [yarn](https://yarnpkg.com/):
16
16
 
17
17
  ```bash
18
- yarn add polkamarkets-js
18
+ yarn add https://github.com/Polkamarkets/polkamarkets-js
19
19
  ```
20
20
 
21
21
  ## Usage
22
22
 
23
23
  ### Initializing App
24
24
 
25
- Polkamarkets uses [`bepro-js`](https://github.com/bepronetwork/bepro-js/tree/feature/prediction-markets) for the web3 EVM integration.
25
+ `polkamarkets-js` library initialization is performed in [`Application.js`](https://github.com/Polkamarkets/polkamarkets-js/blob/main/src/Application.js).
26
26
 
27
27
  You'll need to provide a web3 RPC provider (e.g., Infura for Ethereum dapps)
28
28
 
29
29
  ```javascript
30
- import Polkamarkets from 'polkamarkets-js';
30
+ import * as polkamarketsjs from 'polkamarkets-js';
31
31
 
32
32
  // Moonriver RPC
33
33
  const web3Provider = 'https://rpc.moonriver.moonbeam.network';
34
34
 
35
+ const polkamarkets = new polkamarketsjs.Application({ web3Provider });
36
+
35
37
  // Starting application
36
- const polkamarkets = new Polkamarkets(web3Provider);
38
+ polkamarkets.start();
37
39
 
38
40
  // Connecting wallet
39
41
  await polkamarkets.login();
40
-
41
- // Fetching connected address
42
- const balance = await polkamarkets.getAddress();
43
-
44
- // Fetching address balance
45
- const balance = await polkamarkets.getBalance();
46
42
  ```
47
43
 
48
44
  ### Prediction Markets
@@ -51,37 +47,40 @@ Once the library is initialized, it's ready to interact with prediction markets
51
47
 
52
48
  ```javascript
53
49
  const contractAddress = '0xDcBe79f74c98368141798eA0b7b979B9bA54b026';
54
- polkamarkets.getPredictionMarketContract(contractAddress);
50
+ const contract = polkamarkets.getPredictionMarketContract({ contractAddress });
55
51
  ```
56
52
 
57
53
  Once initialized, you'll be able to interact with the smart contract.
58
54
 
59
- - Prediction Market Smart Contract: [PredictionMarket.sol](https://github.com/bepronetwork/bepro-js/blob/feature/prediction-markets/contracts/PredictionMarket.sol)
60
- - Prediction Market JS Integration: [PredictionMarketContract.js](https://github.com/bepronetwork/bepro-js/blob/feature/prediction-markets/src/models/PredictionMarketContract.js)
55
+ - Prediction Market Smart Contract: [PredictionMarket.sol](https://github.com/Polkamarkets/polkamarkets-js/blob/main/contracts/PredictionMarket.sol)
56
+ - Prediction Market JS Integration: [PredictionMarketContract.js](https://github.com/Polkamarkets/polkamarkets-js/blob/main/src/models/PredictionMarketContract.js)
61
57
 
62
58
  Here's a few call examples
63
59
 
64
60
  ```javascript
65
61
  const marketId = 1;
66
- const outcomeId = 0;
62
+ const outcomeId = 2;
67
63
  const ethAmount = 0.1;
68
64
 
65
+ // Fetching all Market Ids
66
+ await contract.getMarkets();
67
+
69
68
  // Fetching Market Details
70
- await polkamarkets.getMarketData(marketId);
69
+ await contract.getMarketData({ marketId });
71
70
 
72
71
  // Buying Outcome Shares
73
- const mintOutcomeSharesToBuy = await polkamarkets.calcBuyAmount(marketId, outcomeId, ethAmount)
74
- await polkamarkets.buy(marketId, outcomeId, ethAmount, minOutcomeSharesToBuy);
72
+ const mintOutcomeSharesToBuy = await contract.calcBuyAmount({ marketId, outcomeId, ethAmount })
73
+ await contract.buy({ marketId, outcomeId, ethAmount, minOutcomeSharesToBuy });
75
74
 
76
75
  // Selling Outcome Shares
77
- const maxOutcomeSharesToSell = await polkamarkets.calcSellAmount(marketId, outcomeId, ethAmount)
78
- await polkamarkets.sell(marketId, outcomeId, ethAmount, maxOutcomeSharesToSell);
76
+ const maxOutcomeSharesToSell = await contract.calcSellAmount({ marketId, outcomeId, ethAmount })
77
+ await contract.buy({ marketId, outcomeId, ethAmount, maxOutcomeSharesToSell });
79
78
 
80
79
  // Claiming Winnings
81
- await polkamarkets.claimWinnings(marketId);
80
+ await contract.claimWinnings({ marketId });
82
81
 
83
82
  // Fetching portfolio data
84
- await polkamarkets.getPortfolio();
83
+ await contract.getMyPortfolio();
85
84
  ```
86
85
 
87
86
  ## Contribution
@@ -96,4 +95,4 @@ Contributions are welcomed but we ask to red existing code guidelines, specially
96
95
 
97
96
  The usage of ETH in all methods or params means using the native currency of that blockchain, example BSC in Binance Chain would still be nominated as ETH
98
97
 
99
- [1]: https://github.com/bepronetwork/bepro-js/blob/master/CONTRIBUTING.md
98
+ [1]: https://github.com/Polkamarkets/polkamarkets-js/blob/main/CONTRIBUTING.md