@zama-fhe/react-sdk 3.0.0-alpha.9 → 3.0.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.
- package/README.md +42 -7
- package/dist/index.d.ts +132 -86
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/wagmi/index.js +1 -1
- package/dist/wagmi/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -698,6 +698,38 @@ const { data: meta } = useTokenMetadata("0xTokenAddress");
|
|
|
698
698
|
// meta?.name, meta?.symbol, meta?.decimals
|
|
699
699
|
```
|
|
700
700
|
|
|
701
|
+
### Activity Feed
|
|
702
|
+
|
|
703
|
+
#### `useActivityFeed`
|
|
704
|
+
|
|
705
|
+
Parse raw event logs into a classified, optionally decrypted activity feed.
|
|
706
|
+
|
|
707
|
+
```ts
|
|
708
|
+
function useActivityFeed(config: UseActivityFeedConfig): UseQueryResult<ActivityItem[], Error>;
|
|
709
|
+
|
|
710
|
+
interface UseActivityFeedConfig {
|
|
711
|
+
tokenAddress: Address;
|
|
712
|
+
userAddress: Address | undefined;
|
|
713
|
+
logs: readonly (RawLog & Partial<ActivityLogMetadata>)[] | undefined;
|
|
714
|
+
decrypt?: boolean; // default: true — batch-decrypt encrypted amounts
|
|
715
|
+
}
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
Enabled when both `logs` and `userAddress` are defined. When `decrypt` is `true` (default), encrypted transfer amounts are automatically decrypted via the relayer.
|
|
719
|
+
|
|
720
|
+
```tsx
|
|
721
|
+
const { data: feed } = useActivityFeed({
|
|
722
|
+
tokenAddress: "0xTokenAddress",
|
|
723
|
+
logs, // from getLogs or a similar source
|
|
724
|
+
userAddress,
|
|
725
|
+
decrypt: true,
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
feed?.forEach((item) => {
|
|
729
|
+
console.log(item.type, item.direction, item.amount);
|
|
730
|
+
});
|
|
731
|
+
```
|
|
732
|
+
|
|
701
733
|
### Low-Level FHE Hooks
|
|
702
734
|
|
|
703
735
|
These hooks are for **custom FHE contracts** (non-token contracts that use encrypted types directly). For confidential ERC-20 tokens, use the high-level token hooks above instead. For detailed usage examples, see the [Encrypt & Decrypt guide](../../docs/gitbook/src/guides/encrypt-decrypt.md).
|
|
@@ -766,13 +798,14 @@ Use `zamaQueryKeys` for manual cache management (invalidation, prefetching, remo
|
|
|
766
798
|
import { zamaQueryKeys, decryptionKeys } from "@zama-fhe/react-sdk";
|
|
767
799
|
```
|
|
768
800
|
|
|
769
|
-
| Factory | Keys
|
|
770
|
-
| ------------------------------------ |
|
|
771
|
-
| `zamaQueryKeys.confidentialBalance` | `.all`, `.token(address)`, `.owner(address, owner)`
|
|
772
|
-
| `zamaQueryKeys.confidentialBalances` | `.all`, `.tokens(addresses, owner)`
|
|
773
|
-
| `zamaQueryKeys.isAllowed` | `.all`
|
|
774
|
-
| `zamaQueryKeys.underlyingAllowance` | `.all`, `.token(address)`, `.scope(address, owner, wrapper)`
|
|
775
|
-
| `
|
|
801
|
+
| Factory | Keys | Description |
|
|
802
|
+
| ------------------------------------ | --------------------------------------------------------------------------- | ----------------------------------- |
|
|
803
|
+
| `zamaQueryKeys.confidentialBalance` | `.all`, `.token(address)`, `.owner(address, owner)` | Single-token decrypted balance. |
|
|
804
|
+
| `zamaQueryKeys.confidentialBalances` | `.all`, `.tokens(addresses, owner)` | Multi-token batch balances. |
|
|
805
|
+
| `zamaQueryKeys.isAllowed` | `.all` | Session signature status. |
|
|
806
|
+
| `zamaQueryKeys.underlyingAllowance` | `.all`, `.token(address)`, `.scope(address, owner, wrapper)` | Underlying ERC-20 allowance. |
|
|
807
|
+
| `zamaQueryKeys.activityFeed` | `.all`, `.token(address)`, `.scope(address, userAddress, logsKey, decrypt)` | Activity feed items. |
|
|
808
|
+
| `decryptionKeys` | `.value(handle)` | Individual decrypted handle values. |
|
|
776
809
|
|
|
777
810
|
```tsx
|
|
778
811
|
import { useQueryClient } from "@tanstack/react-query";
|
|
@@ -926,4 +959,6 @@ All public exports from `@zama-fhe/sdk` are re-exported from the main entry poin
|
|
|
926
959
|
|
|
927
960
|
**Event decoders:** `decodeConfidentialTransfer`, `decodeWrapped`, `decodeUnwrapRequested`, `decodeUnwrappedFinalized`, `decodeUnwrappedStarted`, `decodeOnChainEvent`, `decodeOnChainEvents`, `findUnwrapRequested`, `findWrapped`.
|
|
928
961
|
|
|
962
|
+
**Activity feed:** `ActivityDirection`, `ActivityType`, `ActivityAmount`, `ActivityLogMetadata`, `ActivityItem`, `parseActivityFeed`, `extractEncryptedHandles`, `applyDecryptedValues`, `sortByBlockNumber`.
|
|
963
|
+
|
|
929
964
|
**Contract call builders:** `confidentialBalanceOfContract`, `confidentialTransferContract`, `confidentialTransferFromContract`, `isOperatorContract`, `unwrapContract`, `unwrapFromBalanceContract`, `finalizeUnwrapContract`, `setOperatorContract`, `underlyingContract`, `inferredTotalSupplyContract`, `wrapContract`, `supportsInterfaceContract`, `isConfidentialTokenContract`, `isConfidentialWrapperContract`, `nameContract`, `symbolContract`, `decimalsContract`, `allowanceContract`, `approveContract`, `confidentialTotalSupplyContract`, `totalSupplyContract`, `rateContract`.
|