Skip to content

Commit

Permalink
update with permissionless v0.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofgazso committed Nov 1, 2023
1 parent af98eec commit 2a4908e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 38 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "MIT",
"dependencies": {
"dotenv": "^16.3.1",
"permissionless": "^0.0.8",
"permissionless": "^0.0.11",
"viem": "^1.14.0"
},
"devDependencies": {
Expand Down
21 changes: 9 additions & 12 deletions tutorial-1.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { UserOperation, bundlerActions, getSenderAddress, getUserOperationHash } from "permissionless"
import dotenv from "dotenv"
import { UserOperation, bundlerActions, getSenderAddress, signUserOperationHashWithECDSA } from "permissionless"
import { pimlicoBundlerActions, pimlicoPaymasterActions } from "permissionless/actions/pimlico"
import { Hex, concat, createClient, createPublicClient, encodeFunctionData, http } from "viem"
import { lineaTestnet } from "viem/chains"
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"
import { pimlicoBundlerActions, pimlicoPaymasterActions } from "permissionless/actions/pimlico"
import dotenv from "dotenv"
import { lineaTestnet } from "viem/chains"
dotenv.config()

// CREATE THE CLIENTS
Expand Down Expand Up @@ -122,14 +122,11 @@ const sponsoredUserOperation: UserOperation = {
console.log("Received paymaster sponsor result:", sponsorUserOperationResult)

// SIGN THE USER OPERATION
const signature = await owner.signMessage({
message: {
raw: getUserOperationHash({
userOperation: sponsoredUserOperation,
chainId: lineaTestnet.id,
entryPoint: ENTRY_POINT_ADDRESS
})
}
const signature = await signUserOperationHashWithECDSA({
account: owner,
userOperation: sponsoredUserOperation,
chainId: lineaTestnet.id,
entryPoint: ENTRY_POINT_ADDRESS
})
sponsoredUserOperation.signature = signature

Expand Down
39 changes: 18 additions & 21 deletions tutorial-2.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import dotenv from "dotenv"
import { getAccountNonce } from "permissionless"
import { UserOperation, bundlerActions, getSenderAddress, getUserOperationHash } from "permissionless"
import {
UserOperation,
bundlerActions,
getAccountNonce,
getSenderAddress,
signUserOperationHashWithECDSA
} from "permissionless"
import { pimlicoBundlerActions, pimlicoPaymasterActions } from "permissionless/actions/pimlico"
import { Address, Hash, concat, createClient, createPublicClient, encodeFunctionData, http } from "viem"
import { privateKeyToAccount, signMessage } from "viem/accounts"
import { privateKeyToAccount } from "viem/accounts"
import { polygonMumbai } from "viem/chains"
dotenv.config()

Expand Down Expand Up @@ -192,15 +197,11 @@ if (nonce === 0n) {
userOperation.paymasterAndData = result.paymasterAndData

// SIGN THE USEROPERATION
const signature = await signMessage({
message: {
raw: getUserOperationHash({
userOperation: userOperation as UserOperation,
entryPoint: ENTRY_POINT_ADDRESS,
chainId: polygonMumbai.id
})
},
privateKey: privateKey as Hash
const signature = await signUserOperationHashWithECDSA({
account: signer,
userOperation: userOperation as UserOperation,
chainId: polygonMumbai.id,
entryPoint: ENTRY_POINT_ADDRESS
})

userOperation.signature = signature
Expand Down Expand Up @@ -259,15 +260,11 @@ const sponsoredUserOperation: UserOperation = {

// SIGN THE USEROPERATION

sponsoredUserOperation.signature = await signMessage({
message: {
raw: getUserOperationHash({
userOperation: sponsoredUserOperation,
entryPoint: ENTRY_POINT_ADDRESS,
chainId: polygonMumbai.id
})
},
privateKey: privateKey as Hash
sponsoredUserOperation.signature = await signUserOperationHashWithECDSA({
account: signer,
userOperation: sponsoredUserOperation,
chainId: polygonMumbai.id,
entryPoint: ENTRY_POINT_ADDRESS
})

await submitUserOperation(sponsoredUserOperation)

0 comments on commit 2a4908e

Please sign in to comment.