@nevermined-io/core-kit 0.1.56 → 0.1.57
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.
|
@@ -20,6 +20,7 @@ export declare abstract class ContractBase extends Instantiable {
|
|
|
20
20
|
readonly contractName: string;
|
|
21
21
|
contract: any;
|
|
22
22
|
address: Address;
|
|
23
|
+
private _zeroDevPaymaster;
|
|
23
24
|
constructor(contractName: string, address: Address);
|
|
24
25
|
protected init(config: InstantiableConfig, contractConfig: {
|
|
25
26
|
address: `0x${string}`;
|
|
@@ -40,6 +41,7 @@ export declare abstract class ContractBase extends Instantiable {
|
|
|
40
41
|
private localAccountMulticall;
|
|
41
42
|
private localAccountSimulateMulticall;
|
|
42
43
|
private internalSimulateMulticallSmartAccount;
|
|
44
|
+
private getOrCreatePaymaster;
|
|
43
45
|
private getZeroDevRPC;
|
|
44
46
|
}
|
|
45
47
|
//# sourceMappingURL=ContractBase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractBase.d.ts","sourceRoot":"","sources":["../../src/contracts/ContractBase.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,GAAG,EACH,OAAO,EACP,OAAO,EAQP,kBAAkB,EACnB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE7E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAKxD,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,GAAG,CAAA;IACR,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,GAAG,EAAE,CAAA;CACZ;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAA;IACp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
|
contractName;
|
|
9
9
|
contract;
|
|
10
10
|
address;
|
|
11
|
+
_zeroDevPaymaster = null;
|
|
11
12
|
constructor(contractName, address) {
|
|
12
13
|
super();
|
|
13
14
|
this.contractName = contractName;
|
|
@@ -141,15 +142,11 @@ export class ContractBase extends Instantiable {
|
|
|
141
142
|
contractAddress: this.address,
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
|
-
const
|
|
145
|
-
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
146
|
-
chain: getChain(this.config.chainId),
|
|
147
|
-
transport: http(ZERODEV_RPC),
|
|
148
|
-
});
|
|
145
|
+
const zerodevPaymaster = this.getOrCreatePaymaster();
|
|
149
146
|
const kernelClient = createKernelAccountClient({
|
|
150
147
|
account: from,
|
|
151
148
|
chain: getChain(this.config.chainId),
|
|
152
|
-
bundlerTransport: http(
|
|
149
|
+
bundlerTransport: http(this.getZeroDevRPC()),
|
|
153
150
|
client: this.client.public,
|
|
154
151
|
paymaster: {
|
|
155
152
|
getPaymasterData: (userOperation) => {
|
|
@@ -214,7 +211,6 @@ export class ContractBase extends Instantiable {
|
|
|
214
211
|
gasLimit,
|
|
215
212
|
});
|
|
216
213
|
}
|
|
217
|
-
const ZERODEV_RPC = `https://rpc.zerodev.app/api/v3/${this.config.zeroDevProjectId}/chain/${this.config.chainId}`;
|
|
218
214
|
try {
|
|
219
215
|
await this.client.public.simulateContract({
|
|
220
216
|
address: this.address,
|
|
@@ -232,19 +228,12 @@ export class ContractBase extends Instantiable {
|
|
|
232
228
|
}
|
|
233
229
|
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
234
230
|
}
|
|
235
|
-
const zerodevPaymaster =
|
|
236
|
-
chain: getChain(this.config.chainId),
|
|
237
|
-
transport: http(ZERODEV_RPC),
|
|
238
|
-
});
|
|
231
|
+
const zerodevPaymaster = this.getOrCreatePaymaster();
|
|
239
232
|
const kernelClient = createKernelAccountClient({
|
|
240
233
|
account: from,
|
|
241
|
-
// Replace with your chain
|
|
242
234
|
chain: getChain(this.config.chainId),
|
|
243
|
-
|
|
244
|
-
bundlerTransport: http(ZERODEV_RPC),
|
|
245
|
-
// Required - the public client
|
|
235
|
+
bundlerTransport: http(this.getZeroDevRPC()),
|
|
246
236
|
client: this.client.public,
|
|
247
|
-
// Optional -- only if you want to use a paymaster
|
|
248
237
|
paymaster: {
|
|
249
238
|
getPaymasterData: (userOperation) => {
|
|
250
239
|
return zerodevPaymaster.sponsorUserOperation({
|
|
@@ -450,10 +439,7 @@ export class ContractBase extends Instantiable {
|
|
|
450
439
|
}
|
|
451
440
|
async internalSimulateMulticallSmartAccount(calls, from, txparams) {
|
|
452
441
|
try {
|
|
453
|
-
const zerodevPaymaster =
|
|
454
|
-
chain: getChain(this.config.chainId),
|
|
455
|
-
transport: http(this.getZeroDevRPC()),
|
|
456
|
-
});
|
|
442
|
+
const zerodevPaymaster = this.getOrCreatePaymaster();
|
|
457
443
|
const kernelClient = createKernelAccountClient({
|
|
458
444
|
account: from,
|
|
459
445
|
chain: getChain(this.config.chainId),
|
|
@@ -513,6 +499,15 @@ export class ContractBase extends Instantiable {
|
|
|
513
499
|
throw new ContractSimulationError(`Error Simulating Multicalls - ${err}`);
|
|
514
500
|
}
|
|
515
501
|
}
|
|
502
|
+
getOrCreatePaymaster() {
|
|
503
|
+
if (!this._zeroDevPaymaster) {
|
|
504
|
+
this._zeroDevPaymaster = createZeroDevPaymasterClient({
|
|
505
|
+
chain: getChain(this.config.chainId),
|
|
506
|
+
transport: http(this.getZeroDevRPC()),
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
return this._zeroDevPaymaster;
|
|
510
|
+
}
|
|
516
511
|
getZeroDevRPC() {
|
|
517
512
|
return `https://rpc.zerodev.app/api/v3/${this.config.zeroDevProjectId}/chain/${this.config.chainId}`;
|
|
518
513
|
}
|