@owney/sdk 0.7.16-beta.3 → 0.7.16-beta.4
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/index.cjs +31 -14
- package/dist/index.js +31 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2956,6 +2956,18 @@ function mapYieldseekerAgentApy(options, days) {
|
|
|
2956
2956
|
|
|
2957
2957
|
// src/agents/yieldseeker/yieldseeker.agent.ts
|
|
2958
2958
|
var OWNEY_AGENT_NAME = "owney";
|
|
2959
|
+
var YIELDSEEKER_USERNAME_PREFIX = "owney_";
|
|
2960
|
+
var YIELDSEEKER_USERNAME_RANDOM_LENGTH = 14;
|
|
2961
|
+
var YIELDSEEKER_USERNAME_CREATE_ATTEMPTS = 3;
|
|
2962
|
+
function generateYieldseekerUsername() {
|
|
2963
|
+
const suffix = globalThis.crypto.randomUUID().replaceAll("-", "").slice(0, YIELDSEEKER_USERNAME_RANDOM_LENGTH).toLowerCase();
|
|
2964
|
+
return `${YIELDSEEKER_USERNAME_PREFIX}${suffix}`;
|
|
2965
|
+
}
|
|
2966
|
+
function isUsernameConflict(error) {
|
|
2967
|
+
if (!(error instanceof YieldseekerApiError)) return false;
|
|
2968
|
+
const code = error.providerCode.toUpperCase();
|
|
2969
|
+
return code.includes("USERNAME") && (code.includes("TAKEN") || code.includes("EXIST") || code.includes("UNAVAILABLE") || code.includes("IN_USE"));
|
|
2970
|
+
}
|
|
2959
2971
|
var YIELDSEEKER_AGENT_WALLET_ABI = [
|
|
2960
2972
|
{
|
|
2961
2973
|
type: "function",
|
|
@@ -3295,21 +3307,26 @@ var YieldseekerAgent = class {
|
|
|
3295
3307
|
throw this.mapApiError(error);
|
|
3296
3308
|
}
|
|
3297
3309
|
let created;
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3310
|
+
for (let attempt = 0; attempt < YIELDSEEKER_USERNAME_CREATE_ATTEMPTS; attempt += 1) {
|
|
3311
|
+
try {
|
|
3312
|
+
created = await this.providerRequest(
|
|
3313
|
+
state,
|
|
3314
|
+
chainId,
|
|
3315
|
+
"/users",
|
|
3316
|
+
{
|
|
3317
|
+
method: "POST",
|
|
3318
|
+
body: {
|
|
3319
|
+
walletAddress,
|
|
3320
|
+
username: generateYieldseekerUsername()
|
|
3321
|
+
}
|
|
3308
3322
|
}
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3323
|
+
);
|
|
3324
|
+
break;
|
|
3325
|
+
} catch (createError) {
|
|
3326
|
+
const canRetry = isUsernameConflict(createError) && attempt + 1 < YIELDSEEKER_USERNAME_CREATE_ATTEMPTS;
|
|
3327
|
+
if (canRetry) continue;
|
|
3328
|
+
throw this.mapApiError(createError);
|
|
3329
|
+
}
|
|
3313
3330
|
}
|
|
3314
3331
|
user = created?.user ?? null;
|
|
3315
3332
|
}
|
package/dist/index.js
CHANGED
|
@@ -2935,6 +2935,18 @@ function mapYieldseekerAgentApy(options, days) {
|
|
|
2935
2935
|
|
|
2936
2936
|
// src/agents/yieldseeker/yieldseeker.agent.ts
|
|
2937
2937
|
var OWNEY_AGENT_NAME = "owney";
|
|
2938
|
+
var YIELDSEEKER_USERNAME_PREFIX = "owney_";
|
|
2939
|
+
var YIELDSEEKER_USERNAME_RANDOM_LENGTH = 14;
|
|
2940
|
+
var YIELDSEEKER_USERNAME_CREATE_ATTEMPTS = 3;
|
|
2941
|
+
function generateYieldseekerUsername() {
|
|
2942
|
+
const suffix = globalThis.crypto.randomUUID().replaceAll("-", "").slice(0, YIELDSEEKER_USERNAME_RANDOM_LENGTH).toLowerCase();
|
|
2943
|
+
return `${YIELDSEEKER_USERNAME_PREFIX}${suffix}`;
|
|
2944
|
+
}
|
|
2945
|
+
function isUsernameConflict(error) {
|
|
2946
|
+
if (!(error instanceof YieldseekerApiError)) return false;
|
|
2947
|
+
const code = error.providerCode.toUpperCase();
|
|
2948
|
+
return code.includes("USERNAME") && (code.includes("TAKEN") || code.includes("EXIST") || code.includes("UNAVAILABLE") || code.includes("IN_USE"));
|
|
2949
|
+
}
|
|
2938
2950
|
var YIELDSEEKER_AGENT_WALLET_ABI = [
|
|
2939
2951
|
{
|
|
2940
2952
|
type: "function",
|
|
@@ -3274,21 +3286,26 @@ var YieldseekerAgent = class {
|
|
|
3274
3286
|
throw this.mapApiError(error);
|
|
3275
3287
|
}
|
|
3276
3288
|
let created;
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3289
|
+
for (let attempt = 0; attempt < YIELDSEEKER_USERNAME_CREATE_ATTEMPTS; attempt += 1) {
|
|
3290
|
+
try {
|
|
3291
|
+
created = await this.providerRequest(
|
|
3292
|
+
state,
|
|
3293
|
+
chainId,
|
|
3294
|
+
"/users",
|
|
3295
|
+
{
|
|
3296
|
+
method: "POST",
|
|
3297
|
+
body: {
|
|
3298
|
+
walletAddress,
|
|
3299
|
+
username: generateYieldseekerUsername()
|
|
3300
|
+
}
|
|
3287
3301
|
}
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3302
|
+
);
|
|
3303
|
+
break;
|
|
3304
|
+
} catch (createError) {
|
|
3305
|
+
const canRetry = isUsernameConflict(createError) && attempt + 1 < YIELDSEEKER_USERNAME_CREATE_ATTEMPTS;
|
|
3306
|
+
if (canRetry) continue;
|
|
3307
|
+
throw this.mapApiError(createError);
|
|
3308
|
+
}
|
|
3292
3309
|
}
|
|
3293
3310
|
user = created?.user ?? null;
|
|
3294
3311
|
}
|