@avalabs/vm-module-types 0.0.13 → 0.0.16
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/.turbo/turbo-build.log +107 -21
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/balance.cjs +6 -0
- package/dist/balance.d.cts +103 -0
- package/dist/balance.d.ts +103 -0
- package/dist/balance.js +3 -0
- package/dist/chunk-4PGCXP4C.cjs +10 -0
- package/dist/chunk-4PGCXP4C.cjs.map +1 -0
- package/dist/chunk-74SNNWSF.cjs +9 -0
- package/dist/chunk-74SNNWSF.cjs.map +1 -0
- package/dist/chunk-7FBUAZNW.cjs +8 -0
- package/dist/chunk-7FBUAZNW.cjs.map +1 -0
- package/dist/chunk-7U2R34EQ.js +3 -0
- package/dist/chunk-7U2R34EQ.js.map +1 -0
- package/dist/chunk-A4YEBDMG.js +7 -0
- package/dist/chunk-A4YEBDMG.js.map +1 -0
- package/dist/chunk-AILYKQEY.cjs +4 -0
- package/dist/chunk-AILYKQEY.cjs.map +1 -0
- package/dist/chunk-BFBDZPL3.cjs +9 -0
- package/dist/chunk-BFBDZPL3.cjs.map +1 -0
- package/dist/chunk-BHB5UV3J.js +3 -0
- package/dist/chunk-BHB5UV3J.js.map +1 -0
- package/dist/chunk-CUVJNZP5.js +3 -0
- package/dist/chunk-CUVJNZP5.js.map +1 -0
- package/dist/chunk-H6ZZE5M7.js +5 -0
- package/dist/chunk-H6ZZE5M7.js.map +1 -0
- package/dist/chunk-JUV577XH.cjs +4 -0
- package/dist/chunk-JUV577XH.cjs.map +1 -0
- package/dist/chunk-KVTVJNN4.cjs +7 -0
- package/dist/chunk-KVTVJNN4.cjs.map +1 -0
- package/dist/chunk-OGQBQHLH.cjs +4 -0
- package/dist/chunk-OGQBQHLH.cjs.map +1 -0
- package/dist/chunk-TSO5BGJ4.js +5 -0
- package/dist/chunk-TSO5BGJ4.js.map +1 -0
- package/dist/chunk-WOO6UGSQ.js +7 -0
- package/dist/chunk-WOO6UGSQ.js.map +1 -0
- package/dist/chunk-XMGYJ4KK.js +5 -0
- package/dist/chunk-XMGYJ4KK.js.map +1 -0
- package/dist/chunk-XQGU7MZ4.cjs +7 -0
- package/dist/chunk-XQGU7MZ4.cjs.map +1 -0
- package/dist/chunk-YJHKZHST.js +5 -0
- package/dist/chunk-YJHKZHST.js.map +1 -0
- package/dist/coingecko.cjs +16 -0
- package/dist/coingecko.cjs.map +1 -0
- package/dist/coingecko.d.cts +23 -0
- package/dist/coingecko.d.ts +23 -0
- package/dist/coingecko.js +3 -0
- package/dist/coingecko.js.map +1 -0
- package/dist/common.cjs +12 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +32 -0
- package/dist/common.d.ts +32 -0
- package/dist/common.js +3 -0
- package/dist/common.js.map +1 -0
- package/dist/index.cjs +31 -15
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +9 -1
- package/dist/manifest.cjs +12 -0
- package/dist/manifest.cjs.map +1 -0
- package/dist/manifest.d.cts +261 -0
- package/dist/manifest.d.ts +261 -0
- package/dist/manifest.js +3 -0
- package/dist/manifest.js.map +1 -0
- package/dist/module.cjs +6 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.d.cts +24 -0
- package/dist/module.d.ts +24 -0
- package/dist/module.js +3 -0
- package/dist/module.js.map +1 -0
- package/dist/network-fee.cjs +6 -0
- package/dist/network-fee.cjs.map +1 -0
- package/dist/network-fee.d.cts +18 -0
- package/dist/network-fee.d.ts +18 -0
- package/dist/network-fee.js +3 -0
- package/dist/network-fee.js.map +1 -0
- package/dist/rpc.cjs +16 -0
- package/dist/rpc.cjs.map +1 -0
- package/dist/rpc.d.cts +125 -0
- package/dist/rpc.d.ts +125 -0
- package/dist/rpc.js +3 -0
- package/dist/rpc.js.map +1 -0
- package/dist/token.cjs +12 -0
- package/dist/token.cjs.map +1 -0
- package/dist/token.d.cts +25 -0
- package/dist/token.d.ts +25 -0
- package/dist/token.js +3 -0
- package/dist/token.js.map +1 -0
- package/dist/transaction-history.cjs +20 -0
- package/dist/transaction-history.cjs.map +1 -0
- package/dist/transaction-history.d.cts +106 -0
- package/dist/transaction-history.d.ts +106 -0
- package/dist/transaction-history.js +3 -0
- package/dist/transaction-history.js.map +1 -0
- package/package.json +7 -2
- package/src/balance.ts +118 -0
- package/src/coingecko.ts +15 -0
- package/src/common.ts +34 -0
- package/src/index.ts +9 -1
- package/src/manifest.ts +40 -0
- package/src/module.ts +17 -0
- package/src/network-fee.ts +7 -0
- package/src/rpc.ts +144 -0
- package/src/token.ts +25 -0
- package/src/transaction-history.ts +113 -0
- package/dist/chunk-4RO2H63T.js +0 -7
- package/dist/chunk-4RO2H63T.js.map +0 -1
- package/dist/chunk-L7UO6W6T.cjs +0 -16
- package/dist/chunk-L7UO6W6T.cjs.map +0 -1
- package/dist/types.cjs +0 -40
- package/dist/types.d.cts +0 -516
- package/dist/types.d.ts +0 -516
- package/dist/types.js +0 -3
- package/src/types.ts +0 -328
- /package/dist/{types.cjs.map → balance.cjs.map} +0 -0
- /package/dist/{types.js.map → balance.js.map} +0 -0
package/dist/token.d.cts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface NetworkToken {
|
|
2
|
+
name: string;
|
|
3
|
+
symbol: string;
|
|
4
|
+
decimals: number;
|
|
5
|
+
logoUri?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
interface NetworkContractToken {
|
|
9
|
+
address: string;
|
|
10
|
+
chainId?: number;
|
|
11
|
+
color?: string;
|
|
12
|
+
contractType: string;
|
|
13
|
+
decimals: number;
|
|
14
|
+
logoUri?: string;
|
|
15
|
+
name: string;
|
|
16
|
+
symbol: string;
|
|
17
|
+
}
|
|
18
|
+
declare enum TokenType {
|
|
19
|
+
NATIVE = "NATIVE",
|
|
20
|
+
ERC20 = "ERC20",
|
|
21
|
+
ERC721 = "ERC721",
|
|
22
|
+
ERC1155 = "ERC1155"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { NetworkContractToken, NetworkToken, TokenType };
|
package/dist/token.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface NetworkToken {
|
|
2
|
+
name: string;
|
|
3
|
+
symbol: string;
|
|
4
|
+
decimals: number;
|
|
5
|
+
logoUri?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
interface NetworkContractToken {
|
|
9
|
+
address: string;
|
|
10
|
+
chainId?: number;
|
|
11
|
+
color?: string;
|
|
12
|
+
contractType: string;
|
|
13
|
+
decimals: number;
|
|
14
|
+
logoUri?: string;
|
|
15
|
+
name: string;
|
|
16
|
+
symbol: string;
|
|
17
|
+
}
|
|
18
|
+
declare enum TokenType {
|
|
19
|
+
NATIVE = "NATIVE",
|
|
20
|
+
ERC20 = "ERC20",
|
|
21
|
+
ERC721 = "ERC721",
|
|
22
|
+
ERC1155 = "ERC1155"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { NetworkContractToken, NetworkToken, TokenType };
|
package/dist/token.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkBFBDZPL3_cjs = require('./chunk-BFBDZPL3.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, 'PChainTransactionType', {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkBFBDZPL3_cjs.b; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, 'TransactionType', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkBFBDZPL3_cjs.a; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, 'XChainTransactionType', {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkBFBDZPL3_cjs.c; }
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=out.js.map
|
|
20
|
+
//# sourceMappingURL=transaction-history.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Network } from './common.cjs';
|
|
2
|
+
import { TokenType } from './token.cjs';
|
|
3
|
+
|
|
4
|
+
type GetTransactionHistory = {
|
|
5
|
+
network: Network;
|
|
6
|
+
address: string;
|
|
7
|
+
nextPageToken?: string;
|
|
8
|
+
offset?: number;
|
|
9
|
+
};
|
|
10
|
+
type TransactionHistoryResponse = {
|
|
11
|
+
transactions: Transaction[];
|
|
12
|
+
nextPageToken?: string;
|
|
13
|
+
};
|
|
14
|
+
type Transaction = {
|
|
15
|
+
isContractCall: boolean;
|
|
16
|
+
isIncoming: boolean;
|
|
17
|
+
isOutgoing: boolean;
|
|
18
|
+
isSender: boolean;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
hash: string;
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
tokens: TxToken[];
|
|
24
|
+
gasPrice?: string;
|
|
25
|
+
gasUsed: string;
|
|
26
|
+
txType?: TransactionType | PChainTransactionType | XChainTransactionType;
|
|
27
|
+
chainId: string;
|
|
28
|
+
method?: string;
|
|
29
|
+
explorerLink: string;
|
|
30
|
+
};
|
|
31
|
+
interface TxToken {
|
|
32
|
+
decimal?: string;
|
|
33
|
+
name: string;
|
|
34
|
+
symbol: string;
|
|
35
|
+
amount: string;
|
|
36
|
+
imageUri?: string;
|
|
37
|
+
from?: TokenWithAddress;
|
|
38
|
+
to?: TokenWithAddress;
|
|
39
|
+
collectableTokenId?: string;
|
|
40
|
+
type: TokenType;
|
|
41
|
+
}
|
|
42
|
+
type TokenWithAddress = {
|
|
43
|
+
/**
|
|
44
|
+
* The contract name.
|
|
45
|
+
*/
|
|
46
|
+
name?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The contract symbol.
|
|
49
|
+
*/
|
|
50
|
+
symbol?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.
|
|
53
|
+
*/
|
|
54
|
+
decimals?: number;
|
|
55
|
+
/**
|
|
56
|
+
* The logo uri for the address.
|
|
57
|
+
*/
|
|
58
|
+
logoUri?: string;
|
|
59
|
+
/**
|
|
60
|
+
* A wallet or contract address in mixed-case checksum encoding.
|
|
61
|
+
*/
|
|
62
|
+
address: string;
|
|
63
|
+
};
|
|
64
|
+
declare enum TransactionType {
|
|
65
|
+
BRIDGE = "Bridge",
|
|
66
|
+
SWAP = "Swap",
|
|
67
|
+
SEND = "Send",
|
|
68
|
+
RECEIVE = "Receive",
|
|
69
|
+
NFT_BUY = "NFTBuy",
|
|
70
|
+
APPROVE = "Approve",
|
|
71
|
+
TRANSFER = "Transfer",
|
|
72
|
+
NFT_SEND = "NFTSend",
|
|
73
|
+
NFT_RECEIVE = "NFTReceive",
|
|
74
|
+
AIRDROP = "Airdrop",
|
|
75
|
+
FILL_ORDER = "FillOrder",
|
|
76
|
+
UNWRAP = "Unwrap",
|
|
77
|
+
UNKNOWN = "UNKNOWN"
|
|
78
|
+
}
|
|
79
|
+
declare enum PChainTransactionType {
|
|
80
|
+
ADD_VALIDATOR_TX = "AddValidatorTx",
|
|
81
|
+
ADD_SUBNET_VALIDATOR_TX = "AddSubnetValidatorTx",
|
|
82
|
+
ADD_DELEGATOR_TX = "AddDelegatorTx",
|
|
83
|
+
CREATE_CHAIN_TX = "CreateChainTx",
|
|
84
|
+
CREATE_SUBNET_TX = "CreateSubnetTx",
|
|
85
|
+
IMPORT_TX = "ImportTx",
|
|
86
|
+
EXPORT_TX = "ExportTx",
|
|
87
|
+
ADVANCE_TIME_TX = "AdvanceTimeTx",
|
|
88
|
+
REWARD_VALIDATOR_TX = "RewardValidatorTx",
|
|
89
|
+
REMOVE_SUBNET_VALIDATOR_TX = "RemoveSubnetValidatorTx",
|
|
90
|
+
TRANSFORM_SUBNET_TX = "TransformSubnetTx",
|
|
91
|
+
ADD_PERMISSIONLESS_VALIDATOR_TX = "AddPermissionlessValidatorTx",
|
|
92
|
+
ADD_PERMISSIONLESS_DELEGATOR_TX = "AddPermissionlessDelegatorTx",
|
|
93
|
+
BASE_TX = "BaseTx",
|
|
94
|
+
TRANSFER_SUBNET_OWNERSHIP_TX = "TransferSubnetOwnershipTx",
|
|
95
|
+
UNKNOWN = "UNKNOWN"
|
|
96
|
+
}
|
|
97
|
+
declare enum XChainTransactionType {
|
|
98
|
+
BASE_TX = "BaseTx",
|
|
99
|
+
CREATE_ASSET_TX = "CreateAssetTx",
|
|
100
|
+
OPERATION_TX = "OperationTx",
|
|
101
|
+
IMPORT_TX = "ImportTx",
|
|
102
|
+
EXPORT_TX = "ExportTx",
|
|
103
|
+
UNKNOWN = "UNKNOWN"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { GetTransactionHistory, PChainTransactionType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, XChainTransactionType };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Network } from './common.js';
|
|
2
|
+
import { TokenType } from './token.js';
|
|
3
|
+
|
|
4
|
+
type GetTransactionHistory = {
|
|
5
|
+
network: Network;
|
|
6
|
+
address: string;
|
|
7
|
+
nextPageToken?: string;
|
|
8
|
+
offset?: number;
|
|
9
|
+
};
|
|
10
|
+
type TransactionHistoryResponse = {
|
|
11
|
+
transactions: Transaction[];
|
|
12
|
+
nextPageToken?: string;
|
|
13
|
+
};
|
|
14
|
+
type Transaction = {
|
|
15
|
+
isContractCall: boolean;
|
|
16
|
+
isIncoming: boolean;
|
|
17
|
+
isOutgoing: boolean;
|
|
18
|
+
isSender: boolean;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
hash: string;
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
tokens: TxToken[];
|
|
24
|
+
gasPrice?: string;
|
|
25
|
+
gasUsed: string;
|
|
26
|
+
txType?: TransactionType | PChainTransactionType | XChainTransactionType;
|
|
27
|
+
chainId: string;
|
|
28
|
+
method?: string;
|
|
29
|
+
explorerLink: string;
|
|
30
|
+
};
|
|
31
|
+
interface TxToken {
|
|
32
|
+
decimal?: string;
|
|
33
|
+
name: string;
|
|
34
|
+
symbol: string;
|
|
35
|
+
amount: string;
|
|
36
|
+
imageUri?: string;
|
|
37
|
+
from?: TokenWithAddress;
|
|
38
|
+
to?: TokenWithAddress;
|
|
39
|
+
collectableTokenId?: string;
|
|
40
|
+
type: TokenType;
|
|
41
|
+
}
|
|
42
|
+
type TokenWithAddress = {
|
|
43
|
+
/**
|
|
44
|
+
* The contract name.
|
|
45
|
+
*/
|
|
46
|
+
name?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The contract symbol.
|
|
49
|
+
*/
|
|
50
|
+
symbol?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.
|
|
53
|
+
*/
|
|
54
|
+
decimals?: number;
|
|
55
|
+
/**
|
|
56
|
+
* The logo uri for the address.
|
|
57
|
+
*/
|
|
58
|
+
logoUri?: string;
|
|
59
|
+
/**
|
|
60
|
+
* A wallet or contract address in mixed-case checksum encoding.
|
|
61
|
+
*/
|
|
62
|
+
address: string;
|
|
63
|
+
};
|
|
64
|
+
declare enum TransactionType {
|
|
65
|
+
BRIDGE = "Bridge",
|
|
66
|
+
SWAP = "Swap",
|
|
67
|
+
SEND = "Send",
|
|
68
|
+
RECEIVE = "Receive",
|
|
69
|
+
NFT_BUY = "NFTBuy",
|
|
70
|
+
APPROVE = "Approve",
|
|
71
|
+
TRANSFER = "Transfer",
|
|
72
|
+
NFT_SEND = "NFTSend",
|
|
73
|
+
NFT_RECEIVE = "NFTReceive",
|
|
74
|
+
AIRDROP = "Airdrop",
|
|
75
|
+
FILL_ORDER = "FillOrder",
|
|
76
|
+
UNWRAP = "Unwrap",
|
|
77
|
+
UNKNOWN = "UNKNOWN"
|
|
78
|
+
}
|
|
79
|
+
declare enum PChainTransactionType {
|
|
80
|
+
ADD_VALIDATOR_TX = "AddValidatorTx",
|
|
81
|
+
ADD_SUBNET_VALIDATOR_TX = "AddSubnetValidatorTx",
|
|
82
|
+
ADD_DELEGATOR_TX = "AddDelegatorTx",
|
|
83
|
+
CREATE_CHAIN_TX = "CreateChainTx",
|
|
84
|
+
CREATE_SUBNET_TX = "CreateSubnetTx",
|
|
85
|
+
IMPORT_TX = "ImportTx",
|
|
86
|
+
EXPORT_TX = "ExportTx",
|
|
87
|
+
ADVANCE_TIME_TX = "AdvanceTimeTx",
|
|
88
|
+
REWARD_VALIDATOR_TX = "RewardValidatorTx",
|
|
89
|
+
REMOVE_SUBNET_VALIDATOR_TX = "RemoveSubnetValidatorTx",
|
|
90
|
+
TRANSFORM_SUBNET_TX = "TransformSubnetTx",
|
|
91
|
+
ADD_PERMISSIONLESS_VALIDATOR_TX = "AddPermissionlessValidatorTx",
|
|
92
|
+
ADD_PERMISSIONLESS_DELEGATOR_TX = "AddPermissionlessDelegatorTx",
|
|
93
|
+
BASE_TX = "BaseTx",
|
|
94
|
+
TRANSFER_SUBNET_OWNERSHIP_TX = "TransferSubnetOwnershipTx",
|
|
95
|
+
UNKNOWN = "UNKNOWN"
|
|
96
|
+
}
|
|
97
|
+
declare enum XChainTransactionType {
|
|
98
|
+
BASE_TX = "BaseTx",
|
|
99
|
+
CREATE_ASSET_TX = "CreateAssetTx",
|
|
100
|
+
OPERATION_TX = "OperationTx",
|
|
101
|
+
IMPORT_TX = "ImportTx",
|
|
102
|
+
EXPORT_TX = "ExportTx",
|
|
103
|
+
UNKNOWN = "UNKNOWN"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { GetTransactionHistory, PChainTransactionType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, XChainTransactionType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avalabs/vm-module-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -12,8 +12,13 @@
|
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"tsup": "7.2.0",
|
|
15
|
+
"bn.js": "5.2.1",
|
|
16
|
+
"@types/bn.js": "5.1.5",
|
|
17
|
+
"@avalabs/coingecko-sdk": "v2.8.0-alpha.193",
|
|
18
|
+
"@avalabs/glacier-sdk": "v2.8.0-alpha.193",
|
|
19
|
+
"@avalabs/utils-sdk": "2.8.0-alpha.193",
|
|
15
20
|
"@internal/tsup-config": "0.0.1",
|
|
16
|
-
"eslint-config-custom": "0.0.
|
|
21
|
+
"eslint-config-custom": "0.0.1"
|
|
17
22
|
},
|
|
18
23
|
"peerDependencies": {
|
|
19
24
|
"ethers": "^6.8.1"
|
package/src/balance.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Storage, Network } from './common';
|
|
2
|
+
import type { NetworkContractToken, NetworkToken, TokenType } from './token';
|
|
3
|
+
import type BN from 'bn.js';
|
|
4
|
+
import type { PChainBalance, XChainBalances } from '@avalabs/glacier-sdk';
|
|
5
|
+
|
|
6
|
+
export type GetBalancesParams = {
|
|
7
|
+
addresses: string[];
|
|
8
|
+
network: Network;
|
|
9
|
+
customTokens?: NetworkContractToken[];
|
|
10
|
+
currency: string;
|
|
11
|
+
storage?: Storage;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type TokenBalanceData = {
|
|
15
|
+
type: TokenType;
|
|
16
|
+
name: string;
|
|
17
|
+
symbol: string;
|
|
18
|
+
balance: BN;
|
|
19
|
+
balanceInCurrency: number;
|
|
20
|
+
balanceDisplayValue: string;
|
|
21
|
+
balanceCurrencyDisplayValue: string;
|
|
22
|
+
priceInCurrency: number;
|
|
23
|
+
priceChanges?: {
|
|
24
|
+
percentage?: number;
|
|
25
|
+
value?: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type TokenMarketData = {
|
|
30
|
+
marketCap: number;
|
|
31
|
+
change24: number;
|
|
32
|
+
vol24: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type NetworkTokenWithBalance = TokenBalanceDataWithDecimals &
|
|
36
|
+
NetworkToken &
|
|
37
|
+
TokenMarketData & {
|
|
38
|
+
coingeckoId: string;
|
|
39
|
+
type: TokenType.NATIVE;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
interface TokenBalanceDataWithDecimals extends TokenBalanceData {
|
|
43
|
+
decimals: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* EVM TokenWithBalance interface.
|
|
48
|
+
*/
|
|
49
|
+
export type TokenWithBalanceERC20 = TokenBalanceDataWithDecimals &
|
|
50
|
+
TokenMarketData &
|
|
51
|
+
NetworkContractToken & {
|
|
52
|
+
type: TokenType.ERC20;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type TokenWithBalanceEVM = NetworkTokenWithBalance | TokenWithBalanceERC20;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Bitcoin TokenWithBalance interface.
|
|
59
|
+
*/
|
|
60
|
+
interface BitcoinInputUTXO {
|
|
61
|
+
txHash: string;
|
|
62
|
+
txHex?: string;
|
|
63
|
+
index: number;
|
|
64
|
+
value: number;
|
|
65
|
+
script: string;
|
|
66
|
+
blockHeight: number;
|
|
67
|
+
confirmations: number;
|
|
68
|
+
confirmedTime?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface BitcoinInputUTXOWithOptionalScript extends Omit<BitcoinInputUTXO, 'script'> {
|
|
72
|
+
script?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface TokenWithBalanceBTC extends NetworkTokenWithBalance {
|
|
76
|
+
logoUri: string;
|
|
77
|
+
utxos: BitcoinInputUTXOWithOptionalScript[];
|
|
78
|
+
utxosUnconfirmed?: BitcoinInputUTXOWithOptionalScript[];
|
|
79
|
+
unconfirmedBalance?: BN;
|
|
80
|
+
unconfirmedBalanceDisplayValue?: string;
|
|
81
|
+
unconfirmedBalanceCurrencyDisplayValue?: string;
|
|
82
|
+
unconfirmedBalanceInCurrency?: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Avalanche TokenWithBalance interface.
|
|
87
|
+
*/
|
|
88
|
+
export interface TokenWithBalancePVM extends NetworkTokenWithBalance {
|
|
89
|
+
available?: BN;
|
|
90
|
+
availableInCurrency?: number;
|
|
91
|
+
availableDisplayValue?: string;
|
|
92
|
+
availableCurrencyDisplayValue?: string;
|
|
93
|
+
utxos?: PChainBalance;
|
|
94
|
+
lockedStaked: number;
|
|
95
|
+
lockedStakeable: number;
|
|
96
|
+
lockedPlatform: number;
|
|
97
|
+
atomicMemoryLocked: number;
|
|
98
|
+
atomicMemoryUnlocked: number;
|
|
99
|
+
unlockedUnstaked: number;
|
|
100
|
+
unlockedStaked: number;
|
|
101
|
+
pendingStaked: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface TokenWithBalanceAVM extends NetworkTokenWithBalance {
|
|
105
|
+
available?: BN;
|
|
106
|
+
availableInCurrency?: number;
|
|
107
|
+
availableDisplayValue?: string;
|
|
108
|
+
availableCurrencyDisplayValue?: string;
|
|
109
|
+
utxos?: XChainBalances;
|
|
110
|
+
locked: number;
|
|
111
|
+
unlocked: number;
|
|
112
|
+
atomicMemoryUnlocked: number;
|
|
113
|
+
atomicMemoryLocked: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type TokenWithBalance = TokenWithBalanceEVM | TokenWithBalanceBTC | TokenWithBalancePVM | TokenWithBalanceAVM;
|
|
117
|
+
|
|
118
|
+
export type GetBalancesResponse = Record<string, Record<string, TokenWithBalance>>;
|
package/src/coingecko.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { number, object, record, z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const SimplePriceInCurrency = object({
|
|
4
|
+
price: number().optional().nullable(),
|
|
5
|
+
change24: number().optional().nullable(),
|
|
6
|
+
marketCap: number().optional().nullable(),
|
|
7
|
+
vol24: number().optional().nullable(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const SimplePriceInCurrencyResponseSchema = record(SimplePriceInCurrency);
|
|
11
|
+
export const SimplePriceResponseSchema = record(SimplePriceInCurrencyResponseSchema);
|
|
12
|
+
export type SimplePriceResponse = z.infer<typeof SimplePriceResponseSchema>;
|
|
13
|
+
|
|
14
|
+
export const RawSimplePriceResponseSchema = record(record(number().nullable().optional()));
|
|
15
|
+
export type RawSimplePriceResponse = z.infer<typeof RawSimplePriceResponseSchema>;
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { NetworkToken } from './token';
|
|
2
|
+
|
|
3
|
+
export type Network = {
|
|
4
|
+
isTestnet?: boolean;
|
|
5
|
+
chainId: number;
|
|
6
|
+
chainName: string;
|
|
7
|
+
rpcUrl: string;
|
|
8
|
+
utilityAddresses?: {
|
|
9
|
+
multicall: string;
|
|
10
|
+
};
|
|
11
|
+
networkToken: NetworkToken;
|
|
12
|
+
pricingProviders?: {
|
|
13
|
+
coingecko: {
|
|
14
|
+
assetPlatformId?: string;
|
|
15
|
+
nativeTokenId?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
explorerUrl?: string;
|
|
19
|
+
logoUri?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type Storage = {
|
|
23
|
+
get: <T>(id: string) => T | undefined;
|
|
24
|
+
set: <T>(id: string, data: T) => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type Caip2ChainId = string;
|
|
28
|
+
|
|
29
|
+
export type Hex = `0x${string}`;
|
|
30
|
+
|
|
31
|
+
export enum Environment {
|
|
32
|
+
PRODUCTION = 'production',
|
|
33
|
+
DEV = 'dev',
|
|
34
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './coingecko';
|
|
3
|
+
export * from './balance';
|
|
4
|
+
export * from './manifest';
|
|
5
|
+
export * from './module';
|
|
6
|
+
export * from './network-fee';
|
|
7
|
+
export * from './rpc';
|
|
8
|
+
export * from './token';
|
|
9
|
+
export * from './transaction-history';
|
package/src/manifest.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { boolean, object, string, z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const sourceSchema = object({
|
|
4
|
+
checksum: string(),
|
|
5
|
+
location: object({
|
|
6
|
+
npm: object({
|
|
7
|
+
filePath: string(),
|
|
8
|
+
packageName: string(),
|
|
9
|
+
registry: string(),
|
|
10
|
+
}),
|
|
11
|
+
}),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const manifestSchema = object({
|
|
15
|
+
name: string(),
|
|
16
|
+
version: string(),
|
|
17
|
+
description: string(),
|
|
18
|
+
sources: object({
|
|
19
|
+
module: sourceSchema,
|
|
20
|
+
provider: sourceSchema.optional(),
|
|
21
|
+
}),
|
|
22
|
+
network: object({
|
|
23
|
+
chainIds: string().array(),
|
|
24
|
+
namespaces: string().array(),
|
|
25
|
+
}),
|
|
26
|
+
cointype: string(),
|
|
27
|
+
permissions: object({
|
|
28
|
+
rpc: object({
|
|
29
|
+
dapps: boolean(),
|
|
30
|
+
methods: string().array(),
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
manifestVersion: string(),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export type Manifest = z.infer<typeof manifestSchema>;
|
|
37
|
+
|
|
38
|
+
export const parseManifest = (params: unknown): z.SafeParseReturnType<unknown, Manifest> => {
|
|
39
|
+
return manifestSchema.safeParse(params);
|
|
40
|
+
};
|
package/src/module.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GetBalancesParams, GetBalancesResponse } from './balance';
|
|
2
|
+
import type { Network } from './common';
|
|
3
|
+
import type { Manifest } from './manifest';
|
|
4
|
+
import type { NetworkFees } from './network-fee';
|
|
5
|
+
import type { RpcRequest, RpcResponse } from './rpc';
|
|
6
|
+
import type { NetworkContractToken } from './token';
|
|
7
|
+
import type { GetTransactionHistory, TransactionHistoryResponse } from './transaction-history';
|
|
8
|
+
|
|
9
|
+
export interface Module {
|
|
10
|
+
getManifest: () => Manifest | undefined;
|
|
11
|
+
getBalances: (params: GetBalancesParams) => Promise<GetBalancesResponse>;
|
|
12
|
+
getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;
|
|
13
|
+
getNetworkFee: (network: Network) => Promise<NetworkFees>;
|
|
14
|
+
getAddress: () => Promise<string>;
|
|
15
|
+
getTokens: (network: Network) => Promise<NetworkContractToken[]>;
|
|
16
|
+
onRpcRequest: (request: RpcRequest, chain: Network) => Promise<RpcResponse>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type NetworkFees = {
|
|
2
|
+
low: { maxFeePerGas: bigint; maxPriorityFeePerGas?: bigint };
|
|
3
|
+
medium: { maxFeePerGas: bigint; maxPriorityFeePerGas?: bigint };
|
|
4
|
+
high: { maxFeePerGas: bigint; maxPriorityFeePerGas?: bigint };
|
|
5
|
+
baseFee?: bigint;
|
|
6
|
+
isFixedFee: boolean;
|
|
7
|
+
};
|