@orb-labs/orby-core 0.0.5 → 0.0.7

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 (54) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/actions/account_cluster.d.ts +5 -5
  3. package/dist/actions/account_cluster.js +147 -330
  4. package/dist/actions/admin.d.ts +3 -3
  5. package/dist/actions/admin.js +37 -127
  6. package/dist/actions/application.d.ts +2 -2
  7. package/dist/actions/application.js +14 -77
  8. package/dist/actions/instance.d.ts +3 -3
  9. package/dist/actions/instance.js +98 -255
  10. package/dist/actions/operation.d.ts +4 -4
  11. package/dist/actions/operation.js +92 -263
  12. package/dist/actions/token.d.ts +3 -3
  13. package/dist/actions/token.js +34 -119
  14. package/dist/constants.d.ts +3 -3
  15. package/dist/constants.js +70 -71
  16. package/dist/entities/account.d.ts +1 -1
  17. package/dist/entities/account.js +25 -30
  18. package/dist/entities/financial/account_balance.d.ts +2 -2
  19. package/dist/entities/financial/account_balance.js +20 -22
  20. package/dist/entities/financial/asset.js +13 -15
  21. package/dist/entities/financial/currency.d.ts +1 -1
  22. package/dist/entities/financial/currency.js +16 -35
  23. package/dist/entities/financial/currency_amount.d.ts +1 -1
  24. package/dist/entities/financial/currency_amount.js +49 -71
  25. package/dist/entities/financial/fungible_token.d.ts +2 -2
  26. package/dist/entities/financial/fungible_token.js +31 -52
  27. package/dist/entities/financial/fungible_token_amount.d.ts +2 -2
  28. package/dist/entities/financial/fungible_token_amount.js +53 -75
  29. package/dist/entities/financial/non_fungible_token.d.ts +2 -2
  30. package/dist/entities/financial/non_fungible_token.js +25 -45
  31. package/dist/entities/financial/semi_fungible_token.d.ts +2 -2
  32. package/dist/entities/financial/semi_fungible_token.js +25 -45
  33. package/dist/entities/library_request.d.ts +1 -1
  34. package/dist/entities/library_request.js +7 -9
  35. package/dist/entities/state.d.ts +4 -4
  36. package/dist/entities/state.js +57 -67
  37. package/dist/index.d.ts +27 -27
  38. package/dist/index.js +27 -27
  39. package/dist/interfaces/account_cluster.d.ts +4 -4
  40. package/dist/interfaces/admin.d.ts +1 -1
  41. package/dist/interfaces/instance.d.ts +1 -1
  42. package/dist/interfaces/operation.d.ts +3 -3
  43. package/dist/interfaces/orby.d.ts +6 -6
  44. package/dist/interfaces/token.d.ts +1 -1
  45. package/dist/tsconfig.tsbuildinfo +1 -1
  46. package/dist/types.d.ts +7 -7
  47. package/dist/utils/action_helpers.d.ts +1 -1
  48. package/dist/utils/action_helpers.js +42 -58
  49. package/dist/utils/jsbi.d.ts +2 -0
  50. package/dist/utils/jsbi.js +2 -0
  51. package/dist/utils/utils.d.ts +1 -1
  52. package/dist/utils/utils.js +17 -19
  53. package/dist/utils/validateAndParseAddress.js +3 -3
  54. package/package.json +4 -2
package/dist/constants.js CHANGED
@@ -1,134 +1,133 @@
1
- var _a, _b, _c;
2
1
  import toFormat from "toformat";
3
2
  import _Big from "big.js";
4
- import { Blockchain, BlockchainEnvironment } from "./enums";
5
- import { Currency } from "./entities/financial/currency";
6
- export var Big = toFormat(_Big);
7
- export var BLOCKCHAIN_ID = (_a = {},
8
- _a[Blockchain.ETHEREUM] = 1,
9
- _a[Blockchain.POLYGON] = 137,
10
- _a[Blockchain.BINANCE] = 56,
11
- _a[Blockchain.ARBITRUM] = 42161,
12
- _a[Blockchain.ARBITRUM_NOVA] = 42170,
13
- _a[Blockchain.OPTIMISM] = 10,
14
- _a[Blockchain.EVMOS] = 9001,
15
- _a[Blockchain.MOONBEAM] = 1284,
16
- _a[Blockchain.BASE] = 8453,
17
- _a[Blockchain.AVALANCHE] = 43114,
3
+ import { Blockchain, BlockchainEnvironment } from "./enums.js";
4
+ import { Currency } from "./entities/financial/currency.js";
5
+ export const Big = toFormat(_Big);
6
+ export const BLOCKCHAIN_ID = {
7
+ [Blockchain.ETHEREUM]: 1,
8
+ [Blockchain.POLYGON]: 137,
9
+ [Blockchain.BINANCE]: 56,
10
+ [Blockchain.ARBITRUM]: 42161,
11
+ [Blockchain.ARBITRUM_NOVA]: 42170,
12
+ [Blockchain.OPTIMISM]: 10,
13
+ [Blockchain.EVMOS]: 9001,
14
+ [Blockchain.MOONBEAM]: 1284,
15
+ [Blockchain.BASE]: 8453,
16
+ [Blockchain.AVALANCHE]: 43114,
18
17
  // testnets
19
- _a[Blockchain.ETHEREUM_SEPOLIA] = 11155111,
20
- _a[Blockchain.ETHEREUM_HOLESKY] = 17000,
21
- _a[Blockchain.ARBITRUM_SEPOLIA] = 421614,
22
- _a[Blockchain.OPTIMISM_SEPOLIA] = 11155420,
23
- _a[Blockchain.POLYGON_AMOY] = 80002,
24
- _a[Blockchain.BINANCE_TESTNET] = 97,
25
- _a[Blockchain.OPBNB_TESTNET] = 5611,
26
- _a[Blockchain.MOONBEAM_ALPHA] = 1287,
27
- _a[Blockchain.BASE_SEPOLIA] = 84532,
18
+ [Blockchain.ETHEREUM_SEPOLIA]: 11155111,
19
+ [Blockchain.ETHEREUM_HOLESKY]: 17000,
20
+ [Blockchain.ARBITRUM_SEPOLIA]: 421614,
21
+ [Blockchain.OPTIMISM_SEPOLIA]: 11155420,
22
+ [Blockchain.POLYGON_AMOY]: 80002,
23
+ [Blockchain.BINANCE_TESTNET]: 97,
24
+ [Blockchain.OPBNB_TESTNET]: 5611,
25
+ [Blockchain.MOONBEAM_ALPHA]: 1287,
26
+ [Blockchain.BASE_SEPOLIA]: 84532,
28
27
  // local testing
29
- _a[Blockchain.HARDHAT] = 31337,
30
- _a[Blockchain.LOCAL_CHAIN_0] = 1000000000001,
31
- _a[Blockchain.LOCAL_CHAIN_1] = 1000000000002,
32
- _a);
33
- export var CHAIN_CONFIGS = (_b = {},
34
- _b[Blockchain.ETHEREUM] = {
28
+ [Blockchain.HARDHAT]: 31337,
29
+ [Blockchain.LOCAL_CHAIN_0]: 1_000_000_000_001,
30
+ [Blockchain.LOCAL_CHAIN_1]: 1_000_000_000_002,
31
+ };
32
+ export const CHAIN_CONFIGS = {
33
+ [Blockchain.ETHEREUM]: {
35
34
  environment: BlockchainEnvironment.MAINNET,
36
35
  chainId: BigInt(1),
37
36
  },
38
- _b[Blockchain.POLYGON] = {
37
+ [Blockchain.POLYGON]: {
39
38
  environment: BlockchainEnvironment.MAINNET,
40
39
  chainId: BigInt(137),
41
40
  },
42
- _b[Blockchain.BINANCE] = {
41
+ [Blockchain.BINANCE]: {
43
42
  environment: BlockchainEnvironment.MAINNET,
44
43
  chainId: BigInt(56),
45
44
  },
46
- _b[Blockchain.ARBITRUM] = {
45
+ [Blockchain.ARBITRUM]: {
47
46
  environment: BlockchainEnvironment.MAINNET,
48
47
  chainId: BigInt(42161),
49
48
  },
50
- _b[Blockchain.ARBITRUM_NOVA] = {
49
+ [Blockchain.ARBITRUM_NOVA]: {
51
50
  environment: BlockchainEnvironment.MAINNET,
52
51
  chainId: BigInt(42170),
53
52
  },
54
- _b[Blockchain.OPTIMISM] = {
53
+ [Blockchain.OPTIMISM]: {
55
54
  environment: BlockchainEnvironment.MAINNET,
56
55
  chainId: BigInt(10),
57
56
  },
58
- _b[Blockchain.EVMOS] = {
57
+ [Blockchain.EVMOS]: {
59
58
  environment: BlockchainEnvironment.MAINNET,
60
59
  chainId: BigInt(9001),
61
60
  },
62
- _b[Blockchain.MOONBEAM] = {
61
+ [Blockchain.MOONBEAM]: {
63
62
  environment: BlockchainEnvironment.MAINNET,
64
63
  chainId: BigInt(1284),
65
64
  },
66
- _b[Blockchain.BASE] = {
65
+ [Blockchain.BASE]: {
67
66
  environment: BlockchainEnvironment.MAINNET,
68
67
  chainId: BigInt(8453),
69
68
  },
70
- _b[Blockchain.AVALANCHE] = {
69
+ [Blockchain.AVALANCHE]: {
71
70
  environment: BlockchainEnvironment.MAINNET,
72
71
  chainId: BigInt(43114),
73
72
  },
74
73
  // testnets
75
- _b[Blockchain.ETHEREUM_SEPOLIA] = {
74
+ [Blockchain.ETHEREUM_SEPOLIA]: {
76
75
  environment: BlockchainEnvironment.TESTNET,
77
76
  chainId: BigInt(11155111),
78
77
  },
79
- _b[Blockchain.ETHEREUM_HOLESKY] = {
78
+ [Blockchain.ETHEREUM_HOLESKY]: {
80
79
  environment: BlockchainEnvironment.TESTNET,
81
80
  chainId: BigInt(17000),
82
81
  },
83
- _b[Blockchain.ARBITRUM_SEPOLIA] = {
82
+ [Blockchain.ARBITRUM_SEPOLIA]: {
84
83
  environment: BlockchainEnvironment.TESTNET,
85
84
  chainId: BigInt(421614),
86
85
  },
87
- _b[Blockchain.BASE_SEPOLIA] = {
86
+ [Blockchain.BASE_SEPOLIA]: {
88
87
  environment: BlockchainEnvironment.TESTNET,
89
88
  chainId: BigInt(84532),
90
89
  },
91
- _b[Blockchain.OPTIMISM_SEPOLIA] = {
90
+ [Blockchain.OPTIMISM_SEPOLIA]: {
92
91
  environment: BlockchainEnvironment.TESTNET,
93
92
  chainId: BigInt(11155420),
94
93
  },
95
- _b[Blockchain.BINANCE_TESTNET] = {
94
+ [Blockchain.BINANCE_TESTNET]: {
96
95
  environment: BlockchainEnvironment.TESTNET,
97
96
  chainId: BigInt(97),
98
97
  },
99
- _b[Blockchain.OPBNB_TESTNET] = {
98
+ [Blockchain.OPBNB_TESTNET]: {
100
99
  environment: BlockchainEnvironment.TESTNET,
101
100
  chainId: BigInt(5611),
102
101
  },
103
- _b[Blockchain.MOONBEAM_ALPHA] = {
102
+ [Blockchain.MOONBEAM_ALPHA]: {
104
103
  environment: BlockchainEnvironment.TESTNET,
105
104
  chainId: BigInt(1287),
106
105
  },
107
- _b[Blockchain.POLYGON_AMOY] = {
106
+ [Blockchain.POLYGON_AMOY]: {
108
107
  environment: BlockchainEnvironment.TESTNET,
109
108
  chainId: BigInt(80002),
110
109
  },
111
- _b);
112
- export var BLOCKCHAIN_ID_TO_BLOCKCHAIN = (_c = {},
113
- _c[1] = Blockchain.ETHEREUM,
114
- _c[137] = Blockchain.POLYGON,
115
- _c[56] = Blockchain.BINANCE,
116
- _c[42161] = Blockchain.ARBITRUM,
117
- _c[42170] = Blockchain.ARBITRUM_NOVA,
118
- _c[10] = Blockchain.OPTIMISM,
119
- _c[9001] = Blockchain.EVMOS,
120
- _c[1284] = Blockchain.MOONBEAM,
121
- _c[8453] = Blockchain.BASE,
122
- _c[43114] = Blockchain.AVALANCHE,
110
+ };
111
+ export const BLOCKCHAIN_ID_TO_BLOCKCHAIN = {
112
+ [1]: Blockchain.ETHEREUM,
113
+ [137]: Blockchain.POLYGON,
114
+ [56]: Blockchain.BINANCE,
115
+ [42161]: Blockchain.ARBITRUM,
116
+ [42170]: Blockchain.ARBITRUM_NOVA,
117
+ [10]: Blockchain.OPTIMISM,
118
+ [9001]: Blockchain.EVMOS,
119
+ [1284]: Blockchain.MOONBEAM,
120
+ [8453]: Blockchain.BASE,
121
+ [43114]: Blockchain.AVALANCHE,
123
122
  // testnets
124
- _c[11155111] = Blockchain.ETHEREUM_SEPOLIA,
125
- _c[84532] = Blockchain.BASE_SEPOLIA,
126
- _c[17000] = Blockchain.ETHEREUM_HOLESKY,
127
- _c[421614] = Blockchain.ARBITRUM_SEPOLIA,
128
- _c[11155420] = Blockchain.OPTIMISM_SEPOLIA,
129
- _c[80002] = Blockchain.POLYGON_AMOY,
130
- _c[97] = Blockchain.BINANCE_TESTNET,
131
- _c[5611] = Blockchain.OPBNB_TESTNET,
132
- _c[1287] = Blockchain.MOONBEAM_ALPHA,
133
- _c);
134
- export var FIAT_CURRENCY = new Currency(6, "USD", "US Dollar", undefined, false, false);
123
+ [11155111]: Blockchain.ETHEREUM_SEPOLIA,
124
+ [84532]: Blockchain.BASE_SEPOLIA,
125
+ [17000]: Blockchain.ETHEREUM_HOLESKY,
126
+ [421614]: Blockchain.ARBITRUM_SEPOLIA,
127
+ [11155420]: Blockchain.OPTIMISM_SEPOLIA,
128
+ [80002]: Blockchain.POLYGON_AMOY,
129
+ [97]: Blockchain.BINANCE_TESTNET,
130
+ [5611]: Blockchain.OPBNB_TESTNET,
131
+ [1287]: Blockchain.MOONBEAM_ALPHA,
132
+ };
133
+ export const FIAT_CURRENCY = new Currency(6, "USD", "US Dollar", undefined, false, false);
@@ -1,4 +1,4 @@
1
- import { AccountType, VMType } from "../enums";
1
+ import { AccountType, VMType } from "../enums.js";
2
2
  export declare class Account {
3
3
  readonly address: string;
4
4
  readonly chainId?: bigint;
@@ -1,10 +1,20 @@
1
- import { AccountType } from "../enums";
2
- import { getChainIdFromOrbyChainId } from "../utils/utils";
3
- var Account = /** @class */ (function () {
4
- function Account(address, accountType, vmType, chainId) {
1
+ import { AccountType } from "../enums.js";
2
+ import { getChainIdFromOrbyChainId } from "../utils/utils.js";
3
+ export class Account {
4
+ static toAccount(account) {
5
+ const chainId = account?.chainId
6
+ ? getChainIdFromOrbyChainId(account.chainId)
7
+ : undefined;
8
+ const formattedAccountType = account?.accountType?.toLowerCase();
9
+ if (!chainId && formattedAccountType == AccountType.SCA) {
10
+ return undefined;
11
+ }
12
+ return new Account(account.address, formattedAccountType, account.vmType, chainId);
13
+ }
14
+ constructor(address, accountType, vmType, chainId) {
5
15
  // TODO(felix): add this back
6
16
  // invariant(!_.isUndefined(getBlockchainFromBlockchainId(chainId)), "CHAIN_ID");
7
- this.address = address === null || address === void 0 ? void 0 : address.toLowerCase(); // validateAndParseAddress(address)?.toLowerCase();
17
+ this.address = address?.toLowerCase(); // validateAndParseAddress(address)?.toLowerCase();
8
18
  this.chainId = chainId ? BigInt(chainId) : undefined;
9
19
  this.accountType = accountType;
10
20
  this.vmType = vmType;
@@ -16,35 +26,20 @@ var Account = /** @class */ (function () {
16
26
  this.hasSufficientBalanceForGas = false;
17
27
  }
18
28
  }
19
- Account.toAccount = function (account) {
20
- var _a;
21
- var chainId = (account === null || account === void 0 ? void 0 : account.chainId)
22
- ? getChainIdFromOrbyChainId(account.chainId)
23
- : undefined;
24
- var formattedAccountType = (_a = account === null || account === void 0 ? void 0 : account.accountType) === null || _a === void 0 ? void 0 : _a.toLowerCase();
25
- if (!chainId && formattedAccountType == AccountType.SCA) {
26
- return undefined;
27
- }
28
- return new Account(account.address, formattedAccountType, account.vmType, chainId);
29
- };
30
- Account.key = function (address, chainId) {
31
- var _a;
29
+ static key(address, chainId) {
32
30
  return chainId
33
- ? "".concat((_a = chainId === null || chainId === void 0 ? void 0 : chainId.toString()) === null || _a === void 0 ? void 0 : _a.toLowerCase(), "-").concat(address)
31
+ ? `${chainId?.toString()?.toLowerCase()}-${address}`
34
32
  : address;
35
- };
36
- Account.prototype.toAccountModel = function () {
37
- var _a, _b;
33
+ }
34
+ toAccountModel() {
38
35
  return {
39
36
  address: this.address,
40
- accountType: (_a = this.accountType) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
41
- vmType: (_b = this.vmType) === null || _b === void 0 ? void 0 : _b.toUpperCase(),
37
+ accountType: this.accountType?.toUpperCase(),
38
+ vmType: this.vmType?.toUpperCase(),
42
39
  chainId: this.chainId ? "EIP155-" + this.chainId : undefined,
43
40
  };
44
- };
45
- Account.prototype.equals = function (other) {
41
+ }
42
+ equals(other) {
46
43
  return this.key == other.key && this.accountType == other.accountType;
47
- };
48
- return Account;
49
- }());
50
- export { Account };
44
+ }
45
+ }
@@ -1,5 +1,5 @@
1
- import { Account } from "../account";
2
- import { FungibleTokenAmount } from "./fungible_token_amount";
1
+ import { Account } from "../account.js";
2
+ import { FungibleTokenAmount } from "./fungible_token_amount.js";
3
3
  export declare class AccountBalance {
4
4
  readonly amount: FungibleTokenAmount;
5
5
  readonly account: Account;
@@ -1,33 +1,31 @@
1
- import { Account } from "../account";
2
- import { FungibleTokenAmount } from "./fungible_token_amount";
3
- var AccountBalance = /** @class */ (function () {
4
- function AccountBalance(amount, account) {
5
- this.amount = amount;
6
- this.account = account;
7
- }
8
- AccountBalance.toAccountBalance = function (balance) {
1
+ import { Account } from "../account.js";
2
+ import { FungibleTokenAmount } from "./fungible_token_amount.js";
3
+ export class AccountBalance {
4
+ static toAccountBalance(balance) {
9
5
  if (!balance) {
10
6
  return undefined;
11
7
  }
12
- var amount = FungibleTokenAmount.toFungibleTokenAmount(balance.amount);
13
- var account = Account.toAccount(balance.account);
8
+ const amount = FungibleTokenAmount.toFungibleTokenAmount(balance.amount);
9
+ const account = Account.toAccount(balance.account);
14
10
  return new AccountBalance(amount, account);
15
- };
16
- AccountBalance.prototype.equals = function (other) {
11
+ }
12
+ constructor(amount, account) {
13
+ this.amount = amount;
14
+ this.account = account;
15
+ }
16
+ equals(other) {
17
17
  return (this.account.equals(other.account) && this.amount.equals(other.amount));
18
- };
19
- AccountBalance.prototype.lessThan = function (other) {
18
+ }
19
+ lessThan(other) {
20
20
  return (this.account.equals(other.account) && this.amount.lessThan(other.amount));
21
- };
22
- AccountBalance.prototype.greaterThan = function (other) {
21
+ }
22
+ greaterThan(other) {
23
23
  return (this.account.equals(other.account) &&
24
24
  this.amount.greaterThan(other.amount));
25
- };
26
- AccountBalance.prototype.greaterThanOrEqual = function (other) {
25
+ }
26
+ greaterThanOrEqual(other) {
27
27
  return (this.account.equals(other.account) &&
28
28
  (this.amount.greaterThan(other.amount) ||
29
29
  this.amount.equals(other.amount)));
30
- };
31
- return AccountBalance;
32
- }());
33
- export { AccountBalance };
30
+ }
31
+ }
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * An Asset is any fungible financial instrument, including Ether, all ERC20 tokens, and NFTs
3
3
  */
4
- var Asset = /** @class */ (function () {
4
+ export class Asset {
5
5
  /**
6
6
  * Constructs an instance of the `Asset`.
7
7
  * @param symbol symbol of the asset
8
8
  * @param name of the asset
9
9
  */
10
- function Asset(symbol, name, coinGeckoId) {
10
+ constructor(symbol, name, coinGeckoId) {
11
11
  this.symbol = symbol;
12
12
  this.name = name;
13
13
  this.coinGeckoId = coinGeckoId;
@@ -16,25 +16,23 @@ var Asset = /** @class */ (function () {
16
16
  * Returns whether this asset is functionally equivalent to the other asset
17
17
  * @param other the other asset
18
18
  */
19
- Asset.prototype.equals = function (other) {
19
+ equals(other) {
20
20
  if (this === other)
21
21
  return true;
22
22
  return this.symbol === other.symbol && this.name === other.name;
23
- };
23
+ }
24
24
  // return Asset in the "@domains/orby/src/api/graphql/generated" but could not set type here because the generated code is not available for other domains
25
- Asset.prototype.toAssetModel = function () {
25
+ toAssetModel() {
26
26
  return { symbol: this.symbol, name: this.name };
27
- };
28
- Asset.toAsset = function (asset) {
27
+ }
28
+ static toAsset(asset) {
29
29
  if (!asset) {
30
30
  return undefined;
31
31
  }
32
- var symbol = asset.symbol, name = asset.name;
32
+ const { symbol, name } = asset;
33
33
  return new Asset(symbol, name);
34
- };
35
- Asset.prototype.id = function () {
36
- return "".concat(this.name, ":").concat(this.symbol);
37
- };
38
- return Asset;
39
- }());
40
- export { Asset };
34
+ }
35
+ id() {
36
+ return `${this.name}:${this.symbol}`;
37
+ }
38
+ }
@@ -1,4 +1,4 @@
1
- import { Asset } from "./asset";
1
+ import { Asset } from "./asset.js";
2
2
  /**
3
3
  * A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies
4
4
  */
@@ -1,27 +1,11 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
1
  import invariant from "tiny-invariant";
17
- import { Asset } from "./asset";
2
+ import { Asset } from "./asset.js";
18
3
  // This class is inspired by the Uniswap SDK's (@uniswap/sdk-core) CurrencyAmount class. Create this instance here
19
4
  // because we represent currency amounts that are not fungible token amounts.
20
5
  /**
21
6
  * A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies
22
7
  */
23
- var Currency = /** @class */ (function (_super) {
24
- __extends(Currency, _super);
8
+ export class Currency extends Asset {
25
9
  /**
26
10
  * Constructs an instance of the base class `Currency`.
27
11
  * @param decimals decimals of the currency
@@ -30,39 +14,36 @@ var Currency = /** @class */ (function (_super) {
30
14
  * @param isNative whether the currency is native to the chain and must be wrapped (e.g. Ether)
31
15
  * @param isToken whether the currency is a token that is usable in Uniswap without wrapping
32
16
  */
33
- function Currency(decimals, symbol, name, logoUrl, isNative, isToken, coinGeckoId) {
34
- var _this = _super.call(this, symbol, name, coinGeckoId) || this;
17
+ constructor(decimals, symbol, name, logoUrl, isNative, isToken, coinGeckoId) {
18
+ super(symbol, name, coinGeckoId);
35
19
  invariant(decimals >= 0 && decimals < 255 && Number.isInteger(decimals), "DECIMALS");
36
- _this.decimals = decimals;
37
- _this.isNative = isNative !== null && isNative !== void 0 ? isNative : false;
38
- _this.isToken = isToken !== null && isToken !== void 0 ? isToken : true;
39
- _this.logoUrl = logoUrl;
40
- return _this;
20
+ this.decimals = decimals;
21
+ this.isNative = isNative ?? false;
22
+ this.isToken = isToken ?? true;
23
+ this.logoUrl = logoUrl;
41
24
  }
42
25
  /**
43
26
  * Returns whether this currency is functionally equivalent to the other currency
44
27
  * @param other the other currency
45
28
  */
46
- Currency.prototype.equals = function (other) {
29
+ equals(other) {
47
30
  if (this === other)
48
31
  return true;
49
32
  return (this.symbol === other.symbol &&
50
33
  this.name === other.name &&
51
34
  this.decimals === other.decimals);
52
- };
35
+ }
53
36
  /**
54
37
  * Returns the asset representation of this currency
55
38
  */
56
- Currency.prototype.asset = function () {
39
+ asset() {
57
40
  return this;
58
- };
59
- Currency.toCurrency = function (currency) {
41
+ }
42
+ static toCurrency(currency) {
60
43
  if (!currency) {
61
44
  return undefined;
62
45
  }
63
- var asset = currency.asset, decimals = currency.decimals, logoUrl = currency.logoUrl, isNative = currency.isNative;
46
+ const { asset, decimals, logoUrl, isNative } = currency;
64
47
  return new Currency(decimals, asset.symbol, asset.name, logoUrl, isNative);
65
- };
66
- return Currency;
67
- }(Asset));
68
- export { Currency };
48
+ }
49
+ }
@@ -1,6 +1,6 @@
1
1
  import JSBI from "jsbi";
2
2
  import { Fraction, BigintIsh, Rounding } from "@uniswap/sdk-core";
3
- import { Currency } from "./currency";
3
+ import { Currency } from "./currency.js";
4
4
  export declare class CurrencyAmount extends Fraction {
5
5
  readonly currency: Currency;
6
6
  readonly decimalScale: JSBI;