CoinEntity.fromJson constructor
CoinEntity.fromJson( - Map json
)
Implementation
factory CoinEntity.fromJson(Map json) {
return switch (json) {
{
'name': String name,
'symbol': String symbol,
'decimals': int decimals,
'chainID': int chainID,
'contractAddress': String contractAddress,
} =>
ERC20Entity(
name: name,
symbol: symbol,
decimals: decimals,
chainID: chainID,
contractAddress: contractAddress,
allowDeletion: json['allowDeletion'] ?? true,
),
{
"name": String name,
"symbol": String symbol,
"contractAddress": String contractAddress,
"tokenId": String tokenId,
"chainID": int chainID,
} =>
ERC1155Entity(
name: name,
symbol: symbol,
contractAddress: contractAddress,
tokenId: BigInt.parse(tokenId),
chainID: chainID,
allowDeletion: json['allowDeletion'] ?? true,
),
{
'name': String name,
'symbol': String symbol,
'decimals': int decimals,
'chainID': int chainID,
} =>
EvmCoinEntity(
name: name,
symbol: symbol,
decimals: decimals,
chainID: chainID,
),
{
'name': String name,
'symbol': String symbol,
'decimals': int decimals,
} =>
CoinEntity(
name: name,
symbol: symbol,
decimals: decimals,
),
_ => throw Exception("Invalid TokenEntity JSON"),
};
}