├── .nvmrc ├── .gitignore ├── scripts ├── dev.sh ├── travis_test.sh ├── test.sh ├── travis_prep.sh ├── lint.sh ├── build.sh └── gen_from_tokenbase.js ├── .gitmodules ├── dist ├── schemas │ ├── main │ │ ├── index.d.ts │ │ ├── ENSName │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── CryptoPunks │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── CryptoKitties │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── EnjinItem │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── OwnableContract │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── ENSShortNameAuction │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── index.js.map │ │ └── index.js │ ├── goerli │ │ ├── index.d.ts │ │ ├── index.js.map │ │ └── index.js │ ├── rinkeby │ │ ├── index.d.ts │ │ ├── rinkebyENSName │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── testRinkebyNFT │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── rinkebyCryptoKitties │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── rinkebyOwnableContract │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── rinkebyENSShortNameAuction │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── rinkebyCustom │ │ │ ├── index.d.ts │ │ │ ├── index.js.map │ │ │ └── index.js │ │ ├── index.js.map │ │ └── index.js │ ├── index.d.ts │ ├── ERC20 │ │ ├── index.d.ts │ │ ├── index.js.map │ │ └── index.js │ ├── ERC1155 │ │ ├── index.d.ts │ │ ├── index.js.map │ │ └── index.js │ ├── index.js.map │ ├── ERC721 │ │ ├── index.d.ts │ │ ├── index.js.map │ │ └── index.js │ ├── ContractRole │ │ ├── index.d.ts │ │ ├── index.js.map │ │ └── index.js │ └── index.js ├── tokens │ ├── main │ │ └── index.d.ts │ ├── goerli │ │ ├── index.d.ts │ │ ├── index.js.map │ │ └── index.js │ ├── rinkeby │ │ ├── index.d.ts │ │ ├── index.js.map │ │ └── index.js │ ├── index.d.ts │ ├── index.js.map │ └── index.js ├── index.d.ts ├── index.js.map ├── common │ ├── ens.d.ts │ ├── ens.js.map │ └── ens.js ├── types.js.map ├── schemaFunctions.d.ts ├── index.js ├── types.js ├── types.d.ts ├── schemaFunctions.js.map └── schemaFunctions.js ├── .babelrc ├── .travis.yml ├── src ├── tokens │ ├── goerli │ │ └── index.ts │ ├── index.ts │ └── rinkeby │ │ └── index.ts ├── schemas │ ├── index.ts │ ├── goerli │ │ └── index.ts │ ├── main │ │ ├── index.ts │ │ ├── EnjinItem │ │ │ └── index.ts │ │ ├── ENSName │ │ │ └── index.ts │ │ ├── ENSShortNameAuction │ │ │ └── index.ts │ │ ├── OwnableContract │ │ │ └── index.ts │ │ ├── CryptoPunks │ │ │ └── index.ts │ │ └── CryptoKitties │ │ │ └── index.ts │ ├── rinkeby │ │ ├── index.ts │ │ ├── rinkebyCustom │ │ │ └── index.ts │ │ ├── rinkebyENSName │ │ │ └── index.ts │ │ ├── rinkebyOwnableContract │ │ │ └── index.ts │ │ ├── rinkebyENSShortNameAuction │ │ │ └── index.ts │ │ ├── testRinkebyNFT │ │ │ └── index.ts │ │ └── rinkebyCryptoKitties │ │ │ └── index.ts │ ├── ERC20 │ │ └── index.ts │ ├── ContractRole │ │ └── index.ts │ ├── ERC1155 │ │ └── index.ts │ └── ERC721 │ │ └── index.ts ├── index.ts ├── globals.d.ts ├── common │ └── ens.ts ├── types.ts └── schemaFunctions.ts ├── tsconfig.json ├── LICENSE ├── test └── schemas.js ├── package.json ├── README.md └── tslint.json /.nvmrc: -------------------------------------------------------------------------------- 1 | 16.11.0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | yarn-error.log 3 | .env 4 | .DS_Store -------------------------------------------------------------------------------- /scripts/dev.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf dist 4 | yarn run tsc --watch 5 | -------------------------------------------------------------------------------- /scripts/travis_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | yarn test 6 | -------------------------------------------------------------------------------- /scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | yarn run mocha --timeout 50000 --exit 6 | -------------------------------------------------------------------------------- /scripts/travis_prep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | yarn list 6 | yarn build 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tokenbase"] 2 | path = tokenbase 3 | url = https://github.com/forkdelta/tokenbase.git 4 | -------------------------------------------------------------------------------- /dist/schemas/main/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | export declare const mainSchemas: Array>; 3 | -------------------------------------------------------------------------------- /dist/tokens/main/index.d.ts: -------------------------------------------------------------------------------- 1 | import { NetworkTokens } from '../../types'; 2 | export declare const mainTokens: NetworkTokens; 3 | -------------------------------------------------------------------------------- /scripts/lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | yarn run tslint --project . 'src/**/*.ts' --fix 6 | 7 | echo "Lint OK!" 8 | -------------------------------------------------------------------------------- /dist/schemas/goerli/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | export declare const goerliSchemas: Array>; 3 | -------------------------------------------------------------------------------- /dist/tokens/goerli/index.d.ts: -------------------------------------------------------------------------------- 1 | import { NetworkTokens } from '../../types'; 2 | export declare const goerliTokens: NetworkTokens; 3 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | export declare const rinkebySchemas: Array>; 3 | -------------------------------------------------------------------------------- /dist/tokens/rinkeby/index.d.ts: -------------------------------------------------------------------------------- 1 | import { NetworkTokens } from '../../types'; 2 | export declare const rinkebyTokens: NetworkTokens; 3 | -------------------------------------------------------------------------------- /dist/schemas/main/ENSName/index.d.ts: -------------------------------------------------------------------------------- 1 | import { ENSName } from '../../../common/ens'; 2 | import { Schema } from '../../../types'; 3 | export declare const ENSNameSchema: Schema; 4 | -------------------------------------------------------------------------------- /dist/schemas/main/CryptoPunks/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../../types'; 2 | export declare type CryptoPunksType = string; 3 | export declare const CryptoPunksSchema: Schema; 4 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyENSName/index.d.ts: -------------------------------------------------------------------------------- 1 | import { ENSName } from '../../../common/ens'; 2 | import { Schema } from '../../../types'; 3 | export declare const rinkebyENSNameSchema: Schema; 4 | -------------------------------------------------------------------------------- /dist/schemas/main/CryptoKitties/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../../types'; 2 | export declare type CryptoKittiesType = string; 3 | export declare const CryptoKittiesSchema: Schema; 4 | -------------------------------------------------------------------------------- /dist/tokens/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const tokens: { 2 | goerli: import("../types").NetworkTokens; 3 | rinkeby: import("../types").NetworkTokens; 4 | main: import("../types").NetworkTokens; 5 | }; 6 | -------------------------------------------------------------------------------- /dist/schemas/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const schemas: { 2 | goerli: import("../types").Schema[]; 3 | rinkeby: import("../types").Schema[]; 4 | main: import("../types").Schema[]; 5 | }; 6 | -------------------------------------------------------------------------------- /dist/schemas/main/EnjinItem/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../../types'; 2 | import { SemiFungibleTradeType } from '../../ERC1155'; 3 | export declare const EnjinItemSchema: Schema; 4 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/testRinkebyNFT/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../../types'; 2 | export declare type TestRinkebyNFTType = string; 3 | export declare const testRinkebyNFTSchema: Schema; 4 | -------------------------------------------------------------------------------- /dist/schemas/ERC20/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | export interface FungibleTradeType { 3 | address: string; 4 | quantity: string; 5 | } 6 | export declare const ERC20Schema: Schema; 7 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "targets": { 5 | "browsers": ["last 2 versions", "safari >= 7"] 6 | } 7 | }] 8 | ], 9 | "plugins": [ 10 | "transform-runtime" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyCryptoKitties/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../../types'; 2 | export declare type RinkebyCryptoKittiesType = string; 3 | export declare const rinkebyCryptoKittiesSchema: Schema; 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | sudo: required 3 | group: beta 4 | language: node_js 5 | node_js: 6 | - "8" 7 | cache: 8 | yarn: true 9 | before_script: 10 | - scripts/travis_prep.sh 11 | script: 12 | - scripts/travis_test.sh 13 | -------------------------------------------------------------------------------- /dist/schemas/ERC1155/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | export interface SemiFungibleTradeType { 3 | id: string; 4 | address: string; 5 | quantity: string; 6 | } 7 | export declare const ERC1155Schema: Schema; 8 | -------------------------------------------------------------------------------- /dist/tokens/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":";AAAA,mCAAmC;;;AAEnC,wCAA0C;AAC1C,2CAAgD;AAChD,0CAA8C;AAEjC,QAAA,MAAM,GAAG;IACpB,MAAM,EAAE,oBAAY;IACpB,OAAO,EAAE,qBAAa;IACtB,IAAI,EAAE,kBAAU;CACjB,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":";AAAA,mCAAmC;;;AAEnC,wCAA2C;AAC3C,2CAAiD;AACjD,0CAA+C;AAElC,QAAA,OAAO,GAAG;IACrB,MAAM,EAAE,qBAAa;IACrB,OAAO,EAAE,sBAAc;IACvB,IAAI,EAAE,mBAAW;CAClB,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/main/OwnableContract/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../../types'; 2 | export interface OwnableContractType { 3 | name?: string; 4 | description?: string; 5 | address: string; 6 | } 7 | export declare const OwnableContractSchema: Schema; 8 | -------------------------------------------------------------------------------- /dist/schemas/goerli/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/goerli/index.ts"],"names":[],"mappings":";;;AACA,iDAA2D;AAC3D,wCAA2C;AAC3C,oCAAuC;AACvC,2CAA+D;AAGlD,QAAA,aAAa,GAAuB;IAC7C,mBAAW;IACX,oBAAY;IACZ,sBAAc;IACd,uBAAa;IACb,0BAAkB;CACrB,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyOwnableContract/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../../types'; 2 | export interface RinkebyOwnableContractType { 3 | name?: string; 4 | address: string; 5 | } 6 | export declare const rinkebyOwnableContractSchema: Schema; 7 | -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export { encodeBuy, encodeSell, encodeAtomicizedBuy, encodeAtomicizedSell, encodeCall, encodeDefaultCall, encodeReplacementPattern, } from './schemaFunctions'; 2 | export { schemas } from './schemas/index'; 3 | export { tokens } from './tokens/index'; 4 | export { AbiType } from 'ethereum-types'; 5 | -------------------------------------------------------------------------------- /dist/schemas/ERC721/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | export interface NonFungibleContractType { 3 | id: string; 4 | address: string; 5 | } 6 | export declare const ERC721Schema: Schema; 7 | export declare const ERC721v3Schema: Schema; 8 | -------------------------------------------------------------------------------- /dist/schemas/main/ENSShortNameAuction/index.d.ts: -------------------------------------------------------------------------------- 1 | import { ENSName } from '../../../common/ens'; 2 | import { Schema } from '../../../types'; 3 | export declare const ENS_SHORT_NAME_AUCTION_ADDRESS = "0x699c7f511c9e2182e89f29b3bfb68bd327919d17"; 4 | export declare const ENSShortNameAuctionSchema: Schema; 5 | -------------------------------------------------------------------------------- /dist/tokens/goerli/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tokens/goerli/index.ts"],"names":[],"mappings":";;;AAIa,QAAA,YAAY,GAAkB;IACvC,qBAAqB,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,4CAA4C,EAAC;IAC3I,WAAW,EAAE,EAAE;CAClB,CAAC"} -------------------------------------------------------------------------------- /src/tokens/goerli/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | NetworkTokens, 3 | } from '../../types'; 4 | 5 | export const goerliTokens: NetworkTokens = { 6 | canonicalWrappedEther: { name: 'Goerli Wrapped Ether', symbol: 'WETH', decimals: 18, address: '0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6'}, 7 | otherTokens: [] 8 | }; -------------------------------------------------------------------------------- /dist/schemas/ContractRole/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | export interface ContractRoleType { 3 | roleGetter: string; 4 | roleSetter: string; 5 | address: string; 6 | name?: string; 7 | description?: string; 8 | } 9 | export declare const ContractRoleSchema: Schema; 10 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyENSShortNameAuction/index.d.ts: -------------------------------------------------------------------------------- 1 | import { ENSName } from '../../../common/ens'; 2 | import { Schema } from '../../../types'; 3 | export declare const RINKEBY_ENS_SHORT_NAME_AUCTION_ADDRESS = "0x76b6481a334783be36f2fc35b8f0b9bc7835d57b"; 4 | export declare const rinkebyENSShortNameAuctionSchema: Schema; 5 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo 'Generating token list from tokenbase...' 4 | node scripts/gen_from_tokenbase.js 5 | echo 'Compiling Typescript...' 6 | rm -rf dist-tsc dist 7 | yarn run tsc 8 | for DIR in $(ls src/schemas/main); do 9 | cp -r src/schemas/main/$DIR/*.json dist/schemas/main/$DIR 10 | done 11 | echo 'Done' -------------------------------------------------------------------------------- /src/tokens/index.ts: -------------------------------------------------------------------------------- 1 | // To help typescript find the type 2 | 3 | import { mainTokens } from './main/index'; 4 | import { rinkebyTokens } from './rinkeby/index'; 5 | import { goerliTokens } from './goerli/index'; 6 | 7 | export const tokens = { 8 | goerli: goerliTokens, 9 | rinkeby: rinkebyTokens, 10 | main: mainTokens, 11 | }; 12 | -------------------------------------------------------------------------------- /src/schemas/index.ts: -------------------------------------------------------------------------------- 1 | // To help typescript find the type 2 | 3 | import { mainSchemas } from './main/index'; 4 | import { rinkebySchemas } from './rinkeby/index'; 5 | import { goerliSchemas } from './goerli/index'; 6 | 7 | export const schemas = { 8 | goerli: goerliSchemas, 9 | rinkeby: rinkebySchemas, 10 | main: mainSchemas, 11 | }; 12 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyCustom/index.d.ts: -------------------------------------------------------------------------------- 1 | import { AnnotatedFunctionABI, Schema } from '../../../types'; 2 | export interface RinkebyCustomType { 3 | name: string; 4 | description: string; 5 | thumbnail: string; 6 | url: string; 7 | transfer: AnnotatedFunctionABI; 8 | } 9 | export declare const rinkebyCustomSchema: Schema; 10 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | encodeBuy, 3 | encodeSell, 4 | encodeAtomicizedBuy, 5 | encodeAtomicizedSell, 6 | encodeCall, 7 | encodeDefaultCall, 8 | encodeReplacementPattern, 9 | } from './schemaFunctions'; 10 | export { schemas } from './schemas/index'; 11 | export { tokens } from './tokens/index'; 12 | 13 | export { AbiType } from 'ethereum-types'; 14 | -------------------------------------------------------------------------------- /dist/tokens/goerli/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.goerliTokens = void 0; 4 | exports.goerliTokens = { 5 | canonicalWrappedEther: { name: 'Goerli Wrapped Ether', symbol: 'WETH', decimals: 18, address: '0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6' }, 6 | otherTokens: [] 7 | }; 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAQ2B;AAPzB,4GAAA,SAAS,OAAA;AACT,6GAAA,UAAU,OAAA;AACV,sHAAA,mBAAmB,OAAA;AACnB,uHAAA,oBAAoB,OAAA;AACpB,6GAAA,UAAU,OAAA;AACV,oHAAA,iBAAiB,OAAA;AACjB,2HAAA,wBAAwB,OAAA;AAE1B,yCAA0C;AAAjC,gGAAA,OAAO,OAAA;AAChB,wCAAwC;AAA/B,+FAAA,MAAM,OAAA;AAEf,iDAAyC;AAAhC,yGAAA,OAAO,OAAA"} -------------------------------------------------------------------------------- /dist/common/ens.d.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../types'; 2 | export interface ENSName { 3 | nodeHash: string; 4 | nameHash: string; 5 | name: string; 6 | } 7 | export declare const namehash: (name: string) => string; 8 | export declare const nodehash: (name: string) => string; 9 | export declare const ENSNameBaseSchema: Required, 'fields' | 'assetFromFields' | 'checkAsset' | 'hash'>>; 10 | -------------------------------------------------------------------------------- /dist/schemas/main/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/main/index.ts"],"names":[],"mappings":";;;AACA,iDAA2D;AAC3D,wCAA2C;AAC3C,oCAAuC;AACvC,2CAA+D;AAE/D,iDAA4D;AAC5D,+CAAwD;AACxD,2CAA8C;AAC9C,2CAAgD;AAChD,uDAAwE;AACxE,mDAAgE;AAEnD,QAAA,WAAW,GAAuB;IAC7C,2BAAmB;IACnB,yBAAiB;IACjB,qBAAa;IACb,iCAAyB;IACzB,6BAAqB;IACrB,mBAAW;IACX,oBAAY;IACZ,sBAAc;IACd,uBAAa;IACb,2BAAe;IACf,0BAAkB;CACnB,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/rinkeby/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/rinkeby/index.ts"],"names":[],"mappings":";;;AACA,iDAA2D;AAC3D,wCAA2C;AAC3C,oCAAuC;AACvC,2CAA+D;AAE/D,wDAA0E;AAC1E,iDAA4D;AAC5D,kDAA8D;AAC9D,8DAAsF;AACtF,0DAA8E;AAC9E,kDAA8D;AAEjD,QAAA,cAAc,GAAuB;IAChD,kCAA0B;IAC1B,2BAAmB;IACnB,4BAAoB;IACpB,wCAAgC;IAChC,oCAA4B;IAC5B,4BAAoB;IACpB,mBAAW;IACX,oBAAY;IACZ,sBAAc;IACd,uBAAa;IACb,0BAAkB;CACnB,CAAC"} -------------------------------------------------------------------------------- /src/schemas/goerli/index.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | import { ContractRoleSchema } from '../ContractRole/index'; 3 | import { ERC1155Schema } from '../ERC1155'; 4 | import { ERC20Schema } from '../ERC20'; 5 | import { ERC721Schema, ERC721v3Schema } from '../ERC721/index'; 6 | 7 | 8 | export const goerliSchemas: Array> = [ 9 | ERC20Schema, 10 | ERC721Schema, 11 | ERC721v3Schema, 12 | ERC1155Schema, 13 | ContractRoleSchema, 14 | ]; -------------------------------------------------------------------------------- /dist/tokens/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // To help typescript find the type 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | exports.tokens = void 0; 5 | const index_1 = require("./main/index"); 6 | const index_2 = require("./rinkeby/index"); 7 | const index_3 = require("./goerli/index"); 8 | exports.tokens = { 9 | goerli: index_3.goerliTokens, 10 | rinkeby: index_2.rinkebyTokens, 11 | main: index_1.mainTokens, 12 | }; 13 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // To help typescript find the type 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | exports.schemas = void 0; 5 | const index_1 = require("./main/index"); 6 | const index_2 = require("./rinkeby/index"); 7 | const index_3 = require("./goerli/index"); 8 | exports.schemas = { 9 | goerli: index_3.goerliSchemas, 10 | rinkeby: index_2.rinkebySchemas, 11 | main: index_1.mainSchemas, 12 | }; 13 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/tokens/rinkeby/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tokens/rinkeby/index.ts"],"names":[],"mappings":";;;AAIa,QAAA,aAAa,GAAkB;IAC1C,qBAAqB,EAAE,EAAC,IAAI,EAAE,iCAAiC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,4CAA4C,EAAC;IACrJ,WAAW,EAAE;QACX,EAAC,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,4CAA4C,EAAC;QAChH,EAAC,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,4CAA4C,EAAC;KAC5H;CACF,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/goerli/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.goerliSchemas = void 0; 4 | const index_1 = require("../ContractRole/index"); 5 | const ERC1155_1 = require("../ERC1155"); 6 | const ERC20_1 = require("../ERC20"); 7 | const index_2 = require("../ERC721/index"); 8 | exports.goerliSchemas = [ 9 | ERC20_1.ERC20Schema, 10 | index_2.ERC721Schema, 11 | index_2.ERC721v3Schema, 12 | ERC1155_1.ERC1155Schema, 13 | index_1.ContractRoleSchema, 14 | ]; 15 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": [ 3 | "./src/**/*", 4 | "./node_modules/web3-typescript-typings/index.d.ts", 5 | "./node_modules/types-bn/index.d.ts", 6 | "./node_modules/types-ethereumjs-util/index.d.ts" 7 | ], 8 | "compilerOptions": { 9 | "sourceMap": true, 10 | "outDir": "./dist/", 11 | "noImplicitAny": true, 12 | "noImplicitThis": false, 13 | "declaration": true, 14 | "module": "commonjs", 15 | "target": "es6", 16 | "pretty": true, 17 | "strict": true, 18 | "noImplicitReturns": true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/tokens/rinkeby/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | NetworkTokens, 3 | } from '../../types'; 4 | 5 | export const rinkebyTokens: NetworkTokens = { 6 | canonicalWrappedEther: {name: 'Rinkeby Canonical Wrapped Ether', symbol: 'WETH', decimals: 18, address: '0xc778417e063141139fce010982780140aa0cd5ab'}, 7 | otherTokens: [ 8 | {name: 'Rinkeby Test Token', symbol: 'TST', decimals: 18, address: '0xb7dDCF6B64C05D76Adc497AE78AD83ba3883A294'}, 9 | {name: 'Decentraland - Chainbreakers', symbol: 'MANA', decimals: 18, address: '0x0f8528c53fecb54b7005525a3e797e261a51b88e'}, 10 | ], 11 | }; 12 | -------------------------------------------------------------------------------- /src/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'ethereumjs-abi' { 2 | const soliditySHA3: (argTypes: string[], args: any[]) => Buffer; 3 | const methodID: (name: string, types: string[]) => Buffer; 4 | const rawEncode: (argTypes: string[], args: any[]) => Buffer; 5 | const encodeSingle: (type: string, arg: any) => Buffer; 6 | const elementaryName: (name: string) => string; 7 | const isDynamic: (type: string) => boolean; 8 | } 9 | 10 | declare module 'wyvern-js' { 11 | export const WyvernProtocol: any; 12 | } 13 | 14 | declare module '*.json' { 15 | const value: any; 16 | export default value; 17 | } 18 | -------------------------------------------------------------------------------- /dist/tokens/rinkeby/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.rinkebyTokens = void 0; 4 | exports.rinkebyTokens = { 5 | canonicalWrappedEther: { name: 'Rinkeby Canonical Wrapped Ether', symbol: 'WETH', decimals: 18, address: '0xc778417e063141139fce010982780140aa0cd5ab' }, 6 | otherTokens: [ 7 | { name: 'Rinkeby Test Token', symbol: 'TST', decimals: 18, address: '0xb7dDCF6B64C05D76Adc497AE78AD83ba3883A294' }, 8 | { name: 'Decentraland - Chainbreakers', symbol: 'MANA', decimals: 18, address: '0x0f8528c53fecb54b7005525a3e797e261a51b88e' }, 9 | ], 10 | }; 11 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /scripts/gen_from_tokenbase.js: -------------------------------------------------------------------------------- 1 | const yaml = require('js-yaml') 2 | const fs = require('fs') 3 | 4 | const files = fs.readdirSync('./tokenbase/tokens').filter(f => f.endsWith('.yaml')) 5 | const yamls = files.map(f => yaml.safeLoad(fs.readFileSync('./tokenbase/tokens/' + f))) 6 | 7 | const otherTokens = yamls.map(y => ` {name: '${y.name}', symbol: '${y.symbol}', decimals: ${y.decimals}, address: '${y.addr}'},`).join('\n') 8 | 9 | fs.writeFileSync('./src/tokens/main/index.ts', `import { 10 | NetworkTokens, 11 | } from '../../types'; 12 | 13 | export const mainTokens: NetworkTokens = { 14 | canonicalWrappedEther: {name: 'Canonical Wrapped Ether', symbol: 'WETH', decimals: 18, address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'}, 15 | otherTokens: [ 16 | ${otherTokens} 17 | ], 18 | }; // tslint:disable:max-file-line-count`) 19 | -------------------------------------------------------------------------------- /dist/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AACA,+CAI6B;AAI3B,qGAPA,4BAAoB,OAOA;AADpB,uGALA,8BAAsB,OAKA;AAEtB,kGANA,yBAAiB,OAMA;AAGnB,IAAY,OAKX;AALD,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,8BAAmB,CAAA;IACnB,4BAAiB,CAAA;IACjB,0BAAe,CAAA;AACjB,CAAC,EALW,OAAO,GAAP,eAAO,KAAP,eAAO,QAKlB;AAED,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,gCAA2B,CAAA;IAC3B,0BAAqB,CAAA;AACvB,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAcD,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,4CAAyB,CAAA;AAC3B,CAAC,EALW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK1B;AAED,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,qCAAe,CAAA;IACf,qCAAe,CAAA;IACf,qCAAe,CAAA;IACf,qCAAe,CAAA;AACjB,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B;AAYD,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,6CAA2B,CAAA;IAC3B,iCAAe,CAAA;IACf,iCAAe,CAAA;AACjB,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB"} -------------------------------------------------------------------------------- /src/schemas/main/index.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | import { ContractRoleSchema } from '../ContractRole/index'; 3 | import { ERC1155Schema } from '../ERC1155'; 4 | import { ERC20Schema } from '../ERC20'; 5 | import { ERC721Schema, ERC721v3Schema } from '../ERC721/index'; 6 | 7 | import { CryptoKittiesSchema } from './CryptoKitties/index'; 8 | import { CryptoPunksSchema } from './CryptoPunks/index'; 9 | import { EnjinItemSchema } from './EnjinItem'; 10 | import { ENSNameSchema } from './ENSName/index'; 11 | import { ENSShortNameAuctionSchema } from './ENSShortNameAuction/index'; 12 | import { OwnableContractSchema } from './OwnableContract/index'; 13 | 14 | export const mainSchemas: Array> = [ 15 | CryptoKittiesSchema, 16 | CryptoPunksSchema, 17 | ENSNameSchema, 18 | ENSShortNameAuctionSchema, 19 | OwnableContractSchema, 20 | ERC20Schema, 21 | ERC721Schema, 22 | ERC721v3Schema, 23 | ERC1155Schema, 24 | EnjinItemSchema, 25 | ContractRoleSchema, 26 | ]; 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017-2018 Project Wyvern Developers 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /dist/schemas/main/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.mainSchemas = void 0; 4 | const index_1 = require("../ContractRole/index"); 5 | const ERC1155_1 = require("../ERC1155"); 6 | const ERC20_1 = require("../ERC20"); 7 | const index_2 = require("../ERC721/index"); 8 | const index_3 = require("./CryptoKitties/index"); 9 | const index_4 = require("./CryptoPunks/index"); 10 | const EnjinItem_1 = require("./EnjinItem"); 11 | const index_5 = require("./ENSName/index"); 12 | const index_6 = require("./ENSShortNameAuction/index"); 13 | const index_7 = require("./OwnableContract/index"); 14 | exports.mainSchemas = [ 15 | index_3.CryptoKittiesSchema, 16 | index_4.CryptoPunksSchema, 17 | index_5.ENSNameSchema, 18 | index_6.ENSShortNameAuctionSchema, 19 | index_7.OwnableContractSchema, 20 | ERC20_1.ERC20Schema, 21 | index_2.ERC721Schema, 22 | index_2.ERC721v3Schema, 23 | ERC1155_1.ERC1155Schema, 24 | EnjinItem_1.EnjinItemSchema, 25 | index_1.ContractRoleSchema, 26 | ]; 27 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/schemas/rinkeby/index.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from '../../types'; 2 | import { ContractRoleSchema } from '../ContractRole/index'; 3 | import { ERC1155Schema } from '../ERC1155'; 4 | import { ERC20Schema } from '../ERC20'; 5 | import { ERC721Schema, ERC721v3Schema } from '../ERC721/index'; 6 | 7 | import { rinkebyCryptoKittiesSchema } from './rinkebyCryptoKitties/index'; 8 | import { rinkebyCustomSchema } from './rinkebyCustom/index'; 9 | import { rinkebyENSNameSchema } from './rinkebyENSName/index'; 10 | import { rinkebyENSShortNameAuctionSchema } from './rinkebyENSShortNameAuction/index'; 11 | import { rinkebyOwnableContractSchema } from './rinkebyOwnableContract/index'; 12 | import { testRinkebyNFTSchema } from './testRinkebyNFT/index'; 13 | 14 | export const rinkebySchemas: Array> = [ 15 | rinkebyCryptoKittiesSchema, 16 | rinkebyCustomSchema, 17 | rinkebyENSNameSchema, 18 | rinkebyENSShortNameAuctionSchema, 19 | rinkebyOwnableContractSchema, 20 | testRinkebyNFTSchema, 21 | ERC20Schema, 22 | ERC721Schema, 23 | ERC721v3Schema, 24 | ERC1155Schema, 25 | ContractRoleSchema, 26 | ]; 27 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.rinkebySchemas = void 0; 4 | const index_1 = require("../ContractRole/index"); 5 | const ERC1155_1 = require("../ERC1155"); 6 | const ERC20_1 = require("../ERC20"); 7 | const index_2 = require("../ERC721/index"); 8 | const index_3 = require("./rinkebyCryptoKitties/index"); 9 | const index_4 = require("./rinkebyCustom/index"); 10 | const index_5 = require("./rinkebyENSName/index"); 11 | const index_6 = require("./rinkebyENSShortNameAuction/index"); 12 | const index_7 = require("./rinkebyOwnableContract/index"); 13 | const index_8 = require("./testRinkebyNFT/index"); 14 | exports.rinkebySchemas = [ 15 | index_3.rinkebyCryptoKittiesSchema, 16 | index_4.rinkebyCustomSchema, 17 | index_5.rinkebyENSNameSchema, 18 | index_6.rinkebyENSShortNameAuctionSchema, 19 | index_7.rinkebyOwnableContractSchema, 20 | index_8.testRinkebyNFTSchema, 21 | ERC20_1.ERC20Schema, 22 | index_2.ERC721Schema, 23 | index_2.ERC721v3Schema, 24 | ERC1155_1.ERC1155Schema, 25 | index_1.ContractRoleSchema, 26 | ]; 27 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyCustom/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/rinkeby/rinkebyCust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KAAK,CAAC,QAAQ;QACjC,oBAAoB,EAAE,EAAE;KACzB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;CAC7B,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/main/EnjinItem/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/main/EnjinItem/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyC;AAEzC,0CAKwB;AACxB,2CAAqE;AAExD,QAAA,eAAe,mCACvB,uBAAa,KAChB,OAAO,EAAE,CAAC,EACV,eAAe,EAAE,CAAC,EAClB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,mEAAmE,EAChF,OAAO,EAAE,uBAAuB,EAChC,SAAS,kCACJ,uBAAa,CAAC,SAAS,KAC1B,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,uBAAe,CAAC,IAAI;YACrC,MAAM,EAAE,KAAK,CAAC,OAAO;YACrB,MAAM,EAAE;gBACN,EAAC,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAC;aAC/E;YACD,OAAO,EAAE;gBACP,EAAC,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC;aACjE;SACF,CAAC;QACF,mCAAmC;QACnC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,uBAAe,CAAC,IAAI;YACrC,MAAM,EAAE,KAAK,CAAC,OAAO;YACrB,MAAM,EAAE;gBACN,EAAC,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAC;gBAC9E,EAAC,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAC;aACjE;YACD,OAAO,EAAE;gBACP,EAAC,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC;aAChE;YACD,gBAAgB,EAAE,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO;SACpD,CAAC,EACF,oBAAoB,EAAE,EAAE,OAE1B"} -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyENSName/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/rinkeby/rinkebyENSName/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,6CAAiE;AACjE,0CAKwB;AAEX,QAAA,oBAAoB,mCAC5B,uBAAiB,KACpB,OAAO,EAAE,CAAC,EACV,eAAe,EAAE,CAAC,EAClB,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,yCAAyC,EACtD,SAAS,EAAE,iCAAiC,EAC5C,OAAO,EAAE,8DAA8D,EACvE,SAAS,EACP,CAAM,KAAK,EAAC,EAAE;QACZ,OAAO;YACL,SAAS,EAAE,iCAAiC;YAC5C,KAAK,EAAE,WAAW,GAAG,KAAK,CAAC,IAAI;YAC/B,WAAW,EAAE,YAAY,GAAG,KAAK,CAAC,QAAQ,GAAG,GAAG;YAChD,GAAG,EAAE,8DAA8D;YACnE,UAAU,EAAE,EAAE;SACf,CAAC;IACN,CAAC,CAAA,EACD,SAAS,EAAE;QACT,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,uBAAe,CAAC,UAAU;YAC3C,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE;gBACN,EAAC,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE;gBACtF,EAAC,IAAI,EAAE,yBAAiB,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC;aACtE;YACD,OAAO,EAAE,EAAE;SACZ,CAAC;QACF,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,uBAAe,CAAC,IAAI;YACrC,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE;gBACN,EAAC,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAC;aACtF;YACD,OAAO,EAAE;gBACP,EAAC,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAC;aAC5D;SACF,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB,EACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE;KACb,IACD"} -------------------------------------------------------------------------------- /dist/schemaFunctions.d.ts: -------------------------------------------------------------------------------- 1 | import { WyvernAtomicizerContract } from 'wyvern-js/lib/abi_gen/wyvern_atomicizer'; 2 | import { AnnotatedFunctionABI, FunctionInputKind, Schema } from './types'; 3 | export declare const encodeReplacementPattern: any; 4 | export interface LimitedCallSpec { 5 | target: string; 6 | calldata: string; 7 | } 8 | export declare const encodeCall: (abi: AnnotatedFunctionABI, parameters: any[]) => string; 9 | export interface CallSpec { 10 | target: string; 11 | calldata: string; 12 | replacementPattern: string; 13 | } 14 | export declare type SellEncoder = (schema: Schema, asset: T, address: string) => CallSpec; 15 | export declare const encodeSell: SellEncoder; 16 | export declare type AtomicizedSellEncoder = (schema: Schema, assets: T[], address: string, atomicizer: WyvernAtomicizerContract) => Partial; 17 | export declare const encodeAtomicizedSell: AtomicizedSellEncoder; 18 | export declare type AtomicizedBuyEncoder = (schema: Schema, assets: T[], address: string, atomicizer: WyvernAtomicizerContract) => Partial; 19 | export declare const encodeAtomicizedBuy: AtomicizedBuyEncoder; 20 | export declare type BuyEncoder = (schema: Schema, asset: T, address: string) => CallSpec; 21 | export declare const encodeBuy: BuyEncoder; 22 | export declare type DefaultCallEncoder = (abi: AnnotatedFunctionABI, address: string) => string; 23 | export declare const encodeDefaultCall: DefaultCallEncoder; 24 | export declare type ReplacementEncoder = (abi: AnnotatedFunctionABI, kind?: FunctionInputKind) => string; 25 | -------------------------------------------------------------------------------- /dist/schemas/main/ENSName/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/main/ENSName/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,6CAAiE;AACjE,0CAKwB;AAEX,QAAA,aAAa,mCACrB,uBAAiB,KACpB,OAAO,EAAE,CAAC,EACV,eAAe,EAAE,OAAO,EACxB,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,sCAAsC,EACnD,SAAS,EAAE,iCAAiC,EAC5C,OAAO,EAAE,8DAA8D,EACvE,SAAS,EAAE,CAAM,KAA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,MAAM;oBACZ,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,KAAK,CAAC,QAAQ;iBACtB;aACF;YACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;SACzE,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB,EACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE;KACb,IACD"} -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyOwnableContract/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/rinkeby/rinkebyOwnableContract/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,0CAKwB;AAOX,QAAA,4BAA4B,GAAuC;IAC9E,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,CAAC;IAClB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,gCAAgC;IAC7C,SAAS,EAAE,oHAAoH;IAC/H,OAAO,EAAE,+FAA+F;IACxG,MAAM,EAAE;QACN,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAC;QAC5D,EAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAC;KACpE;IACD,eAAe,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,CAAC;QACjC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;IACF,SAAS,EACP,CAAM,KAAK,EAAC,EAAE;QACZ,OAAO;YACL,SAAS,EAAE,oHAAoH;YAC/H,KAAK,EAAE,qBAAqB,GAAG,KAAK,CAAC,IAAI,GAAG,GAAG;YAC/C,WAAW,EAAE,qBAAqB,GAAG,KAAK,CAAC,OAAO;YAClD,GAAG,EAAE,uCAAuC,GAAG,KAAK,CAAC,OAAO;YAC5D,UAAU,EAAE,EAAE;SACf,CAAC;IACN,CAAC,CAAA;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,uBAAe,CAAC,UAAU;YAC3C,MAAM,EAAE,KAAK,CAAC,OAAO;YACrB,MAAM,EAAE;gBACN,EAAC,IAAI,EAAE,yBAAiB,CAAC,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAC;aACzE;YACD,OAAO,EAAE,EAAE;SACZ,CAAC;QACF,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,uBAAe,CAAC,IAAI;YACrC,MAAM,EAAE,KAAK,CAAC,OAAO;YACrB,MAAM,EAAE,EAAE;YACV,OAAO,EAAE;gBACP,EAAC,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC;aACjE;SACF,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO;CACrB,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/main/ENSShortNameAuction/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/main/ENSShortNameAuction/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,6CAK6B;AA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SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,sBAAc,CAAC,KAAK;wBAC1B,OAAO,EAAE,KAAK;wBACd,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ;qBACf;oBACD;wBACE,IAAI,EAAE,sBAAc,CAAC,WAAW;wBAChC,OAAO,EAAE,KAAK;wBACd,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,SAAS;qBAChB;iBACF;gBACD,eAAe,EAAE,CAAO,MAAwB,EAAE,EAAE;oBAAC,OAAA,CAAC;wBACpD,IAAI,EAAE,MAAM,CAAC,IAAI;wBACjB,QAAQ,EAAE,IAAA,cAAQ,EAAC,MAAM,CAAC,IAAI,CAAC;wBAC/B,QAAQ,EAAE,IAAA,cAAQ,EAAC,MAAM,CAAC,IAAI,CAAC;qBAChC,CAAC,CAAA;kBAAA;aACH;SACF;KACF,IACD"} -------------------------------------------------------------------------------- /test/schemas.js: -------------------------------------------------------------------------------- 1 | /* globals describe:false,it:false */ 2 | const { INFURA_API_KEY } = process.env 3 | if (!INFURA_API_KEY) { 4 | throw new Error('Need to set INFURA_API_KEY') 5 | } 6 | const assert = require('assert') 7 | const Web3 = require('web3') 8 | const ZeroClientProvider = require('web3-provider-engine/zero.js') 9 | 10 | const engine = ZeroClientProvider({ 11 | getAccounts: () => {}, 12 | rpcUrl: `https://mainnet.infura.io/v3/${INFURA_API_KEY}` 13 | }) 14 | const web3 = new Web3(engine) 15 | 16 | const { schemas } = require('../dist/index.js') 17 | 18 | const promisify = (inner) => 19 | new Promise((resolve, reject) => 20 | inner((err, res) => { 21 | if (err) { reject(err) } 22 | resolve(res) 23 | }) 24 | ) 25 | 26 | schemas.main.map(schema => { 27 | describe(schema.name, () => { 28 | it('should have a unique name', () => { 29 | const matching = schemas.main.filter(s => s.name === schema.name) 30 | assert.equal(matching.length, 1, 'Schema name ' + schema.name + ' is not unique') 31 | }) 32 | 33 | const transfer = schema.events.transfer[0] 34 | if (transfer) { 35 | const transferContract = web3.eth.contract([transfer]).at(transfer.target) 36 | it('should have some transfer events', async () => { 37 | const fromBlock = schema.deploymentBlock 38 | const toBlock = fromBlock + 10000 39 | const events = await promisify(c => transferContract[transfer.name]({}, {fromBlock, toBlock}).get(c)) 40 | console.log(events.length + ' transfer events for schema ' + schema.name + ' in first 10000 blocks') 41 | assert.equal(events.length > 0, true, 'No transfer events found in first 10000 blocks') 42 | }) 43 | } 44 | }) 45 | }) 46 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyENSShortNameAuction/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/rinkeby/rinkebyENSShortNameAuction/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,6CAK6B;AAC7B,0CAKwB;AAEX,QAAA,sCAAsC,GACjD,4CAA4C,CAAC;AAElC,QAAA,gCAAgC,mCACxC,uBAAiB,KACpB,OAAO,EAAE,CAAC,EACV,eAAe,EAAE,OAAO,EACxB,IAAI,EAAE,qBAAqB,EAC3B,WAAW,EAAE,0DAA0D,EACvE,SAAS,EAAE,EAAE,EACb,OAAO,EAAE,sBAAsB,EAC/B,SAAS,EAAE,CAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5B,OAAO;YACL,KAAK,EAAE,kBAAkB,GAAG,IAAI;YAChC,WAAW,EAAE,EAAE;YACf,GAAG,EAAE,EAAE;YACP,SAAS,EAAE,EAAE;YACb,UAAU,EAAE,EAAE;SACf,CAAC;IACJ,CAAC,CAAA,EACD,SAAS,EAAE;QACT,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACvB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,uBAAe,CAAC,UAAU;YAC3C,MAAM,EAAE,8CAAsC;YAC9C,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,yBAAiB,CAAC,IAAI;oBAC5B,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBAC1B;gBACD,EAAE,IAAI,EAAE,yBAAiB,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;aACxE;YACD,OAAO,EAAE,EAAE;SACZ,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB,EACD,MAAM,EAAE;QACN,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,wBAAO,CAAC,KAAK;gBACnB,IAAI,EAAE,gBAAgB;gBACtB,MAAM,EAAE,8CAAsC;gBAC9C,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,sBAAc,CAAC,KAAK;wBAC1B,OAAO,EAAE,KAAK;wBACd,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ;qBACf;oBACD;wBACE,IAAI,EAAE,sBAAc,CAAC,WAAW;wBAChC,OAAO,EAAE,KAAK;wBACd,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,SAAS;qBAChB;iBACF;gBACD,eAAe,EAAE,CAAO,MAAwB,EAAE,EAAE;oBAAC,OAAA,CAAC;wBACpD,IAAI,EAAE,MAAM,CAAC,IAAI;wBACjB,QAAQ,EAAE,IAAA,cAAQ,EAAC,MAAM,CAAC,IAAI,CAAC;wBAC/B,QAAQ,EAAE,IAAA,cAAQ,EAAC,MAAM,CAAC,IAAI,CAAC;qBAChC,CAAC,CAAA;kBAAA;aACH;SACF;KACF,IACD"} -------------------------------------------------------------------------------- /src/schemas/rinkeby/rinkebyCustom/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import { 3 | AnnotatedFunctionABI, 4 | Schema, 5 | } from '../../../types'; 6 | 7 | export interface RinkebyCustomType { 8 | name: string; 9 | description: string; 10 | thumbnail: string; 11 | url: string; 12 | transfer: AnnotatedFunctionABI; 13 | } 14 | 15 | export const rinkebyCustomSchema: Schema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'RinkebyCustom', 19 | description: 'Rinkeby Custom (manual ABI specification)', 20 | thumbnail: 'https://d30y9cdsu7xlg0.cloudfront.net/png/45447-200.png', 21 | website: 'https://github.com/projectwyvern/wyvern-schemas', 22 | fields: [ 23 | {name: 'Name', type: 'string', description: 'Name of Asset'}, 24 | {name: 'Description', type: 'string', description: 'Description of Asset'}, 25 | {name: 'Thumbnail', type: 'string', description: 'URL of asset thumbnail image'}, 26 | {name: 'URL', type: 'string', description: 'URL of asset'}, 27 | {name: 'Transfer', type: 'abi', description: 'ABI of transfer function'}, 28 | ], 29 | assetFromFields: (fields: any) => ({ 30 | name: fields.Name, 31 | description: fields.Description, 32 | thumbnail: fields.Thumbnail, 33 | url: fields.URL, 34 | transfer: fields.Transfer, 35 | }), 36 | formatter: 37 | async asset => { 38 | return { 39 | thumbnail: asset.thumbnail, 40 | title: asset.name, 41 | description: asset.description, 42 | url: asset.url, 43 | properties: [], 44 | }; 45 | }, 46 | functions: { 47 | transfer: asset => asset.transfer, 48 | assetsOfOwnerByIndex: [], 49 | }, 50 | events: { 51 | transfer: [], 52 | }, 53 | hash: a => JSON.stringify(a), 54 | }; 55 | -------------------------------------------------------------------------------- /dist/common/ens.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ens.js","sourceRoot":"","sources":["../../src/common/ens.ts"],"names":[],"mappings":";;;AAAA,qDAAuC;AAUhC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE;IACvC,IAAI,IAAI,GAAG,kEAAkE,CAAC;IAC9E,IAAI,IAAI,KAAK,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,KAAK,IAAI,CAAC,GAAG,MAAM,CA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AO;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,IAAA,gBAAQ,EAAC,MAAM,CAAC,IAAI,CAAC;QAC/B,QAAQ,EAAE,IAAA,gBAAQ,EAAC,MAAM,CAAC,IAAI,CAAC;KAChC,CAAC;IACF,UAAU,EAAE,CAAC,KAAc,EAAE,EAAE;QAC7B,OAAO,KAAK,CAAC,IAAI;YACf,CAAC,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,QAAQ;gBACrC,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,QAAQ;YAC3C,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IACD,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ;CACjC,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/main/OwnableContract/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/main/OwnableContract/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,0CAKwB;AAQX,QAAA,qBAAqB,GAAgC;IAChE,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,CAAC;IAClB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,8CAA8C;IAC3D,SAAS,EAAE,oHAAoH;IAC/H,OAAO,EAAE,+FAA+F;IACxG,MAAM,EAAE;QACN,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAC;QAC5D,EAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAC;QAC1E,EAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAC;KACpE;IACD,eAAe,EAAE,CAAC,MAAW,EAAE,EA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SAAS,EAAC;aACjE;SACF,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO;CACrB,CAAC"} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wyvern-schemas", 3 | "version": "0.14.1", 4 | "files": [ 5 | "dist" 6 | ], 7 | "main": "./dist/index.js", 8 | "description": "Nonfungible asset schemas for the Wyvern Protocol", 9 | "scripts": { 10 | "lint": "scripts/lint.sh", 11 | "dev": "scripts/dev.sh", 12 | "build": "scripts/build.sh", 13 | "test": "scripts/test.sh", 14 | "prepublish": "scripts/build.sh" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/ProjectWyvern/wyvern-schemas.git" 19 | }, 20 | "keywords": [ 21 | "ethereum", 22 | "project-wyvern", 23 | "smart-contracts" 24 | ], 25 | "author": "Project Wyvern Developers", 26 | "license": "MIT", 27 | "bugs": { 28 | "url": "https://github.com/ProjectWyvern/wyvern-schemas/issues" 29 | }, 30 | "homepage": "https://github.com/ProjectWyvern/wyvern-schemas#readme", 31 | "devDependencies": { 32 | "@0x/types": "^3.3.5", 33 | "@types/node": "16.11.0", 34 | "buffer": "^5.0.8", 35 | "ethereum-types": "^3.6.0", 36 | "ethereumjs-abi": "https://github.com/ProjectWyvern/ethereumjs-abi.git", 37 | "ethereumjs-util": "^5.1.3", 38 | "js-yaml": "^3.10.0", 39 | "jsonlint": "^1.6.2", 40 | "mocha": "^5.0.1", 41 | "ts-loader": "^3.3.0", 42 | "tslint": "^5.9.1", 43 | "tslint-eslint-rules": "^4.1.1", 44 | "types-bn": "^0.0.1", 45 | "types-ethereumjs-util": "^0.0.5", 46 | "typescript": "^4.5.4", 47 | "web3": "^0.20.4", 48 | "web3-provider-engine": "^13.6.5" 49 | }, 50 | "dependencies": { 51 | "axios": "^0.17.1", 52 | "bignumber.js": "9.0.2" 53 | }, 54 | "peerDependencies": { 55 | "wyvern-js": "git+https://github.com/ProjectOpenSea/wyvern-js.git#7429b1f2dd123f012cae1f3144a069e91ecd0682" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Project Wyvern Logo](https://media.githubusercontent.com/media/ProjectWyvern/wyvern-branding/master/logo/logo-square-red-transparent-200x200.png?raw=true "Project Wyvern Logo") 2 | 3 | ## Wyvern Protocol Nonfungible Asset Schemas 4 | 5 | [![https://badges.frapsoft.com/os/mit/mit.svg?v=102](https://badges.frapsoft.com/os/mit/mit.svg?v=102)](https://opensource.org/licenses/MIT) [![Build Status](https://travis-ci.org/ProjectWyvern/wyvern-ethereum.svg?branch=master)](https://travis-ci.org/ProjectWyvern/wyvern-schemas) [![npm](https://img.shields.io/npm/v/wyvern-schemas.svg)](https://www.npmjs.com/package/wyvern-schemas) [![npm](https://img.shields.io/npm/dt/wyvern-schemas.svg)](https://www.npmjs.com/package/wyvern-schemas) 6 | 7 | ### Synopsis 8 | 9 | Nonfungible asset schemas for the Wyvern Protocol, used directly by the [Wyvern Exchange](https://exchange.projectwyvern.com). 10 | 11 | ### Development Information 12 | 13 | #### Dependency Installation 14 | 15 | Install [Yarn](https://yarnpkg.com/en/) and update dependencies: 16 | 17 | ```bash 18 | yarn 19 | ``` 20 | 21 | #### Adding an Asset Schema 22 | 23 | Expect the schema format to undergo several revisions prior to release of the Exchange. For now, please submit a Github issue with the asset information. 24 | 25 | #### Linting & Schema Validation 26 | 27 | Run the lint script: 28 | 29 | ```bash 30 | yarn lint 31 | ``` 32 | 33 | #### Testing 34 | 35 | Build first, then test (tests are in vanilla JS) - you will need an internet connection, the testsuite makes RPC calls against Ethereum state via [Infura](https://infura.io): 36 | 37 | ```bash 38 | yarn build && yarn test 39 | ``` 40 | 41 | #### General Contribution 42 | 43 | Contributions welcome! Please use GitHub issues for suggestions/concerns - if you prefer to express your intentions in code, feel free to submit a pull request. 44 | -------------------------------------------------------------------------------- /src/common/ens.ts: -------------------------------------------------------------------------------- 1 | import { sha3 } from 'ethereumjs-util'; 2 | 3 | import { Schema } from '../types'; 4 | 5 | export interface ENSName { 6 | nodeHash: string; 7 | nameHash: string; 8 | name: string; 9 | } 10 | 11 | export const namehash = (name: string) => { 12 | let node = '0000000000000000000000000000000000000000000000000000000000000000'; 13 | if (name !== '') { 14 | const labels = name.split('.'); 15 | for (let i = labels.length - 1; i >= 0; i--) { 16 | const labelHash = sha3(labels[i]).toString('hex'); 17 | node = sha3(Buffer.from(node + labelHash, 'hex')).toString('hex'); 18 | } 19 | } 20 | return '0x' + node.toString(); 21 | }; 22 | 23 | export const nodehash = (name: string) => { 24 | const label = name.split('.')[0]; 25 | if (label) { 26 | return '0x' + sha3(label).toString('hex'); 27 | } else { 28 | return ''; 29 | } 30 | }; 31 | 32 | export const ENSNameBaseSchema: Required< 33 | Pick, 'fields' | 'assetFromFields' | 'checkAsset' | 'hash'> 34 | > = { 35 | fields: [ 36 | { name: 'Name', type: 'string', description: 'ENS Name' }, 37 | { 38 | name: 'NodeHash', 39 | type: 'bytes32', 40 | description: 'ENS Node Hash', 41 | readOnly: true, 42 | }, 43 | { 44 | name: 'NameHash', 45 | type: 'bytes32', 46 | description: 'ENS Name Hash', 47 | readOnly: true, 48 | }, 49 | ], 50 | assetFromFields: (fields: any) => ({ 51 | id: fields.ID, 52 | address: fields.Address, 53 | name: fields.Name, 54 | nodeHash: nodehash(fields.Name), 55 | nameHash: namehash(fields.Name), 56 | }), 57 | checkAsset: (asset: ENSName) => { 58 | return asset.name 59 | ? namehash(asset.name) === asset.nameHash && 60 | nodehash(asset.name) === asset.nodeHash 61 | : true; 62 | }, 63 | hash: ({ nodeHash }) => nodeHash, 64 | }; 65 | -------------------------------------------------------------------------------- /src/schemas/main/EnjinItem/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | FunctionInputKind, 5 | FunctionOutputKind, 6 | Schema, 7 | StateMutability, 8 | } from '../../../types'; 9 | import { ERC1155Schema, SemiFungibleTradeType } from '../../ERC1155'; 10 | 11 | export const EnjinItemSchema: Schema = { 12 | ...ERC1155Schema, 13 | version: 1, 14 | deploymentBlock: 0, // Not indexed (for now; need asset-specific indexing strategy) 15 | name: 'Enjin', 16 | description: 'Items conforming to the Enjin implementation of the ERC1155 spec.', 17 | website: 'https://enjincoin.io/', 18 | functions: { 19 | ...ERC1155Schema.functions, 20 | ownerOf: asset => ({ 21 | type: AbiType.Function, 22 | name: 'ownerOf', 23 | payable: false, 24 | constant: true, 25 | stateMutability: StateMutability.View, 26 | target: asset.address, 27 | inputs: [ 28 | {kind: FunctionInputKind.Asset, name: '_id', type: 'uint256', value: asset.id}, 29 | ], 30 | outputs: [ 31 | {kind: FunctionOutputKind.Owner, name: 'owner', type: 'address'}, 32 | ], 33 | }), 34 | // Parameters are flipped from 1155 35 | countOf: asset => ({ 36 | type: AbiType.Function, 37 | name: 'balanceOf', 38 | payable: false, 39 | constant: true, 40 | stateMutability: StateMutability.View, 41 | target: asset.address, 42 | inputs: [ 43 | {kind: FunctionInputKind.Asset, name: '_id', type: 'uint256', value: asset.id}, 44 | {kind: FunctionInputKind.Owner, name: '_owner', type: 'address'}, 45 | ], 46 | outputs: [ 47 | {kind: FunctionOutputKind.Count, name: 'balance', type: 'uint'}, 48 | ], 49 | assetFromOutputs: (outputs: any) => outputs.balance, 50 | }), 51 | assetsOfOwnerByIndex: [], 52 | }, 53 | }; 54 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.AbiType = exports.tokens = exports.schemas = exports.encodeReplacementPattern = exports.encodeDefaultCall = exports.encodeCall = exports.encodeAtomicizedSell = exports.encodeAtomicizedBuy = exports.encodeSell = exports.encodeBuy = void 0; 4 | var schemaFunctions_1 = require("./schemaFunctions"); 5 | Object.defineProperty(exports, "encodeBuy", { enumerable: true, get: function () { return schemaFunctions_1.encodeBuy; } }); 6 | Object.defineProperty(exports, "encodeSell", { enumerable: true, get: function () { return schemaFunctions_1.encodeSell; } }); 7 | Object.defineProperty(exports, "encodeAtomicizedBuy", { enumerable: true, get: function () { return schemaFunctions_1.encodeAtomicizedBuy; } }); 8 | Object.defineProperty(exports, "encodeAtomicizedSell", { enumerable: true, get: function () { return schemaFunctions_1.encodeAtomicizedSell; } }); 9 | Object.defineProperty(exports, "encodeCall", { enumerable: true, get: function () { return schemaFunctions_1.encodeCall; } }); 10 | Object.defineProperty(exports, "encodeDefaultCall", { enumerable: true, get: function () { return schemaFunctions_1.encodeDefaultCall; } }); 11 | Object.defineProperty(exports, "encodeReplacementPattern", { enumerable: true, get: function () { return schemaFunctions_1.encodeReplacementPattern; } }); 12 | var index_1 = require("./schemas/index"); 13 | Object.defineProperty(exports, "schemas", { enumerable: true, get: function () { return index_1.schemas; } }); 14 | var index_2 = require("./tokens/index"); 15 | Object.defineProperty(exports, "tokens", { enumerable: true, get: function () { return index_2.tokens; } }); 16 | var ethereum_types_1 = require("ethereum-types"); 17 | Object.defineProperty(exports, "AbiType", { enumerable: true, get: function () { return ethereum_types_1.AbiType; } }); 18 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/ContractRole/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/ContractRole/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,uCAKqB;AAUR,QAAA,kBAAkB,GAA6B;IAC1D,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,CAAC;IAClB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,yCAAyC;IACtD,SAAS,EAAE,oHAAoH;IAC/H,OAAO,EAAE,+FAA+F;IACxG,MAAM,EAAE;QACN,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAA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KAAK,CAAC,OAAO;YACrB,MAAM,EAAE;gBACN,EAAC,IAAI,EAAE,yBAAiB,CAAC,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAC;aACzE;YACD,OAAO,EAAE,EAAE;SACZ,CAAC;QACF,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,KAAK,CAAC,UAAU;YACtB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,uBAAe,CAAC,IAAI;YACrC,MAAM,EAAE,KAAK,CAAC,OAAO;YACrB,MAAM,EAAE,EAAE;YACV,OAAO,EAAE;gBACP,EAAC,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC;aACjE;SACF,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO;CACrB,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/ERC20/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/ERC20/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,uCAKqB;AAOR,QAAA,WAAW,GAA8B;IACpD,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,CAAC;IAClB,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,yDAAyD;IACtE,SAAS,EAAE,mDAAmD;IAC9D,OAAO,EAAE,4CAA4C;IACrD,MAAM,EAAE;QACN,EAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAwB,EAAC;QACzE,EAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS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OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,uBAAe,CAAC,IAAI;YACrC,MAAM,EAAE,KAAK,CAAC,OAAO;YACrB,MAAM,EAAE;gBACN,EAAC,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAC;aACjE;YACD,OAAO,EAAE;gBACP,EAAC,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC;aAChE;YACD,gBAAgB,EAAE,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO;SACpD,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO;CAC7B,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/main/EnjinItem/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.EnjinItemSchema = void 0; 4 | const ethereum_types_1 = require("ethereum-types"); 5 | const types_1 = require("../../../types"); 6 | const ERC1155_1 = require("../../ERC1155"); 7 | exports.EnjinItemSchema = Object.assign(Object.assign({}, ERC1155_1.ERC1155Schema), { version: 1, deploymentBlock: 0, name: 'Enjin', description: 'Items conforming to the Enjin implementation of the ERC1155 spec.', website: 'https://enjincoin.io/', functions: Object.assign(Object.assign({}, ERC1155_1.ERC1155Schema.functions), { ownerOf: asset => ({ 8 | type: ethereum_types_1.AbiType.Function, 9 | name: 'ownerOf', 10 | payable: false, 11 | constant: true, 12 | stateMutability: types_1.StateMutability.View, 13 | target: asset.address, 14 | inputs: [ 15 | { kind: types_1.FunctionInputKind.Asset, name: '_id', type: 'uint256', value: asset.id }, 16 | ], 17 | outputs: [ 18 | { kind: types_1.FunctionOutputKind.Owner, name: 'owner', type: 'address' }, 19 | ], 20 | }), 21 | // Parameters are flipped from 1155 22 | countOf: asset => ({ 23 | type: ethereum_types_1.AbiType.Function, 24 | name: 'balanceOf', 25 | payable: false, 26 | constant: true, 27 | stateMutability: types_1.StateMutability.View, 28 | target: asset.address, 29 | inputs: [ 30 | { kind: types_1.FunctionInputKind.Asset, name: '_id', type: 'uint256', value: asset.id }, 31 | { kind: types_1.FunctionInputKind.Owner, name: '_owner', type: 'address' }, 32 | ], 33 | outputs: [ 34 | { kind: types_1.FunctionOutputKind.Count, name: 'balance', type: 'uint' }, 35 | ], 36 | assetFromOutputs: (outputs) => outputs.balance, 37 | }), assetsOfOwnerByIndex: [] }) }); 38 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/common/ens.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.ENSNameBaseSchema = exports.nodehash = exports.namehash = void 0; 4 | const ethereumjs_util_1 = require("ethereumjs-util"); 5 | const namehash = (name) => { 6 | let node = '0000000000000000000000000000000000000000000000000000000000000000'; 7 | if (name !== '') { 8 | const labels = name.split('.'); 9 | for (let i = labels.length - 1; i >= 0; i--) { 10 | const labelHash = (0, ethereumjs_util_1.sha3)(labels[i]).toString('hex'); 11 | node = (0, ethereumjs_util_1.sha3)(Buffer.from(node + labelHash, 'hex')).toString('hex'); 12 | } 13 | } 14 | return '0x' + node.toString(); 15 | }; 16 | exports.namehash = namehash; 17 | const nodehash = (name) => { 18 | const label = name.split('.')[0]; 19 | if (label) { 20 | return '0x' + (0, ethereumjs_util_1.sha3)(label).toString('hex'); 21 | } 22 | else { 23 | return ''; 24 | } 25 | }; 26 | exports.nodehash = nodehash; 27 | exports.ENSNameBaseSchema = { 28 | fields: [ 29 | { name: 'Name', type: 'string', description: 'ENS Name' }, 30 | { 31 | name: 'NodeHash', 32 | type: 'bytes32', 33 | description: 'ENS Node Hash', 34 | readOnly: true, 35 | }, 36 | { 37 | name: 'NameHash', 38 | type: 'bytes32', 39 | description: 'ENS Name Hash', 40 | readOnly: true, 41 | }, 42 | ], 43 | assetFromFields: (fields) => ({ 44 | id: fields.ID, 45 | address: fields.Address, 46 | name: fields.Name, 47 | nodeHash: (0, exports.nodehash)(fields.Name), 48 | nameHash: (0, exports.namehash)(fields.Name), 49 | }), 50 | checkAsset: (asset) => { 51 | return asset.name 52 | ? (0, exports.namehash)(asset.name) === asset.nameHash && 53 | (0, exports.nodehash)(asset.name) === asset.nodeHash 54 | : true; 55 | }, 56 | hash: ({ nodeHash }) => nodeHash, 57 | }; 58 | //# sourceMappingURL=ens.js.map -------------------------------------------------------------------------------- /src/schemas/rinkeby/rinkebyENSName/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { ENSName, ENSNameBaseSchema } from '../../../common/ens'; 4 | import { 5 | FunctionInputKind, 6 | FunctionOutputKind, 7 | Schema, 8 | StateMutability, 9 | } from '../../../types'; 10 | 11 | export const rinkebyENSNameSchema: Schema = { 12 | ...ENSNameBaseSchema, 13 | version: 1, 14 | deploymentBlock: 0, 15 | name: 'ENSName', 16 | description: 'Rinkeby Ethereum Name Service (EIP 137)', 17 | thumbnail: 'https://ens.domains/img/ens.svg', 18 | website: 'https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md', 19 | formatter: 20 | async asset => { 21 | return { 22 | thumbnail: 'https://ens.domains/img/ens.svg', 23 | title: 'ENS Name ' + asset.name, 24 | description: '(ENS node ' + asset.nodeHash + ')', 25 | url: 'https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md', 26 | properties: [], 27 | }; 28 | }, 29 | functions: { 30 | transfer: asset => ({ 31 | type: AbiType.Function, 32 | name: 'setOwner', 33 | payable: false, 34 | constant: false, 35 | stateMutability: StateMutability.Nonpayable, 36 | target: '0xe7410170f87102df0055eb195163a03b7f2bff4a', 37 | inputs: [ 38 | {kind: FunctionInputKind.Asset, name: 'node', type: 'bytes32', value: asset.nodeHash }, 39 | {kind: FunctionInputKind.Replaceable, name: 'owner', type: 'address'}, 40 | ], 41 | outputs: [], 42 | }), 43 | ownerOf: asset => ({ 44 | type: AbiType.Function, 45 | name: 'owner', 46 | payable: false, 47 | constant: true, 48 | stateMutability: StateMutability.View, 49 | target: '0xe7410170f87102df0055eb195163a03b7f2bff4a', 50 | inputs: [ 51 | {kind: FunctionInputKind.Asset, name: 'node', type: 'bytes32', value: asset.nodeHash}, 52 | ], 53 | outputs: [ 54 | {kind: FunctionOutputKind.Owner, name: '', type: 'address'}, 55 | ], 56 | }), 57 | assetsOfOwnerByIndex: [], 58 | }, 59 | events: { 60 | transfer: [], 61 | }, 62 | }; 63 | -------------------------------------------------------------------------------- /dist/types.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.EventInputKind = exports.FunctionOutputKind = exports.StateMutability = exports.ABIType = exports.Network = exports.FunctionInputKind = exports.AnnotatedFunctionABI = exports.AnnotatedFunctionInput = void 0; 4 | const types_1 = require("wyvern-js/lib/types"); 5 | Object.defineProperty(exports, "AnnotatedFunctionABI", { enumerable: true, get: function () { return types_1.AnnotatedFunctionABI; } }); 6 | Object.defineProperty(exports, "AnnotatedFunctionInput", { enumerable: true, get: function () { return types_1.AnnotatedFunctionInput; } }); 7 | Object.defineProperty(exports, "FunctionInputKind", { enumerable: true, get: function () { return types_1.FunctionInputKind; } }); 8 | var Network; 9 | (function (Network) { 10 | Network["Main"] = "main"; 11 | Network["Rinkeby"] = "rinkeby"; 12 | Network["Goerli"] = "goerli"; 13 | Network["Kovan"] = "kovan"; 14 | })(Network = exports.Network || (exports.Network = {})); 15 | var ABIType; 16 | (function (ABIType) { 17 | ABIType["Function"] = "function"; 18 | ABIType["Event"] = "event"; 19 | })(ABIType = exports.ABIType || (exports.ABIType = {})); 20 | var StateMutability; 21 | (function (StateMutability) { 22 | StateMutability["Pure"] = "pure"; 23 | StateMutability["View"] = "view"; 24 | StateMutability["Payable"] = "payable"; 25 | StateMutability["Nonpayable"] = "nonpayable"; 26 | })(StateMutability = exports.StateMutability || (exports.StateMutability = {})); 27 | var FunctionOutputKind; 28 | (function (FunctionOutputKind) { 29 | FunctionOutputKind["Owner"] = "owner"; 30 | FunctionOutputKind["Asset"] = "asset"; 31 | FunctionOutputKind["Count"] = "count"; 32 | FunctionOutputKind["Other"] = "other"; 33 | })(FunctionOutputKind = exports.FunctionOutputKind || (exports.FunctionOutputKind = {})); 34 | var EventInputKind; 35 | (function (EventInputKind) { 36 | EventInputKind["Source"] = "source"; 37 | EventInputKind["Destination"] = "destination"; 38 | EventInputKind["Asset"] = "asset"; 39 | EventInputKind["Other"] = "other"; 40 | })(EventInputKind = exports.EventInputKind || (exports.EventInputKind = {})); 41 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /dist/schemas/main/CryptoPunks/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/main/CryptoPunks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,0CAMwB;AAIX,QAAA,iBAAiB,GAA4B;IACxD,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,OAAO;IACxB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,iGAAiG;IAC9G,SAAS,EAAE,0DAA0D;IACrE,OAAO,EAAE,uCAAuC;IAChD,MAAM,EAAE;QACN,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,oBAAoB,EAAC;KACjE;IACD,eAAe,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE;IAC3C,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,EAAC,EAAE,EAAE,K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AAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAC;aAC5D;SACF,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,CAAC;gBACT,IAAI,EAAE,wBAAO,CAAC,KAAK;gBACnB,IAAI,EAAE,cAAc;gBACpB,MAAM,EAAE,4CAA4C;gBACpD,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE;oBACN,EAAC,IAAI,EAAE,sBAAc,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC3E,EAAC,IAAI,EAAE,sBAAc,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC9E,EAAC,IAAI,EAAE,sBAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAC;iBACjF;gBACD,eAAe,EAAE,CAAO,MAAW,EAAE,EAAE,kDAAC,OAAA,MAAM,CAAC,SAAS,CAAA,GAAA;aACzD,CAAC;KACH;IACD,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CACb,CAAC"} -------------------------------------------------------------------------------- /dist/schemas/rinkeby/testRinkebyNFT/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/rinkeby/testRinkebyNFT/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,0CAMwB;AAIX,QAAA,oBAAoB,GAA+B;IAC9D,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,CAAC;IAClB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,+DAA+D;IAC5E,SAAS,EAAE,qFAAqF;IAChG,OAAO,EAAE,2BAA2B;IACpC,MAAM,EAAE;QACN,EAAC,IAAI,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BAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAC;aACjF;YACD,OAAO,EAAE;gBACP,EAAC,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAC;aAClE;SACF,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,CAAC;gBACT,IAAI,EAAE,wBAAO,CAAC,KAAK;gBACnB,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,4CAA4C;gBACpD,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE;oBACN,EAAC,IAAI,EAAE,sBAAc,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC5E,EAAC,IAAI,EAAE,sBAAc,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC/E,EAAC,IAAI,EAAE,sBAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAC;iBAChF;gBACD,eAAe,EAAE,CAAO,MAAW,EAAE,EAAE,kDAAC,OAAA,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA,GAAA;aACnE,CAAC;KACH;IACD,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CACb,CAAC"} -------------------------------------------------------------------------------- /src/schemas/main/ENSName/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { ENSName, ENSNameBaseSchema } from '../../../common/ens'; 4 | import { 5 | FunctionInputKind, 6 | FunctionOutputKind, 7 | Schema, 8 | StateMutability, 9 | } from '../../../types'; 10 | 11 | export const ENSNameSchema: Schema = { 12 | ...ENSNameBaseSchema, 13 | version: 2, 14 | deploymentBlock: 3605331, 15 | name: 'ENSName', 16 | description: 'Ethereum Name Service Name (EIP 137)', 17 | thumbnail: 'https://ens.domains/img/ens.svg', 18 | website: 'https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md', 19 | formatter: async asset => { 20 | return { 21 | thumbnail: 'https://ens.domains/img/ens.svg', 22 | title: 23 | 'ENS Name ' + 24 | (asset.name ? asset.name : asset.nodeHash.slice(0, 4) + '...'), 25 | description: 'ENS node ' + asset.nodeHash, 26 | url: 'https://etherscan.io/enslookup?q=' + asset.name, 27 | properties: [], 28 | }; 29 | }, 30 | functions: { 31 | transfer: asset => ({ 32 | type: AbiType.Function, 33 | name: 'transfer', 34 | payable: false, 35 | constant: false, 36 | stateMutability: StateMutability.Nonpayable, 37 | target: '0x6090a6e47849629b7245dfa1ca21d94cd15878ef', 38 | inputs: [ 39 | { 40 | kind: FunctionInputKind.Asset, 41 | name: '_hash', 42 | type: 'bytes32', 43 | value: asset.nodeHash, 44 | }, 45 | { 46 | kind: FunctionInputKind.Replaceable, 47 | name: 'newOwner', 48 | type: 'address', 49 | }, 50 | ], 51 | outputs: [], 52 | }), 53 | ownerOf: asset => ({ 54 | type: AbiType.Function, 55 | name: 'owner', 56 | payable: false, 57 | constant: true, 58 | stateMutability: StateMutability.View, 59 | target: '0x314159265dD8dbb310642f98f50C066173C1259b', 60 | inputs: [ 61 | { 62 | kind: FunctionInputKind.Asset, 63 | name: 'node', 64 | type: 'bytes32', 65 | value: asset.nameHash, 66 | }, 67 | ], 68 | outputs: [{ kind: FunctionOutputKind.Owner, name: '', type: 'address' }], 69 | }), 70 | assetsOfOwnerByIndex: [], 71 | }, 72 | events: { 73 | transfer: [], 74 | }, 75 | }; 76 | -------------------------------------------------------------------------------- /src/schemas/rinkeby/rinkebyOwnableContract/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | FunctionInputKind, 5 | FunctionOutputKind, 6 | Schema, 7 | StateMutability, 8 | } from '../../../types'; 9 | 10 | export interface RinkebyOwnableContractType { 11 | name?: string; 12 | address: string; 13 | } 14 | 15 | export const rinkebyOwnableContractSchema: Schema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'OwnableContract', 19 | description: 'Rinkeby Ownable Smart Contract', 20 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 21 | website: 'https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/ownership/Ownable.sol', 22 | fields: [ 23 | {name: 'Name', type: 'string', description: 'Contract Name'}, 24 | {name: 'Address', type: 'address', description: 'Contract Address'}, 25 | ], 26 | assetFromFields: (fields: any) => ({ 27 | name: fields.Name, 28 | address: fields.Address, 29 | }), 30 | formatter: 31 | async asset => { 32 | return { 33 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 34 | title: 'Ownable Contract: "' + asset.name + '"', 35 | description: 'Ownable at address ' + asset.address, 36 | url: 'https://rinkeby.etherscan.io/address/' + asset.address, 37 | properties: [], 38 | }; 39 | }, 40 | functions: { 41 | transfer: asset => ({ 42 | type: AbiType.Function, 43 | name: 'transferOwnership', 44 | payable: false, 45 | constant: false, 46 | stateMutability: StateMutability.Nonpayable, 47 | target: asset.address, 48 | inputs: [ 49 | {kind: FunctionInputKind.Replaceable, name: 'newOwner', type: 'address'}, 50 | ], 51 | outputs: [], 52 | }), 53 | ownerOf: asset => ({ 54 | type: AbiType.Function, 55 | name: 'owner', 56 | payable: false, 57 | constant: true, 58 | stateMutability: StateMutability.View, 59 | target: asset.address, 60 | inputs: [], 61 | outputs: [ 62 | {kind: FunctionOutputKind.Owner, name: 'owner', type: 'address'}, 63 | ], 64 | }), 65 | assetsOfOwnerByIndex: [], 66 | }, 67 | events: { 68 | transfer: [], 69 | }, 70 | hash: a => a.address, 71 | }; 72 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyCustom/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.rinkebyCustomSchema = void 0; 13 | exports.rinkebyCustomSchema = { 14 | version: 1, 15 | deploymentBlock: 0, 16 | name: 'RinkebyCustom', 17 | description: 'Rinkeby Custom (manual ABI specification)', 18 | thumbnail: 'https://d30y9cdsu7xlg0.cloudfront.net/png/45447-200.png', 19 | website: 'https://github.com/projectwyvern/wyvern-schemas', 20 | fields: [ 21 | { name: 'Name', type: 'string', description: 'Name of Asset' }, 22 | { name: 'Description', type: 'string', description: 'Description of Asset' }, 23 | { name: 'Thumbnail', type: 'string', description: 'URL of asset thumbnail image' }, 24 | { name: 'URL', type: 'string', description: 'URL of asset' }, 25 | { name: 'Transfer', type: 'abi', description: 'ABI of transfer function' }, 26 | ], 27 | assetFromFields: (fields) => ({ 28 | name: fields.Name, 29 | description: fields.Description, 30 | thumbnail: fields.Thumbnail, 31 | url: fields.URL, 32 | transfer: fields.Transfer, 33 | }), 34 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 35 | return { 36 | thumbnail: asset.thumbnail, 37 | title: asset.name, 38 | description: asset.description, 39 | url: asset.url, 40 | properties: [], 41 | }; 42 | }), 43 | functions: { 44 | transfer: asset => asset.transfer, 45 | assetsOfOwnerByIndex: [], 46 | }, 47 | events: { 48 | transfer: [], 49 | }, 50 | hash: a => JSON.stringify(a), 51 | }; 52 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/schemas/main/ENSShortNameAuction/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | ENSName, 5 | ENSNameBaseSchema, 6 | namehash, 7 | nodehash, 8 | } from '../../../common/ens'; 9 | import { 10 | EventInputKind, 11 | FunctionInputKind, 12 | Schema, 13 | StateMutability, 14 | } from '../../../types'; 15 | 16 | export const ENS_SHORT_NAME_AUCTION_ADDRESS = 17 | '0x699c7f511c9e2182e89f29b3bfb68bd327919d17'; 18 | 19 | export const ENSShortNameAuctionSchema: Schema = { 20 | ...ENSNameBaseSchema, 21 | version: 0, 22 | deploymentBlock: 8488908, 23 | name: 'ENSShortNameAuction', 24 | description: 'ERC721 ENS short (3-6 character) names sold via auction.', 25 | thumbnail: '', // TODO: put SVG body directly here or host a PNG ourselves? 26 | website: 'https://ens.domains/', 27 | formatter: async ({ name }) => { 28 | return { 29 | title: 'ENS Short Name: ' + name, 30 | description: '', 31 | url: '', 32 | thumbnail: '', 33 | properties: [], 34 | }; 35 | }, 36 | functions: { 37 | transfer: ({ name }) => ({ 38 | type: AbiType.Function, 39 | name: 'register', 40 | payable: false, 41 | constant: false, 42 | stateMutability: StateMutability.Nonpayable, 43 | target: ENS_SHORT_NAME_AUCTION_ADDRESS, 44 | inputs: [ 45 | { 46 | kind: FunctionInputKind.Data, 47 | name: 'name', 48 | type: 'string', 49 | value: name.split('.')[0], 50 | }, 51 | { kind: FunctionInputKind.Replaceable, name: 'owner', type: 'address' }, 52 | ], 53 | outputs: [], 54 | }), 55 | assetsOfOwnerByIndex: [], 56 | }, 57 | events: { 58 | transfer: [ 59 | { 60 | type: AbiType.Event, 61 | name: 'NameRegistered', 62 | target: ENS_SHORT_NAME_AUCTION_ADDRESS, 63 | anonymous: false, 64 | inputs: [ 65 | { 66 | kind: EventInputKind.Asset, 67 | indexed: false, 68 | name: 'name', 69 | type: 'string', 70 | }, 71 | { 72 | kind: EventInputKind.Destination, 73 | indexed: false, 74 | name: 'owner', 75 | type: 'address', 76 | }, 77 | ], 78 | assetFromInputs: async (inputs: { name: string }) => ({ 79 | name: inputs.name, 80 | nodeHash: nodehash(inputs.name), 81 | nameHash: namehash(inputs.name), 82 | }), 83 | }, 84 | ], 85 | }, 86 | }; 87 | -------------------------------------------------------------------------------- /src/schemas/rinkeby/rinkebyENSShortNameAuction/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | ENSName, 5 | ENSNameBaseSchema, 6 | namehash, 7 | nodehash, 8 | } from '../../../common/ens'; 9 | import { 10 | EventInputKind, 11 | FunctionInputKind, 12 | Schema, 13 | StateMutability, 14 | } from '../../../types'; 15 | 16 | export const RINKEBY_ENS_SHORT_NAME_AUCTION_ADDRESS = 17 | '0x76b6481a334783be36f2fc35b8f0b9bc7835d57b'; 18 | 19 | export const rinkebyENSShortNameAuctionSchema: Schema = { 20 | ...ENSNameBaseSchema, 21 | version: 0, 22 | deploymentBlock: 4791629, 23 | name: 'ENSShortNameAuction', 24 | description: 'ERC721 ENS short (3-6 character) names sold via auction.', 25 | thumbnail: '', // TODO: put SVG body directly here or host a PNG ourselves? 26 | website: 'https://ens.domains/', 27 | formatter: async ({ name }) => { 28 | return { 29 | title: 'ENS Short Name: ' + name, 30 | description: '', 31 | url: '', 32 | thumbnail: '', 33 | properties: [], 34 | }; 35 | }, 36 | functions: { 37 | transfer: ({ name }) => ({ 38 | type: AbiType.Function, 39 | name: 'register', 40 | payable: false, 41 | constant: false, 42 | stateMutability: StateMutability.Nonpayable, 43 | target: RINKEBY_ENS_SHORT_NAME_AUCTION_ADDRESS, 44 | inputs: [ 45 | { 46 | kind: FunctionInputKind.Data, 47 | name: 'name', 48 | type: 'string', 49 | value: name.split('.')[0], 50 | }, 51 | { kind: FunctionInputKind.Replaceable, name: 'owner', type: 'address' }, 52 | ], 53 | outputs: [], 54 | }), 55 | assetsOfOwnerByIndex: [], 56 | }, 57 | events: { 58 | transfer: [ 59 | { 60 | type: AbiType.Event, 61 | name: 'NameRegistered', 62 | target: RINKEBY_ENS_SHORT_NAME_AUCTION_ADDRESS, 63 | anonymous: false, 64 | inputs: [ 65 | { 66 | kind: EventInputKind.Asset, 67 | indexed: false, 68 | name: 'name', 69 | type: 'string', 70 | }, 71 | { 72 | kind: EventInputKind.Destination, 73 | indexed: false, 74 | name: 'owner', 75 | type: 'address', 76 | }, 77 | ], 78 | assetFromInputs: async (inputs: { name: string }) => ({ 79 | name: inputs.name, 80 | nodeHash: nodehash(inputs.name), 81 | nameHash: namehash(inputs.name), 82 | }), 83 | }, 84 | ], 85 | }, 86 | }; 87 | -------------------------------------------------------------------------------- /src/schemas/ERC20/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | FunctionInputKind, 5 | FunctionOutputKind, 6 | Schema, 7 | StateMutability 8 | } from '../../types'; 9 | 10 | export interface FungibleTradeType { 11 | address: string; 12 | quantity: string; 13 | } 14 | 15 | export const ERC20Schema: Schema = { 16 | version: 1, 17 | deploymentBlock: 0, // Not indexed (for now; need asset-specific indexing strategy) 18 | name: 'ERC20', 19 | description: 'Items conforming to the ERC20 spec, using transferFrom.', 20 | thumbnail: 'https://opensea.io/static/images/opensea-icon.png', 21 | website: 'https://github.com/ethereum/eips/issues/20', 22 | fields: [ 23 | {name: 'Address', type: 'address', description: 'Asset Contract Address'}, 24 | {name: 'Quantity', type: 'uint256', description: 'Quantity to transfer'}, 25 | ], 26 | assetFromFields: (fields: any) => ({ 27 | address: fields.Address, 28 | quantity: fields.Quantity, 29 | }), 30 | assetToFields: asset => ({ 31 | Address: asset.address, 32 | Quantity: asset.quantity, 33 | }), 34 | formatter: 35 | async asset => { 36 | return { 37 | title: 'ERC20 Asset at ' + asset.address, 38 | description: 'Trading ' + asset.quantity.toString(), 39 | url: '', 40 | thumbnail: '', 41 | properties: [], 42 | }; 43 | }, 44 | functions: { 45 | transfer: asset => ({ 46 | type: AbiType.Function, 47 | name: 'transferFrom', 48 | payable: false, 49 | constant: false, 50 | stateMutability: StateMutability.Nonpayable, 51 | target: asset.address, 52 | inputs: [ 53 | {kind: FunctionInputKind.Owner, name: '_from', type: 'address'}, 54 | {kind: FunctionInputKind.Replaceable, name: '_to', type: 'address'}, 55 | {kind: FunctionInputKind.Count, name: '_value', type: 'uint256', value: asset.quantity }, 56 | ], 57 | outputs: [], 58 | }), 59 | countOf: asset => ({ 60 | type: AbiType.Function, 61 | name: 'balanceOf', 62 | payable: false, 63 | constant: true, 64 | stateMutability: StateMutability.View, 65 | target: asset.address, 66 | inputs: [ 67 | {kind: FunctionInputKind.Owner, name: '_owner', type: 'address'}, 68 | ], 69 | outputs: [ 70 | {kind: FunctionOutputKind.Count, name: 'balance', type: 'uint'}, 71 | ], 72 | assetFromOutputs: (outputs: any) => outputs.balance, 73 | }), 74 | assetsOfOwnerByIndex: [], 75 | }, 76 | events: { 77 | transfer: [], 78 | }, 79 | hash: asset => asset.address, 80 | }; 81 | -------------------------------------------------------------------------------- /src/schemas/main/OwnableContract/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | FunctionInputKind, 5 | FunctionOutputKind, 6 | Schema, 7 | StateMutability, 8 | } from '../../../types'; 9 | 10 | export interface OwnableContractType { 11 | name?: string; 12 | description?: string; 13 | address: string; 14 | } 15 | 16 | export const OwnableContractSchema: Schema = { 17 | version: 1, 18 | deploymentBlock: 0, // Not indexed (for now; need asset-specific indexing strategy) 19 | name: 'OwnableContract', 20 | description: 'Smart contract with transferrable ownership.', 21 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 22 | website: 'https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/ownership/Ownable.sol', 23 | fields: [ 24 | {name: 'Name', type: 'string', description: 'Contract Name'}, 25 | {name: 'Description', type: 'string', description: 'Contract Description'}, 26 | {name: 'Address', type: 'address', description: 'Contract Address'}, 27 | ], 28 | assetFromFields: (fields: any) => ({ 29 | name: fields.Name, 30 | address: fields.Address, 31 | description: fields.Description, 32 | }), 33 | formatter: 34 | async asset => { 35 | return { 36 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 37 | title: 'Smart Contract: "' + asset.name + '"', 38 | description: asset.description || ('Ownable smart contract at ' + asset.address), 39 | url: 'https://etherscan.io/address/' + asset.address, 40 | properties: [], 41 | }; 42 | }, 43 | functions: { 44 | transfer: asset => ({ 45 | type: AbiType.Function, 46 | name: 'transferOwnership', 47 | payable: false, 48 | constant: false, 49 | stateMutability: StateMutability.Nonpayable, 50 | target: asset.address, 51 | inputs: [ 52 | {kind: FunctionInputKind.Replaceable, name: 'newOwner', type: 'address'}, 53 | ], 54 | outputs: [], 55 | }), 56 | ownerOf: asset => ({ 57 | type: AbiType.Function, 58 | name: 'owner', 59 | payable: false, 60 | constant: true, 61 | stateMutability: StateMutability.View, 62 | target: asset.address, 63 | inputs: [], 64 | outputs: [ 65 | {kind: FunctionOutputKind.Owner, name: 'owner', type: 'address'}, 66 | ], 67 | }), 68 | assetsOfOwnerByIndex: [], 69 | }, 70 | events: { 71 | transfer: [], 72 | }, 73 | hash: a => a.address, 74 | }; 75 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyCryptoKitties/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/rinkeby/rinkebyCryptoKitties/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mD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C;qBAC1B;gBACH,CAAC;aACF,CAAC;KACH;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,CAAC;gBACT,IAAI,EAAE,wBAAO,CAAC,KAAK;gBACnB,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,4CAA4C;gBACpD,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE;oBACN,EAAC,IAAI,EAAE,sBAAc,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC3E,EAAC,IAAI,EAAE,sBAAc,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC9E,EAAC,IAAI,EAAE,sBAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAC;iBAC9E;gBACD,eAAe,EAAE,CAAO,MAAW,EAAE,EAAE,kDAAC,OAAA,MAAM,CAAC,OAAO,CAAA,GAAA;aACvD,CAAC;KACH;IACD,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CACb,CAAC"} -------------------------------------------------------------------------------- /src/schemas/main/CryptoPunks/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | EventInputKind, 5 | FunctionInputKind, 6 | FunctionOutputKind, 7 | Schema, 8 | StateMutability, 9 | } from '../../../types'; 10 | 11 | export type CryptoPunksType = string; 12 | 13 | export const CryptoPunksSchema: Schema = { 14 | version: 1, 15 | deploymentBlock: 3914495, 16 | name: 'CryptoPunks', 17 | description: '10,000 unique collectible characters with proof of ownership stored on the Ethereum blockchain.', 18 | thumbnail: 'https://www.larvalabs.com/cryptopunks/cryptopunk2838.png', 19 | website: 'https://www.larvalabs.com/cryptopunks', 20 | fields: [ 21 | {name: 'ID', type: 'uint256', description: 'CryptoPunk number.'}, 22 | ], 23 | assetFromFields: (fields: any) => fields.ID, 24 | assetToFields: asset => ({ID: asset}), 25 | formatter: 26 | async asset => { 27 | return { 28 | thumbnail: 'https://www.larvalabs.com/cryptopunks/cryptopunk' + asset + '.png', 29 | title: 'CryptoPunk #' + asset, 30 | description: '', 31 | url: 'https://www.larvalabs.com/cryptopunks/details/' + asset, 32 | properties: [], 33 | }; 34 | }, 35 | functions: { 36 | transfer: asset => ({ 37 | type: AbiType.Function, 38 | name: 'transferPunk', 39 | payable: false, 40 | constant: false, 41 | stateMutability: StateMutability.Nonpayable, 42 | target: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb', 43 | inputs: [ 44 | {kind: FunctionInputKind.Replaceable, name: 'to', type: 'address'}, 45 | {kind: FunctionInputKind.Asset, name: 'punkIndex', type: 'uint256', value: asset}, 46 | ], 47 | outputs: [], 48 | }), 49 | ownerOf: asset => ({ 50 | type: AbiType.Function, 51 | name: 'punkIndexToAddress', 52 | payable: false, 53 | constant: true, 54 | stateMutability: StateMutability.View, 55 | target: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb', 56 | inputs: [ 57 | {kind: FunctionInputKind.Asset, name: '', type: 'uint256', value: asset}, 58 | ], 59 | outputs: [ 60 | {kind: FunctionOutputKind.Owner, name: '', type: 'address'}, 61 | ], 62 | }), 63 | assetsOfOwnerByIndex: [], 64 | }, 65 | events: { 66 | transfer: [{ 67 | type: AbiType.Event, 68 | name: 'PunkTransfer', 69 | target: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb', 70 | anonymous: false, 71 | inputs: [ 72 | {kind: EventInputKind.Source, indexed: true, name: 'from', type: 'address'}, 73 | {kind: EventInputKind.Destination, indexed: true, name: 'to', type: 'address'}, 74 | {kind: EventInputKind.Asset, indexed: false, name: 'punkIndex', type: 'uint256'}, 75 | ], 76 | assetFromInputs: async (inputs: any) => inputs.punkIndex, 77 | }], 78 | }, 79 | hash: a => a, 80 | }; 81 | -------------------------------------------------------------------------------- /src/schemas/rinkeby/testRinkebyNFT/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | EventInputKind, 5 | FunctionInputKind, 6 | FunctionOutputKind, 7 | Schema, 8 | StateMutability, 9 | } from '../../../types'; 10 | 11 | export type TestRinkebyNFTType = string; 12 | 13 | export const testRinkebyNFTSchema: Schema = { 14 | version: 1, 15 | deploymentBlock: 0, 16 | name: 'TestRinkebyNFT', 17 | description: 'Rinkeby ERC721 non-fungible token for Wyvern Exchange testing', 18 | thumbnail: 'https://cointelegraph.com/storage/uploads/view/f88e17e41f607dc0aef238230dd40cc6.png', 19 | website: 'https://projectwyvern.com', 20 | fields: [ 21 | {name: 'ID', type: 'uint256', description: 'Token identification number.'}, 22 | ], 23 | assetFromFields: (fields: any) => fields.ID, 24 | assetToFields: asset => ({ID: asset}), 25 | formatter: 26 | async asset => { 27 | return { 28 | thumbnail: 'https://cointelegraph.com/storage/uploads/view/f88e17e41f607dc0aef238230dd40cc6.png', 29 | title: 'TestRinkebyNFT #' + asset, 30 | description: 'A useless NFT!', 31 | url: 'https://www.projectwyvern.com', 32 | properties: [], 33 | }; 34 | }, 35 | functions: { 36 | transfer: asset => ({ 37 | type: AbiType.Function, 38 | name: 'transfer', 39 | payable: false, 40 | constant: false, 41 | stateMutability: StateMutability.Nonpayable, 42 | target: '0x07a6dc6e3f1120ca03658d473d10aee3af5f8abb', 43 | inputs: [ 44 | {kind: FunctionInputKind.Replaceable, name: '_to', type: 'address'}, 45 | {kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset}, 46 | ], 47 | outputs: [], 48 | }), 49 | ownerOf: asset => ({ 50 | type: AbiType.Function, 51 | name: 'ownerOf', 52 | payable: false, 53 | constant: true, 54 | stateMutability: StateMutability.View, 55 | target: '0x07a6dc6e3f1120ca03658d473d10aee3af5f8abb', 56 | inputs: [ 57 | {kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset}, 58 | ], 59 | outputs: [ 60 | {kind: FunctionOutputKind.Owner, name: '_owner', type: 'address'}, 61 | ], 62 | }), 63 | assetsOfOwnerByIndex: [], 64 | }, 65 | events: { 66 | transfer: [{ 67 | type: AbiType.Event, 68 | name: 'Transfer', 69 | target: '0x07a6dc6e3f1120ca03658d473d10aee3af5f8abb', 70 | anonymous: false, 71 | inputs: [ 72 | {kind: EventInputKind.Source, indexed: true, name: '_from', type: 'address'}, 73 | {kind: EventInputKind.Destination, indexed: true, name: '_to', type: 'address'}, 74 | {kind: EventInputKind.Asset, indexed: false, name: '_tokenId', type: 'uint256'}, 75 | ], 76 | assetFromInputs: async (inputs: any) => inputs._tokenId.toString(), 77 | }], 78 | }, 79 | hash: a => a, 80 | }; 81 | -------------------------------------------------------------------------------- /dist/schemas/main/CryptoKitties/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schemas/main/CryptoKitties/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAA0B;AAC1B,mDAAyC;AAEzC,0CAMwB;AAIX,QAAA,mBAAmB,GAA8B;IAC5D,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,OAAO;IACxB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,6CAA6C;IAC1D,SAAS,EAAE,mDAAmD;IAC9D,OAAO,EAAE,0BAA0B;IACnC,MAAM,EAAE;QACN,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,qBAAqB,EAAC;KAClE;IACD,eAAe,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE;IAC3C,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,EAAC,EAAE,EAAE,KAAK,EAAC,CAAC;IACrC,SAAS,EACP,CAAM,KAAK,EAAC,EAAE;QACZ,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,wCAAwC,KAAK,EAAE,CAAC,CA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IAAI,EAAE,IAAI,EAAE,SAAS,EAAC;oBAC/E,EAAC,IAAI,EAAE,sBAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAC;iBAC/E;gBACD,eAAe,EAAE,CAAO,MAAW,EAAE,EAAE,kDAAC,OAAA,MAAM,CAAC,OAAO,CAAA,GAAA;aACvD,CAAC;KACH;IACD,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CACb,CAAC"} -------------------------------------------------------------------------------- /src/schemas/ContractRole/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | FunctionInputKind, 5 | FunctionOutputKind, 6 | Schema, 7 | StateMutability, 8 | } from '../../types'; 9 | 10 | export interface ContractRoleType { 11 | roleGetter: string; 12 | roleSetter: string; 13 | address: string; 14 | name?: string; 15 | description?: string; 16 | } 17 | 18 | export const ContractRoleSchema: Schema = { 19 | version: 1, 20 | deploymentBlock: 0, // Not indexed (for now; need asset-specific indexing strategy) 21 | name: 'ContractRole', 22 | description: 'Transferrable role on a smart contract.', 23 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 24 | website: 'https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/ownership/Ownable.sol', 25 | fields: [ 26 | {name: 'Name', type: 'string', description: 'Contract Name'}, 27 | {name: 'Description', type: 'string', description: 'Contract Description'}, 28 | {name: 'Address', type: 'address', description: 'Contract Address'}, 29 | {name: 'RoleGetter', type: 'string', description: 'Name of method to get value of role. Should take no arguments.'}, 30 | {name: 'RoleSetter', type: 'string', description: 'Name of method to set value of role. Should take one argument, an address.'}, 31 | ], 32 | assetFromFields: (fields: any) => ({ 33 | name: fields.Name, 34 | address: fields.Address, 35 | description: fields.Description, 36 | roleGetter: fields.RoleGetter, 37 | roleSetter: fields.RoleSetter, 38 | }), 39 | formatter: 40 | async asset => { 41 | return { 42 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 43 | title: `Smart Contract Role: ${asset.roleGetter} for ${asset.name}`, 44 | description: asset.description || (`${asset.roleGetter} for smart contract at ${asset.address}`), 45 | url: 'https://etherscan.io/address/' + asset.address, 46 | properties: [], 47 | }; 48 | }, 49 | functions: { 50 | transfer: asset => ({ 51 | type: AbiType.Function, 52 | name: asset.roleSetter, 53 | payable: false, 54 | constant: false, 55 | stateMutability: StateMutability.Nonpayable, 56 | target: asset.address, 57 | inputs: [ 58 | {kind: FunctionInputKind.Replaceable, name: 'newOwner', type: 'address'}, 59 | ], 60 | outputs: [], 61 | }), 62 | ownerOf: asset => ({ 63 | type: AbiType.Function, 64 | name: asset.roleGetter, 65 | payable: false, 66 | constant: true, 67 | stateMutability: StateMutability.View, 68 | target: asset.address, 69 | inputs: [], 70 | outputs: [ 71 | {kind: FunctionOutputKind.Owner, name: 'owner', type: 'address'}, 72 | ], 73 | }), 74 | assetsOfOwnerByIndex: [], 75 | }, 76 | events: { 77 | transfer: [], 78 | }, 79 | hash: a => a.address, 80 | }; 81 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyENSName/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.rinkebyENSNameSchema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const ens_1 = require("../../../common/ens"); 15 | const types_1 = require("../../../types"); 16 | exports.rinkebyENSNameSchema = Object.assign(Object.assign({}, ens_1.ENSNameBaseSchema), { version: 1, deploymentBlock: 0, name: 'ENSName', description: 'Rinkeby Ethereum Name Service (EIP 137)', thumbnail: 'https://ens.domains/img/ens.svg', website: 'https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md', formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 17 | return { 18 | thumbnail: 'https://ens.domains/img/ens.svg', 19 | title: 'ENS Name ' + asset.name, 20 | description: '(ENS node ' + asset.nodeHash + ')', 21 | url: 'https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md', 22 | properties: [], 23 | }; 24 | }), functions: { 25 | transfer: asset => ({ 26 | type: ethereum_types_1.AbiType.Function, 27 | name: 'setOwner', 28 | payable: false, 29 | constant: false, 30 | stateMutability: types_1.StateMutability.Nonpayable, 31 | target: '0xe7410170f87102df0055eb195163a03b7f2bff4a', 32 | inputs: [ 33 | { kind: types_1.FunctionInputKind.Asset, name: 'node', type: 'bytes32', value: asset.nodeHash }, 34 | { kind: types_1.FunctionInputKind.Replaceable, name: 'owner', type: 'address' }, 35 | ], 36 | outputs: [], 37 | }), 38 | ownerOf: asset => ({ 39 | type: ethereum_types_1.AbiType.Function, 40 | name: 'owner', 41 | payable: false, 42 | constant: true, 43 | stateMutability: types_1.StateMutability.View, 44 | target: '0xe7410170f87102df0055eb195163a03b7f2bff4a', 45 | inputs: [ 46 | { kind: types_1.FunctionInputKind.Asset, name: 'node', type: 'bytes32', value: asset.nodeHash }, 47 | ], 48 | outputs: [ 49 | { kind: types_1.FunctionOutputKind.Owner, name: '', type: 'address' }, 50 | ], 51 | }), 52 | assetsOfOwnerByIndex: [], 53 | }, events: { 54 | transfer: [], 55 | } }); 56 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyOwnableContract/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.rinkebyOwnableContractSchema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../../types"); 15 | exports.rinkebyOwnableContractSchema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'OwnableContract', 19 | description: 'Rinkeby Ownable Smart Contract', 20 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 21 | website: 'https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/ownership/Ownable.sol', 22 | fields: [ 23 | { name: 'Name', type: 'string', description: 'Contract Name' }, 24 | { name: 'Address', type: 'address', description: 'Contract Address' }, 25 | ], 26 | assetFromFields: (fields) => ({ 27 | name: fields.Name, 28 | address: fields.Address, 29 | }), 30 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 31 | return { 32 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 33 | title: 'Ownable Contract: "' + asset.name + '"', 34 | description: 'Ownable at address ' + asset.address, 35 | url: 'https://rinkeby.etherscan.io/address/' + asset.address, 36 | properties: [], 37 | }; 38 | }), 39 | functions: { 40 | transfer: asset => ({ 41 | type: ethereum_types_1.AbiType.Function, 42 | name: 'transferOwnership', 43 | payable: false, 44 | constant: false, 45 | stateMutability: types_1.StateMutability.Nonpayable, 46 | target: asset.address, 47 | inputs: [ 48 | { kind: types_1.FunctionInputKind.Replaceable, name: 'newOwner', type: 'address' }, 49 | ], 50 | outputs: [], 51 | }), 52 | ownerOf: asset => ({ 53 | type: ethereum_types_1.AbiType.Function, 54 | name: 'owner', 55 | payable: false, 56 | constant: true, 57 | stateMutability: types_1.StateMutability.View, 58 | target: asset.address, 59 | inputs: [], 60 | outputs: [ 61 | { kind: types_1.FunctionOutputKind.Owner, name: 'owner', type: 'address' }, 62 | ], 63 | }), 64 | assetsOfOwnerByIndex: [], 65 | }, 66 | events: { 67 | transfer: [], 68 | }, 69 | hash: a => a.address, 70 | }; 71 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint:latest", "tslint-eslint-rules"], 3 | "rules": { 4 | "adjacent-overload-signatures": true, 5 | "arrow-parens": [true, "ban-single-arg-parens"], 6 | "arrow-return-shorthand": true, 7 | "await-promise": true, 8 | "binary-expression-operand-order": true, 9 | "callable-types": true, 10 | "class-name": true, 11 | "completed-docs": [ 12 | true, 13 | { 14 | "functions": { "visibilities": ["exported"] }, 15 | "methods": { "locations": "instance", "privacies": ["public", "protected"] } 16 | } 17 | ], 18 | "curly": true, 19 | "eofline": true, 20 | "encoding": true, 21 | "import-spacing": true, 22 | "indent": [true, "spaces", 2], 23 | "interface-name": false, 24 | "interface-over-type-literal": true, 25 | "linebreak-style": [true, "LF"], 26 | "max-classes-per-file": false, 27 | "max-classes-per-file": [true, 1], 28 | "max-line-length": false, 29 | "max-file-line-count": [true, 500], 30 | "member-access": true, 31 | "member-ordering": [true, "public-before-private", "static-before-instance", "variables-before-functions"], 32 | "newline-before-return": false, 33 | "new-parens": true, 34 | "no-angle-bracket-type-assertion": true, 35 | "no-boolean-literal-compare": true, 36 | "no-default-export": true, 37 | "no-empty-interface": false, 38 | "no-floating-promises": true, 39 | "no-non-null-assertion": true, 40 | "no-parameter-reassignment": true, 41 | "no-redundant-jsdoc": true, 42 | "no-return-await": true, 43 | "no-string-throw": true, 44 | "no-submodule-imports": false, 45 | "no-unnecessary-type-assertion": true, 46 | "no-unused-variable": [true, { "ignore-pattern": "^_\\d*" }], 47 | "no-implicit-dependencies": [true, "dev"], 48 | "number-literal-format": true, 49 | "object-literal-sort-keys": false, 50 | "object-literal-key-quotes": false, 51 | "ordered-imports": [ 52 | true, 53 | { 54 | "grouped-imports": true 55 | } 56 | ], 57 | "prefer-const": true, 58 | "prefer-for-of": true, 59 | "prefer-function-over-method": true, 60 | "promise-function-async": true, 61 | "quotemark": [true, "single", "avoid-escape", "jsx-double"], 62 | "semicolon": [true, "always"], 63 | "space-before-function-paren": [ 64 | true, 65 | { 66 | "anonymous": "never", 67 | "named": "never", 68 | "method": "never", 69 | "constructor": "never", 70 | "asyncArrow": "always" 71 | } 72 | ], 73 | "space-within-parens": false, 74 | "type-literal-delimiter": true, 75 | "variable-name": [true, "ban-keywords", "allow-pascal-case"], 76 | "whitespace": [ 77 | true, 78 | "check-branch", 79 | "check-decl", 80 | "check-operator", 81 | "check-separator", 82 | "check-rest-spread", 83 | "check-type", 84 | "check-typecast", 85 | "check-preblock" 86 | ] 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /dist/schemas/main/ENSName/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.ENSNameSchema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const ens_1 = require("../../../common/ens"); 15 | const types_1 = require("../../../types"); 16 | exports.ENSNameSchema = Object.assign(Object.assign({}, ens_1.ENSNameBaseSchema), { version: 2, deploymentBlock: 3605331, name: 'ENSName', description: 'Ethereum Name Service Name (EIP 137)', thumbnail: 'https://ens.domains/img/ens.svg', website: 'https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md', formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 17 | return { 18 | thumbnail: 'https://ens.domains/img/ens.svg', 19 | title: 'ENS Name ' + 20 | (asset.name ? asset.name : asset.nodeHash.slice(0, 4) + '...'), 21 | description: 'ENS node ' + asset.nodeHash, 22 | url: 'https://etherscan.io/enslookup?q=' + asset.name, 23 | properties: [], 24 | }; 25 | }), functions: { 26 | transfer: asset => ({ 27 | type: ethereum_types_1.AbiType.Function, 28 | name: 'transfer', 29 | payable: false, 30 | constant: false, 31 | stateMutability: types_1.StateMutability.Nonpayable, 32 | target: '0x6090a6e47849629b7245dfa1ca21d94cd15878ef', 33 | inputs: [ 34 | { 35 | kind: types_1.FunctionInputKind.Asset, 36 | name: '_hash', 37 | type: 'bytes32', 38 | value: asset.nodeHash, 39 | }, 40 | { 41 | kind: types_1.FunctionInputKind.Replaceable, 42 | name: 'newOwner', 43 | type: 'address', 44 | }, 45 | ], 46 | outputs: [], 47 | }), 48 | ownerOf: asset => ({ 49 | type: ethereum_types_1.AbiType.Function, 50 | name: 'owner', 51 | payable: false, 52 | constant: true, 53 | stateMutability: types_1.StateMutability.View, 54 | target: '0x314159265dD8dbb310642f98f50C066173C1259b', 55 | inputs: [ 56 | { 57 | kind: types_1.FunctionInputKind.Asset, 58 | name: 'node', 59 | type: 'bytes32', 60 | value: asset.nameHash, 61 | }, 62 | ], 63 | outputs: [{ kind: types_1.FunctionOutputKind.Owner, name: '', type: 'address' }], 64 | }), 65 | assetsOfOwnerByIndex: [], 66 | }, events: { 67 | transfer: [], 68 | } }); 69 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/main/OwnableContract/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.OwnableContractSchema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../../types"); 15 | exports.OwnableContractSchema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'OwnableContract', 19 | description: 'Smart contract with transferrable ownership.', 20 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 21 | website: 'https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/ownership/Ownable.sol', 22 | fields: [ 23 | { name: 'Name', type: 'string', description: 'Contract Name' }, 24 | { name: 'Description', type: 'string', description: 'Contract Description' }, 25 | { name: 'Address', type: 'address', description: 'Contract Address' }, 26 | ], 27 | assetFromFields: (fields) => ({ 28 | name: fields.Name, 29 | address: fields.Address, 30 | description: fields.Description, 31 | }), 32 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 33 | return { 34 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 35 | title: 'Smart Contract: "' + asset.name + '"', 36 | description: asset.description || ('Ownable smart contract at ' + asset.address), 37 | url: 'https://etherscan.io/address/' + asset.address, 38 | properties: [], 39 | }; 40 | }), 41 | functions: { 42 | transfer: asset => ({ 43 | type: ethereum_types_1.AbiType.Function, 44 | name: 'transferOwnership', 45 | payable: false, 46 | constant: false, 47 | stateMutability: types_1.StateMutability.Nonpayable, 48 | target: asset.address, 49 | inputs: [ 50 | { kind: types_1.FunctionInputKind.Replaceable, name: 'newOwner', type: 'address' }, 51 | ], 52 | outputs: [], 53 | }), 54 | ownerOf: asset => ({ 55 | type: ethereum_types_1.AbiType.Function, 56 | name: 'owner', 57 | payable: false, 58 | constant: true, 59 | stateMutability: types_1.StateMutability.View, 60 | target: asset.address, 61 | inputs: [], 62 | outputs: [ 63 | { kind: types_1.FunctionOutputKind.Owner, name: 'owner', type: 'address' }, 64 | ], 65 | }), 66 | assetsOfOwnerByIndex: [], 67 | }, 68 | events: { 69 | transfer: [], 70 | }, 71 | hash: a => a.address, 72 | }; 73 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/ERC20/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.ERC20Schema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../types"); 15 | exports.ERC20Schema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'ERC20', 19 | description: 'Items conforming to the ERC20 spec, using transferFrom.', 20 | thumbnail: 'https://opensea.io/static/images/opensea-icon.png', 21 | website: 'https://github.com/ethereum/eips/issues/20', 22 | fields: [ 23 | { name: 'Address', type: 'address', description: 'Asset Contract Address' }, 24 | { name: 'Quantity', type: 'uint256', description: 'Quantity to transfer' }, 25 | ], 26 | assetFromFields: (fields) => ({ 27 | address: fields.Address, 28 | quantity: fields.Quantity, 29 | }), 30 | assetToFields: asset => ({ 31 | Address: asset.address, 32 | Quantity: asset.quantity, 33 | }), 34 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 35 | return { 36 | title: 'ERC20 Asset at ' + asset.address, 37 | description: 'Trading ' + asset.quantity.toString(), 38 | url: '', 39 | thumbnail: '', 40 | properties: [], 41 | }; 42 | }), 43 | functions: { 44 | transfer: asset => ({ 45 | type: ethereum_types_1.AbiType.Function, 46 | name: 'transferFrom', 47 | payable: false, 48 | constant: false, 49 | stateMutability: types_1.StateMutability.Nonpayable, 50 | target: asset.address, 51 | inputs: [ 52 | { kind: types_1.FunctionInputKind.Owner, name: '_from', type: 'address' }, 53 | { kind: types_1.FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 54 | { kind: types_1.FunctionInputKind.Count, name: '_value', type: 'uint256', value: asset.quantity }, 55 | ], 56 | outputs: [], 57 | }), 58 | countOf: asset => ({ 59 | type: ethereum_types_1.AbiType.Function, 60 | name: 'balanceOf', 61 | payable: false, 62 | constant: true, 63 | stateMutability: types_1.StateMutability.View, 64 | target: asset.address, 65 | inputs: [ 66 | { kind: types_1.FunctionInputKind.Owner, name: '_owner', type: 'address' }, 67 | ], 68 | outputs: [ 69 | { kind: types_1.FunctionOutputKind.Count, name: 'balance', type: 'uint' }, 70 | ], 71 | assetFromOutputs: (outputs) => outputs.balance, 72 | }), 73 | assetsOfOwnerByIndex: [], 74 | }, 75 | events: { 76 | transfer: [], 77 | }, 78 | hash: asset => asset.address, 79 | }; 80 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/types.d.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | import { AnnotatedFunctionABI, AnnotatedFunctionInput, FunctionInputKind } from 'wyvern-js/lib/types'; 3 | export { AnnotatedFunctionInput, AnnotatedFunctionABI, FunctionInputKind, }; 4 | export declare enum Network { 5 | Main = "main", 6 | Rinkeby = "rinkeby", 7 | Goerli = "goerli", 8 | Kovan = "kovan" 9 | } 10 | export declare enum ABIType { 11 | Function = "function", 12 | Event = "event" 13 | } 14 | export interface Token { 15 | name: string; 16 | symbol: string; 17 | decimals: number; 18 | address: string; 19 | } 20 | export interface NetworkTokens { 21 | canonicalWrappedEther: Token; 22 | otherTokens: Token[]; 23 | } 24 | export declare enum StateMutability { 25 | Pure = "pure", 26 | View = "view", 27 | Payable = "payable", 28 | Nonpayable = "nonpayable" 29 | } 30 | export declare enum FunctionOutputKind { 31 | Owner = "owner", 32 | Asset = "asset", 33 | Count = "count", 34 | Other = "other" 35 | } 36 | export interface AnnotatedFunctionOutput { 37 | name: string; 38 | type: string; 39 | kind: FunctionOutputKind; 40 | } 41 | export interface AnnotatedFunctionABIReturning extends AnnotatedFunctionABI { 42 | assetFromOutputs: (outputs: any) => T; 43 | } 44 | export declare enum EventInputKind { 45 | Source = "source", 46 | Destination = "destination", 47 | Asset = "asset", 48 | Other = "other" 49 | } 50 | export interface AnnotatedEventInput { 51 | name: string; 52 | type: string; 53 | indexed: boolean; 54 | kind: EventInputKind; 55 | } 56 | export interface AnnotatedEventABI { 57 | type: AbiType.Event; 58 | name: string; 59 | target: string; 60 | anonymous: boolean; 61 | inputs: AnnotatedEventInput[]; 62 | assetFromInputs: (inputs: any, web3: any) => Promise; 63 | } 64 | export interface MerkleProof { 65 | root: string; 66 | proof: string[]; 67 | } 68 | export interface SchemaFunctions { 69 | transfer: (asset: T) => AnnotatedFunctionABI; 70 | checkAndTransfer?: (asset: T, validatorAddress: string, proof?: MerkleProof) => AnnotatedFunctionABI; 71 | ownerOf?: (asset: T) => AnnotatedFunctionABI; 72 | countOf?: (asset: T) => AnnotatedFunctionABIReturning; 73 | assetsOfOwnerByIndex: Array>; 74 | initializeProxy?: (owner: string) => AnnotatedFunctionABI; 75 | } 76 | export interface SchemaEvents { 77 | transfer: Array>; 78 | } 79 | export interface Property { 80 | key: string; 81 | kind: string; 82 | value: any; 83 | } 84 | export interface FormatInfo { 85 | thumbnail: string; 86 | title: string; 87 | description: string; 88 | url: string; 89 | properties: Property[]; 90 | } 91 | export interface SchemaField { 92 | name: string; 93 | type: string; 94 | description: string; 95 | values?: any[]; 96 | readOnly?: boolean; 97 | } 98 | export interface Schema { 99 | version: number; 100 | deploymentBlock: number; 101 | name: string; 102 | description: string; 103 | thumbnail: string; 104 | website: string; 105 | fields: SchemaField[]; 106 | checkAsset?: (asset: T) => boolean; 107 | assetFromFields: (fields: any) => T; 108 | assetToFields?: (asset: T) => any; 109 | allAssets?: (web3: any) => Promise; 110 | functions: SchemaFunctions; 111 | events: SchemaEvents; 112 | formatter: (obj: T, web3: any) => Promise; 113 | hash: (obj: T) => any; 114 | } 115 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | import { 3 | AnnotatedFunctionABI, 4 | AnnotatedFunctionInput, 5 | FunctionInputKind 6 | } from 'wyvern-js/lib/types'; 7 | 8 | export { 9 | AnnotatedFunctionInput, 10 | AnnotatedFunctionABI, 11 | FunctionInputKind, 12 | }; 13 | 14 | export enum Network { 15 | Main = 'main', 16 | Rinkeby = 'rinkeby', 17 | Goerli = 'goerli', 18 | Kovan = 'kovan', 19 | } 20 | 21 | export enum ABIType { 22 | Function = AbiType.Function, 23 | Event = AbiType.Event, 24 | } 25 | 26 | export interface Token { 27 | name: string; 28 | symbol: string; 29 | decimals: number; 30 | address: string; 31 | } 32 | 33 | export interface NetworkTokens { 34 | canonicalWrappedEther: Token; 35 | otherTokens: Token[]; 36 | } 37 | 38 | export enum StateMutability { 39 | Pure = 'pure', 40 | View = 'view', 41 | Payable = 'payable', 42 | Nonpayable = 'nonpayable', 43 | } 44 | 45 | export enum FunctionOutputKind { 46 | Owner = 'owner', 47 | Asset = 'asset', 48 | Count = 'count', 49 | Other = 'other', 50 | } 51 | 52 | export interface AnnotatedFunctionOutput { 53 | name: string; 54 | type: string; 55 | kind: FunctionOutputKind; 56 | } 57 | 58 | export interface AnnotatedFunctionABIReturning extends AnnotatedFunctionABI { 59 | assetFromOutputs: (outputs: any) => T; 60 | } 61 | 62 | export enum EventInputKind { 63 | Source = 'source', 64 | Destination = 'destination', 65 | Asset = 'asset', 66 | Other = 'other', 67 | } 68 | 69 | export interface AnnotatedEventInput { 70 | name: string; 71 | type: string; 72 | indexed: boolean; 73 | kind: EventInputKind; 74 | } 75 | 76 | export interface AnnotatedEventABI { 77 | type: AbiType.Event; 78 | name: string; 79 | target: string; 80 | anonymous: boolean; 81 | inputs: AnnotatedEventInput[]; 82 | assetFromInputs: (inputs: any, web3: any) => Promise; 83 | } 84 | 85 | export interface MerkleProof { 86 | root: string; 87 | proof: string[]; 88 | } 89 | 90 | export interface SchemaFunctions { 91 | transfer: (asset: T) => AnnotatedFunctionABI; 92 | checkAndTransfer?: (asset: T, validatorAddress: string, proof?: MerkleProof) => AnnotatedFunctionABI; 93 | ownerOf?: (asset: T) => AnnotatedFunctionABI; 94 | countOf?: (asset: T) => AnnotatedFunctionABIReturning; 95 | assetsOfOwnerByIndex: Array>; 96 | initializeProxy?: (owner: string) => AnnotatedFunctionABI; 97 | } 98 | 99 | export interface SchemaEvents { 100 | transfer: Array>; 101 | } 102 | 103 | export interface Property { 104 | key: string; 105 | kind: string; 106 | value: any; 107 | } 108 | 109 | export interface FormatInfo { 110 | thumbnail: string; 111 | title: string; 112 | description: string; 113 | url: string; 114 | properties: Property[]; 115 | } 116 | 117 | export interface SchemaField { 118 | name: string; 119 | type: string; 120 | description: string; 121 | values?: any[]; 122 | readOnly?: boolean; 123 | } 124 | 125 | export interface Schema { 126 | version: number; 127 | deploymentBlock: number; 128 | name: string; 129 | description: string; 130 | thumbnail: string; 131 | website: string; 132 | fields: SchemaField[]; 133 | checkAsset?: (asset: T) => boolean; 134 | assetFromFields: (fields: any) => T; 135 | assetToFields?: (asset: T) => any; 136 | allAssets?: (web3: any) => Promise; 137 | functions: SchemaFunctions; 138 | events: SchemaEvents; 139 | formatter: (obj: T, web3: any) => Promise; 140 | hash: (obj: T) => any; 141 | } 142 | -------------------------------------------------------------------------------- /dist/schemas/ERC1155/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/ERC1155/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,uCAKqB;AAQR,QAAA,aAAa,GAAkC;IAC1D,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,CAAC;IAClB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,2DAA2D;IACxE,SAAS,EAAE,mDAAmD;IAC9D,OAAO,EAAE,8CAA8C;IACvD,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE;QAC9D,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAwB,EAAE;QAC3E,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,sBAAsB,EAAE;KAC3E;IACD,eAAe,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,CAAC;QACjC,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B,CAA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,CAAC,EAAE;iBACjC;gBACD;oBACE,IAAI,EAAE,yBAAiB,CAAC,IAAI;oBAC5B,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,WAAW;oBACjB,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;iBACpC;aACF;YACD,OAAO,EAAE,EAAE;SACZ,CAAC;QACF,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,EAAE,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,uBAAe,CAAC,IAAI;YACrC,MAAM,EAAE,KAAK,CAAC,OAAO;YACrB,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;gBAClE;oBACE,IAAI,EAAE,yBAAiB,CAAC,KAAK;oBAC7B,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,KAAK,CAAC,EAAE;iBAChB;aACF;YACD,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,0BAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE;aAClE;YACD,gBAAgB,EAAE,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO;SACpD,CAAC;QACF,oBAAoB,EAAE,EAAE;KACzB;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,GAAG,KAAK,CAAC,EAAE;CAChD,CAAC"} -------------------------------------------------------------------------------- /src/schemas/rinkeby/rinkebyCryptoKitties/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | EventInputKind, 5 | FunctionInputKind, 6 | FunctionOutputKind, 7 | Schema, 8 | StateMutability, 9 | } from '../../../types'; 10 | 11 | export type RinkebyCryptoKittiesType = string; 12 | 13 | export const rinkebyCryptoKittiesSchema: Schema = { 14 | version: 1, 15 | deploymentBlock: 0, 16 | name: 'RinkebyCryptoKitties', 17 | description: 'Rinkeby Testnet CryptoKitties', 18 | thumbnail: 'https://www.cryptokitties.co/images/kitty-eth.svg', 19 | website: 'https://cryptokitties.co', 20 | fields: [ 21 | {name: 'ID', type: 'uint256', description: 'CryptoKitty number.'}, 22 | ], 23 | assetFromFields: (fields: any) => fields.ID, 24 | assetToFields: asset => ({ID: asset}), 25 | formatter: 26 | async asset => { 27 | return { 28 | thumbnail: 'https://www.cryptokitties.co/images/kitty-eth.svg', 29 | title: 'RinkebyCryptoKitty #' + asset, 30 | description: 'A Rinkeby kitten!', 31 | url: 'https://www.cryptokitties.co/kitty/' + asset, 32 | properties: [], 33 | }; 34 | }, 35 | functions: { 36 | transfer: asset => ({ 37 | type: AbiType.Function, 38 | name: 'transfer', 39 | payable: false, 40 | constant: false, 41 | stateMutability: StateMutability.Nonpayable, 42 | target: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf', 43 | inputs: [ 44 | {kind: FunctionInputKind.Replaceable, name: '_to', type: 'address'}, 45 | {kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset}, 46 | ], 47 | outputs: [], 48 | }), 49 | ownerOf: asset => ({ 50 | type: AbiType.Function, 51 | name: 'ownerOf', 52 | payable: false, 53 | constant: true, 54 | stateMutability: StateMutability.View, 55 | target: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf', 56 | inputs: [ 57 | {kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset}, 58 | ], 59 | outputs: [ 60 | {kind: FunctionOutputKind.Owner, name: 'owner', type: 'address'}, 61 | ], 62 | }), 63 | assetsOfOwnerByIndex: [{ 64 | type: AbiType.Function, 65 | name: 'tokensOfOwnerByIndex', 66 | payable: false, 67 | constant: true, 68 | stateMutability: StateMutability.View, 69 | target: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf', 70 | inputs: [ 71 | {kind: FunctionInputKind.Owner, name: '_owner', type: 'address'}, 72 | {kind: FunctionInputKind.Index, name: '_index', type: 'uint'}, 73 | ], 74 | outputs: [ 75 | {kind: FunctionOutputKind.Asset, name: 'tokenId', type: 'uint'}, 76 | ], 77 | assetFromOutputs: (output: any) => { 78 | if (output.toNumber() === 0) { 79 | return null; 80 | } else { 81 | return output.toString(); 82 | } 83 | }, 84 | }], 85 | }, 86 | events: { 87 | transfer: [{ 88 | type: AbiType.Event, 89 | name: 'Transfer', 90 | target: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf', 91 | anonymous: false, 92 | inputs: [ 93 | {kind: EventInputKind.Source, indexed: true, name: 'from', type: 'address'}, 94 | {kind: EventInputKind.Destination, indexed: true, name: 'to', type: 'address'}, 95 | {kind: EventInputKind.Asset, indexed: true, name: 'tokenId', type: 'uint256'}, 96 | ], 97 | assetFromInputs: async (inputs: any) => inputs.tokenId, 98 | }], 99 | }, 100 | hash: a => a, 101 | }; 102 | -------------------------------------------------------------------------------- /dist/schemas/main/ENSShortNameAuction/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.ENSShortNameAuctionSchema = exports.ENS_SHORT_NAME_AUCTION_ADDRESS = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const ens_1 = require("../../../common/ens"); 15 | const types_1 = require("../../../types"); 16 | exports.ENS_SHORT_NAME_AUCTION_ADDRESS = '0x699c7f511c9e2182e89f29b3bfb68bd327919d17'; 17 | exports.ENSShortNameAuctionSchema = Object.assign(Object.assign({}, ens_1.ENSNameBaseSchema), { version: 0, deploymentBlock: 8488908, name: 'ENSShortNameAuction', description: 'ERC721 ENS short (3-6 character) names sold via auction.', thumbnail: '', website: 'https://ens.domains/', formatter: ({ name }) => __awaiter(void 0, void 0, void 0, function* () { 18 | return { 19 | title: 'ENS Short Name: ' + name, 20 | description: '', 21 | url: '', 22 | thumbnail: '', 23 | properties: [], 24 | }; 25 | }), functions: { 26 | transfer: ({ name }) => ({ 27 | type: ethereum_types_1.AbiType.Function, 28 | name: 'register', 29 | payable: false, 30 | constant: false, 31 | stateMutability: types_1.StateMutability.Nonpayable, 32 | target: exports.ENS_SHORT_NAME_AUCTION_ADDRESS, 33 | inputs: [ 34 | { 35 | kind: types_1.FunctionInputKind.Data, 36 | name: 'name', 37 | type: 'string', 38 | value: name.split('.')[0], 39 | }, 40 | { kind: types_1.FunctionInputKind.Replaceable, name: 'owner', type: 'address' }, 41 | ], 42 | outputs: [], 43 | }), 44 | assetsOfOwnerByIndex: [], 45 | }, events: { 46 | transfer: [ 47 | { 48 | type: ethereum_types_1.AbiType.Event, 49 | name: 'NameRegistered', 50 | target: exports.ENS_SHORT_NAME_AUCTION_ADDRESS, 51 | anonymous: false, 52 | inputs: [ 53 | { 54 | kind: types_1.EventInputKind.Asset, 55 | indexed: false, 56 | name: 'name', 57 | type: 'string', 58 | }, 59 | { 60 | kind: types_1.EventInputKind.Destination, 61 | indexed: false, 62 | name: 'owner', 63 | type: 'address', 64 | }, 65 | ], 66 | assetFromInputs: (inputs) => __awaiter(void 0, void 0, void 0, function* () { 67 | return ({ 68 | name: inputs.name, 69 | nodeHash: (0, ens_1.nodehash)(inputs.name), 70 | nameHash: (0, ens_1.namehash)(inputs.name), 71 | }); 72 | }), 73 | }, 74 | ], 75 | } }); 76 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/schemas/main/CryptoKitties/index.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | import { AbiType } from 'ethereum-types'; 3 | 4 | import { 5 | EventInputKind, 6 | FunctionInputKind, 7 | FunctionOutputKind, 8 | Schema, 9 | StateMutability, 10 | } from '../../../types'; 11 | 12 | export type CryptoKittiesType = string; 13 | 14 | export const CryptoKittiesSchema: Schema = { 15 | version: 1, 16 | deploymentBlock: 4605167, 17 | name: 'CryptoKitties', 18 | description: 'The virtual kitties that started the craze.', 19 | thumbnail: 'https://www.cryptokitties.co/images/kitty-eth.svg', 20 | website: 'https://cryptokitties.co', 21 | fields: [ 22 | {name: 'ID', type: 'uint256', description: 'CryptoKitty number.'}, 23 | ], 24 | assetFromFields: (fields: any) => fields.ID, 25 | assetToFields: asset => ({ID: asset}), 26 | formatter: 27 | async asset => { 28 | const response = await axios.get(`https://api.cryptokitties.co/kitties/${asset}`).catch(err => { 29 | if (err.response && (err.response.status === 404 || err.response.status === 400)) { 30 | return null; 31 | } else { 32 | throw err; 33 | } 34 | }); 35 | if (response === null) { 36 | return { 37 | thumbnail: 'https://www.cryptokitties.co/images/kitty-eth.svg', 38 | title: 'CryptoKitty #' + asset, 39 | description: '', 40 | url: 'https://www.cryptokitties.co/kitty/' + asset, 41 | properties: [], 42 | }; 43 | } else { 44 | const data = response.data; 45 | const attrs = data.enhanced_cattributes || data.cattributes || []; 46 | return { 47 | thumbnail: data.image_url_cdn, 48 | title: 'CryptoKitty #' + asset, 49 | description: data.bio, 50 | url: 'https://www.cryptokitties.co/kitty/' + asset, 51 | properties: attrs.map((c: any) => ({ 52 | key: c.type, 53 | kind: 'string', 54 | value: c.description, 55 | })), 56 | }; 57 | } 58 | }, 59 | functions: { 60 | transfer: asset => ({ 61 | type: AbiType.Function, 62 | name: 'transfer', 63 | payable: false, 64 | constant: false, 65 | stateMutability: StateMutability.Nonpayable, 66 | target: '0x06012c8cf97bead5deae237070f9587f8e7a266d', 67 | inputs: [ 68 | {kind: FunctionInputKind.Replaceable, name: '_to', type: 'address'}, 69 | {kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset}, 70 | ], 71 | outputs: [], 72 | }), 73 | ownerOf: asset => ({ 74 | type: AbiType.Function, 75 | name: 'ownerOf', 76 | payable: false, 77 | constant: true, 78 | stateMutability: StateMutability.View, 79 | target: '0x06012c8cf97bead5deae237070f9587f8e7a266d', 80 | inputs: [ 81 | {kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset}, 82 | ], 83 | outputs: [ 84 | {kind: FunctionOutputKind.Owner, name: 'owner', type: 'address'}, 85 | ], 86 | }), 87 | assetsOfOwnerByIndex: [], 88 | }, 89 | events: { 90 | transfer: [{ 91 | type: AbiType.Event, 92 | name: 'Transfer', 93 | target: '0x06012c8cf97bead5deae237070f9587f8e7a266d', 94 | anonymous: false, 95 | inputs: [ 96 | {kind: EventInputKind.Source, indexed: false, name: 'from', type: 'address'}, 97 | {kind: EventInputKind.Destination, indexed: false, name: 'to', type: 'address'}, 98 | {kind: EventInputKind.Asset, indexed: false, name: 'tokenId', type: 'uint256'}, 99 | ], 100 | assetFromInputs: async (inputs: any) => inputs.tokenId, 101 | }], 102 | }, 103 | hash: a => a, 104 | }; 105 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyENSShortNameAuction/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.rinkebyENSShortNameAuctionSchema = exports.RINKEBY_ENS_SHORT_NAME_AUCTION_ADDRESS = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const ens_1 = require("../../../common/ens"); 15 | const types_1 = require("../../../types"); 16 | exports.RINKEBY_ENS_SHORT_NAME_AUCTION_ADDRESS = '0x76b6481a334783be36f2fc35b8f0b9bc7835d57b'; 17 | exports.rinkebyENSShortNameAuctionSchema = Object.assign(Object.assign({}, ens_1.ENSNameBaseSchema), { version: 0, deploymentBlock: 4791629, name: 'ENSShortNameAuction', description: 'ERC721 ENS short (3-6 character) names sold via auction.', thumbnail: '', website: 'https://ens.domains/', formatter: ({ name }) => __awaiter(void 0, void 0, void 0, function* () { 18 | return { 19 | title: 'ENS Short Name: ' + name, 20 | description: '', 21 | url: '', 22 | thumbnail: '', 23 | properties: [], 24 | }; 25 | }), functions: { 26 | transfer: ({ name }) => ({ 27 | type: ethereum_types_1.AbiType.Function, 28 | name: 'register', 29 | payable: false, 30 | constant: false, 31 | stateMutability: types_1.StateMutability.Nonpayable, 32 | target: exports.RINKEBY_ENS_SHORT_NAME_AUCTION_ADDRESS, 33 | inputs: [ 34 | { 35 | kind: types_1.FunctionInputKind.Data, 36 | name: 'name', 37 | type: 'string', 38 | value: name.split('.')[0], 39 | }, 40 | { kind: types_1.FunctionInputKind.Replaceable, name: 'owner', type: 'address' }, 41 | ], 42 | outputs: [], 43 | }), 44 | assetsOfOwnerByIndex: [], 45 | }, events: { 46 | transfer: [ 47 | { 48 | type: ethereum_types_1.AbiType.Event, 49 | name: 'NameRegistered', 50 | target: exports.RINKEBY_ENS_SHORT_NAME_AUCTION_ADDRESS, 51 | anonymous: false, 52 | inputs: [ 53 | { 54 | kind: types_1.EventInputKind.Asset, 55 | indexed: false, 56 | name: 'name', 57 | type: 'string', 58 | }, 59 | { 60 | kind: types_1.EventInputKind.Destination, 61 | indexed: false, 62 | name: 'owner', 63 | type: 'address', 64 | }, 65 | ], 66 | assetFromInputs: (inputs) => __awaiter(void 0, void 0, void 0, function* () { 67 | return ({ 68 | name: inputs.name, 69 | nodeHash: (0, ens_1.nodehash)(inputs.name), 70 | nameHash: (0, ens_1.namehash)(inputs.name), 71 | }); 72 | }), 73 | }, 74 | ], 75 | } }); 76 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/ContractRole/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.ContractRoleSchema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../types"); 15 | exports.ContractRoleSchema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'ContractRole', 19 | description: 'Transferrable role on a smart contract.', 20 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 21 | website: 'https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/ownership/Ownable.sol', 22 | fields: [ 23 | { name: 'Name', type: 'string', description: 'Contract Name' }, 24 | { name: 'Description', type: 'string', description: 'Contract Description' }, 25 | { name: 'Address', type: 'address', description: 'Contract Address' }, 26 | { name: 'RoleGetter', type: 'string', description: 'Name of method to get value of role. Should take no arguments.' }, 27 | { name: 'RoleSetter', type: 'string', description: 'Name of method to set value of role. Should take one argument, an address.' }, 28 | ], 29 | assetFromFields: (fields) => ({ 30 | name: fields.Name, 31 | address: fields.Address, 32 | description: fields.Description, 33 | roleGetter: fields.RoleGetter, 34 | roleSetter: fields.RoleSetter, 35 | }), 36 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 37 | return { 38 | thumbnail: 'https://i.redditmedia.com/NaFzmSbDX2T2RALMxy2tmGJN_gPVNH9lJggCKUDDqcc.jpg?w=320&s=3913239508209aaf6ba1188fe3d3b5fc', 39 | title: `Smart Contract Role: ${asset.roleGetter} for ${asset.name}`, 40 | description: asset.description || (`${asset.roleGetter} for smart contract at ${asset.address}`), 41 | url: 'https://etherscan.io/address/' + asset.address, 42 | properties: [], 43 | }; 44 | }), 45 | functions: { 46 | transfer: asset => ({ 47 | type: ethereum_types_1.AbiType.Function, 48 | name: asset.roleSetter, 49 | payable: false, 50 | constant: false, 51 | stateMutability: types_1.StateMutability.Nonpayable, 52 | target: asset.address, 53 | inputs: [ 54 | { kind: types_1.FunctionInputKind.Replaceable, name: 'newOwner', type: 'address' }, 55 | ], 56 | outputs: [], 57 | }), 58 | ownerOf: asset => ({ 59 | type: ethereum_types_1.AbiType.Function, 60 | name: asset.roleGetter, 61 | payable: false, 62 | constant: true, 63 | stateMutability: types_1.StateMutability.View, 64 | target: asset.address, 65 | inputs: [], 66 | outputs: [ 67 | { kind: types_1.FunctionOutputKind.Owner, name: 'owner', type: 'address' }, 68 | ], 69 | }), 70 | assetsOfOwnerByIndex: [], 71 | }, 72 | events: { 73 | transfer: [], 74 | }, 75 | hash: a => a.address, 76 | }; 77 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/main/CryptoPunks/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.CryptoPunksSchema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../../types"); 15 | exports.CryptoPunksSchema = { 16 | version: 1, 17 | deploymentBlock: 3914495, 18 | name: 'CryptoPunks', 19 | description: '10,000 unique collectible characters with proof of ownership stored on the Ethereum blockchain.', 20 | thumbnail: 'https://www.larvalabs.com/cryptopunks/cryptopunk2838.png', 21 | website: 'https://www.larvalabs.com/cryptopunks', 22 | fields: [ 23 | { name: 'ID', type: 'uint256', description: 'CryptoPunk number.' }, 24 | ], 25 | assetFromFields: (fields) => fields.ID, 26 | assetToFields: asset => ({ ID: asset }), 27 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 28 | return { 29 | thumbnail: 'https://www.larvalabs.com/cryptopunks/cryptopunk' + asset + '.png', 30 | title: 'CryptoPunk #' + asset, 31 | description: '', 32 | url: 'https://www.larvalabs.com/cryptopunks/details/' + asset, 33 | properties: [], 34 | }; 35 | }), 36 | functions: { 37 | transfer: asset => ({ 38 | type: ethereum_types_1.AbiType.Function, 39 | name: 'transferPunk', 40 | payable: false, 41 | constant: false, 42 | stateMutability: types_1.StateMutability.Nonpayable, 43 | target: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb', 44 | inputs: [ 45 | { kind: types_1.FunctionInputKind.Replaceable, name: 'to', type: 'address' }, 46 | { kind: types_1.FunctionInputKind.Asset, name: 'punkIndex', type: 'uint256', value: asset }, 47 | ], 48 | outputs: [], 49 | }), 50 | ownerOf: asset => ({ 51 | type: ethereum_types_1.AbiType.Function, 52 | name: 'punkIndexToAddress', 53 | payable: false, 54 | constant: true, 55 | stateMutability: types_1.StateMutability.View, 56 | target: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb', 57 | inputs: [ 58 | { kind: types_1.FunctionInputKind.Asset, name: '', type: 'uint256', value: asset }, 59 | ], 60 | outputs: [ 61 | { kind: types_1.FunctionOutputKind.Owner, name: '', type: 'address' }, 62 | ], 63 | }), 64 | assetsOfOwnerByIndex: [], 65 | }, 66 | events: { 67 | transfer: [{ 68 | type: ethereum_types_1.AbiType.Event, 69 | name: 'PunkTransfer', 70 | target: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb', 71 | anonymous: false, 72 | inputs: [ 73 | { kind: types_1.EventInputKind.Source, indexed: true, name: 'from', type: 'address' }, 74 | { kind: types_1.EventInputKind.Destination, indexed: true, name: 'to', type: 'address' }, 75 | { kind: types_1.EventInputKind.Asset, indexed: false, name: 'punkIndex', type: 'uint256' }, 76 | ], 77 | assetFromInputs: (inputs) => __awaiter(void 0, void 0, void 0, function* () { return inputs.punkIndex; }), 78 | }], 79 | }, 80 | hash: a => a, 81 | }; 82 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/rinkeby/testRinkebyNFT/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.testRinkebyNFTSchema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../../types"); 15 | exports.testRinkebyNFTSchema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'TestRinkebyNFT', 19 | description: 'Rinkeby ERC721 non-fungible token for Wyvern Exchange testing', 20 | thumbnail: 'https://cointelegraph.com/storage/uploads/view/f88e17e41f607dc0aef238230dd40cc6.png', 21 | website: 'https://projectwyvern.com', 22 | fields: [ 23 | { name: 'ID', type: 'uint256', description: 'Token identification number.' }, 24 | ], 25 | assetFromFields: (fields) => fields.ID, 26 | assetToFields: asset => ({ ID: asset }), 27 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 28 | return { 29 | thumbnail: 'https://cointelegraph.com/storage/uploads/view/f88e17e41f607dc0aef238230dd40cc6.png', 30 | title: 'TestRinkebyNFT #' + asset, 31 | description: 'A useless NFT!', 32 | url: 'https://www.projectwyvern.com', 33 | properties: [], 34 | }; 35 | }), 36 | functions: { 37 | transfer: asset => ({ 38 | type: ethereum_types_1.AbiType.Function, 39 | name: 'transfer', 40 | payable: false, 41 | constant: false, 42 | stateMutability: types_1.StateMutability.Nonpayable, 43 | target: '0x07a6dc6e3f1120ca03658d473d10aee3af5f8abb', 44 | inputs: [ 45 | { kind: types_1.FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 46 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset }, 47 | ], 48 | outputs: [], 49 | }), 50 | ownerOf: asset => ({ 51 | type: ethereum_types_1.AbiType.Function, 52 | name: 'ownerOf', 53 | payable: false, 54 | constant: true, 55 | stateMutability: types_1.StateMutability.View, 56 | target: '0x07a6dc6e3f1120ca03658d473d10aee3af5f8abb', 57 | inputs: [ 58 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset }, 59 | ], 60 | outputs: [ 61 | { kind: types_1.FunctionOutputKind.Owner, name: '_owner', type: 'address' }, 62 | ], 63 | }), 64 | assetsOfOwnerByIndex: [], 65 | }, 66 | events: { 67 | transfer: [{ 68 | type: ethereum_types_1.AbiType.Event, 69 | name: 'Transfer', 70 | target: '0x07a6dc6e3f1120ca03658d473d10aee3af5f8abb', 71 | anonymous: false, 72 | inputs: [ 73 | { kind: types_1.EventInputKind.Source, indexed: true, name: '_from', type: 'address' }, 74 | { kind: types_1.EventInputKind.Destination, indexed: true, name: '_to', type: 'address' }, 75 | { kind: types_1.EventInputKind.Asset, indexed: false, name: '_tokenId', type: 'uint256' }, 76 | ], 77 | assetFromInputs: (inputs) => __awaiter(void 0, void 0, void 0, function* () { return inputs._tokenId.toString(); }), 78 | }], 79 | }, 80 | hash: a => a, 81 | }; 82 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/ERC721/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/ERC721/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAyC;AAEzC,uCAKqB;AAQR,QAAA,YAAY,GAAoC;IAC3D,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,CAAC;IAClB,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,0DAA0D;IACvE,SAAS,EAAE,mDAAmD;IAC9D,OAAO,EAAE,oBAAoB;IAC7B,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE;QAC9D,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAwB,EAAE;KAC5E;IACD,eAAe,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,CAAC;QACjC,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;IACF,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QACvB,EAAE,EAAE,KAA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E,wBAAO,CAAC,QAAQ;YACtB,IAAI,EAAE,0CAA0C;YAChD,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,uBAAe,CAAC,UAAU;YAC3C,MAAM,EAAE,gBAAgB;YACxB,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;gBAChE,EAAE,IAAI,EAAE,yBAAiB,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;gBACpE,EAAE,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE;gBACvF,EAAE,IAAI,EAAE,yBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE;gBACpF,EAAC,IAAI,EAAE,yBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAC;gBAC/F,EAAC,IAAI,EAAE,yBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAC;aACtG;YACD,OAAO,EAAE,EAAE;SACZ,CAAC,OAEJ"} -------------------------------------------------------------------------------- /dist/schemaFunctions.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"schemaFunctions.js","sourceRoot":"","sources":["../src/schemaFunctions.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AACzC,yCAAyC;A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IAAA,gCAAwB,EAAC,QAAQ,EAAE,yBAAiB,CAAC,KAAK,CAAC,CAAC;KAClF;IAED,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,QAAQ;QACR,kBAAkB;KACnB,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,SAAS,aAkCpB;AAIK,MAAM,iBAAiB,GAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;IACpE,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACxC,QAAQ,KAAK,CAAC,IAAI,EAAE;YAClB,KAAK,yBAAiB,CAAC,WAAW;gBAChC,OAAO,0BAAc,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzD,KAAK,yBAAiB,CAAC,KAAK;gBAC1B,OAAO,OAAO,CAAC;YACjB,KAAK,yBAAiB,CAAC,KAAK,CAAC;YAC7B;gBACE,OAAO,KAAK,CAAC,KAAK,CAAC;SACtB;IACH,CAAC,CAAC,CAAC;IACH,OAAO,IAAA,kBAAU,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC;AAbW,QAAA,iBAAiB,qBAa5B"} -------------------------------------------------------------------------------- /src/schemas/ERC1155/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | FunctionInputKind, 5 | FunctionOutputKind, 6 | Schema, 7 | StateMutability, 8 | } from '../../types'; 9 | 10 | export interface SemiFungibleTradeType { 11 | id: string; 12 | address: string; 13 | quantity: string; 14 | } 15 | 16 | export const ERC1155Schema: Schema = { 17 | version: 1, 18 | deploymentBlock: 0, // Not indexed (for now; need asset-specific indexing strategy) 19 | name: 'ERC1155', 20 | description: 'Items conforming to the ERC1155 spec, using transferFrom.', 21 | thumbnail: 'https://opensea.io/static/images/opensea-icon.png', 22 | website: 'https://github.com/ethereum/eips/issues/1155', 23 | fields: [ 24 | { name: 'ID', type: 'uint256', description: 'Asset Token ID' }, 25 | { name: 'Address', type: 'address', description: 'Asset Contract Address' }, 26 | { name: 'Quantity', type: 'uint256', description: 'Quantity to transfer' }, 27 | ], 28 | assetFromFields: (fields: any) => ({ 29 | id: fields.ID, 30 | address: fields.Address, 31 | quantity: fields.Quantity, 32 | }), 33 | assetToFields: (asset) => ({ 34 | ID: asset.id, 35 | Address: asset.address, 36 | Quantity: asset.quantity, 37 | }), 38 | formatter: async (asset) => { 39 | return { 40 | title: 'ERC1155 Asset: Token ID ' + asset.id + ' at ' + asset.address, 41 | description: 'Trading ' + asset.quantity.toString(), 42 | url: '', 43 | thumbnail: '', 44 | properties: [], 45 | }; 46 | }, 47 | functions: { 48 | transfer: (asset) => ({ 49 | type: AbiType.Function, 50 | name: 'safeTransferFrom', 51 | payable: false, 52 | constant: false, 53 | stateMutability: StateMutability.Nonpayable, 54 | target: asset.address, 55 | inputs: [ 56 | { kind: FunctionInputKind.Owner, name: '_from', type: 'address' }, 57 | { kind: FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 58 | { 59 | kind: FunctionInputKind.Asset, 60 | name: '_id', 61 | type: 'uint256', 62 | value: asset.id, 63 | }, 64 | { 65 | kind: FunctionInputKind.Count, 66 | name: '_value', 67 | type: 'uint256', 68 | value: asset.quantity, 69 | }, 70 | { 71 | kind: FunctionInputKind.Data, 72 | name: '_data', 73 | type: 'bytes', 74 | value: '', 75 | }, 76 | ], 77 | outputs: [], 78 | }), 79 | checkAndTransfer: (asset, validatorAddress, merkle) => ({ 80 | type: AbiType.Function, 81 | name: 'matchERC1155UsingCriteria', 82 | payable: false, 83 | constant: false, 84 | stateMutability: StateMutability.Nonpayable, 85 | target: validatorAddress, 86 | inputs: [ 87 | { kind: FunctionInputKind.Owner, name: 'from', type: 'address' }, 88 | { kind: FunctionInputKind.Replaceable, name: 'to', type: 'address' }, 89 | { 90 | kind: FunctionInputKind.Asset, 91 | name: 'token', 92 | type: 'address', 93 | value: asset.address, 94 | }, 95 | { 96 | kind: FunctionInputKind.Asset, 97 | name: 'tokenId', 98 | type: 'uint256', 99 | value: asset.id, 100 | }, 101 | { 102 | kind: FunctionInputKind.Count, 103 | name: 'amount', 104 | type: 'uint256', 105 | value: asset.quantity, 106 | }, 107 | { 108 | kind: FunctionInputKind.Data, 109 | name: 'root', 110 | type: 'bytes32', 111 | value: merkle ? merkle.root : '', 112 | }, 113 | { 114 | kind: FunctionInputKind.Data, 115 | name: 'proof', 116 | type: 'bytes32[]', 117 | value: merkle ? merkle.proof : '[]', 118 | }, 119 | ], 120 | outputs: [], 121 | }), 122 | countOf: (asset) => ({ 123 | type: AbiType.Function, 124 | name: 'balanceOf', 125 | payable: false, 126 | constant: true, 127 | stateMutability: StateMutability.View, 128 | target: asset.address, 129 | inputs: [ 130 | { kind: FunctionInputKind.Owner, name: '_owner', type: 'address' }, 131 | { 132 | kind: FunctionInputKind.Asset, 133 | name: '_id', 134 | type: 'uint256', 135 | value: asset.id, 136 | }, 137 | ], 138 | outputs: [ 139 | { kind: FunctionOutputKind.Count, name: 'balance', type: 'uint' }, 140 | ], 141 | assetFromOutputs: (outputs: any) => outputs.balance, 142 | }), 143 | assetsOfOwnerByIndex: [], 144 | }, 145 | events: { 146 | transfer: [], 147 | }, 148 | hash: (asset) => asset.address + '-' + asset.id, 149 | }; 150 | -------------------------------------------------------------------------------- /dist/schemas/rinkeby/rinkebyCryptoKitties/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.rinkebyCryptoKittiesSchema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../../types"); 15 | exports.rinkebyCryptoKittiesSchema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'RinkebyCryptoKitties', 19 | description: 'Rinkeby Testnet CryptoKitties', 20 | thumbnail: 'https://www.cryptokitties.co/images/kitty-eth.svg', 21 | website: 'https://cryptokitties.co', 22 | fields: [ 23 | { name: 'ID', type: 'uint256', description: 'CryptoKitty number.' }, 24 | ], 25 | assetFromFields: (fields) => fields.ID, 26 | assetToFields: asset => ({ ID: asset }), 27 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 28 | return { 29 | thumbnail: 'https://www.cryptokitties.co/images/kitty-eth.svg', 30 | title: 'RinkebyCryptoKitty #' + asset, 31 | description: 'A Rinkeby kitten!', 32 | url: 'https://www.cryptokitties.co/kitty/' + asset, 33 | properties: [], 34 | }; 35 | }), 36 | functions: { 37 | transfer: asset => ({ 38 | type: ethereum_types_1.AbiType.Function, 39 | name: 'transfer', 40 | payable: false, 41 | constant: false, 42 | stateMutability: types_1.StateMutability.Nonpayable, 43 | target: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf', 44 | inputs: [ 45 | { kind: types_1.FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 46 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset }, 47 | ], 48 | outputs: [], 49 | }), 50 | ownerOf: asset => ({ 51 | type: ethereum_types_1.AbiType.Function, 52 | name: 'ownerOf', 53 | payable: false, 54 | constant: true, 55 | stateMutability: types_1.StateMutability.View, 56 | target: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf', 57 | inputs: [ 58 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset }, 59 | ], 60 | outputs: [ 61 | { kind: types_1.FunctionOutputKind.Owner, name: 'owner', type: 'address' }, 62 | ], 63 | }), 64 | assetsOfOwnerByIndex: [{ 65 | type: ethereum_types_1.AbiType.Function, 66 | name: 'tokensOfOwnerByIndex', 67 | payable: false, 68 | constant: true, 69 | stateMutability: types_1.StateMutability.View, 70 | target: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf', 71 | inputs: [ 72 | { kind: types_1.FunctionInputKind.Owner, name: '_owner', type: 'address' }, 73 | { kind: types_1.FunctionInputKind.Index, name: '_index', type: 'uint' }, 74 | ], 75 | outputs: [ 76 | { kind: types_1.FunctionOutputKind.Asset, name: 'tokenId', type: 'uint' }, 77 | ], 78 | assetFromOutputs: (output) => { 79 | if (output.toNumber() === 0) { 80 | return null; 81 | } 82 | else { 83 | return output.toString(); 84 | } 85 | }, 86 | }], 87 | }, 88 | events: { 89 | transfer: [{ 90 | type: ethereum_types_1.AbiType.Event, 91 | name: 'Transfer', 92 | target: '0x16baf0de678e52367adc69fd067e5edd1d33e3bf', 93 | anonymous: false, 94 | inputs: [ 95 | { kind: types_1.EventInputKind.Source, indexed: true, name: 'from', type: 'address' }, 96 | { kind: types_1.EventInputKind.Destination, indexed: true, name: 'to', type: 'address' }, 97 | { kind: types_1.EventInputKind.Asset, indexed: true, name: 'tokenId', type: 'uint256' }, 98 | ], 99 | assetFromInputs: (inputs) => __awaiter(void 0, void 0, void 0, function* () { return inputs.tokenId; }), 100 | }], 101 | }, 102 | hash: a => a, 103 | }; 104 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/main/CryptoKitties/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.CryptoKittiesSchema = void 0; 13 | const axios_1 = require("axios"); 14 | const ethereum_types_1 = require("ethereum-types"); 15 | const types_1 = require("../../../types"); 16 | exports.CryptoKittiesSchema = { 17 | version: 1, 18 | deploymentBlock: 4605167, 19 | name: 'CryptoKitties', 20 | description: 'The virtual kitties that started the craze.', 21 | thumbnail: 'https://www.cryptokitties.co/images/kitty-eth.svg', 22 | website: 'https://cryptokitties.co', 23 | fields: [ 24 | { name: 'ID', type: 'uint256', description: 'CryptoKitty number.' }, 25 | ], 26 | assetFromFields: (fields) => fields.ID, 27 | assetToFields: asset => ({ ID: asset }), 28 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 29 | const response = yield axios_1.default.get(`https://api.cryptokitties.co/kitties/${asset}`).catch(err => { 30 | if (err.response && (err.response.status === 404 || err.response.status === 400)) { 31 | return null; 32 | } 33 | else { 34 | throw err; 35 | } 36 | }); 37 | if (response === null) { 38 | return { 39 | thumbnail: 'https://www.cryptokitties.co/images/kitty-eth.svg', 40 | title: 'CryptoKitty #' + asset, 41 | description: '', 42 | url: 'https://www.cryptokitties.co/kitty/' + asset, 43 | properties: [], 44 | }; 45 | } 46 | else { 47 | const data = response.data; 48 | const attrs = data.enhanced_cattributes || data.cattributes || []; 49 | return { 50 | thumbnail: data.image_url_cdn, 51 | title: 'CryptoKitty #' + asset, 52 | description: data.bio, 53 | url: 'https://www.cryptokitties.co/kitty/' + asset, 54 | properties: attrs.map((c) => ({ 55 | key: c.type, 56 | kind: 'string', 57 | value: c.description, 58 | })), 59 | }; 60 | } 61 | }), 62 | functions: { 63 | transfer: asset => ({ 64 | type: ethereum_types_1.AbiType.Function, 65 | name: 'transfer', 66 | payable: false, 67 | constant: false, 68 | stateMutability: types_1.StateMutability.Nonpayable, 69 | target: '0x06012c8cf97bead5deae237070f9587f8e7a266d', 70 | inputs: [ 71 | { kind: types_1.FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 72 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset }, 73 | ], 74 | outputs: [], 75 | }), 76 | ownerOf: asset => ({ 77 | type: ethereum_types_1.AbiType.Function, 78 | name: 'ownerOf', 79 | payable: false, 80 | constant: true, 81 | stateMutability: types_1.StateMutability.View, 82 | target: '0x06012c8cf97bead5deae237070f9587f8e7a266d', 83 | inputs: [ 84 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset }, 85 | ], 86 | outputs: [ 87 | { kind: types_1.FunctionOutputKind.Owner, name: 'owner', type: 'address' }, 88 | ], 89 | }), 90 | assetsOfOwnerByIndex: [], 91 | }, 92 | events: { 93 | transfer: [{ 94 | type: ethereum_types_1.AbiType.Event, 95 | name: 'Transfer', 96 | target: '0x06012c8cf97bead5deae237070f9587f8e7a266d', 97 | anonymous: false, 98 | inputs: [ 99 | { kind: types_1.EventInputKind.Source, indexed: false, name: 'from', type: 'address' }, 100 | { kind: types_1.EventInputKind.Destination, indexed: false, name: 'to', type: 'address' }, 101 | { kind: types_1.EventInputKind.Asset, indexed: false, name: 'tokenId', type: 'uint256' }, 102 | ], 103 | assetFromInputs: (inputs) => __awaiter(void 0, void 0, void 0, function* () { return inputs.tokenId; }), 104 | }], 105 | }, 106 | hash: a => a, 107 | }; 108 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/schemas/ERC721/index.ts: -------------------------------------------------------------------------------- 1 | import { AbiType } from 'ethereum-types'; 2 | 3 | import { 4 | FunctionInputKind, 5 | FunctionOutputKind, 6 | Schema, 7 | StateMutability 8 | } from '../../types'; 9 | 10 | 11 | export interface NonFungibleContractType { 12 | id: string; 13 | address: string; 14 | } 15 | 16 | export const ERC721Schema: Schema = { 17 | version: 2, 18 | deploymentBlock: 0, // Not indexed (for now; need asset-specific indexing strategy) 19 | name: 'ERC721', 20 | description: 'Items conforming to the ERC721 spec, using transferFrom.', 21 | thumbnail: 'https://opensea.io/static/images/opensea-icon.png', 22 | website: 'http://erc721.org/', 23 | fields: [ 24 | { name: 'ID', type: 'uint256', description: 'Asset Token ID' }, 25 | { name: 'Address', type: 'address', description: 'Asset Contract Address' }, 26 | ], 27 | assetFromFields: (fields: any) => ({ 28 | id: fields.ID, 29 | address: fields.Address, 30 | }), 31 | assetToFields: asset => ({ 32 | ID: asset.id, 33 | Address: asset.address, 34 | }), 35 | formatter: 36 | async asset => { 37 | return { 38 | title: 'ERC721 Asset: Token ID ' + asset.id + ' at ' + asset.address, 39 | description: '', 40 | url: '', 41 | thumbnail: '', 42 | properties: [], 43 | }; 44 | }, 45 | functions: { 46 | transfer: asset => ({ 47 | type: AbiType.Function, 48 | name: 'transferFrom', 49 | payable: false, 50 | constant: false, 51 | stateMutability: StateMutability.Nonpayable, 52 | target: asset.address, 53 | inputs: [ 54 | { kind: FunctionInputKind.Owner, name: '_from', type: 'address' }, 55 | { kind: FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 56 | { kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset.id }, 57 | ], 58 | outputs: [], 59 | }), 60 | checkAndTransfer: (asset, validatorAddress, merkle) => ({ 61 | type: AbiType.Function, 62 | name: 'matchERC721UsingCriteria', 63 | payable: false, 64 | constant: false, 65 | stateMutability: StateMutability.Nonpayable, 66 | target: validatorAddress, 67 | inputs: [ 68 | { kind: FunctionInputKind.Owner, name: 'from', type: 'address' }, 69 | { kind: FunctionInputKind.Replaceable, name: 'to', type: 'address' }, 70 | { kind: FunctionInputKind.Asset, name: 'token', type: 'address', value: asset.address }, 71 | { kind: FunctionInputKind.Asset, name: 'tokenId', type: 'uint256', value: asset.id }, 72 | { kind: FunctionInputKind.Data, name: 'root', type: 'bytes32', value: merkle ? merkle.root : "" }, 73 | { kind: FunctionInputKind.Data, name: 'proof', type: 'bytes32[]', value: merkle ? merkle.proof : "[]" }, 74 | ], 75 | outputs: [], 76 | }), 77 | ownerOf: asset => ({ 78 | type: AbiType.Function, 79 | name: 'ownerOf', 80 | payable: false, 81 | constant: true, 82 | stateMutability: StateMutability.View, 83 | target: asset.address, 84 | inputs: [ 85 | { kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset.id }, 86 | ], 87 | outputs: [ 88 | { kind: FunctionOutputKind.Owner, name: 'owner', type: 'address' }, 89 | ], 90 | }), 91 | assetsOfOwnerByIndex: [], 92 | }, 93 | events: { 94 | transfer: [], 95 | }, 96 | hash: asset => asset.address + '-' + asset.id, 97 | }; 98 | 99 | export const ERC721v3Schema: Schema = { 100 | ...ERC721Schema, 101 | version: 3, 102 | name: 'ERC721v3', 103 | description: 'Items conforming to the ERC721 v3 spec, using safeTransferFrom.', 104 | functions: { 105 | ...ERC721Schema.functions, 106 | transfer: asset => ({ 107 | type: AbiType.Function, 108 | name: 'safeTransferFrom', 109 | payable: false, 110 | constant: false, 111 | stateMutability: StateMutability.Nonpayable, 112 | target: asset.address, 113 | inputs: [ 114 | { kind: FunctionInputKind.Owner, name: '_from', type: 'address' }, 115 | { kind: FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 116 | { kind: FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset.id }, 117 | ], 118 | outputs: [], 119 | }), 120 | checkAndTransfer: (asset, validatorAddress, merkle) => ({ 121 | type: AbiType.Function, 122 | name: 'matchERC721WithSafeTransferUsingCriteria', 123 | payable: false, 124 | constant: false, 125 | stateMutability: StateMutability.Nonpayable, 126 | target: validatorAddress, 127 | inputs: [ 128 | { kind: FunctionInputKind.Owner, name: 'from', type: 'address' }, 129 | { kind: FunctionInputKind.Replaceable, name: 'to', type: 'address' }, 130 | { kind: FunctionInputKind.Asset, name: 'token', type: 'address', value: asset.address }, 131 | { kind: FunctionInputKind.Asset, name: 'tokenId', type: 'uint256', value: asset.id }, 132 | {kind: FunctionInputKind.Data, name: 'root', type: 'bytes32', value: merkle ? merkle.root : ""}, 133 | {kind: FunctionInputKind.Data, name: 'proof', type: 'bytes32[]', value: merkle ? merkle.proof : "[]"}, 134 | ], 135 | outputs: [], 136 | }), 137 | }, 138 | }; 139 | -------------------------------------------------------------------------------- /dist/schemaFunctions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.encodeDefaultCall = exports.encodeBuy = exports.encodeAtomicizedBuy = exports.encodeAtomicizedSell = exports.encodeSell = exports.encodeCall = exports.encodeReplacementPattern = void 0; 4 | const bignumber_js_1 = require("bignumber.js"); 5 | const ethABI = require("ethereumjs-abi"); 6 | const wyvern_js_1 = require("wyvern-js"); 7 | const types_1 = require("./types"); 8 | const failWith = (msg) => { 9 | throw new Error(msg); 10 | }; 11 | exports.encodeReplacementPattern = wyvern_js_1.WyvernProtocol.encodeReplacementPattern; 12 | const encodeCall = (abi, parameters) => { 13 | const inputTypes = abi.inputs.map(i => i.type); 14 | return '0x' + Buffer.concat([ 15 | ethABI.methodID(abi.name, inputTypes), 16 | ethABI.rawEncode(inputTypes, parameters), 17 | ]).toString('hex'); 18 | }; 19 | exports.encodeCall = encodeCall; 20 | const encodeSell = (schema, asset, address) => { 21 | const transfer = schema.functions.transfer(asset); 22 | return { 23 | target: transfer.target, 24 | calldata: (0, exports.encodeDefaultCall)(transfer, address), 25 | replacementPattern: (0, exports.encodeReplacementPattern)(transfer), 26 | }; 27 | }; 28 | exports.encodeSell = encodeSell; 29 | const encodeAtomicizedSell = (schema, assets, address, atomicizer) => { 30 | const transactions = assets.map(asset => { 31 | const { target, calldata } = (0, exports.encodeSell)(schema, asset, address); 32 | return { 33 | calldata, 34 | abi: schema.functions.transfer(asset), 35 | address: target, 36 | value: new bignumber_js_1.BigNumber(0), 37 | }; 38 | }); 39 | const atomicizedCalldata = atomicizer 40 | .atomicize(transactions.map(t => t.address), transactions.map(t => t.value), transactions.map(t => new bignumber_js_1.BigNumber((t.calldata.length - 2) / 2)), // subtract 2 for '0x', divide by 2 for hex 41 | transactions.map(t => t.calldata).reduce((x, y) => { 42 | return x + y.slice(2); 43 | })) 44 | .getABIEncodedTransactionData(); 45 | const atomicizedReplacementPattern = wyvern_js_1.WyvernProtocol.encodeAtomicizedReplacementPattern(transactions.map(t => t.abi)); 46 | return { 47 | calldata: atomicizedCalldata, 48 | replacementPattern: atomicizedReplacementPattern, 49 | }; 50 | }; 51 | exports.encodeAtomicizedSell = encodeAtomicizedSell; 52 | const encodeAtomicizedBuy = (schema, assets, address, atomicizer) => { 53 | const transactions = assets.map(asset => { 54 | const { target, calldata } = (0, exports.encodeBuy)(schema, asset, address); 55 | return { 56 | calldata, 57 | abi: schema.functions.transfer(asset), 58 | address: target, 59 | value: new bignumber_js_1.BigNumber(0), 60 | }; 61 | }); 62 | const atomicizedCalldata = atomicizer 63 | .atomicize(transactions.map(t => t.address), transactions.map(t => t.value), transactions.map(t => new bignumber_js_1.BigNumber((t.calldata.length - 2) / 2)), // subtract 2 for '0x', divide by 2 for hex 64 | transactions.map(t => t.calldata).reduce((x, y) => { 65 | return x + y.slice(2); 66 | })) 67 | .getABIEncodedTransactionData(); 68 | const atomicizedReplacementPattern = wyvern_js_1.WyvernProtocol.encodeAtomicizedReplacementPattern(transactions.map(t => t.abi), types_1.FunctionInputKind.Owner); 69 | return { 70 | calldata: atomicizedCalldata, 71 | replacementPattern: atomicizedReplacementPattern, 72 | }; 73 | }; 74 | exports.encodeAtomicizedBuy = encodeAtomicizedBuy; 75 | const encodeBuy = (schema, asset, address) => { 76 | const transfer = schema.functions.transfer(asset); 77 | const replaceables = transfer.inputs.filter((i) => i.kind === types_1.FunctionInputKind.Replaceable); 78 | const ownerInputs = transfer.inputs.filter((i) => i.kind === types_1.FunctionInputKind.Owner); 79 | // Validate 80 | if (replaceables.length !== 1) { 81 | failWith('Only 1 input can match transfer destination, but instead ' + replaceables.length + ' did'); 82 | } 83 | // Compute calldata 84 | const parameters = transfer.inputs.map((input) => { 85 | switch (input.kind) { 86 | case types_1.FunctionInputKind.Replaceable: 87 | return address; 88 | case types_1.FunctionInputKind.Owner: 89 | return wyvern_js_1.WyvernProtocol.generateDefaultValue(input.type); 90 | default: 91 | return input.value.toString(); 92 | } 93 | }); 94 | const calldata = (0, exports.encodeCall)(transfer, parameters); 95 | // Compute replacement pattern 96 | let replacementPattern = '0x'; 97 | if (ownerInputs.length > 0) { 98 | replacementPattern = (0, exports.encodeReplacementPattern)(transfer, types_1.FunctionInputKind.Owner); 99 | } 100 | return { 101 | target: transfer.target, 102 | calldata, 103 | replacementPattern, 104 | }; 105 | }; 106 | exports.encodeBuy = encodeBuy; 107 | const encodeDefaultCall = (abi, address) => { 108 | const parameters = abi.inputs.map(input => { 109 | switch (input.kind) { 110 | case types_1.FunctionInputKind.Replaceable: 111 | return wyvern_js_1.WyvernProtocol.generateDefaultValue(input.type); 112 | case types_1.FunctionInputKind.Owner: 113 | return address; 114 | case types_1.FunctionInputKind.Asset: 115 | default: 116 | return input.value; 117 | } 118 | }); 119 | return (0, exports.encodeCall)(abi, parameters); 120 | }; 121 | exports.encodeDefaultCall = encodeDefaultCall; 122 | //# sourceMappingURL=schemaFunctions.js.map -------------------------------------------------------------------------------- /dist/schemas/ERC1155/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.ERC1155Schema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../types"); 15 | exports.ERC1155Schema = { 16 | version: 1, 17 | deploymentBlock: 0, 18 | name: 'ERC1155', 19 | description: 'Items conforming to the ERC1155 spec, using transferFrom.', 20 | thumbnail: 'https://opensea.io/static/images/opensea-icon.png', 21 | website: 'https://github.com/ethereum/eips/issues/1155', 22 | fields: [ 23 | { name: 'ID', type: 'uint256', description: 'Asset Token ID' }, 24 | { name: 'Address', type: 'address', description: 'Asset Contract Address' }, 25 | { name: 'Quantity', type: 'uint256', description: 'Quantity to transfer' }, 26 | ], 27 | assetFromFields: (fields) => ({ 28 | id: fields.ID, 29 | address: fields.Address, 30 | quantity: fields.Quantity, 31 | }), 32 | assetToFields: (asset) => ({ 33 | ID: asset.id, 34 | Address: asset.address, 35 | Quantity: asset.quantity, 36 | }), 37 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 38 | return { 39 | title: 'ERC1155 Asset: Token ID ' + asset.id + ' at ' + asset.address, 40 | description: 'Trading ' + asset.quantity.toString(), 41 | url: '', 42 | thumbnail: '', 43 | properties: [], 44 | }; 45 | }), 46 | functions: { 47 | transfer: (asset) => ({ 48 | type: ethereum_types_1.AbiType.Function, 49 | name: 'safeTransferFrom', 50 | payable: false, 51 | constant: false, 52 | stateMutability: types_1.StateMutability.Nonpayable, 53 | target: asset.address, 54 | inputs: [ 55 | { kind: types_1.FunctionInputKind.Owner, name: '_from', type: 'address' }, 56 | { kind: types_1.FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 57 | { 58 | kind: types_1.FunctionInputKind.Asset, 59 | name: '_id', 60 | type: 'uint256', 61 | value: asset.id, 62 | }, 63 | { 64 | kind: types_1.FunctionInputKind.Count, 65 | name: '_value', 66 | type: 'uint256', 67 | value: asset.quantity, 68 | }, 69 | { 70 | kind: types_1.FunctionInputKind.Data, 71 | name: '_data', 72 | type: 'bytes', 73 | value: '', 74 | }, 75 | ], 76 | outputs: [], 77 | }), 78 | checkAndTransfer: (asset, validatorAddress, merkle) => ({ 79 | type: ethereum_types_1.AbiType.Function, 80 | name: 'matchERC1155UsingCriteria', 81 | payable: false, 82 | constant: false, 83 | stateMutability: types_1.StateMutability.Nonpayable, 84 | target: validatorAddress, 85 | inputs: [ 86 | { kind: types_1.FunctionInputKind.Owner, name: 'from', type: 'address' }, 87 | { kind: types_1.FunctionInputKind.Replaceable, name: 'to', type: 'address' }, 88 | { 89 | kind: types_1.FunctionInputKind.Asset, 90 | name: 'token', 91 | type: 'address', 92 | value: asset.address, 93 | }, 94 | { 95 | kind: types_1.FunctionInputKind.Asset, 96 | name: 'tokenId', 97 | type: 'uint256', 98 | value: asset.id, 99 | }, 100 | { 101 | kind: types_1.FunctionInputKind.Count, 102 | name: 'amount', 103 | type: 'uint256', 104 | value: asset.quantity, 105 | }, 106 | { 107 | kind: types_1.FunctionInputKind.Data, 108 | name: 'root', 109 | type: 'bytes32', 110 | value: merkle ? merkle.root : '', 111 | }, 112 | { 113 | kind: types_1.FunctionInputKind.Data, 114 | name: 'proof', 115 | type: 'bytes32[]', 116 | value: merkle ? merkle.proof : '[]', 117 | }, 118 | ], 119 | outputs: [], 120 | }), 121 | countOf: (asset) => ({ 122 | type: ethereum_types_1.AbiType.Function, 123 | name: 'balanceOf', 124 | payable: false, 125 | constant: true, 126 | stateMutability: types_1.StateMutability.View, 127 | target: asset.address, 128 | inputs: [ 129 | { kind: types_1.FunctionInputKind.Owner, name: '_owner', type: 'address' }, 130 | { 131 | kind: types_1.FunctionInputKind.Asset, 132 | name: '_id', 133 | type: 'uint256', 134 | value: asset.id, 135 | }, 136 | ], 137 | outputs: [ 138 | { kind: types_1.FunctionOutputKind.Count, name: 'balance', type: 'uint' }, 139 | ], 140 | assetFromOutputs: (outputs) => outputs.balance, 141 | }), 142 | assetsOfOwnerByIndex: [], 143 | }, 144 | events: { 145 | transfer: [], 146 | }, 147 | hash: (asset) => asset.address + '-' + asset.id, 148 | }; 149 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/schemas/ERC721/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.ERC721v3Schema = exports.ERC721Schema = void 0; 13 | const ethereum_types_1 = require("ethereum-types"); 14 | const types_1 = require("../../types"); 15 | exports.ERC721Schema = { 16 | version: 2, 17 | deploymentBlock: 0, 18 | name: 'ERC721', 19 | description: 'Items conforming to the ERC721 spec, using transferFrom.', 20 | thumbnail: 'https://opensea.io/static/images/opensea-icon.png', 21 | website: 'http://erc721.org/', 22 | fields: [ 23 | { name: 'ID', type: 'uint256', description: 'Asset Token ID' }, 24 | { name: 'Address', type: 'address', description: 'Asset Contract Address' }, 25 | ], 26 | assetFromFields: (fields) => ({ 27 | id: fields.ID, 28 | address: fields.Address, 29 | }), 30 | assetToFields: asset => ({ 31 | ID: asset.id, 32 | Address: asset.address, 33 | }), 34 | formatter: (asset) => __awaiter(void 0, void 0, void 0, function* () { 35 | return { 36 | title: 'ERC721 Asset: Token ID ' + asset.id + ' at ' + asset.address, 37 | description: '', 38 | url: '', 39 | thumbnail: '', 40 | properties: [], 41 | }; 42 | }), 43 | functions: { 44 | transfer: asset => ({ 45 | type: ethereum_types_1.AbiType.Function, 46 | name: 'transferFrom', 47 | payable: false, 48 | constant: false, 49 | stateMutability: types_1.StateMutability.Nonpayable, 50 | target: asset.address, 51 | inputs: [ 52 | { kind: types_1.FunctionInputKind.Owner, name: '_from', type: 'address' }, 53 | { kind: types_1.FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 54 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset.id }, 55 | ], 56 | outputs: [], 57 | }), 58 | checkAndTransfer: (asset, validatorAddress, merkle) => ({ 59 | type: ethereum_types_1.AbiType.Function, 60 | name: 'matchERC721UsingCriteria', 61 | payable: false, 62 | constant: false, 63 | stateMutability: types_1.StateMutability.Nonpayable, 64 | target: validatorAddress, 65 | inputs: [ 66 | { kind: types_1.FunctionInputKind.Owner, name: 'from', type: 'address' }, 67 | { kind: types_1.FunctionInputKind.Replaceable, name: 'to', type: 'address' }, 68 | { kind: types_1.FunctionInputKind.Asset, name: 'token', type: 'address', value: asset.address }, 69 | { kind: types_1.FunctionInputKind.Asset, name: 'tokenId', type: 'uint256', value: asset.id }, 70 | { kind: types_1.FunctionInputKind.Data, name: 'root', type: 'bytes32', value: merkle ? merkle.root : "" }, 71 | { kind: types_1.FunctionInputKind.Data, name: 'proof', type: 'bytes32[]', value: merkle ? merkle.proof : "[]" }, 72 | ], 73 | outputs: [], 74 | }), 75 | ownerOf: asset => ({ 76 | type: ethereum_types_1.AbiType.Function, 77 | name: 'ownerOf', 78 | payable: false, 79 | constant: true, 80 | stateMutability: types_1.StateMutability.View, 81 | target: asset.address, 82 | inputs: [ 83 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset.id }, 84 | ], 85 | outputs: [ 86 | { kind: types_1.FunctionOutputKind.Owner, name: 'owner', type: 'address' }, 87 | ], 88 | }), 89 | assetsOfOwnerByIndex: [], 90 | }, 91 | events: { 92 | transfer: [], 93 | }, 94 | hash: asset => asset.address + '-' + asset.id, 95 | }; 96 | exports.ERC721v3Schema = Object.assign(Object.assign({}, exports.ERC721Schema), { version: 3, name: 'ERC721v3', description: 'Items conforming to the ERC721 v3 spec, using safeTransferFrom.', functions: Object.assign(Object.assign({}, exports.ERC721Schema.functions), { transfer: asset => ({ 97 | type: ethereum_types_1.AbiType.Function, 98 | name: 'safeTransferFrom', 99 | payable: false, 100 | constant: false, 101 | stateMutability: types_1.StateMutability.Nonpayable, 102 | target: asset.address, 103 | inputs: [ 104 | { kind: types_1.FunctionInputKind.Owner, name: '_from', type: 'address' }, 105 | { kind: types_1.FunctionInputKind.Replaceable, name: '_to', type: 'address' }, 106 | { kind: types_1.FunctionInputKind.Asset, name: '_tokenId', type: 'uint256', value: asset.id }, 107 | ], 108 | outputs: [], 109 | }), checkAndTransfer: (asset, validatorAddress, merkle) => ({ 110 | type: ethereum_types_1.AbiType.Function, 111 | name: 'matchERC721WithSafeTransferUsingCriteria', 112 | payable: false, 113 | constant: false, 114 | stateMutability: types_1.StateMutability.Nonpayable, 115 | target: validatorAddress, 116 | inputs: [ 117 | { kind: types_1.FunctionInputKind.Owner, name: 'from', type: 'address' }, 118 | { kind: types_1.FunctionInputKind.Replaceable, name: 'to', type: 'address' }, 119 | { kind: types_1.FunctionInputKind.Asset, name: 'token', type: 'address', value: asset.address }, 120 | { kind: types_1.FunctionInputKind.Asset, name: 'tokenId', type: 'uint256', value: asset.id }, 121 | { kind: types_1.FunctionInputKind.Data, name: 'root', type: 'bytes32', value: merkle ? merkle.root : "" }, 122 | { kind: types_1.FunctionInputKind.Data, name: 'proof', type: 'bytes32[]', value: merkle ? merkle.proof : "[]" }, 123 | ], 124 | outputs: [], 125 | }) }) }); 126 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /src/schemaFunctions.ts: -------------------------------------------------------------------------------- 1 | import { BigNumber } from 'bignumber.js'; 2 | import * as ethABI from 'ethereumjs-abi'; 3 | import { WyvernProtocol } from 'wyvern-js'; 4 | import { WyvernAtomicizerContract } from 'wyvern-js/lib/abi_gen/wyvern_atomicizer'; 5 | 6 | import { 7 | AnnotatedFunctionABI, 8 | FunctionInputKind, 9 | Schema, 10 | } from './types'; 11 | 12 | const failWith = (msg: string): any => { 13 | throw new Error(msg); 14 | }; 15 | 16 | export const encodeReplacementPattern = WyvernProtocol.encodeReplacementPattern; 17 | // const generateDefaultValue = (type: string): any => { 18 | // switch (type) { 19 | // case 'address': 20 | // case 'bytes20': 21 | // /* Null address is sometimes checked in transfer calls. */ 22 | // return '0x1111111111111111111111111111111111111111'; 23 | // case 'bytes32': 24 | // return '0x0000000000000000000000000000000000000000000000000000000000000000'; 25 | // case 'bool': 26 | // return false; 27 | // case 'int': 28 | // case 'uint': 29 | // case 'uint8': 30 | // case 'uint16': 31 | // case 'uint32': 32 | // case 'uint64': 33 | // case 'uint256': 34 | // return 0; 35 | // default: 36 | // failWith('Default value not yet implemented for type: ' + type); 37 | // } 38 | // }; 39 | // // Copied from wyvern-js 3.0.0-rc1, with generateDefaultValue changed 40 | // export const encodeReplacementPattern: ReplacementEncoder = (abi, replaceKind = FunctionInputKind.Replaceable): string => { 41 | // const allowReplaceByte = '1'; 42 | // const doNotAllowReplaceByte = '0'; 43 | // /* Four bytes for method ID. */ 44 | // const maskArr: string[] = [doNotAllowReplaceByte, doNotAllowReplaceByte, 45 | // doNotAllowReplaceByte, doNotAllowReplaceByte]; 46 | // /* This DOES NOT currently support dynamic-length data (arrays). */ 47 | // abi.inputs.map(i => { 48 | // const type = ethABI.elementaryName(i.type); 49 | // const encoded = ethABI.encodeSingle(type, generateDefaultValue(i.type)); 50 | // if (i.kind === replaceKind) { 51 | // maskArr.push((allowReplaceByte as any).repeat(encoded.length)); 52 | // } else { 53 | // maskArr.push((doNotAllowReplaceByte as any).repeat(encoded.length)); 54 | // } 55 | // }); 56 | // const mask = maskArr.reduce((x, y) => x + y, ''); 57 | // const ret = []; 58 | // /* Encode into bytes. */ 59 | // for (const char of mask) { 60 | // const byte = char === allowReplaceByte ? 255 : 0; 61 | // const buf = Buffer.alloc(1); 62 | // buf.writeUInt8(byte, 0); 63 | // ret.push(buf); 64 | // } 65 | // return '0x' + Buffer.concat(ret).toString('hex'); 66 | // } 67 | 68 | export interface LimitedCallSpec { 69 | target: string; 70 | calldata: string; 71 | } 72 | 73 | export const encodeCall = (abi: AnnotatedFunctionABI, parameters: any[]): string => { 74 | const inputTypes = abi.inputs.map(i => i.type); 75 | return '0x' + Buffer.concat([ 76 | ethABI.methodID(abi.name, inputTypes), 77 | ethABI.rawEncode(inputTypes, parameters), 78 | ]).toString('hex'); 79 | }; 80 | 81 | export interface CallSpec { 82 | target: string; 83 | calldata: string; 84 | replacementPattern: string; 85 | } 86 | 87 | export type SellEncoder = (schema: Schema, asset: T, address: string) => CallSpec; 88 | 89 | export const encodeSell: SellEncoder = (schema, asset, address) => { 90 | const transfer = schema.functions.transfer(asset); 91 | return { 92 | target: transfer.target, 93 | calldata: encodeDefaultCall(transfer, address), 94 | replacementPattern: encodeReplacementPattern(transfer), 95 | }; 96 | }; 97 | 98 | export type AtomicizedSellEncoder = (schema: Schema, assets: T[], address: string, atomicizer: WyvernAtomicizerContract) => Partial; 99 | 100 | export const encodeAtomicizedSell: AtomicizedSellEncoder = (schema, assets, address, atomicizer) => { 101 | const transactions = assets.map(asset => { 102 | const { target, calldata } = encodeSell(schema, asset, address); 103 | return { 104 | calldata, 105 | abi: schema.functions.transfer(asset), 106 | address: target, 107 | value: new BigNumber(0), 108 | }; 109 | }); 110 | 111 | const atomicizedCalldata = atomicizer 112 | .atomicize( 113 | transactions.map(t => t.address), 114 | transactions.map(t => t.value), 115 | transactions.map(t => new BigNumber((t.calldata.length - 2) / 2)), // subtract 2 for '0x', divide by 2 for hex 116 | transactions.map(t => t.calldata).reduce((x, y) => { 117 | return x + y.slice(2); 118 | }), // cut off the '0x' 119 | ) 120 | .getABIEncodedTransactionData(); 121 | 122 | const atomicizedReplacementPattern = WyvernProtocol.encodeAtomicizedReplacementPattern(transactions.map(t => t.abi)); 123 | 124 | return { 125 | calldata: atomicizedCalldata, 126 | replacementPattern: atomicizedReplacementPattern, 127 | }; 128 | }; 129 | 130 | export type AtomicizedBuyEncoder = (schema: Schema, assets: T[], address: string, atomicizer: WyvernAtomicizerContract) => Partial; 131 | 132 | export const encodeAtomicizedBuy: AtomicizedBuyEncoder = (schema, assets, address, atomicizer) => { 133 | const transactions = assets.map(asset => { 134 | const { target, calldata } = encodeBuy(schema, asset, address); 135 | return { 136 | calldata, 137 | abi: schema.functions.transfer(asset), 138 | address: target, 139 | value: new BigNumber(0), 140 | }; 141 | }); 142 | 143 | const atomicizedCalldata = atomicizer 144 | .atomicize( 145 | transactions.map(t => t.address), 146 | transactions.map(t => t.value), 147 | transactions.map(t => new BigNumber((t.calldata.length - 2) / 2)), // subtract 2 for '0x', divide by 2 for hex 148 | transactions.map(t => t.calldata).reduce((x, y) => { 149 | return x + y.slice(2); 150 | }), // cut off the '0x' 151 | ) 152 | .getABIEncodedTransactionData(); 153 | 154 | const atomicizedReplacementPattern = WyvernProtocol.encodeAtomicizedReplacementPattern(transactions.map(t => t.abi), FunctionInputKind.Owner); 155 | 156 | return { 157 | calldata: atomicizedCalldata, 158 | replacementPattern: atomicizedReplacementPattern, 159 | }; 160 | }; 161 | 162 | export type BuyEncoder = (schema: Schema, asset: T, address: string) => CallSpec; 163 | 164 | export const encodeBuy: BuyEncoder = (schema, asset, address) => { 165 | const transfer = schema.functions.transfer(asset); 166 | const replaceables = transfer.inputs.filter((i: any) => i.kind === FunctionInputKind.Replaceable); 167 | const ownerInputs = transfer.inputs.filter((i: any) => i.kind === FunctionInputKind.Owner); 168 | 169 | // Validate 170 | if (replaceables.length !== 1) { 171 | failWith('Only 1 input can match transfer destination, but instead ' + replaceables.length + ' did'); 172 | } 173 | 174 | // Compute calldata 175 | const parameters = transfer.inputs.map((input: any) => { 176 | switch (input.kind) { 177 | case FunctionInputKind.Replaceable: 178 | return address; 179 | case FunctionInputKind.Owner: 180 | return WyvernProtocol.generateDefaultValue(input.type); 181 | default: 182 | return input.value.toString(); 183 | } 184 | }); 185 | const calldata = encodeCall(transfer, parameters); 186 | 187 | // Compute replacement pattern 188 | let replacementPattern = '0x'; 189 | if (ownerInputs.length > 0) { 190 | replacementPattern = encodeReplacementPattern(transfer, FunctionInputKind.Owner); 191 | } 192 | 193 | return { 194 | target: transfer.target, 195 | calldata, 196 | replacementPattern, 197 | }; 198 | }; 199 | 200 | export type DefaultCallEncoder = (abi: AnnotatedFunctionABI, address: string) => string; 201 | 202 | export const encodeDefaultCall: DefaultCallEncoder = (abi, address) => { 203 | const parameters = abi.inputs.map(input => { 204 | switch (input.kind) { 205 | case FunctionInputKind.Replaceable: 206 | return WyvernProtocol.generateDefaultValue(input.type); 207 | case FunctionInputKind.Owner: 208 | return address; 209 | case FunctionInputKind.Asset: 210 | default: 211 | return input.value; 212 | } 213 | }); 214 | return encodeCall(abi, parameters); 215 | }; 216 | 217 | export type ReplacementEncoder = (abi: AnnotatedFunctionABI, kind?: FunctionInputKind) => string; 218 | --------------------------------------------------------------------------------