@avalabs/vm-module-types 0.0.22 → 0.1.0
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/LICENSE +9 -0
- package/dist/account.cjs +12 -0
- package/dist/account.cjs.map +1 -0
- package/dist/account.d.cts +34 -0
- package/dist/account.d.ts +34 -0
- package/dist/account.js +3 -0
- package/dist/account.js.map +1 -0
- package/dist/balance.d.cts +4 -5
- package/dist/balance.d.ts +4 -5
- package/dist/{chunk-H6ZZE5M7.js → chunk-7JLXTNPE.js} +1 -1
- package/dist/chunk-7JLXTNPE.js.map +1 -0
- package/dist/{chunk-BFBDZPL3.cjs → chunk-B6DAZDIA.cjs} +1 -1
- package/dist/chunk-B6DAZDIA.cjs.map +1 -0
- package/dist/chunk-RIBT5FN6.js +5 -0
- package/dist/chunk-RIBT5FN6.js.map +1 -0
- package/dist/chunk-TCBFAMPS.cjs +7 -0
- package/dist/chunk-TCBFAMPS.cjs.map +1 -0
- package/dist/coingecko.d.cts +4 -4
- package/dist/coingecko.d.ts +4 -4
- package/dist/index.cjs +18 -13
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/module.d.cts +2 -2
- package/dist/module.d.ts +2 -2
- package/dist/transaction-history.cjs +4 -4
- package/dist/transaction-history.d.cts +1 -1
- package/dist/transaction-history.d.ts +1 -1
- package/dist/transaction-history.js +1 -1
- package/package.json +6 -1
- package/.turbo/turbo-build.log +0 -130
- package/.turbo/turbo-lint.log +0 -4
- package/CHANGELOG.md +0 -102
- package/dist/chunk-BFBDZPL3.cjs.map +0 -1
- package/dist/chunk-H6ZZE5M7.js.map +0 -1
- package/src/balance.ts +0 -146
- package/src/coingecko.ts +0 -15
- package/src/common.ts +0 -43
- package/src/index.ts +0 -10
- package/src/manifest.ts +0 -40
- package/src/module.ts +0 -17
- package/src/network-fee.ts +0 -7
- package/src/rpc.ts +0 -157
- package/src/token.ts +0 -52
- package/src/transaction-history.ts +0 -113
- package/src/transaction-simulation.ts +0 -29
- package/tsconfig.json +0 -8
- package/tsup.config.ts +0 -4
package/src/rpc.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { TransactionRequest } from 'ethers';
|
|
2
|
-
import type { Caip2ChainId, Hex } from './common';
|
|
3
|
-
import type { JsonRpcError, EthereumProviderError, OptionalDataWithOptionalCause } from '@metamask/rpc-errors';
|
|
4
|
-
import type { BalanceChange, TokenApprovals } from './transaction-simulation';
|
|
5
|
-
|
|
6
|
-
export enum RpcMethod {
|
|
7
|
-
/* EVM */
|
|
8
|
-
ETH_SEND_TRANSACTION = 'eth_sendTransaction',
|
|
9
|
-
SIGN_TYPED_DATA_V3 = 'eth_signTypedData_v3',
|
|
10
|
-
SIGN_TYPED_DATA_V4 = 'eth_signTypedData_v4',
|
|
11
|
-
SIGN_TYPED_DATA_V1 = 'eth_signTypedData_v1',
|
|
12
|
-
SIGN_TYPED_DATA = 'eth_signTypedData',
|
|
13
|
-
PERSONAL_SIGN = 'personal_sign',
|
|
14
|
-
ETH_SIGN = 'eth_sign',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type DappInfo = {
|
|
18
|
-
name: string;
|
|
19
|
-
url: string;
|
|
20
|
-
icon: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type RpcRequest = {
|
|
24
|
-
requestId: string;
|
|
25
|
-
sessionId: string;
|
|
26
|
-
method: RpcMethod;
|
|
27
|
-
chainId: Caip2ChainId;
|
|
28
|
-
params: unknown;
|
|
29
|
-
dappInfo: DappInfo;
|
|
30
|
-
context?: Record<string, unknown>; // for storing additional context information that's only relevant to the consumer
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type RpcError =
|
|
34
|
-
| JsonRpcError<OptionalDataWithOptionalCause>
|
|
35
|
-
| EthereumProviderError<OptionalDataWithOptionalCause>;
|
|
36
|
-
|
|
37
|
-
export type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> =
|
|
38
|
-
| {
|
|
39
|
-
result: R;
|
|
40
|
-
}
|
|
41
|
-
| {
|
|
42
|
-
error: E;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export interface MessageTypeProperty {
|
|
46
|
-
name: string;
|
|
47
|
-
type: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface MessageTypes {
|
|
51
|
-
EIP712Domain: MessageTypeProperty[];
|
|
52
|
-
[additionalProperties: string]: MessageTypeProperty[];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface TypedData<T extends MessageTypes> {
|
|
56
|
-
types: T;
|
|
57
|
-
primaryType: keyof T;
|
|
58
|
-
domain: Record<string, unknown>;
|
|
59
|
-
message: Record<string, unknown>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type TypedDataV1 = { name: string; type: string; value: unknown }[];
|
|
63
|
-
|
|
64
|
-
export type DisplayData = {
|
|
65
|
-
title: string;
|
|
66
|
-
dAppInfo?: {
|
|
67
|
-
name: string;
|
|
68
|
-
action: string;
|
|
69
|
-
logoUri?: string;
|
|
70
|
-
};
|
|
71
|
-
network: {
|
|
72
|
-
chainId: number;
|
|
73
|
-
name: string;
|
|
74
|
-
logoUri?: string;
|
|
75
|
-
};
|
|
76
|
-
account?: string;
|
|
77
|
-
messageDetails?: string;
|
|
78
|
-
transactionDetails?: {
|
|
79
|
-
website: string;
|
|
80
|
-
from: string;
|
|
81
|
-
to: string;
|
|
82
|
-
data?: string;
|
|
83
|
-
type?: string;
|
|
84
|
-
};
|
|
85
|
-
networkFeeSelector?: boolean;
|
|
86
|
-
disclaimer?: string;
|
|
87
|
-
alert?: Alert;
|
|
88
|
-
balanceChange?: BalanceChange;
|
|
89
|
-
tokenApprovals?: TokenApprovals;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export enum AlertType {
|
|
93
|
-
WARNING = 'Warning',
|
|
94
|
-
DANGER = 'Danger',
|
|
95
|
-
INFO = 'Info',
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export type AlertDetails = {
|
|
99
|
-
title: string;
|
|
100
|
-
description: string;
|
|
101
|
-
detailedDescription?: string;
|
|
102
|
-
actionTitles?: {
|
|
103
|
-
proceed: string;
|
|
104
|
-
reject: string;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export type Alert = {
|
|
109
|
-
type: AlertType;
|
|
110
|
-
details: AlertDetails;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export type SigningData =
|
|
114
|
-
| {
|
|
115
|
-
type: RpcMethod.ETH_SEND_TRANSACTION;
|
|
116
|
-
account: string;
|
|
117
|
-
chainId: number;
|
|
118
|
-
data: TransactionRequest;
|
|
119
|
-
}
|
|
120
|
-
| {
|
|
121
|
-
type: RpcMethod.ETH_SIGN | RpcMethod.PERSONAL_SIGN;
|
|
122
|
-
account: string;
|
|
123
|
-
chainId: number;
|
|
124
|
-
data: string;
|
|
125
|
-
}
|
|
126
|
-
| {
|
|
127
|
-
type: RpcMethod.SIGN_TYPED_DATA | RpcMethod.SIGN_TYPED_DATA_V1;
|
|
128
|
-
account: string;
|
|
129
|
-
chainId: number;
|
|
130
|
-
data: TypedData<MessageTypes> | TypedDataV1;
|
|
131
|
-
}
|
|
132
|
-
| {
|
|
133
|
-
type: RpcMethod.SIGN_TYPED_DATA_V3 | RpcMethod.SIGN_TYPED_DATA_V4;
|
|
134
|
-
account: string;
|
|
135
|
-
chainId: number;
|
|
136
|
-
data: TypedData<MessageTypes>;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export type ApprovalParams = {
|
|
140
|
-
request: RpcRequest;
|
|
141
|
-
displayData: DisplayData;
|
|
142
|
-
signingData: SigningData;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
export type ApprovalResponse =
|
|
146
|
-
| {
|
|
147
|
-
result: Hex;
|
|
148
|
-
}
|
|
149
|
-
| {
|
|
150
|
-
error: RpcError;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export interface ApprovalController {
|
|
154
|
-
requestApproval: (params: ApprovalParams) => Promise<ApprovalResponse>;
|
|
155
|
-
onTransactionConfirmed: (txHash: Hex) => void;
|
|
156
|
-
onTransactionReverted: (txHash: Hex) => void;
|
|
157
|
-
}
|
package/src/token.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export enum TokenType {
|
|
2
|
-
NATIVE = 'NATIVE',
|
|
3
|
-
ERC20 = 'ERC20',
|
|
4
|
-
ERC721 = 'ERC721',
|
|
5
|
-
ERC1155 = 'ERC1155',
|
|
6
|
-
NONERC = 'NONERC',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface NetworkToken {
|
|
10
|
-
name: string;
|
|
11
|
-
symbol: string;
|
|
12
|
-
decimals: number;
|
|
13
|
-
logoUri?: string;
|
|
14
|
-
description?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type NetworkContractToken = ERC20Token | ERC1155Token | ERC721Token | NONERCToken;
|
|
18
|
-
|
|
19
|
-
export interface ERC20Token {
|
|
20
|
-
address: string;
|
|
21
|
-
chainId?: number;
|
|
22
|
-
color?: string;
|
|
23
|
-
type: TokenType.ERC20;
|
|
24
|
-
decimals: number;
|
|
25
|
-
logoUri?: string;
|
|
26
|
-
name: string;
|
|
27
|
-
symbol: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ERC1155Token {
|
|
31
|
-
address: string;
|
|
32
|
-
type: TokenType.ERC1155;
|
|
33
|
-
logoUri?: string;
|
|
34
|
-
name?: string;
|
|
35
|
-
symbol?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface ERC721Token {
|
|
39
|
-
address: string;
|
|
40
|
-
type: TokenType.ERC721;
|
|
41
|
-
logoUri?: string;
|
|
42
|
-
name?: string;
|
|
43
|
-
symbol?: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface NONERCToken {
|
|
47
|
-
address: string;
|
|
48
|
-
type: TokenType.NONERC;
|
|
49
|
-
logoUri?: string;
|
|
50
|
-
name?: string;
|
|
51
|
-
symbol?: string;
|
|
52
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { Network } from './common';
|
|
2
|
-
import type { TokenType } from './token';
|
|
3
|
-
|
|
4
|
-
export type GetTransactionHistory = {
|
|
5
|
-
network: Network;
|
|
6
|
-
address: string;
|
|
7
|
-
nextPageToken?: string;
|
|
8
|
-
offset?: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type TransactionHistoryResponse = {
|
|
12
|
-
transactions: Transaction[];
|
|
13
|
-
nextPageToken?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type Transaction = {
|
|
17
|
-
isContractCall: boolean;
|
|
18
|
-
isIncoming: boolean;
|
|
19
|
-
isOutgoing: boolean;
|
|
20
|
-
isSender: boolean;
|
|
21
|
-
timestamp: number;
|
|
22
|
-
hash: string;
|
|
23
|
-
from: string;
|
|
24
|
-
to: string;
|
|
25
|
-
tokens: TxToken[];
|
|
26
|
-
gasPrice?: string;
|
|
27
|
-
gasUsed: string;
|
|
28
|
-
txType?: TransactionType | PChainTransactionType | XChainTransactionType;
|
|
29
|
-
chainId: string; // chainId from ActiveNetwork used to fetch tx
|
|
30
|
-
method?: string;
|
|
31
|
-
explorerLink: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export interface TxToken {
|
|
35
|
-
decimal?: string;
|
|
36
|
-
name: string;
|
|
37
|
-
symbol: string;
|
|
38
|
-
amount: string;
|
|
39
|
-
imageUri?: string;
|
|
40
|
-
from?: TokenWithAddress;
|
|
41
|
-
to?: TokenWithAddress;
|
|
42
|
-
collectableTokenId?: string;
|
|
43
|
-
type: TokenType;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// this is RichAddress from @avalabs/glacier-sdk,
|
|
47
|
-
// rename it to TokenWithAddress for better understanding
|
|
48
|
-
type TokenWithAddress = {
|
|
49
|
-
/**
|
|
50
|
-
* The contract name.
|
|
51
|
-
*/
|
|
52
|
-
name?: string;
|
|
53
|
-
/**
|
|
54
|
-
* The contract symbol.
|
|
55
|
-
*/
|
|
56
|
-
symbol?: string;
|
|
57
|
-
/**
|
|
58
|
-
* The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.
|
|
59
|
-
*/
|
|
60
|
-
decimals?: number;
|
|
61
|
-
/**
|
|
62
|
-
* The logo uri for the address.
|
|
63
|
-
*/
|
|
64
|
-
logoUri?: string;
|
|
65
|
-
/**
|
|
66
|
-
* A wallet or contract address in mixed-case checksum encoding.
|
|
67
|
-
*/
|
|
68
|
-
address: string;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export enum TransactionType {
|
|
72
|
-
BRIDGE = 'Bridge',
|
|
73
|
-
SWAP = 'Swap',
|
|
74
|
-
SEND = 'Send',
|
|
75
|
-
RECEIVE = 'Receive',
|
|
76
|
-
NFT_BUY = 'NFTBuy',
|
|
77
|
-
APPROVE = 'Approve',
|
|
78
|
-
TRANSFER = 'Transfer',
|
|
79
|
-
NFT_SEND = 'NFTSend',
|
|
80
|
-
NFT_RECEIVE = 'NFTReceive',
|
|
81
|
-
AIRDROP = 'Airdrop',
|
|
82
|
-
FILL_ORDER = 'FillOrder',
|
|
83
|
-
UNWRAP = 'Unwrap',
|
|
84
|
-
UNKNOWN = 'UNKNOWN',
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export enum PChainTransactionType {
|
|
88
|
-
ADD_VALIDATOR_TX = 'AddValidatorTx',
|
|
89
|
-
ADD_SUBNET_VALIDATOR_TX = 'AddSubnetValidatorTx',
|
|
90
|
-
ADD_DELEGATOR_TX = 'AddDelegatorTx',
|
|
91
|
-
CREATE_CHAIN_TX = 'CreateChainTx',
|
|
92
|
-
CREATE_SUBNET_TX = 'CreateSubnetTx',
|
|
93
|
-
IMPORT_TX = 'ImportTx',
|
|
94
|
-
EXPORT_TX = 'ExportTx',
|
|
95
|
-
ADVANCE_TIME_TX = 'AdvanceTimeTx',
|
|
96
|
-
REWARD_VALIDATOR_TX = 'RewardValidatorTx',
|
|
97
|
-
REMOVE_SUBNET_VALIDATOR_TX = 'RemoveSubnetValidatorTx',
|
|
98
|
-
TRANSFORM_SUBNET_TX = 'TransformSubnetTx',
|
|
99
|
-
ADD_PERMISSIONLESS_VALIDATOR_TX = 'AddPermissionlessValidatorTx',
|
|
100
|
-
ADD_PERMISSIONLESS_DELEGATOR_TX = 'AddPermissionlessDelegatorTx',
|
|
101
|
-
BASE_TX = 'BaseTx',
|
|
102
|
-
TRANSFER_SUBNET_OWNERSHIP_TX = 'TransferSubnetOwnershipTx',
|
|
103
|
-
UNKNOWN = 'UNKNOWN',
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export enum XChainTransactionType {
|
|
107
|
-
BASE_TX = 'BaseTx',
|
|
108
|
-
CREATE_ASSET_TX = 'CreateAssetTx',
|
|
109
|
-
OPERATION_TX = 'OperationTx',
|
|
110
|
-
IMPORT_TX = 'ImportTx',
|
|
111
|
-
EXPORT_TX = 'ExportTx',
|
|
112
|
-
UNKNOWN = 'UNKNOWN',
|
|
113
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { NetworkContractToken, NetworkToken } from './token';
|
|
2
|
-
|
|
3
|
-
export type BalanceChange = {
|
|
4
|
-
ins: TokenDiff[];
|
|
5
|
-
outs: TokenDiff[];
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type TokenDiff = {
|
|
9
|
-
token: NetworkContractToken | NetworkToken;
|
|
10
|
-
items: TokenDiffItem[];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type TokenDiffItem = {
|
|
14
|
-
displayValue: string;
|
|
15
|
-
usdPrice: string | undefined;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type TokenApproval = {
|
|
19
|
-
token: NetworkContractToken;
|
|
20
|
-
spenderAddress: string;
|
|
21
|
-
value?: string;
|
|
22
|
-
usdPrice?: string;
|
|
23
|
-
logoUri?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type TokenApprovals = {
|
|
27
|
-
isEditable: boolean;
|
|
28
|
-
approvals: TokenApproval[];
|
|
29
|
-
};
|
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED