Skip to content

Commit d30684f

Browse files
authored
Merge pull request #132 from tronprotocol/develop
Develop
2 parents 5e5cb5a + 1b7bbcb commit d30684f

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ In order to contribute you can
168168

169169
## Recent History
170170

171+
__3.2.3__
172+
- Support triggerSmartContract function with empty character functionSelector and empty array parameters
173+
- The triggerSmartContract function Support for anonymous contract parameter incoming
174+
171175
__3.2.2__
172176
- Set feeLimit default value as 40 TRX
173177
- The `createToken` method supports 0 in its precision

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tronweb",
3-
"version": "3.2.2",
3+
"version": "3.2.3",
44
"description": "JavaScript SDK that encapsulates the TRON HTTP API",
55
"main": "dist/TronWeb.node.js",
66
"scripts": {

src/lib/transactionBuilder.js

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -811,58 +811,60 @@ export default class TransactionBuilder {
811811
value: tokenId,
812812
gte: 0,
813813
optional: true
814-
},
815-
{
816-
name: 'function selector',
817-
type: 'not-empty-string',
818-
value: functionSelector
819814
}
820815
], callback))
821816
return;
822817

823-
functionSelector = functionSelector.replace('/\s*/g', '');
818+
const args = {
819+
contract_address: toHex(contractAddress),
820+
owner_address: toHex(issuerAddress)
821+
};
824822

825-
if (parameters.length) {
826-
const abiCoder = new AbiCoder();
827-
let types = [];
828-
const values = [];
823+
if (functionSelector && utils.isString(functionSelector)) {
824+
functionSelector = functionSelector.replace('/\s*/g', '');
825+
if (parameters.length) {
826+
const abiCoder = new AbiCoder();
827+
let types = [];
828+
const values = [];
829829

830-
for (let i = 0; i < parameters.length; i++) {
831-
let {type, value} = parameters[i];
830+
for (let i = 0; i < parameters.length; i++) {
831+
let {type, value} = parameters[i];
832832

833-
if (!type || !utils.isString(type) || !type.length)
834-
return callback('Invalid parameter type provided: ' + type);
833+
if (!type || !utils.isString(type) || !type.length)
834+
return callback('Invalid parameter type provided: ' + type);
835835

836-
if (type == 'address')
837-
value = toHex(value).replace(ADDRESS_PREFIX_REGEX, '0x');
838-
else if (type == 'address[]')
839-
value = value.map(v => toHex(v).replace(ADDRESS_PREFIX_REGEX, '0x'));
836+
if (type == 'address')
837+
value = toHex(value).replace(ADDRESS_PREFIX_REGEX, '0x');
838+
else if (type == 'address[]')
839+
value = value.map(v => toHex(v).replace(ADDRESS_PREFIX_REGEX, '0x'));
840840

841-
types.push(type);
842-
values.push(value);
843-
}
841+
types.push(type);
842+
values.push(value);
843+
}
844844

845-
try {
846-
// workaround for unsupported trcToken type
847-
types = types.map(type => {
848-
if (/trcToken/.test(type)) {
849-
type = type.replace(/trcToken/, 'uint256')
850-
}
851-
return type
852-
})
845+
try {
846+
// workaround for unsupported trcToken type
847+
types = types.map(type => {
848+
if (/trcToken/.test(type)) {
849+
type = type.replace(/trcToken/, 'uint256')
850+
}
851+
return type
852+
})
853+
854+
parameters = abiCoder.encode(types, values).replace(/^(0x)/, '');
855+
} catch (ex) {
856+
return callback(ex);
857+
}
858+
} else parameters = '';
853859

854-
parameters = abiCoder.encode(types, values).replace(/^(0x)/, '');
855-
} catch (ex) {
856-
return callback(ex);
860+
if(options.shieldedParameter){
861+
parameters = options.shieldedParameter.replace(/^(0x)/, '');
857862
}
858-
} else parameters = '';
859863

860-
const args = {
861-
contract_address: toHex(contractAddress),
862-
owner_address: toHex(issuerAddress),
863-
function_selector: functionSelector,
864-
parameter: parameters
865-
};
864+
args.function_selector = functionSelector;
865+
args.parameter = parameters;
866+
}
867+
866868

867869
if (!options._isConstant) {
868870
args.call_value = parseInt(callValue)

0 commit comments

Comments
 (0)