@orb-labs/orby-core 0.0.13 → 0.0.15
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/actions/operation.d.ts +1 -1
- package/dist/actions/operation.js +5 -3
- package/dist/cjs/actions/account_cluster.d.ts +32 -0
- package/dist/cjs/actions/account_cluster.js +211 -0
- package/dist/cjs/actions/admin.d.ts +17 -0
- package/dist/cjs/actions/admin.js +43 -0
- package/dist/cjs/actions/application.d.ts +6 -0
- package/dist/cjs/actions/application.js +20 -0
- package/dist/cjs/actions/blockchain.d.ts +16 -0
- package/dist/cjs/actions/blockchain.js +39 -0
- package/dist/cjs/actions/instance.d.ts +15 -0
- package/dist/cjs/actions/instance.js +98 -0
- package/dist/cjs/actions/operation.d.ts +99 -0
- package/dist/cjs/actions/operation.js +345 -0
- package/dist/cjs/actions/token.d.ts +15 -0
- package/dist/cjs/actions/token.js +50 -0
- package/dist/cjs/constants.d.ts +14 -0
- package/dist/cjs/constants.js +139 -0
- package/dist/cjs/entities/account.d.ts +14 -0
- package/dist/cjs/entities/account.js +49 -0
- package/dist/cjs/entities/financial/account_balance.d.ts +12 -0
- package/dist/cjs/entities/financial/account_balance.js +35 -0
- package/dist/cjs/entities/financial/asset.d.ts +31 -0
- package/dist/cjs/entities/financial/asset.js +42 -0
- package/dist/cjs/entities/financial/currency.d.ts +41 -0
- package/dist/cjs/entities/financial/currency.js +56 -0
- package/dist/cjs/entities/financial/currency_amount.d.ts +34 -0
- package/dist/cjs/entities/financial/currency_amount.js +99 -0
- package/dist/cjs/entities/financial/fungible_token.d.ts +41 -0
- package/dist/cjs/entities/financial/fungible_token.js +68 -0
- package/dist/cjs/entities/financial/fungible_token_amount.d.ts +36 -0
- package/dist/cjs/entities/financial/fungible_token_amount.js +102 -0
- package/dist/cjs/entities/financial/non_fungible_token.d.ts +39 -0
- package/dist/cjs/entities/financial/non_fungible_token.js +65 -0
- package/dist/cjs/entities/financial/semi_fungible_token.d.ts +41 -0
- package/dist/cjs/entities/financial/semi_fungible_token.js +67 -0
- package/dist/cjs/entities/library_request.d.ts +8 -0
- package/dist/cjs/entities/library_request.js +37 -0
- package/dist/cjs/entities/state.d.ts +22 -0
- package/dist/cjs/entities/state.js +106 -0
- package/dist/cjs/enums.d.ts +116 -0
- package/dist/cjs/enums.js +138 -0
- package/dist/cjs/index.d.ts +29 -0
- package/dist/cjs/index.js +49 -0
- package/dist/cjs/interfaces/account_cluster.d.ts +30 -0
- package/dist/cjs/interfaces/account_cluster.js +2 -0
- package/dist/cjs/interfaces/admin.d.ts +14 -0
- package/dist/cjs/interfaces/admin.js +2 -0
- package/dist/cjs/interfaces/application.d.ts +3 -0
- package/dist/cjs/interfaces/application.js +2 -0
- package/dist/cjs/interfaces/blockchain.d.ts +13 -0
- package/dist/cjs/interfaces/blockchain.js +2 -0
- package/dist/cjs/interfaces/instance.d.ts +12 -0
- package/dist/cjs/interfaces/instance.js +2 -0
- package/dist/cjs/interfaces/operation.d.ts +97 -0
- package/dist/cjs/interfaces/operation.js +2 -0
- package/dist/cjs/interfaces/orby.d.ts +9 -0
- package/dist/cjs/interfaces/orby.js +2 -0
- package/dist/cjs/interfaces/token.d.ts +12 -0
- package/dist/cjs/interfaces/token.js +2 -0
- package/dist/cjs/types.d.ts +152 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils/action_helpers.d.ts +22 -0
- package/dist/cjs/utils/action_helpers.js +274 -0
- package/dist/cjs/utils/utils.d.ts +10 -0
- package/dist/cjs/utils/utils.js +79 -0
- package/dist/cjs/utils/validateAndParseAddress.d.ts +10 -0
- package/dist/cjs/utils/validateAndParseAddress.js +29 -0
- package/dist/esm/actions/account_cluster.d.ts +32 -0
- package/dist/esm/actions/account_cluster.js +207 -0
- package/dist/esm/actions/admin.d.ts +17 -0
- package/dist/esm/actions/admin.js +39 -0
- package/dist/esm/actions/application.d.ts +6 -0
- package/dist/esm/actions/application.js +16 -0
- package/dist/esm/actions/blockchain.d.ts +16 -0
- package/dist/esm/actions/blockchain.js +35 -0
- package/dist/esm/actions/instance.d.ts +15 -0
- package/dist/esm/actions/instance.js +94 -0
- package/dist/esm/actions/operation.d.ts +99 -0
- package/dist/esm/actions/operation.js +341 -0
- package/dist/esm/actions/token.d.ts +15 -0
- package/dist/esm/actions/token.js +46 -0
- package/dist/esm/constants.d.ts +14 -0
- package/dist/esm/constants.js +133 -0
- package/dist/esm/entities/account.d.ts +14 -0
- package/dist/esm/entities/account.js +45 -0
- package/dist/esm/entities/financial/account_balance.d.ts +12 -0
- package/dist/esm/entities/financial/account_balance.js +31 -0
- package/dist/esm/entities/financial/asset.d.ts +31 -0
- package/dist/esm/entities/financial/asset.js +38 -0
- package/dist/esm/entities/financial/currency.d.ts +41 -0
- package/dist/esm/entities/financial/currency.js +49 -0
- package/dist/esm/entities/financial/currency_amount.d.ts +34 -0
- package/dist/esm/entities/financial/currency_amount.js +92 -0
- package/dist/esm/entities/financial/fungible_token.d.ts +41 -0
- package/dist/esm/entities/financial/fungible_token.js +64 -0
- package/dist/esm/entities/financial/fungible_token_amount.d.ts +36 -0
- package/dist/esm/entities/financial/fungible_token_amount.js +95 -0
- package/dist/esm/entities/financial/non_fungible_token.d.ts +39 -0
- package/dist/esm/entities/financial/non_fungible_token.js +61 -0
- package/dist/esm/entities/financial/semi_fungible_token.d.ts +41 -0
- package/dist/esm/entities/financial/semi_fungible_token.js +63 -0
- package/dist/esm/entities/library_request.d.ts +8 -0
- package/dist/esm/entities/library_request.js +30 -0
- package/dist/esm/entities/state.d.ts +22 -0
- package/dist/esm/entities/state.js +102 -0
- package/dist/esm/enums.d.ts +116 -0
- package/dist/esm/enums.js +135 -0
- package/dist/esm/index.d.ts +29 -0
- package/dist/esm/index.js +33 -0
- package/dist/esm/interfaces/account_cluster.d.ts +30 -0
- package/dist/esm/interfaces/account_cluster.js +1 -0
- package/dist/esm/interfaces/admin.d.ts +14 -0
- package/dist/esm/interfaces/admin.js +1 -0
- package/dist/esm/interfaces/application.d.ts +3 -0
- package/dist/esm/interfaces/application.js +1 -0
- package/dist/esm/interfaces/blockchain.d.ts +13 -0
- package/dist/esm/interfaces/blockchain.js +1 -0
- package/dist/esm/interfaces/instance.d.ts +12 -0
- package/dist/esm/interfaces/instance.js +1 -0
- package/dist/esm/interfaces/operation.d.ts +97 -0
- package/dist/esm/interfaces/operation.js +1 -0
- package/dist/esm/interfaces/orby.d.ts +9 -0
- package/dist/esm/interfaces/orby.js +1 -0
- package/dist/esm/interfaces/token.d.ts +12 -0
- package/dist/esm/interfaces/token.js +1 -0
- package/dist/esm/types.d.ts +152 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/action_helpers.d.ts +22 -0
- package/dist/esm/utils/action_helpers.js +250 -0
- package/dist/esm/utils/utils.d.ts +10 -0
- package/dist/esm/utils/utils.js +70 -0
- package/dist/esm/utils/validateAndParseAddress.d.ts +10 -0
- package/dist/esm/utils/validateAndParseAddress.js +25 -0
- package/dist/interfaces/operation.d.ts +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/action_helpers.js +1 -1
- package/package.json +16 -7
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isMainnet = exports.getBlockchainFromName = exports.hasError = exports.getBlockchainIdFromBlockchain = exports.getOrbyChainId = exports.getChainIdFromOrbyChainId = void 0;
|
4
|
+
const enums_js_1 = require("../enums.js");
|
5
|
+
const constants_js_1 = require("../constants.js");
|
6
|
+
const getChainIdFromOrbyChainId = (value) => {
|
7
|
+
let chainId = undefined;
|
8
|
+
const formattedValue = value?.trim()?.toLowerCase();
|
9
|
+
if (formattedValue?.includes("eip155")) {
|
10
|
+
const publicIdElements = formattedValue.split("eip155-");
|
11
|
+
const potentialId = publicIdElements?.length > 1 ? publicIdElements[1] : undefined;
|
12
|
+
chainId = !Number.isNaN(Number(potentialId))
|
13
|
+
? BigInt(potentialId)
|
14
|
+
: undefined;
|
15
|
+
}
|
16
|
+
else {
|
17
|
+
const blockchain = (0, exports.getBlockchainFromName)(formattedValue);
|
18
|
+
const potentialId = blockchain
|
19
|
+
? (0, exports.getBlockchainIdFromBlockchain)(blockchain)
|
20
|
+
: undefined;
|
21
|
+
chainId = potentialId ? BigInt(potentialId) : undefined;
|
22
|
+
}
|
23
|
+
return chainId;
|
24
|
+
};
|
25
|
+
exports.getChainIdFromOrbyChainId = getChainIdFromOrbyChainId;
|
26
|
+
const getOrbyChainId = (chainId) => {
|
27
|
+
if (!chainId) {
|
28
|
+
return undefined;
|
29
|
+
}
|
30
|
+
return `EIP155-${chainId.toString()}`;
|
31
|
+
};
|
32
|
+
exports.getOrbyChainId = getOrbyChainId;
|
33
|
+
const getBlockchainIdFromBlockchain = (blockchain) => {
|
34
|
+
return constants_js_1.BLOCKCHAIN_ID[blockchain];
|
35
|
+
};
|
36
|
+
exports.getBlockchainIdFromBlockchain = getBlockchainIdFromBlockchain;
|
37
|
+
const hasError = (data) => {
|
38
|
+
if (data?.code && data?.message) {
|
39
|
+
return { code: data.code, message: data.message };
|
40
|
+
}
|
41
|
+
return undefined;
|
42
|
+
};
|
43
|
+
exports.hasError = hasError;
|
44
|
+
const getBlockchainFromName = (chainName) => {
|
45
|
+
const formattedChainName = chainName?.toLowerCase()?.replace("-", "_");
|
46
|
+
switch (formattedChainName) {
|
47
|
+
case "bnbt": {
|
48
|
+
return enums_js_1.Blockchain.BINANCE_TESTNET;
|
49
|
+
}
|
50
|
+
case "matic_amoy": {
|
51
|
+
return enums_js_1.Blockchain.POLYGON_AMOY;
|
52
|
+
}
|
53
|
+
case "matic": {
|
54
|
+
return enums_js_1.Blockchain.POLYGON;
|
55
|
+
}
|
56
|
+
case "mainnet": {
|
57
|
+
return enums_js_1.Blockchain.ETHEREUM;
|
58
|
+
}
|
59
|
+
case "holesky": {
|
60
|
+
return enums_js_1.Blockchain.ETHEREUM_HOLESKY;
|
61
|
+
}
|
62
|
+
case "sepolia": {
|
63
|
+
return enums_js_1.Blockchain.ETHEREUM_SEPOLIA;
|
64
|
+
}
|
65
|
+
case "unknown": {
|
66
|
+
return undefined;
|
67
|
+
}
|
68
|
+
default: {
|
69
|
+
//statements;
|
70
|
+
return formattedChainName;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
};
|
74
|
+
exports.getBlockchainFromName = getBlockchainFromName;
|
75
|
+
const isMainnet = (chainId) => {
|
76
|
+
const blockchain = constants_js_1.BLOCKCHAIN_ID_TO_BLOCKCHAIN[Number(chainId)];
|
77
|
+
return constants_js_1.CHAIN_CONFIGS[blockchain].environment == enums_js_1.BlockchainEnvironment.MAINNET;
|
78
|
+
};
|
79
|
+
exports.isMainnet = isMainnet;
|
@@ -0,0 +1,10 @@
|
|
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;
|
@@ -0,0 +1,29 @@
|
|
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");
|
6
|
+
/**
|
7
|
+
* Validates an address and returns the parsed (checksummed) version of that address
|
8
|
+
* @param address the unchecksummed hex address
|
9
|
+
*/
|
10
|
+
function validateAndParseAddress(address) {
|
11
|
+
try {
|
12
|
+
return (0, address_1.getAddress)(address);
|
13
|
+
}
|
14
|
+
catch (error) {
|
15
|
+
throw new Error(`${address} is not a valid address.`);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
// 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}$/;
|
20
|
+
/**
|
21
|
+
* Checks if an address is valid by checking 0x prefix, length === 42 and hex encoding.
|
22
|
+
* @param address the unchecksummed hex address
|
23
|
+
*/
|
24
|
+
function checkValidAddress(address) {
|
25
|
+
if (startsWith0xLen42HexRegex.test(address)) {
|
26
|
+
return address;
|
27
|
+
}
|
28
|
+
throw new Error(`${address} is not a valid address.`);
|
29
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Account } from "../entities/account.js";
|
2
|
+
import { AccountCluster, Activity, ChainEndpoint, FungibleTokenOverview, StandardizedBalance, VirtualNodeRpcUrlForSupportedChain } from "../types.js";
|
3
|
+
import { ChainSupportStatus, LIBRARY_TYPE, Order } from "../enums.js";
|
4
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
5
|
+
export declare class AccountClusterActions extends LibraryRequest {
|
6
|
+
constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
|
7
|
+
createAccountCluster(accounts: Account[]): Promise<AccountCluster>;
|
8
|
+
addToAccountCluster(accounts: Account[], accountClusterId: string): Promise<AccountCluster>;
|
9
|
+
removeFromAccountCluster(accounts: Account[], accountClusterId: string): Promise<AccountCluster>;
|
10
|
+
getVirtualNodeRpcUrlsForSupportedChains(accountClusterId: string): Promise<VirtualNodeRpcUrlForSupportedChain[]>;
|
11
|
+
enableChainAbstractionForAccountCluster(accountClusterId: string, enable: boolean): Promise<boolean>;
|
12
|
+
setCustomChainEndpointsForAccountCluster(accountClusterId: string, chainEndpoints: ChainEndpoint[]): Promise<boolean>;
|
13
|
+
removeCustomChainEndpointsForAccountCluster(accountClusterId: string, chainIds: bigint[]): Promise<boolean>;
|
14
|
+
getCustomChainEndpointsForAccountCluster(accountClusterId: string, returnChainIdsOnly: boolean): Promise<ChainEndpoint[]>;
|
15
|
+
isChainSupportedOnAccountCluster(accountClusterId: string, chainId: bigint): Promise<ChainSupportStatus>;
|
16
|
+
getNodeRpcUrl(accountClusterId: string, chainId: bigint): Promise<string>;
|
17
|
+
getVirtualNodeRpcUrl(accountClusterId: string, chainId: bigint, entrypointAccountAddress: string): Promise<string>;
|
18
|
+
getActivity(accountClusterId: string, limit?: number, offset?: number, order?: Order, startDate?: number, endDate?: number, filters?: {
|
19
|
+
transactionHash?: string;
|
20
|
+
address?: string;
|
21
|
+
}[]): Promise<{
|
22
|
+
activities: Activity[];
|
23
|
+
pageInfo: {
|
24
|
+
hasNextPage: boolean;
|
25
|
+
hasPreviousPage: boolean;
|
26
|
+
totalCount: number;
|
27
|
+
};
|
28
|
+
}>;
|
29
|
+
getPortfolioOverview(accountClusterId: string): Promise<FungibleTokenOverview>;
|
30
|
+
getFungibleTokenPortfolio(accountClusterId: string): Promise<StandardizedBalance[]>;
|
31
|
+
getFungibleTokenBalances(accountClusterId: string, offset?: number, limit?: number, chainId?: bigint, tokensToOmit?: string[]): Promise<StandardizedBalance[]>;
|
32
|
+
}
|
@@ -0,0 +1,207 @@
|
|
1
|
+
import { extractAccountCluster, extractActivities, extractFungibleTokenOverview, extractStandardizedBalances, } from "../utils/action_helpers.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
import { getChainIdFromOrbyChainId, getOrbyChainId } from "../utils/utils.js";
|
4
|
+
export class AccountClusterActions extends LibraryRequest {
|
5
|
+
constructor(library, client, provider) {
|
6
|
+
super(library, client, provider);
|
7
|
+
}
|
8
|
+
async createAccountCluster(accounts) {
|
9
|
+
const formattedAccounts = accounts.map((account) => account.toAccountModel());
|
10
|
+
const accountCluster = await this.sendRequest("orby_createAccountCluster", [
|
11
|
+
{
|
12
|
+
accounts: formattedAccounts,
|
13
|
+
},
|
14
|
+
]);
|
15
|
+
return extractAccountCluster(accountCluster);
|
16
|
+
}
|
17
|
+
async addToAccountCluster(accounts, accountClusterId) {
|
18
|
+
const formattedAccounts = accounts.map((account) => account.toAccountModel());
|
19
|
+
const accountCluster = await this.sendRequest("orby_addToAccountCluster", [
|
20
|
+
{
|
21
|
+
accounts: formattedAccounts,
|
22
|
+
accountClusterId,
|
23
|
+
},
|
24
|
+
]);
|
25
|
+
return extractAccountCluster(accountCluster);
|
26
|
+
}
|
27
|
+
async removeFromAccountCluster(accounts, accountClusterId) {
|
28
|
+
const formattedAccounts = accounts.map((account) => account.toAccountModel());
|
29
|
+
const accountCluster = await this.sendRequest("orby_removeFromAccountCluster", [
|
30
|
+
{
|
31
|
+
accounts: formattedAccounts,
|
32
|
+
accountClusterId,
|
33
|
+
},
|
34
|
+
]);
|
35
|
+
return extractAccountCluster(accountCluster);
|
36
|
+
}
|
37
|
+
async getVirtualNodeRpcUrlsForSupportedChains(accountClusterId) {
|
38
|
+
const { virtualNodeRpcUrlsForSupportedChains, message, code } = await this.sendRequest("orby_getVirtualNodeRpcUrlsForSupportedChains", [
|
39
|
+
{
|
40
|
+
accountClusterId,
|
41
|
+
},
|
42
|
+
]);
|
43
|
+
if (code && message) {
|
44
|
+
console.error("[getVirtualNodeRpcUrlsForSupportedChains]", code, message);
|
45
|
+
return undefined;
|
46
|
+
}
|
47
|
+
return virtualNodeRpcUrlsForSupportedChains.map((info) => {
|
48
|
+
return {
|
49
|
+
chainId: getChainIdFromOrbyChainId(info.chainId),
|
50
|
+
virtualNodeRpcUrl: info.virtualNodeRpcUrl,
|
51
|
+
entrypointAccountAddress: info?.entrypointAccountAddress?.toLowerCase(),
|
52
|
+
};
|
53
|
+
});
|
54
|
+
}
|
55
|
+
async enableChainAbstractionForAccountCluster(accountClusterId, enable) {
|
56
|
+
const { success, message, code } = await this.sendRequest("orby_enableChainAbstractionForAccountCluster", [
|
57
|
+
{
|
58
|
+
accountClusterId,
|
59
|
+
enable,
|
60
|
+
},
|
61
|
+
]);
|
62
|
+
if (code && message) {
|
63
|
+
console.error("[enableChainAbstractionForAccountCluster]", code, message);
|
64
|
+
return undefined;
|
65
|
+
}
|
66
|
+
return success;
|
67
|
+
}
|
68
|
+
async setCustomChainEndpointsForAccountCluster(accountClusterId, chainEndpoints) {
|
69
|
+
const formattedEndpoints = chainEndpoints.map((endpoint) => {
|
70
|
+
return {
|
71
|
+
chainId: getOrbyChainId(endpoint.chainId),
|
72
|
+
customRpcUrls: endpoint.customRpcUrls,
|
73
|
+
customIndexerUrls: endpoint.customIndexerUrls,
|
74
|
+
};
|
75
|
+
});
|
76
|
+
const { success, message, code } = await this.sendRequest("orby_setCustomChainEndpointsForAccountCluster", [
|
77
|
+
{
|
78
|
+
accountClusterId,
|
79
|
+
chainEndpoints: formattedEndpoints,
|
80
|
+
},
|
81
|
+
]);
|
82
|
+
if (code && message) {
|
83
|
+
console.error("[setCustomChainEndpointsForAccountCluster]", code, message);
|
84
|
+
return undefined;
|
85
|
+
}
|
86
|
+
return success;
|
87
|
+
}
|
88
|
+
async removeCustomChainEndpointsForAccountCluster(accountClusterId, chainIds) {
|
89
|
+
const formattedChainIds = chainIds.map((chainId) => getOrbyChainId(chainId));
|
90
|
+
const { success, message, code } = await this.sendRequest("orby_removeCustomChainEndpointsForAccountCluster", [
|
91
|
+
{
|
92
|
+
accountClusterId,
|
93
|
+
chainIds: formattedChainIds,
|
94
|
+
},
|
95
|
+
]);
|
96
|
+
if (code && message) {
|
97
|
+
console.error("[removeCustomChainEndpointsForAccountCluster]", code, message);
|
98
|
+
return undefined;
|
99
|
+
}
|
100
|
+
return success;
|
101
|
+
}
|
102
|
+
async getCustomChainEndpointsForAccountCluster(accountClusterId, returnChainIdsOnly) {
|
103
|
+
const { chainEndpoints, message, code } = await this.sendRequest("orby_getCustomChainEndpointsForAccountCluster", [
|
104
|
+
{
|
105
|
+
accountClusterId,
|
106
|
+
returnChainIdsOnly,
|
107
|
+
},
|
108
|
+
]);
|
109
|
+
if (code && message) {
|
110
|
+
console.error("[getCustomChainEndpointsForAccountCluster]", code, message);
|
111
|
+
return undefined;
|
112
|
+
}
|
113
|
+
return chainEndpoints.map((endpoint) => {
|
114
|
+
return {
|
115
|
+
chainId: getChainIdFromOrbyChainId(endpoint.chainId),
|
116
|
+
customRpcUrls: endpoint.customRpcUrls,
|
117
|
+
customIndexerUrls: endpoint.customIndexerUrls,
|
118
|
+
};
|
119
|
+
});
|
120
|
+
}
|
121
|
+
async isChainSupportedOnAccountCluster(accountClusterId, chainId) {
|
122
|
+
const { supportStatus, message, code } = await this.sendRequest("orby_isChainSupportedOnAccountCluster", [
|
123
|
+
{
|
124
|
+
accountClusterId,
|
125
|
+
chainId: getOrbyChainId(chainId),
|
126
|
+
},
|
127
|
+
]);
|
128
|
+
if (code && message) {
|
129
|
+
console.error("[isChainSupportedOnAccountCluster]", code, message);
|
130
|
+
return undefined;
|
131
|
+
}
|
132
|
+
return supportStatus;
|
133
|
+
}
|
134
|
+
async getNodeRpcUrl(accountClusterId, chainId) {
|
135
|
+
const { nodeRpcUrl, code, message } = await this.sendRequest("orby_getNodeRpcUrl", [
|
136
|
+
{
|
137
|
+
accountClusterId,
|
138
|
+
chainId: getOrbyChainId(chainId),
|
139
|
+
},
|
140
|
+
]);
|
141
|
+
if (code && message) {
|
142
|
+
console.error("[getNodeRpcUrl]", code, message);
|
143
|
+
return undefined;
|
144
|
+
}
|
145
|
+
return nodeRpcUrl;
|
146
|
+
}
|
147
|
+
async getVirtualNodeRpcUrl(accountClusterId, chainId, entrypointAccountAddress) {
|
148
|
+
const { virtualNodeRpcUrl, message, code } = await this.sendRequest("orby_getVirtualNodeRpcUrl", [
|
149
|
+
{
|
150
|
+
accountClusterId,
|
151
|
+
chainId: getOrbyChainId(chainId),
|
152
|
+
entrypointAccountAddress,
|
153
|
+
},
|
154
|
+
]);
|
155
|
+
if (code && message) {
|
156
|
+
console.error("[getVirtualNodeRpcUrl]", code, message);
|
157
|
+
return undefined;
|
158
|
+
}
|
159
|
+
return virtualNodeRpcUrl;
|
160
|
+
}
|
161
|
+
async getActivity(accountClusterId, limit, offset, order, startDate, endDate, filters) {
|
162
|
+
const { pageInfo, edges, code, message } = await this.sendRequest("orby_getActivity", [
|
163
|
+
{
|
164
|
+
accountClusterId,
|
165
|
+
limit,
|
166
|
+
offset,
|
167
|
+
order,
|
168
|
+
startDate,
|
169
|
+
endDate,
|
170
|
+
filters,
|
171
|
+
},
|
172
|
+
]);
|
173
|
+
if (code && message) {
|
174
|
+
console.error("[getActivity]", code, message);
|
175
|
+
return undefined;
|
176
|
+
}
|
177
|
+
return { activities: extractActivities(edges), pageInfo };
|
178
|
+
}
|
179
|
+
async getPortfolioOverview(accountClusterId) {
|
180
|
+
const fungibleTokenOverview = await this.sendRequest("orby_getPortfolioOverview", [{ accountClusterId }]);
|
181
|
+
return extractFungibleTokenOverview(fungibleTokenOverview);
|
182
|
+
}
|
183
|
+
async getFungibleTokenPortfolio(accountClusterId) {
|
184
|
+
const { fungibleTokenBalances, code, message } = await this.sendRequest("orby_getFungibleTokenPortfolio", [{ accountClusterId }]);
|
185
|
+
if (code && message) {
|
186
|
+
console.error("[getFungibleTokenPortfolio]", code, message);
|
187
|
+
return undefined;
|
188
|
+
}
|
189
|
+
return extractStandardizedBalances(fungibleTokenBalances);
|
190
|
+
}
|
191
|
+
async getFungibleTokenBalances(accountClusterId, offset, limit, chainId, tokensToOmit) {
|
192
|
+
const { fungibleTokenBalances, code, message } = await this.sendRequest("orby_getFungibleTokenBalances", [
|
193
|
+
{
|
194
|
+
accountClusterId,
|
195
|
+
offset,
|
196
|
+
limit,
|
197
|
+
chainId: chainId ? getOrbyChainId(chainId) : undefined,
|
198
|
+
tokensToOmit,
|
199
|
+
},
|
200
|
+
]);
|
201
|
+
if (code && message) {
|
202
|
+
console.error("[getFungibleTokenBalances]", code, message);
|
203
|
+
return undefined;
|
204
|
+
}
|
205
|
+
return extractStandardizedBalances(fungibleTokenBalances);
|
206
|
+
}
|
207
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { GasSpendForInstance, GasSponsorshipData } from "../types.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
import { LIBRARY_TYPE } from "../enums.js";
|
4
|
+
export declare class AdminActions extends LibraryRequest {
|
5
|
+
constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
|
6
|
+
createInstance(name: string): Promise<{
|
7
|
+
success: boolean;
|
8
|
+
orbyInstancePrivateUrl: string;
|
9
|
+
orbyInstancePublicUrl: string;
|
10
|
+
}>;
|
11
|
+
getInstanceUrls(name: string): Promise<{
|
12
|
+
orbyInstancePrivateUrl: string;
|
13
|
+
orbyInstancePublicUrl: string;
|
14
|
+
}>;
|
15
|
+
getGasSpentForCustomer(month: string, year: string): Promise<GasSponsorshipData>;
|
16
|
+
getGasSpentForInstances(month: string, year: string, instanceNames: string[]): Promise<GasSpendForInstance[]>;
|
17
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { extractGasSpendForInstances, extractGasSponsorshipData, } from "../utils/action_helpers.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
export class AdminActions extends LibraryRequest {
|
4
|
+
constructor(library, client, provider) {
|
5
|
+
super(library, client, provider);
|
6
|
+
}
|
7
|
+
async createInstance(name) {
|
8
|
+
const result = await this.sendRequest("orby_createInstance", [{ name }]);
|
9
|
+
if (result.code && result.message) {
|
10
|
+
console.error("[createInstance]", result.code, result.message);
|
11
|
+
return undefined;
|
12
|
+
}
|
13
|
+
return result;
|
14
|
+
}
|
15
|
+
async getInstanceUrls(name) {
|
16
|
+
const result = await this.sendRequest("orby_getInstanceUrls", [{ name }]);
|
17
|
+
if (result.code && result.message) {
|
18
|
+
console.error("[getInstanceUrls]", result.code, result.message);
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
return result;
|
22
|
+
}
|
23
|
+
async getGasSpentForCustomer(month, year) {
|
24
|
+
const { totalGasSpentForCustomer, code, message } = await this.sendRequest("orby_getGasSpentForCustomer", [{ month, year }]);
|
25
|
+
if (code && message) {
|
26
|
+
console.error("[getGasSpentForCustomer]", code, message);
|
27
|
+
return undefined;
|
28
|
+
}
|
29
|
+
return extractGasSponsorshipData(totalGasSpentForCustomer);
|
30
|
+
}
|
31
|
+
async getGasSpentForInstances(month, year, instanceNames) {
|
32
|
+
const { totalGasSpendForInstances, code, message } = await this.sendRequest("orby_getGasSpentForInstances", [{ month, year, instanceNames }]);
|
33
|
+
if (code && message) {
|
34
|
+
console.error("[getGasSpentForInstances]", code, message);
|
35
|
+
return undefined;
|
36
|
+
}
|
37
|
+
return extractGasSpendForInstances(totalGasSpendForInstances);
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
2
|
+
import { LIBRARY_TYPE } from "../enums.js";
|
3
|
+
export declare class ApplicationActions extends LibraryRequest {
|
4
|
+
constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
|
5
|
+
isChainAbstractionCompatible(appDomainUrl: string): Promise<boolean>;
|
6
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
2
|
+
export class ApplicationActions extends LibraryRequest {
|
3
|
+
constructor(library, client, provider) {
|
4
|
+
super(library, client, provider);
|
5
|
+
}
|
6
|
+
async isChainAbstractionCompatible(appDomainUrl) {
|
7
|
+
const { isChainAbstractionCompatible, code, message } = await this.sendRequest("orby_isChainAbstractionCompatible", [
|
8
|
+
{ appDomainUrl },
|
9
|
+
]);
|
10
|
+
if (code && message) {
|
11
|
+
console.error("[isChainAbstractionCompatible]", code, message);
|
12
|
+
return undefined;
|
13
|
+
}
|
14
|
+
return isChainAbstractionCompatible;
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { BlockchainInformation } from "../types.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
import { LIBRARY_TYPE } from "../enums.js";
|
4
|
+
export declare class BlockchainActions extends LibraryRequest {
|
5
|
+
constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
|
6
|
+
getBlockchainInformation(chainId: bigint): Promise<BlockchainInformation>;
|
7
|
+
listBlockchainsInformation(offset?: number, limit?: number): Promise<{
|
8
|
+
blockchains: BlockchainInformation[];
|
9
|
+
pageInfo: {
|
10
|
+
hasNextPage: boolean;
|
11
|
+
hasPreviousPage: boolean;
|
12
|
+
totalCount: number;
|
13
|
+
};
|
14
|
+
}>;
|
15
|
+
getChainsSupportedByDefault(): Promise<BlockchainInformation[]>;
|
16
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { extractBlockchainInformation, extractBlockchainInformations, } from "../utils/action_helpers.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
import { getOrbyChainId } from "../utils/utils.js";
|
4
|
+
export class BlockchainActions extends LibraryRequest {
|
5
|
+
constructor(library, client, provider) {
|
6
|
+
super(library, client, provider);
|
7
|
+
}
|
8
|
+
async getBlockchainInformation(chainId) {
|
9
|
+
const { blockchain, code, message } = await this.sendRequest("orby_getBlockchainInformation", [{ chainId: getOrbyChainId(chainId) }]);
|
10
|
+
if (code && message) {
|
11
|
+
console.error("[getBlockchainInformation]", code, message);
|
12
|
+
return undefined;
|
13
|
+
}
|
14
|
+
return extractBlockchainInformation(blockchain);
|
15
|
+
}
|
16
|
+
async listBlockchainsInformation(offset, limit) {
|
17
|
+
const { pageInfo, edges, code, message } = await this.sendRequest("orby_listBlockchainsInformation", [{ offset, limit }]);
|
18
|
+
if (code && message) {
|
19
|
+
console.error("[listBlockchainsInformation]", code, message);
|
20
|
+
return undefined;
|
21
|
+
}
|
22
|
+
return {
|
23
|
+
blockchains: extractBlockchainInformations(edges),
|
24
|
+
pageInfo,
|
25
|
+
};
|
26
|
+
}
|
27
|
+
async getChainsSupportedByDefault() {
|
28
|
+
const { blockchains, code, message } = await this.sendRequest("orby_getChainsSupportedByDefault", []);
|
29
|
+
if (code && message) {
|
30
|
+
console.error("[getChainsSupportedByDefault]", code, message);
|
31
|
+
return undefined;
|
32
|
+
}
|
33
|
+
return extractBlockchainInformations(blockchains);
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { ChainEndpoint, GasSponsorshipPolicy } from "../types.js";
|
2
|
+
import { LIBRARY_TYPE } from "../enums.js";
|
3
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
4
|
+
export declare class InstanceActions extends LibraryRequest {
|
5
|
+
constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
|
6
|
+
setCustomChainEndpointsForInstance(chainEndpoints: ChainEndpoint[]): Promise<boolean>;
|
7
|
+
removeCustomChainEndpointForInstance(chainIds: bigint[]): Promise<boolean>;
|
8
|
+
getCustomChainEndpointsForInstance(returnChainIdsOnly: boolean): Promise<boolean>;
|
9
|
+
enableChainAbstractionForInstance(enable: boolean): Promise<boolean>;
|
10
|
+
enableGasSponsorshipForInstance(enable: boolean): Promise<boolean>;
|
11
|
+
getGasSponsorForInstance(): Promise<string>;
|
12
|
+
getOrbyGasSponsorPolicyForInstance(): Promise<GasSponsorshipPolicy>;
|
13
|
+
setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy: GasSponsorshipPolicy): Promise<boolean>;
|
14
|
+
removeOrbyGasSponsorPolicyForInstance(): Promise<boolean>;
|
15
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
import { extractGasSponsorshipPolicy } from "../utils/action_helpers.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
import { getChainIdFromOrbyChainId, getOrbyChainId } from "../utils/utils.js";
|
4
|
+
export class InstanceActions extends LibraryRequest {
|
5
|
+
constructor(library, client, provider) {
|
6
|
+
super(library, client, provider);
|
7
|
+
}
|
8
|
+
async setCustomChainEndpointsForInstance(chainEndpoints) {
|
9
|
+
const formattedEndpoints = chainEndpoints.map((endpoint) => {
|
10
|
+
return {
|
11
|
+
chainId: getOrbyChainId(endpoint.chainId),
|
12
|
+
customRpcUrls: endpoint.customRpcUrls,
|
13
|
+
customIndexerUrls: endpoint.customIndexerUrls,
|
14
|
+
};
|
15
|
+
});
|
16
|
+
const { success, code, message } = await this.sendRequest("orby_setCustomChainEndpointsForInstance", [{ chainEndpoints: formattedEndpoints }]);
|
17
|
+
if (code && message) {
|
18
|
+
console.error("[setCustomChainEndpointsForInstance]", code, message);
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
return success;
|
22
|
+
}
|
23
|
+
async removeCustomChainEndpointForInstance(chainIds) {
|
24
|
+
const formattedChainIds = chainIds.map((chainId) => getOrbyChainId(chainId));
|
25
|
+
const { success, code, message } = await this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }]);
|
26
|
+
if (code && message) {
|
27
|
+
console.error("[removeCustomChainEndpointForInstance]", code, message);
|
28
|
+
return undefined;
|
29
|
+
}
|
30
|
+
return success;
|
31
|
+
}
|
32
|
+
async getCustomChainEndpointsForInstance(returnChainIdsOnly) {
|
33
|
+
const { chainEndpoints, code, message } = await this.sendRequest("orby_getCustomChainEndpointsForInstance", [{ returnChainIdsOnly }]);
|
34
|
+
if (code && message) {
|
35
|
+
console.error("[getCustomChainEndpointsForInstance]", code, message);
|
36
|
+
return undefined;
|
37
|
+
}
|
38
|
+
return chainEndpoints.map((endpoint) => {
|
39
|
+
return {
|
40
|
+
chainId: getChainIdFromOrbyChainId(endpoint.chainId),
|
41
|
+
customRpcUrls: endpoint.customRpcUrls,
|
42
|
+
customIndexerUrls: endpoint.customIndexerUrls,
|
43
|
+
};
|
44
|
+
});
|
45
|
+
}
|
46
|
+
async enableChainAbstractionForInstance(enable) {
|
47
|
+
const { success, code, message } = await this.sendRequest("orby_enableChainAbstractionForInstance", [{ enable }]);
|
48
|
+
if (code && message) {
|
49
|
+
console.error("[enableChainAbstractionForInstance]", code, message);
|
50
|
+
return undefined;
|
51
|
+
}
|
52
|
+
return success;
|
53
|
+
}
|
54
|
+
async enableGasSponsorshipForInstance(enable) {
|
55
|
+
const { success, code, message } = await this.sendRequest("orby_enableGasSponsorshipForInstance", [{ enable }]);
|
56
|
+
if (code && message) {
|
57
|
+
console.error("[enableGasSponsorshipForInstance]", code, message);
|
58
|
+
return undefined;
|
59
|
+
}
|
60
|
+
return success;
|
61
|
+
}
|
62
|
+
async getGasSponsorForInstance() {
|
63
|
+
const { gasSponsor, code, message } = await this.sendRequest("orby_getGasSponsorForInstance", []);
|
64
|
+
if (code && message) {
|
65
|
+
console.error("[getGasSponsorForInstance]", code, message);
|
66
|
+
return undefined;
|
67
|
+
}
|
68
|
+
return gasSponsor;
|
69
|
+
}
|
70
|
+
async getOrbyGasSponsorPolicyForInstance() {
|
71
|
+
const { gasSponsorshipPolicy, message, code } = await this.sendRequest("orby_getOrbyGasSponsorPolicyForInstance", []);
|
72
|
+
if (code && message) {
|
73
|
+
console.error("[getOrbyGasSponsorPolicyForInstance]", code, message);
|
74
|
+
return undefined;
|
75
|
+
}
|
76
|
+
return extractGasSponsorshipPolicy(gasSponsorshipPolicy);
|
77
|
+
}
|
78
|
+
async setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy) {
|
79
|
+
const { success, code, message } = await this.sendRequest("orby_setOrbyGasSponsorPolicyForInstance", [{ ...gasSponsorshipPolicy }]);
|
80
|
+
if (code && message) {
|
81
|
+
console.error("[setOrbyGasSponsorPolicyForInstance]", code, message);
|
82
|
+
return undefined;
|
83
|
+
}
|
84
|
+
return success;
|
85
|
+
}
|
86
|
+
async removeOrbyGasSponsorPolicyForInstance() {
|
87
|
+
const { success, code, message } = await this.sendRequest("orby_removeOrbyGasSponsorPolicyForInstance", []);
|
88
|
+
if (code && message) {
|
89
|
+
console.error("[removeOrbyGasSponsorPolicyForInstance]", code, message);
|
90
|
+
return undefined;
|
91
|
+
}
|
92
|
+
return success;
|
93
|
+
}
|
94
|
+
}
|