diff --git a/.github/workflow.yaml b/.github/workflow.yaml new file mode 100644 index 0000000..b0f1175 --- /dev/null +++ b/.github/workflow.yaml @@ -0,0 +1,32 @@ +name: Bun Script Execution + +on: + #push: # Trigger on push events to master branch (you can adjust this trigger) + workflow_dispatch: # Trigger on manual workflow dispatch + +jobs: + run-bun-script: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + + - name: Get Parameters (for push event) + if: github.event_name == 'push' + run: | + # No parameters are automatically provided on push events + echo "No parameters provided on push event." + + - name: Get Parameters (for manual trigger) + if: github.event_name == 'workflow_dispatch' + run: | + PARAM_VALUE_1=${{ github.event.inputs.param1 }} + PARAM_VALUE_2=${{ github.event.inputs.param2 }} + # ... add more parameter retrieval as needed + # Use empty strings if parameters are not provided + + - name: Run Bun Script + run: bun run index.ts --param1 $PARAM_VALUE_1 --param2 $PARAM_VALUE_2 + # Adjust the command based on your parameter names and flags \ No newline at end of file diff --git a/CI/.gitignore b/CI/.gitignore new file mode 100644 index 0000000..9b1ee42 --- /dev/null +++ b/CI/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/CI/README.md b/CI/README.md new file mode 100644 index 0000000..957cf82 --- /dev/null +++ b/CI/README.md @@ -0,0 +1,15 @@ +# ci + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.1.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/CI/bun.lockb b/CI/bun.lockb new file mode 100644 index 0000000..da8a37c Binary files /dev/null and b/CI/bun.lockb differ diff --git a/CI/index.ts b/CI/index.ts new file mode 100644 index 0000000..ced3f58 --- /dev/null +++ b/CI/index.ts @@ -0,0 +1,23 @@ +import { YupAPI } from 'yup-api-interact' + + +const args = Bun.argv.slice(3); + +const secrets = JSON.parse(args[0]); +const githubEvvent = JSON.parse(args[1]); +const action = args[2] + + +const main = async () => { + const YUP_PK = secrets.YUP_PK; + + const api = new YupAPI({ PK: YUP_PK, token: '' }); + + if(action === 'commit') { + console.log('Announcing commit') + console.log(secrets, githubEvvent) + } + +} + +main().catch(console.error); diff --git a/CI/package.json b/CI/package.json new file mode 100644 index 0000000..8ee1623 --- /dev/null +++ b/CI/package.json @@ -0,0 +1,15 @@ +{ + "name": "ci", + "module": "index.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "yup-api-interact": "^0.1.4", + "farcaster-hub-utils": "https://github.com/andrei0x309/farcaster-hub-utils#main" + } +} \ No newline at end of file diff --git a/CI/tsconfig.json b/CI/tsconfig.json new file mode 100644 index 0000000..238655f --- /dev/null +++ b/CI/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +} diff --git a/src/App.vue b/src/App.vue index ad2e7c3..873da60 100644 --- a/src/App.vue +++ b/src/App.vue @@ -31,40 +31,38 @@ export default defineComponent({ if (chrome.runtime.lastError) { console.info("Error receiving message:", chrome.runtime.lastError); } - if (message?.type !== "CLWALLET_PAGE_MSG") { - return true; - } + if (message?.type === "CLWALLET_PAGE_MSG") { + console.info("page listener:", message); - console.info("page listener:", message); - - (async () => { - if (!message?.method) { - sendResponse({ - code: 500, - message: "Invalid request method", - }); - } else { - // ETH API - switch (message.method) { - case "paste": { - const currentAddress = (await getSelectedAddress()) as string[]; - if (currentAddress.length > 0) { - document.execCommand("insertText", false, currentAddress[0]); + (async () => { + if (!message?.method) { + sendResponse({ + code: 500, + message: "Invalid request method", + }); + } else { + // ETH API + switch (message.method) { + case "paste": { + const currentAddress = (await getSelectedAddress()) as string[]; + if (currentAddress.length > 0) { + document.execCommand("insertText", false, currentAddress[0]); + } + sendResponse(true); + break; + } + default: { + sendResponse({ + error: true, + message: + "ClearWallet: Invalid PAGE request method " + (message?.method ?? ""), + }); + break; } - sendResponse(true); - break; - } - default: { - sendResponse({ - error: true, - message: - "ClearWallet: Invalid PAGE request method " + (message?.method ?? ""), - }); - break; } } - } - })(); + })(); + } return true; }; diff --git a/src/extension/content.ts b/src/extension/content.ts index 0be9501..6132722 100644 --- a/src/extension/content.ts +++ b/src/extension/content.ts @@ -66,7 +66,7 @@ window.addEventListener("message", (event) => { }, } if(event?.data?.data?.data?.method !== 'eth_chainId') { - // console.info('data out', data) + console.info('data out', data) } window.postMessage(data, "*"); diff --git a/src/extension/inject.ts b/src/extension/inject.ts index 0736c53..f379f6c 100644 --- a/src/extension/inject.ts +++ b/src/extension/inject.ts @@ -101,7 +101,7 @@ const sendMessage = (args: RequestArguments, ping = false, from = 'request'): Pr data.type = 'CLWALLET_PING' } if(method!== 'eth_chainId') { - // console.info('data in', data) + console.info('data in', data) } window.postMessage(data, "*"); diff --git a/src/extension/serviceWorker.ts b/src/extension/serviceWorker.ts index 921b6e4..3ac7c10 100644 --- a/src/extension/serviceWorker.ts +++ b/src/extension/serviceWorker.ts @@ -630,12 +630,6 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an sendResponse(false) break } - case 'net_version': { - const network = await getSelectedNetwork() - const chainId = String(network?.chainId ?? 1) - sendResponse(chainId) - break - } case 'wallet_switchEthereumChain': { try { const currentChainId = `0x${((await getSelectedNetwork())?.chainId ?? 0).toString(16)}`