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
4cd6f80f
Commit
4cd6f80f
authored
Jul 31, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added sign message
parent
13a52897
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
143 additions
and
1 deletion
+143
-1
signMessage.ts
apps/remix-ide-e2e/src/commands/signMessage.ts
+44
-0
signingMessage.test.ts
apps/remix-ide-e2e/src/tests/signingMessage.test.ts
+97
-0
index.d.ts
apps/remix-ide-e2e/src/types/index.d.ts
+2
-1
No files found.
apps/remix-ide-e2e/src/commands/signMessage.ts
0 → 100644
View file @
4cd6f80f
import
{
NightwatchBrowser
}
from
"nightwatch"
const
EventEmitter
=
require
(
'events'
)
class
SelectContract
extends
EventEmitter
{
command
(
this
:
NightwatchBrowser
,
msg
:
string
,
callback
:
(
hash
:
{
value
:
string
},
signature
:
{
value
:
string
})
=>
void
):
NightwatchBrowser
{
this
.
api
.
perform
((
done
)
=>
{
signMsg
(
this
.
api
,
msg
,
(
hash
,
signature
)
=>
{
callback
(
hash
,
signature
)
done
()
this
.
emit
(
'complete'
)
})
})
return
this
}
}
function
signMsg
(
browser
:
NightwatchBrowser
,
msg
:
string
,
cb
:
(
hash
:
{
value
:
string
},
signature
:
{
value
:
string
})
=>
void
)
{
let
hash
,
signature
browser
.
waitForElementPresent
(
'i[id="remixRunSignMsg"]'
)
.
click
(
'i[id="remixRunSignMsg"]'
)
.
waitForElementVisible
(
'textarea[id="prompt_text"]'
)
.
setValue
(
'textarea[id="prompt_text"]'
,
msg
,
()
=>
{
browser
.
modalFooterOKClick
().
perform
(
(
client
,
done
)
=>
{
browser
.
waitForElementVisible
(
'span[id="remixRunSignMsgHash"]'
).
getText
(
'span[id="remixRunSignMsgHash"]'
,
(
v
)
=>
{
hash
=
v
;
done
()
})
}
)
.
perform
(
(
client
,
done
)
=>
{
browser
.
waitForElementVisible
(
'span[id="remixRunSignMsgSignature"]'
).
getText
(
'span[id="remixRunSignMsgSignature"]'
,
(
v
)
=>
{
signature
=
v
;
done
()
})
}
)
.
modalFooterOKClick
()
.
perform
(
()
=>
{
cb
(
hash
,
signature
)
}
)
})
}
module
.
exports
=
SelectContract
apps/remix-ide-e2e/src/tests/signingMessage.test.ts
0 → 100644
View file @
4cd6f80f
'use strict'
import
{
NightwatchBrowser
}
from
"nightwatch"
import
init
from
'../helpers/init'
import
sauce
from
'./sauce'
module
.
exports
=
{
before
:
function
(
browser
:
NightwatchBrowser
,
done
:
VoidFunction
)
{
init
(
browser
,
done
)
},
'@sources'
:
function
()
{
return
sources
},
'Test Signature'
:
function
(
browser
:
NightwatchBrowser
)
{
let
hash
,
signature
browser
.
clickLaunchIcon
(
'udapp'
)
.
selectAccount
(
'0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'
)
// this account will be used for this test suite
.
signMessage
(
'test message'
,
(
h
,
s
)
=>
{
hash
=
h
signature
=
s
console
.
log
(
'hash'
,
hash
)
console
.
log
(
'signature'
,
signature
)
browser
.
assert
.
ok
(
typeof
hash
.
value
===
'string'
,
'type of hash.value must be String'
)
browser
.
assert
.
ok
(
typeof
signature
.
value
===
'string'
,
'type of signature.value must be String'
)
})
.
addFile
(
'signMassage.sol'
,
sources
[
0
][
'browser/signMassage.sol'
])
.
openFile
(
'browser/signMassage.sol'
)
.
pause
(
5000
)
.
selectContract
(
'ECVerify'
)
.
createContract
(
''
)
.
clickInstance
(
0
)
.
perform
((
done
)
=>
{
browser
.
getAddressAtPosition
(
0
,
(
address
)
=>
{
// skip 'instance' part of e.g. 'instance0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'
console
.
log
(
'Test Signature address'
,
address
)
const
inputs
=
`"
${
hash
.
value
}
","
${
signature
.
value
}
"`
console
.
log
(
'Test Signature Input'
,
inputs
)
browser
.
clickFunction
(
'ecrecovery - call'
,
{
types
:
'bytes32 hash, bytes sig'
,
values
:
inputs
})
.
pause
(
5000
)
.
verifyCallReturnValue
(
address
,
[
'0:address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'
])
.
perform
(()
=>
{
done
()
})
})
})
.
end
()
},
tearDown
:
sauce
}
const
sources
=
[
{
'browser/signMassage.sol'
:
{
content
:
`
pragma solidity >=0.4.22 <0.7.0;
contract SignMassageTest {
function testRecovery(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address) {
return ecrecover(h, v, r, s);
}
}
library ECVerify {
function ecrecovery(bytes32 hash, bytes memory sig) public pure returns (address) {
bytes32 r;
bytes32 s;
uint8 v;
if (sig.length != 65) {
return address(0);
}
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := and(mload(add(sig, 65)), 255)
}
if (v < 27) {
v += 27;
}
if (v != 27 && v != 28) {
return address(0);
}
return ecrecover(hash, v, r, s);
}
function ecverify(bytes32 hash, bytes memory sig, address signer) public pure returns (bool) {
return signer == ecrecovery(hash, sig);
}
}`
}
}
]
apps/remix-ide-e2e/src/types/index.d.ts
View file @
4cd6f80f
...
...
@@ -43,7 +43,8 @@ declare module "nightwatch" {
testEditorValue
(
testvalue
:
string
):
NightwatchBrowser
,
removeFile
(
path
:
string
):
NightwatchBrowser
,
switchBrowserWindow
(
url
:
string
,
windowName
:
string
,
cb
:
(
browser
:
NightwatchBrowser
,
window
?:
NightwatchCallbackResult
<
Window
>
)
=>
void
):
NightwatchBrowser
,
setupMetamask
(
passphrase
:
string
,
password
:
string
):
NightwatchBrowser
setupMetamask
(
passphrase
:
string
,
password
:
string
):
NightwatchBrowser
,
signMessage
(
msg
:
string
,
callback
:
(
hash
:
{
value
:
string
},
signature
:
{
value
:
string
})
=>
void
):
NightwatchBrowser
}
export
interface
NightwatchBrowser
{
...
...
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