@skalenetwork/privacy-sdk 0.1.0-develop.0 → 0.1.0-develop.2

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 CHANGED
@@ -10,9 +10,12 @@ npm install @skalenetwork/privacy-sdk
10
10
 
11
11
  ## Quick Start
12
12
 
13
+ The SDK accepts any signer that implements `{ address, sendTransaction }`. Here's how to initialize with popular web3 libraries:
14
+
15
+ ### With viem
16
+
13
17
  ```typescript
14
18
  import { ConfidentialWrapper } from "@skalenetwork/privacy-sdk";
15
- import { deriveViewerKeypair } from "@skalenetwork/privacy-sdk/utils";
16
19
  import { createWalletClient, http } from "viem";
17
20
  import { privateKeyToAccount } from "viem/accounts";
18
21
 
@@ -27,6 +30,56 @@ const token = new ConfidentialWrapper({
27
30
  sendTransaction: (tx) => walletClient.sendTransaction({ ...tx, chain: null }),
28
31
  },
29
32
  });
33
+ ```
34
+
35
+ ### With ethers v6
36
+
37
+ ```typescript
38
+ import { ConfidentialWrapper } from "@skalenetwork/privacy-sdk";
39
+ import { Wallet, JsonRpcProvider } from "ethers";
40
+
41
+ const provider = new JsonRpcProvider(RPC_URL);
42
+ const wallet = new Wallet("0x...", provider);
43
+
44
+ const token = new ConfidentialWrapper({
45
+ rpcUrl: RPC_URL,
46
+ address: WRAPPER_ADDRESS,
47
+ signer: {
48
+ address: wallet.address as `0x${string}`,
49
+ sendTransaction: async (tx) => {
50
+ const resp = await wallet.sendTransaction(tx);
51
+ return resp.hash as `0x${string}`;
52
+ },
53
+ },
54
+ });
55
+ ```
56
+
57
+ ### With web3.js
58
+
59
+ ```typescript
60
+ import { ConfidentialWrapper } from "@skalenetwork/privacy-sdk";
61
+ import Web3 from "web3";
62
+
63
+ const web3 = new Web3(RPC_URL);
64
+ const account = web3.eth.accounts.privateKeyToAccount("0x...");
65
+
66
+ const token = new ConfidentialWrapper({
67
+ rpcUrl: RPC_URL,
68
+ address: WRAPPER_ADDRESS,
69
+ signer: {
70
+ address: account.address as `0x${string}`,
71
+ sendTransaction: async (tx) => {
72
+ const receipt = await web3.eth.sendTransaction({ from: account.address, ...tx });
73
+ return receipt.transactionHash as `0x${string}`;
74
+ },
75
+ },
76
+ });
77
+ ```
78
+
79
+ ### Usage
80
+
81
+ ```typescript
82
+ import { deriveViewerKeypair } from "@skalenetwork/privacy-sdk/utils";
30
83
 
31
84
  // Derive viewer keypair from a signed message (do this once per account)
32
85
  const sig = await walletClient.signMessage({ message: "SKALE Privacy Viewer Key", account });
@@ -35,11 +88,10 @@ token.setViewerPrivateKey(privateKey);
35
88
  await token.registerViewerPublicKey(publicKey);
36
89
 
37
90
  // Wrap underlying ERC-20 → confidential token (approve underlying first)
38
- const { ctxHash } = await token.wrap(account.address, 1000n).waitForCtx();
91
+ const { ctxHash: wrapCtxHash } = await token.wrap(account.address, 1000n).waitForCtx();
39
92
 
40
- // Confidential transfer — await for origin hash, .waitForCtx() for the full CTX result
41
- const hash = await token.transfer(recipient, 500n);
42
- const { originHash, ctxHash } = await token.transfer(recipient, 500n).waitForCtx();
93
+ // Confidential transfer
94
+ const { ctxHash: transferCtxHash, ctxReceipt } = await token.transfer(recipient, 500n).waitForCtx();
43
95
 
44
96
  // Decrypt balance
45
97
  const balance = await token.decryptBalance();
@@ -50,7 +102,7 @@ await token.unwrap(account.address, 500n).waitForCtx();
50
102
 
51
103
  ## Docs
52
104
 
53
- - [Concepts](https://github.com/skalenetwork/private-pay/blob/main/packages/privacy-sdk/docs/concepts.md) — CTX lifecycle, viewer keys, CtxPromise pattern
54
- - [Architecture](https://github.com/skalenetwork/private-pay/blob/main/packages/privacy-sdk/docs/architecture.md) — three-layer design (facades / actions / utils)
55
- - [API Reference](https://github.com/skalenetwork/private-pay/blob/main/packages/privacy-sdk/docs/api.md) — full method tables for all exports
105
+ - [Concepts](https://github.com/skalenetwork/privacy-sdk/blob/develop/docs/concepts.md) — CTX lifecycle, viewer keys, CtxPromise pattern
106
+ - [Architecture](https://github.com/skalenetwork/privacy-sdk/blob/develop/docs/architecture.md) — three-layer design (facades / actions / utils)
107
+ - [API Reference](https://github.com/skalenetwork/privacy-sdk/blob/develop/docs/api.md) — full method tables for all exports
56
108
 
@@ -23,13 +23,11 @@ __export(actions_exports, {
23
23
  approve: () => approve,
24
24
  authorizeHistoricViewForRange: () => authorizeHistoricViewForRange,
25
25
  authorizeHistoricViewForTransfer: () => authorizeHistoricViewForTransfer,
26
- decryptHistoricTransferData: () => decryptHistoricTransferData,
27
26
  decryptTokenBalance: () => decryptTokenBalance,
28
- fundCtxBalance: () => fundCtxBalance,
29
27
  getCtxBalance: () => getCtxBalance,
30
- getCtxFee: () => getCtxFee,
28
+ getCtxFee: () => getCtxRawCost,
31
29
  getTransferId: () => getTransferId,
32
- getValueForCtx: () => getValueForCtx,
30
+ getValueForCtx: () => getCtxOperationCost,
33
31
  registerViewerKey: () => registerViewerKey,
34
32
  requestTransferDecryption: () => requestTransferDecryption,
35
33
  revokeHistoricView: () => revokeHistoricView,
@@ -40,12 +38,17 @@ __export(actions_exports, {
40
38
  module.exports = __toCommonJS(actions_exports);
41
39
 
42
40
  // src/actions/transfers.ts
43
- var import_viem2 = require("viem");
41
+ var import_viem = require("viem");
44
42
 
45
43
  // src/abi/confidentialWrapper.ts
46
44
  var confidentialWrapperAbi = [
47
45
  {
48
46
  inputs: [
47
+ {
48
+ internalType: "bool",
49
+ name: "proxyMode",
50
+ type: "bool"
51
+ },
49
52
  {
50
53
  internalType: "contract IERC20Metadata",
51
54
  name: "underlyingToken",
@@ -611,6 +614,11 @@ var confidentialWrapperAbi = [
611
614
  name: "InvalidDataOffset",
612
615
  type: "error"
613
616
  },
617
+ {
618
+ inputs: [],
619
+ name: "InvalidInitialization",
620
+ type: "error"
621
+ },
614
622
  {
615
623
  inputs: [],
616
624
  name: "InvalidPublicKey",
@@ -639,7 +647,7 @@ var confidentialWrapperAbi = [
639
647
  },
640
648
  {
641
649
  inputs: [],
642
- name: "InvalidShortString",
650
+ name: "InvalidSaltForTransactionValue",
643
651
  type: "error"
644
652
  },
645
653
  {
@@ -685,6 +693,11 @@ var confidentialWrapperAbi = [
685
693
  name: "NoViewerRegisteredForHolder",
686
694
  type: "error"
687
695
  },
696
+ {
697
+ inputs: [],
698
+ name: "NotInitializing",
699
+ type: "error"
700
+ },
688
701
  {
689
702
  inputs: [
690
703
  {
@@ -723,17 +736,6 @@ var confidentialWrapperAbi = [
723
736
  name: "SafeERC20FailedOperation",
724
737
  type: "error"
725
738
  },
726
- {
727
- inputs: [
728
- {
729
- internalType: "string",
730
- name: "str",
731
- type: "string"
732
- }
733
- ],
734
- name: "StringTooLong",
735
- type: "error"
736
- },
737
739
  {
738
740
  inputs: [
739
741
  {
@@ -793,6 +795,11 @@ var confidentialWrapperAbi = [
793
795
  name: "ValueWasNotEncryptedCorrectly",
794
796
  type: "error"
795
797
  },
798
+ {
799
+ inputs: [],
800
+ name: "WrongInitializer",
801
+ type: "error"
802
+ },
796
803
  {
797
804
  inputs: [],
798
805
  name: "WrongPlaintextFormat",
@@ -1149,6 +1156,19 @@ var confidentialWrapperAbi = [
1149
1156
  name: "HistoricViewTransferIdRevoked",
1150
1157
  type: "event"
1151
1158
  },
1159
+ {
1160
+ anonymous: false,
1161
+ inputs: [
1162
+ {
1163
+ indexed: false,
1164
+ internalType: "uint64",
1165
+ name: "version",
1166
+ type: "uint64"
1167
+ }
1168
+ ],
1169
+ name: "Initialized",
1170
+ type: "event"
1171
+ },
1152
1172
  {
1153
1173
  anonymous: false,
1154
1174
  inputs: [
@@ -1781,6 +1801,30 @@ var confidentialWrapperAbi = [
1781
1801
  stateMutability: "view",
1782
1802
  type: "function"
1783
1803
  },
1804
+ {
1805
+ inputs: [
1806
+ {
1807
+ internalType: "address",
1808
+ name: "holder",
1809
+ type: "address"
1810
+ },
1811
+ {
1812
+ internalType: "uint256",
1813
+ name: "value",
1814
+ type: "uint256"
1815
+ }
1816
+ ],
1817
+ name: "encryptValue",
1818
+ outputs: [
1819
+ {
1820
+ internalType: "bytes",
1821
+ name: "encryptedValue",
1822
+ type: "bytes"
1823
+ }
1824
+ ],
1825
+ stateMutability: "view",
1826
+ type: "function"
1827
+ },
1784
1828
  {
1785
1829
  inputs: [
1786
1830
  {
@@ -1850,7 +1894,7 @@ var confidentialWrapperAbi = [
1850
1894
  ],
1851
1895
  name: "encryptedReceiveWithAuthorization",
1852
1896
  outputs: [],
1853
- stateMutability: "nonpayable",
1897
+ stateMutability: "payable",
1854
1898
  type: "function"
1855
1899
  },
1856
1900
  {
@@ -1979,6 +2023,57 @@ var confidentialWrapperAbi = [
1979
2023
  stateMutability: "view",
1980
2024
  type: "function"
1981
2025
  },
2026
+ {
2027
+ inputs: [
2028
+ {
2029
+ internalType: "string",
2030
+ name: "",
2031
+ type: "string"
2032
+ },
2033
+ {
2034
+ internalType: "string",
2035
+ name: "",
2036
+ type: "string"
2037
+ },
2038
+ {
2039
+ internalType: "string",
2040
+ name: "",
2041
+ type: "string"
2042
+ },
2043
+ {
2044
+ internalType: "address",
2045
+ name: "",
2046
+ type: "address"
2047
+ }
2048
+ ],
2049
+ name: "initialize",
2050
+ outputs: [],
2051
+ stateMutability: "pure",
2052
+ type: "function"
2053
+ },
2054
+ {
2055
+ inputs: [
2056
+ {
2057
+ internalType: "contract IERC20Metadata",
2058
+ name: "underlyingToken",
2059
+ type: "address"
2060
+ },
2061
+ {
2062
+ internalType: "string",
2063
+ name: "version_",
2064
+ type: "string"
2065
+ },
2066
+ {
2067
+ internalType: "address",
2068
+ name: "initialAuthority",
2069
+ type: "address"
2070
+ }
2071
+ ],
2072
+ name: "initialize",
2073
+ outputs: [],
2074
+ stateMutability: "nonpayable",
2075
+ type: "function"
2076
+ },
1982
2077
  {
1983
2078
  inputs: [],
1984
2079
  name: "isConsumingScheduledOp",
@@ -2683,7 +2778,6 @@ var confidentialWrapperAbi = [
2683
2778
  ];
2684
2779
 
2685
2780
  // src/actions/funding.ts
2686
- var import_viem = require("viem");
2687
2781
  var CTX_RESERVE_THRESHOLD = 1n;
2688
2782
  async function getCtxBalance(config) {
2689
2783
  return await config.publicClient.readContract({
@@ -2693,87 +2787,78 @@ async function getCtxBalance(config) {
2693
2787
  args: [config.signer.address]
2694
2788
  });
2695
2789
  }
2696
- async function getCtxFee(config) {
2790
+ async function getCtxRawCost(config) {
2697
2791
  return await config.publicClient.readContract({
2698
2792
  address: config.address,
2699
2793
  abi: confidentialWrapperAbi,
2700
2794
  functionName: "callbackFee"
2701
2795
  });
2702
2796
  }
2703
- async function fundCtxBalance(config, params) {
2704
- const data = (0, import_viem.encodeFunctionData)({
2705
- abi: confidentialWrapperAbi,
2706
- functionName: "fundWithGasToken",
2707
- args: [config.signer.address]
2708
- });
2709
- return config.signer.sendTransaction({
2710
- to: config.address,
2711
- data,
2712
- value: params.amount
2713
- });
2714
- }
2715
- async function getValueForCtx(config) {
2716
- const [fee, balance] = await Promise.all([getCtxFee(config), getCtxBalance(config)]);
2797
+ async function getCtxOperationCost(config) {
2798
+ const [fee, balance] = await Promise.all([getCtxRawCost(config), getCtxBalance(config)]);
2717
2799
  const topUp = CTX_RESERVE_THRESHOLD * fee - balance;
2718
2800
  return fee + (topUp > 0n ? topUp : 0n);
2719
2801
  }
2720
2802
 
2721
2803
  // src/actions/transfers.ts
2722
- async function approve(config, params) {
2723
- const data = (0, import_viem2.encodeFunctionData)({
2804
+ async function approve(config, spender, amount) {
2805
+ const data = (0, import_viem.encodeFunctionData)({
2724
2806
  abi: confidentialWrapperAbi,
2725
2807
  functionName: "approve",
2726
- args: [params.spender, params.amount]
2808
+ args: [spender, amount]
2727
2809
  });
2728
2810
  return config.signer.sendTransaction({ to: config.address, data });
2729
2811
  }
2730
- async function transfer(config, params) {
2731
- const value = await getValueForCtx(config);
2732
- const valueHex = (0, import_viem2.toHex)(params.amount, { size: 32 });
2812
+ async function transfer(config, to, amount) {
2813
+ const value = await getCtxOperationCost(config);
2814
+ const valueHex = (0, import_viem.encodeAbiParameters)(
2815
+ [{ type: "address" }, { type: "uint256" }],
2816
+ [config.signer.address, amount]
2817
+ );
2733
2818
  const encryptedValue = await config.bite.encryptMessageForCTX(valueHex, config.address);
2734
- const data = (0, import_viem2.encodeFunctionData)({
2819
+ const data = (0, import_viem.encodeFunctionData)({
2735
2820
  abi: confidentialWrapperAbi,
2736
2821
  functionName: "encryptedTransfer",
2737
- args: [params.to, encryptedValue]
2822
+ args: [to, encryptedValue]
2738
2823
  });
2739
2824
  return config.signer.sendTransaction({ to: config.address, data, value });
2740
2825
  }
2741
- async function wrap(config, params) {
2742
- const value = await getValueForCtx(config);
2743
- const data = (0, import_viem2.encodeFunctionData)({
2826
+ async function wrap(config, receiver, amount) {
2827
+ const value = await getCtxOperationCost(config);
2828
+ const data = (0, import_viem.encodeFunctionData)({
2744
2829
  abi: confidentialWrapperAbi,
2745
2830
  functionName: "depositForWithGasToken",
2746
- args: [params.receiver, params.amount]
2831
+ args: [receiver, amount]
2747
2832
  });
2748
2833
  return config.signer.sendTransaction({ to: config.address, data, value });
2749
2834
  }
2750
- async function unwrap(config, params) {
2751
- const value = await getValueForCtx(config);
2752
- const data = (0, import_viem2.encodeFunctionData)({
2835
+ async function unwrap(config, receiver, amount) {
2836
+ const value = await getCtxOperationCost(config);
2837
+ const data = (0, import_viem.encodeFunctionData)({
2753
2838
  abi: confidentialWrapperAbi,
2754
2839
  functionName: "withdrawToWithGasToken",
2755
- args: [params.receiver, params.amount]
2840
+ args: [receiver, amount]
2756
2841
  });
2757
2842
  return config.signer.sendTransaction({ to: config.address, data, value });
2758
2843
  }
2759
2844
 
2760
2845
  // src/actions/decrypt.ts
2761
- var import_viem4 = require("viem");
2846
+ var import_viem3 = require("viem");
2762
2847
 
2763
2848
  // src/utils/crypto.ts
2764
2849
  var import_secp256k1 = require("@noble/curves/secp256k1");
2765
2850
  var import_sha256 = require("@noble/hashes/sha256");
2766
2851
  var import_aes = require("@noble/ciphers/aes");
2767
- var import_viem3 = require("viem");
2852
+ var import_viem2 = require("viem");
2768
2853
  function bytesToBigInt(bytes) {
2769
2854
  if (bytes.length === 0) {
2770
2855
  return 0n;
2771
2856
  }
2772
- const hexValue = (0, import_viem3.bytesToHex)(bytes);
2857
+ const hexValue = (0, import_viem2.bytesToHex)(bytes);
2773
2858
  return BigInt(hexValue === "0x" ? "0x0" : hexValue);
2774
2859
  }
2775
2860
  function decryptEciesPayload(encryptedHex, privateKey) {
2776
- const payload = (0, import_viem3.hexToBytes)(encryptedHex);
2861
+ const payload = (0, import_viem2.hexToBytes)(encryptedHex);
2777
2862
  if (payload.length < 65) {
2778
2863
  throw new Error("Encrypted payload is too short.");
2779
2864
  }
@@ -2787,7 +2872,7 @@ function decryptEciesPayload(encryptedHex, privateKey) {
2787
2872
  throw new Error("Invalid AES-CBC ciphertext length.");
2788
2873
  }
2789
2874
  const sharedSecret = import_secp256k1.secp256k1.getSharedSecret(
2790
- (0, import_viem3.hexToBytes)(privateKey),
2875
+ (0, import_viem2.hexToBytes)(privateKey),
2791
2876
  ephemeralCompressedPublicKey,
2792
2877
  true
2793
2878
  );
@@ -2795,23 +2880,6 @@ function decryptEciesPayload(encryptedHex, privateKey) {
2795
2880
  const keyMaterial = Uint8Array.from(encryptionKey);
2796
2881
  return (0, import_aes.cbc)(keyMaterial, iv).decrypt(ciphertext);
2797
2882
  }
2798
- function tryDecodeTransferData(encoded) {
2799
- try {
2800
- const [from, to, value, timestamp, transferId] = (0, import_viem3.decodeAbiParameters)(
2801
- [
2802
- { type: "address" },
2803
- { type: "address" },
2804
- { type: "uint256" },
2805
- { type: "uint256" },
2806
- { type: "uint256" }
2807
- ],
2808
- encoded
2809
- );
2810
- return { from, to, value, timestamp, transferId };
2811
- } catch {
2812
- return void 0;
2813
- }
2814
- }
2815
2883
  async function decryptBalance(encryptedHex, privateKey) {
2816
2884
  const plaintext = decryptEciesPayload(encryptedHex, privateKey);
2817
2885
  if (plaintext.length <= 32) {
@@ -2819,40 +2887,21 @@ async function decryptBalance(encryptedHex, privateKey) {
2819
2887
  }
2820
2888
  return bytesToBigInt(plaintext.slice(-32));
2821
2889
  }
2822
- async function decryptTransferData(encryptedHex, privateKey) {
2823
- const plaintext = decryptEciesPayload(encryptedHex, privateKey);
2824
- const direct = tryDecodeTransferData((0, import_viem3.bytesToHex)(plaintext));
2825
- if (direct) {
2826
- return direct;
2827
- }
2828
- const structSizeBytes = 32 * 5;
2829
- if (plaintext.length >= structSizeBytes) {
2830
- const trailing = plaintext.slice(-structSizeBytes);
2831
- const trailingDecoded = tryDecodeTransferData((0, import_viem3.bytesToHex)(trailing));
2832
- if (trailingDecoded) {
2833
- return trailingDecoded;
2834
- }
2835
- }
2836
- throw new Error("Unable to decode decrypted transfer payload as TransferData struct.");
2837
- }
2838
2890
 
2839
2891
  // src/actions/decrypt.ts
2840
- async function decryptTokenBalance(config, params) {
2892
+ async function decryptTokenBalance(config, viewerKey) {
2841
2893
  const raw = await config.publicClient.readContract({
2842
2894
  address: config.address,
2843
2895
  abi: confidentialWrapperAbi,
2844
2896
  functionName: "encryptedBalanceOf",
2845
2897
  args: [config.signer.address]
2846
2898
  });
2847
- const encryptedHex = typeof raw === "string" ? raw : (0, import_viem4.bytesToHex)(raw);
2848
- return decryptBalance(encryptedHex, params.viewerKey);
2899
+ const encryptedHex = typeof raw === "string" ? raw : (0, import_viem3.bytesToHex)(raw);
2900
+ return decryptBalance(encryptedHex, viewerKey);
2849
2901
  }
2850
- async function decryptHistoricTransferData(params) {
2851
- return decryptTransferData(params.encryptedData, params.viewerKey);
2852
- }
2853
- async function getTransferId(config, params) {
2854
- const receipt = await config.publicClient.waitForTransactionReceipt({ hash: params.ctxHash });
2855
- const events = (0, import_viem4.parseEventLogs)({
2902
+ async function getTransferId(config, ctxHash) {
2903
+ const receipt = await config.publicClient.waitForTransactionReceipt({ hash: ctxHash });
2904
+ const events = (0, import_viem3.parseEventLogs)({
2856
2905
  abi: confidentialWrapperAbi,
2857
2906
  logs: receipt.logs,
2858
2907
  eventName: "EncryptedTransfer"
@@ -2869,10 +2918,10 @@ async function getTransferId(config, params) {
2869
2918
  }
2870
2919
 
2871
2920
  // src/actions/access.ts
2872
- var import_viem6 = require("viem");
2921
+ var import_viem5 = require("viem");
2873
2922
 
2874
2923
  // src/utils/viewerKey.ts
2875
- var import_viem5 = require("viem");
2924
+ var import_viem4 = require("viem");
2876
2925
  var import_utils = require("viem/utils");
2877
2926
  var import_secp256k12 = require("@noble/curves/secp256k1");
2878
2927
  function parsePublicKeyCoordinates(publicKey) {
@@ -2887,43 +2936,43 @@ function parsePublicKeyCoordinates(publicKey) {
2887
2936
  }
2888
2937
 
2889
2938
  // src/actions/access.ts
2890
- async function registerViewerKey(config, params) {
2891
- const { x, y } = parsePublicKeyCoordinates(params.publicKey);
2892
- const data = (0, import_viem6.encodeFunctionData)({
2939
+ async function registerViewerKey(config, publicKey) {
2940
+ const { x, y } = parsePublicKeyCoordinates(publicKey);
2941
+ const data = (0, import_viem5.encodeFunctionData)({
2893
2942
  abi: confidentialWrapperAbi,
2894
2943
  functionName: "setViewerPublicKey",
2895
2944
  args: [{ x, y }]
2896
2945
  });
2897
2946
  return config.signer.sendTransaction({ to: config.address, data });
2898
2947
  }
2899
- async function authorizeHistoricViewForRange(config, params) {
2900
- const data = (0, import_viem6.encodeFunctionData)({
2948
+ async function authorizeHistoricViewForRange(config, address, fromTimestamp, toTimestamp) {
2949
+ const data = (0, import_viem5.encodeFunctionData)({
2901
2950
  abi: confidentialWrapperAbi,
2902
2951
  functionName: "authorizeHistoricViewTimeRange",
2903
- args: [params.address, params.fromTimestamp, params.toTimestamp]
2952
+ args: [address, fromTimestamp, toTimestamp]
2904
2953
  });
2905
2954
  return config.signer.sendTransaction({ to: config.address, data });
2906
2955
  }
2907
- async function authorizeHistoricViewForTransfer(config, params) {
2908
- const data = (0, import_viem6.encodeFunctionData)({
2956
+ async function authorizeHistoricViewForTransfer(config, address, transferId) {
2957
+ const data = (0, import_viem5.encodeFunctionData)({
2909
2958
  abi: confidentialWrapperAbi,
2910
2959
  functionName: "authorizeHistoricViewTransferId",
2911
- args: [params.address, params.transferId]
2960
+ args: [address, transferId]
2912
2961
  });
2913
2962
  return config.signer.sendTransaction({ to: config.address, data });
2914
2963
  }
2915
- async function revokeHistoricView(config, params) {
2916
- const data = (0, import_viem6.encodeFunctionData)({
2964
+ async function revokeHistoricView(config, address) {
2965
+ const data = (0, import_viem5.encodeFunctionData)({
2917
2966
  abi: confidentialWrapperAbi,
2918
2967
  functionName: "removeHistoricViewAuth",
2919
- args: [params.address]
2968
+ args: [address]
2920
2969
  });
2921
2970
  return config.signer.sendTransaction({ to: config.address, data });
2922
2971
  }
2923
- async function requestTransferDecryption(config, params) {
2924
- const value = await getValueForCtx(config);
2925
- const receipt = await config.publicClient.waitForTransactionReceipt({ hash: params.ctxHash });
2926
- const events = (0, import_viem6.parseEventLogs)({
2972
+ async function requestTransferDecryption(config, ctxHash) {
2973
+ const value = await getCtxOperationCost(config);
2974
+ const receipt = await config.publicClient.waitForTransactionReceipt({ hash: ctxHash });
2975
+ const events = (0, import_viem5.parseEventLogs)({
2927
2976
  abi: confidentialWrapperAbi,
2928
2977
  logs: receipt.logs,
2929
2978
  eventName: "EncryptedTransfer"
@@ -2953,7 +3002,7 @@ async function requestTransferDecryption(config, params) {
2953
3002
  if (!canDecrypt) {
2954
3003
  throw new Error("Viewer is not authorized to decrypt this historic transfer.");
2955
3004
  }
2956
- const data = (0, import_viem6.encodeFunctionData)({
3005
+ const data = (0, import_viem5.encodeFunctionData)({
2957
3006
  abi: confidentialWrapperAbi,
2958
3007
  functionName: "requestDecryptHistoricTransferFor",
2959
3008
  args: [encryptedData, viewerAddress]
@@ -2965,9 +3014,7 @@ async function requestTransferDecryption(config, params) {
2965
3014
  approve,
2966
3015
  authorizeHistoricViewForRange,
2967
3016
  authorizeHistoricViewForTransfer,
2968
- decryptHistoricTransferData,
2969
3017
  decryptTokenBalance,
2970
- fundCtxBalance,
2971
3018
  getCtxBalance,
2972
3019
  getCtxFee,
2973
3020
  getTransferId,