@0xsequence/account 2.2.4 → 2.2.6

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.
@@ -442,13 +442,46 @@ class Account {
442
442
  return bundles;
443
443
  }
444
444
  async predecorateTransactions(txs, status, chainId) {
445
+ txs = Array.isArray(txs) ? txs : [txs];
445
446
  // if onchain wallet config is not up to date
446
447
  // then we should append an extra transaction that updates it
447
448
  // to the latest "lazy" state
448
449
  if (status.onChain.imageHash !== status.imageHash) {
449
450
  const wallet = this.walletForStatus(chainId, status);
450
451
  const updateConfig = await wallet.buildUpdateConfigurationTransaction(status.config);
451
- return [Array.isArray(txs) ? txs : [txs], updateConfig.transactions].flat();
452
+ txs = [...txs, ...updateConfig.transactions];
453
+ }
454
+
455
+ // On immutable chains, we add the WalletProxyHook
456
+ const {
457
+ proxyImplementationHook
458
+ } = this.contexts[status.config.version];
459
+ if (proxyImplementationHook && (chainId === network.ChainId.IMMUTABLE_ZKEVM || chainId === network.ChainId.IMMUTABLE_ZKEVM_TESTNET)) {
460
+ const provider = this.providerFor(chainId);
461
+ if (provider) {
462
+ const hook = new ethers.ethers.Contract(this.address, abi.walletContracts.walletProxyHook.abi, provider);
463
+ let implementation;
464
+ try {
465
+ implementation = await hook.PROXY_getImplementation();
466
+ } catch (e) {
467
+ // Handle below
468
+ console.log('Error getting implementation address', e);
469
+ }
470
+ if (!implementation || implementation === ethers.ethers.ZeroAddress) {
471
+ console.log('Adding wallet proxy hook');
472
+ const hooksInterface = new ethers.ethers.Interface(abi.walletContracts.moduleHooks.abi);
473
+ const tx = {
474
+ to: this.address,
475
+ data: hooksInterface.encodeFunctionData(hooksInterface.getFunction('addHook'), ['0x90611127', proxyImplementationHook]),
476
+ gasLimit: 50000,
477
+ // Expected ~28k gas. Buffer added
478
+ delegateCall: false,
479
+ revertOnError: false,
480
+ value: 0
481
+ };
482
+ txs = [tx, ...txs];
483
+ }
484
+ }
452
485
  }
453
486
  return txs;
454
487
  }
@@ -442,13 +442,46 @@ class Account {
442
442
  return bundles;
443
443
  }
444
444
  async predecorateTransactions(txs, status, chainId) {
445
+ txs = Array.isArray(txs) ? txs : [txs];
445
446
  // if onchain wallet config is not up to date
446
447
  // then we should append an extra transaction that updates it
447
448
  // to the latest "lazy" state
448
449
  if (status.onChain.imageHash !== status.imageHash) {
449
450
  const wallet = this.walletForStatus(chainId, status);
450
451
  const updateConfig = await wallet.buildUpdateConfigurationTransaction(status.config);
451
- return [Array.isArray(txs) ? txs : [txs], updateConfig.transactions].flat();
452
+ txs = [...txs, ...updateConfig.transactions];
453
+ }
454
+
455
+ // On immutable chains, we add the WalletProxyHook
456
+ const {
457
+ proxyImplementationHook
458
+ } = this.contexts[status.config.version];
459
+ if (proxyImplementationHook && (chainId === network.ChainId.IMMUTABLE_ZKEVM || chainId === network.ChainId.IMMUTABLE_ZKEVM_TESTNET)) {
460
+ const provider = this.providerFor(chainId);
461
+ if (provider) {
462
+ const hook = new ethers.ethers.Contract(this.address, abi.walletContracts.walletProxyHook.abi, provider);
463
+ let implementation;
464
+ try {
465
+ implementation = await hook.PROXY_getImplementation();
466
+ } catch (e) {
467
+ // Handle below
468
+ console.log('Error getting implementation address', e);
469
+ }
470
+ if (!implementation || implementation === ethers.ethers.ZeroAddress) {
471
+ console.log('Adding wallet proxy hook');
472
+ const hooksInterface = new ethers.ethers.Interface(abi.walletContracts.moduleHooks.abi);
473
+ const tx = {
474
+ to: this.address,
475
+ data: hooksInterface.encodeFunctionData(hooksInterface.getFunction('addHook'), ['0x90611127', proxyImplementationHook]),
476
+ gasLimit: 50000,
477
+ // Expected ~28k gas. Buffer added
478
+ delegateCall: false,
479
+ revertOnError: false,
480
+ value: 0
481
+ };
482
+ txs = [tx, ...txs];
483
+ }
484
+ }
452
485
  }
453
486
  return txs;
454
487
  }
@@ -438,13 +438,46 @@ class Account {
438
438
  return bundles;
439
439
  }
440
440
  async predecorateTransactions(txs, status, chainId) {
441
+ txs = Array.isArray(txs) ? txs : [txs];
441
442
  // if onchain wallet config is not up to date
442
443
  // then we should append an extra transaction that updates it
443
444
  // to the latest "lazy" state
444
445
  if (status.onChain.imageHash !== status.imageHash) {
445
446
  const wallet = this.walletForStatus(chainId, status);
446
447
  const updateConfig = await wallet.buildUpdateConfigurationTransaction(status.config);
447
- return [Array.isArray(txs) ? txs : [txs], updateConfig.transactions].flat();
448
+ txs = [...txs, ...updateConfig.transactions];
449
+ }
450
+
451
+ // On immutable chains, we add the WalletProxyHook
452
+ const {
453
+ proxyImplementationHook
454
+ } = this.contexts[status.config.version];
455
+ if (proxyImplementationHook && (chainId === ChainId.IMMUTABLE_ZKEVM || chainId === ChainId.IMMUTABLE_ZKEVM_TESTNET)) {
456
+ const provider = this.providerFor(chainId);
457
+ if (provider) {
458
+ const hook = new ethers.Contract(this.address, walletContracts.walletProxyHook.abi, provider);
459
+ let implementation;
460
+ try {
461
+ implementation = await hook.PROXY_getImplementation();
462
+ } catch (e) {
463
+ // Handle below
464
+ console.log('Error getting implementation address', e);
465
+ }
466
+ if (!implementation || implementation === ethers.ZeroAddress) {
467
+ console.log('Adding wallet proxy hook');
468
+ const hooksInterface = new ethers.Interface(walletContracts.moduleHooks.abi);
469
+ const tx = {
470
+ to: this.address,
471
+ data: hooksInterface.encodeFunctionData(hooksInterface.getFunction('addHook'), ['0x90611127', proxyImplementationHook]),
472
+ gasLimit: 50000,
473
+ // Expected ~28k gas. Buffer added
474
+ delegateCall: false,
475
+ revertOnError: false,
476
+ value: 0
477
+ };
478
+ txs = [tx, ...txs];
479
+ }
480
+ }
448
481
  }
449
482
  return txs;
450
483
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/account",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "tools for migrating sequence wallets to new versions",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/account",
6
6
  "source": "src/index.ts",
@@ -12,21 +12,21 @@
12
12
  "ethers": ">=6"
13
13
  },
14
14
  "dependencies": {
15
- "@0xsequence/abi": "2.2.4",
16
- "@0xsequence/core": "2.2.4",
17
- "@0xsequence/migration": "2.2.4",
18
- "@0xsequence/network": "2.2.4",
19
- "@0xsequence/relayer": "2.2.4",
20
- "@0xsequence/sessions": "2.2.4",
21
- "@0xsequence/utils": "2.2.4",
22
- "@0xsequence/wallet": "2.2.4"
15
+ "@0xsequence/core": "2.2.6",
16
+ "@0xsequence/relayer": "2.2.6",
17
+ "@0xsequence/network": "2.2.6",
18
+ "@0xsequence/sessions": "2.2.6",
19
+ "@0xsequence/migration": "2.2.6",
20
+ "@0xsequence/wallet": "2.2.6",
21
+ "@0xsequence/abi": "2.2.6",
22
+ "@0xsequence/utils": "2.2.6"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
26
26
  "ethers": "6.13.4",
27
27
  "nyc": "^15.1.0",
28
- "@0xsequence/signhub": "2.2.4",
29
- "@0xsequence/tests": "2.2.4"
28
+ "@0xsequence/tests": "2.2.6",
29
+ "@0xsequence/signhub": "2.2.6"
30
30
  },
31
31
  "files": [
32
32
  "src",
package/src/account.ts CHANGED
@@ -402,13 +402,46 @@ export class Account {
402
402
  status: AccountStatus,
403
403
  chainId: ethers.BigNumberish
404
404
  ): Promise<commons.transaction.Transactionish> {
405
+ txs = Array.isArray(txs) ? txs : [txs]
405
406
  // if onchain wallet config is not up to date
406
407
  // then we should append an extra transaction that updates it
407
408
  // to the latest "lazy" state
408
409
  if (status.onChain.imageHash !== status.imageHash) {
409
410
  const wallet = this.walletForStatus(chainId, status)
410
411
  const updateConfig = await wallet.buildUpdateConfigurationTransaction(status.config)
411
- return [Array.isArray(txs) ? txs : [txs], updateConfig.transactions].flat()
412
+ txs = [...txs, ...updateConfig.transactions]
413
+ }
414
+
415
+ // On immutable chains, we add the WalletProxyHook
416
+ const { proxyImplementationHook } = this.contexts[status.config.version]
417
+ if (proxyImplementationHook && (chainId === ChainId.IMMUTABLE_ZKEVM || chainId === ChainId.IMMUTABLE_ZKEVM_TESTNET)) {
418
+ const provider = this.providerFor(chainId)
419
+ if (provider) {
420
+ const hook = new ethers.Contract(this.address, walletContracts.walletProxyHook.abi, provider)
421
+ let implementation
422
+ try {
423
+ implementation = await hook.PROXY_getImplementation()
424
+ } catch (e) {
425
+ // Handle below
426
+ console.log('Error getting implementation address', e)
427
+ }
428
+ if (!implementation || implementation === ethers.ZeroAddress) {
429
+ console.log('Adding wallet proxy hook')
430
+ const hooksInterface = new ethers.Interface(walletContracts.moduleHooks.abi)
431
+ const tx: commons.transaction.Transaction = {
432
+ to: this.address,
433
+ data: hooksInterface.encodeFunctionData(hooksInterface.getFunction('addHook')!, [
434
+ '0x90611127',
435
+ proxyImplementationHook
436
+ ]),
437
+ gasLimit: 50000, // Expected ~28k gas. Buffer added
438
+ delegateCall: false,
439
+ revertOnError: false,
440
+ value: 0
441
+ }
442
+ txs = [tx, ...txs]
443
+ }
444
+ }
412
445
  }
413
446
 
414
447
  return txs