@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,6 +1,7 @@
|
|
|
1
1
|
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
2
|
import { getSageGameId, ATLAS_TO_STARDUST, toAddress } from '../utils/constants';
|
|
3
|
-
import { deriveGameAccounts
|
|
3
|
+
import { deriveGameAccounts } from '../utils';
|
|
4
|
+
import { createFluentInstruction, createFluentConfigSelector } from '../utils/instruction-converter';
|
|
4
5
|
/**
|
|
5
6
|
* Internal function to accept a rental instruction with configuration options
|
|
6
7
|
*/
|
|
@@ -16,16 +17,16 @@ async function _acceptRental(params, config) {
|
|
|
16
17
|
config);
|
|
17
18
|
// Let codama derive the rest (rentalThread, rentalState, rentalAuthority, etc.)
|
|
18
19
|
const input = {
|
|
19
|
-
borrower,
|
|
20
|
-
borrowerProfile: toAddress(borrowerProfile),
|
|
21
|
-
borrowerProfileFaction: profileFaction,
|
|
22
|
-
fleet: toAddress(fleet),
|
|
23
|
-
contract: toAddress(contract),
|
|
24
|
-
gameId: actualGameId,
|
|
25
|
-
starbase,
|
|
26
|
-
starbasePlayer,
|
|
27
|
-
amount,
|
|
28
|
-
duration,
|
|
20
|
+
borrower, // Pass as-is (string or signer)
|
|
21
|
+
borrowerProfile: toAddress(borrowerProfile), // Ensure string
|
|
22
|
+
borrowerProfileFaction: profileFaction, // Already string from deriveGameAccounts
|
|
23
|
+
fleet: toAddress(fleet), // Ensure string
|
|
24
|
+
contract: toAddress(contract), // Ensure string
|
|
25
|
+
gameId: actualGameId, // Already string
|
|
26
|
+
starbase, // Already string from deriveGameAccounts
|
|
27
|
+
starbasePlayer, // Already string from deriveGameAccounts
|
|
28
|
+
amount, // BigInt value
|
|
29
|
+
duration, // BigInt value
|
|
29
30
|
referralTokenAccount: referralTokenAccount ? toAddress(referralTokenAccount) : undefined,
|
|
30
31
|
};
|
|
31
32
|
// Get network-specific codama functions from centralized config
|
|
@@ -33,51 +34,56 @@ async function _acceptRental(params, config) {
|
|
|
33
34
|
const programsModule = getModule('programs');
|
|
34
35
|
const { getAcceptRentalInstructionAsync } = instructionsModule;
|
|
35
36
|
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
36
|
-
|
|
37
|
+
const rawInstruction = await getAcceptRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
38
|
+
return createFluentInstruction(rawInstruction);
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* Creates an instruction to accept a rental with fluent configuration.
|
|
40
42
|
*
|
|
41
43
|
* @example
|
|
42
44
|
* ```typescript
|
|
43
|
-
* //
|
|
44
|
-
* const
|
|
45
|
-
* borrower: wallet,
|
|
46
|
-
* borrowerProfile:
|
|
47
|
-
* borrowerFaction: 1,
|
|
48
|
-
* fleet:
|
|
49
|
-
* contract:
|
|
50
|
-
* rate: 1000,
|
|
51
|
-
* duration: 86400
|
|
45
|
+
* // Works with any library - just use strings for addresses!
|
|
46
|
+
* const instruction = await acceptRental({
|
|
47
|
+
* borrower: wallet, // Can be signer object or string
|
|
48
|
+
* borrowerProfile: "ProfileAddr...", // String address
|
|
49
|
+
* borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
|
|
50
|
+
* fleet: "FleetAddress123...", // String address
|
|
51
|
+
* contract: "ContractAddr...", // String address
|
|
52
|
+
* rate: 1000, // ATLAS tokens
|
|
53
|
+
* duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
|
|
52
54
|
* });
|
|
53
55
|
*
|
|
54
56
|
* // With referral (referrer gets 5% of platform fees)
|
|
55
|
-
* const
|
|
57
|
+
* const instruction = await acceptRental({
|
|
56
58
|
* borrower: wallet,
|
|
57
|
-
* borrowerProfile:
|
|
59
|
+
* borrowerProfile: "ProfileAddr...",
|
|
58
60
|
* borrowerFaction: 1,
|
|
59
|
-
* fleet:
|
|
60
|
-
* contract:
|
|
61
|
+
* fleet: "FleetAddress123...",
|
|
62
|
+
* contract: "ContractAddr...",
|
|
61
63
|
* rate: 1000,
|
|
62
64
|
* duration: 86400,
|
|
63
|
-
* referralTokenAccount:
|
|
65
|
+
* referralTokenAccount: "ReferralAddr..."
|
|
64
66
|
* });
|
|
65
67
|
*
|
|
66
68
|
* // Use mainnet configuration
|
|
67
|
-
* const
|
|
69
|
+
* const instruction = await acceptRental(params).set({ programs: 'mainnet' });
|
|
68
70
|
*
|
|
69
71
|
* // Override specific constants
|
|
70
|
-
* const
|
|
71
|
-
*
|
|
72
|
+
* const instruction = await acceptRental(params).set({
|
|
73
|
+
* programs: 'mainnet',
|
|
72
74
|
* gameId: 'custom-game-id...'
|
|
73
75
|
* });
|
|
76
|
+
*
|
|
77
|
+
* // Use the instruction with your preferred Solana library
|
|
78
|
+
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
74
79
|
* ```
|
|
75
80
|
*
|
|
76
81
|
* @param params The simplified parameters for accepting a rental
|
|
77
82
|
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
78
83
|
*/
|
|
79
84
|
export function acceptRental(params) {
|
|
80
|
-
|
|
85
|
+
const baseSelector = createConfigSelector((config) => _acceptRental(params, config));
|
|
86
|
+
return createFluentConfigSelector(baseSelector);
|
|
81
87
|
}
|
|
82
88
|
export function getAcceptRentalInstructionAsync(input, options) {
|
|
83
89
|
return createConfigSelector(async (config) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAqD,MAAM,gCAAgC,CAAC;AA4DxJ;;GAEG;AACH,KAAK,UAAU,aAAa,CAC1B,MAA0B,EAC1B,MAAsB;IAEtB,MAAM,EACJ,QAAQ,EACR,eAAe,EACf,eAAe,EACf,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,oBAAoB,GACrB,GAAG,MAAM,CAAC;IAEX,sFAAsF;IACtF,MAAM,YAAY,GAAG,MAAM,CAA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AG,MAAM,+BAA+B,CAC1D,KAAY,EACZ,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;IACF,OAAO,uBAAuB,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,YAAY,CAC1B,MAA0B;IAE1B,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrF,OAAO,0BAA0B,CAAC,YAAY,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
|
+
import { toAddress } from '../utils/constants';
|
|
2
3
|
/**
|
|
3
4
|
* Internal function to cancel a rental instruction with configuration options
|
|
4
5
|
*/
|
|
@@ -6,8 +7,8 @@ async function _cancelRental(params, config) {
|
|
|
6
7
|
const { borrower, contract, } = params;
|
|
7
8
|
// Let codama derive all the optional accounts
|
|
8
9
|
const input = {
|
|
9
|
-
borrower,
|
|
10
|
-
contract,
|
|
10
|
+
borrower, // Pass as-is (string or signer)
|
|
11
|
+
contract: toAddress(contract), // Ensure string
|
|
11
12
|
};
|
|
12
13
|
// Get network-specific codama functions from centralized config
|
|
13
14
|
const instructionsModule = getModule('instructions');
|
|
@@ -21,20 +22,23 @@ async function _cancelRental(params, config) {
|
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
23
24
|
* ```typescript
|
|
24
|
-
* //
|
|
25
|
-
* const
|
|
26
|
-
* borrower: wallet,
|
|
27
|
-
* contract:
|
|
25
|
+
* // Works with any library - just use strings for addresses!
|
|
26
|
+
* const instruction = await cancelRental({
|
|
27
|
+
* borrower: wallet, // Can be signer object or string
|
|
28
|
+
* contract: "ContractAddr..." // String address
|
|
28
29
|
* });
|
|
29
30
|
*
|
|
30
31
|
* // Use mainnet configuration
|
|
31
|
-
* const
|
|
32
|
+
* const instruction = await cancelRental(params).set({ programs: 'mainnet' });
|
|
32
33
|
*
|
|
33
34
|
* // Override specific constants
|
|
34
|
-
* const
|
|
35
|
-
*
|
|
35
|
+
* const instruction = await cancelRental(params).set({
|
|
36
|
+
* programs: 'mainnet',
|
|
36
37
|
* sageProgramAddress: 'custom...'
|
|
37
38
|
* });
|
|
39
|
+
*
|
|
40
|
+
* // Use the instruction with your preferred Solana library
|
|
41
|
+
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
38
42
|
* ```
|
|
39
43
|
*
|
|
40
44
|
* @param params The simplified parameters for canceling a rental
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAsB/C;;GAEG;AACH,KAAK,UAAU,aAAa,CAC1B,MAA0B,EAC1B,MAAsB;IAEtB,MAAM,EACJ,QAAQ,EACR,QAAQ,GACT,GAAG,MAAM,CAAC;IAEX,8CAA8C;IAC9C,MAAM,KAAK,GAAG;QACZ,QAAQ,EAAqB,gCAAgC;QAC7D,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,gBAAgB;KAChD,CAAC;IAEF,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,EAAE,+BAA+B,EAAE,GAAG,kBAAkB,CAAC;IAC/D,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC;IAEjD,OAAO,+BAA+B,CACpC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,YAAY,CAC1B,MAA0B;IAE1B,OAAO,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/esm/rental/close.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
|
+
import { toAddress } from '../utils/constants';
|
|
2
3
|
/**
|
|
3
4
|
* Internal function to close a rental instruction with configuration options
|
|
4
5
|
*/
|
|
@@ -6,9 +7,9 @@ async function _closeRental(params, config) {
|
|
|
6
7
|
const { borrower, ownerTokenAccount, contract, } = params;
|
|
7
8
|
// Let codama derive the optional accounts
|
|
8
9
|
const input = {
|
|
9
|
-
borrower,
|
|
10
|
-
ownerTokenAccount,
|
|
11
|
-
contract,
|
|
10
|
+
borrower: toAddress(borrower), // Ensure string
|
|
11
|
+
ownerTokenAccount: toAddress(ownerTokenAccount), // Ensure string
|
|
12
|
+
contract: toAddress(contract), // Ensure string
|
|
12
13
|
};
|
|
13
14
|
// Get network-specific codama functions from centralized config
|
|
14
15
|
const instructionsModule = getModule('instructions');
|
|
@@ -22,21 +23,24 @@ async function _closeRental(params, config) {
|
|
|
22
23
|
*
|
|
23
24
|
* @example
|
|
24
25
|
* ```typescript
|
|
25
|
-
* //
|
|
26
|
-
* const
|
|
27
|
-
* borrower:
|
|
28
|
-
* ownerTokenAccount:
|
|
29
|
-
* 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
|
|
30
31
|
* });
|
|
31
32
|
*
|
|
32
33
|
* // Use mainnet configuration
|
|
33
|
-
* const
|
|
34
|
+
* const instruction = await closeRental(params).set({ programs: 'mainnet' });
|
|
34
35
|
*
|
|
35
36
|
* // Override specific constants
|
|
36
|
-
* const
|
|
37
|
-
*
|
|
37
|
+
* const instruction = await closeRental(params).set({
|
|
38
|
+
* programs: 'mainnet',
|
|
38
39
|
* sageProgramAddress: 'custom...'
|
|
39
40
|
* });
|
|
41
|
+
*
|
|
42
|
+
* // Use the instruction with your preferred Solana library
|
|
43
|
+
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
40
44
|
* ```
|
|
41
45
|
*
|
|
42
46
|
* @param params The simplified parameters for closing a rental
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,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ED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
|
-
import { getSageGameId } from '../utils/constants';
|
|
3
|
-
import { deriveGameAccounts
|
|
2
|
+
import { getSageGameId, toAddress } from '../utils/constants';
|
|
3
|
+
import { deriveGameAccounts } from '../utils';
|
|
4
4
|
/**
|
|
5
5
|
* Internal function to reset a rental instruction with configuration options
|
|
6
6
|
*/
|
|
7
7
|
async function _resetRental(params, config) {
|
|
8
8
|
const { fleet, contract, rentalState, gameId, faction, ownerProfile, } = params;
|
|
9
9
|
// Get the actual game ID to use (param override, config override, or network default)
|
|
10
|
-
const actualGameId = gameId
|
|
10
|
+
const actualGameId = gameId ? toAddress(gameId) : await getSageGameId(config);
|
|
11
11
|
// Derive the three accounts we need
|
|
12
|
-
const { starbase, starbasePlayer } = await deriveGameAccounts(ownerProfile, faction, actualGameId, 0, // starbaseSeqId
|
|
12
|
+
const { starbase, starbasePlayer } = await deriveGameAccounts(toAddress(ownerProfile), faction, actualGameId, 0, // starbaseSeqId
|
|
13
13
|
config);
|
|
14
14
|
// Get network-specific codama functions from centralized config
|
|
15
15
|
const instructionsModule = getModule('instructions');
|
|
@@ -18,12 +18,12 @@ async function _resetRental(params, config) {
|
|
|
18
18
|
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
19
19
|
// Let codama derive the rest (rentalAuthority)
|
|
20
20
|
const input = {
|
|
21
|
-
fleet,
|
|
22
|
-
contract,
|
|
23
|
-
rentalState,
|
|
24
|
-
gameId: actualGameId,
|
|
25
|
-
starbase,
|
|
26
|
-
starbasePlayer,
|
|
21
|
+
fleet: toAddress(fleet), // Ensure string
|
|
22
|
+
contract: toAddress(contract), // Ensure string
|
|
23
|
+
rentalState: toAddress(rentalState), // Ensure string
|
|
24
|
+
gameId: actualGameId, // Already string
|
|
25
|
+
starbase, // Already string from deriveGameAccounts
|
|
26
|
+
starbasePlayer, // Already string from deriveGameAccounts
|
|
27
27
|
};
|
|
28
28
|
return getResetRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
29
29
|
}
|
|
@@ -32,24 +32,27 @@ async function _resetRental(params, config) {
|
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```typescript
|
|
35
|
-
* //
|
|
36
|
-
* const
|
|
37
|
-
* fleet:
|
|
38
|
-
* contract:
|
|
39
|
-
* rentalState:
|
|
35
|
+
* // Works with any library - just use strings for addresses!
|
|
36
|
+
* const instruction = await resetRental({
|
|
37
|
+
* fleet: "FleetAddress123...", // String address
|
|
38
|
+
* contract: "ContractAddr...", // String address
|
|
39
|
+
* rentalState: "RentalStateAddr...", // String address
|
|
40
40
|
* faction: 'mud',
|
|
41
|
-
* ownerProfile:
|
|
41
|
+
* ownerProfile: "OwnerProfileAddr..." // String address
|
|
42
42
|
* });
|
|
43
43
|
*
|
|
44
44
|
* // Use mainnet configuration
|
|
45
|
-
* const
|
|
45
|
+
* const instruction = await resetRental(params).set({ programs: 'mainnet' });
|
|
46
46
|
*
|
|
47
47
|
* // Override specific constants
|
|
48
|
-
* const
|
|
49
|
-
*
|
|
48
|
+
* const instruction = await resetRental(params).set({
|
|
49
|
+
* programs: 'mainnet',
|
|
50
50
|
* gameId: 'custom-game-id...',
|
|
51
51
|
* sageProgramAddress: 'custom...'
|
|
52
52
|
* });
|
|
53
|
+
*
|
|
54
|
+
* // Use the instruction with your preferred Solana library
|
|
55
|
+
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
53
56
|
* ```
|
|
54
57
|
*
|
|
55
58
|
* @param params The simplified parameters for resetting a rental
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBA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,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,WAAW,CACzB,MAAyB;IAEzB,OAAO,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,KAAU,EAAE,OAAa;IACtE,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,8BAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/esm/utils/config.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
// Single codama output - network agnostic
|
|
5
5
|
import * as instructions from '../codama/instructions';
|
|
6
6
|
import * as programs from '../codama/programs';
|
|
7
|
-
import { packWithKit, packWithWeb3js, packWithAuto } from './pack-functions';
|
|
8
7
|
const PROGRAM_SETS = {
|
|
9
8
|
mainnet: {
|
|
10
9
|
SAGE_PROGRAM_ADDRESS: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
|
|
@@ -49,7 +48,6 @@ export function resolveProgramAddresses(config) {
|
|
|
49
48
|
profileFactionProgramAddress: config.profileFactionProgramAddress || programConfig.PROFILE_FACTION_PROGRAM_ADDRESS,
|
|
50
49
|
gameId: config.gameId || programConfig.SAGE_GAME_ID,
|
|
51
50
|
atlasMint: config.atlasMint || programConfig.ATLAS_MINT,
|
|
52
|
-
rpcUrl: config.rpcUrl || programConfig.RPC_URL,
|
|
53
51
|
};
|
|
54
52
|
}
|
|
55
53
|
/**
|
|
@@ -116,44 +114,6 @@ export async function getCachedNetworkModule(modulePath) {
|
|
|
116
114
|
}
|
|
117
115
|
return getModule(modulePath);
|
|
118
116
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Create a chainable packed transaction that allows .pack().send() without double await
|
|
121
|
-
*
|
|
122
|
-
* @param packedTxPromise Promise that resolves to a PackedTransaction
|
|
123
|
-
* @returns ChainablePackedTransaction that can be chained with .send()
|
|
124
|
-
*/
|
|
125
|
-
function createChainablePackedTransaction(packedTxPromise) {
|
|
126
|
-
let cachedPackedTx = null;
|
|
127
|
-
const chainable = {
|
|
128
|
-
get messageBytes() {
|
|
129
|
-
if (cachedPackedTx)
|
|
130
|
-
return cachedPackedTx.messageBytes;
|
|
131
|
-
throw new Error('PackedTransaction not yet resolved. Use await on .pack() first, or use .send() directly for chaining.');
|
|
132
|
-
},
|
|
133
|
-
get signatures() {
|
|
134
|
-
if (cachedPackedTx)
|
|
135
|
-
return cachedPackedTx.signatures;
|
|
136
|
-
throw new Error('PackedTransaction not yet resolved. Use await on .pack() first, or use .send() directly for chaining.');
|
|
137
|
-
},
|
|
138
|
-
send: async (signer) => {
|
|
139
|
-
// If not cached, wait for the packed transaction
|
|
140
|
-
if (!cachedPackedTx) {
|
|
141
|
-
cachedPackedTx = await packedTxPromise;
|
|
142
|
-
}
|
|
143
|
-
return cachedPackedTx.send(signer);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
// Make the chainable object thenable so it can be awaited to get the PackedTransaction
|
|
147
|
-
const thenable = Object.assign(chainable, {
|
|
148
|
-
then(onfulfilled, onrejected) {
|
|
149
|
-
return packedTxPromise.then((packedTx) => {
|
|
150
|
-
cachedPackedTx = packedTx;
|
|
151
|
-
return onfulfilled ? onfulfilled(packedTx) : packedTx;
|
|
152
|
-
}, onrejected);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return thenable;
|
|
156
|
-
}
|
|
157
117
|
/**
|
|
158
118
|
* Create a chainable config selector with existing configuration state.
|
|
159
119
|
* This enables config chaining by merging new options with existing ones.
|
|
@@ -173,30 +133,6 @@ function createChainableConfigSelector(executeFn, existingConfig) {
|
|
|
173
133
|
const selector = {
|
|
174
134
|
set: (additionalOptions) => createChainableConfigSelector(executeFn, { ...existingConfig, ...additionalOptions }),
|
|
175
135
|
build: () => executeFn(existingConfig),
|
|
176
|
-
packKit: (feePayer) => {
|
|
177
|
-
const packedTxPromise = (async () => {
|
|
178
|
-
const instruction = await executeFn(existingConfig);
|
|
179
|
-
const effectiveConfig = getEffectiveConfig(existingConfig);
|
|
180
|
-
return await packWithKit(instruction, feePayer, effectiveConfig);
|
|
181
|
-
})();
|
|
182
|
-
return createChainablePackedTransaction(packedTxPromise);
|
|
183
|
-
},
|
|
184
|
-
packWeb3js: (feePayer) => {
|
|
185
|
-
const packedTxPromise = (async () => {
|
|
186
|
-
const instruction = await executeFn(existingConfig);
|
|
187
|
-
const effectiveConfig = getEffectiveConfig(existingConfig);
|
|
188
|
-
return await packWithWeb3js(instruction, feePayer, effectiveConfig);
|
|
189
|
-
})();
|
|
190
|
-
return createChainablePackedTransaction(packedTxPromise);
|
|
191
|
-
},
|
|
192
|
-
pack: (feePayer) => {
|
|
193
|
-
const packedTxPromise = (async () => {
|
|
194
|
-
const instruction = await executeFn(existingConfig);
|
|
195
|
-
const effectiveConfig = getEffectiveConfig(existingConfig);
|
|
196
|
-
return await packWithAuto(instruction, feePayer, effectiveConfig);
|
|
197
|
-
})();
|
|
198
|
-
return createChainablePackedTransaction(packedTxPromise);
|
|
199
|
-
},
|
|
200
136
|
// Implement PromiseLike to allow direct awaiting
|
|
201
137
|
then(onfulfilled, onrejected) {
|
|
202
138
|
return executeFn(existingConfig).then(onfulfilled, onrejected);
|
|
@@ -227,30 +163,6 @@ export function createConfigSelector(executeFn) {
|
|
|
227
163
|
const selector = {
|
|
228
164
|
set: (options) => createChainableConfigSelector(executeFn, getEffectiveConfig(options)),
|
|
229
165
|
build: () => executeFn(getEffectiveConfig()),
|
|
230
|
-
packKit: (feePayer) => {
|
|
231
|
-
const packedTxPromise = (async () => {
|
|
232
|
-
const instruction = await executeFn(getEffectiveConfig());
|
|
233
|
-
const effectiveConfig = getEffectiveConfig();
|
|
234
|
-
return await packWithKit(instruction, feePayer, effectiveConfig);
|
|
235
|
-
})();
|
|
236
|
-
return createChainablePackedTransaction(packedTxPromise);
|
|
237
|
-
},
|
|
238
|
-
packWeb3js: (feePayer) => {
|
|
239
|
-
const packedTxPromise = (async () => {
|
|
240
|
-
const instruction = await executeFn(getEffectiveConfig());
|
|
241
|
-
const effectiveConfig = getEffectiveConfig();
|
|
242
|
-
return await packWithWeb3js(instruction, feePayer, effectiveConfig);
|
|
243
|
-
})();
|
|
244
|
-
return createChainablePackedTransaction(packedTxPromise);
|
|
245
|
-
},
|
|
246
|
-
pack: (feePayer) => {
|
|
247
|
-
const packedTxPromise = (async () => {
|
|
248
|
-
const instruction = await executeFn(getEffectiveConfig());
|
|
249
|
-
const effectiveConfig = getEffectiveConfig();
|
|
250
|
-
return await packWithAuto(instruction, feePayer, effectiveConfig);
|
|
251
|
-
})();
|
|
252
|
-
return createChainablePackedTransaction(packedTxPromise);
|
|
253
|
-
},
|
|
254
166
|
// Implement PromiseLike to allow direct awaiting
|
|
255
167
|
then(onfulfilled, onrejected) {
|
|
256
168
|
return executeFn(getEffectiveConfig()).then(onfulfilled, onrejected);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0CAA0C;AAC1C,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0CAA0C;AAC1C,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAC;AAI/C,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE;QACP,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AAC,cAAc,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAiD;IAEjD,MAAM,QAAQ,GAAG;QACf,GAAG,EAAE,CAAC,OAAsB,EAAE,EAAE,CAAC,6BAA6B,CAAC,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACtG,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC5C,iDAAiD;QACjD,IAAI,CACF,WAAqE,EACrE,UAAuE;YAEvE,OAAO,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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.js","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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fluent instruction interface for format conversion between @solana/kit and @solana/web3.js
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create a fluent instruction wrapper around a kit instruction
|
|
6
|
+
* @param kitInstruction The base instruction in kit format
|
|
7
|
+
* @returns Fluent instruction with conversion methods
|
|
8
|
+
*/
|
|
9
|
+
export function createFluentInstruction(kitInstruction) {
|
|
10
|
+
return {
|
|
11
|
+
...kitInstruction,
|
|
12
|
+
web3js() {
|
|
13
|
+
return {
|
|
14
|
+
keys: kitInstruction.accounts.map(account => ({
|
|
15
|
+
pubkey: account.address,
|
|
16
|
+
isWritable: (account.role & 1) === 1, // Check if writable bit is set
|
|
17
|
+
isSigner: (account.role & 2) === 2, // Check if signer bit is set
|
|
18
|
+
})),
|
|
19
|
+
programId: kitInstruction.programAddress,
|
|
20
|
+
data: kitInstruction.data
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a fluent config selector that adds format conversion methods
|
|
27
|
+
* @param baseSelector The base ConfigSelector
|
|
28
|
+
* @returns FluentConfigSelector with additional format conversion methods
|
|
29
|
+
*/
|
|
30
|
+
export function createFluentConfigSelector(baseSelector) {
|
|
31
|
+
return {
|
|
32
|
+
// Override set to return FluentConfigSelector
|
|
33
|
+
set(options) {
|
|
34
|
+
const newBaseSelector = baseSelector.set(options);
|
|
35
|
+
return createFluentConfigSelector(newBaseSelector);
|
|
36
|
+
},
|
|
37
|
+
build: baseSelector.build,
|
|
38
|
+
then: baseSelector.then,
|
|
39
|
+
async web3js() {
|
|
40
|
+
const fluentInstruction = await baseSelector.build();
|
|
41
|
+
return fluentInstruction.web3js();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=instruction-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-converter.js","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":"AAAA;;GAEG;AA+DH;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,cAA8B;IACpE,OAAO;QACL,GAAG,cAAc;QACjB,MAAM;YACJ,OAAO;gBACL,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBAC5C,MAAM,EAAE,OAAO,CAAC,OAAO;oBACvB,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,+BAA+B;oBACrE,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,EAAI,6BAA6B;iBACpE,CAAC,CAAC;gBACH,SAAS,EAAE,cAAc,CAAC,cAAc;gBACxC,IAAI,EAAE,cAAc,CAAC,IAAI;aAC1B,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,YAA+B;IAE/B,OAAO;QACL,8CAA8C;QAC9C,GAAG,CAAC,OAAO;YACT,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClD,OAAO,0BAA0B,CAAC,eAAe,CAAC,CAAC;QACrD,CAAC;QACD,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,KAAK,CAAC,MAAM;YACV,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;YACrD,OAAO,iBAAiB,CAAC,MAAM,EAAE,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +1,23 @@
|
|
|
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 closing a rental contract
|
|
6
|
+
* Simplified parameters for closing a rental contract - strings only!
|
|
6
7
|
*/
|
|
7
8
|
export interface CloseContractParams {
|
|
8
9
|
/**
|
|
9
|
-
* The owner wallet that will sign the transaction
|
|
10
|
+
* The owner wallet that will sign the transaction (can be signer or string)
|
|
10
11
|
*/
|
|
11
|
-
owner:
|
|
12
|
+
owner: UniversalSigner | UniversalAddress;
|
|
12
13
|
/**
|
|
13
14
|
* The fleet account address associated with the contract
|
|
14
15
|
*/
|
|
15
|
-
fleet:
|
|
16
|
+
fleet: UniversalAddress;
|
|
16
17
|
/**
|
|
17
18
|
* The rental contract account address to close
|
|
18
19
|
*/
|
|
19
|
-
contract:
|
|
20
|
+
contract: UniversalAddress;
|
|
20
21
|
/**
|
|
21
22
|
* Optional faction (1 = mud, 2 = oni, 3 = ustur)
|
|
22
23
|
* Or as string: 'mud', 'oni', 'ustur'
|
|
@@ -26,7 +27,7 @@ export interface CloseContractParams {
|
|
|
26
27
|
* The game ID account address
|
|
27
28
|
* If not provided, will use network-specific default
|
|
28
29
|
*/
|
|
29
|
-
gameId?:
|
|
30
|
+
gameId?: UniversalAddress;
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Creates an instruction to close a rental contract with fluent configuration.
|
|
@@ -36,17 +37,17 @@ export interface CloseContractParams {
|
|
|
36
37
|
*
|
|
37
38
|
* @example
|
|
38
39
|
* ```typescript
|
|
39
|
-
* // Use
|
|
40
|
+
* // Use atlasnet defaults (instruction building only)
|
|
40
41
|
* await closeContract(params);
|
|
41
42
|
*
|
|
42
43
|
* // Use mainnet
|
|
43
|
-
* await closeContract(params).set({
|
|
44
|
+
* await closeContract(params).set({ programs: 'mainnet' });
|
|
44
45
|
*
|
|
45
46
|
* // Override game ID
|
|
46
47
|
* await closeContract(params).set({ gameId: 'custom...' });
|
|
47
48
|
* ```
|
|
48
49
|
*/
|
|
49
|
-
export declare function closeContract(params: CloseContractParams):
|
|
50
|
+
export declare function closeContract(params: CloseContractParams): FluentConfigSelector<FluentInstruction>;
|
|
50
51
|
export declare function getCloseContractInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
51
52
|
export {};
|
|
52
53
|
//# sourceMappingURL=close.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/contract/close.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/contract/close.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;AAE3B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,eAAe,GAAG,gBAAgB,CAAC;IAE1C;;OAEG;IACH,KAAK,EAAE,gBAAgB,CAAC;IAExB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAkGD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,mBAAmB,GAC1B,oBAAoB,CAAC,iBAAiB,CAAC,CAGzC;AAGD,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK/F"}
|