@aztec/entrypoints 0.80.0 → 0.82.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/dest/account_entrypoint.d.ts +3 -3
- package/dest/account_entrypoint.d.ts.map +1 -1
- package/dest/account_entrypoint.js +25 -11
- package/dest/dapp_entrypoint.d.ts +3 -3
- package/dest/dapp_entrypoint.d.ts.map +1 -1
- package/dest/dapp_entrypoint.js +25 -20
- package/dest/default_entrypoint.d.ts +13 -0
- package/dest/default_entrypoint.d.ts.map +1 -0
- package/dest/default_entrypoint.js +35 -0
- package/dest/encoding.d.ts +111 -0
- package/dest/encoding.d.ts.map +1 -0
- package/dest/encoding.js +135 -0
- package/dest/index.d.ts +3 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -0
- package/dest/interfaces.d.ts +83 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +2 -0
- package/dest/payload.d.ts +32 -0
- package/dest/payload.d.ts.map +1 -0
- package/dest/payload.js +27 -0
- package/package.json +10 -6
- package/src/account_entrypoint.ts +34 -15
- package/src/dapp_entrypoint.ts +35 -17
- package/src/default_entrypoint.ts +48 -0
- package/src/encoding.ts +225 -0
- package/src/index.ts +3 -0
- package/src/interfaces.ts +93 -0
- package/src/payload.ts +35 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
-
import { type EntrypointInterface, type ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
|
|
3
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
2
|
import { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { AuthWitnessProvider, EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
|
|
4
|
+
import { ExecutionPayload } from './payload.js';
|
|
5
5
|
/**
|
|
6
6
|
* Implementation for an entrypoint interface that follows the default entrypoint signature
|
|
7
7
|
* for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
@@ -12,7 +12,7 @@ export declare class DefaultAccountEntrypoint implements EntrypointInterface {
|
|
|
12
12
|
private chainId;
|
|
13
13
|
private version;
|
|
14
14
|
constructor(address: AztecAddress, auth: AuthWitnessProvider, chainId?: number, version?: number);
|
|
15
|
-
createTxExecutionRequest(exec:
|
|
15
|
+
createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
|
|
16
16
|
private getEntrypointAbi;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=account_entrypoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_entrypoint.d.ts","sourceRoot":"","sources":["../src/account_entrypoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account_entrypoint.d.ts","sourceRoot":"","sources":["../src/account_entrypoint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,mBAAmB;IAEhE,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;gBAHP,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,mBAAmB,EACzB,OAAO,GAAE,MAAyB,EAClC,OAAO,GAAE,MAAwB;IAGrC,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;IA8C9B,OAAO,CAAC,gBAAgB;CAqGzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EntrypointPayload, computeCombinedPayloadHash } from '@aztec/aztec.js/entrypoint';
|
|
2
1
|
import { FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
|
|
3
2
|
import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
4
3
|
import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
|
|
4
|
+
import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encoding.js';
|
|
5
5
|
/**
|
|
6
6
|
* Implementation for an entrypoint interface that follows the default entrypoint signature
|
|
7
7
|
* for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
@@ -16,29 +16,43 @@ import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
|
|
|
16
16
|
this.chainId = chainId;
|
|
17
17
|
this.version = version;
|
|
18
18
|
}
|
|
19
|
-
async createTxExecutionRequest(exec) {
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
async createTxExecutionRequest(exec, fee, options) {
|
|
20
|
+
// Initial request with calls, authWitnesses and capsules
|
|
21
|
+
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
22
|
+
// Global tx options
|
|
23
|
+
const { cancellable, nonce } = options;
|
|
24
|
+
// Encode the calls for the app
|
|
25
|
+
const appEncodedCalls = await EncodedCallsForEntrypoint.fromAppExecution(calls, nonce);
|
|
26
|
+
// Get the execution payload for the fee, it includes the calls and potentially authWitnesses
|
|
27
|
+
const { calls: feeCalls, authWitnesses: feeAuthwitnesses } = await fee.paymentMethod.getExecutionPayload(fee.gasSettings);
|
|
28
|
+
// Encode the calls for the fee
|
|
29
|
+
const feePayer = await fee.paymentMethod.getFeePayer(fee.gasSettings);
|
|
30
|
+
const isFeePayer = feePayer.equals(this.address);
|
|
31
|
+
const feeEncodedCalls = await EncodedCallsForEntrypoint.fromFeeCalls(feeCalls, isFeePayer);
|
|
32
|
+
// Obtain the entrypoint hashed args, built from the app and fee encoded calls
|
|
23
33
|
const abi = this.getEntrypointAbi();
|
|
24
34
|
const entrypointHashedArgs = await HashedValues.fromValues(encodeArguments(abi, [
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
appEncodedCalls,
|
|
36
|
+
feeEncodedCalls,
|
|
27
37
|
!!cancellable
|
|
28
38
|
]));
|
|
29
|
-
|
|
39
|
+
// Generate the combined payload auth witness, by signing the hash of the combined payload
|
|
40
|
+
const combinedPayloadAuthWitness = await this.auth.createAuthWit(await computeCombinedPayloadHash(appEncodedCalls, feeEncodedCalls));
|
|
41
|
+
// Assemble the tx request
|
|
30
42
|
const txRequest = TxExecutionRequest.from({
|
|
31
43
|
firstCallArgsHash: entrypointHashedArgs.hash,
|
|
32
44
|
origin: this.address,
|
|
33
45
|
functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
|
|
34
46
|
txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
|
|
35
47
|
argsOfCalls: [
|
|
36
|
-
...
|
|
37
|
-
...
|
|
38
|
-
entrypointHashedArgs
|
|
48
|
+
...appEncodedCalls.hashedArguments,
|
|
49
|
+
...feeEncodedCalls.hashedArguments,
|
|
50
|
+
entrypointHashedArgs,
|
|
51
|
+
...extraHashedArgs
|
|
39
52
|
],
|
|
40
53
|
authWitnesses: [
|
|
41
54
|
...authWitnesses,
|
|
55
|
+
...feeAuthwitnesses,
|
|
42
56
|
combinedPayloadAuthWitness
|
|
43
57
|
],
|
|
44
58
|
capsules
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
-
import { type EntrypointInterface, type ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
|
|
3
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
2
|
import { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { AuthWitnessProvider, EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
|
|
4
|
+
import { ExecutionPayload } from './payload.js';
|
|
5
5
|
/**
|
|
6
6
|
* Implementation for an entrypoint interface that follows the default entrypoint signature
|
|
7
7
|
* for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
@@ -13,7 +13,7 @@ export declare class DefaultDappEntrypoint implements EntrypointInterface {
|
|
|
13
13
|
private chainId;
|
|
14
14
|
private version;
|
|
15
15
|
constructor(userAddress: AztecAddress, userAuthWitnessProvider: AuthWitnessProvider, dappEntrypointAddress: AztecAddress, chainId?: number, version?: number);
|
|
16
|
-
createTxExecutionRequest(exec:
|
|
16
|
+
createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
|
|
17
17
|
private getEntrypointAbi;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=dapp_entrypoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dapp_entrypoint.d.ts","sourceRoot":"","sources":["../src/dapp_entrypoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dapp_entrypoint.d.ts","sourceRoot":"","sources":["../src/dapp_entrypoint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,mBAAmB;IAE7D,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,uBAAuB;IAC/B,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;gBAJP,WAAW,EAAE,YAAY,EACzB,uBAAuB,EAAE,mBAAmB,EAC5C,qBAAqB,EAAE,YAAY,EACnC,OAAO,GAAE,MAAyB,EAClC,OAAO,GAAE,MAAwB;IAGrC,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;IAiD9B,OAAO,CAAC,gBAAgB;CAiEzB"}
|
package/dest/dapp_entrypoint.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Fr
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { FunctionSelector, FunctionType, encodeArguments } from '@aztec/stdlib/abi';
|
|
3
|
+
import { computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
|
|
4
4
|
import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
5
5
|
import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
|
|
6
|
+
import { EncodedCallsForEntrypoint } from './encoding.js';
|
|
6
7
|
/**
|
|
7
8
|
* Implementation for an entrypoint interface that follows the default entrypoint signature
|
|
8
9
|
* for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
@@ -19,17 +20,25 @@ import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
|
|
|
19
20
|
this.chainId = chainId;
|
|
20
21
|
this.version = version;
|
|
21
22
|
}
|
|
22
|
-
async createTxExecutionRequest(exec) {
|
|
23
|
-
|
|
23
|
+
async createTxExecutionRequest(exec, fee, options) {
|
|
24
|
+
if (options.nonce || options.cancellable !== undefined) {
|
|
25
|
+
throw new Error('TxExecutionOptions are not supported in DappEntrypoint');
|
|
26
|
+
}
|
|
27
|
+
// Initial request with calls, authWitnesses and capsules
|
|
28
|
+
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
24
29
|
if (calls.length !== 1) {
|
|
25
30
|
throw new Error(`Expected exactly 1 function call, got ${calls.length}`);
|
|
26
31
|
}
|
|
27
|
-
|
|
32
|
+
// Encode the function call the dapp is ultimately going to invoke
|
|
33
|
+
const encodedCalls = await EncodedCallsForEntrypoint.fromFunctionCalls(calls);
|
|
34
|
+
// Obtain the entrypoint hashed args, built from the function call and the user's address
|
|
28
35
|
const abi = this.getEntrypointAbi();
|
|
29
36
|
const entrypointHashedArgs = await HashedValues.fromValues(encodeArguments(abi, [
|
|
30
|
-
|
|
37
|
+
encodedCalls,
|
|
31
38
|
this.userAddress
|
|
32
39
|
]));
|
|
40
|
+
// Construct an auth witness for the entrypoint, by signing the hash of the action to perform
|
|
41
|
+
// (the dapp calls a function on the user's behalf)
|
|
33
42
|
const functionSelector = await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters);
|
|
34
43
|
// Default msg_sender for entrypoints is now Fr.max_value rather than 0 addr (see #7190 & #7404)
|
|
35
44
|
const innerHash = await computeInnerAuthWitHash([
|
|
@@ -37,26 +46,22 @@ import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
|
|
|
37
46
|
functionSelector.toField(),
|
|
38
47
|
entrypointHashedArgs.hash
|
|
39
48
|
]);
|
|
40
|
-
const outerHash = await
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, {
|
|
44
|
-
chainId: new Fr(this.chainId),
|
|
45
|
-
version: new Fr(this.version)
|
|
46
|
-
});
|
|
47
|
-
const authWitness = await this.userAuthWitnessProvider.createAuthWit(outerHash);
|
|
49
|
+
const outerHash = await computeOuterAuthWitHash(this.dappEntrypointAddress, new Fr(this.chainId), new Fr(this.version), innerHash);
|
|
50
|
+
const entypointAuthwitness = await this.userAuthWitnessProvider.createAuthWit(outerHash);
|
|
51
|
+
// Assemble the tx request
|
|
48
52
|
const txRequest = TxExecutionRequest.from({
|
|
49
53
|
firstCallArgsHash: entrypointHashedArgs.hash,
|
|
50
54
|
origin: this.dappEntrypointAddress,
|
|
51
55
|
functionSelector,
|
|
52
56
|
txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
|
|
53
57
|
argsOfCalls: [
|
|
54
|
-
...
|
|
55
|
-
entrypointHashedArgs
|
|
58
|
+
...encodedCalls.hashedArguments,
|
|
59
|
+
entrypointHashedArgs,
|
|
60
|
+
...extraHashedArgs
|
|
56
61
|
],
|
|
57
62
|
authWitnesses: [
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
entypointAuthwitness,
|
|
64
|
+
...authWitnesses
|
|
60
65
|
],
|
|
61
66
|
capsules
|
|
62
67
|
});
|
|
@@ -66,7 +71,7 @@ import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
|
|
|
66
71
|
return {
|
|
67
72
|
name: 'entrypoint',
|
|
68
73
|
isInitializer: false,
|
|
69
|
-
functionType:
|
|
74
|
+
functionType: FunctionType.PRIVATE,
|
|
70
75
|
isInternal: false,
|
|
71
76
|
isStatic: false,
|
|
72
77
|
parameters: [
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
2
|
+
import type { EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
|
|
3
|
+
import type { ExecutionPayload } from './payload.js';
|
|
4
|
+
/**
|
|
5
|
+
* Default implementation of the entrypoint interface. It calls a function on a contract directly
|
|
6
|
+
*/
|
|
7
|
+
export declare class DefaultEntrypoint implements EntrypointInterface {
|
|
8
|
+
private chainId;
|
|
9
|
+
private protocolVersion;
|
|
10
|
+
constructor(chainId: number, protocolVersion: number);
|
|
11
|
+
createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=default_entrypoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default_entrypoint.d.ts","sourceRoot":"","sources":["../src/default_entrypoint.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,mBAAmB;IAC/C,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,eAAe;gBAAxC,OAAO,EAAE,MAAM,EAAU,eAAe,EAAE,MAAM;IAE9D,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;CA+B/B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FunctionType } from '@aztec/stdlib/abi';
|
|
2
|
+
import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
3
|
+
/**
|
|
4
|
+
* Default implementation of the entrypoint interface. It calls a function on a contract directly
|
|
5
|
+
*/ export class DefaultEntrypoint {
|
|
6
|
+
chainId;
|
|
7
|
+
protocolVersion;
|
|
8
|
+
constructor(chainId, protocolVersion){
|
|
9
|
+
this.chainId = chainId;
|
|
10
|
+
this.protocolVersion = protocolVersion;
|
|
11
|
+
}
|
|
12
|
+
async createTxExecutionRequest(exec, fee, options) {
|
|
13
|
+
if (options.nonce || options.cancellable !== undefined) {
|
|
14
|
+
throw new Error('TxExecutionOptions are not supported in DefaultEntrypoint');
|
|
15
|
+
}
|
|
16
|
+
// Initial request with calls, authWitnesses and capsules
|
|
17
|
+
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
18
|
+
if (calls.length > 1) {
|
|
19
|
+
throw new Error(`Expected a single call, got ${calls.length}`);
|
|
20
|
+
}
|
|
21
|
+
const call = calls[0];
|
|
22
|
+
// Hash the arguments for the function call
|
|
23
|
+
const hashedArguments = [
|
|
24
|
+
await HashedValues.fromValues(call.args)
|
|
25
|
+
];
|
|
26
|
+
if (call.type !== FunctionType.PRIVATE) {
|
|
27
|
+
throw new Error('Public entrypoints are not allowed');
|
|
28
|
+
}
|
|
29
|
+
// Assemble the tx request
|
|
30
|
+
return new TxExecutionRequest(call.to, call.selector, hashedArguments[0].hash, new TxContext(this.chainId, this.protocolVersion, fee.gasSettings), [
|
|
31
|
+
...hashedArguments,
|
|
32
|
+
...extraHashedArgs
|
|
33
|
+
], authWitnesses, capsules);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
3
|
+
import { FunctionCall } from '@aztec/stdlib/abi';
|
|
4
|
+
import { HashedValues } from '@aztec/stdlib/tx';
|
|
5
|
+
declare const APP_MAX_CALLS = 4;
|
|
6
|
+
declare const FEE_MAX_CALLS = 2;
|
|
7
|
+
/** Encoded function call for an Aztec entrypoint */
|
|
8
|
+
export type EncodedFunctionCall = {
|
|
9
|
+
/** Arguments hash for the call */
|
|
10
|
+
args_hash: Fr;
|
|
11
|
+
/** Selector of the function to call */
|
|
12
|
+
function_selector: Fr;
|
|
13
|
+
/** Address of the contract to call */
|
|
14
|
+
target_address: Fr;
|
|
15
|
+
/** Whether the function is public or private */
|
|
16
|
+
is_public: boolean;
|
|
17
|
+
/** Whether the function can alter state */
|
|
18
|
+
is_static: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Type that represents function calls ready to be sent to a circuit for execution */
|
|
21
|
+
export type EncodedCalls = {
|
|
22
|
+
/** Function calls in the expected format (Noir's convention) */
|
|
23
|
+
encodedFunctionCalls: EncodedFunctionCall[];
|
|
24
|
+
/** The hashed args for the call, ready to be injected in the execution cache */
|
|
25
|
+
hashedArguments: HashedValues[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Entrypoints derive their arguments from the calls that they'll ultimate make.
|
|
29
|
+
* This utility class helps in creating the payload for the entrypoint by taking into
|
|
30
|
+
* account how the calls are encoded and hashed.
|
|
31
|
+
* */
|
|
32
|
+
export declare abstract class EncodedCallsForEntrypoint implements EncodedCalls {
|
|
33
|
+
/** Function calls in the expected format (Noir's convention) */
|
|
34
|
+
encodedFunctionCalls: EncodedFunctionCall[];
|
|
35
|
+
/** The hashed args for the call, ready to be injected in the execution cache */
|
|
36
|
+
hashedArguments: HashedValues[];
|
|
37
|
+
/** The index of the generator to use for hashing */
|
|
38
|
+
generatorIndex: number;
|
|
39
|
+
/** The nonce for the payload, used to emit a nullifier identifying the call */
|
|
40
|
+
nonce: Fr;
|
|
41
|
+
constructor(
|
|
42
|
+
/** Function calls in the expected format (Noir's convention) */
|
|
43
|
+
encodedFunctionCalls: EncodedFunctionCall[],
|
|
44
|
+
/** The hashed args for the call, ready to be injected in the execution cache */
|
|
45
|
+
hashedArguments: HashedValues[],
|
|
46
|
+
/** The index of the generator to use for hashing */
|
|
47
|
+
generatorIndex: number,
|
|
48
|
+
/** The nonce for the payload, used to emit a nullifier identifying the call */
|
|
49
|
+
nonce: Fr);
|
|
50
|
+
/**
|
|
51
|
+
* The function calls to execute. This uses snake_case naming so that it is compatible with Noir encoding
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
get function_calls(): EncodedFunctionCall[];
|
|
55
|
+
/**
|
|
56
|
+
* Serializes the payload to an array of fields
|
|
57
|
+
* @returns The fields of the payload
|
|
58
|
+
*/
|
|
59
|
+
abstract toFields(): Fr[];
|
|
60
|
+
/**
|
|
61
|
+
* Hashes the payload
|
|
62
|
+
* @returns The hash of the payload
|
|
63
|
+
*/
|
|
64
|
+
hash(): Promise<Fr>;
|
|
65
|
+
/** Serializes the function calls to an array of fields. */
|
|
66
|
+
protected functionCallsToFields(): Fr[];
|
|
67
|
+
/**
|
|
68
|
+
* Encodes a set of function calls for a dapp entrypoint
|
|
69
|
+
* @param functionCalls - The function calls to execute
|
|
70
|
+
* @returns The encoded calls
|
|
71
|
+
*/
|
|
72
|
+
static fromFunctionCalls(functionCalls: FunctionCall[]): Promise<EncodedAppEntrypointCalls>;
|
|
73
|
+
/**
|
|
74
|
+
* Encodes the functions for the app-portion of a transaction from a set of function calls and a nonce
|
|
75
|
+
* @param functionCalls - The function calls to execute
|
|
76
|
+
* @param nonce - The nonce for the payload, used to emit a nullifier identifying the call
|
|
77
|
+
* @returns The encoded calls
|
|
78
|
+
*/
|
|
79
|
+
static fromAppExecution(functionCalls: FunctionCall[] | Tuple<FunctionCall, typeof APP_MAX_CALLS>, nonce?: Fr): Promise<EncodedAppEntrypointCalls>;
|
|
80
|
+
/**
|
|
81
|
+
* Creates an encoded set of functions to pay the fee for a transaction
|
|
82
|
+
* @param functionCalls - The calls generated by the payment method
|
|
83
|
+
* @param isFeePayer - Whether the sender should be appointed as fee payer
|
|
84
|
+
* @returns The encoded calls
|
|
85
|
+
*/
|
|
86
|
+
static fromFeeCalls(functionCalls: FunctionCall[] | Tuple<FunctionCall, typeof FEE_MAX_CALLS>, isFeePayer: boolean): Promise<EncodedFeeEntrypointCalls>;
|
|
87
|
+
}
|
|
88
|
+
/** Encoded calls for app phase execution. */
|
|
89
|
+
export declare class EncodedAppEntrypointCalls extends EncodedCallsForEntrypoint {
|
|
90
|
+
constructor(encodedFunctionCalls: EncodedFunctionCall[], hashedArguments: HashedValues[], generatorIndex: number, nonce: Fr);
|
|
91
|
+
toFields(): Fr[];
|
|
92
|
+
}
|
|
93
|
+
/** Encoded calls for fee payment */
|
|
94
|
+
export declare class EncodedFeeEntrypointCalls extends EncodedCallsForEntrypoint {
|
|
95
|
+
#private;
|
|
96
|
+
constructor(encodedFunctionCalls: EncodedFunctionCall[], hashedArguments: HashedValues[], generatorIndex: number, nonce: Fr, isFeePayer: boolean);
|
|
97
|
+
toFields(): Fr[];
|
|
98
|
+
/** Whether the sender should be appointed as fee payer. */
|
|
99
|
+
get is_fee_payer(): boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Computes a hash of a combined set of app and fee calls.
|
|
103
|
+
* @param appCalls - A set of app calls.
|
|
104
|
+
* @param feeCalls - A set of calls used to pay fees.
|
|
105
|
+
* @returns A hash of a combined call set.
|
|
106
|
+
*/
|
|
107
|
+
export declare function computeCombinedPayloadHash(appPayload: EncodedAppEntrypointCalls, feePayload: EncodedFeeEntrypointCalls): Promise<Fr>;
|
|
108
|
+
/** Encodes FunctionCalls for execution, following Noir's convention */
|
|
109
|
+
export declare function encode(calls: FunctionCall[]): Promise<EncodedCalls>;
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,QAAA,MAAM,aAAa,IAAI,CAAC;AAExB,QAAA,MAAM,aAAa,IAAI,CAAC;AAGxB,oDAAoD;AACpD,MAAM,MAAM,mBAAmB,GAAG;IAChC,kCAAkC;IAClC,SAAS,EAAE,EAAE,CAAC;IACd,uCAAuC;IACvC,iBAAiB,EAAE,EAAE,CAAC;IACtB,sCAAsC;IACtC,cAAc,EAAE,EAAE,CAAC;IACnB,gDAAgD;IAChD,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAGF,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG;IACzB,gEAAgE;IAChE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IAC5C,gFAAgF;IAChF,eAAe,EAAE,YAAY,EAAE,CAAC;CACjC,CAAC;AAEF;;;;KAIK;AACL,8BAAsB,yBAA0B,YAAW,YAAY;IAEnE,gEAAgE;IACzD,oBAAoB,EAAE,mBAAmB,EAAE;IAClD,gFAAgF;IACzE,eAAe,EAAE,YAAY,EAAE;IACtC,oDAAoD;IAC7C,cAAc,EAAE,MAAM;IAC7B,+EAA+E;IACxE,KAAK,EAAE,EAAE;;IAPhB,gEAAgE;IACzD,oBAAoB,EAAE,mBAAmB,EAAE;IAClD,gFAAgF;IACzE,eAAe,EAAE,YAAY,EAAE;IACtC,oDAAoD;IAC7C,cAAc,EAAE,MAAM;IAC7B,+EAA+E;IACxE,KAAK,EAAE,EAAE;IAIlB;;;OAGG;IACH,IAAI,cAAc,0BAEjB;IAGD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE;IAEzB;;;OAGG;IACH,IAAI;IAIJ,2DAA2D;IAC3D,SAAS,CAAC,qBAAqB;IAU/B;;;;OAIG;WACU,iBAAiB,CAAC,aAAa,EAAE,YAAY,EAAE;IAK5D;;;;;OAKG;WACU,gBAAgB,CAC3B,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,EAAE,OAAO,aAAa,CAAC,EACzE,KAAK,KAAc;IAerB;;;;;OAKG;WACU,YAAY,CACvB,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,EAAE,OAAO,aAAa,CAAC,EACzE,UAAU,EAAE,OAAO;CAYtB;AAED,6CAA6C;AAC7C,qBAAa,yBAA0B,SAAQ,yBAAyB;gBAEpE,oBAAoB,EAAE,mBAAmB,EAAE,EAC3C,eAAe,EAAE,YAAY,EAAE,EAC/B,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,EAAE;IAKF,QAAQ,IAAI,EAAE,EAAE;CAG1B;AAED,oCAAoC;AACpC,qBAAa,yBAA0B,SAAQ,yBAAyB;;gBAIpE,oBAAoB,EAAE,mBAAmB,EAAE,EAC3C,eAAe,EAAE,YAAY,EAAE,EAC/B,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,EAAE,EACT,UAAU,EAAE,OAAO;IAMZ,QAAQ,IAAI,EAAE,EAAE;IAKzB,2DAA2D;IAC3D,IAAI,YAAY,YAEf;CAEF;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,yBAAyB,EACrC,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,EAAE,CAAC,CAKb;AAED,uEAAuE;AACvE,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAmBzE"}
|
package/dest/encoding.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { GeneratorIndex } from '@aztec/constants';
|
|
2
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
4
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
+
import { FunctionCall, FunctionType } from '@aztec/stdlib/abi';
|
|
6
|
+
import { HashedValues } from '@aztec/stdlib/tx';
|
|
7
|
+
// These must match the values defined in:
|
|
8
|
+
// - noir-projects/aztec-nr/aztec/src/entrypoint/app.nr
|
|
9
|
+
const APP_MAX_CALLS = 4;
|
|
10
|
+
// - and noir-projects/aztec-nr/aztec/src/entrypoint/fee.nr
|
|
11
|
+
const FEE_MAX_CALLS = 2;
|
|
12
|
+
/**
|
|
13
|
+
* Entrypoints derive their arguments from the calls that they'll ultimate make.
|
|
14
|
+
* This utility class helps in creating the payload for the entrypoint by taking into
|
|
15
|
+
* account how the calls are encoded and hashed.
|
|
16
|
+
* */ export class EncodedCallsForEntrypoint {
|
|
17
|
+
encodedFunctionCalls;
|
|
18
|
+
hashedArguments;
|
|
19
|
+
generatorIndex;
|
|
20
|
+
nonce;
|
|
21
|
+
constructor(/** Function calls in the expected format (Noir's convention) */ encodedFunctionCalls, /** The hashed args for the call, ready to be injected in the execution cache */ hashedArguments, /** The index of the generator to use for hashing */ generatorIndex, /** The nonce for the payload, used to emit a nullifier identifying the call */ nonce){
|
|
22
|
+
this.encodedFunctionCalls = encodedFunctionCalls;
|
|
23
|
+
this.hashedArguments = hashedArguments;
|
|
24
|
+
this.generatorIndex = generatorIndex;
|
|
25
|
+
this.nonce = nonce;
|
|
26
|
+
}
|
|
27
|
+
/* eslint-disable camelcase */ /**
|
|
28
|
+
* The function calls to execute. This uses snake_case naming so that it is compatible with Noir encoding
|
|
29
|
+
* @internal
|
|
30
|
+
*/ get function_calls() {
|
|
31
|
+
return this.encodedFunctionCalls;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Hashes the payload
|
|
35
|
+
* @returns The hash of the payload
|
|
36
|
+
*/ hash() {
|
|
37
|
+
return poseidon2HashWithSeparator(this.toFields(), this.generatorIndex);
|
|
38
|
+
}
|
|
39
|
+
/** Serializes the function calls to an array of fields. */ functionCallsToFields() {
|
|
40
|
+
return this.encodedFunctionCalls.flatMap((call)=>[
|
|
41
|
+
call.args_hash,
|
|
42
|
+
call.function_selector,
|
|
43
|
+
call.target_address,
|
|
44
|
+
new Fr(call.is_public),
|
|
45
|
+
new Fr(call.is_static)
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Encodes a set of function calls for a dapp entrypoint
|
|
50
|
+
* @param functionCalls - The function calls to execute
|
|
51
|
+
* @returns The encoded calls
|
|
52
|
+
*/ static async fromFunctionCalls(functionCalls) {
|
|
53
|
+
const encoded = await encode(functionCalls);
|
|
54
|
+
return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, 0, Fr.random());
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Encodes the functions for the app-portion of a transaction from a set of function calls and a nonce
|
|
58
|
+
* @param functionCalls - The function calls to execute
|
|
59
|
+
* @param nonce - The nonce for the payload, used to emit a nullifier identifying the call
|
|
60
|
+
* @returns The encoded calls
|
|
61
|
+
*/ static async fromAppExecution(functionCalls, nonce = Fr.random()) {
|
|
62
|
+
if (functionCalls.length > APP_MAX_CALLS) {
|
|
63
|
+
throw new Error(`Expected at most ${APP_MAX_CALLS} function calls, got ${functionCalls.length}`);
|
|
64
|
+
}
|
|
65
|
+
const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), APP_MAX_CALLS);
|
|
66
|
+
const encoded = await encode(paddedCalls);
|
|
67
|
+
return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, GeneratorIndex.SIGNATURE_PAYLOAD, nonce);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates an encoded set of functions to pay the fee for a transaction
|
|
71
|
+
* @param functionCalls - The calls generated by the payment method
|
|
72
|
+
* @param isFeePayer - Whether the sender should be appointed as fee payer
|
|
73
|
+
* @returns The encoded calls
|
|
74
|
+
*/ static async fromFeeCalls(functionCalls, isFeePayer) {
|
|
75
|
+
const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), FEE_MAX_CALLS);
|
|
76
|
+
const encoded = await encode(paddedCalls);
|
|
77
|
+
return new EncodedFeeEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, GeneratorIndex.FEE_PAYLOAD, Fr.random(), isFeePayer);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Encoded calls for app phase execution. */ export class EncodedAppEntrypointCalls extends EncodedCallsForEntrypoint {
|
|
81
|
+
constructor(encodedFunctionCalls, hashedArguments, generatorIndex, nonce){
|
|
82
|
+
super(encodedFunctionCalls, hashedArguments, generatorIndex, nonce);
|
|
83
|
+
}
|
|
84
|
+
toFields() {
|
|
85
|
+
return [
|
|
86
|
+
...this.functionCallsToFields(),
|
|
87
|
+
this.nonce
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Encoded calls for fee payment */ export class EncodedFeeEntrypointCalls extends EncodedCallsForEntrypoint {
|
|
92
|
+
#isFeePayer;
|
|
93
|
+
constructor(encodedFunctionCalls, hashedArguments, generatorIndex, nonce, isFeePayer){
|
|
94
|
+
super(encodedFunctionCalls, hashedArguments, generatorIndex, nonce);
|
|
95
|
+
this.#isFeePayer = isFeePayer;
|
|
96
|
+
}
|
|
97
|
+
toFields() {
|
|
98
|
+
return [
|
|
99
|
+
...this.functionCallsToFields(),
|
|
100
|
+
this.nonce,
|
|
101
|
+
new Fr(this.#isFeePayer)
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
/* eslint-disable camelcase */ /** Whether the sender should be appointed as fee payer. */ get is_fee_payer() {
|
|
105
|
+
return this.#isFeePayer;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Computes a hash of a combined set of app and fee calls.
|
|
110
|
+
* @param appCalls - A set of app calls.
|
|
111
|
+
* @param feeCalls - A set of calls used to pay fees.
|
|
112
|
+
* @returns A hash of a combined call set.
|
|
113
|
+
*/ export async function computeCombinedPayloadHash(appPayload, feePayload) {
|
|
114
|
+
return poseidon2HashWithSeparator([
|
|
115
|
+
await appPayload.hash(),
|
|
116
|
+
await feePayload.hash()
|
|
117
|
+
], GeneratorIndex.COMBINED_PAYLOAD);
|
|
118
|
+
}
|
|
119
|
+
/** Encodes FunctionCalls for execution, following Noir's convention */ export async function encode(calls) {
|
|
120
|
+
const hashedArguments = [];
|
|
121
|
+
for (const call of calls){
|
|
122
|
+
hashedArguments.push(await HashedValues.fromValues(call.args));
|
|
123
|
+
}
|
|
124
|
+
/* eslint-disable camelcase */ const encodedFunctionCalls = calls.map((call, index)=>({
|
|
125
|
+
args_hash: hashedArguments[index].hash,
|
|
126
|
+
function_selector: call.selector.toField(),
|
|
127
|
+
target_address: call.to.toField(),
|
|
128
|
+
is_public: call.type == FunctionType.PUBLIC,
|
|
129
|
+
is_static: call.isStatic
|
|
130
|
+
}));
|
|
131
|
+
return {
|
|
132
|
+
encodedFunctionCalls,
|
|
133
|
+
hashedArguments
|
|
134
|
+
};
|
|
135
|
+
}
|
package/dest/index.d.ts
CHANGED
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC"}
|
package/dest/index.js
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
8
|
+
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
9
|
+
import type { ExecutionPayload } from './payload.js';
|
|
10
|
+
/**
|
|
11
|
+
* General options for the tx execution.
|
|
12
|
+
*/
|
|
13
|
+
export type TxExecutionOptions = {
|
|
14
|
+
/** Whether the transaction can be cancelled. */
|
|
15
|
+
cancellable?: boolean;
|
|
16
|
+
/** The nonce to use for the transaction. */
|
|
17
|
+
nonce?: Fr;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Creates transaction execution requests out of a set of function calls, a fee payment method and
|
|
21
|
+
* general options for the transaction
|
|
22
|
+
*/
|
|
23
|
+
export interface EntrypointInterface {
|
|
24
|
+
/**
|
|
25
|
+
* Generates an execution request out of set of function calls.
|
|
26
|
+
* @param exec - The execution intents to be run.
|
|
27
|
+
* @param fee - The fee options for the transaction.
|
|
28
|
+
* @param options - Nonce and whether the transaction is cancellable.
|
|
29
|
+
* @returns The authenticated transaction execution request.
|
|
30
|
+
*/
|
|
31
|
+
createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
|
|
32
|
+
}
|
|
33
|
+
/** Creates authorization witnesses. */
|
|
34
|
+
export interface AuthWitnessProvider {
|
|
35
|
+
/**
|
|
36
|
+
* Computes an authentication witness from either a message hash
|
|
37
|
+
* @param messageHash - The message hash to approve
|
|
38
|
+
* @returns The authentication witness
|
|
39
|
+
*/
|
|
40
|
+
createAuthWit(messageHash: Fr | Buffer): Promise<AuthWitness>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
44
|
+
*/
|
|
45
|
+
export interface FeePaymentMethod {
|
|
46
|
+
/** The asset used to pay the fee. */
|
|
47
|
+
getAsset(): Promise<AztecAddress>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the data to be added to the final execution request
|
|
50
|
+
* to pay the fee in the given asset
|
|
51
|
+
* @param gasSettings - The gas limits and max fees.
|
|
52
|
+
* @returns The function calls to pay the fee.
|
|
53
|
+
*/
|
|
54
|
+
getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload>;
|
|
55
|
+
/**
|
|
56
|
+
* The expected fee payer for this tx.
|
|
57
|
+
* @param gasSettings - The gas limits and max fees.
|
|
58
|
+
*/
|
|
59
|
+
getFeePayer(gasSettings: GasSettings): Promise<AztecAddress>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fee payment options for a transaction.
|
|
63
|
+
*/
|
|
64
|
+
export type FeeOptions = {
|
|
65
|
+
/** The fee payment method to use */
|
|
66
|
+
paymentMethod: FeePaymentMethod;
|
|
67
|
+
/** The gas settings */
|
|
68
|
+
gasSettings: GasSettings;
|
|
69
|
+
};
|
|
70
|
+
/** Fee options as set by a user. */
|
|
71
|
+
export type UserFeeOptions = {
|
|
72
|
+
/** The fee payment method to use */
|
|
73
|
+
paymentMethod?: FeePaymentMethod;
|
|
74
|
+
/** The gas settings */
|
|
75
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
76
|
+
/** Percentage to pad the base fee by, if empty, defaults to 0.5 */
|
|
77
|
+
baseFeePadding?: number;
|
|
78
|
+
/** Whether to run an initial simulation of the tx with high gas limit to figure out actual gas settings. */
|
|
79
|
+
estimateGas?: boolean;
|
|
80
|
+
/** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
|
|
81
|
+
estimatedGasPadding?: number;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,EAAE,CAAC;CACZ,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,wBAAwB,CACtB,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChC;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAClC;;;;;OAKG;IACH,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACzE;;;OAGG;IACH,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9D;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,oCAAoC;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,uBAAuB;IACvB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAGF,oCAAoC;AACpC,MAAM,MAAM,cAAc,GAAG;IAC3B,oCAAoC;IACpC,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,uBAAuB;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4GAA4G;IAC5G,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qHAAqH;IACrH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC"}
|