-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
5,374 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RPC_URL= | ||
WALLET_SECRET_KEY= | ||
CONTRACT_ADDRESS= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
list.csv | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# airdrop cli | ||
|
||
## support chain | ||
|
||
- Ethereum mainnet | ||
|
||
## support types | ||
|
||
- CryptoPokers | ||
|
||
## CSV Structure | ||
|
||
```csv | ||
address,amount | ||
0x000000000000,1 | ||
0x000000000001,2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package di | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/wire" | ||
"github.com/kelseyhightower/envconfig" | ||
) | ||
|
||
type Config struct { | ||
RpcUrl string `envconfig:"RPC_URL" default:"https://eth-mainnet.g.alchemy.com/v2/7q07HgmNB4AvgtnWTJF0uKgXmHIPpC-e"` | ||
WalletSecretKey string `envconfig:"WALLET_SECRET_KEY"` | ||
ContractAddress string `envconfig:"CONTRACT_ADDRESS"` | ||
} | ||
|
||
func loadConfig(_ context.Context) (*Config, error) { | ||
var cfg Config | ||
if err := envconfig.Process("", &cfg); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &cfg, nil | ||
} | ||
|
||
func providerConfig(ctx context.Context) (*Config, error) { | ||
return loadConfig(ctx) | ||
} | ||
|
||
var providerSet = wire.NewSet(providerConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build wireinject | ||
|
||
package di | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/wire" | ||
) | ||
|
||
type App struct { | ||
Config *Config | ||
} | ||
|
||
func NewApp(ctx context.Context) (*App, error) { | ||
wire.Build( | ||
providerSet, | ||
wire.Struct(new(App), "*"), | ||
) | ||
return nil, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package alchemy | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"io" | ||
"net/http" | ||
"net/url" | ||
"path" | ||
) | ||
|
||
type Client struct { | ||
rpcUrl string | ||
} | ||
|
||
func NewClient(rpcUrl string) *Client { | ||
return &Client{rpcUrl: rpcUrl} | ||
} | ||
|
||
type GetNFTsRequest struct { | ||
Owner string | ||
ContractAddress string | ||
// pageKey string | ||
} | ||
|
||
type GetNFTsResponse struct { | ||
OwnedNfts []struct { | ||
Id struct { | ||
TokenId string `json:"tokenId"` | ||
} `json:"id"` | ||
Title string `json:"title"` | ||
} `json:"ownedNfts"` | ||
} | ||
|
||
func (c *Client) GetNFTs(ctx context.Context, payload GetNFTsRequest) (*GetNFTsResponse, error) { | ||
url, err := url.Parse(c.rpcUrl) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
url.Path = path.Join(url.Path, "getNFTs") | ||
|
||
q := url.Query() | ||
q.Add("owner", payload.Owner) | ||
q.Add("contractAddresses[]", payload.ContractAddress) | ||
q.Add("withMetadata", "true") | ||
|
||
url.RawQuery = q.Encode() | ||
|
||
req, err := http.NewRequest("GET", url.String(), nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
req.Header.Add("access", "application/json") | ||
res, err := http.DefaultClient.Do(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer res.Body.Close() | ||
body, err := io.ReadAll(res.Body) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var r GetNFTsResponse | ||
if err = json.Unmarshal(body, &r); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &r, nil | ||
} |
2,991 changes: 2,991 additions & 0 deletions
2,991
packages/airdrop/gateway/onchain/CryptoPokers/CryptoPokers.go
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.