Skip to content

Commit

Permalink
v6.3.0: adds polygon support (#2)
Browse files Browse the repository at this point in the history
* v6.3.0: adds polygon support

* fix node versions for github workflows
  • Loading branch information
spape authored May 21, 2022
1 parent c014f93 commit e4471e3
Show file tree
Hide file tree
Showing 8 changed files with 1,129 additions and 403 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '16.x'
- name: Cache node modules
uses: actions/cache@v2
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '16.x'
- name: Cache node modules
uses: actions/cache@v2
env:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ let allAssets = await dripAssets({
This library supports the following blockchains:

- [Ethereum](https://ethereum.org)
- [BNB Smart Chain](https://www.binance.org/en/smartChain)
- [BNB Smart Chain](https://www.binance.org/smartChain)
- [Polygon](https://polygon.technology)

## Functionalities

Expand Down
2 changes: 1 addition & 1 deletion dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<script crossorigin src="https://unpkg.com/@depay/web3-tokens@8"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-wallets@8"></script>
<script src="tmp/index.dev.js"></script>
<link rel="stylesheet" href="https://unpkg.com/bootstrap@4/dist/css/bootstrap.css">
<link rel="stylesheet" href="https://unpkg.com/bootstrap@5/dist/css/bootstrap.css">
<style>
.btn-primary {
color: #fff;
Expand Down
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-assets",
"moduleName": "Web3Assets",
"version": "6.2.1",
"version": "6.3.0",
"description": "",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -35,22 +35,22 @@
"private": false,
"dependencies": {},
"peerDependencies": {
"@depay/web3-blockchains": "^4.3.0",
"@depay/web3-client": "^8.0.0",
"@depay/web3-constants": "^5.0.0",
"@depay/web3-tokens": "^8.0.1"
"@depay/web3-blockchains": "^4.5.0",
"@depay/web3-client": "^8.2.1",
"@depay/web3-constants": "^5.2.1",
"@depay/web3-tokens": "^8.1.0"
},
"engines": {
"node": ">=10"
"node": ">=16"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@depay/web3-blockchains": "^4.3.0",
"@depay/web3-client": "^8.0.0",
"@depay/web3-constants": "^5.0.0",
"@depay/web3-mock": "^11.7.0",
"@depay/web3-tokens": "^8.0.1",
"@depay/web3-blockchains": "^4.5.0",
"@depay/web3-client": "^8.2.1",
"@depay/web3-constants": "^5.2.1",
"@depay/web3-mock": "^11.8.1",
"@depay/web3-tokens": "^8.1.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-replace": "^2.4.2",
Expand All @@ -62,8 +62,9 @@
"eslint": "^7.15.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.22.1",
"ethers": "^5.4.6",
"ethers": "^5.6.5",
"fetch-mock": "^9.11.0",
"jest-environment-jsdom": "^28.1.0",
"regenerator-runtime": "^0.13.7",
"rollup": "^2.34.2",
"rollup-plugin-delete": "^2.0.0",
Expand Down
104 changes: 101 additions & 3 deletions tests/units/dripAssets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('dripAssets', ()=>{
afterEach(resetMocks)

const accounts = ['0xEcA533Ef096f191A35DE76aa4580FA3A722724bE']
const blockchains = ['ethereum', 'bsc']
const blockchains = ['ethereum', 'bsc', 'polygon']

beforeEach(()=>{
blockchains.forEach((blockchain)=>{
Expand Down Expand Up @@ -61,6 +61,23 @@ describe('dripAssets', ()=>{
"decimals": 18
}]
)

fetchMock.get({ url: `https://public.depay.fi/accounts/polygon/${accounts[0]}/assets` },
[{
"name": "Matic",
"symbol": "MATIC",
"address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"type": "NATIVE",
"balance": "2100000000000000000"
}, {
"name": "DePay",
"symbol": "DEPAY",
"address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
"type": "20",
"balance": "1000000000000000000",
"decimals": 18
}]
)
})

describe('drips assets for given accounts (first all major tokens per blockchain, then all further assets)', ()=>{
Expand All @@ -70,14 +87,14 @@ describe('dripAssets', ()=>{
let dripsCount = 0

let allAssets = await dripAssets({
accounts: { ethereum: accounts[0], bsc: accounts[0] },
accounts: { ethereum: accounts[0], bsc: accounts[0], polygon: accounts[0] },
drip: (asset)=>{
dripsCount++
drippedAssets.push(asset)
}
})

expect(dripsCount).toEqual(20)
expect(dripsCount).toEqual(29)

let expectedAssets = [{
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
Expand All @@ -97,6 +114,15 @@ describe('dripAssets', ()=>{
blockchain: 'bsc',
balance: '123456789'
},
{
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
symbol: 'MATIC',
name: 'Polygon',
decimals: 18,
type: 'NATIVE',
blockchain: 'polygon',
balance: '123456789'
},
{
address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
symbol: 'WETH',
Expand Down Expand Up @@ -241,6 +267,69 @@ describe('dripAssets', ()=>{
blockchain: 'bsc',
balance: '123456789'
},
{
address: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
symbol: 'WMATIC',
name: 'Wrapped Matic',
decimals: 18,
type: '20',
blockchain: 'polygon',
balance: '123456789'
},
{
address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
symbol: 'WETH',
name: 'Wrapped Ether',
decimals: 18,
type: '20',
blockchain: 'polygon',
balance: '123456789'
},
{
address: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
symbol: 'USDC',
name: 'USD Coin',
decimals: 6,
type: '20',
blockchain: 'polygon',
balance: '123456789'
},
{
address: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
symbol: 'USDT',
name: 'Tether USD',
decimals: 6,
type: '20',
blockchain: 'polygon',
balance: '123456789'
},
{
address: '0xa3Fa99A148fA48D14Ed51d610c367C61876997F1',
symbol: 'miMATIC',
name: 'miMATIC',
decimals: 18,
type: '20',
blockchain: 'polygon',
balance: '123456789'
},
{
address: '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063',
symbol: 'DAI',
name: 'Dai Stablecoin',
decimals: 18,
type: '20',
blockchain: 'polygon',
balance: '123456789'
},
{
address: '0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6',
symbol: 'WBTC',
name: 'Wrapped BTC',
decimals: 8,
type: '20',
blockchain: 'polygon',
balance: '123456789'
},
{
address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
balance: '56789',
Expand All @@ -258,6 +347,15 @@ describe('dripAssets', ()=>{
name: 'DePay',
symbol: 'DEPAY',
type: '20'
},
{
address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
balance: '56789',
blockchain: 'polygon',
decimals: 18,
name: 'DePay',
symbol: 'DEPAY',
type: '20'
}
]

Expand Down
34 changes: 33 additions & 1 deletion tests/units/getAssets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,23 @@ describe('getAssets', ()=>{
"balance": "1000000000000000000"
}]
)
expect(await getAssets({ accounts: { ethereum: address, bsc: address } })).toEqual([
fetchMock.get({
url: `https://public.depay.fi/accounts/polygon/${address}/assets`,
}, [{
"name": "Matic",
"symbol": "Matic",
"address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"type": "NATIVE",
"balance": "1100000000000000000"
}, {
"name": "DePay",
"symbol": "DEPAY",
"address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
"type": "20",
"balance": "1100000000000000000"
}]
)
expect(await getAssets({ accounts: { ethereum: address, bsc: address, polygon: address } })).toEqual([
{
name: 'Ether',
symbol: 'ETH',
Expand Down Expand Up @@ -78,6 +94,22 @@ describe('getAssets', ()=>{
type: '20',
balance: '1000000000000000000',
blockchain: 'bsc'
},
{
name: 'Matic',
symbol: 'Matic',
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
type: 'NATIVE',
balance: '1100000000000000000',
blockchain: 'polygon'
},
{
name: 'DePay',
symbol: 'DEPAY',
address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
type: '20',
balance: '1100000000000000000',
blockchain: 'polygon'
}
])
})
Expand Down
Loading

0 comments on commit e4471e3

Please sign in to comment.