@orb-labs/orby-core 0.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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/actions/account_cluster.d.ts +24 -0
  4. package/dist/actions/account_cluster.js +147 -0
  5. package/dist/actions/admin.d.ts +17 -0
  6. package/dist/actions/admin.js +42 -0
  7. package/dist/actions/application.d.ts +6 -0
  8. package/dist/actions/application.js +25 -0
  9. package/dist/actions/instance.d.ts +16 -0
  10. package/dist/actions/instance.js +94 -0
  11. package/dist/actions/operation.d.ts +78 -0
  12. package/dist/actions/operation.js +113 -0
  13. package/dist/actions/token.d.ts +15 -0
  14. package/dist/actions/token.js +46 -0
  15. package/dist/constants.d.ts +4 -0
  16. package/dist/constants.js +36 -0
  17. package/dist/entities/account.d.ts +14 -0
  18. package/dist/entities/account.js +52 -0
  19. package/dist/entities/financial/account_balance.d.ts +12 -0
  20. package/dist/entities/financial/account_balance.js +35 -0
  21. package/dist/entities/financial/asset.d.ts +31 -0
  22. package/dist/entities/financial/asset.js +42 -0
  23. package/dist/entities/financial/currency.d.ts +41 -0
  24. package/dist/entities/financial/currency.js +56 -0
  25. package/dist/entities/financial/currency_amount.d.ts +31 -0
  26. package/dist/entities/financial/currency_amount.js +81 -0
  27. package/dist/entities/financial/fungible_token.d.ts +41 -0
  28. package/dist/entities/financial/fungible_token.js +70 -0
  29. package/dist/entities/financial/fungible_token_amount.d.ts +33 -0
  30. package/dist/entities/financial/fungible_token_amount.js +84 -0
  31. package/dist/entities/financial/non_fungible_token.d.ts +39 -0
  32. package/dist/entities/financial/non_fungible_token.js +66 -0
  33. package/dist/entities/financial/semi_fungible_token.d.ts +41 -0
  34. package/dist/entities/financial/semi_fungible_token.js +68 -0
  35. package/dist/entities/library_request.d.ts +8 -0
  36. package/dist/entities/library_request.js +37 -0
  37. package/dist/entities/state.d.ts +22 -0
  38. package/dist/entities/state.js +105 -0
  39. package/dist/enums.d.ts +115 -0
  40. package/dist/enums.js +137 -0
  41. package/dist/index.d.ts +26 -0
  42. package/dist/index.js +47 -0
  43. package/dist/interfaces/account_cluster.d.ts +22 -0
  44. package/dist/interfaces/account_cluster.js +2 -0
  45. package/dist/interfaces/admin.d.ts +14 -0
  46. package/dist/interfaces/admin.js +2 -0
  47. package/dist/interfaces/application.d.ts +3 -0
  48. package/dist/interfaces/application.js +2 -0
  49. package/dist/interfaces/instance.d.ts +13 -0
  50. package/dist/interfaces/instance.js +2 -0
  51. package/dist/interfaces/operation.d.ts +76 -0
  52. package/dist/interfaces/operation.js +2 -0
  53. package/dist/interfaces/orby.d.ts +8 -0
  54. package/dist/interfaces/orby.js +2 -0
  55. package/dist/interfaces/token.d.ts +12 -0
  56. package/dist/interfaces/token.js +2 -0
  57. package/dist/types.d.ts +143 -0
  58. package/dist/types.js +2 -0
  59. package/dist/utils/utils.d.ts +26 -0
  60. package/dist/utils/utils.js +319 -0
  61. package/dist/utils/validateAndParseAddress.d.ts +10 -0
  62. package/dist/utils/validateAndParseAddress.js +29 -0
  63. package/package.json +25 -0
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FungibleTokenAmount = void 0;
7
+ const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
8
+ const jsbi_1 = __importDefault(require("jsbi"));
9
+ const sdk_core_1 = require("@uniswap/sdk-core");
10
+ const fungible_token_1 = require("./fungible_token");
11
+ const currency_amount_1 = require("./currency_amount");
12
+ // This class is inspired by the Uniswap SDK's (@uniswap/sdk-core) CurrencyAmount class. Created this instance here
13
+ // because we have a need to represent a currency amount that is not a fungible token amount.
14
+ class FungibleTokenAmount extends sdk_core_1.Fraction {
15
+ /**
16
+ * Returns a new fungibleToken amount instance from the unitless amount of token, i.e. the raw amount
17
+ * @param fungibleToken the fungibleToken in the amount
18
+ * @param rawAmount the raw token or ether amount
19
+ */
20
+ static fromRawAmount(fungibleToken, rawAmount, amountInFiatCurrency) {
21
+ return new FungibleTokenAmount(fungibleToken, rawAmount, undefined, amountInFiatCurrency);
22
+ }
23
+ /**
24
+ * Construct a fungibleToken amount with a denominator that is not equal to 1
25
+ * @param fungibleToken the fungibleToken
26
+ * @param numerator the numerator of the fractional token amount
27
+ * @param denominator the denominator of the fractional token amount
28
+ */
29
+ static fromFractionalAmount(fungibleToken, numerator, denominator, amountInFiatCurrency) {
30
+ return new FungibleTokenAmount(fungibleToken, numerator, denominator, amountInFiatCurrency);
31
+ }
32
+ static toFungibleTokenAmount(amount) {
33
+ if (!amount) {
34
+ return undefined;
35
+ }
36
+ const amountInFiatCurrency = currency_amount_1.CurrencyAmount.toCurrencyAmount(amount.amountInFiatCurrency);
37
+ return FungibleTokenAmount.fromRawAmount(fungible_token_1.FungibleToken.toFungibleToken(amount.token), amount.value, amountInFiatCurrency);
38
+ }
39
+ constructor(fungibleToken, numerator, denominator, amountInFiatCurrency) {
40
+ super(numerator.toString(), denominator === null || denominator === void 0 ? void 0 : denominator.toString());
41
+ (0, tiny_invariant_1.default)(jsbi_1.default.lessThanOrEqual(this.quotient, sdk_core_1.MaxUint256), "AMOUNT");
42
+ this.token = fungibleToken;
43
+ this.decimalScale = jsbi_1.default.exponentiate(jsbi_1.default.BigInt(10), jsbi_1.default.BigInt(fungibleToken.decimals));
44
+ this.amountInFiatCurrency = amountInFiatCurrency;
45
+ }
46
+ equals(other) {
47
+ return (this.token.equals(other.token) &&
48
+ this.toRawAmount() == other.toRawAmount());
49
+ }
50
+ add(other) {
51
+ (0, tiny_invariant_1.default)(this.token.equals(other.token), "FUNGIBLE_TOKEN");
52
+ const added = super.add(other);
53
+ return FungibleTokenAmount.fromFractionalAmount(this.token, added.numerator, added.denominator);
54
+ }
55
+ subtract(other) {
56
+ (0, tiny_invariant_1.default)(this.token.equals(other.token), "FUNGIBLE_TOKEN");
57
+ const subtracted = super.subtract(other);
58
+ return FungibleTokenAmount.fromFractionalAmount(this.token, subtracted.numerator, subtracted.denominator);
59
+ }
60
+ multiply(other) {
61
+ const multiplied = super.multiply(other);
62
+ return FungibleTokenAmount.fromFractionalAmount(this.token, multiplied.numerator, multiplied.denominator);
63
+ }
64
+ divide(other) {
65
+ const divided = super.divide(other);
66
+ return FungibleTokenAmount.fromFractionalAmount(this.token, divided.numerator, divided.denominator);
67
+ }
68
+ greaterThanOrEqual(other) {
69
+ return this.greaterThan(other) || this.equals(other);
70
+ }
71
+ toRawAmount() {
72
+ return BigInt(this.quotient.toString());
73
+ }
74
+ fiatValue() {
75
+ return this.amountInFiatCurrency;
76
+ }
77
+ toCurrencyValue(price) {
78
+ const fraction = price.multiply(this);
79
+ const denominator = jsbi_1.default.multiply(fraction.denominator, this.decimalScale);
80
+ this.amountInFiatCurrency = currency_amount_1.CurrencyAmount.fromFractionalAmount(price.currency, fraction.numerator, denominator);
81
+ return this.amountInFiatCurrency;
82
+ }
83
+ }
84
+ exports.FungibleTokenAmount = FungibleTokenAmount;
@@ -0,0 +1,39 @@
1
+ import { Asset } from "./asset";
2
+ import { TokenType } from "../../enums";
3
+ /**
4
+ * Represents an ERC721 token with a unique address and some metadata.
5
+ */
6
+ export declare class NonFungibleToken extends Asset {
7
+ readonly isNative: false;
8
+ readonly isToken: true;
9
+ /**
10
+ * The contract address on the chain on which this token lives
11
+ */
12
+ readonly address: string;
13
+ /**
14
+ * The chain ID on which this token resides
15
+ */
16
+ readonly chainId: bigint;
17
+ readonly url?: string;
18
+ /**
19
+ * @param chainId The chain ID on which this token resides
20
+ * @param address The contract address on the chain on which this token lives
21
+ * @param symbol {@link Currency#symbol}
22
+ * @param name {@link Currency#name}
23
+ * @param url The URL of the token's metadata
24
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
25
+ */
26
+ constructor(chainId: bigint, address: string, symbol: string, name: string, url?: string, bypassChecksum?: boolean, coinGeckoId?: string);
27
+ static toNonFungibleToken(nft?: any): NonFungibleToken;
28
+ /**
29
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
30
+ * @param other other token to compare
31
+ */
32
+ equals(other: NonFungibleToken): boolean;
33
+ /**
34
+ * Returns the asset representation of this currency
35
+ */
36
+ asset(): Asset;
37
+ type(): TokenType;
38
+ identifier(): string;
39
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NonFungibleToken = void 0;
4
+ const asset_1 = require("./asset");
5
+ const validateAndParseAddress_1 = require("../../utils/validateAndParseAddress");
6
+ const enums_1 = require("../../enums");
7
+ /**
8
+ * Represents an ERC721 token with a unique address and some metadata.
9
+ */
10
+ class NonFungibleToken extends asset_1.Asset {
11
+ /**
12
+ * @param chainId The chain ID on which this token resides
13
+ * @param address The contract address on the chain on which this token lives
14
+ * @param symbol {@link Currency#symbol}
15
+ * @param name {@link Currency#name}
16
+ * @param url The URL of the token's metadata
17
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
18
+ */
19
+ constructor(chainId, address, symbol, name, url, bypassChecksum, coinGeckoId) {
20
+ // TODO(felix): add this back
21
+ // invariant(!_.isUndefined(getBlockchainFromBlockchainId(chainId)), "CHAIN_ID");
22
+ var _a, _b;
23
+ super(symbol, name, coinGeckoId);
24
+ this.isNative = false;
25
+ this.isToken = true;
26
+ if (bypassChecksum) {
27
+ this.address = (_a = (0, validateAndParseAddress_1.checkValidAddress)(address)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
28
+ }
29
+ else {
30
+ this.address = (_b = (0, validateAndParseAddress_1.validateAndParseAddress)(address)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
31
+ }
32
+ this.chainId = chainId;
33
+ this.url = url;
34
+ }
35
+ static toNonFungibleToken(nft) {
36
+ if (!nft) {
37
+ return undefined;
38
+ }
39
+ const asset = asset_1.Asset.toAsset(nft.asset);
40
+ return new NonFungibleToken(nft.chainId, nft.address, asset.symbol, asset.name, nft.url);
41
+ }
42
+ /**
43
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
44
+ * @param other other token to compare
45
+ */
46
+ equals(other) {
47
+ // short circuit on reference equality
48
+ if (this === other)
49
+ return true;
50
+ return (this.chainId === other.chainId &&
51
+ this.address === other.address.toLowerCase());
52
+ }
53
+ /**
54
+ * Returns the asset representation of this currency
55
+ */
56
+ asset() {
57
+ return this;
58
+ }
59
+ type() {
60
+ return enums_1.TokenType.NON_FUNGIBLE_TOKEN;
61
+ }
62
+ identifier() {
63
+ return `${this.chainId}+${this.address.toLowerCase()}`;
64
+ }
65
+ }
66
+ exports.NonFungibleToken = NonFungibleToken;
@@ -0,0 +1,41 @@
1
+ import { Currency } from "./currency";
2
+ import { TokenType } from "../../enums";
3
+ /**
4
+ * Represents an ERC1155 token with a unique address and some metadata.
5
+ */
6
+ export declare class SemiFungibleToken extends Currency {
7
+ readonly isNative: false;
8
+ readonly isToken: true;
9
+ /**
10
+ * The contract address on the chain on which this token lives
11
+ */
12
+ readonly address: string;
13
+ /**
14
+ * The chain ID on which this token resides
15
+ */
16
+ readonly chainId: bigint;
17
+ readonly url?: string;
18
+ /**
19
+ *
20
+ * @param chainId The chain ID on which this token resides
21
+ * @param address The contract address on the chain on which this token lives
22
+ * @param decimals {@link Currency#decimals}
23
+ * @param symbol {@link Currency#symbol}
24
+ * @param name {@link Currency#name}
25
+ * @param url The URL of the token's metadata
26
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
27
+ */
28
+ constructor(chainId: bigint, address: string, decimals: number, symbol: string, name: string, url?: string, bypassChecksum?: boolean, coinGeckoId?: string);
29
+ static toSemiFungibleToken(sft?: any): SemiFungibleToken;
30
+ /**
31
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
32
+ * @param other other token to compare
33
+ */
34
+ equals(other: SemiFungibleToken): boolean;
35
+ /**
36
+ * Returns the currency object that this token represents
37
+ */
38
+ currency(): Currency;
39
+ type(): TokenType;
40
+ identifier(): string;
41
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SemiFungibleToken = void 0;
4
+ const currency_1 = require("./currency");
5
+ const validateAndParseAddress_1 = require("../../utils/validateAndParseAddress");
6
+ const enums_1 = require("../../enums");
7
+ /**
8
+ * Represents an ERC1155 token with a unique address and some metadata.
9
+ */
10
+ class SemiFungibleToken extends currency_1.Currency {
11
+ /**
12
+ *
13
+ * @param chainId The chain ID on which this token resides
14
+ * @param address The contract address on the chain on which this token lives
15
+ * @param decimals {@link Currency#decimals}
16
+ * @param symbol {@link Currency#symbol}
17
+ * @param name {@link Currency#name}
18
+ * @param url The URL of the token's metadata
19
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
20
+ */
21
+ constructor(chainId, address, decimals, symbol, name, url, bypassChecksum, coinGeckoId) {
22
+ // TODO(felix): add this back
23
+ // invariant(!_.isUndefined(getBlockchainFromBlockchainId(chainId)), "CHAIN_ID");
24
+ var _a, _b;
25
+ super(decimals, symbol, name, url, false, true, coinGeckoId);
26
+ this.isNative = false;
27
+ this.isToken = true;
28
+ if (bypassChecksum) {
29
+ this.address = (_a = (0, validateAndParseAddress_1.checkValidAddress)(address)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
30
+ }
31
+ else {
32
+ this.address = (_b = (0, validateAndParseAddress_1.validateAndParseAddress)(address)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
33
+ }
34
+ this.chainId = chainId;
35
+ this.url = url;
36
+ }
37
+ static toSemiFungibleToken(sft) {
38
+ if (!sft) {
39
+ return undefined;
40
+ }
41
+ const currency = currency_1.Currency.toCurrency(sft.currency);
42
+ return new SemiFungibleToken(sft.chainId, sft.address, currency.decimals, currency.symbol, currency.name, sft.url);
43
+ }
44
+ /**
45
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
46
+ * @param other other token to compare
47
+ */
48
+ equals(other) {
49
+ // short circuit on reference equality
50
+ if (this === other)
51
+ return true;
52
+ return (this.chainId === other.chainId &&
53
+ this.address === other.address.toLowerCase());
54
+ }
55
+ /**
56
+ * Returns the currency object that this token represents
57
+ */
58
+ currency() {
59
+ return this;
60
+ }
61
+ type() {
62
+ return enums_1.TokenType.SEMI_FUNGIBLE_TOKEN;
63
+ }
64
+ identifier() {
65
+ return `${this.chainId}+${this.address.toLowerCase()}`;
66
+ }
67
+ }
68
+ exports.SemiFungibleToken = SemiFungibleToken;
@@ -0,0 +1,8 @@
1
+ import { LIBRARY_TYPE } from "../enums";
2
+ export declare class LibraryRequest {
3
+ readonly library: LIBRARY_TYPE;
4
+ readonly client?: any;
5
+ readonly provider?: any;
6
+ constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
7
+ sendRequest(method: string, params: any[]): Promise<any>;
8
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LibraryRequest = void 0;
7
+ const enums_1 = require("../enums");
8
+ const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
9
+ class LibraryRequest {
10
+ constructor(library, client, provider) {
11
+ if (library == enums_1.LIBRARY_TYPE.VIEM) {
12
+ (0, tiny_invariant_1.default)(client, "CLIENT");
13
+ (0, tiny_invariant_1.default)(!provider, "PROVIDER");
14
+ this.client = client;
15
+ }
16
+ else if (library == enums_1.LIBRARY_TYPE.ETHERS) {
17
+ (0, tiny_invariant_1.default)(provider, "PROVIDER");
18
+ (0, tiny_invariant_1.default)(!client, "CLIENT");
19
+ this.provider = provider;
20
+ }
21
+ else {
22
+ (0, tiny_invariant_1.default)(false, "LIBRARY");
23
+ }
24
+ this.library = library;
25
+ this.client = client;
26
+ this.provider = provider;
27
+ }
28
+ sendRequest(method, params) {
29
+ if (this.library == enums_1.LIBRARY_TYPE.VIEM) {
30
+ return this.client.request({ method, params });
31
+ }
32
+ else if (this.library == enums_1.LIBRARY_TYPE.ETHERS) {
33
+ return this.provider.send(method, params);
34
+ }
35
+ }
36
+ }
37
+ exports.LibraryRequest = LibraryRequest;
@@ -0,0 +1,22 @@
1
+ import { FungibleToken } from "./financial/fungible_token";
2
+ import { FungibleTokenAmount } from "./financial/fungible_token_amount";
3
+ import { NonFungibleToken } from "./financial/non_fungible_token";
4
+ import { SemiFungibleToken } from "./financial/semi_fungible_token";
5
+ export declare class State {
6
+ private readonly fungibleTokens;
7
+ private readonly nonFungibleTokens;
8
+ private readonly semiFungibleTokens;
9
+ constructor(fungibleTokens: FungibleTokenAmount[], nonFungibleTokens: NonFungibleToken[], semiFungibleTokens: SemiFungibleToken[]);
10
+ static fromFungibleTokenAmounts(fungibleTokenAmounts: FungibleTokenAmount[]): State;
11
+ static fromTokenAndAmount(token?: FungibleToken, amount?: bigint): State;
12
+ getFungibleTokens(): FungibleTokenAmount[];
13
+ getNonFungibleTokens(): NonFungibleToken[];
14
+ getSemiFungibleTokens(): SemiFungibleToken[];
15
+ addTokens(fungibleTokens: FungibleTokenAmount[]): State;
16
+ addState(other: State): State;
17
+ deductState(other: State): State;
18
+ equals(other?: State): boolean;
19
+ addStates(states: State[]): State;
20
+ static mergeStates(states: State[]): State;
21
+ static toState(state: any): State;
22
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.State = void 0;
4
+ const fungible_token_amount_1 = require("./financial/fungible_token_amount");
5
+ const non_fungible_token_1 = require("./financial/non_fungible_token");
6
+ const semi_fungible_token_1 = require("./financial/semi_fungible_token");
7
+ class State {
8
+ constructor(fungibleTokens, nonFungibleTokens, semiFungibleTokens) {
9
+ this.fungibleTokens = fungibleTokens.reduce((acc, amount) => {
10
+ acc.set(amount.token.identifier(), amount);
11
+ return acc;
12
+ }, new Map());
13
+ this.nonFungibleTokens = nonFungibleTokens.reduce((acc, token) => {
14
+ acc.set(token.identifier(), token);
15
+ return acc;
16
+ }, new Map());
17
+ this.semiFungibleTokens = semiFungibleTokens.reduce((acc, token) => {
18
+ acc.set(token.identifier(), token);
19
+ return acc;
20
+ }, new Map());
21
+ }
22
+ static fromFungibleTokenAmounts(fungibleTokenAmounts) {
23
+ return new State(fungibleTokenAmounts, [], []);
24
+ }
25
+ static fromTokenAndAmount(token, amount) {
26
+ if (!token || !amount) {
27
+ return undefined;
28
+ }
29
+ const fungibleTokenAmount = fungible_token_amount_1.FungibleTokenAmount.fromRawAmount(token, amount);
30
+ return State.fromFungibleTokenAmounts([fungibleTokenAmount]);
31
+ }
32
+ getFungibleTokens() {
33
+ return Array.from(this.fungibleTokens.values());
34
+ }
35
+ getNonFungibleTokens() {
36
+ return Array.from(this.nonFungibleTokens.values());
37
+ }
38
+ getSemiFungibleTokens() {
39
+ return Array.from(this.semiFungibleTokens.values());
40
+ }
41
+ addTokens(fungibleTokens) {
42
+ fungibleTokens.forEach((amount) => {
43
+ const identifier = amount.token.identifier();
44
+ const currentAmount = this.fungibleTokens.get(identifier);
45
+ if (currentAmount) {
46
+ this.fungibleTokens.set(identifier, currentAmount.add(amount));
47
+ }
48
+ else {
49
+ this.fungibleTokens.set(identifier, amount);
50
+ }
51
+ });
52
+ return this;
53
+ }
54
+ addState(other) {
55
+ var _a;
56
+ (_a = other === null || other === void 0 ? void 0 : other.fungibleTokens) === null || _a === void 0 ? void 0 : _a.forEach((amount) => {
57
+ const identifier = amount.token.identifier();
58
+ const currentAmount = this.fungibleTokens.get(identifier);
59
+ if (currentAmount) {
60
+ this.fungibleTokens.set(identifier, currentAmount.add(amount));
61
+ }
62
+ else {
63
+ this.fungibleTokens.set(identifier, amount);
64
+ }
65
+ });
66
+ return this;
67
+ }
68
+ deductState(other) {
69
+ other.fungibleTokens.forEach((amount) => {
70
+ const identifier = amount.token.identifier();
71
+ const currentAmount = this.fungibleTokens.get(identifier);
72
+ if ((currentAmount === null || currentAmount === void 0 ? void 0 : currentAmount.toRawAmount()) > (amount === null || amount === void 0 ? void 0 : amount.toRawAmount())) {
73
+ this.fungibleTokens.set(identifier, currentAmount.subtract(amount));
74
+ }
75
+ else if (currentAmount) {
76
+ this.fungibleTokens.delete(identifier);
77
+ }
78
+ });
79
+ return this;
80
+ }
81
+ equals(other) {
82
+ if (!other) {
83
+ return false;
84
+ }
85
+ return (this.fungibleTokens.size == other.fungibleTokens.size &&
86
+ Array.from(this.fungibleTokens.entries()).every(([key, value]) => {
87
+ const otherValue = other.fungibleTokens.get(key);
88
+ return otherValue && value.equals(otherValue);
89
+ }));
90
+ }
91
+ addStates(states) {
92
+ states.forEach((state) => this.addState(state));
93
+ return this;
94
+ }
95
+ static mergeStates(states) {
96
+ return states.reduce((acc, state) => acc.addState(state), new State([], [], []));
97
+ }
98
+ static toState(state) {
99
+ const fungibleTokenAmounts = state.fungibleTokenAmounts.map((ft) => fungible_token_amount_1.FungibleTokenAmount.toFungibleTokenAmount(ft));
100
+ const nonFungibleTokenAmounts = state.nonFungibleTokenAmounts.map((nft) => non_fungible_token_1.NonFungibleToken.toNonFungibleToken(nft));
101
+ const semiFungibleTokenAmounts = state.semiFungibleTokenAmounts.map((sft) => semi_fungible_token_1.SemiFungibleToken.toSemiFungibleToken(sft));
102
+ return new State(fungibleTokenAmounts, nonFungibleTokenAmounts, semiFungibleTokenAmounts);
103
+ }
104
+ }
105
+ exports.State = State;
@@ -0,0 +1,115 @@
1
+ export declare enum Blockchain {
2
+ ETHEREUM = "ethereum",
3
+ POLYGON = "polygon",
4
+ BINANCE = "binance",
5
+ ARBITRUM = "arbitrum",
6
+ BASE = "base",
7
+ AVALANCHE = "avalanche",
8
+ ARBITRUM_NOVA = "arbitrum_nova",
9
+ OPTIMISM = "optimism",
10
+ EVMOS = "evmos",
11
+ MOONBEAM = "moonbeam",
12
+ ETHEREUM_SEPOLIA = "ethereum_sepolia",
13
+ ETHEREUM_HOLESKY = "ethereum_holesky",
14
+ BASE_SEPOLIA = "base_sepolia",
15
+ ARBITRUM_SEPOLIA = "arbitrum_sepolia",
16
+ OPTIMISM_SEPOLIA = "optimism_sepolia",
17
+ POLYGON_AMOY = "polygon_amoy",
18
+ BINANCE_TESTNET = "binance_testnet",
19
+ OPBNB_TESTNET = "opbnb_testnet",
20
+ MOONBEAM_ALPHA = "moonbeam_alpha",
21
+ HARDHAT = "hardhat",
22
+ LOCAL_CHAIN_0 = "local_chain_0",
23
+ LOCAL_CHAIN_1 = "local_chain_1"
24
+ }
25
+ export declare enum TokenType {
26
+ FUNGIBLE_TOKEN = "FUNGIBLE_TOKEN",
27
+ NON_FUNGIBLE_TOKEN = "NON_FUNGIBLE_TOKEN",
28
+ SEMI_FUNGIBLE_TOKEN = "SEMI_FUNGIBLE_TOKEN",
29
+ FIAT = "FIAT"
30
+ }
31
+ export declare enum AccountType {
32
+ EOA = "EOA",
33
+ SCA = "SCA"
34
+ }
35
+ export declare enum VMType {
36
+ EVM = "EVM"
37
+ }
38
+ export declare enum ChainSupportStatus {
39
+ CHAIN_SUPPORTED = "CHAIN_SUPPORTED",
40
+ CHAIN_UNAVAILABLE = "CHAIN_UNAVAILABLE",
41
+ ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE"
42
+ }
43
+ export declare enum CreateOperationsStatus {
44
+ INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
45
+ INTERNAL = "INTERNAL",
46
+ INVALID_ARGUMENT = "INVALID_ARGUMENT",
47
+ NO_EXECUTION_PATH = "NO_EXECUTION_PATH",
48
+ SUCCESS = "SUCCESS"
49
+ }
50
+ export declare enum OperationDataFormat {
51
+ TRANSACTION = "TRANSACTION",
52
+ TYPED_DATA = "TYPED_DATA"
53
+ }
54
+ export declare enum OperationType {
55
+ APPROVE_ERC20_TOKEN = "APPROVE_ERC20_TOKEN",
56
+ CANCEL_OPERATION = "CANCEL_OPERATION",
57
+ CANCEL_TRANSACTION = "CANCEL_TRANSACTION",
58
+ FINAL_TRANSACTION = "FINAL_TRANSACTION",
59
+ GAS_ABSTRACTION = "GAS_ABSTRACTION",
60
+ NATIVE_TOKEN_TRANSFER = "NATIVE_TOKEN_TRANSFER",
61
+ SUBMIT_INTENT = "SUBMIT_INTENT"
62
+ }
63
+ export declare enum Category {
64
+ SEND = "SEND",
65
+ RECEIVE = "RECEIVE",
66
+ SWAP = "SWAP",
67
+ REBALANCE = "REBALANCE",
68
+ BRIDGE = "BRIDGE",
69
+ FUNCTION_CALL = "FUNCTION_CALL",
70
+ TYPED_DATA_SIGNATURE = "TYPED_DATA_SIGNATURE"
71
+ }
72
+ export declare enum OperationStatusType {
73
+ FAILED = "FAILED",
74
+ NOT_FOUND = "NOT_FOUND",
75
+ PENDING = "PENDING",
76
+ SUCCESSFUL = "SUCCESSFUL",
77
+ WAITING_PRECONDITION = "WAITING_PRECONDITION"
78
+ }
79
+ export declare enum QuoteType {
80
+ EXACT_INPUT = "EXACT_INPUT",
81
+ EXACT_OUTPUT = "EXACT_OUTPUT"
82
+ }
83
+ export declare enum Order {
84
+ NEWEST = "NEWEST",
85
+ OLDEST = "OLDEST"
86
+ }
87
+ export declare enum ActivityStatus {
88
+ CANCELLED = "CANCELLED",
89
+ FAILED = "FAILED",
90
+ PENDING = "PENDING",
91
+ SUCCESS = "SUCCESS"
92
+ }
93
+ export declare enum BlockchainEnvironment {
94
+ MAINNET = "MAINNET",
95
+ TESTNET = "TESTNET"
96
+ }
97
+ export declare enum TokenAllowlistType {
98
+ ALL_TOKENS = "ALL_TOKENS",
99
+ ONLY_FUNGIBLE_TOKENS = "ONLY_FUNGIBLE_TOKENS",
100
+ ONLY_NON_FUNGIBLE_TOKENS = "ONLY_NON_FUNGIBLE_TOKENS",
101
+ ONLY_SEMI_FUNGIBLE_TOKENS = "ONLY_SEMI_FUNGIBLE_TOKENS"
102
+ }
103
+ export declare enum TimeIntervalUnits {
104
+ DAYS = "DAYS",
105
+ FOREVER = "FOREVER",
106
+ HOURS = "HOURS",
107
+ MINUTES = "MINUTES",
108
+ MONTHS = "MONTHS",
109
+ WEEKS = "WEEKS",
110
+ YEARS = "YEARS"
111
+ }
112
+ export declare enum LIBRARY_TYPE {
113
+ VIEM = "VIEM",
114
+ ETHERS = "ETHERS"
115
+ }