addModule method

Future<Map<String, dynamic>> addModule(
  1. String walletAddress,
  2. String disableModuleName,
  3. String disableModuleAddress,
  4. String enableModuleAddress, {
  5. String methodName = 'addModule',
  6. String network = "fuse",
  7. Map? transactionBody,
})

Implementation

Future<Map<String, dynamic>> addModule(
  String walletAddress,
  String disableModuleName,
  String disableModuleAddress,
  String enableModuleAddress, {
  String methodName = 'addModule',
  String network = "fuse",
  Map? transactionBody,
}) async {
  EthereumAddress wallet = EthereumAddress.fromHex(walletAddress);
  EthereumAddress newModule = EthereumAddress.fromHex(enableModuleAddress);
  String nonce = await getNonceForRelay();
  DeployedContract contract = await _contract(
    disableModuleName,
    disableModuleAddress,
  );
  Uint8List data = contract.function(methodName).encodeCall([
    wallet,
    newModule,
  ]);
  String encodedData = '0x' + HEX.encode(data);

  String signature = await signOffChain(
    disableModuleAddress,
    walletAddress,
    BigInt.from(0),
    encodedData,
    nonce,
    BigInt.from(0),
    BigInt.from(_defaultGasLimit),
  );

  return {
    "walletAddress": walletAddress,
    "methodData": encodedData,
    "communityAddress": _defaultCommunityContractAddress,
    "nonce": nonce,
    "network": network,
    "methodName": methodName,
    "gasPrice": 0,
    "gasLimit": _defaultGasLimit,
    "signature": signature,
    "walletModule": disableModuleName,
    "transactionBody": transactionBody,
  };
}