pinpet-sdk 2.1.34 → 2.2.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/dist/index.d.ts +8 -1
- package/dist/pinpet-sdk.cjs.js +4240 -474
- package/dist/pinpet-sdk.esm.js +4368 -603
- package/dist/pinpet-sdk.js +4268 -503
- package/dist/pinpet-sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/idl/pinpet_main.json +3735 -0
- package/src/index.js +10 -3
- package/src/sdk.js +10 -4
- package/src/types/index.d.ts +8 -1
- package/src/utils/constants.js +6 -0
- /package/src/idl/{pinpet.json → pinpet_localnet.json} +0 -0
package/src/index.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
// Import main SDK class
|
|
8
8
|
const PinPetSdk = require('./sdk');
|
|
9
|
-
const
|
|
9
|
+
const idlLocalnet = require('./idl/pinpet_localnet.json');
|
|
10
|
+
const idlMain = require('./idl/pinpet_main.json');
|
|
10
11
|
const { PublicKey } = require('@solana/web3.js');
|
|
11
12
|
|
|
12
13
|
// Import modules (optional, users can also access directly via sdk.trading)
|
|
@@ -20,8 +21,13 @@ const { getDefaultOptions } = require('./utils/constants');
|
|
|
20
21
|
const OrderUtils = require('./utils/orderUtils');
|
|
21
22
|
const CurveAMM = require('./utils/curve_amm');
|
|
22
23
|
|
|
23
|
-
//
|
|
24
|
-
const SPINPET_PROGRAM_ID = new PublicKey(
|
|
24
|
+
// Program ID constants
|
|
25
|
+
const SPINPET_PROGRAM_ID = new PublicKey(idlMain.address);
|
|
26
|
+
|
|
27
|
+
function getProgramId(network) {
|
|
28
|
+
if (network === 'localnet') return new PublicKey(idlLocalnet.address);
|
|
29
|
+
return new PublicKey(idlMain.address);
|
|
30
|
+
}
|
|
25
31
|
|
|
26
32
|
// Main exports
|
|
27
33
|
module.exports = {
|
|
@@ -30,6 +36,7 @@ module.exports = {
|
|
|
30
36
|
|
|
31
37
|
// Constants
|
|
32
38
|
SPINPET_PROGRAM_ID,
|
|
39
|
+
getProgramId,
|
|
33
40
|
|
|
34
41
|
// Configuration utilities
|
|
35
42
|
getDefaultOptions,
|
package/src/sdk.js
CHANGED
|
@@ -20,7 +20,13 @@ const ChainModule = require('./modules/chain');
|
|
|
20
20
|
const ToolsModule = require('./modules/tools');
|
|
21
21
|
const OrderUtils = require('./utils/orderUtils');
|
|
22
22
|
const CurveAMM = require('./utils/curve_amm');
|
|
23
|
-
const
|
|
23
|
+
const idlLocalnet = require('./idl/pinpet_localnet.json');
|
|
24
|
+
const idlMain = require('./idl/pinpet_main.json');
|
|
25
|
+
|
|
26
|
+
function getIdlByNetwork(network) {
|
|
27
|
+
if (network === 'localnet') return idlLocalnet;
|
|
28
|
+
return idlMain;
|
|
29
|
+
}
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
32
|
* SpinPet SDK Main Class
|
|
@@ -54,7 +60,8 @@ class PinPetSdk {
|
|
|
54
60
|
this.connection = connection;
|
|
55
61
|
//this.wallet = wallet instanceof anchor.Wallet ? wallet : new anchor.Wallet(wallet);
|
|
56
62
|
this.programId = typeof programId === 'string' ? new PublicKey(programId) : programId;
|
|
57
|
-
|
|
63
|
+
this.idl = getIdlByNetwork(options.network);
|
|
64
|
+
|
|
58
65
|
// Initialize account configuration with options
|
|
59
66
|
this.feeRecipient = this._parsePublicKey(this.options.feeRecipient);
|
|
60
67
|
this.baseFeeRecipient = this._parsePublicKey(this.options.baseFeeRecipient);
|
|
@@ -162,8 +169,7 @@ class PinPetSdk {
|
|
|
162
169
|
|
|
163
170
|
anchor.setProvider(provider);
|
|
164
171
|
|
|
165
|
-
|
|
166
|
-
return new anchor.Program(spinpetIdl, this.programId);
|
|
172
|
+
return new anchor.Program(this.idl, this.programId);
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
// ========== Unified Data Interface Routing Method ==========
|
package/src/types/index.d.ts
CHANGED
|
@@ -5,8 +5,12 @@ import { BN, Wallet, Program } from '@coral-xyz/anchor';
|
|
|
5
5
|
|
|
6
6
|
export type DataSourceType = 'fast' | 'chain';
|
|
7
7
|
|
|
8
|
+
export type NetworkType = 'mainnet' | 'localnet';
|
|
9
|
+
|
|
8
10
|
export interface NetworkConfig {
|
|
9
11
|
name: string;
|
|
12
|
+
network: NetworkType;
|
|
13
|
+
programId: string;
|
|
10
14
|
defaultDataSource: DataSourceType;
|
|
11
15
|
solanaEndpoint: string;
|
|
12
16
|
pinPetFastApiUrl: string;
|
|
@@ -16,6 +20,7 @@ export interface NetworkConfig {
|
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
export interface PinPetSdkOptions {
|
|
23
|
+
network?: NetworkType;
|
|
19
24
|
defaultDataSource?: DataSourceType;
|
|
20
25
|
solanaEndpoint?: string;
|
|
21
26
|
pinPetFastApiUrl?: string;
|
|
@@ -362,7 +367,9 @@ export declare class CurveAMM {
|
|
|
362
367
|
|
|
363
368
|
// ========================= 常量和函数导出 =========================
|
|
364
369
|
|
|
365
|
-
export declare const SPINPET_PROGRAM_ID:
|
|
370
|
+
export declare const SPINPET_PROGRAM_ID: PublicKey;
|
|
371
|
+
|
|
372
|
+
export declare function getProgramId(network?: NetworkType): PublicKey;
|
|
366
373
|
|
|
367
374
|
export declare function getDefaultOptions(networkName?: 'MAINNET' | 'DEVNET' | 'LOCALNET'): NetworkConfig;
|
|
368
375
|
|
package/src/utils/constants.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
const DEFAULT_NETWORKS = {
|
|
7
7
|
MAINNET: {
|
|
8
8
|
name: 'mainnet-beta',
|
|
9
|
+
network: 'mainnet',
|
|
10
|
+
programId: 'CYdRzRacZ5kTc9Ht3U7mFhbsyxG3sZGEzC4cNf2Gjg2W',
|
|
9
11
|
defaultDataSource: 'fast',
|
|
10
12
|
solanaEndpoint: 'https://solana-rpc.pinpet.fun',
|
|
11
13
|
pinPetFastApiUrl: 'https://api.pinpet.fun/',
|
|
@@ -15,6 +17,8 @@ const DEFAULT_NETWORKS = {
|
|
|
15
17
|
},
|
|
16
18
|
DEVNET: {
|
|
17
19
|
name: 'devnet',
|
|
20
|
+
network: 'localnet',
|
|
21
|
+
programId: 'F2FzigE1Z374iDvreiM6hZQe6oGXgomJfv8PyybvUXye',
|
|
18
22
|
defaultDataSource: 'fast',
|
|
19
23
|
solanaEndpoint: 'https://lu-ura5lv-fast-devnet.helius-rpc.com',
|
|
20
24
|
pinPetFastApiUrl: 'https://devtestapi.pinpet.fun',
|
|
@@ -24,6 +28,8 @@ const DEFAULT_NETWORKS = {
|
|
|
24
28
|
},
|
|
25
29
|
LOCALNET: {
|
|
26
30
|
name: 'localnet',
|
|
31
|
+
network: 'localnet',
|
|
32
|
+
programId: 'F2FzigE1Z374iDvreiM6hZQe6oGXgomJfv8PyybvUXye',
|
|
27
33
|
defaultDataSource: 'fast', // 'fast' or 'chain'
|
|
28
34
|
solanaEndpoint: 'http://127.0.0.1:8899',
|
|
29
35
|
pinPetFastApiUrl: 'http://127.0.0.1:3000',
|
|
File without changes
|