Skip to content

Commit 45a5f9f

Browse files
alavarellolgalende
andauthored
Chore: Refactor intents with operations and add dynamic call (#222)
Co-authored-by: lgalende <63872655+lgalende@users.noreply.github.com> Co-authored-by: lgalende <lau@mimic.fi>
1 parent 561d73a commit 45a5f9f

47 files changed

Lines changed: 1459 additions & 1270 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/late-cobras-turn.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@mimicprotocol/test-ts": patch
3+
"@mimicprotocol/lib-ts": patch
4+
"@mimicprotocol/cli": patch
5+
---
6+
7+
Refactor intents to have operations and bump to runner version v0.1.0

.changeset/spicy-areas-switch.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@mimicprotocol/test-ts": minor
3+
"@mimicprotocol/lib-ts": minor
4+
"@mimicprotocol/cli": minor
5+
---
6+
7+
Add operations and dynamic call operation

packages/cli/tests/fixtures/functions/function.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Address, BigInt, Bytes, ERC20Token, EvmCallBuilder, NULL_ADDRESS, TokenAmount } from '@mimicprotocol/lib-ts'
1+
import {
2+
Address,
3+
BigInt,
4+
Bytes,
5+
ERC20Token,
6+
EvmCallBuilder,
7+
IntentBuilder,
8+
NULL_ADDRESS,
9+
TokenAmount,
10+
} from '@mimicprotocol/lib-ts'
211

312
/* eslint-disable @typescript-eslint/no-namespace */
413
declare namespace input {
@@ -16,5 +25,9 @@ export default function main(): void {
1625
const maxFeeAmount = BigInt.fromI32(input.firstStaticNumber).times(BigInt.fromI32(input.secondStaticNumber))
1726
const maxFee = TokenAmount.fromBigInt(maxFeeToken, maxFeeAmount)
1827

19-
EvmCallBuilder.forChain(chainId).addCall(target, data).addSettler(settler).addMaxFee(maxFee).build().send()
28+
new IntentBuilder()
29+
.addSettler(settler)
30+
.addMaxFee(maxFee)
31+
.addOperationBuilder(EvmCallBuilder.forChain(chainId).addCall(target, data))
32+
.send()
2033
}

packages/cli/tests/fixtures/functions/invalid-function.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
BlockchainToken,
55
Bytes,
66
EvmCallBuilder,
7+
IntentBuilder,
78
NULL_ADDRESS,
89
TokenAmount,
910
} from '@mimicprotocol/lib-ts'
@@ -17,5 +18,9 @@ export default function main(): void {
1718
const maxFeeAmount = BigInt.zero().plus(BigInt.fromI32(undeclaredVariable))
1819
const maxFee = TokenAmount.fromBigInt(maxFeeToken, maxFeeAmount)
1920

20-
EvmCallBuilder.forChain(chainId).addCall(target, data).addSettler(settler).addMaxFee(maxFee).build().send()
21+
new IntentBuilder()
22+
.addSettler(settler)
23+
.addMaxFee(maxFee)
24+
.addOperationBuilder(EvmCallBuilder.forChain(chainId).addCall(target, data))
25+
.send()
2126
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
_evmCall: {"op":2,"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","user":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0x0000000000000000000000000000000000000000","amount":"10"}],"events":[],"chainId":1,"calls":[{"target":"0x0000000000000000000000000000000000000000","data":"0x","value":"5"}]}
1+
_sendIntent: {"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","feePayer":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0x0000000000000000000000000000000000000000","amount":"10"}],"operations":[{"opType":2,"chainId":1,"user":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","events":[],"calls":[{"target":"0x0000000000000000000000000000000000000000","data":"0x","value":"5"}]}]}

packages/integration/tests/001-init-intent/src/function.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Bytes,
55
ChainId,
66
ERC20Token,
7-
EvmCallBuilder,
7+
IntentBuilder,
88
NULL_ADDRESS,
99
TokenAmount,
1010
} from '@mimicprotocol/lib-ts'
@@ -16,5 +16,5 @@ export default function main(): void {
1616
const value = BigInt.fromI32(5)
1717
const fee = TokenAmount.fromI32(ERC20Token.fromString(NULL_ADDRESS, chainId), 10)
1818

19-
EvmCallBuilder.forChain(chainId).addCall(target, data, value).addMaxFee(fee).build().send()
19+
new IntentBuilder().addMaxFee(fee).addEvmCallOperation(chainId, target, data, value).send()
2020
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
_evmCall: {"op":2,"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","user":"0xa000000000000000000000000000000000000001","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0xa000000000000000000000000000000000000003","amount":"10"}],"events":[],"chainId":1,"calls":[{"target":"0xa000000000000000000000000000000000000002","data":"0xabcdef0123456789","value":"1000000000000000000"}]}
1+
_sendIntent: {"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","feePayer":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0xa000000000000000000000000000000000000003","amount":"10"}],"operations":[{"opType":2,"chainId":1,"user":"0xa000000000000000000000000000000000000001","events":[],"calls":[{"target":"0xa000000000000000000000000000000000000002","data":"0xabcdef0123456789","value":"1000000000000000000"}]}]}

packages/integration/tests/002-evm-call-intent/src/function.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ export default function main(): void {
99
EvmCallBuilder.forChain(inputs.chainId)
1010
.addCall(inputs.target, inputs.data, inputs.value)
1111
.addUser(inputs.user)
12-
.addMaxFee(maxFee)
13-
.build()
14-
.send()
12+
.send(maxFee)
1513
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
_evmCall: {"op":2,"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","user":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0x0000000000000000000000000000000000000000","amount":"10"}],"events":[],"chainId":1,"calls":[{"target":"0x0000000000000000000000000000000000000000","data":"0x","value":"0"}]}
2-
_evmCall: {"op":2,"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","user":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0x0000000000000000000000000000000000000000","amount":"9"}],"events":[],"chainId":1,"calls":[{"target":"0x0000000000000000000000000000000000000000","data":"0x","value":"0"}]}
3-
_evmCall: {"op":2,"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","user":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0x0000000000000000000000000000000000000000","amount":"8"}],"events":[],"chainId":1,"calls":[{"target":"0x0000000000000000000000000000000000000000","data":"0x","value":"0"}]}
1+
_sendIntent: {"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","feePayer":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0x0000000000000000000000000000000000000000","amount":"10"}],"operations":[{"opType":2,"chainId":1,"user":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","events":[],"calls":[{"target":"0x0000000000000000000000000000000000000000","data":"0x","value":"0"}]}]}
2+
_sendIntent: {"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","feePayer":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0x0000000000000000000000000000000000000000","amount":"9"}],"operations":[{"opType":2,"chainId":1,"user":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","events":[],"calls":[{"target":"0x0000000000000000000000000000000000000000","data":"0x","value":"0"}]}]}
3+
_sendIntent: {"settler":"0x6b175474e89094c44da98b954eedeac495271d0f","feePayer":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","deadline":"1438223473","nonce":"0xabcd","maxFees":[{"token":"0x0000000000000000000000000000000000000000","amount":"8"}],"operations":[{"opType":2,"chainId":1,"user":"0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0","events":[],"calls":[{"target":"0x0000000000000000000000000000000000000000","data":"0x","value":"0"}]}]}

packages/integration/tests/003-multiple-evm-call-intents/src/function.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export default function main(): void {
88
const data = Bytes.empty()
99

1010
const fee1 = TokenAmount.fromI32(token, 10)
11-
EvmCallBuilder.forChain(inputs.chainId).addCall(target, data).addMaxFee(fee1).build().send()
11+
EvmCallBuilder.forChain(inputs.chainId).addCall(target, data).send(fee1)
1212

1313
const fee2 = fee1.minus(TokenAmount.fromI32(token, 1))
14-
EvmCallBuilder.forChain(inputs.chainId).addCall(target, data).addMaxFee(fee2).build().send()
14+
EvmCallBuilder.forChain(inputs.chainId).addCall(target, data).send(fee2)
1515

1616
const fee3 = fee1.minus(TokenAmount.fromI32(token, 2))
17-
EvmCallBuilder.forChain(inputs.chainId).addCall(target, data).addMaxFee(fee3).build().send()
17+
EvmCallBuilder.forChain(inputs.chainId).addCall(target, data).send(fee3)
1818
}

0 commit comments

Comments
 (0)