@sign-global/tokentable 0.4.0-beta.1 → 0.4.0-beta.10
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/README.md +98 -2
- package/dist/cjs/airdrop/AirdropClient.js +9 -2
- package/dist/cjs/airdrop/AirdropClient.js.map +1 -1
- package/dist/cjs/airdrop/SignatureAirdropClient.d.ts +22 -9
- package/dist/cjs/airdrop/SignatureAirdropClient.js +95 -19
- package/dist/cjs/airdrop/SignatureAirdropClient.js.map +1 -1
- package/dist/cjs/airdrop/core/evm/SignatureAirdropService.d.ts +23 -0
- package/dist/cjs/airdrop/core/evm/SignatureAirdropService.js +71 -0
- package/dist/cjs/airdrop/core/evm/SignatureAirdropService.js.map +1 -0
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.d.ts +16 -0
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.js +47 -0
- package/dist/cjs/airdrop/core/evm/contracts/AirdropSignatureClient.js.map +1 -0
- package/dist/cjs/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +564 -0
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +6 -3
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +2 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +6 -4
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +10 -11
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +1 -1
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +10 -9
- package/dist/cjs/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -1
- package/dist/cjs/airdrop/services/index.d.ts +25 -8
- package/dist/cjs/airdrop/services/index.js +34 -5
- package/dist/cjs/airdrop/services/index.js.map +1 -1
- package/dist/cjs/airdrop/types/index.d.ts +27 -0
- package/dist/cjs/airdrop/types/index.js.map +1 -1
- package/dist/cjs/utils/api-client.d.ts +1 -0
- package/dist/cjs/utils/api-client.js +2 -2
- package/dist/cjs/utils/api-client.js.map +1 -1
- package/dist/esm/airdrop/AirdropClient.js +9 -2
- package/dist/esm/airdrop/AirdropClient.js.map +1 -1
- package/dist/esm/airdrop/SignatureAirdropClient.d.ts +22 -9
- package/dist/esm/airdrop/SignatureAirdropClient.js +96 -20
- package/dist/esm/airdrop/SignatureAirdropClient.js.map +1 -1
- package/dist/esm/airdrop/core/evm/SignatureAirdropService.d.ts +23 -0
- package/dist/esm/airdrop/core/evm/SignatureAirdropService.js +67 -0
- package/dist/esm/airdrop/core/evm/SignatureAirdropService.js.map +1 -0
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.d.ts +16 -0
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.js +40 -0
- package/dist/esm/airdrop/core/evm/contracts/AirdropSignatureClient.js.map +1 -0
- package/dist/esm/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +564 -0
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.d.ts +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js +6 -3
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.js.map +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.d.ts +2 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js +7 -5
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/evm/index.js.map +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.d.ts +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js +11 -12
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/solana/index.js.map +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.d.ts +1 -1
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js +10 -9
- package/dist/esm/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.js.map +1 -1
- package/dist/esm/airdrop/services/index.d.ts +25 -8
- package/dist/esm/airdrop/services/index.js +31 -4
- package/dist/esm/airdrop/services/index.js.map +1 -1
- package/dist/esm/airdrop/types/index.d.ts +27 -0
- package/dist/esm/airdrop/types/index.js.map +1 -1
- package/dist/esm/utils/api-client.d.ts +1 -0
- package/dist/esm/utils/api-client.js +2 -2
- package/dist/esm/utils/api-client.js.map +1 -1
- package/package.json +3 -3
- package/src/airdrop/AirdropClient.ts +8 -2
- package/src/airdrop/SignatureAirdropClient.ts +155 -27
- package/src/airdrop/core/evm/SignatureAirdropService.ts +90 -0
- package/src/airdrop/core/evm/contracts/AirdropSignatureClient.ts +56 -0
- package/src/airdrop/core/evm/contracts/abis/FungibleTokenECDSADistributor.json +564 -0
- package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/EvmWallet.ts +6 -3
- package/src/airdrop/core/useWeb3ConnectWallet/providers/evm/index.tsx +18 -5
- package/src/airdrop/core/useWeb3ConnectWallet/providers/solana/index.tsx +11 -14
- package/src/airdrop/core/useWeb3ConnectWallet/providers/ton/TonWallet.ts +16 -12
- package/src/airdrop/services/index.ts +75 -14
- package/src/airdrop/types/index.ts +31 -1
- package/src/utils/api-client.ts +3 -2
|
@@ -57,11 +57,11 @@ export class TonWallet extends WalletBase<TonStoreType> {
|
|
|
57
57
|
|
|
58
58
|
async sign(originMsg: string): Promise<ISignResult> {
|
|
59
59
|
const message = await hashSha256(originMsg);
|
|
60
|
-
const tonConnectUI = tonStore.walletClient as
|
|
60
|
+
const tonConnectUI = tonStore.walletClient as any;
|
|
61
61
|
// const walletInfo = tonConnectUI?.wallet;
|
|
62
62
|
const authType = '';
|
|
63
63
|
// if (walletInfo?.jsBridgeKey && walletInfo?.openMethod !== 'qrcode') {
|
|
64
|
-
// authType = walletInfo.jsBridgeKey;
|
|
64
|
+
// authType = walletInfo.jsBridgeKey;
|
|
65
65
|
// }
|
|
66
66
|
|
|
67
67
|
console.log(this.isConnected, tonConnectUI, 'connected');
|
|
@@ -72,12 +72,10 @@ export class TonWallet extends WalletBase<TonStoreType> {
|
|
|
72
72
|
if (authType) {
|
|
73
73
|
const wallets = await tonConnectUI.getWallets();
|
|
74
74
|
|
|
75
|
-
const currentWallet = wallets.find((wallet) =>
|
|
75
|
+
const currentWallet = wallets.find((wallet: any) =>
|
|
76
76
|
[wallet.name, wallet.appName].includes(authType)
|
|
77
77
|
) as WalletInfoRemote;
|
|
78
78
|
|
|
79
|
-
console.log(wallets, currentWallet, 'ww');
|
|
80
|
-
|
|
81
79
|
const link = tonConnectUI.connector.connect(
|
|
82
80
|
{
|
|
83
81
|
bridgeUrl: currentWallet.bridgeUrl,
|
|
@@ -133,13 +131,19 @@ export class TonWallet extends WalletBase<TonStoreType> {
|
|
|
133
131
|
};
|
|
134
132
|
}
|
|
135
133
|
|
|
136
|
-
override async signin(statement
|
|
137
|
-
const fullMessage =
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
override async signin(statement: string, prepare = true): Promise<ISignResult> {
|
|
135
|
+
const fullMessage = prepare
|
|
136
|
+
? JSON.stringify(
|
|
137
|
+
{
|
|
138
|
+
statement: statement || 'Welcome to EthSign',
|
|
139
|
+
issuedAt: new Date().toISOString(),
|
|
140
|
+
nonce: getCustomNaNoId()
|
|
141
|
+
},
|
|
142
|
+
null,
|
|
143
|
+
' '
|
|
144
|
+
)
|
|
145
|
+
: statement;
|
|
146
|
+
const signRes = await this.sign(fullMessage);
|
|
143
147
|
return signRes;
|
|
144
148
|
}
|
|
145
149
|
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { apiClient } from '../../utils/api-client';
|
|
2
2
|
import { safeParseJSON } from '../../utils/utils';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AirdropSigIdentityTypeEnum,
|
|
5
|
+
IAirdropData,
|
|
6
|
+
IAirdropSignatureData,
|
|
7
|
+
IClaimSignature,
|
|
8
|
+
IContractConfig,
|
|
9
|
+
IProject
|
|
10
|
+
} from '../types';
|
|
4
11
|
|
|
5
12
|
export { TonWalletService } from './wallet-service/ton';
|
|
6
13
|
|
|
@@ -11,7 +18,7 @@ const createApiClient = (baseURL?: string) => {
|
|
|
11
18
|
export const getAirdropProject = async (projectId: string, baseURL?: string): Promise<IProject> => {
|
|
12
19
|
const client = createApiClient(baseURL);
|
|
13
20
|
const res = await client.get<any>(`/airdrop-open/projects/${projectId}`);
|
|
14
|
-
if (!res) return res; // res
|
|
21
|
+
if (!res) return res; // res is null
|
|
15
22
|
const projectConfig = res?.themeConf;
|
|
16
23
|
const blockCountries = safeParseJSON(projectConfig?.blockCountries);
|
|
17
24
|
return {
|
|
@@ -70,27 +77,81 @@ export const getJettonInfo = async (
|
|
|
70
77
|
return client.get(`/airdrop-open/jetton/${data.address}?isTestnet=${data.isTestnet}`);
|
|
71
78
|
};
|
|
72
79
|
|
|
73
|
-
|
|
80
|
+
interface SidResponse {
|
|
81
|
+
sid: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface TwitterConnectParams {
|
|
85
|
+
code: string;
|
|
86
|
+
projectId: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface WalletBindParams {
|
|
90
|
+
projectId: string;
|
|
91
|
+
key: string;
|
|
92
|
+
signature: string;
|
|
93
|
+
message: string;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
recipientType: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const getSidHeader = (projectId: string) => ({
|
|
99
|
+
sid: window.localStorage.getItem(`sid_${projectId}`) || ''
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export const connectTwitter = async (data: TwitterConnectParams, baseURL?: string): Promise<SidResponse> => {
|
|
103
|
+
const client = createApiClient(baseURL);
|
|
104
|
+
return client.post('/airdrop-open/connect-twitter', data, {
|
|
105
|
+
headers: getSidHeader(data.projectId)
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const checkEligibility = async (
|
|
110
|
+
data: { projectId: string },
|
|
111
|
+
baseURL?: string
|
|
112
|
+
): Promise<IAirdropSignatureData> => {
|
|
113
|
+
const headers = getSidHeader(data.projectId);
|
|
114
|
+
if (!headers.sid)
|
|
115
|
+
return {
|
|
116
|
+
claims: [],
|
|
117
|
+
identities: []
|
|
118
|
+
};
|
|
74
119
|
const client = createApiClient(baseURL);
|
|
75
|
-
|
|
120
|
+
|
|
121
|
+
return client.post('/airdrop-open/check-eligibility', data, {
|
|
122
|
+
headers: headers
|
|
123
|
+
});
|
|
76
124
|
};
|
|
77
125
|
|
|
78
|
-
export const
|
|
126
|
+
export const bindWallet = async (data: WalletBindParams, baseURL?: string): Promise<SidResponse> => {
|
|
79
127
|
const client = createApiClient(baseURL);
|
|
80
|
-
return client.post('/airdrop-open/
|
|
128
|
+
return client.post('/airdrop-open/connect-wallet', data, {
|
|
129
|
+
headers: getSidHeader(data.projectId)
|
|
130
|
+
});
|
|
81
131
|
};
|
|
82
132
|
|
|
83
|
-
|
|
133
|
+
interface DisconnectParams {
|
|
134
|
+
projectId: string;
|
|
135
|
+
recipientType: AirdropSigIdentityTypeEnum;
|
|
136
|
+
recipient?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const disconnectRecipient = async (data: DisconnectParams, baseURL?: string): Promise<void> => {
|
|
140
|
+
const client = createApiClient(baseURL);
|
|
141
|
+
return client.post('/airdrop-open/disconnect', data, {
|
|
142
|
+
headers: getSidHeader(data.projectId)
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const checkGetSignatures = async (
|
|
84
147
|
data: {
|
|
85
148
|
projectId: string;
|
|
86
|
-
|
|
87
|
-
signature: string;
|
|
88
|
-
message: string;
|
|
89
|
-
timestamp: number;
|
|
90
|
-
recipientType: string;
|
|
149
|
+
claimIds: string[];
|
|
91
150
|
},
|
|
92
151
|
baseURL?: string
|
|
93
|
-
) => {
|
|
152
|
+
): Promise<{ signatures: IClaimSignature[] }> => {
|
|
94
153
|
const client = createApiClient(baseURL);
|
|
95
|
-
return client.post('/airdrop-open/
|
|
154
|
+
return client.post('/airdrop-open/check-get-signatures', data, {
|
|
155
|
+
headers: getSidHeader(data.projectId)
|
|
156
|
+
});
|
|
96
157
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TonConnectUI } from '@tonconnect/ui-react';
|
|
2
2
|
import { AirdropService as TonAirdropService } from '../core/ton/AirdropService';
|
|
3
3
|
import { AirdropService as EvmAirdropService } from '../core/evm/AirdropService';
|
|
4
|
-
import { TonClient } from '@ton/ton';
|
|
5
4
|
import { ChainConfig } from '../constants';
|
|
6
5
|
import { WalletClient as ViemWalletClient } from 'viem';
|
|
7
6
|
|
|
@@ -63,6 +62,7 @@ export interface IProject {
|
|
|
63
62
|
version: string;
|
|
64
63
|
extra?: IProjectExtra;
|
|
65
64
|
identities: Identity[];
|
|
65
|
+
projectTag: string;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export interface Identity {
|
|
@@ -113,10 +113,39 @@ export type IAirdropClaim = {
|
|
|
113
113
|
project: IProject;
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
+
export type IAirdropSignatureClaim = {
|
|
117
|
+
percent: number;
|
|
118
|
+
unlockingAt: number;
|
|
119
|
+
claimDeadline: number;
|
|
120
|
+
value: string;
|
|
121
|
+
recipient: string;
|
|
122
|
+
recipientType: string;
|
|
123
|
+
claimId: string;
|
|
124
|
+
data?: string;
|
|
125
|
+
signature?: string;
|
|
126
|
+
claimed?: boolean;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export interface IAirdropSignatureIdentity {
|
|
130
|
+
type: AirdropSigIdentityTypeEnum;
|
|
131
|
+
value: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
116
134
|
export interface IAirdropData {
|
|
117
135
|
claims: IAirdropClaim[];
|
|
118
136
|
}
|
|
119
137
|
|
|
138
|
+
export interface IAirdropSignatureData {
|
|
139
|
+
claims: IAirdropSignatureClaim[];
|
|
140
|
+
identities: IAirdropSignatureIdentity[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface IClaimSignature {
|
|
144
|
+
claimId: string;
|
|
145
|
+
data: string;
|
|
146
|
+
signature: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
120
149
|
export enum TonAirdropVersionEnum {
|
|
121
150
|
V1 = '1.0.0',
|
|
122
151
|
V2 = '2.0.0',
|
|
@@ -136,6 +165,7 @@ export type IAirdropService = TonAirdropService | EvmAirdropService;
|
|
|
136
165
|
|
|
137
166
|
type BaseAirdropOptions = {
|
|
138
167
|
endpoint?: string;
|
|
168
|
+
project?: IProject;
|
|
139
169
|
};
|
|
140
170
|
|
|
141
171
|
type ProjectIdOptions = BaseAirdropOptions & {
|
package/src/utils/api-client.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type ApiClientOptions = {
|
|
|
5
5
|
export type ApiRequestOptions = {
|
|
6
6
|
params?: Record<string, string | number>;
|
|
7
7
|
skipHandleError?: boolean;
|
|
8
|
+
headers?: Record<string, string>;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
type ApiResponse = {
|
|
@@ -48,11 +49,11 @@ export class ApiClient {
|
|
|
48
49
|
): Promise<unknown> {
|
|
49
50
|
const finalUrl = (this.options?.baseURL || '') + url;
|
|
50
51
|
|
|
51
|
-
const init: RequestInit = { method };
|
|
52
|
+
const init: RequestInit = { method, headers: options?.headers || {} };
|
|
52
53
|
if (data instanceof FormData) {
|
|
53
54
|
init.body = data;
|
|
54
55
|
} else {
|
|
55
|
-
init.headers = { 'content-type': 'application/json' };
|
|
56
|
+
init.headers = { 'content-type': 'application/json', ...init.headers };
|
|
56
57
|
init.body = data ? JSON.stringify(data) : void 0;
|
|
57
58
|
}
|
|
58
59
|
|