fallback and receive for quick-dapp

pull/5370/head
drafish 5 months ago committed by yann300
parent ef974d066f
commit e5c8f9036c
  1. 26
      apps/quick-dapp/src/actions/index.ts
  2. 3
      apps/quick-dapp/src/remix-client.ts
  3. 8
      libs/remix-ui/run-tab/src/lib/run-tab.tsx

@ -1,5 +1,6 @@
import axios from 'axios';
import { omitBy } from 'lodash';
import semver from 'semver';
import { execution } from '@remix-project/remix-lib';
import SurgeClient from '@drafish/surge-client';
import remixClient from '../remix-client';
@ -16,6 +17,21 @@ const surgeClient = new SurgeClient({
},
});
const getVersion = (solcVersion) => {
let version = '0.8.25'
try {
const arr = solcVersion.split('+')
if (arr && arr[0]) version = arr[0]
if (semver.lt(version, '0.6.0')) {
return { version: version, canReceive: false };
} else {
return { version: version, canReceive: true };
}
} catch (e) {
return { version, canReceive: true };
}
};
let dispatch: any, state: any;
export const initDispatch = (_dispatch: any) => {
@ -221,6 +237,7 @@ export const deploy = async (payload: any, callback: any) => {
export const initInstance = async ({
methodIdentifiers,
devdoc,
solcVersion,
...payload
}: any) => {
const functionHashes: any = {};
@ -257,11 +274,18 @@ export const initInstance = async ({
}
const abi: any = {};
const lowLevel: any = {}
payload.abi.forEach((item: any) => {
if (item.type === 'function') {
item.id = encodeFunctionId(item);
abi[item.id] = item;
}
if (item.type === 'fallback') {
lowLevel.fallback = item;
}
if (item.type === 'receive') {
lowLevel.receive = item;
}
});
const ids = Object.keys(abi);
const items =
@ -279,6 +303,8 @@ export const initInstance = async ({
items,
containers: Object.keys(items),
natSpec,
solcVersion: getVersion(solcVersion),
...lowLevel,
},
});
};

@ -8,7 +8,7 @@ class RemixClient extends PluginClient {
createClient(this);
}
edit({ address, abi, network, name, devdoc, methodIdentifiers }: any): void {
edit({ address, abi, network, name, devdoc, methodIdentifiers, solcVersion }: any): void {
initInstance({
address,
abi,
@ -16,6 +16,7 @@ class RemixClient extends PluginClient {
name,
devdoc,
methodIdentifiers,
solcVersion,
});
}
}

@ -356,13 +356,15 @@ export function RunTabUI(props: RunTabProps) {
getFuncABIInputs={getFuncABIValues}
exEnvironment={runTab.selectExEnv}
editInstance={(instance) => {
const { metadata, abi, object } = instance.contractData;
plugin.call('quick-dapp', 'edit', {
address: instance.address,
abi: instance.contractData.abi,
abi: abi,
name: instance.name,
network: runTab.networkName,
devdoc: instance.contractData.object.devdoc,
methodIdentifiers: instance.contractData.object.evm.methodIdentifiers,
devdoc: object.devdoc,
methodIdentifiers: object.evm.methodIdentifiers,
solcVersion: JSON.parse(metadata).compiler.version,
})
}}
/>

Loading…
Cancel
Save