@multiversx/sdk-network-providers
Advanced tools
Comparing version 2.2.1 to 2.3.0
import { AxiosRequestConfig } from "axios"; | ||
import { AccountOnNetwork, GuardianData } from "./accounts"; | ||
import { ContractQueryResponse } from "./contractQueryResponse"; | ||
import { IAddress, IContractQuery, INetworkProvider, IPagination, ITransaction } from "./interface"; | ||
import { IAddress, IContractQuery, INetworkProvider, IPagination, ITransaction, ITransactionNext } from "./interface"; | ||
import { NetworkConfig } from "./networkConfig"; | ||
@@ -32,5 +32,5 @@ import { NetworkGeneralStatistics } from "./networkGeneralStatistics"; | ||
getTransactionStatus(txHash: string): Promise<TransactionStatus>; | ||
sendTransaction(tx: ITransaction): Promise<string>; | ||
sendTransactions(txs: ITransaction[]): Promise<string[]>; | ||
simulateTransaction(tx: ITransaction): Promise<any>; | ||
sendTransaction(tx: ITransaction | ITransactionNext): Promise<string>; | ||
sendTransactions(txs: (ITransaction | ITransactionNext)[]): Promise<string[]>; | ||
simulateTransaction(tx: ITransaction | ITransactionNext): Promise<any>; | ||
queryContract(query: IContractQuery): Promise<ContractQueryResponse>; | ||
@@ -37,0 +37,0 @@ getDefinitionOfFungibleToken(tokenIdentifier: string): Promise<DefinitionOfFungibleTokenOnNetwork>; |
@@ -137,3 +137,4 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let response = yield this.doPostGeneric("transactions", tx.toSendable()); | ||
const transaction = transactions_1.prepareTransactionForBroadcasting(tx); | ||
const response = yield this.doPostGeneric("transactions", transaction); | ||
return response.txHash; | ||
@@ -140,0 +141,0 @@ }); |
@@ -62,7 +62,7 @@ import { AccountOnNetwork } from "./accounts"; | ||
*/ | ||
sendTransaction(tx: ITransaction): Promise<string>; | ||
sendTransaction(tx: ITransaction | ITransactionNext): Promise<string>; | ||
/** | ||
* Broadcasts a list of already-signed transactions. | ||
*/ | ||
sendTransactions(txs: ITransaction[]): Promise<string[]>; | ||
sendTransactions(txs: (ITransaction | ITransactionNext)[]): Promise<string[]>; | ||
/** | ||
@@ -119,1 +119,18 @@ * Simulates the processing of an already-signed transaction. | ||
} | ||
export interface ITransactionNext { | ||
sender: string; | ||
receiver: string; | ||
gasLimit: bigint; | ||
chainID: string; | ||
nonce: bigint; | ||
value: bigint; | ||
senderUsername: string; | ||
receiverUsername: string; | ||
gasPrice: bigint; | ||
data: Uint8Array; | ||
version: number; | ||
options: number; | ||
guardian: string; | ||
signature: Uint8Array; | ||
guardianSignature: Uint8Array; | ||
} |
@@ -293,3 +293,46 @@ "use strict"; | ||
}); | ||
it("should send both `Transaction` and `TransactionNext`", function () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.timeout(50000); | ||
const transaction = { | ||
toSendable: function () { | ||
return { | ||
"nonce": 7, | ||
"value": "0", | ||
"receiver": "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th", | ||
"sender": "erd1zztjf9fhwvuvquzsllknq4qcmffwad6n0hjtn5dyzytr5tgz7uas0mkgrq", | ||
"gasPrice": 1000000000, | ||
"gasLimit": 50000, | ||
"chainID": "D", | ||
"version": 2, | ||
"signature": "149f1d8296efcb9489c5b3142ae659aacfa3a7daef3645f1d3747a96dc9cee377070dd8b83b322997c15ba3c305ac18daaee0fd25760eba334b14a9272b34802" | ||
}; | ||
} | ||
}; | ||
const transactionNext = { | ||
nonce: BigInt(8), | ||
value: BigInt(0), | ||
receiver: "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th", | ||
sender: "erd1zztjf9fhwvuvquzsllknq4qcmffwad6n0hjtn5dyzytr5tgz7uas0mkgrq", | ||
data: new Uint8Array(Buffer.from("test")), | ||
gasPrice: BigInt(1000000000), | ||
gasLimit: BigInt(80000), | ||
chainID: "D", | ||
version: 2, | ||
signature: Buffer.from("3fa42d97b4f85442850340a11411a3cbd63885e06ff3f84c7a75d0ef59c780f7a18aa4f331cf460300bc8bd99352aea10b7c3bc17e40287337ae9f9842470205", "hex"), | ||
senderUsername: "", | ||
receiverUsername: "", | ||
guardian: "", | ||
guardianSignature: new Uint8Array(), | ||
options: 0 | ||
}; | ||
const apiLegacyTxHash = yield apiProvider.sendTransaction(transaction); | ||
const apiTxNextHash = yield apiProvider.sendTransaction(transactionNext); | ||
const proxyLegacyTxHash = yield proxyProvider.sendTransaction(transaction); | ||
const proxyTxNextHash = yield proxyProvider.sendTransaction(transactionNext); | ||
chai_1.assert.equal(apiLegacyTxHash, proxyLegacyTxHash); | ||
chai_1.assert.equal(apiTxNextHash, proxyTxNextHash); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=providers.dev.net.spec.js.map |
import { AxiosRequestConfig } from "axios"; | ||
import { AccountOnNetwork, GuardianData } from "./accounts"; | ||
import { ContractQueryResponse } from "./contractQueryResponse"; | ||
import { IAddress, IContractQuery, INetworkProvider, IPagination, ITransaction } from "./interface"; | ||
import { IAddress, IContractQuery, INetworkProvider, IPagination, ITransaction, ITransactionNext } from "./interface"; | ||
import { NetworkConfig } from "./networkConfig"; | ||
@@ -29,5 +29,5 @@ import { NetworkGeneralStatistics } from "./networkGeneralStatistics"; | ||
getTransactionStatus(txHash: string): Promise<TransactionStatus>; | ||
sendTransaction(tx: ITransaction): Promise<string>; | ||
sendTransactions(txs: ITransaction[]): Promise<string[]>; | ||
simulateTransaction(tx: ITransaction): Promise<any>; | ||
sendTransaction(tx: ITransaction | ITransactionNext): Promise<string>; | ||
sendTransactions(txs: (ITransaction | ITransactionNext)[]): Promise<string[]>; | ||
simulateTransaction(tx: ITransaction | ITransactionNext): Promise<any>; | ||
queryContract(query: IContractQuery): Promise<ContractQueryResponse>; | ||
@@ -34,0 +34,0 @@ getDefinitionOfFungibleToken(tokenIdentifier: string): Promise<DefinitionOfFungibleTokenOnNetwork>; |
@@ -141,3 +141,4 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let response = yield this.doPostGeneric("transaction/send", tx.toSendable()); | ||
const transaction = transactions_1.prepareTransactionForBroadcasting(tx); | ||
const response = yield this.doPostGeneric("transaction/send", transaction); | ||
return response.txHash; | ||
@@ -148,3 +149,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const data = txs.map(tx => tx.toSendable()); | ||
const data = (txs).map((tx) => transactions_1.prepareTransactionForBroadcasting(tx)); | ||
const response = yield this.doPostGeneric("transaction/send-multiple", data); | ||
@@ -160,3 +161,4 @@ const hashes = Array(txs.length).fill(null); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let response = yield this.doPostGeneric("transaction/simulate", tx.toSendable()); | ||
const transaction = transactions_1.prepareTransactionForBroadcasting(tx); | ||
const response = yield this.doPostGeneric("transaction/simulate", transaction); | ||
return response; | ||
@@ -163,0 +165,0 @@ }); |
/// <reference types="node" /> | ||
import { TransactionStatus } from "./transactionStatus"; | ||
import { ContractResults } from "./contractResults"; | ||
import { IAddress } from "./interface"; | ||
import { IAddress, ITransaction, ITransactionNext } from "./interface"; | ||
import { TransactionLogs } from "./transactionLogs"; | ||
import { TransactionReceipt } from "./transactionReceipt"; | ||
export declare function prepareTransactionForBroadcasting(transaction: ITransaction | ITransactionNext): any; | ||
export declare class TransactionOnNetwork { | ||
@@ -8,0 +9,0 @@ isCompleted?: boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionOnNetwork = void 0; | ||
exports.TransactionOnNetwork = exports.prepareTransactionForBroadcasting = void 0; | ||
const transactionStatus_1 = require("./transactionStatus"); | ||
@@ -9,2 +9,25 @@ const contractResults_1 = require("./contractResults"); | ||
const transactionReceipt_1 = require("./transactionReceipt"); | ||
function prepareTransactionForBroadcasting(transaction) { | ||
if ("toSendable" in transaction) { | ||
return transaction.toSendable(); | ||
} | ||
return { | ||
nonce: Number(transaction.nonce), | ||
value: transaction.value.toString(), | ||
receiver: transaction.receiver, | ||
sender: transaction.sender, | ||
senderUsername: transaction.senderUsername ? Buffer.from(transaction.senderUsername).toString("base64") : undefined, | ||
receiverUsername: transaction.receiverUsername ? Buffer.from(transaction.receiverUsername).toString("base64") : undefined, | ||
gasPrice: Number(transaction.gasPrice), | ||
gasLimit: Number(transaction.gasLimit), | ||
data: transaction.data.length === 0 ? undefined : Buffer.from(transaction.data).toString("base64"), | ||
chainID: transaction.chainID, | ||
version: transaction.version, | ||
options: transaction.options, | ||
guardian: transaction.guardian || undefined, | ||
signature: Buffer.from(transaction.signature).toString("hex"), | ||
guardianSignature: transaction.guardianSignature.length === 0 ? undefined : Buffer.from(transaction.guardianSignature).toString("hex"), | ||
}; | ||
} | ||
exports.prepareTransactionForBroadcasting = prepareTransactionForBroadcasting; | ||
class TransactionOnNetwork { | ||
@@ -11,0 +34,0 @@ constructor(init) { |
{ | ||
"name": "@multiversx/sdk-network-providers", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"lockfileVersion": 2, | ||
@@ -5,0 +5,0 @@ "requires": true, |
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
191143
2808