Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FE Release 2024-05-15 #2642

Merged
merged 75 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
345ba64
Update bl
aureliusbtc May 7, 2024
540cd3a
chore: lint bl
ChiTimesChi May 7, 2024
b9652fb
RFQ: support multiple rebalance methods (#2556)
dwasse May 8, 2024
e6573c6
RFQ: add decimals cache (#2502)
dwasse May 8, 2024
9367858
CCTP: use chain listener instead of scribe (#2592)
dwasse May 8, 2024
7825fa4
docs(contracts-communication): move natspec from interfaces (#2595)
ChiTimesChi May 8, 2024
2c606ed
Publish
ChiTimesChi May 8, 2024
1c304ee
fix(sdk-rouder): remove cache hydration (#2597)
ChiTimesChi May 8, 2024
51503f4
Publish
ChiTimesChi May 8, 2024
ab56c7a
update bl
trajan0x May 9, 2024
3693110
Revert "update bl"
trajan0x May 9, 2024
0782d67
update bl
trajan0x May 9, 2024
a7d430c
feat(webhook): add webhook (#2538)
golangisfun123 May 9, 2024
db9440a
rfq api cache (#2562)
trajan0x May 9, 2024
1d3ed83
add trace to sync (#2601)
trajan0x May 9, 2024
bc97878
remove iconfig file (#2602)
trajan0x May 9, 2024
e6588f7
feat(contracts-communication): remove batching (#2599)
ChiTimesChi May 9, 2024
4d69f73
Publish
ChiTimesChi May 9, 2024
e18bf80
optional screener for cctp relayer (#2600)
trajan0x May 9, 2024
c920c85
Sin/testnet 9 (#2567)
ChiTimesChi May 9, 2024
f1f61b0
adding spectral coingecko ids for pricing (#2596)
Defi-Moses May 9, 2024
925447b
feat(widget): suppress console errors (#2594)
bigboydiamonds May 9, 2024
ca1690d
Publish
bigboydiamonds May 9, 2024
be4351b
fix(contracts-communication): interchain module ignore nonces (#2604)
ChiTimesChi May 9, 2024
172c009
Publish
ChiTimesChi May 9, 2024
4fcfcab
feat(synapse-interface): bridge gas handler (#2437)
bigboydiamonds May 9, 2024
84da80d
Publish
bigboydiamonds May 9, 2024
389ee74
add "and" (#2608)
nautsimon May 10, 2024
f4ee9d0
fix(contracts-communication): default settings for Guard service (#2605)
ChiTimesChi May 10, 2024
3f0b5ae
Publish
ChiTimesChi May 10, 2024
85a2a62
Fix: put blocking call to Start() in new goroutine (#2614)
dwasse May 10, 2024
2fcf06d
feat(contracts-communication): default values for modules/required re…
ChiTimesChi May 11, 2024
537755e
Publish
ChiTimesChi May 11, 2024
4aa97e4
RFQ: rebalance edge cases & refactoring (#2613)
dwasse May 11, 2024
38b8d90
refactor: move opinionated stuff into SynapseModule (#2617)
ChiTimesChi May 12, 2024
9b4ae6f
Publish
aureliusbtc May 12, 2024
acd3ed2
Document Modules (#2611)
trajan0x May 12, 2024
73b982e
cleanup (#2618)
trajan0x May 12, 2024
72ddf82
fix tests (#2620)
trajan0x May 12, 2024
578acef
RFQ API: replace `otelresty` with `otelhhtp` package (#2606)
dwasse May 12, 2024
8d91fb2
make coverage aggregator public (#2621)
trajan0x May 12, 2024
c9a982b
Publish
trajan0x May 12, 2024
8efa9c8
publish aggregator fix (#2622)
trajan0x May 12, 2024
daa6fd0
Publish
trajan0x May 12, 2024
382219d
fix(solidity-devops): update forge-std to 1.8.2 (#2619)
ChiTimesChi May 12, 2024
4403b44
Publish
ChiTimesChi May 12, 2024
41ef12b
feat(docs): auto deploy vercel to prod (only vercel) (#2627)
trajan0x May 13, 2024
1550dc5
fix(ci): fixes bug in #2627, deploys go to prod (#2628)
trajan0x May 13, 2024
33c3833
docs(contributing) add a guide on adding js packages (#2629)
trajan0x May 13, 2024
be2c740
revert coderabbit fix (#2630)
trajan0x May 13, 2024
cb72c21
prod release fix (#2631)
trajan0x May 13, 2024
46f4469
Publish
trajan0x May 13, 2024
0ae2f8e
add grafana dashboard and fix broken link (#2634)
trajan0x May 14, 2024
aa41b03
add scroll (#2635)
trajan0x May 14, 2024
fe7beae
Submitter: bump MaxResultsPerChain (#2633)
dwasse May 14, 2024
f110451
fast bridge regen (#2636)
trajan0x May 14, 2024
4508866
omnirpc doc fixes (#2637)
trajan0x May 14, 2024
e4330ba
fix typo (#2638)
trajan0x May 14, 2024
0074c21
Update bl
aureliusbtc May 14, 2024
c565e6d
Add SPECTRAL token support (#2640)
bigboydiamonds May 15, 2024
722c0f0
Publish
abtestingalpha May 15, 2024
102a010
feat(synapse-interface): Adds Scroll via RFQ (#2526)
abtestingalpha May 15, 2024
9b30673
Publish
abtestingalpha May 15, 2024
96f3e77
feat(widget): maintenance (#2616)
bigboydiamonds May 17, 2024
85e40c9
Publish
bigboydiamonds May 17, 2024
f9b6d45
RFQ API: add GET /ack endpoint (#2643)
dwasse May 20, 2024
cd9c482
Feat: lower submitter retry interval (#2645)
dwasse May 21, 2024
f6464df
update bl
aureliusbtc May 22, 2024
3476000
Adjusts banner date (#2647)
abtestingalpha May 22, 2024
ae07d12
Publish
abtestingalpha May 22, 2024
5233a25
Add SPEC token pricing to the manual cache (#2646)
Defi-Moses May 27, 2024
347eaa5
Update bl
aureliusbtc May 28, 2024
14d03f7
fix(screener): fix screener http 502 (#2650)
golangisfun123 May 30, 2024
171abd4
update bl
aureliusbtc May 30, 2024
24cba2c
update bl
aureliusbtc May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
key: docker-release-${{ runner.os }}-${{ matrix.package }}

- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
name: check if any changes warrant a new build of goreleaser-cgo-cross-compiler
id: changes
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lerna.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
types: [closed]
paths:
- 'packages/**'
- 'docs/**'
branches:
- master

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
fetch-depth: 0
# if any of these packages use submodules in the future, please uncomment this line
# submodules: 'recursive'
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter_solidity
with:
# make sure to update run-goreleaser when adding a new package here
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/ui-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
paths:
- 'packages/explorer-ui/**'
- 'packages/docs/**'
- 'docs/bridge/**'
- 'packages/synapse-interface/**'
jobs:
changes:
Expand All @@ -21,14 +21,14 @@ jobs:
fetch-depth: 0
# if any of these packages use submodules in the future, please uncomment this line
# submodules: 'recursive'
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter_ui
with:
# make sure to update run-goreleaser when adding a new package here
# also add to the get-project-id step
filters: |
explorer-ui: 'packages/explorer-ui/**'
docs: 'packages/docs/**'
docs: 'docs/bridge/**'
synapse-interface: 'packages/synapse-interface/**'
- id: length
run: |
Expand All @@ -47,6 +47,8 @@ jobs:
matrix:
package: ${{ fromJson(needs.changes.outputs.packages) }}
env:
# TODO: this appears to work even if package is not in packages/[package]
# (see the addition of docs for details). It's possible workign directory can be removd.
WORKING_DIRECTORY: 'packages/${{matrix.package}}'
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
VERCEL_TOKEN: '${{ secrets.VERCEL_TOKEN }}'
Expand Down Expand Up @@ -77,16 +79,22 @@ jobs:
echo "VERCEL_PROJECT_ID=$TARGET_ID" >> $GITHUB_ENV
- name: Install Vercel CLI
run: npm install --global [email protected]
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy to Vercel (Output Preview/Inspect Links)
if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) != github.ref }}
id: deploy
run: |
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
vercel build --token=${{ secrets.VERCEL_TOKEN }}
export DEPLOY_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
echo "DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_ENV
echo "::set-output name=url::$DEPLOY_URL"
- name: Deploy to Vercel (Output Prod)
if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }}
run: |
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod

- name: Update PR Description
if: ${{ github.event_name == 'pull_request' && format('refs/heads/{0}', github.event.repository.default_branch) != github.ref }}
uses: actions/github-script@v3
Expand Down
14 changes: 9 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"eslint.workingDirectories": [
{ "directory": "packages/contracts", "changeProcessCWD": true }
{
"directory": "packages/contracts",
"changeProcessCWD": true
}
],
"eslint.nodePath": "./node_modules/eslint/bin/",
"eslint.format.enable": true,
"editorconfig.generateAuto": false,
"files.trimTrailingWhitespace": true,
"solidity.packageDefaultDependenciesContractsDirectory": "contracts",
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.compileUsingRemoteVersion": "v0.8.17",
"solidity.formatter": "prettier"
}
"solidity.compileUsingRemoteVersion": "v0.8.17+commit.8df45f5f",
"solidity.formatter": "prettier",
"solidity.defaultCompiler": "remote"
}
1 change: 1 addition & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ignore: |
**/node_modules/**
**/charts/**
**/swagger.yaml
**/openapi.yaml

rules:
document-start:
Expand Down
3 changes: 1 addition & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ ethergo/ @trajan0x
make/ @trajan0x

packages/contracts-core/ @ChiTimesChi @trajan0x
packages/contracts-rfq @ChiTimesChi @mikeyrf
packages/docs/ @trajan0x
packages/contracts-rfq @ChiTimesChi
packages/sdk-router/ @aureliusbtc @ChiTimesChi @trajan0x
packages/explorer-ui/ @trajan0x @bigboydiamonds @abtestingalpha
packages/rest-api/ @trajan0x @Defi-Moses
Expand Down
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Contributions should roughly follow the [uber style guide](https://github.com/ub

<!-- todo: more-->

## Adding a new JS/TS Package

If you need to make a new JS/TS package, here are the steps to follow:

- If adding under `packages/*`, no need to do anything further.
- Otherwise, make sure you add the package to:
- `.github/workflows/lerna.yml` under paths. This will make sure that the package is built and tested in CI.
- `workspaces.packages` in packages.json. This will make sure that the package is built and tested locally.
- `lerna.json` under `packages` and `version` fields. This will make sure that the package is versioned correctly.
- If the package is a library that you'd like to publish, simply set the `private` field in `package.json` to `false` and the `publishConfig` access to public.
- If the package is a UI, please see [here](./.github/workflows/ui-preview.md) for instructions on configuring vercel. Make sure to update the paths there as well.

## Linting

Linting for go is used using [golangci-lint](https://golangci-lint.run/) at the latest released version. Please upgrade or install using your package manager. and run `make lint` from your desired module.
Expand Down
1 change: 1 addition & 0 deletions agents/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ require (
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/deepmap/oapi-codegen v1.8.2 // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/flowchartsman/swaggerui v0.0.0-20221017034628-909ed4f3701b // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions agents/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/flowchartsman/swaggerui v0.0.0-20221017034628-909ed4f3701b h1:oy54yVy300Db264NfQCJubZHpJOl+SoT6udALQdFbSI=
github.com/flowchartsman/swaggerui v0.0.0-20221017034628-909ed4f3701b/go.mod h1:/RJwPD5L4xWgCbqQ1L5cB12ndgfKKT54n9cZFf+8pus=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
github.com/friendsofgo/graphiql v0.2.2 h1:ccnuxpjgIkB+Lr9YB2ZouiZm7wvciSfqwpa9ugWzmn0=
Expand Down
2 changes: 1 addition & 1 deletion charts/screener/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.4
version: 0.2.5

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
2 changes: 1 addition & 1 deletion charts/screener/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
{{ toYaml .Values.files | indent 2 }}
{{ tpl (toYaml .Values.files) . | indent 2 }}
{{- end }}
1 change: 1 addition & 0 deletions committee/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ require (
github.com/fatih/structtag v1.2.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fjl/memsize v0.0.2 // indirect
github.com/flowchartsman/swaggerui v0.0.0-20221017034628-909ed4f3701b // indirect
github.com/flynn/noise v1.1.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions committee/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/flowchartsman/swaggerui v0.0.0-20221017034628-909ed4f3701b h1:oy54yVy300Db264NfQCJubZHpJOl+SoT6udALQdFbSI=
github.com/flowchartsman/swaggerui v0.0.0-20221017034628-909ed4f3701b/go.mod h1:/RJwPD5L4xWgCbqQ1L5cB12ndgfKKT54n9cZFf+8pus=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg=
github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
Expand Down
2 changes: 2 additions & 0 deletions contrib/promexporter/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/flowchartsman/swaggerui v0.0.0-20221017034628-909ed4f3701b h1:oy54yVy300Db264NfQCJubZHpJOl+SoT6udALQdFbSI=
github.com/flowchartsman/swaggerui v0.0.0-20221017034628-909ed4f3701b/go.mod h1:/RJwPD5L4xWgCbqQ1L5cB12ndgfKKT54n9cZFf+8pus=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down
1 change: 1 addition & 0 deletions contrib/promexporter/internal/gql/explorer/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions contrib/screener-api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ package client

import (
"context"
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"strings"
"time"

"github.com/dubonzi/otelresty"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
Expand All @@ -14,6 +21,7 @@ import (
// ScreenerClient is an interface for the Screener API.
type ScreenerClient interface {
ScreenAddress(ctx context.Context, ruleset, address string) (blocked bool, err error)
BlacklistAddress(ctx context.Context, appsecret string, appid string, body BlackListBody) (string, error)
}

type clientImpl struct {
Expand All @@ -37,6 +45,7 @@ type blockedResponse struct {
Blocked bool `json:"risk"`
}

// ScreenAddress checks if an address is blocked by the screener.
func (c clientImpl) ScreenAddress(ctx context.Context, ruleset, address string) (bool, error) {
var blockedRes blockedResponse
resp, err := c.rClient.R().
Expand All @@ -54,6 +63,73 @@ func (c clientImpl) ScreenAddress(ctx context.Context, ruleset, address string)
return blockedRes.Blocked, nil
}

// BlackListBody is the json payload that represents a blacklisted address.
type BlackListBody struct {
Type string `json:"type"`
ID string `json:"id"`
Data string `json:"data"`
Address string `json:"address"`
Network string `json:"network"`
Tag string `json:"tag"`
Remark string `json:"remark"`
}

type blacklistResponse struct {
Status string `json:"status"`
Error string `json:"error"`
}

func (c clientImpl) BlacklistAddress(ctx context.Context, appsecret string, appid string, body BlackListBody) (string, error) {
var blacklistRes blacklistResponse

nonce := strings.ReplaceAll(uuid.New().String(), "-", "")[:32]
timestamp := fmt.Sprintf("%d", time.Now().Unix())
queryString := ""

bodyBz, err := json.Marshal(body)
if err != nil {
return "", fmt.Errorf("error marshaling body: %w", err)
}

message := fmt.Sprintf("%s%s%s%s%s%s%s",
appid, timestamp, nonce, "POST", "/api/data/sync/", queryString, string(bodyBz))

signature := GenerateSignature(appsecret, message)

resp, err := c.rClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("AppID", appid).
SetHeader("Timestamp", timestamp).
SetHeader("Nonce", nonce).
SetHeader("QueryString", queryString).
SetHeader("Signature", signature).
SetBody(body).
SetResult(&blacklistRes).
Post("/api/data/sync/")

if err != nil {
return resp.Status(), fmt.Errorf("error from server: %s: %w", resp.String(), err)
}

if resp.IsError() {
return resp.Status(), fmt.Errorf("error from server: %s", resp.String())
}

return blacklistRes.Status, nil
}

// GenerateSignature generates a signature for the request.
func GenerateSignature(
secret,
message string,
) string {
key := []byte(secret)
h := hmac.New(sha256.New, key)
h.Write([]byte(message))
return hex.EncodeToString(h.Sum(nil))
}

// NewNoOpClient creates a new no-op client for the Screener API.
// it returns false for every address.
func NewNoOpClient() (ScreenerClient, error) {
Expand All @@ -66,4 +142,8 @@ func (n noOpClient) ScreenAddress(_ context.Context, _, _ string) (bool, error)
return false, nil
}

func (n noOpClient) BlacklistAddress(_ context.Context, _ string, _ string, _ BlackListBody) (string, error) {
return "", nil
}

var _ ScreenerClient = noOpClient{}
4 changes: 4 additions & 0 deletions contrib/screener-api/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import "time"

// Config is the configuration for the screener.
type Config struct {
// AppSecret is the app secret
AppSecret string `yaml:"app-secret"`
// AppID is the app id
AppID string `yaml:"app-id"`
// TRMKey is the api key for trmlabs
TRMKey string `yaml:"trm-key"`
// Rules of [caller_type]->risk_type
Expand Down
27 changes: 26 additions & 1 deletion contrib/screener-api/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@ package db
import (
"context"
"errors"
"github.com/synapsecns/sanguine/contrib/screener-api/trmlabs"
"time"

"github.com/synapsecns/sanguine/contrib/screener-api/trmlabs"
)

// BlacklistedAddressWriterDB provides methods to write blacklisted addresses to the database.
type BlacklistedAddressWriterDB interface {
PutBlacklistedAddress(ctx context.Context, body BlacklistedAddress) error
DeleteBlacklistedAddress(ctx context.Context, id string) error
UpdateBlacklistedAddress(ctx context.Context, id string, body BlacklistedAddress) error
}

// BlacklistedAddressReaderDB provides methods to read blacklisted addresses from the database.
type BlacklistedAddressReaderDB interface {
GetBlacklistedAddress(ctx context.Context, address string) (*BlacklistedAddress, error)
}

// BlacklistedAddressDB is the interface for reading and writing blacklisted addresses to the database.
type BlacklistedAddressDB interface {
BlacklistedAddressWriterDB
BlacklistedAddressReaderDB
}

// RuleWriterDB is the interface for writing rules to the database.
type RuleWriterDB interface {
PutAddressIndicators(ctx context.Context, address string, riskIndicator []trmlabs.AddressRiskIndicator) error
Expand All @@ -24,5 +43,11 @@ type RuleDB interface {
RuleReaderDB
}

// DB is the general database interface for the screener-api.
type DB interface {
BlacklistedAddressDB
RuleDB
}

// ErrNoAddressNotCached is returned when an address is not cached.
var ErrNoAddressNotCached = errors.New("address not cached")
Loading
Loading