@wuwei-labs/srsly 2.0.0-beta.2 → 2.0.0-beta.21
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 +305 -110
- package/dist/cjs/codama/accounts/config.js +88 -0
- package/dist/cjs/codama/accounts/config.js.map +1 -0
- package/dist/cjs/codama/accounts/contractState.js +17 -39
- package/dist/cjs/codama/accounts/contractState.js.map +1 -1
- package/dist/cjs/codama/accounts/index.js +1 -1
- package/dist/cjs/codama/accounts/index.js.map +1 -1
- package/dist/cjs/codama/accounts/rentalState.js +18 -33
- package/dist/cjs/codama/accounts/rentalState.js.map +1 -1
- package/dist/cjs/codama/accounts/thread.js +15 -32
- package/dist/cjs/codama/accounts/thread.js.map +1 -1
- package/dist/cjs/codama/errors/srsly.js +24 -3
- package/dist/cjs/codama/errors/srsly.js.map +1 -1
- package/dist/cjs/codama/instructions/acceptRental.js +202 -224
- package/dist/cjs/codama/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/codama/instructions/cancelRental.js +100 -136
- package/dist/cjs/codama/instructions/cancelRental.js.map +1 -1
- package/dist/cjs/codama/instructions/closeContract.js +95 -116
- package/dist/cjs/codama/instructions/closeContract.js.map +1 -1
- package/dist/cjs/codama/instructions/closeRental.js +119 -132
- package/dist/cjs/codama/instructions/closeRental.js.map +1 -1
- package/dist/cjs/codama/instructions/createContract.js +127 -143
- package/dist/cjs/codama/instructions/createContract.js.map +1 -1
- package/dist/cjs/codama/instructions/index.js +2 -1
- package/dist/cjs/codama/instructions/index.js.map +1 -1
- package/dist/cjs/codama/instructions/initializeConfig.js +131 -0
- package/dist/cjs/codama/instructions/initializeConfig.js.map +1 -0
- package/dist/cjs/codama/instructions/payRental.js +125 -129
- package/dist/cjs/codama/instructions/payRental.js.map +1 -1
- package/dist/cjs/codama/instructions/resetRental.js +55 -77
- package/dist/cjs/codama/instructions/resetRental.js.map +1 -1
- package/dist/cjs/codama/instructions/updateConfig.js +145 -0
- package/dist/cjs/codama/instructions/updateConfig.js.map +1 -0
- package/dist/cjs/codama/programs/srsly.js +12 -8
- package/dist/cjs/codama/programs/srsly.js.map +1 -1
- package/dist/cjs/codama/shared/index.js +6 -2
- package/dist/cjs/codama/shared/index.js.map +1 -1
- package/dist/cjs/codama/types/trigger.js +1 -1
- package/dist/cjs/codama/types/trigger.js.map +1 -1
- package/dist/cjs/codama/types/triggerContext.js +1 -1
- package/dist/cjs/codama/types/triggerContext.js.map +1 -1
- package/dist/cjs/contract/close.js +75 -34
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +59 -43
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +54 -0
- package/dist/cjs/rental/accept.js +68 -40
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +36 -28
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +37 -29
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +46 -42
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +319 -0
- package/dist/cjs/utils/config.js.map +1 -0
- package/dist/cjs/utils/constants.js +69 -9
- 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/profiles.js +96 -95
- package/dist/cjs/utils/profiles.js.map +1 -1
- package/dist/esm/codama/accounts/config.js +76 -0
- package/dist/esm/codama/accounts/config.js.map +1 -0
- package/dist/esm/codama/accounts/contractState.js +3 -7
- package/dist/esm/codama/accounts/contractState.js.map +1 -1
- package/dist/esm/codama/accounts/index.js +1 -1
- package/dist/esm/codama/accounts/index.js.map +1 -1
- package/dist/esm/codama/accounts/rentalState.js +3 -1
- package/dist/esm/codama/accounts/rentalState.js.map +1 -1
- package/dist/esm/codama/errors/srsly.js +23 -2
- package/dist/esm/codama/errors/srsly.js.map +1 -1
- package/dist/esm/codama/instructions/acceptRental.js +30 -39
- package/dist/esm/codama/instructions/acceptRental.js.map +1 -1
- package/dist/esm/codama/instructions/cancelRental.js +10 -33
- package/dist/esm/codama/instructions/cancelRental.js.map +1 -1
- package/dist/esm/codama/instructions/closeContract.js +17 -25
- package/dist/esm/codama/instructions/closeContract.js.map +1 -1
- package/dist/esm/codama/instructions/closeRental.js +19 -19
- package/dist/esm/codama/instructions/closeRental.js.map +1 -1
- package/dist/esm/codama/instructions/createContract.js +13 -16
- package/dist/esm/codama/instructions/createContract.js.map +1 -1
- package/dist/esm/codama/instructions/index.js +2 -1
- package/dist/esm/codama/instructions/index.js.map +1 -1
- package/dist/esm/codama/instructions/initializeConfig.js +121 -0
- package/dist/esm/codama/instructions/initializeConfig.js.map +1 -0
- package/dist/esm/codama/instructions/payRental.js +34 -25
- package/dist/esm/codama/instructions/payRental.js.map +1 -1
- package/dist/esm/codama/instructions/resetRental.js +0 -9
- package/dist/esm/codama/instructions/resetRental.js.map +1 -1
- package/dist/esm/codama/instructions/updateConfig.js +135 -0
- package/dist/esm/codama/instructions/updateConfig.js.map +1 -0
- package/dist/esm/codama/programs/srsly.js +12 -8
- package/dist/esm/codama/programs/srsly.js.map +1 -1
- package/dist/esm/contract/close.js +68 -16
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +60 -33
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +54 -0
- package/dist/esm/rental/accept.js +70 -31
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +37 -18
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +38 -19
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset.js +48 -33
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/config.js +277 -0
- package/dist/esm/utils/config.js.map +1 -0
- package/dist/esm/utils/constants.js +60 -7
- 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/profiles.js +39 -19
- package/dist/esm/utils/profiles.js.map +1 -1
- package/dist/types/codama/accounts/config.d.ts +52 -0
- package/dist/types/codama/accounts/config.d.ts.map +1 -0
- package/dist/types/codama/accounts/contractState.d.ts +2 -4
- package/dist/types/codama/accounts/contractState.d.ts.map +1 -1
- package/dist/types/codama/accounts/index.d.ts +1 -1
- package/dist/types/codama/accounts/index.d.ts.map +1 -1
- package/dist/types/codama/accounts/rentalState.d.ts +2 -0
- package/dist/types/codama/accounts/rentalState.d.ts.map +1 -1
- package/dist/types/codama/errors/srsly.d.ts +16 -2
- package/dist/types/codama/errors/srsly.d.ts.map +1 -1
- package/dist/types/codama/instructions/acceptRental.d.ts +41 -34
- package/dist/types/codama/instructions/acceptRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/cancelRental.d.ts +14 -10
- package/dist/types/codama/instructions/cancelRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/closeContract.d.ts +29 -21
- package/dist/types/codama/instructions/closeContract.d.ts.map +1 -1
- package/dist/types/codama/instructions/closeRental.d.ts +20 -12
- package/dist/types/codama/instructions/closeRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/createContract.d.ts +27 -23
- package/dist/types/codama/instructions/createContract.d.ts.map +1 -1
- package/dist/types/codama/instructions/index.d.ts +2 -1
- package/dist/types/codama/instructions/index.d.ts.map +1 -1
- package/dist/types/codama/instructions/initializeConfig.d.ts +60 -0
- package/dist/types/codama/instructions/initializeConfig.d.ts.map +1 -0
- package/dist/types/codama/instructions/payRental.d.ts +28 -13
- package/dist/types/codama/instructions/payRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/resetRental.d.ts +3 -3
- package/dist/types/codama/instructions/resetRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/updateConfig.d.ts +93 -0
- package/dist/types/codama/instructions/updateConfig.d.ts.map +1 -0
- package/dist/types/codama/programs/srsly.d.ts +11 -8
- package/dist/types/codama/programs/srsly.d.ts.map +1 -1
- package/dist/types/contract/close.d.ts +20 -24
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +34 -22
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts +42 -20
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +16 -11
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +16 -11
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts +17 -20
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +167 -0
- package/dist/types/utils/config.d.ts.map +1 -0
- package/dist/types/utils/constants.d.ts +23 -7
- 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/profiles.d.ts +14 -8
- package/dist/types/utils/profiles.d.ts.map +1 -1
- package/package.json +36 -14
- package/target/idl/srsly.json +3279 -0
- package/target/types/srsly.ts +1 -0
- package/dist/cjs/codama/accounts/fleet.js +0 -94
- package/dist/cjs/codama/accounts/fleet.js.map +0 -1
- package/dist/cjs/codama/instructions/normalizeAdmin.js +0 -165
- package/dist/cjs/codama/instructions/normalizeAdmin.js.map +0 -1
- package/dist/esm/codama/accounts/fleet.js +0 -64
- package/dist/esm/codama/accounts/fleet.js.map +0 -1
- package/dist/esm/codama/instructions/normalizeAdmin.js +0 -142
- package/dist/esm/codama/instructions/normalizeAdmin.js.map +0 -1
- package/dist/types/codama/accounts/fleet.d.ts +0 -38
- package/dist/types/codama/accounts/fleet.d.ts.map +0 -1
- package/dist/types/codama/instructions/normalizeAdmin.d.ts +0 -67
- package/dist/types/codama/instructions/normalizeAdmin.d.ts.map +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, getOptionDecoder, getOptionEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, transformEncoder, } from '@solana/kit';
|
|
9
|
+
import { SRSLY_PROGRAM_ADDRESS } from '../programs';
|
|
10
|
+
import { getAccountMetaFactory } from '../shared';
|
|
11
|
+
import { getPaymentFrequencyDecoder, getPaymentFrequencyEncoder, } from '../types';
|
|
12
|
+
export const UPDATE_CONFIG_DISCRIMINATOR = new Uint8Array([
|
|
13
|
+
29, 158, 252, 191, 10, 83, 219, 99,
|
|
14
|
+
]);
|
|
15
|
+
export function getUpdateConfigDiscriminatorBytes() {
|
|
16
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(UPDATE_CONFIG_DISCRIMINATOR);
|
|
17
|
+
}
|
|
18
|
+
export function getUpdateConfigInstructionDataEncoder() {
|
|
19
|
+
return transformEncoder(getStructEncoder([
|
|
20
|
+
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
21
|
+
['authority', getOptionEncoder(getAddressEncoder())],
|
|
22
|
+
['stardustToAtlas', getOptionEncoder(getU64Encoder())],
|
|
23
|
+
['serviceFeeBps', getOptionEncoder(getU64Encoder())],
|
|
24
|
+
['referralFeeBps', getOptionEncoder(getU64Encoder())],
|
|
25
|
+
['baseBps', getOptionEncoder(getU64Encoder())],
|
|
26
|
+
['rentalDurationMinSeconds', getOptionEncoder(getU64Encoder())],
|
|
27
|
+
['rentalDurationMaxSeconds', getOptionEncoder(getU64Encoder())],
|
|
28
|
+
['feesAccount', getOptionEncoder(getAddressEncoder())],
|
|
29
|
+
['atlasMint', getOptionEncoder(getAddressEncoder())],
|
|
30
|
+
[
|
|
31
|
+
'defaultPaymentFrequency',
|
|
32
|
+
getOptionEncoder(getPaymentFrequencyEncoder()),
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
'allowedFrequencies',
|
|
36
|
+
getOptionEncoder(getArrayEncoder(getPaymentFrequencyEncoder())),
|
|
37
|
+
],
|
|
38
|
+
]), (value) => ({ ...value, discriminator: UPDATE_CONFIG_DISCRIMINATOR }));
|
|
39
|
+
}
|
|
40
|
+
export function getUpdateConfigInstructionDataDecoder() {
|
|
41
|
+
return getStructDecoder([
|
|
42
|
+
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
43
|
+
['authority', getOptionDecoder(getAddressDecoder())],
|
|
44
|
+
['stardustToAtlas', getOptionDecoder(getU64Decoder())],
|
|
45
|
+
['serviceFeeBps', getOptionDecoder(getU64Decoder())],
|
|
46
|
+
['referralFeeBps', getOptionDecoder(getU64Decoder())],
|
|
47
|
+
['baseBps', getOptionDecoder(getU64Decoder())],
|
|
48
|
+
['rentalDurationMinSeconds', getOptionDecoder(getU64Decoder())],
|
|
49
|
+
['rentalDurationMaxSeconds', getOptionDecoder(getU64Decoder())],
|
|
50
|
+
['feesAccount', getOptionDecoder(getAddressDecoder())],
|
|
51
|
+
['atlasMint', getOptionDecoder(getAddressDecoder())],
|
|
52
|
+
['defaultPaymentFrequency', getOptionDecoder(getPaymentFrequencyDecoder())],
|
|
53
|
+
[
|
|
54
|
+
'allowedFrequencies',
|
|
55
|
+
getOptionDecoder(getArrayDecoder(getPaymentFrequencyDecoder())),
|
|
56
|
+
],
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
export function getUpdateConfigInstructionDataCodec() {
|
|
60
|
+
return combineCodec(getUpdateConfigInstructionDataEncoder(), getUpdateConfigInstructionDataDecoder());
|
|
61
|
+
}
|
|
62
|
+
export async function getUpdateConfigInstructionAsync(input, config) {
|
|
63
|
+
// Program address.
|
|
64
|
+
const programAddress = config?.programAddress ?? SRSLY_PROGRAM_ADDRESS;
|
|
65
|
+
// Original accounts.
|
|
66
|
+
const originalAccounts = {
|
|
67
|
+
config: { value: input.config ?? null, isWritable: true },
|
|
68
|
+
authority: { value: input.authority ?? null, isWritable: false },
|
|
69
|
+
};
|
|
70
|
+
const accounts = originalAccounts;
|
|
71
|
+
// Original args.
|
|
72
|
+
const args = { ...input, authority: input.authorityArg };
|
|
73
|
+
// Resolve default values.
|
|
74
|
+
if (!accounts.config.value) {
|
|
75
|
+
accounts.config.value = await getProgramDerivedAddress({
|
|
76
|
+
programAddress,
|
|
77
|
+
seeds: [
|
|
78
|
+
getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
83
|
+
const instruction = {
|
|
84
|
+
accounts: [
|
|
85
|
+
getAccountMeta(accounts.config),
|
|
86
|
+
getAccountMeta(accounts.authority),
|
|
87
|
+
],
|
|
88
|
+
programAddress,
|
|
89
|
+
data: getUpdateConfigInstructionDataEncoder().encode(args),
|
|
90
|
+
};
|
|
91
|
+
return instruction;
|
|
92
|
+
}
|
|
93
|
+
export function getUpdateConfigInstruction(input, config) {
|
|
94
|
+
// Program address.
|
|
95
|
+
const programAddress = config?.programAddress ?? SRSLY_PROGRAM_ADDRESS;
|
|
96
|
+
// Original accounts.
|
|
97
|
+
const originalAccounts = {
|
|
98
|
+
config: { value: input.config ?? null, isWritable: true },
|
|
99
|
+
authority: { value: input.authority ?? null, isWritable: false },
|
|
100
|
+
};
|
|
101
|
+
const accounts = originalAccounts;
|
|
102
|
+
// Original args.
|
|
103
|
+
const args = { ...input, authority: input.authorityArg };
|
|
104
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
105
|
+
const instruction = {
|
|
106
|
+
accounts: [
|
|
107
|
+
getAccountMeta(accounts.config),
|
|
108
|
+
getAccountMeta(accounts.authority),
|
|
109
|
+
],
|
|
110
|
+
programAddress,
|
|
111
|
+
data: getUpdateConfigInstructionDataEncoder().encode(args),
|
|
112
|
+
};
|
|
113
|
+
return instruction;
|
|
114
|
+
}
|
|
115
|
+
export function parseUpdateConfigInstruction(instruction) {
|
|
116
|
+
if (instruction.accounts.length < 2) {
|
|
117
|
+
// TODO: Coded error.
|
|
118
|
+
throw new Error('Not enough accounts');
|
|
119
|
+
}
|
|
120
|
+
let accountIndex = 0;
|
|
121
|
+
const getNextAccount = () => {
|
|
122
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
123
|
+
accountIndex += 1;
|
|
124
|
+
return accountMeta;
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
programAddress: instruction.programAddress,
|
|
128
|
+
accounts: {
|
|
129
|
+
config: getNextAccount(),
|
|
130
|
+
authority: getNextAccount(),
|
|
131
|
+
},
|
|
132
|
+
data: getUpdateConfigInstructionDataDecoder().decode(instruction.data),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=updateConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateConfig.js","sourceRoot":"","sources":["../../../../src/codama/instructions/updateConfig.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,gBAAgB,GAgBjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAA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WAAW,CAAC,cAAc;QAC1C,QAAQ,EAAE;YACR,MAAM,EAAE,cAAc,EAAE;YACxB,SAAS,EAAE,cAAc,EAAE;SAC5B;QACD,IAAI,EAAE,qCAAqC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;KACvE,CAAC;AACJ,CAAC"}
|
|
@@ -9,19 +9,19 @@ import { containsBytes, fixEncoderSize, getBytesEncoder, } from '@solana/kit';
|
|
|
9
9
|
export const SRSLY_PROGRAM_ADDRESS = 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT';
|
|
10
10
|
export var SrslyAccount;
|
|
11
11
|
(function (SrslyAccount) {
|
|
12
|
-
SrslyAccount[SrslyAccount["
|
|
13
|
-
SrslyAccount[SrslyAccount["
|
|
12
|
+
SrslyAccount[SrslyAccount["Config"] = 0] = "Config";
|
|
13
|
+
SrslyAccount[SrslyAccount["ContractState"] = 1] = "ContractState";
|
|
14
14
|
SrslyAccount[SrslyAccount["RentalState"] = 2] = "RentalState";
|
|
15
15
|
SrslyAccount[SrslyAccount["Thread"] = 3] = "Thread";
|
|
16
16
|
})(SrslyAccount || (SrslyAccount = {}));
|
|
17
17
|
export function identifySrslyAccount(account) {
|
|
18
18
|
const data = 'data' in account ? account.data : account;
|
|
19
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([155, 12, 170, 224, 30, 250, 204, 130])), 0)) {
|
|
20
|
+
return SrslyAccount.Config;
|
|
21
|
+
}
|
|
19
22
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([190, 138, 10, 223, 189, 116, 222, 115])), 0)) {
|
|
20
23
|
return SrslyAccount.ContractState;
|
|
21
24
|
}
|
|
22
|
-
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([109, 207, 251, 48, 106, 2, 136, 163])), 0)) {
|
|
23
|
-
return SrslyAccount.Fleet;
|
|
24
|
-
}
|
|
25
25
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([97, 162, 29, 222, 251, 251, 180, 244])), 0)) {
|
|
26
26
|
return SrslyAccount.RentalState;
|
|
27
27
|
}
|
|
@@ -37,9 +37,10 @@ export var SrslyInstruction;
|
|
|
37
37
|
SrslyInstruction[SrslyInstruction["CloseContract"] = 2] = "CloseContract";
|
|
38
38
|
SrslyInstruction[SrslyInstruction["CloseRental"] = 3] = "CloseRental";
|
|
39
39
|
SrslyInstruction[SrslyInstruction["CreateContract"] = 4] = "CreateContract";
|
|
40
|
-
SrslyInstruction[SrslyInstruction["
|
|
40
|
+
SrslyInstruction[SrslyInstruction["InitializeConfig"] = 5] = "InitializeConfig";
|
|
41
41
|
SrslyInstruction[SrslyInstruction["PayRental"] = 6] = "PayRental";
|
|
42
42
|
SrslyInstruction[SrslyInstruction["ResetRental"] = 7] = "ResetRental";
|
|
43
|
+
SrslyInstruction[SrslyInstruction["UpdateConfig"] = 8] = "UpdateConfig";
|
|
43
44
|
})(SrslyInstruction || (SrslyInstruction = {}));
|
|
44
45
|
export function identifySrslyInstruction(instruction) {
|
|
45
46
|
const data = 'data' in instruction ? instruction.data : instruction;
|
|
@@ -58,8 +59,8 @@ export function identifySrslyInstruction(instruction) {
|
|
|
58
59
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([244, 48, 244, 178, 216, 88, 122, 52])), 0)) {
|
|
59
60
|
return SrslyInstruction.CreateContract;
|
|
60
61
|
}
|
|
61
|
-
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([
|
|
62
|
-
return SrslyInstruction.
|
|
62
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([208, 127, 21, 1, 194, 190, 196, 70])), 0)) {
|
|
63
|
+
return SrslyInstruction.InitializeConfig;
|
|
63
64
|
}
|
|
64
65
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([114, 15, 111, 207, 115, 207, 108, 169])), 0)) {
|
|
65
66
|
return SrslyInstruction.PayRental;
|
|
@@ -67,6 +68,9 @@ export function identifySrslyInstruction(instruction) {
|
|
|
67
68
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([139, 185, 76, 32, 61, 143, 163, 183])), 0)) {
|
|
68
69
|
return SrslyInstruction.ResetRental;
|
|
69
70
|
}
|
|
71
|
+
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([29, 158, 252, 191, 10, 83, 219, 99])), 0)) {
|
|
72
|
+
return SrslyInstruction.UpdateConfig;
|
|
73
|
+
}
|
|
70
74
|
throw new Error('The provided instruction could not be identified as a srsly instruction.');
|
|
71
75
|
}
|
|
72
76
|
//# sourceMappingURL=srsly.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"srsly.js","sourceRoot":"","sources":["../../../../src/codama/programs/srsly.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"srsly.js","sourceRoot":"","sources":["../../../../src/codama/programs/srsly.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAC;AAarB,MAAM,CAAC,MAAM,qBAAqB,GAChC,6CAAuG,CAAC;AAE1G,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,mDAAM,CAAA;IACN,iEAAa,CAAA;IACb,6DAAW,CAAA;IACX,mDAAM,CAAA;AACR,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,MAAM,UAAU,oBAAoB,CAClC,OAA0D;IAE1D,MAAM,IAAI,GAAG,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC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,EAAE,GAAG,CAAC,CAAC,CACxD,EACD,CAAC,CACF,EACD,CAAC;QACD,OAAO,gBAAgB,CAAC,SAAS,CAAC;IACpC,CAAC;IACD,IACE,aAAa,CACX,IAAI,EACJ,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CACzC,IAAI,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CACtD,EACD,CAAC,CACF,EACD,CAAC;QACD,OAAO,gBAAgB,CAAC,WAAW,CAAC;IACtC,CAAC;IACD,IACE,aAAa,CACX,IAAI,EACJ,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CACzC,IAAI,UAAU,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CACrD,EACD,CAAC,CACF,EACD,CAAC;QACD,OAAO,gBAAgB,CAAC,YAAY,CAAC;IACvC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -1,44 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
|
+
import { getSageGameId, toAddress } from '../utils/constants';
|
|
3
|
+
import { deriveGameAccounts, } from '../utils';
|
|
3
4
|
/**
|
|
4
5
|
* Asynchronously creates an instruction to close a rental contract with minimal required parameters.
|
|
5
6
|
* Derives rentalAuthority automatically and handles optional parameters.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```typescript
|
|
9
|
-
* // Create the instruction with
|
|
10
|
+
* // Create the instruction with default devnet settings
|
|
10
11
|
* const ix = await closeContract({
|
|
11
12
|
* owner: wallet,
|
|
12
13
|
* fleet: fleetAddress,
|
|
13
14
|
* contract: contractAddress,
|
|
14
|
-
* faction: 'mud',
|
|
15
|
-
* // Optional: provide explicit starbase and starbasePlayer if you have them
|
|
16
|
-
* // Optional: provide rentalState and rentalTokenAccount if active rental exists
|
|
15
|
+
* faction: 'mud',
|
|
17
16
|
* });
|
|
18
17
|
*
|
|
19
|
-
* //
|
|
20
|
-
* const
|
|
21
|
-
*
|
|
18
|
+
* // Use mainnet configuration
|
|
19
|
+
* const ix = await closeContract({
|
|
20
|
+
* owner: wallet,
|
|
21
|
+
* fleet: fleetAddress,
|
|
22
|
+
* contract: contractAddress,
|
|
23
|
+
* faction: 'mud',
|
|
24
|
+
* }).set({ network: 'mainnet' });
|
|
25
|
+
*
|
|
26
|
+
* // Override specific constants
|
|
27
|
+
* const ix = await closeContract({
|
|
28
|
+
* owner: wallet,
|
|
29
|
+
* fleet: fleetAddress,
|
|
30
|
+
* contract: contractAddress,
|
|
31
|
+
* faction: 'mud',
|
|
32
|
+
* }).set({
|
|
33
|
+
* network: 'mainnet',
|
|
34
|
+
* gameId: 'custom-game-id...'
|
|
35
|
+
* });
|
|
22
36
|
* ```
|
|
23
37
|
*
|
|
24
38
|
* @param params The simplified parameters for closing a rental contract
|
|
25
39
|
* @returns A promise that resolves to the instruction to close a contract
|
|
26
40
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Internal function to close a contract instruction with configuration options
|
|
43
|
+
*/
|
|
44
|
+
async function _closeContract(params, config) {
|
|
45
|
+
const { owner, fleet, contract, faction, gameId, } = params;
|
|
46
|
+
// Get the actual game ID to use (param override, config override, or network default)
|
|
47
|
+
const actualGameId = gameId ? toAddress(gameId) : await getSageGameId(config);
|
|
48
|
+
const derivedAccounts = await deriveGameAccounts(owner.address, faction, actualGameId, 0, // starbaseSeqId
|
|
49
|
+
config);
|
|
30
50
|
const starbase = derivedAccounts.starbase;
|
|
31
51
|
const starbasePlayer = derivedAccounts.starbasePlayer;
|
|
52
|
+
// Get network-specific codama functions from centralized config
|
|
53
|
+
const instructionsModule = getModule('instructions');
|
|
54
|
+
const programsModule = getModule('programs');
|
|
55
|
+
const { getCloseContractInstructionAsync } = instructionsModule;
|
|
56
|
+
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
32
57
|
// Let codama derive the rest (rentalAuthority, ownerTokenAccount, etc.)
|
|
33
58
|
const input = {
|
|
34
59
|
owner,
|
|
35
|
-
fleet,
|
|
36
|
-
contract,
|
|
60
|
+
fleet: toAddress(fleet),
|
|
61
|
+
contract: toAddress(contract),
|
|
37
62
|
starbase,
|
|
38
63
|
starbasePlayer,
|
|
39
|
-
gameId,
|
|
64
|
+
gameId: actualGameId,
|
|
40
65
|
};
|
|
41
66
|
return getCloseContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
42
67
|
}
|
|
43
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Creates an instruction to close a rental contract with fluent configuration.
|
|
70
|
+
*
|
|
71
|
+
* @param params The contract closing parameters
|
|
72
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // Use devnet defaults
|
|
77
|
+
* await closeContract(params);
|
|
78
|
+
*
|
|
79
|
+
* // Use mainnet
|
|
80
|
+
* await closeContract(params).set({ network: 'mainnet' });
|
|
81
|
+
*
|
|
82
|
+
* // Override game ID
|
|
83
|
+
* await closeContract(params).set({ gameId: 'custom...' });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function closeContract(params) {
|
|
87
|
+
return createConfigSelector((config) => _closeContract(params, config));
|
|
88
|
+
}
|
|
89
|
+
// Export config selector for getCloseContractInstructionAsync
|
|
90
|
+
export function getCloseContractInstructionAsync(input, options) {
|
|
91
|
+
return createConfigSelector(async (config) => {
|
|
92
|
+
const instructionsModule = getModule('instructions');
|
|
93
|
+
return instructionsModule.getCloseContractInstructionAsync(input, options);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
44
96
|
//# sourceMappingURL=close.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/contract/close.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/contract/close.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK9D,OAAO,EACL,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAkClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH;;GAEG;AACH,KAAK,UAAU,cAAc,CAC3B,MAA2B,EAC3B,MAAsB;IAEtB,MAAM,EACJ,KAAK,EACL,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,GACP,GAAG,MAAM,CAAC;IAEX,sFAAsF;IACtF,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;IAE9E,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAC9C,KAAK,CAAC,OAAO,EACb,OAAQ,EACR,YAAY,EACZ,CAAC,EAAE,gBAAgB;IACnB,MAAM,CACP,CAAC;IAEF,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC;IAC1C,MAAM,cAAc,GAAG,eAAe,CAAC,cAAc,CAAC;IAEtD,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,EAAE,gCAAgC,EAAE,GAAG,kBAAkB,CAAC;IAChE,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC;IAEjD,wEAAwE;IACxE,MAAM,KAAK,GAAG;QACZ,KAAK;QACL,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC;QACvB,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC;QAC7B,QAAQ;QACR,cAAc;QACd,MAAM,EAAE,YAAY;KACrB,CAAC;IAEF,OAAO,gCAAgC,CACrC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA2B;IAE3B,OAAO,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,gCAAgC,CAAC,KAAU,EAAE,OAAa;IACxE,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,gCAAgC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,45 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
|
+
import { getSageGameId, getSageProgramAddress, getAtlasMint, toAddress } from '../utils/constants';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
4
|
+
* Internal function to create a contract instruction with configuration options
|
|
5
|
+
*/
|
|
6
|
+
async function _createContract(params, config) {
|
|
7
|
+
const { owner, fleet, ownerProfile, rate, durationMin, durationMax, paymentsFreq, ownerKeyIndex = 0, gameId, mint, } = params;
|
|
8
|
+
// Get the actual game ID to use (param override, config override, or network default)
|
|
9
|
+
const actualGameId = gameId ? toAddress(gameId) : await getSageGameId(config);
|
|
10
|
+
// Get codama functions
|
|
11
|
+
const instructionsModule = getModule('instructions');
|
|
12
|
+
const programsModule = getModule('programs');
|
|
13
|
+
const { getCreateContractInstructionAsync } = instructionsModule;
|
|
14
|
+
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
15
|
+
// Default ATLAS mint address if not provided (uses config)
|
|
16
|
+
const atlasMint = mint ? toAddress(mint) : await getAtlasMint(config);
|
|
17
|
+
// Let codama derive the rest (contract, rentalAuthority, ownerTokenAccount, etc.)
|
|
18
|
+
const input = {
|
|
19
|
+
mint: atlasMint,
|
|
20
|
+
owner, // Keep as TransactionSigner
|
|
21
|
+
fleet: toAddress(fleet),
|
|
22
|
+
ownerProfile: toAddress(ownerProfile),
|
|
23
|
+
gameId: actualGameId,
|
|
24
|
+
rate: BigInt(rate),
|
|
25
|
+
durationMin: BigInt(durationMin),
|
|
26
|
+
durationMax: BigInt(durationMax),
|
|
27
|
+
paymentsFeq: paymentsFreq,
|
|
28
|
+
ownerKeyIndex,
|
|
29
|
+
sageProgram: toAddress(await getSageProgramAddress(config)),
|
|
30
|
+
};
|
|
31
|
+
return getCreateContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates an instruction to create a rental contract with fluent configuration.
|
|
6
35
|
*
|
|
7
36
|
* @example
|
|
8
37
|
* ```typescript
|
|
9
|
-
* //
|
|
10
|
-
* const ix = await createContract(
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
38
|
+
* // Use devnet defaults
|
|
39
|
+
* const ix = await createContract(params);
|
|
40
|
+
*
|
|
41
|
+
* // Use mainnet configuration
|
|
42
|
+
* const ix = await createContract(params).set({ network: 'mainnet' });
|
|
43
|
+
*
|
|
44
|
+
* // Override specific constants
|
|
45
|
+
* const ix = await createContract(params).set({
|
|
46
|
+
* network: 'mainnet',
|
|
47
|
+
* gameId: 'custom-game-id...',
|
|
48
|
+
* sageProgramAddress: 'custom-sage...'
|
|
18
49
|
* });
|
|
19
50
|
*
|
|
20
|
-
* //
|
|
21
|
-
* const
|
|
22
|
-
*
|
|
51
|
+
* // Chain configurations
|
|
52
|
+
* const ix = await createContract(params)
|
|
53
|
+
* .set({ network: 'devnet' })
|
|
54
|
+
* .set({ gameId: 'override-game...' });
|
|
23
55
|
* ```
|
|
24
56
|
*
|
|
25
57
|
* @param params The simplified parameters for creating a rental contract
|
|
26
|
-
* @returns A
|
|
58
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
27
59
|
*/
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
paymentsFeq: paymentsFreq,
|
|
40
|
-
ownerKeyIndex,
|
|
41
|
-
};
|
|
42
|
-
return getCreateContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
60
|
+
export function createContract(params) {
|
|
61
|
+
return createConfigSelector((config) => _createContract(params, config));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Export config selector for getCreateContractInstructionAsync
|
|
65
|
+
*/
|
|
66
|
+
export function getCreateContractInstructionAsync(input, options) {
|
|
67
|
+
return createConfigSelector(async (config) => {
|
|
68
|
+
const instructionsModule = getModule('instructions');
|
|
69
|
+
return instructionsModule.getCreateContractInstructionAsync(input, options);
|
|
70
|
+
});
|
|
43
71
|
}
|
|
44
|
-
export { getCreateContractInstructionAsync };
|
|
45
72
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":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C;QAChC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;QAChC,WAAW,EAAE,YAAY;QACzB,aAAa;QACb,WAAW,EAAE,SAAS,CAAC,MAAM,qBAAqB,CAAC,MAAM,CAAC,CAAC;KAC5D,CAAC;IAEF,OAAO,iCAAiC,CACtC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,cAAc,CAC5B,MAA4B;IAE5B,OAAO,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAAC,KAAU,EAAE,OAAa;IACzE,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,iCAAiC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// Export main SDK functions
|
|
2
2
|
export * from "./contract";
|
|
3
|
+
export * from "./rental";
|
|
4
|
+
export * from "./utils";
|
|
5
|
+
// Export PaymentFrequency from utils since it's not in codama
|
|
6
|
+
export { PaymentFrequency } from "./utils/constants";
|
|
3
7
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AAsBxB,8DAA8D;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wuwei-labs/srsly",
|
|
3
|
+
"version": "2.0.0-beta.21",
|
|
4
|
+
"description": "",
|
|
5
|
+
"source": "./src/index.ts",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/cjs",
|
|
12
|
+
"dist/esm",
|
|
13
|
+
"dist/types",
|
|
14
|
+
"target/idl/srsly.json",
|
|
15
|
+
"target/types/srsly.ts"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"SRSLY",
|
|
19
|
+
"Star",
|
|
20
|
+
"Atlas",
|
|
21
|
+
"sdk"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"package": "pnpm run clean && pnpm build && pnpm run package:cjs && pnpm run package:esm && pnpm run generate",
|
|
25
|
+
"package:cjs": "tsc -p tsconfig.cjs.json && tsconfig-to-dual-package tsconfig.cjs.json",
|
|
26
|
+
"package:esm": "tsc -p tsconfig.esm.json && tsconfig-to-dual-package tsconfig.esm.json",
|
|
27
|
+
"clean": "rm -rf dist && cargo clean && pnpm install",
|
|
28
|
+
"generate": "node generate.mjs",
|
|
29
|
+
"build": "anchor build && pnpm run generate",
|
|
30
|
+
"docs": "typedoc",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest",
|
|
33
|
+
"test:coverage": "vitest run --coverage"
|
|
34
|
+
},
|
|
35
|
+
"author": "",
|
|
36
|
+
"license": "ISC",
|
|
37
|
+
"packageManager": "pnpm@10.6.5",
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@codama/nodes-from-anchor": "^1.1.13",
|
|
40
|
+
"@codama/renderers": "^1.0.21",
|
|
41
|
+
"@solana/web3.js": "^1.98.2",
|
|
42
|
+
"@types/node": "^24.0.3",
|
|
43
|
+
"codama": "^1.2.13",
|
|
44
|
+
"tsconfig-to-dual-package": "^1.2.0",
|
|
45
|
+
"typedoc": "^0.28.3",
|
|
46
|
+
"typescript": "^5.8.3",
|
|
47
|
+
"vitest": "^3.2.4"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@solana/kit": "^2.1.0",
|
|
51
|
+
"@wuwei-labs/srsly": "2.0.0-beta.12"
|
|
52
|
+
},
|
|
53
|
+
"type": "module"
|
|
54
|
+
}
|