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
...
@@ -20,7 +20,7 @@ class Chain33Service
public
function
__construct
(
$parameter
=
[])
public
function
__construct
(
$parameter
=
[])
{
{
if
(
empty
(
$parameter
))
{
if
(
empty
(
$parameter
))
{
$this
->
node_params
=
Yii
::
$app
->
params
[
'chain33'
];
$this
->
node_params
=
Yii
::
$app
->
params
[
'chain33'
];
}
else
{
}
else
{
$this
->
node_params
=
$parameter
;
$this
->
node_params
=
$parameter
;
...
@@ -31,8 +31,8 @@ class Chain33Service
...
@@ -31,8 +31,8 @@ class Chain33Service
{
{
$config
=
$this
->
node_params
;
$config
=
$this
->
node_params
;
$scheme
=
$config
[
'scheme'
]
??
'http'
;
$scheme
=
$config
[
'scheme'
]
??
'http'
;
$host
=
$config
[
'host'
]
??
'127.0.0.1'
;
$host
=
$config
[
'host'
]
??
'127.0.0.1'
;
$port
=
(
string
)
$config
[
'port'
]
??
''
;
$port
=
(
string
)
$config
[
'port'
]
??
''
;
if
(
$port
)
{
if
(
$port
)
{
return
$scheme
.
'://'
.
$host
.
':'
.
$port
;
return
$scheme
.
'://'
.
$host
.
':'
.
$port
;
}
else
{
}
else
{
...
@@ -44,9 +44,9 @@ class Chain33Service
...
@@ -44,9 +44,9 @@ class Chain33Service
{
{
$data
=
[
$data
=
[
'jsonrpc'
=>
'2.0'
,
'jsonrpc'
=>
'2.0'
,
'id'
=>
0
,
'id'
=>
0
,
'method'
=>
$method
,
'method'
=>
$method
,
'params'
=>
[],
'params'
=>
[],
];
];
if
(
!
empty
(
$params
))
{
if
(
!
empty
(
$params
))
{
$data
[
'params'
][]
=
$params
;
$data
[
'params'
][]
=
$params
;
...
@@ -56,7 +56,11 @@ class Chain33Service
...
@@ -56,7 +56,11 @@ class Chain33Service
public
function
send
(
$params
=
[],
$method
=
'Chain33.Query'
)
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
);
$jsonrpc
=
self
::
jsonRpcBuild
(
$params
,
$method
);
$ch
->
setHeader
(
'Content-Type'
,
'application/json'
);
$ch
->
setHeader
(
'Content-Type'
,
'application/json'
);
$ch
->
setRawPostData
(
$jsonrpc
);
$ch
->
setRawPostData
(
$jsonrpc
);
...
@@ -124,7 +128,7 @@ class Chain33Service
...
@@ -124,7 +128,7 @@ class Chain33Service
* 获取地址下的所有token资产
* 获取地址下的所有token资产
*
*
* @param string|array $address
* @param string|array $address
* @param string
$symbol
* @param string $symbol
* @return array
* @return array
*/
*/
public
function
getAccountTokenAssets
(
$address
,
$symbol
)
public
function
getAccountTokenAssets
(
$address
,
$symbol
)
...
@@ -133,8 +137,8 @@ class Chain33Service
...
@@ -133,8 +137,8 @@ class Chain33Service
$address
=
[
$address
];
$address
=
[
$address
];
}
}
$params
=
[
$params
=
[
"addresses"
=>
$address
,
"addresses"
=>
$address
,
"execer"
=>
"user.p.guodun.token"
,
"execer"
=>
"user.p.guodun.token"
,
"tokenSymbol"
=>
$symbol
"tokenSymbol"
=>
$symbol
];
];
return
$this
->
send
(
$params
,
'token.GetTokenBalance'
);
return
$this
->
send
(
$params
,
'token.GetTokenBalance'
);
...
@@ -147,18 +151,18 @@ class Chain33Service
...
@@ -147,18 +151,18 @@ class Chain33Service
* @param $to
* @param $to
* @param $amount
* @param $amount
* @param string $note
* @param string $note
* @param bool
$isToken
* @param bool $isToken
* @param string $tokenSymbol
* @param string $tokenSymbol
* @return array
* @return array
*/
*/
public
function
extractToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
public
function
extractToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
{
{
$params
=
[
$params
=
[
"from"
=>
$to
,
"from"
=>
$to
,
"to"
=>
$from
,
"to"
=>
$from
,
"amount"
=>
-
$amount
,
"amount"
=>
-
$amount
,
"note"
=>
$note
,
"note"
=>
$note
,
"isToken"
=>
$isToken
?
true
:
false
,
"isToken"
=>
$isToken
?
true
:
false
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
];
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
...
@@ -171,18 +175,18 @@ class Chain33Service
...
@@ -171,18 +175,18 @@ class Chain33Service
* @param $to
* @param $to
* @param $amount
* @param $amount
* @param string $note
* @param string $note
* @param bool
$isToken
* @param bool $isToken
* @param string $tokenSymbol
* @param string $tokenSymbol
* @return array
* @return array
*/
*/
public
function
transToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
public
function
transToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
{
{
$params
=
[
$params
=
[
"from"
=>
$from
,
"from"
=>
$from
,
"to"
=>
$to
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"note"
=>
$note
,
"note"
=>
$note
,
"isToken"
=>
$isToken
?
true
:
false
,
"isToken"
=>
$isToken
?
true
:
false
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
];
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
...
@@ -191,25 +195,25 @@ class Chain33Service
...
@@ -191,25 +195,25 @@ class Chain33Service
public
function
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
)
public
function
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
)
{
{
$params
=
[
$params
=
[
"to"
=>
$to
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"isToken"
=>
$isToken
,
"isToken"
=>
$isToken
,
"tokenSymbol"
=>
$tokenSymbol
,
"tokenSymbol"
=>
$tokenSymbol
,
"fee"
=>
$fee
,
"fee"
=>
$fee
,
"note"
=>
$note
,
"note"
=>
$note
,
"execer"
=>
$execer
,
"execer"
=>
$execer
,
];
];
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
}
}
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
{
{
$params
=
[
$params
=
[
"to"
=>
$to
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"fee"
=>
$fee
,
"fee"
=>
$fee
,
"note"
=>
$note
,
"note"
=>
$note
,
"execer"
=>
$execer
,
"execer"
=>
$execer
,
];
];
...
@@ -274,11 +278,11 @@ class Chain33Service
...
@@ -274,11 +278,11 @@ class Chain33Service
public
function
structureTrade
(
$amount
,
$execName
,
$fee
,
$isToken
=
True
,
$to
,
$tokenSymbol
=
''
)
public
function
structureTrade
(
$amount
,
$execName
,
$fee
,
$isToken
=
True
,
$to
,
$tokenSymbol
=
''
)
{
{
$params
=
[
$params
=
[
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"execName"
=>
$execName
,
"execName"
=>
$execName
,
"fee"
=>
$fee
,
"fee"
=>
$fee
,
"isToken"
=>
$isToken
?
true
:
false
,
"isToken"
=>
$isToken
?
true
:
false
,
"to"
=>
$to
,
"to"
=>
$to
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
];
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
...
@@ -287,9 +291,9 @@ class Chain33Service
...
@@ -287,9 +291,9 @@ class Chain33Service
public
function
signTrade
(
$addr
,
$expire
=
'2h'
,
$txHex
)
public
function
signTrade
(
$addr
,
$expire
=
'2h'
,
$txHex
)
{
{
$params
=
[
$params
=
[
"addr"
=>
$addr
,
"addr"
=>
$addr
,
"expire"
=>
$expire
,
"expire"
=>
$expire
,
"txHex"
=>
$txHex
"txHex"
=>
$txHex
];
];
return
$this
->
send
(
$params
,
'Chain33.SignRawTx'
);
return
$this
->
send
(
$params
,
'Chain33.SignRawTx'
);
}
}
...
@@ -297,7 +301,7 @@ class Chain33Service
...
@@ -297,7 +301,7 @@ class Chain33Service
public
function
sendTrade
(
$data
)
public
function
sendTrade
(
$data
)
{
{
$params
=
[
$params
=
[
"data"
=>
$data
,
"data"
=>
$data
,
];
];
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
}
}
...
@@ -329,12 +333,12 @@ class Chain33Service
...
@@ -329,12 +333,12 @@ class Chain33Service
public
function
getTxByAddr
(
$addr
,
$flag
,
$count
,
$direction
,
$height
,
$index
)
public
function
getTxByAddr
(
$addr
,
$flag
,
$count
,
$direction
,
$height
,
$index
)
{
{
$params
=
[
$params
=
[
'addr'
=>
$addr
,
'addr'
=>
$addr
,
'flag'
=>
$flag
,
'flag'
=>
$flag
,
'count'
=>
$count
,
'count'
=>
$count
,
'direction'
=>
$direction
,
'direction'
=>
$direction
,
'height'
=>
$height
,
'height'
=>
$height
,
'index'
=>
$index
'index'
=>
$index
];
];
return
$this
->
send
(
$params
,
'Chain33.GetTxByAddr'
);
return
$this
->
send
(
$params
,
'Chain33.GetTxByAddr'
);
}
}
...
@@ -359,9 +363,9 @@ class Chain33Service
...
@@ -359,9 +363,9 @@ class Chain33Service
public
function
unLockWallet
(
$password
)
public
function
unLockWallet
(
$password
)
{
{
$params
=
[
$params
=
[
'passwd'
=>
$password
,
'passwd'
=>
$password
,
'walletorticket'
=>
false
,
'walletorticket'
=>
false
,
'timeout'
=>
30
'timeout'
=>
30
];
];
return
$this
->
send
(
$params
,
'Chain33.UnLock'
);
return
$this
->
send
(
$params
,
'Chain33.UnLock'
);
}
}
...
...
console/controllers/CrossChainController.php
View file @
bd210511
...
@@ -51,7 +51,6 @@ class CrossChainController extends Controller
...
@@ -51,7 +51,6 @@ class CrossChainController extends Controller
'scheme'
=>
$transfer_url
[
0
],
'scheme'
=>
$transfer_url
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$transfer_url
[
1
]),
'host'
=>
str_replace
(
'//'
,
''
,
$transfer_url
[
1
]),
'port'
=>
isset
(
$transfer_url
[
2
])
?
$transfer_url
[
2
]
:
''
,
'port'
=>
isset
(
$transfer_url
[
2
])
?
$transfer_url
[
2
]
:
''
,
'timeout'
=>
100
];
];
$service
=
new
Chain33Service
(
$node_params
);
$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