@meshconnect/web-link-sdk 3.2.8 → 3.2.10

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": "@meshconnect/web-link-sdk",
3
- "version": "3.2.8",
3
+ "version": "3.2.10",
4
4
  "description": "A client-side JS library for integrating with Mesh Connect",
5
5
  "exports": "./index.js",
6
6
  "license": "MIT",
@@ -115,7 +115,7 @@ export function createSPLTransferInstruction(_a) {
115
115
  }
116
116
  export function createTransferTransaction(config) {
117
117
  return __awaiter(this, void 0, void 0, function () {
118
- var fromPubkey, toPubkey, instructions, connection, token2022Accounts, tokenProgram, tokenMintPubkey, fromTokenAccount, toTokenAccount, messageV0;
118
+ var fromPubkey, toPubkey, instructions, connection, token2022Accounts, tokenMintPubkey, fromTokenAccount2022_1, tokenProgram, fromTokenAccount, toTokenAccount_1, messageV0;
119
119
  var _a;
120
120
  return __generator(this, function (_b) {
121
121
  switch (_b.label) {
@@ -129,7 +129,7 @@ export function createTransferTransaction(config) {
129
129
  toPubkey: toPubkey,
130
130
  lamports: Number(config.amount)
131
131
  }));
132
- return [3 /*break*/, 6];
132
+ return [3 /*break*/, 7];
133
133
  case 1:
134
134
  connection = void 0;
135
135
  // special use case for PYUSD on solana devnet. TODO: make it generic
@@ -142,37 +142,40 @@ export function createTransferTransaction(config) {
142
142
  return [4 /*yield*/, connection.getTokenAccountsByOwner(fromPubkey, { programId: TOKEN_2022_PROGRAM_ID })];
143
143
  case 2:
144
144
  token2022Accounts = _b.sent();
145
- tokenProgram = (token2022Accounts === null || token2022Accounts === void 0 ? void 0 : token2022Accounts.value.length)
145
+ tokenMintPubkey = new PublicKey(config.tokenMint);
146
+ return [4 /*yield*/, getAssociatedTokenAddress(tokenMintPubkey, fromPubkey, TOKEN_2022_PROGRAM_ID.toBase58())];
147
+ case 3:
148
+ fromTokenAccount2022_1 = _b.sent();
149
+ tokenProgram = (token2022Accounts === null || token2022Accounts === void 0 ? void 0 : token2022Accounts.value.filter(function (x) { return x.pubkey.toBase58() === fromTokenAccount2022_1.toBase58(); }).length)
146
150
  ? TOKEN_2022_PROGRAM_ID
147
151
  : TOKEN_PROGRAM_ID;
148
152
  config.tokenProgram = tokenProgram.toBase58();
149
- tokenMintPubkey = new PublicKey(config.tokenMint);
150
153
  return [4 /*yield*/, getAssociatedTokenAddress(tokenMintPubkey, fromPubkey, config.tokenProgram)];
151
- case 3:
154
+ case 4:
152
155
  fromTokenAccount = _b.sent();
153
156
  return [4 /*yield*/, getAssociatedTokenAddress(tokenMintPubkey, toPubkey, config.tokenProgram)];
154
- case 4:
155
- toTokenAccount = _b.sent();
157
+ case 5:
158
+ toTokenAccount_1 = _b.sent();
156
159
  return [4 /*yield*/, connection.getTokenAccountsByOwner(toPubkey, {
157
160
  programId: tokenProgram
158
161
  })];
159
- case 5:
160
- if (!((_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.value.length)) {
161
- instructions.push(createTokenAccountInstruction(toPubkey, toTokenAccount, toPubkey, tokenMintPubkey, tokenProgram));
162
+ case 6:
163
+ if (!((_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.value.filter(function (x) { return x.pubkey.toBase58() === toTokenAccount_1.toBase58(); }).length)) {
164
+ instructions.push(createTokenAccountInstruction(fromPubkey, toTokenAccount_1, toPubkey, tokenMintPubkey, tokenProgram));
162
165
  }
163
166
  if (config.tokenProgram === TOKEN_2022_PROGRAM_ID.toBase58()) {
164
- instructions.push(createTransferCheckedInstruction(fromTokenAccount, toTokenAccount, fromPubkey, BigInt(config.amount), config.tokenDecimals, tokenMintPubkey));
167
+ instructions.push(createTransferCheckedInstruction(fromTokenAccount, toTokenAccount_1, fromPubkey, BigInt(config.amount), config.tokenDecimals, tokenMintPubkey));
165
168
  }
166
169
  else {
167
170
  instructions.push(createSPLTransferInstruction({
168
171
  fromTokenAccount: fromTokenAccount,
169
- toTokenAccount: toTokenAccount,
172
+ toTokenAccount: toTokenAccount_1,
170
173
  owner: fromPubkey,
171
174
  amount: BigInt(config.amount)
172
175
  }));
173
176
  }
174
- _b.label = 6;
175
- case 6:
177
+ _b.label = 7;
178
+ case 7:
176
179
  messageV0 = new TransactionMessage({
177
180
  payerKey: fromPubkey,
178
181
  recentBlockhash: config.blockhash,
@@ -1 +1 @@
1
- export declare const sdkVersion = "3.2.8";
1
+ export declare const sdkVersion = "3.2.10";
package/utils/version.js CHANGED
@@ -1 +1 @@
1
- export var sdkVersion = '3.2.8';
1
+ export var sdkVersion = '3.2.10';