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.
- 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/hardhat.config.js +4 -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 +256 -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 -436
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const arbitration = require("../interfaces").arbitration;
|
|
2
|
+
const Numbers = require("../utils/Numbers");
|
|
3
|
+
const IContract = require('./IContract');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Arbitration Contract Object
|
|
7
|
+
* @constructor ArbitrationContract
|
|
8
|
+
* @param {Web3} web3
|
|
9
|
+
* @param {Integer} decimals
|
|
10
|
+
* @param {Address} contractAddress
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
class ArbitrationContract extends IContract {
|
|
14
|
+
constructor(params) {
|
|
15
|
+
super({ abi: arbitration, ...params });
|
|
16
|
+
this.contractName = 'arbitration';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @function getDisputeFee
|
|
21
|
+
* @description get cost of applying for arbitration
|
|
22
|
+
* @param {bytes32} questionId
|
|
23
|
+
* @return {Integer} decimals
|
|
24
|
+
*/
|
|
25
|
+
async getDisputeFee({ questionId }) {
|
|
26
|
+
const fee = await this.params.contract.getContract().methods.getDisputeFee(questionId).call();
|
|
27
|
+
|
|
28
|
+
return Numbers.fromDecimalsNumber(fee, 18);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async getArbitrationDisputeId({ questionId }) {
|
|
32
|
+
const allEvents = await this.getEvents('ArbitrationCreated');
|
|
33
|
+
const questionEvents = allEvents.filter(event => event.returnValues._questionID === questionId);
|
|
34
|
+
|
|
35
|
+
if (questionEvents.length === 0) return null;
|
|
36
|
+
|
|
37
|
+
return Number(questionEvents[0].returnValues._disputeID);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async getArbitrationRequests({ questionId }) {
|
|
41
|
+
const allEvents = await this.getEvents('ArbitrationRequested');
|
|
42
|
+
const questionEvents = allEvents.filter(event => event.returnValues._questionID === questionId);
|
|
43
|
+
|
|
44
|
+
return questionEvents.map(event => ({
|
|
45
|
+
questionId: event.returnValues._questionID,
|
|
46
|
+
requester: event.returnValues._requester,
|
|
47
|
+
maxPrevious: Numbers.fromDecimalsNumber(event.returnValues._maxPrevious, 18)
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @function requestArbitration
|
|
53
|
+
* @description apply for arbitration
|
|
54
|
+
* @param {bytes32} questionId
|
|
55
|
+
* @param {Integer} maxPrevious
|
|
56
|
+
*/
|
|
57
|
+
async requestArbitration({ questionId, bond }) {
|
|
58
|
+
const fee = await this.params.contract.getContract().methods.getDisputeFee(questionId).call();
|
|
59
|
+
const maxPrevious = Numbers.toSmartContractDecimals(bond, 18);
|
|
60
|
+
|
|
61
|
+
return await this.__sendTx(
|
|
62
|
+
this.getContract().methods.requestArbitration(questionId, maxPrevious),
|
|
63
|
+
false,
|
|
64
|
+
fee
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = ArbitrationContract;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const arbitrationProxy = require("../interfaces").arbitrationProxy;
|
|
2
|
+
const Numbers = require("../utils/Numbers");
|
|
3
|
+
const IContract = require('./IContract');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ArbitrationProxy Contract Object
|
|
7
|
+
* @constructor ArbitrationProxyContract
|
|
8
|
+
* @param {Web3} web3
|
|
9
|
+
* @param {Integer} decimals
|
|
10
|
+
* @param {Address} contractAddress
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
class ArbitrationProxyContract extends IContract {
|
|
14
|
+
constructor(params) {
|
|
15
|
+
super({ abi: arbitrationProxy, ...params });
|
|
16
|
+
this.contractName = 'arbitrationProxy';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getArbitrationRequestsRejected({ questionId }) {
|
|
20
|
+
const allEvents = await this.getEvents('RequestRejected');
|
|
21
|
+
const questionEvents = allEvents.filter(event => event.returnValues._questionID === questionId);
|
|
22
|
+
|
|
23
|
+
return questionEvents.map(event => ({
|
|
24
|
+
questionId: event.returnValues._questionID,
|
|
25
|
+
requester: event.returnValues._requester,
|
|
26
|
+
maxPrevious: Numbers.fromDecimalsNumber(event.returnValues._maxPrevious, 18),
|
|
27
|
+
reason: event.returnValues._reason
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = ArbitrationProxyContract;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const ierc20 = require("../interfaces").ierc20;
|
|
2
|
+
const Numbers = require("../utils/Numbers");
|
|
3
|
+
const IContract = require('./IContract');
|
|
4
|
+
|
|
5
|
+
class ERC20Contract extends IContract {
|
|
6
|
+
constructor(params, abi) {
|
|
7
|
+
super({...params, abi: params.abi || ierc20});
|
|
8
|
+
this.contractName = 'erc20';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async __assert() {
|
|
12
|
+
await super.__assert();
|
|
13
|
+
this.params.decimals = await this.getDecimalsAsync();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async transferTokenAmount({ toAddress, tokenAmount }) {
|
|
17
|
+
let amountWithDecimals = Numbers.toSmartContractDecimals(
|
|
18
|
+
tokenAmount,
|
|
19
|
+
this.getDecimals()
|
|
20
|
+
);
|
|
21
|
+
return await this.__sendTx(
|
|
22
|
+
this.getContract()
|
|
23
|
+
.methods.transfer(toAddress, amountWithDecimals)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getTokenAmount(address) {
|
|
28
|
+
return Numbers.fromDecimals(
|
|
29
|
+
await this.getContract().methods.balanceOf(address).call(),
|
|
30
|
+
this.getDecimals()
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async totalSupply() {
|
|
35
|
+
return Numbers.fromDecimals(await this.getContract().methods.totalSupply().call(), this.getDecimals());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getABI() {
|
|
39
|
+
return this.params.contract;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getDecimals() {
|
|
43
|
+
return this.params.decimals;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getDecimalsAsync() {
|
|
47
|
+
return await this.getContract().methods.decimals().call();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async balanceOf({ address }) {
|
|
51
|
+
const decimals = this.getDecimals() || (await this.getDecimalsAsync());
|
|
52
|
+
return Numbers.fromDecimalsNumber(await this.getContract().methods.balanceOf(address).call(), decimals);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async isApproved({ address, amount, spenderAddress }) {
|
|
56
|
+
try {
|
|
57
|
+
let approvedAmount = Numbers.fromDecimals(
|
|
58
|
+
await this.getContract().methods.allowance(address, spenderAddress).call(),
|
|
59
|
+
this.getDecimals()
|
|
60
|
+
);
|
|
61
|
+
return (approvedAmount >= amount);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async approve({ address, amount, callback }) {
|
|
68
|
+
try {
|
|
69
|
+
let amountWithDecimals = Numbers.toSmartContractDecimals(
|
|
70
|
+
amount,
|
|
71
|
+
this.getDecimals() || (await this.getDecimalsAsync())
|
|
72
|
+
);
|
|
73
|
+
let res = await this.__sendTx(
|
|
74
|
+
this.getContract().methods.approve(address, amountWithDecimals),
|
|
75
|
+
null,
|
|
76
|
+
null,
|
|
77
|
+
callback
|
|
78
|
+
);
|
|
79
|
+
return res;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async burn({ amount }) {
|
|
86
|
+
try {
|
|
87
|
+
let amountWithDecimals = Numbers.toSmartContractDecimals(
|
|
88
|
+
amount,
|
|
89
|
+
this.getDecimals()
|
|
90
|
+
);
|
|
91
|
+
let res = await this.__sendTx(
|
|
92
|
+
this.getContract().methods.burn(amountWithDecimals),
|
|
93
|
+
false,
|
|
94
|
+
);
|
|
95
|
+
return res;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
throw err;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async mint({ address, amount }) {
|
|
102
|
+
try {
|
|
103
|
+
let amountWithDecimals = Numbers.toSmartContractDecimals(
|
|
104
|
+
amount,
|
|
105
|
+
this.getDecimals()
|
|
106
|
+
);
|
|
107
|
+
let res = await this.__sendTx(
|
|
108
|
+
this.getContract().methods.mint(address, amountWithDecimals),
|
|
109
|
+
false,
|
|
110
|
+
);
|
|
111
|
+
return res;
|
|
112
|
+
} catch (err) {
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async burnEvents({ address }) {
|
|
118
|
+
const events = await this.getEvents(
|
|
119
|
+
'Transfer',
|
|
120
|
+
{ from: address, to: '0x0000000000000000000000000000000000000000' }
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
// attaching block timestamp to event
|
|
124
|
+
return await Promise.all(events.map(async (event) => {
|
|
125
|
+
const block = await this.getBlock(event.blockNumber);
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
...event,
|
|
129
|
+
timestamp: block.timestamp
|
|
130
|
+
};
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async name() {
|
|
135
|
+
return await this.getContract().methods.name().call();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async symbol() {
|
|
139
|
+
return await this.getContract().methods.symbol().call();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async paused() {
|
|
143
|
+
return await this.getContract().methods.paused().call();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async getTokenInfo() {
|
|
147
|
+
return {
|
|
148
|
+
name: await this.name(),
|
|
149
|
+
address: this.getAddress(),
|
|
150
|
+
ticker: await this.symbol(),
|
|
151
|
+
decimals: await this.getDecimalsAsync(),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = ERC20Contract;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const fantasyerc20 = require("../interfaces").fantasyerc20;
|
|
2
|
+
const ERC20Contract = require("./ERC20Contract");
|
|
3
|
+
|
|
4
|
+
const Numbers = require("../utils/Numbers");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fantasy ERC20 Contract Object
|
|
8
|
+
* @constructor FantasyERC20Contract
|
|
9
|
+
* @param {Web3} web3
|
|
10
|
+
* @param {Integer} decimals
|
|
11
|
+
* @param {Address} contractAddress
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
class FantasyERC20Contract extends ERC20Contract {
|
|
15
|
+
constructor(params) {
|
|
16
|
+
super({ abi: fantasyerc20, ...params });
|
|
17
|
+
this.contractName = 'erc20';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Get Functions */
|
|
21
|
+
/**
|
|
22
|
+
* @function hasUserClaimedTokens
|
|
23
|
+
* @description Returns if the user has already claimed the tokens
|
|
24
|
+
* @returns {Boolean} claimedTokens
|
|
25
|
+
*/
|
|
26
|
+
async hasUserClaimedTokens({ address }) {
|
|
27
|
+
return await this.params.contract
|
|
28
|
+
.getContract()
|
|
29
|
+
.methods
|
|
30
|
+
.hasUserClaimedTokens(address)
|
|
31
|
+
.call();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @function tokenAmountToClaim
|
|
36
|
+
* @description Returns the amount of tokens to claim
|
|
37
|
+
* @returns {Integer} tokenAmountToClaim
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
async tokenAmountToClaim() {
|
|
41
|
+
const tokenAmountToClaim = Numbers.fromDecimalsNumber(
|
|
42
|
+
await this.params.contract
|
|
43
|
+
.getContract()
|
|
44
|
+
.methods
|
|
45
|
+
.tokenAmountToClaim()
|
|
46
|
+
.call(),
|
|
47
|
+
this.getDecimals()
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return tokenAmountToClaim;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* POST User Functions */
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @function claimTokens
|
|
57
|
+
* @description Claim tokens for sender
|
|
58
|
+
*/
|
|
59
|
+
async claimTokens() {
|
|
60
|
+
return await this.__sendTx(
|
|
61
|
+
this.getContract().methods.claimTokens()
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @function claimAndApproveTokens
|
|
67
|
+
* @description Claim and approve tokens for sender
|
|
68
|
+
*/
|
|
69
|
+
async claimAndApproveTokens() {
|
|
70
|
+
return await this.__sendTx(
|
|
71
|
+
this.getContract().methods.claimAndApproveTokens()
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @function resetBalance
|
|
77
|
+
* @description Reset user's balance to tokenAmountToClaim
|
|
78
|
+
*/
|
|
79
|
+
async resetBalance() {
|
|
80
|
+
const address = await this.getMyAccount();
|
|
81
|
+
if (!address) return false;
|
|
82
|
+
|
|
83
|
+
const tokenAmountToClaim = await this.tokenAmountToClaim();
|
|
84
|
+
const balance = await this.getTokenAmount(address);
|
|
85
|
+
|
|
86
|
+
const amountToBurn = balance - tokenAmountToClaim > 0 ? balance - tokenAmountToClaim : 0;
|
|
87
|
+
|
|
88
|
+
return await this.burn({ amount: amountToBurn });
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = FantasyERC20Contract;
|