Skip to content

Commit

Permalink
v6.5.3: fix patch dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Oct 23, 2022
1 parent 5221d6c commit 8fe27ce
Show file tree
Hide file tree
Showing 5 changed files with 877 additions and 463 deletions.
12 changes: 6 additions & 6 deletions dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<link rel="icon" type="image/png" href="https://depay.com/favicon.png"/>
<title>Development</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://cdn.ethers.io/lib/ethers-5.4.umd.min.js" type="application/javascript"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-constants@5"></script>
<script src="https://cdn.ethers.io/lib/ethers-5.7.umd.min.js" type="application/javascript"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-constants@6"></script>
<script crossorigin src="https://unpkg.com/@depay/walletconnect-v1@1"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-blockchains@4"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-client@8"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-tokens@8"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-wallets@8"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-blockchains@6"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-client@10"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-tokens@9"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-wallets@12"></script>
<script src="tmp/index.dev.js"></script>
<link rel="stylesheet" href="https://unpkg.com/bootstrap@5/dist/css/bootstrap.css">
<style>
Expand Down
27 changes: 15 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.5.2",
"version": "6.5.3",
"description": "",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -35,22 +35,24 @@
"private": false,
"dependencies": {},
"peerDependencies": {
"@depay/web3-blockchains": "^5.0.1",
"@depay/web3-client": "^8.5.0",
"@depay/web3-constants": "^6.0.0",
"@depay/web3-tokens": "^8.2.0"
"@depay/solana-web3.js": "^1.19.0",
"@depay/web3-blockchains": "^6.2.0",
"@depay/web3-client": "^10.1.6",
"@depay/web3-constants": "^6.3.1",
"@depay/web3-tokens": "^9.11.3"
},
"engines": {
"node": ">=16"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@depay/web3-blockchains": "^5.0.1",
"@depay/web3-client": "^8.5.0",
"@depay/web3-constants": "^6.0.0",
"@depay/web3-mock": "^11.11.0",
"@depay/web3-tokens": "^8.2.0",
"@depay/solana-web3.js": "^1.19.0",
"@depay/web3-blockchains": "^6.2.0",
"@depay/web3-client": "^10.1.6",
"@depay/web3-constants": "^6.3.1",
"@depay/web3-mock": "^13.22.4",
"@depay/web3-tokens": "^9.11.3",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-replace": "^2.4.2",
Expand All @@ -62,14 +64,15 @@
"eslint": "^7.15.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.22.1",
"ethers": "^5.6.8",
"ethers": "^5.7.1",
"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",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-serve": "^1.1.0",
"tslib": "^2.3.1"
"tslib": "^2.3.1",
"webpack": "^5.74.0"
}
}
82 changes: 25 additions & 57 deletions tests/units/dripAssets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fetchMock from 'fetch-mock'
import { Blockchain } from '@depay/web3-blockchains'
import { dripAssets } from 'src'
import { mock, resetMocks } from '@depay/web3-mock'
import { provider as providerFor, resetCache } from '@depay/web3-client'
import { getProvider, resetCache } from '@depay/web3-client'
import { Token } from '@depay/web3-tokens'

describe('dripAssets', ()=>{
Expand All @@ -14,18 +14,20 @@ describe('dripAssets', ()=>{

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

beforeEach(()=>{
blockchains.forEach((blockchain)=>{
const provider = providerFor(blockchain)

blockchains.forEach(async (blockchain)=>{
provider = await getProvider(blockchain)
mock({ accounts: { return: accounts }, provider, blockchain })
mock({ balance: { for: accounts[0], return: '123456789' }, provider, blockchain })
Blockchain.findByName(blockchain).tokens.forEach((token)=>{
if(token.type == '20') {
mock({ call: { return: '123456789', to: token.address, api: Token[blockchain].DEFAULT, method: 'balanceOf', params: accounts[0] }, provider, blockchain })
mock({ request: { return: '123456789', to: token.address, api: Token[blockchain].DEFAULT, method: 'balanceOf', params: accounts[0] }, provider, blockchain })
}
})
mock({ call: { return: '56789', to: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', api: Token[blockchain].DEFAULT, method: 'balanceOf', params: accounts[0] }, provider, blockchain })
mock({ request: { return: '56789', to: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', api: Token[blockchain].DEFAULT, method: 'balanceOf', params: accounts[0] }, provider, blockchain })
})

fetchMock.get({ url: `https://public.depay.com/accounts/ethereum/${accounts[0]}/assets` },
Expand Down Expand Up @@ -94,7 +96,7 @@ describe('dripAssets', ()=>{
}
})

expect(dripsCount).toEqual(29)
expect(dripsCount).toEqual(28)

let expectedAssets = [{
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
Expand Down Expand Up @@ -177,15 +179,6 @@ describe('dripAssets', ()=>{
blockchain: 'ethereum',
balance: '123456789'
},
{
address: '0x4Fabb145d64652a948d72533023f6E7A623C7C53',
symbol: 'BUSD',
name: 'Binance USD',
decimals: 18,
type: '20',
blockchain: 'ethereum',
balance: '123456789'
},
{
address: '0x8E870D67F660D95d5be530380D0eC0bd388289E1',
symbol: 'USDP',
Expand Down Expand Up @@ -422,7 +415,7 @@ describe('dripAssets', ()=>{
}
})

expect(dripsCount).toEqual(17)
expect(dripsCount).toEqual(16)

let expectedAssets = [{
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
Expand Down Expand Up @@ -478,15 +471,6 @@ describe('dripAssets', ()=>{
blockchain: 'ethereum',
balance: '123456789'
},
{
address: '0x4Fabb145d64652a948d72533023f6E7A623C7C53',
symbol: 'BUSD',
name: 'Binance USD',
decimals: 18,
type: '20',
blockchain: 'ethereum',
balance: '123456789'
},
{
address: '0x8E870D67F660D95d5be530380D0eC0bd388289E1',
symbol: 'USDP',
Expand Down Expand Up @@ -590,21 +574,23 @@ describe('dripAssets', ()=>{
let drippedAssets = []
let dripsCount = 0

blockchains.forEach((blockchain)=>{
const provider = providerFor(blockchain)
mock({ call: { return: 'DePay', to: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb', api: Token[blockchain].DEFAULT, method: 'name' }, provider, blockchain })
mock({ call: { return: 'DEPAY', to: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb', api: Token[blockchain].DEFAULT, method: 'symbol' }, provider, blockchain })
mock({ call: { return: 18, to: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb', api: Token[blockchain].DEFAULT, method: 'decimals' }, provider, blockchain })
blockchains.forEach(async (blockchain)=>{
provider = await getProvider(blockchain)
mock({ request: { return: 'DePay', to: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb', api: Token[blockchain].DEFAULT, method: 'name' }, provider, blockchain })
mock({ request: { return: 'DEPAY', to: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb', api: Token[blockchain].DEFAULT, method: 'symbol' }, provider, blockchain })
mock({ request: { return: 18, to: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb', api: Token[blockchain].DEFAULT, method: 'decimals' }, provider, blockchain })
})

mock({ call: { return: 'Wrapped Ether', to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', api: Token['ethereum'].DEFAULT, method: 'name' }, provider: providerFor('ethereum'), blockchain: 'ethereum' })
mock({ call: { return: 'WETH', to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', api: Token['ethereum'].DEFAULT, method: 'symbol' }, provider: providerFor('ethereum'), blockchain: 'ethereum' })
mock({ call: { return: 18, to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', api: Token['ethereum'].DEFAULT, method: 'decimals' }, provider: providerFor('ethereum'), blockchain: 'ethereum' })
mock({ call: { return: '0', to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', api: Token['ethereum'].DEFAULT, method: 'balanceOf', params: accounts[0] }, provider: providerFor('ethereum'), blockchain: 'ethereum' })
provider = await getProvider('ethereum')
mock({ request: { return: 'Wrapped Ether', to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', api: Token['ethereum'].DEFAULT, method: 'name' }, provider, blockchain: 'ethereum' })
mock({ request: { return: 'WETH', to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', api: Token['ethereum'].DEFAULT, method: 'symbol' }, provider, blockchain: 'ethereum' })
mock({ request: { return: 18, to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', api: Token['ethereum'].DEFAULT, method: 'decimals' }, provider, blockchain: 'ethereum' })
mock({ request: { return: '0', to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', api: Token['ethereum'].DEFAULT, method: 'balanceOf', params: accounts[0] }, provider, blockchain: 'ethereum' })

mock({ call: { return: 'Wrapped BNB', to: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', api: Token['bsc'].DEFAULT, method: 'name' }, provider: providerFor('bsc'), blockchain: 'bsc' })
mock({ call: { return: 'BNB', to: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', api: Token['bsc'].DEFAULT, method: 'symbol' }, provider: providerFor('bsc'), blockchain: 'bsc' })
mock({ call: { return: 18, to: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', api: Token['bsc'].DEFAULT, method: 'decimals' }, provider: providerFor('bsc'), blockchain: 'bsc' })
provider = await getProvider('bsc')
mock({ request: { return: 'Wrapped BNB', to: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', api: Token['bsc'].DEFAULT, method: 'name' }, provider, blockchain: 'bsc' })
mock({ request: { return: 'BNB', to: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', api: Token['bsc'].DEFAULT, method: 'symbol' }, provider, blockchain: 'bsc' })
mock({ request: { return: 18, to: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', api: Token['bsc'].DEFAULT, method: 'decimals' }, provider, blockchain: 'bsc' })

let allAssets = await dripAssets({
accounts: { ethereum: accounts[0], bsc: accounts[0] },
Expand All @@ -620,7 +606,7 @@ describe('dripAssets', ()=>{
}
})

expect(dripsCount).toEqual(19)
expect(dripsCount).toEqual(18)

let expectedAssets = [
{
Expand Down Expand Up @@ -686,15 +672,6 @@ describe('dripAssets', ()=>{
blockchain: 'ethereum',
balance: '123456789'
},
{
address: '0x4Fabb145d64652a948d72533023f6E7A623C7C53',
symbol: 'BUSD',
name: 'Binance USD',
decimals: 18,
type: '20',
blockchain: 'ethereum',
balance: '123456789'
},
{
address: '0x8E870D67F660D95d5be530380D0eC0bd388289E1',
symbol: 'USDP',
Expand Down Expand Up @@ -818,7 +795,7 @@ describe('dripAssets', ()=>{
}
})

expect(dripsCount).toEqual(19)
expect(dripsCount).toEqual(18)

let expectedAssets = [{
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
Expand Down Expand Up @@ -892,15 +869,6 @@ describe('dripAssets', ()=>{
blockchain: 'ethereum',
balance: '123456789'
},
{
address: '0x4Fabb145d64652a948d72533023f6E7A623C7C53',
symbol: 'BUSD',
name: 'Binance USD',
decimals: 18,
type: '20',
blockchain: 'ethereum',
balance: '123456789'
},
{
address: '0x8E870D67F660D95d5be530380D0eC0bd388289E1',
symbol: 'USDP',
Expand Down
20 changes: 14 additions & 6 deletions tests/units/getAssets.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import fetchMock from 'fetch-mock'
import { getAssets } from 'src'
import { mock, resetMocks } from '@depay/web3-mock'
import { provider, resetCache } from '@depay/web3-client'
import { getProvider, resetCache } from '@depay/web3-client'

describe('getAssets', ()=>{

beforeEach(()=>fetchMock.reset())
beforeEach(resetMocks)
beforeEach(resetCache)
let provider

beforeEach(()=>{
resetMocks()
resetCache()
fetchMock.reset()
})
afterEach(resetMocks)

describe('fetch assets for given accounts', ()=>{
Expand Down Expand Up @@ -362,16 +366,20 @@ describe('getAssets', ()=>{
})

it('ensures fetching asset for NATIVE currency if it was missing in the api response', async()=> {

provider = await getProvider('ethereum')
let ethereumBalanceMock = mock({
provider: provider('ethereum'),
provider,
blockchain: 'ethereum',
balance: {
for: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
return: '22222221'
}
})

provider = await getProvider('bsc')
let bscBalanceMock = mock({
provider: provider('bsc'),
provider,
blockchain: 'bsc',
balance: {
for: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
Expand Down
Loading

0 comments on commit 8fe27ce

Please sign in to comment.