@wuwei-labs/srsly 4.1.3 → 4.1.4
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 +4 -4
- package/dist/cjs/generated/codama/errors/srsly.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/acceptRental.js +6 -8
- package/dist/cjs/generated/codama/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/activateRental.js +3 -8
- 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 +4 -25
- 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/index.js +1 -1
- package/dist/cjs/generated/codama/types/index.js.map +1 -1
- package/dist/cjs/instructions/acceptRental.js +7 -2
- package/dist/cjs/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/instructions/reserveRental.js +12 -7
- 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 +106 -45
- package/dist/cjs/utils/discountAuth.js.map +1 -1
- package/dist/cjs/utils/index.js +6 -3
- 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 +3 -3
- package/dist/esm/generated/codama/errors/srsly.js.map +1 -1
- package/dist/esm/generated/codama/instructions/acceptRental.js +7 -9
- package/dist/esm/generated/codama/instructions/acceptRental.js.map +1 -1
- package/dist/esm/generated/codama/instructions/activateRental.js +3 -8
- 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 +5 -26
- 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/index.js +1 -1
- package/dist/esm/generated/codama/types/index.js.map +1 -1
- package/dist/esm/instructions/acceptRental.js +7 -2
- package/dist/esm/instructions/acceptRental.js.map +1 -1
- package/dist/esm/instructions/reserveRental.js +12 -7
- 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 +103 -45
- 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 +53 -95
- 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 +3 -3
- package/dist/types/generated/codama/errors/srsly.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/acceptRental.d.ts +24 -26
- package/dist/types/generated/codama/instructions/acceptRental.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/activateRental.d.ts +14 -21
- 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 +26 -32
- 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/index.d.ts +1 -1
- package/dist/types/generated/codama/types/index.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 +70 -38
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/legacy/index.ts"],"names":[],"mappings":"AAAA;;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tD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC"}
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAA0G,MAAM,aAAa,CAAC;AAC3L,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAA0G,MAAM,aAAa,CAAC;AAC3L,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAsB,MAAM,sBAAsB,CAAC;AA4FhG;;GAEG;AACH,MAAM,gBAAgB,GAA2B;IAC/C,CAAC,eAAe,CAAC,EAAE,qCAAqC;IACxD,CAAC,cAAc,CAAC,EAAE,+BAA+B;IACjD,sEAAsE;CACvE,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAA2B;IAC7C,UAAU,EAAE,+BAA+B;IAC3C,SAAS,EAAE,+BAA+B;IAC1C,SAAS,EAAE,qCAAqC;IAChD,UAAU,EAAE,uBAAuB;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD;;GAEG;AACH,IAAI,YAAY,GAAc;IAC5B,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,YAAY,CAAC,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AAS,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,YAAY,CAAC,MAA2B;IACtD,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAEnE,uDAAuD;IACvD,OAAO;QACL,GAAG,gBAAgB;QACnB,KAAK,EAAE,WAAW,CAAC,SAAS,IAAI,gBAAgB,CAAC,KAAK;KACvD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAAc;IACnD,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,CAAC;IACtD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @purpose Discount
|
|
2
|
+
* @purpose Discount authorization helper for server-side signing
|
|
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.
|
|
8
4
|
*/
|
|
9
5
|
import { address, createKeyPairSignerFromBytes } from '@solana/kit';
|
|
10
|
-
import {
|
|
6
|
+
import { createDiscountAuth as slyvaultCreateDiscountAuth, fetchMember } from '@wuwei-labs/slyvault';
|
|
11
7
|
import { getRpcUrl, mergeConfig } from './config';
|
|
12
8
|
import { createRpc } from './rpc';
|
|
13
9
|
/**
|
|
14
|
-
* Parse a stringified keypair (JSON array of bytes) into a
|
|
10
|
+
* Parse a stringified keypair (JSON array of bytes) into a KeyPairSigner
|
|
15
11
|
*/
|
|
16
12
|
async function parseKeypairString(keypairString) {
|
|
17
13
|
try {
|
|
@@ -26,38 +22,62 @@ async function parseKeypairString(keypairString) {
|
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
* Browser-compatible base64 encoding (Uint8Array -> string)
|
|
26
|
+
*/
|
|
27
|
+
function uint8ArrayToBase64(bytes) {
|
|
28
|
+
let binary = '';
|
|
29
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
30
|
+
binary += String.fromCharCode(bytes[i]);
|
|
31
|
+
}
|
|
32
|
+
return btoa(binary);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Browser-compatible base64 decoding (string -> Uint8Array)
|
|
36
|
+
*/
|
|
37
|
+
function base64ToUint8Array(base64) {
|
|
38
|
+
const binary = atob(base64);
|
|
39
|
+
const bytes = new Uint8Array(binary.length);
|
|
40
|
+
for (let i = 0; i < binary.length; i++) {
|
|
41
|
+
bytes[i] = binary.charCodeAt(i);
|
|
42
|
+
}
|
|
43
|
+
return bytes;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a signed discount authorization
|
|
36
47
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
48
|
+
* Server-side helper that fetches the member to get the nonce,
|
|
49
|
+
* then creates a signed discount authorization in a JSON-serializable format.
|
|
39
50
|
*
|
|
40
|
-
* @param params - Discount parameters
|
|
51
|
+
* @param params - Discount parameters including member address
|
|
41
52
|
* @param config - Optional SDK configuration overrides
|
|
42
|
-
* @returns
|
|
53
|
+
* @returns A SerializedDiscountAuth object ready for API transport
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import { createDiscount } from '@wuwei-labs/srsly';
|
|
58
|
+
*
|
|
59
|
+
* const discountAuth = await createDiscount({
|
|
60
|
+
* address: 'AFFILIATE_MEMBER_PDA',
|
|
61
|
+
* discount: 10, // 10%
|
|
62
|
+
* expirySlots: 1000, // ~6-7 minutes
|
|
63
|
+
* discountAuthority: serverKeypair,
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Ready to return via API - no serialization needed
|
|
67
|
+
* return discountAuth;
|
|
68
|
+
* ```
|
|
43
69
|
*/
|
|
44
|
-
export async function
|
|
70
|
+
export async function createDiscount(params, config) {
|
|
45
71
|
const finalConfig = mergeConfig(config);
|
|
46
72
|
const rpcUrl = getRpcUrl(finalConfig);
|
|
47
|
-
// Fetch member to get nonce
|
|
48
|
-
const memberAddr = address(params.
|
|
73
|
+
// Fetch member to get nonce
|
|
74
|
+
const memberAddr = address(params.address);
|
|
49
75
|
const member = await fetchMember(memberAddr, rpcUrl);
|
|
50
|
-
//
|
|
76
|
+
// Fetch current slot and compute absolute expiry
|
|
51
77
|
const rpc = createRpc(rpcUrl);
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const expiresAt = BigInt(now + params.expirySeconds);
|
|
56
|
-
// Generate random 16-byte nonce
|
|
57
|
-
const nonce = crypto.getRandomValues(new Uint8Array(16));
|
|
58
|
-
// Convert context to Address
|
|
59
|
-
const context = address(params.context);
|
|
60
|
-
// Convert discountAuthority to TransactionSigner
|
|
78
|
+
const currentSlot = await rpc.getSlot({ commitment: 'confirmed' }).send();
|
|
79
|
+
const expirySlot = currentSlot + BigInt(params.expirySlots);
|
|
80
|
+
// Convert discountAuthority to KeyPairSigner
|
|
61
81
|
let discountAuthority;
|
|
62
82
|
if (typeof params.discountAuthority === 'string') {
|
|
63
83
|
discountAuthority = await parseKeypairString(params.discountAuthority);
|
|
@@ -69,29 +89,67 @@ export async function createDiscountForRental(params, config) {
|
|
|
69
89
|
discountAuthority = await createKeyPairSignerFromBytes(new Uint8Array(params.discountAuthority));
|
|
70
90
|
}
|
|
71
91
|
else if ('secretKey' in params.discountAuthority && params.discountAuthority.secretKey instanceof Uint8Array) {
|
|
92
|
+
// web3.js Keypair
|
|
72
93
|
discountAuthority = await createKeyPairSignerFromBytes(params.discountAuthority.secretKey);
|
|
73
94
|
}
|
|
74
95
|
else {
|
|
96
|
+
// Already a KeyPairSigner
|
|
75
97
|
discountAuthority = params.discountAuthority;
|
|
76
98
|
}
|
|
77
|
-
//
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const createParams = {
|
|
82
|
-
authority: discountAuthority,
|
|
83
|
-
memberState: memberAddr,
|
|
84
|
-
vault: member.data.vault,
|
|
85
|
-
context,
|
|
86
|
-
nonce,
|
|
99
|
+
// Create the raw discount auth
|
|
100
|
+
const contextAddr = address(params.contextKey);
|
|
101
|
+
const raw = await slyvaultCreateDiscountAuth({
|
|
102
|
+
contextKey: contextAddr,
|
|
87
103
|
memberNonce: member.data.nonce,
|
|
88
104
|
discount: params.discount,
|
|
89
|
-
|
|
105
|
+
expirySlot,
|
|
106
|
+
discountAuthority,
|
|
107
|
+
});
|
|
108
|
+
// Return serialized format for API transport
|
|
109
|
+
return serializeDiscountAuth({ ...raw, context: contextAddr });
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Deserialize a discount authorization from API format
|
|
113
|
+
*
|
|
114
|
+
* Converts the JSON-safe SerializedDiscountAuth back to the format
|
|
115
|
+
* expected by the on-chain program.
|
|
116
|
+
*
|
|
117
|
+
* @internal Used by acceptRental and claimRental
|
|
118
|
+
*/
|
|
119
|
+
export function deserializeDiscountAuth(serialized) {
|
|
120
|
+
return {
|
|
121
|
+
context: address(serialized.context),
|
|
122
|
+
memberNonce: serialized.memberNonce,
|
|
123
|
+
discountBps: serialized.discountBps,
|
|
124
|
+
expirySlot: BigInt(serialized.expirySlot),
|
|
125
|
+
signature: base64ToUint8Array(serialized.signature),
|
|
90
126
|
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Serialize a raw discount authorization to JSON-safe format
|
|
130
|
+
*
|
|
131
|
+
* Converts bigint expirySlot and Uint8Array signature to string representations
|
|
132
|
+
* suitable for API transport (JSON.stringify/JSON.parse safe).
|
|
133
|
+
*
|
|
134
|
+
* @param raw - Raw discount authorization with bigint/Uint8Array fields
|
|
135
|
+
* @returns SerializedDiscountAuth ready for JSON transport
|
|
136
|
+
*/
|
|
137
|
+
export function serializeDiscountAuth(raw) {
|
|
91
138
|
return {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
139
|
+
context: raw.context,
|
|
140
|
+
memberNonce: raw.memberNonce,
|
|
141
|
+
discountBps: raw.discountBps,
|
|
142
|
+
expirySlot: raw.expirySlot.toString(),
|
|
143
|
+
signature: uint8ArrayToBase64(new Uint8Array(raw.signature)),
|
|
95
144
|
};
|
|
96
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Check if a value is a SerializedDiscountAuth
|
|
148
|
+
*/
|
|
149
|
+
export function isSerializedDiscountAuth(value) {
|
|
150
|
+
return (typeof value === 'object' &&
|
|
151
|
+
value !== null &&
|
|
152
|
+
'signature' in value &&
|
|
153
|
+
typeof value.signature === 'string');
|
|
154
|
+
}
|
|
97
155
|
//# sourceMappingURL=discountAuth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discountAuth.js","sourceRoot":"","sources":["../../../src/utils/discountAuth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"discountAuth.js","sourceRoot":"","sources":["../../../src/utils/discountAuth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAgB,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EACL,kBAAkB,IAAI,0BAA0B,EAChD,WAAW,EAEZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAkB,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC;;GAEG;AACH,KAAK,UAAU,kBAAkB,CA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AC,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,WAAW,IAAI,KAAK;QACpB,OAAQ,KAAgC,CAAC,SAAS,KAAK,QAAQ,CAChE,CAAC;AACJ,CAAC"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -20,6 +20,6 @@ export { createRpc, setRpcDebug, isRpcDebugEnabled } from './rpc';
|
|
|
20
20
|
export { fetchLookupTable, getLookupTableAddress } from './lookupTable';
|
|
21
21
|
// Rental Utilities
|
|
22
22
|
export { hasActiveRental, hasQueuedRental, } from './rental';
|
|
23
|
-
// Discount
|
|
24
|
-
export {
|
|
23
|
+
// Discount Authorization Utilities
|
|
24
|
+
export { createDiscount, serializeDiscountAuth, deserializeDiscountAuth, isSerializedDiscountAuth } from './discountAuth';
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gBAAgB;AAChB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAElB,oBAAoB;AACpB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAKnB,MAAM,aAAa,CAAC;AAErB,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EAEhB,MAAM,UAAU,CAAC;AAElB,wBAAwB;AACxB,OAAO,EACL,iBAAiB,EACjB,SAAS,EAIV,MAAM,UAAU,CAAC;AAElB,wBAAwB;AACxB,OAAO,EACL,mBAAmB,EAEpB,MAAM,gBAAgB,CAAC;AAExB,qBAAqB;AACrB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAElE,iCAAiC;AACjC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,eAAe,CAAC;AAEvB,mBAAmB;AACnB,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gBAAgB;AAChB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAElB,oBAAoB;AACpB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAKnB,MAAM,aAAa,CAAC;AAErB,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EAEhB,MAAM,UAAU,CAAC;AAElB,wBAAwB;AACxB,OAAO,EACL,iBAAiB,EACjB,SAAS,EAIV,MAAM,UAAU,CAAC;AAElB,wBAAwB;AACxB,OAAO,EACL,mBAAmB,EAEpB,MAAM,gBAAgB,CAAC;AAExB,qBAAqB;AACrB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAElE,iCAAiC;AACjC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,eAAe,CAAC;AAEvB,mBAAmB;AACnB,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB,mCAAmC;AACnC,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EAKzB,MAAM,gBAAgB,CAAC"}
|
package/dist/esm/version.js
CHANGED
package/dist/idl/srsly.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"address": "
|
|
2
|
+
"address": "SRSLYxcFnjd5jG2DpJw4as6UEyjwJQK1U4J1TD1hvZH",
|
|
3
3
|
"metadata": {
|
|
4
4
|
"name": "srsly",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.0.3",
|
|
6
6
|
"spec": "0.1.0",
|
|
7
7
|
"description": "Space Rental from SLY"
|
|
8
8
|
},
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"docs": [
|
|
13
13
|
"Accept a rental contract by providing payment and specifying duration.",
|
|
14
14
|
"Used when no active rental exists. For queued rentals, use reserve_rental.",
|
|
15
|
-
"Optionally includes
|
|
15
|
+
"Optionally includes discount authorization for referrer/affiliate discounts."
|
|
16
16
|
],
|
|
17
17
|
"discriminator": [
|
|
18
18
|
192,
|
|
@@ -218,14 +218,6 @@
|
|
|
218
218
|
"writable": true,
|
|
219
219
|
"optional": true
|
|
220
220
|
},
|
|
221
|
-
{
|
|
222
|
-
"name": "discount",
|
|
223
|
-
"docs": [
|
|
224
|
-
"Optional Discount PDA — passed through to slyvault deposit CPI (consumed there)"
|
|
225
|
-
],
|
|
226
|
-
"writable": true,
|
|
227
|
-
"optional": true
|
|
228
|
-
},
|
|
229
221
|
{
|
|
230
222
|
"name": "contract_thread",
|
|
231
223
|
"writable": true,
|
|
@@ -241,7 +233,7 @@
|
|
|
241
233
|
},
|
|
242
234
|
{
|
|
243
235
|
"name": "slyvault_program",
|
|
244
|
-
"address": "
|
|
236
|
+
"address": "VLTukwau1TDGhQUgBJfSSojSMv3BfnMHKrewnGN98M3"
|
|
245
237
|
},
|
|
246
238
|
{
|
|
247
239
|
"name": "antegen_program",
|
|
@@ -264,6 +256,16 @@
|
|
|
264
256
|
{
|
|
265
257
|
"name": "duration",
|
|
266
258
|
"type": "i64"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "discount_auth",
|
|
262
|
+
"type": {
|
|
263
|
+
"option": {
|
|
264
|
+
"defined": {
|
|
265
|
+
"name": "DiscountAuthorization"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
267
269
|
}
|
|
268
270
|
]
|
|
269
271
|
},
|
|
@@ -438,14 +440,6 @@
|
|
|
438
440
|
"writable": true,
|
|
439
441
|
"optional": true
|
|
440
442
|
},
|
|
441
|
-
{
|
|
442
|
-
"name": "discount",
|
|
443
|
-
"docs": [
|
|
444
|
-
"Optional Discount PDA — must be locked, consumed via slyvault deposit CPI"
|
|
445
|
-
],
|
|
446
|
-
"writable": true,
|
|
447
|
-
"optional": true
|
|
448
|
-
},
|
|
449
443
|
{
|
|
450
444
|
"name": "rental_authority",
|
|
451
445
|
"writable": true,
|
|
@@ -480,7 +474,7 @@
|
|
|
480
474
|
},
|
|
481
475
|
{
|
|
482
476
|
"name": "slyvault_program",
|
|
483
|
-
"address": "
|
|
477
|
+
"address": "VLTukwau1TDGhQUgBJfSSojSMv3BfnMHKrewnGN98M3"
|
|
484
478
|
},
|
|
485
479
|
{
|
|
486
480
|
"name": "fiber_program",
|
|
@@ -2284,11 +2278,11 @@
|
|
|
2284
2278
|
},
|
|
2285
2279
|
{
|
|
2286
2280
|
"name": "srsly_program",
|
|
2287
|
-
"address": "
|
|
2281
|
+
"address": "SRSLYxcFnjd5jG2DpJw4as6UEyjwJQK1U4J1TD1hvZH"
|
|
2288
2282
|
},
|
|
2289
2283
|
{
|
|
2290
2284
|
"name": "slyvault_program",
|
|
2291
|
-
"address": "
|
|
2285
|
+
"address": "VLTukwau1TDGhQUgBJfSSojSMv3BfnMHKrewnGN98M3"
|
|
2292
2286
|
},
|
|
2293
2287
|
{
|
|
2294
2288
|
"name": "token_program",
|
|
@@ -3082,11 +3076,11 @@
|
|
|
3082
3076
|
},
|
|
3083
3077
|
{
|
|
3084
3078
|
"name": "srsly_program",
|
|
3085
|
-
"address": "
|
|
3079
|
+
"address": "SRSLYxcFnjd5jG2DpJw4as6UEyjwJQK1U4J1TD1hvZH"
|
|
3086
3080
|
},
|
|
3087
3081
|
{
|
|
3088
3082
|
"name": "slyvault_program",
|
|
3089
|
-
"address": "
|
|
3083
|
+
"address": "VLTukwau1TDGhQUgBJfSSojSMv3BfnMHKrewnGN98M3"
|
|
3090
3084
|
},
|
|
3091
3085
|
{
|
|
3092
3086
|
"name": "token_program",
|
|
@@ -3659,7 +3653,8 @@
|
|
|
3659
3653
|
"# Arguments",
|
|
3660
3654
|
"* `bid_points` - Points to bid (burned; 0 if ATLAS bid)",
|
|
3661
3655
|
"* `bid_atlas` - ATLAS premium to bid (0 if points bid)",
|
|
3662
|
-
"* `duration` - Rental duration in seconds"
|
|
3656
|
+
"* `duration` - Rental duration in seconds",
|
|
3657
|
+
"* `discount_auth` - Optional discount authorization for deferred fee"
|
|
3663
3658
|
],
|
|
3664
3659
|
"discriminator": [
|
|
3665
3660
|
5,
|
|
@@ -3747,7 +3742,7 @@
|
|
|
3747
3742
|
{
|
|
3748
3743
|
"name": "defender_state",
|
|
3749
3744
|
"docs": [
|
|
3750
|
-
"Defender's borrower state (
|
|
3745
|
+
"Defender's borrower state (for knockoff refund + tracking)"
|
|
3751
3746
|
],
|
|
3752
3747
|
"writable": true,
|
|
3753
3748
|
"optional": true
|
|
@@ -3934,13 +3929,6 @@
|
|
|
3934
3929
|
"writable": true,
|
|
3935
3930
|
"optional": true
|
|
3936
3931
|
},
|
|
3937
|
-
{
|
|
3938
|
-
"name": "discount",
|
|
3939
|
-
"docs": [
|
|
3940
|
-
"Optional Discount PDA — read-only at reserve time, stored for deferred use at activation"
|
|
3941
|
-
],
|
|
3942
|
-
"optional": true
|
|
3943
|
-
},
|
|
3944
3932
|
{
|
|
3945
3933
|
"name": "rental_authority",
|
|
3946
3934
|
"pda": {
|
|
@@ -3972,10 +3960,6 @@
|
|
|
3972
3960
|
{
|
|
3973
3961
|
"name": "sage_program"
|
|
3974
3962
|
},
|
|
3975
|
-
{
|
|
3976
|
-
"name": "slyvault_program",
|
|
3977
|
-
"address": "6F45Qqc6fnzhxxo5ABwDMHcfxxtVhB8kbjJNabnpsZi7"
|
|
3978
|
-
},
|
|
3979
3963
|
{
|
|
3980
3964
|
"name": "antegen_program",
|
|
3981
3965
|
"address": "AgTv5w1UvUb6zeqkThwMrztGu9hpepBu8YLghuR4dpSx"
|
|
@@ -4009,6 +3993,16 @@
|
|
|
4009
3993
|
{
|
|
4010
3994
|
"name": "duration",
|
|
4011
3995
|
"type": "i64"
|
|
3996
|
+
},
|
|
3997
|
+
{
|
|
3998
|
+
"name": "discount_auth",
|
|
3999
|
+
"type": {
|
|
4000
|
+
"option": {
|
|
4001
|
+
"defined": {
|
|
4002
|
+
"name": "DiscountAuthorization"
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4012
4006
|
}
|
|
4013
4007
|
]
|
|
4014
4008
|
},
|
|
@@ -5050,8 +5044,8 @@
|
|
|
5050
5044
|
},
|
|
5051
5045
|
{
|
|
5052
5046
|
"code": 6091,
|
|
5053
|
-
"name": "
|
|
5054
|
-
"msg": "
|
|
5047
|
+
"name": "SelfKnockoffNotAllowed",
|
|
5048
|
+
"msg": "Cannot knock off your own reservation"
|
|
5055
5049
|
}
|
|
5056
5050
|
],
|
|
5057
5051
|
"types": [
|
|
@@ -5998,93 +5992,53 @@
|
|
|
5998
5992
|
}
|
|
5999
5993
|
},
|
|
6000
5994
|
{
|
|
6001
|
-
"name": "
|
|
5995
|
+
"name": "DiscountAuthorization",
|
|
6002
5996
|
"docs": [
|
|
6003
|
-
"
|
|
6004
|
-
""
|
|
6005
|
-
"Created by the discount authority (server-side), consumed at deposit time.",
|
|
6006
|
-
"Acts as a nullifier — once closed, the same nonce can never recreate it.",
|
|
6007
|
-
"Rent is paid by the affiliate MemberState PDA and returned on close.",
|
|
6008
|
-
"",
|
|
6009
|
-
"Seeds: [DISCOUNT_SEED, context.as_ref(), &nonce]"
|
|
5997
|
+
"Discount authorization signed by a member or affiliate",
|
|
5998
|
+
"Discount recipient is always the depositor (derived from context)"
|
|
6010
5999
|
],
|
|
6011
6000
|
"type": {
|
|
6012
6001
|
"kind": "struct",
|
|
6013
6002
|
"fields": [
|
|
6014
|
-
{
|
|
6015
|
-
"name": "version",
|
|
6016
|
-
"docs": [
|
|
6017
|
-
"Account version for future migrations"
|
|
6018
|
-
],
|
|
6019
|
-
"type": "u8"
|
|
6020
|
-
},
|
|
6021
|
-
{
|
|
6022
|
-
"name": "vault",
|
|
6023
|
-
"docs": [
|
|
6024
|
-
"Which vault this discount applies to"
|
|
6025
|
-
],
|
|
6026
|
-
"type": "pubkey"
|
|
6027
|
-
},
|
|
6028
6003
|
{
|
|
6029
6004
|
"name": "context",
|
|
6030
6005
|
"docs": [
|
|
6031
|
-
"Context
|
|
6032
|
-
],
|
|
6033
|
-
"type": "pubkey"
|
|
6034
|
-
},
|
|
6035
|
-
{
|
|
6036
|
-
"name": "rent_payer",
|
|
6037
|
-
"docs": [
|
|
6038
|
-
"Affiliate PDA that paid rent (gets it back on close)"
|
|
6006
|
+
"Context address the authorization is bound to (e.g. rental_state PDA)"
|
|
6039
6007
|
],
|
|
6040
6008
|
"type": "pubkey"
|
|
6041
6009
|
},
|
|
6042
6010
|
{
|
|
6043
6011
|
"name": "member_nonce",
|
|
6044
6012
|
"docs": [
|
|
6045
|
-
"
|
|
6013
|
+
"Member or Affiliate nonce (signer)"
|
|
6046
6014
|
],
|
|
6047
6015
|
"type": "u32"
|
|
6048
6016
|
},
|
|
6049
6017
|
{
|
|
6050
6018
|
"name": "discount_bps",
|
|
6051
6019
|
"docs": [
|
|
6052
|
-
"
|
|
6020
|
+
"Discount percentage in basis points (10000 = 100% of signer's allocation)"
|
|
6053
6021
|
],
|
|
6054
6022
|
"type": "u16"
|
|
6055
6023
|
},
|
|
6056
6024
|
{
|
|
6057
|
-
"name": "
|
|
6025
|
+
"name": "expiry_slot",
|
|
6058
6026
|
"docs": [
|
|
6059
|
-
"
|
|
6027
|
+
"Slot after which this authorization expires"
|
|
6060
6028
|
],
|
|
6061
|
-
"type": "
|
|
6029
|
+
"type": "u64"
|
|
6062
6030
|
},
|
|
6063
6031
|
{
|
|
6064
|
-
"name": "
|
|
6032
|
+
"name": "signature",
|
|
6065
6033
|
"docs": [
|
|
6066
|
-
"
|
|
6034
|
+
"Ed25519 signature of the authorization message"
|
|
6067
6035
|
],
|
|
6068
6036
|
"type": {
|
|
6069
6037
|
"array": [
|
|
6070
6038
|
"u8",
|
|
6071
|
-
|
|
6039
|
+
64
|
|
6072
6040
|
]
|
|
6073
6041
|
}
|
|
6074
|
-
},
|
|
6075
|
-
{
|
|
6076
|
-
"name": "locked",
|
|
6077
|
-
"docs": [
|
|
6078
|
-
"Whether this discount has been locked (reserved for deferred use)"
|
|
6079
|
-
],
|
|
6080
|
-
"type": "bool"
|
|
6081
|
-
},
|
|
6082
|
-
{
|
|
6083
|
-
"name": "bump",
|
|
6084
|
-
"docs": [
|
|
6085
|
-
"PDA bump seed"
|
|
6086
|
-
],
|
|
6087
|
-
"type": "u8"
|
|
6088
6042
|
}
|
|
6089
6043
|
]
|
|
6090
6044
|
}
|
|
@@ -6572,12 +6526,16 @@
|
|
|
6572
6526
|
}
|
|
6573
6527
|
},
|
|
6574
6528
|
{
|
|
6575
|
-
"name": "
|
|
6529
|
+
"name": "discount_auth",
|
|
6576
6530
|
"docs": [
|
|
6577
|
-
"Discount
|
|
6531
|
+
"Discount authorization for deferred fee payment"
|
|
6578
6532
|
],
|
|
6579
6533
|
"type": {
|
|
6580
|
-
"option":
|
|
6534
|
+
"option": {
|
|
6535
|
+
"defined": {
|
|
6536
|
+
"name": "DiscountAuthorization"
|
|
6537
|
+
}
|
|
6538
|
+
}
|
|
6581
6539
|
}
|
|
6582
6540
|
},
|
|
6583
6541
|
{
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @see https://github.com/codama-idl/codama
|
|
7
7
|
*/
|
|
8
8
|
import { fetchEncodedAccount, fetchEncodedAccounts, type Account, type Address, type Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type Option, type OptionOrNullable, type ReadonlyUint8Array } from "@solana/kit";
|
|
9
|
-
import { type RentalStatus, type RentalStatusArgs } from "../types";
|
|
9
|
+
import { type DiscountAuthorization, type DiscountAuthorizationArgs, type RentalStatus, type RentalStatusArgs } from "../types";
|
|
10
10
|
export declare const RENTAL_STATE_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
11
11
|
export declare function getRentalStateDiscriminatorBytes(): ReadonlyUint8Array;
|
|
12
12
|
export type RentalState = {
|
|
@@ -37,8 +37,8 @@ export type RentalState = {
|
|
|
37
37
|
serviceFee: bigint;
|
|
38
38
|
/** Referrer affiliate member for deferred fee tracking */
|
|
39
39
|
referrer: Option<Address>;
|
|
40
|
-
/** Discount
|
|
41
|
-
|
|
40
|
+
/** Discount authorization for deferred fee payment */
|
|
41
|
+
discountAuth: Option<DiscountAuthorization>;
|
|
42
42
|
/** Points bid for reservation knockoff comparison (0 if ATLAS bid) */
|
|
43
43
|
bidPoints: number;
|
|
44
44
|
/** ATLAS premium bid for reservation knockoff (0 if points bid) */
|
|
@@ -77,8 +77,8 @@ export type RentalStateArgs = {
|
|
|
77
77
|
serviceFee: number | bigint;
|
|
78
78
|
/** Referrer affiliate member for deferred fee tracking */
|
|
79
79
|
referrer: OptionOrNullable<Address>;
|
|
80
|
-
/** Discount
|
|
81
|
-
|
|
80
|
+
/** Discount authorization for deferred fee payment */
|
|
81
|
+
discountAuth: OptionOrNullable<DiscountAuthorizationArgs>;
|
|
82
82
|
/** Points bid for reservation knockoff comparison (0 if ATLAS bid) */
|
|
83
83
|
bidPoints: number;
|
|
84
84
|
/** ATLAS premium bid for reservation knockoff (0 if points bid) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rentalState.d.ts","sourceRoot":"","sources":["../../../../../src/generated/codama/accounts/rentalState.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAKL,mBAAmB,EACnB,oBAAoB,EAoBpB,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,
|
|
1
|
+
{"version":3,"file":"rentalState.d.ts","sourceRoot":"","sources":["../../../../../src/generated/codama/accounts/rentalState.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAKL,mBAAmB,EACnB,oBAAoB,EAoBpB,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAKL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,0BAA0B,yBAErC,CAA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