@primuslabs/fhetransform-sdk 0.4.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 +198 -0
- package/dist/abis/acl.abi.d.ts +379 -0
- package/dist/abis/acl.abi.js +495 -0
- package/dist/abis/acl.abi.js.map +1 -0
- package/dist/abis/alphatrion_reward.abi.d.ts +407 -0
- package/dist/abis/alphatrion_reward.abi.js +532 -0
- package/dist/abis/alphatrion_reward.abi.js.map +1 -0
- package/dist/abis/ciphertext_digests.abi.d.ts +336 -0
- package/dist/abis/ciphertext_digests.abi.js +444 -0
- package/dist/abis/ciphertext_digests.abi.js.map +1 -0
- package/dist/abis/ciphertext_verification.abi.d.ts +637 -0
- package/dist/abis/ciphertext_verification.abi.js +830 -0
- package/dist/abis/ciphertext_verification.abi.js.map +1 -0
- package/dist/abis/convert_token.abi.d.ts +922 -0
- package/dist/abis/convert_token.abi.js +1208 -0
- package/dist/abis/convert_token.abi.js.map +1 -0
- package/dist/abis/decryption.abi.d.ts +956 -0
- package/dist/abis/decryption.abi.js +1244 -0
- package/dist/abis/decryption.abi.js.map +1 -0
- package/dist/abis/erc20.abi.d.ts +265 -0
- package/dist/abis/erc20.abi.js +350 -0
- package/dist/abis/erc20.abi.js.map +1 -0
- package/dist/abis/fhe_executor.abi.d.ts +1535 -0
- package/dist/abis/fhe_executor.abi.js +1962 -0
- package/dist/abis/fhe_executor.abi.js.map +1 -0
- package/dist/abis/space_bridge_config.abi.d.ts +792 -0
- package/dist/abis/space_bridge_config.abi.js +1032 -0
- package/dist/abis/space_bridge_config.abi.js.map +1 -0
- package/dist/abis/token.abi.d.ts +630 -0
- package/dist/abis/token.abi.js +828 -0
- package/dist/abis/token.abi.js.map +1 -0
- package/dist/cli/eusdc.d.ts +2 -0
- package/dist/cli/eusdc.js +41 -0
- package/dist/cli/eusdc.js.map +1 -0
- package/dist/contract/callbacks.d.ts +59 -0
- package/dist/contract/callbacks.js +2 -0
- package/dist/contract/callbacks.js.map +1 -0
- package/dist/contract/convert-token.d.ts +107 -0
- package/dist/contract/convert-token.js +249 -0
- package/dist/contract/convert-token.js.map +1 -0
- package/dist/contract/token.d.ts +167 -0
- package/dist/contract/token.js +404 -0
- package/dist/contract/token.js.map +1 -0
- package/dist/contract/transaction.d.ts +29 -0
- package/dist/contract/transaction.js +2 -0
- package/dist/contract/transaction.js.map +1 -0
- package/dist/core/address.d.ts +118 -0
- package/dist/core/address.js +200 -0
- package/dist/core/address.js.map +1 -0
- package/dist/core/auth.d.ts +68 -0
- package/dist/core/auth.js +58 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/bytes.d.ts +48 -0
- package/dist/core/bytes.js +117 -0
- package/dist/core/bytes.js.map +1 -0
- package/dist/core/cache-manager.d.ts +138 -0
- package/dist/core/cache-manager.js +440 -0
- package/dist/core/cache-manager.js.map +1 -0
- package/dist/core/chain.d.ts +41 -0
- package/dist/core/chain.js +59 -0
- package/dist/core/chain.js.map +1 -0
- package/dist/core/constants.d.ts +24 -0
- package/dist/core/constants.js +25 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/error.d.ts +2 -0
- package/dist/core/error.js +14 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/errors/error-catalog.d.ts +29 -0
- package/dist/core/errors/error-catalog.js +84 -0
- package/dist/core/errors/error-catalog.js.map +1 -0
- package/dist/core/errors/error-codes.d.ts +52 -0
- package/dist/core/errors/error-codes.js +61 -0
- package/dist/core/errors/error-codes.js.map +1 -0
- package/dist/core/errors/error-utils.d.ts +27 -0
- package/dist/core/errors/error-utils.js +110 -0
- package/dist/core/errors/error-utils.js.map +1 -0
- package/dist/core/errors/fhe-error.d.ts +98 -0
- package/dist/core/errors/fhe-error.js +190 -0
- package/dist/core/errors/fhe-error.js.map +1 -0
- package/dist/core/errors/index.d.ts +4 -0
- package/dist/core/errors/index.js +5 -0
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/estimate.d.ts +39 -0
- package/dist/core/estimate.js +111 -0
- package/dist/core/estimate.js.map +1 -0
- package/dist/core/event.d.ts +212 -0
- package/dist/core/event.js +42 -0
- package/dist/core/event.js.map +1 -0
- package/dist/core/fhe-type.d.ts +75 -0
- package/dist/core/fhe-type.js +115 -0
- package/dist/core/fhe-type.js.map +1 -0
- package/dist/core/fhe.d.ts +11 -0
- package/dist/core/fhe.js +23 -0
- package/dist/core/fhe.js.map +1 -0
- package/dist/core/handle.d.ts +42 -0
- package/dist/core/handle.js +99 -0
- package/dist/core/handle.js.map +1 -0
- package/dist/core/json-utils.d.ts +18 -0
- package/dist/core/json-utils.js +37 -0
- package/dist/core/json-utils.js.map +1 -0
- package/dist/core/kms.d.ts +42 -0
- package/dist/core/kms.js +70 -0
- package/dist/core/kms.js.map +1 -0
- package/dist/core/logger.d.ts +3 -0
- package/dist/core/logger.js +11 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/pretty-print.d.ts +18 -0
- package/dist/core/pretty-print.js +84 -0
- package/dist/core/pretty-print.js.map +1 -0
- package/dist/core/primitives.d.ts +22 -0
- package/dist/core/primitives.js +2 -0
- package/dist/core/primitives.js.map +1 -0
- package/dist/core/retryable-handler.d.ts +74 -0
- package/dist/core/retryable-handler.js +227 -0
- package/dist/core/retryable-handler.js.map +1 -0
- package/dist/core/signer-address-info.d.ts +15 -0
- package/dist/core/signer-address-info.js +33 -0
- package/dist/core/signer-address-info.js.map +1 -0
- package/dist/core/string.d.ts +28 -0
- package/dist/core/string.js +33 -0
- package/dist/core/string.js.map +1 -0
- package/dist/core/swallow.d.ts +23 -0
- package/dist/core/swallow.js +37 -0
- package/dist/core/swallow.js.map +1 -0
- package/dist/core/system-contract-info.d.ts +17 -0
- package/dist/core/system-contract-info.js +41 -0
- package/dist/core/system-contract-info.js.map +1 -0
- package/dist/core/ttl-cache.d.ts +81 -0
- package/dist/core/ttl-cache.js +113 -0
- package/dist/core/ttl-cache.js.map +1 -0
- package/dist/core/tx-error-parser.d.ts +40 -0
- package/dist/core/tx-error-parser.js +83 -0
- package/dist/core/tx-error-parser.js.map +1 -0
- package/dist/core/utils.d.ts +62 -0
- package/dist/core/utils.js +143 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/jazz/encrypt-key-p.d.ts +65 -0
- package/dist/jazz/encrypt-key-p.js +283 -0
- package/dist/jazz/encrypt-key-p.js.map +1 -0
- package/dist/jazz/encrypt-p.d.ts +82 -0
- package/dist/jazz/encrypt-p.js +139 -0
- package/dist/jazz/encrypt-p.js.map +1 -0
- package/dist/jazz/encrypt.d.ts +58 -0
- package/dist/jazz/encrypt.js +155 -0
- package/dist/jazz/encrypt.js.map +1 -0
- package/dist/jazz/input-proof-p.d.ts +122 -0
- package/dist/jazz/input-proof-p.js +265 -0
- package/dist/jazz/input-proof-p.js.map +1 -0
- package/dist/jazz/jazz-client-i.d.ts +16 -0
- package/dist/jazz/jazz-client-i.js +2 -0
- package/dist/jazz/jazz-client-i.js.map +1 -0
- package/dist/jazz/jazz-client.d.ts +18 -0
- package/dist/jazz/jazz-client.js +24 -0
- package/dist/jazz/jazz-client.js.map +1 -0
- package/dist/jazz/key-pair.d.ts +50 -0
- package/dist/jazz/key-pair.js +166 -0
- package/dist/jazz/key-pair.js.map +1 -0
- package/dist/jazz/mock/fake.d.ts +3 -0
- package/dist/jazz/mock/fake.js +23 -0
- package/dist/jazz/mock/fake.js.map +1 -0
- package/dist/jazz/mock/fetch-input-proof.d.ts +4 -0
- package/dist/jazz/mock/fetch-input-proof.js +63 -0
- package/dist/jazz/mock/fetch-input-proof.js.map +1 -0
- package/dist/jazz/mock/fetch-key-url.d.ts +3 -0
- package/dist/jazz/mock/fetch-key-url.js +15 -0
- package/dist/jazz/mock/fetch-key-url.js.map +1 -0
- package/dist/jazz/mock/fetch-public-decrypt.d.ts +3 -0
- package/dist/jazz/mock/fetch-public-decrypt.js +81 -0
- package/dist/jazz/mock/fetch-public-decrypt.js.map +1 -0
- package/dist/jazz/mock/fetch-user-decrypt.d.ts +4 -0
- package/dist/jazz/mock/fetch-user-decrypt.js +174 -0
- package/dist/jazz/mock/fetch-user-decrypt.js.map +1 -0
- package/dist/jazz/module/fetch-input-proof.d.ts +19 -0
- package/dist/jazz/module/fetch-input-proof.js +72 -0
- package/dist/jazz/module/fetch-input-proof.js.map +1 -0
- package/dist/jazz/module/fetch-key-url.d.ts +17 -0
- package/dist/jazz/module/fetch-key-url.js +46 -0
- package/dist/jazz/module/fetch-key-url.js.map +1 -0
- package/dist/jazz/module/fetch-public-decrypt.d.ts +19 -0
- package/dist/jazz/module/fetch-public-decrypt.js +65 -0
- package/dist/jazz/module/fetch-public-decrypt.js.map +1 -0
- package/dist/jazz/module/fetch-user-decrypt.d.ts +19 -0
- package/dist/jazz/module/fetch-user-decrypt.js +109 -0
- package/dist/jazz/module/fetch-user-decrypt.js.map +1 -0
- package/dist/jazz/module/jazz-async-request.d.ts +102 -0
- package/dist/jazz/module/jazz-async-request.js +515 -0
- package/dist/jazz/module/jazz-async-request.js.map +1 -0
- package/dist/jazz/module/jazz-p.d.ts +61 -0
- package/dist/jazz/module/jazz-p.js +33 -0
- package/dist/jazz/module/jazz-p.js.map +1 -0
- package/dist/jazz/module/s3-download.d.ts +85 -0
- package/dist/jazz/module/s3-download.js +293 -0
- package/dist/jazz/module/s3-download.js.map +1 -0
- package/dist/jazz/permit.d.ts +200 -0
- package/dist/jazz/permit.js +319 -0
- package/dist/jazz/permit.js.map +1 -0
- package/dist/jazz/public-decrypt-p.d.ts +96 -0
- package/dist/jazz/public-decrypt-p.js +258 -0
- package/dist/jazz/public-decrypt-p.js.map +1 -0
- package/dist/jazz/public-decrypt.d.ts +48 -0
- package/dist/jazz/public-decrypt.js +156 -0
- package/dist/jazz/public-decrypt.js.map +1 -0
- package/dist/jazz/read-contract.d.ts +81 -0
- package/dist/jazz/read-contract.js +125 -0
- package/dist/jazz/read-contract.js.map +1 -0
- package/dist/jazz/types/common.d.ts +17 -0
- package/dist/jazz/types/common.js +2 -0
- package/dist/jazz/types/common.js.map +1 -0
- package/dist/jazz/types/input-proof.d.ts +76 -0
- package/dist/jazz/types/input-proof.js +2 -0
- package/dist/jazz/types/input-proof.js.map +1 -0
- package/dist/jazz/types/key-url.d.ts +68 -0
- package/dist/jazz/types/key-url.js +5 -0
- package/dist/jazz/types/key-url.js.map +1 -0
- package/dist/jazz/types/public-decrypt.d.ts +61 -0
- package/dist/jazz/types/public-decrypt.js +2 -0
- package/dist/jazz/types/public-decrypt.js.map +1 -0
- package/dist/jazz/types/user-decrypt.d.ts +123 -0
- package/dist/jazz/types/user-decrypt.js +2 -0
- package/dist/jazz/types/user-decrypt.js.map +1 -0
- package/dist/jazz/user-decrypt-p.d.ts +111 -0
- package/dist/jazz/user-decrypt-p.js +280 -0
- package/dist/jazz/user-decrypt-p.js.map +1 -0
- package/dist/jazz/user-decrypt.d.ts +74 -0
- package/dist/jazz/user-decrypt.js +143 -0
- package/dist/jazz/user-decrypt.js.map +1 -0
- package/dist/native/fhe-api.js +5959 -0
- package/dist/native/fhe-api.node.cjs +6167 -0
- package/dist/native/fhe-api.node.worker.cjs +210 -0
- package/dist/native/fhe-api.wasm +0 -0
- package/dist/native/fhe-api.worker.js +164 -0
- package/dist/native/kms/node/kms_lib.d.ts +38 -0
- package/dist/native/kms/node/kms_lib.js +356 -0
- package/dist/native/kms/node/kms_lib_bg.wasm +0 -0
- package/dist/native/kms/node/kms_lib_bg.wasm.d.ts +21 -0
- package/dist/native/kms/node/package.json +11 -0
- package/dist/native/kms/web/kms_lib.d.ts +84 -0
- package/dist/native/kms/web/kms_lib.js +443 -0
- package/dist/native/kms/web/kms_lib_bg.wasm +0 -0
- package/dist/native/kms/web/kms_lib_bg.wasm.d.ts +21 -0
- package/dist/native/kms/web/package.json +15 -0
- package/dist/runtime/browser.d.ts +36 -0
- package/dist/runtime/browser.js +115 -0
- package/dist/runtime/browser.js.map +1 -0
- package/dist/runtime/node.d.ts +30 -0
- package/dist/runtime/node.js +95 -0
- package/dist/runtime/node.js.map +1 -0
- package/dist/sdk/fhetransform-sdk-b.d.ts +102 -0
- package/dist/sdk/fhetransform-sdk-b.js +294 -0
- package/dist/sdk/fhetransform-sdk-b.js.map +1 -0
- package/dist/sdk/fhetransform-sdk.d.ts +87 -0
- package/dist/sdk/fhetransform-sdk.js +135 -0
- package/dist/sdk/fhetransform-sdk.js.map +1 -0
- package/dist/sdk/jazz-service.d.ts +13 -0
- package/dist/sdk/jazz-service.js +58 -0
- package/dist/sdk/jazz-service.js.map +1 -0
- package/dist/sdk/permit-service.d.ts +45 -0
- package/dist/sdk/permit-service.js +144 -0
- package/dist/sdk/permit-service.js.map +1 -0
- package/dist/wasm/fhe-wasm-client.d.ts +19 -0
- package/dist/wasm/fhe-wasm-client.js +23 -0
- package/dist/wasm/fhe-wasm-client.js.map +1 -0
- package/dist/wasm/fhe-wasm-module.d.ts +24 -0
- package/dist/wasm/fhe-wasm-module.js +141 -0
- package/dist/wasm/fhe-wasm-module.js.map +1 -0
- package/dist/wasm/fhe-wasm-type.d.ts +59 -0
- package/dist/wasm/fhe-wasm-type.js +244 -0
- package/dist/wasm/fhe-wasm-type.js.map +1 -0
- package/dist/wasm/wasm-loader.browser.d.ts +21 -0
- package/dist/wasm/wasm-loader.browser.js +143 -0
- package/dist/wasm/wasm-loader.browser.js.map +1 -0
- package/dist/wasm/wasm-loader.node.d.ts +24 -0
- package/dist/wasm/wasm-loader.node.js +114 -0
- package/dist/wasm/wasm-loader.node.js.map +1 -0
- package/dist/wasm/worker-client.browser.d.ts +6 -0
- package/dist/wasm/worker-client.browser.js +21 -0
- package/dist/wasm/worker-client.browser.js.map +1 -0
- package/dist/wasm/worker-client.d.ts +34 -0
- package/dist/wasm/worker-client.js +160 -0
- package/dist/wasm/worker-client.js.map +1 -0
- package/dist/wasm/worker-client.node.d.ts +6 -0
- package/dist/wasm/worker-client.node.js +20 -0
- package/dist/wasm/worker-client.node.js.map +1 -0
- package/dist/wasm/worker-message.d.ts +61 -0
- package/dist/wasm/worker-message.js +2 -0
- package/dist/wasm/worker-message.js.map +1 -0
- package/dist/wasm/worker-transport.browser.d.ts +15 -0
- package/dist/wasm/worker-transport.browser.js +35 -0
- package/dist/wasm/worker-transport.browser.js.map +1 -0
- package/dist/wasm/worker-transport.d.ts +6 -0
- package/dist/wasm/worker-transport.js +2 -0
- package/dist/wasm/worker-transport.js.map +1 -0
- package/dist/wasm/worker-transport.node.d.ts +17 -0
- package/dist/wasm/worker-transport.node.js +39 -0
- package/dist/wasm/worker-transport.node.js.map +1 -0
- package/dist/wasm/worker.d.ts +1 -0
- package/dist/wasm/worker.js +69 -0
- package/dist/wasm/worker.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { FheTransformSDKEventInput } from "../core/event.js";
|
|
2
|
+
import { FheType, UnverifiedEncryptData } from "../core/fhe-type.js";
|
|
3
|
+
import { Address, Bytes32Hex, BytesHex } from "../core/primitives.js";
|
|
4
|
+
import { CountRetryHandler } from "../core/retryable-handler.js";
|
|
5
|
+
import { FheTransformSDK } from "../sdk/fhetransform-sdk";
|
|
6
|
+
import { TransferCallbacks } from "./callbacks.js";
|
|
7
|
+
import { TransactionResult } from "./transaction.js";
|
|
8
|
+
import { ethers } from "ethers";
|
|
9
|
+
/** Options for configuring a transfer transaction. */
|
|
10
|
+
export interface TransferOptions {
|
|
11
|
+
/** Amount to transfer in the token's smallest unit (e.g., wei). */
|
|
12
|
+
value?: bigint;
|
|
13
|
+
/** Maximum gas units to spend on the transaction. */
|
|
14
|
+
gasLimit?: bigint;
|
|
15
|
+
/** Gas price to use for the transaction. */
|
|
16
|
+
gasPrice?: bigint;
|
|
17
|
+
}
|
|
18
|
+
/** Result of a confidential transfer operation. */
|
|
19
|
+
export interface TransferResult extends TransactionResult {
|
|
20
|
+
/** The encrypted amount that was transferred. */
|
|
21
|
+
transferred: Bytes32Hex;
|
|
22
|
+
}
|
|
23
|
+
export declare class TokenBase {
|
|
24
|
+
readonly sdk: FheTransformSDK;
|
|
25
|
+
readonly address: Address;
|
|
26
|
+
readonly abi: ethers.Interface | ethers.InterfaceAbi;
|
|
27
|
+
readonly countRetryHandler: CountRetryHandler;
|
|
28
|
+
private _tokenContract;
|
|
29
|
+
constructor(sdk: FheTransformSDK, address: Address, abi: ethers.Interface | ethers.InterfaceAbi);
|
|
30
|
+
protected emit(input: FheTransformSDKEventInput): void;
|
|
31
|
+
protected ensureContract(): Promise<ethers.Contract>;
|
|
32
|
+
protected ensureWriteContract(): Promise<ethers.Contract>;
|
|
33
|
+
protected getContract(): Promise<ethers.Contract>;
|
|
34
|
+
/**
|
|
35
|
+
* Estimate the FHE execution fee for a given function.
|
|
36
|
+
* @param functionName - The name of the function to estimate fee for
|
|
37
|
+
* @returns The estimated total fee as a bigint
|
|
38
|
+
*/
|
|
39
|
+
protected getFheFee(functionName: string): Promise<bigint>;
|
|
40
|
+
/**
|
|
41
|
+
* Encrypts a numeric value using the FHE SDK.
|
|
42
|
+
* @param amount - The plaintext value to encrypt
|
|
43
|
+
* @param fheType - The FHE type to use (defaults to ve_uint64)
|
|
44
|
+
* @returns The encrypted value as an UnverifiedEncryptData object
|
|
45
|
+
*/
|
|
46
|
+
protected encryptAmount(amount: bigint, fheType?: FheType): Promise<UnverifiedEncryptData>;
|
|
47
|
+
/**
|
|
48
|
+
* Generic transaction executor with logging and event parsing.
|
|
49
|
+
* Handles transaction sending, confirmation, event parsing, and error handling.
|
|
50
|
+
*
|
|
51
|
+
* @param functionName - The fully qualified function signature
|
|
52
|
+
* @param args - Function arguments
|
|
53
|
+
* @param options - Transaction options (value, gasLimit, gasPrice)
|
|
54
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
55
|
+
* @returns TransferResult containing tx hash, receipt, and transferred amount
|
|
56
|
+
*/
|
|
57
|
+
protected executeTransaction(functionName: string, args: unknown[], t0: number, options?: TransferOptions, callbacks?: TransferCallbacks): Promise<TransferResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Parses a specific event from transaction logs.
|
|
60
|
+
* @param contract - The contract instance
|
|
61
|
+
* @param receipt - The transaction receipt
|
|
62
|
+
* @param eventName - The name of the event to find
|
|
63
|
+
* @returns The parsed event or null if not found
|
|
64
|
+
*/
|
|
65
|
+
protected parseEvent(contract: ethers.Contract, receipt: ethers.TransactionReceipt, eventName: string): ethers.LogDescription | null;
|
|
66
|
+
}
|
|
67
|
+
export declare class Token extends TokenBase {
|
|
68
|
+
/**
|
|
69
|
+
* Gets the token name.
|
|
70
|
+
* @returns The token name
|
|
71
|
+
*/
|
|
72
|
+
name(): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the token symbol.
|
|
75
|
+
* @returns The token symbol
|
|
76
|
+
*/
|
|
77
|
+
symbol(): Promise<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the token decimals.
|
|
80
|
+
* @returns The number of decimals
|
|
81
|
+
*/
|
|
82
|
+
decimals(): Promise<number>;
|
|
83
|
+
/**
|
|
84
|
+
* Gets the contract URI.
|
|
85
|
+
* @returns The contract URI string
|
|
86
|
+
*/
|
|
87
|
+
contractURI(): Promise<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the plaintext total supply.
|
|
90
|
+
* @returns The total supply as a bigint
|
|
91
|
+
*/
|
|
92
|
+
totalSupply(): Promise<bigint>;
|
|
93
|
+
/**
|
|
94
|
+
* Gets the encrypted total supply without decrypting.
|
|
95
|
+
* @returns The encrypted total supply as bytes32
|
|
96
|
+
*/
|
|
97
|
+
confidentialTotalSupply(): Promise<Bytes32Hex>;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the plaintext balance for the given owner.
|
|
100
|
+
* The caller must have decryption permissions for the encrypted balance.
|
|
101
|
+
* @param owner - The address to query
|
|
102
|
+
* @returns The balance as a bigint
|
|
103
|
+
*/
|
|
104
|
+
balanceOf(owner: Address): Promise<bigint>;
|
|
105
|
+
/**
|
|
106
|
+
* Gets the encrypted balance without decrypting.
|
|
107
|
+
* @param owner - The address to query
|
|
108
|
+
* @returns The encrypted balance as bytes32
|
|
109
|
+
*/
|
|
110
|
+
confidentialBalanceOf(owner: Address): Promise<Bytes32Hex>;
|
|
111
|
+
/**
|
|
112
|
+
* Sets an operator with approval expiry.
|
|
113
|
+
* @param operator - The address to approve as operator
|
|
114
|
+
* @param until - Optional Unix timestamp for expiry (default: now + 1 hour)
|
|
115
|
+
* @returns Transaction result
|
|
116
|
+
*/
|
|
117
|
+
setOperator(operator: Address, until?: number): Promise<TransactionResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Checks if a holder has approved a spender as operator.
|
|
120
|
+
* @param holder - The token holder
|
|
121
|
+
* @param spender - The spender to check
|
|
122
|
+
* @returns True if spender is an operator for holder
|
|
123
|
+
*/
|
|
124
|
+
isOperator(holder: Address, spender: Address): Promise<boolean>;
|
|
125
|
+
/**
|
|
126
|
+
* Transfers confidential tokens to a recipient.
|
|
127
|
+
* @param to - Recipient address
|
|
128
|
+
* @param amount - Amount to transfer
|
|
129
|
+
* @param options - Transfer options (value, gas settings)
|
|
130
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
131
|
+
* @returns Transfer result with tx hash and transferred amount
|
|
132
|
+
*/
|
|
133
|
+
confidentialTransfer(to: Address, amount: bigint, options?: TransferOptions, callbacks?: TransferCallbacks): Promise<TransferResult>;
|
|
134
|
+
/**
|
|
135
|
+
* Transfers confidential tokens from one address to another.
|
|
136
|
+
* Requires the spender to have operator approval.
|
|
137
|
+
* @param from - Source address
|
|
138
|
+
* @param to - Recipient address
|
|
139
|
+
* @param amount - Amount to transfer
|
|
140
|
+
* @param options - Transfer options (value, gas settings)
|
|
141
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
142
|
+
* @returns Transfer result with tx hash and transferred amount
|
|
143
|
+
*/
|
|
144
|
+
confidentialTransferFrom(from: Address, to: Address, amount: bigint, options?: TransferOptions, callbacks?: TransferCallbacks): Promise<TransferResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Transfers confidential tokens and calls a recipient contract.
|
|
147
|
+
* @param to - Recipient address (must be a contract implementing the callback)
|
|
148
|
+
* @param amount - Amount to transfer
|
|
149
|
+
* @param data - Calldata for the recipient contract
|
|
150
|
+
* @param options - Transfer options (value, gas settings)
|
|
151
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
152
|
+
* @returns Transfer result with tx hash and transferred amount
|
|
153
|
+
*/
|
|
154
|
+
confidentialTransferAndCall(to: Address, amount: bigint, data: BytesHex, options?: TransferOptions, callbacks?: TransferCallbacks): Promise<TransferResult>;
|
|
155
|
+
/**
|
|
156
|
+
* Transfers confidential tokens from one address to another and calls the recipient.
|
|
157
|
+
* Requires the spender to have operator approval.
|
|
158
|
+
* @param from - Source address
|
|
159
|
+
* @param to - Recipient address (must be a contract implementing the callback)
|
|
160
|
+
* @param amount - Amount to transfer
|
|
161
|
+
* @param data - Calldata for the recipient contract
|
|
162
|
+
* @param options - Transfer options (value, gas settings)
|
|
163
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
164
|
+
* @returns Transfer result with tx hash and transferred amount
|
|
165
|
+
*/
|
|
166
|
+
confidentialTransferFromAndCall(from: Address, to: Address, amount: bigint, data: BytesHex, options?: TransferOptions, callbacks?: TransferCallbacks): Promise<TransferResult>;
|
|
167
|
+
}
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { bytesToBigInt, fromHexString } from "../core/bytes.js";
|
|
2
|
+
import { toError } from "../core/error.js";
|
|
3
|
+
import { toFheError } from "../core/errors/error-utils.js";
|
|
4
|
+
import { FheTransformSDKEvents } from "../core/event.js";
|
|
5
|
+
import { FheType } from "../core/fhe-type.js";
|
|
6
|
+
import { logger } from "../core/logger.js";
|
|
7
|
+
import { formatValue } from "../core/pretty-print.js";
|
|
8
|
+
import { CountRetryHandler } from "../core/retryable-handler.js";
|
|
9
|
+
import { swallow } from "../core/swallow.js";
|
|
10
|
+
import { ethers } from "ethers";
|
|
11
|
+
import { FheErrorCode } from "../core/errors/error-codes.js";
|
|
12
|
+
import { FheError } from "../core/errors/fhe-error.js";
|
|
13
|
+
// ============================================
|
|
14
|
+
// TokenBase: Core Functionality
|
|
15
|
+
// ============================================
|
|
16
|
+
export class TokenBase {
|
|
17
|
+
sdk;
|
|
18
|
+
address;
|
|
19
|
+
abi;
|
|
20
|
+
countRetryHandler;
|
|
21
|
+
_tokenContract = null;
|
|
22
|
+
constructor(sdk, address, abi) {
|
|
23
|
+
this.sdk = sdk;
|
|
24
|
+
this.address = address;
|
|
25
|
+
this.abi = abi;
|
|
26
|
+
this.sdk.errorParser.addAbi(abi);
|
|
27
|
+
this.countRetryHandler = new CountRetryHandler({
|
|
28
|
+
retryableErrors: ["nonce has already been used", "nonce too low", "replacement fee too low"]
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
emit(input) {
|
|
32
|
+
this.sdk.emitEvent(input, this.address);
|
|
33
|
+
}
|
|
34
|
+
// ============================================
|
|
35
|
+
// Contract Management
|
|
36
|
+
// ============================================
|
|
37
|
+
async ensureContract() {
|
|
38
|
+
if (this._tokenContract) {
|
|
39
|
+
return this._tokenContract;
|
|
40
|
+
}
|
|
41
|
+
const provider = await this.sdk.requireProvider();
|
|
42
|
+
this._tokenContract = new ethers.Contract(this.address, this.abi, provider);
|
|
43
|
+
return this._tokenContract;
|
|
44
|
+
}
|
|
45
|
+
async ensureWriteContract() {
|
|
46
|
+
const contract = await this.ensureContract();
|
|
47
|
+
const signer = await this.sdk.requireSigner();
|
|
48
|
+
return contract.connect(signer);
|
|
49
|
+
}
|
|
50
|
+
async getContract() {
|
|
51
|
+
return await this.ensureWriteContract();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Estimate the FHE execution fee for a given function.
|
|
55
|
+
* @param functionName - The name of the function to estimate fee for
|
|
56
|
+
* @returns The estimated total fee as a bigint
|
|
57
|
+
*/
|
|
58
|
+
async getFheFee(functionName) {
|
|
59
|
+
const chainId = await this.sdk.getChainID();
|
|
60
|
+
const { totalFee } = await this.sdk.estimateFheFee(this.address, functionName, chainId);
|
|
61
|
+
return totalFee;
|
|
62
|
+
}
|
|
63
|
+
// ============================================
|
|
64
|
+
// Encryption
|
|
65
|
+
// ============================================
|
|
66
|
+
/**
|
|
67
|
+
* Encrypts a numeric value using the FHE SDK.
|
|
68
|
+
* @param amount - The plaintext value to encrypt
|
|
69
|
+
* @param fheType - The FHE type to use (defaults to ve_uint64)
|
|
70
|
+
* @returns The encrypted value as an UnverifiedEncryptData object
|
|
71
|
+
*/
|
|
72
|
+
async encryptAmount(amount, fheType) {
|
|
73
|
+
const userAddress = await this.sdk.requireWalletAddress();
|
|
74
|
+
const encryptParameters = {
|
|
75
|
+
payloads: [{ value: amount, fheType: fheType ?? FheType.ve_uint64 }],
|
|
76
|
+
contractAddress: this.address,
|
|
77
|
+
userAddress,
|
|
78
|
+
options: {
|
|
79
|
+
onJazzProgress: (args) => {
|
|
80
|
+
logger.info(() => ["[TokenBase.encryptAmount] onJazzProgress:", formatValue(args)]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
logger.debug("Encrypting amount", { encryptParameters });
|
|
85
|
+
const { encryptedValues } = await this.sdk.encrypt(encryptParameters);
|
|
86
|
+
const encrypted = encryptedValues?.[0];
|
|
87
|
+
if (!encrypted) {
|
|
88
|
+
throw new FheError({ code: FheErrorCode.EncryptionFailed, message: "Encryption returned no values" });
|
|
89
|
+
}
|
|
90
|
+
return encrypted;
|
|
91
|
+
}
|
|
92
|
+
// ============================================
|
|
93
|
+
// Transaction Execution
|
|
94
|
+
// ============================================
|
|
95
|
+
/**
|
|
96
|
+
* Generic transaction executor with logging and event parsing.
|
|
97
|
+
* Handles transaction sending, confirmation, event parsing, and error handling.
|
|
98
|
+
*
|
|
99
|
+
* @param functionName - The fully qualified function signature
|
|
100
|
+
* @param args - Function arguments
|
|
101
|
+
* @param options - Transaction options (value, gasLimit, gasPrice)
|
|
102
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
103
|
+
* @returns TransferResult containing tx hash, receipt, and transferred amount
|
|
104
|
+
*/
|
|
105
|
+
async executeTransaction(functionName, args, t0, options, callbacks) {
|
|
106
|
+
try {
|
|
107
|
+
const contract = await this.getContract();
|
|
108
|
+
const fn = contract.getFunction(functionName);
|
|
109
|
+
const txOptions = {
|
|
110
|
+
value: options?.value ?? 0n,
|
|
111
|
+
...(options?.gasLimit && { gasLimit: options.gasLimit }),
|
|
112
|
+
...(options?.gasPrice && { gasPrice: options.gasPrice }),
|
|
113
|
+
};
|
|
114
|
+
// 1. Send transaction
|
|
115
|
+
const tx = await this.countRetryHandler.withRetry(async () => {
|
|
116
|
+
return await fn(...args, txOptions).catch(this.sdk.errorParser.catch);
|
|
117
|
+
}, functionName);
|
|
118
|
+
logger.info("Transaction sent", { txHash: tx.hash, function: functionName });
|
|
119
|
+
swallow("transfer submitted", () => callbacks?.onTransferSubmitted?.(tx.hash));
|
|
120
|
+
// 2. Wait for confirmation
|
|
121
|
+
const receipt = await tx.wait();
|
|
122
|
+
logger.info("Transaction confirmed", {
|
|
123
|
+
txHash: tx.hash,
|
|
124
|
+
blockNumber: receipt.blockNumber,
|
|
125
|
+
status: receipt.status,
|
|
126
|
+
});
|
|
127
|
+
swallow("transfer confirm", () => callbacks?.onTransferConfirmed?.(receipt));
|
|
128
|
+
// 3. Check transaction status
|
|
129
|
+
if (receipt.status === 0) {
|
|
130
|
+
const error = new FheError({ code: FheErrorCode.TransactionReverted, message: `Transaction reverted: ${tx.hash}`, context: { txHash: tx.hash } });
|
|
131
|
+
logger.error("Transaction reverted", {
|
|
132
|
+
txHash: tx.hash,
|
|
133
|
+
blockNumber: receipt.blockNumber,
|
|
134
|
+
gasUsed: receipt.gasUsed.toString(),
|
|
135
|
+
});
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
// 4. Parse event
|
|
139
|
+
const transferEvent = this.parseEvent(contract, receipt, "ConfidentialTransfer");
|
|
140
|
+
if (!transferEvent) {
|
|
141
|
+
const error = new FheError({ code: FheErrorCode.ContractCallFailed, message: "ConfidentialTransfer event not found in transaction logs", context: { functionName } });
|
|
142
|
+
logger.error("Event not found", {
|
|
143
|
+
txHash: tx.hash,
|
|
144
|
+
blockNumber: receipt.blockNumber,
|
|
145
|
+
logCount: receipt.logs.length,
|
|
146
|
+
});
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
this.emit({ type: FheTransformSDKEvents.TransactionEnd, functionName, txHash: tx.hash, durationMs: Date.now() - t0 });
|
|
150
|
+
// 5. Return result
|
|
151
|
+
return {
|
|
152
|
+
txHash: tx.hash,
|
|
153
|
+
receipt,
|
|
154
|
+
transferred: transferEvent.args[2],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
swallow("transfer error", () => callbacks?.onError?.(toError(error)));
|
|
159
|
+
this.emit({ type: FheTransformSDKEvents.TransactionError, functionName, error: toFheError(error).getPublicPayload(), durationMs: Date.now() - t0 });
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Parses a specific event from transaction logs.
|
|
165
|
+
* @param contract - The contract instance
|
|
166
|
+
* @param receipt - The transaction receipt
|
|
167
|
+
* @param eventName - The name of the event to find
|
|
168
|
+
* @returns The parsed event or null if not found
|
|
169
|
+
*/
|
|
170
|
+
parseEvent(contract, receipt, eventName) {
|
|
171
|
+
for (const log of receipt.logs) {
|
|
172
|
+
try {
|
|
173
|
+
const parsed = contract.interface.parseLog(log);
|
|
174
|
+
if (parsed?.name === eventName) {
|
|
175
|
+
return parsed;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// Skip unparseable logs
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// ============================================
|
|
187
|
+
// Token: Public API
|
|
188
|
+
// ============================================
|
|
189
|
+
export class Token extends TokenBase {
|
|
190
|
+
// ============================================
|
|
191
|
+
// Metadata
|
|
192
|
+
// ============================================
|
|
193
|
+
/**
|
|
194
|
+
* Gets the token name.
|
|
195
|
+
* @returns The token name
|
|
196
|
+
*/
|
|
197
|
+
async name() {
|
|
198
|
+
const contract = await this.ensureContract();
|
|
199
|
+
return await contract.name();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Gets the token symbol.
|
|
203
|
+
* @returns The token symbol
|
|
204
|
+
*/
|
|
205
|
+
async symbol() {
|
|
206
|
+
const contract = await this.ensureContract();
|
|
207
|
+
return await contract.symbol();
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Gets the token decimals.
|
|
211
|
+
* @returns The number of decimals
|
|
212
|
+
*/
|
|
213
|
+
async decimals() {
|
|
214
|
+
const contract = await this.ensureContract();
|
|
215
|
+
return await contract.decimals();
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Gets the contract URI.
|
|
219
|
+
* @returns The contract URI string
|
|
220
|
+
*/
|
|
221
|
+
async contractURI() {
|
|
222
|
+
const contract = await this.ensureContract();
|
|
223
|
+
return await contract.contractURI();
|
|
224
|
+
}
|
|
225
|
+
// ============================================
|
|
226
|
+
// Total Supply
|
|
227
|
+
// ============================================
|
|
228
|
+
/**
|
|
229
|
+
* Gets the plaintext total supply.
|
|
230
|
+
* @returns The total supply as a bigint
|
|
231
|
+
*/
|
|
232
|
+
async totalSupply() {
|
|
233
|
+
const encryptedValue = await this.confidentialTotalSupply();
|
|
234
|
+
logger.debug("Encrypted total supply fetched", { encryptedValue });
|
|
235
|
+
// Check if encrypted value is zero
|
|
236
|
+
if (bytesToBigInt(fromHexString(encryptedValue)) === 0n) {
|
|
237
|
+
return 0n;
|
|
238
|
+
}
|
|
239
|
+
// TODO: Implement decryption of confidential total supply
|
|
240
|
+
// The contract owner or authorized entity needs to decrypt this
|
|
241
|
+
// Consider adding a view function that allows authorized callers to decrypt
|
|
242
|
+
throw new FheError({ code: FheErrorCode.NotImplemented, message: "not implemented" });
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Gets the encrypted total supply without decrypting.
|
|
246
|
+
* @returns The encrypted total supply as bytes32
|
|
247
|
+
*/
|
|
248
|
+
async confidentialTotalSupply() {
|
|
249
|
+
const contract = await this.ensureContract();
|
|
250
|
+
return await contract.confidentialTotalSupply();
|
|
251
|
+
}
|
|
252
|
+
// ============================================
|
|
253
|
+
// Balances
|
|
254
|
+
// ============================================
|
|
255
|
+
/**
|
|
256
|
+
* Gets the plaintext balance for the given owner.
|
|
257
|
+
* The caller must have decryption permissions for the encrypted balance.
|
|
258
|
+
* @param owner - The address to query
|
|
259
|
+
* @returns The balance as a bigint
|
|
260
|
+
*/
|
|
261
|
+
async balanceOf(owner) {
|
|
262
|
+
const encryptedValue = await this.confidentialBalanceOf(owner);
|
|
263
|
+
logger.debug("Encrypted balance fetched", { encryptedValue });
|
|
264
|
+
// Fast path: zero balance
|
|
265
|
+
if (bytesToBigInt(fromHexString(encryptedValue)) === 0n) {
|
|
266
|
+
return 0n;
|
|
267
|
+
}
|
|
268
|
+
// Decrypt the balance using the user's decryption key
|
|
269
|
+
const userDecryptParameters = {
|
|
270
|
+
payloads: {
|
|
271
|
+
handle: encryptedValue,
|
|
272
|
+
contractAddress: this.address,
|
|
273
|
+
},
|
|
274
|
+
options: {
|
|
275
|
+
onJazzProgress: (args) => {
|
|
276
|
+
logger.info(() => ["[Token.balanceOf] onJazzProgress:", formatValue(args)]);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
logger.debug("Decrypting balance", { userDecryptParameters });
|
|
281
|
+
const userDecryptResult = await this.sdk.userDecrypt(userDecryptParameters);
|
|
282
|
+
logger.debug("Decryption result", { userDecryptResult });
|
|
283
|
+
const plaintexts = userDecryptResult?.plaintexts;
|
|
284
|
+
if (!plaintexts) {
|
|
285
|
+
throw new FheError({ code: FheErrorCode.DecryptionFailed, message: "Decryption returned no plaintext" });
|
|
286
|
+
}
|
|
287
|
+
const value = plaintexts.value;
|
|
288
|
+
logger.debug("Decrypted balance", { value });
|
|
289
|
+
return value;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Gets the encrypted balance without decrypting.
|
|
293
|
+
* @param owner - The address to query
|
|
294
|
+
* @returns The encrypted balance as bytes32
|
|
295
|
+
*/
|
|
296
|
+
async confidentialBalanceOf(owner) {
|
|
297
|
+
const contract = await this.ensureContract();
|
|
298
|
+
return await contract.confidentialBalanceOf(owner);
|
|
299
|
+
}
|
|
300
|
+
// ============================================
|
|
301
|
+
// Operator Approval
|
|
302
|
+
// ============================================
|
|
303
|
+
/**
|
|
304
|
+
* Sets an operator with approval expiry.
|
|
305
|
+
* @param operator - The address to approve as operator
|
|
306
|
+
* @param until - Optional Unix timestamp for expiry (default: now + 1 hour)
|
|
307
|
+
* @returns Transaction result
|
|
308
|
+
*/
|
|
309
|
+
async setOperator(operator, until) {
|
|
310
|
+
const effectiveUntil = until ?? Math.floor(Date.now() / 1000) + 3600;
|
|
311
|
+
const contract = await this.ensureWriteContract();
|
|
312
|
+
const tx = await contract.setOperator(operator, effectiveUntil);
|
|
313
|
+
logger.info("setOperator transaction sent", { txHash: tx.hash });
|
|
314
|
+
const receipt = await tx.wait();
|
|
315
|
+
logger.info("setOperator confirmed", {
|
|
316
|
+
txHash: tx.hash,
|
|
317
|
+
blockNumber: receipt.blockNumber,
|
|
318
|
+
});
|
|
319
|
+
if (receipt.status === 0) {
|
|
320
|
+
throw new FheError({ code: FheErrorCode.TransactionReverted, message: `Transaction reverted on-chain: ${tx.hash}`, context: { txHash: tx.hash } });
|
|
321
|
+
}
|
|
322
|
+
return { txHash: tx.hash, receipt };
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Checks if a holder has approved a spender as operator.
|
|
326
|
+
* @param holder - The token holder
|
|
327
|
+
* @param spender - The spender to check
|
|
328
|
+
* @returns True if spender is an operator for holder
|
|
329
|
+
*/
|
|
330
|
+
async isOperator(holder, spender) {
|
|
331
|
+
const contract = await this.ensureContract();
|
|
332
|
+
return await contract.isOperator(holder, spender);
|
|
333
|
+
}
|
|
334
|
+
// ============================================
|
|
335
|
+
// Write Operations - Confidential Transfers
|
|
336
|
+
// ============================================
|
|
337
|
+
/**
|
|
338
|
+
* Transfers confidential tokens to a recipient.
|
|
339
|
+
* @param to - Recipient address
|
|
340
|
+
* @param amount - Amount to transfer
|
|
341
|
+
* @param options - Transfer options (value, gas settings)
|
|
342
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
343
|
+
* @returns Transfer result with tx hash and transferred amount
|
|
344
|
+
*/
|
|
345
|
+
async confidentialTransfer(to, amount, options, callbacks) {
|
|
346
|
+
const t0 = Date.now();
|
|
347
|
+
const encryptedAmount = await this.encryptAmount(amount);
|
|
348
|
+
swallow("encrypt amount", () => callbacks?.onEncryptComplete?.());
|
|
349
|
+
const totalFee = await this.getFheFee("confidentialTransfer");
|
|
350
|
+
return this.executeTransaction("confidentialTransfer(address,(bytes32,bytes))", [to, encryptedAmount], t0, { ...options, value: totalFee }, callbacks);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Transfers confidential tokens from one address to another.
|
|
354
|
+
* Requires the spender to have operator approval.
|
|
355
|
+
* @param from - Source address
|
|
356
|
+
* @param to - Recipient address
|
|
357
|
+
* @param amount - Amount to transfer
|
|
358
|
+
* @param options - Transfer options (value, gas settings)
|
|
359
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
360
|
+
* @returns Transfer result with tx hash and transferred amount
|
|
361
|
+
*/
|
|
362
|
+
async confidentialTransferFrom(from, to, amount, options, callbacks) {
|
|
363
|
+
const t0 = Date.now();
|
|
364
|
+
const encryptedAmount = await this.encryptAmount(amount);
|
|
365
|
+
swallow("encrypt amount", () => callbacks?.onEncryptComplete?.());
|
|
366
|
+
const totalFee = await this.getFheFee("confidentialTransferFrom");
|
|
367
|
+
return this.executeTransaction("confidentialTransferFrom(address,address,(bytes32,bytes))", [from, to, encryptedAmount], t0, { ...options, value: totalFee }, callbacks);
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Transfers confidential tokens and calls a recipient contract.
|
|
371
|
+
* @param to - Recipient address (must be a contract implementing the callback)
|
|
372
|
+
* @param amount - Amount to transfer
|
|
373
|
+
* @param data - Calldata for the recipient contract
|
|
374
|
+
* @param options - Transfer options (value, gas settings)
|
|
375
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
376
|
+
* @returns Transfer result with tx hash and transferred amount
|
|
377
|
+
*/
|
|
378
|
+
async confidentialTransferAndCall(to, amount, data, options, callbacks) {
|
|
379
|
+
const t0 = Date.now();
|
|
380
|
+
const encryptedAmount = await this.encryptAmount(amount);
|
|
381
|
+
swallow("encrypt amount", () => callbacks?.onEncryptComplete?.());
|
|
382
|
+
const totalFee = await this.getFheFee("confidentialTransferAndCall");
|
|
383
|
+
return this.executeTransaction("confidentialTransferAndCall(address,(bytes32,bytes),bytes)", [to, encryptedAmount, data], t0, { ...options, value: totalFee }, callbacks);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Transfers confidential tokens from one address to another and calls the recipient.
|
|
387
|
+
* Requires the spender to have operator approval.
|
|
388
|
+
* @param from - Source address
|
|
389
|
+
* @param to - Recipient address (must be a contract implementing the callback)
|
|
390
|
+
* @param amount - Amount to transfer
|
|
391
|
+
* @param data - Calldata for the recipient contract
|
|
392
|
+
* @param options - Transfer options (value, gas settings)
|
|
393
|
+
* @param callbacks - Optional lifecycle callbacks
|
|
394
|
+
* @returns Transfer result with tx hash and transferred amount
|
|
395
|
+
*/
|
|
396
|
+
async confidentialTransferFromAndCall(from, to, amount, data, options, callbacks) {
|
|
397
|
+
const t0 = Date.now();
|
|
398
|
+
const encryptedAmount = await this.encryptAmount(amount);
|
|
399
|
+
swallow("encrypt amount", () => callbacks?.onEncryptComplete?.());
|
|
400
|
+
const totalFee = await this.getFheFee("confidentialTransferFromAndCall");
|
|
401
|
+
return this.executeTransaction("confidentialTransferFromAndCall(address,address,(bytes32,bytes),bytes)", [from, to, encryptedAmount, data], t0, { ...options, value: totalFee }, callbacks);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/contract/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAA6B,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAyB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAsBvD,+CAA+C;AAC/C,gCAAgC;AAChC,+CAA+C;AAE/C,MAAM,OAAO,SAAS;IACX,GAAG,CAAkB;IACrB,OAAO,CAAU;IACjB,GAAG,CAAyC;IAC5C,iBAAiB,CAAoB;IAGtC,cAAc,GAA2B,IAAI,CAAC;IAEtD,YAAY,GAAoB,EAAE,OAAgB,EAAE,GAA2C;QAC7F,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAA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,EAAE,CAAC;QACtB,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACzD,OAAO,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;QAElE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC;QAEzE,OAAO,IAAI,CAAC,kBAAkB,CAC5B,wEAAwE,EACxE,CAAC,IAAI,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,EACjC,EAAE,EACF,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAC/B,SAAS,CACV,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BytesHex } from "../core/primitives.js";
|
|
2
|
+
/**
|
|
3
|
+
* Raw log entry from a blockchain transaction.
|
|
4
|
+
* Contains topics (indexed event parameters) and data (non-indexed event data).
|
|
5
|
+
*/
|
|
6
|
+
export interface RawLog {
|
|
7
|
+
/** Array of indexed event parameters as bytes32 values */
|
|
8
|
+
readonly topics: readonly BytesHex[];
|
|
9
|
+
/** Non-indexed event data as bytes */
|
|
10
|
+
readonly data: BytesHex;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Transaction receipt returned after a transaction is mined.
|
|
14
|
+
* Contains logs and other transaction metadata.
|
|
15
|
+
*/
|
|
16
|
+
export interface TransactionReceipt {
|
|
17
|
+
/** Array of logs emitted during the transaction */
|
|
18
|
+
readonly logs: readonly RawLog[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of a successful transaction.
|
|
22
|
+
* Contains the transaction hash and receipt for further inspection.
|
|
23
|
+
*/
|
|
24
|
+
export interface TransactionResult {
|
|
25
|
+
/** Transaction hash as bytes32 */
|
|
26
|
+
txHash: BytesHex;
|
|
27
|
+
/** Transaction receipt containing logs and metadata */
|
|
28
|
+
receipt: TransactionReceipt;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/contract/transaction.ts"],"names":[],"mappings":""}
|