@avalabs/vm-module-types 0.0.0-publicTypes-20240620175625 → 0.0.0-refactor-params-20240711144842
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/.turbo/turbo-build.log +32 -0
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +47 -2
- package/dist/chunk-NR7FSFOY.js +7 -0
- package/dist/chunk-NR7FSFOY.js.map +1 -0
- package/dist/chunk-ZEYSSEII.cjs +13 -0
- package/dist/chunk-ZEYSSEII.cjs.map +1 -0
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types.cjs +28 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +431 -0
- package/dist/types.d.ts +431 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +11 -4
- package/src/types.ts +77 -6
- package/tsconfig.json +1 -1
- package/tsup.config.ts +4 -0
|
@@ -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
|
+
[34mCLI[39m Building entry: src/index.ts, src/types.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v7.2.0
|
|
8
|
+
[34mCLI[39m Using tsup config: /home/runner/work/vm-modules/vm-modules/packages/types/tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: es2021
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mCJS[39m Build start
|
|
12
|
+
[34mESM[39m Build start
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m748.00 B[39m
|
|
14
|
+
[32mCJS[39m [1mdist/types.cjs [22m[32m748.00 B[39m
|
|
15
|
+
[32mCJS[39m [1mdist/chunk-ZEYSSEII.cjs [22m[32m1.57 KB[39m
|
|
16
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m51.00 B[39m
|
|
17
|
+
[32mCJS[39m [1mdist/types.cjs.map [22m[32m51.00 B[39m
|
|
18
|
+
[32mCJS[39m [1mdist/chunk-ZEYSSEII.cjs.map [22m[32m6.62 KB[39m
|
|
19
|
+
[32mCJS[39m ⚡️ Build success in 593ms
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m195.00 B[39m
|
|
21
|
+
[32mESM[39m [1mdist/types.js [22m[32m195.00 B[39m
|
|
22
|
+
[32mESM[39m [1mdist/chunk-NR7FSFOY.js [22m[32m1.47 KB[39m
|
|
23
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m51.00 B[39m
|
|
24
|
+
[32mESM[39m [1mdist/types.js.map [22m[32m51.00 B[39m
|
|
25
|
+
[32mESM[39m [1mdist/chunk-NR7FSFOY.js.map [22m[32m6.62 KB[39m
|
|
26
|
+
[32mESM[39m ⚡️ Build success in 594ms
|
|
27
|
+
[34mDTS[39m Build start
|
|
28
|
+
[32mDTS[39m ⚡️ Build success in 7341ms
|
|
29
|
+
[32mDTS[39m [1mdist/types.d.cts [22m[32m11.47 KB[39m
|
|
30
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m355.00 B[39m
|
|
31
|
+
[32mDTS[39m [1mdist/types.d.ts [22m[32m11.47 KB[39m
|
|
32
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m354.00 B[39m
|
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,52 @@
|
|
|
1
1
|
# @avalabs/vm-module-types
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-refactor-params-20240711144842
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- cd97708: fix: build types package
|
|
8
|
+
- e0c3f2b: make module interface more consistent
|
|
9
|
+
|
|
10
|
+
## 0.0.11
|
|
11
|
+
|
|
12
|
+
## 0.0.10
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 60f36fa: add getTokens function
|
|
17
|
+
|
|
18
|
+
## 0.0.9
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 6ffa356: add module functions to evm-module
|
|
23
|
+
|
|
24
|
+
## 0.0.8
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- d1d080f: test release
|
|
29
|
+
|
|
30
|
+
## 0.0.7
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- bb98621: Move types to @avalabs/vm-module-types
|
|
35
|
+
|
|
36
|
+
## 0.0.6
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 1122704: test release
|
|
41
|
+
|
|
42
|
+
## 0.0.3
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- 0b0c52e: Move types to @avalabs/vm-module-types
|
|
47
|
+
|
|
48
|
+
## 0.0.2
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- 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":""}
|
package/dist/index.d.cts
ADDED
|
@@ -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';
|
package/dist/index.d.ts
ADDED
|
@@ -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 @@
|
|
|
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":""}
|
package/dist/types.d.cts
ADDED
|
@@ -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.d.ts
ADDED
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avalabs/vm-module-types",
|
|
3
|
-
"version": "0.0.0-
|
|
4
|
-
"main": "
|
|
3
|
+
"version": "0.0.0-refactor-params-20240711144842",
|
|
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
|
-
"
|
|
13
|
+
"tsup": "7.2.0",
|
|
14
|
+
"@internal/tsup-config": "0.0.1",
|
|
15
|
+
"eslint-config-custom": "0.0.0-refactor-params-20240711144842"
|
|
10
16
|
},
|
|
11
17
|
"scripts": {
|
|
18
|
+
"build": "tsup",
|
|
12
19
|
"lint": "eslint \"src/**/*.ts\""
|
|
13
20
|
}
|
|
14
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
|
-
|
|
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
package/tsup.config.ts
ADDED