@wuwei-labs/srsly 2.0.0-beta.32 → 2.0.0-beta.34
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/codama/instructions/cancelRental.js +77 -12
- package/dist/cjs/codama/instructions/cancelRental.js.map +1 -1
- package/dist/cjs/codama/instructions/closeContract.js +57 -6
- package/dist/cjs/codama/instructions/closeContract.js.map +1 -1
- package/dist/cjs/codama/instructions/closeRental.js +95 -14
- package/dist/cjs/codama/instructions/closeRental.js.map +1 -1
- package/dist/cjs/contract/close.js +6 -7
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/utils/config.js +16 -3
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/fetch-accounts.js +115 -0
- package/dist/cjs/utils/fetch-accounts.js.map +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/codama/instructions/cancelRental.js +77 -12
- package/dist/esm/codama/instructions/cancelRental.js.map +1 -1
- package/dist/esm/codama/instructions/closeContract.js +59 -8
- package/dist/esm/codama/instructions/closeContract.js.map +1 -1
- package/dist/esm/codama/instructions/closeRental.js +95 -14
- package/dist/esm/codama/instructions/closeRental.js.map +1 -1
- package/dist/esm/contract/close.js +6 -7
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/utils/config.js +16 -3
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/esm/utils/fetch-accounts.js +109 -0
- package/dist/esm/utils/fetch-accounts.js.map +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/types/codama/instructions/cancelRental.d.ts +34 -22
- package/dist/types/codama/instructions/cancelRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/closeContract.d.ts +37 -25
- package/dist/types/codama/instructions/closeContract.d.ts.map +1 -1
- package/dist/types/codama/instructions/closeRental.d.ts +46 -26
- package/dist/types/codama/instructions/closeRental.d.ts.map +1 -1
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/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/fetch-accounts.d.ts +88 -0
- package/dist/types/utils/fetch-accounts.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/target/idl/srsly.json +179 -59
|
@@ -40,7 +40,9 @@ async function getCancelRentalInstructionAsync(input, config) {
|
|
|
40
40
|
const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS;
|
|
41
41
|
// Original accounts.
|
|
42
42
|
const originalAccounts = {
|
|
43
|
-
borrower: { value: input.borrower ?? null, isWritable:
|
|
43
|
+
borrower: { value: input.borrower ?? null, isWritable: true },
|
|
44
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
45
|
+
mint: { value: input.mint ?? null, isWritable: false },
|
|
44
46
|
borrowerTokenAccount: {
|
|
45
47
|
value: input.borrowerTokenAccount ?? null,
|
|
46
48
|
isWritable: true,
|
|
@@ -56,11 +58,37 @@ async function getCancelRentalInstructionAsync(input, config) {
|
|
|
56
58
|
value: input.rentalAuthority ?? null,
|
|
57
59
|
isWritable: false,
|
|
58
60
|
},
|
|
59
|
-
config: { value: input.config ?? null, isWritable: false },
|
|
60
61
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
62
|
+
associatedTokenProgram: {
|
|
63
|
+
value: input.associatedTokenProgram ?? null,
|
|
64
|
+
isWritable: false,
|
|
65
|
+
},
|
|
66
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
61
67
|
};
|
|
62
68
|
const accounts = originalAccounts;
|
|
63
69
|
// Resolve default values.
|
|
70
|
+
if (!accounts.config.value) {
|
|
71
|
+
accounts.config.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
72
|
+
programAddress,
|
|
73
|
+
seeds: [
|
|
74
|
+
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (!accounts.borrowerTokenAccount.value) {
|
|
79
|
+
accounts.borrowerTokenAccount.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
80
|
+
programAddress: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
81
|
+
seeds: [
|
|
82
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.borrower.value)),
|
|
83
|
+
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([
|
|
84
|
+
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
85
|
+
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
86
|
+
126, 255, 0, 169,
|
|
87
|
+
])),
|
|
88
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.mint.value)),
|
|
89
|
+
],
|
|
90
|
+
});
|
|
91
|
+
}
|
|
64
92
|
if (!accounts.rentalAuthority.value) {
|
|
65
93
|
accounts.rentalAuthority.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
66
94
|
programAddress,
|
|
@@ -94,11 +122,17 @@ async function getCancelRentalInstructionAsync(input, config) {
|
|
|
94
122
|
],
|
|
95
123
|
});
|
|
96
124
|
}
|
|
97
|
-
if (!accounts.
|
|
98
|
-
accounts.
|
|
99
|
-
programAddress,
|
|
125
|
+
if (!accounts.rentalTokenAccount.value) {
|
|
126
|
+
accounts.rentalTokenAccount.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
127
|
+
programAddress: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
100
128
|
seeds: [
|
|
101
|
-
(0, kit_1.
|
|
129
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.rentalState.value)),
|
|
130
|
+
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([
|
|
131
|
+
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
132
|
+
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
133
|
+
126, 255, 0, 169,
|
|
134
|
+
])),
|
|
135
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.mint.value)),
|
|
102
136
|
],
|
|
103
137
|
});
|
|
104
138
|
}
|
|
@@ -106,18 +140,29 @@ async function getCancelRentalInstructionAsync(input, config) {
|
|
|
106
140
|
accounts.tokenProgram.value =
|
|
107
141
|
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
108
142
|
}
|
|
143
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
144
|
+
accounts.associatedTokenProgram.value =
|
|
145
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
146
|
+
}
|
|
147
|
+
if (!accounts.systemProgram.value) {
|
|
148
|
+
accounts.systemProgram.value =
|
|
149
|
+
'11111111111111111111111111111111';
|
|
150
|
+
}
|
|
109
151
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
|
|
110
152
|
const instruction = {
|
|
111
153
|
accounts: [
|
|
112
154
|
getAccountMeta(accounts.borrower),
|
|
155
|
+
getAccountMeta(accounts.config),
|
|
156
|
+
getAccountMeta(accounts.mint),
|
|
113
157
|
getAccountMeta(accounts.borrowerTokenAccount),
|
|
114
158
|
getAccountMeta(accounts.rentalThread),
|
|
115
159
|
getAccountMeta(accounts.contract),
|
|
116
160
|
getAccountMeta(accounts.rentalState),
|
|
117
161
|
getAccountMeta(accounts.rentalTokenAccount),
|
|
118
162
|
getAccountMeta(accounts.rentalAuthority),
|
|
119
|
-
getAccountMeta(accounts.config),
|
|
120
163
|
getAccountMeta(accounts.tokenProgram),
|
|
164
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
165
|
+
getAccountMeta(accounts.systemProgram),
|
|
121
166
|
],
|
|
122
167
|
programAddress,
|
|
123
168
|
data: getCancelRentalInstructionDataEncoder().encode({}),
|
|
@@ -129,7 +174,9 @@ function getCancelRentalInstruction(input, config) {
|
|
|
129
174
|
const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS;
|
|
130
175
|
// Original accounts.
|
|
131
176
|
const originalAccounts = {
|
|
132
|
-
borrower: { value: input.borrower ?? null, isWritable:
|
|
177
|
+
borrower: { value: input.borrower ?? null, isWritable: true },
|
|
178
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
179
|
+
mint: { value: input.mint ?? null, isWritable: false },
|
|
133
180
|
borrowerTokenAccount: {
|
|
134
181
|
value: input.borrowerTokenAccount ?? null,
|
|
135
182
|
isWritable: true,
|
|
@@ -145,8 +192,12 @@ function getCancelRentalInstruction(input, config) {
|
|
|
145
192
|
value: input.rentalAuthority ?? null,
|
|
146
193
|
isWritable: false,
|
|
147
194
|
},
|
|
148
|
-
config: { value: input.config ?? null, isWritable: false },
|
|
149
195
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
196
|
+
associatedTokenProgram: {
|
|
197
|
+
value: input.associatedTokenProgram ?? null,
|
|
198
|
+
isWritable: false,
|
|
199
|
+
},
|
|
200
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
150
201
|
};
|
|
151
202
|
const accounts = originalAccounts;
|
|
152
203
|
// Resolve default values.
|
|
@@ -154,18 +205,29 @@ function getCancelRentalInstruction(input, config) {
|
|
|
154
205
|
accounts.tokenProgram.value =
|
|
155
206
|
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
156
207
|
}
|
|
208
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
209
|
+
accounts.associatedTokenProgram.value =
|
|
210
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
211
|
+
}
|
|
212
|
+
if (!accounts.systemProgram.value) {
|
|
213
|
+
accounts.systemProgram.value =
|
|
214
|
+
'11111111111111111111111111111111';
|
|
215
|
+
}
|
|
157
216
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
|
|
158
217
|
const instruction = {
|
|
159
218
|
accounts: [
|
|
160
219
|
getAccountMeta(accounts.borrower),
|
|
220
|
+
getAccountMeta(accounts.config),
|
|
221
|
+
getAccountMeta(accounts.mint),
|
|
161
222
|
getAccountMeta(accounts.borrowerTokenAccount),
|
|
162
223
|
getAccountMeta(accounts.rentalThread),
|
|
163
224
|
getAccountMeta(accounts.contract),
|
|
164
225
|
getAccountMeta(accounts.rentalState),
|
|
165
226
|
getAccountMeta(accounts.rentalTokenAccount),
|
|
166
227
|
getAccountMeta(accounts.rentalAuthority),
|
|
167
|
-
getAccountMeta(accounts.config),
|
|
168
228
|
getAccountMeta(accounts.tokenProgram),
|
|
229
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
230
|
+
getAccountMeta(accounts.systemProgram),
|
|
169
231
|
],
|
|
170
232
|
programAddress,
|
|
171
233
|
data: getCancelRentalInstructionDataEncoder().encode({}),
|
|
@@ -173,7 +235,7 @@ function getCancelRentalInstruction(input, config) {
|
|
|
173
235
|
return instruction;
|
|
174
236
|
}
|
|
175
237
|
function parseCancelRentalInstruction(instruction) {
|
|
176
|
-
if (instruction.accounts.length <
|
|
238
|
+
if (instruction.accounts.length < 12) {
|
|
177
239
|
// TODO: Coded error.
|
|
178
240
|
throw new Error('Not enough accounts');
|
|
179
241
|
}
|
|
@@ -187,14 +249,17 @@ function parseCancelRentalInstruction(instruction) {
|
|
|
187
249
|
programAddress: instruction.programAddress,
|
|
188
250
|
accounts: {
|
|
189
251
|
borrower: getNextAccount(),
|
|
252
|
+
config: getNextAccount(),
|
|
253
|
+
mint: getNextAccount(),
|
|
190
254
|
borrowerTokenAccount: getNextAccount(),
|
|
191
255
|
rentalThread: getNextAccount(),
|
|
192
256
|
contract: getNextAccount(),
|
|
193
257
|
rentalState: getNextAccount(),
|
|
194
258
|
rentalTokenAccount: getNextAccount(),
|
|
195
259
|
rentalAuthority: getNextAccount(),
|
|
196
|
-
config: getNextAccount(),
|
|
197
260
|
tokenProgram: getNextAccount(),
|
|
261
|
+
associatedTokenProgram: getNextAccount(),
|
|
262
|
+
systemProgram: getNextAccount(),
|
|
198
263
|
},
|
|
199
264
|
data: getCancelRentalInstructionDataDecoder().decode(instruction.data),
|
|
200
265
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancelRental.js","sourceRoot":"","sources":["../../../../src/codama/instructions/cancelRental.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAuCH,8EAIC;
|
|
1
|
+
{"version":3,"file":"cancelRental.js","sourceRoot":"","sources":["../../../../src/codama/instructions/cancelRental.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAuCH,8EAIC;AAwED,sFAKC;AAED,sFAIC;AAED,kFAQC;AA8BD,0EAoNC;AA8BD,gEAiIC;AAwBD,oEAoCC;AAnlBD,qCAyBqB;AACrB,0CAAoD;AACpD,sCAImB;AAEN,QAAA,2BAA2B,GAAG,IAAI,UAAU,CAAC;IACxD,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;CAC/B,CAAC,CAAC;AAEH,SAAgB,iCAAiC;IAC/C,OAAO,IAAA,oBAAc,EAAC,IAAA,qBAAe,GAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAChD,mCAA2B,CAC5B,CAAC;AACJ,CAAC;AAwED,SAAgB,q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AAE,CAAC;QACzD,YAAY,IAAI,CAAC,CAAC;QAClB,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;IACF,OAAO;QACL,cAAc,EAAE,WAAW,CAAC,cAAc;QAC1C,QAAQ,EAAE;YACR,QAAQ,EAAE,cAAc,EAAE;YAC1B,MAAM,EAAE,cAAc,EAAE;YACxB,IAAI,EAAE,cAAc,EAAE;YACtB,oBAAoB,EAAE,cAAc,EAAE;YACtC,YAAY,EAAE,cAAc,EAAE;YAC9B,QAAQ,EAAE,cAAc,EAAE;YAC1B,WAAW,EAAE,cAAc,EAAE;YAC7B,kBAAkB,EAAE,cAAc,EAAE;YACpC,eAAe,EAAE,cAAc,EAAE;YACjC,YAAY,EAAE,cAAc,EAAE;YAC9B,sBAAsB,EAAE,cAAc,EAAE;YACxC,aAAa,EAAE,cAAc,EAAE;SAChC;QACD,IAAI,EAAE,qCAAqC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;KACvE,CAAC;AACJ,CAAC"}
|
|
@@ -40,8 +40,9 @@ async function getCloseContractInstructionAsync(input, config) {
|
|
|
40
40
|
const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS;
|
|
41
41
|
// Original accounts.
|
|
42
42
|
const originalAccounts = {
|
|
43
|
-
config: { value: input.config ?? null, isWritable: false },
|
|
44
43
|
owner: { value: input.owner ?? null, isWritable: true },
|
|
44
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
45
|
+
mint: { value: input.mint ?? null, isWritable: false },
|
|
45
46
|
ownerTokenAccount: {
|
|
46
47
|
value: input.ownerTokenAccount ?? null,
|
|
47
48
|
isWritable: true,
|
|
@@ -63,6 +64,11 @@ async function getCloseContractInstructionAsync(input, config) {
|
|
|
63
64
|
sageProgram: { value: input.sageProgram ?? null, isWritable: false },
|
|
64
65
|
feeTokenAccount: { value: input.feeTokenAccount ?? null, isWritable: true },
|
|
65
66
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
67
|
+
associatedTokenProgram: {
|
|
68
|
+
value: input.associatedTokenProgram ?? null,
|
|
69
|
+
isWritable: false,
|
|
70
|
+
},
|
|
71
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
66
72
|
};
|
|
67
73
|
const accounts = originalAccounts;
|
|
68
74
|
// Resolve default values.
|
|
@@ -74,6 +80,20 @@ async function getCloseContractInstructionAsync(input, config) {
|
|
|
74
80
|
],
|
|
75
81
|
});
|
|
76
82
|
}
|
|
83
|
+
if (!accounts.ownerTokenAccount.value) {
|
|
84
|
+
accounts.ownerTokenAccount.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
85
|
+
programAddress: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
86
|
+
seeds: [
|
|
87
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.owner.value)),
|
|
88
|
+
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([
|
|
89
|
+
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
90
|
+
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
91
|
+
126, 255, 0, 169,
|
|
92
|
+
])),
|
|
93
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.mint.value)),
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
77
97
|
if (!accounts.rentalAuthority.value) {
|
|
78
98
|
accounts.rentalAuthority.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
79
99
|
programAddress,
|
|
@@ -89,11 +109,20 @@ async function getCloseContractInstructionAsync(input, config) {
|
|
|
89
109
|
accounts.tokenProgram.value =
|
|
90
110
|
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
91
111
|
}
|
|
112
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
113
|
+
accounts.associatedTokenProgram.value =
|
|
114
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
115
|
+
}
|
|
116
|
+
if (!accounts.systemProgram.value) {
|
|
117
|
+
accounts.systemProgram.value =
|
|
118
|
+
'11111111111111111111111111111111';
|
|
119
|
+
}
|
|
92
120
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
|
|
93
121
|
const instruction = {
|
|
94
122
|
accounts: [
|
|
95
|
-
getAccountMeta(accounts.config),
|
|
96
123
|
getAccountMeta(accounts.owner),
|
|
124
|
+
getAccountMeta(accounts.config),
|
|
125
|
+
getAccountMeta(accounts.mint),
|
|
97
126
|
getAccountMeta(accounts.ownerTokenAccount),
|
|
98
127
|
getAccountMeta(accounts.rentalTokenAccount),
|
|
99
128
|
getAccountMeta(accounts.rentalState),
|
|
@@ -106,6 +135,8 @@ async function getCloseContractInstructionAsync(input, config) {
|
|
|
106
135
|
getAccountMeta(accounts.sageProgram),
|
|
107
136
|
getAccountMeta(accounts.feeTokenAccount),
|
|
108
137
|
getAccountMeta(accounts.tokenProgram),
|
|
138
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
139
|
+
getAccountMeta(accounts.systemProgram),
|
|
109
140
|
],
|
|
110
141
|
programAddress,
|
|
111
142
|
data: getCloseContractInstructionDataEncoder().encode({}),
|
|
@@ -117,8 +148,9 @@ function getCloseContractInstruction(input, config) {
|
|
|
117
148
|
const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS;
|
|
118
149
|
// Original accounts.
|
|
119
150
|
const originalAccounts = {
|
|
120
|
-
config: { value: input.config ?? null, isWritable: false },
|
|
121
151
|
owner: { value: input.owner ?? null, isWritable: true },
|
|
152
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
153
|
+
mint: { value: input.mint ?? null, isWritable: false },
|
|
122
154
|
ownerTokenAccount: {
|
|
123
155
|
value: input.ownerTokenAccount ?? null,
|
|
124
156
|
isWritable: true,
|
|
@@ -140,6 +172,11 @@ function getCloseContractInstruction(input, config) {
|
|
|
140
172
|
sageProgram: { value: input.sageProgram ?? null, isWritable: false },
|
|
141
173
|
feeTokenAccount: { value: input.feeTokenAccount ?? null, isWritable: true },
|
|
142
174
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
175
|
+
associatedTokenProgram: {
|
|
176
|
+
value: input.associatedTokenProgram ?? null,
|
|
177
|
+
isWritable: false,
|
|
178
|
+
},
|
|
179
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
143
180
|
};
|
|
144
181
|
const accounts = originalAccounts;
|
|
145
182
|
// Resolve default values.
|
|
@@ -147,11 +184,20 @@ function getCloseContractInstruction(input, config) {
|
|
|
147
184
|
accounts.tokenProgram.value =
|
|
148
185
|
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
149
186
|
}
|
|
187
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
188
|
+
accounts.associatedTokenProgram.value =
|
|
189
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
190
|
+
}
|
|
191
|
+
if (!accounts.systemProgram.value) {
|
|
192
|
+
accounts.systemProgram.value =
|
|
193
|
+
'11111111111111111111111111111111';
|
|
194
|
+
}
|
|
150
195
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
|
|
151
196
|
const instruction = {
|
|
152
197
|
accounts: [
|
|
153
|
-
getAccountMeta(accounts.config),
|
|
154
198
|
getAccountMeta(accounts.owner),
|
|
199
|
+
getAccountMeta(accounts.config),
|
|
200
|
+
getAccountMeta(accounts.mint),
|
|
155
201
|
getAccountMeta(accounts.ownerTokenAccount),
|
|
156
202
|
getAccountMeta(accounts.rentalTokenAccount),
|
|
157
203
|
getAccountMeta(accounts.rentalState),
|
|
@@ -164,6 +210,8 @@ function getCloseContractInstruction(input, config) {
|
|
|
164
210
|
getAccountMeta(accounts.sageProgram),
|
|
165
211
|
getAccountMeta(accounts.feeTokenAccount),
|
|
166
212
|
getAccountMeta(accounts.tokenProgram),
|
|
213
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
214
|
+
getAccountMeta(accounts.systemProgram),
|
|
167
215
|
],
|
|
168
216
|
programAddress,
|
|
169
217
|
data: getCloseContractInstructionDataEncoder().encode({}),
|
|
@@ -171,7 +219,7 @@ function getCloseContractInstruction(input, config) {
|
|
|
171
219
|
return instruction;
|
|
172
220
|
}
|
|
173
221
|
function parseCloseContractInstruction(instruction) {
|
|
174
|
-
if (instruction.accounts.length <
|
|
222
|
+
if (instruction.accounts.length < 17) {
|
|
175
223
|
// TODO: Coded error.
|
|
176
224
|
throw new Error('Not enough accounts');
|
|
177
225
|
}
|
|
@@ -184,8 +232,9 @@ function parseCloseContractInstruction(instruction) {
|
|
|
184
232
|
return {
|
|
185
233
|
programAddress: instruction.programAddress,
|
|
186
234
|
accounts: {
|
|
187
|
-
config: getNextAccount(),
|
|
188
235
|
owner: getNextAccount(),
|
|
236
|
+
config: getNextAccount(),
|
|
237
|
+
mint: getNextAccount(),
|
|
189
238
|
ownerTokenAccount: getNextAccount(),
|
|
190
239
|
rentalTokenAccount: getNextAccount(),
|
|
191
240
|
rentalState: getNextAccount(),
|
|
@@ -198,6 +247,8 @@ function parseCloseContractInstruction(instruction) {
|
|
|
198
247
|
sageProgram: getNextAccount(),
|
|
199
248
|
feeTokenAccount: getNextAccount(),
|
|
200
249
|
tokenProgram: getNextAccount(),
|
|
250
|
+
associatedTokenProgram: getNextAccount(),
|
|
251
|
+
systemProgram: getNextAccount(),
|
|
201
252
|
},
|
|
202
253
|
data: getCloseContractInstructionDataDecoder().decode(instruction.data),
|
|
203
254
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closeContract.js","sourceRoot":"","sources":["../../../../src/codama/instructions/closeContract.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"closeContract.js","sourceRoot":"","s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ACR,KAAK,EAAE,cAAc,EAAE;YACvB,MAAM,EAAE,cAAc,EAAE;YACxB,IAAI,EAAE,cAAc,EAAE;YACtB,iBAAiB,EAAE,cAAc,EAAE;YACnC,kBAAkB,EAAE,cAAc,EAAE;YACpC,WAAW,EAAE,cAAc,EAAE;YAC7B,KAAK,EAAE,cAAc,EAAE;YACvB,MAAM,EAAE,cAAc,EAAE;YACxB,QAAQ,EAAE,cAAc,EAAE;YAC1B,cAAc,EAAE,cAAc,EAAE;YAChC,QAAQ,EAAE,cAAc,EAAE;YAC1B,eAAe,EAAE,cAAc,EAAE;YACjC,WAAW,EAAE,cAAc,EAAE;YAC7B,eAAe,EAAE,cAAc,EAAE;YACjC,YAAY,EAAE,cAAc,EAAE;YAC9B,sBAAsB,EAAE,cAAc,EAAE;YACxC,aAAa,EAAE,cAAc,EAAE;SAChC;QACD,IAAI,EAAE,sCAAsC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;KACxE,CAAC;AACJ,CAAC"}
|
|
@@ -40,7 +40,12 @@ async function getCloseRentalInstructionAsync(input, config) {
|
|
|
40
40
|
const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS;
|
|
41
41
|
// Original accounts.
|
|
42
42
|
const originalAccounts = {
|
|
43
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
44
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
45
|
+
mint: { value: input.mint ?? null, isWritable: false },
|
|
46
|
+
authority: { value: input.authority ?? null, isWritable: false },
|
|
43
47
|
borrower: { value: input.borrower ?? null, isWritable: true },
|
|
48
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
44
49
|
ownerTokenAccount: {
|
|
45
50
|
value: input.ownerTokenAccount ?? null,
|
|
46
51
|
isWritable: true,
|
|
@@ -57,13 +62,38 @@ async function getCloseRentalInstructionAsync(input, config) {
|
|
|
57
62
|
},
|
|
58
63
|
feeTokenAccount: { value: input.feeTokenAccount ?? null, isWritable: true },
|
|
59
64
|
rentalThread: { value: input.rentalThread ?? null, isWritable: true },
|
|
60
|
-
config: { value: input.config ?? null, isWritable: false },
|
|
61
65
|
antegenProgram: { value: input.antegenProgram ?? null, isWritable: false },
|
|
62
66
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
67
|
+
associatedTokenProgram: {
|
|
68
|
+
value: input.associatedTokenProgram ?? null,
|
|
69
|
+
isWritable: false,
|
|
70
|
+
},
|
|
63
71
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
64
72
|
};
|
|
65
73
|
const accounts = originalAccounts;
|
|
66
74
|
// Resolve default values.
|
|
75
|
+
if (!accounts.config.value) {
|
|
76
|
+
accounts.config.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
77
|
+
programAddress,
|
|
78
|
+
seeds: [
|
|
79
|
+
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (!accounts.ownerTokenAccount.value) {
|
|
84
|
+
accounts.ownerTokenAccount.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
85
|
+
programAddress: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
86
|
+
seeds: [
|
|
87
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.owner.value)),
|
|
88
|
+
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([
|
|
89
|
+
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
90
|
+
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
91
|
+
126, 255, 0, 169,
|
|
92
|
+
])),
|
|
93
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.mint.value)),
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
67
97
|
if (!accounts.rentalState.value) {
|
|
68
98
|
accounts.rentalState.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
69
99
|
programAddress,
|
|
@@ -76,6 +106,20 @@ async function getCloseRentalInstructionAsync(input, config) {
|
|
|
76
106
|
],
|
|
77
107
|
});
|
|
78
108
|
}
|
|
109
|
+
if (!accounts.rentalTokenAccount.value) {
|
|
110
|
+
accounts.rentalTokenAccount.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
111
|
+
programAddress: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
112
|
+
seeds: [
|
|
113
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.rentalState.value)),
|
|
114
|
+
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([
|
|
115
|
+
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
116
|
+
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
117
|
+
126, 255, 0, 169,
|
|
118
|
+
])),
|
|
119
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.mint.value)),
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
79
123
|
if (!accounts.rentalAuthority.value) {
|
|
80
124
|
accounts.rentalAuthority.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
81
125
|
programAddress,
|
|
@@ -87,6 +131,20 @@ async function getCloseRentalInstructionAsync(input, config) {
|
|
|
87
131
|
],
|
|
88
132
|
});
|
|
89
133
|
}
|
|
134
|
+
if (!accounts.feeTokenAccount.value) {
|
|
135
|
+
accounts.feeTokenAccount.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
136
|
+
programAddress: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
137
|
+
seeds: [
|
|
138
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.authority.value)),
|
|
139
|
+
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([
|
|
140
|
+
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
141
|
+
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
142
|
+
126, 255, 0, 169,
|
|
143
|
+
])),
|
|
144
|
+
(0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.mint.value)),
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
90
148
|
if (!accounts.rentalThread.value) {
|
|
91
149
|
accounts.rentalThread.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
92
150
|
programAddress,
|
|
@@ -97,14 +155,6 @@ async function getCloseRentalInstructionAsync(input, config) {
|
|
|
97
155
|
],
|
|
98
156
|
});
|
|
99
157
|
}
|
|
100
|
-
if (!accounts.config.value) {
|
|
101
|
-
accounts.config.value = await (0, kit_1.getProgramDerivedAddress)({
|
|
102
|
-
programAddress,
|
|
103
|
-
seeds: [
|
|
104
|
-
(0, kit_1.getBytesEncoder)().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
105
|
-
],
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
158
|
if (!accounts.antegenProgram.value) {
|
|
109
159
|
accounts.antegenProgram.value =
|
|
110
160
|
'AgThdyi1P5RkVeZD2rQahTvs8HePJoGFFxKtvok5s2J1';
|
|
@@ -113,6 +163,10 @@ async function getCloseRentalInstructionAsync(input, config) {
|
|
|
113
163
|
accounts.tokenProgram.value =
|
|
114
164
|
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
115
165
|
}
|
|
166
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
167
|
+
accounts.associatedTokenProgram.value =
|
|
168
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
169
|
+
}
|
|
116
170
|
if (!accounts.systemProgram.value) {
|
|
117
171
|
accounts.systemProgram.value =
|
|
118
172
|
'11111111111111111111111111111111';
|
|
@@ -120,7 +174,12 @@ async function getCloseRentalInstructionAsync(input, config) {
|
|
|
120
174
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
|
|
121
175
|
const instruction = {
|
|
122
176
|
accounts: [
|
|
177
|
+
getAccountMeta(accounts.payer),
|
|
178
|
+
getAccountMeta(accounts.config),
|
|
179
|
+
getAccountMeta(accounts.mint),
|
|
180
|
+
getAccountMeta(accounts.authority),
|
|
123
181
|
getAccountMeta(accounts.borrower),
|
|
182
|
+
getAccountMeta(accounts.owner),
|
|
124
183
|
getAccountMeta(accounts.ownerTokenAccount),
|
|
125
184
|
getAccountMeta(accounts.contract),
|
|
126
185
|
getAccountMeta(accounts.rentalState),
|
|
@@ -128,9 +187,9 @@ async function getCloseRentalInstructionAsync(input, config) {
|
|
|
128
187
|
getAccountMeta(accounts.rentalAuthority),
|
|
129
188
|
getAccountMeta(accounts.feeTokenAccount),
|
|
130
189
|
getAccountMeta(accounts.rentalThread),
|
|
131
|
-
getAccountMeta(accounts.config),
|
|
132
190
|
getAccountMeta(accounts.antegenProgram),
|
|
133
191
|
getAccountMeta(accounts.tokenProgram),
|
|
192
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
134
193
|
getAccountMeta(accounts.systemProgram),
|
|
135
194
|
],
|
|
136
195
|
programAddress,
|
|
@@ -143,7 +202,12 @@ function getCloseRentalInstruction(input, config) {
|
|
|
143
202
|
const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS;
|
|
144
203
|
// Original accounts.
|
|
145
204
|
const originalAccounts = {
|
|
205
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
206
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
207
|
+
mint: { value: input.mint ?? null, isWritable: false },
|
|
208
|
+
authority: { value: input.authority ?? null, isWritable: false },
|
|
146
209
|
borrower: { value: input.borrower ?? null, isWritable: true },
|
|
210
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
147
211
|
ownerTokenAccount: {
|
|
148
212
|
value: input.ownerTokenAccount ?? null,
|
|
149
213
|
isWritable: true,
|
|
@@ -160,9 +224,12 @@ function getCloseRentalInstruction(input, config) {
|
|
|
160
224
|
},
|
|
161
225
|
feeTokenAccount: { value: input.feeTokenAccount ?? null, isWritable: true },
|
|
162
226
|
rentalThread: { value: input.rentalThread ?? null, isWritable: true },
|
|
163
|
-
config: { value: input.config ?? null, isWritable: false },
|
|
164
227
|
antegenProgram: { value: input.antegenProgram ?? null, isWritable: false },
|
|
165
228
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
229
|
+
associatedTokenProgram: {
|
|
230
|
+
value: input.associatedTokenProgram ?? null,
|
|
231
|
+
isWritable: false,
|
|
232
|
+
},
|
|
166
233
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
167
234
|
};
|
|
168
235
|
const accounts = originalAccounts;
|
|
@@ -175,6 +242,10 @@ function getCloseRentalInstruction(input, config) {
|
|
|
175
242
|
accounts.tokenProgram.value =
|
|
176
243
|
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
177
244
|
}
|
|
245
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
246
|
+
accounts.associatedTokenProgram.value =
|
|
247
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
248
|
+
}
|
|
178
249
|
if (!accounts.systemProgram.value) {
|
|
179
250
|
accounts.systemProgram.value =
|
|
180
251
|
'11111111111111111111111111111111';
|
|
@@ -182,7 +253,12 @@ function getCloseRentalInstruction(input, config) {
|
|
|
182
253
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
|
|
183
254
|
const instruction = {
|
|
184
255
|
accounts: [
|
|
256
|
+
getAccountMeta(accounts.payer),
|
|
257
|
+
getAccountMeta(accounts.config),
|
|
258
|
+
getAccountMeta(accounts.mint),
|
|
259
|
+
getAccountMeta(accounts.authority),
|
|
185
260
|
getAccountMeta(accounts.borrower),
|
|
261
|
+
getAccountMeta(accounts.owner),
|
|
186
262
|
getAccountMeta(accounts.ownerTokenAccount),
|
|
187
263
|
getAccountMeta(accounts.contract),
|
|
188
264
|
getAccountMeta(accounts.rentalState),
|
|
@@ -190,9 +266,9 @@ function getCloseRentalInstruction(input, config) {
|
|
|
190
266
|
getAccountMeta(accounts.rentalAuthority),
|
|
191
267
|
getAccountMeta(accounts.feeTokenAccount),
|
|
192
268
|
getAccountMeta(accounts.rentalThread),
|
|
193
|
-
getAccountMeta(accounts.config),
|
|
194
269
|
getAccountMeta(accounts.antegenProgram),
|
|
195
270
|
getAccountMeta(accounts.tokenProgram),
|
|
271
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
196
272
|
getAccountMeta(accounts.systemProgram),
|
|
197
273
|
],
|
|
198
274
|
programAddress,
|
|
@@ -201,7 +277,7 @@ function getCloseRentalInstruction(input, config) {
|
|
|
201
277
|
return instruction;
|
|
202
278
|
}
|
|
203
279
|
function parseCloseRentalInstruction(instruction) {
|
|
204
|
-
if (instruction.accounts.length <
|
|
280
|
+
if (instruction.accounts.length < 17) {
|
|
205
281
|
// TODO: Coded error.
|
|
206
282
|
throw new Error('Not enough accounts');
|
|
207
283
|
}
|
|
@@ -214,7 +290,12 @@ function parseCloseRentalInstruction(instruction) {
|
|
|
214
290
|
return {
|
|
215
291
|
programAddress: instruction.programAddress,
|
|
216
292
|
accounts: {
|
|
293
|
+
payer: getNextAccount(),
|
|
294
|
+
config: getNextAccount(),
|
|
295
|
+
mint: getNextAccount(),
|
|
296
|
+
authority: getNextAccount(),
|
|
217
297
|
borrower: getNextAccount(),
|
|
298
|
+
owner: getNextAccount(),
|
|
218
299
|
ownerTokenAccount: getNextAccount(),
|
|
219
300
|
contract: getNextAccount(),
|
|
220
301
|
rentalState: getNextAccount(),
|
|
@@ -222,9 +303,9 @@ function parseCloseRentalInstruction(instruction) {
|
|
|
222
303
|
rentalAuthority: getNextAccount(),
|
|
223
304
|
feeTokenAccount: getNextAccount(),
|
|
224
305
|
rentalThread: getNextAccount(),
|
|
225
|
-
config: getNextAccount(),
|
|
226
306
|
antegenProgram: getNextAccount(),
|
|
227
307
|
tokenProgram: getNextAccount(),
|
|
308
|
+
associatedTokenProgram: getNextAccount(),
|
|
228
309
|
systemProgram: getNextAccount(),
|
|
229
310
|
},
|
|
230
311
|
data: getCloseRentalInstructionDataDecoder().decode(instruction.data),
|