@wuwei-labs/srsly 2.0.0-beta.45 → 2.0.0-beta.48
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/codama/instructions/cancelRental.js +13 -23
- package/dist/cjs/codama/instructions/cancelRental.js.map +1 -1
- package/dist/cjs/contract/close.js +106 -21
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +59 -5
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/demos.js +65 -0
- package/dist/cjs/demos.js.map +1 -0
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/rental/accept.js +31 -0
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +60 -9
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +35 -23
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset-contract-temp.js +4 -1
- package/dist/cjs/rental/reset-contract-temp.js.map +1 -1
- package/dist/cjs/rental/reset.js +131 -26
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/fetch-accounts.js +26 -0
- package/dist/cjs/utils/fetch-accounts.js.map +1 -1
- package/dist/cjs/utils/index.js +8 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/pda.js.map +1 -1
- package/dist/cjs/utils/sdk-helpers.js +122 -0
- package/dist/cjs/utils/sdk-helpers.js.map +1 -0
- package/dist/cjs/utils/signer.js +105 -10
- package/dist/cjs/utils/signer.js.map +1 -1
- package/dist/esm/codama/instructions/cancelRental.js +13 -23
- package/dist/esm/codama/instructions/cancelRental.js.map +1 -1
- package/dist/esm/contract/close.js +106 -22
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +59 -6
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/demos.js +23 -0
- package/dist/esm/demos.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/rental/accept.js +30 -0
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +60 -10
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +37 -26
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset-contract-temp.js +4 -1
- package/dist/esm/rental/reset-contract-temp.js.map +1 -1
- package/dist/esm/rental/reset.js +131 -27
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/fetch-accounts.js +26 -1
- package/dist/esm/utils/fetch-accounts.js.map +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/pda.js.map +1 -1
- package/dist/esm/utils/sdk-helpers.js +113 -0
- package/dist/esm/utils/sdk-helpers.js.map +1 -0
- package/dist/esm/utils/signer.js +103 -11
- package/dist/esm/utils/signer.js.map +1 -1
- package/dist/types/codama/instructions/cancelRental.d.ts +2 -2
- package/dist/types/codama/instructions/cancelRental.d.ts.map +1 -1
- package/dist/types/contract/close.d.ts +17 -12
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +8 -2
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/demos.d.ts +58 -0
- package/dist/types/demos.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts +6 -0
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +9 -3
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +11 -5
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset-contract-temp.d.ts +1 -1
- package/dist/types/rental/reset-contract-temp.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts +35 -24
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/fetch-accounts.d.ts +48 -1
- package/dist/types/utils/fetch-accounts.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/pda.d.ts.map +1 -1
- package/dist/types/utils/sdk-helpers.d.ts +49 -0
- package/dist/types/utils/sdk-helpers.d.ts.map +1 -0
- package/dist/types/utils/signer.d.ts +39 -16
- package/dist/types/utils/signer.d.ts.map +1 -1
- package/package.json +7 -1
- package/target/idl/srsly.json +1 -23
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ConfigSelector } from '../utils/config';
|
|
2
|
+
import { type FluentInstruction, type SmartFluentConfigSelector } from '../utils/instruction-converter';
|
|
3
|
+
import { type UniversalSigner } from '../utils/signer';
|
|
2
4
|
type UniversalAddress = string;
|
|
3
|
-
type UniversalSigner = any;
|
|
4
|
-
type ResetRentalInstruction = any;
|
|
5
5
|
/**
|
|
6
6
|
* Parameters for resetting a rental after cancellation.
|
|
7
7
|
*
|
|
@@ -20,9 +20,10 @@ export interface ResetRentalParams {
|
|
|
20
20
|
payer: UniversalSigner;
|
|
21
21
|
/**
|
|
22
22
|
* String address of the fleet associated with the rental contract.
|
|
23
|
+
* If omitted, the fleet address will be fetched from the contract account.
|
|
23
24
|
* The fleet's rental state will be reset to allow for new rentals.
|
|
24
25
|
*/
|
|
25
|
-
fleet
|
|
26
|
+
fleet?: UniversalAddress;
|
|
26
27
|
/**
|
|
27
28
|
* String address of the rental contract to reset.
|
|
28
29
|
* This contract will be made available for new rentals after reset.
|
|
@@ -30,9 +31,10 @@ export interface ResetRentalParams {
|
|
|
30
31
|
contract: UniversalAddress;
|
|
31
32
|
/**
|
|
32
33
|
* String address of the rental state account to be reset.
|
|
34
|
+
* If omitted, the rental state address will be fetched from the contract account.
|
|
33
35
|
* This account contains the canceled rental data that needs to be cleared.
|
|
34
36
|
*/
|
|
35
|
-
rentalState
|
|
37
|
+
rentalState?: UniversalAddress;
|
|
36
38
|
/**
|
|
37
39
|
* Faction identifier for Star Atlas integration.
|
|
38
40
|
* Can be provided as a number (1 = MUD, 2 = ONI, 3 = Ustur) or string ('mud', 'oni', 'ustur').
|
|
@@ -42,10 +44,11 @@ export interface ResetRentalParams {
|
|
|
42
44
|
faction: number | string;
|
|
43
45
|
/**
|
|
44
46
|
* String address of the owner's profile in the Star Atlas game.
|
|
47
|
+
* If omitted, the owner profile will be fetched from the contract account.
|
|
45
48
|
* Required for deriving game accounts (starbase, starbasePlayer) needed by SAGE.
|
|
46
49
|
* Must be the profile of the original fleet owner.
|
|
47
50
|
*/
|
|
48
|
-
ownerProfile
|
|
51
|
+
ownerProfile?: UniversalAddress;
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* Creates an instruction to reset a rental contract after cancellation with fluent configuration.
|
|
@@ -89,31 +92,35 @@ export interface ResetRentalParams {
|
|
|
89
92
|
* ```typescript
|
|
90
93
|
* import { resetRental } from '@srsly/sdk';
|
|
91
94
|
*
|
|
92
|
-
* // Reset a canceled rental
|
|
95
|
+
* // Reset a canceled rental (all addresses auto-fetched from contract)
|
|
93
96
|
* const instruction = await resetRental({
|
|
94
|
-
*
|
|
97
|
+
* payer: wallet, // Transaction payer
|
|
95
98
|
* contract: "ContractAddr...", // Contract to reactivate
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
+
* faction: 'mud' // Owner's faction
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* // Optionally provide explicit addresses to avoid fetching
|
|
103
|
+
* const instruction = await resetRental({
|
|
104
|
+
* payer: wallet,
|
|
105
|
+
* fleet: "FleetAddress123...", // Optional: will be fetched if omitted
|
|
106
|
+
* contract: "ContractAddr...",
|
|
107
|
+
* rentalState: "RentalStateAddr...", // Optional: will be fetched if omitted
|
|
108
|
+
* faction: 'mud',
|
|
109
|
+
* ownerProfile: "OwnerProfileAddr..." // Optional: will be fetched if omitted
|
|
99
110
|
* });
|
|
100
111
|
*
|
|
101
112
|
* // Configure for mainnet
|
|
102
113
|
* const mainnetInstruction = await resetRental({
|
|
103
|
-
*
|
|
114
|
+
* payer: wallet,
|
|
104
115
|
* contract: "ContractAddr...",
|
|
105
|
-
*
|
|
106
|
-
* faction: 1, // Can use numbers: 1=mud, 2=oni, 3=ustur
|
|
107
|
-
* ownerProfile: "OwnerProfileAddr..."
|
|
116
|
+
* faction: 1 // Can use numbers: 1=mud, 2=oni, 3=ustur
|
|
108
117
|
* }).set({ programs: 'mainnet' });
|
|
109
118
|
*
|
|
110
119
|
* // Override specific game configuration
|
|
111
120
|
* const customInstruction = await resetRental({
|
|
112
|
-
*
|
|
121
|
+
* payer: wallet,
|
|
113
122
|
* contract: "ContractAddr...",
|
|
114
|
-
*
|
|
115
|
-
* faction: 'mud',
|
|
116
|
-
* ownerProfile: "OwnerProfileAddr..."
|
|
123
|
+
* faction: 'mud'
|
|
117
124
|
* }).set({
|
|
118
125
|
* programs: 'mainnet',
|
|
119
126
|
* gameId: 'custom-game-id...'
|
|
@@ -121,11 +128,9 @@ export interface ResetRentalParams {
|
|
|
121
128
|
*
|
|
122
129
|
* // Convert to @solana/web3.js format
|
|
123
130
|
* const web3jsInstruction = await resetRental({
|
|
124
|
-
*
|
|
131
|
+
* payer: wallet,
|
|
125
132
|
* contract: "ContractAddr...",
|
|
126
|
-
*
|
|
127
|
-
* faction: 'mud',
|
|
128
|
-
* ownerProfile: "OwnerProfileAddr..."
|
|
133
|
+
* faction: 'mud'
|
|
129
134
|
* }).web3js();
|
|
130
135
|
*
|
|
131
136
|
* // Use with your preferred Solana library
|
|
@@ -134,10 +139,10 @@ export interface ResetRentalParams {
|
|
|
134
139
|
* ```
|
|
135
140
|
*
|
|
136
141
|
* @param params - The rental reset parameters including fleet, contract, rental state, and owner details
|
|
137
|
-
* @returns A
|
|
142
|
+
* @returns A SmartFluentConfigSelector that can be configured with .set() or awaited directly
|
|
138
143
|
* @throws Error when rental is not in canceled state or instruction generation fails
|
|
139
144
|
*/
|
|
140
|
-
export declare function resetRental(params: ResetRentalParams):
|
|
145
|
+
export declare function resetRental(params: ResetRentalParams): SmartFluentConfigSelector<FluentInstruction>;
|
|
141
146
|
/**
|
|
142
147
|
* Low-level function to create a rental reset instruction with raw input parameters.
|
|
143
148
|
*
|
|
@@ -151,5 +156,11 @@ export declare function resetRental(params: ResetRentalParams): ConfigSelector<R
|
|
|
151
156
|
* @returns A ConfigSelector for the raw instruction
|
|
152
157
|
*/
|
|
153
158
|
export declare function getResetRentalInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
159
|
+
export declare const resetRentalDemo: {
|
|
160
|
+
tabName: string;
|
|
161
|
+
description: string;
|
|
162
|
+
imports: string;
|
|
163
|
+
instruction: string;
|
|
164
|
+
};
|
|
154
165
|
export {};
|
|
155
166
|
//# sourceMappingURL=reset.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuE,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAG/I,OAAO,EAA4D,KAAK,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAElK,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGhF,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAE/B;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,KAAK,EAAE,eAAe,CAAC;IACvB;;;;OAIG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAEzB;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;;;OAIG;IACF,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAEhC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AA+JD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,iBAAiB,GACxB,yBAAyB,CAAC,iBAAiB,CAAC,CAG9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK7F;AAGD,eAAO,MAAM,eAAe;;;;;CAS3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Address } from '@solana/kit';
|
|
2
|
-
import { fetchContractState as fetchContractStateCodama, fetchRentalState as fetchRentalStateCodama } from '../codama/accounts';
|
|
2
|
+
import { fetchContractState as fetchContractStateCodama, fetchRentalState as fetchRentalStateCodama, fetchMaybeConfig as fetchConfigStateCodama } from '../codama/accounts';
|
|
3
3
|
/**
|
|
4
4
|
* Convenience wrapper functions for fetching account states with RPC URL strings.
|
|
5
5
|
* These functions handle creating the RPC connection for you.
|
|
@@ -70,6 +70,53 @@ export declare function fetchRentalState<TAddress extends string = string>(renta
|
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
export declare function fetchRentalState<TAddress extends string = string>(rpcUrl: string, rentalAddress: string | Address<TAddress>): Promise<ReturnType<typeof fetchRentalStateCodama>>;
|
|
73
|
+
/**
|
|
74
|
+
* Fetches config state data from the blockchain using global config to derive PDA
|
|
75
|
+
*
|
|
76
|
+
* @returns The config state data with metadata
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* // Uses global config to automatically derive config PDA
|
|
81
|
+
* const configState = await fetchConfigState();
|
|
82
|
+
* console.log('Config authority:', configState.data.authority);
|
|
83
|
+
* console.log('Config fees:', configState.data.fees);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function fetchConfigState(): Promise<ReturnType<typeof fetchConfigStateCodama>>;
|
|
87
|
+
/**
|
|
88
|
+
* Fetches config state data from the blockchain using RPC URL from global config
|
|
89
|
+
*
|
|
90
|
+
* @param configAddress - The config account address to fetch
|
|
91
|
+
* @returns The config state data with metadata
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const configState = await fetchConfigState('ConfigAddress123...');
|
|
96
|
+
* console.log('Config authority:', configState.data.authority);
|
|
97
|
+
* console.log('Config fees:', configState.data.fees);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function fetchConfigState<TAddress extends string = string>(configAddress: string | Address<TAddress>): Promise<ReturnType<typeof fetchConfigStateCodama>>;
|
|
101
|
+
/**
|
|
102
|
+
* Fetches config state data from the blockchain using a specific RPC URL
|
|
103
|
+
*
|
|
104
|
+
* @param rpcUrl - The RPC endpoint URL as a string
|
|
105
|
+
* @param configAddress - The config account address to fetch
|
|
106
|
+
* @returns The config state data with metadata
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const configState = await fetchConfigState(
|
|
111
|
+
* 'https://api.devnet.solana.com',
|
|
112
|
+
* 'ConfigAddress123...'
|
|
113
|
+
* );
|
|
114
|
+
*
|
|
115
|
+
* console.log('Config authority:', configState.data.authority);
|
|
116
|
+
* console.log('Config fees:', configState.data.fees);
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function fetchConfigState<TAddress extends string = string>(rpcUrl: string, configAddress: string | Address<TAddress>): Promise<ReturnType<typeof fetchConfigStateCodama>>;
|
|
73
120
|
/**
|
|
74
121
|
* Fetches multiple contract states in a single RPC call
|
|
75
122
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-accounts.d.ts","sourceRoot":"","sources":["../../../src/utils/fetch-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,kBAAkB,IAAI,wBAAwB,EAC9C,gBAAgB,IAAI,sBAAsB,EAG3C,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch-accounts.d.ts","sourceRoot":"","sources":["../../../src/utils/fetch-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,kBAAkB,IAAI,wBAAwB,EAC9C,gBAAgB,IAAI,sBAAsB,EAC1C,gBAAgB,IAAI,sBAAsB,EAG3C,MAAM,oBAAoB,CAAC;AAK5B;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EACvE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,GAC1C,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EACvE,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,GAC1C,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC;AAuBxD;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EACrE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,GACxC,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;;;;GAiBG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|
+
export { createRpcFromConfig, deriveConfigPda, fetchAccountWithValidation, fetchMultipleAccounts, deriveAllRentalPDAs, ErrorMessages } from "./sdk-helpers";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,0BAA0B,EAC1B,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACd,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pda.d.ts","sourceRoot":"","sources":["../../../src/utils/pda.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAyE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAGlH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,GAAG,OAAO,EACvB,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,GAChC,OAAO,C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@@
|
|
|
1
|
+
import { type Rpc, type GetAccountInfoApi, type Address, type MaybeAccount } from '@solana/kit';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
/**
|
|
4
|
+
* SDK Helper utilities to reduce code duplication across instruction implementations
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Creates an RPC connection from resolved addresses, with validation
|
|
8
|
+
*/
|
|
9
|
+
export declare function createRpcFromConfig(resolvedAddresses: {
|
|
10
|
+
rpcUrl?: string;
|
|
11
|
+
}, operationName: string): Rpc<GetAccountInfoApi>;
|
|
12
|
+
/**
|
|
13
|
+
* Derives the config PDA for the SRSLY program
|
|
14
|
+
*/
|
|
15
|
+
export declare function deriveConfigPda(programAddress: string | PublicKey): Promise<[Address, number]>;
|
|
16
|
+
/**
|
|
17
|
+
* Generic fetch function with validation and error handling
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchAccountWithValidation<T extends MaybeAccount<any, string>>(fetchFn: (rpc: Rpc<GetAccountInfoApi>, address: Address) => Promise<T>, rpc: Rpc<GetAccountInfoApi>, accountAddress: string | PublicKey, accountType: string): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Batch fetch multiple accounts with proper error handling
|
|
22
|
+
*/
|
|
23
|
+
export declare function fetchMultipleAccounts<T extends Record<string, MaybeAccount<any, string>>>(fetchOperations: Array<{
|
|
24
|
+
fetchFn: (rpc: Rpc<GetAccountInfoApi>, address: Address) => Promise<MaybeAccount<any, string>>;
|
|
25
|
+
address: string | PublicKey;
|
|
26
|
+
accountType: string;
|
|
27
|
+
key: keyof T;
|
|
28
|
+
}>, rpc: Rpc<GetAccountInfoApi>): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Convert public key to address format used by the SDK
|
|
31
|
+
*/
|
|
32
|
+
export declare function toAddressString(key: string | PublicKey): string;
|
|
33
|
+
/**
|
|
34
|
+
* Derive all rental-related PDAs in one call
|
|
35
|
+
*/
|
|
36
|
+
export declare function deriveAllRentalPDAs(contract: string | PublicKey, borrower: string | PublicKey, programAddress: string | PublicKey, antegenProgramAddress: string | PublicKey): Promise<{
|
|
37
|
+
rentalState: [Address, number];
|
|
38
|
+
rentalAuthority: [Address, number];
|
|
39
|
+
rentalThread: [Address, number];
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Standard error messages for common scenarios
|
|
43
|
+
*/
|
|
44
|
+
export declare const ErrorMessages: {
|
|
45
|
+
readonly rpcRequired: (operation: string) => string;
|
|
46
|
+
readonly accountNotFound: (type: string, address: string) => string;
|
|
47
|
+
readonly fetchFailed: (type: string, error: unknown) => string;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=sdk-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/sdk-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,GAAG,EAAE,KAAK,iBAAiB,EAAW,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1H,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;GAEG;AAEH;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAKzH;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAOpG;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,EAClF,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CA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C"}
|
|
@@ -1,35 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Universal signer handling utilities for
|
|
2
|
+
* Universal signer handling utilities for @solana/kit compatibility
|
|
3
3
|
*
|
|
4
|
-
* This module provides utilities to handle different signer types
|
|
5
|
-
* @solana/kit
|
|
4
|
+
* This module provides utilities to handle different signer types in a unified way
|
|
5
|
+
* while ensuring compatibility with @solana/kit. Supports string addresses for
|
|
6
|
+
* browser usage and TransactionSigner objects for Node.js usage.
|
|
7
|
+
*
|
|
8
|
+
* Note: web3.js signers (Keypair, etc.) are explicitly not supported.
|
|
9
|
+
* Use address strings or @solana/kit TransactionSigner objects instead.
|
|
6
10
|
*/
|
|
7
11
|
import { type TransactionSigner } from '@solana/kit';
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* Error thrown when an invalid signer type is provided
|
|
14
|
+
*/
|
|
15
|
+
export declare class InvalidSignerError extends Error {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Universal signer type that supports @solana/kit compatible signers and address strings
|
|
20
|
+
*
|
|
21
|
+
* Supported types:
|
|
22
|
+
* - string: Base58 Solana address (for browser usage)
|
|
23
|
+
* - TransactionSigner: @solana/kit signer object (for Node.js usage)
|
|
24
|
+
* - { address: string }: Kit-compatible signer with address property
|
|
25
|
+
*
|
|
26
|
+
* Note: web3.js signers (Keypair, etc.) are not supported. Use address strings
|
|
27
|
+
* or TransactionSigner objects from @solana/kit instead.
|
|
10
28
|
*/
|
|
11
|
-
export type UniversalSigner = string | {
|
|
29
|
+
export type UniversalSigner = string | TransactionSigner | {
|
|
12
30
|
address: string;
|
|
13
|
-
}
|
|
14
|
-
publicKey: {
|
|
15
|
-
toString(): string;
|
|
16
|
-
};
|
|
17
|
-
} | {
|
|
18
|
-
publicKey: string;
|
|
19
|
-
} | any;
|
|
31
|
+
};
|
|
20
32
|
/**
|
|
21
|
-
*
|
|
33
|
+
* Validates that a signer is compatible with @solana/kit
|
|
34
|
+
*
|
|
35
|
+
* @param signer - The signer to validate
|
|
36
|
+
* @throws {InvalidSignerError} If the signer is not compatible
|
|
37
|
+
*/
|
|
38
|
+
export declare function validateSigner(signer: unknown): asserts signer is UniversalSigner;
|
|
39
|
+
/**
|
|
40
|
+
* Creates TransactionSigner from UniversalSigner input with validation
|
|
22
41
|
*
|
|
23
42
|
* This function provides universal compatibility by:
|
|
43
|
+
* - Validating the signer is compatible with @solana/kit
|
|
24
44
|
* - Converting string addresses to TransactionSigner using createNoopSigner
|
|
25
45
|
* - Passing through existing TransactionSigner objects unchanged
|
|
26
|
-
* - Safely handling different signer interfaces (kit, web3.js, etc.)
|
|
27
46
|
*
|
|
28
47
|
* The returned TransactionSigner has both .address property and signing capability,
|
|
29
48
|
* making it suitable for both PDA derivation and codama instruction building.
|
|
30
49
|
*
|
|
31
|
-
* @param signer - The signer input (string address or signer
|
|
50
|
+
* @param signer - The signer input (string address or @solana/kit compatible signer)
|
|
32
51
|
* @returns TransactionSigner that can be used directly for codama and has .address property
|
|
52
|
+
* @throws {InvalidSignerError} If the signer is not compatible (e.g., web3.js Keypair)
|
|
33
53
|
*
|
|
34
54
|
* @example
|
|
35
55
|
* ```typescript
|
|
@@ -38,10 +58,13 @@ export type UniversalSigner = string | {
|
|
|
38
58
|
* // borrower.address → Address object for PDA derivation
|
|
39
59
|
* // borrower → TransactionSigner for codama
|
|
40
60
|
*
|
|
41
|
-
* //
|
|
61
|
+
* // Node.js usage with TransactionSigner
|
|
42
62
|
* const borrower = createTransactionSigner(wallet);
|
|
43
63
|
* // borrower.address → wallet.address for PDA derivation
|
|
44
64
|
* // borrower → wallet signer for codama
|
|
65
|
+
*
|
|
66
|
+
* // This will throw an error:
|
|
67
|
+
* // createTransactionSigner(keypair); // InvalidSignerError: web3.js signers not supported
|
|
45
68
|
* ```
|
|
46
69
|
*/
|
|
47
70
|
export declare function createTransactionSigner(signer: UniversalSigner): TransactionSigner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/utils/signer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/utils/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAwC,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG3F;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,iBAAiB,GACjB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,CAgEjF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CA6BlF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,IAAI,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAElG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,IAAI,MAAM,CAEzE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wuwei-labs/srsly",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.48",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
"import": "./dist/esm/index.js",
|
|
25
25
|
"default": "./dist/cjs/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./demos": {
|
|
28
|
+
"types": "./dist/types/demos.d.ts",
|
|
29
|
+
"require": "./dist/cjs/demos.js",
|
|
30
|
+
"import": "./dist/esm/demos.js",
|
|
31
|
+
"default": "./dist/cjs/demos.js"
|
|
32
|
+
},
|
|
27
33
|
"./codama": {
|
|
28
34
|
"types": "./dist/types/codama/index.d.ts",
|
|
29
35
|
"require": "./dist/cjs/codama/index.js",
|
package/target/idl/srsly.json
CHANGED
|
@@ -515,29 +515,7 @@
|
|
|
515
515
|
},
|
|
516
516
|
{
|
|
517
517
|
"name": "rental_thread",
|
|
518
|
-
"
|
|
519
|
-
"seeds": [
|
|
520
|
-
{
|
|
521
|
-
"kind": "const",
|
|
522
|
-
"value": [
|
|
523
|
-
116,
|
|
524
|
-
104,
|
|
525
|
-
114,
|
|
526
|
-
101,
|
|
527
|
-
97,
|
|
528
|
-
100
|
|
529
|
-
]
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
"kind": "account",
|
|
533
|
-
"path": "rental_authority"
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
"kind": "account",
|
|
537
|
-
"path": "rental_state"
|
|
538
|
-
}
|
|
539
|
-
]
|
|
540
|
-
}
|
|
518
|
+
"writable": true
|
|
541
519
|
},
|
|
542
520
|
{
|
|
543
521
|
"name": "contract"
|