@primuslabs/fund-js-sdk 0.1.36 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -3
- package/dist/index.mjs +5 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1851,16 +1851,18 @@ var Fund = class {
|
|
|
1851
1851
|
async approve(tokenInfo, recipientInfoList) {
|
|
1852
1852
|
return new Promise(async (resolve, reject) => {
|
|
1853
1853
|
try {
|
|
1854
|
-
const
|
|
1854
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1855
|
+
const decimals = await tokenContract.decimals();
|
|
1856
|
+
const approveAmount = recipientInfoList.reduce((acc, cur) => acc.add(parseUnits2(cur.tokenAmount.toString(), decimals)), import_ethers3.ethers.BigNumber.from(0));
|
|
1857
|
+
const formatApproveAmount = formatUnits2(approveAmount, decimals);
|
|
1855
1858
|
let approveParams = {
|
|
1856
1859
|
spenderAddress: this.fundContract.address,
|
|
1857
|
-
approveAmount
|
|
1860
|
+
approveAmount: formatApproveAmount
|
|
1858
1861
|
};
|
|
1859
1862
|
if ([97, 56].includes(this.chainId)) {
|
|
1860
1863
|
const gasPrice = await this.provider.getGasPrice();
|
|
1861
1864
|
approveParams.otherParams = { gasPrice };
|
|
1862
1865
|
}
|
|
1863
|
-
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1864
1866
|
await tokenContract.approve(approveParams);
|
|
1865
1867
|
resolve("Approved");
|
|
1866
1868
|
} catch (error) {
|
package/dist/index.mjs
CHANGED
|
@@ -1817,16 +1817,18 @@ var Fund = class {
|
|
|
1817
1817
|
async approve(tokenInfo, recipientInfoList) {
|
|
1818
1818
|
return new Promise(async (resolve, reject) => {
|
|
1819
1819
|
try {
|
|
1820
|
-
const
|
|
1820
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1821
|
+
const decimals = await tokenContract.decimals();
|
|
1822
|
+
const approveAmount = recipientInfoList.reduce((acc, cur) => acc.add(parseUnits2(cur.tokenAmount.toString(), decimals)), ethers3.BigNumber.from(0));
|
|
1823
|
+
const formatApproveAmount = formatUnits2(approveAmount, decimals);
|
|
1821
1824
|
let approveParams = {
|
|
1822
1825
|
spenderAddress: this.fundContract.address,
|
|
1823
|
-
approveAmount
|
|
1826
|
+
approveAmount: formatApproveAmount
|
|
1824
1827
|
};
|
|
1825
1828
|
if ([97, 56].includes(this.chainId)) {
|
|
1826
1829
|
const gasPrice = await this.provider.getGasPrice();
|
|
1827
1830
|
approveParams.otherParams = { gasPrice };
|
|
1828
1831
|
}
|
|
1829
|
-
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
1830
1832
|
await tokenContract.approve(approveParams);
|
|
1831
1833
|
resolve("Approved");
|
|
1832
1834
|
} catch (error) {
|