@veridex/sdk 1.0.0-beta.3 → 1.0.0-beta.5

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/dist/index.mjs CHANGED
@@ -3852,27 +3852,42 @@ var AptosClient = class {
3852
3852
  targetChain
3853
3853
  };
3854
3854
  }
3855
+ /**
3856
+ * Get vault address from on-chain VaultRegistry.
3857
+ * Queries the get_vault_address view function which looks up the vault in the registry.
3858
+ */
3855
3859
  async getVaultAddress(userKeyHash) {
3856
3860
  try {
3857
- const vaultAddress = this.computeVaultAddressFromHash(userKeyHash);
3858
- const account = await this.client.getAccount(vaultAddress);
3859
- if (account) {
3861
+ const normalizedKeyHash = "0x" + userKeyHash.replace("0x", "").padStart(64, "0");
3862
+ const payload = {
3863
+ function: `${this.moduleAddress}::spoke::get_vault_address`,
3864
+ type_arguments: [],
3865
+ arguments: [normalizedKeyHash]
3866
+ // Pass as hex string, not byte array
3867
+ };
3868
+ const response = await this.client.view(payload);
3869
+ if (response && response.length > 0) {
3870
+ const vaultAddress = response[0];
3860
3871
  return vaultAddress;
3861
3872
  }
3862
3873
  return null;
3863
3874
  } catch (error) {
3864
- if (error?.status === 404) {
3875
+ if (error?.message?.includes("E_VAULT_NOT_FOUND") || error?.message?.includes("error code 6") || error?.status === 404) {
3865
3876
  return null;
3866
3877
  }
3867
- console.error("Error getting vault address:", error);
3878
+ console.error("Error getting vault address from registry:", error);
3868
3879
  return null;
3869
3880
  }
3870
3881
  }
3871
3882
  /**
3872
- * Compute vault address using resource account derivation
3873
- * On Aptos, vaults are derived from the module address + user key hash
3883
+ * @deprecated Use getVaultAddress() instead - this method uses incorrect address derivation.
3884
+ * On Aptos, vaults are created as named objects by the relayer, not resource accounts.
3885
+ * The vault address depends on which relayer created it, so must be queried on-chain.
3874
3886
  */
3875
3887
  computeVaultAddress(userKeyHash) {
3888
+ console.warn(
3889
+ "computeVaultAddress() is deprecated for Aptos. Use getVaultAddress() to query the on-chain VaultRegistry instead."
3890
+ );
3876
3891
  return this.computeVaultAddressFromHash(userKeyHash);
3877
3892
  }
3878
3893
  computeVaultAddressFromHash(userKeyHash) {