@wuwei-labs/srsly 2.0.0-beta.26 → 2.0.0-beta.28
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 +189 -97
- package/dist/cjs/contract/close.js +33 -24
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +67 -52
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/package.json +2 -13
- package/dist/cjs/rental/accept.js +35 -29
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +13 -9
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +15 -11
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +20 -17
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +0 -88
- package/dist/cjs/utils/config.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 +49 -0
- package/dist/cjs/utils/instruction-converter.js.map +1 -0
- package/dist/esm/contract/close.js +34 -25
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +67 -51
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/package.json +2 -13
- package/dist/esm/rental/accept.js +36 -30
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +13 -9
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +15 -11
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset.js +22 -19
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/config.js +0 -88
- package/dist/esm/utils/config.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 +45 -0
- package/dist/esm/utils/instruction-converter.js.map +1 -0
- package/dist/types/contract/close.d.ts +12 -11
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +49 -65
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts +32 -28
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +16 -12
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +16 -13
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts +19 -16
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +0 -95
- package/dist/types/utils/config.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 +76 -0
- package/dist/types/utils/instruction-converter.d.ts.map +1 -0
- package/dist/types/utils/types.d.ts +0 -8
- package/dist/types/utils/types.d.ts.map +1 -1
- package/package.json +2 -13
- package/dist/cjs/utils/pack-functions.js +0 -148
- package/dist/cjs/utils/pack-functions.js.map +0 -1
- package/dist/cjs/utils/solana-adapter.js +0 -120
- package/dist/cjs/utils/solana-adapter.js.map +0 -1
- package/dist/esm/utils/pack-functions.js +0 -110
- package/dist/esm/utils/pack-functions.js.map +0 -1
- package/dist/esm/utils/solana-adapter.js +0 -82
- package/dist/esm/utils/solana-adapter.js.map +0 -1
- package/dist/types/utils/pack-functions.d.ts +0 -18
- package/dist/types/utils/pack-functions.d.ts.map +0 -1
- package/dist/types/utils/solana-adapter.d.ts +0 -26
- package/dist/types/utils/solana-adapter.d.ts.map +0 -1
|
@@ -1,87 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Unified contract creation - works with both @solana/kit and @solana/web3.js
|
|
3
|
+
* Uses strings for all addresses to eliminate library-specific type complexity
|
|
4
|
+
*/
|
|
3
5
|
import { PaymentFrequencyString } from '../types/paymentFrequency';
|
|
4
|
-
type
|
|
6
|
+
import { type FluentInstruction, type FluentConfigSelector } from '../utils/instruction-converter';
|
|
7
|
+
type UniversalAddress = string;
|
|
8
|
+
type UniversalSigner = any;
|
|
5
9
|
/**
|
|
6
|
-
* Simplified parameters for creating a rental contract
|
|
10
|
+
* Simplified parameters for creating a rental contract - strings only!
|
|
7
11
|
*/
|
|
8
12
|
export interface CreateContractParams {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* The fleet account address to be rented out
|
|
15
|
-
*/
|
|
16
|
-
fleet: string | Address<string>;
|
|
17
|
-
/**
|
|
18
|
-
* The owner's profile account address
|
|
19
|
-
*/
|
|
20
|
-
ownerProfile: string | Address<string>;
|
|
21
|
-
/**
|
|
22
|
-
* The rental rate in ATLAS tokens
|
|
23
|
-
*/
|
|
24
|
-
rate: number | bigint;
|
|
25
|
-
/**
|
|
26
|
-
* The maximum rental duration in seconds
|
|
27
|
-
* Must be a multiple of the payment frequency interval
|
|
28
|
-
* e.g., 2592000 for "30 days" with daily frequency, 86400 for "24 hours" with hourly frequency
|
|
29
|
-
*/
|
|
30
|
-
durationMax: number | bigint;
|
|
31
|
-
/**
|
|
32
|
-
* The payment frequency (e.g., "daily", "weekly", "monthly")
|
|
33
|
-
* Valid values are auto-generated from Rust PaymentFrequency enum
|
|
34
|
-
* Note: Do not include the '@' prefix - it will be added automatically
|
|
35
|
-
* The minimum rental duration will be automatically set to the payment frequency interval
|
|
36
|
-
*/
|
|
13
|
+
owner: UniversalSigner | UniversalAddress;
|
|
14
|
+
fleet: UniversalAddress;
|
|
15
|
+
ownerProfile: UniversalAddress;
|
|
16
|
+
rate: number;
|
|
17
|
+
durationMax: number;
|
|
37
18
|
paymentsFreq: PaymentFrequencyString;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*/
|
|
19
|
+
gameId?: UniversalAddress;
|
|
20
|
+
sageProgramAddress?: UniversalAddress;
|
|
21
|
+
atlasMint?: UniversalAddress;
|
|
42
22
|
ownerKeyIndex?: number;
|
|
43
|
-
/**
|
|
44
|
-
* The game ID account address
|
|
45
|
-
* If not provided, will use network-specific default
|
|
46
|
-
*/
|
|
47
|
-
gameId?: string | Address<string>;
|
|
48
|
-
/**
|
|
49
|
-
* The ATLAS mint address
|
|
50
|
-
* If not provided, will use the default ATLAS mint
|
|
51
|
-
*/
|
|
52
|
-
mint?: string | Address<string>;
|
|
53
23
|
}
|
|
54
24
|
/**
|
|
55
25
|
* Creates an instruction to create a rental contract with fluent configuration.
|
|
26
|
+
* This unified version works with both @solana/kit and @solana/web3.js using strings for addresses.
|
|
56
27
|
*
|
|
57
28
|
* @example
|
|
58
29
|
* ```typescript
|
|
59
|
-
* //
|
|
60
|
-
* const ix = await createContract(params);
|
|
30
|
+
* // Works with any library - just use strings for addresses!
|
|
61
31
|
*
|
|
62
|
-
* //
|
|
63
|
-
* const
|
|
64
|
-
*
|
|
65
|
-
* //
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
32
|
+
* // Default returns @solana/kit format
|
|
33
|
+
* const kitInstruction = await createContract({
|
|
34
|
+
* owner: wallet, // Can be signer object or string
|
|
35
|
+
* fleet: "FleetAddress123...", // String address
|
|
36
|
+
* ownerProfile: "ProfileAddr...", // String address
|
|
37
|
+
* rate: 1000,
|
|
38
|
+
* durationMax: days(7),
|
|
39
|
+
* paymentsFreq: 'daily'
|
|
70
40
|
* });
|
|
71
41
|
*
|
|
72
|
-
* //
|
|
73
|
-
* const
|
|
74
|
-
*
|
|
75
|
-
*
|
|
42
|
+
* // Convert to @solana/web3.js format using fluent interface
|
|
43
|
+
* const web3jsInstruction = await createContract({
|
|
44
|
+
* owner: wallet,
|
|
45
|
+
* fleet: "FleetAddress123...",
|
|
46
|
+
* ownerProfile: "ProfileAddr...",
|
|
47
|
+
* rate: 1000,
|
|
48
|
+
* durationMax: days(7),
|
|
49
|
+
* paymentsFreq: 'daily'
|
|
50
|
+
* }).web3js();
|
|
51
|
+
*
|
|
52
|
+
* // Chain configuration and format conversion
|
|
53
|
+
* const web3jsInstructionWithConfig = await createContract({
|
|
54
|
+
* owner: wallet,
|
|
55
|
+
* fleet: "FleetAddress123...",
|
|
56
|
+
* ownerProfile: "ProfileAddr...",
|
|
57
|
+
* rate: 1000,
|
|
58
|
+
* durationMax: days(7),
|
|
59
|
+
* paymentsFreq: 'daily'
|
|
60
|
+
* }).set({ programs: 'mainnet' }).web3js();
|
|
61
|
+
*
|
|
62
|
+
* // Use with your preferred Solana library
|
|
63
|
+
* const transaction = new Transaction().add(web3jsInstruction);
|
|
76
64
|
* ```
|
|
77
65
|
*
|
|
78
66
|
* @param params The simplified parameters for creating a rental contract
|
|
79
67
|
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
80
68
|
*/
|
|
81
|
-
export declare function createContract(params: CreateContractParams):
|
|
82
|
-
/**
|
|
83
|
-
* Export config selector for getCreateContractInstructionAsync
|
|
84
|
-
*/
|
|
85
|
-
export declare function getCreateContractInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
69
|
+
export declare function createContract(params: CreateContractParams): FluentConfigSelector<FluentInstruction>;
|
|
86
70
|
export {};
|
|
87
71
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,sBAAsB,EAA2B,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAuD,KAAK,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGxJ,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAC/B,KAAK,eAAe,GAAG,GAAG,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CAAC;IAC1C,KAAK,EAAE,gBAAgB,CAAC;IACxB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,sBAAsB,CAAC;IACrC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA8DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAGpG"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { Address, TransactionSigner } from '@solana/kit';
|
|
2
1
|
import { type ConfigSelector } from '../utils/config';
|
|
3
|
-
type
|
|
2
|
+
import { type FluentInstruction, type FluentConfigSelector } from '../utils/instruction-converter';
|
|
3
|
+
type UniversalAddress = string;
|
|
4
|
+
type UniversalSigner = any;
|
|
4
5
|
/**
|
|
5
|
-
* Simplified parameters for accepting a rental
|
|
6
|
+
* Simplified parameters for accepting a rental - strings only!
|
|
6
7
|
*/
|
|
7
8
|
export interface AcceptRentalParams {
|
|
8
9
|
/**
|
|
9
|
-
* The borrower wallet that will sign the transaction
|
|
10
|
+
* The borrower wallet that will sign the transaction (can be signer or string)
|
|
10
11
|
*/
|
|
11
|
-
borrower:
|
|
12
|
+
borrower: UniversalSigner | UniversalAddress;
|
|
12
13
|
/**
|
|
13
14
|
* The borrower's profile account address
|
|
14
15
|
*/
|
|
15
|
-
borrowerProfile:
|
|
16
|
+
borrowerProfile: UniversalAddress;
|
|
16
17
|
/**
|
|
17
18
|
* The borrower's faction (1 = mud, 2 = oni, 3 = ustur)
|
|
18
19
|
* Or as string: 'mud', 'oni', 'ustur'
|
|
@@ -21,16 +22,16 @@ export interface AcceptRentalParams {
|
|
|
21
22
|
/**
|
|
22
23
|
* The fleet account address that will be rented
|
|
23
24
|
*/
|
|
24
|
-
fleet:
|
|
25
|
+
fleet: UniversalAddress;
|
|
25
26
|
/**
|
|
26
27
|
* The rental contract account address
|
|
27
28
|
*/
|
|
28
|
-
contract:
|
|
29
|
+
contract: UniversalAddress;
|
|
29
30
|
/**
|
|
30
31
|
* The game ID account address
|
|
31
32
|
* If not provided, will use network-specific default
|
|
32
33
|
*/
|
|
33
|
-
gameId?:
|
|
34
|
+
gameId?: UniversalAddress;
|
|
34
35
|
/**
|
|
35
36
|
* The rental rate (in ATLAS tokens)
|
|
36
37
|
*/
|
|
@@ -43,50 +44,53 @@ export interface AcceptRentalParams {
|
|
|
43
44
|
* Optional referral token account address
|
|
44
45
|
* If provided, referrer will receive 5% of the platform fees
|
|
45
46
|
*/
|
|
46
|
-
referralTokenAccount?:
|
|
47
|
+
referralTokenAccount?: UniversalAddress;
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Creates an instruction to accept a rental with fluent configuration.
|
|
50
51
|
*
|
|
51
52
|
* @example
|
|
52
53
|
* ```typescript
|
|
53
|
-
* //
|
|
54
|
-
* const
|
|
55
|
-
* borrower: wallet,
|
|
56
|
-
* borrowerProfile:
|
|
57
|
-
* borrowerFaction: 1,
|
|
58
|
-
* fleet:
|
|
59
|
-
* contract:
|
|
60
|
-
* rate: 1000,
|
|
61
|
-
* duration: 86400
|
|
54
|
+
* // Works with any library - just use strings for addresses!
|
|
55
|
+
* const instruction = await acceptRental({
|
|
56
|
+
* borrower: wallet, // Can be signer object or string
|
|
57
|
+
* borrowerProfile: "ProfileAddr...", // String address
|
|
58
|
+
* borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
|
|
59
|
+
* fleet: "FleetAddress123...", // String address
|
|
60
|
+
* contract: "ContractAddr...", // String address
|
|
61
|
+
* rate: 1000, // ATLAS tokens
|
|
62
|
+
* duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
|
|
62
63
|
* });
|
|
63
64
|
*
|
|
64
65
|
* // With referral (referrer gets 5% of platform fees)
|
|
65
|
-
* const
|
|
66
|
+
* const instruction = await acceptRental({
|
|
66
67
|
* borrower: wallet,
|
|
67
|
-
* borrowerProfile:
|
|
68
|
+
* borrowerProfile: "ProfileAddr...",
|
|
68
69
|
* borrowerFaction: 1,
|
|
69
|
-
* fleet:
|
|
70
|
-
* contract:
|
|
70
|
+
* fleet: "FleetAddress123...",
|
|
71
|
+
* contract: "ContractAddr...",
|
|
71
72
|
* rate: 1000,
|
|
72
73
|
* duration: 86400,
|
|
73
|
-
* referralTokenAccount:
|
|
74
|
+
* referralTokenAccount: "ReferralAddr..."
|
|
74
75
|
* });
|
|
75
76
|
*
|
|
76
77
|
* // Use mainnet configuration
|
|
77
|
-
* const
|
|
78
|
+
* const instruction = await acceptRental(params).set({ programs: 'mainnet' });
|
|
78
79
|
*
|
|
79
80
|
* // Override specific constants
|
|
80
|
-
* const
|
|
81
|
-
*
|
|
81
|
+
* const instruction = await acceptRental(params).set({
|
|
82
|
+
* programs: 'mainnet',
|
|
82
83
|
* gameId: 'custom-game-id...'
|
|
83
84
|
* });
|
|
85
|
+
*
|
|
86
|
+
* // Use the instruction with your preferred Solana library
|
|
87
|
+
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
84
88
|
* ```
|
|
85
89
|
*
|
|
86
90
|
* @param params The simplified parameters for accepting a rental
|
|
87
91
|
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
88
92
|
*/
|
|
89
|
-
export declare function acceptRental(params: AcceptRentalParams):
|
|
93
|
+
export declare function acceptRental(params: AcceptRentalParams): FluentConfigSelector<FluentInstruction>;
|
|
90
94
|
export declare function getAcceptRentalInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
91
95
|
export {};
|
|
92
96
|
//# sourceMappingURL=accept.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAG3G,OAAO,EAAuD,KAAK,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGxJ,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAC/B,KAAK,eAAe,GAAG,GAAG,CAAC;AAG3B;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,eAAe,GAAG,gBAAgB,CAAC;IAE7C;;OAEG;IACH,eAAe,EAAE,gBAAgB,CAAC;IAElC;;;OAGG;IACH,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC;IAEjC;;OAEG;IACH,KAAK,EAAE,gBAAgB,CAAC;IAExB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,gBAAgB,CAAC;CACzC;AAqED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,oBAAoB,CAAC,iBAAiB,CAAC,CAGzC;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK9F"}
|
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
import { Address, TransactionSigner } from '@solana/kit';
|
|
2
1
|
import { type ConfigSelector } from '../utils/config';
|
|
2
|
+
type UniversalAddress = string;
|
|
3
|
+
type UniversalSigner = any;
|
|
3
4
|
type CancelRentalInstruction = any;
|
|
4
5
|
/**
|
|
5
|
-
* Simplified parameters for canceling a rental
|
|
6
|
+
* Simplified parameters for canceling a rental - strings only!
|
|
6
7
|
*/
|
|
7
8
|
export interface CancelRentalParams {
|
|
8
9
|
/**
|
|
9
|
-
* The borrower wallet that will sign the transaction
|
|
10
|
+
* The borrower wallet that will sign the transaction (can be signer or string)
|
|
10
11
|
*/
|
|
11
|
-
borrower:
|
|
12
|
+
borrower: UniversalSigner | UniversalAddress;
|
|
12
13
|
/**
|
|
13
14
|
* The rental contract account address
|
|
14
15
|
*/
|
|
15
|
-
contract:
|
|
16
|
+
contract: UniversalAddress;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Creates an instruction to cancel a rental with fluent configuration.
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* ```typescript
|
|
22
|
-
* //
|
|
23
|
-
* const
|
|
24
|
-
* borrower: wallet,
|
|
25
|
-
* contract:
|
|
23
|
+
* // Works with any library - just use strings for addresses!
|
|
24
|
+
* const instruction = await cancelRental({
|
|
25
|
+
* borrower: wallet, // Can be signer object or string
|
|
26
|
+
* contract: "ContractAddr..." // String address
|
|
26
27
|
* });
|
|
27
28
|
*
|
|
28
29
|
* // Use mainnet configuration
|
|
29
|
-
* const
|
|
30
|
+
* const instruction = await cancelRental(params).set({ programs: 'mainnet' });
|
|
30
31
|
*
|
|
31
32
|
* // Override specific constants
|
|
32
|
-
* const
|
|
33
|
-
*
|
|
33
|
+
* const instruction = await cancelRental(params).set({
|
|
34
|
+
* programs: 'mainnet',
|
|
34
35
|
* sageProgramAddress: 'custom...'
|
|
35
36
|
* });
|
|
37
|
+
*
|
|
38
|
+
* // Use the instruction with your preferred Solana library
|
|
39
|
+
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
36
40
|
* ```
|
|
37
41
|
*
|
|
38
42
|
* @param params The simplified parameters for canceling a rental
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAI3G,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAC/B,KAAK,eAAe,GAAG,GAAG,CAAC;AAC3B,KAAK,uBAAuB,GAAG,GAAG,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,eAAe,GAAG,gBAAgB,CAAC;IAE7C;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,cAAc,CAAC,uBAAuB,CAAC,CAEzC;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK9F"}
|
|
@@ -1,43 +1,46 @@
|
|
|
1
|
-
import { Address } from '@solana/kit';
|
|
2
1
|
import { type ConfigSelector } from '../utils/config';
|
|
2
|
+
type UniversalAddress = string;
|
|
3
3
|
type CloseRentalInstruction = any;
|
|
4
4
|
/**
|
|
5
|
-
* Simplified parameters for closing a rental
|
|
5
|
+
* Simplified parameters for closing a rental - strings only!
|
|
6
6
|
*/
|
|
7
7
|
export interface CloseRentalParams {
|
|
8
8
|
/**
|
|
9
9
|
* The borrower address (not a signer in this transaction)
|
|
10
10
|
*/
|
|
11
|
-
borrower:
|
|
11
|
+
borrower: UniversalAddress;
|
|
12
12
|
/**
|
|
13
13
|
* The owner's token account address for receiving ATLAS
|
|
14
14
|
*/
|
|
15
|
-
ownerTokenAccount:
|
|
15
|
+
ownerTokenAccount: UniversalAddress;
|
|
16
16
|
/**
|
|
17
17
|
* The rental contract account address
|
|
18
18
|
*/
|
|
19
|
-
contract:
|
|
19
|
+
contract: UniversalAddress;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Creates an instruction to close a rental with fluent configuration.
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* ```typescript
|
|
26
|
-
* //
|
|
27
|
-
* const
|
|
28
|
-
* borrower:
|
|
29
|
-
* ownerTokenAccount:
|
|
30
|
-
* contract:
|
|
26
|
+
* // Works with any library - just use strings for addresses!
|
|
27
|
+
* const instruction = await closeRental({
|
|
28
|
+
* borrower: "BorrowerAddr...", // String address
|
|
29
|
+
* ownerTokenAccount: "TokenAcct...", // String address
|
|
30
|
+
* contract: "ContractAddr..." // String address
|
|
31
31
|
* });
|
|
32
32
|
*
|
|
33
33
|
* // Use mainnet configuration
|
|
34
|
-
* const
|
|
34
|
+
* const instruction = await closeRental(params).set({ programs: 'mainnet' });
|
|
35
35
|
*
|
|
36
36
|
* // Override specific constants
|
|
37
|
-
* const
|
|
38
|
-
*
|
|
37
|
+
* const instruction = await closeRental(params).set({
|
|
38
|
+
* programs: 'mainnet',
|
|
39
39
|
* sageProgramAddress: 'custom...'
|
|
40
40
|
* });
|
|
41
|
+
*
|
|
42
|
+
* // Use the instruction with your preferred Solana library
|
|
43
|
+
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
41
44
|
* ```
|
|
42
45
|
*
|
|
43
46
|
* @param params The simplified parameters for closing a rental
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAI3G,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAC/B,KAAK,sBAAsB,GAAG,GAAG,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAkCD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,iBAAiB,GACxB,cAAc,CAAC,sBAAsB,CAAC,CAExC;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK7F"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Address } from '@solana/kit';
|
|
2
1
|
import { type ConfigSelector } from '../utils/config';
|
|
2
|
+
type UniversalAddress = string;
|
|
3
3
|
type ResetRentalInstruction = any;
|
|
4
4
|
/**
|
|
5
|
-
* Simplified parameters for resetting a rental
|
|
5
|
+
* Simplified parameters for resetting a rental - strings only!
|
|
6
6
|
*/
|
|
7
7
|
export interface ResetRentalParams {
|
|
8
8
|
/**
|
|
9
9
|
* The fleet account address
|
|
10
10
|
*/
|
|
11
|
-
fleet:
|
|
11
|
+
fleet: UniversalAddress;
|
|
12
12
|
/**
|
|
13
13
|
* The rental contract account address
|
|
14
14
|
*/
|
|
15
|
-
contract:
|
|
15
|
+
contract: UniversalAddress;
|
|
16
16
|
/**
|
|
17
17
|
* The rental state account address
|
|
18
18
|
*/
|
|
19
|
-
rentalState:
|
|
19
|
+
rentalState: UniversalAddress;
|
|
20
20
|
/**
|
|
21
21
|
* The game ID account address
|
|
22
22
|
* If not provided, will use network-specific default
|
|
23
23
|
*/
|
|
24
|
-
gameId?:
|
|
24
|
+
gameId?: UniversalAddress;
|
|
25
25
|
/**
|
|
26
26
|
* Optional faction (1 = mud, 2 = oni, 3 = ustur)
|
|
27
27
|
* Or as string: 'mud', 'oni', 'ustur'
|
|
@@ -32,31 +32,34 @@ export interface ResetRentalParams {
|
|
|
32
32
|
* The owner's profile address
|
|
33
33
|
* Needed only if faction is provided to derive starbasePlayer
|
|
34
34
|
*/
|
|
35
|
-
ownerProfile:
|
|
35
|
+
ownerProfile: UniversalAddress;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Creates an instruction to reset a rental with fluent configuration.
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
41
|
* ```typescript
|
|
42
|
-
* //
|
|
43
|
-
* const
|
|
44
|
-
* fleet:
|
|
45
|
-
* contract:
|
|
46
|
-
* rentalState:
|
|
42
|
+
* // Works with any library - just use strings for addresses!
|
|
43
|
+
* const instruction = await resetRental({
|
|
44
|
+
* fleet: "FleetAddress123...", // String address
|
|
45
|
+
* contract: "ContractAddr...", // String address
|
|
46
|
+
* rentalState: "RentalStateAddr...", // String address
|
|
47
47
|
* faction: 'mud',
|
|
48
|
-
* ownerProfile:
|
|
48
|
+
* ownerProfile: "OwnerProfileAddr..." // String address
|
|
49
49
|
* });
|
|
50
50
|
*
|
|
51
51
|
* // Use mainnet configuration
|
|
52
|
-
* const
|
|
52
|
+
* const instruction = await resetRental(params).set({ programs: 'mainnet' });
|
|
53
53
|
*
|
|
54
54
|
* // Override specific constants
|
|
55
|
-
* const
|
|
56
|
-
*
|
|
55
|
+
* const instruction = await resetRental(params).set({
|
|
56
|
+
* programs: 'mainnet',
|
|
57
57
|
* gameId: 'custom-game-id...',
|
|
58
58
|
* sageProgramAddress: 'custom...'
|
|
59
59
|
* });
|
|
60
|
+
*
|
|
61
|
+
* // Use the instruction with your preferred Solana library
|
|
62
|
+
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
60
63
|
* ```
|
|
61
64
|
*
|
|
62
65
|
* @param params The simplified parameters for resetting a rental
|
|
@@ -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,EAAmC,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAK3G,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAC/B,KAAK,sBAAsB,GAAG,GAAG,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,KAAK,EAAE,gBAAgB,CAAC;IAExB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;OAEG;IACH,WAAW,EAAE,gBAAgB,CAAC;IAE9B;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;;OAGG;IACH,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAuDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,iBAAiB,GACxB,cAAc,CAAC,sBAAsB,CAAC,CAExC;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK7F"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Network configuration for the SRSLY SDK
|
|
3
3
|
*/
|
|
4
|
-
import { SolanaLibrary } from './solana-adapter';
|
|
5
|
-
import { UniversalAddress, UniversalTransactionSigner } from './types';
|
|
6
4
|
export type ProgramSet = 'mainnet' | 'atlasnet' | 'holosim';
|
|
7
5
|
/**
|
|
8
6
|
* Configuration options that can be set globally or overridden per call
|
|
@@ -13,12 +11,6 @@ export interface ConfigOptions {
|
|
|
13
11
|
profileFactionProgramAddress?: string;
|
|
14
12
|
gameId?: string;
|
|
15
13
|
atlasMint?: string;
|
|
16
|
-
rpcUrl?: string;
|
|
17
|
-
solanaLibrary?: SolanaLibrary;
|
|
18
|
-
transactionOptions?: {
|
|
19
|
-
commitment?: 'processed' | 'confirmed' | 'finalized';
|
|
20
|
-
skipPreflight?: boolean;
|
|
21
|
-
};
|
|
22
14
|
}
|
|
23
15
|
/**
|
|
24
16
|
* Resolve program addresses based on configuration
|
|
@@ -31,7 +23,6 @@ export declare function resolveProgramAddresses(config: ConfigOptions): {
|
|
|
31
23
|
profileFactionProgramAddress: string;
|
|
32
24
|
gameId: string;
|
|
33
25
|
atlasMint: string;
|
|
34
|
-
rpcUrl: any;
|
|
35
26
|
};
|
|
36
27
|
/**
|
|
37
28
|
* Set global configuration options that will be used as defaults for all SDK operations
|
|
@@ -82,55 +73,6 @@ export declare function getModule(modulePath: 'instructions' | 'programs'): any;
|
|
|
82
73
|
* Get codama modules (network agnostic)
|
|
83
74
|
*/
|
|
84
75
|
export declare function getCachedNetworkModule<T = any>(modulePath: string): Promise<T>;
|
|
85
|
-
/**
|
|
86
|
-
* Interface for a packed transaction that can be sent or used with wallet adapters
|
|
87
|
-
*/
|
|
88
|
-
export interface PackedTransaction {
|
|
89
|
-
/** Raw transaction message bytes compatible with web3.js VersionedTransaction.deserialize() */
|
|
90
|
-
messageBytes: Uint8Array;
|
|
91
|
-
/** Transaction signature map (empty for unsigned transactions) */
|
|
92
|
-
signatures: any;
|
|
93
|
-
/**
|
|
94
|
-
* Send the packed transaction using the configured Solana library
|
|
95
|
-
*
|
|
96
|
-
* @param signer The transaction signer that will sign and pay for the transaction
|
|
97
|
-
* @returns Promise resolving to the transaction signature
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```typescript
|
|
101
|
-
* import { createKeyPairSignerFromBytes } from '@solana/kit';
|
|
102
|
-
*
|
|
103
|
-
* // Create signer from keypair bytes
|
|
104
|
-
* const signer = await createKeyPairSignerFromBytes(keypairBytes);
|
|
105
|
-
*
|
|
106
|
-
* // Pack transaction, then send (now chainable!)
|
|
107
|
-
* const signature = await createContract(params)
|
|
108
|
-
* .pack(signer.address)
|
|
109
|
-
* .send(signer);
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
send(signer: UniversalTransactionSigner): Promise<string>;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Chainable PackedTransaction that allows fluent .pack().send() without double await
|
|
116
|
-
*/
|
|
117
|
-
export interface ChainablePackedTransaction extends PackedTransaction {
|
|
118
|
-
/**
|
|
119
|
-
* Chainable send method that can be called directly on pack() result
|
|
120
|
-
*
|
|
121
|
-
* @param signer The transaction signer that will sign and pay for the transaction
|
|
122
|
-
* @returns Promise resolving to the transaction signature
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* // Now works without double await!
|
|
127
|
-
* const signature = await createContract(params)
|
|
128
|
-
* .pack(signer.address)
|
|
129
|
-
* .send(signer);
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
send(signer: UniversalTransactionSigner): Promise<string>;
|
|
133
|
-
}
|
|
134
76
|
/**
|
|
135
77
|
* Configuration selector for overriding network and constants
|
|
136
78
|
* Also implements PromiseLike to allow direct awaiting
|
|
@@ -144,43 +86,6 @@ export interface ConfigSelector<T> extends PromiseLike<T> {
|
|
|
144
86
|
* Build with current configuration (explicit call)
|
|
145
87
|
*/
|
|
146
88
|
build(): Promise<T>;
|
|
147
|
-
/**
|
|
148
|
-
* Pack using @solana/kit (modern, recommended)
|
|
149
|
-
*
|
|
150
|
-
* @param feePayer The address that will pay for the transaction fees
|
|
151
|
-
* @returns ChainablePackedTransaction optimized for @solana/kit
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* ```typescript
|
|
155
|
-
* import { createKeyPairSignerFromBytes } from '@solana/kit';
|
|
156
|
-
* const signer = await createKeyPairSignerFromBytes(keypairBytes);
|
|
157
|
-
* const signature = await createContract(params)
|
|
158
|
-
* .packKit(signer.address)
|
|
159
|
-
* .send(signer);
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
packKit(feePayer: UniversalAddress): ChainablePackedTransaction;
|
|
163
|
-
/**
|
|
164
|
-
* Pack using @solana/web3.js (wallet adapter compatibility)
|
|
165
|
-
*
|
|
166
|
-
* @param feePayer The address that will pay for the transaction fees
|
|
167
|
-
* @returns ChainablePackedTransaction optimized for @solana/web3.js
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```typescript
|
|
171
|
-
* const packedTx = await createContract(params).packWeb3js(wallet.publicKey);
|
|
172
|
-
* const versionedTx = new VersionedTransaction(VersionedMessage.deserialize(packedTx.messageBytes));
|
|
173
|
-
* const signedTx = await wallet.signTransaction(versionedTx);
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
packWeb3js(feePayer: UniversalAddress): ChainablePackedTransaction;
|
|
177
|
-
/**
|
|
178
|
-
* Pack using the configured or best available library
|
|
179
|
-
*
|
|
180
|
-
* @param feePayer The address that will pay for the transaction fees
|
|
181
|
-
* @returns ChainablePackedTransaction using the best available library
|
|
182
|
-
*/
|
|
183
|
-
pack(feePayer: UniversalAddress): ChainablePackedTransaction;
|
|
184
89
|
}
|
|
185
90
|
/**
|
|
186
91
|
* Create the initial fluent config selector for a function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAwB5D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,aAAa;;;;;;EAiB5D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAErD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAEzC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAGD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,aAAa,GAAG,aAAa,CAE3E;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,cAAc,GAAG,UAAU,GAAG,GAAG,CAEtE;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAKpF;AAID;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IACvD;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IAE/C;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB;AAsCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,GAChD,cAAc,CAAC,CAAC,CAAC,CAcnB"}
|
|
@@ -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"}
|
|
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"}
|