Update contracts

This commit is contained in:
silverpill 2021-10-21 11:54:24 +00:00
parent 486c819bc3
commit a9fb874cb3
6 changed files with 627 additions and 163 deletions

View file

@ -17,7 +17,7 @@ ethereum_json_rpc_url: 'http://127.0.0.1:8545'
# Block explorer base URL (must be compatible with https://eips.ethereum.org/EIPS/eip-3091)
ethereum_explorer_url: null
ethereum_contract:
address: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512'
address: '0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0'
chain_id: 31337
signing_key: null

188
contracts/Manager.json Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -29,7 +29,7 @@ use super::utils::{
};
pub const COLLECTIBLE: &str = "Collectible";
pub const MINTER: &str = "Minter";
pub const MANAGER: &str = "Manager";
const TOKEN_WAIT_TIME: i64 = 10; // in minutes
#[derive(thiserror::Error, Debug)]
@ -93,15 +93,18 @@ pub async fn get_nft_contract(
let ethereum_config = config.ethereum_contract.as_ref()
.ok_or(EthereumError::ImproperlyConfigured)?;
let minter_abi = load_abi(&config.contract_dir, MINTER)?;
let minter_address = parse_address(&ethereum_config.address)?;
let minter = Contract::from_json(
let manager_abi = load_abi(&config.contract_dir, MANAGER)?;
let manager_address = parse_address(&ethereum_config.address)?;
let manager = Contract::from_json(
web3.eth(),
minter_address,
&minter_abi,
manager_address,
&manager_abi,
)?;
let token_address = minter.query("token", (), None, Options::default(), None).await?;
let token_address = manager.query(
"collectible",
(), None, Options::default(), None,
).await?;
let token_abi = load_abi(&config.contract_dir, COLLECTIBLE)?;
let token = Contract::from_json(
web3.eth(),
@ -206,8 +209,10 @@ pub async fn process_events(
// Mint event found
let token_id_u256 = transfer.token_id.into_uint()
.ok_or(EthereumError::ConversionError)?;
let token_uri_result = contract.query("tokenURI", (token_id_u256,), None, Options::default(), None);
let token_uri: String = token_uri_result.await?;
let token_uri: String = contract.query(
"tokenURI", (token_id_u256,),
None, Options::default(), None,
).await?;
let tx_id_h256 = transfer.tx_id.ok_or(EthereumError::ConversionError)?;
let tx_id = hex::encode(tx_id_h256.as_bytes());
let ipfs_cid = parse_ipfs_url(&token_uri)

View file

@ -1,7 +1,7 @@
use serde::Serialize;
use crate::config::Config;
use crate::ethereum::nft::MINTER;
use crate::ethereum::nft::MANAGER;
#[derive(Serialize)]
pub struct Instance {
@ -31,7 +31,7 @@ impl From<&Config> for Instance {
login_message: config.login_message.clone(),
ethereum_explorer_url: config.ethereum_explorer_url.clone(),
nft_contract_name: config.ethereum_contract.as_ref()
.and(Some(MINTER.into())),
.and(Some(MANAGER.into())),
nft_contract_address: config.ethereum_contract.as_ref()
.map(|val| val.address.clone()),
ipfs_gateway_url: config.ipfs_gateway_url.clone(),