@suilend/sui-fe 0.3.2 → 0.3.3

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
@@ -14,8 +14,8 @@ export type LastSignedTransaction<T> = {
14
14
  signedTransaction: SignatureWithBytes;
15
15
  type: T;
16
16
  };
17
- export declare function checkLastTransactionSignature<T>(type: T, lastCurrentFlowTransaction: SuiTransactionBlockResponse | undefined, lastSignedTransaction: LastSignedTransaction<T> | undefined, setLastSignedTransaction: (value: LastSignedTransaction<T> | undefined) => void, suiClient: SuiClient, validCallback: (res: SuiTransactionBlockResponse) => Promise<void>, invalidCallback: () => Promise<void>): Promise<void>;
18
- export declare function onSign<T>(type: T, setLastSignedTransaction: (value: LastSignedTransaction<T> | undefined) => void, index?: number): (signedTransaction: SignatureWithBytes) => void;
17
+ export declare const checkLastTransactionSignature: <T>(type: T, lastCurrentFlowTransaction: SuiTransactionBlockResponse | undefined, lastSignedTransaction: LastSignedTransaction<T> | undefined, setLastSignedTransaction: (value: LastSignedTransaction<T> | undefined) => void, suiClient: SuiClient, validCallback: (res: SuiTransactionBlockResponse) => Promise<void>, invalidCallback: () => Promise<void>) => Promise<void>;
18
+ export declare const onSign: <T>(type: T, setLastSignedTransaction: (value: LastSignedTransaction<T> | undefined) => void, index?: number) => (signedTransaction: SignatureWithBytes) => void;
19
19
  export declare const createKeypair: (account: WalletAccount, signPersonalMessage: SuiSignPersonalMessageMethod) => Promise<{
20
20
  keypair: Ed25519Keypair;
21
21
  address: string;
package/lib/keypair.js CHANGED
@@ -12,9 +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.checkIfKeypairCanBeUsed = exports.createKeypair = exports.keypairSignExecuteAndWaitForTransaction = exports.keypairWaitForTransaction = exports.TransactionStatusError = void 0;
16
- exports.checkLastTransactionSignature = checkLastTransactionSignature;
17
- exports.onSign = onSign;
15
+ exports.returnAllOwnedObjectsAndSuiToUser = exports.fundKeypair = exports.checkIfKeypairCanBeUsed = exports.createKeypair = exports.onSign = exports.checkLastTransactionSignature = exports.keypairSignExecuteAndWaitForTransaction = exports.keypairWaitForTransaction = exports.TransactionStatusError = void 0;
18
16
  const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
19
17
  const transactions_1 = require("@mysten/sui/transactions");
20
18
  const utils_1 = require("@mysten/sui/utils");
@@ -64,42 +62,41 @@ const keypairSignExecuteAndWaitForTransaction = (transaction, keypair, suiClient
64
62
  return res2;
65
63
  });
66
64
  exports.keypairSignExecuteAndWaitForTransaction = keypairSignExecuteAndWaitForTransaction;
67
- function checkLastTransactionSignature(type, lastCurrentFlowTransaction, lastSignedTransaction, setLastSignedTransaction, suiClient, validCallback, invalidCallback) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- var _a, _b;
70
- console.log("[checkLastTransactionSignature]", {
71
- type,
72
- lastCurrentFlowTransaction,
73
- lastSignedTransaction,
74
- });
75
- if ((lastSignedTransaction === null || lastSignedTransaction === void 0 ? void 0 : lastSignedTransaction.type) === type &&
76
- ((_b = (_a = lastCurrentFlowTransaction === null || lastCurrentFlowTransaction === void 0 ? void 0 : lastCurrentFlowTransaction.transaction) === null || _a === void 0 ? void 0 : _a.txSignatures) !== null && _b !== void 0 ? _b : []).includes(lastSignedTransaction.signedTransaction.signature)) {
77
- console.log("[checkLastTransactionSignature] lastSignedTransaction type and signature MATCH");
78
- try {
79
- const res = yield (0, exports.keypairWaitForTransaction)(lastCurrentFlowTransaction.digest, suiClient); // Assumed to only throw if the transaction was executed but failed (e.g. insufficient gas), or if the connection was lost
80
- yield validCallback(res);
65
+ const checkLastTransactionSignature = (type, lastCurrentFlowTransaction, lastSignedTransaction, setLastSignedTransaction, suiClient, validCallback, invalidCallback) => __awaiter(void 0, void 0, void 0, function* () {
66
+ var _a, _b;
67
+ console.log("[checkLastTransactionSignature]", {
68
+ type,
69
+ lastCurrentFlowTransaction,
70
+ lastSignedTransaction,
71
+ });
72
+ if ((lastSignedTransaction === null || lastSignedTransaction === void 0 ? void 0 : lastSignedTransaction.type) === type &&
73
+ ((_b = (_a = lastCurrentFlowTransaction === null || lastCurrentFlowTransaction === void 0 ? void 0 : lastCurrentFlowTransaction.transaction) === null || _a === void 0 ? void 0 : _a.txSignatures) !== null && _b !== void 0 ? _b : []).includes(lastSignedTransaction.signedTransaction.signature)) {
74
+ console.log("[checkLastTransactionSignature] lastSignedTransaction type and signature MATCH");
75
+ try {
76
+ const res = yield (0, exports.keypairWaitForTransaction)(lastCurrentFlowTransaction.digest, suiClient); // Assumed to only throw if the transaction was executed but failed (e.g. insufficient gas), or if the connection was lost
77
+ yield validCallback(res);
78
+ setLastSignedTransaction(undefined);
79
+ }
80
+ catch (err) {
81
+ console.error("[checkLastTransactionSignature]", err);
82
+ if (err instanceof TransactionStatusError) {
83
+ console.log("[checkLastTransactionSignature] TransactionStatusError");
81
84
  setLastSignedTransaction(undefined);
85
+ yield invalidCallback();
82
86
  }
83
- catch (err) {
84
- console.error("[checkLastTransactionSignature]", err);
85
- if (err instanceof TransactionStatusError) {
86
- console.log("[checkLastTransactionSignature] TransactionStatusError");
87
- setLastSignedTransaction(undefined);
88
- yield invalidCallback();
89
- }
90
- else {
91
- throw err;
92
- }
87
+ else {
88
+ throw err;
93
89
  }
94
90
  }
95
- else {
96
- console.log("[checkLastTransactionSignature] lastSignedTransaction type and signature DO NOT MATCH");
97
- setLastSignedTransaction(undefined);
98
- yield invalidCallback();
99
- }
100
- });
101
- }
102
- function onSign(type, setLastSignedTransaction, index) {
91
+ }
92
+ else {
93
+ console.log("[checkLastTransactionSignature] lastSignedTransaction type and signature DO NOT MATCH");
94
+ setLastSignedTransaction(undefined);
95
+ yield invalidCallback();
96
+ }
97
+ });
98
+ exports.checkLastTransactionSignature = checkLastTransactionSignature;
99
+ const onSign = (type, setLastSignedTransaction, index) => {
103
100
  return (signedTransaction) => {
104
101
  console.log(`[onSign] Setting setLastSignedTransaction for ${type}${index !== undefined ? ` ${index}` : ""}`);
105
102
  setLastSignedTransaction({
@@ -107,7 +104,8 @@ function onSign(type, setLastSignedTransaction, index) {
107
104
  type,
108
105
  });
109
106
  };
110
- }
107
+ };
108
+ exports.onSign = onSign;
111
109
  // CREATE KEYPAIR
112
110
  const KEYPAIR_SEED_MESSAGE = "send:wallet-connect";
113
111
  const createKeypair = (account, signPersonalMessage) => __awaiter(void 0, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@suilend/sui-fe","version":"0.3.2","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.3.3","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"}}