Skip to content

Commit 037cfa7

Browse files
EnoRageTanz0rzraverianov
authored
feat: global refactoring (#38)
Co-authored-by: Tanz0rz <[email protected]> Co-authored-by: Roman Averianov <[email protected]>
1 parent bcfbca9 commit 037cfa7

File tree

236 files changed

+18818
-7468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+18818
-7468
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @jeyldii @krboktv @Tanz0rz @enorage

.github/workflows/pr.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: PR validation
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '**.md'
7+
- '**.png'
8+
- .gitignore
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code into workspace directory
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Go 1.21
18+
uses: actions/setup-go@v3
19+
with:
20+
go-version: '1.21.0'
21+
22+
- name: Unit tests
23+
run: make test
24+
25+
lint:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Set up Go 1.21
29+
uses: actions/setup-go@v3
30+
with:
31+
go-version: 1.21
32+
- name: Checkout code into workspace directory
33+
uses: actions/checkout@v3
34+
35+
- name: Lint
36+
uses: golangci/golangci-lint-action@v3
37+
with:
38+
args: --timeout=3m
39+
version: v1.54.1
40+
skip-cache: true

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release new version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
type: choice
8+
description: Version
9+
options:
10+
- patch
11+
- minor
12+
- major
13+
- prerelease
14+
15+
jobs:
16+
create:
17+
name: Create Release
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.21.0'
27+
28+
- name: Build
29+
run: go build -v ./...
30+
31+
- name: Create Release
32+
id: create_release
33+
uses: actions/create-release@v1
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
with:
37+
tag_name: ${{ github.event.inputs.version }}
38+
release_name: Release ${{ github.event.inputs.version }}
39+
draft: false
40+
prerelease: false

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
.idea/
22
.vscode/
3-
swagger-dynamic/*.json
43
/tmp
4+
/bin
5+
6+
### macOS ###
7+
*.DS_Store
8+
.AppleDouble
9+
.LSOverride

CHANGELOG.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,69 @@
11
# Release(March 9, 2024)
2+
23
Tag: [v0.0.3-developer-preview](https://github.com/1inch/1inch-sdk/releases/tag/v0.0.3-developer-preview)
34

45
### New Features and Enhancements:
5-
- All non-global query configurations have been moved to the request-level params ([PR](https://github.com/1inch/1inch-sdk/pull/6))
6+
7+
- All non-global query configurations have been moved to the request-level
8+
params ([PR](https://github.com/1inch/1inch-sdk/pull/6))
69
- RPC providers for all chains will now be defined/set at SDK startup
710
- Query parameters now use concrete types instead of pointers ([PR](https://github.com/1inch/1inch-sdk/pull/16))
811
- Limit orders created within the SDK now support auto-expiration ([PR](https://github.com/1inch/1inch-sdk/pull/23))
9-
- Permit1 properly supported for limit orders when possible (fallback to Approval if Permit1 does not work) ([commit](https://github.com/1inch/1inch-sdk/commit/f2e79e5f0e81503bfeeff076e41455e86e5a5120))
10-
- When creating a limit order, integrators can error out when an approval is needed. This is useful for integrators who want all onchain actions to be performed manually by their users ([PR](https://github.com/1inch/1inch-sdk/pull/26))
12+
- Permit1 properly supported for limit orders when possible (fallback to Approval if Permit1 does not
13+
work) ([commit](https://github.com/1inch/1inch-sdk/commit/f2e79e5f0e81503bfeeff076e41455e86e5a5120))
14+
- When creating a limit order, integrators can error out when an approval is needed. This is useful for integrators who
15+
want all onchain actions to be performed manually by their users ([PR](https://github.com/1inch/1inch-sdk/pull/26))
1116

1217
### Optimizations and Bug Fixes:
13-
- Tenderly forks are cleaned up automatically at the beginning of each test run ([PR](https://github.com/1inch/1inch-sdk/pull/6))
14-
- Validation pattern for swagger-generated input params is now fully handled on all endpoints ([PR](https://github.com/1inch/1inch-sdk/pull/8))
15-
- Project-wide validation scripts added to verify validation logic standards ([PR](https://github.com/1inch/1inch-sdk/pull/11))
18+
19+
- Tenderly forks are cleaned up automatically at the beginning of each test
20+
run ([PR](https://github.com/1inch/1inch-sdk/pull/6))
21+
- Validation pattern for swagger-generated input params is now fully handled on all
22+
endpoints ([PR](https://github.com/1inch/1inch-sdk/pull/8))
23+
- Project-wide validation scripts added to verify validation logic
24+
standards ([PR](https://github.com/1inch/1inch-sdk/pull/11))
1625

1726
# Release(January 23, 2024)
27+
1828
Tag: [v0.0.2-developer-preview](https://github.com/1inch/1inch-sdk/releases/tag/v0.0.2-developer-preview)
1929

2030
### New Features and Enhancements:
31+
2132
- **Added Tenderly support for e2e swap tests**
2233
- e2e tests will now create forks, apply state overrides, and run simulations when a Tenderly API key is provided.
2334
- **Added approval type selection**
2435
- Users can choose between `Approve` and `Permit1` (`Permit2` currently unsupported)
2536
- **Implemented nonce cache to address RPC lag**
26-
- Once a wallet has posted a transaction, the nonce of that transaction is tracked and incremented internally by the SDK.
37+
- Once a wallet has posted a transaction, the nonce of that transaction is tracked and incremented internally by the
38+
SDK.
2739

2840
### Optimizations and Bug Fixes:
41+
2942
- Updated orderbook to use string inputs instead of integers to support all of uint256.
3043
- Increased gas limit and reduced permit duration to improve transactions success and debugging.
3144
- Moved Actions into a service within the main client to consolidate SDK structure.
3245
- Simplified tests and refactored onchain actions to have more uniformity across the library.
3346

34-
# Release(January 15, 2024)
35-
Tag: [v0.0.1-developer-preview](https://github.com/1inch/1inch-sdk/releases/tag/v0.0.1-developer-preview)
47+
# Release(January 15, 2024)
3648

49+
Tag: [v0.0.1-developer-preview](https://github.com/1inch/1inch-sdk/releases/tag/v0.0.1-developer-preview)
3750

3851
### New Features and Enhancements:
3952

4053
### Limit Order support
54+
4155
- Enables posting orders to the 1inch Limit Order Protocol
4256
- Enables reading orders from the 1inch Limit Order Protocol
4357
- Most endpoints from the Limit Order API supported
4458
- `has-active-orders-with-permit` REST endpoint still untested
4559

4660
### Aggregator Protocol support
61+
4762
- All REST endpoints supported
4863
- Get quotes and swap data from the Aggregator Protocol
4964

5065
### Onchain execution support
66+
5167
- Execute swaps onchain from within the SDK
5268

5369

DEVELOPMENT.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
This SDK will be open for contributions from the community. Contribution guidelines will be added soon!
22

3-
43
### Versioning
54

6-
This library is currently in the developer preview phase (versions 0.x.x). There will be significant changes to the design of this library leading up to a 1.0.0 release. You can expect the API calls, library structure, etc. to break between each release. Once the library version reaches 1.0.0 and beyond, it will follow traditional semver conventions.
5+
This library is currently in the developer preview phase (versions 0.x.x). There will be significant changes to the
6+
design of this library leading up to a 1.0.0 release. You can expect the API calls, library structure, etc. to break
7+
between each release. Once the library version reaches 1.0.0 and beyond, it will follow traditional semver conventions.
78

89
### Project structure
910

10-
This SDK is powered by a [client struct](https://github.com/1inch/1inch-sdk/blob/main/golang/client/client.go) that contains instances of all Services used to talk to the 1inch APIs
11+
This SDK is powered by a [client struct](https://github.com/1inch/1inch-sdk/blob/main/golang/client/client.go) that
12+
contains instances of all Services used to talk to the 1inch APIs
1113

12-
Each Service maps 1-to-1 with the underlying Dev Portal REST API. See [SwapService](https://github.com/1inch/1inch-sdk/blob/main/golang/client/swap.go) as an example. Under each function, you will find the matching REST API path)
14+
Each Service maps 1-to-1 with the underlying Dev Portal REST API.
15+
See [SwapService](https://github.com/1inch/1inch-sdk/blob/main/golang/client/swap.go) as an example. Under each
16+
function, you will find the matching REST API path)
1317

14-
Each Service uses various types and functions to do its job that are kept separate from the main service file. These can be found in the accompanying folder within the client directory (see the [swap](https://github.com/1inch/1inch-sdk/tree/main/golang/client/swap) package)
18+
Each Service uses various types and functions to do its job that are kept separate from the main service file. These can
19+
be found in the accompanying folder within the client directory (see
20+
the [swap](https://github.com/1inch/1inch-sdk/tree/main/golang/client/swap) package)
1521

1622
### Type generation
1723

18-
Type generation is done using the `generate_types.sh` script. To add a new swagger file or update an existing one, place the swagger file in `swagger-static` and run the script. It will generate the types file and place it in the appropriately-named sub-folder inside the `client` directory
24+
Type generation is done using the `generate_types.sh` script. To add a new openapi file or update an existing one, place
25+
the openapi file in `openapi` and run the script from the root of the project. It will generate the types files for all openapi specs and place them in the
26+
appropriately-named sub-folder inside the `generatedtypes` directory.
27+
28+
### OpenAPI file formatting
1929

20-
### Swagger file formatting
21-
For consistency, Swagger files should be formatted with `prettier`
30+
For consistency, openapi files should be formatted with `prettier`
2231

2332
This can be installed globally using npm:
2433

Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#! /usr/bin/make -f
2+
3+
MAKEFLAGS += --silent
4+
5+
# Go related variables.
6+
GOBASE := $(shell pwd)
7+
GOBIN := $(GOBASE)/bin
8+
GOPKG := $(.)
9+
# A valid GOPATH is required to use the `go get` command.
10+
# If $GOPATH is not specified, $HOME/go will be used by default
11+
GOPATH := $(if $(GOPATH),$(GOPATH),~/go)
12+
13+
get:
14+
@echo " > Checking if there are any missing dependencies..."
15+
GOBIN=$(GOBIN) go get ./... $(get)
16+
17+
test:
18+
@echo " > Running unit tests"
19+
GOBIN=$(GOBIN) go test -race ./...
20+
21+
fmt:
22+
@echo " > Running go fmt"
23+
GOBIN=$(GOBIN) go fmt ./...
24+
25+
lint: go-lint
26+
27+
go-lint-install:
28+
@echo " > Installing golint"
29+
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.54.1
30+
31+
go-lint:
32+
@echo " > Checking if golint is installed..."
33+
@if [ ! -x "./bin/golangci-lint" ]; then \
34+
echo "golangci-lint not found, installing..."; \
35+
$(MAKE) go-lint-install; \
36+
fi
37+
@echo " > Running golint"
38+
@./bin/golangci-lint version
39+
@./bin/golangci-lint run --timeout=2m
40+
41+
codegen-types:
42+
@echo "Running generate_types.sh from the codegen directory..."
43+
@cd codegen && ./generate_types.sh
44+
@echo "Script execution completed."

0 commit comments

Comments
 (0)