@suilend/sui-fe 0.3.11 → 0.3.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/lib/keypair.d.ts CHANGED
@@ -29,7 +29,7 @@ export type FundKeypairResult = {
29
29
  };
30
30
  export declare const fundKeypair: (tokens: (Token & {
31
31
  amount: BigNumber;
32
- })[], keypair: Ed25519Keypair, signExecuteAndWaitForTransaction: (transaction: Transaction, options?: {
32
+ })[], keypair: Ed25519Keypair, suiClient: SuiClient, signExecuteAndWaitForTransaction: (transaction: Transaction, options?: {
33
33
  auction?: boolean;
34
34
  }, onSetGasBudget?: (transaction: Transaction) => void, onSign?: (signedTransaction: SignatureWithBytes) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<SuiTransactionBlockResponse>, // From WalletContext
35
35
  onSign?: (signedTransaction: SignatureWithBytes) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<{
package/lib/keypair.js CHANGED
@@ -181,23 +181,31 @@ const checkIfKeypairCanBeUsed = (lastSignedTransaction, currentFlowDigests, keyp
181
181
  }
182
182
  });
183
183
  exports.checkIfKeypairCanBeUsed = checkIfKeypairCanBeUsed;
184
- const fundKeypair = (tokens, keypair, signExecuteAndWaitForTransaction, // From WalletContext
184
+ const fundKeypair = (tokens, keypair, suiClient, signExecuteAndWaitForTransaction, // From WalletContext
185
185
  onSign, onExecute) => __awaiter(void 0, void 0, void 0, function* () {
186
186
  console.log("[fundKeypair] tokens:", tokens.map((t) => ({
187
187
  coinType: t.coinType,
188
188
  amount: t.amount.toString(),
189
189
  })));
190
- const fundKeypairTransaction = new transactions_1.Transaction();
191
- const coinsWithBalance = tokens.map((token) => (0, transactions_1.coinWithBalance)({
192
- balance: BigInt(token
193
- .amount.times(10 ** token.decimals)
194
- .integerValue(bignumber_js_1.default.ROUND_DOWN)
195
- .toString()),
196
- type: token.coinType,
197
- useGasCoin: (0, coinType_1.isSui)(token.coinType),
198
- })(fundKeypairTransaction));
199
- fundKeypairTransaction.transferObjects(coinsWithBalance, keypair.toSuiAddress());
200
- const res = yield signExecuteAndWaitForTransaction(fundKeypairTransaction, undefined, undefined, onSign, onExecute);
190
+ const allCoins = yield Promise.all(tokens.map((token) => (0, transactions_2.getAllCoins)(suiClient, keypair.toSuiAddress(), token.coinType)));
191
+ const transaction = new transactions_1.Transaction();
192
+ transaction.setSender(keypair.toSuiAddress());
193
+ const mergeCoins = tokens.map((token, index) => (0, transactions_2.mergeAllCoins)(token.coinType, transaction, allCoins[index]));
194
+ const coins = [];
195
+ for (let i = 0; i < tokens.length; i++) {
196
+ const token = tokens[i];
197
+ const [coin] = transaction.splitCoins((0, coinType_1.isSui)(token.coinType)
198
+ ? transaction.gas
199
+ : transaction.object(mergeCoins[i].coinObjectId), [
200
+ BigInt(token
201
+ .amount.times(10 ** token.decimals)
202
+ .integerValue(bignumber_js_1.default.ROUND_DOWN)
203
+ .toString()),
204
+ ]);
205
+ coins.push(coin);
206
+ }
207
+ transaction.transferObjects(coins, keypair.toSuiAddress());
208
+ const res = yield signExecuteAndWaitForTransaction(transaction, undefined, undefined, onSign, onExecute);
201
209
  return { res };
202
210
  });
203
211
  exports.fundKeypair = fundKeypair;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@suilend/sui-fe","version":"0.3.11","private":false,"description":"A collection of TypeScript frontend libraries","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./lib/api":"./lib/api.js","./lib/coin":"./lib/coin.js","./lib/coinMetadata":"./lib/coinMetadata.js","./lib/coinType":"./lib/coinType.js","./lib/constants":"./lib/constants.js","./lib/format":"./lib/format.js","./lib":"./lib/index.js","./lib/indexedDB":"./lib/indexedDB.js","./lib/keypair":"./lib/keypair.js","./lib/ledger":"./lib/ledger.js","./lib/msafe":"./lib/msafe.js","./lib/track":"./lib/track.js","./lib/transactions":"./lib/transactions.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix \"./src/**/*.ts\"","prettier":"prettier --write \"./src/**/*\"","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ts-node ./release.ts && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/suilend/sui-fe.git"},"bugs":{"url":"https://github.com/suilend/sui-fe/issues"},"dependencies":{"@mysten/wallet-standard":"0.14.7","@pythnetwork/pyth-sui-js":"^2.1.0","bignumber.js":"^9.1.2","blake2b":"^2.1.4","lodash":"^4.17.21","mixpanel-browser":"^2.56.0","next":"^15.0.3","p-limit":"3.1.0"},"devDependencies":{"@tsconfig/recommended":"^1.0.8","@types/blake2b":"^2.1.3","@types/lodash":"^4.17.13","@types/mixpanel-browser":"^2.50.2","@types/node":"^22.9.0","@typescript-eslint/eslint-plugin":"^8.14.0","@typescript-eslint/parser":"^8.14.0","eslint":"^9.14.0","eslint-config-next":"^15.0.3","eslint-config-prettier":"^9.1.0","eslint-plugin-import":"^2.31.0","eslint-plugin-prettier":"^5.2.1","prettier":"^3.3.3","ts-node":"^10.9.2","typescript":"^5.6.3"},"peerDependencies":{"@mysten/sui":"1.28.2","date-fns":"^4.1.0"}}
1
+ {"name":"@suilend/sui-fe","version":"0.3.13","private":false,"description":"A collection of TypeScript frontend libraries","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./lib/api":"./lib/api.js","./lib/coin":"./lib/coin.js","./lib/coinMetadata":"./lib/coinMetadata.js","./lib/coinType":"./lib/coinType.js","./lib/constants":"./lib/constants.js","./lib/format":"./lib/format.js","./lib":"./lib/index.js","./lib/indexedDB":"./lib/indexedDB.js","./lib/keypair":"./lib/keypair.js","./lib/ledger":"./lib/ledger.js","./lib/msafe":"./lib/msafe.js","./lib/track":"./lib/track.js","./lib/transactions":"./lib/transactions.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix \"./src/**/*.ts\"","prettier":"prettier --write \"./src/**/*\"","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ts-node ./release.ts && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/suilend/sui-fe.git"},"bugs":{"url":"https://github.com/suilend/sui-fe/issues"},"dependencies":{"@mysten/wallet-standard":"0.14.7","@pythnetwork/pyth-sui-js":"^2.1.0","bignumber.js":"^9.1.2","blake2b":"^2.1.4","lodash":"^4.17.21","mixpanel-browser":"^2.56.0","next":"^15.0.3","p-limit":"3.1.0"},"devDependencies":{"@tsconfig/recommended":"^1.0.8","@types/blake2b":"^2.1.3","@types/lodash":"^4.17.13","@types/mixpanel-browser":"^2.50.2","@types/node":"^22.9.0","@typescript-eslint/eslint-plugin":"^8.14.0","@typescript-eslint/parser":"^8.14.0","eslint":"^9.14.0","eslint-config-next":"^15.0.3","eslint-config-prettier":"^9.1.0","eslint-plugin-import":"^2.31.0","eslint-plugin-prettier":"^5.2.1","prettier":"^3.3.3","ts-node":"^10.9.2","typescript":"^5.6.3"},"peerDependencies":{"@mysten/sui":"1.28.2","date-fns":"^4.1.0"}}