New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fairmint/safe-js

Package Overview
Dependencies
Maintainers
6
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fairmint/safe-js - npm Package Compare versions

Comparing version 1.4.3 to 1.4.4

2

package.json
{
"name": "@fairmint/safe-js",
"version": "1.4.3",
"version": "1.4.4",
"description": "Safe javascript library.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,4 +23,4 @@ const abi = require("@fairmint/cafe-abi/abi.json");

const [currencyAddress, whitelistAddress] = await Promise.all([
this.dat.currency(),
this.dat.whitelist(),
this.dat.currency().then(contract.converter),
this.dat.whitelist().then(contract.converter),
]);

@@ -43,8 +43,8 @@

] = await Promise.all([
this.currency.name(),
this.currency.symbol(),
this.currency.decimals(),
this.dat.decimals(),
this.dat.name(),
this.dat.symbol(),
this.currency.name().then(contract.converter),
this.currency.symbol().then(contract.converter),
this.currency.decimals().then(contract.converter),
this.dat.decimals().then(contract.converter),
this.dat.name().then(contract.converter),
this.dat.symbol().then(contract.converter),
]);

@@ -89,19 +89,19 @@

] = await Promise.all([
this.dat.initTrial(),
this.dat.initGoal(),
this.dat.initReserve(),
this.dat.equityCommitment(),
this.dat.maxGoal(),
this.dat.shareholdersPool(),
this.dat.fundraisingGoal(),
this.dat.totalSupply(),
this.dat.beneficiary(),
this.dat.control(),
this.dat.feeBasisPoints(),
this.dat.buySlopeNum(),
this.dat.buySlopeDen(),
this.dat.stakeholdersPoolIssued(),
this.dat.stakeholdersPoolAuthorized(),
this.dat.minInvestment(),
this.dat.state(),
this.dat.initTrial().then(contract.converter),
this.dat.initGoal().then(contract.converter),
this.dat.initReserve().then(contract.converter),
this.dat.equityCommitment().then(contract.converter),
this.dat.maxGoal().then(contract.converter),
this.dat.shareholdersPool().then(contract.converter),
this.dat.fundraisingGoal().then(contract.converter),
this.dat.totalSupply().then(contract.converter),
this.dat.beneficiary().then(contract.converter),
this.dat.control().then(contract.converter),
this.dat.feeBasisPoints().then(contract.converter),
this.dat.buySlopeNum().then(contract.converter),
this.dat.buySlopeDen().then(contract.converter),
this.dat.stakeholdersPoolIssued().then(contract.converter),
this.dat.stakeholdersPoolAuthorized().then(contract.converter),
this.dat.minInvestment().then(contract.converter),
this.dat.state().then(contract.converter),
]);

@@ -116,5 +116,5 @@

] = await Promise.all([
this.whitelist.owner(),
this.whitelist.lockupGranularity(),
this.whitelist.startDate(),
this.whitelist.owner().then(contract.converter),
this.whitelist.lockupGranularity().then(contract.converter),
this.whitelist.startDate().then(contract.converter),
]);

@@ -129,14 +129,14 @@

this.data.initTrial = contract.toBigNumber(initTrial).shiftedBy(
this.data.initTrial = new BigNumber(initTrial).shiftedBy(
-this.data.decimals
);
this.data.equityCommitment = contract.toBigNumber(equityCommitment).shiftedBy(-2);
this.data.maxGoal = contract.toBigNumber(maxGoal).shiftedBy(-this.data.decimals);
this.data.shareholdersPool = contract.toBigNumber(shareholdersPool).shiftedBy(
this.data.equityCommitment = new BigNumber(equityCommitment).shiftedBy(-2);
this.data.maxGoal = new BigNumber(maxGoal).shiftedBy(-this.data.decimals);
this.data.shareholdersPool = new BigNumber(shareholdersPool).shiftedBy(
-this.data.decimals
);
this.data.fundraisingGoal = contract.toBigNumber(fundraisingGoal).shiftedBy(
this.data.fundraisingGoal = new BigNumber(fundraisingGoal).shiftedBy(
-this.data.decimals
);
this.data.totalSupply = contract.toBigNumber(totalSupply).shiftedBy(
this.data.totalSupply = new BigNumber(totalSupply).shiftedBy(
-this.data.decimals

@@ -146,18 +146,18 @@ );

this.data.control = control;
this.data.fee = contract.toBigNumber(fee).div(constants.BASIS_POINTS_DEN);
this.data.minInvestment = contract.toBigNumber(minInvestment).shiftedBy(
this.data.fee = new BigNumber(fee).div(constants.BASIS_POINTS_DEN);
this.data.minInvestment = new BigNumber(minInvestment).shiftedBy(
-this.data.currency.decimals
);
this.data.state = constants.STATES[stateId];
this.data.buySlope = contract.toBigNumber(buySlopeNum)
this.data.buySlope = new BigNumber(buySlopeNum)
.shiftedBy(18 + 18 - this.data.currency.decimals)
.div(contract.toBigNumber(buySlopeDen));
this.data.stakeholdersIssued = contract.toBigNumber(stakeholdersIssued).shiftedBy(
.div(new BigNumber(buySlopeDen));
this.data.stakeholdersIssued = new BigNumber(stakeholdersIssued).shiftedBy(
-this.data.decimals
);
this.data.stakeholdersAuthorized = contract.toBigNumber(
this.data.stakeholdersAuthorized = new BigNumber(
stakeholdersAuthorized
).shiftedBy(-4);
this.data.initGoal = contract.toBigNumber(initGoal).shiftedBy(-this.data.decimals);
this.data.initReserve = contract.toBigNumber(initReserve).shiftedBy(
this.data.initGoal = new BigNumber(initGoal).shiftedBy(-this.data.decimals);
this.data.initReserve = new BigNumber(initReserve).shiftedBy(
-this.data.decimals

@@ -187,3 +187,3 @@ );

this.data.equityCommitment.times(
contract.toBigNumber(1).minus(this.data.stakeholdersAuthorized)
new BigNumber(1).minus(this.data.stakeholdersAuthorized)
)

@@ -199,3 +199,3 @@ );

this.data.equityCommitment.times(
contract.toBigNumber(1).minus(this.data.stakeholdersAuthorized)
new BigNumber(1).minus(this.data.stakeholdersAuthorized)
)

@@ -212,3 +212,3 @@ );

} else {
this.data.redeemPrice = contract.toBigNumber(0);
this.data.redeemPrice = new BigNumber(0);
}

@@ -229,3 +229,3 @@ }

this.provider.getBalance(accountAddress),
this.dat.balanceOf(accountAddress),
this.dat.balanceOf(accountAddress).then(contract.converter),
this.currency

@@ -239,4 +239,4 @@ ? this.currency.balanceOf(accountAddress)

]);
account.ethBalance = contract.toBigNumber(ethBalance).shiftedBy(-18);
account.tokenBalance = contract.toBigNumber(tokenBalance).shiftedBy(
account.ethBalance = new BigNumber(ethBalance).shiftedBy(-18);
account.tokenBalance = new BigNumber(tokenBalance).shiftedBy(
-this.data.decimals

@@ -258,6 +258,6 @@ );

} = await this.whitelist.getAuthorizedUserIdInfo(userId);
account.whitelist.jurisdictionId = jurisdictionId;
account.whitelist.totalTokensLocked = totalTokensLocked;
account.whitelist.startIndex = startIndex;
account.whitelist.endIndex = endIndex;
account.whitelist.jurisdictionId = new BigNumber(jurisdictionId);
account.whitelist.totalTokensLocked = new BigNumber(totalTokensLocked);
account.whitelist.startIndex = new BigNumber(startIndex);
account.whitelist.endIndex = new BigNumber(endIndex);
} else {

@@ -272,6 +272,6 @@ account.whitelist.jurisdictionId = "0";

if (currencyBalance) {
account.currencyBalance = contract.toBigNumber(currencyBalance).shiftedBy(
account.currencyBalance = new BigNumber(currencyBalance).shiftedBy(
-this.data.currency.decimals
);
account.allowance = contract.toBigNumber(allowance).shiftedBy(
account.allowance = new BigNumber(allowance).shiftedBy(
-this.data.currency.decimals

@@ -299,3 +299,3 @@ );

try {
this.data.version = await this.dat.version();
this.data.version = await this.dat.version().then(contract.converter);
} catch (error) {

@@ -317,6 +317,6 @@ // Reading version expected to fail for version 1

balance = await this.currency.balanceOf(accountAddress);
balance = contract.toBigNumber(balance).shiftedBy(-this.data.currency.decimals);
balance = new BigNumber(balance).shiftedBy(-this.data.currency.decimals);
} else {
balance = await this.provider.getBalance(accountAddress);
balance = contract.toBigNumber(balance).shiftedBy(-18);
balance = new BigNumber(balance).shiftedBy(-18);
}

@@ -330,3 +330,3 @@ return balance;

async getFairAllowance(owner, spender) {
return await this.dat.allowance(owner, spender);
return await this.dat.allowance(owner, spender).then(contract.converter);
}

@@ -338,3 +338,3 @@

async isWhitelistOperator(accountAddress) {
return this.whitelist.isOperator(accountAddress);
return this.whitelist.isOperator(accountAddress).then(contract.converter);
}

@@ -347,3 +347,3 @@

addWhitelistOperator(accountAddress) {
return this.whitelist.addOperator(accountAddress);
return this.whitelist.addOperator(accountAddress).then(contract.converter);
}

@@ -358,3 +358,3 @@

value ? value : constants.MAX_UINT
);
).then(contract.converter);
}

@@ -368,7 +368,7 @@ /**

value ? value : constants.MAX_UINT
);
).then(contract.converter).then(contract.converter);
}
authorizedWalletToUserId(walletAddress) {
return this.whitelist
.authorizedWalletToUserId(walletAddress);
.authorizedWalletToUserId(walletAddress).then(contract.converter);
}

@@ -391,3 +391,3 @@ getAuthorizedUserIdInfo(userId) {

setInvestorLimit(limit) {
return this.whitelist.setInvestorLimit(limit);
return this.whitelist.setInvestorLimit(limit).then(contract.converter);
}

@@ -398,3 +398,3 @@ setInvestorLimitForJurisdiction(jurisdictionIds, limits) {

limits
);
).then(contract.converter);
}

@@ -405,7 +405,7 @@ halt(jurisdictionIds, dues) {

resume(jurisdictionIds) {
return this.whitelist.resume(jurisdictionIds);
return this.whitelist.resume(jurisdictionIds).then(contract.converter);
}
async estimateBuyValue(currencyAmount) {
if (!currencyAmount) return 0;
const currencyValue = contract.toBigNumber(currencyAmount).shiftedBy(
const currencyValue = new BigNumber(currencyAmount).shiftedBy(
this.data.currency.decimals

@@ -415,3 +415,3 @@ );

.estimateBuyValue(currencyValue.toFixed());
return contract.toBigNumber(buyValue).shiftedBy(-this.data.decimals);
return new BigNumber(buyValue).shiftedBy(-this.data.decimals);
}

@@ -428,11 +428,11 @@ async buy(currencyAmount, maxSlipPercent, sendToAddress) {

throw new Error("0 expected value");
const currencyValue = contract.toBigNumber(currencyAmount)
const currencyValue = new BigNumber(currencyAmount)
.shiftedBy(this.data.currency.decimals)
.dp(0);
let minBuyValue = estimateBuyValue
.times(contract.toBigNumber(100).minus(maxSlipPercent).div(100))
.times(new BigNumber(100).minus(maxSlipPercent).div(100))
.shiftedBy(this.data.decimals)
.dp(0);
if (minBuyValue.lt(1)) {
minBuyValue = contract.toBigNumber(1);
minBuyValue = new BigNumber(1);
}

@@ -444,20 +444,20 @@

minBuyValue.toFixed()
);
).then(contract.converter);
}
async estimateSellValue(tokenAmount) {
if (!tokenAmount) return contract.toBigNumber(0);
const tokenValue = contract.toBigNumber(tokenAmount).shiftedBy(this.data.decimals);
if (tokenValue.isEqualTo(0)) return contract.toBigNumber(0);
if (!tokenAmount) return new BigNumber(0);
const tokenValue = new BigNumber(tokenAmount).shiftedBy(this.data.decimals);
if (tokenValue.isEqualTo(0)) return new BigNumber(0);
try {
const sellValue = await this.dat
.estimateSellValue(tokenValue.toFixed());
return contract.toBigNumber(sellValue).shiftedBy(-this.data.currency.decimals);
return new BigNumber(sellValue).shiftedBy(-this.data.currency.decimals);
} catch (e) {
console.log(`Error reading sellValue: ${e}`);
// likely > totalSupply
return contract.toBigNumber(0);
return new BigNumber(0);
}
}
async sell(tokenAmount, maxSlipPercent, sendToAddress) {
tokenAmount = contract.toBigNumber(tokenAmount);
tokenAmount = new BigNumber(tokenAmount);
const estimateSellValue = await this.estimateSellValue(

@@ -479,7 +479,7 @@ tokenAmount.toFixed()

let minSellValue = estimateSellValue
.times(contract.toBigNumber(100).minus(maxSlipPercent).div(100))
.times(new BigNumber(100).minus(maxSlipPercent).div(100))
.shiftedBy(this.data.currency.decimals)
.dp(0);
if (minSellValue.lt(1)) {
minSellValue = contract.toBigNumber(1);
minSellValue = new BigNumber(1);
}

@@ -490,3 +490,3 @@ return this.dat.sell(

minSellValue.toFixed()
);
).then(contract.converter);
}

@@ -508,3 +508,3 @@ canSell() {

burn(tokenAmount) {
const tokenValue = contract.toBigNumber(tokenAmount)
const tokenValue = new BigNumber(tokenAmount)
.shiftedBy(this.data.decimals)

@@ -521,3 +521,3 @@ .dp(0);

}
const tokenValue = contract.toBigNumber(tokenAmount)
const tokenValue = new BigNumber(tokenAmount)
.shiftedBy(this.data.decimals)

@@ -528,3 +528,3 @@ .dp(0);

manualBuy(sendToAddress, currencyAmount) {
const buyAmount = contract.toBigNumber(currencyAmount)
const buyAmount = new BigNumber(currencyAmount)
.shiftedBy(this.data.currency.decimals)

@@ -535,7 +535,7 @@ .dp(0);

increaseCommitment(commitment, tokenAmount) {
const tokenValue = contract.toBigNumber(tokenAmount)
const tokenValue = new BigNumber(tokenAmount)
.shiftedBy(this.data.decimals)
.dp(0);
return this.dat.increaseCommitment(
contract.toBigNumber(commitment).shiftedBy(2).toFixed(),
new BigNumber(commitment).shiftedBy(2).toFixed(),
tokenValue.toFixed()

@@ -551,7 +551,7 @@ );

}
const tokenValue = contract.toBigNumber(tokenAmount)
const tokenValue = new BigNumber(tokenAmount)
.shiftedBy(this.data.decimals)
.dp(0);
return this.dat.convertToCafe(
contract.toBigNumber(commitment).shiftedBy(2).toFixed(),
new BigNumber(commitment).shiftedBy(2).toFixed(),
tokenValue.toFixed(),

@@ -600,3 +600,3 @@ sendTo

nonce === undefined
? await this.dat.nonces(this.data.account.address)
? await this.dat.nonces(this.data.account.address).then(contract.converter)
: nonce,

@@ -688,3 +688,3 @@ deadline: deadline || constants.MAX_UINT,

nonce: await this.currency
.nonces(this.data.account.address),
.nonces(this.data.account.address).then(contract.converter),
};

@@ -741,10 +741,10 @@ const data = {

}
const currencyValue = contract.toBigNumber(currencyAmount)
const currencyValue = new BigNumber(currencyAmount)
.shiftedBy(this.data.currency.decimals)
.dp(0);
let minBuyValue = contract.toBigNumber(minTokensBought)
let minBuyValue = new BigNumber(minTokensBought)
.shiftedBy(this.data.decimals)
.dp(0);
if (minBuyValue.lt(1)) {
minBuyValue = contract.toBigNumber(1);
minBuyValue = new BigNumber(1);
}

@@ -785,3 +785,3 @@

nonce === undefined
? await this.dat.nonces(this.data.account.address)
? await this.dat.nonces(this.data.account.address).then(contract.converter)
: nonce,

@@ -815,10 +815,10 @@ deadline: deadline || constants.MAX_UINT,

}
const currencyValue = contract.toBigNumber(currencyAmount)
const currencyValue = new BigNumber(currencyAmount)
.shiftedBy(this.data.currency.decimals)
.dp(0);
let minBuyValue = contract.toBigNumber(minTokensBought)
let minBuyValue = new BigNumber(minTokensBought)
.shiftedBy(this.data.decimals)
.dp(0);
if (minBuyValue.lt(1)) {
minBuyValue = contract.toBigNumber(1);
minBuyValue = new BigNumber(1);
}

@@ -862,10 +862,10 @@ const signatureHash = signature.substring(2);

}
const fairValue = contract.toBigNumber(quantityToSell)
const fairValue = new BigNumber(quantityToSell)
.shiftedBy(this.data.decimals)
.dp(0);
let minCurrencyValue = contract.toBigNumber(minCurrencyReturned)
let minCurrencyValue = new BigNumber(minCurrencyReturned)
.shiftedBy(this.data.currency.decimals)
.dp(0);
if (minCurrencyValue.lt(1)) {
minCurrencyValue = contract.toBigNumber(1);
minCurrencyValue = new BigNumber(1);
}

@@ -935,10 +935,10 @@

}
const fairValue = contract.toBigNumber(quantityToSell)
const fairValue = new BigNumber(quantityToSell)
.shiftedBy(this.data.decimals)
.dp(0);
let minCurrencyValue = contract.toBigNumber(minCurrencyReturned)
let minCurrencyValue = new BigNumber(minCurrencyReturned)
.shiftedBy(this.data.currency.decimals)
.dp(0);
if (minCurrencyValue.lt(1)) {
minCurrencyValue = contract.toBigNumber(1);
minCurrencyValue = new BigNumber(1);
}

@@ -945,0 +945,0 @@ const signatureHash = signature.substring(2);

@@ -10,4 +10,7 @@ const BigNumber = require("bignumber.js");

},
toBigNumber: (value) => {
return new BigNumber(value.toString())
converter: async (value) => {
if (value && value._isBigNumber) {
return value.toString();
}
return value
}

@@ -14,0 +17,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