• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cowprotocol / cow-sdk / 14001954831

21 Mar 2025 10:26PM UTC coverage: 73.659% (-3.4%) from 77.101%
14001954831

Pull #253

github

anxolin
chore: improve signatures
Pull Request #253: feat(bridging): get quote + post cross-chain swap

392 of 552 branches covered (71.01%)

Branch coverage included in aggregate %.

41 of 126 new or added lines in 16 files covered. (32.54%)

23 existing lines in 5 files now uncovered.

844 of 1126 relevant lines covered (74.96%)

16.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/weiroll/index.ts
1
import { Planner as WeirollPlanner, Contract as WeirollContract } from '@weiroll/weiroll.js'
2
import { Interface } from '@ethersproject/abi'
3
import { EvmCall } from '../common'
4
export { Contract as WeirollContract, Planner as WeirollPlanner } from '@weiroll/weiroll.js'
5
import { Contract as EthersContract } from '@ethersproject/contracts'
6

7
export enum WeirollCommandFlags {
8
  DELEGATECALL = 0,
9
  CALL = 1,
10
  STATICCALL = 2,
11
  CALL_WITH_VALUE = 3,
12
  CALLTYPE_MASK = 3,
13
  EXTENDED_COMMAND = 64,
14
  TUPLE_RETURN = 128,
15
}
16

17
const WEIROLL_ADDRESS = '0x9585c3062Df1C247d5E373Cfca9167F7dC2b5963'
2✔
18

19
const WEIROLL_ABI = [
2✔
20
  {
21
    inputs: [
22
      { internalType: 'uint256', name: 'command_index', type: 'uint256' },
23
      { internalType: 'address', name: 'target', type: 'address' },
24
      { internalType: 'string', name: 'message', type: 'string' },
25
    ],
26
    name: 'ExecutionFailed',
27
    type: 'error',
28
  },
29
  {
30
    inputs: [
31
      { internalType: 'bytes32[]', name: 'commands', type: 'bytes32[]' },
32
      { internalType: 'bytes[]', name: 'state', type: 'bytes[]' },
33
    ],
34
    name: 'execute',
35
    outputs: [{ internalType: 'bytes[]', name: '', type: 'bytes[]' }],
36
    stateMutability: 'payable',
37
    type: 'function',
38
  },
39
]
40

41
function getWeirollCalldata(planner: WeirollPlanner) {
42
  const planResult = planner.plan()
2✔
43
  const { commands, state } = planResult
2✔
44

45
  const weirollInterface = new Interface(WEIROLL_ABI)
2✔
46

47
  return weirollInterface.encodeFunctionData('execute', [commands, state])
2✔
48
}
49

50
/**
51
 * Create a weiroll transaction
52
 *
53
 * @param addToPlanner - A function that adds the commands to the planner
54
 *
55
 * @returns An EVM call
56
 */
57
export function createWeirollDelegateCall(addToPlanner: (planner: WeirollPlanner) => void): EvmCall {
58
  // Create a new planner
59
  const planner = new WeirollPlanner()
2✔
60

61
  // Add the commands to the planner
62
  addToPlanner(planner)
2✔
63

64
  // Get the EVM call
65
  return {
2✔
66
    to: WEIROLL_ADDRESS,
67
    value: BigInt(0),
68
    data: getWeirollCalldata(planner),
69
  }
70
}
71

72
export function createWeirollContract(contract: EthersContract, commandflags?: WeirollCommandFlags): WeirollContract {
73
  return WeirollContract.createContract(
1✔
74
    contract,
75
    commandflags as unknown as Parameters<typeof WeirollContract.createContract>[1]
76
  )
77
}
78

79
export function createWeirollLibrary(contract: EthersContract): WeirollContract {
NEW
80
  return WeirollContract.createLibrary(contract)
×
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc