Skip to content

Commit

Permalink
Merge pull request #103 from pimlicolabs/feat/wagmi
Browse files Browse the repository at this point in the history
wagmi connector
  • Loading branch information
plusminushalf authored Jan 30, 2024
2 parents f4e2b4b + b9d43c1 commit 84f6461
Show file tree
Hide file tree
Showing 28 changed files with 488 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-ants-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@permissionless/wagmi": patch
---

First release with smartAccount connector
2 changes: 2 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ runs:
steps:
- name: Set up Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.25

- name: Set up foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,28 @@ jobs:
with:
registry-url: 'https://registry.npmjs.org'

- name: Set version
- name: Set permissionless version
run: |
jq --arg prop "workspaces" 'del(.[$prop])' package.json > package.tmp.json && rm package.json && cp package.tmp.json package.json && rm package.tmp.json
cd packages/permissionless
npm --no-git-tag-version version 0.0.0
npm --no-git-tag-version version $(npm pkg get version | sed 's/"//g')-$(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//').$(date +'%Y%m%dT%H%M%S')
- name: Set permissionless/wagmi version
run: |
cd packages/wagmi
npm --no-git-tag-version version 0.0.0
npm --no-git-tag-version version $(npm pkg get version | sed 's/"//g')-$(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//').$(date +'%Y%m%dT%H%M%S')
- name: Build
run: bun run build

- name: Publish to npm
- name: Publish permissionless to npm
run: cd packages/permissionless && npm publish --tag $(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish permissionless/wagmi to npm
run: cd packages/wagmi && npm publish --tag $(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_PERMISSIONLESS_TOKEN }}
41 changes: 38 additions & 3 deletions .github/workflows/prune-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
with:
registry-url: 'https://registry.npmjs.org'

- name: Prune tags
- name: Prune permissionless tags
run: |
PACKAGE_NAME=$(jq -r '.name' package.json)
npm view $PACKAGE_NAME dist-tags --json | jq -r 'to_entries | .[] | select(.key != "latest") | select(.key != "main") | select(.key != "next") | .key' | xargs -I % npm dist-tag rm $PACKAGE_NAME %
working-directory: packages/permissionless
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Deprecate canary versions
- name: Deprecate permissionless canary versions
working-directory: packages/permissionless
run: |
PACKAGE_NAME=$(jq -r '.name' package.json)
Expand All @@ -42,7 +42,42 @@ jobs:
VERSION=$(echo $line | jq -r '.key')
TIME=$(echo $line | jq -r '.value')
PUBLISH_DATE=$(date --date=$TIME +%s)
if [ $PUBLISH_DATE -lt $FOUR_DAYS_AGO ]; then
continue # skip versions older than 4 days to reduce the number of npm deprecate calls
fi
if [ $PUBLISH_DATE -lt $TWO_DAYS_AGO ]; then
echo "Deprecate $PACKAGE_NAME@$VERSION"
npm deprecate $PACKAGE_NAME@$VERSION "This canary version is deprecated because it is older than 2 days." || true
echo "Deprecated $PACKAGE_NAME@$VERSION"
fi
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Prune @permissionless/wagmi tags
run: |
PACKAGE_NAME=$(jq -r '.name' package.json)
npm view $PACKAGE_NAME dist-tags --json | jq -r 'to_entries | .[] | select(.key != "latest") | select(.key != "main") | select(.key != "next") | .key' | xargs -I % npm dist-tag rm $PACKAGE_NAME %
working-directory: packages/wagmi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Deprecate @permissionless/wagmi canary versions
working-directory: packages/wagmi
run: |
PACKAGE_NAME=$(jq -r '.name' package.json)
TWO_DAYS_AGO=$(date --date='2 days ago' +%s)
FOUR_DAYS_AGO=$(date --date='4 days ago' +%s)
npm view $PACKAGE_NAME time --json | jq -c 'to_entries | .[] | select(.key | test("^0.0.0-.+$"))' \
| while read line; do
VERSION=$(echo $line | jq -r '.key')
TIME=$(echo $line | jq -r '.value')
PUBLISH_DATE=$(date --date=$TIME +%s)
if [ $PUBLISH_DATE -lt $FOUR_DAYS_AGO ]; then
continue # skip versions older than 4 days to reduce the number of npm deprecate calls
fi
Expand Down
Binary file modified bun.lockb
Binary file not shown.
19 changes: 13 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
"keywords": [],
"license": "MIT",
"scripts": {
"build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types",
"build:cjs": "tsc --project ./tsconfig.cjs.json && tsc-alias -p ./tsconfig.cjs.json && printf '{\"type\":\"commonjs\"}' > ./packages/permissionless/_cjs/package.json",
"build:esm": "tsc --project ./tsconfig.esm.json && tsc-alias -p ./tsconfig.esm.json && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./packages/permissionless/_esm/package.json",
"build:types": "tsc --project ./tsconfig.types.json && tsc-alias -p ./tsconfig.types.json",
"clean": "rimraf ./packages/permissionless/_esm ./packages/permissionless/_cjs ./packages/permissionless/_types",
"build": "bun run build:permissionless && bun run build:wagmi",
"build:permissionless": "bun run clean:permissionless && bun run build:cjs && bun run build:esm && bun run build:types",
"build:wagmi": "bun run clean:wagmi && bun run build:wagmi:cjs && bun run build:wagmi:esm && bun run build:wagmi:types",
"build:cjs": "tsc --project ./tsconfig/tsconfig.permissionless.cjs.json && tsc-alias -p ./tsconfig/tsconfig.permissionless.cjs.json && printf '{\"type\":\"commonjs\"}' > ./packages/permissionless/_cjs/package.json",
"build:esm": "tsc --project ./tsconfig/tsconfig.permissionless.esm.json && tsc-alias -p ./tsconfig/tsconfig.permissionless.esm.json && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./packages/permissionless/_esm/package.json",
"build:types": "tsc --project ./tsconfig/tsconfig.permissionless.types.json && tsc-alias -p ./tsconfig/tsconfig.permissionless.types.json",
"clean": "bun run clean:permissionless && bun run clean:wagmi",
"clean:permissionless": "rimraf ./packages/permissionless/_esm ./packages/permissionless/_cjs ./packages/permissionless/_types",
"clean:wagmi": "rimraf ./packages/wagmi/_esm ./packages/wagmi/_cjs ./packages/wagmi/_types",
"changeset": "changeset",
"changeset:release": "bun run build && changeset publish",
"changeset:version": "changeset version && bun install --lockfile-only",
Expand All @@ -35,7 +39,10 @@
"lint:fix": "bun run lint --apply",
"test": "vitest dev -c ./packages/permissionless-test/vitest.config.ts",
"test:ci": "CI=true vitest -c ./packages/permissionless-test/vitest.config.ts --coverage",
"run:demo": "bun run --cwd packages/wagmi-demo dev"
"run:demo": "bun run --cwd packages/wagmi-demo dev",
"build:wagmi:cjs": "tsc --project ./tsconfig/tsconfig.wagmi.cjs.json && tsc-alias -p ./tsconfig/tsconfig.wagmi.cjs.json && printf '{\"type\":\"commonjs\"}' > ./packages/wagmi/_cjs/package.json",
"build:wagmi:esm": "tsc --project ./tsconfig/tsconfig.wagmi.esm.json && tsc-alias -p ./tsconfig/tsconfig.wagmi.esm.json && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./packages/wagmi/_esm/package.json",
"build:wagmi:types": "tsc --project ./tsconfig/tsconfig.wagmi.types.json && tsc-alias -p ./tsconfig/tsconfig.wagmi.types.json"
},
"simple-git-hooks": {
"pre-commit": "bun run format && bun run lint:fix"
Expand Down
2 changes: 1 addition & 1 deletion packages/permissionless-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dotenv": "^16.3.1",
"execa": "^8.0.1",
"get-port": "^7.0.0",
"permissionless": "workspace:*",
"permissionless": "workspace:packages/permissionless",
"viem": "^2.0.0"
}
}
32 changes: 16 additions & 16 deletions packages/permissionless/utils/errors/getBundlerError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function getBundlerError(
return new ExecutionRevertedError({
cause: err,
message: executionRevertedError.details
}) as any
}) as ExecutionRevertedErrorType
}

// TODO: Add validation Errors
Expand All @@ -97,15 +97,15 @@ export function getBundlerError(
sender: args.userOperation.sender,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa10"
}) as any
}) as SenderAlreadyDeployedErrorType
}

if (InitCodeRevertedError.message.test(message)) {
return new InitCodeRevertedError({
cause: err,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa13"
}) as any
}) as InitCodeRevertedErrorType
}

if (SenderAddressMismatchError.message.test(message)) {
Expand All @@ -114,7 +114,7 @@ export function getBundlerError(
sender: args.userOperation.sender,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa14"
}) as any
}) as SenderAddressMismatchErrorType
}

if (InitCodeDidNotDeploySenderError.message.test(message)) {
Expand All @@ -123,7 +123,7 @@ export function getBundlerError(
sender: args.userOperation.sender,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa15"
}) as any
}) as InitCodeDidNotDeploySenderErrorType
}

if (SenderNotDeployedError.message.test(message)) {
Expand All @@ -132,7 +132,7 @@ export function getBundlerError(
sender: args.userOperation.sender,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa20"
}) as any
}) as SenderNotDeployedErrorType
}

if (SmartAccountInsufficientFundsError.message.test(message)) {
Expand All @@ -141,15 +141,15 @@ export function getBundlerError(
sender: args.userOperation.sender,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa21"
}) as any
}) as SmartAccountInsufficientFundsErrorType
}

if (SmartAccountSignatureValidityPeriodError.message.test(message)) {
return new SmartAccountSignatureValidityPeriodError({
cause: err,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa22"
}) as any
}) as SmartAccountSignatureValidityPeriodErrorType
}

if (SmartAccountValidationRevertedError.message.test(message)) {
Expand All @@ -158,7 +158,7 @@ export function getBundlerError(
sender: args.userOperation.sender,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa23"
}) as any
}) as SmartAccountValidationRevertedErrorType
}

if (InvalidSmartAccountNonceError.message.test(message)) {
Expand All @@ -168,7 +168,7 @@ export function getBundlerError(
nonce: args.userOperation.nonce,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa25"
}) as any
}) as InvalidSmartAccountNonceErrorType
}

if (PaymasterNotDeployedError.message.test(message)) {
Expand All @@ -177,7 +177,7 @@ export function getBundlerError(
paymasterAndData: args.userOperation.paymasterAndData,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa30"
}) as any
}) as PaymasterNotDeployedErrorType
}

if (PaymasterDepositTooLowError.message.test(message)) {
Expand All @@ -186,7 +186,7 @@ export function getBundlerError(
paymasterAndData: args.userOperation.paymasterAndData,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa31"
}) as any
}) as PaymasterDepositTooLowErrorType
}

if (PaymasterValidityPeriodError.message.test(message)) {
Expand All @@ -195,7 +195,7 @@ export function getBundlerError(
paymasterAndData: args.userOperation.paymasterAndData,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa32"
}) as any
}) as PaymasterValidityPeriodErrorType
}

if (PaymasterValidationRevertedError.message.test(message)) {
Expand All @@ -204,7 +204,7 @@ export function getBundlerError(
paymasterAndData: args.userOperation.paymasterAndData,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa33"
}) as any
}) as PaymasterValidationRevertedErrorType
}

if (PaymasterDataRejectedError.message.test(message)) {
Expand All @@ -213,8 +213,8 @@ export function getBundlerError(
paymasterAndData: args.userOperation.paymasterAndData,
docsPath:
"https://docs.pimlico.io/bundler/reference/entrypoint-errors/aa34"
}) as any
}) as PaymasterDataRejectedErrorType
}

return new UnknownNodeError({ cause: err }) as any
return new UnknownNodeError({ cause: err }) as UnknownNodeErrorType
}
1 change: 1 addition & 0 deletions packages/permissionless/utils/getAction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Client } from "viem"

// biome-ignore lint/suspicious/noExplicitAny: it's a generic function, so it's hard to type
export function getAction<params extends any[], returnType extends {}>(
client: Client,
// biome-ignore lint/suspicious/noExplicitAny: it's a recursive function, so it's hard to type
Expand Down
2 changes: 2 additions & 0 deletions packages/wagmi-demo/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RPC_URL=
PAYMASTER_URL=
12 changes: 12 additions & 0 deletions packages/wagmi-demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Create Wagmi</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions packages/wagmi-demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@permissionless/wagmi-demo",
"private": true,
"author": "Pimlico",
"homepage": "https://docs.pimlico.io/permissionless/wagmi",
"repository": "github:pimlicolabs/permissionless.js",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "biome check .",
"preview": "vite preview"
},
"dependencies": {
"wagmi": "^0.0.0-canary-20240123224806",
"viem": "^2.0.0",
"@tanstack/react-query": "5.0.5",
"react": "^18.2.0",
"permissionless": "workspace:packages/permissionless",
"vite": "^4.4.9",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"react-dom": "^18.2.0",
"@permissionless/wagmi": "workspace:packages/wagmi",
"@vitejs/plugin-react": "^4.1.0"
}
}
Loading

0 comments on commit 84f6461

Please sign in to comment.