safe-core-sdk icon indicating copy to clipboard operation
safe-core-sdk copied to clipboard

Cannot propose transaction in browser environment

Open milli-xpn opened this issue 1 year ago • 1 comments

Description

I am running into an issue where I cannot propose a transaction through the safe-core-sdk and safe-service-client when running this code in our react application in the browser.

I am constructing a multisig transaction with the relevant libraries following this guide

When it comes to calling proposeTransaction my application will throw with error createKeccakHash is not a function.

Environment

  • Safe Core SDK version: ^3.2.0
  • Safe contract version: ?
  • Environment:
    • browser

Steps to reproduce

Following the stack trace, this comes from the following:

  • SafeServiceClient.proposeTransaction calls a method getEip3770Address which calls validateEip3770Address from the safe-core-sdk-utils which then calls validateEthereumAddress which uses the package web3-utils isAddress method which has a dependency on node cryptography libraries which do not exist in the browser.

To get around this problem temporarily, I have patched the library to bypass the validation here and the proposal is able to go through.

I have not found a way to polyfil this and get this to work in the browser without patching. I am using webpack as my bundler.

Expected result

To be able to propose and execute a transaction using safe-core-sdk libraries in react/browser code.

milli-xpn avatar Jan 13 '23 05:01 milli-xpn