@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,61 @@
|
|
1
|
+
import { Asset } from "./asset.js";
|
2
|
+
import { checkValidAddress, validateAndParseAddress, } from "../../utils/validateAndParseAddress.js";
|
3
|
+
import { TokenType } from "../../enums.js";
|
4
|
+
/**
|
5
|
+
* Represents an ERC721 token with a unique address and some metadata.
|
6
|
+
*/
|
7
|
+
export class NonFungibleToken extends Asset {
|
8
|
+
/**
|
9
|
+
* @param chainId The chain ID on which this token resides
|
10
|
+
* @param address The contract address on the chain on which this token lives
|
11
|
+
* @param symbol {@link Currency#symbol}
|
12
|
+
* @param name {@link Currency#name}
|
13
|
+
* @param url The URL of the token's metadata
|
14
|
+
* @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
|
15
|
+
*/
|
16
|
+
constructor(chainId, address, symbol, name, url, bypassChecksum, coinGeckoId) {
|
17
|
+
// TODO(felix): add this back
|
18
|
+
// invariant(!_.isUndefined(getBlockchainFromBlockchainId(chainId)), "CHAIN_ID");
|
19
|
+
super(symbol, name, coinGeckoId);
|
20
|
+
this.isNative = false;
|
21
|
+
this.isToken = true;
|
22
|
+
if (bypassChecksum) {
|
23
|
+
this.address = checkValidAddress(address)?.toLowerCase();
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
this.address = validateAndParseAddress(address)?.toLowerCase();
|
27
|
+
}
|
28
|
+
this.chainId = chainId;
|
29
|
+
this.url = url;
|
30
|
+
}
|
31
|
+
static toNonFungibleToken(nft) {
|
32
|
+
if (!nft) {
|
33
|
+
return undefined;
|
34
|
+
}
|
35
|
+
const asset = Asset.toAsset(nft.asset);
|
36
|
+
return new NonFungibleToken(nft.chainId, nft.address, asset.symbol, asset.name, nft.url);
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
40
|
+
* @param other other token to compare
|
41
|
+
*/
|
42
|
+
equals(other) {
|
43
|
+
// short circuit on reference equality
|
44
|
+
if (this === other)
|
45
|
+
return true;
|
46
|
+
return (this.chainId === other.chainId &&
|
47
|
+
this.address === other.address.toLowerCase());
|
48
|
+
}
|
49
|
+
/**
|
50
|
+
* Returns the asset representation of this currency
|
51
|
+
*/
|
52
|
+
asset() {
|
53
|
+
return this;
|
54
|
+
}
|
55
|
+
type() {
|
56
|
+
return TokenType.NON_FUNGIBLE_TOKEN;
|
57
|
+
}
|
58
|
+
identifier() {
|
59
|
+
return `${this.chainId}+${this.address.toLowerCase()}`;
|
60
|
+
}
|
61
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { Currency } from "./currency.js";
|
2
|
+
import { TokenType } from "../../enums.js";
|
3
|
+
/**
|
4
|
+
* Represents an ERC1155 token with a unique address and some metadata.
|
5
|
+
*/
|
6
|
+
export declare class SemiFungibleToken extends Currency {
|
7
|
+
readonly isNative: false;
|
8
|
+
readonly isToken: true;
|
9
|
+
/**
|
10
|
+
* The contract address on the chain on which this token lives
|
11
|
+
*/
|
12
|
+
readonly address: string;
|
13
|
+
/**
|
14
|
+
* The chain ID on which this token resides
|
15
|
+
*/
|
16
|
+
readonly chainId: bigint;
|
17
|
+
readonly url?: string;
|
18
|
+
/**
|
19
|
+
*
|
20
|
+
* @param chainId The chain ID on which this token resides
|
21
|
+
* @param address The contract address on the chain on which this token lives
|
22
|
+
* @param decimals {@link Currency#decimals}
|
23
|
+
* @param symbol {@link Currency#symbol}
|
24
|
+
* @param name {@link Currency#name}
|
25
|
+
* @param url The URL of the token's metadata
|
26
|
+
* @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
|
27
|
+
*/
|
28
|
+
constructor(chainId: bigint, address: string, decimals: number, symbol: string, name: string, url?: string, bypassChecksum?: boolean, coinGeckoId?: string);
|
29
|
+
static toSemiFungibleToken(sft?: any): SemiFungibleToken;
|
30
|
+
/**
|
31
|
+
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
32
|
+
* @param other other token to compare
|
33
|
+
*/
|
34
|
+
equals(other: SemiFungibleToken): boolean;
|
35
|
+
/**
|
36
|
+
* Returns the currency object that this token represents
|
37
|
+
*/
|
38
|
+
currency(): Currency;
|
39
|
+
type(): TokenType;
|
40
|
+
identifier(): string;
|
41
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import { Currency } from "./currency.js";
|
2
|
+
import { checkValidAddress, validateAndParseAddress, } from "../../utils/validateAndParseAddress.js";
|
3
|
+
import { TokenType } from "../../enums.js";
|
4
|
+
/**
|
5
|
+
* Represents an ERC1155 token with a unique address and some metadata.
|
6
|
+
*/
|
7
|
+
export class SemiFungibleToken extends Currency {
|
8
|
+
/**
|
9
|
+
*
|
10
|
+
* @param chainId The chain ID on which this token resides
|
11
|
+
* @param address The contract address on the chain on which this token lives
|
12
|
+
* @param decimals {@link Currency#decimals}
|
13
|
+
* @param symbol {@link Currency#symbol}
|
14
|
+
* @param name {@link Currency#name}
|
15
|
+
* @param url The URL of the token's metadata
|
16
|
+
* @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
|
17
|
+
*/
|
18
|
+
constructor(chainId, address, decimals, symbol, name, url, bypassChecksum, coinGeckoId) {
|
19
|
+
// TODO(felix): add this back
|
20
|
+
// invariant(!_.isUndefined(getBlockchainFromBlockchainId(chainId)), "CHAIN_ID");
|
21
|
+
super(decimals, symbol, name, url, false, true, coinGeckoId);
|
22
|
+
this.isNative = false;
|
23
|
+
this.isToken = true;
|
24
|
+
if (bypassChecksum) {
|
25
|
+
this.address = checkValidAddress(address)?.toLowerCase();
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
this.address = validateAndParseAddress(address)?.toLowerCase();
|
29
|
+
}
|
30
|
+
this.chainId = chainId;
|
31
|
+
this.url = url;
|
32
|
+
}
|
33
|
+
static toSemiFungibleToken(sft) {
|
34
|
+
if (!sft) {
|
35
|
+
return undefined;
|
36
|
+
}
|
37
|
+
const currency = Currency.toCurrency(sft.currency);
|
38
|
+
return new SemiFungibleToken(sft.chainId, sft.address, currency.decimals, currency.symbol, currency.name, sft.url);
|
39
|
+
}
|
40
|
+
/**
|
41
|
+
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
42
|
+
* @param other other token to compare
|
43
|
+
*/
|
44
|
+
equals(other) {
|
45
|
+
// short circuit on reference equality
|
46
|
+
if (this === other)
|
47
|
+
return true;
|
48
|
+
return (this.chainId === other.chainId &&
|
49
|
+
this.address === other.address.toLowerCase());
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* Returns the currency object that this token represents
|
53
|
+
*/
|
54
|
+
currency() {
|
55
|
+
return this;
|
56
|
+
}
|
57
|
+
type() {
|
58
|
+
return TokenType.SEMI_FUNGIBLE_TOKEN;
|
59
|
+
}
|
60
|
+
identifier() {
|
61
|
+
return `${this.chainId}+${this.address.toLowerCase()}`;
|
62
|
+
}
|
63
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { LIBRARY_TYPE } from "../enums.js";
|
2
|
+
export declare class LibraryRequest {
|
3
|
+
readonly library: LIBRARY_TYPE;
|
4
|
+
readonly client?: any;
|
5
|
+
readonly provider?: any;
|
6
|
+
constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
|
7
|
+
sendRequest(method: string, params: any[]): Promise<any>;
|
8
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { LIBRARY_TYPE } from "../enums.js";
|
2
|
+
import invariant from "tiny-invariant";
|
3
|
+
export class LibraryRequest {
|
4
|
+
constructor(library, client, provider) {
|
5
|
+
if (library == LIBRARY_TYPE.VIEM) {
|
6
|
+
invariant(client, "CLIENT");
|
7
|
+
invariant(!provider, "PROVIDER");
|
8
|
+
this.client = client;
|
9
|
+
}
|
10
|
+
else if (library == LIBRARY_TYPE.ETHERS) {
|
11
|
+
invariant(provider, "PROVIDER");
|
12
|
+
invariant(!client, "CLIENT");
|
13
|
+
this.provider = provider;
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
invariant(false, "LIBRARY");
|
17
|
+
}
|
18
|
+
this.library = library;
|
19
|
+
this.client = client;
|
20
|
+
this.provider = provider;
|
21
|
+
}
|
22
|
+
sendRequest(method, params) {
|
23
|
+
if (this.library == LIBRARY_TYPE.VIEM) {
|
24
|
+
return this.client.request({ method, params });
|
25
|
+
}
|
26
|
+
else if (this.library == LIBRARY_TYPE.ETHERS) {
|
27
|
+
return this.provider.send(method, params);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { FungibleToken } from "./financial/fungible_token.js";
|
2
|
+
import { FungibleTokenAmount } from "./financial/fungible_token_amount.js";
|
3
|
+
import { NonFungibleToken } from "./financial/non_fungible_token.js";
|
4
|
+
import { SemiFungibleToken } from "./financial/semi_fungible_token.js";
|
5
|
+
export declare class State {
|
6
|
+
private readonly fungibleTokens;
|
7
|
+
private readonly nonFungibleTokens;
|
8
|
+
private readonly semiFungibleTokens;
|
9
|
+
constructor(fungibleTokens: FungibleTokenAmount[], nonFungibleTokens: NonFungibleToken[], semiFungibleTokens: SemiFungibleToken[]);
|
10
|
+
static fromFungibleTokenAmounts(fungibleTokenAmounts: FungibleTokenAmount[]): State;
|
11
|
+
static fromTokenAndAmount(token?: FungibleToken, amount?: bigint): State;
|
12
|
+
getFungibleTokens(): FungibleTokenAmount[];
|
13
|
+
getNonFungibleTokens(): NonFungibleToken[];
|
14
|
+
getSemiFungibleTokens(): SemiFungibleToken[];
|
15
|
+
addTokens(fungibleTokens: FungibleTokenAmount[]): State;
|
16
|
+
addState(other: State): State;
|
17
|
+
deductState(other: State): State;
|
18
|
+
equals(other?: State): boolean;
|
19
|
+
addStates(states: State[]): State;
|
20
|
+
static mergeStates(states: State[]): State;
|
21
|
+
static toState(state: any): State;
|
22
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { FungibleTokenAmount } from "./financial/fungible_token_amount.js";
|
2
|
+
import { NonFungibleToken } from "./financial/non_fungible_token.js";
|
3
|
+
import { SemiFungibleToken } from "./financial/semi_fungible_token.js";
|
4
|
+
export class State {
|
5
|
+
constructor(fungibleTokens, nonFungibleTokens, semiFungibleTokens) {
|
6
|
+
this.fungibleTokens = fungibleTokens.reduce((acc, amount) => {
|
7
|
+
acc.set(amount.token.identifier(), amount);
|
8
|
+
return acc;
|
9
|
+
}, new Map());
|
10
|
+
this.nonFungibleTokens = nonFungibleTokens.reduce((acc, token) => {
|
11
|
+
acc.set(token.identifier(), token);
|
12
|
+
return acc;
|
13
|
+
}, new Map());
|
14
|
+
this.semiFungibleTokens = semiFungibleTokens.reduce((acc, token) => {
|
15
|
+
acc.set(token.identifier(), token);
|
16
|
+
return acc;
|
17
|
+
}, new Map());
|
18
|
+
}
|
19
|
+
static fromFungibleTokenAmounts(fungibleTokenAmounts) {
|
20
|
+
return new State(fungibleTokenAmounts, [], []);
|
21
|
+
}
|
22
|
+
static fromTokenAndAmount(token, amount) {
|
23
|
+
if (!token || !amount) {
|
24
|
+
return undefined;
|
25
|
+
}
|
26
|
+
const fungibleTokenAmount = FungibleTokenAmount.fromRawAmount(token, amount);
|
27
|
+
return State.fromFungibleTokenAmounts([fungibleTokenAmount]);
|
28
|
+
}
|
29
|
+
getFungibleTokens() {
|
30
|
+
return Array.from(this.fungibleTokens.values());
|
31
|
+
}
|
32
|
+
getNonFungibleTokens() {
|
33
|
+
return Array.from(this.nonFungibleTokens.values());
|
34
|
+
}
|
35
|
+
getSemiFungibleTokens() {
|
36
|
+
return Array.from(this.semiFungibleTokens.values());
|
37
|
+
}
|
38
|
+
addTokens(fungibleTokens) {
|
39
|
+
fungibleTokens.forEach((amount) => {
|
40
|
+
const identifier = amount.token.identifier();
|
41
|
+
const currentAmount = this.fungibleTokens.get(identifier);
|
42
|
+
if (currentAmount) {
|
43
|
+
this.fungibleTokens.set(identifier, currentAmount.add(amount));
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
this.fungibleTokens.set(identifier, amount);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
return this;
|
50
|
+
}
|
51
|
+
addState(other) {
|
52
|
+
other?.fungibleTokens?.forEach((amount) => {
|
53
|
+
const identifier = amount.token.identifier();
|
54
|
+
const currentAmount = this.fungibleTokens.get(identifier);
|
55
|
+
if (currentAmount) {
|
56
|
+
this.fungibleTokens.set(identifier, currentAmount.add(amount));
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
this.fungibleTokens.set(identifier, amount);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
return this;
|
63
|
+
}
|
64
|
+
deductState(other) {
|
65
|
+
other.fungibleTokens.forEach((amount) => {
|
66
|
+
const identifier = amount.token.identifier();
|
67
|
+
const currentAmount = this.fungibleTokens.get(identifier);
|
68
|
+
if (currentAmount?.toRawAmount() > amount?.toRawAmount()) {
|
69
|
+
this.fungibleTokens.set(identifier, currentAmount.subtract(amount));
|
70
|
+
}
|
71
|
+
else if (currentAmount) {
|
72
|
+
this.fungibleTokens.delete(identifier);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
return this;
|
76
|
+
}
|
77
|
+
equals(other) {
|
78
|
+
if (!other) {
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
return (this.fungibleTokens.size == other.fungibleTokens.size &&
|
82
|
+
Array.from(this.fungibleTokens.entries()).every(([key, value]) => {
|
83
|
+
const otherValue = other.fungibleTokens.get(key);
|
84
|
+
return otherValue && value.equals(otherValue);
|
85
|
+
}));
|
86
|
+
}
|
87
|
+
addStates(states) {
|
88
|
+
states.forEach((state) => this.addState(state));
|
89
|
+
return this;
|
90
|
+
}
|
91
|
+
static mergeStates(states) {
|
92
|
+
return states.reduce((acc, state) => acc.addState(state), new State([], [], []));
|
93
|
+
}
|
94
|
+
static toState(state) {
|
95
|
+
if (!state)
|
96
|
+
return undefined;
|
97
|
+
const fungibleTokenAmounts = state.fungibleTokenAmounts.map((ft) => FungibleTokenAmount.toFungibleTokenAmount(ft));
|
98
|
+
const nonFungibleTokenAmounts = state.nonFungibleTokenAmounts.map((nft) => NonFungibleToken.toNonFungibleToken(nft));
|
99
|
+
const semiFungibleTokenAmounts = state.semiFungibleTokenAmounts.map((sft) => SemiFungibleToken.toSemiFungibleToken(sft));
|
100
|
+
return new State(fungibleTokenAmounts, nonFungibleTokenAmounts, semiFungibleTokenAmounts);
|
101
|
+
}
|
102
|
+
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
export declare enum Blockchain {
|
2
|
+
ETHEREUM = "ethereum",
|
3
|
+
POLYGON = "polygon",
|
4
|
+
BINANCE = "binance",
|
5
|
+
ARBITRUM = "arbitrum",
|
6
|
+
BASE = "base",
|
7
|
+
AVALANCHE = "avalanche",
|
8
|
+
ARBITRUM_NOVA = "arbitrum_nova",
|
9
|
+
OPTIMISM = "optimism",
|
10
|
+
EVMOS = "evmos",
|
11
|
+
MOONBEAM = "moonbeam",
|
12
|
+
ETHEREUM_SEPOLIA = "ethereum_sepolia",
|
13
|
+
ETHEREUM_HOLESKY = "ethereum_holesky",
|
14
|
+
BASE_SEPOLIA = "base_sepolia",
|
15
|
+
ARBITRUM_SEPOLIA = "arbitrum_sepolia",
|
16
|
+
OPTIMISM_SEPOLIA = "optimism_sepolia",
|
17
|
+
POLYGON_AMOY = "polygon_amoy",
|
18
|
+
BINANCE_TESTNET = "binance_testnet",
|
19
|
+
OPBNB_TESTNET = "opbnb_testnet",
|
20
|
+
MOONBEAM_ALPHA = "moonbeam_alpha",
|
21
|
+
HARDHAT = "hardhat",
|
22
|
+
LOCAL_CHAIN_0 = "local_chain_0",
|
23
|
+
LOCAL_CHAIN_1 = "local_chain_1"
|
24
|
+
}
|
25
|
+
export declare enum TokenType {
|
26
|
+
FUNGIBLE_TOKEN = "FUNGIBLE_TOKEN",
|
27
|
+
NON_FUNGIBLE_TOKEN = "NON_FUNGIBLE_TOKEN",
|
28
|
+
SEMI_FUNGIBLE_TOKEN = "SEMI_FUNGIBLE_TOKEN",
|
29
|
+
FIAT = "FIAT"
|
30
|
+
}
|
31
|
+
export declare enum AccountType {
|
32
|
+
EOA = "EOA",
|
33
|
+
SCA = "SCA"
|
34
|
+
}
|
35
|
+
export declare enum VMType {
|
36
|
+
EVM = "EVM"
|
37
|
+
}
|
38
|
+
export declare enum ChainSupportStatus {
|
39
|
+
CHAIN_SUPPORTED = "CHAIN_SUPPORTED",
|
40
|
+
CHAIN_UNAVAILABLE = "CHAIN_UNAVAILABLE",
|
41
|
+
ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE"
|
42
|
+
}
|
43
|
+
export declare enum CreateOperationsStatus {
|
44
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
45
|
+
INSUFFICIENT_FUNDS_FOR_GAS = "INSUFFICIENT_FUNDS_FOR_GAS",
|
46
|
+
INTERNAL = "INTERNAL",
|
47
|
+
INVALID_ARGUMENT = "INVALID_ARGUMENT",
|
48
|
+
NO_EXECUTION_PATH = "NO_EXECUTION_PATH",
|
49
|
+
SUCCESS = "SUCCESS"
|
50
|
+
}
|
51
|
+
export declare enum OperationDataFormat {
|
52
|
+
TRANSACTION = "TRANSACTION",
|
53
|
+
TYPED_DATA = "TYPED_DATA"
|
54
|
+
}
|
55
|
+
export declare enum OperationType {
|
56
|
+
APPROVE_ERC20_TOKEN = "APPROVE_ERC20_TOKEN",
|
57
|
+
CANCEL_OPERATION = "CANCEL_OPERATION",
|
58
|
+
CANCEL_TRANSACTION = "CANCEL_TRANSACTION",
|
59
|
+
FINAL_TRANSACTION = "FINAL_TRANSACTION",
|
60
|
+
GAS_ABSTRACTION = "GAS_ABSTRACTION",
|
61
|
+
NATIVE_TOKEN_TRANSFER = "NATIVE_TOKEN_TRANSFER",
|
62
|
+
SUBMIT_INTENT = "SUBMIT_INTENT"
|
63
|
+
}
|
64
|
+
export declare enum Category {
|
65
|
+
SEND = "SEND",
|
66
|
+
RECEIVE = "RECEIVE",
|
67
|
+
SWAP = "SWAP",
|
68
|
+
REBALANCE = "REBALANCE",
|
69
|
+
BRIDGE = "BRIDGE",
|
70
|
+
FUNCTION_CALL = "FUNCTION_CALL",
|
71
|
+
TYPED_DATA_SIGNATURE = "TYPED_DATA_SIGNATURE"
|
72
|
+
}
|
73
|
+
export declare enum OperationStatusType {
|
74
|
+
FAILED = "FAILED",
|
75
|
+
NOT_FOUND = "NOT_FOUND",
|
76
|
+
PENDING = "PENDING",
|
77
|
+
SUCCESSFUL = "SUCCESSFUL",
|
78
|
+
WAITING_PRECONDITION = "WAITING_PRECONDITION"
|
79
|
+
}
|
80
|
+
export declare enum QuoteType {
|
81
|
+
EXACT_INPUT = "EXACT_INPUT",
|
82
|
+
EXACT_OUTPUT = "EXACT_OUTPUT"
|
83
|
+
}
|
84
|
+
export declare enum Order {
|
85
|
+
NEWEST = "NEWEST",
|
86
|
+
OLDEST = "OLDEST"
|
87
|
+
}
|
88
|
+
export declare enum ActivityStatus {
|
89
|
+
CANCELLED = "CANCELLED",
|
90
|
+
FAILED = "FAILED",
|
91
|
+
PENDING = "PENDING",
|
92
|
+
SUCCESS = "SUCCESS"
|
93
|
+
}
|
94
|
+
export declare enum BlockchainEnvironment {
|
95
|
+
MAINNET = "MAINNET",
|
96
|
+
TESTNET = "TESTNET"
|
97
|
+
}
|
98
|
+
export declare enum TokenAllowlistType {
|
99
|
+
ALL_TOKENS = "ALL_TOKENS",
|
100
|
+
ONLY_FUNGIBLE_TOKENS = "ONLY_FUNGIBLE_TOKENS",
|
101
|
+
ONLY_NON_FUNGIBLE_TOKENS = "ONLY_NON_FUNGIBLE_TOKENS",
|
102
|
+
ONLY_SEMI_FUNGIBLE_TOKENS = "ONLY_SEMI_FUNGIBLE_TOKENS"
|
103
|
+
}
|
104
|
+
export declare enum TimeIntervalUnits {
|
105
|
+
DAYS = "DAYS",
|
106
|
+
FOREVER = "FOREVER",
|
107
|
+
HOURS = "HOURS",
|
108
|
+
MINUTES = "MINUTES",
|
109
|
+
MONTHS = "MONTHS",
|
110
|
+
WEEKS = "WEEKS",
|
111
|
+
YEARS = "YEARS"
|
112
|
+
}
|
113
|
+
export declare enum LIBRARY_TYPE {
|
114
|
+
VIEM = "VIEM",
|
115
|
+
ETHERS = "ETHERS"
|
116
|
+
}
|
@@ -0,0 +1,135 @@
|
|
1
|
+
export var Blockchain;
|
2
|
+
(function (Blockchain) {
|
3
|
+
Blockchain["ETHEREUM"] = "ethereum";
|
4
|
+
Blockchain["POLYGON"] = "polygon";
|
5
|
+
Blockchain["BINANCE"] = "binance";
|
6
|
+
Blockchain["ARBITRUM"] = "arbitrum";
|
7
|
+
Blockchain["BASE"] = "base";
|
8
|
+
Blockchain["AVALANCHE"] = "avalanche";
|
9
|
+
Blockchain["ARBITRUM_NOVA"] = "arbitrum_nova";
|
10
|
+
Blockchain["OPTIMISM"] = "optimism";
|
11
|
+
Blockchain["EVMOS"] = "evmos";
|
12
|
+
Blockchain["MOONBEAM"] = "moonbeam";
|
13
|
+
// testnets
|
14
|
+
Blockchain["ETHEREUM_SEPOLIA"] = "ethereum_sepolia";
|
15
|
+
Blockchain["ETHEREUM_HOLESKY"] = "ethereum_holesky";
|
16
|
+
Blockchain["BASE_SEPOLIA"] = "base_sepolia";
|
17
|
+
Blockchain["ARBITRUM_SEPOLIA"] = "arbitrum_sepolia";
|
18
|
+
Blockchain["OPTIMISM_SEPOLIA"] = "optimism_sepolia";
|
19
|
+
Blockchain["POLYGON_AMOY"] = "polygon_amoy";
|
20
|
+
Blockchain["BINANCE_TESTNET"] = "binance_testnet";
|
21
|
+
Blockchain["OPBNB_TESTNET"] = "opbnb_testnet";
|
22
|
+
Blockchain["MOONBEAM_ALPHA"] = "moonbeam_alpha";
|
23
|
+
// local testing
|
24
|
+
Blockchain["HARDHAT"] = "hardhat";
|
25
|
+
Blockchain["LOCAL_CHAIN_0"] = "local_chain_0";
|
26
|
+
Blockchain["LOCAL_CHAIN_1"] = "local_chain_1";
|
27
|
+
})(Blockchain || (Blockchain = {}));
|
28
|
+
export var TokenType;
|
29
|
+
(function (TokenType) {
|
30
|
+
TokenType["FUNGIBLE_TOKEN"] = "FUNGIBLE_TOKEN";
|
31
|
+
TokenType["NON_FUNGIBLE_TOKEN"] = "NON_FUNGIBLE_TOKEN";
|
32
|
+
TokenType["SEMI_FUNGIBLE_TOKEN"] = "SEMI_FUNGIBLE_TOKEN";
|
33
|
+
TokenType["FIAT"] = "FIAT";
|
34
|
+
})(TokenType || (TokenType = {}));
|
35
|
+
export var AccountType;
|
36
|
+
(function (AccountType) {
|
37
|
+
AccountType["EOA"] = "EOA";
|
38
|
+
AccountType["SCA"] = "SCA";
|
39
|
+
})(AccountType || (AccountType = {}));
|
40
|
+
export var VMType;
|
41
|
+
(function (VMType) {
|
42
|
+
VMType["EVM"] = "EVM";
|
43
|
+
})(VMType || (VMType = {}));
|
44
|
+
export var ChainSupportStatus;
|
45
|
+
(function (ChainSupportStatus) {
|
46
|
+
ChainSupportStatus["CHAIN_SUPPORTED"] = "CHAIN_SUPPORTED";
|
47
|
+
ChainSupportStatus["CHAIN_UNAVAILABLE"] = "CHAIN_UNAVAILABLE";
|
48
|
+
ChainSupportStatus["ACCOUNT_UNAVAILABLE"] = "ACCOUNT_UNAVAILABLE";
|
49
|
+
})(ChainSupportStatus || (ChainSupportStatus = {}));
|
50
|
+
export var CreateOperationsStatus;
|
51
|
+
(function (CreateOperationsStatus) {
|
52
|
+
CreateOperationsStatus["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
53
|
+
CreateOperationsStatus["INSUFFICIENT_FUNDS_FOR_GAS"] = "INSUFFICIENT_FUNDS_FOR_GAS";
|
54
|
+
CreateOperationsStatus["INTERNAL"] = "INTERNAL";
|
55
|
+
CreateOperationsStatus["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
|
56
|
+
CreateOperationsStatus["NO_EXECUTION_PATH"] = "NO_EXECUTION_PATH";
|
57
|
+
CreateOperationsStatus["SUCCESS"] = "SUCCESS";
|
58
|
+
})(CreateOperationsStatus || (CreateOperationsStatus = {}));
|
59
|
+
export var OperationDataFormat;
|
60
|
+
(function (OperationDataFormat) {
|
61
|
+
OperationDataFormat["TRANSACTION"] = "TRANSACTION";
|
62
|
+
OperationDataFormat["TYPED_DATA"] = "TYPED_DATA";
|
63
|
+
})(OperationDataFormat || (OperationDataFormat = {}));
|
64
|
+
export var OperationType;
|
65
|
+
(function (OperationType) {
|
66
|
+
OperationType["APPROVE_ERC20_TOKEN"] = "APPROVE_ERC20_TOKEN";
|
67
|
+
OperationType["CANCEL_OPERATION"] = "CANCEL_OPERATION";
|
68
|
+
OperationType["CANCEL_TRANSACTION"] = "CANCEL_TRANSACTION";
|
69
|
+
OperationType["FINAL_TRANSACTION"] = "FINAL_TRANSACTION";
|
70
|
+
OperationType["GAS_ABSTRACTION"] = "GAS_ABSTRACTION";
|
71
|
+
OperationType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER";
|
72
|
+
OperationType["SUBMIT_INTENT"] = "SUBMIT_INTENT";
|
73
|
+
})(OperationType || (OperationType = {}));
|
74
|
+
export var Category;
|
75
|
+
(function (Category) {
|
76
|
+
Category["SEND"] = "SEND";
|
77
|
+
Category["RECEIVE"] = "RECEIVE";
|
78
|
+
Category["SWAP"] = "SWAP";
|
79
|
+
Category["REBALANCE"] = "REBALANCE";
|
80
|
+
Category["BRIDGE"] = "BRIDGE";
|
81
|
+
Category["FUNCTION_CALL"] = "FUNCTION_CALL";
|
82
|
+
Category["TYPED_DATA_SIGNATURE"] = "TYPED_DATA_SIGNATURE";
|
83
|
+
})(Category || (Category = {}));
|
84
|
+
export var OperationStatusType;
|
85
|
+
(function (OperationStatusType) {
|
86
|
+
OperationStatusType["FAILED"] = "FAILED";
|
87
|
+
OperationStatusType["NOT_FOUND"] = "NOT_FOUND";
|
88
|
+
OperationStatusType["PENDING"] = "PENDING";
|
89
|
+
OperationStatusType["SUCCESSFUL"] = "SUCCESSFUL";
|
90
|
+
OperationStatusType["WAITING_PRECONDITION"] = "WAITING_PRECONDITION";
|
91
|
+
})(OperationStatusType || (OperationStatusType = {}));
|
92
|
+
export var QuoteType;
|
93
|
+
(function (QuoteType) {
|
94
|
+
QuoteType["EXACT_INPUT"] = "EXACT_INPUT";
|
95
|
+
QuoteType["EXACT_OUTPUT"] = "EXACT_OUTPUT";
|
96
|
+
})(QuoteType || (QuoteType = {}));
|
97
|
+
export var Order;
|
98
|
+
(function (Order) {
|
99
|
+
Order["NEWEST"] = "NEWEST";
|
100
|
+
Order["OLDEST"] = "OLDEST";
|
101
|
+
})(Order || (Order = {}));
|
102
|
+
export var ActivityStatus;
|
103
|
+
(function (ActivityStatus) {
|
104
|
+
ActivityStatus["CANCELLED"] = "CANCELLED";
|
105
|
+
ActivityStatus["FAILED"] = "FAILED";
|
106
|
+
ActivityStatus["PENDING"] = "PENDING";
|
107
|
+
ActivityStatus["SUCCESS"] = "SUCCESS";
|
108
|
+
})(ActivityStatus || (ActivityStatus = {}));
|
109
|
+
export var BlockchainEnvironment;
|
110
|
+
(function (BlockchainEnvironment) {
|
111
|
+
BlockchainEnvironment["MAINNET"] = "MAINNET";
|
112
|
+
BlockchainEnvironment["TESTNET"] = "TESTNET";
|
113
|
+
})(BlockchainEnvironment || (BlockchainEnvironment = {}));
|
114
|
+
export var TokenAllowlistType;
|
115
|
+
(function (TokenAllowlistType) {
|
116
|
+
TokenAllowlistType["ALL_TOKENS"] = "ALL_TOKENS";
|
117
|
+
TokenAllowlistType["ONLY_FUNGIBLE_TOKENS"] = "ONLY_FUNGIBLE_TOKENS";
|
118
|
+
TokenAllowlistType["ONLY_NON_FUNGIBLE_TOKENS"] = "ONLY_NON_FUNGIBLE_TOKENS";
|
119
|
+
TokenAllowlistType["ONLY_SEMI_FUNGIBLE_TOKENS"] = "ONLY_SEMI_FUNGIBLE_TOKENS";
|
120
|
+
})(TokenAllowlistType || (TokenAllowlistType = {}));
|
121
|
+
export var TimeIntervalUnits;
|
122
|
+
(function (TimeIntervalUnits) {
|
123
|
+
TimeIntervalUnits["DAYS"] = "DAYS";
|
124
|
+
TimeIntervalUnits["FOREVER"] = "FOREVER";
|
125
|
+
TimeIntervalUnits["HOURS"] = "HOURS";
|
126
|
+
TimeIntervalUnits["MINUTES"] = "MINUTES";
|
127
|
+
TimeIntervalUnits["MONTHS"] = "MONTHS";
|
128
|
+
TimeIntervalUnits["WEEKS"] = "WEEKS";
|
129
|
+
TimeIntervalUnits["YEARS"] = "YEARS";
|
130
|
+
})(TimeIntervalUnits || (TimeIntervalUnits = {}));
|
131
|
+
export var LIBRARY_TYPE;
|
132
|
+
(function (LIBRARY_TYPE) {
|
133
|
+
LIBRARY_TYPE["VIEM"] = "VIEM";
|
134
|
+
LIBRARY_TYPE["ETHERS"] = "ETHERS";
|
135
|
+
})(LIBRARY_TYPE || (LIBRARY_TYPE = {}));
|
@@ -0,0 +1,29 @@
|
|
1
|
+
export * from "./interfaces/account_cluster.js";
|
2
|
+
export * from "./interfaces/admin.js";
|
3
|
+
export * from "./interfaces/application.js";
|
4
|
+
export * from "./interfaces/instance.js";
|
5
|
+
export * from "./interfaces/operation.js";
|
6
|
+
export * from "./interfaces/token.js";
|
7
|
+
export * from "./interfaces/orby.js";
|
8
|
+
export * from "./interfaces/blockchain.js";
|
9
|
+
export * from "./actions/account_cluster.js";
|
10
|
+
export * from "./actions/admin.js";
|
11
|
+
export * from "./actions/application.js";
|
12
|
+
export * from "./actions/instance.js";
|
13
|
+
export * from "./actions/operation.js";
|
14
|
+
export * from "./actions/token.js";
|
15
|
+
export * from "./actions/blockchain.js";
|
16
|
+
export * from "./entities/financial/account_balance.js";
|
17
|
+
export * from "./entities/financial/asset.js";
|
18
|
+
export * from "./entities/financial/currency_amount.js";
|
19
|
+
export * from "./entities/financial/currency.js";
|
20
|
+
export * from "./entities/financial/fungible_token_amount.js";
|
21
|
+
export * from "./entities/financial/fungible_token.js";
|
22
|
+
export * from "./entities/financial/non_fungible_token.js";
|
23
|
+
export * from "./entities/financial/semi_fungible_token.js";
|
24
|
+
export * from "./entities/account.js";
|
25
|
+
export * from "./entities/state.js";
|
26
|
+
export * from "./enums.js";
|
27
|
+
export * from "./types.js";
|
28
|
+
export * from "./constants.js";
|
29
|
+
export * from "./utils/utils.js";
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// interfaces
|
2
|
+
export * from "./interfaces/account_cluster.js";
|
3
|
+
export * from "./interfaces/admin.js";
|
4
|
+
export * from "./interfaces/application.js";
|
5
|
+
export * from "./interfaces/instance.js";
|
6
|
+
export * from "./interfaces/operation.js";
|
7
|
+
export * from "./interfaces/token.js";
|
8
|
+
export * from "./interfaces/orby.js";
|
9
|
+
export * from "./interfaces/blockchain.js";
|
10
|
+
// actions
|
11
|
+
export * from "./actions/account_cluster.js";
|
12
|
+
export * from "./actions/admin.js";
|
13
|
+
export * from "./actions/application.js";
|
14
|
+
export * from "./actions/instance.js";
|
15
|
+
export * from "./actions/operation.js";
|
16
|
+
export * from "./actions/token.js";
|
17
|
+
export * from "./actions/blockchain.js";
|
18
|
+
// entities
|
19
|
+
export * from "./entities/financial/account_balance.js";
|
20
|
+
export * from "./entities/financial/asset.js";
|
21
|
+
export * from "./entities/financial/currency_amount.js";
|
22
|
+
export * from "./entities/financial/currency.js";
|
23
|
+
export * from "./entities/financial/fungible_token_amount.js";
|
24
|
+
export * from "./entities/financial/fungible_token.js";
|
25
|
+
export * from "./entities/financial/non_fungible_token.js";
|
26
|
+
export * from "./entities/financial/semi_fungible_token.js";
|
27
|
+
export * from "./entities/account.js";
|
28
|
+
export * from "./entities/state.js";
|
29
|
+
// enums, types and constants
|
30
|
+
export * from "./enums.js";
|
31
|
+
export * from "./types.js";
|
32
|
+
export * from "./constants.js";
|
33
|
+
export * from "./utils/utils.js";
|