Skip to content

Commit cbb5dfe

Browse files
committed
updates for v0.4.0
1 parent 6b9a7c5 commit cbb5dfe

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

apps/vyper/src/app/utils/compiler.tsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export function normalizeContractPath(contractPath: string): string[] {
4848
function parseErrorString(errorString) {
4949
// Split the string into lines
5050
console.log(errorString)
51+
return
5152
let lines = errorString.trim().split('\n')
5253
// Extract the line number and message
5354
let message = errorString.trim()
@@ -141,27 +142,32 @@ const compileReturnType = (output, contract) => {
141142
return result
142143
}
143144

144-
const fixContractContent = (content: string) => {
145-
const pragmaRegex = /#\s*pragma\s+[@]*version\s+([\^~<>!=^]+)\s*(\d+\.\d+\.\d+)/
146-
if (content.length === 0) return
145+
const updatePragmaDeclaration = (content: string) => {
146+
const pragmaRegex = /#\s*pragma\s+[@]*version\s+([~<>!=^]+)\s*(\d+\.\d+\.\d+)/
147+
const oldPragmaRegex = /#\s*pragma\s+[@]*version\s+([\^^]+)\s*(\d+\.\d+\.\d+)/
148+
const oldPragmaDeclaration = ['# pragma version ^0.2.16', '# pragma version ^0.3.10', '#pragma version ^0.2.16', '#pragma version ^0.3.10']
147149
const pragmaFound = content.match(pragmaRegex)
148-
const wrongpragmaFound = content.includes('# pragma version ^0.3.10')
149-
const evmVerFound = content.includes('#pragma evm-version cancun')
150+
const oldPragmaFound = content.match(oldPragmaRegex)
151+
150152
const pragma = '# pragma version ~=0.4.0'
151-
const evmVer = '# pragma evm-version cancun'
152153

153-
// if (evmVerFound === false) {
154-
// content = `${evmVer}\n${content}`
155-
// }
156-
if (wrongpragmaFound === true) {
157-
content = content.replace('# pragma version ^0.3.10', '')
154+
if (oldPragmaFound) {
155+
console.log('found old pragma')
156+
// oldPragmaDeclaration.forEach(declaration => {
157+
// content = content.replace(declaration, '# pragma version ~=0.4.0')
158+
// })
158159
}
159160
if (!pragmaFound) {
160-
content = `${pragma}\n${content}`
161+
content = `${pragma}\n\n${content}`
161162
}
162163
return content
163164
}
164165

166+
const fixContractContent = (content: string) => {
167+
if (content.length === 0) return
168+
return updatePragmaDeclaration(content)
169+
}
170+
165171
/**
166172
* Compile the a contract
167173
* @param url The url of the compiler
@@ -177,7 +183,7 @@ export async function compile(url: string, contract: Contract): Promise<any> {
177183
}
178184

179185
const cleanedUpContent = fixContractContent(contract.content)
180-
console.log('cleanedUp', cleanedUpContent)
186+
// console.log('cleanedUp', cleanedUpContent)
181187

182188
let contractName = contract['name']
183189
const compilePackage = {
@@ -187,6 +193,7 @@ export async function compile(url: string, contract: Contract): Promise<any> {
187193
}
188194
}
189195
console.log(compilePackage)
196+
190197
let response = await axios.post(`${url}compile`, compilePackage )
191198

192199
if (response.status === 404) {
@@ -197,9 +204,11 @@ export async function compile(url: string, contract: Contract): Promise<any> {
197204
}
198205

199206
const compileCode = response.data
207+
console.log('compileCode', compileCode)
200208
contractName = null
201209
response = null
202210
let result: any
211+
let intermediateError
203212

204213
const status = await (await axios.get(url + 'status/' + compileCode , {
205214
method: 'Get'
@@ -210,12 +219,13 @@ export async function compile(url: string, contract: Contract): Promise<any> {
210219
})).data
211220

212221
return result
213-
} else if (status !== 'SUCCESS') {
222+
} else if (status === 'FAILED') {
214223
const intermediate = await(await axios.get(url + 'exceptions/' + compileCode , {
215224
method: 'Get'
216225
})).data
217-
result = parseErrorString(intermediate)
218226
console.log('Errors found', intermediate)
227+
result = parseErrorString(intermediate)
228+
intermediateError = intermediate
219229
return result
220230
}
221231
await new Promise((resolve) => setTimeout(() => resolve({}), 3000))

apps/vyper/src/app/utils/remix-client.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ export class RemixClient extends PluginClient<any, CustomRemixApi> {
8383

8484
try {
8585
// @ts-ignore
86-
this.call('notification', 'toast', 'cloning Snekmate Vyper repository...')
86+
this.call('notification', 'toast', 'cloning Snekmate Vyper repository...')
8787
await this.call(
8888
'dgitApi',
8989
'clone',
90-
{url: 'https://github.com/pcaversaccio/snekmate', token: null, branch: 'main', singleBranch: false, workspaceName: 'snekmate'},
90+
{ url: 'https://github.com/vyperlang/vyper', token: null, branch: 'master', singleBranch: false, workspaceName: 'vyper' },
9191
)
9292

9393
await this.call(
@@ -99,7 +99,7 @@ export class RemixClient extends PluginClient<any, CustomRemixApi> {
9999
refresh: true,
100100
}
101101
)
102-
102+
103103
this.call(
104104
// @ts-ignore
105105
'notification',

0 commit comments

Comments
 (0)