-
Notifications
You must be signed in to change notification settings - Fork 49
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: token endpoint added for SolanaApi #60
Open
3scava1i3r
wants to merge
8
commits into
MoralisWeb3:main
Choose a base branch
from
3scava1i3r:feat-tokenSolanaApi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7bf40b4
added Contribute.md
3scava1i3r 6ea21e3
added token endpoint for SolanaApi
3scava1i3r b0c38ba
some .meta files added
3scava1i3r 5d0b22d
made needed changes
3scava1i3r 78ed79f
comments added
3scava1i3r abc7cd2
done more resolve work
3scava1i3r 9802143
minor fix
3scava1i3r 58455a7
small namespace change
3scava1i3r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,91 @@ | ||
# web3-unity-sdk | ||
|
||
The web3uiKit is aimed at helping developers build web3 based unity games fast, delivering a quality DX to our developers plus an inclusive and reliable UX to your end users. | ||
Thank you for taking an interest in contributing | ||
|
||
| ||
|
||
# Our core goals for this SDK 📈 | ||
|
||
| ||
|
||
# About our stack | ||
|
||
| ||
|
||
# Getting started | ||
|
||
| ||
|
||
# Got an idea for a component? | ||
|
||
You can start coding right away but in order for us to organize the build, please follow these steps | ||
|
||
1. Open an issue in our gitHub repo https://github.com/MoralisWeb3/web3-unity-sdk/issues | ||
2. Give the issue a title prefixed with feature, bugFix, docs or chore | ||
3. Describe what you will build, or fix as best you can so we know what to expect | ||
4. Add any examples like images, design ideas or CodePen mockups | ||
5. Be open to refinement of your idea | ||
6. Stay in communication, once we accept the proposal we want that update. If you disappear we might finish it for you or pass it to another dev | ||
7. To complete your task and be merged, you should read about Pull Requests below | ||
8. In need of inspiration? Keep an eye on the issue board as our team will open issues for you and even add new designs for components we need, hot from our Moralis design UX team. | ||
|
||
| ||
|
||
# NewComp | ||
|
||
Just a friendly heads up incase you missed that above... | ||
We have made a component called `NewComp` you can copy and paste this component to get started but don't change it or we will reject your pull request, sorry. Suggestions are welcome but we are pretty happy with it. | ||
This component has an example of just about everything with a friendly non programmer comment to help you learn, how we do things, why we do them and what we expect when it comes to a pull request. | ||
|
||
Lets take a tour and look at some of our standards | ||
|
||
|
||
# Pull Request | ||
|
||
For your pull request please follow this guide | ||
|
||
## Branch Name | ||
|
||
`pull request type + task` | ||
|
||
- so if i add a new tokenapi addon my branch is `feat-addedTokenApi` | ||
|
||
**Pull request types:** | ||
|
||
- feat = new feature | ||
- fix = bug fix | ||
- docs = added or changed documentation | ||
- chore = some mindless work, like reformatting | ||
|
||
So if i fix the validation to the `Form` my branch is `fix-form-validation`... you get it, right? 😅 | ||
|
||
## Conventional Commits | ||
|
||
We follow a strict convectional commits pattern, and please if you change more than one component, then have 1 commit per components. No monster PRs please, its hard to review them if you change 500 files in one go, lol | ||
https://www.conventionalcommits.org/en/v1.0.0/ | ||
|
||
## PR Feedback | ||
|
||
We are all students in this journey of life, so please accept any critique given. We are just trying to help you out or align your code with our base perhaps. This is a difficult but important part of collaboration and team work. | ||
lets **review each others code and PRs** | ||
|
||
**Q:** Why peer review? | ||
|
||
**A:** So we can all learn from each other, the rising tide brings up all ships. | ||
|
||
| ||
|
||
# Approval | ||
|
||
Don't forget we can approve and merge your code but you need to add your component to the projects base `index.ts` so the next dev can use it. | ||
|
||
| ||
|
||
|
||
# Any questions? | ||
|
||
Jump over to the Moralis Discord and checkout the channel `game-dev` | ||
|
||
| ||
|
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,91 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Cysharp.Threading.Tasks; | ||
using System.Net; | ||
using MoralisUnity.SolanaApi.Client; | ||
using MoralisUnity.SolanaApi.Interfaces; | ||
using MoralisUnity.SolanaApi.Models; | ||
|
||
namespace MoralisUnity.SolanaApi.Api | ||
{ | ||
public class TokenApi : ITokenApi; | ||
|
||
{ | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TokenApi"/> class. | ||
/// </summary> | ||
/// <param name="apiClient"> an instance of ApiClient (optional)</param> | ||
/// <returns></returns> | ||
public TokenApi(ApiClient apiClient = null) | ||
{ | ||
if (apiClient == null) // use the default one in Configuration | ||
this.ApiClient = Configuration.DefaultApiClient; | ||
3scava1i3r marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
this.ApiClient = apiClient; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NativeApi"/> class. | ||
/// </summary> | ||
/// <returns></returns> | ||
public TokenApi(String basePath) | ||
{ | ||
this.ApiClient = new ApiClient(basePath); | ||
} | ||
|
||
/// <summary> | ||
/// Sets the base path of the API client. | ||
/// </summary> | ||
/// <param name="basePath">The base path</param> | ||
/// <value>The base path</value> | ||
public void SetBasePath(String basePath) | ||
{ | ||
this.ApiClient.BasePath = basePath; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base path of the API client. | ||
/// </summary> | ||
/// <param name="basePath">The base path</param> | ||
/// <value>The base path</value> | ||
public String GetBasePath(String basePath) | ||
{ | ||
return this.ApiClient.BasePath; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the API client. | ||
/// </summary> | ||
/// <value>An instance of the ApiClient</value> | ||
public ApiClient ApiClient { get; set; } | ||
|
||
|
||
public async UniTask<TokenPrice> GetTokenPrice(NetworkTypes network, string address) { | ||
3scava1i3r marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (address == null) throw new ApiException(400, "Missing required parameter 'address' when calling GetTokenPrice"); | ||
|
||
var headerParams = new Dictionary<String, String>(); | ||
|
||
var path = "/token/{network}/{address}/price"; | ||
path = path.Replace("{" + "network" + "}", ApiClient.ParameterToString(network.ToString())); | ||
path = path.Replace("{" + "address" + "}", ApiClient.ParameterToString(address)); | ||
|
||
// Authentication setting, if any | ||
String[] authSettings = new String[] { "ApiKeyAuth" }; | ||
|
||
Tuple<HttpStatusCode, Dictionary<string, string>, string> response = await ApiClient.CallApi(path, Method.GET, null, null, headerParams, null, null, authSettings); | ||
|
||
if (((int)response.Item1) >= 400) | ||
throw new ApiException((int)response.Item1, "Error calling GetTokenPrice: " + response.Item3, response.Item3); | ||
else if (((int)response.Item1) == 0) | ||
throw new ApiException((int)response.Item1, "Error calling GetTokenPrice: " + response.Item3, response.Item3); | ||
|
||
|
||
return ((CloudFunctionResult<TokenPrice>)ApiClient.Deserialize(response.Item3, typeof(CloudFunctionResult<TokenPrice>), response.Item2)).Result; | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
} |
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,91 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Cysharp.Threading.Tasks; | ||
using System.Net; | ||
using MoralisUnity.SolanaApi.Client; | ||
using MoralisUnity.SolanaApi.Interfaces; | ||
using MoralisUnity.SolanaApi.Models; | ||
|
||
namespace MoralisUnity.SolanaApi.CloudApi | ||
{ | ||
public class TokenApi : ITokenApi; | ||
3scava1i3r marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{ | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TokenApi"/> class. | ||
/// </summary> | ||
/// <param name="apiClient"> an instance of ApiClient (optional)</param> | ||
/// <returns></returns> | ||
public TokenApi(ApiClient apiClient = null) | ||
{ | ||
if (apiClient == null) // use the default one in Configuration | ||
this.ApiClient = Configuration.DefaultApiClient; | ||
3scava1i3r marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
this.ApiClient = apiClient; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NativeApi"/> class. | ||
/// </summary> | ||
/// <returns></returns> | ||
public TokenApi(String basePath) | ||
{ | ||
this.ApiClient = new ApiClient(basePath); | ||
} | ||
|
||
/// <summary> | ||
/// Sets the base path of the API client. | ||
/// </summary> | ||
/// <param name="basePath">The base path</param> | ||
/// <value>The base path</value> | ||
public void SetBasePath(String basePath) | ||
{ | ||
this.ApiClient.BasePath = basePath; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the base path of the API client. | ||
/// </summary> | ||
/// <param name="basePath">The base path</param> | ||
/// <value>The base path</value> | ||
public String GetBasePath(String basePath) | ||
{ | ||
return this.ApiClient.BasePath; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the API client. | ||
/// </summary> | ||
/// <value>An instance of the ApiClient</value> | ||
public ApiClient ApiClient { get; set; } | ||
|
||
|
||
public async UniTask<TokenPrice> GetTokenPrice(NetworkTypes network, string address) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow coding practices in other files - braces should be on a new line. |
||
if (address == null) throw new ApiException(400, "Missing required parameter 'address' when calling GetTokenPrice"); | ||
|
||
var headerParams = new Dictionary<String, String>(); | ||
|
||
var path = "/token/{network}/{address}/price"; | ||
path = path.Replace("{" + "network" + "}", ApiClient.ParameterToString(network.ToString())); | ||
path = path.Replace("{" + "address" + "}", ApiClient.ParameterToString(address)); | ||
|
||
// Authentication setting, if any | ||
String[] authSettings = new String[] { "ApiKeyAuth" }; | ||
|
||
Tuple<HttpStatusCode, Dictionary<string, string>, string> response = await ApiClient.CallApi(path, Method.GET, null, null, headerParams, null, null, authSettings); | ||
|
||
if (((int)response.Item1) >= 400) | ||
throw new ApiException((int)response.Item1, "Error calling GetTokenPrice: " + response.Item3, response.Item3); | ||
else if (((int)response.Item1) == 0) | ||
throw new ApiException((int)response.Item1, "Error calling GetTokenPrice: " + response.Item3, response.Item3); | ||
|
||
|
||
return ((CloudFunctionResult<TokenPrice>)ApiClient.Deserialize(response.Item3, typeof(CloudFunctionResult<TokenPrice>), response.Item2)).Result; | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
} |
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,10 @@ | ||
using Cysharp.Threading.Tasks; | ||
using MoralisUnity.SolanaApi.Models; | ||
|
||
namespace MoralisUnity.SolanaApi.Interfaces | ||
{ | ||
public interface ITokenApi | ||
{ | ||
Unitask<TokenPrice> GetTokenPrice(string address, NetworkTypes network); | ||
} | ||
} |
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,32 @@ | ||
using System.Runtime.Serialization; | ||
using Newtonsoft.Json; | ||
|
||
namespace DefaultNamespace | ||
{ | ||
public class TokenPrice | ||
{ | ||
[DataContract] | ||
public class TokenPrice | ||
{ | ||
|
||
[DataMember(Name = "usdPrice", EmitDefaultValue = false)] | ||
[JsonProperty(PropertyName = "usdPrice")] | ||
public string UsdPrice { get; set; } | ||
|
||
[DataMember(Name = "exchangeName", EmitDefaultValue = false)] | ||
[JsonProperty(PropertyName = "exchangeName")] | ||
public string ExchangeName { get; set; } | ||
|
||
[DataMember(Name = "exchangeAddress", EmitDefaultValue = false)] | ||
[JsonProperty(PropertyName = "exchangeAddress")] | ||
public string ExchangeAddress { get; set; } | ||
|
||
[DataMember(Name = "nativePrice", EmitDefaultValue = false)] | ||
[JsonProperty(PropertyName = "nativePrice")] | ||
public string NativePrice { get; set; } | ||
|
||
|
||
} | ||
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add descriptive comments to all public classes and methods