Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Canary
on:
pull_request:
branches:
- 'master'
- "master"
merge_group:
types: [checks_requested]

Expand All @@ -23,10 +23,10 @@ jobs:
fetch-tags: true

- name: Setup node
uses: actions/setup-node@v6
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'yarn'
cache: "yarn"

- name: Install dependencies
run: |
Expand Down Expand Up @@ -60,10 +60,10 @@ jobs:
fetch-tags: true

- name: Setup node
uses: actions/setup-node@v6
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'yarn'
cache: "yarn"

- name: Install dependencies
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ function getPrototypeChain<T extends BaseExtension<string>>(instance: T) {
let currentProto = Object.getPrototypeOf(instance);
const protos = [currentProto];

while (currentProto !== BaseModule.prototype) {
while (currentProto && currentProto !== BaseModule.prototype) {
currentProto = Object.getPrototypeOf(currentProto);

protos.push(currentProto);

}

return protos;
Expand Down
24 changes: 24 additions & 0 deletions packages/@magic-sdk/provider/src/modules/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
ConnectWithUIOptions,
ConnectWithUiEvents,
ShowUIPromiEvents,
Sign7702AuthorizationRequest,
Sign7702AuthorizationResponse,
} from '@magic-sdk/types';
import { BaseModule } from './base-module';
import { createJsonRpcRequestPayload } from '../core/json-rpc';
Expand Down Expand Up @@ -76,4 +78,26 @@ export class WalletModule extends BaseModule {
createJsonRpcRequestPayload(MagicPayloadMethod.SendGaslessTransaction, [address, transaction]),
);
}

/**
* Sign an EIP-7702 authorization to delegate the EOA to a smart contract implementation.
* This enables account abstraction features for externally owned accounts.
*
* @param params - The authorization parameters including contractAddress, chainId, and optional nonce
* @returns Promise resolving to the signed authorization with signature components (v, r, s)
*
* @example
* ```typescript
* const authorization = await magic.wallet.sign7702Authorization({
* contractAddress: '0x000000004F43C49e93C970E84001853a70923B03',
* chainId: 1,
* nonce: 0
* });
* ```
*/
public sign7702Authorization(params: Sign7702AuthorizationRequest) {
return this.request<Sign7702AuthorizationResponse>(
createJsonRpcRequestPayload(MagicPayloadMethod.Sign7702Authorization, [params]),
);
}
}
1 change: 1 addition & 0 deletions packages/@magic-sdk/types/src/core/json-rpc-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export enum MagicPayloadMethod {
EnableMFA = 'magic_auth_enable_mfa_flow',
DisableMFA = 'magic_auth_disable_mfa_flow',
GetMultichainPublicAddress = 'magic_get_multichain_public_address',
Sign7702Authorization = 'magic_wallet_sign_7702_authorization',
}

// Methods to not route if connected to third party wallet
Expand Down
60 changes: 60 additions & 0 deletions packages/@magic-sdk/types/src/modules/wallet-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,63 @@ export interface GaslessTransactionRequest {
export enum WalletEventOnReceived {
WalletInfoFetched = 'Wallet/wallet-info-fetched',
}

/**
* Request parameters for EIP-7702 authorization signing
*/
export interface Sign7702AuthorizationRequest {
/**
* The smart contract implementation address the EOA delegates to
*/
contractAddress: string;

/**
* The chain ID for the network (use 0 for universal cross-chain authorization)
*/
chainId: number;

/**
* The nonce for the EOA account (transaction count)
*/
nonce?: number;
}

/**
* Response from EIP-7702 authorization signing
*/
export interface Sign7702AuthorizationResponse {
/**
* The contract address that was authorized
*/
contractAddress: string;

/**
* The chain ID for the authorization
*/
chainId: number;

/**
* The nonce used in the authorization
*/
nonce: number;

/**
* The v component of the signature (recovery id)
*/
v: number;

/**
* The r component of the signature
*/
r: string;

/**
* The s component of the signature
*/
s: string;

/**
* Optional: Full signature as hex string
*/
signature?: string;
}
4 changes: 2 additions & 2 deletions packages/magic-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
]
},
"dependencies": {
"@magic-sdk/provider": "^31.2.0",
"@magic-sdk/types": "^25.2.0",
"@magic-sdk/provider": "^33.0.0",
"@magic-sdk/types": "^27.0.0",
"localforage": "^1.7.4"
},
"gitHead": "1ef062ea699d48d5e9a9375a93b7c147632b05ca"
Expand Down
44 changes: 22 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,20 @@ __metadata:
languageName: unknown
linkType: soft

"@magic-sdk/provider@^33.0.0, @magic-sdk/provider@workspace:packages/@magic-sdk/provider":
version: 0.0.0-use.local
resolution: "@magic-sdk/provider@workspace:packages/@magic-sdk/provider"
dependencies:
"@babel/plugin-transform-modules-commonjs": ^7.9.6
"@magic-sdk/types": ^25.2.0
eventemitter3: ^4.0.4
localforage: ^1.7.4
tslib: ^2.3.1
peerDependencies:
localforage: ^1.7.4
languageName: unknown
linkType: soft

"@magic-sdk/provider@npm:^29.5.0":
version: 29.5.0
resolution: "@magic-sdk/provider@npm:29.5.0"
Expand All @@ -3342,20 +3356,6 @@ __metadata:
languageName: node
linkType: hard

"@magic-sdk/provider@workspace:packages/@magic-sdk/provider":
version: 0.0.0-use.local
resolution: "@magic-sdk/provider@workspace:packages/@magic-sdk/provider"
dependencies:
"@babel/plugin-transform-modules-commonjs": ^7.9.6
"@magic-sdk/types": ^25.2.0
eventemitter3: ^4.0.4
localforage: ^1.7.4
tslib: ^2.3.1
peerDependencies:
localforage: ^1.7.4
languageName: unknown
linkType: soft

"@magic-sdk/react-native-bare@npm:^32.2.0":
version: 32.2.0
resolution: "@magic-sdk/react-native-bare@npm:32.2.0"
Expand Down Expand Up @@ -3491,6 +3491,12 @@ __metadata:
languageName: unknown
linkType: soft

"@magic-sdk/types@^27.0.0, @magic-sdk/types@workspace:packages/@magic-sdk/types":
version: 0.0.0-use.local
resolution: "@magic-sdk/types@workspace:packages/@magic-sdk/types"
languageName: unknown
linkType: soft

"@magic-sdk/types@npm:^24.21.0, @magic-sdk/types@npm:^24.22.0":
version: 24.22.0
resolution: "@magic-sdk/types@npm:24.22.0"
Expand All @@ -3505,12 +3511,6 @@ __metadata:
languageName: node
linkType: hard

"@magic-sdk/types@workspace:packages/@magic-sdk/types":
version: 0.0.0-use.local
resolution: "@magic-sdk/types@workspace:packages/@magic-sdk/types"
languageName: unknown
linkType: soft

"@motionone/animation@npm:^10.15.1, @motionone/animation@npm:^10.18.0":
version: 10.18.0
resolution: "@motionone/animation@npm:10.18.0"
Expand Down Expand Up @@ -14518,8 +14518,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "magic-sdk@workspace:packages/magic-sdk"
dependencies:
"@magic-sdk/provider": ^31.2.0
"@magic-sdk/types": ^25.2.0
"@magic-sdk/provider": ^33.0.0
"@magic-sdk/types": ^27.0.0
localforage: ^1.7.4
languageName: unknown
linkType: soft
Expand Down