-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: colin <[email protected]>
- Loading branch information
1 parent
4bae9c4
commit efa7cfa
Showing
5 changed files
with
113 additions
and
1 deletion.
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
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,26 @@ | ||
package solscan | ||
|
||
import ( | ||
"github.com/dapplink-labs/chain-explorer-api/common" | ||
"github.com/dapplink-labs/chain-explorer-api/common/account" | ||
"math/big" | ||
"strconv" | ||
) | ||
|
||
func (cea *ChainExplorerAdaptor) GetAccountBalance(req *account.AccountBalanceRequest) (*account.AccountBalanceResponse, error) { | ||
|
||
var responseData []AddressSummaryData | ||
|
||
cea.baseClient.Call("solscan", "", "", "/v1.0/account/tokens", map[string]any{ | ||
"account": req.Account[0], | ||
}, &responseData) | ||
|
||
return &account.AccountBalanceResponse{ | ||
Account: req.Account[0], | ||
Balance: (*common.BigInt)(big.NewInt(responseData[0].Amount)), | ||
BalanceStr: strconv.FormatInt(responseData[0].Amount, 10), | ||
Symbol: responseData[0].TokenAccount, | ||
ContractAddress: responseData[0].TokenAddress, | ||
TokenId: responseData[0].TokenAccount, | ||
}, nil | ||
} |
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 @@ | ||
package solscan |
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,22 @@ | ||
package solscan | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/dapplink-labs/chain-explorer-api/explorer" | ||
"github.com/dapplink-labs/chain-explorer-api/explorer/base" | ||
) | ||
|
||
const ChainExplorerName = "solscan" | ||
|
||
type ChainExplorerAdaptor struct { | ||
explorer.ChainExplorerAdaptor | ||
baseClient *base.BaseClient | ||
} | ||
|
||
func NewChainExplorerAdaptor(key string, baseURL string, verbose bool, timeout time.Duration) (*ChainExplorerAdaptor, error) { | ||
baseClient := base.NewBaseClient(key, baseURL, verbose, timeout) | ||
return &ChainExplorerAdaptor{ | ||
baseClient: baseClient, | ||
}, nil | ||
} |
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,12 @@ | ||
package solscan | ||
|
||
// AddressSummaryData The Data field within the Response structure of | ||
// Fundamental blockchain data -> Address Data -> Get basic address details | ||
|
||
type AddressSummaryData struct { | ||
TokenAccount string `json:"token_account"` | ||
TokenAddress string `json:"token_address"` | ||
Amount int64 `json:"amount"` | ||
TokenDecimals int `json:"token_decimals"` | ||
Owner string `json:"owner"` | ||
} |