@azuro-org/toolkit 3.0.0 → 4.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.
Files changed (66) hide show
  1. package/.eslintrc +166 -0
  2. package/README.md +7 -110
  3. package/codegen.ts +62 -0
  4. package/dist/abis/FreeBet.d.ts +426 -0
  5. package/dist/abis/LP.d.ts +1469 -0
  6. package/dist/abis/LiveCore.d.ts +694 -0
  7. package/dist/abis/PrematchComboCore.d.ts +740 -0
  8. package/dist/abis/PrematchCore.d.ts +819 -0
  9. package/dist/abis/ProxyFront.d.ts +137 -0
  10. package/dist/abis/index.d.ts +6 -0
  11. package/dist/config.d.ts +51 -0
  12. package/dist/docs/index.d.ts +22 -0
  13. package/dist/docs/live/condition.d.ts +28 -0
  14. package/dist/docs/live/conditions.d.ts +29 -0
  15. package/dist/docs/live/fragments/condition.d.ts +20 -0
  16. package/dist/docs/live/types.d.ts +1902 -0
  17. package/dist/docs/prematch/bettors.d.ts +21 -0
  18. package/dist/docs/prematch/condition.d.ts +40 -0
  19. package/dist/docs/prematch/conditions.d.ts +41 -0
  20. package/dist/docs/prematch/conditionsBatch.d.ts +22 -0
  21. package/dist/docs/prematch/fragments/bettor.d.ts +12 -0
  22. package/dist/docs/prematch/fragments/condition.d.ts +32 -0
  23. package/dist/docs/prematch/fragments/liveBet.d.ts +42 -0
  24. package/dist/docs/prematch/fragments/mainGameInfo.d.ts +31 -0
  25. package/dist/docs/prematch/fragments/prematchBet.d.ts +75 -0
  26. package/dist/docs/prematch/game.d.ts +39 -0
  27. package/dist/docs/prematch/gameBets.d.ts +54 -0
  28. package/dist/docs/prematch/games.d.ts +43 -0
  29. package/dist/docs/prematch/liveBets.d.ts +54 -0
  30. package/dist/docs/prematch/navigation.d.ts +34 -0
  31. package/dist/docs/prematch/prematchBets.d.ts +87 -0
  32. package/dist/docs/prematch/sports.d.ts +63 -0
  33. package/dist/docs/prematch/sportsNavigation.d.ts +22 -0
  34. package/dist/docs/prematch/types.d.ts +6307 -0
  35. package/dist/global.d.ts +6 -0
  36. package/dist/helpers/formatToFixed.d.ts +1 -0
  37. package/dist/index.d.ts +24 -1
  38. package/dist/index.js +5709 -0
  39. package/dist/utils/calcMindOdds.d.ts +6 -0
  40. package/dist/utils/calcOdds.d.ts +28 -0
  41. package/dist/utils/deBridge/createDeBridgeBet.d.ts +65 -0
  42. package/dist/utils/deBridge/getDeBridgeOrder.d.ts +39 -0
  43. package/dist/utils/deBridge/getDeBridgeSupportedChains.d.ts +4 -0
  44. package/dist/utils/deBridge/getDeBridgeSupportedTokens.d.ts +8 -0
  45. package/dist/utils/getBetStatus.d.ts +17 -0
  46. package/dist/utils/getEndpoints.d.ts +5 -0
  47. package/dist/utils/getFreebets.d.ts +35 -0
  48. package/dist/utils/getGameStatus.d.ts +16 -0
  49. package/dist/utils/getLiveBetFee.d.ts +14 -0
  50. package/dist/utils/getPrematchBetDataBytes.d.ts +3 -0
  51. package/dist/utils/groupByConditionId.d.ts +5 -0
  52. package/dist/utils/groupConditionsByMarket.d.ts +23 -0
  53. package/dist/utils/setupContracts.d.ts +37 -0
  54. package/dist/utils/wave/activateWave.d.ts +10 -0
  55. package/dist/utils/wave/getWaveLeaderBoard.d.ts +22 -0
  56. package/dist/utils/wave/getWaveLevels.d.ts +26 -0
  57. package/dist/utils/wave/getWavePeriods.d.ts +18 -0
  58. package/dist/utils/wave/getWaveStats.d.ts +30 -0
  59. package/graphql.config.yml +21 -0
  60. package/package.json +24 -8
  61. package/tsconfig.json +25 -10
  62. package/dist/aggregateOutcomesByMarkets.d.ts +0 -25
  63. package/dist/index.es.js +0 -109
  64. package/lib/aggregateOutcomesByMarkets.d.ts +0 -25
  65. package/lib/index.d.ts +0 -1
  66. package/lib/index.js +0 -109
package/.eslintrc ADDED
@@ -0,0 +1,166 @@
1
+ {
2
+ "extends": [
3
+ "plugin:import/errors",
4
+ "plugin:import/warnings",
5
+ "plugin:import/recommended"
6
+ ],
7
+ "parser": "@typescript-eslint/parser",
8
+ "plugins": [
9
+ "import",
10
+ "@typescript-eslint"
11
+ ],
12
+ "ignorePatterns": [
13
+ "*.js",
14
+ "*.graphql.ts",
15
+ "src/docs/*",
16
+ "examples/**",
17
+ "*.json",
18
+ "codegen.ts"
19
+ // "./dist"
20
+ ],
21
+ "settings": {
22
+ "import/parsers": {
23
+ "@typescript-eslint/parser": [".ts", ".tsx"]
24
+ },
25
+ "import/resolver": {
26
+ "typescript": "./tsconfig.json"
27
+ }
28
+ },
29
+ "parserOptions": {
30
+ "project": "./tsconfig.json"
31
+ },
32
+ "rules": {
33
+ // Common
34
+
35
+ "padding-line-between-statements": [
36
+ "error",
37
+ {
38
+ "blankLine": "always",
39
+ "prev": "*",
40
+ "next": [ "return", "if", "try" ]
41
+ }
42
+ ],
43
+
44
+ "eol-last": [
45
+ "error",
46
+ "always"
47
+ ],
48
+ "curly": [
49
+ "error"
50
+ ],
51
+ "indent": "off",
52
+ "quotes": [
53
+ "error",
54
+ "single"
55
+ ],
56
+ "brace-style": [
57
+ "error",
58
+ "stroustrup"
59
+ ],
60
+ "prefer-const": "off",
61
+ "key-spacing": [
62
+ "error",
63
+ { "beforeColon": false }
64
+ ],
65
+ "arrow-spacing": "error",
66
+ "space-infix-ops": "error",
67
+ "space-before-blocks": "error",
68
+ "no-multi-spaces": "warn",
69
+ "no-trailing-spaces": "warn",
70
+ "semi": [
71
+ "error",
72
+ "never"
73
+ ],
74
+ "max-len": "off",
75
+ "object-curly-spacing": [
76
+ "error",
77
+ "always"
78
+ ],
79
+ "array-bracket-spacing": [
80
+ "error",
81
+ "always"
82
+ ],
83
+ "no-multiple-empty-lines": [
84
+ "error",
85
+ {
86
+ "max": 2
87
+ }
88
+ ],
89
+ "comma-spacing": "warn",
90
+ "comma-dangle": [
91
+ "error",
92
+ {
93
+ "arrays": "always-multiline",
94
+ "objects": "always-multiline",
95
+ "imports": "always-multiline",
96
+ "exports": "always-multiline",
97
+ "functions": "never"
98
+ }
99
+ ],
100
+ "keyword-spacing": "error",
101
+
102
+ // Import plugin
103
+
104
+ "import/order": [
105
+ "error",
106
+ {
107
+ "groups": [
108
+ [ "builtin", "external" ],
109
+ "internal"
110
+ ],
111
+ "pathGroups": [
112
+ {
113
+ "pattern": "react",
114
+ "group": "builtin",
115
+ "position": "before"
116
+ },
117
+ {
118
+ "pattern": "wagmi",
119
+ "group": "external"
120
+ },
121
+ {
122
+ "pattern": "viem",
123
+ "group": "external"
124
+ },
125
+ {
126
+ "pattern": "cookies-next",
127
+ "group": "external"
128
+ },
129
+ {
130
+ "pattern": "@apollo/**",
131
+ "group": "external"
132
+ }
133
+ ],
134
+ "newlines-between": "always"
135
+ }
136
+ ],
137
+ "import/first": 0,
138
+ "import/extensions": 0,
139
+ "import/no-unresolved": 0,
140
+ "import/no-dynamic-require": 0,
141
+ "import/prefer-default-export": 0,
142
+ "import/no-webpack-loader-syntax": 0,
143
+ "import/no-named-as-default-member": 1,
144
+ "import/no-extraneous-dependencies": 0,
145
+ "import/no-anonymous-default-export": 0,
146
+ "import/newline-after-import": [
147
+ "error",
148
+ {
149
+ "count": 2
150
+ }
151
+ ],
152
+ // typescript
153
+ "@typescript-eslint/no-explicit-any": "off",
154
+ "@typescript-eslint/no-for-in-array": "error",
155
+ "@typescript-eslint/await-thenable": "warn",
156
+ "@typescript-eslint/consistent-type-imports": "error",
157
+ "@typescript-eslint/type-annotation-spacing": "error",
158
+ "@typescript-eslint/indent": [
159
+ "error",
160
+ 2,
161
+ {
162
+ "SwitchCase": 1
163
+ }
164
+ ]
165
+ }
166
+ }
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Toolkit Package
1
+ # Toolkit
2
2
 
3
3
  This package provides helpers to develop an app using Azuro Protocol.
4
4
 
@@ -9,116 +9,13 @@ This package provides helpers to develop an app using Azuro Protocol.
9
9
  npm i --save @azuro-org/toolkit
10
10
  ```
11
11
 
12
+ #### Peer Dependencies
12
13
 
13
- ## Helpers
14
-
15
- ### `aggregateOutcomesByMarkets.ts`
16
-
17
- This helper function allows you to aggregate outcomes that are obtained from conditions by markets. This function takes
18
- an array of conditions and groups outcomes by their market key. It then sorts the outcomes within each market group
19
- and returns an array of market objects, each containing an array of outcomes.
20
-
21
- Here is an example of how you can use it:
22
-
23
- ```graphql
24
- query Game($id: String!) {
25
- game(id: $id) {
26
- liquidityPool {
27
- address
28
- }
29
- conditions {
30
- conditionId
31
- coreAddress
32
- outcomes {
33
- outcomeId
34
- }
35
- }
36
- }
37
- }
38
- ```
39
-
40
- ```ts
41
- type Conditions = {
42
- conditionId: string
43
- coreAddress: string
44
- outcomes: {
45
- outcomeId: string
46
- }
47
- }
48
-
49
- aggregateOutcomesByMarkets({
50
- lpAddress: game.liquidityPool.lpAddress,
51
- conditions: game.conditions,
52
- dictionaries, // **
53
- })
54
- ```
55
-
56
- The result will be of type
57
-
58
- ```ts
59
- type Outcome = {
60
- selectionName: string
61
- conditionId: string
62
- outcomeId: string
63
- lpAddress: string
64
- coreAddress: string
65
- }
66
-
67
- type OutcomesByMarkets = {
68
- marketName: string
69
- outcomes: Outcome[][] // *
70
- }[]
71
14
  ```
72
-
73
- `*` returned `outcomes` are wrapped with additional array `Outcome[][]`
74
-
75
- `**` `dictionaries` contain a set of texts for each outcome ID used in Azuro. These texts can be used to display outcomes
76
- in a user-friendly way and provide more context about what the outcome represents. Dictionaries are an important
77
- component of Azuro's infrastructure as they allow for standardized and consistent outcomes across all markets and events.
78
- [Read more about dictionaries](https://azuro-v2-docs.surge.sh/build-own-app/dive-deeper/dictionaries).
79
-
80
- ---
81
-
82
- You can pass additional data in outcomes if required, the helper will add it to outcomes in the result:
83
-
84
- ```graphql {11}
85
- query Game($id: String!) {
86
- game(id: $id) {
87
- ...
88
- conditions {
89
- ...
90
- outcomes {
91
- ...
92
- odds
93
- }
94
- }
95
- }
96
- }
15
+ @apollo/client@^3.8.0-beta.7
16
+ @azuro-org/dictionaries@^3.0.12
17
+ viem@^2.17.3
18
+ @wagmi/core@^2.11.7
97
19
  ```
98
20
 
99
- ```ts
100
- type MyOutcome = {
101
- outcomeId: string
102
- odds: string
103
- }
104
-
105
- aggregateOutcomesByMarkets<MyOutcome>(...)
106
- ```
107
-
108
- The result will be of type
109
-
110
- ```ts {7}
111
- type Outcome = {
112
- selectionName: string
113
- conditionId: string
114
- outcomeId: string
115
- lpAddress: string
116
- coreAddress: string
117
- odds: string
118
- }
119
-
120
- type OutcomesByMarkets = {
121
- marketName: string
122
- outcomes: Outcome[][]
123
- }[]
124
- ```
21
+ Package information can be found in our [Doc](https://gem.azuro.org/hub/apps/toolkit/overview)
package/codegen.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { CodegenConfig } from '@graphql-codegen/cli'
2
+
3
+
4
+ const config: CodegenConfig = {
5
+ ignoreNoDocuments: true,
6
+ generates: {
7
+ 'src/docs/prematch/types.ts': {
8
+ schema: 'https://thegraph.azuro.org/subgraphs/name/azuro-protocol/azuro-api-polygon-v3',
9
+ plugins: [
10
+ 'typescript',
11
+ ],
12
+ },
13
+ 'src/docs/prematch': {
14
+ preset: 'near-operation-file',
15
+ schema: 'https://thegraph.azuro.org/subgraphs/name/azuro-protocol/azuro-api-polygon-v3',
16
+ documents: 'src/docs/prematch/**/*.graphql',
17
+ presetConfig: {
18
+ extension: '.ts',
19
+ baseTypesPath: 'types.ts',
20
+ },
21
+ plugins: [
22
+ 'typescript-operations',
23
+ 'typescript-react-apollo',
24
+ ],
25
+ config: {
26
+ withHooks: false,
27
+ scalars: {
28
+ 'BigInt': 'string',
29
+ 'BigDecimal': 'string',
30
+ }
31
+ },
32
+ },
33
+ 'src/docs/live/types.ts': {
34
+ schema: 'https://thegraph.azuro.org/subgraphs/name/azuro-protocol/azuro-api-live-data-feed-dev',
35
+ plugins: [
36
+ 'typescript',
37
+ ],
38
+ },
39
+ 'src/docs/live': {
40
+ preset: 'near-operation-file',
41
+ schema: 'https://thegraph.azuro.org/subgraphs/name/azuro-protocol/azuro-api-live-data-feed-dev',
42
+ documents: 'src/docs/live/**/*.graphql',
43
+ presetConfig: {
44
+ extension: '.ts',
45
+ baseTypesPath: 'types.ts',
46
+ },
47
+ plugins: [
48
+ 'typescript-operations',
49
+ 'typescript-react-apollo',
50
+ ],
51
+ config: {
52
+ withHooks: false,
53
+ scalars: {
54
+ 'BigInt': 'string',
55
+ 'BigDecimal': 'string',
56
+ }
57
+ },
58
+ },
59
+ },
60
+ }
61
+
62
+ export default config