Skip to content

Add paymentToken, payment and paymentReceiver support #268

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

Merged
merged 2 commits into from
Aug 20, 2024
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
5 changes: 5 additions & 0 deletions .changeset/green-gorillas-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Added support for paymentToken, payment and paymentReceiver in Safe smart account
52 changes: 44 additions & 8 deletions packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,9 @@
multiSendAddress,
safeSingletonAddress,
erc7579LaunchpadAddress,
paymentToken,
payment,
paymentReceiver,
setupTransactions = [],
safeModules = [],
validators = [],
Expand All @@ -628,6 +631,9 @@
safeModuleSetupAddress: Address
safe4337ModuleAddress: Address
multiSendAddress: Address
paymentToken: Address
payment: bigint
paymentReceiver: Address
erc7579LaunchpadAddress?: Address
setupTransactions?: {
to: Address
Expand Down Expand Up @@ -755,9 +761,9 @@
multiSendAddress,
multiSendCallData,
safe4337ModuleAddress,
zeroAddress,
BigInt(0),
zeroAddress
paymentToken,
payment,
paymentReceiver
]
})
}
Expand Down Expand Up @@ -795,6 +801,9 @@
safeSingletonAddress,
erc7579LaunchpadAddress,
multiSendAddress,
paymentToken,
payment,
paymentReceiver,
saltNonce = BigInt(0),
setupTransactions = [],
safeModules = [],
Expand All @@ -810,6 +819,9 @@
safe4337ModuleAddress: Address
safeSingletonAddress: Address
multiSendAddress: Address
paymentToken: Address
payment: bigint
paymentReceiver: Address
erc7579LaunchpadAddress?: Address
saltNonce?: bigint
setupTransactions?: {
Expand Down Expand Up @@ -846,7 +858,10 @@
fallbacks,
hooks,
attesters,
attestersThreshold
attestersThreshold,
paymentToken,
payment,
paymentReceiver
})

const initCodeCallData = encodeFunctionData({
Expand Down Expand Up @@ -874,6 +889,9 @@
safeSingletonAddress,
multiSendAddress,
erc7579LaunchpadAddress,
paymentToken,
payment,
paymentReceiver,
setupTransactions = [],
safeModules = [],
saltNonce = BigInt(0),
Expand All @@ -896,6 +914,9 @@
data: Address
value: bigint
}[]
paymentToken: Address
payment: bigint
paymentReceiver: Address
safeModules?: Address[]
saltNonce?: bigint
erc7579LaunchpadAddress?: Address
Expand Down Expand Up @@ -929,7 +950,10 @@
fallbacks,
hooks,
attesters,
attestersThreshold
attestersThreshold,
paymentToken,
payment,
paymentReceiver
})

const deploymentCode = encodePacked(
Expand Down Expand Up @@ -1060,6 +1084,9 @@
validUntil?: number
validAfter?: number
nonceKey?: bigint
paymentToken?: Address
payment?: bigint
paymentReceiver?: Address
} & GetErc7579Params<TErc7579>

function isErc7579Args(
Expand Down Expand Up @@ -1119,7 +1146,10 @@
saltNonce = BigInt(0),
validUntil = 0,
validAfter = 0,
nonceKey
nonceKey,
paymentToken = zeroAddress,
payment = BigInt(0),
paymentReceiver = zeroAddress

Check warning on line 1152 in packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts

View check run for this annotation

Codecov / codecov/patch

packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts#L1149-L1152

Added lines #L1149 - L1152 were not covered by tests
} = args

let _safeModuleSetupAddress: Address | undefined = undefined
Expand Down Expand Up @@ -1197,7 +1227,10 @@
fallbacks,
hooks,
attesters,
attestersThreshold
attestersThreshold,
paymentToken,
payment,
paymentReceiver
}))

if (!accountAddress) throw new Error("Account address not found")
Expand Down Expand Up @@ -1397,7 +1430,10 @@
fallbacks,
hooks,
attesters,
attestersThreshold
attestersThreshold,
paymentToken,
payment,
paymentReceiver
})
},
async encodeDeployCallData(_) {
Expand Down
Loading