Skip to content

Commit f3671f3

Browse files
feat: add swap icy webhook
1 parent 9fa782f commit f3671f3

File tree

39 files changed

+3109
-29
lines changed

39 files changed

+3109
-29
lines changed

cmd/revert-icy/main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"github.com/dwarvesf/fortress-api/pkg/config"
5+
"github.com/dwarvesf/fortress-api/pkg/controller"
6+
"github.com/dwarvesf/fortress-api/pkg/job"
7+
"github.com/dwarvesf/fortress-api/pkg/logger"
8+
"github.com/dwarvesf/fortress-api/pkg/service"
9+
"github.com/dwarvesf/fortress-api/pkg/store"
10+
)
11+
12+
func main() {
13+
cfg := config.LoadConfig(config.DefaultConfigLoaders())
14+
log := logger.NewLogrusLogger()
15+
log.Infof("Server starting")
16+
17+
s := store.New()
18+
repo := store.NewPostgresStore(cfg)
19+
svc := service.New(cfg, s, repo)
20+
ctrl := controller.New(s, repo, svc, nil, log, cfg)
21+
22+
if err := job.NewRevertIcy(ctrl, s, repo, svc, log, cfg).Run(); err != nil {
23+
log.Fatal(err, "failed to run job")
24+
return
25+
}
26+
27+
log.Infof("done")
28+
}

codebase.md

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ require (
1919
github.com/go-playground/validator/v10 v10.14.1
2020
github.com/go-testfixtures/testfixtures/v3 v3.9.0
2121
github.com/goccy/go-json v0.10.2
22-
github.com/golang-jwt/jwt v3.2.2+incompatible
2322
github.com/golang-jwt/jwt/v4 v4.5.0
2423
github.com/golang/mock v1.6.0
2524
github.com/google/go-cmp v0.6.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14j
276276
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
277277
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
278278
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
279-
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
280-
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
281279
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
282280
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
283281
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- +migrate Up
2+
CREATE TABLE icy_swap_btc_requests (
3+
id uuid PRIMARY KEY DEFAULT (uuid()),
4+
profile_id varchar(255) NOT NULL,
5+
request_code varchar(255) NOT NULL,
6+
tx_status varchar(255),
7+
tx_id int,
8+
btc_address varchar(255),
9+
timestamp integer,
10+
amount varchar(255),
11+
token_name varchar(255),
12+
token_id varchar(255),
13+
swap_request_status varchar(255),
14+
swap_request_error text,
15+
revert_status varchar(255),
16+
revert_error text,
17+
withdraw_status varchar(255),
18+
withdraw_error text,
19+
tx_swap text,
20+
tx_deposit text,
21+
created_at TIMESTAMP(6) DEFAULT NOW(),
22+
updated_at TIMESTAMP(6) DEFAULT NOW()
23+
);
24+
25+
CREATE INDEX idx_icy_swap_btc_profile_id ON icy_swap_btc_requests(profile_id);
26+
CREATE INDEX idx_icy_swap_btc_request_code ON icy_swap_btc_requests(request_code);
27+
28+
-- +migrate Down
29+
DROP INDEX IF EXISTS idx_icy_swap_btc_profile_id;
30+
DROP INDEX IF EXISTS idx_icy_swap_btc_request_code;
31+
DROP TABLE icy_swap_btc_requests;

pkg/config/config.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Config struct {
2929
Mochi Mochi
3030
MochiPay MochiPay
3131
MochiProfile MochiProfile
32+
IcyBackend IcyBackend
3233
Tono Tono
3334
ImprovMX ImprovMX
3435
CommunityNft CommunityNft
@@ -118,13 +119,24 @@ type Mochi struct {
118119
}
119120

120121
type MochiPay struct {
121-
BaseURL string
122+
BaseURL string
123+
ApplicationName string
124+
ApplicationPrivateKey string
125+
ApplicationId string
126+
ApplicationVaultId string
127+
ApplicationOwnerId string
128+
IcyPoolPrivateKey string
129+
IcyPoolPublicKey string
122130
}
123131

124132
type MochiProfile struct {
125133
BaseURL string
126134
}
127135

136+
type IcyBackend struct {
137+
BaseURL string
138+
}
139+
128140
type Tono struct {
129141
BaseURL string
130142
}
@@ -325,11 +337,21 @@ func Generate(v ENV) *Config {
325337
APIKey: v.GetString("MOCHI_API_KEY"),
326338
},
327339
MochiPay: MochiPay{
328-
BaseURL: v.GetString("MOCHI_PAY_BASE_URL"),
340+
BaseURL: v.GetString("MOCHI_PAY_BASE_URL"),
341+
ApplicationName: v.GetString("MOCHI_PAY_APPLICATION_NAME"),
342+
ApplicationPrivateKey: v.GetString("MOCHI_PAY_APPLICATION_PRIVATE_KEY"),
343+
ApplicationId: v.GetString("MOCHI_PAY_APPLICATION_ID"),
344+
ApplicationVaultId: v.GetString("MOCHI_PAY_APPLICATION_VAULT_ID"),
345+
ApplicationOwnerId: v.GetString("MOCHI_PAY_APPLICATION_OWNER_ID"),
346+
IcyPoolPrivateKey: v.GetString("MOCHI_PAY_ICY_POOL_PRIVATE_KEY"),
347+
IcyPoolPublicKey: v.GetString("MOCHI_PAY_ICY_POOL_PUBLIC_KEY"),
329348
},
330349
MochiProfile: MochiProfile{
331350
BaseURL: v.GetString("MOCHI_PROFILE_BASE_URL"),
332351
},
352+
IcyBackend: IcyBackend{
353+
BaseURL: v.GetString("ICY_BACKEND_BASE_URL"),
354+
},
333355
Tono: Tono{
334356
BaseURL: v.GetString("TONO_BASE_URL"),
335357
},

pkg/contracts/erc20/erc20.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/contracts/erc721/erc721.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)