@exodus/solana-plugin 1.7.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-plugin",
3
- "version": "1.7.2",
3
+ "version": "1.8.0",
4
4
  "description": "Exodus internal Solana asset plugin",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -21,8 +21,8 @@
21
21
  "dependencies": {
22
22
  "@exodus/assets": "^9.0.1",
23
23
  "@exodus/bip44-constants": "^195.0.0",
24
- "@exodus/solana-api": "^3.3.1",
25
- "@exodus/solana-lib": "^3.0.0",
24
+ "@exodus/solana-api": "^3.4.1",
25
+ "@exodus/solana-lib": "^3.2.0",
26
26
  "@exodus/solana-meta": "^1.0.7",
27
27
  "minimalistic-assert": "^1.0.1",
28
28
  "ms": "^2.1.3"
@@ -30,5 +30,5 @@
30
30
  "devDependencies": {
31
31
  "@exodus/assets-testing": "^1.0.0"
32
32
  },
33
- "gitHead": "dfd307b8c18b885aeccf12c59c1cbc0c4a127064"
33
+ "gitHead": "7fa370d0fdd120110c54d56e2b528a5464e6f9e5"
34
34
  }
@@ -11,6 +11,7 @@ import {
11
11
  signHardware,
12
12
  signMessageNew,
13
13
  createFeeData,
14
+ signMessageWithSigner,
14
15
  } from '@exodus/solana-lib'
15
16
  import ms from 'ms'
16
17
  import {
@@ -22,6 +23,7 @@ import {
22
23
  createAccountState,
23
24
  createAndBroadcastTXFactory,
24
25
  } from '@exodus/solana-api'
26
+ import { createGetBalanceForAddress } from './get-balance-for-address'
25
27
 
26
28
  const DEFAULT_ACCOUNT_RESERVE = 0.01
27
29
  const DEFAULT_LOW_BALANCE = 0.01
@@ -110,6 +112,7 @@ export const createSolanaAssetFactory =
110
112
  staking: {},
111
113
  isTestnet,
112
114
  signWithSigner,
115
+ signMessageWithSigner: true,
113
116
  }
114
117
 
115
118
  const assetStakingApi = {
@@ -141,6 +144,7 @@ export const createSolanaAssetFactory =
141
144
  defaultAddressPath,
142
145
  features,
143
146
  getBalances,
147
+ getBalanceForAddress: createGetBalanceForAddress({ api: serverApi, asset: base }),
144
148
  getDefaultAddressPath: () => defaultAddressPath,
145
149
  getFee: (args) => args?.feeData?.fee || feeData.fee,
146
150
  getFeeAsync: async ({ feeData }) => feeData.fee,
@@ -161,7 +165,10 @@ export const createSolanaAssetFactory =
161
165
  : signUnsignedTx(unsignedTx, privateKey),
162
166
  signUnsignedTx,
163
167
  signHardware,
164
- signMessage: signMessageNew,
168
+ signMessage: ({ privateKey, signer, message }) =>
169
+ signer
170
+ ? signMessageWithSigner({ signer, message })
171
+ : signMessageNew({ privateKey, message }),
165
172
  staking: assetStakingApi,
166
173
  validateAssetId: isValidAddress,
167
174
  }
@@ -0,0 +1,15 @@
1
+ import assert from 'minimalistic-assert'
2
+
3
+ export const createGetBalanceForAddress = ({ api, asset }) => {
4
+ assert(asset, 'api is required')
5
+ assert(asset, 'asset is required')
6
+ return async (address) => {
7
+ const accountInfo = await api.getAccountInfo(address)
8
+
9
+ if (accountInfo) {
10
+ return asset.currency.baseUnit(accountInfo.lamports)
11
+ }
12
+
13
+ return asset.currency.ZERO
14
+ }
15
+ }