@multiversx/sdk-core
Advanced tools
Comparing version 11.4.0-alpha.0 to 11.4.0-alpha.1
@@ -14,2 +14,3 @@ export * from "./account"; | ||
export * from "./smartcontracts"; | ||
export * from "./tokenOperations"; | ||
export * from "./tokenPayment"; | ||
@@ -16,0 +17,0 @@ export * from "./tokenTransferBuilders"; |
@@ -27,2 +27,3 @@ "use strict"; | ||
__exportStar(require("./smartcontracts"), exports); | ||
__exportStar(require("./tokenOperations"), exports); | ||
__exportStar(require("./tokenPayment"), exports); | ||
@@ -29,0 +30,0 @@ __exportStar(require("./tokenTransferBuilders"), exports); |
@@ -11,2 +11,1 @@ /// <reference types="node" /> | ||
export declare function addressToHex(address: IAddress): string; | ||
export declare function addressToBuffer(address: IAddress): Buffer; |
@@ -21,4 +21,8 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addressToBuffer = exports.addressToHex = exports.bufferToHex = exports.utf8ToHex = exports.bigIntToHex = exports.bigIntToBuffer = exports.bufferToBigInt = exports.stringToBuffer = void 0; | ||
exports.addressToHex = exports.bufferToHex = exports.utf8ToHex = exports.bigIntToHex = exports.bigIntToBuffer = exports.bufferToBigInt = exports.stringToBuffer = void 0; | ||
const bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
const address_1 = require("../address"); | ||
@@ -32,2 +36,5 @@ const contractsCodecUtils = __importStar(require("../smartcontracts/codec/utils")); | ||
function bufferToBigInt(buffer) { | ||
if (buffer.length == 0) { | ||
return new bignumber_js_1.default(0); | ||
} | ||
return contractsCodecUtils.bufferToBigInt(buffer); | ||
@@ -55,9 +62,6 @@ } | ||
function addressToHex(address) { | ||
return addressToBuffer(address).toString("hex"); | ||
const buffer = address_1.Address.fromBech32(address.toString()).pubkey(); | ||
return buffer.toString("hex"); | ||
} | ||
exports.addressToHex = addressToHex; | ||
function addressToBuffer(address) { | ||
return address_1.Address.fromBech32(address.toString()).pubkey(); | ||
} | ||
exports.addressToBuffer = addressToBuffer; | ||
//# sourceMappingURL=codec.js.map |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import BigNumber from "bignumber.js"; | ||
@@ -16,2 +17,5 @@ import { IAddress, IChainID, IGasLimit, IGasPrice, INonce, ITransactionValue } from "../interface"; | ||
gasLimitESDTNFTCreate: IGasLimit; | ||
gasLimitESDTNFTUpdateAttributes: IGasLimit; | ||
gasLimitESDTNFTAddQuantity: IGasLimit; | ||
gasLimitESDTNFTBurn: IGasLimit; | ||
gasLimitStorePerByte: IGasLimit; | ||
@@ -22,3 +26,3 @@ issueCost: BigNumber.Value; | ||
interface IBaseArgs { | ||
nonce?: INonce; | ||
transactionNonce?: INonce; | ||
value?: ITransactionValue; | ||
@@ -86,3 +90,3 @@ gasPrice?: IGasPrice; | ||
} | ||
interface IESDTNFTCreateArgs extends IBaseArgs { | ||
interface INFTCreateArgs extends IBaseArgs { | ||
creator: IAddress; | ||
@@ -94,6 +98,6 @@ tokenIdentifier: string; | ||
hash: string; | ||
attributes: string; | ||
attributes: Buffer; | ||
uris: string[]; | ||
} | ||
interface IESDTPausingArgs extends IBaseArgs { | ||
interface IPausingArgs extends IBaseArgs { | ||
manager: IAddress; | ||
@@ -104,3 +108,3 @@ tokenIdentifier: string; | ||
} | ||
interface IESDTFreezingArgs extends IBaseArgs { | ||
interface IFreezingArgs extends IBaseArgs { | ||
manager: IAddress; | ||
@@ -112,3 +116,3 @@ user: IAddress; | ||
} | ||
interface IESDTLocalMintArgs extends IBaseArgs { | ||
interface ILocalMintArgs extends IBaseArgs { | ||
manager: IAddress; | ||
@@ -119,3 +123,3 @@ user: IAddress; | ||
} | ||
interface IESDTLocalBurnArgs extends IBaseArgs { | ||
interface ILocalBurnArgs extends IBaseArgs { | ||
manager: IAddress; | ||
@@ -126,4 +130,23 @@ user: IAddress; | ||
} | ||
interface IUpdateAttributesArgs extends IBaseArgs { | ||
manager: IAddress; | ||
tokenIdentifier: string; | ||
tokenNonce: BigNumber.Value; | ||
attributes: Buffer; | ||
} | ||
interface IAddQuantityArgs extends IBaseArgs { | ||
manager: IAddress; | ||
tokenIdentifier: string; | ||
tokenNonce: BigNumber.Value; | ||
quantityToAdd: BigNumber.Value; | ||
} | ||
interface IBurnQuantityArgs extends IBaseArgs { | ||
manager: IAddress; | ||
tokenIdentifier: string; | ||
tokenNonce: BigNumber.Value; | ||
quantityToBurn: BigNumber.Value; | ||
} | ||
export declare class TokenOperationsFactory { | ||
private readonly config; | ||
private readonly trueAsHex; | ||
constructor(config: IConfig); | ||
@@ -136,8 +159,12 @@ issueFungible(args: IIssueFungibleArgs): Transaction; | ||
setSpecialRoleOnSemiFungible(args: ISemiFungibleSetSpecialRoleArgs): Transaction; | ||
setSpecialRoleOnMetaESDT(args: ISemiFungibleSetSpecialRoleArgs): Transaction; | ||
setSpecialRoleOnNonFungible(args: INonFungibleSetSpecialRoleArgs): Transaction; | ||
nftCreate(args: IESDTNFTCreateArgs): Transaction; | ||
pause(args: IESDTPausingArgs): Transaction; | ||
freeze(args: IESDTFreezingArgs): Transaction; | ||
localMint(args: IESDTLocalMintArgs): Transaction; | ||
localBurn(args: IESDTLocalBurnArgs): Transaction; | ||
nftCreate(args: INFTCreateArgs): Transaction; | ||
pause(args: IPausingArgs): Transaction; | ||
freeze(args: IFreezingArgs): Transaction; | ||
localMint(args: ILocalMintArgs): Transaction; | ||
localBurn(args: ILocalBurnArgs): Transaction; | ||
updateAttributes(args: IUpdateAttributesArgs): Transaction; | ||
addQuantity(args: IAddQuantityArgs): Transaction; | ||
burnQuantity(args: IBurnQuantityArgs): Transaction; | ||
private createTransaction; | ||
@@ -144,0 +171,0 @@ private buildTransactionPayload; |
@@ -13,5 +13,5 @@ "use strict"; | ||
this.config = config; | ||
this.trueAsHex = codec_1.utf8ToHex("true"); | ||
} | ||
issueFungible(args) { | ||
const trueAsHex = codec_1.utf8ToHex("true"); | ||
const parts = [ | ||
@@ -23,10 +23,10 @@ "issue", | ||
codec_1.bigIntToHex(args.numDecimals), | ||
...(args.canFreeze ? [codec_1.utf8ToHex("canFreeze"), trueAsHex] : []), | ||
...(args.canWipe ? [codec_1.utf8ToHex("canWipe"), trueAsHex] : []), | ||
...(args.canPause ? [codec_1.utf8ToHex("canPause"), trueAsHex] : []), | ||
...(args.canMint ? [codec_1.utf8ToHex("canMint"), trueAsHex] : []), | ||
...(args.canBurn ? [codec_1.utf8ToHex("canBurn"), trueAsHex] : []), | ||
...(args.canChangeOwner ? [codec_1.utf8ToHex("canChangeOwner"), trueAsHex] : []), | ||
...(args.canUpgrade ? [codec_1.utf8ToHex("canUpgrade"), trueAsHex] : []), | ||
...(args.canAddSpecialRoles ? [codec_1.utf8ToHex("canAddSpecialRoles"), trueAsHex] : []), | ||
...(args.canFreeze ? [codec_1.utf8ToHex("canFreeze"), this.trueAsHex] : []), | ||
...(args.canWipe ? [codec_1.utf8ToHex("canWipe"), this.trueAsHex] : []), | ||
...(args.canPause ? [codec_1.utf8ToHex("canPause"), this.trueAsHex] : []), | ||
...(args.canMint ? [codec_1.utf8ToHex("canMint"), this.trueAsHex] : []), | ||
...(args.canBurn ? [codec_1.utf8ToHex("canBurn"), this.trueAsHex] : []), | ||
...(args.canChangeOwner ? [codec_1.utf8ToHex("canChangeOwner"), this.trueAsHex] : []), | ||
...(args.canUpgrade ? [codec_1.utf8ToHex("canUpgrade"), this.trueAsHex] : []), | ||
...(args.canAddSpecialRoles ? [codec_1.utf8ToHex("canAddSpecialRoles"), this.trueAsHex] : []), | ||
]; | ||
@@ -36,3 +36,3 @@ return this.createTransaction({ | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
value: this.config.issueCost, | ||
@@ -46,3 +46,2 @@ gasPrice: args.gasPrice, | ||
issueSemiFungible(args) { | ||
const trueAsHex = codec_1.utf8ToHex("true"); | ||
const parts = [ | ||
@@ -52,9 +51,9 @@ "issueSemiFungible", | ||
codec_1.utf8ToHex(args.tokenTicker), | ||
...(args.canFreeze ? [codec_1.utf8ToHex("canFreeze"), trueAsHex] : []), | ||
...(args.canWipe ? [codec_1.utf8ToHex("canWipe"), trueAsHex] : []), | ||
...(args.canPause ? [codec_1.utf8ToHex("canPause"), trueAsHex] : []), | ||
...(args.canTransferNFTCreateRole ? [codec_1.utf8ToHex("canTransferNFTCreateRole"), trueAsHex] : []), | ||
...(args.canChangeOwner ? [codec_1.utf8ToHex("canChangeOwner"), trueAsHex] : []), | ||
...(args.canUpgrade ? [codec_1.utf8ToHex("canUpgrade"), trueAsHex] : []), | ||
...(args.canAddSpecialRoles ? [codec_1.utf8ToHex("canAddSpecialRoles"), trueAsHex] : []), | ||
...(args.canFreeze ? [codec_1.utf8ToHex("canFreeze"), this.trueAsHex] : []), | ||
...(args.canWipe ? [codec_1.utf8ToHex("canWipe"), this.trueAsHex] : []), | ||
...(args.canPause ? [codec_1.utf8ToHex("canPause"), this.trueAsHex] : []), | ||
...(args.canTransferNFTCreateRole ? [codec_1.utf8ToHex("canTransferNFTCreateRole"), this.trueAsHex] : []), | ||
...(args.canChangeOwner ? [codec_1.utf8ToHex("canChangeOwner"), this.trueAsHex] : []), | ||
...(args.canUpgrade ? [codec_1.utf8ToHex("canUpgrade"), this.trueAsHex] : []), | ||
...(args.canAddSpecialRoles ? [codec_1.utf8ToHex("canAddSpecialRoles"), this.trueAsHex] : []), | ||
]; | ||
@@ -64,3 +63,3 @@ return this.createTransaction({ | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
value: this.config.issueCost, | ||
@@ -74,3 +73,2 @@ gasPrice: args.gasPrice, | ||
issueNonFungible(args) { | ||
const trueAsHex = codec_1.utf8ToHex("true"); | ||
const parts = [ | ||
@@ -80,9 +78,9 @@ "issueNonFungible", | ||
codec_1.utf8ToHex(args.tokenTicker), | ||
...(args.canFreeze ? [codec_1.utf8ToHex("canFreeze"), trueAsHex] : []), | ||
...(args.canWipe ? [codec_1.utf8ToHex("canWipe"), trueAsHex] : []), | ||
...(args.canPause ? [codec_1.utf8ToHex("canPause"), trueAsHex] : []), | ||
...(args.canTransferNFTCreateRole ? [codec_1.utf8ToHex("canTransferNFTCreateRole"), trueAsHex] : []), | ||
...(args.canChangeOwner ? [codec_1.utf8ToHex("canChangeOwner"), trueAsHex] : []), | ||
...(args.canUpgrade ? [codec_1.utf8ToHex("canUpgrade"), trueAsHex] : []), | ||
...(args.canAddSpecialRoles ? [codec_1.utf8ToHex("canAddSpecialRoles"), trueAsHex] : []), | ||
...(args.canFreeze ? [codec_1.utf8ToHex("canFreeze"), this.trueAsHex] : []), | ||
...(args.canWipe ? [codec_1.utf8ToHex("canWipe"), this.trueAsHex] : []), | ||
...(args.canPause ? [codec_1.utf8ToHex("canPause"), this.trueAsHex] : []), | ||
...(args.canTransferNFTCreateRole ? [codec_1.utf8ToHex("canTransferNFTCreateRole"), this.trueAsHex] : []), | ||
...(args.canChangeOwner ? [codec_1.utf8ToHex("canChangeOwner"), this.trueAsHex] : []), | ||
...(args.canUpgrade ? [codec_1.utf8ToHex("canUpgrade"), this.trueAsHex] : []), | ||
...(args.canAddSpecialRoles ? [codec_1.utf8ToHex("canAddSpecialRoles"), this.trueAsHex] : []), | ||
]; | ||
@@ -92,3 +90,3 @@ return this.createTransaction({ | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
value: this.config.issueCost, | ||
@@ -102,3 +100,2 @@ gasPrice: args.gasPrice, | ||
registerMetaESDT(args) { | ||
const trueAsHex = codec_1.utf8ToHex("true"); | ||
const parts = [ | ||
@@ -109,9 +106,9 @@ "registerMetaESDT", | ||
codec_1.bigIntToHex(args.numDecimals), | ||
...(args.canFreeze ? [codec_1.utf8ToHex("canFreeze"), trueAsHex] : []), | ||
...(args.canWipe ? [codec_1.utf8ToHex("canWipe"), trueAsHex] : []), | ||
...(args.canPause ? [codec_1.utf8ToHex("canPause"), trueAsHex] : []), | ||
...(args.canTransferNFTCreateRole ? [codec_1.utf8ToHex("canTransferNFTCreateRole"), trueAsHex] : []), | ||
...(args.canChangeOwner ? [codec_1.utf8ToHex("canChangeOwner"), trueAsHex] : []), | ||
...(args.canUpgrade ? [codec_1.utf8ToHex("canUpgrade"), trueAsHex] : []), | ||
...(args.canAddSpecialRoles ? [codec_1.utf8ToHex("canAddSpecialRoles"), trueAsHex] : []), | ||
...(args.canFreeze ? [codec_1.utf8ToHex("canFreeze"), this.trueAsHex] : []), | ||
...(args.canWipe ? [codec_1.utf8ToHex("canWipe"), this.trueAsHex] : []), | ||
...(args.canPause ? [codec_1.utf8ToHex("canPause"), this.trueAsHex] : []), | ||
...(args.canTransferNFTCreateRole ? [codec_1.utf8ToHex("canTransferNFTCreateRole"), this.trueAsHex] : []), | ||
...(args.canChangeOwner ? [codec_1.utf8ToHex("canChangeOwner"), this.trueAsHex] : []), | ||
...(args.canUpgrade ? [codec_1.utf8ToHex("canUpgrade"), this.trueAsHex] : []), | ||
...(args.canAddSpecialRoles ? [codec_1.utf8ToHex("canAddSpecialRoles"), this.trueAsHex] : []), | ||
]; | ||
@@ -121,3 +118,3 @@ return this.createTransaction({ | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
value: this.config.issueCost, | ||
@@ -141,3 +138,3 @@ gasPrice: args.gasPrice, | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
@@ -162,3 +159,3 @@ gasLimitHint: args.gasLimit, | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
@@ -170,2 +167,5 @@ gasLimitHint: args.gasLimit, | ||
} | ||
setSpecialRoleOnMetaESDT(args) { | ||
return this.setSpecialRoleOnSemiFungible(args); | ||
} | ||
setSpecialRoleOnNonFungible(args) { | ||
@@ -185,3 +185,3 @@ const parts = [ | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
@@ -201,3 +201,3 @@ gasLimitHint: args.gasLimit, | ||
codec_1.utf8ToHex(args.hash), | ||
codec_1.utf8ToHex(args.attributes), | ||
codec_1.bufferToHex(args.attributes), | ||
...args.uris.map(codec_1.utf8ToHex), | ||
@@ -211,3 +211,3 @@ ]; | ||
receiver: args.creator, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
@@ -230,3 +230,3 @@ gasLimitHint: args.gasLimit, | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
@@ -243,3 +243,3 @@ gasLimitHint: args.gasLimit, | ||
const parts = [ | ||
args.freeze ? "freeze" : "unfreeze", | ||
args.freeze ? "freeze" : "unFreeze", | ||
codec_1.utf8ToHex(args.tokenIdentifier), | ||
@@ -251,3 +251,3 @@ codec_1.addressToHex(args.user) | ||
receiver: this.config.esdtContractAddress, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
@@ -268,3 +268,3 @@ gasLimitHint: args.gasLimit, | ||
receiver: args.manager, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
@@ -285,3 +285,3 @@ gasLimitHint: args.gasLimit, | ||
receiver: args.manager, | ||
nonce: args.nonce, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
@@ -293,2 +293,53 @@ gasLimitHint: args.gasLimit, | ||
} | ||
updateAttributes(args) { | ||
const parts = [ | ||
"ESDTNFTUpdateAttributes", | ||
codec_1.utf8ToHex(args.tokenIdentifier), | ||
codec_1.bigIntToHex(args.tokenNonce), | ||
codec_1.bufferToHex(args.attributes), | ||
]; | ||
return this.createTransaction({ | ||
sender: args.manager, | ||
receiver: args.manager, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
gasLimitHint: args.gasLimit, | ||
executionGasLimit: this.config.gasLimitESDTNFTUpdateAttributes, | ||
dataParts: parts | ||
}); | ||
} | ||
addQuantity(args) { | ||
const parts = [ | ||
"ESDTNFTAddQuantity", | ||
codec_1.utf8ToHex(args.tokenIdentifier), | ||
codec_1.bigIntToHex(args.tokenNonce), | ||
codec_1.bigIntToHex(args.quantityToAdd) | ||
]; | ||
return this.createTransaction({ | ||
sender: args.manager, | ||
receiver: args.manager, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
gasLimitHint: args.gasLimit, | ||
executionGasLimit: this.config.gasLimitESDTNFTAddQuantity, | ||
dataParts: parts | ||
}); | ||
} | ||
burnQuantity(args) { | ||
const parts = [ | ||
"ESDTNFTBurn", | ||
codec_1.utf8ToHex(args.tokenIdentifier), | ||
codec_1.bigIntToHex(args.tokenNonce), | ||
codec_1.bigIntToHex(args.quantityToBurn) | ||
]; | ||
return this.createTransaction({ | ||
sender: args.manager, | ||
receiver: args.manager, | ||
nonce: args.transactionNonce, | ||
gasPrice: args.gasPrice, | ||
gasLimitHint: args.gasLimit, | ||
executionGasLimit: this.config.gasLimitESDTNFTBurn, | ||
dataParts: parts | ||
}); | ||
} | ||
createTransaction({ sender, receiver, nonce, value, gasPrice, gasLimitHint, executionGasLimit, dataParts }) { | ||
@@ -295,0 +346,0 @@ const payload = this.buildTransactionPayload(dataParts); |
@@ -15,2 +15,5 @@ import BigNumber from "bignumber.js"; | ||
gasLimitESDTNFTCreate: IGasLimit; | ||
gasLimitESDTNFTUpdateAttributes: IGasLimit; | ||
gasLimitESDTNFTAddQuantity: IGasLimit; | ||
gasLimitESDTNFTBurn: IGasLimit; | ||
gasLimitStorePerByte: IGasLimit; | ||
@@ -17,0 +20,0 @@ issueCost: BigNumber.Value; |
@@ -17,2 +17,5 @@ "use strict"; | ||
this.gasLimitESDTNFTCreate = 3000000; | ||
this.gasLimitESDTNFTUpdateAttributes = 1000000; | ||
this.gasLimitESDTNFTAddQuantity = 1000000; | ||
this.gasLimitESDTNFTBurn = 1000000; | ||
this.gasLimitStorePerByte = 50000; | ||
@@ -19,0 +22,0 @@ this.issueCost = "50000000000000000"; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { IAddress } from "../interface"; | ||
@@ -10,3 +11,3 @@ interface ITransactionOnNetwork { | ||
} | ||
export interface IContractResultItem { | ||
interface IContractResultItem { | ||
logs: ITransactionLogs; | ||
@@ -17,3 +18,3 @@ } | ||
} | ||
export interface ITransactionEvent { | ||
interface ITransactionEvent { | ||
readonly address: IAddress; | ||
@@ -24,3 +25,3 @@ readonly identifier: string; | ||
} | ||
export interface ITransactionEventTopic { | ||
interface ITransactionEventTopic { | ||
valueOf(): any; | ||
@@ -38,4 +39,4 @@ } | ||
tokenIdentifier: string; | ||
nonce: number; | ||
initialQuantity: number; | ||
nonce: string; | ||
initialQuantity: string; | ||
} | ||
@@ -45,3 +46,3 @@ export interface IMintOutcome { | ||
tokenIdentifier: string; | ||
nonce: number; | ||
nonce: string; | ||
mintedSupply: string; | ||
@@ -52,3 +53,3 @@ } | ||
tokenIdentifier: string; | ||
nonce: number; | ||
nonce: string; | ||
burntSupply: string; | ||
@@ -61,5 +62,20 @@ } | ||
tokenIdentifier: string; | ||
nonce: number; | ||
nonce: string; | ||
balance: string; | ||
} | ||
export interface IUpdateAttributesOutcome { | ||
tokenIdentifier: string; | ||
nonce: string; | ||
attributes: Buffer; | ||
} | ||
export interface IAddQuantityOutcome { | ||
tokenIdentifier: string; | ||
nonce: string; | ||
addedQuantity: string; | ||
} | ||
export interface IBurnQuantityOutcome { | ||
tokenIdentifier: string; | ||
nonce: string; | ||
burntQuantity: string; | ||
} | ||
export declare class TokenOperationsOutcomeParser { | ||
@@ -69,2 +85,3 @@ parseIssueFungible(transaction: ITransactionOnNetwork): IESDTIssueOutcome; | ||
parseIssueSemiFungible(transaction: ITransactionOnNetwork): IESDTIssueOutcome; | ||
parseRegisterMetaESDT(transaction: ITransactionOnNetwork): IESDTIssueOutcome; | ||
parseSetSpecialRole(transaction: ITransactionOnNetwork): ISetSpecialRoleOutcome; | ||
@@ -78,6 +95,13 @@ parseNFTCreate(transaction: ITransactionOnNetwork): INFTCreateOutcome; | ||
parseUnfreeze(transaction: ITransactionOnNetwork): IFreezingOutcome; | ||
parseUpdateAttributes(transaction: ITransactionOnNetwork): IUpdateAttributesOutcome; | ||
parseAddQuantity(transaction: ITransactionOnNetwork): IAddQuantityOutcome; | ||
parseBurnQuantity(transaction: ITransactionOnNetwork): IBurnQuantityOutcome; | ||
private ensureNoError; | ||
private findSingleEventByIdentifier; | ||
private gatherAllEvents; | ||
private extractTokenIdentifier; | ||
private extractNonce; | ||
private extractAmount; | ||
private extractAddress; | ||
} | ||
export {}; |
@@ -9,28 +9,30 @@ "use strict"; | ||
parseIssueFungible(transaction) { | ||
var _a; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "issue"); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
return { tokenIdentifier: tokenIdentifier }; | ||
} | ||
parseIssueNonFungible(transaction) { | ||
var _a; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "issueNonFungible"); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
return { tokenIdentifier: tokenIdentifier }; | ||
} | ||
parseIssueSemiFungible(transaction) { | ||
var _a; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "issueSemiFungible"); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
return { tokenIdentifier: tokenIdentifier }; | ||
} | ||
parseRegisterMetaESDT(transaction) { | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "registerMetaESDT"); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
return { tokenIdentifier: tokenIdentifier }; | ||
} | ||
parseSetSpecialRole(transaction) { | ||
var _a; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTSetRole"); | ||
const userAddress = event.address.toString(); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const roles = event.topics.slice(3).map(topic => topic.valueOf().toString()); | ||
@@ -40,28 +42,25 @@ return { userAddress, tokenIdentifier, roles }; | ||
parseNFTCreate(transaction) { | ||
var _a, _b, _c; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTNFTCreate"); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const nonce = codec_1.bufferToBigInt((_b = event.topics[1]) === null || _b === void 0 ? void 0 : _b.valueOf()).toNumber(); | ||
const initialQuantity = codec_1.bufferToBigInt((_c = event.topics[2]) === null || _c === void 0 ? void 0 : _c.valueOf()).toNumber(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const nonce = this.extractNonce(event); | ||
const initialQuantity = this.extractAmount(event); | ||
return { tokenIdentifier, nonce, initialQuantity }; | ||
} | ||
parseLocalMint(transaction) { | ||
var _a, _b, _c; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTLocalMint"); | ||
const userAddress = event.address.toString(); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const nonce = codec_1.bufferToBigInt((_b = event.topics[1]) === null || _b === void 0 ? void 0 : _b.valueOf()).toNumber(); | ||
const mintedSupply = codec_1.bufferToBigInt((_c = event.topics[2]) === null || _c === void 0 ? void 0 : _c.valueOf()).toString(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const nonce = this.extractNonce(event); | ||
const mintedSupply = this.extractAmount(event); | ||
return { userAddress, tokenIdentifier, nonce, mintedSupply }; | ||
} | ||
parseLocalBurn(transaction) { | ||
var _a, _b, _c; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTLocalBurn"); | ||
const userAddress = event.address.toString(); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const nonce = codec_1.bufferToBigInt((_b = event.topics[1]) === null || _b === void 0 ? void 0 : _b.valueOf()).toNumber(); | ||
const burntSupply = codec_1.bufferToBigInt((_c = event.topics[2]) === null || _c === void 0 ? void 0 : _c.valueOf()).toString(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const nonce = this.extractNonce(event); | ||
const burntSupply = this.extractAmount(event); | ||
return { userAddress, tokenIdentifier, nonce, burntSupply }; | ||
@@ -80,21 +79,44 @@ } | ||
parseFreeze(transaction) { | ||
var _a, _b, _c, _d; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTFreeze"); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const nonce = codec_1.bufferToBigInt((_b = event.topics[1]) === null || _b === void 0 ? void 0 : _b.valueOf()).toNumber() || 0; | ||
const balance = codec_1.bufferToBigInt((_c = event.topics[2]) === null || _c === void 0 ? void 0 : _c.valueOf()).toString(); | ||
const userAddress = address_1.Address.fromBuffer((_d = event.topics[3]) === null || _d === void 0 ? void 0 : _d.valueOf()).toString(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const nonce = this.extractNonce(event); | ||
const balance = this.extractAmount(event); | ||
const userAddress = this.extractAddress(event); | ||
return { userAddress, tokenIdentifier, nonce, balance }; | ||
} | ||
parseUnfreeze(transaction) { | ||
var _a, _b, _c, _d; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTUnFreeze"); | ||
const tokenIdentifier = (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
const nonce = codec_1.bufferToBigInt((_b = event.topics[1]) === null || _b === void 0 ? void 0 : _b.valueOf()).toNumber() || 0; | ||
const balance = codec_1.bufferToBigInt((_c = event.topics[2]) === null || _c === void 0 ? void 0 : _c.valueOf()).toString(); | ||
const userAddress = address_1.Address.fromBuffer((_d = event.topics[3]) === null || _d === void 0 ? void 0 : _d.valueOf()).toString(); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const nonce = this.extractNonce(event); | ||
const balance = this.extractAmount(event); | ||
const userAddress = this.extractAddress(event); | ||
return { userAddress, tokenIdentifier, nonce, balance }; | ||
} | ||
parseUpdateAttributes(transaction) { | ||
var _a; | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTNFTUpdateAttributes"); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const nonce = this.extractNonce(event); | ||
const attributes = (_a = event.topics[3]) === null || _a === void 0 ? void 0 : _a.valueOf(); | ||
return { tokenIdentifier, nonce, attributes }; | ||
} | ||
parseAddQuantity(transaction) { | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTNFTAddQuantity"); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const nonce = this.extractNonce(event); | ||
const addedQuantity = this.extractAmount(event); | ||
return { tokenIdentifier, nonce, addedQuantity }; | ||
} | ||
parseBurnQuantity(transaction) { | ||
this.ensureNoError(transaction); | ||
const event = this.findSingleEventByIdentifier(transaction, "ESDTNFTBurn"); | ||
const tokenIdentifier = this.extractTokenIdentifier(event); | ||
const nonce = this.extractNonce(event); | ||
const burntQuantity = this.extractAmount(event); | ||
return { tokenIdentifier, nonce, burntQuantity }; | ||
} | ||
ensureNoError(transaction) { | ||
@@ -106,3 +128,3 @@ var _a; | ||
const message = (_a = event.topics[1]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
throw new errors_1.ErrCannotParseTransactionOutcome(transaction.hash, `encountered error: ${message} (${data})`); | ||
throw new errors_1.ErrCannotParseTransactionOutcome(transaction.hash, `encountered signalError: ${message} (${data})`); | ||
} | ||
@@ -129,4 +151,20 @@ } | ||
} | ||
extractTokenIdentifier(event) { | ||
var _a; | ||
return (_a = event.topics[0]) === null || _a === void 0 ? void 0 : _a.valueOf().toString(); | ||
} | ||
extractNonce(event) { | ||
var _a; | ||
return codec_1.bufferToBigInt((_a = event.topics[1]) === null || _a === void 0 ? void 0 : _a.valueOf()).toFixed(0); | ||
} | ||
extractAmount(event) { | ||
var _a; | ||
return codec_1.bufferToBigInt((_a = event.topics[2]) === null || _a === void 0 ? void 0 : _a.valueOf()).toFixed(0); | ||
} | ||
extractAddress(event) { | ||
var _a; | ||
return address_1.Address.fromBuffer((_a = event.topics[3]) === null || _a === void 0 ? void 0 : _a.valueOf()).toString(); | ||
} | ||
} | ||
exports.TokenOperationsOutcomeParser = TokenOperationsOutcomeParser; | ||
//# sourceMappingURL=tokenOperationsOutcomeParser.js.map |
{ | ||
"name": "@multiversx/sdk-core", | ||
"version": "11.4.0-alpha.0", | ||
"version": "11.4.0-alpha.1", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
676976
303
11569