Skip to content

Commit

Permalink
Other improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
perekopskiy committed Jun 10, 2021
1 parent 216c0a4 commit c5007a6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
15 changes: 8 additions & 7 deletions core/lib/storage/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Built-in deps
use std::time::Instant;
// External imports

// Workspace imports
use zksync_types::Address;
// Local imports
use self::records::ServerConfig;
use crate::{QueryResult, StorageProcessor};
Expand Down Expand Up @@ -31,19 +31,20 @@ impl<'a, 'c> ConfigSchema<'a, 'c> {

// Stores the server configuration for tests.
#[doc(hidden)]
#[allow(dead_code)]
pub(crate) async fn store_config(
&mut self,
contract_addr: &str,
gov_contract_addr: &str,
nft_factory_addr: &str,
contract_addr: Address,
gov_contract_addr: Address,
nft_factory_addr: Address,
) -> QueryResult<()> {
let start = Instant::now();

sqlx::query!(
"INSERT INTO server_config (contract_addr, gov_contract_addr, nft_factory_addr) VALUES ($1, $2, $3)",
contract_addr,
gov_contract_addr,
nft_factory_addr
&format!("{:?}", contract_addr),
&format!("{:?}", gov_contract_addr),
&format!("{:?}", nft_factory_addr)
)
.execute(self.0.conn())
.await?;
Expand Down
10 changes: 7 additions & 3 deletions core/lib/storage/src/tests/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,15 @@ async fn test_nfts_with_factories(mut storage: StorageProcessor<'_>) -> QueryRes
.apply_storage_account_diff(diff)
.await?;

let default_factory_address_str = "1111111111111111111111111111111111111111";
let default_factory_address = Address::from_str(default_factory_address_str).unwrap();
let default_factory_address =
Address::from_str("1111111111111111111111111111111111111111").unwrap();
storage
.config_schema()
.store_config("", "", &format!("0x{}", default_factory_address_str))
.store_config(
Default::default(),
Default::default(),
default_factory_address,
)
.await?;

let token_id = TokenId(token_id as u32);
Expand Down
2 changes: 1 addition & 1 deletion core/lib/types/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl NFT {
}
}

// TODO: move this file to `api_types` crate (ZKD-67)
// TODO: move this struct to `api_types` crate (ZKD-67)
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct ApiNFT {
pub id: TokenId,
Expand Down
4 changes: 2 additions & 2 deletions sdk/zksync.js/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
TransactionReceipt,
TxEthSignature,
TxEthSignatureVariant,
NFTWithFactories
NFTInfo
} from './types';
import { isTokenETH, sleep, TokenSet, isNFT } from './utils';
import {
Expand Down Expand Up @@ -180,7 +180,7 @@ export class Provider {
return await this.transport.request('get_eth_tx_for_withdrawal', [withdrawal_hash]);
}

async getNFT(id: number): Promise<NFTWithFactories> {
async getNFT(id: number): Promise<NFTInfo> {
const nft = await this.transport.request('get_nft', [id]);

// If the NFT does not exist, throw an exception
Expand Down
2 changes: 1 addition & 1 deletion sdk/zksync.js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface NFT {
contentHash: string;
}

export interface NFTWithFactories {
export interface NFTInfo {
id: number;
symbol: string;
creatorId: number;
Expand Down

0 comments on commit c5007a6

Please sign in to comment.