Skip to content

Commit

Permalink
Merge pull request #1624 from matter-labs/lyova-fix-nft-decimals
Browse files Browse the repository at this point in the history
NFTs now have 0 decimals
  • Loading branch information
Deniallugo authored May 24, 2021
2 parents b791a26 + 1b23e1e commit 561ae27
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/lib/storage/src/chain/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl<'a, 'c> StateSchema<'a, 'c> {
upd.token_id,
address,
upd.symbol,
1
0
)
.execute(self.0.conn())
.await?;
Expand Down
6 changes: 3 additions & 3 deletions core/lib/types/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ impl Token {
}
}

pub fn new_nft(id: TokenId, address: Address, symbol: &str, decimals: u8) -> Self {
pub fn new_nft(id: TokenId, symbol: &str) -> Self {
Self {
id,
address,
address: Default::default(),
symbol: symbol.to_string(),
decimals,
decimals: 0,
is_nft: true,
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/tests/ts-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"license": "MIT",
"mocha": {
"timeout": 240000,
"timeout": 300000,
"exit": true,
"color": false,
"slow": 0,
Expand Down
8 changes: 4 additions & 4 deletions core/tests/ts-tests/tests/mint-nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Tester.prototype.testMintNFT = async function (

expect(balanceBefore.sub(balanceAfter).eq(fee), 'Wrong amount in wallet after withdraw').to.be.true;
const state = await receiver.getAccountState();
const nft: any = Object.values(state.committed.nfts)[0];
expect(nft !== undefined);
const nft = Object.values(state.committed.nfts)[0];
expect(nft).to.exist;
expect(nft.contentHash).eq(utils.hexlify(contentHash));

return nft;
Expand All @@ -70,9 +70,9 @@ Tester.prototype.testGetNFT = async function (wallet: Wallet, feeToken: TokenLik
await handle.awaitReceipt();
this.runningFee = this.runningFee.add(fee);
const state = await wallet.getAccountState();
const nft: any = Object.values(state.committed.nfts)[0];
const nft = Object.values(state.committed.nfts)[0];
const nft1 = await wallet.provider.getNFT(nft.id);
expect(nft1).eq(null, ' NFT does not exist yet');
expect(nft1).eq(null, 'NFT does not exist yet');
await handle.awaitVerifyReceipt();
const nft2 = await wallet.provider.getNFT(nft.id);
expect(nft2.id).eq(nft.id);
Expand Down
3 changes: 1 addition & 2 deletions sdk/zksync-rs/src/operations/transfer_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ where
}
};

// Address is not used in signing, thus default can be passed to the constructor.
let nft_token = Token::new_nft(nft.id, Address::default(), &nft.symbol, 1);
let nft_token = Token::new_nft(nft.id, &nft.symbol);
let (tx_nft, tx_nft_signature) = self
.wallet
.signer
Expand Down
2 changes: 1 addition & 1 deletion sdk/zksync.js/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class TokenSet {

public resolveTokenDecimals(tokenLike: TokenOrId): number {
if (isNFT(tokenLike)) {
return 1;
return 0;
}
return this.resolveTokenObject(tokenLike).decimals;
}
Expand Down

0 comments on commit 561ae27

Please sign in to comment.