diff --git a/packages/firsttest/README.md b/packages/firsttest/README.md new file mode 100644 index 000000000..f928de72c --- /dev/null +++ b/packages/firsttest/README.md @@ -0,0 +1,15 @@ +## FirstTest Plugin for Boost + +### New Plugin TODO list + +1. Find the ABI of the function your transaction is calling, and add export it as a const in the abi.ts file + 1. this can be multiple ABIs, if the transaction is calling multiple functions +2. in FirstTest.ts, fill out each Action function by mapping the ActionParams to the ABI of the function + + + +### Actions and Descriptions + + + +### Example Transactions \ No newline at end of file diff --git a/packages/firsttest/package.json b/packages/firsttest/package.json new file mode 100644 index 000000000..70d7669f3 --- /dev/null +++ b/packages/firsttest/package.json @@ -0,0 +1,42 @@ +{ + "name": "@rabbitholegg/questdk-plugin-firsttest", + "private": true, + "version": "1.0.0-alpha.0", + "type": "module", + "exports": { + "require": "./dist/cjs/index.js", + "import": "./dist/esm/index.js", + "types": "./dist/types/index.d.ts" + }, + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "description": "Plugin for firstTest", + "scripts": { + "bench": "vitest bench", + "bench:ci": "CI=true vitest bench", + "build": "pnpm run clean && pnpm run build:cjs && pnpm run build:esm && pnpm run build:types", + "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'", + "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir ./dist/esm && echo > ./dist/esm/package.json '{\"type\":\"module\",\"sideEffects\":false}'", + "build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap", + "clean": "rimraf dist", + "format": "rome format . --write", + "lint": "rome check .", + "lint:fix": "pnpm lint --apply", + "test": "vitest dev", + "test:cov": "vitest dev --coverage", + "test:ci": "CI=true vitest --coverage", + "test:ui": "vitest dev --ui" + }, + "keywords": [], + "author": "", + "license": "ISC", + "types": "./dist/types/index.d.ts", + "typings": "./dist/types/index.d.ts", + "devDependencies": { + "tsconfig": "workspace:*" + }, + "dependencies": { + "@rabbitholegg/questdk-plugin-utils": "workspace:*", + "@rabbitholegg/questdk": "workspace:*" + } +} diff --git a/packages/firsttest/plugin-details.yml b/packages/firsttest/plugin-details.yml new file mode 100644 index 000000000..97c01b02d --- /dev/null +++ b/packages/firsttest/plugin-details.yml @@ -0,0 +1,12 @@ +project: + name: FirstTest + iconOption: https://assets.coingecko.com/coins/images/6319/standard/usdc.png + appLink: https://firsttest.xyz + +task: + # action specific name, this is what will show as the default title for your boosts + name: Mint on FirstTest + # action specific link to your project. (ie: myapp.com/mint) + link: https://firsttest.xyz/mint + iconOption: https://assets.coingecko.com/coins/images/6319/standard/usdc.png + actionPluginId: mint diff --git a/packages/firsttest/src/FirstTest.test.ts b/packages/firsttest/src/FirstTest.test.ts new file mode 100644 index 000000000..44c3e58c8 --- /dev/null +++ b/packages/firsttest/src/FirstTest.test.ts @@ -0,0 +1,29 @@ +import { apply } from '@rabbitholegg/questdk/filter' +import { describe, expect, test } from 'vitest' +import { passingTestCases, failingTestCases } from './test-transactions' +import { mint } from './FirstTest' + +describe('Given the firsttest plugin', () => { + describe('When handling the mint action', () => { + + describe('should pass filter with valid transactions', () => { + passingTestCases.forEach((testCase) => { + const { transaction, description, params } = testCase + test(description, async () => { + const filter = await mint(params) + expect(apply(transaction, filter)).to.be.false + }) + }) + }) + + describe('should not pass filter with invalid transactions', () => { + failingTestCases.forEach((testCase) => { + const { transaction, description, params } = testCase + test(description, async () => { + const filter = await mint(params) + expect(apply(transaction, filter)).to.be.false + }) + }) + }) + }) +}) diff --git a/packages/firsttest/src/FirstTest.ts b/packages/firsttest/src/FirstTest.ts new file mode 100644 index 000000000..51d723339 --- /dev/null +++ b/packages/firsttest/src/FirstTest.ts @@ -0,0 +1,46 @@ +import { + type TransactionFilter, + type MintActionParams, + compressJson, +} from '@rabbitholegg/questdk' +import { type Address } from 'viem' + +/* + * Function templates for handling various blockchain action types. + * It's adaptable for actions defined in ActionParams: Bridge, Swap, Stake, Mint, Delegate, Quest, Etc. + * Duplicate and customize for each specific action type. + * If you wish to use a different action other than swap, import one of the ActionParams types + * from @rabbitholegg/questdk (ie: SwapActionParams) and change the function below to use + * the action params you wish to use. + */ + + export const mint = async(_params: MintActionParams): Promise => { + + // the ActionParams for this function are populated in the Boost Manager when the actual Boost is launched. + + // In this function you should load the ABI, and translate any ActionParams into the input object defined below + // which should match the parameter names in the transaction + + // You can also use the boostdk filter system to support operators on parameters, for example, greater than + + + // We always want to return a compressed JSON object which we'll transform into a TransactionFilter + return compressJson({ + chainId: '0x0', + to: '0x0', // The to field is the address of the contract we're interacting with + input: {}, // The input object is where we'll put the ABI and the parameters + }) + + } + +export const getSupportedTokenAddresses = async ( + _chainId: number, +): Promise => { + // Given a specific chain we would expect this function to return a list of supported token addresses + return [] +} + +export const getSupportedChainIds = async (): Promise => { + // This should return all of the ChainIds that are supported by the Project we're integrating + return [] +} diff --git a/packages/firsttest/src/index.ts b/packages/firsttest/src/index.ts new file mode 100644 index 000000000..821f8d1bb --- /dev/null +++ b/packages/firsttest/src/index.ts @@ -0,0 +1,16 @@ +import { + type IActionPlugin, +} from '@rabbitholegg/questdk' + +import { + mint, + getSupportedChainIds, + getSupportedTokenAddresses, +} from './FirstTest.js' + +export const FirstTest: IActionPlugin = { + pluginId: "firsttest", + getSupportedTokenAddresses, + getSupportedChainIds, + mint, +} diff --git a/packages/firsttest/src/test-transactions.ts b/packages/firsttest/src/test-transactions.ts new file mode 100644 index 000000000..c9791aacf --- /dev/null +++ b/packages/firsttest/src/test-transactions.ts @@ -0,0 +1,29 @@ +import { type MintActionParams } from '@rabbitholegg/questdk' +import { + createTestCase, + type TestParams, +} from '@rabbitholegg/questdk-plugin-utils' + +// values are placeholders, replace with actual values from your test transaction +export const MINT_TEST: TestParams = { + transaction: { + chainId: 1, + from: '0x0', + hash: '0x0', + input: '0x0', + to: '0x0', + value: '0', + }, + params: { + chainId: 0, + contractAddress: '0x0', + }, +} + +export const passingTestCases = [ + createTestCase(MINT_TEST, 'this is a demo test'), +] + +export const failingTestCases = [ + createTestCase(MINT_TEST, 'when chainId is not correct', { chainId: 99 }), +] diff --git a/packages/firsttest/tsconfig.build.json b/packages/firsttest/tsconfig.build.json new file mode 100644 index 000000000..9f29e5ec9 --- /dev/null +++ b/packages/firsttest/tsconfig.build.json @@ -0,0 +1,18 @@ +{ + "extends": "tsconfig/base.json", + "include": ["src"], + "exclude": [ + "src/**/*.test.ts", + "src/**/*.test-d.ts", + "src/**/*.bench.ts", + "src/_test", + "scripts/**/*" + ], + "compilerOptions": { + "declaration": true, + "declarationDir": "./dist/types", + "resolveJsonModule": true, + "sourceMap": true, + "rootDir": "./src" + } +} diff --git a/packages/firsttest/tsconfig.json b/packages/firsttest/tsconfig.json new file mode 100644 index 000000000..c76405177 --- /dev/null +++ b/packages/firsttest/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "tsconfig/base.json", + "include": ["src/**/*", "src/chain-data.ts"], + "exclude": ["dist", "build", "node_modules"] +} diff --git a/packages/registry/package.json b/packages/registry/package.json index e78759a42..3a91cf47a 100644 --- a/packages/registry/package.json +++ b/packages/registry/package.json @@ -68,6 +68,7 @@ "@rabbitholegg/questdk-plugin-llama": "workspace:*", "@rabbitholegg/questdk-plugin-boost": "workspace:*", "@rabbitholegg/questdk-plugin-kote": "workspace:*", - "@rabbitholegg/questdk-plugin-jojo": "workspace:*" + "@rabbitholegg/questdk-plugin-jojo": "workspace:*", + "@rabbitholegg/questdk-plugin-firsttest": "workspace:*" } } diff --git a/packages/registry/src/index.ts b/packages/registry/src/index.ts index 38eaee780..9d634f7e5 100644 --- a/packages/registry/src/index.ts +++ b/packages/registry/src/index.ts @@ -31,6 +31,7 @@ import { Vela } from '@rabbitholegg/questdk-plugin-vela' import { WooFi } from '@rabbitholegg/questdk-plugin-woofi' import { Zora } from '@rabbitholegg/questdk-plugin-zora' import { JOJO } from '@rabbitholegg/questdk-plugin-jojo' +import { FirstTest } from '@rabbitholegg/questdk-plugin-firsttest' import { ENTRYPOINT } from './contract-addresses' import { type IntentParams, @@ -85,6 +86,7 @@ export const plugins: Record = { [Llama.pluginId]: Llama, [Kote.pluginId]: Kote, [JOJO.pluginId]: JOJO, + [FirstTest.pluginId]: FirstTest, } export const getPlugin = (pluginId: string) => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5313bad21..dc077a048 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -219,6 +219,19 @@ importers: specifier: workspace:* version: link:../tsconfig + packages/firsttest: + dependencies: + '@rabbitholegg/questdk': + specifier: workspace:* + version: link:../../apps/questdk + '@rabbitholegg/questdk-plugin-utils': + specifier: workspace:* + version: link:../utils + devDependencies: + tsconfig: + specifier: workspace:* + version: link:../tsconfig + packages/gmx: dependencies: '@rabbitholegg/questdk': @@ -458,6 +471,9 @@ importers: '@rabbitholegg/questdk-plugin-connext': specifier: workspace:* version: link:../connext + '@rabbitholegg/questdk-plugin-firsttest': + specifier: workspace:* + version: link:../firsttest '@rabbitholegg/questdk-plugin-gmx': specifier: workspace:* version: link:../gmx