aftermath-ts-sdk 1.1.55 → 1.1.56

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.
@@ -167,7 +167,7 @@ class RouterApiHelpers {
167
167
  // =========================================================================
168
168
  fetchTransactionForCompleteTradeRoute(inputs) {
169
169
  return __awaiter(this, void 0, void 0, function* () {
170
- return this.SynchronousHelpers.fetchBuildTransactionForCompleteTradeRoute(inputs);
170
+ return this.SynchronousHelpers.fetchBuildTransactionForCompleteTradeRoute(Object.assign(Object.assign({}, inputs), { slippage: inputs.slippage * 100 }));
171
171
  });
172
172
  }
173
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aftermath-ts-sdk",
3
- "version": "1.1.55",
3
+ "version": "1.1.56",
4
4
  "description": "Aftermath TypeScript SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,39 +0,0 @@
1
- import { DisplayFieldsResponse, SuiObjectResponse } from "@mysten/sui.js/client";
2
- import { AnyObjectType, Balance, ObjectId, Slippage } from "../../types";
3
- export declare class Utils {
4
- static stripLeadingZeroesFromType: (type: AnyObjectType) => AnyObjectType;
5
- static addLeadingZeroesToType: (type: AnyObjectType) => AnyObjectType;
6
- static isNumber: (str: string) => boolean;
7
- static sum: (arr: number[]) => number;
8
- static sumBigInt: (arr: bigint[]) => bigint;
9
- static closeEnough: (a: number, b: number, tolerance: number) => boolean;
10
- static closeEnoughBigInt: (a: bigint, b: bigint, tolerance: number) => boolean;
11
- static veryCloseInt: (a: number, b: number, fixedOne: number) => boolean;
12
- static blendedOperations: {
13
- mulNNN: (a: number, b: number) => number;
14
- mulNNB: (a: number, b: number) => bigint;
15
- mulNBN: (a: number, b: bigint) => number;
16
- mulNBB: (a: number, b: bigint) => bigint;
17
- mulBBN: (a: bigint, b: bigint) => number;
18
- mulBBB: (a: bigint, b: bigint) => bigint;
19
- };
20
- static maxBigInt: (...args: bigint[]) => bigint;
21
- static capitalizeOnlyFirstLetter: (str: string) => string;
22
- static parseJsonWithBigint: (json: string, unsafeStringNumberConversion?: boolean) => any;
23
- static deepCopy: <T>(target: T) => T;
24
- static indexOfMax: (arr: any[]) => number;
25
- static uniqueArray: <T>(arr: T[]) => T[];
26
- static sleep: (ms: number) => Promise<unknown>;
27
- static createUid: () => string;
28
- static bifilter: <ArrayType>(array: ArrayType[], func: (item: ArrayType, index: number, arr: ArrayType[]) => boolean) => [trues: ArrayType[], falses: ArrayType[]];
29
- static bifilterAsync: <ArrayType>(array: ArrayType[], func: (item: ArrayType, index: number, arr: ArrayType[]) => Promise<boolean>) => Promise<[trues: ArrayType[], falses: ArrayType[]]>;
30
- static filterObject: <Value>(obj: Record<string, Value>, predicate: (key: string, value: Value) => boolean) => Record<string, Value>;
31
- static applySlippageBigInt: (amount: Balance, slippage: Slippage) => bigint;
32
- static applySlippage: (amount: number, slippage: Slippage) => number;
33
- static isArrayOfStrings(value: unknown): value is string[];
34
- static getObjectType(data: SuiObjectResponse): ObjectId;
35
- static getObjectId(data: SuiObjectResponse): ObjectId;
36
- static getObjectFields(data: SuiObjectResponse): Record<string, any>;
37
- static getObjectDisplay(data: SuiObjectResponse): DisplayFieldsResponse;
38
- }
39
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/general/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EAErB,iBAAiB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,aAAa,EACb,OAAO,EAEP,QAAQ,EACR,QAAQ,EACR,MAAM,aAAa,CAAC;AAIrB,qBAAa,KAAK;IAKjB,OAAc,0BAA0B,SACjC,aAAa,KACjB,aAAa,CAAiC;IAEjD,OAAc,sBAAsB,SAC7B,aAAa,KACjB,aAAa,CA0Bd;IAMF,OAAc,QAAQ,QAAS,MAAM,KAAG,OAAO,CAA6B;IAE5E,OA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EAAE,iBAAiB,GAAG,QAAQ;WAO9C,eAAe,CAC5B,IAAI,EAAE,iBAAiB,GACrB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WASR,gBAAgB,CAC7B,IAAI,EAAE,iBAAiB,GACrB,qBAAqB;CAMxB"}
@@ -1,188 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var _a;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Utils = void 0;
14
- const casting_1 = require("./casting");
15
- class Utils {
16
- // =========================================================================
17
- // Type Checking
18
- // =========================================================================
19
- static isArrayOfStrings(value) {
20
- return (Array.isArray(value) &&
21
- value.every((item) => typeof item === "string"));
22
- }
23
- // =========================================================================
24
- // Sui Object Parsing
25
- // =========================================================================
26
- static getObjectType(data) {
27
- var _b, _c;
28
- const objectType = (_b = data.data) === null || _b === void 0 ? void 0 : _b.type;
29
- if (objectType)
30
- return objectType;
31
- throw new Error("no object type found on " + ((_c = data.data) === null || _c === void 0 ? void 0 : _c.objectId));
32
- }
33
- static getObjectId(data) {
34
- var _b, _c;
35
- const objectId = (_b = data.data) === null || _b === void 0 ? void 0 : _b.objectId;
36
- if (objectId)
37
- return objectId;
38
- throw new Error("no object id found on " + ((_c = data.data) === null || _c === void 0 ? void 0 : _c.type));
39
- }
40
- static getObjectFields(data) {
41
- var _b, _c;
42
- try {
43
- const content = (_b = data.data) === null || _b === void 0 ? void 0 : _b.content;
44
- return content.fields;
45
- }
46
- catch (e) {
47
- throw new Error("no object fields found on " + ((_c = data.data) === null || _c === void 0 ? void 0 : _c.objectId));
48
- }
49
- }
50
- static getObjectDisplay(data) {
51
- var _b;
52
- const display = this.getObjectDisplay(data);
53
- if (display)
54
- return display;
55
- throw new Error("no object display found on " + ((_b = data.data) === null || _b === void 0 ? void 0 : _b.objectId));
56
- }
57
- }
58
- exports.Utils = Utils;
59
- _a = Utils;
60
- // =========================================================================
61
- // Type Manipulation
62
- // =========================================================================
63
- Utils.stripLeadingZeroesFromType = (type) => type.replaceAll(/x0+/g, "x");
64
- Utils.addLeadingZeroesToType = (type) => {
65
- const expectedTypeLength = 64;
66
- let strippedType = type.replace("0x", "");
67
- let typeSuffix = "";
68
- if (strippedType.includes("::")) {
69
- const splitType = strippedType.replace("0x", "").split("::");
70
- typeSuffix = splitType
71
- .slice(1)
72
- .reduce((acc, str) => acc + "::" + str, "");
73
- strippedType = splitType[0];
74
- }
75
- const typeLength = strippedType.length;
76
- if (typeLength > expectedTypeLength)
77
- throw new Error("invalid type length");
78
- const zeros = Array(expectedTypeLength - typeLength)
79
- .fill("0")
80
- .reduce((acc, val) => acc + val, "");
81
- const newType = "0x" + zeros + strippedType;
82
- return newType + typeSuffix;
83
- };
84
- // =========================================================================
85
- // Numbers
86
- // =========================================================================
87
- Utils.isNumber = (str) => /^\d*\.?\d*$/g.test(str);
88
- Utils.sum = (arr) => arr.reduce((prev, cur) => prev + cur, 0);
89
- Utils.sumBigInt = (arr) => arr.reduce((prev, cur) => prev + cur, BigInt(0));
90
- Utils.closeEnough = (a, b, tolerance) => Math.abs(a - b) <= tolerance * Math.max(a, b);
91
- Utils.closeEnoughBigInt = (a, b, tolerance) => _a.closeEnough(Number(a), Number(b), tolerance);
92
- Utils.veryCloseInt = (a, b, fixedOne) => Math.abs(Math.floor(a / fixedOne) - Math.floor(b / fixedOne)) <= 1;
93
- Utils.blendedOperations = {
94
- mulNNN: (a, b) => a * b,
95
- mulNNB: (a, b) => BigInt(Math.floor(a * b)),
96
- mulNBN: (a, b) => a * Number(b),
97
- mulNBB: (a, b) => BigInt(Math.floor(a * Number(b))),
98
- mulBBN: (a, b) => Number(a * b),
99
- mulBBB: (a, b) => a * b,
100
- };
101
- Utils.maxBigInt = (...args) => args.reduce((m, e) => (e > m ? e : m));
102
- // =========================================================================
103
- // Display
104
- // =========================================================================
105
- Utils.capitalizeOnlyFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
106
- // =========================================================================
107
- // JSON
108
- // =========================================================================
109
- Utils.parseJsonWithBigint = (json, unsafeStringNumberConversion = false) => JSON.parse(json, (key, value) => {
110
- // handles bigint casting
111
- if (typeof value === "string" && /^\d+n$/.test(value)) {
112
- return BigInt(value.slice(0, value.length - 1));
113
- }
114
- if (unsafeStringNumberConversion &&
115
- typeof value === "string" &&
116
- _a.isNumber(value)) {
117
- return BigInt(value);
118
- }
119
- return value;
120
- });
121
- // =========================================================================
122
- // General
123
- // =========================================================================
124
- Utils.deepCopy = (target) => {
125
- if (target === null) {
126
- return target;
127
- }
128
- if (target instanceof Date) {
129
- return new Date(target.getTime());
130
- }
131
- if (target instanceof Array) {
132
- const cp = [];
133
- target.forEach((v) => {
134
- cp.push(v);
135
- });
136
- return cp.map((n) => _a.deepCopy(n));
137
- }
138
- if (typeof target === "object") {
139
- const cp = Object.assign({}, target);
140
- Object.keys(cp).forEach((k) => {
141
- cp[k] = _a.deepCopy(cp[k]);
142
- });
143
- return cp;
144
- }
145
- return target;
146
- };
147
- Utils.indexOfMax = (arr) => {
148
- if (arr.length === 0)
149
- return -1;
150
- let max = arr[0];
151
- let maxIndex = 0;
152
- for (let i = 1; i < arr.length; i++) {
153
- if (arr[i] > max) {
154
- maxIndex = i;
155
- max = arr[i];
156
- }
157
- }
158
- return maxIndex;
159
- };
160
- Utils.uniqueArray = (arr) => [...new Set(arr)];
161
- Utils.sleep = (ms) => new Promise((r) => setTimeout(r, ms));
162
- Utils.createUid = () => Date.now().toString(36) + Math.random().toString(36).substring(2);
163
- Utils.bifilter = (array, func) => {
164
- return array.reduce(([T, F], x, i, arr) => {
165
- if (func(x, i, arr) === false)
166
- return [T, [...F, x]];
167
- else
168
- return [[...T, x], F];
169
- }, [[], []]);
170
- };
171
- Utils.bifilterAsync = (array, func) => __awaiter(void 0, void 0, void 0, function* () {
172
- const predicates = yield Promise.all(array.map(func));
173
- return _a.bifilter(array, (_, index) => predicates[index]);
174
- });
175
- Utils.filterObject = (obj, predicate) => Object.keys(obj).reduce((acc, key) => {
176
- const val = obj[key];
177
- if (!predicate(key, val))
178
- return acc;
179
- return Object.assign(Object.assign({}, acc), { [key]: val });
180
- }, {});
181
- Utils.applySlippageBigInt = (amount, slippage) => {
182
- return (amount -
183
- BigInt(Math.floor(casting_1.Casting.normalizeSlippageTolerance(slippage) *
184
- Number(amount))));
185
- };
186
- Utils.applySlippage = (amount, slippage) => {
187
- return amount - casting_1.Casting.normalizeSlippageTolerance(slippage) * amount;
188
- };