@suilend/sui-fe 0.2.85 → 0.2.87

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
@@ -1,4 +1,5 @@
1
1
  import { SuiClient, SuiTransactionBlockResponse } from "@mysten/sui/client";
2
+ import { SignatureWithBytes } from "@mysten/sui/cryptography";
2
3
  import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
3
4
  import { Transaction } from "@mysten/sui/transactions";
4
5
  import { SuiSignPersonalMessageMethod, WalletAccount } from "@mysten/wallet-standard";
@@ -10,7 +11,8 @@ export declare const createKeypair: (account: WalletAccount, signPersonalMessage
10
11
  privateKey: string;
11
12
  }>;
12
13
  export declare const checkIfKeypairCanBeUsed: (currentFlowDigests: string[], keypair: Ed25519Keypair, suiClient: SuiClient) => Promise<void>;
13
- export declare const keypairSignExecuteAndWaitForTransaction: (transaction: Transaction, keypair: Ed25519Keypair, suiClient: SuiClient) => Promise<SuiTransactionBlockResponse>;
14
+ export declare const keypairWaitForTransaction: (digest: string, suiClient: SuiClient) => Promise<SuiTransactionBlockResponse>;
15
+ export declare const keypairSignExecuteAndWaitForTransaction: (transaction: Transaction, keypair: Ed25519Keypair, suiClient: SuiClient, onSign?: (signedTransaction: SignatureWithBytes) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<SuiTransactionBlockResponse>;
14
16
  export type FundKeypairResult = {
15
17
  res: SuiTransactionBlockResponse;
16
18
  };
package/lib/keypair.js CHANGED
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.returnAllOwnedObjectsAndSuiToUser = exports.fundKeypair = exports.keypairSignExecuteAndWaitForTransaction = exports.checkIfKeypairCanBeUsed = exports.createKeypair = void 0;
15
+ exports.returnAllOwnedObjectsAndSuiToUser = exports.fundKeypair = exports.keypairSignExecuteAndWaitForTransaction = exports.keypairWaitForTransaction = exports.checkIfKeypairCanBeUsed = exports.createKeypair = void 0;
16
16
  const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
17
17
  const transactions_1 = require("@mysten/sui/transactions");
18
18
  const utils_1 = require("@mysten/sui/utils");
@@ -74,31 +74,38 @@ const checkIfKeypairCanBeUsed = (currentFlowDigests, keypair, suiClient) => __aw
74
74
  }
75
75
  });
76
76
  exports.checkIfKeypairCanBeUsed = checkIfKeypairCanBeUsed;
77
- const keypairSignExecuteAndWaitForTransaction = (transaction, keypair, suiClient) => __awaiter(void 0, void 0, void 0, function* () {
77
+ const keypairWaitForTransaction = (digest, suiClient) => __awaiter(void 0, void 0, void 0, function* () {
78
78
  var _a, _b;
79
+ const res = yield suiClient.waitForTransaction({
80
+ digest,
81
+ options: {
82
+ showBalanceChanges: true,
83
+ showEffects: true,
84
+ showEvents: true,
85
+ showObjectChanges: true,
86
+ },
87
+ });
88
+ if (((_a = res.effects) === null || _a === void 0 ? void 0 : _a.status) !== undefined &&
89
+ res.effects.status.status === "failure")
90
+ throw new Error((_b = res.effects.status.error) !== null && _b !== void 0 ? _b : "Transaction failed");
91
+ return res;
92
+ });
93
+ exports.keypairWaitForTransaction = keypairWaitForTransaction;
94
+ const keypairSignExecuteAndWaitForTransaction = (transaction, keypair, suiClient, onSign, onExecute) => __awaiter(void 0, void 0, void 0, function* () {
79
95
  // 1) Sign
80
96
  const builtTransaction = yield transaction.build({
81
97
  client: suiClient,
82
98
  });
83
99
  const signedTransaction = yield keypair.signTransaction(builtTransaction);
100
+ onSign === null || onSign === void 0 ? void 0 : onSign(signedTransaction);
84
101
  // 2) Execute
85
102
  const res1 = yield suiClient.executeTransactionBlock({
86
103
  transactionBlock: signedTransaction.bytes,
87
104
  signature: signedTransaction.signature,
88
105
  });
106
+ onExecute === null || onExecute === void 0 ? void 0 : onExecute(res1);
89
107
  // 3) Wait
90
- const res2 = yield suiClient.waitForTransaction({
91
- digest: res1.digest,
92
- options: {
93
- showBalanceChanges: true,
94
- showEffects: true,
95
- showEvents: true,
96
- showObjectChanges: true,
97
- },
98
- });
99
- if (((_a = res2.effects) === null || _a === void 0 ? void 0 : _a.status) !== undefined &&
100
- res2.effects.status.status === "failure")
101
- throw new Error((_b = res2.effects.status.error) !== null && _b !== void 0 ? _b : "Transaction failed");
108
+ const res2 = yield (0, exports.keypairWaitForTransaction)(res1.digest, suiClient);
102
109
  return res2;
103
110
  });
104
111
  exports.keypairSignExecuteAndWaitForTransaction = keypairSignExecuteAndWaitForTransaction;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@suilend/sui-fe","version":"0.2.85","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/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","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/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.2.87","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/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","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/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"}}