@levrbet/shared 0.1.69 → 0.1.71
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/dist/react/hooks/contracts/index.d.ts +2 -0
- package/dist/react/hooks/contracts/index.js +19 -0
- package/dist/react/hooks/contracts/index.js.map +1 -0
- package/dist/react/hooks/contracts/useContracts.d.ts +10 -0
- package/dist/react/hooks/contracts/useContracts.js +34 -0
- package/dist/react/hooks/contracts/useContracts.js.map +1 -0
- package/dist/react/hooks/contracts/useLevrMarketContractAddresses.d.ts +3 -0
- package/dist/react/hooks/contracts/useLevrMarketContractAddresses.js +26 -0
- package/dist/react/hooks/contracts/useLevrMarketContractAddresses.js.map +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/types/contracts.types.d.ts +8 -0
- package/dist/react/types/contracts.types.js +3 -0
- package/dist/react/types/contracts.types.js.map +1 -0
- package/dist/react/types/index.d.ts +1 -0
- package/dist/react/types/index.js +18 -0
- package/dist/react/types/index.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useContracts"), exports);
|
|
18
|
+
__exportStar(require("./useLevrMarketContractAddresses"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/contracts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,mEAAgD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import { getLevrContract } from "../../../core";
|
|
3
|
+
import { UseContractParams } from "../../types/contracts.types";
|
|
4
|
+
export interface UseContractsReturn {
|
|
5
|
+
levrManager: ReturnType<typeof getLevrContract<"levrManager">>;
|
|
6
|
+
levrMarketRouter: ReturnType<typeof getLevrContract<"levrMarketRouter">>;
|
|
7
|
+
levrMvpRouter: ReturnType<typeof getLevrContract<"levrMvpRouter">>;
|
|
8
|
+
levrOrderbook: ReturnType<typeof getLevrContract<"levrOrderbook">>;
|
|
9
|
+
}
|
|
10
|
+
export declare const useContracts: ({ address, chainId, walletClient, LEVR_ENV, }: UseContractParams) => UseQueryResult<UseContractsReturn, Error>;
|
|
@@ -0,0 +1,34 @@
|
|
|
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.useContracts = void 0;
|
|
7
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const core_1 = require("../../../core");
|
|
10
|
+
const useContracts = ({ address, chainId, walletClient, LEVR_ENV, }) => {
|
|
11
|
+
return (0, react_query_1.useQuery)({
|
|
12
|
+
queryKey: ["contracts", address, chainId, walletClient?.account?.address],
|
|
13
|
+
queryFn: async () => {
|
|
14
|
+
if (!chainId)
|
|
15
|
+
throw new Error("No chainId");
|
|
16
|
+
if (walletClient?.account?.address !== address)
|
|
17
|
+
throw new Error("Wallet client address does not match account address");
|
|
18
|
+
const contractArgs = [chainId, LEVR_ENV, { walletClient }];
|
|
19
|
+
return {
|
|
20
|
+
levrManager: (0, core_1.getLevrContract)("levrManager", ...contractArgs),
|
|
21
|
+
levrMarketRouter: (0, core_1.getLevrContract)("levrMarketRouter", ...contractArgs),
|
|
22
|
+
levrMvpRouter: (0, core_1.getLevrContract)("levrMvpRouter", ...contractArgs),
|
|
23
|
+
levrOrderbook: (0, core_1.getLevrContract)("levrOrderbook", ...contractArgs),
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
enabled: !lodash_1.default.isNil(chainId),
|
|
27
|
+
staleTime: Infinity,
|
|
28
|
+
gcTime: Infinity,
|
|
29
|
+
retry: false,
|
|
30
|
+
throwOnError: true,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.useContracts = useContracts;
|
|
34
|
+
//# sourceMappingURL=useContracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContracts.js","sourceRoot":"","sources":["../../../../src/react/hooks/contracts/useContracts.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgE;AAChE,oDAAsB;AACtB,wCAA+C;AAUxC,MAAM,YAAY,GAAG,CAAC,EACzB,OAAO,EACP,OAAO,EACP,YAAY,EACZ,QAAQ,GACQ,EAA6C,EAAE;IAC/D,OAAO,IAAA,sBAAQ,EAAC;QACZ,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;QACzE,OAAO,EAAE,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;YAC3C,IAAI,YAAY,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO;gBAC1C,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;YAE3E,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,YAAY,EAAE,CAAU,CAAA;YAEnE,OAAO;gBACH,WAAW,EAAE,IAAA,sBAAe,EAAC,aAAa,EAAE,GAAG,YAAY,CAAC;gBAC5D,gBAAgB,EAAE,IAAA,sBAAe,EAAC,kBAAkB,EAAE,GAAG,YAAY,CAAC;gBACtE,aAAa,EAAE,IAAA,sBAAe,EAAC,eAAe,EAAE,GAAG,YAAY,CAAC;gBAChE,aAAa,EAAE,IAAA,sBAAe,EAAC,eAAe,EAAE,GAAG,YAAY,CAAC;aACnE,CAAA;QACL,CAAC;QACD,OAAO,EAAE,CAAC,gBAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QAC1B,SAAS,EAAE,QAAQ;QACnB,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,KAAK;QACZ,YAAY,EAAE,IAAI;KACrB,CAAC,CAAA;AACN,CAAC,CAAA;AA5BY,QAAA,YAAY,gBA4BxB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { LevrMarketId } from "../../../core";
|
|
2
|
+
import { UseContractParams } from "../../types/contracts.types";
|
|
3
|
+
export declare const useLevrMarketContractAddresses: (params: UseContractParams) => import("@tanstack/react-query").UseQueryResult<Record<LevrMarketId, `0x${string}`>, Error>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLevrMarketContractAddresses = void 0;
|
|
4
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
+
const core_1 = require("../../../core");
|
|
6
|
+
const useContracts_1 = require("./useContracts");
|
|
7
|
+
const MARKET_IDS = [core_1.LevrMarketId.FULL_TIME_WINNER, core_1.LevrMarketId.OVER_UNDER];
|
|
8
|
+
const useLevrMarketContractAddresses = (params) => {
|
|
9
|
+
const { data: contracts } = (0, useContracts_1.useContracts)(params);
|
|
10
|
+
return (0, react_query_1.useQuery)({
|
|
11
|
+
queryKey: ["levrMarketContractAddresses", params],
|
|
12
|
+
queryFn: async () => {
|
|
13
|
+
if (!contracts)
|
|
14
|
+
throw new Error("No contracts");
|
|
15
|
+
const entries = await Promise.all(MARKET_IDS.map((marketId) => contracts.levrManager.read
|
|
16
|
+
.getLevrMarketContractAddress([marketId])
|
|
17
|
+
.then((address) => [marketId, address])));
|
|
18
|
+
return Object.fromEntries(entries);
|
|
19
|
+
},
|
|
20
|
+
enabled: !!contracts,
|
|
21
|
+
staleTime: Infinity,
|
|
22
|
+
gcTime: Infinity,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.useLevrMarketContractAddresses = useLevrMarketContractAddresses;
|
|
26
|
+
//# sourceMappingURL=useLevrMarketContractAddresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLevrMarketContractAddresses.js","sourceRoot":"","sources":["../../../../src/react/hooks/contracts/useLevrMarketContractAddresses.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD,wCAA4C;AAE5C,iDAA6C;AAE7C,MAAM,UAAU,GAAG,CAAC,mBAAY,CAAC,gBAAgB,EAAE,mBAAY,CAAC,UAAU,CAAU,CAAA;AAE7E,MAAM,8BAA8B,GAAG,CAAC,MAAyB,EAAE,EAAE;IACxE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAA,2BAAY,EAAC,MAAM,CAAC,CAAA;IAEhD,OAAO,IAAA,sBAAQ,EAAC;QACZ,QAAQ,EAAE,CAAC,6BAA6B,EAAE,MAAM,CAAC;QACjD,OAAO,EAAE,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;YAE/C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACxB,SAAS,CAAC,WAAW,CAAC,IAAI;iBACrB,4BAA4B,CAAC,CAAC,QAAQ,CAAC,CAAC;iBACxC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAC,CACvD,CACJ,CAAA;YAED,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAkC,CAAA;QACvE,CAAC;QACD,OAAO,EAAE,CAAC,CAAC,SAAS;QACpB,SAAS,EAAE,QAAQ;QACnB,MAAM,EAAE,QAAQ;KACnB,CAAC,CAAA;AACN,CAAC,CAAA;AAtBY,QAAA,8BAA8B,kCAsB1C"}
|
package/dist/react/index.d.ts
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("../core"), exports);
|
|
18
18
|
__exportStar(require("./hooks"), exports);
|
|
19
19
|
__exportStar(require("./queryClient"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,0CAAuB;AACvB,gDAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,0CAAuB;AACvB,gDAA6B;AAC7B,0CAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.types.js","sourceRoot":"","sources":["../../../src/react/types/contracts.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./contracts.types";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./contracts.types"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levrbet/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.71",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"jose": "^6.1.0",
|
|
80
80
|
"lodash": "^4.17.21",
|
|
81
81
|
"ms": "^2.1.3",
|
|
82
|
+
"object-hash": "^3.0.0",
|
|
82
83
|
"ox": "^0.9.7",
|
|
83
84
|
"rate-limit-redis": "^4.2.2",
|
|
84
85
|
"redis": "^5.8.2",
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
"@types/lodash": "^4.17.20",
|
|
95
96
|
"@types/ms": "^2.1.0",
|
|
96
97
|
"@types/node": "24.6.0",
|
|
98
|
+
"@types/object-hash": "^3.0.6",
|
|
97
99
|
"@types/react": "19.1.16",
|
|
98
100
|
"cross-fetch": "^4.1.0",
|
|
99
101
|
"prisma": "^6.16.2",
|