@orb-labs/orby-core 0.0.6 → 0.0.8

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 (56) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/actions/account_cluster.d.ts +12 -5
  3. package/dist/actions/account_cluster.js +185 -338
  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/blockchain.d.ts +16 -0
  9. package/dist/actions/blockchain.js +35 -0
  10. package/dist/actions/instance.d.ts +3 -4
  11. package/dist/actions/instance.js +90 -255
  12. package/dist/actions/operation.d.ts +19 -10
  13. package/dist/actions/operation.js +323 -259
  14. package/dist/actions/token.d.ts +3 -3
  15. package/dist/actions/token.js +43 -119
  16. package/dist/constants.d.ts +3 -3
  17. package/dist/constants.js +70 -71
  18. package/dist/entities/account.d.ts +1 -1
  19. package/dist/entities/account.js +25 -30
  20. package/dist/entities/financial/account_balance.d.ts +2 -2
  21. package/dist/entities/financial/account_balance.js +20 -22
  22. package/dist/entities/financial/asset.js +13 -15
  23. package/dist/entities/financial/currency.d.ts +1 -1
  24. package/dist/entities/financial/currency.js +16 -35
  25. package/dist/entities/financial/currency_amount.d.ts +1 -1
  26. package/dist/entities/financial/currency_amount.js +49 -71
  27. package/dist/entities/financial/fungible_token.d.ts +3 -3
  28. package/dist/entities/financial/fungible_token.js +31 -52
  29. package/dist/entities/financial/fungible_token_amount.d.ts +2 -2
  30. package/dist/entities/financial/fungible_token_amount.js +53 -75
  31. package/dist/entities/financial/non_fungible_token.d.ts +2 -2
  32. package/dist/entities/financial/non_fungible_token.js +25 -45
  33. package/dist/entities/financial/semi_fungible_token.d.ts +2 -2
  34. package/dist/entities/financial/semi_fungible_token.js +25 -45
  35. package/dist/entities/library_request.d.ts +1 -1
  36. package/dist/entities/library_request.js +7 -9
  37. package/dist/entities/state.d.ts +4 -4
  38. package/dist/entities/state.js +57 -67
  39. package/dist/index.d.ts +29 -27
  40. package/dist/index.js +29 -27
  41. package/dist/interfaces/account_cluster.d.ts +11 -4
  42. package/dist/interfaces/admin.d.ts +1 -1
  43. package/dist/interfaces/blockchain.d.ts +13 -0
  44. package/dist/interfaces/blockchain.js +1 -0
  45. package/dist/interfaces/instance.d.ts +1 -2
  46. package/dist/interfaces/operation.d.ts +25 -10
  47. package/dist/interfaces/orby.d.ts +8 -7
  48. package/dist/interfaces/token.d.ts +1 -1
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/dist/types.d.ts +9 -9
  51. package/dist/utils/action_helpers.d.ts +1 -1
  52. package/dist/utils/action_helpers.js +43 -63
  53. package/dist/utils/utils.d.ts +2 -1
  54. package/dist/utils/utils.js +23 -19
  55. package/dist/utils/validateAndParseAddress.js +3 -3
  56. package/package.json +4 -2
@@ -1,122 +1,46 @@
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
1
+ import { extractStandardizedToken, extractStandardizedTokens, } from "../utils/action_helpers.js";
2
+ import { LibraryRequest } from "../entities/library_request.js";
3
+ import { getOrbyChainId } from "../utils/utils.js";
4
+ export class TokenActions extends LibraryRequest {
5
+ constructor(library, client, provider) {
6
+ super(library, client, provider);
50
7
  }
51
- };
52
- import { extractStandardizedToken, extractStandardizedTokens, } from "../utils/action_helpers";
53
- import { LibraryRequest } from "../entities/library_request";
54
- var TokenActions = /** @class */ (function (_super) {
55
- __extends(TokenActions, _super);
56
- function TokenActions(library, client, provider) {
57
- return _super.call(this, library, client, provider) || this;
58
- }
59
- TokenActions.prototype.getStandardizedTokenIds = function (tokens) {
60
- return __awaiter(this, void 0, void 0, function () {
61
- var formattedTokensInfo, _a, standardizedTokenIds, message, code;
62
- return __generator(this, function (_b) {
63
- switch (_b.label) {
64
- case 0:
65
- formattedTokensInfo = tokens.map(function (_a) {
66
- var tokenAddress = _a.tokenAddress, chainId = _a.chainId;
67
- return { chainId: "EIP155-".concat(chainId), tokenAddress: tokenAddress };
68
- });
69
- return [4 /*yield*/, this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }])];
70
- case 1:
71
- _a = _b.sent(), standardizedTokenIds = _a.standardizedTokenIds, message = _a.message, code = _a.code;
72
- if (code && message) {
73
- console.error("[getStandardizedTokenIds]", code, message);
74
- return [2 /*return*/, undefined];
75
- }
76
- return [2 /*return*/, standardizedTokenIds];
77
- }
78
- });
79
- });
80
- };
81
- TokenActions.prototype.getStandardizedTokens = function (tokens) {
82
- return __awaiter(this, void 0, void 0, function () {
83
- var formattedTokensInfo, _a, standardizedTokens, message, code;
84
- return __generator(this, function (_b) {
85
- switch (_b.label) {
86
- case 0:
87
- formattedTokensInfo = tokens.map(function (_a) {
88
- var tokenAddress = _a.tokenAddress, chainId = _a.chainId;
89
- return { chainId: "EIP155-".concat(chainId), tokenAddress: tokenAddress };
90
- });
91
- return [4 /*yield*/, this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }])];
92
- case 1:
93
- _a = _b.sent(), standardizedTokens = _a.standardizedTokens, message = _a.message, code = _a.code;
94
- if (code && message) {
95
- console.error("[getStandardizedTokens]", code, message);
96
- return [2 /*return*/, undefined];
97
- }
98
- return [2 /*return*/, extractStandardizedTokens(standardizedTokens)];
99
- }
100
- });
8
+ async getStandardizedTokenIds(tokens) {
9
+ const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
10
+ return { chainId: getOrbyChainId(chainId), tokenAddress };
101
11
  });
102
- };
103
- TokenActions.prototype.getFungibleTokenData = function (standardizedTokenIds) {
104
- return __awaiter(this, void 0, void 0, function () {
105
- var _a, data, message, code;
106
- return __generator(this, function (_b) {
107
- switch (_b.label) {
108
- case 0: return [4 /*yield*/, this.sendRequest("orby_getFungibleTokenData", [{ standardizedTokenIds: standardizedTokenIds }])];
109
- case 1:
110
- _a = _b.sent(), data = _a.data, message = _a.message, code = _a.code;
111
- if (code && message) {
112
- console.error("[getFungibleTokenData]", code, message);
113
- return [2 /*return*/, undefined];
114
- }
115
- return [2 /*return*/, extractStandardizedToken(data)];
116
- }
117
- });
12
+ const { standardizedTokenIds, message, code } = await this.sendRequest("orby_getStandardizedTokenIds", [
13
+ {
14
+ tokens: formattedTokensInfo,
15
+ },
16
+ ]);
17
+ if (code && message) {
18
+ console.error("[getStandardizedTokenIds]", code, message);
19
+ return undefined;
20
+ }
21
+ return standardizedTokenIds;
22
+ }
23
+ async getStandardizedTokens(tokens) {
24
+ const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
25
+ return { chainId: getOrbyChainId(chainId), tokenAddress };
118
26
  });
119
- };
120
- return TokenActions;
121
- }(LibraryRequest));
122
- export { TokenActions };
27
+ const { standardizedTokens, message, code } = await this.sendRequest("orby_getStandardizedTokens", [
28
+ {
29
+ tokens: formattedTokensInfo,
30
+ },
31
+ ]);
32
+ if (code && message) {
33
+ console.error("[getStandardizedTokens]", code, message);
34
+ return undefined;
35
+ }
36
+ return extractStandardizedTokens(standardizedTokens);
37
+ }
38
+ async getFungibleTokenData(standardizedTokenIds) {
39
+ const { data, message, code } = await this.sendRequest("orby_getFungibleTokenData", [{ standardizedTokenIds }]);
40
+ if (code && message) {
41
+ console.error("[getFungibleTokenData]", code, message);
42
+ return undefined;
43
+ }
44
+ return extractStandardizedToken(data);
45
+ }
46
+ }
@@ -1,6 +1,6 @@
1
- import { Blockchain } from "./enums";
2
- import { Currency } from "./entities/financial/currency";
3
- import { ChainConfigs } from "./types";
1
+ import { Blockchain } from "./enums.js";
2
+ import { Currency } from "./entities/financial/currency.js";
3
+ import { ChainConfigs } from "./types.js";
4
4
  export declare const Big: any;
5
5
  export declare const BLOCKCHAIN_ID: {
6
6
  [s: string]: number;
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
  */