@exodus/solana-plugin 1.8.0 → 1.9.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.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Exodus internal Solana asset plugin",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -22,13 +22,14 @@
22
22
  "@exodus/assets": "^9.0.1",
23
23
  "@exodus/bip44-constants": "^195.0.0",
24
24
  "@exodus/solana-api": "^3.4.1",
25
- "@exodus/solana-lib": "^3.2.0",
25
+ "@exodus/solana-lib": "^3.2.2",
26
26
  "@exodus/solana-meta": "^1.0.7",
27
+ "@exodus/web3-solana-utils": "^1.65.0",
27
28
  "minimalistic-assert": "^1.0.1",
28
29
  "ms": "^2.1.3"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@exodus/assets-testing": "^1.0.0"
32
33
  },
33
- "gitHead": "7fa370d0fdd120110c54d56e2b528a5464e6f9e5"
34
+ "gitHead": "c1e3c89cbf1ee6f75f9d75f1b87af72590e74b47"
34
35
  }
@@ -6,6 +6,7 @@ import {
6
6
  getEncodedSecretKey,
7
7
  isValidAddress,
8
8
  parseUnsignedTx,
9
+ prepareForSigning,
9
10
  signUnsignedTx,
10
11
  signUnsignedTxWithSigner,
11
12
  signHardware,
@@ -24,6 +25,7 @@ import {
24
25
  createAndBroadcastTXFactory,
25
26
  } from '@exodus/solana-api'
26
27
  import { createGetBalanceForAddress } from './get-balance-for-address'
28
+ import { createWeb3API } from './web3'
27
29
 
28
30
  const DEFAULT_ACCOUNT_RESERVE = 0.01
29
31
  const DEFAULT_LOW_BALANCE = 0.01
@@ -150,7 +152,7 @@ export const createSolanaAssetFactory =
150
152
  getFeeAsync: async ({ feeData }) => feeData.fee,
151
153
  getFeeData: () => feeData,
152
154
  getSupportedPurposes: () => [44],
153
- getKeyIdentifier: createGetKeyIdentifier({ bip44 }),
155
+ getKeyIdentifier: createGetKeyIdentifier({ bip44, assetName: base.name }),
154
156
  getTokens: () =>
155
157
  Object.values(assets)
156
158
  .filter((asset) => asset.name !== base.name)
@@ -171,6 +173,7 @@ export const createSolanaAssetFactory =
171
173
  : signMessageNew({ privateKey, message }),
172
174
  staking: assetStakingApi,
173
175
  validateAssetId: isValidAddress,
176
+ web3: createWeb3API({ asset: base, prepareForSigning }),
174
177
  }
175
178
 
176
179
  const fullAsset = {
@@ -1,7 +1,7 @@
1
1
  import assert from 'minimalistic-assert'
2
2
 
3
3
  export const createGetBalanceForAddress = ({ api, asset }) => {
4
- assert(asset, 'api is required')
4
+ assert(api, 'api is required')
5
5
  assert(asset, 'asset is required')
6
6
  return async (address) => {
7
7
  const accountInfo = await api.getAccountInfo(address)
@@ -0,0 +1,23 @@
1
+ import assert from 'minimalistic-assert'
2
+ import { createSimulateTransactions as createSimulateSolanaTransactions } from '@exodus/web3-solana-utils'
3
+
4
+ // This function accepts either a list of transactions created by a wallet (unsignedTxs) or a web3 transaction (transactionBuffers).
5
+ export const createSimulateTransactions = ({ asset, prepareForSigning }) => {
6
+ assert(asset, '"asset" should be passed.')
7
+ assert(prepareForSigning, '"prepareForSigning" should be passed.')
8
+
9
+ const simulateSolanaTransactions = createSimulateSolanaTransactions()
10
+
11
+ return function simulateTransactions({ transactionBuffers, unsignedTxs, ...restParameters }) {
12
+ if (unsignedTxs) {
13
+ // Converts to web3.js Transaction class instances.
14
+ const transactions = unsignedTxs.map(prepareForSigning)
15
+
16
+ return simulateSolanaTransactions({
17
+ asset,
18
+ transactions,
19
+ ...restParameters,
20
+ })
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,7 @@
1
+ import { createSimulateTransactions } from './createSimulateTransactions'
2
+
3
+ export const createWeb3API = (deps) => {
4
+ return {
5
+ simulateTransactions: createSimulateTransactions(deps),
6
+ }
7
+ }