@mimicprotocol/cli 0.0.1-rc.16 → 0.0.1-rc.18

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.
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ build
3
+ types
@@ -1,7 +1,8 @@
1
- import { Transfer } from '@mimicprotocol/lib-ts'
1
+ import { ERC20Token, Transfer } from '@mimicprotocol/lib-ts'
2
2
 
3
3
  import { inputs } from './types'
4
4
 
5
5
  export default function main(): void {
6
- Transfer.create(inputs.chainId, inputs.token, inputs.amount, inputs.recipient, inputs.fee).send()
6
+ const token = ERC20Token.fromAddress(inputs.token, inputs.chainId)
7
+ Transfer.create(token, inputs.amount, inputs.recipient, inputs.maxFee).send()
7
8
  }
@@ -0,0 +1,40 @@
1
+ import { runTask, Transfer } from '@mimicprotocol/test-ts'
2
+ import { expect } from 'chai'
3
+
4
+ describe('Task', () => {
5
+ const taskDir = './'
6
+
7
+ const context = {
8
+ user: '0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0',
9
+ settlers: [{ address: '0xdcf1d9d12a0488dfb70a8696f44d6d3bc303963d', chainId: 10 }],
10
+ timestamp: Date.now(),
11
+ }
12
+
13
+ const inputs = {
14
+ chainId: 10, // Optimism
15
+ token: '0x7f5c764cbc14f9669b88837ca1490cca17c31607', // USDC
16
+ amount: '1000000', // 1 USDC
17
+ recipient: '0xbce3248ede29116e4bd18416dcc2dfca668eeb84',
18
+ maxFee: '100000', // 0.1 USDC
19
+ }
20
+
21
+ it('produces the expected intents', async () => {
22
+ const intents = (await runTask(taskDir, context, { inputs })) as Transfer[]
23
+
24
+ expect(intents).to.be.an('array')
25
+ expect(intents).to.have.lengthOf(1)
26
+
27
+ expect(intents[0].type).to.be.equal('transfer')
28
+ expect(intents[0].settler).to.be.equal(context.settlers[0].address)
29
+ expect(intents[0].user).to.be.equal(context.user)
30
+ expect(intents[0].chainId).to.be.equal(inputs.chainId)
31
+ expect(intents[0].maxFees).to.have.lengthOf(1)
32
+ expect(intents[0].maxFees[0].token).to.be.equal(inputs.token)
33
+ expect(intents[0].maxFees[0].amount).to.be.equal(inputs.maxFee)
34
+
35
+ expect(intents[0].transfers).to.have.lengthOf(1)
36
+ expect(intents[0].transfers[0].token).to.be.equal(inputs.token)
37
+ expect(intents[0].transfers[0].amount).to.be.equal(inputs.amount)
38
+ expect(intents[0].transfers[0].recipient).to.be.equal(inputs.recipient)
39
+ })
40
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimicprotocol/cli",
3
- "version": "0.0.1-rc.16",
3
+ "version": "0.0.1-rc.18",
4
4
  "license": "GPL-3.0",
5
5
  "private": false,
6
6
  "type": "commonjs",
@@ -1,48 +0,0 @@
1
- import { Context, runTask, Transfer } from '@mimicprotocol/test-ts'
2
- import { expect } from 'chai'
3
-
4
- describe('Task', () => {
5
- it('produces the expected intents', async () => {
6
- const taskDir = './'
7
-
8
- const context: Context = {
9
- user: '0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0',
10
- settlers: [
11
- {
12
- address: '0xdcf1d9d12a0488dfb70a8696f44d6d3bc303963d',
13
- chainId: 10,
14
- },
15
- ],
16
- configSig: '682ec8210b1ce912da4d2952',
17
- }
18
-
19
- const inputs = {
20
- chainId: 10,
21
- token: '0x7f5c764cbc14f9669b88837ca1490cca17c31607',
22
- amount: '10000000',
23
- recipient: context.user!,
24
- fee: '100',
25
- }
26
-
27
- const intents = await runTask(taskDir, context, { inputs })
28
-
29
- expect(intents).to.be.an('array').that.is.not.empty
30
- expect(intents).to.have.lengthOf(1)
31
-
32
- const intent = intents[0]
33
- expect(intent.type).to.be.equal('transfer')
34
- expect(intent.settler).to.be.equal(context.settlers![0].address)
35
- expect(intent.user).to.be.equal(context.user)
36
-
37
- const transferIntent = intent as Transfer
38
- expect(transferIntent.chainId).to.be.equal(inputs.chainId)
39
- expect(transferIntent.maxFees).to.have.lengthOf(1)
40
- expect(transferIntent.maxFees[0].token).to.be.equal(inputs.token)
41
- expect(transferIntent.maxFees[0].amount).to.be.equal(inputs.fee)
42
-
43
- expect(transferIntent.transfers).to.have.lengthOf(1)
44
- expect(transferIntent.transfers[0].token).to.be.equal(inputs.token)
45
- expect(transferIntent.transfers[0].amount).to.be.equal(inputs.amount)
46
- expect(transferIntent.transfers[0].recipient).to.be.equal(inputs.recipient)
47
- })
48
- })