Skip to content

Commit

Permalink
Merge pull request #168 from pimlicolabs/fix/issue-99
Browse files Browse the repository at this point in the history
use BigInt instead of 1n
  • Loading branch information
plusminushalf authored Apr 11, 2024
2 parents 53c004b + 8652af7 commit 7e23e4f
Show file tree
Hide file tree
Showing 23 changed files with 125 additions and 93 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-insects-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Fixed use of BigInt literals for targeting lower than ES2020
24 changes: 12 additions & 12 deletions packages/permissionless-test/ep-0.6/biconomySmartaccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {
await expect(async () =>
ecdsaSmartAccount.signTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})
).rejects.toThrow(SignTransactionNotSupportedBySmartAccount)
Expand Down Expand Up @@ -111,12 +111,12 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {
transactions: [
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
},
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
}
]
Expand Down Expand Up @@ -152,7 +152,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {
const txHash = await entryPointContract.write.depositTo(
[smartAccountClient.account.address],
{
value: 10n
value: BigInt(10)
}
)

Expand Down Expand Up @@ -183,7 +183,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {

const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})

Expand Down Expand Up @@ -242,12 +242,12 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {
transactions: [
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
},
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
}
]
Expand Down Expand Up @@ -303,7 +303,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {
// Send an initial tx to deploy the account
const hash = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})

Expand All @@ -326,7 +326,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {

test("verifySignature of deployed", async () => {
const initialEcdsaSmartAccount = await getSignerToBiconomyAccount({
index: 0n
index: BigInt(0)
})

const smartAccountClient = await getSmartAccountClient({
Expand All @@ -351,7 +351,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {

test("verifySignature of not deployed", async () => {
const initialEcdsaSmartAccount = await getSignerToBiconomyAccount({
index: 10000n
index: BigInt(10000)
})

const smartAccountClient = await getSmartAccountClient({
Expand All @@ -376,7 +376,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {

test("verifySignature with signTypedData", async () => {
const initialEcdsaSmartAccount = await getSignerToBiconomyAccount({
index: 0n
index: BigInt(0)
})

const smartAccountClient = await getSmartAccountClient({
Expand Down Expand Up @@ -456,7 +456,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => {

test("verifySignature with signTypedData for not deployed", async () => {
const initialEcdsaSmartAccount = await getSignerToBiconomyAccount({
index: 1000000n
index: BigInt(1000000)
})

const smartAccountClient = await getSmartAccountClient({
Expand Down
4 changes: 2 additions & 2 deletions packages/permissionless-test/ep-0.6/bundlerActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe("BUNDLER ACTIONS", () => {
),
entryPoint: getEntryPoint(),
factoryAddress: process.env.FACTORY_ADDRESS_V06 as Address,
index: 3n
index: BigInt(3)
})

const paymasterClient = getPimlicoPaymasterClient()
Expand All @@ -125,7 +125,7 @@ describe("BUNDLER ACTIONS", () => {

const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n
value: BigInt(0)
})
}, 100000)

Expand Down
4 changes: 2 additions & 2 deletions packages/permissionless-test/ep-0.6/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ describe("test public actions and utils", () => {
expect(deepHexlify(null)).toBe(null)
expect(deepHexlify(true)).toBe(true)
expect(deepHexlify(false)).toBe(false)
expect(deepHexlify(1n)).toBe("0x1")
expect(deepHexlify(BigInt(1))).toBe("0x1")
expect(
deepHexlify({
name: "Garvit",
balance: 1n
balance: BigInt(1)
})
).toEqual({
name: "Garvit",
Expand Down
22 changes: 11 additions & 11 deletions packages/permissionless-test/ep-0.6/simpleAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("Simple Account", () => {
await expect(async () =>
simpleSmartAccount.signTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})
).rejects.toThrow(SignTransactionNotSupportedBySmartAccount)
Expand Down Expand Up @@ -136,12 +136,12 @@ describe("Simple Account", () => {
transactions: [
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
},
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
}
]
Expand Down Expand Up @@ -174,7 +174,7 @@ describe("Simple Account", () => {
const txHash = await entryPointContract.write.depositTo(
[smartAccountClient.account.address],
{
value: 10n
value: BigInt(10)
}
)

Expand All @@ -196,7 +196,7 @@ describe("Simple Account", () => {
)
const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})
expectTypeOf(response).toBeString()
Expand All @@ -221,7 +221,7 @@ describe("Simple Account", () => {
const response = await smartAccountClient.sendTransaction({
to: smartAccountClient.account.address,
data: "0x",
value: 0n
value: BigInt(0)
})

expectTypeOf(response).toBeString()
Expand All @@ -242,7 +242,7 @@ describe("Simple Account", () => {
userOperation: {
callData: await smartAccountClient.account.encodeCallData({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})
}
Expand All @@ -265,7 +265,7 @@ describe("Simple Account", () => {

const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})

Expand Down Expand Up @@ -318,12 +318,12 @@ describe("Simple Account", () => {
transactions: [
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
},
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
}
]
Expand Down Expand Up @@ -364,7 +364,7 @@ describe("Simple Account", () => {

test("verifySignature", async () => {
const initialEcdsaSmartAccount = await getSignerToSimpleSmartAccount({
index: 0n
index: BigInt(0)
})
const pimlicoPaymaster = getPimlicoPaymasterClient()

Expand Down
6 changes: 3 additions & 3 deletions packages/permissionless-test/ep-0.7/bundlerActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe("BUNDLER ACTIONS", () => {
),
entryPoint: getEntryPoint(),
factoryAddress: process.env.FACTORY_ADDRESS_V07 as Address,
index: 3n
index: BigInt(3)
})

const paymasterClient = getPimlicoPaymasterClient()
Expand All @@ -126,7 +126,7 @@ describe("BUNDLER ACTIONS", () => {

const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n
value: BigInt(0)
})
}, 100000)

Expand Down Expand Up @@ -230,7 +230,7 @@ describe("BUNDLER ACTIONS", () => {
userOperation: {
callData: await simpleAccountClient.account.encodeCallData({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})
}
Expand Down
8 changes: 4 additions & 4 deletions packages/permissionless-test/ep-0.7/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const getTestingChain = () => {
export const getSignerToSimpleSmartAccount = async ({
signer = privateKeyToAccount(process.env.TEST_PRIVATE_KEY as Hex),
address,
index = 0n
index = BigInt(0)
}: {
signer?: SmartAccountSigner
address?: Address
Expand Down Expand Up @@ -141,7 +141,7 @@ export const getSignerToSafeSmartAccount = async (args?: {
entryPoint: getEntryPoint(),
signer: signer,
safeVersion: "1.4.1",
saltNonce: args?.saltNonce ?? 100n,
saltNonce: args?.saltNonce ?? BigInt(100),
setupTransactions: args?.setupTransactions
})
}
Expand All @@ -150,7 +150,7 @@ export const getSmartAccountClient = async ({
account,
middleware,
preFund = false,
index = 0n
index = BigInt(0)
}: Middleware<ENTRYPOINT_ADDRESS_V07_TYPE> & {
account?: SmartAccount<ENTRYPOINT_ADDRESS_V07_TYPE>
preFund?: boolean
Expand Down Expand Up @@ -308,7 +308,7 @@ export const refillSmartAccount = async (
) => {
const publicClient = getPublicClient()
const balance = await publicClient.getBalance({ address })
if (balance === 0n) {
if (balance === BigInt(0)) {
await walletClient.sendTransaction({
to: address,
value: parseEther("1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("Simple Account from walletClient", () => {
await expect(async () =>
simpleSmartAccount.signTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})
).rejects.toThrow(new SignTransactionNotSupportedBySmartAccount())
Expand Down Expand Up @@ -161,12 +161,12 @@ describe("Simple Account from walletClient", () => {
transactions: [
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
},
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
}
]
Expand Down Expand Up @@ -205,7 +205,7 @@ describe("Simple Account from walletClient", () => {
const txHash = await entryPointContract.write.depositTo(
[smartAccountClient.account.address],
{
value: 10n
value: BigInt(10)
}
)

Expand All @@ -231,7 +231,7 @@ describe("Simple Account from walletClient", () => {
)
const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})
expectTypeOf(response).toBeString()
Expand All @@ -257,7 +257,7 @@ describe("Simple Account from walletClient", () => {

const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
})

Expand Down Expand Up @@ -313,12 +313,12 @@ describe("Simple Account from walletClient", () => {
transactions: [
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
},
{
to: zeroAddress,
value: 0n,
value: BigInt(0),
data: "0x"
}
]
Expand Down
2 changes: 1 addition & 1 deletion packages/permissionless-test/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export let forkBlockNumber: bigint
if (process.env.VITE_ANVIL_BLOCK_NUMBER) {
forkBlockNumber = BigInt(Number(process.env.VITE_ANVIL_BLOCK_NUMBER))
} else {
forkBlockNumber = 10419392n
forkBlockNumber = BigInt(10419392)
warn(
`\`VITE_ANVIL_BLOCK_NUMBER\` not found. Falling back to \`${forkBlockNumber}\`.`
)
Expand Down
2 changes: 1 addition & 1 deletion packages/permissionless-test/src/opStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (process.env.VITE_ANVIL_BLOCK_NUMBER_OPTIMISM) {
Number(process.env.VITE_ANVIL_BLOCK_NUMBER_OPTIMISM)
)
} else {
forkBlockNumberOptimism = 115197387n
forkBlockNumberOptimism = BigInt(115197387)
warn(
`\`VITE_ANVIL_BLOCK_NUMBER_OPTIMISM\` not found. Falling back to \`${forkBlockNumberOptimism}\`.`
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const getAccountAddress = async ({
fallbackHandlerAddress,
ecdsaModuleAddress,
owner,
index = 0n
index = BigInt(0)
}: {
factoryAddress: Address
accountLogicAddress: Address
Expand Down Expand Up @@ -219,7 +219,7 @@ export async function signerToBiconomySmartAccount<
signer,
address,
entryPoint: entryPointAddress,
index = 0n,
index = BigInt(0),
factoryAddress = BICONOMY_ADDRESSES.FACTORY_ADDRESS,
accountLogicAddress = BICONOMY_ADDRESSES.ACCOUNT_V2_0_LOGIC,
fallbackHandlerAddress = BICONOMY_ADDRESSES.DEFAULT_FALLBACK_HANDLER_ADDRESS,
Expand Down
Loading

0 comments on commit 7e23e4f

Please sign in to comment.