@dynamic-labs/embedded-wallet-solana 3.0.0-alpha.13 → 3.0.0-alpha.15

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/CHANGELOG.md CHANGED
@@ -1,4 +1,50 @@
1
1
 
2
+ ## [3.0.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.14...v3.0.0-alpha.15) (2024-07-11)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * catch third party wallet construction errors ([#6268](https://github.com/dynamic-labs/DynamicAuth/issues/6268)) ([badef39](https://github.com/dynamic-labs/DynamicAuth/commit/badef39d753c7d29925c6c8680053027bd99b69b))
8
+ * decode all solana transactions ([#6294](https://github.com/dynamic-labs/DynamicAuth/issues/6294)) ([5220ab2](https://github.com/dynamic-labs/DynamicAuth/commit/5220ab29381f3a7f1afc7043332b5a018b47eb0a))
9
+ * passkey cta ([#6255](https://github.com/dynamic-labs/DynamicAuth/issues/6255)) ([1b1b152](https://github.com/dynamic-labs/DynamicAuth/commit/1b1b152a24b409c5d941a9c92a003daf0bbe48a1))
10
+
11
+ ## [3.0.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.13...v3.0.0-alpha.14) (2024-07-09)
12
+
13
+
14
+ ### ⚠ BREAKING CHANGES
15
+
16
+ * remove setPrimaryWallet in favor of useSwitchWallet (#6212)
17
+ * move getBalance method to wallet so it can be fetched for any wallet not just the active one (#6200)
18
+ * make Wallet a class instead of just a type (#6094)
19
+
20
+ ### Features
21
+
22
+ * add @dynamic-labs/solana-extension ([#6140](https://github.com/dynamic-labs/DynamicAuth/issues/6140)) ([c0e2a06](https://github.com/dynamic-labs/DynamicAuth/commit/c0e2a067dd83163094b58a15696df8654da47c65))
23
+ * add solana support for multi-asset ([#6222](https://github.com/dynamic-labs/DynamicAuth/issues/6222)) ([9660d79](https://github.com/dynamic-labs/DynamicAuth/commit/9660d7962f1fb01011d68397bb367fdfc5335ca9))
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * allow closing re-connect wallet modal ([#6250](https://github.com/dynamic-labs/DynamicAuth/issues/6250)) ([55ba25b](https://github.com/dynamic-labs/DynamicAuth/commit/55ba25bd3e907629aaa26e788885bfa38f8fe350))
29
+ * move getBalance method to wallet so it can be fetched for any wallet not just the active one ([#6200](https://github.com/dynamic-labs/DynamicAuth/issues/6200)) ([ee94773](https://github.com/dynamic-labs/DynamicAuth/commit/ee94773df9b31462a325666760fcf1fc70dec68a))
30
+ * move getNameService method to wallet so name service data can be fetched for any wallet ([#6205](https://github.com/dynamic-labs/DynamicAuth/issues/6205)) ([6671ae9](https://github.com/dynamic-labs/DynamicAuth/commit/6671ae92532ffc1889e24519e75f47d336ac0da6))
31
+ * relax phone number length validation ([#6226](https://github.com/dynamic-labs/DynamicAuth/issues/6226)) ([f0969b4](https://github.com/dynamic-labs/DynamicAuth/commit/f0969b4fbdafde07125cddecb16b4bfd011ea65e))
32
+ * sdkHasLoaded flipping back to false with otp ([#6242](https://github.com/dynamic-labs/DynamicAuth/issues/6242)) ([32ad9dd](https://github.com/dynamic-labs/DynamicAuth/commit/32ad9dd2dae7775f494506773fb343fe1a249c65))
33
+ * send transaction demo undefined address/value ([#6248](https://github.com/dynamic-labs/DynamicAuth/issues/6248)) ([036a511](https://github.com/dynamic-labs/DynamicAuth/commit/036a511fb848ef461edd9b7a5d79d478b0f1cf23))
34
+ * set last active account on accountChange request ([#6218](https://github.com/dynamic-labs/DynamicAuth/issues/6218)) ([05797d2](https://github.com/dynamic-labs/DynamicAuth/commit/05797d292aab8b4de02555594d4d1bbd4c9543eb))
35
+ * show ledger toggle when linking wallet ([#6202](https://github.com/dynamic-labs/DynamicAuth/issues/6202)) ([a449c0b](https://github.com/dynamic-labs/DynamicAuth/commit/a449c0bfc4e3a75ccd7084b930c48fbd6c14f691))
36
+ * show user wallet in profile view on single wallet mode even if it's not primary ([#6187](https://github.com/dynamic-labs/DynamicAuth/issues/6187)) ([ffaaeb2](https://github.com/dynamic-labs/DynamicAuth/commit/ffaaeb2c6cbb2868a381d85451ae5574024156bb))
37
+ * stop auto-switching to connected secondary wallet if primary wallet is not connected ([#6196](https://github.com/dynamic-labs/DynamicAuth/issues/6196)) ([4e8bcd2](https://github.com/dynamic-labs/DynamicAuth/commit/4e8bcd2d02d3fca54a0ed29c45b386ae99266b84))
38
+ * stop coinbase and solflare popups when secondary ([#6225](https://github.com/dynamic-labs/DynamicAuth/issues/6225)) ([7e9c104](https://github.com/dynamic-labs/DynamicAuth/commit/7e9c1049a09c9fd513c9a2a746d6baac916f1bf4))
39
+ * stop sending double sign request on network switch ([e325709](https://github.com/dynamic-labs/DynamicAuth/commit/e325709bb5d2d1331fe16cc705398fc7b1cc292a))
40
+ * tunrkey solana signer accept uint8array message ([#6137](https://github.com/dynamic-labs/DynamicAuth/issues/6137)) ([70f89ce](https://github.com/dynamic-labs/DynamicAuth/commit/70f89ce0dafa4c99b318c9c5adce59083cd6d284))
41
+ * update formatting of phantom bitcoin publickey ([#6210](https://github.com/dynamic-labs/DynamicAuth/issues/6210)) ([f58cea9](https://github.com/dynamic-labs/DynamicAuth/commit/f58cea99333fd7c6af8f56f637ee32f1f7ce8d76))
42
+ * use white color in farcaster qr code when in dark mode ([#6245](https://github.com/dynamic-labs/DynamicAuth/issues/6245)) ([a91958d](https://github.com/dynamic-labs/DynamicAuth/commit/a91958d8773be138da8f54791c4c67866257bbad))
43
+
44
+
45
+ * make Wallet a class instead of just a type ([#6094](https://github.com/dynamic-labs/DynamicAuth/issues/6094)) ([6dc4672](https://github.com/dynamic-labs/DynamicAuth/commit/6dc4672951cfadc22a6c569e74eae3485bd472f3))
46
+ * remove setPrimaryWallet in favor of useSwitchWallet ([#6212](https://github.com/dynamic-labs/DynamicAuth/issues/6212)) ([de125e1](https://github.com/dynamic-labs/DynamicAuth/commit/de125e1ebbc20507e4ec07f337f5f5fd13aabcbe))
47
+
2
48
  ## [3.0.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.12...v3.0.0-alpha.13) (2024-06-27)
3
49
 
4
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/embedded-wallet-solana",
3
- "version": "3.0.0-alpha.13",
3
+ "version": "3.0.0-alpha.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -33,14 +33,14 @@
33
33
  "@turnkey/iframe-stamper": "2.0.0",
34
34
  "@turnkey/solana": "0.3.1",
35
35
  "@turnkey/webauthn-stamper": "0.5.0",
36
- "@dynamic-labs/embedded-wallet": "3.0.0-alpha.13",
37
- "@dynamic-labs/rpc-provider-solana": "3.0.0-alpha.13",
38
- "@dynamic-labs/rpc-providers": "3.0.0-alpha.13",
39
- "@dynamic-labs/solana-utils": "3.0.0-alpha.13",
40
- "@dynamic-labs/types": "3.0.0-alpha.13",
41
- "@dynamic-labs/utils": "3.0.0-alpha.13",
42
- "@dynamic-labs/wallet-book": "3.0.0-alpha.13",
43
- "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.13",
36
+ "@dynamic-labs/embedded-wallet": "3.0.0-alpha.15",
37
+ "@dynamic-labs/rpc-provider-solana": "3.0.0-alpha.15",
38
+ "@dynamic-labs/rpc-providers": "3.0.0-alpha.15",
39
+ "@dynamic-labs/solana-utils": "3.0.0-alpha.15",
40
+ "@dynamic-labs/types": "3.0.0-alpha.15",
41
+ "@dynamic-labs/utils": "3.0.0-alpha.15",
42
+ "@dynamic-labs/wallet-book": "3.0.0-alpha.15",
43
+ "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.15",
44
44
  "viem": "2.9.25"
45
45
  },
46
46
  "peerDependencies": {}
@@ -16,13 +16,10 @@ class TurnkeySolanaSigner {
16
16
  ? new web3_js.PublicKey(this.turnkeyAddress)
17
17
  : undefined;
18
18
  }
19
- signMessage(message) {
19
+ signMessage(encodedMessage) {
20
20
  return _tslib.__awaiter(this, void 0, void 0, function* () {
21
- const signedMessage = yield this.walletConnector.signMessage(message);
22
- if (!signedMessage) {
23
- throw new Error('Failed to sign message');
24
- }
25
- return signedMessage;
21
+ const signedMessage = yield this.walletConnector.signUint8ArrayMessage(encodedMessage);
22
+ return { signature: signedMessage };
26
23
  });
27
24
  }
28
25
  signTransaction(transaction) {
@@ -1,5 +1,8 @@
1
1
  import { PublicKey, SendOptions, Transaction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
2
2
  import { TurnkeySolanaWalletConnector } from './TurnkeySolanaWalletConnector';
3
+ type SignedMessage = {
4
+ signature: Uint8Array;
5
+ };
3
6
  export type IEmbeddedWalletSolanaSigner = {
4
7
  publicKey?: {
5
8
  toBytes(): Uint8Array;
@@ -11,7 +14,7 @@ export type IEmbeddedWalletSolanaSigner = {
11
14
  signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
12
15
  signature: TransactionSignature;
13
16
  }>;
14
- signMessage(message: string, encoding?: string): Promise<string>;
17
+ signMessage(message: Uint8Array, encoding?: string): Promise<SignedMessage>;
15
18
  connect: (args?: {
16
19
  onlyIfTrusted: boolean;
17
20
  }) => Promise<{
@@ -29,7 +32,7 @@ export declare class TurnkeySolanaSigner implements IEmbeddedWalletSolanaSigner
29
32
  constructor({ walletConnector, }: {
30
33
  walletConnector: TurnkeySolanaWalletConnector;
31
34
  });
32
- signMessage(message: string): Promise<string>;
35
+ signMessage(encodedMessage: Uint8Array): Promise<SignedMessage>;
33
36
  signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
34
37
  signAllTransactions<T extends Transaction | VersionedTransaction>(_transactions: T[]): Promise<T[]>;
35
38
  signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
@@ -43,3 +46,4 @@ export declare class TurnkeySolanaSigner implements IEmbeddedWalletSolanaSigner
43
46
  } | undefined>;
44
47
  disconnect(): Promise<void>;
45
48
  }
49
+ export {};
@@ -12,13 +12,10 @@ class TurnkeySolanaSigner {
12
12
  ? new PublicKey(this.turnkeyAddress)
13
13
  : undefined;
14
14
  }
15
- signMessage(message) {
15
+ signMessage(encodedMessage) {
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
- const signedMessage = yield this.walletConnector.signMessage(message);
18
- if (!signedMessage) {
19
- throw new Error('Failed to sign message');
20
- }
21
- return signedMessage;
17
+ const signedMessage = yield this.walletConnector.signUint8ArrayMessage(encodedMessage);
18
+ return { signature: signedMessage };
22
19
  });
23
20
  }
24
21
  signTransaction(transaction) {
@@ -167,18 +167,11 @@ class TurnkeySolanaWalletConnector extends embeddedWallet.TurnkeyWalletConnector
167
167
  }
168
168
  getSigner() {
169
169
  return _tslib.__awaiter(this, void 0, void 0, function* () {
170
- if (this.isSessionKeyCompatible()) {
171
- yield this.createOrRestoreSession();
172
- }
173
170
  return new TurnkeySolanaSigner.TurnkeySolanaSigner({ walletConnector: this });
174
171
  });
175
172
  }
176
- getBalance() {
173
+ getBalance(address) {
177
174
  return _tslib.__awaiter(this, void 0, void 0, function* () {
178
- const address = this.getAccount();
179
- if (!address) {
180
- return undefined;
181
- }
182
175
  const connectionClient = this.getConnection();
183
176
  const publicKey = new web3_js.PublicKey(address);
184
177
  const balance = yield connectionClient.getBalance(publicKey);
@@ -186,33 +179,63 @@ class TurnkeySolanaWalletConnector extends embeddedWallet.TurnkeyWalletConnector
186
179
  return solBalance.toString();
187
180
  });
188
181
  }
189
- signMessage(messageToSign) {
182
+ signUint8ArrayMessage(encodedMessage) {
190
183
  return _tslib.__awaiter(this, void 0, void 0, function* () {
191
184
  if (!this.turnkeyAddress) {
192
185
  throw new utils.DynamicError('No turnkey account');
193
186
  }
194
187
  const address = this.turnkeyAddress;
195
- const signedMessage = yield this.walletUiUtils.signMessage({
188
+ let signedMessageRaw;
189
+ yield this.createOrRestoreSession();
190
+ yield this.walletUiUtils.signMessage({
196
191
  handler: () => _tslib.__awaiter(this, void 0, void 0, function* () {
197
- var _a;
198
- const enc = new TextEncoder();
199
- const encodedMessage = enc.encode(messageToSign);
200
- const signedMessageRaw = yield ((_a = (yield this.getTurnkeyAccount())) === null || _a === void 0 ? void 0 : _a.signMessage(encodedMessage, address));
192
+ const account = yield this.getTurnkeyAccount();
193
+ try {
194
+ signedMessageRaw = yield (account === null || account === void 0 ? void 0 : account.signMessage(encodedMessage, address));
195
+ }
196
+ catch (_a) {
197
+ yield this.removeSessionKeys();
198
+ yield this.createOrRestoreSession({
199
+ ignoreRestore: true,
200
+ });
201
+ signedMessageRaw = yield (account === null || account === void 0 ? void 0 : account.signMessage(encodedMessage, address));
202
+ }
201
203
  return utils.bufferToBase64(signedMessageRaw || Buffer.from([]));
202
204
  }),
203
- message: messageToSign,
205
+ message: new TextDecoder().decode(encodedMessage),
204
206
  });
205
- return signedMessage;
207
+ if (!signedMessageRaw) {
208
+ throw new Error('Failed to sign message');
209
+ }
210
+ return signedMessageRaw;
211
+ });
212
+ }
213
+ signMessage(messageToSign) {
214
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
215
+ const enc = new TextEncoder();
216
+ const encodedMessage = enc.encode(messageToSign);
217
+ const signedRawMessage = yield this.signUint8ArrayMessage(encodedMessage);
218
+ return utils.bufferToBase64(signedRawMessage);
206
219
  });
207
220
  }
208
221
  signTransaction(transaction) {
209
222
  return _tslib.__awaiter(this, void 0, void 0, function* () {
223
+ yield this.createOrRestoreSession();
210
224
  const account = yield this.getTurnkeyAccount();
211
225
  const address = this.turnkeyAddress;
212
226
  if (!account || !address) {
213
227
  throw new Error('No turnkey account');
214
228
  }
215
- yield account.addSignature(transaction, address);
229
+ try {
230
+ yield account.addSignature(transaction, address);
231
+ }
232
+ catch (_a) {
233
+ yield this.removeSessionKeys();
234
+ yield this.createOrRestoreSession({
235
+ ignoreRestore: true,
236
+ });
237
+ yield account.addSignature(transaction, address);
238
+ }
216
239
  return transaction;
217
240
  });
218
241
  }
@@ -40,7 +40,8 @@ export declare class TurnkeySolanaWalletConnector extends TurnkeyWalletConnector
40
40
  private createTurnkeyAccount;
41
41
  private getTurnkeyAccount;
42
42
  getSigner(): Promise<TurnkeySolanaSigner | undefined>;
43
- getBalance(): Promise<string | undefined>;
43
+ getBalance(address: string): Promise<string | undefined>;
44
+ signUint8ArrayMessage(encodedMessage: Uint8Array): Promise<Uint8Array>;
44
45
  signMessage(messageToSign: string): Promise<string | undefined>;
45
46
  signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
46
47
  internalSignAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<string>;
@@ -163,18 +163,11 @@ class TurnkeySolanaWalletConnector extends TurnkeyWalletConnectorBase {
163
163
  }
164
164
  getSigner() {
165
165
  return __awaiter(this, void 0, void 0, function* () {
166
- if (this.isSessionKeyCompatible()) {
167
- yield this.createOrRestoreSession();
168
- }
169
166
  return new TurnkeySolanaSigner({ walletConnector: this });
170
167
  });
171
168
  }
172
- getBalance() {
169
+ getBalance(address) {
173
170
  return __awaiter(this, void 0, void 0, function* () {
174
- const address = this.getAccount();
175
- if (!address) {
176
- return undefined;
177
- }
178
171
  const connectionClient = this.getConnection();
179
172
  const publicKey = new PublicKey(address);
180
173
  const balance = yield connectionClient.getBalance(publicKey);
@@ -182,33 +175,63 @@ class TurnkeySolanaWalletConnector extends TurnkeyWalletConnectorBase {
182
175
  return solBalance.toString();
183
176
  });
184
177
  }
185
- signMessage(messageToSign) {
178
+ signUint8ArrayMessage(encodedMessage) {
186
179
  return __awaiter(this, void 0, void 0, function* () {
187
180
  if (!this.turnkeyAddress) {
188
181
  throw new DynamicError('No turnkey account');
189
182
  }
190
183
  const address = this.turnkeyAddress;
191
- const signedMessage = yield this.walletUiUtils.signMessage({
184
+ let signedMessageRaw;
185
+ yield this.createOrRestoreSession();
186
+ yield this.walletUiUtils.signMessage({
192
187
  handler: () => __awaiter(this, void 0, void 0, function* () {
193
- var _a;
194
- const enc = new TextEncoder();
195
- const encodedMessage = enc.encode(messageToSign);
196
- const signedMessageRaw = yield ((_a = (yield this.getTurnkeyAccount())) === null || _a === void 0 ? void 0 : _a.signMessage(encodedMessage, address));
188
+ const account = yield this.getTurnkeyAccount();
189
+ try {
190
+ signedMessageRaw = yield (account === null || account === void 0 ? void 0 : account.signMessage(encodedMessage, address));
191
+ }
192
+ catch (_a) {
193
+ yield this.removeSessionKeys();
194
+ yield this.createOrRestoreSession({
195
+ ignoreRestore: true,
196
+ });
197
+ signedMessageRaw = yield (account === null || account === void 0 ? void 0 : account.signMessage(encodedMessage, address));
198
+ }
197
199
  return bufferToBase64(signedMessageRaw || Buffer.from([]));
198
200
  }),
199
- message: messageToSign,
201
+ message: new TextDecoder().decode(encodedMessage),
200
202
  });
201
- return signedMessage;
203
+ if (!signedMessageRaw) {
204
+ throw new Error('Failed to sign message');
205
+ }
206
+ return signedMessageRaw;
207
+ });
208
+ }
209
+ signMessage(messageToSign) {
210
+ return __awaiter(this, void 0, void 0, function* () {
211
+ const enc = new TextEncoder();
212
+ const encodedMessage = enc.encode(messageToSign);
213
+ const signedRawMessage = yield this.signUint8ArrayMessage(encodedMessage);
214
+ return bufferToBase64(signedRawMessage);
202
215
  });
203
216
  }
204
217
  signTransaction(transaction) {
205
218
  return __awaiter(this, void 0, void 0, function* () {
219
+ yield this.createOrRestoreSession();
206
220
  const account = yield this.getTurnkeyAccount();
207
221
  const address = this.turnkeyAddress;
208
222
  if (!account || !address) {
209
223
  throw new Error('No turnkey account');
210
224
  }
211
- yield account.addSignature(transaction, address);
225
+ try {
226
+ yield account.addSignature(transaction, address);
227
+ }
228
+ catch (_a) {
229
+ yield this.removeSessionKeys();
230
+ yield this.createOrRestoreSession({
231
+ ignoreRestore: true,
232
+ });
233
+ yield account.addSignature(transaction, address);
234
+ }
212
235
  return transaction;
213
236
  });
214
237
  }
@@ -54,7 +54,7 @@ const decodeTransaction = (transaction, connection, thisAddress) => _tslib.__awa
54
54
  let decodedInstructions = [];
55
55
  if ('version' in transaction) {
56
56
  const lookupTableAddresses = transaction.message.addressTableLookups.map((lookup) => new web3_js.PublicKey(lookup.accountKey));
57
- // for NON simple sol transfers we need to fetch the lookup table accounts
57
+ // For non-simple SOL transfers, we need to fetch the lookup table accounts
58
58
  if (lookupTableAddresses.length > 0) {
59
59
  const lookupTables = yield Promise.all(lookupTableAddresses.map((address) => connection.getAddressLookupTable(address)));
60
60
  const lookupTableAccounts = lookupTables
@@ -80,7 +80,7 @@ const decodeTransaction = (transaction, connection, thisAddress) => _tslib.__awa
80
80
  throw new utils.DynamicError('Bad formatted instruction');
81
81
  }
82
82
  const solTransfers = decodedInstructions.filter((instruction) => instruction.programId.equals(web3_js.SystemProgram.programId));
83
- // non SPL transfers, just SOL
83
+ // Non-SPL transfers, just SOL
84
84
  if (solTransfers.length > 0) {
85
85
  return solTransfers.map((decodedInstruction) => {
86
86
  const decodedTransferInstruction = web3_js.SystemInstruction.decodeTransfer(decodedInstruction);
@@ -91,13 +91,13 @@ const decodeTransaction = (transaction, connection, thisAddress) => _tslib.__awa
91
91
  });
92
92
  }
93
93
  // SPL transfers
94
- return Promise.all(decodedInstructions.map((instruction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
94
+ let splTransfers = yield Promise.all(decodedInstructions.map((instruction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
95
95
  var _h, _j, _k, _l, _m, _o, _p;
96
96
  if (instruction.programId.equals(splToken.TOKEN_PROGRAM_ID)) {
97
97
  const decodedTokenInstruction = splToken.decodeTransferInstructionUnchecked(instruction);
98
98
  const { source, destination } = decodedTokenInstruction.keys;
99
99
  if (destination) {
100
- // for contract interactions, ex. swaps, the destination is the turnkey address, flip sender and receiver
100
+ // For contract interactions, e.g., swaps, the destination is the turnkey address, flip sender and receiver
101
101
  if ((destination === null || destination === void 0 ? void 0 : destination.pubkey.toBase58()) === thisAddress) {
102
102
  return {
103
103
  from: thisAddress,
@@ -121,6 +121,17 @@ const decodeTransaction = (transaction, connection, thisAddress) => _tslib.__awa
121
121
  }
122
122
  return null;
123
123
  })));
124
+ splTransfers = splTransfers.filter((transfer) => transfer !== null);
125
+ if (splTransfers === null || splTransfers === void 0 ? void 0 : splTransfers.length)
126
+ return splTransfers;
127
+ // Return program IDs for non-SOL and non-SPL transfers
128
+ const noTransferDestinations = decodedInstructions.map((instruction) => ({
129
+ from: thisAddress,
130
+ to: instruction.programId.toBase58(),
131
+ }));
132
+ if (noTransferDestinations.length)
133
+ return noTransferDestinations;
134
+ return { from: thisAddress, to: 'Unknown' };
124
135
  });
125
136
  const summarizeTransactionDecodedData = (transactionsData) => {
126
137
  const recipients = new Set();
@@ -50,7 +50,7 @@ const decodeTransaction = (transaction, connection, thisAddress) => __awaiter(vo
50
50
  let decodedInstructions = [];
51
51
  if ('version' in transaction) {
52
52
  const lookupTableAddresses = transaction.message.addressTableLookups.map((lookup) => new PublicKey(lookup.accountKey));
53
- // for NON simple sol transfers we need to fetch the lookup table accounts
53
+ // For non-simple SOL transfers, we need to fetch the lookup table accounts
54
54
  if (lookupTableAddresses.length > 0) {
55
55
  const lookupTables = yield Promise.all(lookupTableAddresses.map((address) => connection.getAddressLookupTable(address)));
56
56
  const lookupTableAccounts = lookupTables
@@ -76,7 +76,7 @@ const decodeTransaction = (transaction, connection, thisAddress) => __awaiter(vo
76
76
  throw new DynamicError('Bad formatted instruction');
77
77
  }
78
78
  const solTransfers = decodedInstructions.filter((instruction) => instruction.programId.equals(SystemProgram.programId));
79
- // non SPL transfers, just SOL
79
+ // Non-SPL transfers, just SOL
80
80
  if (solTransfers.length > 0) {
81
81
  return solTransfers.map((decodedInstruction) => {
82
82
  const decodedTransferInstruction = SystemInstruction.decodeTransfer(decodedInstruction);
@@ -87,13 +87,13 @@ const decodeTransaction = (transaction, connection, thisAddress) => __awaiter(vo
87
87
  });
88
88
  }
89
89
  // SPL transfers
90
- return Promise.all(decodedInstructions.map((instruction) => __awaiter(void 0, void 0, void 0, function* () {
90
+ let splTransfers = yield Promise.all(decodedInstructions.map((instruction) => __awaiter(void 0, void 0, void 0, function* () {
91
91
  var _h, _j, _k, _l, _m, _o, _p;
92
92
  if (instruction.programId.equals(TOKEN_PROGRAM_ID)) {
93
93
  const decodedTokenInstruction = decodeTransferInstructionUnchecked(instruction);
94
94
  const { source, destination } = decodedTokenInstruction.keys;
95
95
  if (destination) {
96
- // for contract interactions, ex. swaps, the destination is the turnkey address, flip sender and receiver
96
+ // For contract interactions, e.g., swaps, the destination is the turnkey address, flip sender and receiver
97
97
  if ((destination === null || destination === void 0 ? void 0 : destination.pubkey.toBase58()) === thisAddress) {
98
98
  return {
99
99
  from: thisAddress,
@@ -117,6 +117,17 @@ const decodeTransaction = (transaction, connection, thisAddress) => __awaiter(vo
117
117
  }
118
118
  return null;
119
119
  })));
120
+ splTransfers = splTransfers.filter((transfer) => transfer !== null);
121
+ if (splTransfers === null || splTransfers === void 0 ? void 0 : splTransfers.length)
122
+ return splTransfers;
123
+ // Return program IDs for non-SOL and non-SPL transfers
124
+ const noTransferDestinations = decodedInstructions.map((instruction) => ({
125
+ from: thisAddress,
126
+ to: instruction.programId.toBase58(),
127
+ }));
128
+ if (noTransferDestinations.length)
129
+ return noTransferDestinations;
130
+ return { from: thisAddress, to: 'Unknown' };
120
131
  });
121
132
  const summarizeTransactionDecodedData = (transactionsData) => {
122
133
  const recipients = new Set();