@avalabs/vm-module-types
Advanced tools
Comparing version 0.0.0-addFunctions-20240621170127 to 0.0.0-automate-signed-commit-20240712162835
# @avalabs/vm-module-types | ||
## 0.0.0-addFunctions-20240621170127 | ||
## 0.0.0-automate-signed-commit-20240712162835 | ||
### Patch Changes | ||
- 2f39ec5: make module interface dynamic | ||
- b09fcea: add module functions to evm-module | ||
- cd97708: fix: build types package | ||
- d0c2cc9: make module interface more consistent | ||
- 7bc6c6e: add eth_sendTransaction handler | ||
## 0.0.11 | ||
## 0.0.10 | ||
### Patch Changes | ||
- 60f36fa: add getTokens function | ||
## 0.0.9 | ||
### Patch Changes | ||
- 6ffa356: add module functions to evm-module | ||
## 0.0.8 | ||
@@ -11,0 +26,0 @@ |
{ | ||
"name": "@avalabs/vm-module-types", | ||
"version": "0.0.0-addFunctions-20240621170127", | ||
"main": "src/index.ts", | ||
"version": "0.0.0-automate-signed-commit-20240712162835", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"type": "module", | ||
"dependencies": { | ||
"zod": "3.23.8" | ||
"zod": "3.23.8", | ||
"@metamask/rpc-errors": "6.3.0", | ||
"ethers": "6.8.1" | ||
}, | ||
"devDependencies": { | ||
"eslint-config-custom": "0.0.1" | ||
"tsup": "7.2.0", | ||
"@internal/tsup-config": "0.0.1", | ||
"eslint-config-custom": "0.0.0-automate-signed-commit-20240712162835" | ||
}, | ||
"peerDependencies": { | ||
"ethers": "^6.8.1" | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"lint": "eslint \"src/**/*.ts\"" | ||
} | ||
} |
142
src/types.ts
import { object, string, boolean, z } from 'zod'; | ||
import type { TransactionRequest } from 'ethers'; | ||
import type { JsonRpcError, EthereumProviderError, OptionalDataWithOptionalCause } from '@metamask/rpc-errors'; | ||
@@ -42,13 +44,25 @@ export enum TransactionType { | ||
ETH_SIGN = 'eth_sign', | ||
WALLET_ADD_ETHEREUM_CHAIN = 'wallet_addEthereumChain', | ||
WALLET_SWITCH_ETHEREUM_CHAIN = 'wallet_switchEthereumChain', | ||
WALLET_GET_ETHEREUM_CHAIN = 'wallet_getEthereumChain', | ||
} | ||
export type DappInfo = { | ||
name: string; | ||
url: string; | ||
icon: string; | ||
}; | ||
export type RpcRequest = { | ||
requestId: string; | ||
sessionId: string; | ||
method: RpcMethod; | ||
chainId: Caip2ChainId; | ||
params: unknown; | ||
dappInfo: DappInfo; | ||
context?: Record<string, unknown>; // for storing additional context information that's only relevant to the consumer | ||
}; | ||
export type RpcResponse<R = unknown, E extends Error = Error> = | ||
export type RpcError = | ||
| JsonRpcError<OptionalDataWithOptionalCause> | ||
| EthereumProviderError<OptionalDataWithOptionalCause>; | ||
export type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> = | ||
| { | ||
@@ -61,20 +75,30 @@ result: R; | ||
export type Network = { | ||
chainId: number; | ||
chainName: string; | ||
rpcUrl: string; | ||
networkToken: NetworkToken; | ||
utilityAddresses?: { | ||
multicall: string; | ||
}; | ||
logoUrl?: string; | ||
isTestnet?: boolean; | ||
explorerUrl?: string; | ||
}; | ||
export interface Module { | ||
getManifest: () => Manifest | undefined; | ||
getNetworkFee: () => Promise<RpcResponse<NetworkFees>>; | ||
getTransactionHistory: (params: GetTransactionHistory) => Promise<RpcResponse<TransactionHistoryResponse>>; | ||
getBalances: () => Promise<string>; | ||
getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>; | ||
getNetworkFee: (network: Network) => Promise<NetworkFees>; | ||
getAddress: () => Promise<string>; | ||
getBalances: () => Promise<string>; | ||
onRpcRequest: (request: RpcRequest) => Promise<RpcResponse>; | ||
getTokens: (network: Network) => Promise<NetworkContractToken[]>; | ||
onRpcRequest: (request: RpcRequest, network: Network) => Promise<RpcResponse>; | ||
} | ||
export type GetTransactionHistory = { | ||
chainId: number; | ||
isTestnet: boolean; | ||
networkToken: NetworkToken; | ||
explorerUrl: string; | ||
network: Network; | ||
address: string; | ||
nextPageToken?: string; | ||
offset?: number; | ||
glacierApiUrl?: string; | ||
}; | ||
@@ -148,2 +172,13 @@ | ||
export interface NetworkContractToken { | ||
address: string; | ||
chainId?: number; | ||
color?: string; | ||
contractType: string; | ||
decimals: number; | ||
logoUri?: string; | ||
name: string; | ||
symbol: string; | ||
} | ||
const sourceSchema = object({ | ||
@@ -187,1 +222,82 @@ checksum: string(), | ||
}; | ||
export type Caip2ChainId = string; | ||
export type Hex = `0x${string}`; | ||
export enum Environment { | ||
PRODUCTION = 'production', | ||
DEV = 'dev', | ||
} | ||
export type DisplayData = { | ||
title: string; | ||
network: { | ||
chainId: number; | ||
name: string; | ||
logoUrl?: string; | ||
}; | ||
messageDetails?: string; | ||
transactionDetails?: { | ||
website: string; | ||
from: string; | ||
to: string; | ||
data?: string; | ||
}; | ||
networkFeeSelector?: boolean; | ||
}; | ||
/** | ||
* Enum for different types of signing data. | ||
*/ | ||
export enum SigningDataType { | ||
// EVM signing data types | ||
EVM_TRANSACTION = 'evm_transaction', | ||
EVM_MESSAGE_ETH_SIGN = 'evm_message_eth_sign', | ||
EVM_MESSAGE_PERSONAL_SIGN = 'evm_message_personal_sign', | ||
EVM_MESSAGE_ETH_SIGN_TYPED_DATA = 'evm_message_eth_sign_typed_data', | ||
EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V1 = 'evm_message_eth_sign_typed_data_v1', | ||
EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V3 = 'evm_message_eth_sign_typed_data_v3', | ||
EVM_MESSAGE_ETH_SIGN_TYPED_DATA_V4 = 'evm_message_eth_sign_typed_data_v4', | ||
// Avalanche signing data types | ||
AVALANCHE_TRANSACTION = 'avalanche_transaction', | ||
AVALANCHE_MESSAGE = 'avalanche_message', | ||
// Bitcoin signing data types | ||
BTC_TRANSACTION = 'btc_transaction', | ||
} | ||
export type SigningData = | ||
| { | ||
type: SigningDataType.EVM_TRANSACTION; | ||
account: string; | ||
chainId: number; | ||
data: TransactionRequest; | ||
} | ||
| { | ||
type: SigningDataType.EVM_MESSAGE_ETH_SIGN; | ||
account: string; | ||
chainId: number; | ||
data: string; | ||
}; | ||
export type ApprovalParams = { | ||
request: RpcRequest; | ||
displayData: DisplayData; | ||
signingData: SigningData; | ||
}; | ||
export type ApprovalResponse = | ||
| { | ||
result: Hex; | ||
} | ||
| { | ||
error: RpcError; | ||
}; | ||
export interface ApprovalController { | ||
requestApproval: (params: ApprovalParams) => Promise<ApprovalResponse>; | ||
onTransactionConfirmed: (txHash: Hex) => void; | ||
onTransactionReverted: (txHash: Hex) => void; | ||
} |
@@ -5,5 +5,5 @@ { | ||
"outDir": "./dist", | ||
"composite": true | ||
"tsBuildInfoFile": ".tsbuildinfo" | ||
}, | ||
"include": ["src"] | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
62334
25
857
Yes
4
3
3
1
+ Added@metamask/rpc-errors@6.3.0
+ Addedethers@6.8.1
+ Added@adraffy/ens-normalize@1.10.0(transitive)
+ Added@ethereumjs/common@3.2.0(transitive)
+ Added@ethereumjs/rlp@4.0.1(transitive)
+ Added@ethereumjs/tx@4.2.0(transitive)
+ Added@ethereumjs/util@8.1.0(transitive)
+ Added@metamask/rpc-errors@6.3.0(transitive)
+ Added@metamask/superstruct@3.1.0(transitive)
+ Added@metamask/utils@8.5.0(transitive)
+ Added@noble/curves@1.2.01.4.2(transitive)
+ Added@noble/hashes@1.3.21.4.01.7.1(transitive)
+ Added@scure/base@1.1.91.2.4(transitive)
+ Added@scure/bip32@1.4.0(transitive)
+ Added@scure/bip39@1.3.0(transitive)
+ Added@types/debug@4.1.12(transitive)
+ Added@types/ms@2.1.0(transitive)
+ Added@types/node@18.15.13(transitive)
+ Addedaes-js@4.0.0-beta.5(transitive)
+ Addedcrc-32@1.2.2(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedethereum-cryptography@2.2.1(transitive)
+ Addedethers@6.8.1(transitive)
+ Addedfast-safe-stringify@2.1.1(transitive)
+ Addedmicro-ftch@0.3.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addedpony-cause@2.1.11(transitive)
+ Addedsemver@7.7.1(transitive)
+ Addedtslib@2.4.0(transitive)
+ Addeduuid@9.0.1(transitive)
+ Addedws@8.5.0(transitive)