@orb-labs/orby-core 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/actions/account_cluster.d.ts +12 -5
- package/dist/actions/account_cluster.js +185 -338
- package/dist/actions/admin.d.ts +3 -3
- package/dist/actions/admin.js +37 -127
- package/dist/actions/application.d.ts +2 -2
- package/dist/actions/application.js +14 -77
- package/dist/actions/blockchain.d.ts +16 -0
- package/dist/actions/blockchain.js +35 -0
- package/dist/actions/instance.d.ts +3 -4
- package/dist/actions/instance.js +90 -255
- package/dist/actions/operation.d.ts +19 -10
- package/dist/actions/operation.js +323 -259
- package/dist/actions/token.d.ts +3 -3
- package/dist/actions/token.js +43 -119
- package/dist/constants.d.ts +3 -3
- package/dist/constants.js +70 -71
- package/dist/entities/account.d.ts +1 -1
- package/dist/entities/account.js +25 -30
- package/dist/entities/financial/account_balance.d.ts +2 -2
- package/dist/entities/financial/account_balance.js +20 -22
- package/dist/entities/financial/asset.js +13 -15
- package/dist/entities/financial/currency.d.ts +1 -1
- package/dist/entities/financial/currency.js +16 -35
- package/dist/entities/financial/currency_amount.d.ts +1 -1
- package/dist/entities/financial/currency_amount.js +49 -71
- package/dist/entities/financial/fungible_token.d.ts +3 -3
- package/dist/entities/financial/fungible_token.js +31 -52
- package/dist/entities/financial/fungible_token_amount.d.ts +2 -2
- package/dist/entities/financial/fungible_token_amount.js +53 -75
- package/dist/entities/financial/non_fungible_token.d.ts +2 -2
- package/dist/entities/financial/non_fungible_token.js +25 -45
- package/dist/entities/financial/semi_fungible_token.d.ts +2 -2
- package/dist/entities/financial/semi_fungible_token.js +25 -45
- package/dist/entities/library_request.d.ts +1 -1
- package/dist/entities/library_request.js +7 -9
- package/dist/entities/state.d.ts +4 -4
- package/dist/entities/state.js +57 -67
- package/dist/index.d.ts +29 -27
- package/dist/index.js +29 -27
- package/dist/interfaces/account_cluster.d.ts +11 -4
- package/dist/interfaces/admin.d.ts +1 -1
- package/dist/interfaces/blockchain.d.ts +13 -0
- package/dist/interfaces/blockchain.js +1 -0
- package/dist/interfaces/instance.d.ts +1 -2
- package/dist/interfaces/operation.d.ts +25 -10
- package/dist/interfaces/orby.d.ts +8 -7
- package/dist/interfaces/token.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +9 -9
- package/dist/utils/action_helpers.d.ts +1 -1
- package/dist/utils/action_helpers.js +43 -63
- package/dist/utils/utils.d.ts +2 -1
- package/dist/utils/utils.js +23 -19
- package/dist/utils/validateAndParseAddress.js +3 -3
- package/package.json +4 -2
package/dist/actions/token.js
CHANGED
@@ -1,122 +1,46 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
23
|
-
});
|
24
|
-
};
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
27
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
29
|
-
function step(op) {
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
31
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
34
|
-
switch (op[0]) {
|
35
|
-
case 0: case 1: t = op; break;
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
39
|
-
default:
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
44
|
-
if (t[2]) _.ops.pop();
|
45
|
-
_.trys.pop(); continue;
|
46
|
-
}
|
47
|
-
op = body.call(thisArg, _);
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
1
|
+
import { extractStandardizedToken, extractStandardizedTokens, } from "../utils/action_helpers.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
import { getOrbyChainId } from "../utils/utils.js";
|
4
|
+
export class TokenActions extends LibraryRequest {
|
5
|
+
constructor(library, client, provider) {
|
6
|
+
super(library, client, provider);
|
50
7
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
var TokenActions = /** @class */ (function (_super) {
|
55
|
-
__extends(TokenActions, _super);
|
56
|
-
function TokenActions(library, client, provider) {
|
57
|
-
return _super.call(this, library, client, provider) || this;
|
58
|
-
}
|
59
|
-
TokenActions.prototype.getStandardizedTokenIds = function (tokens) {
|
60
|
-
return __awaiter(this, void 0, void 0, function () {
|
61
|
-
var formattedTokensInfo, _a, standardizedTokenIds, message, code;
|
62
|
-
return __generator(this, function (_b) {
|
63
|
-
switch (_b.label) {
|
64
|
-
case 0:
|
65
|
-
formattedTokensInfo = tokens.map(function (_a) {
|
66
|
-
var tokenAddress = _a.tokenAddress, chainId = _a.chainId;
|
67
|
-
return { chainId: "EIP155-".concat(chainId), tokenAddress: tokenAddress };
|
68
|
-
});
|
69
|
-
return [4 /*yield*/, this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }])];
|
70
|
-
case 1:
|
71
|
-
_a = _b.sent(), standardizedTokenIds = _a.standardizedTokenIds, message = _a.message, code = _a.code;
|
72
|
-
if (code && message) {
|
73
|
-
console.error("[getStandardizedTokenIds]", code, message);
|
74
|
-
return [2 /*return*/, undefined];
|
75
|
-
}
|
76
|
-
return [2 /*return*/, standardizedTokenIds];
|
77
|
-
}
|
78
|
-
});
|
79
|
-
});
|
80
|
-
};
|
81
|
-
TokenActions.prototype.getStandardizedTokens = function (tokens) {
|
82
|
-
return __awaiter(this, void 0, void 0, function () {
|
83
|
-
var formattedTokensInfo, _a, standardizedTokens, message, code;
|
84
|
-
return __generator(this, function (_b) {
|
85
|
-
switch (_b.label) {
|
86
|
-
case 0:
|
87
|
-
formattedTokensInfo = tokens.map(function (_a) {
|
88
|
-
var tokenAddress = _a.tokenAddress, chainId = _a.chainId;
|
89
|
-
return { chainId: "EIP155-".concat(chainId), tokenAddress: tokenAddress };
|
90
|
-
});
|
91
|
-
return [4 /*yield*/, this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }])];
|
92
|
-
case 1:
|
93
|
-
_a = _b.sent(), standardizedTokens = _a.standardizedTokens, message = _a.message, code = _a.code;
|
94
|
-
if (code && message) {
|
95
|
-
console.error("[getStandardizedTokens]", code, message);
|
96
|
-
return [2 /*return*/, undefined];
|
97
|
-
}
|
98
|
-
return [2 /*return*/, extractStandardizedTokens(standardizedTokens)];
|
99
|
-
}
|
100
|
-
});
|
8
|
+
async getStandardizedTokenIds(tokens) {
|
9
|
+
const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
|
10
|
+
return { chainId: getOrbyChainId(chainId), tokenAddress };
|
101
11
|
});
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
}
|
117
|
-
});
|
12
|
+
const { standardizedTokenIds, message, code } = await this.sendRequest("orby_getStandardizedTokenIds", [
|
13
|
+
{
|
14
|
+
tokens: formattedTokensInfo,
|
15
|
+
},
|
16
|
+
]);
|
17
|
+
if (code && message) {
|
18
|
+
console.error("[getStandardizedTokenIds]", code, message);
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
return standardizedTokenIds;
|
22
|
+
}
|
23
|
+
async getStandardizedTokens(tokens) {
|
24
|
+
const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
|
25
|
+
return { chainId: getOrbyChainId(chainId), tokenAddress };
|
118
26
|
});
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
27
|
+
const { standardizedTokens, message, code } = await this.sendRequest("orby_getStandardizedTokens", [
|
28
|
+
{
|
29
|
+
tokens: formattedTokensInfo,
|
30
|
+
},
|
31
|
+
]);
|
32
|
+
if (code && message) {
|
33
|
+
console.error("[getStandardizedTokens]", code, message);
|
34
|
+
return undefined;
|
35
|
+
}
|
36
|
+
return extractStandardizedTokens(standardizedTokens);
|
37
|
+
}
|
38
|
+
async getFungibleTokenData(standardizedTokenIds) {
|
39
|
+
const { data, message, code } = await this.sendRequest("orby_getFungibleTokenData", [{ standardizedTokenIds }]);
|
40
|
+
if (code && message) {
|
41
|
+
console.error("[getFungibleTokenData]", code, message);
|
42
|
+
return undefined;
|
43
|
+
}
|
44
|
+
return extractStandardizedToken(data);
|
45
|
+
}
|
46
|
+
}
|
package/dist/constants.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { Blockchain } from "./enums";
|
2
|
-
import { Currency } from "./entities/financial/currency";
|
3
|
-
import { ChainConfigs } from "./types";
|
1
|
+
import { Blockchain } from "./enums.js";
|
2
|
+
import { Currency } from "./entities/financial/currency.js";
|
3
|
+
import { ChainConfigs } from "./types.js";
|
4
4
|
export declare const Big: any;
|
5
5
|
export declare const BLOCKCHAIN_ID: {
|
6
6
|
[s: string]: number;
|
package/dist/constants.js
CHANGED
@@ -1,134 +1,133 @@
|
|
1
|
-
var _a, _b, _c;
|
2
1
|
import toFormat from "toformat";
|
3
2
|
import _Big from "big.js";
|
4
|
-
import { Blockchain, BlockchainEnvironment } from "./enums";
|
5
|
-
import { Currency } from "./entities/financial/currency";
|
6
|
-
export
|
7
|
-
export
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
import { Blockchain, BlockchainEnvironment } from "./enums.js";
|
4
|
+
import { Currency } from "./entities/financial/currency.js";
|
5
|
+
export const Big = toFormat(_Big);
|
6
|
+
export const BLOCKCHAIN_ID = {
|
7
|
+
[Blockchain.ETHEREUM]: 1,
|
8
|
+
[Blockchain.POLYGON]: 137,
|
9
|
+
[Blockchain.BINANCE]: 56,
|
10
|
+
[Blockchain.ARBITRUM]: 42161,
|
11
|
+
[Blockchain.ARBITRUM_NOVA]: 42170,
|
12
|
+
[Blockchain.OPTIMISM]: 10,
|
13
|
+
[Blockchain.EVMOS]: 9001,
|
14
|
+
[Blockchain.MOONBEAM]: 1284,
|
15
|
+
[Blockchain.BASE]: 8453,
|
16
|
+
[Blockchain.AVALANCHE]: 43114,
|
18
17
|
// testnets
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
[Blockchain.ETHEREUM_SEPOLIA]: 11155111,
|
19
|
+
[Blockchain.ETHEREUM_HOLESKY]: 17000,
|
20
|
+
[Blockchain.ARBITRUM_SEPOLIA]: 421614,
|
21
|
+
[Blockchain.OPTIMISM_SEPOLIA]: 11155420,
|
22
|
+
[Blockchain.POLYGON_AMOY]: 80002,
|
23
|
+
[Blockchain.BINANCE_TESTNET]: 97,
|
24
|
+
[Blockchain.OPBNB_TESTNET]: 5611,
|
25
|
+
[Blockchain.MOONBEAM_ALPHA]: 1287,
|
26
|
+
[Blockchain.BASE_SEPOLIA]: 84532,
|
28
27
|
// local testing
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
export
|
34
|
-
|
28
|
+
[Blockchain.HARDHAT]: 31337,
|
29
|
+
[Blockchain.LOCAL_CHAIN_0]: 1_000_000_000_001,
|
30
|
+
[Blockchain.LOCAL_CHAIN_1]: 1_000_000_000_002,
|
31
|
+
};
|
32
|
+
export const CHAIN_CONFIGS = {
|
33
|
+
[Blockchain.ETHEREUM]: {
|
35
34
|
environment: BlockchainEnvironment.MAINNET,
|
36
35
|
chainId: BigInt(1),
|
37
36
|
},
|
38
|
-
|
37
|
+
[Blockchain.POLYGON]: {
|
39
38
|
environment: BlockchainEnvironment.MAINNET,
|
40
39
|
chainId: BigInt(137),
|
41
40
|
},
|
42
|
-
|
41
|
+
[Blockchain.BINANCE]: {
|
43
42
|
environment: BlockchainEnvironment.MAINNET,
|
44
43
|
chainId: BigInt(56),
|
45
44
|
},
|
46
|
-
|
45
|
+
[Blockchain.ARBITRUM]: {
|
47
46
|
environment: BlockchainEnvironment.MAINNET,
|
48
47
|
chainId: BigInt(42161),
|
49
48
|
},
|
50
|
-
|
49
|
+
[Blockchain.ARBITRUM_NOVA]: {
|
51
50
|
environment: BlockchainEnvironment.MAINNET,
|
52
51
|
chainId: BigInt(42170),
|
53
52
|
},
|
54
|
-
|
53
|
+
[Blockchain.OPTIMISM]: {
|
55
54
|
environment: BlockchainEnvironment.MAINNET,
|
56
55
|
chainId: BigInt(10),
|
57
56
|
},
|
58
|
-
|
57
|
+
[Blockchain.EVMOS]: {
|
59
58
|
environment: BlockchainEnvironment.MAINNET,
|
60
59
|
chainId: BigInt(9001),
|
61
60
|
},
|
62
|
-
|
61
|
+
[Blockchain.MOONBEAM]: {
|
63
62
|
environment: BlockchainEnvironment.MAINNET,
|
64
63
|
chainId: BigInt(1284),
|
65
64
|
},
|
66
|
-
|
65
|
+
[Blockchain.BASE]: {
|
67
66
|
environment: BlockchainEnvironment.MAINNET,
|
68
67
|
chainId: BigInt(8453),
|
69
68
|
},
|
70
|
-
|
69
|
+
[Blockchain.AVALANCHE]: {
|
71
70
|
environment: BlockchainEnvironment.MAINNET,
|
72
71
|
chainId: BigInt(43114),
|
73
72
|
},
|
74
73
|
// testnets
|
75
|
-
|
74
|
+
[Blockchain.ETHEREUM_SEPOLIA]: {
|
76
75
|
environment: BlockchainEnvironment.TESTNET,
|
77
76
|
chainId: BigInt(11155111),
|
78
77
|
},
|
79
|
-
|
78
|
+
[Blockchain.ETHEREUM_HOLESKY]: {
|
80
79
|
environment: BlockchainEnvironment.TESTNET,
|
81
80
|
chainId: BigInt(17000),
|
82
81
|
},
|
83
|
-
|
82
|
+
[Blockchain.ARBITRUM_SEPOLIA]: {
|
84
83
|
environment: BlockchainEnvironment.TESTNET,
|
85
84
|
chainId: BigInt(421614),
|
86
85
|
},
|
87
|
-
|
86
|
+
[Blockchain.BASE_SEPOLIA]: {
|
88
87
|
environment: BlockchainEnvironment.TESTNET,
|
89
88
|
chainId: BigInt(84532),
|
90
89
|
},
|
91
|
-
|
90
|
+
[Blockchain.OPTIMISM_SEPOLIA]: {
|
92
91
|
environment: BlockchainEnvironment.TESTNET,
|
93
92
|
chainId: BigInt(11155420),
|
94
93
|
},
|
95
|
-
|
94
|
+
[Blockchain.BINANCE_TESTNET]: {
|
96
95
|
environment: BlockchainEnvironment.TESTNET,
|
97
96
|
chainId: BigInt(97),
|
98
97
|
},
|
99
|
-
|
98
|
+
[Blockchain.OPBNB_TESTNET]: {
|
100
99
|
environment: BlockchainEnvironment.TESTNET,
|
101
100
|
chainId: BigInt(5611),
|
102
101
|
},
|
103
|
-
|
102
|
+
[Blockchain.MOONBEAM_ALPHA]: {
|
104
103
|
environment: BlockchainEnvironment.TESTNET,
|
105
104
|
chainId: BigInt(1287),
|
106
105
|
},
|
107
|
-
|
106
|
+
[Blockchain.POLYGON_AMOY]: {
|
108
107
|
environment: BlockchainEnvironment.TESTNET,
|
109
108
|
chainId: BigInt(80002),
|
110
109
|
},
|
111
|
-
|
112
|
-
export
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
110
|
+
};
|
111
|
+
export const BLOCKCHAIN_ID_TO_BLOCKCHAIN = {
|
112
|
+
[1]: Blockchain.ETHEREUM,
|
113
|
+
[137]: Blockchain.POLYGON,
|
114
|
+
[56]: Blockchain.BINANCE,
|
115
|
+
[42161]: Blockchain.ARBITRUM,
|
116
|
+
[42170]: Blockchain.ARBITRUM_NOVA,
|
117
|
+
[10]: Blockchain.OPTIMISM,
|
118
|
+
[9001]: Blockchain.EVMOS,
|
119
|
+
[1284]: Blockchain.MOONBEAM,
|
120
|
+
[8453]: Blockchain.BASE,
|
121
|
+
[43114]: Blockchain.AVALANCHE,
|
123
122
|
// testnets
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
export
|
123
|
+
[11155111]: Blockchain.ETHEREUM_SEPOLIA,
|
124
|
+
[84532]: Blockchain.BASE_SEPOLIA,
|
125
|
+
[17000]: Blockchain.ETHEREUM_HOLESKY,
|
126
|
+
[421614]: Blockchain.ARBITRUM_SEPOLIA,
|
127
|
+
[11155420]: Blockchain.OPTIMISM_SEPOLIA,
|
128
|
+
[80002]: Blockchain.POLYGON_AMOY,
|
129
|
+
[97]: Blockchain.BINANCE_TESTNET,
|
130
|
+
[5611]: Blockchain.OPBNB_TESTNET,
|
131
|
+
[1287]: Blockchain.MOONBEAM_ALPHA,
|
132
|
+
};
|
133
|
+
export const FIAT_CURRENCY = new Currency(6, "USD", "US Dollar", undefined, false, false);
|
package/dist/entities/account.js
CHANGED
@@ -1,10 +1,20 @@
|
|
1
|
-
import { AccountType } from "../enums";
|
2
|
-
import { getChainIdFromOrbyChainId } from "../utils/utils";
|
3
|
-
|
4
|
-
|
1
|
+
import { AccountType } from "../enums.js";
|
2
|
+
import { getChainIdFromOrbyChainId } from "../utils/utils.js";
|
3
|
+
export class Account {
|
4
|
+
static toAccount(account) {
|
5
|
+
const chainId = account?.chainId
|
6
|
+
? getChainIdFromOrbyChainId(account.chainId)
|
7
|
+
: undefined;
|
8
|
+
const formattedAccountType = account?.accountType?.toLowerCase();
|
9
|
+
if (!chainId && formattedAccountType == AccountType.SCA) {
|
10
|
+
return undefined;
|
11
|
+
}
|
12
|
+
return new Account(account.address, formattedAccountType, account.vmType, chainId);
|
13
|
+
}
|
14
|
+
constructor(address, accountType, vmType, chainId) {
|
5
15
|
// TODO(felix): add this back
|
6
16
|
// invariant(!_.isUndefined(getBlockchainFromBlockchainId(chainId)), "CHAIN_ID");
|
7
|
-
this.address = address
|
17
|
+
this.address = address?.toLowerCase(); // validateAndParseAddress(address)?.toLowerCase();
|
8
18
|
this.chainId = chainId ? BigInt(chainId) : undefined;
|
9
19
|
this.accountType = accountType;
|
10
20
|
this.vmType = vmType;
|
@@ -16,35 +26,20 @@ var Account = /** @class */ (function () {
|
|
16
26
|
this.hasSufficientBalanceForGas = false;
|
17
27
|
}
|
18
28
|
}
|
19
|
-
|
20
|
-
var _a;
|
21
|
-
var chainId = (account === null || account === void 0 ? void 0 : account.chainId)
|
22
|
-
? getChainIdFromOrbyChainId(account.chainId)
|
23
|
-
: undefined;
|
24
|
-
var formattedAccountType = (_a = account === null || account === void 0 ? void 0 : account.accountType) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
25
|
-
if (!chainId && formattedAccountType == AccountType.SCA) {
|
26
|
-
return undefined;
|
27
|
-
}
|
28
|
-
return new Account(account.address, formattedAccountType, account.vmType, chainId);
|
29
|
-
};
|
30
|
-
Account.key = function (address, chainId) {
|
31
|
-
var _a;
|
29
|
+
static key(address, chainId) {
|
32
30
|
return chainId
|
33
|
-
?
|
31
|
+
? `${chainId?.toString()?.toLowerCase()}-${address}`
|
34
32
|
: address;
|
35
|
-
}
|
36
|
-
|
37
|
-
var _a, _b;
|
33
|
+
}
|
34
|
+
toAccountModel() {
|
38
35
|
return {
|
39
36
|
address: this.address,
|
40
|
-
accountType:
|
41
|
-
vmType:
|
37
|
+
accountType: this.accountType?.toUpperCase(),
|
38
|
+
vmType: this.vmType?.toUpperCase(),
|
42
39
|
chainId: this.chainId ? "EIP155-" + this.chainId : undefined,
|
43
40
|
};
|
44
|
-
}
|
45
|
-
|
41
|
+
}
|
42
|
+
equals(other) {
|
46
43
|
return this.key == other.key && this.accountType == other.accountType;
|
47
|
-
}
|
48
|
-
|
49
|
-
}());
|
50
|
-
export { Account };
|
44
|
+
}
|
45
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Account } from "../account";
|
2
|
-
import { FungibleTokenAmount } from "./fungible_token_amount";
|
1
|
+
import { Account } from "../account.js";
|
2
|
+
import { FungibleTokenAmount } from "./fungible_token_amount.js";
|
3
3
|
export declare class AccountBalance {
|
4
4
|
readonly amount: FungibleTokenAmount;
|
5
5
|
readonly account: Account;
|
@@ -1,33 +1,31 @@
|
|
1
|
-
import { Account } from "../account";
|
2
|
-
import { FungibleTokenAmount } from "./fungible_token_amount";
|
3
|
-
|
4
|
-
|
5
|
-
this.amount = amount;
|
6
|
-
this.account = account;
|
7
|
-
}
|
8
|
-
AccountBalance.toAccountBalance = function (balance) {
|
1
|
+
import { Account } from "../account.js";
|
2
|
+
import { FungibleTokenAmount } from "./fungible_token_amount.js";
|
3
|
+
export class AccountBalance {
|
4
|
+
static toAccountBalance(balance) {
|
9
5
|
if (!balance) {
|
10
6
|
return undefined;
|
11
7
|
}
|
12
|
-
|
13
|
-
|
8
|
+
const amount = FungibleTokenAmount.toFungibleTokenAmount(balance.amount);
|
9
|
+
const account = Account.toAccount(balance.account);
|
14
10
|
return new AccountBalance(amount, account);
|
15
|
-
}
|
16
|
-
|
11
|
+
}
|
12
|
+
constructor(amount, account) {
|
13
|
+
this.amount = amount;
|
14
|
+
this.account = account;
|
15
|
+
}
|
16
|
+
equals(other) {
|
17
17
|
return (this.account.equals(other.account) && this.amount.equals(other.amount));
|
18
|
-
}
|
19
|
-
|
18
|
+
}
|
19
|
+
lessThan(other) {
|
20
20
|
return (this.account.equals(other.account) && this.amount.lessThan(other.amount));
|
21
|
-
}
|
22
|
-
|
21
|
+
}
|
22
|
+
greaterThan(other) {
|
23
23
|
return (this.account.equals(other.account) &&
|
24
24
|
this.amount.greaterThan(other.amount));
|
25
|
-
}
|
26
|
-
|
25
|
+
}
|
26
|
+
greaterThanOrEqual(other) {
|
27
27
|
return (this.account.equals(other.account) &&
|
28
28
|
(this.amount.greaterThan(other.amount) ||
|
29
29
|
this.amount.equals(other.amount)));
|
30
|
-
}
|
31
|
-
|
32
|
-
}());
|
33
|
-
export { AccountBalance };
|
30
|
+
}
|
31
|
+
}
|
@@ -1,13 +1,13 @@
|
|
1
1
|
/**
|
2
2
|
* An Asset is any fungible financial instrument, including Ether, all ERC20 tokens, and NFTs
|
3
3
|
*/
|
4
|
-
|
4
|
+
export class Asset {
|
5
5
|
/**
|
6
6
|
* Constructs an instance of the `Asset`.
|
7
7
|
* @param symbol symbol of the asset
|
8
8
|
* @param name of the asset
|
9
9
|
*/
|
10
|
-
|
10
|
+
constructor(symbol, name, coinGeckoId) {
|
11
11
|
this.symbol = symbol;
|
12
12
|
this.name = name;
|
13
13
|
this.coinGeckoId = coinGeckoId;
|
@@ -16,25 +16,23 @@ var Asset = /** @class */ (function () {
|
|
16
16
|
* Returns whether this asset is functionally equivalent to the other asset
|
17
17
|
* @param other the other asset
|
18
18
|
*/
|
19
|
-
|
19
|
+
equals(other) {
|
20
20
|
if (this === other)
|
21
21
|
return true;
|
22
22
|
return this.symbol === other.symbol && this.name === other.name;
|
23
|
-
}
|
23
|
+
}
|
24
24
|
// return Asset in the "@domains/orby/src/api/graphql/generated" but could not set type here because the generated code is not available for other domains
|
25
|
-
|
25
|
+
toAssetModel() {
|
26
26
|
return { symbol: this.symbol, name: this.name };
|
27
|
-
}
|
28
|
-
|
27
|
+
}
|
28
|
+
static toAsset(asset) {
|
29
29
|
if (!asset) {
|
30
30
|
return undefined;
|
31
31
|
}
|
32
|
-
|
32
|
+
const { symbol, name } = asset;
|
33
33
|
return new Asset(symbol, name);
|
34
|
-
}
|
35
|
-
|
36
|
-
return
|
37
|
-
}
|
38
|
-
|
39
|
-
}());
|
40
|
-
export { Asset };
|
34
|
+
}
|
35
|
+
id() {
|
36
|
+
return `${this.name}:${this.symbol}`;
|
37
|
+
}
|
38
|
+
}
|