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
8d9b3f49
Commit
8d9b3f49
authored
May 30, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update wagmi and web3modal versions
parent
07d53241
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
644 additions
and
959 deletions
+644
-959
global.d.ts
global.d.ts
+2
-4
walletConnect.ts
lib/csp/policies/walletConnect.ts
+1
-2
useProvider.tsx
lib/web3/useProvider.tsx
+3
-2
next.config.js
next.config.js
+1
-0
package.json
package.json
+4
-4
TestApp.tsx
playwright/TestApp.tsx
+19
-16
contract.ts
types/api/contract.ts
+6
-0
wallets.ts
types/client/wallets.ts
+0
-9
utils.ts
types/utils.ts
+3
-2
AddressDetails.pw.tsx
ui/address/AddressDetails.pw.tsx
+2
-1
ContractMethodCallable.tsx
ui/address/contract/ContractMethodCallable.tsx
+5
-4
ContractWrite.tsx
ui/address/contract/ContractWrite.tsx
+15
-11
ContractWriteResultDumb.pw.tsx
ui/address/contract/ContractWriteResultDumb.pw.tsx
+3
-3
context.tsx
ui/address/contract/context.tsx
+30
-25
types.ts
ui/address/contract/types.ts
+1
-1
NetworkAddToWallet.tsx
ui/shared/NetworkAddToWallet.tsx
+3
-1
Web3ModalProvider.tsx
ui/shared/Web3ModalProvider.tsx
+29
-22
AddressAddToWallet.tsx
ui/shared/address/AddressAddToWallet.tsx
+1
-1
Footer.pw.tsx
ui/snippets/footer/Footer.pw.tsx
+2
-1
yarn.lock
yarn.lock
+514
-850
No files found.
global.d.ts
View file @
8d9b3f49
import
type
{
ExternalProvider
}
from
'
types/client/wallets
'
;
import
type
{
WindowProvider
}
from
'
wagmi
'
;
type
CPreferences
=
{
type
CPreferences
=
{
zone
:
string
;
zone
:
string
;
...
@@ -8,9 +8,7 @@ type CPreferences = {
...
@@ -8,9 +8,7 @@ type CPreferences = {
declare
global
{
declare
global
{
export
interface
Window
{
export
interface
Window
{
ethereum
?:
{
ethereum
?:
WindowProvider
;
providers
?:
Array
<
ExternalProvider
>
;
};
coinzilla_display
:
Array
<
CPreferences
>
;
coinzilla_display
:
Array
<
CPreferences
>
;
ga
?:
{
ga
?:
{
getAll
:
()
=>
Array
<
{
get
:
(
prop
:
string
)
=>
string
}
>
;
getAll
:
()
=>
Array
<
{
get
:
(
prop
:
string
)
=>
string
}
>
;
...
...
lib/csp/policies/walletConnect.ts
View file @
8d9b3f49
...
@@ -10,8 +10,7 @@ export function walletConnect(): CspDev.DirectiveDescriptor {
...
@@ -10,8 +10,7 @@ export function walletConnect(): CspDev.DirectiveDescriptor {
return
{
return
{
'
connect-src
'
:
[
'
connect-src
'
:
[
'
*.walletconnect.com
'
,
'
*.walletconnect.com
'
,
'
wss://*.bridge.walletconnect.org
'
,
'
wss://relay.walletconnect.com
'
,
'
wss://www.walletlink.org
'
,
],
],
'
img-src
'
:
[
'
img-src
'
:
[
'
*.walletconnect.com
'
,
'
*.walletconnect.com
'
,
...
...
lib/web3/useProvider.tsx
View file @
8d9b3f49
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
WindowProvider
}
from
'
wagmi
'
;
import
type
{
ExternalProvider
}
from
'
types/client/wallets
'
;
import
'
wagmi/window
'
;
import
appConfig
from
'
configs/app/config
'
;
import
appConfig
from
'
configs/app/config
'
;
export
default
function
useProvider
()
{
export
default
function
useProvider
()
{
const
[
provider
,
setProvider
]
=
React
.
useState
<
External
Provider
>
();
const
[
provider
,
setProvider
]
=
React
.
useState
<
Window
Provider
>
();
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
!
(
'
ethereum
'
in
window
))
{
if
(
!
(
'
ethereum
'
in
window
))
{
...
...
next.config.js
View file @
8d9b3f49
...
@@ -28,6 +28,7 @@ const moduleExports = withTM({
...
@@ -28,6 +28,7 @@ const moduleExports = withTM({
use
:
[
'
@svgr/webpack
'
],
use
:
[
'
@svgr/webpack
'
],
},
},
);
);
config
.
resolve
.
fallback
=
{
fs
:
false
,
net
:
false
,
tls
:
false
};
return
config
;
return
config
;
},
},
...
...
package.json
View file @
8d9b3f49
...
@@ -43,14 +43,13 @@
...
@@ -43,14 +43,13 @@
"
@tanstack/react-query-devtools
"
:
"
^4.0.10
"
,
"
@tanstack/react-query-devtools
"
:
"
^4.0.10
"
,
"
@types/papaparse
"
:
"
^5.3.5
"
,
"
@types/papaparse
"
:
"
^5.3.5
"
,
"
@types/react-scroll
"
:
"
^1.8.4
"
,
"
@types/react-scroll
"
:
"
^1.8.4
"
,
"
@web3modal/ethereum
"
:
"
^2.
0.0-rc.2
"
,
"
@web3modal/ethereum
"
:
"
^2.
4.1
"
,
"
@web3modal/react
"
:
"
^2.
0.0-rc.2
"
,
"
@web3modal/react
"
:
"
^2.
4.1
"
,
"
bignumber.js
"
:
"
^9.1.0
"
,
"
bignumber.js
"
:
"
^9.1.0
"
,
"
chakra-react-select
"
:
"
^4.4.3
"
,
"
chakra-react-select
"
:
"
^4.4.3
"
,
"
d3
"
:
"
^7.6.1
"
,
"
d3
"
:
"
^7.6.1
"
,
"
dayjs
"
:
"
^1.11.5
"
,
"
dayjs
"
:
"
^1.11.5
"
,
"
dom-to-image
"
:
"
^2.6.0
"
,
"
dom-to-image
"
:
"
^2.6.0
"
,
"
ethers
"
:
"
^5.7.2
"
,
"
framer-motion
"
:
"
^6.5.1
"
,
"
framer-motion
"
:
"
^6.5.1
"
,
"
graphiql
"
:
"
^2.2.0
"
,
"
graphiql
"
:
"
^2.2.0
"
,
"
graphql
"
:
"
^16.6.0
"
,
"
graphql
"
:
"
^16.6.0
"
,
...
@@ -78,7 +77,8 @@
...
@@ -78,7 +77,8 @@
"
react-scroll
"
:
"
^1.8.7
"
,
"
react-scroll
"
:
"
^1.8.7
"
,
"
swagger-ui-react
"
:
"
^4.15.5
"
,
"
swagger-ui-react
"
:
"
^4.15.5
"
,
"
use-font-face-observer
"
:
"
^1.2.1
"
,
"
use-font-face-observer
"
:
"
^1.2.1
"
,
"
wagmi
"
:
"
^0.10.6
"
"
viem
"
:
"
^0.3.39
"
,
"
wagmi
"
:
"
^1.0.9
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@playwright/experimental-ct-react
"
:
"
1.32.3
"
,
"
@playwright/experimental-ct-react
"
:
"
1.32.3
"
,
...
...
playwright/TestApp.tsx
View file @
8d9b3f49
import
{
ChakraProvider
}
from
'
@chakra-ui/react
'
;
import
{
ChakraProvider
}
from
'
@chakra-ui/react
'
;
import
{
QueryClient
,
QueryClientProvider
}
from
'
@tanstack/react-query
'
;
import
{
QueryClient
,
QueryClientProvider
}
from
'
@tanstack/react-query
'
;
import
{
providers
}
from
'
ethers
'
;
import
{
w3mProvider
}
from
'
@web3modal/ethereum
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
createClient
,
WagmiConfig
}
from
'
wagmi
'
;
import
{
createWalletClient
,
custom
}
from
'
viem
'
;
import
{
configureChains
,
createConfig
,
WagmiConfig
}
from
'
wagmi
'
;
import
{
mainnet
}
from
'
wagmi/chains
'
;
import
{
mainnet
}
from
'
wagmi/chains
'
;
import
{
MockConnector
}
from
'
wagmi/connectors/mock
'
;
import
{
MockConnector
}
from
'
wagmi/connectors/mock
'
;
...
@@ -28,25 +29,27 @@ const defaultAppContext = {
...
@@ -28,25 +29,27 @@ const defaultAppContext = {
};
};
// >>> Web3 stuff
// >>> Web3 stuff
const
provider
=
new
providers
.
JsonRpcProvider
(
'
http://localhost:8545
'
,
{
name
:
'
POA
'
,
chainId
:
99
,
},
);
const
connector
=
new
MockConnector
({
const
connector
=
new
MockConnector
({
chains
:
[
mainnet
],
options
:
{
options
:
{
signer
:
provider
.
getSigner
(),
chainId
:
mainnet
.
id
,
walletClient
:
createWalletClient
({
chain
:
mainnet
,
transport
:
custom
(
window
.
ethereum
!
),
}),
},
},
});
});
const
wagmiClient
=
createClient
({
const
{
publicClient
}
=
configureChains
(
autoConnect
:
true
,
[
mainnet
],
[
w3mProvider
({
projectId
:
''
}),
],
);
const
wagmiConfig
=
createConfig
({
autoConnect
:
false
,
connectors
:
[
connector
],
connectors
:
[
connector
],
p
rovider
,
p
ublicClient
,
});
});
// <<<<
// <<<<
...
@@ -65,7 +68,7 @@ const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props
...
@@ -65,7 +68,7 @@ const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props
<
QueryClientProvider
client=
{
queryClient
}
>
<
QueryClientProvider
client=
{
queryClient
}
>
<
SocketProvider
url=
{
withSocket
?
`ws://localhost:${ PORT }`
:
undefined
}
>
<
SocketProvider
url=
{
withSocket
?
`ws://localhost:${ PORT }`
:
undefined
}
>
<
AppContextProvider
{
...
appContext
}
>
<
AppContextProvider
{
...
appContext
}
>
<
WagmiConfig
c
lient=
{
wagmiClient
}
>
<
WagmiConfig
c
onfig=
{
wagmiConfig
}
>
{
children
}
{
children
}
</
WagmiConfig
>
</
WagmiConfig
>
</
AppContextProvider
>
</
AppContextProvider
>
...
...
types/api/contract.ts
View file @
8d9b3f49
import
type
{
Abi
}
from
'
abitype
'
;
import
type
{
Abi
}
from
'
abitype
'
;
// import type { ArrayElement } from 'types/utils';
export
type
SmartContractMethodArgType
=
'
address
'
|
'
uint256
'
|
'
bool
'
|
'
string
'
|
'
bytes
'
|
'
bytes32
'
;
export
type
SmartContractMethodArgType
=
'
address
'
|
'
uint256
'
|
'
bool
'
|
'
string
'
|
'
bytes
'
|
'
bytes32
'
;
export
type
SmartContractMethodStateMutability
=
'
view
'
|
'
nonpayable
'
|
'
payable
'
;
export
type
SmartContractMethodStateMutability
=
'
view
'
|
'
nonpayable
'
|
'
payable
'
;
...
@@ -80,15 +82,19 @@ export interface SmartContractWriteReceive {
...
@@ -80,15 +82,19 @@ export interface SmartContractWriteReceive {
}
}
export
type
SmartContractWriteMethod
=
SmartContractMethodBase
|
SmartContractWriteFallback
|
SmartContractWriteReceive
;
export
type
SmartContractWriteMethod
=
SmartContractMethodBase
|
SmartContractWriteFallback
|
SmartContractWriteReceive
;
// export type SmartContractWriteMethod = ArrayElement<Abi> & {name?: string};
// export type SmartContractReadMethod = ArrayElement<Abi> & {name?: string};
export
type
SmartContractMethod
=
SmartContractReadMethod
|
SmartContractWriteMethod
;
export
type
SmartContractMethod
=
SmartContractReadMethod
|
SmartContractWriteMethod
;
// export type SmartContractMethodInput = ArrayElement<Abi> & {name?: string};
export
interface
SmartContractMethodInput
{
export
interface
SmartContractMethodInput
{
internalType
?:
SmartContractMethodArgType
;
internalType
?:
SmartContractMethodArgType
;
name
:
string
;
name
:
string
;
type
:
SmartContractMethodArgType
;
type
:
SmartContractMethodArgType
;
}
}
// export type SmartContractMethodOutput = ArrayElement<Abi> & {name?: string};
export
interface
SmartContractMethodOutput
extends
SmartContractMethodInput
{
export
interface
SmartContractMethodOutput
extends
SmartContractMethodInput
{
value
?:
string
;
value
?:
string
;
}
}
...
...
types/client/wallets.ts
View file @
8d9b3f49
import
type
{
providers
}
from
'
ethers
'
;
export
type
WalletType
=
'
metamask
'
|
'
coinbase
'
;
export
type
WalletType
=
'
metamask
'
|
'
coinbase
'
;
export
interface
WalletInfo
{
export
interface
WalletInfo
{
name
:
string
;
name
:
string
;
icon
:
React
.
ElementType
;
icon
:
React
.
ElementType
;
}
}
export
interface
ExternalProvider
extends
providers
.
ExternalProvider
{
isCoinbaseWallet
?:
boolean
;
// have to patch ethers here, since params could be not only an array
// eslint-disable-next-line @typescript-eslint/no-explicit-any
request
?:
(
request
:
{
method
:
string
;
params
?:
any
})
=>
Promise
<
any
>
;
}
types/utils.ts
View file @
8d9b3f49
export
type
ArrayElement
<
ArrayType
extends
Array
<
unknown
>>
=
export
type
ArrayElement
<
ArrType
>
=
ArrType
extends
ReadonlyArray
<
infer
ElementType
>
ArrayType
extends
Array
<
(
infer
ElementType
)
>
?
ElementType
:
never
;
?
ElementType
:
never
;
export
type
ExcludeNull
<
T
>
=
T
extends
null
?
never
:
T
;
export
type
ExcludeNull
<
T
>
=
T
extends
null
?
never
:
T
;
...
...
ui/address/AddressDetails.pw.tsx
View file @
8d9b3f49
import
{
test
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
{
test
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
WindowProvider
}
from
'
wagmi
'
;
import
type
{
Address
}
from
'
types/api/address
'
;
import
type
{
Address
}
from
'
types/api/address
'
;
...
@@ -74,7 +75,7 @@ test('token', async({ mount, page }) => {
...
@@ -74,7 +75,7 @@ test('token', async({ mount, page }) => {
await
page
.
evaluate
(()
=>
{
await
page
.
evaluate
(()
=>
{
window
.
ethereum
=
{
window
.
ethereum
=
{
providers
:
[
{
isMetaMask
:
true
}
],
providers
:
[
{
isMetaMask
:
true
}
],
};
}
as
WindowProvider
;
});
});
const
component
=
await
mount
(
const
component
=
await
mount
(
...
...
ui/address/contract/ContractMethodCallable.tsx
View file @
8d9b3f49
...
@@ -25,7 +25,7 @@ interface Props<T extends SmartContractMethod> {
...
@@ -25,7 +25,7 @@ interface Props<T extends SmartContractMethod> {
isWrite
?:
boolean
;
isWrite
?:
boolean
;
}
}
const
getFieldName
=
(
name
:
string
,
index
:
number
):
string
=>
name
||
String
(
index
);
const
getFieldName
=
(
name
:
string
|
undefined
,
index
:
number
):
string
=>
name
||
String
(
index
);
const
sortFields
=
(
data
:
Array
<
SmartContractMethodInput
>
)
=>
([
a
]:
[
string
,
string
],
[
b
]:
[
string
,
string
]):
1
|
-
1
|
0
=>
{
const
sortFields
=
(
data
:
Array
<
SmartContractMethodInput
>
)
=>
([
a
]:
[
string
,
string
],
[
b
]:
[
string
,
string
]):
1
|
-
1
|
0
=>
{
const
fieldNames
=
data
.
map
(({
name
},
index
)
=>
getFieldName
(
name
,
index
));
const
fieldNames
=
data
.
map
(({
name
},
index
)
=>
getFieldName
(
name
,
index
));
...
@@ -69,12 +69,13 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit,
...
@@ -69,12 +69,13 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit,
const
inputs
=
React
.
useMemo
(()
=>
{
const
inputs
=
React
.
useMemo
(()
=>
{
return
[
return
[
...(
'
inputs
'
in
data
?
data
.
inputs
:
[]),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...(
data
.
stateMutability
===
'
payable
'
?
[
{
...(
'
inputs
'
in
data
?
data
.
inputs
as
Array
<
any
>
:
[]),
// todo_tom fix type
...(
'
stateMutability
'
in
data
&&
data
.
stateMutability
===
'
payable
'
?
[
{
name
:
'
value
'
,
name
:
'
value
'
,
type
:
appConfig
.
network
.
currency
.
symbol
,
type
:
appConfig
.
network
.
currency
.
symbol
,
internalType
:
appConfig
.
network
.
currency
.
symbol
,
internalType
:
appConfig
.
network
.
currency
.
symbol
,
}
as
SmartContractMethodInput
]
:
[]),
}
]
:
[]),
];
];
},
[
data
]);
},
[
data
]);
...
...
ui/address/contract/ContractWrite.tsx
View file @
8d9b3f49
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
useAccount
,
use
Signer
,
useNetwork
,
useSwitchNetwork
}
from
'
wagmi
'
;
import
{
useAccount
,
use
WalletClient
,
useNetwork
,
useSwitchNetwork
}
from
'
wagmi
'
;
import
type
{
SmartContractWriteMethod
}
from
'
types/api/contract
'
;
import
type
{
SmartContractWriteMethod
}
from
'
types/api/contract
'
;
...
@@ -24,7 +24,7 @@ interface Props {
...
@@ -24,7 +24,7 @@ interface Props {
}
}
const
ContractWrite
=
({
addressHash
,
isProxy
,
isCustomAbi
}:
Props
)
=>
{
const
ContractWrite
=
({
addressHash
,
isProxy
,
isCustomAbi
}:
Props
)
=>
{
const
{
data
:
signer
}
=
useSigner
();
const
{
data
:
walletClient
}
=
useWalletClient
();
const
{
isConnected
}
=
useAccount
();
const
{
isConnected
}
=
useAccount
();
const
{
chain
}
=
useNetwork
();
const
{
chain
}
=
useNetwork
();
const
{
switchNetworkAsync
}
=
useSwitchNetwork
();
const
{
switchNetworkAsync
}
=
useSwitchNetwork
();
...
@@ -67,24 +67,28 @@ const ContractWrite = ({ addressHash, isProxy, isCustomAbi }: Props) => {
...
@@ -67,24 +67,28 @@ const ContractWrite = ({ addressHash, isProxy, isCustomAbi }: Props) => {
if
(
item
.
type
===
'
receive
'
)
{
if
(
item
.
type
===
'
receive
'
)
{
const
value
=
args
[
0
]
?
getNativeCoinValue
(
args
[
0
])
:
'
0
'
;
const
value
=
args
[
0
]
?
getNativeCoinValue
(
args
[
0
])
:
'
0
'
;
const
result
=
await
signer
?.
sendTransaction
({
const
hash
=
await
walletClient
?.
sendTransaction
({
to
:
addressHash
,
to
:
addressHash
as
`0x
${
string
}
`
|
undefined
,
value
,
value
:
BigInt
(
value
),
// todo_tom simplify this
});
});
return
{
hash
:
result
?.
hash
as
string
};
return
{
hash
};
}
}
const
_args
=
item
.
stateMutability
===
'
payable
'
?
args
.
slice
(
0
,
-
1
)
:
args
;
const
_args
=
'
stateMutability
'
in
item
&&
item
.
stateMutability
===
'
payable
'
?
args
.
slice
(
0
,
-
1
)
:
args
;
const
value
=
item
.
stateMutability
===
'
payable
'
?
getNativeCoinValue
(
args
[
args
.
length
-
1
])
:
undefined
;
const
value
=
'
stateMutability
'
in
item
&&
item
.
stateMutability
===
'
payable
'
?
getNativeCoinValue
(
args
[
args
.
length
-
1
])
:
undefined
;
const
methodName
=
item
.
type
===
'
fallback
'
?
'
fallback
'
:
item
.
name
;
const
methodName
=
item
.
type
===
'
fallback
'
?
'
fallback
'
:
item
.
name
;
const
result
=
await
_contract
[
methodName
](...
_args
,
{
if
(
!
methodName
)
{
throw
new
Error
(
'
Method name is not defined
'
);
}
const
hash
=
await
_contract
.
write
[
methodName
](...
_args
,
{
gasLimit
:
100
_000
,
gasLimit
:
100
_000
,
value
,
value
,
});
});
return
{
hash
:
result
.
hash
as
string
};
return
{
hash
};
},
[
_contract
,
addressHash
,
chain
,
isConnected
,
signer
,
switchNetworkAsync
]);
},
[
_contract
,
addressHash
,
chain
,
isConnected
,
walletClient
,
switchNetworkAsync
]);
const
renderContent
=
React
.
useCallback
((
item
:
SmartContractWriteMethod
,
index
:
number
,
id
:
number
)
=>
{
const
renderContent
=
React
.
useCallback
((
item
:
SmartContractWriteMethod
,
index
:
number
,
id
:
number
)
=>
{
return
(
return
(
...
...
ui/address/contract/ContractWriteResultDumb.pw.tsx
View file @
8d9b3f49
...
@@ -12,7 +12,7 @@ test('loading', async({ mount }) => {
...
@@ -12,7 +12,7 @@ test('loading', async({ mount }) => {
error
:
null
,
error
:
null
,
},
},
result
:
{
result
:
{
hash
:
'
0x363574E6C5C71c343d7348093D84320c76d5Dd29
'
,
hash
:
'
0x363574E6C5C71c343d7348093D84320c76d5Dd29
'
as
`0x
${
string
}
`
,
},
},
onSettle
:
()
=>
{},
onSettle
:
()
=>
{},
};
};
...
@@ -33,7 +33,7 @@ test('success', async({ mount }) => {
...
@@ -33,7 +33,7 @@ test('success', async({ mount }) => {
error
:
null
,
error
:
null
,
},
},
result
:
{
result
:
{
hash
:
'
0x363574E6C5C71c343d7348093D84320c76d5Dd29
'
,
hash
:
'
0x363574E6C5C71c343d7348093D84320c76d5Dd29
'
as
`0x
${
string
}
`
,
},
},
onSettle
:
()
=>
{},
onSettle
:
()
=>
{},
};
};
...
@@ -57,7 +57,7 @@ test('error +@mobile', async({ mount }) => {
...
@@ -57,7 +57,7 @@ test('error +@mobile', async({ mount }) => {
}
as
Error
,
}
as
Error
,
},
},
result
:
{
result
:
{
hash
:
'
0x363574E6C5C71c343d7348093D84320c76d5Dd29
'
,
hash
:
'
0x363574E6C5C71c343d7348093D84320c76d5Dd29
'
as
`0x
${
string
}
`
,
},
},
onSettle
:
()
=>
{},
onSettle
:
()
=>
{},
};
};
...
...
ui/address/contract/context.tsx
View file @
8d9b3f49
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
type
{
Contract
}
from
'
ethers
'
;
import
type
{
Abi
}
from
'
abitype
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
useContract
,
useProvider
,
useSigner
}
from
'
wagmi
'
;
import
type
{
WalletClient
}
from
'
wagmi
'
;
import
{
useWalletClient
}
from
'
wagmi
'
;
import
type
{
GetContractResult
}
from
'
wagmi/actions
'
;
import
{
getContract
}
from
'
wagmi/actions
'
;
import
type
{
Address
}
from
'
types/api/address
'
;
import
type
{
Address
}
from
'
types/api/address
'
;
...
@@ -13,20 +16,19 @@ type ProviderProps = {
...
@@ -13,20 +16,19 @@ type ProviderProps = {
}
}
type
TContractContext
=
{
type
TContractContext
=
{
contract
:
Contract
|
null
;
contract
:
GetContractResult
<
Abi
,
WalletClient
>
|
undefined
;
proxy
:
Contract
|
null
;
proxy
:
GetContractResult
<
Abi
,
WalletClient
>
|
undefined
;
custom
:
Contract
|
null
;
custom
:
GetContractResult
<
Abi
,
WalletClient
>
|
undefined
;
};
};
const
ContractContext
=
React
.
createContext
<
TContractContext
>
({
const
ContractContext
=
React
.
createContext
<
TContractContext
>
({
contract
:
null
,
contract
:
undefined
,
proxy
:
null
,
proxy
:
undefined
,
custom
:
null
,
custom
:
undefined
,
});
});
export
function
ContractContextProvider
({
addressHash
,
children
}:
ProviderProps
)
{
export
function
ContractContextProvider
({
addressHash
,
children
}:
ProviderProps
)
{
const
provider
=
useProvider
();
const
{
data
:
walletClient
}
=
useWalletClient
();
const
{
data
:
signer
}
=
useSigner
();
const
queryClient
=
useQueryClient
();
const
queryClient
=
useQueryClient
();
const
{
data
:
contractInfo
}
=
useApiQuery
(
'
contract
'
,
{
const
{
data
:
contractInfo
}
=
useApiQuery
(
'
contract
'
,
{
...
@@ -58,27 +60,30 @@ export function ContractContextProvider({ addressHash, children }: ProviderProps
...
@@ -58,27 +60,30 @@ export function ContractContextProvider({ addressHash, children }: ProviderProps
},
},
});
});
const
contract
=
use
Contract
({
const
contract
=
addressHash
&&
contractInfo
?.
abi
?
get
Contract
({
address
:
addressHash
,
address
:
addressHash
as
`0x
${
string
}
`
,
abi
:
contractInfo
?.
abi
??
undefined
,
abi
:
contractInfo
?.
abi
??
undefined
,
signerOrProvider
:
signer
??
provider
,
walletClient
:
walletClient
??
undefined
,
});
})
:
undefined
;
const
proxy
=
useContract
({
address
:
addressInfo
?.
implementation_address
??
undefined
,
const
proxy
=
addressInfo
?.
implementation_address
&&
proxyInfo
?.
abi
?
getContract
({
abi
:
proxyInfo
?.
abi
??
undefined
,
address
:
addressInfo
?.
implementation_address
as
`0x
${
string
}
`
,
signerOrProvider
:
signer
??
provider
,
abi
:
proxyInfo
?.
abi
,
});
walletClient
:
walletClient
??
undefined
,
const
custom
=
useContract
({
})
:
undefined
;
address
:
addressHash
,
abi
:
customInfo
??
undefined
,
const
custom
=
addressHash
&&
customInfo
?
getContract
({
signerOrProvider
:
signer
??
provider
,
address
:
addressHash
as
`0x
${
string
}
`
,
});
abi
:
customInfo
,
walletClient
:
walletClient
??
undefined
,
})
:
undefined
;
const
value
=
React
.
useMemo
(()
=>
({
const
value
=
React
.
useMemo
(()
=>
({
contract
,
contract
,
proxy
,
proxy
,
custom
,
custom
,
}),
[
contract
,
proxy
,
custom
]);
// todo_tom fix this
}
as
TContractContext
),
[
contract
,
proxy
,
custom
]);
return
(
return
(
<
ContractContext
.
Provider
value=
{
value
}
>
<
ContractContext
.
Provider
value=
{
value
}
>
...
...
ui/address/contract/types.ts
View file @
8d9b3f49
...
@@ -6,7 +6,7 @@ export type MethodFormFields = Record<string, string>;
...
@@ -6,7 +6,7 @@ export type MethodFormFields = Record<string, string>;
export
type
ContractMethodReadResult
=
SmartContractQueryMethodRead
|
ResourceError
;
export
type
ContractMethodReadResult
=
SmartContractQueryMethodRead
|
ResourceError
;
export
type
ContractMethodWriteResult
=
Error
|
{
hash
:
string
}
|
undefined
;
export
type
ContractMethodWriteResult
=
Error
|
{
hash
:
`0x
${
string
}
`
|
undefined
}
|
undefined
;
export
type
ContractMethodCallResult
<
T
extends
SmartContractMethod
>
=
export
type
ContractMethodCallResult
<
T
extends
SmartContractMethod
>
=
T
extends
{
method_id
:
string
}
?
ContractMethodReadResult
:
ContractMethodWriteResult
;
T
extends
{
method_id
:
string
}
?
ContractMethodReadResult
:
ContractMethodWriteResult
;
ui/shared/NetworkAddToWallet.tsx
View file @
8d9b3f49
...
@@ -30,7 +30,9 @@ const NetworkAddToWallet = ({ className }: Props) => {
...
@@ -30,7 +30,9 @@ const NetworkAddToWallet = ({ className }: Props) => {
rpcUrls
:
[
appConfig
.
network
.
rpcUrl
],
rpcUrls
:
[
appConfig
.
network
.
rpcUrl
],
blockExplorerUrls
:
[
appConfig
.
baseUrl
],
blockExplorerUrls
:
[
appConfig
.
baseUrl
],
}
],
}
],
};
// in wagmi types for wallet_addEthereumChain method is not provided
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}
as
any
;
await
provider
?.
request
?.(
config
);
await
provider
?.
request
?.(
config
);
toast
({
toast
({
position
:
'
top-right
'
,
position
:
'
top-right
'
,
...
...
ui/shared/Web3ModalProvider.tsx
View file @
8d9b3f49
import
{
useColorModeValue
,
useToken
}
from
'
@chakra-ui/react
'
;
import
{
useColorModeValue
,
useToken
}
from
'
@chakra-ui/react
'
;
import
{
import
{
EthereumClient
,
w3mConnectors
,
w3mProvider
}
from
'
@web3modal/ethereum
'
;
EthereumClient
,
modalConnectors
,
walletConnectProvider
,
}
from
'
@web3modal/ethereum
'
;
import
{
Web3Modal
}
from
'
@web3modal/react
'
;
import
{
Web3Modal
}
from
'
@web3modal/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
Chain
}
from
'
wagmi
'
;
import
type
{
Chain
}
from
'
wagmi
'
;
import
{
configureChains
,
createC
lient
,
WagmiConfig
}
from
'
wagmi
'
;
import
{
configureChains
,
createC
onfig
,
WagmiConfig
}
from
'
wagmi
'
;
import
appConfig
from
'
configs/app/config
'
;
import
appConfig
from
'
configs/app/config
'
;
const
{
wagmiClient
,
ethereumClient
}
=
(
()
=>
{
const
getConfig
=
()
=>
{
try
{
try
{
if
(
!
appConfig
.
walletConnect
.
projectId
)
{
throw
new
Error
(
'
WalletConnect Project ID is not set
'
);
}
const
currentChain
:
Chain
=
{
const
currentChain
:
Chain
=
{
id
:
Number
(
appConfig
.
network
.
id
),
id
:
Number
(
appConfig
.
network
.
id
),
name
:
appConfig
.
network
.
name
||
''
,
name
:
appConfig
.
network
.
name
||
''
,
...
@@ -23,6 +23,9 @@ const { wagmiClient, ethereumClient } = (() => {
...
@@ -23,6 +23,9 @@ const { wagmiClient, ethereumClient } = (() => {
symbol
:
appConfig
.
network
.
currency
.
symbol
||
''
,
symbol
:
appConfig
.
network
.
currency
.
symbol
||
''
,
},
},
rpcUrls
:
{
rpcUrls
:
{
'
public
'
:
{
http
:
[
appConfig
.
network
.
rpcUrl
||
''
],
},
'
default
'
:
{
'
default
'
:
{
http
:
[
appConfig
.
network
.
rpcUrl
||
''
],
http
:
[
appConfig
.
network
.
rpcUrl
||
''
],
},
},
...
@@ -37,46 +40,50 @@ const { wagmiClient, ethereumClient } = (() => {
...
@@ -37,46 +40,50 @@ const { wagmiClient, ethereumClient } = (() => {
const
chains
=
[
currentChain
];
const
chains
=
[
currentChain
];
const
{
p
rovider
}
=
configureChains
(
chains
,
[
const
{
p
ublicClient
}
=
configureChains
(
chains
,
[
w
alletConnect
Provider
({
projectId
:
appConfig
.
walletConnect
.
projectId
||
''
}),
w
3m
Provider
({
projectId
:
appConfig
.
walletConnect
.
projectId
||
''
}),
]);
]);
const
wagmiC
lient
=
createClient
({
const
wagmiC
onfig
=
createConfig
({
autoConnect
:
true
,
autoConnect
:
true
,
connectors
:
modalConnectors
({
appName
:
'
web3Modal
'
,
chains
}),
connectors
:
w3mConnectors
({
projectId
:
appConfig
.
walletConnect
.
projectId
,
chains
,
version
:
2
}),
p
rovider
,
p
ublicClient
,
});
});
const
ethereumClient
=
new
EthereumClient
(
wagmiC
lient
,
chains
);
const
ethereumClient
=
new
EthereumClient
(
wagmiC
onfig
,
chains
);
return
{
wagmiC
lient
,
ethereumClient
};
return
{
wagmiC
onfig
,
ethereumClient
};
}
catch
(
error
)
{
}
catch
(
error
)
{
return
{
wagmiC
lient
:
undefined
,
ethereumClient
:
undefined
};
return
{
wagmiC
onfig
:
undefined
,
ethereumClient
:
undefined
};
}
}
}
)()
;
};
interface
Props
{
interface
Props
{
children
:
React
.
ReactNode
;
children
:
React
.
ReactNode
;
fallback
?:
JSX
.
Element
|
(()
=>
JSX
.
Element
);
fallback
?:
JSX
.
Element
|
(()
=>
JSX
.
Element
);
}
}
const
{
wagmiConfig
,
ethereumClient
}
=
getConfig
();
const
Web3ModalProvider
=
({
children
,
fallback
}:
Props
)
=>
{
const
Web3ModalProvider
=
({
children
,
fallback
}:
Props
)
=>
{
const
modalZIndex
=
useToken
<
string
>
(
'
zIndices
'
,
'
modal
'
);
const
modalZIndex
=
useToken
<
string
>
(
'
zIndices
'
,
'
modal
'
);
const
web3ModalTheme
=
useColorModeValue
(
'
light
'
,
'
dark
'
);
const
web3ModalTheme
=
useColorModeValue
(
'
light
'
,
'
dark
'
);
if
(
!
wagmiC
lient
||
!
ethereumClient
)
{
if
(
!
wagmiC
onfig
||
!
ethereumClient
||
!
appConfig
.
walletConnect
.
projectId
)
{
return
typeof
fallback
===
'
function
'
?
fallback
()
:
(
fallback
||
null
);
return
typeof
fallback
===
'
function
'
?
fallback
()
:
(
fallback
||
null
);
}
}
return
(
return
(
<
WagmiConfig
client=
{
wagmiClient
}
>
<>
{
children
}
<
WagmiConfig
config=
{
wagmiConfig
}
>
{
children
}
</
WagmiConfig
>
<
Web3Modal
<
Web3Modal
projectId=
{
appConfig
.
walletConnect
.
projectId
}
projectId=
{
appConfig
.
walletConnect
.
projectId
}
ethereumClient=
{
ethereumClient
}
ethereumClient=
{
ethereumClient
}
themeZIndex=
{
Number
(
modalZIndex
)
}
themeMode=
{
web3ModalTheme
}
themeMode=
{
web3ModalTheme
}
themeBackground=
"themeColor"
themeVariables=
{
{
'
--w3m-z-index
'
:
modalZIndex
,
}
}
/>
/>
</
WagmiConfig
>
</>
);
);
};
};
...
...
ui/shared/address/AddressAddToWallet.tsx
View file @
8d9b3f49
...
@@ -26,7 +26,7 @@ const AddressAddToWallet = ({ className, token, isLoading }: Props) => {
...
@@ -26,7 +26,7 @@ const AddressAddToWallet = ({ className, token, isLoading }: Props) => {
type
:
'
ERC20
'
,
// Initially only supports ERC20, but eventually more!
type
:
'
ERC20
'
,
// Initially only supports ERC20, but eventually more!
options
:
{
options
:
{
address
:
token
.
address
,
address
:
token
.
address
,
symbol
:
token
.
symbol
,
symbol
:
token
.
symbol
||
''
,
decimals
:
Number
(
token
.
decimals
)
||
18
,
decimals
:
Number
(
token
.
decimals
)
||
18
,
// TODO: add token image when we have it in API
// TODO: add token image when we have it in API
// image: ''
// image: ''
...
...
ui/snippets/footer/Footer.pw.tsx
View file @
8d9b3f49
import
{
test
as
base
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
{
test
as
base
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
WindowProvider
}
from
'
wagmi
'
;
import
{
FOOTER_LINKS
}
from
'
mocks/config/footerLinks
'
;
import
{
FOOTER_LINKS
}
from
'
mocks/config/footerLinks
'
;
import
contextWithEnvs
from
'
playwright/fixtures/contextWithEnvs
'
;
import
contextWithEnvs
from
'
playwright/fixtures/contextWithEnvs
'
;
...
@@ -64,7 +65,7 @@ base.describe('without custom links', () => {
...
@@ -64,7 +65,7 @@ base.describe('without custom links', () => {
await
page
.
evaluate
(()
=>
{
await
page
.
evaluate
(()
=>
{
window
.
ethereum
=
{
window
.
ethereum
=
{
providers
:
[
{
isMetaMask
:
true
}
],
providers
:
[
{
isMetaMask
:
true
}
],
};
}
as
WindowProvider
;
});
});
await
mount
(
await
mount
(
...
...
yarn.lock
View file @
8d9b3f49
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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