commit 76c4d818093143c860ae45a7c6596351af814892 Author: yyy9608 Date: Fri Apr 26 11:47:34 2024 +0800 move diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..27814b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +.env + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/README.md b/README.md new file mode 100644 index 0000000..4675903 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +``` + + 1.git clone --- 拉取代碼 + 2.npm install or yarn 安裝依賴 + 3.copy .env.md 複製到 .env + 4.npm run start or yarn start 運行項目 + + + yarn build or npm run build + + + yarn deploy:dev or npm run build + + + yarn deploy:prod or npm run deploy:prod +``` \ No newline at end of file diff --git a/config/env.js b/config/env.js new file mode 100644 index 0000000..ffa7e49 --- /dev/null +++ b/config/env.js @@ -0,0 +1,104 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); + +// Make sure that including paths.js after env.js will read .env variables. +delete require.cache[require.resolve('./paths')]; + +const NODE_ENV = process.env.NODE_ENV; +if (!NODE_ENV) { + throw new Error( + 'The NODE_ENV environment variable is required but was not specified.' + ); +} + +// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use +const dotenvFiles = [ + `${paths.dotenv}.${NODE_ENV}.local`, + // Don't include `.env.local` for `test` environment + // since normally you expect tests to produce the same + // results for everyone + NODE_ENV !== 'test' && `${paths.dotenv}.local`, + `${paths.dotenv}.${NODE_ENV}`, + paths.dotenv, +].filter(Boolean); + +// Load environment variables from .env* files. Suppress warnings using silent +// if this file is missing. dotenv will never modify any environment variables +// that have already been set. Variable expansion is supported in .env files. +// https://github.com/motdotla/dotenv +// https://github.com/motdotla/dotenv-expand +dotenvFiles.forEach(dotenvFile => { + if (fs.existsSync(dotenvFile)) { + require('dotenv-expand')( + require('dotenv').config({ + path: dotenvFile, + }) + ); + } +}); + +// We support resolving modules according to `NODE_PATH`. +// This lets you use absolute paths in imports inside large monorepos: +// https://github.com/facebook/create-react-app/issues/253. +// It works similar to `NODE_PATH` in Node itself: +// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. +// Otherwise, we risk importing Node.js core modules into an app instead of webpack shims. +// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421 +// We also resolve them to make sure all tools using them work consistently. +const appDirectory = fs.realpathSync(process.cwd()); +process.env.NODE_PATH = (process.env.NODE_PATH || '') + .split(path.delimiter) + .filter(folder => folder && !path.isAbsolute(folder)) + .map(folder => path.resolve(appDirectory, folder)) + .join(path.delimiter); + +// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be +// injected into the application via DefinePlugin in webpack configuration. +const REACT_APP = /^REACT_APP_/i; + +function getClientEnvironment(publicUrl) { + const raw = Object.keys(process.env) + .filter(key => REACT_APP.test(key)) + .reduce( + (env, key) => { + env[key] = process.env[key]; + return env; + }, + { + // Useful for determining whether we’re running in production mode. + // Most importantly, it switches React into the correct mode. + NODE_ENV: process.env.NODE_ENV || 'development', + // Useful for resolving the correct path to static assets in `public`. + // For example, . + // This should only be used as an escape hatch. Normally you would put + // images into the `src` and `import` them in code to get their paths. + PUBLIC_URL: publicUrl, + // We support configuring the sockjs pathname during development. + // These settings let a developer run multiple simultaneous projects. + // They are used as the connection `hostname`, `pathname` and `port` + // in webpackHotDevClient. They are used as the `sockHost`, `sockPath` + // and `sockPort` options in webpack-dev-server. + WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST, + WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH, + WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT, + // Whether or not react-refresh is enabled. + // It is defined here so it is available in the webpackHotDevClient. + FAST_REFRESH: process.env.FAST_REFRESH !== 'false', + } + ); + // Stringify all values so we can feed into webpack DefinePlugin + const stringified = { + 'process.env': Object.keys(raw).reduce((env, key) => { + env[key] = JSON.stringify(raw[key]); + return env; + }, {}), + }; + + return { raw, stringified }; +} + +module.exports = getClientEnvironment; diff --git a/config/getHttpsConfig.js b/config/getHttpsConfig.js new file mode 100644 index 0000000..013d493 --- /dev/null +++ b/config/getHttpsConfig.js @@ -0,0 +1,66 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const crypto = require('crypto'); +const chalk = require('react-dev-utils/chalk'); +const paths = require('./paths'); + +// Ensure the certificate and key provided are valid and if not +// throw an easy to debug error +function validateKeyAndCerts({ cert, key, keyFile, crtFile }) { + let encrypted; + try { + // publicEncrypt will throw an error with an invalid cert + encrypted = crypto.publicEncrypt(cert, Buffer.from('test')); + } catch (err) { + throw new Error( + `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}` + ); + } + + try { + // privateDecrypt will throw an error with an invalid key + crypto.privateDecrypt(key, encrypted); + } catch (err) { + throw new Error( + `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${ + err.message + }` + ); + } +} + +// Read file and throw an error if it doesn't exist +function readEnvFile(file, type) { + if (!fs.existsSync(file)) { + throw new Error( + `You specified ${chalk.cyan( + type + )} in your env, but the file "${chalk.yellow(file)}" can't be found.` + ); + } + return fs.readFileSync(file); +} + +// Get the https config +// Return cert files if provided in env, otherwise just true or false +function getHttpsConfig() { + const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env; + const isHttps = HTTPS === 'true'; + + if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) { + const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE); + const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE); + const config = { + cert: readEnvFile(crtFile, 'SSL_CRT_FILE'), + key: readEnvFile(keyFile, 'SSL_KEY_FILE'), + }; + + validateKeyAndCerts({ ...config, keyFile, crtFile }); + return config; + } + return isHttps; +} + +module.exports = getHttpsConfig; diff --git a/config/jest/babelTransform.js b/config/jest/babelTransform.js new file mode 100644 index 0000000..5b391e4 --- /dev/null +++ b/config/jest/babelTransform.js @@ -0,0 +1,29 @@ +'use strict'; + +const babelJest = require('babel-jest').default; + +const hasJsxRuntime = (() => { + if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') { + return false; + } + + try { + require.resolve('react/jsx-runtime'); + return true; + } catch (e) { + return false; + } +})(); + +module.exports = babelJest.createTransformer({ + presets: [ + [ + require.resolve('babel-preset-react-app'), + { + runtime: hasJsxRuntime ? 'automatic' : 'classic', + }, + ], + ], + babelrc: false, + configFile: false, +}); diff --git a/config/jest/cssTransform.js b/config/jest/cssTransform.js new file mode 100644 index 0000000..8f65114 --- /dev/null +++ b/config/jest/cssTransform.js @@ -0,0 +1,14 @@ +'use strict'; + +// This is a custom Jest transformer turning style imports into empty objects. +// http://facebook.github.io/jest/docs/en/webpack.html + +module.exports = { + process() { + return 'module.exports = {};'; + }, + getCacheKey() { + // The output is always the same. + return 'cssTransform'; + }, +}; diff --git a/config/jest/fileTransform.js b/config/jest/fileTransform.js new file mode 100644 index 0000000..aab6761 --- /dev/null +++ b/config/jest/fileTransform.js @@ -0,0 +1,40 @@ +'use strict'; + +const path = require('path'); +const camelcase = require('camelcase'); + +// This is a custom Jest transformer turning file imports into filenames. +// http://facebook.github.io/jest/docs/en/webpack.html + +module.exports = { + process(src, filename) { + const assetFilename = JSON.stringify(path.basename(filename)); + + if (filename.match(/\.svg$/)) { + // Based on how SVGR generates a component name: + // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6 + const pascalCaseFilename = camelcase(path.parse(filename).name, { + pascalCase: true, + }); + const componentName = `Svg${pascalCaseFilename}`; + return `const React = require('react'); + module.exports = { + __esModule: true, + default: ${assetFilename}, + ReactComponent: React.forwardRef(function ${componentName}(props, ref) { + return { + $$typeof: Symbol.for('react.element'), + type: 'svg', + ref: ref, + key: null, + props: Object.assign({}, props, { + children: ${assetFilename} + }) + }; + }), + };`; + } + + return `module.exports = ${assetFilename};`; + }, +}; diff --git a/config/modules.js b/config/modules.js new file mode 100644 index 0000000..d63e41d --- /dev/null +++ b/config/modules.js @@ -0,0 +1,134 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); +const chalk = require('react-dev-utils/chalk'); +const resolve = require('resolve'); + +/** + * Get additional module paths based on the baseUrl of a compilerOptions object. + * + * @param {Object} options + */ +function getAdditionalModulePaths(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return ''; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + // We don't need to do anything if `baseUrl` is set to `node_modules`. This is + // the default behavior. + if (path.relative(paths.appNodeModules, baseUrlResolved) === '') { + return null; + } + + // Allow the user set the `baseUrl` to `appSrc`. + if (path.relative(paths.appSrc, baseUrlResolved) === '') { + return [paths.appSrc]; + } + + // If the path is equal to the root directory we ignore it here. + // We don't want to allow importing from the root directly as source files are + // not transpiled outside of `src`. We do allow importing them with the + // absolute path (e.g. `src/Components/Button.js`) but we set that up with + // an alias. + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return null; + } + + // Otherwise, throw an error. + throw new Error( + chalk.red.bold( + "Your project's `baseUrl` can only be set to `src` or `node_modules`." + + ' Create React App does not support other values at this time.' + ) + ); +} + +/** + * Get webpack aliases based on the baseUrl of a compilerOptions object. + * + * @param {*} options + */ +function getWebpackAliases(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return {}; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return { + src: paths.appSrc, + }; + } +} + +/** + * Get jest aliases based on the baseUrl of a compilerOptions object. + * + * @param {*} options + */ +function getJestAliases(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return {}; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return { + '^src/(.*)$': '/src/$1', + }; + } +} + +function getModules() { + // Check if TypeScript is setup + const hasTsConfig = fs.existsSync(paths.appTsConfig); + const hasJsConfig = fs.existsSync(paths.appJsConfig); + + if (hasTsConfig && hasJsConfig) { + throw new Error( + 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' + ); + } + + let config; + + // If there's a tsconfig.json we assume it's a + // TypeScript project and set up the config + // based on tsconfig.json + if (hasTsConfig) { + const ts = require(resolve.sync('typescript', { + basedir: paths.appNodeModules, + })); + config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config; + // Otherwise we'll check if there is jsconfig.json + // for non TS projects. + } else if (hasJsConfig) { + config = require(paths.appJsConfig); + } + + config = config || {}; + const options = config.compilerOptions || {}; + + const additionalModulePaths = getAdditionalModulePaths(options); + + return { + additionalModulePaths: additionalModulePaths, + webpackAliases: getWebpackAliases(options), + jestAliases: getJestAliases(options), + hasTsConfig, + }; +} + +module.exports = getModules(); diff --git a/config/paths.js b/config/paths.js new file mode 100644 index 0000000..f0a6cd9 --- /dev/null +++ b/config/paths.js @@ -0,0 +1,77 @@ +'use strict'; + +const path = require('path'); +const fs = require('fs'); +const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath'); + +// Make sure any symlinks in the project folder are resolved: +// https://github.com/facebook/create-react-app/issues/637 +const appDirectory = fs.realpathSync(process.cwd()); +const resolveApp = relativePath => path.resolve(appDirectory, relativePath); + +// We use `PUBLIC_URL` environment variable or "homepage" field to infer +// "public path" at which the app is served. +// webpack needs to know it to put the right + + + \ No newline at end of file diff --git a/public/initialization.js b/public/initialization.js new file mode 100644 index 0000000..2a67be3 --- /dev/null +++ b/public/initialization.js @@ -0,0 +1,55 @@ +(() => { + // 获取屏幕大小 + const getScreen = () => { + const width = window.innerWidth; + const height = window.innerHeight; + document.body.style = ` + --width:${width}px; + --height:${height}px; + `; + } + getScreen() + // 监听屏幕变化 + window.addEventListener('resize', getScreen); + + // 加载loading + // let publicLoading = document.getElementById('loading'); + // let publicWidth = 0; + // let publicTimerID = null; + // publicTimerID = setInterval(() => { + // if (publicWidth > 99) { + // clearInterval(publicTimerID); + // return; + // }; + // publicWidth += 1; + // publicLoading.style.width = `${publicWidth}%`; + // }, 100); + + // ios 禁用屏幕缩放 + document.documentElement.addEventListener( + "touchstart", + function (event) { + if (event.touches.length > 1) { + event.preventDefault(); + } + }, + false + ); + + var lastTouchEnd = 0; + document.documentElement.addEventListener( + "touchend", + function (event) { + var now = Date.now(); + if (now - lastTouchEnd <= 300) { + event.preventDefault(); + } + lastTouchEnd = now; + }, + false + ); + + document.addEventListener("gesturestart", function (event) { + event.preventDefault(); + }); +})() \ No newline at end of file diff --git a/public/loading/loading-1.png b/public/loading/loading-1.png new file mode 100644 index 0000000..9c3057f Binary files /dev/null and b/public/loading/loading-1.png differ diff --git a/public/loading/loading-2.png b/public/loading/loading-2.png new file mode 100644 index 0000000..bca09e5 Binary files /dev/null and b/public/loading/loading-2.png differ diff --git a/public/loading/loading-3.png b/public/loading/loading-3.png new file mode 100644 index 0000000..35b2860 Binary files /dev/null and b/public/loading/loading-3.png differ diff --git a/public/loading/loading-4.png b/public/loading/loading-4.png new file mode 100644 index 0000000..388c0d3 Binary files /dev/null and b/public/loading/loading-4.png differ diff --git a/public/loading/loading-5.png b/public/loading/loading-5.png new file mode 100644 index 0000000..c7ea1b6 Binary files /dev/null and b/public/loading/loading-5.png differ diff --git a/public/logo192.png b/public/logo192.png new file mode 100644 index 0000000..5974c60 Binary files /dev/null and b/public/logo192.png differ diff --git a/public/logo512.png b/public/logo512.png new file mode 100644 index 0000000..5974c60 Binary files /dev/null and b/public/logo512.png differ diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..df534d4 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "SOFIL", + "name": "SOFIL", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..e9e57dc --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 0000000..8a9acaa --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,217 @@ +'use strict'; + +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'production'; +process.env.NODE_ENV = 'production'; + +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + +// Ensure environment variables are read. +require('../config/env'); + +const path = require('path'); +const chalk = require('react-dev-utils/chalk'); +const fs = require('fs-extra'); +const bfj = require('bfj'); +const webpack = require('webpack'); +const configFactory = require('../config/webpack.config'); +const paths = require('../config/paths'); +const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); +const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages'); +const printHostingInstructions = require('react-dev-utils/printHostingInstructions'); +const FileSizeReporter = require('react-dev-utils/FileSizeReporter'); +const printBuildError = require('react-dev-utils/printBuildError'); + +const measureFileSizesBeforeBuild = + FileSizeReporter.measureFileSizesBeforeBuild; +const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild; +const useYarn = fs.existsSync(paths.yarnLockFile); + +// These sizes are pretty large. We'll warn for bundles exceeding them. +const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024; +const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024; + +const isInteractive = process.stdout.isTTY; + +// Warn and crash if required files are missing +if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { + process.exit(1); +} + +const argv = process.argv.slice(2); +const writeStatsJson = argv.indexOf('--stats') !== -1; + +// Generate configuration +const config = configFactory('production'); + +// We require that you explicitly set browsers and do not fall back to +// browserslist defaults. +const { checkBrowsers } = require('react-dev-utils/browsersHelper'); +checkBrowsers(paths.appPath, isInteractive) + .then(() => { + // First, read the current file sizes in build directory. + // This lets us display how much they changed later. + return measureFileSizesBeforeBuild(paths.appBuild); + }) + .then(previousFileSizes => { + // Remove all content but keep the directory so that + // if you're in it, you don't end up in Trash + fs.emptyDirSync(paths.appBuild); + // Merge with the public folder + copyPublicFolder(); + // Start the webpack build + return build(previousFileSizes); + }) + .then( + ({ stats, previousFileSizes, warnings }) => { + if (warnings.length) { + console.log(chalk.yellow('Compiled with warnings.\n')); + console.log(warnings.join('\n\n')); + console.log( + '\nSearch for the ' + + chalk.underline(chalk.yellow('keywords')) + + ' to learn more about each warning.' + ); + console.log( + 'To ignore, add ' + + chalk.cyan('// eslint-disable-next-line') + + ' to the line before.\n' + ); + } else { + console.log(chalk.green('Compiled successfully.\n')); + } + + console.log('File sizes after gzip:\n'); + printFileSizesAfterBuild( + stats, + previousFileSizes, + paths.appBuild, + WARN_AFTER_BUNDLE_GZIP_SIZE, + WARN_AFTER_CHUNK_GZIP_SIZE + ); + console.log(); + + const appPackage = require(paths.appPackageJson); + const publicUrl = paths.publicUrlOrPath; + const publicPath = config.output.publicPath; + const buildFolder = path.relative(process.cwd(), paths.appBuild); + printHostingInstructions( + appPackage, + publicUrl, + publicPath, + buildFolder, + useYarn + ); + }, + err => { + const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true'; + if (tscCompileOnError) { + console.log( + chalk.yellow( + 'Compiled with the following type errors (you may want to check these before deploying your app):\n' + ) + ); + printBuildError(err); + } else { + console.log(chalk.red('Failed to compile.\n')); + printBuildError(err); + process.exit(1); + } + } + ) + .catch(err => { + if (err && err.message) { + console.log(err.message); + } + process.exit(1); + }); + +// Create the production build and print the deployment instructions. +function build(previousFileSizes) { + console.log('Creating an optimized production build...'); + + const compiler = webpack(config); + return new Promise((resolve, reject) => { + compiler.run((err, stats) => { + let messages; + if (err) { + if (!err.message) { + return reject(err); + } + + let errMessage = err.message; + + // Add additional information for postcss errors + if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) { + errMessage += + '\nCompileError: Begins at CSS selector ' + + err['postcssNode'].selector; + } + + messages = formatWebpackMessages({ + errors: [errMessage], + warnings: [], + }); + } else { + messages = formatWebpackMessages( + stats.toJson({ all: false, warnings: true, errors: true }) + ); + } + if (messages.errors.length) { + // Only keep the first error. Others are often indicative + // of the same problem, but confuse the reader with noise. + if (messages.errors.length > 1) { + messages.errors.length = 1; + } + return reject(new Error(messages.errors.join('\n\n'))); + } + if ( + process.env.CI && + (typeof process.env.CI !== 'string' || + process.env.CI.toLowerCase() !== 'false') && + messages.warnings.length + ) { + // Ignore sourcemap warnings in CI builds. See #8227 for more info. + const filteredWarnings = messages.warnings.filter( + w => !/Failed to parse source map/.test(w) + ); + if (filteredWarnings.length) { + console.log( + chalk.yellow( + '\nTreating warnings as errors because process.env.CI = true.\n' + + 'Most CI servers set it automatically.\n' + ) + ); + return reject(new Error(filteredWarnings.join('\n\n'))); + } + } + + const resolveArgs = { + stats, + previousFileSizes, + warnings: messages.warnings, + }; + + if (writeStatsJson) { + return bfj + .write(paths.appBuild + '/bundle-stats.json', stats.toJson()) + .then(() => resolve(resolveArgs)) + .catch(error => reject(new Error(error))); + } + + return resolve(resolveArgs); + }); + }); +} + +function copyPublicFolder() { + fs.copySync(paths.appPublic, paths.appBuild, { + dereference: true, + filter: file => file !== paths.appHtml, + }); +} diff --git a/scripts/start.js b/scripts/start.js new file mode 100644 index 0000000..4104798 --- /dev/null +++ b/scripts/start.js @@ -0,0 +1,154 @@ +'use strict'; + +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'development'; +process.env.NODE_ENV = 'development'; + +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + +// Ensure environment variables are read. +require('../config/env'); + +const fs = require('fs'); +const chalk = require('react-dev-utils/chalk'); +const webpack = require('webpack'); +const WebpackDevServer = require('webpack-dev-server'); +const clearConsole = require('react-dev-utils/clearConsole'); +const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); +const { + choosePort, + createCompiler, + prepareProxy, + prepareUrls, +} = require('react-dev-utils/WebpackDevServerUtils'); +const openBrowser = require('react-dev-utils/openBrowser'); +const semver = require('semver'); +const paths = require('../config/paths'); +const configFactory = require('../config/webpack.config'); +const createDevServerConfig = require('../config/webpackDevServer.config'); +const getClientEnvironment = require('../config/env'); +const react = require(require.resolve('react', { paths: [paths.appPath] })); + +const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1)); +const useYarn = fs.existsSync(paths.yarnLockFile); +const isInteractive = process.stdout.isTTY; + +// Warn and crash if required files are missing +if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { + process.exit(1); +} + +// Tools like Cloud9 rely on this. +const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; +const HOST = process.env.HOST || '0.0.0.0'; + +if (process.env.HOST) { + console.log( + chalk.cyan( + `Attempting to bind to HOST environment variable: ${chalk.yellow( + chalk.bold(process.env.HOST) + )}` + ) + ); + console.log( + `If this was unintentional, check that you haven't mistakenly set it in your shell.` + ); + console.log( + `Learn more here: ${chalk.yellow('https://cra.link/advanced-config')}` + ); + console.log(); +} + +// We require that you explicitly set browsers and do not fall back to +// browserslist defaults. +const { checkBrowsers } = require('react-dev-utils/browsersHelper'); +checkBrowsers(paths.appPath, isInteractive) + .then(() => { + // We attempt to use the default port but if it is busy, we offer the user to + // run on a different port. `choosePort()` Promise resolves to the next free port. + return choosePort(HOST, DEFAULT_PORT); + }) + .then(port => { + if (port == null) { + // We have not found a port. + return; + } + + const config = configFactory('development'); + const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'; + const appName = require(paths.appPackageJson).name; + + const useTypeScript = fs.existsSync(paths.appTsConfig); + const urls = prepareUrls( + protocol, + HOST, + port, + paths.publicUrlOrPath.slice(0, -1) + ); + // Create a webpack compiler that is configured with custom messages. + const compiler = createCompiler({ + appName, + config, + urls, + useYarn, + useTypeScript, + webpack, + }); + // Load proxy config + const proxySetting = require(paths.appPackageJson).proxy; + const proxyConfig = prepareProxy( + proxySetting, + paths.appPublic, + paths.publicUrlOrPath + ); + // Serve webpack assets generated by the compiler over a web server. + const serverConfig = { + ...createDevServerConfig(proxyConfig, urls.lanUrlForConfig), + host: HOST, + port, + }; + const devServer = new WebpackDevServer(serverConfig, compiler); + // Launch WebpackDevServer. + devServer.startCallback(() => { + if (isInteractive) { + clearConsole(); + } + + if (env.raw.FAST_REFRESH && semver.lt(react.version, '16.10.0')) { + console.log( + chalk.yellow( + `Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.` + ) + ); + } + + console.log(chalk.cyan('Starting the development server...\n')); + openBrowser(urls.localUrlForBrowser); + }); + + ['SIGINT', 'SIGTERM'].forEach(function (sig) { + process.on(sig, function () { + devServer.close(); + process.exit(); + }); + }); + + if (process.env.CI !== 'true') { + // Gracefully exit when stdin ends + process.stdin.on('end', function () { + devServer.close(); + process.exit(); + }); + } + }) + .catch(err => { + if (err && err.message) { + console.log(err.message); + } + process.exit(1); + }); diff --git a/scripts/test.js b/scripts/test.js new file mode 100644 index 0000000..a38c855 --- /dev/null +++ b/scripts/test.js @@ -0,0 +1,52 @@ +'use strict'; + +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'test'; +process.env.NODE_ENV = 'test'; +process.env.PUBLIC_URL = ''; + +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + +// Ensure environment variables are read. +require('../config/env'); + +const jest = require('jest'); +const execSync = require('child_process').execSync; +let argv = process.argv.slice(2); + +function isInGitRepository() { + try { + execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' }); + return true; + } catch (e) { + return false; + } +} + +function isInMercurialRepository() { + try { + execSync('hg --cwd . root', { stdio: 'ignore' }); + return true; + } catch (e) { + return false; + } +} + +// Watch unless on CI or explicitly running all tests +if ( + !process.env.CI && + argv.indexOf('--watchAll') === -1 && + argv.indexOf('--watchAll=false') === -1 +) { + // https://github.com/facebook/create-react-app/issues/5210 + const hasSourceControl = isInGitRepository() || isInMercurialRepository(); + argv.push(hasSourceControl ? '--watch' : '--watchAll'); +} + + +jest.run(argv); diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..4fdd363 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,14 @@ +import '~/assets/iconfont/iconfont.css'; +import { HashRouter } from 'react-router-dom'; +import LayoutRouter from '~/router/layout' + +function App() { + + return ( + + + + ); +} + +export default App; diff --git a/src/assets/NFT-black.png b/src/assets/NFT-black.png new file mode 100644 index 0000000..9301749 Binary files /dev/null and b/src/assets/NFT-black.png differ diff --git a/src/assets/NFT.png b/src/assets/NFT.png new file mode 100644 index 0000000..83721ea Binary files /dev/null and b/src/assets/NFT.png differ diff --git a/src/assets/bsc-fil.png b/src/assets/bsc-fil.png new file mode 100644 index 0000000..ba5f56a Binary files /dev/null and b/src/assets/bsc-fil.png differ diff --git a/src/assets/contract.png b/src/assets/contract.png new file mode 100644 index 0000000..79ae7b4 Binary files /dev/null and b/src/assets/contract.png differ diff --git a/src/assets/copy.png b/src/assets/copy.png new file mode 100644 index 0000000..a08f58a Binary files /dev/null and b/src/assets/copy.png differ diff --git a/src/assets/error.png b/src/assets/error.png new file mode 100644 index 0000000..3896b90 Binary files /dev/null and b/src/assets/error.png differ diff --git a/src/assets/fil.png b/src/assets/fil.png new file mode 100644 index 0000000..8716036 Binary files /dev/null and b/src/assets/fil.png differ diff --git a/src/assets/group.png b/src/assets/group.png new file mode 100644 index 0000000..6e6c543 Binary files /dev/null and b/src/assets/group.png differ diff --git a/src/assets/help-0.png b/src/assets/help-0.png new file mode 100644 index 0000000..ec2ac8f Binary files /dev/null and b/src/assets/help-0.png differ diff --git a/src/assets/help-1.png b/src/assets/help-1.png new file mode 100644 index 0000000..302f47c Binary files /dev/null and b/src/assets/help-1.png differ diff --git a/src/assets/help-2.png b/src/assets/help-2.png new file mode 100644 index 0000000..fbe2e82 Binary files /dev/null and b/src/assets/help-2.png differ diff --git a/src/assets/iconfont/iconfont.css b/src/assets/iconfont/iconfont.css new file mode 100644 index 0000000..2a78084 --- /dev/null +++ b/src/assets/iconfont/iconfont.css @@ -0,0 +1,47 @@ +@font-face { + font-family: "iconfont"; /* Project id 4449044 */ + src: url('iconfont.woff2?t=1712643499155') format('woff2'), + url('iconfont.woff?t=1712643499155') format('woff'), + url('iconfont.ttf?t=1712643499155') format('truetype'); +} + +.iconfont { + font-family: "iconfont" !important; + font-size: 16px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.icon-shangjiantou:before { + content: "\e63a"; +} + +.icon-copy1:before { + content: "\e94c"; +} + +.icon-arrow1:before { + content: "\e625"; +} + +.icon-copy:before { + content: "\e7ad"; +} + +.icon-back_light:before { + content: "\e7e0"; +} + +.icon-arrow:before { + content: "\e70a"; +} + +.icon-guanbi:before { + content: "\e61c"; +} + +.icon-ego-menu:before { + content: "\e605"; +} + diff --git a/src/assets/iconfont/iconfont.js b/src/assets/iconfont/iconfont.js new file mode 100644 index 0000000..59abfc6 --- /dev/null +++ b/src/assets/iconfont/iconfont.js @@ -0,0 +1 @@ +window._iconfont_svg_string_4449044='',function(o){var t=(t=document.getElementsByTagName("script"))[t.length-1],e=t.getAttribute("data-injectcss"),t=t.getAttribute("data-disable-injectsvg");if(!t){var i,n,c,a,l,s=function(t,e){e.parentNode.insertBefore(t,e)};if(e&&!o.__iconfont__svg__cssinject__){o.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(t){console&&console.log(t)}}i=function(){var t,e=document.createElement("div");e.innerHTML=o._iconfont_svg_string_4449044,(e=e.getElementsByTagName("svg")[0])&&(e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.width=0,e.style.height=0,e.style.overflow="hidden",e=e,(t=document.body).firstChild?s(e,t.firstChild):t.appendChild(e))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(i,0):(n=function(){document.removeEventListener("DOMContentLoaded",n,!1),i()},document.addEventListener("DOMContentLoaded",n,!1)):document.attachEvent&&(c=i,a=o.document,l=!1,h(),a.onreadystatechange=function(){"complete"==a.readyState&&(a.onreadystatechange=null,d())})}function d(){l||(l=!0,c())}function h(){try{a.documentElement.doScroll("left")}catch(t){return void setTimeout(h,50)}d()}}(window); \ No newline at end of file diff --git a/src/assets/iconfont/iconfont.json b/src/assets/iconfont/iconfont.json new file mode 100644 index 0000000..c458258 --- /dev/null +++ b/src/assets/iconfont/iconfont.json @@ -0,0 +1,65 @@ +{ + "id": "4449044", + "name": "SoFil", + "font_family": "iconfont", + "css_prefix_text": "icon-", + "description": "", + "glyphs": [ + { + "icon_id": "4770734", + "name": "上箭头", + "font_class": "shangjiantou", + "unicode": "e63a", + "unicode_decimal": 58938 + }, + { + "icon_id": "11981529", + "name": "copy", + "font_class": "copy1", + "unicode": "e94c", + "unicode_decimal": 59724 + }, + { + "icon_id": "831601", + "name": "arrow", + "font_class": "arrow1", + "unicode": "e625", + "unicode_decimal": 58917 + }, + { + "icon_id": "20284804", + "name": "copy", + "font_class": "copy", + "unicode": "e7ad", + "unicode_decimal": 59309 + }, + { + "icon_id": "1496051", + "name": "back_light", + "font_class": "back_light", + "unicode": "e7e0", + "unicode_decimal": 59360 + }, + { + "icon_id": "5466007", + "name": "arrow", + "font_class": "arrow", + "unicode": "e70a", + "unicode_decimal": 59146 + }, + { + "icon_id": "4862242", + "name": "关闭", + "font_class": "guanbi", + "unicode": "e61c", + "unicode_decimal": 58908 + }, + { + "icon_id": "879161", + "name": "菜单", + "font_class": "ego-menu", + "unicode": "e605", + "unicode_decimal": 58885 + } + ] +} diff --git a/src/assets/iconfont/iconfont.ttf b/src/assets/iconfont/iconfont.ttf new file mode 100644 index 0000000..2e3a7d6 Binary files /dev/null and b/src/assets/iconfont/iconfont.ttf differ diff --git a/src/assets/iconfont/iconfont.woff b/src/assets/iconfont/iconfont.woff new file mode 100644 index 0000000..d625415 Binary files /dev/null and b/src/assets/iconfont/iconfont.woff differ diff --git a/src/assets/iconfont/iconfont.woff2 b/src/assets/iconfont/iconfont.woff2 new file mode 100644 index 0000000..7a84586 Binary files /dev/null and b/src/assets/iconfont/iconfont.woff2 differ diff --git a/src/assets/loading.png b/src/assets/loading.png new file mode 100644 index 0000000..2e11f8d Binary files /dev/null and b/src/assets/loading.png differ diff --git a/src/assets/loading/loading-1.png b/src/assets/loading/loading-1.png new file mode 100644 index 0000000..a124746 Binary files /dev/null and b/src/assets/loading/loading-1.png differ diff --git a/src/assets/loading/loading-2.png b/src/assets/loading/loading-2.png new file mode 100644 index 0000000..f4f4f10 Binary files /dev/null and b/src/assets/loading/loading-2.png differ diff --git a/src/assets/loading/loading-3.png b/src/assets/loading/loading-3.png new file mode 100644 index 0000000..e474191 Binary files /dev/null and b/src/assets/loading/loading-3.png differ diff --git a/src/assets/loading/loading-4.png b/src/assets/loading/loading-4.png new file mode 100644 index 0000000..69a417f Binary files /dev/null and b/src/assets/loading/loading-4.png differ diff --git a/src/assets/loading/loading-5.png b/src/assets/loading/loading-5.png new file mode 100644 index 0000000..a37792f Binary files /dev/null and b/src/assets/loading/loading-5.png differ diff --git a/src/assets/loading/loading-6.png b/src/assets/loading/loading-6.png new file mode 100644 index 0000000..89c3911 Binary files /dev/null and b/src/assets/loading/loading-6.png differ diff --git a/src/assets/logo.png b/src/assets/logo.png new file mode 100644 index 0000000..d06718c Binary files /dev/null and b/src/assets/logo.png differ diff --git a/src/assets/max-logo.png b/src/assets/max-logo.png new file mode 100644 index 0000000..a8aa9b3 Binary files /dev/null and b/src/assets/max-logo.png differ diff --git a/src/assets/menu/conditions.png b/src/assets/menu/conditions.png new file mode 100644 index 0000000..ac62f71 Binary files /dev/null and b/src/assets/menu/conditions.png differ diff --git a/src/assets/menu/discord.png b/src/assets/menu/discord.png new file mode 100644 index 0000000..4c0f637 Binary files /dev/null and b/src/assets/menu/discord.png differ diff --git a/src/assets/menu/language.png b/src/assets/menu/language.png new file mode 100644 index 0000000..b0a8c60 Binary files /dev/null and b/src/assets/menu/language.png differ diff --git a/src/assets/menu/linkedin.png b/src/assets/menu/linkedin.png new file mode 100644 index 0000000..745f212 Binary files /dev/null and b/src/assets/menu/linkedin.png differ diff --git a/src/assets/menu/menu-0.png b/src/assets/menu/menu-0.png new file mode 100644 index 0000000..a75fff7 Binary files /dev/null and b/src/assets/menu/menu-0.png differ diff --git a/src/assets/menu/menu-1.png b/src/assets/menu/menu-1.png new file mode 100644 index 0000000..4760609 Binary files /dev/null and b/src/assets/menu/menu-1.png differ diff --git a/src/assets/menu/menu-2.png b/src/assets/menu/menu-2.png new file mode 100644 index 0000000..cb18bd7 Binary files /dev/null and b/src/assets/menu/menu-2.png differ diff --git a/src/assets/menu/menu-3.png b/src/assets/menu/menu-3.png new file mode 100644 index 0000000..ebf0726 Binary files /dev/null and b/src/assets/menu/menu-3.png differ diff --git a/src/assets/menu/menu-bg-0.png b/src/assets/menu/menu-bg-0.png new file mode 100644 index 0000000..10be911 Binary files /dev/null and b/src/assets/menu/menu-bg-0.png differ diff --git a/src/assets/menu/menu-bg-1.png b/src/assets/menu/menu-bg-1.png new file mode 100644 index 0000000..10be911 Binary files /dev/null and b/src/assets/menu/menu-bg-1.png differ diff --git a/src/assets/menu/menu-bg-2.png b/src/assets/menu/menu-bg-2.png new file mode 100644 index 0000000..da2c595 Binary files /dev/null and b/src/assets/menu/menu-bg-2.png differ diff --git a/src/assets/menu/menu-bg-3.png b/src/assets/menu/menu-bg-3.png new file mode 100644 index 0000000..a5aa6a7 Binary files /dev/null and b/src/assets/menu/menu-bg-3.png differ diff --git a/src/assets/menu/my-pledge.png b/src/assets/menu/my-pledge.png new file mode 100644 index 0000000..3430f6b Binary files /dev/null and b/src/assets/menu/my-pledge.png differ diff --git a/src/assets/menu/privacy-policy.png b/src/assets/menu/privacy-policy.png new file mode 100644 index 0000000..c025dd2 Binary files /dev/null and b/src/assets/menu/privacy-policy.png differ diff --git a/src/assets/menu/referral.png b/src/assets/menu/referral.png new file mode 100644 index 0000000..31f6a88 Binary files /dev/null and b/src/assets/menu/referral.png differ diff --git a/src/assets/menu/telegram.png b/src/assets/menu/telegram.png new file mode 100644 index 0000000..440df85 Binary files /dev/null and b/src/assets/menu/telegram.png differ diff --git a/src/assets/menu/twitter.png b/src/assets/menu/twitter.png new file mode 100644 index 0000000..67c20b5 Binary files /dev/null and b/src/assets/menu/twitter.png differ diff --git a/src/assets/modal-bg-img.png b/src/assets/modal-bg-img.png new file mode 100644 index 0000000..a2ef9b1 Binary files /dev/null and b/src/assets/modal-bg-img.png differ diff --git a/src/assets/modal.png b/src/assets/modal.png new file mode 100644 index 0000000..e7045ac Binary files /dev/null and b/src/assets/modal.png differ diff --git a/src/assets/nft-details-box.png b/src/assets/nft-details-box.png new file mode 100644 index 0000000..44aeb1a Binary files /dev/null and b/src/assets/nft-details-box.png differ diff --git a/src/assets/notify-right.png b/src/assets/notify-right.png new file mode 100644 index 0000000..81ef401 Binary files /dev/null and b/src/assets/notify-right.png differ diff --git a/src/assets/pledge-header.png b/src/assets/pledge-header.png new file mode 100644 index 0000000..cc39d74 Binary files /dev/null and b/src/assets/pledge-header.png differ diff --git a/src/assets/pledge.png b/src/assets/pledge.png new file mode 100644 index 0000000..4ce55a6 Binary files /dev/null and b/src/assets/pledge.png differ diff --git a/src/assets/product-box.png b/src/assets/product-box.png new file mode 100644 index 0000000..dd7f155 Binary files /dev/null and b/src/assets/product-box.png differ diff --git a/src/assets/recommend-box.png b/src/assets/recommend-box.png new file mode 100644 index 0000000..4778fdf Binary files /dev/null and b/src/assets/recommend-box.png differ diff --git a/src/assets/recommend.png b/src/assets/recommend.png new file mode 100644 index 0000000..d07a0c6 Binary files /dev/null and b/src/assets/recommend.png differ diff --git a/src/assets/referees-box.png b/src/assets/referees-box.png new file mode 100644 index 0000000..33f59c1 Binary files /dev/null and b/src/assets/referees-box.png differ diff --git a/src/assets/scroll-1.png b/src/assets/scroll-1.png new file mode 100644 index 0000000..2897fa4 Binary files /dev/null and b/src/assets/scroll-1.png differ diff --git a/src/assets/scroll-2.png b/src/assets/scroll-2.png new file mode 100644 index 0000000..d8bc7b8 Binary files /dev/null and b/src/assets/scroll-2.png differ diff --git a/src/assets/scroll-3.png b/src/assets/scroll-3.png new file mode 100644 index 0000000..3a74148 Binary files /dev/null and b/src/assets/scroll-3.png differ diff --git a/src/assets/share-1.png b/src/assets/share-1.png new file mode 100644 index 0000000..45ef843 Binary files /dev/null and b/src/assets/share-1.png differ diff --git a/src/assets/share-2.png b/src/assets/share-2.png new file mode 100644 index 0000000..3691f67 Binary files /dev/null and b/src/assets/share-2.png differ diff --git a/src/assets/share-3.png b/src/assets/share-3.png new file mode 100644 index 0000000..1cba3fe Binary files /dev/null and b/src/assets/share-3.png differ diff --git a/src/assets/share.png b/src/assets/share.png new file mode 100644 index 0000000..c5fa857 Binary files /dev/null and b/src/assets/share.png differ diff --git a/src/assets/stake-bg-img-1.png b/src/assets/stake-bg-img-1.png new file mode 100644 index 0000000..79d0f36 Binary files /dev/null and b/src/assets/stake-bg-img-1.png differ diff --git a/src/assets/stake-bg-img-2.png b/src/assets/stake-bg-img-2.png new file mode 100644 index 0000000..9ae5be9 Binary files /dev/null and b/src/assets/stake-bg-img-2.png differ diff --git a/src/assets/stake-box.png b/src/assets/stake-box.png new file mode 100644 index 0000000..de1d742 Binary files /dev/null and b/src/assets/stake-box.png differ diff --git a/src/assets/stake-watermark.png b/src/assets/stake-watermark.png new file mode 100644 index 0000000..0331586 Binary files /dev/null and b/src/assets/stake-watermark.png differ diff --git a/src/assets/warning.png b/src/assets/warning.png new file mode 100644 index 0000000..73c29a5 Binary files /dev/null and b/src/assets/warning.png differ diff --git a/src/assets/watermark.png b/src/assets/watermark.png new file mode 100644 index 0000000..dcae765 Binary files /dev/null and b/src/assets/watermark.png differ diff --git a/src/assets/withdraw-watermark.png b/src/assets/withdraw-watermark.png new file mode 100644 index 0000000..a4f4c2c Binary files /dev/null and b/src/assets/withdraw-watermark.png differ diff --git a/src/components/BackBar.tsx b/src/components/BackBar.tsx new file mode 100644 index 0000000..7f26124 --- /dev/null +++ b/src/components/BackBar.tsx @@ -0,0 +1,20 @@ +import { useRouter } from "~/hooks/useRouter"; + +interface BackBarProps { + title: string +} + +const BackBar = ({ title }: BackBarProps) => { + + const { push } = useRouter(); + + return ( +
+
push(-1)}>
+
{title}
+
+
+ ) +}; + +export default BackBar; \ No newline at end of file diff --git a/src/components/Button.tsx b/src/components/Button.tsx new file mode 100644 index 0000000..93969e3 --- /dev/null +++ b/src/components/Button.tsx @@ -0,0 +1,14 @@ +import { Button as VantButton, ButtonProps as VantButtonProps } from "react-vant" +import '~/styles/components.scss' + +interface ButtonProps extends VantButtonProps { + +} + +const Button = (props: ButtonProps) => { + return ( + {props.children} + ) +} + +export default Button \ No newline at end of file diff --git a/src/components/ConnectWalletButton.tsx b/src/components/ConnectWalletButton.tsx new file mode 100644 index 0000000..1f26c6a --- /dev/null +++ b/src/components/ConnectWalletButton.tsx @@ -0,0 +1,122 @@ +import '~/styles/components.scss' +import { useEffect, useRef, useState } from "react" +import { Button, Popover, PopoverInstance, Popup, Toast } from "react-vant" +import { observer } from 'mobx-react' +import useConnectWallet from '~/hooks/useConnectWallet' +import store from '~/store' +import { splitAddress } from '~/utils' +import { useRouter } from '~/hooks/useRouter' +import useCopyLink from '~/hooks/useCopy' +import { useTranslation } from 'react-i18next' + +interface ConnectWalletButtonProps { + class?: string +} + +const ConnectWalletButton = (props: ConnectWalletButtonProps) => { + + const { walletAddress, filBalance, contract } = store.state + const { push } = useRouter(); + const [loading, setLoading] = useState(false) + const { connect } = useConnectWallet(); + const [visible, setVisible] = useState(false) + const { copyVal } = useCopyLink() + + const [contractCount,setContractCount] = useState(0) + + const {t} = useTranslation() + + const connectWallet = async () => { + setLoading(true); + await connect(); + setLoading(false); + } + + const toPath = (path: string) => { + push(path) + setVisible(false) + } + + const logout = () => { + store.setAddress('') + setVisible(false) + Toast.success(t('Log out')) + } + + const getData = async () => { + const { Pledge__factory } = contract._contract + const _record = await Pledge__factory.getPledgeRecords(walletAddress); //質押記錄 + setContractCount(_record.length) + } + + useEffect(()=>{ + walletAddress && visible && getData() + },[walletAddress,visible]) + + return ( +
+ { + walletAddress ? ( + + ) : ( + + ) + } + + setVisible(false)} overlayStyle={{ background: 'rgba(0,0,0,0.4)' }} round style={{ background: '#2D2D2D' }}> +
+
{t('Wallet')}
+
+
{splitAddress(walletAddress, 6)}
+
copyVal(walletAddress)}>
+
+
+
+ +
+
+
Filecoin(FIL)
+
{t('Balance')}:{filBalance}FIL
+
+
+
+
+ +
+
+
{t('SOFIL Staking Contract')}
+
{t('Staking Amount')}:{contractCount}
+
+
+
+
toPath('/myPledge')}> + +
{t('My Staking')}
+
+
+
toPath('/invitation')}> + +
{t('My Referral')}
+
+
+
{t('Log out')}
+
+
+
+ ) +} + +export default observer(ConnectWalletButton) \ No newline at end of file diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx new file mode 100644 index 0000000..86a9e99 --- /dev/null +++ b/src/components/Loading.tsx @@ -0,0 +1,17 @@ +import '~/styles/components.scss' + +const Loading = () => { + return ( +
+
+ {/* { + Array.from({ length: 5 }).map((_, index) => ( + + )) + } */} +
+
+ ) +} + +export default Loading \ No newline at end of file diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx new file mode 100644 index 0000000..cd7eae6 --- /dev/null +++ b/src/components/Modal.tsx @@ -0,0 +1,64 @@ +import { Overlay } from 'react-vant'; +import '~/styles/components.scss' + +interface ModalProps { + buttonText?: string | JSX.Element; + title?: string; + children: JSX.Element; + buttonClick?: Function; + visible: boolean; + setVisible: Function; + hiddenCloseIcon?: boolean; + showCancelButton?: boolean; + showCancelButtonText?: string; + showCancelButtonClick?: Function; + showConfirmButton?: boolean; + confirmButtonClass?: string; + modalClass?: string; + backgroundColosed?: boolean; + width?: string; +} + +const Modal = (props: ModalProps) => { + + const { title, buttonClick, visible, setVisible, children, buttonText, hiddenCloseIcon, showCancelButton, showCancelButtonText, showCancelButtonClick, showConfirmButton, backgroundColosed, width, confirmButtonClass, modalClass } = props + + return ( + backgroundColosed && setVisible(false)} + > +
+
+
+
{title}
+
+ { + !hiddenCloseIcon && ( + setVisible(false)} /> + ) + } +
+
+ {children} + +
+ { + !showConfirmButton && ( +
buttonClick && buttonClick()}>{buttonText}
+ ) + } + { + showCancelButton && +
showCancelButtonClick && showCancelButtonClick()}>{showCancelButtonText || '關閉'}
+ } +
+ +
+
+ ) +} + +export default Modal \ No newline at end of file diff --git a/src/components/ModalLoading.tsx b/src/components/ModalLoading.tsx new file mode 100644 index 0000000..28e8b52 --- /dev/null +++ b/src/components/ModalLoading.tsx @@ -0,0 +1,45 @@ +import '~/styles/components.scss' +import { useState } from "react" +import Modal from "./Modal" +import { copy } from '~/utils/copy' +import { Toast } from 'react-vant' +import { splitAddress } from '~/utils' + +interface ModalLoadingProps { + visible: boolean, + setVisible: Function, + loading: boolean, + status: number, // -1 正在處理, 1 成功 否則失敗, + hash: string +} + +const ModalLoading = (props: ModalLoadingProps) => { + + const { visible, setVisible, loading, status, hash } = props + + return ( + setVisible(false)} showConfirmButton={true}> +
+
+ { + loading ? ( +
+
+
+ ) : ( + + ) + } +
+
{ + status === -1 ? 'Your transaction is being processed' : status === 1 ? 'Transaction Success' : 'Transaction Failed' + }
+
Message ID: {splitAddress(hash, 6)} copy(hash, () => { + Toast.success("Copy Success") + })}>
+
+
+ ) +} + +export default ModalLoading; \ No newline at end of file diff --git a/src/components/Unlogin.tsx b/src/components/Unlogin.tsx new file mode 100644 index 0000000..54340af --- /dev/null +++ b/src/components/Unlogin.tsx @@ -0,0 +1,17 @@ +import { useTranslation } from 'react-i18next'; +import '~/styles/components.scss' +import ConnectWalletButton from "./ConnectWalletButton"; + +const UnLogin = () => { + const { t } = useTranslation() + return ( +
+
{t('Connect your wallet to view more details')}
+
+ +
+
+ ) +} + +export default UnLogin; \ No newline at end of file diff --git a/src/contract/api.ts b/src/contract/api.ts new file mode 100644 index 0000000..4c73af6 --- /dev/null +++ b/src/contract/api.ts @@ -0,0 +1,226 @@ +import { AddressLike, Typed } from "ethers"; +import store from "~/store"; +import { + InvitationUserRecordType, + InvitationWithdrawRecordType, + PledgeInfoType, + PledgeWithdrawRecordType, +} from "~/types/api.d"; +import { toFixed2 } from "~/utils"; +import { fromWei, toBigInt, toWei } from "~/utils/wei"; +const { _contract } = store.state.contract; + +const { Pledge__factory } = _contract; + +const eth_pledgeRecords = async (_owner: string) => { + const _recordPs = Pledge__factory.getPledgeRecords(_owner); //質押記錄 + const _wdRecordPs = Pledge__factory.getPledgeWithdrawRecord(_owner); //質押體現記錄 + const [_records, _wdRecords] = await Promise.all([_recordPs, _wdRecordPs]); + const result = { + records: [] as PledgeInfoType[], + withdrawRecordPs: [] as PledgeWithdrawRecordType[], + totalPledge: "0", + totalWithdraw: "0", + }; + + let totalPledge = toBigInt(0); + let totalWithdraw = toBigInt(0); + + result.records = _records.map((v) => { + totalPledge += v["pledgeAmount"]; + return handlePledgeData(v); + }); + + result.withdrawRecordPs = _wdRecords.map((v) => { + totalWithdraw += v["amount"]; + return { + amount: toFixed2(fromWei(v["amount"]), 4), + createTime: Number(v["createTime"].toString(10)), + tokenId: v["tokenId"].toString(10), + pledgeDay: v["pledgeDay"].toString(10), + _type: Number(v["_type"].toString(10)), + }; + }); + + result.totalPledge = toFixed2(fromWei(totalPledge), 2); + result.totalWithdraw = toFixed2(fromWei(totalWithdraw), 2); + + return result; +}; + +// 產品列表 +const eth_pledgeProducts = async () => { + const res = await tryCatch(Pledge__factory.getProductInfo); + if (res.data) { + const list = [] as object[]; + res.data.forEach((item: any, index: number) => { + list[index] = { + day: Number(item["day"].toString(10)), + rate: Number(item["rate"].toString(10)), + }; + }); + res.data = list; + } + return res; +}; + +// 獲取質押的信息 提取額度 已質押額度 持有合約數量 +const eth_pledgeInfo = async (owner: string) => { + try { + const _pledges = Pledge__factory.getOwnerAllPledgeInfo(owner); + const _withdrawAmount = Pledge__factory.getWithdrawbleAmount(owner); + const _currentTime = Pledge__factory.getCurrentTime(); + const _destoryRecord = Pledge__factory.getPledgeDestoryRecords(owner); + const [pledges, withdrawAmount, currentTime, destoryRecord] = + await Promise.all([ + _pledges, + _withdrawAmount, + _currentTime, + _destoryRecord, + ]); + + const result = { + pledgeInfos: pledges.map((v) => handlePledgeData(v)), + pledgeToast: "0", + withdrawAmount: "0", + expiredPledgeInfos: [] as PledgeInfoType[], + unExpiredPledgeInfos: [] as PledgeInfoType[], + currentTime: 0, + destoryRecord: destoryRecord.map((v) => handlePledgeData(v)), + }; + + result.currentTime = Number(currentTime.toString(10)); + result.withdrawAmount = toFixed2(fromWei(withdrawAmount), 2); + result.expiredPledgeInfos = result.pledgeInfos.filter( + (v) => v.endTime <= result.currentTime + ); + + result.unExpiredPledgeInfos = result.pledgeInfos.filter( + (v) => v.endTime > result.currentTime + ); + // 未到期的質押額度 + let _total = toBigInt(0); + result.unExpiredPledgeInfos.forEach((item) => { + _total += toWei(item["pledgeAmount"]); + }); + + result.pledgeToast = fromWei(_total); + + return result; + } catch (error) { + console.log(error); + } +}; + +// 獲取邀請的用戶列表,合約,提取,推薦用戶,未到期合約 +const eth_invitation = async (owner: string) => { + try { + const _user = Pledge__factory.getAllInvitationMember(owner); + const _contract = Pledge__factory.getOwnerInvitationPledges(owner); + const _rate = Pledge__factory.invitationRate(); + const _currentTime = Pledge__factory.getCurrentTime(); + const _withdrawAmount = Pledge__factory.getOwnerAllInvitationWithdrawAmout(owner); + // Pledge__factory.dayTime().then((res) => { + // console.log(res); + // }); + const _withdrawRecord = Pledge__factory.getInvitationWithdrawRecord(owner); + + const [user, contract, rate, currentTime, withdrawAmount, withdrawRecord] = + await Promise.all([ + _user, + _contract, + _rate, + _currentTime, + _withdrawAmount, + _withdrawRecord, + ]); + + const result = { + recommendAmount: 0, + unExpiredContract: 0, + withdrawAmount: "0.00", + contract: contract.map((v) => handlePledgeData(v)), + user: [] as InvitationUserRecordType[], + currentTime: Number(currentTime.toString(10)), + rate: Number(rate.toString(10)), + withdrawRecord: [] as InvitationWithdrawRecordType[], + }; + + result.withdrawRecord = withdrawRecord.map((v) => ({ + createTime: Number(v["createTime"].toString(10)), + amount: toFixed2(fromWei(v["amount"]), 4), + })); + + result.user = user.map((v) => ({ + key: v["key"], + contribute: fromWei(v["contribute"]), + bindTime: Number(v["bindTime"].toString(10)), + referrer: v["referrer"], + })); + + result.recommendAmount = result.user.length; + result.unExpiredContract = result.contract.filter( + (v) => v.endTime > result.currentTime + ).length; + result.withdrawAmount = toFixed2(fromWei(withdrawAmount), 4); + + return result; + } catch (error) { + console.error(error); + } +}; + +const eth_Detail = async (tokenId: number, _type: string) => { + try { + const _id = toBigInt(tokenId); + const _pledge = Pledge__factory.getDetails(_id, _type); + const _currentTime = Pledge__factory.getCurrentTime(); + const [pledge, currentTime] = await Promise.all([_pledge, _currentTime]); + + const result = { + currentTime: Number(currentTime.toString(10)), + data: handlePledgeData(pledge), + }; + return result; + } catch (error) { + console.error(error); + } +}; + +const handlePledgeData = (item: any) => { + const _obj = {} as PledgeInfoType; + _obj.endTime = Number(item["endTime"].toString(10)); + _obj.startTime = Number(item["startTime"].toString(10)); + _obj.pledgeAmount = fromWei(item["pledgeAmount"]); + _obj.pledgeDay = Number(item["pledgeDay"].toString(10)); + _obj.rate = Number(item["rate"].toString(10)); + _obj.sender = item["sender"]; + _obj.tokenId = Number(item["tokenId"].toString(10)); + _obj.withdrawTime = Number(item["withdrawTime"].toString(10)); + _obj.isBlack = item["isBlack"]; + return _obj; +}; + +async function tryCatch(_api: Function, ...args: any) { + let result = { + code: 0, + data: null as any, + msg: "", + }; + try { + const _result = await _api(...args); + result.data = _result; + } catch (error) { + result.code = 500; + result.msg = JSON.stringify(error); + } + return result; +} + +export { + eth_pledgeProducts, + eth_pledgeInfo, + eth_invitation, + eth_pledgeRecords, + eth_Detail, +}; diff --git a/src/contract/index.tsx b/src/contract/index.tsx new file mode 100644 index 0000000..84b68a9 --- /dev/null +++ b/src/contract/index.tsx @@ -0,0 +1,116 @@ +import { FIL__factory, NFT__factory, Pledge__factory, Pool__factory } from './typechain-types'; + +import { ethers } from 'ethers'; +import store from '~/store'; +import { ContractType } from '~/types/store'; +// 0x7a89c2D92Bf53160ab58d7889966741cA8Eb5855 +export const config = { + 56: { + chainId: 56, + rpc: "https://bsc-dataseed1.defibit.io", + address: { + FIL__factory: "0x0d8ce2a99bb6e3b7db580ed848240e4a0f9ae153", + NFT__factory: "0x5fd156B6B47Bb0B363fa3D4e2E31a8394Ee7A630", + Pool__factory: "0xC31cEb39961076d8fAD3936D88489972c02b4D83", + Pledge__factory: "0x2F3d8761c8214627743F84F9890A8eEeD914ddf1", + } + }, + 97: { + chainId: 97, + rpc: "https://bsc-testnet.blockpi.network/v1/rpc/public", + address: { + FIL__factory: "0xfa01Ef257b47578063741D3E4b60e16764FA6fa8", + NFT__factory: "0x1eF6AAc9B468d7B310675409EFE5f954dFe59dDF", + Pool__factory: "0xe861046E610B6f6A0E79eEf8Dd0aF5a42dC83293", + Pledge__factory: "0xD8553004442098415734A9EFE49e13E29919BfF9", + } + }, + 31337: { + chainId: 31337, + rpc: "http://127.0.0.1:8545", + address: { + FIL__factory: "0x5FbDB2315678afecb367f032d93F642f64180aa3", + NFT__factory: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", + Pool__factory: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", + Pledge__factory: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", + } + } +} as any +// 57.333333333333333332 +const contractObj = { + FIL__factory, + NFT__factory, + Pledge__factory, + Pool__factory +} as any +// 切换/添加网络 +const switchNetWork = () => { + (window as any).ethereum.request({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x38' }], + }).then((r: any) => { + // console.log(r); + }).catch((switchError: any) => { + if (switchError.code === 4902) { + (window as any).ethereum.request({ + method: 'wallet_addEthereumChain', + params: [ + { + chainId: '0x38', + chainName: 'Binance Smart Chain Mainnet', + rpcUrls: ['https://bsc-dataseed1.binance.org'] /* ... */, + }, + ], + }).then(() => { + (window as any).ethereum.request({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x38' }], + }) + }); + } + }); +}; + + + +export const initContract = async () => { + + let chainId = Number(process.env.REACT_APP_CHAINID); + let account = [] as string[]; + + let _contract: { [key: string]: any } = { + _contract: {}, + _provider: null + }; + + + if (window.ethereum) { + account = await window.ethereum.request({ + method: 'eth_accounts' + }); + chainId = ethers.toNumber(await window.ethereum.request({ + method: 'eth_chainId' + })) + } + + if(!config[chainId]){ + chainId = Number(process.env.REACT_APP_CHAINID) + }; + + const contractAddress = config[chainId]; + let _provider = null as any; + + if (account.length <= 0) { + _provider = new ethers.JsonRpcProvider(contractAddress.rpc) + } else { + _provider = await new ethers.BrowserProvider(window.ethereum).getSigner() + } + + _contract._provider = _provider; + + Object.keys(contractAddress.address).forEach((item) => { + _contract._contract[item] = contractObj[item].connect(contractAddress.address[item], _provider); + }) + store.setContract(_contract as ContractType); + +} \ No newline at end of file diff --git a/src/contract/typechain-types/common.ts b/src/contract/typechain-types/common.ts new file mode 100644 index 0000000..56b5f21 --- /dev/null +++ b/src/contract/typechain-types/common.ts @@ -0,0 +1,131 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + FunctionFragment, + Typed, + EventFragment, + ContractTransaction, + ContractTransactionResponse, + DeferredTopicFilter, + EventLog, + TransactionRequest, + LogDescription, +} from "ethers"; + +export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> + extends DeferredTopicFilter {} + +export interface TypedContractEvent< + InputTuple extends Array = any, + OutputTuple extends Array = any, + OutputObject = any +> { + (...args: Partial): TypedDeferredTopicFilter< + TypedContractEvent + >; + name: string; + fragment: EventFragment; + getFragment(...args: Partial): EventFragment; +} + +type __TypechainAOutputTuple = T extends TypedContractEvent< + infer _U, + infer W +> + ? W + : never; +type __TypechainOutputObject = T extends TypedContractEvent< + infer _U, + infer _W, + infer V +> + ? V + : never; + +export interface TypedEventLog + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export interface TypedLogDescription + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export type TypedListener = ( + ...listenerArg: [ + ...__TypechainAOutputTuple, + TypedEventLog, + ...undefined[] + ] +) => void; + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory< + infer C, + any +> + ? C + : never; +export type GetARGsTypeFromFactory = F extends MinEthersFactory + ? Parameters + : never; + +export type StateMutability = "nonpayable" | "payable" | "view"; + +export type BaseOverrides = Omit; +export type NonPayableOverrides = Omit< + BaseOverrides, + "value" | "blockTag" | "enableCcipRead" +>; +export type PayableOverrides = Omit< + BaseOverrides, + "blockTag" | "enableCcipRead" +>; +export type ViewOverrides = Omit; +export type Overrides = S extends "nonpayable" + ? NonPayableOverrides + : S extends "payable" + ? PayableOverrides + : ViewOverrides; + +export type PostfixOverrides, S extends StateMutability> = + | A + | [...A, Overrides]; +export type ContractMethodArgs< + A extends Array, + S extends StateMutability +> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>; + +export type DefaultReturnType = R extends Array ? R[0] : R; + +// export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> { +export interface TypedContractMethod< + A extends Array = Array, + R = any, + S extends StateMutability = "payable" +> { + (...args: ContractMethodArgs): S extends "view" + ? Promise> + : Promise; + + name: string; + + fragment: FunctionFragment; + + getFragment(...args: ContractMethodArgs): FunctionFragment; + + populateTransaction( + ...args: ContractMethodArgs + ): Promise; + staticCall( + ...args: ContractMethodArgs + ): Promise>; + send(...args: ContractMethodArgs): Promise; + estimateGas(...args: ContractMethodArgs): Promise; + staticCallResult(...args: ContractMethodArgs): Promise; +} diff --git a/src/contract/typechain-types/contracts/FIL.ts b/src/contract/typechain-types/contracts/FIL.ts new file mode 100644 index 0000000..1458fed --- /dev/null +++ b/src/contract/typechain-types/contracts/FIL.ts @@ -0,0 +1,286 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "../common"; + +export interface FILInterface extends Interface { + getFunction( + nameOrSignature: + | "allowance" + | "approve" + | "balanceOf" + | "decimals" + | "name" + | "symbol" + | "totalSupply" + | "transfer" + | "transferFrom" + ): FunctionFragment; + + getEvent(nameOrSignatureOrTopic: "Approval" | "Transfer"): EventFragment; + + encodeFunctionData( + functionFragment: "allowance", + values: [AddressLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "approve", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "balanceOf", + values: [AddressLike] + ): string; + encodeFunctionData(functionFragment: "decimals", values?: undefined): string; + encodeFunctionData(functionFragment: "name", values?: undefined): string; + encodeFunctionData(functionFragment: "symbol", values?: undefined): string; + encodeFunctionData( + functionFragment: "totalSupply", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "transfer", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "transferFrom", + values: [AddressLike, AddressLike, BigNumberish] + ): string; + + decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "name", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "symbol", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "totalSupply", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "transferFrom", + data: BytesLike + ): Result; +} + +export namespace ApprovalEvent { + export type InputTuple = [ + owner: AddressLike, + spender: AddressLike, + value: BigNumberish + ]; + export type OutputTuple = [owner: string, spender: string, value: bigint]; + export interface OutputObject { + owner: string; + spender: string; + value: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace TransferEvent { + export type InputTuple = [ + from: AddressLike, + to: AddressLike, + value: BigNumberish + ]; + export type OutputTuple = [from: string, to: string, value: bigint]; + export interface OutputObject { + from: string; + to: string; + value: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface FIL extends BaseContract { + connect(runner?: ContractRunner | null): FIL; + waitForDeployment(): Promise; + + interface: FILInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + allowance: TypedContractMethod< + [owner: AddressLike, spender: AddressLike], + [bigint], + "view" + >; + + approve: TypedContractMethod< + [spender: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + balanceOf: TypedContractMethod<[account: AddressLike], [bigint], "view">; + + decimals: TypedContractMethod<[], [bigint], "view">; + + name: TypedContractMethod<[], [string], "view">; + + symbol: TypedContractMethod<[], [string], "view">; + + totalSupply: TypedContractMethod<[], [bigint], "view">; + + transfer: TypedContractMethod< + [to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + transferFrom: TypedContractMethod< + [from: AddressLike, to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "allowance" + ): TypedContractMethod< + [owner: AddressLike, spender: AddressLike], + [bigint], + "view" + >; + getFunction( + nameOrSignature: "approve" + ): TypedContractMethod< + [spender: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + getFunction( + nameOrSignature: "balanceOf" + ): TypedContractMethod<[account: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "decimals" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "name" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "symbol" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "totalSupply" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "transfer" + ): TypedContractMethod< + [to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + getFunction( + nameOrSignature: "transferFrom" + ): TypedContractMethod< + [from: AddressLike, to: AddressLike, value: BigNumberish], + [boolean], + "nonpayable" + >; + + getEvent( + key: "Approval" + ): TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + getEvent( + key: "Transfer" + ): TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + + filters: { + "Approval(address,address,uint256)": TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + Approval: TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + + "Transfer(address,address,uint256)": TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + Transfer: TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + }; +} diff --git a/src/contract/typechain-types/contracts/NFT.ts b/src/contract/typechain-types/contracts/NFT.ts new file mode 100644 index 0000000..93f59c2 --- /dev/null +++ b/src/contract/typechain-types/contracts/NFT.ts @@ -0,0 +1,621 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "../common"; + +export interface NFTInterface extends Interface { + getFunction( + nameOrSignature: + | "addAdmin" + | "addBlacks" + | "approve" + | "balanceOf" + | "blacks" + | "delBlacks" + | "deleteAdmin" + | "deployAddress" + | "getAdmin" + | "getApproved" + | "getBlacks" + | "isApprovedForAll" + | "mint" + | "name" + | "ownerOf" + | "pledgeAddress" + | "safeTransferFrom(address,address,uint256)" + | "safeTransferFrom(address,address,uint256,bytes)" + | "setApprovalForAll" + | "setPledgeAddress" + | "supportsInterface" + | "symbol" + | "tokenByIndex" + | "tokenOfOwnerByIndex" + | "tokenURI" + | "totalSupply" + | "transferFrom" + ): FunctionFragment; + + getEvent( + nameOrSignatureOrTopic: "Approval" | "ApprovalForAll" | "Transfer" + ): EventFragment; + + encodeFunctionData( + functionFragment: "addAdmin", + values: [AddressLike[]] + ): string; + encodeFunctionData( + functionFragment: "addBlacks", + values: [BigNumberish[]] + ): string; + encodeFunctionData( + functionFragment: "approve", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "balanceOf", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "blacks", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "delBlacks", + values: [BigNumberish[]] + ): string; + encodeFunctionData( + functionFragment: "deleteAdmin", + values: [AddressLike[]] + ): string; + encodeFunctionData( + functionFragment: "deployAddress", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "getAdmin", values?: undefined): string; + encodeFunctionData( + functionFragment: "getApproved", + values: [BigNumberish] + ): string; + encodeFunctionData(functionFragment: "getBlacks", values?: undefined): string; + encodeFunctionData( + functionFragment: "isApprovedForAll", + values: [AddressLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "mint", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData(functionFragment: "name", values?: undefined): string; + encodeFunctionData( + functionFragment: "ownerOf", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "pledgeAddress", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "safeTransferFrom(address,address,uint256)", + values: [AddressLike, AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "safeTransferFrom(address,address,uint256,bytes)", + values: [AddressLike, AddressLike, BigNumberish, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "setApprovalForAll", + values: [AddressLike, boolean] + ): string; + encodeFunctionData( + functionFragment: "setPledgeAddress", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "supportsInterface", + values: [BytesLike] + ): string; + encodeFunctionData(functionFragment: "symbol", values?: undefined): string; + encodeFunctionData( + functionFragment: "tokenByIndex", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "tokenOfOwnerByIndex", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "tokenURI", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "totalSupply", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "transferFrom", + values: [AddressLike, AddressLike, BigNumberish] + ): string; + + decodeFunctionResult(functionFragment: "addAdmin", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "addBlacks", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "blacks", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "delBlacks", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "deleteAdmin", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "deployAddress", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "getAdmin", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getApproved", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "getBlacks", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "isApprovedForAll", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "mint", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "name", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "ownerOf", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "pledgeAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "safeTransferFrom(address,address,uint256)", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "safeTransferFrom(address,address,uint256,bytes)", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setApprovalForAll", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setPledgeAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "supportsInterface", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "symbol", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "tokenByIndex", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "tokenOfOwnerByIndex", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "tokenURI", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "totalSupply", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "transferFrom", + data: BytesLike + ): Result; +} + +export namespace ApprovalEvent { + export type InputTuple = [ + owner: AddressLike, + approved: AddressLike, + tokenId: BigNumberish + ]; + export type OutputTuple = [owner: string, approved: string, tokenId: bigint]; + export interface OutputObject { + owner: string; + approved: string; + tokenId: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace ApprovalForAllEvent { + export type InputTuple = [ + owner: AddressLike, + operator: AddressLike, + approved: boolean + ]; + export type OutputTuple = [ + owner: string, + operator: string, + approved: boolean + ]; + export interface OutputObject { + owner: string; + operator: string; + approved: boolean; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace TransferEvent { + export type InputTuple = [ + from: AddressLike, + to: AddressLike, + tokenId: BigNumberish + ]; + export type OutputTuple = [from: string, to: string, tokenId: bigint]; + export interface OutputObject { + from: string; + to: string; + tokenId: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface NFT extends BaseContract { + connect(runner?: ContractRunner | null): NFT; + waitForDeployment(): Promise; + + interface: NFTInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + addAdmin: TypedContractMethod<[_adds: AddressLike[]], [void], "nonpayable">; + + addBlacks: TypedContractMethod< + [_tokenIds: BigNumberish[]], + [void], + "nonpayable" + >; + + approve: TypedContractMethod< + [to: AddressLike, tokenId: BigNumberish], + [void], + "nonpayable" + >; + + balanceOf: TypedContractMethod<[owner: AddressLike], [bigint], "view">; + + blacks: TypedContractMethod<[arg0: BigNumberish], [bigint], "view">; + + delBlacks: TypedContractMethod< + [_tokenIds: BigNumberish[]], + [void], + "nonpayable" + >; + + deleteAdmin: TypedContractMethod< + [_dels: AddressLike[]], + [void], + "nonpayable" + >; + + deployAddress: TypedContractMethod<[], [string], "view">; + + getAdmin: TypedContractMethod<[], [string[]], "view">; + + getApproved: TypedContractMethod<[tokenId: BigNumberish], [string], "view">; + + getBlacks: TypedContractMethod<[], [bigint[]], "view">; + + isApprovedForAll: TypedContractMethod< + [owner: AddressLike, operator: AddressLike], + [boolean], + "view" + >; + + mint: TypedContractMethod< + [to: AddressLike, tokenId: BigNumberish], + [void], + "nonpayable" + >; + + name: TypedContractMethod<[], [string], "view">; + + ownerOf: TypedContractMethod<[tokenId: BigNumberish], [string], "view">; + + pledgeAddress: TypedContractMethod<[], [string], "view">; + + "safeTransferFrom(address,address,uint256)": TypedContractMethod< + [from: AddressLike, to: AddressLike, tokenId: BigNumberish], + [void], + "nonpayable" + >; + + "safeTransferFrom(address,address,uint256,bytes)": TypedContractMethod< + [ + from: AddressLike, + to: AddressLike, + tokenId: BigNumberish, + data: BytesLike + ], + [void], + "nonpayable" + >; + + setApprovalForAll: TypedContractMethod< + [operator: AddressLike, approved: boolean], + [void], + "nonpayable" + >; + + setPledgeAddress: TypedContractMethod< + [_pledgeAddr: AddressLike], + [void], + "nonpayable" + >; + + supportsInterface: TypedContractMethod< + [interfaceId: BytesLike], + [boolean], + "view" + >; + + symbol: TypedContractMethod<[], [string], "view">; + + tokenByIndex: TypedContractMethod<[index: BigNumberish], [bigint], "view">; + + tokenOfOwnerByIndex: TypedContractMethod< + [owner: AddressLike, index: BigNumberish], + [bigint], + "view" + >; + + tokenURI: TypedContractMethod<[tokenId: BigNumberish], [string], "view">; + + totalSupply: TypedContractMethod<[], [bigint], "view">; + + transferFrom: TypedContractMethod< + [from: AddressLike, to: AddressLike, tokenId: BigNumberish], + [void], + "nonpayable" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "addAdmin" + ): TypedContractMethod<[_adds: AddressLike[]], [void], "nonpayable">; + getFunction( + nameOrSignature: "addBlacks" + ): TypedContractMethod<[_tokenIds: BigNumberish[]], [void], "nonpayable">; + getFunction( + nameOrSignature: "approve" + ): TypedContractMethod< + [to: AddressLike, tokenId: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "balanceOf" + ): TypedContractMethod<[owner: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "blacks" + ): TypedContractMethod<[arg0: BigNumberish], [bigint], "view">; + getFunction( + nameOrSignature: "delBlacks" + ): TypedContractMethod<[_tokenIds: BigNumberish[]], [void], "nonpayable">; + getFunction( + nameOrSignature: "deleteAdmin" + ): TypedContractMethod<[_dels: AddressLike[]], [void], "nonpayable">; + getFunction( + nameOrSignature: "deployAddress" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "getAdmin" + ): TypedContractMethod<[], [string[]], "view">; + getFunction( + nameOrSignature: "getApproved" + ): TypedContractMethod<[tokenId: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "getBlacks" + ): TypedContractMethod<[], [bigint[]], "view">; + getFunction( + nameOrSignature: "isApprovedForAll" + ): TypedContractMethod< + [owner: AddressLike, operator: AddressLike], + [boolean], + "view" + >; + getFunction( + nameOrSignature: "mint" + ): TypedContractMethod< + [to: AddressLike, tokenId: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "name" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "ownerOf" + ): TypedContractMethod<[tokenId: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "pledgeAddress" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "safeTransferFrom(address,address,uint256)" + ): TypedContractMethod< + [from: AddressLike, to: AddressLike, tokenId: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "safeTransferFrom(address,address,uint256,bytes)" + ): TypedContractMethod< + [ + from: AddressLike, + to: AddressLike, + tokenId: BigNumberish, + data: BytesLike + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "setApprovalForAll" + ): TypedContractMethod< + [operator: AddressLike, approved: boolean], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "setPledgeAddress" + ): TypedContractMethod<[_pledgeAddr: AddressLike], [void], "nonpayable">; + getFunction( + nameOrSignature: "supportsInterface" + ): TypedContractMethod<[interfaceId: BytesLike], [boolean], "view">; + getFunction( + nameOrSignature: "symbol" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "tokenByIndex" + ): TypedContractMethod<[index: BigNumberish], [bigint], "view">; + getFunction( + nameOrSignature: "tokenOfOwnerByIndex" + ): TypedContractMethod< + [owner: AddressLike, index: BigNumberish], + [bigint], + "view" + >; + getFunction( + nameOrSignature: "tokenURI" + ): TypedContractMethod<[tokenId: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "totalSupply" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "transferFrom" + ): TypedContractMethod< + [from: AddressLike, to: AddressLike, tokenId: BigNumberish], + [void], + "nonpayable" + >; + + getEvent( + key: "Approval" + ): TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + getEvent( + key: "ApprovalForAll" + ): TypedContractEvent< + ApprovalForAllEvent.InputTuple, + ApprovalForAllEvent.OutputTuple, + ApprovalForAllEvent.OutputObject + >; + getEvent( + key: "Transfer" + ): TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + + filters: { + "Approval(address,address,uint256)": TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + Approval: TypedContractEvent< + ApprovalEvent.InputTuple, + ApprovalEvent.OutputTuple, + ApprovalEvent.OutputObject + >; + + "ApprovalForAll(address,address,bool)": TypedContractEvent< + ApprovalForAllEvent.InputTuple, + ApprovalForAllEvent.OutputTuple, + ApprovalForAllEvent.OutputObject + >; + ApprovalForAll: TypedContractEvent< + ApprovalForAllEvent.InputTuple, + ApprovalForAllEvent.OutputTuple, + ApprovalForAllEvent.OutputObject + >; + + "Transfer(address,address,uint256)": TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + Transfer: TypedContractEvent< + TransferEvent.InputTuple, + TransferEvent.OutputTuple, + TransferEvent.OutputObject + >; + }; +} diff --git a/src/contract/typechain-types/contracts/Pledge.ts b/src/contract/typechain-types/contracts/Pledge.ts new file mode 100644 index 0000000..4ff9ed2 --- /dev/null +++ b/src/contract/typechain-types/contracts/Pledge.ts @@ -0,0 +1,1184 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "../common"; + +export type PledgeTypeStruct = { + tokenId: BigNumberish; + startTime: BigNumberish; + endTime: BigNumberish; + withdrawTime: BigNumberish; + pledgeAmount: BigNumberish; + rate: BigNumberish; + pledgeDay: BigNumberish; + sender: AddressLike; + isBlack: boolean; +}; + +export type PledgeTypeStructOutput = [ + tokenId: bigint, + startTime: bigint, + endTime: bigint, + withdrawTime: bigint, + pledgeAmount: bigint, + rate: bigint, + pledgeDay: bigint, + sender: string, + isBlack: boolean +] & { + tokenId: bigint; + startTime: bigint; + endTime: bigint; + withdrawTime: bigint; + pledgeAmount: bigint; + rate: bigint; + pledgeDay: bigint; + sender: string; + isBlack: boolean; +}; + +export type RecommendObjTypeStruct = { + key: AddressLike; + referrer: AddressLike; + bindTime: BigNumberish; + contribute: BigNumberish; +}; + +export type RecommendObjTypeStructOutput = [ + key: string, + referrer: string, + bindTime: bigint, + contribute: bigint +] & { key: string; referrer: string; bindTime: bigint; contribute: bigint }; + +export type InvitationWithdrawRecordTypeStruct = { + amount: BigNumberish; + createTime: BigNumberish; +}; + +export type InvitationWithdrawRecordTypeStructOutput = [ + amount: bigint, + createTime: bigint +] & { amount: bigint; createTime: bigint }; + +export type PledgeWithdrawRecordTypeStruct = { + amount: BigNumberish; + createTime: BigNumberish; + tokenId: BigNumberish; + pledgeDay: BigNumberish; + _type: BigNumberish; +}; + +export type PledgeWithdrawRecordTypeStructOutput = [ + amount: bigint, + createTime: bigint, + tokenId: bigint, + pledgeDay: bigint, + _type: bigint +] & { + amount: bigint; + createTime: bigint; + tokenId: bigint; + pledgeDay: bigint; + _type: bigint; +}; + +export type ProductInfoStruct = { day: BigNumberish; rate: BigNumberish }; + +export type ProductInfoStructOutput = [day: bigint, rate: bigint] & { + day: bigint; + rate: bigint; +}; + +export interface PledgeInterface extends Interface { + getFunction( + nameOrSignature: + | "addBlackOrWhiteList" + | "addNftBalcks" + | "blackList" + | "calculateInterest" + | "dayTime" + | "delBlackOrWhiteList" + | "deleteNftBlacks" + | "destroyPledge" + | "getAllInvitationMember" + | "getBlackOrWhiteList" + | "getCurrentTime" + | "getDetails" + | "getInvitationWithdrawRecord" + | "getOwnerAllInvitationWithdrawAmout" + | "getOwnerAllPledgeInfo" + | "getOwnerAllTokens" + | "getOwnerInvitationPledges" + | "getPledgeDestoryRecords" + | "getPledgeRecords" + | "getPledgeWithdrawRecord" + | "getProductInfo" + | "getWithdrawbleAmount" + | "initialize" + | "invitationAddress" + | "invitationPledges" + | "invitationRate" + | "invitationTokens" + | "invitationWithdrawRecord" + | "nextTokenId" + | "pledge" + | "pledgeDestoryRecords" + | "pledgeRecords" + | "pledgeStatus" + | "pledgeWithdrawRecord" + | "productInfo" + | "recommendObj" + | "setInvitationRate" + | "setPledgeStatus" + | "setProductInfo" + | "whiteList" + | "withdraAllInterest" + | "withdraInvitationAllInterest" + | "withdrawInterest" + | "withdrawInvitationInterest" + ): FunctionFragment; + + getEvent(nameOrSignatureOrTopic: "Initialized"): EventFragment; + + encodeFunctionData( + functionFragment: "addBlackOrWhiteList", + values: [AddressLike[], BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "addNftBalcks", + values: [BigNumberish[]] + ): string; + encodeFunctionData( + functionFragment: "blackList", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "calculateInterest", + values: [PledgeTypeStruct] + ): string; + encodeFunctionData(functionFragment: "dayTime", values?: undefined): string; + encodeFunctionData( + functionFragment: "delBlackOrWhiteList", + values: [AddressLike[], BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "deleteNftBlacks", + values: [BigNumberish[]] + ): string; + encodeFunctionData( + functionFragment: "destroyPledge", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "getAllInvitationMember", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getBlackOrWhiteList", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "getCurrentTime", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getDetails", + values: [BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "getInvitationWithdrawRecord", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getOwnerAllInvitationWithdrawAmout", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getOwnerAllPledgeInfo", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getOwnerAllTokens", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getOwnerInvitationPledges", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getPledgeDestoryRecords", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getPledgeRecords", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getPledgeWithdrawRecord", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getProductInfo", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getWithdrawbleAmount", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "initialize", + values: [AddressLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "invitationAddress", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "invitationPledges", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "invitationRate", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "invitationTokens", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "invitationWithdrawRecord", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "nextTokenId", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "pledge", + values: [BigNumberish, BigNumberish, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "pledgeDestoryRecords", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "pledgeRecords", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "pledgeStatus", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "pledgeWithdrawRecord", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "productInfo", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "recommendObj", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "setInvitationRate", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "setPledgeStatus", + values: [boolean] + ): string; + encodeFunctionData( + functionFragment: "setProductInfo", + values: [BigNumberish[], BigNumberish[]] + ): string; + encodeFunctionData( + functionFragment: "whiteList", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "withdraAllInterest", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "withdraInvitationAllInterest", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "withdrawInterest", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "withdrawInvitationInterest", + values: [BigNumberish] + ): string; + + decodeFunctionResult( + functionFragment: "addBlackOrWhiteList", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "addNftBalcks", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "blackList", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "calculateInterest", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "dayTime", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "delBlackOrWhiteList", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "deleteNftBlacks", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "destroyPledge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getAllInvitationMember", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getBlackOrWhiteList", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getCurrentTime", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "getDetails", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getInvitationWithdrawRecord", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getOwnerAllInvitationWithdrawAmout", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getOwnerAllPledgeInfo", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getOwnerAllTokens", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getOwnerInvitationPledges", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getPledgeDestoryRecords", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getPledgeRecords", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getPledgeWithdrawRecord", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getProductInfo", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getWithdrawbleAmount", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "invitationAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "invitationPledges", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "invitationRate", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "invitationTokens", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "invitationWithdrawRecord", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "nextTokenId", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "pledge", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "pledgeDestoryRecords", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "pledgeRecords", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "pledgeStatus", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "pledgeWithdrawRecord", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "productInfo", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "recommendObj", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setInvitationRate", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setPledgeStatus", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setProductInfo", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "whiteList", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "withdraAllInterest", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "withdraInvitationAllInterest", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "withdrawInterest", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "withdrawInvitationInterest", + data: BytesLike + ): Result; +} + +export namespace InitializedEvent { + export type InputTuple = [version: BigNumberish]; + export type OutputTuple = [version: bigint]; + export interface OutputObject { + version: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface Pledge extends BaseContract { + connect(runner?: ContractRunner | null): Pledge; + waitForDeployment(): Promise; + + interface: PledgeInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + addBlackOrWhiteList: TypedContractMethod< + [_blacks: AddressLike[], _type: BigNumberish], + [void], + "nonpayable" + >; + + addNftBalcks: TypedContractMethod< + [_tokenIds: BigNumberish[]], + [void], + "nonpayable" + >; + + blackList: TypedContractMethod<[arg0: BigNumberish], [string], "view">; + + calculateInterest: TypedContractMethod< + [_pledge: PledgeTypeStruct], + [bigint], + "view" + >; + + dayTime: TypedContractMethod<[], [bigint], "view">; + + delBlackOrWhiteList: TypedContractMethod< + [_blacks: AddressLike[], _type: BigNumberish], + [void], + "nonpayable" + >; + + deleteNftBlacks: TypedContractMethod< + [_ids: BigNumberish[]], + [void], + "nonpayable" + >; + + destroyPledge: TypedContractMethod< + [tokenId: BigNumberish], + [void], + "nonpayable" + >; + + getAllInvitationMember: TypedContractMethod< + [addr: AddressLike], + [RecommendObjTypeStructOutput[]], + "view" + >; + + getBlackOrWhiteList: TypedContractMethod< + [_type: BigNumberish], + [string[]], + "view" + >; + + getCurrentTime: TypedContractMethod<[], [bigint], "view">; + + getDetails: TypedContractMethod< + [tokenId: BigNumberish, _type: BigNumberish], + [PledgeTypeStructOutput], + "view" + >; + + getInvitationWithdrawRecord: TypedContractMethod< + [_owner: AddressLike], + [InvitationWithdrawRecordTypeStructOutput[]], + "view" + >; + + getOwnerAllInvitationWithdrawAmout: TypedContractMethod< + [owner: AddressLike], + [bigint], + "view" + >; + + getOwnerAllPledgeInfo: TypedContractMethod< + [_ownerAddress: AddressLike], + [PledgeTypeStructOutput[]], + "view" + >; + + getOwnerAllTokens: TypedContractMethod< + [_ownerAddress: AddressLike], + [bigint[]], + "view" + >; + + getOwnerInvitationPledges: TypedContractMethod< + [addr: AddressLike], + [PledgeTypeStructOutput[]], + "view" + >; + + getPledgeDestoryRecords: TypedContractMethod< + [_owner: AddressLike], + [PledgeTypeStructOutput[]], + "view" + >; + + getPledgeRecords: TypedContractMethod< + [_owner: AddressLike], + [PledgeTypeStructOutput[]], + "view" + >; + + getPledgeWithdrawRecord: TypedContractMethod< + [_owner: AddressLike], + [PledgeWithdrawRecordTypeStructOutput[]], + "view" + >; + + getProductInfo: TypedContractMethod<[], [ProductInfoStructOutput[]], "view">; + + getWithdrawbleAmount: TypedContractMethod< + [_owner: AddressLike], + [bigint], + "view" + >; + + initialize: TypedContractMethod< + [nftAddress: AddressLike, poolAddress: AddressLike], + [void], + "nonpayable" + >; + + invitationAddress: TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [string], + "view" + >; + + invitationPledges: TypedContractMethod< + [arg0: BigNumberish], + [ + [ + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + string, + boolean + ] & { + tokenId: bigint; + startTime: bigint; + endTime: bigint; + withdrawTime: bigint; + pledgeAmount: bigint; + rate: bigint; + pledgeDay: bigint; + sender: string; + isBlack: boolean; + } + ], + "view" + >; + + invitationRate: TypedContractMethod<[], [bigint], "view">; + + invitationTokens: TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [bigint], + "view" + >; + + invitationWithdrawRecord: TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [[bigint, bigint] & { amount: bigint; createTime: bigint }], + "view" + >; + + nextTokenId: TypedContractMethod<[], [bigint], "view">; + + pledge: TypedContractMethod< + [amount: BigNumberish, index: BigNumberish, _referrer: AddressLike], + [void], + "nonpayable" + >; + + pledgeDestoryRecords: TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [ + [ + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + string, + boolean + ] & { + tokenId: bigint; + startTime: bigint; + endTime: bigint; + withdrawTime: bigint; + pledgeAmount: bigint; + rate: bigint; + pledgeDay: bigint; + sender: string; + isBlack: boolean; + } + ], + "view" + >; + + pledgeRecords: TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [ + [ + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + string, + boolean + ] & { + tokenId: bigint; + startTime: bigint; + endTime: bigint; + withdrawTime: bigint; + pledgeAmount: bigint; + rate: bigint; + pledgeDay: bigint; + sender: string; + isBlack: boolean; + } + ], + "view" + >; + + pledgeStatus: TypedContractMethod<[], [boolean], "view">; + + pledgeWithdrawRecord: TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [ + [bigint, bigint, bigint, bigint, bigint] & { + amount: bigint; + createTime: bigint; + tokenId: bigint; + pledgeDay: bigint; + _type: bigint; + } + ], + "view" + >; + + productInfo: TypedContractMethod< + [arg0: BigNumberish], + [[bigint, bigint] & { day: bigint; rate: bigint }], + "view" + >; + + recommendObj: TypedContractMethod< + [arg0: AddressLike], + [ + [string, string, bigint, bigint] & { + key: string; + referrer: string; + bindTime: bigint; + contribute: bigint; + } + ], + "view" + >; + + setInvitationRate: TypedContractMethod< + [_rate: BigNumberish], + [void], + "nonpayable" + >; + + setPledgeStatus: TypedContractMethod< + [_status: boolean], + [void], + "nonpayable" + >; + + setProductInfo: TypedContractMethod< + [_days: BigNumberish[], _rates: BigNumberish[]], + [void], + "nonpayable" + >; + + whiteList: TypedContractMethod<[arg0: BigNumberish], [string], "view">; + + withdraAllInterest: TypedContractMethod<[], [void], "nonpayable">; + + withdraInvitationAllInterest: TypedContractMethod<[], [void], "nonpayable">; + + withdrawInterest: TypedContractMethod< + [tokenId: BigNumberish], + [void], + "nonpayable" + >; + + withdrawInvitationInterest: TypedContractMethod< + [tokenId: BigNumberish], + [void], + "nonpayable" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "addBlackOrWhiteList" + ): TypedContractMethod< + [_blacks: AddressLike[], _type: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "addNftBalcks" + ): TypedContractMethod<[_tokenIds: BigNumberish[]], [void], "nonpayable">; + getFunction( + nameOrSignature: "blackList" + ): TypedContractMethod<[arg0: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "calculateInterest" + ): TypedContractMethod<[_pledge: PledgeTypeStruct], [bigint], "view">; + getFunction( + nameOrSignature: "dayTime" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "delBlackOrWhiteList" + ): TypedContractMethod< + [_blacks: AddressLike[], _type: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "deleteNftBlacks" + ): TypedContractMethod<[_ids: BigNumberish[]], [void], "nonpayable">; + getFunction( + nameOrSignature: "destroyPledge" + ): TypedContractMethod<[tokenId: BigNumberish], [void], "nonpayable">; + getFunction( + nameOrSignature: "getAllInvitationMember" + ): TypedContractMethod< + [addr: AddressLike], + [RecommendObjTypeStructOutput[]], + "view" + >; + getFunction( + nameOrSignature: "getBlackOrWhiteList" + ): TypedContractMethod<[_type: BigNumberish], [string[]], "view">; + getFunction( + nameOrSignature: "getCurrentTime" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "getDetails" + ): TypedContractMethod< + [tokenId: BigNumberish, _type: BigNumberish], + [PledgeTypeStructOutput], + "view" + >; + getFunction( + nameOrSignature: "getInvitationWithdrawRecord" + ): TypedContractMethod< + [_owner: AddressLike], + [InvitationWithdrawRecordTypeStructOutput[]], + "view" + >; + getFunction( + nameOrSignature: "getOwnerAllInvitationWithdrawAmout" + ): TypedContractMethod<[owner: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "getOwnerAllPledgeInfo" + ): TypedContractMethod< + [_ownerAddress: AddressLike], + [PledgeTypeStructOutput[]], + "view" + >; + getFunction( + nameOrSignature: "getOwnerAllTokens" + ): TypedContractMethod<[_ownerAddress: AddressLike], [bigint[]], "view">; + getFunction( + nameOrSignature: "getOwnerInvitationPledges" + ): TypedContractMethod< + [addr: AddressLike], + [PledgeTypeStructOutput[]], + "view" + >; + getFunction( + nameOrSignature: "getPledgeDestoryRecords" + ): TypedContractMethod< + [_owner: AddressLike], + [PledgeTypeStructOutput[]], + "view" + >; + getFunction( + nameOrSignature: "getPledgeRecords" + ): TypedContractMethod< + [_owner: AddressLike], + [PledgeTypeStructOutput[]], + "view" + >; + getFunction( + nameOrSignature: "getPledgeWithdrawRecord" + ): TypedContractMethod< + [_owner: AddressLike], + [PledgeWithdrawRecordTypeStructOutput[]], + "view" + >; + getFunction( + nameOrSignature: "getProductInfo" + ): TypedContractMethod<[], [ProductInfoStructOutput[]], "view">; + getFunction( + nameOrSignature: "getWithdrawbleAmount" + ): TypedContractMethod<[_owner: AddressLike], [bigint], "view">; + getFunction( + nameOrSignature: "initialize" + ): TypedContractMethod< + [nftAddress: AddressLike, poolAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "invitationAddress" + ): TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [string], + "view" + >; + getFunction( + nameOrSignature: "invitationPledges" + ): TypedContractMethod< + [arg0: BigNumberish], + [ + [ + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + string, + boolean + ] & { + tokenId: bigint; + startTime: bigint; + endTime: bigint; + withdrawTime: bigint; + pledgeAmount: bigint; + rate: bigint; + pledgeDay: bigint; + sender: string; + isBlack: boolean; + } + ], + "view" + >; + getFunction( + nameOrSignature: "invitationRate" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "invitationTokens" + ): TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [bigint], + "view" + >; + getFunction( + nameOrSignature: "invitationWithdrawRecord" + ): TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [[bigint, bigint] & { amount: bigint; createTime: bigint }], + "view" + >; + getFunction( + nameOrSignature: "nextTokenId" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "pledge" + ): TypedContractMethod< + [amount: BigNumberish, index: BigNumberish, _referrer: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "pledgeDestoryRecords" + ): TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [ + [ + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + string, + boolean + ] & { + tokenId: bigint; + startTime: bigint; + endTime: bigint; + withdrawTime: bigint; + pledgeAmount: bigint; + rate: bigint; + pledgeDay: bigint; + sender: string; + isBlack: boolean; + } + ], + "view" + >; + getFunction( + nameOrSignature: "pledgeRecords" + ): TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [ + [ + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + bigint, + string, + boolean + ] & { + tokenId: bigint; + startTime: bigint; + endTime: bigint; + withdrawTime: bigint; + pledgeAmount: bigint; + rate: bigint; + pledgeDay: bigint; + sender: string; + isBlack: boolean; + } + ], + "view" + >; + getFunction( + nameOrSignature: "pledgeStatus" + ): TypedContractMethod<[], [boolean], "view">; + getFunction( + nameOrSignature: "pledgeWithdrawRecord" + ): TypedContractMethod< + [arg0: AddressLike, arg1: BigNumberish], + [ + [bigint, bigint, bigint, bigint, bigint] & { + amount: bigint; + createTime: bigint; + tokenId: bigint; + pledgeDay: bigint; + _type: bigint; + } + ], + "view" + >; + getFunction( + nameOrSignature: "productInfo" + ): TypedContractMethod< + [arg0: BigNumberish], + [[bigint, bigint] & { day: bigint; rate: bigint }], + "view" + >; + getFunction( + nameOrSignature: "recommendObj" + ): TypedContractMethod< + [arg0: AddressLike], + [ + [string, string, bigint, bigint] & { + key: string; + referrer: string; + bindTime: bigint; + contribute: bigint; + } + ], + "view" + >; + getFunction( + nameOrSignature: "setInvitationRate" + ): TypedContractMethod<[_rate: BigNumberish], [void], "nonpayable">; + getFunction( + nameOrSignature: "setPledgeStatus" + ): TypedContractMethod<[_status: boolean], [void], "nonpayable">; + getFunction( + nameOrSignature: "setProductInfo" + ): TypedContractMethod< + [_days: BigNumberish[], _rates: BigNumberish[]], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "whiteList" + ): TypedContractMethod<[arg0: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "withdraAllInterest" + ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "withdraInvitationAllInterest" + ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "withdrawInterest" + ): TypedContractMethod<[tokenId: BigNumberish], [void], "nonpayable">; + getFunction( + nameOrSignature: "withdrawInvitationInterest" + ): TypedContractMethod<[tokenId: BigNumberish], [void], "nonpayable">; + + getEvent( + key: "Initialized" + ): TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + + filters: { + "Initialized(uint64)": TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + Initialized: TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + }; +} diff --git a/src/contract/typechain-types/contracts/Pool.ts b/src/contract/typechain-types/contracts/Pool.ts new file mode 100644 index 0000000..61e618c --- /dev/null +++ b/src/contract/typechain-types/contracts/Pool.ts @@ -0,0 +1,241 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "../common"; + +export interface PoolInterface extends Interface { + getFunction( + nameOrSignature: + | "_pledgeContractAddress" + | "deposit" + | "initialize" + | "poolStatus" + | "setPledgeContractAddress" + | "setPoolStatus" + | "withdraw" + | "withdrawTo" + ): FunctionFragment; + + getEvent(nameOrSignatureOrTopic: "Initialized"): EventFragment; + + encodeFunctionData( + functionFragment: "_pledgeContractAddress", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "deposit", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "initialize", + values: [AddressLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "poolStatus", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "setPledgeContractAddress", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "setPoolStatus", + values: [boolean] + ): string; + encodeFunctionData( + functionFragment: "withdraw", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "withdrawTo", + values: [BigNumberish] + ): string; + + decodeFunctionResult( + functionFragment: "_pledgeContractAddress", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "deposit", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "poolStatus", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "setPledgeContractAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setPoolStatus", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "withdrawTo", data: BytesLike): Result; +} + +export namespace InitializedEvent { + export type InputTuple = [version: BigNumberish]; + export type OutputTuple = [version: bigint]; + export interface OutputObject { + version: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface Pool extends BaseContract { + connect(runner?: ContractRunner | null): Pool; + waitForDeployment(): Promise; + + interface: PoolInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + _pledgeContractAddress: TypedContractMethod<[], [string], "view">; + + deposit: TypedContractMethod< + [from: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + + initialize: TypedContractMethod< + [tokenAddress: AddressLike, nftAddress: AddressLike], + [void], + "nonpayable" + >; + + poolStatus: TypedContractMethod<[], [boolean], "view">; + + setPledgeContractAddress: TypedContractMethod< + [addr: AddressLike], + [void], + "nonpayable" + >; + + setPoolStatus: TypedContractMethod<[_status: boolean], [void], "nonpayable">; + + withdraw: TypedContractMethod< + [to: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + + withdrawTo: TypedContractMethod<[amount: BigNumberish], [void], "nonpayable">; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "_pledgeContractAddress" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "deposit" + ): TypedContractMethod< + [from: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "initialize" + ): TypedContractMethod< + [tokenAddress: AddressLike, nftAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "poolStatus" + ): TypedContractMethod<[], [boolean], "view">; + getFunction( + nameOrSignature: "setPledgeContractAddress" + ): TypedContractMethod<[addr: AddressLike], [void], "nonpayable">; + getFunction( + nameOrSignature: "setPoolStatus" + ): TypedContractMethod<[_status: boolean], [void], "nonpayable">; + getFunction( + nameOrSignature: "withdraw" + ): TypedContractMethod< + [to: AddressLike, amount: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "withdrawTo" + ): TypedContractMethod<[amount: BigNumberish], [void], "nonpayable">; + + getEvent( + key: "Initialized" + ): TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + + filters: { + "Initialized(uint64)": TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + Initialized: TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + }; +} diff --git a/src/contract/typechain-types/contracts/index.ts b/src/contract/typechain-types/contracts/index.ts new file mode 100644 index 0000000..08c6039 --- /dev/null +++ b/src/contract/typechain-types/contracts/index.ts @@ -0,0 +1,7 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { FIL } from "./FIL"; +export type { NFT } from "./NFT"; +export type { Pledge } from "./Pledge"; +export type { Pool } from "./Pool"; diff --git a/src/contract/typechain-types/factories/contracts/FIL__factory.ts b/src/contract/typechain-types/factories/contracts/FIL__factory.ts new file mode 100644 index 0000000..be45252 --- /dev/null +++ b/src/contract/typechain-types/factories/contracts/FIL__factory.ts @@ -0,0 +1,374 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { + Contract, + ContractFactory, + ContractTransactionResponse, + Interface, +} from "ethers"; +import type { Signer, ContractDeployTransaction, ContractRunner } from "ethers"; +import type { NonPayableOverrides } from "../../common"; +import type { FIL, FILInterface } from "../../contracts/FIL"; + +const _abi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "allowance", + type: "uint256", + }, + { + internalType: "uint256", + name: "needed", + type: "uint256", + }, + ], + name: "ERC20InsufficientAllowance", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "balance", + type: "uint256", + }, + { + internalType: "uint256", + name: "needed", + type: "uint256", + }, + ], + name: "ERC20InsufficientBalance", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address", + }, + ], + name: "ERC20InvalidApprover", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address", + }, + ], + name: "ERC20InvalidReceiver", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "ERC20InvalidSender", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + ], + name: "ERC20InvalidSpender", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Approval", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "address", + name: "spender", + type: "address", + }, + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +const _bytecode = + "0x60806040523480156200001157600080fd5b506040518060400160405280600b81526020016a2334b632b1b7b4b72232bb60a91b815250604051806040016040528060048152602001631111925360e21b8152508160039081620000649190620002d4565b506004620000738282620002d4565b505050620000ad336200008b620000b360201b60201c565b6200009890600a620004b5565b620000a79062989680620004cd565b620000b8565b620004fd565b601290565b6001600160a01b038216620000e85760405163ec442f0560e01b8152600060048201526024015b60405180910390fd5b620000f660008383620000fa565b5050565b6001600160a01b038316620001295780600260008282546200011d9190620004e7565b909155506200019d9050565b6001600160a01b038316600090815260208190526040902054818110156200017e5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401620000df565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b038216620001bb57600280548290039055620001da565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516200022091815260200190565b60405180910390a3505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200025857607f821691505b6020821081036200027957634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002cf576000816000526020600020601f850160051c81016020861015620002aa5750805b601f850160051c820191505b81811015620002cb57828155600101620002b6565b5050505b505050565b81516001600160401b03811115620002f057620002f06200022d565b620003088162000301845462000243565b846200027f565b602080601f831160018114620003405760008415620003275750858301515b600019600386901b1c1916600185901b178555620002cb565b600085815260208120601f198616915b82811015620003715788860151825594840194600190910190840162000350565b5085821015620003905787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620003f7578160001904821115620003db57620003db620003a0565b80851615620003e957918102915b93841c9390800290620003bb565b509250929050565b6000826200041057506001620004af565b816200041f57506000620004af565b8160018114620004385760028114620004435762000463565b6001915050620004af565b60ff841115620004575762000457620003a0565b50506001821b620004af565b5060208310610133831016604e8410600b841016171562000488575081810a620004af565b620004948383620003b6565b8060001904821115620004ab57620004ab620003a0565b0290505b92915050565b6000620004c660ff841683620003ff565b9392505050565b8082028115828204841417620004af57620004af620003a0565b80820180821115620004af57620004af620003a0565b6107c7806200050d6000396000f3fe608060405234801561001057600080fd5b50600436106100a35760003560e01c8063313ce5671161007657806395d89b411161005b57806395d89b4114610146578063a9059cbb1461014e578063dd62ed3e1461016157600080fd5b8063313ce5671461010e57806370a082311461011d57600080fd5b806306fdde03146100a8578063095ea7b3146100c657806318160ddd146100e957806323b872dd146100fb575b600080fd5b6100b061019a565b6040516100bd9190610610565b60405180910390f35b6100d96100d436600461067b565b61022c565b60405190151581526020016100bd565b6002545b6040519081526020016100bd565b6100d96101093660046106a5565b610246565b604051601281526020016100bd565b6100ed61012b3660046106e1565b6001600160a01b031660009081526020819052604090205490565b6100b061026a565b6100d961015c36600461067b565b610279565b6100ed61016f366004610703565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101a990610736565b80601f01602080910402602001604051908101604052809291908181526020018280546101d590610736565b80156102225780601f106101f757610100808354040283529160200191610222565b820191906000526020600020905b81548152906001019060200180831161020557829003601f168201915b5050505050905090565b60003361023a818585610287565b60019150505b92915050565b600033610254858285610299565b61025f858585610335565b506001949350505050565b6060600480546101a990610736565b60003361023a818585610335565b61029483838360016103c6565b505050565b6001600160a01b03838116600090815260016020908152604080832093861683529290522054600019811461032f5781811015610320576040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b61032f848484840360006103c6565b50505050565b6001600160a01b038316610378576040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260006004820152602401610317565b6001600160a01b0382166103bb576040517fec442f0500000000000000000000000000000000000000000000000000000000815260006004820152602401610317565b6102948383836104cd565b6001600160a01b038416610409576040517fe602df0500000000000000000000000000000000000000000000000000000000815260006004820152602401610317565b6001600160a01b03831661044c576040517f94280d6200000000000000000000000000000000000000000000000000000000815260006004820152602401610317565b6001600160a01b038085166000908152600160209081526040808320938716835292905220829055801561032f57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516104bf91815260200190565b60405180910390a350505050565b6001600160a01b0383166104f85780600260008282546104ed9190610770565b909155506105839050565b6001600160a01b03831660009081526020819052604090205481811015610564576040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024810182905260448101839052606401610317565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b03821661059f576002805482900390556105be565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161060391815260200190565b60405180910390a3505050565b60006020808352835180602085015260005b8181101561063e57858101830151858201604001528201610622565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461067657600080fd5b919050565b6000806040838503121561068e57600080fd5b6106978361065f565b946020939093013593505050565b6000806000606084860312156106ba57600080fd5b6106c38461065f565b92506106d16020850161065f565b9150604084013590509250925092565b6000602082840312156106f357600080fd5b6106fc8261065f565b9392505050565b6000806040838503121561071657600080fd5b61071f8361065f565b915061072d6020840161065f565b90509250929050565b600181811c9082168061074a57607f821691505b60208210810361076a57634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561024057634e487b7160e01b600052601160045260246000fdfea264697066735822122011832f4806ad976896ccf4cc11b5de1c53e800d30f6eea2fd61487fc9ad24e1b64736f6c63430008180033"; + +type FILConstructorParams = + | [signer?: Signer] + | ConstructorParameters; + +const isSuperArgs = ( + xs: FILConstructorParams +): xs is ConstructorParameters => xs.length > 1; + +export class FIL__factory extends ContractFactory { + constructor(...args: FILConstructorParams) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi, _bytecode, args[0]); + } + } + + override getDeployTransaction( + overrides?: NonPayableOverrides & { from?: string } + ): Promise { + return super.getDeployTransaction(overrides || {}); + } + override deploy(overrides?: NonPayableOverrides & { from?: string }) { + return super.deploy(overrides || {}) as Promise< + FIL & { + deploymentTransaction(): ContractTransactionResponse; + } + >; + } + override connect(runner: ContractRunner | null): FIL__factory { + return super.connect(runner) as FIL__factory; + } + + static readonly bytecode = _bytecode; + static readonly abi = _abi; + static createInterface(): FILInterface { + return new Interface(_abi) as FILInterface; + } + static connect(address: string, runner?: ContractRunner | null): FIL { + return new Contract(address, _abi, runner) as unknown as FIL; + } +} diff --git a/src/contract/typechain-types/factories/contracts/NFT__factory.ts b/src/contract/typechain-types/factories/contracts/NFT__factory.ts new file mode 100644 index 0000000..a448acb --- /dev/null +++ b/src/contract/typechain-types/factories/contracts/NFT__factory.ts @@ -0,0 +1,747 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { + Contract, + ContractFactory, + ContractTransactionResponse, + Interface, +} from "ethers"; +import type { Signer, ContractDeployTransaction, ContractRunner } from "ethers"; +import type { NonPayableOverrides } from "../../common"; +import type { NFT, NFTInterface } from "../../contracts/NFT"; + +const _abi = [ + { + inputs: [ + { + internalType: "string", + name: "name", + type: "string", + }, + { + internalType: "string", + name: "symbol", + type: "string", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "ERC721EnumerableForbiddenBatchMint", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "ERC721IncorrectOwner", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "operator", + type: "address", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "ERC721InsufficientApproval", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address", + }, + ], + name: "ERC721InvalidApprover", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "operator", + type: "address", + }, + ], + name: "ERC721InvalidOperator", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "ERC721InvalidOwner", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address", + }, + ], + name: "ERC721InvalidReceiver", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "ERC721InvalidSender", + type: "error", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "ERC721NonexistentToken", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "uint256", + name: "index", + type: "uint256", + }, + ], + name: "ERC721OutOfBoundsIndex", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "approved", + type: "address", + }, + { + indexed: true, + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "Approval", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "operator", + type: "address", + }, + { + indexed: false, + internalType: "bool", + name: "approved", + type: "bool", + }, + ], + name: "ApprovalForAll", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: true, + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, + { + inputs: [ + { + internalType: "address[]", + name: "_adds", + type: "address[]", + }, + ], + name: "addAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "_tokenIds", + type: "uint256[]", + }, + ], + name: "addBlacks", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "approve", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "blacks", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "_tokenIds", + type: "uint256[]", + }, + ], + name: "delBlacks", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address[]", + name: "_dels", + type: "address[]", + }, + ], + name: "deleteAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "deployAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getAdmin", + outputs: [ + { + internalType: "address[]", + name: "", + type: "address[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "getApproved", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getBlacks", + outputs: [ + { + internalType: "uint256[]", + name: "", + type: "uint256[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "address", + name: "operator", + type: "address", + }, + ], + name: "isApprovedForAll", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "mint", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "ownerOf", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pledgeAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "safeTransferFrom", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "safeTransferFrom", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "operator", + type: "address", + }, + { + internalType: "bool", + name: "approved", + type: "bool", + }, + ], + name: "setApprovalForAll", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_pledgeAddr", + type: "address", + }, + ], + name: "setPledgeAddress", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "interfaceId", + type: "bytes4", + }, + ], + name: "supportsInterface", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "index", + type: "uint256", + }, + ], + name: "tokenByIndex", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "uint256", + name: "index", + type: "uint256", + }, + ], + name: "tokenOfOwnerByIndex", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "tokenURI", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "transferFrom", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +const _bytecode = + "0x60806040523480156200001157600080fd5b5060405162002e0938038062002e098339810160408190526200003491620001f0565b81816000620000448382620002eb565b506001620000538282620002eb565b5050600b54600160a01b900460ff16159050620000b65760405162461bcd60e51b815260206004820152601960248201527f596f752063616e206f6e6c7920757365206974206f6e63652e00000000000000604482015260640160405180910390fd5b5050600a80546001810182556000919091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b03191633908117909155600b805460ff60a01b199092166001600160a81b031990921691909117600160a01b179055620003b7565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200015057600080fd5b81516001600160401b03808211156200016d576200016d62000128565b604051601f8301601f19908116603f0116810190828211818310171562000198576200019862000128565b8160405283815260209250866020858801011115620001b657600080fd5b600091505b83821015620001da5785820183015181830184015290820190620001bb565b6000602085830101528094505050505092915050565b600080604083850312156200020457600080fd5b82516001600160401b03808211156200021c57600080fd5b6200022a868387016200013e565b935060208501519150808211156200024157600080fd5b5062000250858286016200013e565b9150509250929050565b600181811c908216806200026f57607f821691505b6020821081036200029057634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002e6576000816000526020600020601f850160051c81016020861015620002c15750805b601f850160051c820191505b81811015620002e257828155600101620002cd565b5050505b505050565b81516001600160401b0381111562000307576200030762000128565b6200031f816200031884546200025a565b8462000296565b602080601f8311600181146200035757600084156200033e5750858301515b600019600386901b1c1916600185901b178555620002e2565b600085815260208120601f198616915b82811015620003885788860151825594840194600190910190840162000367565b5085821015620003a75787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b612a4280620003c76000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636e9960c3116100f9578063b88d4fde11610097578063cf0a5b4511610071578063cf0a5b451461039a578063d38ff7a1146103ad578063e985e9c5146103c2578063ec329a25146103fe57600080fd5b8063b88d4fde14610361578063bba295a114610374578063c87b56dd1461038757600080fd5b8063993a86bd116100d3578063993a86bd146103155780639c8bf94114610328578063a22cb4651461033b578063b3988fdf1461034e57600080fd5b80636e9960c3146102e557806370a08231146102fa57806395d89b411461030d57600080fd5b806323b872dd1161016657806340c10f191161014057806340c10f191461029957806342842e0e146102ac5780634f6ccce7146102bf5780636352211e146102d257600080fd5b806323b872dd146102605780632f745c59146102735780633d0950a81461028657600080fd5b8063095ea7b311610197578063095ea7b31461022657806318160ddd1461023b5780631d086e701461024d57600080fd5b806301ffc9a7146101be57806306fdde03146101e6578063081812fc146101fb575b600080fd5b6101d16101cc36600461245d565b610411565b60405190151581526020015b60405180910390f35b6101ee610455565b6040516101dd91906124ca565b61020e6102093660046124dd565b6104e7565b6040516001600160a01b0390911681526020016101dd565b610239610234366004612512565b610510565b005b6008545b6040519081526020016101dd565b61023961025b3660046125a7565b61051f565b61023961026e366004612644565b6107b1565b61023f610281366004612512565b610855565b6102396102943660046125a7565b6108ba565b6102396102a7366004612512565b610b98565b6102396102ba366004612644565b610c5b565b61023f6102cd3660046124dd565b610c7b565b61020e6102e03660046124dd565b610cd4565b6102ed610cdf565b6040516101dd9190612680565b61023f6103083660046126c1565b610d40565b6101ee610da1565b600b5461020e906001600160a01b031681565b6102396103363660046126c1565b610db0565b6102396103493660046126dc565b610e98565b61023961035c366004612718565b610ea3565b61023961036f36600461279e565b610f7e565b600c5461020e906001600160a01b031681565b6101ee6103953660046124dd565b610f95565b61023f6103a83660046124dd565b61100a565b6103b561102b565b6040516101dd919061285e565b6101d16103d0366004612896565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61023961040c366004612718565b611082565b60006001600160e01b031982167f780e9d6300000000000000000000000000000000000000000000000000000000148061044f575061044f82611147565b92915050565b606060008054610464906128c9565b80601f0160208091040260200160405190810160405280929190818152602001828054610490906128c9565b80156104dd5780601f106104b2576101008083540402835291602001916104dd565b820191906000526020600020905b8154815290600101906020018083116104c057829003601f168201915b5050505050905090565b60006104f2826111e2565b506000828152600460205260409020546001600160a01b031661044f565b61051b82823361121b565b5050565b6000610585600a80548060200260200160405190810160405280929190818152602001828054801561057a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161055c575b505050505033611228565b90506001811515146105de5760405162461bcd60e51b815260206004820152601760248201527f466f722061646d696e6973747261746f7273206f6e6c7900000000000000000060448201526064015b60405180910390fd5b600b546000906105f89084906001600160a01b0316611228565b600b549091506001600160a01b031633146106695760405162461bcd60e51b815260206004820152602b60248201527f43616e206f6e6c792062652063616c6c65642062792074686520636f6e74726160448201526a31ba103232b83637bcb2b960a91b60648201526084016105d5565b80156106dd5760405162461bcd60e51b815260206004820152602360248201527f556e61626c6520746f2064656c65746520636f6e7472616374206465706c6f7960448201527f657273000000000000000000000000000000000000000000000000000000000060648201526084016105d5565b600083511161072e5760405162461bcd60e51b815260206004820152601f60248201527f4d75737420656e746572206174206c65617374206f6e6520616464726573730060448201526064016105d5565b6000610794600a80548060200260200160405190810160405280929190818152602001828054801561078957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161076b575b505050505085611282565b80519091506107aa90600a906020840190612382565b5050505050565b6001600160a01b0382166107db57604051633250574960e11b8152600060048201526024016105d5565b60006107e8838333611484565b9050836001600160a01b0316816001600160a01b03161461084f576040517f64283d7b0000000000000000000000000000000000000000000000000000000081526001600160a01b03808616600483015260248201849052821660448201526064016105d5565b50505050565b600061086083610d40565b82106108915760405163295f44f760e21b81526001600160a01b0384166004820152602481018390526044016105d5565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600061091e600a80548060200260200160405190810160405280929190818152602001828054801561057a576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161055c57505050505033611228565b90506001811515146109725760405162461bcd60e51b815260206004820152601760248201527f466f722061646d696e6973747261746f7273206f6e6c7900000000000000000060448201526064016105d5565b60008251116109c35760405162461bcd60e51b815260206004820152601f60248201527f4d75737420656e746572206174206c65617374206f6e6520616464726573730060448201526064016105d5565b600b546001600160a01b03163314610a315760405162461bcd60e51b815260206004820152602b60248201527f43616e206f6e6c792062652063616c6c65642062792074686520636f6e74726160448201526a31ba103232b83637bcb2b960a91b60648201526084016105d5565b60005b8251811015610b1b576000838281518110610a5157610a51612903565b602002602001015190506000610ac1600a805480602002602001604051908101604052809291908181526020018280548015610ab657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610a98575b505050505083611228565b90508015610b115760405162461bcd60e51b815260206004820152601660248201527f4164647265737320616c7265616479206578697374730000000000000000000060448201526064016105d5565b5050600101610a34565b506000610b82600a805480602002602001604051908101604052809291908181526020018280548015610b7757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610b59575b50505050508461156b565b805190915061084f90600a906020840190612382565b600c546001600160a01b03163314610c015760405162461bcd60e51b815260206004820152602660248201527f4f6e6c792074686520506c656467652041677265656d656e742063616e206265604482015265103ab9b2b21760d11b60648201526084016105d5565b60008111610c515760405162461bcd60e51b815260206004820152601d60248201527f4e4654204944206d7573742062652067726561746572207468616e203000000060448201526064016105d5565b61051b828261169d565b610c7683838360405180602001604052806000815250610f7e565b505050565b6000610c8660085490565b8210610caf5760405163295f44f760e21b815260006004820152602481018390526044016105d5565b60088281548110610cc257610cc2612903565b90600052602060002001549050919050565b600061044f826111e2565b6060600a8054806020026020016040519081016040528092919081815260200182805480156104dd57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610d19575050505050905090565b60006001600160a01b038216610d85576040517f89c62b64000000000000000000000000000000000000000000000000000000008152600060048201526024016105d5565b506001600160a01b031660009081526003602052604090205490565b606060018054610464906128c9565b6000610e14600a80548060200260200160405190810160405280929190818152602001828054801561057a576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161055c57505050505033611228565b9050600181151514610e685760405162461bcd60e51b815260206004820152601760248201527f466f722061646d696e6973747261746f7273206f6e6c7900000000000000000060448201526064016105d5565b50600c805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b61051b3383836116b7565b600c546001600160a01b03163314610f0c5760405162461bcd60e51b815260206004820152602660248201527f4f6e6c792074686520506c656467652041677265656d656e742063616e206265604482015265103ab9b2b21760d11b60648201526084016105d5565b6000610f68600d805480602002602001604051908101604052809291908181526020018280548015610f5d57602002820191906000526020600020905b815481526020019060010190808311610f49575b50505050508361176f565b8051909150610c7690600d9060208401906123f4565b610f898484846107b1565b61084f84848484611946565b6060610fa0826111e2565b506000610fb860408051602081019091526000815290565b90506000815111610fd85760405180602001604052806000815250611003565b80610fe284611a68565b604051602001610ff3929190612919565b6040516020818303038152906040525b9392505050565b600d818154811061101a57600080fd5b600091825260209091200154905081565b6060600d8054806020026020016040519081016040528092919081815260200182805480156104dd57602002820191906000526020600020905b815481526020019060010190808311611065575050505050905090565b600c546001600160a01b031633146110eb5760405162461bcd60e51b815260206004820152602660248201527f4f6e6c792074686520506c656467652041677265656d656e742063616e206265604482015265103ab9b2b21760d11b60648201526084016105d5565b6000610f68600d80548060200260200160405190810160405280929190818152602001828054801561113c57602002820191906000526020600020905b815481526020019060010190808311611128575b505050505083611b08565b60006001600160e01b031982167f80ac58cd0000000000000000000000000000000000000000000000000000000014806111aa57506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061044f57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b031983161461044f565b6000818152600260205260408120546001600160a01b03168061044f57604051637e27328960e01b8152600481018490526024016105d5565b610c768383836001611c15565b60008060005b845181101561127a57836001600160a01b031685828151811061125357611253612903565b60200260200101516001600160a01b031603611272576001915061127a565b60010161122e565b509392505050565b60606000835167ffffffffffffffff8111156112a0576112a061253c565b6040519080825280602002602001820160405280156112c9578160200160208202803683370190505b50905060005b83518110156113695760005b8551811015611360578482815181106112f6576112f6612903565b60200260200101516001600160a01b031686828151811061131957611319612903565b60200260200101516001600160a01b03160361135857600183828151811061134357611343612903565b91151560209283029190910190910152611360565b6001016112db565b506001016112cf565b506000805b85518110156113ab5782818151811061138957611389612903565b60200260200101516113a3578161139f8161295e565b9250505b60010161136e565b5060008167ffffffffffffffff8111156113c7576113c761253c565b6040519080825280602002602001820160405280156113f0578160200160208202803683370190505b5090506000805b87518110156114785784818151811061141257611412612903565b60200260200101516114705787818151811061143057611430612903565b602002602001015183838151811061144a5761144a612903565b6001600160a01b03909216602092830291909101909101528161146c8161295e565b9250505b6001016113f7565b50909695505050505050565b6000806114e1600d8054806020026020016040519081016040528092919081815260200182805480156114d657602002820191906000526020600020905b8154815260200190600101908083116114c2575b505050505085611d60565b905080156115575760405162461bcd60e51b815260206004820152603260248201527f556e61626c6520746f205472616e736665722c20746865204e465420546f6b6560448201527f6e6420697320626c61636b6c69737465642e000000000000000000000000000060648201526084016105d5565b611562858585611da0565b95945050505050565b606060008251845161157d9190612977565b905060008167ffffffffffffffff81111561159a5761159a61253c565b6040519080825280602002602001820160405280156115c3578160200160208202803683370190505b5090506000805b865181101561162c578681815181106115e5576115e5612903565b60200260200101518383815181106115ff576115ff612903565b6001600160a01b0390921660209283029190910190910152816116218161295e565b9250506001016115ca565b5060005b85518110156116925785818151811061164b5761164b612903565b602002602001015183838151811061166557611665612903565b6001600160a01b0390921660209283029190910190910152816116878161295e565b925050600101611630565b509095945050505050565b61051b828260405180602001604052806000815250611e75565b6001600160a01b038216611702576040517f5b08ba180000000000000000000000000000000000000000000000000000000081526001600160a01b03831660048201526024016105d5565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60606000835167ffffffffffffffff81111561178d5761178d61253c565b6040519080825280602002602001820160405280156117b6578160200160208202803683370190505b50905060005b83518110156118445760005b855181101561183b578482815181106117e3576117e3612903565b60200260200101518682815181106117fd576117fd612903565b60200260200101510361183357600183828151811061181e5761181e612903565b9115156020928302919091019091015261183b565b6001016117c8565b506001016117bc565b506000805b85518110156118865782818151811061186457611864612903565b602002602001015161187e578161187a8161295e565b9250505b600101611849565b5060008167ffffffffffffffff8111156118a2576118a261253c565b6040519080825280602002602001820160405280156118cb578160200160208202803683370190505b5090506000805b8751811015611478578481815181106118ed576118ed612903565b602002602001015161193e5787818151811061190b5761190b612903565b602002602001015183838151811061192557611925612903565b60209081029190910101528161193a8161295e565b9250505b6001016118d2565b6001600160a01b0383163b1561084f57604051630a85bd0160e11b81526001600160a01b0384169063150b7a029061198890339088908790879060040161298a565b6020604051808303816000875af19250505080156119c3575060408051601f3d908101601f191682019092526119c0918101906129c6565b60015b611a2c573d8080156119f1576040519150601f19603f3d011682016040523d82523d6000602084013e6119f6565b606091505b508051600003611a2457604051633250574960e11b81526001600160a01b03851660048201526024016105d5565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b146107aa57604051633250574960e11b81526001600160a01b03851660048201526024016105d5565b60606000611a7583611e8c565b600101905060008167ffffffffffffffff811115611a9557611a9561253c565b6040519080825280601f01601f191660200182016040528015611abf576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8504945084611ac957509392505050565b6060600082518451611b1a9190612977565b905060008167ffffffffffffffff811115611b3757611b3761253c565b604051908082528060200260200182016040528015611b60578160200160208202803683370190505b5090506000805b8651811015611bbc57868181518110611b8257611b82612903565b6020026020010151838381518110611b9c57611b9c612903565b602090810291909101015281611bb18161295e565b925050600101611b67565b5060005b855181101561169257858181518110611bdb57611bdb612903565b6020026020010151838381518110611bf557611bf5612903565b602090810291909101015281611c0a8161295e565b925050600101611bc0565b8080611c2957506001600160a01b03821615155b15611d23576000611c39846111e2565b90506001600160a01b03831615801590611c655750826001600160a01b0316816001600160a01b031614155b8015611c9757506001600160a01b0380821660009081526005602090815260408083209387168352929052205460ff16155b15611cd9576040517fa9fbf51f0000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105d5565b8115611d215783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50506000908152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60008060005b845181101561127a5783858281518110611d8257611d82612903565b602002602001015103611d98576001915061127a565b600101611d66565b600080611dae858585611f6e565b90506001600160a01b038116611e0b57611e0684600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611e2e565b846001600160a01b0316816001600160a01b031614611e2e57611e2e8185612074565b6001600160a01b038516611e4a57611e4584612105565b611e6d565b846001600160a01b0316816001600160a01b031614611e6d57611e6d85856121b4565b949350505050565b611e7f8383612204565b610c766000848484611946565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611ed5577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310611f01576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611f1f57662386f26fc10000830492506010015b6305f5e1008310611f37576305f5e100830492506008015b6127108310611f4b57612710830492506004015b60648310611f5d576064830492506002015b600a831061044f5760010192915050565b6000828152600260205260408120546001600160a01b0390811690831615611f9b57611f9b818486612282565b6001600160a01b03811615611fd957611fb8600085600080611c15565b6001600160a01b038116600090815260036020526040902080546000190190555b6001600160a01b03851615612008576001600160a01b0385166000908152600360205260409020805460010190555b600084815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b600061207f83610d40565b6000838152600760205260409020549091508082146120d2576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612117906001906129e3565b6000838152600960205260408120546008805493945090928490811061213f5761213f612903565b90600052602060002001549050806008838154811061216057612160612903565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612198576121986129f6565b6001900381819060005260206000200160009055905550505050565b600060016121c184610d40565b6121cb91906129e3565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b03821661222e57604051633250574960e11b8152600060048201526024016105d5565b600061223c83836000611484565b90506001600160a01b03811615610c76576040517f73c6ac6e000000000000000000000000000000000000000000000000000000008152600060048201526024016105d5565b61228d8383836122ff565b610c76576001600160a01b0383166122bb57604051637e27328960e01b8152600481018290526024016105d5565b6040517f177e802f0000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602481018290526044016105d5565b60006001600160a01b03831615801590611e6d5750826001600160a01b0316846001600160a01b0316148061235957506001600160a01b0380851660009081526005602090815260408083209387168352929052205460ff165b80611e6d5750506000908152600460205260409020546001600160a01b03908116911614919050565b8280548282559060005260206000209081019282156123e4579160200282015b828111156123e4578251825473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039091161782556020909201916001909101906123a2565b506123f092915061242f565b5090565b8280548282559060005260206000209081019282156123e4579160200282015b828111156123e4578251825591602001919060010190612414565b5b808211156123f05760008155600101612430565b6001600160e01b03198116811461245a57600080fd5b50565b60006020828403121561246f57600080fd5b813561100381612444565b60005b8381101561249557818101518382015260200161247d565b50506000910152565b600081518084526124b681602086016020860161247a565b601f01601f19169290920160200192915050565b602081526000611003602083018461249e565b6000602082840312156124ef57600080fd5b5035919050565b80356001600160a01b038116811461250d57600080fd5b919050565b6000806040838503121561252557600080fd5b61252e836124f6565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561257b5761257b61253c565b604052919050565b600067ffffffffffffffff82111561259d5761259d61253c565b5060051b60200190565b600060208083850312156125ba57600080fd5b823567ffffffffffffffff8111156125d157600080fd5b8301601f810185136125e257600080fd5b80356125f56125f082612583565b612552565b81815260059190911b8201830190838101908783111561261457600080fd5b928401925b828410156126395761262a846124f6565b82529284019290840190612619565b979650505050505050565b60008060006060848603121561265957600080fd5b612662846124f6565b9250612670602085016124f6565b9150604084013590509250925092565b6020808252825182820181905260009190848201906040850190845b818110156114785783516001600160a01b03168352928401929184019160010161269c565b6000602082840312156126d357600080fd5b611003826124f6565b600080604083850312156126ef57600080fd5b6126f8836124f6565b91506020830135801515811461270d57600080fd5b809150509250929050565b6000602080838503121561272b57600080fd5b823567ffffffffffffffff81111561274257600080fd5b8301601f8101851361275357600080fd5b80356127616125f082612583565b81815260059190911b8201830190838101908783111561278057600080fd5b928401925b8284101561263957833582529284019290840190612785565b600080600080608085870312156127b457600080fd5b6127bd856124f6565b935060206127cc8187016124f6565b935060408601359250606086013567ffffffffffffffff808211156127f057600080fd5b818801915088601f83011261280457600080fd5b8135818111156128165761281661253c565b612828601f8201601f19168501612552565b9150808252898482850101111561283e57600080fd5b808484018584013760008482840101525080935050505092959194509250565b6020808252825182820181905260009190848201906040850190845b818110156114785783518352928401929184019160010161287a565b600080604083850312156128a957600080fd5b6128b2836124f6565b91506128c0602084016124f6565b90509250929050565b600181811c908216806128dd57607f821691505b6020821081036128fd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b6000835161292b81846020880161247a565b83519083019061293f81836020880161247a565b01949350505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161297057612970612948565b5060010190565b8082018082111561044f5761044f612948565b60006001600160a01b038087168352808616602084015250836040830152608060608301526129bc608083018461249e565b9695505050505050565b6000602082840312156129d857600080fd5b815161100381612444565b8181038181111561044f5761044f612948565b634e487b7160e01b600052603160045260246000fdfea264697066735822122019882c7d1e074f47e5b0c81020aeb5869dd3763bed5f30f082cf5619c9e36f1564736f6c63430008180033"; + +type NFTConstructorParams = + | [signer?: Signer] + | ConstructorParameters; + +const isSuperArgs = ( + xs: NFTConstructorParams +): xs is ConstructorParameters => xs.length > 1; + +export class NFT__factory extends ContractFactory { + constructor(...args: NFTConstructorParams) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi, _bytecode, args[0]); + } + } + + override getDeployTransaction( + name: string, + symbol: string, + overrides?: NonPayableOverrides & { from?: string } + ): Promise { + return super.getDeployTransaction(name, symbol, overrides || {}); + } + override deploy( + name: string, + symbol: string, + overrides?: NonPayableOverrides & { from?: string } + ) { + return super.deploy(name, symbol, overrides || {}) as Promise< + NFT & { + deploymentTransaction(): ContractTransactionResponse; + } + >; + } + override connect(runner: ContractRunner | null): NFT__factory { + return super.connect(runner) as NFT__factory; + } + + static readonly bytecode = _bytecode; + static readonly abi = _abi; + static createInterface(): NFTInterface { + return new Interface(_abi) as NFTInterface; + } + static connect(address: string, runner?: ContractRunner | null): NFT { + return new Contract(address, _abi, runner) as unknown as NFT; + } +} diff --git a/src/contract/typechain-types/factories/contracts/Pledge__factory.ts b/src/contract/typechain-types/factories/contracts/Pledge__factory.ts new file mode 100644 index 0000000..199e4df --- /dev/null +++ b/src/contract/typechain-types/factories/contracts/Pledge__factory.ts @@ -0,0 +1,1373 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { + Contract, + ContractFactory, + ContractTransactionResponse, + Interface, +} from "ethers"; +import type { Signer, ContractDeployTransaction, ContractRunner } from "ethers"; +import type { NonPayableOverrides } from "../../common"; +import type { Pledge, PledgeInterface } from "../../contracts/Pledge"; + +const _abi = [ + { + inputs: [], + name: "InvalidInitialization", + type: "error", + }, + { + inputs: [], + name: "NotInitializing", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint64", + name: "version", + type: "uint64", + }, + ], + name: "Initialized", + type: "event", + }, + { + inputs: [ + { + internalType: "address[]", + name: "_blacks", + type: "address[]", + }, + { + internalType: "uint256", + name: "_type", + type: "uint256", + }, + ], + name: "addBlackOrWhiteList", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "_tokenIds", + type: "uint256[]", + }, + ], + name: "addNftBalcks", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "blackList", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + internalType: "struct PledgeType", + name: "_pledge", + type: "tuple", + }, + ], + name: "calculateInterest", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "dayTime", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address[]", + name: "_blacks", + type: "address[]", + }, + { + internalType: "uint256", + name: "_type", + type: "uint256", + }, + ], + name: "delBlackOrWhiteList", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "_ids", + type: "uint256[]", + }, + ], + name: "deleteNftBlacks", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "destroyPledge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "addr", + type: "address", + }, + ], + name: "getAllInvitationMember", + outputs: [ + { + components: [ + { + internalType: "address", + name: "key", + type: "address", + }, + { + internalType: "address", + name: "referrer", + type: "address", + }, + { + internalType: "uint256", + name: "bindTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "contribute", + type: "uint256", + }, + ], + internalType: "struct RecommendObjType[]", + name: "result", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_type", + type: "uint256", + }, + ], + name: "getBlackOrWhiteList", + outputs: [ + { + internalType: "address[]", + name: "", + type: "address[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getCurrentTime", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_type", + type: "uint256", + }, + ], + name: "getDetails", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + internalType: "struct PledgeType", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + ], + name: "getInvitationWithdrawRecord", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "createTime", + type: "uint256", + }, + ], + internalType: "struct InvitationWithdrawRecordType[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "getOwnerAllInvitationWithdrawAmout", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_ownerAddress", + type: "address", + }, + ], + name: "getOwnerAllPledgeInfo", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + internalType: "struct PledgeType[]", + name: "result", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_ownerAddress", + type: "address", + }, + ], + name: "getOwnerAllTokens", + outputs: [ + { + internalType: "uint256[]", + name: "", + type: "uint256[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "addr", + type: "address", + }, + ], + name: "getOwnerInvitationPledges", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + internalType: "struct PledgeType[]", + name: "result", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + ], + name: "getPledgeDestoryRecords", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + internalType: "struct PledgeType[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + ], + name: "getPledgeRecords", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + internalType: "struct PledgeType[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + ], + name: "getPledgeWithdrawRecord", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "createTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "uint256", + name: "_type", + type: "uint256", + }, + ], + internalType: "struct PledgeWithdrawRecordType[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getProductInfo", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "day", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + ], + internalType: "struct ProductInfo[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + ], + name: "getWithdrawbleAmount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "nftAddress", + type: "address", + }, + { + internalType: "address", + name: "poolAddress", + type: "address", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "invitationAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "invitationPledges", + outputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "invitationRate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "invitationTokens", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "invitationWithdrawRecord", + outputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "createTime", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "nextTokenId", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "index", + type: "uint256", + }, + { + internalType: "address", + name: "_referrer", + type: "address", + }, + ], + name: "pledge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "pledgeDestoryRecords", + outputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "pledgeRecords", + outputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "withdrawTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bool", + name: "isBlack", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pledgeStatus", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "pledgeWithdrawRecord", + outputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "createTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + internalType: "uint256", + name: "pledgeDay", + type: "uint256", + }, + { + internalType: "uint256", + name: "_type", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "productInfo", + outputs: [ + { + internalType: "uint256", + name: "day", + type: "uint256", + }, + { + internalType: "uint256", + name: "rate", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "recommendObj", + outputs: [ + { + internalType: "address", + name: "key", + type: "address", + }, + { + internalType: "address", + name: "referrer", + type: "address", + }, + { + internalType: "uint256", + name: "bindTime", + type: "uint256", + }, + { + internalType: "uint256", + name: "contribute", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_rate", + type: "uint256", + }, + ], + name: "setInvitationRate", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bool", + name: "_status", + type: "bool", + }, + ], + name: "setPledgeStatus", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "_days", + type: "uint256[]", + }, + { + internalType: "uint256[]", + name: "_rates", + type: "uint256[]", + }, + ], + name: "setProductInfo", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "whiteList", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "withdraAllInterest", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "withdraInvitationAllInterest", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "withdrawInterest", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "withdrawInvitationInterest", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +const _bytecode = + "0x608060405234801561001057600080fd5b50614e87806100206000396000f3fe608060405234801561001057600080fd5b50600436106102f45760003560e01c806392e6c01e11610191578063d6083337116100e3578063e8c8585111610097578063f30d4de511610071578063f30d4de51461078f578063fc72a385146107a2578063fe906a1b146107b757600080fd5b8063e8c8585114610756578063ebcbe33214610769578063f2f76c571461077c57600080fd5b8063e0b65e56116100c8578063e0b65e5614610703578063e205d7c814610716578063e56c64ef1461073657600080fd5b8063d6083337146106dd578063dd0ebe3e146106f057600080fd5b8063aeebe27111610145578063bb119f6e1161011f578063bb119f6e1461068f578063c68a3c8e146106b7578063d468e615146106ca57600080fd5b8063aeebe27114610656578063af85805b14610669578063b4ca65e61461067c57600080fd5b8063a2a2d77911610176578063a2a2d779146105c3578063a6e189cf146105d6578063a95e780c1461064357600080fd5b806392e6c01e1461059d5780639589f8ea146105b057600080fd5b806349ebbfa61161024a578063665aacca116101fe57806375794a3c116101d857806375794a3c1461056b57806380c0976e146105745780638d6ca85b1461057d57600080fd5b8063665aacca1461053d5780636efd33e814610550578063709ec8b41461055857600080fd5b80635888a3e41161022f5780635888a3e4146104ec57806359540f5e146104ff5780635c475d421461051257600080fd5b806349ebbfa6146104915780634c519a7f146104b157600080fd5b806329cb924d116102ac57806342e0ee3b1161028657806342e0ee3b1461045657806345599a9d1461045e578063485cc9551461047e57600080fd5b806329cb924d1461041d5780633715dac6146104235780633c02ecad1461043657600080fd5b806308669aab116102dd57806308669aab146103cb5780630a17e685146103e057806322eee1df146103fd57600080fd5b806304804035146102f9578063058afac914610315575b600080fd5b610302600e5481565b6040519081526020015b60405180910390f35b61037c6103233660046145d6565b60056020819052600091825260409091208054600182015460028301546003840154600485015495850154600686015460079096015494969395929491939290916001600160a01b03811690600160a01b900460ff1689565b60408051998a5260208a0198909852968801959095526060870193909352608086019190915260a085015260c08401526001600160a01b031660e083015215156101008201526101200161030c565b6103de6103d93660046145d6565b6107ca565b005b6010546103ed9060ff1681565b604051901515815260200161030c565b61041061040b366004614614565b610bbd565b60405161030c9190614638565b42610302565b610302610431366004614729565b610d46565b610449610444366004614614565b610dc9565b60405161030c91906147ae565b6103de610ea5565b61047161046c366004614614565b6111c5565b60405161030c9190614851565b6103de61048c36600461489b565b611243565b6104a461049f3660046145d6565b61149f565b60405161030c91906148d4565b6104c46104bf366004614915565b611513565b604080519586526020860194909452928401919091526060830152608082015260a00161030c565b6103de6104fa366004614941565b611561565b6103de61050d366004614a0d565b611b4f565b6105256105203660046145d6565b611e23565b6040516001600160a01b03909116815260200161030c565b6103de61054b366004614a4a565b611e4d565b6103de611fbb565b6105256105663660046145d6565b61226a565b610302600f5481565b61030260115481565b61059061058b366004614614565b61227a565b60405161030c9190614aae565b6103de6105ab3660046145d6565b612413565b6103de6105be366004614ae6565b612809565b6105256105d1366004614915565b612a43565b6106186105e4366004614614565b60066020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b604080516001600160a01b03958616815294909316602085015291830152606082015260800161030c565b6103de6106513660046145d6565b612a7b565b610302610664366004614614565b612b5a565b610302610677366004614614565b612bba565b61044961068a366004614614565b612ca8565b6106a261069d3660046145d6565b612d76565b6040805192835260208301919091520161030c565b6103de6106c53660046145d6565b612da4565b6103de6106d8366004614ae6565b613117565b6103026106eb366004614915565b613333565b61037c6106fe366004614915565b613364565b610449610711366004614614565b6133db565b610729610724366004614b86565b61356a565b60405161030c9190614ba8565b610749610744366004614614565b6136e4565b60405161030c9190614c17565b6103de610764366004614a0d565b613780565b610449610777366004614614565b6139df565b6103de61078a366004614c78565b613bc4565b61037c61079d366004614915565b613cb1565b6107aa613ccd565b60405161030c9190614c93565b6106a26107c5366004614915565b613d40565b6000610830600b80548060200260200160405190810160405280929190818152602001828054801561082557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610807575b505050505033613d7c565b905080156108855760405162461bcd60e51b815260206004820152601860248201527f596f75277665206265656e20626c61636b6c69737465642e000000000000000060448201526064015b60405180910390fd5b600080546040516331a9108f60e11b8152600481018590526001600160a01b0390911690636352211e90602401602060405180830381865afa1580156108cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f39190614cdd565b90506001600160a01b038116331461094d5760405162461bcd60e51b815260206004820152601460248201527f49742773206e6f74206120636f6e74726163742e000000000000000000000000604482015260640161087c565b6000838152600360208181526040928390208351610120810185528154815260018201549281019290925260028101549382019390935290820154606082015260048201546080820152600582015460a0820152600682015460c08201526007909101546001600160a01b03811660e0830152600160a01b900460ff16158015610100830152610a455760405162461bcd60e51b815260206004820152603160248201527f556e61626c6520746f2077697468647261772c746865204e465420546f6b656e60448201527f6420697320626c61636b6c69737465642e000000000000000000000000000000606482015260840161087c565b6000610a5082610d46565b905060008111610ab35760405162461bcd60e51b815260206004820152602860248201527f5769746864726177616c20616d6f756e74206d75737420626520677265617465604482015267072207468616e20360c41b606482015260840161087c565b60408201514290811115610ac8575060408201515b60015460405163f3fef3a360e01b8152336004820152602481018490526001600160a01b039091169063f3fef3a390604401600060405180830381600087803b158015610b1457600080fd5b505af1158015610b28573d6000803e3d6000fd5b50505060009687525060036020818152604080892083019390935533885260098152828820835160a08101855294855242858301908152865194860194855260c0909601516060860190815260016080870181815283548083018555938c5293909a20955160059092029095019081559451978501979097559051600284015590519082015592516004909301929092555050565b6001600160a01b0381166000908152600860209081526040808320805482518185028101850190935280835260609493830182828015610c2657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610c08575b50505050509050805167ffffffffffffffff811115610c4757610c476146a8565b604051908082528060200260200182016040528015610c9957816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181610c655790505b50915060005b8151811015610d3f5760066000838381518110610cbe57610cbe614cfa565b6020908102919091018101516001600160a01b03908116835282820193909352604091820160002082516080810184528154851681526001820154909416918401919091526002810154918301919091526003015460608201528351849083908110610d2c57610d2c614cfa565b6020908102919091010152600101610c9f565b5050919050565b6080810151606082015160a083015160408401516000939242929091831115610d7157856040015192505b601154600090610d818486614d26565b610d8b9190614d39565b9050600060648261016d610d9f868a614d5b565b610da99190614d39565b610db39190614d5b565b610dbd9190614d39565b98975050505050505050565b6001600160a01b0381166000908152600d60209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610e9a57600084815260209081902060408051610120810182526008860290920180548352600180820154848601526002820154928401929092526003810154606084015260048101546080840152600581015460a0840152600681015460c0840152600701546001600160a01b03811660e0840152600160a01b900460ff1615156101008301529083529092019101610e01565b505050509050919050565b6000610f09600b805480602002602001604051908101604052809291908181526020018280548015610825576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161080757505050505033613d7c565b90508015610f595760405162461bcd60e51b815260206004820152601860248201527f596f75277665206265656e20626c61636b6c69737465642e0000000000000000604482015260640161087c565b6000610f6433612bba565b905060008111610fc75760405162461bcd60e51b815260206004820152602860248201527f5769746864726177616c20616d6f756e74206d75737420626520677265617465604482015267072207468616e20360c41b606482015260840161087c565b6000610fd23361227a565b905060005b81518110156110e35760004290506000838381518110610ff957610ff9614cfa565b602002602001015190506003600082815260200190815260200160002060070160149054906101000a900460ff161561109a5760405162461bcd60e51b815260206004820152603260248201527f556e61626c6520746f2077697468647261772c20746865204e465420546f6b6560448201527f6e6420697320626c61636b6c69737465642e0000000000000000000000000000606482015260840161087c565b6000818152600360205260409020600201548211156110c85760008181526003602052604090206002015491505b60009081526003602081905260409091200155600101610fd7565b5060015460405163f3fef3a360e01b8152336004820152602481018490526001600160a01b039091169063f3fef3a390604401600060405180830381600087803b15801561113057600080fd5b505af1158015611144573d6000803e3d6000fd5b5050336000908152600960209081526040808320815160a0810183529788524288840190815291880184815260608901858152600260808b01818152845460018181018755958952969097209a516005909602909a019485559251918401919091555196820196909655945160038601555160049094019390935550505050565b6001600160a01b0381166000908152600a60209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610e9a578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906111fd565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff1660008115801561128e5750825b905060008267ffffffffffffffff1660011480156112ab5750303b155b9050811580156112b9575080155b156112f0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561132457845468ff00000000000000001916680100000000000000001785555b600080546001600160a01b03808a1673ffffffffffffffffffffffffffffffffffffffff1992831617835560018054918a1691909216178155600f818155600e8281556010805460ff191681556201518060115560408051808201825260b481526020808201948552600280548089018255818a5292519281027f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace8181019490945595517f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5acf968701558351808501855261010e81528083019788528154808a018355828b52905190820280850191909155965196860196909655825180840190935261016883528201928352845495860185559584905251939092029384019290925551910155831561149657845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b6060816001146114b057600c6114b3565b600b5b80548060200260200160405190810160405280929190818152602001828054801561150757602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116114e9575b50505050509050919050565b6009602052816000526040600020818154811061152f57600080fd5b600091825260209091206005909102018054600182015460028301546003840154600490940154929550909350919085565b60006115c5600b805480602002602001604051908101604052809291908181526020018280548015610825576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161080757505050505033613d7c565b905080156116155760405162461bcd60e51b815260206004820152601860248201527f596f75277665206265656e20626c61636b6c69737465642e0000000000000000604482015260640161087c565b6000611679600c805480602002602001604051908101604052809291908181526020018280548015610825576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161080757505050505033613d7c565b9050806116d35760105460ff16156116d35760405162461bcd60e51b815260206004820152601560248201527f54686520706c6564676520697320636c6f7365642e0000000000000000000000604482015260640161087c565b60018510156117245760405162461bcd60e51b815260206004820152601360248201527f4d696e696d756d20706c65646765203146494c00000000000000000000000000604482015260640161087c565b60025484106117755760405162461bcd60e51b815260206004820152601660248201527f50726f6475637420646f6573206e6f7420657869737400000000000000000000604482015260640161087c565b6001546040517f47e7ef24000000000000000000000000000000000000000000000000000000008152336004820152602481018790526001600160a01b03909116906347e7ef2490604401600060405180830381600087803b1580156117da57600080fd5b505af11580156117ee573d6000803e3d6000fd5b5050600f80546000935091508261180483614d72565b9091555090506001600160a01b038416156118225761182284613dce565b60006002868154811061183757611837614cfa565b600091825260208083206040805180820190915260029093020180548084526001909101549183019190915260115491935042929161187591614d5b565b61187f9042614d8b565b6000546040517f40c10f19000000000000000000000000000000000000000000000000000000008152336004820152602481018790529192506001600160a01b0316906340c10f1990604401600060405180830381600087803b1580156118e557600080fd5b505af11580156118f9573d6000803e3d6000fd5b5050505060006040518061012001604052808681526020018481526020018381526020018481526020018b81526020018560200151815260200185600001518152602001336001600160a01b031681526020016000151581525090508060036000878152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506101008201518160070160146101000a81548160ff02191690831515021790555090505060046000336001600160a01b03166001600160a01b03168152602001908152602001600020819080600181540180825580915050600190039060005260206000209060080201600090919091909150600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506101008201518160070160146101000a81548160ff021916908315150217905550505060006001600160a01b031660066000336001600160a01b03166001600160a01b0316815260200190815260200160002060000160009054906101000a90046001600160a01b03166001600160a01b031614611b4357611b4381613fa6565b50505050505050505050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316636e9960c36040518163ffffffff1660e01b8152600401600060405180830381865afa158015611ba3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bcb9190810190614d9e565b90506000611bd98233613d7c565b9050600181151514611c275760405162461bcd60e51b8152602060048201526017602482015276466f722061646d696e6973747261746f7273206f6e6c7960481b604482015260640161087c565b6000835111611c785760405162461bcd60e51b815260206004820152601260248201527f506172616d6574657220697320656d7074790000000000000000000000000000604482015260640161087c565b6000546040517fec329a250000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063ec329a2590611cc1908690600401614aae565b600060405180830381600087803b158015611cdb57600080fd5b505af1158015611cef573d6000803e3d6000fd5b5050505060005b8351811015611e1d576000848281518110611d1357611d13614cfa565b602090810291909101810151600081815260039092526040909120600701549091506001600160a01b0316611d8a5760405162461bcd60e51b815260206004820152601560248201527f4e465420494420646f6573206e6f742065786973740000000000000000000000604482015260640161087c565b600081815260036020526040902060070154600160a01b900460ff1615611df35760405162461bcd60e51b815260206004820152601560248201527f4e465420494420616c7265616479206578697374730000000000000000000000604482015260640161087c565b6000908152600360205260409020600701805460ff60a01b1916600160a01b179055600101611cf6565b50505050565b600c8181548110611e3357600080fd5b6000918252602090912001546001600160a01b0316905081565b60008060009054906101000a90046001600160a01b03166001600160a01b0316636e9960c36040518163ffffffff1660e01b8152600401600060405180830381865afa158015611ea1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ec99190810190614d9e565b90506000611ed78233613d7c565b9050600181151514611f255760405162461bcd60e51b8152602060048201526017602482015276466f722061646d696e6973747261746f7273206f6e6c7960481b604482015260640161087c565b611f31600260006144d5565b60005b6003811015611fb45760026040518060400160405280878481518110611f5c57611f5c614cfa565b60200260200101518152602001868481518110611f7b57611f7b614cfa565b60209081029190910181015190915282546001818101855560009485529382902083516002909202019081559101519082015501611f34565b5050505050565b600061201f600b805480602002602001604051908101604052809291908181526020018280548015610825576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161080757505050505033613d7c565b9050801561206f5760405162461bcd60e51b815260206004820152601860248201527f596f75277665206265656e20626c61636b6c69737465642e0000000000000000604482015260640161087c565b600061207a33612b5a565b9050600081116120dd5760405162461bcd60e51b815260206004820152602860248201527f5769746864726177616c20616d6f756e74206d75737420626520677265617465604482015267072207468616e20360c41b606482015260840161087c565b3360009081526007602090815260408083208054825181850281018501909352808352919290919083018282801561213457602002820191906000526020600020905b815481526020019060010190808311612120575b5050505050905060005b81518110156121b7576000429050600083838151811061216057612160614cfa565b60200260200101519050816005600083815260200190815260200160002060020154101561219d5760008181526005602052604090206002015491505b60009081526005602052604090206003015560010161213e565b5060015460405163f3fef3a360e01b81523360048201526024810184905242916001600160a01b03169063f3fef3a390604401600060405180830381600087803b15801561220457600080fd5b505af1158015612218573d6000803e3d6000fd5b5050336000908152600a602090815260408083208151808301909252978152808201958652875460018181018a5598845291909220915160029091029091019081559251929094019190915550505050565b600b8181548110611e3357600080fd5b600080546040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526060939216906370a0823190602401602060405180830381865afa1580156122e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123049190614e38565b905060008167ffffffffffffffff811115612321576123216146a8565b60405190808252806020026020018201604052801561234a578160200160208202803683370190505b50905060005b8281101561240b576000546040517f2f745c590000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301526024820184905290911690632f745c5990604401602060405180830381865afa1580156123c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e69190614e38565b8282815181106123f8576123f8614cfa565b6020908102919091010152600101612350565b509392505050565b6000612477600b805480602002602001604051908101604052809291908181526020018280548015610825576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161080757505050505033613d7c565b905080156124c75760405162461bcd60e51b815260206004820152601860248201527f596f75277665206265656e20626c61636b6c69737465642e0000000000000000604482015260640161087c565b600080546040516331a9108f60e11b8152600481018590526001600160a01b0390911690636352211e90602401602060405180830381865afa158015612511573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125359190614cdd565b90506001600160a01b038116331461258f5760405162461bcd60e51b815260206004820152601c60248201527f596f75277265206e6f74206120636f6e7472616374206f776e65722e00000000604482015260640161087c565b60008381526003602081815260409283902083516101208101855281548152600182015492810192909252600281015493820184905291820154606082015260048201546080820152600582015460a0820152600682015460c08201526007909101546001600160a01b03811660e0830152600160a01b900460ff161515610100820152429182116126635760405162461bcd60e51b815260206004820152601a60248201527f556e6578706972656420506c656467652041677265656d656e74000000000000604482015260640161087c565b6000546040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018790526001600160a01b03909116906323b872dd90606401600060405180830381600087803b1580156126ce57600080fd5b505af11580156126e2573d6000803e3d6000fd5b5050600154608084015160405163f3fef3a360e01b815233600482015260248101919091526001600160a01b03909116925063f3fef3a39150604401600060405180830381600087803b15801561273857600080fd5b505af115801561274c573d6000803e3d6000fd5b5050505060608101918252336000908152600d6020908152604080832080546001818101835591855293839020855160089095020193845591840151918301919091558201516002820155915160038301556080810151600483015560a0810151600583015560c0810151600683015560e081015160079092018054610100909201511515600160a01b0274ffffffffffffffffffffffffffffffffffffffffff199092166001600160a01b039390931692909217179055505050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316636e9960c36040518163ffffffff1660e01b8152600401600060405180830381865afa15801561285d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526128859190810190614d9e565b905060006128938233613d7c565b90506001811515146128e15760405162461bcd60e51b8152602060048201526017602482015276466f722061646d696e6973747261746f7273206f6e6c7960481b604482015260640161087c565b60008451116129325760405162461bcd60e51b815260206004820152601a60248201527f456e746572206174206c65617374206f6e652061646472657373000000000000604482015260640161087c565b826001036129b95760006129a0600b80548060200260200160405190810160405280929190818152602001828054801561299557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612977575b5050505050866141a1565b80519091506129b690600b9060208401906144f9565b50505b82600203611e1d576000612a25600c805480602002602001604051908101604052809291908181526020018280548015612995576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311612977575050505050866141a1565b8051909150612a3b90600c9060208401906144f9565b505050505050565b60086020528160005260406000208181548110612a5f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316636e9960c36040518163ffffffff1660e01b8152600401600060405180830381865afa158015612acf573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612af79190810190614d9e565b90506000612b058233613d7c565b9050600181151514612b535760405162461bcd60e51b8152602060048201526017602482015276466f722061646d696e6973747261746f7273206f6e6c7960481b604482015260640161087c565b5050600e55565b60008080612b67846139df565b905060005b8151811015612bb1576000828281518110612b8957612b89614cfa565b60200260200101519050612b9c81610d46565b612ba69085614d8b565b935050600101612b6c565b50909392505050565b600080612bc68361227a565b90506000815111612bda5750600092915050565b6000805b825181101561240b576000838281518110612bfb57612bfb614cfa565b6020908102919091018101516000818152600380845260409182902082516101208101845281548152600182015495810195909552600281015492850192909252810154606084015260048101546080840152600581015460a0840152600681015460c0840152600701546001600160a01b03811660e0840152600160a01b900460ff1615156101008301529150612c9281610d46565b612c9c9085614d8b565b93505050600101612bde565b6001600160a01b0381166000908152600460209081526040808320805482518185028101850190935280835260609492939192909184018215610e9a57600084815260209081902060408051610120810182526008860290920180548352600180820154848601526002820154928401929092526003810154606084015260048101546080840152600581015460a0840152600681015460c0840152600701546001600160a01b03811660e0840152600160a01b900460ff1615156101008301529083529092019101610e01565b60028181548110612d8657600080fd5b60009182526020909120600290910201805460019091015490915082565b6000612e08600b805480602002602001604051908101604052809291908181526020018280548015610825576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161080757505050505033613d7c565b90508015612e585760405162461bcd60e51b815260206004820152601860248201527f596f75277665206265656e20626c61636b6c69737465642e0000000000000000604482015260640161087c565b33600090815260076020908152604080832080548251818502810185019093528083529192909190830182828015612eaf57602002820191906000526020600020905b815481526020019060010190808311612e9b575b505050505090506000805b8251811015612efb576000838281518110612ed757612ed7614cfa565b60200260200101519050858103612ef2576001925050612efb565b50600101612eba565b50600181151514612f4e5760405162461bcd60e51b815260206004820152601460248201527f49742773206e6f74206120636f6e74726163742e000000000000000000000000604482015260640161087c565b60008481526005602081815260408084208151610120810183528154815260018201549381019390935260028101549183019190915260038101546060830152600481015460808301529182015460a0820152600682015460c08201526007909101546001600160a01b03811660e0830152600160a01b900460ff16151561010082015290612fdc82610d46565b90506000811161303f5760405162461bcd60e51b815260206004820152602860248201527f5769746864726177616c20616d6f756e74206d75737420626520677265617465604482015267072207468616e20360c41b606482015260840161087c565b60408201514290811115613054575060408201515b60015460405163f3fef3a360e01b8152336004820152602481018490526001600160a01b039091169063f3fef3a390604401600060405180830381600087803b1580156130a057600080fd5b505af11580156130b4573d6000803e3d6000fd5b50505060009788525060056020908152604080892060030192909255338852600a8152818820825180840190935292825242828201908152835460018181018655948a529190982091516002909102909101908155955195019490945550505050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316636e9960c36040518163ffffffff1660e01b8152600401600060405180830381865afa15801561316b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526131939190810190614d9e565b905060006131a18233613d7c565b90506001811515146131ef5760405162461bcd60e51b8152602060048201526017602482015276466f722061646d696e6973747261746f7273206f6e6c7960481b604482015260640161087c565b60008451116132405760405162461bcd60e51b815260206004820152601a60248201527f456e746572206174206c65617374206f6e652061646472657373000000000000604482015260640161087c565b826001036132c75760006132ae600b8054806020026020016040519081016040528092919081815260200182805480156132a357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613285575b5050505050866142d3565b80519091506132c490600b9060208401906144f9565b50505b82600203611e1d576000612a25600c8054806020026020016040519081016040528092919081815260200182805480156132a3576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311613285575050505050866142d3565b6007602052816000526040600020818154811061334f57600080fd5b90600052602060002001600091509150505481565b600d602052816000526040600020818154811061338057600080fd5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006870154600790970154959850939650919490939192916001600160a01b03811690600160a01b900460ff1689565b606060006133e88361227a565b9050805167ffffffffffffffff811115613404576134046146a8565b60405190808252806020026020018201604052801561348f57816020015b61347c6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000151581525090565b8152602001906001900390816134225790505b50915060005b8151811015610d3f57600360008383815181106134b4576134b4614cfa565b6020908102919091018101518252818101929092526040908101600020815161012081018352815481526001820154938101939093526002810154918301919091526003810154606083015260048101546080830152600581015460a0830152600681015460c0830152600701546001600160a01b03811660e0830152600160a01b900460ff161515610100820152835184908390811061355757613557614cfa565b6020908102919091010152600101613495565b6135c46040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000151581525090565b8160010361365757506000828152600360208181526040928390208351610120810185528154815260018201549281019290925260028101549382019390935290820154606082015260048201546080820152600582015460a0820152600682015460c08201526007909101546001600160a01b03811660e0830152600160a01b900460ff1615156101008201526136de565b506000828152600560208181526040928390208351610120810185528154815260018201549281019290925260028101549382019390935260038301546060820152600483015460808201529082015460a0820152600682015460c08201526007909101546001600160a01b03811660e0830152600160a01b900460ff1615156101008201525b92915050565b6001600160a01b0381166000908152600960209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610e9a57838290600052602060002090600502016040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820154815250508152602001906001019061371c565b60008060009054906101000a90046001600160a01b03166001600160a01b0316636e9960c36040518163ffffffff1660e01b8152600401600060405180830381865afa1580156137d4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526137fc9190810190614d9e565b9050600061380a8233613d7c565b90506001811515146138585760405162461bcd60e51b8152602060048201526017602482015276466f722061646d696e6973747261746f7273206f6e6c7960481b604482015260640161087c565b60008351116138a95760405162461bcd60e51b815260206004820152601260248201527f506172616d6574657220697320656d7074790000000000000000000000000000604482015260640161087c565b6000546040517fb3988fdf0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063b3988fdf906138f2908690600401614aae565b600060405180830381600087803b15801561390c57600080fd5b505af1158015613920573d6000803e3d6000fd5b5050505060005b8351811015611e1d57600084828151811061394457613944614cfa565b602090810291909101810151600081815260039092526040909120600701549091506001600160a01b03166139bb5760405162461bcd60e51b815260206004820152601560248201527f4e465420494420646f6573206e6f742065786973740000000000000000000000604482015260640161087c565b6000908152600360205260409020600701805460ff60a01b19169055600101613927565b6001600160a01b0381166000908152600760209081526040808320805482518185028101850190935280835260609493830182828015613a3e57602002820191906000526020600020905b815481526020019060010190808311613a2a575b50505050509050805167ffffffffffffffff811115613a5f57613a5f6146a8565b604051908082528060200260200182016040528015613aea57816020015b613ad76040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000151581525090565b815260200190600190039081613a7d5790505b50915060005b8151811015610d3f576000828281518110613b0d57613b0d614cfa565b6020908102919091018101516000818152600580845260409182902082516101208101845281548152600182015495810195909552600281015492850192909252600382015460608501526004820154608085015281015460a0840152600681015460c0840152600701546001600160a01b03811660e0840152600160a01b900460ff1615156101008301528551909250859084908110613bb057613bb0614cfa565b602090810291909101015250600101613af0565b60008060009054906101000a90046001600160a01b03166001600160a01b0316636e9960c36040518163ffffffff1660e01b8152600401600060405180830381865afa158015613c18573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613c409190810190614d9e565b90506000613c4e8233613d7c565b9050600181151514613c9c5760405162461bcd60e51b8152602060048201526017602482015276466f722061646d696e6973747261746f7273206f6e6c7960481b604482015260640161087c565b50506010805460ff1916911515919091179055565b6004602052816000526040600020818154811061338057600080fd5b60606002805480602002602001604051908101604052809291908181526020016000905b82821015613d3757838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190613cf1565b50505050905090565b600a6020528160005260406000208181548110613d5c57600080fd5b600091825260209091206002909102018054600190910154909250905082565b60008060005b845181101561240b57836001600160a01b0316858281518110613da757613da7614cfa565b60200260200101516001600160a01b031603613dc6576001915061240b565b600101613d82565b336000908152600660205260409020546001600160a01b031615613e345760405162461bcd60e51b815260206004820152601960248201527f416c72656164792068617665207265636f6d6d656e6465727300000000000000604482015260640161087c565b6001600160a01b0381163303613e8c5760405162461bcd60e51b815260206004820152601d60248201527f596f752063616e2774207265636f6d6d656e6420796f757273656c662e000000604482015260640161087c565b6001600160a01b0381811660009081526006602052604090206001015433911603613ef95760405162461bcd60e51b815260206004820152601a60248201527f43616e2774207265636f6d6d656e642065616368206f74686572000000000000604482015260640161087c565b60408051608081018252338082526001600160a01b039384166020808401828152428587019081526000606087018181528682526006855288822097518854908b1673ffffffffffffffffffffffffffffffffffffffff1991821617895593516001808a01805492909c1691861691909117909a55915160028801559051600390960195909555918452600881529383208054958601815583529290912090920180549091169091179055565b33600090815260066020526040812060010154600e5460a08401819052608084015160c085015185516001600160a01b039094169486949293929060648361016d613ff18789614d5b565b613ffb9190614d39565b6140059190614d5b565b61400f9190614d39565b33600090815260066020526040812060030180549293508392909190614036908490614d8b565b90915550506001600160a01b038716600090815260076020526040812054900361408d5760408051600080825260208083018085526001600160a01b038c1683526007909152929020905161408b929061456b565b505b6001600160a01b03871660009081526008602052604081205490036140df5760408051600080825260208083018085526001600160a01b038c168352600890915292902090516140dd92906144f9565b505b506001600160a01b03958616600090815260076020818152604080842080546001818101835591865283862001869055948452600580835293819020895181559189015194820194909455928701516002840155606087015160038401556080870151600484015560a08701519183019190915560c0860151600683015560e086015191018054610100909601511515600160a01b0274ffffffffffffffffffffffffffffffffffffffffff1990961691909616179390931790935550505050565b60606000825184516141b39190614d8b565b905060008167ffffffffffffffff8111156141d0576141d06146a8565b6040519080825280602002602001820160405280156141f9578160200160208202803683370190505b5090506000805b86518110156142625786818151811061421b5761421b614cfa565b602002602001015183838151811061423557614235614cfa565b6001600160a01b03909216602092830291909101909101528161425781614d72565b925050600101614200565b5060005b85518110156142c85785818151811061428157614281614cfa565b602002602001015183838151811061429b5761429b614cfa565b6001600160a01b0390921660209283029190910190910152816142bd81614d72565b925050600101614266565b509095945050505050565b60606000835167ffffffffffffffff8111156142f1576142f16146a8565b60405190808252806020026020018201604052801561431a578160200160208202803683370190505b50905060005b83518110156143ba5760005b85518110156143b15784828151811061434757614347614cfa565b60200260200101516001600160a01b031686828151811061436a5761436a614cfa565b60200260200101516001600160a01b0316036143a957600183828151811061439457614394614cfa565b911515602092830291909101909101526143b1565b60010161432c565b50600101614320565b506000805b85518110156143fc578281815181106143da576143da614cfa565b60200260200101516143f457816143f081614d72565b9250505b6001016143bf565b5060008167ffffffffffffffff811115614418576144186146a8565b604051908082528060200260200182016040528015614441578160200160208202803683370190505b5090506000805b87518110156144c95784818151811061446357614463614cfa565b60200260200101516144c15787818151811061448157614481614cfa565b602002602001015183838151811061449b5761449b614cfa565b6001600160a01b0390921660209283029190910190910152816144bd81614d72565b9250505b600101614448565b50909695505050505050565b50805460008255600202906000526020600020908101906144f691906145a6565b50565b82805482825590600052602060002090810192821561455b579160200282015b8281111561455b578251825473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03909116178255602090920191600190910190614519565b506145679291506145c1565b5090565b82805482825590600052602060002090810192821561455b579160200282015b8281111561455b57825182559160200191906001019061458b565b5b8082111561456757600080825560018201556002016145a7565b5b8082111561456757600081556001016145c2565b6000602082840312156145e857600080fd5b5035919050565b6001600160a01b03811681146144f657600080fd5b803561460f816145ef565b919050565b60006020828403121561462657600080fd5b8135614631816145ef565b9392505050565b602080825282518282018190526000919060409081850190868401855b8281101561469b57815180516001600160a01b03908116865287820151168786015285810151868601526060908101519085015260809093019290850190600101614655565b5091979650505050505050565b634e487b7160e01b600052604160045260246000fd5b604051610120810167ffffffffffffffff811182821017156146e2576146e26146a8565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715614711576147116146a8565b604052919050565b8035801515811461460f57600080fd5b6000610120828403121561473c57600080fd5b6147446146be565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015261479060e08401614604565b60e08201526101006147a3818501614719565b908201529392505050565b6020808252825182820181905260009190848201906040850190845b818110156144c95761483d838551805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c08301526001600160a01b0360e08201511660e083015261010080820151151581840152505050565b9284019261012092909201916001016147ca565b602080825282518282018190526000919060409081850190868401855b8281101561469b5761488b84835180518252602090810151910152565b928401929085019060010161486e565b600080604083850312156148ae57600080fd5b82356148b9816145ef565b915060208301356148c9816145ef565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156144c95783516001600160a01b0316835292840192918401916001016148f0565b6000806040838503121561492857600080fd5b8235614933816145ef565b946020939093013593505050565b60008060006060848603121561495657600080fd5b8335925060208401359150604084013561496f816145ef565b809150509250925092565b600067ffffffffffffffff821115614994576149946146a8565b5060051b60200190565b600082601f8301126149af57600080fd5b813560206149c46149bf8361497a565b6146e8565b8083825260208201915060208460051b8701019350868411156149e657600080fd5b602086015b84811015614a0257803583529183019183016149eb565b509695505050505050565b600060208284031215614a1f57600080fd5b813567ffffffffffffffff811115614a3657600080fd5b614a428482850161499e565b949350505050565b60008060408385031215614a5d57600080fd5b823567ffffffffffffffff80821115614a7557600080fd5b614a818683870161499e565b93506020850135915080821115614a9757600080fd5b50614aa48582860161499e565b9150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156144c957835183529284019291840191600101614aca565b60008060408385031215614af957600080fd5b823567ffffffffffffffff811115614b1057600080fd5b8301601f81018513614b2157600080fd5b80356020614b316149bf8361497a565b82815260059290921b83018101918181019088841115614b5057600080fd5b938201935b83851015614b77578435614b68816145ef565b82529382019390820190614b55565b98969091013596505050505050565b60008060408385031215614b9957600080fd5b50508035926020909101359150565b61012081016136de8284805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c08301526001600160a01b0360e08201511660e083015261010080820151151581840152505050565b602080825282518282018190526000919060409081850190868401855b8281101561469b5781518051855286810151878601528581015186860152606080820151908601526080908101519085015260a09093019290850190600101614c34565b600060208284031215614c8a57600080fd5b61463182614719565b602080825282518282018190526000919060409081850190868401855b8281101561469b57614ccd84835180518252602090810151910152565b9284019290850190600101614cb0565b600060208284031215614cef57600080fd5b8151614631816145ef565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156136de576136de614d10565b600082614d5657634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176136de576136de614d10565b600060018201614d8457614d84614d10565b5060010190565b808201808211156136de576136de614d10565b60006020808385031215614db157600080fd5b825167ffffffffffffffff811115614dc857600080fd5b8301601f81018513614dd957600080fd5b8051614de76149bf8261497a565b81815260059190911b82018301908381019087831115614e0657600080fd5b928401925b82841015614e2d578351614e1e816145ef565b82529284019290840190614e0b565b979650505050505050565b600060208284031215614e4a57600080fd5b505191905056fea26469706673582212207c7571ecaf108170ced6f01d7abdb2c5e715cd49607015b6abc0e96ef79dd5a564736f6c63430008180033"; + +type PledgeConstructorParams = + | [signer?: Signer] + | ConstructorParameters; + +const isSuperArgs = ( + xs: PledgeConstructorParams +): xs is ConstructorParameters => xs.length > 1; + +export class Pledge__factory extends ContractFactory { + constructor(...args: PledgeConstructorParams) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi, _bytecode, args[0]); + } + } + + override getDeployTransaction( + overrides?: NonPayableOverrides & { from?: string } + ): Promise { + return super.getDeployTransaction(overrides || {}); + } + override deploy(overrides?: NonPayableOverrides & { from?: string }) { + return super.deploy(overrides || {}) as Promise< + Pledge & { + deploymentTransaction(): ContractTransactionResponse; + } + >; + } + override connect(runner: ContractRunner | null): Pledge__factory { + return super.connect(runner) as Pledge__factory; + } + + static readonly bytecode = _bytecode; + static readonly abi = _abi; + static createInterface(): PledgeInterface { + return new Interface(_abi) as PledgeInterface; + } + static connect(address: string, runner?: ContractRunner | null): Pledge { + return new Contract(address, _abi, runner) as unknown as Pledge; + } +} diff --git a/src/contract/typechain-types/factories/contracts/Pool__factory.ts b/src/contract/typechain-types/factories/contracts/Pool__factory.ts new file mode 100644 index 0000000..c0432f7 --- /dev/null +++ b/src/contract/typechain-types/factories/contracts/Pool__factory.ts @@ -0,0 +1,203 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { + Contract, + ContractFactory, + ContractTransactionResponse, + Interface, +} from "ethers"; +import type { Signer, ContractDeployTransaction, ContractRunner } from "ethers"; +import type { NonPayableOverrides } from "../../common"; +import type { Pool, PoolInterface } from "../../contracts/Pool"; + +const _abi = [ + { + inputs: [], + name: "InvalidInitialization", + type: "error", + }, + { + inputs: [], + name: "NotInitializing", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint64", + name: "version", + type: "uint64", + }, + ], + name: "Initialized", + type: "event", + }, + { + inputs: [], + name: "_pledgeContractAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "deposit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "tokenAddress", + type: "address", + }, + { + internalType: "address", + name: "nftAddress", + type: "address", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "poolStatus", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "addr", + type: "address", + }, + ], + name: "setPledgeContractAddress", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bool", + name: "_status", + type: "bool", + }, + ], + name: "setPoolStatus", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "withdraw", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "withdrawTo", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +const _bytecode = + "0x608060405234801561001057600080fd5b50610ae4806100206000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806393bc96fa1161005b57806393bc96fa146100f8578063cf3df2301461010b578063f02286921461011e578063f3fef3a31461014257600080fd5b806305217c151461008d57806310b927ca146100a257806347e7ef24146100d2578063485cc955146100e5575b600080fd5b6100a061009b3660046108bc565b610155565b005b6002546100b5906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6100a06100e03660046108f5565b610268565b6100a06100f3366004610921565b61037a565b6100a061010636600461095a565b6104ec565b6100a0610119366004610973565b61063a565b60025461013290600160a01b900460ff1681565b60405190151581526020016100c9565b6100a06101503660046108f5565b61073e565b60015460408051636e9960c360e01b815290516000926001600160a01b031691636e9960c391600480830192869291908290030181865afa15801561019e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526101c691908101906109b6565b905060006101d48233610851565b905060018115151461022d5760405162461bcd60e51b815260206004820152601760248201527f466f722061646d696e6973747261746f7273206f6e6c7900000000000000000060448201526064015b60405180910390fd5b505060028054911515600160a01b027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b600081116102de5760405162461bcd60e51b815260206004820152602560248201527f4465706f73697420616d6f756e74206d7573742062652067726561746572207460448201527f68616e20300000000000000000000000000000000000000000000000000000006064820152608401610224565b6000546040517f23b872dd0000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015230602483015260448201849052909116906323b872dd906064015b6020604051808303816000875af1158015610351573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103759190610a7b565b505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156103c55750825b905060008267ffffffffffffffff1660011480156103e25750303b155b9050811580156103f0575080155b15610427576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561045b57845468ff00000000000000001916680100000000000000001785555b600080546001600160a01b03808a1673ffffffffffffffffffffffffffffffffffffffff1992831617909255600180549289169290911691909117905583156104e357845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b60015460408051636e9960c360e01b815290516000926001600160a01b031691636e9960c391600480830192869291908290030181865afa158015610535573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261055d91908101906109b6565b9050600061056b8233610851565b90506001811515146105bf5760405162461bcd60e51b815260206004820152601760248201527f466f722061646d696e6973747261746f7273206f6e6c790000000000000000006044820152606401610224565b60005460405163a9059cbb60e01b8152336004820152602481018590526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015610610573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106349190610a7b565b50505050565b60015460408051636e9960c360e01b815290516000926001600160a01b031691636e9960c391600480830192869291908290030181865afa158015610683573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106ab91908101906109b6565b905060006106b98233610851565b905060018115151461070d5760405162461bcd60e51b815260206004820152601760248201527f466f722061646d696e6973747261746f7273206f6e6c790000000000000000006044820152606401610224565b50506002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600254600160a01b900460ff16156107985760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c20636f6e74726163742073746174757320697320636c6f73656400006044820152606401610224565b6002546001600160a01b031633146108185760405162461bcd60e51b815260206004820152602d60248201527f4d7573742062652075736564206173206120636c6175736520696e206120706c60448201527f6564676520636f6e7472616374000000000000000000000000000000000000006064820152608401610224565b60005460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb90604401610332565b60008060005b84518110156108a357836001600160a01b031685828151811061087c5761087c610a98565b60200260200101516001600160a01b03160361089b57600191506108a3565b600101610857565b509392505050565b80151581146108b957600080fd5b50565b6000602082840312156108ce57600080fd5b81356108d9816108ab565b9392505050565b6001600160a01b03811681146108b957600080fd5b6000806040838503121561090857600080fd5b8235610913816108e0565b946020939093013593505050565b6000806040838503121561093457600080fd5b823561093f816108e0565b9150602083013561094f816108e0565b809150509250929050565b60006020828403121561096c57600080fd5b5035919050565b60006020828403121561098557600080fd5b81356108d9816108e0565b634e487b7160e01b600052604160045260246000fd5b80516109b1816108e0565b919050565b600060208083850312156109c957600080fd5b825167ffffffffffffffff808211156109e157600080fd5b818501915085601f8301126109f557600080fd5b815181811115610a0757610a07610990565b8060051b604051601f19603f83011681018181108582111715610a2c57610a2c610990565b604052918252848201925083810185019188831115610a4a57600080fd5b938501935b82851015610a6f57610a60856109a6565b84529385019392850192610a4f565b98975050505050505050565b600060208284031215610a8d57600080fd5b81516108d9816108ab565b634e487b7160e01b600052603260045260246000fdfea2646970667358221220504c88590109157b4a48217972540f347382145a002bf03dce8de06b0ee811b564736f6c63430008180033"; + +type PoolConstructorParams = + | [signer?: Signer] + | ConstructorParameters; + +const isSuperArgs = ( + xs: PoolConstructorParams +): xs is ConstructorParameters => xs.length > 1; + +export class Pool__factory extends ContractFactory { + constructor(...args: PoolConstructorParams) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi, _bytecode, args[0]); + } + } + + override getDeployTransaction( + overrides?: NonPayableOverrides & { from?: string } + ): Promise { + return super.getDeployTransaction(overrides || {}); + } + override deploy(overrides?: NonPayableOverrides & { from?: string }) { + return super.deploy(overrides || {}) as Promise< + Pool & { + deploymentTransaction(): ContractTransactionResponse; + } + >; + } + override connect(runner: ContractRunner | null): Pool__factory { + return super.connect(runner) as Pool__factory; + } + + static readonly bytecode = _bytecode; + static readonly abi = _abi; + static createInterface(): PoolInterface { + return new Interface(_abi) as PoolInterface; + } + static connect(address: string, runner?: ContractRunner | null): Pool { + return new Contract(address, _abi, runner) as unknown as Pool; + } +} diff --git a/src/contract/typechain-types/factories/contracts/index.ts b/src/contract/typechain-types/factories/contracts/index.ts new file mode 100644 index 0000000..61c65b4 --- /dev/null +++ b/src/contract/typechain-types/factories/contracts/index.ts @@ -0,0 +1,7 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { FIL__factory } from "./FIL__factory"; +export { NFT__factory } from "./NFT__factory"; +export { Pledge__factory } from "./Pledge__factory"; +export { Pool__factory } from "./Pool__factory"; diff --git a/src/contract/typechain-types/factories/index.ts b/src/contract/typechain-types/factories/index.ts new file mode 100644 index 0000000..6397da0 --- /dev/null +++ b/src/contract/typechain-types/factories/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export * as contracts from "./contracts"; diff --git a/src/contract/typechain-types/hardhat.d.ts b/src/contract/typechain-types/hardhat.d.ts new file mode 100644 index 0000000..fed74bd --- /dev/null +++ b/src/contract/typechain-types/hardhat.d.ts @@ -0,0 +1,441 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { ethers } from "ethers"; +import { + DeployContractOptions, + FactoryOptions, + HardhatEthersHelpers as HardhatEthersHelpersBase, +} from "@nomicfoundation/hardhat-ethers/types"; + +import * as Contracts from "."; + +declare module "hardhat/types/runtime" { + interface HardhatEthersHelpers extends HardhatEthersHelpersBase { + getContractFactory( + name: "Initializable", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC1155Errors", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC20Errors", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC721Errors", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "ERC20", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "ERC20Burnable", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC20Metadata", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC20", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "ERC721", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "ERC721Enumerable", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC721Enumerable", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC721Metadata", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC721", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC721Receiver", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "ERC165", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IERC165", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "Math", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "Strings", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "FIL", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "NFT", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "Pledge", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "Pool", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + + getContractAt( + name: "Initializable", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC1155Errors", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC20Errors", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC721Errors", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "ERC20", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "ERC20Burnable", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC20Metadata", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC20", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "ERC721", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "ERC721Enumerable", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC721Enumerable", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC721Metadata", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC721", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC721Receiver", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "ERC165", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IERC165", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "Math", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "Strings", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "FIL", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "NFT", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "Pledge", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "Pool", + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + + deployContract( + name: "Initializable", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC1155Errors", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC20Errors", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721Errors", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC20", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC20Burnable", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC20Metadata", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC20", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC721", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC721Enumerable", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721Enumerable", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721Metadata", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721Receiver", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC165", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC165", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "Math", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "Strings", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "FIL", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "NFT", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "Pledge", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "Pool", + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + + deployContract( + name: "Initializable", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC1155Errors", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC20Errors", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721Errors", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC20", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC20Burnable", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC20Metadata", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC20", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC721", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC721Enumerable", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721Enumerable", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721Metadata", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC721Receiver", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "ERC165", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "IERC165", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "Math", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "Strings", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "FIL", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "NFT", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "Pledge", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: "Pool", + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + + // default types + getContractFactory( + name: string, + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + abi: any[], + bytecode: ethers.BytesLike, + signer?: ethers.Signer + ): Promise; + getContractAt( + nameOrAbi: string | any[], + address: string | ethers.Addressable, + signer?: ethers.Signer + ): Promise; + deployContract( + name: string, + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + deployContract( + name: string, + args: any[], + signerOrOptions?: ethers.Signer | DeployContractOptions + ): Promise; + } +} diff --git a/src/contract/typechain-types/index.ts b/src/contract/typechain-types/index.ts new file mode 100644 index 0000000..f6d242c --- /dev/null +++ b/src/contract/typechain-types/index.ts @@ -0,0 +1,14 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type * as contracts from "./contracts"; +export type { contracts }; +export * as factories from "./factories"; +export type { FIL } from "./contracts/FIL"; +export { FIL__factory } from "./factories/contracts/FIL__factory"; +export type { NFT } from "./contracts/NFT"; +export { NFT__factory } from "./factories/contracts/NFT__factory"; +export type { Pledge } from "./contracts/Pledge"; +export { Pledge__factory } from "./factories/contracts/Pledge__factory"; +export type { Pool } from "./contracts/Pool"; +export { Pool__factory } from "./factories/contracts/Pool__factory"; diff --git a/src/global.d.ts b/src/global.d.ts new file mode 100644 index 0000000..3346303 --- /dev/null +++ b/src/global.d.ts @@ -0,0 +1,3 @@ +interface Window { + ethereum?: any; +} \ No newline at end of file diff --git a/src/hooks/useConnectWallet.ts b/src/hooks/useConnectWallet.ts new file mode 100644 index 0000000..c6f912a --- /dev/null +++ b/src/hooks/useConnectWallet.ts @@ -0,0 +1,40 @@ +import $store from "../store"; + +export default function useConnectWallet() { + const connect = async () => { + try { + if (!(window as any).ethereum) { + window.location.reload(); + return; + } + let res = await (window as any).ethereum.request({ + method: "eth_requestAccounts", + }); + + if (res.length <= 0) { + $store.removeAddr(); + return; + } + + $store.setAddress(res[0]); + } catch (error) {} + }; + + const getWallet = async () => { + let res = [] as string[]; + if (!(window as any).ethereum) { + return res; + } + res = await (window as any).ethereum.request({ + method: "eth_accounts", + }); + if (res.length <= 0) { + $store.removeAddr(); + } else { + $store.setAddress(res[0]); + } + return res; + }; + + return { connect, getWallet }; +} diff --git a/src/hooks/useCopy.ts b/src/hooks/useCopy.ts new file mode 100644 index 0000000..0624528 --- /dev/null +++ b/src/hooks/useCopy.ts @@ -0,0 +1,15 @@ +import { Toast } from 'react-vant'; +import { copy } from "../utils/copy"; + +const useCopyLink = () => { + + const copyVal = (address: any) => { + copy(address, () => { + Toast.success('Copy Success'); + }) + }; + + return { copyVal } +}; + +export default useCopyLink; \ No newline at end of file diff --git a/src/hooks/useRouter.ts b/src/hooks/useRouter.ts new file mode 100644 index 0000000..6eef4ef --- /dev/null +++ b/src/hooks/useRouter.ts @@ -0,0 +1,13 @@ +import { useLocation, useNavigate } from "react-router-dom"; +import store from "~/store"; + +export const useRouter = () => { + const navigate = useNavigate(); + const location = useLocation(); + + const push = (path: any, state?: any, replace?: boolean) => { + navigate(path, { state, replace: replace || false }); + }; + + return { push, location }; +}; diff --git a/src/index.tsx b/src/index.tsx new file mode 100644 index 0000000..edb6910 --- /dev/null +++ b/src/index.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import App from './App'; +import '~/styles/global.scss' +import { initContract } from './contract'; +import './language' +// import Vconsole from 'vconsole'; +// new Vconsole() + +const root = ReactDOM.createRoot( + document.getElementById('root') as HTMLElement +); + +(async () => { + await initContract() + + root.render( + // + + // + ) +})() \ No newline at end of file diff --git a/src/language/en.json b/src/language/en.json new file mode 100644 index 0000000..7f807c3 --- /dev/null +++ b/src/language/en.json @@ -0,0 +1,14 @@ +{ + "FAQ1":"Making your Filecoin holdings to work for you by generating staking rewards while contributing to the security and efficiency of Filecoin. Filecoin has evolved from a blockchain only serves data storage validation to decentralized application enablement by launching Filecoin virtual machine (FVM), which trigger a greater market potential and growth.", + "FAQ2":"NFT is an on-chain staking certificate on SOFIL platform. The one who hold the NFT can withdraw daily rewards before the end of staking period and redeem the staked amount after the staking period.You can keep the NFT in your wallet for rewards and staking amount redemption. If you need liquidity before the end of staking period, you can also sell it or collaterize it to borrow in the open market. Please be aware that if you have transferred your NFT to others, although you are the one who created the staking, you would not be able to withdraw rewards or withdraw the staked amount anymore. The right to withdraw rewards and redeem the staked amount belongs to the NFT holder. ", + "FAQ3":"All staking rewards distributed from SOFIL platform generated from mining rewards, rather than from other external platforms. Filecoin mining is operated by SOFIL strategic partners.", + + + "Earn FILs Against Your FILs":"Earn FILs \n Against Your FILs", + "pledge-desc":"Enter the referral code of your referrer (if any). SOFIL will provide additional rewards to the referrer. The referral rewards will not be deducted from your staking rewards.", + + "Accumulative Stake":"Accumulative\nStake", + "Accumulative Rewards Withdraw":"Accumulative Rewards\nWithdraw", + "unstake-desc":"By clicking ‘Confirm’ below, you would burn your NFT and redeem all the staked amount. You would not be able to withdraw rewards from this contract anymore, please make sure you have withdrawn all the rewards produced from this staking contract." + +} \ No newline at end of file diff --git a/src/language/hk.json b/src/language/hk.json new file mode 100644 index 0000000..1660702 --- /dev/null +++ b/src/language/hk.json @@ -0,0 +1,131 @@ +{ + "Connect Wallet": "連接錢包", + "Log out": "登出錢包", + "Wallet": "錢包", + "Balance": "餘額", + "SOFIL Staking Contract": "SOFIL質押合約", + "Staking Amount": "質押合約數量", + "My Staking": "我的質押", + "My Referral": "我的推薦", + "Connect your wallet to view more details":"連接你的錢包以查看更多詳細信息", + "Please add BSC node to your wallet":"請在錢包添加幣安節點", + + "Please visit in DApp Browser": "請在DApp瀏覽器中訪問", + "Please switch to BSC network": "請切換至BSC網絡", + "Basic Staking": "基本質押", + "Support & Resources": "支持與資源", + "Language": "語言", + "Join Us on Telegram": "在Telegram上加入我們", + "Follow Us on Twitter": "在Twitter上加入我們", + "Follow Us on LinkedIn": "在LinkedIn上加入我們", + "Terms of Services": "條款細則", + "Privacy Policy": "私隱條款", + "Copyright © 2024 SOFIL. All Rights Reserved.": "Copyright © 2024 SOFIL. All Rights Reserved.", + "warnings": "警告", + "SOFIL currently supports the Smart Chain (BSC).": "SOFIL 目前支持幣安智能鏈 (BSC)", + "Connect BSC": "连接BSC", + "Your wallet is running on an unsupported network": "您的錢包運行在不支持的网络上", + + "STAKE TO EARN":"質押賺幣", + "Get Started":"開始質押", + "Days":"天", + "Annualized Percentage Rate (APR)":"年收益率", + "Upcoming Soon":"即將推出", + "Flexible Staking Subscription":"活期質押産品", + "90 Days Staking Subscriptiong":"90天鎖定期質押産品", + "How It Works":"如何運作", + "Refer To Earn":"接收質押NFT", + "Up To 7% of Referees Staking Rewards":"高達質押人賺取的 7%", + "By sharing your referral code and introducing your friends to SOFIL and stake, you can earn referral rewards and withdraw everyday.":"透過分享您的推薦碼並向您的朋友介紹 SOFIL 並成功質押,您會獲得能每天提取的推薦獎勵。", + "FAQs":"常見問題", + "Learn More":"了解更多", + "Locked":"鎖定期", + "Why should I stake Filecoin?":"問題一:為什麼我要質押 FIL?", + "FAQ1":"透過質押FIL產生質押獎勵,讓你持有的 FIL 為您賺取,同時為 Filecoin 的安全性和效率做出貢獻。Filecoin已經從僅提供資料儲存驗證的區塊鏈發展到透過推出Filecoin虛擬機來實現去中心化應用,從而引發更大的市潛力和成長。", + "What can I do with the NFT after receiving it?":"問題二:質押後獲得的NFT可以用來做什麼?", + "FAQ2":"NNFT是SOFIL平台上的鏈上質押通證。 持有NFT的人可以在質押期結束前提取每日收益,並在質押期結束後贖回質押金。你可以把NFT保存在錢包中,用於每日收益提取和質押金的兌現。 如果你在質押期結束前需要流動性,也可以將其出售或在公開市場上抵押借款。請注意,如果你把NFT轉讓給他人,儘管你是質押的發起者,但你把無法再提取收益或兌現質押金金額,提取和兌現的權歸於NFT持有人。", + "Where do my reward from staking come from?":"問題三:我的質押收益從哪裡來?", + "FAQ3":"所有收益均來自Filecoin挖礦獎勵,而非其他外部平台,Filecoin挖礦由SOFIL策略夥伴營運。", + + "1. Stake":"1. 質押", + "Choose a staking plan":"選擇一個質押産品", + "2. Receive NFT":"2. 接收質押NFT ", + "NFT as a stake certificate to withdraw daily staking rewards":"持有質押NFT作為鏈上質押憑証,每天提取質押獎勵", + "3. Maturity":"3. 質押到期", + "Holding NFT can redeem all staking amount":"H持有質押NFT可兌回本金和所有未提取的質押獎勵", + "Flexible": "活期", + + "Enter a staking amount":"輸入質押數量", + "Earn FILs Against Your FILs":"賺取FIL\n 質押你的FIL", + "Available Balance":"可用結餘", + "Choose a staking period":"選擇一個質押期", + "Est.APR":"年收益率", + "Max":"最大", + "Review and Confirm":"撮要及確認", + "Staking Period":"質押期", + "Est. Rewards":"預計收益總額", + "Est. Total Receivable":"預計應收總額", + "STAKE":"質押", + "By clicking Stake,you agree to SOFIL Terms of Services and Privacy Policy":"*點擊質押表示你同意SOFIL平台的服務條款及隱私條款", + "Enter a Referral Code (if any)":"輸入推薦碼 (如有)", + "pledge-desc":"輸入推薦人的推薦代碼(如果有)。 SOFIL將為判定提供額外獎勵 推薦獎勵不會從您的收入中扣除", + "You can enter or leave it blank":"您可以輸入或留空", + "CONFIRM":"確認", + + "Staking Details":"質押總覽", + "SOFIL NFTs represent the staking contracts you hold":"你持有的 SOFIL NFT代表你持有的質押合約", + "Staking Contracts":"質押合約", + "Withdrawable Rewards":"可提取收益", + "Transactions":"交易明細", + "Staked Balance":"已質押的額度", + "WITHDRAW":"提取", + "No. of Staking Contracts":"持有的質押合約", + "Contract(NFT)":"合約NFT", + "Withdrawable":"可提取總額", + "Maturity Date":"到期日", + "Status":"狀態", + "Active":"未到期", + "Matured":"已到期", + "Closed":"已關閉", + "No records":"暫無記錄", + "Accumulative Stake":"總質押", + "Accumulative Rewards Withdraw":"總提取收益", + "Withdraw":"質押", + "Stake":"提取", + "Create Contract(NFT)":"創建合約(NFT)", + "Contract Address":"合約地址", + "Copy Success":"複製成功", + "merge and extract":"合并提取", + + "Contract (NFT) Details": "合約(NFT)明細", + "NFT Details": "NFT明細", + "Contract No. (NFT ID)": "合約號碼(NFT ID", + "NFT Standard": "NFT格式", + "Contract Details": "合約明細", + "Contract Type": "合約類別", + "Staked Amount": "質押數量", + "Est. APR": "預計年收益率", + "Created Time": "創建時間", + "Maturity Time": "到期時間", + "Rewards & Withdrawals Details": "收益及提取明細", + "Rewards Start Time": "收益開始時間", + "Rewards Distributed": "已發放收益", + "Rewards Withdrawn": "已提取收益", + "Withdrawable Amount": "可提取收益", + "UNSTAKE": "解除質押", + "unstake-desc": "點擊下面的“確認”,您將銷毀您的 合約NFT 並兌回所有已質押的幣。 您將無法再從該合約中提取收益,請確保您已提取該合約產生的所有收益。", + "Referral Rewards": "推薦獎勵", + "Introduce your friends to stake and earn": "透過推薦碼推薦用戶進行質押並賺取 FIL", + "Your Referral Code": "你的推薦碼", + "SHARE": "分享", + "Referred Users": "已推薦的用户數量", + "Active Contracts": "未到期合約", + "Referred": "推薦", + "Share your referral code to earn rewards": "立刻分享你的推薦碼,獲取推薦獎勵", + "Addresses": "錢包地址", + "Contributed": "獎勵貢獻", + "Binding Time": "綁定時間", + "Contreact(Rewards) Details": "合約(奖励)明細", + "Days Staking": "天質押", + "Rewards Details": "收益及提取明細" +} \ No newline at end of file diff --git a/src/language/index.ts b/src/language/index.ts new file mode 100644 index 0000000..f845cf4 --- /dev/null +++ b/src/language/index.ts @@ -0,0 +1,29 @@ +import en from "./en.json"; +import zh from "./zh.json"; +import hk from "./hk.json"; +import i18n from "i18next"; +import { initReactI18next } from "react-i18next"; + +export const SOFIL_LANGUAGE = "SOFIL_LANGUAGE"; + +const resources = { + en: { + translation: { ...en }, + }, + zh: { + translation: { ...zh }, + }, + hk: { + translation: { ...hk }, + }, +}; + +i18n.use(initReactI18next).init({ + resources, + lng: window.sessionStorage.getItem(SOFIL_LANGUAGE) || "hk", + interpolation: { + escapeValue: false, + }, +}); + +export default i18n; diff --git a/src/language/zh.json b/src/language/zh.json new file mode 100644 index 0000000..73d4e7f --- /dev/null +++ b/src/language/zh.json @@ -0,0 +1,131 @@ +{ + "Connect Wallet": "连接钱包", + "Log out": "登出钱包", + "Wallet": "钱包", + "Balance": "余额", + "SOFIL Staking Contract": "SOFIL质押合约", + "Staking Amount": "质押合约数量", + "My Staking": "我的质押", + "My Referral": "我的推荐", + "Connect your wallet to view more details": "连接你的钱包以查看更多详细信息", + "Please add BSC node to your wallet": "请在钱包添加币安节点", + + "Please visit in DApp Browser": "请在DApp浏览器中访问", + "Please switch to BSC network": "请切换至BSC网络", + "Basic Staking": "基本质押", + "Support & Resources": "支持与资源", + "Language": "语言", + "Join Us on Telegram": "在Telegram上加入我们", + "Follow Us on Twitter": "在Twitter上加入我们", + "Follow Us on LinkedIn": "在LinkedIn上加入我们", + "Terms of Services": "条款细则", + "Privacy Policy": "隐私条款", + "Copyright © 2024 SOFIL. All Rights Reserved.": "Copyright © 2024 SOFIL. All Rights Reserved.", + "warnings": "警告", + "SOFIL currently supports the Smart Chain (BSC).": "SOFIL 目前支持币安智能链 (BSC)", + "Connect BSC": "连接BSC", + "Your wallet is running on an unsupported network": "您的钱包运行在不支持的网络上", + + "STAKE TO EARN": "质押赚币", + "Get Started": "开始质押", + "Days": "天", + "Annualized Percentage Rate (APR)": "年收益率", + "Upcoming Soon": "即将推出", + "Flexible Staking Subscription": "活期质押产品", + "90 Days Staking Subscriptiong": "90天锁定期质押产品", + "How It Works": "如何运作", + "Refer To Earn": "接收质押NFT", + "Up To 7% of Referees Staking Rewards": "高达质押人赚取的 7%", + "By sharing your referral code and introducing your friends to SOFIL and stake, you can earn referral rewards and withdraw everyday.": "通过分享您的推荐码并向您的朋友介绍 SOFIL 并成功质押,您会获得能每天提取的推荐奖励。", + "FAQs": "常见问题", + "Learn More": "了解更多", + "Locked": "锁定期", + "Why should I stake Filecoin?": "问题一:为什么我要质押 FIL?", + "FAQ1": "通过质押 FIL 产生质押奖励,让你持有的 FIL 为您赚取,同时为 Filecoin 的安全性和效率做出贡献。Filecoin已经从仅提供数据储存验证的区块链发展到通过推出 Filecoin 虚拟机来实现去中心化应用,从而引发更大的市潜力和成长。", + "What can I do with the NFT after receiving it?": "问题二:质押后获得的NFT可以用来做什么?", + "FAQ2": "NFT是 SOFIL 平台上的链上质押通证。持有 NFT 的人可以在质押期结束前提取每日收益,并在质押期结束后赎回质押金。你可以把 NFT 保存在钱包中,用于每日收益提取和质押金的兑现。如果你在质押期结束前需要流动性,也可以将其出售或在公开市场上抵押借款。请注意,如果你把 NFT 转让给他人,尽管你是质押的发起者,但你把无法再提取收益或兑现质押金金额,提取和兑现的权归于 NFT 持有人。", + "Where do my reward from staking come from?": "问题三:我的质押收益从哪里来?", + "FAQ3": "所有收益均来自 Filecoin 挖矿奖励,而非其他外部平台,Filecoin 挖矿由 SOFIL 策略夥伴运营。", + + "1. Stake": "1. 质押", + "Choose a staking plan": "选择一个质押产品", + "2. Receive NFT": "2. 接收质押NFT ", + "NFT as a stake certificate to withdraw daily staking rewards": "持有质押NFT作为链上质押凭证,每天提取质押奖励", + "3. Maturity": "3. 质押到期", + "Holding NFT can redeem all staking amount": "持有质押NFT可兑回本金和所有未提取的质押奖励", + "Flexible": "活期", + + "Enter a staking amount": "输入质押数量", + "Earn FILs Against Your FILs": "赚取FIL\n 质押你的FIL", + "Available Balance": "可用余额", + "Choose a staking period": "选择一个质押期", + "Est.APR": "预计年收益率", + "Max": "最大", + "Review and Confirm": "撮要及确认", + "Staking Period": "质押期", + "Est. Rewards": "预计收益总额", + "Est. Total Receivable": "预计应收总额", + "STAKE": "质押", + "By clicking Stake,you agree to SOFIL Terms of Services and Privacy Policy": "*点击质押表示你同意 SOFIL 平台的服务条款及隐私条款", + "Enter a Referral Code (if any)": "输入推荐码 (如有)", + "pledge-desc": "输入推荐人的推荐代码(如果有)。 SOFIL 将为判定提供额外奖励 推荐奖励不会从您的收入中扣除", + "You can enter or leave it blank": "您可以输入或留空", + "CONFIRM": "确认", + + "Staking Details": "质押总览", + "SOFIL NFTs represent the staking contracts you hold": "你持有的 SOFIL NFT 代表你持有的质押合约", + "Staking Contracts": "质押合约", + "Withdrawable Rewards": "可提取收益", + "Transactions": "交易明细", + "Staked Balance": "已质押的额度", + "WITHDRAW": "提取", + "No. of Staking Contracts": "持有的质押合约", + "Contract(NFT)": "合约NFT", + "Withdrawable": "可提取总额", + "Maturity Date": "到期日", + "Status": "状态", + "Active": "未到期", + "Matured": "已到期", + "Closed": "已关闭", + "No records": "暂无记录", + "Accumulative Stake": "总质押", + "Accumulative Rewards Withdraw": "总提取收益", + "Withdraw": "质押", + "Stake": "提取", + "Create Contract(NFT)": "创建合约(NFT)", + "Contract Address": "合约地址", + "Copy Success": "复制成功", + "merge and extract": "合并提取", + + "Contract (NFT) Details": "合约(NFT)明细", + "NFT Details": "NFT明细", + "Contract No. (NFT ID)": "合约号码(NFT ID", + "NFT Standard": "NFT格式", + "Contract Details": "合约明细", + "Contract Type": "合约类别", + "Staked Amount": "质押数量", + "Est. APR": "预计年收益率", + "Created Time": "创建时间", + "Maturity Time": "到期时间", + "Rewards & Withdrawals Details": "收益及提取明细", + "Rewards Start Time": "收益开始时间", + "Rewards Distributed": "已发放收益", + "Rewards Withdrawn": "已提取收益", + "Withdrawable Amount": "可提取收益", + "UNSTAKE": "解除质押", + "unstake-desc": "点击下面的“确认”,您将销毁您的 合约NFT 并兑回所有已质押的币。 您将无法再从该合约中提取收益,请确保您已提取该合约产生的所有收益。", + "Referral Rewards": "推荐奖励", + "Introduce your friends to stake and earn": "通过推荐码推荐用户进行质押并赚取 FIL", + "Your Referral Code": "你的推荐码", + "SHARE": "分享", + "Referred Users": "已推荐的用户数量", + "Active Contracts": "未到期合约", + "Referred": "推荐", + "Share your referral code to earn rewards": "立刻分享你的推荐码,获取推荐奖励", + "Addresses": "钱包地址", + "Contributed": "奖励贡献", + "Binding Time": "绑定时间", + "Contreact(Rewards) Details": "合约(奖励)明细", + "Days Staking": "天质押", + "Rewards Details": "收益及提取明细" +} diff --git a/src/pages/admin/AdminNFT.tsx b/src/pages/admin/AdminNFT.tsx new file mode 100644 index 0000000..18d723b --- /dev/null +++ b/src/pages/admin/AdminNFT.tsx @@ -0,0 +1,114 @@ +import { observer } from "mobx-react" +import { useEffect, useRef, useState } from "react" +import { Input, TextAreaInstance, Toast } from "react-vant" +import Button from "~/components/Button" +import store from "~/store" +import '~/styles/admin.scss' +import { toBigInt } from "~/utils/wei" + +const AdminNFT = () => { + + const { walletAddress, contract } = store.state + const { NFT__factory, Pledge__factory } = contract._contract + const [nftBlacks, setNFTBlacks] = useState([] as number[]) + const blackRefs = useRef(null); + const [chooseIds, setChooseIds] = useState([] as number[]) + + const [blackLoading, setBlackLoading] = useState(false) + const [rmBlackLoading, setRmBlackLoading] = useState(false) + + const getBlacks = async () => { + const res = await NFT__factory.getBlacks() + const _ids = res.map(v => Number(v.toString(10))) + setNFTBlacks(_ids) + } + + const handleChooseIds = (_id: number) => { + let index = chooseIds.indexOf(_id) + if (index < 0) { + chooseIds.push(_id) + } else { + chooseIds.splice(index, 1) + } + setChooseIds([...chooseIds]) + } + + const addBlacks = async () => { + try { + const dom = blackRefs.current!.nativeElement + const value = dom?.value; + if (!value) return Toast.info('輸入NFT ID') + const _ids = value.split(',') + const _tokenIds = _ids.map(v => toBigInt(v)) + setBlackLoading(true) + const res = await Pledge__factory.addNftBalcks(_tokenIds); + const tx = await res.wait() + setBlackLoading(false) + if (tx?.status === 1) { + Toast.success("添加黑名單成功") + getBlacks() + blackRefs.current!.clear() + } + } catch (error) { + console.error(error); + alert(JSON.stringify(error)) + setBlackLoading(false) + } + } + + const delBlacks = async () => { + try { + const _tokenIds = chooseIds.map(v => toBigInt(v)); + if (_tokenIds.length <= 0) return Toast.info('请选择NFT ID') + setRmBlackLoading(true) + const res = await Pledge__factory.deleteNftBlacks(_tokenIds); + const tx = await res.wait() + setRmBlackLoading(false) + setChooseIds([]) + if (tx?.status === 1) { + Toast.success("移除黑名單成功") + getBlacks() + } + } catch (error) { + console.error(error); + alert(JSON.stringify(error)) + setRmBlackLoading(false) + } + } + + + useEffect(() => { + getBlacks() + }, []) + + return ( +
+
NFT ID黑名单:
+
+ { + nftBlacks.length === 0 ? ( +
暂无NFT ID
+ ) : nftBlacks.map(item => ( +
handleChooseIds(item)} + >{item}
+ )) + } +
+
点击选中NFT ID,再次点击取消NFT ID
+
+ +
+
+
添加NFT ID黑名單:
+ +
+ +
+
+ ) +} + +export default observer(AdminNFT) \ No newline at end of file diff --git a/src/pages/admin/AdminPledge.tsx b/src/pages/admin/AdminPledge.tsx new file mode 100644 index 0000000..684bdf3 --- /dev/null +++ b/src/pages/admin/AdminPledge.tsx @@ -0,0 +1,250 @@ +import { observer } from "mobx-react" +import { useEffect, useRef, useState } from "react" +import { Input, TextAreaInstance, Toast } from "react-vant" +import Button from "~/components/Button" +import store from "~/store" +import '~/styles/admin.scss' + +const AdminPledge = () => { + + const { walletAddress, contract } = store.state + const { Pledge__factory } = contract._contract + const [status, setStatus] = useState(false) + const [blacks, setBlacks] = useState([] as string[]) + const [whites, setWhites] = useState([] as string[]) + + const blackRefs = useRef(null) + const whiteRefs = useRef(null) + + const [chooseBlacks, setChooseBlacks] = useState([] as string[]); + const [chooseWhites, setChooseWhites] = useState([] as string[]); + + const [statusLoading, setStatusLoading] = useState([false, false]) + const [blackLoading, setBlackLoading] = useState(false) + const [removeBlackLoading, setRemoveBlackLoading] = useState(false) + const [removeWhiteLoading, setRemoveWhiteLoading] = useState(false) + const [whiteLoading, setWhiteLoading] = useState(false) + + const getStatus = async () => { + const res = await Pledge__factory.pledgeStatus() + setStatus(res) + } + + const getWhites = async () => { + const res = await Pledge__factory.getBlackOrWhiteList("0x2") + setWhites(res) + } + + const getblacks = async () => { + const res = await Pledge__factory.getBlackOrWhiteList("0x1") + setBlacks(res) + } + + const removeBlacks = async () => { + try { + if (chooseBlacks.length <= 0) return Toast.info('请选择要移除的地址') + setRemoveBlackLoading(true) + const res = await Pledge__factory.delBlackOrWhiteList(chooseBlacks, "0x1"); + const tx = await res.wait() + setRemoveBlackLoading(false) + setChooseBlacks([]) + if (tx?.status === 1) { + Toast.success("移除黑名單成功") + getblacks() + } + } catch (error) { + alert(JSON.stringify(error)) + setRemoveBlackLoading(false) + } + } + + const removeWhites = async () => { + try { + if (chooseWhites.length <= 0) return Toast.info('请选择要移除的地址') + setRemoveWhiteLoading(true) + const res = await Pledge__factory.delBlackOrWhiteList(chooseWhites, "0x2"); + const tx = await res.wait() + setRemoveWhiteLoading(false) + setChooseWhites([]) + if (tx?.status === 1) { + Toast.success("移除白名單成功") + getWhites() + } + } catch (error) { + alert(JSON.stringify(error)) + setRemoveWhiteLoading(false) + } + } + + const addBlacks = async () => { + try { + const dom = blackRefs.current!.nativeElement + const value = dom?.value; + if (!value) return Toast.info('輸入地址') + const _address = value.split(',') + setBlackLoading(true) + const res = await Pledge__factory.addBlackOrWhiteList(_address, "0x1"); + const tx = await res.wait() + setBlackLoading(false) + if (tx?.status === 1) { + Toast.success("添加黑名單成功") + getblacks() + blackRefs.current!.clear() + } + } catch (error) { + alert(JSON.stringify(error)) + setBlackLoading(false) + } + } + + const addWhites = async () => { + try { + const dom = whiteRefs.current!.nativeElement + const value = dom?.value; + if (!value) return Toast.info('輸入地址') + const _address = value.split(',') + setWhiteLoading(true) + const res = await Pledge__factory.addBlackOrWhiteList(_address, "0x2"); + const tx = await res.wait() + setWhiteLoading(false) + if (tx?.status === 1) { + Toast.success("添加白名單成功") + getWhites() + whiteRefs.current!.clear() + } + } catch (error) { + alert(JSON.stringify(error)) + setWhiteLoading(false) + } + } + + const handleStatus = async (_status: boolean) => { + const index = _status ? 1 : 0; + try { + statusLoading[index] = true + setStatusLoading([...statusLoading]) + const res = await Pledge__factory.setPledgeStatus(_status) + const tx = await res.wait() + if (tx?.status === 1) { + Toast.success('設置成功') + } + getStatus() + statusLoading[index] = false + setStatusLoading([...statusLoading]) + } catch (error) { + alert(JSON.stringify(error)) + statusLoading[index] = false + setStatusLoading([...statusLoading]) + } + } + + const addChooseBlacks = (addr: string) => { + let index = chooseBlacks.indexOf(addr) + if (index < 0) { + chooseBlacks.push(addr) + } else { + chooseBlacks.splice(index, 1) + } + setChooseBlacks([...chooseBlacks]) + } + + const addChooseWhites = (addr: string) => { + let index = chooseWhites.indexOf(addr) + if (index < 0) { + chooseWhites.push(addr) + } else { + chooseWhites.splice(index, 1) + } + setChooseWhites([...chooseWhites]) + } + + + useEffect(() => { + if (walletAddress) { + getStatus() + getblacks() + getWhites() + } + }, [walletAddress]) + + return ( +
+
質押狀態:{!status ? '開啓中' : '關閉中'}
+
+ +
+ +
+
+
+
黑名單列表(點擊地址選中,可以多選):
+ { + blacks.length <= 0 ? ( +
暫無地址
+ ) : ( +
+ { + blacks.map((item, index) => ( +
addChooseBlacks(item)}> +
{item}
+ { + chooseBlacks.includes(item) && ( +
+ ) + } +
+ )) + } +
+ ) + } +
+
+ +
+
+
+
添加黑名單:
+ +
+ +
+
+
白名單列表(點擊地址選中,可以多選):
+ { + whites.length <= 0 ? ( +
暫無地址
+ ) : ( +
+ { + whites.map((item, index) => ( +
addChooseWhites(item)}> +
{item}
+ { + chooseWhites.includes(item) && ( +
+ ) + } +
+ )) + } +
+ ) + } +
+
+ +
+
+
+ +
添加白名單:
+ +
+ +
+
+ ) +} + +export default observer(AdminPledge) \ No newline at end of file diff --git a/src/pages/admin/AdminPool.tsx b/src/pages/admin/AdminPool.tsx new file mode 100644 index 0000000..c034b05 --- /dev/null +++ b/src/pages/admin/AdminPool.tsx @@ -0,0 +1,101 @@ +import { observer } from "mobx-react" +import { useEffect, useRef, useState } from "react" +import { Input, Toast } from "react-vant" +import Button from "~/components/Button" +import store from "~/store" +import '~/styles/admin.scss' +import { toFixed2 } from "~/utils" +import { fromWei, toWei } from "~/utils/wei" + +const AdminPool = () => { + + const { walletAddress, contract } = store.state + const { Pool__factory,FIL__factory } = contract._contract + const [statusLoading, setStatusLoading] = useState([false, false]) + const [status, setStatus] = useState(false) + + const [poolBalance, setPoolBalance] = useState('0.00') + + const amountRef = useRef(null) + const [withdrawLoading, setWithdrawLoading] = useState(false) + + const getStatus = async () => { + const res = await Pool__factory.poolStatus() + setStatus(res) + } + + const getBalance = async () => { + try { + const res = await FIL__factory.balanceOf(Pool__factory.target) + setPoolBalance(toFixed2(fromWei(res),6)) + } catch (error) { + console.log(error); + } + } + + const handleStatus = async (_status: boolean) => { + const index = _status ? 1 : 0; + try { + statusLoading[index] = true + setStatusLoading([...statusLoading]) + const res = await Pool__factory.setPoolStatus(_status) + const tx = await res.wait() + if (tx?.status === 1) { + Toast.success('設置成功') + } + getStatus() + statusLoading[index] = false + setStatusLoading([...statusLoading]) + } catch (error) { + alert(JSON.stringify(error)) + statusLoading[index] = false + setStatusLoading([...statusLoading]) + } + } + + const withdraw = async () => { + const amount = amountRef.current!.value + if (!amount) return Toast.info('请输入提现数量') + try { + setWithdrawLoading(true) + const res = await Pool__factory.withdrawTo(toWei(amount)) + const tx = await res.wait() + if (tx?.status === 1) { + Toast.success('提现成功') + amountRef.current!.value = '' + } + getBalance() + setWithdrawLoading(false) + } catch (error) { + alert(JSON.stringify(error)) + setWithdrawLoading(false) + } + } + + useEffect(() => { + walletAddress && getStatus() + walletAddress && getBalance() + }, [walletAddress]) + + return ( +
+
池子余额:{Number(poolBalance).toLocaleString()}FIL
+
+
池子狀態:{!status ? '開啓中' : '關閉中'}
+
+ +
+ +
+
+
+
提现数量
+ +
+ +
+
+ ) +} + +export default observer(AdminPool) \ No newline at end of file diff --git a/src/pages/admin/AdminSet.tsx b/src/pages/admin/AdminSet.tsx new file mode 100644 index 0000000..58a468e --- /dev/null +++ b/src/pages/admin/AdminSet.tsx @@ -0,0 +1,117 @@ +import { observer } from "mobx-react" +import { useEffect, useRef, useState } from "react" +import { Input, TextAreaInstance, Toast } from "react-vant" +import Button from "~/components/Button" +import store from "~/store" +import '~/styles/admin.scss' + +const AdminSet = () => { + + const { walletAddress, contract } = store.state + const { NFT__factory } = contract._contract + const [admins, setAdmins] = useState([] as string[]) + const adminRefs = useRef(null); + const [chooseAdmin, setChooseAdmin] = useState([] as string[]); + + const [removeAdminLoading,setRemoveAdminLoading] = useState(false) + const [addAdminLoading,setAddAdminLoading] = useState(false) + + const getAdmin = async () => { + const res = await NFT__factory.getAdmin() + setAdmins(res) + } + + const addChooseAdmin = (addr: string) => { + let index = chooseAdmin.indexOf(addr) + if (index < 0) { + chooseAdmin.push(addr) + } else { + chooseAdmin.splice(index, 1) + } + setChooseAdmin([...chooseAdmin]) + } + + const removeAdmin = async () => { + try { + if (chooseAdmin.length <= 0) return Toast.info('请选择要移除的地址') + setRemoveAdminLoading(true) + const res = await NFT__factory.deleteAdmin(chooseAdmin); + const tx = await res.wait() + setRemoveAdminLoading(false) + setChooseAdmin([]) + if (tx?.status === 1) { + Toast.success("移除管理员成功") + getAdmin() + } + } catch (error) { + console.error(error); + alert(JSON.stringify(error)) + setRemoveAdminLoading(false) + } + } + + const addAdmin = async () => { + try { + const dom = adminRefs.current!.nativeElement + const value = dom?.value; + if (!value) return Toast.info('輸入地址') + const _address = value.split(',') + setAddAdminLoading(true) + const res = await NFT__factory.addAdmin(_address) + const tx = await res.wait() + setAddAdminLoading(false) + if (tx?.status === 1) { + Toast.success("添加管理员成功") + getAdmin() + adminRefs.current!.clear() + } + } catch (error) { + console.error(error); + alert(JSON.stringify(error)) + setAddAdminLoading(false) + } + } + + useEffect(() => { + getAdmin() + }, []) + + return ( +
+
管理员列表(點擊地址選中,可以多選):
+ { + admins.length <= 0 ? ( +
暫無管理员
+ ) : ( +
+ { + admins.map((item, index) => ( +
addChooseAdmin(item)}> +
{item}
+ { + chooseAdmin.includes(item) && ( +
+ ) + } +
+ )) + } +
+ ) + } +
+
+ +
+
+
+
添加管理员:
+ +
+ +
+
+ ) +} + +export default observer(AdminSet) \ No newline at end of file diff --git a/src/pages/admin/index.tsx b/src/pages/admin/index.tsx new file mode 100644 index 0000000..b6f1aef --- /dev/null +++ b/src/pages/admin/index.tsx @@ -0,0 +1,72 @@ +import '~/styles/admin.scss' +import { observer } from "mobx-react" +import { useEffect, useState } from "react" +import { Tabs } from "react-vant" +import store from "~/store" +import AdminPledge from "./AdminPledge" +import AdminPool from './AdminPool' +import AdminNFT from './AdminNFT' +import AdminSet from './AdminSet' + +const Admin = () => { + + const { walletAddress, contract } = store.state + const { NFT__factory } = contract._contract + const [isAdmin, setIsAdmin] = useState(false) + const [isDeploy, setIsDeploy] = useState(false) + + const [tabIndex, setTabIndex] = useState(0) + + const getAdmin = async () => { + try { + const res = await NFT__factory.getAdmin() + let data = res.map(v => v.toLocaleUpperCase()) + let _isAdmin = data.includes(walletAddress.toLocaleUpperCase()) + setIsAdmin(_isAdmin) + } catch (error) { + console.error(error); + } + } + + const getIsDeploy = async () => { + const _deploy = await NFT__factory.deployAddress() + const _isDeploy = _deploy.toLocaleUpperCase() === walletAddress.toLocaleUpperCase(); + setIsDeploy(_isDeploy) + } + + useEffect(() => { + walletAddress && getAdmin() + walletAddress && getIsDeploy() + }, [walletAddress]) + + if (!isAdmin) return <> + + return ( +
+ setTabIndex(index)}> + + + + { + isDeploy && ( + + ) + } + + { + tabIndex === 0 && + } + { + tabIndex === 1 && + } + { + tabIndex === 2 && + } + { + tabIndex === 3 && + } +
+ ) +} + +export default observer(Admin) \ No newline at end of file diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx new file mode 100644 index 0000000..b20ce1b --- /dev/null +++ b/src/pages/home/index.tsx @@ -0,0 +1,163 @@ +import { useEffect, useMemo, useState } from 'react' +import { useTranslation } from 'react-i18next' +import { Collapse } from 'react-vant' +import Button from '~/components/Button' +import { eth_pledgeProducts } from '~/contract/api' +import { useRouter } from '~/hooks/useRouter' +import '~/styles/home.scss' + +const Home = () => { + + const { push } = useRouter() + const { t } = useTranslation() + + const [pledgeList, setPledgeList] = useState([ + { day: 180, rate: 14 }, + { day: 270, rate: 15 }, + { day: 360, rate: 16 }, + ]) + const [pledgeIndex, setPledgeIndex] = useState(0) + + const pledgeHelp = useMemo(() => [ + { title: '1. Stake', desc: 'Choose a staking plan' }, + { title: '2. Receive NFT', desc: 'NFT as a stake certificate to withdraw daily staking rewards' }, + { title: '3. Maturity', desc: 'Holding NFT can redeem all staking amount' }, + ], []) + + const collapseData = useMemo(() => [ + { title: 'Why should I stake Filecoin?', desc: 'FAQ1' }, + { title: 'What can I do with the NFT after receiving it?', desc: 'FAQ2' }, + { title: 'Where do my reward from staking come from?', desc: 'FAQ3' }, + ], []) + + const getData = async () => { + const res = await eth_pledgeProducts() + res.data && setPledgeList(res.data) + } + + useEffect(() => { + getData() + }, []) + return ( +
+
+
+
{t('STAKE TO EARN')}
+
+ +
+
+
+
+
+
+
+ +
+
+ { + pledgeList.map((item, index) => ( +
setPledgeIndex(index)} + className={`mr-1 tabs-box row-center ${pledgeIndex === index && 'active-tab-box'}`} + >{item.day} {t('Days')}
+ )) + } +
+
push('/pledge', { index: pledgeIndex })}>
+
+
+
{t('Annualized Percentage Rate (APR)')}
+
{pledgeList[pledgeIndex].rate}%
+
+
+
+
+ +
{t('Upcoming Soon')}
+
+
+ +
{t('Flexible Staking Subscription')}
+
+
+ +
{t('90 Days Staking Subscriptiong')}
+
+
+ +
{t('How It Works')}
+
+ { + pledgeHelp.map((item, index) => ( +
+
+
{t(item.title)}
+
{t(item.desc)}
+
+ + +
+ )) + } +
+ +
{t('Refer To Earn')}
+
+
+ +
+
{t('Up To 7% of Referees Staking Rewards')}
+
+
{t('By sharing your referral code and introducing your friends to SOFIL and stake, you can earn referral rewards and withdraw everyday.')}
+
+
+
+
+
+ +
{t('FAQs')}
+
+ + { + collapseData.map((item, index) => ( + + {t(item.desc)} + + )) + } + +
+ +
+
+
+ ) +} + +interface BinancePagProps { + title?: string; + color?: string +} + +const BinancePag = (props: BinancePagProps) => { + + const { t } = useTranslation() + const { title, color } = props + + return ( +
+
+ +
+
Binance-Peg Filecoin
+
FIL
+
+
+ +
+ ) +} + +export default Home \ No newline at end of file diff --git a/src/pages/invitation-detail/index.tsx b/src/pages/invitation-detail/index.tsx new file mode 100644 index 0000000..15038fa --- /dev/null +++ b/src/pages/invitation-detail/index.tsx @@ -0,0 +1,169 @@ + +import { observer } from 'mobx-react' +import { useEffect, useRef, useState } from 'react' +import { useTranslation } from 'react-i18next' +import Button from '~/components/Button' +import ModalLoading from '~/components/ModalLoading' +import { eth_Detail } from '~/contract/api' +import useCopyLink from '~/hooks/useCopy' +import { useRouter } from '~/hooks/useRouter' +import store from '~/store' +import '~/styles/pledge.scss' +import { PledgeInfoType } from '~/types/api.d' +import { calcExtractableAmount, calcReleasedIncome, calcWithdrawnAmount, getTime, splitAddress } from '~/utils' + +const InvitationDetail = () => { + + const { t } = useTranslation() + const { contract } = store.state + const { walletAddress } = store.state + const { copyVal } = useCopyLink() + const { push, location } = useRouter() + const _data = location.state.data as PledgeInfoType + const _currentTime = location.state.currentTime + const rate = location.state.rate + + const [data, setData] = useState(_data as PledgeInfoType) + const [currentTime, setCurrentTime] = useState(_currentTime) + + const [loading, setLoading] = useState(false) + const [visible, setVisible] = useState(false) + const [hash, setHash] = useState('') + const [status, setStatus] = useState(-1) + + const navbarRefs = useRef(document.querySelector('.layout .header')) + + const withdrawIncome = async () => { + try { + const { Pledge__factory } = contract._contract; + setLoading(true) + const res = await Pledge__factory.withdraInvitationAllInterest(); + setHash(res.hash) + setVisible(true) + const tx = await res.wait() + setStatus(tx?.status as number); + setLoading(false) + getData() + store.getBalance(walletAddress) + } catch (error) { + console.log(error); + setLoading(false) + } + } + + const getData = async () => { + const res = await eth_Detail(_data.tokenId, "0x2"); + if (res) { + setCurrentTime(res.currentTime) + setData(res.data) + } + } + + useEffect(() => { + walletAddress && getData() + }, [walletAddress]) + + useEffect(() => { + navbarRefs.current?.classList.add('nft-detail-navbar') + + return () => { + navbarRefs.current?.classList.remove('nft-detail-navbar') + } + }, []) + + return ( +
+
+
+
+
push(-1)}>
+
{t('Contreact(Rewards) Details')}
+
+
+
+
+
+
+ +
+
{t('NFT Details')}
+
+
{t('Contract No. (NFT ID)')}
+
# {data.tokenId}
+
+
+
{t('NFT Standard')}
+
ERC-721 (BSC)
+
+
+
{t('Contract Address')}
+
+ {splitAddress(contract._contract.NFT__factory.target, 6)} + copyVal(contract._contract.NFT__factory.target)}> +
+
+
+ {/* */} +
{t('Contract Details')}
+
+
{t('Contract Type')}
+
{data.pledgeDay} {t('Days Staking')}
+
+
+
{t('Status')}
+
{data.endTime > currentTime ? 'Active' : 'Matured'}
+
+
+
{t('Staked Amount')}
+
{data.pledgeAmount} FIL
+
+
+
{t('Est. APR')}
+
{rate}%
+
+
+
{t('Created Time')}
+
{getTime(data.startTime * 1000)}
+
+
+
{t('Maturity Time')}
+
{getTime(data.endTime * 1000)}
+
+
+ {/* */} +
{t('Rewards Details')}
+
+
{t('Rewards Start Time')}
+
{getTime(data.startTime * 1000)}
+
+
+
{t('Rewards Distributed')}
+
{calcReleasedIncome(data, currentTime)} FIL
+
+
+
{t('Rewards Withdrawn')}
+
{calcWithdrawnAmount(data)} FIL
+
+
+
{t('Withdrawable Amount')}
+
{calcExtractableAmount(data, currentTime)} FIL
+
+
+
+ +
+ +
+ + +
+ ) +} + +export default observer(InvitationDetail) \ No newline at end of file diff --git a/src/pages/invitation/index.tsx b/src/pages/invitation/index.tsx new file mode 100644 index 0000000..9dab866 --- /dev/null +++ b/src/pages/invitation/index.tsx @@ -0,0 +1,308 @@ +import '~/styles/invitation.scss' +import { useEffect, useRef, useState } from "react" +import { Empty, Tabs } from "react-vant" +import Button from '~/components/Button' +import store from '~/store' +import { observer } from 'mobx-react' +import Modal from '~/components/Modal' +import { calcIncome, getTime, splitAddress, toFixed2 } from '~/utils' +import useCopyLink from '~/hooks/useCopy' +import { eth_invitation } from '~/contract/api' +import { InvitationUserRecordType, InvitationWithdrawRecordType, PledgeInfoType } from '~/types/api.d' +import { useRouter } from '~/hooks/useRouter' +import ModalLoading from '~/components/ModalLoading' +import UnLogin from '~/components/Unlogin' +import { useTranslation } from 'react-i18next' + +const Invitation = () => { + + const { t } = useTranslation() + const { walletAddress, contract } = store.state + const { copyVal } = useCopyLink() + const [tabIndex, setTabIndex] = useState(0) + const [visible, setVisible] = useState(false) + + const [recommendAmount, setRecommendAmount] = useState(0) + const [unExpiredContract, setUnExpiredContract] = useState(0) + const [withdrawAmount, setWithdrawAmount] = useState('0.00') + const [userRecord, setUserRecord] = useState([] as InvitationUserRecordType[]) + const [contractRecord, setContractRecord] = useState([] as PledgeInfoType[]) + const [withdrawtRecord, setWithdrawRecord] = useState([] as InvitationWithdrawRecordType[]) + const [rate, setRate] = useState(0); + const [currentTime, setCurrentTime] = useState(0) + + const [loading, setLoading] = useState(false) + const [loadingVisible, setLoadingVisible] = useState(false) + const [hash, setHash] = useState('') + const [status, setStatus] = useState(-1) + + const navbarRefs = useRef(document.querySelector('.layout .header')) + + const getData = async () => { + const res = await eth_invitation(walletAddress) + if (res) { + setRecommendAmount(res.recommendAmount) + setUnExpiredContract(res.unExpiredContract) + setUserRecord(res.user) + setContractRecord(res.contract) + setWithdrawAmount(res.withdrawAmount) + setRate(res.rate) + setCurrentTime(res.currentTime) + setWithdrawRecord(res.withdrawRecord) + } + } + + const withdrawIncome = async () => { + try { + const { Pledge__factory } = contract._contract; + setLoading(true) + const res = await Pledge__factory.withdraInvitationAllInterest(); + setHash(res.hash) + setLoadingVisible(true) + const tx = await res.wait() + setStatus(tx?.status as number); + setLoading(false) + getData() + store.getBalance(walletAddress) + } catch (error) { + console.log(error); + setLoading(false) + } + } + + const resetData = () => { + setRecommendAmount(0) + setUnExpiredContract(0) + setWithdrawAmount('0.00') + setUserRecord([]) + setContractRecord([]) + setWithdrawRecord([]) + setRate(0) + setCurrentTime(0) + } + + useEffect(() => { + walletAddress && getData() + !walletAddress && resetData() + }, [walletAddress]) + + useEffect(() => { + navbarRefs.current?.classList.add('invitation-navbar') + + return () => { + navbarRefs.current?.classList.remove('invitation-navbar') + } + }, []) + + return ( +
+
+
+
+
{t('Referral Rewards')}
+
{t('Introduce your friends to stake and earn')}
+
+
+
+
{t('Up To 7% of Referees Staking Rewards')}
+
+ +
+
+
+
+ { + walletAddress ? ( +
+
+ +
+
+
{t('Your Referral Code')}
+
{splitAddress(walletAddress, 5)}
+ +
+
+
{t('Withdrawable Rewards')}
+
{toFixed2(withdrawAmount, 2)} FIL
+ +
+
+ +
+
+
{t('Referred Users')}
+
{recommendAmount}
+
+
+
{t('Active Contracts')}
+
{unExpiredContract}
+
+
+
+ +
+
+ setTabIndex(index)} + > + + + + + + + +
+
+ { + tabIndex === 0 && + } + { + tabIndex === 1 && ( + + ) + } + { + tabIndex === 2 && ( + + ) + } +
+
+ ) : ( + + ) + } + + +
+
+ +
+
{t('Share your referral code to earn rewards')}
+
+
{splitAddress(walletAddress, 6)}
+
copyVal(walletAddress)} /> +
+
+ + + +
+
+ + + +
+ ) +} + +const UserRecord = ({ list }: { list: InvitationUserRecordType[] }) => { + const { t } = useTranslation() + return ( +
+
+
{t('Addresses')}
+
{t('Contributed')}
+
{t('Binding Time')}
+
+ { + list.length === 0 ? ( + + ) : list.map((item, index) => ( +
+
{splitAddress(item.key, 4)}
+
{toFixed2(item.contribute, 2)} FIL
+
{getTime(item.bindTime * 1000)}
+
+ )) + } +
+ + ) +} + +interface ContractRecordProps { + list: PledgeInfoType[]; + rate: number; + currentTime: number; +} + +const ContractRecord = (props: ContractRecordProps) => { + + const { list, rate, currentTime } = props + const { t } = useTranslation() + const { push } = useRouter() + + return ( +
+
+
{t('Contract(NFT)')}
+
{t('Contributed')}
+
{t('Maturity Date')}
+
+ { + list.length === 0 ? ( + + ) : list.map((item, index) => ( +
{ + push('/invitationDetail', { data: item, currentTime, rate }) + }}> +
+
+ +
+
# {item.tokenId}
+
{item.pledgeDay} {t('Days')}
+
+
+
+
{toFixed2(calcIncome(item), 2)} FIL
+
+
{getTime(item.endTime * 1000, 'day')}
+
+
+
+ )) + } +
+ ) +} + +const WithdrawRecord = ({ list, address }: { list: InvitationWithdrawRecordType[], address: string }) => { + const { t } = useTranslation() + return ( +
+ { + list.length === 0 ? ( + + ) : list.map((item, index) => ( +
+
+
+
{t('Withdraw')}
+
{item.amount} FIL
+
+
{getTime(item.createTime * 1000)}
+
{t('Contract Address')}:{splitAddress(address, 6)}
+
+ )) + } +
+ ) +} + +export default observer(Invitation) \ No newline at end of file diff --git a/src/pages/my-pledge/index.tsx b/src/pages/my-pledge/index.tsx new file mode 100644 index 0000000..538d845 --- /dev/null +++ b/src/pages/my-pledge/index.tsx @@ -0,0 +1,398 @@ +import '~/styles/pledge.scss'; +import { observer } from 'mobx-react'; +import { useEffect, useRef, useState } from 'react'; +import Button from '~/components/Button'; +import store from '~/store'; +import { Empty, Tabs, Toast } from 'react-vant'; +import { useRouter } from '~/hooks/useRouter'; +import UnLogin from '~/components/Unlogin'; +import { eth_pledgeInfo, eth_pledgeRecords } from '~/contract/api'; +import { PledgeInfoType, PledgeWithdrawRecordType } from '~/types/api.d'; +import { calcIncome, getTime, splitAddress, toFixed2 } from '~/utils'; +import ModalLoading from '~/components/ModalLoading'; +import { copy } from '~/utils/copy'; +import { useTranslation } from 'react-i18next'; +import { t } from 'i18next'; + +const MyPledge = () => { + + const { walletAddress, filBalance, contract } = store.state + const {t} = useTranslation() + + const [tabIndex, setTabIndex] = useState(0) + const [pledgeToast, setPledgeToast] = useState('0') + const [withdrawAmount, setWithdrawAmount] = useState('0') + const [pledgeInfos, setPledgeInfos] = useState([] as PledgeInfoType[]); //所有質押記錄 + const [expiredPledgeInfos, setExpiredPledgeInfosPledgeInfos] = useState([] as PledgeInfoType[]); // 已到期 + const [unExpiredPledgeInfos, setUnExpiredPledgeInfosPledgeInfos] = useState([] as PledgeInfoType[]); //未到期 + const [destroyRecord, setDestroyRecord] = useState([] as PledgeInfoType[]); //未到期 + const [currentTime, setCurrentTime] = useState(0) + + const [totalPledge, setTotalPledge] = useState('0') + const [totalWithdraw, setTotalWithdraw] = useState('0') + const [pledgeRecord, setPledgeRecord] = useState([] as PledgeInfoType[]) + const [pledgeWithdrawRecord, setPledgeWithdrawRecord] = useState([] as PledgeWithdrawRecordType[]) + + const [loading, setLoading] = useState(false) + const [visible, setVisible] = useState(false) + const [hash, setHash] = useState('') + const [status, setStatus] = useState(-1) + + const navbarRefs = useRef(document.querySelector('.layout .header')) + + const resetState = () => { + setPledgeToast('0') + setWithdrawAmount('0') + setPledgeInfos([]) + setExpiredPledgeInfosPledgeInfos([]) + setUnExpiredPledgeInfosPledgeInfos([]) + setDestroyRecord([]) + setTotalPledge('0') + setTotalWithdraw('0') + setPledgeRecord([]) + setPledgeWithdrawRecord([]) + setCurrentTime(0) + } + + // 分類欄 : 質押合約 + const getData = async () => { + const res = await eth_pledgeInfo(walletAddress); + if (res) { + setPledgeInfos(res.pledgeInfos) + setWithdrawAmount(res.withdrawAmount) + setPledgeToast(res.pledgeToast) + setExpiredPledgeInfosPledgeInfos(res.expiredPledgeInfos) + setUnExpiredPledgeInfosPledgeInfos(res.unExpiredPledgeInfos) + setCurrentTime(res.currentTime) + setDestroyRecord(res.destoryRecord) + } + } + + // 分類欄 : 交易明細 + const getRecordData = async () => { + const res = await eth_pledgeRecords(walletAddress) + if (res) { + setTotalPledge(res.totalPledge) + setTotalWithdraw(res.totalWithdraw) + setPledgeRecord(res.records) + setPledgeWithdrawRecord(res.withdrawRecordPs) + } + } + + const withdrawIncome = async () => { + try { + const { Pledge__factory } = contract._contract; + setLoading(true) + const res = await Pledge__factory.withdraAllInterest(); + setHash(res.hash) + setVisible(true) + const tx = await res.wait() + setStatus(tx?.status as number); + setLoading(false) + getData() + store.getBalance(walletAddress) + } catch (error) { + console.log(error); + setLoading(false) + } + } + + useEffect(() => { + tabIndex === 0 && walletAddress && getData() + + tabIndex === 1 && walletAddress && getRecordData() + + !walletAddress && resetState() + + }, [walletAddress, tabIndex]) + + useEffect(() => { + if (!visible) { + setHash('') + setStatus(-1) + } + }, [visible]) + + useEffect(() => { + navbarRefs.current?.classList.add('pledge-contract-navbar') + + return () => { + navbarRefs.current?.classList.remove('pledge-contract-navbar') + } + }, []) + + return ( +
+
+
+
+
+
{t('Staking Details')}
+
{t('SOFIL NFTs represent the staking contracts you hold')}
+
+ setTabIndex(index)}> + + + +
+
+
+
+ { + walletAddress ? ( + <> + { + tabIndex === 0 && ( + + ) + } + { + tabIndex === 1 && ( + + ) + } + + ) : ( + + ) + } +
+ +
+ ) +} + +interface PledgeContractProps { + data: [PledgeInfoType[], PledgeInfoType[], PledgeInfoType[]], + currentTime: number, + filBalance: string, + pledgeToast: string, + withdrawAmount: string, + pledgeInfosLength: number, + withdrawIncome: Function, + loading: boolean, + hash: string, + visible: boolean, + setVisible: Function, + status: number +} + +const PledgeContract = (props: PledgeContractProps) => { + + const { data, currentTime, filBalance, pledgeToast, withdrawAmount, pledgeInfosLength, withdrawIncome, hash, setVisible, visible, status, loading } = props + const { push } = useRouter() + const [tabIndex, setTabIndex] = useState(0) + + return ( +
+
+
+
{t('Available Balance')}
+
{toFixed2(filBalance, 2) || '0.00'} FIL
+
+ +
+
{t('Staked Balance')}
+
{toFixed2(pledgeToast, 2)} FIL
+
+
+
{t('Withdrawable Rewards')}
+
{toFixed2(withdrawAmount, 2)} FIL
+
+ +
+
{t('No. of Staking Contracts')}
+
{pledgeInfosLength}
+
+
+
+
+ setTabIndex(index)} active={tabIndex} color='#0F0637' > + + + + +
+
+
+
{t('Contract(NFT)')}
+
{t('Withdrawable')}
+
{tabIndex === 0 ? t('Maturity Date') : t('Status')}
+
+ { + data[tabIndex].length === 0 ? ( +
+ +
+ ) : data[tabIndex].map((item, index) => ( +
{ + push('/nftDetail', { data: item, currentTime: currentTime, index: tabIndex }) + }}> +
+
+ +
+
# {item.tokenId}
+
{item.pledgeDay} {t('Days')}
+
+
+
+
{toFixed2(calcIncome(item), 2)} FIL
+
+ { + tabIndex === 0 && ( +
{getTime(item.endTime * 1000, 'day')}
+ ) + } + { + tabIndex === 1 && ( +
{t('Matured')}
+ ) + } + { + tabIndex === 2 && ( +
{t('Closed')}
+ ) + } +
+
+
+ )) + } +
+ +
+ ) +} + +interface RecordProps { + totalPledge: string, + totalWithdraw: string + pledgeRecord: PledgeInfoType[], + pledgeWithdrawRecord: PledgeWithdrawRecordType[], + contractAddress: string +} + +const Record = (props: RecordProps) => { + + const [tabIndex, setTabIndex] = useState(0) + const { totalPledge, totalWithdraw, pledgeRecord, pledgeWithdrawRecord, contractAddress } = props; + + return ( +
+
+
+
{t('Accumulative Stake')}
+
{toFixed2(totalPledge, 2)} FIL
+ {/*
+ +
*/} +
+
+
{t('Accumulative Rewards Withdraw')}
+
{toFixed2(totalWithdraw, 2)} FIL
+
+ {/* */} +
+
+
+
+
+ setTabIndex(index)}> + + + +
+
+ { + tabIndex === 0 ? ( +
+ { + pledgeRecord.length === 0 ? ( + + ) : pledgeRecord.map((item, index) => ( +
+
+
{t('Create Contract(NFT)')}
+
{item.pledgeAmount} FIL
+
+
+
# {item.tokenId}
+
{item.pledgeDay} {t('Days')}
+
+
{getTime(item.startTime * 1000)}
+
{t('Contract Address')}: copy(contractAddress, () => { + Toast.success('Copy Success') + })}>{splitAddress(contractAddress, 8)}
+
+
+ )) + } +
+ ) : ( +
+ { + pledgeWithdrawRecord.length === 0 ? ( + + ) : pledgeWithdrawRecord.map((item, index) => ( +
+
+
{t('Withdraw')}
+
{item.amount} FIL
+
+
+ { + item._type === 1 ? ( +
+
# {item.tokenId}
+
{item.pledgeDay} {t('Days')}
+
+ ) : ( +
{t('merge and extract')}
+ ) + } +
+
{getTime(item.createTime * 1000)}
+
{t('Contract Address')}: copy(contractAddress, () => { + Toast.success(t('Copy Success')) + })}>{splitAddress(contractAddress, 8)}
+
+
+ )) + } +
+ ) + } +
+
+
+ ) +} + + +export default observer(MyPledge) \ No newline at end of file diff --git a/src/pages/nft-detail/index.tsx b/src/pages/nft-detail/index.tsx new file mode 100644 index 0000000..70a6977 --- /dev/null +++ b/src/pages/nft-detail/index.tsx @@ -0,0 +1,249 @@ + +import { t } from 'i18next' +import { observer } from 'mobx-react' +import { useEffect, useRef, useState } from 'react' +import Button from '~/components/Button' +import Modal from '~/components/Modal' +import ModalLoading from '~/components/ModalLoading' +import { eth_Detail } from '~/contract/api' +import useCopyLink from '~/hooks/useCopy' +import { useRouter } from '~/hooks/useRouter' +import store from '~/store' +import '~/styles/pledge.scss' +import { PledgeInfoType } from '~/types/api.d' +import { calcExtractableAmount, calcReleasedIncome, calcWithdrawnAmount, getTime, splitAddress } from '~/utils' +import { toBigInt } from '~/utils/wei' + +const NFTDetail = () => { + + const { contract, walletAddress } = store.state + const { copyVal } = useCopyLink() + const { push, location } = useRouter() + const _data = location.state.data as PledgeInfoType + const _currentTime = location.state.currentTime; + const index = location.state.index; + + const [data, setData] = useState(_data as PledgeInfoType) + const [currentTime, setCurrentTime] = useState(_currentTime) + + const [loading, setLoading] = useState(false) + const [visible, setVisible] = useState(false) + const [hash, setHash] = useState('') + const [status, setStatus] = useState(-1) + + const [loadingEx, setLoadingEx] = useState(false) + const [visibleEx, setVisibleEx] = useState(false) + const [hashEx, setHashEx] = useState('') + const [statusEx, setStatusEx] = useState(-1) + + const [pledgeVisible, setPledgeVisible] = useState(false) + + const navbarRefs = useRef(document.querySelector('.layout .header')) + + const withdrawIncome = async () => { + try { + const { Pledge__factory } = contract._contract + const tokenId = toBigInt(data.tokenId) + setLoading(true) + const res = await Pledge__factory.withdrawInterest(tokenId) + setHash(res.hash) + setVisible(true) + const tx = await res.wait() + setStatus(tx?.status as number); + setLoading(false) + store.getBalance(walletAddress) + getData() + } catch (error) { + console.log(error); + setLoading(false) + } + } + + const exchangePrincipal = async () => { + try { + setLoadingEx(true) + const { Pledge__factory, NFT__factory } = contract._contract; + const isApprove = await NFT__factory.isApprovedForAll(walletAddress, Pledge__factory.target) + if (!isApprove) { + const approve = await NFT__factory.setApprovalForAll(Pledge__factory.target, true) + await approve.wait() + } + setLoadingEx(false) + setPledgeVisible(true) + } catch (error) { + setLoadingEx(false) + } + } + + const confirmExchangePrincipal = async () => { + setPledgeVisible(false) + try { + const { Pledge__factory, NFT__factory } = contract._contract; + // 檢測有沒有授權NFT + setLoadingEx(true) + const tokenId = toBigInt(`${data.tokenId}`) + const res = await Pledge__factory.destroyPledge(tokenId); + setHashEx(res.hash) + setVisibleEx(true) + const tx = await res.wait() + setStatusEx(tx?.status as number); + setLoadingEx(false) + store.getBalance(walletAddress); + getData() + } catch (error) { + console.log(error); + setLoadingEx(false) + } + } + + const getData = async () => { + const res = await eth_Detail(_data.tokenId, "0x1"); + if (res) { + setCurrentTime(res.currentTime) + setData(res.data) + } + } + + useEffect(() => { + walletAddress && getData() + }, [walletAddress]) + + useEffect(() => { + navbarRefs.current?.classList.add('nft-detail-navbar') + + return () => { + navbarRefs.current?.classList.remove('nft-detail-navbar') + } + }, []) + + return ( +
+
+
+
+
push(-1)}>
+
{t('Contract (NFT) Details')}
+
+
+
+
+
+
+
+ { + data.isBlack ? ( + + ) : ( + + ) + } +
+
{t('NFT Details')}
+
+
{t('Contract No. (NFT ID)')}
+
# {data.tokenId}
+
+
+
{t('NFT Standard')}
+
ERC-721 (BSC)
+
+
+
{t('Contract Address')}
+
+ {splitAddress(contract._contract.NFT__factory.target, 6)} + copyVal(contract._contract.NFT__factory.target)}> +
+
+
+
+ {/* */} +
+
{t('Contract Details')}
+
+
{t('Contract Type')}
+
{data.pledgeDay} {t('Days Staking')}
+
+
+
{t('Status')}
+
{data.endTime > currentTime ? t('Active') : t('Matured')}
+
+
+
{t('Staked Amount')}
+
{data.pledgeAmount} FIL
+
+
+
{t('Est. APR')}
+
{data.rate}%
+
+
+
{t('Created Time')}
+
{getTime(data.startTime * 1000)}
+
+
+
{t('Maturity Time')}
+
{getTime(data.endTime * 1000)}
+
+
+
+ {/* */} +
+
{t('Rewards & Withdrawals Details')}
+
+
{t('Rewards Start Time')}
+
{getTime(data.startTime * 1000)}
+
+
+
{t('Rewards Distributed')}
+
{calcReleasedIncome(data, currentTime)} FIL
+
+
+
{t('Rewards Withdrawn')}
+
{calcWithdrawnAmount(data)} FIL
+
+
+
{t('Withdrawable Amount')}
+
{calcExtractableAmount(data, currentTime)} FIL
+
+
+
+
+ { + index !== 2 && ( +
+ + { + currentTime > data.endTime && ( + + ) + } +
+ ) + } + + + +
+
+ +
+
{t('UNSTAKE')}
+
{t('unstake-desc')}
+
+
+
+ ) +} + +export default observer(NFTDetail) \ No newline at end of file diff --git a/src/pages/pledge/index.tsx b/src/pages/pledge/index.tsx new file mode 100644 index 0000000..d44ea1f --- /dev/null +++ b/src/pages/pledge/index.tsx @@ -0,0 +1,259 @@ +import { ethers } from 'ethers'; +import { observer } from 'mobx-react'; +import { useEffect, useRef, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Dialog, Toast } from 'react-vant'; +import Button from '~/components/Button'; +import Loading from '~/components/Loading'; +import Modal from '~/components/Modal'; +import ModalLoading from '~/components/ModalLoading'; +import { eth_pledgeProducts } from '~/contract/api'; +import { useRouter } from '~/hooks/useRouter'; +import store from '~/store'; +import '~/styles/pledge.scss' +import { toFixed2 } from '~/utils'; +import { fromWei, toBigInt, toWei, wei } from '~/utils/wei'; +// +const Pledge = () => { + + const { t } = useTranslation() + const { location } = useRouter() + + const { filBalance, walletAddress, contract: { _contract: { Pledge__factory, FIL__factory, Pool__factory } } } = store.state + const [pledgeList, setPledgeList] = useState([ + { day: 180, rate: 14 }, + { day: 270, rate: 15 }, + { day: 360, rate: 16 }, + ]) + + const [amount, setAmount] = useState('') + const [profit, setProfit] = useState('0.00') + const [tabIndex, setTabIndex] = useState(location.state ? location.state.index : 0) + const [visible, setVisible] = useState(false) + const [loading, setLoading] = useState(false) + const [visibleLoading, setVisibleLoading] = useState(false) + const [hash, setHash] = useState('') + const [status, setStatus] = useState(-1) + const invitationAddressRefs = useRef(null) + + const navbarRefs = useRef(document.querySelector('.layout .header')) + + const handleInput = (e: React.ChangeEvent) => { + let value = e.target.value.replace(/[^\d]/g, '') + setAmount(value) + } + + const getData = async () => { + const res = await eth_pledgeProducts() + res.data && setPledgeList(res.data) + } + + const pledge = async () => { + if (!amount) return Toast.info(t('Enter a staking amount')) + try { + setLoading(true) + + //查詢是否授權 + const allowance = await FIL__factory.allowance(walletAddress, Pool__factory.target) + + // 授權金額小於質押數量時授權 + if (allowance < toWei(amount)) { + // 授權 + const approve = await FIL__factory.approve(Pool__factory.target, wei.MaxUint256) + await approve.wait() + } + + const res = await Pledge__factory.recommendObj(walletAddress) + + if (res["key"] === wei.AddressZero) { + setLoading(false) + setVisible(true) + return + } + + + + confirmPledge() + } catch (error) { + console.log(error); + + setLoading(false) + } + } + + const confirmPledge = async () => { + try { + setLoading(true) + let inviterAddr = invitationAddressRefs.current?.value ? invitationAddressRefs.current?.value.trim() : wei.AddressZero + + if (!ethers.isAddress(inviterAddr)) { + inviterAddr = wei.AddressZero + } + + // 質押 + const res = await Pledge__factory.pledge(toWei(amount), toBigInt(tabIndex), inviterAddr) + setHash(res.hash) + setVisibleLoading(true) + const tx = await res.wait() + + setStatus(tx?.status as number); + setLoading(false) + setAmount("") + // 更新餘額 + store.getBalance(walletAddress) + + } catch (error) { + console.log(error); + + setLoading(false) + } + } + + useEffect(() => { + getData() + navbarRefs.current?.classList.add('pledge-navbar') + + return () => { + navbarRefs.current?.classList.remove('pledge-navbar') + } + }, []) + + useEffect(() => { + // 計算收益 + const calcIncome = () => { + if (amount === '') { + setProfit('0.00') + return + } + const pledgeAmount = toWei(amount) + const pledgeDay = toBigInt(pledgeList[tabIndex].day) + const rate = toBigInt(pledgeList[tabIndex].rate) + const year = toBigInt(365) + const total = pledgeAmount * rate / year * pledgeDay + const _profit = ethers.formatUnits(total, 20) + setProfit(_profit) + } + calcIncome() + }, [amount, tabIndex]) + + useEffect(() => { + if (!visibleLoading) { + setHash('') + setStatus(-1) + } + }, [visibleLoading]) + + return ( +
+
+
+
+
{t('Earn FILs Against Your FILs')}
+
+
+
+
+
{t('Available Balance')}
+
+ +
{filBalance || '0.00'}
+
+
{t('Choose a staking period')}
+
+ { + pledgeList.map((item, index) => ( +
{ + setTabIndex(index) + }} + > +
+
{item.day} {t('Days')}
+
{item.rate} %
+
{t('Est.APR')}
+
+
+ )) + } +
+
{t('Enter a staking amount')}
+
+
+ + +
+
+
FIL
+ +
+
+
{t('Review and Confirm')}
+
+
{t('Staking Amount')}:
+
{amount || '0.00'} FIL
+
+
+
{t('Staking Period')}:
+
{pledgeList[tabIndex].day} {t('Days')}
+
+
+
{t('Est. Rewards')}:
+
{toFixed2(profit, 4)} FIL
+
+
+
{t('Est. Total Receivable')}:
+
{toFixed2(profit, 4)} FIL
+
+
+ +
+
{t('By clicking Stake,you agree to SOFIL Terms of Services and Privacy Policy')}
+
+ { + setVisible(false); + confirmPledge() + }} + setVisible={() => { + setVisible(false) + }} + backgroundColosed + > +
+
+ +
+
{t('Enter a Referral Code (if any)')}
+
+
{t('pledge-desc')}
+
+
+
+ +
+
+
+
+ + + +
+ ) +} + +export default observer(Pledge); \ No newline at end of file diff --git a/src/router/layout/Navbar.tsx b/src/router/layout/Navbar.tsx new file mode 100644 index 0000000..2502d3d --- /dev/null +++ b/src/router/layout/Navbar.tsx @@ -0,0 +1,223 @@ +import { observer } from 'mobx-react' +import { useEffect, useMemo, useState } from 'react' +import { useTranslation } from 'react-i18next' +import { Popup, Toast } from 'react-vant' +import ConnectWalletButton from '~/components/ConnectWalletButton' +import Modal from '~/components/Modal' +import { config } from '~/contract' +import { useRouter } from '~/hooks/useRouter' +import { SOFIL_LANGUAGE } from '~/language' +import store from '~/store' +import '~/styles/layout.scss' +import { toBigInt } from '~/utils/wei' + +interface NavbarProps { + pathname: string +} + +const Navbar = (props: NavbarProps) => { + + const { filBalance } = store.state + const { push } = useRouter() + const [chainId, setChainId] = useState(Number(process.env.REACT_APP_CHAINID)) + const { t, i18n } = useTranslation() + + const [visible, setVisible] = useState(false) + const [errorVisible, setErrorVisible] = useState(false) + const [langVisible, setLangVisible] = useState(false) + + const menu = useMemo(() => [ + { id: 1, title: "Basic Staking", uri: require('~/assets/menu/menu-bg-0.png'), path: '/pledge' }, + { id: 2, title: "My Staking", uri: require('~/assets/menu/menu-bg-1.png'), path: '/myPledge' }, + { id: 3, title: "My Referral", uri: require('~/assets/menu/menu-bg-2.png'), path: '/invitation' }, + { id: 4, title: "Support & Resources", uri: require('~/assets/menu/menu-bg-3.png'), path: '' }, + ], []) + + const urls = useMemo(() => [ + { img: require("~/assets/menu/telegram.png"), title: 'Join Us on Telegram', uri: 'https://t.me/sofil_announcements ' }, + { img: require("~/assets/menu/twitter.png"), title: 'Follow Us on Twitter', uri: 'https://twitter.com/official_sofil' }, + { img: require("~/assets/menu/linkedin.png"), title: 'Follow Us on LinkedIn', uri: 'https://www.linkedin.com/company/sofilofficial/ ' }, + ], []) + + const langs = useMemo(() => [ + { title: 'English', key: 'en' }, + { title: '简体中文', key: 'zh' }, + { title: '繁体中文', key: 'hk' }, + ], []) + + const gitbooks = useMemo(() => ({ + 'en': 'https://sofil.gitbook.io/main', + 'zh': 'https://sofil.gitbook.io/main/v/cn', + 'hk': 'https://sofil.gitbook.io/main/v/tc' + } as { [key: string]: string }), []) + + const [currentLang, setCurrentLang] = useState(2) + + const setLang = (index: number) => { + const key = langs[index].key + setCurrentLang(index) + setLangVisible(false) + i18n.changeLanguage(key) + window.sessionStorage.setItem(SOFIL_LANGUAGE, key) + } + + const switchNetWork = () => { + // 请在DApp浏览器中访问 + if (!window.ethereum) return Toast.fail(t('Please visit in DApp Browser')) + const _chainId = toBigInt(`${process.env.REACT_APP_CHAINID}`).toString(16) + setErrorVisible(false) + window.ethereum.request({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: `0x${_chainId}` }], + }).then((res: any) => { + + }).catch((error: any) => { + // 请切换至BSC网络 + Toast.fail(t('Please switch to BSC network')) + console.error(error); + }) + } + + useEffect(() => { + window.ethereum && window.ethereum.request({ + method: 'eth_chainId' + }).then((chainId: string) => { + const _chainId = Number(toBigInt(chainId).toString(10)) + setChainId(_chainId) + }) + + window.ethereum && window.ethereum.on("chainChanged", (chainId: string) => { + window.location.reload() + }); + }, []) + + useEffect(() => { + let index = langs.findIndex(v => v.key === window.sessionStorage.getItem(SOFIL_LANGUAGE)) + if (index > -1) { + setCurrentLang(index) + } + }) + + useEffect(()=>{ + if(currentLang == 0){ + document.body.style.fontFamily = "Play"; + }else{ + document.body.style.fontFamily = "initial"; + } + },[currentLang]) + + return ( +
+
+
+
+ push('/')} /> + {/*
FIL Price: {filBalance || '0.00'} FIL
*/} +
+
+
+ { + config[chainId] ? ( + + ) : ( +
setErrorVisible(true)}> + +
+ ) + } +
setVisible(true)}> + +
+
+
+ +
+
+
+ { + push('/') + setVisible(false) + }} /> +
setVisible(false)}>
+
+
+ { + menu.map((item, index) => ( +
{ + if (item.path) { + push(item.path) + setVisible(false) + } else { + const key = langs[currentLang].key; + window.open(gitbooks[key]) + } + }}> +
+
+
+ +
+
+
{t(item.title)}
+
+
+ )) + } +
+ +
+
setLangVisible(!langVisible)}> +
{t('Language')}
+
+
{langs[currentLang].title}
+
+
+
+
+ { + langs.map((item, index) => ( +
setLang(index)}> +
{item.title}
+ {currentLang === index &&
} +
+ )) + } +
+ +
+ +
+ { + urls.map((item, index) => ( +
{ + window.open(item.uri) + }}> +
+ +
{t(item.title)}
+
+
+
+ )) + } +
+
{t('Terms of Services')}
+
{t('Privacy Policy')}
+
+
{t('Copyright © 2024 SOFIL. All Rights Reserved.')}
+
+
+
+ + +
+
{t('SOFIL currently supports the Smart Chain (BSC).')}
+
{t('Your wallet is running on an unsupported network')}
+
+
+ +
+ ) +} + +export default observer(Navbar) \ No newline at end of file diff --git a/src/router/layout/RenderRouter.tsx b/src/router/layout/RenderRouter.tsx new file mode 100644 index 0000000..195b804 --- /dev/null +++ b/src/router/layout/RenderRouter.tsx @@ -0,0 +1,25 @@ +import { Suspense } from "react"; +import { Route, Routes } from "react-router-dom"; +import { Loading } from "react-vant"; +import routes from "../routes"; + +const RenderRouter = () => { + return ( + +
+ +
加载中...
+
+
}> + + {routes.map(item => { + return ( + + ) + })} + + + ) +} + +export default RenderRouter; diff --git a/src/router/layout/index.tsx b/src/router/layout/index.tsx new file mode 100644 index 0000000..af80c6d --- /dev/null +++ b/src/router/layout/index.tsx @@ -0,0 +1,51 @@ +import '~/styles/layout.scss' +import { useRouter } from '~/hooks/useRouter'; +import RenderRouter from './RenderRouter'; +import Navbar from './Navbar'; +import { observer } from 'mobx-react'; +import { useEffect } from 'react'; +import store from '~/store'; +import { initContract } from '~/contract'; + +const LayoutRouter = () => { + + const { location } = useRouter() + const { walletAddress } = store.state + + useEffect(() => { + const init = async () => { + initContract() + if (walletAddress) { + store.getBalance(walletAddress) + } else { + store.setBanlance("0.00") + } + } + init() + }, [walletAddress]) + + useEffect(() => { + window.ethereum && window.ethereum.on('accountsChanged', (res: string[]) => { + if (res.length <= 0) { + store.removeAddr() + } else { + store.setAddress(res[0]) + } + }); + + + }, []) + + return ( +
+ +
+ +
+
+ ); +} + +export default observer(LayoutRouter) \ No newline at end of file diff --git a/src/router/routes.tsx b/src/router/routes.tsx new file mode 100644 index 0000000..43ab771 --- /dev/null +++ b/src/router/routes.tsx @@ -0,0 +1,43 @@ +import { lazy } from "react"; +import { RouteObject } from "react-router-dom"; + +const Home = lazy(() => import("~/pages/home")); +const Pledge = lazy(() => import("~/pages/pledge")); +const MyPledge = lazy(() => import("~/pages/my-pledge")); +const NFTDetail = lazy(() => import("~/pages/nft-detail")); +const Invitation = lazy(() => import("~/pages/invitation")); +const InvitationDetail = lazy(() => import("~/pages/invitation-detail")); +const Admin = lazy(() => import("~/pages/admin")); + +const routes = [ + { + path: "/", + element: + }, + { + path: "/pledge", + element: + }, + { + path: "/myPledge", + element: + }, + { + path: "/nftDetail", + element: + }, + { + path: "/invitation", + element: + }, + { + path: "/invitationDetail", + element: + }, + { + path: "/admin", + element: + } +] as RouteObject[]; + +export default routes; diff --git a/src/store/index.ts b/src/store/index.ts new file mode 100644 index 0000000..95548c4 --- /dev/null +++ b/src/store/index.ts @@ -0,0 +1,71 @@ +import { makeAutoObservable } from "mobx"; +import { StoreLocalStorageKey } from "~/types/store.d"; +import { ContractType } from "~/types/store"; +import { toFixed2 } from "~/utils"; +import { fromWei } from "~/utils/wei"; + +interface Store { + state: object; +} + +class AppStore implements Store { + state = { + walletAddress: "", + contract: {} as ContractType, + filBalance: "0.00", + }; + + constructor() { + makeAutoObservable(this); + this.initState(); + } + + /** + * @description 初始化数据 + */ + initState() { + let addr = + window.sessionStorage.getItem(StoreLocalStorageKey.ADDRESS) || ""; + this.state.walletAddress = addr; + } + + /** + * @description 设置地址 + */ + setAddress(addr: string): void { + this.state.walletAddress = addr; + window.sessionStorage.setItem(StoreLocalStorageKey.ADDRESS, addr); + } + + /** + * @description 移除地址 + */ + removeAddr(): void { + this.state.walletAddress = ""; + window.sessionStorage.removeItem(StoreLocalStorageKey.ADDRESS); + } + + setContract(_contract: ContractType): void { + this.state.contract = _contract; + } + + setBanlance(value: string): void { + this.state.filBalance = value; + } + + async getBalance(address: string) { + + try { + const { FIL__factory } = this.state.contract._contract; + const res = await FIL__factory.balanceOf(address); + const balance = toFixed2(fromWei(res), 2); + this.setBanlance(balance); + } catch (error) { + console.error(error); + } + } +} + +const store = new AppStore(); + +export default store; diff --git a/src/styles/admin.scss b/src/styles/admin.scss new file mode 100644 index 0000000..ec56ed8 --- /dev/null +++ b/src/styles/admin.scss @@ -0,0 +1,58 @@ +.admin{ + .rv-tabs__nav { + background: none; + } +} + +.admin-pledge{ + .input{ + margin-top: 10px; + border-radius: 10px; + padding:10px; + border: 1px solid $white; + caret-color:$white; + } + + .black-box{ + border: 1px solid #fff; + padding: 10px; + border-radius: 10px; + } + + .rv-textarea__control { + color: $white; + } + +} + +.admin-nft{ + .id-box{ + width: 30%; + height: 35px; + background-color: $red; + border-radius: 5px; + margin-right: 3%; + } + .active{ + border: 4px solid #4EE1F9; + } + .input{ + margin-top: 10px; + border-radius: 10px; + padding:10px; + border: 1px solid $white; + caret-color:$white; + } + .rv-textarea__control { + color: $white; + } +} + +.admin-pool{ + .input{ + border: 2px solid #057ec1; + border-radius: 5px; + width: 100%; + background: none; + } +} \ No newline at end of file diff --git a/src/styles/components.scss b/src/styles/components.scss new file mode 100644 index 0000000..f286bcd --- /dev/null +++ b/src/styles/components.scss @@ -0,0 +1,155 @@ +.modal-content { + width: 370px; + border-radius: 20px; + background: linear-gradient(291deg, #0e2d6f 2%, #352b72 43%, #01123c 83%); + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + padding: 20px; + color: $white; + .modal-button { + position: relative; + width: 130px; + height: 44px; + overflow: hidden; + border-radius: 22px; + background: linear-gradient(180deg, #70effc 0%, #297ed3 100%, #70effc 100%); + color: $white; + + &:active { + opacity: 0.8; + } + } +} + +.max-button { + width: 200px; + height: 60px; + border-radius: 30px; + background: $white; + border: none; + color: $white; + font-size: 20px; + color: $black; + font-weight: bold; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); +} + +.min-button { + width: 100px; + height: 35px; + border-radius: 30px; + font-size: 18px; + background-color: $white; + color: $black; + font-weight: bold; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + white-space: nowrap; +} + +.connect-button { + .button { + width: 140px; + height: 30px; + border-radius: 23px; + background: #ffffff; + box-sizing: border-box; + border: 1px solid #4ee1f9; + color: $black; + font-weight: bold; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + } + + .rv-popover__content { + width: 126px; + } +} + +.unlogin { + .button { + width: 200px !important; + height: 50px !important; + border-radius: 30px !important; + background: #021a56; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + border: none; + color: $white; + font-size: 20px; + } +} + +.loading { + .dynamics-box { + width: 73px; + height: 84px; + .dynamics-img { + width: 100%; + height: 100%; + object-fit: cover; + animation: fadeLoop 5s linear infinite; + } + } + + .img { + width: 73px; + height: 84px; + object-fit: cover; + transform: rotate(0deg); + } + + @keyframes fadeLoop { + 0% { + background-image: url("../assets/loading/loading-1.png"); + background-size: 100% 100%; + object-fit: cover; + } + + 1% { + background-image: url("../assets/loading/loading-1.png"); + background-size: 100% 100%; + object-fit: cover; + } + + 20% { + background-image: url("../assets/loading/loading-2.png"); + background-size: 100% 100%; + object-fit: cover; + } + + 40% { + background-image: url("../assets/loading/loading-3.png"); + background-size: 100% 100%; + object-fit: cover; + } + + 60% { + background-image: url("../assets/loading/loading-4.png"); + background-size: 100% 100%; + object-fit: cover; + } + + 80% { + background-image: url("../assets/loading/loading-5.png"); + background-size: 100% 100%; + object-fit: cover; + } + + 100% { + background-image: url("../assets/loading/loading-6.png"); + background-size: 100% 100%; + object-fit: cover; + } + } +} + +.my-loading { + $image-count: 5; // 图片数量 + $animation-duration: 10s; // 动画持续时间 + + .box { + width: 100px; + height: 120px; + position: relative; + animation: fadeLoop 5s linear infinite; + background-size: 100% 100%; + object-fit: cover; + } +} diff --git a/src/styles/global.scss b/src/styles/global.scss new file mode 100644 index 0000000..8016755 --- /dev/null +++ b/src/styles/global.scss @@ -0,0 +1,213 @@ +$colors:( + primary : $primary, + background : $background, + primary-text : $primary-text, + sub-text : $sub-text, + green : $green, + blue : $blue, + red : $red, + white : $white, + black : $black, + page:$page +); + +$iterations: 5; + +* { + padding: 0; + margin: 0; + box-sizing: border-box; +} + +body { + font-size: 16px; + color: #021A56; + user-select: none; + background-color: $white; + font-family: Play; + width: 430px; + overflow-x: hidden; +} + +@each $key,$color in $colors{ + .#{""+$key}{ color:$color }; + .#{""+$key}-bg{background-color: $color }; +}; + +@for $i from 1 through $iterations{ + // 外边距 + .mt-#{$i}px{margin-top: #{$i}px;} + .ml-#{$i}px{margin-left: #{$i}px;} + .mt-#{$i}{margin-top: 10px * $i;} + .mb-#{$i}{margin-bottom: 10px * $i;} + .ml-#{$i}{margin-left: 10px * $i;} + .mr-#{$i}{margin-right: 10px * $i;} + .m-#{$i}{margin: 10px * $i;} + .mtb-#{$i}{margin: 10px*$i 0px;} + .mlr-#{$i}{margin: 0px 10px*$i;} + + // 内边距 + .pt-#{$i}px{padding-top: #{$i}px;} + .pl-#{$i}px{padding-left: #{$i}px;} + .pt-#{$i}{padding-top: 10px * $i;} + .pb-#{$i}{padding-bottom: 10px * $i;} + .pl-#{$i}{padding-left: 10px * $i;} + .pr-#{$i}{padding-right: 10px * $i;} + .p-#{$i}{padding: 10px * $i;} + .ptb-#{$i}{padding: 10px*$i 0px;} + .plr-#{$i}{padding: 0px 10px*$i;} +} + +@for $i from 0 through 30{ + .fz-#{ $i + 8 }{font-size: 8px + $i} +} + +@for $i from 1 through 10{ + .flex-#{$i}{flex:$i}; +} + +.divider{ + width: 100%; + height: 0px; + border: 1px solid #D2D4D9; +} + +.fz-wb-100{ + font-weight: 100; +} + +.fz-wb-550 { + font-weight: 550; +} + +.fz-wb-1000 { + font-weight: 1000; +} + +.tac{ + text-align: center; +} + +.tar{ + text-align: end; +} + +.taj { + text-align: justify; +} + +.align-items { + align-items: center; +} + +.flex-wrap { + flex-wrap: wrap; +} + +.tad{ + text-align: end; +} + +.row { + display: flex; +} + +.row-items { + display: flex; + align-items: center +} + +.row-center { + display: flex; + justify-content: center; + align-items: center; +} + +.row-between { + display: flex; + justify-content: space-between; + align-items: center; +} + +.row-justify-around { + display: flex; + justify-content: space-around +} + +.row-justify-evenly { + display: flex; + justify-content: space-evenly +} + +.row-justify-end { + display: flex; + justify-content: flex-end +} + +.row-justify-start { + display: flex; + justify-content: flex-start +} + +.row-center { + display: flex; + justify-content: center; + align-items: center +} + +.column { + display: flex; + ; + flex-direction: column +} + +; + +.column-items-center { + display: flex; + align-items: center; + flex-direction: column +} + +.column-justify-center { + display: flex; + justify-content: center; + flex-direction: column +} + +.column-justify-between { + display: flex; + justify-content: space-between; + flex-direction: column +} + +.column-justify-around { + display: flex; + justify-content: space-around; + flex-direction: column +} + +.column-justify-evenly { + display: flex; + justify-content: space-evenly; + flex-direction: column +} + +.column-justify-end { + display: flex; + justify-content: flex-end; + flex-direction: column +} + +.column-justify-start { + display: flex; + justify-content: flex-start; + flex-direction: column +} + +.column-center { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column +} \ No newline at end of file diff --git a/src/styles/home.scss b/src/styles/home.scss new file mode 100644 index 0000000..d8b2b36 --- /dev/null +++ b/src/styles/home.scss @@ -0,0 +1,245 @@ +.home { + .liner-box { + position: relative; + width: 100%; + height: 190px; + background-color: #2d8ad7; + border-radius: 0px 0px 20% 20% / 40% 40%; + + .start-button { + width: 140px; + height: 35px; + border-radius: 23px; + background: #f3f3f3; + box-sizing: border-box; + border: 1px solid #4ee1f9; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + border: none; + font-weight: bold; + } + + .logo { + background-image: url("../assets/max-logo.png"); + width: 300px; + height: 328px; + background-size: 100% 100%; + position: absolute; + left: 230px; + top: 0; + } + + .radius { + width: 100%; + background: linear-gradient(180deg, #473c80 -6%, #021a56 100%); + height: 180px; + color: $white; + border-radius: 0px 0px 20% 20% / 40% 40%; + position: absolute; + top: 0; + left: 0; + } + } + + .product-box { + width: 100%; + height: 192px; + border-radius: 23px; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + background-image: url('../assets/product-box.png'); + background-size: 100% 100%; + object-fit: cover; + position: relative; + z-index: 1; + color: $white; + .box { + width: 391px; + height: 172px; + border-radius: 23px; + background: rgba(255, 255, 255, 0.102); + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + padding: 15px; + } + } + + .BinancePag { + .img { + @include img-size(42px, 42px); + } + + .Locked { + width: 100px; + height: 30px; + -webkit-clip-path: polygon(15% 0, 85% 0, 100% 50%, 100% 50%, 85% 100%, 15% 100%, 0 46%, 0 50%); + clip-path: polygon(15% 0, 85% 0, 100% 50%, 100% 50%, 85% 100%, 15% 100%, 0 46%, 0 50%); + background: #4ee1f9; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + border: none; + font-weight: bold; + } + } + + .tabs-box { + width: 82px; + height: 29px; + box-sizing: border-box; + border: 1px solid #ffffff; + border-radius: 23px; + font-size: 14px; + font-weight: bold; + } + + .active-tab-box { + width: 82px; + height: 29px; + border-radius: 23px; + opacity: 1; + background: #f3f3f3; + box-sizing: border-box; + color: $black; + border: 1px solid #4ee1f9; + } + + .divider { + width: 100%; + height: 6px; + background: #1c1c1c; + } + + .help { + width: 430px; + display: flex; + align-items: center; + overflow: hidden; + overflow-x: scroll; + &::-webkit-scrollbar { + display: none; + } + } + + .Upcoming { + .box { + width: 100%; + height: 106px; + border-radius: 23px; + background: #ffffff; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + padding: 15px 25px; + } + } + + @for $i from 1 through 3 { + .help-bg-img-#{$i} { + background-image: url('../assets/scroll-#{$i}.png'); + } + } + + .help-box { + min-width: 260px; + height: 130px; + border-radius: 17px; + background-size: 100% 100%; + opacity: 1; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + padding: 20px 14px; + color: $white; + object-fit: cover; + align-items: start; + + .help-img-0 { + width: 46px; + height: 72px; + object-fit: cover; + margin-top: 10px; + } + + .help-img-1 { + width: 64px; + height: 87px; + object-fit: cover; + margin-top: 10px; + } + + .help-img-2 { + width: 68px; + height: 69px; + object-fit: cover; + margin-top: 10px; + } + } + + .refer { + width: 100%; + height: 178px; + border-radius: 23px; + opacity: 1; + background: #ffffff; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + position: relative; + .img { + position: absolute; + width: 94px; + height: 92px; + object-fit: cover; + left: 0; + bottom: -35px; + } + + .box { + width: 391px; + height: 159px; + border-radius: 23px; + background-size: 100% 100%; + background-image: url('../assets/referees-box.png'); + box-sizing: border-box; + border: 1px solid #ffffff; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + color: $white; + } + } + + .understand-button { + width: 150px; + height: 35px; + border-radius: 23px; + background: #021a56; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + color: $white; + } + + .rv-cell { + background: $white; + border-radius: 10px; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + } + + .rv-collapse-item { + border-radius: 20px; + } + + .rv-collapse-item__title--expanded { + border-radius: 10px 10px 0px 0px; + } + + .rv-collapse-item--border { + &::after { + border: none; + } + } + + .rv-collapse-item__title--expanded { + &::after { + border: none; + } + } + + .rv-collapse-item__wrapper { + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + } + + .rv-collapse-item__content { + background: $white; + color: $black; + border-radius: 0px 0px 10px 10px; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + } +} diff --git a/src/styles/invitation.scss b/src/styles/invitation.scss new file mode 100644 index 0000000..96e9827 --- /dev/null +++ b/src/styles/invitation.scss @@ -0,0 +1,131 @@ +.invitation { + position: relative; + .watermark-1 { + position: absolute; + background-image: url("../assets/stake-bg-img-2.png"); + width: 232px; + height: 268px; + right: -60px; + background-size: 100% 100%; + position: -1; + top: calc($height - 338px); + } + .liner-box { + width: 100%; + height: 180px; + background: #0e52a5; + border-radius: 0px 0px 20% 20% / 40% 40%; + position: relative; + + .box { + width: 100%; + height: 170px; + border-radius: 0px 0px 20% 20% / 40% 40%; + background-image: url("../assets/recommend-box.png"); + background-size: 100% 100%; + object-fit: cover; + color: $white; + position: absolute; + left: 0; + top: 0; + } + + .learn-box { + width: 370px; + height: 100px; + border-radius: 23px; + background: linear-gradient(275deg, #0e2d6f 1%, #352b72 50%, #01123c 98%); + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + position: absolute; + left: 30px; + bottom: -50px; + .notify-img { + position: absolute; + width: 80px; + height: 80px; + object-fit: cover; + background-image: url("../assets/notify-right.png"); + background-size: 100% 100%; + right: -30px; + top: -25px; + } + } + } + + .block { + &::before { + content: " "; + } + display: block; + height: 50px; + } + + .rv-tabs__nav { + background: none; + } + + .button { + width: 130px; + height: 40px; + border-radius: 23px; + background: #021a56; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + color: $white; + font-weight: bold; + } + + .nft-img { + width: 40px; + height: 40px; + object-fit: cover; + } + + .share-img { + width: 60px; + height: 60px; + object-fit: cover; + } + + .copy-img { + width: 20px; + height: 20px; + object-fit: cover; + } + + .menu { + img { + width: 42px; + height: 42px; + object-fit: cover; + } + } + + .modal-button { + width: 140px; + height: 30px; + color: $black; + border-radius: 23px; + background: $white; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + } + + .record-box { + width: 100%; + border-radius: 20px; + padding: 20px; + background: rgba(44, 127, 211, 0.0784); + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + margin-top: 20px; + + .watermark { + background-image: url("../assets/stake-watermark.png"); + background-size: 100% 100%; + width: 34px; + height: 34px; + object-fit: cover; + position: absolute; + right: 15px; + bottom: 20px; + } + } +} diff --git a/src/styles/layout.scss b/src/styles/layout.scss new file mode 100644 index 0000000..0c29184 --- /dev/null +++ b/src/styles/layout.scss @@ -0,0 +1,235 @@ +.layout { + .pledge-navbar { + background: linear-gradient(304deg, #021a56 -1%, #3b5783 21%, #021a56 95%) !important; + } + + .pledge-contract-navbar { + background: linear-gradient(283deg, #297ed3 -1%, #6d9ce3 102%, #408edd 93%) !important; + } + + .nft-detail-navbar { + background: linear-gradient(108deg, #1b80bf 0%, #3f69aa 67%, #1578b6 95%) !important; + } + + .invitation-navbar { + background: linear-gradient(113deg, #137ec1 0%, #416bab 66%, #1b74ab 95%) !important; + } + + .header { + padding: 0px 10px 0px 20px; + height: 60px; + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + background: linear-gradient(100deg, #433978 -6%, #44397d 100%); + + .icon-ego-menu { + font-size: 30px; + } + + .logo { + width: 42px; + height: 50px; + object-fit: cover; + } + + .error { + width: 50px; + height: 35px; + border-radius: 20px; + border: 2px solid #fd0000; + display: flex; + justify-content: center; + align-items: center; + + &:active { + opacity: 0.8; + } + + img { + width: 20px; + height: 20px; + object-fit: cover; + } + } + } + + .header-bg-color { + color: $white; + background-size: 100% 100%; + background-repeat: no-repeat; + } + + .pages { + height: 100%; + width: 100%; + } +} + +.rv-popup::-webkit-scrollbar { + display: none; +} + +.connect-button { + .button { + width: 126px; + height: 32px; + background: none; + border: 1px solid $white; + color: $white; + } + + .rv-popover__content { + width: 126px; + } +} + +.popup { + display: flex; + flex-direction: column; + justify-content: space-between; + height: 100%; + color: $white; + + .header { + height: 60px; + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + } + + @for $i from 0 through 3 { + .img-box-#{$i} { + width: 50%; + height: 181px; + background-image: url("../assets/menu/menu-bg-#{$i}.png"); + background-size: 100% 100%; + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 20px 30px 35px 30px; + } + } + + .menu-hover { + &:active { + opacity: 0.85; + } + } + + .menu-img-0 { + @include img-size(32px, 44px); + } + + .menu-img-1 { + @include img-size(40px, 40px); + } + + .menu-img-2 { + @include img-size(45px, 44px); + } + + .menu-img-3 { + @include img-size(26px, 40px); + } + + .active-language-box { + height: 200px !important; + transition: all 0.25s linear; + } + + .language-box { + width: 100%; + background-color: #313131; + border-radius: 23px; + height: 50px; + overflow: hidden; + transition: all 0.15s linear; + + .box { + height: 50px; + } + .box-1 { + height: 40px; + } + } + + .community-box { + width: 100%; + height: 50px; + border-radius: 23px; + opacity: 1; + background: #313131; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + &:active { + opacity: 0.8; + } + + .img { + @include img-size(26px, 26px); + } + } + + .text-divider { + border-bottom: 1px solid $white; + &:active{ + opacity: 0.8; + } + } + + .divider { + width: 100%; + height: 1px; + background-color: $white; + } + + .icon { + width: 36px; + height: 36px; + object-fit: cover; + } + + .logo { + width: 42px; + height: 50px; + object-fit: cover; + } + + .icon-guanbi { + font-size: 24px; + } +} + +.rv-popup { + .header-fil { + width: 40px; + height: 40px; + object-fit: cover; + } + + .header-divider { + width: 100%; + height: 1px; + background-color: $white; + } + + .header-pledge-img { + width: 50px; + height: 50px; + object-fit: cover; + } + + .header-recommend-img { + width: 30px; + height: 30px; + object-fit: cover; + margin-left: 15px; + margin-right: 10px; + } + + .header-logout { + color: #4ee1f9; + } +} diff --git a/src/styles/pledge.scss b/src/styles/pledge.scss new file mode 100644 index 0000000..361b649 --- /dev/null +++ b/src/styles/pledge.scss @@ -0,0 +1,321 @@ +.pledge { + position: relative; + + .modal-bg-img { + background-image: url("../assets/modal-bg-img.png"); + background-size: 100% 100%; + border: none; + width: 376px; + } + + .watermark { + width: 231px; + height: 267px; + object-fit: cover; + background-image: url("../assets/watermark.png"); + background-size: 100% 100%; + position: absolute; + bottom: 0; + left: -50px; + z-index: -1; + } + + .liner-box { + position: relative; + width: 100%; + height: 128px; + opacity: 1; + background: #4ee1f9; + border-radius: 0px 0px 20% 20% / 40% 40%; + + .bg-img { + position: absolute; + background-image: url("../assets/pledge-header.png"); + background-size: 100% 100%; + width: 119px; + height: 185px; + object-fit: cover; + top: 0; + right: -15px; + } + + .box { + width: 100%; + background: linear-gradient(246deg, #021a56 -1%, #3b5783 21%, #021a56 93%); + height: 120px; + color: $white; + border-radius: 0px 0px 20% 20% / 40% 40%; + } + } + + .fil { + @include img-size(42px, 42px); + } + + .stake-button { + width: 193px; + height: 46px; + border-radius: 23px; + background: #021a56; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + color: $white; + font-weight: bold; + } + + .pledge-box { + width: 118px; + height: 118px; + border-radius: 20px; + background: #ffffff; + box-sizing: border-box; + border: 1px solid #021a56; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + color: #021a56; + } + + .active { + background-color: #021a56; + color: $white; + } + + .input-box { + width: 100%; + height: 60px; + border-radius: 10px; + background-color: #021a56; + + .fil { + width: 35px; + height: 35px; + object-fit: cover; + } + input { + width: 100%; + border: none; + background: none; + color: $white; + } + .button { + width: 70px; + height: 30px; + border-radius: 20px; + border: none; + font-weight: bold; + } + } + + .modal-img { + width: 101px; + height: 78px; + object-fit: cover; + } + + .modal-input { + width: 100%; + height: 40px; + border: 1px solid #057ec1; + border-radius: 10px; + width: 306px; + height: 54px; + border-radius: 16px; + opacity: 1; + background: $white; + box-sizing: border-box; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + input { + background: none; + border: none; + color: $black; + } + } + + .modal-close { + position: absolute; + top: 0; + right: 0px; + } + + .pledge-confirm { + width: 160px; + height: 40px; + border-radius: 23px; + opacity: 1; + background: $white; + color: $black; + font-weight: bold; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + } +} + +.my-pledge { + position: relative; + .watermark-1 { + position: absolute; + right: -10px; + background-image: url("../assets/stake-bg-img-1.png"); + width: 153px; + height: 191px; + background-size: 100% 100%; + top: 220px; + position: -1; + } + .watermark-2 { + position: absolute; + background-image: url("../assets/stake-bg-img-2.png"); + width: 232px; + height: 268px; + left: -40px; + background-size: 100% 100%; + position: -1; + top: calc($height - 328px); + } + .button-stake { + width: 130px; + height: 40px; + border-radius: 23px; + background: #021a56; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + color: $white; + font-weight: bold; + } + + .liner-box { + width: 100%; + background: #051d59; + height: 200px; + border-radius: 0px 0px 20% 20% / 40% 40%; + + .box { + width: 100%; + background-image: url("../assets/stake-box.png"); + background-size: 100% 100%; + height: 190px; + border-radius: 0px 0px 20% 20% / 40% 40%; + color: $white; + } + } + + .divider { + width: 100%; + height: 0px; + opacity: 1; + border: 1px solid #707070; + } + + .nft-img { + width: 40px; + height: 40px; + object-fit: cover; + } + + .rv-tabs__nav { + background: none; + } + + .record { + .box { + width: 100%; + padding: 15px; + border-radius: 20px; + background: rgba(44, 127, 211, 0.0784); + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + position: relative; + + .watermark { + background-image: url("../assets/stake-watermark.png"); + background-size: 100% 100%; + width: 34px; + height: 34px; + object-fit: cover; + position: absolute; + right: 15px; + bottom: 20px; + } + + .contract-bottom { + border-bottom: 1px solid $black; + &:active { + opacity: 0.5; + } + } + + .withdraw-watermark { + background-image: url("../assets/withdraw-watermark.png"); + background-size: 100% 100%; + width: 34px; + height: 34px; + object-fit: cover; + position: absolute; + right: 15px; + bottom: 20px; + } + } + } +} + +.nft-detail { + .liner-box { + width: 100%; + background: #051d59; + height: 140px; + border-radius: 0px 0px 20% 20% / 40% 40%; + + .box { + width: 100%; + height: 130px; + background-size: 100% 100%; + background-image: url("../assets/nft-details-box.png"); + border-radius: 0px 0px 20% 20% / 40% 40%; + color: $white; + } + } + + .modal-bg-img { + background-image: url("../assets/modal-bg-img.png"); + background-size: 100% 100%; + border: none; + width: 376px; + } + + .stake-button { + width: 175px; + height: 50px; + border-radius: 25px; + background: #021a56; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + color: $white; + font-size: 18px; + font-weight: bold; + } + + .box { + background: rgba(44, 127, 211, 0.0784); + border-radius: 20px; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + } + + .img { + width: 111px; + height: 111px; + object-fit: cover; + border: 1px solid #051d59; + box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.1608); + } + + .warning-img { + width: 82px; + height: 82px; + object-fit: cover; + } + + .unstake-button { + width: 160px; + height: 40px; + color: $black; + font-weight: bold; + border-radius: 23px; + opacity: 1; + background: #ffffff; + box-shadow: 0px 6px 6px 0px rgba(0, 0, 0, 0.1608); + } +} diff --git a/src/styles/theme.scss b/src/styles/theme.scss new file mode 100644 index 0000000..8014c21 --- /dev/null +++ b/src/styles/theme.scss @@ -0,0 +1,25 @@ +$primary:#021A56;; +$background:#fff; +$primary-text:#000; +$sub-text:#BABABA; +$green:#0ECB81; +$blue:#409EFF; +$red:#F6465D; +$white:#fff; +$black:#021A56; +$page:rgb(248,247,255); +$like:#F96900; + +$width:var(--width); +$height:var(--height); + +$button-background: linear-gradient(0deg, #5B40A2 0%, #B595FF 100%); +$button-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.3); +$fil-bg: linear-gradient(95deg, #F96900 0%, #FFAA6B 115%, #FF800B 115%); +$usdt-bg: linear-gradient(104deg, #320D6D 3%, #8A4CED 106%); + +@mixin img-size($width,$height){ + width: $white; + height: $height; + object-fit: cover; +} \ No newline at end of file diff --git a/src/types/api.d.ts b/src/types/api.d.ts new file mode 100644 index 0000000..96a0e6a --- /dev/null +++ b/src/types/api.d.ts @@ -0,0 +1,33 @@ +interface PledgeInfoType { + pledgeAmount: string; + pledgeDay: number; + endTime: number; + rate: number; + sender: string; + startTime: number; + tokenId: number; + withdrawTime: number; + isBlack:boolean +} + +interface InvitationUserRecordType { + bindTime: number; + key: string; + contribute: string; + referrer: string; +} + +interface InvitationWithdrawRecordType{ + createTime:number; + amount:string +} + +interface PledgeWithdrawRecordType { + amount:string; + createTime:number; + tokenId:string; + pledgeDay:string; + _type:number; +} + +export { PledgeInfoType, InvitationUserRecordType,PledgeWithdrawRecordType, InvitationWithdrawRecordType}; diff --git a/src/types/store.d.ts b/src/types/store.d.ts new file mode 100644 index 0000000..3829056 --- /dev/null +++ b/src/types/store.d.ts @@ -0,0 +1,31 @@ +import { JsonRpcProvider, Web3Provider } from "@ethersproject/providers"; +import { Contract, Provider } from "ethers-multicall"; +import { FIL, NFT, Pledge, Pool } from "~/contract/typechain-types"; + +enum StoreLocalStorageKey { + TOKEN = "MARKET_NFT_TOKEN", + ADDRESS = "MARKET_NFT_ADDRESS", +} + +interface Contract_Factory { + FIL__factory: FIL; + NFT__factory: NFT; + Pledge__factory: Pledge; + Pool__factory: Pool; +} + + +interface ETH_Contract_Factory { + FIL__factory: Contract; + NFT__factory: Contract; + Pledge__factory: Contract; + Pool__factory: Contract; +} + + +interface ContractType { + _contract: Contract_Factory; + _provider: Web3Provider | JsonRpcProvider; +} + +export { StoreLocalStorageKey, ContractType }; diff --git a/src/utils/copy.ts b/src/utils/copy.ts new file mode 100644 index 0000000..e230d05 --- /dev/null +++ b/src/utils/copy.ts @@ -0,0 +1,21 @@ +export function copy(value: string, cb?: Function) { + // 动态创建 textarea 标签 + const textarea: any = document.createElement('textarea') + // 将该 textarea 设为 readonly 防止 iOS 下自动唤起键盘,同时将 textarea 移出可视区域 + textarea.readOnly = 'readonly' + textarea.style.position = 'absolute' + textarea.style.left = '-9999px' + // 将要 copy 的值赋给 textarea 标签的 value 属性 + // 网上有些例子是赋值给innerText,这样也会赋值成功,但是识别不了\r\n的换行符,赋值给value属性就可以 + textarea.value = value + // 将 textarea 插入到 body 中 + document.body.appendChild(textarea) + // 选中值并复制 + textarea.select() + textarea.setSelectionRange(0, textarea.value.length) + document.execCommand('Copy') + document.body.removeChild(textarea) + if (cb && Object.prototype.toString.call(cb) === '[object Function]') { + cb() + } +} \ No newline at end of file diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..2d2360e --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,187 @@ +import { BigNumberish, ethers } from "ethers"; +import { Toast } from "react-vant"; +import { PledgeInfoType } from "~/types/api"; +import { toBigInt, toWei } from "./wei"; +import { t } from "i18next"; + +// 切割字符中 ''...'' +const splitAddress = (address: any, index?: number) => { + try { + let idx = index ? index : 5; + return ( + address.substring(0, idx) + + "..." + + address.substring(address.length - idx, address.length) + ); + } catch (error) { + return ""; + } +}; + +export const getChainId = async () => { + const chainId = toBigInt( + await window.ethereum.request({ + method: "eth_chainId", + }) + ).toString(10); + return chainId ? Number(chainId) : 0; +}; + +const switchNetWork = () => { + return new Promise(async (resolve) => { + if (!window.ethereum) { + resolve(false); + return; + } + let chainId = await getChainId(); + + if (chainId === 97 || chainId === 56) { + //测试 + resolve(true); + return; + } + (window as any).ethereum + .request({ + method: "wallet_switchEthereumChain", + params: [{ chainId: "0x38" }], + }) + .then((r: any) => { + resolve(true); + // console.log(r); + }) + .catch((switchError: any) => { + if (switchError.code === 4902) { + resolve(false); + Toast.info(t("Please add BSC node to your wallet")); + } + }); + }); +}; + +const toThousands = (value: number | string) => { + if (!value) return 0; + return Number(value).toLocaleString(); +}; + +/** + * @param value + * @returns + */ +const getTime = (value: number, type?: string) => { + let date = new Date(value); + let yy: number | string = date.getFullYear(); + let mm: number | string = date.getMonth() + 1; + let dd: number | string = date.getDate(); + let xs: number | string = date.getHours(); + let ff: number | string = date.getMinutes(); + let ss: number | string = date.getSeconds(); + mm = mm >= 10 ? mm : "0" + mm; + dd = dd >= 10 ? dd : "0" + dd; + xs = xs >= 10 ? xs : "0" + xs; + ff = ff >= 10 ? ff : "0" + ff; + ss = ss >= 10 ? ss : "0" + ss; + if (type === "day") return `${yy}-${mm}-${dd}`; + return `${yy}-${mm}-${dd} ${xs}:${ff}`; +}; + +const toFixed2 = (val: string, double: number) => { + try { + if (val.indexOf(".") > -1) { + return val.substring( + 0, + val.indexOf(".") + (double === 0 ? double : double + 1) + ); + } + return val; + } catch (error) { + return "0"; + } +}; + +// 計算縂發放的收益 +const calcIncome = (data: PledgeInfoType) => { + try { + const rate = toBigInt(data.rate); + const day = toBigInt(data.pledgeDay); + const income = + ((toWei(data.pledgeAmount) * rate) / ethers.toBigInt(365)) * day; + return toFixed2(ethers.formatUnits(income, 20), 4) || "0.00"; + } catch (error) { + return "0.00"; + } +}; + +// 計算已發放收益 +const calcReleasedIncome = (data: PledgeInfoType, currentTime: number) => { + try { + const day = Number(process.env.REACT_APP_DAY_TIME); + const startTime = data.startTime; + let curTime = currentTime; + if (data.endTime <= curTime) { + curTime = data.endTime; + } + const timeDifference = curTime - startTime; + const daysDifference = Math.floor(timeDifference / day); + if (daysDifference <= 0) return "0"; + const rate = toBigInt(data.rate); + const pledgeAmount = toWei(data.pledgeAmount); + const year = toBigInt(365); + const income = ((pledgeAmount * rate) / year) * toBigInt(daysDifference); + return toFixed2(ethers.formatUnits(income, 20), 4); + } catch (error) { + return "0.00"; + } +}; + +// 計算已提取收益 +const calcWithdrawnAmount = (data: PledgeInfoType) => { + try { + const day = Number(process.env.REACT_APP_DAY_TIME); + const startTime = data.startTime; + const withdrawTime = data.withdrawTime; + const timeDifference = withdrawTime - startTime; + const daysDifference = Math.floor(timeDifference / day); + if (daysDifference <= 0) return "0"; + const rate = toBigInt(data.rate); + const pledgeAmount = toWei(data.pledgeAmount); + const year = toBigInt(365); + const income = ((pledgeAmount * rate) / year) * toBigInt(daysDifference); + return toFixed2(ethers.formatUnits(income, 20), 4); + } catch (error) { + return "0.00"; + } +}; + +// 計算可提取收益 +const calcExtractableAmount = (data: PledgeInfoType, currentTime: number) => { + try { + const day = Number(process.env.REACT_APP_DAY_TIME); + const withdrawTime = data.withdrawTime; + let curTime = currentTime; + if (data.endTime <= curTime) { + curTime = data.endTime; + } + const timeDifference = curTime - withdrawTime; + const daysDifference = Math.floor(timeDifference / day); + if (daysDifference <= 0) return "0"; + const rate = toBigInt(data.rate); + const pledgeAmount = toWei(data.pledgeAmount); + const year = toBigInt(365); + const income = ((pledgeAmount * rate) / year) * toBigInt(daysDifference); + return toFixed2(ethers.formatUnits(income, 20), 4); + } catch (error) { + return "0.00"; + } +}; + +export { + splitAddress, + switchNetWork, + toThousands, + getTime, + toFixed2, + calcReleasedIncome, + calcIncome, + calcExtractableAmount, + calcWithdrawnAmount, +}; diff --git a/src/utils/sign/sign.ts b/src/utils/sign/sign.ts new file mode 100644 index 0000000..8d7fc3d --- /dev/null +++ b/src/utils/sign/sign.ts @@ -0,0 +1,22 @@ +const md5 = require('js-md5') +var signkey = process.env.REACT_APP_SIGN_KEY + +var signGenerator = (data: any) => { + + var keys = []; + for (var key in data) { + keys.push(key); + } + keys.sort(); + + var ptxt = ""; + for (var i = 0; i < keys.length; i++) { + ptxt += keys[i] + data[keys[i]]; + } + ptxt = signkey + ptxt + signkey; + + var signval = md5(ptxt).toLowerCase() + return signval; +} + +export default signGenerator; \ No newline at end of file diff --git a/src/utils/sign/sort.ts b/src/utils/sign/sort.ts new file mode 100644 index 0000000..9dbfee3 --- /dev/null +++ b/src/utils/sign/sort.ts @@ -0,0 +1,35 @@ +/* eslint-disable no-loop-func */ +var sortParam = (data: any) => { + var keys: any = []; + for (var key in data) { + keys.push(key); + } + + var ptxt = ""; + for (var i = 0; i < keys.length; i++) { + if (data[keys[i]] instanceof Array) { + if (i === 0) { + data[keys[i]].forEach((v: string, index: number) => { + if (index === 1) { + ptxt += keys[i] + "=" + v; + } else { + ptxt += "&" + keys[i] + "=" + v; + } + }); + } else { + data[keys[i]].forEach((v: any) => { + ptxt += "&" + keys[i] + "=" + v; + }); + } + } else { + if (i === 0) { + ptxt += keys[i] + "=" + data[keys[i]]; + } else { + ptxt += "&" + keys[i] + "=" + data[keys[i]]; + } + } + } + // console.log(ptxt); + return ptxt; +}; +export default sortParam; diff --git a/src/utils/wei.ts b/src/utils/wei.ts new file mode 100644 index 0000000..bfd019b --- /dev/null +++ b/src/utils/wei.ts @@ -0,0 +1,25 @@ +import { BigNumberish, ethers } from "ethers"; + +export const wei = { + Zero: ethers.toBigInt(0), + MaxUint256: ethers.toBigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), + MinInt256: ethers.toBigInt("-0x8000000000000000000000000000000000000000000000000000000000000000"), + MaxInt256: ethers.toBigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), + AddressZero: "0x0000000000000000000000000000000000000000", +} as any; + +export const toWei = (value: string) => { + return ethers.parseEther(value); +}; + +export const fromWei = (value: BigNumberish) => { + return ethers.formatEther(value); +}; + +export const toBigInt = (value: BigNumberish | Uint8Array) => { + return ethers.toBigInt(value) +}; + +export const toString = (value: BigNumberish, int?: number) => { + return ethers.formatUnits(value, int || 18); +}; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..2e447eb --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./src", + "target": "es5", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "paths": { + "~/*":["*"] + }, + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx" + }, + "include": [ + "src" + ] +}