hive-stream 2.0.3 → 2.0.5

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 (99) hide show
  1. package/.env +3 -1
  2. package/.env.example +3 -2
  3. package/.travis.yml +11 -11
  4. package/LICENSE +21 -21
  5. package/README.md +238 -236
  6. package/dist/actions.d.ts +10 -9
  7. package/dist/actions.js +23 -15
  8. package/dist/actions.js.map +1 -1
  9. package/dist/adapters/base.adapter.d.ts +25 -21
  10. package/dist/adapters/base.adapter.js +49 -63
  11. package/dist/adapters/base.adapter.js.map +1 -1
  12. package/dist/adapters/mongodb.adapter.d.ts +37 -29
  13. package/dist/adapters/mongodb.adapter.js +158 -113
  14. package/dist/adapters/mongodb.adapter.js.map +1 -1
  15. package/dist/adapters/sqlite.adapter.d.ts +41 -23
  16. package/dist/adapters/sqlite.adapter.js +397 -121
  17. package/dist/adapters/sqlite.adapter.js.map +1 -1
  18. package/dist/api.d.ts +6 -0
  19. package/dist/api.js +56 -0
  20. package/dist/api.js.map +1 -0
  21. package/dist/config.d.ts +16 -14
  22. package/dist/config.js +18 -15
  23. package/dist/config.js.map +1 -1
  24. package/dist/contracts/coinflip.contract.d.ts +14 -0
  25. package/dist/contracts/coinflip.contract.js +95 -0
  26. package/dist/contracts/coinflip.contract.js.map +1 -0
  27. package/dist/contracts/dice.contract.d.ts +29 -29
  28. package/dist/contracts/dice.contract.js +155 -157
  29. package/dist/contracts/dice.contract.js.map +1 -1
  30. package/dist/contracts/lotto.contract.d.ts +20 -16
  31. package/dist/contracts/lotto.contract.js +246 -107
  32. package/dist/contracts/lotto.contract.js.map +1 -1
  33. package/dist/exchanges/bittrex.d.ts +6 -0
  34. package/dist/exchanges/bittrex.js +35 -0
  35. package/dist/exchanges/bittrex.js.map +1 -0
  36. package/dist/exchanges/exchange.d.ts +9 -0
  37. package/dist/exchanges/exchange.js +27 -0
  38. package/dist/exchanges/exchange.js.map +1 -0
  39. package/dist/hive-rates.d.ts +9 -0
  40. package/dist/hive-rates.js +76 -0
  41. package/dist/hive-rates.js.map +1 -0
  42. package/dist/index.d.ts +11 -10
  43. package/dist/index.js +32 -15
  44. package/dist/index.js.map +1 -1
  45. package/dist/streamer.d.ts +93 -70
  46. package/dist/streamer.js +545 -439
  47. package/dist/streamer.js.map +1 -1
  48. package/dist/test.d.ts +1 -1
  49. package/dist/test.js +25 -27
  50. package/dist/test.js.map +1 -1
  51. package/dist/types/hive-stream.d.ts +6 -6
  52. package/dist/types/hive-stream.js +2 -2
  53. package/dist/utils.d.ts +27 -14
  54. package/dist/utils.js +261 -85
  55. package/dist/utils.js.map +1 -1
  56. package/ecosystem.config.js +17 -17
  57. package/jest.config.js +8 -13
  58. package/package.json +48 -44
  59. package/test-contract-block.md +18 -18
  60. package/tests/adapters/sqlite.adapter.spec.ts +43 -0
  61. package/tests/contracts/coinflip.contract.spec.ts +132 -0
  62. package/tests/contracts/dice.contract.spec.ts +159 -156
  63. package/tests/contracts/entrants.json +728 -728
  64. package/tests/contracts/lotto.contract.spec.ts +323 -372
  65. package/tests/setup.ts +18 -20
  66. package/tests/streamer.spec.ts +151 -151
  67. package/tests/utils.spec.ts +94 -99
  68. package/tsconfig.build.json +22 -20
  69. package/tslint.json +20 -20
  70. package/wallaby.js +26 -0
  71. package/dist/adapters/file.adapter.d.ts +0 -8
  72. package/dist/adapters/file.adapter.js +0 -70
  73. package/dist/adapters/file.adapter.js.map +0 -1
  74. package/dist/test/setup.d.ts +0 -0
  75. package/dist/test/setup.js +0 -9
  76. package/dist/test/setup.js.map +0 -1
  77. package/dist/test/streamer.spec.d.ts +0 -1
  78. package/dist/test/streamer.spec.js +0 -145
  79. package/dist/test/streamer.spec.js.map +0 -1
  80. package/dist/test/utils.spec.d.ts +0 -1
  81. package/dist/test/utils.spec.js +0 -11
  82. package/dist/test/utils.spec.js.map +0 -1
  83. package/dist/tests/contracts/dice.contract.spec.d.ts +0 -1
  84. package/dist/tests/contracts/dice.contract.spec.js +0 -130
  85. package/dist/tests/contracts/dice.contract.spec.js.map +0 -1
  86. package/dist/tests/contracts/entrants.json +0 -729
  87. package/dist/tests/contracts/lotto.contract.spec.d.ts +0 -1
  88. package/dist/tests/contracts/lotto.contract.spec.js +0 -300
  89. package/dist/tests/contracts/lotto.contract.spec.js.map +0 -1
  90. package/dist/tests/setup.d.ts +0 -1
  91. package/dist/tests/setup.js +0 -19
  92. package/dist/tests/setup.js.map +0 -1
  93. package/dist/tests/streamer.spec.d.ts +0 -1
  94. package/dist/tests/streamer.spec.js +0 -123
  95. package/dist/tests/streamer.spec.js.map +0 -1
  96. package/dist/tests/utils.spec.d.ts +0 -1
  97. package/dist/tests/utils.spec.js +0 -87
  98. package/dist/tests/utils.spec.js.map +0 -1
  99. package/hive-stream.json +0 -1
package/dist/config.d.ts CHANGED
@@ -1,14 +1,16 @@
1
- export interface ConfigInterface {
2
- ACTIVE_KEY: string;
3
- POSTING_KEY: string;
4
- JSON_ID: string;
5
- APP_NAME: string;
6
- USERNAME: string;
7
- PAYLOAD_IDENTIFIER: string;
8
- LAST_BLOCK_NUMBER: number;
9
- BLOCK_CHECK_INTERVAL: number;
10
- BLOCKS_BEHIND_WARNING: number;
11
- API_NODES: string[];
12
- DEBUG_MODE: boolean;
13
- }
14
- export declare const Config: ConfigInterface;
1
+ export interface ConfigInterface {
2
+ ACTIVE_KEY: string;
3
+ POSTING_KEY: string;
4
+ JSON_ID: string;
5
+ HIVE_ENGINE_API: string;
6
+ HIVE_ENGINE_ID: string;
7
+ APP_NAME: string;
8
+ USERNAME: string;
9
+ PAYLOAD_IDENTIFIER: string;
10
+ LAST_BLOCK_NUMBER: number;
11
+ BLOCK_CHECK_INTERVAL: number;
12
+ BLOCKS_BEHIND_WARNING: number;
13
+ API_NODES: string[];
14
+ DEBUG_MODE: boolean;
15
+ }
16
+ export declare const Config: ConfigInterface;
package/dist/config.js CHANGED
@@ -1,16 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Config = {
4
- ACTIVE_KEY: process.env.ACTIVE_KEY,
5
- POSTING_KEY: process.env.POSTING_KEY,
6
- JSON_ID: 'hivestream',
7
- APP_NAME: 'steem-stream',
8
- PAYLOAD_IDENTIFIER: 'hivePayload',
9
- USERNAME: '',
10
- LAST_BLOCK_NUMBER: 0,
11
- BLOCK_CHECK_INTERVAL: 1000,
12
- BLOCKS_BEHIND_WARNING: 25,
13
- API_NODES: ['https://anyx.io', 'https://api.hive.blog'],
14
- DEBUG_MODE: false,
15
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Config = void 0;
4
+ exports.Config = {
5
+ ACTIVE_KEY: process.env.ACTIVE_KEY,
6
+ POSTING_KEY: process.env.POSTING_KEY,
7
+ JSON_ID: 'hivestream',
8
+ HIVE_ENGINE_API: 'https://api.hive-engine.com/rpc',
9
+ HIVE_ENGINE_ID: 'ssc-mainnet-hive',
10
+ APP_NAME: 'steem-stream',
11
+ PAYLOAD_IDENTIFIER: 'hivePayload',
12
+ USERNAME: '',
13
+ LAST_BLOCK_NUMBER: 42203941,
14
+ BLOCK_CHECK_INTERVAL: 1000,
15
+ BLOCKS_BEHIND_WARNING: 25,
16
+ API_NODES: ['https://anyx.io', 'https://api.hive.blog'],
17
+ DEBUG_MODE: true,
18
+ };
16
19
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AAca,QAAA,MAAM,GAAoB;IACnC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;IAClC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IAEpC,OAAO,EAAE,YAAY;IAErB,QAAQ,EAAE,cAAc;IAExB,kBAAkB,EAAE,aAAa;IAEjC,QAAQ,EAAE,EAAE;IAEZ,iBAAiB,EAAE,CAAC;IAEpB,oBAAoB,EAAE,IAAI;IAC1B,qBAAqB,EAAE,EAAE;IAEzB,SAAS,EAAE,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;IAEvD,UAAU,EAAE,KAAK;CACpB,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAgBa,QAAA,MAAM,GAAoB;IACnC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;IAClC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IAEpC,OAAO,EAAE,YAAY;IAErB,eAAe,EAAE,iCAAiC;IAClD,cAAc,EAAE,kBAAkB;IAElC,QAAQ,EAAE,cAAc;IAExB,kBAAkB,EAAE,aAAa;IAEjC,QAAQ,EAAE,EAAE;IAEZ,iBAAiB,EAAE,QAAQ;IAE3B,oBAAoB,EAAE,IAAI;IAC1B,qBAAqB,EAAE,EAAE;IAEzB,SAAS,EAAE,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;IAEvD,UAAU,EAAE,IAAI;CACnB,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare class CoinflipContract {
2
+ private _instance;
3
+ private adapter;
4
+ private blockNumber;
5
+ private blockId;
6
+ private previousBlockId;
7
+ private transactionId;
8
+ private create;
9
+ private updateBlockInfo;
10
+ flip(payload: any, { sender, amount }: {
11
+ sender: any;
12
+ amount: any;
13
+ }): Promise<void>;
14
+ }
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CoinflipContract = void 0;
7
+ const seedrandom_1 = __importDefault(require("seedrandom"));
8
+ const uuid_1 = require("uuid");
9
+ const CONTRACT_NAME = 'coinflip';
10
+ const ACCOUNT = 'beggars';
11
+ const TOKEN_SYMBOL = 'HIVE';
12
+ const VALID_CURRENCIES = ['HIVE'];
13
+ const MAX_AMOUNT = 20;
14
+ function rng(previousBlockId, blockId, transactionId, serverSeed, clientSeed = '') {
15
+ const random = (0, seedrandom_1.default)(`${previousBlockId}${blockId}${transactionId}${clientSeed}${serverSeed}`).double();
16
+ const randomRoll = Math.floor(random * 2) + 1;
17
+ return randomRoll === 1 ? 'heads' : 'tails';
18
+ }
19
+ class CoinflipContract {
20
+ // tslint:disable-next-line: variable-name
21
+ _instance;
22
+ adapter;
23
+ blockNumber;
24
+ blockId;
25
+ previousBlockId;
26
+ transactionId;
27
+ create() {
28
+ this.adapter = this._instance.getAdapter();
29
+ }
30
+ updateBlockInfo(blockNumber, blockId, previousBlockId, transactionId) {
31
+ // Lifecycle method which sets block info
32
+ this.blockNumber = blockNumber;
33
+ this.blockId = blockId;
34
+ this.previousBlockId = previousBlockId;
35
+ this.transactionId = transactionId;
36
+ }
37
+ async flip(payload, { sender, amount }) {
38
+ const { guess, seed } = payload;
39
+ const VALID_GUESSES = ['heads', 'tails'];
40
+ const amountTrim = amount.split(' ');
41
+ const amountParsed = parseFloat(amountTrim[0]);
42
+ const amountCurrency = amountTrim[1].trim();
43
+ const transaction = await this._instance.getTransaction(this.blockNumber, this.transactionId);
44
+ const verify = await this._instance.verifyTransfer(transaction, sender, ACCOUNT, amount);
45
+ if (verify) {
46
+ // User sent an invalid currency
47
+ if (!VALID_CURRENCIES.includes(amountCurrency)) {
48
+ await this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] You sent an invalid currency.`);
49
+ return;
50
+ }
51
+ // User sent too much, refund the difference
52
+ if (amountParsed > MAX_AMOUNT) {
53
+ await this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] You sent too much.`);
54
+ return;
55
+ }
56
+ // Invalid guess
57
+ if (!VALID_GUESSES.includes(guess)) {
58
+ await this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] Invalid guess. Please only send heads or tails.`);
59
+ return;
60
+ }
61
+ const serverSeed = (0, uuid_1.v4)();
62
+ const generatedGuess = rng(this.previousBlockId, this.blockId, this.transactionId, serverSeed, seed ?? '');
63
+ if (generatedGuess === guess) {
64
+ await this.adapter.addEvent(new Date(), CONTRACT_NAME, 'flip', payload, {
65
+ action: 'transfer',
66
+ data: {
67
+ date: new Date(),
68
+ guess,
69
+ serverSeed,
70
+ previousBlockId: this.previousBlockId,
71
+ blockId: this.blockId,
72
+ transactionId: this.transactionId,
73
+ userWon: 'true'
74
+ }
75
+ });
76
+ await this._instance.transferHiveTokens(ACCOUNT, sender, (amountParsed * 2).toFixed(3), amountTrim[1], `[Winner] | Guess: ${guess} | Server Roll: ${generatedGuess} | Previous block id: ${this.previousBlockId} | BlockID: ${this.blockId} | Trx ID: ${this.transactionId} | Server Seed: ${serverSeed}`);
77
+ return;
78
+ }
79
+ await this.adapter.addEvent(new Date(), CONTRACT_NAME, 'flip', payload, {
80
+ action: 'transfer',
81
+ data: {
82
+ guess,
83
+ serverSeed,
84
+ previousBlockId: this.previousBlockId,
85
+ blockId: this.blockId,
86
+ transactionId: this.transactionId,
87
+ userWon: 'false'
88
+ }
89
+ });
90
+ await this._instance.transferHiveTokens(ACCOUNT, sender, '0.001', amountTrim[1], `[Lost] | Guess: ${guess} | Server Roll: ${generatedGuess} | Previous block id: ${this.previousBlockId} | BlockID: ${this.blockId} | Trx ID: ${this.transactionId} | Server Seed: ${serverSeed}`);
91
+ }
92
+ }
93
+ }
94
+ exports.CoinflipContract = CoinflipContract;
95
+ //# sourceMappingURL=coinflip.contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coinflip.contract.js","sourceRoot":"","sources":["../../src/contracts/coinflip.contract.ts"],"names":[],"mappings":";;;;;;AACA,4DAAoC;AACpC,+BAAoC;AAEpC,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC,MAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAM,gBAAgB,GAAG,CAAC,MAAM,CAAC,CAAC;AAClC,MA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AAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,mBAAmB,KAAK,mBAAmB,cAAc,yBAAyB,IAAI,CAAC,eAAe,eAAe,IAAI,CAAC,OAAO,cAAc,IAAI,CAAC,aAAa,mBAAmB,UAAU,EAAE,CAAC,CAAC;SACtR;IACL,CAAC;CACJ;AAzFD,4CAyFC"}
@@ -1,29 +1,29 @@
1
- export declare class DiceContract {
2
- private _instance;
3
- private blockNumber;
4
- private blockId;
5
- private previousBlockId;
6
- private transactionId;
7
- private create;
8
- private destroy;
9
- private updateBlockInfo;
10
- /**
11
- * Get Balance
12
- *
13
- * Helper method for getting the contract account balance. In the case of our dice contract
14
- * we want to make sure the account has enough money to pay out any bets
15
- *
16
- * @returns number
17
- */
18
- private getBalance;
19
- /**
20
- * Roll
21
- *
22
- * Automatically called when a custom JSON action matches the following method
23
- *
24
- * @param payload
25
- * @param param1 - sender and amount
26
- */
27
- private roll;
28
- private testauto;
29
- }
1
+ export declare class DiceContract {
2
+ private _instance;
3
+ private blockNumber;
4
+ private blockId;
5
+ private previousBlockId;
6
+ private transactionId;
7
+ private create;
8
+ private destroy;
9
+ private updateBlockInfo;
10
+ /**
11
+ * Get Balance
12
+ *
13
+ * Helper method for getting the contract account balance. In the case of our dice contract
14
+ * we want to make sure the account has enough money to pay out any bets
15
+ *
16
+ * @returns number
17
+ */
18
+ private getBalance;
19
+ /**
20
+ * Roll
21
+ *
22
+ * Automatically called when a custom JSON action matches the following method
23
+ *
24
+ * @param payload
25
+ * @param param1 - sender and amount
26
+ */
27
+ private roll;
28
+ private testauto;
29
+ }
@@ -1,158 +1,156 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const seedrandom_1 = __importDefault(require("seedrandom"));
16
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
- const CONTRACT_NAME = 'hivedice';
18
- const ACCOUNT = 'beggars';
19
- const TOKEN_SYMBOL = 'HIVE';
20
- const HOUSE_EDGE = 0.05;
21
- const MIN_BET = 1;
22
- const MAX_BET = 10;
23
- // Random Number Generator
24
- const rng = (previousBlockId, blockId, transactionId) => {
25
- const random = seedrandom_1.default(`${previousBlockId}${blockId}${transactionId}`).double();
26
- const randomRoll = Math.floor(random * 100) + 1;
27
- return randomRoll;
28
- };
29
- // Valid betting currencies
30
- const VALID_CURRENCIES = ['HIVE'];
31
- class DiceContract {
32
- create() {
33
- // Runs every time register is called on this contract
34
- // Do setup logic and code in here (creating a database, etc)
35
- }
36
- destroy() {
37
- // Runs every time unregister is run for this contract
38
- // Close database connections, write to a database with state, etc
39
- }
40
- // Updates the contract with information about the current block
41
- // This is a method automatically called if it exists
42
- updateBlockInfo(blockNumber, blockId, previousBlockId, transactionId) {
43
- // Lifecycle method which sets block info
44
- this.blockNumber = blockNumber;
45
- this.blockId = blockId;
46
- this.previousBlockId = previousBlockId;
47
- this.transactionId = transactionId;
48
- }
49
- /**
50
- * Get Balance
51
- *
52
- * Helper method for getting the contract account balance. In the case of our dice contract
53
- * we want to make sure the account has enough money to pay out any bets
54
- *
55
- * @returns number
56
- */
57
- getBalance() {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const account = yield this._instance['client'].database.getAccounts([ACCOUNT]);
60
- if (account === null || account === void 0 ? void 0 : account[0]) {
61
- const balance = account[0].balance.split(' ');
62
- const amount = balance[0];
63
- return parseFloat(amount);
64
- }
65
- return null;
66
- });
67
- }
68
- /**
69
- * Roll
70
- *
71
- * Automatically called when a custom JSON action matches the following method
72
- *
73
- * @param payload
74
- * @param param1 - sender and amount
75
- */
76
- roll(payload, { sender, amount }) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- // Destructure the values from the payload
79
- const { roll } = payload;
80
- // The amount is formatted like 100 HIVE
81
- // The value is the first part, the currency symbol is the second
82
- const amountTrim = amount.split(' ');
83
- // Parse the numeric value as a real value
84
- const amountParsed = parseFloat(amountTrim[0]);
85
- // Format the amount to 3 decimal places
86
- const amountFormatted = parseFloat(amountTrim[0]).toFixed(3);
87
- // Trim any space from the currency symbol
88
- const amountCurrency = amountTrim[1].trim();
89
- console.log(`Roll: ${roll}
90
- Amount parsed: ${amountParsed}
91
- Amount formatted: ${amountFormatted}
92
- Currency: ${amountCurrency}`);
93
- // Get the transaction from the blockchain
94
- const transaction = yield this._instance.getTransaction(this.blockNumber, this.transactionId);
95
- // Call the verifyTransfer method to confirm the transfer happened
96
- const verify = yield this._instance.verifyTransfer(transaction, sender, 'beggars', amount);
97
- // Get the balance of our contract account
98
- const balance = yield this.getBalance();
99
- // Transfer is valid
100
- if (verify) {
101
- // Server balance is less than the max bet, cancel and refund
102
- if (balance < MAX_BET) {
103
- // Send back what was sent, the server is broke
104
- yield this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] The server could not fufill your bet.`);
105
- return;
106
- }
107
- // Bet amount is valid
108
- if (amountParsed >= MIN_BET && amountParsed <= MAX_BET) {
109
- // Validate roll is valid
110
- if ((roll >= 2 && roll <= 96) && VALID_CURRENCIES.includes(amountCurrency)) {
111
- // Roll a random value
112
- const random = rng(this.previousBlockId, this.blockId, this.transactionId);
113
- // Calculate the multiplier percentage
114
- const multiplier = new bignumber_js_1.default(1).minus(HOUSE_EDGE).multipliedBy(100).dividedBy(roll);
115
- // Calculate the number of tokens won
116
- const tokensWon = new bignumber_js_1.default(amountParsed).multipliedBy(multiplier).toFixed(3, bignumber_js_1.default.ROUND_DOWN);
117
- // Memo that shows in users memo when they win
118
- const winningMemo = `You won ${tokensWon} ${TOKEN_SYMBOL}. Roll: ${random}, Your guess: ${roll}`;
119
- // Memo that shows in users memo when they lose
120
- const losingMemo = `You lost ${amountParsed} ${TOKEN_SYMBOL}. Roll: ${random}, Your guess: ${roll}`;
121
- // User won more than the server can afford, refund the bet amount
122
- if (parseFloat(tokensWon) > balance) {
123
- yield this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] The server could not fufill your bet.`);
124
- return;
125
- }
126
- // If random value is less than roll
127
- if (random < roll) {
128
- yield this._instance.transferHiveTokens(ACCOUNT, sender, tokensWon, TOKEN_SYMBOL, winningMemo);
129
- }
130
- else {
131
- yield this._instance.transferHiveTokens(ACCOUNT, sender, '0.001', TOKEN_SYMBOL, losingMemo);
132
- }
133
- }
134
- else {
135
- // Invalid bet parameters, refund the user their bet
136
- yield this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] Invalid bet params.`);
137
- }
138
- }
139
- else {
140
- try {
141
- // We need to refund the user
142
- const transfer = yield this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] You sent an invalid bet amount.`);
143
- console.log(transfer);
144
- }
145
- catch (e) {
146
- console.log(e);
147
- }
148
- }
149
- }
150
- });
151
- }
152
- // Called by our time-based action
153
- testauto() {
154
- console.log('test');
155
- }
156
- }
157
- exports.DiceContract = DiceContract;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DiceContract = void 0;
7
+ const seedrandom_1 = __importDefault(require("seedrandom"));
8
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
+ const CONTRACT_NAME = 'hivedice';
10
+ const ACCOUNT = 'beggars';
11
+ const TOKEN_SYMBOL = 'HIVE';
12
+ const HOUSE_EDGE = 0.05;
13
+ const MIN_BET = 1;
14
+ const MAX_BET = 10;
15
+ // Random Number Generator
16
+ const rng = (previousBlockId, blockId, transactionId) => {
17
+ const random = (0, seedrandom_1.default)(`${previousBlockId}${blockId}${transactionId}`).double();
18
+ const randomRoll = Math.floor(random * 100) + 1;
19
+ return randomRoll;
20
+ };
21
+ // Valid betting currencies
22
+ const VALID_CURRENCIES = ['HIVE'];
23
+ class DiceContract {
24
+ // tslint:disable-next-line: variable-name
25
+ _instance;
26
+ blockNumber;
27
+ blockId;
28
+ previousBlockId;
29
+ transactionId;
30
+ create() {
31
+ // Runs every time register is called on this contract
32
+ // Do setup logic and code in here (creating a database, etc)
33
+ }
34
+ destroy() {
35
+ // Runs every time unregister is run for this contract
36
+ // Close database connections, write to a database with state, etc
37
+ }
38
+ // Updates the contract with information about the current block
39
+ // This is a method automatically called if it exists
40
+ updateBlockInfo(blockNumber, blockId, previousBlockId, transactionId) {
41
+ // Lifecycle method which sets block info
42
+ this.blockNumber = blockNumber;
43
+ this.blockId = blockId;
44
+ this.previousBlockId = previousBlockId;
45
+ this.transactionId = transactionId;
46
+ }
47
+ /**
48
+ * Get Balance
49
+ *
50
+ * Helper method for getting the contract account balance. In the case of our dice contract
51
+ * we want to make sure the account has enough money to pay out any bets
52
+ *
53
+ * @returns number
54
+ */
55
+ async getBalance() {
56
+ const account = await this._instance['client'].database.getAccounts([ACCOUNT]);
57
+ if (account?.[0]) {
58
+ const balance = account[0].balance.split(' ');
59
+ const amount = balance[0];
60
+ return parseFloat(amount);
61
+ }
62
+ return null;
63
+ }
64
+ /**
65
+ * Roll
66
+ *
67
+ * Automatically called when a custom JSON action matches the following method
68
+ *
69
+ * @param payload
70
+ * @param param1 - sender and amount
71
+ */
72
+ async roll(payload, { sender, amount }) {
73
+ try {
74
+ // Destructure the values from the payload
75
+ const { roll } = payload;
76
+ // The amount is formatted like 100 HIVE
77
+ // The value is the first part, the currency symbol is the second
78
+ const amountTrim = amount.split(' ');
79
+ // Parse the numeric value as a real value
80
+ const amountParsed = parseFloat(amountTrim[0]);
81
+ // Format the amount to 3 decimal places
82
+ const amountFormatted = parseFloat(amountTrim[0]).toFixed(3);
83
+ // Trim any space from the currency symbol
84
+ const amountCurrency = amountTrim[1].trim();
85
+ // console.log(`Roll: ${roll}
86
+ // Amount parsed: ${amountParsed}
87
+ // Amount formatted: ${amountFormatted}
88
+ // Currency: ${amountCurrency}`);
89
+ // Get the transaction from the blockchain
90
+ const transaction = await this._instance.getTransaction(this.blockNumber, this.transactionId);
91
+ // Call the verifyTransfer method to confirm the transfer happened
92
+ const verify = await this._instance.verifyTransfer(transaction, sender, 'beggars', amount);
93
+ // Get the balance of our contract account
94
+ const balance = await this.getBalance();
95
+ // Transfer is valid
96
+ if (verify) {
97
+ // Server balance is less than the max bet, cancel and refund
98
+ if (balance < MAX_BET) {
99
+ // Send back what was sent, the server is broke
100
+ await this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] The server could not fufill your bet.`);
101
+ return;
102
+ }
103
+ // Bet amount is valid
104
+ if (amountParsed >= MIN_BET && amountParsed <= MAX_BET) {
105
+ // Validate roll is valid
106
+ if ((roll >= 2 && roll <= 96) && VALID_CURRENCIES.includes(amountCurrency)) {
107
+ // Roll a random value
108
+ const random = rng(this.previousBlockId, this.blockId, this.transactionId);
109
+ // Calculate the multiplier percentage
110
+ const multiplier = new bignumber_js_1.default(1).minus(HOUSE_EDGE).multipliedBy(100).dividedBy(roll);
111
+ // Calculate the number of tokens won
112
+ const tokensWon = new bignumber_js_1.default(amountParsed).multipliedBy(multiplier).toFixed(3, bignumber_js_1.default.ROUND_DOWN);
113
+ // Memo that shows in users memo when they win
114
+ const winningMemo = `You won ${tokensWon} ${TOKEN_SYMBOL}. Roll: ${random}, Your guess: ${roll}`;
115
+ // Memo that shows in users memo when they lose
116
+ const losingMemo = `You lost ${amountParsed} ${TOKEN_SYMBOL}. Roll: ${random}, Your guess: ${roll}`;
117
+ // User won more than the server can afford, refund the bet amount
118
+ if (parseFloat(tokensWon) > balance) {
119
+ await this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] The server could not fufill your bet.`);
120
+ return;
121
+ }
122
+ // If random value is less than roll
123
+ if (random < roll) {
124
+ await this._instance.transferHiveTokens(ACCOUNT, sender, tokensWon, TOKEN_SYMBOL, winningMemo);
125
+ }
126
+ else {
127
+ await this._instance.transferHiveTokens(ACCOUNT, sender, '0.001', TOKEN_SYMBOL, losingMemo);
128
+ }
129
+ }
130
+ else {
131
+ // Invalid bet parameters, refund the user their bet
132
+ await this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] Invalid bet params.`);
133
+ }
134
+ }
135
+ else {
136
+ try {
137
+ // We need to refund the user
138
+ await this._instance.transferHiveTokens(ACCOUNT, sender, amountTrim[0], amountTrim[1], `[Refund] You sent an invalid bet amount.`);
139
+ }
140
+ catch (e) {
141
+ console.log(e);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ catch (e) {
147
+ throw e;
148
+ }
149
+ }
150
+ // Called by our time-based action
151
+ testauto() {
152
+ console.log('test');
153
+ }
154
+ }
155
+ exports.DiceContract = DiceContract;
158
156
  //# sourceMappingURL=dice.contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dice.contract.js","sourceRoot":"","sources":["../../src/contracts/dice.contract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,4DAAoC;AACpC,gEAAqC;AAErC,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC,MAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,MAAM,YAAY,GAAG,MAAM,CAAC;AAE5B,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,0BAA0B;AAC1B,MAAM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