Skip to content

Commit

Permalink
chore: add support for more zksync chains
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalavedra committed Feb 3, 2025
1 parent b34c0ed commit 8fa76b5
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfort/openfort-js",
"version": "0.8.20",
"version": "0.8.21",
"author": "Openfort (https://www.openfort.xyz)",
"bugs": "https://github.com/openfort-xyz/openfort-js/issues",
"repository": "openfort-xyz/openfort-js.git",
Expand Down
30 changes: 30 additions & 0 deletions sdk/src/chains/11124.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Chain } from 'chains';

const chain: Chain = {
chainId: 11124,
name: 'Abstract Testnet',
nativeCurrency: {
decimals: 18,
name: 'ETH',
symbol: 'ETH',
},
rpc: ['https://api.testnet.abs.xyz'],
explorers: [
{
name: 'Etherscan',
url: 'https://sepolia.abscan.org',
standard: 'EIP3091',
},
{
name: 'Abstract Explorer',
url: 'https://explorer.testnet.abs.xyz',
standard: 'EIP3091',
},
],
testnet: true,
shortName: 'abstract-testnet',
slug: 'abstract-testnet',
chain: 'abstract-testnet',
};

export default chain;
30 changes: 30 additions & 0 deletions sdk/src/chains/2741.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Chain } from 'chains';

const chain: Chain = {
chainId: 2741,
name: 'Abstract',
nativeCurrency: {
decimals: 18,
name: 'ETH',
symbol: 'ETH',
},
rpc: ['https://api.mainnet.abs.xyz'],
explorers: [
{
name: 'Etherscan',
url: 'https://abscan.org',
standard: 'EIP3091',
},
{
name: 'Abstract Explorer',
url: 'https://explorer.mainnet.abs.xyz',
standard: 'EIP3091',
},
],
shortName: 'abstract',
slug: 'abstract',
chain: '',
testnet: false,
};

export default chain;
9 changes: 9 additions & 0 deletions sdk/src/chains/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import zksyncSepolia from './300';
import zksync from './324';

import abstract from './2741';
import abstractTestnet from './11124';

import bnb from './56';
import bnbTestnet from './97';

Expand Down Expand Up @@ -126,10 +129,16 @@ export const chainMap: { [key: number]: Chain } = {
247253: saakuruTestnet,
// eslint-disable-next-line @typescript-eslint/naming-convention
7225878: saakuruMainnet,
// eslint-disable-next-line @typescript-eslint/naming-convention
2741: abstract,
// eslint-disable-next-line @typescript-eslint/naming-convention
11124: abstractTestnet,
};

export default [
ethereum,
abstract,
abstractTestnet,
zksyncSepolia,
zksync,
bnb,
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/evm/registerSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ export const registerSession = async ({

if (openfortTransaction?.nextAction?.payload?.signableHash) {
let signature;
// zkSync and Sophon test need a different signature
if ([300, 531050104, 324, 50104].includes(account.chainId)) {
// zkSync based chains need a different signature
if ([300, 531050104, 324, 50104, 2741, 11124].includes(account.chainId)) {
signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash, false, false);
} else {
signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash);
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/evm/revokeSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export const revokeSession = async ({

if (openfortTransaction?.nextAction?.payload?.signableHash) {
let signature;
// zkSync and Sophon test need a different signature
if ([300, 531050104, 324, 50104].includes(account.chainId)) {
// zkSync based chains need a different signature
if ([300, 531050104, 324, 50104, 2741, 11124].includes(account.chainId)) {
signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash, false, false);
} else {
signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash);
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/evm/sendCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export const sendCalls = async ({
let response: ResponseResponse;
if (openfortTransaction?.nextAction?.payload?.signableHash) {
let signature;
// zkSync and Sophon test need a different signature
if ([300, 531050104, 324, 50104].includes(account.chainId)) {
// zkSync based chains need a different signature
if ([300, 531050104, 324, 50104, 2741, 11124].includes(account.chainId)) {
signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash, false, false);
} else {
signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash);
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/evm/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export const sendTransaction = async ({
let response: ResponseResponse;
if (openfortTransaction?.nextAction?.payload?.signableHash) {
let signature;
// zkSync and Sophon test need a different signature
if ([300, 531050104, 324, 50104].includes(account.chainId)) {
// zkSync based chains need a different signature
if ([300, 531050104, 324, 50104, 2741, 11124].includes(account.chainId)) {
signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash, false, false);
} else {
signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash);
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/openfort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ export class Openfort {
const account = Account.fromStorage(this.storage);
if (account && [AccountType.UPGRADEABLE_V5,
AccountType.UPGRADEABLE_V6,
AccountType.ZKSYNC_UPGRADEABLE_V1].includes(account.type as AccountType)) {
AccountType.ZKSYNC_UPGRADEABLE_V1,
AccountType.ZKSYNC_UPGRADEABLE_V2].includes(account.type as AccountType)) {
const updatedDomain: TypedDataDomain = {
name: 'Openfort',
version: '0.5',
Expand Down
1 change: 1 addition & 0 deletions sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export enum AccountType {
UPGRADEABLE_V5 = 'Upgradeable_v05',
UPGRADEABLE_V6 = 'Upgradeable_v06',
ZKSYNC_UPGRADEABLE_V1 = 'zksync_upgradeable_v1',
ZKSYNC_UPGRADEABLE_V2 = 'zksync_upgradeable_v2',
}

export enum AuthType {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const VERSION = '0.8.20';
export const VERSION = '0.8.21';
export const PACKAGE = '@openfort/openfort-js';

0 comments on commit 8fa76b5

Please sign in to comment.