Skip to content

Commit 40e9d85

Browse files
authored
feat: add arbitrum one (#389)
* feat: add permit info for arbitrum one * feat: add permitinfo file checked against coingecko list https://tokens.coingecko.com/arbitrum-one/all.json * feat: update templates to allow adding arb1 tokens with gh forms * chore: update dependencies which support arb1 * chore: add commands related to arb1 * chore: update text
1 parent e437827 commit 40e9d85

File tree

10 files changed

+3036
-62
lines changed

10 files changed

+3036
-62
lines changed

.github/ISSUE_TEMPLATE/1-addTokenForm.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ body:
1313
Please fill in all the required fields in the form.
1414
We will process and evaluate your request as soon as possible.
1515
16-
Also, don't forget to update the issue title adding your token's `SYMBOL` and `NETWORK` (MAINNET or GNOSIS_CHAIN)
16+
Also, don't forget to update the issue title adding your token's `SYMBOL` and `NETWORK`.
1717
1818
## Disclaimer
1919
CoW DAO reserves the right, at its sole discretion, to accept or reject the listing of any token.
@@ -32,6 +32,7 @@ body:
3232
options:
3333
- MAINNET
3434
- GNOSIS_CHAIN
35+
- ARBITRUM_ONE
3536
validations:
3637
required: true
3738
- type: input

.github/ISSUE_TEMPLATE/2-addImageForm.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Add Image
22
description: Creates a request to add a token image to CoW Swap's image repository
3-
title: "[AddImage] `SYMBOL` on `NETWORK`"
3+
title: '[AddImage] `SYMBOL` on `NETWORK`'
44
labels: [addImage]
55

66
body:
@@ -9,11 +9,11 @@ body:
99
value: |
1010
# Request to ADD image
1111
Thank you for contributing to CoW Swap's image repository.
12-
12+
1313
Please fill in all the required fields in the form.
1414
We will process and evaluate your request as soon as possible.
15-
16-
Also, don't forget to update the issue title adding your token's `SYMBOL` and `NETWORK` (MAINNET or GNOSIS_CHAIN)
15+
16+
Also, don't forget to update the issue title adding your token's `SYMBOL` and `NETWORK`.
1717
1818
- type: dropdown
1919
id: network
@@ -24,6 +24,7 @@ body:
2424
options:
2525
- MAINNET
2626
- GNOSIS_CHAIN
27+
- ARBITRUM_ONE
2728
validations:
2829
required: true
2930
- type: input
@@ -40,4 +41,4 @@ body:
4041
description: Ideally a 256x256 PNG file. But we'll take care of optimizing it later.
4142
placeholder: https://gateway.pinata.cloud/ipfs/Qme9B6jRpGtZsRFcPjHvA5T4ugFuL4c3SzWfxyMPa59AMo
4243
validations:
43-
required: true
44+
required: true

.github/ISSUE_TEMPLATE/3-removeTokenForm.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Remove Token
22
description: Creates a request to remove a token from CoW Swap's default token list
3-
title: "[RemoveToken] `SYMBOL` on `NETWORK`"
3+
title: '[RemoveToken] `SYMBOL` on `NETWORK`'
44
labels: [removeToken]
55

66
body:
@@ -9,11 +9,11 @@ body:
99
value: |
1010
# Request to REMOVE token
1111
Thank you for contributing to CoW Swap's default token list.
12-
13-
Please fill in all the required fields in the form.
12+
13+
Please fill in all the required fields in the form.
1414
We will process and evaluate your request as soon as possible.
15-
16-
Also, don't forget to update the issue title adding your token's `SYMBOL` and `NETWORK` (MAINNET or GNOSIS_CHAIN)
15+
16+
Also, don't forget to update the issue title adding your token's `SYMBOL` and `NETWORK` (MAINNET or GNOSIS_CHAIN)
1717
1818
- type: dropdown
1919
id: network
@@ -24,6 +24,7 @@ body:
2424
options:
2525
- MAINNET
2626
- GNOSIS_CHAIN
27+
- ARBITRUM_ONE
2728
validations:
2829
required: true
2930
- type: input

.github/workflows/processRequest.yml

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
issue-number: ${{ github.event.issue.number }}
5252
body: |
5353
Your request has been received and is being processed.
54-
54+
5555
This issue will be updated when completed.
5656
5757
- name: Extract info
@@ -61,35 +61,38 @@ jobs:
6161
# Using JS, build a new comment body
6262
script: |
6363
const body = context.payload.issue.body
64-
64+
6565
const fieldNames = `${ process.env.FIELD_NAMES }`.split(',')
66-
66+
6767
// Extract the values for each field - if it exists - based on their labels from the issue body
6868
const values = fieldNames.reduce((acc, f) => {
6969
// Create a regex for each field, with capturing group with the same name
7070
const r = new RegExp(String.raw`${f}\s+(?<${f.toLowerCase()}>.*?)(\s+###|$)`, 's')
71-
71+
7272
// Build an object with the capturing group and value for each field
7373
return {...acc, ...body.match(r)?.groups}
7474
}, {})
75-
75+
7676
// Lower case the address at the source
7777
values.address = values.address.toLowerCase()
78-
78+
7979
if (values.network === 'MAINNET') {
8080
values.chainId = 1
8181
values.blockExplorer = 'etherscan'
82+
} else if () {
83+
values.chainId = 42161
84+
values.blockExplorer = 'arbiscan'
8285
} else {
8386
values.chainId = 100
8487
values.blockExplorer = 'gnosisscan'
8588
}
86-
89+
8790
// Used only in the PR context for displaying it
8891
values.prImageUrl = `https://raw.githubusercontent.com/cowprotocol/token-lists/{0}/${ values.chainId }_${ values.address }/src/public/images/${ values.chainId }/${ values.address }/logo.png`
8992
// Will be the final URL once it's merged to `main`
9093
values.logoURI = `https://raw.githubusercontent.com/cowprotocol/token-lists/main/src/public/images/${ values.chainId }/${ values.address }/logo.png`
91-
92-
94+
95+
9396
// Return a string
9497
return JSON.stringify(values)
9598
result-encoding: string
@@ -99,10 +102,10 @@ jobs:
99102
cat << EOF
100103
${{ steps.extractInfo.outputs.result }}
101104
EOF
102-
105+
103106
# force failure for testing
104107
# exit 1
105-
108+
106109
107110
validateInput:
108111
runs-on: ubuntu-latest
@@ -133,7 +136,7 @@ jobs:
133136
if: env.SYMBOL && contains(env.SYMBOL, ' ')
134137
run: |
135138
echo "${{ env.SYMBOL }}"
136-
echo "::error title={Validation failed}::{Symbol cannot contain spaces}"
139+
echo "::error title={Validation failed}::{Symbol cannot contain spaces}"
137140
exit 1
138141
- name: Validate removeToken
139142
if: contains(github.event.issue.labels.*.name, 'removeToken') && (!env.NETWORK || !env.REASON || !env.ADDRESS)
@@ -147,8 +150,8 @@ jobs:
147150
with:
148151
comment: |
149152
Invalid request
150-
151-
Make sure all the required fields are provided and submit a new issue
153+
154+
Make sure all the required fields are provided and submit a new issue
152155
153156
optimizeImage:
154157
needs: [ extractInfoFromIssue, validateInput ]
@@ -171,18 +174,18 @@ jobs:
171174
prTitle: "[addToken] `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).symbol }}` to `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).network }}`"
172175
prBody: |
173176
Adding token `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).symbol }}` on network `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).network }}`
174-
177+
175178
*Address*: `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).address }}`
176-
179+
177180
[Link to block explorer ↗︎](https://${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).blockExplorer }}.io/token/${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).address }})
178-
181+
179182
| Description | Image |
180183
|-|-|
181184
| Original | ![original](${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).url }}) |
182185
| Optimized | ![optimized](${{ format(fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).prImageUrl, 'addToken') }}) |
183-
186+
184187
### Reason
185-
188+
186189
```
187190
${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).reason }}
188191
```
@@ -198,13 +201,13 @@ jobs:
198201
prTitle: "[removeToken] `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).address }}` from `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).network }}`"
199202
prBody: |
200203
Removing token from network `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).network }}`
201-
204+
202205
*Address*: `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).address }}`
203-
206+
204207
[Link to block explorer ↗︎](https://${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).blockExplorer }}.io/token/${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).address }})
205-
208+
206209
### Reason
207-
210+
208211
```
209212
${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).reason }}
210213
```
@@ -220,11 +223,11 @@ jobs:
220223
prTitle: "[addImage] `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).address }}` to `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).network }}`"
221224
prBody: |
222225
Adding image to network `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).network }}`
223-
226+
224227
*Address*: `${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).address }}`
225-
228+
226229
[Link to block explorer ↗︎](https://${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).blockExplorer }}.io/token/${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).address }})
227-
230+
228231
| Description | Image |
229232
|-|-|
230233
| Original | ![original](${{ fromJSON(needs.extractInfoFromIssue.outputs.issueInfo).url }}) |

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616
"validate": "ajv -s node_modules/@uniswap/token-lists/dist/tokenlist.schema.json -d src/public/CowSwap.json -c ajv-formats --errors text",
1717
"fetchPermitInfo": "yarn run-script src/permitInfo/fetchPermitInfo.ts",
1818
"fetchPermitInfo:mainnet": "yarn run fetchPermitInfo -- 1",
19+
"fetchPermitInfo:arb1": "yarn run fetchPermitInfo -- 42161",
1920
"fetchPermitInfo:gnosis": "yarn run fetchPermitInfo -- 100",
2021
"fetchPermitInfo:sepolia": "yarn run fetchPermitInfo -- 11155111",
2122
"recheckPermitInfo:mainnet": "yarn run fetchPermitInfo -- 1 '' '' true",
23+
"recheckPermitInfo:arb1": "yarn run fetchPermitInfo -- 42161 '' '' true",
2224
"recheckPermitInfo:gnosis": "yarn run fetchPermitInfo -- 100 '' '' true",
2325
"recheckPermitInfo:sepolia": "yarn run fetchPermitInfo -- 11155111 '' '' true",
2426
"run-script": "node --loader ts-node/esm --experimental-json-modules --experimental-specifier-resolution=node",
2527
"test": "node --test"
2628
},
2729
"license": "(MIT OR Apache-2.0)",
2830
"dependencies": {
29-
"@cowprotocol/cow-sdk": "^5.1.0",
30-
"@cowprotocol/permit-utils": "^0.2.0",
31+
"@cowprotocol/cow-sdk": "^5.3.0-RC.1",
32+
"@cowprotocol/permit-utils": "^0.3.0-RC.0",
3133
"@uniswap/token-lists": "^1.0.0-beta.33",
3234
"ajv": "^8.12.0",
3335
"ajv-cli": "^5.0.0",
@@ -46,4 +48,4 @@
4648
"prettier": "^3.0.3",
4749
"typescript": "^5.2.2"
4850
}
49-
}
51+
}

src/permitInfo/const.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { env } from 'node:process'
1+
import { SupportedChainId } from '@cowprotocol/cow-sdk'
22
import { join } from 'node:path'
3-
import {SupportedChainId} from '@cowprotocol/cow-sdk'
3+
import { env } from 'node:process'
44

55
// CoW protocol contract address. Could be any address in theory for checking the token is permittable
66
export const SPENDER_ADDRESS = '0xC92E8bdf79f0507f65a392b0ab4667716BFE0110'
77

88
export const DEFAULT_RPC_URLS: Record<SupportedChainId, string> = {
99
[SupportedChainId.MAINNET]: 'https://mainnet.infura.io/v3/' + env.INFURA_API_KEY,
10+
[SupportedChainId.ARBITRUM_ONE]: 'https://arbitrum.meowrpc.com',
1011
[SupportedChainId.GNOSIS_CHAIN]: 'https://rpc.gnosischain.com',
1112
[SupportedChainId.SEPOLIA]: 'https://ethereum-sepolia.publicnode.com',
1213
}

src/permitInfo/utils/getProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { SupportedChainId } from '@cowprotocol/cow-sdk'
12
import { JsonRpcProvider } from '@ethersproject/providers'
2-
import { DEFAULT_RPC_URLS } from '../const'
33
import { ethers } from 'ethers'
4-
import {SupportedChainId} from '@cowprotocol/cow-sdk'
4+
import { DEFAULT_RPC_URLS } from '../const'
55

66
export function getProvider(chainId: number, rpcUrl: string | undefined): JsonRpcProvider {
77
const rpcEndpoint = rpcUrl ? rpcUrl : DEFAULT_RPC_URLS[chainId as SupportedChainId]
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1+
import { SupportedChainId } from '@cowprotocol/cow-sdk'
12
import { readFileSync } from 'node:fs'
3+
import { join } from 'node:path'
24
import { BASE_PATH } from '../const'
35
import { Token } from '../types'
4-
import { join } from 'node:path'
5-
import { SupportedChainId } from '@cowprotocol/cow-sdk'
66

77
const tokenListsByNetwork: Record<SupportedChainId, string> = {
88
[SupportedChainId.MAINNET]: 'CowSwap.json',
9+
[SupportedChainId.ARBITRUM_ONE]: 'CowSwap.json',
910
[SupportedChainId.GNOSIS_CHAIN]: 'CowSwap.json',
1011
[SupportedChainId.SEPOLIA]: 'CowSwapSepolia.json',
1112
}
1213

1314
export function getTokensFromTokenList(chainId: SupportedChainId, tokenListPath: string | undefined): Array<Token> {
14-
const filePath = tokenListPath
15-
? tokenListPath
16-
: join(BASE_PATH, tokenListsByNetwork[chainId])
15+
const filePath = tokenListPath ? tokenListPath : join(BASE_PATH, tokenListsByNetwork[chainId])
1716

1817
return JSON.parse(readFileSync(filePath, 'utf-8')).tokens
1918
}

0 commit comments

Comments
 (0)