Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
db23f70a
Commit
db23f70a
authored
Nov 30, 2020
by
aniket-engg
Committed by
Aniket
Dec 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
txFormat and txHelper
parent
1678b0e9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
40 deletions
+37
-40
txFormat.ts
libs/remix-lib/src/execution/txFormat.ts
+10
-10
txHelper.ts
libs/remix-lib/src/execution/txHelper.ts
+27
-30
No files found.
libs/remix-lib/src/execution/txFormat.ts
View file @
db23f70a
'use strict'
const
ethers
=
require
(
'ethers'
)
import
{
ethers
}
from
'ethers'
const
helper
=
require
(
'./txHelper'
)
const
asyncJS
=
require
(
'async'
)
const
solcLinker
=
require
(
'solc/linker'
)
const
ethJSUtil
=
require
(
'ethereumjs-util'
)
import
{
eachOfSeries
}
from
'async'
import
{
linkBytecode
}
from
'solc/linker'
import
{
isValidAddress
,
addHexPrefix
}
from
'ethereumjs-util'
module
.
exports
=
{
...
...
@@ -38,7 +38,7 @@ module.exports = {
* @param {Function} callback - callback
*/
encodeParams
:
function
(
params
,
funAbi
,
callback
)
{
let
data
=
''
let
data
:
any
=
''
let
dataHex
=
''
let
funArgs
if
(
params
.
indexOf
(
'raw:0x'
)
===
0
)
{
...
...
@@ -104,7 +104,7 @@ module.exports = {
for
(
let
libFile
in
linkLibraries
)
{
for
(
let
lib
in
linkLibraries
[
libFile
])
{
const
address
=
linkLibraries
[
libFile
][
lib
]
if
(
!
ethJSUtil
.
isValidAddress
(
address
))
return
callback
(
address
+
' is not a valid address. Please check the provided address is valid.'
)
if
(
!
isValidAddress
(
address
))
return
callback
(
address
+
' is not a valid address. Please check the provided address is valid.'
)
bytecodeToDeploy
=
this
.
linkLibraryStandardFromlinkReferences
(
lib
,
address
.
replace
(
'0x'
,
''
),
bytecodeToDeploy
,
linkReferences
)
}
}
...
...
@@ -168,7 +168,7 @@ module.exports = {
*/
buildData
:
function
(
contractName
,
contract
,
contracts
,
isConstructor
,
funAbi
,
params
,
callback
,
callbackStep
,
callbackDeployLibrary
)
{
let
funArgs
=
[]
let
data
=
''
let
data
:
any
=
''
let
dataHex
=
''
if
(
params
.
indexOf
(
'raw:0x'
)
===
0
)
{
...
...
@@ -223,8 +223,8 @@ module.exports = {
linkBytecodeStandard
:
function
(
contract
,
contracts
,
callback
,
callbackStep
,
callbackDeployLibrary
)
{
let
contractBytecode
=
contract
.
evm
.
bytecode
.
object
asyncJS
.
eachOfSeries
(
contract
.
evm
.
bytecode
.
linkReferences
,
(
libs
,
file
,
cbFile
)
=>
{
asyncJS
.
eachOfSeries
(
contract
.
evm
.
bytecode
.
linkReferences
[
file
],
(
libRef
,
libName
,
cbLibDeployed
)
=>
{
eachOfSeries
(
contract
.
evm
.
bytecode
.
linkReferences
,
(
libs
,
file
,
cbFile
)
=>
{
eachOfSeries
(
contract
.
evm
.
bytecode
.
linkReferences
[
file
],
(
libRef
,
libName
,
cbLibDeployed
)
=>
{
const
library
=
contracts
[
file
][
libName
]
if
(
library
)
{
this
.
deployLibrary
(
file
+
':'
+
libName
,
libName
,
library
,
contracts
,
(
error
,
address
)
=>
{
...
...
@@ -351,7 +351,7 @@ module.exports = {
},
linkLibrary
:
function
(
libraryName
,
address
,
bytecodeToLink
)
{
return
solcLinker
.
linkBytecode
(
bytecodeToLink
,
{
[
libraryName
]:
ethJSUtil
.
addHexPrefix
(
address
)
})
return
linkBytecode
(
bytecodeToLink
,
{
[
libraryName
]:
addHexPrefix
(
address
)
})
},
decodeResponse
:
function
(
response
,
fnabi
)
{
...
...
libs/remix-lib/src/execution/txHelper.ts
View file @
db23f70a
'use strict'
import
{
ethers
}
from
'ethers'
module
.
exports
=
{
makeFullTypeDefinition
:
function
(
typeDef
)
{
export
function
makeFullTypeDefinition
(
typeDef
)
{
if
(
typeDef
&&
typeDef
.
type
.
indexOf
(
'tuple'
)
===
0
&&
typeDef
.
components
)
{
const
innerTypes
=
typeDef
.
components
.
map
((
innerType
)
=>
{
return
this
.
makeFullTypeDefinition
(
innerType
)
})
return
`tuple(
${
innerTypes
.
join
(
','
)}
)
${
this
.
extractSize
(
typeDef
.
type
)}
`
}
return
typeDef
.
type
},
}
encodeParams
:
function
(
funABI
,
args
)
{
export
function
encodeParams
(
funABI
,
args
)
{
const
types
=
[]
if
(
funABI
.
inputs
&&
funABI
.
inputs
.
length
)
{
for
(
let
i
=
0
;
i
<
funABI
.
inputs
.
length
;
i
++
)
{
...
...
@@ -31,15 +30,15 @@ module.exports = {
// it could be done here too for consistency
const
abiCoder
=
new
ethers
.
utils
.
AbiCoder
()
return
abiCoder
.
encode
(
types
,
args
)
},
}
encodeFunctionId
:
function
(
funABI
)
{
export
function
encodeFunctionId
(
funABI
)
{
if
(
funABI
.
type
===
'fallback'
||
funABI
.
type
===
'receive'
)
return
'0x'
let
abi
=
new
ethers
.
utils
.
Interface
([
funABI
])
return
abi
.
getSighash
(
funABI
.
name
)
},
}
sortAbiFunction
:
f
unction
(
contractabi
)
{
export
function
sortAbiF
unction
(
contractabi
)
{
// Check if function is constant (introduced with Solidity 0.6.0)
const
isConstant
=
({
stateMutability
})
=>
stateMutability
===
'view'
||
stateMutability
===
'pure'
// Sorts the list of ABI entries. Constant functions will appear first,
...
...
@@ -59,9 +58,9 @@ module.exports = {
return
1
}
})
},
}
getConstructorInterface
:
function
(
abi
)
{
export
function
getConstructorInterface
(
abi
)
{
const
funABI
=
{
'name'
:
''
,
'inputs'
:
[],
'type'
:
'constructor'
,
'payable'
:
false
,
'outputs'
:
[]
}
if
(
typeof
abi
===
'string'
)
{
try
{
...
...
@@ -82,23 +81,23 @@ module.exports = {
}
return
funABI
},
}
serializeInputs
:
function
(
fnAbi
)
{
export
function
serializeInputs
(
fnAbi
)
{
let
serialized
=
'('
if
(
fnAbi
.
inputs
&&
fnAbi
.
inputs
.
length
)
{
serialized
+=
fnAbi
.
inputs
.
map
((
input
)
=>
{
return
input
.
type
}).
join
(
','
)
}
serialized
+=
')'
return
serialized
},
}
extractSize
:
function
(
type
)
{
export
function
extractSize
(
type
)
{
const
size
=
type
.
match
(
/
([
a-zA-Z0-9
])(\[
.*
\])
/
)
return
size
?
size
[
2
]
:
''
},
}
getFunction
:
f
unction
(
abi
,
fnName
)
{
export
function
getF
unction
(
abi
,
fnName
)
{
for
(
let
i
=
0
;
i
<
abi
.
length
;
i
++
)
{
const
fn
=
abi
[
i
]
if
(
fn
.
type
===
'function'
&&
fnName
===
fn
.
name
+
'('
+
fn
.
inputs
.
map
((
value
)
=>
{
...
...
@@ -113,55 +112,53 @@ module.exports = {
}
}
return
null
},
}
getFallbackInterface
:
function
(
abi
)
{
export
function
getFallbackInterface
(
abi
)
{
for
(
let
i
=
0
;
i
<
abi
.
length
;
i
++
)
{
if
(
abi
[
i
].
type
===
'fallback'
)
{
return
abi
[
i
]
}
}
},
}
getReceiveInterface
:
function
(
abi
)
{
export
function
getReceiveInterface
(
abi
)
{
for
(
let
i
=
0
;
i
<
abi
.
length
;
i
++
)
{
if
(
abi
[
i
].
type
===
'receive'
)
{
return
abi
[
i
]
}
}
},
}
/**
/**
* return the contract obj of the given @arg name. Uses last compilation result.
* return null if not found
* @param {String} name - contract name
* @returns contract obj and associated file: { contract, file } or null
*/
getContract
:
(
contractName
,
contracts
)
=>
{
export
function
getContract
(
contractName
,
contracts
)
{
for
(
let
file
in
contracts
)
{
if
(
contracts
[
file
][
contractName
])
{
return
{
object
:
contracts
[
file
][
contractName
],
file
:
file
}
}
}
return
null
},
}
/**
/**
* call the given @arg cb (function) for all the contracts. Uses last compilation result
* stop visiting when cb return true
* @param {Function} cb - callback
*/
visitContracts
:
(
contracts
,
cb
)
=>
{
export
function
visitContracts
(
contracts
,
cb
)
{
for
(
let
file
in
contracts
)
{
for
(
let
name
in
contracts
[
file
])
{
if
(
cb
({
name
:
name
,
object
:
contracts
[
file
][
name
],
file
:
file
}))
return
}
}
},
}
inputParametersDeclarationToString
:
function
(
abiinputs
)
{
export
function
inputParametersDeclarationToString
(
abiinputs
)
{
const
inputs
=
(
abiinputs
||
[]).
map
((
inp
)
=>
inp
.
type
+
' '
+
inp
.
name
)
return
inputs
.
join
(
', '
)
}
}
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