Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@multiversx/sdk-core

Package Overview
Dependencies
Maintainers
9
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@multiversx/sdk-core - npm Package Compare versions

Comparing version 11.2.0 to 11.3.0

6

out/smartcontracts/typesystem/abiRegistry.d.ts

@@ -0,5 +1,5 @@

import { ContractInterface } from "./contractInterface";
import { EnumType } from "./enum";
import { StructType } from "./struct";
import { ContractInterface } from "./contractInterface";
import { CustomType } from "./types";
import { EnumType } from "./enum";
export declare class AbiRegistry {

@@ -15,3 +15,2 @@ readonly interfaces: ContractInterface[];

private createCustomType;
private sortCustomTypesByDependencies;
getInterface(name: string): ContractInterface;

@@ -34,2 +33,3 @@ getInterfaces(names: string[]): ContractInterface[];

remapToKnownTypes(): AbiRegistry;
private mapCustomTypeDepthFirst;
}

@@ -25,7 +25,7 @@ "use strict";

const utils_1 = require("../../utils");
const struct_1 = require("./struct");
const contractInterface_1 = require("./contractInterface");
const endpoint_1 = require("./endpoint");
const enum_1 = require("./enum");
const struct_1 = require("./struct");
const typeMapper_1 = require("./typeMapper");
const endpoint_1 = require("./endpoint");
class AbiRegistry {

@@ -54,3 +54,2 @@ constructor() {

}
this.sortCustomTypesByDependencies();
return this;

@@ -67,14 +66,2 @@ }

}
sortCustomTypesByDependencies() {
// TODO: Improve consistency of the sorting function (and make sure the sorting is stable): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
this.customTypes.sort((a, b) => {
const bDependsOnA = b.getNamesOfDependencies().indexOf(a.getName()) > -1;
if (bDependsOnA) {
// Sort "a" before "b".
return -1;
}
// Sort "b" before "a".
return 1;
});
}
getInterface(name) {

@@ -120,8 +107,9 @@ let result = this.interfaces.find((e) => e.name == name);

for (const type of this.customTypes) {
const mappedTyped = mapper.mapType(type);
newCustomTypes.push(mappedTyped);
this.mapCustomTypeDepthFirst(type, this.customTypes, mapper, newCustomTypes);
}
if (this.customTypes.length != newCustomTypes.length) {
throw new errors.ErrTypingSystem("Did not re-map all custom types");
}
// Then, remap types of all endpoint parameters.
// But we'll use an enhanced mapper, that takes into account the results from the previous step.
mapper = new typeMapper_1.TypeMapper(newCustomTypes);
// The mapper learned all necessary types in the previous step.
for (const iface of this.interfaces) {

@@ -141,2 +129,18 @@ let newEndpoints = [];

}
mapCustomTypeDepthFirst(typeToMap, allTypesToMap, mapper, mappedTypes) {
const hasBeenMapped = mappedTypes.findIndex(type => type.getName() == typeToMap.getName()) >= 0;
if (hasBeenMapped) {
return;
}
for (const typeName of typeToMap.getNamesOfDependencies()) {
const dependencyType = allTypesToMap.find(type => type.getName() == typeName);
if (!dependencyType) {
// It's a type that we don't have to map (e.g. could be a primitive type).
continue;
}
this.mapCustomTypeDepthFirst(dependencyType, allTypesToMap, mapper, mappedTypes);
}
const mappedType = mapper.mapType(typeToMap);
mappedTypes.push(mappedType);
}
}

@@ -143,0 +147,0 @@ exports.AbiRegistry = AbiRegistry;

@@ -7,4 +7,9 @@ import { CustomType, Type } from "./types";

constructor(learnedTypes?: CustomType[]);
/**
* Maps a "raw type" object to a "known (specific) type" object.
* In the process, it also learns the new type.
* Can only map types if their dependencies were previously learned (through mapping).
*/
mapType(type: Type): Type;
mapRecursiveType(type: Type): Type | null;
private mapTypeRecursively;
private learnType;

@@ -11,0 +16,0 @@ private mapStructType;

@@ -105,6 +105,14 @@ "use strict";

}
/**
* Maps a "raw type" object to a "known (specific) type" object.
* In the process, it also learns the new type.
* Can only map types if their dependencies were previously learned (through mapping).
*/
mapType(type) {
let mappedType = this.mapRecursiveType(type);
let mappedType = this.mapTypeRecursively(type);
if (mappedType) {
// We do not learn generic types (that also have type parameters)
// We do not learn generic types (that also have type parameters),
// we only learn closed, non-generic types.
// Reason: in the ABI, generic types are unnamed.
// E.g.: two occurrences of List<Foobar> aren't recognized as a single type (simplification).
if (!mappedType.isGenericType()) {

@@ -117,3 +125,3 @@ this.learnType(mappedType);

}
mapRecursiveType(type) {
mapTypeRecursively(type) {
let isGeneric = type.isGenericType();

@@ -120,0 +128,0 @@ let previouslyLearnedType = this.learnedTypesMap.get(type.getName());

@@ -44,3 +44,3 @@ "use strict";

this.nonce = nonce || 0;
this.value = value || 0;
this.value = value ? new bignumber_js_1.BigNumber(value.toString()).toFixed(0) : 0;
this.sender = sender;

@@ -157,3 +157,3 @@ this.receiver = receiver;

nonce: Number(plainObjectTransaction.nonce),
value: new bignumber_js_1.BigNumber(plainObjectTransaction.value),
value: new bignumber_js_1.BigNumber(plainObjectTransaction.value).toFixed(0),
receiver: address_1.Address.fromString(plainObjectTransaction.receiver),

@@ -160,0 +160,0 @@ sender: address_1.Address.fromString(plainObjectTransaction.sender),

{
"name": "@multiversx/sdk-core",
"version": "11.2.0",
"version": "11.3.0",
"description": "MultiversX SDK for JavaScript and TypeScript",

@@ -5,0 +5,0 @@ "main": "out/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc