@suilend/sui-fe 0.2.98 → 0.3.0
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 +3 -0
- package/lib/keypair.js +11 -3
- package/package.json +1 -1
package/lib/keypair.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export declare const createKeypair: (account: WalletAccount, signPersonalMessage
|
|
|
13
13
|
export declare const checkIfKeypairCanBeUsed: (lastSignedTransaction: SignatureWithBytes | undefined, currentFlowDigests: string[], keypair: Ed25519Keypair, suiClient: SuiClient) => Promise<{
|
|
14
14
|
lastCurrentFlowTransaction: SuiTransactionBlockResponse | undefined;
|
|
15
15
|
}>;
|
|
16
|
+
export declare class TransactionStatusError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
16
19
|
export declare const keypairWaitForTransaction: (digest: string, suiClient: SuiClient) => Promise<SuiTransactionBlockResponse>;
|
|
17
20
|
export declare const keypairSignExecuteAndWaitForTransaction: (transaction: Transaction, keypair: Ed25519Keypair, suiClient: SuiClient, onSign?: (signedTransaction: SignatureWithBytes) => void, onExecute?: (res: SuiTransactionBlockResponse) => void) => Promise<SuiTransactionBlockResponse>;
|
|
18
21
|
export type FundKeypairResult = {
|
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.keypairWaitForTransaction = exports.checkIfKeypairCanBeUsed = exports.createKeypair = void 0;
|
|
15
|
+
exports.returnAllOwnedObjectsAndSuiToUser = exports.fundKeypair = exports.keypairSignExecuteAndWaitForTransaction = exports.keypairWaitForTransaction = exports.TransactionStatusError = 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");
|
|
@@ -81,6 +81,13 @@ const checkIfKeypairCanBeUsed = (lastSignedTransaction, currentFlowDigests, keyp
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
exports.checkIfKeypairCanBeUsed = checkIfKeypairCanBeUsed;
|
|
84
|
+
class TransactionStatusError extends Error {
|
|
85
|
+
constructor(message) {
|
|
86
|
+
super(message);
|
|
87
|
+
this.name = "TxStatusError";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.TransactionStatusError = TransactionStatusError;
|
|
84
91
|
const keypairWaitForTransaction = (digest, suiClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
92
|
var _a, _b;
|
|
86
93
|
const res = yield suiClient.waitForTransaction({
|
|
@@ -94,7 +101,7 @@ const keypairWaitForTransaction = (digest, suiClient) => __awaiter(void 0, void
|
|
|
94
101
|
});
|
|
95
102
|
if (((_a = res.effects) === null || _a === void 0 ? void 0 : _a.status) !== undefined &&
|
|
96
103
|
res.effects.status.status === "failure")
|
|
97
|
-
throw new
|
|
104
|
+
throw new TransactionStatusError((_b = res.effects.status.error) !== null && _b !== void 0 ? _b : "Transaction failed");
|
|
98
105
|
return res;
|
|
99
106
|
});
|
|
100
107
|
exports.keypairWaitForTransaction = keypairWaitForTransaction;
|
|
@@ -140,11 +147,12 @@ const returnAllOwnedObjectsAndSuiToUser = (address, keypair, suiClient, onSign,
|
|
|
140
147
|
console.log(`[returnAllOwnedObjectsAndSuiToUser] address: ${address}`);
|
|
141
148
|
const transaction = new transactions_1.Transaction();
|
|
142
149
|
transaction.setSender(keypair.toSuiAddress());
|
|
143
|
-
transaction.transferObjects([transaction.gas], address);
|
|
150
|
+
transaction.transferObjects([transaction.gas], address); // Will throw if there is no gas
|
|
144
151
|
const ownedObjectIds = (yield (0, transactions_2.getAllOwnedObjects)(suiClient, keypair.toSuiAddress()))
|
|
145
152
|
.filter((obj) => { var _a; return ((_a = obj.data) === null || _a === void 0 ? void 0 : _a.content).type !== "0x2::coin::Coin<0x2::sui::SUI>"; })
|
|
146
153
|
.map((obj) => { var _a; return (_a = obj.data) === null || _a === void 0 ? void 0 : _a.objectId; }); // Assumed to be <512 objects
|
|
147
154
|
transaction.transferObjects(ownedObjectIds, address);
|
|
155
|
+
transaction.setGasBudget(0.000741 * 10 ** 9);
|
|
148
156
|
const res = yield (0, exports.keypairSignExecuteAndWaitForTransaction)(transaction, keypair, suiClient, onSign, onExecute);
|
|
149
157
|
return { res };
|
|
150
158
|
});
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sui-fe","version":"0.
|
|
1
|
+
{"name":"@suilend/sui-fe","version":"0.3.0","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"}}
|