@avalabs/vm-module-types 0.0.0-publicTypes-20240620160105 → 0.0.0-refactor-params-20240711144718

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.
@@ -0,0 +1,32 @@
1
+
2
+ > @avalabs/vm-module-types@0.0.11 build /home/runner/work/vm-modules/vm-modules/packages/types
3
+ > tsup
4
+
5
+ CLI Building entry: src/index.ts, src/types.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
+ CJS dist/index.cjs 748.00 B
14
+ CJS dist/types.cjs 748.00 B
15
+ CJS dist/chunk-ZEYSSEII.cjs 1.57 KB
16
+ CJS dist/index.cjs.map 51.00 B
17
+ CJS dist/types.cjs.map 51.00 B
18
+ CJS dist/chunk-ZEYSSEII.cjs.map 6.62 KB
19
+ CJS ⚡️ Build success in 599ms
20
+ ESM dist/index.js 195.00 B
21
+ ESM dist/types.js 195.00 B
22
+ ESM dist/chunk-NR7FSFOY.js 1.47 KB
23
+ ESM dist/index.js.map 51.00 B
24
+ ESM dist/types.js.map 51.00 B
25
+ ESM dist/chunk-NR7FSFOY.js.map 6.62 KB
26
+ ESM ⚡️ Build success in 600ms
27
+ DTS Build start
28
+ DTS ⚡️ Build success in 7420ms
29
+ DTS dist/types.d.cts 11.47 KB
30
+ DTS dist/index.d.cts 355.00 B
31
+ DTS dist/types.d.ts 11.47 KB
32
+ DTS dist/index.d.ts 354.00 B
@@ -1,4 +1,4 @@
1
1
 
2
- > @avalabs/vm-module-types@0.0.1 lint /home/runner/work/vm-modules/vm-modules/packages/types
2
+ > @avalabs/vm-module-types@0.0.11 lint /home/runner/work/vm-modules/vm-modules/packages/types
3
3
  > eslint "src/**/*.ts"
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,7 +1,51 @@
1
1
  # @avalabs/vm-module-types
2
2
 
3
- ## 0.0.0-publicTypes-20240620160105
3
+ ## 0.0.0-refactor-params-20240711144718
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 55240c4: Move types from packages-internal/types to packages/types
7
+ - cd97708: fix: build types package
8
+
9
+ ## 0.0.11
10
+
11
+ ## 0.0.10
12
+
13
+ ### Patch Changes
14
+
15
+ - 60f36fa: add getTokens function
16
+
17
+ ## 0.0.9
18
+
19
+ ### Patch Changes
20
+
21
+ - 6ffa356: add module functions to evm-module
22
+
23
+ ## 0.0.8
24
+
25
+ ### Patch Changes
26
+
27
+ - d1d080f: test release
28
+
29
+ ## 0.0.7
30
+
31
+ ### Patch Changes
32
+
33
+ - bb98621: Move types to @avalabs/vm-module-types
34
+
35
+ ## 0.0.6
36
+
37
+ ### Patch Changes
38
+
39
+ - 1122704: test release
40
+
41
+ ## 0.0.3
42
+
43
+ ### Patch Changes
44
+
45
+ - 0b0c52e: Move types to @avalabs/vm-module-types
46
+
47
+ ## 0.0.2
48
+
49
+ ### Patch Changes
50
+
51
+ - 4b7d5e9: Move types from packages-internal/types to packages/types
@@ -0,0 +1,7 @@
1
+ import { object, string, boolean } from 'zod';
2
+
3
+ var p=(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))(p||{}),m=(s=>(s.NATIVE="NATIVE",s.ERC20="ERC20",s.ERC721="ERC721",s.ERC1155="ERC1155",s))(m||{}),l=(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))(l||{}),o=object({checksum:string(),location:object({npm:object({filePath:string(),packageName:string(),registry:string()})})}),d=object({name:string(),version:string(),description:string(),sources:object({module:o,provider:o.optional()}),network:object({chainIds:string().array(),namespaces:string().array()}),cointype:string(),permissions:object({rpc:object({dapps:boolean(),methods:string().array()})}),manifestVersion:string()}),u=a=>d.safeParse(a),E=(i=>(i.PRODUCTION="production",i.DEV="dev",i))(E||{});
4
+
5
+ export { p as a, m as b, l as c, u as d, E as e };
6
+ //# sourceMappingURL=out.js.map
7
+ //# sourceMappingURL=chunk-NR7FSFOY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"names":["object","string","boolean","TransactionType","TokenType","RpcMethod","sourceSchema","manifestSchema","parseManifest","params","Environment"],"mappings":"AAAA,OAAS,UAAAA,EAAQ,UAAAC,EAAQ,WAAAC,MAAkB,MAGpC,IAAKC,OACVA,EAAA,OAAS,SACTA,EAAA,KAAO,OACPA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,QAAU,SACVA,EAAA,QAAU,UACVA,EAAA,SAAW,WACXA,EAAA,SAAW,UACXA,EAAA,YAAc,aACdA,EAAA,QAAU,UACVA,EAAA,WAAa,YACbA,EAAA,OAAS,SACTA,EAAA,QAAU,UAbAA,OAAA,IAgBAC,OACVA,EAAA,OAAS,SACTA,EAAA,MAAQ,QACRA,EAAA,OAAS,SACTA,EAAA,QAAU,UAJAA,OAAA,IAcAC,OAEVA,EAAA,qBAAuB,sBACvBA,EAAA,mBAAqB,uBACrBA,EAAA,mBAAqB,uBACrBA,EAAA,mBAAqB,uBACrBA,EAAA,gBAAkB,oBAClBA,EAAA,cAAgB,gBAChBA,EAAA,SAAW,WACXA,EAAA,0BAA4B,0BAC5BA,EAAA,6BAA+B,6BAC/BA,EAAA,0BAA4B,0BAXlBA,OAAA,IAkJNC,EAAeN,EAAO,CAC1B,SAAUC,EAAO,EACjB,SAAUD,EAAO,CACf,IAAKA,EAAO,CACV,SAAUC,EAAO,EACjB,YAAaA,EAAO,EACpB,SAAUA,EAAO,CACnB,CAAC,CACH,CAAC,CACH,CAAC,EAEKM,EAAiBP,EAAO,CAC5B,KAAMC,EAAO,EACb,QAASA,EAAO,EAChB,YAAaA,EAAO,EACpB,QAASD,EAAO,CACd,OAAQM,EACR,SAAUA,EAAa,SAAS,CAClC,CAAC,EACD,QAASN,EAAO,CACd,SAAUC,EAAO,EAAE,MAAM,EACzB,WAAYA,EAAO,EAAE,MAAM,CAC7B,CAAC,EACD,SAAUA,EAAO,EACjB,YAAaD,EAAO,CAClB,IAAKA,EAAO,CACV,MAAOE,EAAQ,EACf,QAASD,EAAO,EAAE,MAAM,CAC1B,CAAC,CACH,CAAC,EACD,gBAAiBA,EAAO,CAC1B,CAAC,EAIYO,EAAiBC,GACrBF,EAAe,UAAUE,CAAM,EAO5BC,OACVA,EAAA,WAAa,aACbA,EAAA,IAAM,MAFIA,OAAA","sourcesContent":["import { object, string, boolean, z } from 'zod';\nimport type { JsonRpcError, EthereumProviderError, OptionalDataWithOptionalCause } from '@metamask/rpc-errors';\n\nexport enum TransactionType {\n BRIDGE = 'Bridge',\n SWAP = 'Swap',\n SEND = 'Send',\n RECEIVE = 'Receive',\n NFT_BUY = 'NFTBuy',\n APPROVE = 'Approve',\n TRANSFER = 'Transfer',\n NFT_SEND = 'NFTSend',\n NFT_RECEIVE = 'NFTReceive',\n AIRDROP = 'Airdrop',\n FILL_ORDER = 'FillOrder',\n UNWRAP = 'Unwrap',\n UNKNOWN = 'UNKNOWN',\n}\n\nexport enum TokenType {\n NATIVE = 'NATIVE',\n ERC20 = 'ERC20',\n ERC721 = 'ERC721',\n ERC1155 = 'ERC1155',\n}\n\nexport type NetworkFees = {\n low: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint };\n medium: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint };\n high: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint };\n baseFee: bigint;\n};\n\nexport enum RpcMethod {\n /* EVM */\n ETH_SEND_TRANSACTION = 'eth_sendTransaction',\n SIGN_TYPED_DATA_V3 = 'eth_signTypedData_v3',\n SIGN_TYPED_DATA_V4 = 'eth_signTypedData_v4',\n SIGN_TYPED_DATA_V1 = 'eth_signTypedData_v1',\n SIGN_TYPED_DATA = 'eth_signTypedData',\n PERSONAL_SIGN = 'personal_sign',\n ETH_SIGN = 'eth_sign',\n WALLET_ADD_ETHEREUM_CHAIN = 'wallet_addEthereumChain',\n WALLET_SWITCH_ETHEREUM_CHAIN = 'wallet_switchEthereumChain',\n WALLET_GET_ETHEREUM_CHAIN = 'wallet_getEthereumChain',\n}\n\nexport type DappInfo = {\n name: string;\n url: string;\n icon: string;\n};\n\nexport type RpcRequest = {\n requestId: string;\n sessionId: string;\n method: RpcMethod;\n chainId: Caip2ChainId;\n params: unknown;\n dappInfo: DappInfo;\n};\n\nexport type RpcError =\n | JsonRpcError<OptionalDataWithOptionalCause>\n | EthereumProviderError<OptionalDataWithOptionalCause>;\n\nexport type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> =\n | {\n result: R;\n }\n | {\n error: E;\n };\n\nexport type Network = {\n chainId: Caip2ChainId;\n chainName: string;\n rpcUrl: string;\n networkToken: NetworkToken;\n multiContractAddress?: string;\n logoUrl?: string;\n isTestnet?: boolean;\n explorerUrl?: string;\n};\n\nexport interface Module {\n getManifest: () => Manifest | undefined;\n getBalances: () => Promise<string>;\n getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;\n getNetworkFee: (network: Network) => Promise<NetworkFees>;\n getAddress: () => Promise<string>;\n getTokens: (network: Network) => Promise<NetworkContractToken[]>;\n onRpcRequest: (request: RpcRequest, chain: Network) => Promise<RpcResponse>;\n}\n\nexport type GetTransactionHistory = {\n network: Network;\n address: string;\n nextPageToken?: string;\n offset?: number;\n};\n\nexport type TransactionHistoryResponse = {\n transactions: Transaction[];\n nextPageToken?: string;\n};\n\nexport type Transaction = {\n isContractCall: boolean;\n isIncoming: boolean;\n isOutgoing: boolean;\n isSender: boolean;\n timestamp: number;\n hash: string;\n from: string;\n to: string;\n tokens: TxToken[];\n gasPrice?: string;\n gasUsed: string;\n txType?: TransactionType;\n chainId: string; // chainId from ActiveNetwork used to fetch tx\n method?: string;\n explorerLink: string;\n};\n\nexport interface TxToken {\n decimal?: string;\n name: string;\n symbol: string;\n amount: string;\n imageUri?: string;\n from?: RichAddress;\n to?: RichAddress;\n collectableTokenId?: string;\n type: TokenType;\n}\n\ntype RichAddress = {\n /**\n * The contract name.\n */\n name?: string;\n /**\n * The contract symbol.\n */\n symbol?: string;\n /**\n * The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.\n */\n decimals?: number;\n /**\n * The logo uri for the address.\n */\n logoUri?: string;\n /**\n * A wallet or contract address in mixed-case checksum encoding.\n */\n address: string;\n};\n\nexport interface NetworkToken {\n name: string;\n symbol: string;\n description: string;\n decimals: number;\n logoUri: string;\n}\n\nexport interface NetworkContractToken {\n address: string;\n chainId?: number;\n color?: string;\n contractType: string;\n decimals: number;\n logoUri?: string;\n name: string;\n symbol: string;\n}\n\nconst sourceSchema = object({\n checksum: string(),\n location: object({\n npm: object({\n filePath: string(),\n packageName: string(),\n registry: string(),\n }),\n }),\n});\n\nconst manifestSchema = object({\n name: string(),\n version: string(),\n description: string(),\n sources: object({\n module: sourceSchema,\n provider: sourceSchema.optional(),\n }),\n network: object({\n chainIds: string().array(),\n namespaces: string().array(),\n }),\n cointype: string(),\n permissions: object({\n rpc: object({\n dapps: boolean(),\n methods: string().array(),\n }),\n }),\n manifestVersion: string(),\n});\n\nexport type Manifest = z.infer<typeof manifestSchema>;\n\nexport const parseManifest = (params: unknown): z.SafeParseReturnType<unknown, Manifest> => {\n return manifestSchema.safeParse(params);\n};\n\nexport type Caip2ChainId = string;\n\nexport type Hex = `0x${string}`;\n\nexport enum Environment {\n PRODUCTION = 'production',\n DEV = 'dev',\n}\n"]}
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ var p=(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))(p||{}),m=(s=>(s.NATIVE="NATIVE",s.ERC20="ERC20",s.ERC721="ERC721",s.ERC1155="ERC1155",s))(m||{}),l=(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))(l||{}),o=zod.object({checksum:zod.string(),location:zod.object({npm:zod.object({filePath:zod.string(),packageName:zod.string(),registry:zod.string()})})}),d=zod.object({name:zod.string(),version:zod.string(),description:zod.string(),sources:zod.object({module:o,provider:o.optional()}),network:zod.object({chainIds:zod.string().array(),namespaces:zod.string().array()}),cointype:zod.string(),permissions:zod.object({rpc:zod.object({dapps:zod.boolean(),methods:zod.string().array()})}),manifestVersion:zod.string()}),u=a=>d.safeParse(a),E=(i=>(i.PRODUCTION="production",i.DEV="dev",i))(E||{});
6
+
7
+ exports.a = p;
8
+ exports.b = m;
9
+ exports.c = l;
10
+ exports.d = u;
11
+ exports.e = E;
12
+ //# sourceMappingURL=out.js.map
13
+ //# sourceMappingURL=chunk-ZEYSSEII.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"names":["object","string","boolean","TransactionType","TokenType","RpcMethod","sourceSchema","manifestSchema","parseManifest","params","Environment"],"mappings":"AAAA,OAAS,UAAAA,EAAQ,UAAAC,EAAQ,WAAAC,MAAkB,MAGpC,IAAKC,OACVA,EAAA,OAAS,SACTA,EAAA,KAAO,OACPA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,QAAU,SACVA,EAAA,QAAU,UACVA,EAAA,SAAW,WACXA,EAAA,SAAW,UACXA,EAAA,YAAc,aACdA,EAAA,QAAU,UACVA,EAAA,WAAa,YACbA,EAAA,OAAS,SACTA,EAAA,QAAU,UAbAA,OAAA,IAgBAC,OACVA,EAAA,OAAS,SACTA,EAAA,MAAQ,QACRA,EAAA,OAAS,SACTA,EAAA,QAAU,UAJAA,OAAA,IAcAC,OAEVA,EAAA,qBAAuB,sBACvBA,EAAA,mBAAqB,uBACrBA,EAAA,mBAAqB,uBACrBA,EAAA,mBAAqB,uBACrBA,EAAA,gBAAkB,oBAClBA,EAAA,cAAgB,gBAChBA,EAAA,SAAW,WACXA,EAAA,0BAA4B,0BAC5BA,EAAA,6BAA+B,6BAC/BA,EAAA,0BAA4B,0BAXlBA,OAAA,IAkJNC,EAAeN,EAAO,CAC1B,SAAUC,EAAO,EACjB,SAAUD,EAAO,CACf,IAAKA,EAAO,CACV,SAAUC,EAAO,EACjB,YAAaA,EAAO,EACpB,SAAUA,EAAO,CACnB,CAAC,CACH,CAAC,CACH,CAAC,EAEKM,EAAiBP,EAAO,CAC5B,KAAMC,EAAO,EACb,QAASA,EAAO,EAChB,YAAaA,EAAO,EACpB,QAASD,EAAO,CACd,OAAQM,EACR,SAAUA,EAAa,SAAS,CAClC,CAAC,EACD,QAASN,EAAO,CACd,SAAUC,EAAO,EAAE,MAAM,EACzB,WAAYA,EAAO,EAAE,MAAM,CAC7B,CAAC,EACD,SAAUA,EAAO,EACjB,YAAaD,EAAO,CAClB,IAAKA,EAAO,CACV,MAAOE,EAAQ,EACf,QAASD,EAAO,EAAE,MAAM,CAC1B,CAAC,CACH,CAAC,EACD,gBAAiBA,EAAO,CAC1B,CAAC,EAIYO,EAAiBC,GACrBF,EAAe,UAAUE,CAAM,EAO5BC,OACVA,EAAA,WAAa,aACbA,EAAA,IAAM,MAFIA,OAAA","sourcesContent":["import { object, string, boolean, z } from 'zod';\nimport type { JsonRpcError, EthereumProviderError, OptionalDataWithOptionalCause } from '@metamask/rpc-errors';\n\nexport enum TransactionType {\n BRIDGE = 'Bridge',\n SWAP = 'Swap',\n SEND = 'Send',\n RECEIVE = 'Receive',\n NFT_BUY = 'NFTBuy',\n APPROVE = 'Approve',\n TRANSFER = 'Transfer',\n NFT_SEND = 'NFTSend',\n NFT_RECEIVE = 'NFTReceive',\n AIRDROP = 'Airdrop',\n FILL_ORDER = 'FillOrder',\n UNWRAP = 'Unwrap',\n UNKNOWN = 'UNKNOWN',\n}\n\nexport enum TokenType {\n NATIVE = 'NATIVE',\n ERC20 = 'ERC20',\n ERC721 = 'ERC721',\n ERC1155 = 'ERC1155',\n}\n\nexport type NetworkFees = {\n low: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint };\n medium: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint };\n high: { maxPriorityFeePerGas: bigint; maxFeePerGas: bigint };\n baseFee: bigint;\n};\n\nexport enum RpcMethod {\n /* EVM */\n ETH_SEND_TRANSACTION = 'eth_sendTransaction',\n SIGN_TYPED_DATA_V3 = 'eth_signTypedData_v3',\n SIGN_TYPED_DATA_V4 = 'eth_signTypedData_v4',\n SIGN_TYPED_DATA_V1 = 'eth_signTypedData_v1',\n SIGN_TYPED_DATA = 'eth_signTypedData',\n PERSONAL_SIGN = 'personal_sign',\n ETH_SIGN = 'eth_sign',\n WALLET_ADD_ETHEREUM_CHAIN = 'wallet_addEthereumChain',\n WALLET_SWITCH_ETHEREUM_CHAIN = 'wallet_switchEthereumChain',\n WALLET_GET_ETHEREUM_CHAIN = 'wallet_getEthereumChain',\n}\n\nexport type DappInfo = {\n name: string;\n url: string;\n icon: string;\n};\n\nexport type RpcRequest = {\n requestId: string;\n sessionId: string;\n method: RpcMethod;\n chainId: Caip2ChainId;\n params: unknown;\n dappInfo: DappInfo;\n};\n\nexport type RpcError =\n | JsonRpcError<OptionalDataWithOptionalCause>\n | EthereumProviderError<OptionalDataWithOptionalCause>;\n\nexport type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> =\n | {\n result: R;\n }\n | {\n error: E;\n };\n\nexport type Network = {\n chainId: Caip2ChainId;\n chainName: string;\n rpcUrl: string;\n networkToken: NetworkToken;\n multiContractAddress?: string;\n logoUrl?: string;\n isTestnet?: boolean;\n explorerUrl?: string;\n};\n\nexport interface Module {\n getManifest: () => Manifest | undefined;\n getBalances: () => Promise<string>;\n getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;\n getNetworkFee: (network: Network) => Promise<NetworkFees>;\n getAddress: () => Promise<string>;\n getTokens: (network: Network) => Promise<NetworkContractToken[]>;\n onRpcRequest: (request: RpcRequest, chain: Network) => Promise<RpcResponse>;\n}\n\nexport type GetTransactionHistory = {\n network: Network;\n address: string;\n nextPageToken?: string;\n offset?: number;\n};\n\nexport type TransactionHistoryResponse = {\n transactions: Transaction[];\n nextPageToken?: string;\n};\n\nexport type Transaction = {\n isContractCall: boolean;\n isIncoming: boolean;\n isOutgoing: boolean;\n isSender: boolean;\n timestamp: number;\n hash: string;\n from: string;\n to: string;\n tokens: TxToken[];\n gasPrice?: string;\n gasUsed: string;\n txType?: TransactionType;\n chainId: string; // chainId from ActiveNetwork used to fetch tx\n method?: string;\n explorerLink: string;\n};\n\nexport interface TxToken {\n decimal?: string;\n name: string;\n symbol: string;\n amount: string;\n imageUri?: string;\n from?: RichAddress;\n to?: RichAddress;\n collectableTokenId?: string;\n type: TokenType;\n}\n\ntype RichAddress = {\n /**\n * The contract name.\n */\n name?: string;\n /**\n * The contract symbol.\n */\n symbol?: string;\n /**\n * The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.\n */\n decimals?: number;\n /**\n * The logo uri for the address.\n */\n logoUri?: string;\n /**\n * A wallet or contract address in mixed-case checksum encoding.\n */\n address: string;\n};\n\nexport interface NetworkToken {\n name: string;\n symbol: string;\n description: string;\n decimals: number;\n logoUri: string;\n}\n\nexport interface NetworkContractToken {\n address: string;\n chainId?: number;\n color?: string;\n contractType: string;\n decimals: number;\n logoUri?: string;\n name: string;\n symbol: string;\n}\n\nconst sourceSchema = object({\n checksum: string(),\n location: object({\n npm: object({\n filePath: string(),\n packageName: string(),\n registry: string(),\n }),\n }),\n});\n\nconst manifestSchema = object({\n name: string(),\n version: string(),\n description: string(),\n sources: object({\n module: sourceSchema,\n provider: sourceSchema.optional(),\n }),\n network: object({\n chainIds: string().array(),\n namespaces: string().array(),\n }),\n cointype: string(),\n permissions: object({\n rpc: object({\n dapps: boolean(),\n methods: string().array(),\n }),\n }),\n manifestVersion: string(),\n});\n\nexport type Manifest = z.infer<typeof manifestSchema>;\n\nexport const parseManifest = (params: unknown): z.SafeParseReturnType<unknown, Manifest> => {\n return manifestSchema.safeParse(params);\n};\n\nexport type Caip2ChainId = string;\n\nexport type Hex = `0x${string}`;\n\nexport enum Environment {\n PRODUCTION = 'production',\n DEV = 'dev',\n}\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var chunkZEYSSEII_cjs = require('./chunk-ZEYSSEII.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, 'Environment', {
8
+ enumerable: true,
9
+ get: function () { return chunkZEYSSEII_cjs.e; }
10
+ });
11
+ Object.defineProperty(exports, 'RpcMethod', {
12
+ enumerable: true,
13
+ get: function () { return chunkZEYSSEII_cjs.c; }
14
+ });
15
+ Object.defineProperty(exports, 'TokenType', {
16
+ enumerable: true,
17
+ get: function () { return chunkZEYSSEII_cjs.b; }
18
+ });
19
+ Object.defineProperty(exports, 'TransactionType', {
20
+ enumerable: true,
21
+ get: function () { return chunkZEYSSEII_cjs.a; }
22
+ });
23
+ Object.defineProperty(exports, 'parseManifest', {
24
+ enumerable: true,
25
+ get: function () { return chunkZEYSSEII_cjs.d; }
26
+ });
27
+ //# sourceMappingURL=out.js.map
28
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { Caip2ChainId, DappInfo, Environment, GetTransactionHistory, Hex, Manifest, Module, Network, NetworkContractToken, NetworkFees, NetworkToken, RpcError, RpcMethod, RpcRequest, RpcResponse, TokenType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, parseManifest } from './types.cjs';
2
+ import 'zod';
3
+ import '@metamask/rpc-errors';
@@ -0,0 +1,3 @@
1
+ export { Caip2ChainId, DappInfo, Environment, GetTransactionHistory, Hex, Manifest, Module, Network, NetworkContractToken, NetworkFees, NetworkToken, RpcError, RpcMethod, RpcRequest, RpcResponse, TokenType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, parseManifest } from './types.js';
2
+ import 'zod';
3
+ import '@metamask/rpc-errors';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { e as Environment, c as RpcMethod, b as TokenType, a as TransactionType, d as parseManifest } from './chunk-NR7FSFOY.js';
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
package/dist/types.cjs ADDED
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var chunkZEYSSEII_cjs = require('./chunk-ZEYSSEII.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, 'Environment', {
8
+ enumerable: true,
9
+ get: function () { return chunkZEYSSEII_cjs.e; }
10
+ });
11
+ Object.defineProperty(exports, 'RpcMethod', {
12
+ enumerable: true,
13
+ get: function () { return chunkZEYSSEII_cjs.c; }
14
+ });
15
+ Object.defineProperty(exports, 'TokenType', {
16
+ enumerable: true,
17
+ get: function () { return chunkZEYSSEII_cjs.b; }
18
+ });
19
+ Object.defineProperty(exports, 'TransactionType', {
20
+ enumerable: true,
21
+ get: function () { return chunkZEYSSEII_cjs.a; }
22
+ });
23
+ Object.defineProperty(exports, 'parseManifest', {
24
+ enumerable: true,
25
+ get: function () { return chunkZEYSSEII_cjs.d; }
26
+ });
27
+ //# sourceMappingURL=out.js.map
28
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,431 @@
1
+ import { z } from 'zod';
2
+ import { JsonRpcError, OptionalDataWithOptionalCause, EthereumProviderError } from '@metamask/rpc-errors';
3
+
4
+ declare enum TransactionType {
5
+ BRIDGE = "Bridge",
6
+ SWAP = "Swap",
7
+ SEND = "Send",
8
+ RECEIVE = "Receive",
9
+ NFT_BUY = "NFTBuy",
10
+ APPROVE = "Approve",
11
+ TRANSFER = "Transfer",
12
+ NFT_SEND = "NFTSend",
13
+ NFT_RECEIVE = "NFTReceive",
14
+ AIRDROP = "Airdrop",
15
+ FILL_ORDER = "FillOrder",
16
+ UNWRAP = "Unwrap",
17
+ UNKNOWN = "UNKNOWN"
18
+ }
19
+ declare enum TokenType {
20
+ NATIVE = "NATIVE",
21
+ ERC20 = "ERC20",
22
+ ERC721 = "ERC721",
23
+ ERC1155 = "ERC1155"
24
+ }
25
+ type NetworkFees = {
26
+ low: {
27
+ maxPriorityFeePerGas: bigint;
28
+ maxFeePerGas: bigint;
29
+ };
30
+ medium: {
31
+ maxPriorityFeePerGas: bigint;
32
+ maxFeePerGas: bigint;
33
+ };
34
+ high: {
35
+ maxPriorityFeePerGas: bigint;
36
+ maxFeePerGas: bigint;
37
+ };
38
+ baseFee: bigint;
39
+ };
40
+ declare enum RpcMethod {
41
+ ETH_SEND_TRANSACTION = "eth_sendTransaction",
42
+ SIGN_TYPED_DATA_V3 = "eth_signTypedData_v3",
43
+ SIGN_TYPED_DATA_V4 = "eth_signTypedData_v4",
44
+ SIGN_TYPED_DATA_V1 = "eth_signTypedData_v1",
45
+ SIGN_TYPED_DATA = "eth_signTypedData",
46
+ PERSONAL_SIGN = "personal_sign",
47
+ ETH_SIGN = "eth_sign",
48
+ WALLET_ADD_ETHEREUM_CHAIN = "wallet_addEthereumChain",
49
+ WALLET_SWITCH_ETHEREUM_CHAIN = "wallet_switchEthereumChain",
50
+ WALLET_GET_ETHEREUM_CHAIN = "wallet_getEthereumChain"
51
+ }
52
+ type DappInfo = {
53
+ name: string;
54
+ url: string;
55
+ icon: string;
56
+ };
57
+ type RpcRequest = {
58
+ requestId: string;
59
+ sessionId: string;
60
+ method: RpcMethod;
61
+ chainId: Caip2ChainId;
62
+ params: unknown;
63
+ dappInfo: DappInfo;
64
+ };
65
+ type RpcError = JsonRpcError<OptionalDataWithOptionalCause> | EthereumProviderError<OptionalDataWithOptionalCause>;
66
+ type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> = {
67
+ result: R;
68
+ } | {
69
+ error: E;
70
+ };
71
+ type Network = {
72
+ chainId: Caip2ChainId;
73
+ chainName: string;
74
+ rpcUrl: string;
75
+ networkToken: NetworkToken;
76
+ multiContractAddress?: string;
77
+ logoUrl?: string;
78
+ isTestnet?: boolean;
79
+ explorerUrl?: string;
80
+ };
81
+ interface Module {
82
+ getManifest: () => Manifest | undefined;
83
+ getBalances: () => Promise<string>;
84
+ getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;
85
+ getNetworkFee: (network: Network) => Promise<NetworkFees>;
86
+ getAddress: () => Promise<string>;
87
+ getTokens: (network: Network) => Promise<NetworkContractToken[]>;
88
+ onRpcRequest: (request: RpcRequest, chain: Network) => Promise<RpcResponse>;
89
+ }
90
+ type GetTransactionHistory = {
91
+ network: Network;
92
+ address: string;
93
+ nextPageToken?: string;
94
+ offset?: number;
95
+ };
96
+ type TransactionHistoryResponse = {
97
+ transactions: Transaction[];
98
+ nextPageToken?: string;
99
+ };
100
+ type Transaction = {
101
+ isContractCall: boolean;
102
+ isIncoming: boolean;
103
+ isOutgoing: boolean;
104
+ isSender: boolean;
105
+ timestamp: number;
106
+ hash: string;
107
+ from: string;
108
+ to: string;
109
+ tokens: TxToken[];
110
+ gasPrice?: string;
111
+ gasUsed: string;
112
+ txType?: TransactionType;
113
+ chainId: string;
114
+ method?: string;
115
+ explorerLink: string;
116
+ };
117
+ interface TxToken {
118
+ decimal?: string;
119
+ name: string;
120
+ symbol: string;
121
+ amount: string;
122
+ imageUri?: string;
123
+ from?: RichAddress;
124
+ to?: RichAddress;
125
+ collectableTokenId?: string;
126
+ type: TokenType;
127
+ }
128
+ type RichAddress = {
129
+ /**
130
+ * The contract name.
131
+ */
132
+ name?: string;
133
+ /**
134
+ * The contract symbol.
135
+ */
136
+ symbol?: string;
137
+ /**
138
+ * The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.
139
+ */
140
+ decimals?: number;
141
+ /**
142
+ * The logo uri for the address.
143
+ */
144
+ logoUri?: string;
145
+ /**
146
+ * A wallet or contract address in mixed-case checksum encoding.
147
+ */
148
+ address: string;
149
+ };
150
+ interface NetworkToken {
151
+ name: string;
152
+ symbol: string;
153
+ description: string;
154
+ decimals: number;
155
+ logoUri: string;
156
+ }
157
+ interface NetworkContractToken {
158
+ address: string;
159
+ chainId?: number;
160
+ color?: string;
161
+ contractType: string;
162
+ decimals: number;
163
+ logoUri?: string;
164
+ name: string;
165
+ symbol: string;
166
+ }
167
+ declare const manifestSchema: z.ZodObject<{
168
+ name: z.ZodString;
169
+ version: z.ZodString;
170
+ description: z.ZodString;
171
+ sources: z.ZodObject<{
172
+ module: z.ZodObject<{
173
+ checksum: z.ZodString;
174
+ location: z.ZodObject<{
175
+ npm: z.ZodObject<{
176
+ filePath: z.ZodString;
177
+ packageName: z.ZodString;
178
+ registry: z.ZodString;
179
+ }, "strip", z.ZodTypeAny, {
180
+ filePath: string;
181
+ packageName: string;
182
+ registry: string;
183
+ }, {
184
+ filePath: string;
185
+ packageName: string;
186
+ registry: string;
187
+ }>;
188
+ }, "strip", z.ZodTypeAny, {
189
+ npm: {
190
+ filePath: string;
191
+ packageName: string;
192
+ registry: string;
193
+ };
194
+ }, {
195
+ npm: {
196
+ filePath: string;
197
+ packageName: string;
198
+ registry: string;
199
+ };
200
+ }>;
201
+ }, "strip", z.ZodTypeAny, {
202
+ checksum: string;
203
+ location: {
204
+ npm: {
205
+ filePath: string;
206
+ packageName: string;
207
+ registry: string;
208
+ };
209
+ };
210
+ }, {
211
+ checksum: string;
212
+ location: {
213
+ npm: {
214
+ filePath: string;
215
+ packageName: string;
216
+ registry: string;
217
+ };
218
+ };
219
+ }>;
220
+ provider: z.ZodOptional<z.ZodObject<{
221
+ checksum: z.ZodString;
222
+ location: z.ZodObject<{
223
+ npm: z.ZodObject<{
224
+ filePath: z.ZodString;
225
+ packageName: z.ZodString;
226
+ registry: z.ZodString;
227
+ }, "strip", z.ZodTypeAny, {
228
+ filePath: string;
229
+ packageName: string;
230
+ registry: string;
231
+ }, {
232
+ filePath: string;
233
+ packageName: string;
234
+ registry: string;
235
+ }>;
236
+ }, "strip", z.ZodTypeAny, {
237
+ npm: {
238
+ filePath: string;
239
+ packageName: string;
240
+ registry: string;
241
+ };
242
+ }, {
243
+ npm: {
244
+ filePath: string;
245
+ packageName: string;
246
+ registry: string;
247
+ };
248
+ }>;
249
+ }, "strip", z.ZodTypeAny, {
250
+ checksum: string;
251
+ location: {
252
+ npm: {
253
+ filePath: string;
254
+ packageName: string;
255
+ registry: string;
256
+ };
257
+ };
258
+ }, {
259
+ checksum: string;
260
+ location: {
261
+ npm: {
262
+ filePath: string;
263
+ packageName: string;
264
+ registry: string;
265
+ };
266
+ };
267
+ }>>;
268
+ }, "strip", z.ZodTypeAny, {
269
+ module: {
270
+ checksum: string;
271
+ location: {
272
+ npm: {
273
+ filePath: string;
274
+ packageName: string;
275
+ registry: string;
276
+ };
277
+ };
278
+ };
279
+ provider?: {
280
+ checksum: string;
281
+ location: {
282
+ npm: {
283
+ filePath: string;
284
+ packageName: string;
285
+ registry: string;
286
+ };
287
+ };
288
+ } | undefined;
289
+ }, {
290
+ module: {
291
+ checksum: string;
292
+ location: {
293
+ npm: {
294
+ filePath: string;
295
+ packageName: string;
296
+ registry: string;
297
+ };
298
+ };
299
+ };
300
+ provider?: {
301
+ checksum: string;
302
+ location: {
303
+ npm: {
304
+ filePath: string;
305
+ packageName: string;
306
+ registry: string;
307
+ };
308
+ };
309
+ } | undefined;
310
+ }>;
311
+ network: z.ZodObject<{
312
+ chainIds: z.ZodArray<z.ZodString, "many">;
313
+ namespaces: z.ZodArray<z.ZodString, "many">;
314
+ }, "strip", z.ZodTypeAny, {
315
+ chainIds: string[];
316
+ namespaces: string[];
317
+ }, {
318
+ chainIds: string[];
319
+ namespaces: string[];
320
+ }>;
321
+ cointype: z.ZodString;
322
+ permissions: z.ZodObject<{
323
+ rpc: z.ZodObject<{
324
+ dapps: z.ZodBoolean;
325
+ methods: z.ZodArray<z.ZodString, "many">;
326
+ }, "strip", z.ZodTypeAny, {
327
+ dapps: boolean;
328
+ methods: string[];
329
+ }, {
330
+ dapps: boolean;
331
+ methods: string[];
332
+ }>;
333
+ }, "strip", z.ZodTypeAny, {
334
+ rpc: {
335
+ dapps: boolean;
336
+ methods: string[];
337
+ };
338
+ }, {
339
+ rpc: {
340
+ dapps: boolean;
341
+ methods: string[];
342
+ };
343
+ }>;
344
+ manifestVersion: z.ZodString;
345
+ }, "strip", z.ZodTypeAny, {
346
+ name: string;
347
+ version: string;
348
+ description: string;
349
+ sources: {
350
+ module: {
351
+ checksum: string;
352
+ location: {
353
+ npm: {
354
+ filePath: string;
355
+ packageName: string;
356
+ registry: string;
357
+ };
358
+ };
359
+ };
360
+ provider?: {
361
+ checksum: string;
362
+ location: {
363
+ npm: {
364
+ filePath: string;
365
+ packageName: string;
366
+ registry: string;
367
+ };
368
+ };
369
+ } | undefined;
370
+ };
371
+ network: {
372
+ chainIds: string[];
373
+ namespaces: string[];
374
+ };
375
+ cointype: string;
376
+ permissions: {
377
+ rpc: {
378
+ dapps: boolean;
379
+ methods: string[];
380
+ };
381
+ };
382
+ manifestVersion: string;
383
+ }, {
384
+ name: string;
385
+ version: string;
386
+ description: string;
387
+ sources: {
388
+ module: {
389
+ checksum: string;
390
+ location: {
391
+ npm: {
392
+ filePath: string;
393
+ packageName: string;
394
+ registry: string;
395
+ };
396
+ };
397
+ };
398
+ provider?: {
399
+ checksum: string;
400
+ location: {
401
+ npm: {
402
+ filePath: string;
403
+ packageName: string;
404
+ registry: string;
405
+ };
406
+ };
407
+ } | undefined;
408
+ };
409
+ network: {
410
+ chainIds: string[];
411
+ namespaces: string[];
412
+ };
413
+ cointype: string;
414
+ permissions: {
415
+ rpc: {
416
+ dapps: boolean;
417
+ methods: string[];
418
+ };
419
+ };
420
+ manifestVersion: string;
421
+ }>;
422
+ type Manifest = z.infer<typeof manifestSchema>;
423
+ declare const parseManifest: (params: unknown) => z.SafeParseReturnType<unknown, Manifest>;
424
+ type Caip2ChainId = string;
425
+ type Hex = `0x${string}`;
426
+ declare enum Environment {
427
+ PRODUCTION = "production",
428
+ DEV = "dev"
429
+ }
430
+
431
+ export { Caip2ChainId, DappInfo, Environment, GetTransactionHistory, Hex, Manifest, Module, Network, NetworkContractToken, NetworkFees, NetworkToken, RpcError, RpcMethod, RpcRequest, RpcResponse, TokenType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, parseManifest };
@@ -0,0 +1,431 @@
1
+ import { z } from 'zod';
2
+ import { JsonRpcError, OptionalDataWithOptionalCause, EthereumProviderError } from '@metamask/rpc-errors';
3
+
4
+ declare enum TransactionType {
5
+ BRIDGE = "Bridge",
6
+ SWAP = "Swap",
7
+ SEND = "Send",
8
+ RECEIVE = "Receive",
9
+ NFT_BUY = "NFTBuy",
10
+ APPROVE = "Approve",
11
+ TRANSFER = "Transfer",
12
+ NFT_SEND = "NFTSend",
13
+ NFT_RECEIVE = "NFTReceive",
14
+ AIRDROP = "Airdrop",
15
+ FILL_ORDER = "FillOrder",
16
+ UNWRAP = "Unwrap",
17
+ UNKNOWN = "UNKNOWN"
18
+ }
19
+ declare enum TokenType {
20
+ NATIVE = "NATIVE",
21
+ ERC20 = "ERC20",
22
+ ERC721 = "ERC721",
23
+ ERC1155 = "ERC1155"
24
+ }
25
+ type NetworkFees = {
26
+ low: {
27
+ maxPriorityFeePerGas: bigint;
28
+ maxFeePerGas: bigint;
29
+ };
30
+ medium: {
31
+ maxPriorityFeePerGas: bigint;
32
+ maxFeePerGas: bigint;
33
+ };
34
+ high: {
35
+ maxPriorityFeePerGas: bigint;
36
+ maxFeePerGas: bigint;
37
+ };
38
+ baseFee: bigint;
39
+ };
40
+ declare enum RpcMethod {
41
+ ETH_SEND_TRANSACTION = "eth_sendTransaction",
42
+ SIGN_TYPED_DATA_V3 = "eth_signTypedData_v3",
43
+ SIGN_TYPED_DATA_V4 = "eth_signTypedData_v4",
44
+ SIGN_TYPED_DATA_V1 = "eth_signTypedData_v1",
45
+ SIGN_TYPED_DATA = "eth_signTypedData",
46
+ PERSONAL_SIGN = "personal_sign",
47
+ ETH_SIGN = "eth_sign",
48
+ WALLET_ADD_ETHEREUM_CHAIN = "wallet_addEthereumChain",
49
+ WALLET_SWITCH_ETHEREUM_CHAIN = "wallet_switchEthereumChain",
50
+ WALLET_GET_ETHEREUM_CHAIN = "wallet_getEthereumChain"
51
+ }
52
+ type DappInfo = {
53
+ name: string;
54
+ url: string;
55
+ icon: string;
56
+ };
57
+ type RpcRequest = {
58
+ requestId: string;
59
+ sessionId: string;
60
+ method: RpcMethod;
61
+ chainId: Caip2ChainId;
62
+ params: unknown;
63
+ dappInfo: DappInfo;
64
+ };
65
+ type RpcError = JsonRpcError<OptionalDataWithOptionalCause> | EthereumProviderError<OptionalDataWithOptionalCause>;
66
+ type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> = {
67
+ result: R;
68
+ } | {
69
+ error: E;
70
+ };
71
+ type Network = {
72
+ chainId: Caip2ChainId;
73
+ chainName: string;
74
+ rpcUrl: string;
75
+ networkToken: NetworkToken;
76
+ multiContractAddress?: string;
77
+ logoUrl?: string;
78
+ isTestnet?: boolean;
79
+ explorerUrl?: string;
80
+ };
81
+ interface Module {
82
+ getManifest: () => Manifest | undefined;
83
+ getBalances: () => Promise<string>;
84
+ getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;
85
+ getNetworkFee: (network: Network) => Promise<NetworkFees>;
86
+ getAddress: () => Promise<string>;
87
+ getTokens: (network: Network) => Promise<NetworkContractToken[]>;
88
+ onRpcRequest: (request: RpcRequest, chain: Network) => Promise<RpcResponse>;
89
+ }
90
+ type GetTransactionHistory = {
91
+ network: Network;
92
+ address: string;
93
+ nextPageToken?: string;
94
+ offset?: number;
95
+ };
96
+ type TransactionHistoryResponse = {
97
+ transactions: Transaction[];
98
+ nextPageToken?: string;
99
+ };
100
+ type Transaction = {
101
+ isContractCall: boolean;
102
+ isIncoming: boolean;
103
+ isOutgoing: boolean;
104
+ isSender: boolean;
105
+ timestamp: number;
106
+ hash: string;
107
+ from: string;
108
+ to: string;
109
+ tokens: TxToken[];
110
+ gasPrice?: string;
111
+ gasUsed: string;
112
+ txType?: TransactionType;
113
+ chainId: string;
114
+ method?: string;
115
+ explorerLink: string;
116
+ };
117
+ interface TxToken {
118
+ decimal?: string;
119
+ name: string;
120
+ symbol: string;
121
+ amount: string;
122
+ imageUri?: string;
123
+ from?: RichAddress;
124
+ to?: RichAddress;
125
+ collectableTokenId?: string;
126
+ type: TokenType;
127
+ }
128
+ type RichAddress = {
129
+ /**
130
+ * The contract name.
131
+ */
132
+ name?: string;
133
+ /**
134
+ * The contract symbol.
135
+ */
136
+ symbol?: string;
137
+ /**
138
+ * The number of decimals the token uses. For example `6`, means to divide the token amount by `1000000` to get its user representation.
139
+ */
140
+ decimals?: number;
141
+ /**
142
+ * The logo uri for the address.
143
+ */
144
+ logoUri?: string;
145
+ /**
146
+ * A wallet or contract address in mixed-case checksum encoding.
147
+ */
148
+ address: string;
149
+ };
150
+ interface NetworkToken {
151
+ name: string;
152
+ symbol: string;
153
+ description: string;
154
+ decimals: number;
155
+ logoUri: string;
156
+ }
157
+ interface NetworkContractToken {
158
+ address: string;
159
+ chainId?: number;
160
+ color?: string;
161
+ contractType: string;
162
+ decimals: number;
163
+ logoUri?: string;
164
+ name: string;
165
+ symbol: string;
166
+ }
167
+ declare const manifestSchema: z.ZodObject<{
168
+ name: z.ZodString;
169
+ version: z.ZodString;
170
+ description: z.ZodString;
171
+ sources: z.ZodObject<{
172
+ module: z.ZodObject<{
173
+ checksum: z.ZodString;
174
+ location: z.ZodObject<{
175
+ npm: z.ZodObject<{
176
+ filePath: z.ZodString;
177
+ packageName: z.ZodString;
178
+ registry: z.ZodString;
179
+ }, "strip", z.ZodTypeAny, {
180
+ filePath: string;
181
+ packageName: string;
182
+ registry: string;
183
+ }, {
184
+ filePath: string;
185
+ packageName: string;
186
+ registry: string;
187
+ }>;
188
+ }, "strip", z.ZodTypeAny, {
189
+ npm: {
190
+ filePath: string;
191
+ packageName: string;
192
+ registry: string;
193
+ };
194
+ }, {
195
+ npm: {
196
+ filePath: string;
197
+ packageName: string;
198
+ registry: string;
199
+ };
200
+ }>;
201
+ }, "strip", z.ZodTypeAny, {
202
+ checksum: string;
203
+ location: {
204
+ npm: {
205
+ filePath: string;
206
+ packageName: string;
207
+ registry: string;
208
+ };
209
+ };
210
+ }, {
211
+ checksum: string;
212
+ location: {
213
+ npm: {
214
+ filePath: string;
215
+ packageName: string;
216
+ registry: string;
217
+ };
218
+ };
219
+ }>;
220
+ provider: z.ZodOptional<z.ZodObject<{
221
+ checksum: z.ZodString;
222
+ location: z.ZodObject<{
223
+ npm: z.ZodObject<{
224
+ filePath: z.ZodString;
225
+ packageName: z.ZodString;
226
+ registry: z.ZodString;
227
+ }, "strip", z.ZodTypeAny, {
228
+ filePath: string;
229
+ packageName: string;
230
+ registry: string;
231
+ }, {
232
+ filePath: string;
233
+ packageName: string;
234
+ registry: string;
235
+ }>;
236
+ }, "strip", z.ZodTypeAny, {
237
+ npm: {
238
+ filePath: string;
239
+ packageName: string;
240
+ registry: string;
241
+ };
242
+ }, {
243
+ npm: {
244
+ filePath: string;
245
+ packageName: string;
246
+ registry: string;
247
+ };
248
+ }>;
249
+ }, "strip", z.ZodTypeAny, {
250
+ checksum: string;
251
+ location: {
252
+ npm: {
253
+ filePath: string;
254
+ packageName: string;
255
+ registry: string;
256
+ };
257
+ };
258
+ }, {
259
+ checksum: string;
260
+ location: {
261
+ npm: {
262
+ filePath: string;
263
+ packageName: string;
264
+ registry: string;
265
+ };
266
+ };
267
+ }>>;
268
+ }, "strip", z.ZodTypeAny, {
269
+ module: {
270
+ checksum: string;
271
+ location: {
272
+ npm: {
273
+ filePath: string;
274
+ packageName: string;
275
+ registry: string;
276
+ };
277
+ };
278
+ };
279
+ provider?: {
280
+ checksum: string;
281
+ location: {
282
+ npm: {
283
+ filePath: string;
284
+ packageName: string;
285
+ registry: string;
286
+ };
287
+ };
288
+ } | undefined;
289
+ }, {
290
+ module: {
291
+ checksum: string;
292
+ location: {
293
+ npm: {
294
+ filePath: string;
295
+ packageName: string;
296
+ registry: string;
297
+ };
298
+ };
299
+ };
300
+ provider?: {
301
+ checksum: string;
302
+ location: {
303
+ npm: {
304
+ filePath: string;
305
+ packageName: string;
306
+ registry: string;
307
+ };
308
+ };
309
+ } | undefined;
310
+ }>;
311
+ network: z.ZodObject<{
312
+ chainIds: z.ZodArray<z.ZodString, "many">;
313
+ namespaces: z.ZodArray<z.ZodString, "many">;
314
+ }, "strip", z.ZodTypeAny, {
315
+ chainIds: string[];
316
+ namespaces: string[];
317
+ }, {
318
+ chainIds: string[];
319
+ namespaces: string[];
320
+ }>;
321
+ cointype: z.ZodString;
322
+ permissions: z.ZodObject<{
323
+ rpc: z.ZodObject<{
324
+ dapps: z.ZodBoolean;
325
+ methods: z.ZodArray<z.ZodString, "many">;
326
+ }, "strip", z.ZodTypeAny, {
327
+ dapps: boolean;
328
+ methods: string[];
329
+ }, {
330
+ dapps: boolean;
331
+ methods: string[];
332
+ }>;
333
+ }, "strip", z.ZodTypeAny, {
334
+ rpc: {
335
+ dapps: boolean;
336
+ methods: string[];
337
+ };
338
+ }, {
339
+ rpc: {
340
+ dapps: boolean;
341
+ methods: string[];
342
+ };
343
+ }>;
344
+ manifestVersion: z.ZodString;
345
+ }, "strip", z.ZodTypeAny, {
346
+ name: string;
347
+ version: string;
348
+ description: string;
349
+ sources: {
350
+ module: {
351
+ checksum: string;
352
+ location: {
353
+ npm: {
354
+ filePath: string;
355
+ packageName: string;
356
+ registry: string;
357
+ };
358
+ };
359
+ };
360
+ provider?: {
361
+ checksum: string;
362
+ location: {
363
+ npm: {
364
+ filePath: string;
365
+ packageName: string;
366
+ registry: string;
367
+ };
368
+ };
369
+ } | undefined;
370
+ };
371
+ network: {
372
+ chainIds: string[];
373
+ namespaces: string[];
374
+ };
375
+ cointype: string;
376
+ permissions: {
377
+ rpc: {
378
+ dapps: boolean;
379
+ methods: string[];
380
+ };
381
+ };
382
+ manifestVersion: string;
383
+ }, {
384
+ name: string;
385
+ version: string;
386
+ description: string;
387
+ sources: {
388
+ module: {
389
+ checksum: string;
390
+ location: {
391
+ npm: {
392
+ filePath: string;
393
+ packageName: string;
394
+ registry: string;
395
+ };
396
+ };
397
+ };
398
+ provider?: {
399
+ checksum: string;
400
+ location: {
401
+ npm: {
402
+ filePath: string;
403
+ packageName: string;
404
+ registry: string;
405
+ };
406
+ };
407
+ } | undefined;
408
+ };
409
+ network: {
410
+ chainIds: string[];
411
+ namespaces: string[];
412
+ };
413
+ cointype: string;
414
+ permissions: {
415
+ rpc: {
416
+ dapps: boolean;
417
+ methods: string[];
418
+ };
419
+ };
420
+ manifestVersion: string;
421
+ }>;
422
+ type Manifest = z.infer<typeof manifestSchema>;
423
+ declare const parseManifest: (params: unknown) => z.SafeParseReturnType<unknown, Manifest>;
424
+ type Caip2ChainId = string;
425
+ type Hex = `0x${string}`;
426
+ declare enum Environment {
427
+ PRODUCTION = "production",
428
+ DEV = "dev"
429
+ }
430
+
431
+ export { Caip2ChainId, DappInfo, Environment, GetTransactionHistory, Hex, Manifest, Module, Network, NetworkContractToken, NetworkFees, NetworkToken, RpcError, RpcMethod, RpcRequest, RpcResponse, TokenType, Transaction, TransactionHistoryResponse, TransactionType, TxToken, parseManifest };
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ export { e as Environment, c as RpcMethod, b as TokenType, a as TransactionType, d as parseManifest } from './chunk-NR7FSFOY.js';
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@avalabs/vm-module-types",
3
- "version": "0.0.0-publicTypes-20240620160105",
4
- "main": "src/index.ts",
3
+ "version": "0.0.0-refactor-params-20240711144718",
4
+ "main": "dist/index.cjs",
5
+ "module": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "type": "module",
5
8
  "dependencies": {
6
- "zod": "3.23.8"
9
+ "zod": "3.23.8",
10
+ "@metamask/rpc-errors": "6.3.0"
7
11
  },
8
12
  "devDependencies": {
9
- "@internal/types": "0.0.0-publicTypes-20240620160105",
13
+ "tsup": "7.2.0",
14
+ "@internal/tsup-config": "0.0.1",
10
15
  "eslint-config-custom": "0.0.1"
11
16
  },
12
17
  "scripts": {
18
+ "build": "tsup",
13
19
  "lint": "eslint \"src/**/*.ts\""
14
20
  }
15
21
  }
package/src/types.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { object, string, boolean, z } from 'zod';
2
+ import type { JsonRpcError, EthereumProviderError, OptionalDataWithOptionalCause } from '@metamask/rpc-errors';
2
3
 
3
4
  export enum TransactionType {
4
5
  BRIDGE = 'Bridge',
@@ -30,23 +31,73 @@ export type NetworkFees = {
30
31
  baseFee: bigint;
31
32
  };
32
33
 
34
+ export enum RpcMethod {
35
+ /* EVM */
36
+ ETH_SEND_TRANSACTION = 'eth_sendTransaction',
37
+ SIGN_TYPED_DATA_V3 = 'eth_signTypedData_v3',
38
+ SIGN_TYPED_DATA_V4 = 'eth_signTypedData_v4',
39
+ SIGN_TYPED_DATA_V1 = 'eth_signTypedData_v1',
40
+ SIGN_TYPED_DATA = 'eth_signTypedData',
41
+ PERSONAL_SIGN = 'personal_sign',
42
+ ETH_SIGN = 'eth_sign',
43
+ WALLET_ADD_ETHEREUM_CHAIN = 'wallet_addEthereumChain',
44
+ WALLET_SWITCH_ETHEREUM_CHAIN = 'wallet_switchEthereumChain',
45
+ WALLET_GET_ETHEREUM_CHAIN = 'wallet_getEthereumChain',
46
+ }
47
+
48
+ export type DappInfo = {
49
+ name: string;
50
+ url: string;
51
+ icon: string;
52
+ };
53
+
54
+ export type RpcRequest = {
55
+ requestId: string;
56
+ sessionId: string;
57
+ method: RpcMethod;
58
+ chainId: Caip2ChainId;
59
+ params: unknown;
60
+ dappInfo: DappInfo;
61
+ };
62
+
63
+ export type RpcError =
64
+ | JsonRpcError<OptionalDataWithOptionalCause>
65
+ | EthereumProviderError<OptionalDataWithOptionalCause>;
66
+
67
+ export type RpcResponse<R = unknown, E extends RpcError = JsonRpcError<OptionalDataWithOptionalCause>> =
68
+ | {
69
+ result: R;
70
+ }
71
+ | {
72
+ error: E;
73
+ };
74
+
75
+ export type Network = {
76
+ chainId: Caip2ChainId;
77
+ chainName: string;
78
+ rpcUrl: string;
79
+ networkToken: NetworkToken;
80
+ multiContractAddress?: string;
81
+ logoUrl?: string;
82
+ isTestnet?: boolean;
83
+ explorerUrl?: string;
84
+ };
85
+
33
86
  export interface Module {
34
87
  getManifest: () => Manifest | undefined;
35
88
  getBalances: () => Promise<string>;
36
89
  getTransactionHistory: (params: GetTransactionHistory) => Promise<TransactionHistoryResponse>;
37
- getNetworkFee: () => Promise<NetworkFees>;
90
+ getNetworkFee: (network: Network) => Promise<NetworkFees>;
38
91
  getAddress: () => Promise<string>;
92
+ getTokens: (network: Network) => Promise<NetworkContractToken[]>;
93
+ onRpcRequest: (request: RpcRequest, chain: Network) => Promise<RpcResponse>;
39
94
  }
40
95
 
41
96
  export type GetTransactionHistory = {
42
- chainId: number;
43
- isTestnet: boolean;
44
- networkToken: NetworkToken;
45
- explorerUrl: string;
97
+ network: Network;
46
98
  address: string;
47
99
  nextPageToken?: string;
48
100
  offset?: number;
49
- glacierApiUrl?: string;
50
101
  };
51
102
 
52
103
  export type TransactionHistoryResponse = {
@@ -115,6 +166,17 @@ export interface NetworkToken {
115
166
  logoUri: string;
116
167
  }
117
168
 
169
+ export interface NetworkContractToken {
170
+ address: string;
171
+ chainId?: number;
172
+ color?: string;
173
+ contractType: string;
174
+ decimals: number;
175
+ logoUri?: string;
176
+ name: string;
177
+ symbol: string;
178
+ }
179
+
118
180
  const sourceSchema = object({
119
181
  checksum: string(),
120
182
  location: object({
@@ -153,3 +215,12 @@ export type Manifest = z.infer<typeof manifestSchema>;
153
215
  export const parseManifest = (params: unknown): z.SafeParseReturnType<unknown, Manifest> => {
154
216
  return manifestSchema.safeParse(params);
155
217
  };
218
+
219
+ export type Caip2ChainId = string;
220
+
221
+ export type Hex = `0x${string}`;
222
+
223
+ export enum Environment {
224
+ PRODUCTION = 'production',
225
+ DEV = 'dev',
226
+ }
package/tsconfig.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "extends": "@internal/tsconfig/tsconfig.base.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "./dist",
5
- "composite": true
5
+ "tsBuildInfoFile": ".tsbuildinfo"
6
6
  },
7
7
  "include": ["src"]
8
8
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { defineConfig } from 'tsup';
2
+ import { baseConfig } from '@internal/tsup-config';
3
+
4
+ export default defineConfig({ ...baseConfig, entry: ['src/*.ts'] });