@0xobelisk/sui-client 1.1.7 → 1.1.8
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/dist/dubhe.d.ts +6 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiIndexerClient/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/dubhe.ts +49 -0
- package/src/libs/suiIndexerClient/index.ts +10 -0
|
@@ -70,6 +70,7 @@ export declare class SuiIndexerClient {
|
|
|
70
70
|
checkpoint?: number;
|
|
71
71
|
orderBy?: string[];
|
|
72
72
|
}): Promise<ConnectionResponse<IndexerTransaction>>;
|
|
73
|
+
getTransaction(digest: string): Promise<IndexerTransaction | undefined>;
|
|
73
74
|
getSchemas(params?: {
|
|
74
75
|
first?: number;
|
|
75
76
|
after?: string;
|
package/package.json
CHANGED
package/src/dubhe.ts
CHANGED
|
@@ -1143,6 +1143,55 @@ export class Dubhe {
|
|
|
1143
1143
|
});
|
|
1144
1144
|
}
|
|
1145
1145
|
|
|
1146
|
+
async getTransaction(
|
|
1147
|
+
digest: string
|
|
1148
|
+
): Promise<IndexerTransaction | undefined> {
|
|
1149
|
+
return await this.suiIndexerClient.getTransaction(digest);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
async awaitIndexerTransaction(
|
|
1153
|
+
digest: string,
|
|
1154
|
+
options?: {
|
|
1155
|
+
checkInterval?: number;
|
|
1156
|
+
timeout?: number;
|
|
1157
|
+
maxRetries?: number;
|
|
1158
|
+
}
|
|
1159
|
+
): Promise<IndexerTransaction | undefined> {
|
|
1160
|
+
const {
|
|
1161
|
+
checkInterval = 100,
|
|
1162
|
+
timeout = 30000, // 30 seconds default timeout
|
|
1163
|
+
maxRetries = 300, // 300 times default max retries
|
|
1164
|
+
} = options ?? {};
|
|
1165
|
+
|
|
1166
|
+
const startTime = Date.now();
|
|
1167
|
+
let retryCount = 0;
|
|
1168
|
+
|
|
1169
|
+
while (retryCount < maxRetries) {
|
|
1170
|
+
try {
|
|
1171
|
+
if (Date.now() - startTime > timeout) {
|
|
1172
|
+
throw new Error(`Timeout waiting for transaction ${digest}`);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
|
1176
|
+
|
|
1177
|
+
const transaction = await this.getTransaction(digest);
|
|
1178
|
+
if (transaction) {
|
|
1179
|
+
return transaction;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
retryCount++;
|
|
1183
|
+
} catch (error) {
|
|
1184
|
+
throw new Error(
|
|
1185
|
+
`Error while waiting for transaction ${digest}: ${error}`
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
throw new Error(
|
|
1191
|
+
`Max retries (${maxRetries}) reached while waiting for transaction ${digest}`
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1146
1195
|
async getEvents({
|
|
1147
1196
|
first,
|
|
1148
1197
|
after,
|
|
@@ -121,6 +121,16 @@ export class SuiIndexerClient {
|
|
|
121
121
|
return response.transactions;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
async getTransaction(
|
|
125
|
+
digest: string
|
|
126
|
+
): Promise<IndexerTransaction | undefined> {
|
|
127
|
+
const response = await this.getTransactions({
|
|
128
|
+
first: 1,
|
|
129
|
+
digest,
|
|
130
|
+
});
|
|
131
|
+
return response.edges[0]?.node;
|
|
132
|
+
}
|
|
133
|
+
|
|
124
134
|
async getSchemas(params?: {
|
|
125
135
|
first?: number;
|
|
126
136
|
after?: string;
|