Socket
Socket
Sign inDemoInstall

@tenderly/sdk

Package Overview
Dependencies
9
Maintainers
9
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.15 to 0.2.0

121

dist/index.d.ts

@@ -1,2 +0,2 @@

import axios, { AxiosResponse, AxiosError } from 'axios';
import axios, { AxiosResponse } from 'axios';

@@ -49,2 +49,3 @@ type Path = string;

};
type EmptyObject = Record<PropertyKey, never>;

@@ -54,5 +55,5 @@ interface Repository<T> {

add: (uniqueId: string, data: Partial<T>) => Promise<T | undefined>;
remove: (uniqueId: any) => Promise<void>;
update: <UpdateableFields>(uniqueId: any, data: UpdateableFields) => Promise<unknown | undefined>;
getBy: (queryObject: unknown) => Promise<T[] | undefined>;
remove: (uniqueId: string) => Promise<void>;
update: (uniqueId: string, data: never) => Promise<unknown | undefined>;
getBy: (queryObject: never) => Promise<T[] | undefined>;
getAll: () => Promise<T[] | undefined>;

@@ -293,3 +294,3 @@ }

*/
get(address: string): Promise<Contract>;
get(address: string): Promise<Contract | undefined>;
/**

@@ -307,3 +308,3 @@ * Add a contract to the Tenderly's instances' project

displayName?: string;
}): Promise<Contract>;
}): Promise<Contract | undefined>;
/**

@@ -320,3 +321,3 @@ * Remove a contract from the Tenderly's instances' project

* @param address - The address of the contract
* @param contractData - The data of the contract
* @param payload - The data of the contract
* @returns The contract object in a plain format

@@ -335,4 +336,4 @@ * @example

*/
update(address: string, payload: UpdateContractRequest): Promise<Contract>;
getAll(): Promise<Contract[]>;
update(address: string, payload: UpdateContractRequest): Promise<Contract | undefined>;
getAll(): Promise<Contract[] | undefined>;
/**

@@ -349,3 +350,3 @@ * Get all contracts in the Tenderly's instances' project

*/
getBy(queryObject?: GetByParams): Promise<TenderlyContract[]>;
getBy(queryObject?: GetByParams): Promise<TenderlyContract[] | undefined>;
private buildQueryParams;

@@ -359,3 +360,3 @@ /**Verifies a contract on Tenderly by submitting a verification request with

*/
verify(address: string, verificationRequest: VerificationRequest): Promise<TenderlyContract>;
verify(address: string, verificationRequest: VerificationRequest): Promise<TenderlyContract | undefined>;
_mapSolcSourcesToTenderlySources(sources: Record<Path, {

@@ -365,8 +366,8 @@ name?: string;

}>): Record<string, {
name?: string;
name?: string | undefined;
code: string;
}>;
_repackLibraries(solcConfig: SolcConfig): SolcConfig;
_repackLibraries(solcConfig: SolcConfig): Omit<SolcConfig, "sources">;
_isFullyQualifiedContractName(contractName: string): boolean;
_copySolcConfigToTenderlySolcConfig(solcConfig: SolcConfig): SolcConfig;
_copySolcConfigToTenderlySolcConfig(solcConfig: SolcConfig): Omit<SolcConfig, 'sources'>;
}

@@ -435,3 +436,3 @@

*/
get(address: string): Promise<Wallet>;
get(address: string): Promise<Wallet | undefined>;
/**

@@ -447,3 +448,3 @@ * Add a wallet to the project.

displayName?: string;
}): Promise<Wallet>;
}): Promise<Wallet | undefined>;
/**

@@ -470,3 +471,3 @@ * Remove a wallet from the Tenderly instances' project.

*/
update(address: string, payload: UpdateWalletRequest): Promise<Wallet>;
update(address: string, payload: UpdateWalletRequest): Promise<Wallet | undefined>;
/**

@@ -476,3 +477,3 @@ * Get all wallets in the Tenderly instances' project.

*/
getAll(): Promise<Wallet[]>;
getAll(): Promise<Wallet[] | undefined>;
/**

@@ -509,9 +510,10 @@ * Get all wallets in the Tenderly instances' project.

type SimulationRequestOverrides = {
[contractAddress: Web3Address]: {
nonce: number;
code: string;
balance: string;
state_diff: {
[storageKey: string]: string;
};
[contractAddress: Web3Address]: SimulationRequestOverride;
};
type SimulationRequestOverride = {
nonce?: number;
code?: string;
balance?: string;
state_diff?: {
[storageKey: string]: string | unknown;
};

@@ -552,9 +554,10 @@ };

type SimulationParametersOverrides = {
[contractAddress: Web3Address]: {
nonce?: number;
code?: string;
balance?: string;
state?: {
[property: string]: unknown;
};
[contractAddress: Web3Address]: SimulationParametersOverride;
};
type SimulationParametersOverride = {
nonce?: number;
code?: string;
balance?: string;
state?: {
[property: string]: unknown;
};

@@ -595,3 +598,3 @@ };

networkID: string;
stateOverrides: Record<Web3Address, StateOverride>;
stateOverrides: StateOverride;
};

@@ -665,5 +668,5 @@ type EncodedStateOverride = Record<Web3Address, Record<string, unknown>>;

* @param {object} simulationParams.overrides - Overrides for the transaction simulation.
* @returns {Promise<SimulationResult>} - A Promise that resolves to a simulation result object.
* @returns {Promise<SimulationOutput>} - A Promise that resolves to a simulation output.
*/
simulateTransaction({ transaction, blockNumber, overrides }: SimulationParameters): Promise<SimulationOutput>;
simulateTransaction({ transaction, blockNumber, overrides, }: SimulationParameters): Promise<SimulationOutput | undefined>;
/**

@@ -678,5 +681,5 @@ * Simulates a bundle of transactions by encoding overrides, building a request body,

* @param {number} params.blockNumber - The block number for the simulation bundle.
* @returns {Promise<SimulationResult[]>} - A Promise that resolves to an array of simulation result objects.
* @returns {Promise<SimulationOutput[]>} - A Promise that resolves to an array of simulation result objects.
*/
simulateBundle({ transactions, overrides, blockNumber }: SimulationBundleDetails): Promise<SimulationOutput[]>;
simulateBundle({ transactions, overrides, blockNumber }: SimulationBundleDetails): Promise<SimulationOutput[] | undefined>;
}

@@ -686,3 +689,3 @@

* The main class of the Tenderly SDK
* Instantiate this class with your config and you're ready to go
* Instantiate this class with your config, and you're ready to go
* @example

@@ -715,3 +718,3 @@ * const tenderly = new Tenderly({

* The main class of the Tenderly SDK
* Instantiate this class with your config and you're ready to go
* Instantiate this class with your config, and you're ready to go
* @example

@@ -754,3 +757,3 @@ * const tenderly = new Tenderly({

});
static handle(error: Error): void;
static handle(error: Error | unknown): void;
}

@@ -763,7 +766,25 @@

} & TenderlyError);
static handle(error: AxiosError<{
error: TenderlyError;
}>): void;
static handle(error: Error | unknown): void;
}
declare class BytecodeMismatchError extends GeneralError<BytecodeMismatchErrorResponse> {
constructor(message: string, data?: BytecodeMismatchErrorResponse);
}
declare class CompilationError extends GeneralError<CompilationErrorResponse[]> {
constructor(message: string, data?: CompilationErrorResponse[]);
}
declare class EncodingError extends GeneralError {
constructor(error: TenderlyError);
}
declare class InvalidArgumentsError extends GeneralError {
constructor(message: string);
}
declare class InvalidResponseError extends GeneralError {
constructor(message: string);
}
declare class NotFoundError extends GeneralError {

@@ -773,8 +794,16 @@ constructor(message: string);

declare class InvalidArgumentsError extends GeneralError {
declare class UnexpectedVerificationError extends GeneralError {
constructor(message: string);
}
declare function handleError(error: Error): void;
declare function handleError(error: Error | unknown): void;
export { ApiError, BytecodeMismatchErrorResponse, CompilationErrorResponse, Contract, ContractRequest, ContractResponse, EncodeStateRequest, EncodedStateOverride, GeneralError, GetByParams, InvalidArgumentsError, Network, NotFoundError, Path, RawEvent, SimulateBundleResponse, SimulateSimpleResponse, SimulateSimpleResponse_TraceResponse, SimulationBundleDetails, SimulationBundleRequest, SimulationCallArguments, SimulationOutput, SimulationParameters, SimulationParametersOverrides, SimulationRequest, SimulationRequestOverrides, SolcConfig, SolidityCompilerVersions, StateOverride, Tenderly, TenderlyConfiguration, TenderlyContract, TenderlyError, TenderlySolcConfigLibraries, TenderlyWallet, TransactionParameters, UpdateContractRequest, UpdateWalletRequest, VerificationRequest, VerificationResponse, Wallet, WalletRequest, WalletResponse, Web3Address, WithRequired, handleError };
type TenderlyEnvVariables = {
TENDERLY_ACCESS_KEY: string;
TENDERLY_ACCOUNT_NAME: string;
TENDERLY_PROJECT_NAME: string;
TENDERLY_GET_BY_PROJECT_NAME: string;
};
declare function getEnvironmentVariables(): TenderlyEnvVariables;
export { ApiError, BytecodeMismatchError, BytecodeMismatchErrorResponse, CompilationError, CompilationErrorResponse, Contract, ContractRequest, ContractResponse, EmptyObject, EncodeStateRequest, EncodedStateOverride, EncodingError, GeneralError, GetByParams, InvalidArgumentsError, InvalidResponseError, Network, NotFoundError, Path, RawEvent, SimulateBundleResponse, SimulateSimpleResponse, SimulateSimpleResponse_TraceResponse, SimulationBundleDetails, SimulationBundleRequest, SimulationCallArguments, SimulationOutput, SimulationParameters, SimulationParametersOverride, SimulationParametersOverrides, SimulationRequest, SimulationRequestOverride, SimulationRequestOverrides, SolcConfig, SolidityCompilerVersions, StateOverride, Tenderly, TenderlyConfiguration, TenderlyContract, TenderlyError, TenderlySolcConfigLibraries, TenderlyWallet, TransactionParameters, UnexpectedVerificationError, UpdateContractRequest, UpdateWalletRequest, VerificationRequest, VerificationResponse, Wallet, WalletRequest, WalletResponse, Web3Address, WithRequired, getEnvironmentVariables, handleError };

@@ -0,1 +1,2 @@

"use strict";
var __create = Object.create;

@@ -87,7 +88,13 @@ var __defProp = Object.defineProperty;

ApiError: () => ApiError,
BytecodeMismatchError: () => BytecodeMismatchError,
CompilationError: () => CompilationError,
EncodingError: () => EncodingError,
GeneralError: () => GeneralError,
InvalidArgumentsError: () => InvalidArgumentsError,
InvalidResponseError: () => InvalidResponseError,
Network: () => Network,
NotFoundError: () => NotFoundError,
Tenderly: () => Tenderly,
UnexpectedVerificationError: () => UnexpectedVerificationError,
getEnvironmentVariables: () => getEnvironmentVariables,
handleError: () => handleError

@@ -111,3 +118,5 @@ });

static handle(error) {
throw error;
if (error instanceof Error)
throw error;
throw new Error(JSON.stringify(error));
}

@@ -143,20 +152,45 @@ };

// lib/errors/Error.handlerRegistry.ts
var errorHandlers = /* @__PURE__ */ new Set([
ApiError
]);
// lib/errors/BytecodeMismatchError.ts
var BytecodeMismatchError = class extends GeneralError {
constructor(message, data) {
super({
message,
id: "local_error",
slug: "bytecode_mismatch_error",
data
});
this.name = "BytecodeMismatchError";
}
};
__name(BytecodeMismatchError, "BytecodeMismatchError");
// lib/errors/NotFoundError.ts
var NotFoundError = class extends GeneralError {
constructor(message) {
// lib/errors/CompilationError.ts
var CompilationError = class extends GeneralError {
constructor(message, data) {
super({
message,
id: "local_error",
slug: "resource_not_found"
slug: "compilation_error",
data
});
this.name = "NotFoundError";
this.name = "CompilationError";
}
};
__name(NotFoundError, "NotFoundError");
__name(CompilationError, "CompilationError");
// lib/errors/EncodingError.ts
var EncodingError = class extends GeneralError {
constructor(error) {
super(error);
this.name = "EncodingError";
}
};
__name(EncodingError, "EncodingError");
// lib/errors/Error.handlerRegistry.ts
var errorHandlers = [
ApiError,
GeneralError
];
// lib/errors/InvalidArgumentsError.ts

@@ -175,36 +209,27 @@ var InvalidArgumentsError = class extends GeneralError {

// lib/errors/index.ts
function handleError(error) {
errorHandlers.forEach((handler) => handler.handle(error));
throw error;
}
__name(handleError, "handleError");
// lib/errors/CompilationError.ts
var CompilationError = class extends GeneralError {
constructor(message, data) {
// lib/errors/InvalidResponseError.ts
var InvalidResponseError = class extends GeneralError {
constructor(message) {
super({
id: "local_error",
message,
id: "local_error",
slug: "compilation_error",
data
slug: "invalid_response"
});
this.name = "CompilationError";
this.name = "InvalidResponseError";
}
};
__name(CompilationError, "CompilationError");
__name(InvalidResponseError, "InvalidResponseError");
// lib/errors/BytecodeMismatchError.ts
var BytecodeMismatchError = class extends GeneralError {
constructor(message, data) {
// lib/errors/NotFoundError.ts
var NotFoundError = class extends GeneralError {
constructor(message) {
super({
message,
id: "local_error",
slug: "bytecode_mismatch_error",
data
slug: "resource_not_found"
});
this.name = "BytecodeMismatchError";
this.name = "NotFoundError";
}
};
__name(BytecodeMismatchError, "BytecodeMismatchError");
__name(NotFoundError, "NotFoundError");

@@ -224,2 +249,9 @@ // lib/errors/UnexpectedVerificationError.ts

// lib/errors/index.ts
function handleError(error) {
errorHandlers.forEach((handler) => handler.handle(error));
throw error;
}
__name(handleError, "handleError");
// lib/repositories/contracts/contracts.repository.ts

@@ -270,3 +302,3 @@ function mapContractResponseToContractModel(contractResponse) {

return __async(this, null, function* () {
var _a, _b, _c;
var _a;
try {

@@ -289,3 +321,3 @@ const result = yield this.apiV2.get(`

});
if (!((_a = result.data) == null ? void 0 : _a.accounts) || ((_c = (_b = result.data) == null ? void 0 : _b.accounts) == null ? void 0 : _c.length) === 0) {
if (!((_a = result.data) == null ? void 0 : _a.accounts) || !result.data.accounts[0]) {
throw new NotFoundError(`Contract with address ${address} not found`);

@@ -349,3 +381,3 @@ }

* @param address - The address of the contract
* @param contractData - The data of the contract
* @param payload - The data of the contract
* @returns The contract object in a plain format

@@ -492,3 +524,3 @@ * @example

}
if (!verificationResp.results || verificationResp.results.length === 0) {
if (!verificationResp.results || !verificationResp.results[0]) {
throw new UnexpectedVerificationError(

@@ -510,10 +542,11 @@ // eslint-disable-next-line max-len

const tenderlySources = {};
for (const path in sources) {
Object.entries(sources).forEach(([path, source]) => {
tenderlySources[path] = {
code: sources[path].content
code: source.content
};
}
});
return tenderlySources;
}
_repackLibraries(solcConfig) {
var _a;
const tenderlySolcConfig = this._copySolcConfigToTenderlySolcConfig(solcConfig);

@@ -526,10 +559,9 @@ const solcConfigSettings = solcConfig.settings;

for (const [fileName, libVal] of Object.entries(solcConfigSettings.libraries)) {
if (libraries[fileName] === void 0) {
for (const [libName, libAddress] of Object.entries(libVal)) {
libraries[fileName] = {
addresses: {}
addresses: __spreadProps(__spreadValues({}, (_a = libraries == null ? void 0 : libraries[fileName]) == null ? void 0 : _a.addresses), {
[libName]: libAddress
})
};
}
for (const [libName, libAddress] of Object.entries(libVal)) {
libraries[fileName].addresses[libName] = libAddress;
}
}

@@ -546,3 +578,2 @@ tenderlySolcConfig.settings.libraries = libraries;

return {
sources: void 0,
version: solcConfig.version,

@@ -557,6 +588,6 @@ settings

function getContractFromResponse(contractResponse) {
const getterProperty = contractResponse.account ? "account" : "contract";
const walletDetails = contractResponse.account || contractResponse.contract;
return {
address: contractResponse[getterProperty].address,
network: Number.parseInt(contractResponse[getterProperty].network_id)
address: walletDetails.address,
network: Number.parseInt(walletDetails.network_id)
};

@@ -579,3 +610,3 @@ }

address: wallet.address,
display_name: wallet.displayName,
display_name: wallet.displayName || "",
network_ids: [

@@ -609,3 +640,2 @@ `${wallet.network}`

return __async(this, null, function* () {
var _a;
try {

@@ -627,3 +657,3 @@ const { data } = yield this.apiV2.get(`

});
if (!(data == null ? void 0 : data.accounts) || ((_a = data == null ? void 0 : data.accounts) == null ? void 0 : _a.length) === 0) {
if (!(data == null ? void 0 : data.accounts) || !data.accounts[0]) {
throw new NotFoundError(`Wallet with address ${address} not found`);

@@ -658,2 +688,5 @@ }

}, walletData))));
if (!data[0]) {
throw new InvalidResponseError(`Invalid response received while trying to create a wallet ${address}`);
}
return mapWalletResponseToWalletModel(data[0]);

@@ -807,14 +840,5 @@ } catch (error) {

// lib/errors/EncodingError.ts
var EncodingError = class extends GeneralError {
constructor(error) {
super(error);
__publicField(this, "status");
this.name = "EncodingError";
}
};
__name(EncodingError, "EncodingError");
// lib/executors/Simulator.ts
function mapToSimulationResult(simpleSimulationResponse) {
var _a;
return {

@@ -828,3 +852,3 @@ status: simpleSimulationResponse.status,

logs: simpleSimulationResponse.logs,
trace: simpleSimulationResponse.trace.map((trace) => __spreadProps(__spreadValues({}, trace), {
trace: (_a = simpleSimulationResponse.trace) == null ? void 0 : _a.map((trace) => __spreadProps(__spreadValues({}, trace), {
error_messages: trace.error_reason

@@ -852,14 +876,15 @@ }))

stateOverrides: Object.keys(overrides).map((contractAddress) => {
var _a;
const cAddress = contractAddress.toLowerCase();
return {
[cAddress]: overrides[contractAddress].state
[cAddress]: (_a = overrides[contractAddress]) == null ? void 0 : _a.state
};
}).map((x) => {
const y = {};
Object.keys(x).forEach((key) => {
y[key] = {
value: x[key]
}).map((addresses) => {
const mappedOverrides = {};
Object.keys(addresses).forEach((address) => {
mappedOverrides[address] = {
value: addresses[address]
};
});
return y;
return mappedOverrides;
}).reduce((acc, curr) => __spreadValues(__spreadValues({}, acc), curr))

@@ -870,3 +895,4 @@ };

return Object.keys(stateOverrides).map((address) => address.toLowerCase()).reduce((acc, curr) => {
acc[curr] = stateOverrides[curr].value;
var _a;
acc[curr] = (_a = stateOverrides[curr]) == null ? void 0 : _a.value;
return acc;

@@ -880,17 +906,19 @@ }, {});

return Object.keys(overrides).map((address) => address.toLowerCase()).reduce((acc, curr) => {
var _a, _b, _c;
acc[curr] = {};
var _a, _b, _c, _d, _e, _f;
const currentOverride = {};
if (encodedStateOverrides && encodedStateOverrides[curr]) {
acc[curr].state_diff = encodedStateOverrides[curr];
currentOverride.state_diff = encodedStateOverrides[curr];
}
if ((_a = overrides[curr]) == null ? void 0 : _a.nonce) {
acc[curr].nonce = overrides[curr].nonce;
currentOverride.nonce = (_b = overrides[curr]) == null ? void 0 : _b.nonce;
}
if ((_b = overrides[curr]) == null ? void 0 : _b.code) {
acc[curr].code = overrides[curr].code;
if ((_c = overrides[curr]) == null ? void 0 : _c.code) {
currentOverride.code = (_d = overrides[curr]) == null ? void 0 : _d.code;
}
if ((_c = overrides[curr]) == null ? void 0 : _c.balance) {
acc[curr].balance = overrides[curr].balance;
if ((_e = overrides[curr]) == null ? void 0 : _e.balance) {
currentOverride.balance = (_f = overrides[curr]) == null ? void 0 : _f.balance;
}
return acc;
return __spreadProps(__spreadValues({}, acc), {
[curr]: currentOverride
});
}, {});

@@ -957,3 +985,3 @@ }

} catch (error) {
if (error.response && error.response.data && error.response.data.error) {
if (isTenderlyAxiosError(error)) {
throw new EncodingError(error.response.data.error);

@@ -993,3 +1021,3 @@ }

* @param {object} simulationParams.overrides - Overrides for the transaction simulation.
* @returns {Promise<SimulationResult>} - A Promise that resolves to a simulation result object.
* @returns {Promise<SimulationOutput>} - A Promise that resolves to a simulation output.
*/

@@ -1017,3 +1045,3 @@ simulateTransaction(_0) {

* @param {number} params.blockNumber - The block number for the simulation bundle.
* @returns {Promise<SimulationResult[]>} - A Promise that resolves to an array of simulation result objects.
* @returns {Promise<SimulationOutput[]>} - A Promise that resolves to an array of simulation result objects.
*/

@@ -1042,3 +1070,3 @@ simulateBundle(_0) {

// lib/sdkVersion.ts
var TENDERLY_SDK_VERSION = "0.1.15";
var TENDERLY_SDK_VERSION = "0.2.0";

@@ -1133,3 +1161,3 @@ // lib/core/ApiClient.ts

__name(ApiClientProvider, "ApiClientProvider");
__publicField(ApiClientProvider, "instance", null);
__publicField(ApiClientProvider, "instance");

@@ -1140,3 +1168,3 @@ // lib/core/Tenderly.ts

* The main class of the Tenderly SDK
* Instantiate this class with your config and you're ready to go
* Instantiate this class with your config, and you're ready to go
* @example

@@ -1168,15 +1196,15 @@ * const tenderly = new Tenderly({

this.configuration = configuration;
const apiProvider = new ApiClientProvider({
this.apiClientProvider = new ApiClientProvider({
apiKey: configuration.accessKey
});
this.simulator = new Simulator({
apiProvider,
apiProvider: this.apiClientProvider,
configuration
});
this.contracts = new ContractRepository({
apiProvider,
apiProvider: this.apiClientProvider,
configuration
});
this.wallets = new WalletRepository({
apiProvider,
apiProvider: this.apiClientProvider,
configuration

@@ -1252,11 +1280,23 @@ });

})(Network || (Network = {}));
// lib/helpers.ts
function getEnvironmentVariables() {
return process.env;
}
__name(getEnvironmentVariables, "getEnvironmentVariables");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ApiError,
BytecodeMismatchError,
CompilationError,
EncodingError,
GeneralError,
InvalidArgumentsError,
InvalidResponseError,
Network,
NotFoundError,
Tenderly,
UnexpectedVerificationError,
getEnvironmentVariables,
handleError
});
{
"name": "@tenderly/sdk",
"version": "0.1.15",
"version": "0.2.0",
"description": "Tenderly SDK",

@@ -25,2 +25,3 @@ "main": "dist/index.js",

"@types/jest": "^29.4.0",
"@types/node": "^20.4.8",
"@typescript-eslint/eslint-plugin": "^5.53.0",

@@ -32,2 +33,3 @@ "@typescript-eslint/parser": "^5.53.0",

"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unused-imports": "^3.0.0",
"ethers": "^6.2.0",

@@ -34,0 +36,0 @@ "husky": "^8.0.3",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc