@orb-labs/orby-core 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.
@@ -10,29 +10,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.OperationActions = void 0;
13
- const utils_1 = require("../utils/utils");
13
+ const action_helpers_1 = require("../utils/action_helpers");
14
14
  const currency_amount_1 = require("../entities/financial/currency_amount");
15
15
  const library_request_1 = require("../entities/library_request");
16
16
  class OperationActions extends library_request_1.LibraryRequest {
17
17
  constructor(library, client, provider) {
18
18
  super(library, client, provider);
19
19
  }
20
- getOperationsToExecuteTransaction(accountClusterId, to, data, value) {
20
+ getOperationsToExecuteTransaction(accountClusterId, to, data, value, gasToken) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- const { operationSet } = yield this.sendRequest("orby_getOperationsToExecuteTransaction", [{ accountClusterId, to, data, value }]);
23
- return (0, utils_1.extractOperationSet)(operationSet);
22
+ const operationSet = yield this.sendRequest("orby_getOperationsToExecuteTransaction", [{ accountClusterId, to, data, value, gasToken }]);
23
+ return (0, action_helpers_1.extractOperationSet)(operationSet);
24
24
  });
25
25
  }
26
26
  getOperationsToSignTypedData(accountClusterId, data) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- const { operationSet } = yield this.sendRequest("orby_getOperationsToSignTypedData", [{ accountClusterId, data }]);
29
- return (0, utils_1.extractOperationSet)(operationSet);
28
+ const operationSet = yield this.sendRequest("orby_getOperationsToSignTypedData", [{ accountClusterId, data }]);
29
+ return (0, action_helpers_1.extractOperationSet)(operationSet);
30
30
  });
31
31
  }
32
32
  getOperationsToCancelTransaction(accountClusterId, operationSetId) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
- const { cancellationOperationSet } = yield this.sendRequest("orby_getOperationsToCancelTransaction", [{ accountClusterId, operationSetId }]);
35
- return (0, utils_1.extractOperationSet)(cancellationOperationSet);
34
+ const operationSet = yield this.sendRequest("orby_getOperationsToCancelTransaction", [{ accountClusterId, operationSetId }]);
35
+ return (0, action_helpers_1.extractOperationSet)(operationSet);
36
36
  });
37
37
  }
38
38
  isTransactionPreconditionSatisfied(accountClusterId, to, data, value) {
@@ -43,60 +43,80 @@ class OperationActions extends library_request_1.LibraryRequest {
43
43
  }
44
44
  isTypedDataPreconditionSatisfied(accountClusterId, data) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
- const { satisfied } = yield this.sendRequest("orby_isTypedDataPreconditionSatisfied", [{ accountClusterId, data }]);
46
+ const { satisfied, code, message } = yield this.sendRequest("orby_isTypedDataPreconditionSatisfied", [{ accountClusterId, data }]);
47
+ if (code && message) {
48
+ console.error("[isTypedDataPreconditionSatisfied]", code, message);
49
+ return undefined;
50
+ }
47
51
  return satisfied;
48
52
  });
49
53
  }
50
54
  sendSignedOperations(accountClusterId, signedOperations) {
51
55
  return __awaiter(this, void 0, void 0, function* () {
52
- const { operationSetId, operationResponses } = yield this.sendRequest("orby_sendSignedOperations", [{ accountClusterId, signedOperations }]);
56
+ const { operationSetId, operationResponses, code, message } = yield this.sendRequest("orby_sendSignedOperations", [
57
+ { accountClusterId, signedOperations },
58
+ ]);
59
+ if (code && message) {
60
+ console.error("[sendSignedOperations]", code, message);
61
+ return undefined;
62
+ }
53
63
  return {
54
64
  operationSetId,
55
- operationResponses: (0, utils_1.extractOperationStatuses)(operationResponses),
65
+ operationResponses: (0, action_helpers_1.extractOperationStatuses)(operationResponses),
56
66
  };
57
67
  });
58
68
  }
59
69
  getOperationStatuses(operationIds) {
60
70
  return __awaiter(this, void 0, void 0, function* () {
61
71
  const { operationStatuses } = yield this.sendRequest("orby_getOperationStatuses", [{ operationIds }]);
62
- return (0, utils_1.extractOperationStatuses)(operationStatuses);
72
+ return (0, action_helpers_1.extractOperationStatuses)(operationStatuses);
63
73
  });
64
74
  }
65
75
  estimateFiatCostToExecuteTransaction(to, data, value) {
66
76
  return __awaiter(this, void 0, void 0, function* () {
67
- const { estimatedCost } = yield this.sendRequest("orby_estimateFiatCostToExecuteTransaction", [{ to, data, value }]);
77
+ const { estimatedCost, code, message } = yield this.sendRequest("orby_estimateFiatCostToExecuteTransaction", [{ to, data, value }]);
78
+ if (code && message) {
79
+ console.error("[estimateFiatCostToExecuteTransaction]", code, message);
80
+ return undefined;
81
+ }
68
82
  return currency_amount_1.CurrencyAmount.toCurrencyAmount(estimatedCost);
69
83
  });
70
84
  }
71
85
  estimateFiatCostToSignTypedData(data) {
72
86
  return __awaiter(this, void 0, void 0, function* () {
73
- const { estimatedCost } = yield this.sendRequest("orby_estimateFiatCostToSignTypedData", [{ data }]);
87
+ const { estimatedCost, code, message } = yield this.sendRequest("orby_estimateFiatCostToSignTypedData", [{ data }]);
88
+ if (code && message) {
89
+ console.error("[estimateFiatCostToSignTypedData]", code, message);
90
+ return undefined;
91
+ }
74
92
  return currency_amount_1.CurrencyAmount.toCurrencyAmount(estimatedCost);
75
93
  });
76
94
  }
77
95
  getOperationsToTransferToken(accountClusterId, standardizedTokenId, amount, recipient, gasToken) {
78
96
  return __awaiter(this, void 0, void 0, function* () {
79
- const { operationSet } = yield this.sendRequest("orby_getOperationsToTransferToken", [{ accountClusterId, standardizedTokenId, amount, recipient, gasToken }]);
80
- return (0, utils_1.extractOperationSet)(operationSet);
97
+ const operationSet = yield this.sendRequest("orby_getOperationsToTransferToken", [{ accountClusterId, standardizedTokenId, amount, recipient, gasToken }]);
98
+ return (0, action_helpers_1.extractOperationSet)(operationSet);
81
99
  });
82
100
  }
83
101
  getOperationsToSwap(accountClusterId, swapType, input, output, gasToken) {
84
102
  return __awaiter(this, void 0, void 0, function* () {
85
- const { operationSet } = yield this.sendRequest("orby_getOperationsToSwap", [{ accountClusterId, swapType, input, output, gasToken }]);
86
- return (0, utils_1.extractOperationSet)(operationSet);
103
+ const operationSet = yield this.sendRequest("orby_getOperationsToSwap", [
104
+ { accountClusterId, swapType, input, output, gasToken },
105
+ ]);
106
+ return (0, action_helpers_1.extractOperationSet)(operationSet);
87
107
  });
88
108
  }
89
109
  getQuote(accountClusterId, swapType, input, output) {
90
110
  return __awaiter(this, void 0, void 0, function* () {
91
- const { operationSet } = yield this.sendRequest("orby_getQuote", [
111
+ const operationSet = yield this.sendRequest("orby_getQuote", [
92
112
  { accountClusterId, swapType, input, output },
93
113
  ]);
94
- return (0, utils_1.extractOperationSet)(operationSet);
114
+ return (0, action_helpers_1.extractOperationSet)(operationSet);
95
115
  });
96
116
  }
97
117
  getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
98
118
  return __awaiter(this, void 0, void 0, function* () {
99
- const { operationSet } = yield this.sendRequest("orby_getOperationsToBridge", [
119
+ const operationSet = yield this.sendRequest("orby_getOperationsToBridge", [
100
120
  {
101
121
  accountClusterId,
102
122
  standardizedTokenId,
@@ -106,7 +126,7 @@ class OperationActions extends library_request_1.LibraryRequest {
106
126
  gasToken,
107
127
  },
108
128
  ]);
109
- return (0, utils_1.extractOperationSet)(operationSet);
129
+ return (0, action_helpers_1.extractOperationSet)(operationSet);
110
130
  });
111
131
  }
112
132
  }
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TokenActions = void 0;
13
- const utils_1 = require("../utils/utils");
13
+ const action_helpers_1 = require("../utils/action_helpers");
14
14
  const library_request_1 = require("../entities/library_request");
15
15
  class TokenActions extends library_request_1.LibraryRequest {
16
16
  constructor(library, client, provider) {
@@ -21,7 +21,11 @@ class TokenActions extends library_request_1.LibraryRequest {
21
21
  const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
22
22
  return { chainId: `EIP155-${chainId}`, tokenAddress };
23
23
  });
24
- const { standardizedTokenIds } = yield this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }]);
24
+ const { standardizedTokenIds, message, code } = yield this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }]);
25
+ if (code && message) {
26
+ console.error("[getStandardizedTokenIds]", code, message);
27
+ return undefined;
28
+ }
25
29
  return standardizedTokenIds;
26
30
  });
27
31
  }
@@ -30,16 +34,22 @@ class TokenActions extends library_request_1.LibraryRequest {
30
34
  const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
31
35
  return { chainId: `EIP155-${chainId}`, tokenAddress };
32
36
  });
33
- const { standardizedTokens } = yield this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }]);
34
- return (0, utils_1.extractStandardizedTokens)(standardizedTokens);
37
+ const { standardizedTokens, message, code } = yield this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }]);
38
+ if (code && message) {
39
+ console.error("[getStandardizedTokens]", code, message);
40
+ return undefined;
41
+ }
42
+ return (0, action_helpers_1.extractStandardizedTokens)(standardizedTokens);
35
43
  });
36
44
  }
37
45
  getFungibleTokenData(standardizedTokenIds) {
38
46
  return __awaiter(this, void 0, void 0, function* () {
39
- const { data } = yield this.sendRequest("orby_getFungibleTokenData", [
40
- { standardizedTokenIds },
41
- ]);
42
- return (0, utils_1.extractStandardizedToken)(data);
47
+ const { data, message, code } = yield this.sendRequest("orby_getFungibleTokenData", [{ standardizedTokenIds }]);
48
+ if (code && message) {
49
+ console.error("[getFungibleTokenData]", code, message);
50
+ return undefined;
51
+ }
52
+ return (0, action_helpers_1.extractStandardizedToken)(data);
43
53
  });
44
54
  }
45
55
  }
@@ -1,4 +1,14 @@
1
+ import { Blockchain } from "./enums";
2
+ import { Currency } from "./entities/financial/currency";
3
+ import { ChainConfigs } from "./types";
1
4
  export declare const Big: any;
2
5
  export declare const BLOCKCHAIN_ID: {
3
6
  [s: string]: number;
4
7
  };
8
+ export declare const CHAIN_CONFIGS: {
9
+ [s: string]: ChainConfigs;
10
+ };
11
+ export declare const BLOCKCHAIN_ID_TO_BLOCKCHAIN: {
12
+ [s: number]: Blockchain;
13
+ };
14
+ export declare const FIAT_CURRENCY: Currency;
package/dist/constants.js CHANGED
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BLOCKCHAIN_ID = exports.Big = void 0;
6
+ exports.FIAT_CURRENCY = exports.BLOCKCHAIN_ID_TO_BLOCKCHAIN = exports.CHAIN_CONFIGS = exports.BLOCKCHAIN_ID = exports.Big = void 0;
7
7
  const toformat_1 = __importDefault(require("toformat"));
8
8
  const big_js_1 = __importDefault(require("big.js"));
9
9
  const enums_1 = require("./enums");
10
+ const currency_1 = require("./entities/financial/currency");
10
11
  exports.Big = (0, toformat_1.default)(big_js_1.default);
11
12
  exports.BLOCKCHAIN_ID = {
12
13
  [enums_1.Blockchain.ETHEREUM]: 1,
@@ -34,3 +35,105 @@ exports.BLOCKCHAIN_ID = {
34
35
  [enums_1.Blockchain.LOCAL_CHAIN_0]: 1000000000001,
35
36
  [enums_1.Blockchain.LOCAL_CHAIN_1]: 1000000000002,
36
37
  };
38
+ exports.CHAIN_CONFIGS = {
39
+ [enums_1.Blockchain.ETHEREUM]: {
40
+ environment: enums_1.BlockchainEnvironment.MAINNET,
41
+ chainId: BigInt(1),
42
+ },
43
+ [enums_1.Blockchain.POLYGON]: {
44
+ environment: enums_1.BlockchainEnvironment.MAINNET,
45
+ chainId: BigInt(137),
46
+ },
47
+ [enums_1.Blockchain.BINANCE]: {
48
+ environment: enums_1.BlockchainEnvironment.MAINNET,
49
+ chainId: BigInt(56),
50
+ },
51
+ [enums_1.Blockchain.ARBITRUM]: {
52
+ environment: enums_1.BlockchainEnvironment.MAINNET,
53
+ chainId: BigInt(42161),
54
+ },
55
+ [enums_1.Blockchain.ARBITRUM_NOVA]: {
56
+ environment: enums_1.BlockchainEnvironment.MAINNET,
57
+ chainId: BigInt(42170),
58
+ },
59
+ [enums_1.Blockchain.OPTIMISM]: {
60
+ environment: enums_1.BlockchainEnvironment.MAINNET,
61
+ chainId: BigInt(10),
62
+ },
63
+ [enums_1.Blockchain.EVMOS]: {
64
+ environment: enums_1.BlockchainEnvironment.MAINNET,
65
+ chainId: BigInt(9001),
66
+ },
67
+ [enums_1.Blockchain.MOONBEAM]: {
68
+ environment: enums_1.BlockchainEnvironment.MAINNET,
69
+ chainId: BigInt(1284),
70
+ },
71
+ [enums_1.Blockchain.BASE]: {
72
+ environment: enums_1.BlockchainEnvironment.MAINNET,
73
+ chainId: BigInt(8453),
74
+ },
75
+ [enums_1.Blockchain.AVALANCHE]: {
76
+ environment: enums_1.BlockchainEnvironment.MAINNET,
77
+ chainId: BigInt(43114),
78
+ },
79
+ // testnets
80
+ [enums_1.Blockchain.ETHEREUM_SEPOLIA]: {
81
+ environment: enums_1.BlockchainEnvironment.TESTNET,
82
+ chainId: BigInt(11155111),
83
+ },
84
+ [enums_1.Blockchain.ETHEREUM_HOLESKY]: {
85
+ environment: enums_1.BlockchainEnvironment.TESTNET,
86
+ chainId: BigInt(17000),
87
+ },
88
+ [enums_1.Blockchain.ARBITRUM_SEPOLIA]: {
89
+ environment: enums_1.BlockchainEnvironment.TESTNET,
90
+ chainId: BigInt(421614),
91
+ },
92
+ [enums_1.Blockchain.BASE_SEPOLIA]: {
93
+ environment: enums_1.BlockchainEnvironment.TESTNET,
94
+ chainId: BigInt(84532),
95
+ },
96
+ [enums_1.Blockchain.OPTIMISM_SEPOLIA]: {
97
+ environment: enums_1.BlockchainEnvironment.TESTNET,
98
+ chainId: BigInt(11155420),
99
+ },
100
+ [enums_1.Blockchain.BINANCE_TESTNET]: {
101
+ environment: enums_1.BlockchainEnvironment.TESTNET,
102
+ chainId: BigInt(97),
103
+ },
104
+ [enums_1.Blockchain.OPBNB_TESTNET]: {
105
+ environment: enums_1.BlockchainEnvironment.TESTNET,
106
+ chainId: BigInt(5611),
107
+ },
108
+ [enums_1.Blockchain.MOONBEAM_ALPHA]: {
109
+ environment: enums_1.BlockchainEnvironment.TESTNET,
110
+ chainId: BigInt(1287),
111
+ },
112
+ [enums_1.Blockchain.POLYGON_AMOY]: {
113
+ environment: enums_1.BlockchainEnvironment.TESTNET,
114
+ chainId: BigInt(80002),
115
+ },
116
+ };
117
+ exports.BLOCKCHAIN_ID_TO_BLOCKCHAIN = {
118
+ [1]: enums_1.Blockchain.ETHEREUM,
119
+ [137]: enums_1.Blockchain.POLYGON,
120
+ [56]: enums_1.Blockchain.BINANCE,
121
+ [42161]: enums_1.Blockchain.ARBITRUM,
122
+ [42170]: enums_1.Blockchain.ARBITRUM_NOVA,
123
+ [10]: enums_1.Blockchain.OPTIMISM,
124
+ [9001]: enums_1.Blockchain.EVMOS,
125
+ [1284]: enums_1.Blockchain.MOONBEAM,
126
+ [8453]: enums_1.Blockchain.BASE,
127
+ [43114]: enums_1.Blockchain.AVALANCHE,
128
+ // testnets
129
+ [11155111]: enums_1.Blockchain.ETHEREUM_SEPOLIA,
130
+ [84532]: enums_1.Blockchain.BASE_SEPOLIA,
131
+ [17000]: enums_1.Blockchain.ETHEREUM_HOLESKY,
132
+ [421614]: enums_1.Blockchain.ARBITRUM_SEPOLIA,
133
+ [11155420]: enums_1.Blockchain.OPTIMISM_SEPOLIA,
134
+ [80002]: enums_1.Blockchain.POLYGON_AMOY,
135
+ [97]: enums_1.Blockchain.BINANCE_TESTNET,
136
+ [5611]: enums_1.Blockchain.OPBNB_TESTNET,
137
+ [1287]: enums_1.Blockchain.MOONBEAM_ALPHA,
138
+ };
139
+ exports.FIAT_CURRENCY = new currency_1.Currency(6, "USD", "US Dollar", undefined, false, false);
@@ -1,5 +1,5 @@
1
1
  import JSBI from "jsbi";
2
- import { Fraction, BigintIsh } from "@uniswap/sdk-core";
2
+ import { Fraction, BigintIsh, Rounding } from "@uniswap/sdk-core";
3
3
  import { Currency } from "./currency";
4
4
  export declare class CurrencyAmount extends Fraction {
5
5
  readonly currency: Currency;
@@ -28,4 +28,7 @@ export declare class CurrencyAmount extends Fraction {
28
28
  toRawAmount(): bigint;
29
29
  toCurrencyValue(price: CurrencyAmount): CurrencyAmount;
30
30
  fiatValue(): CurrencyAmount;
31
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
32
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
33
+ toExact(format?: object): string;
31
34
  }
@@ -8,6 +8,7 @@ const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
8
8
  const jsbi_1 = __importDefault(require("jsbi"));
9
9
  const sdk_core_1 = require("@uniswap/sdk-core");
10
10
  const currency_1 = require("./currency");
11
+ const constants_1 = require("../../constants");
11
12
  // This class is inspired by the Uniswap SDK's (@uniswap/sdk-core) CurrencyAmount class. Created this instance here
12
13
  // because we have a need to represent a currency amount that is not a fungible token amount.
13
14
  class CurrencyAmount extends sdk_core_1.Fraction {
@@ -77,5 +78,22 @@ class CurrencyAmount extends sdk_core_1.Fraction {
77
78
  fiatValue() {
78
79
  return this.amountInFiatCurrency;
79
80
  }
81
+ toSignificant(significantDigits = 6, format, rounding = sdk_core_1.Rounding.ROUND_DOWN) {
82
+ return super
83
+ .divide(this.decimalScale)
84
+ .toSignificant(significantDigits, format, rounding);
85
+ }
86
+ toFixed(decimalPlaces = this.currency.decimals, format, rounding = sdk_core_1.Rounding.ROUND_DOWN) {
87
+ (0, tiny_invariant_1.default)(decimalPlaces <= this.currency.decimals, "DECIMALS");
88
+ return super
89
+ .divide(this.decimalScale)
90
+ .toFixed(decimalPlaces, format, rounding);
91
+ }
92
+ toExact(format = { groupSeparator: "" }) {
93
+ constants_1.Big.DP = this.currency.decimals;
94
+ return new constants_1.Big(this.quotient.toString())
95
+ .div(this.decimalScale.toString())
96
+ .toFormat(format);
97
+ }
80
98
  }
81
99
  exports.CurrencyAmount = CurrencyAmount;
@@ -1,5 +1,5 @@
1
1
  import JSBI from "jsbi";
2
- import { Fraction, BigintIsh } from "@uniswap/sdk-core";
2
+ import { Fraction, BigintIsh, Rounding } from "@uniswap/sdk-core";
3
3
  import { FungibleToken } from "./fungible_token";
4
4
  import { CurrencyAmount } from "./currency_amount";
5
5
  export declare class FungibleTokenAmount extends Fraction {
@@ -30,4 +30,7 @@ export declare class FungibleTokenAmount extends Fraction {
30
30
  toRawAmount(): bigint;
31
31
  fiatValue(): CurrencyAmount;
32
32
  toCurrencyValue(price: CurrencyAmount): CurrencyAmount;
33
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
34
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
35
+ toExact(format?: object): string;
33
36
  }
@@ -9,6 +9,7 @@ const jsbi_1 = __importDefault(require("jsbi"));
9
9
  const sdk_core_1 = require("@uniswap/sdk-core");
10
10
  const fungible_token_1 = require("./fungible_token");
11
11
  const currency_amount_1 = require("./currency_amount");
12
+ const constants_1 = require("../../constants");
12
13
  // This class is inspired by the Uniswap SDK's (@uniswap/sdk-core) CurrencyAmount class. Created this instance here
13
14
  // because we have a need to represent a currency amount that is not a fungible token amount.
14
15
  class FungibleTokenAmount extends sdk_core_1.Fraction {
@@ -80,5 +81,22 @@ class FungibleTokenAmount extends sdk_core_1.Fraction {
80
81
  this.amountInFiatCurrency = currency_amount_1.CurrencyAmount.fromFractionalAmount(price.currency, fraction.numerator, denominator);
81
82
  return this.amountInFiatCurrency;
82
83
  }
84
+ toSignificant(significantDigits = 6, format, rounding = sdk_core_1.Rounding.ROUND_DOWN) {
85
+ return super
86
+ .divide(this.decimalScale)
87
+ .toSignificant(significantDigits, format, rounding);
88
+ }
89
+ toFixed(decimalPlaces = this.token.decimals, format, rounding = sdk_core_1.Rounding.ROUND_DOWN) {
90
+ (0, tiny_invariant_1.default)(decimalPlaces <= this.token.decimals, "DECIMALS");
91
+ return super
92
+ .divide(this.decimalScale)
93
+ .toFixed(decimalPlaces, format, rounding);
94
+ }
95
+ toExact(format = { groupSeparator: "" }) {
96
+ constants_1.Big.DP = this.token.decimals;
97
+ return new constants_1.Big(this.quotient.toString())
98
+ .div(this.decimalScale.toString())
99
+ .toFormat(format);
100
+ }
83
101
  }
84
102
  exports.FungibleTokenAmount = FungibleTokenAmount;
package/dist/index.d.ts CHANGED
@@ -24,6 +24,4 @@ export * from "./entities/state";
24
24
  export * from "./enums";
25
25
  export * from "./types";
26
26
  export * from "./constants";
27
- export * from "./constants";
28
- export * from "./enums";
29
- export * from "./types";
27
+ export * from "./utils/utils";
package/dist/index.js CHANGED
@@ -44,7 +44,4 @@ __exportStar(require("./entities/state"), exports);
44
44
  __exportStar(require("./enums"), exports);
45
45
  __exportStar(require("./types"), exports);
46
46
  __exportStar(require("./constants"), exports);
47
- // other
48
- __exportStar(require("./constants"), exports);
49
- __exportStar(require("./enums"), exports);
50
- __exportStar(require("./types"), exports);
47
+ __exportStar(require("./utils/utils"), exports);
@@ -17,6 +17,6 @@ export interface IAccountClusterActions {
17
17
  address?: string;
18
18
  }[]): Promise<Activity[]>;
19
19
  getPortfolioOverview(accountClusterId: string): Promise<FungibleTokenOverview>;
20
- getFungibleTokenPortfolio(accountClusterId: string): Promise<FungibleTokenOverview>;
20
+ getFungibleTokenPortfolio(accountClusterId: string): Promise<StandardizedBalance[]>;
21
21
  getFungibleTokenBalances(accountClusterId: string, offset?: number, limit?: number, tokensToOmit?: string[]): Promise<StandardizedBalance[]>;
22
22
  }
@@ -1,10 +1,10 @@
1
- import { Operation, OperationStatus, SignedOperation } from "../types";
1
+ import { OperationSet, OperationStatus, SignedOperation } from "../types";
2
2
  import { CurrencyAmount } from "../entities/financial/currency_amount";
3
3
  import { QuoteType } from "../enums";
4
4
  export interface IOperationActions {
5
- getOperationsToExecuteTransaction(accountClusterId: string, to: string, data: string, value?: string): Promise<Operation[]>;
6
- getOperationsToSignTypedData(accountClusterId: string, data: string): Promise<Operation[]>;
7
- getOperationsToCancelTransaction(accountClusterId: string, operationSetId: string): Promise<Operation[]>;
5
+ getOperationsToExecuteTransaction(accountClusterId: string, to: string, data: string, value?: bigint): Promise<OperationSet>;
6
+ getOperationsToSignTypedData(accountClusterId: string, data: string): Promise<OperationSet>;
7
+ getOperationsToCancelTransaction(accountClusterId: string, operationSetId: string): Promise<OperationSet>;
8
8
  isTransactionPreconditionSatisfied(accountClusterId: string, to: string, data: string, value?: string): Promise<boolean>;
9
9
  isTypedDataPreconditionSatisfied(accountClusterId: string, data: string): Promise<boolean>;
10
10
  sendSignedOperations(accountClusterId: string, signedOperations: SignedOperation[]): Promise<{
@@ -14,7 +14,7 @@ export interface IOperationActions {
14
14
  getOperationStatuses(operationIds: string[]): Promise<OperationStatus[]>;
15
15
  estimateFiatCostToExecuteTransaction(to: string, data: string, value?: string): Promise<CurrencyAmount>;
16
16
  estimateFiatCostToSignTypedData(data: string): Promise<CurrencyAmount>;
17
- getOperationsToTransferToken(accountClusterId: string, standardizedTokenId: string, amount: number, recipient: {
17
+ getOperationsToTransferToken(accountClusterId: string, standardizedTokenId: string, amount: bigint, recipient: {
18
18
  chainId: bigint;
19
19
  recipientAddress: string;
20
20
  }, gasToken?: {
@@ -23,17 +23,17 @@ export interface IOperationActions {
23
23
  chainId: bigint;
24
24
  address?: string;
25
25
  }[];
26
- }): Promise<Operation[]>;
26
+ }): Promise<OperationSet>;
27
27
  getOperationsToSwap(accountClusterId: string, swapType: QuoteType, input: {
28
28
  standardizedTokenId: string;
29
- amount?: number;
29
+ amount?: bigint;
30
30
  tokenSources?: {
31
31
  chainId: string;
32
32
  address?: string;
33
33
  }[];
34
34
  }, output: {
35
35
  standardizedTokenId: string;
36
- amount?: number;
36
+ amount?: bigint;
37
37
  tokenDestination?: {
38
38
  chainId: string;
39
39
  address?: string;
@@ -44,22 +44,22 @@ export interface IOperationActions {
44
44
  chainId: bigint;
45
45
  address?: string;
46
46
  }[];
47
- }): Promise<Operation[]>;
47
+ }): Promise<OperationSet>;
48
48
  getQuote(accountClusterId: string, swapType: QuoteType, input: {
49
49
  standardizedTokenId: string;
50
- amount?: number;
50
+ amount?: bigint;
51
51
  tokenSources?: {
52
52
  chainId: string;
53
53
  address?: string;
54
54
  }[];
55
55
  }, output: {
56
56
  standardizedTokenId: string;
57
- amount?: number;
57
+ amount?: bigint;
58
58
  tokenDestination?: {
59
59
  chainId: string;
60
60
  address?: string;
61
61
  };
62
- }): Promise<Operation[]>;
62
+ }): Promise<OperationSet>;
63
63
  getOperationsToBridge(accountClusterId: string, standardizedTokenId: string, amount: bigint, tokenSources?: {
64
64
  chainId: string;
65
65
  address?: string;
@@ -72,5 +72,5 @@ export interface IOperationActions {
72
72
  chainId: bigint;
73
73
  address?: string;
74
74
  }[];
75
- }): Promise<Operation[]>;
75
+ }): Promise<OperationSet>;
76
76
  }
package/dist/types.d.ts CHANGED
@@ -14,7 +14,7 @@ export type ChainEndpoint = {
14
14
  customRpcUrls?: string[];
15
15
  customIndexerUrls?: string[];
16
16
  };
17
- export interface Operation {
17
+ export interface OperationSet {
18
18
  status: CreateOperationsStatus;
19
19
  primaryOperation?: OnchainOperation;
20
20
  primaryOperationPreconditions?: State;
@@ -37,7 +37,7 @@ export interface OnchainOperation {
37
37
  data: string;
38
38
  estimatedNetworkFees?: CurrencyAmount;
39
39
  estimatedNetworkFeesInFiatCurrency?: CurrencyAmount;
40
- estimatedTimeInMs?: bigint;
40
+ estimatedTimeInMs?: number;
41
41
  format: OperationDataFormat;
42
42
  from?: string;
43
43
  gasLimit?: bigint;
@@ -141,3 +141,7 @@ export type GasSponsorshipData = {
141
141
  totalGasSpent: CurrencyAmount;
142
142
  totalTransactionCount: bigint;
143
143
  };
144
+ export type ChainConfigs = {
145
+ environment: BlockchainEnvironment;
146
+ chainId: bigint;
147
+ };
@@ -0,0 +1,22 @@
1
+ import { AccountCluster, Activity, AllowlistWithOpenFallback, BlockchainInformation, FungibleTokenOverview, GasSpendForInstance, GasSponsorshipData, GasSponsorshipPolicy, Intent, MaxAmountPerInterval, OnchainOperation, OperationSet, OperationStatus, StandardizedBalance, StandardizedToken } from "../types";
2
+ export declare const extractAccountCluster: (accountCluster?: any) => AccountCluster;
3
+ export declare const extractOperationSet: (operationSet?: any) => OperationSet;
4
+ export declare const extractOnchainOperation: (onchainOperation?: any) => OnchainOperation;
5
+ export declare const extractIntent: (intent?: any) => Intent;
6
+ export declare const extractOperationStatuses: (operationStatus?: any[]) => OperationStatus[];
7
+ export declare const extractOperationStatus: (status?: any) => OperationStatus;
8
+ export declare const extractActivities: (activities?: any[]) => Activity[];
9
+ export declare const extractFungibleTokenOverview: (overview?: any) => FungibleTokenOverview;
10
+ export declare const extractStandardizedBalances: (balances?: any) => StandardizedBalance[];
11
+ export declare const extractStandardizedBalance: (balance?: any) => StandardizedBalance;
12
+ export declare const extractStandardizedTokens: (tokens?: any) => StandardizedToken[];
13
+ export declare const extractStandardizedToken: (token?: any) => StandardizedToken;
14
+ export declare const extractBlockchainInformations: (blockchainInformation?: any[]) => BlockchainInformation[];
15
+ export declare const extractBlockchainInformation: (blockchainInformation?: any) => BlockchainInformation;
16
+ export declare const extractMaxAmountPerInterval: (maxAmountPerInterval?: any) => MaxAmountPerInterval;
17
+ export declare const extractAllowlistWithOpenFallback: (allowlist?: any) => AllowlistWithOpenFallback;
18
+ export declare const extractGasSponsorshipPolicy: (gasSponsorshipPolicy?: any) => GasSponsorshipPolicy;
19
+ export declare const extractGasSpendForInstances: (gasSpendForInstances?: any[]) => GasSpendForInstance[];
20
+ export declare const extractGasSpendForInstance: (gasSpendForInstance?: any) => GasSpendForInstance;
21
+ export declare const extractGasSponsorshipInformation: (gasSponsorshipData?: any[]) => GasSponsorshipData[];
22
+ export declare const extractGasSponsorshipData: (gasSponsorshipData?: any) => GasSponsorshipData;