@levrbet/shared 0.1.168 → 0.1.170
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/core/contracts/instances.d.ts +17 -3
- package/dist/core/contracts/instances.js +30 -2
- package/dist/core/contracts/instances.js.map +1 -1
- package/dist/core/prisma/generated/edge.js +4 -3
- package/dist/core/prisma/generated/index-browser.js +1 -0
- package/dist/core/prisma/generated/index.d.ts +28 -1
- package/dist/core/prisma/generated/index.js +4 -3
- package/dist/core/prisma/generated/package.json +1 -1
- package/dist/core/prisma/generated/schema.prisma +1 -0
- package/dist/core/prisma/generated/wasm.js +4 -3
- package/dist/core/utils/misc.utils.d.ts +6 -0
- package/dist/core/utils/misc.utils.js +17 -1
- package/dist/core/utils/misc.utils.js.map +1 -1
- package/dist/react/hooks/auth/useAuthHeaders.js +2 -1
- package/dist/react/hooks/auth/useAuthHeaders.js.map +1 -1
- package/dist/react/hooks/contracts/erc20/index.d.ts +6 -0
- package/dist/react/hooks/contracts/erc20/index.js +23 -0
- package/dist/react/hooks/contracts/erc20/index.js.map +1 -0
- package/dist/react/hooks/contracts/erc20/useApproveErc20.d.ts +13 -0
- package/dist/react/hooks/contracts/erc20/useApproveErc20.js +28 -0
- package/dist/react/hooks/contracts/erc20/useApproveErc20.js.map +1 -0
- package/dist/react/hooks/contracts/erc20/useErc20Allowance.d.ts +10 -0
- package/dist/react/hooks/contracts/erc20/useErc20Allowance.js +34 -0
- package/dist/react/hooks/contracts/erc20/useErc20Allowance.js.map +1 -0
- package/dist/react/hooks/contracts/erc20/useErc20Balance.d.ts +22 -0
- package/dist/react/hooks/contracts/erc20/useErc20Balance.js +95 -0
- package/dist/react/hooks/contracts/erc20/useErc20Balance.js.map +1 -0
- package/dist/react/hooks/contracts/erc20/useErc20Decimals.d.ts +8 -0
- package/dist/react/hooks/contracts/erc20/useErc20Decimals.js +28 -0
- package/dist/react/hooks/contracts/erc20/useErc20Decimals.js.map +1 -0
- package/dist/react/hooks/contracts/erc20/useErc20Symbol.d.ts +8 -0
- package/dist/react/hooks/contracts/erc20/useErc20Symbol.js +28 -0
- package/dist/react/hooks/contracts/erc20/useErc20Symbol.js.map +1 -0
- package/dist/react/hooks/contracts/erc20/useTransferErc20.d.ts +13 -0
- package/dist/react/hooks/contracts/erc20/useTransferErc20.js +31 -0
- package/dist/react/hooks/contracts/erc20/useTransferErc20.js.map +1 -0
- package/dist/react/hooks/contracts/index.d.ts +1 -0
- package/dist/react/hooks/contracts/index.js +1 -0
- package/dist/react/hooks/contracts/index.js.map +1 -1
- package/dist/react/hooks/contracts/useContracts.d.ts +7 -1
- package/dist/react/hooks/contracts/useContracts.js +24 -2
- package/dist/react/hooks/contracts/useContracts.js.map +1 -1
- package/dist/react/injectedDependencies.d.ts +4 -3
- package/dist/react/injectedDependencies.js.map +1 -1
- package/dist/react/queryKeys.d.ts +17 -0
- package/dist/react/queryKeys.js +23 -0
- package/dist/react/queryKeys.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
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.useErc20Symbol = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const core_1 = require("../../../../core");
|
|
9
|
+
const injectedDependencies_1 = require("../../../injectedDependencies");
|
|
10
|
+
const queryKeys_1 = require("../../../queryKeys");
|
|
11
|
+
const useErc20Symbol = ({ erc20Address, chainId: _chainId }) => {
|
|
12
|
+
const { useQuery, useChainId } = (0, injectedDependencies_1.getDependencies)();
|
|
13
|
+
const chainId = useChainId?.() ?? _chainId;
|
|
14
|
+
return useQuery({
|
|
15
|
+
queryKey: queryKeys_1.queryKeys.erc20.symbol(erc20Address, chainId),
|
|
16
|
+
queryFn: async () => {
|
|
17
|
+
if (!erc20Address || !chainId)
|
|
18
|
+
throw new Error("Missing erc20Address or chainId");
|
|
19
|
+
const contract = (0, core_1.getErc20Contract)(erc20Address, chainId);
|
|
20
|
+
return await contract.read.symbol();
|
|
21
|
+
},
|
|
22
|
+
enabled: !lodash_1.default.isNil(erc20Address) && !lodash_1.default.isNil(chainId),
|
|
23
|
+
staleTime: Infinity,
|
|
24
|
+
gcTime: Infinity,
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
exports.useErc20Symbol = useErc20Symbol;
|
|
28
|
+
//# sourceMappingURL=useErc20Symbol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useErc20Symbol.js","sourceRoot":"","sources":["../../../../../src/react/hooks/contracts/erc20/useErc20Symbol.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AAEtB,2CAA8D;AAC9D,wEAA+D;AAC/D,kDAA8C;AAOvC,MAAM,cAAc,GAAG,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAwB,EAAE,EAAE;IACxF,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAA,sCAAe,GAAE,CAAA;IAClD,MAAM,OAAO,GAAG,UAAU,EAAE,EAAE,IAAI,QAAQ,CAAA;IAE1C,OAAO,QAAQ,CAAC;QACZ,QAAQ,EAAE,qBAAS,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC;QACvD,OAAO,EAAE,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;YAEjF,MAAM,QAAQ,GAAG,IAAA,uBAAgB,EAAC,YAAY,EAAE,OAAO,CAAC,CAAA;YAExD,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAA;QACvC,CAAC;QACD,OAAO,EAAE,CAAC,gBAAC,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QACpD,SAAS,EAAE,QAAQ;QACnB,MAAM,EAAE,QAAQ;KACnB,CAAC,CAAA;AACN,CAAC,CAAA;AAjBY,QAAA,cAAc,kBAiB1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import { LevrChain } from "../../../../core";
|
|
3
|
+
interface UseTransferErc20Params {
|
|
4
|
+
erc20Address?: Address;
|
|
5
|
+
chainId?: LevrChain;
|
|
6
|
+
toAddress?: Address;
|
|
7
|
+
}
|
|
8
|
+
export declare const useTransferErc20: ({ erc20Address, chainId: _chainId, toAddress }?: UseTransferErc20Params) => import("@tanstack/react-query").UseMutationResult<{
|
|
9
|
+
hash: `0x${string}`;
|
|
10
|
+
}, Error, {
|
|
11
|
+
amount: bigint;
|
|
12
|
+
}, unknown>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTransferErc20 = void 0;
|
|
4
|
+
const core_1 = require("../../../../core");
|
|
5
|
+
const injectedDependencies_1 = require("../../../injectedDependencies");
|
|
6
|
+
const queryKeys_1 = require("../../../queryKeys");
|
|
7
|
+
const useTransferErc20 = ({ erc20Address, chainId: _chainId, toAddress } = {}) => {
|
|
8
|
+
const { useMutation, useChainId, useConnectorClient, useAccount } = (0, injectedDependencies_1.getDependencies)();
|
|
9
|
+
const chainId = useChainId?.() ?? _chainId;
|
|
10
|
+
const { data: walletClient } = useConnectorClient?.() ?? {};
|
|
11
|
+
const { address: userAddress } = useAccount?.() ?? {};
|
|
12
|
+
return useMutation({
|
|
13
|
+
mutationFn: async ({ amount }) => {
|
|
14
|
+
if (!erc20Address || !chainId || !toAddress)
|
|
15
|
+
throw new Error("Missing erc20Address, chainId, or toAddress");
|
|
16
|
+
if (!walletClient)
|
|
17
|
+
throw new Error("Wallet client not available");
|
|
18
|
+
const contract = (0, core_1.getErc20Contract)(erc20Address, chainId, { walletClient });
|
|
19
|
+
const hash = await contract.write.transfer([toAddress, amount]);
|
|
20
|
+
return { hash };
|
|
21
|
+
},
|
|
22
|
+
meta: {
|
|
23
|
+
invalidatesQueries: [
|
|
24
|
+
queryKeys_1.queryKeys.erc20.balance(erc20Address, userAddress, chainId),
|
|
25
|
+
queryKeys_1.queryKeys.erc20.balance(erc20Address, toAddress, chainId),
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.useTransferErc20 = useTransferErc20;
|
|
31
|
+
//# sourceMappingURL=useTransferErc20.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTransferErc20.js","sourceRoot":"","sources":["../../../../../src/react/hooks/contracts/erc20/useTransferErc20.ts"],"names":[],"mappings":";;;AACA,2CAA8D;AAC9D,wEAA+D;AAC/D,kDAA8C;AAQvC,MAAM,gBAAgB,GAAG,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,KAA6B,EAAE,EAAE,EAAE;IAC5G,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,IAAA,sCAAe,GAAE,CAAA;IACrF,MAAM,OAAO,GAAG,UAAU,EAAE,EAAE,IAAI,QAAQ,CAAA;IAC1C,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,kBAAkB,EAAE,EAAE,IAAI,EAAE,CAAA;IAC3D,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,EAAE,IAAI,EAAE,CAAA;IAErD,OAAO,WAAY,CAAC;QAChB,UAAU,EAAE,KAAK,EAAE,EAAE,MAAM,EAAsB,EAAE,EAAE;YACjD,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;YAC3G,IAAI,CAAC,YAAY;gBAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;YAEjE,MAAM,QAAQ,GAAG,IAAA,uBAAgB,EAAC,YAAY,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,CAAC,CAAA;YAC1E,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAA;YAE/D,OAAO,EAAE,IAAI,EAAE,CAAA;QACnB,CAAC;QACD,IAAI,EAAE;YACF,kBAAkB,EAAE;gBAChB,qBAAS,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC;gBAC3D,qBAAS,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC;aAC5D;SACJ;KACJ,CAAC,CAAA;AACN,CAAC,CAAA;AAvBY,QAAA,gBAAgB,oBAuB5B"}
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./erc20"), exports);
|
|
17
18
|
__exportStar(require("./useContracts"), exports);
|
|
18
19
|
__exportStar(require("./useLevrMarketContractAddresses"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/contracts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,mEAAgD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/contracts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,iDAA8B;AAC9B,mEAAgD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UseQueryResult } from "@tanstack/react-query";
|
|
2
|
-
import {
|
|
2
|
+
import { Address } from "viem";
|
|
3
|
+
import { getErc20Contract, getLevrContract, LevrChain } from "../../../core";
|
|
3
4
|
import { UseContractParams } from "../../types";
|
|
4
5
|
export interface UseContractsReturn {
|
|
5
6
|
levrConfigProvider: ReturnType<typeof getLevrContract<"levrConfigProvider">>;
|
|
@@ -112,3 +113,8 @@ export declare const useContractAddresses: (params?: UseContractParams) => {
|
|
|
112
113
|
readonly levrMarketMaker: "0x5c48f5aa8d216548147e4688c9f4e81acbc15324";
|
|
113
114
|
readonly levrMarketRiskSentinel: "0xcb4b4b18bc2d4f9e7e4a7bbb372e31d547635dcc";
|
|
114
115
|
};
|
|
116
|
+
export interface UseErc20ContractParams {
|
|
117
|
+
tokenAddress: Address;
|
|
118
|
+
chainId?: LevrChain;
|
|
119
|
+
}
|
|
120
|
+
export declare const useErc20Contract: (params: UseErc20ContractParams) => UseQueryResult<ReturnType<typeof getErc20Contract>, Error>;
|
|
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useContractAddresses = exports.useContracts = void 0;
|
|
6
|
+
exports.useErc20Contract = exports.useContractAddresses = exports.useContracts = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const core_1 = require("../../../core");
|
|
9
9
|
const injectedDependencies_1 = require("../../injectedDependencies");
|
|
10
|
+
const queryKeys_1 = require("../../queryKeys");
|
|
10
11
|
const useContracts = (params) => {
|
|
11
12
|
const { useQuery, useAccount, useChainId, useConnectorClient, levrEnv } = (0, injectedDependencies_1.getDependencies)();
|
|
12
13
|
const { chainId: _chainId } = params ?? {};
|
|
@@ -14,7 +15,7 @@ const useContracts = (params) => {
|
|
|
14
15
|
const chainId = useChainId?.() ?? _chainId;
|
|
15
16
|
const { data: walletClient } = useConnectorClient?.() ?? { data: undefined };
|
|
16
17
|
return useQuery({
|
|
17
|
-
queryKey:
|
|
18
|
+
queryKey: queryKeys_1.queryKeys.contracts.all(address, chainId, walletClient?.account?.address),
|
|
18
19
|
queryFn: async () => {
|
|
19
20
|
if (!chainId)
|
|
20
21
|
throw new Error("No chainId");
|
|
@@ -56,4 +57,25 @@ const useContractAddresses = (params) => {
|
|
|
56
57
|
return core_1.levrContractAddresses[levrEnv][chainId];
|
|
57
58
|
};
|
|
58
59
|
exports.useContractAddresses = useContractAddresses;
|
|
60
|
+
const useErc20Contract = (params) => {
|
|
61
|
+
const { useQuery, useAccount, useChainId, useConnectorClient } = (0, injectedDependencies_1.getDependencies)();
|
|
62
|
+
const { tokenAddress, chainId: _chainId } = params;
|
|
63
|
+
const { address } = useAccount?.() ?? { address: null };
|
|
64
|
+
const chainId = useChainId?.() ?? _chainId;
|
|
65
|
+
const { data: walletClient } = useConnectorClient?.() ?? { data: undefined };
|
|
66
|
+
return useQuery({
|
|
67
|
+
queryKey: queryKeys_1.queryKeys.contracts.erc20(tokenAddress, address, chainId, walletClient?.account?.address),
|
|
68
|
+
queryFn: async () => {
|
|
69
|
+
if (!chainId)
|
|
70
|
+
throw new Error("No chainId");
|
|
71
|
+
return (0, core_1.getErc20Contract)(tokenAddress, chainId, { walletClient });
|
|
72
|
+
},
|
|
73
|
+
enabled: !lodash_1.default.isNil(chainId) && !lodash_1.default.isNil(tokenAddress),
|
|
74
|
+
staleTime: Infinity,
|
|
75
|
+
gcTime: Infinity,
|
|
76
|
+
retry: false,
|
|
77
|
+
throwOnError: true,
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
exports.useErc20Contract = useErc20Contract;
|
|
59
81
|
//# sourceMappingURL=useContracts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContracts.js","sourceRoot":"","sources":["../../../../src/react/hooks/contracts/useContracts.ts"],"names":[],"mappings":";;;;;;AACA,oDAAsB;
|
|
1
|
+
{"version":3,"file":"useContracts.js","sourceRoot":"","sources":["../../../../src/react/hooks/contracts/useContracts.ts"],"names":[],"mappings":";;;;;;AACA,oDAAsB;AAEtB,wCAAmG;AACnG,qEAA4D;AAC5D,+CAA2C;AAyBpC,MAAM,YAAY,GAAG,CAAC,MAA0B,EAA6C,EAAE;IAClG,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,IAAA,sCAAe,GAAE,CAAA;IAC3F,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IACvD,MAAM,OAAO,GAAG,UAAU,EAAE,EAAE,IAAI,QAAQ,CAAA;IAC1C,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,kBAAkB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IAE5E,OAAO,QAAQ,CAAC;QACZ,QAAQ,EAAE,qBAAS,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;QACnF,OAAO,EAAE,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;YAE3C,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,CAAU,CAAA;YAElE,OAAO;gBACH,kBAAkB,EAAE,IAAA,sBAAe,EAAC,oBAAoB,EAAE,GAAG,YAAY,CAAC;gBAC1E,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AAE,qBAAS,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;QACnG,OAAO,EAAE,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;YAE3C,OAAO,IAAA,uBAAgB,EAAC,YAAY,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,CAAC,CAAA;QACpE,CAAC;QACD,OAAO,EAAE,CAAC,gBAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAC,CAAC,KAAK,CAAC,YAAY,CAAC;QACpD,SAAS,EAAE,QAAQ;QACnB,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,KAAK;QACZ,YAAY,EAAE,IAAI;KACrB,CAAC,CAAA;AACN,CAAC,CAAA;AApBY,QAAA,gBAAgB,oBAoB5B"}
|
|
@@ -19,16 +19,17 @@
|
|
|
19
19
|
* After injection, all hooks from this library will use the consumer's live React context and configuration.
|
|
20
20
|
*/
|
|
21
21
|
import { useIdentityToken, usePrivy, useUser } from "@privy-io/react-auth";
|
|
22
|
-
import type { useQuery } from "@tanstack/react-query";
|
|
23
|
-
import type { WalletClient } from "viem";
|
|
22
|
+
import type { useMutation, useQuery } from "@tanstack/react-query";
|
|
23
|
+
import type { Address, WalletClient } from "viem";
|
|
24
24
|
import { LevrChain, LevrEnv } from "../core";
|
|
25
25
|
export interface InjectedDependencies {
|
|
26
26
|
usePrivy: typeof usePrivy;
|
|
27
27
|
useIdentityToken: typeof useIdentityToken;
|
|
28
28
|
useUser: typeof useUser;
|
|
29
29
|
useQuery: typeof useQuery;
|
|
30
|
+
useMutation: typeof useMutation;
|
|
30
31
|
useAccount?: () => {
|
|
31
|
-
address?:
|
|
32
|
+
address?: Address;
|
|
32
33
|
};
|
|
33
34
|
useChainId?: () => LevrChain | undefined;
|
|
34
35
|
useConnectorClient?: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectedDependencies.js","sourceRoot":"","sources":["../../src/react/injectedDependencies.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;
|
|
1
|
+
{"version":3,"file":"injectedDependencies.js","sourceRoot":"","sources":["../../src/react/injectedDependencies.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AA4CH,gDAoBC;AAaD,0CAWC;AAOD,8DAEC;AA9ED;;GAEG;AACH,IAAI,oBAAoB,GAAgC,IAAI,CAAA;AAE5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,kBAAkB,CAAC,YAAkC;IACjE,IAAI,oBAAoB,KAAK,IAAI,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CACR,oDAAoD;YAChD,iFAAiF,CACxF,CAAA;IACL,CAAC;IAED,uDAAuD;IACvD,IACI,CAAC,YAAY,CAAC,QAAQ;QACtB,CAAC,YAAY,CAAC,gBAAgB;QAC9B,CAAC,YAAY,CAAC,OAAO;QACrB,CAAC,YAAY,CAAC,QAAQ;QACtB,CAAC,YAAY,CAAC,OAAO,EACvB,CAAC;QACC,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAA;IACpH,CAAC;IAED,oBAAoB,GAAG,YAAY,CAAA;AACvC,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,eAAe;IAC3B,IAAI,oBAAoB,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACX,uCAAuC;YACnC,6FAA6F;YAC7F,4CAA4C;YAC5C,iGAAiG,CACxG,CAAA;IACL,CAAC;IAED,OAAO,oBAAoB,CAAA;AAC/B,CAAC;AAED;;;;GAIG;AACH,SAAgB,yBAAyB;IACrC,oBAAoB,GAAG,IAAI,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import { LevrAuth, LevrChain } from "../core";
|
|
3
|
+
export declare const queryKeys: {
|
|
4
|
+
readonly auth: {
|
|
5
|
+
readonly headers: (levrAuth: LevrAuth, userId?: string, address?: Address) => string[];
|
|
6
|
+
};
|
|
7
|
+
readonly contracts: {
|
|
8
|
+
readonly all: (address?: Address | string | null, chainId?: LevrChain, walletAddress?: Address | string) => (string | LevrChain)[];
|
|
9
|
+
readonly erc20: (tokenAddress: Address, address?: Address | string | null, chainId?: LevrChain, walletAddress?: Address | string) => (string | LevrChain)[];
|
|
10
|
+
};
|
|
11
|
+
readonly erc20: {
|
|
12
|
+
readonly decimals: (tokenAddress?: Address, chainId?: LevrChain) => (string | LevrChain)[];
|
|
13
|
+
readonly symbol: (tokenAddress?: Address, chainId?: LevrChain) => (string | LevrChain)[];
|
|
14
|
+
readonly balance: (tokenAddress?: Address, userAddress?: Address | string | null, chainId?: LevrChain) => (string | LevrChain)[];
|
|
15
|
+
readonly allowance: (tokenAddress?: Address, ownerAddress?: Address | string | null, spenderAddress?: Address | string | null, chainId?: LevrChain) => (string | LevrChain)[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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.queryKeys = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
exports.queryKeys = {
|
|
9
|
+
auth: {
|
|
10
|
+
headers: (levrAuth, userId, address) => ["authHeaders", levrAuth, userId, address].filter((k) => !lodash_1.default.isNil(k)),
|
|
11
|
+
},
|
|
12
|
+
contracts: {
|
|
13
|
+
all: (address, chainId, walletAddress) => ["contracts", address, chainId, walletAddress].filter((k) => !lodash_1.default.isNil(k)),
|
|
14
|
+
erc20: (tokenAddress, address, chainId, walletAddress) => ["erc20Contract", tokenAddress, address, chainId, walletAddress].filter((k) => !lodash_1.default.isNil(k)),
|
|
15
|
+
},
|
|
16
|
+
erc20: {
|
|
17
|
+
decimals: (tokenAddress, chainId) => ["erc20", "decimals", tokenAddress, chainId].filter((k) => !lodash_1.default.isNil(k)),
|
|
18
|
+
symbol: (tokenAddress, chainId) => ["erc20", "symbol", tokenAddress, chainId].filter((k) => !lodash_1.default.isNil(k)),
|
|
19
|
+
balance: (tokenAddress, userAddress, chainId) => ["erc20", "balance", tokenAddress, userAddress, chainId].filter((k) => !lodash_1.default.isNil(k)),
|
|
20
|
+
allowance: (tokenAddress, ownerAddress, spenderAddress, chainId) => ["erc20", "allowance", tokenAddress, ownerAddress, spenderAddress, chainId].filter((k) => !lodash_1.default.isNil(k)),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=queryKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryKeys.js","sourceRoot":"","sources":["../../src/react/queryKeys.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AAIT,QAAA,SAAS,GAAG;IACrB,IAAI,EAAE;QACF,OAAO,EAAE,CAAC,QAAkB,EAAE,MAAe,EAAE,OAAiB,EAAE,EAAE,CAChE,CAAC,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,gBAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC5E;IACD,SAAS,EAAE;QACP,GAAG,EAAE,CAAC,OAAiC,EAAE,OAAmB,EAAE,aAAgC,EAAE,EAAE,CAC9F,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,gBAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7E,KAAK,EAAE,CACH,YAAqB,E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