Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
3846c3bd
Unverified
Commit
3846c3bd
authored
Nov 02, 2023
by
tom goriunov
Committed by
GitHub
Nov 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show "Read contract" tab even if WalletConnect is not configured (#1315)
Fixes #1313
parent
795e71c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
10 deletions
+34
-10
proxy.ts
pages/api/proxy.ts
+3
-3
AddressContract.tsx
ui/address/AddressContract.tsx
+1
-1
ContractRead.tsx
ui/address/contract/ContractRead.tsx
+6
-6
useWatchAccount.tsx
ui/address/contract/useWatchAccount.tsx
+24
-0
No files found.
pages/api/proxy.ts
View file @
3846c3bd
...
...
@@ -32,8 +32,8 @@ export default handler;
export
const
config
=
{
api
:
{
// disable body parser otherwise it is impossible to upload large files (over 1Mb)
// e.g. when verifying a smart contract
bodyParser
:
false
,
bodyParser
:
{
sizeLimit
:
'
100mb
'
,
}
,
},
};
ui/address/AddressContract.tsx
View file @
3846c3bd
...
...
@@ -16,7 +16,7 @@ const TAB_LIST_PROPS = {
const
AddressContract
=
({
tabs
}:
Props
)
=>
{
const
fallback
=
React
.
useCallback
(()
=>
{
const
noProviderTabs
=
tabs
.
filter
(({
id
})
=>
id
===
'
contact_code
'
);
const
noProviderTabs
=
tabs
.
filter
(({
id
})
=>
id
===
'
contact_code
'
||
id
.
startsWith
(
'
read_
'
)
);
return
(
<
RoutedTabs
tabs=
{
noProviderTabs
}
variant=
"outline"
colorScheme=
"gray"
size=
"sm"
tabListProps=
{
TAB_LIST_PROPS
}
/>
);
...
...
ui/address/contract/ContractRead.tsx
View file @
3846c3bd
import
{
Alert
,
Flex
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
{
useAccount
}
from
'
wagmi
'
;
import
type
{
SmartContractReadMethod
,
SmartContractQueryMethodRead
}
from
'
types/api/contract
'
;
...
...
@@ -16,6 +15,7 @@ import ContractImplementationAddress from './ContractImplementationAddress';
import
ContractMethodCallable
from
'
./ContractMethodCallable
'
;
import
ContractMethodConstant
from
'
./ContractMethodConstant
'
;
import
ContractReadResult
from
'
./ContractReadResult
'
;
import
useWatchAccount
from
'
./useWatchAccount
'
;
interface
Props
{
addressHash
?:
string
;
...
...
@@ -25,13 +25,13 @@ interface Props {
const
ContractRead
=
({
addressHash
,
isProxy
,
isCustomAbi
}:
Props
)
=>
{
const
apiFetch
=
useApiFetch
();
const
{
address
:
userAddress
}
=
use
Account
();
const
account
=
useWatch
Account
();
const
{
data
,
isLoading
,
isError
}
=
useApiQuery
(
isProxy
?
'
contract_methods_read_proxy
'
:
'
contract_methods_read
'
,
{
pathParams
:
{
hash
:
addressHash
},
queryParams
:
{
is_custom_abi
:
isCustomAbi
?
'
true
'
:
'
false
'
,
from
:
userA
ddress
,
from
:
account
?.
a
ddress
,
},
queryOptions
:
{
enabled
:
Boolean
(
addressHash
),
...
...
@@ -50,11 +50,11 @@ const ContractRead = ({ addressHash, isProxy, isCustomAbi }: Props) => {
args
,
method_id
:
item
.
method_id
,
contract_type
:
isProxy
?
'
proxy
'
:
'
regular
'
,
from
:
userA
ddress
,
from
:
account
?.
a
ddress
,
},
},
});
},
[
a
ddressHash
,
apiFetch
,
isCustomAbi
,
isProxy
,
userAddress
]);
},
[
a
ccount
?.
address
,
addressHash
,
apiFetch
,
isCustomAbi
,
isProxy
]);
const
renderItemContent
=
React
.
useCallback
((
item
:
SmartContractReadMethod
,
index
:
number
,
id
:
number
)
=>
{
if
(
item
.
error
)
{
...
...
@@ -94,7 +94,7 @@ const ContractRead = ({ addressHash, isProxy, isCustomAbi }: Props) => {
return
(
<>
{
isCustomAbi
&&
<
ContractCustomAbiAlert
/>
}
<
ContractConnectWallet
/>
{
account
&&
<
ContractConnectWallet
/>
}
{
isProxy
&&
<
ContractImplementationAddress
hash=
{
addressHash
}
/>
}
<
ContractMethodsAccordion
data=
{
data
}
addressHash=
{
addressHash
}
renderItemContent=
{
renderItemContent
}
/>
</>
...
...
ui/address/contract/useWatchAccount.tsx
0 → 100644
View file @
3846c3bd
import
{
watchAccount
,
getAccount
}
from
'
@wagmi/core
'
;
import
React
from
'
react
'
;
export
function
getWalletAccount
()
{
try
{
return
getAccount
();
}
catch
(
error
)
{
return
null
;
}
}
export
default
function
useWatchAccount
()
{
const
[
account
,
setAccount
]
=
React
.
useState
(
getWalletAccount
());
React
.
useEffect
(()
=>
{
if
(
!
account
)
{
return
;
}
return
watchAccount
(
setAccount
);
},
[
account
]);
return
account
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment