@exodus/solana-plugin 1.8.1 → 1.9.1

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.1",
3
+ "version": "1.9.1",
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.2",
25
+ "@exodus/solana-lib": "^3.3.1",
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": "8f0211c5cbdc7117872f2f910c9b31d7e4e106f0"
34
+ "gitHead": "45964c12e52066c643ee1b6c906eb898baad1088"
34
35
  }
@@ -4,8 +4,10 @@ import {
4
4
  createGetKeyIdentifier,
5
5
  getAddressFromPublicKey,
6
6
  getEncodedSecretKey,
7
+ fillTransactionWithEmptySignatureSlot,
7
8
  isValidAddress,
8
9
  parseUnsignedTx,
10
+ prepareForSigning,
9
11
  signUnsignedTx,
10
12
  signUnsignedTxWithSigner,
11
13
  signHardware,
@@ -24,6 +26,7 @@ import {
24
26
  createAndBroadcastTXFactory,
25
27
  } from '@exodus/solana-api'
26
28
  import { createGetBalanceForAddress } from './get-balance-for-address'
29
+ import { createWeb3API } from './web3'
27
30
 
28
31
  const DEFAULT_ACCOUNT_RESERVE = 0.01
29
32
  const DEFAULT_LOW_BALANCE = 0.01
@@ -171,6 +174,11 @@ export const createSolanaAssetFactory =
171
174
  : signMessageNew({ privateKey, message }),
172
175
  staking: assetStakingApi,
173
176
  validateAssetId: isValidAddress,
177
+ web3: createWeb3API({
178
+ asset: base,
179
+ prepareForSigning,
180
+ fillTransactionWithEmptySignatureSlot,
181
+ }),
174
182
  }
175
183
 
176
184
  const fullAsset = {
@@ -0,0 +1,36 @@
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 = ({
6
+ asset,
7
+ prepareForSigning,
8
+ fillTransactionWithEmptySignatureSlot,
9
+ }) => {
10
+ assert(asset, '"asset" should be passed.')
11
+ assert(prepareForSigning, '"prepareForSigning" should be passed.')
12
+ assert(
13
+ fillTransactionWithEmptySignatureSlot,
14
+ '"fillTransactionWithEmptySignatureSlot" should be passed.'
15
+ )
16
+
17
+ const simulateSolanaTransactions = createSimulateSolanaTransactions()
18
+
19
+ return function simulateTransactions({ transactionBuffers, unsignedTxs, ...restParameters }) {
20
+ if (unsignedTxs) {
21
+ // Converts to web3.js Transaction class instances.
22
+ const transactions = unsignedTxs.map((unsignedTx) => {
23
+ const transaction = prepareForSigning(unsignedTx)
24
+ fillTransactionWithEmptySignatureSlot({ transaction, publicKey: transaction.feePayer })
25
+
26
+ return transaction
27
+ })
28
+
29
+ return simulateSolanaTransactions({
30
+ asset,
31
+ transactions,
32
+ ...restParameters,
33
+ })
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,7 @@
1
+ import { createSimulateTransactions } from './createSimulateTransactions'
2
+
3
+ export const createWeb3API = (deps) => {
4
+ return {
5
+ simulateTransactions: createSimulateTransactions(deps),
6
+ }
7
+ }