Skip to content

Commit

Permalink
get assets also if there is no account connected, but given
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Aug 31, 2021
1 parent 78102c1 commit abac9a9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ const getAssets = async (options) => {
if(options === undefined) { options = {}; }

let wallet = await depayWeb3Wallets.getWallet();
if (!wallet) { return }

let account;
if(options.account) {
account = options.account;
} else {
} else if(wallet) {
account = await wallet.account();
}
if (!account) { return }
Expand Down
3 changes: 1 addition & 2 deletions dist/es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ const getAssets = async (options) => {
if(options === undefined) { options = {}; }

let wallet = await getWallet();
if (!wallet) { return }

let account;
if(options.account) {
account = options.account;
} else {
} else if(wallet) {
account = await wallet.account();
}
if (!account) { return }
Expand Down
3 changes: 1 addition & 2 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
if(options === undefined) { options = {}; }

let wallet = await depayWeb3Wallets.getWallet();
if (!wallet) { return }

let account;
if(options.account) {
account = options.account;
} else {
} else if(wallet) {
account = await wallet.account();
}
if (!account) { return }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "depay-web3-assets",
"moduleName": "Web3Assets",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"main": "dist/cjs/index.js",
"module": "dist/es/index.js",
Expand Down
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ const getAssets = async (options) => {
if(options === undefined) { options = {} }

let wallet = await getWallet()
if (!wallet) { return }

let account
if(options.account) {
account = options.account
} else {
} else if(wallet) {
account = await wallet.account()
}
if (!account) { return }
Expand Down
7 changes: 5 additions & 2 deletions tests/units/getAssets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('assets', ()=>{
).rejects.toEqual('Web3Wallets: Please pass an apiKey. See documentation.')
})

describe('fetch assets', ()=>{
describe('fetch assets for connected wallet', ()=>{

beforeEach(()=>{
mock({ blockchain: 'ethereum', wallet: 'metamask' })
Expand Down Expand Up @@ -120,8 +120,11 @@ describe('assets', ()=>{
}
])
})
})

describe('fetch assets for given account (no connected wallet)', ()=>{

it('fetches the assets for a given account', async()=> {
it('fetches the assets for a given account without any connected wallet', async()=> {
let account = '0xEcA533Ef096f191A35DE76aa4580FA3A722724bE'
fetchMock.get({
url: `https://api.depay.pro/v1/assets?account=${account}&blockchain=ethereum`,
Expand Down

0 comments on commit abac9a9

Please sign in to comment.