Skip to content

Commit e0bff86

Browse files
joeizangAniket-Engg
authored andcommitted
fix version determination so it updates on deploy
1 parent f623faf commit e0bff86

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
3939
{props.instances.instanceList.map((instance, index) => {
4040
return (
4141
<UniversalDappUI
42+
plugin={props.plugin}
4243
key={index}
4344
instance={instance}
4445
context={props.getContext()}

libs/remix-ui/run-tab/src/lib/components/lowlevelInteractionIcon.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
import { CustomTooltip } from '@remix-ui/helper'
2-
import React, { useState } from 'react'
2+
import React, { useEffect, useState } from 'react'
33
import { FormattedMessage } from 'react-intl'
4+
import { RunTab } from '../types/run-tab'
45

5-
export function LowLevelInteractionIcon () {
6-
const [version, _] = useState(window.location.href.split('=')[5].split('+')[0].split('-')[1])
6+
export type LowLevelInteractionIconProps = {
7+
plugin: RunTab
8+
}
9+
10+
export function LowLevelInteractionIcon (props: LowLevelInteractionIconProps) {
11+
const getVersion = () => window.location.href.split('=')[5].split('+')[0].split('-')[1]
12+
const [version, setVersion] = useState(() => getVersion())
13+
14+
useEffect(() => {
15+
const listenForCompileFinished = async () => {
16+
props.plugin.on('solidity', 'compilationFinished',
17+
(file: string, source, languageVersion, data, input, version) => {
18+
const versionUpdate = `v${version.split('+')[0]}` // remove commit hash
19+
console.log(versionUpdate)
20+
setVersion(versionUpdate)
21+
})
22+
}
23+
listenForCompileFinished()
24+
25+
return () => {
26+
props.plugin.off('solidity', 'compilationFinished')
27+
}
28+
}, [])
729

830
return (
931
<>

libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export function UniversalDappUI(props: UdappProps) {
285285
<div className="py-2 border-top d-flex justify-content-start flex-grow-1">
286286
<FormattedMessage id="udapp.lowLevelInteractions" />
287287
</div>
288-
<LowLevelInteractionIcon />
288+
<LowLevelInteractionIcon plugin={props.plugin} />
289289
</div>
290290
<div className="d-flex flex-column align-items-start">
291291
<label className="">CALLDATA</label>

libs/remix-ui/run-tab/src/lib/run-tab.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ export function RunTabUI(props: RunTabProps) {
322322
runTransactions={executeTransactions}
323323
sendValue={runTab.sendValue}
324324
getFuncABIInputs={getFuncABIValues}
325+
plugin={props.plugin}
325326
/>
326327
</div>
327328
</div>

libs/remix-ui/run-tab/src/lib/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ export interface RecorderProps {
283283
}
284284

285285
export interface InstanceContainerProps {
286+
plugin: RunTab,
286287
instances: {
287288
instanceList: {
288289
contractData?: ContractData,
@@ -396,6 +397,7 @@ export interface UdappProps {
396397
decodedResponse?: Record<number, any>,
397398
abi?: any
398399
},
400+
plugin: RunTab,
399401
context: 'memory' | 'blockchain',
400402
removeInstance: (index: number) => void,
401403
index: number,

0 commit comments

Comments
 (0)