@wonderland/aztec-fee-payment 0.0.0 → 4.1.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -2
- package/README.md +127 -2
- package/dist/src/artifacts/BridgedFPC.d.ts +67 -0
- package/dist/src/artifacts/BridgedFPC.d.ts.map +1 -0
- package/dist/src/artifacts/BridgedFPC.js +62 -0
- package/dist/src/artifacts/Counter.d.ts +63 -0
- package/dist/src/artifacts/Counter.d.ts.map +1 -0
- package/dist/src/artifacts/Counter.js +62 -0
- package/dist/src/ts/artifactRegistry.d.ts +46 -0
- package/dist/src/ts/artifactRegistry.d.ts.map +1 -0
- package/dist/src/ts/artifactRegistry.js +128 -0
- package/dist/src/ts/fee-payment-methods/bridged.d.ts +34 -0
- package/dist/src/ts/fee-payment-methods/bridged.d.ts.map +1 -0
- package/dist/src/ts/fee-payment-methods/bridged.js +69 -0
- package/dist/src/ts/fee-payment-methods/index.d.ts +3 -0
- package/dist/src/ts/fee-payment-methods/index.d.ts.map +1 -0
- package/dist/src/ts/fee-payment-methods/index.js +3 -0
- package/dist/src/ts/fee-payment-methods/shared.d.ts +34 -0
- package/dist/src/ts/fee-payment-methods/shared.d.ts.map +1 -0
- package/dist/src/ts/fee-payment-methods/shared.js +72 -0
- package/dist/src/ts/index.d.ts +27 -0
- package/dist/src/ts/index.d.ts.map +1 -0
- package/dist/src/ts/index.js +34 -0
- package/dist/src/ts/utils/deploy.d.ts +22 -0
- package/dist/src/ts/utils/deploy.d.ts.map +1 -0
- package/dist/src/ts/utils/deploy.js +28 -0
- package/dist/src/ts/utils/gas.d.ts +51 -0
- package/dist/src/ts/utils/gas.d.ts.map +1 -0
- package/dist/src/ts/utils/gas.js +60 -0
- package/dist/src/ts/utils/index.d.ts +3 -0
- package/dist/src/ts/utils/index.d.ts.map +1 -0
- package/dist/src/ts/utils/index.js +5 -0
- package/dist/target/bridged_contract-BridgedFPC.json +8821 -0
- package/dist/target/counter_contract-Counter.json +2691 -0
- package/package.json +29 -8
- package/target/bridged_contract-BridgedFPC.json +8821 -0
- package/target/bridged_contract-BridgedFPC.json.bak +1 -0
- package/target/counter_contract-Counter.json +2691 -0
- package/target/counter_contract-Counter.json.bak +1 -0
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridged.d.ts","sourceRoot":"","sources":["../../../../src/ts/fee-payment-methods/bridged.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAM5D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,iCAAkC,YAAW,gBAAgB;IAEtE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAJT,UAAU,EAAE,YAAY,EACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,EAAE,EACV,IAAI,EAAE,EAAE,EACR,SAAS,EAAE,EAAE;IAGhC,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAIjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAI9B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA0CtD,cAAc,IAAI,WAAW,GAAG,SAAS;CAG1C"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { FunctionCall, FunctionSelector, FunctionType, } from "@aztec/stdlib/abi";
|
|
2
|
+
import { ExecutionPayload } from "@aztec/stdlib/tx";
|
|
3
|
+
import { Fr } from "@aztec/foundation/curves/bn254";
|
|
4
|
+
import { ProtocolContractAddress } from "@aztec/protocol-contracts";
|
|
5
|
+
/**
|
|
6
|
+
* Fee payment method for BridgedFPC that bundles FeeJuice.claim +
|
|
7
|
+
* mint_and_pay_fee in a single transaction setup phase.
|
|
8
|
+
*
|
|
9
|
+
* Enables cold-start fee sponsorship directly from a L1 bridge deposit,
|
|
10
|
+
* with no prior `mint` call needed. The caller's wallet only needs to
|
|
11
|
+
* have done the L1 deposit; the L2 claim and wFJ credit happen atomically here.
|
|
12
|
+
*
|
|
13
|
+
* The payment calls (in order):
|
|
14
|
+
* 1. FeeJuice.claim(fpcAddress, amount, secret, leafIndex)
|
|
15
|
+
* - Consumes the L1→L2 message; emits the FeeJuice nullifier.
|
|
16
|
+
* 2. BridgedFPC.mint_and_pay_fee(amount, salt, leafIndex)
|
|
17
|
+
* - Asserts the FeeJuice nullifier exists (pending from step 1).
|
|
18
|
+
* - Credits (amount - max_gas_cost) to msg_sender.
|
|
19
|
+
* - Sets BridgedFPC as fee payer and ends setup.
|
|
20
|
+
*/
|
|
21
|
+
export class BridgedMintAndPayFeePaymentMethod {
|
|
22
|
+
constructor(fpcAddress, amount, secret, salt, leafIndex) {
|
|
23
|
+
this.fpcAddress = fpcAddress;
|
|
24
|
+
this.amount = amount;
|
|
25
|
+
this.secret = secret;
|
|
26
|
+
this.salt = salt;
|
|
27
|
+
this.leafIndex = leafIndex;
|
|
28
|
+
}
|
|
29
|
+
getAsset() {
|
|
30
|
+
throw new Error("Asset is not required for bridged fee payment.");
|
|
31
|
+
}
|
|
32
|
+
getFeePayer() {
|
|
33
|
+
return Promise.resolve(this.fpcAddress);
|
|
34
|
+
}
|
|
35
|
+
async getExecutionPayload() {
|
|
36
|
+
const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
|
|
37
|
+
return new ExecutionPayload([
|
|
38
|
+
FunctionCall.from({
|
|
39
|
+
name: "claim",
|
|
40
|
+
to: feeJuiceAddress,
|
|
41
|
+
selector: await FunctionSelector.fromSignature("claim((Field),u128,Field,Field)"),
|
|
42
|
+
type: FunctionType.PRIVATE,
|
|
43
|
+
hideMsgSender: false,
|
|
44
|
+
isStatic: false,
|
|
45
|
+
args: [
|
|
46
|
+
this.fpcAddress.toField(),
|
|
47
|
+
new Fr(this.amount),
|
|
48
|
+
this.secret,
|
|
49
|
+
this.leafIndex,
|
|
50
|
+
],
|
|
51
|
+
returnTypes: [],
|
|
52
|
+
}),
|
|
53
|
+
FunctionCall.from({
|
|
54
|
+
name: "mint_and_pay_fee",
|
|
55
|
+
to: this.fpcAddress,
|
|
56
|
+
selector: await FunctionSelector.fromSignature("mint_and_pay_fee(u128,Field,Field)"),
|
|
57
|
+
type: FunctionType.PRIVATE,
|
|
58
|
+
hideMsgSender: false,
|
|
59
|
+
isStatic: false,
|
|
60
|
+
args: [new Fr(this.amount), this.salt, this.leafIndex],
|
|
61
|
+
returnTypes: [],
|
|
62
|
+
}),
|
|
63
|
+
], [], [], [], this.fpcAddress);
|
|
64
|
+
}
|
|
65
|
+
getGasSettings() {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJpZGdlZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy90cy9mZWUtcGF5bWVudC1tZXRob2RzL2JyaWRnZWQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUNMLFlBQVksRUFDWixnQkFBZ0IsRUFDaEIsWUFBWSxHQUNiLE1BQU0sbUJBQW1CLENBQUM7QUFHM0IsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDcEQsT0FBTyxFQUFFLEVBQUUsRUFBRSx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UMsT0FBTyxFQUFFO29CQUN6QixJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDO29CQUNuQixJQUFJLENBQUMsTUFBTTtvQkFDWCxJQUFJLENBQUMsU0FBUztpQkFDZjtnQkFDRCxXQUFXLEVBQUUsRUFBRTthQUNoQixDQUFDO1lBQ0YsWUFBWSxDQUFDLElBQUksQ0FBQztnQkFDaEIsSUFBSSxFQUFFLGtCQUFrQjtnQkFDeEIsRUFBRSxFQUFFLElBQUksQ0FBQyxVQUFVO2dCQUNuQixRQUFRLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQyxhQUFhLENBQzVDLG9DQUFvQyxDQUNyQztnQkFDRCxJQUFJLEVBQUUsWUFBWSxDQUFDLE9BQU87Z0JBQzFCLGFBQWEsRUFBRSxLQUFLO2dCQUNwQixRQUFRLEVBQUUsS0FBSztnQkFDZixJQUFJLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLEVBQUUsSUFBSSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsU0FBUyxDQUFDO2dCQUN0RCxXQUFXLEVBQUUsRUFBRTthQUNoQixDQUFDO1NBQ0gsRUFDRCxFQUFFLEVBQ0YsRUFBRSxFQUNGLEVBQUUsRUFDRixJQUFJLENBQUMsVUFBVSxDQUNoQixDQUFDO0lBQ0osQ0FBQztJQUVELGNBQWM7UUFDWixPQUFPO0lBQ1QsQ0FBQztDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts/fee-payment-methods/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { FPCFeePaymentMethod, FPCExactFeePaymentMethod } from "./shared.js";
|
|
2
|
+
export { BridgedMintAndPayFeePaymentMethod } from "./bridged.js";
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdHMvZmVlLXBheW1lbnQtbWV0aG9kcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFDNUUsT0FBTyxFQUFFLGlDQUFpQyxFQUFFLE1BQU0sY0FBYyxDQUFDIn0=
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FeePaymentMethod } from "@aztec/aztec.js/fee";
|
|
2
|
+
import { AztecAddress } from "@aztec/stdlib/aztec-address";
|
|
3
|
+
import type { GasSettings } from "@aztec/stdlib/gas";
|
|
4
|
+
import { ExecutionPayload } from "@aztec/stdlib/tx";
|
|
5
|
+
/**
|
|
6
|
+
* Generic fee payment method compatible with any FPC contract that implements pay_fee().
|
|
7
|
+
* Deducts max gas cost from the sender's internal balance. Does not refund unused gas.
|
|
8
|
+
* Suitable for any FPC that implements pay_fee().
|
|
9
|
+
*
|
|
10
|
+
* Use FPCExactFeePaymentMethod for transactions that need unused gas refunded.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FPCFeePaymentMethod implements FeePaymentMethod {
|
|
13
|
+
private readonly fpcAddress;
|
|
14
|
+
constructor(fpcAddress: AztecAddress);
|
|
15
|
+
getAsset(): Promise<AztecAddress>;
|
|
16
|
+
getFeePayer(): Promise<AztecAddress>;
|
|
17
|
+
getExecutionPayload(): Promise<ExecutionPayload>;
|
|
18
|
+
getGasSettings(): GasSettings | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generic fee payment method compatible with any FPC contract that implements pay_fee_exact().
|
|
22
|
+
* Deducts max gas cost upfront, then refunds (max - actual) in the teardown phase via a partial note.
|
|
23
|
+
*
|
|
24
|
+
* Use REASONABLE_TEARDOWN_GAS_LIMITS in the transaction's gasSettings to budget the teardown phase.
|
|
25
|
+
*/
|
|
26
|
+
export declare class FPCExactFeePaymentMethod implements FeePaymentMethod {
|
|
27
|
+
private readonly fpcAddress;
|
|
28
|
+
constructor(fpcAddress: AztecAddress);
|
|
29
|
+
getAsset(): Promise<AztecAddress>;
|
|
30
|
+
getFeePayer(): Promise<AztecAddress>;
|
|
31
|
+
getExecutionPayload(): Promise<ExecutionPayload>;
|
|
32
|
+
getGasSettings(): GasSettings | undefined;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../src/ts/fee-payment-methods/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAM5D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;GAMG;AACH,qBAAa,mBAAoB,YAAW,gBAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,YAAY;IAErD,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAIjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAI9B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAqBtD,cAAc,IAAI,WAAW,GAAG,SAAS;CAG1C;AAED;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,gBAAgB;IACnD,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,YAAY;IAErD,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAIjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAI9B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAqBtD,cAAc,IAAI,WAAW,GAAG,SAAS;CAG1C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { FunctionCall, FunctionSelector, FunctionType, } from "@aztec/stdlib/abi";
|
|
2
|
+
import { ExecutionPayload } from "@aztec/stdlib/tx";
|
|
3
|
+
/**
|
|
4
|
+
* Generic fee payment method compatible with any FPC contract that implements pay_fee().
|
|
5
|
+
* Deducts max gas cost from the sender's internal balance. Does not refund unused gas.
|
|
6
|
+
* Suitable for any FPC that implements pay_fee().
|
|
7
|
+
*
|
|
8
|
+
* Use FPCExactFeePaymentMethod for transactions that need unused gas refunded.
|
|
9
|
+
*/
|
|
10
|
+
export class FPCFeePaymentMethod {
|
|
11
|
+
constructor(fpcAddress) {
|
|
12
|
+
this.fpcAddress = fpcAddress;
|
|
13
|
+
}
|
|
14
|
+
getAsset() {
|
|
15
|
+
throw new Error("Asset is not required for FPC fee payment.");
|
|
16
|
+
}
|
|
17
|
+
getFeePayer() {
|
|
18
|
+
return Promise.resolve(this.fpcAddress);
|
|
19
|
+
}
|
|
20
|
+
async getExecutionPayload() {
|
|
21
|
+
return new ExecutionPayload([
|
|
22
|
+
FunctionCall.from({
|
|
23
|
+
name: "pay_fee",
|
|
24
|
+
to: this.fpcAddress,
|
|
25
|
+
selector: await FunctionSelector.fromSignature("pay_fee()"),
|
|
26
|
+
type: FunctionType.PRIVATE,
|
|
27
|
+
hideMsgSender: false,
|
|
28
|
+
isStatic: false,
|
|
29
|
+
args: [],
|
|
30
|
+
returnTypes: [],
|
|
31
|
+
}),
|
|
32
|
+
], [], [], [], this.fpcAddress);
|
|
33
|
+
}
|
|
34
|
+
getGasSettings() {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generic fee payment method compatible with any FPC contract that implements pay_fee_exact().
|
|
40
|
+
* Deducts max gas cost upfront, then refunds (max - actual) in the teardown phase via a partial note.
|
|
41
|
+
*
|
|
42
|
+
* Use REASONABLE_TEARDOWN_GAS_LIMITS in the transaction's gasSettings to budget the teardown phase.
|
|
43
|
+
*/
|
|
44
|
+
export class FPCExactFeePaymentMethod {
|
|
45
|
+
constructor(fpcAddress) {
|
|
46
|
+
this.fpcAddress = fpcAddress;
|
|
47
|
+
}
|
|
48
|
+
getAsset() {
|
|
49
|
+
throw new Error("Asset is not required for FPC fee payment.");
|
|
50
|
+
}
|
|
51
|
+
getFeePayer() {
|
|
52
|
+
return Promise.resolve(this.fpcAddress);
|
|
53
|
+
}
|
|
54
|
+
async getExecutionPayload() {
|
|
55
|
+
return new ExecutionPayload([
|
|
56
|
+
FunctionCall.from({
|
|
57
|
+
name: "pay_fee_exact",
|
|
58
|
+
to: this.fpcAddress,
|
|
59
|
+
selector: await FunctionSelector.fromSignature("pay_fee_exact()"),
|
|
60
|
+
type: FunctionType.PRIVATE,
|
|
61
|
+
hideMsgSender: false,
|
|
62
|
+
isStatic: false,
|
|
63
|
+
args: [],
|
|
64
|
+
returnTypes: [],
|
|
65
|
+
}),
|
|
66
|
+
], [], [], [], this.fpcAddress);
|
|
67
|
+
}
|
|
68
|
+
getGasSettings() {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2hhcmVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RzL2ZlZS1wYXltZW50LW1ldGhvZHMvc2hhcmVkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFDTCxZQUFZLEVBQ1osZ0JBQWdCLEVBQ2hCLFlBQVksR0FDYixNQUFNLG1CQUFtQixDQUFD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jO0lBQUcsQ0FBQztJQUV6RCxRQUFRO1FBQ04sTUFBTSxJQUFJLEtBQUssQ0FBQyw0Q0FBNEMsQ0FBQyxDQUFDO0lBQ2hFLENBQUM7SUFFRCxXQUFXO1FBQ1QsT0FBTyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUMxQyxDQUFDO0lBRUQsS0FBSyxDQUFDLG1CQUFtQjtRQUN2QixPQUFPLElBQUksZ0JBQWdCLENBQ3pCO1lBQ0UsWUFBWSxDQUFDLElBQUksQ0FBQztnQkFDaEIsSUFBSSxFQUFFLGVBQWU7Z0JBQ3JCLEVBQUUsRUFBRSxJQUFJLENBQUMsVUFBVTtnQkFDbkIsUUFBUSxFQUFFLE1BQU0sZ0JBQWdCLENBQUMsYUFBYSxDQUFDLGlCQUFpQixDQUFDO2dCQUNqRSxJQUFJLEVBQUUsWUFBWSxDQUFDLE9BQU87Z0JBQzFCLGFBQWEsRUFBRSxLQUFLO2dCQUNwQixRQUFRLEVBQUUsS0FBSztnQkFDZixJQUFJLEVBQUUsRUFBRTtnQkFDUixXQUFXLEVBQUUsRUFBRTthQUNoQixDQUFDO1NBQ0gsRUFDRCxFQUFFLEVBQ0YsRUFBRSxFQUNGLEVBQUUsRUFDRixJQUFJLENBQUMsVUFBVSxDQUNoQixDQUFDO0lBQ0osQ0FBQztJQUVELGNBQWM7UUFDWixPQUFPO0lBQ1QsQ0FBQztDQUNGIn0=
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @defi-wonderland/aztec-fee-payment
|
|
3
|
+
*
|
|
4
|
+
* Fee Payment Contracts (FPCs) for Aztec - enables bridged fee payment strategies.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import {
|
|
9
|
+
* BridgedFPCContract,
|
|
10
|
+
* FPCFeePaymentMethod,
|
|
11
|
+
* registerBridgedContract,
|
|
12
|
+
* } from '@defi-wonderland/aztec-fee-payment';
|
|
13
|
+
*
|
|
14
|
+
* // Register (no deploy needed — fully private contract)
|
|
15
|
+
* const fpc = await registerBridgedContract(wallet);
|
|
16
|
+
*
|
|
17
|
+
* // Use FPCFeePaymentMethod after minting internal balance
|
|
18
|
+
* await someContract.methods.doSomething()
|
|
19
|
+
* .send({
|
|
20
|
+
* fee: { paymentMethod: new FPCFeePaymentMethod(fpc.address) }
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export { BridgedFPCContract, BridgedFPCContractArtifact, } from "../artifacts/BridgedFPC.js";
|
|
25
|
+
export { FPCFeePaymentMethod, FPCExactFeePaymentMethod, BridgedMintAndPayFeePaymentMethod, } from "./fee-payment-methods/index.js";
|
|
26
|
+
export { DEFAULT_FEE_MULTIPLIER, REASONABLE_GAS_LIMITS, REASONABLE_TEARDOWN_GAS_LIMITS, maxFeesPerGasFromBaseFees, maxGasCostFor, registerBridgedContract, } from "./utils/index.js";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAEL,sBAAsB,EACtB,qBAAqB,EACrB,8BAA8B,EAC9B,yBAAyB,EACzB,aAAa,EAEb,uBAAuB,GACxB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @defi-wonderland/aztec-fee-payment
|
|
3
|
+
*
|
|
4
|
+
* Fee Payment Contracts (FPCs) for Aztec - enables bridged fee payment strategies.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import {
|
|
9
|
+
* BridgedFPCContract,
|
|
10
|
+
* FPCFeePaymentMethod,
|
|
11
|
+
* registerBridgedContract,
|
|
12
|
+
* } from '@defi-wonderland/aztec-fee-payment';
|
|
13
|
+
*
|
|
14
|
+
* // Register (no deploy needed — fully private contract)
|
|
15
|
+
* const fpc = await registerBridgedContract(wallet);
|
|
16
|
+
*
|
|
17
|
+
* // Use FPCFeePaymentMethod after minting internal balance
|
|
18
|
+
* await someContract.methods.doSomething()
|
|
19
|
+
* .send({
|
|
20
|
+
* fee: { paymentMethod: new FPCFeePaymentMethod(fpc.address) }
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
// Contract artifacts and type-safe wrappers
|
|
25
|
+
export { BridgedFPCContract, BridgedFPCContractArtifact, } from "../artifacts/BridgedFPC.js";
|
|
26
|
+
// Fee payment method implementations
|
|
27
|
+
export { FPCFeePaymentMethod, FPCExactFeePaymentMethod, BridgedMintAndPayFeePaymentMethod, } from "./fee-payment-methods/index.js";
|
|
28
|
+
// Utilities for integrators
|
|
29
|
+
export {
|
|
30
|
+
// Gas calculations
|
|
31
|
+
DEFAULT_FEE_MULTIPLIER, REASONABLE_GAS_LIMITS, REASONABLE_TEARDOWN_GAS_LIMITS, maxFeesPerGasFromBaseFees, maxGasCostFor,
|
|
32
|
+
// Deployment
|
|
33
|
+
registerBridgedContract, } from "./utils/index.js";
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FzQkc7QUFFSCw0Q0FBNEM7QUFDNUMsT0FBTyxFQUNMLGtCQUFrQixFQUNsQiwwQkFBMEIsR0FDM0IsTUFBTSw0QkFBNEIsQ0FBQztBQUVwQyxxQ0FBcUM7QUFDckMsT0FBTyxFQUNMLG1CQUFtQixFQUNuQix3QkFBd0IsRUFDeEIsaUNBQWlDLEdBQ2xDLE1BQU0sZ0NBQWdDLENBQUM7QUFFeEMsNEJBQTRCO0FBQzVCLE9BQU87QUFDTCxtQkFBbUI7QUFDbkIsc0JBQXNCLEVBQ3RCLHFCQUFxQixFQUNyQiw4QkFBOEIsRUFDOUIseUJBQXlCLEVBQ3pCLGFBQWE7QUFDYixhQUFhO0FBQ2IsdUJBQXVCLEdBQ3hCLE1BQU0sa0JBQWtCLENBQUMifQ==
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Fr } from "@aztec/foundation/curves/bn254";
|
|
2
|
+
import { Wallet } from "@aztec/aztec.js/wallet";
|
|
3
|
+
import { BridgedFPCContract } from "../../artifacts/BridgedFPC.js";
|
|
4
|
+
/**
|
|
5
|
+
* Registers the BridgedFPC contract with the PXE without sending any deployment transaction.
|
|
6
|
+
*
|
|
7
|
+
* BridgedFPC is a fully private contract (no public functions, no constructor, no initializer).
|
|
8
|
+
* The Aztec protocol allows interacting with such contracts immediately once registered —
|
|
9
|
+
* no on-chain deployment transaction is required.
|
|
10
|
+
*
|
|
11
|
+
* The contract address is computed deterministically from its class hash and the provided salt,
|
|
12
|
+
* with `deployer: AztecAddress.ZERO` so the deployer address is NOT mixed in. This means the same
|
|
13
|
+
* salt always produces the same address regardless of who calls this function.
|
|
14
|
+
* (`universalDeploy` is only available on `.send()` options; for `.register()` the equivalent
|
|
15
|
+
* is setting `deployer` to `AztecAddress.ZERO`.)
|
|
16
|
+
*
|
|
17
|
+
* @param wallet The wallet used to register the contract with the PXE
|
|
18
|
+
* @param salt Optional address salt (defaults to Fr.ZERO for a canonical address)
|
|
19
|
+
* @returns The registered BridgedFPC contract instance
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerBridgedContract(wallet: Wallet, salt?: Fr): Promise<BridgedFPCContract>;
|
|
22
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,EAAY,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAM7B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Fr } from "@aztec/foundation/curves/bn254";
|
|
2
|
+
import { AztecAddress } from "@aztec/aztec.js/addresses";
|
|
3
|
+
import { BridgedFPCContract } from "../../artifacts/BridgedFPC.js";
|
|
4
|
+
/**
|
|
5
|
+
* Registers the BridgedFPC contract with the PXE without sending any deployment transaction.
|
|
6
|
+
*
|
|
7
|
+
* BridgedFPC is a fully private contract (no public functions, no constructor, no initializer).
|
|
8
|
+
* The Aztec protocol allows interacting with such contracts immediately once registered —
|
|
9
|
+
* no on-chain deployment transaction is required.
|
|
10
|
+
*
|
|
11
|
+
* The contract address is computed deterministically from its class hash and the provided salt,
|
|
12
|
+
* with `deployer: AztecAddress.ZERO` so the deployer address is NOT mixed in. This means the same
|
|
13
|
+
* salt always produces the same address regardless of who calls this function.
|
|
14
|
+
* (`universalDeploy` is only available on `.send()` options; for `.register()` the equivalent
|
|
15
|
+
* is setting `deployer` to `AztecAddress.ZERO`.)
|
|
16
|
+
*
|
|
17
|
+
* @param wallet The wallet used to register the contract with the PXE
|
|
18
|
+
* @param salt Optional address salt (defaults to Fr.ZERO for a canonical address)
|
|
19
|
+
* @returns The registered BridgedFPC contract instance
|
|
20
|
+
*/
|
|
21
|
+
export async function registerBridgedContract(wallet, salt = Fr.ZERO) {
|
|
22
|
+
return BridgedFPCContract.deploy(wallet).register({
|
|
23
|
+
contractAddressSalt: salt,
|
|
24
|
+
skipInitialization: true,
|
|
25
|
+
deployer: AztecAddress.ZERO,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RzL3V0aWxzL2RlcGxveS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFFcEQsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRXpELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRW5FOzs7Ozs7Ozs7Ozs7Ozs7O0dBZ0JHO0FBQ0gsTUFBTSxDQUFDLEtBQUssVUFBVSx1QkFBdUIsQ0FDM0MsTUFBYyxFQUNkLE9BQVcsRUFBRSxDQUFDLElBQUk7SUFFbEIsT0FBTyxrQkFBa0IsQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUMsUUFBUSxDQUFDO1FBQ2hELG1CQUFtQixFQUFFLElBQUk7UUFDekIsa0JBQWtCLEVBQUUsSUFBSTtRQUN4QixRQUFRLEVBQUUsWUFBWSxDQUFDLElBQUk7S0FDNUIsQ0FBQyxDQUFDO0FBQ0wsQ0FBQyJ9
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Gas, GasFees } from "@aztec/stdlib/gas";
|
|
2
|
+
/**
|
|
3
|
+
* Default safety multiplier applied to base fees.
|
|
4
|
+
* Provides headroom above the current minimum to avoid rejection under fee spikes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_FEE_MULTIPLIER = 3n;
|
|
7
|
+
/**
|
|
8
|
+
* Reasonable default gas limits for most transactions.
|
|
9
|
+
*/
|
|
10
|
+
export declare const REASONABLE_GAS_LIMITS: Gas;
|
|
11
|
+
/**
|
|
12
|
+
* Teardown gas limits for transactions that use pay_fee_exact().
|
|
13
|
+
*
|
|
14
|
+
* These are Aztec's protocol-wide defaults (DEFAULT_TEARDOWN_DA_GAS_LIMIT = 393,216;
|
|
15
|
+
* DEFAULT_TEARDOWN_L2_GAS_LIMIT = 1,000,000). They are NOT calibrated to the _refund
|
|
16
|
+
* teardown function, which only emits one note hash and costs roughly 40-50k L2 gas
|
|
17
|
+
* in practice (~20x cheaper than this limit).
|
|
18
|
+
*
|
|
19
|
+
* The protocol bills teardown gas at the limit (rather than actual usage), this
|
|
20
|
+
* overestimate inflates the cost of every pay_fee_exact transaction. Consider
|
|
21
|
+
* benchmarking _refund's actual gas consumption and replacing this with a tighter
|
|
22
|
+
* constant.
|
|
23
|
+
*
|
|
24
|
+
* NOTE: teardown gas is already included in the gas_limits fee calculation by the protocol,
|
|
25
|
+
* so this must NOT be passed to maxGasCostFor (that would double-count teardown cost).
|
|
26
|
+
*/
|
|
27
|
+
export declare const REASONABLE_TEARDOWN_GAS_LIMITS: Gas;
|
|
28
|
+
/**
|
|
29
|
+
* Calculate max fees per gas from base fees with a multiplier.
|
|
30
|
+
* @param baseFees - The current base fees from the node
|
|
31
|
+
* @param multiplier - Multiplier to apply (default: DEFAULT_FEE_MULTIPLIER)
|
|
32
|
+
* @returns GasFees object with calculated max fees
|
|
33
|
+
*/
|
|
34
|
+
export declare function maxFeesPerGasFromBaseFees(baseFees: {
|
|
35
|
+
feePerDaGas: string | number | bigint;
|
|
36
|
+
feePerL2Gas: string | number | bigint;
|
|
37
|
+
}, multiplier?: bigint): GasFees;
|
|
38
|
+
/**
|
|
39
|
+
* Calculate the maximum gas cost for a transaction.
|
|
40
|
+
*
|
|
41
|
+
* Teardown gas is already accounted for inside gasLimits by the protocol
|
|
42
|
+
* (the kernel's gas_meter includes teardown in the overall fee computation),
|
|
43
|
+
* so teardownGasLimits must NOT be added again here — doing so would
|
|
44
|
+
* double-count the teardown cost.
|
|
45
|
+
*
|
|
46
|
+
* @param maxFeesPerGas - Maximum fees per gas unit
|
|
47
|
+
* @param gasLimits - Gas limits for the transaction (already covers teardown allocation)
|
|
48
|
+
* @returns Maximum possible gas cost in wei
|
|
49
|
+
*/
|
|
50
|
+
export declare function maxGasCostFor(maxFeesPerGas: GasFees, gasLimits: Gas): bigint;
|
|
51
|
+
//# sourceMappingURL=gas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/gas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAQjD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,qBAAqB,KAGhC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,KAGzC,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE;IACR,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CACvC,EACD,UAAU,GAAE,MAA+B,GAC1C,OAAO,CAKT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,GAAG,MAAM,CAK5E"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Gas, GasFees } from "@aztec/stdlib/gas";
|
|
2
|
+
import { DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT, DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT, } from "@aztec/constants";
|
|
3
|
+
/**
|
|
4
|
+
* Default safety multiplier applied to base fees.
|
|
5
|
+
* Provides headroom above the current minimum to avoid rejection under fee spikes.
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_FEE_MULTIPLIER = 3n;
|
|
8
|
+
/**
|
|
9
|
+
* Reasonable default gas limits for most transactions.
|
|
10
|
+
*/
|
|
11
|
+
export const REASONABLE_GAS_LIMITS = Gas.from({
|
|
12
|
+
daGas: DEFAULT_DA_GAS_LIMIT,
|
|
13
|
+
l2Gas: DEFAULT_L2_GAS_LIMIT,
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Teardown gas limits for transactions that use pay_fee_exact().
|
|
17
|
+
*
|
|
18
|
+
* These are Aztec's protocol-wide defaults (DEFAULT_TEARDOWN_DA_GAS_LIMIT = 393,216;
|
|
19
|
+
* DEFAULT_TEARDOWN_L2_GAS_LIMIT = 1,000,000). They are NOT calibrated to the _refund
|
|
20
|
+
* teardown function, which only emits one note hash and costs roughly 40-50k L2 gas
|
|
21
|
+
* in practice (~20x cheaper than this limit).
|
|
22
|
+
*
|
|
23
|
+
* The protocol bills teardown gas at the limit (rather than actual usage), this
|
|
24
|
+
* overestimate inflates the cost of every pay_fee_exact transaction. Consider
|
|
25
|
+
* benchmarking _refund's actual gas consumption and replacing this with a tighter
|
|
26
|
+
* constant.
|
|
27
|
+
*
|
|
28
|
+
* NOTE: teardown gas is already included in the gas_limits fee calculation by the protocol,
|
|
29
|
+
* so this must NOT be passed to maxGasCostFor (that would double-count teardown cost).
|
|
30
|
+
*/
|
|
31
|
+
export const REASONABLE_TEARDOWN_GAS_LIMITS = Gas.from({
|
|
32
|
+
daGas: DEFAULT_TEARDOWN_DA_GAS_LIMIT,
|
|
33
|
+
l2Gas: DEFAULT_TEARDOWN_L2_GAS_LIMIT,
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Calculate max fees per gas from base fees with a multiplier.
|
|
37
|
+
* @param baseFees - The current base fees from the node
|
|
38
|
+
* @param multiplier - Multiplier to apply (default: DEFAULT_FEE_MULTIPLIER)
|
|
39
|
+
* @returns GasFees object with calculated max fees
|
|
40
|
+
*/
|
|
41
|
+
export function maxFeesPerGasFromBaseFees(baseFees, multiplier = DEFAULT_FEE_MULTIPLIER) {
|
|
42
|
+
return new GasFees(BigInt(baseFees.feePerDaGas) * multiplier, BigInt(baseFees.feePerL2Gas) * multiplier);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Calculate the maximum gas cost for a transaction.
|
|
46
|
+
*
|
|
47
|
+
* Teardown gas is already accounted for inside gasLimits by the protocol
|
|
48
|
+
* (the kernel's gas_meter includes teardown in the overall fee computation),
|
|
49
|
+
* so teardownGasLimits must NOT be added again here — doing so would
|
|
50
|
+
* double-count the teardown cost.
|
|
51
|
+
*
|
|
52
|
+
* @param maxFeesPerGas - Maximum fees per gas unit
|
|
53
|
+
* @param gasLimits - Gas limits for the transaction (already covers teardown allocation)
|
|
54
|
+
* @returns Maximum possible gas cost in wei
|
|
55
|
+
*/
|
|
56
|
+
export function maxGasCostFor(maxFeesPerGas, gasLimits) {
|
|
57
|
+
return (BigInt(maxFeesPerGas.feePerDaGas) * BigInt(gasLimits.daGas) +
|
|
58
|
+
BigInt(maxFeesPerGas.feePerL2Gas) * BigInt(gasLimits.l2Gas));
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RzL3V0aWxzL2dhcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsR0FBRyxFQUFFLE9BQU8sRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ2pELE9BQU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QU0sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLENBQzVELENBQUM7QUFDSixDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,8BAA8B,EAC9B,yBAAyB,EACzB,aAAa,GACd,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Gas calculation utilities
|
|
2
|
+
export { DEFAULT_FEE_MULTIPLIER, REASONABLE_GAS_LIMITS, REASONABLE_TEARDOWN_GAS_LIMITS, maxFeesPerGasFromBaseFees, maxGasCostFor, } from "./gas.js";
|
|
3
|
+
// Deployment utilities
|
|
4
|
+
export { registerBridgedContract } from "./deploy.js";
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdHMvdXRpbHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNEJBQTRCO0FBQzVCLE9BQU8sRUFDTCxzQkFBc0IsRUFDdEIscUJBQXFCLEVBQ3JCLDhCQUE4QixFQUM5Qix5QkFBeUIsRUFDekIsYUFBYSxHQUNkLE1BQU0sVUFBVSxDQUFDO0FBRWxCLHVCQUF1QjtBQUN2QixPQUFPLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxhQUFhLENBQUMifQ==
|