@alephium/web3 1.0.2 → 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.
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/contract/contract.js +1 -1
- package/dist/src/contract/ralph.d.ts +1 -1
- package/dist/src/contract/ralph.js +4 -4
- package/package.json +1 -1
- package/src/contract/contract.ts +1 -1
- package/src/contract/ralph.ts +2 -2
|
@@ -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.
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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
package/src/contract/contract.ts
CHANGED
|
@@ -1177,7 +1177,7 @@ function calcWrapperContractId(
|
|
|
1177
1177
|
group: number
|
|
1178
1178
|
): string {
|
|
1179
1179
|
const prefix = ralph.encodeMapPrefix(mapIndex)
|
|
1180
|
-
const encodedKey = ralph.
|
|
1180
|
+
const encodedKey = ralph.encodeMapKey(key, keyType)
|
|
1181
1181
|
const path = binToHex(prefix) + binToHex(encodedKey)
|
|
1182
1182
|
return subContractId(parentContractId, path, group)
|
|
1183
1183
|
}
|
package/src/contract/ralph.ts
CHANGED
|
@@ -389,7 +389,7 @@ export function decodePrimitive(value: Uint8Array, type: string): Val {
|
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
export function
|
|
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
|
|
405
|
+
return hexToBinUnsafe(hexStr)
|
|
406
406
|
case 'Address':
|
|
407
407
|
const address = toApiAddress(value)
|
|
408
408
|
return encodeAddress(address)
|