@sign-global/tokentable 0.4.1-beta.6 → 0.4.1-beta.8
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/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.d.ts +1 -1
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js +11 -6
- package/dist/cjs/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.d.ts +1 -5
- package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.js +0 -16
- package/dist/cjs/airdrop/contracts/solana/SignatureAirdropService.js.map +1 -1
- package/dist/cjs/airdrop/contracts/solana/SolanaContractClient.js +1 -1
- package/dist/cjs/airdrop/contracts/solana/fee_collector.d.ts +20 -71
- package/dist/cjs/airdrop/contracts/solana/fee_collector.json +20 -71
- package/dist/cjs/airdrop/contracts/solana/fungible_token_distributor_solana.d.ts +64 -77
- package/dist/cjs/airdrop/contracts/solana/fungible_token_distributor_solana.json +65 -78
- package/dist/cjs/utils/web3.d.ts +15 -1
- package/dist/cjs/utils/web3.js +43 -0
- package/dist/cjs/utils/web3.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.d.ts +1 -1
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js +12 -7
- package/dist/esm/airdrop/contracts/solana/AirdropSignatureClient.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.d.ts +1 -5
- package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.js +0 -16
- package/dist/esm/airdrop/contracts/solana/SignatureAirdropService.js.map +1 -1
- package/dist/esm/airdrop/contracts/solana/SolanaContractClient.js +1 -1
- package/dist/esm/airdrop/contracts/solana/fee_collector.d.ts +20 -71
- package/dist/esm/airdrop/contracts/solana/fee_collector.json +20 -71
- package/dist/esm/airdrop/contracts/solana/fungible_token_distributor_solana.d.ts +64 -77
- package/dist/esm/airdrop/contracts/solana/fungible_token_distributor_solana.json +65 -78
- package/dist/esm/utils/web3.d.ts +15 -1
- package/dist/esm/utils/web3.js +43 -2
- package/dist/esm/utils/web3.js.map +1 -1
- package/package.json +1 -1
- package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +14 -8
- package/src/airdrop/contracts/solana/SignatureAirdropService.ts +0 -20
- package/src/airdrop/contracts/solana/SolanaContractClient.ts +1 -1
- package/src/airdrop/contracts/solana/fee_collector.json +20 -71
- package/src/airdrop/contracts/solana/fee_collector.ts +20 -71
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +65 -78
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +65 -78
- package/src/utils/web3.ts +62 -2
|
@@ -86,41 +86,8 @@ export type FungibleTokenDistributorSolana = {
|
|
|
86
86
|
"path": "authority"
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
|
-
"kind": "
|
|
90
|
-
"
|
|
91
|
-
6,
|
|
92
|
-
221,
|
|
93
|
-
246,
|
|
94
|
-
225,
|
|
95
|
-
215,
|
|
96
|
-
101,
|
|
97
|
-
161,
|
|
98
|
-
147,
|
|
99
|
-
217,
|
|
100
|
-
203,
|
|
101
|
-
225,
|
|
102
|
-
70,
|
|
103
|
-
206,
|
|
104
|
-
235,
|
|
105
|
-
121,
|
|
106
|
-
172,
|
|
107
|
-
28,
|
|
108
|
-
180,
|
|
109
|
-
133,
|
|
110
|
-
237,
|
|
111
|
-
95,
|
|
112
|
-
91,
|
|
113
|
-
55,
|
|
114
|
-
145,
|
|
115
|
-
58,
|
|
116
|
-
140,
|
|
117
|
-
245,
|
|
118
|
-
133,
|
|
119
|
-
126,
|
|
120
|
-
255,
|
|
121
|
-
0,
|
|
122
|
-
169
|
|
123
|
-
]
|
|
89
|
+
"kind": "account",
|
|
90
|
+
"path": "tokenProgram"
|
|
124
91
|
},
|
|
125
92
|
{
|
|
126
93
|
"kind": "account",
|
|
@@ -547,6 +514,50 @@ export type FungibleTokenDistributorSolana = {
|
|
|
547
514
|
}
|
|
548
515
|
]
|
|
549
516
|
},
|
|
517
|
+
{
|
|
518
|
+
"name": "receiveProgramAdmin",
|
|
519
|
+
"discriminator": [
|
|
520
|
+
238,
|
|
521
|
+
172,
|
|
522
|
+
61,
|
|
523
|
+
197,
|
|
524
|
+
23,
|
|
525
|
+
72,
|
|
526
|
+
249,
|
|
527
|
+
87
|
|
528
|
+
],
|
|
529
|
+
"accounts": [
|
|
530
|
+
{
|
|
531
|
+
"name": "config",
|
|
532
|
+
"writable": true,
|
|
533
|
+
"pda": {
|
|
534
|
+
"seeds": [
|
|
535
|
+
{
|
|
536
|
+
"kind": "const",
|
|
537
|
+
"value": [
|
|
538
|
+
99,
|
|
539
|
+
111,
|
|
540
|
+
110,
|
|
541
|
+
102,
|
|
542
|
+
105,
|
|
543
|
+
103
|
|
544
|
+
]
|
|
545
|
+
}
|
|
546
|
+
]
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"name": "authority",
|
|
551
|
+
"writable": true,
|
|
552
|
+
"signer": true
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"name": "systemProgram",
|
|
556
|
+
"address": "11111111111111111111111111111111"
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
"args": []
|
|
560
|
+
},
|
|
550
561
|
{
|
|
551
562
|
"name": "setBaseParams",
|
|
552
563
|
"discriminator": [
|
|
@@ -883,11 +894,6 @@ export type FungibleTokenDistributorSolana = {
|
|
|
883
894
|
"writable": true,
|
|
884
895
|
"signer": true
|
|
885
896
|
},
|
|
886
|
-
{
|
|
887
|
-
"name": "newOwner",
|
|
888
|
-
"writable": true,
|
|
889
|
-
"signer": true
|
|
890
|
-
},
|
|
891
897
|
{
|
|
892
898
|
"name": "systemProgram",
|
|
893
899
|
"address": "11111111111111111111111111111111"
|
|
@@ -944,7 +950,8 @@ export type FungibleTokenDistributorSolana = {
|
|
|
944
950
|
{
|
|
945
951
|
"name": "newAdmin",
|
|
946
952
|
"writable": true,
|
|
947
|
-
"signer": true
|
|
953
|
+
"signer": true,
|
|
954
|
+
"optional": true
|
|
948
955
|
},
|
|
949
956
|
{
|
|
950
957
|
"name": "systemProgram",
|
|
@@ -1129,41 +1136,8 @@ export type FungibleTokenDistributorSolana = {
|
|
|
1129
1136
|
"path": "authority"
|
|
1130
1137
|
},
|
|
1131
1138
|
{
|
|
1132
|
-
"kind": "
|
|
1133
|
-
"
|
|
1134
|
-
6,
|
|
1135
|
-
221,
|
|
1136
|
-
246,
|
|
1137
|
-
225,
|
|
1138
|
-
215,
|
|
1139
|
-
101,
|
|
1140
|
-
161,
|
|
1141
|
-
147,
|
|
1142
|
-
217,
|
|
1143
|
-
203,
|
|
1144
|
-
225,
|
|
1145
|
-
70,
|
|
1146
|
-
206,
|
|
1147
|
-
235,
|
|
1148
|
-
121,
|
|
1149
|
-
172,
|
|
1150
|
-
28,
|
|
1151
|
-
180,
|
|
1152
|
-
133,
|
|
1153
|
-
237,
|
|
1154
|
-
95,
|
|
1155
|
-
91,
|
|
1156
|
-
55,
|
|
1157
|
-
145,
|
|
1158
|
-
58,
|
|
1159
|
-
140,
|
|
1160
|
-
245,
|
|
1161
|
-
133,
|
|
1162
|
-
126,
|
|
1163
|
-
255,
|
|
1164
|
-
0,
|
|
1165
|
-
169
|
|
1166
|
-
]
|
|
1139
|
+
"kind": "account",
|
|
1140
|
+
"path": "tokenProgram"
|
|
1167
1141
|
},
|
|
1168
1142
|
{
|
|
1169
1143
|
"kind": "account",
|
|
@@ -1401,16 +1375,21 @@ export type FungibleTokenDistributorSolana = {
|
|
|
1401
1375
|
},
|
|
1402
1376
|
{
|
|
1403
1377
|
"code": 6009,
|
|
1378
|
+
"name": "notPermissioned",
|
|
1379
|
+
"msg": "notPermissioned"
|
|
1380
|
+
},
|
|
1381
|
+
{
|
|
1382
|
+
"code": 6010,
|
|
1404
1383
|
"name": "ownableUnauthorizedAccount",
|
|
1405
1384
|
"msg": "ownableUnauthorizedAccount"
|
|
1406
1385
|
},
|
|
1407
1386
|
{
|
|
1408
|
-
"code":
|
|
1387
|
+
"code": 6011,
|
|
1409
1388
|
"name": "invalidFeeCollector",
|
|
1410
1389
|
"msg": "invalidFeeCollector"
|
|
1411
1390
|
},
|
|
1412
1391
|
{
|
|
1413
|
-
"code":
|
|
1392
|
+
"code": 6012,
|
|
1414
1393
|
"name": "paused",
|
|
1415
1394
|
"msg": "paused"
|
|
1416
1395
|
}
|
|
@@ -1517,6 +1496,10 @@ export type FungibleTokenDistributorSolana = {
|
|
|
1517
1496
|
{
|
|
1518
1497
|
"name": "admin",
|
|
1519
1498
|
"type": "pubkey"
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
"name": "newAdmin",
|
|
1502
|
+
"type": "pubkey"
|
|
1520
1503
|
}
|
|
1521
1504
|
]
|
|
1522
1505
|
}
|
|
@@ -1537,6 +1520,10 @@ export type FungibleTokenDistributorSolana = {
|
|
|
1537
1520
|
"name": "owner",
|
|
1538
1521
|
"type": "pubkey"
|
|
1539
1522
|
},
|
|
1523
|
+
{
|
|
1524
|
+
"name": "newOwner",
|
|
1525
|
+
"type": "pubkey"
|
|
1526
|
+
},
|
|
1540
1527
|
{
|
|
1541
1528
|
"name": "defaultFeesBips",
|
|
1542
1529
|
"type": "u64"
|
package/src/utils/web3.ts
CHANGED
|
@@ -8,9 +8,18 @@ import {
|
|
|
8
8
|
TokenInvalidAccountOwnerError,
|
|
9
9
|
TokenInvalidMintError,
|
|
10
10
|
TokenInvalidOwnerError,
|
|
11
|
-
TOKEN_PROGRAM_ID
|
|
11
|
+
TOKEN_PROGRAM_ID,
|
|
12
|
+
TOKEN_2022_PROGRAM_ID
|
|
12
13
|
} from '@solana/spl-token';
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Cluster,
|
|
16
|
+
clusterApiUrl,
|
|
17
|
+
Commitment,
|
|
18
|
+
Connection,
|
|
19
|
+
ParsedAccountData,
|
|
20
|
+
PublicKey,
|
|
21
|
+
Transaction
|
|
22
|
+
} from '@solana/web3.js';
|
|
14
23
|
|
|
15
24
|
export function flipAddressType(address: string) {
|
|
16
25
|
if (!address) return '';
|
|
@@ -110,3 +119,54 @@ export async function getOrCreateAssociatedTokenAccount({
|
|
|
110
119
|
if (!account.owner.equals(owner)) throw new TokenInvalidOwnerError();
|
|
111
120
|
return account;
|
|
112
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
|
+
}
|