Skip to content

Commit

Permalink
change signer to smartAccountSigner
Browse files Browse the repository at this point in the history
  • Loading branch information
plusminushalf committed Nov 22, 2023
1 parent 28f34bc commit bf7374b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/accounts/privateKeyToSafeSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function privateKeyToSafeSmartAccount<
const privateKeyAccount = privateKeyToAccount(privateKey)

return signerToSafeSmartAccount(client, {
signer: privateKeyAccount,
smartAccountSigner: privateKeyAccount,
safeVersion,
entryPoint,
addModuleLibAddress: _addModuleLibAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/privateKeyToSimpleSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function privateKeyToSimpleSmartAccount<
const privateKeyAccount = privateKeyToAccount(privateKey)

return signerToSimpleSmartAccount(client, {
signer: privateKeyAccount,
smartAccountSigner: privateKeyAccount,
factoryAddress,
entryPoint,
index
Expand Down
10 changes: 5 additions & 5 deletions src/accounts/signerToSafeSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export async function signerToSafeSmartAccount<
>(
client: Client<TTransport, TChain>,
{
signer,
smartAccountSigner,
safeVersion,
entryPoint,
addModuleLibAddress: _addModuleLibAddress,
Expand All @@ -508,7 +508,7 @@ export async function signerToSafeSmartAccount<
setupTransactions = []
}: {
safeVersion: SafeVersion
signer: SmartAccountSigner
smartAccountSigner: SmartAccountSigner
entryPoint: Address
addModuleLibAddress?: Address
safe4337ModuleAddress?: Address
Expand All @@ -528,14 +528,14 @@ export async function signerToSafeSmartAccount<
const chainId = await getChainId(client)

const viemSigner: Account =
signer.type === "local"
smartAccountSigner.type === "local"
? ({
...signer,
...smartAccountSigner,
signTransaction: (_, __) => {
throw new SignTransactionNotSupportedBySmartAccount()
}
} as Account)
: (signer as Account)
: (smartAccountSigner as Account)

const {
addModuleLibAddress,
Expand Down
10 changes: 5 additions & 5 deletions src/accounts/signerToSimpleSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,26 @@ export async function signerToSimpleSmartAccount<
>(
client: Client<TTransport, TChain>,
{
signer,
smartAccountSigner,
factoryAddress,
entryPoint,
index = 0n
}: {
signer: SmartAccountSigner
smartAccountSigner: SmartAccountSigner
factoryAddress: Address
entryPoint: Address
index?: bigint
}
): Promise<SimpleSmartAccount<TTransport, TChain>> {
const viemSigner: Account =
signer.type === "local"
smartAccountSigner.type === "local"
? ({
...signer,
...smartAccountSigner,
signTransaction: (_, __) => {
throw new SignTransactionNotSupportedBySmartAccount()
}
} as Account)
: (signer as Account)
: (smartAccountSigner as Account)

const [accountAddress, chainId] = await Promise.all([
getAccountAddress<TTransport, TChain>({
Expand Down
12 changes: 8 additions & 4 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ export const getSignerToSimpleSmartAccount = async () => {

const publicClient = await getPublicClient()

const signer = privateKeyToAccount(process.env.TEST_PRIVATE_KEY as Hex)
const smartAccountSigner = privateKeyToAccount(
process.env.TEST_PRIVATE_KEY as Hex
)

return await signerToSimpleSmartAccount(publicClient, {
entryPoint: getEntryPoint(),
factoryAddress: getFactoryAddress(),
signer: signer
smartAccountSigner: smartAccountSigner
})
}

Expand All @@ -64,11 +66,13 @@ export const getSignerToSafeSmartAccount = async (args?: {

const publicClient = await getPublicClient()

const signer = privateKeyToAccount(process.env.TEST_PRIVATE_KEY as Hex)
const smartAccountSigner = privateKeyToAccount(
process.env.TEST_PRIVATE_KEY as Hex
)

return await signerToSafeSmartAccount(publicClient, {
entryPoint: getEntryPoint(),
signer: signer,
smartAccountSigner: smartAccountSigner,
safeVersion: "1.4.1",
saltNonce: 100n,
setupTransactions: args?.setupTransactions
Expand Down

0 comments on commit bf7374b

Please sign in to comment.