@avalabs/vm-module-types
Advanced tools
Comparing version 0.0.0-ops-build-types-package-20240710173505 to 0.0.0-ops-build-types-package-20240710173627
# @avalabs/vm-module-types | ||
## 0.0.0-ops-build-types-package-20240710173505 | ||
## 0.0.0-ops-build-types-package-20240710173627 | ||
@@ -5,0 +5,0 @@ ### Patch Changes |
@@ -1,416 +0,2 @@ | ||
import { z } from 'zod'; | ||
declare enum TransactionType { | ||
BRIDGE = "Bridge", | ||
SWAP = "Swap", | ||
SEND = "Send", | ||
RECEIVE = "Receive", | ||
NFT_BUY = "NFTBuy", | ||
APPROVE = "Approve", | ||
TRANSFER = "Transfer", | ||
NFT_SEND = "NFTSend", | ||
NFT_RECEIVE = "NFTReceive", | ||
AIRDROP = "Airdrop", | ||
FILL_ORDER = "FillOrder", | ||
UNWRAP = "Unwrap", | ||
UNKNOWN = "UNKNOWN" | ||
} | ||
declare enum TokenType { | ||
NATIVE = "NATIVE", | ||
ERC20 = "ERC20", | ||
ERC721 = "ERC721", | ||
ERC1155 = "ERC1155" | ||
} | ||
type NetworkFees = { | ||
low: { | ||
maxPriorityFeePerGas: bigint; | ||
maxFeePerGas: bigint; | ||
}; | ||
medium: { | ||
maxPriorityFeePerGas: bigint; | ||
maxFeePerGas: bigint; | ||
}; | ||
high: { | ||
maxPriorityFeePerGas: bigint; | ||
maxFeePerGas: bigint; | ||
}; | ||
baseFee: bigint; | ||
}; | ||
declare enum RpcMethod { | ||
ETH_SEND_TRANSACTION = "eth_sendTransaction", | ||
SIGN_TYPED_DATA_V3 = "eth_signTypedData_v3", | ||
SIGN_TYPED_DATA_V4 = "eth_signTypedData_v4", | ||
SIGN_TYPED_DATA_V1 = "eth_signTypedData_v1", | ||
SIGN_TYPED_DATA = "eth_signTypedData", | ||
PERSONAL_SIGN = "personal_sign", | ||
ETH_SIGN = "eth_sign", | ||
WALLET_ADD_ETHEREUM_CHAIN = "wallet_addEthereumChain", | ||
WALLET_SWITCH_ETHEREUM_CHAIN = "wallet_switchEthereumChain", | ||
WALLET_GET_ETHEREUM_CHAIN = "wallet_getEthereumChain" | ||
} | ||
type RpcRequest = { | ||
method: RpcMethod; | ||
params: unknown; | ||
}; | ||
type RpcResponse<R = unknown, E extends Error = Error> = { | ||
result: R; | ||
} | { | ||
error: E; | ||
}; | ||
type Chain = { | ||
isTestnet?: boolean; | ||
chainId?: string; | ||
chainName?: string; | ||
rpcUrl?: string; | ||
multiContractAddress?: string; | ||
}; | ||
type GetNetworkFeeParams = Chain; | ||
interface Module { | ||
getManifest: () => Manifest | undefined; | ||
getBalances: () => Promise<string>; | ||
getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>; | ||
getNetworkFee: (params: GetNetworkFeeParams) => Promise<NetworkFees>; | ||
getAddress: () => Promise<string>; | ||
getTokens: (chainId: number) => Promise<NetworkContractToken[]>; | ||
onRpcRequest: (request: RpcRequest) => Promise<RpcResponse>; | ||
} | ||
type GetTransactionHistory = { | ||
chainId: number; | ||
isTestnet: boolean; | ||
networkToken: NetworkToken; | ||
explorerUrl: string; | ||
address: string; | ||
nextPageToken?: string; | ||
offset?: number; | ||
glacierApiUrl?: string; | ||
}; | ||
type TransactionHistoryResponse = { | ||
transactions: Transaction[]; | ||
nextPageToken?: string; | ||
}; | ||
type Transaction = { | ||
isContractCall: boolean; | ||
isIncoming: boolean; | ||
isOutgoing: boolean; | ||
isSender: boolean; | ||
timestamp: number; | ||
hash: string; | ||
from: string; | ||
to: string; | ||
tokens: TxToken[]; | ||
gasPrice?: string; | ||
gasUsed: string; | ||
txType?: TransactionType; | ||
chainId: string; | ||
method?: string; | ||
explorerLink: string; | ||
}; | ||
interface TxToken { | ||
decimal?: string; | ||
name: string; | ||
symbol: string; | ||
amount: string; | ||
imageUri?: string; | ||
from?: RichAddress; | ||
to?: RichAddress; | ||
collectableTokenId?: string; | ||
type: TokenType; | ||
} | ||
type RichAddress = { | ||
/** | ||
* The contract name. | ||
*/ | ||
name?: string; | ||
/** | ||
* The contract symbol. | ||
*/ | ||
symbol?: string; | ||
/** | ||
* The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation. | ||
*/ | ||
decimals?: number; | ||
/** | ||
* The logo uri for the address. | ||
*/ | ||
logoUri?: string; | ||
/** | ||
* A wallet or contract address in mixed-case checksum encoding. | ||
*/ | ||
address: string; | ||
}; | ||
interface NetworkToken { | ||
name: string; | ||
symbol: string; | ||
description: string; | ||
decimals: number; | ||
logoUri: string; | ||
} | ||
interface NetworkContractToken { | ||
address: string; | ||
chainId?: number; | ||
color?: string; | ||
contractType: string; | ||
decimals: number; | ||
logoUri?: string; | ||
name: string; | ||
symbol: string; | ||
} | ||
declare const manifestSchema: z.ZodObject<{ | ||
name: z.ZodString; | ||
version: z.ZodString; | ||
description: z.ZodString; | ||
sources: z.ZodObject<{ | ||
module: z.ZodObject<{ | ||
checksum: z.ZodString; | ||
location: z.ZodObject<{ | ||
npm: z.ZodObject<{ | ||
filePath: z.ZodString; | ||
packageName: z.ZodString; | ||
registry: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}, { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}, { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
}, { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
}>; | ||
provider: z.ZodOptional<z.ZodObject<{ | ||
checksum: z.ZodString; | ||
location: z.ZodObject<{ | ||
npm: z.ZodObject<{ | ||
filePath: z.ZodString; | ||
packageName: z.ZodString; | ||
registry: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}, { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}, { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
}, { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
}>>; | ||
}, "strip", z.ZodTypeAny, { | ||
module: { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
}; | ||
provider?: { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
} | undefined; | ||
}, { | ||
module: { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
}; | ||
provider?: { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
} | undefined; | ||
}>; | ||
network: z.ZodObject<{ | ||
chainIds: z.ZodArray<z.ZodString, "many">; | ||
namespaces: z.ZodArray<z.ZodString, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
chainIds: string[]; | ||
namespaces: string[]; | ||
}, { | ||
chainIds: string[]; | ||
namespaces: string[]; | ||
}>; | ||
cointype: z.ZodString; | ||
permissions: z.ZodObject<{ | ||
rpc: z.ZodObject<{ | ||
dapps: z.ZodBoolean; | ||
methods: z.ZodArray<z.ZodString, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
dapps: boolean; | ||
methods: string[]; | ||
}, { | ||
dapps: boolean; | ||
methods: string[]; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
rpc: { | ||
dapps: boolean; | ||
methods: string[]; | ||
}; | ||
}, { | ||
rpc: { | ||
dapps: boolean; | ||
methods: string[]; | ||
}; | ||
}>; | ||
manifestVersion: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
name: string; | ||
version: string; | ||
description: string; | ||
sources: { | ||
module: { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
}; | ||
provider?: { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
} | undefined; | ||
}; | ||
network: { | ||
chainIds: string[]; | ||
namespaces: string[]; | ||
}; | ||
cointype: string; | ||
permissions: { | ||
rpc: { | ||
dapps: boolean; | ||
methods: string[]; | ||
}; | ||
}; | ||
manifestVersion: string; | ||
}, { | ||
name: string; | ||
version: string; | ||
description: string; | ||
sources: { | ||
module: { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
}; | ||
provider?: { | ||
checksum: string; | ||
location: { | ||
npm: { | ||
filePath: string; | ||
packageName: string; | ||
registry: string; | ||
}; | ||
}; | ||
} | undefined; | ||
}; | ||
network: { | ||
chainIds: string[]; | ||
namespaces: string[]; | ||
}; | ||
cointype: string; | ||
permissions: { | ||
rpc: { | ||
dapps: boolean; | ||
methods: string[]; | ||
}; | ||
}; | ||
manifestVersion: string; | ||
}>; | ||
type Manifest = z.infer<typeof manifestSchema>; | ||
declare const parseManifest: (params: unknown) => z.SafeParseReturnType<unknown, Manifest>; | ||
export { Chain, GetNetworkFeeParams, GetTransactionHistory, Manifest, Module, NetworkContractToken, NetworkFees, NetworkToken, RpcMethod, RpcRequest, RpcResponse, TokenType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, parseManifest }; | ||
export { Chain, GetNetworkFeeParams, GetTransactionHistory, Manifest, Module, NetworkContractToken, NetworkFees, NetworkToken, RpcMethod, RpcRequest, RpcResponse, TokenType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, parseManifest } from './types.js'; | ||
import 'zod'; |
@@ -1,7 +0,3 @@ | ||
import { object, string, boolean } from 'zod'; | ||
var g=(e=>(e.BRIDGE="Bridge",e.SWAP="Swap",e.SEND="Send",e.RECEIVE="Receive",e.NFT_BUY="NFTBuy",e.APPROVE="Approve",e.TRANSFER="Transfer",e.NFT_SEND="NFTSend",e.NFT_RECEIVE="NFTReceive",e.AIRDROP="Airdrop",e.FILL_ORDER="FillOrder",e.UNWRAP="Unwrap",e.UNKNOWN="UNKNOWN",e))(g||{}),m=(s=>(s.NATIVE="NATIVE",s.ERC20="ERC20",s.ERC721="ERC721",s.ERC1155="ERC1155",s))(m||{}),p=(t=>(t.ETH_SEND_TRANSACTION="eth_sendTransaction",t.SIGN_TYPED_DATA_V3="eth_signTypedData_v3",t.SIGN_TYPED_DATA_V4="eth_signTypedData_v4",t.SIGN_TYPED_DATA_V1="eth_signTypedData_v1",t.SIGN_TYPED_DATA="eth_signTypedData",t.PERSONAL_SIGN="personal_sign",t.ETH_SIGN="eth_sign",t.WALLET_ADD_ETHEREUM_CHAIN="wallet_addEthereumChain",t.WALLET_SWITCH_ETHEREUM_CHAIN="wallet_switchEthereumChain",t.WALLET_GET_ETHEREUM_CHAIN="wallet_getEthereumChain",t))(p||{}),i=object({checksum:string(),location:object({npm:object({filePath:string(),packageName:string(),registry:string()})})}),l=object({name:string(),version:string(),description:string(),sources:object({module:i,provider:i.optional()}),network:object({chainIds:string().array(),namespaces:string().array()}),cointype:string(),permissions:object({rpc:object({dapps:boolean(),methods:string().array()})}),manifestVersion:string()}),d=o=>l.safeParse(o); | ||
export { p as RpcMethod, m as TokenType, g as TransactionType, d as parseManifest }; | ||
export { c as RpcMethod, b as TokenType, a as TransactionType, d as parseManifest } from './chunk-JBRIWUTQ.js'; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@avalabs/vm-module-types", | ||
"version": "0.0.0-ops-build-types-package-20240710173505", | ||
"version": "0.0.0-ops-build-types-package-20240710173627", | ||
"main": "dist/index.cjs", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.js", |
206
src/index.ts
@@ -1,205 +0,1 @@ | ||
import { object, string, boolean, z } from 'zod'; | ||
export enum TransactionType { | ||
BRIDGE = 'Bridge', | ||
SWAP = 'Swap', | ||
SEND = 'Send', | ||
RECEIVE = 'Receive', | ||
NFT_BUY = 'NFTBuy', | ||
APPROVE = 'Approve', | ||
TRANSFER = 'Transfer', | ||
NFT_SEND = 'NFTSend', | ||
NFT_RECEIVE = 'NFTReceive', | ||
AIRDROP = 'Airdrop', | ||
FILL_ORDER = 'FillOrder', | ||
UNWRAP = 'Unwrap', | ||
UNKNOWN = 'UNKNOWN', | ||
} | ||
export enum TokenType { | ||
NATIVE = 'NATIVE', | ||
ERC20 = 'ERC20', | ||
ERC721 = 'ERC721', | ||
ERC1155 = 'ERC1155', | ||
} | ||
export type NetworkFees = { | ||
low: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint }; | ||
medium: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint }; | ||
high: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint }; | ||
baseFee: bigint; | ||
}; | ||
export enum RpcMethod { | ||
/* EVM */ | ||
ETH_SEND_TRANSACTION = 'eth_sendTransaction', | ||
SIGN_TYPED_DATA_V3 = 'eth_signTypedData_v3', | ||
SIGN_TYPED_DATA_V4 = 'eth_signTypedData_v4', | ||
SIGN_TYPED_DATA_V1 = 'eth_signTypedData_v1', | ||
SIGN_TYPED_DATA = 'eth_signTypedData', | ||
PERSONAL_SIGN = 'personal_sign', | ||
ETH_SIGN = 'eth_sign', | ||
WALLET_ADD_ETHEREUM_CHAIN = 'wallet_addEthereumChain', | ||
WALLET_SWITCH_ETHEREUM_CHAIN = 'wallet_switchEthereumChain', | ||
WALLET_GET_ETHEREUM_CHAIN = 'wallet_getEthereumChain', | ||
} | ||
export type RpcRequest = { | ||
method: RpcMethod; | ||
params: unknown; | ||
}; | ||
export type RpcResponse<R = unknown, E extends Error = Error> = | ||
| { | ||
result: R; | ||
} | ||
| { | ||
error: E; | ||
}; | ||
export type Chain = { | ||
isTestnet?: boolean; | ||
chainId?: string; | ||
chainName?: string; | ||
rpcUrl?: string; | ||
multiContractAddress?: string; | ||
}; | ||
export type GetNetworkFeeParams = Chain; | ||
export interface Module { | ||
getManifest: () => Manifest | undefined; | ||
getBalances: () => Promise<string>; | ||
getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>; | ||
getNetworkFee: (params: GetNetworkFeeParams) => Promise<NetworkFees>; | ||
getAddress: () => Promise<string>; | ||
getTokens: (chainId: number) => Promise<NetworkContractToken[]>; | ||
onRpcRequest: (request: RpcRequest) => Promise<RpcResponse>; | ||
} | ||
export type GetTransactionHistory = { | ||
chainId: number; | ||
isTestnet: boolean; | ||
networkToken: NetworkToken; | ||
explorerUrl: string; | ||
address: string; | ||
nextPageToken?: string; | ||
offset?: number; | ||
glacierApiUrl?: string; | ||
}; | ||
export type TransactionHistoryResponse = { | ||
transactions: Transaction[]; | ||
nextPageToken?: string; | ||
}; | ||
export type Transaction = { | ||
isContractCall: boolean; | ||
isIncoming: boolean; | ||
isOutgoing: boolean; | ||
isSender: boolean; | ||
timestamp: number; | ||
hash: string; | ||
from: string; | ||
to: string; | ||
tokens: TxToken[]; | ||
gasPrice?: string; | ||
gasUsed: string; | ||
txType?: TransactionType; | ||
chainId: string; // chainId from ActiveNetwork used to fetch tx | ||
method?: string; | ||
explorerLink: string; | ||
}; | ||
export interface TxToken { | ||
decimal?: string; | ||
name: string; | ||
symbol: string; | ||
amount: string; | ||
imageUri?: string; | ||
from?: RichAddress; | ||
to?: RichAddress; | ||
collectableTokenId?: string; | ||
type: TokenType; | ||
} | ||
type RichAddress = { | ||
/** | ||
* The contract name. | ||
*/ | ||
name?: string; | ||
/** | ||
* The contract symbol. | ||
*/ | ||
symbol?: string; | ||
/** | ||
* The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation. | ||
*/ | ||
decimals?: number; | ||
/** | ||
* The logo uri for the address. | ||
*/ | ||
logoUri?: string; | ||
/** | ||
* A wallet or contract address in mixed-case checksum encoding. | ||
*/ | ||
address: string; | ||
}; | ||
export interface NetworkToken { | ||
name: string; | ||
symbol: string; | ||
description: string; | ||
decimals: number; | ||
logoUri: string; | ||
} | ||
export interface NetworkContractToken { | ||
address: string; | ||
chainId?: number; | ||
color?: string; | ||
contractType: string; | ||
decimals: number; | ||
logoUri?: string; | ||
name: string; | ||
symbol: string; | ||
} | ||
const sourceSchema = object({ | ||
checksum: string(), | ||
location: object({ | ||
npm: object({ | ||
filePath: string(), | ||
packageName: string(), | ||
registry: string(), | ||
}), | ||
}), | ||
}); | ||
const manifestSchema = object({ | ||
name: string(), | ||
version: string(), | ||
description: string(), | ||
sources: object({ | ||
module: sourceSchema, | ||
provider: sourceSchema.optional(), | ||
}), | ||
network: object({ | ||
chainIds: string().array(), | ||
namespaces: string().array(), | ||
}), | ||
cointype: string(), | ||
permissions: object({ | ||
rpc: object({ | ||
dapps: boolean(), | ||
methods: string().array(), | ||
}), | ||
}), | ||
manifestVersion: string(), | ||
}); | ||
export type Manifest = z.infer<typeof manifestSchema>; | ||
export const parseManifest = (params: unknown): z.SafeParseReturnType<unknown, Manifest> => { | ||
return manifestSchema.safeParse(params); | ||
}; | ||
export * from './types'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
48152
25
676
1