@suilend/sui-fe 0.2.80 → 0.2.82
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/coin.d.ts +1 -0
- package/lib/coin.js +111 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/keypair.d.ts +27 -0
- package/lib/keypair.js +136 -0
- package/lib/transactions.d.ts +4 -1
- package/lib/transactions.js +67 -1
- package/package.json +1 -1
package/lib/coin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BLACKLISTED_WORDS: string[];
|
package/lib/coin.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BLACKLISTED_WORDS = void 0;
|
|
4
|
+
exports.BLACKLISTED_WORDS = [
|
|
5
|
+
// Sui
|
|
6
|
+
"sui",
|
|
7
|
+
"suilend",
|
|
8
|
+
"springsui",
|
|
9
|
+
"steamm",
|
|
10
|
+
"root",
|
|
11
|
+
"rootlet",
|
|
12
|
+
"rootlets",
|
|
13
|
+
"send",
|
|
14
|
+
// Test
|
|
15
|
+
"test",
|
|
16
|
+
"temp",
|
|
17
|
+
"dummy",
|
|
18
|
+
// Brands
|
|
19
|
+
"bnb",
|
|
20
|
+
"bn",
|
|
21
|
+
"okx",
|
|
22
|
+
"coin",
|
|
23
|
+
"coinbase",
|
|
24
|
+
"p",
|
|
25
|
+
"bp",
|
|
26
|
+
"cb",
|
|
27
|
+
"bb",
|
|
28
|
+
// Inappropriate
|
|
29
|
+
"anal",
|
|
30
|
+
"anus",
|
|
31
|
+
"ass",
|
|
32
|
+
"asshole",
|
|
33
|
+
"bitch",
|
|
34
|
+
"bitching",
|
|
35
|
+
"boob",
|
|
36
|
+
"boobs",
|
|
37
|
+
"butt",
|
|
38
|
+
"butthole",
|
|
39
|
+
"butts",
|
|
40
|
+
"cheat",
|
|
41
|
+
"cheater",
|
|
42
|
+
"cock",
|
|
43
|
+
"cockhead",
|
|
44
|
+
"cocaine",
|
|
45
|
+
"crack",
|
|
46
|
+
"cracker",
|
|
47
|
+
"cunt",
|
|
48
|
+
"cunty",
|
|
49
|
+
"cum",
|
|
50
|
+
"cumshot",
|
|
51
|
+
"death",
|
|
52
|
+
"dead",
|
|
53
|
+
"die",
|
|
54
|
+
"dick",
|
|
55
|
+
"dickhead",
|
|
56
|
+
"drug",
|
|
57
|
+
"drugs",
|
|
58
|
+
"fake",
|
|
59
|
+
"fraud",
|
|
60
|
+
"fuck",
|
|
61
|
+
"fucker",
|
|
62
|
+
"fucking",
|
|
63
|
+
"hack",
|
|
64
|
+
"hacker",
|
|
65
|
+
"hate",
|
|
66
|
+
"heroin",
|
|
67
|
+
"hitler",
|
|
68
|
+
"hax",
|
|
69
|
+
"haxor",
|
|
70
|
+
"jizz",
|
|
71
|
+
"kill",
|
|
72
|
+
"meth",
|
|
73
|
+
"naked",
|
|
74
|
+
"nazi",
|
|
75
|
+
"nude",
|
|
76
|
+
"nudes",
|
|
77
|
+
"pedo",
|
|
78
|
+
"pedophile",
|
|
79
|
+
"penis",
|
|
80
|
+
"pirate",
|
|
81
|
+
"piracy",
|
|
82
|
+
"porn",
|
|
83
|
+
"porno",
|
|
84
|
+
"pussy",
|
|
85
|
+
"pussycat",
|
|
86
|
+
"racism",
|
|
87
|
+
"racist",
|
|
88
|
+
"scam",
|
|
89
|
+
"scammer",
|
|
90
|
+
"sex",
|
|
91
|
+
"sexism",
|
|
92
|
+
"sexist",
|
|
93
|
+
"shit",
|
|
94
|
+
"shitter",
|
|
95
|
+
"shitting",
|
|
96
|
+
"slut",
|
|
97
|
+
"slutty",
|
|
98
|
+
"sperm",
|
|
99
|
+
"steal",
|
|
100
|
+
"terror",
|
|
101
|
+
"terrorist",
|
|
102
|
+
"thief",
|
|
103
|
+
"thieves",
|
|
104
|
+
"tit",
|
|
105
|
+
"tits",
|
|
106
|
+
"vagina",
|
|
107
|
+
"weed",
|
|
108
|
+
"whore",
|
|
109
|
+
"whoring",
|
|
110
|
+
"xxx",
|
|
111
|
+
];
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from "./api";
|
|
2
|
+
export * from "./coin";
|
|
2
3
|
export * from "./coinMetadata";
|
|
3
4
|
export * from "./coinType";
|
|
4
5
|
export * from "./constants";
|
|
5
6
|
export * from "./format";
|
|
6
7
|
export * from "./indexedDB";
|
|
8
|
+
export * from "./keypair";
|
|
7
9
|
export * from "./msafe";
|
|
8
10
|
export * from "./track";
|
|
9
11
|
export * from "./transactions";
|
package/lib/index.js
CHANGED
|
@@ -15,11 +15,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./coin"), exports);
|
|
18
19
|
__exportStar(require("./coinMetadata"), exports);
|
|
19
20
|
__exportStar(require("./coinType"), exports);
|
|
20
21
|
__exportStar(require("./constants"), exports);
|
|
21
22
|
__exportStar(require("./format"), exports);
|
|
22
23
|
__exportStar(require("./indexedDB"), exports);
|
|
24
|
+
__exportStar(require("./keypair"), exports);
|
|
23
25
|
__exportStar(require("./msafe"), exports);
|
|
24
26
|
__exportStar(require("./track"), exports);
|
|
25
27
|
__exportStar(require("./transactions"), exports);
|
package/lib/keypair.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SuiClient, SuiTransactionBlockResponse } from "@mysten/sui/client";
|
|
2
|
+
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
3
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
4
|
+
import { SuiSignPersonalMessageMethod, WalletAccount } from "@mysten/wallet-standard";
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
6
|
+
import { Token } from "./coinMetadata";
|
|
7
|
+
export declare const createKeypair: (account: WalletAccount, signPersonalMessage: SuiSignPersonalMessageMethod) => Promise<{
|
|
8
|
+
keypair: Ed25519Keypair;
|
|
9
|
+
address: string;
|
|
10
|
+
privateKey: string;
|
|
11
|
+
}>;
|
|
12
|
+
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 type FundKeypairResult = {
|
|
15
|
+
res: SuiTransactionBlockResponse;
|
|
16
|
+
};
|
|
17
|
+
export declare const fundKeypair: (tokens: (Token & {
|
|
18
|
+
amount: BigNumber;
|
|
19
|
+
})[], keypair: Ed25519Keypair, signExecuteAndWaitForTransaction: (transaction: Transaction, options?: {
|
|
20
|
+
auction?: boolean;
|
|
21
|
+
}) => Promise<SuiTransactionBlockResponse>) => Promise<{
|
|
22
|
+
res: SuiTransactionBlockResponse;
|
|
23
|
+
}>;
|
|
24
|
+
export type ReturnAllOwnedObjectsAndSuiToUserResult = {
|
|
25
|
+
res: SuiTransactionBlockResponse;
|
|
26
|
+
};
|
|
27
|
+
export declare const returnAllOwnedObjectsAndSuiToUser: (address: string, keypair: Ed25519Keypair, suiClient: SuiClient) => Promise<ReturnAllOwnedObjectsAndSuiToUserResult>;
|
package/lib/keypair.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.returnAllOwnedObjectsAndSuiToUser = exports.fundKeypair = exports.keypairSignExecuteAndWaitForTransaction = exports.checkIfKeypairCanBeUsed = exports.createKeypair = void 0;
|
|
16
|
+
const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
|
|
17
|
+
const transactions_1 = require("@mysten/sui/transactions");
|
|
18
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
19
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
20
|
+
const coinType_1 = require("./coinType");
|
|
21
|
+
const transactions_2 = require("./transactions");
|
|
22
|
+
const KEYPAIR_SEED_MESSAGE = "send:wallet-connect";
|
|
23
|
+
const createKeypair = (account, signPersonalMessage) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const message = Buffer.from(KEYPAIR_SEED_MESSAGE);
|
|
25
|
+
const { signature } = yield signPersonalMessage({
|
|
26
|
+
message,
|
|
27
|
+
account,
|
|
28
|
+
});
|
|
29
|
+
const signatureBytes = (0, utils_1.fromBase64)(signature);
|
|
30
|
+
const signatureHex = (0, utils_1.toHex)(signatureBytes);
|
|
31
|
+
const keypair = ed25519_1.Ed25519Keypair.deriveKeypairFromSeed(signatureHex);
|
|
32
|
+
const address = keypair.toSuiAddress();
|
|
33
|
+
const privateKey = keypair.getSecretKey();
|
|
34
|
+
console.log("[createKeypair] keypair:", keypair, "address:", address);
|
|
35
|
+
return { keypair, address, privateKey };
|
|
36
|
+
});
|
|
37
|
+
exports.createKeypair = createKeypair;
|
|
38
|
+
const checkIfKeypairCanBeUsed = (currentFlowDigests, keypair, suiClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const ownedObjectIds = (yield (0, transactions_2.getAllOwnedObjects)(suiClient, keypair.toSuiAddress())).map((obj) => { var _a; return (_a = obj.data) === null || _a === void 0 ? void 0 : _a.objectId; });
|
|
40
|
+
console.log("[checkIfKeypairCanBeUsed] ownedObjectIds:", ownedObjectIds);
|
|
41
|
+
if (ownedObjectIds.length === 0) {
|
|
42
|
+
// Empty wallet
|
|
43
|
+
// CONTINUE
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const mostRecentFromAddressTransaction = yield (0, transactions_2.getMostRecentFromAddressTransaction)(suiClient, keypair.toSuiAddress());
|
|
47
|
+
console.log("[checkIfKeypairCanBeUsed] mostRecentFromAddressTransaction:", mostRecentFromAddressTransaction, "currentFlowDigests:", currentFlowDigests);
|
|
48
|
+
if (mostRecentFromAddressTransaction === undefined) {
|
|
49
|
+
// Non-empty wallet with no FROM transactions
|
|
50
|
+
// CONTINUE
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// Non-empty wallet with FROM transactions
|
|
54
|
+
if (currentFlowDigests.includes(mostRecentFromAddressTransaction.digest)) {
|
|
55
|
+
// Retrying current flow
|
|
56
|
+
// CONTINUE
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Previous flow
|
|
60
|
+
const timestampMs = mostRecentFromAddressTransaction.timestampMs;
|
|
61
|
+
const isRecent = !!timestampMs && +timestampMs > Date.now() - 1000 * 60 * 2; // Less than 2 minutes ago
|
|
62
|
+
console.log("[checkIfKeypairCanBeUsed] isRecent:", isRecent, timestampMs, Date.now() - 1000 * 60 * 2);
|
|
63
|
+
if (isRecent) {
|
|
64
|
+
// Previous flow may be ongoing
|
|
65
|
+
// STOP
|
|
66
|
+
throw new Error("Please wait for previous flow to complete");
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Previous flow stopped before completion
|
|
70
|
+
// CONTINUE
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
exports.checkIfKeypairCanBeUsed = checkIfKeypairCanBeUsed;
|
|
77
|
+
const keypairSignExecuteAndWaitForTransaction = (transaction, keypair, suiClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
// 1) Sign
|
|
80
|
+
const builtTransaction = yield transaction.build({
|
|
81
|
+
client: suiClient,
|
|
82
|
+
});
|
|
83
|
+
const signedTransaction = yield keypair.signTransaction(builtTransaction);
|
|
84
|
+
// 2) Execute
|
|
85
|
+
const res1 = yield suiClient.executeTransactionBlock({
|
|
86
|
+
transactionBlock: signedTransaction.bytes,
|
|
87
|
+
signature: signedTransaction.signature,
|
|
88
|
+
});
|
|
89
|
+
// 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");
|
|
102
|
+
return res2;
|
|
103
|
+
});
|
|
104
|
+
exports.keypairSignExecuteAndWaitForTransaction = keypairSignExecuteAndWaitForTransaction;
|
|
105
|
+
const fundKeypair = (tokens, keypair, signExecuteAndWaitForTransaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
console.log("[fundKeypair] tokens:", tokens.map((t) => ({
|
|
107
|
+
coinType: t.coinType,
|
|
108
|
+
amount: t.amount.toString(),
|
|
109
|
+
})));
|
|
110
|
+
const fundKeypairTransaction = new transactions_1.Transaction();
|
|
111
|
+
const coinsWithBalance = tokens.map((token) => (0, transactions_1.coinWithBalance)({
|
|
112
|
+
balance: BigInt(token
|
|
113
|
+
.amount.times(10 ** token.decimals)
|
|
114
|
+
.integerValue(bignumber_js_1.default.ROUND_DOWN)
|
|
115
|
+
.toString()),
|
|
116
|
+
type: token.coinType,
|
|
117
|
+
useGasCoin: (0, coinType_1.isSui)(token.coinType),
|
|
118
|
+
})(fundKeypairTransaction));
|
|
119
|
+
fundKeypairTransaction.transferObjects(coinsWithBalance, keypair.toSuiAddress());
|
|
120
|
+
const res = yield signExecuteAndWaitForTransaction(fundKeypairTransaction);
|
|
121
|
+
return { res };
|
|
122
|
+
});
|
|
123
|
+
exports.fundKeypair = fundKeypair;
|
|
124
|
+
const returnAllOwnedObjectsAndSuiToUser = (address, keypair, suiClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
+
console.log(`[returnAllOwnedObjectsAndSuiToUser] address: ${address}`);
|
|
126
|
+
const transaction = new transactions_1.Transaction();
|
|
127
|
+
transaction.setSender(keypair.toSuiAddress());
|
|
128
|
+
transaction.transferObjects([transaction.gas], address);
|
|
129
|
+
const ownedObjectIds = (yield (0, transactions_2.getAllOwnedObjects)(suiClient, keypair.toSuiAddress()))
|
|
130
|
+
.filter((obj) => { var _a; return ((_a = obj.data) === null || _a === void 0 ? void 0 : _a.content).type !== "0x2::coin::Coin<0x2::sui::SUI>"; })
|
|
131
|
+
.map((obj) => { var _a; return (_a = obj.data) === null || _a === void 0 ? void 0 : _a.objectId; }); // Assumed to be <512 objects
|
|
132
|
+
transaction.transferObjects(ownedObjectIds, address);
|
|
133
|
+
const res = yield (0, exports.keypairSignExecuteAndWaitForTransaction)(transaction, keypair, suiClient);
|
|
134
|
+
return { res };
|
|
135
|
+
});
|
|
136
|
+
exports.returnAllOwnedObjectsAndSuiToUser = returnAllOwnedObjectsAndSuiToUser;
|
package/lib/transactions.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { SuiTransactionBlockResponse } from "@mysten/sui/client";
|
|
1
|
+
import { SuiClient, SuiObjectDataFilter, SuiObjectResponse, SuiTransactionBlockResponse } from "@mysten/sui/client";
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
3
|
import { Token } from "./coinMetadata";
|
|
4
4
|
export declare const getTotalGasFee: (res: SuiTransactionBlockResponse) => BigNumber;
|
|
5
5
|
export declare const getBalanceChange: (res: SuiTransactionBlockResponse, address: string, token: Token, multiplier?: -1 | 1) => BigNumber | undefined;
|
|
6
|
+
export declare const getAllOwnedObjects: (suiClient: SuiClient, address: string, filter?: SuiObjectDataFilter) => Promise<SuiObjectResponse[]>;
|
|
7
|
+
export declare const getAllCoins: (suiClient: SuiClient, address: string, coinType: string) => Promise<import("@mysten/sui/client").CoinStruct[]>;
|
|
8
|
+
export declare const getMostRecentFromAddressTransaction: (suiClient: SuiClient, address: string) => Promise<SuiTransactionBlockResponse | undefined>;
|
package/lib/transactions.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getBalanceChange = exports.getTotalGasFee = void 0;
|
|
15
|
+
exports.getMostRecentFromAddressTransaction = exports.getAllCoins = exports.getAllOwnedObjects = exports.getBalanceChange = exports.getTotalGasFee = void 0;
|
|
7
16
|
const utils_1 = require("@mysten/sui/utils");
|
|
8
17
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
18
|
const coinType_1 = require("./coinType");
|
|
@@ -30,3 +39,60 @@ const getBalanceChange = (res, address, token, multiplier = 1) => {
|
|
|
30
39
|
.times(multiplier);
|
|
31
40
|
};
|
|
32
41
|
exports.getBalanceChange = getBalanceChange;
|
|
42
|
+
const getAllOwnedObjects = (suiClient, address, filter) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
const allObjs = [];
|
|
44
|
+
let cursor = null;
|
|
45
|
+
let hasNextPage = true;
|
|
46
|
+
while (hasNextPage) {
|
|
47
|
+
const objs = yield suiClient.getOwnedObjects({
|
|
48
|
+
owner: address,
|
|
49
|
+
cursor,
|
|
50
|
+
filter,
|
|
51
|
+
options: { showContent: true },
|
|
52
|
+
});
|
|
53
|
+
allObjs.push(...objs.data);
|
|
54
|
+
cursor = objs.nextCursor;
|
|
55
|
+
hasNextPage = objs.hasNextPage;
|
|
56
|
+
}
|
|
57
|
+
return allObjs;
|
|
58
|
+
});
|
|
59
|
+
exports.getAllOwnedObjects = getAllOwnedObjects;
|
|
60
|
+
const getAllCoins = (suiClient, address, coinType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
var _a;
|
|
62
|
+
const allCoins = [];
|
|
63
|
+
let cursor = undefined;
|
|
64
|
+
let hasNextPage = true;
|
|
65
|
+
while (hasNextPage) {
|
|
66
|
+
const coins = yield suiClient.getCoins({
|
|
67
|
+
owner: address,
|
|
68
|
+
coinType,
|
|
69
|
+
cursor,
|
|
70
|
+
});
|
|
71
|
+
allCoins.push(...coins.data);
|
|
72
|
+
cursor = (_a = coins.nextCursor) !== null && _a !== void 0 ? _a : undefined;
|
|
73
|
+
hasNextPage = coins.hasNextPage;
|
|
74
|
+
}
|
|
75
|
+
return allCoins;
|
|
76
|
+
});
|
|
77
|
+
exports.getAllCoins = getAllCoins;
|
|
78
|
+
const getMostRecentFromAddressTransaction = (suiClient, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
const allTransactions = [];
|
|
80
|
+
let cursor = null;
|
|
81
|
+
let hasNextPage = true;
|
|
82
|
+
while (hasNextPage) {
|
|
83
|
+
const transactions = yield suiClient.queryTransactionBlocks({
|
|
84
|
+
filter: { FromAddress: address },
|
|
85
|
+
cursor,
|
|
86
|
+
limit: 1,
|
|
87
|
+
order: "descending",
|
|
88
|
+
options: {
|
|
89
|
+
showEvents: true,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
allTransactions.push(...transactions.data);
|
|
93
|
+
cursor = transactions.nextCursor;
|
|
94
|
+
hasNextPage = transactions.hasNextPage;
|
|
95
|
+
}
|
|
96
|
+
return allTransactions[0];
|
|
97
|
+
});
|
|
98
|
+
exports.getMostRecentFromAddressTransaction = getMostRecentFromAddressTransaction;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sui-fe","version":"0.2.
|
|
1
|
+
{"name":"@suilend/sui-fe","version":"0.2.82","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"}}
|