@tokenops/sdk 1.5.1 → 2.0.0-alpha.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/CHANGELOG.md +198 -2
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SECURITY.md +7 -1
- package/SUPPORT.md +47 -0
- package/dist/{chunk-YQIBBEFJ.js → chunk-335Z2W67.js} +1 -1
- package/dist/{chunk-2NCLOQ56.cjs → chunk-3QHNYEQD.cjs} +77 -0
- package/dist/chunk-456VDDA3.js +370 -0
- package/dist/{chunk-SG65XWH7.js → chunk-4RAAATVY.js} +1 -3
- package/dist/{chunk-6BMP4ICG.js → chunk-4TSDNZQ3.js} +60 -2
- package/dist/{chunk-PUPKNW3R.cjs → chunk-5576FRT3.cjs} +30 -6
- package/dist/{chunk-AOP6HMPW.js → chunk-6GNR22OV.js} +75 -1
- package/dist/{chunk-NTZY6IB7.js → chunk-6NAVMWZQ.js} +4 -3
- package/dist/{chunk-C7BRZXJA.cjs → chunk-6PXXGACR.cjs} +8 -7
- package/dist/{chunk-IJFQ5L4I.js → chunk-74QFZ5MK.js} +4 -3
- package/dist/chunk-7AFPOE7N.cjs +59 -0
- package/dist/chunk-AXIPOR3C.js +56 -0
- package/dist/chunk-CTED3MTR.cjs +380 -0
- package/dist/{chunk-XGGTQQFH.js → chunk-DZHYSUGY.js} +28 -7
- package/dist/{chunk-OXTLPTO3.js → chunk-EAJ7SYHE.js} +4 -3
- package/dist/{chunk-V2PXZVBF.cjs → chunk-FGEB7RMY.cjs} +4 -4
- package/dist/chunk-GKKDAW44.js +8823 -0
- package/dist/{chunk-2PWNH3UE.js → chunk-H5POPGOZ.js} +63 -5
- package/dist/{chunk-W7IGCOVL.cjs → chunk-JQYC66TO.cjs} +9 -8
- package/dist/{chunk-PFXURMBZ.cjs → chunk-JZLGCTGK.cjs} +68 -8
- package/dist/{chunk-JYOTGRSO.cjs → chunk-KFRDLKMA.cjs} +61 -1
- package/dist/chunk-M4IT6DNJ.cjs +608 -0
- package/dist/{chunk-KLKI352M.cjs → chunk-MVDQMV25.cjs} +0 -3
- package/dist/chunk-NCVX3K2N.cjs +161 -0
- package/dist/chunk-NWFMBLSQ.js +4 -0
- package/dist/chunk-O5676ZWY.js +585 -0
- package/dist/chunk-PUX5VXDB.cjs +8845 -0
- package/dist/{chunk-IXLO7GO5.js → chunk-TWT3STIX.js} +46 -80
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/chunk-VP2B4WM2.js +154 -0
- package/dist/{chunk-5X5WL5CU.cjs → chunk-WJLECC22.cjs} +51 -88
- package/dist/{chunk-WENHUPZC.cjs → chunk-XAYGD4E4.cjs} +9 -8
- package/dist/core/addresses.d.ts +15 -3
- package/dist/core/brands.d.ts +8 -2
- package/dist/core/errors.d.ts +71 -10
- package/dist/core/preflight.d.ts +1 -0
- package/dist/fhe/erc7984-abi.d.ts +1 -0
- package/dist/fhe/index.cjs +34 -13
- package/dist/fhe/index.d.cts +1 -0
- package/dist/fhe/index.d.ts +1 -0
- package/dist/fhe/index.js +19 -6
- package/dist/fhe/mock-erc7984.d.ts +4 -4
- package/dist/fhe/operators.d.ts +160 -3
- package/dist/fhe/react/index.cjs +14 -0
- package/dist/fhe/react/index.d.cts +2 -0
- package/dist/fhe/react/index.d.ts +2 -0
- package/dist/fhe/react/index.js +6 -0
- package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
- package/dist/fhe/react/useIsOperator.d.ts +54 -0
- package/dist/fhe/sepolia-encryptor-web.d.ts +18 -3
- package/dist/fhe/types.d.ts +6 -0
- package/dist/fhe-airdrop/abis/{cloneable.d.ts → airdrop-base.d.ts} +254 -396
- package/dist/fhe-airdrop/abis/compliance.d.ts +422 -0
- package/dist/fhe-airdrop/abis/ecdsa.d.ts +1316 -0
- package/dist/fhe-airdrop/abis/factory.d.ts +1319 -190
- package/dist/fhe-airdrop/abis/index.d.ts +5 -2
- package/dist/fhe-airdrop/abis/merkle.d.ts +1238 -0
- package/dist/fhe-airdrop/advanced/index.cjs +10 -12
- package/dist/fhe-airdrop/advanced/index.d.cts +34 -11
- package/dist/fhe-airdrop/advanced/index.d.ts +34 -11
- package/dist/fhe-airdrop/advanced/index.js +2 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +34 -48
- package/dist/fhe-airdrop/advanced/react/index.d.cts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.d.ts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.js +33 -48
- package/dist/fhe-airdrop/advanced/react/usePredictEcdsaAirdropAddress.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/usePredictMerkleAirdropAddress.d.ts +27 -0
- package/dist/fhe-airdrop/airdrop-base.d.ts +600 -0
- package/dist/fhe-airdrop/campaign.d.ts +297 -0
- package/dist/fhe-airdrop/compliance.d.ts +302 -0
- package/dist/fhe-airdrop/constants.d.ts +33 -0
- package/dist/fhe-airdrop/ecdsa.d.ts +263 -0
- package/dist/fhe-airdrop/encryption.d.ts +92 -14
- package/dist/fhe-airdrop/errors.d.ts +245 -15
- package/dist/fhe-airdrop/factory.d.ts +533 -274
- package/dist/fhe-airdrop/guards.d.ts +273 -0
- package/dist/fhe-airdrop/index.cjs +1089 -33
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +929 -7
- package/dist/fhe-airdrop/merkle-tree.d.ts +103 -0
- package/dist/fhe-airdrop/merkle.d.ts +180 -0
- package/dist/fhe-airdrop/react/_shared.d.ts +144 -71
- package/dist/fhe-airdrop/react/index.cjs +364 -413
- package/dist/fhe-airdrop/react/index.d.cts +53 -72
- package/dist/fhe-airdrop/react/index.d.ts +53 -72
- package/dist/fhe-airdrop/react/index.js +258 -369
- package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +10 -5
- package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +15 -6
- package/dist/fhe-airdrop/react/useAirdropPause.d.ts +30 -0
- package/dist/fhe-airdrop/react/useAirdropPaused.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -4
- package/dist/fhe-airdrop/react/useAirdropWindow.d.ts +37 -0
- package/dist/fhe-airdrop/react/useClaimedAmount.d.ts +29 -0
- package/dist/fhe-airdrop/react/useComplianceManager.d.ts +16 -0
- package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +28 -0
- package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +25 -0
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +23 -0
- package/dist/fhe-airdrop/react/useEffectiveUpgradeable.d.ts +20 -0
- package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +17 -12
- package/dist/fhe-airdrop/react/useFactoryFees.d.ts +28 -0
- package/dist/fhe-airdrop/react/useFactoryRegistry.d.ts +35 -0
- package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +35 -0
- package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +35 -0
- package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +34 -0
- package/dist/fhe-airdrop/react/useMerkleRoot.d.ts +15 -0
- package/dist/fhe-airdrop/react/useSetMerkleRoot.d.ts +22 -0
- package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +23 -0
- package/dist/fhe-airdrop/roles.d.ts +147 -0
- package/dist/fhe-airdrop/types.d.ts +68 -55
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +34 -25
- package/dist/fhe-disperse/index.d.cts +1 -1
- package/dist/fhe-disperse/index.d.ts +1 -1
- package/dist/fhe-disperse/index.js +6 -5
- package/dist/fhe-disperse/react/index.cjs +42 -23
- package/dist/fhe-disperse/react/index.d.cts +3 -1
- package/dist/fhe-disperse/react/index.d.ts +3 -1
- package/dist/fhe-disperse/react/index.js +9 -6
- package/dist/fhe-vesting/advanced/index.cjs +8 -7
- package/dist/fhe-vesting/advanced/index.js +6 -5
- package/dist/fhe-vesting/advanced/react/index.cjs +12 -11
- package/dist/fhe-vesting/advanced/react/index.js +9 -8
- package/dist/fhe-vesting/index.cjs +35 -34
- package/dist/fhe-vesting/index.js +7 -6
- package/dist/fhe-vesting/manager.d.ts +19 -0
- package/dist/fhe-vesting/react/index.cjs +160 -140
- package/dist/fhe-vesting/react/index.d.cts +6 -4
- package/dist/fhe-vesting/react/index.d.ts +6 -4
- package/dist/fhe-vesting/react/index.js +24 -16
- package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
- package/dist/fhe-vesting/types.d.ts +12 -1
- package/dist/index.cjs +27 -15
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/index.cjs +17 -16
- package/dist/testnet-faucet/index.js +5 -4
- package/dist/testnet-faucet/react/index.cjs +11 -10
- package/dist/testnet-faucet/react/index.js +6 -5
- package/package.json +18 -9
- package/dist/chunk-4WPGQSNT.cjs +0 -44
- package/dist/chunk-6R4KNAPK.js +0 -1630
- package/dist/chunk-DUZIIRPF.js +0 -1655
- package/dist/chunk-MCRBVJGZ.cjs +0 -1637
- package/dist/chunk-ODLTEGHB.js +0 -41
- package/dist/chunk-ORFTDNFZ.js +0 -105
- package/dist/chunk-T46YXSBP.cjs +0 -109
- package/dist/chunk-TIUKIY5V.cjs +0 -1663
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +0 -53
- package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +0 -49
- package/dist/fhe-airdrop/airdrop.d.ts +0 -310
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -31
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
- package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +0 -6
- package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +0 -9
- package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +0 -22
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +0 -51
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useClaim.d.ts +0 -31
- package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +0 -11
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +0 -41
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +0 -48
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +0 -29
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +0 -31
- package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +0 -14
- package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +0 -33
- package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +0 -51
- package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +0 -14
- package/dist/fhe-airdrop/react/useSetPaused.d.ts +0 -14
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +0 -31
- package/dist/fhe-airdrop/react/useWithdraw.d.ts +0 -12
- package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +0 -13
- package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
- package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
package/dist/chunk-ODLTEGHB.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ConfidentialAirdropFactoryClient, confidentialAirdropFactoryAbi } from './chunk-DUZIIRPF.js';
|
|
2
|
-
|
|
3
|
-
// src/fhe-airdrop/advanced/factory-advanced.ts
|
|
4
|
-
var ConfidentialAirdropFactoryAdvancedClient = class extends ConfidentialAirdropFactoryClient {
|
|
5
|
-
/**
|
|
6
|
-
* Compute the deterministic CREATE2 address for an airdrop clone without
|
|
7
|
-
* deploying it.
|
|
8
|
-
*
|
|
9
|
-
* Note: `gasFee` must match what the factory would charge the deployer at
|
|
10
|
-
* deploy time (custom fee if set, otherwise `defaultGasFee`). Use
|
|
11
|
-
* `getCustomFee(deployer)` and `defaultGasFee()` to resolve it correctly —
|
|
12
|
-
* a mismatch silently targets the wrong address.
|
|
13
|
-
*
|
|
14
|
-
* For the common "deploy a clone and learn its address" flow, use the
|
|
15
|
-
* headline `factory.createConfidentialAirdrop` instead — it parses the
|
|
16
|
-
* address from the tx receipt's `ConfidentialAirdropCreated` event without
|
|
17
|
-
* any `gasFee` guessing.
|
|
18
|
-
*/
|
|
19
|
-
async predictAirdropAddress(args) {
|
|
20
|
-
return this.publicClient.readContract({
|
|
21
|
-
address: this.address,
|
|
22
|
-
abi: confidentialAirdropFactoryAbi,
|
|
23
|
-
functionName: "predictAirdropAddress",
|
|
24
|
-
args: [toAbiParams(args.params), args.userSalt, args.deployer, args.gasFee]
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
function createConfidentialAirdropFactoryAdvancedClient(config) {
|
|
29
|
-
return new ConfidentialAirdropFactoryAdvancedClient(config);
|
|
30
|
-
}
|
|
31
|
-
function toAbiParams(params) {
|
|
32
|
-
return {
|
|
33
|
-
token: params.token,
|
|
34
|
-
startTime: params.startTimestamp,
|
|
35
|
-
endTime: params.endTimestamp,
|
|
36
|
-
canExtendClaimWindow: params.canExtendClaimWindow,
|
|
37
|
-
admin: params.admin
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { ConfidentialAirdropFactoryAdvancedClient, createConfidentialAirdropFactoryAdvancedClient };
|
package/dist/chunk-ORFTDNFZ.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { createConfidentialAirdropClient } from './chunk-6R4KNAPK.js';
|
|
2
|
-
import { createConfidentialAirdropFactoryClient, resolveEncryptor } from './chunk-DUZIIRPF.js';
|
|
3
|
-
import { getFheAirdropFactoryAddress } from './chunk-XGGTQQFH.js';
|
|
4
|
-
import { DeploymentAddressUnavailableError } from './chunk-QBJ7O2B4.js';
|
|
5
|
-
import { useRef, useMemo } from 'react';
|
|
6
|
-
import { usePublicClient, useWalletClient } from 'wagmi';
|
|
7
|
-
|
|
8
|
-
var FHE_AIRDROP_KEY = "tokenops-sdk";
|
|
9
|
-
var FHE_AIRDROP_NAMESPACE = "fhe-airdrop";
|
|
10
|
-
function tryResolveFactoryAddress(override, chainId) {
|
|
11
|
-
if (override) return override;
|
|
12
|
-
if (chainId === void 0) return void 0;
|
|
13
|
-
return getFheAirdropFactoryAddress(chainId);
|
|
14
|
-
}
|
|
15
|
-
function useMemoFactoryClient(opts = {}) {
|
|
16
|
-
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
17
|
-
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
18
|
-
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
19
|
-
const resolvedAddress = tryResolveFactoryAddress(opts.address, chainId);
|
|
20
|
-
const resolutionError = computeFactoryResolutionError(opts.address, chainId);
|
|
21
|
-
const encryptorSourceRef = useRef(opts.encryptor);
|
|
22
|
-
encryptorSourceRef.current = opts.encryptor;
|
|
23
|
-
const client = useMemo(() => {
|
|
24
|
-
if (!publicClient) return void 0;
|
|
25
|
-
if (!resolvedAddress) return void 0;
|
|
26
|
-
return createConfidentialAirdropFactoryClient({
|
|
27
|
-
publicClient,
|
|
28
|
-
...walletClient ? { walletClient } : {},
|
|
29
|
-
address: resolvedAddress,
|
|
30
|
-
...chainId !== void 0 ? { chainId } : {},
|
|
31
|
-
// Lazy — invoked per-encryption inside the headless client. Picks up
|
|
32
|
-
// whichever EncryptorSource the consumer last passed in.
|
|
33
|
-
encryptor: () => resolveEncryptor(encryptorSourceRef.current)
|
|
34
|
-
});
|
|
35
|
-
}, [publicClient, walletClient, resolvedAddress, chainId]);
|
|
36
|
-
return {
|
|
37
|
-
client,
|
|
38
|
-
resolutionError,
|
|
39
|
-
publicClient,
|
|
40
|
-
walletClient: walletClient ?? void 0,
|
|
41
|
-
chainId,
|
|
42
|
-
resolvedAddress
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function computeFactoryResolutionError(override, chainId) {
|
|
46
|
-
if (override) return void 0;
|
|
47
|
-
if (chainId === void 0) {
|
|
48
|
-
return new DeploymentAddressUnavailableError({
|
|
49
|
-
reason: "chain-id-missing",
|
|
50
|
-
product: "fheAirdrop",
|
|
51
|
-
contract: "confidentialAirdropFactory",
|
|
52
|
-
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const resolved = getFheAirdropFactoryAddress(chainId);
|
|
56
|
-
if (!resolved) {
|
|
57
|
-
return new DeploymentAddressUnavailableError({
|
|
58
|
-
reason: "registry-not-deployed",
|
|
59
|
-
product: "fheAirdrop",
|
|
60
|
-
contract: "confidentialAirdropFactory",
|
|
61
|
-
chainId,
|
|
62
|
-
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return void 0;
|
|
66
|
-
}
|
|
67
|
-
function useMemoAirdropClient(opts) {
|
|
68
|
-
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
69
|
-
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
70
|
-
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
71
|
-
const client = useMemo(() => {
|
|
72
|
-
if (!publicClient) return void 0;
|
|
73
|
-
if (!opts.address) return void 0;
|
|
74
|
-
return createConfidentialAirdropClient({
|
|
75
|
-
publicClient,
|
|
76
|
-
...walletClient ? { walletClient } : {},
|
|
77
|
-
address: opts.address,
|
|
78
|
-
...opts.aclAddress ? { aclAddress: opts.aclAddress } : {}
|
|
79
|
-
});
|
|
80
|
-
}, [publicClient, walletClient, opts.address, opts.aclAddress]);
|
|
81
|
-
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
82
|
-
}
|
|
83
|
-
function buildQueryKey(method, chainId, address, ...args) {
|
|
84
|
-
return [
|
|
85
|
-
FHE_AIRDROP_KEY,
|
|
86
|
-
FHE_AIRDROP_NAMESPACE,
|
|
87
|
-
method,
|
|
88
|
-
chainId ?? null,
|
|
89
|
-
address ? address.toLowerCase() : null,
|
|
90
|
-
...args.map(normalizeKeyArg)
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
function normalizeKeyArg(value) {
|
|
94
|
-
if (typeof value === "bigint") return value.toString();
|
|
95
|
-
if (Array.isArray(value)) return value.map(normalizeKeyArg);
|
|
96
|
-
if (value && typeof value === "object") {
|
|
97
|
-
return Object.fromEntries(
|
|
98
|
-
Object.entries(value).map(([k, v]) => [k, normalizeKeyArg(v)])
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
if (typeof value === "string" && value.startsWith("0x")) return value.toLowerCase();
|
|
102
|
-
return value;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export { buildQueryKey, useMemoAirdropClient, useMemoFactoryClient };
|
package/dist/chunk-T46YXSBP.cjs
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkMCRBVJGZ_cjs = require('./chunk-MCRBVJGZ.cjs');
|
|
4
|
-
var chunkTIUKIY5V_cjs = require('./chunk-TIUKIY5V.cjs');
|
|
5
|
-
var chunkPUPKNW3R_cjs = require('./chunk-PUPKNW3R.cjs');
|
|
6
|
-
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
7
|
-
var react = require('react');
|
|
8
|
-
var wagmi = require('wagmi');
|
|
9
|
-
|
|
10
|
-
var FHE_AIRDROP_KEY = "tokenops-sdk";
|
|
11
|
-
var FHE_AIRDROP_NAMESPACE = "fhe-airdrop";
|
|
12
|
-
function tryResolveFactoryAddress(override, chainId) {
|
|
13
|
-
if (override) return override;
|
|
14
|
-
if (chainId === void 0) return void 0;
|
|
15
|
-
return chunkPUPKNW3R_cjs.getFheAirdropFactoryAddress(chainId);
|
|
16
|
-
}
|
|
17
|
-
function useMemoFactoryClient(opts = {}) {
|
|
18
|
-
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
19
|
-
const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
|
|
20
|
-
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
21
|
-
const resolvedAddress = tryResolveFactoryAddress(opts.address, chainId);
|
|
22
|
-
const resolutionError = computeFactoryResolutionError(opts.address, chainId);
|
|
23
|
-
const encryptorSourceRef = react.useRef(opts.encryptor);
|
|
24
|
-
encryptorSourceRef.current = opts.encryptor;
|
|
25
|
-
const client = react.useMemo(() => {
|
|
26
|
-
if (!publicClient) return void 0;
|
|
27
|
-
if (!resolvedAddress) return void 0;
|
|
28
|
-
return chunkTIUKIY5V_cjs.createConfidentialAirdropFactoryClient({
|
|
29
|
-
publicClient,
|
|
30
|
-
...walletClient ? { walletClient } : {},
|
|
31
|
-
address: resolvedAddress,
|
|
32
|
-
...chainId !== void 0 ? { chainId } : {},
|
|
33
|
-
// Lazy — invoked per-encryption inside the headless client. Picks up
|
|
34
|
-
// whichever EncryptorSource the consumer last passed in.
|
|
35
|
-
encryptor: () => chunkTIUKIY5V_cjs.resolveEncryptor(encryptorSourceRef.current)
|
|
36
|
-
});
|
|
37
|
-
}, [publicClient, walletClient, resolvedAddress, chainId]);
|
|
38
|
-
return {
|
|
39
|
-
client,
|
|
40
|
-
resolutionError,
|
|
41
|
-
publicClient,
|
|
42
|
-
walletClient: walletClient ?? void 0,
|
|
43
|
-
chainId,
|
|
44
|
-
resolvedAddress
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function computeFactoryResolutionError(override, chainId) {
|
|
48
|
-
if (override) return void 0;
|
|
49
|
-
if (chainId === void 0) {
|
|
50
|
-
return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
51
|
-
reason: "chain-id-missing",
|
|
52
|
-
product: "fheAirdrop",
|
|
53
|
-
contract: "confidentialAirdropFactory",
|
|
54
|
-
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const resolved = chunkPUPKNW3R_cjs.getFheAirdropFactoryAddress(chainId);
|
|
58
|
-
if (!resolved) {
|
|
59
|
-
return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
60
|
-
reason: "registry-not-deployed",
|
|
61
|
-
product: "fheAirdrop",
|
|
62
|
-
contract: "confidentialAirdropFactory",
|
|
63
|
-
chainId,
|
|
64
|
-
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return void 0;
|
|
68
|
-
}
|
|
69
|
-
function useMemoAirdropClient(opts) {
|
|
70
|
-
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
71
|
-
const { data: walletClient } = wagmi.useWalletClient({ chainId: opts.chainId });
|
|
72
|
-
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
73
|
-
const client = react.useMemo(() => {
|
|
74
|
-
if (!publicClient) return void 0;
|
|
75
|
-
if (!opts.address) return void 0;
|
|
76
|
-
return chunkMCRBVJGZ_cjs.createConfidentialAirdropClient({
|
|
77
|
-
publicClient,
|
|
78
|
-
...walletClient ? { walletClient } : {},
|
|
79
|
-
address: opts.address,
|
|
80
|
-
...opts.aclAddress ? { aclAddress: opts.aclAddress } : {}
|
|
81
|
-
});
|
|
82
|
-
}, [publicClient, walletClient, opts.address, opts.aclAddress]);
|
|
83
|
-
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
84
|
-
}
|
|
85
|
-
function buildQueryKey(method, chainId, address, ...args) {
|
|
86
|
-
return [
|
|
87
|
-
FHE_AIRDROP_KEY,
|
|
88
|
-
FHE_AIRDROP_NAMESPACE,
|
|
89
|
-
method,
|
|
90
|
-
chainId ?? null,
|
|
91
|
-
address ? address.toLowerCase() : null,
|
|
92
|
-
...args.map(normalizeKeyArg)
|
|
93
|
-
];
|
|
94
|
-
}
|
|
95
|
-
function normalizeKeyArg(value) {
|
|
96
|
-
if (typeof value === "bigint") return value.toString();
|
|
97
|
-
if (Array.isArray(value)) return value.map(normalizeKeyArg);
|
|
98
|
-
if (value && typeof value === "object") {
|
|
99
|
-
return Object.fromEntries(
|
|
100
|
-
Object.entries(value).map(([k, v]) => [k, normalizeKeyArg(v)])
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
if (typeof value === "string" && value.startsWith("0x")) return value.toLowerCase();
|
|
104
|
-
return value;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
exports.buildQueryKey = buildQueryKey;
|
|
108
|
-
exports.useMemoAirdropClient = useMemoAirdropClient;
|
|
109
|
-
exports.useMemoFactoryClient = useMemoFactoryClient;
|