@exodus/solana-api 3.3.2 → 3.4.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 +3 -3
- package/src/api.js +29 -12
- package/src/tx-send.js +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Exodus internal Solana asset API wrapper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@exodus/models": "^10.1.0",
|
|
30
30
|
"@exodus/nfts-core": "^0.5.0",
|
|
31
31
|
"@exodus/simple-retry": "^0.0.6",
|
|
32
|
-
"@exodus/solana-lib": "^3.0
|
|
32
|
+
"@exodus/solana-lib": "^3.1.0",
|
|
33
33
|
"@exodus/solana-meta": "^1.0.7",
|
|
34
34
|
"bn.js": "^4.11.0",
|
|
35
35
|
"debug": "^4.1.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@exodus/assets-testing": "^1.0.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "0214827414fb3ac874b22cef41dae41bcef98ed6"
|
|
48
48
|
}
|
package/src/api.js
CHANGED
|
@@ -929,10 +929,10 @@ export class Api {
|
|
|
929
929
|
|
|
930
930
|
simulateTransaction = async (encodedTransaction, options) => {
|
|
931
931
|
const {
|
|
932
|
-
value: { accounts },
|
|
932
|
+
value: { accounts, unitsConsumed, err },
|
|
933
933
|
} = await this.rpcCall('simulateTransaction', [encodedTransaction, options])
|
|
934
934
|
|
|
935
|
-
return accounts
|
|
935
|
+
return { accounts, unitsConsumed, err }
|
|
936
936
|
}
|
|
937
937
|
|
|
938
938
|
resolveSimulationSideEffects = async (solAccounts, tokenAccounts) => {
|
|
@@ -1045,14 +1045,7 @@ export class Api {
|
|
|
1045
1045
|
}
|
|
1046
1046
|
}
|
|
1047
1047
|
|
|
1048
|
-
|
|
1049
|
-
* Simulate transaction and return side effects
|
|
1050
|
-
*/
|
|
1051
|
-
simulateAndRetrieveSideEffects = async (
|
|
1052
|
-
message,
|
|
1053
|
-
publicKey,
|
|
1054
|
-
transactionMessage // decompiled TransactionMessage
|
|
1055
|
-
) => {
|
|
1048
|
+
simulateUnsignedTransaction = async ({ message, transactionMessage }) => {
|
|
1056
1049
|
const { config, accountAddresses } = getTransactionSimulationParams(
|
|
1057
1050
|
transactionMessage || message
|
|
1058
1051
|
)
|
|
@@ -1062,9 +1055,33 @@ export class Api {
|
|
|
1062
1055
|
Buffer.from(message.serialize()),
|
|
1063
1056
|
signatures
|
|
1064
1057
|
).toString('base64')
|
|
1065
|
-
const
|
|
1058
|
+
const { accounts, unitsConsumed, err } = await this.simulateTransaction(encodedTransaction, {
|
|
1059
|
+
...config,
|
|
1060
|
+
replaceRecentBlockhash: true,
|
|
1061
|
+
sigVerify: false,
|
|
1062
|
+
})
|
|
1063
|
+
return {
|
|
1064
|
+
accounts,
|
|
1065
|
+
accountAddresses,
|
|
1066
|
+
unitsConsumed,
|
|
1067
|
+
err,
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Simulate transaction and return side effects
|
|
1073
|
+
*/
|
|
1074
|
+
simulateAndRetrieveSideEffects = async (
|
|
1075
|
+
message,
|
|
1076
|
+
publicKey,
|
|
1077
|
+
transactionMessage // decompiled TransactionMessage
|
|
1078
|
+
) => {
|
|
1079
|
+
const { accounts, accountAddresses } = await this.simulateUnsignedTransaction({
|
|
1080
|
+
message,
|
|
1081
|
+
transactionMessage,
|
|
1082
|
+
})
|
|
1066
1083
|
const { solAccounts, tokenAccounts } = filterAccountsByOwner(
|
|
1067
|
-
|
|
1084
|
+
accounts,
|
|
1068
1085
|
accountAddresses,
|
|
1069
1086
|
publicKey
|
|
1070
1087
|
)
|
package/src/tx-send.js
CHANGED
|
@@ -141,9 +141,10 @@ export const createAndBroadcastTXFactory =
|
|
|
141
141
|
|
|
142
142
|
let { priorityFee } = feeData
|
|
143
143
|
|
|
144
|
+
const transactionForFeeEstimation = prepareForSigning(unsignedTransaction)
|
|
145
|
+
|
|
144
146
|
if (!priorityFee) {
|
|
145
147
|
try {
|
|
146
|
-
const transactionForFeeEstimation = prepareForSigning(unsignedTransaction)
|
|
147
148
|
priorityFee = await api.getPriorityFee(transactionToBase58(transactionForFeeEstimation))
|
|
148
149
|
} catch (e) {
|
|
149
150
|
console.warn(`Failed to fetch priority fee: ${e.message}`)
|
|
@@ -151,7 +152,12 @@ export const createAndBroadcastTXFactory =
|
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
const { unitsConsumed: computeUnits } = await api.simulateUnsignedTransaction({
|
|
156
|
+
message: transactionForFeeEstimation.compileMessage(),
|
|
157
|
+
})
|
|
158
|
+
|
|
154
159
|
unsignedTransaction.txData.priorityFee = priorityFee
|
|
160
|
+
unsignedTransaction.txData.computeUnits = computeUnits
|
|
155
161
|
|
|
156
162
|
const { txId, rawTx } = await assetClientInterface.signTransaction({
|
|
157
163
|
assetName: baseAsset.name,
|