Skip to content

Commit

Permalink
Merge pull request #37 from decentraland/fix/polygon-issues
Browse files Browse the repository at this point in the history
feat: fix some Polygon logic issues
  • Loading branch information
juanmahidalgo authored Jul 14, 2024
2 parents d4d4d00 + 3f2c4e8 commit 7e10d7e
Show file tree
Hide file tree
Showing 17 changed files with 525 additions and 18 deletions.
245 changes: 245 additions & 0 deletions abi/polygon/CollectionManager.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
[
{
"inputs": [
{ "internalType": "address", "name": "_owner", "type": "address" },
{ "internalType": "contract IERC20", "name": "_acceptedToken", "type": "address" },
{ "internalType": "address", "name": "_committee", "type": "address" },
{ "internalType": "address", "name": "_feesCollector", "type": "address" },
{ "internalType": "contract IRarities", "name": "_rarities", "type": "address" },
{ "internalType": "bytes4[]", "name": "_committeeMethods", "type": "bytes4[]" },
{ "internalType": "bool[]", "name": "_committeeValues", "type": "bool[]" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "contract IERC20", "name": "_oldAcceptedToken", "type": "address" },
{ "indexed": true, "internalType": "contract IERC20", "name": "_newAcceptedToken", "type": "address" }
],
"name": "AcceptedTokenSet",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "bytes4", "name": "_method", "type": "bytes4" },
{ "indexed": false, "internalType": "bool", "name": "_isAllowed", "type": "bool" }
],
"name": "CommitteeMethodSet",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "_oldCommittee", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "_newCommittee", "type": "address" }
],
"name": "CommitteeSet",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "_oldFeesCollector", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "_newFeesCollector", "type": "address" }
],
"name": "FeesCollectorSet",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": false, "internalType": "address", "name": "userAddress", "type": "address" },
{ "indexed": false, "internalType": "address", "name": "relayerAddress", "type": "address" },
{ "indexed": false, "internalType": "bytes", "name": "functionSignature", "type": "bytes" }
],
"name": "MetaTransactionExecuted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "contract IRarities", "name": "_oldRarities", "type": "address" },
{ "indexed": true, "internalType": "contract IRarities", "name": "_newRarities", "type": "address" }
],
"name": "RaritiesSet",
"type": "event"
},
{
"inputs": [],
"name": "acceptedToken",
"outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "bytes4", "name": "", "type": "bytes4" }],
"name": "allowedCommitteeMethods",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "committee",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "contract IForwarder", "name": "_forwarder", "type": "address" },
{ "internalType": "contract IERC721CollectionFactoryV2", "name": "_factory", "type": "address" },
{ "internalType": "bytes32", "name": "_salt", "type": "bytes32" },
{ "internalType": "string", "name": "_name", "type": "string" },
{ "internalType": "string", "name": "_symbol", "type": "string" },
{ "internalType": "string", "name": "_baseURI", "type": "string" },
{ "internalType": "address", "name": "_creator", "type": "address" },
{
"components": [
{ "internalType": "string", "name": "rarity", "type": "string" },
{ "internalType": "uint256", "name": "price", "type": "uint256" },
{ "internalType": "address", "name": "beneficiary", "type": "address" },
{ "internalType": "string", "name": "metadata", "type": "string" }
],
"internalType": "struct IERC721CollectionV2.ItemParam[]",
"name": "_items",
"type": "tuple[]"
}
],
"name": "createCollection",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "domainSeparator",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "userAddress", "type": "address" },
{ "internalType": "bytes", "name": "functionSignature", "type": "bytes" },
{ "internalType": "bytes32", "name": "sigR", "type": "bytes32" },
{ "internalType": "bytes32", "name": "sigS", "type": "bytes32" },
{ "internalType": "uint8", "name": "sigV", "type": "uint8" }
],
"name": "executeMetaTransaction",
"outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "feesCollector",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getChainId",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "user", "type": "address" }],
"name": "getNonce",
"outputs": [{ "internalType": "uint256", "name": "nonce", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "contract IForwarder", "name": "_forwarder", "type": "address" },
{ "internalType": "contract IERC721CollectionV2", "name": "_collection", "type": "address" },
{ "internalType": "bytes", "name": "_data", "type": "bytes" }
],
"name": "manageCollection",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pricePerItem",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "rarities",
"outputs": [{ "internalType": "contract IRarities", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{ "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [{ "internalType": "contract IERC20", "name": "_newAcceptedToken", "type": "address" }],
"name": "setAcceptedToken",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "_newCommittee", "type": "address" }],
"name": "setCommittee",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "bytes4[]", "name": "_methods", "type": "bytes4[]" },
{ "internalType": "bool[]", "name": "_values", "type": "bool[]" }
],
"name": "setCommitteeMethods",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "_newFeesCollector", "type": "address" }],
"name": "setFeesCollector",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "contract IRarities", "name": "_newRarities", "type": "address" }],
"name": "setRarities",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
17 changes: 17 additions & 0 deletions db/migrations/1720782180337-Data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = class Data1720782180337 {
name = 'Data1720782180337'

async up(db) {
await db.query(`ALTER TABLE "nft" DROP COLUMN "contract_address"`)
await db.query(`ALTER TABLE "nft" ADD "contract_address" text NOT NULL`)
await db.query(`ALTER TABLE "sale" DROP COLUMN "search_contract_address"`)
await db.query(`ALTER TABLE "sale" ADD "search_contract_address" text NOT NULL`)
}

async down(db) {
await db.query(`ALTER TABLE "nft" ADD "contract_address" bytea NOT NULL`)
await db.query(`ALTER TABLE "nft" DROP COLUMN "contract_address"`)
await db.query(`ALTER TABLE "sale" ADD "search_contract_address" bytea NOT NULL`)
await db.query(`ALTER TABLE "sale" DROP COLUMN "search_contract_address"`)
}
}
4 changes: 2 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ type Data @entity {
type NFT @entity {
id: ID!
tokenId: BigInt!
contractAddress: Bytes!
contractAddress: String!
category: Category!
owner: Account!
tokenURI: String
Expand Down Expand Up @@ -351,7 +351,7 @@ type Sale @entity {

# search
searchTokenId: BigInt!
searchContractAddress: Bytes!
searchContractAddress: String!
searchCategory: String!

## collections subgraph fields
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function getNetwork(network: Network): string {
const chainId =
network === Network.ETHEREUM
? process.env.ETHEREUM_CHAIN_ID
: process.env.MATIC_CHAIN_ID;
: process.env.POLYGON_CHAIN_ID;
const chainName =
network === Network.ETHEREUM
? chainId === ChainId.ETHEREUM_MAINNET.toString()
Expand Down
2 changes: 1 addition & 1 deletion src/eth/handlers/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function handleTransfer(

nft.tokenId = tokenId;
nft.owner = toAccount;
nft.contractAddress = Buffer.from(contractAddress.slice(2), "hex");
nft.contractAddress = contractAddress;
nft.category = category as Category;
nft.updatedAt = timestamp;
nft.soldAt = null;
Expand Down
6 changes: 3 additions & 3 deletions src/model/generated/nft.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, BigIntColumn as BigIntColumn_, BytesColumn as BytesColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, OneToMany as OneToMany_, OneToOne as OneToOne_, JoinColumn as JoinColumn_, IntColumn as IntColumn_, BooleanColumn as BooleanColumn_} from "@subsquid/typeorm-store"
import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, BigIntColumn as BigIntColumn_, StringColumn as StringColumn_, ManyToOne as ManyToOne_, Index as Index_, OneToMany as OneToMany_, OneToOne as OneToOne_, JoinColumn as JoinColumn_, IntColumn as IntColumn_, BooleanColumn as BooleanColumn_} from "@subsquid/typeorm-store"
import {Category} from "./_category"
import {Account} from "./account.model"
import {Order} from "./order.model"
Expand Down Expand Up @@ -29,8 +29,8 @@ export class NFT {
@BigIntColumn_({nullable: false})
tokenId!: bigint

@BytesColumn_({nullable: false})
contractAddress!: Uint8Array
@StringColumn_({nullable: false})
contractAddress!: string

@Column_("varchar", {length: 8, nullable: false})
category!: Category
Expand Down
4 changes: 2 additions & 2 deletions src/model/generated/sale.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class Sale {
@BigIntColumn_({nullable: false})
searchTokenId!: bigint

@BytesColumn_({nullable: false})
searchContractAddress!: Uint8Array
@StringColumn_({nullable: false})
searchContractAddress!: string

@StringColumn_({nullable: false})
searchCategory!: string
Expand Down
Loading

0 comments on commit 7e10d7e

Please sign in to comment.