@meshconnect/web-link-sdk 3.2.12 → 3.2.13

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.12",
3
+ "version": "3.2.13",
4
4
  "description": "A client-side JS library for integrating with Mesh Connect",
5
5
  "exports": "./index.js",
6
6
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  "util": "^0.12.4"
23
23
  },
24
24
  "dependencies": {
25
- "@meshconnect/node-api": "^2.0.20",
25
+ "@meshconnect/node-api": "^2.0.21",
26
26
  "@meshconnect/solana-web3.js": "^1.0.4",
27
27
  "bs58": "^5.0.0",
28
28
  "buffer": "^6.0.3",
@@ -34,7 +34,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- import { PublicKey, SystemProgram, TransactionMessage, VersionedTransaction, TransactionInstruction, Connection } from '@meshconnect/solana-web3.js';
37
+ import { PublicKey, SystemProgram, TransactionMessage, VersionedTransaction, TransactionInstruction } from '@meshconnect/solana-web3.js';
38
38
  import { getSolanaProvider } from './providerDiscovery';
39
39
  var TOKEN_PROGRAM_ID = new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
40
40
  var TOKEN_2022_PROGRAM_ID = new PublicKey('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb');
@@ -134,10 +134,9 @@ export function createTransferTransaction(config) {
134
134
  }
135
135
  function createTransferInstructions(config) {
136
136
  return __awaiter(this, void 0, void 0, function () {
137
- var fromPubkey, toPubkey, instructions, connection, token2022Accounts, tokenMintPubkey, fromTokenAccount2022_1, tokenProgram, fromTokenAccount, toTokenAccount_1;
138
- var _a;
139
- return __generator(this, function (_b) {
140
- switch (_b.label) {
137
+ var fromPubkey, toPubkey, instructions, tokenMintPubkey, fromTokenAccount, toTokenAccount;
138
+ return __generator(this, function (_a) {
139
+ switch (_a.label) {
141
140
  case 0:
142
141
  fromPubkey = new PublicKey(config.fromAddress);
143
142
  toPubkey = new PublicKey(config.toAddress);
@@ -148,53 +147,33 @@ function createTransferInstructions(config) {
148
147
  toPubkey: toPubkey,
149
148
  lamports: Number(config.amount)
150
149
  }));
151
- return [3 /*break*/, 7];
150
+ return [3 /*break*/, 4];
152
151
  case 1:
153
- connection = void 0;
154
- // special use case for PYUSD on solana devnet. TODO: make it generic
155
- if (config.tokenMint === 'CXk2AMBfi3TwaEL2468s6zP8xq9NxTXjp9gjMgzeUynM') {
156
- connection = new Connection('https://api.devnet.solana.com', 'confirmed');
157
- }
158
- else {
159
- connection = new Connection('https://alien-newest-vineyard.solana-mainnet.quiknode.pro/ebe5e35661d7edb7a5e48ab84bd9d477e472a40b', 'confirmed');
160
- }
161
- return [4 /*yield*/, connection.getTokenAccountsByOwner(fromPubkey, { programId: TOKEN_2022_PROGRAM_ID })];
162
- case 2:
163
- token2022Accounts = _b.sent();
164
152
  tokenMintPubkey = new PublicKey(config.tokenMint);
165
- return [4 /*yield*/, getAssociatedTokenAddress(tokenMintPubkey, fromPubkey, TOKEN_2022_PROGRAM_ID.toBase58())];
166
- case 3:
167
- fromTokenAccount2022_1 = _b.sent();
168
- tokenProgram = (token2022Accounts === null || token2022Accounts === void 0 ? void 0 : token2022Accounts.value.filter(function (x) { return x.pubkey.toBase58() === fromTokenAccount2022_1.toBase58(); }).length)
169
- ? TOKEN_2022_PROGRAM_ID
170
- : TOKEN_PROGRAM_ID;
171
- return [4 /*yield*/, getAssociatedTokenAddress(tokenMintPubkey, fromPubkey, tokenProgram.toBase58())];
172
- case 4:
173
- fromTokenAccount = _b.sent();
174
- config.tokenProgram = tokenProgram.toBase58();
153
+ return [4 /*yield*/, getAssociatedTokenAddress(tokenMintPubkey, fromPubkey, config.tokenProgram)];
154
+ case 2:
155
+ fromTokenAccount = _a.sent();
175
156
  return [4 /*yield*/, getAssociatedTokenAddress(tokenMintPubkey, toPubkey, config.tokenProgram)];
176
- case 5:
177
- toTokenAccount_1 = _b.sent();
178
- return [4 /*yield*/, connection.getTokenAccountsByOwner(toPubkey, {
179
- programId: tokenProgram
180
- })];
181
- case 6:
182
- if (!((_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.value.filter(function (x) { return x.pubkey.toBase58() === toTokenAccount_1.toBase58(); }).length)) {
183
- instructions.push(createTokenAccountInstruction(fromPubkey, toTokenAccount_1, toPubkey, tokenMintPubkey, tokenProgram));
157
+ case 3:
158
+ toTokenAccount = _a.sent();
159
+ if (config.createATA) {
160
+ instructions.push(createTokenAccountInstruction(fromPubkey, toTokenAccount, toPubkey, tokenMintPubkey, config.tokenProgram
161
+ ? new PublicKey(config.tokenProgram)
162
+ : TOKEN_PROGRAM_ID));
184
163
  }
185
164
  if (config.tokenProgram === TOKEN_2022_PROGRAM_ID.toBase58()) {
186
- instructions.push(createTransferCheckedInstruction(fromTokenAccount, toTokenAccount_1, fromPubkey, BigInt(config.amount), config.tokenDecimals, tokenMintPubkey));
165
+ instructions.push(createTransferCheckedInstruction(fromTokenAccount, toTokenAccount, fromPubkey, BigInt(config.amount), config.tokenDecimals, tokenMintPubkey));
187
166
  }
188
167
  else {
189
168
  instructions.push(createSPLTransferInstruction({
190
169
  fromTokenAccount: fromTokenAccount,
191
- toTokenAccount: toTokenAccount_1,
170
+ toTokenAccount: toTokenAccount,
192
171
  owner: fromPubkey,
193
172
  amount: BigInt(config.amount)
194
173
  }));
195
174
  }
196
- _b.label = 7;
197
- case 7: return [2 /*return*/, instructions];
175
+ _a.label = 4;
176
+ case 4: return [2 /*return*/, instructions];
198
177
  }
199
178
  });
200
179
  });
@@ -66,6 +66,7 @@ export interface TransactionConfig {
66
66
  blockhash: string;
67
67
  walletName: string;
68
68
  tokenMint?: string;
69
+ createATA?: boolean;
69
70
  tokenProgram?: string;
70
71
  tokenDecimals?: number;
71
72
  }
package/utils/types.d.ts CHANGED
@@ -133,7 +133,9 @@ export interface SmartContractPayload {
133
133
  account: string;
134
134
  value?: string;
135
135
  walletName?: string;
136
+ tokenProgram?: string;
136
137
  blockhash?: string;
138
+ createATA?: boolean;
137
139
  gasLimit?: number | null;
138
140
  maxFeePerGas?: number | null;
139
141
  maxPriorityFeePerGas?: number | null;
@@ -1 +1 @@
1
- export declare const sdkVersion = "3.2.12";
1
+ export declare const sdkVersion = "3.2.13";
package/utils/version.js CHANGED
@@ -1 +1 @@
1
- export var sdkVersion = '3.2.12';
1
+ export var sdkVersion = '3.2.13';
@@ -201,6 +201,8 @@ var SolanaWalletStrategy = /** @class */ (function (_super) {
201
201
  blockhash: payload.blockhash,
202
202
  walletName: payload.walletName || '',
203
203
  tokenMint: payload.address,
204
+ createATA: payload.createATA || false,
205
+ tokenProgram: payload.tokenProgram,
204
206
  tokenDecimals: decimals
205
207
  })];
206
208
  case 3: return [2 /*return*/, _c.sent()];
@@ -244,6 +246,8 @@ var SolanaWalletStrategy = /** @class */ (function (_super) {
244
246
  blockhash: payload.transactionInstructions.blockhash,
245
247
  walletName: payload.transactionInstructions.walletName || '',
246
248
  tokenMint: payload.transferConfig.address,
249
+ createATA: payload.transferConfig.createATA || false,
250
+ tokenProgram: payload.transferConfig.tokenProgram,
247
251
  tokenDecimals: decimals
248
252
  })];
249
253
  case 4: