@aztec/cli-wallet 0.78.1 → 0.79.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/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +17 -10
- package/dest/utils/sponsored_fee_payment.d.ts +19 -0
- package/dest/utils/sponsored_fee_payment.d.ts.map +1 -0
- package/dest/utils/sponsored_fee_payment.js +26 -0
- package/package.json +10 -10
- package/src/utils/options/fees.ts +17 -9
- package/src/utils/sponsored_fee_payment.ts +29 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../../src/utils/options/fees.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EACrB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAO,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../../src/utils/options/fees.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EACrB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAO,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,KAAK,EAAE,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,CAAC,oBAAoB,CAAC;IAa/E,MAAM,CAAC,mBAAmB;IAI1B,MAAM,CAAC,UAAU;WAIJ,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ;CAsB3E;AAED,qBAAa,mBAAoB,SAAQ,OAAO;WAC9B,mBAAmB;WAInB,UAAU;WAIJ,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ;CA2BpF;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,OAAO,EAC5B,GAAG,EAAE,KAAK,EACV,EAAE,CAAC,EAAE,QAAQ,GACZ,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,gBAAgB,CAAC,CA+EtD;AAsBD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAerD"}
|
|
@@ -4,6 +4,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
4
4
|
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { Option } from 'commander';
|
|
6
6
|
import { createOrRetrieveAccount } from '../accounts.js';
|
|
7
|
+
import { SponsoredFeePaymentMethod } from '../sponsored_fee_payment.js';
|
|
7
8
|
import { aliasedAddressParser } from './options.js';
|
|
8
9
|
export function printGasEstimates(feeOpts, gasEstimates, log) {
|
|
9
10
|
log(`Estimated gas usage: ${formatGasEstimate(gasEstimates)}`);
|
|
@@ -46,7 +47,7 @@ function getFeePaymentMethodParams(allowCustomFeePayer) {
|
|
|
46
47
|
return {
|
|
47
48
|
method: {
|
|
48
49
|
type: 'name',
|
|
49
|
-
description: 'Valid values: "fee_juice", "fpc-public", "fpc-private"
|
|
50
|
+
description: 'Valid values: "fee_juice", "fpc-public", "fpc-private", "fpc-sponsored"',
|
|
50
51
|
default: 'fee_juice'
|
|
51
52
|
},
|
|
52
53
|
...feePayer ? {
|
|
@@ -54,7 +55,7 @@ function getFeePaymentMethodParams(allowCustomFeePayer) {
|
|
|
54
55
|
} : {},
|
|
55
56
|
asset: {
|
|
56
57
|
type: 'address',
|
|
57
|
-
description: 'The asset used for fee payment.
|
|
58
|
+
description: 'The asset used for fee payment. Required for "fpc-public" and "fpc-private".'
|
|
58
59
|
},
|
|
59
60
|
fpc: {
|
|
60
61
|
type: 'address',
|
|
@@ -183,18 +184,17 @@ export function parsePaymentMethod(payment, allowCustomFeePayer, log, db) {
|
|
|
183
184
|
acc[dimension] = value ?? 1;
|
|
184
185
|
return acc;
|
|
185
186
|
}, {});
|
|
186
|
-
const
|
|
187
|
+
const getFpc = ()=>{
|
|
187
188
|
if (!parsed.fpc) {
|
|
188
189
|
throw new Error('Missing "fpc" in payment option');
|
|
189
190
|
}
|
|
191
|
+
return aliasedAddressParser('contracts', parsed.fpc, db);
|
|
192
|
+
};
|
|
193
|
+
const getAsset = ()=>{
|
|
190
194
|
if (!parsed.asset) {
|
|
191
195
|
throw new Error('Missing "asset" in payment option');
|
|
192
196
|
}
|
|
193
|
-
|
|
194
|
-
return [
|
|
195
|
-
AztecAddress.fromString(parsed.asset),
|
|
196
|
-
fpc
|
|
197
|
-
];
|
|
197
|
+
return AztecAddress.fromString(parsed.asset);
|
|
198
198
|
};
|
|
199
199
|
return async (sender)=>{
|
|
200
200
|
switch(parsed.method){
|
|
@@ -223,18 +223,25 @@ export function parsePaymentMethod(payment, allowCustomFeePayer, log, db) {
|
|
|
223
223
|
}
|
|
224
224
|
case 'fpc-public':
|
|
225
225
|
{
|
|
226
|
-
const
|
|
226
|
+
const fpc = getFpc();
|
|
227
|
+
const asset = getAsset();
|
|
227
228
|
log(`Using public fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
228
229
|
const { PublicFeePaymentMethod } = await import('@aztec/aztec.js/fee');
|
|
229
230
|
return new PublicFeePaymentMethod(fpc, sender);
|
|
230
231
|
}
|
|
231
232
|
case 'fpc-private':
|
|
232
233
|
{
|
|
233
|
-
const
|
|
234
|
+
const fpc = getFpc();
|
|
235
|
+
const asset = getAsset();
|
|
234
236
|
log(`Using private fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
235
237
|
const { PrivateFeePaymentMethod } = await import('@aztec/aztec.js/fee');
|
|
236
238
|
return new PrivateFeePaymentMethod(fpc, sender);
|
|
237
239
|
}
|
|
240
|
+
case 'fpc-sponsored':
|
|
241
|
+
{
|
|
242
|
+
const sponsor = getFpc();
|
|
243
|
+
return new SponsoredFeePaymentMethod(sponsor);
|
|
244
|
+
}
|
|
238
245
|
case undefined:
|
|
239
246
|
throw new Error('Missing "method" in payment option');
|
|
240
247
|
default:
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
2
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
export declare class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
5
|
+
private paymentContract;
|
|
6
|
+
constructor(paymentContract: AztecAddress);
|
|
7
|
+
getAsset(): Promise<AztecAddress>;
|
|
8
|
+
getFeePayer(): Promise<AztecAddress>;
|
|
9
|
+
getFunctionCalls(): Promise<{
|
|
10
|
+
name: string;
|
|
11
|
+
to: AztecAddress;
|
|
12
|
+
selector: FunctionSelector;
|
|
13
|
+
type: FunctionType;
|
|
14
|
+
isStatic: boolean;
|
|
15
|
+
args: never[];
|
|
16
|
+
returnTypes: never[];
|
|
17
|
+
}[]>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=sponsored_fee_payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sponsored_fee_payment.d.ts","sourceRoot":"","sources":["../../src/utils/sponsored_fee_payment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,qBAAa,yBAA0B,YAAW,gBAAgB;IACpD,OAAO,CAAC,eAAe;gBAAf,eAAe,EAAE,YAAY;IAEjD,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAIjC,WAAW;IAIL,gBAAgB;;;;;;;;;CAavB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
2
|
+
export class SponsoredFeePaymentMethod {
|
|
3
|
+
paymentContract;
|
|
4
|
+
constructor(paymentContract){
|
|
5
|
+
this.paymentContract = paymentContract;
|
|
6
|
+
}
|
|
7
|
+
getAsset() {
|
|
8
|
+
throw new Error('Asset is not required for sponsored fpc.');
|
|
9
|
+
}
|
|
10
|
+
getFeePayer() {
|
|
11
|
+
return Promise.resolve(this.paymentContract);
|
|
12
|
+
}
|
|
13
|
+
async getFunctionCalls() {
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
name: 'sponsor_unconditionally',
|
|
17
|
+
to: this.paymentContract,
|
|
18
|
+
selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
|
|
19
|
+
type: FunctionType.PRIVATE,
|
|
20
|
+
isStatic: false,
|
|
21
|
+
args: [],
|
|
22
|
+
returnTypes: []
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/cli-wallet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/cmds/index.js",
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/accounts": "0.
|
|
69
|
-
"@aztec/aztec.js": "0.
|
|
70
|
-
"@aztec/cli": "0.
|
|
71
|
-
"@aztec/ethereum": "0.
|
|
72
|
-
"@aztec/foundation": "0.
|
|
73
|
-
"@aztec/kv-store": "0.
|
|
74
|
-
"@aztec/noir-contracts.js": "0.
|
|
75
|
-
"@aztec/pxe": "0.
|
|
76
|
-
"@aztec/stdlib": "0.
|
|
68
|
+
"@aztec/accounts": "0.79.0",
|
|
69
|
+
"@aztec/aztec.js": "0.79.0",
|
|
70
|
+
"@aztec/cli": "0.79.0",
|
|
71
|
+
"@aztec/ethereum": "0.79.0",
|
|
72
|
+
"@aztec/foundation": "0.79.0",
|
|
73
|
+
"@aztec/kv-store": "0.79.0",
|
|
74
|
+
"@aztec/noir-contracts.js": "0.79.0",
|
|
75
|
+
"@aztec/pxe": "0.79.0",
|
|
76
|
+
"@aztec/stdlib": "0.79.0",
|
|
77
77
|
"commander": "^12.1.0",
|
|
78
78
|
"inquirer": "^10.1.8",
|
|
79
79
|
"source-map-support": "^0.5.21",
|
|
@@ -15,6 +15,7 @@ import { Option } from 'commander';
|
|
|
15
15
|
|
|
16
16
|
import type { WalletDB } from '../../storage/wallet_db.js';
|
|
17
17
|
import { createOrRetrieveAccount } from '../accounts.js';
|
|
18
|
+
import { SponsoredFeePaymentMethod } from '../sponsored_fee_payment.js';
|
|
18
19
|
import { aliasedAddressParser } from './options.js';
|
|
19
20
|
|
|
20
21
|
export type CliFeeArgs = {
|
|
@@ -85,13 +86,13 @@ function getFeePaymentMethodParams(allowCustomFeePayer: boolean): OptionParams {
|
|
|
85
86
|
return {
|
|
86
87
|
method: {
|
|
87
88
|
type: 'name',
|
|
88
|
-
description: 'Valid values: "fee_juice", "fpc-public", "fpc-private"
|
|
89
|
+
description: 'Valid values: "fee_juice", "fpc-public", "fpc-private", "fpc-sponsored"',
|
|
89
90
|
default: 'fee_juice',
|
|
90
91
|
},
|
|
91
92
|
...(feePayer ? { feePayer } : {}),
|
|
92
93
|
asset: {
|
|
93
94
|
type: 'address',
|
|
94
|
-
description: 'The asset used for fee payment.
|
|
95
|
+
description: 'The asset used for fee payment. Required for "fpc-public" and "fpc-private".',
|
|
95
96
|
},
|
|
96
97
|
fpc: {
|
|
97
98
|
type: 'address',
|
|
@@ -260,17 +261,18 @@ export function parsePaymentMethod(
|
|
|
260
261
|
return acc;
|
|
261
262
|
}, {} as Record<string, string>);
|
|
262
263
|
|
|
263
|
-
const
|
|
264
|
+
const getFpc = () => {
|
|
264
265
|
if (!parsed.fpc) {
|
|
265
266
|
throw new Error('Missing "fpc" in payment option');
|
|
266
267
|
}
|
|
268
|
+
return aliasedAddressParser('contracts', parsed.fpc, db);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const getAsset = () => {
|
|
267
272
|
if (!parsed.asset) {
|
|
268
273
|
throw new Error('Missing "asset" in payment option');
|
|
269
274
|
}
|
|
270
|
-
|
|
271
|
-
const fpc = aliasedAddressParser('contracts', parsed.fpc, db);
|
|
272
|
-
|
|
273
|
-
return [AztecAddress.fromString(parsed.asset), fpc];
|
|
275
|
+
return AztecAddress.fromString(parsed.asset);
|
|
274
276
|
};
|
|
275
277
|
|
|
276
278
|
return async (sender: AccountWallet) => {
|
|
@@ -308,17 +310,23 @@ export function parsePaymentMethod(
|
|
|
308
310
|
}
|
|
309
311
|
}
|
|
310
312
|
case 'fpc-public': {
|
|
311
|
-
const
|
|
313
|
+
const fpc = getFpc();
|
|
314
|
+
const asset = getAsset();
|
|
312
315
|
log(`Using public fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
313
316
|
const { PublicFeePaymentMethod } = await import('@aztec/aztec.js/fee');
|
|
314
317
|
return new PublicFeePaymentMethod(fpc, sender);
|
|
315
318
|
}
|
|
316
319
|
case 'fpc-private': {
|
|
317
|
-
const
|
|
320
|
+
const fpc = getFpc();
|
|
321
|
+
const asset = getAsset();
|
|
318
322
|
log(`Using private fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
319
323
|
const { PrivateFeePaymentMethod } = await import('@aztec/aztec.js/fee');
|
|
320
324
|
return new PrivateFeePaymentMethod(fpc, sender);
|
|
321
325
|
}
|
|
326
|
+
case 'fpc-sponsored': {
|
|
327
|
+
const sponsor = getFpc();
|
|
328
|
+
return new SponsoredFeePaymentMethod(sponsor);
|
|
329
|
+
}
|
|
322
330
|
case undefined:
|
|
323
331
|
throw new Error('Missing "method" in payment option');
|
|
324
332
|
default:
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
2
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
|
|
5
|
+
export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
6
|
+
constructor(private paymentContract: AztecAddress) {}
|
|
7
|
+
|
|
8
|
+
getAsset(): Promise<AztecAddress> {
|
|
9
|
+
throw new Error('Asset is not required for sponsored fpc.');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getFeePayer() {
|
|
13
|
+
return Promise.resolve(this.paymentContract);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getFunctionCalls() {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: 'sponsor_unconditionally',
|
|
20
|
+
to: this.paymentContract,
|
|
21
|
+
selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
|
|
22
|
+
type: FunctionType.PRIVATE,
|
|
23
|
+
isStatic: false,
|
|
24
|
+
args: [],
|
|
25
|
+
returnTypes: [],
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|