@orb-labs/orby-core 0.0.15 → 0.0.17
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 +9 -0
- package/dist/cjs/actions/operation.d.ts +2 -2
- package/dist/cjs/actions/operation.js +74 -4
- package/dist/cjs/entities/account.js +1 -1
- package/dist/cjs/interfaces/operation.d.ts +2 -2
- package/dist/cjs/types.d.ts +20 -0
- package/dist/esm/actions/operation.d.ts +2 -2
- package/dist/esm/actions/operation.js +75 -5
- package/dist/esm/actions/token.js +1 -1
- package/dist/esm/entities/account.js +1 -1
- package/dist/esm/interfaces/operation.d.ts +2 -2
- package/dist/esm/types.d.ts +20 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/dist/actions/account_cluster.d.ts +0 -32
- package/dist/actions/account_cluster.js +0 -207
- package/dist/actions/admin.d.ts +0 -17
- package/dist/actions/admin.js +0 -39
- package/dist/actions/application.d.ts +0 -6
- package/dist/actions/application.js +0 -16
- package/dist/actions/blockchain.d.ts +0 -16
- package/dist/actions/blockchain.js +0 -35
- package/dist/actions/instance.d.ts +0 -15
- package/dist/actions/instance.js +0 -94
- package/dist/actions/operation.d.ts +0 -99
- package/dist/actions/operation.js +0 -341
- package/dist/actions/token.d.ts +0 -15
- package/dist/actions/token.js +0 -46
- package/dist/constants.d.ts +0 -14
- package/dist/constants.js +0 -133
- package/dist/entities/account.d.ts +0 -14
- package/dist/entities/account.js +0 -45
- package/dist/entities/financial/account_balance.d.ts +0 -12
- package/dist/entities/financial/account_balance.js +0 -31
- package/dist/entities/financial/asset.d.ts +0 -31
- package/dist/entities/financial/asset.js +0 -38
- package/dist/entities/financial/currency.d.ts +0 -41
- package/dist/entities/financial/currency.js +0 -49
- package/dist/entities/financial/currency_amount.d.ts +0 -34
- package/dist/entities/financial/currency_amount.js +0 -92
- package/dist/entities/financial/fungible_token.d.ts +0 -41
- package/dist/entities/financial/fungible_token.js +0 -64
- package/dist/entities/financial/fungible_token_amount.d.ts +0 -36
- package/dist/entities/financial/fungible_token_amount.js +0 -95
- package/dist/entities/financial/non_fungible_token.d.ts +0 -39
- package/dist/entities/financial/non_fungible_token.js +0 -61
- package/dist/entities/financial/semi_fungible_token.d.ts +0 -41
- package/dist/entities/financial/semi_fungible_token.js +0 -63
- package/dist/entities/library_request.d.ts +0 -8
- package/dist/entities/library_request.js +0 -30
- package/dist/entities/state.d.ts +0 -22
- package/dist/entities/state.js +0 -102
- package/dist/enums.d.ts +0 -116
- package/dist/enums.js +0 -135
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -33
- package/dist/interfaces/account_cluster.d.ts +0 -30
- package/dist/interfaces/account_cluster.js +0 -1
- package/dist/interfaces/admin.d.ts +0 -14
- package/dist/interfaces/admin.js +0 -1
- package/dist/interfaces/application.d.ts +0 -3
- package/dist/interfaces/application.js +0 -1
- package/dist/interfaces/blockchain.d.ts +0 -13
- package/dist/interfaces/blockchain.js +0 -1
- package/dist/interfaces/instance.d.ts +0 -12
- package/dist/interfaces/instance.js +0 -1
- package/dist/interfaces/operation.d.ts +0 -97
- package/dist/interfaces/operation.js +0 -1
- package/dist/interfaces/orby.d.ts +0 -9
- package/dist/interfaces/orby.js +0 -1
- package/dist/interfaces/token.d.ts +0 -12
- package/dist/interfaces/token.js +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types.d.ts +0 -152
- package/dist/types.js +0 -1
- package/dist/utils/action_helpers.d.ts +0 -22
- package/dist/utils/action_helpers.js +0 -250
- package/dist/utils/utils.d.ts +0 -10
- package/dist/utils/utils.js +0 -70
- package/dist/utils/validateAndParseAddress.d.ts +0 -10
- package/dist/utils/validateAndParseAddress.js +0 -25
package/dist/utils/utils.js
DELETED
@@ -1,70 +0,0 @@
|
|
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;
|
9
|
-
chainId = !Number.isNaN(Number(potentialId))
|
10
|
-
? BigInt(potentialId)
|
11
|
-
: undefined;
|
12
|
-
}
|
13
|
-
else {
|
14
|
-
const blockchain = getBlockchainFromName(formattedValue);
|
15
|
-
const potentialId = blockchain
|
16
|
-
? getBlockchainIdFromBlockchain(blockchain)
|
17
|
-
: undefined;
|
18
|
-
chainId = potentialId ? BigInt(potentialId) : undefined;
|
19
|
-
}
|
20
|
-
return chainId;
|
21
|
-
};
|
22
|
-
export const getOrbyChainId = (chainId) => {
|
23
|
-
if (!chainId) {
|
24
|
-
return undefined;
|
25
|
-
}
|
26
|
-
return `EIP155-${chainId.toString()}`;
|
27
|
-
};
|
28
|
-
export const getBlockchainIdFromBlockchain = (blockchain) => {
|
29
|
-
return BLOCKCHAIN_ID[blockchain];
|
30
|
-
};
|
31
|
-
export const hasError = (data) => {
|
32
|
-
if (data?.code && data?.message) {
|
33
|
-
return { code: data.code, message: data.message };
|
34
|
-
}
|
35
|
-
return undefined;
|
36
|
-
};
|
37
|
-
export const getBlockchainFromName = (chainName) => {
|
38
|
-
const formattedChainName = chainName?.toLowerCase()?.replace("-", "_");
|
39
|
-
switch (formattedChainName) {
|
40
|
-
case "bnbt": {
|
41
|
-
return Blockchain.BINANCE_TESTNET;
|
42
|
-
}
|
43
|
-
case "matic_amoy": {
|
44
|
-
return Blockchain.POLYGON_AMOY;
|
45
|
-
}
|
46
|
-
case "matic": {
|
47
|
-
return Blockchain.POLYGON;
|
48
|
-
}
|
49
|
-
case "mainnet": {
|
50
|
-
return Blockchain.ETHEREUM;
|
51
|
-
}
|
52
|
-
case "holesky": {
|
53
|
-
return Blockchain.ETHEREUM_HOLESKY;
|
54
|
-
}
|
55
|
-
case "sepolia": {
|
56
|
-
return Blockchain.ETHEREUM_SEPOLIA;
|
57
|
-
}
|
58
|
-
case "unknown": {
|
59
|
-
return undefined;
|
60
|
-
}
|
61
|
-
default: {
|
62
|
-
//statements;
|
63
|
-
return formattedChainName;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
};
|
67
|
-
export const isMainnet = (chainId) => {
|
68
|
-
const blockchain = BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)];
|
69
|
-
return CHAIN_CONFIGS[blockchain].environment == BlockchainEnvironment.MAINNET;
|
70
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Validates an address and returns the parsed (checksummed) version of that address
|
3
|
-
* @param address the unchecksummed hex address
|
4
|
-
*/
|
5
|
-
export declare function validateAndParseAddress(address: string): string;
|
6
|
-
/**
|
7
|
-
* Checks if an address is valid by checking 0x prefix, length === 42 and hex encoding.
|
8
|
-
* @param address the unchecksummed hex address
|
9
|
-
*/
|
10
|
-
export declare function checkValidAddress(address: string): string;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { getAddress } from "@ethersproject/address";
|
2
|
-
/**
|
3
|
-
* Validates an address and returns the parsed (checksummed) version of that address
|
4
|
-
* @param address the unchecksummed hex address
|
5
|
-
*/
|
6
|
-
export function validateAndParseAddress(address) {
|
7
|
-
try {
|
8
|
-
return getAddress(address);
|
9
|
-
}
|
10
|
-
catch (error) {
|
11
|
-
throw new Error(`${address} is not a valid address.`);
|
12
|
-
}
|
13
|
-
}
|
14
|
-
// Checks a string starts with 0x, is 42 characters long and contains only hex characters after 0x
|
15
|
-
const startsWith0xLen42HexRegex = /^0x[0-9a-fA-F]{40}$/;
|
16
|
-
/**
|
17
|
-
* Checks if an address is valid by checking 0x prefix, length === 42 and hex encoding.
|
18
|
-
* @param address the unchecksummed hex address
|
19
|
-
*/
|
20
|
-
export function checkValidAddress(address) {
|
21
|
-
if (startsWith0xLen42HexRegex.test(address)) {
|
22
|
-
return address;
|
23
|
-
}
|
24
|
-
throw new Error(`${address} is not a valid address.`);
|
25
|
-
}
|