Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
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
LuckySwap
interface
Commits
904d1835
Unverified
Commit
904d1835
authored
Jul 06, 2022
by
Vignesh Mohankumar
Committed by
GitHub
Jul 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: rename library to provider (#4038)
parent
77366bf8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
useSendSwapTransaction.tsx
src/lib/hooks/swap/useSendSwapTransaction.tsx
+6
-6
index.ts
src/utils/index.ts
+6
-6
No files found.
src/lib/hooks/swap/useSendSwapTransaction.tsx
View file @
904d1835
...
@@ -40,12 +40,12 @@ interface FailedCall extends SwapCallEstimate {
...
@@ -40,12 +40,12 @@ interface FailedCall extends SwapCallEstimate {
export
default
function
useSendSwapTransaction
(
export
default
function
useSendSwapTransaction
(
account
:
string
|
null
|
undefined
,
account
:
string
|
null
|
undefined
,
chainId
:
number
|
undefined
,
chainId
:
number
|
undefined
,
library
:
JsonRpcProvider
|
undefined
,
provider
:
JsonRpcProvider
|
undefined
,
trade
:
AnyTrade
|
undefined
,
// trade to execute, required
trade
:
AnyTrade
|
undefined
,
// trade to execute, required
swapCalls
:
SwapCall
[]
swapCalls
:
SwapCall
[]
):
{
callback
:
null
|
(()
=>
Promise
<
TransactionResponse
>
)
}
{
):
{
callback
:
null
|
(()
=>
Promise
<
TransactionResponse
>
)
}
{
return
useMemo
(()
=>
{
return
useMemo
(()
=>
{
if
(
!
trade
||
!
library
||
!
account
||
!
chainId
)
{
if
(
!
trade
||
!
provider
||
!
account
||
!
chainId
)
{
return
{
callback
:
null
}
return
{
callback
:
null
}
}
}
return
{
return
{
...
@@ -64,7 +64,7 @@ export default function useSendSwapTransaction(
...
@@ -64,7 +64,7 @@ export default function useSendSwapTransaction(
value
,
value
,
}
}
return
library
return
provider
.
estimateGas
(
tx
)
.
estimateGas
(
tx
)
.
then
((
gasEstimate
)
=>
{
.
then
((
gasEstimate
)
=>
{
return
{
return
{
...
@@ -75,7 +75,7 @@ export default function useSendSwapTransaction(
...
@@ -75,7 +75,7 @@ export default function useSendSwapTransaction(
.
catch
((
gasError
)
=>
{
.
catch
((
gasError
)
=>
{
console
.
debug
(
'
Gas estimate failed, trying eth_call to extract error
'
,
call
)
console
.
debug
(
'
Gas estimate failed, trying eth_call to extract error
'
,
call
)
return
library
return
provider
.
call
(
tx
)
.
call
(
tx
)
.
then
((
result
)
=>
{
.
then
((
result
)
=>
{
console
.
debug
(
'
Unexpected successful call after failed estimate gas
'
,
call
,
gasError
,
result
)
console
.
debug
(
'
Unexpected successful call after failed estimate gas
'
,
call
,
gasError
,
result
)
...
@@ -110,7 +110,7 @@ export default function useSendSwapTransaction(
...
@@ -110,7 +110,7 @@ export default function useSendSwapTransaction(
call
:
{
address
,
calldata
,
value
},
call
:
{
address
,
calldata
,
value
},
}
=
bestCallOption
}
=
bestCallOption
return
library
return
provider
.
getSigner
()
.
getSigner
()
.
sendTransaction
({
.
sendTransaction
({
from
:
account
,
from
:
account
,
...
@@ -136,5 +136,5 @@ export default function useSendSwapTransaction(
...
@@ -136,5 +136,5 @@ export default function useSendSwapTransaction(
})
})
},
},
}
}
},
[
account
,
chainId
,
library
,
swapCalls
,
trade
])
},
[
account
,
chainId
,
provider
,
swapCalls
,
trade
])
}
}
src/utils/index.ts
View file @
904d1835
...
@@ -25,22 +25,22 @@ export function shortenAddress(address: string, chars = 4): string {
...
@@ -25,22 +25,22 @@ export function shortenAddress(address: string, chars = 4): string {
}
}
// account is not optional
// account is not optional
function
getSigner
(
library
:
JsonRpcProvider
,
account
:
string
):
JsonRpcSigner
{
function
getSigner
(
provider
:
JsonRpcProvider
,
account
:
string
):
JsonRpcSigner
{
return
library
.
getSigner
(
account
).
connectUnchecked
()
return
provider
.
getSigner
(
account
).
connectUnchecked
()
}
}
// account is optional
// account is optional
function
getProviderOrSigner
(
library
:
JsonRpcProvider
,
account
?:
string
):
JsonRpcProvider
|
JsonRpcSigner
{
function
getProviderOrSigner
(
provider
:
JsonRpcProvider
,
account
?:
string
):
JsonRpcProvider
|
JsonRpcSigner
{
return
account
?
getSigner
(
library
,
account
)
:
library
return
account
?
getSigner
(
provider
,
account
)
:
provider
}
}
// account is optional
// account is optional
export
function
getContract
(
address
:
string
,
ABI
:
any
,
library
:
JsonRpcProvider
,
account
?:
string
):
Contract
{
export
function
getContract
(
address
:
string
,
ABI
:
any
,
provider
:
JsonRpcProvider
,
account
?:
string
):
Contract
{
if
(
!
isAddress
(
address
)
||
address
===
AddressZero
)
{
if
(
!
isAddress
(
address
)
||
address
===
AddressZero
)
{
throw
Error
(
`Invalid 'address' parameter '
${
address
}
'.`
)
throw
Error
(
`Invalid 'address' parameter '
${
address
}
'.`
)
}
}
return
new
Contract
(
address
,
ABI
,
getProviderOrSigner
(
library
,
account
)
as
any
)
return
new
Contract
(
address
,
ABI
,
getProviderOrSigner
(
provider
,
account
)
as
any
)
}
}
export
function
escapeRegExp
(
string
:
string
):
string
{
export
function
escapeRegExp
(
string
:
string
):
string
{
...
...
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