deleteKey method

Future<BlockchainResponse> deleteKey({
  1. required String accountId,
  2. required String deletedPublicKey,
  3. required String privateKey,
  4. required String publicKey,
})

Implementation

Future<BlockchainResponse> deleteKey({
  required String accountId,
  required String deletedPublicKey,
  required String privateKey,
  required String publicKey,
}) async {
  final transactionInfo = await getTransactionInfo(
    accountId: accountId,
    publicKey: publicKey,
  );
  final gas = BlockchainGas.gas[BlockChains.near];
  if (gas == null) {
    throw Exception('Incorrect Blockchain Gas');
  }

  final List<Map<String, dynamic>> actions = [
    {
      "type": "deleteKey",
      "data": {
        "publicKey": deletedPublicKey,
      },
    },
  ];

  final signedAction = await signNearActions(
    fromAddress: accountId,
    toAddress: accountId,
    transferAmount: "0",
    privateKey: privateKey,
    gas: gas,
    nonce: transactionInfo.nonce,
    blockHash: transactionInfo.blockHash,
    actions: actions,
  );
  final res = await nearRpcClient.sendSyncTx([signedAction]);
  return res;
}