-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* appky patch * change url for testing * update url * setup action * setup actions for testing * simulate new plugin
- Loading branch information
Showing
12 changed files
with
232 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<TransactionFilter> => { | ||
|
||
// 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<Address[]> => { | ||
// Given a specific chain we would expect this function to return a list of supported token addresses | ||
return [] | ||
} | ||
|
||
export const getSupportedChainIds = async (): Promise<number[]> => { | ||
// This should return all of the ChainIds that are supported by the Project we're integrating | ||
return [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MintActionParams> = { | ||
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 }), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "tsconfig/base.json", | ||
"include": ["src/**/*", "src/chain-data.ts"], | ||
"exclude": ["dist", "build", "node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.