@heyanon/sdk 1.0.5 → 2.0.0

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.
Files changed (43) hide show
  1. package/dist/adapter/types.d.ts +16 -6
  2. package/dist/blockchain/constants/chains.d.ts +20 -19
  3. package/dist/blockchain/constants/index.d.ts +0 -3
  4. package/dist/blockchain/evm/abis/WETH9Abi.d.ts +187 -0
  5. package/dist/blockchain/evm/abis/index.d.ts +1 -0
  6. package/dist/blockchain/evm/constants/chains.d.ts +17 -0
  7. package/dist/blockchain/evm/constants/index.d.ts +3 -0
  8. package/dist/blockchain/evm/constants/weth9.d.ts +21 -0
  9. package/dist/blockchain/evm/index.d.ts +4 -0
  10. package/dist/blockchain/{helpers → evm/utils}/checkToApprove.d.ts +1 -1
  11. package/dist/blockchain/evm/utils/getChainFromName.d.ts +2 -0
  12. package/dist/blockchain/evm/utils/getChainName.d.ts +1 -0
  13. package/dist/blockchain/evm/utils/getUnwrapData.d.ts +3 -0
  14. package/dist/blockchain/evm/utils/getWrapAddress.d.ts +3 -0
  15. package/dist/blockchain/evm/utils/getWrapAddress.test.d.ts +1 -0
  16. package/dist/blockchain/evm/utils/getWrapData.d.ts +3 -0
  17. package/dist/blockchain/evm/utils/getWrapData.test.d.ts +1 -0
  18. package/dist/blockchain/evm/utils/getWrappedNative.d.ts +3 -0
  19. package/dist/blockchain/evm/utils/getWrappedNative.test.d.ts +1 -0
  20. package/dist/blockchain/{helpers → evm/utils}/index.d.ts +6 -2
  21. package/dist/blockchain/evm/utils/isEvmChain.d.ts +1 -0
  22. package/dist/blockchain/evm/utils/isEvmChain.test.d.ts +1 -0
  23. package/dist/blockchain/index.d.ts +2 -2
  24. package/dist/blockchain/solana/index.d.ts +2 -0
  25. package/dist/blockchain/solana/types.d.ts +12 -0
  26. package/dist/blockchain/solana/utils/buildV0Transaction.d.ts +8 -0
  27. package/dist/blockchain/solana/utils/index.d.ts +2 -0
  28. package/dist/blockchain/solana/utils/toPublicKey.d.ts +2 -0
  29. package/dist/blockchain/solana/utils/toPublicKey.test.d.ts +1 -0
  30. package/dist/index.js +476 -104
  31. package/dist/index.mjs +472 -94
  32. package/package.json +2 -1
  33. package/dist/blockchain/constants/chainNames.d.ts +0 -3
  34. package/dist/blockchain/constants/weth9.d.ts +0 -23
  35. package/dist/blockchain/helpers/getChainFromName.d.ts +0 -2
  36. package/dist/blockchain/helpers/getChainName.d.ts +0 -2
  37. package/dist/blockchain/helpers/getWrappedNative.d.ts +0 -3
  38. /package/dist/blockchain/{constants → evm/constants}/misc.d.ts +0 -0
  39. /package/dist/blockchain/{types.d.ts → evm/types.d.ts} +0 -0
  40. /package/dist/blockchain/{helpers → evm/utils}/checkToApprove.test.d.ts +0 -0
  41. /package/dist/blockchain/{helpers → evm/utils}/getChainFromName.test.d.ts +0 -0
  42. /package/dist/blockchain/{helpers → evm/utils}/getChainName.test.d.ts +0 -0
  43. /package/dist/blockchain/{helpers/getWrappedNative.test.d.ts → evm/utils/getUnwrapData.test.d.ts} +0 -0
@@ -1,21 +1,31 @@
1
1
  import { AiTool } from '../ai';
2
- import { ChainId, SendTransactionProps, TransactionReturn } from '../blockchain';
2
+ import { EVM, Solana } from '../blockchain';
3
3
  import { Hex, PublicClient, SignMessageReturnType, SignTypedDataParameters as ViemSignTypedDataParameters, SignTypedDataReturnType } from 'viem';
4
+ import { Connection, PublicKey } from '@solana/web3.js';
4
5
  export interface FunctionReturn {
5
6
  readonly success: boolean;
6
7
  readonly data: string;
7
8
  }
8
9
  type SignTypedDataParameters = Omit<ViemSignTypedDataParameters, 'account'>;
9
- export interface FunctionOptions {
10
- readonly getProvider: (chainId: ChainId) => PublicClient;
11
- readonly sendTransactions: (props: SendTransactionProps) => Promise<TransactionReturn>;
12
- readonly notify: (message: string) => Promise<any>;
10
+ export interface EvmFunctionOptions {
11
+ readonly getProvider: (chainId: number) => PublicClient;
12
+ readonly sendTransactions: (props: EVM.types.SendTransactionProps) => Promise<EVM.types.TransactionReturn>;
13
13
  readonly signMessages?: (messages: Hex[]) => Promise<SignMessageReturnType[]>;
14
14
  readonly signTypedDatas?: (args: SignTypedDataParameters[]) => Promise<SignTypedDataReturnType[]>;
15
15
  }
16
+ export interface SolanaFunctionOptions {
17
+ readonly getConnection: () => Connection;
18
+ readonly sendTransactions: (props: Solana.types.SendTransactionProps) => Promise<Solana.types.TransactionReturn>;
19
+ readonly getPublicKey: () => Promise<PublicKey>;
20
+ }
21
+ export interface FunctionOptions {
22
+ readonly evm: EvmFunctionOptions;
23
+ readonly solana: SolanaFunctionOptions;
24
+ readonly notify: (message: string) => Promise<void>;
25
+ }
16
26
  export interface AdapterExport {
17
27
  readonly tools: AiTool[];
18
- readonly functions: Record<string, (args: any, options: FunctionOptions) => PromiseLike<FunctionReturn>>;
28
+ readonly functions: Record<string, (args: any, options: FunctionOptions) => Promise<FunctionReturn>>;
19
29
  readonly description: string;
20
30
  }
21
31
  export {};
@@ -1,20 +1,21 @@
1
- export declare enum ChainId {
2
- ETHEREUM = 1,
3
- OPTIMISM = 10,
4
- BSC = 56,
5
- GNOSIS = 100,
6
- POLYGON = 137,
7
- SONIC = 146,
8
- FANTOM = 250,
9
- ZKSYNC = 324,
10
- METIS = 1088,
11
- KAVA = 2222,
12
- BASE = 8453,
13
- IOTA = 8822,
14
- AVALANCHE = 43114,
15
- ARBITRUM = 42161,
16
- ONE_SEPOLIA = 421614,
17
- SCROLL = 534352,
18
- SEPOLIA = 11155111
1
+ export declare enum Chain {
2
+ ETHEREUM = "ethereum",
3
+ OPTIMISM = "optimism",
4
+ BSC = "bsc",
5
+ GNOSIS = "gnosis",
6
+ POLYGON = "polygon",
7
+ SONIC = "sonic",
8
+ FANTOM = "fantom",
9
+ ZKSYNC = "zksync",
10
+ METIS = "metis",
11
+ KAVA_EVM = "kava_evm",
12
+ BASE = "base",
13
+ IOTA_EVM = "iota_evm",
14
+ AVALANCHE = "avalanche",
15
+ ARBITRUM = "arbitrum",
16
+ SCROLL = "scroll",
17
+ SOLANA = "solana"
19
18
  }
20
- export declare const allChainIds: ChainId[];
19
+ export type EvmChain = Exclude<Chain, Chain.SOLANA>;
20
+ export declare const allChains: Chain[];
21
+ export declare const allEvmChains: (Chain.ETHEREUM | Chain.OPTIMISM | Chain.BSC | Chain.GNOSIS | Chain.POLYGON | Chain.SONIC | Chain.FANTOM | Chain.ZKSYNC | Chain.METIS | Chain.KAVA_EVM | Chain.BASE | Chain.IOTA_EVM | Chain.AVALANCHE | Chain.ARBITRUM | Chain.SCROLL)[];
@@ -1,4 +1 @@
1
1
  export * from './chains';
2
- export * from './weth9';
3
- export * from './chainNames';
4
- export * from './misc';
@@ -0,0 +1,187 @@
1
+ export declare const WETH9Abi: readonly [{
2
+ readonly anonymous: false;
3
+ readonly inputs: readonly [{
4
+ readonly indexed: true;
5
+ readonly internalType: "address";
6
+ readonly name: "owner";
7
+ readonly type: "address";
8
+ }, {
9
+ readonly indexed: true;
10
+ readonly internalType: "address";
11
+ readonly name: "spender";
12
+ readonly type: "address";
13
+ }, {
14
+ readonly indexed: false;
15
+ readonly internalType: "uint256";
16
+ readonly name: "value";
17
+ readonly type: "uint256";
18
+ }];
19
+ readonly name: "Approval";
20
+ readonly type: "event";
21
+ }, {
22
+ readonly anonymous: false;
23
+ readonly inputs: readonly [{
24
+ readonly indexed: true;
25
+ readonly internalType: "address";
26
+ readonly name: "from";
27
+ readonly type: "address";
28
+ }, {
29
+ readonly indexed: true;
30
+ readonly internalType: "address";
31
+ readonly name: "to";
32
+ readonly type: "address";
33
+ }, {
34
+ readonly indexed: false;
35
+ readonly internalType: "uint256";
36
+ readonly name: "value";
37
+ readonly type: "uint256";
38
+ }];
39
+ readonly name: "Transfer";
40
+ readonly type: "event";
41
+ }, {
42
+ readonly inputs: readonly [{
43
+ readonly internalType: "address";
44
+ readonly name: "owner";
45
+ readonly type: "address";
46
+ }, {
47
+ readonly internalType: "address";
48
+ readonly name: "spender";
49
+ readonly type: "address";
50
+ }];
51
+ readonly name: "allowance";
52
+ readonly outputs: readonly [{
53
+ readonly internalType: "uint256";
54
+ readonly name: "";
55
+ readonly type: "uint256";
56
+ }];
57
+ readonly stateMutability: "view";
58
+ readonly type: "function";
59
+ }, {
60
+ readonly inputs: readonly [{
61
+ readonly internalType: "address";
62
+ readonly name: "spender";
63
+ readonly type: "address";
64
+ }, {
65
+ readonly internalType: "uint256";
66
+ readonly name: "amount";
67
+ readonly type: "uint256";
68
+ }];
69
+ readonly name: "approve";
70
+ readonly outputs: readonly [{
71
+ readonly internalType: "bool";
72
+ readonly name: "";
73
+ readonly type: "bool";
74
+ }];
75
+ readonly stateMutability: "nonpayable";
76
+ readonly type: "function";
77
+ }, {
78
+ readonly inputs: readonly [{
79
+ readonly internalType: "address";
80
+ readonly name: "account";
81
+ readonly type: "address";
82
+ }];
83
+ readonly name: "balanceOf";
84
+ readonly outputs: readonly [{
85
+ readonly internalType: "uint256";
86
+ readonly name: "";
87
+ readonly type: "uint256";
88
+ }];
89
+ readonly stateMutability: "view";
90
+ readonly type: "function";
91
+ }, {
92
+ readonly inputs: readonly [];
93
+ readonly name: "deposit";
94
+ readonly outputs: readonly [];
95
+ readonly stateMutability: "payable";
96
+ readonly type: "function";
97
+ }, {
98
+ readonly inputs: readonly [];
99
+ readonly name: "totalSupply";
100
+ readonly outputs: readonly [{
101
+ readonly internalType: "uint256";
102
+ readonly name: "";
103
+ readonly type: "uint256";
104
+ }];
105
+ readonly stateMutability: "view";
106
+ readonly type: "function";
107
+ }, {
108
+ readonly inputs: readonly [{
109
+ readonly internalType: "address";
110
+ readonly name: "to";
111
+ readonly type: "address";
112
+ }, {
113
+ readonly internalType: "uint256";
114
+ readonly name: "amount";
115
+ readonly type: "uint256";
116
+ }];
117
+ readonly name: "transfer";
118
+ readonly outputs: readonly [{
119
+ readonly internalType: "bool";
120
+ readonly name: "";
121
+ readonly type: "bool";
122
+ }];
123
+ readonly stateMutability: "nonpayable";
124
+ readonly type: "function";
125
+ }, {
126
+ readonly inputs: readonly [{
127
+ readonly internalType: "address";
128
+ readonly name: "from";
129
+ readonly type: "address";
130
+ }, {
131
+ readonly internalType: "address";
132
+ readonly name: "to";
133
+ readonly type: "address";
134
+ }, {
135
+ readonly internalType: "uint256";
136
+ readonly name: "amount";
137
+ readonly type: "uint256";
138
+ }];
139
+ readonly name: "transferFrom";
140
+ readonly outputs: readonly [{
141
+ readonly internalType: "bool";
142
+ readonly name: "";
143
+ readonly type: "bool";
144
+ }];
145
+ readonly stateMutability: "nonpayable";
146
+ readonly type: "function";
147
+ }, {
148
+ readonly inputs: readonly [{
149
+ readonly internalType: "uint256";
150
+ readonly name: "wad";
151
+ readonly type: "uint256";
152
+ }];
153
+ readonly name: "withdraw";
154
+ readonly outputs: readonly [];
155
+ readonly stateMutability: "nonpayable";
156
+ readonly type: "function";
157
+ }, {
158
+ readonly inputs: readonly [];
159
+ readonly name: "name";
160
+ readonly outputs: readonly [{
161
+ readonly internalType: "string";
162
+ readonly name: "";
163
+ readonly type: "string";
164
+ }];
165
+ readonly stateMutability: "view";
166
+ readonly type: "function";
167
+ }, {
168
+ readonly inputs: readonly [];
169
+ readonly name: "symbol";
170
+ readonly outputs: readonly [{
171
+ readonly internalType: "string";
172
+ readonly name: "";
173
+ readonly type: "string";
174
+ }];
175
+ readonly stateMutability: "view";
176
+ readonly type: "function";
177
+ }, {
178
+ readonly inputs: readonly [];
179
+ readonly name: "decimals";
180
+ readonly outputs: readonly [{
181
+ readonly internalType: "uint8";
182
+ readonly name: "";
183
+ readonly type: "uint8";
184
+ }];
185
+ readonly stateMutability: "view";
186
+ readonly type: "function";
187
+ }];
@@ -0,0 +1 @@
1
+ export * from './WETH9Abi';
@@ -0,0 +1,17 @@
1
+ export declare const ChainIds: {
2
+ ethereum: number;
3
+ optimism: number;
4
+ bsc: number;
5
+ gnosis: number;
6
+ polygon: number;
7
+ sonic: number;
8
+ fantom: number;
9
+ zksync: number;
10
+ metis: number;
11
+ kava_evm: number;
12
+ base: number;
13
+ iota_evm: number;
14
+ avalanche: number;
15
+ arbitrum: number;
16
+ scroll: number;
17
+ };
@@ -0,0 +1,3 @@
1
+ export * from './misc';
2
+ export * from './weth9';
3
+ export * from './chains';
@@ -0,0 +1,21 @@
1
+ import { Token } from '@real-wagmi/sdk';
2
+ /**
3
+ * Known WETH9 implementation addresses, used in our implementation of Ether#wrapped
4
+ */
5
+ export declare const WETH9: {
6
+ ethereum: Token;
7
+ optimism: Token;
8
+ bsc: Token;
9
+ polygon: Token;
10
+ fantom: Token;
11
+ zksync: Token;
12
+ kava_evm: Token;
13
+ avalanche: Token;
14
+ arbitrum: Token;
15
+ metis: Token;
16
+ base: Token;
17
+ iota_evm: Token;
18
+ sonic: Token;
19
+ scroll: Token;
20
+ gnosis: Token;
21
+ };
@@ -0,0 +1,4 @@
1
+ export * as types from './types';
2
+ export * as utils from './utils';
3
+ export * as constants from './constants';
4
+ export * as abis from './abis';
@@ -1,5 +1,5 @@
1
1
  import { Address, PublicClient } from 'viem';
2
- import { TransactionParams } from '../../blockchain';
2
+ import { TransactionParams } from '../types';
3
3
  interface Props {
4
4
  readonly args: {
5
5
  readonly account: Address;
@@ -0,0 +1,2 @@
1
+ import { EvmChain } from '../../constants';
2
+ export declare function getChainFromName(chain: EvmChain): number;
@@ -0,0 +1 @@
1
+ export declare function getChainName(chainId: number): string;
@@ -0,0 +1,3 @@
1
+ import { EvmChain } from '../../constants';
2
+ import { TransactionParams } from '../types';
3
+ export declare function getUnwrapData(chain: EvmChain, amount: bigint): TransactionParams;
@@ -0,0 +1,3 @@
1
+ import { EvmChain } from '../../constants';
2
+ import { Address } from 'viem';
3
+ export declare function getWrapAddress(chain: EvmChain): Address;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { TransactionParams } from '../types';
2
+ import { EvmChain } from '../../constants';
3
+ export declare function getWrapData(chain: EvmChain, amount: bigint): TransactionParams;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Token } from '@real-wagmi/sdk';
2
+ import { EvmChain } from '../../constants/chains';
3
+ export declare function getWrappedNative(chain: EvmChain): Token;
@@ -1,4 +1,8 @@
1
- export * from './getChainName';
1
+ export * from './checkToApprove';
2
2
  export * from './getChainFromName';
3
+ export * from './getChainName';
4
+ export * from './getUnwrapData';
5
+ export * from './getWrapAddress';
6
+ export * from './getWrapData';
3
7
  export * from './getWrappedNative';
4
- export * from './checkToApprove';
8
+ export * from './isEvmChain';
@@ -0,0 +1 @@
1
+ export declare function isEvmChain(chain: string): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,3 @@
1
+ export * as EVM from './evm';
2
+ export * as Solana from './solana';
1
3
  export * from './constants';
2
- export * from './helpers';
3
- export * from './types';
@@ -0,0 +1,2 @@
1
+ export * as types from './types';
2
+ export * as utils from './utils';
@@ -0,0 +1,12 @@
1
+ import { PublicKey, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
2
+ export interface TransactionReturnData {
3
+ readonly message: string;
4
+ readonly hash: TransactionSignature;
5
+ }
6
+ export interface TransactionReturn {
7
+ readonly data: TransactionReturnData[];
8
+ }
9
+ export interface SendTransactionProps {
10
+ readonly account: PublicKey;
11
+ readonly transactions: VersionedTransaction[];
12
+ }
@@ -0,0 +1,8 @@
1
+ import { Connection, PublicKey, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
2
+ interface Props {
3
+ connection: Connection;
4
+ payer: PublicKey;
5
+ instructions: TransactionInstruction[];
6
+ }
7
+ export declare function buildV0Transaction({ connection, payer, instructions }: Props): Promise<VersionedTransaction>;
8
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './buildV0Transaction';
2
+ export * from './toPublicKey';
@@ -0,0 +1,2 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ export declare function toPublicKey(publicKey: string): PublicKey;
@@ -0,0 +1 @@
1
+ export {};