polkamarkets-js 1.0.1 → 3.1.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.
- package/.openzeppelin/unknown-1337.json +2056 -0
- package/CONTRIBUTING.md +36 -0
- package/README.md +24 -25
- package/_book/README.md +590 -0
- package/_book/core.md +50 -0
- package/_book/gitbook/fonts/fontawesome/FontAwesome.otf +0 -0
- package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot +0 -0
- package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.svg +685 -0
- package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf +0 -0
- package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff +0 -0
- package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff2 +0 -0
- package/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js +240 -0
- package/_book/gitbook/gitbook-plugin-fontsettings/website.css +291 -0
- package/_book/gitbook/gitbook-plugin-highlight/ebook.css +135 -0
- package/_book/gitbook/gitbook-plugin-highlight/website.css +434 -0
- package/_book/gitbook/gitbook-plugin-lunr/lunr.min.js +7 -0
- package/_book/gitbook/gitbook-plugin-lunr/search-lunr.js +59 -0
- package/_book/gitbook/gitbook-plugin-search/lunr.min.js +7 -0
- package/_book/gitbook/gitbook-plugin-search/search-engine.js +50 -0
- package/_book/gitbook/gitbook-plugin-search/search.css +35 -0
- package/_book/gitbook/gitbook-plugin-search/search.js +213 -0
- package/_book/gitbook/gitbook-plugin-sharing/buttons.js +90 -0
- package/_book/gitbook/gitbook.js +4 -0
- package/_book/gitbook/images/apple-touch-icon-precomposed-152.png +0 -0
- package/_book/gitbook/images/favicon.ico +0 -0
- package/_book/gitbook/style.css +9 -0
- package/_book/gitbook/theme.js +4 -0
- package/_book/index.html +705 -0
- package/_book/intro.md +32 -0
- package/_book/search_index.json +1 -0
- package/book.json +8 -0
- package/build/contracts/AccessControl.json +1 -0
- package/build/contracts/AccessControlEnumerable.json +1 -0
- package/build/contracts/Achievements.json +1 -0
- package/build/contracts/Address.json +1 -0
- package/build/contracts/BalanceHolder.json +1 -0
- package/build/contracts/BalanceHolder_ERC20.json +1 -0
- package/build/contracts/CeilDiv.json +1 -0
- package/build/contracts/Clones.json +1 -0
- package/build/contracts/Context.json +1 -0
- package/build/contracts/Counters.json +1 -0
- package/build/contracts/ERC165.json +1 -0
- package/build/contracts/ERC20.json +1 -0
- package/build/contracts/ERC20Burnable.json +1 -0
- package/build/contracts/ERC20Pausable.json +1 -0
- package/build/contracts/ERC20PresetMinterPauser.json +1 -0
- package/build/contracts/ERC721.json +1 -0
- package/build/contracts/EnumerableMap.json +1 -0
- package/build/contracts/EnumerableSet.json +1 -0
- package/build/contracts/FantasyERC20.json +1 -0
- package/build/contracts/IAccessControl.json +1 -0
- package/build/contracts/IAccessControlEnumerable.json +1 -0
- package/build/contracts/IBalanceHolder_ERC20.json +1 -0
- package/build/contracts/IERC165.json +1 -0
- package/build/contracts/IERC20.json +1 -0
- package/build/contracts/IERC20Metadata.json +1 -0
- package/build/contracts/IERC20Permit.json +1 -0
- package/build/contracts/IERC721.json +1 -0
- package/build/contracts/IERC721Enumerable.json +1 -0
- package/build/contracts/IERC721Metadata.json +1 -0
- package/build/contracts/IERC721Receiver.json +1 -0
- package/build/contracts/IFantasyERC20.json +1 -0
- package/build/contracts/IPredictionMarketV3.json +1 -0
- package/build/contracts/IPredictionMarketV3Factory.json +1 -0
- package/build/contracts/IPredictionMarketV3Manager.json +1 -0
- package/build/contracts/IRealityETH_ERC20.json +1 -0
- package/build/contracts/IRealityETH_IERC20.json +1 -0
- package/build/contracts/IWETH.json +1 -0
- package/build/contracts/LandFactory.json +1 -0
- package/build/contracts/Math.json +1 -0
- package/build/contracts/Migrations.json +1 -0
- package/build/contracts/Ownable.json +1 -0
- package/build/contracts/Pausable.json +1 -0
- package/build/contracts/PredictionMarket.json +1 -0
- package/build/contracts/PredictionMarketV2.json +1 -0
- package/build/contracts/PredictionMarketV3.json +1 -0
- package/build/contracts/PredictionMarketV3Controller.json +1 -0
- package/build/contracts/PredictionMarketV3Factory.json +1 -0
- package/build/contracts/PredictionMarketV3Manager.json +1 -0
- package/build/contracts/PredictionMarketV3Querier.json +1 -0
- package/build/contracts/RealitioERC20.json +1 -0
- package/build/contracts/RealitioForeignArbitrationProxyWithAppeals.json +1 -0
- package/build/contracts/RealitioHomeArbitrationProxy.json +1 -0
- package/build/contracts/RealitioSafeMath256.json +1 -0
- package/build/contracts/RealitioSafeMath32.json +1 -0
- package/build/contracts/RealityETH_ERC20_Factory.json +1 -0
- package/build/contracts/RealityETH_ERC20_v3_0.json +1 -0
- package/build/contracts/ReentrancyGuard.json +1 -0
- package/build/contracts/SafeERC20.json +1 -0
- package/build/contracts/SafeMath.json +1 -0
- package/build/contracts/Strings.json +1 -0
- package/build/contracts/Voting.json +1 -0
- package/build/contracts/WETH9.json +1 -0
- package/build/contracts/test.json +1 -0
- package/cleanContracts.js +22 -0
- package/contracts/FantasyERC20.sol +81 -0
- package/contracts/IFantasyERC20.sol +20 -0
- package/contracts/IPredictionMarketV3.sol +207 -0
- package/contracts/IPredictionMarketV3Factory.sol +10 -0
- package/contracts/IPredictionMarketV3Manager.sol +12 -0
- package/contracts/IRealityETH_ERC20.sol +64 -0
- package/contracts/LandFactory.sol +248 -0
- package/contracts/Migrations.sol +24 -0
- package/contracts/PredictionMarketV3.sol +1332 -0
- package/contracts/PredictionMarketV3Controller.sol +87 -0
- package/contracts/PredictionMarketV3Factory.sol +205 -0
- package/contracts/PredictionMarketV3Manager.sol +45 -0
- package/contracts/PredictionMarketV3Querier.sol +79 -0
- package/contracts/RealityETH_ERC20_Factory.sol +54 -0
- package/contracts/Voting.sol +153 -0
- package/contracts/WETH9.sol +62 -0
- package/help.txt +8 -0
- package/index.js +3 -0
- package/migrations/10_deploy_weth.js +5 -0
- package/migrations/11_deploy_full_flow.js +99 -0
- package/migrations/12_deploy_pm_v3_querier.js +7 -0
- package/migrations/13_deploy_pm_v3_factory.js +14 -0
- package/migrations/1_initial_migration.js +5 -0
- package/migrations/2_deploy_erc20.js +10 -0
- package/migrations/3_deploy_realitio.js +11 -0
- package/migrations/4_deploy_pm.js +20 -0
- package/migrations/5_seed_markets.js +51 -0
- package/migrations/6_deploy_achievements.js +5 -0
- package/migrations/7_deploy_voting.js +14 -0
- package/migrations/8_deploy_pm_v2.js +20 -0
- package/migrations/9_seed_markets_v2.js +68 -0
- package/package.json +106 -13
- package/src/Application.js +421 -0
- package/src/interfaces/index.js +19 -0
- package/src/models/AchievementsContract.js +217 -0
- package/src/models/ArbitrationContract.js +69 -0
- package/src/models/ArbitrationProxyContract.js +32 -0
- package/src/models/ERC20Contract.js +156 -0
- package/src/models/FantasyERC20Contract.js +92 -0
- package/src/models/IContract.js +1002 -0
- package/src/models/PolkamarketsSmartAccount.js +100 -0
- package/src/models/PredictionMarketContract.js +562 -0
- package/src/models/PredictionMarketV2Contract.js +830 -0
- package/src/models/PredictionMarketV3Contract.js +233 -0
- package/src/models/PredictionMarketV3ControllerContract.js +102 -0
- package/src/models/PredictionMarketV3FactoryContract.js +96 -0
- package/src/models/PredictionMarketV3ManagerContract.js +111 -0
- package/src/models/PredictionMarketV3QuerierContract.js +24 -0
- package/src/models/RealitioERC20Contract.js +286 -0
- package/src/models/VotingContract.js +182 -0
- package/src/models/WETH9Contract.js +92 -0
- package/src/models/index.js +33 -0
- package/src/utils/Account.js +40 -0
- package/src/utils/Contract.js +120 -0
- package/src/utils/Numbers.js +94 -0
- package/tests/fantasyERC20Contract.js +225 -0
- package/tests/index.js +10 -0
- package/tests/predictionMarketContract.js +466 -0
- package/tests/predictionMarketV2Contract.js +1042 -0
- package/tests/predictionMarketV3Contract.js +1079 -0
- package/tests/predictionMarketV3ControllerContract.js +613 -0
- package/tests/predictionMarketV3FactoryContract.js +469 -0
- package/tests/predictionMarketV3ManagerContract.js +610 -0
- package/tests/utils.js +16 -0
- package/tests/votingContract.js +490 -0
- package/tooling/docs/jsdoc.json +6 -0
- package/truffle-config.js +134 -0
- package/polkamarkets.js +0 -422
package/CONTRIBUTING.md
ADDED
|
@@ -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
|
-

|
|
1
|
+
# 
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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/
|
|
60
|
-
- Prediction Market JS Integration: [PredictionMarketContract.js](https://github.com/
|
|
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 =
|
|
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
|
|
69
|
+
await contract.getMarketData({ marketId });
|
|
71
70
|
|
|
72
71
|
// Buying Outcome Shares
|
|
73
|
-
const mintOutcomeSharesToBuy = await
|
|
74
|
-
await
|
|
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
|
|
78
|
-
await
|
|
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
|
|
80
|
+
await contract.claimWinnings({ marketId });
|
|
82
81
|
|
|
83
82
|
// Fetching portfolio data
|
|
84
|
-
await
|
|
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/
|
|
98
|
+
[1]: https://github.com/Polkamarkets/polkamarkets-js/blob/main/CONTRIBUTING.md
|