eco-solver 0.0.1-security → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of eco-solver might be problematic. Click here for more details.
- package/.eslintignore +8 -0
- package/.eslintrc.js +24 -0
- package/.github/workflows/ci.yaml +38 -0
- package/.nvmrc +1 -0
- package/.prettierignore +3 -0
- package/.prettierrc +8 -0
- package/Dockerfile +11 -0
- package/LICENSE +21 -0
- package/README.md +29 -5
- package/config/default.ts +135 -0
- package/config/development.ts +95 -0
- package/config/preproduction.ts +17 -0
- package/config/production.ts +17 -0
- package/config/staging.ts +17 -0
- package/config/test.ts +7 -0
- package/index.js +66 -0
- package/jest.config.ts +14 -0
- package/nest-cli.json +8 -0
- package/package.json +115 -6
- package/src/api/api.module.ts +27 -0
- package/src/api/balance.controller.ts +41 -0
- package/src/api/quote.controller.ts +54 -0
- package/src/api/tests/balance.controller.spec.ts +113 -0
- package/src/api/tests/quote.controller.spec.ts +83 -0
- package/src/app.module.ts +74 -0
- package/src/balance/balance.module.ts +14 -0
- package/src/balance/balance.service.ts +230 -0
- package/src/balance/balance.ws.service.ts +104 -0
- package/src/balance/types.ts +16 -0
- package/src/bullmq/bullmq.helper.ts +41 -0
- package/src/bullmq/processors/eth-ws.processor.ts +47 -0
- package/src/bullmq/processors/inbox.processor.ts +55 -0
- package/src/bullmq/processors/interval.processor.ts +54 -0
- package/src/bullmq/processors/processor.module.ts +14 -0
- package/src/bullmq/processors/signer.processor.ts +41 -0
- package/src/bullmq/processors/solve-intent.processor.ts +73 -0
- package/src/bullmq/processors/tests/solve-intent.processor.spec.ts +3 -0
- package/src/bullmq/utils/queue.ts +22 -0
- package/src/chain-monitor/chain-monitor.module.ts +12 -0
- package/src/chain-monitor/chain-sync.service.ts +134 -0
- package/src/chain-monitor/tests/chain-sync.service.spec.ts +190 -0
- package/src/commander/.eslintrc.js +6 -0
- package/src/commander/balance/balance-command.module.ts +12 -0
- package/src/commander/balance/balance.command.ts +73 -0
- package/src/commander/command-main.ts +15 -0
- package/src/commander/commander-app.module.ts +31 -0
- package/src/commander/eco-config.command.ts +20 -0
- package/src/commander/safe/safe-command.module.ts +11 -0
- package/src/commander/safe/safe.command.ts +70 -0
- package/src/commander/transfer/client.command.ts +24 -0
- package/src/commander/transfer/transfer-command.module.ts +26 -0
- package/src/commander/transfer/transfer.command.ts +138 -0
- package/src/commander/utils.ts +8 -0
- package/src/common/chains/definitions/arbitrum.ts +12 -0
- package/src/common/chains/definitions/base.ts +21 -0
- package/src/common/chains/definitions/eco.ts +54 -0
- package/src/common/chains/definitions/ethereum.ts +22 -0
- package/src/common/chains/definitions/helix.ts +53 -0
- package/src/common/chains/definitions/mantle.ts +12 -0
- package/src/common/chains/definitions/optimism.ts +22 -0
- package/src/common/chains/definitions/polygon.ts +12 -0
- package/src/common/chains/supported.ts +26 -0
- package/src/common/chains/transport.ts +19 -0
- package/src/common/errors/eco-error.ts +155 -0
- package/src/common/events/constants.ts +3 -0
- package/src/common/events/viem.ts +22 -0
- package/src/common/logging/eco-log-message.ts +74 -0
- package/src/common/redis/constants.ts +55 -0
- package/src/common/redis/redis-connection-utils.ts +106 -0
- package/src/common/routes/constants.ts +3 -0
- package/src/common/utils/objects.ts +34 -0
- package/src/common/utils/strings.ts +49 -0
- package/src/common/utils/tests/objects.spec.ts +23 -0
- package/src/common/utils/tests/strings.spec.ts +22 -0
- package/src/common/viem/contracts.ts +25 -0
- package/src/common/viem/tests/utils.spec.ts +115 -0
- package/src/common/viem/utils.ts +78 -0
- package/src/contracts/ERC20.contract.ts +389 -0
- package/src/contracts/EntryPoint.V6.contract.ts +1309 -0
- package/src/contracts/KernelAccount.abi.ts +87 -0
- package/src/contracts/OwnableExecutor.abi.ts +128 -0
- package/src/contracts/SimpleAccount.contract.ts +524 -0
- package/src/contracts/inbox.ts +8 -0
- package/src/contracts/index.ts +9 -0
- package/src/contracts/intent-source.ts +55 -0
- package/src/contracts/interfaces/index.ts +1 -0
- package/src/contracts/interfaces/prover.interface.ts +22 -0
- package/src/contracts/prover.ts +9 -0
- package/src/contracts/tests/erc20.contract.spec.ts +59 -0
- package/src/contracts/utils.ts +31 -0
- package/src/decoder/decoder.interface.ts +3 -0
- package/src/decoder/tests/utils.spec.ts +36 -0
- package/src/decoder/utils.ts +24 -0
- package/src/decorators/cacheable.decorator.ts +48 -0
- package/src/eco-configs/aws-config.service.ts +75 -0
- package/src/eco-configs/eco-config.module.ts +44 -0
- package/src/eco-configs/eco-config.service.ts +220 -0
- package/src/eco-configs/eco-config.types.ts +278 -0
- package/src/eco-configs/interfaces/config-source.interface.ts +3 -0
- package/src/eco-configs/tests/aws-config.service.spec.ts +52 -0
- package/src/eco-configs/tests/eco-config.service.spec.ts +137 -0
- package/src/eco-configs/tests/utils.spec.ts +84 -0
- package/src/eco-configs/utils.ts +49 -0
- package/src/fee/fee.module.ts +10 -0
- package/src/fee/fee.service.ts +467 -0
- package/src/fee/tests/fee.service.spec.ts +909 -0
- package/src/fee/tests/utils.spec.ts +49 -0
- package/src/fee/types.ts +44 -0
- package/src/fee/utils.ts +23 -0
- package/src/flags/flags.module.ts +10 -0
- package/src/flags/flags.service.ts +112 -0
- package/src/flags/tests/flags.service.spec.ts +68 -0
- package/src/flags/utils.ts +22 -0
- package/src/health/constants.ts +1 -0
- package/src/health/health.controller.ts +23 -0
- package/src/health/health.module.ts +25 -0
- package/src/health/health.service.ts +40 -0
- package/src/health/indicators/balance.indicator.ts +196 -0
- package/src/health/indicators/eco-redis.indicator.ts +23 -0
- package/src/health/indicators/git-commit.indicator.ts +67 -0
- package/src/health/indicators/mongodb.indicator.ts +11 -0
- package/src/health/indicators/permission.indicator.ts +64 -0
- package/src/intent/create-intent.service.ts +129 -0
- package/src/intent/feasable-intent.service.ts +80 -0
- package/src/intent/fulfill-intent.service.ts +318 -0
- package/src/intent/intent.controller.ts +199 -0
- package/src/intent/intent.module.ts +49 -0
- package/src/intent/schemas/intent-call-data.schema.ts +16 -0
- package/src/intent/schemas/intent-data.schema.ts +114 -0
- package/src/intent/schemas/intent-source.schema.ts +33 -0
- package/src/intent/schemas/intent-token-amount.schema.ts +14 -0
- package/src/intent/schemas/reward-data.schema.ts +48 -0
- package/src/intent/schemas/route-data.schema.ts +52 -0
- package/src/intent/schemas/watch-event.schema.ts +32 -0
- package/src/intent/tests/create-intent.service.spec.ts +215 -0
- package/src/intent/tests/feasable-intent.service.spec.ts +155 -0
- package/src/intent/tests/fulfill-intent.service.spec.ts +564 -0
- package/src/intent/tests/utils-intent.service.spec.ts +308 -0
- package/src/intent/tests/utils.spec.ts +62 -0
- package/src/intent/tests/validate-intent.service.spec.ts +297 -0
- package/src/intent/tests/validation.service.spec.ts +337 -0
- package/src/intent/utils-intent.service.ts +168 -0
- package/src/intent/utils.ts +37 -0
- package/src/intent/validate-intent.service.ts +176 -0
- package/src/intent/validation.sevice.ts +223 -0
- package/src/interceptors/big-int.interceptor.ts +30 -0
- package/src/intervals/interval.module.ts +18 -0
- package/src/intervals/retry-infeasable-intents.service.ts +89 -0
- package/src/intervals/tests/retry-infeasable-intents.service.spec.ts +167 -0
- package/src/kms/errors.ts +0 -0
- package/src/kms/kms.module.ts +12 -0
- package/src/kms/kms.service.ts +65 -0
- package/src/kms/tests/kms.service.spec.ts +60 -0
- package/src/liquidity-manager/jobs/check-balances-cron.job.ts +229 -0
- package/src/liquidity-manager/jobs/liquidity-manager.job.ts +52 -0
- package/src/liquidity-manager/jobs/rebalance.job.ts +61 -0
- package/src/liquidity-manager/liquidity-manager.module.ts +29 -0
- package/src/liquidity-manager/processors/base.processor.ts +117 -0
- package/src/liquidity-manager/processors/eco-protocol-intents.processor.ts +34 -0
- package/src/liquidity-manager/processors/grouped-jobs.processor.ts +103 -0
- package/src/liquidity-manager/queues/liquidity-manager.queue.ts +48 -0
- package/src/liquidity-manager/schemas/rebalance-token.schema.ts +32 -0
- package/src/liquidity-manager/schemas/rebalance.schema.ts +32 -0
- package/src/liquidity-manager/services/liquidity-manager.service.ts +188 -0
- package/src/liquidity-manager/services/liquidity-provider.service.ts +25 -0
- package/src/liquidity-manager/services/liquidity-providers/LiFi/lifi-provider.service.spec.ts +125 -0
- package/src/liquidity-manager/services/liquidity-providers/LiFi/lifi-provider.service.ts +117 -0
- package/src/liquidity-manager/services/liquidity-providers/LiFi/utils/get-transaction-hashes.ts +16 -0
- package/src/liquidity-manager/tests/liquidity-manager.service.spec.ts +142 -0
- package/src/liquidity-manager/types/token-state.enum.ts +5 -0
- package/src/liquidity-manager/types/types.d.ts +52 -0
- package/src/liquidity-manager/utils/address.ts +5 -0
- package/src/liquidity-manager/utils/math.ts +9 -0
- package/src/liquidity-manager/utils/serialize.spec.ts +24 -0
- package/src/liquidity-manager/utils/serialize.ts +47 -0
- package/src/liquidity-manager/utils/token.ts +91 -0
- package/src/main.ts +63 -0
- package/src/nest-redlock/nest-redlock.config.ts +14 -0
- package/src/nest-redlock/nest-redlock.interface.ts +5 -0
- package/src/nest-redlock/nest-redlock.module.ts +64 -0
- package/src/nest-redlock/nest-redlock.service.ts +59 -0
- package/src/prover/proof.service.ts +184 -0
- package/src/prover/prover.module.ts +10 -0
- package/src/prover/tests/proof.service.spec.ts +154 -0
- package/src/quote/dto/quote.intent.data.dto.ts +35 -0
- package/src/quote/dto/quote.reward.data.dto.ts +67 -0
- package/src/quote/dto/quote.route.data.dto.ts +71 -0
- package/src/quote/dto/types.ts +18 -0
- package/src/quote/errors.ts +215 -0
- package/src/quote/quote.module.ts +17 -0
- package/src/quote/quote.service.ts +299 -0
- package/src/quote/schemas/quote-call.schema.ts +16 -0
- package/src/quote/schemas/quote-intent.schema.ts +27 -0
- package/src/quote/schemas/quote-reward.schema.ts +24 -0
- package/src/quote/schemas/quote-route.schema.ts +30 -0
- package/src/quote/schemas/quote-token.schema.ts +14 -0
- package/src/quote/tests/quote.service.spec.ts +444 -0
- package/src/sign/atomic-signer.service.ts +24 -0
- package/src/sign/atomic.nonce.service.ts +114 -0
- package/src/sign/kms-account/kmsToAccount.ts +73 -0
- package/src/sign/kms-account/signKms.ts +30 -0
- package/src/sign/kms-account/signKmsTransaction.ts +37 -0
- package/src/sign/kms-account/signKmsTypedData.ts +21 -0
- package/src/sign/nonce.service.ts +89 -0
- package/src/sign/schemas/nonce.schema.ts +36 -0
- package/src/sign/sign.controller.ts +52 -0
- package/src/sign/sign.helper.ts +23 -0
- package/src/sign/sign.module.ts +27 -0
- package/src/sign/signer-kms.service.ts +27 -0
- package/src/sign/signer.service.ts +26 -0
- package/src/solver/filters/tests/valid-smart-wallet.service.spec.ts +87 -0
- package/src/solver/filters/valid-smart-wallet.service.ts +58 -0
- package/src/solver/solver.module.ts +10 -0
- package/src/transaction/multichain-public-client.service.ts +15 -0
- package/src/transaction/smart-wallets/kernel/actions/encodeData.kernel.ts +57 -0
- package/src/transaction/smart-wallets/kernel/create-kernel-client-v2.account.ts +183 -0
- package/src/transaction/smart-wallets/kernel/create.kernel.account.ts +270 -0
- package/src/transaction/smart-wallets/kernel/index.ts +2 -0
- package/src/transaction/smart-wallets/kernel/kernel-account-client-v2.service.ts +90 -0
- package/src/transaction/smart-wallets/kernel/kernel-account-client.service.ts +107 -0
- package/src/transaction/smart-wallets/kernel/kernel-account.client.ts +105 -0
- package/src/transaction/smart-wallets/kernel/kernel-account.config.ts +34 -0
- package/src/transaction/smart-wallets/simple-account/create.simple.account.ts +19 -0
- package/src/transaction/smart-wallets/simple-account/index.ts +2 -0
- package/src/transaction/smart-wallets/simple-account/simple-account-client.service.ts +42 -0
- package/src/transaction/smart-wallets/simple-account/simple-account.client.ts +83 -0
- package/src/transaction/smart-wallets/simple-account/simple-account.config.ts +5 -0
- package/src/transaction/smart-wallets/smart-wallet.types.ts +38 -0
- package/src/transaction/smart-wallets/utils.ts +14 -0
- package/src/transaction/transaction.module.ts +25 -0
- package/src/transaction/viem_multichain_client.service.ts +100 -0
- package/src/transforms/viem-address.decorator.ts +14 -0
- package/src/utils/bigint.ts +44 -0
- package/src/utils/types.ts +18 -0
- package/src/watch/intent/tests/watch-create-intent.service.spec.ts +257 -0
- package/src/watch/intent/tests/watch-fulfillment.service.spec.ts +141 -0
- package/src/watch/intent/watch-create-intent.service.ts +106 -0
- package/src/watch/intent/watch-event.service.ts +133 -0
- package/src/watch/intent/watch-fulfillment.service.ts +115 -0
- package/src/watch/watch.module.ts +13 -0
- package/test/app.e2e-spec.ts +21 -0
- package/test/jest-e2e.json +9 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +29 -0
@@ -0,0 +1,524 @@
|
|
1
|
+
export const SimpleAccountAbi = [
|
2
|
+
{
|
3
|
+
inputs: [
|
4
|
+
{
|
5
|
+
internalType: 'contract IEntryPoint',
|
6
|
+
name: 'anEntryPoint',
|
7
|
+
type: 'address',
|
8
|
+
},
|
9
|
+
],
|
10
|
+
stateMutability: 'nonpayable',
|
11
|
+
type: 'constructor',
|
12
|
+
},
|
13
|
+
{
|
14
|
+
anonymous: false,
|
15
|
+
inputs: [
|
16
|
+
{
|
17
|
+
indexed: false,
|
18
|
+
internalType: 'address',
|
19
|
+
name: 'previousAdmin',
|
20
|
+
type: 'address',
|
21
|
+
},
|
22
|
+
{
|
23
|
+
indexed: false,
|
24
|
+
internalType: 'address',
|
25
|
+
name: 'newAdmin',
|
26
|
+
type: 'address',
|
27
|
+
},
|
28
|
+
],
|
29
|
+
name: 'AdminChanged',
|
30
|
+
type: 'event',
|
31
|
+
},
|
32
|
+
{
|
33
|
+
anonymous: false,
|
34
|
+
inputs: [
|
35
|
+
{
|
36
|
+
indexed: true,
|
37
|
+
internalType: 'address',
|
38
|
+
name: 'beacon',
|
39
|
+
type: 'address',
|
40
|
+
},
|
41
|
+
],
|
42
|
+
name: 'BeaconUpgraded',
|
43
|
+
type: 'event',
|
44
|
+
},
|
45
|
+
{
|
46
|
+
anonymous: false,
|
47
|
+
inputs: [
|
48
|
+
{
|
49
|
+
indexed: false,
|
50
|
+
internalType: 'uint8',
|
51
|
+
name: 'version',
|
52
|
+
type: 'uint8',
|
53
|
+
},
|
54
|
+
],
|
55
|
+
name: 'Initialized',
|
56
|
+
type: 'event',
|
57
|
+
},
|
58
|
+
{
|
59
|
+
anonymous: false,
|
60
|
+
inputs: [
|
61
|
+
{
|
62
|
+
indexed: true,
|
63
|
+
internalType: 'contract IEntryPoint',
|
64
|
+
name: 'entryPoint',
|
65
|
+
type: 'address',
|
66
|
+
},
|
67
|
+
{
|
68
|
+
indexed: true,
|
69
|
+
internalType: 'address',
|
70
|
+
name: 'owner',
|
71
|
+
type: 'address',
|
72
|
+
},
|
73
|
+
],
|
74
|
+
name: 'SimpleAccountInitialized',
|
75
|
+
type: 'event',
|
76
|
+
},
|
77
|
+
{
|
78
|
+
anonymous: false,
|
79
|
+
inputs: [
|
80
|
+
{
|
81
|
+
indexed: true,
|
82
|
+
internalType: 'address',
|
83
|
+
name: 'implementation',
|
84
|
+
type: 'address',
|
85
|
+
},
|
86
|
+
],
|
87
|
+
name: 'Upgraded',
|
88
|
+
type: 'event',
|
89
|
+
},
|
90
|
+
{
|
91
|
+
inputs: [],
|
92
|
+
name: 'addDeposit',
|
93
|
+
outputs: [],
|
94
|
+
stateMutability: 'payable',
|
95
|
+
type: 'function',
|
96
|
+
},
|
97
|
+
{
|
98
|
+
inputs: [],
|
99
|
+
name: 'entryPoint',
|
100
|
+
outputs: [
|
101
|
+
{
|
102
|
+
internalType: 'contract IEntryPoint',
|
103
|
+
name: '',
|
104
|
+
type: 'address',
|
105
|
+
},
|
106
|
+
],
|
107
|
+
stateMutability: 'view',
|
108
|
+
type: 'function',
|
109
|
+
},
|
110
|
+
{
|
111
|
+
inputs: [
|
112
|
+
{
|
113
|
+
internalType: 'address',
|
114
|
+
name: 'dest',
|
115
|
+
type: 'address',
|
116
|
+
},
|
117
|
+
{
|
118
|
+
internalType: 'uint256',
|
119
|
+
name: 'value',
|
120
|
+
type: 'uint256',
|
121
|
+
},
|
122
|
+
{
|
123
|
+
internalType: 'bytes',
|
124
|
+
name: 'func',
|
125
|
+
type: 'bytes',
|
126
|
+
},
|
127
|
+
],
|
128
|
+
name: 'execute',
|
129
|
+
outputs: [],
|
130
|
+
stateMutability: 'nonpayable',
|
131
|
+
type: 'function',
|
132
|
+
},
|
133
|
+
{
|
134
|
+
inputs: [
|
135
|
+
{
|
136
|
+
internalType: 'address[]',
|
137
|
+
name: 'dest',
|
138
|
+
type: 'address[]',
|
139
|
+
},
|
140
|
+
{
|
141
|
+
internalType: 'bytes[]',
|
142
|
+
name: 'func',
|
143
|
+
type: 'bytes[]',
|
144
|
+
},
|
145
|
+
],
|
146
|
+
name: 'executeBatch',
|
147
|
+
outputs: [],
|
148
|
+
stateMutability: 'nonpayable',
|
149
|
+
type: 'function',
|
150
|
+
},
|
151
|
+
{
|
152
|
+
inputs: [],
|
153
|
+
name: 'getDeposit',
|
154
|
+
outputs: [
|
155
|
+
{
|
156
|
+
internalType: 'uint256',
|
157
|
+
name: '',
|
158
|
+
type: 'uint256',
|
159
|
+
},
|
160
|
+
],
|
161
|
+
stateMutability: 'view',
|
162
|
+
type: 'function',
|
163
|
+
},
|
164
|
+
{
|
165
|
+
inputs: [],
|
166
|
+
name: 'getNonce',
|
167
|
+
outputs: [
|
168
|
+
{
|
169
|
+
internalType: 'uint256',
|
170
|
+
name: '',
|
171
|
+
type: 'uint256',
|
172
|
+
},
|
173
|
+
],
|
174
|
+
stateMutability: 'view',
|
175
|
+
type: 'function',
|
176
|
+
},
|
177
|
+
{
|
178
|
+
inputs: [
|
179
|
+
{
|
180
|
+
internalType: 'address',
|
181
|
+
name: 'anOwner',
|
182
|
+
type: 'address',
|
183
|
+
},
|
184
|
+
],
|
185
|
+
name: 'initialize',
|
186
|
+
outputs: [],
|
187
|
+
stateMutability: 'nonpayable',
|
188
|
+
type: 'function',
|
189
|
+
},
|
190
|
+
{
|
191
|
+
inputs: [
|
192
|
+
{
|
193
|
+
internalType: 'address',
|
194
|
+
name: '',
|
195
|
+
type: 'address',
|
196
|
+
},
|
197
|
+
{
|
198
|
+
internalType: 'address',
|
199
|
+
name: '',
|
200
|
+
type: 'address',
|
201
|
+
},
|
202
|
+
{
|
203
|
+
internalType: 'uint256[]',
|
204
|
+
name: '',
|
205
|
+
type: 'uint256[]',
|
206
|
+
},
|
207
|
+
{
|
208
|
+
internalType: 'uint256[]',
|
209
|
+
name: '',
|
210
|
+
type: 'uint256[]',
|
211
|
+
},
|
212
|
+
{
|
213
|
+
internalType: 'bytes',
|
214
|
+
name: '',
|
215
|
+
type: 'bytes',
|
216
|
+
},
|
217
|
+
],
|
218
|
+
name: 'onERC1155BatchReceived',
|
219
|
+
outputs: [
|
220
|
+
{
|
221
|
+
internalType: 'bytes4',
|
222
|
+
name: '',
|
223
|
+
type: 'bytes4',
|
224
|
+
},
|
225
|
+
],
|
226
|
+
stateMutability: 'pure',
|
227
|
+
type: 'function',
|
228
|
+
},
|
229
|
+
{
|
230
|
+
inputs: [
|
231
|
+
{
|
232
|
+
internalType: 'address',
|
233
|
+
name: '',
|
234
|
+
type: 'address',
|
235
|
+
},
|
236
|
+
{
|
237
|
+
internalType: 'address',
|
238
|
+
name: '',
|
239
|
+
type: 'address',
|
240
|
+
},
|
241
|
+
{
|
242
|
+
internalType: 'uint256',
|
243
|
+
name: '',
|
244
|
+
type: 'uint256',
|
245
|
+
},
|
246
|
+
{
|
247
|
+
internalType: 'uint256',
|
248
|
+
name: '',
|
249
|
+
type: 'uint256',
|
250
|
+
},
|
251
|
+
{
|
252
|
+
internalType: 'bytes',
|
253
|
+
name: '',
|
254
|
+
type: 'bytes',
|
255
|
+
},
|
256
|
+
],
|
257
|
+
name: 'onERC1155Received',
|
258
|
+
outputs: [
|
259
|
+
{
|
260
|
+
internalType: 'bytes4',
|
261
|
+
name: '',
|
262
|
+
type: 'bytes4',
|
263
|
+
},
|
264
|
+
],
|
265
|
+
stateMutability: 'pure',
|
266
|
+
type: 'function',
|
267
|
+
},
|
268
|
+
{
|
269
|
+
inputs: [
|
270
|
+
{
|
271
|
+
internalType: 'address',
|
272
|
+
name: '',
|
273
|
+
type: 'address',
|
274
|
+
},
|
275
|
+
{
|
276
|
+
internalType: 'address',
|
277
|
+
name: '',
|
278
|
+
type: 'address',
|
279
|
+
},
|
280
|
+
{
|
281
|
+
internalType: 'uint256',
|
282
|
+
name: '',
|
283
|
+
type: 'uint256',
|
284
|
+
},
|
285
|
+
{
|
286
|
+
internalType: 'bytes',
|
287
|
+
name: '',
|
288
|
+
type: 'bytes',
|
289
|
+
},
|
290
|
+
],
|
291
|
+
name: 'onERC721Received',
|
292
|
+
outputs: [
|
293
|
+
{
|
294
|
+
internalType: 'bytes4',
|
295
|
+
name: '',
|
296
|
+
type: 'bytes4',
|
297
|
+
},
|
298
|
+
],
|
299
|
+
stateMutability: 'pure',
|
300
|
+
type: 'function',
|
301
|
+
},
|
302
|
+
{
|
303
|
+
inputs: [],
|
304
|
+
name: 'owner',
|
305
|
+
outputs: [
|
306
|
+
{
|
307
|
+
internalType: 'address',
|
308
|
+
name: '',
|
309
|
+
type: 'address',
|
310
|
+
},
|
311
|
+
],
|
312
|
+
stateMutability: 'view',
|
313
|
+
type: 'function',
|
314
|
+
},
|
315
|
+
{
|
316
|
+
inputs: [],
|
317
|
+
name: 'proxiableUUID',
|
318
|
+
outputs: [
|
319
|
+
{
|
320
|
+
internalType: 'bytes32',
|
321
|
+
name: '',
|
322
|
+
type: 'bytes32',
|
323
|
+
},
|
324
|
+
],
|
325
|
+
stateMutability: 'view',
|
326
|
+
type: 'function',
|
327
|
+
},
|
328
|
+
{
|
329
|
+
inputs: [
|
330
|
+
{
|
331
|
+
internalType: 'bytes4',
|
332
|
+
name: 'interfaceId',
|
333
|
+
type: 'bytes4',
|
334
|
+
},
|
335
|
+
],
|
336
|
+
name: 'supportsInterface',
|
337
|
+
outputs: [
|
338
|
+
{
|
339
|
+
internalType: 'bool',
|
340
|
+
name: '',
|
341
|
+
type: 'bool',
|
342
|
+
},
|
343
|
+
],
|
344
|
+
stateMutability: 'view',
|
345
|
+
type: 'function',
|
346
|
+
},
|
347
|
+
{
|
348
|
+
inputs: [
|
349
|
+
{
|
350
|
+
internalType: 'address',
|
351
|
+
name: '',
|
352
|
+
type: 'address',
|
353
|
+
},
|
354
|
+
{
|
355
|
+
internalType: 'address',
|
356
|
+
name: '',
|
357
|
+
type: 'address',
|
358
|
+
},
|
359
|
+
{
|
360
|
+
internalType: 'address',
|
361
|
+
name: '',
|
362
|
+
type: 'address',
|
363
|
+
},
|
364
|
+
{
|
365
|
+
internalType: 'uint256',
|
366
|
+
name: '',
|
367
|
+
type: 'uint256',
|
368
|
+
},
|
369
|
+
{
|
370
|
+
internalType: 'bytes',
|
371
|
+
name: '',
|
372
|
+
type: 'bytes',
|
373
|
+
},
|
374
|
+
{
|
375
|
+
internalType: 'bytes',
|
376
|
+
name: '',
|
377
|
+
type: 'bytes',
|
378
|
+
},
|
379
|
+
],
|
380
|
+
name: 'tokensReceived',
|
381
|
+
outputs: [],
|
382
|
+
stateMutability: 'pure',
|
383
|
+
type: 'function',
|
384
|
+
},
|
385
|
+
{
|
386
|
+
inputs: [
|
387
|
+
{
|
388
|
+
internalType: 'address',
|
389
|
+
name: 'newImplementation',
|
390
|
+
type: 'address',
|
391
|
+
},
|
392
|
+
],
|
393
|
+
name: 'upgradeTo',
|
394
|
+
outputs: [],
|
395
|
+
stateMutability: 'nonpayable',
|
396
|
+
type: 'function',
|
397
|
+
},
|
398
|
+
{
|
399
|
+
inputs: [
|
400
|
+
{
|
401
|
+
internalType: 'address',
|
402
|
+
name: 'newImplementation',
|
403
|
+
type: 'address',
|
404
|
+
},
|
405
|
+
{
|
406
|
+
internalType: 'bytes',
|
407
|
+
name: 'data',
|
408
|
+
type: 'bytes',
|
409
|
+
},
|
410
|
+
],
|
411
|
+
name: 'upgradeToAndCall',
|
412
|
+
outputs: [],
|
413
|
+
stateMutability: 'payable',
|
414
|
+
type: 'function',
|
415
|
+
},
|
416
|
+
{
|
417
|
+
inputs: [
|
418
|
+
{
|
419
|
+
components: [
|
420
|
+
{
|
421
|
+
internalType: 'address',
|
422
|
+
name: 'sender',
|
423
|
+
type: 'address',
|
424
|
+
},
|
425
|
+
{
|
426
|
+
internalType: 'uint256',
|
427
|
+
name: 'nonce',
|
428
|
+
type: 'uint256',
|
429
|
+
},
|
430
|
+
{
|
431
|
+
internalType: 'bytes',
|
432
|
+
name: 'initCode',
|
433
|
+
type: 'bytes',
|
434
|
+
},
|
435
|
+
{
|
436
|
+
internalType: 'bytes',
|
437
|
+
name: 'callData',
|
438
|
+
type: 'bytes',
|
439
|
+
},
|
440
|
+
{
|
441
|
+
internalType: 'uint256',
|
442
|
+
name: 'callGasLimit',
|
443
|
+
type: 'uint256',
|
444
|
+
},
|
445
|
+
{
|
446
|
+
internalType: 'uint256',
|
447
|
+
name: 'verificationGasLimit',
|
448
|
+
type: 'uint256',
|
449
|
+
},
|
450
|
+
{
|
451
|
+
internalType: 'uint256',
|
452
|
+
name: 'preVerificationGas',
|
453
|
+
type: 'uint256',
|
454
|
+
},
|
455
|
+
{
|
456
|
+
internalType: 'uint256',
|
457
|
+
name: 'maxFeePerGas',
|
458
|
+
type: 'uint256',
|
459
|
+
},
|
460
|
+
{
|
461
|
+
internalType: 'uint256',
|
462
|
+
name: 'maxPriorityFeePerGas',
|
463
|
+
type: 'uint256',
|
464
|
+
},
|
465
|
+
{
|
466
|
+
internalType: 'bytes',
|
467
|
+
name: 'paymasterAndData',
|
468
|
+
type: 'bytes',
|
469
|
+
},
|
470
|
+
{
|
471
|
+
internalType: 'bytes',
|
472
|
+
name: 'signature',
|
473
|
+
type: 'bytes',
|
474
|
+
},
|
475
|
+
],
|
476
|
+
internalType: 'struct UserOperation',
|
477
|
+
name: 'userOp',
|
478
|
+
type: 'tuple',
|
479
|
+
},
|
480
|
+
{
|
481
|
+
internalType: 'bytes32',
|
482
|
+
name: 'userOpHash',
|
483
|
+
type: 'bytes32',
|
484
|
+
},
|
485
|
+
{
|
486
|
+
internalType: 'uint256',
|
487
|
+
name: 'missingAccountFunds',
|
488
|
+
type: 'uint256',
|
489
|
+
},
|
490
|
+
],
|
491
|
+
name: 'validateUserOp',
|
492
|
+
outputs: [
|
493
|
+
{
|
494
|
+
internalType: 'uint256',
|
495
|
+
name: 'validationData',
|
496
|
+
type: 'uint256',
|
497
|
+
},
|
498
|
+
],
|
499
|
+
stateMutability: 'nonpayable',
|
500
|
+
type: 'function',
|
501
|
+
},
|
502
|
+
{
|
503
|
+
inputs: [
|
504
|
+
{
|
505
|
+
internalType: 'address payable',
|
506
|
+
name: 'withdrawAddress',
|
507
|
+
type: 'address',
|
508
|
+
},
|
509
|
+
{
|
510
|
+
internalType: 'uint256',
|
511
|
+
name: 'amount',
|
512
|
+
type: 'uint256',
|
513
|
+
},
|
514
|
+
],
|
515
|
+
name: 'withdrawDepositTo',
|
516
|
+
outputs: [],
|
517
|
+
stateMutability: 'nonpayable',
|
518
|
+
type: 'function',
|
519
|
+
},
|
520
|
+
{
|
521
|
+
stateMutability: 'payable',
|
522
|
+
type: 'receive',
|
523
|
+
},
|
524
|
+
] as const
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { InboxAbi } from '@eco-foundation/routes-ts'
|
2
|
+
import { ExtractAbiEvent } from 'abitype'
|
3
|
+
import { Prettify, Log } from 'viem'
|
4
|
+
|
5
|
+
// Define the type for the Fulfillment event log
|
6
|
+
export type FulfillmentLog = Prettify<
|
7
|
+
Log<bigint, number, false, ExtractAbiEvent<typeof InboxAbi, 'Fulfillment'>, true>
|
8
|
+
>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export * from './ERC20.contract'
|
2
|
+
export * from './intent-source'
|
3
|
+
export * from './prover'
|
4
|
+
export * from './SimpleAccount.contract'
|
5
|
+
export * from './utils'
|
6
|
+
export * from './KernelAccount.abi'
|
7
|
+
export * from './OwnableExecutor.abi'
|
8
|
+
// interfaces
|
9
|
+
export * from './interfaces'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { decodeEventLog, DecodeEventLogReturnType, GetEventArgs, Hex, Log, Prettify } from 'viem'
|
2
|
+
import { ExtractAbiEvent } from 'abitype'
|
3
|
+
import { Network } from 'alchemy-sdk'
|
4
|
+
import { IntentSourceAbi } from '@eco-foundation/routes-ts'
|
5
|
+
import { CallDataType, RewardTokensType } from '@/quote/dto/types'
|
6
|
+
|
7
|
+
// Define the type for the IntentSource struct in the contract, and add the hash and logIndex fields
|
8
|
+
export type IntentCreatedEventViemType = Prettify<
|
9
|
+
GetEventArgs<
|
10
|
+
typeof IntentSourceAbi,
|
11
|
+
'IntentCreated',
|
12
|
+
{
|
13
|
+
EnableUnion: true
|
14
|
+
IndexedOnly: false
|
15
|
+
Required: false
|
16
|
+
}
|
17
|
+
> & {
|
18
|
+
hash: Hex
|
19
|
+
logIndex: number
|
20
|
+
}
|
21
|
+
>
|
22
|
+
/**
|
23
|
+
* Define the interface for the calls field in the IntentSource event
|
24
|
+
*/
|
25
|
+
export interface CallDataInterface extends CallDataType {}
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Define the interface for the token amount field in the IntentSource event
|
29
|
+
*/
|
30
|
+
export interface RewardTokensInterface extends RewardTokensType {}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Define the type for the IntentSource event log
|
34
|
+
*/
|
35
|
+
export type IntentCreatedEventLog = DecodeEventLogReturnType<
|
36
|
+
typeof IntentSourceAbi,
|
37
|
+
'IntentCreated'
|
38
|
+
>
|
39
|
+
|
40
|
+
// Define the type for the IntentCreated event log
|
41
|
+
export type IntentCreatedLog = Prettify<
|
42
|
+
Log<bigint, number, false, ExtractAbiEvent<typeof IntentSourceAbi, 'IntentCreated'>, true> & {
|
43
|
+
sourceNetwork: Network
|
44
|
+
sourceChainID: bigint
|
45
|
+
}
|
46
|
+
>
|
47
|
+
|
48
|
+
export function decodeCreateIntentLog(data: Hex, topics: [signature: Hex, ...args: Hex[]] | []) {
|
49
|
+
return decodeEventLog({
|
50
|
+
abi: IntentSourceAbi,
|
51
|
+
eventName: 'IntentCreated',
|
52
|
+
topics,
|
53
|
+
data,
|
54
|
+
})
|
55
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './prover.interface'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { ViemCall } from '../utils'
|
2
|
+
|
3
|
+
export const ProverInterfaceAbi = [
|
4
|
+
{
|
5
|
+
inputs: [],
|
6
|
+
name: 'getProofType',
|
7
|
+
outputs: [
|
8
|
+
{
|
9
|
+
internalType: 'enum IProver.ProofType',
|
10
|
+
name: '',
|
11
|
+
type: 'uint8',
|
12
|
+
},
|
13
|
+
],
|
14
|
+
stateMutability: 'pure',
|
15
|
+
type: 'function',
|
16
|
+
},
|
17
|
+
] as const
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Call type for the getProofType function
|
21
|
+
*/
|
22
|
+
export type ProofCall = ViemCall<typeof ProverInterfaceAbi, 'pure'>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { isERC20Target } from '@/contracts/ERC20.contract'
|
2
|
+
const address1 = '0x1111111111111111111111111111111111111111'
|
3
|
+
|
4
|
+
describe('ERC20 contract', () => {
|
5
|
+
describe('on isERC20Target', () => {
|
6
|
+
it('should return false if the target data is null', async () => {
|
7
|
+
expect(isERC20Target(null)).toBe(false)
|
8
|
+
})
|
9
|
+
|
10
|
+
it('should return false if the target data is not erc20', async () => {
|
11
|
+
expect(
|
12
|
+
isERC20Target({
|
13
|
+
targetConfig: { contractType: 'erc721' },
|
14
|
+
} as any),
|
15
|
+
).toBe(false)
|
16
|
+
})
|
17
|
+
|
18
|
+
it('should return false if the target selector isnt the permitted selector', async () => {
|
19
|
+
expect(
|
20
|
+
isERC20Target(
|
21
|
+
{
|
22
|
+
targetConfig: { contractType: 'erc20' },
|
23
|
+
selector: '0x70a08231', //balanceOf
|
24
|
+
} as any,
|
25
|
+
'0xa123123',
|
26
|
+
),
|
27
|
+
).toBe(false)
|
28
|
+
})
|
29
|
+
|
30
|
+
it('should return false if the target selector is not transfer', async () => {
|
31
|
+
expect(
|
32
|
+
isERC20Target({
|
33
|
+
targetConfig: { contractType: 'erc20' },
|
34
|
+
selector: '0x70a08231', //balanceOf
|
35
|
+
} as any),
|
36
|
+
).toBe(false)
|
37
|
+
})
|
38
|
+
|
39
|
+
it('should return false if the target selector args are incorrect', async () => {
|
40
|
+
expect(
|
41
|
+
isERC20Target({
|
42
|
+
targetConfig: { contractType: 'erc20' },
|
43
|
+
selector: '0xa9059cbb', //transfer
|
44
|
+
decodedFunctionData: { args: [address1] },
|
45
|
+
} as any),
|
46
|
+
).toBe(false)
|
47
|
+
})
|
48
|
+
|
49
|
+
it('should return true if the target selector and args are for erc20 transfer', async () => {
|
50
|
+
expect(
|
51
|
+
isERC20Target({
|
52
|
+
targetConfig: { contractType: 'erc20' },
|
53
|
+
selector: '0xa9059cbb', //transfer
|
54
|
+
decodedFunctionData: { args: [address1, 100n] },
|
55
|
+
} as any),
|
56
|
+
).toBe(true)
|
57
|
+
})
|
58
|
+
})
|
59
|
+
})
|