@dynamic-labs-sdk/tempo 1.41.0 → 1.42.0
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 +21 -0
- package/dist/exports/waas.d.ts +1 -0
- package/dist/exports/waas.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/{tempoChainIds-Ce9YCriF.cjs → tempoChainIds-BLY1kZtw.cjs} +2 -2
- package/dist/{tempoChainIds-Ce9YCriF.cjs.map → tempoChainIds-BLY1kZtw.cjs.map} +1 -1
- package/dist/{tempoChainIds-Dt0jiwLT.esm.js → tempoChainIds-D1VlZrU5.esm.js} +2 -2
- package/dist/{tempoChainIds-Dt0jiwLT.esm.js.map → tempoChainIds-D1VlZrU5.esm.js.map} +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas/sendTempoTransaction/sendTempoTransaction.d.ts +2 -0
- package/dist/waas/sendTempoTransaction/sendTempoTransaction.d.ts.map +1 -1
- package/dist/waas/signTempoTransaction/index.d.ts +2 -0
- package/dist/waas/signTempoTransaction/index.d.ts.map +1 -0
- package/dist/waas/signTempoTransaction/signTempoTransaction.d.ts +41 -0
- package/dist/waas/signTempoTransaction/signTempoTransaction.d.ts.map +1 -0
- package/dist/waas/utils/assertTransactionCanBeBroadcast/assertTransactionCanBeBroadcast.d.ts +17 -0
- package/dist/waas/utils/assertTransactionCanBeBroadcast/assertTransactionCanBeBroadcast.d.ts.map +1 -0
- package/dist/waas/utils/assertTransactionCanBeBroadcast/index.d.ts +2 -0
- package/dist/waas/utils/assertTransactionCanBeBroadcast/index.d.ts.map +1 -0
- package/dist/waas/utils/assertValidTempoFeePayerFields/assertValidTempoFeePayerFields.d.ts +22 -0
- package/dist/waas/utils/assertValidTempoFeePayerFields/assertValidTempoFeePayerFields.d.ts.map +1 -0
- package/dist/waas/utils/assertValidTempoFeePayerFields/index.d.ts +2 -0
- package/dist/waas/utils/assertValidTempoFeePayerFields/index.d.ts.map +1 -0
- package/dist/waas/utils/assertValidTempoTransactionRequest/assertValidTempoTransactionRequest.d.ts +4 -2
- package/dist/waas/utils/assertValidTempoTransactionRequest/assertValidTempoTransactionRequest.d.ts.map +1 -1
- package/dist/waas/utils/assertValidTempoValidityWindow/assertValidTempoValidityWindow.d.ts +22 -0
- package/dist/waas/utils/assertValidTempoValidityWindow/assertValidTempoValidityWindow.d.ts.map +1 -0
- package/dist/waas/utils/assertValidTempoValidityWindow/index.d.ts +2 -0
- package/dist/waas/utils/assertValidTempoValidityWindow/index.d.ts.map +1 -0
- package/dist/waas/utils/createViemWalletClientForWaasTempo/createViemWalletClientForWaasTempo.d.ts +2 -1
- package/dist/waas/utils/createViemWalletClientForWaasTempo/createViemWalletClientForWaasTempo.d.ts.map +1 -1
- package/dist/waas/utils/getTempoWalletClient/getTempoWalletClient.d.ts +21 -0
- package/dist/waas/utils/getTempoWalletClient/getTempoWalletClient.d.ts.map +1 -0
- package/dist/waas/utils/getTempoWalletClient/index.d.ts +2 -0
- package/dist/waas/utils/getTempoWalletClient/index.d.ts.map +1 -0
- package/dist/waas/utils/serializeTempoTransactionForWaas/serializeTempoTransactionForWaas.d.ts +3 -1
- package/dist/waas/utils/serializeTempoTransactionForWaas/serializeTempoTransactionForWaas.d.ts.map +1 -1
- package/dist/waas.cjs +176 -39
- package/dist/waas.cjs.map +1 -1
- package/dist/waas.esm.js +176 -40
- package/dist/waas.esm.js.map +1 -1
- package/package.json +4 -4
|
@@ -22,6 +22,7 @@ type SendTempoTransactionResult = {
|
|
|
22
22
|
* @param [client] - The Dynamic client instance. Only required when using multiple clients.
|
|
23
23
|
* @returns The transaction hash.
|
|
24
24
|
* @throws {InvalidParamError} If the wallet account is not a Tempo wallet account.
|
|
25
|
+
* @throws {TempoTransactionValidationError} If `awaitingFeePayer` is set, because a transaction that awaits a fee payer cannot be broadcast.
|
|
25
26
|
* @example
|
|
26
27
|
* ```ts
|
|
27
28
|
* const { transactionHash } = await sendTempoTransaction({
|
|
@@ -34,6 +35,7 @@ type SendTempoTransactionResult = {
|
|
|
34
35
|
* });
|
|
35
36
|
* ```
|
|
36
37
|
* @see sendTip20Transaction
|
|
38
|
+
* @see signTempoTransaction
|
|
37
39
|
* @see getTempoPublicClient
|
|
38
40
|
* @notInstrumented
|
|
39
41
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendTempoTransaction.d.ts","sourceRoot":"","sources":["../../../src/waas/sendTempoTransaction/sendTempoTransaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sendTempoTransaction.d.ts","sourceRoot":"","sources":["../../../src/waas/sendTempoTransaction/sendTempoTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAO9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAG3F,KAAK,0BAA0B,GAAG,IAAI,CACpC,uBAAuB,EACvB,OAAO,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,CACzE,GAAG;IACF,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,oBAAoB,sCACI,0BAA0B,gEAE5D,OAAO,CAAC,0BAA0B,CAmBpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/waas/signTempoTransaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { WalletAccount } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import type { TempoTransactionRequest } from '../utils/assertValidTempoTransactionRequest';
|
|
3
|
+
type SignTempoTransactionParams = Pick<TempoTransactionRequest, 'awaitingFeePayer' | 'calls' | 'feeToken' | 'gas' | 'nonceKey' | 'validAfter' | 'validBefore'> & {
|
|
4
|
+
walletAccount: WalletAccount;
|
|
5
|
+
};
|
|
6
|
+
type SignTempoTransactionResult = {
|
|
7
|
+
signedTransaction: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Signs a Tempo transaction with a Tempo embedded wallet without broadcasting
|
|
11
|
+
* it. Set `awaitingFeePayer` to sign a transaction whose fee a sponsor pays:
|
|
12
|
+
* the sender signs first, and the sponsor signs the returned transaction
|
|
13
|
+
* afterwards and broadcasts it.
|
|
14
|
+
*
|
|
15
|
+
* @param params.walletAccount - The Tempo embedded wallet account that signs.
|
|
16
|
+
* @param [params.awaitingFeePayer] - Leaves the fee to a sponsor who signs afterwards. Cannot be combined with `feeToken`.
|
|
17
|
+
* @param [params.calls] - The calls the transaction executes atomically.
|
|
18
|
+
* @param [params.feeToken] - TIP-20 token address used to pay the fee.
|
|
19
|
+
* @param [params.gas] - Gas limit. Defaults to a buffered estimate.
|
|
20
|
+
* @param [params.nonceKey] - Nonce key selecting a parallel nonce lane.
|
|
21
|
+
* @param [params.validAfter] - Unix timestamp after which the transaction is valid.
|
|
22
|
+
* @param [params.validBefore] - Unix timestamp after which the transaction expires.
|
|
23
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple clients.
|
|
24
|
+
* @returns The serialized signed transaction.
|
|
25
|
+
* @throws {InvalidParamError} If the wallet account is not a Tempo wallet account.
|
|
26
|
+
* @throws {TempoTransactionValidationError} If a field is malformed or inconsistent.
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const { signedTransaction } = await signTempoTransaction({
|
|
30
|
+
* awaitingFeePayer: true,
|
|
31
|
+
* calls: [{ data: transferData, to: tokenAddress }],
|
|
32
|
+
* walletAccount,
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
* @see sendTempoTransaction
|
|
36
|
+
* @see getTempoPublicClient
|
|
37
|
+
* @notInstrumented
|
|
38
|
+
*/
|
|
39
|
+
export declare const signTempoTransaction: ({ walletAccount, ...transaction }: SignTempoTransactionParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => Promise<SignTempoTransactionResult>;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=signTempoTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signTempoTransaction.d.ts","sourceRoot":"","sources":["../../../src/waas/signTempoTransaction/signTempoTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAO9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAE3F,KAAK,0BAA0B,GAAG,IAAI,CACpC,uBAAuB,EACrB,kBAAkB,GAClB,OAAO,GACP,UAAU,GACV,KAAK,GACL,UAAU,GACV,YAAY,GACZ,aAAa,CAChB,GAAG;IACF,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,oBAAoB,sCACI,0BAA0B,gEAE5D,OAAO,CAAC,0BAA0B,CAapC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rejects a transaction that awaits a fee payer, because broadcasting it
|
|
3
|
+
* before the sponsor signs would fail on the network.
|
|
4
|
+
*
|
|
5
|
+
* @param transaction - The transaction about to be broadcast.
|
|
6
|
+
* @returns Nothing. Throws when the transaction awaits a fee payer.
|
|
7
|
+
* @throws {TempoTransactionValidationError} If `awaitingFeePayer` is set.
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* assertTransactionCanBeBroadcast({ calls: [{ to: '0xabc' }] });
|
|
11
|
+
* ```
|
|
12
|
+
* @see signTempoTransaction
|
|
13
|
+
* @see sendTempoTransaction
|
|
14
|
+
* @notInstrumented
|
|
15
|
+
*/
|
|
16
|
+
export declare const assertTransactionCanBeBroadcast: (transaction: unknown) => void;
|
|
17
|
+
//# sourceMappingURL=assertTransactionCanBeBroadcast.d.ts.map
|
package/dist/waas/utils/assertTransactionCanBeBroadcast/assertTransactionCanBeBroadcast.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertTransactionCanBeBroadcast.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/assertTransactionCanBeBroadcast/assertTransactionCanBeBroadcast.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,+BAA+B,gBAAiB,OAAO,KAAG,IAWtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/assertTransactionCanBeBroadcast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rejects an inconsistent fee payer setup before it reaches the signer. A
|
|
3
|
+
* transaction that awaits a fee payer leaves the fee token to the sponsor, so
|
|
4
|
+
* it cannot name one.
|
|
5
|
+
*
|
|
6
|
+
* @param params.awaitingFeePayer - Whether a sponsor signs the transaction afterwards.
|
|
7
|
+
* @param [params.feeToken] - The TIP-20 token address that pays the fee.
|
|
8
|
+
* @returns Nothing. Throws on an inconsistent setup.
|
|
9
|
+
* @throws {TempoTransactionValidationError} If `awaitingFeePayer` is not true or is combined with `feeToken`.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* assertValidTempoFeePayerFields({ awaitingFeePayer: true });
|
|
13
|
+
* ```
|
|
14
|
+
* @see assertValidTempoTransactionRequest
|
|
15
|
+
* @see signTempoTransaction
|
|
16
|
+
* @notInstrumented
|
|
17
|
+
*/
|
|
18
|
+
export declare const assertValidTempoFeePayerFields: ({ awaitingFeePayer, feeToken, }: {
|
|
19
|
+
awaitingFeePayer?: true;
|
|
20
|
+
feeToken?: string;
|
|
21
|
+
}) => void;
|
|
22
|
+
//# sourceMappingURL=assertValidTempoFeePayerFields.d.ts.map
|
package/dist/waas/utils/assertValidTempoFeePayerFields/assertValidTempoFeePayerFields.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertValidTempoFeePayerFields.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/assertValidTempoFeePayerFields/assertValidTempoFeePayerFields.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,8BAA8B,oCAGxC;IACD,gBAAgB,CAAC,EAAE,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KAAG,IAUH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/assertValidTempoFeePayerFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/waas/utils/assertValidTempoTransactionRequest/assertValidTempoTransactionRequest.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import type { Hex, TransactionSerializable } from 'viem';
|
|
|
2
2
|
import type { TempoTransactionCall } from '../serializeTempoTransactionForWaas';
|
|
3
3
|
/**
|
|
4
4
|
* A Tempo transaction request. Extends the standard viem transaction with the
|
|
5
|
-
* Tempo fields: batched `calls`, `feeToken`, `nonceKey` (2D nonce)
|
|
6
|
-
* `validAfter` / `validBefore` expirations
|
|
5
|
+
* Tempo fields: batched `calls`, `feeToken`, `nonceKey` (2D nonce),
|
|
6
|
+
* `validAfter` / `validBefore` expirations and `awaitingFeePayer`, which leaves
|
|
7
|
+
* the fee to be paid by a sponsor who signs the transaction afterwards.
|
|
7
8
|
*
|
|
8
9
|
* @example
|
|
9
10
|
* ```ts
|
|
@@ -14,6 +15,7 @@ import type { TempoTransactionCall } from '../serializeTempoTransactionForWaas';
|
|
|
14
15
|
* ```
|
|
15
16
|
*/
|
|
16
17
|
export type TempoTransactionRequest = TransactionSerializable & {
|
|
18
|
+
awaitingFeePayer?: true;
|
|
17
19
|
calls?: readonly TempoTransactionCall[];
|
|
18
20
|
feeToken?: Hex;
|
|
19
21
|
nonceKey?: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertValidTempoTransactionRequest.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/assertValidTempoTransactionRequest/assertValidTempoTransactionRequest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,uBAAuB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"assertValidTempoTransactionRequest.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/assertValidTempoTransactionRequest/assertValidTempoTransactionRequest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,uBAAuB,EAAE,MAAM,MAAM,CAAC;AAKzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG,uBAAuB,GAAG;IAC9D,gBAAgB,CAAC,EAAE,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACxC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kCAAkC,8BAG5C;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,uBAAuB,CAAC;CACtC,KAAG,IAgCH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rejects a malformed validity window before it reaches the signer. Both
|
|
3
|
+
* bounds are non-negative integer Unix timestamps in seconds, and the window
|
|
4
|
+
* must open before it closes.
|
|
5
|
+
*
|
|
6
|
+
* @param params.validAfter - Unix timestamp after which the transaction is valid.
|
|
7
|
+
* @param params.validBefore - Unix timestamp after which the transaction expires.
|
|
8
|
+
* @returns Nothing. Throws on a malformed window.
|
|
9
|
+
* @throws {TempoTransactionValidationError} If a bound is not a non-negative integer or `validAfter` is not before `validBefore`.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* assertValidTempoValidityWindow({ validAfter: 100, validBefore: 200 });
|
|
13
|
+
* ```
|
|
14
|
+
* @see assertValidTempoTransactionRequest
|
|
15
|
+
* @see sendTempoTransaction
|
|
16
|
+
* @notInstrumented
|
|
17
|
+
*/
|
|
18
|
+
export declare const assertValidTempoValidityWindow: ({ validAfter, validBefore, }: {
|
|
19
|
+
validAfter?: number;
|
|
20
|
+
validBefore?: number;
|
|
21
|
+
}) => void;
|
|
22
|
+
//# sourceMappingURL=assertValidTempoValidityWindow.d.ts.map
|
package/dist/waas/utils/assertValidTempoValidityWindow/assertValidTempoValidityWindow.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertValidTempoValidityWindow.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/assertValidTempoValidityWindow/assertValidTempoValidityWindow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,8BAA8B,iCAGxC;IACD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,KAAG,IAmBH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/assertValidTempoValidityWindow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/waas/utils/createViemWalletClientForWaasTempo/createViemWalletClientForWaasTempo.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ type CreateViemWalletClientForWaasTempoParams = {
|
|
|
11
11
|
* Creates a viem wallet client for a Tempo embedded wallet account.
|
|
12
12
|
*
|
|
13
13
|
* Transactions are signed as Tempo transactions: batched `calls`, `feeToken`,
|
|
14
|
-
* `nonceKey
|
|
14
|
+
* `nonceKey`, `validAfter` / `validBefore` and `awaitingFeePayer` pass through
|
|
15
|
+
* to the signer. Gas
|
|
15
16
|
* is the larger of the caller's value and a 30% buffered estimate with a 300k
|
|
16
17
|
* floor, fees are at least the network gas price, and the nonce is the next
|
|
17
18
|
* one on the requested nonce lane.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createViemWalletClientForWaasTempo.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/createViemWalletClientForWaasTempo/createViemWalletClientForWaasTempo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EAEL,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,kBAAkB,EACnB,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"createViemWalletClientForWaasTempo.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/createViemWalletClientForWaasTempo/createViemWalletClientForWaasTempo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EAEL,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,kBAAkB,EACnB,MAAM,MAAM,CAAC;AAkDd,KAAK,wCAAwC,GAAG;IAC9C,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,sBAAsB,CAAC,EAAE,IAAI,CAC3B,kBAAkB,EAClB,SAAS,GAAG,OAAO,GAAG,WAAW,CAClC,CAAC;IACF,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,eAAO,MAAM,kCAAkC,kFAM1C,wCAAwC,iBAC5B,aAAa,KAC3B,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CA8LjD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DynamicClient, WalletAccount } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import type { Account, Chain, Transport, WalletClient } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the viem wallet client of a Tempo embedded wallet account.
|
|
5
|
+
*
|
|
6
|
+
* @param params.walletAccount - The Tempo embedded wallet account.
|
|
7
|
+
* @param client - The Dynamic client instance.
|
|
8
|
+
* @returns A viem wallet client bound to the Tempo account.
|
|
9
|
+
* @throws {InvalidParamError} If the wallet account is not a Tempo wallet account.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const walletClient = await getTempoWalletClient({ walletAccount }, client);
|
|
13
|
+
* ```
|
|
14
|
+
* @see sendTempoTransaction
|
|
15
|
+
* @see signTempoTransaction
|
|
16
|
+
* @notInstrumented
|
|
17
|
+
*/
|
|
18
|
+
export declare const getTempoWalletClient: ({ walletAccount }: {
|
|
19
|
+
walletAccount: WalletAccount;
|
|
20
|
+
}, client: DynamicClient) => Promise<WalletClient<Transport, Chain, Account>>;
|
|
21
|
+
//# sourceMappingURL=getTempoWalletClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTempoWalletClient.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/getTempoWalletClient/getTempoWalletClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK7E,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,sBACZ;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,UAC3C,aAAa,KACpB,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAejD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/getTempoWalletClient/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/waas/utils/serializeTempoTransactionForWaas/serializeTempoTransactionForWaas.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type TempoTransactionCall = {
|
|
|
16
16
|
value?: bigint;
|
|
17
17
|
};
|
|
18
18
|
export type SerializeTempoTransactionForWaasParams = {
|
|
19
|
+
/** Leaves the fee to a sponsor who signs the transaction after the sender. */
|
|
20
|
+
awaitingFeePayer?: boolean;
|
|
19
21
|
/** Calls executed atomically by the transaction, one entry per batched call. */
|
|
20
22
|
calls: readonly TempoTransactionCall[];
|
|
21
23
|
chainId: number;
|
|
@@ -53,5 +55,5 @@ export type SerializeTempoTransactionForWaasParams = {
|
|
|
53
55
|
* @see createWalletProviderForWaasTempo
|
|
54
56
|
* @notInstrumented
|
|
55
57
|
*/
|
|
56
|
-
export declare const serializeTempoTransactionForWaas: ({ calls, chainId, feeToken, gas, maxFeePerGas, maxPriorityFeePerGas, nonce, nonceKey, validAfter, validBefore, }: SerializeTempoTransactionForWaasParams) => string;
|
|
58
|
+
export declare const serializeTempoTransactionForWaas: ({ awaitingFeePayer, calls, chainId, feeToken, gas, maxFeePerGas, maxPriorityFeePerGas, nonce, nonceKey, validAfter, validBefore, }: SerializeTempoTransactionForWaasParams) => string;
|
|
57
59
|
//# sourceMappingURL=serializeTempoTransactionForWaas.d.ts.map
|
package/dist/waas/utils/serializeTempoTransactionForWaas/serializeTempoTransactionForWaas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeTempoTransactionForWaas.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/serializeTempoTransactionForWaas/serializeTempoTransactionForWaas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,gFAAgF;IAChF,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"serializeTempoTransactionForWaas.d.ts","sourceRoot":"","sources":["../../../../src/waas/utils/serializeTempoTransactionForWaas/serializeTempoTransactionForWaas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gFAAgF;IAChF,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gCAAgC,uIAY1C,sCAAsC,KAAG,MAiBzC,CAAC"}
|
package/dist/waas.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_tempoChainIds = require('./tempoChainIds-
|
|
1
|
+
const require_tempoChainIds = require('./tempoChainIds-BLY1kZtw.cjs');
|
|
2
2
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
3
3
|
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
4
4
|
let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
@@ -7,6 +7,77 @@ let _dynamic_labs_sdk_client_waas_core = require("@dynamic-labs-sdk/client/waas/
|
|
|
7
7
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
8
8
|
let viem_accounts = require("viem/accounts");
|
|
9
9
|
|
|
10
|
+
//#region src/errors/TempoTransactionValidationError/TempoTransactionValidationError.ts
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when a Tempo transaction fails validation before signing, for
|
|
13
|
+
* example because of a malformed address or non-hex call data.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* throw new TempoTransactionValidationError({ reason: 'malformed call data' });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see createWalletProviderForWaasTempo
|
|
21
|
+
* @see addWaasTempoExtension
|
|
22
|
+
*/
|
|
23
|
+
var TempoTransactionValidationError = class extends _dynamic_labs_sdk_client.BaseError {
|
|
24
|
+
constructor({ reason }) {
|
|
25
|
+
super({
|
|
26
|
+
cause: null,
|
|
27
|
+
code: "tempo_transaction_validation_error",
|
|
28
|
+
docsUrl: null,
|
|
29
|
+
name: "TempoTransactionValidationError",
|
|
30
|
+
shortMessage: `Invalid Tempo transaction: ${reason}`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/waas/utils/assertTransactionCanBeBroadcast/assertTransactionCanBeBroadcast.ts
|
|
37
|
+
/**
|
|
38
|
+
* Rejects a transaction that awaits a fee payer, because broadcasting it
|
|
39
|
+
* before the sponsor signs would fail on the network.
|
|
40
|
+
*
|
|
41
|
+
* @param transaction - The transaction about to be broadcast.
|
|
42
|
+
* @returns Nothing. Throws when the transaction awaits a fee payer.
|
|
43
|
+
* @throws {TempoTransactionValidationError} If `awaitingFeePayer` is set.
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* assertTransactionCanBeBroadcast({ calls: [{ to: '0xabc' }] });
|
|
47
|
+
* ```
|
|
48
|
+
* @see signTempoTransaction
|
|
49
|
+
* @see sendTempoTransaction
|
|
50
|
+
* @notInstrumented
|
|
51
|
+
*/
|
|
52
|
+
const assertTransactionCanBeBroadcast = (transaction) => {
|
|
53
|
+
if (typeof transaction === "object" && transaction !== null && "awaitingFeePayer" in transaction && transaction.awaitingFeePayer) throw new TempoTransactionValidationError({ reason: "awaitingFeePayer transactions cannot be broadcast, use signTempoTransaction" });
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/waas/utils/getTempoWalletClient/getTempoWalletClient.ts
|
|
58
|
+
/**
|
|
59
|
+
* Creates the viem wallet client of a Tempo embedded wallet account.
|
|
60
|
+
*
|
|
61
|
+
* @param params.walletAccount - The Tempo embedded wallet account.
|
|
62
|
+
* @param client - The Dynamic client instance.
|
|
63
|
+
* @returns A viem wallet client bound to the Tempo account.
|
|
64
|
+
* @throws {InvalidParamError} If the wallet account is not a Tempo wallet account.
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const walletClient = await getTempoWalletClient({ walletAccount }, client);
|
|
68
|
+
* ```
|
|
69
|
+
* @see sendTempoTransaction
|
|
70
|
+
* @see signTempoTransaction
|
|
71
|
+
* @notInstrumented
|
|
72
|
+
*/
|
|
73
|
+
const getTempoWalletClient = async ({ walletAccount }, client) => {
|
|
74
|
+
const walletProvider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
75
|
+
if (!require_tempoChainIds.isTempoWalletProvider(walletProvider)) throw new _dynamic_labs_sdk_client.InvalidParamError("Wallet account is not a Tempo wallet account");
|
|
76
|
+
(0, _dynamic_labs_sdk_client_core.assertDefined)(walletProvider.createViemWalletClient, "Tempo wallet provider cannot create a wallet client");
|
|
77
|
+
return await walletProvider.createViemWalletClient({ walletAccount });
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
10
81
|
//#region src/waas/sendTempoTransaction/sendTempoTransaction.ts
|
|
11
82
|
/**
|
|
12
83
|
* Sends a Tempo transaction from a Tempo embedded wallet, including the
|
|
@@ -24,6 +95,7 @@ let viem_accounts = require("viem/accounts");
|
|
|
24
95
|
* @param [client] - The Dynamic client instance. Only required when using multiple clients.
|
|
25
96
|
* @returns The transaction hash.
|
|
26
97
|
* @throws {InvalidParamError} If the wallet account is not a Tempo wallet account.
|
|
98
|
+
* @throws {TempoTransactionValidationError} If `awaitingFeePayer` is set, because a transaction that awaits a fee payer cannot be broadcast.
|
|
27
99
|
* @example
|
|
28
100
|
* ```ts
|
|
29
101
|
* const { transactionHash } = await sendTempoTransaction({
|
|
@@ -36,19 +108,56 @@ let viem_accounts = require("viem/accounts");
|
|
|
36
108
|
* });
|
|
37
109
|
* ```
|
|
38
110
|
* @see sendTip20Transaction
|
|
111
|
+
* @see signTempoTransaction
|
|
39
112
|
* @see getTempoPublicClient
|
|
40
113
|
* @notInstrumented
|
|
41
114
|
*/
|
|
42
115
|
const sendTempoTransaction = async ({ walletAccount, ...transaction }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(0, _dynamic_labs_sdk_client_core.assertDefined)(walletProvider.createViemWalletClient, "Tempo wallet provider cannot create a wallet client");
|
|
46
|
-
const walletClient = await walletProvider.createViemWalletClient({ walletAccount });
|
|
116
|
+
assertTransactionCanBeBroadcast(transaction);
|
|
117
|
+
const walletClient = await getTempoWalletClient({ walletAccount }, client);
|
|
47
118
|
(0, _dynamic_labs_sdk_client_core.assertDefined)(walletClient.account.signTransaction, "Tempo account cannot sign transactions");
|
|
48
119
|
const serializedTransaction = await walletClient.account.signTransaction(transaction);
|
|
49
120
|
return { transactionHash: await walletClient.sendRawTransaction({ serializedTransaction }) };
|
|
50
121
|
};
|
|
51
122
|
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/waas/signTempoTransaction/signTempoTransaction.ts
|
|
125
|
+
/**
|
|
126
|
+
* Signs a Tempo transaction with a Tempo embedded wallet without broadcasting
|
|
127
|
+
* it. Set `awaitingFeePayer` to sign a transaction whose fee a sponsor pays:
|
|
128
|
+
* the sender signs first, and the sponsor signs the returned transaction
|
|
129
|
+
* afterwards and broadcasts it.
|
|
130
|
+
*
|
|
131
|
+
* @param params.walletAccount - The Tempo embedded wallet account that signs.
|
|
132
|
+
* @param [params.awaitingFeePayer] - Leaves the fee to a sponsor who signs afterwards. Cannot be combined with `feeToken`.
|
|
133
|
+
* @param [params.calls] - The calls the transaction executes atomically.
|
|
134
|
+
* @param [params.feeToken] - TIP-20 token address used to pay the fee.
|
|
135
|
+
* @param [params.gas] - Gas limit. Defaults to a buffered estimate.
|
|
136
|
+
* @param [params.nonceKey] - Nonce key selecting a parallel nonce lane.
|
|
137
|
+
* @param [params.validAfter] - Unix timestamp after which the transaction is valid.
|
|
138
|
+
* @param [params.validBefore] - Unix timestamp after which the transaction expires.
|
|
139
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple clients.
|
|
140
|
+
* @returns The serialized signed transaction.
|
|
141
|
+
* @throws {InvalidParamError} If the wallet account is not a Tempo wallet account.
|
|
142
|
+
* @throws {TempoTransactionValidationError} If a field is malformed or inconsistent.
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const { signedTransaction } = await signTempoTransaction({
|
|
146
|
+
* awaitingFeePayer: true,
|
|
147
|
+
* calls: [{ data: transferData, to: tokenAddress }],
|
|
148
|
+
* walletAccount,
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
* @see sendTempoTransaction
|
|
152
|
+
* @see getTempoPublicClient
|
|
153
|
+
* @notInstrumented
|
|
154
|
+
*/
|
|
155
|
+
const signTempoTransaction = async ({ walletAccount, ...transaction }, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
156
|
+
const walletClient = await getTempoWalletClient({ walletAccount }, client);
|
|
157
|
+
(0, _dynamic_labs_sdk_client_core.assertDefined)(walletClient.account.signTransaction, "Tempo account cannot sign transactions");
|
|
158
|
+
return { signedTransaction: await walletClient.account.signTransaction(transaction) };
|
|
159
|
+
};
|
|
160
|
+
|
|
52
161
|
//#endregion
|
|
53
162
|
//#region src/constants.ts
|
|
54
163
|
/**
|
|
@@ -200,32 +309,6 @@ var TempoRawMessageNotUtf8Error = class extends _dynamic_labs_sdk_client.BaseErr
|
|
|
200
309
|
}
|
|
201
310
|
};
|
|
202
311
|
|
|
203
|
-
//#endregion
|
|
204
|
-
//#region src/errors/TempoTransactionValidationError/TempoTransactionValidationError.ts
|
|
205
|
-
/**
|
|
206
|
-
* Thrown when a Tempo transaction fails validation before signing, for
|
|
207
|
-
* example because of a malformed address or non-hex call data.
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```ts
|
|
211
|
-
* throw new TempoTransactionValidationError({ reason: 'malformed call data' });
|
|
212
|
-
* ```
|
|
213
|
-
*
|
|
214
|
-
* @see createWalletProviderForWaasTempo
|
|
215
|
-
* @see addWaasTempoExtension
|
|
216
|
-
*/
|
|
217
|
-
var TempoTransactionValidationError = class extends _dynamic_labs_sdk_client.BaseError {
|
|
218
|
-
constructor({ reason }) {
|
|
219
|
-
super({
|
|
220
|
-
cause: null,
|
|
221
|
-
code: "tempo_transaction_validation_error",
|
|
222
|
-
docsUrl: null,
|
|
223
|
-
name: "TempoTransactionValidationError",
|
|
224
|
-
shortMessage: `Invalid Tempo transaction: ${reason}`
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
|
|
229
312
|
//#endregion
|
|
230
313
|
//#region src/errors/TempoTypedDataNotSupportedError/TempoTypedDataNotSupportedError.ts
|
|
231
314
|
/**
|
|
@@ -276,6 +359,54 @@ const assertValidTempoTransactionCalls = ({ calls }) => {
|
|
|
276
359
|
}
|
|
277
360
|
};
|
|
278
361
|
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/waas/utils/assertValidTempoFeePayerFields/assertValidTempoFeePayerFields.ts
|
|
364
|
+
/**
|
|
365
|
+
* Rejects an inconsistent fee payer setup before it reaches the signer. A
|
|
366
|
+
* transaction that awaits a fee payer leaves the fee token to the sponsor, so
|
|
367
|
+
* it cannot name one.
|
|
368
|
+
*
|
|
369
|
+
* @param params.awaitingFeePayer - Whether a sponsor signs the transaction afterwards.
|
|
370
|
+
* @param [params.feeToken] - The TIP-20 token address that pays the fee.
|
|
371
|
+
* @returns Nothing. Throws on an inconsistent setup.
|
|
372
|
+
* @throws {TempoTransactionValidationError} If `awaitingFeePayer` is not true or is combined with `feeToken`.
|
|
373
|
+
* @example
|
|
374
|
+
* ```ts
|
|
375
|
+
* assertValidTempoFeePayerFields({ awaitingFeePayer: true });
|
|
376
|
+
* ```
|
|
377
|
+
* @see assertValidTempoTransactionRequest
|
|
378
|
+
* @see signTempoTransaction
|
|
379
|
+
* @notInstrumented
|
|
380
|
+
*/
|
|
381
|
+
const assertValidTempoFeePayerFields = ({ awaitingFeePayer, feeToken }) => {
|
|
382
|
+
if (awaitingFeePayer !== void 0 && awaitingFeePayer !== true) throw new TempoTransactionValidationError({ reason: "awaitingFeePayer must be true" });
|
|
383
|
+
if (awaitingFeePayer && feeToken !== void 0) throw new TempoTransactionValidationError({ reason: "awaitingFeePayer cannot be combined with feeToken" });
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region src/waas/utils/assertValidTempoValidityWindow/assertValidTempoValidityWindow.ts
|
|
388
|
+
/**
|
|
389
|
+
* Rejects a malformed validity window before it reaches the signer. Both
|
|
390
|
+
* bounds are non-negative integer Unix timestamps in seconds, and the window
|
|
391
|
+
* must open before it closes.
|
|
392
|
+
*
|
|
393
|
+
* @param params.validAfter - Unix timestamp after which the transaction is valid.
|
|
394
|
+
* @param params.validBefore - Unix timestamp after which the transaction expires.
|
|
395
|
+
* @returns Nothing. Throws on a malformed window.
|
|
396
|
+
* @throws {TempoTransactionValidationError} If a bound is not a non-negative integer or `validAfter` is not before `validBefore`.
|
|
397
|
+
* @example
|
|
398
|
+
* ```ts
|
|
399
|
+
* assertValidTempoValidityWindow({ validAfter: 100, validBefore: 200 });
|
|
400
|
+
* ```
|
|
401
|
+
* @see assertValidTempoTransactionRequest
|
|
402
|
+
* @see sendTempoTransaction
|
|
403
|
+
* @notInstrumented
|
|
404
|
+
*/
|
|
405
|
+
const assertValidTempoValidityWindow = ({ validAfter, validBefore }) => {
|
|
406
|
+
for (const [field, value] of [["validAfter", validAfter], ["validBefore", validBefore]]) if (value !== void 0 && (!Number.isInteger(value) || value < 0)) throw new TempoTransactionValidationError({ reason: `${field} must be a non-negative integer timestamp` });
|
|
407
|
+
if (validAfter !== void 0 && validBefore !== void 0 && validAfter >= validBefore) throw new TempoTransactionValidationError({ reason: "validAfter must be before validBefore" });
|
|
408
|
+
};
|
|
409
|
+
|
|
279
410
|
//#endregion
|
|
280
411
|
//#region src/waas/utils/assertValidTempoTransactionRequest/assertValidTempoTransactionRequest.ts
|
|
281
412
|
/**
|
|
@@ -294,14 +425,11 @@ const assertValidTempoTransactionCalls = ({ calls }) => {
|
|
|
294
425
|
*/
|
|
295
426
|
const assertValidTempoTransactionRequest = ({ transaction, chainId }) => {
|
|
296
427
|
if (transaction.feeToken !== void 0 && !(0, viem.isAddress)(transaction.feeToken)) throw new TempoTransactionValidationError({ reason: "malformed feeToken address" });
|
|
428
|
+
assertValidTempoFeePayerFields(transaction);
|
|
297
429
|
if (transaction.calls !== void 0 && (transaction.to !== void 0 || transaction.data !== void 0 || transaction.value !== void 0)) throw new TempoTransactionValidationError({ reason: "calls cannot be combined with top-level to, data or value" });
|
|
298
430
|
if (transaction.chainId !== void 0 && transaction.chainId !== chainId) throw new TempoTransactionValidationError({ reason: "chainId does not match the active Tempo network" });
|
|
299
431
|
if (transaction.nonceKey !== void 0 && (typeof transaction.nonceKey !== "bigint" || transaction.nonceKey < 0n)) throw new TempoTransactionValidationError({ reason: "nonceKey must be a non-negative bigint" });
|
|
300
|
-
|
|
301
|
-
const value = transaction[field];
|
|
302
|
-
if (value !== void 0 && (!Number.isInteger(value) || value < 0)) throw new TempoTransactionValidationError({ reason: `${field} must be a non-negative integer timestamp` });
|
|
303
|
-
}
|
|
304
|
-
if (transaction.validAfter !== void 0 && transaction.validBefore !== void 0 && transaction.validAfter >= transaction.validBefore) throw new TempoTransactionValidationError({ reason: "validAfter must be before validBefore" });
|
|
432
|
+
assertValidTempoValidityWindow(transaction);
|
|
305
433
|
};
|
|
306
434
|
|
|
307
435
|
//#endregion
|
|
@@ -347,13 +475,14 @@ const isBusinessAccountWalletAccount = (walletAccount) => "businessAccountId" in
|
|
|
347
475
|
* @see createWalletProviderForWaasTempo
|
|
348
476
|
* @notInstrumented
|
|
349
477
|
*/
|
|
350
|
-
const serializeTempoTransactionForWaas = ({ calls, chainId, feeToken, gas, maxFeePerGas, maxPriorityFeePerGas, nonce, nonceKey, validAfter, validBefore }) => JSON.stringify({
|
|
478
|
+
const serializeTempoTransactionForWaas = ({ awaitingFeePayer, calls, chainId, feeToken, gas, maxFeePerGas, maxPriorityFeePerGas, nonce, nonceKey, validAfter, validBefore }) => JSON.stringify({
|
|
351
479
|
calls: calls.map(({ data, to, value }) => ({
|
|
352
480
|
data,
|
|
353
481
|
to,
|
|
354
482
|
value
|
|
355
483
|
})),
|
|
356
484
|
chainId,
|
|
485
|
+
feePayer: awaitingFeePayer ? true : void 0,
|
|
357
486
|
feeToken,
|
|
358
487
|
gas,
|
|
359
488
|
maxFeePerGas,
|
|
@@ -438,7 +567,8 @@ const TEMPO_NONCE_MANAGER_ABI = [{
|
|
|
438
567
|
* Creates a viem wallet client for a Tempo embedded wallet account.
|
|
439
568
|
*
|
|
440
569
|
* Transactions are signed as Tempo transactions: batched `calls`, `feeToken`,
|
|
441
|
-
* `nonceKey
|
|
570
|
+
* `nonceKey`, `validAfter` / `validBefore` and `awaitingFeePayer` pass through
|
|
571
|
+
* to the signer. Gas
|
|
442
572
|
* is the larger of the caller's value and a 30% buffered estimate with a 300k
|
|
443
573
|
* floor, fees are at least the network gas price, and the nonce is the next
|
|
444
574
|
* one on the requested nonce lane.
|
|
@@ -497,7 +627,7 @@ const createViemWalletClientForWaasTempo = async ({ waasProvider, walletAccount,
|
|
|
497
627
|
functionName: "getNonce"
|
|
498
628
|
}));
|
|
499
629
|
};
|
|
500
|
-
|
|
630
|
+
const walletClient = (0, viem.createWalletClient)({
|
|
501
631
|
account: (0, viem_accounts.toAccount)({
|
|
502
632
|
address: walletAccount.address,
|
|
503
633
|
signMessage: async ({ message }) => {
|
|
@@ -542,6 +672,7 @@ const createViemWalletClientForWaasTempo = async ({ waasProvider, walletAccount,
|
|
|
542
672
|
const maxPriorityFeePerGas = requestedMaxPriorityFeePerGas !== void 0 && requestedMaxPriorityFeePerGas > priorityGasPrice ? requestedMaxPriorityFeePerGas : priorityGasPrice;
|
|
543
673
|
if (maxPriorityFeePerGas > maxFeePerGas) throw new TempoTransactionValidationError({ reason: "maxPriorityFeePerGas must not exceed maxFeePerGas" });
|
|
544
674
|
const serializedTransaction = serializeTempoTransactionForWaas({
|
|
675
|
+
awaitingFeePayer: transaction.awaitingFeePayer,
|
|
545
676
|
calls,
|
|
546
677
|
chainId: chain.id,
|
|
547
678
|
feeToken: transaction.feeToken,
|
|
@@ -567,6 +698,11 @@ const createViemWalletClientForWaasTempo = async ({ waasProvider, walletAccount,
|
|
|
567
698
|
transport,
|
|
568
699
|
...viemWalletClientConfig
|
|
569
700
|
});
|
|
701
|
+
const { sendTransaction } = walletClient;
|
|
702
|
+
return Object.assign(walletClient, { sendTransaction: (async (transaction) => {
|
|
703
|
+
assertTransactionCanBeBroadcast(transaction);
|
|
704
|
+
return await sendTransaction(transaction);
|
|
705
|
+
}) });
|
|
570
706
|
};
|
|
571
707
|
|
|
572
708
|
//#endregion
|
|
@@ -755,4 +891,5 @@ exports.TempoTransactionValidationError = TempoTransactionValidationError;
|
|
|
755
891
|
exports.TempoTypedDataNotSupportedError = TempoTypedDataNotSupportedError;
|
|
756
892
|
exports.addWaasTempoExtension = addWaasTempoExtension;
|
|
757
893
|
exports.sendTempoTransaction = sendTempoTransaction;
|
|
894
|
+
exports.signTempoTransaction = signTempoTransaction;
|
|
758
895
|
//# sourceMappingURL=waas.cjs.map
|