Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
akihokurino committed May 17, 2023
1 parent 211e182 commit d61cb6b
Show file tree
Hide file tree
Showing 23 changed files with 987 additions and 16 deletions.
6 changes: 5 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ IPFS_GATEWAY=

WALLET_ADDRESS=0x1341048E3d37046Ca18A09EFB154Ea9771744f41
WALLET_SECRET=
RELAYER_SECRET=

ETHEREUM_NFT_721_ADDRESS=0xb45788Bf46F1189C66a008dAb10c2f526c3fB87c
ETHEREUM_NFT_1155_ADDRESS=0xF239EeE3a78eC18ABBB78E9b5E46758019EE5d81
Expand All @@ -33,4 +34,7 @@ BUYER_ADDRESS=0x0E91D6613a84d7C8b72a289D8b275AF7717C3d2E
BUYER_SECRET=
NFT_MARKET_OWNER_SECRET=

POLYGON_NFT_MARKET_ADDRESS=0x0E436C0a80ef25D241846b3623E9FE45adD2C5F5
POLYGON_NFT_MARKET_ADDRESS=0x0E436C0a80ef25D241846b3623E9FE45adD2C5F5

POLYGON_META_TRANSACTION_WALLET_ADDRESS=0x814D6920bd6A822d208A1432857d4462549b9B76
POLYGON_META_TRANSACTIONAL_NFT_721_ADDRESS=0xed33883F60dE0adF0F337B1143b49D04720D8a55
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ mint: build
--amount $(AMOUNT) \
--package $(PACKAGE)

meta-mint: build
./target/debug/cli \
--command mint \
--contract meta-transaction-wallet \
--network $(NETWORK) \
--content-hash $(CONTENT_HASH) \
--package $(PACKAGE) \
--to-address "0x1341048E3d37046Ca18A09EFB154Ea9771744f41"

transfer: build
./target/debug/cli \
--command transfer \
Expand Down Expand Up @@ -148,4 +157,7 @@ extract-abi:
cat ethereum/artifacts/contracts/Sbt721.sol/Sbt721.json | jq '.abi' > impl_ethers_rs/src/sbt_721/abi.json
cat ethereum/artifacts/contracts/Sbt721.sol/Sbt721.json | jq '.bytecode' > impl_ethers_rs/src/sbt_721/bin

cat ethereum/artifacts/contracts/NftMarket.sol/NftMarket.json | jq '.abi' > impl_ethers_rs/src/nft_market/abi.json
cat ethereum/artifacts/contracts/NftMarket.sol/NftMarket.json | jq '.abi' > impl_ethers_rs/src/nft_market/abi.json

cat ethereum/artifacts/contracts/MetaTransactionWallet.sol/MetaTransactionWallet.json | jq '.abi' > impl_ethers_rs/src/meta_transaction_wallet/mtw_abi.json
cat ethereum/artifacts/contracts/MetaTransactionWallet.sol/MetaTransactionalNft721.json | jq '.abi' > impl_ethers_rs/src/meta_transaction_wallet/nft_abi.json
8 changes: 8 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum Contract {
Sbt721,
RevealNft721,
NftMarket,
MetaTransactionWallet,
}

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -166,6 +167,12 @@ async fn execute(args: Args) -> CliResult<()> {
.await
.map_err(Error::from)
}
Contract::MetaTransactionWallet => {
let cli = impl_ethers_rs::meta_transaction_wallet::client::Client::new(network);
cli.mint(to_address, args.content_hash.clone())
.await
.map_err(Error::from)
}
_ => return Err(Error::Internal("invalid params".to_string())),
},
Package::RustWeb3 => match args.contract {
Expand Down Expand Up @@ -283,6 +290,7 @@ async fn execute(args: Args) -> CliResult<()> {
}
Ok(())
}
_ => return Err(Error::Internal("invalid params".to_string())),
},
Package::RustWeb3 => match args.contract {
Contract::Nft721 => {
Expand Down
1 change: 1 addition & 0 deletions ethereum/.env.default
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
WALLET_SECRET=
WALLET_MNEMONIC=
RELAYER_SECRET=

GOERLI_CHAIN_URL=
MUMBAI_CHAIN_URL=
Expand Down
5 changes: 4 additions & 1 deletion ethereum/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ deploy-upgradeable-nft-721-v2:
npx hardhat run scripts/deploy-upgradeable-nft-721-v2.ts --network $(NETWORK)

deploy-nft-market:
npx hardhat run scripts/deploy-nft-market.ts --network $(NETWORK)
npx hardhat run scripts/deploy-nft-market.ts --network $(NETWORK)

deploy-meta-transaction-wallet:
npx hardhat run scripts/deploy-meta-transaction-wallet.ts --network $(NETWORK)
1 change: 0 additions & 1 deletion ethereum/contracts/MetaTransactionWallet.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/metatx/MinimalForwarder.sol
// https://github.com/dea-sg/meta-tx/blob/main/contracts/metatx/ForwarderUpgradeable.sol
// https://github.com/dea-sg/meta-tx/blob/main/test/forward.ts
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
Expand Down
6 changes: 3 additions & 3 deletions ethereum/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ const config: HardhatUserConfig = {
},
goerli: {
url: process.env.GOERLI_CHAIN_URL!,
accounts: [process.env.WALLET_SECRET!],
accounts: [process.env.WALLET_SECRET!, process.env.RELAYER_SECRET!],
chainId: chainIds.goerli,
},
mumbai: {
url: process.env.MUMBAI_CHAIN_URL!,
accounts: [process.env.WALLET_SECRET!],
accounts: [process.env.WALLET_SECRET!, process.env.RELAYER_SECRET!],
chainId: chainIds.mumbai,
},
fuji: {
url: process.env.FUJI_CHAIN_URL!,
accounts: [process.env.WALLET_SECRET!],
accounts: [process.env.WALLET_SECRET!, process.env.RELAYER_SECRET!],
chainId: chainIds.fuji,
},
},
Expand Down
37 changes: 37 additions & 0 deletions ethereum/scripts/deploy-meta-transaction-wallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ethers, upgrades } from "hardhat";
import { HardhatRuntimeEnvironment } from "hardhat/types";

async function main(hre: HardhatRuntimeEnvironment) {
const relayer = ethers.provider.getSigner(1);

const wallet = await upgrades.deployProxy(
await ethers.getContractFactory("MetaTransactionWallet", {}),
[await relayer.getAddress()]
);
console.log("deployed wallet to:", wallet.address);

const receipt1 = await wallet.deployTransaction.wait();
await ethers.provider.waitForTransaction(receipt1.transactionHash, 5);
await hre.run("verify:verify", {
address: wallet.address,
});

const NftContract = await ethers.getContractFactory(
"MetaTransactionalNft721"
);
const nft = await NftContract.deploy(wallet.address);
await nft.deployed();
console.log("deployed nft to:", nft.address);

const receipt2 = await nft.deployTransaction.wait();
await ethers.provider.waitForTransaction(receipt2.transactionHash, 5);
await hre.run("verify:verify", {
address: nft.address,
constructorArguments: [wallet.address],
});
}

main(require("hardhat")).catch((error) => {
console.error(error);
process.exitCode = 1;
});
Empty file.
5 changes: 3 additions & 2 deletions ethereum/test/MetaTransactionWallet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/dea-sg/meta-tx/blob/main/test/forward.ts
import {
SignTypedDataVersion,
TypedMessage,
Expand Down Expand Up @@ -99,7 +100,7 @@ describe("MetaTransactionWallet", () => {
it("should execute meta transaction", async () => {
const value = 1000000000;
const dist = await destination.getAddress();
const nonce = await wallet.getNonce(await relay.getAddress());
const nonce = await wallet.getNonce(userWallet.address);

const message: Message = {
from: userWallet.address,
Expand Down Expand Up @@ -128,7 +129,7 @@ describe("MetaTransactionWallet", () => {
});

it("should mint nft through the meta transaction", async () => {
const nonce = await wallet.getNonce(await relay.getAddress());
const nonce = await wallet.getNonce(userWallet.address);
const contentHash = "A";

const data = nft.interface.encodeFunctionData("mint", [
Expand Down
2 changes: 1 addition & 1 deletion impl_ethers_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
prelude = { path = "../prelude" }
ethers = { version = "2.0.4", features = ["legacy"] }
ethers = { version = "2.0.4", features = ["legacy", "eip712"] }
ethers-signers = "2.0.4"
ethers-providers = { version = "2.0.4", features = ["ws"] }
thiserror = "1.0.24"
Expand Down
1 change: 1 addition & 0 deletions impl_ethers_rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::str::FromStr;
use std::sync::Arc;

pub mod event;
pub mod meta_transaction_wallet;
pub mod nft_1155;
pub mod nft_721;
pub mod nft_market;
Expand Down
1 change: 1 addition & 0 deletions impl_ethers_rs/src/meta_transaction_wallet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod client;
Loading

0 comments on commit d61cb6b

Please sign in to comment.