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

depay-blockchain-token

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

depay-blockchain-token - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

116

dist/cjs/index.js

@@ -6,4 +6,5 @@ 'use strict';

var CONSTANTS = require('depay-blockchain-constants');
var ethers = require('ethers');
var depayCryptoWallets = require('depay-crypto-wallets');
var depayBlockchainClient = require('depay-blockchain-client');
var ethers = require('ethers');

@@ -142,6 +143,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

}
return await depayBlockchainClient.request(['ethereum://', this.address, '/decimals'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'decimals',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -153,6 +161,13 @@

}
return await depayBlockchainClient.request(['ethereum://', this.address, '/symbol'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'symbol',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -164,6 +179,13 @@

}
return await depayBlockchainClient.request(['ethereum://', this.address, '/name'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'name',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -176,9 +198,14 @@

}
let accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
let provider = new ethers.ethers.providers.Web3Provider(window.ethereum);
let signer = provider.getSigner();
let contract = new ethers.ethers.Contract(this.address, ERC20, provider);
let estimate = contract
.connect(signer)
.estimateGas.transfer(accounts[0], '1')
depayBlockchainClient.estimate(
{
blockchain: 'ethereum',
address: this.address,
method: 'transfer',
},
{
api: ERC20,
params: [await depayCryptoWallets.getWallet().account(), '1'],
},
)
.then(() => resolve(true))

@@ -191,14 +218,47 @@ .catch(() => resolve(false));

if (this.address == CONSTANTS__default['default'][this.blockchain].NATIVE) {
return await depayBlockchainClient.request(['ethereum://', account, '/balance'].join(''), {
cache: 30000, // 30 seconds
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: account,
method: 'balance',
},
{
cache: 30000, // 30 seconds
},
)
} else {
return await depayBlockchainClient.request(['ethereum://', this.address, '/balanceOf'].join(''), {
api: ERC20,
params: [account],
cache: 30000, // 30 seconds
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'balanceOf',
},
{
api: ERC20,
params: [account],
cache: 30000, // 30 seconds
},
)
}
}
async allowance(spender) {
if (this.address == CONSTANTS__default['default'][this.blockchain].NATIVE) {
return ethers.ethers.BigNumber.from(CONSTANTS__default['default'][this.blockchain].MAXINT)
} else {
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'allowance',
},
{
api: ERC20,
params: [await depayCryptoWallets.getWallet().account(), spender],
cache: 30000, // 30 seconds
},
)
}
}
async BigNumber(amount) {

@@ -205,0 +265,0 @@ let decimals = await this.decimals();

import CONSTANTS from 'depay-blockchain-constants';
import { request } from 'depay-blockchain-client';
import { ethers } from 'ethers';
import { getWallet } from 'depay-crypto-wallets';
import { request, estimate } from 'depay-blockchain-client';

@@ -133,6 +134,13 @@ var ERC20 = [

}
return await request(['ethereum://', this.address, '/decimals'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await request(
{
blockchain: 'ethereum',
address: this.address,
method: 'decimals',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -144,6 +152,13 @@

}
return await request(['ethereum://', this.address, '/symbol'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await request(
{
blockchain: 'ethereum',
address: this.address,
method: 'symbol',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -155,6 +170,13 @@

}
return await request(['ethereum://', this.address, '/name'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await request(
{
blockchain: 'ethereum',
address: this.address,
method: 'name',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -167,9 +189,14 @@

}
let accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
let provider = new ethers.providers.Web3Provider(window.ethereum);
let signer = provider.getSigner();
let contract = new ethers.Contract(this.address, ERC20, provider);
let estimate = contract
.connect(signer)
.estimateGas.transfer(accounts[0], '1')
estimate(
{
blockchain: 'ethereum',
address: this.address,
method: 'transfer',
},
{
api: ERC20,
params: [await getWallet().account(), '1'],
},
)
.then(() => resolve(true))

@@ -182,14 +209,47 @@ .catch(() => resolve(false));

if (this.address == CONSTANTS[this.blockchain].NATIVE) {
return await request(['ethereum://', account, '/balance'].join(''), {
cache: 30000, // 30 seconds
})
return await request(
{
blockchain: 'ethereum',
address: account,
method: 'balance',
},
{
cache: 30000, // 30 seconds
},
)
} else {
return await request(['ethereum://', this.address, '/balanceOf'].join(''), {
api: ERC20,
params: [account],
cache: 30000, // 30 seconds
})
return await request(
{
blockchain: 'ethereum',
address: this.address,
method: 'balanceOf',
},
{
api: ERC20,
params: [account],
cache: 30000, // 30 seconds
},
)
}
}
async allowance(spender) {
if (this.address == CONSTANTS[this.blockchain].NATIVE) {
return ethers.BigNumber.from(CONSTANTS[this.blockchain].MAXINT)
} else {
return await request(
{
blockchain: 'ethereum',
address: this.address,
method: 'allowance',
},
{
api: ERC20,
params: [await getWallet().account(), spender],
cache: 30000, // 30 seconds
},
)
}
}
async BigNumber(amount) {

@@ -196,0 +256,0 @@ let decimals = await this.decimals();

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('depay-blockchain-constants'), require('depay-blockchain-client'), require('ethers')) :
typeof define === 'function' && define.amd ? define(['exports', 'depay-blockchain-constants', 'depay-blockchain-client', 'ethers'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BlockchainToken = {}, global.BlockchainConstants, global.BlockchainClient, global.ethers));
}(this, (function (exports, CONSTANTS, depayBlockchainClient, ethers) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('depay-blockchain-constants'), require('ethers'), require('depay-crypto-wallets'), require('depay-blockchain-client')) :
typeof define === 'function' && define.amd ? define(['exports', 'depay-blockchain-constants', 'ethers', 'depay-crypto-wallets', 'depay-blockchain-client'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BlockchainToken = {}, global.BlockchainConstants, global.ethers, global.CryptoWallets, global.BlockchainClient));
}(this, (function (exports, CONSTANTS, ethers, depayCryptoWallets, depayBlockchainClient) { 'use strict';

@@ -139,6 +139,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

}
return await depayBlockchainClient.request(['ethereum://', this.address, '/decimals'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'decimals',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -150,6 +157,13 @@

}
return await depayBlockchainClient.request(['ethereum://', this.address, '/symbol'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'symbol',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -161,6 +175,13 @@

}
return await depayBlockchainClient.request(['ethereum://', this.address, '/name'].join(''), {
api: ERC20,
cache: 86400000, // 1 day
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'name',
},
{
api: ERC20,
cache: 86400000, // 1 day
},
)
}

@@ -173,9 +194,14 @@

}
let accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
let provider = new ethers.ethers.providers.Web3Provider(window.ethereum);
let signer = provider.getSigner();
let contract = new ethers.ethers.Contract(this.address, ERC20, provider);
let estimate = contract
.connect(signer)
.estimateGas.transfer(accounts[0], '1')
depayBlockchainClient.estimate(
{
blockchain: 'ethereum',
address: this.address,
method: 'transfer',
},
{
api: ERC20,
params: [await depayCryptoWallets.getWallet().account(), '1'],
},
)
.then(() => resolve(true))

@@ -188,14 +214,47 @@ .catch(() => resolve(false));

if (this.address == CONSTANTS__default['default'][this.blockchain].NATIVE) {
return await depayBlockchainClient.request(['ethereum://', account, '/balance'].join(''), {
cache: 30000, // 30 seconds
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: account,
method: 'balance',
},
{
cache: 30000, // 30 seconds
},
)
} else {
return await depayBlockchainClient.request(['ethereum://', this.address, '/balanceOf'].join(''), {
api: ERC20,
params: [account],
cache: 30000, // 30 seconds
})
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'balanceOf',
},
{
api: ERC20,
params: [account],
cache: 30000, // 30 seconds
},
)
}
}
async allowance(spender) {
if (this.address == CONSTANTS__default['default'][this.blockchain].NATIVE) {
return ethers.ethers.BigNumber.from(CONSTANTS__default['default'][this.blockchain].MAXINT)
} else {
return await depayBlockchainClient.request(
{
blockchain: 'ethereum',
address: this.address,
method: 'allowance',
},
{
api: ERC20,
params: [await depayCryptoWallets.getWallet().account(), spender],
cache: 30000, // 30 seconds
},
)
}
}
async BigNumber(amount) {

@@ -202,0 +261,0 @@ let decimals = await this.decimals();

{
"name": "depay-blockchain-token",
"moduleName": "BlockchainToken",
"version": "1.4.0",
"version": "1.5.0",
"description": "JavaScript library providing basic functionalities to work with tokens.",

@@ -35,4 +35,5 @@ "main": "dist/cjs/index.js",

"dependencies": {
"depay-blockchain-client": "^2.0.0",
"depay-blockchain-client": "^2.3.0",
"depay-blockchain-constants": "^1.4.0",
"depay-crypto-wallets": "^2.4.0",
"ethers": "^5.3.1"

@@ -39,0 +40,0 @@ },

@@ -84,4 +84,3 @@ ## Quickstart

```javascript
await token.balance('0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE') // BigNumber {_hex: "0x0b896d5e9eeaabf4f1", _isBigNumber: true}
```

@@ -88,0 +87,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