@sign-global/tokentable 0.4.3-beta.0 → 0.4.3-beta.1

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 (213) hide show
  1. package/dist/cjs/airdrop/AirdropClient.d.ts +1 -1
  2. package/dist/cjs/airdrop/AirdropClient.js +4 -3
  3. package/dist/cjs/airdrop/AirdropClient.js.map +1 -1
  4. package/dist/cjs/airdrop/SignatureAirdropClient.d.ts +10 -1
  5. package/dist/cjs/airdrop/SignatureAirdropClient.js +48 -11
  6. package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -1
  7. package/dist/cjs/airdrop/common/index.d.ts +1 -1
  8. package/dist/cjs/airdrop/constants/chain-config.d.ts +1 -1
  9. package/dist/cjs/airdrop/constants/chain-config.js +1 -1
  10. package/dist/cjs/airdrop/constants/chain-config.js.map +1 -1
  11. package/dist/cjs/airdrop/constants/index.d.ts +1 -0
  12. package/dist/cjs/airdrop/constants/index.js +1 -0
  13. package/dist/cjs/airdrop/constants/index.js.map +1 -1
  14. package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureClient.js +0 -1
  15. package/dist/cjs/airdrop/contracts/evm/contracts/AirdropSignatureClient.js.map +1 -1
  16. package/dist/cjs/airdrop/contracts/index.d.ts +1 -0
  17. package/dist/cjs/airdrop/contracts/index.js +3 -1
  18. package/dist/cjs/airdrop/contracts/index.js.map +1 -1
  19. package/dist/cjs/airdrop/contracts/solana/AirdropService.d.ts +16 -0
  20. package/dist/cjs/airdrop/contracts/solana/AirdropService.js +38 -0
  21. package/dist/cjs/airdrop/contracts/solana/AirdropService.js.map +1 -0
  22. package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js +2 -2
  23. package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
  24. package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.d.ts +3 -2
  25. package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.js +7 -3
  26. package/dist/cjs/airdrop/contracts/solana/FeeCollectorClient.js.map +1 -1
  27. package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.d.ts +49 -0
  28. package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.js +242 -0
  29. package/dist/cjs/airdrop/contracts/solana/MerkleDistributorClient.js.map +1 -0
  30. package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.d.ts +1 -0
  31. package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js +3 -0
  32. package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js.map +1 -1
  33. package/dist/cjs/airdrop/contracts/solana/fee_collector.d.ts +49 -1
  34. package/dist/cjs/airdrop/contracts/solana/fee_collector.json +51 -3
  35. package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.d.ts +1695 -0
  36. package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.js +3 -0
  37. package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.js.map +1 -0
  38. package/dist/cjs/airdrop/contracts/solana/merkle_token_distributor_solana.json +1689 -0
  39. package/dist/cjs/airdrop/services/index.d.ts +3 -2
  40. package/dist/cjs/airdrop/services/index.js +8 -1
  41. package/dist/cjs/airdrop/services/index.js.map +1 -1
  42. package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.d.ts +1 -0
  43. package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.js +2 -1
  44. package/dist/cjs/airdrop/strategies/AirdropStrategyFactory.js.map +1 -1
  45. package/dist/cjs/airdrop/strategies/IAirdropStrategy.d.ts +1 -0
  46. package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.d.ts +25 -0
  47. package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.js +62 -0
  48. package/dist/cjs/airdrop/strategies/SolanaAirdropStrategy.js.map +1 -0
  49. package/dist/cjs/airdrop/types/index.d.ts +6 -1
  50. package/dist/cjs/airdrop/types/index.js +1 -0
  51. package/dist/cjs/airdrop/types/index.js.map +1 -1
  52. package/dist/esm/airdrop/AirdropClient.d.ts +1 -1
  53. package/dist/esm/airdrop/AirdropClient.js +4 -3
  54. package/dist/esm/airdrop/AirdropClient.js.map +1 -1
  55. package/dist/esm/airdrop/SignatureAirdropClient.d.ts +10 -1
  56. package/dist/esm/airdrop/SignatureAirdropClient.js +49 -12
  57. package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -1
  58. package/dist/esm/airdrop/common/index.d.ts +1 -1
  59. package/dist/esm/airdrop/constants/chain-config.d.ts +1 -1
  60. package/dist/esm/airdrop/constants/chain-config.js +1 -1
  61. package/dist/esm/airdrop/constants/chain-config.js.map +1 -1
  62. package/dist/esm/airdrop/constants/index.d.ts +1 -0
  63. package/dist/esm/airdrop/constants/index.js +1 -0
  64. package/dist/esm/airdrop/constants/index.js.map +1 -1
  65. package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureClient.js +0 -1
  66. package/dist/esm/airdrop/contracts/evm/contracts/AirdropSignatureClient.js.map +1 -1
  67. package/dist/esm/airdrop/contracts/index.d.ts +1 -0
  68. package/dist/esm/airdrop/contracts/index.js +1 -0
  69. package/dist/esm/airdrop/contracts/index.js.map +1 -1
  70. package/dist/esm/airdrop/contracts/solana/AirdropService.d.ts +16 -0
  71. package/dist/esm/airdrop/contracts/solana/AirdropService.js +34 -0
  72. package/dist/esm/airdrop/contracts/solana/AirdropService.js.map +1 -0
  73. package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js +2 -2
  74. package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
  75. package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.d.ts +3 -2
  76. package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.js +7 -3
  77. package/dist/esm/airdrop/contracts/solana/FeeCollectorClient.js.map +1 -1
  78. package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.d.ts +49 -0
  79. package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.js +212 -0
  80. package/dist/esm/airdrop/contracts/solana/MerkleDistributorClient.js.map +1 -0
  81. package/dist/esm/airdrop/contracts/solana/SolanaContractClient.d.ts +1 -0
  82. package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js +3 -0
  83. package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js.map +1 -1
  84. package/dist/esm/airdrop/contracts/solana/fee_collector.d.ts +49 -1
  85. package/dist/esm/airdrop/contracts/solana/fee_collector.json +51 -3
  86. package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.d.ts +1695 -0
  87. package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.js +2 -0
  88. package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.js.map +1 -0
  89. package/dist/esm/airdrop/contracts/solana/merkle_token_distributor_solana.json +1689 -0
  90. package/dist/esm/airdrop/services/index.d.ts +3 -2
  91. package/dist/esm/airdrop/services/index.js +6 -0
  92. package/dist/esm/airdrop/services/index.js.map +1 -1
  93. package/dist/esm/airdrop/strategies/AirdropStrategyFactory.d.ts +1 -0
  94. package/dist/esm/airdrop/strategies/AirdropStrategyFactory.js +2 -1
  95. package/dist/esm/airdrop/strategies/AirdropStrategyFactory.js.map +1 -1
  96. package/dist/esm/airdrop/strategies/IAirdropStrategy.d.ts +1 -0
  97. package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.d.ts +25 -0
  98. package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.js +58 -0
  99. package/dist/esm/airdrop/strategies/SolanaAirdropStrategy.js.map +1 -0
  100. package/dist/esm/airdrop/types/index.d.ts +6 -1
  101. package/dist/esm/airdrop/types/index.js +1 -0
  102. package/dist/esm/airdrop/types/index.js.map +1 -1
  103. package/package.json +2 -9
  104. package/src/airdrop/AirdropClient.ts +0 -307
  105. package/src/airdrop/SignatureAirdropClient.ts +0 -337
  106. package/src/airdrop/common/index.ts +0 -54
  107. package/src/airdrop/common/projectDataForTon.ts +0 -79
  108. package/src/airdrop/constants/chain-config.ts +0 -107
  109. package/src/airdrop/constants/index.ts +0 -8
  110. package/src/airdrop/constants/network.ts +0 -78
  111. package/src/airdrop/contracts/evm/AirdropService.ts +0 -181
  112. package/src/airdrop/contracts/evm/SignatureAirdropService.ts +0 -114
  113. package/src/airdrop/contracts/evm/contracts/AirdropSignatureClient.ts +0 -63
  114. package/src/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.ts +0 -61
  115. package/src/airdrop/contracts/evm/contracts/AirdropV2Client.ts +0 -37
  116. package/src/airdrop/contracts/evm/contracts/AirdropV3Client.ts +0 -49
  117. package/src/airdrop/contracts/evm/contracts/AirdropV3FeeClient.ts +0 -16
  118. package/src/airdrop/contracts/evm/contracts/AirdropV4Client.ts +0 -36
  119. package/src/airdrop/contracts/evm/contracts/ContractBaseClient.ts +0 -85
  120. package/src/airdrop/contracts/evm/contracts/DeployClient.ts +0 -35
  121. package/src/airdrop/contracts/evm/contracts/FeeCollectorClient.ts +0 -21
  122. package/src/airdrop/contracts/evm/contracts/KycClient.ts +0 -21
  123. package/src/airdrop/contracts/evm/contracts/abis/Airdrop.json +0 -674
  124. package/src/airdrop/contracts/evm/contracts/abis/AirdropV2.json +0 -676
  125. package/src/airdrop/contracts/evm/contracts/abis/AirdropV3.json +0 -740
  126. package/src/airdrop/contracts/evm/contracts/abis/AirdropV3_Fee.json +0 -678
  127. package/src/airdrop/contracts/evm/contracts/abis/CustomFeeNativeAirdropV4.json +0 -701
  128. package/src/airdrop/contracts/evm/contracts/abis/Deployer.json +0 -271
  129. package/src/airdrop/contracts/evm/contracts/abis/ERC721.json +0 -737
  130. package/src/airdrop/contracts/evm/contracts/abis/FeeCollector.json +0 -322
  131. package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
  132. package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +0 -260
  133. package/src/airdrop/contracts/evm/contracts/abis/KycHook.json +0 -312
  134. package/src/airdrop/contracts/index.ts +0 -4
  135. package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +0 -242
  136. package/src/airdrop/contracts/solana/FeeCollectorClient.ts +0 -43
  137. package/src/airdrop/contracts/solana/SignatureAirdropService.ts +0 -51
  138. package/src/airdrop/contracts/solana/SolanaContractClient.ts +0 -126
  139. package/src/airdrop/contracts/solana/fee_collector.json +0 -1063
  140. package/src/airdrop/contracts/solana/fee_collector.ts +0 -1069
  141. package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +0 -1573
  142. package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +0 -1579
  143. package/src/airdrop/contracts/ton/AirdropClientV1.ts +0 -122
  144. package/src/airdrop/contracts/ton/AirdropClientV2.ts +0 -118
  145. package/src/airdrop/contracts/ton/AirdropClientV21.ts +0 -131
  146. package/src/airdrop/contracts/ton/AirdropClientV3.ts +0 -127
  147. package/src/airdrop/contracts/ton/AirdropService.ts +0 -150
  148. package/src/airdrop/contracts/ton/TonContractBaseClient.ts +0 -236
  149. package/src/airdrop/contracts/ton/v1/build/Leaf.compiled.json +0 -1
  150. package/src/airdrop/contracts/ton/v1/build/MerkleTokenDistributor.compiled.json +0 -1
  151. package/src/airdrop/contracts/ton/v1/utils/constants.ts +0 -42
  152. package/src/airdrop/contracts/ton/v1/utils/date.utils.ts +0 -11
  153. package/src/airdrop/contracts/ton/v1/utils/index.ts +0 -3
  154. package/src/airdrop/contracts/ton/v1/utils/ton.utils.ts +0 -84
  155. package/src/airdrop/contracts/ton/v1/wrappers/JettonMinter.ts +0 -81
  156. package/src/airdrop/contracts/ton/v1/wrappers/JettonWallet.ts +0 -73
  157. package/src/airdrop/contracts/ton/v1/wrappers/Leaf.ts +0 -88
  158. package/src/airdrop/contracts/ton/v1/wrappers/MerkleTokenDistributor.ts +0 -317
  159. package/src/airdrop/contracts/ton/v1/wrappers/index.ts +0 -2
  160. package/src/airdrop/contracts/ton/v2/build/Leaf.compiled.json +0 -1
  161. package/src/airdrop/contracts/ton/v2/build/MerkleTokenDistributor.compiled.json +0 -1
  162. package/src/airdrop/contracts/ton/v2/utils/constants.ts +0 -43
  163. package/src/airdrop/contracts/ton/v2/utils/date.utils.ts +0 -11
  164. package/src/airdrop/contracts/ton/v2/utils/index.ts +0 -3
  165. package/src/airdrop/contracts/ton/v2/utils/ton.utils.ts +0 -102
  166. package/src/airdrop/contracts/ton/v2/wrappers/Leaf.ts +0 -69
  167. package/src/airdrop/contracts/ton/v2/wrappers/MerkleTokenDistributor.ts +0 -340
  168. package/src/airdrop/contracts/ton/v2/wrappers/index.ts +0 -2
  169. package/src/airdrop/contracts/ton/v21/build/Leaf.compiled.json +0 -1
  170. package/src/airdrop/contracts/ton/v21/build/MerkleTokenDistributor.compiled.json +0 -1
  171. package/src/airdrop/contracts/ton/v21/utils/constants.ts +0 -48
  172. package/src/airdrop/contracts/ton/v21/utils/date.utils.ts +0 -11
  173. package/src/airdrop/contracts/ton/v21/utils/index.ts +0 -3
  174. package/src/airdrop/contracts/ton/v21/utils/ton.utils.ts +0 -84
  175. package/src/airdrop/contracts/ton/v21/wrappers/Leaf.ts +0 -69
  176. package/src/airdrop/contracts/ton/v21/wrappers/MerkleTokenDistributor.ts +0 -346
  177. package/src/airdrop/contracts/ton/v21/wrappers/index.ts +0 -2
  178. package/src/airdrop/contracts/ton/v3/build/Leaf.compiled.json +0 -1
  179. package/src/airdrop/contracts/ton/v3/build/MerkleTokenDistributor.compiled.json +0 -1
  180. package/src/airdrop/contracts/ton/v3/utils/constants.ts +0 -43
  181. package/src/airdrop/contracts/ton/v3/utils/date.utils.ts +0 -11
  182. package/src/airdrop/contracts/ton/v3/utils/index.ts +0 -3
  183. package/src/airdrop/contracts/ton/v3/utils/ton.utils.ts +0 -84
  184. package/src/airdrop/contracts/ton/v3/wrappers/Leaf.ts +0 -68
  185. package/src/airdrop/contracts/ton/v3/wrappers/MerkleTokenDistributor.ts +0 -316
  186. package/src/airdrop/contracts/ton/v3/wrappers/index.ts +0 -2
  187. package/src/airdrop/index.ts +0 -10
  188. package/src/airdrop/services/index.ts +0 -159
  189. package/src/airdrop/services/wallet-service/ton/WalletService.ts +0 -226
  190. package/src/airdrop/services/wallet-service/ton/index.ts +0 -1
  191. package/src/airdrop/strategies/AirdropStrategyFactory.ts +0 -31
  192. package/src/airdrop/strategies/EvmAirdropStrategy.ts +0 -81
  193. package/src/airdrop/strategies/IAirdropStrategy.ts +0 -26
  194. package/src/airdrop/strategies/StrategyCache.ts +0 -34
  195. package/src/airdrop/strategies/TonAirdropStrategy.ts +0 -77
  196. package/src/airdrop/tests/index.test.ts +0 -387
  197. package/src/airdrop/types/index.ts +0 -199
  198. package/src/index.ts +0 -3
  199. package/src/utils/api-client.ts +0 -69
  200. package/src/utils/index.ts +0 -3
  201. package/src/utils/utils.ts +0 -45
  202. package/src/utils/web3.ts +0 -172
  203. package/src/wallets/WalletBase.ts +0 -92
  204. package/src/wallets/WalletFactory.tsx +0 -35
  205. package/src/wallets/index.ts +0 -3
  206. package/src/wallets/providers/evm/EvmWallet.ts +0 -101
  207. package/src/wallets/providers/evm/index.tsx +0 -56
  208. package/src/wallets/providers/index.ts +0 -4
  209. package/src/wallets/providers/solana/index.tsx +0 -133
  210. package/src/wallets/providers/ton/TonWallet.ts +0 -153
  211. package/src/wallets/providers/ton/index.tsx +0 -41
  212. package/src/wallets/types.ts +0 -45
  213. package/src/wallets/utils/index.ts +0 -61
@@ -1,199 +0,0 @@
1
- import { TonConnectUI as TonWalletClient } from '@tonconnect/ui-react';
2
- import { AirdropService as TonAirdropService } from '../contracts/ton/AirdropService';
3
- import { AirdropService as EvmAirdropService } from '../contracts/evm/AirdropService';
4
- import { ChainConfig } from '../constants';
5
- import { WalletClient as ViemWalletClient } from 'viem';
6
- import { WalletContextState as SolanaWalletState } from '@solana/wallet-adapter-react';
7
-
8
- export type ChainId = keyof typeof ChainConfig;
9
-
10
- export interface EvmContractClientOption {
11
- chainId: ChainId;
12
- walletClient?: ViemWalletClient;
13
- contractAddress: string;
14
- abi?: any;
15
- }
16
-
17
- export enum ChainType {
18
- Evm = 'evm',
19
- Ton = 'ton',
20
- Solana = 'solana'
21
- }
22
-
23
- export type ThemeConfig = {
24
- logo?: string;
25
- title?: string;
26
- description?: string;
27
- coverImage?: string;
28
- subTitle?: string;
29
- primaryColor?: string;
30
- secondaryColor?: string;
31
- buttonPrimaryHover?: string;
32
- buttonSecondaryHover?: string;
33
- buttonPrimaryForeground?: string;
34
- buttonSecondaryForeground?: string;
35
- welcomeModalText?: string;
36
- welcomeModalTitle?: string;
37
- isShowWelcomeModal?: boolean;
38
- blockCountries?: string;
39
- termsOfUse?: string;
40
- successModalPrimaryBtnText?: string;
41
- successModalUrl?: string;
42
- successModalTitle?: string;
43
- successModalDesc?: string;
44
- successModalShareTexts?: string;
45
- isUnAvailable?: boolean;
46
- privacyPolicy?: string;
47
- };
48
-
49
- export interface IProject {
50
- id: string;
51
- name: string;
52
- chainId: string;
53
- chainType: ChainType;
54
- tokenAddress: string;
55
- tokenType: string;
56
- startTime: number;
57
- endTime: number;
58
- contractAddress: string;
59
- recipientType: string;
60
- merkleRoot: string;
61
- ownerAddress: string;
62
- blockCountries: Record<string, string>;
63
- themeConf: ThemeConfig | null;
64
- version: string;
65
- extra?: IProjectExtra;
66
- identities: Identity[];
67
- projectTag: string;
68
- }
69
-
70
- export interface Identity {
71
- identityType: string;
72
- authorizeUrl?: string;
73
- }
74
-
75
- export enum AirdropSigIdentityTypeEnum {
76
- Twitter = 'X Account',
77
- SolanaWallet = 'Solana Wallet',
78
- EVMWallet = 'EVM Wallet',
79
- TONWallet = 'TON Wallet'
80
- }
81
-
82
- export interface IProjectExtra {
83
- kyc: boolean;
84
- tag: string;
85
- seed: number;
86
- signer: string;
87
- identities: string[];
88
- }
89
-
90
- export enum ETokenType {
91
- Erc20 = 'ERC20',
92
- Native = 'NATIVE_TOKEN',
93
- NFT = 'ERC721'
94
- }
95
-
96
- export type IAirdropClaim = {
97
- index: number;
98
- recipient: string;
99
- proof: string[];
100
- amount: string;
101
- unlockingAt: number;
102
- group: string;
103
- data: string;
104
- leaf: string;
105
- claimed?: boolean;
106
-
107
- claimId?: string;
108
-
109
- // ton
110
- claimable?: boolean;
111
- proofHash: string;
112
- ownerAddress: string;
113
- proofBoc: string;
114
- expiryTimestamp: number;
115
- expired?: boolean;
116
- project: IProject;
117
- };
118
-
119
- export type IAirdropSignatureClaim = {
120
- percent: number;
121
- unlockingAt: number;
122
- claimDeadline: number;
123
- value: string;
124
- recipient: string;
125
- recipientType: string;
126
- claimId: string;
127
- data?: string;
128
- signature?: string;
129
- claimed?: boolean;
130
- note: string;
131
- };
132
-
133
- export interface IAirdropSignatureIdentity {
134
- type: AirdropSigIdentityTypeEnum;
135
- value: string;
136
- displayName: string;
137
- }
138
-
139
- export interface IAirdropData {
140
- claims: IAirdropClaim[];
141
- }
142
-
143
- export interface IAirdropSignatureData {
144
- claims: IAirdropSignatureClaim[];
145
- identities: IAirdropSignatureIdentity[];
146
- }
147
-
148
- export interface IClaimSignature {
149
- claimId: string;
150
- data: string;
151
- signature: string;
152
- hash: string;
153
- }
154
-
155
- export enum TonAirdropVersionEnum {
156
- V1 = '1.0.0',
157
- V2 = '2.0.0',
158
- LiteV1 = '11.0.0',
159
- NativeV1 = '21.0.0'
160
- }
161
-
162
- export enum EvmAirdropVersionEnum {
163
- V0 = '0.0.2', // 兼容btc减半 airdrop
164
- V3 = '0.3.0', // zeta 收费
165
- V4 = '0.4.0' // zeta kyc、kyc threshold
166
- }
167
-
168
- export type IWalletClient = TonWalletClient | ViemWalletClient | SolanaWalletState;
169
-
170
- export type { TonWalletClient, ViemWalletClient, SolanaWalletState };
171
- export type IAirdropService = TonAirdropService | EvmAirdropService;
172
-
173
- type BaseAirdropOptions = {
174
- endpoint?: string;
175
- project?: IProject;
176
- };
177
-
178
- type ProjectIdOptions = BaseAirdropOptions & {
179
- projectId: string;
180
- slug?: never;
181
- };
182
-
183
- type SlugOptions = BaseAirdropOptions & {
184
- slug: string;
185
- projectId?: never;
186
- };
187
-
188
- export type IAirdropOptions = ProjectIdOptions | SlugOptions;
189
-
190
- export interface IContractConfig {
191
- version?: string | null;
192
- paused: boolean | null;
193
- claimFee?: string | null;
194
- }
195
-
196
- export enum ErrorCode {
197
- // 'Wallet already connected'
198
- WALLET_ALREADY_CONNECTED = 'Wallet already connected'
199
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export { AirdropClient, SignatureAirdropClient, CONST } from './airdrop';
2
- export { WalletFactory, EvmProvider, SolanaProvider, TonProvider } from './wallets';
3
- export * from './airdrop/types';
@@ -1,69 +0,0 @@
1
- export type ApiClientOptions = {
2
- baseURL?: string;
3
- };
4
-
5
- export type ApiRequestOptions = {
6
- params?: Record<string, string | number>;
7
- skipHandleError?: boolean;
8
- headers?: Record<string, string>;
9
- };
10
-
11
- type ApiResponse = {
12
- message: string;
13
- statusCode: number;
14
- data: unknown;
15
- success: boolean;
16
- };
17
-
18
- export class ApiClient {
19
- constructor(private options?: ApiClientOptions) {}
20
-
21
- extend(options: ApiClientOptions): ApiClient {
22
- return new ApiClient({
23
- ...this.options,
24
- ...options
25
- });
26
- }
27
-
28
- async get<TRes>(url: string, options?: ApiRequestOptions): Promise<TRes> {
29
- return this.request('GET', url, null, options) as TRes;
30
- }
31
-
32
- async post<TRes, TReq = unknown>(url: string, data?: TReq, options?: ApiRequestOptions): Promise<TRes> {
33
- return this.request('POST', url, data, options) as TRes;
34
- }
35
-
36
- async put<TRes, TReq = unknown>(url: string, data?: TReq, options?: ApiRequestOptions): Promise<TRes> {
37
- return this.request('PUT', url, data, options) as TRes;
38
- }
39
-
40
- async delete<TRes>(url: string, options?: ApiRequestOptions): Promise<TRes> {
41
- return this.request('DELETE', url, null, options) as TRes;
42
- }
43
-
44
- private async request(
45
- method: 'GET' | 'POST' | 'PUT' | 'DELETE',
46
- url: string,
47
- data: unknown,
48
- options?: ApiRequestOptions
49
- ): Promise<unknown> {
50
- const finalUrl = (this.options?.baseURL || '') + url;
51
-
52
- const init: RequestInit = { method, headers: options?.headers || {} };
53
- if (data instanceof FormData) {
54
- init.body = data;
55
- } else {
56
- init.headers = { 'content-type': 'application/json', ...init.headers };
57
- init.body = data ? JSON.stringify(data) : void 0;
58
- }
59
-
60
- const res = await fetch(finalUrl, init);
61
- const [status, resData]: [number, ApiResponse] = await Promise.all([res.status, res.json() as any]);
62
- if ((status < 200 && status >= 300) || resData?.success !== true) {
63
- return Promise.reject(resData);
64
- }
65
- return resData.data;
66
- }
67
- }
68
-
69
- export const apiClient = new ApiClient({ baseURL: 'https://claim.tokentable.xyz/api' });
@@ -1,3 +0,0 @@
1
- export * from './web3';
2
- export * from './utils';
3
- export * from './api-client';
@@ -1,45 +0,0 @@
1
- import dayjs from 'dayjs';
2
-
3
- export const safeParseJSON = (str: string): any => {
4
- try {
5
- return JSON.parse(str);
6
- } catch (error) {
7
- return {};
8
- }
9
- };
10
-
11
- export const isBeforeByUnix = (unix: number) => {
12
- return dayjs(new Date()).isBefore(dayjs.unix(unix), 'millisecond');
13
- };
14
-
15
- export const delay = (ms: number): Promise<unknown> => new Promise((res) => setTimeout(res, ms));
16
-
17
- export async function retry<T>(fn: () => Promise<T>, options: { retries: number; delay: number }): Promise<T> {
18
- let lastError: Error | undefined;
19
- for (let i = 0; i < options.retries; i++) {
20
- try {
21
- return await fn();
22
- } catch (e) {
23
- if (e instanceof Error) {
24
- lastError = e;
25
- }
26
- await new Promise((resolve) => setTimeout(resolve, options.delay));
27
- }
28
- }
29
- throw lastError;
30
- }
31
-
32
- export const isMobile = () => {
33
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
34
- };
35
-
36
- export const cleanUrlParams = (paramsToRemove: string[]) => {
37
- if (typeof window !== 'undefined') {
38
- const url = new URL(window.location.href);
39
- paramsToRemove.forEach((param) => {
40
- url.searchParams.delete(param);
41
- });
42
-
43
- window.history.replaceState({}, document.title, url.toString());
44
- }
45
- };
package/src/utils/web3.ts DELETED
@@ -1,172 +0,0 @@
1
- import TonWeb from 'tonweb';
2
- import {
3
- ASSOCIATED_TOKEN_PROGRAM_ID,
4
- getAssociatedTokenAddress,
5
- getAccount,
6
- createAssociatedTokenAccountInstruction,
7
- TokenAccountNotFoundError,
8
- TokenInvalidAccountOwnerError,
9
- TokenInvalidMintError,
10
- TokenInvalidOwnerError,
11
- TOKEN_PROGRAM_ID,
12
- TOKEN_2022_PROGRAM_ID
13
- } from '@solana/spl-token';
14
- import {
15
- Cluster,
16
- clusterApiUrl,
17
- Commitment,
18
- Connection,
19
- ParsedAccountData,
20
- PublicKey,
21
- Transaction
22
- } from '@solana/web3.js';
23
-
24
- export function flipAddressType(address: string) {
25
- if (!address) return '';
26
- return address.includes(':')
27
- ? new TonWeb.utils.Address(address).toString(true, true, true)
28
- : new TonWeb.utils.Address(address).toString(false, false, true);
29
- }
30
-
31
- export function hexStrToU8Array(hexStr: string): number[] {
32
- // 移除 "0x" 前缀(如果存在)
33
- hexStr = hexStr.startsWith('0x') ? hexStr.slice(2) : hexStr;
34
-
35
- // 确保 hexStr 长度正确(64 个字符,即 32 字节)
36
- // if (hexStr.length !== 64) {
37
- // throw new Error('Invalid hex string length. Expected 64 characters (32 bytes).');
38
- // }
39
-
40
- // 将 16 进制字符串转换为 Uint8Array
41
- const bytes = [];
42
- for (let i = 0; i < hexStr.length / 2; i++) {
43
- bytes[i] = parseInt(hexStr.substring(i * 2, i * 2 + 2), 16);
44
- }
45
-
46
- return bytes;
47
- }
48
-
49
- export async function getOrCreateAssociatedTokenAccount({
50
- connection,
51
- payer,
52
- mint,
53
- owner,
54
- signTransaction,
55
- allowOwnerOffCurve = false,
56
- commitment,
57
- programId = TOKEN_PROGRAM_ID,
58
- associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID
59
- }: {
60
- connection: Connection;
61
- payer: PublicKey;
62
- mint: PublicKey;
63
- owner: PublicKey;
64
- allowOwnerOffCurve?: boolean;
65
- commitment?: Commitment;
66
- programId?: PublicKey;
67
- associatedTokenProgramId?: PublicKey;
68
- signTransaction: (signature: Transaction) => Promise<Transaction>;
69
- }) {
70
- const associatedToken = await getAssociatedTokenAddress(
71
- mint,
72
- owner,
73
- allowOwnerOffCurve,
74
- programId,
75
- associatedTokenProgramId
76
- );
77
- // This is the optimal logic, considering TX fee, client-side computation, RPC roundtrips and guaranteed idempotent.
78
- // Sadly we can't do this atomically.
79
- let account;
80
- try {
81
- account = await getAccount(connection, associatedToken, commitment, programId);
82
- } catch (error) {
83
- // TokenAccountNotFoundError can be possible if the associated address has already received some lamports,
84
- // becoming a system account. Assuming program derived addressing is safe, this is the only case for the
85
- // TokenInvalidAccountOwnerError in this code path.
86
- if (error instanceof TokenAccountNotFoundError || error instanceof TokenInvalidAccountOwnerError) {
87
- // As this isn't atomic, it's possible others can create associated accounts meanwhile.
88
- try {
89
- const transaction = new Transaction().add(
90
- createAssociatedTokenAccountInstruction(
91
- payer,
92
- associatedToken,
93
- owner,
94
- mint,
95
- programId,
96
- associatedTokenProgramId
97
- )
98
- );
99
- const blockHash = await connection.getRecentBlockhash();
100
- transaction.feePayer = await payer;
101
- transaction.recentBlockhash = await blockHash.blockhash;
102
- const signed = await signTransaction(transaction);
103
-
104
- const signature = await connection.sendRawTransaction(signed.serialize());
105
-
106
- await connection.confirmTransaction(signature);
107
- } catch (error) {
108
- console.log(error);
109
- // Ignore all errors; for now there is no API-compatible way to selectively ignore the expected
110
- // instruction error if the associated account exists already.
111
- }
112
- // Now this should always succeed
113
- account = await getAccount(connection, associatedToken, commitment, programId);
114
- } else {
115
- throw error;
116
- }
117
- }
118
- if (!account.mint.equals(mint)) throw new TokenInvalidMintError();
119
- if (!account.owner.equals(owner)) throw new TokenInvalidOwnerError();
120
- return account;
121
- }
122
-
123
- export enum SplTokenVersion {
124
- SplToken = 'spl-token',
125
- SplToken2022 = 'spl-token-2022'
126
- }
127
-
128
- export type FetchTokenVersionOptions = {
129
- clusterOrEndpoint?: Cluster | string;
130
- };
131
-
132
- export type FetchTokenMetadataOptions = FetchTokenVersionOptions & {
133
- fetchOffchainMetadata?: boolean;
134
- };
135
-
136
- async function _getTokenProgramAndParsedAccountData(conn: Connection, tokenAddress: string) {
137
- const tokenMintAddress = new PublicKey(tokenAddress);
138
- const parsedMintAccountInfo = await conn.getParsedAccountInfo(tokenMintAddress);
139
- const parsedMintAccountData = parsedMintAccountInfo.value?.data as ParsedAccountData;
140
- if (parsedMintAccountData?.program === SplTokenVersion.SplToken) {
141
- return {
142
- name: SplTokenVersion.SplToken,
143
- programId: TOKEN_PROGRAM_ID,
144
- parsedMintAccountData
145
- };
146
- } else if (parsedMintAccountData?.program === SplTokenVersion.SplToken2022) {
147
- return {
148
- name: SplTokenVersion.SplToken2022,
149
- programId: TOKEN_2022_PROGRAM_ID,
150
- parsedMintAccountData
151
- };
152
- }
153
- return null;
154
- }
155
-
156
- function _getConnection(clusterOrEndpoint: Cluster | string) {
157
- let endpoint: string;
158
- try {
159
- endpoint = clusterApiUrl((clusterOrEndpoint as Cluster) ?? 'mainnet-beta');
160
- } catch {
161
- endpoint = clusterOrEndpoint as string;
162
- }
163
-
164
- const conn = new Connection(endpoint);
165
- return conn;
166
- }
167
-
168
- export async function fetchTokenVersion(tokenAddress: string, options: FetchTokenMetadataOptions) {
169
- const conn = _getConnection(options.clusterOrEndpoint!);
170
- const data = await _getTokenProgramAndParsedAccountData(conn, tokenAddress);
171
- return data ? { name: data.name, programId: data.programId } : null;
172
- }
@@ -1,92 +0,0 @@
1
- import { ISignResult } from './types';
2
- import { prepareSignMessage } from './utils';
3
-
4
- export abstract class WalletBase<S> {
5
- type: string;
6
- provider: any;
7
- address?: string;
8
- publicKey?: string;
9
- chainId?: number | string;
10
- protocolTag?: string;
11
- authType: string;
12
- userAddress?: string;
13
- network?: string;
14
-
15
- constructor(type: string, userAddress?: string) {
16
- this.type = type;
17
- this.provider = null;
18
- this.address = '';
19
- this.chainId = 1;
20
- this.authType = '';
21
- this.userAddress = userAddress || '';
22
- // this.init();
23
- }
24
-
25
- // abstract init(): void;
26
-
27
- // abstract init(): void;
28
- protected get isConnected(): boolean {
29
- throw new Error('Not implemented');
30
- }
31
-
32
- abstract connect(_?: string): void;
33
-
34
- // common sign
35
- abstract sign(_: string, _1?: string): Promise<ISignResult>;
36
-
37
- // checkAddressValidity(): boolean {
38
- // console.log(this.userAddress, this.address);
39
- // if (!this.address) {
40
- // // 兼容ton的情况,ton只有sign之后才有地址
41
- // return true;
42
- // }
43
- // if (this.userAddress && this.address !== this.userAddress) {
44
- // console.error('Wallet address and user address do not match.');
45
- // globalVm.toggleAccountChangedModal(true);
46
- // return false;
47
- // }
48
- // return true;
49
- // }
50
-
51
- async safeSign(_: string, _1?: string): Promise<ISignResult> {
52
- // if (!this.checkAddressValidity()) {
53
- // throw new Error('Wallet address and user address do not match.');
54
- // }
55
- return this.sign(_, _1);
56
- }
57
-
58
- async signin(statement?: string): Promise<ISignResult> {
59
- const msgRes = prepareSignMessage({ statement, chainId: this.chainId!, address: this.address! });
60
- return this.sign(JSON.stringify(msgRes, null, ' '));
61
- }
62
-
63
- // for metamask sign of EIP-712
64
- signByEIP712(_: string): Promise<ISignResult> {
65
- throw new Error(`received message:${_},Method not implemented.`);
66
- }
67
-
68
- getSignEIP712Message(_: { chainId: number | string; info: string; hash: string }): string {
69
- throw new Error(`received message:${JSON.stringify(_)},Method not implemented.`);
70
- }
71
-
72
- getWallet(): {
73
- address?: string;
74
- isConnected: boolean;
75
- publicKey: string | undefined;
76
- type: string;
77
- network: string | undefined;
78
- } {
79
- // 获取钱包信息
80
- return {
81
- type: this.type,
82
- isConnected: this.isConnected,
83
- address: this.address,
84
- publicKey: this.publicKey,
85
- network: this.network
86
- };
87
- }
88
-
89
- abstract getStore(): S;
90
-
91
- // abstract decrypt(message: string, address: string): Promise<string>;
92
- }
@@ -1,35 +0,0 @@
1
- import { EvmWallet } from './providers/evm';
2
- import { ChainType } from './types';
3
- import { TonWallet } from './providers/ton';
4
- import { SolWallet } from './providers/solana';
5
-
6
- export abstract class WalletFactory {
7
- private static instances: Record<string, EvmWallet | TonWallet | SolWallet> = {};
8
- static getWallet(type: ChainType, userAddress?: string): EvmWallet | TonWallet | SolWallet {
9
- if (!this.instances[type]) {
10
- let WalletClass;
11
- switch (type) {
12
- case ChainType.Evm:
13
- WalletClass = EvmWallet;
14
- break;
15
- case ChainType.Ton:
16
- WalletClass = TonWallet;
17
- break;
18
- // case ChainType.Starknet:
19
- // WalletClass = StarknetWallet;
20
- // break;
21
- case ChainType.Solana:
22
- WalletClass = SolWallet;
23
- break;
24
- default:
25
- throw new Error('Unsupported wallet type');
26
- }
27
-
28
- if (!WalletClass) {
29
- throw new Error('Unsupported wallet type');
30
- }
31
- this.instances[type] = new WalletClass(type, userAddress);
32
- }
33
- return this.instances[type];
34
- }
35
- }
@@ -1,3 +0,0 @@
1
- export { WalletFactory } from './WalletFactory';
2
-
3
- export * from './providers';