Comparing version 13.0.1 to 13.1.0
@@ -119,2 +119,6 @@ 'use strict'; | ||
}, null, this); | ||
}; | ||
AssetCache.pending = function () { | ||
return promises.length !== 0; | ||
}; |
@@ -319,4 +319,4 @@ 'use strict'; | ||
var symbolMatch = str.match(/([A-Z]+)(@|$)/); | ||
var symbol = symbolMatch ? symbolMatch[1] : null; | ||
var symbolMatch = str.match(/(^| |,)([A-Z]+)(@|$)/); | ||
var symbol = symbolMatch ? symbolMatch[2] : null; | ||
@@ -327,3 +327,3 @@ var _str$split3 = str.split('@'), | ||
var contract = /[a-z0-5]+(\.[a-z0-5]+])?$/.test(contractRaw) ? contractRaw : null; | ||
var contract = /^[a-z0-5]+(\.[a-z0-5]+)*$/.test(contractRaw) ? contractRaw : null; | ||
@@ -330,0 +330,0 @@ var join = function join(e1, e2) { |
@@ -241,3 +241,3 @@ 'use strict'; | ||
it('parseExtendedAsset', function () { | ||
var parseExtendedAssets = [['SYM', null, null, 'SYM', null], ['SYM@contract', null, null, 'SYM', 'contract'], ['4,SYM', null, 4, 'SYM', null], ['4,SYM@contract', null, 4, 'SYM', 'contract'], ['1 SYM', '1', null, 'SYM', null], ['1.0 SYM', '1.0', null, 'SYM', null], ['1.0 4,SYM@contract', '1.0', 4, 'SYM', 'contract'], ['1.0 4,SYM', '1.0', 4, 'SYM', null]]; | ||
var parseExtendedAssets = [['SYM', null, null, 'SYM', null], ['SYM@contract', null, null, 'SYM', 'contract'], ['4,SYM', null, 4, 'SYM', null], ['4,SYM@contract', null, 4, 'SYM', 'contract'], ['1 SYM', '1', null, 'SYM', null], ['1.0 SYM', '1.0', null, 'SYM', null], ['1.0 4,SYM@contract', '1.0', 4, 'SYM', 'contract'], ['1.0 4,SYM@tract.token', '1.0', 4, 'SYM', 'tract.token'], ['1.0 4,SYM@tr.act.token', '1.0', 4, 'SYM', 'tr.act.token'], ['1.0 4,SYM', '1.0', 4, 'SYM', null]]; | ||
var _iteratorNormalCompletion7 = true; | ||
@@ -244,0 +244,0 @@ var _didIteratorError7 = false; |
@@ -312,2 +312,26 @@ 'use strict'; | ||
it('create asset', function _callee5() { | ||
var eos, pubkey, auth; | ||
return regeneratorRuntime.async(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
eos = Eos.Localnet({ signProvider: signProvider }); | ||
pubkey = 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV'; | ||
auth = { authorization: 'eosio.token' }; | ||
_context5.next = 5; | ||
return regeneratorRuntime.awrap(eos.create('eosio.token', '10000 ' + randomAsset(), auth)); | ||
case 5: | ||
_context5.next = 7; | ||
return regeneratorRuntime.awrap(eos.create('eosio.token', '10000.00 ' + randomAsset(), auth)); | ||
case 7: | ||
case 'end': | ||
return _context5.stop(); | ||
} | ||
} | ||
}, null, this); | ||
}); | ||
it('newaccount (broadcast)', function () { | ||
@@ -333,4 +357,4 @@ var eos = Eos.Localnet({ signProvider: signProvider }); | ||
receiver: name, | ||
stake_net_quantity: '100.0000 SYS', | ||
stake_cpu_quantity: '100.0000 SYS', | ||
stake_net_quantity: '1.0000 SYS', | ||
stake_cpu_quantity: '1.0000 SYS', | ||
transfer: 0 | ||
@@ -424,7 +448,7 @@ }); | ||
it('action to contract atomic', function _callee5() { | ||
it('action to contract atomic', function _callee6() { | ||
var amt, eos, trTest, assertTr; | ||
return regeneratorRuntime.async(function _callee5$(_context5) { | ||
return regeneratorRuntime.async(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
@@ -447,5 +471,5 @@ amt = 1; // for unique transactions | ||
_context5.t0 = regeneratorRuntime; | ||
_context5.t1 = assertTr; | ||
_context5.next = 8; | ||
_context6.t0 = regeneratorRuntime; | ||
_context6.t1 = assertTr; | ||
_context6.next = 8; | ||
return regeneratorRuntime.awrap(eos.transaction(['eosio.token'], function (_ref6) { | ||
@@ -457,11 +481,11 @@ var eosio_token = _ref6.eosio_token; | ||
case 8: | ||
_context5.t2 = _context5.sent; | ||
_context5.t3 = (0, _context5.t1)(_context5.t2); | ||
_context5.next = 12; | ||
return _context5.t0.awrap.call(_context5.t0, _context5.t3); | ||
_context6.t2 = _context6.sent; | ||
_context6.t3 = (0, _context6.t1)(_context6.t2); | ||
_context6.next = 12; | ||
return _context6.t0.awrap.call(_context6.t0, _context6.t3); | ||
case 12: | ||
_context5.t4 = regeneratorRuntime; | ||
_context5.t5 = assertTr; | ||
_context5.next = 16; | ||
_context6.t4 = regeneratorRuntime; | ||
_context6.t5 = assertTr; | ||
_context6.next = 16; | ||
return regeneratorRuntime.awrap(eos.transaction('eosio.token', function (eosio_token) { | ||
@@ -472,10 +496,10 @@ return trTest(eosio_token); | ||
case 16: | ||
_context5.t6 = _context5.sent; | ||
_context5.t7 = (0, _context5.t5)(_context5.t6); | ||
_context5.next = 20; | ||
return _context5.t4.awrap.call(_context5.t4, _context5.t7); | ||
_context6.t6 = _context6.sent; | ||
_context6.t7 = (0, _context6.t5)(_context6.t6); | ||
_context6.next = 20; | ||
return _context6.t4.awrap.call(_context6.t4, _context6.t7); | ||
case 20: | ||
case 'end': | ||
return _context5.stop(); | ||
return _context6.stop(); | ||
} | ||
@@ -564,10 +588,10 @@ } | ||
// ./eosioc set contract currency build/contracts/currency/currency.wasm build/contracts/currency/currency.abi | ||
it('Transaction ABI lookup', function _callee6() { | ||
it('Transaction ABI lookup', function _callee7() { | ||
var eos, tx; | ||
return regeneratorRuntime.async(function _callee6$(_context6) { | ||
return regeneratorRuntime.async(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
eos = Eos.Localnet(); | ||
_context6.next = 3; | ||
_context7.next = 3; | ||
return regeneratorRuntime.awrap(eos.transaction({ | ||
@@ -591,3 +615,3 @@ actions: [{ | ||
case 3: | ||
tx = _context6.sent; | ||
tx = _context7.sent; | ||
@@ -598,3 +622,3 @@ assert.equal(tx.transaction.transaction.actions[0].account, 'currency'); | ||
case 'end': | ||
return _context6.stop(); | ||
return _context7.stop(); | ||
} | ||
@@ -609,2 +633,6 @@ } | ||
return 'a' + name + '111222333444'.substring(0, 11 - name.length); // always 12 in length | ||
}; | ||
var randomAsset = function randomAsset() { | ||
return ecc.sha256(String(Math.random())).toUpperCase().replace(/[^A-Z]/g, '').substring(0, 7); | ||
}; |
@@ -243,9 +243,6 @@ 'use strict'; | ||
/** Current action within a transaction. */ | ||
var currentAccount = void 0; | ||
/** @private */ | ||
function precisionCache(assetCache, value) { | ||
var symbolInfo = parseExtendedAsset(value); | ||
var contract = symbolInfo.contract || currentAccount; | ||
var contract = symbolInfo.contract || 'eosio.token'; | ||
@@ -346,3 +343,3 @@ var precision = void 0; | ||
assert(precision != null, 'Precision unknown for asset: ' + symbol + '@' + currentAccount); | ||
assert(precision != null, 'Precision unknown for asset: ' + symbol + '@eosio.token'); | ||
var pad = '\0'.repeat(7 - symbol.length); | ||
@@ -429,7 +426,7 @@ b.append(String.fromCharCode(precision) + symbol + pad); | ||
if (format === 'plain') { | ||
if (format === 'plain_asset') { | ||
return UDecimalPad(amount, precision) + ' ' + symbol; | ||
} | ||
if (format === 'extended') { | ||
if (format === 'extended_asset') { | ||
var contractSuffix = contract ? '@' + contract : ''; | ||
@@ -439,10 +436,17 @@ return UDecimalPad(amount, precision) + ' ' + symbol + contractSuffix; | ||
if (format === 'full') { | ||
var _contractSuffix = contract ? '@' + contract : ''; | ||
if (format === 'full_asset') { | ||
var precisionPrefix = precision != null ? precision + ',' : ''; | ||
var full = UDecimalPad(amount, precision) + ' ' + precisionPrefix + symbol + _contractSuffix; | ||
// console.log('full', full) | ||
var full = UDecimalPad(amount, precision) + ' ' + precisionPrefix + symbol; | ||
// console.log('full_asset', full) | ||
return full; | ||
} | ||
if (format === 'full_extended_asset') { | ||
var _contractSuffix = contract ? '@' + contract : ''; | ||
var _precisionPrefix = precision != null ? precision + ',' : ''; | ||
var _full = UDecimalPad(amount, precision) + ' ' + _precisionPrefix + symbol + _contractSuffix; | ||
// console.log('full_extended_asset', full) | ||
return _full; | ||
} | ||
assert(false, 'format should be: plain, extended, or full'); | ||
@@ -469,3 +473,3 @@ } | ||
return toAssetString(UDecimalUnimply(amount, precision) + ' ' + precision + ',' + symbol, assetCache, 'full'); | ||
return toAssetString(UDecimalUnimply(amount, precision) + ' ' + precision + ',' + symbol, assetCache, 'full_asset'); | ||
}, | ||
@@ -478,4 +482,3 @@ appendByteBuffer: function appendByteBuffer(b, value) { | ||
precision = _precisionCache5.precision, | ||
symbol = _precisionCache5.symbol, | ||
contract = _precisionCache5.contract; | ||
symbol = _precisionCache5.symbol; | ||
@@ -487,3 +490,3 @@ assert(precision != null, 'Precision unknown for asset: ' + value); | ||
fromObject: function fromObject(value) { | ||
return toAssetString(value, assetCache, 'full'); | ||
return toAssetString(value, assetCache, 'full_asset'); | ||
}, | ||
@@ -494,3 +497,3 @@ toObject: function toObject(value) { | ||
} | ||
return toAssetString(value, assetCache, 'plain'); | ||
return toAssetString(value, assetCache, 'plain_asset'); | ||
} | ||
@@ -531,4 +534,3 @@ }; | ||
assert(/^\d+(\.\d+)* [A-Z]+@[a-z0-5]+(\.[a-z0-5]+)*$/.test(value), 'Invalid extended asset: ' + value); | ||
return toAssetString(value, assetCache, 'full'); | ||
return toAssetString(value, assetCache, 'full_extended_asset'); | ||
}, | ||
@@ -539,3 +541,3 @@ toObject: function toObject(value) { | ||
} | ||
return toAssetString(value, assetCache, 'extended'); | ||
return toAssetString(value, assetCache, 'extended_asset'); | ||
} | ||
@@ -652,19 +654,12 @@ }; | ||
currentAccount = object.account; | ||
try { | ||
var ser = (object.name || '') == '' ? fields.data : structLookup(object.name, object.account); | ||
if (ser) { | ||
b.readVarint32(); // length prefix (usefull if object.name is unknown) | ||
object.data = ser.fromByteBuffer(b, config); | ||
} else { | ||
// console.log(`Unknown Action.name ${object.name}`) | ||
var lenPrefix = b.readVarint32(); | ||
var bCopy = b.copy(b.offset, b.offset + lenPrefix); | ||
b.skip(lenPrefix); | ||
object.data = Buffer.from(bCopy.toBinary(), 'binary'); | ||
} | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
currentAccount = null; | ||
var ser = (object.name || '') == '' ? fields.data : structLookup(object.name, object.account); | ||
if (ser) { | ||
b.readVarint32(); // length prefix (usefull if object.name is unknown) | ||
object.data = ser.fromByteBuffer(b, config); | ||
} else { | ||
// console.log(`Unknown Action.name ${object.name}`) | ||
var lenPrefix = b.readVarint32(); | ||
var bCopy = b.copy(b.offset, b.offset + lenPrefix); | ||
b.skip(lenPrefix); | ||
object.data = Buffer.from(bCopy.toBinary(), 'binary'); | ||
} | ||
@@ -678,23 +673,16 @@ }, | ||
currentAccount = object.account; | ||
try { | ||
var ser = (object.name || '') == '' ? fields.data : structLookup(object.name, object.account); | ||
if (ser) { | ||
var b2 = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN); | ||
ser.appendByteBuffer(b2, object.data); | ||
b.writeVarint32(b2.offset); | ||
b.append(b2.copy(0, b2.offset), 'binary'); | ||
} else { | ||
// console.log(`Unknown Action.name ${object.name}`) | ||
var data = typeof object.data === 'string' ? new Buffer(object.data, 'hex') : object.data; | ||
if (!Buffer.isBuffer(data)) { | ||
throw new TypeError('Unknown struct \'' + object.name + '\' for contract \'' + object.account + '\', locate this struct or provide serialized action.data'); | ||
} | ||
b.writeVarint32(data.length); | ||
b.append(data.toString('binary'), 'binary'); | ||
var ser = (object.name || '') == '' ? fields.data : structLookup(object.name, object.account); | ||
if (ser) { | ||
var b2 = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN); | ||
ser.appendByteBuffer(b2, object.data); | ||
b.writeVarint32(b2.offset); | ||
b.append(b2.copy(0, b2.offset), 'binary'); | ||
} else { | ||
// console.log(`Unknown Action.name ${object.name}`) | ||
var data = typeof object.data === 'string' ? new Buffer(object.data, 'hex') : object.data; | ||
if (!Buffer.isBuffer(data)) { | ||
throw new TypeError('Unknown struct \'' + object.name + '\' for contract \'' + object.account + '\', locate this struct or provide serialized action.data'); | ||
} | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
currentAccount = null; | ||
b.writeVarint32(data.length); | ||
b.append(data.toString('binary'), 'binary'); | ||
} | ||
@@ -710,23 +698,15 @@ }, | ||
currentAccount = object.account; | ||
try { | ||
var ser = (name || '') == '' ? fields.data : structLookup(name, object.account); | ||
if (ser) { | ||
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') { | ||
result.data = ser.fromObject(data); // resolve shorthand | ||
} else if (typeof data === 'string') { | ||
var buf = new Buffer(data, 'hex'); | ||
result.data = Fcbuffer.fromBuffer(ser, buf); | ||
} else { | ||
throw new TypeError('Expecting hex string or object in action.data'); | ||
} | ||
var ser = (name || '') == '' ? fields.data : structLookup(name, object.account); | ||
if (ser) { | ||
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') { | ||
result.data = ser.fromObject(data); // resolve shorthand | ||
} else if (typeof data === 'string') { | ||
var buf = new Buffer(data, 'hex'); | ||
result.data = Fcbuffer.fromBuffer(ser, buf); | ||
} else { | ||
// console.log(`Unknown Action.name ${object.name}`) | ||
result.data = data; | ||
throw new TypeError('Expecting hex string or object in action.data'); | ||
} | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
currentAccount = null; | ||
} else { | ||
// console.log(`Unknown Action.name ${object.name}`) | ||
result.data = data; | ||
} | ||
@@ -745,31 +725,23 @@ }, | ||
currentAccount = object.account; | ||
var ser = (name || '') == '' ? fields.data : structLookup(name, object.account); | ||
if (!ser) { | ||
// Types without an ABI will accept hex | ||
result.data = Buffer.isBuffer(data) ? data.toString('hex') : data; | ||
return; | ||
} | ||
try { | ||
var ser = (name || '') == '' ? fields.data : structLookup(name, object.account); | ||
if (!ser) { | ||
// Types without an ABI will accept hex | ||
result.data = Buffer.isBuffer(data) ? data.toString('hex') : data; | ||
return; | ||
if (forceActionDataHex) { | ||
var b2 = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN); | ||
if (data) { | ||
ser.appendByteBuffer(b2, data); | ||
} | ||
result.data = b2.copy(0, b2.offset).toString('hex'); | ||
// console.log('result.data', result.data) | ||
return; | ||
} | ||
if (forceActionDataHex) { | ||
var b2 = new ByteBuffer(ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN); | ||
if (data) { | ||
ser.appendByteBuffer(b2, data); | ||
} | ||
result.data = b2.copy(0, b2.offset).toString('hex'); | ||
// console.log('result.data', result.data) | ||
return; | ||
} | ||
// Serializable JSON | ||
result.data = ser.toObject(data, config); | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
currentAccount = null; | ||
} | ||
// Serializable JSON | ||
result.data = ser.toObject(data, config); | ||
} | ||
}; | ||
}; |
@@ -608,12 +608,20 @@ 'use strict'; | ||
// Resolve shorthand, queue requests | ||
Transaction.fromObject(rawTx); | ||
txObject = Transaction.fromObject(rawTx); | ||
// After fromObject ensure any async actions are finished | ||
_context2.next = 9; | ||
if (!AssetCache.pending()) { | ||
_context2.next = 11; | ||
break; | ||
} | ||
_context2.next = 10; | ||
return regeneratorRuntime.awrap(AssetCache.resolve()); | ||
case 9: | ||
case 10: | ||
// Create the object again with resolved data | ||
txObject = Transaction.fromObject(rawTx); | ||
case 11: | ||
buf = Fcbuffer.toBuffer(Transaction, txObject); | ||
@@ -695,3 +703,3 @@ tr = Transaction.toObject(txObject); | ||
case 16: | ||
case 17: | ||
case 'end': | ||
@@ -698,0 +706,0 @@ return _context2.stop(); |
{ | ||
"name": "eosjs", | ||
"version": "13.0.1", | ||
"version": "13.1.0", | ||
"description": "General purpose library for the EOS blockchain.", | ||
@@ -49,3 +49,3 @@ "main": "lib/index.js", | ||
"create-hash": "^1.1.3", | ||
"eosjs-api": "6.1.0", | ||
"eosjs-api": "6.1.2", | ||
"eosjs-ecc": "4.0.1", | ||
@@ -52,0 +52,0 @@ "fcbuffer": "2.2.0" |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1363194
35780
0
+ Addedeosjs-api@6.1.2(transitive)
- Removedeosjs-api@6.1.0(transitive)
Updatedeosjs-api@6.1.2