mppx 0.6.2 → 0.6.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/CHANGELOG.md +6 -0
- package/dist/tempo/client/SessionManager.d.ts.map +1 -1
- package/dist/tempo/client/SessionManager.js +15 -1
- package/dist/tempo/client/SessionManager.js.map +1 -1
- package/dist/tempo/server/Session.d.ts.map +1 -1
- package/dist/tempo/server/Session.js +23 -0
- package/dist/tempo/server/Session.js.map +1 -1
- package/dist/tempo/server/internal/html.gen.d.ts +1 -1
- package/dist/tempo/server/internal/html.gen.d.ts.map +1 -1
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/server/internal/html.gen.js.map +1 -1
- package/dist/tempo/session/Chain.d.ts.map +1 -1
- package/dist/tempo/session/Chain.js +29 -0
- package/dist/tempo/session/Chain.js.map +1 -1
- package/package.json +1 -1
- package/src/tempo/client/SessionManager.ts +13 -1
- package/src/tempo/server/Session.test.ts +265 -3
- package/src/tempo/server/Session.ts +30 -0
- package/src/tempo/server/internal/html.gen.ts +1 -1
- package/src/tempo/session/Chain.ts +55 -0
|
@@ -94,6 +94,12 @@ function assertUint128(amount: bigint): void {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
function isTempoAccessKeyAccount(
|
|
98
|
+
account: Account,
|
|
99
|
+
): account is Account & { accessKeyAddress: Address } {
|
|
100
|
+
return 'accessKeyAddress' in account && typeof account.accessKeyAddress === 'string'
|
|
101
|
+
}
|
|
102
|
+
|
|
97
103
|
/** Options for {@link settleOnChain}. */
|
|
98
104
|
export type SettleOptions =
|
|
99
105
|
| { feePayer: Account; account: Account }
|
|
@@ -119,6 +125,15 @@ export async function settleOnChain(
|
|
|
119
125
|
const data = encodeFunctionData({ abi: escrowAbi, functionName: 'settle', args })
|
|
120
126
|
return sendFeePayerTx(client, resolved, options.feePayer, escrowContract, data, 'settle')
|
|
121
127
|
}
|
|
128
|
+
if (isTempoAccessKeyAccount(resolved)) {
|
|
129
|
+
return sendAccountTx(
|
|
130
|
+
client,
|
|
131
|
+
resolved,
|
|
132
|
+
escrowContract,
|
|
133
|
+
encodeFunctionData({ abi: escrowAbi, functionName: 'settle', args }),
|
|
134
|
+
'settle',
|
|
135
|
+
)
|
|
136
|
+
}
|
|
122
137
|
return writeContract(client, {
|
|
123
138
|
account: resolved,
|
|
124
139
|
chain: client.chain,
|
|
@@ -154,6 +169,15 @@ export async function closeOnChain(
|
|
|
154
169
|
const data = encodeFunctionData({ abi: escrowAbi, functionName: 'close', args })
|
|
155
170
|
return sendFeePayerTx(client, resolved, options.feePayer, escrowContract, data, 'close')
|
|
156
171
|
}
|
|
172
|
+
if (isTempoAccessKeyAccount(resolved)) {
|
|
173
|
+
return sendAccountTx(
|
|
174
|
+
client,
|
|
175
|
+
resolved,
|
|
176
|
+
escrowContract,
|
|
177
|
+
encodeFunctionData({ abi: escrowAbi, functionName: 'close', args }),
|
|
178
|
+
'close',
|
|
179
|
+
)
|
|
180
|
+
}
|
|
157
181
|
return writeContract(client, {
|
|
158
182
|
account: resolved,
|
|
159
183
|
chain: client.chain,
|
|
@@ -164,6 +188,37 @@ export async function closeOnChain(
|
|
|
164
188
|
})
|
|
165
189
|
}
|
|
166
190
|
|
|
191
|
+
async function sendAccountTx(
|
|
192
|
+
client: Client,
|
|
193
|
+
account: Account,
|
|
194
|
+
to: Address,
|
|
195
|
+
data: Hex,
|
|
196
|
+
label: string,
|
|
197
|
+
): Promise<Hex> {
|
|
198
|
+
const prepared = await prepareTransactionRequest(client, {
|
|
199
|
+
account,
|
|
200
|
+
calls: [{ to, data }],
|
|
201
|
+
} as never)
|
|
202
|
+
prepared.gas = prepared.gas! + 5_000n
|
|
203
|
+
|
|
204
|
+
const serialized = (await signTransaction(client, {
|
|
205
|
+
...prepared,
|
|
206
|
+
account,
|
|
207
|
+
} as never)) as Hex
|
|
208
|
+
|
|
209
|
+
const receipt = await sendRawTransactionSync(client, {
|
|
210
|
+
serializedTransaction: serialized as Transaction.TransactionSerializedTempo,
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
if (receipt.status !== 'success') {
|
|
214
|
+
throw new VerificationFailedError({
|
|
215
|
+
reason: `${label} transaction reverted: ${receipt.transactionHash}`,
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return receipt.transactionHash
|
|
220
|
+
}
|
|
221
|
+
|
|
167
222
|
/**
|
|
168
223
|
* Build, sign, and broadcast a fee-sponsored type-0x76 transaction.
|
|
169
224
|
*
|