Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
bd210511
Commit
bd210511
authored
Sep 09, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整请求时间
parent
176cbc54
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
42 deletions
+45
-42
Curl.php
common/helpers/Curl.php
+0
-0
Chain33Service.php
common/service/chain33/Chain33Service.php
+45
-41
CrossChainController.php
console/controllers/CrossChainController.php
+0
-1
No files found.
common/helpers/Curl.php
View file @
bd210511
This diff is collapsed.
Click to expand it.
common/service/chain33/Chain33Service.php
View file @
bd210511
...
...
@@ -20,7 +20,7 @@ class Chain33Service
public
function
__construct
(
$parameter
=
[])
{
if
(
empty
(
$parameter
))
{
if
(
empty
(
$parameter
))
{
$this
->
node_params
=
Yii
::
$app
->
params
[
'chain33'
];
}
else
{
$this
->
node_params
=
$parameter
;
...
...
@@ -31,8 +31,8 @@ class Chain33Service
{
$config
=
$this
->
node_params
;
$scheme
=
$config
[
'scheme'
]
??
'http'
;
$host
=
$config
[
'host'
]
??
'127.0.0.1'
;
$port
=
(
string
)
$config
[
'port'
]
??
''
;
$host
=
$config
[
'host'
]
??
'127.0.0.1'
;
$port
=
(
string
)
$config
[
'port'
]
??
''
;
if
(
$port
)
{
return
$scheme
.
'://'
.
$host
.
':'
.
$port
;
}
else
{
...
...
@@ -44,9 +44,9 @@ class Chain33Service
{
$data
=
[
'jsonrpc'
=>
'2.0'
,
'id'
=>
0
,
'method'
=>
$method
,
'params'
=>
[],
'id'
=>
0
,
'method'
=>
$method
,
'params'
=>
[],
];
if
(
!
empty
(
$params
))
{
$data
[
'params'
][]
=
$params
;
...
...
@@ -56,7 +56,11 @@ class Chain33Service
public
function
send
(
$params
=
[],
$method
=
'Chain33.Query'
)
{
$ch
=
new
Curl
();
$timeout
=
[
'connect_timeout'
=>
50000
,
'timeout_ms'
=>
40000
];
$ch
=
new
Curl
(
$timeout
);
$jsonrpc
=
self
::
jsonRpcBuild
(
$params
,
$method
);
$ch
->
setHeader
(
'Content-Type'
,
'application/json'
);
$ch
->
setRawPostData
(
$jsonrpc
);
...
...
@@ -124,7 +128,7 @@ class Chain33Service
* 获取地址下的所有token资产
*
* @param string|array $address
* @param string
$symbol
* @param string $symbol
* @return array
*/
public
function
getAccountTokenAssets
(
$address
,
$symbol
)
...
...
@@ -133,8 +137,8 @@ class Chain33Service
$address
=
[
$address
];
}
$params
=
[
"addresses"
=>
$address
,
"execer"
=>
"user.p.guodun.token"
,
"addresses"
=>
$address
,
"execer"
=>
"user.p.guodun.token"
,
"tokenSymbol"
=>
$symbol
];
return
$this
->
send
(
$params
,
'token.GetTokenBalance'
);
...
...
@@ -147,18 +151,18 @@ class Chain33Service
* @param $to
* @param $amount
* @param string $note
* @param bool
$isToken
* @param bool $isToken
* @param string $tokenSymbol
* @return array
*/
public
function
extractToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
{
$params
=
[
"from"
=>
$to
,
"to"
=>
$from
,
"amount"
=>
-
$amount
,
"note"
=>
$note
,
"isToken"
=>
$isToken
?
true
:
false
,
"from"
=>
$to
,
"to"
=>
$from
,
"amount"
=>
-
$amount
,
"note"
=>
$note
,
"isToken"
=>
$isToken
?
true
:
false
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
...
...
@@ -171,18 +175,18 @@ class Chain33Service
* @param $to
* @param $amount
* @param string $note
* @param bool
$isToken
* @param bool $isToken
* @param string $tokenSymbol
* @return array
*/
public
function
transToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
{
$params
=
[
"from"
=>
$from
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"note"
=>
$note
,
"isToken"
=>
$isToken
?
true
:
false
,
"from"
=>
$from
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"note"
=>
$note
,
"isToken"
=>
$isToken
?
true
:
false
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
...
...
@@ -191,25 +195,25 @@ class Chain33Service
public
function
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
)
{
$params
=
[
"to"
=>
$to
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"isToken"
=>
$isToken
,
"tokenSymbol"
=>
$tokenSymbol
,
"fee"
=>
$fee
,
"note"
=>
$note
,
"note"
=>
$note
,
"execer"
=>
$execer
,
];
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
}
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
{
$params
=
[
"to"
=>
$to
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"fee"
=>
$fee
,
"note"
=>
$note
,
"note"
=>
$note
,
"execer"
=>
$execer
,
];
...
...
@@ -274,11 +278,11 @@ class Chain33Service
public
function
structureTrade
(
$amount
,
$execName
,
$fee
,
$isToken
=
True
,
$to
,
$tokenSymbol
=
''
)
{
$params
=
[
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"execName"
=>
$execName
,
"fee"
=>
$fee
,
"isToken"
=>
$isToken
?
true
:
false
,
"to"
=>
$to
,
"fee"
=>
$fee
,
"isToken"
=>
$isToken
?
true
:
false
,
"to"
=>
$to
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
...
...
@@ -287,9 +291,9 @@ class Chain33Service
public
function
signTrade
(
$addr
,
$expire
=
'2h'
,
$txHex
)
{
$params
=
[
"addr"
=>
$addr
,
"addr"
=>
$addr
,
"expire"
=>
$expire
,
"txHex"
=>
$txHex
"txHex"
=>
$txHex
];
return
$this
->
send
(
$params
,
'Chain33.SignRawTx'
);
}
...
...
@@ -297,7 +301,7 @@ class Chain33Service
public
function
sendTrade
(
$data
)
{
$params
=
[
"data"
=>
$data
,
"data"
=>
$data
,
];
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
}
...
...
@@ -329,12 +333,12 @@ class Chain33Service
public
function
getTxByAddr
(
$addr
,
$flag
,
$count
,
$direction
,
$height
,
$index
)
{
$params
=
[
'addr'
=>
$addr
,
'flag'
=>
$flag
,
'count'
=>
$count
,
'addr'
=>
$addr
,
'flag'
=>
$flag
,
'count'
=>
$count
,
'direction'
=>
$direction
,
'height'
=>
$height
,
'index'
=>
$index
'height'
=>
$height
,
'index'
=>
$index
];
return
$this
->
send
(
$params
,
'Chain33.GetTxByAddr'
);
}
...
...
@@ -359,9 +363,9 @@ class Chain33Service
public
function
unLockWallet
(
$password
)
{
$params
=
[
'passwd'
=>
$password
,
'passwd'
=>
$password
,
'walletorticket'
=>
false
,
'timeout'
=>
30
'timeout'
=>
30
];
return
$this
->
send
(
$params
,
'Chain33.UnLock'
);
}
...
...
console/controllers/CrossChainController.php
View file @
bd210511
...
...
@@ -51,7 +51,6 @@ class CrossChainController extends Controller
'scheme'
=>
$transfer_url
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$transfer_url
[
1
]),
'port'
=>
isset
(
$transfer_url
[
2
])
?
$transfer_url
[
2
]
:
''
,
'timeout'
=>
100
];
$service
=
new
Chain33Service
(
$node_params
);
...
...
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