@suilend/sdk 1.1.99 → 2.0.1
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/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
- package/_generated/_dependencies/source/0x1/index.js +3 -6
- package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
- package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
- package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
- package/_generated/_dependencies/source/0x2/index.js +3 -6
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
- package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
- package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
- package/_generated/_framework/reified.d.ts +2 -2
- package/_generated/_framework/reified.js +27 -40
- package/_generated/_framework/util.js +26 -40
- package/_generated/_framework/vector.d.ts +4 -4
- package/_generated/_framework/vector.js +16 -21
- package/_generated/suilend/cell/structs.d.ts +4 -4
- package/_generated/suilend/cell/structs.js +31 -36
- package/_generated/suilend/decimal/structs.d.ts +4 -4
- package/_generated/suilend/decimal/structs.js +19 -24
- package/_generated/suilend/index.js +8 -12
- package/_generated/suilend/lending-market/functions.d.ts +1 -0
- package/_generated/suilend/lending-market/functions.js +271 -302
- package/_generated/suilend/lending-market/structs.d.ts +146 -146
- package/_generated/suilend/lending-market/structs.js +549 -617
- package/_generated/suilend/lending-market-registry/functions.js +7 -11
- package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
- package/_generated/suilend/liquidity-mining/structs.js +159 -205
- package/_generated/suilend/obligation/structs.d.ts +106 -106
- package/_generated/suilend/obligation/structs.js +313 -363
- package/_generated/suilend/rate-limiter/functions.js +23 -31
- package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
- package/_generated/suilend/rate-limiter/structs.js +49 -56
- package/_generated/suilend/reserve/structs.d.ts +139 -139
- package/_generated/suilend/reserve/structs.js +397 -451
- package/_generated/suilend/reserve-config/functions.js +149 -190
- package/_generated/suilend/reserve-config/structs.d.ts +33 -33
- package/_generated/suilend/reserve-config/structs.js +109 -149
- package/api/events.js +1 -5
- package/api/index.js +1 -17
- package/client.d.ts +10 -10
- package/client.js +118 -128
- package/index.js +7 -23
- package/lib/constants.js +3 -9
- package/lib/index.js +5 -21
- package/lib/initialize.d.ts +3 -3
- package/lib/initialize.js +103 -140
- package/lib/liquidityMining.d.ts +3 -3
- package/lib/liquidityMining.js +57 -72
- package/lib/pyth.js +9 -14
- package/lib/strategyOwnerCap.js +106 -119
- package/lib/transactions.js +2 -7
- package/lib/types.js +4 -7
- package/mmt.js +2 -5
- package/package.json +1 -1
- package/parsers/apiReserveAssetDataEvent.js +25 -33
- package/parsers/index.js +5 -21
- package/parsers/lendingMarket.d.ts +1 -1
- package/parsers/lendingMarket.js +12 -19
- package/parsers/obligation.js +19 -26
- package/parsers/rateLimiter.js +11 -19
- package/parsers/reserve.d.ts +1 -1
- package/parsers/reserve.js +42 -85
- package/strategies.d.ts +11 -11
- package/strategies.js +547 -586
- package/swap/index.js +2 -18
- package/swap/quote.js +57 -65
- package/swap/transaction.d.ts +2 -2
- package/swap/transaction.js +40 -35
- package/utils/events.d.ts +3 -3
- package/utils/events.js +18 -35
- package/utils/index.js +16 -40
- package/utils/obligation.d.ts +4 -4
- package/utils/obligation.js +17 -60
- package/utils/simulate.js +118 -143
|
@@ -1,53 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.currentOutflow = currentOutflow;
|
|
5
|
-
exports.newConfig = newConfig;
|
|
6
|
-
exports.processQty = processQty;
|
|
7
|
-
exports.remainingOutflow = remainingOutflow;
|
|
8
|
-
exports.updateInternal = updateInternal;
|
|
9
|
-
const __1 = require("..");
|
|
10
|
-
const util_1 = require("../../_framework/util");
|
|
11
|
-
function new_(tx, args) {
|
|
1
|
+
import { PUBLISHED_AT } from "..";
|
|
2
|
+
import { obj, pure } from "../../_framework/util";
|
|
3
|
+
export function new_(tx, args) {
|
|
12
4
|
return tx.moveCall({
|
|
13
|
-
target: `${
|
|
14
|
-
arguments: [
|
|
5
|
+
target: `${PUBLISHED_AT}::rate_limiter::new`,
|
|
6
|
+
arguments: [obj(tx, args.config), pure(tx, args.curTime, `u64`)],
|
|
15
7
|
});
|
|
16
8
|
}
|
|
17
|
-
function currentOutflow(tx, args) {
|
|
9
|
+
export function currentOutflow(tx, args) {
|
|
18
10
|
return tx.moveCall({
|
|
19
|
-
target: `${
|
|
20
|
-
arguments: [
|
|
11
|
+
target: `${PUBLISHED_AT}::rate_limiter::current_outflow`,
|
|
12
|
+
arguments: [obj(tx, args.rateLimiter), pure(tx, args.curTime, `u64`)],
|
|
21
13
|
});
|
|
22
14
|
}
|
|
23
|
-
function newConfig(tx, args) {
|
|
15
|
+
export function newConfig(tx, args) {
|
|
24
16
|
return tx.moveCall({
|
|
25
|
-
target: `${
|
|
17
|
+
target: `${PUBLISHED_AT}::rate_limiter::new_config`,
|
|
26
18
|
arguments: [
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
pure(tx, args.windowDuration, `u64`),
|
|
20
|
+
pure(tx, args.maxOutflow, `u64`),
|
|
29
21
|
],
|
|
30
22
|
});
|
|
31
23
|
}
|
|
32
|
-
function processQty(tx, args) {
|
|
24
|
+
export function processQty(tx, args) {
|
|
33
25
|
return tx.moveCall({
|
|
34
|
-
target: `${
|
|
26
|
+
target: `${PUBLISHED_AT}::rate_limiter::process_qty`,
|
|
35
27
|
arguments: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
obj(tx, args.rateLimiter),
|
|
29
|
+
pure(tx, args.curTime, `u64`),
|
|
30
|
+
obj(tx, args.qty),
|
|
39
31
|
],
|
|
40
32
|
});
|
|
41
33
|
}
|
|
42
|
-
function remainingOutflow(tx, args) {
|
|
34
|
+
export function remainingOutflow(tx, args) {
|
|
43
35
|
return tx.moveCall({
|
|
44
|
-
target: `${
|
|
45
|
-
arguments: [
|
|
36
|
+
target: `${PUBLISHED_AT}::rate_limiter::remaining_outflow`,
|
|
37
|
+
arguments: [obj(tx, args.rateLimiter), pure(tx, args.curTime, `u64`)],
|
|
46
38
|
});
|
|
47
39
|
}
|
|
48
|
-
function updateInternal(tx, args) {
|
|
40
|
+
export function updateInternal(tx, args) {
|
|
49
41
|
return tx.moveCall({
|
|
50
|
-
target: `${
|
|
51
|
-
arguments: [
|
|
42
|
+
target: `${PUBLISHED_AT}::rate_limiter::update_internal`,
|
|
43
|
+
arguments: [obj(tx, args.rateLimiter), pure(tx, args.curTime, `u64`)],
|
|
52
44
|
});
|
|
53
45
|
}
|
|
@@ -2,7 +2,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
|
|
|
2
2
|
import { FieldsWithTypes } from "../../_framework/util";
|
|
3
3
|
import { Decimal } from "../decimal/structs";
|
|
4
4
|
import { PKG_V1 } from "../index";
|
|
5
|
-
import {
|
|
5
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
6
6
|
export declare function isRateLimiter(type: string): boolean;
|
|
7
7
|
export interface RateLimiterFields {
|
|
8
8
|
config: ToField<RateLimiterConfig>;
|
|
@@ -29,17 +29,17 @@ export declare class RateLimiter implements StructClass {
|
|
|
29
29
|
static get r(): import("../../_framework/reified").StructClassReified<RateLimiter, RateLimiterFields>;
|
|
30
30
|
static phantom(): PhantomReified<ToTypeStr<RateLimiter>>;
|
|
31
31
|
static get p(): PhantomReified<"0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21::rate_limiter::RateLimiter" | "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::rate_limiter::RateLimiter">;
|
|
32
|
-
static get bcs(): import("@mysten/
|
|
33
|
-
config: import("@mysten/
|
|
34
|
-
window_duration: import("@mysten/
|
|
35
|
-
max_outflow: import("@mysten/
|
|
32
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
33
|
+
config: import("@mysten/bcs").BcsStruct<{
|
|
34
|
+
window_duration: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
35
|
+
max_outflow: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
36
36
|
}, string>;
|
|
37
|
-
prev_qty: import("@mysten/
|
|
38
|
-
value: import("@mysten/
|
|
37
|
+
prev_qty: import("@mysten/bcs").BcsStruct<{
|
|
38
|
+
value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u256">;
|
|
39
39
|
}, string>;
|
|
40
|
-
window_start: import("@mysten/
|
|
41
|
-
cur_qty: import("@mysten/
|
|
42
|
-
value: import("@mysten/
|
|
40
|
+
window_start: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
41
|
+
cur_qty: import("@mysten/bcs").BcsStruct<{
|
|
42
|
+
value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u256">;
|
|
43
43
|
}, string>;
|
|
44
44
|
}, string>;
|
|
45
45
|
static fromFields(fields: Record<string, any>): RateLimiter;
|
|
@@ -77,7 +77,7 @@ export declare class RateLimiter implements StructClass {
|
|
|
77
77
|
static fromJSON(json: Record<string, any>): RateLimiter;
|
|
78
78
|
static fromSuiParsedData(content: SuiParsedData): RateLimiter;
|
|
79
79
|
static fromSuiObjectData(data: SuiObjectData): RateLimiter;
|
|
80
|
-
static fetch(client:
|
|
80
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<RateLimiter>;
|
|
81
81
|
}
|
|
82
82
|
export declare function isRateLimiterConfig(type: string): boolean;
|
|
83
83
|
export interface RateLimiterConfigFields {
|
|
@@ -101,9 +101,9 @@ export declare class RateLimiterConfig implements StructClass {
|
|
|
101
101
|
static get r(): import("../../_framework/reified").StructClassReified<RateLimiterConfig, RateLimiterConfigFields>;
|
|
102
102
|
static phantom(): PhantomReified<ToTypeStr<RateLimiterConfig>>;
|
|
103
103
|
static get p(): PhantomReified<"0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21::rate_limiter::RateLimiterConfig" | "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::rate_limiter::RateLimiterConfig">;
|
|
104
|
-
static get bcs(): import("@mysten/
|
|
105
|
-
window_duration: import("@mysten/
|
|
106
|
-
max_outflow: import("@mysten/
|
|
104
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
105
|
+
window_duration: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
106
|
+
max_outflow: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
107
107
|
}, string>;
|
|
108
108
|
static fromFields(fields: Record<string, any>): RateLimiterConfig;
|
|
109
109
|
static fromFieldsWithTypes(item: FieldsWithTypes): RateLimiterConfig;
|
|
@@ -122,5 +122,5 @@ export declare class RateLimiterConfig implements StructClass {
|
|
|
122
122
|
static fromJSON(json: Record<string, any>): RateLimiterConfig;
|
|
123
123
|
static fromSuiParsedData(content: SuiParsedData): RateLimiterConfig;
|
|
124
124
|
static fromSuiObjectData(data: SuiObjectData): RateLimiterConfig;
|
|
125
|
-
static fetch(client:
|
|
125
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<RateLimiterConfig>;
|
|
126
126
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,27 +7,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const structs_1 = require("../decimal/structs");
|
|
18
|
-
const index_1 = require("../index");
|
|
19
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
20
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../_framework/reified";
|
|
11
|
+
import { composeSuiType, compressSuiType, } from "../../_framework/util";
|
|
12
|
+
import { Decimal } from "../decimal/structs";
|
|
13
|
+
import { PKG_V1 } from "../index";
|
|
14
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
15
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
21
16
|
/* ============================== RateLimiter =============================== */
|
|
22
|
-
function isRateLimiter(type) {
|
|
23
|
-
type =
|
|
24
|
-
return type === `${
|
|
17
|
+
export function isRateLimiter(type) {
|
|
18
|
+
type = compressSuiType(type);
|
|
19
|
+
return type === `${PKG_V1}::rate_limiter::RateLimiter`;
|
|
25
20
|
}
|
|
26
|
-
class RateLimiter {
|
|
21
|
+
export class RateLimiter {
|
|
27
22
|
constructor(typeArgs, fields) {
|
|
28
23
|
this.__StructClass = true;
|
|
29
24
|
this.$typeName = RateLimiter.$typeName;
|
|
30
25
|
this.$isPhantom = RateLimiter.$isPhantom;
|
|
31
|
-
this.$fullTypeName =
|
|
26
|
+
this.$fullTypeName = composeSuiType(RateLimiter.$typeName, ...typeArgs);
|
|
32
27
|
this.$typeArgs = typeArgs;
|
|
33
28
|
this.config = fields.config;
|
|
34
29
|
this.prevQty = fields.prevQty;
|
|
@@ -38,7 +33,7 @@ class RateLimiter {
|
|
|
38
33
|
static reified() {
|
|
39
34
|
return {
|
|
40
35
|
typeName: RateLimiter.$typeName,
|
|
41
|
-
fullTypeName:
|
|
36
|
+
fullTypeName: composeSuiType(RateLimiter.$typeName, ...[]),
|
|
42
37
|
typeArgs: [],
|
|
43
38
|
isPhantom: RateLimiter.$isPhantom,
|
|
44
39
|
reifiedTypeArgs: [],
|
|
@@ -61,25 +56,25 @@ class RateLimiter {
|
|
|
61
56
|
return RateLimiter.reified();
|
|
62
57
|
}
|
|
63
58
|
static phantom() {
|
|
64
|
-
return
|
|
59
|
+
return phantom(RateLimiter.reified());
|
|
65
60
|
}
|
|
66
61
|
static get p() {
|
|
67
62
|
return RateLimiter.phantom();
|
|
68
63
|
}
|
|
69
64
|
static get bcs() {
|
|
70
|
-
return
|
|
65
|
+
return bcs.struct("RateLimiter", {
|
|
71
66
|
config: RateLimiterConfig.bcs,
|
|
72
|
-
prev_qty:
|
|
73
|
-
window_start:
|
|
74
|
-
cur_qty:
|
|
67
|
+
prev_qty: Decimal.bcs,
|
|
68
|
+
window_start: bcs.u64(),
|
|
69
|
+
cur_qty: Decimal.bcs,
|
|
75
70
|
});
|
|
76
71
|
}
|
|
77
72
|
static fromFields(fields) {
|
|
78
73
|
return RateLimiter.reified().new({
|
|
79
|
-
config:
|
|
80
|
-
prevQty:
|
|
81
|
-
windowStart:
|
|
82
|
-
curQty:
|
|
74
|
+
config: decodeFromFields(RateLimiterConfig.reified(), fields.config),
|
|
75
|
+
prevQty: decodeFromFields(Decimal.reified(), fields.prev_qty),
|
|
76
|
+
windowStart: decodeFromFields("u64", fields.window_start),
|
|
77
|
+
curQty: decodeFromFields(Decimal.reified(), fields.cur_qty),
|
|
83
78
|
});
|
|
84
79
|
}
|
|
85
80
|
static fromFieldsWithTypes(item) {
|
|
@@ -87,10 +82,10 @@ class RateLimiter {
|
|
|
87
82
|
throw new Error("not a RateLimiter type");
|
|
88
83
|
}
|
|
89
84
|
return RateLimiter.reified().new({
|
|
90
|
-
config:
|
|
91
|
-
prevQty:
|
|
92
|
-
windowStart:
|
|
93
|
-
curQty:
|
|
85
|
+
config: decodeFromFieldsWithTypes(RateLimiterConfig.reified(), item.fields.config),
|
|
86
|
+
prevQty: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.prev_qty),
|
|
87
|
+
windowStart: decodeFromFieldsWithTypes("u64", item.fields.window_start),
|
|
88
|
+
curQty: decodeFromFieldsWithTypes(Decimal.reified(), item.fields.cur_qty),
|
|
94
89
|
});
|
|
95
90
|
}
|
|
96
91
|
static fromBcs(data) {
|
|
@@ -109,10 +104,10 @@ class RateLimiter {
|
|
|
109
104
|
}
|
|
110
105
|
static fromJSONField(field) {
|
|
111
106
|
return RateLimiter.reified().new({
|
|
112
|
-
config:
|
|
113
|
-
prevQty:
|
|
114
|
-
windowStart:
|
|
115
|
-
curQty:
|
|
107
|
+
config: decodeFromJSONField(RateLimiterConfig.reified(), field.config),
|
|
108
|
+
prevQty: decodeFromJSONField(Decimal.reified(), field.prevQty),
|
|
109
|
+
windowStart: decodeFromJSONField("u64", field.windowStart),
|
|
110
|
+
curQty: decodeFromJSONField(Decimal.reified(), field.curQty),
|
|
116
111
|
});
|
|
117
112
|
}
|
|
118
113
|
static fromJSON(json) {
|
|
@@ -135,7 +130,7 @@ class RateLimiter {
|
|
|
135
130
|
if (data.bcs.dataType !== "moveObject" || !isRateLimiter(data.bcs.type)) {
|
|
136
131
|
throw new Error(`object at is not a RateLimiter object`);
|
|
137
132
|
}
|
|
138
|
-
return RateLimiter.fromBcs((
|
|
133
|
+
return RateLimiter.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
139
134
|
}
|
|
140
135
|
if (data.content) {
|
|
141
136
|
return RateLimiter.fromSuiParsedData(data.content);
|
|
@@ -157,21 +152,20 @@ class RateLimiter {
|
|
|
157
152
|
});
|
|
158
153
|
}
|
|
159
154
|
}
|
|
160
|
-
|
|
161
|
-
RateLimiter.$typeName = `${index_1.PKG_V1}::rate_limiter::RateLimiter`;
|
|
155
|
+
RateLimiter.$typeName = `${PKG_V1}::rate_limiter::RateLimiter`;
|
|
162
156
|
RateLimiter.$numTypeParams = 0;
|
|
163
157
|
RateLimiter.$isPhantom = [];
|
|
164
158
|
/* ============================== RateLimiterConfig =============================== */
|
|
165
|
-
function isRateLimiterConfig(type) {
|
|
166
|
-
type =
|
|
167
|
-
return type === `${
|
|
159
|
+
export function isRateLimiterConfig(type) {
|
|
160
|
+
type = compressSuiType(type);
|
|
161
|
+
return type === `${PKG_V1}::rate_limiter::RateLimiterConfig`;
|
|
168
162
|
}
|
|
169
|
-
class RateLimiterConfig {
|
|
163
|
+
export class RateLimiterConfig {
|
|
170
164
|
constructor(typeArgs, fields) {
|
|
171
165
|
this.__StructClass = true;
|
|
172
166
|
this.$typeName = RateLimiterConfig.$typeName;
|
|
173
167
|
this.$isPhantom = RateLimiterConfig.$isPhantom;
|
|
174
|
-
this.$fullTypeName =
|
|
168
|
+
this.$fullTypeName = composeSuiType(RateLimiterConfig.$typeName, ...typeArgs);
|
|
175
169
|
this.$typeArgs = typeArgs;
|
|
176
170
|
this.windowDuration = fields.windowDuration;
|
|
177
171
|
this.maxOutflow = fields.maxOutflow;
|
|
@@ -179,7 +173,7 @@ class RateLimiterConfig {
|
|
|
179
173
|
static reified() {
|
|
180
174
|
return {
|
|
181
175
|
typeName: RateLimiterConfig.$typeName,
|
|
182
|
-
fullTypeName:
|
|
176
|
+
fullTypeName: composeSuiType(RateLimiterConfig.$typeName, ...[]),
|
|
183
177
|
typeArgs: [],
|
|
184
178
|
isPhantom: RateLimiterConfig.$isPhantom,
|
|
185
179
|
reifiedTypeArgs: [],
|
|
@@ -202,21 +196,21 @@ class RateLimiterConfig {
|
|
|
202
196
|
return RateLimiterConfig.reified();
|
|
203
197
|
}
|
|
204
198
|
static phantom() {
|
|
205
|
-
return
|
|
199
|
+
return phantom(RateLimiterConfig.reified());
|
|
206
200
|
}
|
|
207
201
|
static get p() {
|
|
208
202
|
return RateLimiterConfig.phantom();
|
|
209
203
|
}
|
|
210
204
|
static get bcs() {
|
|
211
|
-
return
|
|
212
|
-
window_duration:
|
|
213
|
-
max_outflow:
|
|
205
|
+
return bcs.struct("RateLimiterConfig", {
|
|
206
|
+
window_duration: bcs.u64(),
|
|
207
|
+
max_outflow: bcs.u64(),
|
|
214
208
|
});
|
|
215
209
|
}
|
|
216
210
|
static fromFields(fields) {
|
|
217
211
|
return RateLimiterConfig.reified().new({
|
|
218
|
-
windowDuration:
|
|
219
|
-
maxOutflow:
|
|
212
|
+
windowDuration: decodeFromFields("u64", fields.window_duration),
|
|
213
|
+
maxOutflow: decodeFromFields("u64", fields.max_outflow),
|
|
220
214
|
});
|
|
221
215
|
}
|
|
222
216
|
static fromFieldsWithTypes(item) {
|
|
@@ -224,8 +218,8 @@ class RateLimiterConfig {
|
|
|
224
218
|
throw new Error("not a RateLimiterConfig type");
|
|
225
219
|
}
|
|
226
220
|
return RateLimiterConfig.reified().new({
|
|
227
|
-
windowDuration:
|
|
228
|
-
maxOutflow:
|
|
221
|
+
windowDuration: decodeFromFieldsWithTypes("u64", item.fields.window_duration),
|
|
222
|
+
maxOutflow: decodeFromFieldsWithTypes("u64", item.fields.max_outflow),
|
|
229
223
|
});
|
|
230
224
|
}
|
|
231
225
|
static fromBcs(data) {
|
|
@@ -242,8 +236,8 @@ class RateLimiterConfig {
|
|
|
242
236
|
}
|
|
243
237
|
static fromJSONField(field) {
|
|
244
238
|
return RateLimiterConfig.reified().new({
|
|
245
|
-
windowDuration:
|
|
246
|
-
maxOutflow:
|
|
239
|
+
windowDuration: decodeFromJSONField("u64", field.windowDuration),
|
|
240
|
+
maxOutflow: decodeFromJSONField("u64", field.maxOutflow),
|
|
247
241
|
});
|
|
248
242
|
}
|
|
249
243
|
static fromJSON(json) {
|
|
@@ -267,7 +261,7 @@ class RateLimiterConfig {
|
|
|
267
261
|
!isRateLimiterConfig(data.bcs.type)) {
|
|
268
262
|
throw new Error(`object at is not a RateLimiterConfig object`);
|
|
269
263
|
}
|
|
270
|
-
return RateLimiterConfig.fromBcs((
|
|
264
|
+
return RateLimiterConfig.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
271
265
|
}
|
|
272
266
|
if (data.content) {
|
|
273
267
|
return RateLimiterConfig.fromSuiParsedData(data.content);
|
|
@@ -289,7 +283,6 @@ class RateLimiterConfig {
|
|
|
289
283
|
});
|
|
290
284
|
}
|
|
291
285
|
}
|
|
292
|
-
|
|
293
|
-
RateLimiterConfig.$typeName = `${index_1.PKG_V1}::rate_limiter::RateLimiterConfig`;
|
|
286
|
+
RateLimiterConfig.$typeName = `${PKG_V1}::rate_limiter::RateLimiterConfig`;
|
|
294
287
|
RateLimiterConfig.$numTypeParams = 0;
|
|
295
288
|
RateLimiterConfig.$isPhantom = [];
|