@orb-labs/orby-core 0.0.4 → 0.0.6

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 (35) hide show
  1. package/dist/actions/account_cluster.d.ts +1 -1
  2. package/dist/actions/account_cluster.js +316 -158
  3. package/dist/actions/admin.js +115 -46
  4. package/dist/actions/application.js +68 -20
  5. package/dist/actions/instance.js +237 -113
  6. package/dist/actions/operation.js +242 -110
  7. package/dist/actions/token.js +107 -41
  8. package/dist/constants.js +92 -97
  9. package/dist/entities/account.js +26 -28
  10. package/dist/entities/financial/account_balance.js +22 -24
  11. package/dist/entities/financial/asset.js +15 -17
  12. package/dist/entities/financial/currency.js +37 -25
  13. package/dist/entities/financial/currency_amount.js +79 -64
  14. package/dist/entities/financial/fungible_token.js +49 -34
  15. package/dist/entities/financial/fungible_token_amount.js +85 -70
  16. package/dist/entities/financial/non_fungible_token.js +45 -30
  17. package/dist/entities/financial/semi_fungible_token.js +45 -30
  18. package/dist/entities/library_request.js +19 -24
  19. package/dist/entities/state.js +67 -60
  20. package/dist/enums.js +34 -37
  21. package/dist/index.js +27 -43
  22. package/dist/interfaces/account_cluster.d.ts +1 -1
  23. package/dist/interfaces/account_cluster.js +1 -2
  24. package/dist/interfaces/admin.js +1 -2
  25. package/dist/interfaces/application.js +1 -2
  26. package/dist/interfaces/instance.js +1 -2
  27. package/dist/interfaces/operation.js +1 -2
  28. package/dist/interfaces/orby.js +1 -2
  29. package/dist/interfaces/token.js +1 -2
  30. package/dist/tsconfig.tsbuildinfo +1 -0
  31. package/dist/types.js +1 -2
  32. package/dist/utils/action_helpers.js +99 -109
  33. package/dist/utils/utils.js +24 -32
  34. package/dist/utils/validateAndParseAddress.js +7 -11
  35. package/package.json +1 -1
@@ -1,61 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMainnet = exports.getBlockchainFromName = exports.hasError = exports.getBlockchainIdFromBlockchain = exports.getChainIdFromOrbyChainId = void 0;
4
- const enums_1 = require("../enums");
5
- const constants_1 = require("../constants");
6
- const getChainIdFromOrbyChainId = (value) => {
1
+ import { Blockchain, BlockchainEnvironment } from "../enums";
2
+ import { BLOCKCHAIN_ID, BLOCKCHAIN_ID_TO_BLOCKCHAIN, CHAIN_CONFIGS, } from "../constants";
3
+ export var getChainIdFromOrbyChainId = function (value) {
7
4
  var _a;
8
- let chainId = undefined;
9
- const formattedValue = (_a = value === null || value === void 0 ? void 0 : value.trim()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
5
+ var chainId = undefined;
6
+ var formattedValue = (_a = value === null || value === void 0 ? void 0 : value.trim()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
10
7
  if (formattedValue === null || formattedValue === void 0 ? void 0 : formattedValue.includes("eip155")) {
11
- const publicIdElements = formattedValue.split("eip155-");
12
- const potentialId = (publicIdElements === null || publicIdElements === void 0 ? void 0 : publicIdElements.length) > 1 ? publicIdElements[1] : undefined;
8
+ var publicIdElements = formattedValue.split("eip155-");
9
+ var potentialId = (publicIdElements === null || publicIdElements === void 0 ? void 0 : publicIdElements.length) > 1 ? publicIdElements[1] : undefined;
13
10
  chainId = !Number.isNaN(Number(potentialId))
14
11
  ? BigInt(potentialId)
15
12
  : undefined;
16
13
  }
17
14
  else {
18
- const blockchain = (0, exports.getBlockchainFromName)(formattedValue);
19
- const potentialId = blockchain
20
- ? (0, exports.getBlockchainIdFromBlockchain)(blockchain)
15
+ var blockchain = getBlockchainFromName(formattedValue);
16
+ var potentialId = blockchain
17
+ ? getBlockchainIdFromBlockchain(blockchain)
21
18
  : undefined;
22
19
  chainId = potentialId ? BigInt(potentialId) : undefined;
23
20
  }
24
21
  return chainId;
25
22
  };
26
- exports.getChainIdFromOrbyChainId = getChainIdFromOrbyChainId;
27
- const getBlockchainIdFromBlockchain = (blockchain) => {
28
- return constants_1.BLOCKCHAIN_ID[blockchain];
23
+ export var getBlockchainIdFromBlockchain = function (blockchain) {
24
+ return BLOCKCHAIN_ID[blockchain];
29
25
  };
30
- exports.getBlockchainIdFromBlockchain = getBlockchainIdFromBlockchain;
31
- const hasError = (data) => {
26
+ export var hasError = function (data) {
32
27
  if ((data === null || data === void 0 ? void 0 : data.code) && (data === null || data === void 0 ? void 0 : data.message)) {
33
28
  return { code: data.code, message: data.message };
34
29
  }
35
30
  return undefined;
36
31
  };
37
- exports.hasError = hasError;
38
- const getBlockchainFromName = (chainName) => {
32
+ export var getBlockchainFromName = function (chainName) {
39
33
  var _a;
40
- const formattedChainName = (_a = chainName === null || chainName === void 0 ? void 0 : chainName.toLowerCase()) === null || _a === void 0 ? void 0 : _a.replace("-", "_");
34
+ var formattedChainName = (_a = chainName === null || chainName === void 0 ? void 0 : chainName.toLowerCase()) === null || _a === void 0 ? void 0 : _a.replace("-", "_");
41
35
  switch (formattedChainName) {
42
36
  case "bnbt": {
43
- return enums_1.Blockchain.BINANCE_TESTNET;
37
+ return Blockchain.BINANCE_TESTNET;
44
38
  }
45
39
  case "matic_amoy": {
46
- return enums_1.Blockchain.POLYGON_AMOY;
40
+ return Blockchain.POLYGON_AMOY;
47
41
  }
48
42
  case "matic": {
49
- return enums_1.Blockchain.POLYGON;
43
+ return Blockchain.POLYGON;
50
44
  }
51
45
  case "mainnet": {
52
- return enums_1.Blockchain.ETHEREUM;
46
+ return Blockchain.ETHEREUM;
53
47
  }
54
48
  case "holesky": {
55
- return enums_1.Blockchain.ETHEREUM_HOLESKY;
49
+ return Blockchain.ETHEREUM_HOLESKY;
56
50
  }
57
51
  case "sepolia": {
58
- return enums_1.Blockchain.ETHEREUM_SEPOLIA;
52
+ return Blockchain.ETHEREUM_SEPOLIA;
59
53
  }
60
54
  case "unknown": {
61
55
  return undefined;
@@ -66,9 +60,7 @@ const getBlockchainFromName = (chainName) => {
66
60
  }
67
61
  }
68
62
  };
69
- exports.getBlockchainFromName = getBlockchainFromName;
70
- const isMainnet = (chainId) => {
71
- const blockchain = constants_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)];
72
- return constants_1.CHAIN_CONFIGS[blockchain].environment == enums_1.BlockchainEnvironment.MAINNET;
63
+ export var isMainnet = function (chainId) {
64
+ var blockchain = BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)];
65
+ return CHAIN_CONFIGS[blockchain].environment == BlockchainEnvironment.MAINNET;
73
66
  };
74
- exports.isMainnet = isMainnet;
@@ -1,29 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateAndParseAddress = validateAndParseAddress;
4
- exports.checkValidAddress = checkValidAddress;
5
- const address_1 = require("@ethersproject/address");
1
+ import { getAddress } from "@ethersproject/address";
6
2
  /**
7
3
  * Validates an address and returns the parsed (checksummed) version of that address
8
4
  * @param address the unchecksummed hex address
9
5
  */
10
- function validateAndParseAddress(address) {
6
+ export function validateAndParseAddress(address) {
11
7
  try {
12
- return (0, address_1.getAddress)(address);
8
+ return getAddress(address);
13
9
  }
14
10
  catch (error) {
15
- throw new Error(`${address} is not a valid address.`);
11
+ throw new Error("".concat(address, " is not a valid address."));
16
12
  }
17
13
  }
18
14
  // Checks a string starts with 0x, is 42 characters long and contains only hex characters after 0x
19
- const startsWith0xLen42HexRegex = /^0x[0-9a-fA-F]{40}$/;
15
+ var startsWith0xLen42HexRegex = /^0x[0-9a-fA-F]{40}$/;
20
16
  /**
21
17
  * Checks if an address is valid by checking 0x prefix, length === 42 and hex encoding.
22
18
  * @param address the unchecksummed hex address
23
19
  */
24
- function checkValidAddress(address) {
20
+ export function checkValidAddress(address) {
25
21
  if (startsWith0xLen42HexRegex.test(address)) {
26
22
  return address;
27
23
  }
28
- throw new Error(`${address} is not a valid address.`);
24
+ throw new Error("".concat(address, " is not a valid address."));
29
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orb-labs/orby-core",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "exports": {
5
5
  ".": "./dist/index.js"
6
6
  },