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

feat: swap icy webhook #770

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions codebase.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ require (
github.com/go-playground/validator/v10 v10.14.1
github.com/go-testfixtures/testfixtures/v3 v3.9.0
github.com/goccy/go-json v0.10.2
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.6.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14j
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- +migrate Up
CREATE TABLE icy_swap_btc_requests (
id uuid PRIMARY KEY DEFAULT (uuid()),
profile_id varchar(255) NOT NULL,
request_code varchar(255) NOT NULL,
tx_status varchar(255),
tx_id int,
btc_address varchar(255),
timestamp integer,
amount varchar(255),
token_name varchar(255),
token_id varchar(255),
swap_request_status varchar(255),
swap_request_error text,
revert_status varchar(255),
revert_error text,
tx_swap text,
tx_deposit text,
created_at TIMESTAMP(6) DEFAULT NOW(),
updated_at TIMESTAMP(6) DEFAULT NOW()
);

CREATE INDEX idx_icy_swap_btc_profile_id ON icy_swap_btc_requests(profile_id);
CREATE INDEX idx_icy_swap_btc_request_code ON icy_swap_btc_requests(request_code);

-- +migrate Down
DROP INDEX IF EXISTS idx_icy_swap_btc_profile_id;
DROP INDEX IF EXISTS idx_icy_swap_btc_request_code;
DROP TABLE icy_swap_btc_requests;
26 changes: 24 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
Mochi Mochi
MochiPay MochiPay
MochiProfile MochiProfile
IcyBackend IcyBackend
Tono Tono
ImprovMX ImprovMX
CommunityNft CommunityNft
Expand Down Expand Up @@ -118,13 +119,24 @@ type Mochi struct {
}

type MochiPay struct {
BaseURL string
BaseURL string
ApplicationName string
ApplicationPrivateKey string
ApplicationId string
ApplicationVaultId string
ApplicationOwnerId string
IcyPoolPrivateKey string
IcyPoolPublicKey string
}

type MochiProfile struct {
BaseURL string
}

type IcyBackend struct {
BaseURL string
}

type Tono struct {
BaseURL string
}
Expand Down Expand Up @@ -325,11 +337,21 @@ func Generate(v ENV) *Config {
APIKey: v.GetString("MOCHI_API_KEY"),
},
MochiPay: MochiPay{
BaseURL: v.GetString("MOCHI_PAY_BASE_URL"),
BaseURL: v.GetString("MOCHI_PAY_BASE_URL"),
ApplicationName: v.GetString("MOCHI_PAY_APPLICATION_NAME"),
ApplicationPrivateKey: v.GetString("MOCHI_PAY_APPLICATION_PRIVATE_KEY"),
ApplicationId: v.GetString("MOCHI_PAY_APPLICATION_ID"),
ApplicationVaultId: v.GetString("MOCHI_PAY_APPLICATION_VAULT_ID"),
ApplicationOwnerId: v.GetString("MOCHI_PAY_APPLICATION_OWNER_ID"),
IcyPoolPrivateKey: v.GetString("MOCHI_PAY_ICY_POOL_PRIVATE_KEY"),
IcyPoolPublicKey: v.GetString("MOCHI_PAY_ICY_POOL_PUBLIC_KEY"),
},
MochiProfile: MochiProfile{
BaseURL: v.GetString("MOCHI_PROFILE_BASE_URL"),
},
IcyBackend: IcyBackend{
BaseURL: v.GetString("ICY_BACKEND_BASE_URL"),
},
Tono: Tono{
BaseURL: v.GetString("TONO_BASE_URL"),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/contracts/erc20/erc20.go

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

6 changes: 3 additions & 3 deletions pkg/contracts/erc721/erc721.go

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

249 changes: 249 additions & 0 deletions pkg/contracts/icyswapbtc/icyswapbtc.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
[
{
"inputs": [
{ "internalType": "address", "name": "_icy", "type": "address" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "icyAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "string",
"name": "btcAddress",
"type": "string"
},
{
"indexed": false,
"internalType": "uint256",
"name": "btcAmount",
"type": "uint256"
}
],
"name": "RevertIcy",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "signerAddress",
"type": "address"
}
],
"name": "SetSigner",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "icyAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "string",
"name": "btcAddress",
"type": "string"
},
{
"indexed": false,
"internalType": "uint256",
"name": "btcAmount",
"type": "uint256"
}
],
"name": "Swap",
"type": "event"
},
{ "stateMutability": "nonpayable", "type": "fallback" },
{
"inputs": [],
"name": "REVERT_ICY_HASH",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "SWAP_HASH",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip712Domain",
"outputs": [
{ "internalType": "bytes1", "name": "fields", "type": "bytes1" },
{ "internalType": "string", "name": "name", "type": "string" },
{ "internalType": "string", "name": "version", "type": "string" },
{ "internalType": "uint256", "name": "chainId", "type": "uint256" },
{
"internalType": "address",
"name": "verifyingContract",
"type": "address"
},
{ "internalType": "bytes32", "name": "salt", "type": "bytes32" },
{ "internalType": "uint256[]", "name": "extensions", "type": "uint256[]" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "icyAmount", "type": "uint256" },
{ "internalType": "string", "name": "btcAddress", "type": "string" },
{ "internalType": "uint256", "name": "btcAmount", "type": "uint256" },
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
],
"name": "getRevertIcyHash",
"outputs": [
{ "internalType": "bytes32", "name": "hash", "type": "bytes32" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "bytes32", "name": "_digest", "type": "bytes32" },
{ "internalType": "bytes", "name": "_signature", "type": "bytes" }
],
"name": "getSigner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "icyAmount", "type": "uint256" },
{ "internalType": "string", "name": "btcAddress", "type": "string" },
{ "internalType": "uint256", "name": "btcAmount", "type": "uint256" },
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
],
"name": "getSwapHash",
"outputs": [
{ "internalType": "bytes32", "name": "hash", "type": "bytes32" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "icy",
"outputs": [
{ "internalType": "contract ERC20", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "icyAmount", "type": "uint256" },
{ "internalType": "string", "name": "btcAddress", "type": "string" },
{ "internalType": "uint256", "name": "btcAmount", "type": "uint256" },
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
{ "internalType": "bytes", "name": "_signature", "type": "bytes" }
],
"name": "revertIcy",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"name": "revertedIcyHashes",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_signerAddress", "type": "address" }
],
"name": "setSigner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "signerAddress",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "icyAmount", "type": "uint256" },
{ "internalType": "string", "name": "btcAddress", "type": "string" },
{ "internalType": "uint256", "name": "btcAmount", "type": "uint256" },
{ "internalType": "uint256", "name": "nonce", "type": "uint256" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
{ "internalType": "bytes", "name": "_signature", "type": "bytes" }
],
"name": "swap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"name": "swappedHashes",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "stateMutability": "payable", "type": "receive" }
]
Loading
Loading