Skip to content

Commit

Permalink
feat: erc-1155 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammed-almujil committed Mar 26, 2023
1 parent 6a78acd commit 1bbf246
Show file tree
Hide file tree
Showing 13 changed files with 536 additions and 378 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,5 @@
],
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
"comma-dangle": ["error", "always"],
"semi": [2, "always"],
"quotes": [2, "single", { "avoidEscape": true }]
}
}
32 changes: 24 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import * as eth from './src/eth'
import { NFTOptions } from './src/models';
import { type NFTOptions, } from './src/models'
import { setIpfsHostnames, setArweaveHostnames } from './src/services'

async function getERC721(NFTOptions: NFTOptions) {
let NFTs = await eth.getERC721(NFTOptions)
const result = NFTs.map((nft) => nft.toDict());
return result
const NFTs = await eth.getERC721(NFTOptions,);
const result = NFTs.map((nft) => nft.toDict());
return result;
}
module.exports.setArweaveHostnames = async (hostnames: string[]) => setArweaveHostnames(hostnames);
module.exports.setIpfsHostnames = async (hostnames: string[]) => setIpfsHostnames(hostnames);
module.exports.setEthProvider = async (provider: string) => eth.setProvider(provider);
module.exports.getERC721 = async (options: NFTOptions) => await getERC721(options);

async function getERC1155(NFTOptions: NFTOptions) {
const NFTs = await eth.getERC1155(NFTOptions,);
const result = NFTs.map((nft) => nft.toDict());
return result;
}

async function getEthNFTs(NFTOptions: NFTOptions) {
const NFTs = await eth.getNFTs(NFTOptions,);
const result = NFTs.map((nft) => nft.toDict());
return result;
}


module.exports.setArweaveHostnames = async (hostnames: string[]) => { setArweaveHostnames(hostnames,); }
module.exports.setIpfsHostnames = async (hostnames: string[]) => { setIpfsHostnames(hostnames,); }
module.exports.setEthProvider = async (provider: string) => { eth.setProvider(provider,); }
module.exports.getERC721 = async (options: NFTOptions) => await getERC721(options);
module.exports.getERC1155 = async (options: NFTOptions) => await getERC1155(options);
module.exports.getEthNFTs = async (options: NFTOptions) => await getEthNFTs(options);
114 changes: 57 additions & 57 deletions src/eth/ABI.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
import { AbiItem } from 'web3-utils'


const ERC721Transfer = [{
type: 'address',
name: 'from',
indexed: true,
}, {
type: 'address',
name: 'to',
indexed: true,
}, {
type: 'uint256',
name: 'tokenId',
indexed: true,
},
];

const ERC721TokenURI: AbiItem=
{
inputs: [
{
internalType: 'uint256',
name: 'tokenId',
type: 'uint256'
}
],
import { type AbiItem } from 'web3-utils'
const ERC721Transfer = [
{ type: 'address', name: 'from', indexed: true },
{ type: 'address', name: 'to', indexed: true },
{ type: 'uint256', name: 'tokenId', indexed: true }
]
const ERC721: AbiItem[] = [
{
constant: true,
inputs: [{ name: '_tokenId', type: 'uint256' }],
name: 'tokenURI',
outputs: [
{
internalType: 'string',
name: '',
type: 'string'
}
],
outputs: [{ name: '', type: 'string' }],
payable: false,
stateMutability: 'view',
type: 'function'
};
}
]
const ERC1155TransferSingle = [
{ type: 'address', name: 'operator', indexed: true },
{ type: 'address', name: 'from', indexed: true },
{ type: 'address', name: 'to', indexed: true },
{ type: 'uint256', name: 'id' },
{ type: 'uint256', name: 'value' }
]

const ERC721: AbiItem[]= [
{
"constant": true,
"inputs": [
{
"name": "_tokenId",
"type": "uint256"
}
],
"name": "tokenURI",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function",
}]
;
const ERC1155TransferMulti = [
{ type: 'address', name: 'operator', indexed: true },
{ type: 'address', name: 'from', indexed: true },
{ type: 'address', name: 'to', indexed: true },
{ type: 'uint256[]', name: 'ids' },
{ type: 'uint256[]', name: 'values' }
]

export { ERC721TokenURI, ERC721Transfer, ERC721 };
const ERC1155: AbiItem[] = [
{
inputs: [{ internalType: 'uint256', name: 'id', type: 'uint256' }],
name: 'uri',
outputs: [{ internalType: 'string', name: '', type: 'string' }],
stateMutability: 'view',
type: 'function'
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "string",
name: "value",
type: "string"
},
{
indexed: true,
internalType: "uint256",
name: "id",
type: "uint256"
}
],
name: "URI",
type: "event"
}
]
export { ERC721Transfer, ERC721, ERC1155TransferSingle, ERC1155TransferMulti, ERC1155, }
Loading

0 comments on commit 1bbf246

Please sign in to comment.