@alephium/web3 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -716,7 +716,7 @@ function addStdIdToFields(contract, fields) {
716
716
  exports.addStdIdToFields = addStdIdToFields;
717
717
  function calcWrapperContractId(parentContractId, mapIndex, key, keyType, group) {
718
718
  const prefix = ralph.encodeMapPrefix(mapIndex);
719
- const encodedKey = ralph.primitiveToByteVec(key, keyType);
719
+ const encodedKey = ralph.encodeMapKey(key, keyType);
720
720
  const path = (0, utils_1.binToHex)(prefix) + (0, utils_1.binToHex)(encodedKey);
721
721
  return (0, address_1.subContractId)(parentContractId, path, group);
722
722
  }
@@ -59,7 +59,7 @@ export declare function tryDecodeMapDebugLog(message: string): {
59
59
  isInsert: boolean;
60
60
  } | undefined;
61
61
  export declare function decodePrimitive(value: Uint8Array, type: string): Val;
62
- export declare function primitiveToByteVec(value: Val, type: string): Uint8Array;
62
+ export declare function encodeMapKey(value: Val, type: string): Uint8Array;
63
63
  export declare function typeLength(typ: string, structs: Struct[]): number;
64
64
  export declare function flattenFields(fields: Fields, names: string[], types: string[], isMutable: boolean[], structs: Struct[]): {
65
65
  name: string;
@@ -18,7 +18,7 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  var _a;
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.buildDebugBytecode = exports.encodeContractField = exports.buildContractByteCode = exports.encodeContractFields = exports.buildScriptByteCode = exports.flattenFields = exports.typeLength = exports.primitiveToByteVec = exports.decodePrimitive = exports.tryDecodeMapDebugLog = exports.calcFieldSize = exports.encodeMapPrefix = exports.parseMapType = exports.splitFields = exports.encodeScriptField = exports.encodeScriptFieldAsString = exports.encodePrimitiveValues = exports.addressVal = exports.byteVecVal = exports.u256Val = exports.i256Val = exports.boolVal = exports.encodeVmAddress = exports.encodeVmByteVec = exports.encodeVmU256 = exports.encodeVmI256 = exports.encodeVmBool = exports.VmValType = exports.encodeAddress = exports.encodeByteVec = exports.encodeU256 = exports.encodeI256 = exports.decodeBool = exports.encodeBool = void 0;
21
+ exports.buildDebugBytecode = exports.encodeContractField = exports.buildContractByteCode = exports.encodeContractFields = exports.buildScriptByteCode = exports.flattenFields = exports.typeLength = exports.encodeMapKey = exports.decodePrimitive = exports.tryDecodeMapDebugLog = exports.calcFieldSize = exports.encodeMapPrefix = exports.parseMapType = exports.splitFields = exports.encodeScriptField = exports.encodeScriptFieldAsString = exports.encodePrimitiveValues = exports.addressVal = exports.byteVecVal = exports.u256Val = exports.i256Val = exports.boolVal = exports.encodeVmAddress = exports.encodeVmByteVec = exports.encodeVmU256 = exports.encodeVmI256 = exports.encodeVmBool = exports.VmValType = exports.encodeAddress = exports.encodeByteVec = exports.encodeU256 = exports.encodeI256 = exports.decodeBool = exports.encodeBool = void 0;
22
22
  const api_1 = require("../api");
23
23
  const utils_1 = require("../utils");
24
24
  const codec_1 = require("../codec");
@@ -380,7 +380,7 @@ function decodePrimitive(value, type) {
380
380
  }
381
381
  }
382
382
  exports.decodePrimitive = decodePrimitive;
383
- function primitiveToByteVec(value, type) {
383
+ function encodeMapKey(value, type) {
384
384
  switch (type) {
385
385
  case 'Bool':
386
386
  const byte = (0, api_1.toApiBoolean)(value) ? 1 : 0;
@@ -393,7 +393,7 @@ function primitiveToByteVec(value, type) {
393
393
  return encodeU256(BigInt(u256));
394
394
  case 'ByteVec':
395
395
  const hexStr = (0, api_1.toApiByteVec)(value);
396
- return encodeByteVec(hexStr);
396
+ return (0, utils_1.hexToBinUnsafe)(hexStr);
397
397
  case 'Address':
398
398
  const address = (0, api_1.toApiAddress)(value);
399
399
  return encodeAddress(address);
@@ -401,7 +401,7 @@ function primitiveToByteVec(value, type) {
401
401
  throw Error(`Expected primitive type, got ${type}`);
402
402
  }
403
403
  }
404
- exports.primitiveToByteVec = primitiveToByteVec;
404
+ exports.encodeMapKey = encodeMapKey;
405
405
  function typeLength(typ, structs) {
406
406
  if (api_1.PrimitiveTypes.includes(typ)) {
407
407
  return 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A JS/TS library to interact with the Alephium platform",
5
5
  "license": "GPL",
6
6
  "main": "dist/src/index.js",
@@ -1177,7 +1177,7 @@ function calcWrapperContractId(
1177
1177
  group: number
1178
1178
  ): string {
1179
1179
  const prefix = ralph.encodeMapPrefix(mapIndex)
1180
- const encodedKey = ralph.primitiveToByteVec(key, keyType)
1180
+ const encodedKey = ralph.encodeMapKey(key, keyType)
1181
1181
  const path = binToHex(prefix) + binToHex(encodedKey)
1182
1182
  return subContractId(parentContractId, path, group)
1183
1183
  }
@@ -389,7 +389,7 @@ export function decodePrimitive(value: Uint8Array, type: string): Val {
389
389
  }
390
390
  }
391
391
 
392
- export function primitiveToByteVec(value: Val, type: string): Uint8Array {
392
+ export function encodeMapKey(value: Val, type: string): Uint8Array {
393
393
  switch (type) {
394
394
  case 'Bool':
395
395
  const byte = toApiBoolean(value) ? 1 : 0
@@ -402,7 +402,7 @@ export function primitiveToByteVec(value: Val, type: string): Uint8Array {
402
402
  return encodeU256(BigInt(u256))
403
403
  case 'ByteVec':
404
404
  const hexStr = toApiByteVec(value)
405
- return encodeByteVec(hexStr)
405
+ return hexToBinUnsafe(hexStr)
406
406
  case 'Address':
407
407
  const address = toApiAddress(value)
408
408
  return encodeAddress(address)