Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
chainId: 0
};
// Legacy unsigned transaction
if (transaction.length === 6) {
return tx;
}
try {
tx.v = bignumber_1.BigNumber.from(transaction[6]).toNumber();
}
catch (error) {
console.log(error);
return tx;
}
tx.r = bytes_1.hexZeroPad(transaction[7], 32);
tx.s = bytes_1.hexZeroPad(transaction[8], 32);
if (bignumber_1.BigNumber.from(tx.r).isZero() && bignumber_1.BigNumber.from(tx.s).isZero()) {
// EIP-155 unsigned transaction
tx.chainId = tx.v;
tx.v = 0;
}
else {
// Signed Tranasaction
tx.chainId = Math.floor((tx.v - 35) / 2);
if (tx.chainId < 0) {
tx.chainId = 0;
}
var recoveryParam = tx.v - 27;
var raw = transaction.slice(0, 6);
if (tx.chainId !== 0) {
raw.push(bytes_1.hexlify(tx.chainId));
raw.push("0x");
raw.push("0x");
Writer.prototype._getValue = function (value) {
var bytes = bytes_1.arrayify(bignumber_1.BigNumber.from(value));
if (bytes.length > this.wordSize) {
logger.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, {
length: this.wordSize,
offset: bytes.length
});
}
if (bytes.length % this.wordSize) {
bytes = bytes_1.concat([this._padding.slice(bytes.length % this.wordSize), bytes]);
}
return bytes;
};
// BigNumberish items; padded on the left to wordSize
Object.defineProperty(exports, "__esModule", { value: true });
var bignumber_1 = require("@ethersproject/bignumber");
var AddressZero = "0x0000000000000000000000000000000000000000";
exports.AddressZero = AddressZero;
var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
exports.HashZero = HashZero;
// NFKD (decomposed)
//const EtherSymbol = "\uD835\uDF63";
// NFKC (composed)
var EtherSymbol = "\u039e";
exports.EtherSymbol = EtherSymbol;
var NegativeOne = bignumber_1.BigNumber.from(-1);
exports.NegativeOne = NegativeOne;
var Zero = bignumber_1.BigNumber.from(0);
exports.Zero = Zero;
var One = bignumber_1.BigNumber.from(1);
exports.One = One;
var Two = bignumber_1.BigNumber.from(2);
exports.Two = Two;
var WeiPerEther = bignumber_1.BigNumber.from("1000000000000000000");
exports.WeiPerEther = WeiPerEther;
var MaxUint256 = bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
exports.MaxUint256 = MaxUint256;
Formatter.prototype.number = function (number) {
return bignumber_1.BigNumber.from(number).toNumber();
};
// Strict! Used on input.
return [4 /*yield*/, this.call({
to: resolverAddress,
data: ("0x691f3431" + hash_1.namehash(reverseName).substring(2))
})];
case 4:
bytes = _a.apply(void 0, [_b.sent()]);
// Strip off the dynamic string pointer (0x20)
if (bytes.length < 32 || !bignumber_1.BigNumber.from(bytes.slice(0, 32)).eq(32)) {
return [2 /*return*/, null];
}
bytes = bytes.slice(32);
// Not a length-prefixed string
if (bytes.length < 32) {
return [2 /*return*/, null];
}
length = bignumber_1.BigNumber.from(bytes.slice(0, 32)).toNumber();
bytes = bytes.slice(32);
// Length longer than available data
if (length > bytes.length) {
return [2 /*return*/, null];
}
name = strings_1.toUtf8String(bytes.slice(0, length));
return [4 /*yield*/, this.resolveName(name)];
case 5:
addr = _b.sent();
if (addr != address) {
return [2 /*return*/, null];
}
return [2 /*return*/, name];
}
});
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var basex_1 = require("@ethersproject/basex");
var bytes_1 = require("@ethersproject/bytes");
var bignumber_1 = require("@ethersproject/bignumber");
var strings_1 = require("@ethersproject/strings");
var pbkdf2_1 = require("@ethersproject/pbkdf2");
var properties_1 = require("@ethersproject/properties");
var signing_key_1 = require("@ethersproject/signing-key");
var sha2_1 = require("@ethersproject/sha2");
var transactions_1 = require("@ethersproject/transactions");
var wordlists_1 = require("@ethersproject/wordlists");
var logger_1 = require("@ethersproject/logger");
var _version_1 = require("./_version");
var logger = new logger_1.Logger(_version_1.version);
var N = bignumber_1.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
// "Bitcoin seed"
var MasterSecret = strings_1.toUtf8Bytes("Bitcoin seed");
var HardenedBit = 0x80000000;
// Returns a byte with the MSB bits set
function getUpperMask(bits) {
return ((1 << bits) - 1) << (8 - bits);
}
// Returns a byte with the LSB bits set
function getLowerMask(bits) {
return (1 << bits) - 1;
}
function bytes32(value) {
return bytes_1.hexZeroPad(bytes_1.hexlify(value), 32);
}
function base58check(data) {
return basex_1.Base58.encode(bytes_1.concat([data, bytes_1.hexDataSlice(sha2_1.sha256(sha2_1.sha256(data)), 0, 4)]));
reverseName = address.substring(2).toLowerCase() + ".addr.reverse";
return [4 /*yield*/, this._getResolver(reverseName)];
case 3:
resolverAddress = _b.sent();
if (!resolverAddress) {
return [2 /*return*/, null];
}
_a = bytes_1.arrayify;
return [4 /*yield*/, this.call({
to: resolverAddress,
data: ("0x691f3431" + hash_1.namehash(reverseName).substring(2))
})];
case 4:
bytes = _a.apply(void 0, [_b.sent()]);
// Strip off the dynamic string pointer (0x20)
if (bytes.length < 32 || !bignumber_1.BigNumber.from(bytes.slice(0, 32)).eq(32)) {
return [2 /*return*/, null];
}
bytes = bytes.slice(32);
// Not a length-prefixed string
if (bytes.length < 32) {
return [2 /*return*/, null];
}
length = bignumber_1.BigNumber.from(bytes.slice(0, 32)).toNumber();
bytes = bytes.slice(32);
// Length longer than available data
if (length > bytes.length) {
return [2 /*return*/, null];
}
name = strings_1.toUtf8String(bytes.slice(0, length));
return [4 /*yield*/, this.resolveName(name)];
case 5:
Interface.prototype.parseTransaction = function (tx) {
var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase());
if (!fragment) {
return null;
}
return new TransactionDescription({
args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)),
functionFragment: fragment,
name: fragment.name,
signature: fragment.format(),
sighash: this.getSighash(fragment),
value: bignumber_1.BigNumber.from(tx.value || "0"),
});
};
Interface.prototype.parseLog = function (log) {
function getContractAddress(transaction) {
var from = null;
try {
from = getAddress(transaction.from);
}
catch (error) {
logger.throwArgumentError("missing from address", "transaction", transaction);
}
var nonce = bytes_1.stripZeros(bytes_1.arrayify(bignumber_1.BigNumber.from(transaction.nonce).toHexString()));
return getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(rlp_1.encode([from, nonce])), 12));
}
exports.getContractAddress = getContractAddress;
ConstructorFragment.fromObject = function (value) {
if (ConstructorFragment.isConstructorFragment(value)) {
return value;
}
if (value.type !== "constructor") {
throw new Error("invalid constructor object - " + value.type);
}
var state = verifyState(value);
if (state.constant) {
throw new Error("constructor cannot be constant");
}
return new ConstructorFragment(_constructorGuard, {
type: value.type,
inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []),
payable: state.payable,
gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null)
});
};
ConstructorFragment.fromString = function (value) {