@wuwei-labs/srsly 4.1.2 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/generated/codama/accounts/rentalState.js +2 -2
- package/dist/cjs/generated/codama/accounts/rentalState.js.map +1 -1
- package/dist/cjs/generated/codama/errors/srsly.js +6 -3
- package/dist/cjs/generated/codama/errors/srsly.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/acceptRental.js +8 -6
- package/dist/cjs/generated/codama/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/activateRental.js +8 -3
- package/dist/cjs/generated/codama/instructions/activateRental.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/createConfig.js +4 -4
- package/dist/cjs/generated/codama/instructions/createConfig.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/deleteConfig.js +4 -4
- package/dist/cjs/generated/codama/instructions/deleteConfig.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/reserveRental.js +25 -4
- package/dist/cjs/generated/codama/instructions/reserveRental.js.map +1 -1
- package/dist/cjs/generated/codama/programs/srsly.js +1 -1
- package/dist/cjs/generated/codama/programs/srsly.js.map +1 -1
- package/dist/cjs/generated/codama/types/discount.js +45 -0
- package/dist/cjs/generated/codama/types/discount.js.map +1 -0
- package/dist/cjs/generated/codama/types/fleet.js +0 -14
- package/dist/cjs/generated/codama/types/fleet.js.map +1 -1
- package/dist/cjs/generated/codama/types/index.js +1 -2
- package/dist/cjs/generated/codama/types/index.js.map +1 -1
- package/dist/cjs/generated/codama/types/shipStats.js +0 -2
- package/dist/cjs/generated/codama/types/shipStats.js.map +1 -1
- package/dist/cjs/instructions/acceptRental.js +2 -7
- package/dist/cjs/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/instructions/reserveRental.js +9 -9
- package/dist/cjs/instructions/reserveRental.js.map +1 -1
- package/dist/cjs/kit/index.js +2 -2
- package/dist/cjs/kit/index.js.map +1 -1
- package/dist/cjs/legacy/index.js +2 -2
- package/dist/cjs/legacy/index.js.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/discountAuth.js +45 -106
- package/dist/cjs/utils/discountAuth.js.map +1 -1
- package/dist/cjs/utils/index.js +3 -6
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/generated/codama/accounts/rentalState.js +3 -3
- package/dist/esm/generated/codama/accounts/rentalState.js.map +1 -1
- package/dist/esm/generated/codama/errors/srsly.js +5 -2
- package/dist/esm/generated/codama/errors/srsly.js.map +1 -1
- package/dist/esm/generated/codama/instructions/acceptRental.js +9 -7
- package/dist/esm/generated/codama/instructions/acceptRental.js.map +1 -1
- package/dist/esm/generated/codama/instructions/activateRental.js +8 -3
- package/dist/esm/generated/codama/instructions/activateRental.js.map +1 -1
- package/dist/esm/generated/codama/instructions/createConfig.js +4 -4
- package/dist/esm/generated/codama/instructions/createConfig.js.map +1 -1
- package/dist/esm/generated/codama/instructions/deleteConfig.js +4 -4
- package/dist/esm/generated/codama/instructions/deleteConfig.js.map +1 -1
- package/dist/esm/generated/codama/instructions/reserveRental.js +26 -5
- package/dist/esm/generated/codama/instructions/reserveRental.js.map +1 -1
- package/dist/esm/generated/codama/programs/srsly.js +1 -1
- package/dist/esm/generated/codama/programs/srsly.js.map +1 -1
- package/dist/esm/generated/codama/types/discount.js +40 -0
- package/dist/esm/generated/codama/types/discount.js.map +1 -0
- package/dist/esm/generated/codama/types/fleet.js +1 -15
- package/dist/esm/generated/codama/types/fleet.js.map +1 -1
- package/dist/esm/generated/codama/types/index.js +1 -2
- package/dist/esm/generated/codama/types/index.js.map +1 -1
- package/dist/esm/generated/codama/types/shipStats.js +1 -3
- package/dist/esm/generated/codama/types/shipStats.js.map +1 -1
- package/dist/esm/instructions/acceptRental.js +2 -7
- package/dist/esm/instructions/acceptRental.js.map +1 -1
- package/dist/esm/instructions/reserveRental.js +10 -10
- package/dist/esm/instructions/reserveRental.js.map +1 -1
- package/dist/esm/kit/index.js +1 -1
- package/dist/esm/kit/index.js.map +1 -1
- package/dist/esm/legacy/index.js +1 -1
- package/dist/esm/legacy/index.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/esm/utils/discountAuth.js +45 -103
- package/dist/esm/utils/discountAuth.js.map +1 -1
- package/dist/esm/utils/index.js +2 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/idl/srsly.json +98 -146
- package/dist/types/generated/codama/accounts/rentalState.d.ts +5 -5
- package/dist/types/generated/codama/accounts/rentalState.d.ts.map +1 -1
- package/dist/types/generated/codama/errors/srsly.d.ts +4 -2
- package/dist/types/generated/codama/errors/srsly.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/acceptRental.d.ts +26 -24
- package/dist/types/generated/codama/instructions/acceptRental.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/activateRental.d.ts +21 -14
- package/dist/types/generated/codama/instructions/activateRental.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/createConfig.d.ts +1 -1
- package/dist/types/generated/codama/instructions/createConfig.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/deleteConfig.d.ts +1 -1
- package/dist/types/generated/codama/instructions/deleteConfig.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/reserveRental.d.ts +29 -23
- package/dist/types/generated/codama/instructions/reserveRental.d.ts.map +1 -1
- package/dist/types/generated/codama/programs/srsly.d.ts +2 -2
- package/dist/types/generated/codama/programs/srsly.d.ts.map +1 -1
- package/dist/types/generated/codama/types/discount.d.ts +65 -0
- package/dist/types/generated/codama/types/discount.d.ts.map +1 -0
- package/dist/types/generated/codama/types/fleet.d.ts +0 -14
- package/dist/types/generated/codama/types/fleet.d.ts.map +1 -1
- package/dist/types/generated/codama/types/index.d.ts +1 -2
- package/dist/types/generated/codama/types/index.d.ts.map +1 -1
- package/dist/types/generated/codama/types/shipStats.d.ts +1 -3
- package/dist/types/generated/codama/types/shipStats.d.ts.map +1 -1
- package/dist/types/instructions/acceptRental.d.ts +5 -5
- package/dist/types/instructions/acceptRental.d.ts.map +1 -1
- package/dist/types/instructions/reserveRental.d.ts +4 -4
- package/dist/types/instructions/reserveRental.d.ts.map +1 -1
- package/dist/types/kit/index.d.ts +1 -1
- package/dist/types/kit/index.d.ts.map +1 -1
- package/dist/types/legacy/index.d.ts +1 -1
- package/dist/types/legacy/index.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +3 -3
- package/dist/types/utils/config.d.ts.map +1 -1
- package/dist/types/utils/discountAuth.d.ts +38 -70
- package/dist/types/utils/discountAuth.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,94 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @purpose Discount
|
|
2
|
+
* @purpose Discount PDA helpers for rental discount vouchers
|
|
3
3
|
* @module utils/discountAuth
|
|
4
|
+
*
|
|
5
|
+
* The discount system uses on-chain PDAs instead of ed25519 signatures.
|
|
6
|
+
* Server creates a Discount PDA via slyvault's discount_create instruction,
|
|
7
|
+
* then returns the PDA address to the user for inclusion in rental transactions.
|
|
4
8
|
*/
|
|
5
|
-
import { type Address } from '@solana/kit';
|
|
6
|
-
import { type
|
|
9
|
+
import { type Address, type TransactionSigner } from '@solana/kit';
|
|
10
|
+
import { type CreateDiscountParams } from '@wuwei-labs/slyvault';
|
|
7
11
|
import { type SdkConfig } from './config';
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A signer that can sign transactions
|
|
14
|
+
*/
|
|
15
|
+
export type DiscountAuthoritySigner = TransactionSigner;
|
|
16
|
+
export interface CreateDiscountForRentalParams {
|
|
10
17
|
/** Affiliate member state PDA address */
|
|
11
|
-
|
|
12
|
-
/** Context address the
|
|
13
|
-
|
|
18
|
+
memberAddress: Address | string;
|
|
19
|
+
/** Context binding address (the borrower's wallet) */
|
|
20
|
+
context: Address | string;
|
|
14
21
|
/** Discount percentage (0-100) */
|
|
15
22
|
discount: number;
|
|
16
|
-
/**
|
|
17
|
-
|
|
23
|
+
/** Seconds from now until discount expires */
|
|
24
|
+
expirySeconds: number;
|
|
18
25
|
/**
|
|
19
26
|
* The discount authority signer
|
|
20
27
|
*
|
|
21
28
|
* Accepts:
|
|
22
|
-
* - A
|
|
29
|
+
* - A TransactionSigner from @solana/kit
|
|
23
30
|
* - A web3.js Keypair (with secretKey)
|
|
24
31
|
* - A Uint8Array or number[] of 64 bytes (secret key)
|
|
25
32
|
* - A JSON stringified keypair: "[1,2,3,...64 bytes]"
|
|
26
33
|
*/
|
|
27
|
-
discountAuthority:
|
|
34
|
+
discountAuthority: TransactionSigner | {
|
|
28
35
|
secretKey: Uint8Array;
|
|
29
36
|
} | Uint8Array | number[] | string;
|
|
30
37
|
}
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
export interface SerializedDiscountAuth {
|
|
35
|
-
/** Context address the authorization is bound to (e.g. rental_state PDA) */
|
|
36
|
-
context: string;
|
|
37
|
-
memberNonce: number;
|
|
38
|
-
discountBps: number;
|
|
39
|
-
/** Slot as string (bigint serialized) */
|
|
40
|
-
expirySlot: string;
|
|
41
|
-
/** Signature as base64 string */
|
|
42
|
-
signature: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Create a signed discount authorization
|
|
46
|
-
*
|
|
47
|
-
* Server-side helper that fetches the member to get the nonce,
|
|
48
|
-
* then creates a signed discount authorization in a JSON-serializable format.
|
|
49
|
-
*
|
|
50
|
-
* @param params - Discount parameters including member address
|
|
51
|
-
* @param config - Optional SDK configuration overrides
|
|
52
|
-
* @returns A SerializedDiscountAuth object ready for API transport
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* import { createDiscount } from '@wuwei-labs/srsly';
|
|
57
|
-
*
|
|
58
|
-
* const discountAuth = await createDiscount({
|
|
59
|
-
* address: 'AFFILIATE_MEMBER_PDA',
|
|
60
|
-
* discount: 10, // 10%
|
|
61
|
-
* expirySlots: 1000, // ~6-7 minutes
|
|
62
|
-
* discountAuthority: serverKeypair,
|
|
63
|
-
* });
|
|
64
|
-
*
|
|
65
|
-
* // Ready to return via API - no serialization needed
|
|
66
|
-
* return discountAuth;
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
export declare function createDiscount(params: CreateDiscountParams, config?: Partial<SdkConfig>): Promise<SerializedDiscountAuth>;
|
|
70
|
-
/**
|
|
71
|
-
* Deserialize a discount authorization from API format
|
|
72
|
-
*
|
|
73
|
-
* Converts the JSON-safe SerializedDiscountAuth back to the format
|
|
74
|
-
* expected by the on-chain program.
|
|
39
|
+
* Create a Discount PDA for a rental via slyvault's discount_create instruction.
|
|
75
40
|
*
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
41
|
+
* Server-side helper that:
|
|
42
|
+
* 1. Fetches the member to get nonce + vault
|
|
43
|
+
* 2. Generates a random 16-byte nonce
|
|
44
|
+
* 3. Derives the Discount PDA address
|
|
45
|
+
* 4. Returns the PDA address and the parameters needed to build the create_discount transaction
|
|
81
46
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
47
|
+
* The caller is responsible for building and sending the transaction with the
|
|
48
|
+
* codama-generated `discountCreate` instruction using the returned params.
|
|
84
49
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @
|
|
87
|
-
|
|
88
|
-
export declare function serializeDiscountAuth(raw: DiscountAuthorizationArgs): SerializedDiscountAuth;
|
|
89
|
-
/**
|
|
90
|
-
* Check if a value is a SerializedDiscountAuth
|
|
50
|
+
* @param params - Discount parameters
|
|
51
|
+
* @param config - Optional SDK configuration overrides
|
|
52
|
+
* @returns Object with the PDA address and instruction params
|
|
91
53
|
*/
|
|
92
|
-
export declare function
|
|
93
|
-
|
|
54
|
+
export declare function createDiscountForRental(params: CreateDiscountForRentalParams, config?: Partial<SdkConfig>): Promise<{
|
|
55
|
+
/** The Discount PDA address to pass to rental instructions */
|
|
56
|
+
discountPda: Address;
|
|
57
|
+
/** The rent payer (member_state PDA) */
|
|
58
|
+
rentPayer: Address;
|
|
59
|
+
/** Parameters for building the discount_create instruction */
|
|
60
|
+
createParams: CreateDiscountParams;
|
|
61
|
+
}>;
|
|
94
62
|
//# sourceMappingURL=discountAuth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discountAuth.d.ts","sourceRoot":"","sources":["../../../src/utils/discountAuth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"discountAuth.d.ts","sourceRoot":"","sources":["../../../src/utils/discountAuth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAW,KAAK,OAAO,EAAE,KAAK,iBAAiB,EAAgC,MAAM,aAAa,CAAC;AAC1G,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAGlE;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAiBxD,MAAM,WAAW,6BAA6B;IAC5C,yCAAyC;IACzC,aAAa,EAAE,OAAO,GAAG,MAAM,CAAC;IAChC,sDAAsD;IACtD,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,iBAAiB,EAAE,iBAAiB,GAAG;QAAE,SAAS,EAAE,UAAU,CAAA;KAAE,GAAG,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;CACnG;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,6BAA6B,EACrC,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAC1B,OAAO,CAAC;IACT,8DAA8D;IAC9D,WAAW,EAAE,OAAO,CAAC;IACrB,wCAAwC;IACxC,SAAS,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,YAAY,EAAE,oBAAoB,CAAC;CACpC,CAAC,CAyDD"}
|
|
@@ -11,5 +11,5 @@ export { InstructionResult, type LegacyInstruction } from './instructionResult';
|
|
|
11
11
|
export { createRpc, setRpcDebug, isRpcDebugEnabled } from './rpc';
|
|
12
12
|
export { fetchLookupTable, getLookupTableAddress, type AddressLookupTableData } from './lookupTable';
|
|
13
13
|
export { hasActiveRental, hasQueuedRental, } from './rental';
|
|
14
|
-
export {
|
|
14
|
+
export { createDiscountForRental, type CreateDiscountForRentalParams, type DiscountAuthoritySigner, } from './discountAuth';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACrB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EACf,KAAK,eAAe,EACrB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACrC,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,EAChC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGlE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACrB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EACf,KAAK,eAAe,EACrB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACrC,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,EAChC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGlE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,uBAAuB,EACvB,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.1.
|
|
1
|
+
export declare const VERSION = "4.1.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|