Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
community_vote
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
0
Merge Requests
0
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
hanfeng zhang
community_vote
Commits
b2d16677
Commit
b2d16677
authored
Jun 23, 2021
by
hanfeng zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
321
parent
859a176e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
38 deletions
+29
-38
index.ts
src/service/index.ts
+6
-38
Dto.ts
src/types/Dto.ts
+23
-0
No files found.
src/service/index.ts
View file @
b2d16677
import
axios
,{
AxiosInstance
,
AxiosResponse
}
from
"axios"
;
import
axios
,{
AxiosInstance
,
AxiosResponse
}
from
"axios"
;
import
{
CreateVoteDto
}
from
'@/types/Dto'
interface
Account
{
interface
Account
{
...
@@ -30,6 +31,7 @@ class ChainService {
...
@@ -30,6 +31,7 @@ class ChainService {
private
async
chainRequire
(
method
:
string
,
data
:
any
[],
cb
?:
Callback
){
private
async
chainRequire
(
method
:
string
,
data
:
any
[],
cb
?:
Callback
){
return
await
this
.
service
.
request
({
return
await
this
.
service
.
request
({
data
:{
data
:{
"jsonrpc"
:
"2.0"
,
id
:
1
,
id
:
1
,
method
:
method
,
method
:
method
,
params
:
data
params
:
data
...
@@ -49,45 +51,12 @@ class ChainService {
...
@@ -49,45 +51,12 @@ class ChainService {
}
}
/**
/**
*
* 创建投票项目
* @param toAddr 要转账的目标地址
* @param data
* @param contractPair
* @returns
* @returns
*/
*/
async
creatTransition
(
toAddr
:
string
,
amount
:
number
,
execer
?:
string
){
async
createVote
(
data
:
CreateVoteDto
){
return
await
this
.
chainRequire
(
'Chain33.CreateRawTransaction'
,[{
return
await
this
.
chainRequire
(
'rankvote.CreateRankVoteTx'
,[
data
])
to
:
toAddr
,
amount
:
amount
,
fee
:
0.003
*
10
e8
,
isWithdraw
:
false
,
execer
:
execer
?
execer
:
'coins'
}])
}
}
async
signTransition
(
txHex
:
string
,
privateKey
:
string
){
return
await
this
.
chainRequire
(
'Chain33.SignRawTx'
,[{
privkey
:
privateKey
,
txHex
:
txHex
,
expire
:
'1h'
,
fee
:
0.003
*
10
e8
}])
}
async
sendTransaction
(
txHex
:
string
){
return
await
this
.
chainRequire
(
'Chain33.SendTransaction'
,[{
data
:
txHex
}])
}
async
buildGroupTransaction
(
txHexs
:
string
[]){
return
await
this
.
chainRequire
(
'Chain33.CreateRawTxGroup'
,[{
txs
:
txHexs
}])
}
async
getInfoByHash
(
hash
:
string
){
return
await
this
.
chainRequire
(
'Chain33.QueryTransaction'
,[{
"hash"
:
hash
}])
}
}
}
\ No newline at end of file
src/types/Dto.ts
0 → 100644
View file @
b2d16677
interface
ListItem
{
name
:
string
desc
:
string
}
interface
MemberItem
{
addr
:
string
name
:
string
}
export
interface
CreateVoteDto
{
name
:
string
;
options
:
ListItem
[];
startHeight
:
number
;
endHeight
:
number
;
description
?:
string
;
url
:
string
;
numType
:
number
;
//投票期间可复投次数 1 表示一次性 2表示每天一次
members
:
MemberItem
[];
isOpen
:
boolean
;
type
:
number
;
}
\ No newline at end of file
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