ThierryM1212 / SAFEW

Simple And Fast Ergo Wallet
MIT License
29 stars 4 forks source link

I cannot use SAFEW wallet with my local network #34

Open swag-eag opened 1 month ago

swag-eag commented 1 month ago

Hi.

I am trying to connect SAFEW wallet to my local network (ergo.chain.addressPrefix = 96): Node 1:

Node 2:

What should I modify in the SAFEW source code to connect to this local blockchain?

Thanks

ThierryM1212 commented 1 month ago

Hello, there is no support for testnet, and so no easy switch to another network.

To build a SAFEW version for another network prefix, I would start by searching for "Mainnet" in the code, and replace it with your 96 value, the ergolib constant does not exist. The usage of "(await ergolib).Address.from_mainnet_str" needs also to be changed (frombytes ?). https://github.com/search?q=repo%3AThierryM1212%2FSAFEW%20mainnet&type=code

I hope that will be enough... let me know...

swag-eag commented 1 month ago

I have tried as you said...

Modify source code to connect to local network …/SAFEW/background/background.js Change: var nodeApi = "http://213.239.193.208:9053/"; To: var nodeApi = "http://127.0.0.1:9122/"; Change: nodeApi = local_storage['nodeAddress'] ?? "http://213.239.193.208:9053/"; To: nodeApi = local_storage['nodeAddress'] ?? "http://127.0.0.1:9122/";

…/SAFEW/src/utils/constants.js Change: url: "http://213.239.193.208:9053/", To: url: "http://127.0.0.1:9122/",

…/SAFEW/node_modules/ledger-ergo-js/dist/types/public.d.ts Change: Mainnet = 0, To: Mainnet = 96, …/SAFEW/node_modules/ergo-lib-wasm-browser/ergo_lib_wasm.d.ts Change: Mainnet, To: Mainnet = 96,

But I got this status: image

My configuration file is:

ergo {
  networkType = "mainnet"
  directory = "/home/emilio/ergo/ergo-mainnet-swa/data"

  node {
    mining = true
    offlineGeneration = true
    useExternalMiner = false
  }

  chain {
    addressPrefix = 96
    reemission {
      checkReemissionRules = true
    }
  }

  wallet {
    checkEIP27 = true
    mnemonic = "maximum market scatter fancy sleep begin more awesome defense obscure allow august forget artist solve"
  }
}

scorex {
  network {
    magicBytes = [1, 1, 8, 1]
    bindAddress = "0.0.0.0:9022"
    nodeName = "ergo-mainnet-swa"
    knownPeers = []
  }

  restApi {
    bindAddress = "127.0.0.1:9122"
    apiKeyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf"
  }
}

What am I doing wrong?

Thanks

ThierryM1212 commented 1 month ago

not sure what is not working...

At the line below: https://github.com/ThierryM1212/SAFEW/blob/1fcf4a9e28c3e61ff259d90fcd742770ad288bf6/src/ergo-related/serializer.js#L79 from_mainnet_str needs to be replaced by from_base58 to avoid the check on the mainnet prefix.