import {
  CoinNetworkConfigQueryParam,
  CoinNetworkConfigPageResult,
  CoinNetworkConfigItem,
  CoinNetworkConfigFormData
} from '@/types/api/system/coinNetworkConfig';
import request from '@/utils/request';
import { AxiosPromise } from 'axios';

export function queryCoinNetworkConfig(data: CoinNetworkConfigQueryParam): AxiosPromise<CoinNetworkConfigPageResult> {
  return request({
    url: 'admin/system/coin-network-config/page-query',
    method: 'post',
    params: data
  });
}

export function addCoinNetworkConfig(data: CoinNetworkConfigFormData): any {
  return request({
    url: 'admin/system/coin-network-config/create',
    method: 'post',
    params: data
  });
}

export function updateCoinNetworkConfig(data: CoinNetworkConfigFormData): any {
  return request({
    url: 'admin/system/coin-network-config/update',
    method: 'post',
    params: data
  });
}

export function deleteCoinNetworkConfig(id: number): any {
  return request({
    url: 'admin/system/coin-network-config/delete',
    method: 'post',
    params: { id }
  });
}

/** 指定主网下可配置的子币种（parent_coin_name 不为空且未配置） */
export function getAvailableCoinsForNetwork(
  networkId: number,
  includeCoinName?: string
): AxiosPromise<string[]> {
  return request({
    url: 'admin/system/coin-network-config/available-coins',
    method: 'post',
    params: { networkId, includeCoinName }
  });
}
