From 77d5274cf8b290d9f6f5fb4787d9c54f2e43ba47 Mon Sep 17 00:00:00 2001 From: Layne Haber Date: Thu, 21 Mar 2024 11:12:33 -0600 Subject: [PATCH 1/2] feat: package creation --- adapters/connext/package.json | 26 ++++ adapters/connext/src/index.ts | 4 + adapters/connext/tsconfig.json | 110 ++++++++++++++ adapters/connext/yarn.lock | 268 +++++++++++++++++++++++++++++++++ 4 files changed, 408 insertions(+) create mode 100644 adapters/connext/package.json create mode 100644 adapters/connext/src/index.ts create mode 100644 adapters/connext/tsconfig.json create mode 100644 adapters/connext/yarn.lock diff --git a/adapters/connext/package.json b/adapters/connext/package.json new file mode 100644 index 00000000..bf294bae --- /dev/null +++ b/adapters/connext/package.json @@ -0,0 +1,26 @@ +{ + "name": "connext-calculator", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node dist/index.js", + "dev": "ts-node src/index.ts", + "compile": "tsc", + "watch": "tsc -w", + "clear": "rm -rf dist" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "fast-csv": "5.0.1", + "viem": "2.8.16" + }, + "devDependencies": { + "@types/node": "20.11.30", + "ts-node": "10.9.2", + "typescript": "5.4.3" + } +} \ No newline at end of file diff --git a/adapters/connext/src/index.ts b/adapters/connext/src/index.ts new file mode 100644 index 00000000..80e86e3e --- /dev/null +++ b/adapters/connext/src/index.ts @@ -0,0 +1,4 @@ +const main = () => { + console.log('Hello, world!'); +} +main(); \ No newline at end of file diff --git a/adapters/connext/tsconfig.json b/adapters/connext/tsconfig.json new file mode 100644 index 00000000..d995394b --- /dev/null +++ b/adapters/connext/tsconfig.json @@ -0,0 +1,110 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs" /* Specify what module code is generated. */, + "rootDir": "src/" /* Specify the root folder within your source files. */, + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + "resolveJsonModule": true /* Enable importing .json files. */, + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "dist/" /* Specify an output folder for all emitted files. */, + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } + } + \ No newline at end of file diff --git a/adapters/connext/yarn.lock b/adapters/connext/yarn.lock new file mode 100644 index 00000000..b1dce919 --- /dev/null +++ b/adapters/connext/yarn.lock @@ -0,0 +1,268 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@adraffy/ens-normalize@1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" + integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== + +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + +"@fast-csv/format@5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@fast-csv/format/-/format-5.0.0.tgz#f2e557fdd4370360b418cc78636684c07b12d0ba" + integrity sha512-IyMpHwYIOGa2f0BJi6Wk55UF0oBA5urdIydoEDYxPo88LFbeb3Yr4rgpu98OAO1glUWheSnNtUgS80LE+/dqmw== + dependencies: + lodash.escaperegexp "^4.1.2" + lodash.isboolean "^3.0.3" + lodash.isequal "^4.5.0" + lodash.isfunction "^3.0.9" + lodash.isnil "^4.0.0" + +"@fast-csv/parse@5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@fast-csv/parse/-/parse-5.0.0.tgz#091665753f9e58f0dda6a55ae30f582526042903" + integrity sha512-ecF8tCm3jVxeRjEB6VPzmA+1wGaJ5JgaUX2uesOXdXD6qQp0B3EdshOIed4yT1Xlj/F2f8v4zHSo0Oi31L697g== + dependencies: + lodash.escaperegexp "^4.1.2" + lodash.groupby "^4.6.0" + lodash.isfunction "^3.0.9" + lodash.isnil "^4.0.0" + lodash.isundefined "^3.0.1" + lodash.uniq "^4.5.0" + +"@jridgewell/resolve-uri@^3.0.3": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" + integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + +"@noble/curves@1.2.0", "@noble/curves@~1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" + integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== + dependencies: + "@noble/hashes" "1.3.2" + +"@noble/hashes@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" + integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== + +"@noble/hashes@~1.3.0", "@noble/hashes@~1.3.2": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" + integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== + +"@scure/base@~1.1.0", "@scure/base@~1.1.2": + version "1.1.6" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.6.tgz#8ce5d304b436e4c84f896e0550c83e4d88cb917d" + integrity sha512-ok9AWwhcgYuGG3Zfhyqg+zwl+Wn5uE+dwC0NV/2qQkx4dABbb/bx96vWu8NSj+BNjjSjno+JRYRjle1jV08k3g== + +"@scure/bip32@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.2.tgz#90e78c027d5e30f0b22c1f8d50ff12f3fb7559f8" + integrity sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA== + dependencies: + "@noble/curves" "~1.2.0" + "@noble/hashes" "~1.3.2" + "@scure/base" "~1.1.2" + +"@scure/bip39@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.1.tgz#5cee8978656b272a917b7871c981e0541ad6ac2a" + integrity sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg== + dependencies: + "@noble/hashes" "~1.3.0" + "@scure/base" "~1.1.0" + +"@tsconfig/node10@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" + integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" + integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== + +"@types/node@20.11.30": + version "20.11.30" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.30.tgz#9c33467fc23167a347e73834f788f4b9f399d66f" + integrity sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw== + dependencies: + undici-types "~5.26.4" + +abitype@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.0.tgz#237176dace81d90d018bebf3a45cb42f2a2d9e97" + integrity sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ== + +acorn-walk@^8.1.1: + version "8.3.2" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa" + integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A== + +acorn@^8.4.1: + version "8.11.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" + integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +fast-csv@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/fast-csv/-/fast-csv-5.0.1.tgz#2beaa2437ea83bd335cc3a39a41e69d9936f3987" + integrity sha512-Q43zC4NdQD5MAWOVQOF8KA+D6ddvTJjX2ib8zqysm74jZhtk6+dc8C75/OqRV6Y9CLc4kgvbC3PLG8YL4YZfgw== + dependencies: + "@fast-csv/format" "5.0.0" + "@fast-csv/parse" "5.0.0" + +isows@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74" + integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg== + +lodash.escaperegexp@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz#64762c48618082518ac3df4ccf5d5886dae20347" + integrity sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw== + +lodash.groupby@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.groupby/-/lodash.groupby-4.6.0.tgz#0b08a1dcf68397c397855c3239783832df7403d1" + integrity sha512-5dcWxm23+VAoz+awKmBaiBvzox8+RqMgFhi7UvX9DHZr2HdxHXM/Wrf8cfKpsW37RNrvtPn6hSwNqurSILbmJw== + +lodash.isboolean@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" + integrity sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg== + +lodash.isequal@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" + integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ== + +lodash.isfunction@^3.0.9: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051" + integrity sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw== + +lodash.isnil@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/lodash.isnil/-/lodash.isnil-4.0.0.tgz#49e28cd559013458c814c5479d3c663a21bfaa6c" + integrity sha512-up2Mzq3545mwVnMhTDMdfoG1OurpA/s5t88JmQX809eH3C8491iu2sfKhTfhQtKY78oPNhiaHJUpT/dUDAAtng== + +lodash.isundefined@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz#23ef3d9535565203a66cefd5b830f848911afb48" + integrity sha512-MXB1is3s899/cD8jheYYE2V9qTHwKvt+npCwpD+1Sxm3Q3cECXCiYHjeHWXNwr6Q0SOBPrYUDxendrO6goVTEA== + +lodash.uniq@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" + integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ== + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +ts-node@10.9.2: + version "10.9.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" + integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" + yn "3.1.1" + +typescript@5.4.3: + version "5.4.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.3.tgz#5c6fedd4c87bee01cd7a528a30145521f8e0feff" + integrity sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg== + +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + +viem@2.8.16: + version "2.8.16" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.8.16.tgz#30370390a6f109657b57c1a01b2793c4056b4e95" + integrity sha512-J8tu1aP7TfI2HT/IEmyJ+n+WInrA/cuMuJtfgvYhYgHBobxhYGc2SojHm5lZBWcWgErN1Ld7VcKUwTmPh4ToQA== + dependencies: + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@scure/bip32" "1.3.2" + "@scure/bip39" "1.2.1" + abitype "1.0.0" + isows "1.0.3" + ws "8.13.0" + +ws@8.13.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== From 0af98697071a677a231c75aa09da4170d4e48866 Mon Sep 17 00:00:00 2001 From: Layne Haber Date: Thu, 21 Mar 2024 12:27:50 -0600 Subject: [PATCH 2/2] feat: working script --- adapters/connext/output.csv | 22 +++ adapters/connext/src/index.ts | 24 +++- adapters/connext/src/utils/csv.ts | 18 +++ .../connext/src/utils/getUserTvlByBlock.ts | 22 +++ adapters/connext/src/utils/index.ts | 3 + adapters/connext/src/utils/subgraph.ts | 129 ++++++++++++++++++ adapters/connext/src/utils/types.ts | 35 +++++ 7 files changed, 250 insertions(+), 3 deletions(-) create mode 100644 adapters/connext/output.csv create mode 100644 adapters/connext/src/utils/csv.ts create mode 100644 adapters/connext/src/utils/getUserTvlByBlock.ts create mode 100644 adapters/connext/src/utils/index.ts create mode 100644 adapters/connext/src/utils/subgraph.ts create mode 100644 adapters/connext/src/utils/types.ts diff --git a/adapters/connext/output.csv b/adapters/connext/output.csv new file mode 100644 index 00000000..7561052a --- /dev/null +++ b/adapters/connext/output.csv @@ -0,0 +1,22 @@ +block_number,timestamp,user_address,token_address,token_balance,token_symbol,usd_price +2954869,1710677449,0x04329901a291484bc461b3b61629389cd0a020df,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,1210808254917845817425,LP,0 +2668299,1709531117,0x2ad41b63cf636c794c37293fb8b7613331774e1d,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,55393817407803314274,LP,0 +1022900,1701338640,0x2ba4b2effba90779ca446f2e60e7eef4a707d925,0x611c91c807c07b4d358224fb5dcd3999f36167b3,13995840654870840741,LP,0 +2531745,1708984899,0x2e47bbd27cf07be8b3c3e46a4f406fc60bb59335,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,492750038786035498752,LP,0 +2916886,1710525538,0x4df23313d32b33223d18e1f7437f269d92ed3dd6,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,188,LP,0 +1037985,1701459356,0x5d527765252003acee6545416f6a9c8d15ae8402,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,39968772378383533027145,LP,0 +2953912,1710673621,0x7231fef69df4648448805c28a79945dd30576372,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,988991644100367474966,LP,0 +1713112,1705588962,0x73b6a7a6e39a2e405087164d7f407a0bd2c86dcc,0x611c91c807c07b4d358224fb5dcd3999f36167b3,4993416443158320,LP,0 +2288998,1708013774,0x7c8e34d9d5c1e2c40e8860c4511cc132ecb3fa8c,0x611c91c807c07b4d358224fb5dcd3999f36167b3,1795901903915358,LP,0 +1952553,1706661478,0x7ce49752ffa7055622f444df3c69598748cb2e5f,0x611c91c807c07b4d358224fb5dcd3999f36167b3,412,LP,0 +2776301,1709963126,0x8d6e361347f7dd8f297a3396098dd4343f5bbb45,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,988980051251840569,LP,0 +2524689,1708956675,0x998e4a86fc6352037b57f087e60ee816d4d25c16,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,21082536722635166248,LP,0 +905571,1700399991,0xade09131c6f43fe22c2cbabb759636c43cfc181e,0x611c91c807c07b4d358224fb5dcd3999f36167b3,40000000000000000,LP,0 +964221,1700869352,0xade09131c6f43fe22c2cbabb759636c43cfc181e,0xfb8a9f8b13a6d297a1478af67bde98362be532d6,10217539492437286544516,LP,0 +1000729,1701161360,0xade09131c6f43fe22c2cbabb759636c43cfc181e,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,222543182923056325812,LP,0 +2890430,1710419642,0xd84076087f8045dcfb78443930423fc366bd79a7,0x611c91c807c07b4d358224fb5dcd3999f36167b3,87,LP,0 +2511076,1708902223,0xe0c46719ed5c9d8b2f2f69652a72304aabddd756,0xfb8a9f8b13a6d297a1478af67bde98362be532d6,0,LP,0 +2952998,1710669965,0xe5cec7bb5e90ed2548414d49ceb5e5d89f847295,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,718957933202566179473,LP,0 +2883051,1710390126,0xe603b396503f312f61be2851f4c1b8783d7c1ea6,0x611c91c807c07b4d358224fb5dcd3999f36167b3,495449646078743738973,LP,0 +1157826,1702256219,0xfa53b8cca72c61794ebac3d54b54554aa0f4229d,0xfb8a9f8b13a6d297a1478af67bde98362be532d6,296389691962740119956,LP,0 +2873152,1710350530,0xfd9da5905ff0eaf8e7748fd3efab9a2404ad798b,0x66be8926aa5cbdf24f07560d36999bf9b6b2bb87,2957602281459175118717,LP,0 \ No newline at end of file diff --git a/adapters/connext/src/index.ts b/adapters/connext/src/index.ts index 80e86e3e..9aa53082 100644 --- a/adapters/connext/src/index.ts +++ b/adapters/connext/src/index.ts @@ -1,4 +1,22 @@ -const main = () => { - console.log('Hello, world!'); +import { getUserTVLByBlock, writeCsv } from "./utils"; + +const input = { + blockNumber: 2954869, + blockTimestamp: 1711044141, } -main(); \ No newline at end of file + +const fileName = 'output.csv'; +console.log('Getting TVL at block:', input.blockNumber); + + +// returns all user balances at the input block by looking at the latest +// balance for each user and token on the subgraph, capped at given block. +getUserTVLByBlock(input).then((data) => { + if (data.length === 0) { + console.log("no data to write to file"); + return; + } + writeCsv(data, fileName).then(() => { + console.log('CSV written to file:', fileName); + }) +}); \ No newline at end of file diff --git a/adapters/connext/src/utils/csv.ts b/adapters/connext/src/utils/csv.ts new file mode 100644 index 00000000..1e7a8547 --- /dev/null +++ b/adapters/connext/src/utils/csv.ts @@ -0,0 +1,18 @@ +import { createWriteStream } from 'fs'; +import { format } from '@fast-csv/format'; + +// writes csv from object array with keys as headers +export const writeCsv = async (data: T[], filename: string): Promise => { + const stream = format({ headers: true }); + const output = createWriteStream(filename); + + const completed = new Promise((resolve, reject) => { + stream.pipe(output).on('end', resolve).on('error', reject); + }); + // console.log("writing csv to file:", filename); + data.map((row) => stream.write(row)); + await completed; + stream.end(); + // console.log("csv written to file:", filename); + return; +} \ No newline at end of file diff --git a/adapters/connext/src/utils/getUserTvlByBlock.ts b/adapters/connext/src/utils/getUserTvlByBlock.ts new file mode 100644 index 00000000..0a1dc757 --- /dev/null +++ b/adapters/connext/src/utils/getUserTvlByBlock.ts @@ -0,0 +1,22 @@ +import { parseUnits } from "viem"; +import { getLpAccountBalanceAtBlock } from "./subgraph"; +import { BlockData, OutputDataSchemaRow } from "./types"; + +export const getUserTVLByBlock = async (blocks: BlockData): Promise => { + const { blockNumber } = blocks + + const data = await getLpAccountBalanceAtBlock(blockNumber); + + return data.map(d => { + return { + block_number: +d.block, + timestamp: +d.modified, + user_address: d.account.id, + token_address: d.token.id, + token_balance: BigInt(parseUnits(d.amount, 18)), + token_symbol: d.token.symbol, + usd_price: 0 + } + }) +}; + diff --git a/adapters/connext/src/utils/index.ts b/adapters/connext/src/utils/index.ts new file mode 100644 index 00000000..25d61e1a --- /dev/null +++ b/adapters/connext/src/utils/index.ts @@ -0,0 +1,3 @@ +export * from "./csv"; +export * from "./getUserTvlByBlock"; +export * from "./types"; \ No newline at end of file diff --git a/adapters/connext/src/utils/subgraph.ts b/adapters/connext/src/utils/subgraph.ts new file mode 100644 index 00000000..9c6a4cc1 --- /dev/null +++ b/adapters/connext/src/utils/subgraph.ts @@ -0,0 +1,129 @@ +import { LpAccountBalanceHourly, SubgraphResult } from "./types"; + +export const CONNEXT_SUBGRAPH_QUERY_URL = "https://api.goldsky.com/api/public/project_clssc64y57n5r010yeoly05up/subgraphs/amarok-stableswap-analytics/1.0/gn"; + +const LP_HOURLY_QUERY_BY_BLOCK = ( + first: number, + offset: number, + blockNumber: number +): string => ` + query LpAccountBalanceHourly { + lpAccountBalanceHourlies(first: ${first}, offset: ${offset}, where: { block_lte: ${blockNumber} }) { + amount + account { + id + } + modified + block + token { + id + symbol + } + } + } +` + +const LP_HOURLY_QUERY_BY_TIMESTAMP = ( + first: number, + offset: number, + timestamp: number +): string => ` + query LpAccountBalanceHourly { + lpAccountBalanceHourlies(first: ${first}, offset: ${offset}, where: { modified_lte: ${timestamp} }) { + amount + account { + id + } + modified + block + token { + id + symbol + } + } + } +` + +const executeSubgraphQuery = async (query: string): Promise => { + const response = await fetch(CONNEXT_SUBGRAPH_QUERY_URL, { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify({ query }), + }); + const { + data + } = await response.json() as { data: SubgraphResult }; + return data; +} + +export const getLpAccountBalanceAtBlock = async (block: number, interval = 1000): Promise => { + let hasMore = true; + let offset = 0; + const balances = new Map() + + while (hasMore) { + const { + lpAccountBalanceHourlies + } = await executeSubgraphQuery(LP_HOURLY_QUERY_BY_BLOCK(interval, offset, block)) + appendSubgraphData(lpAccountBalanceHourlies, balances); + hasMore = lpAccountBalanceHourlies.length === interval; + offset += interval; + } + return [...balances.values()].flat(); +} + +export const getLpAccountBalanceAtTimestamp = async (timestamp: number, interval = 1000): Promise => { + let hasMore = true; + let offset = 0; + const balances = new Map() + + while (hasMore) { + const { + lpAccountBalanceHourlies + } = await executeSubgraphQuery(LP_HOURLY_QUERY_BY_TIMESTAMP(interval, offset, timestamp)) + appendSubgraphData(lpAccountBalanceHourlies, balances); + hasMore = lpAccountBalanceHourlies.length === interval; + offset += interval; + } + + + return [...balances.values()].flat(); +} + +const appendSubgraphData = (data: LpAccountBalanceHourly[], existing: Map) => { + // looking for latest record of account balance + data.forEach(d => { + // if there is no tally for account, set and continue + if (!existing.has(d.account.id.toLowerCase())) { + existing.set(d.account.id.toLowerCase(), [d]); + return; + } + + // if there is an existing entry for the account, use the latest record for given asset + const existingData = existing.get(d.account.id.toLowerCase())!; + // get user asset entry if exists + const assetIdx = existingData.findIndex(e => e.token.id.toLowerCase() === d.token.id.toLowerCase()); + if (assetIdx < 0) { + // data is latest for asset + existing.set(d.account.id.toLowerCase(), [...existingData, d]); + return; + } + + // if existing data is latest, do nothing + if (+existingData[assetIdx].modified > +d.modified) { + return; + } + + // update the latest record + existing.set( + d.account.id.toLowerCase(), + existingData.filter((_, idx) => idx !== assetIdx).concat([d]) + ); + return existing; + + }) +} + diff --git a/adapters/connext/src/utils/types.ts b/adapters/connext/src/utils/types.ts new file mode 100644 index 00000000..925ea22c --- /dev/null +++ b/adapters/connext/src/utils/types.ts @@ -0,0 +1,35 @@ +// Function inputs +export interface BlockData { + blockNumber: number; + blockTimestamp: number; +} + +// Outputs +export type OutputDataSchemaRow = { + block_number: number; + timestamp: number; + user_address: string; + token_address: string; + token_balance: bigint; + token_symbol: string; // token symbol should be empty string if it is not available + usd_price: number; // assign 0 if not available +}; + +// Subgraph entity +export type LpAccountBalanceHourly = { + amount: string; + account: { + id: string; + } + modified: string; + block: string; + token: { + id: string; + symbol: string; + } +} + +// Subgraph query result +export type SubgraphResult = { + lpAccountBalanceHourlies: LpAccountBalanceHourly[]; +} \ No newline at end of file