From 4a3da3a6a1838024677f6537a88bc75edbdc52b4 Mon Sep 17 00:00:00 2001 From: poocart <7067483+poocart@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:51:02 +0300 Subject: [PATCH] added buffer dependency (#39) --- CHANGELOG.md | 5 +++ package-lock.json | 62 ++++++++++++++++++++++++++ package.json | 7 +-- src/sdk/base/VerifyingPaymasterAPI.ts | 1 + src/sdk/base/calcPreVerificationGas.ts | 1 + src/sdk/common/ERC4337Utils.ts | 3 +- 6 files changed, 75 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4296026..cb971c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ # Changelog +## [1.2.10] - 2023-09-27 +### Fixes +- Added `buffer` dependency to support both node and browser environments + ## [1.2.9] - 2023-09-26 ### New - Added Mantle testnet + ## [1.2.8] - 2023-09-21 ### Fixes - Fixed the issue with getExchangeOffers endpoint (Account must need to be deployed to access this endpoint) diff --git a/package-lock.json b/package-lock.json index 7b2d775..d1d298b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@thehubbleproject/bls": "0.5.1", "@walletconnect/universal-provider": "2.10.0", "apollo-link-ws": "1.0.20", + "buffer": "^6.0.3", "class-transformer": "0.5.1", "class-validator": "0.14.0", "commander": "10.0.1", @@ -1916,6 +1917,25 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/bech32": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", @@ -1949,6 +1969,29 @@ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -3217,6 +3260,25 @@ "node": ">=0.10.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", diff --git a/package.json b/package.json index ef4b691..f5721f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@etherspot/prime-sdk", - "version": "1.2.9", + "version": "1.2.10", "description": "Etherspot Prime (Account Abstraction) SDK", "keywords": [ "ether", @@ -53,8 +53,9 @@ "@lifi/sdk": "2.2.3", "@nerdwallet/apollo-cache-policies": "1.2.1", "@thehubbleproject/bls": "0.5.1", - "apollo-link-ws": "1.0.20", "@walletconnect/universal-provider": "2.10.0", + "apollo-link-ws": "1.0.20", + "buffer": "^6.0.3", "class-transformer": "0.5.1", "class-validator": "0.14.0", "commander": "10.0.1", @@ -68,10 +69,10 @@ "@types/prettier": "2.7.3", "@typescript-eslint/eslint-plugin": "2.34.0", "@typescript-eslint/parser": "2.34.0", + "dotenv": "16.0.3", "eslint": "6.8.0", "eslint-config-prettier": "6.11.0", "eslint-plugin-import": "2.20.2", - "dotenv": "16.0.3", "npm": "9.6.4", "ts-node": "8.10.2", "typescript": "4.5.2" diff --git a/src/sdk/base/VerifyingPaymasterAPI.ts b/src/sdk/base/VerifyingPaymasterAPI.ts index 813484f..02ee97a 100644 --- a/src/sdk/base/VerifyingPaymasterAPI.ts +++ b/src/sdk/base/VerifyingPaymasterAPI.ts @@ -1,5 +1,6 @@ import { ethers } from 'ethers'; import fetch from 'cross-fetch'; +import { Buffer } from 'buffer'; import { calcPreVerificationGas } from './calcPreVerificationGas'; import { PaymasterAPI } from './PaymasterAPI'; import { UserOperationStruct } from '../contracts/account-abstraction/contracts/core/BaseAccount'; diff --git a/src/sdk/base/calcPreVerificationGas.ts b/src/sdk/base/calcPreVerificationGas.ts index 9b264f4..a32f95f 100644 --- a/src/sdk/base/calcPreVerificationGas.ts +++ b/src/sdk/base/calcPreVerificationGas.ts @@ -2,6 +2,7 @@ import { UserOperationStruct } from '../contracts/account-abstraction/contracts/ import { NotPromise, packUserOp } from '../common'; import { arrayify, hexlify } from 'ethers/lib/utils'; +import { Buffer } from 'buffer'; export interface GasOverheads { /** diff --git a/src/sdk/common/ERC4337Utils.ts b/src/sdk/common/ERC4337Utils.ts index 47bfd24..a4f51bd 100644 --- a/src/sdk/common/ERC4337Utils.ts +++ b/src/sdk/common/ERC4337Utils.ts @@ -2,6 +2,7 @@ import { defaultAbiCoder, hexConcat, hexlify, keccak256 } from 'ethers/lib/utils import { EntryPoint__factory } from '../contracts'; import { UserOperationStruct } from '../contracts/account-abstraction/contracts/core/BaseAccount'; import { ethers } from 'ethers'; +import { Buffer } from 'buffer'; const entryPointAbi: any = EntryPoint__factory.abi; @@ -98,7 +99,7 @@ export function decodeErrorReason(error: string): DecodedError | undefined { return { message: formattedMessage, opIndex, - }; + }; } }