Skip to content

Commit

Permalink
Update API endpoints to use dash.usemoon.ai
Browse files Browse the repository at this point in the history
  • Loading branch information
ewhal committed Apr 17, 2024
1 parent 10fddc9 commit 7169eae
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function LoginButton() {
const scope = process.env.REACT_APP_SCOPE;
const state = process.env.REACT_APP_STATE;

const redirectUrl = `https://moon-wallet-supabase-next-app.vercel.app/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`;
const redirectUrl = `https://dash.usemoon.ai/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`;

window.location.href = redirectUrl;
};
Expand Down Expand Up @@ -75,7 +75,7 @@ app.get('/callback', async (req: Request, res: Response) => {
const { code, state } = req.query;
console.log(process.env.REACT_APP_CLIENT_GRANT_TYPE);
const response = await axios.post(
'https://moon-wallet-supabase-next-app.vercel.app/api/oauth2/exchange',
'https://dash.usemoon.ai/api/oauth2/exchange',
{
grant_type: process.env.REACT_APP_GRANT_TYPE,
code: code,
Expand Down Expand Up @@ -113,7 +113,7 @@ const MoonSIWE = async (addres) => {

try {
// 1. Get a nonce from the server
const nonceResponse = await fetch(`https://moon-wallet-supabase-next-app.vercel.app/api/ethereum/nonce`, {
const nonceResponse = await fetch(`https://dash.usemoon.ai/api/ethereum/nonce`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -142,7 +142,7 @@ const MoonSIWE = async (addres) => {
});

// // 3. Send the signed message to our API
const response = await fetch(`https://moon-wallet-supabase-next-app.vercel.app/api/ethereum/login`, {
const response = await fetch(`https://dash.usemoon.ai/api/ethereum/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ app.get('/callback', async (req: Request, res: Response) => {
const { code, state } = req.query;
console.log(process.env.REACT_APP_CLIENT_GRANT_TYPE);
const response = await axios.post(
'https://moon-wallet-supabase-next-app.vercel.app/api/oauth2/exchange',
'https://dash.usemoon.ai/api/oauth2/exchange',
{
grant_type: process.env.REACT_APP_GRANT_TYPE,
code: code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function LoginButton() {
const scope = process.env.REACT_APP_SCOPE;
const state = process.env.REACT_APP_STATE;

const redirectUrl = `https://moon-wallet-supabase-next-app.vercel.app/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`;
const redirectUrl = `https://dash.usemoon.ai/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`;

window.location.href = redirectUrl;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function SIWE() {
return accounts[0];
});
console.log(address);
return fetch('https://vault-api.usemoon.ai/auth/ethereum/challenge', {
return fetch('http://dash.usemoon.ai/api/ethereum/nonce', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -35,11 +35,13 @@ function SIWE() {
return response.json();
})
.then(function (json) {
console.log(json);
return ethereum.request({ method: 'eth_requestAccounts' }).then(function (accounts: any[]) {
return [accounts[0], json.nonce];
return [accounts[0], json.user[0].auth.genNonce];
});
})
.then(function (args) {
console.log(args);
const account = args[0];
const address = ethers.utils.getAddress(account);
const message = new SiweMessage({
Expand All @@ -63,15 +65,16 @@ function SIWE() {
});
})
.then(function (args) {
return fetch('https://vault-api.usemoon.ai/auth/ethereum', {
console.log(args);
return fetch('http://dash.usemoon.ai/api/ethereum/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
message: args[0],
signature: args[1],
signedMessage: args[1],
address,
}),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/moon-rainbowkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moonup/moon-rainbowkit",
"version": "1.0.14",
"version": "1.0.15",
"license": "MIT",
"author": "0xEwhal <[email protected]>",
"type": "commonjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/moon-rainbowkit/src/siwe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function RainbowMoonProvider({
getNonce: async (): Promise<string> => {
// 1. Get a nonce from the server
const nonceResponse = await fetch(
`https://moon-wallet-supabase-next-app.vercel.app/api/ethereum/nonce`,
`https://dash.usemoon.ai/api/ethereum/nonce`,
{
method: 'POST',
headers: {
Expand Down Expand Up @@ -71,7 +71,7 @@ export function RainbowMoonProvider({
setIsLoading(true);
// // 3. Send the signed message to our API
const response = await fetch(
`https://moon-wallet-supabase-next-app.vercel.app/api/ethereum/login`,
`https://dash.usemoon.ai/api/ethereum/login`,
{
method: 'POST',
headers: {
Expand Down
4 changes: 0 additions & 4 deletions packages/moon-sdk/src/moon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ export class MoonSDK {
this.http.setSecurityData({
token: token,
});
return await this.MoonAPIClient.auth.setSession({
access_token: token,
refresh_token: refreshToken,
});
}

public getSolanaSDK(): Solana {
Expand Down

0 comments on commit 7169eae

Please sign in to comment.