@avalabs/vm-module-types 0.0.23 → 0.1.1

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 ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (C) 2021, Ava Labs, Inc. All rights reserved.
2
+
3
+ Subject to the limited license below (**”License””), you may not, and you may not permit anyone else to, copy, reproduce, aggregate, republish, download, post, distribute, license, sublicense, reverse engineer, modify, or create derivative works based on this software (collectively, **“Software”**).
4
+
5
+ You are hereby granted a limited, non-exclusive, non-sublicensable and non-transferable license to download and use the Software as-is solely (i) for use in connection with the Avalanche Public Blockchain platform, having a NetworkID of 1 (Mainnet) or 5 (Fuji), and associated blockchains, comprised exclusively of the Avalanche X-Chain, C-Chain, P-Chain and any subnets linked to the P-Chain (**“Avalanche Authorized Platform”**) or (ii) for non-production, testing or research purposes without any commercial application within the Avalanche ecosystem (**“Non-Commercial Use”**); provided that, in each case, you may not use or allow use of the Software (a) in connection with any forks of the Avalanche Authorized Platform, (b) in any manner not operationally connected to the Avalanche Authorized Platform other than for Non-Commercial Use, or (c) to the extent the number of monthly active users or the number of total installs of any software that uses the Software across all versions thereof exceeds 10,000 at any time. You may not modify or alter the Software in any way.
6
+
7
+ You hereby acknowledge and agree to the terms set forth at www.avalabs.org/important-notice.
8
+
9
+ **TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED ON AN “AS IS” BASIS, AND AVA LABS EXPRESSLY DISCLAIMS AND EXCLUDES ALL REPRESENTATIONS, WARRANTIES AND OTHER TERMS AND CONDITIONS, WHETHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION BY OPERATION OF LAW OR BY CUSTOM, STATUTE OR OTHERWISE, AND INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTY, TERM, OR CONDITION OF NON-INFRINGEMENT, MERCHANTABILITY, TITLE, OR FITNESS FOR PARTICULAR PURPOSE. YOU USE THE SOFTWARE AT YOUR OWN RISK. AVA LABS EXPRESSLY DISCLAIMS ALL LIABILITY (INCLUDING FOR ALL DIRECT, CONSEQUENTIAL OR OTHER DAMAGES OR LOSSES) RELATED TO ANY USE OF THE SOFTWARE.**
package/README.md CHANGED
@@ -6,4 +6,4 @@ This package exposes the types for the VM modules
6
6
 
7
7
  ## Installation
8
8
 
9
- The module is privately available on NPM as `@avalabs/vm-module-types`
9
+ The module is available on NPM as `@avalabs/vm-module-types`
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@avalabs/vm-module-types",
3
- "version": "0.0.23",
3
+ "version": "0.1.1",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "type": "module",
8
+ "files": [
9
+ "dist",
10
+ "manifest.json"
11
+ ],
12
+ "license": "Limited Ecosystem License",
8
13
  "dependencies": {
9
14
  "zod": "3.23.8",
10
15
  "@metamask/rpc-errors": "6.3.0",
@@ -14,9 +19,9 @@
14
19
  "tsup": "7.2.0",
15
20
  "bn.js": "5.2.1",
16
21
  "@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",
22
+ "@avalabs/core-coingecko-sdk": "3.0.0",
23
+ "@avalabs/glacier-sdk": "3.0.0",
24
+ "@avalabs/core-utils-sdk": "3.0.0",
20
25
  "@internal/tsup-config": "0.0.1",
21
26
  "eslint-config-custom": "0.0.1"
22
27
  },
@@ -1,140 +0,0 @@
1
-
2
- > @avalabs/vm-module-types@0.0.23 build /home/runner/work/vm-modules/vm-modules/packages/types
3
- > tsup
4
-
5
- CLI Building entry: src/account.ts, src/balance.ts, src/coingecko.ts, src/common.ts, src/index.ts, src/manifest.ts, src/module.ts, src/network-fee.ts, src/rpc.ts, src/token.ts, src/transaction-history.ts, src/transaction-simulation.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v7.2.0
8
- CLI Using tsup config: /home/runner/work/vm-modules/vm-modules/packages/types/tsup.config.ts
9
- CLI Target: es2021
10
- CLI Cleaning output folder
11
- CJS Build start
12
- ESM Build start
13
- Generated an empty chunk: "chunk-47KTBBRA".
14
- Generated an empty chunk: "chunk-JUV577XH".
15
- Generated an empty chunk: "chunk-OGQBQHLH".
16
- Generated an empty chunk: "chunk-AILYKQEY".
17
- Generated an empty chunk: "chunk-P6AM7I3B".
18
- Generated an empty chunk: "chunk-BHB5UV3J".
19
- Generated an empty chunk: "chunk-CUVJNZP5".
20
- Generated an empty chunk: "chunk-7U2R34EQ".
21
- CJS dist/chunk-YVYCETG2.cjs 483.00 B
22
- CJS dist/chunk-2KGTZTXY.cjs 219.00 B
23
- CJS dist/chunk-B6DAZDIA.cjs 1.21 KB
24
- CJS dist/chunk-47KTBBRA.cjs 90.00 B
25
- CJS dist/chunk-TCBFAMPS.cjs 240.00 B
26
- CJS dist/chunk-JUV577XH.cjs 90.00 B
27
- CJS dist/chunk-VRQJHO4F.cjs 276.00 B
28
- CJS dist/chunk-OGQBQHLH.cjs 90.00 B
29
- CJS dist/chunk-AILYKQEY.cjs 90.00 B
30
- CJS dist/rpc.cjs 377.00 B
31
- CJS dist/token.cjs 260.00 B
32
- CJS dist/transaction-history.cjs 542.00 B
33
- CJS dist/transaction-simulation.cjs 132.00 B
34
- CJS dist/account.cjs 263.00 B
35
- CJS dist/balance.cjs 117.00 B
36
- CJS dist/coingecko.cjs 418.00 B
37
- CJS dist/common.cjs 386.00 B
38
- CJS dist/index.cjs 2.07 KB
39
- CJS dist/chunk-4PGCXP4C.cjs 433.00 B
40
- CJS dist/manifest.cjs 267.00 B
41
- CJS dist/chunk-74SNNWSF.cjs 667.00 B
42
- CJS dist/module.cjs 116.00 B
43
- CJS dist/network-fee.cjs 121.00 B
44
- CJS dist/chunk-YVYCETG2.cjs.map 4.03 KB
45
- CJS dist/chunk-2KGTZTXY.cjs.map 1.18 KB
46
- CJS dist/chunk-B6DAZDIA.cjs.map 3.72 KB
47
- CJS dist/chunk-47KTBBRA.cjs.map 51.00 B
48
- CJS dist/chunk-TCBFAMPS.cjs.map 997.00 B
49
- CJS dist/chunk-JUV577XH.cjs.map 51.00 B
50
- CJS dist/chunk-VRQJHO4F.cjs.map 1.08 KB
51
- CJS dist/chunk-OGQBQHLH.cjs.map 51.00 B
52
- CJS dist/chunk-AILYKQEY.cjs.map 51.00 B
53
- CJS dist/rpc.cjs.map 51.00 B
54
- CJS dist/token.cjs.map 51.00 B
55
- CJS dist/transaction-history.cjs.map 51.00 B
56
- CJS dist/transaction-simulation.cjs.map 51.00 B
57
- CJS dist/account.cjs.map 51.00 B
58
- CJS dist/balance.cjs.map 51.00 B
59
- CJS dist/coingecko.cjs.map 51.00 B
60
- CJS dist/common.cjs.map 51.00 B
61
- CJS dist/index.cjs.map 51.00 B
62
- CJS dist/chunk-4PGCXP4C.cjs.map 1.24 KB
63
- CJS dist/manifest.cjs.map 51.00 B
64
- CJS dist/chunk-74SNNWSF.cjs.map 1.65 KB
65
- CJS dist/module.cjs.map 51.00 B
66
- CJS dist/network-fee.cjs.map 51.00 B
67
- CJS ⚡️ Build success in 1489ms
68
- ESM dist/chunk-RKFOXZ35.js 464.00 B
69
- ESM dist/chunk-7Y6UGMPZ.js 207.00 B
70
- ESM dist/chunk-7JLXTNPE.js 1.18 KB
71
- ESM dist/chunk-P6AM7I3B.js 75.00 B
72
- ESM dist/chunk-RIBT5FN6.js 228.00 B
73
- ESM dist/chunk-BHB5UV3J.js 75.00 B
74
- ESM dist/chunk-4BNYMHOY.js 257.00 B
75
- ESM dist/chunk-CUVJNZP5.js 75.00 B
76
- ESM dist/chunk-7U2R34EQ.js 75.00 B
77
- ESM dist/rpc.js 133.00 B
78
- ESM dist/token.js 119.00 B
79
- ESM dist/transaction-history.js 195.00 B
80
- ESM dist/transaction-simulation.js 112.00 B
81
- ESM dist/account.js 122.00 B
82
- ESM dist/balance.js 97.00 B
83
- ESM dist/coingecko.js 174.00 B
84
- ESM dist/common.js 142.00 B
85
- ESM dist/index.js 719.00 B
86
- ESM dist/chunk-WOO6UGSQ.js 394.00 B
87
- ESM dist/manifest.js 126.00 B
88
- ESM dist/chunk-A4YEBDMG.js 592.00 B
89
- ESM dist/module.js 96.00 B
90
- ESM dist/network-fee.js 101.00 B
91
- ESM dist/chunk-RKFOXZ35.js.map 4.03 KB
92
- ESM dist/chunk-7Y6UGMPZ.js.map 1.18 KB
93
- ESM dist/chunk-7JLXTNPE.js.map 3.72 KB
94
- ESM dist/chunk-P6AM7I3B.js.map 51.00 B
95
- ESM dist/chunk-RIBT5FN6.js.map 997.00 B
96
- ESM dist/chunk-BHB5UV3J.js.map 51.00 B
97
- ESM dist/chunk-4BNYMHOY.js.map 1.08 KB
98
- ESM dist/chunk-CUVJNZP5.js.map 51.00 B
99
- ESM dist/chunk-7U2R34EQ.js.map 51.00 B
100
- ESM dist/rpc.js.map 51.00 B
101
- ESM dist/token.js.map 51.00 B
102
- ESM dist/transaction-history.js.map 51.00 B
103
- ESM dist/transaction-simulation.js.map 51.00 B
104
- ESM dist/account.js.map 51.00 B
105
- ESM dist/balance.js.map 51.00 B
106
- ESM dist/coingecko.js.map 51.00 B
107
- ESM dist/common.js.map 51.00 B
108
- ESM dist/index.js.map 51.00 B
109
- ESM dist/chunk-WOO6UGSQ.js.map 1.24 KB
110
- ESM dist/manifest.js.map 51.00 B
111
- ESM dist/chunk-A4YEBDMG.js.map 1.65 KB
112
- ESM dist/module.js.map 51.00 B
113
- ESM dist/network-fee.js.map 51.00 B
114
- ESM ⚡️ Build success in 1500ms
115
- DTS Build start
116
- DTS ⚡️ Build success in 10489ms
117
- DTS dist/index.d.cts 1.53 KB
118
- DTS dist/coingecko.d.cts 1.09 KB
119
- DTS dist/module.d.cts 1.13 KB
120
- DTS dist/account.d.cts 841.00 B
121
- DTS dist/balance.d.cts 3.80 KB
122
- DTS dist/manifest.d.cts 6.95 KB
123
- DTS dist/network-fee.d.cts 361.00 B
124
- DTS dist/rpc.d.cts 3.65 KB
125
- DTS dist/transaction-history.d.cts 2.91 KB
126
- DTS dist/common.d.cts 902.00 B
127
- DTS dist/transaction-simulation.d.cts 642.00 B
128
- DTS dist/token.d.cts 1.05 KB
129
- DTS dist/index.d.ts 1.52 KB
130
- DTS dist/coingecko.d.ts 1.09 KB
131
- DTS dist/module.d.ts 1.12 KB
132
- DTS dist/account.d.ts 841.00 B
133
- DTS dist/balance.d.ts 3.80 KB
134
- DTS dist/manifest.d.ts 6.95 KB
135
- DTS dist/network-fee.d.ts 361.00 B
136
- DTS dist/rpc.d.ts 3.65 KB
137
- DTS dist/transaction-history.d.ts 2.91 KB
138
- DTS dist/common.d.ts 901.00 B
139
- DTS dist/transaction-simulation.d.ts 641.00 B
140
- DTS dist/token.d.ts 1.05 KB
@@ -1,4 +0,0 @@
1
-
2
- > @avalabs/vm-module-types@0.0.23 lint /home/runner/work/vm-modules/vm-modules/packages/types
3
- > eslint "src/**/*.ts"
4
-
package/CHANGELOG.md DELETED
@@ -1,108 +0,0 @@
1
- # @avalabs/vm-module-types
2
-
3
- ## 0.0.23
4
-
5
- ### Patch Changes
6
-
7
- - fbdefd2: Replace BN with bigint
8
-
9
- ## 0.0.22
10
-
11
- ## 0.0.21
12
-
13
- ## 0.0.20
14
-
15
- ### Patch Changes
16
-
17
- - 9bfa82d: Implement balance fetching for BitcoinModule
18
-
19
- ## 0.0.19
20
-
21
- ### Patch Changes
22
-
23
- - 5af458b: Add getBalances to avalanche-module
24
-
25
- ## 0.0.18
26
-
27
- ## 0.0.17
28
-
29
- ### Patch Changes
30
-
31
- - 3590edf: Transaction parsing, validation and simulation for EVM
32
-
33
- ## 0.0.16
34
-
35
- ### Patch Changes
36
-
37
- - bc48457: add support for all eth_sign methods
38
-
39
- ## 0.0.15
40
-
41
- ### Patch Changes
42
-
43
- - f536d58: add module functions to evm-module
44
-
45
- ## 0.0.14
46
-
47
- ### Patch Changes
48
-
49
- - 0593258: add getBalances to evm-module
50
-
51
- ## 0.0.13
52
-
53
- ### Patch Changes
54
-
55
- - af68c81: Add getTransactionHistory to avalanche module
56
- - d9fa0f5: added getNetworkFee to avalanche module
57
-
58
- ## 0.0.12
59
-
60
- ### Patch Changes
61
-
62
- - cd97708: fix: build types package
63
- - d0c2cc9: make module interface more consistent
64
- - 7bc6c6e: add eth_sendTransaction handler
65
-
66
- ## 0.0.11
67
-
68
- ## 0.0.10
69
-
70
- ### Patch Changes
71
-
72
- - 60f36fa: add getTokens function
73
-
74
- ## 0.0.9
75
-
76
- ### Patch Changes
77
-
78
- - 6ffa356: add module functions to evm-module
79
-
80
- ## 0.0.8
81
-
82
- ### Patch Changes
83
-
84
- - d1d080f: test release
85
-
86
- ## 0.0.7
87
-
88
- ### Patch Changes
89
-
90
- - bb98621: Move types to @avalabs/vm-module-types
91
-
92
- ## 0.0.6
93
-
94
- ### Patch Changes
95
-
96
- - 1122704: test release
97
-
98
- ## 0.0.3
99
-
100
- ### Patch Changes
101
-
102
- - 0b0c52e: Move types to @avalabs/vm-module-types
103
-
104
- ## 0.0.2
105
-
106
- ### Patch Changes
107
-
108
- - 4b7d5e9: Move types from packages-internal/types to packages/types
package/src/account.ts DELETED
@@ -1,37 +0,0 @@
1
- export enum WalletType {
2
- // Primary wallet types
3
- Mnemonic = 'mnemonic',
4
- Ledger = 'ledger',
5
- LedgerLive = 'ledger-live',
6
- Keystone = 'keystone',
7
- Seedless = 'seedless',
8
- }
9
-
10
- export type GetAddressParams = {
11
- walletType: WalletType;
12
- accountIndex: number;
13
- xpub: string;
14
- xpubXP?: string;
15
- isTestnet?: boolean;
16
- };
17
-
18
- export type GetAddressResponse = Record<string, string>;
19
-
20
- export type PubKeyType = {
21
- evm: string;
22
- /**
23
- * Public keys used for X/P chain are from a different derivation path.
24
- */
25
- xp?: string;
26
- btcWalletPolicyDetails?: BtcWalletPolicyDetails;
27
- };
28
-
29
- export type BtcWalletPolicyDetails = {
30
- hmacHex: string;
31
- /**
32
- * Extended public key of m/44'/60'/n
33
- */
34
- xpub: string;
35
- masterFingerprint: string;
36
- name: string;
37
- };
package/src/balance.ts DELETED
@@ -1,145 +0,0 @@
1
- import type { Storage, Network } from './common';
2
- import type { NetworkContractToken, NetworkToken, TokenType } from './token';
3
- import type { PChainBalance, XChainBalances } from '@avalabs/glacier-sdk';
4
-
5
- export type GetBalancesParams = {
6
- addresses: string[];
7
- network: Network;
8
- customTokens?: NetworkContractToken[];
9
- currency: string;
10
- storage?: Storage;
11
- };
12
-
13
- export type TokenBalanceData = {
14
- type: TokenType;
15
- name: string;
16
- symbol: string;
17
- balance: bigint;
18
- balanceDisplayValue: string;
19
- balanceInCurrency?: number;
20
- balanceCurrencyDisplayValue?: string;
21
- };
22
-
23
- export type TokenMarketData = {
24
- priceInCurrency?: number;
25
- priceChanges?: {
26
- percentage?: number;
27
- value?: number;
28
- };
29
- marketCap?: number;
30
- change24?: number;
31
- vol24?: number;
32
- };
33
-
34
- export type NetworkTokenWithBalance = TokenBalanceDataWithDecimals &
35
- NetworkToken &
36
- TokenMarketData & {
37
- coingeckoId: string;
38
- type: TokenType.NATIVE;
39
- };
40
-
41
- interface TokenBalanceDataWithDecimals extends TokenBalanceData {
42
- decimals: number;
43
- }
44
-
45
- /**
46
- * EVM TokenWithBalance interface.
47
- */
48
- export type TokenWithBalanceERC20 = TokenBalanceDataWithDecimals &
49
- TokenMarketData &
50
- NetworkContractToken & {
51
- type: TokenType.ERC20;
52
- };
53
-
54
- export type TokenWithBalanceEVM = NetworkTokenWithBalance | TokenWithBalanceERC20;
55
-
56
- /**
57
- * Bitcoin TokenWithBalance interface.
58
- */
59
- interface BitcoinInputUTXO {
60
- txHash: string;
61
- txHex?: string;
62
- index: number;
63
- value: number;
64
- script: string;
65
- blockHeight: number;
66
- confirmations: number;
67
- confirmedTime?: string;
68
- }
69
-
70
- interface BitcoinInputUTXOWithOptionalScript extends Omit<BitcoinInputUTXO, 'script'> {
71
- script?: string;
72
- }
73
-
74
- export interface TokenWithBalanceBTC extends NetworkTokenWithBalance {
75
- logoUri: string;
76
- utxos: BitcoinInputUTXOWithOptionalScript[];
77
- utxosUnconfirmed?: BitcoinInputUTXOWithOptionalScript[];
78
- unconfirmedBalance?: bigint;
79
- unconfirmedBalanceDisplayValue?: string;
80
- unconfirmedBalanceCurrencyDisplayValue?: string;
81
- unconfirmedBalanceInCurrency?: number;
82
- }
83
-
84
- /**
85
- * Avalanche TokenWithBalance interface.
86
- */
87
- export interface TokenWithBalancePVM extends NetworkTokenWithBalance {
88
- available?: bigint;
89
- availableInCurrency?: number;
90
- availableDisplayValue?: string;
91
- availableCurrencyDisplayValue?: string;
92
- utxos?: PChainBalance;
93
- balancePerType: {
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
-
105
- export interface TokenWithBalanceAVM extends NetworkTokenWithBalance {
106
- available?: bigint;
107
- availableInCurrency?: number;
108
- availableDisplayValue?: string;
109
- availableCurrencyDisplayValue?: string;
110
- utxos?: XChainBalances;
111
- balancePerType: {
112
- locked: number;
113
- unlocked: number;
114
- atomicMemoryUnlocked: number;
115
- atomicMemoryLocked: number;
116
- };
117
- }
118
-
119
- export interface NftTokenWithBalance extends Omit<NetworkTokenWithBalance, 'type'> {
120
- type: TokenType.ERC721 | TokenType.ERC1155;
121
- address: string;
122
- description: string;
123
- logoUri: string;
124
- logoSmall: string;
125
- name: string;
126
- symbol: string;
127
- tokenId: string;
128
- attributes: TokenAttribute[];
129
- collectionName: string;
130
- updatedAt?: number;
131
- }
132
-
133
- export interface TokenAttribute {
134
- name: string;
135
- value: string;
136
- }
137
-
138
- export type TokenWithBalance =
139
- | TokenWithBalanceEVM
140
- | TokenWithBalanceBTC
141
- | TokenWithBalancePVM
142
- | TokenWithBalanceAVM
143
- | NftTokenWithBalance;
144
-
145
- export type GetBalancesResponse = Record<string, Record<string, TokenWithBalance>>;
package/src/coingecko.ts DELETED
@@ -1,15 +0,0 @@
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 DELETED
@@ -1,43 +0,0 @@
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
- vmName: NetworkVMType;
21
- };
22
-
23
- export enum NetworkVMType {
24
- EVM = 'EVM',
25
- BITCOIN = 'BITCOIN',
26
- AVM = 'AVM',
27
- PVM = 'PVM',
28
- CoreEth = 'CoreEth',
29
- }
30
-
31
- export type Storage = {
32
- get: <T>(id: string) => T | undefined;
33
- set: <T>(id: string, data: T) => void;
34
- };
35
-
36
- export type Caip2ChainId = string;
37
-
38
- export type Hex = `0x${string}`;
39
-
40
- export enum Environment {
41
- PRODUCTION = 'production',
42
- DEV = 'dev',
43
- }
package/src/index.ts DELETED
@@ -1,11 +0,0 @@
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';
10
- export * from './transaction-simulation';
11
- export * from './account';
package/src/manifest.ts DELETED
@@ -1,40 +0,0 @@
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 DELETED
@@ -1,18 +0,0 @@
1
- import type { GetAddressParams, GetAddressResponse } from './account';
2
- import type { GetBalancesParams, GetBalancesResponse } from './balance';
3
- import type { Network } from './common';
4
- import type { Manifest } from './manifest';
5
- import type { NetworkFees } from './network-fee';
6
- import type { RpcRequest, RpcResponse } from './rpc';
7
- import type { NetworkContractToken } from './token';
8
- import type { GetTransactionHistory, TransactionHistoryResponse } from './transaction-history';
9
-
10
- export interface Module {
11
- getManifest: () => Manifest | undefined;
12
- getBalances: (params: GetBalancesParams) => Promise<GetBalancesResponse>;
13
- getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;
14
- getNetworkFee: (network: Network) => Promise<NetworkFees>;
15
- getAddress: (params: GetAddressParams) => Promise<GetAddressResponse>;
16
- getTokens: (network: Network) => Promise<NetworkContractToken[]>;
17
- onRpcRequest: (request: RpcRequest, chain: Network) => Promise<RpcResponse>;
18
- }
@@ -1,7 +0,0 @@
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
- };
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 | 'CreateAssetTx' | 'OperationTx';
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
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "@internal/tsconfig/tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "tsBuildInfoFile": ".tsbuildinfo"
6
- },
7
- "include": ["src"]
8
- }
package/tsup.config.ts DELETED
@@ -1,4 +0,0 @@
1
- import { defineConfig } from 'tsup';
2
- import { baseConfig } from '@internal/tsup-config';
3
-
4
- export default defineConfig({ ...baseConfig, entry: ['src/*.ts'] });