zksync-sso 0.0.0-beta.13 → 0.0.0-beta.14
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/dist/_cjs/client/ecdsa/account.js +38 -0
- package/dist/_cjs/client/ecdsa/account.js.map +1 -0
- package/dist/_cjs/client/ecdsa/actions/account.js +83 -0
- package/dist/_cjs/client/ecdsa/actions/account.js.map +1 -0
- package/dist/_cjs/client/ecdsa/client.js +35 -0
- package/dist/_cjs/client/ecdsa/client.js.map +1 -0
- package/dist/_cjs/client/ecdsa/decorators/ecdsa.js +22 -0
- package/dist/_cjs/client/ecdsa/decorators/ecdsa.js.map +1 -0
- package/dist/_cjs/client/ecdsa/decorators/wallet.js +47 -0
- package/dist/_cjs/client/ecdsa/decorators/wallet.js.map +1 -0
- package/dist/_cjs/client/ecdsa/index.js +23 -0
- package/dist/_cjs/client/ecdsa/index.js.map +1 -0
- package/dist/_cjs/client/ecdsa/types.js +63 -0
- package/dist/_cjs/client/ecdsa/types.js.map +1 -0
- package/dist/_cjs/client/index.js +7 -4
- package/dist/_cjs/client/index.js.map +1 -1
- package/dist/_esm/client/ecdsa/account.js +35 -0
- package/dist/_esm/client/ecdsa/account.js.map +1 -0
- package/dist/_esm/client/ecdsa/actions/account.js +81 -0
- package/dist/_esm/client/ecdsa/actions/account.js.map +1 -0
- package/dist/_esm/client/ecdsa/client.js +32 -0
- package/dist/_esm/client/ecdsa/client.js.map +1 -0
- package/dist/_esm/client/ecdsa/decorators/ecdsa.js +19 -0
- package/dist/_esm/client/ecdsa/decorators/ecdsa.js.map +1 -0
- package/dist/_esm/client/ecdsa/decorators/wallet.js +47 -0
- package/dist/_esm/client/ecdsa/decorators/wallet.js.map +1 -0
- package/dist/_esm/client/ecdsa/index.js +7 -0
- package/dist/_esm/client/ecdsa/index.js.map +1 -0
- package/dist/_esm/client/ecdsa/types.js +61 -0
- package/dist/_esm/client/ecdsa/types.js.map +1 -0
- package/dist/_esm/client/index.js +1 -0
- package/dist/_esm/client/index.js.map +1 -1
- package/dist/_types/client/ecdsa/account.d.ts +14 -0
- package/dist/_types/client/ecdsa/account.d.ts.map +1 -0
- package/dist/_types/client/ecdsa/actions/account.d.ts +38 -0
- package/dist/_types/client/ecdsa/actions/account.d.ts.map +1 -0
- package/dist/_types/client/ecdsa/client.d.ts +25 -0
- package/dist/_types/client/ecdsa/client.d.ts.map +1 -0
- package/dist/_types/client/ecdsa/decorators/ecdsa.d.ts +16 -0
- package/dist/_types/client/ecdsa/decorators/ecdsa.d.ts.map +1 -0
- package/dist/_types/client/ecdsa/decorators/wallet.d.ts +5 -0
- package/dist/_types/client/ecdsa/decorators/wallet.d.ts.map +1 -0
- package/dist/_types/client/ecdsa/index.d.ts +7 -0
- package/dist/_types/client/ecdsa/index.d.ts.map +1 -0
- package/dist/_types/client/ecdsa/types.d.ts +10 -0
- package/dist/_types/client/ecdsa/types.d.ts.map +1 -0
- package/dist/_types/client/index.d.ts +1 -0
- package/dist/_types/client/index.d.ts.map +1 -1
- package/dist/_types/client-auth-server/Signer.d.ts +410 -410
- package/dist/_types/client-auth-server/WalletProvider.d.ts +410 -410
- package/package.json +6 -1
- package/src/client/ecdsa/account.ts +56 -0
- package/src/client/ecdsa/actions/account.ts +145 -0
- package/src/client/ecdsa/client.ts +90 -0
- package/src/client/ecdsa/decorators/ecdsa.ts +32 -0
- package/src/client/ecdsa/decorators/wallet.ts +73 -0
- package/src/client/ecdsa/index.ts +6 -0
- package/src/client/ecdsa/types.ts +108 -0
- package/src/client/index.ts +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toEcdsaAccount = toEcdsaAccount;
|
|
4
|
+
const accounts_1 = require("viem/accounts");
|
|
5
|
+
const zksync_1 = require("viem/zksync");
|
|
6
|
+
const getEip712Domain_js_1 = require("../utils/getEip712Domain.js");
|
|
7
|
+
const types_js_1 = require("./types.js");
|
|
8
|
+
async function toEcdsaAccount(parameters) {
|
|
9
|
+
const { address, owner } = parameters;
|
|
10
|
+
const localOwner = await (0, types_js_1.toOwner)({ owner, address });
|
|
11
|
+
const account = (0, accounts_1.toAccount)({
|
|
12
|
+
address,
|
|
13
|
+
async signMessage({ message }) {
|
|
14
|
+
return localOwner.signMessage({ message });
|
|
15
|
+
},
|
|
16
|
+
async signTransaction(transaction) {
|
|
17
|
+
const signableTransaction = {
|
|
18
|
+
...transaction,
|
|
19
|
+
from: this.address,
|
|
20
|
+
type: "eip712",
|
|
21
|
+
};
|
|
22
|
+
const eip712DomainAndMessage = (0, getEip712Domain_js_1.getEip712Domain)(signableTransaction);
|
|
23
|
+
const signature = await localOwner.signTypedData(eip712DomainAndMessage);
|
|
24
|
+
return (0, zksync_1.serializeTransaction)({
|
|
25
|
+
...signableTransaction,
|
|
26
|
+
customSignature: signature,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
async signTypedData(typedData) {
|
|
30
|
+
return localOwner.signTypedData(typedData);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
...account,
|
|
35
|
+
source: "ssoEcdsaAccount",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/client/ecdsa/account.ts"],"names":[],"mappings":";;AAmBA,wCAoCC;AArDD,4CAA0C;AAC1C,wCAA6F;AAE7F,oEAA8D;AAC9D,yCAAkD;AAa3C,KAAK,UAAU,cAAc,CAClC,UAAoC;IAEpC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;IAEtC,MAAM,UAAU,GAAG,MAAM,IAAA,kBAAO,EAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAErD,MAAM,OAAO,GAAG,IAAA,oBAAS,EAAC;QACxB,OAAO;QACP,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;YAC3B,OAAO,UAAU,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,WAAW;YAC/B,MAAM,mBAAmB,GAAG;gBAC1B,GAAG,WAAW;gBACd,IAAI,EAAE,IAAI,CAAC,OAAQ;gBACnB,IAAI,EAAE,QAAQ;aACwB,CAAC;YAEzC,MAAM,sBAAsB,GAAG,IAAA,oCAAe,EAAC,mBAAmB,CAAC,CAAC;YACpE,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC;YAEzE,OAAO,IAAA,6BAAoB,EAAC;gBAC1B,GAAG,mBAAmB;gBACtB,eAAe,EAAE,SAAS;aAC3B,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,SAAS;YAC3B,OAAO,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,iBAAiB;KACV,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchAccount = exports.deployAccount = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const actions_1 = require("viem/actions");
|
|
6
|
+
const zksync_1 = require("viem/zksync");
|
|
7
|
+
const AAFactory_js_1 = require("../../../abi/AAFactory.js");
|
|
8
|
+
const encoding_js_1 = require("../../../utils/encoding.js");
|
|
9
|
+
const helpers_js_1 = require("../../../utils/helpers.js");
|
|
10
|
+
const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
11
|
+
const deployAccount = async (client, args) => {
|
|
12
|
+
if (!args.salt) {
|
|
13
|
+
args.salt = crypto.getRandomValues(new Uint8Array(32));
|
|
14
|
+
}
|
|
15
|
+
if (args.prefix && args.prefix.length > 12)
|
|
16
|
+
throw new Error("prefix must not be longer than 12");
|
|
17
|
+
const uniqueId = (0, viem_1.concat)([(0, viem_1.toHex)(args.prefix || "", { size: 12 }), args.owner]);
|
|
18
|
+
const encodedSessionKeyModuleData = (0, encoding_js_1.encodeModuleData)({
|
|
19
|
+
address: args.contracts.session,
|
|
20
|
+
parameters: args.initialSession ? (0, encoding_js_1.encodeSession)(args.initialSession) : "0x",
|
|
21
|
+
});
|
|
22
|
+
let deployProxyArgs = {
|
|
23
|
+
account: client.account,
|
|
24
|
+
chain: client.chain,
|
|
25
|
+
address: args.contracts.accountFactory,
|
|
26
|
+
abi: AAFactory_js_1.AAFactoryAbi,
|
|
27
|
+
functionName: "deployProxySsoAccount",
|
|
28
|
+
args: [
|
|
29
|
+
uniqueId,
|
|
30
|
+
[encodedSessionKeyModuleData],
|
|
31
|
+
[args.owner],
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
if (args.paymaster) {
|
|
35
|
+
deployProxyArgs = {
|
|
36
|
+
...deployProxyArgs,
|
|
37
|
+
paymaster: args.paymaster.address,
|
|
38
|
+
paymasterInput: args.paymaster.paymasterInput ?? (0, zksync_1.getGeneralPaymasterInput)({ innerInput: "0x" }),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const transactionHash = await (0, actions_1.writeContract)(client, deployProxyArgs);
|
|
42
|
+
if (args.onTransactionSent) {
|
|
43
|
+
(0, helpers_js_1.noThrow)(() => args.onTransactionSent?.(transactionHash));
|
|
44
|
+
}
|
|
45
|
+
const transactionReceipt = await (0, actions_1.waitForTransactionReceipt)(client, { hash: transactionHash });
|
|
46
|
+
if (transactionReceipt.status !== "success")
|
|
47
|
+
throw new Error("Account deployment transaction reverted");
|
|
48
|
+
const accountCreatedEvent = (0, viem_1.parseEventLogs)({ abi: AAFactory_js_1.AAFactoryAbi, logs: transactionReceipt.logs })
|
|
49
|
+
.find((log) => log && log.eventName === "AccountCreated");
|
|
50
|
+
if (!accountCreatedEvent) {
|
|
51
|
+
throw new Error("No contract address in transaction receipt");
|
|
52
|
+
}
|
|
53
|
+
const { accountAddress } = accountCreatedEvent.args;
|
|
54
|
+
return {
|
|
55
|
+
address: (0, viem_1.getAddress)(accountAddress),
|
|
56
|
+
transactionReceipt: transactionReceipt,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.deployAccount = deployAccount;
|
|
60
|
+
const fetchAccount = async (client, args) => {
|
|
61
|
+
if (!args.contracts.accountFactory)
|
|
62
|
+
throw new Error("Account factory address is not set");
|
|
63
|
+
if (args.prefix && args.prefix.length > 12)
|
|
64
|
+
throw new Error("prefix must not be longer than 12");
|
|
65
|
+
const uniqueId = (0, viem_1.concat)([(0, viem_1.toHex)(args.prefix || "", { size: 12 }), args.owner]);
|
|
66
|
+
const accountId = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["bytes32", "address"], [uniqueId, client.account.address]));
|
|
67
|
+
if (!accountId)
|
|
68
|
+
throw new Error("No account ID provided");
|
|
69
|
+
const accountAddress = await (0, actions_1.readContract)(client, {
|
|
70
|
+
abi: AAFactory_js_1.AAFactoryAbi,
|
|
71
|
+
address: args.contracts.accountFactory,
|
|
72
|
+
functionName: "accountMappings",
|
|
73
|
+
args: [accountId],
|
|
74
|
+
});
|
|
75
|
+
if (!accountAddress || accountAddress == NULL_ADDRESS)
|
|
76
|
+
throw new Error(`No account found for ID: ${accountId}`);
|
|
77
|
+
return {
|
|
78
|
+
address: accountAddress,
|
|
79
|
+
owner: args.owner,
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
exports.fetchAccount = fetchAccount;
|
|
83
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../../src/client/ecdsa/actions/account.ts"],"names":[],"mappings":";;;AACA,+BAA0F;AAC1F,0CAAsF;A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});
|
|
3
|
+
exports.createZksyncEcdsaClient = createZksyncEcdsaClient;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const zksync_1 = require("viem/zksync");
|
|
6
|
+
const account_js_1 = require("./account.js");
|
|
7
|
+
const ecdsa_js_1 = require("./decorators/ecdsa.js");
|
|
8
|
+
const wallet_js_1 = require("./decorators/wallet.js");
|
|
9
|
+
async function createZksyncEcdsaClient(_parameters) {
|
|
10
|
+
const parameters = {
|
|
11
|
+
..._parameters,
|
|
12
|
+
address: (0, viem_1.getAddress)(_parameters.address),
|
|
13
|
+
key: _parameters.key || "zksync-sso-ecdsa-wallet",
|
|
14
|
+
name: _parameters.name || "ZKsync SSO ECDSA Client",
|
|
15
|
+
};
|
|
16
|
+
const account = await (0, account_js_1.toEcdsaAccount)({
|
|
17
|
+
address: parameters.address,
|
|
18
|
+
owner: parameters.owner,
|
|
19
|
+
});
|
|
20
|
+
const client = (0, viem_1.createClient)({
|
|
21
|
+
...parameters,
|
|
22
|
+
account,
|
|
23
|
+
type: "walletClient",
|
|
24
|
+
})
|
|
25
|
+
.extend(() => ({
|
|
26
|
+
contracts: parameters.contracts,
|
|
27
|
+
}))
|
|
28
|
+
.extend(viem_1.publicActions)
|
|
29
|
+
.extend(viem_1.walletActions)
|
|
30
|
+
.extend((0, zksync_1.eip712WalletActions)())
|
|
31
|
+
.extend(ecdsa_js_1.zksyncSsoEcdsaActions)
|
|
32
|
+
.extend(wallet_js_1.zksyncSsoEcdsaWalletActions);
|
|
33
|
+
return client;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/client/ecdsa/client.ts"],"names":[],"mappings":";;AASA,0DAmCC;AA5CD,+BAA+R;AAC/R,wCAAkD;AAGlD,6CAA8C;AAC9C,oDAA0F;AAC1F,sDAAqE;AAG9D,KAAK,UAAU,uBAAuB,CAI3C,WAAoE;IAEpE,MAAM,UAAU,GAGZ;QACF,GAAG,WAAW;QACd,OAAO,EAAE,IAAA,iBAAU,EAAC,WAAW,CAAC,OAAO,CAAC;QACxC,GAAG,EAAE,WAAW,CAAC,GAAG,IAAI,yBAAyB;QACjD,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,yBAAyB;KACpD,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,IAAA,2BAAc,EAAC;QACnC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,KAAK,EAAE,UAAU,CAAC,KAAK;KACxB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAA,mBAAY,EAAuC;QAChE,GAAG,UAAU;QACb,OAAO;QACP,IAAI,EAAE,cAAc;KACrB,CAAC;SACC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACb,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAC,CAAC;SACF,MAAM,CAAC,oBAAa,CAAC;SACrB,MAAM,CAAC,oBAAa,CAAC;SACrB,MAAM,CAAC,IAAA,4BAAmB,GAAE,CAAC;SAC7B,MAAM,CAAC,gCAAqB,CAAC;SAC7B,MAAM,CAAC,uCAA2B,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zksyncSsoEcdsaActions = void 0;
|
|
4
|
+
const session_js_1 = require("../../session/actions/session.js");
|
|
5
|
+
const zksyncSsoEcdsaActions = (client) => {
|
|
6
|
+
return {
|
|
7
|
+
createSession: async (args) => {
|
|
8
|
+
return await (0, session_js_1.createSession)(client, {
|
|
9
|
+
...args,
|
|
10
|
+
contracts: client.contracts,
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
revokeSession: async (args) => {
|
|
14
|
+
return await (0, session_js_1.revokeSession)(client, {
|
|
15
|
+
...args,
|
|
16
|
+
contracts: client.contracts,
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.zksyncSsoEcdsaActions = zksyncSsoEcdsaActions;
|
|
22
|
+
//# sourceMappingURL=ecdsa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecdsa.js","sourceRoot":"","sources":["../../../../../src/client/ecdsa/decorators/ecdsa.ts"],"names":[],"mappings":";;;AAEA,iEAG0C;AAQnC,MAAM,qBAAqB,GAAG,CAGnC,MAAsD,EAAE,EAAE;IAC1D,OAAO;QACL,aAAa,EAAE,KAAK,EAAE,IAA0C,EAAE,EAAE;YAClE,OAAO,MAAM,IAAA,0BAAa,EAAC,MAAM,EAAE;gBACjC,GAAG,IAAI;gBACP,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,CAAC;QACD,aAAa,EAAE,KAAK,EAAE,IAA0C,EAAE,EAAE;YAClE,OAAO,MAAM,IAAA,0BAAa,EAAC,MAAM,EAAE;gBACjC,GAAG,IAAI;gBACP,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,qBAAqB,yBAkBhC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zksyncSsoEcdsaWalletActions = zksyncSsoEcdsaWalletActions;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const actions_1 = require("viem/actions");
|
|
6
|
+
const zksync_1 = require("viem/zksync");
|
|
7
|
+
const index_js_1 = require("../../../paymaster/index.js");
|
|
8
|
+
const sendEip712Transaction_js_1 = require("../../session/actions/sendEip712Transaction.js");
|
|
9
|
+
function zksyncSsoEcdsaWalletActions(client) {
|
|
10
|
+
return {
|
|
11
|
+
deployContract: (args) => (0, actions_1.deployContract)(client, args),
|
|
12
|
+
getAddresses: () => (0, actions_1.getAddresses)(client),
|
|
13
|
+
getChainId: () => (0, actions_1.getChainId)(client),
|
|
14
|
+
sendRawTransaction: (args) => (0, actions_1.sendRawTransaction)(client, args),
|
|
15
|
+
sendTransaction: async (args) => {
|
|
16
|
+
const unformattedTx = Object.assign({}, args);
|
|
17
|
+
if ("eip712Meta" in unformattedTx) {
|
|
18
|
+
const eip712Meta = unformattedTx.eip712Meta;
|
|
19
|
+
unformattedTx.gasPerPubdata = eip712Meta.gasPerPubdata ? BigInt(eip712Meta.gasPerPubdata) : undefined;
|
|
20
|
+
unformattedTx.factoryDeps = eip712Meta.factoryDeps;
|
|
21
|
+
unformattedTx.customSignature = eip712Meta.customSignature;
|
|
22
|
+
unformattedTx.paymaster = eip712Meta.paymasterParams?.paymaster;
|
|
23
|
+
unformattedTx.paymasterInput = eip712Meta.paymasterParams?.paymasterInput ? (0, viem_1.bytesToHex)(new Uint8Array(eip712Meta.paymasterParams?.paymasterInput)) : undefined;
|
|
24
|
+
delete unformattedTx.eip712Meta;
|
|
25
|
+
}
|
|
26
|
+
const { chainId: _, ...unformattedTxWithPaymaster } = await (0, index_js_1.getTransactionWithPaymasterData)(client.chain.id, client.account.address, unformattedTx, client.paymasterHandler);
|
|
27
|
+
const formatters = client.chain?.formatters;
|
|
28
|
+
const format = formatters?.transaction?.format || viem_1.formatTransaction;
|
|
29
|
+
const tx = {
|
|
30
|
+
...format(unformattedTxWithPaymaster),
|
|
31
|
+
type: "eip712",
|
|
32
|
+
};
|
|
33
|
+
return await (0, sendEip712Transaction_js_1.sendEip712Transaction)(client, tx);
|
|
34
|
+
},
|
|
35
|
+
signMessage: (args) => (0, actions_1.signMessage)(client, args),
|
|
36
|
+
signTransaction: async (args) => {
|
|
37
|
+
const { chainId: _, ...unformattedTxWithPaymaster } = await (0, index_js_1.getTransactionWithPaymasterData)(client.chain.id, client.account.address, args, client.paymasterHandler);
|
|
38
|
+
return (0, zksync_1.signTransaction)(client, {
|
|
39
|
+
...args,
|
|
40
|
+
unformattedTxWithPaymaster,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
signTypedData: (args) => (0, actions_1.signTypedData)(client, args),
|
|
44
|
+
writeContract: (args) => (0, actions_1.writeContract)(client, args),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../../../src/client/ecdsa/decorators/wallet.ts"],"names":[],"mappings":";;AAYA,kEA4DC;AAxED,+BAA2J;AAC3J,0CAAuI;AACvI,wCAAoG;AAEpG,0DAA8E;AAC9E,6FAAuF;AAOvF,SAAgB,2BAA2B,CAIzC,MAAsD;IACtD,OAAO;QACL,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,wBAAc,EAAC,MAAM,EAAE,IAAI,CAAC;QACtD,YAAY,EAAE,GAAG,EAAE,CAAC,IAAA,sBAAY,EAAC,MAAM,CAAC;QACxC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,oBAAU,EAAC,MAAM,CAAC;QACpC,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,4BAAkB,EAAC,MAAM,EAAE,IAAI,CAAC;QAC9D,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAE9B,MAAM,aAAa,GAAQ,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YAEnD,IAAI,YAAY,IAAI,aAAa,EAAE,CAAC;gBAClC,MAAM,UAAU,GAAG,aAAa,CAAC,UAA8B,CAAC;gBAChE,aAAa,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBACtG,aAAa,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;gBACnD,aAAa,CAA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AAO,IAAA,wBAAe,EAAC,MAAM,EAAE;gBAC7B,GAAG,IAAI;gBACP,0BAA0B;aACpB,CAAC,CAAC;QACZ,CAAC;QACD,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,uBAAa,EAAC,MAAM,EAAE,IAAI,CAAC;QACpD,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,uBAAa,EAAC,MAAM,EAAE,IAAI,CAAC;KACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./account.js"), exports);
|
|
18
|
+
__exportStar(require("./actions/account.js"), exports);
|
|
19
|
+
__exportStar(require("./client.js"), exports);
|
|
20
|
+
__exportStar(require("./decorators/ecdsa.js"), exports);
|
|
21
|
+
__exportStar(require("./decorators/wallet.js"), exports);
|
|
22
|
+
__exportStar(require("./types.js"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/ecdsa/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,uDAAqC;AACrC,8CAA4B;AAC5B,wDAAsC;AACtC,yDAAuC;AACvC,6CAA2B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toOwner = toOwner;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const accounts_1 = require("viem/accounts");
|
|
6
|
+
const actions_1 = require("viem/actions");
|
|
7
|
+
const utils_1 = require("viem/utils");
|
|
8
|
+
const zksync_1 = require("viem/zksync");
|
|
9
|
+
const getEip712Domain_js_1 = require("../utils/getEip712Domain.js");
|
|
10
|
+
async function toOwner({ owner, address, }) {
|
|
11
|
+
if ("type" in owner && owner.type === "local") {
|
|
12
|
+
return owner;
|
|
13
|
+
}
|
|
14
|
+
let walletClient = undefined;
|
|
15
|
+
if ("request" in owner) {
|
|
16
|
+
if (!address) {
|
|
17
|
+
try {
|
|
18
|
+
[address] = await owner.request({
|
|
19
|
+
method: "eth_requestAccounts",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
[address] = await owner.request({
|
|
24
|
+
method: "eth_accounts",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!address) {
|
|
29
|
+
throw new Error("address is required");
|
|
30
|
+
}
|
|
31
|
+
walletClient = (0, viem_1.createWalletClient)({
|
|
32
|
+
account: address,
|
|
33
|
+
transport: (0, viem_1.custom)(owner),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (!walletClient) {
|
|
37
|
+
walletClient = owner;
|
|
38
|
+
}
|
|
39
|
+
return (0, accounts_1.toAccount)({
|
|
40
|
+
address: walletClient.account.address,
|
|
41
|
+
async signMessage({ message }) {
|
|
42
|
+
return walletClient.signMessage({ message });
|
|
43
|
+
},
|
|
44
|
+
async signTransaction(transaction) {
|
|
45
|
+
const signableTransaction = {
|
|
46
|
+
...transaction,
|
|
47
|
+
from: this.address,
|
|
48
|
+
type: "eip712",
|
|
49
|
+
};
|
|
50
|
+
const eip712DomainAndMessage = (0, getEip712Domain_js_1.getEip712Domain)(signableTransaction);
|
|
51
|
+
const digest = (0, viem_1.hashTypedData)(eip712DomainAndMessage);
|
|
52
|
+
const signedMessage = await walletClient.signMessage({ message: digest });
|
|
53
|
+
return (0, zksync_1.serializeTransaction)({
|
|
54
|
+
...signableTransaction,
|
|
55
|
+
customSignature: signedMessage,
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
async signTypedData(typedData) {
|
|
59
|
+
return (0, utils_1.getAction)(walletClient, actions_1.signTypedData, "signTypedData")(typedData);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/client/ecdsa/types.ts"],"names":[],"mappings":";;AA4BA,0BA+EC;AA3GD,+BAUkC;AAClC,4CAA0C;AAC1C,0CAA6C;AAC7C,sCAAuC;AACvC,wCAA6F;AAE7F,oEAA8D;AAYvD,KAAK,UAAU,OAAO,CAAoC,EAC/D,KAAK,EACL,OAAO,GAQR;IACC,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC9C,OAAO,KAAqB,CAAC;IAC/B,CAAC;IAED,IAAI,YAAY,GAEA,SAAS,CAAC;IAE1B,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,CAAC,OAAO,CAAC,GAAG,MAAO,KAA0B,CAAC,OAAO,CAAC;oBACpD,MAAM,EAAE,qBAAqB;iBAC9B,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,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AAa,EACb,eAAe,CAChB,CAAC,SAAgB,CAAC,CAAC;QACtB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -14,9 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.fetchAccount = exports.deployAccount = void 0;
|
|
18
|
-
var account_js_1 = require("./
|
|
19
|
-
Object.defineProperty(exports, "
|
|
20
|
-
Object.defineProperty(exports, "
|
|
17
|
+
exports.fetchAccount = exports.deployAccount = exports.fetchEcdsaAccount = exports.deployEcdsaAccount = void 0;
|
|
18
|
+
var account_js_1 = require("./ecdsa/actions/account.js");
|
|
19
|
+
Object.defineProperty(exports, "deployEcdsaAccount", { enumerable: true, get: function () { return account_js_1.deployAccount; } });
|
|
20
|
+
Object.defineProperty(exports, "fetchEcdsaAccount", { enumerable: true, get: function () { return account_js_1.fetchAccount; } });
|
|
21
|
+
var account_js_2 = require("./passkey/actions/account.js");
|
|
22
|
+
Object.defineProperty(exports, "deployAccount", { enumerable: true, get: function () { return account_js_2.deployAccount; } });
|
|
23
|
+
Object.defineProperty(exports, "fetchAccount", { enumerable: true, get: function () { return account_js_2.fetchAccount; } });
|
|
21
24
|
__exportStar(require("./session/client.js"), exports);
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAA2E;AAAlE,2GAAA,aAAa,OAAA;AAAE,0GAAA,YAAY,OAAA;AACpC,sDAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAAoH;AAA3G,gHAAA,aAAa,OAAsB;AAAE,+GAAA,YAAY,OAAqB;AAC/E,2DAA2E;AAAlE,2GAAA,aAAa,OAAA;AAAE,0GAAA,YAAY,OAAA;AACpC,sDAAoC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { toAccount } from "viem/accounts";
|
|
2
|
+
import { serializeTransaction } from "viem/zksync";
|
|
3
|
+
import { getEip712Domain } from "../utils/getEip712Domain.js";
|
|
4
|
+
import { toOwner } from "./types.js";
|
|
5
|
+
export async function toEcdsaAccount(parameters) {
|
|
6
|
+
const { address, owner } = parameters;
|
|
7
|
+
const localOwner = await toOwner({ owner, address });
|
|
8
|
+
const account = toAccount({
|
|
9
|
+
address,
|
|
10
|
+
async signMessage({ message }) {
|
|
11
|
+
return localOwner.signMessage({ message });
|
|
12
|
+
},
|
|
13
|
+
async signTransaction(transaction) {
|
|
14
|
+
const signableTransaction = {
|
|
15
|
+
...transaction,
|
|
16
|
+
from: this.address,
|
|
17
|
+
type: "eip712",
|
|
18
|
+
};
|
|
19
|
+
const eip712DomainAndMessage = getEip712Domain(signableTransaction);
|
|
20
|
+
const signature = await localOwner.signTypedData(eip712DomainAndMessage);
|
|
21
|
+
return serializeTransaction({
|
|
22
|
+
...signableTransaction,
|
|
23
|
+
customSignature: signature,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
async signTypedData(typedData) {
|
|
27
|
+
return localOwner.signTypedData(typedData);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
...account,
|
|
32
|
+
source: "ssoEcdsaAccount",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/client/ecdsa/account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAA4C,MAAM,aAAa,CAAC;AAE7F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAe,OAAO,EAAE,MAAM,YAAY,CAAC;AAalD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAoC;IAEpC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;IAEtC,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAErD,MAAM,OAAO,GAAG,SAAS,CAAC;QACxB,OAAO;QACP,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;YAC3B,OAAO,UAAU,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,WAAW;YAC/B,MAAM,mBAAmB,GAAG;gBAC1B,GAAG,WAAW;gBACd,IAAI,EAAE,IAAI,CAAC,OAAQ;gBACnB,IAAI,EAAE,QAAQ;aACwB,CAAC;YAEzC,MAAM,sBAAsB,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;YACpE,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC;YAEzE,OAAO,oBAAoB,CAAC;gBAC1B,GAAG,mBAAmB;gBACtB,eAAe,EAAE,SAAS;aAC3B,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,SAAS;YAC3B,OAAO,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,iBAAiB;KACV,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { concat, encodePacked, getAddress, keccak256, parseEventLogs, toHex } from "viem";
|
|
2
|
+
import { readContract, waitForTransactionReceipt, writeContract } from "viem/actions";
|
|
3
|
+
import { getGeneralPaymasterInput } from "viem/zksync";
|
|
4
|
+
import { AAFactoryAbi } from "../../../abi/AAFactory.js";
|
|
5
|
+
import {} from "../../../paymaster/index.js";
|
|
6
|
+
import { encodeModuleData, encodeSession } from "../../../utils/encoding.js";
|
|
7
|
+
import { noThrow } from "../../../utils/helpers.js";
|
|
8
|
+
const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
9
|
+
export const deployAccount = async (client, // Account deployer (any viem client)
|
|
10
|
+
args) => {
|
|
11
|
+
if (!args.salt) {
|
|
12
|
+
args.salt = crypto.getRandomValues(new Uint8Array(32));
|
|
13
|
+
}
|
|
14
|
+
if (args.prefix && args.prefix.length > 12)
|
|
15
|
+
throw new Error("prefix must not be longer than 12");
|
|
16
|
+
const uniqueId = concat([toHex(args.prefix || "", { size: 12 }), args.owner]);
|
|
17
|
+
const encodedSessionKeyModuleData = encodeModuleData({
|
|
18
|
+
address: args.contracts.session,
|
|
19
|
+
parameters: args.initialSession ? encodeSession(args.initialSession) : "0x",
|
|
20
|
+
});
|
|
21
|
+
let deployProxyArgs = {
|
|
22
|
+
account: client.account,
|
|
23
|
+
chain: client.chain,
|
|
24
|
+
address: args.contracts.accountFactory,
|
|
25
|
+
abi: AAFactoryAbi,
|
|
26
|
+
functionName: "deployProxySsoAccount",
|
|
27
|
+
args: [
|
|
28
|
+
uniqueId,
|
|
29
|
+
[encodedSessionKeyModuleData],
|
|
30
|
+
[args.owner],
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
if (args.paymaster) {
|
|
34
|
+
deployProxyArgs = {
|
|
35
|
+
...deployProxyArgs,
|
|
36
|
+
paymaster: args.paymaster.address,
|
|
37
|
+
paymasterInput: args.paymaster.paymasterInput ?? getGeneralPaymasterInput({ innerInput: "0x" }),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const transactionHash = await writeContract(client, deployProxyArgs);
|
|
41
|
+
if (args.onTransactionSent) {
|
|
42
|
+
noThrow(() => args.onTransactionSent?.(transactionHash));
|
|
43
|
+
}
|
|
44
|
+
const transactionReceipt = await waitForTransactionReceipt(client, { hash: transactionHash });
|
|
45
|
+
if (transactionReceipt.status !== "success")
|
|
46
|
+
throw new Error("Account deployment transaction reverted");
|
|
47
|
+
const accountCreatedEvent = parseEventLogs({ abi: AAFactoryAbi, logs: transactionReceipt.logs })
|
|
48
|
+
.find((log) => log && log.eventName === "AccountCreated");
|
|
49
|
+
if (!accountCreatedEvent) {
|
|
50
|
+
throw new Error("No contract address in transaction receipt");
|
|
51
|
+
}
|
|
52
|
+
const { accountAddress } = accountCreatedEvent.args;
|
|
53
|
+
return {
|
|
54
|
+
address: getAddress(accountAddress),
|
|
55
|
+
transactionReceipt: transactionReceipt,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export const fetchAccount = async (client, // Account deployer (any viem client)
|
|
59
|
+
args) => {
|
|
60
|
+
if (!args.contracts.accountFactory)
|
|
61
|
+
throw new Error("Account factory address is not set");
|
|
62
|
+
if (args.prefix && args.prefix.length > 12)
|
|
63
|
+
throw new Error("prefix must not be longer than 12");
|
|
64
|
+
const uniqueId = concat([toHex(args.prefix || "", { size: 12 }), args.owner]);
|
|
65
|
+
const accountId = keccak256(encodePacked(["bytes32", "address"], [uniqueId, client.account.address]));
|
|
66
|
+
if (!accountId)
|
|
67
|
+
throw new Error("No account ID provided");
|
|
68
|
+
const accountAddress = await readContract(client, {
|
|
69
|
+
abi: AAFactoryAbi,
|
|
70
|
+
address: args.contracts.accountFactory,
|
|
71
|
+
functionName: "accountMappings",
|
|
72
|
+
args: [accountId],
|
|
73
|
+
});
|
|
74
|
+
if (!accountAddress || accountAddress == NULL_ADDRESS)
|
|
75
|
+
throw new Error(`No account found for ID: ${accountId}`);
|
|
76
|
+
return {
|
|
77
|
+
address: accountAddress,
|
|
78
|
+
owner: args.owner,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -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AAY,EAAE,iBAAiB;QAC/B,IAAI,EAAE,CAAC,SAAS,CAAC;KAClB,CAAC,CAAC;IAEH,IAAI,CAAC,cAAc,IAAI,cAAc,IAAI,YAAY;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,SAAS,EAAE,CAAC,CAAC;IAEhH,OAAO;QACL,OAAO,EAAE,cAAc;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createClient, getAddress, publicActions, walletActions } from "viem";
|
|
2
|
+
import { eip712WalletActions } from "viem/zksync";
|
|
3
|
+
import { toEcdsaAccount } from "./account.js";
|
|
4
|
+
import { zksyncSsoEcdsaActions } from "./decorators/ecdsa.js";
|
|
5
|
+
import { zksyncSsoEcdsaWalletActions } from "./decorators/wallet.js";
|
|
6
|
+
export async function createZksyncEcdsaClient(_parameters) {
|
|
7
|
+
const parameters = {
|
|
8
|
+
..._parameters,
|
|
9
|
+
address: getAddress(_parameters.address),
|
|
10
|
+
key: _parameters.key || "zksync-sso-ecdsa-wallet",
|
|
11
|
+
name: _parameters.name || "ZKsync SSO ECDSA Client",
|
|
12
|
+
};
|
|
13
|
+
const account = await toEcdsaAccount({
|
|
14
|
+
address: parameters.address,
|
|
15
|
+
owner: parameters.owner,
|
|
16
|
+
});
|
|
17
|
+
const client = createClient({
|
|
18
|
+
...parameters,
|
|
19
|
+
account,
|
|
20
|
+
type: "walletClient",
|
|
21
|
+
})
|
|
22
|
+
.extend(() => ({
|
|
23
|
+
contracts: parameters.contracts,
|
|
24
|
+
}))
|
|
25
|
+
.extend(publicActions)
|
|
26
|
+
.extend(walletActions)
|
|
27
|
+
.extend(eip712WalletActions())
|
|
28
|
+
.extend(zksyncSsoEcdsaActions)
|
|
29
|
+
.extend(zksyncSsoEcdsaWalletActions);
|
|
30
|
+
return client;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=client.js.map
|
|
@@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|
+
import {} from "viem";
|
|
2
|
+
import { createSession, revokeSession, } from "../../session/actions/session.js";
|
|
3
|
+
export const zksyncSsoEcdsaActions = (client) => {
|
|
4
|
+
return {
|
|
5
|
+
createSession: async (args) => {
|
|
6
|
+
return await createSession(client, {
|
|
7
|
+
...args,
|
|
8
|
+
contracts: client.contracts,
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
revokeSession: async (args) => {
|
|
12
|
+
return await revokeSession(client, {
|
|
13
|
+
...args,
|
|
14
|
+
contracts: client.contracts,
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=ecdsa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecdsa.js","sourceRoot":"","sources":["../../../../../src/client/ecdsa/decorators/ecdsa.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,MAAM,MAAM,CAAC;AAElD,OAAO,EACL,aAAa,EACb,aAAa,GACd,MAAM,kCAAkC,CAAC;AAQ1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAGnC,MAAsD,EAAE,EAAE;IAC1D,OAAO;QACL,aAAa,EAAE,KAAK,EAAE,IAA0C,EAAE,EAAE;YAClE,OAAO,MAAM,aAAa,CAAC,MAAM,EAAE;gBACjC,GAAG,IAAI;gBACP,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,CAAC;QACD,aAAa,EAAE,KAAK,EAAE,IAA0C,EAAE,EAAE;YAClE,OAAO,MAAM,aAAa,CAAC,MAAM,EAAE;gBACjC,GAAG,IAAI;gBACP,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { bytesToHex, formatTransaction } from "viem";
|
|
2
|
+
import { deployContract, getAddresses, getChainId, sendRawTransaction, signMessage, signTypedData, writeContract } from "viem/actions";
|
|
3
|
+
import { signTransaction } from "viem/zksync";
|
|
4
|
+
import { getTransactionWithPaymasterData } from "../../../paymaster/index.js";
|
|
5
|
+
import { sendEip712Transaction } from "../../session/actions/sendEip712Transaction.js";
|
|
6
|
+
export function zksyncSsoEcdsaWalletActions(client) {
|
|
7
|
+
return {
|
|
8
|
+
deployContract: (args) => deployContract(client, args),
|
|
9
|
+
getAddresses: () => getAddresses(client),
|
|
10
|
+
getChainId: () => getChainId(client),
|
|
11
|
+
sendRawTransaction: (args) => sendRawTransaction(client, args),
|
|
12
|
+
sendTransaction: async (args) => {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const unformattedTx = Object.assign({}, args);
|
|
15
|
+
if ("eip712Meta" in unformattedTx) {
|
|
16
|
+
const eip712Meta = unformattedTx.eip712Meta;
|
|
17
|
+
unformattedTx.gasPerPubdata = eip712Meta.gasPerPubdata ? BigInt(eip712Meta.gasPerPubdata) : undefined;
|
|
18
|
+
unformattedTx.factoryDeps = eip712Meta.factoryDeps;
|
|
19
|
+
unformattedTx.customSignature = eip712Meta.customSignature;
|
|
20
|
+
unformattedTx.paymaster = eip712Meta.paymasterParams?.paymaster;
|
|
21
|
+
unformattedTx.paymasterInput = eip712Meta.paymasterParams?.paymasterInput ? bytesToHex(new Uint8Array(eip712Meta.paymasterParams?.paymasterInput)) : undefined;
|
|
22
|
+
delete unformattedTx.eip712Meta;
|
|
23
|
+
}
|
|
24
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
25
|
+
const { chainId: _, ...unformattedTxWithPaymaster } = await getTransactionWithPaymasterData(client.chain.id, client.account.address, unformattedTx, client.paymasterHandler);
|
|
26
|
+
const formatters = client.chain?.formatters;
|
|
27
|
+
const format = formatters?.transaction?.format || formatTransaction;
|
|
28
|
+
const tx = {
|
|
29
|
+
...format(unformattedTxWithPaymaster),
|
|
30
|
+
type: "eip712",
|
|
31
|
+
};
|
|
32
|
+
return await sendEip712Transaction(client, tx);
|
|
33
|
+
},
|
|
34
|
+
signMessage: (args) => signMessage(client, args),
|
|
35
|
+
signTransaction: async (args) => {
|
|
36
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
37
|
+
const { chainId: _, ...unformattedTxWithPaymaster } = await getTransactionWithPaymasterData(client.chain.id, client.account.address, args, client.paymasterHandler);
|
|
38
|
+
return signTransaction(client, {
|
|
39
|
+
...args,
|
|
40
|
+
unformattedTxWithPaymaster,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
signTypedData: (args) => signTypedData(client, args),
|
|
44
|
+
writeContract: (args) => writeContract(client, args),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../../../src/client/ecdsa/decorators/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAiC,iBAAiB,EAA2D,MAAM,MAAM,CAAC;AAC3J,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACvI,OAAO,EAAE,eAAe,EAAwD,MAAM,aAAa,CAAC;AAEpG,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAOvF,MAAM,UAAU,2BAA2B,CAIzC,MAAsD;IACtD,OAAO;QACL,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC;QACtD,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;QACxC,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QACpC,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAA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