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
73794efe
Commit
73794efe
authored
Jun 09, 2016
by
Alex Beregszaszi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UDapp: use 'self' more consistently to avoid typos
parent
d4c56051
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
universal-dapp.js
src/universal-dapp.js
+21
-21
No files found.
src/universal-dapp.js
View file @
73794efe
...
@@ -149,12 +149,12 @@ UniversalDApp.prototype.getABIInputForm = function (cb) {
...
@@ -149,12 +149,12 @@ UniversalDApp.prototype.getABIInputForm = function (cb) {
UniversalDApp
.
prototype
.
getCreateInterface
=
function
(
$container
,
contract
)
{
UniversalDApp
.
prototype
.
getCreateInterface
=
function
(
$container
,
contract
)
{
var
self
=
this
;
var
self
=
this
;
var
$createInterface
=
$
(
'<div class="create"/>'
);
var
$createInterface
=
$
(
'<div class="create"/>'
);
if
(
this
.
options
.
removable
)
{
if
(
self
.
options
.
removable
)
{
var
$close
=
$
(
'<div class="udapp-close" />'
);
var
$close
=
$
(
'<div class="udapp-close" />'
);
$close
.
click
(
function
()
{
self
.
$el
.
remove
();
});
$close
.
click
(
function
()
{
self
.
$el
.
remove
();
});
$createInterface
.
append
(
$close
);
$createInterface
.
append
(
$close
);
}
}
var
$newButton
=
this
.
getInstanceInterface
(
contract
);
var
$newButton
=
self
.
getInstanceInterface
(
contract
);
var
$atButton
=
$
(
'<button class="atAddress"/>'
).
text
(
'At Address'
).
click
(
function
()
{
self
.
clickContractAt
(
self
,
$container
.
find
(
'.createContract'
),
contract
);
});
var
$atButton
=
$
(
'<button class="atAddress"/>'
).
text
(
'At Address'
).
click
(
function
()
{
self
.
clickContractAt
(
self
,
$container
.
find
(
'.createContract'
),
contract
);
});
$createInterface
.
append
(
$atButton
).
append
(
$newButton
);
$createInterface
.
append
(
$atButton
).
append
(
$newButton
);
return
$createInterface
;
return
$createInterface
;
...
@@ -175,7 +175,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
...
@@ -175,7 +175,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
return
1
;
return
1
;
}
}
});
});
var
funABI
=
this
.
getConstructorInterface
(
abi
);
var
funABI
=
self
.
getConstructorInterface
(
abi
);
var
$createInterface
=
$
(
'<div class="createContract"/>'
);
var
$createInterface
=
$
(
'<div class="createContract"/>'
);
var
appendFunctions
=
function
(
address
,
$el
)
{
var
appendFunctions
=
function
(
address
,
$el
)
{
...
@@ -281,7 +281,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
...
@@ -281,7 +281,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
};
};
if
(
!
address
||
!
$target
)
{
if
(
!
address
||
!
$target
)
{
$createInterface
.
append
(
this
.
getCallButton
({
$createInterface
.
append
(
self
.
getCallButton
({
abi
:
funABI
,
abi
:
funABI
,
encode
:
function
(
args
)
{
encode
:
function
(
args
)
{
var
types
=
[];
var
types
=
[];
...
@@ -512,7 +512,8 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -512,7 +512,8 @@ UniversalDApp.prototype.getCallButton = function (args) {
};
};
UniversalDApp
.
prototype
.
linkBytecode
=
function
(
contractName
,
cb
)
{
UniversalDApp
.
prototype
.
linkBytecode
=
function
(
contractName
,
cb
)
{
var
bytecode
=
this
.
getContractByName
(
contractName
).
bytecode
;
var
self
=
this
;
var
bytecode
=
self
.
getContractByName
(
contractName
).
bytecode
;
if
(
bytecode
.
indexOf
(
'_'
)
<
0
)
{
if
(
bytecode
.
indexOf
(
'_'
)
<
0
)
{
return
cb
(
null
,
bytecode
);
return
cb
(
null
,
bytecode
);
}
}
...
@@ -521,11 +522,10 @@ UniversalDApp.prototype.linkBytecode = function (contractName, cb) {
...
@@ -521,11 +522,10 @@ UniversalDApp.prototype.linkBytecode = function (contractName, cb) {
return
cb
(
'Invalid bytecode format.'
);
return
cb
(
'Invalid bytecode format.'
);
}
}
var
libraryName
=
m
[
1
];
var
libraryName
=
m
[
1
];
if
(
!
this
.
getContractByName
(
libraryName
))
{
if
(
!
self
.
getContractByName
(
libraryName
))
{
return
cb
(
'Library '
+
libraryName
+
' not found.'
);
return
cb
(
'Library '
+
libraryName
+
' not found.'
);
}
}
var
self
=
this
;
self
.
deployLibrary
(
libraryName
,
function
(
err
,
address
)
{
this
.
deployLibrary
(
libraryName
,
function
(
err
,
address
)
{
if
(
err
)
{
if
(
err
)
{
return
cb
(
err
);
return
cb
(
err
);
}
}
...
@@ -544,18 +544,18 @@ UniversalDApp.prototype.linkBytecode = function (contractName, cb) {
...
@@ -544,18 +544,18 @@ UniversalDApp.prototype.linkBytecode = function (contractName, cb) {
};
};
UniversalDApp
.
prototype
.
deployLibrary
=
function
(
contractName
,
cb
)
{
UniversalDApp
.
prototype
.
deployLibrary
=
function
(
contractName
,
cb
)
{
if
(
this
.
getContractByName
(
contractName
).
address
)
{
return
cb
(
null
,
this
.
getContractByName
(
contractName
).
address
);
}
var
self
=
this
;
var
self
=
this
;
var
bytecode
=
this
.
getContractByName
(
contractName
).
bytecode
;
if
(
self
.
getContractByName
(
contractName
).
address
)
{
return
cb
(
null
,
self
.
getContractByName
(
contractName
).
address
);
}
var
bytecode
=
self
.
getContractByName
(
contractName
).
bytecode
;
if
(
bytecode
.
indexOf
(
'_'
)
>=
0
)
{
if
(
bytecode
.
indexOf
(
'_'
)
>=
0
)
{
this
.
linkBytecode
(
contractName
,
function
(
err
,
bytecode
)
{
self
.
linkBytecode
(
contractName
,
function
(
err
,
bytecode
)
{
if
(
err
)
cb
(
err
);
if
(
err
)
cb
(
err
);
else
self
.
deployLibrary
(
contractName
,
cb
);
else
self
.
deployLibrary
(
contractName
,
cb
);
});
});
}
else
{
}
else
{
this
.
runTx
(
bytecode
,
{
abi
:
{
constant
:
false
},
bytecode
:
bytecode
},
function
(
err
,
result
)
{
self
.
runTx
(
bytecode
,
{
abi
:
{
constant
:
false
},
bytecode
:
bytecode
},
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
return
cb
(
err
);
return
cb
(
err
);
}
}
...
@@ -603,18 +603,18 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
...
@@ -603,18 +603,18 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
}
}
var
tx
;
var
tx
;
if
(
!
this
.
vm
)
{
if
(
!
self
.
vm
)
{
tx
=
{
tx
=
{
from
:
self
.
options
.
getAddress
?
self
.
options
.
getAddress
()
:
this
.
web3
.
eth
.
accounts
[
0
],
from
:
self
.
options
.
getAddress
?
self
.
options
.
getAddress
()
:
self
.
web3
.
eth
.
accounts
[
0
],
to
:
to
,
to
:
to
,
data
:
data
,
data
:
data
,
gas
:
gas
,
gas
:
gas
,
value
:
value
value
:
value
};
};
if
(
constant
&&
!
isConstructor
)
{
if
(
constant
&&
!
isConstructor
)
{
this
.
web3
.
eth
.
call
(
tx
,
cb
);
self
.
web3
.
eth
.
call
(
tx
,
cb
);
}
else
{
}
else
{
this
.
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
resp
)
{
self
.
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
resp
)
{
if
(
err
)
{
if
(
err
)
{
return
cb
(
err
,
resp
);
return
cb
(
err
,
resp
);
}
}
...
@@ -632,8 +632,8 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
...
@@ -632,8 +632,8 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
}
}
}
else
{
}
else
{
try
{
try
{
var
address
=
this
.
options
.
getAddress
?
this
.
options
.
getAddress
()
:
this
.
getAccounts
()[
0
];
var
address
=
self
.
options
.
getAddress
?
self
.
options
.
getAddress
()
:
self
.
getAccounts
()[
0
];
var
account
=
this
.
accounts
[
address
];
var
account
=
self
.
accounts
[
address
];
tx
=
new
EthJSTX
({
tx
=
new
EthJSTX
({
nonce
:
new
Buffer
([
account
.
nonce
++
]),
// @todo count beyond 255
nonce
:
new
Buffer
([
account
.
nonce
++
]),
// @todo count beyond 255
gasPrice
:
1
,
gasPrice
:
1
,
...
@@ -651,7 +651,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
...
@@ -651,7 +651,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
transactions
:
[],
transactions
:
[],
uncleHeaders
:
[]
uncleHeaders
:
[]
});
});
this
.
vm
.
runTx
({
block
:
block
,
tx
:
tx
,
skipBalance
:
true
,
skipNonce
:
true
},
cb
);
self
.
vm
.
runTx
({
block
:
block
,
tx
:
tx
,
skipBalance
:
true
,
skipNonce
:
true
},
cb
);
}
catch
(
e
)
{
}
catch
(
e
)
{
cb
(
e
,
null
);
cb
(
e
,
null
);
}
}
...
...
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