@wuwei-labs/srsly 2.0.0-beta.37 → 2.0.0-beta.41
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 +2 -1
- package/dist/cjs/codama/accounts/config.js +0 -2
- package/dist/cjs/codama/accounts/config.js.map +1 -1
- package/dist/cjs/codama/accounts/contractState.js.map +1 -1
- package/dist/cjs/codama/accounts/rentalState.js +1 -3
- package/dist/cjs/codama/accounts/rentalState.js.map +1 -1
- package/dist/cjs/codama/errors/srsly.js +13 -1
- package/dist/cjs/codama/errors/srsly.js.map +1 -1
- package/dist/cjs/codama/instructions/acceptRental.js +1 -28
- package/dist/cjs/codama/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/codama/instructions/closeRental.js +28 -13
- package/dist/cjs/codama/instructions/closeRental.js.map +1 -1
- package/dist/cjs/codama/instructions/index.js +1 -0
- package/dist/cjs/codama/instructions/index.js.map +1 -1
- package/dist/cjs/codama/instructions/payRental.js +1 -18
- package/dist/cjs/codama/instructions/payRental.js.map +1 -1
- package/dist/cjs/codama/instructions/resetContractTemp.js +146 -0
- package/dist/cjs/codama/instructions/resetContractTemp.js.map +1 -0
- package/dist/cjs/codama/instructions/resetRental.js +6 -1
- package/dist/cjs/codama/instructions/resetRental.js.map +1 -1
- package/dist/cjs/codama/instructions/updateConfig.js +0 -2
- package/dist/cjs/codama/instructions/updateConfig.js.map +1 -1
- package/dist/cjs/codama/programs/srsly.js +6 -2
- package/dist/cjs/codama/programs/srsly.js.map +1 -1
- package/dist/cjs/codama/types/paymentFrequency.js +31 -0
- package/dist/cjs/codama/types/paymentFrequency.js.map +1 -1
- package/dist/cjs/contract/close.js +71 -11
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +88 -21
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/contract/index.js +45 -0
- package/dist/cjs/contract/index.js.map +1 -1
- package/dist/cjs/index.js +110 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +4 -4
- package/dist/cjs/rental/accept.js +164 -45
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +82 -16
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +152 -27
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/index.js +85 -0
- package/dist/cjs/rental/index.js.map +1 -1
- package/dist/cjs/rental/reset-contract-temp.js +103 -0
- package/dist/cjs/rental/reset-contract-temp.js.map +1 -0
- package/dist/cjs/rental/reset.js +102 -19
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +44 -9
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/constants.js +16 -6
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/instruction-converter.js +60 -5
- package/dist/cjs/utils/instruction-converter.js.map +1 -1
- package/dist/cjs/utils/paymentFrequency.js +7 -2
- package/dist/cjs/utils/paymentFrequency.js.map +1 -1
- package/dist/cjs/utils/pda.js +191 -0
- package/dist/cjs/utils/pda.js.map +1 -0
- package/dist/esm/codama/accounts/config.js +0 -2
- package/dist/esm/codama/accounts/config.js.map +1 -1
- package/dist/esm/codama/accounts/contractState.js.map +1 -1
- package/dist/esm/codama/accounts/rentalState.js +1 -3
- package/dist/esm/codama/accounts/rentalState.js.map +1 -1
- package/dist/esm/codama/errors/srsly.js +12 -0
- package/dist/esm/codama/errors/srsly.js.map +1 -1
- package/dist/esm/codama/instructions/acceptRental.js +1 -28
- package/dist/esm/codama/instructions/acceptRental.js.map +1 -1
- package/dist/esm/codama/instructions/closeRental.js +28 -13
- package/dist/esm/codama/instructions/closeRental.js.map +1 -1
- package/dist/esm/codama/instructions/index.js +1 -0
- package/dist/esm/codama/instructions/index.js.map +1 -1
- package/dist/esm/codama/instructions/payRental.js +1 -18
- package/dist/esm/codama/instructions/payRental.js.map +1 -1
- package/dist/esm/codama/instructions/resetContractTemp.js +136 -0
- package/dist/esm/codama/instructions/resetContractTemp.js.map +1 -0
- package/dist/esm/codama/instructions/resetRental.js +6 -1
- package/dist/esm/codama/instructions/resetRental.js.map +1 -1
- package/dist/esm/codama/instructions/updateConfig.js +0 -2
- package/dist/esm/codama/instructions/updateConfig.js.map +1 -1
- package/dist/esm/codama/programs/srsly.js +6 -2
- package/dist/esm/codama/programs/srsly.js.map +1 -1
- package/dist/esm/codama/types/paymentFrequency.js +31 -0
- package/dist/esm/codama/types/paymentFrequency.js.map +1 -1
- package/dist/esm/contract/close.js +72 -12
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +89 -22
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/contract/index.js +45 -0
- package/dist/esm/contract/index.js.map +1 -1
- package/dist/esm/index.js +110 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +4 -4
- package/dist/esm/rental/accept.js +166 -47
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +83 -17
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +152 -27
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/index.js +85 -0
- package/dist/esm/rental/index.js.map +1 -1
- package/dist/esm/rental/reset-contract-temp.js +100 -0
- package/dist/esm/rental/reset-contract-temp.js.map +1 -0
- package/dist/esm/rental/reset.js +102 -19
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/config.js +44 -9
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/esm/utils/constants.js +16 -6
- package/dist/esm/utils/constants.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/instruction-converter.js +59 -5
- package/dist/esm/utils/instruction-converter.js.map +1 -1
- package/dist/esm/utils/paymentFrequency.js +7 -2
- package/dist/esm/utils/paymentFrequency.js.map +1 -1
- package/dist/esm/utils/pda.js +185 -0
- package/dist/esm/utils/pda.js.map +1 -0
- package/dist/types/codama/accounts/config.d.ts +24 -2
- package/dist/types/codama/accounts/config.d.ts.map +1 -1
- package/dist/types/codama/accounts/contractState.d.ts +26 -0
- package/dist/types/codama/accounts/contractState.d.ts.map +1 -1
- package/dist/types/codama/accounts/rentalState.d.ts +20 -2
- package/dist/types/codama/accounts/rentalState.d.ts.map +1 -1
- package/dist/types/codama/errors/srsly.d.ts +9 -1
- package/dist/types/codama/errors/srsly.d.ts.map +1 -1
- package/dist/types/codama/instructions/acceptRental.d.ts +13 -20
- package/dist/types/codama/instructions/acceptRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/closeRental.d.ts +33 -13
- package/dist/types/codama/instructions/closeRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/index.d.ts +1 -0
- package/dist/types/codama/instructions/index.d.ts.map +1 -1
- package/dist/types/codama/instructions/payRental.d.ts +11 -18
- package/dist/types/codama/instructions/payRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/resetContractTemp.d.ts +71 -0
- package/dist/types/codama/instructions/resetContractTemp.d.ts.map +1 -0
- package/dist/types/codama/instructions/resetRental.d.ts +21 -17
- package/dist/types/codama/instructions/resetRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/updateConfig.d.ts +20 -4
- package/dist/types/codama/instructions/updateConfig.d.ts.map +1 -1
- package/dist/types/codama/programs/srsly.d.ts +6 -3
- package/dist/types/codama/programs/srsly.d.ts.map +1 -1
- package/dist/types/codama/types/paymentFrequency.d.ts +31 -0
- package/dist/types/codama/types/paymentFrequency.d.ts.map +1 -1
- package/dist/types/contract/close.d.ts +77 -16
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +114 -17
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/contract/index.d.ts +45 -0
- package/dist/types/contract/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +111 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts +121 -50
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +80 -16
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +86 -26
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/index.d.ts +85 -0
- package/dist/types/rental/index.d.ts.map +1 -1
- package/dist/types/rental/reset-contract-temp.d.ts +77 -0
- package/dist/types/rental/reset-contract-temp.d.ts.map +1 -0
- package/dist/types/rental/reset.d.ts +114 -24
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +14 -2
- package/dist/types/utils/config.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts +1 -1
- package/dist/types/utils/constants.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/instruction-converter.d.ts +70 -20
- package/dist/types/utils/instruction-converter.d.ts.map +1 -1
- package/dist/types/utils/paymentFrequency.d.ts +3 -3
- package/dist/types/utils/paymentFrequency.d.ts.map +1 -1
- package/dist/types/utils/pda.d.ts +120 -0
- package/dist/types/utils/pda.d.ts.map +1 -0
- package/package.json +5 -5
- package/target/idl/srsly.json +318 -94
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Fluent instruction interface for format conversion between @solana/kit and @solana/web3.js
|
|
3
3
|
*/
|
|
4
|
-
import { ConfigSelector } from './config';
|
|
4
|
+
import { ConfigSelector, ConfigOptions, PublicKeyConstructor } from './config';
|
|
5
5
|
/**
|
|
6
|
-
* @solana/kit instruction format
|
|
6
|
+
* @solana/kit 2.x compatible instruction format
|
|
7
|
+
* This matches the structure expected by appendTransactionMessageInstruction
|
|
7
8
|
*/
|
|
8
9
|
export interface KitInstruction {
|
|
9
|
-
|
|
10
|
+
programAddress: string;
|
|
11
|
+
accounts?: Array<{
|
|
10
12
|
address: string;
|
|
11
13
|
role: number;
|
|
12
14
|
}>;
|
|
13
|
-
|
|
14
|
-
data: Uint8Array | {
|
|
15
|
-
[key: string]: number;
|
|
16
|
-
};
|
|
15
|
+
data?: Uint8Array;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
18
|
* @solana/web3.js instruction format with string addresses
|
|
@@ -47,32 +46,41 @@ export interface Web3jsInstructionWithPublicKeys<TPublicKey = any> {
|
|
|
47
46
|
* Generic web3.js instruction format
|
|
48
47
|
*/
|
|
49
48
|
export type Web3jsInstruction<TPublicKey = string> = TPublicKey extends string ? Web3jsInstructionWithStrings : Web3jsInstructionWithPublicKeys<TPublicKey>;
|
|
50
|
-
/**
|
|
51
|
-
* PublicKey constructor interface
|
|
52
|
-
*/
|
|
53
|
-
export interface PublicKeyConstructor<TPublicKey = any> {
|
|
54
|
-
new (address: string): TPublicKey;
|
|
55
|
-
}
|
|
56
49
|
/**
|
|
57
50
|
* Fluent instruction wrapper that provides format conversion methods
|
|
58
51
|
* @example
|
|
59
52
|
* ```typescript
|
|
60
53
|
* import { PublicKey } from '@solana/web3.js';
|
|
61
54
|
*
|
|
62
|
-
* //
|
|
63
|
-
* const
|
|
55
|
+
* // Get FluentInstruction
|
|
56
|
+
* const fluentInstruction = await createContract(params);
|
|
57
|
+
*
|
|
58
|
+
* // Access pure instruction data for @solana/kit
|
|
59
|
+
* const kitInstruction = fluentInstruction.instruction;
|
|
60
|
+
* // or
|
|
61
|
+
* const kitInstruction = fluentInstruction.kit();
|
|
64
62
|
*
|
|
65
63
|
* // Convert to web3.js format with string addresses
|
|
66
|
-
* const web3jsInstruction =
|
|
64
|
+
* const web3jsInstruction = fluentInstruction.web3js();
|
|
67
65
|
*
|
|
68
66
|
* // Convert to web3.js format with PublicKey instances
|
|
69
|
-
* const web3jsInstructionWithPK =
|
|
67
|
+
* const web3jsInstructionWithPK = fluentInstruction.web3js(PublicKey);
|
|
70
68
|
*
|
|
71
69
|
* // Use with libraries
|
|
72
70
|
* const transaction = new Transaction().add(web3jsInstructionWithPK);
|
|
73
71
|
* ```
|
|
74
72
|
*/
|
|
75
|
-
export interface FluentInstruction
|
|
73
|
+
export interface FluentInstruction {
|
|
74
|
+
/**
|
|
75
|
+
* Pure instruction data (can be passed directly to @solana/kit)
|
|
76
|
+
* This property contains the clean KitInstruction without any method pollution
|
|
77
|
+
*/
|
|
78
|
+
instruction: KitInstruction;
|
|
79
|
+
/**
|
|
80
|
+
* Get pure KitInstruction format (alias for .instruction property)
|
|
81
|
+
* @returns Instruction in @solana/kit format
|
|
82
|
+
*/
|
|
83
|
+
kit(): KitInstruction;
|
|
76
84
|
/**
|
|
77
85
|
* Convert instruction to @solana/web3.js format with string addresses
|
|
78
86
|
* @returns Instruction in @solana/web3.js format with string pubkeys
|
|
@@ -88,6 +96,7 @@ export interface FluentInstruction extends KitInstruction {
|
|
|
88
96
|
/**
|
|
89
97
|
* Fluent config selector that adds format conversion methods
|
|
90
98
|
* This allows chaining both configuration and format conversion
|
|
99
|
+
* @deprecated Use SmartFluentConfigSelector instead
|
|
91
100
|
*/
|
|
92
101
|
export interface FluentConfigSelector<T extends FluentInstruction> extends ConfigSelector<T> {
|
|
93
102
|
/**
|
|
@@ -103,15 +112,56 @@ export interface FluentConfigSelector<T extends FluentInstruction> extends Confi
|
|
|
103
112
|
web3js<TPublicKey>(PublicKeyConstructor: PublicKeyConstructor<TPublicKey>): Promise<Web3jsInstructionWithPublicKeys<TPublicKey>>;
|
|
104
113
|
}
|
|
105
114
|
/**
|
|
106
|
-
*
|
|
115
|
+
* Smart fluent config selector that returns different types based on library configuration
|
|
116
|
+
*
|
|
117
|
+
* Return behavior based on config:
|
|
118
|
+
* - No library config: Returns FluentInstruction (must use .kit() or .web3js())
|
|
119
|
+
* - library='kit': Returns KitInstruction directly
|
|
120
|
+
* - library='web3js': Returns web3js instruction format directly
|
|
121
|
+
*/
|
|
122
|
+
export interface SmartFluentConfigSelector<T extends FluentInstruction> extends ConfigSelector<any> {
|
|
123
|
+
/**
|
|
124
|
+
* Set configuration options for this call
|
|
125
|
+
*/
|
|
126
|
+
set(options: ConfigOptions): SmartFluentConfigSelector<T>;
|
|
127
|
+
/**
|
|
128
|
+
* Build with current configuration (explicit call)
|
|
129
|
+
*/
|
|
130
|
+
build(): Promise<T>;
|
|
131
|
+
/**
|
|
132
|
+
* Get pure KitInstruction format
|
|
133
|
+
* @returns Promise that resolves to KitInstruction
|
|
134
|
+
*/
|
|
135
|
+
kit(): Promise<KitInstruction>;
|
|
136
|
+
/**
|
|
137
|
+
* Convert instruction to @solana/web3.js format with string addresses
|
|
138
|
+
* @returns Promise that resolves to Web3jsInstructionWithStrings
|
|
139
|
+
*/
|
|
140
|
+
web3js(): Promise<Web3jsInstructionWithStrings>;
|
|
141
|
+
/**
|
|
142
|
+
* Convert instruction to @solana/web3.js format with PublicKey instances
|
|
143
|
+
* @param PublicKeyConstructor Constructor for creating PublicKey instances
|
|
144
|
+
* @returns Promise that resolves to Web3jsInstructionWithPublicKeys
|
|
145
|
+
*/
|
|
146
|
+
web3js<TPublicKey>(PublicKeyConstructor: PublicKeyConstructor<TPublicKey>): Promise<Web3jsInstructionWithPublicKeys<TPublicKey>>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a fluent instruction from a kit instruction using non-polluting design
|
|
107
150
|
* @param kitInstruction The base instruction in kit format
|
|
108
|
-
* @returns Fluent instruction with conversion methods
|
|
151
|
+
* @returns Fluent instruction with separate instruction property and conversion methods
|
|
109
152
|
*/
|
|
110
153
|
export declare function createFluentInstruction(kitInstruction: KitInstruction): FluentInstruction;
|
|
111
154
|
/**
|
|
112
155
|
* Create a fluent config selector that adds format conversion methods
|
|
156
|
+
* @deprecated Use createSmartFluentConfigSelector instead
|
|
113
157
|
* @param baseSelector The base ConfigSelector
|
|
114
158
|
* @returns FluentConfigSelector with additional format conversion methods
|
|
115
159
|
*/
|
|
116
160
|
export declare function createFluentConfigSelector<T extends FluentInstruction>(baseSelector: ConfigSelector<T>): FluentConfigSelector<T>;
|
|
161
|
+
/**
|
|
162
|
+
* Create a smart fluent config selector with library-aware return types
|
|
163
|
+
* @param baseSelector The base ConfigSelector
|
|
164
|
+
* @returns SmartFluentConfigSelector with smart return behavior
|
|
165
|
+
*/
|
|
166
|
+
export declare function createSmartFluentConfigSelector<T extends FluentInstruction>(baseSelector: ConfigSelector<T>): SmartFluentConfigSelector<T>;
|
|
117
167
|
//# sourceMappingURL=instruction-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction-converter.d.ts","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"instruction-converter.d.ts","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PaymentFrequency } from '../codama/types/paymentFrequency';
|
|
2
|
-
import { PaymentFrequencyString } from '../types/paymentFrequency';
|
|
3
2
|
/**
|
|
4
3
|
* Converts a PaymentFrequency enum value to seconds
|
|
5
4
|
* Mirrors the to_seconds() method from the Rust implementation
|
|
@@ -8,11 +7,12 @@ export declare function paymentFrequencyToSeconds(frequency: PaymentFrequency):
|
|
|
8
7
|
/**
|
|
9
8
|
* Converts a payment frequency string to seconds
|
|
10
9
|
* Uses auto-generated mapping from Rust PaymentFrequency enum
|
|
10
|
+
* Handles both "@daily" format (from contracts) and "daily" format (from mapping)
|
|
11
11
|
*/
|
|
12
|
-
export declare function paymentFrequencyStringToSeconds(frequencyString:
|
|
12
|
+
export declare function paymentFrequencyStringToSeconds(frequencyString: string): number;
|
|
13
13
|
/**
|
|
14
14
|
* Validates that a duration is a multiple of the payment frequency
|
|
15
15
|
* Uses auto-generated types from Rust PaymentFrequency enum
|
|
16
16
|
*/
|
|
17
|
-
export declare function validateDurationAlignment(duration: number | bigint, frequencyString:
|
|
17
|
+
export declare function validateDurationAlignment(duration: number | bigint, frequencyString: string): void;
|
|
18
18
|
//# sourceMappingURL=paymentFrequency.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentFrequency.d.ts","sourceRoot":"","sources":["../../../src/utils/paymentFrequency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"paymentFrequency.d.ts","sourceRoot":"","sources":["../../../src/utils/paymentFrequency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAuBpE;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,gBAAgB,GAAG,MAAM,CAkB7E;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAY/E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,eAAe,EAAE,MAAM,GACtB,IAAI,CASN"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # PDA Derivation Utilities for Multi-Program Architecture
|
|
3
|
+
*
|
|
4
|
+
* The SRSLY rental system integrates with multiple Solana programs, each requiring
|
|
5
|
+
* PDAs to be derived using their specific program IDs for proper cross-program
|
|
6
|
+
* invocation (CPI) and account ownership.
|
|
7
|
+
*
|
|
8
|
+
* ## Program Responsibilities:
|
|
9
|
+
* - **SRSLY Program**: Contract, Rental State, Rental Authority PDAs
|
|
10
|
+
* - **Antegen Program**: Automated payment threads via Clockwork scheduling
|
|
11
|
+
* - **Profile Program**: Star Atlas SAGE profiles and starbase management
|
|
12
|
+
* - **Player Faction Program**: Player faction enrollment in SAGE ecosystem
|
|
13
|
+
*
|
|
14
|
+
* ## Cross-Program Integration:
|
|
15
|
+
* Each program owns its respective PDAs and must be used for derivation to
|
|
16
|
+
* ensure proper account ownership and enable CPI calls between programs.
|
|
17
|
+
*
|
|
18
|
+
* @note Future Enhancement: Consider requesting codama to auto-generate PDA
|
|
19
|
+
* utilities alongside instruction code to reduce manual maintenance.
|
|
20
|
+
*/
|
|
21
|
+
import { type Address } from '@solana/kit';
|
|
22
|
+
/**
|
|
23
|
+
* Derives the rental contract PDA using the SRSLY program ID
|
|
24
|
+
*
|
|
25
|
+
* Contract PDAs are derived from the fleet address and provide deterministic
|
|
26
|
+
* addresses for rental contracts without requiring a private key. The SDK
|
|
27
|
+
* automatically resolves the correct SRSLY program address for the current network
|
|
28
|
+
* unless a specific program ID is provided.
|
|
29
|
+
*
|
|
30
|
+
* @param fleet - The fleet address to create a contract for
|
|
31
|
+
* @param srslyProgramId - Optional SRSLY program ID (defaults to network-resolved address)
|
|
32
|
+
* @returns The contract PDA derived using SRSLY program ID
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Use network-resolved program address (recommended)
|
|
37
|
+
* const contractAddress = await deriveContract('FleetAddress123...');
|
|
38
|
+
*
|
|
39
|
+
* // Use specific program address
|
|
40
|
+
* const contractAddress = await deriveContract(
|
|
41
|
+
* 'FleetAddress123...',
|
|
42
|
+
* 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT'
|
|
43
|
+
* );
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function deriveContract(fleet: string | Address, srslyProgramId?: string | Address): Promise<Address>;
|
|
47
|
+
/**
|
|
48
|
+
* Derives the rental thread PDA using the Antegen program ID
|
|
49
|
+
*
|
|
50
|
+
* Thread accounts are managed by the Antegen program, so they must be derived
|
|
51
|
+
* using the Antegen program ID rather than the SRSLY program ID. The SDK
|
|
52
|
+
* automatically resolves the correct Antegen program address for the current network
|
|
53
|
+
* unless a specific program ID is provided.
|
|
54
|
+
*
|
|
55
|
+
* @param rentalAuthority - The rental authority PDA (derived with SRSLY program)
|
|
56
|
+
* @param rentalState - The rental state PDA (derived with SRSLY program)
|
|
57
|
+
* @param antegenProgramId - Optional Antegen program ID (defaults to network-resolved address)
|
|
58
|
+
* @returns The rental thread PDA derived using Antegen program ID
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Use network-resolved program address (recommended)
|
|
63
|
+
* const threadPda = await deriveRentalThread(rentalAuthorityPda, rentalStatePda);
|
|
64
|
+
*
|
|
65
|
+
* // Use specific program address
|
|
66
|
+
* const threadPda = await deriveRentalThread(
|
|
67
|
+
* rentalAuthorityPda,
|
|
68
|
+
* rentalStatePda,
|
|
69
|
+
* 'AgThdyi1P5RkVeZD2rQahTvs8HePJoGFFxKtvok5s2J1'
|
|
70
|
+
* );
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function deriveRentalThread(rentalAuthority: Address, rentalState: Address, antegenProgramId?: Address): Promise<Address>;
|
|
74
|
+
/**
|
|
75
|
+
* Derives the rental state PDA using the SRSLY program ID
|
|
76
|
+
*
|
|
77
|
+
* The SDK automatically resolves the correct SRSLY program address for the current network
|
|
78
|
+
* unless a specific program ID is provided.
|
|
79
|
+
*
|
|
80
|
+
* @param contract - The rental contract address
|
|
81
|
+
* @param borrower - The borrower's public key
|
|
82
|
+
* @param srslyProgramId - Optional SRSLY program ID (defaults to network-resolved address)
|
|
83
|
+
* @returns The rental state PDA
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // Use network-resolved program address (recommended)
|
|
88
|
+
* const rentalStateAddress = await deriveRentalState(contractAddress, borrowerAddress);
|
|
89
|
+
*
|
|
90
|
+
* // Use specific program address
|
|
91
|
+
* const rentalStateAddress = await deriveRentalState(
|
|
92
|
+
* contractAddress,
|
|
93
|
+
* borrowerAddress,
|
|
94
|
+
* 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT'
|
|
95
|
+
* );
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function deriveRentalState(contract: Address, borrower: Address, srslyProgramId?: Address): Promise<Address>;
|
|
99
|
+
/**
|
|
100
|
+
* Derives the rental authority PDA using the SRSLY program ID
|
|
101
|
+
*
|
|
102
|
+
* The SDK automatically resolves the correct SRSLY program address for the current network
|
|
103
|
+
* unless a specific program ID is provided.
|
|
104
|
+
*
|
|
105
|
+
* @param srslyProgramId - Optional SRSLY program ID (defaults to network-resolved address)
|
|
106
|
+
* @returns The rental authority PDA
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* // Use network-resolved program address (recommended)
|
|
111
|
+
* const rentalAuthorityAddress = await deriveRentalAuthority();
|
|
112
|
+
*
|
|
113
|
+
* // Use specific program address
|
|
114
|
+
* const rentalAuthorityAddress = await deriveRentalAuthority(
|
|
115
|
+
* 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT'
|
|
116
|
+
* );
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function deriveRentalAuthority(srslyProgramId?: Address): Promise<Address>;
|
|
120
|
+
//# sourceMappingURL=pda.d.ts.map
|
|
@@ -0,0 +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,CAAC,OAAO,CAAC,CAoBlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,kBAAkB,CACtC,eAAe,EAAE,OAAO,EACxB,WAAW,EAAE,OAAO,EACpB,gBAAgB,CAAC,EAAE,OAAO,GACzB,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,qBAAqB,CACzC,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,CAAC,OAAO,CAAC,CAalB"}
|
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.41",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"sdk"
|
|
47
47
|
],
|
|
48
48
|
"scripts": {
|
|
49
|
-
"
|
|
49
|
+
"build": "anchor run build && pnpm run package:cjs && pnpm run package:esm && pnpm run generate",
|
|
50
|
+
"build:clean": "pnpm run clean && pnpm run build",
|
|
50
51
|
"package:cjs": "tsc -p tsconfig.cjs.json && tsconfig-to-dual-package tsconfig.cjs.json",
|
|
51
52
|
"package:esm": "tsc -p tsconfig.esm.json && tsconfig-to-dual-package tsconfig.esm.json",
|
|
52
53
|
"clean": "rm -rf dist && cargo clean && pnpm install",
|
|
53
54
|
"generate": "node generate.mjs",
|
|
54
|
-
"build": "anchor build && pnpm run generate",
|
|
55
55
|
"docs": "typedoc",
|
|
56
56
|
"test": "vitest run",
|
|
57
57
|
"test:watch": "vitest",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"license": "ISC",
|
|
62
62
|
"packageManager": "pnpm@10.6.5",
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@solana/kit": "^2.
|
|
64
|
+
"@solana/kit": "^2.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@codama/nodes-from-anchor": "^1.1.13",
|
|
@@ -74,4 +74,4 @@
|
|
|
74
74
|
"vitest": "^3.2.4",
|
|
75
75
|
"webpack": "^5.99.9"
|
|
76
76
|
}
|
|
77
|
-
}
|
|
77
|
+
}
|