Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@userfeeds/web3-store

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@userfeeds/web3-store - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

682

dist/index.js

@@ -38,3 +38,31 @@ (function (global, factory) {

const networkMapping = {
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
var networkMapping = {
1: 'ethereum',

@@ -46,6 +74,14 @@ 3: 'ropsten',

function getCurrentNetworkName(web3Instance) {
return __awaiter(this, void 0, void 0, function* () {
throwIfNotConnected(web3Instance);
const networkId = yield web3Instance.eth.net.getId();
return networkMapping[networkId];
return __awaiter(this, void 0, void 0, function () {
var networkId;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
throwIfNotConnected(web3Instance);
return [4 /*yield*/, web3Instance.eth.net.getId()];
case 1:
networkId = _a.sent();
return [2 /*return*/, networkMapping[networkId]];
}
});
});

@@ -58,34 +94,42 @@ }

function throwIfNotConnected(web3Instance) {
return __awaiter(this, void 0, void 0, function* () {
if (!(yield web3Instance.eth.net.isListening())) {
throw Error('web3 is not connected');
}
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3Instance.eth.net.isListening()];
case 1:
if (!(_a.sent())) {
throw Error('web3 is not connected');
}
return [2 /*return*/];
}
});
});
}
const BN = utils.BN;
const MAX_VALUE_256 = new BN(2)
var BN = utils.BN;
var MAX_VALUE_256 = new BN(2)
.pow(new BN(256))
.subn(1)
.toString(10);
const fromWeiToString = (wei, decimals, decimalFigures = 3) => {
const counter = new BN(typeof wei === 'number' ? wei.toFixed(0) : wei);
var fromWeiToString = function (wei, decimals, decimalFigures) {
if (decimalFigures === void 0) { decimalFigures = 3; }
var counter = new BN(typeof wei === 'number' ? wei.toFixed(0) : wei);
if (counter.eqn(0)) {
return '0';
}
const divider = new BN(10).pow(new BN(decimals));
const div = new BN(counter).div(divider).toString(10);
const mod = new BN(counter)
var divider = new BN(10).pow(new BN(decimals));
var div = new BN(counter).div(divider).toString(10);
var mod = new BN(counter)
.mod(divider)
.toString(10, decimals)
.slice(0, decimalFigures);
return `${div}.${mod}`;
return div + "." + mod;
};
const toWei = (amout, decimals) => {
const parsedDecimals = typeof decimals !== 'number'
var toWei = function (amout, decimals) {
var parsedDecimals = typeof decimals !== 'number'
? parseInt(decimals, 10) // ToDo check this casting
: decimals;
const multiplier = new BN(10).pow(new BN(parsedDecimals));
const [integral, rawFraction = ''] = amout.toString().split('.');
const fraction = rawFraction.padEnd(parsedDecimals, '0').slice(0, parsedDecimals);
var multiplier = new BN(10).pow(new BN(parsedDecimals));
var _a = amout.toString().split('.'), integral = _a[0], _b = _a[1], rawFraction = _b === void 0 ? '' : _b;
var fraction = rawFraction.padEnd(parsedDecimals, '0').slice(0, parsedDecimals);
return new BN(integral)

@@ -97,3 +141,3 @@ .mul(multiplier)

const withoutValueTransferContractAddressMapping = {
var withoutValueTransferContractAddressMapping = {
ethereum: '0xFd74f0ce337fC692B8c124c094c1386A14ec7901',

@@ -104,3 +148,3 @@ rinkeby: '0xC5De286677AC4f371dc791022218b1c13B72DbBd',

};
const valueTransferContractAddressMapping = {
var valueTransferContractAddressMapping = {
ethereum: '0x70B610F7072E742d4278eC55C02426Dbaaee388C',

@@ -111,3 +155,3 @@ rinkeby: '0x00034B8397d9400117b4298548EAa59267953F8c',

};
const tokenTransferContractAddressMapping = {
var tokenTransferContractAddressMapping = {
ethereum: '0xfF8A1BA752fE5df494B02D77525EC6Fa76cecb93',

@@ -119,11 +163,11 @@ rinkeby: '0xBd2A0FF74dE98cFDDe4653c610E0E473137534fB',

function getContractWithoutValueTransfer(web3Instance, networkName) {
const contractAddress = withoutValueTransferContractAddressMapping[networkName];
var contractAddress = withoutValueTransferContractAddressMapping[networkName];
if (!contractAddress) {
throw new Error('Contract is not available');
}
const contract = new web3Instance.eth.Contract(withoutValueTransferAbi, contractAddress);
var contract = new web3Instance.eth.Contract(withoutValueTransferAbi, contractAddress);
contract.setProvider(web3Instance.currentProvider); // ToDo because of bug in web3 1.0.0-beta26
return contract;
}
const withoutValueTransferAbi = [
var withoutValueTransferAbi = [
{

@@ -139,11 +183,11 @@ constant: false,

function getContractValueTransfer(web3Instance, networkName) {
const contractAddress = valueTransferContractAddressMapping[networkName];
var contractAddress = valueTransferContractAddressMapping[networkName];
if (!contractAddress) {
throw new Error('Contract is not available');
}
const contract = new web3Instance.eth.Contract(valueTransferAbi, contractAddress);
var contract = new web3Instance.eth.Contract(valueTransferAbi, contractAddress);
contract.setProvider(web3Instance.currentProvider); // ToDo because of bug in web3 1.0.0-beta26
return contract;
}
const valueTransferAbi = [
var valueTransferAbi = [
{

@@ -159,7 +203,7 @@ constant: false,

function getContractTokenTransfer(web3Instance, networkName) {
const contractAddress = tokenTransferContractAddressMapping[networkName];
var contractAddress = tokenTransferContractAddressMapping[networkName];
if (!contractAddress) {
throw new Error('Contract is not available');
}
const contract = new web3Instance.eth.Contract(tokenTransferAbi, contractAddress);
var contract = new web3Instance.eth.Contract(tokenTransferAbi, contractAddress);
contract.setProvider(web3Instance.currentProvider); // ToDo because of bug in web3 1.0.0-beta26

@@ -169,3 +213,3 @@ return contract;

function getContractTokenTransferAddress(networkName) {
const contractAddress = tokenTransferContractAddressMapping[networkName];
var contractAddress = tokenTransferContractAddressMapping[networkName];
if (!contractAddress) {

@@ -176,3 +220,3 @@ throw new Error('Contract is not available');

}
const tokenTransferAbi = [
var tokenTransferAbi = [
{

@@ -193,7 +237,7 @@ constant: false,

function getErc20Contract(web3Instance, contractAddress) {
const contract = new web3Instance.eth.Contract(erc20abi, contractAddress);
var contract = new web3Instance.eth.Contract(erc20abi, contractAddress);
contract.setProvider(web3Instance.currentProvider); // ToDo because of bug in web3 1.0.0-beta26
return contract;
}
const erc20abi = [
var erc20abi = [
{

@@ -250,12 +294,19 @@ constant: false,

function erc20ContractApprove(web3Instance, contractAddress, spender, value) {
return __awaiter(this, void 0, void 0, function* () {
const [from] = yield getAccounts(web3Instance);
const contract = getErc20Contract(web3Instance, contractAddress);
return {
promiEvent: contract.methods.approve(spender, value).send({ from }),
};
return __awaiter(this, void 0, void 0, function () {
var from, contract;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getAccounts(web3Instance)];
case 1:
from = (_a.sent())[0];
contract = getErc20Contract(web3Instance, contractAddress);
return [2 /*return*/, {
promiEvent: contract.methods.approve(spender, value).send({ from: from }),
}];
}
});
});
}
function erc20ContractDecimals(web3Instance, contractAddress) {
const contract = getErc20Contract(web3Instance, contractAddress);
var contract = getErc20Contract(web3Instance, contractAddress);
return contract.methods.decimals().call();

@@ -265,81 +316,120 @@ }

function sendClaimWithoutValueTransfer(web3Instance, claim) {
return __awaiter(this, void 0, void 0, function* () {
const networkName = yield getCurrentNetworkName(web3Instance);
const [from] = yield getAccounts(web3Instance);
const contract = getContractWithoutValueTransfer(web3Instance, networkName);
return {
promiEvent: contract.methods.post(JSON.stringify(claim)).send({ from }),
};
return __awaiter(this, void 0, void 0, function () {
var networkName, from, contract;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getCurrentNetworkName(web3Instance)];
case 1:
networkName = _a.sent();
return [4 /*yield*/, getAccounts(web3Instance)];
case 2:
from = (_a.sent())[0];
contract = getContractWithoutValueTransfer(web3Instance, networkName);
return [2 /*return*/, {
promiEvent: contract.methods.post(JSON.stringify(claim)).send({ from: from }),
}];
}
});
});
}
function sendClaimValueTransfer(web3Instance, address, value, claim) {
return __awaiter(this, void 0, void 0, function* () {
const networkName = yield getCurrentNetworkName(web3Instance);
const [from] = yield getAccounts(web3Instance);
const contract = getContractValueTransfer(web3Instance, networkName);
return {
promiEvent: contract.methods
.post(address, JSON.stringify(claim))
.send({ from, value: toWei(value, 18) }),
};
return __awaiter(this, void 0, void 0, function () {
var networkName, from, contract;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getCurrentNetworkName(web3Instance)];
case 1:
networkName = _a.sent();
return [4 /*yield*/, getAccounts(web3Instance)];
case 2:
from = (_a.sent())[0];
contract = getContractValueTransfer(web3Instance, networkName);
return [2 /*return*/, {
promiEvent: contract.methods.post(address, JSON.stringify(claim)).send({ from: from, value: toWei(value, 18) }),
}];
}
});
});
}
function approveUserfeedsContractTokenTransfer(web3Instance, tokenContractAddress, value) {
return __awaiter(this, void 0, void 0, function* () {
const networkName = yield getCurrentNetworkName(web3Instance);
const spenderContractAddress = getContractTokenTransferAddress(networkName);
return erc20ContractApprove(web3Instance, tokenContractAddress, spenderContractAddress, value);
return __awaiter(this, void 0, void 0, function () {
var networkName, spenderContractAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getCurrentNetworkName(web3Instance)];
case 1:
networkName = _a.sent();
spenderContractAddress = getContractTokenTransferAddress(networkName);
return [2 /*return*/, erc20ContractApprove(web3Instance, tokenContractAddress, spenderContractAddress, value)];
}
});
});
}
function sendClaimTokenTransferImpl(web3Instance, address, token, value, claim) {
return __awaiter(this, void 0, void 0, function* () {
const networkName = yield getCurrentNetworkName(web3Instance);
const [from] = yield getAccounts(web3Instance);
const contract = getContractTokenTransfer(web3Instance, networkName);
return {
promiEvent: contract.methods
.post(address, token, value, JSON.stringify(claim))
.send({ from }),
};
return __awaiter(this, void 0, void 0, function () {
var networkName, from, contract;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getCurrentNetworkName(web3Instance)];
case 1:
networkName = _a.sent();
return [4 /*yield*/, getAccounts(web3Instance)];
case 2:
from = (_a.sent())[0];
contract = getContractTokenTransfer(web3Instance, networkName);
return [2 /*return*/, {
promiEvent: contract.methods.post(address, token, value, JSON.stringify(claim)).send({ from: from }),
}];
}
});
});
}
function sendClaimTokenTransfer(web3Instance, recipientAddress, token, value, claim) {
return __awaiter(this, void 0, void 0, function* () {
const decimals = yield erc20ContractDecimals(web3Instance, token);
const tokenWei = toWei(value, decimals);
return sendClaimTokenTransferImpl(web3Instance, recipientAddress, token, tokenWei, claim);
return __awaiter(this, void 0, void 0, function () {
var decimals, tokenWei;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, erc20ContractDecimals(web3Instance, token)];
case 1:
decimals = _a.sent();
tokenWei = toWei(value, decimals);
return [2 /*return*/, sendClaimTokenTransferImpl(web3Instance, recipientAddress, token, tokenWei, claim)];
}
});
});
}
const BN$1 = utils.BN;
class Web3Store {
constructor(injectedWeb3, Erc20Ctor, widgetSettings, initialState = {
currentProvider: undefined,
isListening: undefined,
allowance: undefined,
}) {
var BN$1 = utils.BN;
var Web3Store = /** @class */ (function () {
function Web3Store(injectedWeb3, Erc20Ctor, widgetSettings, initialState) {
if (initialState === void 0) { initialState = {
currentProvider: undefined,
isListening: undefined,
allowance: undefined,
}; }
var _this = this;
this.injectedWeb3 = injectedWeb3;
this.Erc20Ctor = Erc20Ctor;
this.widgetSettings = widgetSettings;
this.sendTokenClaim = (claim, recipientAddress, value) => {
this.sendTokenClaim = function (claim, recipientAddress, value) {
if (value === undefined) {
return sendClaimWithoutValueTransfer(this.injectedWeb3, claim);
return sendClaimWithoutValueTransfer(_this.injectedWeb3, claim);
}
else {
return sendClaimTokenTransfer(this.injectedWeb3, recipientAddress, this.token, value, claim);
return sendClaimTokenTransfer(_this.injectedWeb3, recipientAddress, _this.token, value, claim);
}
};
this.sendEthereumClaim = (claim, recipientAddress, value) => {
this.sendEthereumClaim = function (claim, recipientAddress, value) {
if (value === undefined) {
return sendClaimWithoutValueTransfer(this.injectedWeb3, claim);
return sendClaimWithoutValueTransfer(_this.injectedWeb3, claim);
}
else {
return sendClaimValueTransfer(this.injectedWeb3, recipientAddress, value, claim);
return sendClaimValueTransfer(_this.injectedWeb3, recipientAddress, value, claim);
}
};
this.shouldApprove = (value) => {
return !!this.token && new BN$1(this.allowance).lt(new BN$1(value));
this.shouldApprove = function (value) {
return !!_this.token && new BN$1(_this.allowance).lt(new BN$1(value));
};
this.approve = (value) => {
return approveUserfeedsContractTokenTransfer(this.injectedWeb3, this.token, value);
this.approve = function (value) {
return approveUserfeedsContractTokenTransfer(_this.injectedWeb3, _this.token, value);
};

@@ -355,17 +445,17 @@ this.currentProvider = initialState.currentProvider;

}
startUpdatingInjectedWeb3State() {
Web3Store.prototype.startUpdatingInjectedWeb3State = function () {
this.updateInjectedWeb3State();
clearInterval(this.updateInjectedWeb3StateIntervalId);
this.updateInjectedWeb3StateIntervalId = setInterval(this.updateInjectedWeb3State, 1000);
}
startUpdatingTokenDetails() {
};
Web3Store.prototype.startUpdatingTokenDetails = function () {
this.updateTokenDetails();
clearInterval(this.updateTokenDetailsIntervalId);
this.updateTokenDetailsIntervalId = setInterval(this.updateTokenDetails, 1000);
}
stopUpdating() {
};
Web3Store.prototype.stopUpdating = function () {
clearInterval(this.updateInjectedWeb3StateIntervalId);
clearInterval(this.updateTokenDetailsIntervalId);
}
tokenRequests() {
};
Web3Store.prototype.tokenRequests = function () {
if (this.token) {

@@ -389,166 +479,240 @@ return [

}
}
updateTokenDetails() {
return __awaiter(this, void 0, void 0, function* () {
const [decimals, symbol, name, balance, allowance] = yield Promise.all(this.tokenRequests());
this.decimals = decimals;
this.symbol = symbol;
this.name = name;
this.balance = balance;
this.allowance = allowance;
};
Web3Store.prototype.updateTokenDetails = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, decimals, symbol, name, balance, allowance;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, Promise.all(this.tokenRequests())];
case 1:
_a = _b.sent(), decimals = _a[0], symbol = _a[1], name = _a[2], balance = _a[3], allowance = _a[4];
this.decimals = decimals;
this.symbol = symbol;
this.name = name;
this.balance = balance;
this.allowance = allowance;
return [2 /*return*/];
}
});
});
}
updateInjectedWeb3State() {
return __awaiter(this, void 0, void 0, function* () {
this.currentProvider = this.injectedWeb3.currentProvider;
};
Web3Store.prototype.updateInjectedWeb3State = function () {
return __awaiter(this, void 0, void 0, function () {
var currentBlock_1, _a, isListening, networkId, accounts, currentBlock, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
this.currentProvider = this.injectedWeb3.currentProvider;
if (!!this.currentProvider) return [3 /*break*/, 2];
return [4 /*yield*/, this.erc20.currentBlock()];
case 1:
currentBlock_1 = _c.sent();
this.blockNumber = currentBlock_1;
return [2 /*return*/];
case 2: return [4 /*yield*/, Promise.all([
this.injectedWeb3.eth.net.isListening(),
this.injectedWeb3.eth.net.getId(),
this.injectedWeb3.eth.getAccounts(),
this.injectedWeb3.eth.getBlockNumber(),
])];
case 3:
_a = _c.sent(), isListening = _a[0], networkId = _a[1], accounts = _a[2], currentBlock = _a[3];
this.isListening = isListening;
this.injectedWeb3ActiveNetwork = networkMapping[networkId];
this.currentAccount = accounts[0];
if (!(this.network === this.injectedWeb3ActiveNetwork)) return [3 /*break*/, 4];
this.blockNumber = currentBlock;
return [3 /*break*/, 6];
case 4:
_b = this;
return [4 /*yield*/, this.erc20.currentBlock()];
case 5:
_b.blockNumber = _c.sent();
_c.label = 6;
case 6: return [2 /*return*/];
}
});
});
};
Object.defineProperty(Web3Store.prototype, "erc20", {
get: function () {
return new this.Erc20Ctor(this.network, this.token, this.currentAccount);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "activeNetwork", {
get: function () {
return this.ready ? this.injectedWeb3ActiveNetwork : undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "reason", {
get: function () {
if (!this.currentProvider) {
const currentBlock = yield this.erc20.currentBlock();
this.blockNumber = currentBlock;
return;
return 'Install Metamask to unlock all the features';
}
const [isListening, networkId, accounts, currentBlock] = yield Promise.all([
this.injectedWeb3.eth.net.isListening(),
this.injectedWeb3.eth.net.getId(),
this.injectedWeb3.eth.getAccounts(),
this.injectedWeb3.eth.getBlockNumber(),
]);
this.isListening = isListening;
this.injectedWeb3ActiveNetwork = networkMapping[networkId];
this.currentAccount = accounts[0];
if (this.network === this.injectedWeb3ActiveNetwork) {
this.blockNumber = currentBlock;
else if (!this.currentAccount) {
return 'Unlock your wallet to unlock all the features';
}
else {
this.blockNumber = yield this.erc20.currentBlock();
else if (this.activeNetwork !== this.network) {
return "Switch to " + this.network + " network to unlock all the features";
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "unlocked", {
get: function () {
return !!(this.ready && this.currentAccount);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "ready", {
get: function () {
return !!(this.currentProvider && this.isListening);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "network", {
get: function () {
return this.widgetSettings.asset.split(':')[0];
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "token", {
get: function () {
return this.widgetSettings.asset.split(':')[1];
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "balanceWithDecimalPoint", {
get: function () {
return this.balance !== null && this.balance !== undefined
? fromWeiToString(this.balance, this.decimals)
: undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "allowanceWithDecimalPoint", {
get: function () {
return this.allowance !== null && this.allowance !== undefined
? fromWeiToString(this.allowance, this.decimals)
: undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Web3Store.prototype, "sendClaim", {
get: function () {
return this.token ? this.sendTokenClaim : this.sendEthereumClaim;
},
enumerable: true,
configurable: true
});
Web3Store.prototype.transactionReceipt = function (transactionHash) {
return __awaiter(this, void 0, void 0, function () {
var response, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.injectedWeb3.eth.getTransactionReceipt(transactionHash)];
case 1:
response = _a.sent();
return [2 /*return*/, response];
case 2:
e_1 = _a.sent();
return [2 /*return*/, undefined];
case 3: return [2 /*return*/];
}
});
});
}
get erc20() {
return new this.Erc20Ctor(this.network, this.token, this.currentAccount);
}
get activeNetwork() {
return this.ready ? this.injectedWeb3ActiveNetwork : undefined;
}
get reason() {
if (!this.currentProvider) {
return 'Install Metamask to unlock all the features';
}
else if (!this.currentAccount) {
return 'Unlock your wallet to unlock all the features';
}
else if (this.activeNetwork !== this.network) {
return `Switch to ${this.network} network to unlock all the features`;
}
}
get unlocked() {
return !!(this.ready && this.currentAccount);
}
get ready() {
return !!(this.currentProvider && this.isListening);
}
get network() {
return this.widgetSettings.asset.split(':')[0];
}
get token() {
return this.widgetSettings.asset.split(':')[1];
}
get balanceWithDecimalPoint() {
return this.balance !== null && this.balance !== undefined
? fromWeiToString(this.balance, this.decimals)
: undefined;
}
get allowanceWithDecimalPoint() {
return this.allowance !== null && this.allowance !== undefined
? fromWeiToString(this.allowance, this.decimals)
: undefined;
}
get sendClaim() {
return this.token ? this.sendTokenClaim : this.sendEthereumClaim;
}
transactionReceipt(transactionHash) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.injectedWeb3.eth.getTransactionReceipt(transactionHash);
return response;
}
catch (e) {
return undefined;
}
});
}
get getTransactionReceipt() {
return this.ready && this.network === this.injectedWeb3ActiveNetwork
? this.transactionReceipt
: this.erc20.transactionReceipt;
}
}
__decorate([
mobx.observable
], Web3Store.prototype, "currentProvider", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "isListening", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "injectedWeb3ActiveNetwork", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "currentAccount", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "blockNumber", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "decimals", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "symbol", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "name", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "balance", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "allowance", void 0);
__decorate([
mobx.action.bound
], Web3Store.prototype, "updateTokenDetails", null);
__decorate([
mobx.action.bound
], Web3Store.prototype, "updateInjectedWeb3State", null);
__decorate([
mobx.computed
], Web3Store.prototype, "erc20", null);
__decorate([
mobx.computed
], Web3Store.prototype, "activeNetwork", null);
__decorate([
mobx.computed
], Web3Store.prototype, "reason", null);
__decorate([
mobx.computed
], Web3Store.prototype, "unlocked", null);
__decorate([
mobx.computed
], Web3Store.prototype, "ready", null);
__decorate([
mobx.computed
], Web3Store.prototype, "network", null);
__decorate([
mobx.computed
], Web3Store.prototype, "token", null);
__decorate([
mobx.computed
], Web3Store.prototype, "balanceWithDecimalPoint", null);
__decorate([
mobx.computed
], Web3Store.prototype, "allowanceWithDecimalPoint", null);
__decorate([
mobx.computed
], Web3Store.prototype, "sendClaim", null);
__decorate([
mobx.computed
], Web3Store.prototype, "getTransactionReceipt", null);
};
Object.defineProperty(Web3Store.prototype, "getTransactionReceipt", {
get: function () {
return this.ready && this.network === this.injectedWeb3ActiveNetwork
? this.transactionReceipt
: this.erc20.transactionReceipt;
},
enumerable: true,
configurable: true
});
__decorate([
mobx.observable
], Web3Store.prototype, "currentProvider", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "isListening", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "injectedWeb3ActiveNetwork", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "currentAccount", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "blockNumber", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "decimals", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "symbol", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "name", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "balance", void 0);
__decorate([
mobx.observable
], Web3Store.prototype, "allowance", void 0);
__decorate([
mobx.action.bound
], Web3Store.prototype, "updateTokenDetails", null);
__decorate([
mobx.action.bound
], Web3Store.prototype, "updateInjectedWeb3State", null);
__decorate([
mobx.computed
], Web3Store.prototype, "erc20", null);
__decorate([
mobx.computed
], Web3Store.prototype, "activeNetwork", null);
__decorate([
mobx.computed
], Web3Store.prototype, "reason", null);
__decorate([
mobx.computed
], Web3Store.prototype, "unlocked", null);
__decorate([
mobx.computed
], Web3Store.prototype, "ready", null);
__decorate([
mobx.computed
], Web3Store.prototype, "network", null);
__decorate([
mobx.computed
], Web3Store.prototype, "token", null);
__decorate([
mobx.computed
], Web3Store.prototype, "balanceWithDecimalPoint", null);
__decorate([
mobx.computed
], Web3Store.prototype, "allowanceWithDecimalPoint", null);
__decorate([
mobx.computed
], Web3Store.prototype, "sendClaim", null);
__decorate([
mobx.computed
], Web3Store.prototype, "getTransactionReceipt", null);
return Web3Store;
}());

@@ -555,0 +719,0 @@ return Web3Store;

{
"name": "@userfeeds/web3-store",
"version": "0.0.13",
"version": "0.0.14",
"description": "",
"main": "dist/index.js",
"keywords": [],
"homepage": "https://github.com/Userfeeds/components/tree/master/packages/web3-store",
"license": "Unlicense",
"author": "Userfeeds",
"main": "./dist/index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"peerDependencies": {
"@userfeeds/core": "^0.0.1",
"@userfeeds/core": "^0.1.2",
"@userfeeds/utils": "^0.0.1",

@@ -13,0 +14,0 @@ "mobx": "^4.1.0"

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