@oumla/sdk 0.0.2 → 0.0.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/README.md +2 -2
- package/dist/index.d.ts +95 -314
- package/dist/index.js +250 -378
- package/dist/index.mjs +250 -378
- package/package.json +4 -6
package/dist/index.js
CHANGED
|
@@ -86,12 +86,10 @@ var Base = class {
|
|
|
86
86
|
this.baseUrl = configs.baseUrl || "https://sandbox.oumla.com";
|
|
87
87
|
this.env = configs.env || "testnet";
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
89
|
+
// Add this method to get custom headers
|
|
90
|
+
getCustomHeaders() {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
95
93
|
httpRequest(args) {
|
|
96
94
|
return __async(this, null, function* () {
|
|
97
95
|
var _a;
|
|
@@ -100,13 +98,13 @@ var Base = class {
|
|
|
100
98
|
}
|
|
101
99
|
const paginationOpts = args.pagination ? `?skip=${args.pagination.skip || 0}&take=${args.pagination.take || 10}` : "";
|
|
102
100
|
const URL2 = `${this.baseUrl}${args.path}${paginationOpts}`;
|
|
101
|
+
const headers = __spreadValues(__spreadValues({
|
|
102
|
+
"x-api-key": `Bearer ${this.apiKey}`,
|
|
103
|
+
"Content-Type": "application/json"
|
|
104
|
+
}, this.getCustomHeaders()), args.headers);
|
|
103
105
|
const config = {
|
|
104
|
-
headers
|
|
105
|
-
|
|
106
|
-
"Content-Type": "application/json"
|
|
107
|
-
},
|
|
108
|
-
method: args.method || void 0,
|
|
109
|
-
// GET is the default in fetch
|
|
106
|
+
headers,
|
|
107
|
+
method: args.method || "GET",
|
|
110
108
|
body: args.body ? JSON.stringify(args.body) : void 0
|
|
111
109
|
};
|
|
112
110
|
const res = yield fetch(URL2, config);
|
|
@@ -131,7 +129,7 @@ var Base = class {
|
|
|
131
129
|
}
|
|
132
130
|
};
|
|
133
131
|
|
|
134
|
-
// node_modules/.pnpm/zod@3.
|
|
132
|
+
// node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
135
133
|
var util;
|
|
136
134
|
(function(util2) {
|
|
137
135
|
util2.assertEqual = (val) => val;
|
|
@@ -553,7 +551,7 @@ var ParseStatus = class {
|
|
|
553
551
|
status.dirty();
|
|
554
552
|
if (value.status === "dirty")
|
|
555
553
|
status.dirty();
|
|
556
|
-
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
|
554
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
557
555
|
finalObject[key.value] = value.value;
|
|
558
556
|
}
|
|
559
557
|
}
|
|
@@ -656,6 +654,7 @@ var ZodType = class {
|
|
|
656
654
|
this.catch = this.catch.bind(this);
|
|
657
655
|
this.describe = this.describe.bind(this);
|
|
658
656
|
this.pipe = this.pipe.bind(this);
|
|
657
|
+
this.readonly = this.readonly.bind(this);
|
|
659
658
|
this.isNullable = this.isNullable.bind(this);
|
|
660
659
|
this.isOptional = this.isOptional.bind(this);
|
|
661
660
|
}
|
|
@@ -861,6 +860,9 @@ var ZodType = class {
|
|
|
861
860
|
pipe(target) {
|
|
862
861
|
return ZodPipeline.create(this, target);
|
|
863
862
|
}
|
|
863
|
+
readonly() {
|
|
864
|
+
return ZodReadonly.create(this);
|
|
865
|
+
}
|
|
864
866
|
isOptional() {
|
|
865
867
|
return this.safeParse(void 0).success;
|
|
866
868
|
}
|
|
@@ -870,10 +872,11 @@ var ZodType = class {
|
|
|
870
872
|
};
|
|
871
873
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
872
874
|
var cuid2Regex = /^[a-z][a-z0-9]*$/;
|
|
873
|
-
var ulidRegex =
|
|
874
|
-
var uuidRegex = /^
|
|
875
|
-
var emailRegex = /^(
|
|
876
|
-
var
|
|
875
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
876
|
+
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
877
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
878
|
+
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
879
|
+
var emojiRegex;
|
|
877
880
|
var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
|
|
878
881
|
var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
|
879
882
|
var datetimeRegex = (args) => {
|
|
@@ -907,23 +910,6 @@ function isValidIP(ip, version) {
|
|
|
907
910
|
return false;
|
|
908
911
|
}
|
|
909
912
|
var ZodString = class extends ZodType {
|
|
910
|
-
constructor() {
|
|
911
|
-
super(...arguments);
|
|
912
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), __spreadValues({
|
|
913
|
-
validation,
|
|
914
|
-
code: ZodIssueCode.invalid_string
|
|
915
|
-
}, errorUtil.errToObj(message)));
|
|
916
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
|
917
|
-
this.trim = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
918
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
919
|
-
}));
|
|
920
|
-
this.toLowerCase = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
921
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
922
|
-
}));
|
|
923
|
-
this.toUpperCase = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
924
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
925
|
-
}));
|
|
926
|
-
}
|
|
927
913
|
_parse(input) {
|
|
928
914
|
if (this._def.coerce) {
|
|
929
915
|
input.data = String(input.data);
|
|
@@ -1008,6 +994,9 @@ var ZodString = class extends ZodType {
|
|
|
1008
994
|
status.dirty();
|
|
1009
995
|
}
|
|
1010
996
|
} else if (check.kind === "emoji") {
|
|
997
|
+
if (!emojiRegex) {
|
|
998
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
999
|
+
}
|
|
1011
1000
|
if (!emojiRegex.test(input.data)) {
|
|
1012
1001
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1013
1002
|
addIssueToContext(ctx, {
|
|
@@ -1144,6 +1133,12 @@ var ZodString = class extends ZodType {
|
|
|
1144
1133
|
}
|
|
1145
1134
|
return { status: status.value, value: input.data };
|
|
1146
1135
|
}
|
|
1136
|
+
_regex(regex, validation, message) {
|
|
1137
|
+
return this.refinement((data) => regex.test(data), __spreadValues({
|
|
1138
|
+
validation,
|
|
1139
|
+
code: ZodIssueCode.invalid_string
|
|
1140
|
+
}, errorUtil.errToObj(message)));
|
|
1141
|
+
}
|
|
1147
1142
|
_addCheck(check) {
|
|
1148
1143
|
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1149
1144
|
checks: [...this._def.checks, check]
|
|
@@ -1232,6 +1227,28 @@ var ZodString = class extends ZodType {
|
|
|
1232
1227
|
value: len
|
|
1233
1228
|
}, errorUtil.errToObj(message)));
|
|
1234
1229
|
}
|
|
1230
|
+
/**
|
|
1231
|
+
* @deprecated Use z.string().min(1) instead.
|
|
1232
|
+
* @see {@link ZodString.min}
|
|
1233
|
+
*/
|
|
1234
|
+
nonempty(message) {
|
|
1235
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
1236
|
+
}
|
|
1237
|
+
trim() {
|
|
1238
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1239
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1240
|
+
}));
|
|
1241
|
+
}
|
|
1242
|
+
toLowerCase() {
|
|
1243
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1244
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1245
|
+
}));
|
|
1246
|
+
}
|
|
1247
|
+
toUpperCase() {
|
|
1248
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
|
1249
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1250
|
+
}));
|
|
1251
|
+
}
|
|
1235
1252
|
get isDatetime() {
|
|
1236
1253
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1237
1254
|
}
|
|
@@ -2770,6 +2787,12 @@ var ZodRecord = class extends ZodType {
|
|
|
2770
2787
|
}
|
|
2771
2788
|
};
|
|
2772
2789
|
var ZodMap = class extends ZodType {
|
|
2790
|
+
get keySchema() {
|
|
2791
|
+
return this._def.keyType;
|
|
2792
|
+
}
|
|
2793
|
+
get valueSchema() {
|
|
2794
|
+
return this._def.valueType;
|
|
2795
|
+
}
|
|
2773
2796
|
_parse(input) {
|
|
2774
2797
|
const { status, ctx } = this._processInputParams(input);
|
|
2775
2798
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
@@ -2960,27 +2983,31 @@ var ZodFunction = class extends ZodType {
|
|
|
2960
2983
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
2961
2984
|
const fn = ctx.data;
|
|
2962
2985
|
if (this._def.returns instanceof ZodPromise) {
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
error
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2986
|
+
const me = this;
|
|
2987
|
+
return OK(function(...args) {
|
|
2988
|
+
return __async(this, null, function* () {
|
|
2989
|
+
const error = new ZodError([]);
|
|
2990
|
+
const parsedArgs = yield me._def.args.parseAsync(args, params).catch((e) => {
|
|
2991
|
+
error.addIssue(makeArgsIssue(args, e));
|
|
2992
|
+
throw error;
|
|
2993
|
+
});
|
|
2994
|
+
const result = yield Reflect.apply(fn, this, parsedArgs);
|
|
2995
|
+
const parsedReturns = yield me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
2996
|
+
error.addIssue(makeReturnsIssue(result, e));
|
|
2997
|
+
throw error;
|
|
2998
|
+
});
|
|
2999
|
+
return parsedReturns;
|
|
2973
3000
|
});
|
|
2974
|
-
|
|
2975
|
-
}));
|
|
3001
|
+
});
|
|
2976
3002
|
} else {
|
|
2977
|
-
|
|
2978
|
-
|
|
3003
|
+
const me = this;
|
|
3004
|
+
return OK(function(...args) {
|
|
3005
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
2979
3006
|
if (!parsedArgs.success) {
|
|
2980
3007
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
2981
3008
|
}
|
|
2982
|
-
const result = fn
|
|
2983
|
-
const parsedReturns =
|
|
3009
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3010
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
2984
3011
|
if (!parsedReturns.success) {
|
|
2985
3012
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
2986
3013
|
}
|
|
@@ -3194,8 +3221,28 @@ var ZodEffects = class extends ZodType {
|
|
|
3194
3221
|
_parse(input) {
|
|
3195
3222
|
const { status, ctx } = this._processInputParams(input);
|
|
3196
3223
|
const effect = this._def.effect || null;
|
|
3224
|
+
const checkCtx = {
|
|
3225
|
+
addIssue: (arg) => {
|
|
3226
|
+
addIssueToContext(ctx, arg);
|
|
3227
|
+
if (arg.fatal) {
|
|
3228
|
+
status.abort();
|
|
3229
|
+
} else {
|
|
3230
|
+
status.dirty();
|
|
3231
|
+
}
|
|
3232
|
+
},
|
|
3233
|
+
get path() {
|
|
3234
|
+
return ctx.path;
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3197
3238
|
if (effect.type === "preprocess") {
|
|
3198
|
-
const processed = effect.transform(ctx.data);
|
|
3239
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
3240
|
+
if (ctx.common.issues.length) {
|
|
3241
|
+
return {
|
|
3242
|
+
status: "dirty",
|
|
3243
|
+
value: ctx.data
|
|
3244
|
+
};
|
|
3245
|
+
}
|
|
3199
3246
|
if (ctx.common.async) {
|
|
3200
3247
|
return Promise.resolve(processed).then((processed2) => {
|
|
3201
3248
|
return this._def.schema._parseAsync({
|
|
@@ -3212,20 +3259,6 @@ var ZodEffects = class extends ZodType {
|
|
|
3212
3259
|
});
|
|
3213
3260
|
}
|
|
3214
3261
|
}
|
|
3215
|
-
const checkCtx = {
|
|
3216
|
-
addIssue: (arg) => {
|
|
3217
|
-
addIssueToContext(ctx, arg);
|
|
3218
|
-
if (arg.fatal) {
|
|
3219
|
-
status.abort();
|
|
3220
|
-
} else {
|
|
3221
|
-
status.dirty();
|
|
3222
|
-
}
|
|
3223
|
-
},
|
|
3224
|
-
get path() {
|
|
3225
|
-
return ctx.path;
|
|
3226
|
-
}
|
|
3227
|
-
};
|
|
3228
|
-
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3229
3262
|
if (effect.type === "refinement") {
|
|
3230
3263
|
const executeRefinement = (acc) => {
|
|
3231
3264
|
const result = effect.refinement(acc, checkCtx);
|
|
@@ -3498,6 +3531,21 @@ var ZodPipeline = class extends ZodType {
|
|
|
3498
3531
|
});
|
|
3499
3532
|
}
|
|
3500
3533
|
};
|
|
3534
|
+
var ZodReadonly = class extends ZodType {
|
|
3535
|
+
_parse(input) {
|
|
3536
|
+
const result = this._def.innerType._parse(input);
|
|
3537
|
+
if (isValid(result)) {
|
|
3538
|
+
result.value = Object.freeze(result.value);
|
|
3539
|
+
}
|
|
3540
|
+
return result;
|
|
3541
|
+
}
|
|
3542
|
+
};
|
|
3543
|
+
ZodReadonly.create = (type, params) => {
|
|
3544
|
+
return new ZodReadonly(__spreadValues({
|
|
3545
|
+
innerType: type,
|
|
3546
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly
|
|
3547
|
+
}, processCreateParams(params)));
|
|
3548
|
+
};
|
|
3501
3549
|
var custom = (check, params = {}, fatal) => {
|
|
3502
3550
|
if (check)
|
|
3503
3551
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
@@ -3551,6 +3599,7 @@ var ZodFirstPartyTypeKind;
|
|
|
3551
3599
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
3552
3600
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
3553
3601
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
3602
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
3554
3603
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
3555
3604
|
var instanceOfType = (cls, params = {
|
|
3556
3605
|
message: `Input not instance of ${cls.name}`
|
|
@@ -3664,6 +3713,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3664
3713
|
BRAND,
|
|
3665
3714
|
ZodBranded,
|
|
3666
3715
|
ZodPipeline,
|
|
3716
|
+
ZodReadonly,
|
|
3667
3717
|
custom,
|
|
3668
3718
|
Schema: ZodType,
|
|
3669
3719
|
ZodSchema: ZodType,
|
|
@@ -3718,7 +3768,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3718
3768
|
});
|
|
3719
3769
|
|
|
3720
3770
|
// src/schemas.ts
|
|
3721
|
-
var NetworkSchema = z.enum(["BTC", "ETH"]);
|
|
3771
|
+
var NetworkSchema = z.enum(["BTC", "ETH", "tBTC", "tETH"]);
|
|
3722
3772
|
var ProfileTypeSchema = z.enum(["User", "Department", "Merchant"]);
|
|
3723
3773
|
var GetWalletsSchema = z.object({
|
|
3724
3774
|
reference: z.string()
|
|
@@ -3752,7 +3802,8 @@ var GetTransactionsSchema = z.object({
|
|
|
3752
3802
|
}).partial();
|
|
3753
3803
|
var GenerateAddressSchema = z.object({
|
|
3754
3804
|
network: NetworkSchema,
|
|
3755
|
-
reference: z.string()
|
|
3805
|
+
reference: z.string(),
|
|
3806
|
+
clientShare: z.string()
|
|
3756
3807
|
});
|
|
3757
3808
|
var GetAddressesSchema = z.object({
|
|
3758
3809
|
baseUrl: z.string(),
|
|
@@ -3784,7 +3835,8 @@ var CreateTransactionSchema = z.object({
|
|
|
3784
3835
|
to: z.string(),
|
|
3785
3836
|
amount: z.number(),
|
|
3786
3837
|
from: z.array(z.string()),
|
|
3787
|
-
network: NetworkSchema
|
|
3838
|
+
network: NetworkSchema,
|
|
3839
|
+
clientShare: z.string()
|
|
3788
3840
|
});
|
|
3789
3841
|
var GetOrganizationSchema = z.object({
|
|
3790
3842
|
baseUrl: z.string(),
|
|
@@ -3796,335 +3848,155 @@ var GetOrganizationDashboardSchema = z.object({
|
|
|
3796
3848
|
});
|
|
3797
3849
|
|
|
3798
3850
|
// src/client.ts
|
|
3799
|
-
var
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
*
|
|
3807
|
-
* @param {string} args.reference - The reference of the profile
|
|
3808
|
-
* @param {string} args.network - The network to generate a wallet for
|
|
3809
|
-
*
|
|
3810
|
-
* @example
|
|
3811
|
-
* ``` ts
|
|
3812
|
-
*
|
|
3813
|
-
* const wallet = await client.generateWallet({
|
|
3814
|
-
* reference: 'PROFILE_REFERENCE',
|
|
3815
|
-
* network: 'BTC',
|
|
3816
|
-
* });
|
|
3817
|
-
*
|
|
3818
|
-
* ```
|
|
3819
|
-
*
|
|
3820
|
-
* @returns {Types.TGenerateWalletResponse} - The generated wallet or an error
|
|
3821
|
-
*
|
|
3822
|
-
*/
|
|
3823
|
-
generateWallet(args) {
|
|
3824
|
-
return __async(this, null, function* () {
|
|
3825
|
-
return yield this.httpRequest({
|
|
3826
|
-
method: "POST",
|
|
3827
|
-
path: "/api/v1/wallets/generate",
|
|
3828
|
-
body: args,
|
|
3829
|
-
schema: GenerateWalletSchema
|
|
3830
|
-
});
|
|
3851
|
+
var _Oumla = class extends Base {
|
|
3852
|
+
// 1 hour
|
|
3853
|
+
constructor(opts) {
|
|
3854
|
+
super({
|
|
3855
|
+
apiKey: opts.apiKey,
|
|
3856
|
+
baseUrl: opts.baseUrl,
|
|
3857
|
+
env: opts.env
|
|
3831
3858
|
});
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
*
|
|
3850
|
-
* @returns {Types.TGetWalletsResponse} - The wallets for the organization
|
|
3851
|
-
*
|
|
3852
|
-
*/
|
|
3853
|
-
getWallets(args, pagination) {
|
|
3854
|
-
return __async(this, null, function* () {
|
|
3855
|
-
if (args == null ? void 0 : args.reference) {
|
|
3856
|
-
return yield this.httpRequest({
|
|
3857
|
-
path: `/api/v1/wallets/profile/${args.reference}`,
|
|
3859
|
+
// Update this with each release
|
|
3860
|
+
this.lastUpdateCheck = 0;
|
|
3861
|
+
this.UPDATE_CHECK_INTERVAL = 60 * 60 * 1e3;
|
|
3862
|
+
this.wallets = {
|
|
3863
|
+
generate: (args) => __async(this, null, function* () {
|
|
3864
|
+
return this.httpRequest({
|
|
3865
|
+
path: "/api/v1/wallets/generate",
|
|
3866
|
+
method: "POST",
|
|
3867
|
+
body: args,
|
|
3868
|
+
schema: GenerateWalletSchema
|
|
3869
|
+
});
|
|
3870
|
+
}),
|
|
3871
|
+
get: (args, pagination) => __async(this, null, function* () {
|
|
3872
|
+
const path = (args == null ? void 0 : args.reference) ? `/api/v1/wallets/profile/${args.reference}` : "/api/v1/wallets/organization";
|
|
3873
|
+
return this.httpRequest({
|
|
3874
|
+
path,
|
|
3875
|
+
method: "GET",
|
|
3858
3876
|
pagination
|
|
3859
3877
|
});
|
|
3860
|
-
}
|
|
3861
|
-
|
|
3862
|
-
|
|
3878
|
+
})
|
|
3879
|
+
};
|
|
3880
|
+
this.addresses = {
|
|
3881
|
+
generate: (args) => __async(this, null, function* () {
|
|
3882
|
+
return this.httpRequest({
|
|
3883
|
+
path: "/api/v1/address/generate",
|
|
3884
|
+
method: "POST",
|
|
3885
|
+
body: args,
|
|
3886
|
+
schema: GenerateAddressSchema
|
|
3887
|
+
});
|
|
3888
|
+
}),
|
|
3889
|
+
get: (args, pagination) => __async(this, null, function* () {
|
|
3890
|
+
const path = (args == null ? void 0 : args.reference) ? `/api/v1/addresses/${args.reference}` : "/api/v1/addresses/organization";
|
|
3891
|
+
return this.httpRequest({
|
|
3892
|
+
path,
|
|
3893
|
+
method: "GET",
|
|
3863
3894
|
pagination
|
|
3864
3895
|
});
|
|
3865
|
-
}
|
|
3866
|
-
}
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
* network: 'BTC',
|
|
3881
|
-
* });
|
|
3882
|
-
*
|
|
3883
|
-
* ```
|
|
3884
|
-
*
|
|
3885
|
-
* @returns {Types.TGenerateAddressResponse} - The generated address
|
|
3886
|
-
*/
|
|
3887
|
-
generateAddress(args) {
|
|
3888
|
-
return __async(this, null, function* () {
|
|
3889
|
-
return yield this.httpRequest({
|
|
3890
|
-
method: "POST",
|
|
3891
|
-
path: "/api/v1/address/generate",
|
|
3892
|
-
body: args,
|
|
3893
|
-
schema: GenerateAddressSchema
|
|
3894
|
-
});
|
|
3895
|
-
});
|
|
3896
|
-
}
|
|
3897
|
-
/**
|
|
3898
|
-
*
|
|
3899
|
-
* Get addresses
|
|
3900
|
-
*
|
|
3901
|
-
* @param {string} args.reference - The reference of the profile, Optional
|
|
3902
|
-
* @param {Types.TPagination} [pagination] - Pagination options
|
|
3903
|
-
* @example
|
|
3904
|
-
* ``` ts
|
|
3905
|
-
*
|
|
3906
|
-
* const addresses = await client.getAddresses({
|
|
3907
|
-
* reference: 'PROFILE_REFERENCE',
|
|
3908
|
-
* },
|
|
3909
|
-
* {
|
|
3910
|
-
* skip: 0,
|
|
3911
|
-
* take: 3,
|
|
3912
|
-
* }
|
|
3913
|
-
* );
|
|
3914
|
-
*
|
|
3915
|
-
* ```
|
|
3916
|
-
*
|
|
3917
|
-
* @returns {Types.TGetProfileAddressesResponse} - The addresses for the profile
|
|
3918
|
-
*/
|
|
3919
|
-
getAddresses(args, pagination) {
|
|
3920
|
-
return __async(this, null, function* () {
|
|
3921
|
-
if (args == null ? void 0 : args.reference) {
|
|
3922
|
-
return yield this.httpRequest({
|
|
3923
|
-
path: `/api/v1/addresses/${args.reference}`,
|
|
3896
|
+
})
|
|
3897
|
+
};
|
|
3898
|
+
this.profiles = {
|
|
3899
|
+
create: (args) => __async(this, null, function* () {
|
|
3900
|
+
return this.httpRequest({
|
|
3901
|
+
path: "/api/v1/profiles",
|
|
3902
|
+
method: "POST",
|
|
3903
|
+
body: args,
|
|
3904
|
+
schema: CreateProfileSchema
|
|
3905
|
+
});
|
|
3906
|
+
}),
|
|
3907
|
+
get: (pagination) => __async(this, null, function* () {
|
|
3908
|
+
return this.httpRequest({
|
|
3909
|
+
path: "/api/v1/profiles",
|
|
3910
|
+
method: "GET",
|
|
3924
3911
|
pagination
|
|
3925
3912
|
});
|
|
3926
|
-
}
|
|
3927
|
-
|
|
3928
|
-
|
|
3913
|
+
})
|
|
3914
|
+
};
|
|
3915
|
+
this.organization = {
|
|
3916
|
+
get: () => __async(this, null, function* () {
|
|
3917
|
+
return this.httpRequest({
|
|
3918
|
+
path: "/api/v1/organizations",
|
|
3919
|
+
method: "GET"
|
|
3920
|
+
});
|
|
3921
|
+
}),
|
|
3922
|
+
volume: () => __async(this, null, function* () {
|
|
3923
|
+
return this.httpRequest({
|
|
3924
|
+
path: "/api/v1/statistics/organization/volume",
|
|
3925
|
+
method: "GET"
|
|
3926
|
+
});
|
|
3927
|
+
}),
|
|
3928
|
+
insights: () => __async(this, null, function* () {
|
|
3929
|
+
return this.httpRequest({
|
|
3930
|
+
path: "/api/v1/statistics/organization/insights",
|
|
3931
|
+
method: "GET"
|
|
3932
|
+
});
|
|
3933
|
+
})
|
|
3934
|
+
};
|
|
3935
|
+
this.transactions = {
|
|
3936
|
+
create: (args) => __async(this, null, function* () {
|
|
3937
|
+
return this.httpRequest({
|
|
3938
|
+
path: "/api/v1/withdraw/address",
|
|
3939
|
+
method: "POST",
|
|
3940
|
+
body: args,
|
|
3941
|
+
schema: CreateTransactionSchema
|
|
3942
|
+
});
|
|
3943
|
+
}),
|
|
3944
|
+
get: (args, pagination) => __async(this, null, function* () {
|
|
3945
|
+
let path = "/api/v1/transactions/organization";
|
|
3946
|
+
if (args == null ? void 0 : args.address) {
|
|
3947
|
+
path = `/api/v1/transactions/address/${args.address}`;
|
|
3948
|
+
} else if (args == null ? void 0 : args.wallet) {
|
|
3949
|
+
path = `/api/v1/transactions/wallet/${args.wallet}`;
|
|
3950
|
+
} else if (args == null ? void 0 : args.reference) {
|
|
3951
|
+
path = `/api/v1/transactions/profile/${args.reference}`;
|
|
3952
|
+
}
|
|
3953
|
+
return this.httpRequest({
|
|
3954
|
+
path,
|
|
3955
|
+
method: "GET",
|
|
3929
3956
|
pagination
|
|
3930
3957
|
});
|
|
3931
|
-
}
|
|
3932
|
-
}
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
*
|
|
3938
|
-
* @example
|
|
3939
|
-
* ``` ts
|
|
3940
|
-
*
|
|
3941
|
-
* const organization = await client.getOrganization();
|
|
3942
|
-
*
|
|
3943
|
-
* ```
|
|
3944
|
-
*
|
|
3945
|
-
* @returns {Types.TGetOrganizationResponse} - The organization's information
|
|
3946
|
-
*/
|
|
3947
|
-
getOrganization() {
|
|
3948
|
-
return __async(this, null, function* () {
|
|
3949
|
-
return yield this.httpRequest({
|
|
3950
|
-
path: "/api/v1/organizations"
|
|
3951
|
-
});
|
|
3952
|
-
});
|
|
3953
|
-
}
|
|
3954
|
-
/**
|
|
3955
|
-
*
|
|
3956
|
-
* Create a profile
|
|
3957
|
-
*
|
|
3958
|
-
* @param {string} args.reference - The reference of the profile
|
|
3959
|
-
* @param {Types.TCreateProfileArgs['type']} args.type - The type of the profile
|
|
3960
|
-
*
|
|
3961
|
-
* @example
|
|
3962
|
-
* ``` ts
|
|
3963
|
-
*
|
|
3964
|
-
* const profile = await client.createProfile({
|
|
3965
|
-
* reference: 'PROFILE_REFERENCE',
|
|
3966
|
-
* type: 'User',
|
|
3967
|
-
* });
|
|
3968
|
-
*
|
|
3969
|
-
* ```
|
|
3970
|
-
*
|
|
3971
|
-
* @returns {Types.TCreateProfileResponse} - The created profile
|
|
3972
|
-
*/
|
|
3973
|
-
createProfile(args) {
|
|
3974
|
-
return __async(this, null, function* () {
|
|
3975
|
-
return yield this.httpRequest({
|
|
3976
|
-
method: "POST",
|
|
3977
|
-
path: "/api/v1/profiles",
|
|
3978
|
-
body: args,
|
|
3979
|
-
schema: CreateProfileSchema
|
|
3980
|
-
});
|
|
3981
|
-
});
|
|
3982
|
-
}
|
|
3983
|
-
/**
|
|
3984
|
-
*
|
|
3985
|
-
* Get the profiles for an organization
|
|
3986
|
-
*
|
|
3987
|
-
* @param {Types.TPagination} [pagination] - Pagination options
|
|
3988
|
-
*
|
|
3989
|
-
* @example
|
|
3990
|
-
* ``` ts
|
|
3991
|
-
*
|
|
3992
|
-
* const profiles = await client.getProfiles({
|
|
3993
|
-
* skip: 0,
|
|
3994
|
-
* take: 3,
|
|
3995
|
-
* });
|
|
3996
|
-
*
|
|
3997
|
-
* ```
|
|
3998
|
-
*
|
|
3999
|
-
* @returns {Types.TGetProfilesResponse} - The profiles for the organization
|
|
4000
|
-
*/
|
|
4001
|
-
getProfiles(pagination) {
|
|
4002
|
-
return __async(this, null, function* () {
|
|
4003
|
-
return yield this.httpRequest({
|
|
4004
|
-
path: "/api/v1/profiles",
|
|
4005
|
-
pagination
|
|
4006
|
-
});
|
|
4007
|
-
});
|
|
3958
|
+
})
|
|
3959
|
+
};
|
|
3960
|
+
this.apiKey = opts.apiKey;
|
|
3961
|
+
this.baseUrl = opts.baseUrl || "https://api.oumla.com";
|
|
3962
|
+
this.env = opts.env || "testnet";
|
|
3963
|
+
this.initialize();
|
|
4008
3964
|
}
|
|
4009
|
-
|
|
4010
|
-
*
|
|
4011
|
-
* Get the volume for an organization
|
|
4012
|
-
*
|
|
4013
|
-
* @example
|
|
4014
|
-
* ``` ts
|
|
4015
|
-
*
|
|
4016
|
-
* const volume = await client.getVolume();
|
|
4017
|
-
*
|
|
4018
|
-
* ```
|
|
4019
|
-
*
|
|
4020
|
-
* @returns {Types.TGetVolumeResponse} - The volume of the organization
|
|
4021
|
-
*/
|
|
4022
|
-
getVolume() {
|
|
3965
|
+
initialize() {
|
|
4023
3966
|
return __async(this, null, function* () {
|
|
4024
|
-
|
|
4025
|
-
path: "/api/v1/statistics/organization/volume"
|
|
4026
|
-
});
|
|
3967
|
+
yield this.checkForUpdates();
|
|
4027
3968
|
});
|
|
4028
3969
|
}
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
* @example
|
|
4034
|
-
* ``` ts
|
|
4035
|
-
*
|
|
4036
|
-
* const insights = await client.getInsights();
|
|
4037
|
-
*
|
|
4038
|
-
* ```
|
|
4039
|
-
*
|
|
4040
|
-
* @returns {Types.TGetInsightsResponse} - The insights of the organization
|
|
4041
|
-
*/
|
|
4042
|
-
getInsights() {
|
|
4043
|
-
return __async(this, null, function* () {
|
|
4044
|
-
return yield this.httpRequest({
|
|
4045
|
-
path: "/api/v1/statistics/organization/insights"
|
|
4046
|
-
});
|
|
4047
|
-
});
|
|
3970
|
+
getCustomHeaders() {
|
|
3971
|
+
return {
|
|
3972
|
+
"x-sdk-version": _Oumla.CURRENT_VERSION
|
|
3973
|
+
};
|
|
4048
3974
|
}
|
|
4049
|
-
|
|
4050
|
-
*
|
|
4051
|
-
* Get the all the transactions or transactions for an address, wallet or reference
|
|
4052
|
-
*
|
|
4053
|
-
* By providing more than one option, only one will be used.
|
|
4054
|
-
*
|
|
4055
|
-
* @param {string} [args.address] - The address to get transactions for
|
|
4056
|
-
* @param {string} [args.wallet] - The wallet to get transactions for
|
|
4057
|
-
* @param {string} [args.reference] - The reference to get transactions for
|
|
4058
|
-
* @param {Types.TPagination} [pagination] - Pagination options
|
|
4059
|
-
*
|
|
4060
|
-
* @example
|
|
4061
|
-
* ``` ts
|
|
4062
|
-
*
|
|
4063
|
-
* const transactionsByAddress = await client.getTransactions({
|
|
4064
|
-
* address: 'ADDRESS',
|
|
4065
|
-
* });
|
|
4066
|
-
*
|
|
4067
|
-
* ```
|
|
4068
|
-
*
|
|
4069
|
-
* @returns {Types.TGetTransactionsResponse} - The transactions
|
|
4070
|
-
*
|
|
4071
|
-
*/
|
|
4072
|
-
getTransactions(args, pagination) {
|
|
3975
|
+
checkForUpdates() {
|
|
4073
3976
|
return __async(this, null, function* () {
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
pagination
|
|
4083
|
-
});
|
|
4084
|
-
} else if (args == null ? void 0 : args.reference) {
|
|
4085
|
-
return yield this.httpRequest({
|
|
4086
|
-
path: `/api/v1/transactions/profile/${args.reference}`,
|
|
4087
|
-
pagination
|
|
4088
|
-
});
|
|
4089
|
-
} else {
|
|
4090
|
-
return yield this.httpRequest({
|
|
4091
|
-
path: "/api/v1/transactions/organization",
|
|
4092
|
-
pagination
|
|
3977
|
+
const now = Date.now();
|
|
3978
|
+
if (now - this.lastUpdateCheck < this.UPDATE_CHECK_INTERVAL) {
|
|
3979
|
+
return;
|
|
3980
|
+
}
|
|
3981
|
+
try {
|
|
3982
|
+
const response = yield this.httpRequest({
|
|
3983
|
+
path: "/api/v1/sdk-version",
|
|
3984
|
+
method: "GET"
|
|
4093
3985
|
});
|
|
3986
|
+
if (response.latestVersion !== _Oumla.CURRENT_VERSION) {
|
|
3987
|
+
console.log(
|
|
3988
|
+
`A new version (${response.latestVersion}) of the Oumla SDK is available. Please update.`
|
|
3989
|
+
);
|
|
3990
|
+
}
|
|
3991
|
+
this.lastUpdateCheck = now;
|
|
3992
|
+
} catch (error) {
|
|
3993
|
+
console.error("Failed to check for updates:", error);
|
|
4094
3994
|
}
|
|
4095
3995
|
});
|
|
4096
3996
|
}
|
|
4097
|
-
/**
|
|
4098
|
-
* create transaction
|
|
4099
|
-
*
|
|
4100
|
-
* @param args.from - the address or addresses to transfer from
|
|
4101
|
-
* @param args.to - The desired address to transfer to
|
|
4102
|
-
* @param args.amount - The amount to transfer
|
|
4103
|
-
*
|
|
4104
|
-
* @example
|
|
4105
|
-
*
|
|
4106
|
-
* ``` ts
|
|
4107
|
-
*
|
|
4108
|
-
* const transfer = await client.transfer({
|
|
4109
|
-
* from: '0x...',
|
|
4110
|
-
* to: '0x...',
|
|
4111
|
-
* reference: '0x...',
|
|
4112
|
-
* amount: 100,
|
|
4113
|
-
* });
|
|
4114
|
-
*
|
|
4115
|
-
* ```
|
|
4116
|
-
*/
|
|
4117
|
-
createTransaction(args) {
|
|
4118
|
-
return __async(this, null, function* () {
|
|
4119
|
-
return yield this.httpRequest({
|
|
4120
|
-
method: "POST",
|
|
4121
|
-
path: "/api/v1/withdraw/address",
|
|
4122
|
-
body: args,
|
|
4123
|
-
schema: CreateTransactionSchema
|
|
4124
|
-
});
|
|
4125
|
-
});
|
|
4126
|
-
}
|
|
4127
3997
|
};
|
|
3998
|
+
var Oumla = _Oumla;
|
|
3999
|
+
Oumla.CURRENT_VERSION = "1.0.0";
|
|
4128
4000
|
|
|
4129
4001
|
// src/types.ts
|
|
4130
4002
|
var ProfileType = /* @__PURE__ */ ((ProfileType2) => {
|