Skip to content

Commit 3c74509

Browse files
committed
review changes
1 parent ea98761 commit 3c74509

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

examples/15-simple-dynamic-call/src/function.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ export default function main(): void {
3131
.addTokenInFromTokenAmount(amountIn)
3232
.addTokenOutFromTokenAmount(minAmountOut, smartAccount)
3333

34-
/*
35-
Dynamic call operation (called after the swap, using the received tokens)
36-
It is calling the contract of tokenOut.address on the transfer() function
37-
Using a literal address value for the first arg and the swap operation output as the second arg
38-
This would be equivalent of doing:
39-
`IERC20(tokenOut.address).transfer(to=recipient, value=result of swap)`
40-
*/
34+
/**
35+
* Dynamic call operation (executed after the swap using the received tokens).
36+
* Calls the `transfer()` function on the `tokenOut.address` contract.
37+
* Uses a literal address as the first argument and the swap output as the second.
38+
*
39+
* This is equivalent to:
40+
* `IERC20(tokenOut.address).transfer(to = recipient, value = swapResult)`
41+
*/
4142
const target = tokenOut.address
4243
const selector = Bytes.fromHexString('0xa9059cbb') // transfer() selector
4344
const dynamicCall = EvmDynamicCallBuilder.forChain(chainId)

examples/15-simple-dynamic-call/tests/function.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import { Chains, EvmDynamicCallOperation, OpType, randomEvmAddress, SwapOperation } from '@mimicprotocol/sdk'
2-
import { EvmCallQueryMock, runFunction, TokenPriceQueryMock } from '@mimicprotocol/test-ts'
1+
import { Chains, OpType, randomEvmAddress } from '@mimicprotocol/sdk'
2+
import {
3+
EvmCallQueryMock,
4+
EvmDynamicCallOperation,
5+
runFunction,
6+
SwapOperation,
7+
TokenPriceQueryMock,
8+
} from '@mimicprotocol/test-ts'
39
import { expect } from 'chai'
410

511
describe('Function', () => {
@@ -54,7 +60,6 @@ describe('Function', () => {
5460
expect(result.intents).to.have.lengthOf(1)
5561
const intent = result.intents[0]
5662

57-
expect(intent.feePayer).to.be.equal(context.user)
5863
expect(intent.feePayer).to.be.equal(context.user)
5964
expect(intent.maxFees).to.have.lengthOf(1)
6065
expect(intent.maxFees[0].token).to.be.equal('0x0000000000000000000000000000000000000348')

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ doctrine@^2.1.0:
15221522
dependencies:
15231523
esutils "^2.0.2"
15241524

1525-
dotenv@^17.0.0, dotenv@^17.2.3:
1525+
dotenv@^17.0.0:
15261526
version "17.4.2"
15271527
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-17.4.2.tgz#c07e54a746e11eba021dd9e1047ced5afdc1c034"
15281528
integrity sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==

0 commit comments

Comments
 (0)