Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all Web3 usage to libs/evm-protocol #10504

Merged
merged 20 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions libs/evm-protocols/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@
"lint-diff": "NODE_OPTIONS=\"--max-old-space-size=4096\" eslint -c ../../.eslintrc-diff.cjs './src/**/*.{ts,tsx}'"
},
"dependencies": {
"@hicommonwealth/shared": "workspace:*",
"@alchemy/aa-alchemy": "^3.17.0",
"@alchemy/aa-core": "^3.16.0",
"@ethersproject/bignumber": "^5.7.0",
"moment": "^2.23.0"
"@hicommonwealth/shared": "workspace:*",
"async-mutex": "^0.5.0",
"moment": "^2.23.0",
"web3": "^4.7.0",
"web3-eth-abi": "^4.2.1",
"web3-utils": "^4.2.2",
"web3-validator": "2.0.5"
}
}
1 change: 1 addition & 0 deletions libs/evm-protocols/src/abis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './launchpadFactoryAbi';
export * from './lpBondingCurveAbi';
export * from './namespaceAbi';
export * from './namespaceFactoryAbi';
export * from './recurringContestAbi';
export * from './reservationHookAbi';
export * from './singleContestAbi';
export * from './tokenCommunityManagerAbi';
71 changes: 71 additions & 0 deletions libs/evm-protocols/src/common-protocol/accountAbstraction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { createModularAccountAlchemyClient } from '@alchemy/aa-alchemy';
import {
LocalAccountSigner,
sepolia,
SmartAccountSigner,
} from '@alchemy/aa-core';
import Web3 from 'web3';

type CreateSmartAccountClientOptions = {
owners?: `0x${string}`[];
accountAddress?: `0x${string}`;
privateKey: string;
alchemyKey: string;
gasPolicy: string;
};

export const createSmartAccountClient: (
options: CreateSmartAccountClientOptions,
) => Promise<{
client: Awaited<ReturnType<typeof createModularAccountAlchemyClient>>;
signerAddress: string;
}> = async ({
owners,
accountAddress,
privateKey,
alchemyKey,
gasPolicy,
}: CreateSmartAccountClientOptions) => {
//Figure out specific chain for this at later time
const chain = sepolia;

const signer: SmartAccountSigner =
LocalAccountSigner.privateKeyToAccountSigner(`0x${privateKey}`);
const smartAccountClient = await createModularAccountAlchemyClient({
apiKey: alchemyKey,
chain,
signer,
owners,
accountAddress,
gasManagerConfig: {
policyId: gasPolicy,
},
});

return {
client: smartAccountClient,
signerAddress: await signer.getAddress(),
};
};

export const sendUserOpHelper = async ({
client,
to,
data,
value,
}: {
client: Awaited<ReturnType<typeof createSmartAccountClient>>['client'];
to: string;
value: number;
data: string;
}) => {
const uo = await client.sendUserOperation({
uo: {
target: `0x${to.replace('0x', '')}`,
data: `0x${data.replace('0x', '')}`,
value: Web3.utils.toBigInt(value),
},
account: client.account,
});
return await client.waitForUserOperationTransaction(uo);
};
62 changes: 0 additions & 62 deletions libs/evm-protocols/src/common-protocol/contractHelpers/Contest.ts

This file was deleted.

134 changes: 0 additions & 134 deletions libs/evm-protocols/src/common-protocol/contractHelpers/Launchpad.ts

This file was deleted.

Loading
Loading