Correct decimal data type

This was already correct in terra and eth but wrong in the design doc and solana

Change-Id: I6e3fcf710d81f3cb56868ff7ab73fb3aba1d95bf
This commit is contained in:
Hendrik Hofstadt 2021-07-19 12:34:54 +02:00
parent af4e29978d
commit 8f4ed821ab
5 changed files with 10 additions and 15 deletions

View File

@ -136,8 +136,8 @@ PayloadID uint8 = 2
TokenAddress [32]uint8
// Chain ID of the token
TokenChain uint16
// Number of decimals of the token (big-endian uint256)
Decimals [32]uint8
// Number of decimals of the token
Decimals uint8
// Symbol of the token (UTF-8)
Symbol [32]uint8
// Name of the token (UTF-8)

View File

@ -75,7 +75,7 @@ pub fn attest_token(
let payload = PayloadAssetMeta {
token_address: accs.mint.info().key.to_bytes(),
token_chain: 1,
decimals: U256::from(accs.mint.decimals),
decimals: accs.mint.decimals,
symbol: "".to_string(), // TODO metadata
name: "".to_string(),
};

View File

@ -431,7 +431,7 @@ pub fn attest(
let payload = PayloadAssetMeta {
token_address: mint.to_bytes(),
token_chain: 1,
decimals: U256::from(mint_data.decimals),
decimals: mint_data.decimals,
symbol: "".to_string(), // TODO metadata
name: "".to_string(),
};

View File

@ -94,8 +94,8 @@ pub struct PayloadAssetMeta {
pub token_address: Address,
// Chain ID of the token
pub token_chain: ChainID,
// Number of decimals of the token (big-endian uint256)
pub decimals: U256,
// Number of decimals of the token
pub decimals: u8,
// Symbol of the token
pub symbol: String,
// Name of the token
@ -114,10 +114,7 @@ impl DeserializePayload for PayloadAssetMeta {
v.read_exact(&mut token_address)?;
let token_chain = v.read_u16::<BigEndian>()?;
let mut decimals_data: [u8; 32] = [0; 32];
v.read_exact(&mut decimals_data)?;
let decimals = U256::from_big_endian(&decimals_data);
let decimals = v.read_u8()?;
let mut symbol_data: [u8; 32] = [0; 32];
v.read_exact(&mut symbol_data)?;
@ -147,9 +144,7 @@ impl SerializePayload for PayloadAssetMeta {
writer.write(&self.token_address)?;
writer.write_u16::<BigEndian>(self.token_chain)?;
let mut decimal_data: [u8; 32] = [0; 32];
self.decimals.to_big_endian(&mut decimal_data);
writer.write(&decimal_data)?;
writer.write_u8(self.decimals)?;
let mut symbol: [u8; 32] = [0; 32];
for i in 0..self.symbol.len() {

View File

@ -138,8 +138,8 @@ impl TransferInfo {
// TokenAddress [32]uint8
// // Chain ID of the token
// TokenChain uint16
// // Number of decimals of the token (big-endian uint256)
// Decimals [32]uint8
// // Number of decimals of the token
// Decimals uint8
// // Symbol of the token (UTF-8)
// Symbol [32]uint8
// // Name of the token (UTF-8)