Skip to content
Merged
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
3 changes: 2 additions & 1 deletion apps/quick-dapp/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { execution } from '@remix-project/remix-lib';
import SurgeClient from '@drafish/surge-client';
import remixClient from '../remix-client';
import { themeMap } from '../components/DeployPanel/theme';
import { endpointUrls } from "@remix-endpoints-helper"

const { encodeFunctionId } = execution.txHelper;

const surgeClient = new SurgeClient({
// surge backend doesn't support cross-domain, that's why the proxy goes
// here is the codebase of proxy: https://github.com/remix-project-org/remix-wildcard/blob/master/src/hosts/common-corsproxy.ts
proxy: 'https://common-corsproxy.remixproject.org/',
proxy: endpointUrls.commonCorsProxy,
onError: (err: Error) => {
console.log(err);
},
Expand Down
3 changes: 3 additions & 0 deletions apps/remixdesktop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
],
"@remix/remix-ai-core": [
"../../libs/remix-ai-core/src/index"
],
"@remix-endpoints-helper": [
"../../libs/endpoints-helper/src/index.ts"
]
},
"typeRoots": [
Expand Down
65 changes: 65 additions & 0 deletions libs/endpoints-helper/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
type EndpointUrls = {
corsProxy: string;
solidityScan: string;
ipfsGateway: string;
commonCorsProxy: string;
github: string;
solcoder: string;
completion: string;
ghfolderpull: string;
embedly: string;
gptChat: string;
rag: string;
vyper2: string;
solidityScanWebSocket: string;
};

const defaultUrls: EndpointUrls = {
corsProxy: 'https://corsproxy.remixproject.org',
solidityScan: 'https://solidityscan.remixproject.org',
ipfsGateway: 'https://jqgt.remixproject.org',
commonCorsProxy: 'https://common-corsproxy.remixproject.org',
github: 'https://github.remixproject.org',
solcoder: 'https://solcoder.remixproject.org',
ghfolderpull: 'https://ghfolderpull.remixproject.org',
embedly: 'https://embedly.remixproject.org',
gptChat: 'https://gpt-chat.remixproject.org',
rag: 'https://rag.remixproject.org',
vyper2: 'https://vyper2.remixproject.org',
completion: 'https://completion.remixproject.org',
solidityScanWebSocket: 'wss://solidityscan.remixproject.org',
};

const endpointPathMap: Record<keyof EndpointUrls, string> = {
corsProxy: 'corsproxy',
solidityScan: 'solidityscan',
ipfsGateway: 'jqgt',
commonCorsProxy: 'common-corsproxy',
github: 'github',
solcoder: 'solcoder',
completion: 'completion',
ghfolderpull: 'ghfolderpull',
embedly: 'embedly',
gptChat: 'gpt-chat',
rag: 'rag',
vyper2: 'vyper2',
solidityScanWebSocket: '',
};

const prefix = process.env.NX_ENDPOINTS_URL;

const resolvedUrls: EndpointUrls = prefix
? Object.fromEntries(
Object.entries(defaultUrls).map(([key, _]) => [
key,
`${prefix}/${endpointPathMap[key as keyof EndpointUrls]}`,
])
) as EndpointUrls
: defaultUrls;

resolvedUrls.solidityScanWebSocket = resolvedUrls.solidityScan.replace(
'http://',
'ws://'
);

export const endpointUrls = resolvedUrls;
8 changes: 8 additions & 0 deletions libs/endpoints-helper/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"declaration": true,
"outDir": "dist"
},
"include": ["src"]
}
5 changes: 3 additions & 2 deletions libs/remix-ai-core/src/inferencers/remote/remoteInference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { buildSolgptPrompt } from "../../prompts/promptBuilder";
import EventEmitter from "events";
import { ChatHistory } from "../../prompts/chat";
import axios from 'axios';
import { endpointUrls } from "@remix-endpoints-helper"

const defaultErrorMessage = `Unable to get a response from AI server`
export class RemoteInferencer implements ICompletions {
Expand All @@ -16,8 +17,8 @@ export class RemoteInferencer implements ICompletions {
test_url="http://solcodertest.org"

constructor(apiUrl?:string, completionUrl?:string) {
this.api_url = apiUrl!==undefined ? apiUrl: this.test_env? this.test_url : "https://solcoder.remixproject.org"
this.completion_url = completionUrl!==undefined ? completionUrl : this.test_env? this.test_url : "https://completion.remixproject.org"
this.api_url = apiUrl!==undefined ? apiUrl: this.test_env? this.test_url : endpointUrls.solcoder
this.completion_url = completionUrl!==undefined ? completionUrl : this.test_env? this.test_url : endpointUrls.completion
this.event = new EventEmitter()
}

Expand Down
5 changes: 3 additions & 2 deletions libs/remix-git/src/isogit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import http from 'isomorphic-git/http/web'

import { Octokit } from "octokit"
import { ElectronBasePluginClient } from "@remixproject/plugin-electron"
import { endpointUrls } from "@remix-endpoints-helper"
const currentbranch = async (input: currentBranchInput, fsConfig: isoGitFSConfig) => {

try {
Expand Down Expand Up @@ -200,7 +201,7 @@ const addIsomorphicGitProxyConfig = async (input: {
const token = await plugin.call('config' as any, 'getAppParameter', 'settings/gist-access-token')

let config: isoGitProxyConfig = {
corsProxy: 'https://corsproxy.remixproject.org/',
corsProxy: `${endpointUrls.corsProxy}`,
http,
onAuth: url => {
url
Expand Down Expand Up @@ -235,7 +236,7 @@ const addIsomorphicGitProxyConfig = async (input: {
if (input.provider && input.provider === 'github') {
config = {
...config,
corsProxy: 'https://corsproxy.remixproject.org/',
corsProxy: `${endpointUrls.corsProxy}`,
}
}

Expand Down
5 changes: 3 additions & 2 deletions libs/remix-ui/git/src/components/github/devicecode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CopyToClipboard } from "@remix-ui/clipboard";
import { Card } from "react-bootstrap";
import { sendToMatomo } from "../../lib/pluginActions";
import { gitMatomoEventTypes } from "../../types";
import { endpointUrls } from "@remix-endpoints-helper";

export const GetDeviceCode = () => {
const context = React.useContext(gitPluginContext)
Expand All @@ -20,7 +21,7 @@ export const GetDeviceCode = () => {
// Send a POST request
const response = await axios({
method: 'post',
url: 'https://github.remixproject.org/login/device/code',
url: `${endpointUrls.github}/login/device/code`,
data: {
client_id: '2795b4e41e7197d6ea11',
scope: 'repo gist user:email read:user'
Expand All @@ -42,7 +43,7 @@ export const GetDeviceCode = () => {
// poll https://github.com/login/oauth/access_token
const accestokenresponse = await axios({
method: 'post',
url: 'https://github.remixproject.org/login/oauth/access_token',
url:`${endpointUrls.github}/login/oauth/access_token`,
data: {
client_id: '2795b4e41e7197d6ea11',
device_code: gitHubResponse.device_code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import axios from 'axios'

import './css/style.css'
import { CustomTooltip } from '@remix-ui/helper'
import { endpointUrls } from '@remix-endpoints-helper'

const _paq = (window._paq = window._paq || [])

export const ContractSelection = (props: ContractSelectionProps) => {
Expand Down Expand Up @@ -267,10 +269,10 @@ export const ContractSelection = (props: ContractSelectionProps) => {
const filePath = `.workspaces/${fileName}`
const file = await plugin.call('fileManager', 'readFile', filePath)

const urlResponse = await axios.post(`https://solidityscan.remixproject.org/uploadFile`, { file, fileName })
const urlResponse = await axios.post(`${endpointUrls.solidityScan}/uploadFile`, { file, fileName })

if (urlResponse.data.status === 'success') {
const ws = new WebSocket('wss://solidityscan.remixproject.org/solidityscan')
const ws = new WebSocket(endpointUrls.solidityScanWebSocket)

ws.addEventListener('error', console.error);

Expand Down Expand Up @@ -312,7 +314,7 @@ export const ContractSelection = (props: ContractSelectionProps) => {
_paq.push(['trackEvent', 'solidityCompiler', 'solidityScan', 'scanSuccess'])
const url = data.payload.scan_details.link

const { data: scanData } = await axios.post('https://solidityscan.remixproject.org/downloadResult', { url })
const { data: scanData } = await axios.post(`https://${endpointUrls.solidityScan}/downloadResult`, { url })
const scanReport: ScanReport = scanData.scan_report
if (scanReport?.multi_file_scan_details?.length) {
for (const template of scanReport.multi_file_scan_details) {
Expand Down
3 changes: 2 additions & 1 deletion libs/remix-url-resolver/src/github-folder-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line no-unused-vars
import axios, { AxiosResponse } from 'axios'
import { endpointUrls } from '.'

export type GithubItem = {
name: string
Expand Down Expand Up @@ -42,7 +43,7 @@ export const githubFolderResolver = async (url, obj = {}, maxDepth, depth?, root
}

const pullFolder = async (url) => {
const response = await axios.get('https://ghfolderpull.remixproject.org', { params: { ghfolder: url } });
const response = await axios.get(endpointUrls.ghfolderpull, { params: { ghfolder: url } });
const data: Array<GithubItem> = await response.data;
return data
}
Expand Down
28 changes: 28 additions & 0 deletions libs/remix-url-resolver/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
export { RemixURLResolver } from './resolve'
export { githubFolderResolver } from './github-folder-resolver'

type EndpointUrls = {
ipfsGateway: string;
ghfolderpull: string;
};

const defaultUrls: EndpointUrls = {
ipfsGateway: 'https://jqgt.remixproject.org',
ghfolderpull: 'https://ghfolderpull.remixproject.org',
};

const endpointPathMap: Record<keyof EndpointUrls, string> = {
ipfsGateway: 'jqgt',
ghfolderpull: 'ghfolderpull',
};

const prefix = process.env.NX_ENDPOINTS_URL;

const resolvedUrls: EndpointUrls = prefix
? Object.fromEntries(
Object.entries(defaultUrls).map(([key, _]) => [
key,
`${prefix}/${endpointPathMap[key as keyof EndpointUrls]}`,
])
) as EndpointUrls
: defaultUrls;

export const endpointUrls = resolvedUrls;
3 changes: 2 additions & 1 deletion libs/remix-url-resolver/src/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import axios, { AxiosResponse } from 'axios'
import semver from 'semver'
import { BzzNode as Bzz } from '@erebos/bzz-node'
import { endpointUrls } from '.';

export interface Imported {
content: string;
Expand Down Expand Up @@ -122,7 +123,7 @@ export class RemixURLResolver {
url = url.replace(/^ipfs:\/\/?/, 'ipfs/')
// eslint-disable-next-line no-useless-catch
try {
const req = 'https://jqgt.remixproject.org/' + url
const req = `${endpointUrls.ipfsGateway}/${url}`
// If you don't find greeter.sol on ipfs gateway use local
// const req = 'http://localhost:8080/' + url
const response: AxiosResponse = await axios.get(req, { transformResponse: []})
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"start": "nx start",
"serve": "nx serve remix-ide --configuration=development",
"serve:hot": "nx serve remix-ide --configuration=hot",
"serve:endpoints": "NX_ENDPOINTS_URL=\"http://localhost:4000\" yarn serve",
"serve:plugin": "nx serve ${npm_config_plugin} --configuration=development",
"build:plugin": "NODE_ENV=production nx build ${npm_config_plugin} --configuration=production --skip-nx-cache",
"build": "nx build",
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@
],
"@remix-git": [
"libs/remix-git/"
],
"@remix-endpoints-helper": [
"libs/endpoints-helper/src/index.ts"
]
}
}
Expand Down