@orb-labs/orby-core 0.0.6 → 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.
- package/CHANGELOG.md +7 -0
- package/dist/actions/account_cluster.d.ts +4 -4
- package/dist/actions/account_cluster.js +147 -338
- package/dist/actions/admin.d.ts +3 -3
- package/dist/actions/admin.js +37 -127
- package/dist/actions/application.d.ts +2 -2
- package/dist/actions/application.js +14 -77
- package/dist/actions/instance.d.ts +3 -3
- package/dist/actions/instance.js +98 -255
- package/dist/actions/operation.d.ts +4 -4
- package/dist/actions/operation.js +92 -263
- package/dist/actions/token.d.ts +3 -3
- package/dist/actions/token.js +34 -119
- package/dist/constants.d.ts +3 -3
- package/dist/constants.js +70 -71
- package/dist/entities/account.d.ts +1 -1
- package/dist/entities/account.js +25 -30
- package/dist/entities/financial/account_balance.d.ts +2 -2
- package/dist/entities/financial/account_balance.js +20 -22
- package/dist/entities/financial/asset.js +13 -15
- package/dist/entities/financial/currency.d.ts +1 -1
- package/dist/entities/financial/currency.js +16 -35
- package/dist/entities/financial/currency_amount.d.ts +1 -1
- package/dist/entities/financial/currency_amount.js +49 -71
- package/dist/entities/financial/fungible_token.d.ts +2 -2
- package/dist/entities/financial/fungible_token.js +31 -52
- package/dist/entities/financial/fungible_token_amount.d.ts +2 -2
- package/dist/entities/financial/fungible_token_amount.js +53 -75
- package/dist/entities/financial/non_fungible_token.d.ts +2 -2
- package/dist/entities/financial/non_fungible_token.js +25 -45
- package/dist/entities/financial/semi_fungible_token.d.ts +2 -2
- package/dist/entities/financial/semi_fungible_token.js +25 -45
- package/dist/entities/library_request.d.ts +1 -1
- package/dist/entities/library_request.js +7 -9
- package/dist/entities/state.d.ts +4 -4
- package/dist/entities/state.js +57 -67
- package/dist/index.d.ts +27 -27
- package/dist/index.js +27 -27
- package/dist/interfaces/account_cluster.d.ts +3 -3
- package/dist/interfaces/admin.d.ts +1 -1
- package/dist/interfaces/instance.d.ts +1 -1
- package/dist/interfaces/operation.d.ts +3 -3
- package/dist/interfaces/orby.d.ts +6 -6
- package/dist/interfaces/token.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +7 -7
- package/dist/utils/action_helpers.d.ts +1 -1
- package/dist/utils/action_helpers.js +42 -58
- package/dist/utils/jsbi.d.ts +2 -0
- package/dist/utils/jsbi.js +2 -0
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +17 -19
- package/dist/utils/validateAndParseAddress.js +3 -3
- package/package.json +4 -2
package/dist/utils/utils.js
CHANGED
@@ -1,37 +1,35 @@
|
|
1
|
-
import { Blockchain, BlockchainEnvironment } from "../enums";
|
2
|
-
import { BLOCKCHAIN_ID, BLOCKCHAIN_ID_TO_BLOCKCHAIN, CHAIN_CONFIGS, } from "../constants";
|
3
|
-
export
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
var potentialId = (publicIdElements === null || publicIdElements === void 0 ? void 0 : publicIdElements.length) > 1 ? publicIdElements[1] : undefined;
|
1
|
+
import { Blockchain, BlockchainEnvironment } from "../enums.js";
|
2
|
+
import { BLOCKCHAIN_ID, BLOCKCHAIN_ID_TO_BLOCKCHAIN, CHAIN_CONFIGS, } from "../constants.js";
|
3
|
+
export const getChainIdFromOrbyChainId = (value) => {
|
4
|
+
let chainId = undefined;
|
5
|
+
const formattedValue = value?.trim()?.toLowerCase();
|
6
|
+
if (formattedValue?.includes("eip155")) {
|
7
|
+
const publicIdElements = formattedValue.split("eip155-");
|
8
|
+
const potentialId = publicIdElements?.length > 1 ? publicIdElements[1] : undefined;
|
10
9
|
chainId = !Number.isNaN(Number(potentialId))
|
11
10
|
? BigInt(potentialId)
|
12
11
|
: undefined;
|
13
12
|
}
|
14
13
|
else {
|
15
|
-
|
16
|
-
|
14
|
+
const blockchain = getBlockchainFromName(formattedValue);
|
15
|
+
const potentialId = blockchain
|
17
16
|
? getBlockchainIdFromBlockchain(blockchain)
|
18
17
|
: undefined;
|
19
18
|
chainId = potentialId ? BigInt(potentialId) : undefined;
|
20
19
|
}
|
21
20
|
return chainId;
|
22
21
|
};
|
23
|
-
export
|
22
|
+
export const getBlockchainIdFromBlockchain = (blockchain) => {
|
24
23
|
return BLOCKCHAIN_ID[blockchain];
|
25
24
|
};
|
26
|
-
export
|
27
|
-
if (
|
25
|
+
export const hasError = (data) => {
|
26
|
+
if (data?.code && data?.message) {
|
28
27
|
return { code: data.code, message: data.message };
|
29
28
|
}
|
30
29
|
return undefined;
|
31
30
|
};
|
32
|
-
export
|
33
|
-
|
34
|
-
var formattedChainName = (_a = chainName === null || chainName === void 0 ? void 0 : chainName.toLowerCase()) === null || _a === void 0 ? void 0 : _a.replace("-", "_");
|
31
|
+
export const getBlockchainFromName = (chainName) => {
|
32
|
+
const formattedChainName = chainName?.toLowerCase()?.replace("-", "_");
|
35
33
|
switch (formattedChainName) {
|
36
34
|
case "bnbt": {
|
37
35
|
return Blockchain.BINANCE_TESTNET;
|
@@ -60,7 +58,7 @@ export var getBlockchainFromName = function (chainName) {
|
|
60
58
|
}
|
61
59
|
}
|
62
60
|
};
|
63
|
-
export
|
64
|
-
|
61
|
+
export const isMainnet = (chainId) => {
|
62
|
+
const blockchain = BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)];
|
65
63
|
return CHAIN_CONFIGS[blockchain].environment == BlockchainEnvironment.MAINNET;
|
66
64
|
};
|
@@ -8,11 +8,11 @@ export function validateAndParseAddress(address) {
|
|
8
8
|
return getAddress(address);
|
9
9
|
}
|
10
10
|
catch (error) {
|
11
|
-
throw new Error(
|
11
|
+
throw new Error(`${address} is not a valid address.`);
|
12
12
|
}
|
13
13
|
}
|
14
14
|
// Checks a string starts with 0x, is 42 characters long and contains only hex characters after 0x
|
15
|
-
|
15
|
+
const startsWith0xLen42HexRegex = /^0x[0-9a-fA-F]{40}$/;
|
16
16
|
/**
|
17
17
|
* Checks if an address is valid by checking 0x prefix, length === 42 and hex encoding.
|
18
18
|
* @param address the unchecksummed hex address
|
@@ -21,5 +21,5 @@ export function checkValidAddress(address) {
|
|
21
21
|
if (startsWith0xLen42HexRegex.test(address)) {
|
22
22
|
return address;
|
23
23
|
}
|
24
|
-
throw new Error(
|
24
|
+
throw new Error(`${address} is not a valid address.`);
|
25
25
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orb-labs/orby-core",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.7",
|
4
|
+
"type": "module",
|
4
5
|
"exports": {
|
5
6
|
".": "./dist/index.js"
|
6
7
|
},
|
@@ -25,6 +26,7 @@
|
|
25
26
|
"typescript": "^5.6.3"
|
26
27
|
},
|
27
28
|
"dependencies": {
|
28
|
-
"@uniswap/sdk-core": "^5.9.0"
|
29
|
+
"@uniswap/sdk-core": "^5.9.0",
|
30
|
+
"jsbi": "^3.1.4"
|
29
31
|
}
|
30
32
|
}
|