|
1 | | -import { EvmCallIntent, OpType, randomEvmAddress } from '@mimicprotocol/sdk' |
2 | | -import { Context, EvmCallQueryMock, runFunction, TokenPriceQueryMock } from '@mimicprotocol/test-ts' |
| 1 | +import { OpType, randomEvmAddress } from '@mimicprotocol/sdk' |
| 2 | +import { CallOperation, Context, EvmCallQueryMock, runFunction, TokenPriceQueryMock } from '@mimicprotocol/test-ts' |
3 | 3 | import { expect } from 'chai' |
4 | 4 | import { Interface } from 'ethers' |
5 | 5 |
|
@@ -128,28 +128,29 @@ describe('Function', () => { |
128 | 128 | expect(result.success).to.be.true |
129 | 129 | expect(result.timestamp).to.be.equal(context.timestamp) |
130 | 130 |
|
131 | | - const intents = result.intents as EvmCallIntent[] |
132 | | - expect(intents).to.have.lengthOf(1) |
| 131 | + expect(result.intents).to.have.lengthOf(1) |
| 132 | + const intent = result.intents[0] |
| 133 | + const op = intent.operations[0] as CallOperation |
133 | 134 |
|
134 | | - expect(intents[0].op).to.be.equal(OpType.EvmCall) |
135 | | - expect(intents[0].settler).to.be.equal(context.settlers?.[0].address) |
136 | | - expect(intents[0].user).to.be.equal(inputs.smartAccount) |
137 | | - expect(intents[0].chainId).to.be.equal(inputs.chainId) |
| 135 | + expect(op.opType).to.be.equal(OpType.EvmCall) |
| 136 | + expect(intent.settler).to.be.equal(context.settlers?.[0].address) |
| 137 | + expect(op.user).to.be.equal(inputs.smartAccount) |
| 138 | + expect(op.chainId).to.be.equal(inputs.chainId) |
138 | 139 |
|
139 | 140 | const expectedApproveData = ERC20Interface.encodeFunctionData('approve', [aavePool, balance]) |
140 | | - expect(intents[0].calls[0].target).to.be.equal(underlyingToken) |
141 | | - expect(intents[0].calls[0].value).to.be.equal('0') |
142 | | - expect(intents[0].calls[0].data).to.be.equal(expectedApproveData) |
| 141 | + expect(op.calls[0].target).to.be.equal(underlyingToken) |
| 142 | + expect(op.calls[0].value).to.be.equal('0') |
| 143 | + expect(op.calls[0].data).to.be.equal(expectedApproveData) |
143 | 144 |
|
144 | 145 | const expectedSupplyData = AavePoolInterface.encodeFunctionData('supply(address,uint256,address,uint16)', [ |
145 | 146 | underlyingToken, |
146 | 147 | balance, |
147 | 148 | inputs.smartAccount, |
148 | 149 | 0, |
149 | 150 | ]) |
150 | | - expect(intents[0].calls[1].target).to.be.equal(aavePool) |
151 | | - expect(intents[0].calls[1].value).to.be.equal('0') |
152 | | - expect(intents[0].calls[1].data).to.be.equal(expectedSupplyData) |
| 151 | + expect(op.calls[1].target).to.be.equal(aavePool) |
| 152 | + expect(op.calls[1].value).to.be.equal('0') |
| 153 | + expect(op.calls[1].data).to.be.equal(expectedSupplyData) |
153 | 154 |
|
154 | 155 | expect(result.logs).to.have.lengthOf(1) |
155 | 156 | expect(result.logs[0]).to.be.equal('[Info] Underlying balance in USD: 11') |
|
0 commit comments