Skip to content

Commit

Permalink
v10.12.1: return undefined if account has no data
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed May 6, 2023
1 parent 568c182 commit 7d4c3c0
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ var requestEVM = async ({ blockchain, address, api, method, params, block, timeo

const accountInfo = async ({ address, api, method, params, provider, block }) => {
const info = await provider.getAccountInfo(new PublicKey(address));
if(!info || !info.data) { return }
return api.decode(info.data)
};

Expand Down
1 change: 1 addition & 0 deletions dist/esm/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ let estimate = async function ({ blockchain, from, to, value, method, api, param

const accountInfo = async ({ address, api, method, params, provider, block }) => {
const info = await provider.getAccountInfo(new PublicKey(address));
if(!info || !info.data) { return }
return api.decode(info.data)
};

Expand Down
1 change: 1 addition & 0 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@

const accountInfo = async ({ address, api, method, params, provider, block }) => {
const info = await provider.getAccountInfo(new solanaWeb3_js.PublicKey(address));
if(!info || !info.data) { return }
return api.decode(info.data)
};

Expand Down
1 change: 1 addition & 0 deletions dist/umd/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@

const accountInfo = async ({ address, api, method, params, provider, block }) => {
const info = await provider.getAccountInfo(new solanaWeb3_js.PublicKey(address));
if(!info || !info.data) { return }
return api.decode(info.data)
};

Expand Down
2 changes: 1 addition & 1 deletion package.evm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client-evm",
"moduleName": "Web3Client",
"version": "10.12.0",
"version": "10.12.1",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.evm.js",
"module": "dist/esm/index.evm.js",
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-client",
"moduleName": "Web3Client",
"version": "10.12.0",
"version": "10.12.1",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion package.solana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client-solana",
"moduleName": "Web3Client",
"version": "10.12.0",
"version": "10.12.1",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.solana.js",
"module": "dist/esm/index.solana.js",
Expand Down
1 change: 1 addition & 0 deletions src/platforms/solana/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PublicKey, ACCOUNT_LAYOUT } from '@depay/solana-web3.js'

const accountInfo = async ({ address, api, method, params, provider, block }) => {
const info = await provider.getAccountInfo(new PublicKey(address))
if(!info || !info.data) { return }
return api.decode(info.data)
}

Expand Down
14 changes: 14 additions & 0 deletions tests/units/platforms/solana/request/getAccountInfo.solana.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ describe('request getAccountInfo', () => {
request('solana://2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9', { api })
).rejects.toEqual(Error('failed to get info about account 2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9: SOMETHING WENT WRONG'))
})

it('returns nothing if account does not exist', async ()=>{
mock({
provider,
blockchain,
request: {
method: 'getAccountInfo',
to: 'EHugM4AienbEwyWKVMseUac2VGR876k48JqyQ2ZuzqeE',
return: null
}
})
let data = await request('solana://EHugM4AienbEwyWKVMseUac2VGR876k48JqyQ2ZuzqeE')
expect(data).toEqual(undefined)
})
})
})
})
14 changes: 14 additions & 0 deletions tests/units/platforms/solana/request/getAccountInfo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ describe('request getAccountInfo', () => {
request('solana://2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9', { api })
).rejects.toEqual(Error('failed to get info about account 2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9: SOMETHING WENT WRONG'))
})

it('returns nothing if account does not exist', async ()=>{
mock({
provider,
blockchain,
request: {
method: 'getAccountInfo',
to: 'EHugM4AienbEwyWKVMseUac2VGR876k48JqyQ2ZuzqeE',
return: null
}
})
let data = await request('solana://EHugM4AienbEwyWKVMseUac2VGR876k48JqyQ2ZuzqeE')
expect(data).toEqual(undefined)
})
})
})
})

0 comments on commit 7d4c3c0

Please sign in to comment.