@orb-labs/orby-core 0.0.14 → 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 +4 -0
- 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/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -7
@@ -0,0 +1,30 @@
|
|
1
|
+
import { Account } from "../entities/account.js";
|
2
|
+
import { AccountCluster, Activity, ChainEndpoint, FungibleTokenOverview, StandardizedBalance, VirtualNodeRpcUrlForSupportedChain } from "../types.js";
|
3
|
+
import { ChainSupportStatus, Order } from "../enums.js";
|
4
|
+
export interface IAccountClusterActions {
|
5
|
+
createAccountCluster(accounts: Account[]): Promise<AccountCluster>;
|
6
|
+
addToAccountCluster(accounts: Account[], accountClusterId: string): Promise<AccountCluster>;
|
7
|
+
removeFromAccountCluster(accounts: Account[], accountClusterId: string): Promise<AccountCluster>;
|
8
|
+
getVirtualNodeRpcUrlsForSupportedChains(accountClusterId: string): Promise<VirtualNodeRpcUrlForSupportedChain[]>;
|
9
|
+
enableChainAbstractionForAccountCluster(accountClusterId: string, enable: boolean): Promise<boolean>;
|
10
|
+
setCustomChainEndpointsForAccountCluster(accountClusterId: string, chainEndpoints: ChainEndpoint[]): Promise<boolean>;
|
11
|
+
removeCustomChainEndpointsForAccountCluster(accountClusterId: string, chainIds: bigint[]): Promise<boolean>;
|
12
|
+
getCustomChainEndpointsForAccountCluster(accountClusterId: string, returnChainIdsOnly: boolean): Promise<ChainEndpoint[]>;
|
13
|
+
isChainSupportedOnAccountCluster(accountClusterId: string, chainId: bigint): Promise<ChainSupportStatus>;
|
14
|
+
getNodeRpcUrl(accountClusterId: string, chainId: bigint): Promise<string>;
|
15
|
+
getVirtualNodeRpcUrl(accountClusterId: string, chainId: bigint, entrypointAccountAddress: string): Promise<string>;
|
16
|
+
getActivity(accountClusterId: string, limit?: number, offset?: number, order?: Order, startDate?: number, endDate?: number, filters?: {
|
17
|
+
transactionHash?: string;
|
18
|
+
address?: string;
|
19
|
+
}[]): Promise<{
|
20
|
+
activities: Activity[];
|
21
|
+
pageInfo: {
|
22
|
+
hasNextPage: boolean;
|
23
|
+
hasPreviousPage: boolean;
|
24
|
+
totalCount: number;
|
25
|
+
};
|
26
|
+
}>;
|
27
|
+
getPortfolioOverview(accountClusterId: string): Promise<FungibleTokenOverview>;
|
28
|
+
getFungibleTokenPortfolio(accountClusterId: string): Promise<StandardizedBalance[]>;
|
29
|
+
getFungibleTokenBalances(accountClusterId: string, offset?: number, limit?: number, chainId?: bigint, tokensToOmit?: string[]): Promise<StandardizedBalance[]>;
|
30
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { GasSpendForInstance, GasSponsorshipData } from "../types.js";
|
2
|
+
export interface IAdminActions {
|
3
|
+
createInstance(name: string): Promise<{
|
4
|
+
success: boolean;
|
5
|
+
orbyInstancePrivateUrl: string;
|
6
|
+
orbyInstancePublicUrl: string;
|
7
|
+
}>;
|
8
|
+
getInstanceUrls(name: string): Promise<{
|
9
|
+
orbyInstancePrivateUrl: string;
|
10
|
+
orbyInstancePublicUrl: string;
|
11
|
+
}>;
|
12
|
+
getGasSpentForCustomer(month: string, year: string): Promise<GasSponsorshipData>;
|
13
|
+
getGasSpentForInstances(month: string, year: string, instanceNames: string[]): Promise<GasSpendForInstance[]>;
|
14
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { BlockchainInformation } from "../types.js";
|
2
|
+
export interface IBlockchainActions {
|
3
|
+
getBlockchainInformation(chainId: bigint): Promise<BlockchainInformation>;
|
4
|
+
listBlockchainsInformation(offset?: number, limit?: number): Promise<{
|
5
|
+
blockchains: BlockchainInformation[];
|
6
|
+
pageInfo: {
|
7
|
+
hasNextPage: boolean;
|
8
|
+
hasPreviousPage: boolean;
|
9
|
+
totalCount: number;
|
10
|
+
};
|
11
|
+
}>;
|
12
|
+
getChainsSupportedByDefault(chainId: bigint): Promise<BlockchainInformation[]>;
|
13
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { ChainEndpoint, GasSponsorshipPolicy } from "../types.js";
|
2
|
+
export interface IInstanceActions {
|
3
|
+
setCustomChainEndpointsForInstance(chainEndpoints: ChainEndpoint[]): Promise<boolean>;
|
4
|
+
removeCustomChainEndpointForInstance(chainIds: bigint[]): Promise<boolean>;
|
5
|
+
getCustomChainEndpointsForInstance(returnChainIdsOnly: boolean): Promise<boolean>;
|
6
|
+
enableChainAbstractionForInstance(enable: boolean): Promise<boolean>;
|
7
|
+
enableGasSponsorshipForInstance(enable: boolean): Promise<boolean>;
|
8
|
+
getGasSponsorForInstance(): Promise<string>;
|
9
|
+
getOrbyGasSponsorPolicyForInstance(): Promise<GasSponsorshipPolicy>;
|
10
|
+
setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy: GasSponsorshipPolicy): Promise<boolean>;
|
11
|
+
removeOrbyGasSponsorPolicyForInstance(): Promise<boolean>;
|
12
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import { OnchainOperation, OperationSet, OperationStatus, SignedOperation } from "../types.js";
|
2
|
+
import { CurrencyAmount } from "../entities/financial/currency_amount.js";
|
3
|
+
import { OperationStatusType, QuoteType } from "../enums.js";
|
4
|
+
export interface IOperationActions {
|
5
|
+
getOperationsToExecuteTransaction(accountClusterId: string, to: string, data: string, value?: bigint, gasToken?: {
|
6
|
+
standardizedTokenId: string;
|
7
|
+
tokenSources?: {
|
8
|
+
chainId: bigint;
|
9
|
+
address?: string;
|
10
|
+
}[];
|
11
|
+
}): Promise<OperationSet>;
|
12
|
+
getOperationsToSignTypedData(accountClusterId: string, data: string, gasToken?: {
|
13
|
+
standardizedTokenId: string;
|
14
|
+
tokenSources?: {
|
15
|
+
chainId: bigint;
|
16
|
+
address?: string;
|
17
|
+
}[];
|
18
|
+
}): Promise<OperationSet>;
|
19
|
+
getOperationsToCancelTransaction(accountClusterId: string, operationSetId: string): Promise<OperationSet>;
|
20
|
+
isTransactionPreconditionSatisfied(accountClusterId: string, to: string, data: string, value?: bigint): Promise<boolean>;
|
21
|
+
isTypedDataPreconditionSatisfied(accountClusterId: string, data: string): Promise<boolean>;
|
22
|
+
sendSignedOperations(accountClusterId: string, signedOperations: SignedOperation[]): Promise<{
|
23
|
+
operationSetId: string;
|
24
|
+
operationResponses: OperationStatus[];
|
25
|
+
}>;
|
26
|
+
getOperationStatuses(operationIds: string[]): Promise<OperationStatus[]>;
|
27
|
+
estimateFiatCostToExecuteTransaction(to: string, data: string, value?: bigint): Promise<CurrencyAmount>;
|
28
|
+
estimateFiatCostToSignTypedData(data: string): Promise<CurrencyAmount>;
|
29
|
+
getOperationsToTransferToken(accountClusterId: string, standardizedTokenId: string, amount: bigint, recipient: {
|
30
|
+
chainId: bigint;
|
31
|
+
recipientAddress: string;
|
32
|
+
}, gasToken?: {
|
33
|
+
standardizedTokenId: string;
|
34
|
+
tokenSources?: {
|
35
|
+
chainId: bigint;
|
36
|
+
address?: string;
|
37
|
+
}[];
|
38
|
+
}): Promise<OperationSet>;
|
39
|
+
getOperationsToSwap(accountClusterId: string, swapType: QuoteType, input: {
|
40
|
+
standardizedTokenId: string;
|
41
|
+
amount?: bigint;
|
42
|
+
tokenSources?: {
|
43
|
+
chainId: bigint;
|
44
|
+
address?: string;
|
45
|
+
}[];
|
46
|
+
}, output: {
|
47
|
+
standardizedTokenId: string;
|
48
|
+
amount?: bigint;
|
49
|
+
tokenDestination?: {
|
50
|
+
chainId: bigint;
|
51
|
+
address?: string;
|
52
|
+
};
|
53
|
+
}, gasToken?: {
|
54
|
+
standardizedTokenId: string;
|
55
|
+
tokenSources?: {
|
56
|
+
chainId: bigint;
|
57
|
+
address?: string;
|
58
|
+
}[];
|
59
|
+
}): Promise<OperationSet>;
|
60
|
+
getQuote(accountClusterId: string, swapType: QuoteType, input: {
|
61
|
+
standardizedTokenId: string;
|
62
|
+
amount?: bigint;
|
63
|
+
tokenSources?: {
|
64
|
+
chainId: bigint;
|
65
|
+
address?: string;
|
66
|
+
}[];
|
67
|
+
}, output: {
|
68
|
+
standardizedTokenId: string;
|
69
|
+
amount?: bigint;
|
70
|
+
tokenDestination?: {
|
71
|
+
chainId: bigint;
|
72
|
+
address?: string;
|
73
|
+
};
|
74
|
+
}): Promise<OperationSet>;
|
75
|
+
getOperationsToBridge(accountClusterId: string, standardizedTokenId: string, amount: bigint, tokenSources?: {
|
76
|
+
chainId: bigint;
|
77
|
+
address?: string;
|
78
|
+
}[], tokenDestination?: {
|
79
|
+
chainId: bigint;
|
80
|
+
address?: string;
|
81
|
+
}, gasToken?: {
|
82
|
+
standardizedTokenId: string;
|
83
|
+
tokenSources?: {
|
84
|
+
chainId: bigint;
|
85
|
+
address?: string;
|
86
|
+
}[];
|
87
|
+
}): Promise<OperationSet>;
|
88
|
+
subscribeToOperationStatuses(ids?: string[], onOperationStatusesUpdateCallback?: (statusSummary: OperationStatusType, primaryOperationStatus?: OperationStatus, allOperationStatuses?: OperationStatus[]) => void, timout?: number): {
|
89
|
+
intervalId: NodeJS.Timeout | null;
|
90
|
+
};
|
91
|
+
sendOperationSet(accountClusterId: string, operationSet: OperationSet, signOperation: (operation: OnchainOperation) => Promise<SignedOperation | undefined>): Promise<{
|
92
|
+
success: boolean;
|
93
|
+
operationSetId?: string;
|
94
|
+
primaryOperationStatus?: OperationStatus;
|
95
|
+
operationResponses?: OperationStatus[];
|
96
|
+
}>;
|
97
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { IAccountClusterActions } from "./account_cluster.js";
|
2
|
+
import { IAdminActions } from "./admin.js";
|
3
|
+
import { IApplicationActions } from "./application.js";
|
4
|
+
import { IBlockchainActions } from "./blockchain.js";
|
5
|
+
import { IInstanceActions } from "./instance.js";
|
6
|
+
import { IOperationActions } from "./operation.js";
|
7
|
+
import { ITokenActions } from "./token.js";
|
8
|
+
export interface Orby extends IAccountClusterActions, IAdminActions, IApplicationActions, IInstanceActions, IOperationActions, ITokenActions, IBlockchainActions {
|
9
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { StandardizedToken } from "../types.js";
|
2
|
+
export interface ITokenActions {
|
3
|
+
getStandardizedTokenIds(tokens: {
|
4
|
+
tokenAddress: string;
|
5
|
+
chainId: bigint;
|
6
|
+
}[]): Promise<string[]>;
|
7
|
+
getStandardizedTokens(tokens: {
|
8
|
+
tokenAddress: string;
|
9
|
+
chainId: bigint;
|
10
|
+
}[]): Promise<StandardizedToken[]>;
|
11
|
+
getFungibleTokenData(standardizedTokenIds: string[]): Promise<StandardizedToken[]>;
|
12
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,152 @@
|
|
1
|
+
import { Account } from "./entities/account.js";
|
2
|
+
import { Currency } from "./entities/financial/currency.js";
|
3
|
+
import { CurrencyAmount } from "./entities/financial/currency_amount.js";
|
4
|
+
import { FungibleToken } from "./entities/financial/fungible_token.js";
|
5
|
+
import { FungibleTokenAmount } from "./entities/financial/fungible_token_amount.js";
|
6
|
+
import { State } from "./entities/state.js";
|
7
|
+
import { ActivityStatus, BlockchainEnvironment, Category, CreateOperationsStatus, OperationDataFormat, OperationStatusType, OperationType, TimeIntervalUnits, TokenAllowlistType } from "./enums.js";
|
8
|
+
export type AccountCluster = {
|
9
|
+
accountClusterId: string;
|
10
|
+
accounts: Account[];
|
11
|
+
};
|
12
|
+
export type ChainEndpoint = {
|
13
|
+
chainId: bigint;
|
14
|
+
customRpcUrls?: string[];
|
15
|
+
customIndexerUrls?: string[];
|
16
|
+
};
|
17
|
+
export interface OperationSet {
|
18
|
+
status: CreateOperationsStatus;
|
19
|
+
primaryOperation?: OnchainOperation;
|
20
|
+
primaryOperationPreconditions?: State;
|
21
|
+
inputState?: State;
|
22
|
+
outputState?: State;
|
23
|
+
intents?: Intent[];
|
24
|
+
aggregateNetworkFeeInFiatCurrency?: CurrencyAmount;
|
25
|
+
aggregateOperationFeeInFiatCurrency?: CurrencyAmount;
|
26
|
+
aggregateEstimatedTimeInMs?: number;
|
27
|
+
}
|
28
|
+
export type Intent = {
|
29
|
+
estimatedProtocolFees?: FungibleTokenAmount;
|
30
|
+
estimatedProtocolFeesInFiatCurrency?: CurrencyAmount;
|
31
|
+
inputState?: State;
|
32
|
+
intentOperations?: OnchainOperation[];
|
33
|
+
outputState?: State;
|
34
|
+
};
|
35
|
+
export interface OnchainOperation {
|
36
|
+
chainId: bigint;
|
37
|
+
data: string;
|
38
|
+
estimatedNetworkFees?: CurrencyAmount;
|
39
|
+
estimatedNetworkFeesInFiatCurrency?: CurrencyAmount;
|
40
|
+
estimatedTimeInMs?: number;
|
41
|
+
format: OperationDataFormat;
|
42
|
+
from?: string;
|
43
|
+
gasLimit?: bigint;
|
44
|
+
gasPrice?: bigint;
|
45
|
+
inputState?: State;
|
46
|
+
maxFeePerGas?: bigint;
|
47
|
+
maxPriorityFeePerGas?: bigint;
|
48
|
+
nativeCurrency?: Currency;
|
49
|
+
nonce?: bigint;
|
50
|
+
outputState?: State;
|
51
|
+
to?: string;
|
52
|
+
txRpcUrl: string;
|
53
|
+
type: OperationType;
|
54
|
+
value?: bigint;
|
55
|
+
}
|
56
|
+
export type SignedOperation = {
|
57
|
+
type: OperationType;
|
58
|
+
signature: string;
|
59
|
+
category?: Category;
|
60
|
+
data?: string;
|
61
|
+
};
|
62
|
+
export type OperationStatus = {
|
63
|
+
blockHash?: string;
|
64
|
+
blockNumber?: bigint;
|
65
|
+
chainId?: bigint;
|
66
|
+
errorReason?: string;
|
67
|
+
hash?: string;
|
68
|
+
id?: string;
|
69
|
+
status: OperationStatusType;
|
70
|
+
type: OperationType;
|
71
|
+
};
|
72
|
+
export type Activity = {
|
73
|
+
aggregateFiatValueOfInputState?: CurrencyAmount;
|
74
|
+
aggregateFiatValueOfOutputState?: CurrencyAmount;
|
75
|
+
aggregateNetworkFeesInFiatCurrency?: CurrencyAmount;
|
76
|
+
aggregateProtocolFeesInFiatCurrency?: CurrencyAmount;
|
77
|
+
category: Category;
|
78
|
+
initiateAt?: Date;
|
79
|
+
inputState?: State;
|
80
|
+
operationStatuses: OperationStatus[];
|
81
|
+
outputState?: State;
|
82
|
+
overallStatus: ActivityStatus;
|
83
|
+
};
|
84
|
+
export type FungibleTokenOverview = {
|
85
|
+
tokenCount: number;
|
86
|
+
hiddenTokenCount: number;
|
87
|
+
totalValueInFiat: CurrencyAmount;
|
88
|
+
};
|
89
|
+
export type StandardizedBalance = {
|
90
|
+
standardizedTokenId: string;
|
91
|
+
tokenBalances: FungibleTokenAmount[];
|
92
|
+
tokenBalancesOnChains: FungibleTokenAmount[];
|
93
|
+
total: CurrencyAmount;
|
94
|
+
totalValueInFiat?: CurrencyAmount;
|
95
|
+
};
|
96
|
+
export type StandardizedToken = {
|
97
|
+
standardizedTokenId: string;
|
98
|
+
currency: Currency;
|
99
|
+
priceInFiat?: CurrencyAmount;
|
100
|
+
tokens: FungibleToken[];
|
101
|
+
};
|
102
|
+
export type BlockchainInformation = {
|
103
|
+
chainId: bigint;
|
104
|
+
environment: BlockchainEnvironment;
|
105
|
+
logoUrl?: string;
|
106
|
+
name?: string;
|
107
|
+
};
|
108
|
+
export type ContractAllowlistWithAllMethodFallback = {
|
109
|
+
contractAddress: string;
|
110
|
+
sponsoredFunctions?: string[];
|
111
|
+
};
|
112
|
+
export type TokenAllowlistWithAllMethodsFallback = {
|
113
|
+
sponsoredFunctions?: string[];
|
114
|
+
tokenAllowlistType: TokenAllowlistType;
|
115
|
+
};
|
116
|
+
export type AllowlistWithOpenFallback = {
|
117
|
+
arbitraryContractAllowlist?: ContractAllowlistWithAllMethodFallback[];
|
118
|
+
tokenAllowlist?: TokenAllowlistWithAllMethodsFallback;
|
119
|
+
};
|
120
|
+
export type TimeInterval = {
|
121
|
+
amount?: bigint;
|
122
|
+
unit: TimeIntervalUnits;
|
123
|
+
};
|
124
|
+
export type MaxAmountPerInterval = {
|
125
|
+
amount: bigint;
|
126
|
+
interval: TimeInterval;
|
127
|
+
};
|
128
|
+
export type GasSponsorshipPolicy = {
|
129
|
+
allowlistWithOpenFallback?: AllowlistWithOpenFallback;
|
130
|
+
maxGasSpendPerTransaction?: bigint;
|
131
|
+
maxTotalGasSpendForInstance?: MaxAmountPerInterval;
|
132
|
+
maxTotalGasSpendPerUser?: MaxAmountPerInterval;
|
133
|
+
maxTotalTransactionCountForInstance?: MaxAmountPerInterval;
|
134
|
+
maxTotalTransactionCountPerUser?: MaxAmountPerInterval;
|
135
|
+
};
|
136
|
+
export type GasSpendForInstance = {
|
137
|
+
instanceName?: string;
|
138
|
+
gasSpentForInstance?: GasSponsorshipData;
|
139
|
+
};
|
140
|
+
export type GasSponsorshipData = {
|
141
|
+
totalGasSpent: CurrencyAmount;
|
142
|
+
totalTransactionCount: bigint;
|
143
|
+
};
|
144
|
+
export type ChainConfigs = {
|
145
|
+
environment: BlockchainEnvironment;
|
146
|
+
chainId: bigint;
|
147
|
+
};
|
148
|
+
export type VirtualNodeRpcUrlForSupportedChain = {
|
149
|
+
chainId: string;
|
150
|
+
entrypointAccountAddress: string;
|
151
|
+
virtualNodeRpcUrl: string;
|
152
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { AccountCluster, Activity, AllowlistWithOpenFallback, BlockchainInformation, FungibleTokenOverview, GasSpendForInstance, GasSponsorshipData, GasSponsorshipPolicy, Intent, MaxAmountPerInterval, OnchainOperation, OperationSet, OperationStatus, StandardizedBalance, StandardizedToken } from "../types.js";
|
2
|
+
export declare const extractAccountCluster: (accountCluster?: any) => AccountCluster;
|
3
|
+
export declare const extractOperationSet: (operationSet?: any) => OperationSet;
|
4
|
+
export declare const extractOnchainOperation: (onchainOperation?: any) => OnchainOperation;
|
5
|
+
export declare const extractIntent: (intent?: any) => Intent;
|
6
|
+
export declare const extractOperationStatuses: (operationStatus?: any[]) => OperationStatus[];
|
7
|
+
export declare const extractOperationStatus: (status?: any) => OperationStatus;
|
8
|
+
export declare const extractActivities: (activities?: any[]) => Activity[];
|
9
|
+
export declare const extractFungibleTokenOverview: (overview?: any) => FungibleTokenOverview;
|
10
|
+
export declare const extractStandardizedBalances: (balances?: any) => StandardizedBalance[];
|
11
|
+
export declare const extractStandardizedBalance: (balance?: any) => StandardizedBalance;
|
12
|
+
export declare const extractStandardizedTokens: (tokens?: any) => StandardizedToken[];
|
13
|
+
export declare const extractStandardizedToken: (token?: any) => StandardizedToken;
|
14
|
+
export declare const extractBlockchainInformations: (blockchainInformation?: any[]) => BlockchainInformation[];
|
15
|
+
export declare const extractBlockchainInformation: (blockchainInformation?: any) => BlockchainInformation;
|
16
|
+
export declare const extractMaxAmountPerInterval: (maxAmountPerInterval?: any) => MaxAmountPerInterval;
|
17
|
+
export declare const extractAllowlistWithOpenFallback: (allowlist?: any) => AllowlistWithOpenFallback;
|
18
|
+
export declare const extractGasSponsorshipPolicy: (gasSponsorshipPolicy?: any) => GasSponsorshipPolicy;
|
19
|
+
export declare const extractGasSpendForInstances: (gasSpendForInstances?: any[]) => GasSpendForInstance[];
|
20
|
+
export declare const extractGasSpendForInstance: (gasSpendForInstance?: any) => GasSpendForInstance;
|
21
|
+
export declare const extractGasSponsorshipInformation: (gasSponsorshipData?: any[]) => GasSponsorshipData[];
|
22
|
+
export declare const extractGasSponsorshipData: (gasSponsorshipData?: any) => GasSponsorshipData;
|
@@ -0,0 +1,250 @@
|
|
1
|
+
import { CreateOperationsStatus } from "../enums.js";
|
2
|
+
import { CurrencyAmount } from "../entities/financial/currency_amount.js";
|
3
|
+
import { State } from "../entities/state.js";
|
4
|
+
import { Currency } from "../entities/financial/currency.js";
|
5
|
+
import { FungibleTokenAmount } from "../entities/financial/fungible_token_amount.js";
|
6
|
+
import { FungibleToken } from "../entities/financial/fungible_token.js";
|
7
|
+
import { Account } from "../entities/account.js";
|
8
|
+
import { getChainIdFromOrbyChainId, hasError } from "./utils.js";
|
9
|
+
export const extractAccountCluster = (accountCluster) => {
|
10
|
+
if (!accountCluster) {
|
11
|
+
return undefined;
|
12
|
+
}
|
13
|
+
else if (hasError(accountCluster)) {
|
14
|
+
console.error("[extractAccountCluster]", accountCluster.code, accountCluster.message);
|
15
|
+
return undefined;
|
16
|
+
}
|
17
|
+
return {
|
18
|
+
accountClusterId: accountCluster?.accountClusterId,
|
19
|
+
accounts: accountCluster?.accounts?.map((account) => Account.toAccount(account)),
|
20
|
+
};
|
21
|
+
};
|
22
|
+
export const extractOperationSet = (operationSet) => {
|
23
|
+
if (!operationSet) {
|
24
|
+
return undefined;
|
25
|
+
}
|
26
|
+
else if (hasError(operationSet)) {
|
27
|
+
console.error("[extractOperationSet]", operationSet);
|
28
|
+
return {
|
29
|
+
status: CreateOperationsStatus.INTERNAL,
|
30
|
+
};
|
31
|
+
}
|
32
|
+
return {
|
33
|
+
status: operationSet.status,
|
34
|
+
primaryOperation: extractOnchainOperation(operationSet.primaryOperation),
|
35
|
+
primaryOperationPreconditions: State.toState(operationSet.primaryOperationPreconditions),
|
36
|
+
inputState: State.toState(operationSet.inputState),
|
37
|
+
outputState: State.toState(operationSet.outputState),
|
38
|
+
intents: operationSet.intents?.map((intent) => extractIntent(intent)),
|
39
|
+
aggregateNetworkFeeInFiatCurrency: CurrencyAmount.toCurrencyAmount(operationSet.aggregateNetworkFeeInFiatCurrency),
|
40
|
+
aggregateOperationFeeInFiatCurrency: CurrencyAmount.toCurrencyAmount(operationSet.aggregateOperationFeeInFiatCurrency),
|
41
|
+
aggregateEstimatedTimeInMs: operationSet.aggregateEstimatedTimeInMs,
|
42
|
+
};
|
43
|
+
};
|
44
|
+
export const extractOnchainOperation = (onchainOperation) => {
|
45
|
+
if (!onchainOperation) {
|
46
|
+
return undefined;
|
47
|
+
}
|
48
|
+
return {
|
49
|
+
chainId: getChainIdFromOrbyChainId(onchainOperation.chainId),
|
50
|
+
data: onchainOperation.data,
|
51
|
+
estimatedNetworkFees: CurrencyAmount.toCurrencyAmount(onchainOperation.estimatedNetworkFees),
|
52
|
+
estimatedNetworkFeesInFiatCurrency: CurrencyAmount.toCurrencyAmount(onchainOperation.estimatedNetworkFeesInFiatCurrency),
|
53
|
+
estimatedTimeInMs: onchainOperation.estimatedTimeInMs,
|
54
|
+
format: onchainOperation.format,
|
55
|
+
from: onchainOperation.from,
|
56
|
+
gasLimit: onchainOperation.gasLimit
|
57
|
+
? BigInt(onchainOperation.gasLimit)
|
58
|
+
: undefined,
|
59
|
+
gasPrice: onchainOperation.gasPrice
|
60
|
+
? BigInt(onchainOperation.gasPrice)
|
61
|
+
: undefined,
|
62
|
+
inputState: State.toState(onchainOperation.inputState),
|
63
|
+
maxFeePerGas: onchainOperation.maxFeePerGas
|
64
|
+
? BigInt(onchainOperation.maxFeePerGas)
|
65
|
+
: undefined,
|
66
|
+
maxPriorityFeePerGas: onchainOperation.maxPriorityFeePerGas
|
67
|
+
? BigInt(onchainOperation.maxPriorityFeePerGas)
|
68
|
+
: undefined,
|
69
|
+
nativeCurrency: Currency.toCurrency(onchainOperation.nativeCurrency),
|
70
|
+
nonce: onchainOperation.nonce ? BigInt(onchainOperation.nonce) : undefined,
|
71
|
+
outputState: State.toState(onchainOperation.outputState),
|
72
|
+
to: onchainOperation.to,
|
73
|
+
txRpcUrl: onchainOperation.txRpcUrl,
|
74
|
+
type: onchainOperation.type,
|
75
|
+
value: onchainOperation.value ? BigInt(onchainOperation.value) : undefined,
|
76
|
+
};
|
77
|
+
};
|
78
|
+
export const extractIntent = (intent) => {
|
79
|
+
if (!intent) {
|
80
|
+
return undefined;
|
81
|
+
}
|
82
|
+
return {
|
83
|
+
estimatedProtocolFees: FungibleTokenAmount.toFungibleTokenAmount(intent.estimatedProtocolFees),
|
84
|
+
estimatedProtocolFeesInFiatCurrency: CurrencyAmount.toCurrencyAmount(intent.estimatedProtocolFeesInFiatCurrency),
|
85
|
+
inputState: State.toState(intent.inputState),
|
86
|
+
intentOperations: intent.intentOperations.map((operation) => extractOnchainOperation(operation)),
|
87
|
+
outputState: State.toState(intent.outputState),
|
88
|
+
};
|
89
|
+
};
|
90
|
+
export const extractOperationStatuses = (operationStatus) => {
|
91
|
+
if (hasError(operationStatus)) {
|
92
|
+
console.error("Error ", operationStatus);
|
93
|
+
return undefined;
|
94
|
+
}
|
95
|
+
return operationStatus?.map((status) => extractOperationStatus(status));
|
96
|
+
};
|
97
|
+
export const extractOperationStatus = (status) => {
|
98
|
+
if (!status) {
|
99
|
+
return undefined;
|
100
|
+
}
|
101
|
+
return {
|
102
|
+
blockHash: status.blockHash,
|
103
|
+
blockNumber: status.blockNumber ? BigInt(status.blockNumber) : undefined,
|
104
|
+
chainId: status.chainId
|
105
|
+
? getChainIdFromOrbyChainId(status.chainId)
|
106
|
+
: undefined,
|
107
|
+
errorReason: status.errorReason,
|
108
|
+
hash: status.hash,
|
109
|
+
id: status.id,
|
110
|
+
status: status.status,
|
111
|
+
type: status.type,
|
112
|
+
};
|
113
|
+
};
|
114
|
+
export const extractActivities = (activities) => {
|
115
|
+
if (!activities) {
|
116
|
+
return undefined;
|
117
|
+
}
|
118
|
+
return activities.map((activity) => {
|
119
|
+
return {
|
120
|
+
aggregateFiatValueOfInputState: CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfInputState),
|
121
|
+
aggregateFiatValueOfOutputState: CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfOutputState),
|
122
|
+
aggregateNetworkFeesInFiatCurrency: CurrencyAmount.toCurrencyAmount(activity.aggregateNetworkFeesInFiatCurrency),
|
123
|
+
aggregateProtocolFeesInFiatCurrency: CurrencyAmount.toCurrencyAmount(activity.aggregateProtocolFeesInFiatCurrency),
|
124
|
+
category: activity.category,
|
125
|
+
initiateAt: activity.initiateAt,
|
126
|
+
inputState: State.toState(activity.inputState),
|
127
|
+
operationStatuses: extractOperationStatuses(activity.operationStatuses),
|
128
|
+
outputState: State.toState(activity.outputState),
|
129
|
+
overallStatus: activity.overallStatus,
|
130
|
+
};
|
131
|
+
});
|
132
|
+
};
|
133
|
+
export const extractFungibleTokenOverview = (overview) => {
|
134
|
+
if (!overview) {
|
135
|
+
return undefined;
|
136
|
+
}
|
137
|
+
else if (hasError(overview)) {
|
138
|
+
console.error("[extractFungibleTokenOverview]", overview.code, overview.message);
|
139
|
+
return undefined;
|
140
|
+
}
|
141
|
+
return {
|
142
|
+
tokenCount: overview.tokenCount,
|
143
|
+
hiddenTokenCount: overview.hiddenTokenCount,
|
144
|
+
totalValueInFiat: CurrencyAmount.toCurrencyAmount(overview.totalValueInFiat),
|
145
|
+
};
|
146
|
+
};
|
147
|
+
export const extractStandardizedBalances = (balances) => {
|
148
|
+
return balances?.map((balance) => extractStandardizedBalance(balance));
|
149
|
+
};
|
150
|
+
export const extractStandardizedBalance = (balance) => {
|
151
|
+
if (!balance) {
|
152
|
+
return undefined;
|
153
|
+
}
|
154
|
+
return {
|
155
|
+
standardizedTokenId: balance.standardizedTokenId,
|
156
|
+
tokenBalances: balance.tokenBalances.map((ft) => FungibleTokenAmount.toFungibleTokenAmount(ft)),
|
157
|
+
tokenBalancesOnChains: balance.tokenBalancesOnChains.map((ft) => FungibleTokenAmount.toFungibleTokenAmount(ft)),
|
158
|
+
total: CurrencyAmount.toCurrencyAmount(balance.total),
|
159
|
+
totalValueInFiat: CurrencyAmount.toCurrencyAmount(balance.totalValueInFiat),
|
160
|
+
};
|
161
|
+
};
|
162
|
+
export const extractStandardizedTokens = (tokens) => {
|
163
|
+
return tokens?.map((token) => extractStandardizedToken(token));
|
164
|
+
};
|
165
|
+
export const extractStandardizedToken = (token) => {
|
166
|
+
if (!token) {
|
167
|
+
return undefined;
|
168
|
+
}
|
169
|
+
return {
|
170
|
+
standardizedTokenId: token.standardizedTokenId,
|
171
|
+
currency: Currency.toCurrency(token.currency),
|
172
|
+
priceInFiat: CurrencyAmount.toCurrencyAmount(token.priceInFiat),
|
173
|
+
tokens: token.tokens.map((ft) => FungibleToken.toFungibleToken(ft)),
|
174
|
+
};
|
175
|
+
};
|
176
|
+
export const extractBlockchainInformations = (blockchainInformation) => {
|
177
|
+
return blockchainInformation?.map((info) => extractBlockchainInformation(info));
|
178
|
+
};
|
179
|
+
export const extractBlockchainInformation = (blockchainInformation) => {
|
180
|
+
if (!blockchainInformation) {
|
181
|
+
return undefined;
|
182
|
+
}
|
183
|
+
return {
|
184
|
+
chainId: getChainIdFromOrbyChainId(blockchainInformation.chainId),
|
185
|
+
environment: blockchainInformation.environment,
|
186
|
+
logoUrl: blockchainInformation.logoUrl,
|
187
|
+
name: blockchainInformation.name,
|
188
|
+
};
|
189
|
+
};
|
190
|
+
export const extractMaxAmountPerInterval = (maxAmountPerInterval) => {
|
191
|
+
if (!maxAmountPerInterval) {
|
192
|
+
return undefined;
|
193
|
+
}
|
194
|
+
return {
|
195
|
+
amount: maxAmountPerInterval.amount,
|
196
|
+
interval: {
|
197
|
+
amount: maxAmountPerInterval.interval.amount,
|
198
|
+
unit: maxAmountPerInterval.interval.unit,
|
199
|
+
},
|
200
|
+
};
|
201
|
+
};
|
202
|
+
export const extractAllowlistWithOpenFallback = (allowlist) => {
|
203
|
+
if (!allowlist) {
|
204
|
+
return undefined;
|
205
|
+
}
|
206
|
+
return {
|
207
|
+
tokenAllowlist: {
|
208
|
+
tokenAllowlistType: allowlist.tokenAllowlist.tokenAllowlistType,
|
209
|
+
sponsoredFunctions: allowlist.tokenAllowlist.sponsoredFunctions,
|
210
|
+
},
|
211
|
+
arbitraryContractAllowlist: allowlist.arbitraryContractAllowlist,
|
212
|
+
};
|
213
|
+
};
|
214
|
+
export const extractGasSponsorshipPolicy = (gasSponsorshipPolicy) => {
|
215
|
+
if (!gasSponsorshipPolicy) {
|
216
|
+
return undefined;
|
217
|
+
}
|
218
|
+
return {
|
219
|
+
maxTotalGasSpendForInstance: extractMaxAmountPerInterval(gasSponsorshipPolicy.maxTotalGasSpendForInstance),
|
220
|
+
maxGasSpendPerTransaction: gasSponsorshipPolicy.maxGasSpendPerTransaction,
|
221
|
+
allowlistWithOpenFallback: extractAllowlistWithOpenFallback(gasSponsorshipPolicy.allowlistWithOpenFallback),
|
222
|
+
maxTotalTransactionCountForInstance: extractMaxAmountPerInterval(gasSponsorshipPolicy.maxTotalTransactionCountForInstance),
|
223
|
+
maxTotalGasSpendPerUser: extractMaxAmountPerInterval(gasSponsorshipPolicy.maxTotalGasSpendPerUser),
|
224
|
+
maxTotalTransactionCountPerUser: extractMaxAmountPerInterval(gasSponsorshipPolicy.maxTotalTransactionCountPerUser),
|
225
|
+
};
|
226
|
+
};
|
227
|
+
export const extractGasSpendForInstances = (gasSpendForInstances) => {
|
228
|
+
return gasSpendForInstances?.map((data) => extractGasSpendForInstance(data));
|
229
|
+
};
|
230
|
+
export const extractGasSpendForInstance = (gasSpendForInstance) => {
|
231
|
+
if (!gasSpendForInstance) {
|
232
|
+
return;
|
233
|
+
}
|
234
|
+
return {
|
235
|
+
instanceName: gasSpendForInstance.instanceName,
|
236
|
+
gasSpentForInstance: extractGasSponsorshipData(gasSpendForInstance.gasSpentForInstance),
|
237
|
+
};
|
238
|
+
};
|
239
|
+
export const extractGasSponsorshipInformation = (gasSponsorshipData) => {
|
240
|
+
return gasSponsorshipData?.map((data) => extractGasSponsorshipData(data));
|
241
|
+
};
|
242
|
+
export const extractGasSponsorshipData = (gasSponsorshipData) => {
|
243
|
+
if (!gasSponsorshipData) {
|
244
|
+
return undefined;
|
245
|
+
}
|
246
|
+
return {
|
247
|
+
totalGasSpent: CurrencyAmount.toCurrencyAmount(gasSponsorshipData.totalGasSpent),
|
248
|
+
totalTransactionCount: gasSponsorshipData.totalTransactionCount,
|
249
|
+
};
|
250
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Blockchain } from "../enums.js";
|
2
|
+
export declare const getChainIdFromOrbyChainId: (value: string) => bigint | undefined;
|
3
|
+
export declare const getOrbyChainId: (chainId: bigint) => string;
|
4
|
+
export declare const getBlockchainIdFromBlockchain: (blockchain: Blockchain) => number;
|
5
|
+
export declare const hasError: (data: any) => {
|
6
|
+
code: number;
|
7
|
+
message: string;
|
8
|
+
};
|
9
|
+
export declare const getBlockchainFromName: (chainName: string) => Blockchain;
|
10
|
+
export declare const isMainnet: (chainId: bigint) => boolean;
|