@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.
Files changed (91) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
  2. package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
  3. package/_generated/_dependencies/source/0x1/index.js +3 -6
  4. package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
  5. package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
  6. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
  7. package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
  8. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
  9. package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
  10. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
  11. package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
  12. package/_generated/_dependencies/source/0x2/index.js +3 -6
  13. package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
  14. package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
  15. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
  16. package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
  17. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
  18. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
  19. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
  20. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
  21. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
  22. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
  23. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
  24. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
  25. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
  26. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
  27. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
  28. package/_generated/_framework/reified.d.ts +2 -2
  29. package/_generated/_framework/reified.js +27 -40
  30. package/_generated/_framework/util.js +26 -40
  31. package/_generated/_framework/vector.d.ts +4 -4
  32. package/_generated/_framework/vector.js +16 -21
  33. package/_generated/suilend/cell/structs.d.ts +4 -4
  34. package/_generated/suilend/cell/structs.js +31 -36
  35. package/_generated/suilend/decimal/structs.d.ts +4 -4
  36. package/_generated/suilend/decimal/structs.js +19 -24
  37. package/_generated/suilend/index.js +8 -12
  38. package/_generated/suilend/lending-market/functions.d.ts +1 -0
  39. package/_generated/suilend/lending-market/functions.js +271 -302
  40. package/_generated/suilend/lending-market/structs.d.ts +146 -146
  41. package/_generated/suilend/lending-market/structs.js +549 -617
  42. package/_generated/suilend/lending-market-registry/functions.js +7 -11
  43. package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
  44. package/_generated/suilend/liquidity-mining/structs.js +159 -205
  45. package/_generated/suilend/obligation/structs.d.ts +106 -106
  46. package/_generated/suilend/obligation/structs.js +313 -363
  47. package/_generated/suilend/rate-limiter/functions.js +23 -31
  48. package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
  49. package/_generated/suilend/rate-limiter/structs.js +49 -56
  50. package/_generated/suilend/reserve/structs.d.ts +139 -139
  51. package/_generated/suilend/reserve/structs.js +397 -451
  52. package/_generated/suilend/reserve-config/functions.js +149 -190
  53. package/_generated/suilend/reserve-config/structs.d.ts +33 -33
  54. package/_generated/suilend/reserve-config/structs.js +109 -149
  55. package/api/events.js +1 -5
  56. package/api/index.js +1 -17
  57. package/client.d.ts +10 -10
  58. package/client.js +118 -128
  59. package/index.js +7 -23
  60. package/lib/constants.js +3 -9
  61. package/lib/index.js +5 -21
  62. package/lib/initialize.d.ts +3 -3
  63. package/lib/initialize.js +103 -140
  64. package/lib/liquidityMining.d.ts +3 -3
  65. package/lib/liquidityMining.js +57 -72
  66. package/lib/pyth.js +9 -14
  67. package/lib/strategyOwnerCap.js +106 -119
  68. package/lib/transactions.js +2 -7
  69. package/lib/types.js +4 -7
  70. package/mmt.js +2 -5
  71. package/package.json +1 -1
  72. package/parsers/apiReserveAssetDataEvent.js +25 -33
  73. package/parsers/index.js +5 -21
  74. package/parsers/lendingMarket.d.ts +1 -1
  75. package/parsers/lendingMarket.js +12 -19
  76. package/parsers/obligation.js +19 -26
  77. package/parsers/rateLimiter.js +11 -19
  78. package/parsers/reserve.d.ts +1 -1
  79. package/parsers/reserve.js +42 -85
  80. package/strategies.d.ts +11 -11
  81. package/strategies.js +547 -586
  82. package/swap/index.js +2 -18
  83. package/swap/quote.js +57 -65
  84. package/swap/transaction.d.ts +2 -2
  85. package/swap/transaction.js +40 -35
  86. package/utils/events.d.ts +3 -3
  87. package/utils/events.js +18 -35
  88. package/utils/index.js +16 -40
  89. package/utils/obligation.d.ts +4 -4
  90. package/utils/obligation.js +17 -60
  91. package/utils/simulate.js +118 -143
@@ -3,7 +3,7 @@ import { FieldsWithTypes } from "../../../../_framework/util";
3
3
  import { UID } from "../../0x2/object/structs";
4
4
  import { PKG_V1 } from "../index";
5
5
  import { PriceFeed } from "../price-feed/structs";
6
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
6
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
7
7
  export declare function isPriceInfo(type: string): boolean;
8
8
  export interface PriceInfoFields {
9
9
  attestationTime: ToField<"u64">;
@@ -28,38 +28,38 @@ export declare class PriceInfo implements StructClass {
28
28
  static get r(): import("../../../../_framework/reified").StructClassReified<PriceInfo, PriceInfoFields>;
29
29
  static phantom(): PhantomReified<ToTypeStr<PriceInfo>>;
30
30
  static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfo">;
31
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
32
- attestation_time: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
33
- arrival_time: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
34
- price_feed: import("@mysten/sui/bcs").BcsStruct<{
35
- price_identifier: import("@mysten/sui/bcs").BcsStruct<{
36
- bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
31
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
32
+ attestation_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
33
+ arrival_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
34
+ price_feed: import("@mysten/bcs").BcsStruct<{
35
+ price_identifier: import("@mysten/bcs").BcsStruct<{
36
+ bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
37
37
  length: number;
38
38
  }, string>;
39
39
  }, string>;
40
- price: import("@mysten/sui/bcs").BcsStruct<{
41
- price: import("@mysten/sui/bcs").BcsStruct<{
42
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
43
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
40
+ price: import("@mysten/bcs").BcsStruct<{
41
+ price: import("@mysten/bcs").BcsStruct<{
42
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
43
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
44
44
  }, string>;
45
- conf: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
46
- expo: import("@mysten/sui/bcs").BcsStruct<{
47
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
48
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
45
+ conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
46
+ expo: import("@mysten/bcs").BcsStruct<{
47
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
48
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
49
49
  }, string>;
50
- timestamp: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
50
+ timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
51
51
  }, string>;
52
- ema_price: import("@mysten/sui/bcs").BcsStruct<{
53
- price: import("@mysten/sui/bcs").BcsStruct<{
54
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
55
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
52
+ ema_price: import("@mysten/bcs").BcsStruct<{
53
+ price: import("@mysten/bcs").BcsStruct<{
54
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
55
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
56
56
  }, string>;
57
- conf: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
58
- expo: import("@mysten/sui/bcs").BcsStruct<{
59
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
60
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
57
+ conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
58
+ expo: import("@mysten/bcs").BcsStruct<{
59
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
60
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
61
61
  }, string>;
62
- timestamp: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
62
+ timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
63
63
  }, string>;
64
64
  }, string>;
65
65
  }, string>;
@@ -138,7 +138,7 @@ export declare class PriceInfo implements StructClass {
138
138
  static fromJSON(json: Record<string, any>): PriceInfo;
139
139
  static fromSuiParsedData(content: SuiParsedData): PriceInfo;
140
140
  static fromSuiObjectData(data: SuiObjectData): PriceInfo;
141
- static fetch(client: SuiClient, id: string): Promise<PriceInfo>;
141
+ static fetch(client: SuiJsonRpcClient, id: string): Promise<PriceInfo>;
142
142
  }
143
143
  export declare function isPriceInfoObject(type: string): boolean;
144
144
  export interface PriceInfoObjectFields {
@@ -162,44 +162,44 @@ export declare class PriceInfoObject implements StructClass {
162
162
  static get r(): import("../../../../_framework/reified").StructClassReified<PriceInfoObject, PriceInfoObjectFields>;
163
163
  static phantom(): PhantomReified<ToTypeStr<PriceInfoObject>>;
164
164
  static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfoObject">;
165
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
166
- id: import("@mysten/sui/bcs").BcsStruct<{
167
- id: import("@mysten/sui/bcs").BcsStruct<{
168
- bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
165
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
166
+ id: import("@mysten/bcs").BcsStruct<{
167
+ id: import("@mysten/bcs").BcsStruct<{
168
+ bytes: import("@mysten/bcs").BcsType<string, string, string>;
169
169
  }, string>;
170
170
  }, string>;
171
- price_info: import("@mysten/sui/bcs").BcsStruct<{
172
- attestation_time: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
173
- arrival_time: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
174
- price_feed: import("@mysten/sui/bcs").BcsStruct<{
175
- price_identifier: import("@mysten/sui/bcs").BcsStruct<{
176
- bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
171
+ price_info: import("@mysten/bcs").BcsStruct<{
172
+ attestation_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
173
+ arrival_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
174
+ price_feed: import("@mysten/bcs").BcsStruct<{
175
+ price_identifier: import("@mysten/bcs").BcsStruct<{
176
+ bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
177
177
  length: number;
178
178
  }, string>;
179
179
  }, string>;
180
- price: import("@mysten/sui/bcs").BcsStruct<{
181
- price: import("@mysten/sui/bcs").BcsStruct<{
182
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
183
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
180
+ price: import("@mysten/bcs").BcsStruct<{
181
+ price: import("@mysten/bcs").BcsStruct<{
182
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
183
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
184
184
  }, string>;
185
- conf: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
186
- expo: import("@mysten/sui/bcs").BcsStruct<{
187
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
188
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
185
+ conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
186
+ expo: import("@mysten/bcs").BcsStruct<{
187
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
188
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
189
189
  }, string>;
190
- timestamp: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
190
+ timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
191
191
  }, string>;
192
- ema_price: import("@mysten/sui/bcs").BcsStruct<{
193
- price: import("@mysten/sui/bcs").BcsStruct<{
194
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
195
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
192
+ ema_price: import("@mysten/bcs").BcsStruct<{
193
+ price: import("@mysten/bcs").BcsStruct<{
194
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
195
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
196
196
  }, string>;
197
- conf: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
198
- expo: import("@mysten/sui/bcs").BcsStruct<{
199
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
200
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
197
+ conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
198
+ expo: import("@mysten/bcs").BcsStruct<{
199
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
200
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
201
201
  }, string>;
202
- timestamp: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
202
+ timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
203
203
  }, string>;
204
204
  }, string>;
205
205
  }, string>;
@@ -285,5 +285,5 @@ export declare class PriceInfoObject implements StructClass {
285
285
  static fromJSON(json: Record<string, any>): PriceInfoObject;
286
286
  static fromSuiParsedData(content: SuiParsedData): PriceInfoObject;
287
287
  static fromSuiObjectData(data: SuiObjectData): PriceInfoObject;
288
- static fetch(client: SuiClient, id: string): Promise<PriceInfoObject>;
288
+ static fetch(client: SuiJsonRpcClient, id: string): Promise<PriceInfoObject>;
289
289
  }
@@ -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,28 +7,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PriceInfoObject = exports.PriceInfo = void 0;
13
- exports.isPriceInfo = isPriceInfo;
14
- exports.isPriceInfoObject = isPriceInfoObject;
15
- const reified_1 = require("../../../../_framework/reified");
16
- const util_1 = require("../../../../_framework/util");
17
- const structs_1 = require("../../0x2/object/structs");
18
- const index_1 = require("../index");
19
- const structs_2 = require("../price-feed/structs");
20
- const bcs_1 = require("@mysten/sui/bcs");
21
- 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 { UID } from "../../0x2/object/structs";
13
+ import { PKG_V1 } from "../index";
14
+ import { PriceFeed } from "../price-feed/structs";
15
+ import { bcs } from "@mysten/sui/bcs";
16
+ import { fromBase64 } from "@mysten/sui/utils";
22
17
  /* ============================== PriceInfo =============================== */
23
- function isPriceInfo(type) {
24
- type = (0, util_1.compressSuiType)(type);
25
- return type === `${index_1.PKG_V1}::price_info::PriceInfo`;
18
+ export function isPriceInfo(type) {
19
+ type = compressSuiType(type);
20
+ return type === `${PKG_V1}::price_info::PriceInfo`;
26
21
  }
27
- class PriceInfo {
22
+ export class PriceInfo {
28
23
  constructor(typeArgs, fields) {
29
24
  this.__StructClass = true;
30
25
  this.$typeName = PriceInfo.$typeName;
31
26
  this.$isPhantom = PriceInfo.$isPhantom;
32
- this.$fullTypeName = (0, util_1.composeSuiType)(PriceInfo.$typeName, ...typeArgs);
27
+ this.$fullTypeName = composeSuiType(PriceInfo.$typeName, ...typeArgs);
33
28
  this.$typeArgs = typeArgs;
34
29
  this.attestationTime = fields.attestationTime;
35
30
  this.arrivalTime = fields.arrivalTime;
@@ -38,7 +33,7 @@ class PriceInfo {
38
33
  static reified() {
39
34
  return {
40
35
  typeName: PriceInfo.$typeName,
41
- fullTypeName: (0, util_1.composeSuiType)(PriceInfo.$typeName, ...[]),
36
+ fullTypeName: composeSuiType(PriceInfo.$typeName, ...[]),
42
37
  typeArgs: [],
43
38
  isPhantom: PriceInfo.$isPhantom,
44
39
  reifiedTypeArgs: [],
@@ -61,23 +56,23 @@ class PriceInfo {
61
56
  return PriceInfo.reified();
62
57
  }
63
58
  static phantom() {
64
- return (0, reified_1.phantom)(PriceInfo.reified());
59
+ return phantom(PriceInfo.reified());
65
60
  }
66
61
  static get p() {
67
62
  return PriceInfo.phantom();
68
63
  }
69
64
  static get bcs() {
70
- return bcs_1.bcs.struct("PriceInfo", {
71
- attestation_time: bcs_1.bcs.u64(),
72
- arrival_time: bcs_1.bcs.u64(),
73
- price_feed: structs_2.PriceFeed.bcs,
65
+ return bcs.struct("PriceInfo", {
66
+ attestation_time: bcs.u64(),
67
+ arrival_time: bcs.u64(),
68
+ price_feed: PriceFeed.bcs,
74
69
  });
75
70
  }
76
71
  static fromFields(fields) {
77
72
  return PriceInfo.reified().new({
78
- attestationTime: (0, reified_1.decodeFromFields)("u64", fields.attestation_time),
79
- arrivalTime: (0, reified_1.decodeFromFields)("u64", fields.arrival_time),
80
- priceFeed: (0, reified_1.decodeFromFields)(structs_2.PriceFeed.reified(), fields.price_feed),
73
+ attestationTime: decodeFromFields("u64", fields.attestation_time),
74
+ arrivalTime: decodeFromFields("u64", fields.arrival_time),
75
+ priceFeed: decodeFromFields(PriceFeed.reified(), fields.price_feed),
81
76
  });
82
77
  }
83
78
  static fromFieldsWithTypes(item) {
@@ -85,9 +80,9 @@ class PriceInfo {
85
80
  throw new Error("not a PriceInfo type");
86
81
  }
87
82
  return PriceInfo.reified().new({
88
- attestationTime: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.attestation_time),
89
- arrivalTime: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.arrival_time),
90
- priceFeed: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.PriceFeed.reified(), item.fields.price_feed),
83
+ attestationTime: decodeFromFieldsWithTypes("u64", item.fields.attestation_time),
84
+ arrivalTime: decodeFromFieldsWithTypes("u64", item.fields.arrival_time),
85
+ priceFeed: decodeFromFieldsWithTypes(PriceFeed.reified(), item.fields.price_feed),
91
86
  });
92
87
  }
93
88
  static fromBcs(data) {
@@ -105,9 +100,9 @@ class PriceInfo {
105
100
  }
106
101
  static fromJSONField(field) {
107
102
  return PriceInfo.reified().new({
108
- attestationTime: (0, reified_1.decodeFromJSONField)("u64", field.attestationTime),
109
- arrivalTime: (0, reified_1.decodeFromJSONField)("u64", field.arrivalTime),
110
- priceFeed: (0, reified_1.decodeFromJSONField)(structs_2.PriceFeed.reified(), field.priceFeed),
103
+ attestationTime: decodeFromJSONField("u64", field.attestationTime),
104
+ arrivalTime: decodeFromJSONField("u64", field.arrivalTime),
105
+ priceFeed: decodeFromJSONField(PriceFeed.reified(), field.priceFeed),
111
106
  });
112
107
  }
113
108
  static fromJSON(json) {
@@ -130,7 +125,7 @@ class PriceInfo {
130
125
  if (data.bcs.dataType !== "moveObject" || !isPriceInfo(data.bcs.type)) {
131
126
  throw new Error(`object at is not a PriceInfo object`);
132
127
  }
133
- return PriceInfo.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
128
+ return PriceInfo.fromBcs(fromBase64(data.bcs.bcsBytes));
134
129
  }
135
130
  if (data.content) {
136
131
  return PriceInfo.fromSuiParsedData(data.content);
@@ -152,21 +147,20 @@ class PriceInfo {
152
147
  });
153
148
  }
154
149
  }
155
- exports.PriceInfo = PriceInfo;
156
- PriceInfo.$typeName = `${index_1.PKG_V1}::price_info::PriceInfo`;
150
+ PriceInfo.$typeName = `${PKG_V1}::price_info::PriceInfo`;
157
151
  PriceInfo.$numTypeParams = 0;
158
152
  PriceInfo.$isPhantom = [];
159
153
  /* ============================== PriceInfoObject =============================== */
160
- function isPriceInfoObject(type) {
161
- type = (0, util_1.compressSuiType)(type);
162
- return type === `${index_1.PKG_V1}::price_info::PriceInfoObject`;
154
+ export function isPriceInfoObject(type) {
155
+ type = compressSuiType(type);
156
+ return type === `${PKG_V1}::price_info::PriceInfoObject`;
163
157
  }
164
- class PriceInfoObject {
158
+ export class PriceInfoObject {
165
159
  constructor(typeArgs, fields) {
166
160
  this.__StructClass = true;
167
161
  this.$typeName = PriceInfoObject.$typeName;
168
162
  this.$isPhantom = PriceInfoObject.$isPhantom;
169
- this.$fullTypeName = (0, util_1.composeSuiType)(PriceInfoObject.$typeName, ...typeArgs);
163
+ this.$fullTypeName = composeSuiType(PriceInfoObject.$typeName, ...typeArgs);
170
164
  this.$typeArgs = typeArgs;
171
165
  this.id = fields.id;
172
166
  this.priceInfo = fields.priceInfo;
@@ -174,7 +168,7 @@ class PriceInfoObject {
174
168
  static reified() {
175
169
  return {
176
170
  typeName: PriceInfoObject.$typeName,
177
- fullTypeName: (0, util_1.composeSuiType)(PriceInfoObject.$typeName, ...[]),
171
+ fullTypeName: composeSuiType(PriceInfoObject.$typeName, ...[]),
178
172
  typeArgs: [],
179
173
  isPhantom: PriceInfoObject.$isPhantom,
180
174
  reifiedTypeArgs: [],
@@ -197,21 +191,21 @@ class PriceInfoObject {
197
191
  return PriceInfoObject.reified();
198
192
  }
199
193
  static phantom() {
200
- return (0, reified_1.phantom)(PriceInfoObject.reified());
194
+ return phantom(PriceInfoObject.reified());
201
195
  }
202
196
  static get p() {
203
197
  return PriceInfoObject.phantom();
204
198
  }
205
199
  static get bcs() {
206
- return bcs_1.bcs.struct("PriceInfoObject", {
207
- id: structs_1.UID.bcs,
200
+ return bcs.struct("PriceInfoObject", {
201
+ id: UID.bcs,
208
202
  price_info: PriceInfo.bcs,
209
203
  });
210
204
  }
211
205
  static fromFields(fields) {
212
206
  return PriceInfoObject.reified().new({
213
- id: (0, reified_1.decodeFromFields)(structs_1.UID.reified(), fields.id),
214
- priceInfo: (0, reified_1.decodeFromFields)(PriceInfo.reified(), fields.price_info),
207
+ id: decodeFromFields(UID.reified(), fields.id),
208
+ priceInfo: decodeFromFields(PriceInfo.reified(), fields.price_info),
215
209
  });
216
210
  }
217
211
  static fromFieldsWithTypes(item) {
@@ -219,8 +213,8 @@ class PriceInfoObject {
219
213
  throw new Error("not a PriceInfoObject type");
220
214
  }
221
215
  return PriceInfoObject.reified().new({
222
- id: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.UID.reified(), item.fields.id),
223
- priceInfo: (0, reified_1.decodeFromFieldsWithTypes)(PriceInfo.reified(), item.fields.price_info),
216
+ id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id),
217
+ priceInfo: decodeFromFieldsWithTypes(PriceInfo.reified(), item.fields.price_info),
224
218
  });
225
219
  }
226
220
  static fromBcs(data) {
@@ -237,8 +231,8 @@ class PriceInfoObject {
237
231
  }
238
232
  static fromJSONField(field) {
239
233
  return PriceInfoObject.reified().new({
240
- id: (0, reified_1.decodeFromJSONField)(structs_1.UID.reified(), field.id),
241
- priceInfo: (0, reified_1.decodeFromJSONField)(PriceInfo.reified(), field.priceInfo),
234
+ id: decodeFromJSONField(UID.reified(), field.id),
235
+ priceInfo: decodeFromJSONField(PriceInfo.reified(), field.priceInfo),
242
236
  });
243
237
  }
244
238
  static fromJSON(json) {
@@ -262,7 +256,7 @@ class PriceInfoObject {
262
256
  !isPriceInfoObject(data.bcs.type)) {
263
257
  throw new Error(`object at is not a PriceInfoObject object`);
264
258
  }
265
- return PriceInfoObject.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
259
+ return PriceInfoObject.fromBcs(fromBase64(data.bcs.bcsBytes));
266
260
  }
267
261
  if (data.content) {
268
262
  return PriceInfoObject.fromSuiParsedData(data.content);
@@ -284,7 +278,6 @@ class PriceInfoObject {
284
278
  });
285
279
  }
286
280
  }
287
- exports.PriceInfoObject = PriceInfoObject;
288
- PriceInfoObject.$typeName = `${index_1.PKG_V1}::price_info::PriceInfoObject`;
281
+ PriceInfoObject.$typeName = `${PKG_V1}::price_info::PriceInfoObject`;
289
282
  PriceInfoObject.$numTypeParams = 0;
290
283
  PriceInfoObject.$isPhantom = [];
@@ -1,6 +1,6 @@
1
1
  import { BcsType } from "@mysten/sui/bcs";
2
2
  import { FieldsWithTypes } from "./util";
3
- import { SuiClient, SuiParsedData, SuiObjectData } from "@mysten/sui/client";
3
+ import { SuiJsonRpcClient, SuiParsedData, SuiObjectData } from "@mysten/sui/jsonRpc";
4
4
  export { vector } from "./vector";
5
5
  export interface StructClass {
6
6
  readonly $typeName: string;
@@ -37,7 +37,7 @@ export interface StructClassReified<T extends StructClass, Fields> {
37
37
  fromJSON: (json: Record<string, any>) => T;
38
38
  fromSuiParsedData: (content: SuiParsedData) => T;
39
39
  fromSuiObjectData: (data: SuiObjectData) => T;
40
- fetch: (client: SuiClient, id: string) => Promise<T>;
40
+ fetch: (client: SuiJsonRpcClient, id: string) => Promise<T>;
41
41
  new: (fields: Fields) => T;
42
42
  kind: "StructClassReified";
43
43
  }
@@ -1,22 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.vector = void 0;
4
- exports.phantom = phantom;
5
- exports.toBcs = toBcs;
6
- exports.extractType = extractType;
7
- exports.decodeFromFields = decodeFromFields;
8
- exports.decodeFromFieldsWithTypes = decodeFromFieldsWithTypes;
9
- exports.assertReifiedTypeArgsMatch = assertReifiedTypeArgsMatch;
10
- exports.assertFieldsWithTypesArgsMatch = assertFieldsWithTypesArgsMatch;
11
- exports.fieldToJSON = fieldToJSON;
12
- exports.decodeFromJSONField = decodeFromJSONField;
13
- const bcs_1 = require("@mysten/sui/bcs");
14
- const utils_1 = require("@mysten/sui/utils");
15
- const util_1 = require("./util");
1
+ import { bcs } from "@mysten/sui/bcs";
2
+ import { fromHex, toHex } from "@mysten/sui/utils";
3
+ import { compressSuiType, parseTypeName } from "./util";
16
4
  // for backwards compatibility
17
- var vector_1 = require("./vector");
18
- Object.defineProperty(exports, "vector", { enumerable: true, get: function () { return vector_1.vector; } });
19
- function phantom(type) {
5
+ export { vector } from "./vector";
6
+ export function phantom(type) {
20
7
  if (typeof type === "string") {
21
8
  return {
22
9
  phantomType: type,
@@ -30,33 +17,33 @@ function phantom(type) {
30
17
  };
31
18
  }
32
19
  }
33
- const Address = bcs_1.bcs.bytes(32).transform({
34
- input: (val) => (0, utils_1.fromHEX)(val),
35
- output: (val) => (0, utils_1.toHEX)(val),
20
+ const Address = bcs.bytes(32).transform({
21
+ input: (val) => fromHex(val),
22
+ output: (val) => toHex(val),
36
23
  });
37
- function toBcs(arg) {
24
+ export function toBcs(arg) {
38
25
  switch (arg) {
39
26
  case "bool":
40
- return bcs_1.bcs.bool();
27
+ return bcs.bool();
41
28
  case "u8":
42
- return bcs_1.bcs.u8();
29
+ return bcs.u8();
43
30
  case "u16":
44
- return bcs_1.bcs.u16();
31
+ return bcs.u16();
45
32
  case "u32":
46
- return bcs_1.bcs.u32();
33
+ return bcs.u32();
47
34
  case "u64":
48
- return bcs_1.bcs.u64();
35
+ return bcs.u64();
49
36
  case "u128":
50
- return bcs_1.bcs.u128();
37
+ return bcs.u128();
51
38
  case "u256":
52
- return bcs_1.bcs.u256();
39
+ return bcs.u256();
53
40
  case "address":
54
41
  return Address;
55
42
  default:
56
43
  return arg.bcs;
57
44
  }
58
45
  }
59
- function extractType(reified) {
46
+ export function extractType(reified) {
60
47
  switch (reified) {
61
48
  case "u8":
62
49
  case "u16":
@@ -78,7 +65,7 @@ function extractType(reified) {
78
65
  }
79
66
  throw new Error("unreachable");
80
67
  }
81
- function decodeFromFields(reified, field) {
68
+ export function decodeFromFields(reified, field) {
82
69
  switch (reified) {
83
70
  case "bool":
84
71
  case "u8":
@@ -117,7 +104,7 @@ function decodeFromFields(reified, field) {
117
104
  return reified.fromFields(field);
118
105
  }
119
106
  }
120
- function decodeFromFieldsWithTypes(reified, item) {
107
+ export function decodeFromFieldsWithTypes(reified, item) {
121
108
  switch (reified) {
122
109
  case "bool":
123
110
  case "u8":
@@ -154,23 +141,23 @@ function decodeFromFieldsWithTypes(reified, item) {
154
141
  return reified.fromFieldsWithTypes(item);
155
142
  }
156
143
  }
157
- function assertReifiedTypeArgsMatch(fullType, typeArgs, reifiedTypeArgs) {
144
+ export function assertReifiedTypeArgsMatch(fullType, typeArgs, reifiedTypeArgs) {
158
145
  if (reifiedTypeArgs.length !== typeArgs.length) {
159
146
  throw new Error(`provided item has mismatching number of type arguments ${fullType} (expected ${reifiedTypeArgs.length}, got ${typeArgs.length}))`);
160
147
  }
161
148
  for (let i = 0; i < typeArgs.length; i++) {
162
- if ((0, util_1.compressSuiType)(typeArgs[i]) !==
163
- (0, util_1.compressSuiType)(extractType(reifiedTypeArgs[i]))) {
149
+ if (compressSuiType(typeArgs[i]) !==
150
+ compressSuiType(extractType(reifiedTypeArgs[i]))) {
164
151
  throw new Error(`provided item has mismatching type arguments ${fullType} (expected ${extractType(reifiedTypeArgs[i])}, got ${typeArgs[i]}))`);
165
152
  }
166
153
  }
167
154
  }
168
- function assertFieldsWithTypesArgsMatch(item, reifiedTypeArgs) {
169
- const { typeArgs: itemTypeArgs } = (0, util_1.parseTypeName)(item.type);
155
+ export function assertFieldsWithTypesArgsMatch(item, reifiedTypeArgs) {
156
+ const { typeArgs: itemTypeArgs } = parseTypeName(item.type);
170
157
  assertReifiedTypeArgsMatch(item.type, itemTypeArgs, reifiedTypeArgs);
171
158
  }
172
- function fieldToJSON(type, field) {
173
- const { typeName, typeArgs } = (0, util_1.parseTypeName)(type);
159
+ export function fieldToJSON(type, field) {
160
+ const { typeName, typeArgs } = parseTypeName(type);
174
161
  switch (typeName) {
175
162
  case "bool":
176
163
  return field;
@@ -204,7 +191,7 @@ function fieldToJSON(type, field) {
204
191
  return field.toJSONField();
205
192
  }
206
193
  }
207
- function decodeFromJSONField(typeArg, field) {
194
+ export function decodeFromJSONField(typeArg, field) {
208
195
  switch (typeArg) {
209
196
  case "bool":
210
197
  case "u8":