@sign-global/tokentable-core 1.0.0 → 1.1.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.
- package/CHANGELOG.md +18 -0
- package/README.md +72 -0
- package/dist/index.d.mts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +32 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -2
- package/src/constants/chain-config.ts +2 -2
- package/src/contracts/evm/AirdropService.ts +18 -13
- package/src/services/airdrop/index.ts +3 -1
- package/src/test/setup.ts +24 -0
- package/src/types/index.ts +8 -2
- package/src/utils/__tests__/web3.test.ts +326 -0
- package/src/utils/api-client.ts +2 -2
- package/src/utils/utils.ts +8 -3
- package/vitest.config.ts +14 -0
package/dist/index.mjs
CHANGED
|
@@ -198,8 +198,8 @@ var ChainConfig = {
|
|
|
198
198
|
rpcUrl: "https://zetachain-mainnet.g.alchemy.com/v2/1tmk0FrhwTJHXh0XIyae7_SXw1lDCjgs"
|
|
199
199
|
},
|
|
200
200
|
[arbitrum.id]: {
|
|
201
|
-
contractAddress: "
|
|
202
|
-
rpcUrl:
|
|
201
|
+
contractAddress: "0xeD09c23677D02f4f486E55f0f081cfc114EEa53b",
|
|
202
|
+
rpcUrl: "https://arb-mainnet.g.alchemy.com/v2/udrqNPSB6i5n5L6QSM31Ng72h_hFOrVT"
|
|
203
203
|
},
|
|
204
204
|
[berachainTestnet.id]: {
|
|
205
205
|
contractAddress: "",
|
|
@@ -3835,11 +3835,16 @@ var getCustomNaNoId = () => {
|
|
|
3835
3835
|
const nanoid = customAlphabet("1234567890abcdefghijklmnopqrstuvwxyz", 10);
|
|
3836
3836
|
return nanoid();
|
|
3837
3837
|
};
|
|
3838
|
-
var safeParseJSON = (str) => {
|
|
3838
|
+
var safeParseJSON = (str, defaultValue = {}) => {
|
|
3839
|
+
if (!str || typeof str !== "string") {
|
|
3840
|
+
return defaultValue;
|
|
3841
|
+
}
|
|
3839
3842
|
try {
|
|
3840
|
-
|
|
3843
|
+
const parsed = JSON.parse(str);
|
|
3844
|
+
return parsed !== null && parsed !== void 0 ? parsed : defaultValue;
|
|
3841
3845
|
} catch (error) {
|
|
3842
|
-
|
|
3846
|
+
console.warn("Failed to parse JSON:", error);
|
|
3847
|
+
return defaultValue;
|
|
3843
3848
|
}
|
|
3844
3849
|
};
|
|
3845
3850
|
var isBeforeByUnix = (unix) => {
|
|
@@ -3907,7 +3912,7 @@ var ApiClient = class _ApiClient {
|
|
|
3907
3912
|
}
|
|
3908
3913
|
const res = await fetch(finalUrl, init);
|
|
3909
3914
|
const [status, resData] = await Promise.all([res.status, res.json()]);
|
|
3910
|
-
if (status < 200
|
|
3915
|
+
if (status < 200 || status >= 300 || resData?.success !== true) {
|
|
3911
3916
|
return Promise.reject(resData);
|
|
3912
3917
|
}
|
|
3913
3918
|
return resData.data;
|
|
@@ -4086,22 +4091,27 @@ var AirdropService = class {
|
|
|
4086
4091
|
return this.airdropV3FeeClient.getFeelessThreshold();
|
|
4087
4092
|
}
|
|
4088
4093
|
async getClaimFee(address, amount) {
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
}
|
|
4093
|
-
const feeClient = this.getFeeClient(feeCollector);
|
|
4094
|
-
const fee = await feeClient.getFee(address, amount);
|
|
4095
|
-
const version = await this.getVersion();
|
|
4096
|
-
if (version === "0.3.0" /* V3 */) {
|
|
4097
|
-
const threshold = await this.getFeelessThreshold();
|
|
4098
|
-
if (isGreaterThan(Number(amount), Number(threshold))) {
|
|
4099
|
-
return fee;
|
|
4100
|
-
} else {
|
|
4094
|
+
try {
|
|
4095
|
+
const feeCollector = await this.feeCollectors(this.options.contractAddress);
|
|
4096
|
+
if (!feeCollector || feeCollector === ZERO_ADDRESS) {
|
|
4101
4097
|
return void 0;
|
|
4102
4098
|
}
|
|
4099
|
+
const feeClient = this.getFeeClient(feeCollector);
|
|
4100
|
+
const fee = await feeClient.getFee(address, amount);
|
|
4101
|
+
const version = await this.getVersion();
|
|
4102
|
+
if (version === "0.3.0" /* V3 */) {
|
|
4103
|
+
const threshold = await this.getFeelessThreshold();
|
|
4104
|
+
if (isGreaterThan(Number(amount), Number(threshold))) {
|
|
4105
|
+
return fee;
|
|
4106
|
+
} else {
|
|
4107
|
+
return void 0;
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
return fee;
|
|
4111
|
+
} catch (error) {
|
|
4112
|
+
console.error("Failed to get claim fee:", error);
|
|
4113
|
+
throw new Error(`Failed to calculate claim fee: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
4103
4114
|
}
|
|
4104
|
-
return fee;
|
|
4105
4115
|
}
|
|
4106
4116
|
async getKycThreshold() {
|
|
4107
4117
|
const kycClient = await this.getKycClient();
|
|
@@ -10416,7 +10426,9 @@ var createApiClient = (baseURL) => {
|
|
|
10416
10426
|
var getAirdropProject = async (projectId, baseURL) => {
|
|
10417
10427
|
const client = createApiClient(baseURL);
|
|
10418
10428
|
const res = await client.get(`/airdrop-open/projects/${projectId}`);
|
|
10419
|
-
if (!res)
|
|
10429
|
+
if (!res) {
|
|
10430
|
+
throw new Error(`Project not found: ${projectId}`);
|
|
10431
|
+
}
|
|
10420
10432
|
const projectConfig = res?.themeConf;
|
|
10421
10433
|
const blockCountries = safeParseJSON(projectConfig?.blockCountries);
|
|
10422
10434
|
return {
|