Socket
Socket
Sign inDemoInstall

@multiversx/sdk-core

Package Overview
Dependencies
Maintainers
11
Versions
89
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 13.0.0-beta.8 to 13.0.0-beta.9

out/transactionsOutcomeParsers/smartContractTransactionsOutcomeParser.d.ts

1

out/constants.d.ts

@@ -6,2 +6,3 @@ export declare const TRANSACTION_MIN_GAS_PRICE = 1000000000;

export declare const TRANSACTION_VERSION_DEFAULT = 2;
export declare const MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS = 2;
export declare const ESDT_TRANSFER_GAS_LIMIT = 500000;

@@ -8,0 +9,0 @@ export declare const ESDT_TRANSFER_FUNCTION_NAME = "ESDTTransfer";

3

out/constants.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BECH32_ADDRESS_LENGTH = exports.HEX_TRANSACTION_HASH_LENGTH = exports.MESSAGE_PREFIX = exports.DEFAULT_MESSAGE_VERSION = exports.ESDT_CONTRACT_ADDRESS = exports.DEFAULT_HRP = exports.DELEGATION_MANAGER_SC_ADDRESS = exports.CONTRACT_DEPLOY_ADDRESS = exports.VM_TYPE_WASM_VM = exports.ARGUMENTS_SEPARATOR = exports.ESDT_TRANSFER_VALUE = exports.MULTI_ESDTNFT_TRANSFER_FUNCTION_NAME = exports.ESDTNFT_TRANSFER_FUNCTION_NAME = exports.ESDT_TRANSFER_FUNCTION_NAME = exports.ESDT_TRANSFER_GAS_LIMIT = exports.TRANSACTION_VERSION_DEFAULT = exports.TRANSACTION_OPTIONS_TX_GUARDED = exports.TRANSACTION_OPTIONS_TX_HASH_SIGN = exports.TRANSACTION_OPTIONS_DEFAULT = exports.TRANSACTION_MIN_GAS_PRICE = void 0;
exports.BECH32_ADDRESS_LENGTH = exports.HEX_TRANSACTION_HASH_LENGTH = exports.MESSAGE_PREFIX = exports.DEFAULT_MESSAGE_VERSION = exports.ESDT_CONTRACT_ADDRESS = exports.DEFAULT_HRP = exports.DELEGATION_MANAGER_SC_ADDRESS = exports.CONTRACT_DEPLOY_ADDRESS = exports.VM_TYPE_WASM_VM = exports.ARGUMENTS_SEPARATOR = exports.ESDT_TRANSFER_VALUE = exports.MULTI_ESDTNFT_TRANSFER_FUNCTION_NAME = exports.ESDTNFT_TRANSFER_FUNCTION_NAME = exports.ESDT_TRANSFER_FUNCTION_NAME = exports.ESDT_TRANSFER_GAS_LIMIT = exports.MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS = exports.TRANSACTION_VERSION_DEFAULT = exports.TRANSACTION_OPTIONS_TX_GUARDED = exports.TRANSACTION_OPTIONS_TX_HASH_SIGN = exports.TRANSACTION_OPTIONS_DEFAULT = exports.TRANSACTION_MIN_GAS_PRICE = void 0;
exports.TRANSACTION_MIN_GAS_PRICE = 1000000000;

@@ -9,2 +9,3 @@ exports.TRANSACTION_OPTIONS_DEFAULT = 0;

exports.TRANSACTION_VERSION_DEFAULT = 2;
exports.MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS = 2;
exports.ESDT_TRANSFER_GAS_LIMIT = 500000;

@@ -11,0 +12,0 @@ exports.ESDT_TRANSFER_FUNCTION_NAME = "ESDTTransfer";

import { IPlainTransactionObject, ITransaction } from "../interface";
import { ITransactionOnNetwork } from "../interfaceOfNetwork";
import { Transaction } from "../transaction";
import { TransactionOutcome } from "../transactionsOutcomeParsers/resources";
export declare class TransactionsConverter {

@@ -10,2 +12,5 @@ transactionToPlainObject(transaction: ITransaction): IPlainTransactionObject;

private bufferFromHex;
transactionOnNetworkToOutcome(transactionOnNetwork: ITransactionOnNetwork): TransactionOutcome;
private smartContractResultOnNetworkToSmartContractResult;
private eventOnNetworkToEvent;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionsConverter = void 0;
const smartcontracts_1 = require("../smartcontracts");
const transaction_1 = require("../transaction");
const resources_1 = require("../transactionsOutcomeParsers/resources");
class TransactionsConverter {

@@ -58,4 +60,46 @@ transactionToPlainObject(transaction) {

}
transactionOnNetworkToOutcome(transactionOnNetwork) {
// In the future, this will not be needed because the transaction, as returned from the API,
// will hold the data corresponding to the direct smart contract call outcome (in case of smart contract calls).
const legacyResultsParser = new smartcontracts_1.ResultsParser();
const callOutcomeBundle = legacyResultsParser.parseUntypedOutcome(transactionOnNetwork);
const callOutcome = new resources_1.SmartContractCallOutcome({
function: transactionOnNetwork.function,
returnCode: callOutcomeBundle.returnCode.toString(),
returnMessage: callOutcomeBundle.returnMessage,
returnDataParts: callOutcomeBundle.values,
});
const contractResults = transactionOnNetwork.contractResults.items.map((result) => this.smartContractResultOnNetworkToSmartContractResult(result));
const logs = new resources_1.TransactionLogs({
address: transactionOnNetwork.logs.address.bech32(),
events: transactionOnNetwork.logs.events.map((event) => this.eventOnNetworkToEvent(event)),
});
return new resources_1.TransactionOutcome({
logs: logs,
smartContractResults: contractResults,
directSmartContractCallOutcome: callOutcome,
});
}
smartContractResultOnNetworkToSmartContractResult(resultOnNetwork) {
return new resources_1.SmartContractResult({
sender: resultOnNetwork.sender.bech32(),
receiver: resultOnNetwork.receiver.bech32(),
data: Buffer.from(resultOnNetwork.data),
logs: new resources_1.TransactionLogs({
address: resultOnNetwork.logs.address.bech32(),
events: resultOnNetwork.logs.events.map((event) => this.eventOnNetworkToEvent(event)),
}),
});
}
eventOnNetworkToEvent(eventOnNetwork) {
return new resources_1.TransactionEvent({
address: eventOnNetwork.address.bech32(),
identifier: eventOnNetwork.identifier,
topics: eventOnNetwork.topics.map((topic) => Buffer.from(topic.hex(), "hex")),
data: eventOnNetwork.dataPayload?.valueOf() || Buffer.from(eventOnNetwork.data),
additionalData: eventOnNetwork.additionalData?.map((data) => data.valueOf()) || [],
});
}
}
exports.TransactionsConverter = TransactionsConverter;
//# sourceMappingURL=transactionsConverter.js.map

@@ -20,2 +20,3 @@ /// <reference types="node" />

sender: IAddress;
function?: string;
data: Buffer;

@@ -57,2 +58,3 @@ status: ITransactionStatus;

export interface ITransactionLogs {
address: IAddress;
events: ITransactionEvent[];

@@ -66,2 +68,8 @@ findSingleOrNoneEvent(identifier: string, predicate?: (event: ITransactionEvent) => boolean): ITransactionEvent | undefined;

readonly data: string;
readonly dataPayload?: {
valueOf(): Uint8Array;
};
readonly additionalData?: {
valueOf(): Uint8Array;
}[];
findFirstOrNoneTopic(predicate: (topic: ITransactionEventTopic) => boolean): ITransactionEventTopic | undefined;

@@ -68,0 +76,0 @@ getLastTopic(): ITransactionEventTopic;

@@ -47,2 +47,13 @@ /// <reference types="node" />

}): TypedOutcomeBundle;
parseOutcomeFromUntypedBundle(bundle: UntypedOutcomeBundle, endpoint: {
output: IParameterDefinition[];
}): {
returnCode: ReturnCode;
returnMessage: string;
values: TypedValue[];
firstValue: TypedValue;
secondValue: TypedValue;
thirdValue: TypedValue;
lastValue: TypedValue;
};
parseUntypedOutcome(transaction: ITransactionOnNetwork): UntypedOutcomeBundle;

@@ -49,0 +60,0 @@ private parseTransactionMetadata;

@@ -57,7 +57,11 @@ "use strict";

parseOutcome(transaction, endpoint) {
let untypedBundle = this.parseUntypedOutcome(transaction);
let values = this.argsSerializer.buffersToValues(untypedBundle.values, endpoint.output);
const untypedBundle = this.parseUntypedOutcome(transaction);
const typedBundle = this.parseOutcomeFromUntypedBundle(untypedBundle, endpoint);
return typedBundle;
}
parseOutcomeFromUntypedBundle(bundle, endpoint) {
const values = this.argsSerializer.buffersToValues(bundle.values, endpoint.output);
return {
returnCode: untypedBundle.returnCode,
returnMessage: untypedBundle.returnMessage,
returnCode: bundle.returnCode,
returnMessage: bundle.returnMessage,
values: values,

@@ -64,0 +68,0 @@ firstValue: values[0],

@@ -33,4 +33,4 @@ "use strict";

this.chainID = options.chainID.valueOf();
this.version = options.version?.valueOf() || constants_1.TRANSACTION_VERSION_DEFAULT;
this.options = options.options?.valueOf() || constants_1.TRANSACTION_OPTIONS_DEFAULT;
this.version = Number(options.version?.valueOf() || constants_1.TRANSACTION_VERSION_DEFAULT);
this.options = Number(options.options?.valueOf() || constants_1.TRANSACTION_OPTIONS_DEFAULT);
this.guardian = options.guardian ? this.addressAsBech32(options.guardian) : "";

@@ -37,0 +37,0 @@ this.signature = options.signature || Buffer.from([]);

@@ -19,5 +19,6 @@ import { INetworkConfig } from "./interfaceOfNetwork";

applyGuardian(transaction: ITransaction, guardian: string): void;
applyOptionsForHashSigning(transaction: ITransaction): void;
private toPlainObjectForSigning;
private toBase64OrUndefined;
private ensureFields;
private ensureValidTransactionFields;
}

@@ -55,6 +55,3 @@ "use strict";

computeBytesForSigning(transaction) {
this.ensureFields(transaction);
if (transaction.version >= 2 && this.hasOptionsSetForHashSigning(transaction)) {
return this.computeHashForSigning(transaction);
}
this.ensureValidTransactionFields(transaction);
const plainTransaction = this.toPlainObjectForSigning(transaction);

@@ -82,6 +79,14 @@ const serialized = JSON.stringify(plainTransaction);

applyGuardian(transaction, guardian) {
transaction.version = 2;
if (transaction.version < constants_1.MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS) {
transaction.version = constants_1.MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS;
}
transaction.options = transaction.options | constants_1.TRANSACTION_OPTIONS_TX_GUARDED;
transaction.guardian = guardian;
}
applyOptionsForHashSigning(transaction) {
if (transaction.version < constants_1.MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS) {
transaction.version = constants_1.MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS;
}
transaction.options = transaction.options | constants_1.TRANSACTION_OPTIONS_TX_HASH_SIGN;
}
toPlainObjectForSigning(transaction) {

@@ -107,3 +112,3 @@ return {

}
ensureFields(transaction) {
ensureValidTransactionFields(transaction) {
if (transaction.sender.length !== constants_1.BECH32_ADDRESS_LENGTH) {

@@ -118,2 +123,7 @@ throw new errors.ErrBadUsage("Invalid `sender` field. Should be the bech32 address of the sender.");

}
if (transaction.version < constants_1.MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS) {
if (this.hasOptionsSetForGuardedTransaction(transaction) || this.hasOptionsSetForHashSigning(transaction)) {
throw new errors.ErrBadUsage(`Non-empty transaction options requires transaction version >= ${constants_1.MIN_TRANSACTION_VERSION_THAT_SUPPORTS_OPTIONS}`);
}
}
}

@@ -120,0 +130,0 @@ }

@@ -8,6 +8,4 @@ import { TransactionOutcome } from "./resources";

private ensureNoError;
private findEventsByIdentifier;
private gatherAllEvents;
private extractContractAddress;
private decodeTopicAsString;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DelegationTransactionsOutcomeParser = void 0;
const address_1 = require("../address");
const errors_1 = require("../errors");
const address_1 = require("../address");
const resources_1 = require("./resources");
class DelegationTransactionsOutcomeParser {
constructor() { }
parseCreateNewDelegationContract(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "SCDeploy");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "SCDeploy");
return events.map((event) => ({ contractAddress: this.extractContractAddress(event) }));

@@ -22,26 +23,11 @@ }

}
findEventsByIdentifier(transactionOutcome, identifier) {
const events = this.gatherAllEvents(transactionOutcome).filter((event) => event.identifier == identifier);
if (events.length == 0) {
throw new errors_1.ErrParseTransactionOutcome(`cannot find event of type ${identifier}`);
}
return events;
}
gatherAllEvents(transactionOutcome) {
const allEvents = [];
allEvents.push(...transactionOutcome.transactionLogs.events);
for (const item of transactionOutcome.smartContractResults) {
allEvents.push(...item.logs.events);
}
return allEvents;
}
extractContractAddress(event) {
if (!event.topics[0]) {
if (!event.topics[0]?.length) {
return "";
}
const address = Buffer.from(event.topics[0], "base64");
const address = Buffer.from(event.topics[0]);
return address_1.Address.fromBuffer(address).bech32();
}
decodeTopicAsString(topic) {
return Buffer.from(topic, "base64").toString();
return Buffer.from(topic).toString();
}

@@ -48,0 +34,0 @@ }

export declare class TransactionEvent {
address: string;
identifier: string;
topics: string[];
topics: Uint8Array[];
data: Uint8Array;
additionalData: Uint8Array[];
constructor(init: Partial<TransactionEvent>);

@@ -21,5 +22,15 @@ }

export declare class TransactionOutcome {
directSmartContractCallOutcome: SmartContractCallOutcome;
smartContractResults: SmartContractResult[];
transactionLogs: TransactionLogs;
logs: TransactionLogs;
constructor(init: Partial<TransactionOutcome>);
}
export declare class SmartContractCallOutcome {
function: string;
returnDataParts: Uint8Array[];
returnMessage: string;
returnCode: string;
constructor(init: Partial<SmartContractCallOutcome>);
}
export declare function findEventsByIdentifier(transactionOutcome: TransactionOutcome, identifier: string): TransactionEvent[];
export declare function gatherAllEvents(transactionOutcome: TransactionOutcome): TransactionEvent[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionOutcome = exports.SmartContractResult = exports.TransactionLogs = exports.TransactionEvent = void 0;
exports.gatherAllEvents = exports.findEventsByIdentifier = exports.SmartContractCallOutcome = exports.TransactionOutcome = exports.SmartContractResult = exports.TransactionLogs = exports.TransactionEvent = void 0;
const errors_1 = require("../errors");
class TransactionEvent {

@@ -10,2 +11,3 @@ constructor(init) {

this.data = new Uint8Array();
this.additionalData = [];
Object.assign(this, init);

@@ -35,4 +37,5 @@ }

constructor(init) {
this.directSmartContractCallOutcome = new SmartContractCallOutcome({});
this.smartContractResults = [];
this.transactionLogs = new TransactionLogs({});
this.logs = new TransactionLogs({});
Object.assign(this, init);

@@ -42,2 +45,29 @@ }

exports.TransactionOutcome = TransactionOutcome;
class SmartContractCallOutcome {
constructor(init) {
this.function = "";
this.returnDataParts = [];
this.returnMessage = "";
this.returnCode = "";
Object.assign(this, init);
}
}
exports.SmartContractCallOutcome = SmartContractCallOutcome;
function findEventsByIdentifier(transactionOutcome, identifier) {
const events = gatherAllEvents(transactionOutcome).filter((event) => event.identifier == identifier);
if (events.length == 0) {
throw new errors_1.ErrParseTransactionOutcome(`cannot find event of type ${identifier}`);
}
return events;
}
exports.findEventsByIdentifier = findEventsByIdentifier;
function gatherAllEvents(transactionOutcome) {
const allEvents = [];
allEvents.push(...transactionOutcome.logs.events);
for (const item of transactionOutcome.smartContractResults) {
allEvents.push(...item.logs.events);
}
return allEvents;
}
exports.gatherAllEvents = gatherAllEvents;
//# sourceMappingURL=resources.js.map

@@ -94,4 +94,2 @@ import { TransactionOutcome } from "./resources";

private ensureNoError;
private findEventsByIdentifier;
private gatherAllEvents;
private extractTokenIdentifier;

@@ -98,0 +96,0 @@ private extractNonce;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenManagementTransactionsOutcomeParser = void 0;
const address_1 = require("../address");
const errors_1 = require("../errors");
const address_1 = require("../address");
const utils_1 = require("../smartcontracts/codec/utils");
const resources_1 = require("./resources");
class TokenManagementTransactionsOutcomeParser {
constructor() { }
parseIssueFungible(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "issue");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "issue");
return events.map((event) => ({ tokenIdentifier: this.extractTokenIdentifier(event) }));
}
parseIssueNonFungible(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "issueNonFungible");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "issueNonFungible");
return events.map((event) => ({ tokenIdentifier: this.extractTokenIdentifier(event) }));
}
parseIssueSemiFungible(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "issueSemiFungible");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "issueSemiFungible");
return events.map((event) => ({ tokenIdentifier: this.extractTokenIdentifier(event) }));
}
parseRegisterMetaEsdt(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "registerMetaESDT");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "registerMetaESDT");
return events.map((event) => ({ tokenIdentifier: this.extractTokenIdentifier(event) }));
}
parseRegisterAndSetAllRoles(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const registerEvents = this.findEventsByIdentifier(transactionOutcome, "registerAndSetAllRoles");
const setRoleEvents = this.findEventsByIdentifier(transactionOutcome, "ESDTSetRole");
this.ensureNoError(transactionOutcome.logs.events);
const registerEvents = resources_1.findEventsByIdentifier(transactionOutcome, "registerAndSetAllRoles");
const setRoleEvents = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTSetRole");
if (registerEvents.length !== setRoleEvents.length) {

@@ -44,10 +45,10 @@ throw new errors_1.ErrParseTransactionOutcome("Register Events and Set Role events mismatch. Should have the same number of events.");

parseSetBurnRoleGlobally(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
this.ensureNoError(transactionOutcome.logs.events);
}
parseUnsetBurnRoleGlobally(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
this.ensureNoError(transactionOutcome.logs.events);
}
parseSetSpecialRole(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTSetRole");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTSetRole");
return events.map((event) => this.getOutputForSetSpecialRoleEvent(event));

@@ -63,4 +64,4 @@ }

parseNftCreate(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTNFTCreate");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTNFTCreate");
return events.map((event) => this.getOutputForNftCreateEvent(event));

@@ -75,4 +76,4 @@ }

parseLocalMint(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTLocalMint");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTLocalMint");
return events.map((event) => this.getOutputForLocalMintEvent(event));

@@ -93,4 +94,4 @@ }

parseLocalBurn(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTLocalBurn");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTLocalBurn");
return events.map((event) => this.getOutputForLocalBurnEvent(event));

@@ -111,14 +112,14 @@ }

parsePause(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTPause");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTPause");
return events.map((event) => ({ tokenIdentifier: this.extractTokenIdentifier(event) }));
}
parseUnpause(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTUnPause");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTUnPause");
return events.map((event) => ({ tokenIdentifier: this.extractTokenIdentifier(event) }));
}
parseFreeze(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTFreeze");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTFreeze");
return events.map((event) => this.getOutputForFreezeEvent(event));

@@ -139,4 +140,4 @@ }

parseUnfreeze(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTUnFreeze");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTUnFreeze");
return events.map((event) => this.getOutputForUnfreezeEvent(event));

@@ -157,4 +158,4 @@ }

parseWipe(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTWipe");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTWipe");
return events.map((event) => this.getOutputForWipeEvent(event));

@@ -175,4 +176,4 @@ }

parseUpdateAttributes(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTNFTUpdateAttributes");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTNFTUpdateAttributes");
return events.map((event) => this.getOutputForUpdateAttributesEvent(event));

@@ -183,3 +184,3 @@ }

const nonce = this.extractNonce(event);
const attributes = event.topics[3] ? Buffer.from(event.topics[3], "base64") : new Uint8Array();
const attributes = event.topics[3] ? event.topics[3] : new Uint8Array();
return {

@@ -192,4 +193,4 @@ tokenIdentifier: tokenIdentifier,

parseAddQuantity(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTNFTAddQuantity");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTNFTAddQuantity");
return events.map((event) => this.getOutputForAddQuantityEvent(event));

@@ -208,4 +209,4 @@ }

parseBurnQuantity(transactionOutcome) {
this.ensureNoError(transactionOutcome.transactionLogs.events);
const events = this.findEventsByIdentifier(transactionOutcome, "ESDTNFTBurn");
this.ensureNoError(transactionOutcome.logs.events);
const events = resources_1.findEventsByIdentifier(transactionOutcome, "ESDTNFTBurn");
return events.map((event) => this.getOutputForBurnQuantityEvent(event));

@@ -232,19 +233,4 @@ }

}
findEventsByIdentifier(transactionOutcome, identifier) {
const events = this.gatherAllEvents(transactionOutcome).filter((event) => event.identifier == identifier);
if (events.length == 0) {
throw new errors_1.ErrParseTransactionOutcome(`cannot find event of type ${identifier}`);
}
return events;
}
gatherAllEvents(transactionOutcome) {
const allEvents = [];
allEvents.push(...transactionOutcome.transactionLogs.events);
for (const item of transactionOutcome.smartContractResults) {
allEvents.push(...item.logs.events);
}
return allEvents;
}
extractTokenIdentifier(event) {
if (!event.topics[0]) {
if (!event.topics[0]?.length) {
return "";

@@ -255,24 +241,24 @@ }

extractNonce(event) {
if (!event.topics[1]) {
if (!event.topics[1]?.length) {
return BigInt(0);
}
const nonce = Buffer.from(event.topics[1], "base64");
const nonce = Buffer.from(event.topics[1]);
return BigInt(utils_1.bufferToBigInt(nonce).toFixed(0));
}
extractAmount(event) {
if (!event.topics[2]) {
if (!event.topics[2]?.length) {
return BigInt(0);
}
const amount = Buffer.from(event.topics[2], "base64");
const amount = Buffer.from(event.topics[2]);
return BigInt(utils_1.bufferToBigInt(amount).toFixed(0));
}
extractAddress(event) {
if (!event.topics[3]) {
if (!event.topics[3]?.length) {
return "";
}
const address = Buffer.from(event.topics[3], "base64");
const address = Buffer.from(event.topics[3]);
return address_1.Address.fromBuffer(address).bech32();
}
decodeTopicAsString(topic) {
return Buffer.from(topic, "base64").toString();
return Buffer.from(topic).toString();
}

@@ -279,0 +265,0 @@ }

{
"name": "@multiversx/sdk-core",
"version": "13.0.0-beta.8",
"version": "13.0.0-beta.9",
"description": "MultiversX SDK for JavaScript and TypeScript",

@@ -37,4 +37,4 @@ "main": "out/index.js",

"devDependencies": {
"@multiversx/sdk-network-providers": "2.3.0",
"@multiversx/sdk-wallet": "4.2.0",
"@multiversx/sdk-network-providers": "2.4.1",
"@multiversx/sdk-wallet": "4.4.0",
"@types/assert": "1.4.6",

@@ -41,0 +41,0 @@ "@types/chai": "4.2.11",

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

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

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