Skip to content

Commit 0127def

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

File tree

36 files changed

+2845
-29
lines changed

36 files changed

+2845
-29
lines changed

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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
tx_swap text,
18+
tx_deposit text,
19+
created_at TIMESTAMP(6) DEFAULT NOW(),
20+
updated_at TIMESTAMP(6) DEFAULT NOW()
21+
);
22+
23+
CREATE INDEX idx_icy_swap_btc_profile_id ON icy_swap_btc_requests(profile_id);
24+
CREATE INDEX idx_icy_swap_btc_request_code ON icy_swap_btc_requests(request_code);
25+
26+
-- +migrate Down
27+
DROP INDEX IF EXISTS idx_icy_swap_btc_profile_id;
28+
DROP INDEX IF EXISTS idx_icy_swap_btc_request_code;
29+
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.
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
[
2+
{
3+
"inputs": [
4+
{ "internalType": "address", "name": "_icy", "type": "address" }
5+
],
6+
"stateMutability": "nonpayable",
7+
"type": "constructor"
8+
},
9+
{
10+
"anonymous": false,
11+
"inputs": [
12+
{
13+
"indexed": true,
14+
"internalType": "address",
15+
"name": "user",
16+
"type": "address"
17+
},
18+
{
19+
"indexed": true,
20+
"internalType": "address",
21+
"name": "newOwner",
22+
"type": "address"
23+
}
24+
],
25+
"name": "OwnershipTransferred",
26+
"type": "event"
27+
},
28+
{
29+
"anonymous": false,
30+
"inputs": [
31+
{
32+
"indexed": false,
33+
"internalType": "uint256",
34+
"name": "icyAmount",
35+
"type": "uint256"
36+
},
37+
{
38+
"indexed": false,
39+
"internalType": "string",
40+
"name": "btcAddress",
41+
"type": "string"
42+
},
43+
{
44+
"indexed": false,
45+
"internalType": "uint256",
46+
"name": "btcAmount",
47+
"type": "uint256"
48+
}
49+
],
50+
"name": "RevertIcy",
51+
"type": "event"
52+
},
53+
{
54+
"anonymous": false,
55+
"inputs": [
56+
{
57+
"indexed": false,
58+
"internalType": "address",
59+
"name": "signerAddress",
60+
"type": "address"
61+
}
62+
],
63+
"name": "SetSigner",
64+
"type": "event"
65+
},
66+
{
67+
"anonymous": false,
68+
"inputs": [
69+
{
70+
"indexed": false,
71+
"internalType": "uint256",
72+
"name": "icyAmount",
73+
"type": "uint256"
74+
},
75+
{
76+
"indexed": false,
77+
"internalType": "string",
78+
"name": "btcAddress",
79+
"type": "string"
80+
},
81+
{
82+
"indexed": false,
83+
"internalType": "uint256",
84+
"name": "btcAmount",
85+
"type": "uint256"
86+
}
87+
],
88+
"name": "Swap",
89+
"type": "event"
90+
},
91+
{ "stateMutability": "nonpayable", "type": "fallback" },
92+
{
93+
"inputs": [],
94+
"name": "REVERT_ICY_HASH",
95+
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
96+
"stateMutability": "view",
97+
"type": "function"
98+
},
99+
{
100+
"inputs": [],
101+
"name": "SWAP_HASH",
102+
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
103+
"stateMutability": "view",
104+
"type": "function"
105+
},
106+
{
107+
"inputs": [],
108+
"name": "eip712Domain",
109+
"outputs": [
110+
{ "internalType": "bytes1", "name": "fields", "type": "bytes1" },
111+
{ "internalType": "string", "name": "name", "type": "string" },
112+
{ "internalType": "string", "name": "version", "type": "string" },
113+
{ "internalType": "uint256", "name": "chainId", "type": "uint256" },
114+
{
115+
"internalType": "address",
116+
"name": "verifyingContract",
117+
"type": "address"
118+
},
119+
{ "internalType": "bytes32", "name": "salt", "type": "bytes32" },
120+
{ "internalType": "uint256[]", "name": "extensions", "type": "uint256[]" }
121+
],
122+
"stateMutability": "view",
123+
"type": "function"
124+
},
125+
{
126+
"inputs": [
127+
{ "internalType": "uint256", "name": "icyAmount", "type": "uint256" },
128+
{ "internalType": "string", "name": "btcAddress", "type": "string" },
129+
{ "internalType": "uint256", "name": "btcAmount", "type": "uint256" },
130+
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
131+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
132+
],
133+
"name": "getRevertIcyHash",
134+
"outputs": [
135+
{ "internalType": "bytes32", "name": "hash", "type": "bytes32" }
136+
],
137+
"stateMutability": "view",
138+
"type": "function"
139+
},
140+
{
141+
"inputs": [
142+
{ "internalType": "bytes32", "name": "_digest", "type": "bytes32" },
143+
{ "internalType": "bytes", "name": "_signature", "type": "bytes" }
144+
],
145+
"name": "getSigner",
146+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
147+
"stateMutability": "view",
148+
"type": "function"
149+
},
150+
{
151+
"inputs": [
152+
{ "internalType": "uint256", "name": "icyAmount", "type": "uint256" },
153+
{ "internalType": "string", "name": "btcAddress", "type": "string" },
154+
{ "internalType": "uint256", "name": "btcAmount", "type": "uint256" },
155+
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
156+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
157+
],
158+
"name": "getSwapHash",
159+
"outputs": [
160+
{ "internalType": "bytes32", "name": "hash", "type": "bytes32" }
161+
],
162+
"stateMutability": "view",
163+
"type": "function"
164+
},
165+
{
166+
"inputs": [],
167+
"name": "icy",
168+
"outputs": [
169+
{ "internalType": "contract ERC20", "name": "", "type": "address" }
170+
],
171+
"stateMutability": "view",
172+
"type": "function"
173+
},
174+
{
175+
"inputs": [],
176+
"name": "owner",
177+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
178+
"stateMutability": "view",
179+
"type": "function"
180+
},
181+
{
182+
"inputs": [
183+
{ "internalType": "uint256", "name": "icyAmount", "type": "uint256" },
184+
{ "internalType": "string", "name": "btcAddress", "type": "string" },
185+
{ "internalType": "uint256", "name": "btcAmount", "type": "uint256" },
186+
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
187+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
188+
{ "internalType": "bytes", "name": "_signature", "type": "bytes" }
189+
],
190+
"name": "revertIcy",
191+
"outputs": [],
192+
"stateMutability": "nonpayable",
193+
"type": "function"
194+
},
195+
{
196+
"inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
197+
"name": "revertedIcyHashes",
198+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
199+
"stateMutability": "view",
200+
"type": "function"
201+
},
202+
{
203+
"inputs": [
204+
{ "internalType": "address", "name": "_signerAddress", "type": "address" }
205+
],
206+
"name": "setSigner",
207+
"outputs": [],
208+
"stateMutability": "nonpayable",
209+
"type": "function"
210+
},
211+
{
212+
"inputs": [],
213+
"name": "signerAddress",
214+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
215+
"stateMutability": "view",
216+
"type": "function"
217+
},
218+
{
219+
"inputs": [
220+
{ "internalType": "uint256", "name": "icyAmount", "type": "uint256" },
221+
{ "internalType": "string", "name": "btcAddress", "type": "string" },
222+
{ "internalType": "uint256", "name": "btcAmount", "type": "uint256" },
223+
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
224+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
225+
{ "internalType": "bytes", "name": "_signature", "type": "bytes" }
226+
],
227+
"name": "swap",
228+
"outputs": [],
229+
"stateMutability": "nonpayable",
230+
"type": "function"
231+
},
232+
{
233+
"inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
234+
"name": "swappedHashes",
235+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
236+
"stateMutability": "view",
237+
"type": "function"
238+
},
239+
{
240+
"inputs": [
241+
{ "internalType": "address", "name": "newOwner", "type": "address" }
242+
],
243+
"name": "transferOwnership",
244+
"outputs": [],
245+
"stateMutability": "nonpayable",
246+
"type": "function"
247+
},
248+
{ "stateMutability": "payable", "type": "receive" }
249+
]

0 commit comments

Comments
 (0)