@palindromepay/sdk 2.0.0 → 2.0.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.
@@ -355,7 +355,7 @@ export declare class PalindromePaySDK {
355
355
  isSignatureDeadlineExpired(deadline: bigint, safetySeconds?: number): boolean;
356
356
  /**
357
357
  * Predict the wallet address for a given escrow ID (before creation)
358
- * Uses CREATE2 address computation: keccak256(0xff ++ deployer ++ salt ++ initCodeHash)
358
+ * Calls the contract's computeWalletAddress function - single source of truth
359
359
  */
360
360
  predictWalletAddress(escrowId: bigint): Promise<Address>;
361
361
  /**
@@ -671,28 +671,16 @@ class PalindromePaySDK {
671
671
  // ==========================================================================
672
672
  /**
673
673
  * Predict the wallet address for a given escrow ID (before creation)
674
- * Uses CREATE2 address computation: keccak256(0xff ++ deployer ++ salt ++ initCodeHash)
674
+ * Calls the contract's computeWalletAddress function - single source of truth
675
675
  */
676
676
  async predictWalletAddress(escrowId) {
677
- // Salt is keccak256 of the escrowId padded to 32 bytes
678
- const salt = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "uint256" }], [escrowId]));
679
- // Get wallet bytecode from the ABI JSON
680
- const walletBytecode = PalindromePayWallet_json_1.default.bytecode;
681
- // Encode constructor arguments: (address _escrowContract, uint256 _escrowId)
682
- const encodedArgs = (0, viem_1.encodeAbiParameters)([{ type: "address" }, { type: "uint256" }], [this.contractAddress, escrowId]);
683
- // initCode = bytecode + encoded constructor args
684
- const initCode = (0, viem_1.concat)([walletBytecode, encodedArgs]);
685
- const initCodeHash = (0, viem_1.keccak256)(initCode);
686
- // CREATE2 address: keccak256(0xff ++ deployer ++ salt ++ initCodeHash)[12:]
687
- const data = (0, viem_1.concat)([
688
- "0xff",
689
- this.contractAddress,
690
- salt,
691
- initCodeHash,
692
- ]);
693
- const hash = (0, viem_1.keccak256)(data);
694
- // Take the last 20 bytes (address is derived from bytes 12-31)
695
- return (0, viem_1.getAddress)(`0x${hash.slice(26)}`);
677
+ const predicted = await (0, actions_1.readContract)(this.publicClient, {
678
+ address: this.contractAddress,
679
+ abi: PalindromePay_json_1.default.abi,
680
+ functionName: "computeWalletAddress",
681
+ args: [escrowId],
682
+ });
683
+ return predicted;
696
684
  }
697
685
  // ==========================================================================
698
686
  // ESCROW DATA READING