@@ -162,39 +162,43 @@ export const shouldBehaveLikeLSP17 = (buildContext: () => Promise<LSP17TestConte
162
162
} ) ;
163
163
164
164
describe ( 'when making a call with sending value' , ( ) => {
165
- it ( 'should pass and emit UniversalReceiver' , async ( ) => {
166
- const amountSent = 200 ;
165
+ describe ( 'when extension is not payable' , ( ) => {
166
+ it ( 'should pass and emit UniversalReceiver' , async ( ) => {
167
+ const amountSent = 200 ;
167
168
168
- const tx = await context . accounts [ 0 ] . sendTransaction ( {
169
- to : context . contract . address ,
170
- value : amountSent ,
171
- } ) ;
169
+ const tx = await context . accounts [ 0 ] . sendTransaction ( {
170
+ to : context . contract . address ,
171
+ value : amountSent ,
172
+ } ) ;
173
+
174
+ const isSupportingLSP0 = await context . contract . supportsInterface (
175
+ INTERFACE_IDS . LSP0ERC725Account ,
176
+ ) ;
172
177
173
- const isSupportingLSP0 = await context . contract . supportsInterface (
174
- INTERFACE_IDS . LSP0ERC725Account ,
175
- ) ;
176
-
177
- const isSupportingLSP9 = await context . contract . supportsInterface ( INTERFACE_IDS . LSP9Vault ) ;
178
-
179
- let emittedTypeId ;
180
- if ( isSupportingLSP0 ) {
181
- emittedTypeId = LSP1_TYPE_IDS . LSP0ValueReceived ;
182
- } else if ( isSupportingLSP9 ) {
183
- emittedTypeId = LSP1_TYPE_IDS . LSP9ValueReceived ;
184
- }
185
-
186
- expect ( tx )
187
- . to . emit ( context . contract , 'UniversalReceiver' )
188
- . withArgs (
189
- context . accounts [ 0 ] . address ,
190
- amountSent ,
191
- emittedTypeId ,
192
- '0x' ,
193
- abiCoder . encode (
194
- [ 'bytes' , 'bytes' ] ,
195
- [ ethers . utils . hexlify ( ethers . utils . toUtf8Bytes ( 'LSP1: typeId out of scope' ) ) , '0x' ] ,
196
- ) ,
178
+ const isSupportingLSP9 = await context . contract . supportsInterface (
179
+ INTERFACE_IDS . LSP9Vault ,
197
180
) ;
181
+
182
+ let emittedTypeId ;
183
+ if ( isSupportingLSP0 ) {
184
+ emittedTypeId = LSP1_TYPE_IDS . LSP0ValueReceived ;
185
+ } else if ( isSupportingLSP9 ) {
186
+ emittedTypeId = LSP1_TYPE_IDS . LSP9ValueReceived ;
187
+ }
188
+
189
+ expect ( tx )
190
+ . to . emit ( context . contract , 'UniversalReceiver' )
191
+ . withArgs (
192
+ context . accounts [ 0 ] . address ,
193
+ amountSent ,
194
+ emittedTypeId ,
195
+ '0x' ,
196
+ abiCoder . encode (
197
+ [ 'bytes' , 'bytes' ] ,
198
+ [ ethers . utils . hexlify ( ethers . utils . toUtf8Bytes ( 'LSP1: typeId out of scope' ) ) , '0x' ] ,
199
+ ) ,
200
+ ) ;
201
+ } ) ;
198
202
} ) ;
199
203
} ) ;
200
204
} ) ;
@@ -457,6 +461,35 @@ export const shouldBehaveLikeLSP17 = (buildContext: () => Promise<LSP17TestConte
457
461
} ) ;
458
462
} ) ;
459
463
464
+ describe ( 'when the extension function is payable' , ( ) => {
465
+ it ( 'should forward the value to the extension' , async ( ) => {
466
+ const transferExtension = await new TransferExtension__factory (
467
+ context . accounts [ 0 ] ,
468
+ ) . deploy ( ) ;
469
+
470
+ await context . contract
471
+ . connect ( context . deployParams . owner )
472
+ . setData ( transferFunctionExtensionHandlerKey , transferExtension . address ) ;
473
+
474
+ const amountTransferred = 20 ;
475
+
476
+ const transferFunctionSignature =
477
+ transferFunctionSelector +
478
+ abiCoder . encode ( [ 'uint256' ] , [ amountTransferred ] ) . substring ( 2 ) ;
479
+
480
+ await context . accounts [ 0 ] . sendTransaction ( {
481
+ to : context . contract . address ,
482
+ data : transferFunctionSignature ,
483
+ } ) ;
484
+
485
+ const balanceAfter = await transferExtension . callStatic . balances (
486
+ context . accounts [ 0 ] . address ,
487
+ ) ;
488
+
489
+ expect ( balanceAfter ) . to . equal ( amountTransferred ) ;
490
+ } ) ;
491
+ } ) ;
492
+
460
493
describe ( 'when calling an extension that returns a string' , ( ) => {
461
494
let nameExtension : FakeContract ;
462
495
0 commit comments