@debridge-finance/solana-utils 5.0.0 → 5.1.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/LICENSE CHANGED
@@ -1,100 +1,100 @@
1
- Business Source License 1.1
2
-
3
- License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4
- "Business Source License" is a trademark of MariaDB Corporation Ab.
5
-
6
- -----------------------------------------------------------------------------
7
-
8
- Parameters
9
-
10
- Licensor: DxTech Inc. (Company No.155728732)
11
-
12
- Licensed Work: deBridge V1
13
- The Licensed Work is (c) 2021 DxTech Inc.
14
-
15
- Additional Use Grant: Any uses listed and defined at
16
- v1-license-grants.dbr.eth
17
-
18
- Change Date: The earlier of 31 December 2025 or a date specified at
19
- v1-license-date.dbr.eth
20
-
21
- Change License: GNU General Public License v2.0 or later
22
-
23
- -----------------------------------------------------------------------------
24
-
25
- Terms
26
-
27
- The Licensor hereby grants you the right to copy, modify, create derivative
28
- works, redistribute, and make non-production use of the Licensed Work. The
29
- Licensor may make an Additional Use Grant, above, permitting limited
30
- production use.
31
-
32
- Effective on the Change Date, or the fourth anniversary of the first publicly
33
- available distribution of a specific version of the Licensed Work under this
34
- License, whichever comes first, the Licensor hereby grants you rights under
35
- the terms of the Change License, and the rights granted in the paragraph
36
- above terminate.
37
-
38
- If your use of the Licensed Work does not comply with the requirements
39
- currently in effect as described in this License, you must purchase a
40
- commercial license from the Licensor, its affiliated entities, or authorized
41
- resellers, or you must refrain from using the Licensed Work.
42
-
43
- All copies of the original and modified Licensed Work, and derivative works
44
- of the Licensed Work, are subject to this License. This License applies
45
- separately for each version of the Licensed Work and the Change Date may vary
46
- for each version of the Licensed Work released by Licensor.
47
-
48
- You must conspicuously display this License on each original or modified copy
49
- of the Licensed Work. If you receive the Licensed Work in original or
50
- modified form from a third party, the terms and conditions set forth in this
51
- License apply to your use of that work.
52
-
53
- Any use of the Licensed Work in violation of this License will automatically
54
- terminate your rights under this License for the current and all other
55
- versions of the Licensed Work.
56
-
57
- This License does not grant you any right in any trademark or logo of
58
- Licensor or its affiliates (provided that you may use a trademark or logo of
59
- Licensor as expressly required by this License).
60
-
61
- TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
62
- AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
63
- EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
64
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
65
- TITLE.
66
-
67
- MariaDB hereby grants you permission to use this License’s text to license
68
- your works, and to refer to it using the trademark "Business Source License",
69
- as long as you comply with the Covenants of Licensor below.
70
-
71
- -----------------------------------------------------------------------------
72
-
73
- Covenants of Licensor
74
-
75
- In consideration of the right to use this License’s text and the "Business
76
- Source License" name and trademark, Licensor covenants to MariaDB, and to all
77
- other recipients of the licensed work to be provided by Licensor:
78
-
79
- 1. To specify as the Change License the GPL Version 2.0 or any later version,
80
- or a license that is compatible with GPL Version 2.0 or a later version,
81
- where "compatible" means that software provided under the Change License can
82
- be included in a program with software provided under GPL Version 2.0 or a
83
- later version. Licensor may specify additional Change Licenses without
84
- limitation.
85
-
86
- 2. To either: (a) specify an additional grant of rights to use that does not
87
- impose any additional restriction on the right granted in this License, as
88
- the Additional Use Grant; or (b) insert the text "None".
89
-
90
- 3. To specify a Change Date.
91
-
92
- 4. Not to modify this License in any other way.
93
-
94
- -----------------------------------------------------------------------------
95
-
96
- Notice
97
-
98
- The Business Source License (this document, or the "License") is not an Open
99
- Source license. However, the Licensed Work will eventually be made available
100
- under an Open Source License, as stated in this License.
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: DxTech Inc. (Company No.155728732)
11
+
12
+ Licensed Work: deBridge V1
13
+ The Licensed Work is (c) 2021 DxTech Inc.
14
+
15
+ Additional Use Grant: Any uses listed and defined at
16
+ v1-license-grants.dbr.eth
17
+
18
+ Change Date: The earlier of 31 December 2025 or a date specified at
19
+ v1-license-date.dbr.eth
20
+
21
+ Change License: GNU General Public License v2.0 or later
22
+
23
+ -----------------------------------------------------------------------------
24
+
25
+ Terms
26
+
27
+ The Licensor hereby grants you the right to copy, modify, create derivative
28
+ works, redistribute, and make non-production use of the Licensed Work. The
29
+ Licensor may make an Additional Use Grant, above, permitting limited
30
+ production use.
31
+
32
+ Effective on the Change Date, or the fourth anniversary of the first publicly
33
+ available distribution of a specific version of the Licensed Work under this
34
+ License, whichever comes first, the Licensor hereby grants you rights under
35
+ the terms of the Change License, and the rights granted in the paragraph
36
+ above terminate.
37
+
38
+ If your use of the Licensed Work does not comply with the requirements
39
+ currently in effect as described in this License, you must purchase a
40
+ commercial license from the Licensor, its affiliated entities, or authorized
41
+ resellers, or you must refrain from using the Licensed Work.
42
+
43
+ All copies of the original and modified Licensed Work, and derivative works
44
+ of the Licensed Work, are subject to this License. This License applies
45
+ separately for each version of the Licensed Work and the Change Date may vary
46
+ for each version of the Licensed Work released by Licensor.
47
+
48
+ You must conspicuously display this License on each original or modified copy
49
+ of the Licensed Work. If you receive the Licensed Work in original or
50
+ modified form from a third party, the terms and conditions set forth in this
51
+ License apply to your use of that work.
52
+
53
+ Any use of the Licensed Work in violation of this License will automatically
54
+ terminate your rights under this License for the current and all other
55
+ versions of the Licensed Work.
56
+
57
+ This License does not grant you any right in any trademark or logo of
58
+ Licensor or its affiliates (provided that you may use a trademark or logo of
59
+ Licensor as expressly required by this License).
60
+
61
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
62
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
63
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
64
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
65
+ TITLE.
66
+
67
+ MariaDB hereby grants you permission to use this License’s text to license
68
+ your works, and to refer to it using the trademark "Business Source License",
69
+ as long as you comply with the Covenants of Licensor below.
70
+
71
+ -----------------------------------------------------------------------------
72
+
73
+ Covenants of Licensor
74
+
75
+ In consideration of the right to use this License’s text and the "Business
76
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
77
+ other recipients of the licensed work to be provided by Licensor:
78
+
79
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
80
+ or a license that is compatible with GPL Version 2.0 or a later version,
81
+ where "compatible" means that software provided under the Change License can
82
+ be included in a program with software provided under GPL Version 2.0 or a
83
+ later version. Licensor may specify additional Change Licenses without
84
+ limitation.
85
+
86
+ 2. To either: (a) specify an additional grant of rights to use that does not
87
+ impose any additional restriction on the right granted in this License, as
88
+ the Additional Use Grant; or (b) insert the text "None".
89
+
90
+ 3. To specify a Change Date.
91
+
92
+ 4. Not to modify this License in any other way.
93
+
94
+ -----------------------------------------------------------------------------
95
+
96
+ Notice
97
+
98
+ The Business Source License (this document, or the "License") is not an Open
99
+ Source license. However, the Licensed Work will eventually be made available
100
+ under an Open Source License, as stated in this License.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # `solana-utils` by deBridge
2
-
3
- Common utils package to power communication with Solana contracts at [deBridge](https://debridge.finance).
1
+ # `solana-utils` by deBridge
2
+
3
+ Common utils package to power communication with Solana contracts at [deBridge](https://debridge.finance).
@@ -6504,8 +6504,8 @@ var constants = /*#__PURE__*/Object.freeze({
6504
6504
  dlnDst: dlnDst$1
6505
6505
  });
6506
6506
 
6507
- function getAccountInfo(connection, account, commitment = "confirmed") {
6508
- return __awaiter(this, void 0, void 0, function* () {
6507
+ function getAccountInfo(connection_1, account_1) {
6508
+ return __awaiter(this, arguments, void 0, function* (connection, account, commitment = "confirmed") {
6509
6509
  const info = yield connection.getAccountInfo(account, commitment);
6510
6510
  if (info) {
6511
6511
  // alchemy bug fix
@@ -6598,8 +6598,8 @@ function setBlockhash(transaction, blockhash) {
6598
6598
  }
6599
6599
  }
6600
6600
  function simulateTx(connection, tx, commitment, feePayer, convertToV0, alreadySigned) {
6601
- var _a;
6602
6601
  return __awaiter(this, void 0, void 0, function* () {
6602
+ var _a;
6603
6603
  let convert = convertToV0 && !alreadySigned;
6604
6604
  let txCopy = isVersionedTx(tx)
6605
6605
  ? new VersionedTransaction(tx.message, tx.signatures)
@@ -6644,11 +6644,11 @@ function simulateTx(connection, tx, commitment, feePayer, convertToV0, alreadySi
6644
6644
  * @returns
6645
6645
  */
6646
6646
  function sendAll(connection, wallet, transactions, options) {
6647
- var _a, _b, _c, _d, _e, _f, _g;
6648
6647
  return __awaiter(this, void 0, void 0, function* () {
6648
+ var _a, _b, _c, _d, _e, _f, _g;
6649
6649
  const skipSign = (_a = options === null || options === void 0 ? void 0 : options.skipSign) !== null && _a !== void 0 ? _a : false;
6650
6650
  const blockhashCommitment = (options === null || options === void 0 ? void 0 : options.blockhashCommitment) === undefined
6651
- ? (_b = connection.commitment) !== null && _b !== void 0 ? _b : "confirmed"
6651
+ ? ((_b = connection.commitment) !== null && _b !== void 0 ? _b : "confirmed")
6652
6652
  : options.blockhashCommitment;
6653
6653
  const simulationCommitment = (_c = options === null || options === void 0 ? void 0 : options.simulationCommtiment) !== null && _c !== void 0 ? _c : blockhashCommitment;
6654
6654
  const useMinContextSlot = (_d = options === null || options === void 0 ? void 0 : options.useMinContextSlot) !== null && _d !== void 0 ? _d : false;
@@ -10097,6 +10097,7 @@ function parseSplAccount(dataOrInfo) {
10097
10097
  return null;
10098
10098
  }
10099
10099
  const data = "executable" in dataOrInfo ? dataOrInfo.data : dataOrInfo;
10100
+ // if (data.length === 82) return null; // token mint
10100
10101
  try {
10101
10102
  return AccountLayout.decode(data);
10102
10103
  }
@@ -10285,8 +10286,8 @@ function checkIfAssociatedWalletExists(connection, mintAccount, originalWallet)
10285
10286
  });
10286
10287
  }
10287
10288
  function getTransactionAccountsForSimulationDiff(connection, tx) {
10288
- var _a, _b;
10289
10289
  return __awaiter(this, void 0, void 0, function* () {
10290
+ var _a, _b;
10290
10291
  const result = new Set();
10291
10292
  if ("version" in tx) {
10292
10293
  const ALTs = tx.message.addressTableLookups.map((alt) => alt.accountKey);
@@ -10302,19 +10303,23 @@ function getTransactionAccountsForSimulationDiff(connection, tx) {
10302
10303
  const accGetter = tx.message.getAccountKeys({
10303
10304
  addressLookupTableAccounts: parsedALTs,
10304
10305
  });
10306
+ const staticWritableOrSignerAccounts = [];
10307
+ for (let idx = 0; idx < accGetter.staticAccountKeys.length; idx += 1) {
10308
+ if (tx.message.isAccountSigner(idx) || tx.message.isAccountWritable(idx))
10309
+ staticWritableOrSignerAccounts.push(accGetter.staticAccountKeys[idx]);
10310
+ }
10305
10311
  for (const acc of [
10306
- ...accGetter.staticAccountKeys,
10312
+ ...staticWritableOrSignerAccounts,
10307
10313
  ...((_b = (_a = accGetter.accountKeysFromLookups) === null || _a === void 0 ? void 0 : _a.writable) !== null && _b !== void 0 ? _b : []),
10308
10314
  ]) {
10309
10315
  result.add(acc.toBase58());
10310
10316
  }
10311
10317
  }
10312
10318
  else {
10313
- for (const ix of tx.instructions) {
10314
- // we don't need read-only accounts and instruction.programId since they won't change
10315
- ix.keys
10316
- .filter((meta) => meta.isSigner || meta.isWritable)
10317
- .map((meta) => result.add(meta.pubkey.toBase58()));
10319
+ const compiled = tx.compileMessage();
10320
+ for (let idx = 0; idx < compiled.accountKeys.length; idx += 1) {
10321
+ if (compiled.isAccountSigner(idx) || compiled.isAccountWritable(idx))
10322
+ result.add(compiled.staticAccountKeys[idx].toBase58());
10318
10323
  }
10319
10324
  }
10320
10325
  return Array.from(result);
@@ -10376,6 +10381,11 @@ function getTransactionDiff(connection, tx, txAccounts) {
10376
10381
  },
10377
10382
  }),
10378
10383
  ]);
10384
+ if (simulatedTx.value.err !== null)
10385
+ throw new Error(JSON.stringify({
10386
+ err: simulatedTx.value.err,
10387
+ logs: simulatedTx.value.logs,
10388
+ }));
10379
10389
  const simulatesInfo = simulatedTx.value.accounts;
10380
10390
  const preBalances = parseMultipleAccounts(accountsInfo);
10381
10391
  const postBalances = parseMultipleAccounts(simulatesInfo);
@@ -10445,8 +10455,8 @@ var programs = /*#__PURE__*/Object.freeze({
10445
10455
  });
10446
10456
 
10447
10457
  function simulateTransaction(connection, tx, simulateConfig) {
10448
- var _a, _b, _c, _d, _e, _f, _g, _h;
10449
10458
  return __awaiter(this, void 0, void 0, function* () {
10459
+ var _a, _b, _c, _d, _e, _f, _g, _h;
10450
10460
  const addressesToGetDiffFor = ((_b = (_a = simulateConfig.accounts) === null || _a === void 0 ? void 0 : _a.addresses) !== null && _b !== void 0 ? _b : []).map((a) => new PublicKey(a));
10451
10461
  const accountsToFetch = addressesToGetDiffFor.length > 0
10452
10462
  ? yield connection.getMultipleAccountsInfo(addressesToGetDiffFor)