diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2b41e..d8176b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.9 + +* Fix user-operation modififications post paymaster sponsorship + ## 0.1.8 * Fix incorrect useroperation receipt map key diff --git a/example/pubspec.lock b/example/pubspec.lock index 979e942..f24152f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -93,10 +93,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" convert: dependency: transitive description: @@ -300,18 +300,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.7" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.8" leak_tracker_testing: dependency: transitive description: @@ -580,7 +580,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: @@ -601,10 +601,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.0" stream_channel: dependency: "direct overridden" description: @@ -625,10 +625,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" term_glyph: dependency: transitive description: @@ -641,10 +641,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.3" typed_data: dependency: transitive description: @@ -683,7 +683,7 @@ packages: path: ".." relative: true source: path - version: "0.1.6" + version: "0.1.9" vector_math: dependency: transitive description: @@ -696,10 +696,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.3.0" wallet: dependency: transitive description: diff --git a/lib/src/4337/wallet.dart b/lib/src/4337/wallet.dart index 70aa268..d169c4f 100644 --- a/lib/src/4337/wallet.dart +++ b/lib/src/4337/wallet.dart @@ -148,31 +148,26 @@ class SmartWallet with _PluginManager, _GasSettings implements SmartWalletBase { @override Future sendUserOperation(UserOperation op) => - _prepareAndSignOperation(op).then(sendSignedUserOperation); - - Future _prepareAndSignOperation(UserOperation op) async { - final prepared = await prepareUserOperation(op); - return signUserOperation(prepared); - } + prepareUserOperation(op) + .then(applyCustomGasSettings) + .then(sponsorUserOperation) + .then(signUserOperation) + .then(sendSignedUserOperation); @override Future prepareUserOperation(UserOperation op, {bool update = true}) async { - op = await _updateIfNeeded(op, update); - op = await _applyPlugins(op); + if (update) op = await _updateUserOperation(op); op.validate(op.nonce > BigInt.zero, initCode); return op; } - Future _updateIfNeeded(UserOperation op, bool update) async { - if (!update) return op; - op = await _updateUserOperation(op); - return applyCustomGasSettings(op); - } - - Future _applyPlugins(UserOperation op) async { - if (!hasPlugin('paymaster')) return op; - return plugin('paymaster').intercept(op); + @override + Future sponsorUserOperation(UserOperation op) async { + if (hasPlugin('paymaster')) { + op = await plugin('paymaster').intercept(op); + } + return op; } @override diff --git a/lib/src/interfaces/smart_wallet.dart b/lib/src/interfaces/smart_wallet.dart index ef816ba..8766604 100644 --- a/lib/src/interfaces/smart_wallet.dart +++ b/lib/src/interfaces/smart_wallet.dart @@ -80,7 +80,6 @@ abstract class SmartWalletBase { void dangerouslySetInitCode(Uint8List code); /// Prepares a user operation by updating it with the latest nonce and gas prices, - /// intercepting it with a paymaster (if enabled), and validating it. /// /// [op] is the user operation to prepare. /// [update] is a flag indicating whether to update the user operation with the @@ -90,6 +89,13 @@ abstract class SmartWalletBase { Future prepareUserOperation(UserOperation op, {bool update = true}); + /// Sponsors a user operation by intercepting it with the paymaster plugin, if present. + /// + /// [op] is the user operation to sponsor. + /// + /// Returns a [Future] that resolves to the sponsored [UserOperation] object. + Future sponsorUserOperation(UserOperation op); + /// Asynchronously transfers native Token (ETH) to the specified recipient with the given amount. /// /// Parameters: diff --git a/pubspec.lock b/pubspec.lock index f90e0c2..78bb47c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,23 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" url: "https://pub.dev" source: hosted - version: "72.0.0" - _macros: - dependency: transitive - description: dart - source: sdk - version: "0.3.2" + version: "67.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" url: "https://pub.dev" source: hosted - version: "6.7.0" + version: "6.4.1" args: dependency: transitive description: @@ -154,10 +149,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" convert: dependency: transitive description: @@ -178,10 +173,10 @@ packages: dependency: transitive description: name: dart_style - sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" url: "https://pub.dev" source: hosted - version: "2.3.7" + version: "2.3.6" eip1559: dependency: "direct main" description: @@ -328,14 +323,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" - macros: - dependency: transitive - description: - name: macros - sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" - url: "https://pub.dev" - source: hosted - version: "0.1.2-main.4" matcher: dependency: transitive description: @@ -500,7 +487,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_gen: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 30951ec..830f3d4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: variance_dart description: An Account Abstraction (4337) Development kit, for quickly building mobile web3 apps and smart wallets. -version: 0.1.8 +version: 0.1.9 documentation: https://docs.variance.space homepage: https://variance.space repository: https://github.com/vaariance/variance-dart