Skip to content

Commit 8da51c8

Browse files
committed
add missing methods for erc721Items
1 parent 9184386 commit 8da51c8

36 files changed

+6078
-0
lines changed

src/constants/abis/erc721Items.json

Lines changed: 1001 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import type { FastifyInstance } from 'fastify'
2+
3+
import { erc721ItemsApprove } from './write/approve'
4+
import { erc721ItemsBatchBurn } from './write/batchBurn'
5+
import { erc721ItemsBurn } from './write/burn'
6+
import { erc721ItemsGrantRole } from './write/grantRole'
7+
import { erc721ItemsInitialize } from './write/initialize'
8+
import { erc721ItemsMint } from './write/mint'
9+
import { erc721ItemsMintSequential } from './write/mintSequential'
10+
import { erc721ItemsRenounceRole } from './write/renounceRole'
11+
import { erc721ItemsRevokeRole } from './write/revokeRole'
12+
import { erc721ItemsSafeTransferFrom_1 } from './write/safeTransferFrom_1'
13+
import { erc721ItemsSafeTransferFrom_2 } from './write/safeTransferFrom_2'
14+
import { erc721ItemsSetApprovalForAll } from './write/setApprovalForAll'
15+
import { erc721ItemsSetBaseMetadataURI } from './write/setBaseMetadataURI'
16+
import { erc721ItemsSetContractURI } from './write/setContractURI'
17+
import { erc721ItemsSetDefaultRoyalty } from './write/setDefaultRoyalty'
18+
import { erc721ItemsSetImplicitModeProjectId } from './write/setImplicitModeProjectId'
19+
import { erc721ItemsSetImplicitModeValidator } from './write/setImplicitModeValidator'
20+
import { erc721ItemsSetNameAndSymbol } from './write/setNameAndSymbol'
21+
import { erc721ItemsSetTokenRoyalty } from './write/setTokenRoyalty'
22+
import { erc721ItemsTransferFrom } from './write/transferFrom'
23+
import { erc721ItemsDEFAULT_ADMIN_ROLE } from './read/DEFAULT_ADMIN_ROLE'
24+
import { erc721ItemsAcceptImplicitRequest } from './read/acceptImplicitRequest'
25+
import { erc721ItemsBalanceOf } from './read/balanceOf'
26+
import { erc721ItemsContractURI } from './read/contractURI'
27+
import { erc721ItemsGetApproved } from './read/getApproved'
28+
import { erc721ItemsGetRoleAdmin } from './read/getRoleAdmin'
29+
import { erc721ItemsGetRoleMember } from './read/getRoleMember'
30+
import { erc721ItemsGetRoleMemberCount } from './read/getRoleMemberCount'
31+
import { erc721ItemsHasRole } from './read/hasRole'
32+
import { erc721ItemsIsApprovedForAll } from './read/isApprovedForAll'
33+
import { erc721ItemsName } from './read/name'
34+
import { erc721ItemsOwnerOf } from './read/ownerOf'
35+
import { erc721ItemsRoyaltyInfo } from './read/royaltyInfo'
36+
import { erc721ItemsSupportsInterface } from './read/supportsInterface'
37+
import { erc721ItemsSymbol } from './read/symbol'
38+
import { erc721ItemsTokenURI } from './read/tokenURI'
39+
import { erc721ItemsTotalSupply } from './read/totalSupply'
40+
41+
export function registerErc721ItemsRoutes(fastify: FastifyInstance) {
42+
erc721ItemsApprove(fastify)
43+
erc721ItemsGrantRole(fastify)
44+
erc721ItemsMintSequential(fastify)
45+
erc721ItemsRenounceRole(fastify)
46+
erc721ItemsRevokeRole(fastify)
47+
erc721ItemsSafeTransferFrom_1(fastify)
48+
erc721ItemsSafeTransferFrom_2(fastify)
49+
erc721ItemsSetApprovalForAll(fastify)
50+
erc721ItemsSetBaseMetadataURI(fastify)
51+
erc721ItemsSetContractURI(fastify)
52+
erc721ItemsSetDefaultRoyalty(fastify)
53+
erc721ItemsSetImplicitModeProjectId(fastify)
54+
erc721ItemsSetImplicitModeValidator(fastify)
55+
erc721ItemsSetNameAndSymbol(fastify)
56+
erc721ItemsSetTokenRoyalty(fastify)
57+
erc721ItemsTransferFrom(fastify)
58+
erc721ItemsDEFAULT_ADMIN_ROLE(fastify)
59+
erc721ItemsAcceptImplicitRequest(fastify)
60+
erc721ItemsBalanceOf(fastify)
61+
erc721ItemsContractURI(fastify)
62+
erc721ItemsGetApproved(fastify)
63+
erc721ItemsGetRoleAdmin(fastify)
64+
erc721ItemsGetRoleMember(fastify)
65+
erc721ItemsGetRoleMemberCount(fastify)
66+
erc721ItemsHasRole(fastify)
67+
erc721ItemsIsApprovedForAll(fastify)
68+
erc721ItemsName(fastify)
69+
erc721ItemsOwnerOf(fastify)
70+
erc721ItemsRoyaltyInfo(fastify)
71+
erc721ItemsSupportsInterface(fastify)
72+
erc721ItemsSymbol(fastify)
73+
erc721ItemsTokenURI(fastify)
74+
erc721ItemsTotalSupply(fastify)
75+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import type { FastifyInstance } from 'fastify'
2+
import { ethers } from 'ethers'
3+
import erc721ItemsAbi from '~/constants/abis/erc721Items.json'
4+
import { getSigner } from '~/utils/wallet'
5+
6+
function serializeBigInt(obj: any): any {
7+
if (obj === null || obj === undefined) {
8+
return obj;
9+
}
10+
11+
if (typeof obj === 'bigint') {
12+
return obj.toString();
13+
}
14+
15+
if (Array.isArray(obj)) {
16+
return obj.map(serializeBigInt);
17+
}
18+
19+
if (typeof obj === 'object') {
20+
const serialized: any = {};
21+
for (const [key, value] of Object.entries(obj)) {
22+
serialized[key] = serializeBigInt(value);
23+
}
24+
return serialized;
25+
}
26+
27+
return obj;
28+
}
29+
30+
type erc721ItemsDEFAULT_ADMIN_ROLERequestParams = {
31+
chainId: string
32+
contractAddress: string
33+
}
34+
35+
type erc721ItemsDEFAULT_ADMIN_ROLEResponse = {
36+
result?: {
37+
data: any
38+
error?: string
39+
}
40+
}
41+
42+
const erc721ItemsDEFAULT_ADMIN_ROLESchema = {
43+
tags: ['ERC721Items'],
44+
params: {
45+
type: 'object',
46+
required: ['chainId', 'contractAddress'],
47+
properties: {
48+
chainId: { type: 'string' },
49+
contractAddress: { type: 'string' }
50+
}
51+
},
52+
response: {
53+
200: {
54+
type: 'object',
55+
properties: {
56+
result: {
57+
type: 'object',
58+
properties: {
59+
data: {},
60+
error: { type: 'string', nullable: true }
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}
67+
68+
export async function erc721ItemsDEFAULT_ADMIN_ROLE(fastify: FastifyInstance) {
69+
fastify.get<{
70+
Params: erc721ItemsDEFAULT_ADMIN_ROLERequestParams
71+
72+
Reply: erc721ItemsDEFAULT_ADMIN_ROLEResponse
73+
}>(
74+
'/read/erc721Items/:chainId/:contractAddress/DEFAULT_ADMIN_ROLE',
75+
{ schema: erc721ItemsDEFAULT_ADMIN_ROLESchema },
76+
async (request, reply) => {
77+
78+
const { chainId, contractAddress } = request.params
79+
80+
try {
81+
const signer = await getSigner(chainId)
82+
if (!signer || !signer.account?.address) {
83+
throw new Error('Signer not configured correctly.')
84+
}
85+
86+
const contract = new ethers.Contract(
87+
contractAddress,
88+
erc721ItemsAbi,
89+
signer
90+
)
91+
92+
const result = await contract.DEFAULT_ADMIN_ROLE()
93+
94+
return reply.code(200).send({
95+
result: {
96+
data: serializeBigInt(result)
97+
}
98+
})
99+
} catch (error) {
100+
return reply.code(500).send({
101+
result: {
102+
data: null,
103+
error: error instanceof Error ? error.message : 'Read failed'
104+
}
105+
})
106+
}
107+
}
108+
)
109+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import type { FastifyInstance } from 'fastify'
2+
import { ethers } from 'ethers'
3+
import erc721ItemsAbi from '~/constants/abis/erc721Items.json'
4+
import { getSigner } from '~/utils/wallet'
5+
6+
function serializeBigInt(obj: any): any {
7+
if (obj === null || obj === undefined) {
8+
return obj;
9+
}
10+
11+
if (typeof obj === 'bigint') {
12+
return obj.toString();
13+
}
14+
15+
if (Array.isArray(obj)) {
16+
return obj.map(serializeBigInt);
17+
}
18+
19+
if (typeof obj === 'object') {
20+
const serialized: any = {};
21+
for (const [key, value] of Object.entries(obj)) {
22+
serialized[key] = serializeBigInt(value);
23+
}
24+
return serialized;
25+
}
26+
27+
return obj;
28+
}
29+
30+
type erc721ItemsAcceptImplicitRequestRequestQuery = {
31+
wallet: string, attestation: string, call: string
32+
}
33+
34+
type erc721ItemsAcceptImplicitRequestRequestParams = {
35+
chainId: string
36+
contractAddress: string
37+
}
38+
39+
type erc721ItemsAcceptImplicitRequestResponse = {
40+
result?: {
41+
data: any
42+
error?: string
43+
}
44+
}
45+
46+
const erc721ItemsAcceptImplicitRequestSchema = {
47+
tags: ['ERC721Items'],
48+
querystring: {
49+
type: 'object',
50+
required: ['wallet', 'attestation', 'call'],
51+
properties: {
52+
wallet: { type: 'string' },
53+
attestation: { type: 'string' },
54+
call: { type: 'string' }
55+
}
56+
},
57+
params: {
58+
type: 'object',
59+
required: ['chainId', 'contractAddress'],
60+
properties: {
61+
chainId: { type: 'string' },
62+
contractAddress: { type: 'string' }
63+
}
64+
},
65+
response: {
66+
200: {
67+
type: 'object',
68+
properties: {
69+
result: {
70+
type: 'object',
71+
properties: {
72+
data: {},
73+
error: { type: 'string', nullable: true }
74+
}
75+
}
76+
}
77+
}
78+
}
79+
}
80+
81+
export async function erc721ItemsAcceptImplicitRequest(fastify: FastifyInstance) {
82+
fastify.get<{
83+
Params: erc721ItemsAcceptImplicitRequestRequestParams
84+
Querystring: erc721ItemsAcceptImplicitRequestRequestQuery
85+
Reply: erc721ItemsAcceptImplicitRequestResponse
86+
}>(
87+
'/read/erc721Items/:chainId/:contractAddress/acceptImplicitRequest',
88+
{ schema: erc721ItemsAcceptImplicitRequestSchema },
89+
async (request, reply) => {
90+
const { wallet, attestation, call } = request.query
91+
const { chainId, contractAddress } = request.params
92+
93+
try {
94+
const signer = await getSigner(chainId)
95+
if (!signer || !signer.account?.address) {
96+
throw new Error('Signer not configured correctly.')
97+
}
98+
99+
const contract = new ethers.Contract(
100+
contractAddress,
101+
erc721ItemsAbi,
102+
signer
103+
)
104+
105+
const result = await contract.acceptImplicitRequest(wallet, attestation, call)
106+
107+
return reply.code(200).send({
108+
result: {
109+
data: serializeBigInt(result)
110+
}
111+
})
112+
} catch (error) {
113+
return reply.code(500).send({
114+
result: {
115+
data: null,
116+
error: error instanceof Error ? error.message : 'Read failed'
117+
}
118+
})
119+
}
120+
}
121+
)
122+
}

0 commit comments

Comments
 (0)