Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PLTF-262): zksync deploy collection fix #592

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 23 additions & 32 deletions packages/ethereum/sdk/src/nft/deploy-erc1155.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Ethereum, EthereumTransaction } from "@rarible/ethereum-provider"
import type { Address, Word } from "@rarible/types"
import type { Address } from "@rarible/types"
import { randomWord } from "@rarible/types"
import type { Maybe } from "@rarible/types/build/maybe"
import type { SendFunction } from "../common/send-transaction"
Expand All @@ -26,23 +26,19 @@ export class DeployErc1155 {
const config = await this.getConfig()
const contract = createErc1155FactoryContract(this.ethereum, config.factories.erc1155)
const salt = randomWord()
return {
tx: await this.send(
contract.functionCall("createToken", name, symbol, baseURI, contractURI, salt)
),
address: await this.getContractAddress(name, symbol, baseURI, contractURI, salt),
const tx = await this.send(
contract.functionCall("createToken", name, symbol, baseURI, contractURI, salt)
)
const events = await tx.getEvents()
const proxyEvent = events
.find(e => e.event === "Create1155RaribleProxy")
if (!proxyEvent) {
throw new Error("Event 'Create1155RaribleProxy' has not been found")
}
}

private async getContractAddress(
name: string, symbol: string, baseURI: string, contractURI: string, salt: Word
): Promise<Address> {
if (!this.ethereum) {
throw new Error("Wallet undefined")
return {
tx,
address: proxyEvent.args.proxy,
}
const config = await this.getConfig()
const contract = createErc1155FactoryContract(this.ethereum, config.factories.erc1155)
return contract.functionCall("getAddress", name, symbol, baseURI, contractURI, salt).call()
}

async deployUserToken(
Expand All @@ -54,23 +50,18 @@ export class DeployErc1155 {
const config = await this.getConfig()
const contract = createErc1155UserFactoryContract(this.ethereum, config.factories.erc1155)
const salt = randomWord()
return {
tx: await this.send(
contract.functionCall("createToken", name, symbol, baseURI, contractURI, operators, salt)
),
address: await this.getUserContractAddress(name, symbol, baseURI, contractURI, operators, salt),
const tx = await this.send(
contract.functionCall("createToken", name, symbol, baseURI, contractURI, operators, salt)
)
const events = await tx.getEvents()
const proxyEvent = events
.find(e => e.event === "Create1155RaribleUserProxy")
if (!proxyEvent) {
throw new Error("Event 'Create1155RaribleProxy' has not been found")
}
}

private async getUserContractAddress(
name: string, symbol: string, baseURI: string, contractURI: string, operators: Address[], salt: Word
): Promise<Address> {
if (!this.ethereum) {
throw new Error("Wallet undefined")
return {
tx,
address: proxyEvent.args.proxy,
}
const config = await this.getConfig()
const contract = createErc1155UserFactoryContract(this.ethereum, config.factories.erc1155)
return contract.functionCall("getAddress", name, symbol, baseURI, contractURI, operators, salt)
.call()
}
}
54 changes: 23 additions & 31 deletions packages/ethereum/sdk/src/nft/deploy-erc721.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Ethereum, EthereumTransaction } from "@rarible/ethereum-provider"
import type { Address, Word } from "@rarible/types"
import type { Address } from "@rarible/types"
import { randomWord } from "@rarible/types"
import type { Maybe } from "@rarible/types/build/maybe"
import type { SendFunction } from "../common/send-transaction"
Expand All @@ -26,23 +26,19 @@ export class DeployErc721 {
const config = await this.getConfig()
const contract = createErc721FactoryContract(this.ethereum, config.factories.erc721)
const salt = randomWord()
return {
tx: await this.send(
contract.functionCall("createToken", name, symbol, baseURI, contractURI, salt)
),
address: await this.getContractAddress(name, symbol, baseURI, contractURI, salt),
const tx = await this.send(
contract.functionCall("createToken", name, symbol, baseURI, contractURI, salt)
)
const events = await tx.getEvents()
const proxyEvent = events
.find(e => e.event === "Create721RaribleProxy")
if (!proxyEvent) {
throw new Error("Event 'Create721RaribleProxy' has not been found")
}
}

private async getContractAddress(
name: string, symbol: string, baseURI: string, contractURI: string, salt: Word
): Promise<Address> {
if (!this.ethereum) {
throw new Error("Wallet undefined")
return {
tx,
address: proxyEvent.args.proxy,
}
const config = await this.getConfig()
const contract = createErc721FactoryContract(this.ethereum, config.factories.erc721)
return contract.functionCall("getAddress", name, symbol, baseURI, contractURI, salt).call()
}

async deployUserToken(
Expand All @@ -54,22 +50,18 @@ export class DeployErc721 {
const config = await this.getConfig()
const contract = createErc721UserFactoryContract(this.ethereum, config.factories.erc721)
const salt = randomWord()
return {
tx: await this.send(
contract.functionCall("createToken", name, symbol, baseURI, contractURI, operators, salt)
),
address: await this.getUserContractAddress(name, symbol, baseURI, contractURI, operators, salt),
const tx = await this.send(
contract.functionCall("createToken", name, symbol, baseURI, contractURI, operators, salt)
)
const events = await tx.getEvents()
const proxyEvent = events
.find(e => e.event === "Create721RaribleUserProxy")
if (!proxyEvent) {
throw new Error("Event 'Create721RaribleUserProxy' has not been found")
}
}

private async getUserContractAddress(
name: string, symbol: string, baseURI: string, contractURI: string, operators: Address[], salt: Word
): Promise<Address> {
if (!this.ethereum) {
throw new Error("Wallet undefined")
return {
tx,
address: proxyEvent.args.proxy,
}
const config = await this.getConfig()
const contract = createErc721UserFactoryContract(this.ethereum, config.factories.erc721)
return contract.functionCall("getAddress", name, symbol, baseURI, contractURI, operators, salt).call()
}
}